@flipdish/ui-library 0.66.1 → 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/FormFooter/index.cjs +3 -3
- package/dist/components/forms/FormFooter/index.cjs.map +1 -1
- package/dist/components/forms/FormFooter/index.js +3 -3
- package/dist/components/forms/FormFooter/index.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/components/organisms/SidePanel/components/SidePanelFooter.cjs +3 -1
- package/dist/components/organisms/SidePanel/components/SidePanelFooter.cjs.map +1 -1
- package/dist/components/organisms/SidePanel/components/SidePanelFooter.d.ts +2 -2
- package/dist/components/organisms/SidePanel/components/SidePanelFooter.d.ts.map +1 -1
- package/dist/components/organisms/SidePanel/components/SidePanelFooter.js +3 -1
- package/dist/components/organisms/SidePanel/components/SidePanelFooter.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
|
@@ -3,36 +3,128 @@
|
|
|
3
3
|
var React = require('react');
|
|
4
4
|
var children_utils = require('../../../../../utilities/__internal__/childrenUtils/children.utils.cjs');
|
|
5
5
|
|
|
6
|
+
const toOption = (source, fallback = {}) => {
|
|
7
|
+
const id = source.id ?? fallback.id;
|
|
8
|
+
if (id == null)
|
|
9
|
+
return null;
|
|
10
|
+
const text = source.label || (typeof source.children === 'string' ? source.children : '') || source.textValue || fallback.label;
|
|
11
|
+
return { id, label: text || String(id), isDisabled: Boolean(source.isDisabled ?? fallback.isDisabled) };
|
|
12
|
+
};
|
|
13
|
+
const isOption = (option) => option !== null;
|
|
14
|
+
/**
|
|
15
|
+
* Lists the options the menu draws, in its order, which is the order the trigger shows their pills. It reads them from
|
|
16
|
+
* the same place react-aria does, so the trigger and the footer never act on an option the menu does not show.
|
|
17
|
+
*
|
|
18
|
+
* @param items The data-driven `items` list; used with a render function, or alone when there are no children.
|
|
19
|
+
* @param children Static `MultiSelect.Item` elements, which react-aria draws in place of `items`, or a render function.
|
|
20
|
+
* A render function is called per item and the id, text and disabled state of the element it returns win over the item's.
|
|
21
|
+
* @returns One entry per option that has an id. Empty when children is a render function and no items were passed.
|
|
22
|
+
*/
|
|
23
|
+
const collectOptions = (items, children) => {
|
|
24
|
+
if (typeof children === 'function') {
|
|
25
|
+
return (items ?? [])
|
|
26
|
+
.map((item) => {
|
|
27
|
+
const rendered = children(item);
|
|
28
|
+
return toOption(React.isValidElement(rendered) ? rendered.props : {}, item);
|
|
29
|
+
})
|
|
30
|
+
.filter(isOption);
|
|
31
|
+
}
|
|
32
|
+
if (children != null) {
|
|
33
|
+
return children_utils.flattenChildren(children)
|
|
34
|
+
.filter(React.isValidElement)
|
|
35
|
+
.map((child) => toOption(child.props))
|
|
36
|
+
.filter(isOption);
|
|
37
|
+
}
|
|
38
|
+
return (items ?? []).map((item) => toOption(item)).filter(isOption);
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Reads a selection once into a form that can be read again. An iterable such as a generator is spent by its first
|
|
42
|
+
* read, so the same one must never be read on a later render.
|
|
43
|
+
*
|
|
44
|
+
* @param selection The selection as the consumer passed it.
|
|
45
|
+
* @returns `'all'`, `undefined` and a set as they are; any other iterable as a new set of its keys.
|
|
46
|
+
*/
|
|
47
|
+
const snapshotSelection = (selection) => {
|
|
48
|
+
if (selection === undefined)
|
|
49
|
+
return undefined;
|
|
50
|
+
// Returned as a literal: a string is itself iterable, so the comparison alone does not narrow the type.
|
|
51
|
+
if (selection === 'all')
|
|
52
|
+
return 'all';
|
|
53
|
+
return selection instanceof Set ? selection : new Set(selection);
|
|
54
|
+
};
|
|
6
55
|
/**
|
|
7
|
-
*
|
|
56
|
+
* Turns a selection into explicit keys, so nothing downstream has to handle `'all'`.
|
|
8
57
|
*
|
|
9
|
-
* @param selection The
|
|
10
|
-
* @param
|
|
11
|
-
* @returns The
|
|
58
|
+
* @param selection The selection as the consumer or the list reports it.
|
|
59
|
+
* @param options Every option, used to expand `'all'`.
|
|
60
|
+
* @returns The same set when one was given, a set of any other iterable's keys, and an empty set for none. `'all'`
|
|
61
|
+
* gives every enabled option's id, as it does in react-aria: a disabled option the user could never untick is left out.
|
|
12
62
|
*/
|
|
13
|
-
const
|
|
63
|
+
const resolveSelectedKeys = (selection, options) => {
|
|
14
64
|
if (selection instanceof Set)
|
|
15
|
-
return selection
|
|
16
|
-
|
|
65
|
+
return selection;
|
|
66
|
+
if (selection === 'all')
|
|
67
|
+
return new Set(options.filter((option) => !option.isDisabled).map((option) => option.id));
|
|
68
|
+
return new Set(selection ?? []);
|
|
17
69
|
};
|
|
18
70
|
/**
|
|
19
|
-
*
|
|
71
|
+
* Applies Select all: ticks every option the user is allowed to change.
|
|
72
|
+
*
|
|
73
|
+
* @param current The keys ticked before the press.
|
|
74
|
+
* @param options Every option. A disabled one keeps the state it had.
|
|
75
|
+
* @returns The keys ticked after the press.
|
|
76
|
+
*/
|
|
77
|
+
const selectAllKeys = (current, options) => new Set([...current, ...options.filter((option) => !option.isDisabled).map((option) => option.id)]);
|
|
78
|
+
/**
|
|
79
|
+
* Applies Clear all: unticks every option the user is allowed to change.
|
|
80
|
+
*
|
|
81
|
+
* @param current The keys ticked before the press.
|
|
82
|
+
* @param options Every option. A disabled one that is ticked stays ticked.
|
|
83
|
+
* @returns The keys ticked after the press.
|
|
84
|
+
*/
|
|
85
|
+
const clearAllKeys = (current, options) => new Set(options.filter((option) => option.isDisabled && current.has(option.id)).map((option) => option.id));
|
|
86
|
+
/**
|
|
87
|
+
* Compares two selections by their members.
|
|
88
|
+
*
|
|
89
|
+
* @param a One selection.
|
|
90
|
+
* @param b The other selection.
|
|
91
|
+
* @returns `true` when both hold exactly the same keys.
|
|
92
|
+
*/
|
|
93
|
+
const areKeySetsEqual = (a, b) => a.size === b.size && [...a].every((key) => b.has(key));
|
|
94
|
+
/**
|
|
95
|
+
* Works out how many pills the trigger shows before it collapses the rest into `+N`.
|
|
20
96
|
*
|
|
21
|
-
* @param
|
|
22
|
-
* @
|
|
23
|
-
*
|
|
97
|
+
* @param options The pill, row, gap and overflow-count widths.
|
|
98
|
+
* @returns Every pill when they all fit, otherwise as many whole pills as fit beside the count. When not even one whole
|
|
99
|
+
* pill fits, one if it can be squeezed into the room left, and none (the count alone) if it cannot.
|
|
24
100
|
*/
|
|
25
|
-
const
|
|
26
|
-
if (
|
|
27
|
-
return
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
101
|
+
const countFittingPills = ({ pillWidths, availableWidth, gap, overflowWidth, minPillWidth }) => {
|
|
102
|
+
if (pillWidths.length === 0)
|
|
103
|
+
return 0;
|
|
104
|
+
const totalWidth = pillWidths.reduce((sum, width) => sum + width, 0) + gap * (pillWidths.length - 1);
|
|
105
|
+
if (totalWidth <= availableWidth)
|
|
106
|
+
return pillWidths.length;
|
|
107
|
+
let usedWidth = 0;
|
|
108
|
+
let count = 0;
|
|
109
|
+
for (const width of pillWidths) {
|
|
110
|
+
const nextWidth = usedWidth + width + gap;
|
|
111
|
+
if (nextWidth + overflowWidth > availableWidth)
|
|
112
|
+
break;
|
|
113
|
+
usedWidth = nextWidth;
|
|
114
|
+
count += 1;
|
|
115
|
+
}
|
|
116
|
+
if (count > 0)
|
|
117
|
+
return count;
|
|
118
|
+
// A lone pill needs no count beside it; any other is squeezed into what the count leaves.
|
|
119
|
+
const roomForOnePill = pillWidths.length > 1 ? availableWidth - gap - overflowWidth : availableWidth;
|
|
120
|
+
return roomForOnePill >= minPillWidth ? 1 : 0;
|
|
34
121
|
};
|
|
35
122
|
|
|
36
|
-
exports.
|
|
37
|
-
exports.
|
|
123
|
+
exports.areKeySetsEqual = areKeySetsEqual;
|
|
124
|
+
exports.clearAllKeys = clearAllKeys;
|
|
125
|
+
exports.collectOptions = collectOptions;
|
|
126
|
+
exports.countFittingPills = countFittingPills;
|
|
127
|
+
exports.resolveSelectedKeys = resolveSelectedKeys;
|
|
128
|
+
exports.selectAllKeys = selectAllKeys;
|
|
129
|
+
exports.snapshotSelection = snapshotSelection;
|
|
38
130
|
//# sourceMappingURL=multiSelect.utils.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multiSelect.utils.cjs","sources":["../../../../../../src/components/molecules/Selects/MultiSelect/utilities/multiSelect.utils.ts"],"sourcesContent":[null],"names":["
|
|
1
|
+
{"version":3,"file":"multiSelect.utils.cjs","sources":["../../../../../../src/components/molecules/Selects/MultiSelect/utilities/multiSelect.utils.ts"],"sourcesContent":[null],"names":["isValidElement","flattenChildren"],"mappings":";;;;;AA+BA,MAAM,QAAQ,GAAG,CAAC,MAAoB,EAAE,QAAA,GAAyB,EAAE,KAA8B;IAC/F,MAAM,EAAE,GAAG,MAAM,CAAC,EAAE,IAAI,QAAQ,CAAC,EAAE;IACnC,IAAI,EAAE,IAAI,IAAI;AAAE,QAAA,OAAO,IAAI;AAC3B,IAAA,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,KAAK,OAAO,MAAM,CAAC,QAAQ,KAAK,QAAQ,GAAG,MAAM,CAAC,QAAQ,GAAG,EAAE,CAAC,IAAI,MAAM,CAAC,SAAS,IAAI,QAAQ,CAAC,KAAK;IAC/H,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,IAAI,MAAM,CAAC,EAAE,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,MAAM,CAAC,UAAU,IAAI,QAAQ,CAAC,UAAU,CAAC,EAAE;AACzG,CAAC;AAED,MAAM,QAAQ,GAAG,CAAC,MAAgC,KAAkC,MAAM,KAAK,IAAI;AAEnG;;;;;;;;AAQG;MACU,cAAc,GAAG,CAAC,KAA4C,EAAE,QAA6B,KAAyB;AACjI,IAAA,IAAI,OAAO,QAAQ,KAAK,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;IACpG,IAAI,UAAU,IAAI,cAAc;QAAE,OAAO,UAAU,CAAC,MAAM;IAE1D,IAAI,SAAS,GAAG,CAAC;IACjB,IAAI,KAAK,GAAG,CAAC;AACb,IAAA,KAAK,MAAM,KAAK,IAAI,UAAU,EAAE;AAC9B,QAAA,MAAM,SAAS,GAAG,SAAS,GAAG,KAAK,GAAG,GAAG;AACzC,QAAA,IAAI,SAAS,GAAG,aAAa,GAAG,cAAc;YAAE;QAChD,SAAS,GAAG,SAAS;QACrB,KAAK,IAAI,CAAC;IACZ;IACA,IAAI,KAAK,GAAG,CAAC;AAAE,QAAA,OAAO,KAAK;;AAG3B,IAAA,MAAM,cAAc,GAAG,UAAU,CAAC,MAAM,GAAG,CAAC,GAAG,cAAc,GAAG,GAAG,GAAG,aAAa,GAAG,cAAc;IACpG,OAAO,cAAc,IAAI,YAAY,GAAG,CAAC,GAAG,CAAC;AAC/C;;;;;;;;"}
|
|
@@ -1,23 +1,90 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
2
|
import type { SelectItemType } from '../../selects.types';
|
|
3
|
-
/**
|
|
4
|
-
export type
|
|
3
|
+
/** The id of one option. */
|
|
4
|
+
export type MultiSelectKey = string | number;
|
|
5
|
+
/** Explicit keys in any iterable, or `'all'` for every option the user is allowed to change. */
|
|
6
|
+
export type MultiSelectSelection = 'all' | Iterable<MultiSelectKey>;
|
|
5
7
|
/** Static item elements, or a render function when the list is data-driven. */
|
|
6
8
|
export type MultiSelectChildren = ReactNode | ((item: SelectItemType) => ReactNode);
|
|
9
|
+
/** What the trigger and the footer need to know about one option. */
|
|
10
|
+
export interface MultiSelectOption {
|
|
11
|
+
/** The option's key in the selection. */
|
|
12
|
+
id: MultiSelectKey;
|
|
13
|
+
/** The text its pill shows in the trigger. */
|
|
14
|
+
label: string;
|
|
15
|
+
/** Whether the user is blocked from ticking or unticking it. */
|
|
16
|
+
isDisabled: boolean;
|
|
17
|
+
}
|
|
7
18
|
/**
|
|
8
|
-
*
|
|
19
|
+
* Lists the options the menu draws, in its order, which is the order the trigger shows their pills. It reads them from
|
|
20
|
+
* the same place react-aria does, so the trigger and the footer never act on an option the menu does not show.
|
|
9
21
|
*
|
|
10
|
-
* @param
|
|
11
|
-
* @param
|
|
12
|
-
*
|
|
22
|
+
* @param items The data-driven `items` list; used with a render function, or alone when there are no children.
|
|
23
|
+
* @param children Static `MultiSelect.Item` elements, which react-aria draws in place of `items`, or a render function.
|
|
24
|
+
* A render function is called per item and the id, text and disabled state of the element it returns win over the item's.
|
|
25
|
+
* @returns One entry per option that has an id. Empty when children is a render function and no items were passed.
|
|
13
26
|
*/
|
|
14
|
-
export declare const
|
|
27
|
+
export declare const collectOptions: (items: readonly SelectItemType[] | undefined, children: MultiSelectChildren) => MultiSelectOption[];
|
|
15
28
|
/**
|
|
16
|
-
*
|
|
29
|
+
* Reads a selection once into a form that can be read again. An iterable such as a generator is spent by its first
|
|
30
|
+
* read, so the same one must never be read on a later render.
|
|
17
31
|
*
|
|
18
|
-
* @param
|
|
19
|
-
* @
|
|
20
|
-
* @returns Those ids. Empty when children is a render function and no items were passed.
|
|
32
|
+
* @param selection The selection as the consumer passed it.
|
|
33
|
+
* @returns `'all'`, `undefined` and a set as they are; any other iterable as a new set of its keys.
|
|
21
34
|
*/
|
|
22
|
-
export declare const
|
|
35
|
+
export declare const snapshotSelection: (selection: MultiSelectSelection | undefined) => "all" | Set<MultiSelectKey> | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Turns a selection into explicit keys, so nothing downstream has to handle `'all'`.
|
|
38
|
+
*
|
|
39
|
+
* @param selection The selection as the consumer or the list reports it.
|
|
40
|
+
* @param options Every option, used to expand `'all'`.
|
|
41
|
+
* @returns The same set when one was given, a set of any other iterable's keys, and an empty set for none. `'all'`
|
|
42
|
+
* gives every enabled option's id, as it does in react-aria: a disabled option the user could never untick is left out.
|
|
43
|
+
*/
|
|
44
|
+
export declare const resolveSelectedKeys: (selection: MultiSelectSelection | undefined, options: readonly MultiSelectOption[]) => Set<MultiSelectKey>;
|
|
45
|
+
/**
|
|
46
|
+
* Applies Select all: ticks every option the user is allowed to change.
|
|
47
|
+
*
|
|
48
|
+
* @param current The keys ticked before the press.
|
|
49
|
+
* @param options Every option. A disabled one keeps the state it had.
|
|
50
|
+
* @returns The keys ticked after the press.
|
|
51
|
+
*/
|
|
52
|
+
export declare const selectAllKeys: (current: ReadonlySet<MultiSelectKey>, options: readonly MultiSelectOption[]) => Set<MultiSelectKey>;
|
|
53
|
+
/**
|
|
54
|
+
* Applies Clear all: unticks every option the user is allowed to change.
|
|
55
|
+
*
|
|
56
|
+
* @param current The keys ticked before the press.
|
|
57
|
+
* @param options Every option. A disabled one that is ticked stays ticked.
|
|
58
|
+
* @returns The keys ticked after the press.
|
|
59
|
+
*/
|
|
60
|
+
export declare const clearAllKeys: (current: ReadonlySet<MultiSelectKey>, options: readonly MultiSelectOption[]) => Set<MultiSelectKey>;
|
|
61
|
+
/**
|
|
62
|
+
* Compares two selections by their members.
|
|
63
|
+
*
|
|
64
|
+
* @param a One selection.
|
|
65
|
+
* @param b The other selection.
|
|
66
|
+
* @returns `true` when both hold exactly the same keys.
|
|
67
|
+
*/
|
|
68
|
+
export declare const areKeySetsEqual: (a: ReadonlySet<MultiSelectKey>, b: ReadonlySet<MultiSelectKey>) => boolean;
|
|
69
|
+
/** The measurements `countFittingPills` works from, all in pixels. */
|
|
70
|
+
export interface PillFitOptions {
|
|
71
|
+
/** Width of each pill, in the order they are shown. */
|
|
72
|
+
pillWidths: readonly number[];
|
|
73
|
+
/** Width of the row the pills share with the overflow count. */
|
|
74
|
+
availableWidth: number;
|
|
75
|
+
/** Space between two neighbours in the row. */
|
|
76
|
+
gap: number;
|
|
77
|
+
/** Width reserved for the `+N` count when some pills are left out. */
|
|
78
|
+
overflowWidth: number;
|
|
79
|
+
/** The narrowest the first pill can be squeezed to and still show its remove button and a few characters. */
|
|
80
|
+
minPillWidth: number;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Works out how many pills the trigger shows before it collapses the rest into `+N`.
|
|
84
|
+
*
|
|
85
|
+
* @param options The pill, row, gap and overflow-count widths.
|
|
86
|
+
* @returns Every pill when they all fit, otherwise as many whole pills as fit beside the count. When not even one whole
|
|
87
|
+
* pill fits, one if it can be squeezed into the room left, and none (the count alone) if it cannot.
|
|
88
|
+
*/
|
|
89
|
+
export declare const countFittingPills: ({ pillWidths, availableWidth, gap, overflowWidth, minPillWidth }: PillFitOptions) => number;
|
|
23
90
|
//# sourceMappingURL=multiSelect.utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multiSelect.utils.d.ts","sourceRoot":"","sources":["../../../../../../src/components/molecules/Selects/MultiSelect/utilities/multiSelect.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D
|
|
1
|
+
{"version":3,"file":"multiSelect.utils.d.ts","sourceRoot":"","sources":["../../../../../../src/components/molecules/Selects/MultiSelect/utilities/multiSelect.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,4BAA4B;AAC5B,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,CAAC;AAE7C,gGAAgG;AAChG,MAAM,MAAM,oBAAoB,GAAG,KAAK,GAAG,QAAQ,CAAC,cAAc,CAAC,CAAC;AAEpE,+EAA+E;AAC/E,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,CAAC,CAAC,IAAI,EAAE,cAAc,KAAK,SAAS,CAAC,CAAC;AAEpF,qEAAqE;AACrE,MAAM,WAAW,iBAAiB;IAChC,yCAAyC;IACzC,EAAE,EAAE,cAAc,CAAC;IACnB,8CAA8C;IAC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O,MAAM,iBAAiB,GAAI,kEAAkE,cAAc,KAAG,MAmBpH,CAAC"}
|
|
@@ -1,35 +1,122 @@
|
|
|
1
1
|
import { isValidElement } from 'react';
|
|
2
2
|
import { flattenChildren } from '../../../../../utilities/__internal__/childrenUtils/children.utils.js';
|
|
3
3
|
|
|
4
|
+
const toOption = (source, fallback = {}) => {
|
|
5
|
+
const id = source.id ?? fallback.id;
|
|
6
|
+
if (id == null)
|
|
7
|
+
return null;
|
|
8
|
+
const text = source.label || (typeof source.children === 'string' ? source.children : '') || source.textValue || fallback.label;
|
|
9
|
+
return { id, label: text || String(id), isDisabled: Boolean(source.isDisabled ?? fallback.isDisabled) };
|
|
10
|
+
};
|
|
11
|
+
const isOption = (option) => option !== null;
|
|
12
|
+
/**
|
|
13
|
+
* Lists the options the menu draws, in its order, which is the order the trigger shows their pills. It reads them from
|
|
14
|
+
* the same place react-aria does, so the trigger and the footer never act on an option the menu does not show.
|
|
15
|
+
*
|
|
16
|
+
* @param items The data-driven `items` list; used with a render function, or alone when there are no children.
|
|
17
|
+
* @param children Static `MultiSelect.Item` elements, which react-aria draws in place of `items`, or a render function.
|
|
18
|
+
* A render function is called per item and the id, text and disabled state of the element it returns win over the item's.
|
|
19
|
+
* @returns One entry per option that has an id. Empty when children is a render function and no items were passed.
|
|
20
|
+
*/
|
|
21
|
+
const collectOptions = (items, children) => {
|
|
22
|
+
if (typeof children === 'function') {
|
|
23
|
+
return (items ?? [])
|
|
24
|
+
.map((item) => {
|
|
25
|
+
const rendered = children(item);
|
|
26
|
+
return toOption(isValidElement(rendered) ? rendered.props : {}, item);
|
|
27
|
+
})
|
|
28
|
+
.filter(isOption);
|
|
29
|
+
}
|
|
30
|
+
if (children != null) {
|
|
31
|
+
return flattenChildren(children)
|
|
32
|
+
.filter(isValidElement)
|
|
33
|
+
.map((child) => toOption(child.props))
|
|
34
|
+
.filter(isOption);
|
|
35
|
+
}
|
|
36
|
+
return (items ?? []).map((item) => toOption(item)).filter(isOption);
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Reads a selection once into a form that can be read again. An iterable such as a generator is spent by its first
|
|
40
|
+
* read, so the same one must never be read on a later render.
|
|
41
|
+
*
|
|
42
|
+
* @param selection The selection as the consumer passed it.
|
|
43
|
+
* @returns `'all'`, `undefined` and a set as they are; any other iterable as a new set of its keys.
|
|
44
|
+
*/
|
|
45
|
+
const snapshotSelection = (selection) => {
|
|
46
|
+
if (selection === undefined)
|
|
47
|
+
return undefined;
|
|
48
|
+
// Returned as a literal: a string is itself iterable, so the comparison alone does not narrow the type.
|
|
49
|
+
if (selection === 'all')
|
|
50
|
+
return 'all';
|
|
51
|
+
return selection instanceof Set ? selection : new Set(selection);
|
|
52
|
+
};
|
|
4
53
|
/**
|
|
5
|
-
*
|
|
54
|
+
* Turns a selection into explicit keys, so nothing downstream has to handle `'all'`.
|
|
6
55
|
*
|
|
7
|
-
* @param selection The
|
|
8
|
-
* @param
|
|
9
|
-
* @returns The
|
|
56
|
+
* @param selection The selection as the consumer or the list reports it.
|
|
57
|
+
* @param options Every option, used to expand `'all'`.
|
|
58
|
+
* @returns The same set when one was given, a set of any other iterable's keys, and an empty set for none. `'all'`
|
|
59
|
+
* gives every enabled option's id, as it does in react-aria: a disabled option the user could never untick is left out.
|
|
10
60
|
*/
|
|
11
|
-
const
|
|
61
|
+
const resolveSelectedKeys = (selection, options) => {
|
|
12
62
|
if (selection instanceof Set)
|
|
13
|
-
return selection
|
|
14
|
-
|
|
63
|
+
return selection;
|
|
64
|
+
if (selection === 'all')
|
|
65
|
+
return new Set(options.filter((option) => !option.isDisabled).map((option) => option.id));
|
|
66
|
+
return new Set(selection ?? []);
|
|
15
67
|
};
|
|
16
68
|
/**
|
|
17
|
-
*
|
|
69
|
+
* Applies Select all: ticks every option the user is allowed to change.
|
|
70
|
+
*
|
|
71
|
+
* @param current The keys ticked before the press.
|
|
72
|
+
* @param options Every option. A disabled one keeps the state it had.
|
|
73
|
+
* @returns The keys ticked after the press.
|
|
74
|
+
*/
|
|
75
|
+
const selectAllKeys = (current, options) => new Set([...current, ...options.filter((option) => !option.isDisabled).map((option) => option.id)]);
|
|
76
|
+
/**
|
|
77
|
+
* Applies Clear all: unticks every option the user is allowed to change.
|
|
78
|
+
*
|
|
79
|
+
* @param current The keys ticked before the press.
|
|
80
|
+
* @param options Every option. A disabled one that is ticked stays ticked.
|
|
81
|
+
* @returns The keys ticked after the press.
|
|
82
|
+
*/
|
|
83
|
+
const clearAllKeys = (current, options) => new Set(options.filter((option) => option.isDisabled && current.has(option.id)).map((option) => option.id));
|
|
84
|
+
/**
|
|
85
|
+
* Compares two selections by their members.
|
|
86
|
+
*
|
|
87
|
+
* @param a One selection.
|
|
88
|
+
* @param b The other selection.
|
|
89
|
+
* @returns `true` when both hold exactly the same keys.
|
|
90
|
+
*/
|
|
91
|
+
const areKeySetsEqual = (a, b) => a.size === b.size && [...a].every((key) => b.has(key));
|
|
92
|
+
/**
|
|
93
|
+
* Works out how many pills the trigger shows before it collapses the rest into `+N`.
|
|
18
94
|
*
|
|
19
|
-
* @param
|
|
20
|
-
* @
|
|
21
|
-
*
|
|
95
|
+
* @param options The pill, row, gap and overflow-count widths.
|
|
96
|
+
* @returns Every pill when they all fit, otherwise as many whole pills as fit beside the count. When not even one whole
|
|
97
|
+
* pill fits, one if it can be squeezed into the room left, and none (the count alone) if it cannot.
|
|
22
98
|
*/
|
|
23
|
-
const
|
|
24
|
-
if (
|
|
25
|
-
return
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
99
|
+
const countFittingPills = ({ pillWidths, availableWidth, gap, overflowWidth, minPillWidth }) => {
|
|
100
|
+
if (pillWidths.length === 0)
|
|
101
|
+
return 0;
|
|
102
|
+
const totalWidth = pillWidths.reduce((sum, width) => sum + width, 0) + gap * (pillWidths.length - 1);
|
|
103
|
+
if (totalWidth <= availableWidth)
|
|
104
|
+
return pillWidths.length;
|
|
105
|
+
let usedWidth = 0;
|
|
106
|
+
let count = 0;
|
|
107
|
+
for (const width of pillWidths) {
|
|
108
|
+
const nextWidth = usedWidth + width + gap;
|
|
109
|
+
if (nextWidth + overflowWidth > availableWidth)
|
|
110
|
+
break;
|
|
111
|
+
usedWidth = nextWidth;
|
|
112
|
+
count += 1;
|
|
113
|
+
}
|
|
114
|
+
if (count > 0)
|
|
115
|
+
return count;
|
|
116
|
+
// A lone pill needs no count beside it; any other is squeezed into what the count leaves.
|
|
117
|
+
const roomForOnePill = pillWidths.length > 1 ? availableWidth - gap - overflowWidth : availableWidth;
|
|
118
|
+
return roomForOnePill >= minPillWidth ? 1 : 0;
|
|
32
119
|
};
|
|
33
120
|
|
|
34
|
-
export {
|
|
121
|
+
export { areKeySetsEqual, clearAllKeys, collectOptions, countFittingPills, resolveSelectedKeys, selectAllKeys, snapshotSelection };
|
|
35
122
|
//# sourceMappingURL=multiSelect.utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multiSelect.utils.js","sources":["../../../../../../src/components/molecules/Selects/MultiSelect/utilities/multiSelect.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"multiSelect.utils.js","sources":["../../../../../../src/components/molecules/Selects/MultiSelect/utilities/multiSelect.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AA+BA,MAAM,QAAQ,GAAG,CAAC,MAAoB,EAAE,QAAA,GAAyB,EAAE,KAA8B;IAC/F,MAAM,EAAE,GAAG,MAAM,CAAC,EAAE,IAAI,QAAQ,CAAC,EAAE;IACnC,IAAI,EAAE,IAAI,IAAI;AAAE,QAAA,OAAO,IAAI;AAC3B,IAAA,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,KAAK,OAAO,MAAM,CAAC,QAAQ,KAAK,QAAQ,GAAG,MAAM,CAAC,QAAQ,GAAG,EAAE,CAAC,IAAI,MAAM,CAAC,SAAS,IAAI,QAAQ,CAAC,KAAK;IAC/H,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AiB,GAAG,CAAC,EAAE,UAAU,EAAE,cAAc,EAAE,GAAG,EAAE,aAAa,EAAE,YAAY,EAAkB,KAAY;AAC5H,IAAA,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;AAAE,QAAA,OAAO,CAAC;AAErC,IAAA,MAAM,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,KAAK,GAAG,GAAG,KAAK,EAAE,CAAC,CAAC,GAAG,GAAG,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC;IACpG,IAAI,UAAU,IAAI,cAAc;QAAE,OAAO,UAAU,CAAC,MAAM;IAE1D,IAAI,SAAS,GAAG,CAAC;IACjB,IAAI,KAAK,GAAG,CAAC;AACb,IAAA,KAAK,MAAM,KAAK,IAAI,UAAU,EAAE;AAC9B,QAAA,MAAM,SAAS,GAAG,SAAS,GAAG,KAAK,GAAG,GAAG;AACzC,QAAA,IAAI,SAAS,GAAG,aAAa,GAAG,cAAc;YAAE;QAChD,SAAS,GAAG,SAAS;QACrB,KAAK,IAAI,CAAC;IACZ;IACA,IAAI,KAAK,GAAG,CAAC;AAAE,QAAA,OAAO,KAAK;;AAG3B,IAAA,MAAM,cAAc,GAAG,UAAU,CAAC,MAAM,GAAG,CAAC,GAAG,cAAc,GAAG,GAAG,GAAG,aAAa,GAAG,cAAc;IACpG,OAAO,cAAc,IAAI,YAAY,GAAG,CAAC,GAAG,CAAC;AAC/C;;"}
|
|
@@ -12,7 +12,6 @@ var componentGuard_utils = require('../../../../utilities/__internal__/component
|
|
|
12
12
|
var SelectItem = require('../components/SelectItem.cjs');
|
|
13
13
|
var Select_context = require('../providers/Select.context.cjs');
|
|
14
14
|
var Selects_styles = require('../Selects.styles.cjs');
|
|
15
|
-
var Combobox = require('./components/Combobox.cjs');
|
|
16
15
|
var Popover = require('./components/Popover.cjs');
|
|
17
16
|
|
|
18
17
|
const SelectValue = ({ isOpen, isFocused, isDisabled, isInvalid, size, placeholder, icon, 'data-testid': dataTestId, }) => {
|
|
@@ -38,7 +37,7 @@ const SelectValue = ({ isOpen, isFocused, isDisabled, isInvalid, size, placehold
|
|
|
38
37
|
};
|
|
39
38
|
const SelectRoot = React.forwardRef(({ placeholder = 'Select', icon, size = 'md', children, items, popoverClassName, label, hint, tooltip, hideRequiredIndicator, className, 'data-testid': dataTestId, ...rest }, ref) => {
|
|
40
39
|
const rootTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'select', rootName: 'select' });
|
|
41
|
-
return (jsxRuntime.jsx(Select_context.SelectContext.Provider, { value: { size, testIdPrefix: rootTestId }, children: jsxRuntime.jsx(reactAriaComponents.Select, { ...rest, ref: ref, "data-testid": rootTestId, className: (state) => cx.cx('flex flex-col gap-1.5', typeof className === 'function' ? className(state) : className), children: (state) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [label && (jsxRuntime.jsx(Inputs.Label, { isRequired: hideRequiredIndicator ? false : state.isRequired, tooltip: tooltip, children: label })), jsxRuntime.jsx(SelectValue, { ...state, size, placeholder, icon: icon, "data-testid": testIdUtils.joinTestId(rootTestId, 'trigger') }), jsxRuntime.jsx(Popover.Popover, { size: size, className: popoverClassName, children: jsxRuntime.jsx(reactAriaComponents.ListBox, { items: items, className: "size-full outline-hidden", children: children ?? (items && SelectItem.renderSelectItem) }) }), hint && (jsxRuntime.jsx(Inputs.HintText, { isInvalid: state.isInvalid, className: cx.cx(size === 'sm' && 'text-xs'), children: hint }))] })) }) }));
|
|
40
|
+
return (jsxRuntime.jsx(Select_context.SelectContext.Provider, { value: { size, testIdPrefix: rootTestId }, children: jsxRuntime.jsx(reactAriaComponents.Select, { ...rest, ref: ref, "data-testid": rootTestId, className: (state) => cx.cx('flex flex-col gap-1.5', typeof className === 'function' ? className(state) : className), children: (state) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [label && (jsxRuntime.jsx(Inputs.Label, { isRequired: hideRequiredIndicator ? false : state.isRequired, isInvalid: state.isInvalid, tooltip: tooltip, children: label })), jsxRuntime.jsx(SelectValue, { ...state, size, placeholder, icon: icon, "data-testid": testIdUtils.joinTestId(rootTestId, 'trigger') }), jsxRuntime.jsx(Popover.Popover, { size: size, className: popoverClassName, children: jsxRuntime.jsx(reactAriaComponents.ListBox, { items: items, className: "size-full outline-hidden", children: children ?? (items && SelectItem.renderSelectItem) }) }), hint && (jsxRuntime.jsx(Inputs.HintText, { isInvalid: state.isInvalid, className: cx.cx(size === 'sm' && 'text-xs'), children: hint }))] })) }) }));
|
|
42
41
|
});
|
|
43
42
|
/**
|
|
44
43
|
* Dropdown select that lets the user choose one option from a list.
|
|
@@ -46,7 +45,6 @@ const SelectRoot = React.forwardRef(({ placeholder = 'Select', icon, size = 'md'
|
|
|
46
45
|
* @summary let the user pick one option from a dropdown list
|
|
47
46
|
*/
|
|
48
47
|
const Select = SelectRoot;
|
|
49
|
-
Select.ComboBox = Combobox.ComboBox;
|
|
50
48
|
Select.Item = SelectItem.SelectItem;
|
|
51
49
|
// Keeps the name React DevTools and component stacks showed before the root was split from the exported alias.
|
|
52
50
|
SelectRoot.displayName = 'Select';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.cjs","sources":["../../../../../src/components/molecules/Selects/Select/Select.tsx"],"sourcesContent":[null],"names":["_jsx","AriaButton","cx","AriaSelectValue","styles","Avatar","isReactComponent","isValidElement","_jsxs","_Fragment","ChevronDown","forwardRef","useResolvedTestId","SelectContext","AriaSelect","Label","joinTestId","Popover","AriaListBox","renderSelectItem","HintText","
|
|
1
|
+
{"version":3,"file":"Select.cjs","sources":["../../../../../src/components/molecules/Selects/Select/Select.tsx"],"sourcesContent":[null],"names":["_jsx","AriaButton","cx","AriaSelectValue","styles","Avatar","isReactComponent","isValidElement","_jsxs","_Fragment","ChevronDown","forwardRef","useResolvedTestId","SelectContext","AriaSelect","Label","joinTestId","Popover","AriaListBox","renderSelectItem","HintText","SelectItem"],"mappings":";;;;;;;;;;;;;;;;AAsCA,MAAM,W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YAC9CjB,cAAA,CAACkB,2BAAW,IAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAC,0BAA0B,YAE5D,QAAQ,KAAK,KAAK,IAAIC,2BAAgB,CAAC,EAAA,CAC5B,GACN,EAET,IAAI,KACHnB,cAAA,CAACoB,eAAQ,EAAA,EAAC,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,SAAS,EAAElB,KAAE,CAAC,IAAI,KAAK,IAAI,IAAI,SAAS,CAAC,EAAA,QAAA,EAC5E,IAAI,GACI,CACZ,CAAA,EAAA,CACA,CACJ,EAAA,CACU,EAAA,CACU;AAE7B,CAAC,CACF;AAED;;;;AAIG;AACI,MAAM,MAAM,GAAG;AAGtB,MAAM,CAAC,IAAI,GAAGmB,qBAAU;AACxB;AACA,UAAU,CAAC,WAAW,GAAG,QAAQ;;"}
|
|
@@ -2,7 +2,6 @@ import { type FC, type ReactNode } from 'react';
|
|
|
2
2
|
import type { SelectProps as AriaSelectProps } from 'react-aria-components';
|
|
3
3
|
import { SelectItem } from '../components/SelectItem';
|
|
4
4
|
import type { CommonProps, SelectItemType } from '../selects.types';
|
|
5
|
-
import { ComboBox } from './components/Combobox';
|
|
6
5
|
export interface SelectProps extends Omit<AriaSelectProps<SelectItemType>, 'children' | 'items'>, CommonProps {
|
|
7
6
|
/** Options passed to the list box; each renders as a `Select.Item` unless a render-function `children` draws it. */
|
|
8
7
|
items?: SelectItemType[];
|
|
@@ -20,7 +19,6 @@ declare const SelectRoot: import("react").ForwardRefExoticComponent<SelectProps
|
|
|
20
19
|
* @summary let the user pick one option from a dropdown list
|
|
21
20
|
*/
|
|
22
21
|
export declare const Select: typeof SelectRoot & {
|
|
23
|
-
ComboBox: typeof ComboBox;
|
|
24
22
|
Item: typeof SelectItem;
|
|
25
23
|
};
|
|
26
24
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../../../src/components/molecules/Selects/Select/Select.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,EAAE,EAA8B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5E,OAAO,KAAK,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAG5E,OAAO,EAAoB,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAGxE,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../../../src/components/molecules/Selects/Select/Select.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,EAAE,EAA8B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5E,OAAO,KAAK,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAG5E,OAAO,EAAoB,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAGxE,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGpE,MAAM,WAAW,WAAY,SAAQ,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,EAAE,WAAW;IAC3G,oHAAoH;IACpH,KAAK,CAAC,EAAE,cAAc,EAAE,CAAC;IACzB,sDAAsD;IACtD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,gHAAgH;IAChH,IAAI,CAAC,EAAE,EAAE,GAAG,SAAS,CAAC;IACtB,oIAAoI;IACpI,QAAQ,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC,IAAI,EAAE,cAAc,KAAK,SAAS,CAAC,CAAC;CAC9D;AAsFD,QAAA,MAAM,UAAU,wGAyDf,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,MAAM,EAAiB,OAAO,UAAU,GAAG;IACtD,IAAI,EAAE,OAAO,UAAU,CAAC;CACzB,CAAC"}
|
|
@@ -10,7 +10,6 @@ import { isReactComponent } from '../../../../utilities/__internal__/componentGu
|
|
|
10
10
|
import { renderSelectItem, SelectItem } from '../components/SelectItem.js';
|
|
11
11
|
import { SelectContext } from '../providers/Select.context.js';
|
|
12
12
|
import { styles } from '../Selects.styles.js';
|
|
13
|
-
import { ComboBox } from './components/Combobox.js';
|
|
14
13
|
import { Popover } from './components/Popover.js';
|
|
15
14
|
|
|
16
15
|
const SelectValue = ({ isOpen, isFocused, isDisabled, isInvalid, size, placeholder, icon, 'data-testid': dataTestId, }) => {
|
|
@@ -36,7 +35,7 @@ const SelectValue = ({ isOpen, isFocused, isDisabled, isInvalid, size, placehold
|
|
|
36
35
|
};
|
|
37
36
|
const SelectRoot = forwardRef(({ placeholder = 'Select', icon, size = 'md', children, items, popoverClassName, label, hint, tooltip, hideRequiredIndicator, className, 'data-testid': dataTestId, ...rest }, ref) => {
|
|
38
37
|
const rootTestId = useResolvedTestId({ testId: dataTestId, segment: 'select', rootName: 'select' });
|
|
39
|
-
return (jsx(SelectContext.Provider, { value: { size, testIdPrefix: rootTestId }, children: jsx(Select$1, { ...rest, ref: ref, "data-testid": rootTestId, className: (state) => cx('flex flex-col gap-1.5', typeof className === 'function' ? className(state) : className), children: (state) => (jsxs(Fragment, { children: [label && (jsx(Label, { isRequired: hideRequiredIndicator ? false : state.isRequired, tooltip: tooltip, children: label })), jsx(SelectValue, { ...state, size, placeholder, icon: icon, "data-testid": joinTestId(rootTestId, 'trigger') }), jsx(Popover, { size: size, className: popoverClassName, children: jsx(ListBox, { items: items, className: "size-full outline-hidden", children: children ?? (items && renderSelectItem) }) }), hint && (jsx(HintText, { isInvalid: state.isInvalid, className: cx(size === 'sm' && 'text-xs'), children: hint }))] })) }) }));
|
|
38
|
+
return (jsx(SelectContext.Provider, { value: { size, testIdPrefix: rootTestId }, children: jsx(Select$1, { ...rest, ref: ref, "data-testid": rootTestId, className: (state) => cx('flex flex-col gap-1.5', typeof className === 'function' ? className(state) : className), children: (state) => (jsxs(Fragment, { children: [label && (jsx(Label, { isRequired: hideRequiredIndicator ? false : state.isRequired, isInvalid: state.isInvalid, tooltip: tooltip, children: label })), jsx(SelectValue, { ...state, size, placeholder, icon: icon, "data-testid": joinTestId(rootTestId, 'trigger') }), jsx(Popover, { size: size, className: popoverClassName, children: jsx(ListBox, { items: items, className: "size-full outline-hidden", children: children ?? (items && renderSelectItem) }) }), hint && (jsx(HintText, { isInvalid: state.isInvalid, className: cx(size === 'sm' && 'text-xs'), children: hint }))] })) }) }));
|
|
40
39
|
});
|
|
41
40
|
/**
|
|
42
41
|
* Dropdown select that lets the user choose one option from a list.
|
|
@@ -44,7 +43,6 @@ const SelectRoot = forwardRef(({ placeholder = 'Select', icon, size = 'md', chil
|
|
|
44
43
|
* @summary let the user pick one option from a dropdown list
|
|
45
44
|
*/
|
|
46
45
|
const Select = SelectRoot;
|
|
47
|
-
Select.ComboBox = ComboBox;
|
|
48
46
|
Select.Item = SelectItem;
|
|
49
47
|
// Keeps the name React DevTools and component stacks showed before the root was split from the exported alias.
|
|
50
48
|
SelectRoot.displayName = 'Select';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.js","sources":["../../../../../src/components/molecules/Selects/Select/Select.tsx"],"sourcesContent":[null],"names":["_jsx","AriaButton","AriaSelectValue","_jsxs","_Fragment","AriaSelect","AriaListBox"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Select.js","sources":["../../../../../src/components/molecules/Selects/Select/Select.tsx"],"sourcesContent":[null],"names":["_jsx","AriaButton","AriaSelectValue","_jsxs","_Fragment","AriaSelect","AriaListBox"],"mappings":";;;;;;;;;;;;;;AAsCA,MAAM,WAAW,GAAG,CAAC,EACnB,MAAM,EACN,SAAS,EACT,UAAU,EACV,SAAS,EACT,IAAI,EACJ,WAAW,EACX,IAAI,EACJ,aAAa,EAAE,UAAU,GACqB,KAAI;AAClD,IAAA,QACEA,GAAA,CAACC,MAAU,EAAA,EAAA,aAAA,EACI,UAAU,EACvB,SAAS,EAAE,EAAE,CACX,oKAAoK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AAC,EAAA,QAAA,EAC5E,IAAI,GACI,CACZ,CAAA,EAAA,CACA,CACJ,EAAA,CACU,EAAA,CACU;AAE7B,CAAC,CACF;AAED;;;;AAIG;AACI,MAAM,MAAM,GAAG;AAGtB,MAAM,CAAC,IAAI,GAAG,UAAU;AACxB;AACA,UAAU,CAAC,WAAW,GAAG,QAAQ;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
/** Class strings shared by `Select
|
|
3
|
+
/** Class strings shared by `Select` and `MultiSelect`. Whole literals only, as Tailwind scans for them. */
|
|
4
4
|
const styles = {
|
|
5
5
|
sizes: {
|
|
6
6
|
sm: {
|
|
@@ -8,10 +8,9 @@ const styles = {
|
|
|
8
8
|
withIcon: '',
|
|
9
9
|
text: 'text-sm',
|
|
10
10
|
textContainer: 'gap-x-1.5',
|
|
11
|
-
shortcut: 'pr-2.5',
|
|
12
11
|
},
|
|
13
|
-
md: { root: 'py-2 px-3 gap-2 *:data-icon:size-5', withIcon: '', text: 'text-md', textContainer: 'gap-x-1.5'
|
|
14
|
-
lg: { root: 'py-2.5 px-3.5 gap-2 *:data-icon:size-5', withIcon: '', text: 'text-md', textContainer: 'gap-x-1.5'
|
|
12
|
+
md: { root: 'py-2 px-3 gap-2 *:data-icon:size-5', withIcon: '', text: 'text-md', textContainer: 'gap-x-1.5' },
|
|
13
|
+
lg: { root: 'py-2.5 px-3.5 gap-2 *:data-icon:size-5', withIcon: '', text: 'text-md', textContainer: 'gap-x-1.5' },
|
|
15
14
|
},
|
|
16
15
|
};
|
|
17
16
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Selects.styles.cjs","sources":["../../../../src/components/molecules/Selects/Selects.styles.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;AACO,MAAM,MAAM,GAAG;AACpB,IAAA,KAAK,EAAE;AACL,QAAA,EAAE,EAAE;AACF,YAAA,IAAI,EAAE,uEAAuE;AAC7E,YAAA,QAAQ,EAAE,EAAE;AACZ,YAAA,IAAI,EAAE,SAAS;AACf,YAAA,aAAa,EAAE,WAAW;
|
|
1
|
+
{"version":3,"file":"Selects.styles.cjs","sources":["../../../../src/components/molecules/Selects/Selects.styles.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;AACO,MAAM,MAAM,GAAG;AACpB,IAAA,KAAK,EAAE;AACL,QAAA,EAAE,EAAE;AACF,YAAA,IAAI,EAAE,uEAAuE;AAC7E,YAAA,QAAQ,EAAE,EAAE;AACZ,YAAA,IAAI,EAAE,SAAS;AACf,YAAA,aAAa,EAAE,WAAW;AAC3B,SAAA;AACD,QAAA,EAAE,EAAE,EAAE,IAAI,EAAE,oCAAoC,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE;AAC7G,QAAA,EAAE,EAAE,EAAE,IAAI,EAAE,wCAAwC,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE;AAClH,KAAA;;;"}
|