@cfx-dev/ui-components 4.5.13 → 4.5.15

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.
@@ -2,11 +2,16 @@ import { default as React } from 'react';
2
2
  import { GetColorProps } from '../../utils/color';
3
3
  import * as CheckboxUi from '@radix-ui/react-checkbox';
4
4
  export type CheckboxSize = 'small' | 'normal' | 'large';
5
+ export type CheckboxCheckedType = CheckboxUi.CheckedState;
5
6
  export interface CheckboxProps extends Omit<CheckboxUi.CheckboxProps, 'color'>, GetColorProps {
6
7
  id?: string;
7
8
  size?: CheckboxSize;
8
9
  rootClassName?: string;
9
10
  indicatorClassName?: string;
11
+ iconClassName?: string;
12
+ squareClassName?: string;
13
+ checkedClassName?: string;
14
+ iconSquare?: React.ComponentType;
10
15
  iconIndicator?: React.ComponentType;
11
16
  name?: string;
12
17
  }
@@ -1,7 +1,7 @@
1
- import { jsx as a, jsxs as w, Fragment as $ } from "react/jsx-runtime";
2
- import * as u from "react";
1
+ import { jsx as s, jsxs as w, Fragment as $ } from "react/jsx-runtime";
2
+ import * as l from "react";
3
3
  import G from "react";
