@deskpro/deskpro-ui 5.0.4 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/Drilldown/CreateNewOption.js +18 -0
- package/dist/cjs/components/Drilldown/CreateNewOption.js.map +1 -0
- package/dist/cjs/components/Drilldown/Drilldown.js +78 -197
- package/dist/cjs/components/Drilldown/Drilldown.js.map +1 -1
- package/dist/cjs/components/Drilldown/DrilldownItem.js +65 -0
- package/dist/cjs/components/Drilldown/DrilldownItem.js.map +1 -0
- package/dist/cjs/components/Drilldown/DrilldownList.js +133 -0
- package/dist/cjs/components/Drilldown/DrilldownList.js.map +1 -0
- package/dist/cjs/components/Drilldown/DrilldownResetButton.js +2 -2
- package/dist/cjs/components/Drilldown/DrilldownResetButton.js.map +1 -1
- package/dist/cjs/components/Drilldown/hooks/useFilteredItems.js +42 -0
- package/dist/cjs/components/Drilldown/hooks/useFilteredItems.js.map +1 -0
- package/dist/cjs/components/Drilldown/hooks/useTreeify.js +63 -0
- package/dist/cjs/components/Drilldown/hooks/useTreeify.js.map +1 -0
- package/dist/cjs/components/Drilldown/{useUpdateItems.js → hooks/useUpdateItems.js} +2 -2
- package/dist/cjs/components/Drilldown/hooks/useUpdateItems.js.map +1 -0
- package/dist/cjs/components/Drilldown/index.js +9 -7
- package/dist/cjs/components/Drilldown/index.js.map +1 -1
- package/dist/cjs/components/Drilldown/styles.js +14 -1
- package/dist/cjs/components/Drilldown/styles.js.map +1 -1
- package/dist/cjs/components/Drilldown/types.js.map +1 -1
- package/dist/cjs/components/Drilldown/utility.js +45 -22
- package/dist/cjs/components/Drilldown/utility.js.map +1 -1
- package/dist/cjs/hooks/usePrevious.js +17 -0
- package/dist/cjs/hooks/usePrevious.js.map +1 -0
- package/dist/deskpro-ui.d.ts +34 -44
- package/dist/esm/components/Drilldown/CreateNewOption.js +14 -0
- package/dist/esm/components/Drilldown/CreateNewOption.js.map +1 -0
- package/dist/esm/components/Drilldown/Drilldown.js +78 -193
- package/dist/esm/components/Drilldown/Drilldown.js.map +1 -1
- package/dist/esm/components/Drilldown/DrilldownItem.js +61 -0
- package/dist/esm/components/Drilldown/DrilldownItem.js.map +1 -0
- package/dist/esm/components/Drilldown/DrilldownList.js +127 -0
- package/dist/esm/components/Drilldown/DrilldownList.js.map +1 -0
- package/dist/esm/components/Drilldown/DrilldownResetButton.js +1 -1
- package/dist/esm/components/Drilldown/DrilldownResetButton.js.map +1 -1
- package/dist/esm/components/Drilldown/hooks/useFilteredItems.js +38 -0
- package/dist/esm/components/Drilldown/hooks/useFilteredItems.js.map +1 -0
- package/dist/esm/components/Drilldown/hooks/useTreeify.js +54 -0
- package/dist/esm/components/Drilldown/hooks/useTreeify.js.map +1 -0
- package/dist/esm/components/Drilldown/{useUpdateItems.js → hooks/useUpdateItems.js} +2 -2
- package/dist/esm/components/Drilldown/hooks/useUpdateItems.js.map +1 -0
- package/dist/esm/components/Drilldown/index.js +5 -2
- package/dist/esm/components/Drilldown/index.js.map +1 -1
- package/dist/esm/components/Drilldown/styles.js +13 -0
- package/dist/esm/components/Drilldown/styles.js.map +1 -1
- package/dist/esm/components/Drilldown/types.js.map +1 -1
- package/dist/esm/components/Drilldown/utility.js +40 -20
- package/dist/esm/components/Drilldown/utility.js.map +1 -1
- package/dist/esm/hooks/usePrevious.js +13 -0
- package/dist/esm/hooks/usePrevious.js.map +1 -0
- package/package.json +8 -4
- package/dist/cjs/components/Drilldown/useUpdateItems.js.map +0 -1
- package/dist/esm/components/Drilldown/useUpdateItems.js.map +0 -1
package/dist/deskpro-ui.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ import { FlattenSimpleInterpolation } from 'styled-components';
|
|
|
26
26
|
import { ForwardRefComponent } from 'framer-motion';
|
|
27
27
|
import { ForwardRefExoticComponent } from 'react';
|
|
28
28
|
import { GlobalStyleComponent } from 'styled-components';
|
|
29
|
+
import type { HierarchyNode } from 'd3-hierarchy';
|
|
29
30
|
import { HTMLAttributes } from 'react';
|
|
30
31
|
import { HTMLMotionProps } from 'framer-motion';
|
|
31
32
|
import type { IconDefinition } from '@fortawesome/fontawesome-svg-core';
|
|
@@ -119,7 +120,7 @@ is?: string | undefined;
|
|
|
119
120
|
'aria-colindex'?: number | undefined;
|
|
120
121
|
'aria-colspan'?: number | undefined;
|
|
121
122
|
'aria-controls'?: string | undefined;
|
|
122
|
-
'aria-current'?: boolean | "time" | "true" | "false" | "
|
|
123
|
+
'aria-current'?: boolean | "time" | "true" | "false" | "page" | "location" | "step" | "date" | undefined;
|
|
123
124
|
'aria-describedby'?: string | undefined;
|
|
124
125
|
'aria-details'?: string | undefined;
|
|
125
126
|
'aria-disabled'?: (boolean | "true" | "false") | undefined;
|
|
@@ -540,7 +541,7 @@ is?: string | undefined;
|
|
|
540
541
|
'aria-colindex'?: number | undefined;
|
|
541
542
|
'aria-colspan'?: number | undefined;
|
|
542
543
|
'aria-controls'?: string | undefined;
|
|
543
|
-
'aria-current'?: boolean | "time" | "true" | "false" | "
|
|
544
|
+
'aria-current'?: boolean | "time" | "true" | "false" | "page" | "location" | "step" | "date" | undefined;
|
|
544
545
|
'aria-describedby'?: string | undefined;
|
|
545
546
|
'aria-details'?: string | undefined;
|
|
546
547
|
'aria-disabled'?: (boolean | "true" | "false") | undefined;
|
|
@@ -838,7 +839,7 @@ is?: string | undefined;
|
|
|
838
839
|
'aria-colindex'?: number | undefined;
|
|
839
840
|
'aria-colspan'?: number | undefined;
|
|
840
841
|
'aria-controls'?: string | undefined;
|
|
841
|
-
'aria-current'?: boolean | "time" | "true" | "false" | "
|
|
842
|
+
'aria-current'?: boolean | "time" | "true" | "false" | "page" | "location" | "step" | "date" | undefined;
|
|
842
843
|
'aria-describedby'?: string | undefined;
|
|
843
844
|
'aria-details'?: string | undefined;
|
|
844
845
|
'aria-disabled'?: (boolean | "true" | "false") | undefined;
|
|
@@ -1200,7 +1201,7 @@ is?: string | undefined;
|
|
|
1200
1201
|
'aria-colindex'?: number | undefined;
|
|
1201
1202
|
'aria-colspan'?: number | undefined;
|
|
1202
1203
|
'aria-controls'?: string | undefined;
|
|
1203
|
-
'aria-current'?: boolean | "time" | "true" | "false" | "
|
|
1204
|
+
'aria-current'?: boolean | "time" | "true" | "false" | "page" | "location" | "step" | "date" | undefined;
|
|
1204
1205
|
'aria-describedby'?: string | undefined;
|
|
1205
1206
|
'aria-details'?: string | undefined;
|
|
1206
1207
|
'aria-disabled'?: (boolean | "true" | "false") | undefined;
|
|
@@ -1731,7 +1732,7 @@ declare type DpCustomIconsId = "active-call" | "admin" | "advanced-filter" | "ag
|
|
|
1731
1732
|
* </Drilldown>
|
|
1732
1733
|
* ```
|
|
1733
1734
|
*/
|
|
1734
|
-
export declare function Drilldown<T, TargetRef extends HTMLElement
|
|
1735
|
+
export declare function Drilldown<T, TargetRef extends HTMLElement>({ type, children, options, inputValue, searchPlaceholder, placement, showInternalSearch, isLoading, usePortal, closeOnSelect, isOpen: isOpenProp, renderCreateNewOption, onCreateNewOption, hideIcons, iconColumnWidth, containerWidth, containerHeight, onSelectOption, onInputChange, onFetchMore, onClear, onClose, onOpen, onInputReturn, tabProps, disabled, fetchMoreText, autoscrollText, emptySearchResultsText, externalLinkIcon, selectedIcon, layer, animationDuration, onDrilldown, onDrilldownAnimationEnd, onDrillupAnimationEnd, backText, filterPredicate, }: DrilldownProps<T, TargetRef>): JSX.Element;
|
|
1735
1736
|
|
|
1736
1737
|
declare interface DrilldownBaseProps<T, TargetRef extends HTMLElement> {
|
|
1737
1738
|
/** Event handler for when an option is selected */
|
|
@@ -1789,6 +1790,8 @@ declare interface DrilldownBaseProps<T, TargetRef extends HTMLElement> {
|
|
|
1789
1790
|
fetchMoreText: ReactNode;
|
|
1790
1791
|
/** The text to show for the autoscroll button */
|
|
1791
1792
|
autoscrollText: ReactNode;
|
|
1793
|
+
/** The text to show for the autoscroll button */
|
|
1794
|
+
emptySearchResultsText: ReactNode;
|
|
1792
1795
|
externalLinkIcon: AnyIcon;
|
|
1793
1796
|
selectedIcon: AnyIcon;
|
|
1794
1797
|
/** Event handler that returns input value after enter has been pressed */
|
|
@@ -1896,8 +1899,8 @@ export declare interface DrilldownFlatProps<T, TargetRef extends HTMLElement> ex
|
|
|
1896
1899
|
/** Event handler for when an option is selected */
|
|
1897
1900
|
/** Event handler for when the search input value changes */
|
|
1898
1901
|
onInputChange?: (input: string, pathToSelectedItem: PathToSelectedItem) => void;
|
|
1899
|
-
/**
|
|
1900
|
-
|
|
1902
|
+
/** Predicate for filtering items */
|
|
1903
|
+
filterPredicate?: (item: DrilldownItemTreeType<T>, input: string) => boolean;
|
|
1901
1904
|
/** Event handler that it called when triggering a drilldown, after animation was run */
|
|
1902
1905
|
onDrilldownAnimationEnd?: (item: DrilldownValueFlatType<T> | undefined, pathToSelectedItem: PathToSelectedItem) => Promise<void>;
|
|
1903
1906
|
}
|
|
@@ -1939,7 +1942,7 @@ export declare const DrilldownInternalSearchInputContainer: StyledComponent<"div
|
|
|
1939
1942
|
/**
|
|
1940
1943
|
* @public
|
|
1941
1944
|
*/
|
|
1942
|
-
export declare function DrilldownItem<T = unknown>({ value, active, onSelect, onSelectIcon, onClickSubItem, hideIcons, iconColumnWidth, selectedIcon, externalLinkIcon, handleDrilldown, dataKey, subItems, }: DrilldownItemProps<T>): JSX.Element;
|
|
1945
|
+
export declare function DrilldownItem<T = unknown>({ value, active, onSelect, onSelectIcon, onClickSubItem, hideIcons, iconColumnWidth, selectedIcon, externalLinkIcon, handleDrilldown, dataKey, subItems, isSearchResult, inputValue, flatItemTree, }: DrilldownItemProps<T>): JSX.Element;
|
|
1943
1946
|
|
|
1944
1947
|
/**
|
|
1945
1948
|
* @public
|
|
@@ -1985,6 +1988,9 @@ export declare interface DrilldownItemProps<T = unknown> {
|
|
|
1985
1988
|
handleDrilldown: (item: DrilldownValueType<T>) => Promise<void>;
|
|
1986
1989
|
dataKey: string;
|
|
1987
1990
|
subItems: DrilldownItemType<T>[] | undefined;
|
|
1991
|
+
isSearchResult?: boolean;
|
|
1992
|
+
inputValue?: string;
|
|
1993
|
+
flatItemTree?: HierarchyNode<DrilldownValueFlatType<T>>;
|
|
1988
1994
|
}
|
|
1989
1995
|
|
|
1990
1996
|
/**
|
|
@@ -2030,7 +2036,18 @@ export declare type DrilldownProps<T, TargetRef extends HTMLElement> = Drilldown
|
|
|
2030
2036
|
/**
|
|
2031
2037
|
* @public
|
|
2032
2038
|
*/
|
|
2033
|
-
export declare function drilldownRenderOptions<T = string>(options
|
|
2039
|
+
export declare function drilldownRenderOptions<T = string>({ options, handleSelectOption, handleDrilldown, activeItem, selectedIcon, externalLinkIcon, hideIcons, iconColumnWidth, }: DrilldownRenderOptionsProps<T>): (value: DrilldownItemType<T>, index: number, array: DrilldownItemType<T>[]) => ReactNode;
|
|
2040
|
+
|
|
2041
|
+
declare type DrilldownRenderOptionsProps<T> = {
|
|
2042
|
+
options: DrilldownItemType<T>[];
|
|
2043
|
+
handleSelectOption: (value: DrilldownValueType<T>) => void;
|
|
2044
|
+
handleDrilldown: (item: DrilldownValueType<T>) => Promise<void>;
|
|
2045
|
+
activeItem: ActiveItem<T>;
|
|
2046
|
+
selectedIcon: AnyIcon;
|
|
2047
|
+
externalLinkIcon: AnyIcon;
|
|
2048
|
+
hideIcons?: boolean;
|
|
2049
|
+
iconColumnWidth?: number;
|
|
2050
|
+
};
|
|
2034
2051
|
|
|
2035
2052
|
/**
|
|
2036
2053
|
* @public
|
|
@@ -2137,8 +2154,8 @@ export declare interface DrilldownTreeProps<T, TargetRef extends HTMLElement> ex
|
|
|
2137
2154
|
/** Event handler for when an option is selected */
|
|
2138
2155
|
/** Event handler for when the search input value changes */
|
|
2139
2156
|
onInputChange?: (input: string, pathToSelectedItem: PathToSelectedItem) => void;
|
|
2140
|
-
/**
|
|
2141
|
-
|
|
2157
|
+
/** Predicate for filtering items */
|
|
2158
|
+
filterPredicate?: (item: DrilldownItemTreeType<T>, input: string) => boolean;
|
|
2142
2159
|
/** Event handler that it called when triggering a drilldown, after animation was run */
|
|
2143
2160
|
onDrilldownAnimationEnd?: (item: DrilldownValueTreeType<T> | undefined, pathToSelectedItem: PathToSelectedItem) => Promise<void>;
|
|
2144
2161
|
}
|
|
@@ -2524,33 +2541,6 @@ export declare interface FaIconAvatarProps {
|
|
|
2524
2541
|
iconStyles?: CSSProperties;
|
|
2525
2542
|
}
|
|
2526
2543
|
|
|
2527
|
-
/**
|
|
2528
|
-
* A helper function to make it easier to filter the items at the current depth
|
|
2529
|
-
* e.g. on search input change (see WithSearch story)
|
|
2530
|
-
*
|
|
2531
|
-
* Returns the full items array with only the deepest sub items of the path updated
|
|
2532
|
-
* @public
|
|
2533
|
-
*/
|
|
2534
|
-
export declare function filterCurrentTreeItems<T>(items: DrilldownItemTreeType<T>[], pathToSelectedItem: {
|
|
2535
|
-
key: string;
|
|
2536
|
-
searchTerm?: string;
|
|
2537
|
-
}[], input: string, filterItemsCb: FilterItemsTreeCb<T>, depth?: number): DrilldownItemTreeType<T>[];
|
|
2538
|
-
|
|
2539
|
-
/**
|
|
2540
|
-
* @public
|
|
2541
|
-
*/
|
|
2542
|
-
export declare type FilterItemsCb<T> = (items: DrilldownItemTreeType<T>[], input: string) => DrilldownItemTreeType<T>[];
|
|
2543
|
-
|
|
2544
|
-
/**
|
|
2545
|
-
* @public
|
|
2546
|
-
*/
|
|
2547
|
-
export declare type FilterItemsFlatCb<T> = (items: DrilldownItemFlatType<T>[], input: string, parentKey?: string) => DrilldownItemFlatType<T>[];
|
|
2548
|
-
|
|
2549
|
-
/**
|
|
2550
|
-
* @public
|
|
2551
|
-
*/
|
|
2552
|
-
export declare type FilterItemsTreeCb<T> = (items: DrilldownItemTreeType<T>[], input: string) => DrilldownItemTreeType<T>[];
|
|
2553
|
-
|
|
2554
2544
|
/**
|
|
2555
2545
|
* Wrapper around Formik's useField hook and ErrorMessage component
|
|
2556
2546
|
* @public
|
|
@@ -2669,7 +2659,7 @@ export declare const GroupByButton: React_2.ForwardRefExoticComponent<{
|
|
|
2669
2659
|
'aria-colindex'?: number | undefined;
|
|
2670
2660
|
'aria-colspan'?: number | undefined;
|
|
2671
2661
|
'aria-controls'?: string | undefined;
|
|
2672
|
-
'aria-current'?: boolean | "time" | "true" | "false" | "
|
|
2662
|
+
'aria-current'?: boolean | "time" | "true" | "false" | "page" | "location" | "step" | "date" | undefined;
|
|
2673
2663
|
'aria-describedby'?: string | undefined;
|
|
2674
2664
|
'aria-details'?: string | undefined;
|
|
2675
2665
|
'aria-disabled'?: (boolean | "true" | "false") | undefined;
|
|
@@ -3209,7 +3199,7 @@ is?: string | undefined;
|
|
|
3209
3199
|
'aria-colindex'?: number | undefined;
|
|
3210
3200
|
'aria-colspan'?: number | undefined;
|
|
3211
3201
|
'aria-controls'?: string | undefined;
|
|
3212
|
-
'aria-current'?: boolean | "time" | "true" | "false" | "
|
|
3202
|
+
'aria-current'?: boolean | "time" | "true" | "false" | "page" | "location" | "step" | "date" | undefined;
|
|
3213
3203
|
'aria-describedby'?: string | undefined;
|
|
3214
3204
|
'aria-details'?: string | undefined;
|
|
3215
3205
|
'aria-disabled'?: (boolean | "true" | "false") | undefined;
|
|
@@ -3823,7 +3813,7 @@ export declare type MenuDividerProps = HTMLAttributes<HTMLLIElement> & {
|
|
|
3823
3813
|
/**
|
|
3824
3814
|
* @public
|
|
3825
3815
|
*/
|
|
3826
|
-
export declare const MenuItem: React_2.ForwardRefExoticComponent<Pick<MenuItemProps, "label" | "slot" | "style" | "title" | "children" | "className" | "type" | "icon" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "media" | "target" | "href" | "
|
|
3816
|
+
export declare const MenuItem: React_2.ForwardRefExoticComponent<Pick<MenuItemProps, "label" | "slot" | "style" | "title" | "children" | "className" | "type" | "icon" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "media" | "target" | "href" | "key" | "download" | "hrefLang" | "ping" | "rel" | "referrerPolicy" | "disabled" | "rightIcon" | "active" | "iconColor" | "useHoverState" | "htmlTitle"> & React_2.RefAttributes<HTMLAnchorElement>>;
|
|
3827
3817
|
|
|
3828
3818
|
/**
|
|
3829
3819
|
* @public
|
|
@@ -4005,7 +3995,7 @@ is?: string | undefined;
|
|
|
4005
3995
|
'aria-colindex'?: number | undefined;
|
|
4006
3996
|
'aria-colspan'?: number | undefined;
|
|
4007
3997
|
'aria-controls'?: string | undefined;
|
|
4008
|
-
'aria-current'?: boolean | "time" | "true" | "false" | "
|
|
3998
|
+
'aria-current'?: boolean | "time" | "true" | "false" | "page" | "location" | "step" | "date" | undefined;
|
|
4009
3999
|
'aria-describedby'?: string | undefined;
|
|
4010
4000
|
'aria-details'?: string | undefined;
|
|
4011
4001
|
'aria-disabled'?: (boolean | "true" | "false") | undefined;
|
|
@@ -4340,7 +4330,7 @@ is?: string | undefined;
|
|
|
4340
4330
|
'aria-colindex'?: number | undefined;
|
|
4341
4331
|
'aria-colspan'?: number | undefined;
|
|
4342
4332
|
'aria-controls'?: string | undefined;
|
|
4343
|
-
'aria-current'?: boolean | "time" | "true" | "false" | "
|
|
4333
|
+
'aria-current'?: boolean | "time" | "true" | "false" | "page" | "location" | "step" | "date" | undefined;
|
|
4344
4334
|
'aria-describedby'?: string | undefined;
|
|
4345
4335
|
'aria-details'?: string | undefined;
|
|
4346
4336
|
'aria-disabled'?: (boolean | "true" | "false") | undefined;
|
|
@@ -4552,7 +4542,7 @@ formNoValidate?: boolean | undefined;
|
|
|
4552
4542
|
formTarget?: string | undefined;
|
|
4553
4543
|
} & Omit<CommonButtonProps, "icon" | "size" | "fill" | "rightIcon" | "minimal"> & {
|
|
4554
4544
|
icon?: AnyIcon | IconProps | null | undefined;
|
|
4555
|
-
placement?: "
|
|
4545
|
+
placement?: "right-top" | "right-bottom" | "left-top" | "left-bottom" | "middle-top" | "middle-bottom" | undefined;
|
|
4556
4546
|
rightIcon?: AnyIcon | IconProps | null | undefined;
|
|
4557
4547
|
} & React_2.RefAttributes<HTMLButtonElement>>, DefaultTheme, {
|
|
4558
4548
|
position?: "absolute" | "relative" | undefined;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as S from "./styles";
|
|
2
|
+
import { Icon } from "../Icon";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
/**
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export const CreateNewOption = ({ text, icon, onClick, resetButton, iconColor, active, }) => {
|
|
8
|
+
return (React.createElement(S.CreateNewItemLayout, { active: active, className: resetButton ? "resetButton" : "", onClick: onClick },
|
|
9
|
+
React.createElement(S.DrilldownLabel, null,
|
|
10
|
+
React.createElement(S.DrilldownIcon, null,
|
|
11
|
+
React.createElement(Icon, { themeColor: iconColor, icon: icon })),
|
|
12
|
+
text)));
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=CreateNewOption.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CreateNewOption.js","sourceRoot":"","sources":["../../../../src/components/Drilldown/CreateNewOption.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAW,IAAI,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAgB/B;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EAC9B,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,WAAW,EACX,SAAS,EACT,MAAM,GACe,EAAe,EAAE;IACtC,OAAO,CACL,oBAAC,CAAC,CAAC,mBAAmB,IACpB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,EAC3C,OAAO,EAAE,OAAO;QAEhB,oBAAC,CAAC,CAAC,cAAc;YACf,oBAAC,CAAC,CAAC,aAAa;gBACd,oBAAC,IAAI,IAAC,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,GAAI,CAC3B;YACjB,IAAI,CACY,CACG,CACzB,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,93 +1,17 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef, useState, } from "react";
|
|
3
3
|
import { usePopper } from "react-popper";
|
|
4
4
|
import * as S from "./styles";
|
|
5
|
-
import {
|
|
6
|
-
import { faSearch, faTimes } from "@fortawesome/free-solid-svg-icons";
|
|
5
|
+
import { isStickyFooterType, isStickyHeaderType, isValueFlatType } from "./types";
|
|
7
6
|
import { getFlatItemsFromPath, getFlatValueSubItems, getTreeItemsFromPath, mergeRefs, } from "./utility";
|
|
8
|
-
import { Infinite } from "../Infinite";
|
|
9
|
-
import { Input } from "../Input";
|
|
10
|
-
import { IconButton } from "../Button";
|
|
11
|
-
import { Spinner } from "../Spinner";
|
|
12
7
|
import { Portal } from "../Portal";
|
|
13
|
-
import styled from "styled-components";
|
|
14
|
-
import { Icon, isAnyIcon, isIconProps } from "../Icon";
|
|
15
8
|
import { Stack } from "../../layout/Stack";
|
|
16
9
|
import { TabBar } from "../TabBar/TabBar";
|
|
17
|
-
import { useUpdateItems } from "./useUpdateItems";
|
|
18
|
-
import { ChevronLeftIcon, ChevronRightIcon } from "@heroicons/react/outline";
|
|
19
|
-
import { TSpan } from "../Typography";
|
|
10
|
+
import { useUpdateItems } from "./hooks/useUpdateItems";
|
|
20
11
|
import { notEmpty } from "../../utils";
|
|
21
12
|
import { flushSync } from "react-dom";
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
*/
|
|
25
|
-
export const DrilldownTrigger = styled.div `
|
|
26
|
-
cursor: pointer;
|
|
27
|
-
user-select: none;
|
|
28
|
-
`;
|
|
29
|
-
/**
|
|
30
|
-
* @public
|
|
31
|
-
*/
|
|
32
|
-
export function drilldownRenderOptions(options, handleSelectOption, handleDrilldown, handleBack, activeItem, fetchMoreText, autoscrollText, selectedIcon, externalLinkIcon, hideIcons, iconColumnWidth) {
|
|
33
|
-
return (opt, index) => {
|
|
34
|
-
var _a;
|
|
35
|
-
switch (opt.type) {
|
|
36
|
-
case "value": {
|
|
37
|
-
const subItems = isValueFlatType(opt)
|
|
38
|
-
? getFlatValueSubItems(opt.key, options) // opt is derived from options so if opt is flat type, options must be too.
|
|
39
|
-
: opt === null || opt === void 0 ? void 0 : opt.subItems;
|
|
40
|
-
return (React.createElement(DrilldownItem, { active: (activeItem === null || activeItem === void 0 ? void 0 : activeItem.type) === "value" && (activeItem === null || activeItem === void 0 ? void 0 : activeItem.key) === opt.key, onSelect: handleSelectOption, onSelectIcon: opt.onClickIcon, onClickSubItem: opt.onClickSubItem, key: opt.key, dataKey: opt.key, value: opt, meta: { active: false, input: "" }, hideIcons: hideIcons, iconColumnWidth: iconColumnWidth, selectedIcon: selectedIcon, externalLinkIcon: externalLinkIcon, handleDrilldown: handleDrilldown, subItems: subItems }));
|
|
41
|
-
}
|
|
42
|
-
case "header":
|
|
43
|
-
return React.createElement(S.DrilldownHeaderItem, { key: `header${index}` }, opt.label);
|
|
44
|
-
case "divider":
|
|
45
|
-
return React.createElement(S.DrilldownDividerItem, { key: `divider${index}` });
|
|
46
|
-
case "emptyList":
|
|
47
|
-
return React.createElement(Fragment, { key: `emptyList${index}` }, opt.component);
|
|
48
|
-
case "loading":
|
|
49
|
-
return (React.createElement(Fragment, { key: `loading${index}` }, (_a = opt.component) !== null && _a !== void 0 ? _a : (React.createElement(Stack, { align: "center", justify: "center", style: { height: "36px" } },
|
|
50
|
-
React.createElement(Spinner, { size: "medium" })))));
|
|
51
|
-
default:
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
function getNextItem(options, current, direction) {
|
|
57
|
-
var _a, _b, _c, _d, _e, _f;
|
|
58
|
-
if (options.length === 0)
|
|
59
|
-
return null;
|
|
60
|
-
const maxIndex = options.length - 1;
|
|
61
|
-
if (current == null) {
|
|
62
|
-
switch (direction) {
|
|
63
|
-
case "down":
|
|
64
|
-
return (_a = options[0]) !== null && _a !== void 0 ? _a : null;
|
|
65
|
-
case "up":
|
|
66
|
-
return (_b = options[maxIndex]) !== null && _b !== void 0 ? _b : null;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
const currIndex = (current === null || current === void 0 ? void 0 : current.type) === "createNew"
|
|
70
|
-
? options.findIndex((item) => item.type === "createNew")
|
|
71
|
-
: options.findIndex((item) => item.type === "value" && item.key === current.key);
|
|
72
|
-
switch (direction) {
|
|
73
|
-
case "down":
|
|
74
|
-
if (currIndex === maxIndex) {
|
|
75
|
-
return (_c = options[0]) !== null && _c !== void 0 ? _c : null;
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
return (_d = options[currIndex + 1]) !== null && _d !== void 0 ? _d : null;
|
|
79
|
-
}
|
|
80
|
-
case "up":
|
|
81
|
-
if (currIndex === 0) {
|
|
82
|
-
return (_e = options[maxIndex]) !== null && _e !== void 0 ? _e : null;
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
return (_f = options[currIndex - 1]) !== null && _f !== void 0 ? _f : null;
|
|
86
|
-
}
|
|
87
|
-
default:
|
|
88
|
-
return null;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
13
|
+
import { DrilldownList } from "./DrilldownList";
|
|
14
|
+
import { useFilteredItems } from "./hooks/useFilteredItems";
|
|
91
15
|
const minimumDrilldownWidth = 236;
|
|
92
16
|
/**
|
|
93
17
|
* Wraps around any child to upgrade it to a drilldown component. If used in the
|
|
@@ -116,7 +40,7 @@ const minimumDrilldownWidth = 236;
|
|
|
116
40
|
* </Drilldown>
|
|
117
41
|
* ```
|
|
118
42
|
*/
|
|
119
|
-
export function Drilldown({ type, children, options, inputValue, searchPlaceholder, placement = "bottom-start", showInternalSearch = false, isLoading = false, usePortal = true, closeOnSelect = true, isOpen: isOpenProp, renderCreateNewOption, onCreateNewOption, hideIcons, iconColumnWidth, containerWidth, containerHeight, onSelectOption, onInputChange,
|
|
43
|
+
export function Drilldown({ type, children, options, inputValue, searchPlaceholder, placement = "bottom-start", showInternalSearch = false, isLoading = false, usePortal = true, closeOnSelect = true, isOpen: isOpenProp, renderCreateNewOption, onCreateNewOption, hideIcons, iconColumnWidth, containerWidth, containerHeight, onSelectOption, onInputChange, onFetchMore, onClear, onClose, onOpen, onInputReturn, tabProps, disabled, fetchMoreText, autoscrollText, emptySearchResultsText, externalLinkIcon, selectedIcon, layer = "popover", animationDuration = 0.3, onDrilldown, onDrilldownAnimationEnd, onDrillupAnimationEnd, backText, filterPredicate, }) {
|
|
120
44
|
const [currentItems, setCurrentItems] = useState(type === "tree" ? options : options.filter((opt) => opt.parentKey === undefined));
|
|
121
45
|
const [otherItems, setOtherItems] = useState();
|
|
122
46
|
const [otherItemsSearchTerm, setOtherItemsSearchTerm] = useState("");
|
|
@@ -142,27 +66,21 @@ export function Drilldown({ type, children, options, inputValue, searchPlacehold
|
|
|
142
66
|
setClassName("drilldown");
|
|
143
67
|
}, [options, onDrilldown, pathToSelectedItem]);
|
|
144
68
|
const handleBack = useCallback(async () => {
|
|
145
|
-
var _a
|
|
69
|
+
var _a;
|
|
146
70
|
// Before animate
|
|
147
71
|
const searchTerm = (_a = pathToSelectedItem.at(-1)) === null || _a === void 0 ? void 0 : _a.searchTerm;
|
|
148
72
|
if (type === "tree") {
|
|
149
73
|
const prevItems = getTreeItemsFromPath("previous", options, pathToSelectedItem);
|
|
150
|
-
|
|
151
|
-
const filteredPrevItems = searchTerm && filterItemsCb ? filterItemsCb === null || filterItemsCb === void 0 ? void 0 : filterItemsCb(prevItems, searchTerm) : prevItems;
|
|
152
|
-
setOtherItems(filteredPrevItems);
|
|
74
|
+
setOtherItems(prevItems);
|
|
153
75
|
}
|
|
154
76
|
else {
|
|
155
77
|
const prevItems = getFlatItemsFromPath("previous", options, pathToSelectedItem);
|
|
156
|
-
|
|
157
|
-
const filteredPrevItems = searchTerm && filterItemsCb
|
|
158
|
-
? filterItemsCb === null || filterItemsCb === void 0 ? void 0 : filterItemsCb(prevItems, searchTerm, (_b = pathToSelectedItem.at(-2)) === null || _b === void 0 ? void 0 : _b.key)
|
|
159
|
-
: prevItems;
|
|
160
|
-
setOtherItems(filteredPrevItems);
|
|
78
|
+
setOtherItems(prevItems);
|
|
161
79
|
}
|
|
162
80
|
setOtherItemsSearchTerm(searchTerm !== null && searchTerm !== void 0 ? searchTerm : "");
|
|
163
81
|
// Animate
|
|
164
82
|
setClassName("drillup");
|
|
165
|
-
}, [type,
|
|
83
|
+
}, [type, options, pathToSelectedItem]);
|
|
166
84
|
const useUpdateItemsProps = type === "tree"
|
|
167
85
|
? {
|
|
168
86
|
type,
|
|
@@ -192,6 +110,9 @@ export function Drilldown({ type, children, options, inputValue, searchPlacehold
|
|
|
192
110
|
if (allOptions.length === 1 && hasCreateNewOption) {
|
|
193
111
|
setActiveItem({ type: "createNew" });
|
|
194
112
|
}
|
|
113
|
+
else if (allOptions.length > 1) {
|
|
114
|
+
setActiveItem(null);
|
|
115
|
+
}
|
|
195
116
|
}, [hasCreateNewOption, currentItems]);
|
|
196
117
|
const handleOpen = useCallback(() => {
|
|
197
118
|
if (!disabled) {
|
|
@@ -278,10 +199,35 @@ export function Drilldown({ type, children, options, inputValue, searchPlacehold
|
|
|
278
199
|
const handleOnClick = useCallback(() => {
|
|
279
200
|
isOpen ? handleClose() : handleOpen();
|
|
280
201
|
}, [handleClose, handleOpen, isOpen]);
|
|
202
|
+
const handleSelectOption = useCallback((value) => {
|
|
203
|
+
onSelectOption === null || onSelectOption === void 0 ? void 0 : onSelectOption(value, pathToSelectedItem.map(({ key }) => key));
|
|
204
|
+
handleClose("select");
|
|
205
|
+
}, [handleClose, onSelectOption, pathToSelectedItem]);
|
|
206
|
+
const handleCreateNew = useCallback(() => {
|
|
207
|
+
onCreateNewOption === null || onCreateNewOption === void 0 ? void 0 : onCreateNewOption();
|
|
208
|
+
handleClose("select");
|
|
209
|
+
}, [handleClose, onCreateNewOption]);
|
|
210
|
+
// width of input or set minimum width - 236px
|
|
211
|
+
const refWidth = useMemo(() => {
|
|
212
|
+
if ((referenceElement === null || referenceElement === void 0 ? void 0 : referenceElement.scrollWidth) && referenceElement.scrollWidth > minimumDrilldownWidth) {
|
|
213
|
+
return referenceElement.scrollWidth;
|
|
214
|
+
}
|
|
215
|
+
else
|
|
216
|
+
return minimumDrilldownWidth;
|
|
217
|
+
}, [referenceElement === null || referenceElement === void 0 ? void 0 : referenceElement.scrollWidth]);
|
|
218
|
+
const { filteredItems, flatItemTree } = useFilteredItems({
|
|
219
|
+
type,
|
|
220
|
+
options,
|
|
221
|
+
inputValue,
|
|
222
|
+
pathToSelectedItem,
|
|
223
|
+
filterPredicate,
|
|
224
|
+
emptySearchResultsText,
|
|
225
|
+
update,
|
|
226
|
+
});
|
|
281
227
|
const handleKeyDown = useCallback((e) => {
|
|
282
228
|
var _a;
|
|
283
229
|
const key = e.key;
|
|
284
|
-
const allOptions = getAllCurrentListOptions(currentItems, hasCreateNewOption);
|
|
230
|
+
const allOptions = getAllCurrentListOptions(inputValue ? filteredItems : currentItems, hasCreateNewOption);
|
|
285
231
|
switch (key) {
|
|
286
232
|
case "ArrowUp":
|
|
287
233
|
e.preventDefault();
|
|
@@ -332,11 +278,12 @@ export function Drilldown({ type, children, options, inputValue, searchPlacehold
|
|
|
332
278
|
break;
|
|
333
279
|
}
|
|
334
280
|
}, [
|
|
281
|
+
inputValue,
|
|
282
|
+
filteredItems,
|
|
335
283
|
currentItems,
|
|
336
284
|
hasCreateNewOption,
|
|
337
285
|
activeItem,
|
|
338
286
|
onInputReturn,
|
|
339
|
-
inputValue,
|
|
340
287
|
pathToSelectedItem,
|
|
341
288
|
onSelectOption,
|
|
342
289
|
handleClose,
|
|
@@ -346,22 +293,6 @@ export function Drilldown({ type, children, options, inputValue, searchPlacehold
|
|
|
346
293
|
handleDrilldown,
|
|
347
294
|
handleBack,
|
|
348
295
|
]);
|
|
349
|
-
const handleSelectOption = useCallback((value) => {
|
|
350
|
-
onSelectOption === null || onSelectOption === void 0 ? void 0 : onSelectOption(value, pathToSelectedItem.map(({ key }) => key));
|
|
351
|
-
handleClose("select");
|
|
352
|
-
}, [handleClose, onSelectOption, pathToSelectedItem]);
|
|
353
|
-
const handleCreateNew = useCallback(() => {
|
|
354
|
-
onCreateNewOption === null || onCreateNewOption === void 0 ? void 0 : onCreateNewOption();
|
|
355
|
-
handleClose("select");
|
|
356
|
-
}, [handleClose, onCreateNewOption]);
|
|
357
|
-
// width of input or set minimum width - 236px
|
|
358
|
-
const refWidth = useMemo(() => {
|
|
359
|
-
if ((referenceElement === null || referenceElement === void 0 ? void 0 : referenceElement.scrollWidth) && referenceElement.scrollWidth > minimumDrilldownWidth) {
|
|
360
|
-
return referenceElement.scrollWidth;
|
|
361
|
-
}
|
|
362
|
-
else
|
|
363
|
-
return minimumDrilldownWidth;
|
|
364
|
-
}, [referenceElement === null || referenceElement === void 0 ? void 0 : referenceElement.scrollWidth]);
|
|
365
296
|
const innerDrilldownContent = (React.createElement(S.ListsContainer, null,
|
|
366
297
|
React.createElement(S.ListsWrapper, { className: className, animationDuration: animationDuration, onAnimationEnd: () => {
|
|
367
298
|
var _a, _b;
|
|
@@ -406,10 +337,9 @@ export function Drilldown({ type, children, options, inputValue, searchPlacehold
|
|
|
406
337
|
(_b = scrollRef.current) === null || _b === void 0 ? void 0 : _b.scrollTo(0, 0);
|
|
407
338
|
}
|
|
408
339
|
} },
|
|
409
|
-
(currentItems.length > 0 || showInternalSearch) && (React.createElement(DrilldownList, { type: type, options: options, items: currentItems, handleSelectOption: handleSelectOption, handleDrilldown: handleDrilldown, handleBack: handleBack, showBack: pathToSelectedItem.length > 0, backText: backText, width: containerWidth || refWidth, order: className === "drillup" ? 1 : 0, activeItem: activeItem, containerHeight: containerHeight, onFetchMore: onFetchMore, fetchMoreText: fetchMoreText, autoscrollText: autoscrollText, selectedIcon: selectedIcon, externalLinkIcon: externalLinkIcon, hideIcons: hideIcons, iconColumnWidth: iconColumnWidth, showInternalSearch: showInternalSearch, inputValue: inputValue, onInputChange: onInputChange, inputSearchRef: inputSearchRef, searchPlaceholder: searchPlaceholder, pathToSelectedItem: pathToSelectedItem, scrollRef: scrollRef })),
|
|
340
|
+
(currentItems.length > 0 || showInternalSearch) && (React.createElement(DrilldownList, { type: type, options: options, items: currentItems, handleSelectOption: handleSelectOption, handleDrilldown: handleDrilldown, handleBack: handleBack, showBack: pathToSelectedItem.length > 0, backText: backText, width: containerWidth || refWidth, order: className === "drillup" ? 1 : 0, activeItem: activeItem, containerHeight: containerHeight, onFetchMore: onFetchMore, fetchMoreText: fetchMoreText, autoscrollText: autoscrollText, selectedIcon: selectedIcon, externalLinkIcon: externalLinkIcon, hideIcons: hideIcons, iconColumnWidth: iconColumnWidth, showInternalSearch: showInternalSearch, inputValue: inputValue, onInputChange: onInputChange, inputSearchRef: inputSearchRef, searchPlaceholder: searchPlaceholder, pathToSelectedItem: pathToSelectedItem, scrollRef: scrollRef, isLoading: isLoading, filteredItems: filteredItems, flatItemTree: flatItemTree })),
|
|
410
341
|
otherItems && (React.createElement(DrilldownList, { type: type, options: options, items: otherItems, handleSelectOption: handleSelectOption, handleDrilldown: async () => { }, handleBack: async () => { }, showBack: className === "drilldown" ||
|
|
411
|
-
(className === "drillup" && pathToSelectedItem.length > 1), backText: backText, width: containerWidth || refWidth, activeItem: activeItem, containerHeight: containerHeight, onFetchMore: onFetchMore, fetchMoreText: fetchMoreText, autoscrollText: autoscrollText, selectedIcon: selectedIcon, externalLinkIcon: externalLinkIcon, hideIcons: hideIcons, iconColumnWidth: iconColumnWidth, showInternalSearch: showInternalSearch, inputValue: otherItemsSearchTerm, searchPlaceholder: searchPlaceholder, pathToSelectedItem: pathToSelectedItem }))
|
|
412
|
-
isLoading && React.createElement(Spinner, null))));
|
|
342
|
+
(className === "drillup" && pathToSelectedItem.length > 1), backText: backText, width: containerWidth || refWidth, activeItem: activeItem, containerHeight: containerHeight, onFetchMore: onFetchMore, fetchMoreText: fetchMoreText, autoscrollText: autoscrollText, selectedIcon: selectedIcon, externalLinkIcon: externalLinkIcon, hideIcons: hideIcons, iconColumnWidth: iconColumnWidth, showInternalSearch: showInternalSearch, inputValue: otherItemsSearchTerm, searchPlaceholder: searchPlaceholder, pathToSelectedItem: pathToSelectedItem, filteredItems: filteredItems, flatItemTree: flatItemTree })))));
|
|
413
343
|
const drilldown = (React.createElement(S.DrilldownContainer, { layer: layer, initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { type: "spring", mass: 0.5 }, onKeyDownCapture: handleKeyDown, "data-testid": "drilldown-container", ref: mergeRefs(setPopperElement, drilldownRef), style: styles.popper, containerWidth: containerWidth || refWidth, containerHeight: containerHeight, ...attributes.popper },
|
|
414
344
|
tabProps && (React.createElement(Stack, { vertical: true, padding: "6px 8px" },
|
|
415
345
|
React.createElement(TabBar, { type: "tab", tabs: tabProps.tabs, onClickTab: tabProps.onTabChange, activeIndex: tabProps.activeTabIndex, containerStyles: {
|
|
@@ -445,86 +375,6 @@ export function Drilldown({ type, children, options, inputValue, searchPlacehold
|
|
|
445
375
|
typeof children === "function" ? children(targetProps) : children,
|
|
446
376
|
isOpen && (usePortal ? React.createElement(Portal, null, drilldown) : drilldown)));
|
|
447
377
|
}
|
|
448
|
-
/**
|
|
449
|
-
* @public
|
|
450
|
-
*/
|
|
451
|
-
export function DrilldownItem({ value, active, onSelect, onSelectIcon, onClickSubItem, hideIcons, iconColumnWidth, selectedIcon, externalLinkIcon, handleDrilldown, dataKey, subItems, }) {
|
|
452
|
-
const hasSubItems = !!(subItems && subItems.length > 0);
|
|
453
|
-
const handleOnClick = (e) => {
|
|
454
|
-
if (value.disabled) {
|
|
455
|
-
e.stopPropagation();
|
|
456
|
-
e.preventDefault();
|
|
457
|
-
return;
|
|
458
|
-
}
|
|
459
|
-
if (subItems && value.openSubmenuOnSelect) {
|
|
460
|
-
handleDrilldown(value);
|
|
461
|
-
onClickSubItem === null || onClickSubItem === void 0 ? void 0 : onClickSubItem(value);
|
|
462
|
-
}
|
|
463
|
-
else {
|
|
464
|
-
onSelect === null || onSelect === void 0 ? void 0 : onSelect(value);
|
|
465
|
-
}
|
|
466
|
-
};
|
|
467
|
-
return (React.createElement(S.DrilldownItemLayout, { "data-testid": "drilldown-value", "data-key": dataKey, active: active, onKeyDownCapture: (e) => {
|
|
468
|
-
if (e.key === "ArrowRight") {
|
|
469
|
-
e.preventDefault();
|
|
470
|
-
e.stopPropagation();
|
|
471
|
-
handleDrilldown(value);
|
|
472
|
-
}
|
|
473
|
-
}, tabIndex: 0, href: value.href, rel: value.href ? "noreferrer noopener" : undefined, target: value.href ? "_blank" : undefined, onClick: value.href ? undefined : handleOnClick, disabled: value.disabled },
|
|
474
|
-
React.createElement(S.DrilldownLabel, { selected: value.selected },
|
|
475
|
-
!hideIcons && (React.createElement(S.DrilldownIcon, { iconColumnWidth: iconColumnWidth, onClick: value.icon && onSelectIcon
|
|
476
|
-
? (e) => {
|
|
477
|
-
e.stopPropagation();
|
|
478
|
-
onSelectIcon(value.value);
|
|
479
|
-
}
|
|
480
|
-
: undefined }, isAnyIcon(value.icon) ? (React.createElement(Icon, { icon: value.icon })) : isIconProps(value.icon) ? (React.createElement(Icon, { ...value.icon })) : (value.icon))),
|
|
481
|
-
value.label),
|
|
482
|
-
value.selected && React.createElement(Icon, { size: 14, icon: selectedIcon }),
|
|
483
|
-
value.href && value.showHrefIcon && React.createElement(Icon, { icon: externalLinkIcon, themeColor: "cyan100" }),
|
|
484
|
-
React.createElement(S.ExpandButton, { onClick: (e) => {
|
|
485
|
-
e.preventDefault();
|
|
486
|
-
e.stopPropagation();
|
|
487
|
-
handleDrilldown(value);
|
|
488
|
-
}, icon: ChevronRightIcon, intent: "minimal", "$visible": hasSubItems })));
|
|
489
|
-
}
|
|
490
|
-
/**
|
|
491
|
-
* @public
|
|
492
|
-
*/
|
|
493
|
-
export const CreateNewOption = ({ text, icon, onClick, resetButton, iconColor, active, }) => {
|
|
494
|
-
return (React.createElement(S.CreateNewItemLayout, { active: active, className: resetButton ? "resetButton" : "", onClick: onClick },
|
|
495
|
-
React.createElement(S.DrilldownLabel, null,
|
|
496
|
-
React.createElement(S.DrilldownIcon, null,
|
|
497
|
-
React.createElement(Icon, { themeColor: iconColor, icon: icon })),
|
|
498
|
-
text)));
|
|
499
|
-
};
|
|
500
|
-
export function DrilldownList({ type, options, items, handleSelectOption, handleDrilldown, handleBack, showBack, width, order, activeItem, containerHeight, onFetchMore, fetchMoreText, autoscrollText, selectedIcon, externalLinkIcon, hideIcons, iconColumnWidth, showInternalSearch, inputValue, onInputChange, inputSearchRef, searchPlaceholder, pathToSelectedItem, backText, scrollRef, }) {
|
|
501
|
-
var _a, _b, _c, _d;
|
|
502
|
-
const stickyHeaderOptions = type === "tree"
|
|
503
|
-
? (_a = items.find(isStickyHeaderType)) === null || _a === void 0 ? void 0 : _a.options
|
|
504
|
-
: (_b = items
|
|
505
|
-
.find(isStickyHeaderType)) === null || _b === void 0 ? void 0 : _b.options.filter(isFlatItemType).filter((item) => item.parentKey === pathToSelectedItem.at(-1));
|
|
506
|
-
const stickyFooterOptions = type === "tree"
|
|
507
|
-
? (_c = items.find(isStickyFooterType)) === null || _c === void 0 ? void 0 : _c.options
|
|
508
|
-
: (_d = items
|
|
509
|
-
.find(isStickyFooterType)) === null || _d === void 0 ? void 0 : _d.options.filter(isFlatItemType).filter((item) => item.parentKey === pathToSelectedItem.at(-1));
|
|
510
|
-
return (React.createElement(S.ListContainer, { vertical: true, width: width, order: order },
|
|
511
|
-
showBack && (React.createElement(S.DrilldownBackItemLayout, { onClick: handleBack },
|
|
512
|
-
React.createElement(Icon, { icon: ChevronLeftIcon, size: 14 }),
|
|
513
|
-
React.createElement(TSpan, { type: "p2" }, backText))),
|
|
514
|
-
showInternalSearch && (React.createElement(S.DrilldownInternalSearchInputContainer, null,
|
|
515
|
-
React.createElement(Input, { inputsize: "medium", leftIcon: { icon: faSearch, themeColor: "cyan100" }, rightIcon: React.createElement(IconButton, { minimal: true, icon: faTimes, onClick: () => {
|
|
516
|
-
var _a;
|
|
517
|
-
onInputChange === null || onInputChange === void 0 ? void 0 : onInputChange("", pathToSelectedItem);
|
|
518
|
-
(_a = inputSearchRef === null || inputSearchRef === void 0 ? void 0 : inputSearchRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
519
|
-
} }), value: inputValue, onChange: (event) => onInputChange === null || onInputChange === void 0 ? void 0 : onInputChange(event.target.value, pathToSelectedItem), ref: inputSearchRef, placeholder: searchPlaceholder }))),
|
|
520
|
-
stickyHeaderOptions && (React.createElement(Stack, { vertical: true, align: "stretch", style: { width: "100%" } },
|
|
521
|
-
stickyHeaderOptions.map(drilldownRenderOptions(options, handleSelectOption, handleDrilldown, handleBack, activeItem, fetchMoreText, autoscrollText, selectedIcon, externalLinkIcon)),
|
|
522
|
-
React.createElement(S.DrilldownDividerItem, null))),
|
|
523
|
-
React.createElement(Infinite, { maxHeight: containerHeight ? undefined : "40vh", onFetchMore: onFetchMore, anchor: false, fetchMoreText: fetchMoreText, autoscrollText: autoscrollText, width: "100%", scrollRef: scrollRef }, items.map(drilldownRenderOptions(options, handleSelectOption, handleDrilldown, handleBack, activeItem, fetchMoreText, autoscrollText, selectedIcon, externalLinkIcon, hideIcons, iconColumnWidth))),
|
|
524
|
-
stickyFooterOptions && (React.createElement(Stack, { vertical: true, align: "stretch", style: { width: "100%" } },
|
|
525
|
-
React.createElement(S.DrilldownDividerItem, null),
|
|
526
|
-
stickyFooterOptions.map(drilldownRenderOptions(options, handleSelectOption, handleDrilldown, handleBack, activeItem, fetchMoreText, autoscrollText, selectedIcon, externalLinkIcon))))));
|
|
527
|
-
}
|
|
528
378
|
function isHtmlNode(node) {
|
|
529
379
|
return typeof node === "object" && notEmpty(node) && node instanceof HTMLElement;
|
|
530
380
|
}
|
|
@@ -547,4 +397,39 @@ function getAllCurrentListOptions(currentItems, hasCreateNewOption) {
|
|
|
547
397
|
...(hasCreateNewOption ? [{ type: "createNew" }] : []),
|
|
548
398
|
].filter((opt) => opt.type === "value" || opt.type === "createNew");
|
|
549
399
|
}
|
|
400
|
+
function getNextItem(options, current, direction) {
|
|
401
|
+
var _a, _b, _c, _d, _e, _f;
|
|
402
|
+
if (options.length === 0)
|
|
403
|
+
return null;
|
|
404
|
+
const maxIndex = options.length - 1;
|
|
405
|
+
if (current == null) {
|
|
406
|
+
switch (direction) {
|
|
407
|
+
case "down":
|
|
408
|
+
return (_a = options[0]) !== null && _a !== void 0 ? _a : null;
|
|
409
|
+
case "up":
|
|
410
|
+
return (_b = options[maxIndex]) !== null && _b !== void 0 ? _b : null;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
const currIndex = (current === null || current === void 0 ? void 0 : current.type) === "createNew"
|
|
414
|
+
? options.findIndex((item) => item.type === "createNew")
|
|
415
|
+
: options.findIndex((item) => item.type === "value" && item.key === current.key);
|
|
416
|
+
switch (direction) {
|
|
417
|
+
case "down":
|
|
418
|
+
if (currIndex === maxIndex) {
|
|
419
|
+
return (_c = options[0]) !== null && _c !== void 0 ? _c : null;
|
|
420
|
+
}
|
|
421
|
+
else {
|
|
422
|
+
return (_d = options[currIndex + 1]) !== null && _d !== void 0 ? _d : null;
|
|
423
|
+
}
|
|
424
|
+
case "up":
|
|
425
|
+
if (currIndex === 0) {
|
|
426
|
+
return (_e = options[maxIndex]) !== null && _e !== void 0 ? _e : null;
|
|
427
|
+
}
|
|
428
|
+
else {
|
|
429
|
+
return (_f = options[currIndex - 1]) !== null && _f !== void 0 ? _f : null;
|
|
430
|
+
}
|
|
431
|
+
default:
|
|
432
|
+
return null;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
550
435
|
//# sourceMappingURL=Drilldown.js.map
|