@jfrader/ui 0.1.2 → 0.3.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 (156) hide show
  1. package/README.md +1 -1
  2. package/dist/accordion-Bd-j04hW.js +198 -0
  3. package/dist/accordion.js +1 -1
  4. package/dist/{alert-CA9ZlIZp.js → alert-BBqaKI4k.js} +57 -52
  5. package/dist/alert.js +1 -1
  6. package/dist/{avatar-IUW4yJl0.js → avatar-BahDVO9t.js} +40 -33
  7. package/dist/avatar.js +1 -1
  8. package/dist/{badge-Bru30HEn.js → badge-B_sLygxU.js} +32 -27
  9. package/dist/badge.js +1 -1
  10. package/dist/breadcrumbs-DVAOxfvL.js +141 -0
  11. package/dist/breadcrumbs.js +1 -1
  12. package/dist/{button-Cmixur4Q.js → button-P2e7_44z.js} +65 -53
  13. package/dist/button.js +1 -1
  14. package/dist/calendar-C9Yad_-w.js +394 -0
  15. package/dist/calendar.js +1 -1
  16. package/dist/card-D-aI2QHx.js +158 -0
  17. package/dist/card.js +1 -1
  18. package/dist/checkbox-COYG6L7d.js +140 -0
  19. package/dist/checkbox.js +1 -1
  20. package/dist/{choice-control-ByFogYcT.js → choice-control-5kJkLXgv.js} +1 -1
  21. package/dist/{collection-registry-1l9f3XJZ.js → collection-registry-BTYi6zGh.js} +1 -1
  22. package/dist/combobox-DrmjBbo7.js +327 -0
  23. package/dist/combobox.js +1 -1
  24. package/dist/command-palette-V_2pEay7.js +379 -0
  25. package/dist/command-palette.js +1 -1
  26. package/dist/container-BOaSptJa.js +41 -0
  27. package/dist/container.js +1 -1
  28. package/dist/{date-picker-DrHJMt2p.js → date-picker-ClUYBIBh.js} +69 -59
  29. package/dist/date-picker.js +1 -1
  30. package/dist/dialog-xaydbXl2.js +218 -0
  31. package/dist/dialog.js +1 -1
  32. package/dist/divider-DYoJf0I_.js +84 -0
  33. package/dist/divider.js +1 -1
  34. package/dist/field-anatomy-D2ToMeRa.js +109 -0
  35. package/dist/flex-Dh-_J5-U.js +28 -0
  36. package/dist/flex.js +1 -1
  37. package/dist/{icon-wrapper-CFWzew5m.js → icon-wrapper-stN8sD7R.js} +1 -1
  38. package/dist/index.js +38 -37
  39. package/dist/{kbd-B03_qIwQ.js → kbd-C3ACoMoE.js} +36 -21
  40. package/dist/kbd.js +1 -1
  41. package/dist/{layout-style-7ZTOiWGR.js → layout-style-Cbd1Vilw.js} +1 -1
  42. package/dist/{loading-ring-BpdB0aFi.js → loading-ring-B8-30Dl1.js} +1 -1
  43. package/dist/menu-DU60SMdt.js +216 -0
  44. package/dist/menu.js +1 -1
  45. package/dist/navigation-DhnKriOp.js +197 -0
  46. package/dist/navigation.js +1 -1
  47. package/dist/pagination-DYdwsxwe.js +156 -0
  48. package/dist/pagination.js +1 -1
  49. package/dist/{pill-CrVqffKM.js → pill-DO2gHzMb.js} +16 -10
  50. package/dist/pill.js +1 -1
  51. package/dist/popover-BtN_0ejj.js +113 -0
  52. package/dist/popover.js +1 -1
  53. package/dist/progress-BpJswTG4.js +90 -0
  54. package/dist/progress.js +1 -1
  55. package/dist/radio-group-Ce0_IWQr.js +145 -0
  56. package/dist/radio-group.js +1 -1
  57. package/dist/select-BCS0-LVW.js +286 -0
  58. package/dist/select.js +1 -1
  59. package/dist/{skeleton-gJ4ImO5u.js → skeleton-OoFlOEXO.js} +24 -18
  60. package/dist/skeleton.js +1 -1
  61. package/dist/spinner-C2YDoiMn.js +56 -0
  62. package/dist/spinner.js +1 -1
  63. package/dist/stack-DC3IbtWk.js +27 -0
  64. package/dist/stack.js +1 -1
  65. package/dist/{switch-2hm2WnWt.js → switch-Dr-qjmT4.js} +63 -57
  66. package/dist/switch.js +1 -1
  67. package/dist/sx-Dx9JUKp5.js +23 -0
  68. package/dist/tabs-CK_g1RKa.js +203 -0
  69. package/dist/tabs.js +1 -1
  70. package/dist/text-field-D60ok14S.js +76 -0
  71. package/dist/text-field.js +1 -1
  72. package/dist/textarea-DyfjtP0A.js +86 -0
  73. package/dist/textarea.js +1 -1
  74. package/dist/theme-root-BiXXvQvr.js +42 -0
  75. package/dist/theme-root.js +1 -1
  76. package/dist/{toast-D3Y6OAsg.js → toast-iqelR-r0.js} +41 -30
  77. package/dist/toast.js +1 -1
  78. package/dist/toggle-group-CI0e7hFm.js +166 -0
  79. package/dist/toggle-group.js +1 -1
  80. package/dist/tooltip-CB-HC1js.js +108 -0
  81. package/dist/tooltip.js +1 -1
  82. package/dist/{trigger-style-B1GFmH7M.js → trigger-style-B1KVC8O1.js} +1 -1
  83. package/dist/types/components/accordion/accordion.d.ts +14 -9
  84. package/dist/types/components/alert/alert.d.ts +7 -3
  85. package/dist/types/components/avatar/avatar.d.ts +7 -3
  86. package/dist/types/components/badge/badge.d.ts +7 -3
  87. package/dist/types/components/breadcrumbs/breadcrumbs.d.ts +9 -5
  88. package/dist/types/components/button/button.d.ts +7 -3
  89. package/dist/types/components/calendar/calendar.d.ts +12 -7
  90. package/dist/types/components/card/card.d.ts +21 -13
  91. package/dist/types/components/checkbox/checkbox.d.ts +7 -3
  92. package/dist/types/components/combobox/combobox.d.ts +13 -8
  93. package/dist/types/components/command-palette/command-palette.d.ts +23 -15
  94. package/dist/types/components/container/container.d.ts +7 -3
  95. package/dist/types/components/date-picker/date-picker.d.ts +7 -4
  96. package/dist/types/components/dialog/dialog.d.ts +17 -11
  97. package/dist/types/components/divider/divider.d.ts +7 -3
  98. package/dist/types/components/field/field-anatomy.d.ts +3 -2
  99. package/dist/types/components/flex/flex.d.ts +7 -3
  100. package/dist/types/components/kbd/kbd.d.ts +9 -5
  101. package/dist/types/components/menu/menu.d.ts +14 -9
  102. package/dist/types/components/navigation/navigation.d.ts +12 -7
  103. package/dist/types/components/pagination/pagination.d.ts +7 -3
  104. package/dist/types/components/pill/pill.d.ts +7 -3
  105. package/dist/types/components/popover/popover.d.ts +8 -5
  106. package/dist/types/components/progress/progress.d.ts +7 -3
  107. package/dist/types/components/radio-group/radio-group.d.ts +9 -5
  108. package/dist/types/components/select/select.d.ts +14 -9
  109. package/dist/types/components/skeleton/skeleton.d.ts +7 -3
  110. package/dist/types/components/spinner/spinner.d.ts +7 -3
  111. package/dist/types/components/stack/stack.d.ts +4 -1
  112. package/dist/types/components/switch/switch.d.ts +7 -3
  113. package/dist/types/components/tabs/tabs.d.ts +15 -9
  114. package/dist/types/components/text-field/text-field.d.ts +7 -3
  115. package/dist/types/components/textarea/textarea.d.ts +7 -3
  116. package/dist/types/components/theme-provider/theme-provider.d.ts +11 -0
  117. package/dist/types/components/theme-root/theme-root.d.ts +7 -3
  118. package/dist/types/components/toast/toast.d.ts +7 -4
  119. package/dist/types/components/toggle-group/toggle-group.d.ts +8 -5
  120. package/dist/types/components/tooltip/tooltip.d.ts +8 -5
  121. package/dist/types/index.d.ts +4 -0
  122. package/dist/types/overlay/use-native-dialog.d.ts +2 -2
  123. package/dist/types/styling/css.d.ts +3 -2
  124. package/dist/types/styling/styled.d.ts +1 -0
  125. package/dist/types/styling/sx.d.ts +16 -0
  126. package/dist/types/styling/theme.d.ts +98 -0
  127. package/dist/{visually-hidden-DCWhf0Cb.js → visually-hidden-BJdvqqvn.js} +1 -1
  128. package/package.json +5 -4
  129. package/dist/accordion-C3YbYFBi.js +0 -169
  130. package/dist/breadcrumbs-CQaviWRc.js +0 -126
  131. package/dist/calendar-DUgS0xmp.js +0 -373
  132. package/dist/card-D9CHtouU.js +0 -121
  133. package/dist/checkbox-DKa5BCdy.js +0 -135
  134. package/dist/combobox-Dq3V88Zt.js +0 -302
  135. package/dist/command-palette-6c158eH1.js +0 -329
  136. package/dist/container-xUEIoZzj.js +0 -35
  137. package/dist/css-Cgj6sCHn.js +0 -2
  138. package/dist/dialog-C2NSOOP-.js +0 -176
  139. package/dist/divider-yF5EmhhT.js +0 -77
  140. package/dist/field-anatomy-BzGw1Ch9.js +0 -105
  141. package/dist/flex-5-NI5SSy.js +0 -22
  142. package/dist/menu-bvKRJOhJ.js +0 -187
  143. package/dist/navigation-xPoqh_Iz.js +0 -175
  144. package/dist/pagination-BIKYsxK1.js +0 -149
  145. package/dist/popover-CVAZ_C1a.js +0 -98
  146. package/dist/progress-C8bgujFI.js +0 -84
  147. package/dist/radio-group-CvQ4x8ii.js +0 -131
  148. package/dist/select-CNNiUhKB.js +0 -257
  149. package/dist/spinner-CSFiP0Oi.js +0 -50
  150. package/dist/stack-mEAryjKz.js +0 -21
  151. package/dist/tabs-GBppQabg.js +0 -174
  152. package/dist/text-field-DDPqQu29.js +0 -74
  153. package/dist/textarea-OP8_3IUR.js +0 -84
  154. package/dist/theme-root-eLka0ZP1.js +0 -21
  155. package/dist/toggle-group-BxzJ-6Cp.js +0 -151
  156. package/dist/tooltip-CVl8HS4S.js +0 -93
