@rescui/select 0.18.4 → 0.19.1
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/lib/_virtual/check-outline.js +294 -63
- package/lib/_virtual/close-outline.js +294 -63
- package/lib/_virtual/down-outline.js +294 -63
- package/lib/_virtual/index.css.js +12 -12
- package/lib/_virtual/loading-outline.js +310 -79
- package/lib/hooks/use-a11y.d.ts +2 -2
- package/lib/hooks/use-a11y.js +124 -36
- package/lib/hooks/use-actual-size-from-css.d.ts +3 -4
- package/lib/hooks/use-actual-size-from-css.js +47 -18
- package/lib/hooks/use-focus.js +54 -10
- package/lib/hooks/use-hover.js +54 -10
- package/lib/hooks/use-label-focus.js +45 -15
- package/lib/hooks/use-multi-handlers.js +113 -38
- package/lib/hooks/use-options.d.ts +2 -1
- package/lib/hooks/use-options.js +92 -56
- package/lib/hooks/use-primary-contrast-css-var-transfer.d.ts +2 -3
- package/lib/hooks/use-primary-contrast-css-var-transfer.js +45 -15
- package/lib/index.css +194 -194
- package/lib/multiselect.js +527 -174
- package/lib/native-select.js +416 -118
- package/lib/parts/form-trigger-wrapper.js +159 -39
- package/lib/parts/hidden-select.js +105 -29
- package/lib/parts/icons.js +191 -49
- package/lib/parts/list-box.js +277 -74
- package/lib/parts/multi-trigger.d.ts +2 -2
- package/lib/parts/multi-trigger.js +125 -48
- package/lib/parts/native-select-options-with-groups.js +154 -52
- package/lib/parts/popup-content.d.ts +3 -3
- package/lib/parts/popup-content.js +146 -46
- package/lib/select-basic.js +456 -147
- package/lib/select-searchable.js +448 -155
- package/lib/select.js +228 -56
- package/lib/styles/common.p.module.css.js +29 -29
- package/lib/styles/form-trigger.p.module.css.js +12 -12
- package/lib/styles/list-box.p.module.css.js +13 -13
- package/lib/utils/get-text-from-nodes.js +1 -1
- package/package.json +13 -12
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { c } from 'react-compiler-runtime';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { NO_OPTIONS_VALUE } from '../constants.js';
|
|
3
4
|
import { isOptionAGroup } from '../utils/is-option-a-group.js';
|
|
@@ -9,68 +10,169 @@ const collectOptionGroupValues = options => options.map(_ref => {
|
|
|
9
10
|
return value;
|
|
10
11
|
}).join('-');
|
|
11
12
|
|
|
12
|
-
const Option =
|
|
13
|
-
|
|
13
|
+
const Option = t0 => {
|
|
14
|
+
const $ = c(4);
|
|
15
|
+
const {
|
|
14
16
|
value,
|
|
15
17
|
label,
|
|
16
|
-
disabled
|
|
17
|
-
} =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
disabled: t1
|
|
19
|
+
} = t0;
|
|
20
|
+
const disabled = t1 === undefined ? false : t1;
|
|
21
|
+
let t2;
|
|
22
|
+
|
|
23
|
+
if ($[0] !== disabled || $[1] !== label || $[2] !== value) {
|
|
24
|
+
t2 = /*#__PURE__*/React.createElement("option", {
|
|
25
|
+
value: value,
|
|
26
|
+
disabled: disabled
|
|
27
|
+
}, label);
|
|
28
|
+
$[0] = disabled;
|
|
29
|
+
$[1] = label;
|
|
30
|
+
$[2] = value;
|
|
31
|
+
$[3] = t2;
|
|
32
|
+
} else {
|
|
33
|
+
t2 = $[3];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return t2;
|
|
22
37
|
};
|
|
23
38
|
|
|
24
|
-
const OptionGroup =
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
const OptionGroup = t0 => {
|
|
40
|
+
const $ = c(8);
|
|
41
|
+
const {
|
|
42
|
+
options: t1,
|
|
43
|
+
label: t2,
|
|
44
|
+
disabled: t3
|
|
45
|
+
} = t0;
|
|
46
|
+
let t4;
|
|
47
|
+
|
|
48
|
+
if ($[0] !== t1) {
|
|
49
|
+
t4 = t1 === undefined ? [] : t1;
|
|
50
|
+
$[0] = t1;
|
|
51
|
+
$[1] = t4;
|
|
52
|
+
} else {
|
|
53
|
+
t4 = $[1];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const options = t4;
|
|
57
|
+
const label = t2 === undefined ? "" : t2;
|
|
58
|
+
const disabled = t3 === undefined ? false : t3;
|
|
59
|
+
let t5;
|
|
60
|
+
|
|
61
|
+
if ($[2] !== options) {
|
|
62
|
+
t5 = options.map(_temp);
|
|
63
|
+
$[2] = options;
|
|
64
|
+
$[3] = t5;
|
|
65
|
+
} else {
|
|
66
|
+
t5 = $[3];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
let t6;
|
|
70
|
+
|
|
71
|
+
if ($[4] !== disabled || $[5] !== label || $[6] !== t5) {
|
|
72
|
+
t6 = /*#__PURE__*/React.createElement("optgroup", {
|
|
73
|
+
label: label,
|
|
74
|
+
disabled: disabled
|
|
75
|
+
}, t5);
|
|
76
|
+
$[4] = disabled;
|
|
77
|
+
$[5] = label;
|
|
78
|
+
$[6] = t5;
|
|
79
|
+
$[7] = t6;
|
|
80
|
+
} else {
|
|
81
|
+
t6 = $[7];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return t6;
|
|
39
85
|
};
|
|
40
86
|
|
|
41
|
-
const NativeSelectOptionsWithGroups =
|
|
42
|
-
|
|
87
|
+
const NativeSelectOptionsWithGroups = t0 => {
|
|
88
|
+
const $ = c(11);
|
|
89
|
+
const {
|
|
43
90
|
optionsWithGroups,
|
|
44
91
|
placeholder,
|
|
45
92
|
emptyListMessage
|
|
46
|
-
} =
|
|
93
|
+
} = t0;
|
|
47
94
|
const hasOptions = optionsWithGroups.length > 0;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
95
|
+
const t1 = hasOptions ? placeholder : emptyListMessage;
|
|
96
|
+
let t2;
|
|
97
|
+
|
|
98
|
+
if ($[0] !== t1) {
|
|
99
|
+
t2 = /*#__PURE__*/React.createElement("option", {
|
|
100
|
+
value: "",
|
|
101
|
+
disabled: true,
|
|
102
|
+
hidden: true
|
|
103
|
+
}, t1);
|
|
104
|
+
$[0] = t1;
|
|
105
|
+
$[1] = t2;
|
|
106
|
+
} else {
|
|
107
|
+
t2 = $[1];
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
let t3;
|
|
111
|
+
|
|
112
|
+
if ($[2] !== emptyListMessage || $[3] !== hasOptions) {
|
|
113
|
+
t3 = !hasOptions && /*#__PURE__*/React.createElement("option", {
|
|
114
|
+
value: NO_OPTIONS_VALUE,
|
|
115
|
+
disabled: true
|
|
116
|
+
}, emptyListMessage);
|
|
117
|
+
$[2] = emptyListMessage;
|
|
118
|
+
$[3] = hasOptions;
|
|
119
|
+
$[4] = t3;
|
|
120
|
+
} else {
|
|
121
|
+
t3 = $[4];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
let t4;
|
|
125
|
+
|
|
126
|
+
if ($[5] !== optionsWithGroups) {
|
|
127
|
+
t4 = optionsWithGroups.map(_temp2);
|
|
128
|
+
$[5] = optionsWithGroups;
|
|
129
|
+
$[6] = t4;
|
|
130
|
+
} else {
|
|
131
|
+
t4 = $[6];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
let t5;
|
|
135
|
+
|
|
136
|
+
if ($[7] !== t2 || $[8] !== t3 || $[9] !== t4) {
|
|
137
|
+
t5 = /*#__PURE__*/React.createElement(React.Fragment, null, t2, t3, t4);
|
|
138
|
+
$[7] = t2;
|
|
139
|
+
$[8] = t3;
|
|
140
|
+
$[9] = t4;
|
|
141
|
+
$[10] = t5;
|
|
142
|
+
} else {
|
|
143
|
+
t5 = $[10];
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return t5;
|
|
74
147
|
};
|
|
75
148
|
|
|
149
|
+
function _temp(option) {
|
|
150
|
+
return /*#__PURE__*/React.createElement(Option, {
|
|
151
|
+
key: option.value,
|
|
152
|
+
value: option.value,
|
|
153
|
+
label: option.label,
|
|
154
|
+
disabled: option.disabled
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function _temp2(optionOrGroup) {
|
|
159
|
+
if (isOptionAGroup(optionOrGroup)) {
|
|
160
|
+
const group = optionOrGroup;
|
|
161
|
+
return /*#__PURE__*/React.createElement(OptionGroup, {
|
|
162
|
+
key: `group--${group.label}--${collectOptionGroupValues(group.options)}`,
|
|
163
|
+
options: group.options,
|
|
164
|
+
disabled: group.disabled,
|
|
165
|
+
label: group.label
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const option = optionOrGroup;
|
|
170
|
+
return /*#__PURE__*/React.createElement(Option, {
|
|
171
|
+
key: option.value,
|
|
172
|
+
value: option.value,
|
|
173
|
+
label: option.label,
|
|
174
|
+
disabled: option.disabled
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
|
|
76
178
|
export { NativeSelectOptionsWithGroups };
|
|
@@ -5,7 +5,7 @@ import type { SelectMode, SelectSize, ListBoxState, ListBoxItem, Placement } fro
|
|
|
5
5
|
export type PopupContentProps = {
|
|
6
6
|
theme: Theme;
|
|
7
7
|
listBoxState: ListBoxState;
|
|
8
|
-
|
|
8
|
+
triggerEl: HTMLElement | null;
|
|
9
9
|
dropdownRef?: React.RefObject<DropdownImperativeHandle>;
|
|
10
10
|
listBoxItems?: ListBoxItem[];
|
|
11
11
|
placement: Placement;
|
|
@@ -17,6 +17,6 @@ export type PopupContentProps = {
|
|
|
17
17
|
renderInTrigger?: boolean;
|
|
18
18
|
disableFlip?: boolean;
|
|
19
19
|
isOpen?: boolean;
|
|
20
|
-
|
|
20
|
+
dropdownUpdateDep?: unknown;
|
|
21
21
|
};
|
|
22
|
-
export declare const PopupContent: ({ theme, listBoxState,
|
|
22
|
+
export declare const PopupContent: ({ theme, listBoxState, triggerEl, dropdownRef, listBoxItems, placement, size: sizeFromProps, mode, emptyListMessage, maxVisibleItems, trigger, renderInTrigger, disableFlip, isOpen, dropdownUpdateDep }: PopupContentProps) => React.JSX.Element;
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { c } from 'react-compiler-runtime';
|
|
2
|
+
import React, { useEffect, useLayoutEffect } from 'react';
|
|
2
3
|
import { Dropdown } from '@rescui/dropdown';
|
|
3
4
|
import { useActualSizeFromCss } from '../hooks/use-actual-size-from-css.js';
|
|
4
5
|
import { usePrimaryContrastCssVarTransfer } from '../hooks/use-primary-contrast-css-var-transfer.js';
|
|
5
6
|
import styles from '../styles/common.p.module.css.js';
|
|
6
|
-
import { ListBox } from './list-box.js';
|
|
7
|
+
import { ListBox } from './list-box.js';
|
|
8
|
+
const useIsomorphicLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect; // eslint-disable-next-line complexity
|
|
7
9
|
|
|
8
|
-
const PopupContent =
|
|
9
|
-
|
|
10
|
+
const PopupContent = t0 => {
|
|
11
|
+
const $ = c(35);
|
|
12
|
+
const {
|
|
10
13
|
theme,
|
|
11
14
|
listBoxState,
|
|
12
|
-
|
|
15
|
+
triggerEl,
|
|
13
16
|
dropdownRef,
|
|
14
17
|
listBoxItems,
|
|
15
18
|
placement,
|
|
@@ -21,52 +24,149 @@ const PopupContent = _ref => {
|
|
|
21
24
|
renderInTrigger,
|
|
22
25
|
disableFlip,
|
|
23
26
|
isOpen,
|
|
24
|
-
|
|
25
|
-
} =
|
|
27
|
+
dropdownUpdateDep
|
|
28
|
+
} = t0;
|
|
29
|
+
let t1;
|
|
30
|
+
|
|
31
|
+
if ($[0] !== sizeFromProps || $[1] !== triggerEl) {
|
|
32
|
+
t1 = {
|
|
33
|
+
sizeFromProps,
|
|
34
|
+
triggerEl
|
|
35
|
+
};
|
|
36
|
+
$[0] = sizeFromProps;
|
|
37
|
+
$[1] = triggerEl;
|
|
38
|
+
$[2] = t1;
|
|
39
|
+
} else {
|
|
40
|
+
t1 = $[2];
|
|
41
|
+
}
|
|
42
|
+
|
|
26
43
|
const {
|
|
27
44
|
size,
|
|
28
45
|
observableRef
|
|
29
|
-
} = useActualSizeFromCss(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
46
|
+
} = useActualSizeFromCss(t1);
|
|
47
|
+
let t2;
|
|
48
|
+
|
|
49
|
+
if ($[3] !== isOpen || $[4] !== triggerEl) {
|
|
50
|
+
t2 = {
|
|
51
|
+
isOpen,
|
|
52
|
+
triggerEl
|
|
53
|
+
};
|
|
54
|
+
$[3] = isOpen;
|
|
55
|
+
$[4] = triggerEl;
|
|
56
|
+
$[5] = t2;
|
|
57
|
+
} else {
|
|
58
|
+
t2 = $[5];
|
|
59
|
+
}
|
|
60
|
+
|
|
33
61
|
const {
|
|
34
62
|
isPrimaryContrast
|
|
35
|
-
} = usePrimaryContrastCssVarTransfer(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
} = usePrimaryContrastCssVarTransfer(t2);
|
|
64
|
+
let t3;
|
|
65
|
+
|
|
66
|
+
if ($[6] !== dropdownRef) {
|
|
67
|
+
t3 = () => {
|
|
68
|
+
dropdownRef.current?.scheduleUpdate();
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
$[6] = dropdownRef;
|
|
72
|
+
$[7] = t3;
|
|
73
|
+
} else {
|
|
74
|
+
t3 = $[7];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
let t4;
|
|
78
|
+
|
|
79
|
+
if ($[8] !== dropdownRef || $[9] !== dropdownUpdateDep || $[10] !== listBoxItems || $[11] !== size) {
|
|
80
|
+
t4 = [dropdownRef, dropdownUpdateDep, listBoxItems, size];
|
|
81
|
+
$[8] = dropdownRef;
|
|
82
|
+
$[9] = dropdownUpdateDep;
|
|
83
|
+
$[10] = listBoxItems;
|
|
84
|
+
$[11] = size;
|
|
85
|
+
$[12] = t4;
|
|
86
|
+
} else {
|
|
87
|
+
t4 = $[12];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
useIsomorphicLayoutEffect(t3, t4);
|
|
91
|
+
let t5;
|
|
92
|
+
|
|
93
|
+
if ($[13] !== observableRef) {
|
|
94
|
+
t5 = /*#__PURE__*/React.createElement("div", {
|
|
95
|
+
ref: observableRef,
|
|
96
|
+
className: styles.observable
|
|
97
|
+
});
|
|
98
|
+
$[13] = observableRef;
|
|
99
|
+
$[14] = t5;
|
|
100
|
+
} else {
|
|
101
|
+
t5 = $[14];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
let t6;
|
|
105
|
+
|
|
106
|
+
if ($[15] !== emptyListMessage || $[16] !== isPrimaryContrast || $[17] !== listBoxItems || $[18] !== listBoxState || $[19] !== maxVisibleItems || $[20] !== mode || $[21] !== size) {
|
|
107
|
+
t6 = /*#__PURE__*/React.createElement(ListBox, {
|
|
108
|
+
state: listBoxState,
|
|
109
|
+
size: size,
|
|
110
|
+
mode: mode,
|
|
111
|
+
maxVisibleItems: maxVisibleItems,
|
|
112
|
+
emptyListMessage: emptyListMessage,
|
|
113
|
+
items: listBoxItems,
|
|
114
|
+
isPrimaryContrast: isPrimaryContrast
|
|
115
|
+
});
|
|
116
|
+
$[15] = emptyListMessage;
|
|
117
|
+
$[16] = isPrimaryContrast;
|
|
118
|
+
$[17] = listBoxItems;
|
|
119
|
+
$[18] = listBoxState;
|
|
120
|
+
$[19] = maxVisibleItems;
|
|
121
|
+
$[20] = mode;
|
|
122
|
+
$[21] = size;
|
|
123
|
+
$[22] = t6;
|
|
124
|
+
} else {
|
|
125
|
+
t6 = $[22];
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
let t7;
|
|
129
|
+
|
|
130
|
+
if ($[23] !== disableFlip || $[24] !== dropdownRef || $[25] !== isOpen || $[26] !== placement || $[27] !== renderInTrigger || $[28] !== t6 || $[29] !== theme || $[30] !== trigger) {
|
|
131
|
+
t7 = /*#__PURE__*/React.createElement(Dropdown, {
|
|
132
|
+
theme: theme,
|
|
133
|
+
ref: dropdownRef,
|
|
134
|
+
placement: placement,
|
|
135
|
+
maxWidth: "trigger",
|
|
136
|
+
minWidth: "trigger",
|
|
137
|
+
leastMaxHeight: 999999,
|
|
138
|
+
isOpen: isOpen,
|
|
139
|
+
cancelCloseAnimation: true,
|
|
140
|
+
disableFocusLock: true,
|
|
141
|
+
renderInTrigger: renderInTrigger,
|
|
142
|
+
disableFlip: disableFlip,
|
|
143
|
+
trigger: trigger
|
|
144
|
+
}, t6);
|
|
145
|
+
$[23] = disableFlip;
|
|
146
|
+
$[24] = dropdownRef;
|
|
147
|
+
$[25] = isOpen;
|
|
148
|
+
$[26] = placement;
|
|
149
|
+
$[27] = renderInTrigger;
|
|
150
|
+
$[28] = t6;
|
|
151
|
+
$[29] = theme;
|
|
152
|
+
$[30] = trigger;
|
|
153
|
+
$[31] = t7;
|
|
154
|
+
} else {
|
|
155
|
+
t7 = $[31];
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
let t8;
|
|
159
|
+
|
|
160
|
+
if ($[32] !== t5 || $[33] !== t7) {
|
|
161
|
+
t8 = /*#__PURE__*/React.createElement(React.Fragment, null, t5, t7);
|
|
162
|
+
$[32] = t5;
|
|
163
|
+
$[33] = t7;
|
|
164
|
+
$[34] = t8;
|
|
165
|
+
} else {
|
|
166
|
+
t8 = $[34];
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return t8;
|
|
70
170
|
};
|
|
71
171
|
|
|
72
172
|
export { PopupContent };
|