@pittorica/checkbox-group-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/CheckboxGroup.d.ts +18 -0
- package/dist/CheckboxGroup.d.ts.map +1 -0
- package/dist/CheckboxGroup.stories.d.ts +7 -0
- package/dist/CheckboxGroup.stories.d.ts.map +1 -0
- package/dist/CheckboxGroup.test.d.ts +5 -0
- package/dist/CheckboxGroup.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 +473 -0
- package/package.json +43 -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/checkbox-group-react
|
|
2
|
+
|
|
3
|
+
The `CheckboxGroup` component.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @pittorica/checkbox-group-react
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```jsx
|
|
14
|
+
import { CheckboxGroup } from '@pittorica/checkbox-group-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,18 @@
|
|
|
1
|
+
import { type BoxProps } from '@pittorica/box-react';
|
|
2
|
+
import { type CheckboxProps } from '@pittorica/checkbox-react';
|
|
3
|
+
import type { PittoricaColor } from '@pittorica/text-react';
|
|
4
|
+
export interface CheckboxGroupRootProps extends Omit<BoxProps, 'onChange'> {
|
|
5
|
+
value?: string[];
|
|
6
|
+
defaultValue?: string[];
|
|
7
|
+
onValueChange?: (value: string[]) => void;
|
|
8
|
+
orientation?: 'horizontal' | 'vertical';
|
|
9
|
+
color?: PittoricaColor;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface CheckboxGroupItemProps extends Omit<CheckboxProps, 'value'> {
|
|
13
|
+
value: string;
|
|
14
|
+
}
|
|
15
|
+
export declare const CheckboxGroup: (({ value: controlledValue, defaultValue, onValueChange, orientation, color, disabled, children, className, ...props }: CheckboxGroupRootProps) => import("react/jsx-runtime").JSX.Element) & {
|
|
16
|
+
Item: ({ value, ...props }: CheckboxGroupItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=CheckboxGroup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CheckboxGroup.d.ts","sourceRoot":"","sources":["../src/CheckboxGroup.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAO,KAAK,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAY,KAAK,aAAa,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAa5D,MAAM,WAAW,sBAAuB,SAAQ,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC;IACxE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAC1C,WAAW,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;IACxC,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAiDD,MAAM,WAAW,sBAAuB,SAAQ,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC;IAC1E,KAAK,EAAE,MAAM,CAAC;CACf;AAsBD,eAAO,MAAM,aAAa,0HA7DvB,sBAAsB;gCAyCuB,sBAAsB;CAsBpE,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { CheckboxGroup } from './CheckboxGroup';
|
|
3
|
+
declare const meta: Meta<typeof CheckboxGroup>;
|
|
4
|
+
export default meta;
|
|
5
|
+
export declare const Vertical: StoryObj<typeof CheckboxGroup>;
|
|
6
|
+
export declare const Horizontal: StoryObj<typeof CheckboxGroup>;
|
|
7
|
+
//# sourceMappingURL=CheckboxGroup.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CheckboxGroup.stories.d.ts","sourceRoot":"","sources":["../src/CheckboxGroup.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,aAAa,CAIpC,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,OAAO,aAAa,CAQnD,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,OAAO,aAAa,CASrD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CheckboxGroup.test.d.ts","sourceRoot":"","sources":["../src/CheckboxGroup.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,EACV,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
import { jsx as y, jsxs as M } from "react/jsx-runtime";
|
|
2
|
+
import D, { forwardRef as H, createElement as F, createContext as J, useState as K, use as P } from "react";
|
|
3
|
+
function R(r) {
|
|
4
|
+
var i, e, t = "";
|
|
5
|
+
if (typeof r == "string" || typeof r == "number") t += r;
|
|
6
|
+
else if (typeof r == "object") if (Array.isArray(r)) {
|
|
7
|
+
var o = r.length;
|
|
8
|
+
for (i = 0; i < o; i++) r[i] && (e = R(r[i])) && (t && (t += " "), t += e);
|
|
9
|
+
} else for (e in r) r[e] && (t && (t += " "), t += e);
|
|
10
|
+
return t;
|
|
11
|
+
}
|
|
12
|
+
function Q() {
|
|
13
|
+
for (var r, i, e = 0, t = "", o = arguments.length; e < o; e++) (r = arguments[e]) && (i = R(r)) && (t && (t += " "), t += i);
|
|
14
|
+
return t;
|
|
15
|
+
}
|
|
16
|
+
function z(r) {
|
|
17
|
+
var i, e, t = "";
|
|
18
|
+
if (typeof r == "string" || typeof r == "number") t += r;
|
|
19
|
+
else if (typeof r == "object") if (Array.isArray(r)) {
|
|
20
|
+
var o = r.length;
|
|
21
|
+
for (i = 0; i < o; i++) r[i] && (e = z(r[i])) && (t && (t += " "), t += e);
|
|
22
|
+
} else for (e in r) r[e] && (t && (t += " "), t += e);
|
|
23
|
+
return t;
|
|
24
|
+
}
|
|
25
|
+
function U() {
|
|
26
|
+
for (var r, i, e = 0, t = "", o = arguments.length; e < o; e++) (r = arguments[e]) && (i = z(r)) && (t && (t += " "), t += i);
|
|
27
|
+
return t;
|
|
28
|
+
}
|
|
29
|
+
const I = ({
|
|
30
|
+
ref: r,
|
|
31
|
+
as: i = "div",
|
|
32
|
+
children: e,
|
|
33
|
+
display: t,
|
|
34
|
+
m: o,
|
|
35
|
+
mt: c,
|
|
36
|
+
mr: s,
|
|
37
|
+
mb: f,
|
|
38
|
+
ml: h,
|
|
39
|
+
p: g,
|
|
40
|
+
pt: l,
|
|
41
|
+
pr: p,
|
|
42
|
+
pb: n,
|
|
43
|
+
pl: u,
|
|
44
|
+
width: d,
|
|
45
|
+
height: m,
|
|
46
|
+
position: v,
|
|
47
|
+
style: b,
|
|
48
|
+
className: $,
|
|
49
|
+
href: x,
|
|
50
|
+
target: k,
|
|
51
|
+
rel: w,
|
|
52
|
+
htmlFor: N,
|
|
53
|
+
type: C,
|
|
54
|
+
disabled: A,
|
|
55
|
+
...j
|
|
56
|
+
}) => {
|
|
57
|
+
const a = {};
|
|
58
|
+
t && (a.display = t), d && (a.width = d), m && (a.height = m), v && (a.position = v), o && (a.margin = `var(--pittorica-space-${o})`), c && (a.marginTop = `var(--pittorica-space-${c})`), s && (a.marginRight = `var(--pittorica-space-${s})`), f && (a.marginBottom = `var(--pittorica-space-${f})`), h && (a.marginLeft = `var(--pittorica-space-${h})`), g && (a.padding = `var(--pittorica-space-${g})`), l && (a.paddingTop = `var(--pittorica-space-${l})`), p && (a.paddingRight = `var(--pittorica-space-${p})`), n && (a.paddingBottom = `var(--pittorica-space-${n})`), u && (a.paddingLeft = `var(--pittorica-space-${u})`);
|
|
59
|
+
const B = {
|
|
60
|
+
...b,
|
|
61
|
+
...a
|
|
62
|
+
};
|
|
63
|
+
return /* @__PURE__ */ y(
|
|
64
|
+
i,
|
|
65
|
+
{
|
|
66
|
+
ref: r,
|
|
67
|
+
className: U("pittorica-box", $),
|
|
68
|
+
style: B,
|
|
69
|
+
href: x,
|
|
70
|
+
target: k,
|
|
71
|
+
rel: w,
|
|
72
|
+
htmlFor: N,
|
|
73
|
+
type: C,
|
|
74
|
+
disabled: A,
|
|
75
|
+
...j,
|
|
76
|
+
children: e
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
I.displayName = "Box";
|
|
81
|
+
function L(r) {
|
|
82
|
+
var i, e, t = "";
|
|
83
|
+
if (typeof r == "string" || typeof r == "number") t += r;
|
|
84
|
+
else if (typeof r == "object") if (Array.isArray(r)) {
|
|
85
|
+
var o = r.length;
|
|
86
|
+
for (i = 0; i < o; i++) r[i] && (e = L(r[i])) && (t && (t += " "), t += e);
|
|
87
|
+
} else for (e in r) r[e] && (t && (t += " "), t += e);
|
|
88
|
+
return t;
|
|
89
|
+
}
|
|
90
|
+
function Z() {
|
|
91
|
+
for (var r, i, e = 0, t = "", o = arguments.length; e < o; e++) (r = arguments[e]) && (i = L(r)) && (t && (t += " "), t += i);
|
|
92
|
+
return t;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* @license @tabler/icons-react v3.36.1 - MIT
|
|
96
|
+
*
|
|
97
|
+
* This source code is licensed under the MIT license.
|
|
98
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
99
|
+
*/
|
|
100
|
+
var _ = {
|
|
101
|
+
outline: {
|
|
102
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
103
|
+
width: 24,
|
|
104
|
+
height: 24,
|
|
105
|
+
viewBox: "0 0 24 24",
|
|
106
|
+
fill: "none",
|
|
107
|
+
stroke: "currentColor",
|
|
108
|
+
strokeWidth: 2,
|
|
109
|
+
strokeLinecap: "round",
|
|
110
|
+
strokeLinejoin: "round"
|
|
111
|
+
},
|
|
112
|
+
filled: {
|
|
113
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
114
|
+
width: 24,
|
|
115
|
+
height: 24,
|
|
116
|
+
viewBox: "0 0 24 24",
|
|
117
|
+
fill: "currentColor",
|
|
118
|
+
stroke: "none"
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* @license @tabler/icons-react v3.36.1 - MIT
|
|
123
|
+
*
|
|
124
|
+
* This source code is licensed under the MIT license.
|
|
125
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
126
|
+
*/
|
|
127
|
+
const T = (r, i, e, t) => {
|
|
128
|
+
const o = H(
|
|
129
|
+
({ color: c = "currentColor", size: s = 24, stroke: f = 2, title: h, className: g, children: l, ...p }, n) => F(
|
|
130
|
+
"svg",
|
|
131
|
+
{
|
|
132
|
+
ref: n,
|
|
133
|
+
..._[r],
|
|
134
|
+
width: s,
|
|
135
|
+
height: s,
|
|
136
|
+
className: ["tabler-icon", `tabler-icon-${i}`, g].join(" "),
|
|
137
|
+
...r === "filled" ? {
|
|
138
|
+
fill: c
|
|
139
|
+
} : {
|
|
140
|
+
strokeWidth: f,
|
|
141
|
+
stroke: c
|
|
142
|
+
},
|
|
143
|
+
...p
|
|
144
|
+
},
|
|
145
|
+
[
|
|
146
|
+
h && F("title", { key: "svg-title" }, h),
|
|
147
|
+
...t.map(([u, d]) => F(u, d)),
|
|
148
|
+
...Array.isArray(l) ? l : [l]
|
|
149
|
+
]
|
|
150
|
+
)
|
|
151
|
+
);
|
|
152
|
+
return o.displayName = `${e}`, o;
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* @license @tabler/icons-react v3.36.1 - MIT
|
|
156
|
+
*
|
|
157
|
+
* This source code is licensed under the MIT license.
|
|
158
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
159
|
+
*/
|
|
160
|
+
const X = [["path", { d: "M3 5a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14", key: "svg-0" }]], Y = T("outline", "square", "Square", X);
|
|
161
|
+
/**
|
|
162
|
+
* @license @tabler/icons-react v3.36.1 - MIT
|
|
163
|
+
*
|
|
164
|
+
* This source code is licensed under the MIT license.
|
|
165
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
166
|
+
*/
|
|
167
|
+
const V = [["path", { d: "M18.333 2c1.96 0 3.56 1.537 3.662 3.472l.005 .195v12.666c0 1.96 -1.537 3.56 -3.472 3.662l-.195 .005h-12.666a3.667 3.667 0 0 1 -3.662 -3.472l-.005 -.195v-12.666c0 -1.96 1.537 -3.56 3.472 -3.662l.195 -.005h12.666zm-2.626 7.293a1 1 0 0 0 -1.414 0l-3.293 3.292l-1.293 -1.292l-.094 -.083a1 1 0 0 0 -1.32 1.497l2 2l.094 .083a1 1 0 0 0 1.32 -.083l4 -4l.083 -.094a1 1 0 0 0 -.083 -1.32z", key: "svg-0" }]], tt = T("filled", "square-check-filled", "SquareCheckFilled", V);
|
|
168
|
+
function q(r) {
|
|
169
|
+
var i, e, t = "";
|
|
170
|
+
if (typeof r == "string" || typeof r == "number") t += r;
|
|
171
|
+
else if (typeof r == "object") if (Array.isArray(r)) {
|
|
172
|
+
var o = r.length;
|
|
173
|
+
for (i = 0; i < o; i++) r[i] && (e = q(r[i])) && (t && (t += " "), t += e);
|
|
174
|
+
} else for (e in r) r[e] && (t && (t += " "), t += e);
|
|
175
|
+
return t;
|
|
176
|
+
}
|
|
177
|
+
function rt() {
|
|
178
|
+
for (var r, i, e = 0, t = "", o = arguments.length; e < o; e++) (r = arguments[e]) && (i = q(r)) && (t && (t += " "), t += i);
|
|
179
|
+
return t;
|
|
180
|
+
}
|
|
181
|
+
const G = ({
|
|
182
|
+
ref: r,
|
|
183
|
+
as: i = "div",
|
|
184
|
+
children: e,
|
|
185
|
+
display: t,
|
|
186
|
+
m: o,
|
|
187
|
+
mt: c,
|
|
188
|
+
mr: s,
|
|
189
|
+
mb: f,
|
|
190
|
+
ml: h,
|
|
191
|
+
p: g,
|
|
192
|
+
pt: l,
|
|
193
|
+
pr: p,
|
|
194
|
+
pb: n,
|
|
195
|
+
pl: u,
|
|
196
|
+
width: d,
|
|
197
|
+
height: m,
|
|
198
|
+
position: v,
|
|
199
|
+
style: b,
|
|
200
|
+
className: $,
|
|
201
|
+
href: x,
|
|
202
|
+
target: k,
|
|
203
|
+
rel: w,
|
|
204
|
+
htmlFor: N,
|
|
205
|
+
type: C,
|
|
206
|
+
disabled: A,
|
|
207
|
+
...j
|
|
208
|
+
}) => {
|
|
209
|
+
const a = {};
|
|
210
|
+
t && (a.display = t), d && (a.width = d), m && (a.height = m), v && (a.position = v), o && (a.margin = `var(--pittorica-space-${o})`), c && (a.marginTop = `var(--pittorica-space-${c})`), s && (a.marginRight = `var(--pittorica-space-${s})`), f && (a.marginBottom = `var(--pittorica-space-${f})`), h && (a.marginLeft = `var(--pittorica-space-${h})`), g && (a.padding = `var(--pittorica-space-${g})`), l && (a.paddingTop = `var(--pittorica-space-${l})`), p && (a.paddingRight = `var(--pittorica-space-${p})`), n && (a.paddingBottom = `var(--pittorica-space-${n})`), u && (a.paddingLeft = `var(--pittorica-space-${u})`);
|
|
211
|
+
const B = {
|
|
212
|
+
...b,
|
|
213
|
+
...a
|
|
214
|
+
};
|
|
215
|
+
return /* @__PURE__ */ y(
|
|
216
|
+
i,
|
|
217
|
+
{
|
|
218
|
+
ref: r,
|
|
219
|
+
className: rt("pittorica-box", $),
|
|
220
|
+
style: B,
|
|
221
|
+
href: x,
|
|
222
|
+
target: k,
|
|
223
|
+
rel: w,
|
|
224
|
+
htmlFor: N,
|
|
225
|
+
type: C,
|
|
226
|
+
disabled: A,
|
|
227
|
+
...j,
|
|
228
|
+
children: e
|
|
229
|
+
}
|
|
230
|
+
);
|
|
231
|
+
};
|
|
232
|
+
G.displayName = "Box";
|
|
233
|
+
function W(r) {
|
|
234
|
+
var i, e, t = "";
|
|
235
|
+
if (typeof r == "string" || typeof r == "number") t += r;
|
|
236
|
+
else if (typeof r == "object") if (Array.isArray(r)) {
|
|
237
|
+
var o = r.length;
|
|
238
|
+
for (i = 0; i < o; i++) r[i] && (e = W(r[i])) && (t && (t += " "), t += e);
|
|
239
|
+
} else for (e in r) r[e] && (t && (t += " "), t += e);
|
|
240
|
+
return t;
|
|
241
|
+
}
|
|
242
|
+
function et() {
|
|
243
|
+
for (var r, i, e = 0, t = "", o = arguments.length; e < o; e++) (r = arguments[e]) && (i = W(r)) && (t && (t += " "), t += i);
|
|
244
|
+
return t;
|
|
245
|
+
}
|
|
246
|
+
function S(r) {
|
|
247
|
+
var i, e, t = "";
|
|
248
|
+
if (typeof r == "string" || typeof r == "number") t += r;
|
|
249
|
+
else if (typeof r == "object") if (Array.isArray(r)) {
|
|
250
|
+
var o = r.length;
|
|
251
|
+
for (i = 0; i < o; i++) r[i] && (e = S(r[i])) && (t && (t += " "), t += e);
|
|
252
|
+
} else for (e in r) r[e] && (t && (t += " "), t += e);
|
|
253
|
+
return t;
|
|
254
|
+
}
|
|
255
|
+
function it() {
|
|
256
|
+
for (var r, i, e = 0, t = "", o = arguments.length; e < o; e++) (r = arguments[e]) && (i = S(r)) && (t && (t += " "), t += i);
|
|
257
|
+
return t;
|
|
258
|
+
}
|
|
259
|
+
const E = ({
|
|
260
|
+
ref: r,
|
|
261
|
+
as: i = "div",
|
|
262
|
+
children: e,
|
|
263
|
+
display: t,
|
|
264
|
+
m: o,
|
|
265
|
+
mt: c,
|
|
266
|
+
mr: s,
|
|
267
|
+
mb: f,
|
|
268
|
+
ml: h,
|
|
269
|
+
p: g,
|
|
270
|
+
pt: l,
|
|
271
|
+
pr: p,
|
|
272
|
+
pb: n,
|
|
273
|
+
pl: u,
|
|
274
|
+
width: d,
|
|
275
|
+
height: m,
|
|
276
|
+
position: v,
|
|
277
|
+
style: b,
|
|
278
|
+
className: $,
|
|
279
|
+
href: x,
|
|
280
|
+
target: k,
|
|
281
|
+
rel: w,
|
|
282
|
+
htmlFor: N,
|
|
283
|
+
type: C,
|
|
284
|
+
disabled: A,
|
|
285
|
+
...j
|
|
286
|
+
}) => {
|
|
287
|
+
const a = {};
|
|
288
|
+
t && (a.display = t), d && (a.width = d), m && (a.height = m), v && (a.position = v), o && (a.margin = `var(--pittorica-space-${o})`), c && (a.marginTop = `var(--pittorica-space-${c})`), s && (a.marginRight = `var(--pittorica-space-${s})`), f && (a.marginBottom = `var(--pittorica-space-${f})`), h && (a.marginLeft = `var(--pittorica-space-${h})`), g && (a.padding = `var(--pittorica-space-${g})`), l && (a.paddingTop = `var(--pittorica-space-${l})`), p && (a.paddingRight = `var(--pittorica-space-${p})`), n && (a.paddingBottom = `var(--pittorica-space-${n})`), u && (a.paddingLeft = `var(--pittorica-space-${u})`);
|
|
289
|
+
const B = {
|
|
290
|
+
...b,
|
|
291
|
+
...a
|
|
292
|
+
};
|
|
293
|
+
return /* @__PURE__ */ y(
|
|
294
|
+
i,
|
|
295
|
+
{
|
|
296
|
+
ref: r,
|
|
297
|
+
className: it("pittorica-box", $),
|
|
298
|
+
style: B,
|
|
299
|
+
href: x,
|
|
300
|
+
target: k,
|
|
301
|
+
rel: w,
|
|
302
|
+
htmlFor: N,
|
|
303
|
+
type: C,
|
|
304
|
+
disabled: A,
|
|
305
|
+
...j,
|
|
306
|
+
children: e
|
|
307
|
+
}
|
|
308
|
+
);
|
|
309
|
+
};
|
|
310
|
+
E.displayName = "Box";
|
|
311
|
+
const at = (r, i) => i ? typeof i == "string" ? [`pittorica-text--${r}-${i}`] : Object.entries(i).filter(([e, t]) => t !== void 0).map(
|
|
312
|
+
([e, t]) => e === "initial" ? `pittorica-text--${r}-${t}` : `pittorica-text--${e}-${r}-${t}`
|
|
313
|
+
) : [], ot = ({
|
|
314
|
+
children: r,
|
|
315
|
+
as: i = "span",
|
|
316
|
+
size: e = "3",
|
|
317
|
+
weight: t = "regular",
|
|
318
|
+
align: o,
|
|
319
|
+
truncate: c = !1,
|
|
320
|
+
color: s,
|
|
321
|
+
className: f,
|
|
322
|
+
style: h,
|
|
323
|
+
href: g,
|
|
324
|
+
target: l,
|
|
325
|
+
rel: p,
|
|
326
|
+
htmlFor: n,
|
|
327
|
+
...u
|
|
328
|
+
}) => {
|
|
329
|
+
const d = (s == null ? void 0 : s.startsWith("#")) || (s == null ? void 0 : s.startsWith("rgb")), m = [
|
|
330
|
+
"danger",
|
|
331
|
+
"success",
|
|
332
|
+
"error",
|
|
333
|
+
"info",
|
|
334
|
+
"indigo",
|
|
335
|
+
"crimson",
|
|
336
|
+
"teal",
|
|
337
|
+
"amber",
|
|
338
|
+
"slate",
|
|
339
|
+
"blue",
|
|
340
|
+
"red"
|
|
341
|
+
].includes(s), v = (() => {
|
|
342
|
+
if (s) {
|
|
343
|
+
if (s === "inherit") return "inherit";
|
|
344
|
+
if (d) return s;
|
|
345
|
+
if (m) return `var(--pittorica-${s}-9)`;
|
|
346
|
+
}
|
|
347
|
+
})(), b = {
|
|
348
|
+
...h,
|
|
349
|
+
textAlign: o,
|
|
350
|
+
color: v
|
|
351
|
+
}, $ = at("size", e);
|
|
352
|
+
return /* @__PURE__ */ y(
|
|
353
|
+
E,
|
|
354
|
+
{
|
|
355
|
+
as: i,
|
|
356
|
+
className: et(
|
|
357
|
+
"pittorica-text",
|
|
358
|
+
{ "pittorica-text--truncate": c },
|
|
359
|
+
$,
|
|
360
|
+
f
|
|
361
|
+
),
|
|
362
|
+
"data-weight": t,
|
|
363
|
+
style: b,
|
|
364
|
+
href: g,
|
|
365
|
+
target: l,
|
|
366
|
+
rel: p,
|
|
367
|
+
htmlFor: n,
|
|
368
|
+
...u,
|
|
369
|
+
children: r
|
|
370
|
+
}
|
|
371
|
+
);
|
|
372
|
+
}, st = ({
|
|
373
|
+
checked: r,
|
|
374
|
+
defaultChecked: i,
|
|
375
|
+
onChange: e,
|
|
376
|
+
color: t = "indigo",
|
|
377
|
+
disabled: o = !1,
|
|
378
|
+
label: c,
|
|
379
|
+
className: s,
|
|
380
|
+
style: f,
|
|
381
|
+
...h
|
|
382
|
+
}) => {
|
|
383
|
+
const [g, l] = D.useState(
|
|
384
|
+
i ?? !1
|
|
385
|
+
), p = r === void 0 ? g : r, n = t !== "inherit" && !(t != null && t.startsWith("#")) && !(t != null && t.startsWith("rgb")) ? `var(--pittorica-${t}-9)` : t, u = (d) => {
|
|
386
|
+
if (o) return;
|
|
387
|
+
const m = d.target.checked;
|
|
388
|
+
l(m), e == null || e(m);
|
|
389
|
+
};
|
|
390
|
+
return /* @__PURE__ */ M(
|
|
391
|
+
G,
|
|
392
|
+
{
|
|
393
|
+
as: "label",
|
|
394
|
+
className: Z("pittorica-checkbox-root", s),
|
|
395
|
+
"data-disabled": o,
|
|
396
|
+
style: { "--_checkbox-color": n, ...f },
|
|
397
|
+
children: [
|
|
398
|
+
/* @__PURE__ */ y(
|
|
399
|
+
"input",
|
|
400
|
+
{
|
|
401
|
+
type: "checkbox",
|
|
402
|
+
className: "pittorica-checkbox-input",
|
|
403
|
+
checked: p,
|
|
404
|
+
disabled: o,
|
|
405
|
+
onChange: u,
|
|
406
|
+
...h
|
|
407
|
+
}
|
|
408
|
+
),
|
|
409
|
+
/* @__PURE__ */ y("div", { className: "pittorica-checkbox-control", children: p ? /* @__PURE__ */ y(tt, { size: 20 }) : /* @__PURE__ */ y(Y, { size: 20, stroke: 1.5 }) }),
|
|
410
|
+
c && /* @__PURE__ */ y(ot, { size: "2", weight: "medium", style: { color: "inherit" }, children: c })
|
|
411
|
+
]
|
|
412
|
+
}
|
|
413
|
+
);
|
|
414
|
+
}, O = J(
|
|
415
|
+
null
|
|
416
|
+
), nt = ({
|
|
417
|
+
value: r,
|
|
418
|
+
defaultValue: i = [],
|
|
419
|
+
onValueChange: e,
|
|
420
|
+
orientation: t = "vertical",
|
|
421
|
+
color: o,
|
|
422
|
+
disabled: c,
|
|
423
|
+
children: s,
|
|
424
|
+
className: f,
|
|
425
|
+
...h
|
|
426
|
+
}) => {
|
|
427
|
+
const [g, l] = K(i), p = r !== void 0, n = p ? r : g;
|
|
428
|
+
return /* @__PURE__ */ y(
|
|
429
|
+
O,
|
|
430
|
+
{
|
|
431
|
+
value: {
|
|
432
|
+
value: n,
|
|
433
|
+
onItemChange: (d) => {
|
|
434
|
+
const m = n.includes(d) ? n.filter((v) => v !== d) : [...n, d];
|
|
435
|
+
p || l(m), e == null || e(m);
|
|
436
|
+
},
|
|
437
|
+
color: o,
|
|
438
|
+
disabled: c
|
|
439
|
+
},
|
|
440
|
+
children: /* @__PURE__ */ y(
|
|
441
|
+
I,
|
|
442
|
+
{
|
|
443
|
+
className: Q("pittorica-checkbox-group-root", f),
|
|
444
|
+
"data-orientation": t,
|
|
445
|
+
role: "group",
|
|
446
|
+
...h,
|
|
447
|
+
children: s
|
|
448
|
+
}
|
|
449
|
+
)
|
|
450
|
+
}
|
|
451
|
+
);
|
|
452
|
+
}, ct = ({ value: r, ...i }) => {
|
|
453
|
+
const e = P(O);
|
|
454
|
+
if (!e)
|
|
455
|
+
throw new Error(
|
|
456
|
+
"CheckboxGroup.Item must be used within CheckboxGroup.Root"
|
|
457
|
+
);
|
|
458
|
+
return /* @__PURE__ */ y(
|
|
459
|
+
st,
|
|
460
|
+
{
|
|
461
|
+
...i,
|
|
462
|
+
checked: e.value.includes(r),
|
|
463
|
+
onChange: () => e.onItemChange(r),
|
|
464
|
+
color: i.color || e.color,
|
|
465
|
+
disabled: i.disabled || e.disabled
|
|
466
|
+
}
|
|
467
|
+
);
|
|
468
|
+
}, dt = Object.assign(nt, {
|
|
469
|
+
Item: ct
|
|
470
|
+
});
|
|
471
|
+
export {
|
|
472
|
+
dt as CheckboxGroup
|
|
473
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pittorica/checkbox-group-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
|
+
"clsx": "^2.1.1",
|
|
13
|
+
"@pittorica/box-react": "0.22.0",
|
|
14
|
+
"@pittorica/text-react": "0.22.0",
|
|
15
|
+
"@pittorica/checkbox-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": "0.22.0",
|
|
28
|
+
"@pittorica/theme-react": "0.22.0"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"react": ">=19",
|
|
32
|
+
"react-dom": ">=19"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "npm run clean && npm run build:js && npm run build:types",
|
|
36
|
+
"build:js": "vite build",
|
|
37
|
+
"build:types": "tsc -p tsconfig.json",
|
|
38
|
+
"clean": "rm -rf dist",
|
|
39
|
+
"dev": "vite",
|
|
40
|
+
"test": "vitest run",
|
|
41
|
+
"test:watch": "vitest"
|
|
42
|
+
}
|
|
43
|
+
}
|