@serendie/ui 2.0.0 → 2.1.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.
Files changed (118) hide show
  1. package/dist/components/CheckBox/CheckBox.js +36 -35
  2. package/dist/components/ChoiceBox/ChoiceBox.js +41 -41
  3. package/dist/components/DataTable/DataTableComponent.d.ts +3 -20
  4. package/dist/components/DataTable/DataTableComponent.js +38 -36
  5. package/dist/components/DataTable/table/HeaderCheckbox.js +29 -19
  6. package/dist/components/Search/Search.d.ts +3 -1
  7. package/dist/components/Search/Search.js +34 -33
  8. package/dist/components/Select/Select.d.ts +2 -1
  9. package/dist/components/Select/Select.js +47 -41
  10. package/dist/components/Tooltip/Tooltip.d.ts +14 -0
  11. package/dist/components/Tooltip/Tooltip.js +70 -0
  12. package/dist/components/Tooltip/index.d.ts +1 -0
  13. package/dist/components/Tooltip/index.js +4 -0
  14. package/dist/index.d.ts +1 -0
  15. package/dist/index.js +12 -10
  16. package/dist/node_modules/@ark-ui/react/dist/components/accordion/accordion-item-content.js +4 -6
  17. package/dist/node_modules/@ark-ui/react/dist/components/accordion/accordion-item-indicator.js +4 -6
  18. package/dist/node_modules/@ark-ui/react/dist/components/accordion/accordion-item-trigger.js +10 -12
  19. package/dist/node_modules/@ark-ui/react/dist/components/accordion/accordion-item.js +16 -16
  20. package/dist/node_modules/@ark-ui/react/dist/components/accordion/use-accordion.js +13 -20
  21. package/dist/node_modules/@ark-ui/react/dist/components/avatar/avatar-root.js +1 -5
  22. package/dist/node_modules/@ark-ui/react/dist/components/avatar/use-avatar.js +14 -18
  23. package/dist/node_modules/@ark-ui/react/dist/components/checkbox/checkbox-hidden-input.js +4 -6
  24. package/dist/node_modules/@ark-ui/react/dist/components/checkbox/use-checkbox.js +22 -28
  25. package/dist/node_modules/@ark-ui/react/dist/components/collapsible/collapsible-content.js +7 -9
  26. package/dist/node_modules/@ark-ui/react/dist/components/collapsible/use-collapsible.js +14 -21
  27. package/dist/node_modules/@ark-ui/react/dist/components/collection/list-collection.js +5 -0
  28. package/dist/node_modules/@ark-ui/react/dist/components/combobox/combobox-content.js +9 -8
  29. package/dist/node_modules/@ark-ui/react/dist/components/combobox/combobox-item-group.js +4 -6
  30. package/dist/node_modules/@ark-ui/react/dist/components/combobox/combobox-positioner.js +4 -6
  31. package/dist/node_modules/@ark-ui/react/dist/components/combobox/combobox-root.js +17 -18
  32. package/dist/node_modules/@ark-ui/react/dist/components/combobox/combobox-trigger.js +10 -9
  33. package/dist/node_modules/@ark-ui/react/dist/components/combobox/use-combobox-item-context.js +5 -7
  34. package/dist/node_modules/@ark-ui/react/dist/components/combobox/use-combobox.js +21 -45
  35. package/dist/node_modules/@ark-ui/react/dist/components/dialog/dialog-backdrop.js +10 -9
  36. package/dist/node_modules/@ark-ui/react/dist/components/dialog/dialog-close-trigger.js +4 -6
  37. package/dist/node_modules/@ark-ui/react/dist/components/dialog/dialog-content.js +6 -5
  38. package/dist/node_modules/@ark-ui/react/dist/components/dialog/dialog-description.js +4 -6
  39. package/dist/node_modules/@ark-ui/react/dist/components/dialog/use-dialog.js +13 -22
  40. package/dist/node_modules/@ark-ui/react/dist/components/factory.js +26 -24
  41. package/dist/node_modules/@ark-ui/react/dist/components/menu/menu-content.js +9 -8
  42. package/dist/node_modules/@ark-ui/react/dist/components/menu/menu-item-group.js +1 -3
  43. package/dist/node_modules/@ark-ui/react/dist/components/menu/menu-item.js +15 -13
  44. package/dist/node_modules/@ark-ui/react/dist/components/menu/menu-root.js +13 -14
  45. package/dist/node_modules/@ark-ui/react/dist/components/menu/use-menu-option-item-props-context.js +10 -0
  46. package/dist/node_modules/@ark-ui/react/dist/components/menu/use-menu.js +14 -21
  47. package/dist/node_modules/@ark-ui/react/dist/components/pagination/pagination-ellipsis.js +4 -6
  48. package/dist/node_modules/@ark-ui/react/dist/components/pagination/pagination-next-trigger.js +4 -6
  49. package/dist/node_modules/@ark-ui/react/dist/components/pagination/pagination-prev-trigger.js +4 -6
  50. package/dist/node_modules/@ark-ui/react/dist/components/pagination/pagination-root.js +5 -4
  51. package/dist/node_modules/@ark-ui/react/dist/components/pagination/use-pagination.js +13 -19
  52. package/dist/node_modules/@ark-ui/react/dist/components/portal/portal.js +25 -16
  53. package/dist/node_modules/@ark-ui/react/dist/components/presence/split-presence-props.js +3 -2
  54. package/dist/node_modules/@ark-ui/react/dist/components/presence/use-presence.js +18 -18
  55. package/dist/node_modules/@ark-ui/react/dist/components/radio-group/radio-group-item-control.js +4 -6
  56. package/dist/node_modules/@ark-ui/react/dist/components/radio-group/radio-group-item-text.js +4 -6
  57. package/dist/node_modules/@ark-ui/react/dist/components/radio-group/radio-group-item.js +1 -5
  58. package/dist/node_modules/@ark-ui/react/dist/components/radio-group/use-radio-group.js +14 -22
  59. package/dist/node_modules/@ark-ui/react/dist/components/select/select-content.js +9 -8
  60. package/dist/node_modules/@ark-ui/react/dist/components/select/select-root.js +11 -12
  61. package/dist/node_modules/@ark-ui/react/dist/components/select/use-select.js +20 -47
  62. package/dist/node_modules/@ark-ui/react/dist/components/switch/switch-hidden-input.js +4 -6
  63. package/dist/node_modules/@ark-ui/react/dist/components/switch/use-switch.js +20 -26
  64. package/dist/node_modules/@ark-ui/react/dist/components/tabs/tabs-root.js +9 -8
  65. package/dist/node_modules/@ark-ui/react/dist/components/tabs/use-tabs.js +14 -21
  66. package/dist/node_modules/@ark-ui/react/dist/components/toast/create-toaster.js +3 -7
  67. package/dist/node_modules/@ark-ui/react/dist/components/toast/toaster.js +28 -15
  68. package/dist/node_modules/@ark-ui/react/dist/components/tooltip/tooltip-arrow-tip.js +13 -0
  69. package/dist/node_modules/@ark-ui/react/dist/components/tooltip/tooltip-arrow.js +13 -0
  70. package/dist/node_modules/@ark-ui/react/dist/components/tooltip/tooltip-content.js +15 -0
  71. package/dist/node_modules/@ark-ui/react/dist/components/tooltip/tooltip-positioner.js +14 -0
  72. package/dist/node_modules/@ark-ui/react/dist/components/tooltip/tooltip-root.js +14 -0
  73. package/dist/node_modules/@ark-ui/react/dist/components/tooltip/tooltip-trigger.js +13 -0
  74. package/dist/node_modules/@ark-ui/react/dist/components/tooltip/use-tooltip-context.js +10 -0
  75. package/dist/node_modules/@ark-ui/react/dist/components/tooltip/use-tooltip.js +17 -0
  76. package/dist/node_modules/@ark-ui/react/dist/utils/compose-refs.js +13 -7
  77. package/dist/node_modules/@floating-ui/core/dist/floating-ui.core.js +92 -90
  78. package/dist/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +230 -216
  79. package/dist/node_modules/@zag-js/accordion/dist/index.js +210 -227
  80. package/dist/node_modules/@zag-js/aria-hidden/dist/index.js +49 -12
  81. package/dist/node_modules/@zag-js/avatar/dist/index.js +119 -134
  82. package/dist/node_modules/@zag-js/checkbox/dist/index.js +196 -197
  83. package/dist/node_modules/@zag-js/collapsible/dist/index.js +250 -198
  84. package/dist/node_modules/@zag-js/collection/dist/index.js +172 -179
  85. package/dist/node_modules/@zag-js/combobox/dist/index.js +1176 -1082
  86. package/dist/node_modules/@zag-js/core/dist/index.js +77 -496
  87. package/dist/node_modules/@zag-js/dialog/dist/index.js +243 -270
  88. package/dist/node_modules/@zag-js/dismissable/dist/index.js +62 -60
  89. package/dist/node_modules/@zag-js/dom-query/dist/index.js +465 -253
  90. package/dist/node_modules/@zag-js/focus-trap/dist/index.js +307 -0
  91. package/dist/node_modules/@zag-js/focus-visible/dist/index.js +48 -47
  92. package/dist/node_modules/@zag-js/interact-outside/dist/index.js +112 -80
  93. package/dist/node_modules/@zag-js/menu/dist/index.js +998 -884
  94. package/dist/node_modules/@zag-js/pagination/dist/index.js +207 -213
  95. package/dist/node_modules/@zag-js/popper/dist/index.js +130 -129
  96. package/dist/node_modules/@zag-js/presence/dist/index.js +139 -122
  97. package/dist/node_modules/@zag-js/radio-group/dist/index.js +297 -302
  98. package/dist/node_modules/@zag-js/react/dist/index.js +255 -103
  99. package/dist/node_modules/@zag-js/remove-scroll/dist/index.js +18 -31
  100. package/dist/node_modules/@zag-js/select/dist/index.js +889 -885
  101. package/dist/node_modules/@zag-js/store/dist/index.js +98 -137
  102. package/dist/node_modules/@zag-js/switch/dist/index.js +199 -191
  103. package/dist/node_modules/@zag-js/tabs/dist/index.js +383 -386
  104. package/dist/node_modules/@zag-js/toast/dist/index.js +646 -633
  105. package/dist/node_modules/@zag-js/tooltip/dist/index.js +459 -0
  106. package/dist/node_modules/@zag-js/types/dist/index.js +6 -6
  107. package/dist/node_modules/@zag-js/utils/dist/index.js +112 -99
  108. package/dist/node_modules/proxy-compare/dist/index.js +4 -106
  109. package/dist/styles.css +1 -1
  110. package/package.json +5 -5
  111. package/dist/node_modules/@ark-ui/react/dist/utils/use-is-server.js +0 -10
  112. package/dist/node_modules/@zag-js/dom-event/dist/index.js +0 -130
  113. package/dist/node_modules/@zag-js/element-rect/dist/index.js +0 -32
  114. package/dist/node_modules/@zag-js/form-utils/dist/index.js +0 -51
  115. package/dist/node_modules/aria-hidden/dist/es2015/index.js +0 -52
  116. package/dist/node_modules/focus-trap/dist/focus-trap.esm.js +0 -431
  117. package/dist/node_modules/klona/full/index.js +0 -21
  118. package/dist/node_modules/tabbable/dist/index.esm.js +0 -202
