@vygruppen/spor-react 12.2.0 → 12.2.1
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/.turbo/turbo-build.log +31 -12
- package/.turbo/turbo-typegen.log +19 -1
- package/CHANGELOG.md +8 -0
- package/dist/index.d.mts +43 -94
- package/dist/index.d.ts +43 -94
- package/dist/index.js +346 -337
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +233 -224
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
- package/src/input/ChoiceChip.tsx +39 -66
- package/src/theme/slot-recipes/anatomy.ts +10 -0
- package/src/theme/slot-recipes/choice-chip.ts +183 -0
- package/src/theme/slot-recipes/index.ts +2 -0
- package/src/theme/recipes/choice-chip.ts +0 -144
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vygruppen/spor-react",
|
3
|
-
"version": "12.2.
|
3
|
+
"version": "12.2.1",
|
4
4
|
"main": "./dist/index.js",
|
5
5
|
"module": "./dist/index.mjs",
|
6
6
|
"types": "./dist/index.d.ts",
|
@@ -36,8 +36,8 @@
|
|
36
36
|
"react-swipeable": "^7.0.1",
|
37
37
|
"usehooks-ts": "^3.1.0",
|
38
38
|
"@vygruppen/spor-design-tokens": "4.0.5",
|
39
|
-
"@vygruppen/spor-
|
40
|
-
"@vygruppen/spor-
|
39
|
+
"@vygruppen/spor-loader": "0.6.0",
|
40
|
+
"@vygruppen/spor-icon-react": "4.0.4"
|
41
41
|
},
|
42
42
|
"devDependencies": {
|
43
43
|
"@chakra-ui/cli": "^3.8.0",
|
@@ -56,8 +56,8 @@
|
|
56
56
|
"vitest": "^0.26.3",
|
57
57
|
"vitest-axe": "^0.1.0",
|
58
58
|
"vitest-canvas-mock": "^0.2.2",
|
59
|
-
"@vygruppen/
|
60
|
-
"@vygruppen/
|
59
|
+
"@vygruppen/eslint-config": "1.0.1",
|
60
|
+
"@vygruppen/tsconfig": "0.1.0"
|
61
61
|
},
|
62
62
|
"peerDependencies": {
|
63
63
|
"react": ">=18.0.0 <19.0.0",
|
package/src/input/ChoiceChip.tsx
CHANGED
@@ -1,30 +1,15 @@
|
|
1
1
|
"use client";
|
2
|
-
import {
|
3
|
-
chakra,
|
4
|
-
RecipeVariantProps,
|
5
|
-
Span,
|
6
|
-
useCheckbox,
|
7
|
-
} from "@chakra-ui/react";
|
2
|
+
import { CheckboxCard, CheckboxCardRootProps, Span } from "@chakra-ui/react";
|
8
3
|
import { CloseOutline24Icon } from "@vygruppen/spor-icon-react";
|
9
|
-
import React, {
|
4
|
+
import React, { forwardRef } from "react";
|
10
5
|
|
11
|
-
|
12
|
-
|
13
|
-
|
6
|
+
type CheckBoxIcon = {
|
7
|
+
default: React.ReactNode;
|
8
|
+
checked: React.ReactNode;
|
9
|
+
};
|
14
10
|
|
15
|
-
export type ChoiceChipProps =
|
16
|
-
|
17
|
-
checked?: boolean;
|
18
|
-
disabled?: boolean;
|
19
|
-
defaultChecked?: boolean;
|
20
|
-
/** The button text */
|
21
|
-
children: React.ReactNode;
|
22
|
-
icon?: {
|
23
|
-
default: React.ReactNode;
|
24
|
-
checked: React.ReactNode;
|
25
|
-
};
|
26
|
-
chipType?: "icon" | "choice" | "filter";
|
27
|
-
"aria-label"?: string;
|
11
|
+
export type ChoiceChipProps = CheckboxCardRootProps & {
|
12
|
+
icon?: CheckBoxIcon;
|
28
13
|
};
|
29
14
|
|
30
15
|
/**
|
@@ -59,49 +44,37 @@ export type ChoiceChipProps = PropsWithChildren<ChoiceChipVariantProps> & {
|
|
59
44
|
* ```
|
60
45
|
*/
|
61
46
|
|
62
|
-
const
|
47
|
+
export const ChoiceChip = forwardRef<HTMLInputElement, ChoiceChipProps>(
|
48
|
+
({ children, icon, ...rootProps }, ref) => {
|
49
|
+
return (
|
50
|
+
<CheckboxCard.Root {...rootProps}>
|
51
|
+
<CheckboxCard.Context>
|
52
|
+
{({ checked }) => (
|
53
|
+
<>
|
54
|
+
<CheckboxCard.HiddenInput ref={ref} />
|
55
|
+
<CheckboxCard.Control>
|
56
|
+
<CheckboxCard.Content>
|
57
|
+
<CheckboxCard.Label>
|
58
|
+
{icon && (
|
59
|
+
<Span width="24px">
|
60
|
+
{checked ? icon.checked : icon.default}
|
61
|
+
</Span>
|
62
|
+
)}
|
63
63
|
|
64
|
-
|
65
|
-
children,
|
66
|
-
icon,
|
67
|
-
size = "sm",
|
68
|
-
chipType = "choice",
|
69
|
-
variant = "core",
|
70
|
-
...props
|
71
|
-
}: ChoiceChipProps) => {
|
72
|
-
const {
|
73
|
-
getControlProps,
|
74
|
-
disabled,
|
75
|
-
getLabelProps,
|
76
|
-
getHiddenInputProps,
|
77
|
-
setChecked,
|
78
|
-
checked,
|
79
|
-
} = useCheckbox(props);
|
64
|
+
{rootProps.chipType !== "icon" && children}
|
80
65
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
setChecked(!checked);
|
95
|
-
}}
|
96
|
-
/>
|
97
|
-
<ChoiceChipStyledDiv {...getControlProps()} size={size} variant={variant}>
|
98
|
-
{icon && <Span>{checked ? icon.checked : icon.default}</Span>}
|
99
|
-
{chipType !== "icon" && <Span>{children}</Span>}
|
66
|
+
{rootProps.chipType === "filter" && checked && (
|
67
|
+
<CloseOutline24Icon />
|
68
|
+
)}
|
69
|
+
</CheckboxCard.Label>
|
70
|
+
</CheckboxCard.Content>
|
71
|
+
</CheckboxCard.Control>
|
72
|
+
</>
|
73
|
+
)}
|
74
|
+
</CheckboxCard.Context>
|
75
|
+
</CheckboxCard.Root>
|
76
|
+
);
|
77
|
+
},
|
78
|
+
);
|
100
79
|
|
101
|
-
|
102
|
-
<CloseOutline24Icon marginLeft={1.5} />
|
103
|
-
)}
|
104
|
-
</ChoiceChipStyledDiv>
|
105
|
-
</chakra.label>
|
106
|
-
);
|
107
|
-
};
|
80
|
+
ChoiceChip.displayName = "ChoiceChip";
|
@@ -267,3 +267,13 @@ export const datepickerAnatomy = createAnatomy("datepicker").parts(
|
|
267
267
|
"box",
|
268
268
|
"rangeCalendarPopover",
|
269
269
|
);
|
270
|
+
|
271
|
+
export const checkboxCardAnatomy = createAnatomy("checkbox-card", [
|
272
|
+
"root",
|
273
|
+
"control",
|
274
|
+
"label",
|
275
|
+
"description",
|
276
|
+
"addon",
|
277
|
+
"indicator",
|
278
|
+
"content",
|
279
|
+
]);
|
@@ -0,0 +1,183 @@
|
|
1
|
+
import { defineSlotRecipe } from "@chakra-ui/react";
|
2
|
+
|
3
|
+
import { checkboxCardAnatomy } from "./anatomy";
|
4
|
+
|
5
|
+
export const choiceChipSlotRecipe = defineSlotRecipe({
|
6
|
+
slots: checkboxCardAnatomy.keys(),
|
7
|
+
className: "chakra-checkbox-card",
|
8
|
+
base: {
|
9
|
+
root: {
|
10
|
+
display: "inline-flex",
|
11
|
+
alignItems: "center",
|
12
|
+
boxAlign: "center",
|
13
|
+
fontSize: "xs",
|
14
|
+
cursor: "pointer",
|
15
|
+
transitionProperty: "all",
|
16
|
+
borderRadius: "xl",
|
17
|
+
transitionDuration: "fast",
|
18
|
+
paddingInlineStart: "2",
|
19
|
+
paddingInlineEnd: "2",
|
20
|
+
|
21
|
+
outline: "1px solid",
|
22
|
+
outlineColor: "base.outline",
|
23
|
+
_checked: {
|
24
|
+
backgroundColor: "brand.surface",
|
25
|
+
borderRadius: "sm",
|
26
|
+
outline: "none",
|
27
|
+
color: "brand.text",
|
28
|
+
_hover: {
|
29
|
+
backgroundColor: "brand.surface.hover",
|
30
|
+
_active: {
|
31
|
+
backgroundColor: "brand.surface.active",
|
32
|
+
},
|
33
|
+
},
|
34
|
+
},
|
35
|
+
|
36
|
+
_focusVisible: {
|
37
|
+
outline: "2px solid",
|
38
|
+
outlineColor: "outline.focus",
|
39
|
+
outlineOffset: "1px",
|
40
|
+
},
|
41
|
+
|
42
|
+
_disabled: {
|
43
|
+
pointerEvents: "none",
|
44
|
+
boxShadow: "none",
|
45
|
+
backgroundColor: "surface.disabled",
|
46
|
+
color: "text.disabled",
|
47
|
+
outline: "none",
|
48
|
+
|
49
|
+
_hover: {
|
50
|
+
backgroundColor: "core.surface.disabled",
|
51
|
+
boxShadow: "none",
|
52
|
+
color: "core.text.disabled",
|
53
|
+
},
|
54
|
+
_checked: {
|
55
|
+
cursor: "not-allowed",
|
56
|
+
boxShadow: "none",
|
57
|
+
color: "core.text.disabled",
|
58
|
+
backgroundColor: "core.surface.disabled",
|
59
|
+
_hover: {
|
60
|
+
backgroundColor: "core.surface.disabled",
|
61
|
+
boxShadow: "none",
|
62
|
+
color: "core.text.disabled",
|
63
|
+
},
|
64
|
+
},
|
65
|
+
},
|
66
|
+
},
|
67
|
+
|
68
|
+
label: {
|
69
|
+
display: "flex",
|
70
|
+
alignItems: "center",
|
71
|
+
|
72
|
+
fontSize: "xs",
|
73
|
+
},
|
74
|
+
},
|
75
|
+
|
76
|
+
variants: {
|
77
|
+
size: {
|
78
|
+
xs: {
|
79
|
+
root: {
|
80
|
+
_checked: {
|
81
|
+
borderRadius: "0.563rem",
|
82
|
+
},
|
83
|
+
height: 5,
|
84
|
+
paddingX: 1.5,
|
85
|
+
},
|
86
|
+
},
|
87
|
+
sm: {
|
88
|
+
root: {
|
89
|
+
_checked: {
|
90
|
+
borderRadius: "sm",
|
91
|
+
},
|
92
|
+
height: 6,
|
93
|
+
paddingX: 2,
|
94
|
+
},
|
95
|
+
},
|
96
|
+
md: {
|
97
|
+
root: {
|
98
|
+
_checked: {
|
99
|
+
borderRadius: "sm",
|
100
|
+
},
|
101
|
+
height: 7,
|
102
|
+
paddingX: 2,
|
103
|
+
},
|
104
|
+
},
|
105
|
+
lg: {
|
106
|
+
root: {
|
107
|
+
_checked: {
|
108
|
+
borderRadius: "md",
|
109
|
+
},
|
110
|
+
height: 8,
|
111
|
+
paddingX: 3,
|
112
|
+
},
|
113
|
+
},
|
114
|
+
},
|
115
|
+
|
116
|
+
variant: {
|
117
|
+
core: {
|
118
|
+
root: {
|
119
|
+
color: "core.text",
|
120
|
+
outlineColor: "core.outline",
|
121
|
+
|
122
|
+
_hover: {
|
123
|
+
outline: "2px solid",
|
124
|
+
outlineColor: "core.outline.hover",
|
125
|
+
|
126
|
+
_active: {
|
127
|
+
outline: "1px solid",
|
128
|
+
outlineColor: "core.outline",
|
129
|
+
backgroundColor: "core.surface.active",
|
130
|
+
},
|
131
|
+
},
|
132
|
+
},
|
133
|
+
},
|
134
|
+
accent: {
|
135
|
+
root: {
|
136
|
+
backgroundColor: "accent.surface",
|
137
|
+
color: "accent.text",
|
138
|
+
outline: "none",
|
139
|
+
|
140
|
+
_hover: {
|
141
|
+
backgroundColor: "accent.surface.hover",
|
142
|
+
|
143
|
+
_active: {
|
144
|
+
backgroundColor: "accent.surface.active",
|
145
|
+
},
|
146
|
+
},
|
147
|
+
},
|
148
|
+
},
|
149
|
+
floating: {
|
150
|
+
root: {
|
151
|
+
backgroundColor: "floating.surface",
|
152
|
+
outline: "1px solid",
|
153
|
+
outlineColor: "floating.outline",
|
154
|
+
color: "floating.text",
|
155
|
+
|
156
|
+
boxShadow: "sm",
|
157
|
+
_hover: {
|
158
|
+
backgroundColor: "floating.surface.hover",
|
159
|
+
outline: "1px solid",
|
160
|
+
outlineColor: "floating.outline.hover",
|
161
|
+
|
162
|
+
_active: {
|
163
|
+
backgroundColor: "floating.surface.active",
|
164
|
+
outline: "1px solid",
|
165
|
+
outlineColor: "floating.outline",
|
166
|
+
},
|
167
|
+
},
|
168
|
+
},
|
169
|
+
},
|
170
|
+
},
|
171
|
+
chipType: {
|
172
|
+
icon: {},
|
173
|
+
choice: {},
|
174
|
+
filter: {},
|
175
|
+
},
|
176
|
+
},
|
177
|
+
|
178
|
+
defaultVariants: {
|
179
|
+
size: "md",
|
180
|
+
variant: "core",
|
181
|
+
chipType: "choice",
|
182
|
+
},
|
183
|
+
});
|
@@ -4,6 +4,7 @@ import { alertExpandableSlotRecipe } from "./alert-expandable";
|
|
4
4
|
import { alertServiceSlotRecipe } from "./alert-service";
|
5
5
|
import { breadcrumbSlotRecipe } from "./breadcrumb";
|
6
6
|
import { checkboxSlotRecipe } from "./checkbox";
|
7
|
+
import { choiceChipSlotRecipe } from "./choice-chip";
|
7
8
|
import { datePickerSlotRecipe } from "./datepicker";
|
8
9
|
import { dialogSlotRecipe } from "./dialog";
|
9
10
|
import { drawerSlotRecipe } from "./drawer";
|
@@ -62,4 +63,5 @@ export const slotRecipes = {
|
|
62
63
|
tabs: tabsSlotRecipe,
|
63
64
|
travelTag: travelTagSlotRecipe,
|
64
65
|
toast: toastSlotRecipe,
|
66
|
+
checkboxCard: choiceChipSlotRecipe,
|
65
67
|
};
|
@@ -1,144 +0,0 @@
|
|
1
|
-
import { defineRecipe } from "@chakra-ui/react";
|
2
|
-
|
3
|
-
export const choiceChipRecipe = defineRecipe({
|
4
|
-
base: {
|
5
|
-
display: "inline-flex",
|
6
|
-
alignItems: "center",
|
7
|
-
boxAlign: "center",
|
8
|
-
fontSize: "xs",
|
9
|
-
cursor: "pointer",
|
10
|
-
transitionProperty: "all",
|
11
|
-
borderRadius: "xl",
|
12
|
-
transitionDuration: "fast",
|
13
|
-
height: 6,
|
14
|
-
paddingInlineStart: "2",
|
15
|
-
paddingInlineEnd: "2",
|
16
|
-
|
17
|
-
outline: "1px solid",
|
18
|
-
outlineColor: "base.outline",
|
19
|
-
_checked: {
|
20
|
-
backgroundColor: "brand.surface",
|
21
|
-
borderRadius: "sm",
|
22
|
-
outline: "none",
|
23
|
-
color: "brand.text",
|
24
|
-
_hover: {
|
25
|
-
backgroundColor: "brand.surface.hover",
|
26
|
-
_active: {
|
27
|
-
backgroundColor: "brand.surface.active",
|
28
|
-
},
|
29
|
-
},
|
30
|
-
},
|
31
|
-
|
32
|
-
_focusVisible: {
|
33
|
-
outline: "2px solid",
|
34
|
-
outlineColor: "outline.focus",
|
35
|
-
outlineOffset: "1px",
|
36
|
-
},
|
37
|
-
|
38
|
-
_disabled: {
|
39
|
-
pointerEvents: "none",
|
40
|
-
boxShadow: "none",
|
41
|
-
backgroundColor: "surface.disabled",
|
42
|
-
color: "text.disabled",
|
43
|
-
outline: "none",
|
44
|
-
|
45
|
-
_hover: {
|
46
|
-
backgroundColor: "core.surface.disabled",
|
47
|
-
boxShadow: "none",
|
48
|
-
color: "core.text.disabled",
|
49
|
-
},
|
50
|
-
_checked: {
|
51
|
-
cursor: "not-allowed",
|
52
|
-
boxShadow: "none",
|
53
|
-
color: "core.text.disabled",
|
54
|
-
backgroundColor: "core.surface.disabled",
|
55
|
-
_hover: {
|
56
|
-
backgroundColor: "core.surface.disabled",
|
57
|
-
boxShadow: "none",
|
58
|
-
color: "core.text.disabled",
|
59
|
-
},
|
60
|
-
},
|
61
|
-
},
|
62
|
-
},
|
63
|
-
variants: {
|
64
|
-
variant: {
|
65
|
-
core: {
|
66
|
-
color: "core.text",
|
67
|
-
outlineColor: "core.outline",
|
68
|
-
|
69
|
-
_hover: {
|
70
|
-
outline: "2px solid",
|
71
|
-
outlineColor: "core.outline.hover",
|
72
|
-
|
73
|
-
_active: {
|
74
|
-
outline: "1px solid",
|
75
|
-
outlineColor: "core.outline",
|
76
|
-
backgroundColor: "core.surface.active",
|
77
|
-
},
|
78
|
-
},
|
79
|
-
},
|
80
|
-
accent: {
|
81
|
-
backgroundColor: "accent.surface",
|
82
|
-
color: "accent.text",
|
83
|
-
outline: "none",
|
84
|
-
|
85
|
-
_hover: {
|
86
|
-
backgroundColor: "accent.surface.hover",
|
87
|
-
|
88
|
-
_active: {
|
89
|
-
backgroundColor: "accent.surface.active",
|
90
|
-
},
|
91
|
-
},
|
92
|
-
},
|
93
|
-
floating: {
|
94
|
-
backgroundColor: "floating.surface",
|
95
|
-
outline: "1px solid",
|
96
|
-
outlineColor: "floating.outline",
|
97
|
-
color: "floating.text",
|
98
|
-
|
99
|
-
boxShadow: "sm",
|
100
|
-
_hover: {
|
101
|
-
backgroundColor: "floating.surface.hover",
|
102
|
-
outline: "1px solid",
|
103
|
-
outlineColor: "floating.outline.hover",
|
104
|
-
|
105
|
-
_active: {
|
106
|
-
backgroundColor: "floating.surface.active",
|
107
|
-
outline: "1px solid",
|
108
|
-
outlineColor: "floating.outline",
|
109
|
-
},
|
110
|
-
},
|
111
|
-
},
|
112
|
-
},
|
113
|
-
size: {
|
114
|
-
xs: {
|
115
|
-
_checked: {
|
116
|
-
borderRadius: "0.563rem",
|
117
|
-
},
|
118
|
-
height: 5,
|
119
|
-
paddingX: 1.5,
|
120
|
-
},
|
121
|
-
sm: {
|
122
|
-
_checked: {
|
123
|
-
borderRadius: "sm",
|
124
|
-
},
|
125
|
-
height: 6,
|
126
|
-
paddingX: 2,
|
127
|
-
},
|
128
|
-
md: {
|
129
|
-
_checked: {
|
130
|
-
borderRadius: "sm",
|
131
|
-
},
|
132
|
-
height: 7,
|
133
|
-
paddingX: 2,
|
134
|
-
},
|
135
|
-
lg: {
|
136
|
-
_checked: {
|
137
|
-
borderRadius: "md",
|
138
|
-
},
|
139
|
-
height: 8,
|
140
|
-
paddingX: 3,
|
141
|
-
},
|
142
|
-
},
|
143
|
-
},
|
144
|
-
});
|