@pixum/combobox 5.10.4-alpha.9 → 5.10.4

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.
Files changed (45) hide show
  1. package/lib/ComboBox.d.ts +6 -32
  2. package/lib/ComboBox.js +77 -217
  3. package/lib/ComboBox.js.map +1 -1
  4. package/lib/hooks/index.d.ts +0 -2
  5. package/lib/hooks/index.js +0 -2
  6. package/lib/hooks/index.js.map +1 -1
  7. package/lib/hooks/useIsDesktopScreenWidth.d.ts +0 -5
  8. package/lib/hooks/useIsDesktopScreenWidth.js +24 -34
  9. package/lib/hooks/useIsDesktopScreenWidth.js.map +1 -1
  10. package/lib/index.d.ts +4 -4
  11. package/lib/index.js +3 -2
  12. package/lib/index.js.map +1 -1
  13. package/lib/partials/ComboBoxOptions.d.ts +5 -16
  14. package/lib/partials/ComboBoxOptions.js +21 -25
  15. package/lib/partials/ComboBoxOptions.js.map +1 -1
  16. package/lib/partials/ComboBoxOptionsItems.d.ts +17 -32
  17. package/lib/partials/ComboBoxOptionsItems.js +14 -46
  18. package/lib/partials/ComboBoxOptionsItems.js.map +1 -1
  19. package/lib/partials/ComboBoxOptionsSlot.d.ts +16 -17
  20. package/lib/partials/ComboBoxOptionsSlot.js +11 -26
  21. package/lib/partials/ComboBoxOptionsSlot.js.map +1 -1
  22. package/lib/partials/index.d.ts +1 -2
  23. package/lib/partials/index.js +1 -2
  24. package/lib/partials/index.js.map +1 -1
  25. package/lib/types.d.ts +45 -183
  26. package/lib/utils/index.d.ts +2 -1
  27. package/lib/utils/index.js +2 -1
  28. package/lib/utils/index.js.map +1 -1
  29. package/package.json +8 -8
  30. package/lib/ComboBox.module.css +0 -1
  31. package/lib/hooks/useComboBox.d.ts +0 -60
  32. package/lib/hooks/useComboBox.js +0 -226
  33. package/lib/hooks/useComboBox.js.map +0 -1
  34. package/lib/hooks/useComboBoxFocus.d.ts +0 -35
  35. package/lib/hooks/useComboBoxFocus.js +0 -49
  36. package/lib/hooks/useComboBoxFocus.js.map +0 -1
  37. package/lib/partials/ComboBoxNoResults.d.ts +0 -14
  38. package/lib/partials/ComboBoxNoResults.js +0 -18
  39. package/lib/partials/ComboBoxNoResults.js.map +0 -1
  40. package/lib/partials/ComboBoxOptionsGroup.d.ts +0 -15
  41. package/lib/partials/ComboBoxOptionsGroup.js +0 -31
  42. package/lib/partials/ComboBoxOptionsGroup.js.map +0 -1
  43. package/lib/utils/options.d.ts +0 -77
  44. package/lib/utils/options.js +0 -145
  45. package/lib/utils/options.js.map +0 -1
@@ -1,145 +0,0 @@
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
- }
62
- /**
63
- * Normalises flat and grouped options into one list in render order.
64
- *
65
- * The index of an entry is identical for both input shapes and is therefore
66
- * used as the option DOM id that `aria-activedescendant` points at. Doing this
67
- * once removes the offset arithmetic that grouped rendering used to need.
68
- *
69
- * @param options - Flat or grouped options as passed in by the consumer
70
- * @param listboxId - Id of the listbox, used as prefix for the option ids
71
- * @returns The normalised options in render order
72
- */
73
- export function normaliseOptions(options, listboxId) {
74
- const groups = Array.isArray(options)
75
- ? [['', options]]
76
- : Object.entries(options);
77
- const normalised = [];
78
- groups.forEach(([group, items]) => {
79
- items.forEach(item => {
80
- const index = normalised.length;
81
- normalised.push({
82
- item,
83
- group: group || undefined,
84
- value: resolveOptionValue(item, index),
85
- index,
86
- id: `${listboxId}-option-${index}`,
87
- disabled: item.disabled === true,
88
- });
89
- });
90
- });
91
- return normalised;
92
- }
93
- /**
94
- * Splits normalised options back into their render groups while keeping the
95
- * global indices intact, so that the list can be rendered with a single code
96
- * path for flat and grouped options.
97
- *
98
- * @param options - Normalised options in render order
99
- * @returns One entry per consecutive group
100
- */
101
- export function groupOptions(options) {
102
- return options.reduce((groups, option) => {
103
- const current = groups[groups.length - 1];
104
- if (current && current.group === option.group) {
105
- current.options.push(option);
106
- return groups;
107
- }
108
- groups.push({ group: option.group, options: [option] });
109
- return groups;
110
- }, []);
111
- }
112
- /**
113
- * Normalises the `value` prop to an array, so that single and multi select
114
- * share the same selection logic.
115
- *
116
- * @param value - Selected value(s) or `undefined`
117
- * @returns The selected values as an array
118
- */
119
- export function toValueArray(value) {
120
- if (Array.isArray(value))
121
- return value;
122
- return value ? [value] : [];
123
- }
124
- /**
125
- * Finds the first option that can be activated, starting at `start` and moving
126
- * by `delta` with wrap-around. Disabled options are skipped.
127
- *
128
- * @param options - Normalised options
129
- * @param start - Index to start from; use `-1` to start before the first option
130
- * @param delta - Step width, negative values move backwards
131
- * @returns The index of the next enabled option, or `null` when there is none
132
- */
133
- export function findEnabledIndex(options, start, delta) {
134
- const { length } = options;
135
- if (length === 0)
136
- return null;
137
- let index = start;
138
- for (let step = 0; step < length; step += 1) {
139
- index = (index + delta + length) % length;
140
- if (!options[index].disabled)
141
- return index;
142
- }
143
- return null;
144
- }
145
- //# sourceMappingURL=options.js.map
@@ -1 +0,0 @@
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,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC,IAAI,CAAA;IAChE,IAAI,IAAI,CAAC,GAAG;QAAE,OAAO,IAAI,CAAC,GAAG,CAAA;IAE7B,OAAO,UAAU,KAAK,EAAE,CAAA;AAC1B,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAAC,MAAsB;IACnD,IAAI,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QAC7D,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAA;IACzB,CAAC;IAED,OAAO,MAAM,CAAC,KAAK,CAAA;AACrB,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,eAAe,CAAC,EAIN;QAJM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