@constela/ui 0.2.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 +160 -0
- package/components/alert/alert.constela.json +22 -0
- package/components/alert/alert.styles.json +14 -0
- package/components/alert/alert.test.ts +173 -0
- package/components/avatar/avatar.constela.json +32 -0
- package/components/avatar/avatar.styles.json +15 -0
- package/components/avatar/avatar.test.ts +197 -0
- package/components/badge/badge.constela.json +19 -0
- package/components/badge/badge.styles.json +16 -0
- package/components/badge/badge.test.ts +135 -0
- package/components/breadcrumb/breadcrumb.constela.json +17 -0
- package/components/breadcrumb/breadcrumb.styles.json +5 -0
- package/components/breadcrumb/breadcrumb.test.ts +149 -0
- package/components/button/README.md +164 -0
- package/components/button/button.constela.json +27 -0
- package/components/button/button.styles.json +25 -0
- package/components/button/button.test.ts +233 -0
- package/components/card/card.constela.json +21 -0
- package/components/card/card.styles.json +14 -0
- package/components/card/card.test.ts +154 -0
- package/components/checkbox/checkbox.constela.json +33 -0
- package/components/checkbox/checkbox.styles.json +15 -0
- package/components/checkbox/checkbox.test.ts +275 -0
- package/components/container/container.constela.json +21 -0
- package/components/container/container.styles.json +18 -0
- package/components/container/container.test.ts +164 -0
- package/components/dialog/dialog.constela.json +19 -0
- package/components/dialog/dialog.styles.json +5 -0
- package/components/dialog/dialog.test.ts +139 -0
- package/components/grid/grid.constela.json +23 -0
- package/components/grid/grid.styles.json +25 -0
- package/components/grid/grid.test.ts +193 -0
- package/components/input/input.constela.json +34 -0
- package/components/input/input.styles.json +19 -0
- package/components/input/input.test.ts +301 -0
- package/components/pagination/pagination.constela.json +22 -0
- package/components/pagination/pagination.styles.json +15 -0
- package/components/pagination/pagination.test.ts +170 -0
- package/components/popover/popover.constela.json +20 -0
- package/components/popover/popover.styles.json +16 -0
- package/components/popover/popover.test.ts +165 -0
- package/components/radio/radio.constela.json +31 -0
- package/components/radio/radio.styles.json +15 -0
- package/components/radio/radio.test.ts +253 -0
- package/components/select/select.constela.json +32 -0
- package/components/select/select.styles.json +15 -0
- package/components/select/select.test.ts +257 -0
- package/components/skeleton/skeleton.constela.json +24 -0
- package/components/skeleton/skeleton.styles.json +5 -0
- package/components/skeleton/skeleton.test.ts +164 -0
- package/components/stack/stack.constela.json +27 -0
- package/components/stack/stack.styles.json +33 -0
- package/components/stack/stack.test.ts +261 -0
- package/components/switch/switch.constela.json +29 -0
- package/components/switch/switch.styles.json +15 -0
- package/components/switch/switch.test.ts +224 -0
- package/components/tabs/tabs.constela.json +21 -0
- package/components/tabs/tabs.styles.json +14 -0
- package/components/tabs/tabs.test.ts +163 -0
- package/components/textarea/textarea.constela.json +34 -0
- package/components/textarea/textarea.styles.json +15 -0
- package/components/textarea/textarea.test.ts +290 -0
- package/components/toast/toast.constela.json +23 -0
- package/components/toast/toast.styles.json +17 -0
- package/components/toast/toast.test.ts +183 -0
- package/components/tooltip/tooltip.constela.json +21 -0
- package/components/tooltip/tooltip.styles.json +16 -0
- package/components/tooltip/tooltip.test.ts +164 -0
- package/dist/index.d.ts +54 -0
- package/dist/index.js +83 -0
- package/package.json +39 -0
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test suite for Button component
|
|
3
|
+
*
|
|
4
|
+
* @constela/ui Button component tests following TDD methodology.
|
|
5
|
+
* These tests verify the Button component structure, params, styles, and accessibility.
|
|
6
|
+
*
|
|
7
|
+
* Coverage:
|
|
8
|
+
* - Component structure validation
|
|
9
|
+
* - Params definition validation
|
|
10
|
+
* - Style preset validation
|
|
11
|
+
* - Accessibility attributes
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { describe, it, expect, beforeAll } from 'vitest';
|
|
15
|
+
import {
|
|
16
|
+
loadComponentForTesting,
|
|
17
|
+
assertValidComponent,
|
|
18
|
+
assertValidStylePreset,
|
|
19
|
+
hasParams,
|
|
20
|
+
isOptionalParam,
|
|
21
|
+
hasParamType,
|
|
22
|
+
getRootTag,
|
|
23
|
+
hasVariants,
|
|
24
|
+
hasVariantOptions,
|
|
25
|
+
hasDefaultVariants,
|
|
26
|
+
hasSlot,
|
|
27
|
+
findPropInView,
|
|
28
|
+
type ComponentTestContext,
|
|
29
|
+
} from '../../tests/helpers/test-utils.js';
|
|
30
|
+
describe('Button Component', () => {
|
|
31
|
+
let ctx: ComponentTestContext;
|
|
32
|
+
|
|
33
|
+
beforeAll(() => {
|
|
34
|
+
ctx = loadComponentForTesting('button');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// ==================== Component Structure Tests ====================
|
|
38
|
+
|
|
39
|
+
describe('Component Structure', () => {
|
|
40
|
+
it('should have valid component structure', () => {
|
|
41
|
+
assertValidComponent(ctx.component);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('should have button as root element', () => {
|
|
45
|
+
const rootTag = getRootTag(ctx.component);
|
|
46
|
+
expect(rootTag).toBe('button');
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('should contain a slot for children', () => {
|
|
50
|
+
expect(hasSlot(ctx.component.view)).toBe(true);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('should have className using StyleExpr', () => {
|
|
54
|
+
const className = findPropInView(ctx.component.view, 'className');
|
|
55
|
+
expect(className).not.toBeNull();
|
|
56
|
+
// StyleExpr should have expr: 'style' and preset reference
|
|
57
|
+
expect(className).toMatchObject({
|
|
58
|
+
expr: 'style',
|
|
59
|
+
preset: 'buttonStyles',
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// ==================== Params Validation Tests ====================
|
|
65
|
+
|
|
66
|
+
describe('Params Validation', () => {
|
|
67
|
+
const expectedParams = ['variant', 'size', 'disabled', 'type', 'ariaLabel'];
|
|
68
|
+
|
|
69
|
+
it('should have all expected params', () => {
|
|
70
|
+
expect(hasParams(ctx.component, expectedParams)).toBe(true);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
describe('param: variant', () => {
|
|
74
|
+
it('should be optional', () => {
|
|
75
|
+
expect(isOptionalParam(ctx.component, 'variant')).toBe(true);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('should have type string', () => {
|
|
79
|
+
expect(hasParamType(ctx.component, 'variant', 'string')).toBe(true);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
describe('param: size', () => {
|
|
84
|
+
it('should be optional', () => {
|
|
85
|
+
expect(isOptionalParam(ctx.component, 'size')).toBe(true);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('should have type string', () => {
|
|
89
|
+
expect(hasParamType(ctx.component, 'size', 'string')).toBe(true);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
describe('param: disabled', () => {
|
|
94
|
+
it('should be optional', () => {
|
|
95
|
+
expect(isOptionalParam(ctx.component, 'disabled')).toBe(true);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('should have type boolean', () => {
|
|
99
|
+
expect(hasParamType(ctx.component, 'disabled', 'boolean')).toBe(true);
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
describe('param: type', () => {
|
|
104
|
+
it('should be optional', () => {
|
|
105
|
+
expect(isOptionalParam(ctx.component, 'type')).toBe(true);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('should have type string', () => {
|
|
109
|
+
expect(hasParamType(ctx.component, 'type', 'string')).toBe(true);
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
describe('param: ariaLabel', () => {
|
|
114
|
+
it('should be optional', () => {
|
|
115
|
+
expect(isOptionalParam(ctx.component, 'ariaLabel')).toBe(true);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('should have type string', () => {
|
|
119
|
+
expect(hasParamType(ctx.component, 'ariaLabel', 'string')).toBe(true);
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// ==================== Style Preset Tests ====================
|
|
125
|
+
|
|
126
|
+
describe('Style Preset', () => {
|
|
127
|
+
it('should have valid style preset structure', () => {
|
|
128
|
+
const buttonStyles = ctx.styles['buttonStyles'];
|
|
129
|
+
expect(buttonStyles).toBeDefined();
|
|
130
|
+
assertValidStylePreset(buttonStyles);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it('should have base classes', () => {
|
|
134
|
+
const buttonStyles = ctx.styles['buttonStyles'];
|
|
135
|
+
expect(buttonStyles.base).toBeDefined();
|
|
136
|
+
expect(typeof buttonStyles.base).toBe('string');
|
|
137
|
+
expect(buttonStyles.base.length).toBeGreaterThan(0);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
describe('variant options', () => {
|
|
141
|
+
const variantOptions = ['default', 'destructive', 'outline', 'secondary', 'ghost', 'link'];
|
|
142
|
+
|
|
143
|
+
it('should have variant variants', () => {
|
|
144
|
+
const buttonStyles = ctx.styles['buttonStyles'];
|
|
145
|
+
expect(hasVariants(buttonStyles, ['variant'])).toBe(true);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it.each(variantOptions)('should have %s variant option', (option) => {
|
|
149
|
+
const buttonStyles = ctx.styles['buttonStyles'];
|
|
150
|
+
expect(hasVariantOptions(buttonStyles, 'variant', [option])).toBe(true);
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
describe('size options', () => {
|
|
155
|
+
const sizeOptions = ['default', 'sm', 'lg', 'icon'];
|
|
156
|
+
|
|
157
|
+
it('should have size variants', () => {
|
|
158
|
+
const buttonStyles = ctx.styles['buttonStyles'];
|
|
159
|
+
expect(hasVariants(buttonStyles, ['size'])).toBe(true);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it.each(sizeOptions)('should have %s size option', (option) => {
|
|
163
|
+
const buttonStyles = ctx.styles['buttonStyles'];
|
|
164
|
+
expect(hasVariantOptions(buttonStyles, 'size', [option])).toBe(true);
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
describe('default variants', () => {
|
|
169
|
+
it('should have default variant set to default', () => {
|
|
170
|
+
const buttonStyles = ctx.styles['buttonStyles'];
|
|
171
|
+
expect(hasDefaultVariants(buttonStyles, { variant: 'default' })).toBe(true);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it('should have default size set to default', () => {
|
|
175
|
+
const buttonStyles = ctx.styles['buttonStyles'];
|
|
176
|
+
expect(hasDefaultVariants(buttonStyles, { size: 'default' })).toBe(true);
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
// ==================== Accessibility Tests ====================
|
|
182
|
+
|
|
183
|
+
describe('Accessibility', () => {
|
|
184
|
+
it('should support aria-label attribute', () => {
|
|
185
|
+
const ariaLabel = findPropInView(ctx.component.view, 'aria-label');
|
|
186
|
+
expect(ariaLabel).not.toBeNull();
|
|
187
|
+
// Should reference the ariaLabel param
|
|
188
|
+
expect(ariaLabel).toMatchObject({
|
|
189
|
+
expr: 'param',
|
|
190
|
+
name: 'ariaLabel',
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it('should support disabled attribute', () => {
|
|
195
|
+
const disabled = findPropInView(ctx.component.view, 'disabled');
|
|
196
|
+
expect(disabled).not.toBeNull();
|
|
197
|
+
// Should reference the disabled param
|
|
198
|
+
expect(disabled).toMatchObject({
|
|
199
|
+
expr: 'param',
|
|
200
|
+
name: 'disabled',
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
it('should support type attribute', () => {
|
|
205
|
+
const type = findPropInView(ctx.component.view, 'type');
|
|
206
|
+
expect(type).not.toBeNull();
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
// ==================== View Props Tests ====================
|
|
211
|
+
|
|
212
|
+
describe('View Props', () => {
|
|
213
|
+
it('should pass variant to StyleExpr', () => {
|
|
214
|
+
const className = findPropInView(ctx.component.view, 'className');
|
|
215
|
+
expect(className).toMatchObject({
|
|
216
|
+
expr: 'style',
|
|
217
|
+
props: expect.objectContaining({
|
|
218
|
+
variant: expect.objectContaining({ expr: 'param', name: 'variant' }),
|
|
219
|
+
}),
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
it('should pass size to StyleExpr', () => {
|
|
224
|
+
const className = findPropInView(ctx.component.view, 'className');
|
|
225
|
+
expect(className).toMatchObject({
|
|
226
|
+
expr: 'style',
|
|
227
|
+
props: expect.objectContaining({
|
|
228
|
+
size: expect.objectContaining({ expr: 'param', name: 'size' }),
|
|
229
|
+
}),
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"params": {
|
|
3
|
+
"variant": { "type": "string", "required": false },
|
|
4
|
+
"className": { "type": "string", "required": false }
|
|
5
|
+
},
|
|
6
|
+
"view": {
|
|
7
|
+
"kind": "element",
|
|
8
|
+
"tag": "div",
|
|
9
|
+
"props": {
|
|
10
|
+
"className": {
|
|
11
|
+
"expr": "style",
|
|
12
|
+
"preset": "cardStyles",
|
|
13
|
+
"props": {
|
|
14
|
+
"variant": { "expr": "param", "name": "variant" },
|
|
15
|
+
"className": { "expr": "param", "name": "className" }
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"children": [{ "kind": "slot" }]
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test suite for Card component
|
|
3
|
+
*
|
|
4
|
+
* @constela/ui Card component tests following TDD methodology.
|
|
5
|
+
* These tests verify the Card component structure, params, and styles.
|
|
6
|
+
*
|
|
7
|
+
* Coverage:
|
|
8
|
+
* - Component structure validation
|
|
9
|
+
* - Params definition validation
|
|
10
|
+
* - Style preset validation
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { describe, it, expect, beforeAll } from 'vitest';
|
|
14
|
+
import {
|
|
15
|
+
loadComponentForTesting,
|
|
16
|
+
assertValidComponent,
|
|
17
|
+
assertValidStylePreset,
|
|
18
|
+
hasParams,
|
|
19
|
+
isOptionalParam,
|
|
20
|
+
hasParamType,
|
|
21
|
+
getRootTag,
|
|
22
|
+
hasVariants,
|
|
23
|
+
hasVariantOptions,
|
|
24
|
+
hasDefaultVariants,
|
|
25
|
+
hasSlot,
|
|
26
|
+
findPropInView,
|
|
27
|
+
type ComponentTestContext,
|
|
28
|
+
} from '../../tests/helpers/test-utils.js';
|
|
29
|
+
|
|
30
|
+
describe('Card Component', () => {
|
|
31
|
+
let ctx: ComponentTestContext;
|
|
32
|
+
|
|
33
|
+
beforeAll(() => {
|
|
34
|
+
ctx = loadComponentForTesting('card');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// ==================== Component Structure Tests ====================
|
|
38
|
+
|
|
39
|
+
describe('Component Structure', () => {
|
|
40
|
+
it('should have valid component structure', () => {
|
|
41
|
+
assertValidComponent(ctx.component);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('should have div as root element', () => {
|
|
45
|
+
const rootTag = getRootTag(ctx.component);
|
|
46
|
+
expect(rootTag).toBe('div');
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('should contain a slot for card content', () => {
|
|
50
|
+
expect(hasSlot(ctx.component.view)).toBe(true);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('should have className using StyleExpr with cardStyles preset', () => {
|
|
54
|
+
const className = findPropInView(ctx.component.view, 'className');
|
|
55
|
+
expect(className).not.toBeNull();
|
|
56
|
+
expect(className).toMatchObject({
|
|
57
|
+
expr: 'style',
|
|
58
|
+
preset: 'cardStyles',
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// ==================== Params Validation Tests ====================
|
|
64
|
+
|
|
65
|
+
describe('Params Validation', () => {
|
|
66
|
+
const expectedParams = ['variant', 'className'];
|
|
67
|
+
|
|
68
|
+
it('should have all expected params', () => {
|
|
69
|
+
expect(hasParams(ctx.component, expectedParams)).toBe(true);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
describe('param: variant', () => {
|
|
73
|
+
it('should be optional', () => {
|
|
74
|
+
expect(isOptionalParam(ctx.component, 'variant')).toBe(true);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('should have type string', () => {
|
|
78
|
+
expect(hasParamType(ctx.component, 'variant', 'string')).toBe(true);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
describe('param: className', () => {
|
|
83
|
+
it('should be optional', () => {
|
|
84
|
+
expect(isOptionalParam(ctx.component, 'className')).toBe(true);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('should have type string', () => {
|
|
88
|
+
expect(hasParamType(ctx.component, 'className', 'string')).toBe(true);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// ==================== Style Preset Tests ====================
|
|
94
|
+
|
|
95
|
+
describe('Style Preset', () => {
|
|
96
|
+
it('should have valid style preset structure', () => {
|
|
97
|
+
const cardStyles = ctx.styles['cardStyles'];
|
|
98
|
+
expect(cardStyles).toBeDefined();
|
|
99
|
+
assertValidStylePreset(cardStyles);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('should have base classes for common card styles', () => {
|
|
103
|
+
const cardStyles = ctx.styles['cardStyles'];
|
|
104
|
+
expect(cardStyles.base).toBeDefined();
|
|
105
|
+
expect(typeof cardStyles.base).toBe('string');
|
|
106
|
+
expect(cardStyles.base.length).toBeGreaterThan(0);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
describe('variant options', () => {
|
|
110
|
+
const variantOptions = ['default', 'outline'];
|
|
111
|
+
|
|
112
|
+
it('should have variant variants', () => {
|
|
113
|
+
const cardStyles = ctx.styles['cardStyles'];
|
|
114
|
+
expect(hasVariants(cardStyles, ['variant'])).toBe(true);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it.each(variantOptions)('should have %s variant option', (option) => {
|
|
118
|
+
const cardStyles = ctx.styles['cardStyles'];
|
|
119
|
+
expect(hasVariantOptions(cardStyles, 'variant', [option])).toBe(true);
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
describe('default variants', () => {
|
|
124
|
+
it('should have default variant set to default', () => {
|
|
125
|
+
const cardStyles = ctx.styles['cardStyles'];
|
|
126
|
+
expect(hasDefaultVariants(cardStyles, { variant: 'default' })).toBe(true);
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
// ==================== View Props Tests ====================
|
|
132
|
+
|
|
133
|
+
describe('View Props', () => {
|
|
134
|
+
it('should pass variant to StyleExpr', () => {
|
|
135
|
+
const className = findPropInView(ctx.component.view, 'className');
|
|
136
|
+
expect(className).toMatchObject({
|
|
137
|
+
expr: 'style',
|
|
138
|
+
props: expect.objectContaining({
|
|
139
|
+
variant: expect.objectContaining({ expr: 'param', name: 'variant' }),
|
|
140
|
+
}),
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('should pass className to StyleExpr', () => {
|
|
145
|
+
const className = findPropInView(ctx.component.view, 'className');
|
|
146
|
+
expect(className).toMatchObject({
|
|
147
|
+
expr: 'style',
|
|
148
|
+
props: expect.objectContaining({
|
|
149
|
+
className: expect.objectContaining({ expr: 'param', name: 'className' }),
|
|
150
|
+
}),
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"params": {
|
|
3
|
+
"checked": { "type": "boolean", "required": false },
|
|
4
|
+
"disabled": { "type": "boolean", "required": false },
|
|
5
|
+
"required": { "type": "boolean", "required": false },
|
|
6
|
+
"name": { "type": "string", "required": false },
|
|
7
|
+
"id": { "type": "string", "required": false },
|
|
8
|
+
"ariaLabel": { "type": "string", "required": false },
|
|
9
|
+
"value": { "type": "string", "required": false },
|
|
10
|
+
"size": { "type": "string", "required": false }
|
|
11
|
+
},
|
|
12
|
+
"view": {
|
|
13
|
+
"kind": "element",
|
|
14
|
+
"tag": "input",
|
|
15
|
+
"props": {
|
|
16
|
+
"type": { "expr": "lit", "value": "checkbox" },
|
|
17
|
+
"className": {
|
|
18
|
+
"expr": "style",
|
|
19
|
+
"preset": "checkboxStyles",
|
|
20
|
+
"props": {
|
|
21
|
+
"size": { "expr": "param", "name": "size" }
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"checked": { "expr": "param", "name": "checked" },
|
|
25
|
+
"disabled": { "expr": "param", "name": "disabled" },
|
|
26
|
+
"required": { "expr": "param", "name": "required" },
|
|
27
|
+
"name": { "expr": "param", "name": "name" },
|
|
28
|
+
"id": { "expr": "param", "name": "id" },
|
|
29
|
+
"aria-label": { "expr": "param", "name": "ariaLabel" },
|
|
30
|
+
"value": { "expr": "param", "name": "value" }
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"checkboxStyles": {
|
|
3
|
+
"base": "peer shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 checked:bg-primary checked:text-primary-foreground",
|
|
4
|
+
"variants": {
|
|
5
|
+
"size": {
|
|
6
|
+
"default": "h-4 w-4",
|
|
7
|
+
"sm": "h-3 w-3",
|
|
8
|
+
"lg": "h-5 w-5"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"defaultVariants": {
|
|
12
|
+
"size": "default"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|