@jfrader/ui 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +123 -2
  3. package/dist/accordion-Dl-kvgPQ.js +168 -0
  4. package/dist/accordion.js +1 -0
  5. package/dist/alert-BzntPa_5.js +129 -0
  6. package/dist/alert.js +1 -0
  7. package/dist/avatar-Dk2ES3ru.js +124 -0
  8. package/dist/avatar.js +1 -0
  9. package/dist/badge-DZefC7rm.js +102 -0
  10. package/dist/badge.js +1 -0
  11. package/dist/breadcrumbs-5MCZ_Jr3.js +125 -0
  12. package/dist/breadcrumbs.js +1 -0
  13. package/dist/button-qy-50NPd.js +187 -0
  14. package/dist/button.js +1 -0
  15. package/dist/calendar-DcCAiN3b.js +372 -0
  16. package/dist/calendar.js +1 -0
  17. package/dist/card-L-Z_1vZN.js +120 -0
  18. package/dist/card.js +1 -0
  19. package/dist/checkbox-B7em7B-6.js +134 -0
  20. package/dist/checkbox.js +1 -0
  21. package/dist/choice-control-DCyQ_hVw.js +35 -0
  22. package/dist/collection-registry-C2jnQa7X.js +97 -0
  23. package/dist/combobox-DQcXR94r.js +301 -0
  24. package/dist/combobox.js +1 -0
  25. package/dist/command-palette-BRJ8A5De.js +328 -0
  26. package/dist/command-palette.js +1 -0
  27. package/dist/container-COHiEjI8.js +34 -0
  28. package/dist/container.js +1 -0
  29. package/dist/css-CW_HG55W.js +1 -0
  30. package/dist/date-picker-D1GwiRB9.js +239 -0
  31. package/dist/date-picker.js +1 -0
  32. package/dist/dialog-CYf9fCZO.js +175 -0
  33. package/dist/dialog.js +1 -0
  34. package/dist/disclosure-caret-BC6P8AsM.js +13 -0
  35. package/dist/divider-bi7OgCI5.js +76 -0
  36. package/dist/divider.js +1 -0
  37. package/dist/field-anatomy-DKkB268x.js +104 -0
  38. package/dist/flex-CDFDDaiu.js +21 -0
  39. package/dist/flex.js +1 -0
  40. package/dist/focus-ring-qOS3rPlM.js +11 -0
  41. package/dist/icon-wrapper-BKo4FI-O.js +12 -0
  42. package/dist/index.js +37 -0
  43. package/dist/kbd-DpiJgDJ2.js +55 -0
  44. package/dist/kbd.js +1 -0
  45. package/dist/layout-style-B_6YHQ6Q.js +56 -0
  46. package/dist/loading-ring-CTpT-IrT.js +18 -0
  47. package/dist/media-8K3xDAxM.js +4 -0
  48. package/dist/menu-A9fZUaAG.js +186 -0
  49. package/dist/menu.js +1 -0
  50. package/dist/navigation-Cemnmc_J.js +174 -0
  51. package/dist/navigation.js +1 -0
  52. package/dist/pagination-orCjUsn_.js +148 -0
  53. package/dist/pagination.js +1 -0
  54. package/dist/part-id-Bg1LSlk7.js +4 -0
  55. package/dist/pill-Dg2JJHHW.js +49 -0
  56. package/dist/pill.js +1 -0
  57. package/dist/popover-D_YU34WS.js +97 -0
  58. package/dist/popover.js +1 -0
  59. package/dist/progress-XdvBG0Vv.js +83 -0
  60. package/dist/progress.js +1 -0
  61. package/dist/radio-group-CxMJ2Vq7.js +130 -0
  62. package/dist/radio-group.js +1 -0
  63. package/dist/renderable-DwPvt1I8.js +6 -0
  64. package/dist/roving-focus-DeEZ55-T.js +35 -0
  65. package/dist/select-mwFbmzsn.js +256 -0
  66. package/dist/select.js +1 -0
  67. package/dist/skeleton-qas9ZKK9.js +47 -0
  68. package/dist/skeleton.js +1 -0
  69. package/dist/spinner-ros2CfIf.js +49 -0
  70. package/dist/spinner.js +1 -0
  71. package/dist/stack-Hs8THnIL.js +20 -0
  72. package/dist/stack.js +1 -0
  73. package/dist/surface-Bo_aSQOb.js +18 -0
  74. package/dist/switch-E375Bz4X.js +135 -0
  75. package/dist/switch.js +1 -0
  76. package/dist/tabs-CBwRiuul.js +173 -0
  77. package/dist/tabs.js +1 -0
  78. package/dist/text-field-BlP8qGn_.js +73 -0
  79. package/dist/text-field.js +1 -0
  80. package/dist/textarea-CUG26CH2.js +83 -0
  81. package/dist/textarea.js +1 -0
  82. package/dist/theme-root-CrdzwfSo.js +20 -0
  83. package/dist/theme-root.js +1 -0
  84. package/dist/toast-D_dnqnn-.js +270 -0
  85. package/dist/toast.js +1 -0
  86. package/dist/toggle-group-B7gXCea8.js +150 -0
  87. package/dist/toggle-group.js +1 -0
  88. package/dist/tooltip-BJ2hLV1b.js +92 -0
  89. package/dist/tooltip.js +1 -0
  90. package/dist/trigger-style-f54idgjT.js +35 -0
  91. package/dist/types/components/accordion/accordion.d.ts +33 -0
  92. package/dist/types/components/accordion/index.d.ts +2 -0
  93. package/dist/types/components/alert/alert.d.ts +23 -0
  94. package/dist/types/components/alert/index.d.ts +2 -0
  95. package/dist/types/components/avatar/avatar.d.ts +23 -0
  96. package/dist/types/components/avatar/index.d.ts +2 -0
  97. package/dist/types/components/badge/badge.d.ts +36 -0
  98. package/dist/types/components/badge/index.d.ts +2 -0
  99. package/dist/types/components/breadcrumbs/breadcrumbs.d.ts +15 -0
  100. package/dist/types/components/breadcrumbs/index.d.ts +2 -0
  101. package/dist/types/components/button/button.d.ts +34 -0
  102. package/dist/types/components/button/index.d.ts +2 -0
  103. package/dist/types/components/calendar/calendar.d.ts +28 -0
  104. package/dist/types/components/calendar/calendar.styles.d.ts +9 -0
  105. package/dist/types/components/calendar/calendar.utils.d.ts +37 -0
  106. package/dist/types/components/calendar/index.d.ts +2 -0
  107. package/dist/types/components/card/card.d.ts +34 -0
  108. package/dist/types/components/card/index.d.ts +2 -0
  109. package/dist/types/components/checkbox/checkbox.d.ts +21 -0
  110. package/dist/types/components/checkbox/index.d.ts +2 -0
  111. package/dist/types/components/combobox/combobox.d.ts +44 -0
  112. package/dist/types/components/combobox/index.d.ts +2 -0
  113. package/dist/types/components/command-palette/command-palette.d.ts +47 -0
  114. package/dist/types/components/command-palette/command-palette.styles.d.ts +8 -0
  115. package/dist/types/components/command-palette/index.d.ts +2 -0
  116. package/dist/types/components/container/container.d.ts +14 -0
  117. package/dist/types/components/container/index.d.ts +3 -0
  118. package/dist/types/components/date-picker/date-picker.d.ts +39 -0
  119. package/dist/types/components/date-picker/index.d.ts +2 -0
  120. package/dist/types/components/dialog/dialog.d.ts +61 -0
  121. package/dist/types/components/dialog/index.d.ts +2 -0
  122. package/dist/types/components/divider/divider.d.ts +14 -0
  123. package/dist/types/components/divider/index.d.ts +2 -0
  124. package/dist/types/components/field/field-anatomy.d.ts +49 -0
  125. package/dist/types/components/flex/flex.d.ts +4 -0
  126. package/dist/types/components/flex/index.d.ts +3 -0
  127. package/dist/types/components/kbd/index.d.ts +2 -0
  128. package/dist/types/components/kbd/kbd.d.ts +6 -0
  129. package/dist/types/components/menu/index.d.ts +2 -0
  130. package/dist/types/components/menu/menu.d.ts +29 -0
  131. package/dist/types/components/navigation/index.d.ts +2 -0
  132. package/dist/types/components/navigation/navigation.d.ts +24 -0
  133. package/dist/types/components/pagination/index.d.ts +2 -0
  134. package/dist/types/components/pagination/pagination.d.ts +14 -0
  135. package/dist/types/components/pill/index.d.ts +2 -0
  136. package/dist/types/components/pill/pill.d.ts +6 -0
  137. package/dist/types/components/popover/index.d.ts +2 -0
  138. package/dist/types/components/popover/popover.d.ts +19 -0
  139. package/dist/types/components/progress/index.d.ts +2 -0
  140. package/dist/types/components/progress/progress.d.ts +19 -0
  141. package/dist/types/components/radio-group/index.d.ts +2 -0
  142. package/dist/types/components/radio-group/radio-group.d.ts +29 -0
  143. package/dist/types/components/select/index.d.ts +2 -0
  144. package/dist/types/components/select/select.d.ts +38 -0
  145. package/dist/types/components/skeleton/index.d.ts +2 -0
  146. package/dist/types/components/skeleton/skeleton.d.ts +11 -0
  147. package/dist/types/components/spinner/index.d.ts +2 -0
  148. package/dist/types/components/spinner/spinner.d.ts +8 -0
  149. package/dist/types/components/stack/index.d.ts +3 -0
  150. package/dist/types/components/stack/stack.d.ts +7 -0
  151. package/dist/types/components/switch/index.d.ts +2 -0
  152. package/dist/types/components/switch/switch.d.ts +20 -0
  153. package/dist/types/components/tabs/index.d.ts +2 -0
  154. package/dist/types/components/tabs/tabs.d.ts +22 -0
  155. package/dist/types/components/text-field/index.d.ts +2 -0
  156. package/dist/types/components/text-field/text-field.d.ts +14 -0
  157. package/dist/types/components/textarea/index.d.ts +2 -0
  158. package/dist/types/components/textarea/textarea.d.ts +17 -0
  159. package/dist/types/components/theme-root/index.d.ts +2 -0
  160. package/dist/types/components/theme-root/theme-root.d.ts +7 -0
  161. package/dist/types/components/toast/index.d.ts +2 -0
  162. package/dist/types/components/toast/toast.d.ts +37 -0
  163. package/dist/types/components/toggle-group/index.d.ts +2 -0
  164. package/dist/types/components/toggle-group/toggle-group.d.ts +29 -0
  165. package/dist/types/components/tooltip/index.d.ts +2 -0
  166. package/dist/types/components/tooltip/tooltip.d.ts +23 -0
  167. package/dist/types/index.d.ts +36 -0
  168. package/dist/types/overlay/use-native-dialog.d.ts +39 -0
  169. package/dist/types/overlay/use-overlay-floating.d.ts +11 -0
  170. package/dist/types/overlay/use-scroll-lock.d.ts +5 -0
  171. package/dist/types/styling/choice-control.d.ts +8 -0
  172. package/dist/types/styling/css.d.ts +2 -0
  173. package/dist/types/styling/disclosure-caret.d.ts +9 -0
  174. package/dist/types/styling/focus-ring.d.ts +10 -0
  175. package/dist/types/styling/icon-wrapper.d.ts +1 -0
  176. package/dist/types/styling/input-control.d.ts +1 -0
  177. package/dist/types/styling/layout-style.d.ts +26 -0
  178. package/dist/types/styling/listbox-style.d.ts +12 -0
  179. package/dist/types/styling/loading-ring.d.ts +14 -0
  180. package/dist/types/styling/media.d.ts +2 -0
  181. package/dist/types/styling/surface.d.ts +19 -0
  182. package/dist/types/styling/trigger-style.d.ts +1 -0
  183. package/dist/types/styling/visually-hidden.d.ts +1 -0
  184. package/dist/types/utils/collection-registry.d.ts +41 -0
  185. package/dist/types/utils/part-id.d.ts +2 -0
  186. package/dist/types/utils/renderable.d.ts +3 -0
  187. package/dist/types/utils/roving-focus.d.ts +18 -0
  188. package/dist/types/utils/use-controlled-state.d.ts +7 -0
  189. package/dist/types/utils/use-latest-callback.d.ts +10 -0
  190. package/dist/use-controlled-state-DQXkiTQI.js +20 -0
  191. package/dist/use-native-dialog-BCp1chwO.js +83 -0
  192. package/dist/use-overlay-floating-CsZd3qxa.js +18 -0
  193. package/dist/visually-hidden-BXVyhj0y.js +16 -0
  194. package/package.json +198 -3
