@jfrader/ui 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/README.md +3 -1
  2. package/dist/accordion-CkOZ-tvs.js +178 -0
  3. package/dist/accordion.js +2 -1
  4. package/dist/alert-Dsjx14UW.js +131 -0
  5. package/dist/alert.js +2 -1
  6. package/dist/avatar-BRGKkoSr.js +127 -0
  7. package/dist/avatar.js +2 -1
  8. package/dist/badge-DLxUMsCx.js +104 -0
  9. package/dist/badge.js +2 -1
  10. package/dist/breadcrumbs-694hF_hm.js +131 -0
  11. package/dist/breadcrumbs.js +2 -1
  12. package/dist/button-CoaIcykB.js +190 -0
  13. package/dist/button.js +2 -1
  14. package/dist/calendar-Doj7PTdG.js +379 -0
  15. package/dist/calendar.js +2 -1
  16. package/dist/card-2IM71XZj.js +134 -0
  17. package/dist/card.js +2 -1
  18. package/dist/checkbox-B7xGNFzp.js +136 -0
  19. package/dist/checkbox.js +2 -1
  20. package/dist/{choice-control-DCyQ_hVw.js → choice-control-ByFogYcT.js} +2 -1
  21. package/dist/{collection-registry-C2jnQa7X.js → collection-registry-1l9f3XJZ.js} +3 -2
  22. package/dist/combobox-Bjhxv5U3.js +311 -0
  23. package/dist/combobox.js +2 -1
  24. package/dist/command-palette-BhJwm6cS.js +344 -0
  25. package/dist/command-palette.js +2 -1
  26. package/dist/container-BhnrGPu-.js +36 -0
  27. package/dist/container.js +2 -1
  28. package/dist/{css-CW_HG55W.js → css-Cgj6sCHn.js} +1 -0
  29. package/dist/date-picker-Jk8SpoiO.js +245 -0
  30. package/dist/date-picker.js +2 -1
  31. package/dist/dialog-fhS07G41.js +187 -0
  32. package/dist/dialog.js +2 -1
  33. package/dist/{disclosure-caret-BC6P8AsM.js → disclosure-caret-C5T3fcl6.js} +1 -0
  34. package/dist/divider-v_78HYF5.js +79 -0
  35. package/dist/divider.js +2 -1
  36. package/dist/{field-anatomy-DKkB268x.js → field-anatomy-BzGw1Ch9.js} +4 -3
  37. package/dist/flex-COZzFqI8.js +22 -0
  38. package/dist/flex.js +2 -1
  39. package/dist/{focus-ring-qOS3rPlM.js → focus-ring-BK5W5_NY.js} +1 -0
  40. package/dist/{icon-wrapper-BKo4FI-O.js → icon-wrapper-CFWzew5m.js} +2 -1
  41. package/dist/index.js +37 -36
  42. package/dist/kbd-CeP8Kfvp.js +61 -0
  43. package/dist/kbd.js +2 -1
  44. package/dist/{layout-style-B_6YHQ6Q.js → layout-style-7ZTOiWGR.js} +2 -1
  45. package/dist/{loading-ring-CTpT-IrT.js → loading-ring-BpdB0aFi.js} +2 -1
  46. package/dist/{media-8K3xDAxM.js → media-D_eA_I-e.js} +1 -0
  47. package/dist/menu-B6KCbLCr.js +196 -0
  48. package/dist/menu.js +2 -1
  49. package/dist/navigation-BDht6S2-.js +182 -0
  50. package/dist/navigation.js +2 -1
  51. package/dist/pagination-B50PCaDU.js +151 -0
  52. package/dist/pagination.js +2 -1
  53. package/dist/{part-id-Bg1LSlk7.js → part-id-D0zksy32.js} +1 -0
  54. package/dist/pill-2_XzBdkD.js +51 -0
  55. package/dist/pill.js +2 -1
  56. package/dist/popover-DRHbeIVq.js +103 -0
  57. package/dist/popover.js +2 -1
  58. package/dist/progress-CpsskKTD.js +85 -0
  59. package/dist/progress.js +2 -1
  60. package/dist/radio-group-DPI5KUCj.js +136 -0
  61. package/dist/radio-group.js +2 -1
  62. package/dist/{renderable-DwPvt1I8.js → renderable-DzcIj1Lo.js} +1 -0
  63. package/dist/{roving-focus-DeEZ55-T.js → roving-focus-CYlo_Kf8.js} +1 -0
  64. package/dist/select-C1xGrOhT.js +266 -0
  65. package/dist/select.js +2 -1
  66. package/dist/skeleton-DitdP-yz.js +49 -0
  67. package/dist/skeleton.js +2 -1
  68. package/dist/spinner-CFq5HPoo.js +51 -0
  69. package/dist/spinner.js +2 -1
  70. package/dist/stack-D_g6NJzo.js +21 -0
  71. package/dist/stack.js +2 -1
  72. package/dist/{surface-Bo_aSQOb.js → surface-DZ4d-2aL.js} +1 -0
  73. package/dist/switch-B5TTU-oJ.js +138 -0
  74. package/dist/switch.js +2 -1
  75. package/dist/tabs-C26PWl2c.js +183 -0
  76. package/dist/tabs.js +2 -1
  77. package/dist/text-field-8PQAqRpM.js +75 -0
  78. package/dist/text-field.js +2 -1
  79. package/dist/textarea-CcGWuntL.js +85 -0
  80. package/dist/textarea.js +2 -1
  81. package/dist/theme-root-BRLIA4eb.js +22 -0
  82. package/dist/theme-root.js +2 -1
  83. package/dist/toast-B1PXuwZ4.js +277 -0
  84. package/dist/toast.js +2 -1
  85. package/dist/toggle-group-N_owicT0.js +156 -0
  86. package/dist/toggle-group.js +2 -1
  87. package/dist/tooltip-BJPisf60.js +98 -0
  88. package/dist/tooltip.js +2 -1
  89. package/dist/{trigger-style-f54idgjT.js → trigger-style-B1GFmH7M.js} +2 -1
  90. package/dist/types/components/accordion/accordion.d.ts +13 -9
  91. package/dist/types/components/alert/alert.d.ts +6 -3
  92. package/dist/types/components/avatar/avatar.d.ts +6 -3
  93. package/dist/types/components/badge/badge.d.ts +6 -3
  94. package/dist/types/components/breadcrumbs/breadcrumbs.d.ts +8 -5
  95. package/dist/types/components/button/button.d.ts +6 -3
  96. package/dist/types/components/calendar/calendar.d.ts +11 -7
  97. package/dist/types/components/card/card.d.ts +20 -13
  98. package/dist/types/components/checkbox/checkbox.d.ts +6 -3
  99. package/dist/types/components/combobox/combobox.d.ts +12 -8
  100. package/dist/types/components/command-palette/command-palette.d.ts +22 -15
  101. package/dist/types/components/container/container.d.ts +6 -3
  102. package/dist/types/components/date-picker/date-picker.d.ts +6 -4
  103. package/dist/types/components/dialog/dialog.d.ts +16 -11
  104. package/dist/types/components/divider/divider.d.ts +6 -3
  105. package/dist/types/components/flex/flex.d.ts +6 -3
  106. package/dist/types/components/kbd/kbd.d.ts +8 -5
  107. package/dist/types/components/menu/menu.d.ts +13 -9
  108. package/dist/types/components/navigation/navigation.d.ts +11 -7
  109. package/dist/types/components/pagination/pagination.d.ts +6 -3
  110. package/dist/types/components/pill/pill.d.ts +6 -3
  111. package/dist/types/components/popover/popover.d.ts +7 -5
  112. package/dist/types/components/progress/progress.d.ts +6 -3
  113. package/dist/types/components/radio-group/radio-group.d.ts +8 -5
  114. package/dist/types/components/select/select.d.ts +13 -9
  115. package/dist/types/components/skeleton/skeleton.d.ts +6 -3
  116. package/dist/types/components/spinner/spinner.d.ts +6 -3
  117. package/dist/types/components/stack/stack.d.ts +4 -1
  118. package/dist/types/components/switch/switch.d.ts +6 -3
  119. package/dist/types/components/tabs/tabs.d.ts +14 -9
  120. package/dist/types/components/text-field/text-field.d.ts +6 -3
  121. package/dist/types/components/textarea/textarea.d.ts +6 -3
  122. package/dist/types/components/theme-root/theme-root.d.ts +6 -3
  123. package/dist/types/components/toast/toast.d.ts +6 -4
  124. package/dist/types/components/toggle-group/toggle-group.d.ts +7 -5
  125. package/dist/types/components/tooltip/tooltip.d.ts +7 -5
  126. package/dist/types/overlay/use-native-dialog.d.ts +2 -2
  127. package/dist/{use-controlled-state-DQXkiTQI.js → use-controlled-state-CVXDa-qM.js} +1 -0
  128. package/dist/{use-native-dialog-BCp1chwO.js → use-native-dialog-DWpIUVO1.js} +1 -0
  129. package/dist/{use-overlay-floating-CsZd3qxa.js → use-overlay-floating-efeqppiw.js} +1 -0
  130. package/dist/{visually-hidden-BXVyhj0y.js → visually-hidden-DCWhf0Cb.js} +2 -1
  131. package/package.json +4 -4
  132. package/dist/accordion-Dl-kvgPQ.js +0 -168
  133. package/dist/alert-BzntPa_5.js +0 -129
  134. package/dist/avatar-Dk2ES3ru.js +0 -124
  135. package/dist/badge-DZefC7rm.js +0 -102
  136. package/dist/breadcrumbs-5MCZ_Jr3.js +0 -125
  137. package/dist/button-qy-50NPd.js +0 -187
  138. package/dist/calendar-DcCAiN3b.js +0 -372
  139. package/dist/card-L-Z_1vZN.js +0 -120
  140. package/dist/checkbox-B7em7B-6.js +0 -134
  141. package/dist/combobox-DQcXR94r.js +0 -301
  142. package/dist/command-palette-BRJ8A5De.js +0 -328
  143. package/dist/container-COHiEjI8.js +0 -34
  144. package/dist/date-picker-D1GwiRB9.js +0 -239
  145. package/dist/dialog-CYf9fCZO.js +0 -175
  146. package/dist/divider-bi7OgCI5.js +0 -76
  147. package/dist/flex-CDFDDaiu.js +0 -21
  148. package/dist/kbd-DpiJgDJ2.js +0 -55
  149. package/dist/menu-A9fZUaAG.js +0 -186
  150. package/dist/navigation-Cemnmc_J.js +0 -174
  151. package/dist/pagination-orCjUsn_.js +0 -148
  152. package/dist/pill-Dg2JJHHW.js +0 -49
  153. package/dist/popover-D_YU34WS.js +0 -97
  154. package/dist/progress-XdvBG0Vv.js +0 -83
  155. package/dist/radio-group-CxMJ2Vq7.js +0 -130
  156. package/dist/select-mwFbmzsn.js +0 -256
  157. package/dist/skeleton-qas9ZKK9.js +0 -47
  158. package/dist/spinner-ros2CfIf.js +0 -49
  159. package/dist/stack-Hs8THnIL.js +0 -20
  160. package/dist/switch-E375Bz4X.js +0 -135
  161. package/dist/tabs-CBwRiuul.js +0 -173
  162. package/dist/text-field-BlP8qGn_.js +0 -73
  163. package/dist/textarea-CUG26CH2.js +0 -83
  164. package/dist/theme-root-CrdzwfSo.js +0 -20
  165. package/dist/toast-D_dnqnn-.js +0 -270
  166. package/dist/toggle-group-B7gXCea8.js +0 -150
  167. package/dist/tooltip-BJ2hLV1b.js +0 -92
