@cfx-dev/ui-components 3.0.4 → 4.0.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 (38) hide show
  1. package/dist/Select-Ds-fm4CN.js +3245 -0
  2. package/dist/assets/all_css.css +2 -0
  3. package/dist/assets/css/DropdownSelect.css +1 -0
  4. package/dist/assets/css/Input.css +1 -1
  5. package/dist/assets/css/Modal.css +1 -1
  6. package/dist/assets/css/Slider.css +1 -0
  7. package/dist/assets/general/global.css +1 -1
  8. package/dist/components/Checkbox/Checkbox.js +190 -118
  9. package/dist/components/DropdownSelect/DropdownSelect.d.ts +16 -0
  10. package/dist/components/DropdownSelect/DropdownSelect.js +2393 -0
  11. package/dist/components/DropdownSelect/DropdownSelectShowcase.d.ts +5 -0
  12. package/dist/components/DropdownSelect/DropdownSelectShowcase.js +52 -0
  13. package/dist/components/DropdownSelect/index.d.ts +1 -0
  14. package/dist/components/DropdownSelect/index.js +4 -0
  15. package/dist/components/Input/Input.js +4 -4
  16. package/dist/components/Select/Select.d.ts +2 -0
  17. package/dist/components/Select/Select.js +7 -3092
  18. package/dist/components/Select/SelectShowcase.js +1 -1
  19. package/dist/components/Select/index.d.ts +1 -1
  20. package/dist/components/Select/index.js +3 -2
  21. package/dist/components/Slider/Slider.d.ts +11 -0
  22. package/dist/components/Slider/Slider.js +606 -0
  23. package/dist/components/Slider/SliderShowcase.d.ts +5 -0
  24. package/dist/components/Slider/SliderShowcase.js +63 -0
  25. package/dist/components/Slider/index.d.ts +1 -0
  26. package/dist/components/Slider/index.js +4 -0
  27. package/dist/components/Switch/Switch.js +131 -68
  28. package/dist/components/ui.d.ts +2 -2
  29. package/dist/components/ui.js +13 -13
  30. package/dist/index-BCnz73Lm.js +72 -0
  31. package/dist/index-BW3WdIgK.js +14 -0
  32. package/dist/index-BlbvKsmN.js +82 -0
  33. package/dist/index-CjTSD6zB.js +161 -0
  34. package/dist/main.d.ts +3 -1
  35. package/dist/main.js +69 -65
  36. package/dist/styles-scss/_ui.scss +5 -5
  37. package/package.json +3 -1
  38. package/dist/index-CjWRnNpt.js +0 -210
@@ -1,8 +1,9 @@
1
- import { jsxs as z, jsx as l } from "react/jsx-runtime";
1
+ import { jsx as _, jsxs as D } from "react/jsx-runtime";
2
2
  import * as c from "react";
3
- import L from "react";
4
- import { u as S, f as y, c as j, a as W, P as O, b as A, d as B, e as H } from "../../index-CjWRnNpt.js";
5
- import { r as K } from "../../index-2hJuj4UN.js";
3
+ import $ from "react";
4
+ import { c as y, u as z, a as L, b as j } from "../../index-BCnz73Lm.js";
5
+ import { r as B } from "../../index-2hJuj4UN.js";
6
+ import { P as E } from "../../index-BlbvKsmN.js";
6
7
  import "../Icons/cfx-icons/Close.js";
7
8
  import "../Icons/cfx-icons/Controller.js";
8
9
  import "../Icons/cfx-icons/Copy.js";
@@ -32,7 +33,7 @@ import "../Icons/cfx-icons/Sort.js";
32
33
  import "../Icons/cfx-icons/Square.js";
33
34
  import "../Icons/cfx-icons/SquareCheck.js";
34
35
  import "../Icons/cfx-icons/Stop.js";
35
- import $ from "../Icons/cfx-icons/Tick.js";
36
+ import W from "../Icons/cfx-icons/Tick.js";
36
37
  import "../Icons/cfx-icons/Transfer.js";