@@ -0,0 +1,120 @@
1
+ import { t as e } from "./css-CW_HG55W.js";
2
+ import { createContext as t, forwardRef as n, useContext as r } from "react";
3
+ import { vars as i } from "@jfrader/tokens/vars";
4
+ import { jsx as a } from "@emotion/react/jsx-runtime";
5
+ //#region src/components/card/card.tsx
6
+ var o = t(void 0);
7
+ function s(...e) {
8
+ return e.filter(Boolean).join(" ") || void 0;
9
+ }
10
+ var c = e({
11
+ boxSizing: "border-box",
12
+ minInlineSize: 0,
13
+ backgroundColor: i.color.surfaceRaised,
14
+ border: `1px solid ${i.color.border}`,
15
+ borderRadius: i.radius.lg,
16
+ paddingBlock: i.space[4],
17
+ paddingInline: i.space[5],
18
+ fontFamily: i.font.sans,
19
+ lineHeight: i.lineHeight.base,
20
+ color: i.color.text
21
+ }), l = {
22
+ flat: e({ boxShadow: "none" }),
23
+ raised: e({ boxShadow: i.shadow.raised })
24
+ }, u = e({
25
+ display: "grid",
26
+ gap: i.space[1],
27
+ marginBlockEnd: i.space[4]
28
+ }), d = e({
29
+ margin: 0,
30
+ fontSize: i.textSize.md,
31
+ fontWeight: i.fontWeight.semibold,
32
+ lineHeight: i.lineHeight.tight,
33
+ color: i.color.text
34
+ }), f = e({
35
+ margin: 0,
36
+ fontSize: i.textSize.sm,
37
+ color: i.color.textMuted
38
+ }), p = e({
39
+ fontSize: i.textSize.sm,
40
+ color: i.color.text
41
+ }), m = e({
42
+ display: "flex",
43
+ flexWrap: "wrap",
44
+ alignItems: "center",
45
+ justifyContent: "space-between",
46
+ gap: i.space[2],
47
+ marginBlockStart: i.space[4],
48
+ paddingBlockStart: i.space[4],
49
+ borderBlockStart: `1px solid ${i.color.borderSubtle}`,
50
+ "& > :only-child": { marginInlineStart: "auto" }
51
+ }), h = n(function({ variant: e = "raised", slotProps: t, className: n, ...r }, i) {
52
+ return /* @__PURE__ */ a(o.Provider, {
53
+ value: t,
54
+ children: /* @__PURE__ */ a("div", {
55
+ ...r,
56
+ ref: i,
57
+ "data-ui": "card",
58
+ "data-variant": e,
59
+ className: s(t?.root?.className, n),
60
+ css: [
61
+ c,
62
+ l[e],
63
+ t?.root?.css
64
+ ]
65
+ })
66
+ });
67
+ }), g = n(function({ className: e, ...t }, n) {
68
+ let i = r(o)?.header;
69
+ return /* @__PURE__ */ a("div", {
70
+ ...t,
71
+ ref: n,
72
+ "data-ui": "card-header",
73
+ className: s(i?.className, e),
74
+ css: [u, i?.css]
75
+ });
76
+ }), _ = n(function({ level: e = 3, className: t, ...n }, i) {
77
+ let c = r(o)?.title, l = `h${e}`;
78
+ return /* @__PURE__ */ a(l, {
79
+ ...n,
80
+ ref: i,
81
+ "data-ui": "card-title",
82
+ className: s(c?.className, t),
83
+ css: [d, c?.css]
84
+ });
85
+ }), v = n(function({ className: e, ...t }, n) {
86
+ let i = r(o)?.description;
87
+ return /* @__PURE__ */ a("p", {
88
+ ...t,
89
+ ref: n,
90
+ "data-ui": "card-description",
91
+ className: s(i?.className, e),
92
+ css: [f, i?.css]
93
+ });
94
+ }), y = n(function({ className: e, ...t }, n) {
95
+ let i = r(o)?.content;
96
+ return /* @__PURE__ */ a("div", {
97
+ ...t,
98
+ ref: n,
99
+ "data-ui": "card-content",
100
+ className: s(i?.className, e),
101
+ css: [p, i?.css]
102
+ });
103
+ }), b = n(function({ className: e, ...t }, n) {
104
+ let i = r(o)?.footer;
105
+ return /* @__PURE__ */ a("div", {
106
+ ...t,
107
+ ref: n,
108
+ "data-ui": "card-footer",
109
+ className: s(i?.className, e),
110
+ css: [m, i?.css]
111
+ });
112
+ }), x = Object.assign(h, {
113
+ Header: g,
114
+ Title: _,
115
+ Description: v,
116
+ Content: y,
117
+ Footer: b
118
+ });
119
+ //#endregion
120
+ export { x as t };
package/dist/card.js ADDED
@@ -0,0 +1 @@
1
+ export { t as Card } from "./card-L-Z_1vZN.js";
@@ -0,0 +1,134 @@
1
+ import { t as e } from "./css-CW_HG55W.js";
2
+ import { n as t } from "./media-8K3xDAxM.js";
3
+ import { t as n } from "./renderable-DwPvt1I8.js";
4
+ import { i as r, n as i, r as a, t as o } from "./choice-control-DCyQ_hVw.js";
5
+ import { forwardRef as s, useEffect as c, useId as l, useImperativeHandle as u, useRef as d } from "react";
6
+ import { vars as f } from "@jfrader/tokens/vars";
7
+ import { jsx as p, jsxs as m } from "@emotion/react/jsx-runtime";
8
+ //#region src/components/checkbox/checkbox.tsx
9
+ var h = {
10
+ sm: "16px",
11
+ md: "20px"
12
+ }, g = e({
13
+ "input:checked + span svg": { opacity: 1 },
14
+ "&[data-indeterminate] input + span": {
15
+ backgroundColor: f.color.accent,
16
+ borderColor: f.color.accent
17
+ },
18
+ "&[data-indeterminate] input + span svg": { opacity: 1 }
19
+ }), _ = e({
20
+ display: "inline-flex",
21
+ alignItems: "center",
22
+ justifyContent: "center",
23
+ flexShrink: 0,
24
+ boxSizing: "border-box",
25
+ border: `1px solid ${f.color.borderControl}`,
26
+ borderRadius: f.radius.sm,
27
+ backgroundColor: f.color.surfaceRaised,
28
+ color: f.color.accentContrast,
29
+ transitionProperty: "background-color, border-color",
30
+ transitionDuration: f.motion.duration.fast,
31
+ transitionTimingFunction: f.motion.easeStandard,
32
+ "& svg": {
33
+ inlineSize: "75%",
34
+ blockSize: "75%",
35
+ opacity: 0
36
+ },
37
+ [t]: { transitionDuration: "0s" }
38
+ }), v = {
39
+ sm: e({
40
+ inlineSize: h.sm,
41
+ blockSize: h.sm
42
+ }),
43
+ md: e({
44
+ inlineSize: h.md,
45
+ blockSize: h.md
46
+ })
47
+ }, y = {
48
+ sm: e({ fontSize: f.textSize.sm }),
49
+ md: e({ fontSize: f.textSize.md })
50
+ }, b = e({
51
+ fontSize: f.textSize.sm,
52
+ color: f.color.textMuted
53
+ }), x = {
54
+ sm: e({ marginInlineStart: `calc(${h.sm} + ${f.space[2]})` }),
55
+ md: e({ marginInlineStart: `calc(${h.md} + ${f.space[2]})` })
56
+ };
57
+ function S({ indeterminate: e }) {
58
+ return /* @__PURE__ */ p("svg", {
59
+ viewBox: "0 0 16 16",
60
+ fill: "none",
61
+ stroke: "currentColor",
62
+ strokeWidth: "2",
63
+ strokeLinecap: "round",
64
+ strokeLinejoin: "round",
65
+ children: e ? /* @__PURE__ */ p("line", {
66
+ x1: "4",
67
+ y1: "8",
68
+ x2: "12",
69
+ y2: "8"
70
+ }) : /* @__PURE__ */ p("polyline", { points: "3.5 8.5 6.5 11.5 12.5 4.5" })
71
+ });
72
+ }
73
+ var C = s(function({ label: e, description: t, indeterminate: s = !1, size: f = "md", onChange: h, onCheckedChange: C, slotProps: w, className: T, "aria-labelledby": E, "aria-describedby": D, ...O }, k) {
74
+ let A = d(null);
75
+ u(k, () => A.current, []), c(() => {
76
+ A.current && (A.current.indeterminate = s);
77
+ }, [s]);
78
+ let j = l(), M = `${j}-label`, N = `${j}-description`, P = n(e), F = n(t), I = [E, P && M].filter(Boolean).join(" ") || void 0, L = [D, F && N].filter(Boolean).join(" ") || void 0, R = [T, w?.root?.className].filter(Boolean).join(" ") || void 0, z = (e) => {
79
+ s && (e.currentTarget.indeterminate = !0), h?.(e), C?.(e.currentTarget.checked);
80
+ };
81
+ return /* @__PURE__ */ m("label", {
82
+ "data-ui": "checkbox",
83
+ "data-indeterminate": s || void 0,
84
+ className: R,
85
+ css: [
86
+ a,
87
+ g,
88
+ i,
89
+ w?.root?.css
90
+ ],
91
+ children: [/* @__PURE__ */ m("span", {
92
+ css: r,
93
+ children: [
94
+ /* @__PURE__ */ p("input", {
95
+ ...O,
96
+ ref: A,
97
+ type: "checkbox",
98
+ "aria-labelledby": I,
99
+ "aria-describedby": L,
100
+ "aria-checked": s ? "mixed" : void 0,
101
+ onChange: z,
102
+ css: o
103
+ }),
104
+ /* @__PURE__ */ p("span", {
105
+ "aria-hidden": "true",
106
+ className: w?.control?.className,
107
+ css: [
108
+ _,
109
+ v[f],
110
+ w?.control?.css
111
+ ],
112
+ children: /* @__PURE__ */ p(S, { indeterminate: s })
113
+ }),
114
+ P && /* @__PURE__ */ p("span", {
115
+ id: M,
116
+ className: w?.label?.className,
117
+ css: [y[f], w?.label?.css],
118
+ children: e
119
+ })
120
+ ]
121
+ }), F && /* @__PURE__ */ p("span", {
122
+ id: N,
123
+ className: w?.description?.className,
124
+ css: [
125
+ b,
126
+ x[f],
127
+ w?.description?.css
128
+ ],
129
+ children: t
130
+ })]
131
+ });
132
+ });
133
+ //#endregion
134
+ export { C as t };
@@ -0,0 +1 @@
1
+ export { t as Checkbox } from "./checkbox-B7em7B-6.js";
@@ -0,0 +1,35 @@
1
+ import { t as e } from "./css-CW_HG55W.js";
2
+ import { vars as t } from "@jfrader/tokens/vars";
3
+ //#region src/styling/choice-control.ts
4
+ var n = e({
5
+ display: "inline-flex",
6
+ flexDirection: "column",
7
+ gap: t.space[1],
8
+ cursor: "pointer",
9
+ "input:checked + span": {
10
+ backgroundColor: t.color.accent,
11
+ borderColor: t.color.accent
12
+ }
13
+ }), r = e({
14
+ "input:focus-visible + span": {
15
+ outline: `2px solid ${t.color.focusRing}`,
16
+ outlineOffset: "2px"
17
+ },
18
+ "&:has(input:disabled)": {
19
+ opacity: .55,
20
+ cursor: "not-allowed"
21
+ }
22
+ }), i = e({
23
+ position: "relative",
24
+ display: "inline-flex",
25
+ alignItems: "center",
26
+ gap: t.space[2]
27
+ }), a = e({
28
+ position: "absolute",
29
+ opacity: 0,
30
+ inlineSize: "16px",
31
+ blockSize: "16px",
32
+ margin: 0
33
+ });
34
+ //#endregion
35
+ export { i, r as n, n as r, a as t };
@@ -0,0 +1,97 @@
1
+ import { t as e } from "./css-CW_HG55W.js";
2
+ import { t } from "./part-id-Bg1LSlk7.js";
3
+ import { useCallback as n, useLayoutEffect as r, useMemo as i, useState as a } from "react";
4
+ import { vars as o } from "@jfrader/tokens/vars";
5
+ import { useListItem as s } from "@floating-ui/react";
6
+ //#region src/styling/listbox-style.ts
7
+ var c = e({
8
+ boxSizing: "border-box",
9
+ display: "flex",
10
+ flexDirection: "column",
11
+ backgroundColor: o.color.surfaceRaised,
12
+ border: `1px solid ${o.color.border}`,
13
+ borderRadius: o.radius.md,
14
+ boxShadow: o.shadow.overlay,
15
+ padding: o.space[1],
16
+ minInlineSize: "180px",
17
+ maxInlineSize: "min(320px, calc(100vw - 32px))",
18
+ color: o.color.text,
19
+ fontFamily: o.font.sans,
20
+ lineHeight: o.lineHeight.base
21
+ }), l = e({
22
+ maxBlockSize: "280px",
23
+ overflow: "auto",
24
+ "&[hidden]": { display: "none" }
25
+ }), u = e({
26
+ boxSizing: "border-box",
27
+ display: "flex",
28
+ alignItems: "center",
29
+ inlineSize: "100%",
30
+ minBlockSize: "32px",
31
+ flexShrink: 0,
32
+ borderRadius: o.radius.sm,
33
+ paddingBlock: o.space[1],
34
+ paddingInline: o.space[2],
35
+ fontSize: o.textSize.sm,
36
+ color: o.color.text,
37
+ cursor: "pointer",
38
+ userSelect: "none",
39
+ transitionProperty: "background-color",
40
+ transitionDuration: o.motion.duration.fast,
41
+ transitionTimingFunction: o.motion.easeStandard,
42
+ "&[data-active]": {
43
+ outline: `2px solid ${o.color.focusRing}`,
44
+ outlineOffset: "-2px"
45
+ },
46
+ "@media (prefers-reduced-motion: reduce)": { transitionDuration: "0s" }
47
+ }), d = e({
48
+ "&:hover:not([aria-disabled=\"true\"]), &[data-active]:not([aria-disabled=\"true\"])": { backgroundColor: o.color.surfaceHover },
49
+ "&[aria-disabled=\"true\"]": {
50
+ opacity: .55,
51
+ cursor: "not-allowed"
52
+ }
53
+ }), f = e({
54
+ gap: o.space[2],
55
+ "&[aria-selected=\"true\"]": { fontWeight: o.fontWeight.medium }
56
+ }), p = e({
57
+ flex: 1,
58
+ minInlineSize: 0
59
+ }), m = e({ color: o.color.accentText }), h = (e, t) => e !== void 0 && Object.keys(t).every((n) => e[n] === t[n]), g = (e, n) => `${t(e, "opt", n)}-item`;
60
+ function _() {
61
+ let [e, t] = a(() => /* @__PURE__ */ new Map()), r = n((e, n) => t((t) => h(t.get(e), n) ? t : new Map(t).set(e, n)), []), o = n((e) => t((t) => {
62
+ if (!t.has(e)) return t;
63
+ let n = new Map(t);
64
+ return n.delete(e), n;
65
+ }), []);
66
+ return [e, i(() => ({
67
+ register: r,
68
+ unregister: o
69
+ }), [r, o])];
70
+ }
71
+ function v(e) {
72
+ return s(e);
73
+ }
74
+ function y(e, t, n) {
75
+ r(() => {
76
+ if (t && e !== -1) return n.add(e), () => {
77
+ n.delete(e);
78
+ };
79
+ }, [
80
+ t,
81
+ e,
82
+ n
83
+ ]);
84
+ }
85
+ function b(e, t, n, i, a) {
86
+ let o = v(), { index: s } = o;
87
+ return r(() => {
88
+ let r = n.current?.textContent ?? "";
89
+ if (t.register(e, i(s, r)), a === void 0 || s === -1) return;
90
+ let { labelsRef: o, include: c } = a;
91
+ return o.current[s] = c ? r : null, () => {
92
+ o.current[s] = null;
93
+ };
94
+ }), r(() => () => t.unregister(e), [e, t]), o;
95
+ }
96
+ //#endregion
97
+ export { _ as a, m as c, l as d, c as f, v as i, f as l, y as n, d as o, b as r, u as s, g as t, p as u };
@@ -0,0 +1,301 @@
1
+ import { t as e } from "./css-CW_HG55W.js";
2
+ import { n as t, t as n } from "./use-controlled-state-DQXkiTQI.js";
3
+ import { t as r } from "./renderable-DwPvt1I8.js";
4
+ import { a as i, c as a, d as o, f as s, l as c, o as l, r as u, s as d, t as f, u as p } from "./collection-registry-C2jnQa7X.js";
5
+ import { t as m } from "./use-overlay-floating-CsZd3qxa.js";
6
+ import { t as h } from "./text-field-BlP8qGn_.js";
7
+ import { createContext as g, forwardRef as _, useCallback as v, useContext as y, useId as ee, useLayoutEffect as b, useMemo as x, useRef as S, useState as C } from "react";
8
+ import { vars as w } from "@jfrader/tokens/vars";
9
+ import { jsx as T, jsxs as E } from "@emotion/react/jsx-runtime";
10
+ import { FloatingList as D, FloatingPortal as O, useDismiss as te, useInteractions as k, useListNavigation as A, useMergeRefs as j } from "@floating-ui/react";
11
+ //#region src/components/combobox/combobox.tsx
12
+ var M = "bottom-start", N = "✓", P = "No results", F = (e, t) => e.toLocaleLowerCase().includes(t.toLocaleLowerCase()), I = g(null), L = g(!1);
13
+ function R(e) {
14
+ let t = y(I);
15
+ if (!t) throw Error(`Combobox.${e} must be rendered inside <Combobox>.`);
16
+ return t;
17
+ }
18
+ function z(e) {
19
+ let t = R(e);
20
+ if (!y(L)) throw Error(`Combobox.${e} must be rendered inside <Combobox.List>.`);
21
+ return t;
22
+ }
23
+ var B = e({ "&[hidden]": { display: "none" } }), V = e({
24
+ paddingBlock: w.space[1],
25
+ paddingInline: w.space[2],
26
+ fontSize: w.textSize.sm,
27
+ color: w.color.textMuted
28
+ });
29
+ function H({ value: e, defaultValue: r, onValueChange: a, open: o, defaultOpen: s = !1, onOpenChange: c, name: l, filter: u = F, onInputChange: d, children: f }) {
30
+ let p = ee(), [h, g] = C(`${p}-listbox`), [_, y] = C(!1), [b = null, w] = n(e, r ?? null, a), [D = !1, O] = n(o, s, c), [j, N] = C(null), [P, L] = C(""), [R, z] = i(), [B, V] = C(null), H = S([]), U = S(null), W = t(d), G = v((e, t) => t === "" || u(e, t), [u]), { valuesByIndex: K, skippedIndices: q, matchCount: J } = x(() => {
31
+ let e = [], t = /* @__PURE__ */ new Set(), n = 0;
32
+ return R.forEach((r, i) => {
33
+ if (r.index === -1) return;
34
+ e[r.index] = i;
35
+ let a = G(r.label, P);
36
+ a && (n += 1), (r.disabled || !a) && t.add(r.index);
37
+ }), {
38
+ valuesByIndex: e,
39
+ skippedIndices: t,
40
+ matchCount: n
41
+ };
42
+ }, [
43
+ R,
44
+ P,
45
+ G
46
+ ]), { refs: Y, floatingStyles: X, context: Z } = m({
47
+ open: D,
48
+ placement: M,
49
+ onOpenChange: (e) => O(e)
50
+ }), ne = te(Z, {
51
+ escapeKey: !0,
52
+ outsidePress: !0
53
+ }), re = A(Z, {
54
+ listRef: H,
55
+ activeIndex: j,
56
+ onNavigate: N,
57
+ virtual: !0,
58
+ loop: !0,
59
+ disabledIndices: (e) => q.has(e)
60
+ }), { getReferenceProps: Q, getFloatingProps: $, getItemProps: ie } = k([ne, re]), ae = x(() => {
61
+ let e = (e) => {
62
+ w(e), O(!1), U.current?.commitLabel(R.get(e)?.label ?? "");
63
+ };
64
+ return {
65
+ baseId: p,
66
+ listId: h,
67
+ setListId: g,
68
+ setInputDisabled: y,
69
+ open: D,
70
+ selectedValue: b,
71
+ activeIndex: j,
72
+ options: R,
73
+ matchCount: J,
74
+ inputLabelling: B,
75
+ inputHandleRef: U,
76
+ refs: Y,
77
+ floatingStyles: X,
78
+ elementsRef: H,
79
+ getReferenceProps: Q,
80
+ getFloatingProps: $,
81
+ getItemProps: ie,
82
+ onInputChange: W,
83
+ isVisible: (e) => G(e, P),
84
+ findMatches: (e) => {
85
+ let t = 0, n = null, r = null;
86
+ return R.forEach((i) => {
87
+ i.index !== -1 && G(i.label, e) && (t += 1, !i.disabled && ((n === null || i.index < n) && (n = i.index), (r === null || i.index > r) && (r = i.index)));
88
+ }), {
89
+ count: t,
90
+ first: n,
91
+ last: r
92
+ };
93
+ },
94
+ setQuery: L,
95
+ setActiveIndex: N,
96
+ selectValue: e,
97
+ selectIndex: (t) => {
98
+ let n = K[t];
99
+ n === void 0 || q.has(t) || e(n);
100
+ },
101
+ clearValue: () => w(null),
102
+ requestOpenChange: O,
103
+ registration: z,
104
+ setInputLabelling: V
105
+ };
106
+ }, [
107
+ p,
108
+ h,
109
+ D,
110
+ b,
111
+ j,
112
+ R,
113
+ P,
114
+ J,
115
+ B,
116
+ Y,
117
+ X,
118
+ Q,
119
+ $,
120
+ ie,
121
+ W,
122
+ G,
123
+ K,
124
+ q,
125
+ w,
126
+ O,
127
+ z
128
+ ]);
129
+ return /* @__PURE__ */ E(I.Provider, {
130
+ value: ae,
131
+ children: [f, l !== void 0 && /* @__PURE__ */ T("input", {
132
+ type: "hidden",
133
+ name: l,
134
+ value: b ?? "",
135
+ disabled: _
136
+ })]
137
+ });
138
+ }
139
+ var U = _(function({ inputValue: e, defaultInputValue: t, label: i, description: a, error: o, size: s, slotProps: c, className: l, id: u, onChange: d, onKeyDown: f, onBlur: p, disabled: m = !1, ...g }, _) {
140
+ let { listId: v, open: y, selectedValue: x, activeIndex: S, options: w, inputHandleRef: E, refs: D, getReferenceProps: O, onInputChange: te, findMatches: k, setQuery: A, setActiveIndex: M, selectIndex: N, clearValue: P, requestOpenChange: F, setInputLabelling: I, setInputDisabled: L } = R("Input"), z = j([D.setReference, _]), B = ee(), V = u ?? B, H = `${V}-label`, U = r(i), W = g["aria-labelledby"], G = g["aria-label"], [K, q] = C(t), [J, Y] = C(() => (e ?? t) !== void 0), X = x === null ? void 0 : w.get(x)?.label, Z = e ?? (J ? K ?? "" : X ?? K ?? ""), [, ne] = n(Z, void 0, te), re = (t) => {
141
+ ne(t), e === void 0 && q(t);
142
+ }, Q = e !== void 0 || J ? Z : "", $ = (e) => {
143
+ Y(!1), re(e);
144
+ };
145
+ b(() => {
146
+ A(Q);
147
+ }, [Q, A]), b(() => (L(m), () => L(!1)), [m, L]), b(() => (E.current = { commitLabel: $ }, () => {
148
+ E.current = null;
149
+ })), b(() => (I(W !== void 0 || !U ? {
150
+ labelledBy: W,
151
+ label: G
152
+ } : { labelledBy: H }), () => I(null)), [
153
+ W,
154
+ G,
155
+ U,
156
+ H,
157
+ I
158
+ ]);
159
+ let ie = (t) => {
160
+ d?.(t);
161
+ let n = t.currentTarget.value;
162
+ Y(!0), re(n), n === "" && P();
163
+ let r = e ?? n;
164
+ if (r === "") {
165
+ M(null), F(!1);
166
+ return;
167
+ }
168
+ let i = k(r);
169
+ M(i.first), i.count > 0 && F(!0);
170
+ }, ae = (e) => {
171
+ if (f?.(e), !e.defaultPrevented) {
172
+ if (e.key === "Escape") J && X !== void 0 && $(X);
173
+ else if (y) {
174
+ if (e.key === "Enter" && S !== null) e.preventDefault(), N(S);
175
+ else if (e.key === "Home" || e.key === "End") {
176
+ let t = k(Q), n = e.key === "Home" ? t.first : t.last;
177
+ if (n === null) return;
178
+ e.preventDefault(), M(n);
179
+ }
180
+ }
181
+ }
182
+ }, oe = (e) => {
183
+ p?.(e), y && F(!1);
184
+ };
185
+ return /* @__PURE__ */ T(h, {
186
+ ...O({
187
+ ...g,
188
+ onKeyDown: ae,
189
+ onBlur: oe
190
+ }),
191
+ ref: z,
192
+ id: V,
193
+ label: U ? /* @__PURE__ */ T("span", {
194
+ id: H,
195
+ children: i
196
+ }) : i,
197
+ description: a,
198
+ error: o,
199
+ size: s,
200
+ slotProps: c,
201
+ className: l,
202
+ value: Z,
203
+ disabled: m,
204
+ onChange: ie,
205
+ role: "combobox",
206
+ autoComplete: "off",
207
+ "aria-autocomplete": "list",
208
+ "aria-expanded": y,
209
+ "aria-controls": y ? v : void 0,
210
+ "data-state": y ? "open" : "closed",
211
+ "data-ui": "combobox-input"
212
+ });
213
+ }), W = _(function({ id: e, style: t, onMouseDown: n, children: r, ...i }, a) {
214
+ let { baseId: c, setListId: l, open: u, inputLabelling: d, refs: f, floatingStyles: p, elementsRef: m, getFloatingProps: h } = R("List"), g = e ?? `${c}-listbox`;
215
+ b(() => (l(g), () => l(`${c}-listbox`)), [
216
+ c,
217
+ g,
218
+ l
219
+ ]);
220
+ let _ = j([u ? f.setFloating : null, a]), v = i["aria-labelledby"] !== void 0 || i["aria-label"] !== void 0 ? {} : d?.labelledBy === void 0 ? { "aria-label": d?.label } : { "aria-labelledby": d.labelledBy }, y = (e) => {
221
+ n?.(e), e.preventDefault();
222
+ };
223
+ return /* @__PURE__ */ T(O, { children: /* @__PURE__ */ T("div", {
224
+ ...h({
225
+ id: g,
226
+ ...v,
227
+ ...i,
228
+ onMouseDown: y
229
+ }),
230
+ ref: _,
231
+ role: "listbox",
232
+ hidden: !u,
233
+ "data-state": u ? "open" : "closed",
234
+ "data-ui": "combobox-list",
235
+ style: {
236
+ ...t,
237
+ ...p
238
+ },
239
+ css: [s, o],
240
+ children: /* @__PURE__ */ T(D, {
241
+ elementsRef: m,
242
+ children: /* @__PURE__ */ T(L.Provider, {
243
+ value: !0,
244
+ children: r
245
+ })
246
+ })
247
+ }) });
248
+ }), G = _(function({ value: e, disabled: t = !1, onClick: n, children: r, ...i }, o) {
249
+ let { baseId: s, selectedValue: m, activeIndex: h, options: g, isVisible: _, getItemProps: v, selectValue: y, registration: ee } = z("Item"), b = S(null), { ref: x, index: C } = u(e, ee, b, (e, n) => ({
250
+ index: e,
251
+ label: n,
252
+ disabled: t
253
+ })), w = j([x, o]), D = g.get(e)?.label, O = D !== void 0 && !_(D), te = C !== -1 && h === C, k = m === e, A = (r) => {
254
+ n?.(r), !(t || r.defaultPrevented) && y(e);
255
+ };
256
+ return /* @__PURE__ */ E("div", {
257
+ ...v({
258
+ id: f(s, e),
259
+ ...i,
260
+ onClick: A
261
+ }),
262
+ ref: w,
263
+ role: "option",
264
+ hidden: O,
265
+ "aria-selected": k,
266
+ "aria-disabled": t || void 0,
267
+ "data-active": te || void 0,
268
+ "data-ui": "combobox-item",
269
+ css: [
270
+ d,
271
+ l,
272
+ c,
273
+ B
274
+ ],
275
+ children: [/* @__PURE__ */ T("span", {
276
+ ref: b,
277
+ css: p,
278
+ children: r
279
+ }), k && /* @__PURE__ */ T("span", {
280
+ "aria-hidden": "true",
281
+ css: a,
282
+ children: N
283
+ })]
284
+ });
285
+ }), K = _(function({ children: e, ...t }, n) {
286
+ let { matchCount: i } = z("Empty");
287
+ return i > 0 ? null : /* @__PURE__ */ T("div", {
288
+ ...t,
289
+ ref: n,
290
+ "data-ui": "combobox-empty",
291
+ css: V,
292
+ children: r(e) ? e : P
293
+ });
294
+ }), q = Object.assign(H, {
295
+ Input: U,
296
+ List: W,
297
+ Item: G,
298
+ Empty: K
299
+ });
300
+ //#endregion
301
+ export { q as t };
@@ -0,0 +1 @@
1
+ export { t as Combobox } from "./combobox-DQcXR94r.js";