@cfx-dev/ui-components 4.5.1 → 4.5.4

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 (52) hide show
  1. package/dist/assets/all_css.css +2 -0
  2. package/dist/assets/css/Input.css +1 -1
  3. package/dist/assets/css/Modal.css +1 -1
  4. package/dist/assets/css/StyledInput.css +1 -0
  5. package/dist/assets/css/StyledTextarea.css +1 -0
  6. package/dist/assets/css/Textarea.css +1 -1
  7. package/dist/assets/general/global.css +1 -1
  8. package/dist/components/Button/LinkButton.js +30 -24
  9. package/dist/components/Checkbox/Checkbox.d.ts +1 -0
  10. package/dist/components/Checkbox/Checkbox.js +139 -129
  11. package/dist/components/ClipboardButton/ClipboardButton.js +4 -4
  12. package/dist/components/DropdownSelect/DropdownSelect.d.ts +2 -1
  13. package/dist/components/DropdownSelect/DropdownSelect.js +53 -44
  14. package/dist/components/DropdownSelect/DropdownSelectShowcase.js +13 -12
  15. package/dist/components/Flyout/Flyout.js +4 -4
  16. package/dist/components/Input/Input.d.ts +3 -2
  17. package/dist/components/Input/Input.js +94 -89
  18. package/dist/components/Input/Input.types.d.ts +2 -0
  19. package/dist/components/Input/Input.types.js +1 -0
  20. package/dist/components/Input/RichInput.d.ts +1 -1
  21. package/dist/components/Input/index.d.ts +2 -1
  22. package/dist/components/InputDropzone/InputDropzone.d.ts +1 -0
  23. package/dist/components/InputDropzone/InputDropzone.js +135 -134
  24. package/dist/components/InputDropzone/InputDropzoneShowcase.js +6 -5
  25. package/dist/components/Modal/Modal.d.ts +36 -2
  26. package/dist/components/Modal/Modal.js +129 -63
  27. package/dist/components/Modal/ModalShowcase.js +24 -16
  28. package/dist/components/Radio/Radio.d.ts +1 -0
  29. package/dist/components/Radio/Radio.js +21 -19
  30. package/dist/components/StyledInput/StyledInput.d.ts +12 -0
  31. package/dist/components/StyledInput/StyledInput.js +46 -0
  32. package/dist/components/StyledInput/index.d.ts +2 -0
  33. package/dist/components/StyledInput/index.js +4 -0
  34. package/dist/components/StyledTextarea/StyledTextarea.d.ts +10 -0
  35. package/dist/components/StyledTextarea/StyledTextarea.js +32 -0
  36. package/dist/components/StyledTextarea/index.d.ts +2 -0
  37. package/dist/components/StyledTextarea/index.js +4 -0
  38. package/dist/components/Switch/Switch.js +61 -49
  39. package/dist/components/Tabular/Tabular.d.ts +12 -0
  40. package/dist/components/Tabular/Tabular.js +34 -33
  41. package/dist/components/Tabular/index.d.ts +1 -1
  42. package/dist/components/Textarea/Textarea.d.ts +7 -3
  43. package/dist/components/Textarea/Textarea.js +46 -43
  44. package/dist/components/ToggleGroup/ToggleGroup.d.ts +1 -0
  45. package/dist/components/ToggleGroup/ToggleGroup.js +57 -47
  46. package/dist/main.d.ts +5 -1
  47. package/dist/main.js +126 -122
  48. package/dist/rsc.d.ts +4 -0
  49. package/dist/rsc.js +12 -8
  50. package/dist/styles-scss/global.scss +1 -1
  51. package/dist/styles-scss/tokens.scss +19 -20
  52. package/package.json +1 -1
