@pixum/combobox 5.10.4-alpha.18 → 5.10.4-alpha.24
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/ComboBox.d.ts +28 -6
- package/lib/ComboBox.js +177 -78
- package/lib/ComboBox.js.map +1 -1
- package/lib/ComboBox.module.css +1 -1
- package/lib/hooks/index.d.ts +2 -0
- package/lib/hooks/index.js +2 -0
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/useComboBox.js +1 -0
- package/lib/hooks/useComboBox.js.map +1 -1
- package/lib/hooks/useComboBoxFocus.js +1 -0
- package/lib/hooks/useComboBoxFocus.js.map +1 -1
- package/lib/hooks/useIsDesktopScreenWidth.d.ts +5 -0
- package/lib/hooks/useIsDesktopScreenWidth.js +34 -24
- package/lib/hooks/useIsDesktopScreenWidth.js.map +1 -1
- package/lib/index.d.ts +4 -4
- package/lib/index.js +2 -3
- package/lib/index.js.map +1 -1
- package/lib/partials/ComboBoxOptions.d.ts +15 -4
- package/lib/partials/ComboBoxOptions.js +25 -21
- package/lib/partials/ComboBoxOptions.js.map +1 -1
- package/lib/partials/ComboBoxOptionsItems.d.ts +32 -17
- package/lib/partials/ComboBoxOptionsItems.js +46 -14
- package/lib/partials/ComboBoxOptionsItems.js.map +1 -1
- package/lib/partials/ComboBoxOptionsSlot.d.ts +17 -16
- package/lib/partials/ComboBoxOptionsSlot.js +26 -11
- package/lib/partials/ComboBoxOptionsSlot.js.map +1 -1
- package/lib/partials/index.d.ts +2 -1
- package/lib/partials/index.js +2 -1
- package/lib/partials/index.js.map +1 -1
- package/lib/types.d.ts +122 -51
- package/lib/utils/index.d.ts +1 -2
- package/lib/utils/index.js +1 -2
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/options.d.ts +38 -1
- package/lib/utils/options.js +62 -2
- package/lib/utils/options.js.map +1 -1
- package/package.json +8 -8
package/lib/utils/options.js
CHANGED
|
@@ -1,3 +1,64 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Resolves the stable value of an option.
|
|
14
|
+
*
|
|
15
|
+
* `MenuItemProps` does not guarantee a plain string `text`, so the value is
|
|
16
|
+
* resolved in three steps: the visible label first - that is the value existing
|
|
17
|
+
* consumers pass in as `value` and get back from `onOptionItemClick` -, then
|
|
18
|
+
* the explicit `key`, and finally the render index as a last resort so that
|
|
19
|
+
* options without a label still get a unique value.
|
|
20
|
+
*
|
|
21
|
+
* @param item - The option as handed in by the consumer
|
|
22
|
+
* @param index - Position of the option in render order
|
|
23
|
+
* @returns The stable value of the option
|
|
24
|
+
*/
|
|
25
|
+
export function resolveOptionValue(item, index) {
|
|
26
|
+
if (typeof item.text === 'string' && item.text)
|
|
27
|
+
return item.text;
|
|
28
|
+
if (item.key)
|
|
29
|
+
return item.key;
|
|
30
|
+
return `option-${index}`;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Returns the label of an option for the trigger field.
|
|
34
|
+
*
|
|
35
|
+
* Falls back to the resolved value when the option renders a custom node
|
|
36
|
+
* instead of a plain string.
|
|
37
|
+
*
|
|
38
|
+
* @param option - A normalised option
|
|
39
|
+
* @returns The label to display in the trigger field
|
|
40
|
+
*/
|
|
41
|
+
export function getOptionLabel(option) {
|
|
42
|
+
if (typeof option.item.text === 'string' && option.item.text) {
|
|
43
|
+
return option.item.text;
|
|
44
|
+
}
|
|
45
|
+
return option.value;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Strips the ComboBox specific props from an option so the rest can be spread
|
|
49
|
+
* onto the `MenuItem`.
|
|
50
|
+
*
|
|
51
|
+
* `key` is a reserved React prop and `disabled` is handled by the option
|
|
52
|
+
* wrapper (`aria-disabled` plus the click guard); everything else belongs to
|
|
53
|
+
* `MenuItem` and is forwarded untouched.
|
|
54
|
+
*
|
|
55
|
+
* @param item - The option as handed in by the consumer
|
|
56
|
+
* @returns The props meant for the `MenuItem`
|
|
57
|
+
*/
|
|
58
|
+
export function toMenuItemProps(_a) {
|
|
59
|
+
var { key, disabled } = _a, menuItemProps = __rest(_a, ["key", "disabled"]);
|
|
60
|
+
return menuItemProps;
|
|
61
|
+
}
|
|
1
62
|
/**
|
|
2
63
|
* Normalises flat and grouped options into one list in render order.
|
|
3
64
|
*
|
|
@@ -16,12 +77,11 @@ export function normaliseOptions(options, listboxId) {
|
|
|
16
77
|
const normalised = [];
|
|
17
78
|
groups.forEach(([group, items]) => {
|
|
18
79
|
items.forEach(item => {
|
|
19
|
-
var _a;
|
|
20
80
|
const index = normalised.length;
|
|
21
81
|
normalised.push({
|
|
22
82
|
item,
|
|
23
83
|
group: group || undefined,
|
|
24
|
-
value: (
|
|
84
|
+
value: resolveOptionValue(item, index),
|
|
25
85
|
index,
|
|
26
86
|
id: `${listboxId}-option-${index}`,
|
|
27
87
|
disabled: item.disabled === true,
|
package/lib/utils/options.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/utils/options.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/utils/options.ts"],"names":[],"mappings":";;;;;;;;;;;AAQA;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,kBAAkB,CAChC,IAA6B,EAC7B,KAAa;IAEb,IAAI,OAAO,IAAI,CAAC,IAAI,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,KAAK,CAAA;IAEjB,KAAK,IAAI,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,MAAM,EAAE,IAAI,IAAI,CAAC,EAAE,CAAC;QAC5C,KAAK,GAAG,CAAC,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC,GAAG,MAAM,CAAA;QAEzC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,QAAQ;YAAE,OAAO,KAAK,CAAA;IAC5C,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixum/combobox",
|
|
3
|
-
"version": "5.10.4-alpha.
|
|
3
|
+
"version": "5.10.4-alpha.24+c517232b8",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"module": "lib/index.js",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"peerDependencies": {
|
|
8
|
-
"@pixum/bottom-sheet": "
|
|
9
|
-
"@pixum/menu": "
|
|
10
|
-
"@pixum/menu-item": "
|
|
11
|
-
"@pixum/text": "
|
|
12
|
-
"@pixum/theme-provider": "
|
|
13
|
-
"@pixum/web-input": "2.
|
|
8
|
+
"@pixum/bottom-sheet": "4.9.0",
|
|
9
|
+
"@pixum/menu": "4.4.0",
|
|
10
|
+
"@pixum/menu-item": "3.4.1",
|
|
11
|
+
"@pixum/text": "3.7.0",
|
|
12
|
+
"@pixum/theme-provider": "5.6.0",
|
|
13
|
+
"@pixum/web-input": "2.5.4"
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
16
|
"lib"
|
|
@@ -18,5 +18,5 @@
|
|
|
18
18
|
"sideEffects": [
|
|
19
19
|
"*.css"
|
|
20
20
|
],
|
|
21
|
-
"gitHead": "
|
|
21
|
+
"gitHead": "c517232b84ee4bbb0437b0ab9d26c0efa65c21a7"
|
|
22
22
|
}
|