@@ -1,15 +1,12 @@
1
- import { createAnatomy as U } from "../../anatomy/dist/index.js";
2
- import { ListCollection as k } from "../../collection/dist/index.js";
3
- import { createMachine as W, guards as K } from "../../core/dist/index.js";
4
- import { getEventKey as F } from "../../dom-event/dist/index.js";
5
- import { createScope as $, raf as y, getInitialFocus as B, observeAttributes as Y, scrollIntoView as q, getByTypeahead as A, isSelfTarget as j, isValidTabEvent as J, isEditableElement as Q, visuallyHiddenStyle as X, dataAttr as d, ariaAttr as Z } from "../../dom-query/dist/index.js";
6
- import { getPlacement as H, getPlacementStyles as z } from "../../popper/dist/index.js";
7
- import { trackDismissableElement as x } from "../../dismissable/dist/index.js";
8
- import { trackFormControl as ee } from "../../form-utils/dist/index.js";
9
- import { compact as te, isEqual as P, addOrRemove as ie } from "../../utils/dist/index.js";
10
- import { createProps as S } from "../../types/dist/index.js";
11
- import { ref as D } from "../../store/dist/index.js";
12
- var le = U("select").parts(
1
+ import { createAnatomy as te } from "../../anatomy/dist/index.js";
2
+ import { ListCollection as J } from "../../collection/dist/index.js";
3
+ import { raf as N, getInitialFocus as ie, observeAttributes as le, trackFormControl as ne, getByTypeahead as H, scrollIntoView as ae, isSelfTarget as se, isValidTabEvent as oe, getEventKey as $, getEventTarget as re, isEditableElement as de, visuallyHiddenStyle as ce, dataAttr as r, ariaAttr as ue } from "../../dom-query/dist/index.js";
4
+ import { getPlacement as K, getPlacementStyles as ge } from "../../popper/dist/index.js";
5
+ import { addOrRemove as B, isEqual as he, ensure as me } from "../../utils/dist/index.js";
6
+ import { createMachine as Ie, createGuards as pe } from "../../core/dist/index.js";
7
+ import { trackDismissableElement as Ee } from "../../dismissable/dist/index.js";
8
+ import { createProps as G } from "../../types/dist/index.js";
9
+ var ve = te("select").parts(
13
10
  "label",
14
11
  "positioner",
15
12
  "trigger",
@@ -25,1016 +22,1024 @@ var le = U("select").parts(
25
22
  "root",
26
23
  "control",
27
24
  "valueText"
28
- ), u = le.build(), _ = (t) => D(new k(t));
29
- _.empty = () => D(new k({ items: [] }));
30
- var r = $({
31
- getRootId: (t) => {
32
- var l;
33
- return ((l = t.ids) == null ? void 0 : l.root) ?? `select:${t.id}`;
34
- },
35
- getContentId: (t) => {
36
- var l;
37
- return ((l = t.ids) == null ? void 0 : l.content) ?? `select:${t.id}:content`;
38
- },
39
- getTriggerId: (t) => {
40
- var l;
41
- return ((l = t.ids) == null ? void 0 : l.trigger) ?? `select:${t.id}:trigger`;
42
- },
43
- getClearTriggerId: (t) => {
44
- var l;
45
- return ((l = t.ids) == null ? void 0 : l.clearTrigger) ?? `select:${t.id}:clear-trigger`;
46
- },
47
- getLabelId: (t) => {
48
- var l;
49
- return ((l = t.ids) == null ? void 0 : l.label) ?? `select:${t.id}:label`;
50
- },
51
- getControlId: (t) => {
52
- var l;
53
- return ((l = t.ids) == null ? void 0 : l.control) ?? `select:${t.id}:control`;
54
- },
55
- getItemId: (t, l) => {
56
- var e, i;
57
- return ((i = (e = t.ids) == null ? void 0 : e.item) == null ? void 0 : i.call(e, l)) ?? `select:${t.id}:option:${l}`;
58
- },
59
- getHiddenSelectId: (t) => {
60
- var l;
61
- return ((l = t.ids) == null ? void 0 : l.hiddenSelect) ?? `select:${t.id}:select`;
62
- },
63
- getPositionerId: (t) => {
64
- var l;
65
- return ((l = t.ids) == null ? void 0 : l.positioner) ?? `select:${t.id}:positioner`;
66
- },
67
- getItemGroupId: (t, l) => {
68
- var e, i;
69
- return ((i = (e = t.ids) == null ? void 0 : e.itemGroup) == null ? void 0 : i.call(e, l)) ?? `select:${t.id}:optgroup:${l}`;
70
- },
71
- getItemGroupLabelId: (t, l) => {
72
- var e, i;
73
- return ((i = (e = t.ids) == null ? void 0 : e.itemGroupLabel) == null ? void 0 : i.call(e, l)) ?? `select:${t.id}:optgroup-label:${l}`;
74
- },
75
- getHiddenSelectEl: (t) => r.getById(t, r.getHiddenSelectId(t)),
76
- getContentEl: (t) => r.getById(t, r.getContentId(t)),
77
- getControlEl: (t) => r.getById(t, r.getControlId(t)),
78
- getTriggerEl: (t) => r.getById(t, r.getTriggerId(t)),
79
- getClearTriggerEl: (t) => r.getById(t, r.getClearTriggerId(t)),
80
- getPositionerEl: (t) => r.getById(t, r.getPositionerId(t)),
81
- getHighlightedOptionEl(t) {
82
- return t.highlightedValue ? r.getById(t, r.getItemId(t, t.highlightedValue)) : null;
83
- }
84
- });
85
- function Ee(t, l, e) {
86
- const i = t.context.isDisabled, n = t.context.invalid, s = t.context.readOnly, m = t.context.isInteractive, h = t.context.composite, I = t.hasTag("open"), T = t.matches("focused"), v = t.context.highlightedValue, G = t.context.highlightedItem, w = t.context.selectedItems, V = t.context.isTypingAhead, C = t.context.collection, L = v ? r.getItemId(t.context, v) : void 0;
87
- function f(o) {
88
- const a = C.getItemDisabled(o.item), c = C.getItemValue(o.item);
89
- return {
90
- value: c,
91
- disabled: !!(i || a),
92
- highlighted: v === c,
93
- selected: t.context.value.includes(c)
25
+ ), h = ve.build(), Q = (e) => new J(e);
26
+ Q.empty = () => new J({ items: [] });
27
+ var fe = (e) => {
28
+ var t;
29
+ return ((t = e.ids) == null ? void 0 : t.root) ?? `select:${e.id}`;
30
+ }, D = (e) => {
31
+ var t;
32
+ return ((t = e.ids) == null ? void 0 : t.content) ?? `select:${e.id}:content`;
33
+ }, M = (e) => {
34
+ var t;
35
+ return ((t = e.ids) == null ? void 0 : t.trigger) ?? `select:${e.id}:trigger`;
36
+ }, X = (e) => {
37
+ var t;
38
+ return ((t = e.ids) == null ? void 0 : t.clearTrigger) ?? `select:${e.id}:clear-trigger`;
39
+ }, b = (e) => {
40
+ var t;
41
+ return ((t = e.ids) == null ? void 0 : t.label) ?? `select:${e.id}:label`;
42
+ }, Te = (e) => {
43
+ var t;
44
+ return ((t = e.ids) == null ? void 0 : t.control) ?? `select:${e.id}:control`;
45
+ }, w = (e, t) => {
46
+ var i, l;
47
+ return ((l = (i = e.ids) == null ? void 0 : i.item) == null ? void 0 : l.call(i, t)) ?? `select:${e.id}:option:${t}`;
48
+ }, _ = (e) => {
49
+ var t;
50
+ return ((t = e.ids) == null ? void 0 : t.hiddenSelect) ?? `select:${e.id}:select`;
51
+ }, Z = (e) => {
52
+ var t;
53
+ return ((t = e.ids) == null ? void 0 : t.positioner) ?? `select:${e.id}:positioner`;
54
+ }, Oe = (e, t) => {
55
+ var i, l;
56
+ return ((l = (i = e.ids) == null ? void 0 : i.itemGroup) == null ? void 0 : l.call(i, t)) ?? `select:${e.id}:optgroup:${t}`;
57
+ }, Y = (e, t) => {
58
+ var i, l;
59
+ return ((l = (i = e.ids) == null ? void 0 : i.itemGroupLabel) == null ? void 0 : l.call(i, t)) ?? `select:${e.id}:optgroup-label:${t}`;
60
+ }, k = (e) => e.getById(_(e)), R = (e) => e.getById(D(e)), f = (e) => e.getById(M(e)), ye = (e) => e.getById(X(e)), q = (e) => e.getById(Z(e)), Re = (e, t) => e.getById(w(e, t));
61
+ function Ne(e, t) {
62
+ const { context: i, prop: l, scope: a, state: d, computed: c, send: o } = e, g = l("disabled") || i.get("fieldsetDisabled"), m = l("invalid"), I = l("readOnly"), p = l("composite"), S = l("collection"), E = d.hasTag("open"), P = d.matches("focused"), y = i.get("highlightedValue"), x = i.get("highlightedItem"), z = i.get("selectedItems"), L = i.get("currentPlacement"), U = c("isTypingAhead"), F = c("isInteractive"), A = y ? w(a, y) : void 0;
63
+ function V(n) {
64
+ const s = S.getItemDisabled(n.item), u = S.getItemValue(n.item);
65
+ return me(u, () => `[zag-js] No value found for item ${JSON.stringify(n.item)}`), {
66
+ value: u,
67
+ disabled: !!(g || s),
68
+ highlighted: y === u,
69
+ selected: i.get("value").includes(u)
94
70
  };
95
71
  }
96
- const M = z({
97
- ...t.context.positioning,
98
- placement: t.context.currentPlacement
72
+ const ee = ge({
73
+ ...l("positioning"),
74
+ placement: L
99
75
  });
100
76
  return {
101
- open: I,
102
- focused: T,
103
- empty: t.context.value.length === 0,
104
- highlightedItem: G,
105
- highlightedValue: v,
106
- selectedItems: w,
107
- hasSelectedItems: t.context.hasSelectedItems,
108
- value: t.context.value,
109
- valueAsString: t.context.valueAsString,
110
- collection: C,
111
- setCollection(o) {
112
- l({ type: "COLLECTION.SET", value: o });
113
- },
114
- reposition(o = {}) {
115
- l({ type: "POSITIONING.SET", options: o });
77
+ open: E,
78
+ focused: P,
79
+ empty: i.get("value").length === 0,
80
+ highlightedItem: x,
81
+ highlightedValue: y,
82
+ selectedItems: z,
83
+ hasSelectedItems: c("hasSelectedItems"),
84
+ value: i.get("value"),
85
+ valueAsString: i.get("valueAsString"),
86
+ collection: S,
87
+ multiple: !!l("multiple"),
88
+ disabled: !!g,
89
+ reposition(n = {}) {
90
+ o({ type: "POSITIONING.SET", options: n });
116
91
  },
117
92
  focus() {
118
- var o;
119
- (o = r.getTriggerEl(t.context)) == null || o.focus({ preventScroll: !0 });
93
+ var n;
94
+ (n = f(a)) == null || n.focus({ preventScroll: !0 });
120
95
  },
121
- setOpen(o) {
122
- o !== I && l(o ? "OPEN" : "CLOSE");
96
+ setOpen(n) {
97
+ d.hasTag("open") !== n && o({ type: n ? "OPEN" : "CLOSE" });
123
98
  },
124
- selectValue(o) {
125
- l({ type: "ITEM.SELECT", value: o });
99
+ selectValue(n) {
100
+ o({ type: "ITEM.SELECT", value: n });
126
101
  },
127
- setValue(o) {
128
- l({ type: "VALUE.SET", value: o });
102
+ setValue(n) {
103
+ o({ type: "VALUE.SET", value: n });
129
104
  },
130
105
  selectAll() {
131
- l({ type: "VALUE.SET", value: C.getValues() });
106
+ o({ type: "VALUE.SET", value: S.getValues() });
132
107
  },
133
- highlightValue(o) {
134
- l({ type: "HIGHLIGHTED_VALUE.SET", value: o });
108
+ highlightValue(n) {
109
+ o({ type: "HIGHLIGHTED_VALUE.SET", value: n });
135
110
  },
136
- clearValue(o) {
137
- l(o ? { type: "ITEM.CLEAR", value: o } : { type: "VALUE.CLEAR" });
111
+ clearValue(n) {
112
+ o(n ? { type: "ITEM.CLEAR", value: n } : { type: "VALUE.CLEAR" });
138
113
  },
139
- getItemState: f,
114
+ getItemState: V,
140
115
  getRootProps() {
141
- return e.element({
142
- ...u.root.attrs,
143
- dir: t.context.dir,
144
- id: r.getRootId(t.context),
145
- "data-invalid": d(n),
146
- "data-readonly": d(s)
116
+ return t.element({
117
+ ...h.root.attrs,
118
+ dir: l("dir"),
119
+ id: fe(a),
120
+ "data-invalid": r(m),
121
+ "data-readonly": r(I)
147
122
  });
148
123
  },
149
124
  getLabelProps() {
150
- return e.label({
151
- dir: t.context.dir,
152
- id: r.getLabelId(t.context),
153
- ...u.label.attrs,
154
- "data-disabled": d(i),
155
- "data-invalid": d(n),
156
- "data-readonly": d(s),
157
- htmlFor: r.getHiddenSelectId(t.context),
158
- onClick(o) {
159
- var a;
160
- o.defaultPrevented || i || (a = r.getTriggerEl(t.context)) == null || a.focus({ preventScroll: !0 });
125
+ return t.label({
126
+ dir: l("dir"),
127
+ id: b(a),
128
+ ...h.label.attrs,
129
+ "data-disabled": r(g),
130
+ "data-invalid": r(m),
131
+ "data-readonly": r(I),
132
+ htmlFor: _(a),
133
+ onClick(n) {
134
+ var s;
135
+ n.defaultPrevented || g || (s = f(a)) == null || s.focus({ preventScroll: !0 });
161
136
  }
162
137
  });
163
138
  },
164
139
  getControlProps() {
165
- return e.element({
166
- ...u.control.attrs,
167
- dir: t.context.dir,
168
- id: r.getControlId(t.context),
169
- "data-state": I ? "open" : "closed",
170
- "data-focus": d(T),
171
- "data-disabled": d(i),
172
- "data-invalid": d(n)
140
+ return t.element({
141
+ ...h.control.attrs,
142
+ dir: l("dir"),
143
+ id: Te(a),
144
+ "data-state": E ? "open" : "closed",
145
+ "data-focus": r(P),
146
+ "data-disabled": r(g),
147
+ "data-invalid": r(m)
173
148
  });
174
149
  },
175
150
  getValueTextProps() {
176
- return e.element({
177
- ...u.valueText.attrs,
178
- dir: t.context.dir,
179
- "data-disabled": d(i),
180
- "data-invalid": d(n),
181
- "data-focus": d(T)
151
+ return t.element({
152
+ ...h.valueText.attrs,
153
+ dir: l("dir"),
154
+ "data-disabled": r(g),
155
+ "data-invalid": r(m),
156
+ "data-focus": r(P)
182
157
  });
183
158
  },
184
159
  getTriggerProps() {
185
- return e.button({
186
- id: r.getTriggerId(t.context),
187
- disabled: i,
188
- dir: t.context.dir,
160
+ return t.button({
161
+ id: M(a),
162
+ disabled: g,
163
+ dir: l("dir"),
189
164
  type: "button",
190
165
  role: "combobox",
191
- "aria-controls": r.getContentId(t.context),
192
- "aria-expanded": I,
166
+ "aria-controls": D(a),
167
+ "aria-expanded": E,
193
168
  "aria-haspopup": "listbox",
194
- "data-state": I ? "open" : "closed",
195
- "aria-invalid": n,
196
- "aria-labelledby": r.getLabelId(t.context),
197
- ...u.trigger.attrs,
198
- "data-disabled": d(i),
199
- "data-invalid": d(n),
200
- "data-readonly": d(s),
201
- "data-placement": t.context.currentPlacement,
202
- "data-placeholder-shown": d(!t.context.hasSelectedItems),
203
- onClick(o) {
204
- m && (o.defaultPrevented || l({ type: "TRIGGER.CLICK" }));
169
+ "data-state": E ? "open" : "closed",
170
+ "aria-invalid": m,
171
+ "aria-labelledby": b(a),
172
+ ...h.trigger.attrs,
173
+ "data-disabled": r(g),
174
+ "data-invalid": r(m),
175
+ "data-readonly": r(I),
176
+ "data-placement": L,
177
+ "data-placeholder-shown": r(!c("hasSelectedItems")),
178
+ onClick(n) {
179
+ F && (n.defaultPrevented || o({ type: "TRIGGER.CLICK" }));
205
180
  },
206
181
  onFocus() {
207
- l("TRIGGER.FOCUS");
182
+ o({ type: "TRIGGER.FOCUS" });
208
183
  },
209
184
  onBlur() {
210
- l("TRIGGER.BLUR");
185
+ o({ type: "TRIGGER.BLUR" });
211
186
  },
212
- onKeyDown(o) {
213
- if (o.defaultPrevented || !m) return;
214
- const c = {
187
+ onKeyDown(n) {
188
+ if (n.defaultPrevented || !F) return;
189
+ const u = {
215
190
  ArrowUp() {
216
- l({ type: "TRIGGER.ARROW_UP" });
191
+ o({ type: "TRIGGER.ARROW_UP" });
217
192
  },
218
- ArrowDown(p) {
219
- l({ type: p.altKey ? "OPEN" : "TRIGGER.ARROW_DOWN" });
193
+ ArrowDown(T) {
194
+ o({ type: T.altKey ? "OPEN" : "TRIGGER.ARROW_DOWN" });
220
195
  },
221
196
  ArrowLeft() {
222
- l({ type: "TRIGGER.ARROW_LEFT" });
197
+ o({ type: "TRIGGER.ARROW_LEFT" });
223
198
  },
224
199
  ArrowRight() {
225
- l({ type: "TRIGGER.ARROW_RIGHT" });
200
+ o({ type: "TRIGGER.ARROW_RIGHT" });
226
201
  },
227
202
  Home() {
228
- l({ type: "TRIGGER.HOME" });
203
+ o({ type: "TRIGGER.HOME" });
229
204
  },
230
205
  End() {
231
- l({ type: "TRIGGER.END" });
206
+ o({ type: "TRIGGER.END" });
232
207
  },
233
208
  Enter() {
234
- l({ type: "TRIGGER.ENTER" });
209
+ o({ type: "TRIGGER.ENTER" });
235
210
  },
236
- Space(p) {
237
- l(V ? { type: "TRIGGER.TYPEAHEAD", key: p.key } : { type: "TRIGGER.ENTER" });
211
+ Space(T) {
212
+ o(U ? { type: "TRIGGER.TYPEAHEAD", key: T.key } : { type: "TRIGGER.ENTER" });
238
213
  }
239
- }[F(o, t.context)];
240
- if (c) {
241
- c(o), o.preventDefault();
214
+ }[$(n, {
215
+ dir: l("dir"),
216
+ orientation: "vertical"
217
+ })];
218
+ if (u) {
219
+ u(n), n.preventDefault();
242
220
  return;
243
221
  }
244
- A.isValidEvent(o) && (l({ type: "TRIGGER.TYPEAHEAD", key: o.key }), o.preventDefault());
222
+ H.isValidEvent(n) && (o({ type: "TRIGGER.TYPEAHEAD", key: n.key }), n.preventDefault());
245
223
  }
246
224
  });
247
225
  },
248
226
  getIndicatorProps() {
249
- return e.element({
250
- ...u.indicator.attrs,
251
- dir: t.context.dir,
227
+ return t.element({
228
+ ...h.indicator.attrs,
229
+ dir: l("dir"),
252
230
  "aria-hidden": !0,
253
- "data-state": I ? "open" : "closed",
254
- "data-disabled": d(i),
255
- "data-invalid": d(n),
256
- "data-readonly": d(s)
231
+ "data-state": E ? "open" : "closed",
232
+ "data-disabled": r(g),
233
+ "data-invalid": r(m),
234
+ "data-readonly": r(I)
257
235
  });
258
236
  },
259
- getItemProps(o) {
260
- const a = f(o);
261
- return e.element({
262
- id: r.getItemId(t.context, a.value),
237
+ getItemProps(n) {
238
+ const s = V(n);
239
+ return t.element({
240
+ id: w(a, s.value),
263
241
  role: "option",
264
- ...u.item.attrs,
265
- dir: t.context.dir,
266
- "data-value": a.value,
267
- "aria-selected": a.selected,
268
- "data-state": a.selected ? "checked" : "unchecked",
269
- "data-highlighted": d(a.highlighted),
270
- "data-disabled": d(a.disabled),
271
- "aria-disabled": Z(a.disabled),
272
- onPointerMove(c) {
273
- a.disabled || c.pointerType !== "mouse" || a.value !== t.context.highlightedValue && l({ type: "ITEM.POINTER_MOVE", value: a.value });
242
+ ...h.item.attrs,
243
+ dir: l("dir"),
244
+ "data-value": s.value,
245
+ "aria-selected": s.selected,
246
+ "data-state": s.selected ? "checked" : "unchecked",
247
+ "data-highlighted": r(s.highlighted),
248
+ "data-disabled": r(s.disabled),
249
+ "aria-disabled": ue(s.disabled),
250
+ onPointerMove(u) {
251
+ s.disabled || u.pointerType !== "mouse" || s.value !== y && o({ type: "ITEM.POINTER_MOVE", value: s.value });
274
252
  },
275
- onClick(c) {
276
- c.defaultPrevented || a.disabled || l({ type: "ITEM.CLICK", src: "pointerup", value: a.value });
253
+ onClick(u) {
254
+ u.defaultPrevented || s.disabled || o({ type: "ITEM.CLICK", src: "pointerup", value: s.value });
277
255
  },
278
- onPointerLeave(c) {
279
- a.disabled || o.persistFocus || c.pointerType !== "mouse" || !t.previousEvent.type.includes("POINTER") || l({ type: "ITEM.POINTER_LEAVE" });
256
+ onPointerLeave(u) {
257
+ var O;
258
+ s.disabled || n.persistFocus || u.pointerType !== "mouse" || !((O = e.event.previous()) != null && O.type.includes("POINTER")) || o({ type: "ITEM.POINTER_LEAVE" });
280
259
  }
281
260
  });
282
261
  },
283
- getItemTextProps(o) {
284
- const a = f(o);
285
- return e.element({
286
- ...u.itemText.attrs,
287
- "data-state": a.selected ? "checked" : "unchecked",
288
- "data-disabled": d(a.disabled),
289
- "data-highlighted": d(a.highlighted)
262
+ getItemTextProps(n) {
263
+ const s = V(n);
264
+ return t.element({
265
+ ...h.itemText.attrs,
266
+ "data-state": s.selected ? "checked" : "unchecked",
267
+ "data-disabled": r(s.disabled),
268
+ "data-highlighted": r(s.highlighted)
290
269
  });
291
270
  },
292
- getItemIndicatorProps(o) {
293
- const a = f(o);
294
- return e.element({
271
+ getItemIndicatorProps(n) {
272
+ const s = V(n);
273
+ return t.element({
295
274
  "aria-hidden": !0,
296
- ...u.itemIndicator.attrs,
297
- "data-state": a.selected ? "checked" : "unchecked",
298
- hidden: !a.selected
275
+ ...h.itemIndicator.attrs,
276
+ "data-state": s.selected ? "checked" : "unchecked",
277
+ hidden: !s.selected
299
278
  });
300
279
  },
301
- getItemGroupLabelProps(o) {
302
- const { htmlFor: a } = o;
303
- return e.element({
304
- ...u.itemGroupLabel.attrs,
305
- id: r.getItemGroupLabelId(t.context, a),
306
- role: "group",
307
- dir: t.context.dir
280
+ getItemGroupLabelProps(n) {
281
+ const { htmlFor: s } = n;
282
+ return t.element({
283
+ ...h.itemGroupLabel.attrs,
284
+ id: Y(a, s),
285
+ dir: l("dir"),
286
+ role: "presentation"
308
287
  });
309
288
  },
310
- getItemGroupProps(o) {
311
- const { id: a } = o;
312
- return e.element({
313
- ...u.itemGroup.attrs,
314
- "data-disabled": d(i),
315
- id: r.getItemGroupId(t.context, a),
316
- "aria-labelledby": r.getItemGroupLabelId(t.context, a),
317
- dir: t.context.dir
289
+ getItemGroupProps(n) {
290
+ const { id: s } = n;
291
+ return t.element({
292
+ ...h.itemGroup.attrs,
293
+ "data-disabled": r(g),
294
+ id: Oe(a, s),
295
+ "aria-labelledby": Y(a, s),
296
+ role: "group",
297
+ dir: l("dir")
318
298
  });
319
299
  },
320
300
  getClearTriggerProps() {
321
- return e.button({
322
- ...u.clearTrigger.attrs,
323
- id: r.getClearTriggerId(t.context),
301
+ return t.button({
302
+ ...h.clearTrigger.attrs,
303
+ id: X(a),
324
304
  type: "button",
325
305
  "aria-label": "Clear value",
326
- "data-invalid": d(n),
327
- disabled: i,
328
- hidden: !t.context.hasSelectedItems,
329
- dir: t.context.dir,
330
- onClick(o) {
331
- o.defaultPrevented || l("CLEAR.CLICK");
306
+ "data-invalid": r(m),
307
+ disabled: g,
308
+ hidden: !c("hasSelectedItems"),
309
+ dir: l("dir"),
310
+ onClick(n) {
311
+ n.defaultPrevented || o({ type: "CLEAR.CLICK" });
332
312
  }
333
313
  });
334
314
  },
335
315
  getHiddenSelectProps() {
336
- return e.select({
337
- name: t.context.name,
338
- form: t.context.form,
339
- disabled: i,
340
- multiple: t.context.multiple,
341
- required: t.context.required,
316
+ const n = i.get("value"), s = l("multiple") ? n : n == null ? void 0 : n[0];
317
+ return t.select({
318
+ name: l("name"),
319
+ form: l("form"),
320
+ disabled: g,
321
+ multiple: l("multiple"),
322
+ required: l("required"),
342
323
  "aria-hidden": !0,
343
- id: r.getHiddenSelectId(t.context),
344
- defaultValue: t.context.multiple ? t.context.value : t.context.value[0],
345
- style: X,
324
+ id: _(a),
325
+ defaultValue: s,
326
+ style: ce,
346
327
  tabIndex: -1,
347
328
  // Some browser extensions will focus the hidden select.
348
329
  // Let's forward the focus to the trigger.
349
330
  onFocus() {
350
- var o;
351
- (o = r.getTriggerEl(t.context)) == null || o.focus({ preventScroll: !0 });
331
+ var u;
332
+ (u = f(a)) == null || u.focus({ preventScroll: !0 });
352
333
  },
353
- "aria-labelledby": r.getLabelId(t.context)
334
+ "aria-labelledby": b(a)
354
335
  });
355
336
  },
356
337
  getPositionerProps() {
357
- return e.element({
358
- ...u.positioner.attrs,
359
- dir: t.context.dir,
360
- id: r.getPositionerId(t.context),
361
- style: M.floating
338
+ return t.element({
339
+ ...h.positioner.attrs,
340
+ dir: l("dir"),
341
+ id: Z(a),
342
+ style: ee.floating
362
343
  });
363
344
  },
364
345
  getContentProps() {
365
- return e.element({
366
- hidden: !I,
367
- dir: t.context.dir,
368
- id: r.getContentId(t.context),
369
- role: h ? "listbox" : "dialog",
370
- ...u.content.attrs,
371
- "data-state": I ? "open" : "closed",
372
- "data-placement": t.context.currentPlacement,
373
- "data-activedescendant": L,
374
- "aria-activedescendant": h ? L : void 0,
375
- "aria-multiselectable": t.context.multiple && h ? !0 : void 0,
376
- "aria-labelledby": r.getLabelId(t.context),
346
+ return t.element({
347
+ hidden: !E,
348
+ dir: l("dir"),
349
+ id: D(a),
350
+ role: p ? "listbox" : "dialog",
351
+ ...h.content.attrs,
352
+ "data-state": E ? "open" : "closed",
353
+ "data-placement": L,
354
+ "data-activedescendant": A,
355
+ "aria-activedescendant": p ? A : void 0,
356
+ "aria-multiselectable": l("multiple") && p ? !0 : void 0,
357
+ "aria-labelledby": b(a),
377
358
  tabIndex: 0,
378
- onKeyDown(o) {
379
- if (!m || !j(o)) return;
380
- if (o.key === "Tab" && !J(o)) {
381
- o.preventDefault();
359
+ onKeyDown(n) {
360
+ if (!F || !se(n)) return;
361
+ if (n.key === "Tab" && !oe(n)) {
362
+ n.preventDefault();
382
363
  return;
383
364
  }
384
- const a = {
365
+ const s = {
385
366
  ArrowUp() {
386
- l({ type: "CONTENT.ARROW_UP" });
367
+ o({ type: "CONTENT.ARROW_UP" });
387
368
  },
388
369
  ArrowDown() {
389
- l({ type: "CONTENT.ARROW_DOWN" });
370
+ o({ type: "CONTENT.ARROW_DOWN" });
390
371
  },
391
372
  Home() {
392
- l({ type: "CONTENT.HOME" });
373
+ o({ type: "CONTENT.HOME" });
393
374
  },
394
375
  End() {
395
- l({ type: "CONTENT.END" });
376
+ o({ type: "CONTENT.END" });
396
377
  },
397
378
  Enter() {
398
- l({ type: "ITEM.CLICK", src: "keydown.enter" });
379
+ o({ type: "ITEM.CLICK", src: "keydown.enter" });
399
380
  },
400
- Space(p) {
401
- var N;
402
- V ? l({ type: "CONTENT.TYPEAHEAD", key: p.key }) : (N = a.Enter) == null || N.call(a, p);
381
+ Space(O) {
382
+ var W;
383
+ U ? o({ type: "CONTENT.TYPEAHEAD", key: O.key }) : (W = s.Enter) == null || W.call(s, O);
403
384
  }
404
- }, c = a[F(o)];
405
- if (c) {
406
- c(o), o.preventDefault();
385
+ }, u = s[$(n)];
386
+ if (u) {
387
+ u(n), n.preventDefault();
407
388
  return;
408
389
  }
409
- Q(o.target) || A.isValidEvent(o) && (l({ type: "CONTENT.TYPEAHEAD", key: o.key }), o.preventDefault());
390
+ const T = re(n);
391
+ de(T) || H.isValidEvent(n) && (o({ type: "CONTENT.TYPEAHEAD", key: n.key }), n.preventDefault());
410
392
  }
411
393
  });
412
394
  },
413
395
  getListProps() {
414
- return e.element({
415
- ...u.list.attrs,
396
+ return t.element({
397
+ ...h.list.attrs,
416
398
  tabIndex: 0,
417
- role: h ? void 0 : "listbox",
418
- "aria-labelledby": r.getTriggerId(t.context),
419
- "aria-activedescendant": h ? void 0 : L,
420
- "aria-multiselectable": !h && t.context.multiple ? !0 : void 0
399
+ role: p ? void 0 : "listbox",
400
+ "aria-labelledby": M(a),
401
+ "aria-activedescendant": p ? void 0 : A,
402
+ "aria-multiselectable": !p && l("multiple") ? !0 : void 0
421
403
  });
422
404
  }
423
405
  };
424
406
  }
425
- var { and: O, not: E, or: oe } = K;
426
- function ve(t) {
427
- const l = te(t);
428
- return W(
429
- {
430
- id: "select",
431
- context: {
432
- value: [],
433
- highlightedValue: null,
434
- loopFocus: !1,
435
- closeOnSelect: !l.multiple,
436
- disabled: !1,
437
- readOnly: !1,
438
- composite: !0,
439
- ...l,
440
- highlightedItem: null,
441
- selectedItems: [],
442
- valueAsString: "",
443
- collection: l.collection ?? _.empty(),
444
- typeahead: A.defaultOptions,
445
- fieldsetDisabled: !1,
446
- positioning: {
447
- placement: "bottom-start",
448
- gutter: 8,
449
- ...l.positioning
407
+ var { and: C, not: v, or: Ce } = pe(), ke = Ie({
408
+ props({ props: e }) {
409
+ return {
410
+ loopFocus: !1,
411
+ closeOnSelect: !e.multiple,
412
+ composite: !0,
413
+ defaultValue: [],
414
+ ...e,
415
+ collection: e.collection ?? Q.empty(),
416
+ positioning: {
417
+ placement: "bottom-start",
418
+ gutter: 8,
419
+ ...e.positioning
420
+ }
421
+ };
422
+ },
423
+ context({ prop: e, bindable: t }) {
424
+ return {
425
+ value: t(() => ({
426
+ defaultValue: e("defaultValue"),
427
+ value: e("value"),
428
+ isEqual: he,
429
+ onChange(i) {
430
+ var a;
431
+ const l = e("collection").findMany(i);
432
+ return (a = e("onValueChange")) == null ? void 0 : a({ value: i, items: l });
450
433
  }
451
- },
452
- computed: {
453
- hasSelectedItems: (e) => e.value.length > 0,
454
- isTypingAhead: (e) => e.typeahead.keysSoFar !== "",
455
- isDisabled: (e) => !!e.disabled || e.fieldsetDisabled,
456
- isInteractive: (e) => !(e.isDisabled || e.readOnly)
457
- },
458
- initial: l.open ? "open" : "idle",
459
- created: ["syncCollection"],
460
- entry: ["syncSelectElement"],
461
- watch: {
462
- open: ["toggleVisibility"],
463
- value: ["syncSelectedItems", "syncSelectElement"],
464
- highlightedValue: ["syncHighlightedItem"],
465
- collection: ["syncCollection"]
466
- },
467
- on: {
468
- "HIGHLIGHTED_VALUE.SET": {
469
- actions: ["setHighlightedItem"]
470
- },
471
- "ITEM.SELECT": {
472
- actions: ["selectItem"]
473
- },
474
- "ITEM.CLEAR": {
475
- actions: ["clearItem"]
476
- },
477
- "VALUE.SET": {
478
- actions: ["setSelectedItems"]
479
- },
480
- "VALUE.CLEAR": {
481
- actions: ["clearSelectedItems"]
482
- },
483
- "CLEAR.CLICK": {
484
- actions: ["clearSelectedItems", "focusTriggerEl"]
485
- },
486
- "COLLECTION.SET": {
487
- actions: ["setCollection"]
434
+ })),
435
+ highlightedValue: t(() => ({
436
+ defaultValue: e("defaultHighlightedValue") || null,
437
+ value: e("highlightedValue"),
438
+ onChange(i) {
439
+ var l;
440
+ (l = e("onHighlightChange")) == null || l({
441
+ highlightedValue: i,
442
+ highlightedItem: e("collection").find(i),
443
+ highlightedIndex: e("collection").indexOf(i)
444
+ });
488
445
  }
489
- },
490
- activities: ["trackFormControlState"],
491
- states: {
492
- idle: {
493
- tags: ["closed"],
494
- on: {
495
- "CONTROLLED.OPEN": [
496
- {
497
- guard: "isTriggerClickEvent",
498
- target: "open",
499
- actions: ["setInitialFocus", "highlightFirstSelectedItem"]
500
- },
501
- {
502
- target: "open",
503
- actions: ["setInitialFocus"]
504
- }
505
- ],
506
- "TRIGGER.CLICK": [
507
- {
508
- guard: "isOpenControlled",
509
- actions: ["invokeOnOpen"]
510
- },
511
- {
512
- target: "open",
513
- actions: ["invokeOnOpen", "setInitialFocus", "highlightFirstSelectedItem"]
514
- }
515
- ],
516
- "TRIGGER.FOCUS": {
517
- target: "focused"
518
- },
519
- OPEN: [
520
- {
521
- guard: "isOpenControlled",
522
- actions: ["invokeOnOpen"]
523
- },
524
- {
525
- target: "open",
526
- actions: ["setInitialFocus", "invokeOnOpen"]
527
- }
528
- ]
446
+ })),
447
+ currentPlacement: t(() => ({
448
+ defaultValue: void 0
449
+ })),
450
+ fieldsetDisabled: t(() => ({
451
+ defaultValue: !1
452
+ })),
453
+ highlightedItem: t(() => ({
454
+ defaultValue: null
455
+ })),
456
+ selectedItems: t(() => {
457
+ const i = e("value") ?? e("defaultValue") ?? [];
458
+ return { defaultValue: e("collection").findMany(i) };
459
+ }),
460
+ valueAsString: t(() => {
461
+ const i = e("value") ?? e("defaultValue") ?? [];
462
+ return { defaultValue: e("collection").stringifyMany(i) };
463
+ })
464
+ };
465
+ },
466
+ refs() {
467
+ return {
468
+ typeahead: { ...H.defaultOptions }
469
+ };
470
+ },
471
+ computed: {
472
+ hasSelectedItems: ({ context: e }) => e.get("value").length > 0,
473
+ isTypingAhead: ({ refs: e }) => e.get("typeahead").keysSoFar !== "",
474
+ isDisabled: ({ prop: e, context: t }) => !!e("disabled") || !!t.get("fieldsetDisabled"),
475
+ isInteractive: ({ prop: e }) => !(e("disabled") || e("readOnly"))
476
+ },
477
+ initialState({ prop: e }) {
478
+ return e("open") || e("defaultOpen") ? "open" : "idle";
479
+ },
480
+ entry: ["syncSelectElement"],
481
+ watch({ context: e, prop: t, track: i, action: l }) {
482
+ i([() => e.get("value").toString()], () => {
483
+ l(["syncSelectedItems", "syncSelectElement", "dispatchChangeEvent"]);
484
+ }), i([() => t("open")], () => {
485
+ l(["toggleVisibility"]);
486
+ }), i([() => e.get("highlightedValue")], () => {
487
+ l(["syncHighlightedItem"]);
488
+ }), i([() => t("collection").toString()], () => {
489
+ l(["syncCollection"]);
490
+ });
491
+ },
492
+ on: {
493
+ "HIGHLIGHTED_VALUE.SET": {
494
+ actions: ["setHighlightedItem"]
495
+ },
496
+ "ITEM.SELECT": {
497
+ actions: ["selectItem"]
498
+ },
499
+ "ITEM.CLEAR": {
500
+ actions: ["clearItem"]
501
+ },
502
+ "VALUE.SET": {
503
+ actions: ["setSelectedItems"]
504
+ },
505
+ "VALUE.CLEAR": {
506
+ actions: ["clearSelectedItems"]
507
+ },
508
+ "CLEAR.CLICK": {
509
+ actions: ["clearSelectedItems", "focusTriggerEl"]
510
+ }
511
+ },
512
+ effects: ["trackFormControlState"],
513
+ states: {
514
+ idle: {
515
+ tags: ["closed"],
516
+ on: {
517
+ "CONTROLLED.OPEN": [
518
+ {
519
+ guard: "isTriggerClickEvent",
520
+ target: "open",
521
+ actions: ["setInitialFocus", "highlightFirstSelectedItem"]
522
+ },
523
+ {
524
+ target: "open",
525
+ actions: ["setInitialFocus"]
529
526
  }
530
- },
531
- focused: {
532
- tags: ["closed"],
533
- on: {
534
- "CONTROLLED.OPEN": [
535
- {
536
- guard: "isTriggerClickEvent",
537
- target: "open",
538
- actions: ["setInitialFocus", "highlightFirstSelectedItem"]
539
- },
540
- {
541
- guard: "isTriggerArrowUpEvent",
542
- target: "open",
543
- actions: ["setInitialFocus", "highlightComputedLastItem"]
544
- },
545
- {
546
- guard: oe("isTriggerArrowDownEvent", "isTriggerEnterEvent"),
547
- target: "open",
548
- actions: ["setInitialFocus", "highlightComputedFirstItem"]
549
- },
550
- {
551
- target: "open",
552
- actions: ["setInitialFocus"]
553
- }
554
- ],
555
- OPEN: [
556
- {
557
- guard: "isOpenControlled",
558
- actions: ["invokeOnOpen"]
559
- },
560
- {
561
- target: "open",
562
- actions: ["setInitialFocus", "invokeOnOpen"]
563
- }
564
- ],
565
- "TRIGGER.BLUR": {
566
- target: "idle"
567
- },
568
- "TRIGGER.CLICK": [
569
- {
570
- guard: "isOpenControlled",
571
- actions: ["invokeOnOpen"]
572
- },
573
- {
574
- target: "open",
575
- actions: ["setInitialFocus", "invokeOnOpen", "highlightFirstSelectedItem"]
576
- }
577
- ],
578
- "TRIGGER.ENTER": [
579
- {
580
- guard: "isOpenControlled",
581
- actions: ["invokeOnOpen"]
582
- },
583
- {
584
- target: "open",
585
- actions: ["setInitialFocus", "invokeOnOpen", "highlightComputedFirstItem"]
586
- }
587
- ],
588
- "TRIGGER.ARROW_UP": [
589
- {
590
- guard: "isOpenControlled",
591
- actions: ["invokeOnOpen"]
592
- },
593
- {
594
- target: "open",
595
- actions: ["setInitialFocus", "invokeOnOpen", "highlightComputedLastItem"]
596
- }
597
- ],
598
- "TRIGGER.ARROW_DOWN": [
599
- {
600
- guard: "isOpenControlled",
601
- actions: ["invokeOnOpen"]
602
- },
603
- {
604
- target: "open",
605
- actions: ["setInitialFocus", "invokeOnOpen", "highlightComputedFirstItem"]
606
- }
607
- ],
608
- "TRIGGER.ARROW_LEFT": [
609
- {
610
- guard: O(E("multiple"), "hasSelectedItems"),
611
- actions: ["selectPreviousItem"]
612
- },
613
- {
614
- guard: E("multiple"),
615
- actions: ["selectLastItem"]
616
- }
617
- ],
618
- "TRIGGER.ARROW_RIGHT": [
619
- {
620
- guard: O(E("multiple"), "hasSelectedItems"),
621
- actions: ["selectNextItem"]
622
- },
623
- {
624
- guard: E("multiple"),
625
- actions: ["selectFirstItem"]
626
- }
627
- ],
628
- "TRIGGER.HOME": {
629
- guard: E("multiple"),
630
- actions: ["selectFirstItem"]
631
- },
632
- "TRIGGER.END": {
633
- guard: E("multiple"),
634
- actions: ["selectLastItem"]
635
- },
636
- "TRIGGER.TYPEAHEAD": {
637
- guard: E("multiple"),
638
- actions: ["selectMatchingItem"]
639
- }
527
+ ],
528
+ "TRIGGER.CLICK": [
529
+ {
530
+ guard: "isOpenControlled",
531
+ actions: ["invokeOnOpen"]
532
+ },
533
+ {
534
+ target: "open",
535
+ actions: ["invokeOnOpen", "setInitialFocus", "highlightFirstSelectedItem"]
640
536
  }
537
+ ],
538
+ "TRIGGER.FOCUS": {
539
+ target: "focused"
641
540
  },
642
- open: {
643
- tags: ["open"],
644
- exit: ["scrollContentToTop"],
645
- activities: ["trackDismissableElement", "computePlacement", "scrollToHighlightedItem"],
646
- on: {
647
- "CONTROLLED.CLOSE": {
648
- target: "focused",
649
- actions: ["focusTriggerEl", "clearHighlightedItem"]
650
- },
651
- CLOSE: [
652
- {
653
- guard: "isOpenControlled",
654
- actions: ["invokeOnClose"]
655
- },
656
- {
657
- target: "focused",
658
- actions: ["invokeOnClose", "focusTriggerEl", "clearHighlightedItem"]
659
- }
660
- ],
661
- "TRIGGER.CLICK": [
662
- {
663
- guard: "isOpenControlled",
664
- actions: ["invokeOnClose"]
665
- },
666
- {
667
- target: "focused",
668
- actions: ["invokeOnClose", "clearHighlightedItem"]
669
- }
670
- ],
671
- "ITEM.CLICK": [
672
- {
673
- guard: O("closeOnSelect", "isOpenControlled"),
674
- actions: ["selectHighlightedItem", "invokeOnClose"]
675
- },
676
- {
677
- guard: "closeOnSelect",
678
- target: "focused",
679
- actions: ["selectHighlightedItem", "invokeOnClose", "focusTriggerEl", "clearHighlightedItem"]
680
- },
681
- {
682
- actions: ["selectHighlightedItem"]
683
- }
684
- ],
685
- "CONTENT.HOME": {
686
- actions: ["highlightFirstItem"]
687
- },
688
- "CONTENT.END": {
689
- actions: ["highlightLastItem"]
690
- },
691
- "CONTENT.ARROW_DOWN": [
692
- {
693
- guard: O("hasHighlightedItem", "loop", "isLastItemHighlighted"),
694
- actions: ["highlightFirstItem"]
695
- },
696
- {
697
- guard: "hasHighlightedItem",
698
- actions: ["highlightNextItem"]
699
- },
700
- {
701
- actions: ["highlightFirstItem"]
702
- }
703
- ],
704
- "CONTENT.ARROW_UP": [
705
- {
706
- guard: O("hasHighlightedItem", "loop", "isFirstItemHighlighted"),
707
- actions: ["highlightLastItem"]
708
- },
709
- {
710
- guard: "hasHighlightedItem",
711
- actions: ["highlightPreviousItem"]
712
- },
713
- {
714
- actions: ["highlightLastItem"]
715
- }
716
- ],
717
- "CONTENT.TYPEAHEAD": {
718
- actions: ["highlightMatchingItem"]
719
- },
720
- "ITEM.POINTER_MOVE": {
721
- actions: ["highlightItem"]
722
- },
723
- "ITEM.POINTER_LEAVE": {
724
- actions: ["clearHighlightedItem"]
725
- },
726
- "POSITIONING.SET": {
727
- actions: ["reposition"]
728
- }
541
+ OPEN: [
542
+ {
543
+ guard: "isOpenControlled",
544
+ actions: ["invokeOnOpen"]
545
+ },
546
+ {
547
+ target: "open",
548
+ actions: ["setInitialFocus", "invokeOnOpen"]
729
549
  }
730
- }
550
+ ]
731
551
  }
732
552
  },
733
- {
734
- guards: {
735
- loop: (e) => !!e.loopFocus,
736
- multiple: (e) => !!e.multiple,
737
- hasSelectedItems: (e) => !!e.hasSelectedItems,
738
- hasHighlightedItem: (e) => e.highlightedValue != null,
739
- isFirstItemHighlighted: (e) => e.highlightedValue === e.collection.firstValue,
740
- isLastItemHighlighted: (e) => e.highlightedValue === e.collection.lastValue,
741
- closeOnSelect: (e, i) => !!(i.closeOnSelect ?? e.closeOnSelect),
742
- // guard assertions (for controlled mode)
743
- isOpenControlled: (e) => !!e["open.controlled"],
744
- isTriggerClickEvent: (e, i) => {
745
- var n;
746
- return ((n = i.previousEvent) == null ? void 0 : n.type) === "TRIGGER.CLICK";
747
- },
748
- isTriggerEnterEvent: (e, i) => {
749
- var n;
750
- return ((n = i.previousEvent) == null ? void 0 : n.type) === "TRIGGER.ENTER";
751
- },
752
- isTriggerArrowUpEvent: (e, i) => {
753
- var n;
754
- return ((n = i.previousEvent) == null ? void 0 : n.type) === "TRIGGER.ARROW_UP";
755
- },
756
- isTriggerArrowDownEvent: (e, i) => {
757
- var n;
758
- return ((n = i.previousEvent) == null ? void 0 : n.type) === "TRIGGER.ARROW_DOWN";
759
- }
760
- },
761
- activities: {
762
- trackFormControlState(e, i, { initialContext: n }) {
763
- return ee(r.getHiddenSelectEl(e), {
764
- onFieldsetDisabledChange(s) {
765
- e.fieldsetDisabled = s;
766
- },
767
- onFormReset() {
768
- g.selectedItems(e, n.value);
769
- }
770
- });
553
+ focused: {
554
+ tags: ["closed"],
555
+ on: {
556
+ "CONTROLLED.OPEN": [
557
+ {
558
+ guard: "isTriggerClickEvent",
559
+ target: "open",
560
+ actions: ["setInitialFocus", "highlightFirstSelectedItem"]
561
+ },
562
+ {
563
+ guard: "isTriggerArrowUpEvent",
564
+ target: "open",
565
+ actions: ["setInitialFocus", "highlightComputedLastItem"]
566
+ },
567
+ {
568
+ guard: Ce("isTriggerArrowDownEvent", "isTriggerEnterEvent"),
569
+ target: "open",
570
+ actions: ["setInitialFocus", "highlightComputedFirstItem"]
571
+ },
572
+ {
573
+ target: "open",
574
+ actions: ["setInitialFocus"]
575
+ }
576
+ ],
577
+ OPEN: [
578
+ {
579
+ guard: "isOpenControlled",
580
+ actions: ["invokeOnOpen"]
581
+ },
582
+ {
583
+ target: "open",
584
+ actions: ["setInitialFocus", "invokeOnOpen"]
585
+ }
586
+ ],
587
+ "TRIGGER.BLUR": {
588
+ target: "idle"
771
589
  },
772
- trackDismissableElement(e, i, { send: n }) {
773
- const s = () => r.getContentEl(e);
774
- let m = !0;
775
- return x(s, {
776
- defer: !0,
777
- exclude: [r.getTriggerEl(e), r.getClearTriggerEl(e)],
778
- onFocusOutside: e.onFocusOutside,
779
- onPointerDownOutside: e.onPointerDownOutside,
780
- onInteractOutside(h) {
781
- var I;
782
- (I = e.onInteractOutside) == null || I.call(e, h), m = !(h.detail.focusable || h.detail.contextmenu);
783
- },
784
- onDismiss() {
785
- n({ type: "CLOSE", src: "interact-outside", restoreFocus: m });
786
- }
787
- });
590
+ "TRIGGER.CLICK": [
591
+ {
592
+ guard: "isOpenControlled",
593
+ actions: ["invokeOnOpen"]
594
+ },
595
+ {
596
+ target: "open",
597
+ actions: ["setInitialFocus", "invokeOnOpen", "highlightFirstSelectedItem"]
598
+ }
599
+ ],
600
+ "TRIGGER.ENTER": [
601
+ {
602
+ guard: "isOpenControlled",
603
+ actions: ["invokeOnOpen"]
604
+ },
605
+ {
606
+ target: "open",
607
+ actions: ["setInitialFocus", "invokeOnOpen", "highlightComputedFirstItem"]
608
+ }
609
+ ],
610
+ "TRIGGER.ARROW_UP": [
611
+ {
612
+ guard: "isOpenControlled",
613
+ actions: ["invokeOnOpen"]
614
+ },
615
+ {
616
+ target: "open",
617
+ actions: ["setInitialFocus", "invokeOnOpen", "highlightComputedLastItem"]
618
+ }
619
+ ],
620
+ "TRIGGER.ARROW_DOWN": [
621
+ {
622
+ guard: "isOpenControlled",
623
+ actions: ["invokeOnOpen"]
624
+ },
625
+ {
626
+ target: "open",
627
+ actions: ["setInitialFocus", "invokeOnOpen", "highlightComputedFirstItem"]
628
+ }
629
+ ],
630
+ "TRIGGER.ARROW_LEFT": [
631
+ {
632
+ guard: C(v("multiple"), "hasSelectedItems"),
633
+ actions: ["selectPreviousItem"]
634
+ },
635
+ {
636
+ guard: v("multiple"),
637
+ actions: ["selectLastItem"]
638
+ }
639
+ ],
640
+ "TRIGGER.ARROW_RIGHT": [
641
+ {
642
+ guard: C(v("multiple"), "hasSelectedItems"),
643
+ actions: ["selectNextItem"]
644
+ },
645
+ {
646
+ guard: v("multiple"),
647
+ actions: ["selectFirstItem"]
648
+ }
649
+ ],
650
+ "TRIGGER.HOME": {
651
+ guard: v("multiple"),
652
+ actions: ["selectFirstItem"]
788
653
  },
789
- computePlacement(e) {
790
- return e.currentPlacement = e.positioning.placement, H(() => r.getTriggerEl(e), () => r.getPositionerEl(e), {
791
- defer: !0,
792
- ...e.positioning,
793
- onComplete(s) {
794
- e.currentPlacement = s.placement;
795
- }
796
- });
654
+ "TRIGGER.END": {
655
+ guard: v("multiple"),
656
+ actions: ["selectLastItem"]
797
657
  },
798
- scrollToHighlightedItem(e, i, { getState: n }) {
799
- const s = (h) => {
800
- if (e.highlightedValue == null || n().event.type.includes("POINTER")) return;
801
- const T = r.getHighlightedOptionEl(e), v = r.getContentEl(e);
802
- if (e.scrollToIndexFn) {
803
- const G = e.collection.indexOf(e.highlightedValue);
804
- e.scrollToIndexFn({ index: G, immediate: h });
805
- return;
806
- }
807
- q(T, { rootEl: v, block: "nearest" });
808
- };
809
- return y(() => s(!0)), Y(() => r.getContentEl(e), {
810
- defer: !0,
811
- attributes: ["data-activedescendant"],
812
- callback() {
813
- s(!1);
814
- }
815
- });
658
+ "TRIGGER.TYPEAHEAD": {
659
+ guard: v("multiple"),
660
+ actions: ["selectMatchingItem"]
816
661
  }
817
- },
818
- actions: {
819
- reposition(e, i) {
820
- const n = () => r.getPositionerEl(e);
821
- H(r.getTriggerEl(e), n, {
822
- ...e.positioning,
823
- ...i.options,
824
- defer: !0,
825
- listeners: !1,
826
- onComplete(s) {
827
- e.currentPlacement = s.placement;
828
- }
829
- });
830
- },
831
- toggleVisibility(e, i, { send: n }) {
832
- n({ type: e.open ? "CONTROLLED.OPEN" : "CONTROLLED.CLOSE", previousEvent: i });
833
- },
834
- highlightPreviousItem(e) {
835
- if (e.highlightedValue == null) return;
836
- const i = e.collection.getPreviousValue(e.highlightedValue);
837
- g.highlightedItem(e, i);
838
- },
839
- highlightNextItem(e) {
840
- if (e.highlightedValue == null) return;
841
- const i = e.collection.getNextValue(e.highlightedValue);
842
- g.highlightedItem(e, i);
843
- },
844
- highlightFirstItem(e) {
845
- const i = e.collection.firstValue;
846
- g.highlightedItem(e, i);
847
- },
848
- highlightLastItem(e) {
849
- const i = e.collection.lastValue;
850
- g.highlightedItem(e, i);
851
- },
852
- setInitialFocus(e) {
853
- y(() => {
854
- const i = B({
855
- root: r.getContentEl(e)
856
- });
857
- i == null || i.focus({ preventScroll: !0 });
858
- });
859
- },
860
- focusTriggerEl(e, i) {
861
- var s;
862
- const n = i.restoreFocus ?? ((s = i.previousEvent) == null ? void 0 : s.restoreFocus);
863
- n != null && !n || y(() => {
864
- const m = r.getTriggerEl(e);
865
- m == null || m.focus({ preventScroll: !0 });
866
- });
867
- },
868
- selectHighlightedItem(e, i) {
869
- let n = i.value ?? e.highlightedValue;
870
- if (n == null) return;
871
- const s = e.deselectable && !e.multiple && e.value.includes(n);
872
- n = s ? null : n, g.selectedItem(e, n, s);
873
- },
874
- highlightComputedFirstItem(e) {
875
- const i = e.hasSelectedItems ? e.collection.sort(e.value)[0] : e.collection.firstValue;
876
- g.highlightedItem(e, i);
877
- },
878
- highlightComputedLastItem(e) {
879
- const i = e.hasSelectedItems ? e.collection.sort(e.value)[0] : e.collection.lastValue;
880
- g.highlightedItem(e, i);
881
- },
882
- highlightFirstSelectedItem(e) {
883
- if (!e.hasSelectedItems) return;
884
- const [i] = e.collection.sort(e.value);
885
- g.highlightedItem(e, i);
886
- },
887
- highlightItem(e, i) {
888
- g.highlightedItem(e, i.value);
889
- },
890
- highlightMatchingItem(e, i) {
891
- const n = e.collection.search(i.key, {
892
- state: e.typeahead,
893
- currentValue: e.highlightedValue
894
- });
895
- n != null && g.highlightedItem(e, n);
896
- },
897
- setHighlightedItem(e, i) {
898
- g.highlightedItem(e, i.value);
899
- },
900
- clearHighlightedItem(e) {
901
- g.highlightedItem(e, null, !0);
902
- },
903
- selectItem(e, i) {
904
- const n = e.deselectable && !e.multiple && e.value.includes(i.value), s = n ? null : i.value;
905
- g.selectedItem(e, s, n);
906
- },
907
- clearItem(e, i) {
908
- const n = e.value.filter((s) => s !== i.value);
909
- g.selectedItems(e, n);
910
- },
911
- setSelectedItems(e, i) {
912
- g.selectedItems(e, i.value);
913
- },
914
- clearSelectedItems(e) {
915
- g.selectedItems(e, []);
916
- },
917
- selectPreviousItem(e) {
918
- const i = e.collection.getPreviousValue(e.value[0]);
919
- g.selectedItem(e, i);
920
- },
921
- selectNextItem(e) {
922
- const i = e.collection.getNextValue(e.value[0]);
923
- g.selectedItem(e, i);
924
- },
925
- selectFirstItem(e) {
926
- const i = e.collection.firstValue;
927
- g.selectedItem(e, i);
928
- },
929
- selectLastItem(e) {
930
- const i = e.collection.lastValue;
931
- g.selectedItem(e, i);
932
- },
933
- selectMatchingItem(e, i) {
934
- const n = e.collection.search(i.key, {
935
- state: e.typeahead,
936
- currentValue: e.value[0]
937
- });
938
- n != null && g.selectedItem(e, n);
939
- },
940
- scrollContentToTop(e) {
941
- var i;
942
- e.scrollToIndexFn ? e.scrollToIndexFn({ index: 0, immediate: !0 }) : (i = r.getContentEl(e)) == null || i.scrollTo(0, 0);
943
- },
944
- invokeOnOpen(e) {
945
- var i;
946
- (i = e.onOpenChange) == null || i.call(e, { open: !0 });
662
+ }
663
+ },
664
+ open: {
665
+ tags: ["open"],
666
+ exit: ["scrollContentToTop"],
667
+ effects: ["trackDismissableElement", "computePlacement", "scrollToHighlightedItem"],
668
+ on: {
669
+ "CONTROLLED.CLOSE": [
670
+ {
671
+ guard: "restoreFocus",
672
+ target: "focused",
673
+ actions: ["focusTriggerEl", "clearHighlightedItem"]
674
+ },
675
+ {
676
+ target: "idle",
677
+ actions: ["clearHighlightedItem"]
678
+ }
679
+ ],
680
+ CLOSE: [
681
+ {
682
+ guard: "isOpenControlled",
683
+ actions: ["invokeOnClose"]
684
+ },
685
+ {
686
+ guard: "restoreFocus",
687
+ target: "focused",
688
+ actions: ["invokeOnClose", "focusTriggerEl", "clearHighlightedItem"]
689
+ },
690
+ {
691
+ target: "idle",
692
+ actions: ["invokeOnClose", "clearHighlightedItem"]
693
+ }
694
+ ],
695
+ "TRIGGER.CLICK": [
696
+ {
697
+ guard: "isOpenControlled",
698
+ actions: ["invokeOnClose"]
699
+ },
700
+ {
701
+ target: "focused",
702
+ actions: ["invokeOnClose", "clearHighlightedItem"]
703
+ }
704
+ ],
705
+ "ITEM.CLICK": [
706
+ {
707
+ guard: C("closeOnSelect", "isOpenControlled"),
708
+ actions: ["selectHighlightedItem", "invokeOnClose"]
709
+ },
710
+ {
711
+ guard: "closeOnSelect",
712
+ target: "focused",
713
+ actions: ["selectHighlightedItem", "invokeOnClose", "focusTriggerEl", "clearHighlightedItem"]
714
+ },
715
+ {
716
+ actions: ["selectHighlightedItem"]
717
+ }
718
+ ],
719
+ "CONTENT.HOME": {
720
+ actions: ["highlightFirstItem"]
947
721
  },
948
- invokeOnClose(e) {
949
- var i;
950
- (i = e.onOpenChange) == null || i.call(e, { open: !1 });
722
+ "CONTENT.END": {
723
+ actions: ["highlightLastItem"]
951
724
  },
952
- syncSelectElement(e) {
953
- const i = r.getHiddenSelectEl(e);
954
- if (i) {
955
- if (e.value.length === 0 && !e.multiple) {
956
- i.selectedIndex = -1;
957
- return;
958
- }
959
- for (const n of i.options)
960
- n.selected = e.value.includes(n.value);
725
+ "CONTENT.ARROW_DOWN": [
726
+ {
727
+ guard: C("hasHighlightedItem", "loop", "isLastItemHighlighted"),
728
+ actions: ["highlightFirstItem"]
729
+ },
730
+ {
731
+ guard: "hasHighlightedItem",
732
+ actions: ["highlightNextItem"]
733
+ },
734
+ {
735
+ actions: ["highlightFirstItem"]
961
736
  }
737
+ ],
738
+ "CONTENT.ARROW_UP": [
739
+ {
740
+ guard: C("hasHighlightedItem", "loop", "isFirstItemHighlighted"),
741
+ actions: ["highlightLastItem"]
742
+ },
743
+ {
744
+ guard: "hasHighlightedItem",
745
+ actions: ["highlightPreviousItem"]
746
+ },
747
+ {
748
+ actions: ["highlightLastItem"]
749
+ }
750
+ ],
751
+ "CONTENT.TYPEAHEAD": {
752
+ actions: ["highlightMatchingItem"]
962
753
  },
963
- setCollection(e, i) {
964
- e.collection = i.value;
965
- },
966
- syncCollection(e) {
967
- const i = e.collection.findMany(e.value), n = e.collection.stringifyItems(i);
968
- e.highlightedItem = e.collection.find(e.highlightedValue), e.selectedItems = i, e.valueAsString = n;
754
+ "ITEM.POINTER_MOVE": {
755
+ actions: ["highlightItem"]
969
756
  },
970
- syncSelectedItems(e) {
971
- b.valueChange(e);
757
+ "ITEM.POINTER_LEAVE": {
758
+ actions: ["clearHighlightedItem"]
972
759
  },
973
- syncHighlightedItem(e) {
974
- b.highlightChange(e);
760
+ "POSITIONING.SET": {
761
+ actions: ["reposition"]
975
762
  }
976
763
  }
977
764
  }
978
- );
979
- }
980
- function ne(t) {
981
- y(() => {
982
- const l = r.getHiddenSelectEl(t);
983
- if (!l) return;
984
- const e = r.getWin(t), i = new e.Event("change", { bubbles: !0, composed: !0 });
985
- l.dispatchEvent(i);
986
- });
987
- }
988
- var b = {
989
- valueChange: (t) => {
990
- const l = t.selectedItems;
991
- t.selectedItems = t.value.map((e) => {
992
- const i = l.find((n) => t.collection.getItemValue(n) === e);
993
- return i || t.collection.find(e);
994
- }), t.valueAsString = t.collection.stringifyItems(t.selectedItems);
995
765
  },
996
- highlightChange: (t) => {
997
- t.highlightedItem = t.collection.find(t.highlightedValue);
998
- }
999
- }, R = {
1000
- valueChange: (t) => {
1001
- var l;
1002
- b.valueChange(t), (l = t.onValueChange) == null || l.call(t, {
1003
- value: Array.from(t.value),
1004
- items: Array.from(t.selectedItems)
1005
- }), ne(t);
1006
- },
1007
- highlightChange: (t) => {
1008
- var l;
1009
- b.highlightChange(t), (l = t.onHighlightChange) == null || l.call(t, {
1010
- highlightedValue: t.highlightedValue,
1011
- highlightedItem: t.highlightedItem,
1012
- highlightedIndex: t.collection.indexOf(t.highlightedValue)
1013
- });
1014
- }
1015
- }, g = {
1016
- selectedItem: (t, l, e = !1) => {
1017
- if (!P(t.value, l) && !(l == null && !e)) {
1018
- if (l == null && e) {
1019
- t.value = [], R.valueChange(t);
1020
- return;
766
+ implementations: {
767
+ guards: {
768
+ loop: ({ prop: e }) => !!e("loopFocus"),
769
+ multiple: ({ prop: e }) => !!e("multiple"),
770
+ hasSelectedItems: ({ computed: e }) => !!e("hasSelectedItems"),
771
+ hasHighlightedItem: ({ context: e }) => e.get("highlightedValue") != null,
772
+ isFirstItemHighlighted: ({ context: e, prop: t }) => e.get("highlightedValue") === t("collection").firstValue,
773
+ isLastItemHighlighted: ({ context: e, prop: t }) => e.get("highlightedValue") === t("collection").lastValue,
774
+ closeOnSelect: ({ prop: e, event: t }) => !!(t.closeOnSelect ?? e("closeOnSelect")),
775
+ restoreFocus: ({ event: e }) => j(e),
776
+ // guard assertions (for controlled mode)
777
+ isOpenControlled: ({ prop: e }) => e("open") !== void 0,
778
+ isTriggerClickEvent: ({ event: e }) => {
779
+ var t;
780
+ return ((t = e.previousEvent) == null ? void 0 : t.type) === "TRIGGER.CLICK";
781
+ },
782
+ isTriggerEnterEvent: ({ event: e }) => {
783
+ var t;
784
+ return ((t = e.previousEvent) == null ? void 0 : t.type) === "TRIGGER.ENTER";
785
+ },
786
+ isTriggerArrowUpEvent: ({ event: e }) => {
787
+ var t;
788
+ return ((t = e.previousEvent) == null ? void 0 : t.type) === "TRIGGER.ARROW_UP";
789
+ },
790
+ isTriggerArrowDownEvent: ({ event: e }) => {
791
+ var t;
792
+ return ((t = e.previousEvent) == null ? void 0 : t.type) === "TRIGGER.ARROW_DOWN";
793
+ }
794
+ },
795
+ effects: {
796
+ trackFormControlState({ context: e, scope: t }) {
797
+ return ne(k(t), {
798
+ onFieldsetDisabledChange(i) {
799
+ e.set("fieldsetDisabled", i);
800
+ },
801
+ onFormReset() {
802
+ const i = e.initial("value");
803
+ e.set("value", i);
804
+ }
805
+ });
806
+ },
807
+ trackDismissableElement({ scope: e, send: t, prop: i }) {
808
+ const l = () => R(e);
809
+ let a = !0;
810
+ return Ee(l, {
811
+ defer: !0,
812
+ exclude: [f(e), ye(e)],
813
+ onFocusOutside: i("onFocusOutside"),
814
+ onPointerDownOutside: i("onPointerDownOutside"),
815
+ onInteractOutside(d) {
816
+ var c;
817
+ (c = i("onInteractOutside")) == null || c(d), a = !(d.detail.focusable || d.detail.contextmenu);
818
+ },
819
+ onDismiss() {
820
+ t({ type: "CLOSE", src: "interact-outside", restoreFocus: a });
821
+ }
822
+ });
823
+ },
824
+ computePlacement({ context: e, prop: t, scope: i }) {
825
+ const l = t("positioning");
826
+ return e.set("currentPlacement", l.placement), K(() => f(i), () => q(i), {
827
+ defer: !0,
828
+ ...l,
829
+ onComplete(c) {
830
+ e.set("currentPlacement", c.placement);
831
+ }
832
+ });
833
+ },
834
+ scrollToHighlightedItem({ context: e, prop: t, scope: i, event: l }) {
835
+ const a = (c) => {
836
+ const o = e.get("highlightedValue");
837
+ if (o == null || l.current().type.includes("POINTER")) return;
838
+ const g = Re(i, o), m = R(i), I = t("scrollToIndexFn");
839
+ if (I) {
840
+ const p = t("collection").indexOf(o);
841
+ I == null || I({ index: p, immediate: c });
842
+ return;
843
+ }
844
+ ae(g, { rootEl: m, block: "nearest" });
845
+ };
846
+ return N(() => a(!0)), le(() => R(i), {
847
+ defer: !0,
848
+ attributes: ["data-activedescendant"],
849
+ callback() {
850
+ a(!1);
851
+ }
852
+ });
853
+ }
854
+ },
855
+ actions: {
856
+ reposition({ context: e, prop: t, scope: i, event: l }) {
857
+ const a = () => q(i);
858
+ K(f(i), a, {
859
+ ...t("positioning"),
860
+ ...l.options,
861
+ defer: !0,
862
+ listeners: !1,
863
+ onComplete(d) {
864
+ e.set("currentPlacement", d.placement);
865
+ }
866
+ });
867
+ },
868
+ toggleVisibility({ send: e, prop: t, event: i }) {
869
+ e({ type: t("open") ? "CONTROLLED.OPEN" : "CONTROLLED.CLOSE", previousEvent: i });
870
+ },
871
+ highlightPreviousItem({ context: e, prop: t }) {
872
+ const i = e.get("highlightedValue");
873
+ if (i == null) return;
874
+ const l = t("collection").getPreviousValue(i, 1, t("loopFocus"));
875
+ l != null && e.set("highlightedValue", l);
876
+ },
877
+ highlightNextItem({ context: e, prop: t }) {
878
+ const i = e.get("highlightedValue");
879
+ if (i == null) return;
880
+ const l = t("collection").getNextValue(i, 1, t("loopFocus"));
881
+ l != null && e.set("highlightedValue", l);
882
+ },
883
+ highlightFirstItem({ context: e, prop: t }) {
884
+ const i = t("collection").firstValue;
885
+ e.set("highlightedValue", i);
886
+ },
887
+ highlightLastItem({ context: e, prop: t }) {
888
+ const i = t("collection").lastValue;
889
+ e.set("highlightedValue", i);
890
+ },
891
+ setInitialFocus({ scope: e }) {
892
+ N(() => {
893
+ const t = ie({
894
+ root: R(e)
895
+ });
896
+ t == null || t.focus({ preventScroll: !0 });
897
+ });
898
+ },
899
+ focusTriggerEl({ event: e, scope: t }) {
900
+ j(e) && N(() => {
901
+ const i = f(t);
902
+ i == null || i.focus({ preventScroll: !0 });
903
+ });
904
+ },
905
+ selectHighlightedItem({ context: e, prop: t, event: i }) {
906
+ var d;
907
+ let l = i.value ?? e.get("highlightedValue");
908
+ if (l == null) return;
909
+ (d = t("onSelect")) == null || d({ value: l }), l = t("deselectable") && !t("multiple") && e.get("value").includes(l) ? null : l, e.set("value", (c) => l == null ? [] : t("multiple") ? B(c, l) : [l]);
910
+ },
911
+ highlightComputedFirstItem({ context: e, prop: t, computed: i }) {
912
+ const l = t("collection"), a = i("hasSelectedItems") ? l.sort(e.get("value"))[0] : l.firstValue;
913
+ e.set("highlightedValue", a);
914
+ },
915
+ highlightComputedLastItem({ context: e, prop: t, computed: i }) {
916
+ const l = t("collection"), a = i("hasSelectedItems") ? l.sort(e.get("value"))[0] : l.lastValue;
917
+ e.set("highlightedValue", a);
918
+ },
919
+ highlightFirstSelectedItem({ context: e, prop: t, computed: i }) {
920
+ if (!i("hasSelectedItems")) return;
921
+ const l = t("collection").sort(e.get("value"))[0];
922
+ e.set("highlightedValue", l);
923
+ },
924
+ highlightItem({ context: e, event: t }) {
925
+ e.set("highlightedValue", t.value);
926
+ },
927
+ highlightMatchingItem({ context: e, prop: t, event: i, refs: l }) {
928
+ const a = t("collection").search(i.key, {
929
+ state: l.get("typeahead"),
930
+ currentValue: e.get("highlightedValue")
931
+ });
932
+ a != null && e.set("highlightedValue", a);
933
+ },
934
+ setHighlightedItem({ context: e, event: t }) {
935
+ e.set("highlightedValue", t.value);
936
+ },
937
+ clearHighlightedItem({ context: e }) {
938
+ e.set("highlightedValue", null);
939
+ },
940
+ selectItem({ context: e, prop: t, event: i }) {
941
+ var d;
942
+ (d = t("onSelect")) == null || d({ value: i.value });
943
+ const a = t("deselectable") && !t("multiple") && e.get("value").includes(i.value) ? null : i.value;
944
+ e.set("value", (c) => a == null ? [] : t("multiple") ? B(c, a) : [a]);
945
+ },
946
+ clearItem({ context: e, event: t }) {
947
+ e.set("value", (i) => i.filter((l) => l !== t.value));
948
+ },
949
+ setSelectedItems({ context: e, event: t }) {
950
+ e.set("value", t.value);
951
+ },
952
+ clearSelectedItems({ context: e }) {
953
+ e.set("value", []);
954
+ },
955
+ selectPreviousItem({ context: e, prop: t }) {
956
+ const [i] = e.get("value"), l = t("collection").getPreviousValue(i);
957
+ l && e.set("value", [l]);
958
+ },
959
+ selectNextItem({ context: e, prop: t }) {
960
+ const [i] = e.get("value"), l = t("collection").getNextValue(i);
961
+ l && e.set("value", [l]);
962
+ },
963
+ selectFirstItem({ context: e, prop: t }) {
964
+ const i = t("collection").firstValue;
965
+ i && e.set("value", [i]);
966
+ },
967
+ selectLastItem({ context: e, prop: t }) {
968
+ const i = t("collection").lastValue;
969
+ i && e.set("value", [i]);
970
+ },
971
+ selectMatchingItem({ context: e, prop: t, event: i, refs: l }) {
972
+ const a = t("collection").search(i.key, {
973
+ state: l.get("typeahead"),
974
+ currentValue: e.get("value")[0]
975
+ });
976
+ a != null && e.set("value", [a]);
977
+ },
978
+ scrollContentToTop({ prop: e, scope: t }) {
979
+ var i, l;
980
+ e("scrollToIndexFn") ? (i = e("scrollToIndexFn")) == null || i({ index: 0, immediate: !0 }) : (l = R(t)) == null || l.scrollTo(0, 0);
981
+ },
982
+ invokeOnOpen({ prop: e }) {
983
+ var t;
984
+ (t = e("onOpenChange")) == null || t({ open: !0 });
985
+ },
986
+ invokeOnClose({ prop: e }) {
987
+ var t;
988
+ (t = e("onOpenChange")) == null || t({ open: !1 });
989
+ },
990
+ syncSelectElement({ context: e, prop: t, scope: i }) {
991
+ const l = k(i);
992
+ if (l) {
993
+ if (e.get("value").length === 0 && !t("multiple")) {
994
+ l.selectedIndex = -1;
995
+ return;
996
+ }
997
+ for (const a of l.options)
998
+ a.selected = e.get("value").includes(a.value);
999
+ }
1000
+ },
1001
+ syncCollection({ context: e, prop: t }) {
1002
+ const i = t("collection"), l = i.find(e.get("highlightedValue"));
1003
+ l && e.set("highlightedItem", l);
1004
+ const a = i.findMany(e.get("value"));
1005
+ e.set("selectedItems", a);
1006
+ const d = i.stringifyItems(a);
1007
+ e.set("valueAsString", d);
1008
+ },
1009
+ syncSelectedItems({ context: e, prop: t }) {
1010
+ const i = t("collection"), l = e.get("selectedItems"), d = e.get("value").map((c) => l.find((g) => i.getItemValue(g) === c) || i.find(c));
1011
+ e.set("selectedItems", d), e.set("valueAsString", i.stringifyItems(d));
1012
+ },
1013
+ syncHighlightedItem({ context: e, prop: t }) {
1014
+ const i = t("collection"), l = e.get("highlightedValue"), a = l ? i.find(l) : null;
1015
+ e.set("highlightedItem", a);
1016
+ },
1017
+ dispatchChangeEvent({ scope: e }) {
1018
+ queueMicrotask(() => {
1019
+ const t = k(e);
1020
+ if (!t) return;
1021
+ const i = e.getWin(), l = new i.Event("change", { bubbles: !0, composed: !0 });
1022
+ t.dispatchEvent(l);
1023
+ });
1021
1024
  }
1022
- t.value = t.multiple ? ie(t.value, l) : [l], R.valueChange(t);
1023
1025
  }
1024
- },
1025
- selectedItems: (t, l) => {
1026
- P(t.value, l) || (t.value = l, R.valueChange(t));
1027
- },
1028
- highlightedItem: (t, l, e = !1) => {
1029
- P(t.highlightedValue, l) || l == null && !e || (t.highlightedValue = l ?? null, R.highlightChange(t));
1030
1026
  }
1031
- };
1032
- S()([
1027
+ });
1028
+ function j(e) {
1029
+ var i;
1030
+ const t = e.restoreFocus ?? ((i = e.previousEvent) == null ? void 0 : i.restoreFocus);
1031
+ return t == null || !!t;
1032
+ }
1033
+ G()([
1033
1034
  "closeOnSelect",
1034
1035
  "collection",
1036
+ "composite",
1037
+ "defaultHighlightedValue",
1038
+ "defaultOpen",
1039
+ "defaultValue",
1040
+ "deselectable",
1035
1041
  "dir",
1036
1042
  "disabled",
1037
- "deselectable",
1038
1043
  "form",
1039
1044
  "getRootNode",
1040
1045
  "highlightedValue",
@@ -1049,22 +1054,21 @@ S()([
1049
1054
  "onInteractOutside",
1050
1055
  "onOpenChange",
1051
1056
  "onPointerDownOutside",
1057
+ "onSelect",
1052
1058
  "onValueChange",
1053
- "open.controlled",
1054
1059
  "open",
1055
- "composite",
1056
1060
  "positioning",
1057
- "required",
1058
1061
  "readOnly",
1062
+ "required",
1059
1063
  "scrollToIndexFn",
1060
1064
  "value"
1061
1065
  ]);
1062
- S()(["item", "persistFocus"]);
1063
- S()(["id"]);
1064
- S()(["htmlFor"]);
1066
+ G()(["item", "persistFocus"]);
1067
+ G()(["id"]);
1068
+ G()(["htmlFor"]);
1065
1069
  export {
1066
- le as anatomy,
1067
- _ as collection,
1068
- Ee as connect,
1069
- ve as machine
1070
+ ve as anatomy,
1071
+ Q as collection,
1072
+ Ne as connect,
1073
+ ke as machine
1070
1074
  };