@@ -1,31 +1,37 @@
1
- import { jsx as r } from "react/jsx-runtime";
2
- import i from "react";
3
- import { noop as k } from "../../utils/functional.js";
4
- import { isExternalUrl as x } from "../../utils/links.js";
5
- import { getButtonClassName as d, ButtonContent as B } from "./Button.js";
6
- function M(t) {
1
+ import { jsx as s } from "react/jsx-runtime";
2
+ import o from "react";
3
+ import { isExternalUrl as b } from "../../utils/links.js";
4
+ import { getButtonClassName as h, ButtonContent as B } from "./Button.js";
5
+ function M(e) {
7
6
  const {
8
- to: e,
9
- title: m = "",
10
- tabIndex: a,
11
- target: s = "",
12
- onClick: l = k,
13
- isHrefProp: n = !1,
14
- Component: f,
15
- ref: c
16
- } = t, u = i.useMemo(() => d(t), [t]), o = x(e), C = o ? "a" : f || "a", p = i.useMemo(() => o || n ? { href: e } : { to: e }, [e, o, n]);
17
- return /* @__PURE__ */ r(
18
- C,
7
+ to: t,
8
+ title: f = "",
9
+ tabIndex: m,
10
+ target: u = "",
11
+ onClick: n,
12
+ isHrefProp: a = !1,
13
+ Component: c,
14
+ disabled: l = !1,
15
+ ref: C
16
+ } = e, d = o.useMemo(() => h(e), [e]), r = b(t), k = r ? "a" : c || "a", p = o.useMemo(() => r || a ? { href: t } : { to: t }, [t, r, a]), x = o.useCallback((i) => {
17
+ if (l) {
18
+ i.preventDefault();
19
+ return;
20
+ }
21
+ n && n(i);
22
+ }, [l, n]);
23
+ return /* @__PURE__ */ s(
24
+ k,
19
25
  {
20
- ref: c,
21
- className: u,
22
- tabIndex: a,
23
- title: m,
24
- target: s,
26
+ ref: C,
27
+ className: d,
28
+ tabIndex: m,
29
+ title: f,
30
+ target: u,
25
31
  rel: "noopener noreferrer",
26
- onClickCapture: l,
32
+ onClickCapture: x,
27
33
  ...p,
28
- children: /* @__PURE__ */ r(B, { ...t })
34
+ children: /* @__PURE__ */ s(B, { ...e })
29
35
  }
30
36
  );
31
37
  }
@@ -8,6 +8,7 @@ export interface CheckboxProps extends Omit<CheckboxUi.CheckboxProps, 'color'>,
8
8
  rootClassName?: string;
9
9
  indicatorClassName?: string;
10
10
  iconIndicator?: React.ComponentType;
11
+ name?: string;
11
12
  }
12
13
  declare function Checkbox(props: CheckboxProps): import("react/jsx-runtime").JSX.Element;
13
14
  declare const _default: React.MemoExoticComponent<typeof Checkbox>;
@@ -1,5 +1,5 @@
1
- import { jsx as u, jsxs as w, Fragment as $ } from "react/jsx-runtime";
2
- import * as l from "react";
1
+ import { jsx as a, jsxs as w, Fragment as $ } from "react/jsx-runtime";
2
+ import * as u from "react";
3
3
  import G from "react";
4
4
  import { c as K, P as E, d as X, u as B, e as q, f as J } from "../../index-DCuJlMqr.js";
5
5
  import { u as Q } from "../../index-BZPx6jYI.js";
@@ -57,137 +57,137 @@ import "../Icons/cfx-icons-big/Warning.js";
57
57
  import "../Icons/cfx-icons-big/Confirm.js";
58
58
  import { clsx as g } from "../../utils/clsx.js";
59
59
  import { getColor as Z } from "../../utils/color.js";
