@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,14 +1,12 @@
1
- import { createAnatomy as U } from "../../anatomy/dist/index.js";
2
- import { createMachine as V, guards as F, mergeProps as W } from "../../core/dist/index.js";
3
- import { addDomEvent as B, getEventKey as k, isPrintableKey as K, isModifierKey as Y, isContextMenuEvent as X, getEventPoint as L, clickIfLink as $ } from "../../dom-event/dist/index.js";
4
- import { isEditableElement as G, createScope as q, raf as b, getInitialFocus as j, contains as J, observeAttributes as Q, scrollIntoView as Z, getByTypeahead as w, dataAttr as C, isDownloadingEvent as A, isOpeningInNewTab as M, isSelfTarget as x, getEventTarget as z, isValidTabEvent as ee, prevById as te, nextById as ne, isHTMLElement as ie, queryAll as oe } from "../../dom-query/dist/index.js";
5
- import { getPlacementSide as re, getPlacement as D, getPlacementStyles as ae } from "../../popper/dist/index.js";
6
- import { compact as se, cast as le, last as ge, first as ue, isEqual as de } from "../../utils/dist/index.js";
7
- import { trackDismissableElement as ce } from "../../dismissable/dist/index.js";
8
- import { getElementPolygon as pe, isPointInPolygon as he } from "../../rect-utils/dist/index.js";
9
- import { createProps as y } from "../../types/dist/index.js";
10
- import { ref as _ } from "../../store/dist/index.js";
11
- var Ee = U("menu").parts(
1
+ import { createAnatomy as de } from "../../anatomy/dist/index.js";
2
+ import { createMachine as ue, createGuards as ce, mergeProps as he } from "../../core/dist/index.js";
3
+ import { isEditableElement as ie, raf as b, observeAttributes as pe, addDomEvent as Oe, getByTypeahead as re, clickIfLink as Ee, dataAttr as C, isDownloadingEvent as Y, isOpeningInNewTab as q, isSelfTarget as me, getEventTarget as oe, isValidTabEvent as Te, getEventKey as j, isPrintableKey as Ie, isModifierKey as fe, isContextMenuEvent as Pe, getEventPoint as _, getWindow as ye, ariaAttr as Ce, isAnchorElement as ve, isHTMLElement as Re, queryAll as Se, getInitialFocus as Ne, contains as J, scrollIntoView as ke } from "../../dom-query/dist/index.js";
4
+ import { getPlacementSide as Le, getPlacement as Q, getPlacementStyles as Ae } from "../../popper/dist/index.js";
5
+ import { last as Me, first as be, hasProp as U, prev as _e, next as De, cast as Z } from "../../utils/dist/index.js";
6
+ import { trackDismissableElement as He } from "../../dismissable/dist/index.js";
7
+ import { getElementPolygon as we, isPointInPolygon as Ge } from "../../rect-utils/dist/index.js";
8
+ import { createProps as k } from "../../types/dist/index.js";
9
+ var Ve = de("menu").parts(
12
10
  "arrow",
13
11
  "arrowTip",
14
12
  "content",
@@ -23,161 +21,157 @@ var Ee = U("menu").parts(
23
21
  "separator",
24
22
  "trigger",
25
23
  "triggerItem"
26
- ), p = Ee.build(), a = q({
27
- getTriggerId: (t) => {
28
- var o;
29
- return ((o = t.ids) == null ? void 0 : o.trigger) ?? `menu:${t.id}:trigger`;
30
- },
31
- getContextTriggerId: (t) => {
32
- var o;
33
- return ((o = t.ids) == null ? void 0 : o.contextTrigger) ?? `menu:${t.id}:ctx-trigger`;
34
- },
35
- getContentId: (t) => {
36
- var o;
37
- return ((o = t.ids) == null ? void 0 : o.content) ?? `menu:${t.id}:content`;
38
- },
39
- getArrowId: (t) => {
40
- var o;
41
- return ((o = t.ids) == null ? void 0 : o.arrow) ?? `menu:${t.id}:arrow`;
42
- },
43
- getPositionerId: (t) => {
44
- var o;
45
- return ((o = t.ids) == null ? void 0 : o.positioner) ?? `menu:${t.id}:popper`;
46
- },
47
- getGroupId: (t, o) => {
48
- var e, i;
49
- return ((i = (e = t.ids) == null ? void 0 : e.group) == null ? void 0 : i.call(e, o)) ?? `menu:${t.id}:group:${o}`;
50
- },
51
- getGroupLabelId: (t, o) => {
52
- var e, i;
53
- return ((i = (e = t.ids) == null ? void 0 : e.groupLabel) == null ? void 0 : i.call(e, o)) ?? `menu:${t.id}:group-label:${o}`;
54
- },
55
- getContentEl: (t) => a.getById(t, a.getContentId(t)),
56
- getPositionerEl: (t) => a.getById(t, a.getPositionerId(t)),
57
- getTriggerEl: (t) => a.getById(t, a.getTriggerId(t)),
58
- getHighlightedItemEl: (t) => t.highlightedValue ? a.getById(t, t.highlightedValue) : null,
59
- getArrowEl: (t) => a.getById(t, a.getArrowId(t)),
60
- getElements: (t) => {
61
- const e = `[role^="menuitem"][data-ownedby=${CSS.escape(a.getContentId(t))}]:not([data-disabled])`;
62
- return oe(a.getContentEl(t), e);
63
- },
64
- getFirstEl: (t) => ue(a.getElements(t)),
65
- getLastEl: (t) => ge(a.getElements(t)),
66
- getNextEl: (t, o) => ne(a.getElements(t), t.highlightedValue, o ?? t.loopFocus),
67
- getPrevEl: (t, o) => te(a.getElements(t), t.highlightedValue, o ?? t.loopFocus),
68
- getElemByKey: (t, o) => w(a.getElements(t), { state: t.typeaheadState, key: o, activeId: t.highlightedValue }),
69
- isTargetDisabled: (t) => ie(t) && (t.dataset.disabled === "" || t.hasAttribute("disabled")),
70
- isTriggerItem: (t) => {
71
- var o;
72
- return !!((o = t == null ? void 0 : t.getAttribute("role")) != null && o.startsWith("menuitem")) && !!(t != null && t.hasAttribute("aria-controls"));
73
- },
74
- getOptionFromItemEl(t) {
75
- return {
76
- id: t.id,
77
- name: t.dataset.name,
78
- value: t.dataset.value,
79
- valueText: t.dataset.valueText,
80
- type: t.dataset.type
81
- };
82
- }
83
- });
84
- function be(t, o, e) {
85
- const i = t.context.isSubmenu, r = t.context.isTypingAhead, l = t.context.composite, g = t.hasTag("open"), d = ae({
86
- ...t.context.positioning,
87
- placement: t.context.anchorPoint ? "bottom" : t.context.currentPlacement
24
+ ), E = Ve.build(), w = (e) => {
25
+ var t;
26
+ return ((t = e.ids) == null ? void 0 : t.trigger) ?? `menu:${e.id}:trigger`;
27
+ }, ae = (e) => {
28
+ var t;
29
+ return ((t = e.ids) == null ? void 0 : t.contextTrigger) ?? `menu:${e.id}:ctx-trigger`;
30
+ }, S = (e) => {
31
+ var t;
32
+ return ((t = e.ids) == null ? void 0 : t.content) ?? `menu:${e.id}:content`;
33
+ }, Fe = (e) => {
34
+ var t;
35
+ return ((t = e.ids) == null ? void 0 : t.arrow) ?? `menu:${e.id}:arrow`;
36
+ }, se = (e) => {
37
+ var t;
38
+ return ((t = e.ids) == null ? void 0 : t.positioner) ?? `menu:${e.id}:popper`;
39
+ }, Ue = (e, t) => {
40
+ var n, r;
41
+ return ((r = (n = e.ids) == null ? void 0 : n.group) == null ? void 0 : r.call(n, t)) ?? `menu:${e.id}:group:${t}`;
42
+ }, N = (e, t) => `${e.id}/${t}`, f = (e) => (e == null ? void 0 : e.dataset.value) ?? null, z = (e, t) => {
43
+ var n, r;
44
+ return ((r = (n = e.ids) == null ? void 0 : n.groupLabel) == null ? void 0 : r.call(n, t)) ?? `menu:${e.id}:group-label:${t}`;
45
+ }, I = (e) => e.getById(S(e)), ee = (e) => e.getById(se(e)), D = (e) => e.getById(w(e)), le = (e, t) => t ? e.getById(N(e, t)) : null, te = (e) => e.getById(ae(e)), L = (e) => {
46
+ const n = `[role^="menuitem"][data-ownedby=${CSS.escape(S(e))}]:not([data-disabled])`;
47
+ return Se(I(e), n);
48
+ }, We = (e) => be(L(e)), xe = (e) => Me(L(e)), x = (e, t) => t ? e.id === t || e.dataset.value === t : !1, Be = (e, t) => {
49
+ const n = L(e), r = n.findIndex((o) => x(o, t.value));
50
+ return De(n, r, { loop: t.loop ?? t.loopFocus });
51
+ }, Ke = (e, t) => {
52
+ const n = L(e), r = n.findIndex((o) => x(o, t.value));
53
+ return _e(n, r, { loop: t.loop ?? t.loopFocus });
54
+ }, $e = (e, t) => {
55
+ const n = L(e), r = n.find((o) => x(o, t.value));
56
+ return re(n, { state: t.typeaheadState, key: t.key, activeId: (r == null ? void 0 : r.id) ?? null });
57
+ }, H = (e) => Re(e) && (e.dataset.disabled === "" || e.hasAttribute("disabled")), Xe = (e) => {
58
+ var t;
59
+ return !!((t = e == null ? void 0 : e.getAttribute("role")) != null && t.startsWith("menuitem")) && !!(e != null && e.hasAttribute("aria-controls"));
60
+ }, W = "menu:select";
61
+ function Ye(e, t) {
62
+ if (!e) return;
63
+ const n = ye(e), r = new n.CustomEvent(W, { detail: { value: t } });
64
+ e.dispatchEvent(r);
65
+ }
66
+ function ot(e, t) {
67
+ const { context: n, send: r, state: o, computed: g, prop: a, scope: l } = e, c = o.hasTag("open"), P = g("isSubmenu"), A = g("isTypingAhead"), B = a("composite"), K = n.get("currentPlacement"), ge = n.get("anchorPoint"), R = n.get("highlightedValue"), G = Ae({
68
+ ...a("positioning"),
69
+ placement: ge ? "bottom" : K
88
70
  });
89
- function m(n) {
71
+ function V(i) {
90
72
  return {
91
- disabled: !!n.disabled,
92
- highlighted: t.context.highlightedValue === n.value
73
+ id: N(l, i.value),
74
+ disabled: !!i.disabled,
75
+ highlighted: R === i.value
93
76
  };
94
77
  }
95
- function P(n) {
96
- const s = n.valueText ?? n.value;
97
- return { ...n, id: n.value, valueText: s };
78
+ function $(i) {
79
+ const s = i.valueText ?? i.value;
80
+ return { ...i, id: i.value, valueText: s };
98
81
  }
99
- function S(n) {
82
+ function M(i) {
100
83
  return {
101
- ...m(P(n)),
102
- checked: !!n.checked
84
+ ...V($(i)),
85
+ checked: !!i.checked
103
86
  };
104
87
  }
105
- function v(n) {
106
- const { value: s, closeOnSelect: T, valueText: O } = n, c = m(n);
107
- return e.element({
108
- ...p.item.attrs,
109
- id: s,
88
+ function F(i) {
89
+ const { closeOnSelect: s, valueText: p, value: h } = i, O = V(i), T = N(l, h);
90
+ return t.element({
91
+ ...E.item.attrs,
92
+ id: T,
110
93
  role: "menuitem",
111
- "aria-disabled": c.disabled,
112
- "data-disabled": C(c.disabled),
113
- "data-ownedby": a.getContentId(t.context),
114
- "data-highlighted": C(c.highlighted),
115
- "data-valuetext": O,
116
- onDragStart(u) {
117
- u.currentTarget.matches("a[href]") && u.preventDefault();
94
+ "aria-disabled": Ce(O.disabled),
95
+ "data-disabled": C(O.disabled),
96
+ "data-ownedby": S(l),
97
+ "data-highlighted": C(O.highlighted),
98
+ "data-value": h,
99
+ "data-valuetext": p,
100
+ onDragStart(d) {
101
+ d.currentTarget.matches("a[href]") && d.preventDefault();
118
102
  },
119
- onPointerMove(u) {
120
- if (c.disabled || u.pointerType !== "mouse") return;
121
- const h = u.currentTarget;
122
- c.highlighted || o({ type: "ITEM_POINTERMOVE", id: s, target: h, closeOnSelect: T });
103
+ onPointerMove(d) {
104
+ if (O.disabled || d.pointerType !== "mouse") return;
105
+ const u = d.currentTarget;
106
+ O.highlighted || r({ type: "ITEM_POINTERMOVE", id: T, target: u, closeOnSelect: s });
123
107
  },
124
- onPointerLeave(u) {
125
- if (c.disabled || u.pointerType !== "mouse" || !t.previousEvent.type.includes("POINTER")) return;
126
- const I = u.currentTarget;
127
- o({ type: "ITEM_POINTERLEAVE", id: s, target: I, closeOnSelect: T });
108
+ onPointerLeave(d) {
109
+ var X;
110
+ if (O.disabled || d.pointerType !== "mouse" || !((X = e.event.previous()) == null ? void 0 : X.type.includes("POINTER"))) return;
111
+ const y = d.currentTarget;
112
+ r({ type: "ITEM_POINTERLEAVE", id: T, target: y, closeOnSelect: s });
128
113
  },
129
- onPointerDown(u) {
130
- if (c.disabled) return;
131
- const h = u.currentTarget;
132
- o({ type: "ITEM_POINTERDOWN", target: h, id: s, closeOnSelect: T });
114
+ onPointerDown(d) {
115
+ if (O.disabled) return;
116
+ const u = d.currentTarget;
117
+ r({ type: "ITEM_POINTERDOWN", target: u, id: T, closeOnSelect: s });
133
118
  },
134
- onClick(u) {
135
- if (A(u) || M(u) || c.disabled) return;
136
- const h = u.currentTarget;
137
- o({ type: "ITEM_CLICK", target: h, id: s, closeOnSelect: T });
119
+ onClick(d) {
120
+ if (Y(d) || q(d) || O.disabled) return;
121
+ const u = d.currentTarget;
122
+ r({ type: "ITEM_CLICK", target: u, id: T, closeOnSelect: s });
138
123
  }
139
124
  });
140
125
  }
141
126
  return {
142
- highlightedValue: t.context.highlightedValue,
143
- open: g,
144
- setOpen(n) {
145
- n !== g && o(n ? "OPEN" : "CLOSE");
127
+ highlightedValue: R,
128
+ open: c,
129
+ setOpen(i) {
130
+ o.hasTag("open") !== i && r({ type: i ? "OPEN" : "CLOSE" });
131
+ },
132
+ setHighlightedValue(i) {
133
+ r({ type: "HIGHLIGHTED.SET", value: i });
146
134
  },
147
- setHighlightedValue(n) {
148
- o({ type: "HIGHLIGHTED.SET", id: n });
135
+ setParent(i) {
136
+ r({ type: "PARENT.SET", value: i, id: i.prop("id") });
149
137
  },
150
- setParent(n) {
151
- o({ type: "PARENT.SET", value: n, id: n.state.context.id });
138
+ setChild(i) {
139
+ r({ type: "CHILD.SET", value: i, id: i.prop("id") });
152
140
  },
153
- setChild(n) {
154
- o({ type: "CHILD.SET", value: n, id: n.state.context.id });
141
+ reposition(i = {}) {
142
+ r({ type: "POSITIONING.SET", options: i });
155
143
  },
156
- reposition(n = {}) {
157
- o({ type: "POSITIONING.SET", options: n });
144
+ addItemListener(i) {
145
+ const s = l.getById(i.id);
146
+ if (!s) return;
147
+ const p = () => {
148
+ var h;
149
+ return (h = i.onSelect) == null ? void 0 : h.call(i);
150
+ };
151
+ return s.addEventListener(W, p), () => s.removeEventListener(W, p);
158
152
  },
159
153
  getContextTriggerProps() {
160
- return e.element({
161
- ...p.contextTrigger.attrs,
162
- dir: t.context.dir,
163
- id: a.getContextTriggerId(t.context),
164
- onPointerDown(n) {
165
- if (n.pointerType === "mouse") return;
166
- const s = L(n);
167
- o({ type: "CONTEXT_MENU_START", point: s });
154
+ return t.element({
155
+ ...E.contextTrigger.attrs,
156
+ dir: a("dir"),
157
+ id: ae(l),
158
+ onPointerDown(i) {
159
+ if (i.pointerType === "mouse") return;
160
+ const s = _(i);
161
+ r({ type: "CONTEXT_MENU_START", point: s });
168
162
  },
169
- onPointerCancel(n) {
170
- n.pointerType !== "mouse" && o("CONTEXT_MENU_CANCEL");
163
+ onPointerCancel(i) {
164
+ i.pointerType !== "mouse" && r({ type: "CONTEXT_MENU_CANCEL" });
171
165
  },
172
- onPointerMove(n) {
173
- n.pointerType !== "mouse" && o("CONTEXT_MENU_CANCEL");
166
+ onPointerMove(i) {
167
+ i.pointerType !== "mouse" && r({ type: "CONTEXT_MENU_CANCEL" });
174
168
  },
175
- onPointerUp(n) {
176
- n.pointerType !== "mouse" && o("CONTEXT_MENU_CANCEL");
169
+ onPointerUp(i) {
170
+ i.pointerType !== "mouse" && r({ type: "CONTEXT_MENU_CANCEL" });
177
171
  },
178
- onContextMenu(n) {
179
- const s = L(n);
180
- o({ type: "CONTEXT_MENU", point: s }), n.preventDefault();
172
+ onContextMenu(i) {
173
+ const s = _(i);
174
+ r({ type: "CONTEXT_MENU", point: s }), i.preventDefault();
181
175
  },
182
176
  style: {
183
177
  WebkitTouchCallout: "none",
@@ -186,919 +180,1039 @@ function be(t, o, e) {
186
180
  }
187
181
  });
188
182
  },
189
- getTriggerItemProps(n) {
190
- return W(
191
- v({ value: n.getTriggerProps().id }),
192
- n.getTriggerProps()
193
- );
183
+ getTriggerItemProps(i) {
184
+ const s = i.getTriggerProps();
185
+ return he(F({ value: s.id }), s);
194
186
  },
195
187
  getTriggerProps() {
196
- return e.button({
197
- ...i ? p.triggerItem.attrs : p.trigger.attrs,
198
- "data-placement": t.context.currentPlacement,
188
+ return t.button({
189
+ ...P ? E.triggerItem.attrs : E.trigger.attrs,
190
+ "data-placement": n.get("currentPlacement"),
199
191
  type: "button",
200
- dir: t.context.dir,
201
- id: a.getTriggerId(t.context),
202
- "data-uid": t.context.id,
203
- "aria-haspopup": l ? "menu" : "dialog",
204
- "aria-controls": a.getContentId(t.context),
205
- "aria-expanded": g || void 0,
206
- "data-state": g ? "open" : "closed",
207
- onPointerMove(n) {
208
- n.pointerType !== "mouse" || a.isTargetDisabled(n.currentTarget) || !i || o({ type: "TRIGGER_POINTERMOVE", target: n.currentTarget });
192
+ dir: a("dir"),
193
+ id: w(l),
194
+ "data-uid": a("id"),
195
+ "aria-haspopup": B ? "menu" : "dialog",
196
+ "aria-controls": S(l),
197
+ "aria-expanded": c || void 0,
198
+ "data-state": c ? "open" : "closed",
199
+ onPointerMove(i) {
200
+ if (i.pointerType !== "mouse" || H(i.currentTarget) || !P) return;
201
+ const p = _(i);
202
+ r({ type: "TRIGGER_POINTERMOVE", target: i.currentTarget, point: p });
209
203
  },
210
- onPointerLeave(n) {
211
- if (a.isTargetDisabled(n.currentTarget) || n.pointerType !== "mouse" || !i) return;
212
- const s = L(n);
213
- o({ type: "TRIGGER_POINTERLEAVE", target: n.currentTarget, point: s });
204
+ onPointerLeave(i) {
205
+ if (H(i.currentTarget) || i.pointerType !== "mouse" || !P) return;
206
+ const s = _(i);
207
+ r({
208
+ type: "TRIGGER_POINTERLEAVE",
209
+ target: i.currentTarget,
210
+ point: s
211
+ });
214
212
  },
215
- onPointerDown(n) {
216
- a.isTargetDisabled(n.currentTarget) || X(n) || n.preventDefault();
213
+ onPointerDown(i) {
214
+ H(i.currentTarget) || Pe(i) || i.preventDefault();
217
215
  },
218
- onClick(n) {
219
- n.defaultPrevented || a.isTargetDisabled(n.currentTarget) || o({ type: "TRIGGER_CLICK", target: n.currentTarget });
216
+ onClick(i) {
217
+ i.defaultPrevented || H(i.currentTarget) || r({ type: "TRIGGER_CLICK", target: i.currentTarget });
220
218
  },
221
219
  onBlur() {
222
- o("TRIGGER_BLUR");
220
+ r({ type: "TRIGGER_BLUR" });
223
221
  },
224
222
  onFocus() {
225
- o("TRIGGER_FOCUS");
223
+ r({ type: "TRIGGER_FOCUS" });
226
224
  },
227
- onKeyDown(n) {
228
- if (n.defaultPrevented) return;
225
+ onKeyDown(i) {
226
+ if (i.defaultPrevented) return;
229
227
  const s = {
230
228
  ArrowDown() {
231
- o("ARROW_DOWN");
229
+ r({ type: "ARROW_DOWN" });
232
230
  },
233
231
  ArrowUp() {
234
- o("ARROW_UP");
232
+ r({ type: "ARROW_UP" });
235
233
  },
236
234
  Enter() {
237
- o({ type: "ARROW_DOWN", src: "enter" });
235
+ r({ type: "ARROW_DOWN", src: "enter" });
238
236
  },
239
237
  Space() {
240
- o({ type: "ARROW_DOWN", src: "space" });
238
+ r({ type: "ARROW_DOWN", src: "space" });
241
239
  }
242
- }, T = k(n, t.context), O = s[T];
243
- O && (n.preventDefault(), O(n));
240
+ }, p = j(i, {
241
+ orientation: "vertical",
242
+ dir: a("dir")
243
+ }), h = s[p];
244
+ h && (i.preventDefault(), h(i));
244
245
  }
245
246
  });
246
247
  },
247
248
  getIndicatorProps() {
248
- return e.element({
249
- ...p.indicator.attrs,
250
- dir: t.context.dir,
251
- "data-state": g ? "open" : "closed"
249
+ return t.element({
250
+ ...E.indicator.attrs,
251
+ dir: a("dir"),
252
+ "data-state": c ? "open" : "closed"
252
253
  });
253
254
  },
254
255
  getPositionerProps() {
255
- return e.element({
256
- ...p.positioner.attrs,
257
- dir: t.context.dir,
258
- id: a.getPositionerId(t.context),
259
- style: d.floating
256
+ return t.element({
257
+ ...E.positioner.attrs,
258
+ dir: a("dir"),
259
+ id: se(l),
260
+ style: G.floating
260
261
  });
261
262
  },
262
263
  getArrowProps() {
263
- return e.element({
264
- id: a.getArrowId(t.context),
265
- ...p.arrow.attrs,
266
- dir: t.context.dir,
267
- style: d.arrow
264
+ return t.element({
265
+ id: Fe(l),
266
+ ...E.arrow.attrs,
267
+ dir: a("dir"),
268
+ style: G.arrow
268
269
  });
269
270
  },
270
271
  getArrowTipProps() {
271
- return e.element({
272
- ...p.arrowTip.attrs,
273
- dir: t.context.dir,
274
- style: d.arrowTip
272
+ return t.element({
273
+ ...E.arrowTip.attrs,
274
+ dir: a("dir"),
275
+ style: G.arrowTip
275
276
  });
276
277
  },
277
278
  getContentProps() {
278
- return e.element({
279
- ...p.content.attrs,
280
- id: a.getContentId(t.context),
281
- "aria-label": t.context["aria-label"],
282
- hidden: !g,
283
- "data-state": g ? "open" : "closed",
284
- role: l ? "menu" : "dialog",
279
+ return t.element({
280
+ ...E.content.attrs,
281
+ id: S(l),
282
+ "aria-label": a("aria-label"),
283
+ hidden: !c,
284
+ "data-state": c ? "open" : "closed",
285
+ role: B ? "menu" : "dialog",
285
286
  tabIndex: 0,
286
- dir: t.context.dir,
287
- "aria-activedescendant": t.context.highlightedValue ?? void 0,
288
- "aria-labelledby": a.getTriggerId(t.context),
289
- "data-placement": t.context.currentPlacement,
290
- onPointerEnter(n) {
291
- n.pointerType === "mouse" && o("MENU_POINTERENTER");
287
+ dir: a("dir"),
288
+ "aria-activedescendant": g("highlightedId") || void 0,
289
+ "aria-labelledby": w(l),
290
+ "data-placement": K,
291
+ onPointerEnter(i) {
292
+ i.pointerType === "mouse" && r({ type: "MENU_POINTERENTER" });
292
293
  },
293
- onKeyDown(n) {
294
- if (n.defaultPrevented || !x(n)) return;
295
- const s = z(n);
296
- if (!((s == null ? void 0 : s.closest("[role=menu]")) === n.currentTarget || s === n.currentTarget)) return;
297
- if (n.key === "Tab" && !ee(n)) {
298
- n.preventDefault();
294
+ onKeyDown(i) {
295
+ if (i.defaultPrevented || !me(i)) return;
296
+ const s = oe(i);
297
+ if (!((s == null ? void 0 : s.closest("[role=menu]")) === i.currentTarget || s === i.currentTarget)) return;
298
+ if (i.key === "Tab" && !Te(i)) {
299
+ i.preventDefault();
299
300
  return;
300
301
  }
301
- const O = a.getHighlightedItemEl(t.context), c = {
302
+ const h = le(l, R), O = {
302
303
  ArrowDown() {
303
- o("ARROW_DOWN");
304
+ r({ type: "ARROW_DOWN" });
304
305
  },
305
306
  ArrowUp() {
306
- o("ARROW_UP");
307
+ r({ type: "ARROW_UP" });
307
308
  },
308
309
  ArrowLeft() {
309
- o("ARROW_LEFT");
310
+ r({ type: "ARROW_LEFT" });
310
311
  },
311
312
  ArrowRight() {
312
- o("ARROW_RIGHT");
313
+ r({ type: "ARROW_RIGHT" });
313
314
  },
314
315
  Enter() {
315
- o("ENTER"), $(O);
316
+ var u;
317
+ r({ type: "ENTER" }), R != null && ve(h) && ((u = a("navigate")) == null || u({ value: R, node: h, href: h.href }));
316
318
  },
317
- Space(I) {
318
- var N;
319
- r ? o({ type: "TYPEAHEAD", key: I.key }) : (N = c.Enter) == null || N.call(c, I);
319
+ Space(u) {
320
+ var y;
321
+ A ? r({ type: "TYPEAHEAD", key: u.key }) : (y = O.Enter) == null || y.call(O, u);
320
322
  },
321
323
  Home() {
322
- o("HOME");
324
+ r({ type: "HOME" });
323
325
  },
324
326
  End() {
325
- o("END");
327
+ r({ type: "END" });
326
328
  }
327
- }, u = k(n, { dir: t.context.dir }), h = c[u];
328
- if (h) {
329
- h(n), n.stopPropagation(), n.preventDefault();
329
+ }, T = j(i, { dir: a("dir") }), d = O[T];
330
+ if (d) {
331
+ d(i), i.stopPropagation(), i.preventDefault();
330
332
  return;
331
333
  }
332
- t.context.typeahead && K(n) && (Y(n) || G(s) || (o({ type: "TYPEAHEAD", key: n.key }), n.preventDefault()));
334
+ a("typeahead") && Ie(i) && (fe(i) || ie(s) || (r({ type: "TYPEAHEAD", key: i.key }), i.preventDefault()));
333
335
  }
334
336
  });
335
337
  },
336
338
  getSeparatorProps() {
337
- return e.element({
338
- ...p.separator.attrs,
339
+ return t.element({
340
+ ...E.separator.attrs,
339
341
  role: "separator",
340
- dir: t.context.dir,
342
+ dir: a("dir"),
341
343
  "aria-orientation": "horizontal"
342
344
  });
343
345
  },
344
- getItemState: m,
345
- getItemProps: v,
346
- getOptionItemState: S,
347
- getOptionItemProps(n) {
348
- const { type: s, disabled: T, onCheckedChange: O, closeOnSelect: c } = n, u = P(n), h = S(n);
346
+ getItemState: V,
347
+ getItemProps: F,
348
+ getOptionItemState: M,
349
+ getOptionItemProps(i) {
350
+ const { type: s, disabled: p, onCheckedChange: h, closeOnSelect: O } = i, T = $(i), d = M(i);
349
351
  return {
350
- ...v(u),
351
- ...e.element({
352
+ ...F(T),
353
+ ...t.element({
352
354
  "data-type": s,
353
- ...p.item.attrs,
354
- dir: t.context.dir,
355
- "data-value": u.value,
355
+ ...E.item.attrs,
356
+ dir: a("dir"),
357
+ "data-value": T.value,
356
358
  role: `menuitem${s}`,
357
- "aria-checked": !!h.checked,
358
- "data-state": h.checked ? "checked" : "unchecked",
359
- onClick(I) {
360
- if (T || A(I) || M(I)) return;
361
- const N = I.currentTarget;
362
- o({ type: "ITEM_CLICK", target: N, option: u, closeOnSelect: c }), O == null || O(!h.checked);
359
+ "aria-checked": !!d.checked,
360
+ "data-state": d.checked ? "checked" : "unchecked",
361
+ onClick(u) {
362
+ if (p || Y(u) || q(u)) return;
363
+ const y = u.currentTarget;
364
+ r({ type: "ITEM_CLICK", target: y, option: T, closeOnSelect: O }), h == null || h(!d.checked);
363
365
  }
364
366
  })
365
367
  };
366
368
  },
367
- getItemIndicatorProps(n) {
368
- const s = S(n);
369
- return e.element({
370
- ...p.itemIndicator.attrs,
371
- dir: t.context.dir,
369
+ getItemIndicatorProps(i) {
370
+ const s = M(Z(i)), p = s.checked ? "checked" : "unchecked";
371
+ return t.element({
372
+ ...E.itemIndicator.attrs,
373
+ dir: a("dir"),
372
374
  "data-disabled": C(s.disabled),
373
375
  "data-highlighted": C(s.highlighted),
374
- "data-state": s.checked ? "checked" : "unchecked",
375
- hidden: !s.checked
376
+ "data-state": U(i, "checked") ? p : void 0,
377
+ hidden: U(i, "checked") ? !s.checked : void 0
376
378
  });
377
379
  },
378
- getItemTextProps(n) {
379
- const s = S(n);
380
- return e.element({
381
- ...p.itemText.attrs,
382
- dir: t.context.dir,
380
+ getItemTextProps(i) {
381
+ const s = M(Z(i)), p = s.checked ? "checked" : "unchecked";
382
+ return t.element({
383
+ ...E.itemText.attrs,
384
+ dir: a("dir"),
383
385
  "data-disabled": C(s.disabled),
384
386
  "data-highlighted": C(s.highlighted),
385
- "data-state": s.checked ? "checked" : "unchecked"
387
+ "data-state": U(i, "checked") ? p : void 0
386
388
  });
387
389
  },
388
- getItemGroupLabelProps(n) {
389
- return e.element({
390
- id: a.getGroupLabelId(t.context, n.htmlFor),
391
- dir: t.context.dir,
392
- ...p.itemGroupLabel.attrs
390
+ getItemGroupLabelProps(i) {
391
+ return t.element({
392
+ ...E.itemGroupLabel.attrs,
393
+ id: z(l, i.htmlFor),
394
+ dir: a("dir")
393
395
  });
394
396
  },
395
- getItemGroupProps(n) {
396
- return e.element({
397
- id: a.getGroupId(t.context, n.id),
398
- ...p.itemGroup.attrs,
399
- dir: t.context.dir,
400
- "aria-labelledby": a.getGroupLabelId(t.context, n.id),
397
+ getItemGroupProps(i) {
398
+ return t.element({
399
+ id: Ue(l, i.id),
400
+ ...E.itemGroup.attrs,
401
+ dir: a("dir"),
402
+ "aria-labelledby": z(l, i.id),
401
403
  role: "group"
402
404
  });
403
405
  }
404
406
  };
405
407
  }
406
- var { not: E, and: R, or: Oe } = F;
407
- function ve(t) {
408
- const o = se(t);
409
- return V(
410
- {
411
- id: "menu",
412
- initial: o.open ? "open" : "idle",
413
- context: {
414
- highlightedValue: null,
415
- loopFocus: !1,
416
- anchorPoint: null,
417
- closeOnSelect: !0,
418
- typeahead: !0,
419
- composite: !0,
420
- ...o,
421
- positioning: {
422
- placement: "bottom-start",
423
- gutter: 8,
424
- ...o.positioning
425
- },
426
- intentPolygon: null,
427
- parent: null,
428
- lastHighlightedValue: null,
429
- children: le(_({})),
430
- suspendPointer: !1,
431
- restoreFocus: !0,
432
- typeaheadState: w.defaultOptions
408
+ var { not: m, and: v, or: qe } = ce(), at = ue({
409
+ props({ props: e }) {
410
+ return {
411
+ closeOnSelect: !0,
412
+ typeahead: !0,
413
+ composite: !0,
414
+ loopFocus: !1,
415
+ navigate(t) {
416
+ Ee(t.node);
433
417
  },
434
- computed: {
435
- isSubmenu: (e) => e.parent !== null,
436
- isRtl: (e) => e.dir === "rtl",
437
- isTypingAhead: (e) => e.typeaheadState.keysSoFar !== ""
418
+ ...e,
419
+ positioning: {
420
+ placement: "bottom-start",
421
+ gutter: 8,
422
+ ...e.positioning
423
+ }
424
+ };
425
+ },
426
+ initialState({ prop: e }) {
427
+ return e("open") || e("defaultOpen") ? "open" : "idle";
428
+ },
429
+ context({ bindable: e, prop: t }) {
430
+ return {
431
+ suspendPointer: e(() => ({
432
+ defaultValue: !1
433
+ })),
434
+ highlightedValue: e(() => ({
435
+ defaultValue: t("defaultHighlightedValue") || null,
436
+ value: t("highlightedValue"),
437
+ onChange(n) {
438
+ var r;
439
+ (r = t("onHighlightChange")) == null || r({ highlightedValue: n });
440
+ }
441
+ })),
442
+ lastHighlightedValue: e(() => ({
443
+ defaultValue: null
444
+ })),
445
+ currentPlacement: e(() => ({
446
+ defaultValue: void 0
447
+ })),
448
+ intentPolygon: e(() => ({
449
+ defaultValue: null
450
+ })),
451
+ anchorPoint: e(() => ({
452
+ defaultValue: null,
453
+ hash(n) {
454
+ return `x: ${n == null ? void 0 : n.x}, y: ${n == null ? void 0 : n.y}`;
455
+ }
456
+ }))
457
+ };
458
+ },
459
+ refs() {
460
+ return {
461
+ parent: null,
462
+ children: {},
463
+ typeaheadState: { ...re.defaultOptions },
464
+ positioningOverride: {}
465
+ };
466
+ },
467
+ computed: {
468
+ isSubmenu: ({ refs: e }) => e.get("parent") != null,
469
+ isRtl: ({ prop: e }) => e("dir") === "rtl",
470
+ isTypingAhead: ({ refs: e }) => e.get("typeaheadState").keysSoFar !== "",
471
+ highlightedId: ({ context: e, scope: t, refs: n }) => Je(n.get("children"), e.get("highlightedValue"), t)
472
+ },
473
+ watch({ track: e, action: t, context: n, computed: r, prop: o }) {
474
+ e([() => r("isSubmenu")], () => {
475
+ t(["setSubmenuPlacement"]);
476
+ }), e([() => n.hash("anchorPoint")], () => {
477
+ t(["reposition"]);
478
+ }), e([() => o("open")], () => {
479
+ t(["toggleVisibility"]);
480
+ });
481
+ },
482
+ on: {
483
+ "PARENT.SET": {
484
+ actions: ["setParentMenu"]
485
+ },
486
+ "CHILD.SET": {
487
+ actions: ["setChildMenu"]
488
+ },
489
+ OPEN: [
490
+ {
491
+ guard: "isOpenControlled",
492
+ actions: ["invokeOnOpen"]
493
+ },
494
+ {
495
+ target: "open",
496
+ actions: ["invokeOnOpen"]
497
+ }
498
+ ],
499
+ OPEN_AUTOFOCUS: [
500
+ {
501
+ guard: "isOpenControlled",
502
+ actions: ["invokeOnOpen"]
438
503
  },
439
- watch: {
440
- isSubmenu: "setSubmenuPlacement",
441
- anchorPoint: "reposition",
442
- open: "toggleVisibility"
504
+ {
505
+ // internal: true,
506
+ target: "open",
507
+ actions: ["highlightFirstItem", "invokeOnOpen"]
508
+ }
509
+ ],
510
+ CLOSE: [
511
+ {
512
+ guard: "isOpenControlled",
513
+ actions: ["invokeOnClose"]
443
514
  },
515
+ {
516
+ target: "closed",
517
+ actions: ["invokeOnClose"]
518
+ }
519
+ ],
520
+ "HIGHLIGHTED.RESTORE": {
521
+ actions: ["restoreHighlightedItem"]
522
+ },
523
+ "HIGHLIGHTED.SET": {
524
+ actions: ["setHighlightedItem"]
525
+ }
526
+ },
527
+ states: {
528
+ idle: {
529
+ tags: ["closed"],
444
530
  on: {
445
- "PARENT.SET": {
446
- actions: "setParentMenu"
531
+ "CONTROLLED.OPEN": {
532
+ target: "open"
447
533
  },
448
- "CHILD.SET": {
449
- actions: "setChildMenu"
534
+ "CONTROLLED.CLOSE": {
535
+ target: "closed"
450
536
  },
451
- OPEN: [
537
+ CONTEXT_MENU_START: {
538
+ target: "opening:contextmenu",
539
+ actions: ["setAnchorPoint"]
540
+ },
541
+ CONTEXT_MENU: [
452
542
  {
453
543
  guard: "isOpenControlled",
454
- actions: "invokeOnOpen"
544
+ actions: ["setAnchorPoint", "invokeOnOpen"]
455
545
  },
456
546
  {
457
547
  target: "open",
458
- actions: "invokeOnOpen"
548
+ actions: ["setAnchorPoint", "invokeOnOpen"]
459
549
  }
460
550
  ],
461
- OPEN_AUTOFOCUS: [
551
+ TRIGGER_CLICK: [
462
552
  {
463
553
  guard: "isOpenControlled",
464
554
  actions: ["invokeOnOpen"]
465
555
  },
466
556
  {
467
- internal: !0,
468
557
  target: "open",
469
- actions: ["highlightFirstItem", "invokeOnOpen"]
558
+ actions: ["invokeOnOpen"]
470
559
  }
471
560
  ],
472
- CLOSE: [
561
+ TRIGGER_FOCUS: {
562
+ guard: m("isSubmenu"),
563
+ target: "closed"
564
+ },
565
+ TRIGGER_POINTERMOVE: {
566
+ guard: "isSubmenu",
567
+ target: "opening"
568
+ }
569
+ }
570
+ },
571
+ "opening:contextmenu": {
572
+ tags: ["closed"],
573
+ effects: ["waitForLongPress"],
574
+ on: {
575
+ "CONTROLLED.OPEN": { target: "open" },
576
+ "CONTROLLED.CLOSE": { target: "closed" },
577
+ CONTEXT_MENU_CANCEL: [
473
578
  {
474
579
  guard: "isOpenControlled",
475
- actions: "invokeOnClose"
580
+ actions: ["invokeOnClose"]
476
581
  },
477
582
  {
478
583
  target: "closed",
479
- actions: "invokeOnClose"
584
+ actions: ["invokeOnClose"]
480
585
  }
481
586
  ],
482
- "HIGHLIGHTED.RESTORE": {
483
- actions: "restoreHighlightedItem"
484
- },
485
- "HIGHLIGHTED.SET": {
486
- actions: "setHighlightedItem"
487
- }
488
- },
489
- states: {
490
- idle: {
491
- tags: ["closed"],
492
- on: {
493
- "CONTROLLED.OPEN": "open",
494
- "CONTROLLED.CLOSE": "closed",
495
- CONTEXT_MENU_START: {
496
- target: "opening:contextmenu",
497
- actions: "setAnchorPoint"
498
- },
499
- CONTEXT_MENU: [
500
- {
501
- guard: "isOpenControlled",
502
- actions: ["setAnchorPoint", "invokeOnOpen"]
503
- },
504
- {
505
- target: "open",
506
- actions: ["setAnchorPoint", "invokeOnOpen"]
507
- }
508
- ],
509
- TRIGGER_CLICK: [
510
- {
511
- guard: "isOpenControlled",
512
- actions: "invokeOnOpen"
513
- },
514
- {
515
- target: "open",
516
- actions: "invokeOnOpen"
517
- }
518
- ],
519
- TRIGGER_FOCUS: {
520
- guard: E("isSubmenu"),
521
- target: "closed"
522
- },
523
- TRIGGER_POINTERMOVE: {
524
- guard: "isSubmenu",
525
- target: "opening"
526
- }
527
- }
528
- },
529
- "opening:contextmenu": {
530
- tags: ["closed"],
531
- after: {
532
- LONG_PRESS_DELAY: [
533
- {
534
- guard: "isOpenControlled",
535
- actions: "invokeOnOpen"
536
- },
537
- {
538
- target: "open",
539
- actions: "invokeOnOpen"
540
- }
541
- ]
587
+ "LONG_PRESS.OPEN": [
588
+ {
589
+ guard: "isOpenControlled",
590
+ actions: ["invokeOnOpen"]
542
591
  },
543
- on: {
544
- "CONTROLLED.OPEN": "open",
545
- "CONTROLLED.CLOSE": "closed",
546
- CONTEXT_MENU_CANCEL: [
547
- {
548
- guard: "isOpenControlled",
549
- actions: "invokeOnClose"
550
- },
551
- {
552
- target: "closed",
553
- actions: "invokeOnClose"
554
- }
555
- ]
592
+ {
593
+ target: "open",
594
+ actions: ["invokeOnOpen"]
556
595
  }
596
+ ]
597
+ }
598
+ },
599
+ opening: {
600
+ tags: ["closed"],
601
+ effects: ["waitForOpenDelay"],
602
+ on: {
603
+ "CONTROLLED.OPEN": {
604
+ target: "open"
557
605
  },
558
- opening: {
559
- tags: ["closed"],
560
- after: {
561
- SUBMENU_OPEN_DELAY: [
562
- {
563
- guard: "isOpenControlled",
564
- actions: "invokeOnOpen"
565
- },
566
- {
567
- target: "open",
568
- actions: "invokeOnOpen"
569
- }
570
- ]
571
- },
572
- on: {
573
- "CONTROLLED.OPEN": "open",
574
- "CONTROLLED.CLOSE": "closed",
575
- BLUR: [
576
- {
577
- guard: "isOpenControlled",
578
- actions: "invokeOnClose"
579
- },
580
- {
581
- target: "closed",
582
- actions: "invokeOnClose"
583
- }
584
- ],
585
- TRIGGER_POINTERLEAVE: [
586
- {
587
- guard: "isOpenControlled",
588
- actions: "invokeOnClose"
589
- },
590
- {
591
- target: "closed",
592
- actions: "invokeOnClose"
593
- }
594
- ]
595
- }
606
+ "CONTROLLED.CLOSE": {
607
+ target: "closed"
596
608
  },
597
- closing: {
598
- tags: ["open"],
599
- activities: ["trackPointerMove", "trackInteractOutside"],
600
- after: {
601
- SUBMENU_CLOSE_DELAY: [
602
- {
603
- guard: "isOpenControlled",
604
- actions: ["invokeOnClose"]
605
- },
606
- {
607
- target: "closed",
608
- actions: ["focusParentMenu", "restoreParentHiglightedItem", "invokeOnClose"]
609
- }
610
- ]
609
+ BLUR: [
610
+ {
611
+ guard: "isOpenControlled",
612
+ actions: ["invokeOnClose"]
611
613
  },
612
- on: {
613
- "CONTROLLED.OPEN": "open",
614
- "CONTROLLED.CLOSE": {
615
- target: "closed",
616
- actions: ["focusParentMenu", "restoreParentHiglightedItem"]
617
- },
618
- // don't invoke on open here since the menu is still open (we're only keeping it open)
619
- MENU_POINTERENTER: {
620
- target: "open",
621
- actions: "clearIntentPolygon"
622
- },
623
- POINTER_MOVED_AWAY_FROM_SUBMENU: [
624
- {
625
- guard: "isOpenControlled",
626
- actions: "invokeOnClose"
627
- },
628
- {
629
- target: "closed",
630
- actions: ["focusParentMenu", "restoreParentHiglightedItem"]
631
- }
632
- ]
614
+ {
615
+ target: "closed",
616
+ actions: ["invokeOnClose"]
633
617
  }
634
- },
635
- closed: {
636
- tags: ["closed"],
637
- entry: ["clearHighlightedItem", "focusTrigger", "resumePointer"],
638
- on: {
639
- "CONTROLLED.OPEN": [
640
- {
641
- guard: Oe("isOpenAutoFocusEvent", "isArrowDownEvent"),
642
- target: "open",
643
- actions: "highlightFirstItem"
644
- },
645
- {
646
- guard: "isArrowUpEvent",
647
- target: "open",
648
- actions: "highlightLastItem"
649
- },
650
- {
651
- target: "open"
652
- }
653
- ],
654
- CONTEXT_MENU_START: {
655
- target: "opening:contextmenu",
656
- actions: "setAnchorPoint"
657
- },
658
- CONTEXT_MENU: [
659
- {
660
- guard: "isOpenControlled",
661
- actions: ["setAnchorPoint", "invokeOnOpen"]
662
- },
663
- {
664
- target: "open",
665
- actions: ["setAnchorPoint", "invokeOnOpen"]
666
- }
667
- ],
668
- TRIGGER_CLICK: [
669
- {
670
- guard: "isOpenControlled",
671
- actions: "invokeOnOpen"
672
- },
673
- {
674
- target: "open",
675
- actions: "invokeOnOpen"
676
- }
677
- ],
678
- TRIGGER_POINTERMOVE: {
679
- guard: "isTriggerItem",
680
- target: "opening"
681
- },
682
- TRIGGER_BLUR: "idle",
683
- ARROW_DOWN: [
684
- {
685
- guard: "isOpenControlled",
686
- actions: "invokeOnOpen"
687
- },
688
- {
689
- target: "open",
690
- actions: ["highlightFirstItem", "invokeOnOpen"]
691
- }
692
- ],
693
- ARROW_UP: [
694
- {
695
- guard: "isOpenControlled",
696
- actions: "invokeOnOpen"
697
- },
698
- {
699
- target: "open",
700
- actions: ["highlightLastItem", "invokeOnOpen"]
701
- }
702
- ]
618
+ ],
619
+ TRIGGER_POINTERLEAVE: [
620
+ {
621
+ guard: "isOpenControlled",
622
+ actions: ["invokeOnClose"]
623
+ },
624
+ {
625
+ target: "closed",
626
+ actions: ["invokeOnClose"]
703
627
  }
704
- },
705
- open: {
706
- tags: ["open"],
707
- activities: ["trackInteractOutside", "trackPositioning", "scrollToHighlightedItem"],
708
- entry: ["focusMenu", "resumePointer"],
709
- on: {
710
- "CONTROLLED.CLOSE": [
711
- {
712
- target: "closed",
713
- guard: "isArrowLeftEvent",
714
- actions: ["focusParentMenu"]
715
- },
716
- {
717
- target: "closed"
718
- }
719
- ],
720
- TRIGGER_CLICK: [
721
- {
722
- guard: R(E("isTriggerItem"), "isOpenControlled"),
723
- actions: "invokeOnClose"
724
- },
725
- {
726
- guard: E("isTriggerItem"),
727
- target: "closed",
728
- actions: "invokeOnClose"
729
- }
730
- ],
731
- ARROW_UP: {
732
- actions: ["highlightPrevItem", "focusMenu"]
733
- },
734
- ARROW_DOWN: {
735
- actions: ["highlightNextItem", "focusMenu"]
736
- },
737
- ARROW_LEFT: [
738
- {
739
- guard: R("isSubmenu", "isOpenControlled"),
740
- actions: "invokeOnClose"
741
- },
742
- {
743
- guard: "isSubmenu",
744
- target: "closed",
745
- actions: ["focusParentMenu", "invokeOnClose"]
746
- }
747
- ],
748
- HOME: {
749
- actions: ["highlightFirstItem", "focusMenu"]
750
- },
751
- END: {
752
- actions: ["highlightLastItem", "focusMenu"]
753
- },
754
- ARROW_RIGHT: {
755
- guard: "isTriggerItemHighlighted",
756
- actions: "openSubmenu"
757
- },
758
- ENTER: [
759
- {
760
- guard: "isTriggerItemHighlighted",
761
- actions: "openSubmenu"
762
- },
763
- {
764
- actions: "clickHighlightedItem"
765
- }
766
- ],
767
- ITEM_POINTERMOVE: [
768
- {
769
- guard: E("suspendPointer"),
770
- actions: ["setHighlightedItem", "focusMenu"]
771
- },
772
- {
773
- actions: "setLastHighlightedItem"
774
- }
775
- ],
776
- ITEM_POINTERLEAVE: {
777
- guard: R(E("suspendPointer"), E("isTriggerItem")),
778
- actions: "clearHighlightedItem"
779
- },
780
- ITEM_CLICK: [
781
- // == grouped ==
782
- {
783
- guard: R(
784
- E("isTriggerItemHighlighted"),
785
- E("isHighlightedItemEditable"),
786
- "closeOnSelect",
787
- "isOpenControlled"
788
- ),
789
- actions: ["invokeOnSelect", "setOptionState", "closeRootMenu", "invokeOnClose"]
790
- },
791
- {
792
- guard: R(E("isTriggerItemHighlighted"), E("isHighlightedItemEditable"), "closeOnSelect"),
793
- target: "closed",
794
- actions: ["invokeOnSelect", "setOptionState", "closeRootMenu", "invokeOnClose"]
795
- },
796
- //
797
- {
798
- guard: R(E("isTriggerItemHighlighted"), E("isHighlightedItemEditable")),
799
- actions: ["invokeOnSelect", "setOptionState"]
800
- },
801
- { actions: "setHighlightedItem" }
802
- ],
803
- TRIGGER_POINTERLEAVE: {
804
- target: "closing",
805
- actions: "setIntentPolygon"
806
- },
807
- ITEM_POINTERDOWN: {
808
- actions: "setHighlightedItem"
809
- },
810
- TYPEAHEAD: {
811
- actions: "highlightMatchedItem"
812
- },
813
- FOCUS_MENU: {
814
- actions: "focusMenu"
815
- },
816
- "POSITIONING.SET": {
817
- actions: "reposition"
818
- }
628
+ ],
629
+ "DELAY.OPEN": [
630
+ {
631
+ guard: "isOpenControlled",
632
+ actions: ["invokeOnOpen"]
633
+ },
634
+ {
635
+ target: "open",
636
+ actions: ["invokeOnOpen"]
819
637
  }
820
- }
638
+ ]
821
639
  }
822
640
  },
823
- {
824
- delays: {
825
- LONG_PRESS_DELAY: 700,
826
- SUBMENU_OPEN_DELAY: 100,
827
- SUBMENU_CLOSE_DELAY: 100
828
- },
829
- guards: {
830
- closeOnSelect: (e, i) => !!((i == null ? void 0 : i.closeOnSelect) ?? e.closeOnSelect),
831
- // whether the trigger is also a menu item
832
- isTriggerItem: (e, i) => a.isTriggerItem(i.target),
833
- // whether the trigger item is the active item
834
- isTriggerItemHighlighted: (e, i) => {
835
- const r = i.target ?? a.getHighlightedItemEl(e);
836
- return !!(r != null && r.hasAttribute("aria-controls"));
837
- },
838
- isSubmenu: (e) => e.isSubmenu,
839
- suspendPointer: (e) => e.suspendPointer,
840
- isHighlightedItemEditable: (e) => G(a.getHighlightedItemEl(e)),
841
- isWithinPolygon: (e, i) => e.intentPolygon ? he(e.intentPolygon, i.point) : !1,
842
- // guard assertions (for controlled mode)
843
- isOpenControlled: (e) => !!e["open.controlled"],
844
- isArrowLeftEvent: (e, i) => {
845
- var r;
846
- return ((r = i.previousEvent) == null ? void 0 : r.type) === "ARROW_LEFT";
847
- },
848
- isArrowUpEvent: (e, i) => {
849
- var r;
850
- return ((r = i.previousEvent) == null ? void 0 : r.type) === "ARROW_UP";
851
- },
852
- isArrowDownEvent: (e, i) => {
853
- var r;
854
- return ((r = i.previousEvent) == null ? void 0 : r.type) === "ARROW_DOWN";
855
- },
856
- isOpenAutoFocusEvent: (e, i) => {
857
- var r;
858
- return ((r = i.previousEvent) == null ? void 0 : r.type) === "OPEN_AUTOFOCUS";
859
- }
860
- },
861
- activities: {
862
- trackPositioning(e) {
863
- if (e.anchorPoint) return;
864
- e.currentPlacement = e.positioning.placement;
865
- const i = () => a.getPositionerEl(e);
866
- return D(a.getTriggerEl(e), i, {
867
- ...e.positioning,
868
- defer: !0,
869
- onComplete(r) {
870
- e.currentPlacement = r.placement;
871
- }
872
- });
873
- },
874
- trackInteractOutside(e, i, { send: r }) {
875
- return ce(() => a.getContentEl(e), {
876
- defer: !0,
877
- exclude: [a.getTriggerEl(e)],
878
- onInteractOutside: e.onInteractOutside,
879
- onFocusOutside: e.onFocusOutside,
880
- onEscapeKeyDown(g) {
881
- var d;
882
- (d = e.onEscapeKeyDown) == null || d.call(e, g), e.isSubmenu && g.preventDefault(), H(e);
883
- },
884
- onPointerDownOutside(g) {
885
- var d;
886
- e.restoreFocus = !g.detail.focusable, (d = e.onPointerDownOutside) == null || d.call(e, g);
887
- },
888
- onDismiss() {
889
- r({ type: "CLOSE", src: "interact-outside" });
890
- }
891
- });
892
- },
893
- trackPointerMove(e, i, { guards: r, send: l }) {
894
- const { isWithinPolygon: g } = r;
895
- e.parent.state.context.suspendPointer = !0;
896
- const d = a.getDoc(e);
897
- return B(d, "pointermove", (m) => {
898
- const P = { x: m.clientX, y: m.clientY };
899
- g(e, { point: P }) || (l("POINTER_MOVED_AWAY_FROM_SUBMENU"), e.parent.state.context.suspendPointer = !1);
900
- });
901
- },
902
- scrollToHighlightedItem(e, i, { getState: r }) {
903
- const l = () => {
904
- if (r().event.type.startsWith("ITEM_POINTER")) return;
905
- const m = a.getHighlightedItemEl(e), P = a.getContentEl(e);
906
- Z(m, { rootEl: P, block: "nearest" });
907
- };
908
- return b(() => l()), Q(() => a.getContentEl(e), {
909
- defer: !0,
910
- attributes: ["aria-activedescendant"],
911
- callback: l
912
- });
913
- }
914
- },
915
- actions: {
916
- setAnchorPoint(e, i) {
917
- e.anchorPoint = i.point;
918
- },
919
- setSubmenuPlacement(e) {
920
- e.isSubmenu && (e.positioning.placement = e.isRtl ? "left-start" : "right-start", e.positioning.gutter = 0);
921
- },
922
- reposition(e, i) {
923
- const r = () => a.getPositionerEl(e), l = e.anchorPoint ? () => ({ width: 0, height: 0, ...e.anchorPoint }) : void 0;
924
- D(a.getTriggerEl(e), r, {
925
- ...e.positioning,
926
- defer: !0,
927
- getAnchorRect: l,
928
- ...i.options ?? {},
929
- listeners: !1,
930
- onComplete(g) {
931
- e.currentPlacement = g.placement;
932
- }
933
- });
934
- },
935
- setOptionState(e, i) {
936
- if (!i.option) return;
937
- const { checked: r, onCheckedChange: l, type: g } = i.option;
938
- g === "radio" ? l == null || l(!0) : g === "checkbox" && (l == null || l(!r));
939
- },
940
- clickHighlightedItem(e, i) {
941
- const r = a.getHighlightedItemEl(e);
942
- !r || r.dataset.disabled || queueMicrotask(() => r.click());
943
- },
944
- setIntentPolygon(e, i) {
945
- const r = a.getContentEl(e), l = e.currentPlacement;
946
- if (!r || !l) return;
947
- const g = r.getBoundingClientRect(), d = pe(g, l);
948
- if (!d) return;
949
- const P = re(l) === "right" ? -5 : 5;
950
- e.intentPolygon = [{ ...i.point, x: i.point.x + P }, ...d];
951
- },
952
- clearIntentPolygon(e) {
953
- e.intentPolygon = null;
954
- },
955
- resumePointer(e) {
956
- e.parent && (e.parent.state.context.suspendPointer = !1);
957
- },
958
- setHighlightedItem(e, i) {
959
- f.highlighted(e, i.id);
960
- },
961
- clearHighlightedItem(e) {
962
- f.highlighted(e, null);
963
- },
964
- focusMenu(e) {
965
- b(() => {
966
- const i = a.getContentEl(e), r = j({
967
- root: i,
968
- enabled: !J(i, a.getActiveElement(e)),
969
- filter(l) {
970
- var g;
971
- return !((g = l.role) != null && g.startsWith("menuitem"));
972
- }
973
- });
974
- r == null || r.focus({ preventScroll: !0 });
975
- });
976
- },
977
- highlightFirstItem(e) {
978
- (a.getContentEl(e) ? queueMicrotask : b)(() => {
979
- const r = a.getFirstEl(e);
980
- r && f.highlighted(e, r.id);
981
- });
641
+ closing: {
642
+ tags: ["open"],
643
+ effects: ["trackPointerMove", "trackInteractOutside", "waitForCloseDelay"],
644
+ on: {
645
+ "CONTROLLED.OPEN": {
646
+ target: "open"
982
647
  },
983
- highlightLastItem(e) {
984
- (a.getContentEl(e) ? queueMicrotask : b)(() => {
985
- const r = a.getLastEl(e);
986
- r && f.highlighted(e, r.id);
987
- });
648
+ "CONTROLLED.CLOSE": {
649
+ target: "closed",
650
+ actions: ["focusParentMenu", "restoreParentHighlightedItem"]
988
651
  },
989
- highlightNextItem(e, i) {
990
- const r = a.getNextEl(e, i.loop);
991
- f.highlighted(e, (r == null ? void 0 : r.id) ?? null);
652
+ // don't invoke on open here since the menu is still open (we're only keeping it open)
653
+ MENU_POINTERENTER: {
654
+ target: "open",
655
+ actions: ["clearIntentPolygon"]
992
656
  },
993
- highlightPrevItem(e, i) {
994
- const r = a.getPrevEl(e, i.loop);
995
- f.highlighted(e, (r == null ? void 0 : r.id) ?? null);
657
+ POINTER_MOVED_AWAY_FROM_SUBMENU: [
658
+ {
659
+ guard: "isOpenControlled",
660
+ actions: ["invokeOnClose"]
661
+ },
662
+ {
663
+ target: "closed",
664
+ actions: ["focusParentMenu", "restoreParentHighlightedItem"]
665
+ }
666
+ ],
667
+ "DELAY.CLOSE": [
668
+ {
669
+ guard: "isOpenControlled",
670
+ actions: ["invokeOnClose"]
671
+ },
672
+ {
673
+ target: "closed",
674
+ actions: ["focusParentMenu", "restoreParentHighlightedItem", "invokeOnClose"]
675
+ }
676
+ ]
677
+ }
678
+ },
679
+ closed: {
680
+ tags: ["closed"],
681
+ entry: ["clearHighlightedItem", "focusTrigger", "resumePointer"],
682
+ on: {
683
+ "CONTROLLED.OPEN": [
684
+ {
685
+ guard: qe("isOpenAutoFocusEvent", "isArrowDownEvent"),
686
+ target: "open",
687
+ actions: ["highlightFirstItem"]
688
+ },
689
+ {
690
+ guard: "isArrowUpEvent",
691
+ target: "open",
692
+ actions: ["highlightLastItem"]
693
+ },
694
+ {
695
+ target: "open"
696
+ }
697
+ ],
698
+ CONTEXT_MENU_START: {
699
+ target: "opening:contextmenu",
700
+ actions: ["setAnchorPoint"]
996
701
  },
997
- invokeOnSelect(e) {
998
- var i;
999
- e.highlightedValue && ((i = e.onSelect) == null || i.call(e, { value: e.highlightedValue }));
702
+ CONTEXT_MENU: [
703
+ {
704
+ guard: "isOpenControlled",
705
+ actions: ["setAnchorPoint", "invokeOnOpen"]
706
+ },
707
+ {
708
+ target: "open",
709
+ actions: ["setAnchorPoint", "invokeOnOpen"]
710
+ }
711
+ ],
712
+ TRIGGER_CLICK: [
713
+ {
714
+ guard: "isOpenControlled",
715
+ actions: ["invokeOnOpen"]
716
+ },
717
+ {
718
+ target: "open",
719
+ actions: ["invokeOnOpen"]
720
+ }
721
+ ],
722
+ TRIGGER_POINTERMOVE: {
723
+ guard: "isTriggerItem",
724
+ target: "opening"
1000
725
  },
1001
- focusTrigger(e) {
1002
- e.isSubmenu || e.anchorPoint || !e.restoreFocus || queueMicrotask(() => {
1003
- var i;
1004
- return (i = a.getTriggerEl(e)) == null ? void 0 : i.focus({ preventScroll: !0 });
1005
- });
726
+ TRIGGER_BLUR: { target: "idle" },
727
+ ARROW_DOWN: [
728
+ {
729
+ guard: "isOpenControlled",
730
+ actions: ["invokeOnOpen"]
731
+ },
732
+ {
733
+ target: "open",
734
+ actions: ["highlightFirstItem", "invokeOnOpen"]
735
+ }
736
+ ],
737
+ ARROW_UP: [
738
+ {
739
+ guard: "isOpenControlled",
740
+ actions: ["invokeOnOpen"]
741
+ },
742
+ {
743
+ target: "open",
744
+ actions: ["highlightLastItem", "invokeOnOpen"]
745
+ }
746
+ ]
747
+ }
748
+ },
749
+ open: {
750
+ tags: ["open"],
751
+ effects: ["trackInteractOutside", "trackPositioning", "scrollToHighlightedItem"],
752
+ entry: ["focusMenu", "resumePointer"],
753
+ on: {
754
+ "CONTROLLED.CLOSE": [
755
+ {
756
+ target: "closed",
757
+ guard: "isArrowLeftEvent",
758
+ actions: ["focusParentMenu"]
759
+ },
760
+ {
761
+ target: "closed"
762
+ }
763
+ ],
764
+ TRIGGER_CLICK: [
765
+ {
766
+ guard: v(m("isTriggerItem"), "isOpenControlled"),
767
+ actions: ["invokeOnClose"]
768
+ },
769
+ {
770
+ guard: m("isTriggerItem"),
771
+ target: "closed",
772
+ actions: ["invokeOnClose"]
773
+ }
774
+ ],
775
+ CONTEXT_MENU: {
776
+ actions: ["setAnchorPoint", "focusMenu"]
1006
777
  },
1007
- highlightMatchedItem(e, i) {
1008
- const r = a.getElemByKey(e, i.key);
1009
- r && f.highlighted(e, r.id);
778
+ ARROW_UP: {
779
+ actions: ["highlightPrevItem", "focusMenu"]
1010
780
  },
1011
- setParentMenu(e, i) {
1012
- e.parent = _(i.value);
781
+ ARROW_DOWN: {
782
+ actions: ["highlightNextItem", "focusMenu"]
1013
783
  },
1014
- setChildMenu(e, i) {
1015
- e.children[i.id] = _(i.value);
784
+ ARROW_LEFT: [
785
+ {
786
+ guard: v("isSubmenu", "isOpenControlled"),
787
+ actions: ["invokeOnClose"]
788
+ },
789
+ {
790
+ guard: "isSubmenu",
791
+ target: "closed",
792
+ actions: ["focusParentMenu", "invokeOnClose"]
793
+ }
794
+ ],
795
+ HOME: {
796
+ actions: ["highlightFirstItem", "focusMenu"]
1016
797
  },
1017
- closeRootMenu(e) {
1018
- H(e);
798
+ END: {
799
+ actions: ["highlightLastItem", "focusMenu"]
1019
800
  },
1020
- openSubmenu(e) {
1021
- const i = a.getHighlightedItemEl(e), r = i == null ? void 0 : i.getAttribute("data-uid"), l = r ? e.children[r] : null;
1022
- l == null || l.send("OPEN_AUTOFOCUS");
801
+ ARROW_RIGHT: {
802
+ guard: "isTriggerItemHighlighted",
803
+ actions: ["openSubmenu"]
1023
804
  },
1024
- focusParentMenu(e) {
1025
- var i;
1026
- (i = e.parent) == null || i.send("FOCUS_MENU");
805
+ ENTER: [
806
+ {
807
+ guard: "isTriggerItemHighlighted",
808
+ actions: ["openSubmenu"]
809
+ },
810
+ {
811
+ actions: ["clickHighlightedItem"]
812
+ }
813
+ ],
814
+ ITEM_POINTERMOVE: [
815
+ {
816
+ guard: m("isPointerSuspended"),
817
+ actions: ["setHighlightedItem", "focusMenu"]
818
+ },
819
+ {
820
+ actions: ["setLastHighlightedItem"]
821
+ }
822
+ ],
823
+ ITEM_POINTERLEAVE: {
824
+ guard: v(m("isPointerSuspended"), m("isTriggerItem")),
825
+ actions: ["clearHighlightedItem"]
1027
826
  },
1028
- setLastHighlightedItem(e, i) {
1029
- e.lastHighlightedValue = i.id;
827
+ ITEM_CLICK: [
828
+ // == grouped ==
829
+ {
830
+ guard: v(
831
+ m("isTriggerItemHighlighted"),
832
+ m("isHighlightedItemEditable"),
833
+ "closeOnSelect",
834
+ "isOpenControlled"
835
+ ),
836
+ actions: ["invokeOnSelect", "setOptionState", "closeRootMenu", "invokeOnClose"]
837
+ },
838
+ {
839
+ guard: v(m("isTriggerItemHighlighted"), m("isHighlightedItemEditable"), "closeOnSelect"),
840
+ target: "closed",
841
+ actions: ["invokeOnSelect", "setOptionState", "closeRootMenu", "invokeOnClose"]
842
+ },
843
+ //
844
+ {
845
+ guard: v(m("isTriggerItemHighlighted"), m("isHighlightedItemEditable")),
846
+ actions: ["invokeOnSelect", "setOptionState"]
847
+ },
848
+ { actions: ["setHighlightedItem"] }
849
+ ],
850
+ TRIGGER_POINTERMOVE: {
851
+ guard: "isTriggerItem",
852
+ actions: ["setIntentPolygon"]
1030
853
  },
1031
- restoreHighlightedItem(e) {
1032
- e.lastHighlightedValue && (f.highlighted(e, e.lastHighlightedValue), e.lastHighlightedValue = null);
854
+ TRIGGER_POINTERLEAVE: {
855
+ target: "closing"
1033
856
  },
1034
- restoreParentHiglightedItem(e) {
1035
- var i;
1036
- (i = e.parent) == null || i.send("HIGHLIGHTED.RESTORE");
857
+ ITEM_POINTERDOWN: {
858
+ actions: ["setHighlightedItem"]
1037
859
  },
1038
- invokeOnOpen(e) {
1039
- var i;
1040
- (i = e.onOpenChange) == null || i.call(e, { open: !0 });
860
+ TYPEAHEAD: {
861
+ actions: ["highlightMatchedItem"]
1041
862
  },
1042
- invokeOnClose(e) {
1043
- var i;
1044
- (i = e.onOpenChange) == null || i.call(e, { open: !1 });
863
+ FOCUS_MENU: {
864
+ actions: ["focusMenu"]
1045
865
  },
1046
- toggleVisibility(e, i, { send: r }) {
1047
- r({ type: e.open ? "CONTROLLED.OPEN" : "CONTROLLED.CLOSE", previousEvent: i });
866
+ "POSITIONING.SET": {
867
+ actions: ["reposition"]
1048
868
  }
1049
869
  }
1050
870
  }
1051
- );
871
+ },
872
+ implementations: {
873
+ guards: {
874
+ closeOnSelect: ({ prop: e, event: t }) => !!((t == null ? void 0 : t.closeOnSelect) ?? e("closeOnSelect")),
875
+ // whether the trigger is also a menu item
876
+ isTriggerItem: ({ event: e }) => Xe(e.target),
877
+ // whether the trigger item is the active item
878
+ isTriggerItemHighlighted: ({ event: e, scope: t, computed: n }) => {
879
+ const r = e.target ?? t.getById(n("highlightedId"));
880
+ return !!(r != null && r.hasAttribute("aria-controls"));
881
+ },
882
+ isSubmenu: ({ computed: e }) => e("isSubmenu"),
883
+ isPointerSuspended: ({ context: e }) => e.get("suspendPointer"),
884
+ isHighlightedItemEditable: ({ scope: e, computed: t }) => ie(e.getById(t("highlightedId"))),
885
+ // guard assertions (for controlled mode)
886
+ isOpenControlled: ({ prop: e }) => e("open") !== void 0,
887
+ isArrowLeftEvent: ({ event: e }) => {
888
+ var t;
889
+ return ((t = e.previousEvent) == null ? void 0 : t.type) === "ARROW_LEFT";
890
+ },
891
+ isArrowUpEvent: ({ event: e }) => {
892
+ var t;
893
+ return ((t = e.previousEvent) == null ? void 0 : t.type) === "ARROW_UP";
894
+ },
895
+ isArrowDownEvent: ({ event: e }) => {
896
+ var t;
897
+ return ((t = e.previousEvent) == null ? void 0 : t.type) === "ARROW_DOWN";
898
+ },
899
+ isOpenAutoFocusEvent: ({ event: e }) => {
900
+ var t;
901
+ return ((t = e.previousEvent) == null ? void 0 : t.type) === "OPEN_AUTOFOCUS";
902
+ }
903
+ },
904
+ effects: {
905
+ waitForOpenDelay({ send: e }) {
906
+ const t = setTimeout(() => {
907
+ e({ type: "DELAY.OPEN" });
908
+ }, 100);
909
+ return () => clearTimeout(t);
910
+ },
911
+ waitForCloseDelay({ send: e }) {
912
+ const t = setTimeout(() => {
913
+ e({ type: "DELAY.CLOSE" });
914
+ }, 300);
915
+ return () => clearTimeout(t);
916
+ },
917
+ waitForLongPress({ send: e }) {
918
+ const t = setTimeout(() => {
919
+ e({ type: "LONG_PRESS.OPEN" });
920
+ }, 700);
921
+ return () => clearTimeout(t);
922
+ },
923
+ trackPositioning({ context: e, prop: t, scope: n, refs: r }) {
924
+ if (te(n)) return;
925
+ const o = {
926
+ ...t("positioning"),
927
+ ...r.get("positioningOverride")
928
+ };
929
+ e.set("currentPlacement", o.placement);
930
+ const g = () => ee(n);
931
+ return Q(D(n), g, {
932
+ ...o,
933
+ defer: !0,
934
+ onComplete(a) {
935
+ e.set("currentPlacement", a.placement);
936
+ }
937
+ });
938
+ },
939
+ trackInteractOutside({ refs: e, scope: t, prop: n, computed: r, send: o }) {
940
+ const g = () => I(t);
941
+ let a = !0;
942
+ return He(g, {
943
+ defer: !0,
944
+ exclude: [D(t)],
945
+ onInteractOutside: n("onInteractOutside"),
946
+ onFocusOutside: n("onFocusOutside"),
947
+ onEscapeKeyDown(l) {
948
+ var c;
949
+ (c = n("onEscapeKeyDown")) == null || c(l), r("isSubmenu") && l.preventDefault(), ne({ parent: e.get("parent") });
950
+ },
951
+ onPointerDownOutside(l) {
952
+ var A;
953
+ const c = oe(l.detail.originalEvent);
954
+ if (J(te(t), c) && l.detail.contextmenu) {
955
+ l.preventDefault();
956
+ return;
957
+ }
958
+ a = !l.detail.focusable, (A = n("onPointerDownOutside")) == null || A(l);
959
+ },
960
+ onDismiss() {
961
+ o({ type: "CLOSE", src: "interact-outside", restoreFocus: a });
962
+ }
963
+ });
964
+ },
965
+ trackPointerMove({ context: e, scope: t, send: n, refs: r, flush: o }) {
966
+ const g = r.get("parent");
967
+ o(() => {
968
+ g.context.set("suspendPointer", !0);
969
+ });
970
+ const a = t.getDoc();
971
+ return Oe(a, "pointermove", (l) => {
972
+ je(e.get("intentPolygon"), {
973
+ x: l.clientX,
974
+ y: l.clientY
975
+ }) || (n({ type: "POINTER_MOVED_AWAY_FROM_SUBMENU" }), g.context.set("suspendPointer", !1));
976
+ });
977
+ },
978
+ scrollToHighlightedItem({ event: e, scope: t, computed: n }) {
979
+ const r = () => {
980
+ if (e.type.startsWith("ITEM_POINTER")) return;
981
+ const g = t.getById(n("highlightedId")), a = I(t);
982
+ ke(g, { rootEl: a, block: "nearest" });
983
+ };
984
+ return b(() => r()), pe(() => I(t), {
985
+ defer: !0,
986
+ attributes: ["aria-activedescendant"],
987
+ callback: r
988
+ });
989
+ }
990
+ },
991
+ actions: {
992
+ setAnchorPoint({ context: e, event: t }) {
993
+ e.set("anchorPoint", t.point);
994
+ },
995
+ setSubmenuPlacement({ computed: e, refs: t }) {
996
+ if (!e("isSubmenu")) return;
997
+ const n = e("isRtl") ? "left-start" : "right-start";
998
+ t.set("positioningOverride", { placement: n, gutter: 0 });
999
+ },
1000
+ reposition({ context: e, scope: t, prop: n, event: r, refs: o }) {
1001
+ const g = () => ee(t), a = e.get("anchorPoint"), l = a ? () => ({ width: 0, height: 0, ...a }) : void 0, c = {
1002
+ ...n("positioning"),
1003
+ ...o.get("positioningOverride")
1004
+ };
1005
+ Q(D(t), g, {
1006
+ ...c,
1007
+ defer: !0,
1008
+ getAnchorRect: l,
1009
+ ...r.options ?? {},
1010
+ listeners: !1,
1011
+ onComplete(P) {
1012
+ e.set("currentPlacement", P.placement);
1013
+ }
1014
+ });
1015
+ },
1016
+ setOptionState({ event: e }) {
1017
+ if (!e.option) return;
1018
+ const { checked: t, onCheckedChange: n, type: r } = e.option;
1019
+ r === "radio" ? n == null || n(!0) : r === "checkbox" && (n == null || n(!t));
1020
+ },
1021
+ clickHighlightedItem({ scope: e, computed: t }) {
1022
+ const n = e.getById(t("highlightedId"));
1023
+ !n || n.dataset.disabled || queueMicrotask(() => n.click());
1024
+ },
1025
+ setIntentPolygon({ context: e, scope: t, event: n }) {
1026
+ const r = I(t), o = e.get("currentPlacement");
1027
+ if (!r || !o) return;
1028
+ const g = r.getBoundingClientRect(), a = we(g, o);
1029
+ if (!a) return;
1030
+ const c = Le(o) === "right" ? -5 : 5;
1031
+ e.set("intentPolygon", [{ ...n.point, x: n.point.x + c }, ...a]);
1032
+ },
1033
+ clearIntentPolygon({ context: e }) {
1034
+ e.set("intentPolygon", null);
1035
+ },
1036
+ resumePointer({ refs: e, flush: t }) {
1037
+ const n = e.get("parent");
1038
+ n && t(() => {
1039
+ n.context.set("suspendPointer", !1);
1040
+ });
1041
+ },
1042
+ setHighlightedItem({ context: e, event: t }) {
1043
+ const n = t.value || f(t.target);
1044
+ e.set("highlightedValue", n);
1045
+ },
1046
+ clearHighlightedItem({ context: e }) {
1047
+ e.set("highlightedValue", null);
1048
+ },
1049
+ focusMenu({ scope: e }) {
1050
+ b(() => {
1051
+ const t = I(e), n = Ne({
1052
+ root: t,
1053
+ enabled: !J(t, e.getActiveElement()),
1054
+ filter(r) {
1055
+ var o;
1056
+ return !((o = r.role) != null && o.startsWith("menuitem"));
1057
+ }
1058
+ });
1059
+ n == null || n.focus({ preventScroll: !0 });
1060
+ });
1061
+ },
1062
+ highlightFirstItem({ context: e, scope: t }) {
1063
+ (I(t) ? queueMicrotask : b)(() => {
1064
+ const r = We(t);
1065
+ r && e.set("highlightedValue", f(r));
1066
+ });
1067
+ },
1068
+ highlightLastItem({ context: e, scope: t }) {
1069
+ (I(t) ? queueMicrotask : b)(() => {
1070
+ const r = xe(t);
1071
+ r && e.set("highlightedValue", f(r));
1072
+ });
1073
+ },
1074
+ highlightNextItem({ context: e, scope: t, event: n, prop: r }) {
1075
+ const o = Be(t, {
1076
+ loop: n.loop,
1077
+ value: e.get("highlightedValue"),
1078
+ loopFocus: r("loopFocus")
1079
+ });
1080
+ e.set("highlightedValue", f(o));
1081
+ },
1082
+ highlightPrevItem({ context: e, scope: t, event: n, prop: r }) {
1083
+ const o = Ke(t, {
1084
+ loop: n.loop,
1085
+ value: e.get("highlightedValue"),
1086
+ loopFocus: r("loopFocus")
1087
+ });
1088
+ e.set("highlightedValue", f(o));
1089
+ },
1090
+ invokeOnSelect({ context: e, prop: t, scope: n }) {
1091
+ var g;
1092
+ const r = e.get("highlightedValue");
1093
+ if (r == null) return;
1094
+ const o = le(n, r);
1095
+ Ye(o, r), (g = t("onSelect")) == null || g({ value: r });
1096
+ },
1097
+ focusTrigger({ scope: e, context: t, event: n, computed: r }) {
1098
+ r("isSubmenu") || t.get("anchorPoint") || n.restoreFocus === !1 || queueMicrotask(() => {
1099
+ var o;
1100
+ return (o = D(e)) == null ? void 0 : o.focus({ preventScroll: !0 });
1101
+ });
1102
+ },
1103
+ highlightMatchedItem({ scope: e, context: t, event: n, refs: r }) {
1104
+ const o = $e(e, {
1105
+ key: n.key,
1106
+ value: t.get("highlightedValue"),
1107
+ typeaheadState: r.get("typeaheadState")
1108
+ });
1109
+ o && t.set("highlightedValue", f(o));
1110
+ },
1111
+ setParentMenu({ refs: e, event: t }) {
1112
+ e.set("parent", t.value);
1113
+ },
1114
+ setChildMenu({ refs: e, event: t }) {
1115
+ const n = e.get("children");
1116
+ n[t.id] = t.value, e.set("children", n);
1117
+ },
1118
+ closeRootMenu({ refs: e }) {
1119
+ ne({ parent: e.get("parent") });
1120
+ },
1121
+ openSubmenu({ refs: e, scope: t, computed: n }) {
1122
+ const r = t.getById(n("highlightedId")), o = r == null ? void 0 : r.getAttribute("data-uid"), g = e.get("children"), a = o ? g[o] : null;
1123
+ a == null || a.send({ type: "OPEN_AUTOFOCUS" });
1124
+ },
1125
+ focusParentMenu({ refs: e }) {
1126
+ var t;
1127
+ (t = e.get("parent")) == null || t.send({ type: "FOCUS_MENU" });
1128
+ },
1129
+ setLastHighlightedItem({ context: e, event: t }) {
1130
+ e.set("lastHighlightedValue", f(t.target));
1131
+ },
1132
+ restoreHighlightedItem({ context: e }) {
1133
+ e.get("lastHighlightedValue") && (e.set("highlightedValue", e.get("lastHighlightedValue")), e.set("lastHighlightedValue", null));
1134
+ },
1135
+ restoreParentHighlightedItem({ refs: e }) {
1136
+ var t;
1137
+ (t = e.get("parent")) == null || t.send({ type: "HIGHLIGHTED.RESTORE" });
1138
+ },
1139
+ invokeOnOpen({ prop: e }) {
1140
+ var t;
1141
+ (t = e("onOpenChange")) == null || t({ open: !0 });
1142
+ },
1143
+ invokeOnClose({ prop: e }) {
1144
+ var t;
1145
+ (t = e("onOpenChange")) == null || t({ open: !1 });
1146
+ },
1147
+ toggleVisibility({ prop: e, event: t, send: n }) {
1148
+ n({
1149
+ type: e("open") ? "CONTROLLED.OPEN" : "CONTROLLED.CLOSE",
1150
+ previousEvent: t
1151
+ });
1152
+ }
1153
+ }
1154
+ }
1155
+ });
1156
+ function ne(e) {
1157
+ let t = e.parent;
1158
+ for (; t && t.computed("isSubmenu"); )
1159
+ t = t.refs.get("parent");
1160
+ t == null || t.send({ type: "CLOSE" });
1052
1161
  }
1053
- function H(t) {
1054
- let o = t.parent;
1055
- for (; o && o.state.context.isSubmenu; )
1056
- o = o.state.context.parent;
1057
- o == null || o.send("CLOSE");
1162
+ function je(e, t) {
1163
+ return e ? Ge(e, t) : !1;
1058
1164
  }
1059
- var f = {
1060
- highlighted(t, o) {
1061
- var e;
1062
- de(t.highlightedValue, o) || (t.highlightedValue = o, (e = t.onHighlightChange) == null || e.call(t, { highlightedValue: o }));
1165
+ function Je(e, t, n) {
1166
+ const r = Object.keys(e).length > 0;
1167
+ if (!t) return null;
1168
+ if (!r)
1169
+ return N(n, t);
1170
+ for (const o in e) {
1171
+ const g = e[o], a = w(g.scope);
1172
+ if (a === t)
1173
+ return a;
1063
1174
  }
1064
- };
1065
- y()([
1175
+ return N(n, t);
1176
+ }
1177
+ k()([
1066
1178
  "anchorPoint",
1067
1179
  "aria-label",
1068
1180
  "closeOnSelect",
1181
+ "composite",
1182
+ "defaultHighlightedValue",
1183
+ "defaultOpen",
1069
1184
  "dir",
1070
1185
  "getRootNode",
1071
1186
  "highlightedValue",
1072
1187
  "id",
1073
1188
  "ids",
1074
1189
  "loopFocus",
1190
+ "navigate",
1191
+ "onEscapeKeyDown",
1075
1192
  "onFocusOutside",
1193
+ "onHighlightChange",
1076
1194
  "onInteractOutside",
1077
1195
  "onOpenChange",
1078
1196
  "onPointerDownOutside",
1079
- "onEscapeKeyDown",
1080
1197
  "onSelect",
1081
- "onHighlightChange",
1082
1198
  "open",
1083
- "open.controlled",
1084
1199
  "positioning",
1085
- "typeahead",
1086
- "composite"
1200
+ "typeahead"
1087
1201
  ]);
1088
- y()(["closeOnSelect", "disabled", "value", "valueText"]);
1089
- y()(["htmlFor"]);
1090
- y()(["id"]);
1091
- y()([
1092
- "disabled",
1093
- "valueText",
1202
+ k()(["closeOnSelect", "disabled", "value", "valueText"]);
1203
+ k()(["htmlFor"]);
1204
+ k()(["id"]);
1205
+ k()([
1206
+ "checked",
1094
1207
  "closeOnSelect",
1208
+ "disabled",
1209
+ "onCheckedChange",
1095
1210
  "type",
1096
1211
  "value",
1097
- "checked",
1098
- "onCheckedChange"
1212
+ "valueText"
1099
1213
  ]);
1100
1214
  export {
1101
- Ee as anatomy,
1102
- be as connect,
1103
- ve as machine
1215
+ Ve as anatomy,
1216
+ ot as connect,
1217
+ at as machine
1104
1218
  };