@yselimcan/ui 0.0.8 → 0.0.10

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 (266) hide show
  1. package/dist/index.js +15277 -100
  2. package/dist/styles.css +1 -1
  3. package/package.json +7 -11
  4. package/dist/index10.js +0 -137
  5. package/dist/index100.js +0 -8
  6. package/dist/index101.js +0 -10
  7. package/dist/index102.js +0 -90
  8. package/dist/index103.js +0 -15
  9. package/dist/index104.js +0 -65
  10. package/dist/index105.js +0 -40
  11. package/dist/index106.js +0 -16
  12. package/dist/index107.js +0 -35
  13. package/dist/index108.js +0 -21
  14. package/dist/index109.js +0 -8
  15. package/dist/index11.js +0 -21
  16. package/dist/index110.js +0 -6
  17. package/dist/index111.js +0 -7
  18. package/dist/index112.js +0 -14
  19. package/dist/index113.js +0 -21
  20. package/dist/index114.js +0 -15
  21. package/dist/index115.js +0 -299
  22. package/dist/index116.js +0 -7
  23. package/dist/index117.js +0 -41
  24. package/dist/index118.js +0 -128
  25. package/dist/index119.js +0 -23
  26. package/dist/index12.js +0 -20
  27. package/dist/index120.js +0 -79
  28. package/dist/index121.js +0 -67
  29. package/dist/index122.js +0 -48
  30. package/dist/index123.js +0 -16
  31. package/dist/index124.js +0 -8
  32. package/dist/index125.js +0 -32
  33. package/dist/index126.js +0 -7
  34. package/dist/index127.js +0 -30
  35. package/dist/index128.js +0 -20
  36. package/dist/index129.js +0 -24
  37. package/dist/index13.js +0 -206
  38. package/dist/index130.js +0 -61
  39. package/dist/index131.js +0 -20
  40. package/dist/index132.js +0 -30
  41. package/dist/index133.js +0 -43
  42. package/dist/index134.js +0 -45
  43. package/dist/index135.js +0 -24
  44. package/dist/index136.js +0 -51
  45. package/dist/index137.js +0 -54
  46. package/dist/index138.js +0 -20
  47. package/dist/index139.js +0 -14
  48. package/dist/index14.js +0 -24
  49. package/dist/index140.js +0 -25
  50. package/dist/index141.js +0 -38
  51. package/dist/index142.js +0 -233
  52. package/dist/index143.js +0 -286
  53. package/dist/index144.js +0 -56
  54. package/dist/index145.js +0 -18
  55. package/dist/index146.js +0 -82
  56. package/dist/index147.js +0 -6
  57. package/dist/index148.js +0 -33
  58. package/dist/index149.js +0 -26
  59. package/dist/index15.js +0 -19
  60. package/dist/index150.js +0 -18
  61. package/dist/index151.js +0 -72
  62. package/dist/index152.js +0 -6
  63. package/dist/index153.js +0 -107
  64. package/dist/index154.js +0 -82
  65. package/dist/index155.js +0 -266
  66. package/dist/index156.js +0 -14
  67. package/dist/index157.js +0 -13
  68. package/dist/index158.js +0 -43
  69. package/dist/index159.js +0 -7
  70. package/dist/index16.js +0 -8
  71. package/dist/index160.js +0 -69
  72. package/dist/index161.js +0 -12
  73. package/dist/index162.js +0 -11
  74. package/dist/index163.js +0 -8
  75. package/dist/index164.js +0 -136
  76. package/dist/index165.js +0 -56
  77. package/dist/index166.js +0 -14
  78. package/dist/index167.js +0 -120
  79. package/dist/index168.js +0 -14
  80. package/dist/index169.js +0 -14
  81. package/dist/index17.js +0 -46
  82. package/dist/index170.js +0 -69
  83. package/dist/index171.js +0 -15
  84. package/dist/index172.js +0 -15
  85. package/dist/index173.js +0 -15
  86. package/dist/index174.js +0 -14
  87. package/dist/index175.js +0 -90
  88. package/dist/index176.js +0 -14
  89. package/dist/index177.js +0 -14
  90. package/dist/index178.js +0 -59
  91. package/dist/index179.js +0 -14
  92. package/dist/index18.js +0 -41
  93. package/dist/index180.js +0 -14
  94. package/dist/index181.js +0 -21
  95. package/dist/index182.js +0 -11
  96. package/dist/index183.js +0 -11
  97. package/dist/index184.js +0 -106
  98. package/dist/index185.js +0 -10
  99. package/dist/index186.js +0 -35
  100. package/dist/index187.js +0 -77
  101. package/dist/index188.js +0 -17
  102. package/dist/index189.js +0 -31
  103. package/dist/index19.js +0 -80
  104. package/dist/index190.js +0 -15
  105. package/dist/index191.js +0 -10
  106. package/dist/index192.js +0 -25
  107. package/dist/index193.js +0 -27
  108. package/dist/index194.js +0 -163
  109. package/dist/index195.js +0 -116
  110. package/dist/index196.js +0 -78
  111. package/dist/index197.js +0 -67
  112. package/dist/index198.js +0 -11
  113. package/dist/index199.js +0 -25
  114. package/dist/index20.js +0 -25
  115. package/dist/index200.js +0 -8
  116. package/dist/index201.js +0 -6
  117. package/dist/index202.js +0 -12
  118. package/dist/index203.js +0 -41
  119. package/dist/index204.js +0 -59
  120. package/dist/index205.js +0 -30
  121. package/dist/index206.js +0 -10
  122. package/dist/index207.js +0 -15
  123. package/dist/index208.js +0 -14
  124. package/dist/index209.js +0 -14
  125. package/dist/index21.js +0 -40
  126. package/dist/index210.js +0 -24
  127. package/dist/index211.js +0 -14
  128. package/dist/index212.js +0 -10
  129. package/dist/index213.js +0 -45
  130. package/dist/index214.js +0 -599
  131. package/dist/index215.js +0 -14
  132. package/dist/index216.js +0 -19
  133. package/dist/index217.js +0 -50
  134. package/dist/index218.js +0 -202
  135. package/dist/index219.js +0 -50
  136. package/dist/index22.js +0 -31
  137. package/dist/index220.js +0 -22
  138. package/dist/index221.js +0 -35
  139. package/dist/index222.js +0 -9
  140. package/dist/index223.js +0 -29
  141. package/dist/index224.js +0 -14
  142. package/dist/index225.js +0 -24
  143. package/dist/index226.js +0 -130
  144. package/dist/index227.js +0 -47
  145. package/dist/index228.js +0 -20
  146. package/dist/index229.js +0 -7
  147. package/dist/index23.js +0 -25
  148. package/dist/index230.js +0 -183
  149. package/dist/index231.js +0 -78
  150. package/dist/index232.js +0 -401
  151. package/dist/index233.js +0 -6
  152. package/dist/index234.js +0 -7
  153. package/dist/index235.js +0 -17
  154. package/dist/index236.js +0 -23
  155. package/dist/index237.js +0 -8
  156. package/dist/index238.js +0 -211
  157. package/dist/index239.js +0 -6
  158. package/dist/index24.js +0 -56
  159. package/dist/index240.js +0 -16
  160. package/dist/index241.js +0 -50
  161. package/dist/index242.js +0 -6
  162. package/dist/index243.js +0 -15
  163. package/dist/index244.js +0 -60
  164. package/dist/index245.js +0 -32
  165. package/dist/index246.js +0 -16
  166. package/dist/index247.js +0 -11
  167. package/dist/index248.js +0 -209
  168. package/dist/index249.js +0 -17
  169. package/dist/index25.js +0 -35
  170. package/dist/index250.js +0 -324
  171. package/dist/index251.js +0 -5
  172. package/dist/index252.js +0 -5
  173. package/dist/index253.js +0 -489
  174. package/dist/index254.js +0 -10
  175. package/dist/index255.js +0 -4
  176. package/dist/index256.js +0 -46
  177. package/dist/index257.js +0 -58
  178. package/dist/index258.js +0 -10
  179. package/dist/index259.js +0 -4
  180. package/dist/index26.js +0 -7
  181. package/dist/index260.js +0 -57
  182. package/dist/index261.js +0 -58
  183. package/dist/index262.js +0 -4
  184. package/dist/index263.js +0 -4
  185. package/dist/index264.js +0 -4
  186. package/dist/index265.js +0 -4
  187. package/dist/index27.js +0 -82
  188. package/dist/index28.js +0 -32
  189. package/dist/index29.js +0 -6
  190. package/dist/index3.js +0 -181
  191. package/dist/index30.js +0 -9
  192. package/dist/index31.js +0 -6
  193. package/dist/index32.js +0 -23
  194. package/dist/index33.js +0 -207
  195. package/dist/index34.js +0 -25
  196. package/dist/index35.js +0 -102
  197. package/dist/index36.js +0 -69
  198. package/dist/index37.js +0 -66
  199. package/dist/index38.js +0 -113
  200. package/dist/index39.js +0 -53
  201. package/dist/index4.js +0 -47
  202. package/dist/index40.js +0 -35
  203. package/dist/index41.js +0 -28
  204. package/dist/index42.js +0 -18
  205. package/dist/index43.js +0 -27
  206. package/dist/index44.js +0 -25
  207. package/dist/index45.js +0 -36
  208. package/dist/index46.js +0 -78
  209. package/dist/index47.js +0 -65
  210. package/dist/index48.js +0 -128
  211. package/dist/index49.js +0 -19
  212. package/dist/index5.js +0 -52
  213. package/dist/index50.js +0 -86
  214. package/dist/index51.js +0 -6
  215. package/dist/index52.js +0 -268
  216. package/dist/index53.js +0 -25
  217. package/dist/index54.js +0 -207
  218. package/dist/index55.js +0 -146
  219. package/dist/index56.js +0 -88
  220. package/dist/index57.js +0 -29
  221. package/dist/index58.js +0 -30
  222. package/dist/index59.js +0 -48
  223. package/dist/index6.js +0 -93
  224. package/dist/index60.js +0 -79
  225. package/dist/index61.js +0 -45
  226. package/dist/index62.js +0 -46
  227. package/dist/index63.js +0 -76
  228. package/dist/index64.js +0 -45
  229. package/dist/index65.js +0 -22
  230. package/dist/index66.js +0 -101
  231. package/dist/index67.js +0 -14
  232. package/dist/index68.js +0 -6
  233. package/dist/index69.js +0 -321
  234. package/dist/index7.js +0 -294
  235. package/dist/index70.js +0 -24
  236. package/dist/index71.js +0 -143
  237. package/dist/index72.js +0 -200
  238. package/dist/index73.js +0 -43
  239. package/dist/index74.js +0 -29
  240. package/dist/index75.js +0 -148
  241. package/dist/index76.js +0 -32
  242. package/dist/index77.js +0 -53
  243. package/dist/index78.js +0 -28
  244. package/dist/index79.js +0 -15
  245. package/dist/index8.js +0 -264
  246. package/dist/index80.js +0 -15
  247. package/dist/index81.js +0 -135
  248. package/dist/index82.js +0 -31
  249. package/dist/index83.js +0 -35
  250. package/dist/index84.js +0 -17
  251. package/dist/index85.js +0 -2765
  252. package/dist/index86.js +0 -14
  253. package/dist/index87.js +0 -57
  254. package/dist/index88.js +0 -98
  255. package/dist/index89.js +0 -21
  256. package/dist/index9.js +0 -197
  257. package/dist/index90.js +0 -18
  258. package/dist/index91.js +0 -35
  259. package/dist/index92.js +0 -14
  260. package/dist/index93.js +0 -92
  261. package/dist/index94.js +0 -7
  262. package/dist/index95.js +0 -69
  263. package/dist/index96.js +0 -11
  264. package/dist/index97.js +0 -16
  265. package/dist/index98.js +0 -6
  266. package/dist/index99.js +0 -6
