@pittorica/radio-card-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/RadioCard.d.ts +31 -0
- package/dist/RadioCard.d.ts.map +1 -0
- package/dist/RadioCard.stories.d.ts +7 -0
- package/dist/RadioCard.stories.d.ts.map +1 -0
- package/dist/RadioCard.test.d.ts +5 -0
- package/dist/RadioCard.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 +169 -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-card-react
|
|
2
|
+
|
|
3
|
+
The `RadioCard` component.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @pittorica/radio-card-react
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```jsx
|
|
14
|
+
import { RadioCard } from '@pittorica/radio-card-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.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type ReactNode, type Ref } from 'react';
|
|
2
|
+
import { type BoxProps } from '@pittorica/box-react';
|
|
3
|
+
import type { PittoricaColor } from '@pittorica/text-react';
|
|
4
|
+
export interface RadioCardRootProps extends BoxProps {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
value?: string;
|
|
7
|
+
defaultValue?: string;
|
|
8
|
+
onValueChange?: (value: string) => void;
|
|
9
|
+
/** @default 'indigo' */
|
|
10
|
+
color?: PittoricaColor;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
/** Number of columns. @default '1' */
|
|
13
|
+
columns?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface RadioCardItemProps extends BoxProps {
|
|
16
|
+
value: string;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare const RadioCard: {
|
|
20
|
+
Root: {
|
|
21
|
+
({ children, value: controlledValue, defaultValue, onValueChange, color, disabled, columns, className, style, ...props }: RadioCardRootProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
displayName: string;
|
|
23
|
+
};
|
|
24
|
+
Item: {
|
|
25
|
+
({ children, value: itemValue, disabled: itemDisabled, className, style, ref, ...props }: RadioCardItemProps & {
|
|
26
|
+
ref?: Ref<HTMLButtonElement>;
|
|
27
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
displayName: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=RadioCard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioCard.d.ts","sourceRoot":"","sources":["../src/RadioCard.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,GAAG,EAKT,MAAM,OAAO,CAAC;AAIf,OAAO,EAAO,KAAK,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAoB5D,MAAM,WAAW,kBAAmB,SAAQ,QAAQ;IAClD,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,wBAAwB;IACxB,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,sCAAsC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAoDD,MAAM,WAAW,kBAAmB,SAAQ,QAAQ;IAClD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAiDD,eAAO,MAAM,SAAS;;kIA3FnB,kBAAkB;;;;kGAoDlB,kBAAkB,GAAG;YAAE,GAAG,CAAC,EAAE,GAAG,CAAC,iBAAiB,CAAC,CAAA;SAAE;;;CA0CvD,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { RadioCard } from './RadioCard.js';
|
|
3
|
+
declare const meta: Meta<typeof RadioCard.Root>;
|
|
4
|
+
export default meta;
|
|
5
|
+
export declare const DeliveryOptions: StoryObj;
|
|
6
|
+
export declare const PlanSelection: StoryObj;
|
|
7
|
+
//# sourceMappingURL=RadioCard.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioCard.stories.d.ts","sourceRoot":"","sources":["../src/RadioCard.stories.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,SAAS,CAAC,IAAI,CAIrC,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,eAAO,MAAM,eAAe,EAAE,QAkC7B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,QAiC3B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioCard.test.d.ts","sourceRoot":"","sources":["../src/RadioCard.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,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { jsx as y } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as W, useState as q, useMemo as E, use as M } from "react";
|
|
3
|
+
function C(t) {
|
|
4
|
+
var a, e, r = "";
|
|
5
|
+
if (typeof t == "string" || typeof t == "number") r += t;
|
|
6
|
+
else if (typeof t == "object") if (Array.isArray(t)) {
|
|
7
|
+
var i = t.length;
|
|
8
|
+
for (a = 0; a < i; a++) t[a] && (e = C(t[a])) && (r && (r += " "), r += e);
|
|
9
|
+
} else for (e in t) t[e] && (r && (r += " "), r += e);
|
|
10
|
+
return r;
|
|
11
|
+
}
|
|
12
|
+
function R() {
|
|
13
|
+
for (var t, a, e = 0, r = "", i = arguments.length; e < i; e++) (t = arguments[e]) && (a = C(t)) && (r && (r += " "), r += a);
|
|
14
|
+
return r;
|
|
15
|
+
}
|
|
16
|
+
function x(t) {
|
|
17
|
+
var a, e, r = "";
|
|
18
|
+
if (typeof t == "string" || typeof t == "number") r += t;
|
|
19
|
+
else if (typeof t == "object") if (Array.isArray(t)) {
|
|
20
|
+
var i = t.length;
|
|
21
|
+
for (a = 0; a < i; a++) t[a] && (e = x(t[a])) && (r && (r += " "), r += e);
|
|
22
|
+
} else for (e in t) t[e] && (r && (r += " "), r += e);
|
|
23
|
+
return r;
|
|
24
|
+
}
|
|
25
|
+
function U() {
|
|
26
|
+
for (var t, a, e = 0, r = "", i = arguments.length; e < i; e++) (t = arguments[e]) && (a = x(t)) && (r && (r += " "), r += a);
|
|
27
|
+
return r;
|
|
28
|
+
}
|
|
29
|
+
const b = ({
|
|
30
|
+
ref: t,
|
|
31
|
+
as: a = "div",
|
|
32
|
+
children: e,
|
|
33
|
+
display: r,
|
|
34
|
+
m: i,
|
|
35
|
+
mt: c,
|
|
36
|
+
mr: p,
|
|
37
|
+
mb: l,
|
|
38
|
+
ml: m,
|
|
39
|
+
p: s,
|
|
40
|
+
pt: u,
|
|
41
|
+
pr: d,
|
|
42
|
+
pb: n,
|
|
43
|
+
pl: f,
|
|
44
|
+
width: g,
|
|
45
|
+
height: v,
|
|
46
|
+
position: h,
|
|
47
|
+
style: w,
|
|
48
|
+
className: A,
|
|
49
|
+
href: T,
|
|
50
|
+
target: j,
|
|
51
|
+
rel: B,
|
|
52
|
+
htmlFor: I,
|
|
53
|
+
type: S,
|
|
54
|
+
disabled: D,
|
|
55
|
+
...F
|
|
56
|
+
}) => {
|
|
57
|
+
const o = {};
|
|
58
|
+
r && (o.display = r), g && (o.width = g), v && (o.height = v), h && (o.position = h), i && (o.margin = `var(--pittorica-space-${i})`), c && (o.marginTop = `var(--pittorica-space-${c})`), p && (o.marginRight = `var(--pittorica-space-${p})`), l && (o.marginBottom = `var(--pittorica-space-${l})`), m && (o.marginLeft = `var(--pittorica-space-${m})`), s && (o.padding = `var(--pittorica-space-${s})`), u && (o.paddingTop = `var(--pittorica-space-${u})`), d && (o.paddingRight = `var(--pittorica-space-${d})`), n && (o.paddingBottom = `var(--pittorica-space-${n})`), f && (o.paddingLeft = `var(--pittorica-space-${f})`);
|
|
59
|
+
const L = {
|
|
60
|
+
...w,
|
|
61
|
+
...o
|
|
62
|
+
};
|
|
63
|
+
return /* @__PURE__ */ y(
|
|
64
|
+
a,
|
|
65
|
+
{
|
|
66
|
+
ref: t,
|
|
67
|
+
className: U("pittorica-box", A),
|
|
68
|
+
style: L,
|
|
69
|
+
href: T,
|
|
70
|
+
target: j,
|
|
71
|
+
rel: B,
|
|
72
|
+
htmlFor: I,
|
|
73
|
+
type: S,
|
|
74
|
+
disabled: D,
|
|
75
|
+
...F,
|
|
76
|
+
children: e
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
b.displayName = "Box";
|
|
81
|
+
const $ = W(null), z = () => {
|
|
82
|
+
const t = M($);
|
|
83
|
+
if (!t)
|
|
84
|
+
throw new Error(
|
|
85
|
+
"RadioCard components must be wrapped in <RadioCard.Root />"
|
|
86
|
+
);
|
|
87
|
+
return t;
|
|
88
|
+
}, N = ({
|
|
89
|
+
children: t,
|
|
90
|
+
value: a,
|
|
91
|
+
defaultValue: e,
|
|
92
|
+
onValueChange: r,
|
|
93
|
+
color: i = "indigo",
|
|
94
|
+
disabled: c,
|
|
95
|
+
columns: p = "1",
|
|
96
|
+
className: l,
|
|
97
|
+
style: m,
|
|
98
|
+
...s
|
|
99
|
+
}) => {
|
|
100
|
+
const [u, d] = q(e), n = a !== void 0, f = n ? a : u, g = (h) => {
|
|
101
|
+
n || d(h), r == null || r(h);
|
|
102
|
+
}, v = E(
|
|
103
|
+
() => ({
|
|
104
|
+
value: f,
|
|
105
|
+
onValueChange: g,
|
|
106
|
+
color: i,
|
|
107
|
+
disabled: c
|
|
108
|
+
}),
|
|
109
|
+
[f, i, c]
|
|
110
|
+
);
|
|
111
|
+
return /* @__PURE__ */ y($, { value: v, children: /* @__PURE__ */ y(
|
|
112
|
+
b,
|
|
113
|
+
{
|
|
114
|
+
...s,
|
|
115
|
+
role: "radiogroup",
|
|
116
|
+
className: R("pittorica-radio-card-root", l),
|
|
117
|
+
style: {
|
|
118
|
+
display: "grid",
|
|
119
|
+
gridTemplateColumns: `repeat(${p}, minmax(0, 1fr))`,
|
|
120
|
+
gap: "var(--pittorica-space-3)",
|
|
121
|
+
...m
|
|
122
|
+
},
|
|
123
|
+
children: t
|
|
124
|
+
}
|
|
125
|
+
) });
|
|
126
|
+
}, k = ({
|
|
127
|
+
children: t,
|
|
128
|
+
value: a,
|
|
129
|
+
disabled: e,
|
|
130
|
+
className: r,
|
|
131
|
+
style: i,
|
|
132
|
+
ref: c,
|
|
133
|
+
...p
|
|
134
|
+
}) => {
|
|
135
|
+
const {
|
|
136
|
+
value: l,
|
|
137
|
+
onValueChange: m,
|
|
138
|
+
color: s,
|
|
139
|
+
disabled: u
|
|
140
|
+
} = z(), d = l === a, n = u || e, g = s !== "inherit" && !(s != null && s.startsWith("#")) && !(s != null && s.startsWith("rgb")) ? `var(--pittorica-${s}-9)` : s;
|
|
141
|
+
return /* @__PURE__ */ y(
|
|
142
|
+
b,
|
|
143
|
+
{
|
|
144
|
+
...p,
|
|
145
|
+
as: "button",
|
|
146
|
+
type: "button",
|
|
147
|
+
role: "radio",
|
|
148
|
+
"aria-checked": d,
|
|
149
|
+
"data-state": d ? "checked" : "unchecked",
|
|
150
|
+
disabled: n,
|
|
151
|
+
className: R("pittorica-radio-card-item", r),
|
|
152
|
+
onClick: () => !n && m(a),
|
|
153
|
+
ref: c,
|
|
154
|
+
style: {
|
|
155
|
+
"--pittorica-source-color": g,
|
|
156
|
+
...i
|
|
157
|
+
},
|
|
158
|
+
children: t
|
|
159
|
+
}
|
|
160
|
+
);
|
|
161
|
+
}, J = {
|
|
162
|
+
Root: N,
|
|
163
|
+
Item: k
|
|
164
|
+
};
|
|
165
|
+
N.displayName = "RadioCard.Root";
|
|
166
|
+
k.displayName = "RadioCard.Item";
|
|
167
|
+
export {
|
|
168
|
+
J as RadioCard
|
|
169
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pittorica/radio-card-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/flex-react": "0.22.0",
|
|
28
|
+
"@pittorica/theme-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
|
+
}
|