@pittorica/radio-react 0.22.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/LICENSE +21 -0
- package/README.md +24 -0
- package/dist/Radio.d.ts +21 -0
- package/dist/Radio.d.ts.map +1 -0
- package/dist/Radio.stories.d.ts +8 -0
- package/dist/Radio.stories.d.ts.map +1 -0
- package/dist/Radio.test.d.ts +5 -0
- package/dist/Radio.test.d.ts.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +190 -0
- package/package.json +44 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Davide Di Criscito
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# @pittorica/radio-react
|
|
2
|
+
|
|
3
|
+
The `Radio` component.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @pittorica/radio-react
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```jsx
|
|
14
|
+
import { Radio } from '@pittorica/radio-react';
|
|
15
|
+
// TODO: Add usage example
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## License
|
|
19
|
+
|
|
20
|
+
This project is licensed under the MIT License.
|
|
21
|
+
|
|
22
|
+
**Copyright (c) 2025 Davide Di Criscito**
|
|
23
|
+
|
|
24
|
+
For the full details, see the [LICENSE](LICENSE) file.
|
package/dist/Radio.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type Ref } from 'react';
|
|
2
|
+
import { type BoxProps } from '@pittorica/box-react';
|
|
3
|
+
import type { PittoricaColor } from '@pittorica/text-react';
|
|
4
|
+
export interface RadioProps extends Omit<BoxProps, 'onChange'> {
|
|
5
|
+
checked?: boolean;
|
|
6
|
+
defaultChecked?: boolean;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
/** @default 'indigo' */
|
|
9
|
+
color?: PittoricaColor;
|
|
10
|
+
value?: string;
|
|
11
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
12
|
+
ref?: Ref<HTMLButtonElement>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Primitive Radio component.
|
|
16
|
+
*/
|
|
17
|
+
export declare const Radio: {
|
|
18
|
+
({ checked, disabled, color, className, style, onCheckedChange, ref, ...props }: RadioProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
displayName: string;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=Radio.d.ts.map
|
|
@@ -0,0 +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,SAAQ,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC;IAC5D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,wBAAwB;IACxB,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7C,GAAG,CAAC,EAAE,GAAG,CAAC,iBAAiB,CAAC,CAAC;CAC9B;AAED;;GAEG;AACH,eAAO,MAAM,KAAK;qFASf,UAAU;;CA+BZ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Radio } from './Radio.js';
|
|
3
|
+
declare const meta: Meta<typeof Radio>;
|
|
4
|
+
export default meta;
|
|
5
|
+
export declare const Basic: StoryObj<typeof Radio>;
|
|
6
|
+
export declare const Colors: StoryObj<typeof Radio>;
|
|
7
|
+
export declare const States: StoryObj<typeof Radio>;
|
|
8
|
+
//# sourceMappingURL=Radio.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Radio.stories.d.ts","sourceRoot":"","sources":["../src/Radio.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,KAAK,CAI5B,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,eAAO,MAAM,KAAK,EAAE,QAAQ,CAAC,OAAO,KAAK,CAYxC,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,QAAQ,CAAC,OAAO,KAAK,CASzC,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,QAAQ,CAAC,OAAO,KAAK,CAiBzC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Radio.test.d.ts","sourceRoot":"","sources":["../src/Radio.test.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,2BAA2B,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { jsx as h } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as z, createElement as v } from "react";
|
|
3
|
+
function b(t) {
|
|
4
|
+
var e, i, r = "";
|
|
5
|
+
if (typeof t == "string" || typeof t == "number") r += t;
|
|
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;
|
|
11
|
+
}
|
|
12
|
+
function T() {
|
|
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;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* @license @tabler/icons-react v3.36.1 - MIT
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the MIT license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/
|
|
22
|
+
var I = {
|
|
23
|
+
outline: {
|
|
24
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
25
|
+
width: 24,
|
|
26
|
+
height: 24,
|
|
27
|
+
viewBox: "0 0 24 24",
|
|
28
|
+
fill: "none",
|
|
29
|
+
stroke: "currentColor",
|
|
30
|
+
strokeWidth: 2,
|
|
31
|
+
strokeLinecap: "round",
|
|
32
|
+
strokeLinejoin: "round"
|
|
33
|
+
},
|
|
34
|
+
filled: {
|
|
35
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
36
|
+
width: 24,
|
|
37
|
+
height: 24,
|
|
38
|
+
viewBox: "0 0 24 24",
|
|
39
|
+
fill: "currentColor",
|
|
40
|
+
stroke: "none"
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* @license @tabler/icons-react v3.36.1 - MIT
|
|
45
|
+
*
|
|
46
|
+
* This source code is licensed under the MIT license.
|
|
47
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
48
|
+
*/
|
|
49
|
+
const $ = (t, e, i, r) => {
|
|
50
|
+
const a = z(
|
|
51
|
+
({ color: s = "currentColor", size: n = 24, stroke: l = 2, title: p, className: c, children: d, ...m }, f) => v(
|
|
52
|
+
"svg",
|
|
53
|
+
{
|
|
54
|
+
ref: f,
|
|
55
|
+
...I[t],
|
|
56
|
+
width: n,
|
|
57
|
+
height: n,
|
|
58
|
+
className: ["tabler-icon", `tabler-icon-${e}`, c].join(" "),
|
|
59
|
+
...t === "filled" ? {
|
|
60
|
+
fill: s
|
|
61
|
+
} : {
|
|
62
|
+
strokeWidth: l,
|
|
63
|
+
stroke: s
|
|
64
|
+
},
|
|
65
|
+
...m
|
|
66
|
+
},
|
|
67
|
+
[
|
|
68
|
+
p && v("title", { key: "svg-title" }, p),
|
|
69
|
+
...r.map(([g, u]) => v(g, u)),
|
|
70
|
+
...Array.isArray(d) ? d : [d]
|
|
71
|
+
]
|
|
72
|
+
)
|
|
73
|
+
);
|
|
74
|
+
return a.displayName = `${i}`, a;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* @license @tabler/icons-react v3.36.1 - MIT
|
|
78
|
+
*
|
|
79
|
+
* This source code is licensed under the MIT license.
|
|
80
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
81
|
+
*/
|
|
82
|
+
const M = [["path", { d: "M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0", key: "svg-0" }]], S = $("outline", "circle", "Circle", M);
|
|
83
|
+
/**
|
|
84
|
+
* @license @tabler/icons-react v3.36.1 - MIT
|
|
85
|
+
*
|
|
86
|
+
* This source code is licensed under the MIT license.
|
|
87
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
88
|
+
*/
|
|
89
|
+
const q = [["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 = $("filled", "circle-check-filled", "CircleCheckFilled", q);
|
|
90
|
+
function k(t) {
|
|
91
|
+
var e, i, r = "";
|
|
92
|
+
if (typeof t == "string" || typeof t == "number") r += t;
|
|
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;
|
|
98
|
+
}
|
|
99
|
+
function D() {
|
|
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;
|
|
102
|
+
}
|
|
103
|
+
const x = ({
|
|
104
|
+
ref: t,
|
|
105
|
+
as: e = "div",
|
|
106
|
+
children: i,
|
|
107
|
+
display: r,
|
|
108
|
+
m: a,
|
|
109
|
+
mt: s,
|
|
110
|
+
mr: n,
|
|
111
|
+
mb: l,
|
|
112
|
+
ml: p,
|
|
113
|
+
p: c,
|
|
114
|
+
pt: d,
|
|
115
|
+
pr: m,
|
|
116
|
+
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
|
+
disabled: L,
|
|
129
|
+
...W
|
|
130
|
+
}) => {
|
|
131
|
+
const o = {};
|
|
132
|
+
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})`), n && (o.marginRight = `var(--pittorica-space-${n})`), l && (o.marginBottom = `var(--pittorica-space-${l})`), p && (o.marginLeft = `var(--pittorica-space-${p})`), c && (o.padding = `var(--pittorica-space-${c})`), d && (o.paddingTop = `var(--pittorica-space-${d})`), m && (o.paddingRight = `var(--pittorica-space-${m})`), f && (o.paddingBottom = `var(--pittorica-space-${f})`), g && (o.paddingLeft = `var(--pittorica-space-${g})`);
|
|
133
|
+
const _ = {
|
|
134
|
+
...N,
|
|
135
|
+
...o
|
|
136
|
+
};
|
|
137
|
+
return /* @__PURE__ */ h(
|
|
138
|
+
e,
|
|
139
|
+
{
|
|
140
|
+
ref: t,
|
|
141
|
+
className: D("pittorica-box", A),
|
|
142
|
+
style: _,
|
|
143
|
+
href: R,
|
|
144
|
+
target: j,
|
|
145
|
+
rel: B,
|
|
146
|
+
htmlFor: C,
|
|
147
|
+
type: F,
|
|
148
|
+
disabled: L,
|
|
149
|
+
...W,
|
|
150
|
+
children: i
|
|
151
|
+
}
|
|
152
|
+
);
|
|
153
|
+
};
|
|
154
|
+
x.displayName = "Box";
|
|
155
|
+
const G = ({
|
|
156
|
+
checked: t,
|
|
157
|
+
disabled: e,
|
|
158
|
+
color: i = "indigo",
|
|
159
|
+
className: r,
|
|
160
|
+
style: a,
|
|
161
|
+
onCheckedChange: s,
|
|
162
|
+
ref: n,
|
|
163
|
+
...l
|
|
164
|
+
}) => {
|
|
165
|
+
const c = i !== "inherit" && !(i != null && i.startsWith("#")) && !(i != null && i.startsWith("rgb")) ? `var(--pittorica-${i}-9)` : i;
|
|
166
|
+
return /* @__PURE__ */ h(
|
|
167
|
+
x,
|
|
168
|
+
{
|
|
169
|
+
...l,
|
|
170
|
+
as: "button",
|
|
171
|
+
type: "button",
|
|
172
|
+
role: "radio",
|
|
173
|
+
"aria-checked": t,
|
|
174
|
+
"data-state": t ? "checked" : "unchecked",
|
|
175
|
+
disabled: e,
|
|
176
|
+
className: T("pittorica-radio-root", r),
|
|
177
|
+
onClick: () => !e && (s == null ? void 0 : s(!t)),
|
|
178
|
+
ref: n,
|
|
179
|
+
style: {
|
|
180
|
+
"--pittorica-source-color": c,
|
|
181
|
+
...a
|
|
182
|
+
},
|
|
183
|
+
children: t ? /* @__PURE__ */ h(E, { size: 14 }) : /* @__PURE__ */ h(S, { size: 14, opacity: 0.5 })
|
|
184
|
+
}
|
|
185
|
+
);
|
|
186
|
+
};
|
|
187
|
+
G.displayName = "Radio";
|
|
188
|
+
export {
|
|
189
|
+
G as Radio
|
|
190
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pittorica/radio-react",
|
|
3
|
+
"version": "0.22.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@tabler/icons-react": "^3.36.1",
|
|
13
|
+
"clsx": "^2.1.1",
|
|
14
|
+
"@pittorica/box-react": "0.22.0",
|
|
15
|
+
"@pittorica/text-react": "0.22.0"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
19
|
+
"@testing-library/react": "^14.0.0",
|
|
20
|
+
"@types/react": "^19.2.3",
|
|
21
|
+
"@types/react-dom": "^19.2.3",
|
|
22
|
+
"@vitejs/plugin-react": "^4.0.0",
|
|
23
|
+
"jsdom": "^22.0.0",
|
|
24
|
+
"typescript": "^5.0.0",
|
|
25
|
+
"vite": "^5.0.0",
|
|
26
|
+
"vitest": "^2.1.9",
|
|
27
|
+
"@pittorica/theme-react": "0.22.0",
|
|
28
|
+
"@pittorica/flex-react": "0.22.0",
|
|
29
|
+
"pittorica": "0.22.0"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"react": ">=19",
|
|
33
|
+
"react-dom": ">=19"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "npm run clean && npm run build:js && npm run build:types",
|
|
37
|
+
"build:js": "vite build",
|
|
38
|
+
"build:types": "tsc -p tsconfig.json",
|
|
39
|
+
"clean": "rm -rf dist",
|
|
40
|
+
"dev": "vite",
|
|
41
|
+
"test": "vitest run",
|
|
42
|
+
"test:watch": "vitest"
|
|
43
|
+
}
|
|
44
|
+
}
|