@@ -0,0 +1,158 @@
1
+ 'use client';
2
+ import { r as e, t } from "./sx-Dx9JUKp5.js";
3
+ import { createContext as n, useContext as r } from "react";
4
+ import { vars as i } from "@jfrader/tokens/vars";
5
+ import { jsx as a } from "@emotion/react/jsx-runtime";
6
+ //#region src/components/card/card.tsx
7
+ var o = n(void 0);
8
+ function s(...e) {
9
+ return e.filter(Boolean).join(" ") || void 0;
10
+ }
11
+ var c = e({
12
+ boxSizing: "border-box",
13
+ minInlineSize: 0,
14
+ backgroundColor: i.color.surfaceRaised,
15
+ border: `1px solid ${i.color.border}`,
16
+ borderRadius: i.radius.lg,
17
+ paddingBlock: i.space[4],
18
+ paddingInline: i.space[5],
19
+ fontFamily: i.font.sans,
20
+ lineHeight: i.lineHeight.base,
21
+ color: i.color.text
22
+ }), l = {
23
+ flat: e({ boxShadow: "none" }),
24
+ raised: e({ boxShadow: i.shadow.raised })
25
+ }, u = e({
26
+ display: "grid",
27
+ gap: i.space[1],
28
+ marginBlockEnd: i.space[4]
29
+ }), d = e({
30
+ margin: 0,
31
+ fontSize: i.textSize.md,
32
+ fontWeight: i.fontWeight.semibold,
33
+ lineHeight: i.lineHeight.tight,
34
+ color: i.color.text
35
+ }), f = e({
36
+ margin: 0,
37
+ fontSize: i.textSize.sm,
38
+ color: i.color.textMuted
39
+ }), p = e({
40
+ fontSize: i.textSize.sm,
41
+ color: i.color.text
42
+ }), m = e({
43
+ display: "flex",
44
+ flexWrap: "wrap",
45
+ alignItems: "center",
46
+ justifyContent: "space-between",
47
+ gap: i.space[2],
48
+ marginBlockStart: i.space[4],
49
+ paddingBlockStart: i.space[4],
50
+ borderBlockStart: `1px solid ${i.color.borderSubtle}`,
51
+ "& > :only-child": { marginInlineStart: "auto" }
52
+ });
53
+ function h({ ref: e, variant: n = "raised", slotProps: r, className: i, sx: u, ...d }) {
54
+ return /* @__PURE__ */ a(o.Provider, {
55
+ value: r,
56
+ children: /* @__PURE__ */ a(t, {
57
+ className: s(r?.root?.className, i),
58
+ styles: [
59
+ c,
60
+ l[n],
61
+ r?.root?.css
62
+ ],
63
+ sx: u,
64
+ children: (t) => /* @__PURE__ */ a("div", {
65
+ ...d,
66
+ ref: e,
67
+ "data-ui": "card",
68
+ "data-variant": n,
69
+ className: t
70
+ })
71
+ })
72
+ });
73
+ }
74
+ h.displayName = "Card";
75
+ function g({ ref: e, className: n, sx: i, ...c }) {
76
+ let l = r(o)?.header;
77
+ return /* @__PURE__ */ a(t, {
78
+ className: s(l?.className, n),
79
+ styles: [u, l?.css],
80
+ sx: i,
81
+ children: (t) => /* @__PURE__ */ a("div", {
82
+ ...c,
83
+ ref: e,
84
+ "data-ui": "card-header",
85
+ className: t
86
+ })
87
+ });
88
+ }
89
+ g.displayName = "Card.Header";
90
+ function _({ ref: e, level: n = 3, className: i, sx: c, ...l }) {
91
+ let u = r(o)?.title, f = `h${n}`;
92
+ return /* @__PURE__ */ a(t, {
93
+ className: s(u?.className, i),
94
+ styles: [d, u?.css],
95
+ sx: c,
96
+ children: (t) => /* @__PURE__ */ a(f, {
97
+ ...l,
98
+ ref: e,
99
+ "data-ui": "card-title",
100
+ className: t
101
+ })
102
+ });
103
+ }
104
+ _.displayName = "Card.Title";
105
+ function v({ ref: e, className: n, sx: i, ...c }) {
106
+ let l = r(o)?.description;
107
+ return /* @__PURE__ */ a(t, {
108
+ className: s(l?.className, n),
109
+ styles: [f, l?.css],
110
+ sx: i,
111
+ children: (t) => /* @__PURE__ */ a("p", {
112
+ ...c,
113
+ ref: e,
114
+ "data-ui": "card-description",
115
+ className: t
116
+ })
117
+ });
118
+ }
119
+ v.displayName = "Card.Description";
120
+ function y({ ref: e, className: n, sx: i, ...c }) {
121
+ let l = r(o)?.content;
122
+ return /* @__PURE__ */ a(t, {
123
+ className: s(l?.className, n),
124
+ styles: [p, l?.css],
125
+ sx: i,
126
+ children: (t) => /* @__PURE__ */ a("div", {
127
+ ...c,
128
+ ref: e,
129
+ "data-ui": "card-content",
130
+ className: t
131
+ })
132
+ });
133
+ }
134
+ y.displayName = "Card.Content";
135
+ function b({ ref: e, className: n, sx: i, ...c }) {
136
+ let l = r(o)?.footer;
137
+ return /* @__PURE__ */ a(t, {
138
+ className: s(l?.className, n),
139
+ styles: [m, l?.css],
140
+ sx: i,
141
+ children: (t) => /* @__PURE__ */ a("div", {
142
+ ...c,
143
+ ref: e,
144
+ "data-ui": "card-footer",
145
+ className: t
146
+ })
147
+ });
148
+ }
149
+ b.displayName = "Card.Footer";
150
+ var x = Object.assign(h, {
151
+ Header: g,
152
+ Title: _,
153
+ Description: v,
154
+ Content: y,
155
+ Footer: b
156
+ });
157
+ //#endregion
158
+ export { x as t };
package/dist/card.js CHANGED
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- export { t as Card } from "./card-D9CHtouU.js";
2
+ export { t as Card } from "./card-D-aI2QHx.js";
@@ -0,0 +1,140 @@
1
+ 'use client';
2
+ import { r as e, t } from "./sx-Dx9JUKp5.js";
3
+ import { n } from "./media-D_eA_I-e.js";
4
+ import { t as r } from "./renderable-DzcIj1Lo.js";
5
+ import { i, n as a, r as o, t as s } from "./choice-control-5kJkLXgv.js";
6
+ import { useEffect as c, useId as l, useImperativeHandle as u, useRef as d } from "react";
7
+ import { vars as f } from "@jfrader/tokens/vars";
8
+ import { jsx as p, jsxs as m } from "@emotion/react/jsx-runtime";
9
+ //#region src/components/checkbox/checkbox.tsx
10
+ var h = {
11
+ sm: "16px",
12
+ md: "20px"
13
+ }, g = e({
14
+ "input:checked + span svg": { opacity: 1 },
15
+ "&[data-indeterminate] input + span": {
16
+ backgroundColor: f.color.accent,
17
+ borderColor: f.color.accent
18
+ },
19
+ "&[data-indeterminate] input + span svg": { opacity: 1 }
20
+ }), _ = e({
21
+ display: "inline-flex",
22
+ alignItems: "center",
23
+ justifyContent: "center",
24
+ flexShrink: 0,
25
+ boxSizing: "border-box",
26
+ border: `1px solid ${f.color.borderControl}`,
27
+ borderRadius: f.radius.sm,
28
+ backgroundColor: f.color.surfaceRaised,
29
+ color: f.color.accentContrast,
30
+ transitionProperty: "background-color, border-color",
31
+ transitionDuration: f.motion.duration.fast,
32
+ transitionTimingFunction: f.motion.easeStandard,
33
+ "& svg": {
34
+ inlineSize: "75%",
35
+ blockSize: "75%",
36
+ opacity: 0
37
+ },
38
+ [n]: { transitionDuration: "0s" }
39
+ }), v = {
40
+ sm: e({
41
+ inlineSize: h.sm,
42
+ blockSize: h.sm
43
+ }),
44
+ md: e({
45
+ inlineSize: h.md,
46
+ blockSize: h.md
47
+ })
48
+ }, y = {
49
+ sm: e({ fontSize: f.textSize.sm }),
50
+ md: e({ fontSize: f.textSize.md })
51
+ }, b = e({
52
+ fontSize: f.textSize.sm,
53
+ color: f.color.textMuted
54
+ }), x = {
55
+ sm: e({ marginInlineStart: `calc(${h.sm} + ${f.space[2]})` }),
56
+ md: e({ marginInlineStart: `calc(${h.md} + ${f.space[2]})` })
57
+ };
58
+ function S({ indeterminate: e }) {
59
+ return /* @__PURE__ */ p("svg", {
60
+ viewBox: "0 0 16 16",
61
+ fill: "none",
62
+ stroke: "currentColor",
63
+ strokeWidth: "2",
64
+ strokeLinecap: "round",
65
+ strokeLinejoin: "round",
66
+ children: e ? /* @__PURE__ */ p("line", {
67
+ x1: "4",
68
+ y1: "8",
69
+ x2: "12",
70
+ y2: "8"
71
+ }) : /* @__PURE__ */ p("polyline", { points: "3.5 8.5 6.5 11.5 12.5 4.5" })
72
+ });
73
+ }
74
+ function C({ ref: e, label: n, description: f, indeterminate: h = !1, size: C = "md", onChange: w, onCheckedChange: T, slotProps: E, className: D, sx: O, "aria-labelledby": k, "aria-describedby": A, ...j }) {
75
+ let M = d(null);
76
+ u(e, () => M.current, []), c(() => {
77
+ M.current && (M.current.indeterminate = h);
78
+ }, [h]);
79
+ let N = l(), P = `${N}-label`, F = `${N}-description`, I = r(n), L = r(f), R = [k, I && P].filter(Boolean).join(" ") || void 0, z = [A, L && F].filter(Boolean).join(" ") || void 0, B = [D, E?.root?.className].filter(Boolean).join(" ") || void 0, V = (e) => {
80
+ h && (e.currentTarget.indeterminate = !0), w?.(e), T?.(e.currentTarget.checked);
81
+ };
82
+ return /* @__PURE__ */ p(t, {
83
+ className: B,
84
+ styles: [
85
+ o,
86
+ g,
87
+ a,
88
+ E?.root?.css
89
+ ],
90
+ sx: O,
91
+ children: (e) => /* @__PURE__ */ m("label", {
92
+ "data-ui": "checkbox",
93
+ "data-indeterminate": h || void 0,
94
+ className: e,
95
+ children: [/* @__PURE__ */ m("span", {
96
+ css: i,
97
+ children: [
98
+ /* @__PURE__ */ p("input", {
99
+ ...j,
100
+ ref: M,
101
+ type: "checkbox",
102
+ "aria-labelledby": R,
103
+ "aria-describedby": z,
104
+ "aria-checked": h ? "mixed" : void 0,
105
+ onChange: V,
106
+ css: s
107
+ }),
108
+ /* @__PURE__ */ p("span", {
109
+ "aria-hidden": "true",
110
+ className: E?.control?.className,
111
+ css: [
112
+ _,
113
+ v[C],
114
+ E?.control?.css
115
+ ],
116
+ children: /* @__PURE__ */ p(S, { indeterminate: h })
117
+ }),
118
+ I && /* @__PURE__ */ p("span", {
119
+ id: P,
120
+ className: E?.label?.className,
121
+ css: [y[C], E?.label?.css],
122
+ children: n
123
+ })
124
+ ]
125
+ }), L && /* @__PURE__ */ p("span", {
126
+ id: F,
127
+ className: E?.description?.className,
128
+ css: [
129
+ b,
130
+ x[C],
131
+ E?.description?.css
132
+ ],
133
+ children: f
134
+ })]
135
+ })
136
+ });
137
+ }
138
+ C.displayName = "Checkbox";
139
+ //#endregion
140
+ export { C as t };
package/dist/checkbox.js CHANGED
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- export { t as Checkbox } from "./checkbox-DKa5BCdy.js";
2
+ export { t as Checkbox } from "./checkbox-COYG6L7d.js";
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { t as e } from "./css-Cgj6sCHn.js";
2
+ import { r as e } from "./sx-Dx9JUKp5.js";
3
3
  import { vars as t } from "@jfrader/tokens/vars";