37
38
  import "../Icons/cfx-icons/Trash.js";
38
39
  import "../Icons/cfx-icons/Undo.js";
@@ -53,18 +54,89 @@ import "../Icons/cfx-icons-big/Subscriptions.js";
53
54
  import "../Icons/cfx-icons-big/Upload.js";
54
55
  import "../Icons/cfx-icons-big/Warning.js";
55
56
  import "../Icons/cfx-icons-big/Confirm.js";
56
- import { clsx as R } from "../../utils/clsx.js";
57
- import { getColor as q } from "../../utils/color.js";
58
- function X(e, t) {
57
+ import { clsx as g } from "../../utils/clsx.js";
58
+ import { getColor as K } from "../../utils/color.js";
59
+ function q(e, t) {
60
+ typeof e == "function" ? e(t) : e != null && (e.current = t);
61
+ }
62
+ function X(...e) {
63
+ return (t) => e.forEach((o) => q(o, t));
64
+ }
65
+ function F(...e) {
66
+ return c.useCallback(X(...e), e);
67
+ }
68
+ function G(e, t = []) {
69
+ let o = [];
70
+ function n(u, p) {
71
+ const m = c.createContext(p), s = o.length;
72
+ o = [...o, p];
73
+ function i(a) {
74
+ const { scope: f, children: h, ...C } = a, N = (f == null ? void 0 : f[e][s]) || m, x = c.useMemo(() => C, Object.values(C));
75
+ return /* @__PURE__ */ _(N.Provider, { value: x, children: h });
76
+ }
77
+ function d(a, f) {
78
+ const h = (f == null ? void 0 : f[e][s]) || m, C = c.useContext(h);
79
+ if (C) return C;
80
+ if (p !== void 0) return p;
81
+ throw new Error(`\`${a}\` must be used within \`${u}\``);
82
+ }
83
+ return i.displayName = u + "Provider", [i, d];
84
+ }
85
+ const r = () => {
86
+ const u = o.map((p) => c.createContext(p));
87
+ return function(m) {
88
+ const s = (m == null ? void 0 : m[e]) || u;
89
+ return c.useMemo(
90
+ () => ({ [`__scope${e}`]: { ...m, [e]: s } }),
91
+ [m, s]
92
+ );
93
+ };
94
+ };
95
+ return r.scopeName = e, [n, J(r, ...t)];
96
+ }
97
+ function J(...e) {
98
+ const t = e[0];
99
+ if (e.length === 1) return t;
100
+ const o = () => {
101
+ const n = e.map((r) => ({
102
+ useScope: r(),
103
+ scopeName: r.scopeName
104
+ }));
105
+ return function(u) {
106
+ const p = n.reduce((m, { useScope: s, scopeName: i }) => {
107
+ const a = s(u)[`__scope${i}`];
108
+ return { ...m, ...a };
109
+ }, {});
110
+ return c.useMemo(() => ({ [`__scope${t.scopeName}`]: p }), [p]);
111
+ };
112
+ };
113
+ return o.scopeName = t.scopeName, o;
114
+ }
115
+ function A(e, t, { checkForDefaultPrevented: o = !0 } = {}) {
116
+ return function(r) {
117
+ if (e == null || e(r), o === !1 || !r.defaultPrevented)
118
+ return t == null ? void 0 : t(r);
119
+ };
120
+ }
121
+ function Q(e, t) {
122
+ typeof e == "function" ? e(t) : e != null && (e.current = t);
123
+ }
124
+ function V(...e) {
125
+ return (t) => e.forEach((o) => Q(o, t));
126
+ }
127
+ function Y(...e) {
128
+ return c.useCallback(V(...e), e);
129
+ }
130
+ function Z(e, t) {
59
131
  return c.useReducer((o, n) => t[o][n] ?? o, e);
60
132
  }
61
- var I = (e) => {
62
- const { present: t, children: o } = e, n = F(t), s = typeof o == "function" ? o({ present: n.isPresent }) : c.Children.only(o), a = S(n.ref, G(s));
63
- return typeof o == "function" || n.isPresent ? c.cloneElement(s, { ref: a }) : null;
133
+ var O = (e) => {
134
+ const { present: t, children: o } = e, n = H(t), r = typeof o == "function" ? o({ present: n.isPresent }) : c.Children.only(o), u = Y(n.ref, ee(r));
135
+ return typeof o == "function" || n.isPresent ? c.cloneElement(r, { ref: u }) : null;
64
136
  };
65
- I.displayName = "Presence";
66
- function F(e) {
67
- const [t, o] = c.useState(), n = c.useRef({}), s = c.useRef(e), a = c.useRef("none"), f = e ? "mounted" : "unmounted", [u, m] = X(f, {
137
+ O.displayName = "Presence";
138
+ function H(e) {
139
+ const [t, o] = c.useState(), n = c.useRef({}), r = c.useRef(e), u = c.useRef("none"), p = e ? "mounted" : "unmounted", [m, s] = Z(p, {
68
140
  mounted: {
69
141
  UNMOUNT: "unmounted",
70
142
  ANIMATION_OUT: "unmountSuspended"
@@ -78,140 +150,140 @@ function F(e) {
78
150
  }
79
151
  });
80
152
  return c.useEffect(() => {
81
- const r = x(n.current);
82
- a.current = u === "mounted" ? r : "none";
83
- }, [u]), y(() => {
84
- const r = n.current, d = s.current;
153
+ const i = v(n.current);
154
+ u.current = m === "mounted" ? i : "none";
155
+ }, [m]), y(() => {
156
+ const i = n.current, d = r.current;
85
157
  if (d !== e) {
86
- const C = a.current, _ = x(r);
87
- e ? m("MOUNT") : _ === "none" || (r == null ? void 0 : r.display) === "none" ? m("UNMOUNT") : m(d && C !== _ ? "ANIMATION_OUT" : "UNMOUNT"), s.current = e;
158
+ const f = u.current, h = v(i);
159
+ e ? s("MOUNT") : h === "none" || (i == null ? void 0 : i.display) === "none" ? s("UNMOUNT") : s(d && f !== h ? "ANIMATION_OUT" : "UNMOUNT"), r.current = e;
88
160
  }
89
- }, [e, m]), y(() => {
161
+ }, [e, s]), y(() => {
90
162
  if (t) {
91
- const r = (i) => {
92
- const _ = x(n.current).includes(i.animationName);
93
- i.target === t && _ && K.flushSync(() => m("ANIMATION_END"));
94
- }, d = (i) => {
95
- i.target === t && (a.current = x(n.current));
163
+ const i = (a) => {
164
+ const h = v(n.current).includes(a.animationName);
165
+ a.target === t && h && B.flushSync(() => s("ANIMATION_END"));
166
+ }, d = (a) => {
167
+ a.target === t && (u.current = v(n.current));
96
168
  };
97
- return t.addEventListener("animationstart", d), t.addEventListener("animationcancel", r), t.addEventListener("animationend", r), () => {
98
- t.removeEventListener("animationstart", d), t.removeEventListener("animationcancel", r), t.removeEventListener("animationend", r);
169
+ return t.addEventListener("animationstart", d), t.addEventListener("animationcancel", i), t.addEventListener("animationend", i), () => {
170
+ t.removeEventListener("animationstart", d), t.removeEventListener("animationcancel", i), t.removeEventListener("animationend", i);
99
171
  };
100
172
  } else
101
- m("ANIMATION_END");
102
- }, [t, m]), {
103
- isPresent: ["mounted", "unmountSuspended"].includes(u),
104
- ref: c.useCallback((r) => {
105
- r && (n.current = getComputedStyle(r)), o(r);
173
+ s("ANIMATION_END");
174
+ }, [t, s]), {
175
+ isPresent: ["mounted", "unmountSuspended"].includes(m),
176
+ ref: c.useCallback((i) => {
177
+ i && (n.current = getComputedStyle(i)), o(i);
106
178
  }, [])
107
179
  };
108
180
  }
109
- function x(e) {
181
+ function v(e) {
110
182
  return (e == null ? void 0 : e.animationName) || "none";
111
183
  }
112
- function G(e) {
113
- var n, s;
184
+ function ee(e) {
185
+ var n, r;
114
186
  let t = (n = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : n.get, o = t && "isReactWarning" in t && t.isReactWarning;
115
- return o ? e.ref : (t = (s = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : s.get, o = t && "isReactWarning" in t && t.isReactWarning, o ? e.props.ref : e.props.ref || e.ref);
187
+ return o ? e.ref : (t = (r = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : r.get, o = t && "isReactWarning" in t && t.isReactWarning, o ? e.props.ref : e.props.ref || e.ref);
116
188
  }
117
- var E = "Checkbox", [J, ct] = j(E), [Q, V] = J(E), M = c.forwardRef(
189
+ var S = "Checkbox", [te, lt] = G(S), [oe, ne] = te(S), M = c.forwardRef(
118
190
  (e, t) => {
119
191
  const {
120
192
  __scopeCheckbox: o,
121
193
  name: n,
122
- checked: s,
123
- defaultChecked: a,
124
- required: f,
125
- disabled: u,
126
- value: m = "on",
127
- onCheckedChange: r,
194
+ checked: r,
195
+ defaultChecked: u,
196
+ required: p,
197
+ disabled: m,
198
+ value: s = "on",
199
+ onCheckedChange: i,
128
200
  ...d
129
- } = e, [i, C] = c.useState(null), _ = S(t, (p) => C(p)), k = c.useRef(!1), P = i ? !!i.closest("form") : !0, [b = !1, g] = W({
130
- prop: s,
131
- defaultProp: a,
132
- onChange: r
133
- }), D = c.useRef(b);
201
+ } = e, [a, f] = c.useState(null), h = F(t, (l) => f(l)), C = c.useRef(!1), N = a ? !!a.closest("form") : !0, [x = !1, R] = z({
202
+ prop: r,
203
+ defaultProp: u,
204
+ onChange: i
205
+ }), w = c.useRef(x);
134
206
  return c.useEffect(() => {
135
- const p = i == null ? void 0 : i.form;
136
- if (p) {
137
- const N = () => g(D.current);
138
- return p.addEventListener("reset", N), () => p.removeEventListener("reset", N);
207
+ const l = a == null ? void 0 : a.form;
208
+ if (l) {
209
+ const k = () => R(w.current);
210
+ return l.addEventListener("reset", k), () => l.removeEventListener("reset", k);
139
211
  }
140
- }, [i, g]), /* @__PURE__ */ z(Q, { scope: o, state: b, disabled: u, children: [
141
- /* @__PURE__ */ l(
142
- O.button,
212
+ }, [a, R]), /* @__PURE__ */ D(oe, { scope: o, state: x, disabled: m, children: [
213
+ /* @__PURE__ */ _(
214
+ E.button,
143
215
  {
144
216
  type: "button",
145
217
  role: "checkbox",
146
- "aria-checked": h(b) ? "mixed" : b,
147
- "aria-required": f,
148
- "data-state": w(b),
149
- "data-disabled": u ? "" : void 0,
150
- disabled: u,
151
- value: m,
218
+ "aria-checked": b(x) ? "mixed" : x,
219
+ "aria-required": p,
220
+ "data-state": U(x),
221
+ "data-disabled": m ? "" : void 0,
222
+ disabled: m,
223
+ value: s,
152
224
  ...d,
153
- ref: _,
154
- onKeyDown: A(e.onKeyDown, (p) => {
155
- p.key === "Enter" && p.preventDefault();
225
+ ref: h,
226
+ onKeyDown: A(e.onKeyDown, (l) => {
227
+ l.key === "Enter" && l.preventDefault();
156
228
  }),
157
- onClick: A(e.onClick, (p) => {
158
- g((N) => h(N) ? !0 : !N), P && (k.current = p.isPropagationStopped(), k.current || p.stopPropagation());
229
+ onClick: A(e.onClick, (l) => {
230
+ R((k) => b(k) ? !0 : !k), N && (C.current = l.isPropagationStopped(), C.current || l.stopPropagation());
159
231
  })
160
232
  }
161
233
  ),
162
- P && /* @__PURE__ */ l(
163
- Y,
234
+ N && /* @__PURE__ */ _(
235
+ re,
164
236
  {
165
- control: i,
166
- bubbles: !k.current,
237
+ control: a,
238
+ bubbles: !C.current,
167
239
  name: n,
168
- value: m,
169
- checked: b,
170
- required: f,
171
- disabled: u,
240
+ value: s,
241
+ checked: x,
242
+ required: p,
243
+ disabled: m,
172
244
  style: { transform: "translateX(-100%)" }
173
245
  }
174
246
  )
175
247
  ] });
176
248
  }
177
249
  );
178
- M.displayName = E;
179
- var T = "CheckboxIndicator", U = c.forwardRef(
250
+ M.displayName = S;
251
+ var I = "CheckboxIndicator", T = c.forwardRef(
180
252
  (e, t) => {
181
- const { __scopeCheckbox: o, forceMount: n, ...s } = e, a = V(T, o);
182
- return /* @__PURE__ */ l(I, { present: n || h(a.state) || a.state === !0, children: /* @__PURE__ */ l(
183
- O.span,
253
+ const { __scopeCheckbox: o, forceMount: n, ...r } = e, u = ne(I, o);
254
+ return /* @__PURE__ */ _(O, { present: n || b(u.state) || u.state === !0, children: /* @__PURE__ */ _(
255
+ E.span,
184
256
  {
185
- "data-state": w(a.state),
186
- "data-disabled": a.disabled ? "" : void 0,
187
- ...s,
257
+ "data-state": U(u.state),
258
+ "data-disabled": u.disabled ? "" : void 0,
259
+ ...r,
188
260
  ref: t,
189
261
  style: { pointerEvents: "none", ...e.style }
190
262
  }
191
263
  ) });
192
264
  }
193
265
  );
194
- U.displayName = T;
195
- var Y = (e) => {
196
- const { control: t, checked: o, bubbles: n = !0, ...s } = e, a = c.useRef(null), f = B(o), u = H(t);
266
+ T.displayName = I;
267
+ var re = (e) => {
268
+ const { control: t, checked: o, bubbles: n = !0, ...r } = e, u = c.useRef(null), p = L(o), m = j(t);
197
269
  return c.useEffect(() => {
198
- const m = a.current, r = window.HTMLInputElement.prototype, i = Object.getOwnPropertyDescriptor(r, "checked").set;
199
- if (f !== o && i) {
200
- const C = new Event("click", { bubbles: n });
201
- m.indeterminate = h(o), i.call(m, h(o) ? !1 : o), m.dispatchEvent(C);
270
+ const s = u.current, i = window.HTMLInputElement.prototype, a = Object.getOwnPropertyDescriptor(i, "checked").set;
271
+ if (p !== o && a) {
272
+ const f = new Event("click", { bubbles: n });
273
+ s.indeterminate = b(o), a.call(s, b(o) ? !1 : o), s.dispatchEvent(f);
202
274
  }
203
- }, [f, o, n]), /* @__PURE__ */ l(
275
+ }, [p, o, n]), /* @__PURE__ */ _(
204
276
  "input",
205
277
  {
206
278
  type: "checkbox",
207
279
  "aria-hidden": !0,
208
- defaultChecked: h(o) ? !1 : o,
209
- ...s,
280
+ defaultChecked: b(o) ? !1 : o,
281
+ ...r,
210
282
  tabIndex: -1,
211
- ref: a,
283
+ ref: u,
212
284
  style: {
213
285
  ...e.style,
214
- ...u,
286
+ ...m,
215
287
  position: "absolute",
216
288
  pointerEvents: "none",
217
289
  opacity: 0,
@@ -220,41 +292,41 @@ var Y = (e) => {
220
292
  }
221
293
  );
222
294
  };
223
- function h(e) {
295
+ function b(e) {
224
296
  return e === "indeterminate";
225
297
  }
226
- function w(e) {
227
- return h(e) ? "indeterminate" : e ? "checked" : "unchecked";
298
+ function U(e) {
299
+ return b(e) ? "indeterminate" : e ? "checked" : "unchecked";
228
300
  }
229
- var Z = M, ee = U;
230
- const te = "cfxui__Checkbox__rootUnset__cbb57", oe = "cfxui__Checkbox__root__865aa", ne = "cfxui__Checkbox__indicator__2afc0", v = {
231
- rootUnset: te,
232
- root: oe,
233
- indicator: ne,
301
+ var ie = M, ce = T;
302
+ const se = "cfxui__Checkbox__rootUnset__cbb57", ae = "cfxui__Checkbox__root__865aa", ue = "cfxui__Checkbox__indicator__2afc0", P = {
303
+ rootUnset: se,
304
+ root: ae,
305
+ indicator: ue,
234
306
  "size-small": "cfxui__Checkbox__size-small__02440",
235
307
  "size-normal": "cfxui__Checkbox__size-normal__700f4",
236
308
  "size-large": "cfxui__Checkbox__size-large__28529"
237
309
  };
238
- function re(e) {
310
+ function me(e) {
239
311
  const {
240
312
  id: t,
241
313
  size: o = "normal",
242
314
  rootClassName: n,
243
- indicatorClassName: s,
244
- colorToken: a,
245
- color: f,
246
- opacity: u,
247
- luminance: m,
248
- ...r
249
- } = e, d = R(
250
- v.root,
251
- v.rootUnset,
252
- v[`size-${o}`],
315
+ indicatorClassName: r,
316
+ colorToken: u,
317
+ color: p,
318
+ opacity: m,
319
+ luminance: s,
320
+ ...i
321
+ } = e, d = g(
322
+ P.root,
323
+ P.rootUnset,
324
+ P[`size-${o}`],
253
325
  n
254
- ), i = q(e);
255
- return /* @__PURE__ */ l(Z, { ...r, id: t, style: { color: i }, className: d, children: /* @__PURE__ */ l(ee, { className: R(v.indicator, s), children: /* @__PURE__ */ l($, {}) }) });
326
+ ), a = K(e);
327
+ return /* @__PURE__ */ _(ie, { ...i, id: t, style: { color: a }, className: d, children: /* @__PURE__ */ _(ce, { className: g(P.indicator, r), children: /* @__PURE__ */ _(W, {}) }) });
256
328
  }
257
- const at = L.memo(re);
329
+ const ht = $.memo(me);
258
330
  export {
259
- at as default
331
+ ht as default
260
332
  };
@@ -0,0 +1,16 @@
1
+ import { default as React } from 'react';
2
+ import { InputSize } from '../Input';
3
+ import { SelectOption } from '../Select';
4
+
5
+ export interface DropdownSelectProps<T = string> {
6
+ options: SelectOption<T>[];
7
+ value?: T;
8
+ onChange: (value: T) => void;
9
+ placeholder?: React.ReactNode;
10
+ size?: InputSize;
11
+ disabled?: boolean;
12
+ fullWidth?: boolean;
13
+ onlight?: boolean;
14
+ }
15
+ export declare const DropdownSelect: React.FC<DropdownSelectProps>;
16
+ export default DropdownSelect;