Skip to content

Pipeline Versions #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions components/KernDropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Fragment, useEffect, useMemo, useRef, useState } from 'react'
import { Fragment, useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { Menu, Transition } from '@headlessui/react'
import { KernDropdownProps } from '../types/dropdown';
import { combineClassNames } from '../../javascript-functions/general';
Expand All @@ -10,6 +10,7 @@ import useOnClickOutside from '../hooks/useHooks/useOnClickOutside';
import { useDefaults } from '../hooks/useDefaults';
import SVGIcon from './SVGIcon';
import { CSSProperties } from 'react';
import useRefFor from '../hooks/useRefFor';

const DEFAULTS = { fontSizeClass: 'text-xs' };

Expand All @@ -20,12 +21,16 @@ export default function KernDropdown(props: KernDropdownProps) {
const [disabledOptions, setDisabledOptions] = useState<boolean[]>([]);
const [backgroundColors, setBackgroundColors] = useState<string[]>([]);
const [searchText, setSearchText] = useState('');
const [isOpen, setIsOpen] = useState(false);
const [isOpen, setIsOpen_] = useState(false);
const [selectedCheckboxes, setSelectedCheckboxes] = useState<any[]>([]);
const [position, setPosition] = useState(null);
const [savedIndex, setSavedIndex] = useState(null);

const [defaultProps] = useDefaults<{ fontSizeClass: string }>(props, DEFAULTS);
const forceOpenRef = useRefFor(props.forceOverwriteOpen);

// catches all isOpen changes & sets the value if it is not forced to be open
const setIsOpen = useCallback((value: boolean) => { if ((!value && !forceOpenRef.current) || value) setIsOpen_(value) }, [])

const dropdownRef = useRef(null);
useOnClickOutside(dropdownRef, () => setIsOpen(false));
Expand Down Expand Up @@ -238,6 +243,7 @@ export default function KernDropdown(props: KernDropdownProps) {
backgroundColors[index], props.useDifferentTextColor && props.useDifferentTextColor[index] ? 'text-' + props.differentTextColor + '-700' : active && !backgroundColors[index] ? "bg-gray-100 text-gray-900" : "text-gray-700",
props.iconsArray && props.iconsArray[index] ? "px-2" : "px-4",
defaultProps.fontSizeClass,
props.dropdownAdd ? "inline-flex w-full justify-between" : "",
"py-2 flex items-center"
)}
onClick={() => {
Expand All @@ -260,6 +266,7 @@ export default function KernDropdown(props: KernDropdownProps) {
<span className='truncate'>{option}</span>
{props.onClickDelete && <div className="ml-auto flex items-center cursor-pointer hover:bg-gray-200" onClick={(e) => { e.stopPropagation(); props.onClickDelete(option) }}><IconTrashXFilled size={20} /></div>}
{props.optionsHaveLink && <a href={props.linkList[index]} target="_blank" className="h-4 w-4 mr-2 ml-auto flex items-center cursor-pointer"><IconExternalLink size={16} /></a>}
{props.dropdownAdd && props.dropdownAdd[index]}
</label>
</Tooltip>
</div>
Expand Down
4 changes: 3 additions & 1 deletion components/LocalStorageDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export const LocalStorageDropdown = forwardRef((_props: LocalStorageDropdownProp
setInputText(inputText)
onOptionSelected(inputText)
}}
disabled={props.disabled}

/> :

Expand All @@ -121,7 +122,8 @@ export const LocalStorageDropdown = forwardRef((_props: LocalStorageDropdownProp
}}
className="h-9 w-full text-sm border-gray-300 rounded-md placeholder-italic border text-gray-900 pl-4 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-gray-300 focus:ring-offset-2 focus:ring-offset-gray-100"
placeholder="Enter value..."
onFocus={(event) => event.target.select()} />
onFocus={(event) => event.target.select()}
disabled={props.disabled} />
}


Expand Down
4 changes: 4 additions & 0 deletions types/dropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
* @fontSizeClass {string} - The font size of the dropdown items
* @ignoreDisabledForSearch {boolean} - If the search bar should ignore the disabled options
* @positionDropdown {string} - The position of the dropdown
* @dropdownAdd {JSX.Element} - array of JSX elements that will be added to the dropdown items
* @forceOverwriteOpen {boolean} - forces the dropdown to stay open until set to false/undefined
*/
export type KernDropdownProps = {
buttonName?: string;
Expand Down Expand Up @@ -84,6 +86,8 @@ export type KernDropdownProps = {
ignoreDisabledForSearch?: boolean;
positionDropdown?: "top" | "bottom" | "left" | "right";
scrollAfterNOptions?: number;
dropdownAdd?: JSX.Element[];
forceOverwriteOpen?: boolean;
}

export type AppSelectionDropdownProps = {
Expand Down
1 change: 1 addition & 0 deletions types/localStorageDropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type LocalStorageDropdownProps = {
onOptionSelected?: (option: string) => void;
searchDefaultValue?: string;
excludedFromStorage?: { values: string[]; compareOptions?: CompareOptions[] }; // if the value is in this list it will not be added to the storage //setting this to null will assume all values are valid
disabled?: boolean;
}


Expand Down