60
- var R = "Checkbox", [ee, bo] = K(R), [oe, N] = ee(R);
60
+ var y = "Checkbox", [ee, ko] = K(y), [oe, N] = ee(y);
61
61
  function te(o) {
62
62
  const {
63
- __scopeCheckbox: n,
64
- checked: r,
65
- children: a,
63
+ __scopeCheckbox: i,
64
+ checked: c,
65
+ children: d,
66
66
  defaultChecked: t,
67
67
  disabled: e,
68
68
  form: f,
69
69
  name: _,
70
- onCheckedChange: d,
71
- required: m,
72
- value: h = "on",
70
+ onCheckedChange: m,
71
+ required: h,
72
+ value: l = "on",
73
73
  // @ts-expect-error
74
- internal_do_not_use_render: i
75
- } = o, [p, C] = X({
76
- prop: r,
74
+ internal_do_not_use_render: r
75
+ } = o, [p, v] = X({
76
+ prop: c,
77
77
  defaultProp: t ?? !1,
78
- onChange: d,
79
- caller: R
80
- }), [x, v] = l.useState(null), [I, c] = l.useState(null), s = l.useRef(!1), y = x ? !!f || !!x.closest("form") : (
78
+ onChange: m,
79
+ caller: y
80
+ }), [k, b] = u.useState(null), [I, n] = u.useState(null), s = u.useRef(!1), R = k ? !!f || !!k.closest("form") : (
81
81
  // We set this to true by default so that events bubble to forms without JS (SSR)
82
82
  !0
83
83
  ), P = {
84
84
  checked: p,
85
85
  disabled: e,
86
- setChecked: C,
87
- control: x,
88
- setControl: v,
86
+ setChecked: v,
87
+ control: k,
88
+ setControl: b,
89
89
  name: _,
90
90
  form: f,
91
- value: h,
91
+ value: l,
92
92
  hasConsumerStoppedPropagationRef: s,
93
- required: m,
94
- defaultChecked: k(t) ? !1 : t,
95
- isFormControl: y,
93
+ required: h,
94
+ defaultChecked: x(t) ? !1 : t,
95
+ isFormControl: R,
96
96
  bubbleInput: I,
97
- setBubbleInput: c
97
+ setBubbleInput: n
98
98
  };
99
- return /* @__PURE__ */ u(
99
+ return /* @__PURE__ */ a(
100
100
  oe,
101
101
  {
102
- scope: n,
102
+ scope: i,
103
103
  ...P,
104
- children: re(i) ? i(P) : a
104
+ children: re(r) ? r(P) : d
105
105
  }
106
106
  );
107
107
  }
108
- var T = "CheckboxTrigger", M = l.forwardRef(
109
- ({ __scopeCheckbox: o, onKeyDown: n, onClick: r, ...a }, t) => {
108
+ var T = "CheckboxTrigger", M = u.forwardRef(
109
+ ({ __scopeCheckbox: o, onKeyDown: i, onClick: c, ...d }, t) => {
110
110
  const {
111
111
  control: e,
112
112
  value: f,
113
113
  disabled: _,
114
- checked: d,
115
- required: m,
116
- setControl: h,
117
- setChecked: i,
114
+ checked: m,
115
+ required: h,
116
+ setControl: l,
117
+ setChecked: r,
118
118
  hasConsumerStoppedPropagationRef: p,
119
- isFormControl: C,
120
- bubbleInput: x
121
- } = N(T, o), v = B(t, h), I = l.useRef(d);
122
- return l.useEffect(() => {
123
- const c = e == null ? void 0 : e.form;
124
- if (c) {
125
- const s = () => i(I.current);
126
- return c.addEventListener("reset", s), () => c.removeEventListener("reset", s);
119
+ isFormControl: v,
120
+ bubbleInput: k
121
+ } = N(T, o), b = B(t, l), I = u.useRef(m);
122
+ return u.useEffect(() => {
123
+ const n = e == null ? void 0 : e.form;
124
+ if (n) {
125
+ const s = () => r(I.current);
126
+ return n.addEventListener("reset", s), () => n.removeEventListener("reset", s);
127
127
  }
128
- }, [e, i]), /* @__PURE__ */ u(
128
+ }, [e, r]), /* @__PURE__ */ a(
129
129
  E.button,
130
130
  {
131
131
  type: "button",
132
132
  role: "checkbox",
133
- "aria-checked": k(d) ? "mixed" : d,
134
- "aria-required": m,
135
- "data-state": O(d),
133
+ "aria-checked": x(m) ? "mixed" : m,
134
+ "aria-required": h,
135
+ "data-state": O(m),
136
136
  "data-disabled": _ ? "" : void 0,
137
137
  disabled: _,
138
138
  value: f,
139
- ...a,
140
- ref: v,
141
- onKeyDown: q(n, (c) => {
142
- c.key === "Enter" && c.preventDefault();
139
+ ...d,
140
+ ref: b,
141
+ onKeyDown: q(i, (n) => {
142
+ n.key === "Enter" && n.preventDefault();
143
143
  }),
144
- onClick: q(r, (c) => {
145
- i((s) => k(s) ? !0 : !s), x && C && (p.current = c.isPropagationStopped(), p.current || c.stopPropagation());
144
+ onClick: q(c, (n) => {
145
+ r((s) => x(s) ? !0 : !s), k && v && (p.current = n.isPropagationStopped(), p.current || n.stopPropagation());
146
146
  })
147
147
  }
148
148
  );
149
149
  }
150
150
  );
151
151
  M.displayName = T;
152
- var U = l.forwardRef(
153
- (o, n) => {
152
+ var U = u.forwardRef(
153
+ (o, i) => {
154
154
  const {
155
- __scopeCheckbox: r,
156
- name: a,
155
+ __scopeCheckbox: c,
156
+ name: d,
157
157
  checked: t,
158
158
  defaultChecked: e,
159
159
  required: f,
160
160
  disabled: _,
161
- value: d,
162
- onCheckedChange: m,
163
- form: h,
164
- ...i
161
+ value: m,
162
+ onCheckedChange: h,
163
+ form: l,
164
+ ...r
165
165
  } = o;
166
- return /* @__PURE__ */ u(
166
+ return /* @__PURE__ */ a(
167
167
  te,
168
168
  {
169
- __scopeCheckbox: r,
169
+ __scopeCheckbox: c,
170
170
  checked: t,
171
171
  defaultChecked: e,
172
172
  disabled: _,
173
173
  required: f,
174
- onCheckedChange: m,
175
- name: a,
176
- form: h,
177
- value: d,
174
+ onCheckedChange: h,
175
+ name: d,
176
+ form: l,
177
+ value: m,
178
178
  internal_do_not_use_render: ({ isFormControl: p }) => /* @__PURE__ */ w($, { children: [
179
- /* @__PURE__ */ u(
179
+ /* @__PURE__ */ a(
180
180
  M,
181
181
  {
182
- ...i,
183
- ref: n,
184
- __scopeCheckbox: r
182
+ ...r,
183
+ ref: i,
184
+ __scopeCheckbox: c
185
185
  }
186
186
  ),
187
- p && /* @__PURE__ */ u(
187
+ p && /* @__PURE__ */ a(
188
188
  L,
189
189
  {
190
- __scopeCheckbox: r
190
+ __scopeCheckbox: c
191
191
  }
192
192
  )
193
193
  ] })
@@ -195,21 +195,21 @@ var U = l.forwardRef(
195
195
  );
196
196
  }
197
197
  );
198
- U.displayName = R;
199
- var A = "CheckboxIndicator", D = l.forwardRef(
200
- (o, n) => {
201
- const { __scopeCheckbox: r, forceMount: a, ...t } = o, e = N(A, r);
202
- return /* @__PURE__ */ u(
198
+ U.displayName = y;
199
+ var A = "CheckboxIndicator", D = u.forwardRef(
200
+ (o, i) => {
201
+ const { __scopeCheckbox: c, forceMount: d, ...t } = o, e = N(A, c);
202
+ return /* @__PURE__ */ a(
203
203
  V,
204
204
  {
205
- present: a || k(e.checked) || e.checked === !0,
206
- children: /* @__PURE__ */ u(
205
+ present: d || x(e.checked) || e.checked === !0,
206
+ children: /* @__PURE__ */ a(
207
207
  E.span,
208
208
  {
209
209
  "data-state": O(e.checked),
210
210
  "data-disabled": e.disabled ? "" : void 0,
211
211
  ...t,
212
- ref: n,
212
+ ref: i,
213
213
  style: { pointerEvents: "none", ...o.style }
214
214
  }
215
215
  )
@@ -218,50 +218,50 @@ var A = "CheckboxIndicator", D = l.forwardRef(
218
218
  }
219
219
  );
220
220
  D.displayName = A;
221
- var F = "CheckboxBubbleInput", L = l.forwardRef(
222
- ({ __scopeCheckbox: o, ...n }, r) => {
221
+ var F = "CheckboxBubbleInput", L = u.forwardRef(
222
+ ({ __scopeCheckbox: o, ...i }, c) => {
223
223
  const {
224
- control: a,
224
+ control: d,
225
225
  hasConsumerStoppedPropagationRef: t,
226
226
  checked: e,
227
227
  defaultChecked: f,
228
228
  required: _,
229
- disabled: d,
230
- name: m,
231
- value: h,
232
- form: i,
229
+ disabled: m,
230
+ name: h,
231
+ value: l,
232
+ form: r,
233
233
  bubbleInput: p,
234
- setBubbleInput: C
235
- } = N(F, o), x = B(r, C), v = Q(e), I = J(a);
236
- l.useEffect(() => {
234
+ setBubbleInput: v
235
+ } = N(F, o), k = B(c, v), b = Q(e), I = J(d);
236
+ u.useEffect(() => {
237
237
  const s = p;
238
238
  if (!s) return;
239
- const y = window.HTMLInputElement.prototype, S = Object.getOwnPropertyDescriptor(
240
- y,
239
+ const R = window.HTMLInputElement.prototype, S = Object.getOwnPropertyDescriptor(
240
+ R,
241
241
  "checked"
242
242
  ).set, j = !t.current;
243
- if (v !== e && S) {
243
+ if (b !== e && S) {
244
244
  const H = new Event("click", { bubbles: j });
245
- s.indeterminate = k(e), S.call(s, k(e) ? !1 : e), s.dispatchEvent(H);
245
+ s.indeterminate = x(e), S.call(s, x(e) ? !1 : e), s.dispatchEvent(H);
246
246
  }
247
- }, [p, v, e, t]);
248
- const c = l.useRef(k(e) ? !1 : e);
249
- return /* @__PURE__ */ u(
247
+ }, [p, b, e, t]);
248
+ const n = u.useRef(x(e) ? !1 : e);
249
+ return /* @__PURE__ */ a(
250
250
  E.input,
251
251
  {
252
252
  type: "checkbox",
253
253
  "aria-hidden": !0,
254
- defaultChecked: f ?? c.current,
254
+ defaultChecked: f ?? n.current,
255
255
  required: _,
256
- disabled: d,
257
- name: m,
258
- value: h,
259
- form: i,
260
- ...n,
256
+ disabled: m,
257
+ name: h,
258
+ value: l,
259
+ form: r,
260
+ ...i,
261
261
  tabIndex: -1,
262
- ref: x,
262
+ ref: k,
263
263
  style: {
264
- ...n.style,
264
+ ...i.style,
265
265
  ...I,
266
266
  position: "absolute",
267
267
  pointerEvents: "none",
@@ -280,13 +280,13 @@ L.displayName = F;
280
280
  function re(o) {
281
281
  return typeof o == "function";
282
282
  }
283
- function k(o) {
283
+ function x(o) {
284
284
  return o === "indeterminate";
285
285
  }
286
286
  function O(o) {
287
- return k(o) ? "indeterminate" : o ? "checked" : "unchecked";
287
+ return x(o) ? "indeterminate" : o ? "checked" : "unchecked";
288
288
  }
289
- const ce = "cfxui__Checkbox__rootUnset__cbb57", ne = "cfxui__Checkbox__root__865aa", ie = "cfxui__Checkbox__square__029aa", se = "cfxui__Checkbox__indicator__2afc0", ae = "cfxui__Checkbox__checked__b4081", de = "cfxui__Checkbox__radioIcon__719e7", me = "cfxui__Checkbox__tickIcon__a7f19", b = {
289
+ const ce = "cfxui__Checkbox__rootUnset__cbb57", ne = "cfxui__Checkbox__root__865aa", ie = "cfxui__Checkbox__square__029aa", se = "cfxui__Checkbox__indicator__2afc0", ae = "cfxui__Checkbox__checked__b4081", de = "cfxui__Checkbox__radioIcon__719e7", me = "cfxui__Checkbox__tickIcon__a7f19", C = {
290
290
  rootUnset: ce,
291
291
  root: ne,
292
292
  square: ie,
@@ -300,41 +300,51 @@ const ce = "cfxui__Checkbox__rootUnset__cbb57", ne = "cfxui__Checkbox__root__865
300
300
  };
301
301
  function pe(o) {
302
302
  const {
303
- id: n,
304
- size: r = "normal",
305
- rootClassName: a,
303
+ id: i,
304
+ size: c = "normal",
305
+ rootClassName: d,
306
306
  indicatorClassName: t,
307
307
  colorToken: e,
308
308
  color: f,
309
309
  opacity: _,
310
- luminance: d,
311
- iconIndicator: m = z,
312
- ...h
313
- } = o, i = g(
314
- b.root,
315
- b.rootUnset,
316
- b[`size-${r}`],
317
- a
318
- ), p = Z(o), C = g(
319
- b.checked,
320
- m === Y && b.tickIcon,
321
- m === z && b.radioIcon
310
+ luminance: m,
311
+ checked: h,
312
+ name: l,
313
+ iconIndicator: r = z,
314
+ ...p
315
+ } = o, v = g(
316
+ C.root,
317
+ C.rootUnset,
318
+ C[`size-${c}`],
319
+ d
320
+ ), k = Z(o), b = g(
321
+ C.checked,
322
+ r === Y && C.tickIcon,
323
+ r === z && C.radioIcon
322
324
  );
323
325
  return /* @__PURE__ */ w(
324
326
  U,
325
327
  {
326
- ...h,
327
- id: n,
328
- style: { color: p },
329
- className: i,
328
+ ...p,
329
+ id: i,
330
+ checked: h,
331
+ style: { color: k },
332
+ className: v,
330
333
  children: [
331
- /* @__PURE__ */ u(W, { className: b.square }),
332
- /* @__PURE__ */ u(D, { className: g(b.indicator, t), children: /* @__PURE__ */ u(m, { className: C }) })
334
+ l && /* @__PURE__ */ a(
335
+ "input",
336
+ {
337
+ type: "hidden",
338
+ name: l
339
+ }
340
+ ),
341
+ /* @__PURE__ */ a(W, { className: C.square }),
342
+ /* @__PURE__ */ a(D, { className: g(C.indicator, t), children: /* @__PURE__ */ a(r, { className: b }) })
333
343
  ]
334
344
  }
335
345
  );
336
346
  }
337
- const ko = G.memo(pe);
347
+ const bo = G.memo(pe);
338
348
  export {
339
- ko as default
349
+ bo as default
340
350
  };
@@ -2,9 +2,9 @@ import { jsx as r } from "react/jsx-runtime";
2
2
  import c from "react";
3
3
  import C from "../Button/Button.js";
4
4
  import { clsx as _ } from "../../utils/clsx.js";
5
- import { noop as f } from "../../utils/functional.js";
6
5
  import "../../utils/links.js";
7
- import { Title as u } from "../Title/Title.js";
6
+ import { Title as f } from "../Title/Title.js";
7
+ import { noop as u } from "../../utils/functional.js";
8
8
  import "../../utils/hooks/useGlobalKeyboardEvent.js";
9
9
  import "../../utils/hooks/useKeyboardClose.js";
10
10
  import "../../index-Cl_RnsqN.js";
@@ -19,7 +19,7 @@ function h(o) {
19
19
  copiedTitle: T,
20
20
  textToCopy: j,
21
21
  fixedOn: n,
22
- onClick: t = f,
22
+ onClick: t = u,
23
23
  ...p
24
24
  } = o, {
25
25
  copied: l,
@@ -29,7 +29,7 @@ function h(o) {
29
29
  t(s), i();
30
30
  }, [i, t]), a = _(e.root, { [e.copied]: l });
31
31
  return /* @__PURE__ */ r(
32
- u,
32
+ f,
33
33
  {
34
34
  title: m,
35
35
  fixedOn: n,
@@ -12,9 +12,10 @@ export interface DropdownSelectProps<T = string> {
12
12
  placeholder?: React.ReactNode;
13
13
  size?: ResponsiveValueType<InputSize>;
14
14
  disabled?: boolean;
15
+ ref?: React.Ref<HTMLButtonElement>;
15
16
  fullWidth?: boolean;
16
17
  onlight?: boolean;
17
- ref?: React.Ref<HTMLButtonElement>;
18
+ name?: string;
18
19
  }
19
20
  export declare function DropdownSelect(props: DropdownSelectProps): import("react/jsx-runtime").JSX.Element;
20
21
  export default DropdownSelect;
@@ -1,75 +1,84 @@
1
- import { jsxs as d, jsx as s } from "react/jsx-runtime";
2
- import { g as D, R as W, T as N, D as R } from "../../DropdownContent-BertjH0y.js";
3
- import f, { useRef as v, useState as b, useEffect as z } from "react";
4
- import I from "../Flex/Flex.js";
5
- import { clsx as T } from "../../utils/clsx.js";
6
- import { Icon as j } from "../Icon/Icon.js";
1
+ import { jsxs as f, jsx as l } from "react/jsx-runtime";
2
+ import { g as W, R as N, T as R, D as v } from "../../DropdownContent-BertjH0y.js";
3
+ import _, { useRef as b, useState as z, useEffect as I } from "react";
4
+ import T from "../Flex/Flex.js";
5
+ import { clsx as j } from "../../utils/clsx.js";
6
+ import { Icon as y } from "../Icon/Icon.js";
7
7
  import { mergeRefs as E } from "../../utils/mergeRefs.js";
8
- const M = "cfxui__DropdownSelect__icon__d05b8", O = "cfxui__DropdownSelect__trigger__c03df", k = "cfxui__DropdownSelect__onlight__f0191", y = "cfxui__DropdownSelect__fullWidth__dce56", A = "cfxui__DropdownSelect__placeholder__e0d89", e = {
8
+ const M = "cfxui__DropdownSelect__icon__d05b8", O = "cfxui__DropdownSelect__trigger__c03df", k = "cfxui__DropdownSelect__onlight__f0191", A = "cfxui__DropdownSelect__fullWidth__dce56", B = "cfxui__DropdownSelect__placeholder__e0d89", e = {
9
9
  icon: M,
10
10
  trigger: O,
11
11
  onlight: k,
12
- fullWidth: y,
13
- placeholder: A
14
- }, J = {
12
+ fullWidth: A,
13
+ placeholder: B
14
+ }, K = {
15
15
  small: "xxsmall",
16
16
  normal: "xsmall",
17
17
  large: "normal"
18
18
  };
19
- function K(_) {
19
+ function L(g) {
20
20
  const {
21
- options: t,
22
- value: l,
21
+ options: r,
22
+ value: t,
23
23
  onChange: c,
24
24
  size: i = "normal",
25
25
  fullWidth: o = !1,
26
- onlight: g = !1,
27
- disabled: m,
26
+ onlight: m = !1,
27
+ disabled: p,
28
28
  placeholder: u = "Select...",
29
- ref: p
30
- } = _, r = v(null), [h, x] = b(void 0), S = D(i, "trigger"), w = T(
31
- S,
29
+ ref: h,
30
+ name: a
31
+ } = g, n = b(null), [x, S] = z(void 0), w = W(i, "trigger"), C = j(
32
+ w,
32
33
  e.trigger,
33
34
  {
34
- [e.placeholder]: !l,
35
+ [e.placeholder]: !t,
35
36
  [e.fullWidth]: o,
36
- [e.onlight]: g
37
+ [e.onlight]: m
37
38
  }
38
- ), C = f.useCallback((n) => {
39
- c(n);
40
- }, [c]), a = f.useMemo(
41
- () => t.find((n) => n.value === l),
42
- [t, l]
39
+ ), D = _.useCallback((s) => {
40
+ c(s);
41
+ }, [c]), d = _.useMemo(
42
+ () => r.find((s) => s.value === t),
43
+ [r, t]
43
44
  );
44
- return z(() => {
45
- o && r.current && x(r.current.offsetWidth);
46
- }, [o]), /* @__PURE__ */ d(W, { children: [
47
- /* @__PURE__ */ s(
48
- N,
45
+ return I(() => {
46
+ o && n.current && S(n.current.offsetWidth);
47
+ }, [o]), /* @__PURE__ */ f(N, { children: [
48
+ a && /* @__PURE__ */ l(
49
+ "input",
49
50
  {
50
- ref: E(p, r),
51
- className: w,
52
- disabled: m,
53
- children: /* @__PURE__ */ d(I, { gap: "small", centered: !0, spaceBetween: !0, children: [
54
- a !== void 0 ? a.label : u,
55
- /* @__PURE__ */ s(j, { className: e.icon, name: "DownChevron" })
56
- ] })
51
+ type: "hidden",
52
+ name: a,
53
+ value: t
57
54
  }
58
55
  ),
59
- /* @__PURE__ */ s(
56
+ /* @__PURE__ */ l(
60
57
  R,
61
58
  {
62
- triggerWidth: h,
63
- options: t,
59
+ ref: E(h, n),
60
+ className: C,
61
+ disabled: p,
62
+ children: /* @__PURE__ */ f(T, { gap: "small", centered: !0, spaceBetween: !0, children: [
63
+ d !== void 0 ? d.label : u,
64
+ /* @__PURE__ */ l(y, { className: e.icon, name: "DownChevron" })
65
+ ] })
66
+ }
67
+ ),
68
+ /* @__PURE__ */ l(
69
+ v,
70
+ {
71
+ triggerWidth: x,
72
+ options: r,
64
73
  size: i,
65
74
  fullWidth: o,
66
- onSelect: C
75
+ onSelect: D
67
76
  }
68
77
  )
69
78
  ] });
70
79
  }
71
80
  export {
72
- K as DropdownSelect,
73
- J as ICON_SIZE_MAP,
74
- K as default
81
+ L as DropdownSelect,
82
+ K as ICON_SIZE_MAP,
83
+ L as default
75
84
  };