@@ -0,0 +1,277 @@
1
+ 'use client';
2
+ import { t as e } from "./css-Cgj6sCHn.js";
3
+ import { n as t } from "./media-D_eA_I-e.js";
4
+ import { t as n } from "./renderable-DzcIj1Lo.js";
5
+ import { t as r } from "./button-CoaIcykB.js";
6
+ import { createContext as i, useCallback as a, useContext as o, useEffect as s, useId as c, useMemo as l, useRef as u, useState as d } from "react";
7
+ import { vars as f } from "@jfrader/tokens/vars";
8
+ import { Fragment as p, jsx as m, jsxs as h } from "@emotion/react/jsx-runtime";
9
+ import { createPortal as g } from "react-dom";
10
+ //#region src/components/toast/toast.tsx
11
+ var _ = 4, v = 5e3, y = "Dismiss", b = 100, x = "min(380px, calc(100vw - 32px))", S = "3px", C = i(null), w = i(null), T = e({
12
+ position: "fixed",
13
+ insetBlockEnd: 0,
14
+ insetInlineEnd: 0,
15
+ display: "flex",
16
+ flexDirection: "column",
17
+ gap: f.space[2],
18
+ inlineSize: x,
19
+ margin: 0,
20
+ paddingInlineEnd: f.space[4],
21
+ paddingBlockEnd: f.space[4],
22
+ pointerEvents: "none",
23
+ fontFamily: f.font.sans
24
+ }), E = e({
25
+ boxSizing: "border-box",
26
+ display: "grid",
27
+ gridTemplateColumns: "minmax(0, 1fr) auto",
28
+ alignItems: "start",
29
+ gap: f.space[2],
30
+ backgroundColor: f.color.surfaceRaised,
31
+ border: `1px solid ${f.color.border}`,
32
+ borderRadius: f.radius.lg,
33
+ boxShadow: f.shadow.floating,
34
+ padding: f.space[3],
35
+ color: f.color.text,
36
+ lineHeight: f.lineHeight.base,
37
+ pointerEvents: "auto",
38
+ transitionProperty: "opacity, transform",
39
+ transitionDuration: f.motion.duration.base,
40
+ transitionTimingFunction: f.motion.easeStandard,
41
+ "&[data-populated=\"false\"]": { opacity: 0 },
42
+ "&[data-state=\"closing\"]": {
43
+ opacity: 0,
44
+ transform: `translateY(${f.space[2]})`,
45
+ pointerEvents: "none"
46
+ },
47
+ [t]: { transitionDuration: "0s" }
48
+ }), D = {
49
+ neutral: e({ borderInlineStart: `${S} solid ${f.color.borderStrong}` }),
50
+ success: e({ borderInlineStart: `${S} solid ${f.color.success}` }),
51
+ danger: e({ borderInlineStart: `${S} solid ${f.color.danger}` })
52
+ }, O = e({
53
+ display: "grid",
54
+ gap: f.space[1],
55
+ alignSelf: "center",
56
+ minInlineSize: 0
57
+ }), k = e({
58
+ margin: 0,
59
+ fontSize: f.textSize.sm,
60
+ fontWeight: f.fontWeight.semibold
61
+ }), A = e({
62
+ margin: 0,
63
+ fontSize: f.textSize.sm,
64
+ color: f.color.textMuted
65
+ }), j = e({
66
+ gridColumn: 2,
67
+ gridRow: 1,
68
+ inlineSize: "32px",
69
+ paddingInline: 0
70
+ }), M = e({ display: "contents" }), N = e({
71
+ gridColumn: "1 / -1",
72
+ display: "flex",
73
+ gap: f.space[2]
74
+ });
75
+ function P(e) {
76
+ let t = o(w);
77
+ if (!t) throw Error(`Toast.${e} must be rendered inside <Toast.Provider>.`);
78
+ return t;
79
+ }
80
+ function F() {
81
+ let e = o(C);
82
+ if (!e) throw Error("useToast() must be called inside <Toast.Provider>.");
83
+ return e;
84
+ }
85
+ function I({ children: e, max: t = _, duration: n = v, dismissLabel: r = y }) {
86
+ let i = c(), o = u(0), [s, f] = d([]), p = u([]), h = u(/* @__PURE__ */ new Map()), g = Math.max(1, Math.floor(Number.isFinite(t) ? t : _)), b = a((e, t) => {
87
+ t ? h.current.set(e, t) : h.current.delete(e);
88
+ }, []), x = a((e, t) => {
89
+ let n = new Set(t.filter((e) => e.state === "open").map((e) => h.current.get(e.id)));
90
+ for (let t of e) {
91
+ let e = h.current.get(t.id);
92
+ if (e?.contains(e.ownerDocument.activeElement)) {
93
+ Array.from(e.parentElement?.querySelectorAll("[data-ui=\"toast\"]") ?? []).find((e) => n.has(e))?.querySelector("[data-toast-dismiss]")?.focus();
94
+ break;
95
+ }
96
+ }
97
+ }, []), S = a((e) => {
98
+ o.current += 1;
99
+ let t = `${i}toast-${o.current}`, r = {
100
+ id: t,
101
+ options: {
102
+ ...e,
103
+ duration: e.duration === void 0 ? n : e.duration
104
+ },
105
+ state: "open"
106
+ }, a = p.current, s = [...a, r].slice(-g);
107
+ return x(a.filter((e) => !s.includes(e)), s), p.current = s, f(s), t;
108
+ }, [
109
+ i,
110
+ g,
111
+ n,
112
+ x
113
+ ]), T = a((e) => {
114
+ let t = p.current;
115
+ x(t.filter((t) => t.id === e), t.filter((t) => t.id !== e));
116
+ let n = t.map((t) => t.id === e && t.state === "open" ? {
117
+ ...t,
118
+ state: "closing"
119
+ } : t);
120
+ p.current = n, f(n);
121
+ }, [x]), E = a((e) => {
122
+ let t = p.current, n = t.filter((t) => t.id !== e);
123
+ x(t.filter((t) => t.id === e), n), p.current = n, f(n);
124
+ }, [x]), D = l(() => ({
125
+ toast: S,
126
+ dismiss: T
127
+ }), [S, T]), O = l(() => ({
128
+ toasts: s,
129
+ dismiss: T,
130
+ remove: E,
131
+ registerRoot: b,
132
+ dismissLabel: r
133
+ }), [
134
+ s,
135
+ T,
136
+ E,
137
+ b,
138
+ r
139
+ ]);
140
+ return /* @__PURE__ */ m(C.Provider, {
141
+ value: D,
142
+ children: /* @__PURE__ */ m(w.Provider, {
143
+ value: O,
144
+ children: e
145
+ })
146
+ });
147
+ }
148
+ I.displayName = "Toast.Provider";
149
+ function L({ ref: e, ...t }) {
150
+ let { toasts: n } = P("Viewport"), r = u(null), [i, a] = d(null);
151
+ return s(() => {
152
+ a(r.current?.ownerDocument.body ?? null);
153
+ }, []), /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ m("span", {
154
+ hidden: !0,
155
+ ref: r
156
+ }), i && g(/* @__PURE__ */ m("div", {
157
+ ...t,
158
+ ref: e,
159
+ "data-ui": "toast-viewport",
160
+ css: T,
161
+ children: n.map((e) => /* @__PURE__ */ m(R, { record: e }, e.id))
162
+ }), i)] });
163
+ }
164
+ L.displayName = "Toast.Viewport";
165
+ function R({ record: e }) {
166
+ let { dismiss: t, remove: i, registerRoot: o, dismissLabel: c } = P("Viewport"), { id: l, options: f, state: g } = e, { title: _, description: v, tone: y = "neutral", action: x } = f, S = f.duration, C = u(null), w = a((e) => {
167
+ C.current = e, o(l, e);
168
+ }, [l, o]), [T, F] = d(!1), [I, L] = d(!1), [R, B] = d(!1), V = u(S ?? 0);
169
+ s(() => {
170
+ let e = setTimeout(() => F(!0), b);
171
+ return () => clearTimeout(e);
172
+ }, []);
173
+ let H = T && g === "open" && S !== null && !I && !R;
174
+ return s(() => {
175
+ if (!H) return;
176
+ let e = performance.now(), n = setTimeout(() => t(l), V.current);
177
+ return () => {
178
+ clearTimeout(n), V.current -= performance.now() - e;
179
+ };
180
+ }, [
181
+ H,
182
+ t,
183
+ l
184
+ ]), s(() => {
185
+ if (g !== "closing") return;
186
+ let e = C.current, t = e && typeof e.getAnimations == "function" ? e.getAnimations() : [], n = !1;
187
+ return Promise.allSettled(t.map((e) => e.finished)).then(() => {
188
+ n || i(l);
189
+ }), () => {
190
+ n = !0;
191
+ };
192
+ }, [
193
+ g,
194
+ i,
195
+ l
196
+ ]), /* @__PURE__ */ h("div", {
197
+ ref: w,
198
+ inert: g === "closing",
199
+ "data-ui": "toast",
200
+ "data-tone": y,
201
+ "data-state": g,
202
+ "data-populated": T,
203
+ onPointerEnter: () => L(!0),
204
+ onPointerLeave: () => L(!1),
205
+ onFocus: () => B(!0),
206
+ onBlur: (e) => {
207
+ e.currentTarget.contains(e.relatedTarget) || B(!1);
208
+ },
209
+ css: [E, D[y]],
210
+ children: [/* @__PURE__ */ m("div", {
211
+ role: y === "danger" ? "alert" : "status",
212
+ "aria-atomic": "true",
213
+ css: O,
214
+ children: T && /* @__PURE__ */ h(p, { children: [n(_) && /* @__PURE__ */ m("div", {
215
+ css: k,
216
+ children: _
217
+ }), n(v) && /* @__PURE__ */ m("div", {
218
+ css: A,
219
+ children: v
220
+ })] })
221
+ }), T && /* @__PURE__ */ h("div", {
222
+ css: M,
223
+ children: [/* @__PURE__ */ m(r, {
224
+ variant: "ghost",
225
+ size: "sm",
226
+ "aria-label": c,
227
+ "data-toast-dismiss": "",
228
+ onClick: () => t(l),
229
+ css: j,
230
+ children: /* @__PURE__ */ m(z, {})
231
+ }), x && /* @__PURE__ */ m("div", {
232
+ css: N,
233
+ children: /* @__PURE__ */ m(r, {
234
+ variant: "outline",
235
+ size: "sm",
236
+ onClick: (e) => {
237
+ x?.onClick(e), e.defaultPrevented || t(l);
238
+ },
239
+ children: x.label
240
+ })
241
+ })]
242
+ })]
243
+ });
244
+ }
245
+ function z() {
246
+ return /* @__PURE__ */ h("svg", {
247
+ "aria-hidden": "true",
248
+ viewBox: "0 0 16 16",
249
+ width: "16",
250
+ height: "16",
251
+ fill: "none",
252
+ stroke: "currentColor",
253
+ strokeWidth: "2",
254
+ strokeLinecap: "round",
255
+ children: [/* @__PURE__ */ m("line", {
256
+ x1: "4",
257
+ y1: "4",
258
+ x2: "12",
259
+ y2: "12"
260
+ }), /* @__PURE__ */ m("line", {
261
+ x1: "12",
262
+ y1: "4",
263
+ x2: "4",
264
+ y2: "12"
265
+ })]
266
+ });
267
+ }
268
+ function B(e) {
269
+ return /* @__PURE__ */ m(I, { ...e });
270
+ }
271
+ B.displayName = "Toast";
272
+ var V = Object.assign(B, {
273
+ Provider: I,
274
+ Viewport: L
275
+ });
276
+ //#endregion
277
+ export { F as n, V as t };
package/dist/toast.js CHANGED
@@ -1 +1,2 @@
1
- export { t as Toast, n as useToast } from "./toast-D_dnqnn-.js";
1
+ 'use client';
2
+ export { t as Toast, n as useToast } from "./toast-B1PXuwZ4.js";
@@ -0,0 +1,156 @@
1
+ 'use client';
2
+ import { t as e } from "./css-Cgj6sCHn.js";
3
+ import { t } from "./focus-ring-BK5W5_NY.js";
4
+ import { n, t as r } from "./media-D_eA_I-e.js";
5
+ import { n as i, r as a, t as o } from "./roving-focus-CYlo_Kf8.js";
6
+ import { t as s } from "./use-controlled-state-CVXDa-qM.js";
7
+ import { createContext as c, useContext as l, useEffect as u, useImperativeHandle as d, useMemo as f, useRef as p, useState as m } from "react";
8
+ import { vars as h } from "@jfrader/tokens/vars";
9
+ import { jsx as g } from "@emotion/react/jsx-runtime";
10
+ //#region src/components/toggle-group/toggle-group.tsx
11
+ var _ = c(null);
12
+ function v(e) {
13
+ let t = l(_);
14
+ if (!t) throw Error(`ToggleGroup.${e} must be rendered inside <ToggleGroup>.`);
15
+ return t;
16
+ }
17
+ var y = [], b = (e, t) => {
18
+ if (Array.isArray(e)) {
19
+ if (t === "multiple") return e;
20
+ e = e[0] ?? "";
21
+ }
22
+ return e === void 0 || e === "" ? y : [e];
23
+ }, x = {
24
+ itemSelector: "[data-ui=\"toggle-group-item\"]:not([disabled])",
25
+ ownerSelector: "[data-ui=\"toggle-group-root\"]"
26
+ }, S = "2px", C = e({
27
+ display: "inline-flex",
28
+ gap: S,
29
+ padding: S,
30
+ border: `1px solid ${h.color.borderControl}`,
31
+ borderRadius: h.radius.md,
32
+ backgroundColor: h.color.surfaceInset
33
+ }), w = {
34
+ horizontal: e({ flexDirection: "row" }),
35
+ vertical: e({
36
+ flexDirection: "column",
37
+ alignItems: "stretch"
38
+ })
39
+ }, T = e({
40
+ appearance: "none",
41
+ display: "inline-flex",
42
+ alignItems: "center",
43
+ justifyContent: "center",
44
+ gap: h.space[2],
45
+ minBlockSize: "32px",
46
+ boxSizing: "border-box",
47
+ border: "1px solid transparent",
48
+ borderRadius: h.radius.sm,
49
+ background: "transparent",
50
+ cursor: "pointer",
51
+ paddingBlock: h.space[1],
52
+ paddingInline: h.space[3],
53
+ font: "inherit",
54
+ fontSize: h.textSize.sm,
55
+ fontWeight: h.fontWeight.medium,
56
+ color: h.color.textMuted,
57
+ transitionProperty: "background-color, border-color, color",
58
+ transitionDuration: h.motion.duration.fast,
59
+ transitionTimingFunction: h.motion.easeStandard,
60
+ "&:hover:not(:disabled):not([aria-pressed=\"true\"])": {
61
+ backgroundColor: h.color.surfaceHover,
62
+ color: h.color.text
63
+ },
64
+ "&[aria-pressed=\"true\"]": {
65
+ backgroundColor: h.color.accentSoft,
66
+ borderColor: h.color.accent,
67
+ color: h.color.accentText
68
+ },
69
+ "&[aria-pressed=\"true\"]:hover:not(:disabled)": { backgroundColor: h.color.accentSoftHover },
70
+ "&:disabled": {
71
+ opacity: .55,
72
+ cursor: "not-allowed"
73
+ },
74
+ "&:focus-visible": { ...t },
75
+ [n]: { transitionDuration: "0s" },
76
+ [r]: { "&[aria-pressed=\"true\"]": {
77
+ backgroundColor: "SelectedItem",
78
+ borderColor: "SelectedItem",
79
+ color: "SelectedItemText"
80
+ } }
81
+ });
82
+ function E({ ref: e, type: t = "single", value: n, defaultValue: r, onValueChange: c, orientation: l = "horizontal", disabled: h = !1, allowEmpty: v = !1, label: y, "aria-label": S, onKeyDown: T, ...E }) {
83
+ let [D, O] = s(n, r, c), [k, A] = m(null), j = p(null);
84
+ d(e, () => j.current, []);
85
+ let M = f(() => b(D, t), [D, t]), N = f(() => ({
86
+ pressed: M,
87
+ toggle: (e) => {
88
+ let n = M.includes(e);
89
+ t === "multiple" ? O(n ? M.filter((t) => t !== e) : [...M, e]) : n ? v && O("") : O(e);
90
+ },
91
+ focused: k,
92
+ setFocused: A,
93
+ disabled: h
94
+ }), [
95
+ M,
96
+ O,
97
+ t,
98
+ v,
99
+ k,
100
+ h
101
+ ]);
102
+ u(() => {
103
+ let e = j.current;
104
+ if (!e) return;
105
+ let t = a(e, x);
106
+ if (t.length === 0 || t.some((e) => e.tabIndex === 0)) return;
107
+ let n = t.find((e) => e.getAttribute("aria-pressed") === "true");
108
+ A((n ?? o(t, k) ?? t[0])?.dataset.value ?? null);
109
+ });
110
+ let P = (e) => {
111
+ T?.(e);
112
+ let t = j.current;
113
+ !e.defaultPrevented && t && i(e, t, l, x);
114
+ };
115
+ return /* @__PURE__ */ g(_.Provider, {
116
+ value: N,
117
+ children: /* @__PURE__ */ g("div", {
118
+ ...E,
119
+ ref: j,
120
+ role: "group",
121
+ "aria-label": y ?? S,
122
+ "aria-disabled": h || void 0,
123
+ "data-ui": "toggle-group-root",
124
+ "data-type": t,
125
+ "data-orientation": l,
126
+ onKeyDown: P,
127
+ css: [C, w[l]]
128
+ })
129
+ });
130
+ }
131
+ E.displayName = "ToggleGroup";
132
+ function D({ ref: e, value: t, disabled: n, onClick: r, onFocus: i, ...a }) {
133
+ let { pressed: o, toggle: s, focused: c, setFocused: l, disabled: u } = v("Item"), d = u || n, f = o.includes(t), p = !d && (c === null ? o[0] === t : c === t), m = (e) => {
134
+ r?.(e), !e.defaultPrevented && s(t);
135
+ }, h = (e) => {
136
+ i?.(e), l(t);
137
+ };
138
+ return /* @__PURE__ */ g("button", {
139
+ ...a,
140
+ ref: e,
141
+ type: "button",
142
+ "aria-pressed": f,
143
+ "data-ui": "toggle-group-item",
144
+ "data-value": t,
145
+ "data-state": f ? "on" : "off",
146
+ tabIndex: p ? 0 : -1,
147
+ disabled: d,
148
+ onClick: m,
149
+ onFocus: h,
150
+ css: T
151
+ });
152
+ }
153
+ D.displayName = "ToggleGroup.Item";
154
+ var O = Object.assign(E, { Item: D });
155
+ //#endregion
156
+ export { O as t };
@@ -1 +1,2 @@
1
- export { t as ToggleGroup } from "./toggle-group-B7gXCea8.js";
1
+ 'use client';
2
+ export { t as ToggleGroup } from "./toggle-group-N_owicT0.js";
@@ -0,0 +1,98 @@
1
+ 'use client';
2
+ import { t as e } from "./css-Cgj6sCHn.js";
3
+ import { t } from "./use-controlled-state-CVXDa-qM.js";
4
+ import { t as n } from "./trigger-style-B1GFmH7M.js";
5
+ import { t as r } from "./use-overlay-floating-efeqppiw.js";
6
+ import { createContext as i, useContext as a, useMemo as o } from "react";
7
+ import { vars as s } from "@jfrader/tokens/vars";
8
+ import { jsx as c } from "@emotion/react/jsx-runtime";
9
+ import { FloatingPortal as l, useDismiss as u, useFocus as d, useHover as f, useInteractions as p, useMergeRefs as m, useRole as h } from "@floating-ui/react";
10
+ //#region src/components/tooltip/tooltip.tsx
11
+ var g = 300, _ = 100, v = i(null);
12
+ function y(e) {
13
+ let t = a(v);
14
+ if (!t) throw Error(`Tooltip.${e} must be rendered inside <Tooltip>.`);
15
+ return t;
16
+ }
17
+ var b = e({
18
+ boxSizing: "border-box",
19
+ backgroundColor: s.color.bgSoft,
20
+ border: `1px solid ${s.color.border}`,
21
+ borderRadius: s.radius.sm,
22
+ boxShadow: s.shadow.raised,
23
+ padding: `${s.space[1]} ${s.space[2]}`,
24
+ maxInlineSize: "260px",
25
+ color: s.color.text,
26
+ fontFamily: s.font.sans,
27
+ fontSize: s.textSize.sm,
28
+ lineHeight: s.lineHeight.base
29
+ });
30
+ function x({ open: e, defaultOpen: n = !1, onOpenChange: i, placement: a = "top", openDelay: s = g, closeDelay: l = _, children: m }) {
31
+ let [y = !1, b] = t(e, n, i), { refs: x, floatingStyles: S, context: C } = r({
32
+ open: y,
33
+ placement: a,
34
+ onOpenChange: b
35
+ }), w = f(C, {
36
+ delay: {
37
+ open: s,
38
+ close: l
39
+ },
40
+ move: !1
41
+ }), T = d(C), E = u(C, { escapeKey: !0 }), D = h(C, { role: "tooltip" }), { getReferenceProps: O, getFloatingProps: k } = p([
42
+ w,
43
+ T,
44
+ E,
45
+ D
46
+ ]), A = o(() => ({
47
+ open: y,
48
+ refs: x,
49
+ floatingStyles: S,
50
+ getReferenceProps: O,
51
+ getFloatingProps: k
52
+ }), [
53
+ y,
54
+ x,
55
+ S,
56
+ O,
57
+ k
58
+ ]);
59
+ return /* @__PURE__ */ c(v.Provider, {
60
+ value: A,
61
+ children: m
62
+ });
63
+ }
64
+ x.displayName = "Tooltip";
65
+ function S({ ref: e, "aria-describedby": t, ...r }) {
66
+ let { refs: i, getReferenceProps: a } = y("Trigger"), o = m([i.setReference, e]), s = a(r), l = [t, s["aria-describedby"]].filter(Boolean).join(" ") || void 0;
67
+ return /* @__PURE__ */ c("button", {
68
+ type: "button",
69
+ ...s,
70
+ ref: o,
71
+ "aria-describedby": l,
72
+ "data-ui": "tooltip-trigger",
73
+ css: n
74
+ });
75
+ }
76
+ S.displayName = "Tooltip.Trigger";
77
+ function C({ ref: e, style: t, ...n }) {
78
+ let { open: r, refs: i, floatingStyles: a, getFloatingProps: o } = y("Content"), s = m([i.setFloating, e]);
79
+ if (!r) return null;
80
+ let { tabIndex: u, ...d } = o(n);
81
+ return /* @__PURE__ */ c(l, { children: /* @__PURE__ */ c("div", {
82
+ ...d,
83
+ ref: s,
84
+ "data-ui": "tooltip",
85
+ style: {
86
+ ...t,
87
+ ...a
88
+ },
89
+ css: b
90
+ }) });
91
+ }
92
+ C.displayName = "Tooltip.Content";
93
+ var w = Object.assign(x, {
94
+ Trigger: S,
95
+ Content: C
96
+ });
97
+ //#endregion
98
+ export { w as t };
package/dist/tooltip.js CHANGED
@@ -1 +1,2 @@
1
- export { t as Tooltip } from "./tooltip-BJ2hLV1b.js";
1
+ 'use client';
2
+ export { t as Tooltip } from "./tooltip-BJPisf60.js";
@@ -1,4 +1,5 @@
1
- import { t as e } from "./css-CW_HG55W.js";
1
+ 'use client';
2
+ import { t as e } from "./css-Cgj6sCHn.js";
2
3
  import { vars as t } from "@jfrader/tokens/vars";