4
- import { c as K, P as E, d as X, u as B, e as q, f as J } from "../../index-DCuJlMqr.js";
4
+ import { c as K, P as g, 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";
6
6
  import { P as V } from "../../index-DWzyrn_L.js";
7
7
  import "../Icons/cfx-icons/Close.js";
@@ -55,139 +55,139 @@ import "../Icons/cfx-icons-big/Subscriptions.js";
55
55
  import "../Icons/cfx-icons-big/Upload.js";
56
56
  import "../Icons/cfx-icons-big/Warning.js";
57
57
  import "../Icons/cfx-icons-big/Confirm.js";
58
- import { clsx as g } from "../../utils/clsx.js";
58
+ import { clsx as N } from "../../utils/clsx.js";
59
59
  import { getColor as Z } from "../../utils/color.js";
60
- var y = "Checkbox", [ee, ko] = K(y), [oe, N] = ee(y);
60
+ var R = "Checkbox", [ee, ho] = K(R), [oe, E] = ee(R);
61
61
  function te(o) {
62
62
  const {
63
- __scopeCheckbox: i,
64
- checked: c,
65
- children: d,
66
- defaultChecked: t,
63
+ __scopeCheckbox: a,
64
+ checked: n,
65
+ children: m,
66
+ defaultChecked: r,
67
67
  disabled: e,
68
68
  form: f,
69
69
  name: _,
70
- onCheckedChange: m,
70
+ onCheckedChange: d,
71
71
  required: h,
72
- value: l = "on",
72
+ value: C = "on",
73
73
  // @ts-expect-error
74
- internal_do_not_use_render: r
75
- } = o, [p, v] = X({
76
- prop: c,
77
- defaultProp: t ?? !1,
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") : (
74
+ internal_do_not_use_render: p
75
+ } = o, [i, b] = X({
76
+ prop: n,
77
+ defaultProp: r ?? !1,
78
+ onChange: d,
79
+ caller: R
80
+ }), [u, k] = l.useState(null), [I, t] = l.useState(null), c = l.useRef(!1), y = u ? !!f || !!u.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
- checked: p,
84
+ checked: i,
85
85
  disabled: e,
86
- setChecked: v,
87
- control: k,
88
- setControl: b,
86
+ setChecked: b,
87
+ control: u,
88
+ setControl: k,
89
89
  name: _,
90
90
  form: f,
91
- value: l,
92
- hasConsumerStoppedPropagationRef: s,
91
+ value: C,
92
+ hasConsumerStoppedPropagationRef: c,
93
93
  required: h,
94
- defaultChecked: x(t) ? !1 : t,
95
- isFormControl: R,
94
+ defaultChecked: v(r) ? !1 : r,
95
+ isFormControl: y,
96
96
  bubbleInput: I,
97
- setBubbleInput: n
97
+ setBubbleInput: t
98
98
  };
99
- return /* @__PURE__ */ a(
99
+ return /* @__PURE__ */ s(
100
100
  oe,
101
101
  {
102
- scope: i,
102
+ scope: a,
103
103
  ...P,
104
- children: re(r) ? r(P) : d
104
+ children: re(p) ? p(P) : m
105
105
  }
106
106
  );
107
107
  }
108
- var T = "CheckboxTrigger", M = u.forwardRef(
109
- ({ __scopeCheckbox: o, onKeyDown: i, onClick: c, ...d }, t) => {
108
+ var T = "CheckboxTrigger", M = l.forwardRef(
109
+ ({ __scopeCheckbox: o, onKeyDown: a, onClick: n, ...m }, r) => {
110
110
  const {
111
111
  control: e,
112
112
  value: f,
113
113
  disabled: _,
114
- checked: m,
114
+ checked: d,
115
115
  required: h,
116
- setControl: l,
117
- setChecked: r,
118
- hasConsumerStoppedPropagationRef: p,
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);
116
+ setControl: C,
117
+ setChecked: p,
118
+ hasConsumerStoppedPropagationRef: i,
119
+ isFormControl: b,
120
+ bubbleInput: u
121
+ } = E(T, o), k = B(r, C), I = l.useRef(d);
122
+ return l.useEffect(() => {
123
+ const t = e == null ? void 0 : e.form;
124
+ if (t) {
125
+ const c = () => p(I.current);
126
+ return t.addEventListener("reset", c), () => t.removeEventListener("reset", c);
127
127
  }
128
- }, [e, r]), /* @__PURE__ */ a(
129
- E.button,
128
+ }, [e, p]), /* @__PURE__ */ s(
129
+ g.button,
130
130
  {
131
131
  type: "button",
132
132
  role: "checkbox",
133
- "aria-checked": x(m) ? "mixed" : m,
133
+ "aria-checked": v(d) ? "mixed" : d,
134
134
  "aria-required": h,
135
- "data-state": O(m),
135
+ "data-state": O(d),
136
136
  "data-disabled": _ ? "" : void 0,
137
137
  disabled: _,
138
138
  value: f,
139
- ...d,
140
- ref: b,
141
- onKeyDown: q(i, (n) => {
142
- n.key === "Enter" && n.preventDefault();
139
+ ...m,
140
+ ref: k,
141
+ onKeyDown: q(a, (t) => {
142
+ t.key === "Enter" && t.preventDefault();
143
143
  }),
144
- onClick: q(c, (n) => {
145
- r((s) => x(s) ? !0 : !s), k && v && (p.current = n.isPropagationStopped(), p.current || n.stopPropagation());
144
+ onClick: q(n, (t) => {
145
+ p((c) => v(c) ? !0 : !c), u && b && (i.current = t.isPropagationStopped(), i.current || t.stopPropagation());
146
146
  })
147
147
  }
148
148
  );
149
149
  }
150
150
  );
151
151
  M.displayName = T;
152
- var U = u.forwardRef(
153
- (o, i) => {
152
+ var U = l.forwardRef(
153
+ (o, a) => {
154
154
  const {
155
- __scopeCheckbox: c,
156
- name: d,
157
- checked: t,
155
+ __scopeCheckbox: n,
156
+ name: m,
157
+ checked: r,
158
158
  defaultChecked: e,
159
159
  required: f,
160
160
  disabled: _,
161
- value: m,
161
+ value: d,
162
162
  onCheckedChange: h,
163
- form: l,
164
- ...r
163
+ form: C,
164
+ ...p
165
165
  } = o;
166
- return /* @__PURE__ */ a(
166
+ return /* @__PURE__ */ s(
167
167
  te,
168
168
  {
169
- __scopeCheckbox: c,
170
- checked: t,
169
+ __scopeCheckbox: n,
170
+ checked: r,
171
171
  defaultChecked: e,
172
172
  disabled: _,
173
173
  required: f,
174
174
  onCheckedChange: h,
175
- name: d,
176
- form: l,
177
- value: m,
178
- internal_do_not_use_render: ({ isFormControl: p }) => /* @__PURE__ */ w($, { children: [
179
- /* @__PURE__ */ a(
175
+ name: m,
176
+ form: C,
177
+ value: d,
178
+ internal_do_not_use_render: ({ isFormControl: i }) => /* @__PURE__ */ w($, { children: [
179
+ /* @__PURE__ */ s(
180
180
  M,
181
181
  {
182
- ...r,
183
- ref: i,
184
- __scopeCheckbox: c
182
+ ...p,
183
+ ref: a,
184
+ __scopeCheckbox: n
185
185
  }
186
186
  ),
187
- p && /* @__PURE__ */ a(
187
+ i && /* @__PURE__ */ s(
188
188
  L,
189
189
  {
190
- __scopeCheckbox: c
190
+ __scopeCheckbox: n
191
191
  }
192
192
  )
193
193
  ] })
@@ -195,21 +195,21 @@ var U = u.forwardRef(
195
195
  );
196
196
  }
197
197
  );
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(
198
+ U.displayName = R;
199
+ var A = "CheckboxIndicator", D = l.forwardRef(
200
+ (o, a) => {
201
+ const { __scopeCheckbox: n, forceMount: m, ...r } = o, e = E(A, n);
202
+ return /* @__PURE__ */ s(
203
203
  V,
204
204
  {
205
- present: d || x(e.checked) || e.checked === !0,
206
- children: /* @__PURE__ */ a(
207
- E.span,
205
+ present: m || v(e.checked) || e.checked === !0,
206
+ children: /* @__PURE__ */ s(
207
+ g.span,
208
208
  {
209
209
  "data-state": O(e.checked),
210
210
  "data-disabled": e.disabled ? "" : void 0,
211
- ...t,
212
- ref: i,
211
+ ...r,
212
+ ref: a,
213
213
  style: { pointerEvents: "none", ...o.style }
214
214
  }
215
215
  )
@@ -218,50 +218,50 @@ var A = "CheckboxIndicator", D = u.forwardRef(
218
218
  }
219
219
  );
220
220
  D.displayName = A;
221
- var F = "CheckboxBubbleInput", L = u.forwardRef(
222
- ({ __scopeCheckbox: o, ...i }, c) => {
221
+ var F = "CheckboxBubbleInput", L = l.forwardRef(
222
+ ({ __scopeCheckbox: o, ...a }, n) => {
223
223
  const {
224
- control: d,
225
- hasConsumerStoppedPropagationRef: t,
224
+ control: m,
225
+ hasConsumerStoppedPropagationRef: r,
226
226
  checked: e,
227
227
  defaultChecked: f,
228
228
  required: _,
229
- disabled: m,
229
+ disabled: d,
230
230
  name: h,
231
- value: l,
232
- form: r,
233
- bubbleInput: p,
234
- setBubbleInput: v
235
- } = N(F, o), k = B(c, v), b = Q(e), I = J(d);
236
- u.useEffect(() => {
237
- const s = p;
238
- if (!s) return;
239
- const R = window.HTMLInputElement.prototype, S = Object.getOwnPropertyDescriptor(
240
- R,
231
+ value: C,
232
+ form: p,
233
+ bubbleInput: i,
234
+ setBubbleInput: b
235
+ } = E(F, o), u = B(n, b), k = Q(e), I = J(m);
236
+ l.useEffect(() => {
237
+ const c = i;
238
+ if (!c) return;
239
+ const y = window.HTMLInputElement.prototype, S = Object.getOwnPropertyDescriptor(
240
+ y,
241
241
  "checked"
242
- ).set, j = !t.current;
243
- if (b !== e && S) {
242
+ ).set, j = !r.current;
243
+ if (k !== e && S) {
244
244
  const H = new Event("click", { bubbles: j });
245
- s.indeterminate = x(e), S.call(s, x(e) ? !1 : e), s.dispatchEvent(H);
245
+ c.indeterminate = v(e), S.call(c, v(e) ? !1 : e), c.dispatchEvent(H);
246
246
  }
247
- }, [p, b, e, t]);
248
- const n = u.useRef(x(e) ? !1 : e);
249
- return /* @__PURE__ */ a(
250
- E.input,
247
+ }, [i, k, e, r]);
248
+ const t = l.useRef(v(e) ? !1 : e);
249
+ return /* @__PURE__ */ s(
250
+ g.input,
251
251
  {
252
252
  type: "checkbox",
253
253
  "aria-hidden": !0,
254
- defaultChecked: f ?? n.current,
254
+ defaultChecked: f ?? t.current,
255
255
  required: _,
256
- disabled: m,
256
+ disabled: d,
257
257
  name: h,
258
- value: l,
259
- form: r,
260
- ...i,
258
+ value: C,
259
+ form: p,
260
+ ...a,
261
261
  tabIndex: -1,
262
- ref: k,
262
+ ref: u,
263
263
  style: {
264
- ...i.style,
264
+ ...a.style,
265
265
  ...I,
266
266
  position: "absolute",
267
267
  pointerEvents: "none",
@@ -280,71 +280,81 @@ L.displayName = F;
280
280
  function re(o) {
281
281
  return typeof o == "function";
282
282
  }
283
- function x(o) {
283
+ function v(o) {
284
284
  return o === "indeterminate";
285
285
  }
286
286
  function O(o) {
287
- return x(o) ? "indeterminate" : o ? "checked" : "unchecked";
287
+ return v(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", C = {
289
+ const ce = "cfxui__Checkbox__rootUnset__cbb57", ne = "cfxui__Checkbox__root__865aa", ie = "cfxui__Checkbox__square__029aa", ae = "cfxui__Checkbox__indicator__2afc0", se = "cfxui__Checkbox__radioIcon__719e7", me = "cfxui__Checkbox__tickIcon__a7f19", x = {
290
290
  rootUnset: ce,
291
291
  root: ne,
292
292
  square: ie,
293
- indicator: se,
294
- checked: ae,
293
+ indicator: ae,
295
294
  "size-small": "cfxui__Checkbox__size-small__02440",
296
- radioIcon: de,
295
+ radioIcon: se,
297
296
  tickIcon: me,
298
297
  "size-normal": "cfxui__Checkbox__size-normal__700f4",
299
298
  "size-large": "cfxui__Checkbox__size-large__28529"
300
299
  };
301
- function pe(o) {
300
+ function de(o) {
302
301
  const {
303
- id: i,
304
- size: c = "normal",
305
- rootClassName: d,
306
- indicatorClassName: t,
307
- colorToken: e,
308
- color: f,
309
- opacity: _,
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
302
+ id: a,
303
+ size: n = "normal",
304
+ rootClassName: m,
305
+ indicatorClassName: r,
306
+ iconClassName: e,
307
+ checkedClassName: f,
308
+ squareClassName: _,
309
+ colorToken: d,
310
+ color: h,
311
+ opacity: C,
312
+ luminance: p,
313
+ checked: i,
314
+ name: b,
315
+ iconIndicator: u = z,
316
+ iconSquare: k = W,
317
+ ...I
318
+ } = o, t = Z(o), c = N(
319
+ x.root,
320
+ x.rootUnset,
321
+ x[`size-${n}`],
322
+ m,
323
+ {
324
+ [f || ""]: i
325
+ }
326
+ ), y = N(
327
+ x.checked,
328
+ e,
329
+ {
330
+ [x.tickIcon]: u === Y,
331
+ [x.radioIcon]: u === z
332
+ }
324
333
  );
325
334
  return /* @__PURE__ */ w(
326
335
  U,
327
336
  {
328
- ...p,
329
- id: i,
330
- checked: h,
331
- style: { color: k },
332
- className: v,
337
+ ...I,
338
+ id: a,
339
+ checked: i,
340
+ style: { color: t },
341
+ className: c,
333
342
  children: [
334
- l && /* @__PURE__ */ a(
343
+ b && /* @__PURE__ */ s(
335
344
  "input",
336
345
  {
337
346
  type: "hidden",
338
- name: l
347
+ name: b,
348
+ value: i ? "on" : ""
339
349
  }
340
350
  ),
341
- /* @__PURE__ */ a(W, { className: C.square }),
342
- /* @__PURE__ */ a(D, { className: g(C.indicator, t), children: /* @__PURE__ */ a(r, { className: b }) })
351
+ /* @__PURE__ */ s(k, { className: N(x.square, _) }),
352
+ /* @__PURE__ */ s(D, { className: N(x.indicator, r), children: /* @__PURE__ */ s(u, { className: y }) })
343
353
  ]
344
354
  }
345
355
  );
346
356
  }
347
- const bo = G.memo(pe);
357
+ const Co = G.memo(de);
348
358
  export {
349
- bo as default
359
+ Co as default
350
360
  };
@@ -0,0 +1,4 @@
1
+ import { CheckboxProps } from './Checkbox';
2
+
3
+ declare function CheckboxShowcase(props: CheckboxProps): import("react/jsx-runtime").JSX.Element;
4
+ export default CheckboxShowcase;
@@ -0,0 +1,33 @@
1
+ import { jsx as o } from "react/jsx-runtime";
2
+ import r from "react";
3
+ import i from "../Box/Box.js";
4
+ import "../../utils/ui/ui.js";
5
+ import h from "./Checkbox.js";
6
+ const n = "cfxui__CheckboxShowcase__root__5c0e0", _ = "cfxui__CheckboxShowcase__checked__e49f9", k = "cfxui__CheckboxShowcase__icon__686ec", e = {
7
+ root: n,
8
+ checked: _,
9
+ icon: k
10
+ };
11
+ function l(s) {
12
+ const [a, c] = r.useState(!1);
13
+ return /* @__PURE__ */ o(i, { p: 2, children: /* @__PURE__ */ o(
14
+ h,
15
+ {
16
+ ...s,
17
+ id: "checkbox1",
18
+ name: "checkbox1",
19
+ checked: a,
20
+ onCheckedChange: c,
21
+ onClick: () => c((t) => !t),
22
+ size: "normal",
23
+ rootClassName: e.root,
24
+ indicatorClassName: e.indicator,
25
+ iconClassName: e.icon,
26
+ checkedClassName: e.checked,
27
+ squareClassName: e.square
28
+ }
29
+ ) });
30
+ }
31
+ export {
32
+ l as default
33
+ };
@@ -9,7 +9,7 @@ export type TextWeight = 'thin' | 'normal' | 'bold' | 'bolder';
9
9
  export type TextSpecificOpacity = '0' | '25' | '50' | '75' | '100';
10
10
  export type TextOpacity = TextSpecificOpacity | OpacityRange;
11
11
  export type TextAs = 'span' | 'div' | 'p' | 'label' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
12
- export type TextLetterSpacing = 'normal' | 'large';
12
+ export type TextLetterSpacing = 'normal' | 'large' | 'xlarge';
13
13
  export type TextFamaly = 'primary' | 'secondary';
14
14
  interface TextPropsBase {
15
15
  as?: TextAs;
@@ -60,6 +60,7 @@
60
60
  @include ui.def('font-weight-boldest', 900);
61
61
  @include ui.def('letter-spacing-normal', -0.025em);
62
62
  @include ui.def('letter-spacing-large', 0);
63
+ @include ui.def('letter-spacing-xlarge', 1px);
63
64
  @include ui.def('font-family-primary', 'HelveticaNowText');
64
65
  @include ui.def('font-family-secondary', 'HelveticaNowDisplay');
65
66
  @include ui.define-color-token('text', ui.color('primary', 'pure'));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cfx-dev/ui-components",
3
3
  "private": false,
4
- "version": "4.5.13",
4
+ "version": "4.5.15",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "main": "dist/main.js",