@pittorica/radio-react 0.24.0 → 0.25.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.
package/dist/Radio.d.ts CHANGED
@@ -1,7 +1,10 @@
1
- import { type Ref } from 'react';
1
+ import { type ElementType } from 'react';
2
2
  import { type BoxProps } from '@pittorica/box-react';
3
3
  import type { PittoricaColor } from '@pittorica/text-react';
4
- export interface RadioProps extends Omit<BoxProps, 'onChange'> {
4
+ /**
5
+ * Fix TS2314 & TS2312: Use 'type' alias for intersection with polymorphic BoxProps<E>.
6
+ */
7
+ export type RadioProps<E extends ElementType = 'button'> = Omit<BoxProps<E>, 'onChange'> & {
5
8
  checked?: boolean;
6
9
  defaultChecked?: boolean;
7
10
  disabled?: boolean;
@@ -10,13 +13,13 @@ export interface RadioProps extends Omit<BoxProps, 'onChange'> {
10
13
  value?: string;
11
14
  name?: string;
12
15
  onCheckedChange?: (checked: boolean) => void;
13
- ref?: Ref<HTMLButtonElement>;
14
- }
16
+ };
15
17
  /**
16
18
  * Primitive Radio component.
19
+ * Fully polymorphic and agnostic foundation.
17
20
  */
18
21
  export declare const Radio: {
19
- ({ checked, disabled, color, className, style, onCheckedChange, name, ref, ...props }: RadioProps): import("react/jsx-runtime").JSX.Element;
22
+ <E extends ElementType = "button">({ checked, disabled, color, className, style, onCheckedChange, name, as, ...props }: RadioProps<E>): import("react/jsx-runtime").JSX.Element;
20
23
  displayName: string;
21
24
  };
22
25
  //# sourceMappingURL=Radio.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Radio.d.ts","sourceRoot":"","sources":["../src/Radio.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,GAAG,EAAa,MAAM,OAAO,CAAC;AAMhE,OAAO,EAAO,KAAK,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,MAAM,WAAW,UAAW,S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C,UAAU,CAAC,CAAC,CAAC;;CA0Cf,CAAC"}
package/dist/index.js CHANGED
@@ -1,17 +1,17 @@
1
- import { jsx as h } from "react/jsx-runtime";
2
- import { forwardRef as I, createElement as v } from "react";
3
- function b(t) {
4
- var e, i, r = "";
5
- if (typeof t == "string" || typeof t == "number") r += t;
1
+ import { jsx as u } from "react/jsx-runtime";
2
+ import { forwardRef as _, createElement as $ } from "react";
3
+ function x(t) {
4
+ var r, i, a = "";
5
+ if (typeof t == "string" || typeof t == "number") a += t;
6
6
  else if (typeof t == "object") if (Array.isArray(t)) {
7
- var a = t.length;
8
- for (e = 0; e < a; e++) t[e] && (i = b(t[e])) && (r && (r += " "), r += i);
9
- } else for (i in t) t[i] && (r && (r += " "), r += i);
10
- return r;
7
+ var o = t.length;
8
+ for (r = 0; r < o; r++) t[r] && (i = x(t[r])) && (a && (a += " "), a += i);
9
+ } else for (i in t) t[i] && (a && (a += " "), a += i);
10
+ return a;
11
11
  }
12
- function M() {
13
- for (var t, e, i = 0, r = "", a = arguments.length; i < a; i++) (t = arguments[i]) && (e = b(t)) && (r && (r += " "), r += e);
14
- return r;
12
+ function z() {
13
+ for (var t, r, i = 0, a = "", o = arguments.length; i < o; i++) (t = arguments[i]) && (r = x(t)) && (a && (a += " "), a += r);
14
+ return a;
15
15
  }
16
16
  /**
17
17
  * @license @tabler/icons-react v3.36.1 - MIT
@@ -19,7 +19,7 @@ function M() {
19
19
  * This source code is licensed under the MIT license.
20
20
  * See the LICENSE file in the root directory of this source tree.
21
21
  */
22
- var S = {
22
+ var F = {
23
23
  outline: {
24
24
  xmlns: "http://www.w3.org/2000/svg",
25
25
  width: 24,
@@ -46,32 +46,32 @@ var S = {
46
46
  * This source code is licensed under the MIT license.
47
47
  * See the LICENSE file in the root directory of this source tree.
48
48
  */
49
- const $ = (t, e, i, r) => {
50
- const a = I(
51
- ({ color: s = "currentColor", size: l = 24, stroke: c = 2, title: p, className: d, children: n, ...m }, f) => v(
49
+ const N = (t, r, i, a) => {
50
+ const o = _(
51
+ ({ color: s = "currentColor", size: p = 24, stroke: d = 2, title: n, className: m, children: c, ...l }, g) => $(
52
52
  "svg",
53
53
  {
54
- ref: f,
55
- ...S[t],
56
- width: l,
57
- height: l,
58
- className: ["tabler-icon", `tabler-icon-${e}`, d].join(" "),
54
+ ref: g,
55
+ ...F[t],
56
+ width: p,
57
+ height: p,
58
+ className: ["tabler-icon", `tabler-icon-${r}`, m].join(" "),
59
59
  ...t === "filled" ? {
60
60
  fill: s
61
61
  } : {
62
- strokeWidth: c,
62
+ strokeWidth: d,
63
63
  stroke: s
64
64
  },
65
- ...m
65
+ ...l
66
66
  },
67
67
  [
68
- p && v("title", { key: "svg-title" }, p),
69
- ...r.map(([g, u]) => v(g, u)),
70
- ...Array.isArray(n) ? n : [n]
68
+ n && $("title", { key: "svg-title" }, n),
69
+ ...a.map(([f, v]) => $(f, v)),
70
+ ...Array.isArray(c) ? c : [c]
71
71
  ]
72
72
  )
73
73
  );
74
- return a.displayName = `${i}`, a;
74
+ return o.displayName = `${i}`, o;
75
75
  };
76
76
  /**
77
77
  * @license @tabler/icons-react v3.36.1 - MIT
@@ -79,116 +79,107 @@ const $ = (t, e, i, r) => {
79
79
  * This source code is licensed under the MIT license.
80
80
  * See the LICENSE file in the root directory of this source tree.
81
81
  */
82
- const T = [["path", { d: "M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0", key: "svg-0" }]], q = $("outline", "circle", "Circle", T);
82
+ const I = [["path", { d: "M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0", key: "svg-0" }]], M = N("outline", "circle", "Circle", I);
83
83
  /**
84
84
  * @license @tabler/icons-react v3.36.1 - MIT
85
85
  *
86
86
  * This source code is licensed under the MIT license.
87
87
  * See the LICENSE file in the root directory of this source tree.
88
88
  */
89
- const E = [["path", { d: "M17 3.34a10 10 0 1 1 -14.995 8.984l-.005 -.324l.005 -.324a10 10 0 0 1 14.995 -8.336zm-1.293 5.953a1 1 0 0 0 -1.32 -.083l-.094 .083l-3.293 3.292l-1.293 -1.292l-.094 -.083a1 1 0 0 0 -1.403 1.403l.083 .094l2 2l.094 .083a1 1 0 0 0 1.226 0l.094 -.083l4 -4l.083 -.094a1 1 0 0 0 -.083 -1.32z", key: "svg-0" }]], D = $("filled", "circle-check-filled", "CircleCheckFilled", E);
90
- function k(t) {
91
- var e, i, r = "";
92
- if (typeof t == "string" || typeof t == "number") r += t;
89
+ const S = [["path", { d: "M17 3.34a10 10 0 1 1 -14.995 8.984l-.005 -.324l.005 -.324a10 10 0 0 1 14.995 -8.336zm-1.293 5.953a1 1 0 0 0 -1.32 -.083l-.094 .083l-3.293 3.292l-1.293 -1.292l-.094 -.083a1 1 0 0 0 -1.403 1.403l.083 .094l2 2l.094 .083a1 1 0 0 0 1.226 0l.094 -.083l4 -4l.083 -.094a1 1 0 0 0 -.083 -1.32z", key: "svg-0" }]], E = N("filled", "circle-check-filled", "CircleCheckFilled", S);
90
+ function A(t) {
91
+ var r, i, a = "";
92
+ if (typeof t == "string" || typeof t == "number") a += t;
93
93
  else if (typeof t == "object") if (Array.isArray(t)) {
94
- var a = t.length;
95
- for (e = 0; e < a; e++) t[e] && (i = k(t[e])) && (r && (r += " "), r += i);
96
- } else for (i in t) t[i] && (r && (r += " "), r += i);
97
- return r;
94
+ var o = t.length;
95
+ for (r = 0; r < o; r++) t[r] && (i = A(t[r])) && (a && (a += " "), a += i);
96
+ } else for (i in t) t[i] && (a && (a += " "), a += i);
97
+ return a;
98
98
  }
99
- function G() {
100
- for (var t, e, i = 0, r = "", a = arguments.length; i < a; i++) (t = arguments[i]) && (e = k(t)) && (r && (r += " "), r += e);
101
- return r;
99
+ function q() {
100
+ for (var t, r, i = 0, a = "", o = arguments.length; i < o; i++) (t = arguments[i]) && (r = A(t)) && (a && (a += " "), a += r);
101
+ return a;
102
102
  }
103
- const x = ({
104
- ref: t,
105
- as: e = "div",
106
- children: i,
107
- display: r,
103
+ const C = ({
104
+ as: t,
105
+ children: r,
106
+ display: i,
108
107
  m: a,
109
- mt: s,
110
- mr: l,
111
- mb: c,
112
- ml: p,
113
- p: d,
114
- pt: n,
115
- pr: m,
108
+ mt: o,
109
+ mr: s,
110
+ mb: p,
111
+ ml: d,
112
+ mx: n,
113
+ my: m,
114
+ p: c,
115
+ pt: l,
116
+ pr: g,
116
117
  pb: f,
117
- pl: g,
118
- width: u,
119
- height: y,
120
- position: w,
121
- style: N,
122
- className: A,
123
- href: R,
124
- target: j,
125
- rel: B,
126
- htmlFor: C,
127
- type: F,
128
- name: L,
129
- disabled: W,
130
- ..._
118
+ pl: v,
119
+ px: h,
120
+ py: y,
121
+ width: b,
122
+ height: w,
123
+ position: k,
124
+ style: R,
125
+ className: B,
126
+ disabled: L,
127
+ ...T
131
128
  }) => {
132
- const o = {};
133
- r && (o.display = r), u && (o.width = u), y && (o.height = y), w && (o.position = w), a && (o.margin = `var(--pittorica-space-${a})`), s && (o.marginTop = `var(--pittorica-space-${s})`), l && (o.marginRight = `var(--pittorica-space-${l})`), c && (o.marginBottom = `var(--pittorica-space-${c})`), p && (o.marginLeft = `var(--pittorica-space-${p})`), d && (o.padding = `var(--pittorica-space-${d})`), n && (o.paddingTop = `var(--pittorica-space-${n})`), m && (o.paddingRight = `var(--pittorica-space-${m})`), f && (o.paddingBottom = `var(--pittorica-space-${f})`), g && (o.paddingLeft = `var(--pittorica-space-${g})`);
134
- const z = {
135
- ...N,
136
- ...o
129
+ const j = t || "div", e = {};
130
+ i && (e.display = i), b && (e.width = b), w && (e.height = w), k && (e.position = k), a && (e.margin = `var(--pittorica-space-${a})`), o && (e.marginTop = `var(--pittorica-space-${o})`), s && (e.marginRight = `var(--pittorica-space-${s})`), p && (e.marginBottom = `var(--pittorica-space-${p})`), d && (e.marginLeft = `var(--pittorica-space-${d})`), n && (e.marginLeft = `var(--pittorica-space-${n})`, e.marginRight = `var(--pittorica-space-${n})`), m && (e.marginTop = `var(--pittorica-space-${m})`, e.marginBottom = `var(--pittorica-space-${m})`), c && (e.padding = `var(--pittorica-space-${c})`), l && (e.paddingTop = `var(--pittorica-space-${l})`), g && (e.paddingRight = `var(--pittorica-space-${g})`), f && (e.paddingBottom = `var(--pittorica-space-${f})`), v && (e.paddingLeft = `var(--pittorica-space-${v})`), h && (e.paddingLeft = `var(--pittorica-space-${h})`, e.paddingRight = `var(--pittorica-space-${h})`), y && (e.paddingTop = `var(--pittorica-space-${y})`, e.paddingBottom = `var(--pittorica-space-${y})`);
131
+ const W = {
132
+ ...R,
133
+ ...e
137
134
  };
138
- return /* @__PURE__ */ h(
139
- e,
135
+ return /* @__PURE__ */ u(
136
+ j,
140
137
  {
141
- ref: t,
142
- className: G("pittorica-box", A),
143
- style: z,
144
- href: R,
145
- target: j,
146
- rel: B,
147
- htmlFor: C,
148
- type: F,
149
- name: L,
150
- disabled: W,
151
- ..._,
152
- children: i
138
+ className: q("pittorica-box", B),
139
+ style: W,
140
+ disabled: L,
141
+ ...T,
142
+ children: r
153
143
  }
154
144
  );
155
145
  };
156
- x.displayName = "Box";
157
- const H = ({
146
+ C.displayName = "Box";
147
+ const D = ({
158
148
  checked: t,
159
- disabled: e,
149
+ disabled: r,
160
150
  color: i = "indigo",
161
- className: r,
162
- style: a,
151
+ className: a,
152
+ style: o,
163
153
  onCheckedChange: s,
164
- name: l,
165
- ref: c,
166
- ...p
154
+ name: p,
155
+ as: d,
156
+ ...n
167
157
  }) => {
168
- const n = i !== "inherit" && !(i != null && i.startsWith("#")) && !(i != null && i.startsWith("rgb")) ? `var(--pittorica-${i}-9)` : i;
169
- return /* @__PURE__ */ h(
170
- x,
158
+ const c = i !== "inherit" && !(i != null && i.startsWith("#")) && !(i != null && i.startsWith("rgb")) ? `var(--pittorica-${i}-9)` : i, l = d || "button", g = (f) => {
159
+ r || (s == null || s(!t), typeof n.onClick == "function" && n.onClick(f));
160
+ };
161
+ return /* @__PURE__ */ u(
162
+ C,
171
163
  {
172
- ...p,
173
- as: "button",
174
- type: "button",
164
+ as: l,
165
+ type: l === "button" ? "button" : void 0,
175
166
  role: "radio",
176
- name: l,
167
+ name: p,
177
168
  "aria-checked": t,
178
169
  "data-state": t ? "checked" : "unchecked",
179
- disabled: e,
180
- className: M("pittorica-radio-root", r),
181
- onClick: () => !e && (s == null ? void 0 : s(!t)),
182
- ref: c,
170
+ disabled: r,
171
+ className: z("pittorica-radio-root", a),
172
+ onClick: g,
183
173
  style: {
184
- "--pittorica-source-color": n,
185
- ...a
174
+ "--pittorica-source-color": c,
175
+ ...o
186
176
  },
187
- children: t ? /* @__PURE__ */ h(D, { size: 14 }) : /* @__PURE__ */ h(q, { size: 14, opacity: 0.5 })
177
+ ...n,
178
+ children: t ? /* @__PURE__ */ u(E, { size: 14 }) : /* @__PURE__ */ u(M, { size: 14, opacity: 0.5 })
188
179
  }
189
180
  );
190
181
  };
191
- H.displayName = "Radio";
182
+ D.displayName = "Radio";
192
183
  export {
193
- H as Radio
184
+ D as Radio
194
185
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pittorica/radio-react",
3
- "version": "0.24.0",
3
+ "version": "0.25.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -11,8 +11,8 @@
11
11
  "dependencies": {
12
12
  "@tabler/icons-react": "^3.36.1",
13
13
  "clsx": "^2.1.1",
14
- "@pittorica/box-react": "0.24.0",
15
- "@pittorica/text-react": "0.24.0"
14
+ "@pittorica/box-react": "0.25.0",
15
+ "@pittorica/text-react": "0.25.0"
16
16
  },
17
17
  "devDependencies": {
18
18
  "@testing-library/jest-dom": "^6.9.1",
@@ -24,9 +24,9 @@
24
24
  "typescript": "^5.0.0",
25
25
  "vite": "^5.0.0",
26
26
  "vitest": "^2.1.9",
27
- "@pittorica/theme-react": "0.24.0",
28
- "@pittorica/flex-react": "0.24.0",
29
- "pittorica": "0.24.0"
27
+ "@pittorica/flex-react": "0.25.0",
28
+ "@pittorica/theme-react": "0.25.0",
29
+ "pittorica": "0.25.0"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "react": ">=19",
@@ -37,7 +37,6 @@
37
37
  "build:js": "vite build",
38
38
  "build:types": "tsc -p tsconfig.json",
39
39
  "clean": "rm -rf dist",
40
- "dev": "vite",
41
40
  "test": "vitest run",
42
41
  "test:watch": "vitest"
43
42
  }