package/dist/index52.js DELETED
@@ -1,268 +0,0 @@
1
- "use client";
2
- import * as r from "react";
3
- import * as Fe from "react-dom";
4
- import { useTimeout as G } from "./index148.js";
5
- import { useStableCallback as Ae } from "./index127.js";
6
- import { useId as He } from "./index181.js";
7
- import { useIsoLayoutEffect as J } from "./index126.js";
8
- import { useAnimationFrame as Ue } from "./index160.js";
9
- import { useScrollLock as Ke } from "./index153.js";
10
- import { EMPTY_ARRAY as Le } from "./index100.js";
11
- import { useMenuRootContext as _e, MenuRootContext as Ve } from "./index171.js";
12
- import { useMenubarContext as Ye } from "./index182.js";
13
- import { TYPEAHEAD_RESET_MS as qe } from "./index119.js";
14
- import { useDirection as De } from "./index183.js";
15
- import { useOpenInteractionType as je } from "./index140.js";
16
- import { createChangeEventDetails as Be } from "./index107.js";
17
- import { useContextMenuRootContext as $e } from "./index177.js";
18
- import { MenuStore as ze } from "./index184.js";
19
- import { useMenuSubmenuRootContext as Ge } from "./index185.js";
20
- import { jsx as Q } from "react/jsx-runtime";
21
- import { useFloatingNodeId as Je, useFloatingParentNodeId as Qe, FloatingTree as We } from "./index178.js";
22
- import { useSyncedFloatingRootContext as Xe } from "./index186.js";
23
- import { useDismiss as Ze } from "./index142.js";
24
- import { useRole as et } from "./index187.js";
25
- import { useListNavigation as tt } from "./index143.js";
26
- import { useTypeahead as ot } from "./index144.js";
27
- import { useInteractions as nt } from "./index122.js";
28
- import { useImplicitActiveTrigger as rt, useOpenStateTransitions as st } from "./index120.js";
29
- import { imperativeAction as it, triggerFocus as W, triggerPress as at, itemPress as ut, triggerHover as O, focusOut as ct, listNavigation as lt, siblingOpen as pt, escapeKey as dt } from "./index108.js";
30
- import { mergeProps as X } from "./index27.js";
31
- function Vt(Z) {
32
- const {
33
- children: C,
34
- open: ee,
35
- onOpenChange: te,
36
- onOpenChangeComplete: oe,
37
- defaultOpen: ne = !1,
38
- disabled: re = !1,
39
- modal: N,
40
- loopFocus: se = !0,
41
- orientation: ie = "vertical",
42
- actionsRef: ae,
43
- closeParentOnEsc: ue = !1,
44
- handle: ce,
45
- triggerId: le,
46
- defaultTriggerId: pe = null,
47
- highlightItemOnHover: de = !0
48
- } = Z, u = $e(!0), a = _e(!0), I = Ye(), k = Ge(), T = r.useMemo(() => k && a ? {
49
- type: "menu",
50
- store: a.store
51
- } : I ? {
52
- type: "menubar",
53
- context: I
54
- } : u && !a ? {
55
- type: "context-menu",
56
- context: u
57
- } : {
58
- type: void 0
59
- }, [u, a, I, k]), e = ze.useStore(ce?.store, {
60
- parent: T
61
- }), f = e.useState("floatingTreeRoot"), b = Je(f), x = Qe();
62
- J(() => {
63
- u && !a ? e.update({
64
- parent: {
65
- type: "context-menu",
66
- context: u
67
- },
68
- floatingNodeId: b,
69
- floatingParentNodeId: x
70
- }) : a && e.update({
71
- floatingNodeId: b,
72
- floatingParentNodeId: x
73
- });
74
- }, [u, a, b, x, e]), e.useControlledProp("open", ee, ne), e.useControlledProp("activeTriggerId", le, pe), e.useContextCallback("onOpenChangeComplete", oe);
75
- const i = e.useState("open"), w = e.useState("activeTriggerElement"), E = e.useState("positionerElement"), F = e.useState("hoverEnabled"), me = e.useState("modal"), A = e.useState("disabled"), fe = e.useState("lastOpenChangeReason"), n = e.useState("parent"), l = e.useState("activeIndex"), ge = e.useState("payload"), ye = e.useState("floatingParentNodeId"), h = r.useRef(null), P = ye != null;
76
- let p;
77
- process.env.NODE_ENV !== "production" && n.type !== void 0 && N !== void 0 && console.warn("Base UI: The `modal` prop is not supported on nested menus. It will be ignored."), e.useSyncedValues({
78
- disabled: re,
79
- modal: n.type === void 0 ? N : void 0,
80
- rootId: He()
81
- });
82
- const {
83
- openMethod: ve,
84
- triggerProps: g,
85
- reset: Ce
86
- } = je(i);
87
- rt(e);
88
- const {
89
- forceUnmount: H
90
- } = st(i, e, () => {
91
- e.update({
92
- allowMouseEnter: !1,
93
- stickIfOpen: !0
94
- }), Ce();
95
- }), R = r.useRef(n.type !== "context-menu"), M = G();
96
- r.useEffect(() => {
97
- if (i || (h.current = null), n.type === "context-menu") {
98
- if (!i) {
99
- M.clear(), R.current = !1;
100
- return;
101
- }
102
- M.start(500, () => {
103
- R.current = !0;
104
- });
105
- }
106
- }, [M, i, n.type]), Ke(i && me && fe !== O && ve !== "touch", E), J(() => {
107
- !i && !F && e.set("hoverEnabled", !0);
108
- }, [i, F, e]);
109
- const y = r.useRef(!0), U = G(), d = Ae((t, o) => {
110
- const s = o.reason;
111
- if (i === t && o.trigger === w || (o.preventUnmountOnClose = () => {
112
- e.set("preventUnmountingOnClose", !0);
113
- }, !t && o.trigger == null && (o.trigger = w ?? void 0), te?.(t, o), o.isCanceled))
114
- return;
115
- const ke = {
116
- open: t,
117
- nativeEvent: o.event,
118
- reason: o.reason,
119
- nested: P
120
- };
121
- p?.emit("openchange", ke);
122
- const v = o.event;
123
- if (t === !1 && v?.type === "click" && v.pointerType === "touch" && !y.current)
124
- return;
125
- if (!t && l !== null) {
126
- const m = e.context.itemDomElements.current[l];
127
- queueMicrotask(() => {
128
- m?.setAttribute("tabindex", "-1");
129
- });
130
- }
131
- t && s === W ? (y.current = !1, U.start(300, () => {
132
- y.current = !0;
133
- })) : (y.current = !0, U.clear());
134
- const B = (s === at || s === ut) && v.detail === 0 && v?.isTrusted, we = !t && (s === dt || s == null);
135
- function $() {
136
- const m = {
137
- open: t,
138
- openChangeReason: s
139
- };
140
- h.current = o.event ?? null;
141
- const z = o.trigger?.id ?? null;
142
- (z || t) && (m.activeTriggerId = z, m.activeTriggerElement = o.trigger ?? null), e.update(m);
143
- }
144
- s === O ? Fe.flushSync($) : $(), n.type === "menubar" && (s === W || s === ct || s === O || s === lt || s === pt) ? e.set("instantType", "group") : B || we ? e.set("instantType", B ? "click" : "dismiss") : e.set("instantType", void 0);
145
- }), K = r.useCallback((t) => {
146
- const o = Be(t);
147
- return o.preventUnmountOnClose = () => {
148
- e.set("preventUnmountingOnClose", !0);
149
- }, o;
150
- }, [e]), L = r.useCallback(() => {
151
- e.setOpen(!1, K(it));
152
- }, [e, K]);
153
- r.useImperativeHandle(ae, () => ({
154
- unmount: H,
155
- close: L
156
- }), [H, L]);
157
- let S;
158
- n.type === "context-menu" && (S = n.context), r.useImperativeHandle(S?.positionerRef, () => E, [E]), r.useImperativeHandle(S?.actionsRef, () => ({
159
- setOpen: d
160
- }), [d]);
161
- const c = Xe({
162
- popupStore: e,
163
- onOpenChange: d
164
- });
165
- p = c.context.events, r.useEffect(() => {
166
- const t = ({
167
- open: o,
168
- eventDetails: s
169
- }) => d(o, s);
170
- return p.on("setOpen", t), () => {
171
- p?.off("setOpen", t);
172
- };
173
- }, [p, d]);
174
- const Ie = Ze(c, {
175
- enabled: !A,
176
- bubbles: ue && n.type === "menu",
177
- outsidePress() {
178
- return n.type !== "context-menu" || h.current?.type === "contextmenu" ? !0 : R.current;
179
- },
180
- externalTree: P ? f : void 0
181
- }), Te = et(c, {
182
- role: "menu"
183
- }), be = De(), xe = r.useCallback((t) => {
184
- e.select("activeIndex") !== t && e.set("activeIndex", t);
185
- }, [e]), Ee = tt(c, {
186
- enabled: !A,
187
- listRef: e.context.itemDomElements,
188
- activeIndex: l,
189
- nested: n.type !== void 0,
190
- loopFocus: se,
191
- orientation: ie,
192
- parentOrientation: n.type === "menubar" ? n.context.orientation : void 0,
193
- rtl: be === "rtl",
194
- disabledIndices: Le,
195
- onNavigate: xe,
196
- openOnArrowKeyDown: n.type !== "context-menu",
197
- externalTree: P ? f : void 0,
198
- focusItemOnHover: de
199
- }), he = r.useCallback((t) => {
200
- e.context.typingRef.current = t;
201
- }, [e]), Pe = ot(c, {
202
- listRef: e.context.itemLabels,
203
- activeIndex: l,
204
- resetMs: qe,
205
- onMatch: (t) => {
206
- i && t !== l && e.set("activeIndex", t);
207
- },
208
- onTypingChange: he
209
- }), {
210
- getReferenceProps: _,
211
- getFloatingProps: V,
212
- getItemProps: Y,
213
- getTriggerProps: q
214
- } = nt([Ie, Te, Ee, Pe]), Re = r.useMemo(() => {
215
- const t = X(_(), {
216
- onMouseEnter() {
217
- e.set("hoverEnabled", !0);
218
- },
219
- onMouseMove() {
220
- e.set("allowMouseEnter", !0);
221
- }
222
- }, g);
223
- return delete t.role, t;
224
- }, [_, e, g]), Me = r.useMemo(() => {
225
- const t = q();
226
- if (!t)
227
- return t;
228
- const o = X(t, g);
229
- return delete o.role, delete o["aria-controls"], o;
230
- }, [q, g]), D = Ue(), Se = r.useMemo(() => V({
231
- onMouseEnter() {
232
- n.type === "menu" && D.request(() => e.set("hoverEnabled", !1));
233
- },
234
- onMouseMove() {
235
- e.set("allowMouseEnter", !0);
236
- },
237
- onClick() {
238
- e.select("hoverEnabled") && e.set("hoverEnabled", !1);
239
- },
240
- onKeyDown(t) {
241
- const o = e.select("keyboardEventRelay");
242
- o && !t.isPropagationStopped() && o(t);
243
- }
244
- }), [V, n.type, D, e]), Oe = r.useMemo(() => Y(), [Y]);
245
- e.useSyncedValues({
246
- floatingRootContext: c,
247
- activeTriggerProps: Re,
248
- inactiveTriggerProps: Me,
249
- popupProps: Se,
250
- itemProps: Oe
251
- });
252
- const Ne = r.useMemo(() => ({
253
- store: e,
254
- parent: T
255
- }), [e, T]), j = /* @__PURE__ */ Q(Ve.Provider, {
256
- value: Ne,
257
- children: typeof C == "function" ? C({
258
- payload: ge
259
- }) : C
260
- });
261
- return n.type === void 0 || n.type === "context-menu" ? /* @__PURE__ */ Q(We, {
262
- externalTree: f,
263
- children: j
264
- }) : j;
265
- }
266
- export {
267
- Vt as MenuRoot
268
- };
package/dist/index53.js DELETED
@@ -1,25 +0,0 @@
1
- "use client";
2
- import * as s from "react";
3
- import { useMenuRootContext as l } from "./index171.js";
4
- import { MenuPortalContext as a } from "./index176.js";
5
- import { jsx as e } from "react/jsx-runtime";
6
- import { FloatingPortal as i } from "./index118.js";
7
- const m = /* @__PURE__ */ s.forwardRef(function(t, r) {
8
- const {
9
- keepMounted: o = !1,
10
- ...n
11
- } = t, {
12
- store: u
13
- } = l();
14
- return u.useState("mounted") || o ? /* @__PURE__ */ e(a.Provider, {
15
- value: o,
16
- children: /* @__PURE__ */ e(i, {
17
- ref: r,
18
- ...n
19
- })
20
- }) : null;
21
- });
22
- process.env.NODE_ENV !== "production" && (m.displayName = "MenuPortal");
23
- export {
24
- m as MenuPortal
25
- };
package/dist/index54.js DELETED
@@ -1,207 +0,0 @@
1
- "use client";
2
- import de from "./index94.js";
3
- import * as n from "react";
4
- import * as D from "react-dom";
5
- import { useTimeout as L } from "./index148.js";
6
- import { ownerDocument as B } from "./index147.js";
7
- import { useStableCallback as h } from "./index127.js";
8
- import { useIsoLayoutEffect as be } from "./index126.js";
9
- import { EMPTY_OBJECT as Te } from "./index100.js";
10
- import { FloatingTreeStore as xe } from "./index188.js";
11
- import { useMenuRootContext as G } from "./index171.js";
12
- import { pressableTriggerOpenStateMapping as H } from "./index105.js";
13
- import { useRenderElement as ye } from "./index87.js";
14
- import { useButton as Re } from "./index93.js";
15
- import { getPseudoElementBounds as Me } from "./index150.js";
16
- import { CompositeItem as Oe } from "./index189.js";
17
- import { useCompositeRootContext as he } from "./index190.js";
18
- import { findRootOwnerId as Ee } from "./index191.js";
19
- import { useBaseUiId as ve } from "./index109.js";
20
- import { useMixedToggleClickHandler as Ce } from "./index192.js";
21
- import { useContextMenuRootContext as Ie } from "./index177.js";
22
- import { useMenubarContext as Fe } from "./index182.js";
23
- import { PATIENT_CLICK_THRESHOLD as Pe } from "./index119.js";
24
- import { FocusGuard as A } from "./index193.js";
25
- import { createChangeEventDetails as U } from "./index107.js";
26
- import { jsx as g, jsxs as we } from "react/jsx-runtime";
27
- import { useFloatingTree as Se, useFloatingNodeId as ke, useFloatingParentNodeId as Ne } from "./index178.js";
28
- import { useHoverReferenceInteraction as De } from "./index194.js";
29
- import { safePolygon as Be } from "./index195.js";
30
- import { useClick as He } from "./index121.js";
31
- import { useFocus as Ae } from "./index196.js";
32
- import { useInteractions as Ue } from "./index122.js";
33
- import { getTabbableBeforeElement as _e, isOutsideEvent as Le, getTabbableAfterElement as Ge, getNextTabbable as Ye } from "./index197.js";
34
- import { useTriggerDataForwarding as je } from "./index120.js";
35
- import { triggerHover as Ke, cancelOpen as Ve, focusOut as _ } from "./index108.js";
36
- import { contains as E } from "./index151.js";
37
- const x = 2, Xe = /* @__PURE__ */ n.forwardRef(function(c, u) {
38
- const {
39
- render: d,
40
- className: m,
41
- disabled: Y = !1,
42
- nativeButton: j = !0,
43
- id: K,
44
- openOnHover: V,
45
- delay: X = 100,
46
- closeDelay: v = 0,
47
- handle: $,
48
- payload: J,
49
- ...q
50
- } = c, z = G(!0), e = $?.store ?? z?.store;
51
- if (!e)
52
- throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: <Menu.Trigger> must be either used within a <Menu.Root> component or provided with a handle." : de(85));
53
- const l = ve(K), Q = e.useState("isTriggerActive", l), y = e.useState("floatingRootContext"), s = e.useState("isOpenedByTrigger", l), b = n.useRef(null), t = Je(), W = he(!0), C = Se(), T = n.useMemo(() => C ?? new xe(), [C]), Z = ke(T), ee = Ne(), {
54
- registerTrigger: te,
55
- isMountedByThisTrigger: I
56
- } = je(l, b, e, {
57
- payload: J,
58
- closeDelay: v,
59
- parent: t,
60
- floatingTreeRoot: T,
61
- floatingNodeId: Z,
62
- floatingParentNodeId: ee,
63
- keyboardEventRelay: W?.relayKeyboardEvent
64
- }), oe = e.useState("disabled"), p = Y || oe || t.type === "menubar" && t.context.disabled, {
65
- getButtonProps: re,
66
- buttonRef: ne
67
- } = Re({
68
- disabled: p,
69
- native: j
70
- });
71
- n.useEffect(() => {
72
- !s && t.type === void 0 && (e.context.allowMouseUpTriggerRef.current = !1);
73
- }, [e, s, t.type]);
74
- const f = n.useRef(null), F = L(), R = h((o) => {
75
- if (!f.current)
76
- return;
77
- F.clear(), e.context.allowMouseUpTriggerRef.current = !1;
78
- const i = o.target;
79
- if (E(f.current, i) || E(e.select("positionerElement"), i) || i === f.current || i != null && Ee(i) === e.select("rootId"))
80
- return;
81
- const r = Me(f.current);
82
- o.clientX >= r.left - x && o.clientX <= r.right + x && o.clientY >= r.top - x && o.clientY <= r.bottom + x || T.events.emit("close", {
83
- domEvent: o,
84
- reason: Ve
85
- });
86
- });
87
- n.useEffect(() => {
88
- s && e.select("lastOpenChangeReason") === Ke && B(f.current).addEventListener("mouseup", R, {
89
- once: !0
90
- });
91
- }, [s, R, e]);
92
- const M = t.type === "menubar" && t.context.hasSubmenuOpen, se = De(y, {
93
- enabled: (V ?? M ?? !1) && !p && t.type !== "context-menu" && (t.type !== "menubar" || M && !I),
94
- handleClose: Be({
95
- blockPointerEvents: t.type !== "menubar"
96
- }),
97
- mouseOnly: !0,
98
- move: !1,
99
- restMs: t.type === void 0 ? X : void 0,
100
- delay: {
101
- close: v
102
- },
103
- triggerElementRef: b,
104
- externalTree: T,
105
- isActiveTrigger: Q
106
- }), ie = $e(s, e.select("lastOpenChangeReason")), ue = He(y, {
107
- enabled: !p && t.type !== "context-menu",
108
- event: s && t.type === "menubar" ? "click" : "mousedown",
109
- toggle: !0,
110
- ignoreMouse: !1,
111
- stickIfOpen: t.type === void 0 ? ie : !1
112
- }), ae = Ae(y, {
113
- enabled: !p && (t.type !== "menubar" && s || M)
114
- }), ce = Ce({
115
- open: s,
116
- enabled: t.type === "menubar",
117
- mouseDownAction: "open"
118
- }), le = Ue([ue, ae]), O = t.type === "menubar", P = n.useMemo(() => ({
119
- disabled: p,
120
- open: s
121
- }), [p, s]), pe = e.useState("triggerProps", I), w = [f, u, ne, te, b], S = [le.getReferenceProps(), se ?? Te, pe, {
122
- "aria-haspopup": "menu",
123
- id: l,
124
- onMouseDown: (o) => {
125
- if (e.select("open"))
126
- return;
127
- F.start(200, () => {
128
- e.context.allowMouseUpTriggerRef.current = !0;
129
- }), B(o.currentTarget).addEventListener("mouseup", R, {
130
- once: !0
131
- });
132
- }
133
- }, O ? {
134
- role: "menuitem"
135
- } : {}, ce, q, re], k = n.useRef(null), fe = h((o) => {
136
- D.flushSync(() => {
137
- e.setOpen(!1, U(_, o.nativeEvent, o.currentTarget));
138
- }), _e(k.current)?.focus();
139
- }), me = h((o) => {
140
- const i = e.select("positionerElement");
141
- if (i && Le(o, i))
142
- e.context.beforeContentFocusGuardRef.current?.focus();
143
- else {
144
- D.flushSync(() => {
145
- e.setOpen(!1, U(_, o.nativeEvent, o.currentTarget));
146
- });
147
- let r = Ge(b.current);
148
- for (; r !== null && E(i, r) || r?.hasAttribute("aria-hidden"); ) {
149
- const ge = r;
150
- if (r = Ye(r), r === ge)
151
- break;
152
- }
153
- r?.focus();
154
- }
155
- }), N = ye("button", c, {
156
- enabled: !O,
157
- stateAttributesMapping: H,
158
- state: P,
159
- ref: w,
160
- props: S
161
- });
162
- return O ? /* @__PURE__ */ g(Oe, {
163
- tag: "button",
164
- render: d,
165
- className: m,
166
- state: P,
167
- refs: w,
168
- props: S,
169
- stateAttributesMapping: H
170
- }) : s ? /* @__PURE__ */ we(n.Fragment, {
171
- children: [/* @__PURE__ */ g(A, {
172
- ref: k,
173
- onFocus: fe
174
- }, `${l}-pre-focus-guard`), /* @__PURE__ */ g(n.Fragment, {
175
- children: N
176
- }, l), /* @__PURE__ */ g(A, {
177
- ref: e.context.triggerFocusTargetRef,
178
- onFocus: me
179
- }, `${l}-post-focus-guard`)]
180
- }) : /* @__PURE__ */ g(n.Fragment, {
181
- children: N
182
- }, l);
183
- });
184
- process.env.NODE_ENV !== "production" && (Xe.displayName = "MenuTrigger");
185
- function $e(a, c) {
186
- const u = L(), [d, m] = n.useState(!1);
187
- return be(() => {
188
- a && c === "trigger-hover" ? (m(!0), u.start(Pe, () => {
189
- m(!1);
190
- })) : a || (u.clear(), m(!1));
191
- }, [a, c, u]), d;
192
- }
193
- function Je() {
194
- const a = Ie(!0), c = G(!0), u = Fe();
195
- return n.useMemo(() => u ? {
196
- type: "menubar",
197
- context: u
198
- } : a && !c ? {
199
- type: "context-menu",
200
- context: a
201
- } : {
202
- type: void 0
203
- }, [a, c, u]);
204
- }
205
- export {
206
- Xe as MenuTrigger
207
- };
package/dist/index55.js DELETED
@@ -1,146 +0,0 @@
1
- "use client";
2
- import * as l from "react";
3
- import { inertValue as X } from "./index116.js";
4
- import { MenuPositionerContext as Y } from "./index173.js";
5
- import { useMenuRootContext as Z } from "./index171.js";
6
- import { useAnchorPositioning as $ } from "./index155.js";
7
- import { useRenderElement as ee } from "./index87.js";
8
- import { popupStateMapping as te } from "./index105.js";
9
- import { CompositeList as ne } from "./index154.js";
10
- import { InternalBackdrop as oe } from "./index117.js";
11
- import { useMenuPortalContext as re } from "./index176.js";
12
- import { DROPDOWN_COLLISION_AVOIDANCE as se, POPUP_COLLISION_AVOIDANCE as ie } from "./index119.js";
13
- import { useContextMenuRootContext as ae } from "./index177.js";
14
- import { createChangeEventDetails as x } from "./index107.js";
15
- import { jsxs as le, jsx as I } from "react/jsx-runtime";
16
- import { FloatingNode as de } from "./index178.js";
17
- import { triggerHover as ce, siblingOpen as g } from "./index108.js";
18
- const fe = /* @__PURE__ */ l.forwardRef(function(d, M) {
19
- const {
20
- anchor: v,
21
- positionMethod: E = "absolute",
22
- className: pe,
23
- render: me,
24
- side: O,
25
- align: b,
26
- sideOffset: A = 0,
27
- alignOffset: w = 0,
28
- collisionBoundary: D = "clipping-ancestors",
29
- collisionPadding: k = 5,
30
- arrowPadding: L = 5,
31
- sticky: H = !1,
32
- disableAnchorTracking: T = !1,
33
- collisionAvoidance: V = se,
34
- ..._
35
- } = d, {
36
- store: e
37
- } = Z(), B = re(), U = ae(!0), n = e.useState("parent"), j = e.useState("floatingRootContext"), s = e.useState("floatingTreeRoot"), u = e.useState("mounted"), i = e.useState("open"), F = e.useState("modal"), p = e.useState("activeTriggerElement"), W = e.useState("lastOpenChangeReason"), a = e.useState("floatingNodeId"), P = e.useState("floatingParentNodeId");
38
- let y = v, N = A, S = w, m = b, C = V;
39
- n.type === "context-menu" && (y = v ?? n.context?.anchor, m = m ?? "start", !O && m !== "center" && (S = d.alignOffset ?? 2, N = d.sideOffset ?? -5));
40
- let c = O, f = m;
41
- n.type === "menu" ? (c = c ?? "inline-end", f = f ?? "start", C = d.collisionAvoidance ?? ie) : n.type === "menubar" && (c = c ?? "bottom", f = f ?? "start");
42
- const R = n.type === "context-menu", t = $({
43
- anchor: y,
44
- floatingRootContext: j,
45
- positionMethod: U ? "fixed" : E,
46
- mounted: u,
47
- side: c,
48
- sideOffset: N,
49
- align: f,
50
- alignOffset: S,
51
- arrowPadding: R ? 0 : L,
52
- collisionBoundary: D,
53
- collisionPadding: k,
54
- sticky: H,
55
- nodeId: a,
56
- keepMounted: B,
57
- disableAnchorTracking: T,
58
- collisionAvoidance: C,
59
- shiftCrossAxis: R,
60
- externalTree: s
61
- }), q = l.useMemo(() => {
62
- const r = {};
63
- return i || (r.pointerEvents = "none"), {
64
- role: "presentation",
65
- hidden: !u,
66
- style: {
67
- ...t.positionerStyles,
68
- ...r
69
- }
70
- };
71
- }, [i, u, t.positionerStyles]);
72
- l.useEffect(() => {
73
- function r(o) {
74
- o.open ? (o.parentNodeId === a && e.set("hoverEnabled", !1), o.nodeId !== a && o.parentNodeId === e.select("floatingParentNodeId") && e.setOpen(!1, x(g))) : o.parentNodeId === a && o.reason !== g && e.set("hoverEnabled", !0);
75
- }
76
- return s.events.on("menuopenchange", r), () => {
77
- s.events.off("menuopenchange", r);
78
- };
79
- }, [e, s.events, a]), l.useEffect(() => {
80
- if (e.select("floatingParentNodeId") == null)
81
- return;
82
- function r(o) {
83
- if (o.open || o.nodeId !== e.select("floatingParentNodeId"))
84
- return;
85
- const Q = o.reason ?? g;
86
- e.setOpen(!1, x(Q));
87
- }
88
- return s.events.on("menuopenchange", r), () => {
89
- s.events.off("menuopenchange", r);
90
- };
91
- }, [s.events, e]), l.useEffect(() => {
92
- function r(o) {
93
- !i || o.nodeId !== e.select("floatingParentNodeId") || o.target && p && p !== o.target && e.setOpen(!1, x(g));
94
- }
95
- return s.events.on("itemhover", r), () => {
96
- s.events.off("itemhover", r);
97
- };
98
- }, [s.events, i, p, e]), l.useEffect(() => {
99
- const r = {
100
- open: i,
101
- nodeId: a,
102
- parentNodeId: P,
103
- reason: e.select("lastOpenChangeReason")
104
- };
105
- s.events.emit("menuopenchange", r);
106
- }, [s.events, i, e, a, P]);
107
- const z = l.useMemo(() => ({
108
- open: i,
109
- side: t.side,
110
- align: t.align,
111
- anchorHidden: t.anchorHidden,
112
- nested: n.type === "menu"
113
- }), [i, t.side, t.align, t.anchorHidden, n.type]), G = l.useMemo(() => ({
114
- side: t.side,
115
- align: t.align,
116
- arrowRef: t.arrowRef,
117
- arrowUncentered: t.arrowUncentered,
118
- arrowStyles: t.arrowStyles,
119
- nodeId: t.context.nodeId
120
- }), [t.side, t.align, t.arrowRef, t.arrowUncentered, t.arrowStyles, t.context.nodeId]), J = ee("div", d, {
121
- state: z,
122
- stateAttributesMapping: te,
123
- ref: [M, e.useStateSetter("positionerElement")],
124
- props: [q, _]
125
- }), K = u && n.type !== "menu" && (n.type !== "menubar" && F && W !== ce || n.type === "menubar" && n.context.modal);
126
- let h = null;
127
- return n.type === "menubar" ? h = n.context.contentElement : n.type === void 0 && (h = p), /* @__PURE__ */ le(Y.Provider, {
128
- value: G,
129
- children: [K && /* @__PURE__ */ I(oe, {
130
- ref: n.type === "context-menu" || n.type === "nested-context-menu" ? n.context.internalBackdropRef : null,
131
- inert: X(!i),
132
- cutout: h
133
- }), /* @__PURE__ */ I(de, {
134
- id: a,
135
- children: /* @__PURE__ */ I(ne, {
136
- elementsRef: e.context.itemDomElements,
137
- labelsRef: e.context.itemLabels,
138
- children: J
139
- })
140
- })]
141
- });
142
- });
143
- process.env.NODE_ENV !== "production" && (fe.displayName = "MenuPositioner");
144
- export {
145
- fe as MenuPositioner
146
- };