3
4
  //#region src/styling/trigger-style.ts
4
5
  var n = e({
@@ -1,7 +1,7 @@
1
- import { type ButtonHTMLAttributes, type HTMLAttributes } from 'react';
1
+ import { type ComponentPropsWithRef } from 'react';
2
2
  export type AccordionType = 'single' | 'multiple';
3
3
  export type AccordionValue = string | string[];
4
- interface AccordionBaseProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'> {
4
+ interface AccordionBaseProps extends Omit<ComponentPropsWithRef<'div'>, 'onChange' | 'defaultValue'> {
5
5
  /** Allow closing the last open panel. */
6
6
  collapsible?: boolean;
7
7
  }
@@ -19,15 +19,19 @@ export interface AccordionMultipleProps extends AccordionBaseProps {
19
19
  onValueChange?: (value: string[]) => void;
20
20
  }
21
21
  export type AccordionProps = AccordionSingleProps | AccordionMultipleProps;
22
- export interface AccordionItemProps extends HTMLAttributes<HTMLDivElement> {
22
+ export interface AccordionItemProps extends ComponentPropsWithRef<'div'> {
23
23
  value: string;
24
24
  disabled?: boolean;
25
25
  }
26
- export type AccordionTriggerProps = ButtonHTMLAttributes<HTMLButtonElement>;
27
- export type AccordionPanelProps = HTMLAttributes<HTMLDivElement>;
28
- export declare const Accordion: import("react").ForwardRefExoticComponent<AccordionProps & import("react").RefAttributes<HTMLDivElement>> & {
29
- Item: import("react").ForwardRefExoticComponent<AccordionItemProps & import("react").RefAttributes<HTMLDivElement>>;
30
- Trigger: import("react").ForwardRefExoticComponent<AccordionTriggerProps & import("react").RefAttributes<HTMLButtonElement>>;
31
- Panel: import("react").ForwardRefExoticComponent<AccordionPanelProps & import("react").RefAttributes<HTMLDivElement>>;
26
+ export type AccordionTriggerProps = ComponentPropsWithRef<'button'>;
27
+ export type AccordionPanelProps = ComponentPropsWithRef<'div'>;
28
+ declare function AccordionRoot({ ref, value: valueProp, defaultValue, onValueChange, type, collapsible, onKeyDown, ...rest }: AccordionProps): import("@emotion/react/jsx-runtime").JSX.Element;
29
+ declare function AccordionItem({ ref, value, disabled, ...rest }: AccordionItemProps): import("@emotion/react/jsx-runtime").JSX.Element;
30
+ declare function AccordionTrigger({ ref, onClick, disabled: disabledProp, ...rest }: AccordionTriggerProps): import("@emotion/react/jsx-runtime").JSX.Element;
31
+ declare function AccordionPanel({ ref, 'aria-labelledby': ariaLabelledByProp, ...rest }: AccordionPanelProps): import("@emotion/react/jsx-runtime").JSX.Element;
32
+ export declare const Accordion: typeof AccordionRoot & {
33
+ Item: typeof AccordionItem;
34
+ Trigger: typeof AccordionTrigger;
35
+ Panel: typeof AccordionPanel;
32
36
  };
33
37
  export {};
@@ -1,11 +1,11 @@
1
- import { type HTMLAttributes, type ReactNode } from 'react';
1
+ import type { ComponentPropsWithRef, ReactNode } from 'react';
2
2
  import { type Interpolation, type Theme } from '../../styling/css';
3
3
  export type AlertTone = 'info' | 'success' | 'warning' | 'danger';
4
4
  export interface AlertPartProps {
5
5
  className?: string;
6
6
  css?: Interpolation<Theme>;
7
7
  }
8
- export interface AlertProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title' | 'role'> {
8
+ export interface AlertProps extends Omit<ComponentPropsWithRef<'div'>, 'title' | 'role'> {
9
9
  tone?: AlertTone;
10
10
  /** Announced tone word. Put visible meaning in the title text. */
11
11
  toneLabel?: string;
@@ -20,4 +20,7 @@ export interface AlertProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'
20
20
  dismiss?: AlertPartProps;
21
21
  };
22
22
  }
23
- export declare const Alert: import("react").ForwardRefExoticComponent<AlertProps & import("react").RefAttributes<HTMLDivElement>>;
23
+ export declare function Alert({ ref, tone, toneLabel, title, children, onDismiss, dismissLabel, slotProps, className, ...rest }: AlertProps): import("@emotion/react/jsx-runtime").JSX.Element;
24
+ export declare namespace Alert {
25
+ var displayName: string;
26
+ }
@@ -1,4 +1,4 @@
1
- import { type HTMLAttributes } from 'react';
1
+ import { type ComponentPropsWithRef } from 'react';
2
2
  import { type Interpolation, type Theme } from '../../styling/css';
3
3
  export type AvatarSize = 'sm' | 'md' | 'lg';
4
4
  export type AvatarStatus = 'online' | 'away' | 'busy' | 'offline';
@@ -6,7 +6,7 @@ export interface AvatarPartProps {
6
6
  className?: string;
7
7
  css?: Interpolation<Theme>;
8
8
  }
9
- export interface AvatarProps extends Omit<HTMLAttributes<HTMLSpanElement>, 'children' | 'role' | 'aria-label'> {
9
+ export interface AvatarProps extends Omit<ComponentPropsWithRef<'span'>, 'children' | 'role' | 'aria-label'> {
10
10
  /** Used for the accessible name and the initials fallback. */
11
11
  name: string;
12
12
  src?: string;
@@ -20,4 +20,7 @@ export interface AvatarProps extends Omit<HTMLAttributes<HTMLSpanElement>, 'chil
20
20
  status?: AvatarPartProps;
21
21
  };
22
22
  }
23
- export declare const Avatar: import("react").ForwardRefExoticComponent<AvatarProps & import("react").RefAttributes<HTMLSpanElement>>;
23
+ export declare function Avatar({ ref, name, src, size, status, statusLabel, slotProps, ...rest }: AvatarProps): import("@emotion/react/jsx-runtime").JSX.Element;
24
+ export declare namespace Avatar {
25
+ var displayName: string;
26
+ }
@@ -1,4 +1,4 @@
1
- import { type HTMLAttributes, type ReactNode } from 'react';
1
+ import type { ComponentPropsWithRef, ReactNode } from 'react';
2
2
  import { type Interpolation, type Theme } from '../../styling/css';
3
3
  export type BadgeVariant = 'standard' | 'dot';
4
4
  export type BadgeTone = 'accent' | 'danger' | 'neutral';
@@ -11,7 +11,7 @@ export interface BadgePartProps {
11
11
  className?: string;
12
12
  css?: Interpolation<Theme>;
13
13
  }
14
- export interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {
14
+ export interface BadgeProps extends ComponentPropsWithRef<'span'> {
15
15
  children: ReactNode;
16
16
  badgeContent?: ReactNode;
17
17
  /** Numbers above `max` render as `max+`. */
@@ -33,4 +33,7 @@ export interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {
33
33
  * - Control with an explicit `aria-label`: put the count in the label (`aria-label="Inbox, 3 unread"`).
34
34
  * - Control named by its visible text: the count is read right after the control's name.
35
35
  */
36
- export declare const Badge: import("react").ForwardRefExoticComponent<BadgeProps & import("react").RefAttributes<HTMLSpanElement>>;
36
+ export declare function Badge({ ref, children, badgeContent, max, showZero, invisible, variant, tone, anchor, overlap, slotProps, className, ...rest }: BadgeProps): import("@emotion/react/jsx-runtime").JSX.Element;
37
+ export declare namespace Badge {
38
+ var displayName: string;
39
+ }