4
4
  //#region src/styling/choice-control.ts
5
5
  var n = e({
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { t as e } from "./css-Cgj6sCHn.js";
2
+ import { r as e } from "./sx-Dx9JUKp5.js";
3
3
  import { t } from "./part-id-D0zksy32.js";
4
4
  import { useCallback as n, useLayoutEffect as r, useMemo as i, useState as a } from "react";
5
5
  import { vars as o } from "@jfrader/tokens/vars";
@@ -0,0 +1,327 @@
1
+ 'use client';
2
+ import { r as e, t } from "./sx-Dx9JUKp5.js";
3
+ import { n, t as r } from "./use-controlled-state-CVXDa-qM.js";
4
+ import { t as i } from "./renderable-DzcIj1Lo.js";
5
+ import { a, c as o, d as s, f as c, l, o as u, r as d, s as f, t as p, u as m } from "./collection-registry-BTYi6zGh.js";
6
+ import { t as h } from "./use-overlay-floating-efeqppiw.js";
7
+ import { t as g } from "./text-field-D60ok14S.js";
8
+ import { createContext as _, useCallback as v, useContext as y, useId as b, useLayoutEffect as x, useMemo as S, useRef as C, useState as w } from "react";
9
+ import { vars as T } from "@jfrader/tokens/vars";
10
+ import { jsx as E, jsxs as ee } from "@emotion/react/jsx-runtime";
11
+ import { FloatingList as D, FloatingPortal as O, useDismiss as te, useInteractions as k, useListNavigation as A, useMergeRefs as j } from "@floating-ui/react";
12
+ //#region src/components/combobox/combobox.tsx
13
+ var M = "bottom-start", N = "✓", P = "No results", ne = (e, t) => e.toLocaleLowerCase().includes(t.toLocaleLowerCase()), F = _(null), I = _(!1);
14
+ function L(e) {
15
+ let t = y(F);
16
+ if (!t) throw Error(`Combobox.${e} must be rendered inside <Combobox>.`);
17
+ return t;
18
+ }
19
+ function R(e) {
20
+ let t = L(e);
21
+ if (!y(I)) throw Error(`Combobox.${e} must be rendered inside <Combobox.List>.`);
22
+ return t;
23
+ }
24
+ var z = e({ "&[hidden]": { display: "none" } }), B = e({
25
+ paddingBlock: T.space[1],
26
+ paddingInline: T.space[2],
27
+ fontSize: T.textSize.sm,
28
+ color: T.color.textMuted
29
+ });
30
+ function V({ value: e, defaultValue: t, onValueChange: i, open: o, defaultOpen: s = !1, onOpenChange: c, name: l, filter: u = ne, onInputChange: d, children: f }) {
31
+ let p = b(), [m, g] = w(`${p}-listbox`), [_, y] = w(!1), [x = null, T] = r(e, t ?? null, i), [D = !1, O] = r(o, s, c), [j, N] = w(null), [P, I] = w(""), [L, R] = a(), [z, B] = w(null), V = C([]), H = C(null), U = n(d), W = v((e, t) => t === "" || u(e, t), [u]), { valuesByIndex: G, skippedIndices: K, matchCount: re } = S(() => {
32
+ let e = [], t = /* @__PURE__ */ new Set(), n = 0;
33
+ return L.forEach((r, i) => {
34
+ if (r.index === -1) return;
35
+ e[r.index] = i;
36
+ let a = W(r.label, P);
37
+ a && (n += 1), (r.disabled || !a) && t.add(r.index);
38
+ }), {
39
+ valuesByIndex: e,
40
+ skippedIndices: t,
41
+ matchCount: n
42
+ };
43
+ }, [
44
+ L,
45
+ P,
46
+ W
47
+ ]), { refs: q, floatingStyles: J, context: Y } = h({
48
+ open: D,
49
+ placement: M,
50
+ onOpenChange: (e) => O(e)
51
+ }), X = te(Y, {
52
+ escapeKey: !0,
53
+ outsidePress: !0
54
+ }), ie = A(Y, {
55
+ listRef: V,
56
+ activeIndex: j,
57
+ onNavigate: N,
58
+ virtual: !0,
59
+ loop: !0,
60
+ disabledIndices: (e) => K.has(e)
61
+ }), { getReferenceProps: Z, getFloatingProps: Q, getItemProps: $ } = k([X, ie]), ae = S(() => {
62
+ let e = (e) => {
63
+ T(e), O(!1), H.current?.commitLabel(L.get(e)?.label ?? "");
64
+ };
65
+ return {
66
+ baseId: p,
67
+ listId: m,
68
+ setListId: g,
69
+ setInputDisabled: y,
70
+ open: D,
71
+ selectedValue: x,
72
+ activeIndex: j,
73
+ options: L,
74
+ matchCount: re,
75
+ inputLabelling: z,
76
+ inputHandleRef: H,
77
+ refs: q,
78
+ floatingStyles: J,
79
+ elementsRef: V,
80
+ getReferenceProps: Z,
81
+ getFloatingProps: Q,
82
+ getItemProps: $,
83
+ onInputChange: U,
84
+ isVisible: (e) => W(e, P),
85
+ findMatches: (e) => {
86
+ let t = 0, n = null, r = null;
87
+ return L.forEach((i) => {
88
+ i.index !== -1 && W(i.label, e) && (t += 1, !i.disabled && ((n === null || i.index < n) && (n = i.index), (r === null || i.index > r) && (r = i.index)));
89
+ }), {
90
+ count: t,
91
+ first: n,
92
+ last: r
93
+ };
94
+ },
95
+ setQuery: I,
96
+ setActiveIndex: N,
97
+ selectValue: e,
98
+ selectIndex: (t) => {
99
+ let n = G[t];
100
+ n === void 0 || K.has(t) || e(n);
101
+ },
102
+ clearValue: () => T(null),
103
+ requestOpenChange: O,
104
+ registration: R,
105
+ setInputLabelling: B
106
+ };
107
+ }, [
108
+ p,
109
+ m,
110
+ D,
111
+ x,
112
+ j,
113
+ L,
114
+ P,
115
+ re,
116
+ z,
117
+ q,
118
+ J,
119
+ Z,
120
+ Q,
121
+ $,
122
+ U,
123
+ W,
124
+ G,
125
+ K,
126
+ T,
127
+ O,
128
+ R
129
+ ]);
130
+ return /* @__PURE__ */ ee(F.Provider, {
131
+ value: ae,
132
+ children: [f, l !== void 0 && /* @__PURE__ */ E("input", {
133
+ type: "hidden",
134
+ name: l,
135
+ value: x ?? "",
136
+ disabled: _
137
+ })]
138
+ });
139
+ }
140
+ V.displayName = "Combobox";
141
+ function H({ ref: e, inputValue: t, defaultInputValue: n, label: a, description: o, error: s, size: c, slotProps: l, className: u, sx: d, id: f, onChange: p, onKeyDown: m, onBlur: h, disabled: _ = !1, ...v }) {
142
+ let { listId: y, open: S, selectedValue: C, activeIndex: T, options: ee, inputHandleRef: D, refs: O, getReferenceProps: te, onInputChange: k, findMatches: A, setQuery: M, setActiveIndex: N, selectIndex: P, clearValue: ne, requestOpenChange: F, setInputLabelling: I, setInputDisabled: R } = L("Input"), z = j([O.setReference, e]), B = b(), V = f ?? B, H = `${V}-label`, U = i(a), W = v["aria-labelledby"], G = v["aria-label"], [K, re] = w(n), [q, J] = w(() => (t ?? n) !== void 0), Y = C === null ? void 0 : ee.get(C)?.label, X = t ?? (q ? K ?? "" : Y ?? K ?? ""), [, ie] = r(X, void 0, k), Z = (e) => {
143
+ ie(e), t === void 0 && re(e);
144
+ }, Q = t !== void 0 || q ? X : "", $ = (e) => {
145
+ J(!1), Z(e);
146
+ };
147
+ x(() => {
148
+ M(Q);
149
+ }, [Q, M]), x(() => (R(_), () => R(!1)), [_, R]), x(() => (D.current = { commitLabel: $ }, () => {
150
+ D.current = null;
151
+ })), x(() => (I(W !== void 0 || !U ? {
152
+ labelledBy: W,
153
+ label: G
154
+ } : { labelledBy: H }), () => I(null)), [
155
+ W,
156
+ G,
157
+ U,
158
+ H,
159
+ I
160
+ ]);
161
+ let ae = (e) => {
162
+ p?.(e);
163
+ let n = e.currentTarget.value;
164
+ J(!0), Z(n), n === "" && ne();
165
+ let r = t ?? n;
166
+ if (r === "") {
167
+ N(null), F(!1);
168
+ return;
169
+ }
170
+ let i = A(r);
171
+ N(i.first), i.count > 0 && F(!0);
172
+ }, oe = (e) => {
173
+ if (m?.(e), !e.defaultPrevented) {
174
+ if (e.key === "Escape") q && Y !== void 0 && $(Y);
175
+ else if (S) {
176
+ if (e.key === "Enter" && T !== null) e.preventDefault(), P(T);
177
+ else if (e.key === "Home" || e.key === "End") {
178
+ let t = A(Q), n = e.key === "Home" ? t.first : t.last;
179
+ if (n === null) return;
180
+ e.preventDefault(), N(n);
181
+ }
182
+ }
183
+ }
184
+ }, se = (e) => {
185
+ h?.(e), S && F(!1);
186
+ };
187
+ return /* @__PURE__ */ E(g, {
188
+ ...te({
189
+ ...v,
190
+ onKeyDown: oe,
191
+ onBlur: se
192
+ }),
193
+ ref: z,
194
+ id: V,
195
+ label: U ? /* @__PURE__ */ E("span", {
196
+ id: H,
197
+ children: a
198
+ }) : a,
199
+ description: o,
200
+ error: s,
201
+ size: c,
202
+ slotProps: l,
203
+ className: u,
204
+ sx: d,
205
+ value: X,
206
+ disabled: _,
207
+ onChange: ae,
208
+ role: "combobox",
209
+ autoComplete: "off",
210
+ "aria-autocomplete": "list",
211
+ "aria-expanded": S,
212
+ "aria-controls": S ? y : void 0,
213
+ "data-state": S ? "open" : "closed",
214
+ "data-ui": "combobox-input"
215
+ });
216
+ }
217
+ H.displayName = "Combobox.Input";
218
+ function U({ ref: e, id: n, style: r, onMouseDown: i, children: a, className: o, sx: l, ...u }) {
219
+ let { baseId: d, setListId: f, open: p, inputLabelling: m, refs: h, floatingStyles: g, elementsRef: _, getFloatingProps: v } = L("List"), y = n ?? `${d}-listbox`;
220
+ x(() => (f(y), () => f(`${d}-listbox`)), [
221
+ d,
222
+ y,
223
+ f
224
+ ]);
225
+ let b = j([p ? h.setFloating : null, e]), S = u["aria-labelledby"] !== void 0 || u["aria-label"] !== void 0 ? {} : m?.labelledBy === void 0 ? { "aria-label": m?.label } : { "aria-labelledby": m.labelledBy }, C = (e) => {
226
+ i?.(e), e.preventDefault();
227
+ };
228
+ return /* @__PURE__ */ E(O, { children: /* @__PURE__ */ E(t, {
229
+ className: o,
230
+ styles: [c, s],
231
+ sx: l,
232
+ children: (e) => /* @__PURE__ */ E("div", {
233
+ ...v({
234
+ id: y,
235
+ ...S,
236
+ ...u,
237
+ onMouseDown: C
238
+ }),
239
+ ref: b,
240
+ role: "listbox",
241
+ hidden: !p,
242
+ "data-state": p ? "open" : "closed",
243
+ "data-ui": "combobox-list",
244
+ style: {
245
+ ...r,
246
+ ...g
247
+ },
248
+ className: e,
249
+ children: /* @__PURE__ */ E(D, {
250
+ elementsRef: _,
251
+ children: /* @__PURE__ */ E(I.Provider, {
252
+ value: !0,
253
+ children: a
254
+ })
255
+ })
256
+ })
257
+ }) });
258
+ }
259
+ U.displayName = "Combobox.List";
260
+ function W({ ref: e, value: n, disabled: r = !1, onClick: i, children: a, className: s, sx: c, ...h }) {
261
+ let { baseId: g, selectedValue: _, activeIndex: v, options: y, isVisible: b, getItemProps: x, selectValue: S, registration: w } = R("Item"), T = C(null), { ref: D, index: O } = d(n, w, T, (e, t) => ({
262
+ index: e,
263
+ label: t,
264
+ disabled: r
265
+ })), te = j([D, e]), k = y.get(n)?.label, A = k !== void 0 && !b(k), M = O !== -1 && v === O, P = _ === n, ne = (e) => {
266
+ i?.(e), !(r || e.defaultPrevented) && S(n);
267
+ };
268
+ return /* @__PURE__ */ E(t, {
269
+ className: s,
270
+ styles: [
271
+ f,
272
+ u,
273
+ l,
274
+ z
275
+ ],
276
+ sx: c,
277
+ children: (e) => /* @__PURE__ */ ee("div", {
278
+ ...x({
279
+ id: p(g, n),
280
+ ...h,
281
+ onClick: ne
282
+ }),
283
+ ref: te,
284
+ role: "option",
285
+ hidden: A,
286
+ "aria-selected": P,
287
+ "aria-disabled": r || void 0,
288
+ "data-active": M || void 0,
289
+ "data-ui": "combobox-item",
290
+ className: e,
291
+ children: [/* @__PURE__ */ E("span", {
292
+ ref: T,
293
+ css: m,
294
+ children: a
295
+ }), P && /* @__PURE__ */ E("span", {
296
+ "aria-hidden": "true",
297
+ css: o,
298
+ children: N
299
+ })]
300
+ })
301
+ });
302
+ }
303
+ W.displayName = "Combobox.Item";
304
+ function G({ ref: e, children: n, className: r, sx: a, ...o }) {
305
+ let { matchCount: s } = R("Empty");
306
+ return s > 0 ? null : /* @__PURE__ */ E(t, {
307
+ className: r,
308
+ styles: B,
309
+ sx: a,
310
+ children: (t) => /* @__PURE__ */ E("div", {
311
+ ...o,
312
+ ref: e,
313
+ "data-ui": "combobox-empty",
314
+ className: t,
315
+ children: i(n) ? n : P
316
+ })
317
+ });
318
+ }
319
+ G.displayName = "Combobox.Empty";
320
+ var K = Object.assign(V, {
321
+ Input: H,
322
+ List: U,
323
+ Item: W,
324
+ Empty: G
325
+ });
326
+ //#endregion
327
+ export { K as t };
package/dist/combobox.js CHANGED
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- export { t as Combobox } from "./combobox-Dq3V88Zt.js";
2
+ export { t as Combobox } from "./combobox-DrmjBbo7.js";