@flipdish/ui-library 0.66.2 → 0.67.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/components/__internal__/listOption/listOption.styles.cjs +1 -1
- package/dist/components/__internal__/listOption/listOption.styles.cjs.map +1 -1
- package/dist/components/__internal__/listOption/listOption.styles.js +1 -1
- package/dist/components/__internal__/listOption/listOption.styles.js.map +1 -1
- package/dist/components/forms/fields/FormMultiSelect/index.cjs +8 -23
- package/dist/components/forms/fields/FormMultiSelect/index.cjs.map +1 -1
- package/dist/components/forms/fields/FormMultiSelect/index.d.ts +4 -4
- package/dist/components/forms/fields/FormMultiSelect/index.d.ts.map +1 -1
- package/dist/components/forms/fields/FormMultiSelect/index.js +8 -23
- package/dist/components/forms/fields/FormMultiSelect/index.js.map +1 -1
- package/dist/components/molecules/Dropdown/index.cjs +3 -1
- package/dist/components/molecules/Dropdown/index.cjs.map +1 -1
- package/dist/components/molecules/Dropdown/index.d.ts.map +1 -1
- package/dist/components/molecules/Dropdown/index.js +3 -1
- package/dist/components/molecules/Dropdown/index.js.map +1 -1
- package/dist/components/molecules/Select/index.d.ts +1 -6
- package/dist/components/molecules/Select/index.d.ts.map +1 -1
- package/dist/components/molecules/Selects/MultiSelect/MultiSelect.cjs +76 -41
- package/dist/components/molecules/Selects/MultiSelect/MultiSelect.cjs.map +1 -1
- package/dist/components/molecules/Selects/MultiSelect/MultiSelect.d.ts +15 -38
- package/dist/components/molecules/Selects/MultiSelect/MultiSelect.d.ts.map +1 -1
- package/dist/components/molecules/Selects/MultiSelect/MultiSelect.js +79 -44
- package/dist/components/molecules/Selects/MultiSelect/MultiSelect.js.map +1 -1
- package/dist/components/molecules/Selects/MultiSelect/components/MultiSelectItem.cjs +18 -0
- package/dist/components/molecules/Selects/MultiSelect/components/MultiSelectItem.cjs.map +1 -0
- package/dist/components/molecules/Selects/MultiSelect/components/MultiSelectItem.d.ts +15 -0
- package/dist/components/molecules/Selects/MultiSelect/components/MultiSelectItem.d.ts.map +1 -0
- package/dist/components/molecules/Selects/MultiSelect/components/MultiSelectItem.js +15 -0
- package/dist/components/molecules/Selects/MultiSelect/components/MultiSelectItem.js.map +1 -0
- package/dist/components/molecules/Selects/MultiSelect/components/MultiSelectPills.cjs +74 -0
- package/dist/components/molecules/Selects/MultiSelect/components/MultiSelectPills.cjs.map +1 -0
- package/dist/components/molecules/Selects/MultiSelect/components/MultiSelectPills.d.ts +23 -0
- package/dist/components/molecules/Selects/MultiSelect/components/MultiSelectPills.d.ts.map +1 -0
- package/dist/components/molecules/Selects/MultiSelect/components/MultiSelectPills.js +72 -0
- package/dist/components/molecules/Selects/MultiSelect/components/MultiSelectPills.js.map +1 -0
- package/dist/components/molecules/Selects/MultiSelect/hooks/useMultiSelectSelection.cjs +85 -0
- package/dist/components/molecules/Selects/MultiSelect/hooks/useMultiSelectSelection.cjs.map +1 -0
- package/dist/components/molecules/Selects/MultiSelect/hooks/useMultiSelectSelection.d.ts +35 -0
- package/dist/components/molecules/Selects/MultiSelect/hooks/useMultiSelectSelection.d.ts.map +1 -0
- package/dist/components/molecules/Selects/MultiSelect/hooks/useMultiSelectSelection.js +83 -0
- package/dist/components/molecules/Selects/MultiSelect/hooks/useMultiSelectSelection.js.map +1 -0
- package/dist/components/molecules/Selects/MultiSelect/hooks/usePillOverflow.cjs +43 -0
- package/dist/components/molecules/Selects/MultiSelect/hooks/usePillOverflow.cjs.map +1 -0
- package/dist/components/molecules/Selects/MultiSelect/hooks/usePillOverflow.d.ts +14 -0
- package/dist/components/molecules/Selects/MultiSelect/hooks/usePillOverflow.d.ts.map +1 -0
- package/dist/components/molecules/Selects/MultiSelect/hooks/usePillOverflow.js +41 -0
- package/dist/components/molecules/Selects/MultiSelect/hooks/usePillOverflow.js.map +1 -0
- package/dist/components/molecules/Selects/MultiSelect/utilities/multiSelect.utils.cjs +114 -22
- package/dist/components/molecules/Selects/MultiSelect/utilities/multiSelect.utils.cjs.map +1 -1
- package/dist/components/molecules/Selects/MultiSelect/utilities/multiSelect.utils.d.ts +79 -12
- package/dist/components/molecules/Selects/MultiSelect/utilities/multiSelect.utils.d.ts.map +1 -1
- package/dist/components/molecules/Selects/MultiSelect/utilities/multiSelect.utils.js +108 -21
- package/dist/components/molecules/Selects/MultiSelect/utilities/multiSelect.utils.js.map +1 -1
- package/dist/components/molecules/Selects/Select/Select.cjs +1 -3
- package/dist/components/molecules/Selects/Select/Select.cjs.map +1 -1
- package/dist/components/molecules/Selects/Select/Select.d.ts +0 -2
- package/dist/components/molecules/Selects/Select/Select.d.ts.map +1 -1
- package/dist/components/molecules/Selects/Select/Select.js +1 -3
- package/dist/components/molecules/Selects/Select/Select.js.map +1 -1
- package/dist/components/molecules/Selects/Selects.styles.cjs +3 -4
- package/dist/components/molecules/Selects/Selects.styles.cjs.map +1 -1
- package/dist/components/molecules/Selects/Selects.styles.d.ts +1 -4
- package/dist/components/molecules/Selects/Selects.styles.d.ts.map +1 -1
- package/dist/components/molecules/Selects/Selects.styles.js +3 -4
- package/dist/components/molecules/Selects/Selects.styles.js.map +1 -1
- package/dist/components/molecules/Selects/index.d.ts +1 -2
- package/dist/components/molecules/Selects/index.d.ts.map +1 -1
- package/dist/components/organisms/DatePickers/DateRangePicker/DateRangePicker.cjs +1 -1
- package/dist/components/organisms/DatePickers/DateRangePicker/DateRangePicker.cjs.map +1 -1
- package/dist/components/organisms/DatePickers/DateRangePicker/DateRangePicker.js +1 -1
- package/dist/components/organisms/DatePickers/DateRangePicker/DateRangePicker.js.map +1 -1
- package/dist/styles.css +26 -0
- package/package.json +1 -1
- package/dist/components/molecules/Selects/MultiSelect/useMultiSelectSelection.cjs +0 -43
- package/dist/components/molecules/Selects/MultiSelect/useMultiSelectSelection.cjs.map +0 -1
- package/dist/components/molecules/Selects/MultiSelect/useMultiSelectSelection.d.ts +0 -35
- package/dist/components/molecules/Selects/MultiSelect/useMultiSelectSelection.d.ts.map +0 -1
- package/dist/components/molecules/Selects/MultiSelect/useMultiSelectSelection.js +0 -41
- package/dist/components/molecules/Selects/MultiSelect/useMultiSelectSelection.js.map +0 -1
- package/dist/components/molecules/Selects/Select/components/Combobox.cjs +0 -60
- package/dist/components/molecules/Selects/Select/components/Combobox.cjs.map +0 -1
- package/dist/components/molecules/Selects/Select/components/Combobox.d.ts +0 -16
- package/dist/components/molecules/Selects/Select/components/Combobox.d.ts.map +0 -1
- package/dist/components/molecules/Selects/Select/components/Combobox.js +0 -58
- package/dist/components/molecules/Selects/Select/components/Combobox.js.map +0 -1
package/dist/styles.css
CHANGED
|
@@ -71,6 +71,32 @@
|
|
|
71
71
|
scrollbar-width: thin;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
/*
|
|
75
|
+
* A scrollbar that stays on screen whenever the content overflows, for a list in a popover: an overlay scrollbar hides
|
|
76
|
+
* until the list is scrolled, so nothing says there is more below. Firefox takes the standard properties and, on macOS,
|
|
77
|
+
* still follows the system setting; they are kept from other browsers because setting them switches the rules below off.
|
|
78
|
+
*/
|
|
79
|
+
@utility scrollbar-visible {
|
|
80
|
+
&::-webkit-scrollbar {
|
|
81
|
+
width: 14px;
|
|
82
|
+
}
|
|
83
|
+
&::-webkit-scrollbar-track {
|
|
84
|
+
margin-block: 2px;
|
|
85
|
+
background: transparent;
|
|
86
|
+
}
|
|
87
|
+
/* The transparent border insets the thumb, leaving a 6px bar. */
|
|
88
|
+
&::-webkit-scrollbar-thumb {
|
|
89
|
+
border: 4px solid transparent;
|
|
90
|
+
border-radius: 9999px;
|
|
91
|
+
background-color: color-mix(in srgb, var(--color-alpha-black) 15%, transparent);
|
|
92
|
+
background-clip: content-box;
|
|
93
|
+
}
|
|
94
|
+
@supports not selector(::-webkit-scrollbar) {
|
|
95
|
+
scrollbar-width: thin;
|
|
96
|
+
scrollbar-color: color-mix(in srgb, var(--color-alpha-black) 15%, transparent) transparent;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
74
100
|
@utility transition-inherit-all {
|
|
75
101
|
transition-property: inherit;
|
|
76
102
|
transition-duration: inherit;
|
package/package.json
CHANGED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var React = require('react');
|
|
4
|
-
var multiSelect_utils = require('./utilities/multiSelect.utils.cjs');
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Tracks which MultiSelect options are chosen, internally when the parent does not pass
|
|
8
|
-
* `selectedKeys`, and reports the trigger count plus the footer handlers.
|
|
9
|
-
*
|
|
10
|
-
* @param options The selection props and the options the footer can select.
|
|
11
|
-
* @returns The selection to render, whether any option is chosen, how many, and the change, reset and select-all handlers.
|
|
12
|
-
*/
|
|
13
|
-
const useMultiSelectSelection = ({ selectedKeys, defaultSelectedKeys, onSelectionChange, onReset, onSelectAll, items, children, }) => {
|
|
14
|
-
// Controlled when `selectedKeys` is supplied; otherwise track selection internally
|
|
15
|
-
// (seeded from `defaultSelectedKeys`) so the trigger summary, footer, and item ticks
|
|
16
|
-
// all reflect choices even without the parent wiring `onSelectionChange`.
|
|
17
|
-
const isControlled = selectedKeys !== undefined;
|
|
18
|
-
const [internalSelectedKeys, setInternalSelectedKeys] = React.useState(defaultSelectedKeys ?? new Set());
|
|
19
|
-
const currentSelectedKeys = isControlled ? selectedKeys : internalSelectedKeys;
|
|
20
|
-
const handleSelectionChange = (keys) => {
|
|
21
|
-
if (!isControlled)
|
|
22
|
-
setInternalSelectedKeys(keys);
|
|
23
|
-
onSelectionChange?.(keys);
|
|
24
|
-
};
|
|
25
|
-
const handleReset = () => {
|
|
26
|
-
if (!isControlled)
|
|
27
|
-
setInternalSelectedKeys(new Set());
|
|
28
|
-
onReset?.();
|
|
29
|
-
};
|
|
30
|
-
const handleSelectAll = () => {
|
|
31
|
-
// Every selectable key — from `items` when data-driven, else from the ids of the
|
|
32
|
-
// static `MultiSelect.Item` children, so "Select all" works in both modes.
|
|
33
|
-
if (!isControlled)
|
|
34
|
-
setInternalSelectedKeys(multiSelect_utils.collectSelectableKeys(items ? items.map((item) => item.id) : undefined, children));
|
|
35
|
-
onSelectAll?.();
|
|
36
|
-
};
|
|
37
|
-
const selectedCount = multiSelect_utils.countSelectedKeys(currentSelectedKeys, items?.length ?? 0);
|
|
38
|
-
const hasSelection = selectedCount > 0;
|
|
39
|
-
return { currentSelectedKeys, selectedCount, hasSelection, handleSelectionChange, handleReset, handleSelectAll };
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
exports.useMultiSelectSelection = useMultiSelectSelection;
|
|
43
|
-
//# sourceMappingURL=useMultiSelectSelection.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useMultiSelectSelection.cjs","sources":["../../../../../src/components/molecules/Selects/MultiSelect/useMultiSelectSelection.ts"],"sourcesContent":[null],"names":["useState","collectSelectableKeys","countSelectedKeys"],"mappings":";;;;;AAsBA;;;;;;AAMG;MACU,uBAAuB,GAAG,CAAC,EACtC,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,OAAO,EACP,WAAW,EACX,KAAK,EACL,QAAQ,GACuB,KAAI;;;;AAInC,IAAA,MAAM,YAAY,GAAG,YAAY,KAAK,SAAS;AAC/C,IAAA,MAAM,CAAC,oBAAoB,EAAE,uBAAuB,CAAC,GAAGA,cAAQ,CAAuB,mBAAmB,IAAI,IAAI,GAAG,EAAE,CAAC;IACxH,MAAM,mBAAmB,GAAG,YAAY,GAAG,YAAY,GAAG,oBAAoB;AAE9E,IAAA,MAAM,qBAAqB,GAAG,CAAC,IAA0B,KAAI;AAC3D,QAAA,IAAI,CAAC,YAAY;YAAE,uBAAuB,CAAC,IAAI,CAAC;AAChD,QAAA,iBAAiB,GAAG,IAAI,CAAC;AAC3B,IAAA,CAAC;IAED,MAAM,WAAW,GAAG,MAAK;AACvB,QAAA,IAAI,CAAC,YAAY;AAAE,YAAA,uBAAuB,CAAC,IAAI,GAAG,EAAE,CAAC;QACrD,OAAO,IAAI;AACb,IAAA,CAAC;IAED,MAAM,eAAe,GAAG,MAAK;;;AAG3B,QAAA,IAAI,CAAC,YAAY;AAAE,YAAA,uBAAuB,CAACC,uCAAqB,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,QAAQ,CAAC,CAAC;QAC7H,WAAW,IAAI;AACjB,IAAA,CAAC;AAED,IAAA,MAAM,aAAa,GAAGC,mCAAiB,CAAC,mBAAmB,EAAE,KAAK,EAAE,MAAM,IAAI,CAAC,CAAC;AAChF,IAAA,MAAM,YAAY,GAAG,aAAa,GAAG,CAAC;AAEtC,IAAA,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,YAAY,EAAE,qBAAqB,EAAE,WAAW,EAAE,eAAe,EAAE;AAClH;;"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { type MultiSelectChildren, type MultiSelectSelection } from './utilities/multiSelect.utils';
|
|
2
|
-
export interface UseMultiSelectSelectionOptions {
|
|
3
|
-
/** Controlled selection. When omitted, the hook tracks selection itself. */
|
|
4
|
-
selectedKeys?: MultiSelectSelection;
|
|
5
|
-
/** Initial selection used only while uncontrolled. */
|
|
6
|
-
defaultSelectedKeys?: MultiSelectSelection;
|
|
7
|
-
/** Called with the next selection whenever the user changes it. */
|
|
8
|
-
onSelectionChange?: (keys: MultiSelectSelection) => void;
|
|
9
|
-
/** Called when Reset is pressed. Uncontrolled selection is cleared before this runs. */
|
|
10
|
-
onReset?: () => void;
|
|
11
|
-
/** Called when Select all is pressed. Uncontrolled selection is replaced before this runs. */
|
|
12
|
-
onSelectAll?: () => void;
|
|
13
|
-
/** Data-driven options. When set, Select all uses their ids and ignores static children. */
|
|
14
|
-
items?: readonly {
|
|
15
|
-
id: string | number;
|
|
16
|
-
}[];
|
|
17
|
-
/** Static item elements, or a render function when `items` is set. */
|
|
18
|
-
children?: MultiSelectChildren;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Tracks which MultiSelect options are chosen, internally when the parent does not pass
|
|
22
|
-
* `selectedKeys`, and reports the trigger count plus the footer handlers.
|
|
23
|
-
*
|
|
24
|
-
* @param options The selection props and the options the footer can select.
|
|
25
|
-
* @returns The selection to render, whether any option is chosen, how many, and the change, reset and select-all handlers.
|
|
26
|
-
*/
|
|
27
|
-
export declare const useMultiSelectSelection: ({ selectedKeys, defaultSelectedKeys, onSelectionChange, onReset, onSelectAll, items, children, }: UseMultiSelectSelectionOptions) => {
|
|
28
|
-
currentSelectedKeys: MultiSelectSelection;
|
|
29
|
-
selectedCount: number;
|
|
30
|
-
hasSelection: boolean;
|
|
31
|
-
handleSelectionChange: (keys: MultiSelectSelection) => void;
|
|
32
|
-
handleReset: () => void;
|
|
33
|
-
handleSelectAll: () => void;
|
|
34
|
-
};
|
|
35
|
-
//# sourceMappingURL=useMultiSelectSelection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useMultiSelectSelection.d.ts","sourceRoot":"","sources":["../../../../../src/components/molecules/Selects/MultiSelect/useMultiSelectSelection.ts"],"names":[],"mappings":"AAGA,OAAO,EAA4C,KAAK,mBAAmB,EAAE,KAAK,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAE9I,MAAM,WAAW,8BAA8B;IAC7C,4EAA4E;IAC5E,YAAY,CAAC,EAAE,oBAAoB,CAAC;IACpC,sDAAsD;IACtD,mBAAmB,CAAC,EAAE,oBAAoB,CAAC;IAC3C,mEAAmE;IACnE,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,oBAAoB,KAAK,IAAI,CAAC;IACzD,wFAAwF;IACxF,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,8FAA8F;IAC9F,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,4FAA4F;IAC5F,KAAK,CAAC,EAAE,SAAS;QAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,EAAE,CAAC;IAC3C,sEAAsE;IACtE,QAAQ,CAAC,EAAE,mBAAmB,CAAC;CAChC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,GAAI,kGAQrC,8BAA8B;;;;kCAQM,oBAAoB;;;CAqB1D,CAAC"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
import { countSelectedKeys, collectSelectableKeys } from './utilities/multiSelect.utils.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Tracks which MultiSelect options are chosen, internally when the parent does not pass
|
|
6
|
-
* `selectedKeys`, and reports the trigger count plus the footer handlers.
|
|
7
|
-
*
|
|
8
|
-
* @param options The selection props and the options the footer can select.
|
|
9
|
-
* @returns The selection to render, whether any option is chosen, how many, and the change, reset and select-all handlers.
|
|
10
|
-
*/
|
|
11
|
-
const useMultiSelectSelection = ({ selectedKeys, defaultSelectedKeys, onSelectionChange, onReset, onSelectAll, items, children, }) => {
|
|
12
|
-
// Controlled when `selectedKeys` is supplied; otherwise track selection internally
|
|
13
|
-
// (seeded from `defaultSelectedKeys`) so the trigger summary, footer, and item ticks
|
|
14
|
-
// all reflect choices even without the parent wiring `onSelectionChange`.
|
|
15
|
-
const isControlled = selectedKeys !== undefined;
|
|
16
|
-
const [internalSelectedKeys, setInternalSelectedKeys] = useState(defaultSelectedKeys ?? new Set());
|
|
17
|
-
const currentSelectedKeys = isControlled ? selectedKeys : internalSelectedKeys;
|
|
18
|
-
const handleSelectionChange = (keys) => {
|
|
19
|
-
if (!isControlled)
|
|
20
|
-
setInternalSelectedKeys(keys);
|
|
21
|
-
onSelectionChange?.(keys);
|
|
22
|
-
};
|
|
23
|
-
const handleReset = () => {
|
|
24
|
-
if (!isControlled)
|
|
25
|
-
setInternalSelectedKeys(new Set());
|
|
26
|
-
onReset?.();
|
|
27
|
-
};
|
|
28
|
-
const handleSelectAll = () => {
|
|
29
|
-
// Every selectable key — from `items` when data-driven, else from the ids of the
|
|
30
|
-
// static `MultiSelect.Item` children, so "Select all" works in both modes.
|
|
31
|
-
if (!isControlled)
|
|
32
|
-
setInternalSelectedKeys(collectSelectableKeys(items ? items.map((item) => item.id) : undefined, children));
|
|
33
|
-
onSelectAll?.();
|
|
34
|
-
};
|
|
35
|
-
const selectedCount = countSelectedKeys(currentSelectedKeys, items?.length ?? 0);
|
|
36
|
-
const hasSelection = selectedCount > 0;
|
|
37
|
-
return { currentSelectedKeys, selectedCount, hasSelection, handleSelectionChange, handleReset, handleSelectAll };
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export { useMultiSelectSelection };
|
|
41
|
-
//# sourceMappingURL=useMultiSelectSelection.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useMultiSelectSelection.js","sources":["../../../../../src/components/molecules/Selects/MultiSelect/useMultiSelectSelection.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAsBA;;;;;;AAMG;MACU,uBAAuB,GAAG,CAAC,EACtC,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,OAAO,EACP,WAAW,EACX,KAAK,EACL,QAAQ,GACuB,KAAI;;;;AAInC,IAAA,MAAM,YAAY,GAAG,YAAY,KAAK,SAAS;AAC/C,IAAA,MAAM,CAAC,oBAAoB,EAAE,uBAAuB,CAAC,GAAG,QAAQ,CAAuB,mBAAmB,IAAI,IAAI,GAAG,EAAE,CAAC;IACxH,MAAM,mBAAmB,GAAG,YAAY,GAAG,YAAY,GAAG,oBAAoB;AAE9E,IAAA,MAAM,qBAAqB,GAAG,CAAC,IAA0B,KAAI;AAC3D,QAAA,IAAI,CAAC,YAAY;YAAE,uBAAuB,CAAC,IAAI,CAAC;AAChD,QAAA,iBAAiB,GAAG,IAAI,CAAC;AAC3B,IAAA,CAAC;IAED,MAAM,WAAW,GAAG,MAAK;AACvB,QAAA,IAAI,CAAC,YAAY;AAAE,YAAA,uBAAuB,CAAC,IAAI,GAAG,EAAE,CAAC;QACrD,OAAO,IAAI;AACb,IAAA,CAAC;IAED,MAAM,eAAe,GAAG,MAAK;;;AAG3B,QAAA,IAAI,CAAC,YAAY;AAAE,YAAA,uBAAuB,CAAC,qBAAqB,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,QAAQ,CAAC,CAAC;QAC7H,WAAW,IAAI;AACjB,IAAA,CAAC;AAED,IAAA,MAAM,aAAa,GAAG,iBAAiB,CAAC,mBAAmB,EAAE,KAAK,EAAE,MAAM,IAAI,CAAC,CAAC;AAChF,IAAA,MAAM,YAAY,GAAG,aAAa,GAAG,CAAC;AAEtC,IAAA,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,YAAY,EAAE,qBAAqB,EAAE,WAAW,EAAE,eAAe,EAAE;AAClH;;"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
-
var uiIcons = require('@flipdish/ui-icons');
|
|
5
|
-
var Inputs = require('@flipdish/ui-library/components/atoms/Inputs');
|
|
6
|
-
var useResizeObserver = require('@flipdish/ui-library/hooks/useResizeObserver');
|
|
7
|
-
var cx = require('@flipdish/ui-library/utilities/cx');
|
|
8
|
-
var React = require('react');
|
|
9
|
-
var reactAriaComponents = require('react-aria-components');
|
|
10
|
-
var useHotkeyHint = require('../../../../../hooks/__internal__/useHotkeyHint/useHotkeyHint.cjs');
|
|
11
|
-
var componentGuard_utils = require('../../../../../utilities/__internal__/componentGuardUtils/componentGuard.utils.cjs');
|
|
12
|
-
var SelectItem = require('../../components/SelectItem.cjs');
|
|
13
|
-
var Select_context = require('../../providers/Select.context.cjs');
|
|
14
|
-
var Selects_styles = require('../../Selects.styles.cjs');
|
|
15
|
-
var Popover = require('./Popover.cjs');
|
|
16
|
-
|
|
17
|
-
const ComboBoxValue = React.forwardRef(({ size, shortcut, placeholder, shortcutClassName, icon: IconProp, ...otherProps }, ref) => {
|
|
18
|
-
const state = React.useContext(reactAriaComponents.ComboBoxStateContext);
|
|
19
|
-
const shortcutHint = useHotkeyHint.useHotkeyHint('mod+k');
|
|
20
|
-
const value = state?.selectedItem?.value || null;
|
|
21
|
-
const inputValue = state?.inputValue || null;
|
|
22
|
-
const first = inputValue?.split(value?.supportingText)?.[0] || '';
|
|
23
|
-
const last = inputValue?.split(first)[1];
|
|
24
|
-
const renderLeadingIcon = () => {
|
|
25
|
-
if (componentGuard_utils.isReactComponent(IconProp))
|
|
26
|
-
return jsxRuntime.jsx(IconProp, { "data-icon": true, className: "pointer-events-none", "aria-hidden": "true" });
|
|
27
|
-
if (React.isValidElement(IconProp))
|
|
28
|
-
return IconProp;
|
|
29
|
-
return jsxRuntime.jsx(uiIcons.SearchLg, { "data-icon": true, className: "pointer-events-none", "aria-hidden": "true" });
|
|
30
|
-
};
|
|
31
|
-
return (jsxRuntime.jsxs(reactAriaComponents.Group, { ref: ref, ...otherProps, className: ({ isFocusWithin, isDisabled, isInvalid }) => cx.cx('relative flex w-full items-center gap-2 rounded-lg bg-primary shadow-xs ring-1 ring-primary outline-hidden transition-shadow duration-100 ease-linear ring-inset', isDisabled && 'cursor-not-allowed opacity-50', isFocusWithin && 'ring-2 ring-brand', isInvalid && 'ring-error_subtle', isInvalid && isFocusWithin && 'ring-2 ring-error',
|
|
32
|
-
// Icon styles
|
|
33
|
-
'*:data-icon:shrink-0 *:data-icon:text-fg-quaternary', Selects_styles.styles.sizes[size].root), children: [renderLeadingIcon(), jsxRuntime.jsxs("div", { className: "relative flex w-full items-center", children: [inputValue && (jsxRuntime.jsxs("span", { className: cx.cx('absolute top-1/2 z-0 inline-flex w-full -translate-y-1/2 truncate', Selects_styles.styles.sizes[size].textContainer), "aria-hidden": "true", children: [jsxRuntime.jsx("p", { className: cx.cx('font-medium text-primary', Selects_styles.styles.sizes[size].text), children: first }), last && jsxRuntime.jsx("p", { className: cx.cx('-ml-0.75 text-tertiary', Selects_styles.styles.sizes[size].text), children: last })] })), jsxRuntime.jsx(reactAriaComponents.Input, { placeholder: placeholder, className: cx.cx('z-10 w-full appearance-none bg-transparent text-transparent caret-alpha-black/90 placeholder:text-placeholder focus:outline-hidden disabled:cursor-not-allowed', Selects_styles.styles.sizes[size].text) })] }), shortcut && (jsxRuntime.jsx("div", { className: cx.cx('absolute inset-y-0.5 right-0.5 z-10 hidden items-center rounded-r-[inherit] bg-linear-to-r from-transparent to-bg-primary to-40% pl-8 md:flex', Selects_styles.styles.sizes[size].shortcut, shortcutClassName), children: jsxRuntime.jsx("span", { className: "pointer-events-none rounded px-1 py-px text-xs font-medium text-quaternary ring-1 ring-secondary select-none ring-inset", "aria-hidden": "true", children: shortcutHint }) }))] }));
|
|
34
|
-
});
|
|
35
|
-
ComboBoxValue.displayName = 'ComboBoxValue';
|
|
36
|
-
const ComboBox = React.forwardRef(({ placeholder = 'Search', shortcut = true, size = 'md', children, items, shortcutClassName, icon, hideRequiredIndicator, ...otherProps }, ref) => {
|
|
37
|
-
const placeholderRef = React.useRef(null);
|
|
38
|
-
const [popoverWidth, setPopoverWidth] = React.useState('');
|
|
39
|
-
// Resize observer for popover width
|
|
40
|
-
// biome-ignore lint/correctness/useExhaustiveDependencies: We need to pass the setPopoverWidth function to the onResize callback
|
|
41
|
-
const onResize = React.useCallback(() => {
|
|
42
|
-
if (!placeholderRef.current)
|
|
43
|
-
return;
|
|
44
|
-
const divRect = placeholderRef.current?.getBoundingClientRect();
|
|
45
|
-
setPopoverWidth(`${divRect.width}px`);
|
|
46
|
-
}, [placeholderRef, setPopoverWidth]);
|
|
47
|
-
useResizeObserver.useResizeObserver({
|
|
48
|
-
ref: placeholderRef,
|
|
49
|
-
box: 'border-box',
|
|
50
|
-
onResize,
|
|
51
|
-
});
|
|
52
|
-
return (jsxRuntime.jsx(Select_context.SelectContext.Provider, { value: { size }, children: jsxRuntime.jsx(reactAriaComponents.ComboBox, { menuTrigger: "focus", ...otherProps, ref: ref, children: (state) => (jsxRuntime.jsxs("div", { className: "flex flex-col gap-1.5", children: [otherProps.label && (jsxRuntime.jsx(Inputs.Label, { isRequired: hideRequiredIndicator ? false : state.isRequired, tooltip: otherProps.tooltip, children: otherProps.label })), jsxRuntime.jsx(ComboBoxValue, { ref: placeholderRef, placeholder: placeholder, shortcut: shortcut, shortcutClassName: shortcutClassName, icon: icon, size: size,
|
|
53
|
-
// This is a workaround to correctly calculating the trigger width
|
|
54
|
-
// while using ResizeObserver wasn't 100% reliable.
|
|
55
|
-
onFocus: onResize, onPointerEnter: onResize }), jsxRuntime.jsx(Popover.Popover, { size: size, triggerRef: placeholderRef, style: { width: popoverWidth }, className: otherProps.popoverClassName, children: jsxRuntime.jsx(reactAriaComponents.ListBox, { items: items, className: "size-full outline-hidden", children: children ?? (items && SelectItem.renderSelectItem) }) }), otherProps.hint && (jsxRuntime.jsx(Inputs.HintText, { isInvalid: state.isInvalid, className: cx.cx(size === 'sm' && 'text-xs'), children: otherProps.hint }))] })) }) }));
|
|
56
|
-
});
|
|
57
|
-
ComboBox.displayName = 'Select.ComboBox';
|
|
58
|
-
|
|
59
|
-
exports.ComboBox = ComboBox;
|
|
60
|
-
//# sourceMappingURL=Combobox.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Combobox.cjs","sources":["../../../../../../src/components/molecules/Selects/Select/components/Combobox.tsx"],"sourcesContent":[null],"names":["forwardRef","useContext","ComboBoxStateContext","useHotkeyHint","isReactComponent","_jsx","isValidElement","SearchLg","_jsxs","AriaGroup","cx","styles","AriaInput","useRef","useState","useCallback","useResizeObserver","SelectContext","AriaComboBox","Label","Popover","AriaListBox","renderSelectItem","HintText"],"mappings":";;;;;;;;;;;;;;;;AAuDA,MAAM,aAAa,GAAGA,gBAAU,CAC9B,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,iBAAiB,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAE,EAAE,GAAG,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,EAAE,cAAc,EACnB,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,EAClB,iBAAiB,EAAE,iBAAiB,EACpC,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,IAAI;;;AAGV,wBAAA,OAAO,EAAE,QAAQ,EACjB,cAAc,EAAE,QAAQ,GACxB,EAEFA,cAAA,CAACe,eAAO,EAAA,EAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,SAAS,EAAE,UAAU,CAAC,gBAAgB,YACrHf,cAAA,CAACgB,2BAAW,IAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAC,0BAA0B,EAAA,QAAA,EAE5D,QAAQ,KAAK,KAAK,IAAIC,2BAAgB,CAAC,EAAA,CAC5B,GACN,EAET,UAAU,CAAC,IAAI,KACdjB,cAAA,CAACkB,eAAQ,IAAC,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,SAAS,EAAEb,KAAE,CAAC,IAAI,KAAK,IAAI,IAAI,SAAS,CAAC,EAAA,QAAA,EAC5E,UAAU,CAAC,IAAI,GACP,CACZ,CAAA,EAAA,CACG,CACP,EAAA,CACY,EAAA,CACQ;AAE7B,CAAC;AAEH,QAAQ,CAAC,WAAW,GAAG,iBAAiB;;"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { type FC, type ReactNode } from 'react';
|
|
2
|
-
import type { ComboBoxProps as AriaComboBoxProps, ListBoxProps as AriaListBoxProps } from 'react-aria-components';
|
|
3
|
-
import type { CommonProps, SelectItemType } from '../../selects.types';
|
|
4
|
-
interface ComboBoxProps extends Omit<AriaComboBoxProps<SelectItemType>, 'children' | 'items'>, CommonProps {
|
|
5
|
-
shortcut?: boolean;
|
|
6
|
-
items?: SelectItemType[];
|
|
7
|
-
popoverClassName?: string;
|
|
8
|
-
shortcutClassName?: string;
|
|
9
|
-
/** Leading icon component displayed before the input. */
|
|
10
|
-
icon?: FC | ReactNode;
|
|
11
|
-
/** `Select.Item` elements, or a function that renders one per entry in `items`; omit it to render each entry as a `Select.Item`. */
|
|
12
|
-
children?: AriaListBoxProps<SelectItemType>['children'];
|
|
13
|
-
}
|
|
14
|
-
export declare const ComboBox: import("react").ForwardRefExoticComponent<ComboBoxProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
15
|
-
export {};
|
|
16
|
-
//# sourceMappingURL=Combobox.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Combobox.d.ts","sourceRoot":"","sources":["../../../../../../src/components/molecules/Selects/Select/components/Combobox.tsx"],"names":[],"mappings":"AAMA,OAAO,EACL,KAAK,EAAE,EAKP,KAAK,SAAS,EAKf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,aAAa,IAAI,iBAAiB,EAAgC,YAAY,IAAI,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAahJ,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGvE,UAAU,aAAc,SAAQ,IAAI,CAAC,iBAAiB,CAAC,cAAc,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,EAAE,WAAW;IACxG,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,cAAc,EAAE,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,yDAAyD;IACzD,IAAI,CAAC,EAAE,EAAE,GAAG,SAAS,CAAC;IACtB,oIAAoI;IACpI,QAAQ,CAAC,EAAE,gBAAgB,CAAC,cAAc,CAAC,CAAC,UAAU,CAAC,CAAC;CACzD;AA4FD,eAAO,MAAM,QAAQ,0GA+DpB,CAAC"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { SearchLg } from '@flipdish/ui-icons';
|
|
3
|
-
import { Label, HintText } from '@flipdish/ui-library/components/atoms/Inputs';
|
|
4
|
-
import { useResizeObserver } from '@flipdish/ui-library/hooks/useResizeObserver';
|
|
5
|
-
import { cx } from '@flipdish/ui-library/utilities/cx';
|
|
6
|
-
import { forwardRef, useContext, useRef, useState, useCallback, isValidElement } from 'react';
|
|
7
|
-
import { ComboBoxStateContext, Group, Input, ComboBox as ComboBox$1, ListBox } from 'react-aria-components';
|
|
8
|
-
import { useHotkeyHint } from '../../../../../hooks/__internal__/useHotkeyHint/useHotkeyHint.js';
|
|
9
|
-
import { isReactComponent } from '../../../../../utilities/__internal__/componentGuardUtils/componentGuard.utils.js';
|
|
10
|
-
import { renderSelectItem } from '../../components/SelectItem.js';
|
|
11
|
-
import { SelectContext } from '../../providers/Select.context.js';
|
|
12
|
-
import { styles } from '../../Selects.styles.js';
|
|
13
|
-
import { Popover } from './Popover.js';
|
|
14
|
-
|
|
15
|
-
const ComboBoxValue = forwardRef(({ size, shortcut, placeholder, shortcutClassName, icon: IconProp, ...otherProps }, ref) => {
|
|
16
|
-
const state = useContext(ComboBoxStateContext);
|
|
17
|
-
const shortcutHint = useHotkeyHint('mod+k');
|
|
18
|
-
const value = state?.selectedItem?.value || null;
|
|
19
|
-
const inputValue = state?.inputValue || null;
|
|
20
|
-
const first = inputValue?.split(value?.supportingText)?.[0] || '';
|
|
21
|
-
const last = inputValue?.split(first)[1];
|
|
22
|
-
const renderLeadingIcon = () => {
|
|
23
|
-
if (isReactComponent(IconProp))
|
|
24
|
-
return jsx(IconProp, { "data-icon": true, className: "pointer-events-none", "aria-hidden": "true" });
|
|
25
|
-
if (isValidElement(IconProp))
|
|
26
|
-
return IconProp;
|
|
27
|
-
return jsx(SearchLg, { "data-icon": true, className: "pointer-events-none", "aria-hidden": "true" });
|
|
28
|
-
};
|
|
29
|
-
return (jsxs(Group, { ref: ref, ...otherProps, className: ({ isFocusWithin, isDisabled, isInvalid }) => cx('relative flex w-full items-center gap-2 rounded-lg bg-primary shadow-xs ring-1 ring-primary outline-hidden transition-shadow duration-100 ease-linear ring-inset', isDisabled && 'cursor-not-allowed opacity-50', isFocusWithin && 'ring-2 ring-brand', isInvalid && 'ring-error_subtle', isInvalid && isFocusWithin && 'ring-2 ring-error',
|
|
30
|
-
// Icon styles
|
|
31
|
-
'*:data-icon:shrink-0 *:data-icon:text-fg-quaternary', styles.sizes[size].root), children: [renderLeadingIcon(), jsxs("div", { className: "relative flex w-full items-center", children: [inputValue && (jsxs("span", { className: cx('absolute top-1/2 z-0 inline-flex w-full -translate-y-1/2 truncate', styles.sizes[size].textContainer), "aria-hidden": "true", children: [jsx("p", { className: cx('font-medium text-primary', styles.sizes[size].text), children: first }), last && jsx("p", { className: cx('-ml-0.75 text-tertiary', styles.sizes[size].text), children: last })] })), jsx(Input, { placeholder: placeholder, className: cx('z-10 w-full appearance-none bg-transparent text-transparent caret-alpha-black/90 placeholder:text-placeholder focus:outline-hidden disabled:cursor-not-allowed', styles.sizes[size].text) })] }), shortcut && (jsx("div", { className: cx('absolute inset-y-0.5 right-0.5 z-10 hidden items-center rounded-r-[inherit] bg-linear-to-r from-transparent to-bg-primary to-40% pl-8 md:flex', styles.sizes[size].shortcut, shortcutClassName), children: jsx("span", { className: "pointer-events-none rounded px-1 py-px text-xs font-medium text-quaternary ring-1 ring-secondary select-none ring-inset", "aria-hidden": "true", children: shortcutHint }) }))] }));
|
|
32
|
-
});
|
|
33
|
-
ComboBoxValue.displayName = 'ComboBoxValue';
|
|
34
|
-
const ComboBox = forwardRef(({ placeholder = 'Search', shortcut = true, size = 'md', children, items, shortcutClassName, icon, hideRequiredIndicator, ...otherProps }, ref) => {
|
|
35
|
-
const placeholderRef = useRef(null);
|
|
36
|
-
const [popoverWidth, setPopoverWidth] = useState('');
|
|
37
|
-
// Resize observer for popover width
|
|
38
|
-
// biome-ignore lint/correctness/useExhaustiveDependencies: We need to pass the setPopoverWidth function to the onResize callback
|
|
39
|
-
const onResize = useCallback(() => {
|
|
40
|
-
if (!placeholderRef.current)
|
|
41
|
-
return;
|
|
42
|
-
const divRect = placeholderRef.current?.getBoundingClientRect();
|
|
43
|
-
setPopoverWidth(`${divRect.width}px`);
|
|
44
|
-
}, [placeholderRef, setPopoverWidth]);
|
|
45
|
-
useResizeObserver({
|
|
46
|
-
ref: placeholderRef,
|
|
47
|
-
box: 'border-box',
|
|
48
|
-
onResize,
|
|
49
|
-
});
|
|
50
|
-
return (jsx(SelectContext.Provider, { value: { size }, children: jsx(ComboBox$1, { menuTrigger: "focus", ...otherProps, ref: ref, children: (state) => (jsxs("div", { className: "flex flex-col gap-1.5", children: [otherProps.label && (jsx(Label, { isRequired: hideRequiredIndicator ? false : state.isRequired, tooltip: otherProps.tooltip, children: otherProps.label })), jsx(ComboBoxValue, { ref: placeholderRef, placeholder: placeholder, shortcut: shortcut, shortcutClassName: shortcutClassName, icon: icon, size: size,
|
|
51
|
-
// This is a workaround to correctly calculating the trigger width
|
|
52
|
-
// while using ResizeObserver wasn't 100% reliable.
|
|
53
|
-
onFocus: onResize, onPointerEnter: onResize }), jsx(Popover, { size: size, triggerRef: placeholderRef, style: { width: popoverWidth }, className: otherProps.popoverClassName, children: jsx(ListBox, { items: items, className: "size-full outline-hidden", children: children ?? (items && renderSelectItem) }) }), otherProps.hint && (jsx(HintText, { isInvalid: state.isInvalid, className: cx(size === 'sm' && 'text-xs'), children: otherProps.hint }))] })) }) }));
|
|
54
|
-
});
|
|
55
|
-
ComboBox.displayName = 'Select.ComboBox';
|
|
56
|
-
|
|
57
|
-
export { ComboBox };
|
|
58
|
-
//# sourceMappingURL=Combobox.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Combobox.js","sources":["../../../../../../src/components/molecules/Selects/Select/components/Combobox.tsx"],"sourcesContent":[null],"names":["_jsx","_jsxs","AriaGroup","AriaInput","AriaComboBox","AriaListBox"],"mappings":";;;;;;;;;;;;;;AAuDA,MAAM,aAAa,GAAG,UAAU,CAC9B,CAAC,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