@serendie/ui 2.1.3 → 2.2.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 (122) hide show
  1. package/dist/client.js +79 -74
  2. package/dist/components/Accordion/Accordion.d.ts +1 -1
  3. package/dist/components/Avatar/Avatar.d.ts +1 -1
  4. package/dist/components/Banner/Banner.d.ts +1 -1
  5. package/dist/components/BottomNavigation/BottomNavigationItem.d.ts +1 -1
  6. package/dist/components/Button/Button.d.ts +2 -2
  7. package/dist/components/Button/Button.js +22 -21
  8. package/dist/components/DatePicker/DatePicker.d.ts +13 -0
  9. package/dist/components/DatePicker/DatePicker.js +203 -0
  10. package/dist/components/DatePicker/index.d.ts +2 -0
  11. package/dist/components/DatePicker/index.js +6 -0
  12. package/dist/components/DatePicker/parseDate.d.ts +1 -0
  13. package/dist/components/DatePicker/styles.d.ts +1 -0
  14. package/dist/components/DatePicker/styles.js +224 -0
  15. package/dist/components/IconButton/IconButton.d.ts +3 -3
  16. package/dist/components/List/ListItem.d.ts +1 -1
  17. package/dist/components/ModalDialog/ModalDialog.d.ts +1 -1
  18. package/dist/components/NotificationBadge/NotificationBadge.d.ts +1 -1
  19. package/dist/components/Pagination/Pagination.d.ts +1 -1
  20. package/dist/components/ProgressIndicator/AnimatedArc.d.ts +6 -0
  21. package/dist/components/ProgressIndicator/AnimatedArc.js +46 -0
  22. package/dist/components/ProgressIndicator/ProgressIndicator.d.ts +11 -29
  23. package/dist/components/ProgressIndicator/ProgressIndicator.js +201 -43
  24. package/dist/components/ProgressIndicator/ProgressIndicatorIndeterminate.d.ts +10 -0
  25. package/dist/components/ProgressIndicator/ProgressIndicatorIndeterminate.js +215 -0
  26. package/dist/components/ProgressIndicator/index.d.ts +4 -1
  27. package/dist/components/ProgressIndicator/index.js +3 -2
  28. package/dist/components/ProgressIndicator/util.d.ts +1 -0
  29. package/dist/components/ProgressIndicator/util.js +13 -0
  30. package/dist/components/Search/Search.d.ts +1 -1
  31. package/dist/components/Select/Select.d.ts +1 -1
  32. package/dist/components/Switch/Switch.d.ts +1 -1
  33. package/dist/components/Tabs/Tabs.d.ts +1 -1
  34. package/dist/components/TextField/TextField.js +59 -156
  35. package/dist/components/Toast/Toast.d.ts +1 -1
  36. package/dist/components/TopAppBar/TopAppBar.d.ts +1 -1
  37. package/dist/index.d.ts +1 -0
  38. package/dist/index.js +80 -75
  39. package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-content.js +15 -0
  40. package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-context.js +5 -0
  41. package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-control.js +13 -0
  42. package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-input.js +14 -0
  43. package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-label.js +13 -0
  44. package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-month-select.js +13 -0
  45. package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-next-trigger.js +14 -0
  46. package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-positioner.js +14 -0
  47. package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-prev-trigger.js +14 -0
  48. package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-root.js +55 -0
  49. package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-table-body.js +14 -0
  50. package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-table-cell-trigger.js +19 -0
  51. package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-table-cell.js +26 -0
  52. package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-table-head.js +14 -0
  53. package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-table-header.js +14 -0
  54. package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-table-row.js +14 -0
  55. package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-table.js +16 -0
  56. package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-trigger.js +13 -0
  57. package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-view-control.js +14 -0
  58. package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-view.js +23 -0
  59. package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-year-select.js +13 -0
  60. package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker.anatomy.js +5 -0
  61. package/dist/node_modules/@ark-ui/react/dist/components/date-picker/use-date-picker-context.js +10 -0
  62. package/dist/node_modules/@ark-ui/react/dist/components/date-picker/use-date-picker-table-cell-props-context.js +10 -0
  63. package/dist/node_modules/@ark-ui/react/dist/components/date-picker/use-date-picker-table-props-context.js +10 -0
  64. package/dist/node_modules/@ark-ui/react/dist/components/date-picker/use-date-picker-view-props-context.js +12 -0
  65. package/dist/node_modules/@ark-ui/react/dist/components/date-picker/use-date-picker.js +18 -0
  66. package/dist/node_modules/@ark-ui/react/dist/components/factory.js +11 -12
  67. package/dist/node_modules/@ark-ui/react/dist/components/menu/menu-root.js +5 -4
  68. package/dist/node_modules/@ark-ui/react/dist/utils/use-event.js +0 -1
  69. package/dist/node_modules/@floating-ui/core/dist/floating-ui.core.js +36 -36
  70. package/dist/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +238 -235
  71. package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +88 -83
  72. package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +68 -67
  73. package/dist/node_modules/@internationalized/date/dist/CalendarDate.js +178 -0
  74. package/dist/node_modules/@internationalized/date/dist/DateFormatter.js +99 -0
  75. package/dist/node_modules/@internationalized/date/dist/GregorianCalendar.js +98 -0
  76. package/dist/node_modules/@internationalized/date/dist/conversion.js +135 -0
  77. package/dist/node_modules/@internationalized/date/dist/manipulation.js +205 -0
  78. package/dist/node_modules/@internationalized/date/dist/queries.js +202 -0
  79. package/dist/node_modules/@internationalized/date/dist/string.js +41 -0
  80. package/dist/node_modules/@internationalized/date/dist/utils.js +6 -0
  81. package/dist/node_modules/@internationalized/date/dist/weekStartData.js +100 -0
  82. package/dist/node_modules/@swc/helpers/esm/_check_private_redeclaration.js +7 -0
  83. package/dist/node_modules/@swc/helpers/esm/_class_private_field_init.js +7 -0
  84. package/dist/node_modules/@zag-js/anatomy/dist/index.js +15 -14
  85. package/dist/node_modules/@zag-js/aria-hidden/dist/index.js +23 -23
  86. package/dist/node_modules/@zag-js/collection/dist/index.js +102 -71
  87. package/dist/node_modules/@zag-js/combobox/dist/index.js +482 -426
  88. package/dist/node_modules/@zag-js/date-picker/dist/index.js +1826 -0
  89. package/dist/node_modules/@zag-js/date-utils/dist/index.js +366 -0
  90. package/dist/node_modules/@zag-js/dialog/dist/index.js +66 -64
  91. package/dist/node_modules/@zag-js/dismissable/dist/index.js +94 -69
  92. package/dist/node_modules/@zag-js/dom-query/dist/index.js +359 -300
  93. package/dist/node_modules/@zag-js/live-region/dist/index.js +39 -0
  94. package/dist/node_modules/@zag-js/menu/dist/index.js +357 -340
  95. package/dist/node_modules/@zag-js/popper/dist/index.js +123 -120
  96. package/dist/node_modules/@zag-js/presence/dist/index.js +17 -17
  97. package/dist/node_modules/@zag-js/radio-group/dist/index.js +118 -117
  98. package/dist/node_modules/@zag-js/react/dist/index.js +124 -121
  99. package/dist/node_modules/@zag-js/select/dist/index.js +211 -197
  100. package/dist/node_modules/@zag-js/toast/dist/index.js +73 -71
  101. package/dist/node_modules/@zag-js/tooltip/dist/index.js +31 -30
  102. package/dist/node_modules/@zag-js/utils/dist/index.js +150 -104
  103. package/dist/preset.d.ts +11 -1
  104. package/dist/recipes/index.d.ts +3 -2
  105. package/dist/recipes/index.js +5 -2
  106. package/dist/recipes/textFieldRecipe.d.ts +6 -0
  107. package/dist/recipes/textFieldRecipe.js +107 -0
  108. package/dist/styled-system/css/cva.js +43 -38
  109. package/dist/styled-system/recipes/create-recipe.js +37 -0
  110. package/dist/styled-system/recipes/text-field-recipe.js +61 -0
  111. package/dist/styles.css +1 -1
  112. package/dist/tokens/keyframes/index.d.ts +8 -0
  113. package/dist/tokens/keyframes/index.js +6 -2
  114. package/package.json +3 -3
  115. package/styled-system/recipes/create-recipe.js +82 -0
  116. package/styled-system/recipes/index.d.ts +2 -0
  117. package/styled-system/recipes/index.js +1 -0
  118. package/styled-system/recipes/text-field-recipe.d.ts +28 -0
  119. package/styled-system/recipes/text-field-recipe.js +72 -0
  120. package/styled-system/types/prop-type.d.ts +1 -1
  121. package/dist/node_modules/@zag-js/store/dist/index.js +0 -131
  122. package/dist/node_modules/proxy-compare/dist/index.js +0 -7
