@page-speed/forms 0.4.1 → 0.4.2
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/dist/inputs.cjs +231 -119
- package/dist/inputs.cjs.map +1 -1
- package/dist/inputs.d.cts +13 -2
- package/dist/inputs.d.ts +13 -2
- package/dist/inputs.js +231 -119
- package/dist/inputs.js.map +1 -1
- package/package.json +4 -2
package/dist/inputs.cjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var React7 = require('react');
|
|
4
|
+
var clsx = require('clsx');
|
|
5
|
+
var tailwindMerge = require('tailwind-merge');
|
|
4
6
|
|
|
5
7
|
function _interopNamespace(e) {
|
|
6
8
|
if (e && e.__esModule) return e;
|
|
@@ -117,6 +119,11 @@ function TextArea({
|
|
|
117
119
|
);
|
|
118
120
|
}
|
|
119
121
|
TextArea.displayName = "TextArea";
|
|
122
|
+
function cn(...inputs) {
|
|
123
|
+
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// src/inputs/Checkbox.tsx
|
|
120
127
|
function Checkbox({
|
|
121
128
|
name,
|
|
122
129
|
value,
|
|
@@ -129,6 +136,7 @@ function Checkbox({
|
|
|
129
136
|
indeterminate = false,
|
|
130
137
|
label,
|
|
131
138
|
description,
|
|
139
|
+
checkboxVariant = "boxed",
|
|
132
140
|
...props
|
|
133
141
|
}) {
|
|
134
142
|
const inputRef = React7__namespace.useRef(null);
|
|
@@ -144,36 +152,92 @@ function Checkbox({
|
|
|
144
152
|
const handleBlur = () => {
|
|
145
153
|
onBlur?.();
|
|
146
154
|
};
|
|
147
|
-
const
|
|
148
|
-
|
|
155
|
+
const isActive = value || indeterminate && !value;
|
|
156
|
+
const checkbox = /* @__PURE__ */ React7__namespace.createElement(
|
|
157
|
+
"div",
|
|
149
158
|
{
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
159
|
+
className: cn(
|
|
160
|
+
"relative inline-flex items-center justify-center",
|
|
161
|
+
!label && className
|
|
162
|
+
)
|
|
163
|
+
},
|
|
164
|
+
/* @__PURE__ */ React7__namespace.createElement(
|
|
165
|
+
"input",
|
|
166
|
+
{
|
|
167
|
+
ref: inputRef,
|
|
168
|
+
type: "checkbox",
|
|
169
|
+
id: checkboxId,
|
|
170
|
+
name,
|
|
171
|
+
checked: value,
|
|
172
|
+
onChange: handleChange,
|
|
173
|
+
onBlur: handleBlur,
|
|
174
|
+
disabled,
|
|
175
|
+
required,
|
|
176
|
+
className: "peer sr-only",
|
|
177
|
+
"aria-invalid": error || props["aria-invalid"],
|
|
178
|
+
"aria-describedby": description ? `${checkboxId}-description` : props["aria-describedby"],
|
|
179
|
+
"aria-required": required || props["aria-required"],
|
|
180
|
+
...props
|
|
181
|
+
}
|
|
182
|
+
),
|
|
183
|
+
/* @__PURE__ */ React7__namespace.createElement(
|
|
184
|
+
"div",
|
|
185
|
+
{
|
|
186
|
+
className: cn(
|
|
187
|
+
"flex shrink-0 items-center justify-center rounded-full border-2 transition-colors size-6",
|
|
188
|
+
!error && isActive && "border-primary bg-primary text-primary-foreground",
|
|
189
|
+
!error && !isActive && "border-input bg-transparent",
|
|
190
|
+
error && isActive && "border-destructive bg-destructive text-destructive-foreground",
|
|
191
|
+
error && !isActive && "border-destructive bg-transparent",
|
|
192
|
+
disabled && "opacity-50",
|
|
193
|
+
"peer-focus-visible:ring-2 peer-focus-visible:ring-ring/50 peer-focus-visible:ring-offset-1"
|
|
194
|
+
)
|
|
195
|
+
},
|
|
196
|
+
value && /* @__PURE__ */ React7__namespace.createElement(
|
|
197
|
+
"svg",
|
|
198
|
+
{
|
|
199
|
+
className: "size-3.5",
|
|
200
|
+
viewBox: "0 0 24 24",
|
|
201
|
+
fill: "none",
|
|
202
|
+
stroke: "currentColor",
|
|
203
|
+
strokeWidth: "3",
|
|
204
|
+
strokeLinecap: "round",
|
|
205
|
+
strokeLinejoin: "round"
|
|
206
|
+
},
|
|
207
|
+
/* @__PURE__ */ React7__namespace.createElement("polyline", { points: "20 6 9 17 4 12" })
|
|
208
|
+
),
|
|
209
|
+
indeterminate && !value && /* @__PURE__ */ React7__namespace.createElement(
|
|
210
|
+
"svg",
|
|
211
|
+
{
|
|
212
|
+
className: "size-3.5",
|
|
213
|
+
viewBox: "0 0 24 24",
|
|
214
|
+
fill: "none",
|
|
215
|
+
stroke: "currentColor",
|
|
216
|
+
strokeWidth: "3",
|
|
217
|
+
strokeLinecap: "round",
|
|
218
|
+
strokeLinejoin: "round"
|
|
219
|
+
},
|
|
220
|
+
/* @__PURE__ */ React7__namespace.createElement("line", { x1: "5", y1: "12", x2: "19", y2: "12" })
|
|
221
|
+
)
|
|
222
|
+
)
|
|
223
|
+
);
|
|
166
224
|
if (label) {
|
|
167
225
|
return /* @__PURE__ */ React7__namespace.createElement(
|
|
168
226
|
"label",
|
|
169
227
|
{
|
|
170
|
-
className:
|
|
228
|
+
className: cn(
|
|
229
|
+
"w-full h-full flex gap-3 p-3 duration-200",
|
|
230
|
+
checkboxVariant === "boxed" && "border rounded-lg hover:ring-2",
|
|
231
|
+
checkboxVariant === "boxed" && value && "ring-2",
|
|
232
|
+
disabled ? "opacity-50 cursor-not-allowed hover:ring-0" : "cursor-pointer",
|
|
233
|
+
className
|
|
234
|
+
),
|
|
171
235
|
htmlFor: checkboxId
|
|
172
236
|
},
|
|
173
|
-
/* @__PURE__ */ React7__namespace.createElement("div", { className: "flex w-full flex-row
|
|
237
|
+
/* @__PURE__ */ React7__namespace.createElement("div", { className: "flex w-full flex-row gap-2" }, checkbox, /* @__PURE__ */ React7__namespace.createElement("div", { className: "flex flex-col gap-0.5" }, /* @__PURE__ */ React7__namespace.createElement("div", { className: "text-sm font-medium" }, label), description && /* @__PURE__ */ React7__namespace.createElement(
|
|
174
238
|
"p",
|
|
175
239
|
{
|
|
176
|
-
className: "text-
|
|
240
|
+
className: "text-xs opacity-75",
|
|
177
241
|
id: `${checkboxId}-description`
|
|
178
242
|
},
|
|
179
243
|
description
|
|
@@ -211,6 +275,18 @@ function CheckboxGroup({
|
|
|
211
275
|
).length;
|
|
212
276
|
const allSelected = selectedEnabledCount === enabledOptions.length;
|
|
213
277
|
const someSelected = selectedEnabledCount > 0 && !allSelected;
|
|
278
|
+
const checkboxVariant = React7__namespace.useMemo(() => {
|
|
279
|
+
if (options.some((opt) => opt.description)) {
|
|
280
|
+
return "boxed";
|
|
281
|
+
}
|
|
282
|
+
return "inline";
|
|
283
|
+
}, [options]);
|
|
284
|
+
const countableValue = React7__namespace.useMemo(() => {
|
|
285
|
+
if (value?.length > 0) {
|
|
286
|
+
return value.length;
|
|
287
|
+
}
|
|
288
|
+
return 0;
|
|
289
|
+
}, [value]);
|
|
214
290
|
const handleChange = (optionValue, checked) => {
|
|
215
291
|
const newValues = checked ? [...value, optionValue] : value.filter((v) => v !== optionValue);
|
|
216
292
|
if (maxSelections && checked && newValues.length > maxSelections) {
|
|
@@ -229,9 +305,14 @@ function CheckboxGroup({
|
|
|
229
305
|
const handleBlur = () => {
|
|
230
306
|
onBlur?.();
|
|
231
307
|
};
|
|
232
|
-
const
|
|
233
|
-
const containerClass =
|
|
234
|
-
|
|
308
|
+
const maxReached = Boolean(maxSelections && countableValue >= maxSelections);
|
|
309
|
+
const containerClass = cn(
|
|
310
|
+
"w-full gap-3",
|
|
311
|
+
layout === "stacked" && "flex flex-col",
|
|
312
|
+
layout === "inline" && "flex flex-row flex-wrap",
|
|
313
|
+
layout === "grid" && "grid",
|
|
314
|
+
className
|
|
315
|
+
);
|
|
235
316
|
return /* @__PURE__ */ React7__namespace.createElement(
|
|
236
317
|
"div",
|
|
237
318
|
{
|
|
@@ -248,65 +329,53 @@ function CheckboxGroup({
|
|
|
248
329
|
label && /* @__PURE__ */ React7__namespace.createElement("div", { className: "text-sm font-medium" }, label),
|
|
249
330
|
description && /* @__PURE__ */ React7__namespace.createElement("div", { className: "text-muted-foreground text-sm" }, description),
|
|
250
331
|
showSelectAll && enabledOptions.length > 0 && /* @__PURE__ */ React7__namespace.createElement(
|
|
251
|
-
|
|
332
|
+
Checkbox,
|
|
252
333
|
{
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
},
|
|
265
|
-
onChange: (e) => handleSelectAll(e.target.checked),
|
|
266
|
-
onBlur: handleBlur,
|
|
267
|
-
disabled,
|
|
268
|
-
className: "peer relative flex size-4 shrink-0 appearance-none items-center justify-center rounded-lg border border-input bg-transparent outline-none transition-colors focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50",
|
|
269
|
-
"aria-label": selectAllLabel
|
|
270
|
-
}
|
|
271
|
-
), allSelected && /* @__PURE__ */ React7__namespace.createElement("span", { className: "pointer-events-none absolute top-1/2 left-1/2 flex -translate-x-1/2 -translate-y-1/2 items-center justify-center text-primary-foreground" }, /* @__PURE__ */ React7__namespace.createElement("svg", { className: "size-3", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "3" }, /* @__PURE__ */ React7__namespace.createElement("polyline", { points: "20 6 9 17 4 12" }))), someSelected && !allSelected && /* @__PURE__ */ React7__namespace.createElement("span", { className: "pointer-events-none absolute top-1/2 left-1/2 flex -translate-x-1/2 -translate-y-1/2 items-center justify-center text-primary" }, /* @__PURE__ */ React7__namespace.createElement("svg", { className: "size-3", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "3" }, /* @__PURE__ */ React7__namespace.createElement("line", { x1: "5", y1: "12", x2: "19", y2: "12" })))), /* @__PURE__ */ React7__namespace.createElement("span", { className: "text-sm font-medium" }, selectAllLabel))
|
|
334
|
+
name: `${name}-select-all`,
|
|
335
|
+
id: `${name}-select-all`,
|
|
336
|
+
value: allSelected,
|
|
337
|
+
onChange: handleSelectAll,
|
|
338
|
+
onBlur: handleBlur,
|
|
339
|
+
indeterminate: someSelected,
|
|
340
|
+
label: selectAllLabel,
|
|
341
|
+
checkboxVariant: "inline",
|
|
342
|
+
disabled,
|
|
343
|
+
"aria-label": selectAllLabel
|
|
344
|
+
}
|
|
272
345
|
),
|
|
273
346
|
options.map((option) => {
|
|
274
347
|
const isChecked = value.includes(option.value);
|
|
275
348
|
const isDisabled = disabled || option.disabled || maxReached && !isChecked;
|
|
276
|
-
const checkboxId = `${name}-${option.value}`;
|
|
277
349
|
return /* @__PURE__ */ React7__namespace.createElement(
|
|
278
|
-
|
|
350
|
+
Checkbox,
|
|
279
351
|
{
|
|
280
352
|
key: option.value,
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
onBlur: handleBlur,
|
|
294
|
-
disabled: isDisabled,
|
|
295
|
-
required: required && minSelections ? value.length < minSelections : false,
|
|
296
|
-
className: `peer relative flex size-4 shrink-0 appearance-none items-center justify-center rounded-lg border border-input bg-transparent outline-none transition-colors focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 ${error ? "border-destructive ring-3 ring-destructive/20" : ""} ${isChecked ? "bg-primary border-primary" : ""}`,
|
|
297
|
-
"aria-describedby": option.description ? `${checkboxId}-description` : props["aria-describedby"]
|
|
298
|
-
}
|
|
299
|
-
), isChecked && /* @__PURE__ */ React7__namespace.createElement("span", { className: "pointer-events-none absolute top-1/2 left-1/2 flex -translate-x-1/2 -translate-y-1/2 items-center justify-center text-primary-foreground" }, /* @__PURE__ */ React7__namespace.createElement("svg", { className: "size-3", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "3" }, /* @__PURE__ */ React7__namespace.createElement("polyline", { points: "20 6 9 17 4 12" })))), /* @__PURE__ */ React7__namespace.createElement("div", { className: "flex flex-1 flex-col gap-0.5" }, renderOption ? renderOption(option) : /* @__PURE__ */ React7__namespace.createElement(React7__namespace.Fragment, null, /* @__PURE__ */ React7__namespace.createElement("div", { className: "flex items-center gap-2 text-sm font-medium" }, option.label), option.description && /* @__PURE__ */ React7__namespace.createElement(
|
|
300
|
-
"p",
|
|
301
|
-
{
|
|
302
|
-
className: "text-muted-foreground text-sm",
|
|
303
|
-
id: `${checkboxId}-description`
|
|
304
|
-
},
|
|
305
|
-
option.description
|
|
306
|
-
))))
|
|
353
|
+
name,
|
|
354
|
+
id: `${name}-${option.value}`,
|
|
355
|
+
value: isChecked,
|
|
356
|
+
onChange: (checked) => handleChange(option.value, checked),
|
|
357
|
+
onBlur: handleBlur,
|
|
358
|
+
disabled: isDisabled,
|
|
359
|
+
required: required && minSelections ? value.length < minSelections : false,
|
|
360
|
+
error,
|
|
361
|
+
label: renderOption ? renderOption(option) : option.label,
|
|
362
|
+
description: renderOption ? void 0 : option.description,
|
|
363
|
+
checkboxVariant
|
|
364
|
+
}
|
|
307
365
|
);
|
|
308
366
|
}),
|
|
309
|
-
(minSelections || maxSelections) && /* @__PURE__ */ React7__namespace.createElement(
|
|
367
|
+
(minSelections || maxSelections) && /* @__PURE__ */ React7__namespace.createElement(
|
|
368
|
+
"div",
|
|
369
|
+
{
|
|
370
|
+
className: cn(
|
|
371
|
+
"text-sm p-2 rounded-lg border font-semibold mt-2",
|
|
372
|
+
minSelections && countableValue < minSelections ? "border-destructive bg-destructive/80 text-destructive-foreground" : "border-border bg-card text-card-foreground"
|
|
373
|
+
),
|
|
374
|
+
"aria-live": "polite"
|
|
375
|
+
},
|
|
376
|
+
minSelections && countableValue < minSelections && /* @__PURE__ */ React7__namespace.createElement("span", null, "Select at least ", minSelections, " option", minSelections !== 1 ? "s" : ""),
|
|
377
|
+
maxSelections && /* @__PURE__ */ React7__namespace.createElement("span", null, countableValue, "/", maxSelections, " selected")
|
|
378
|
+
)
|
|
310
379
|
);
|
|
311
380
|
}
|
|
312
381
|
CheckboxGroup.displayName = "CheckboxGroup";
|
|
@@ -320,6 +389,7 @@ function Radio({
|
|
|
320
389
|
error = false,
|
|
321
390
|
className = "",
|
|
322
391
|
layout = "stacked",
|
|
392
|
+
radioVariant = "inline",
|
|
323
393
|
label,
|
|
324
394
|
options,
|
|
325
395
|
...props
|
|
@@ -355,8 +425,12 @@ function Radio({
|
|
|
355
425
|
const handleBlur = () => {
|
|
356
426
|
onBlur?.();
|
|
357
427
|
};
|
|
358
|
-
const
|
|
359
|
-
|
|
428
|
+
const containerClass = cn(
|
|
429
|
+
"w-full gap-3",
|
|
430
|
+
layout === "stacked" && "flex flex-col",
|
|
431
|
+
layout === "inline" && "flex flex-row flex-wrap",
|
|
432
|
+
className
|
|
433
|
+
);
|
|
360
434
|
return /* @__PURE__ */ React7__namespace.createElement(
|
|
361
435
|
"div",
|
|
362
436
|
{
|
|
@@ -372,38 +446,60 @@ function Radio({
|
|
|
372
446
|
const isChecked = value === option.value;
|
|
373
447
|
const isDisabled = disabled || option.disabled;
|
|
374
448
|
const radioId = `${name}-${option.value}`;
|
|
449
|
+
const hasDescription = option.description != null && option.description !== "";
|
|
450
|
+
const radioIndicator = /* @__PURE__ */ React7__namespace.createElement("div", { className: "relative inline-flex items-center justify-center" }, /* @__PURE__ */ React7__namespace.createElement(
|
|
451
|
+
"input",
|
|
452
|
+
{
|
|
453
|
+
type: "radio",
|
|
454
|
+
id: radioId,
|
|
455
|
+
name,
|
|
456
|
+
value: option.value,
|
|
457
|
+
checked: isChecked,
|
|
458
|
+
onChange: (e) => handleChange(e.target.value),
|
|
459
|
+
onBlur: handleBlur,
|
|
460
|
+
disabled: isDisabled,
|
|
461
|
+
required,
|
|
462
|
+
className: "peer sr-only",
|
|
463
|
+
"aria-describedby": hasDescription ? `${radioId}-description` : props["aria-describedby"]
|
|
464
|
+
}
|
|
465
|
+
), /* @__PURE__ */ React7__namespace.createElement(
|
|
466
|
+
"div",
|
|
467
|
+
{
|
|
468
|
+
className: cn(
|
|
469
|
+
"flex shrink-0 items-center justify-center rounded-full border-2 transition-colors size-6",
|
|
470
|
+
!error && isChecked && "border-primary bg-transparent",
|
|
471
|
+
!error && !isChecked && "border-input bg-transparent",
|
|
472
|
+
error && isChecked && "border-destructive bg-transparent",
|
|
473
|
+
error && !isChecked && "border-destructive bg-transparent",
|
|
474
|
+
isDisabled && "opacity-50",
|
|
475
|
+
"peer-focus-visible:ring-2 peer-focus-visible:ring-ring/50 peer-focus-visible:ring-offset-1"
|
|
476
|
+
)
|
|
477
|
+
},
|
|
478
|
+
isChecked && /* @__PURE__ */ React7__namespace.createElement("div", { className: "size-3 rounded-full bg-primary" })
|
|
479
|
+
));
|
|
480
|
+
const labelContent = /* @__PURE__ */ React7__namespace.createElement("div", { className: "flex flex-col gap-0.5" }, /* @__PURE__ */ React7__namespace.createElement("div", { className: "text-sm font-medium" }, option.label), hasDescription && /* @__PURE__ */ React7__namespace.createElement(
|
|
481
|
+
"p",
|
|
482
|
+
{
|
|
483
|
+
className: "text-xs opacity-75",
|
|
484
|
+
id: `${radioId}-description`
|
|
485
|
+
},
|
|
486
|
+
option.description
|
|
487
|
+
));
|
|
375
488
|
return /* @__PURE__ */ React7__namespace.createElement(
|
|
376
489
|
"label",
|
|
377
490
|
{
|
|
378
491
|
key: option.value,
|
|
379
|
-
className:
|
|
492
|
+
className: cn(
|
|
493
|
+
"w-full h-full flex gap-3 p-3 duration-200",
|
|
494
|
+
radioVariant === "boxed" && "border rounded-lg hover:ring-2",
|
|
495
|
+
radioVariant === "boxed" && isChecked && "ring-2",
|
|
496
|
+
isDisabled ? "opacity-50 cursor-not-allowed hover:ring-0" : "cursor-pointer"
|
|
497
|
+
),
|
|
380
498
|
htmlFor: radioId,
|
|
381
499
|
onKeyDown: (e) => handleKeyDown(e, index),
|
|
382
500
|
tabIndex: isDisabled ? -1 : 0
|
|
383
501
|
},
|
|
384
|
-
/* @__PURE__ */ React7__namespace.createElement("div", { className: "flex w-full flex-row items-center gap-2" }, /* @__PURE__ */ React7__namespace.createElement("div", { className: "flex flex-1 flex-col gap-0.5" },
|
|
385
|
-
"p",
|
|
386
|
-
{
|
|
387
|
-
className: "text-muted-foreground text-sm",
|
|
388
|
-
id: `${radioId}-description`
|
|
389
|
-
},
|
|
390
|
-
option.description
|
|
391
|
-
)) : /* @__PURE__ */ React7__namespace.createElement("span", { className: "text-sm font-medium" }, option.label)), /* @__PURE__ */ React7__namespace.createElement("div", { className: "relative" }, /* @__PURE__ */ React7__namespace.createElement(
|
|
392
|
-
"input",
|
|
393
|
-
{
|
|
394
|
-
type: "radio",
|
|
395
|
-
id: radioId,
|
|
396
|
-
name,
|
|
397
|
-
value: option.value,
|
|
398
|
-
checked: isChecked,
|
|
399
|
-
onChange: (e) => handleChange(e.target.value),
|
|
400
|
-
onBlur: handleBlur,
|
|
401
|
-
disabled: isDisabled,
|
|
402
|
-
required,
|
|
403
|
-
className: `peer relative flex aspect-square size-4 shrink-0 appearance-none rounded-full border border-input outline-none transition-colors focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 ${error ? "border-destructive" : ""} ${isChecked ? "border-primary bg-primary" : "bg-transparent"}`,
|
|
404
|
-
"aria-describedby": option.description ? `${radioId}-description` : props["aria-describedby"]
|
|
405
|
-
}
|
|
406
|
-
), isChecked && /* @__PURE__ */ React7__namespace.createElement("span", { className: "pointer-events-none absolute top-1/2 left-1/2 flex size-4 -translate-x-1/2 -translate-y-1/2 items-center justify-center text-primary-foreground" }, /* @__PURE__ */ React7__namespace.createElement("svg", { className: "size-2 fill-current", viewBox: "0 0 24 24" }, /* @__PURE__ */ React7__namespace.createElement("circle", { cx: "12", cy: "12", r: "10" })))))
|
|
502
|
+
/* @__PURE__ */ React7__namespace.createElement("div", { className: "flex w-full flex-row items-center gap-2" }, radioVariant === "inline" && radioIndicator, /* @__PURE__ */ React7__namespace.createElement("div", { className: "flex flex-1 flex-col gap-0.5" }, labelContent), radioVariant === "boxed" && radioIndicator)
|
|
407
503
|
);
|
|
408
504
|
})
|
|
409
505
|
);
|
|
@@ -1253,7 +1349,9 @@ function DatePicker({
|
|
|
1253
1349
|
}) {
|
|
1254
1350
|
const [isOpen, setIsOpen] = React7__namespace.useState(false);
|
|
1255
1351
|
const [inputValue, setInputValue] = React7__namespace.useState("");
|
|
1256
|
-
const [selectedMonth, setSelectedMonth] = React7__namespace.useState(
|
|
1352
|
+
const [selectedMonth, setSelectedMonth] = React7__namespace.useState(
|
|
1353
|
+
value || /* @__PURE__ */ new Date()
|
|
1354
|
+
);
|
|
1257
1355
|
const containerRef = React7__namespace.useRef(null);
|
|
1258
1356
|
const inputRef = React7__namespace.useRef(null);
|
|
1259
1357
|
React7__namespace.useEffect(() => {
|
|
@@ -1344,7 +1442,7 @@ function DatePicker({
|
|
|
1344
1442
|
"button",
|
|
1345
1443
|
{
|
|
1346
1444
|
type: "button",
|
|
1347
|
-
className: "flex items-center justify-center h-8 w-8 rounded border-none bg-transparent hover:bg-
|
|
1445
|
+
className: "flex items-center justify-center h-8 w-8 rounded border-none bg-transparent hover:bg-primary hover:text-primary-foreground cursor-pointer",
|
|
1348
1446
|
onClick: handlePrevMonth,
|
|
1349
1447
|
"aria-label": "Previous month"
|
|
1350
1448
|
},
|
|
@@ -1353,12 +1451,19 @@ function DatePicker({
|
|
|
1353
1451
|
"button",
|
|
1354
1452
|
{
|
|
1355
1453
|
type: "button",
|
|
1356
|
-
className: "flex items-center justify-center h-8 w-8 rounded border-none bg-transparent hover:bg-
|
|
1454
|
+
className: "flex items-center justify-center h-8 w-8 rounded border-none bg-transparent hover:bg-primary hover:text-primary-foreground cursor-pointer",
|
|
1357
1455
|
onClick: handleNextMonth,
|
|
1358
1456
|
"aria-label": "Next month"
|
|
1359
1457
|
},
|
|
1360
1458
|
"\u2192"
|
|
1361
|
-
)), /* @__PURE__ */ React7__namespace.createElement("div", { className: "grid grid-cols-7 gap-1 mt-2" }, ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"].map((day) => /* @__PURE__ */ React7__namespace.createElement(
|
|
1459
|
+
)), /* @__PURE__ */ React7__namespace.createElement("div", { className: "grid grid-cols-7 gap-1 mt-2" }, ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"].map((day) => /* @__PURE__ */ React7__namespace.createElement(
|
|
1460
|
+
"div",
|
|
1461
|
+
{
|
|
1462
|
+
key: day,
|
|
1463
|
+
className: "flex items-center justify-center h-8 w-full text-xs font-medium"
|
|
1464
|
+
},
|
|
1465
|
+
day
|
|
1466
|
+
))), /* @__PURE__ */ React7__namespace.createElement("div", { className: "grid grid-cols-7 gap-1" }, days.map((date, index) => {
|
|
1362
1467
|
if (!date) {
|
|
1363
1468
|
return /* @__PURE__ */ React7__namespace.createElement("div", { key: `empty-${index}` });
|
|
1364
1469
|
}
|
|
@@ -1370,7 +1475,7 @@ function DatePicker({
|
|
|
1370
1475
|
{
|
|
1371
1476
|
key: date.toISOString(),
|
|
1372
1477
|
type: "button",
|
|
1373
|
-
className: `flex items-center justify-center h-8 w-full rounded border-none bg-transparent cursor-pointer text-sm transition-colors hover:bg-
|
|
1478
|
+
className: `flex items-center justify-center h-8 w-full rounded border-none bg-transparent cursor-pointer text-sm transition-colors hover:bg-primary hover:text-primary-foreground ${isSelected ? "bg-primary text-primary-foreground font-semibold" : ""} ${isToday ? "border border-primary" : ""} ${disabled2 ? "cursor-not-allowed opacity-50 pointer-events-none" : ""}`,
|
|
1374
1479
|
onClick: () => !disabled2 && handleDateSelect(date),
|
|
1375
1480
|
disabled: disabled2,
|
|
1376
1481
|
"aria-label": formatDate(date, format)
|
|
@@ -1387,26 +1492,33 @@ function DatePicker({
|
|
|
1387
1492
|
name,
|
|
1388
1493
|
value: value ? value.toISOString() : ""
|
|
1389
1494
|
}
|
|
1390
|
-
), /* @__PURE__ */ React7__namespace.createElement("div", { className: "relative" }, showIcon && /* @__PURE__ */ React7__namespace.createElement(
|
|
1391
|
-
"
|
|
1495
|
+
), /* @__PURE__ */ React7__namespace.createElement("div", { className: "relative" }, showIcon && /* @__PURE__ */ React7__namespace.createElement(
|
|
1496
|
+
"span",
|
|
1392
1497
|
{
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
height: "18",
|
|
1396
|
-
viewBox: "0 0 24 24",
|
|
1397
|
-
fill: "none",
|
|
1398
|
-
stroke: "currentColor",
|
|
1399
|
-
strokeLinecap: "round",
|
|
1400
|
-
strokeLinejoin: "round",
|
|
1401
|
-
strokeWidth: "2"
|
|
1498
|
+
className: "absolute left-3 top-1/2 -translate-y-1/2 pointer-events-none",
|
|
1499
|
+
"aria-hidden": "true"
|
|
1402
1500
|
},
|
|
1403
|
-
/* @__PURE__ */ React7__namespace.createElement(
|
|
1404
|
-
|
|
1501
|
+
/* @__PURE__ */ React7__namespace.createElement(
|
|
1502
|
+
"svg",
|
|
1503
|
+
{
|
|
1504
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1505
|
+
width: "18",
|
|
1506
|
+
height: "18",
|
|
1507
|
+
viewBox: "0 0 24 24",
|
|
1508
|
+
fill: "none",
|
|
1509
|
+
stroke: "currentColor",
|
|
1510
|
+
strokeLinecap: "round",
|
|
1511
|
+
strokeLinejoin: "round",
|
|
1512
|
+
strokeWidth: "2"
|
|
1513
|
+
},
|
|
1514
|
+
/* @__PURE__ */ React7__namespace.createElement("path", { d: "M8 2v4m8-4v4m5 8V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8M3 10h18m-5 10l2 2l4-4" })
|
|
1515
|
+
)
|
|
1516
|
+
), /* @__PURE__ */ React7__namespace.createElement(
|
|
1405
1517
|
"input",
|
|
1406
1518
|
{
|
|
1407
1519
|
ref: inputRef,
|
|
1408
1520
|
type: "text",
|
|
1409
|
-
className: `flex h-9 w-full rounded-md border border-input bg-transparent ${showIcon ? "pl-10" : "pl-3"} ${clearable && value ? "pr-10" : "pr-3"} py-1 text-base shadow-sm transition-colors
|
|
1521
|
+
className: `flex h-9 w-full rounded-md border border-input bg-transparent ${showIcon ? "pl-10" : "pl-3"} ${clearable && value ? "pr-10" : "pr-3"} py-1 text-base shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm ${error ? "border-red-500 ring-1 ring-red-500" : ""}`,
|
|
1410
1522
|
value: inputValue,
|
|
1411
1523
|
onChange: handleInputChange,
|
|
1412
1524
|
onClick: handleToggle,
|
|
@@ -1423,7 +1535,7 @@ function DatePicker({
|
|
|
1423
1535
|
"button",
|
|
1424
1536
|
{
|
|
1425
1537
|
type: "button",
|
|
1426
|
-
className: "absolute right-3 top-1/2 -translate-y-1/2
|
|
1538
|
+
className: "absolute right-3 top-1/2 -translate-y-1/2 transition-colors",
|
|
1427
1539
|
onClick: handleClear,
|
|
1428
1540
|
"aria-label": "Clear date",
|
|
1429
1541
|
tabIndex: -1
|