@kushagradhawan/kookie-ui 0.1.41 → 0.1.42
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/README.md +257 -60
- package/components.css +386 -79
- package/dist/cjs/components/schemas/base-button.schema.d.ts +319 -0
- package/dist/cjs/components/schemas/base-button.schema.d.ts.map +1 -0
- package/dist/cjs/components/schemas/base-button.schema.js +2 -0
- package/dist/cjs/components/schemas/base-button.schema.js.map +7 -0
- package/dist/cjs/components/schemas/button.schema.d.ts +686 -0
- package/dist/cjs/components/schemas/button.schema.d.ts.map +1 -0
- package/dist/cjs/components/schemas/button.schema.js +2 -0
- package/dist/cjs/components/schemas/button.schema.js.map +7 -0
- package/dist/cjs/components/schemas/icon-button.schema.d.ts +329 -0
- package/dist/cjs/components/schemas/icon-button.schema.d.ts.map +1 -0
- package/dist/cjs/components/schemas/icon-button.schema.js +2 -0
- package/dist/cjs/components/schemas/icon-button.schema.js.map +7 -0
- package/dist/cjs/components/schemas/index.d.ts +52 -0
- package/dist/cjs/components/schemas/index.d.ts.map +1 -0
- package/dist/cjs/components/schemas/index.js +2 -0
- package/dist/cjs/components/schemas/index.js.map +7 -0
- package/dist/cjs/components/schemas/toggle-button.schema.d.ts +1172 -0
- package/dist/cjs/components/schemas/toggle-button.schema.d.ts.map +1 -0
- package/dist/cjs/components/schemas/toggle-button.schema.js +2 -0
- package/dist/cjs/components/schemas/toggle-button.schema.js.map +7 -0
- package/dist/cjs/components/schemas/toggle-icon-button.schema.d.ts +563 -0
- package/dist/cjs/components/schemas/toggle-icon-button.schema.d.ts.map +1 -0
- package/dist/cjs/components/schemas/toggle-icon-button.schema.js +2 -0
- package/dist/cjs/components/schemas/toggle-icon-button.schema.js.map +7 -0
- package/dist/cjs/components/sheet.d.ts +1 -1
- package/dist/cjs/components/sheet.d.ts.map +1 -1
- package/dist/cjs/components/sheet.js +1 -1
- package/dist/cjs/components/sheet.js.map +3 -3
- package/dist/cjs/components/shell.d.ts +125 -164
- package/dist/cjs/components/shell.d.ts.map +1 -1
- package/dist/cjs/components/shell.js +1 -1
- package/dist/cjs/components/shell.js.map +3 -3
- package/dist/cjs/components/sidebar.d.ts +1 -7
- package/dist/cjs/components/sidebar.d.ts.map +1 -1
- package/dist/cjs/components/sidebar.js +1 -1
- package/dist/cjs/components/sidebar.js.map +3 -3
- package/dist/cjs/components/theme.d.ts +3 -0
- package/dist/cjs/components/theme.d.ts.map +1 -1
- package/dist/cjs/components/theme.js +1 -1
- package/dist/cjs/components/theme.js.map +3 -3
- package/dist/cjs/components/theme.props.d.ts +10 -0
- package/dist/cjs/components/theme.props.d.ts.map +1 -1
- package/dist/cjs/components/theme.props.js +1 -1
- package/dist/cjs/components/theme.props.js.map +3 -3
- package/dist/cjs/helpers/font-config.d.ts +96 -0
- package/dist/cjs/helpers/font-config.d.ts.map +1 -0
- package/dist/cjs/helpers/font-config.js +3 -0
- package/dist/cjs/helpers/font-config.js.map +7 -0
- package/dist/cjs/helpers/index.d.ts +1 -0
- package/dist/cjs/helpers/index.d.ts.map +1 -1
- package/dist/cjs/helpers/index.js +1 -1
- package/dist/cjs/helpers/index.js.map +2 -2
- package/dist/esm/components/schemas/base-button.schema.d.ts +319 -0
- package/dist/esm/components/schemas/base-button.schema.d.ts.map +1 -0
- package/dist/esm/components/schemas/base-button.schema.js +2 -0
- package/dist/esm/components/schemas/base-button.schema.js.map +7 -0
- package/dist/esm/components/schemas/button.schema.d.ts +686 -0
- package/dist/esm/components/schemas/button.schema.d.ts.map +1 -0
- package/dist/esm/components/schemas/button.schema.js +2 -0
- package/dist/esm/components/schemas/button.schema.js.map +7 -0
- package/dist/esm/components/schemas/icon-button.schema.d.ts +329 -0
- package/dist/esm/components/schemas/icon-button.schema.d.ts.map +1 -0
- package/dist/esm/components/schemas/icon-button.schema.js +2 -0
- package/dist/esm/components/schemas/icon-button.schema.js.map +7 -0
- package/dist/esm/components/schemas/index.d.ts +52 -0
- package/dist/esm/components/schemas/index.d.ts.map +1 -0
- package/dist/esm/components/schemas/index.js +2 -0
- package/dist/esm/components/schemas/index.js.map +7 -0
- package/dist/esm/components/schemas/toggle-button.schema.d.ts +1172 -0
- package/dist/esm/components/schemas/toggle-button.schema.d.ts.map +1 -0
- package/dist/esm/components/schemas/toggle-button.schema.js +2 -0
- package/dist/esm/components/schemas/toggle-button.schema.js.map +7 -0
- package/dist/esm/components/schemas/toggle-icon-button.schema.d.ts +563 -0
- package/dist/esm/components/schemas/toggle-icon-button.schema.d.ts.map +1 -0
- package/dist/esm/components/schemas/toggle-icon-button.schema.js +2 -0
- package/dist/esm/components/schemas/toggle-icon-button.schema.js.map +7 -0
- package/dist/esm/components/sheet.d.ts +1 -1
- package/dist/esm/components/sheet.d.ts.map +1 -1
- package/dist/esm/components/sheet.js +1 -1
- package/dist/esm/components/sheet.js.map +3 -3
- package/dist/esm/components/shell.d.ts +125 -164
- package/dist/esm/components/shell.d.ts.map +1 -1
- package/dist/esm/components/shell.js +1 -1
- package/dist/esm/components/shell.js.map +3 -3
- package/dist/esm/components/sidebar.d.ts +1 -7
- package/dist/esm/components/sidebar.d.ts.map +1 -1
- package/dist/esm/components/sidebar.js +1 -1
- package/dist/esm/components/sidebar.js.map +3 -3
- package/dist/esm/components/theme.d.ts +3 -0
- package/dist/esm/components/theme.d.ts.map +1 -1
- package/dist/esm/components/theme.js +1 -1
- package/dist/esm/components/theme.js.map +3 -3
- package/dist/esm/components/theme.props.d.ts +10 -0
- package/dist/esm/components/theme.props.d.ts.map +1 -1
- package/dist/esm/components/theme.props.js +1 -1
- package/dist/esm/components/theme.props.js.map +3 -3
- package/dist/esm/helpers/font-config.d.ts +96 -0
- package/dist/esm/helpers/font-config.d.ts.map +1 -0
- package/dist/esm/helpers/font-config.js +3 -0
- package/dist/esm/helpers/font-config.js.map +7 -0
- package/dist/esm/helpers/index.d.ts +1 -0
- package/dist/esm/helpers/index.d.ts.map +1 -1
- package/dist/esm/helpers/index.js +1 -1
- package/dist/esm/helpers/index.js.map +2 -2
- package/package.json +23 -3
- package/schemas/base-button.d.ts +2 -0
- package/schemas/base-button.json +284 -0
- package/schemas/button.d.ts +2 -0
- package/schemas/button.json +535 -0
- package/schemas/icon-button.d.ts +2 -0
- package/schemas/icon-button.json +318 -0
- package/schemas/index.d.ts +2 -0
- package/schemas/index.json +2016 -0
- package/schemas/schemas.d.ts +29 -0
- package/schemas/toggle-button.d.ts +2 -0
- package/schemas/toggle-button.json +543 -0
- package/schemas/toggle-icon-button.d.ts +2 -0
- package/schemas/toggle-icon-button.json +326 -0
- package/schemas-json.d.ts +12 -0
- package/src/components/_internal/base-sidebar.css +1 -2
- package/src/components/schemas/base-button.schema.ts +339 -0
- package/src/components/schemas/button.schema.ts +198 -0
- package/src/components/schemas/icon-button.schema.ts +142 -0
- package/src/components/schemas/index.ts +68 -0
- package/src/components/schemas/toggle-button.schema.ts +122 -0
- package/src/components/schemas/toggle-icon-button.schema.ts +195 -0
- package/src/components/sheet.css +39 -19
- package/src/components/sheet.tsx +62 -3
- package/src/components/shell.css +510 -89
- package/src/components/shell.tsx +2055 -928
- package/src/components/sidebar.tsx +3 -22
- package/src/components/theme.props.tsx +8 -0
- package/src/components/theme.tsx +16 -0
- package/src/helpers/font-config.ts +167 -0
- package/src/helpers/index.ts +1 -0
- package/src/styles/fonts.css +16 -13
- package/src/styles/tokens/typography.css +27 -4
- package/styles.css +398 -79
- package/tokens/base.css +12 -0
- package/tokens.css +12 -0
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$ref": "#/definitions/Toggle-icon-buttonSchema",
|
|
3
|
+
"definitions": {
|
|
4
|
+
"Toggle-icon-buttonSchema": {
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"as": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "HTML element type to render as"
|
|
10
|
+
},
|
|
11
|
+
"asChild": {
|
|
12
|
+
"type": "boolean",
|
|
13
|
+
"description": "Merge props with child element instead of rendering wrapper"
|
|
14
|
+
},
|
|
15
|
+
"size": {
|
|
16
|
+
"anyOf": [
|
|
17
|
+
{
|
|
18
|
+
"type": "string",
|
|
19
|
+
"enum": [
|
|
20
|
+
"1",
|
|
21
|
+
"2",
|
|
22
|
+
"3",
|
|
23
|
+
"4"
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"type": "object",
|
|
28
|
+
"properties": {
|
|
29
|
+
"initial": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"enum": [
|
|
32
|
+
"1",
|
|
33
|
+
"2",
|
|
34
|
+
"3",
|
|
35
|
+
"4"
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
"sm": {
|
|
39
|
+
"type": "string",
|
|
40
|
+
"enum": [
|
|
41
|
+
"1",
|
|
42
|
+
"2",
|
|
43
|
+
"3",
|
|
44
|
+
"4"
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
"md": {
|
|
48
|
+
"type": "string",
|
|
49
|
+
"enum": [
|
|
50
|
+
"1",
|
|
51
|
+
"2",
|
|
52
|
+
"3",
|
|
53
|
+
"4"
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
"lg": {
|
|
57
|
+
"type": "string",
|
|
58
|
+
"enum": [
|
|
59
|
+
"1",
|
|
60
|
+
"2",
|
|
61
|
+
"3",
|
|
62
|
+
"4"
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
"xl": {
|
|
66
|
+
"type": "string",
|
|
67
|
+
"enum": [
|
|
68
|
+
"1",
|
|
69
|
+
"2",
|
|
70
|
+
"3",
|
|
71
|
+
"4"
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"additionalProperties": false
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
"default": "2",
|
|
79
|
+
"description": "Button size for responsive design and interface density"
|
|
80
|
+
},
|
|
81
|
+
"variant": {
|
|
82
|
+
"type": "string",
|
|
83
|
+
"enum": [
|
|
84
|
+
"classic",
|
|
85
|
+
"solid",
|
|
86
|
+
"soft",
|
|
87
|
+
"surface",
|
|
88
|
+
"outline",
|
|
89
|
+
"ghost",
|
|
90
|
+
"override"
|
|
91
|
+
],
|
|
92
|
+
"default": "solid",
|
|
93
|
+
"description": "Visual variant that determines the button's appearance and context"
|
|
94
|
+
},
|
|
95
|
+
"color": {
|
|
96
|
+
"type": "string",
|
|
97
|
+
"enum": [
|
|
98
|
+
"tomato",
|
|
99
|
+
"red",
|
|
100
|
+
"ruby",
|
|
101
|
+
"crimson",
|
|
102
|
+
"pink",
|
|
103
|
+
"plum",
|
|
104
|
+
"purple",
|
|
105
|
+
"violet",
|
|
106
|
+
"iris",
|
|
107
|
+
"indigo",
|
|
108
|
+
"blue",
|
|
109
|
+
"cyan",
|
|
110
|
+
"teal",
|
|
111
|
+
"jade",
|
|
112
|
+
"green",
|
|
113
|
+
"grass",
|
|
114
|
+
"brown",
|
|
115
|
+
"orange",
|
|
116
|
+
"sky",
|
|
117
|
+
"mint",
|
|
118
|
+
"lime",
|
|
119
|
+
"yellow",
|
|
120
|
+
"amber",
|
|
121
|
+
"gold",
|
|
122
|
+
"bronze",
|
|
123
|
+
"gray"
|
|
124
|
+
],
|
|
125
|
+
"description": "Accent color for the button"
|
|
126
|
+
},
|
|
127
|
+
"highContrast": {
|
|
128
|
+
"type": "boolean",
|
|
129
|
+
"default": false,
|
|
130
|
+
"description": "High contrast mode for better accessibility"
|
|
131
|
+
},
|
|
132
|
+
"radius": {
|
|
133
|
+
"type": "string",
|
|
134
|
+
"enum": [
|
|
135
|
+
"none",
|
|
136
|
+
"small",
|
|
137
|
+
"medium",
|
|
138
|
+
"large",
|
|
139
|
+
"full"
|
|
140
|
+
],
|
|
141
|
+
"description": "Border radius for the button"
|
|
142
|
+
},
|
|
143
|
+
"loading": {
|
|
144
|
+
"type": "boolean",
|
|
145
|
+
"default": false,
|
|
146
|
+
"description": "Loading state that shows a spinner and disables interaction"
|
|
147
|
+
},
|
|
148
|
+
"fullWidth": {
|
|
149
|
+
"type": "boolean",
|
|
150
|
+
"default": false,
|
|
151
|
+
"description": "Full width mode that expands the button to fill its container"
|
|
152
|
+
},
|
|
153
|
+
"material": {
|
|
154
|
+
"type": "string",
|
|
155
|
+
"enum": [
|
|
156
|
+
"solid",
|
|
157
|
+
"translucent"
|
|
158
|
+
],
|
|
159
|
+
"description": "Material type for visual rendering and depth effects"
|
|
160
|
+
},
|
|
161
|
+
"panelBackground": {
|
|
162
|
+
"type": "string",
|
|
163
|
+
"enum": [
|
|
164
|
+
"solid",
|
|
165
|
+
"translucent"
|
|
166
|
+
],
|
|
167
|
+
"description": "Panel background type (deprecated - use material instead)"
|
|
168
|
+
},
|
|
169
|
+
"flush": {
|
|
170
|
+
"type": "boolean",
|
|
171
|
+
"default": false,
|
|
172
|
+
"description": "Flush mode that removes visual padding for seamless text integration"
|
|
173
|
+
},
|
|
174
|
+
"disabled": {
|
|
175
|
+
"type": "boolean",
|
|
176
|
+
"default": false,
|
|
177
|
+
"description": "Disabled state"
|
|
178
|
+
},
|
|
179
|
+
"type": {
|
|
180
|
+
"type": "string",
|
|
181
|
+
"enum": [
|
|
182
|
+
"button",
|
|
183
|
+
"submit",
|
|
184
|
+
"reset"
|
|
185
|
+
],
|
|
186
|
+
"description": "Type attribute for form buttons"
|
|
187
|
+
},
|
|
188
|
+
"className": {
|
|
189
|
+
"type": "string",
|
|
190
|
+
"description": "Additional CSS class name"
|
|
191
|
+
},
|
|
192
|
+
"style": {
|
|
193
|
+
"type": "object",
|
|
194
|
+
"additionalProperties": {
|
|
195
|
+
"type": [
|
|
196
|
+
"string",
|
|
197
|
+
"number"
|
|
198
|
+
]
|
|
199
|
+
},
|
|
200
|
+
"description": "Inline styles"
|
|
201
|
+
},
|
|
202
|
+
"tabIndex": {
|
|
203
|
+
"type": "number",
|
|
204
|
+
"description": "Tab index for keyboard navigation"
|
|
205
|
+
},
|
|
206
|
+
"aria-label": {
|
|
207
|
+
"type": "string",
|
|
208
|
+
"description": "ARIA label for accessibility"
|
|
209
|
+
},
|
|
210
|
+
"aria-labelledby": {
|
|
211
|
+
"type": "string",
|
|
212
|
+
"description": "ARIA labelled by reference"
|
|
213
|
+
},
|
|
214
|
+
"aria-describedby": {
|
|
215
|
+
"type": "string",
|
|
216
|
+
"description": "ARIA described by reference"
|
|
217
|
+
},
|
|
218
|
+
"aria-expanded": {
|
|
219
|
+
"type": "boolean",
|
|
220
|
+
"description": "ARIA expanded state"
|
|
221
|
+
},
|
|
222
|
+
"aria-pressed": {
|
|
223
|
+
"type": "boolean",
|
|
224
|
+
"description": "ARIA pressed state"
|
|
225
|
+
},
|
|
226
|
+
"aria-current": {
|
|
227
|
+
"anyOf": [
|
|
228
|
+
{
|
|
229
|
+
"type": "boolean"
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"type": "string",
|
|
233
|
+
"enum": [
|
|
234
|
+
"page",
|
|
235
|
+
"step",
|
|
236
|
+
"location",
|
|
237
|
+
"date",
|
|
238
|
+
"time"
|
|
239
|
+
]
|
|
240
|
+
}
|
|
241
|
+
],
|
|
242
|
+
"description": "ARIA current state"
|
|
243
|
+
},
|
|
244
|
+
"aria-controls": {
|
|
245
|
+
"type": "string",
|
|
246
|
+
"description": "ARIA controls reference"
|
|
247
|
+
},
|
|
248
|
+
"aria-owns": {
|
|
249
|
+
"type": "string",
|
|
250
|
+
"description": "ARIA owns reference"
|
|
251
|
+
},
|
|
252
|
+
"data-*": {
|
|
253
|
+
"type": "object",
|
|
254
|
+
"additionalProperties": {
|
|
255
|
+
"type": "string"
|
|
256
|
+
},
|
|
257
|
+
"description": "Data attributes"
|
|
258
|
+
},
|
|
259
|
+
"id": {
|
|
260
|
+
"type": "string",
|
|
261
|
+
"description": "ID attribute"
|
|
262
|
+
},
|
|
263
|
+
"title": {
|
|
264
|
+
"type": "string",
|
|
265
|
+
"description": "Title attribute for tooltip"
|
|
266
|
+
},
|
|
267
|
+
"role": {
|
|
268
|
+
"type": "string",
|
|
269
|
+
"description": "Role attribute"
|
|
270
|
+
},
|
|
271
|
+
"children": {
|
|
272
|
+
"description": "Children elements (required for accessibility if no aria-label)"
|
|
273
|
+
},
|
|
274
|
+
"tooltip": {
|
|
275
|
+
"type": "string",
|
|
276
|
+
"description": "Content to display in the tooltip on hover/focus"
|
|
277
|
+
},
|
|
278
|
+
"tooltipSide": {
|
|
279
|
+
"type": "string",
|
|
280
|
+
"enum": [
|
|
281
|
+
"top",
|
|
282
|
+
"right",
|
|
283
|
+
"bottom",
|
|
284
|
+
"left"
|
|
285
|
+
],
|
|
286
|
+
"default": "top",
|
|
287
|
+
"description": "Side of the button where the tooltip should appear"
|
|
288
|
+
},
|
|
289
|
+
"tooltipAlign": {
|
|
290
|
+
"type": "string",
|
|
291
|
+
"enum": [
|
|
292
|
+
"start",
|
|
293
|
+
"center",
|
|
294
|
+
"end"
|
|
295
|
+
],
|
|
296
|
+
"default": "center",
|
|
297
|
+
"description": "Alignment of the tooltip relative to the button"
|
|
298
|
+
},
|
|
299
|
+
"tooltipDelayDuration": {
|
|
300
|
+
"type": "number",
|
|
301
|
+
"description": "Delay before showing the tooltip (in milliseconds)"
|
|
302
|
+
},
|
|
303
|
+
"tooltipDisableHoverableContent": {
|
|
304
|
+
"type": "boolean",
|
|
305
|
+
"default": false,
|
|
306
|
+
"description": "Whether to disable hoverable content behavior"
|
|
307
|
+
},
|
|
308
|
+
"pressed": {
|
|
309
|
+
"type": "boolean",
|
|
310
|
+
"description": "Controlled pressed state"
|
|
311
|
+
},
|
|
312
|
+
"defaultPressed": {
|
|
313
|
+
"type": "boolean",
|
|
314
|
+
"description": "Default pressed state for uncontrolled usage"
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
"additionalProperties": false
|
|
318
|
+
}
|
|
319
|
+
},
|
|
320
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
321
|
+
"title": "Toggle-icon-button Component Props",
|
|
322
|
+
"description": "Props schema for the toggle-icon-button component in Kookie UI",
|
|
323
|
+
"version": "1.0.0",
|
|
324
|
+
"generatedAt": "2025-09-09T20:52:02.773Z",
|
|
325
|
+
"source": "Zod schema"
|
|
326
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Ambient module declarations for JSON schema imports
|
|
2
|
+
// This file enables TypeScript to resolve JSON schema imports
|
|
3
|
+
|
|
4
|
+
declare module '@kushagradhawan/kookie-ui/schemas-json' {
|
|
5
|
+
const schemaIndex: any;
|
|
6
|
+
export default schemaIndex;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare module '@kushagradhawan/kookie-ui/schemas-json/*' {
|
|
10
|
+
const schema: any;
|
|
11
|
+
export default schema;
|
|
12
|
+
}
|
|
@@ -16,10 +16,9 @@
|
|
|
16
16
|
|
|
17
17
|
/* Sidebar Root Container */
|
|
18
18
|
.rt-SidebarRoot {
|
|
19
|
-
--sidebar-width: 16rem; /* Fixed width */
|
|
20
19
|
--sidebar-base-border-radius: 0; /* Default to no radius */
|
|
21
20
|
|
|
22
|
-
width:
|
|
21
|
+
width: 100%;
|
|
23
22
|
height: 100%;
|
|
24
23
|
flex-shrink: 0;
|
|
25
24
|
display: flex;
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* BaseButton Zod schema - Single source of truth for all button component props
|
|
5
|
+
*
|
|
6
|
+
* This schema defines the core button functionality used by Button, IconButton,
|
|
7
|
+
* ToggleButton, and ToggleIconButton components. It ensures consistency across
|
|
8
|
+
* the design system and provides machine-readable validation.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* // Basic validation
|
|
13
|
+
* const props = BaseButtonSchema.parse({ size: '2', variant: 'solid' });
|
|
14
|
+
*
|
|
15
|
+
* // With responsive props
|
|
16
|
+
* const responsiveProps = BaseButtonSchema.parse({
|
|
17
|
+
* size: { initial: '1', sm: '2', md: '3' },
|
|
18
|
+
* variant: 'solid'
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export const BaseButtonSchema = z
|
|
23
|
+
.object({
|
|
24
|
+
/**
|
|
25
|
+
* Polymorphic rendering - render as different HTML elements
|
|
26
|
+
* @default 'button'
|
|
27
|
+
*/
|
|
28
|
+
as: z.string().optional().describe('HTML element type to render as'),
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Use asChild to merge props with child element
|
|
32
|
+
* @default false
|
|
33
|
+
*/
|
|
34
|
+
asChild: z
|
|
35
|
+
.boolean()
|
|
36
|
+
.optional()
|
|
37
|
+
.describe('Merge props with child element instead of rendering wrapper'),
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Button size for responsive design and interface density
|
|
41
|
+
* Supports responsive objects: { initial: '1', sm: '2', md: '3', lg: '4' }
|
|
42
|
+
* @default '2'
|
|
43
|
+
*/
|
|
44
|
+
size: z
|
|
45
|
+
.union([
|
|
46
|
+
z.enum(['1', '2', '3', '4']),
|
|
47
|
+
z.object({
|
|
48
|
+
initial: z.enum(['1', '2', '3', '4']).optional(),
|
|
49
|
+
sm: z.enum(['1', '2', '3', '4']).optional(),
|
|
50
|
+
md: z.enum(['1', '2', '3', '4']).optional(),
|
|
51
|
+
lg: z.enum(['1', '2', '3', '4']).optional(),
|
|
52
|
+
xl: z.enum(['1', '2', '3', '4']).optional(),
|
|
53
|
+
}),
|
|
54
|
+
])
|
|
55
|
+
.default('2')
|
|
56
|
+
.describe('Button size for responsive design and interface density'),
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Visual variant that determines the button's appearance and context
|
|
60
|
+
* @default 'solid'
|
|
61
|
+
*/
|
|
62
|
+
variant: z
|
|
63
|
+
.enum(['classic', 'solid', 'soft', 'surface', 'outline', 'ghost', 'override'])
|
|
64
|
+
.default('solid')
|
|
65
|
+
.describe("Visual variant that determines the button's appearance and context"),
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Accent color for the button
|
|
69
|
+
*/
|
|
70
|
+
color: z
|
|
71
|
+
.enum([
|
|
72
|
+
'tomato',
|
|
73
|
+
'red',
|
|
74
|
+
'ruby',
|
|
75
|
+
'crimson',
|
|
76
|
+
'pink',
|
|
77
|
+
'plum',
|
|
78
|
+
'purple',
|
|
79
|
+
'violet',
|
|
80
|
+
'iris',
|
|
81
|
+
'indigo',
|
|
82
|
+
'blue',
|
|
83
|
+
'cyan',
|
|
84
|
+
'teal',
|
|
85
|
+
'jade',
|
|
86
|
+
'green',
|
|
87
|
+
'grass',
|
|
88
|
+
'brown',
|
|
89
|
+
'orange',
|
|
90
|
+
'sky',
|
|
91
|
+
'mint',
|
|
92
|
+
'lime',
|
|
93
|
+
'yellow',
|
|
94
|
+
'amber',
|
|
95
|
+
'gold',
|
|
96
|
+
'bronze',
|
|
97
|
+
'gray',
|
|
98
|
+
])
|
|
99
|
+
.optional()
|
|
100
|
+
.describe('Accent color for the button'),
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* High contrast mode for better accessibility
|
|
104
|
+
* @default false
|
|
105
|
+
*/
|
|
106
|
+
highContrast: z
|
|
107
|
+
.boolean()
|
|
108
|
+
.optional()
|
|
109
|
+
.default(false)
|
|
110
|
+
.describe('High contrast mode for better accessibility'),
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Border radius for the button
|
|
114
|
+
*/
|
|
115
|
+
radius: z
|
|
116
|
+
.enum(['none', 'small', 'medium', 'large', 'full'])
|
|
117
|
+
.optional()
|
|
118
|
+
.describe('Border radius for the button'),
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Loading state that shows a spinner and disables interaction
|
|
122
|
+
* Automatically sets disabled=true and provides accessibility announcements
|
|
123
|
+
* @default false
|
|
124
|
+
*/
|
|
125
|
+
loading: z
|
|
126
|
+
.boolean()
|
|
127
|
+
.optional()
|
|
128
|
+
.default(false)
|
|
129
|
+
.describe('Loading state that shows a spinner and disables interaction'),
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Full width mode that expands the button to fill its container
|
|
133
|
+
* Useful for mobile layouts and form submissions
|
|
134
|
+
* @default false
|
|
135
|
+
*/
|
|
136
|
+
fullWidth: z
|
|
137
|
+
.boolean()
|
|
138
|
+
.optional()
|
|
139
|
+
.default(false)
|
|
140
|
+
.describe('Full width mode that expands the button to fill its container'),
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Material type for visual rendering and depth effects
|
|
144
|
+
* Controls how the button renders its visual elements
|
|
145
|
+
*/
|
|
146
|
+
material: z
|
|
147
|
+
.enum(['solid', 'translucent'])
|
|
148
|
+
.optional()
|
|
149
|
+
.describe('Material type for visual rendering and depth effects'),
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Panel background type (deprecated)
|
|
153
|
+
* @deprecated Use `material` prop instead. This prop will be removed in a future version.
|
|
154
|
+
*/
|
|
155
|
+
panelBackground: z
|
|
156
|
+
.enum(['solid', 'translucent'])
|
|
157
|
+
.optional()
|
|
158
|
+
.describe('Panel background type (deprecated - use material instead)'),
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Flush mode that removes visual padding for seamless text integration
|
|
162
|
+
* Only effective with ghost variant
|
|
163
|
+
* @default false
|
|
164
|
+
*/
|
|
165
|
+
flush: z
|
|
166
|
+
.boolean()
|
|
167
|
+
.optional()
|
|
168
|
+
.default(false)
|
|
169
|
+
.describe('Flush mode that removes visual padding for seamless text integration'),
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Disabled state
|
|
173
|
+
* @default false
|
|
174
|
+
*/
|
|
175
|
+
disabled: z.boolean().optional().default(false).describe('Disabled state'),
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Type attribute for form buttons
|
|
179
|
+
* @default 'button'
|
|
180
|
+
*/
|
|
181
|
+
type: z
|
|
182
|
+
.enum(['button', 'submit', 'reset'])
|
|
183
|
+
.optional()
|
|
184
|
+
.describe('Type attribute for form buttons'),
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Additional CSS class name
|
|
188
|
+
*/
|
|
189
|
+
className: z.string().optional().describe('Additional CSS class name'),
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Inline styles
|
|
193
|
+
*/
|
|
194
|
+
style: z
|
|
195
|
+
.record(z.string(), z.union([z.string(), z.number()]))
|
|
196
|
+
.optional()
|
|
197
|
+
.describe('Inline styles'),
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Click handler
|
|
201
|
+
*/
|
|
202
|
+
onClick: z.function().optional().describe('Click handler'),
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Focus handler
|
|
206
|
+
*/
|
|
207
|
+
onFocus: z.function().optional().describe('Focus handler'),
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Blur handler
|
|
211
|
+
*/
|
|
212
|
+
onBlur: z.function().optional().describe('Blur handler'),
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Mouse enter handler
|
|
216
|
+
*/
|
|
217
|
+
onMouseEnter: z.function().optional().describe('Mouse enter handler'),
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Mouse leave handler
|
|
221
|
+
*/
|
|
222
|
+
onMouseLeave: z.function().optional().describe('Mouse leave handler'),
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Key down handler
|
|
226
|
+
*/
|
|
227
|
+
onKeyDown: z.function().optional().describe('Key down handler'),
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Key up handler
|
|
231
|
+
*/
|
|
232
|
+
onKeyUp: z.function().optional().describe('Key up handler'),
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Form submission handler
|
|
236
|
+
*/
|
|
237
|
+
onSubmit: z.function().optional().describe('Form submission handler'),
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Tab index for keyboard navigation
|
|
241
|
+
*/
|
|
242
|
+
tabIndex: z.number().optional().describe('Tab index for keyboard navigation'),
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* ARIA label for accessibility
|
|
246
|
+
*/
|
|
247
|
+
'aria-label': z.string().optional().describe('ARIA label for accessibility'),
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* ARIA labelled by reference
|
|
251
|
+
*/
|
|
252
|
+
'aria-labelledby': z.string().optional().describe('ARIA labelled by reference'),
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* ARIA described by reference
|
|
256
|
+
*/
|
|
257
|
+
'aria-describedby': z.string().optional().describe('ARIA described by reference'),
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* ARIA expanded state
|
|
261
|
+
*/
|
|
262
|
+
'aria-expanded': z.boolean().optional().describe('ARIA expanded state'),
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* ARIA pressed state
|
|
266
|
+
*/
|
|
267
|
+
'aria-pressed': z.boolean().optional().describe('ARIA pressed state'),
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* ARIA current state
|
|
271
|
+
*/
|
|
272
|
+
'aria-current': z
|
|
273
|
+
.union([z.boolean(), z.enum(['page', 'step', 'location', 'date', 'time'])])
|
|
274
|
+
.optional()
|
|
275
|
+
.describe('ARIA current state'),
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* ARIA controls reference
|
|
279
|
+
*/
|
|
280
|
+
'aria-controls': z.string().optional().describe('ARIA controls reference'),
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* ARIA owns reference
|
|
284
|
+
*/
|
|
285
|
+
'aria-owns': z.string().optional().describe('ARIA owns reference'),
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Data attributes
|
|
289
|
+
*/
|
|
290
|
+
'data-*': z.record(z.string(), z.string()).optional().describe('Data attributes'),
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* ID attribute
|
|
294
|
+
*/
|
|
295
|
+
id: z.string().optional().describe('ID attribute'),
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Title attribute for tooltip
|
|
299
|
+
*/
|
|
300
|
+
title: z.string().optional().describe('Title attribute for tooltip'),
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Role attribute
|
|
304
|
+
*/
|
|
305
|
+
role: z.string().optional().describe('Role attribute'),
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Children elements
|
|
309
|
+
*/
|
|
310
|
+
children: z.any().optional().describe('Children elements'),
|
|
311
|
+
})
|
|
312
|
+
.strict();
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Type derived from BaseButton Zod schema
|
|
316
|
+
* This ensures type safety and consistency with the schema
|
|
317
|
+
*/
|
|
318
|
+
export type BaseButtonProps = z.infer<typeof BaseButtonSchema>;
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Development-only helper to validate and normalize props
|
|
322
|
+
* This function should only be used in development mode
|
|
323
|
+
*
|
|
324
|
+
* @param props - Props to validate and normalize
|
|
325
|
+
* @returns Validated and normalized props
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
* ```tsx
|
|
329
|
+
* // In development, this will validate props and show helpful errors
|
|
330
|
+
* const validatedProps = parseBaseButtonProps({ size: 'invalid', variant: 'solid' });
|
|
331
|
+
* // Throws: "Invalid enum value. Expected '1' | '2' | '3' | '4', received 'invalid'"
|
|
332
|
+
* ```
|
|
333
|
+
*/
|
|
334
|
+
export function parseBaseButtonProps(props: unknown): BaseButtonProps {
|
|
335
|
+
if (process.env.NODE_ENV === 'development') {
|
|
336
|
+
return BaseButtonSchema.parse(props);
|
|
337
|
+
}
|
|
338
|
+
return props as BaseButtonProps;
|
|
339
|
+
}
|