@@ -1,13 +1,13 @@
1
- import { createAnatomy as ce } from "../../anatomy/dist/index.js";
2
- import { ListCollection as ee } from "../../collection/dist/index.js";
3
- import { raf as f, setCaretToEnd as ge, observeAttributes as de, observeChildren as he, clickIfLink as Ie, dataAttr as u, ariaAttr as K, isDownloadingEvent as pe, isOpeningInNewTab as me, isContextMenuEvent as Ce, isLeftClick as U, getEventKey as $, isComposingEvent as fe, isAnchorElement as Oe, query as ve, scrollIntoView as Ee } from "../../dom-query/dist/index.js";
4
- import { getPlacement as q, getPlacementStyles as Ve } from "../../popper/dist/index.js";
5
- import { match as D, remove as Te, addOrRemove as Y, isBoolean as ye, isEqual as Pe, ensure as Se } from "../../utils/dist/index.js";
6
- import { ariaHidden as Ne } from "../../aria-hidden/dist/index.js";
7
- import { setup as be } from "../../core/dist/index.js";
8
- import { trackDismissableElement as ke } from "../../dismissable/dist/index.js";
1
+ import { createAnatomy as ge } from "../../anatomy/dist/index.js";
2
+ import { ListCollection as ie } from "../../collection/dist/index.js";
3
+ import { raf as V, setCaretToEnd as de, nextTick as he, observeAttributes as pe, clickIfLink as me, dataAttr as c, ariaAttr as K, isDownloadingEvent as Ie, isOpeningInNewTab as Ce, isContextMenuEvent as ve, isLeftClick as D, getEventKey as $, isComposingEvent as fe, query as Oe, isAnchorElement as Ve, scrollIntoView as q } from "../../dom-query/dist/index.js";
4
+ import { getPlacement as Y, getPlacementStyles as Ee } from "../../popper/dist/index.js";
5
+ import { match as P, remove as Te, addOrRemove as j, isBoolean as ye, isEqual as Pe, ensure as ke } from "../../utils/dist/index.js";
6
+ import { ariaHidden as Le } from "../../aria-hidden/dist/index.js";
7
+ import { setup as Se } from "../../core/dist/index.js";
8
+ import { trackDismissableElement as be } from "../../dismissable/dist/index.js";
9
9
  import { createProps as G } from "../../types/dist/index.js";
10
- var Le = ce("combobox").parts(
10
+ var Ne = ge("combobox").parts(
11
11
  "root",
12
12
  "clearTrigger",
13
13
  "content",
@@ -22,15 +22,15 @@ var Le = ce("combobox").parts(
22
22
  "list",
23
23
  "positioner",
24
24
  "trigger"
25
- ), p = Le.build(), te = (e) => new ee(e);
26
- te.empty = () => new ee({ items: [] });
25
+ ), C = Ne.build(), le = (e) => new ie(e);
26
+ le.empty = () => new ie({ items: [] });
27
27
  var Fe = (e) => {
28
28
  var t;
29
29
  return ((t = e.ids) == null ? void 0 : t.root) ?? `combobox:${e.id}`;
30
30
  }, B = (e) => {
31
31
  var t;
32
32
  return ((t = e.ids) == null ? void 0 : t.label) ?? `combobox:${e.id}:label`;
33
- }, ie = (e) => {
33
+ }, ne = (e) => {
34
34
  var t;
35
35
  return ((t = e.ids) == null ? void 0 : t.control) ?? `combobox:${e.id}:control`;
36
36
  }, M = (e) => {
@@ -39,364 +39,367 @@ var Fe = (e) => {
39
39
  }, w = (e) => {
40
40
  var t;
41
41
  return ((t = e.ids) == null ? void 0 : t.content) ?? `combobox:${e.id}:content`;
42
- }, ne = (e) => {
42
+ }, oe = (e) => {
43
43
  var t;
44
44
  return ((t = e.ids) == null ? void 0 : t.positioner) ?? `combobox:${e.id}:popper`;
45
- }, le = (e) => {
45
+ }, ae = (e) => {
46
46
  var t;
47
47
  return ((t = e.ids) == null ? void 0 : t.trigger) ?? `combobox:${e.id}:toggle-btn`;
48
- }, oe = (e) => {
48
+ }, se = (e) => {
49
49
  var t;
50
50
  return ((t = e.ids) == null ? void 0 : t.clearTrigger) ?? `combobox:${e.id}:clear-btn`;
51
- }, Ae = (e, t) => {
52
- var i, n;
53
- return ((n = (i = e.ids) == null ? void 0 : i.itemGroup) == null ? void 0 : n.call(i, t)) ?? `combobox:${e.id}:optgroup:${t}`;
54
- }, j = (e, t) => {
55
- var i, n;
56
- return ((n = (i = e.ids) == null ? void 0 : i.itemGroupLabel) == null ? void 0 : n.call(i, t)) ?? `combobox:${e.id}:optgroup-label:${t}`;
51
+ }, He = (e, t) => {
52
+ var i, l;
53
+ return ((l = (i = e.ids) == null ? void 0 : i.itemGroup) == null ? void 0 : l.call(i, t)) ?? `combobox:${e.id}:optgroup:${t}`;
57
54
  }, J = (e, t) => {
58
- var i, n;
59
- return ((n = (i = e.ids) == null ? void 0 : i.item) == null ? void 0 : n.call(i, t)) ?? `combobox:${e.id}:option:${t}`;
60
- }, T = (e) => e.getById(w(e)), y = (e) => e.getById(M(e)), Q = (e) => e.getById(ne(e)), X = (e) => e.getById(ie(e)), L = (e) => e.getById(le(e)), Z = (e) => e.getById(oe(e)), ae = (e, t) => {
61
- if (t == null) return;
55
+ var i, l;
56
+ return ((l = (i = e.ids) == null ? void 0 : i.itemGroupLabel) == null ? void 0 : l.call(i, t)) ?? `combobox:${e.id}:optgroup-label:${t}`;
57
+ }, Q = (e, t) => {
58
+ var i, l;
59
+ return ((l = (i = e.ids) == null ? void 0 : i.item) == null ? void 0 : l.call(i, t)) ?? `combobox:${e.id}:option:${t}`;
60
+ }, k = (e) => e.getById(w(e)), L = (e) => e.getById(M(e)), X = (e) => e.getById(oe(e)), Z = (e) => e.getById(ne(e)), H = (e) => e.getById(ae(e)), z = (e) => e.getById(se(e)), F = (e, t) => {
61
+ if (t == null) return null;
62
62
  const i = `[role=option][data-value="${CSS.escape(t)}"]`;
63
- return ve(T(e), i);
64
- }, z = (e) => {
65
- const t = y(e);
63
+ return Oe(k(e), i);
64
+ }, ee = (e) => {
65
+ const t = L(e);
66
66
  e.isActiveElement(t) || t == null || t.focus({ preventScroll: !0 });
67
67
  }, Re = (e) => {
68
- const t = L(e);
68
+ const t = H(e);
69
69
  e.isActiveElement(t) || t == null || t.focus({ preventScroll: !0 });
70
70
  };
71
- function Ye(e, t) {
72
- const { context: i, prop: n, state: o, send: a, scope: r, computed: C, event: k } = e, O = n("translations"), E = n("collection"), I = n("disabled"), P = C("isInteractive"), v = n("invalid"), S = n("readOnly"), d = o.hasTag("open"), F = o.hasTag("focused"), N = n("composite"), b = i.get("highlightedValue"), se = Ve({
73
- ...n("positioning"),
71
+ function qe(e, t) {
72
+ const { context: i, prop: l, state: n, send: o, scope: s, computed: u, event: E } = e, I = l("translations"), f = l("collection"), m = l("disabled"), T = u("isInteractive"), O = l("invalid"), N = l("readOnly"), h = n.hasTag("open"), R = n.hasTag("focused"), S = l("composite"), b = i.get("highlightedValue"), re = Ee({
73
+ ...l("positioning"),
74
74
  placement: i.get("currentPlacement")
75
75
  });
76
- function H(l) {
77
- const s = E.getItemDisabled(l.item), g = E.getItemValue(l.item);
78
- return Se(g, () => `[zag-js] No value found for item ${JSON.stringify(l.item)}`), {
76
+ function U(a) {
77
+ const r = f.getItemDisabled(a.item), g = f.getItemValue(a.item);
78
+ return ke(g, () => `[zag-js] No value found for item ${JSON.stringify(a.item)}`), {
79
79
  value: g,
80
- disabled: !!(s || s),
80
+ disabled: !!(r || r),
81
81
  highlighted: b === g,
82
82
  selected: i.get("value").includes(g)
83
83
  };
84
84
  }
85
85
  return {
86
- focused: F,
87
- open: d,
86
+ focused: R,
87
+ open: h,
88
88
  inputValue: i.get("inputValue"),
89
89
  highlightedValue: b,
90
90
  highlightedItem: i.get("highlightedItem"),
91
91
  value: i.get("value"),
92
- valueAsString: i.get("valueAsString"),
93
- hasSelectedItems: C("hasSelectedItems"),
92
+ valueAsString: u("valueAsString"),
93
+ hasSelectedItems: u("hasSelectedItems"),
94
94
  selectedItems: i.get("selectedItems"),
95
- collection: n("collection"),
96
- multiple: !!n("multiple"),
97
- disabled: !!I,
95
+ collection: l("collection"),
96
+ multiple: !!l("multiple"),
97
+ disabled: !!m,
98
98
  syncSelectedItems() {
99
- a({ type: "SELECTED_ITEMS.SYNC" });
99
+ o({ type: "SELECTED_ITEMS.SYNC" });
100
+ },
101
+ reposition(a = {}) {
102
+ o({ type: "POSITIONING.SET", options: a });
100
103
  },
101
- reposition(l = {}) {
102
- a({ type: "POSITIONING.SET", options: l });
104
+ setHighlightValue(a) {
105
+ o({ type: "HIGHLIGHTED_VALUE.SET", value: a });
103
106
  },
104
- setHighlightValue(l) {
105
- a({ type: "HIGHLIGHTED_VALUE.SET", value: l });
107
+ clearHighlightValue() {
108
+ o({ type: "HIGHLIGHTED_VALUE.CLEAR" });
106
109
  },
107
- selectValue(l) {
108
- a({ type: "ITEM.SELECT", value: l });
110
+ selectValue(a) {
111
+ o({ type: "ITEM.SELECT", value: a });
109
112
  },
110
- setValue(l) {
111
- a({ type: "VALUE.SET", value: l });
113
+ setValue(a) {
114
+ o({ type: "VALUE.SET", value: a });
112
115
  },
113
- setInputValue(l) {
114
- a({ type: "INPUT_VALUE.SET", value: l });
116
+ setInputValue(a, r = "script") {
117
+ o({ type: "INPUT_VALUE.SET", value: a, src: r });
115
118
  },
116
- clearValue(l) {
117
- l != null ? a({ type: "ITEM.CLEAR", value: l }) : a({ type: "VALUE.CLEAR" });
119
+ clearValue(a) {
120
+ a != null ? o({ type: "ITEM.CLEAR", value: a }) : o({ type: "VALUE.CLEAR" });
118
121
  },
119
122
  focus() {
120
- var l;
121
- (l = y(r)) == null || l.focus();
123
+ var a;
124
+ (a = L(s)) == null || a.focus();
122
125
  },
123
- setOpen(l) {
124
- o.hasTag("open") !== l && a({ type: l ? "OPEN" : "CLOSE" });
126
+ setOpen(a, r = "script") {
127
+ n.hasTag("open") !== a && o({ type: a ? "OPEN" : "CLOSE", src: r });
125
128
  },
126
129
  getRootProps() {
127
130
  return t.element({
128
- ...p.root.attrs,
129
- dir: n("dir"),
130
- id: Fe(r),
131
- "data-invalid": u(v),
132
- "data-readonly": u(S)
131
+ ...C.root.attrs,
132
+ dir: l("dir"),
133
+ id: Fe(s),
134
+ "data-invalid": c(O),
135
+ "data-readonly": c(N)
133
136
  });
134
137
  },
135
138
  getLabelProps() {
136
139
  return t.label({
137
- ...p.label.attrs,
138
- dir: n("dir"),
139
- htmlFor: M(r),
140
- id: B(r),
141
- "data-readonly": u(S),
142
- "data-disabled": u(I),
143
- "data-invalid": u(v),
144
- "data-focus": u(F),
145
- onClick(l) {
146
- var s;
147
- N || (l.preventDefault(), (s = L(r)) == null || s.focus({ preventScroll: !0 }));
140
+ ...C.label.attrs,
141
+ dir: l("dir"),
142
+ htmlFor: M(s),
143
+ id: B(s),
144
+ "data-readonly": c(N),
145
+ "data-disabled": c(m),
146
+ "data-invalid": c(O),
147
+ "data-focus": c(R),
148
+ onClick(a) {
149
+ var r;
150
+ S || (a.preventDefault(), (r = H(s)) == null || r.focus({ preventScroll: !0 }));
148
151
  }
149
152
  });
150
153
  },
151
154
  getControlProps() {
152
155
  return t.element({
153
- ...p.control.attrs,
154
- dir: n("dir"),
155
- id: ie(r),
156
- "data-state": d ? "open" : "closed",
157
- "data-focus": u(F),
158
- "data-disabled": u(I),
159
- "data-invalid": u(v)
156
+ ...C.control.attrs,
157
+ dir: l("dir"),
158
+ id: ne(s),
159
+ "data-state": h ? "open" : "closed",
160
+ "data-focus": c(R),
161
+ "data-disabled": c(m),
162
+ "data-invalid": c(O)
160
163
  });
161
164
  },
162
165
  getPositionerProps() {
163
166
  return t.element({
164
- ...p.positioner.attrs,
165
- dir: n("dir"),
166
- id: ne(r),
167
- style: se.floating
167
+ ...C.positioner.attrs,
168
+ dir: l("dir"),
169
+ id: oe(s),
170
+ style: re.floating
168
171
  });
169
172
  },
170
173
  getInputProps() {
171
174
  return t.input({
172
- ...p.input.attrs,
173
- dir: n("dir"),
174
- "aria-invalid": K(v),
175
- "data-invalid": u(v),
176
- "data-autofocus": u(n("autoFocus")),
177
- name: n("name"),
178
- form: n("form"),
179
- disabled: I,
180
- required: n("required"),
175
+ ...C.input.attrs,
176
+ dir: l("dir"),
177
+ "aria-invalid": K(O),
178
+ "data-invalid": c(O),
179
+ "data-autofocus": c(l("autoFocus")),
180
+ name: l("name"),
181
+ form: l("form"),
182
+ disabled: m,
183
+ required: l("required"),
181
184
  autoComplete: "off",
182
185
  autoCorrect: "off",
183
186
  autoCapitalize: "none",
184
187
  spellCheck: "false",
185
- readOnly: S,
186
- placeholder: n("placeholder"),
187
- id: M(r),
188
+ readOnly: N,
189
+ placeholder: l("placeholder"),
190
+ id: M(s),
188
191
  type: "text",
189
192
  role: "combobox",
190
193
  defaultValue: i.get("inputValue"),
191
- "aria-autocomplete": C("autoComplete") ? "both" : "list",
192
- "aria-controls": w(r),
193
- "aria-expanded": d,
194
- "data-state": d ? "open" : "closed",
195
- "aria-activedescendant": b ? J(r, b) : void 0,
196
- onClick(l) {
197
- l.defaultPrevented || n("openOnClick") && P && a({ type: "INPUT.CLICK" });
194
+ "aria-autocomplete": u("autoComplete") ? "both" : "list",
195
+ "aria-controls": w(s),
196
+ "aria-expanded": h,
197
+ "data-state": h ? "open" : "closed",
198
+ "aria-activedescendant": b ? Q(s, b) : void 0,
199
+ onClick(a) {
200
+ a.defaultPrevented || l("openOnClick") && T && o({ type: "INPUT.CLICK", src: "input-click" });
198
201
  },
199
202
  onFocus() {
200
- I || a({ type: "INPUT.FOCUS" });
203
+ m || o({ type: "INPUT.FOCUS" });
201
204
  },
202
205
  onBlur() {
203
- I || a({ type: "INPUT.BLUR" });
206
+ m || o({ type: "INPUT.BLUR" });
204
207
  },
205
- onChange(l) {
206
- a({ type: "INPUT.CHANGE", value: l.currentTarget.value });
208
+ onChange(a) {
209
+ o({ type: "INPUT.CHANGE", value: a.currentTarget.value, src: "input-change" });
207
210
  },
208
- onKeyDown(l) {
209
- if (l.defaultPrevented || !P || l.ctrlKey || l.shiftKey || fe(l)) return;
210
- const s = n("openOnKeyPress"), g = l.ctrlKey || l.metaKey || l.shiftKey, h = !0, A = {
211
- ArrowDown(V) {
212
- !s && !d || (a({ type: V.altKey ? "OPEN" : "INPUT.ARROW_DOWN", keypress: h }), V.preventDefault());
211
+ onKeyDown(a) {
212
+ if (a.defaultPrevented || !T || a.ctrlKey || a.shiftKey || fe(a)) return;
213
+ const r = l("openOnKeyPress"), g = a.ctrlKey || a.metaKey || a.shiftKey, p = !0, A = {
214
+ ArrowDown(y) {
215
+ !r && !h || (o({ type: y.altKey ? "OPEN" : "INPUT.ARROW_DOWN", keypress: p, src: "arrow-key" }), y.preventDefault());
213
216
  },
214
217
  ArrowUp() {
215
- !s && !d || (a({ type: l.altKey ? "CLOSE" : "INPUT.ARROW_UP", keypress: h }), l.preventDefault());
218
+ !r && !h || (o({ type: a.altKey ? "CLOSE" : "INPUT.ARROW_UP", keypress: p, src: "arrow-key" }), a.preventDefault());
216
219
  },
217
- Home(V) {
218
- g || (a({ type: "INPUT.HOME", keypress: h }), d && V.preventDefault());
220
+ Home(y) {
221
+ g || (o({ type: "INPUT.HOME", keypress: p }), h && y.preventDefault());
219
222
  },
220
- End(V) {
221
- g || (a({ type: "INPUT.END", keypress: h }), d && V.preventDefault());
223
+ End(y) {
224
+ g || (o({ type: "INPUT.END", keypress: p }), h && y.preventDefault());
222
225
  },
223
- Enter(V) {
226
+ Enter(y) {
224
227
  var W;
225
- a({ type: "INPUT.ENTER", keypress: h });
226
- const ue = C("isCustomValue") && n("allowCustomValue");
227
- if (d && !ue && V.preventDefault(), b == null) return;
228
- const _ = ae(r, b);
229
- Oe(_) && ((W = n("navigate")) == null || W({ value: b, node: _, href: _.href }));
228
+ o({ type: "INPUT.ENTER", keypress: p, src: "item-select" });
229
+ const ce = u("isCustomValue") && l("allowCustomValue");
230
+ if (h && !ce && y.preventDefault(), b == null) return;
231
+ const _ = F(s, b);
232
+ Ve(_) && ((W = l("navigate")) == null || W({ value: b, node: _, href: _.href }));
230
233
  },
231
234
  Escape() {
232
- a({ type: "INPUT.ESCAPE", keypress: h }), l.preventDefault();
235
+ o({ type: "INPUT.ESCAPE", keypress: p, src: "escape-key" }), a.preventDefault();
233
236
  }
234
- }, re = $(l, { dir: n("dir") }), x = A[re];
235
- x == null || x(l);
237
+ }, ue = $(a, { dir: l("dir") }), x = A[ue];
238
+ x == null || x(a);
236
239
  }
237
240
  });
238
241
  },
239
- getTriggerProps(l = {}) {
242
+ getTriggerProps(a = {}) {
240
243
  return t.button({
241
- ...p.trigger.attrs,
242
- dir: n("dir"),
243
- id: le(r),
244
- "aria-haspopup": N ? "listbox" : "dialog",
244
+ ...C.trigger.attrs,
245
+ dir: l("dir"),
246
+ id: ae(s),
247
+ "aria-haspopup": S ? "listbox" : "dialog",
245
248
  type: "button",
246
- tabIndex: l.focusable ? void 0 : -1,
247
- "aria-label": O.triggerLabel,
248
- "aria-expanded": d,
249
- "data-state": d ? "open" : "closed",
250
- "aria-controls": d ? w(r) : void 0,
251
- disabled: I,
252
- "data-invalid": u(v),
253
- "data-focusable": u(l.focusable),
254
- "data-readonly": u(S),
255
- "data-disabled": u(I),
249
+ tabIndex: a.focusable ? void 0 : -1,
250
+ "aria-label": I.triggerLabel,
251
+ "aria-expanded": h,
252
+ "data-state": h ? "open" : "closed",
253
+ "aria-controls": h ? w(s) : void 0,
254
+ disabled: m,
255
+ "data-invalid": c(O),
256
+ "data-focusable": c(a.focusable),
257
+ "data-readonly": c(N),
258
+ "data-disabled": c(m),
256
259
  onFocus() {
257
- l.focusable && a({ type: "INPUT.FOCUS", src: "trigger" });
260
+ a.focusable && o({ type: "INPUT.FOCUS", src: "trigger" });
258
261
  },
259
- onClick(s) {
260
- s.defaultPrevented || P && U(s) && a({ type: "TRIGGER.CLICK" });
262
+ onClick(r) {
263
+ r.defaultPrevented || T && D(r) && o({ type: "TRIGGER.CLICK", src: "trigger-click" });
261
264
  },
262
- onPointerDown(s) {
263
- P && s.pointerType !== "touch" && U(s) && (s.preventDefault(), queueMicrotask(() => {
265
+ onPointerDown(r) {
266
+ T && r.pointerType !== "touch" && D(r) && (r.preventDefault(), queueMicrotask(() => {
264
267
  var g;
265
- (g = y(r)) == null || g.focus({ preventScroll: !0 });
268
+ (g = L(s)) == null || g.focus({ preventScroll: !0 });
266
269
  }));
267
270
  },
268
- onKeyDown(s) {
269
- if (s.defaultPrevented || N) return;
271
+ onKeyDown(r) {
272
+ if (r.defaultPrevented || S) return;
270
273
  const g = {
271
274
  ArrowDown() {
272
- a({ type: "INPUT.ARROW_DOWN", src: "trigger" });
275
+ o({ type: "INPUT.ARROW_DOWN", src: "arrow-key" });
273
276
  },
274
277
  ArrowUp() {
275
- a({ type: "INPUT.ARROW_UP", src: "trigger" });
278
+ o({ type: "INPUT.ARROW_UP", src: "arrow-key" });
276
279
  }
277
- }, h = $(s, { dir: n("dir") }), A = g[h];
278
- A && (A(s), s.preventDefault());
280
+ }, p = $(r, { dir: l("dir") }), A = g[p];
281
+ A && (A(r), r.preventDefault());
279
282
  }
280
283
  });
281
284
  },
282
285
  getContentProps() {
283
286
  return t.element({
284
- ...p.content.attrs,
285
- dir: n("dir"),
286
- id: w(r),
287
- role: N ? "listbox" : "dialog",
287
+ ...C.content.attrs,
288
+ dir: l("dir"),
289
+ id: w(s),
290
+ role: S ? "listbox" : "dialog",
288
291
  tabIndex: -1,
289
- hidden: !d,
290
- "data-state": d ? "open" : "closed",
292
+ hidden: !h,
293
+ "data-state": h ? "open" : "closed",
291
294
  "data-placement": i.get("currentPlacement"),
292
- "aria-labelledby": B(r),
293
- "aria-multiselectable": n("multiple") && N ? !0 : void 0,
294
- "data-empty": u(E.size === 0),
295
- onPointerDown(l) {
296
- U(l) && l.preventDefault();
295
+ "aria-labelledby": B(s),
296
+ "aria-multiselectable": l("multiple") && S ? !0 : void 0,
297
+ "data-empty": c(f.size === 0),
298
+ onPointerDown(a) {
299
+ D(a) && a.preventDefault();
297
300
  }
298
301
  });
299
302
  },
300
303
  getListProps() {
301
304
  return t.element({
302
- ...p.list.attrs,
303
- role: N ? void 0 : "listbox",
304
- "data-empty": u(E.size === 0),
305
- "aria-labelledby": B(r),
306
- "aria-multiselectable": n("multiple") && !N ? !0 : void 0
305
+ ...C.list.attrs,
306
+ role: S ? void 0 : "listbox",
307
+ "data-empty": c(f.size === 0),
308
+ "aria-labelledby": B(s),
309
+ "aria-multiselectable": l("multiple") && !S ? !0 : void 0
307
310
  });
308
311
  },
309
312
  getClearTriggerProps() {
310
313
  return t.button({
311
- ...p.clearTrigger.attrs,
312
- dir: n("dir"),
313
- id: oe(r),
314
+ ...C.clearTrigger.attrs,
315
+ dir: l("dir"),
316
+ id: se(s),
314
317
  type: "button",
315
318
  tabIndex: -1,
316
- disabled: I,
317
- "data-invalid": u(v),
318
- "aria-label": O.clearTriggerLabel,
319
- "aria-controls": M(r),
319
+ disabled: m,
320
+ "data-invalid": c(O),
321
+ "aria-label": I.clearTriggerLabel,
322
+ "aria-controls": M(s),
320
323
  hidden: !i.get("value").length,
321
- onPointerDown(l) {
322
- U(l) && l.preventDefault();
324
+ onPointerDown(a) {
325
+ D(a) && a.preventDefault();
323
326
  },
324
- onClick(l) {
325
- l.defaultPrevented || P && a({ type: "VALUE.CLEAR", src: "clear-trigger" });
327
+ onClick(a) {
328
+ a.defaultPrevented || T && o({ type: "VALUE.CLEAR", src: "clear-trigger" });
326
329
  }
327
330
  });
328
331
  },
329
- getItemState: H,
330
- getItemProps(l) {
331
- const s = H(l), g = s.value;
332
+ getItemState: U,
333
+ getItemProps(a) {
334
+ const r = U(a), g = r.value;
332
335
  return t.element({
333
- ...p.item.attrs,
334
- dir: n("dir"),
335
- id: J(r, g),
336
+ ...C.item.attrs,
337
+ dir: l("dir"),
338
+ id: Q(s, g),
336
339
  role: "option",
337
340
  tabIndex: -1,
338
- "data-highlighted": u(s.highlighted),
339
- "data-state": s.selected ? "checked" : "unchecked",
340
- "aria-selected": K(s.highlighted),
341
- "aria-disabled": K(s.disabled),
342
- "data-disabled": u(s.disabled),
343
- "data-value": s.value,
341
+ "data-highlighted": c(r.highlighted),
342
+ "data-state": r.selected ? "checked" : "unchecked",
343
+ "aria-selected": K(r.highlighted),
344
+ "aria-disabled": K(r.disabled),
345
+ "data-disabled": c(r.disabled),
346
+ "data-value": r.value,
344
347
  onPointerMove() {
345
- s.disabled || s.highlighted || a({ type: "ITEM.POINTER_MOVE", value: g });
348
+ r.disabled || r.highlighted || o({ type: "ITEM.POINTER_MOVE", value: g });
346
349
  },
347
350
  onPointerLeave() {
348
- if (l.persistFocus || s.disabled) return;
349
- const h = k.previous();
350
- h != null && h.type.includes("POINTER") && a({ type: "ITEM.POINTER_LEAVE", value: g });
351
+ if (a.persistFocus || r.disabled) return;
352
+ const p = E.previous();
353
+ p != null && p.type.includes("POINTER") && o({ type: "ITEM.POINTER_LEAVE", value: g });
351
354
  },
352
- onClick(h) {
353
- pe(h) || me(h) || Ce(h) || s.disabled || a({ type: "ITEM.CLICK", src: "click", value: g });
355
+ onClick(p) {
356
+ Ie(p) || Ce(p) || ve(p) || r.disabled || o({ type: "ITEM.CLICK", src: "item-select", value: g });
354
357
  }
355
358
  });
356
359
  },
357
- getItemTextProps(l) {
358
- const s = H(l);
360
+ getItemTextProps(a) {
361
+ const r = U(a);
359
362
  return t.element({
360
- ...p.itemText.attrs,
361
- dir: n("dir"),
362
- "data-state": s.selected ? "checked" : "unchecked",
363
- "data-disabled": u(s.disabled),
364
- "data-highlighted": u(s.highlighted)
363
+ ...C.itemText.attrs,
364
+ dir: l("dir"),
365
+ "data-state": r.selected ? "checked" : "unchecked",
366
+ "data-disabled": c(r.disabled),
367
+ "data-highlighted": c(r.highlighted)
365
368
  });
366
369
  },
367
- getItemIndicatorProps(l) {
368
- const s = H(l);
370
+ getItemIndicatorProps(a) {
371
+ const r = U(a);
369
372
  return t.element({
370
373
  "aria-hidden": !0,
371
- ...p.itemIndicator.attrs,
372
- dir: n("dir"),
373
- "data-state": s.selected ? "checked" : "unchecked",
374
- hidden: !s.selected
374
+ ...C.itemIndicator.attrs,
375
+ dir: l("dir"),
376
+ "data-state": r.selected ? "checked" : "unchecked",
377
+ hidden: !r.selected
375
378
  });
376
379
  },
377
- getItemGroupProps(l) {
378
- const { id: s } = l;
380
+ getItemGroupProps(a) {
381
+ const { id: r } = a;
379
382
  return t.element({
380
- ...p.itemGroup.attrs,
381
- dir: n("dir"),
382
- id: Ae(r, s),
383
- "aria-labelledby": j(r, s),
384
- "data-empty": u(E.size === 0),
383
+ ...C.itemGroup.attrs,
384
+ dir: l("dir"),
385
+ id: He(s, r),
386
+ "aria-labelledby": J(s, r),
387
+ "data-empty": c(f.size === 0),
385
388
  role: "group"
386
389
  });
387
390
  },
388
- getItemGroupLabelProps(l) {
389
- const { htmlFor: s } = l;
391
+ getItemGroupLabelProps(a) {
392
+ const { htmlFor: r } = a;
390
393
  return t.element({
391
- ...p.itemGroupLabel.attrs,
392
- dir: n("dir"),
393
- id: j(r, s),
394
+ ...C.itemGroupLabel.attrs,
395
+ dir: l("dir"),
396
+ id: J(s, r),
394
397
  role: "presentation"
395
398
  });
396
399
  }
397
400
  };
398
401
  }
399
- var { guards: He, createMachine: Ue, choose: De } = be(), { and: c, not: m } = He, je = Ue({
402
+ var { guards: Ae, createMachine: Ue, choose: De } = Se(), { and: d, not: v } = Ae, Ye = Ue({
400
403
  props({ props: e }) {
401
404
  return {
402
405
  loopFocus: !0,
@@ -410,9 +413,9 @@ var { guards: He, createMachine: Ue, choose: De } = be(), { and: c, not: m } = H
410
413
  openOnChange: !0,
411
414
  composite: !0,
412
415
  navigate({ node: t }) {
413
- Ie(t);
416
+ me(t);
414
417
  },
415
- collection: te.empty(),
418
+ collection: le.empty(),
416
419
  ...e,
417
420
  positioning: {
418
421
  placement: "bottom",
@@ -429,7 +432,7 @@ var { guards: He, createMachine: Ue, choose: De } = be(), { and: c, not: m } = H
429
432
  initialState({ prop: e }) {
430
433
  return e("open") || e("defaultOpen") ? "suggesting" : "idle";
431
434
  },
432
- context({ prop: e, bindable: t, getContext: i }) {
435
+ context({ prop: e, bindable: t, getContext: i, getEvent: l }) {
433
436
  return {
434
437
  currentPlacement: t(() => ({
435
438
  defaultValue: void 0
@@ -442,37 +445,38 @@ var { guards: He, createMachine: Ue, choose: De } = be(), { and: c, not: m } = H
442
445
  return n.join(",");
443
446
  },
444
447
  onChange(n) {
445
- var k;
446
- const o = i(), a = o.get("selectedItems"), r = e("collection"), C = n.map((O) => a.find((I) => r.getItemValue(I) === O) || r.find(O));
447
- o.set("selectedItems", C), o.set("valueAsString", r.stringifyItems(C)), (k = e("onValueChange")) == null || k({ value: n, items: C });
448
+ var I;
449
+ const o = i(), s = o.get("selectedItems"), u = e("collection"), E = n.map((f) => s.find((T) => u.getItemValue(T) === f) || u.find(f));
450
+ o.set("selectedItems", E), (I = e("onValueChange")) == null || I({ value: n, items: E });
448
451
  }
449
452
  })),
450
453
  highlightedValue: t(() => ({
451
454
  defaultValue: e("defaultHighlightedValue") || null,
452
455
  value: e("highlightedValue"),
453
456
  onChange(n) {
454
- var a;
457
+ var s;
455
458
  const o = e("collection").find(n);
456
- (a = e("onHighlightChange")) == null || a({ highlightedValue: n, highlightedItem: o });
459
+ (s = e("onHighlightChange")) == null || s({ highlightedValue: n, highlightedItem: o });
457
460
  }
458
461
  })),
459
462
  inputValue: t(() => {
460
463
  let n = e("inputValue") || e("defaultInputValue") || "";
461
464
  const o = e("defaultValue") || e("value") || [];
462
465
  if (!n.trim() && !e("multiple")) {
463
- const a = e("collection").stringifyMany(o);
464
- n = D(e("selectionBehavior"), {
465
- preserve: n || a,
466
- replace: a,
466
+ const s = e("collection").stringifyMany(o);
467
+ n = P(e("selectionBehavior"), {
468
+ preserve: n || s,
469
+ replace: s,
467
470
  clear: ""
468
471
  });
469
472
  }
470
473
  return {
471
474
  defaultValue: n,
472
475
  value: e("inputValue"),
473
- onChange(a) {
474
- var r;
475
- (r = e("onInputValueChange")) == null || r({ inputValue: a });
476
+ onChange(s) {
477
+ var I;
478
+ const u = l(), E = (u.previousEvent || u).src;
479
+ (I = e("onInputValueChange")) == null || I({ inputValue: s, reason: E });
476
480
  }
477
481
  };
478
482
  }),
@@ -483,10 +487,6 @@ var { guards: He, createMachine: Ue, choose: De } = be(), { and: c, not: m } = H
483
487
  selectedItems: t(() => {
484
488
  const n = e("value") || e("defaultValue") || [];
485
489
  return { defaultValue: e("collection").findMany(n) };
486
- }),
487
- valueAsString: t(() => {
488
- const n = e("value") || e("defaultValue") || [];
489
- return { sync: !0, defaultValue: e("collection").stringifyMany(n) };
490
490
  })
491
491
  };
492
492
  },
@@ -496,17 +496,20 @@ var { guards: He, createMachine: Ue, choose: De } = be(), { and: c, not: m } = H
496
496
  autoComplete: ({ prop: e }) => e("inputBehavior") === "autocomplete",
497
497
  autoHighlight: ({ prop: e }) => e("inputBehavior") === "autohighlight",
498
498
  hasSelectedItems: ({ context: e }) => e.get("value").length > 0,
499
- isCustomValue: ({ context: e }) => e.get("inputValue") !== e.get("valueAsString")
499
+ valueAsString: ({ context: e, prop: t }) => t("collection").stringifyItems(e.get("selectedItems")),
500
+ isCustomValue: ({ context: e, computed: t }) => e.get("inputValue") !== t("valueAsString")
500
501
  },
501
- watch({ context: e, prop: t, track: i, action: n }) {
502
+ watch({ context: e, prop: t, track: i, action: l, send: n }) {
502
503
  i([() => e.hash("value")], () => {
503
- n(["syncSelectedItems"]);
504
+ l(["syncSelectedItems"]);
504
505
  }), i([() => e.get("inputValue")], () => {
505
- n(["syncInputValue"]);
506
+ l(["syncInputValue"]);
506
507
  }), i([() => e.get("highlightedValue")], () => {
507
- n(["syncHighlightedItem", "autofillInputValue"]);
508
+ l(["syncHighlightedItem", "autofillInputValue"]);
508
509
  }), i([() => t("open")], () => {
509
- n(["toggleVisibility"]);
510
+ l(["toggleVisibility"]);
511
+ }), i([() => t("collection").toString()], () => {
512
+ n({ type: "CHILDREN_CHANGE" });
510
513
  });
511
514
  },
512
515
  on: {
@@ -514,7 +517,10 @@ var { guards: He, createMachine: Ue, choose: De } = be(), { and: c, not: m } = H
514
517
  actions: ["syncSelectedItems"]
515
518
  },
516
519
  "HIGHLIGHTED_VALUE.SET": {
517
- actions: ["setHighlightedItem"]
520
+ actions: ["setHighlightedValue"]
521
+ },
522
+ "HIGHLIGHTED_VALUE.CLEAR": {
523
+ actions: ["clearHighlightedValue"]
518
524
  },
519
525
  "ITEM.SELECT": {
520
526
  actions: ["selectItem"]
@@ -541,7 +547,7 @@ var { guards: He, createMachine: Ue, choose: De } = be(), { and: c, not: m } = H
541
547
  states: {
542
548
  idle: {
543
549
  tags: ["idle", "closed"],
544
- entry: ["scrollContentToTop", "clearHighlightedItem"],
550
+ entry: ["scrollContentToTop", "clearHighlightedValue"],
545
551
  on: {
546
552
  "CONTROLLED.OPEN": {
547
553
  target: "interacting"
@@ -587,7 +593,7 @@ var { guards: He, createMachine: Ue, choose: De } = be(), { and: c, not: m } = H
587
593
  },
588
594
  focused: {
589
595
  tags: ["focused", "closed"],
590
- entry: ["scrollContentToTop", "clearHighlightedItem"],
596
+ entry: ["scrollContentToTop", "clearHighlightedValue"],
591
597
  on: {
592
598
  "CONTROLLED.OPEN": [
593
599
  {
@@ -600,7 +606,7 @@ var { guards: He, createMachine: Ue, choose: De } = be(), { and: c, not: m } = H
600
606
  ],
601
607
  "INPUT.CHANGE": [
602
608
  {
603
- guard: c("isOpenControlled", "openOnChange"),
609
+ guard: d("isOpenControlled", "openOnChange"),
604
610
  actions: ["setInputValue", "invokeOnOpen", "highlightFirstItemIfNeeded"]
605
611
  },
606
612
  {
@@ -616,7 +622,7 @@ var { guards: He, createMachine: Ue, choose: De } = be(), { and: c, not: m } = H
616
622
  target: "idle"
617
623
  },
618
624
  "INPUT.ESCAPE": {
619
- guard: c("isCustomValue", m("allowCustomValue")),
625
+ guard: d("isCustomValue", v("allowCustomValue")),
620
626
  actions: ["revertInputValue"]
621
627
  },
622
628
  "INPUT.BLUR": {
@@ -645,7 +651,7 @@ var { guards: He, createMachine: Ue, choose: De } = be(), { and: c, not: m } = H
645
651
  "INPUT.ARROW_DOWN": [
646
652
  // == group 1 ==
647
653
  {
648
- guard: c("isOpenControlled", "autoComplete"),
654
+ guard: d("isOpenControlled", "autoComplete"),
649
655
  actions: ["invokeOnOpen"]
650
656
  },
651
657
  {
@@ -715,6 +721,15 @@ var { guards: He, createMachine: Ue, choose: De } = be(), { and: c, not: m } = H
715
721
  target: "idle"
716
722
  }
717
723
  ],
724
+ CHILDREN_CHANGE: [
725
+ {
726
+ guard: "isHighlightedItemRemoved",
727
+ actions: ["clearHighlightedValue"]
728
+ },
729
+ {
730
+ actions: ["scrollToHighlightedItem"]
731
+ }
732
+ ],
718
733
  "INPUT.HOME": {
719
734
  actions: ["highlightFirstItem"]
720
735
  },
@@ -723,8 +738,8 @@ var { guards: He, createMachine: Ue, choose: De } = be(), { and: c, not: m } = H
723
738
  },
724
739
  "INPUT.ARROW_DOWN": [
725
740
  {
726
- guard: c("autoComplete", "isLastItemHighlighted"),
727
- actions: ["clearHighlightedItem", "scrollContentToTop"]
741
+ guard: d("autoComplete", "isLastItemHighlighted"),
742
+ actions: ["clearHighlightedValue", "scrollContentToTop"]
728
743
  },
729
744
  {
730
745
  actions: ["highlightNextItem"]
@@ -732,8 +747,8 @@ var { guards: He, createMachine: Ue, choose: De } = be(), { and: c, not: m } = H
732
747
  ],
733
748
  "INPUT.ARROW_UP": [
734
749
  {
735
- guard: c("autoComplete", "isFirstItemHighlighted"),
736
- actions: ["clearHighlightedItem"]
750
+ guard: d("autoComplete", "isFirstItemHighlighted"),
751
+ actions: ["clearHighlightedValue"]
737
752
  },
738
753
  {
739
754
  actions: ["highlightPrevItem"]
@@ -742,17 +757,17 @@ var { guards: He, createMachine: Ue, choose: De } = be(), { and: c, not: m } = H
742
757
  "INPUT.ENTER": [
743
758
  // == group 1 ==
744
759
  {
745
- guard: c("isOpenControlled", "isCustomValue", m("hasHighlightedItem"), m("allowCustomValue")),
760
+ guard: d("isOpenControlled", "isCustomValue", v("hasHighlightedItem"), v("allowCustomValue")),
746
761
  actions: ["revertInputValue", "invokeOnClose"]
747
762
  },
748
763
  {
749
- guard: c("isCustomValue", m("hasHighlightedItem"), m("allowCustomValue")),
764
+ guard: d("isCustomValue", v("hasHighlightedItem"), v("allowCustomValue")),
750
765
  target: "focused",
751
766
  actions: ["revertInputValue", "invokeOnClose"]
752
767
  },
753
768
  // == group 2 ==
754
769
  {
755
- guard: c("isOpenControlled", "closeOnSelect"),
770
+ guard: d("isOpenControlled", "closeOnSelect"),
756
771
  actions: ["selectHighlightedItem", "invokeOnClose"]
757
772
  },
758
773
  {
@@ -772,18 +787,18 @@ var { guards: He, createMachine: Ue, choose: De } = be(), { and: c, not: m } = H
772
787
  },
773
788
  {
774
789
  target: "suggesting",
775
- actions: ["clearHighlightedItem", "setInputValue"]
790
+ actions: ["clearHighlightedValue", "setInputValue"]
776
791
  }
777
792
  ],
778
793
  "ITEM.POINTER_MOVE": {
779
- actions: ["setHighlightedItem"]
794
+ actions: ["setHighlightedValue"]
780
795
  },
781
796
  "ITEM.POINTER_LEAVE": {
782
- actions: ["clearHighlightedItem"]
797
+ actions: ["clearHighlightedValue"]
783
798
  },
784
799
  "ITEM.CLICK": [
785
800
  {
786
- guard: c("isOpenControlled", "closeOnSelect"),
801
+ guard: d("isOpenControlled", "closeOnSelect"),
787
802
  actions: ["selectItem", "invokeOnClose"]
788
803
  },
789
804
  {
@@ -797,7 +812,7 @@ var { guards: He, createMachine: Ue, choose: De } = be(), { and: c, not: m } = H
797
812
  ],
798
813
  "LAYER.ESCAPE": [
799
814
  {
800
- guard: c("isOpenControlled", "autoComplete"),
815
+ guard: d("isOpenControlled", "autoComplete"),
801
816
  actions: ["syncInputValue", "invokeOnClose"]
802
817
  },
803
818
  {
@@ -827,11 +842,11 @@ var { guards: He, createMachine: Ue, choose: De } = be(), { and: c, not: m } = H
827
842
  "LAYER.INTERACT_OUTSIDE": [
828
843
  // == group 1 ==
829
844
  {
830
- guard: c("isOpenControlled", "isCustomValue", m("allowCustomValue")),
845
+ guard: d("isOpenControlled", "isCustomValue", v("allowCustomValue")),
831
846
  actions: ["revertInputValue", "invokeOnClose"]
832
847
  },
833
848
  {
834
- guard: c("isCustomValue", m("allowCustomValue")),
849
+ guard: d("isCustomValue", v("allowCustomValue")),
835
850
  target: "idle",
836
851
  actions: ["revertInputValue", "invokeOnClose"]
837
852
  },
@@ -869,13 +884,7 @@ var { guards: He, createMachine: Ue, choose: De } = be(), { and: c, not: m } = H
869
884
  },
870
885
  suggesting: {
871
886
  tags: ["open", "focused"],
872
- effects: [
873
- "trackDismissableLayer",
874
- "scrollToHighlightedItem",
875
- "trackPlacement",
876
- "trackChildNodes",
877
- "hideOtherElements"
878
- ],
887
+ effects: ["trackDismissableLayer", "scrollToHighlightedItem", "trackPlacement", "hideOtherElements"],
879
888
  entry: ["setInitialFocus"],
880
889
  on: {
881
890
  "CONTROLLED.CLOSE": [
@@ -888,10 +897,16 @@ var { guards: He, createMachine: Ue, choose: De } = be(), { and: c, not: m } = H
888
897
  target: "idle"
889
898
  }
890
899
  ],
891
- CHILDREN_CHANGE: {
892
- guard: "autoHighlight",
893
- actions: ["highlightFirstItem"]
894
- },
900
+ CHILDREN_CHANGE: [
901
+ {
902
+ guard: "autoHighlight",
903
+ actions: ["highlightFirstItem"]
904
+ },
905
+ {
906
+ guard: "isHighlightedItemRemoved",
907
+ actions: ["clearHighlightedValue"]
908
+ }
909
+ ],
895
910
  "INPUT.ARROW_DOWN": {
896
911
  target: "interacting",
897
912
  actions: ["highlightNextItem"]
@@ -911,17 +926,17 @@ var { guards: He, createMachine: Ue, choose: De } = be(), { and: c, not: m } = H
911
926
  "INPUT.ENTER": [
912
927
  // == group 1 ==
913
928
  {
914
- guard: c("isOpenControlled", "isCustomValue", m("hasHighlightedItem"), m("allowCustomValue")),
929
+ guard: d("isOpenControlled", "isCustomValue", v("hasHighlightedItem"), v("allowCustomValue")),
915
930
  actions: ["revertInputValue", "invokeOnClose"]
916
931
  },
917
932
  {
918
- guard: c("isCustomValue", m("hasHighlightedItem"), m("allowCustomValue")),
933
+ guard: d("isCustomValue", v("hasHighlightedItem"), v("allowCustomValue")),
919
934
  target: "focused",
920
935
  actions: ["revertInputValue", "invokeOnClose"]
921
936
  },
922
937
  // == group 2 ==
923
938
  {
924
- guard: c("isOpenControlled", "closeOnSelect"),
939
+ guard: d("isOpenControlled", "closeOnSelect"),
925
940
  actions: ["selectHighlightedItem", "invokeOnClose"]
926
941
  },
927
942
  {
@@ -948,19 +963,19 @@ var { guards: He, createMachine: Ue, choose: De } = be(), { and: c, not: m } = H
948
963
  ],
949
964
  "ITEM.POINTER_MOVE": {
950
965
  target: "interacting",
951
- actions: ["setHighlightedItem"]
966
+ actions: ["setHighlightedValue"]
952
967
  },
953
968
  "ITEM.POINTER_LEAVE": {
954
- actions: ["clearHighlightedItem"]
969
+ actions: ["clearHighlightedValue"]
955
970
  },
956
971
  "LAYER.INTERACT_OUTSIDE": [
957
972
  // == group 1 ==
958
973
  {
959
- guard: c("isOpenControlled", "isCustomValue", m("allowCustomValue")),
974
+ guard: d("isOpenControlled", "isCustomValue", v("allowCustomValue")),
960
975
  actions: ["revertInputValue", "invokeOnClose"]
961
976
  },
962
977
  {
963
- guard: c("isCustomValue", m("allowCustomValue")),
978
+ guard: d("isCustomValue", v("allowCustomValue")),
964
979
  target: "idle",
965
980
  actions: ["revertInputValue", "invokeOnClose"]
966
981
  },
@@ -986,7 +1001,7 @@ var { guards: He, createMachine: Ue, choose: De } = be(), { and: c, not: m } = H
986
1001
  ],
987
1002
  "ITEM.CLICK": [
988
1003
  {
989
- guard: c("isOpenControlled", "closeOnSelect"),
1004
+ guard: d("isOpenControlled", "closeOnSelect"),
990
1005
  actions: ["selectItem", "invokeOnClose"]
991
1006
  },
992
1007
  {
@@ -1042,133 +1057,164 @@ var { guards: He, createMachine: Ue, choose: De } = be(), { and: c, not: m } = H
1042
1057
  var t;
1043
1058
  return ((t = e.previousEvent) == null ? void 0 : t.type) === "INPUT.CHANGE";
1044
1059
  },
1045
- autoFocus: ({ prop: e }) => !!e("autoFocus")
1060
+ autoFocus: ({ prop: e }) => !!e("autoFocus"),
1061
+ isHighlightedItemRemoved: ({ prop: e, context: t }) => !e("collection").has(t.get("highlightedValue"))
1046
1062
  },
1047
1063
  effects: {
1048
1064
  trackDismissableLayer({ send: e, prop: t, scope: i }) {
1049
- return t("disableLayer") ? void 0 : ke(() => T(i), {
1065
+ return t("disableLayer") ? void 0 : be(() => k(i), {
1050
1066
  defer: !0,
1051
- exclude: () => [y(i), L(i), Z(i)],
1067
+ exclude: () => [L(i), H(i), z(i)],
1052
1068
  onFocusOutside: t("onFocusOutside"),
1053
1069
  onPointerDownOutside: t("onPointerDownOutside"),
1054
1070
  onInteractOutside: t("onInteractOutside"),
1055
- onEscapeKeyDown(o) {
1056
- o.preventDefault(), o.stopPropagation(), e({ type: "LAYER.ESCAPE" });
1071
+ onEscapeKeyDown(n) {
1072
+ n.preventDefault(), n.stopPropagation(), e({ type: "LAYER.ESCAPE", src: "escape-key" });
1057
1073
  },
1058
1074
  onDismiss() {
1059
- e({ type: "LAYER.INTERACT_OUTSIDE", restoreFocus: !1 });
1075
+ e({ type: "LAYER.INTERACT_OUTSIDE", src: "interact-outside", restoreFocus: !1 });
1060
1076
  }
1061
1077
  });
1062
1078
  },
1063
1079
  hideOtherElements({ scope: e }) {
1064
- return Ne([
1065
- y(e),
1066
- T(e),
1080
+ return Le([
1067
1081
  L(e),
1068
- Z(e)
1082
+ k(e),
1083
+ H(e),
1084
+ z(e)
1069
1085
  ]);
1070
1086
  },
1071
1087
  trackPlacement({ context: e, prop: t, scope: i }) {
1072
- const n = () => X(i) || L(i), o = () => Q(i);
1073
- return e.set("currentPlacement", t("positioning").placement), q(n, o, {
1088
+ const l = () => Z(i) || H(i), n = () => X(i);
1089
+ return e.set("currentPlacement", t("positioning").placement), Y(l, n, {
1074
1090
  ...t("positioning"),
1075
1091
  defer: !0,
1076
- onComplete(a) {
1077
- e.set("currentPlacement", a.placement);
1092
+ onComplete(o) {
1093
+ e.set("currentPlacement", o.placement);
1078
1094
  }
1079
1095
  });
1080
1096
  },
1081
- // in event the options are fetched (async), we still want to auto-highlight the first option
1082
- trackChildNodes({ scope: e, computed: t, send: i }) {
1083
- return t("autoHighlight") ? he(() => T(e), {
1084
- callback: () => i({ type: "CHILDREN_CHANGE" }),
1085
- defer: !0
1086
- }) : void 0;
1087
- },
1088
- scrollToHighlightedItem({ context: e, prop: t, scope: i, event: n }) {
1089
- const o = y(i);
1090
- let a = [];
1091
- const r = (O) => {
1092
- const E = n.current().type.includes("POINTER"), I = e.get("highlightedValue");
1093
- if (E || !I) return;
1094
- const P = ae(i, I), v = T(i), S = t("scrollToIndexFn");
1095
- if (S) {
1096
- const F = t("collection").indexOf(I);
1097
- S({ index: F, immediate: O });
1097
+ scrollToHighlightedItem({ context: e, prop: t, scope: i, event: l }) {
1098
+ const n = L(i);
1099
+ let o = [];
1100
+ const s = (I) => {
1101
+ const f = l.current().type.includes("POINTER"), m = e.get("highlightedValue");
1102
+ if (f || !m) return;
1103
+ const T = k(i), O = t("scrollToIndexFn");
1104
+ if (O) {
1105
+ const R = t("collection").indexOf(m);
1106
+ O({
1107
+ index: R,
1108
+ immediate: I,
1109
+ getElement: () => F(i, m)
1110
+ });
1098
1111
  return;
1099
1112
  }
1100
- const d = f(() => {
1101
- Ee(P, { rootEl: v, block: "nearest" });
1113
+ const N = F(i, m), h = V(() => {
1114
+ q(N, { rootEl: T, block: "nearest" });
1102
1115
  });
1103
- a.push(d);
1104
- }, C = f(() => r(!0));
1105
- a.push(C);
1106
- const k = de(o, {
1116
+ o.push(h);
1117
+ }, u = V(() => s(!0));
1118
+ o.push(u);
1119
+ const E = pe(n, {
1107
1120
  attributes: ["aria-activedescendant"],
1108
- callback: () => r(!1)
1121
+ callback: () => s(!1)
1109
1122
  });
1110
- return a.push(k), () => {
1111
- a.forEach((O) => O());
1123
+ return o.push(E), () => {
1124
+ o.forEach((I) => I());
1112
1125
  };
1113
1126
  }
1114
1127
  },
1115
1128
  actions: {
1116
- reposition({ context: e, prop: t, scope: i, event: n }) {
1117
- q(() => X(i), () => Q(i), {
1129
+ reposition({ context: e, prop: t, scope: i, event: l }) {
1130
+ Y(() => Z(i), () => X(i), {
1118
1131
  ...t("positioning"),
1119
- ...n.options,
1132
+ ...l.options,
1120
1133
  defer: !0,
1121
1134
  listeners: !1,
1122
- onComplete(r) {
1123
- e.set("currentPlacement", r.placement);
1135
+ onComplete(s) {
1136
+ e.set("currentPlacement", s.placement);
1124
1137
  }
1125
1138
  });
1126
1139
  },
1127
- setHighlightedItem(e) {
1128
- const { context: t, event: i } = e;
1129
- i.value != null && t.set("highlightedValue", i.value);
1140
+ setHighlightedValue({ context: e, event: t }) {
1141
+ t.value != null && e.set("highlightedValue", t.value);
1130
1142
  },
1131
- clearHighlightedItem(e) {
1132
- const { context: t } = e;
1133
- t.set("highlightedValue", null);
1143
+ clearHighlightedValue({ context: e }) {
1144
+ e.set("highlightedValue", null);
1134
1145
  },
1135
1146
  selectHighlightedItem(e) {
1136
- var a;
1137
- const { context: t, prop: i } = e, n = t.get("highlightedValue");
1138
- if (!n) return;
1139
- const o = i("multiple") ? Y(t.get("value"), n) : [n];
1140
- (a = i("onSelect")) == null || a({ value: o, itemValue: n }), t.set("value", o), t.set("inputValue", R(e));
1147
+ var u;
1148
+ const { context: t, prop: i } = e, l = i("collection"), n = t.get("highlightedValue");
1149
+ if (!n || !l.has(n)) return;
1150
+ const o = i("multiple") ? j(t.get("value"), n) : [n];
1151
+ (u = i("onSelect")) == null || u({ value: o, itemValue: n }), t.set("value", o);
1152
+ const s = P(i("selectionBehavior"), {
1153
+ preserve: t.get("inputValue"),
1154
+ replace: l.stringifyMany(o),
1155
+ clear: ""
1156
+ });
1157
+ t.set("inputValue", s);
1158
+ },
1159
+ scrollToHighlightedItem({ context: e, prop: t, scope: i }) {
1160
+ he(() => {
1161
+ const l = e.get("highlightedValue");
1162
+ if (l == null) return;
1163
+ const n = F(i, l), o = k(i), s = t("scrollToIndexFn");
1164
+ if (s) {
1165
+ const u = t("collection").indexOf(l);
1166
+ s({
1167
+ index: u,
1168
+ immediate: !0,
1169
+ getElement: () => F(i, l)
1170
+ });
1171
+ return;
1172
+ }
1173
+ q(n, { rootEl: o, block: "nearest" });
1174
+ });
1141
1175
  },
1142
1176
  selectItem(e) {
1143
- const { context: t, event: i, flush: n, prop: o } = e;
1144
- i.value != null && n(() => {
1145
- var r;
1146
- const a = o("multiple") ? Y(t.get("value"), i.value) : [i.value];
1147
- (r = o("onSelect")) == null || r({ value: a, itemValue: i.value }), t.set("value", a), t.set("inputValue", R(e));
1177
+ const { context: t, event: i, flush: l, prop: n } = e;
1178
+ i.value != null && l(() => {
1179
+ var u;
1180
+ const o = n("multiple") ? j(t.get("value"), i.value) : [i.value];
1181
+ (u = n("onSelect")) == null || u({ value: o, itemValue: i.value }), t.set("value", o);
1182
+ const s = P(n("selectionBehavior"), {
1183
+ preserve: t.get("inputValue"),
1184
+ replace: n("collection").stringifyMany(o),
1185
+ clear: ""
1186
+ });
1187
+ t.set("inputValue", s);
1148
1188
  });
1149
1189
  },
1150
1190
  clearItem(e) {
1151
- const { context: t, event: i, flush: n } = e;
1152
- i.value != null && n(() => {
1191
+ const { context: t, event: i, flush: l, prop: n } = e;
1192
+ i.value != null && l(() => {
1153
1193
  const o = Te(t.get("value"), i.value);
1154
- t.set("value", o), t.set("inputValue", R(e));
1194
+ t.set("value", o);
1195
+ const s = P(n("selectionBehavior"), {
1196
+ preserve: t.get("inputValue"),
1197
+ replace: n("collection").stringifyMany(o),
1198
+ clear: ""
1199
+ });
1200
+ t.set("inputValue", s);
1155
1201
  });
1156
1202
  },
1157
1203
  setInitialFocus({ scope: e }) {
1158
- f(() => {
1159
- z(e);
1204
+ V(() => {
1205
+ ee(e);
1160
1206
  });
1161
1207
  },
1162
1208
  setFinalFocus({ scope: e }) {
1163
- f(() => {
1164
- const t = L(e);
1165
- (t == null ? void 0 : t.dataset.focusable) == null ? z(e) : Re(e);
1209
+ V(() => {
1210
+ const t = H(e);
1211
+ (t == null ? void 0 : t.dataset.focusable) == null ? ee(e) : Re(e);
1166
1212
  });
1167
1213
  },
1168
1214
  syncInputValue({ context: e, scope: t, event: i }) {
1169
- const n = y(t);
1170
- n && (n.value = e.get("inputValue"), queueMicrotask(() => {
1171
- i.current().type !== "INPUT.CHANGE" && ge(n);
1215
+ const l = L(t);
1216
+ l && (l.value = e.get("inputValue"), queueMicrotask(() => {
1217
+ i.current().type !== "INPUT.CHANGE" && de(l);
1172
1218
  }));
1173
1219
  },
1174
1220
  setInputValue({ context: e, event: t }) {
@@ -1178,103 +1224,124 @@ var { guards: He, createMachine: Ue, choose: De } = be(), { and: c, not: m } = H
1178
1224
  e.set("inputValue", "");
1179
1225
  },
1180
1226
  revertInputValue({ context: e, prop: t, computed: i }) {
1181
- const n = t("selectionBehavior"), o = D(n, {
1182
- replace: i("hasSelectedItems") ? e.get("valueAsString") : "",
1227
+ const l = t("selectionBehavior"), n = P(l, {
1228
+ replace: i("hasSelectedItems") ? i("valueAsString") : "",
1183
1229
  preserve: e.get("inputValue"),
1184
1230
  clear: ""
1185
1231
  });
1186
- e.set("inputValue", o);
1232
+ e.set("inputValue", n);
1187
1233
  },
1188
1234
  setValue(e) {
1189
- const { context: t, flush: i, event: n } = e;
1235
+ const { context: t, flush: i, event: l, prop: n } = e;
1190
1236
  i(() => {
1191
- t.set("value", n.value), t.set("inputValue", R(e));
1237
+ t.set("value", l.value);
1238
+ const o = P(n("selectionBehavior"), {
1239
+ preserve: t.get("inputValue"),
1240
+ replace: n("collection").stringifyMany(l.value),
1241
+ clear: ""
1242
+ });
1243
+ t.set("inputValue", o);
1192
1244
  });
1193
1245
  },
1194
1246
  clearSelectedItems(e) {
1195
- const { context: t, flush: i } = e;
1247
+ const { context: t, flush: i, prop: l } = e;
1196
1248
  i(() => {
1197
- t.set("value", []), t.set("inputValue", R(e));
1249
+ t.set("value", []);
1250
+ const n = P(l("selectionBehavior"), {
1251
+ preserve: t.get("inputValue"),
1252
+ replace: l("collection").stringifyMany([]),
1253
+ clear: ""
1254
+ });
1255
+ t.set("inputValue", n);
1198
1256
  });
1199
1257
  },
1200
1258
  scrollContentToTop({ prop: e, scope: t }) {
1201
1259
  const i = e("scrollToIndexFn");
1202
- if (i)
1203
- i({ index: 0, immediate: !0 });
1204
- else {
1205
- const n = T(t);
1206
- if (!n) return;
1207
- n.scrollTop = 0;
1260
+ if (i) {
1261
+ const l = e("collection").firstValue;
1262
+ i({
1263
+ index: 0,
1264
+ immediate: !0,
1265
+ getElement: () => F(t, l)
1266
+ });
1267
+ } else {
1268
+ const l = k(t);
1269
+ if (!l) return;
1270
+ l.scrollTop = 0;
1208
1271
  }
1209
1272
  },
1210
- invokeOnOpen({ prop: e }) {
1211
- var t;
1212
- (t = e("onOpenChange")) == null || t({ open: !0 });
1273
+ invokeOnOpen({ prop: e, event: t }) {
1274
+ var l;
1275
+ const i = te(t);
1276
+ (l = e("onOpenChange")) == null || l({ open: !0, reason: i });
1213
1277
  },
1214
- invokeOnClose({ prop: e }) {
1215
- var t;
1216
- (t = e("onOpenChange")) == null || t({ open: !1 });
1278
+ invokeOnClose({ prop: e, event: t }) {
1279
+ var l;
1280
+ const i = te(t);
1281
+ (l = e("onOpenChange")) == null || l({ open: !1, reason: i });
1217
1282
  },
1218
1283
  highlightFirstItem({ context: e, prop: t, scope: i }) {
1219
- (T(i) ? queueMicrotask : f)(() => {
1220
- const o = t("collection").firstValue;
1221
- o && e.set("highlightedValue", o);
1284
+ (k(i) ? queueMicrotask : V)(() => {
1285
+ const n = t("collection").firstValue;
1286
+ n && e.set("highlightedValue", n);
1222
1287
  });
1223
1288
  },
1224
1289
  highlightFirstItemIfNeeded({ computed: e, action: t }) {
1225
1290
  e("autoHighlight") && t(["highlightFirstItem"]);
1226
1291
  },
1227
1292
  highlightLastItem({ context: e, prop: t, scope: i }) {
1228
- (T(i) ? queueMicrotask : f)(() => {
1229
- const o = t("collection").lastValue;
1230
- o && e.set("highlightedValue", o);
1293
+ (k(i) ? queueMicrotask : V)(() => {
1294
+ const n = t("collection").lastValue;
1295
+ n && e.set("highlightedValue", n);
1231
1296
  });
1232
1297
  },
1233
1298
  highlightNextItem({ context: e, prop: t }) {
1234
1299
  let i = null;
1235
- const n = e.get("highlightedValue"), o = t("collection");
1236
- n ? (i = o.getNextValue(n), !i && t("loopFocus") && (i = o.firstValue)) : i = o.firstValue, i && e.set("highlightedValue", i);
1300
+ const l = e.get("highlightedValue"), n = t("collection");
1301
+ l ? (i = n.getNextValue(l), !i && t("loopFocus") && (i = n.firstValue)) : i = n.firstValue, i && e.set("highlightedValue", i);
1237
1302
  },
1238
1303
  highlightPrevItem({ context: e, prop: t }) {
1239
1304
  let i = null;
1240
- const n = e.get("highlightedValue"), o = t("collection");
1241
- n ? (i = o.getPreviousValue(n), !i && t("loopFocus") && (i = o.lastValue)) : i = o.lastValue, i && e.set("highlightedValue", i);
1305
+ const l = e.get("highlightedValue"), n = t("collection");
1306
+ l ? (i = n.getPreviousValue(l), !i && t("loopFocus") && (i = n.lastValue)) : i = n.lastValue, i && e.set("highlightedValue", i);
1242
1307
  },
1243
1308
  highlightFirstSelectedItem({ context: e, prop: t }) {
1244
- f(() => {
1309
+ V(() => {
1245
1310
  const [i] = t("collection").sort(e.get("value"));
1246
1311
  i && e.set("highlightedValue", i);
1247
1312
  });
1248
1313
  },
1249
1314
  highlightFirstOrSelectedItem({ context: e, prop: t, computed: i }) {
1250
- f(() => {
1251
- let n = null;
1252
- i("hasSelectedItems") ? n = t("collection").sort(e.get("value"))[0] : n = t("collection").firstValue, n && e.set("highlightedValue", n);
1315
+ V(() => {
1316
+ let l = null;
1317
+ i("hasSelectedItems") ? l = t("collection").sort(e.get("value"))[0] : l = t("collection").firstValue, l && e.set("highlightedValue", l);
1253
1318
  });
1254
1319
  },
1255
1320
  highlightLastOrSelectedItem({ context: e, prop: t, computed: i }) {
1256
- f(() => {
1257
- const n = t("collection");
1258
- let o = null;
1259
- i("hasSelectedItems") ? o = n.sort(e.get("value"))[0] : o = n.lastValue, o && e.set("highlightedValue", o);
1321
+ V(() => {
1322
+ const l = t("collection");
1323
+ let n = null;
1324
+ i("hasSelectedItems") ? n = l.sort(e.get("value"))[0] : n = l.lastValue, n && e.set("highlightedValue", n);
1260
1325
  });
1261
1326
  },
1262
- autofillInputValue({ context: e, computed: t, prop: i, event: n, scope: o }) {
1263
- const a = y(o), r = i("collection");
1264
- if (!t("autoComplete") || !a || !n.keypress) return;
1265
- const C = r.stringify(e.get("highlightedValue"));
1266
- f(() => {
1267
- a.value = C || e.get("inputValue");
1327
+ autofillInputValue({ context: e, computed: t, prop: i, event: l, scope: n }) {
1328
+ const o = L(n), s = i("collection");
1329
+ if (!t("autoComplete") || !o || !l.keypress) return;
1330
+ const u = s.stringify(e.get("highlightedValue"));
1331
+ V(() => {
1332
+ o.value = u || e.get("inputValue");
1268
1333
  });
1269
1334
  },
1270
1335
  syncSelectedItems(e) {
1271
1336
  queueMicrotask(() => {
1272
- const { context: t, prop: i } = e, n = D(i("selectionBehavior"), {
1337
+ const { context: t, prop: i } = e, l = i("collection"), n = t.get("value"), o = n.map((u) => t.get("selectedItems").find((I) => l.getItemValue(I) === u) || l.find(u));
1338
+ t.set("selectedItems", o);
1339
+ const s = P(i("selectionBehavior"), {
1273
1340
  preserve: t.get("inputValue"),
1274
- replace: i("collection").stringifyMany(t.get("value")),
1341
+ replace: l.stringifyMany(n),
1275
1342
  clear: ""
1276
1343
  });
1277
- t.set("selectedItems", Me(e)), t.set("inputValue", n);
1344
+ t.set("inputValue", s);
1278
1345
  });
1279
1346
  },
1280
1347
  syncHighlightedItem({ context: e, prop: t }) {
@@ -1287,19 +1354,8 @@ var { guards: He, createMachine: Ue, choose: De } = be(), { and: c, not: m } = H
1287
1354
  }
1288
1355
  }
1289
1356
  });
1290
- function R({ context: e, prop: t }) {
1291
- return D(t("selectionBehavior"), {
1292
- preserve: e.get("inputValue"),
1293
- replace: e.get("valueAsString"),
1294
- clear: ""
1295
- });
1296
- }
1297
- function Me({ context: e, prop: t }) {
1298
- const i = t("collection");
1299
- return e.get("value").map((n) => {
1300
- const o = e.get("selectedItems").find((a) => i.getItemValue(a) === n);
1301
- return o || i.find(n);
1302
- });
1357
+ function te(e) {
1358
+ return (e.previousEvent || e).src;
1303
1359
  }
1304
1360
  G()([
1305
1361
  "allowCustomValue",
@@ -1352,8 +1408,8 @@ G()(["htmlFor"]);
1352
1408
  G()(["id"]);
1353
1409
  G()(["item", "persistFocus"]);
1354
1410
  export {
1355
- Le as anatomy,
1356
- te as collection,
1357
- Ye as connect,
1358
- je as machine
1411
+ Ne as anatomy,
1412
+ le as collection,
1413
+ qe as connect,
1414
+ Ye as machine
1359
1415
  };