@page-speed/forms 0.3.7 → 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/core.cjs +2 -2
- package/dist/core.cjs.map +1 -1
- package/dist/core.js +2 -2
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/inputs.cjs +335 -237
- 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 +335 -237
- package/dist/inputs.js.map +1 -1
- package/package.json +4 -2
package/dist/inputs.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import * as React7 from 'react';
|
|
2
|
+
import { clsx } from 'clsx';
|
|
3
|
+
import { twMerge } from 'tailwind-merge';
|
|
2
4
|
|
|
3
5
|
// src/inputs/TextInput.tsx
|
|
4
6
|
function TextInput({
|
|
@@ -21,8 +23,8 @@ function TextInput({
|
|
|
21
23
|
const handleBlur = () => {
|
|
22
24
|
onBlur?.();
|
|
23
25
|
};
|
|
24
|
-
const baseClassName = "text-
|
|
25
|
-
const errorClassName = error ? "
|
|
26
|
+
const baseClassName = "flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm";
|
|
27
|
+
const errorClassName = error ? "border-red-500 ring-1 ring-red-500" : "";
|
|
26
28
|
const combinedClassName = `${baseClassName} ${errorClassName} ${className}`.trim();
|
|
27
29
|
return /* @__PURE__ */ React7.createElement(
|
|
28
30
|
"input",
|
|
@@ -68,8 +70,8 @@ function TextArea({
|
|
|
68
70
|
const handleBlur = () => {
|
|
69
71
|
onBlur?.();
|
|
70
72
|
};
|
|
71
|
-
const baseClassName = "
|
|
72
|
-
const errorClassName = error ? "
|
|
73
|
+
const baseClassName = "flex min-h-20 w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm";
|
|
74
|
+
const errorClassName = error ? "border-red-500 ring-1 ring-red-500" : "";
|
|
73
75
|
const combinedClassName = `${baseClassName} ${errorClassName} ${className}`.trim();
|
|
74
76
|
return /* @__PURE__ */ React7.createElement(
|
|
75
77
|
"textarea",
|
|
@@ -95,6 +97,11 @@ function TextArea({
|
|
|
95
97
|
);
|
|
96
98
|
}
|
|
97
99
|
TextArea.displayName = "TextArea";
|
|
100
|
+
function cn(...inputs) {
|
|
101
|
+
return twMerge(clsx(inputs));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// src/inputs/Checkbox.tsx
|
|
98
105
|
function Checkbox({
|
|
99
106
|
name,
|
|
100
107
|
value,
|
|
@@ -107,6 +114,7 @@ function Checkbox({
|
|
|
107
114
|
indeterminate = false,
|
|
108
115
|
label,
|
|
109
116
|
description,
|
|
117
|
+
checkboxVariant = "boxed",
|
|
110
118
|
...props
|
|
111
119
|
}) {
|
|
112
120
|
const inputRef = React7.useRef(null);
|
|
@@ -122,39 +130,97 @@ function Checkbox({
|
|
|
122
130
|
const handleBlur = () => {
|
|
123
131
|
onBlur?.();
|
|
124
132
|
};
|
|
125
|
-
const
|
|
126
|
-
const errorClassName = error ? "checkbox--error" : "";
|
|
127
|
-
const checkedClassName = value ? "checkbox--checked" : "";
|
|
128
|
-
const disabledClassName = disabled ? "checkbox--disabled" : "";
|
|
129
|
-
const combinedClassName = `${baseClassName} ${errorClassName} ${checkedClassName} ${disabledClassName} ${className}`.trim();
|
|
133
|
+
const isActive = value || indeterminate && !value;
|
|
130
134
|
const checkbox = /* @__PURE__ */ React7.createElement(
|
|
131
|
-
"
|
|
135
|
+
"div",
|
|
132
136
|
{
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
137
|
+
className: cn(
|
|
138
|
+
"relative inline-flex items-center justify-center",
|
|
139
|
+
!label && className
|
|
140
|
+
)
|
|
141
|
+
},
|
|
142
|
+
/* @__PURE__ */ React7.createElement(
|
|
143
|
+
"input",
|
|
144
|
+
{
|
|
145
|
+
ref: inputRef,
|
|
146
|
+
type: "checkbox",
|
|
147
|
+
id: checkboxId,
|
|
148
|
+
name,
|
|
149
|
+
checked: value,
|
|
150
|
+
onChange: handleChange,
|
|
151
|
+
onBlur: handleBlur,
|
|
152
|
+
disabled,
|
|
153
|
+
required,
|
|
154
|
+
className: "peer sr-only",
|
|
155
|
+
"aria-invalid": error || props["aria-invalid"],
|
|
156
|
+
"aria-describedby": description ? `${checkboxId}-description` : props["aria-describedby"],
|
|
157
|
+
"aria-required": required || props["aria-required"],
|
|
158
|
+
...props
|
|
159
|
+
}
|
|
160
|
+
),
|
|
161
|
+
/* @__PURE__ */ React7.createElement(
|
|
162
|
+
"div",
|
|
163
|
+
{
|
|
164
|
+
className: cn(
|
|
165
|
+
"flex shrink-0 items-center justify-center rounded-full border-2 transition-colors size-6",
|
|
166
|
+
!error && isActive && "border-primary bg-primary text-primary-foreground",
|
|
167
|
+
!error && !isActive && "border-input bg-transparent",
|
|
168
|
+
error && isActive && "border-destructive bg-destructive text-destructive-foreground",
|
|
169
|
+
error && !isActive && "border-destructive bg-transparent",
|
|
170
|
+
disabled && "opacity-50",
|
|
171
|
+
"peer-focus-visible:ring-2 peer-focus-visible:ring-ring/50 peer-focus-visible:ring-offset-1"
|
|
172
|
+
)
|
|
173
|
+
},
|
|
174
|
+
value && /* @__PURE__ */ React7.createElement(
|
|
175
|
+
"svg",
|
|
176
|
+
{
|
|
177
|
+
className: "size-3.5",
|
|
178
|
+
viewBox: "0 0 24 24",
|
|
179
|
+
fill: "none",
|
|
180
|
+
stroke: "currentColor",
|
|
181
|
+
strokeWidth: "3",
|
|
182
|
+
strokeLinecap: "round",
|
|
183
|
+
strokeLinejoin: "round"
|
|
184
|
+
},
|
|
185
|
+
/* @__PURE__ */ React7.createElement("polyline", { points: "20 6 9 17 4 12" })
|
|
186
|
+
),
|
|
187
|
+
indeterminate && !value && /* @__PURE__ */ React7.createElement(
|
|
188
|
+
"svg",
|
|
189
|
+
{
|
|
190
|
+
className: "size-3.5",
|
|
191
|
+
viewBox: "0 0 24 24",
|
|
192
|
+
fill: "none",
|
|
193
|
+
stroke: "currentColor",
|
|
194
|
+
strokeWidth: "3",
|
|
195
|
+
strokeLinecap: "round",
|
|
196
|
+
strokeLinejoin: "round"
|
|
197
|
+
},
|
|
198
|
+
/* @__PURE__ */ React7.createElement("line", { x1: "5", y1: "12", x2: "19", y2: "12" })
|
|
199
|
+
)
|
|
200
|
+
)
|
|
148
201
|
);
|
|
149
202
|
if (label) {
|
|
150
|
-
return /* @__PURE__ */ React7.createElement(
|
|
151
|
-
"
|
|
203
|
+
return /* @__PURE__ */ React7.createElement(
|
|
204
|
+
"label",
|
|
152
205
|
{
|
|
153
|
-
className:
|
|
154
|
-
|
|
206
|
+
className: cn(
|
|
207
|
+
"w-full h-full flex gap-3 p-3 duration-200",
|
|
208
|
+
checkboxVariant === "boxed" && "border rounded-lg hover:ring-2",
|
|
209
|
+
checkboxVariant === "boxed" && value && "ring-2",
|
|
210
|
+
disabled ? "opacity-50 cursor-not-allowed hover:ring-0" : "cursor-pointer",
|
|
211
|
+
className
|
|
212
|
+
),
|
|
213
|
+
htmlFor: checkboxId
|
|
155
214
|
},
|
|
156
|
-
description
|
|
157
|
-
|
|
215
|
+
/* @__PURE__ */ React7.createElement("div", { className: "flex w-full flex-row gap-2" }, checkbox, /* @__PURE__ */ React7.createElement("div", { className: "flex flex-col gap-0.5" }, /* @__PURE__ */ React7.createElement("div", { className: "text-sm font-medium" }, label), description && /* @__PURE__ */ React7.createElement(
|
|
216
|
+
"p",
|
|
217
|
+
{
|
|
218
|
+
className: "text-xs opacity-75",
|
|
219
|
+
id: `${checkboxId}-description`
|
|
220
|
+
},
|
|
221
|
+
description
|
|
222
|
+
)))
|
|
223
|
+
);
|
|
158
224
|
}
|
|
159
225
|
return checkbox;
|
|
160
226
|
}
|
|
@@ -187,6 +253,18 @@ function CheckboxGroup({
|
|
|
187
253
|
).length;
|
|
188
254
|
const allSelected = selectedEnabledCount === enabledOptions.length;
|
|
189
255
|
const someSelected = selectedEnabledCount > 0 && !allSelected;
|
|
256
|
+
const checkboxVariant = React7.useMemo(() => {
|
|
257
|
+
if (options.some((opt) => opt.description)) {
|
|
258
|
+
return "boxed";
|
|
259
|
+
}
|
|
260
|
+
return "inline";
|
|
261
|
+
}, [options]);
|
|
262
|
+
const countableValue = React7.useMemo(() => {
|
|
263
|
+
if (value?.length > 0) {
|
|
264
|
+
return value.length;
|
|
265
|
+
}
|
|
266
|
+
return 0;
|
|
267
|
+
}, [value]);
|
|
190
268
|
const handleChange = (optionValue, checked) => {
|
|
191
269
|
const newValues = checked ? [...value, optionValue] : value.filter((v) => v !== optionValue);
|
|
192
270
|
if (maxSelections && checked && newValues.length > maxSelections) {
|
|
@@ -205,15 +283,18 @@ function CheckboxGroup({
|
|
|
205
283
|
const handleBlur = () => {
|
|
206
284
|
onBlur?.();
|
|
207
285
|
};
|
|
208
|
-
const
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
286
|
+
const maxReached = Boolean(maxSelections && countableValue >= maxSelections);
|
|
287
|
+
const containerClass = cn(
|
|
288
|
+
"w-full gap-3",
|
|
289
|
+
layout === "stacked" && "flex flex-col",
|
|
290
|
+
layout === "inline" && "flex flex-row flex-wrap",
|
|
291
|
+
layout === "grid" && "grid",
|
|
292
|
+
className
|
|
293
|
+
);
|
|
213
294
|
return /* @__PURE__ */ React7.createElement(
|
|
214
295
|
"div",
|
|
215
296
|
{
|
|
216
|
-
className:
|
|
297
|
+
className: containerClass,
|
|
217
298
|
role: "group",
|
|
218
299
|
"aria-invalid": error || props["aria-invalid"],
|
|
219
300
|
"aria-describedby": props["aria-describedby"],
|
|
@@ -223,62 +304,56 @@ function CheckboxGroup({
|
|
|
223
304
|
gridTemplateColumns: `repeat(${gridColumns}, 1fr)`
|
|
224
305
|
} : void 0
|
|
225
306
|
},
|
|
226
|
-
label && /* @__PURE__ */ React7.createElement("div", { className: "
|
|
227
|
-
description && /* @__PURE__ */ React7.createElement("div", { className: "
|
|
228
|
-
|
|
229
|
-
|
|
307
|
+
label && /* @__PURE__ */ React7.createElement("div", { className: "text-sm font-medium" }, label),
|
|
308
|
+
description && /* @__PURE__ */ React7.createElement("div", { className: "text-muted-foreground text-sm" }, description),
|
|
309
|
+
showSelectAll && enabledOptions.length > 0 && /* @__PURE__ */ React7.createElement(
|
|
310
|
+
Checkbox,
|
|
230
311
|
{
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
input.indeterminate = someSelected;
|
|
236
|
-
}
|
|
237
|
-
},
|
|
238
|
-
onChange: (e) => handleSelectAll(e.target.checked),
|
|
312
|
+
name: `${name}-select-all`,
|
|
313
|
+
id: `${name}-select-all`,
|
|
314
|
+
value: allSelected,
|
|
315
|
+
onChange: handleSelectAll,
|
|
239
316
|
onBlur: handleBlur,
|
|
317
|
+
indeterminate: someSelected,
|
|
318
|
+
label: selectAllLabel,
|
|
319
|
+
checkboxVariant: "inline",
|
|
240
320
|
disabled,
|
|
241
|
-
className: "checkbox-input",
|
|
242
321
|
"aria-label": selectAllLabel
|
|
243
322
|
}
|
|
244
|
-
),
|
|
323
|
+
),
|
|
324
|
+
options.map((option) => {
|
|
245
325
|
const isChecked = value.includes(option.value);
|
|
246
326
|
const isDisabled = disabled || option.disabled || maxReached && !isChecked;
|
|
247
|
-
const checkboxId = `${name}-${option.value}`;
|
|
248
327
|
return /* @__PURE__ */ React7.createElement(
|
|
249
|
-
|
|
328
|
+
Checkbox,
|
|
250
329
|
{
|
|
251
330
|
key: option.value,
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
onBlur: handleBlur,
|
|
265
|
-
disabled: isDisabled,
|
|
266
|
-
required: required && minSelections ? value.length < minSelections : false,
|
|
267
|
-
className: "checkbox-input",
|
|
268
|
-
"aria-describedby": option.description ? `${checkboxId}-description` : props["aria-describedby"]
|
|
269
|
-
}
|
|
270
|
-
),
|
|
271
|
-
/* @__PURE__ */ React7.createElement("div", { className: "checkbox-content" }, renderOption ? renderOption(option) : /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement("span", { className: "checkbox-label" }, option.label), option.description && /* @__PURE__ */ React7.createElement(
|
|
272
|
-
"span",
|
|
273
|
-
{
|
|
274
|
-
className: "checkbox-description",
|
|
275
|
-
id: `${checkboxId}-description`
|
|
276
|
-
},
|
|
277
|
-
option.description
|
|
278
|
-
)))
|
|
331
|
+
name,
|
|
332
|
+
id: `${name}-${option.value}`,
|
|
333
|
+
value: isChecked,
|
|
334
|
+
onChange: (checked) => handleChange(option.value, checked),
|
|
335
|
+
onBlur: handleBlur,
|
|
336
|
+
disabled: isDisabled,
|
|
337
|
+
required: required && minSelections ? value.length < minSelections : false,
|
|
338
|
+
error,
|
|
339
|
+
label: renderOption ? renderOption(option) : option.label,
|
|
340
|
+
description: renderOption ? void 0 : option.description,
|
|
341
|
+
checkboxVariant
|
|
342
|
+
}
|
|
279
343
|
);
|
|
280
|
-
})
|
|
281
|
-
(minSelections || maxSelections) && /* @__PURE__ */ React7.createElement(
|
|
344
|
+
}),
|
|
345
|
+
(minSelections || maxSelections) && /* @__PURE__ */ React7.createElement(
|
|
346
|
+
"div",
|
|
347
|
+
{
|
|
348
|
+
className: cn(
|
|
349
|
+
"text-sm p-2 rounded-lg border font-semibold mt-2",
|
|
350
|
+
minSelections && countableValue < minSelections ? "border-destructive bg-destructive/80 text-destructive-foreground" : "border-border bg-card text-card-foreground"
|
|
351
|
+
),
|
|
352
|
+
"aria-live": "polite"
|
|
353
|
+
},
|
|
354
|
+
minSelections && countableValue < minSelections && /* @__PURE__ */ React7.createElement("span", null, "Select at least ", minSelections, " option", minSelections !== 1 ? "s" : ""),
|
|
355
|
+
maxSelections && /* @__PURE__ */ React7.createElement("span", null, countableValue, "/", maxSelections, " selected")
|
|
356
|
+
)
|
|
282
357
|
);
|
|
283
358
|
}
|
|
284
359
|
CheckboxGroup.displayName = "CheckboxGroup";
|
|
@@ -292,6 +367,7 @@ function Radio({
|
|
|
292
367
|
error = false,
|
|
293
368
|
className = "",
|
|
294
369
|
layout = "stacked",
|
|
370
|
+
radioVariant = "inline",
|
|
295
371
|
label,
|
|
296
372
|
options,
|
|
297
373
|
...props
|
|
@@ -327,59 +403,83 @@ function Radio({
|
|
|
327
403
|
const handleBlur = () => {
|
|
328
404
|
onBlur?.();
|
|
329
405
|
};
|
|
330
|
-
const
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
406
|
+
const containerClass = cn(
|
|
407
|
+
"w-full gap-3",
|
|
408
|
+
layout === "stacked" && "flex flex-col",
|
|
409
|
+
layout === "inline" && "flex flex-row flex-wrap",
|
|
410
|
+
className
|
|
411
|
+
);
|
|
334
412
|
return /* @__PURE__ */ React7.createElement(
|
|
335
413
|
"div",
|
|
336
414
|
{
|
|
337
|
-
className:
|
|
415
|
+
className: containerClass,
|
|
338
416
|
role: "radiogroup",
|
|
339
417
|
"aria-invalid": error || props["aria-invalid"],
|
|
340
418
|
"aria-describedby": props["aria-describedby"],
|
|
341
419
|
"aria-required": required || props["aria-required"],
|
|
342
420
|
"aria-label": typeof label === "string" ? label : props["aria-label"]
|
|
343
421
|
},
|
|
344
|
-
label && /* @__PURE__ */ React7.createElement("div", { className: "
|
|
345
|
-
|
|
422
|
+
label && /* @__PURE__ */ React7.createElement("div", { className: "text-sm font-medium mb-2" }, label),
|
|
423
|
+
options.map((option, index) => {
|
|
346
424
|
const isChecked = value === option.value;
|
|
347
425
|
const isDisabled = disabled || option.disabled;
|
|
348
426
|
const radioId = `${name}-${option.value}`;
|
|
427
|
+
const hasDescription = option.description != null && option.description !== "";
|
|
428
|
+
const radioIndicator = /* @__PURE__ */ React7.createElement("div", { className: "relative inline-flex items-center justify-center" }, /* @__PURE__ */ React7.createElement(
|
|
429
|
+
"input",
|
|
430
|
+
{
|
|
431
|
+
type: "radio",
|
|
432
|
+
id: radioId,
|
|
433
|
+
name,
|
|
434
|
+
value: option.value,
|
|
435
|
+
checked: isChecked,
|
|
436
|
+
onChange: (e) => handleChange(e.target.value),
|
|
437
|
+
onBlur: handleBlur,
|
|
438
|
+
disabled: isDisabled,
|
|
439
|
+
required,
|
|
440
|
+
className: "peer sr-only",
|
|
441
|
+
"aria-describedby": hasDescription ? `${radioId}-description` : props["aria-describedby"]
|
|
442
|
+
}
|
|
443
|
+
), /* @__PURE__ */ React7.createElement(
|
|
444
|
+
"div",
|
|
445
|
+
{
|
|
446
|
+
className: cn(
|
|
447
|
+
"flex shrink-0 items-center justify-center rounded-full border-2 transition-colors size-6",
|
|
448
|
+
!error && isChecked && "border-primary bg-transparent",
|
|
449
|
+
!error && !isChecked && "border-input bg-transparent",
|
|
450
|
+
error && isChecked && "border-destructive bg-transparent",
|
|
451
|
+
error && !isChecked && "border-destructive bg-transparent",
|
|
452
|
+
isDisabled && "opacity-50",
|
|
453
|
+
"peer-focus-visible:ring-2 peer-focus-visible:ring-ring/50 peer-focus-visible:ring-offset-1"
|
|
454
|
+
)
|
|
455
|
+
},
|
|
456
|
+
isChecked && /* @__PURE__ */ React7.createElement("div", { className: "size-3 rounded-full bg-primary" })
|
|
457
|
+
));
|
|
458
|
+
const labelContent = /* @__PURE__ */ React7.createElement("div", { className: "flex flex-col gap-0.5" }, /* @__PURE__ */ React7.createElement("div", { className: "text-sm font-medium" }, option.label), hasDescription && /* @__PURE__ */ React7.createElement(
|
|
459
|
+
"p",
|
|
460
|
+
{
|
|
461
|
+
className: "text-xs opacity-75",
|
|
462
|
+
id: `${radioId}-description`
|
|
463
|
+
},
|
|
464
|
+
option.description
|
|
465
|
+
));
|
|
349
466
|
return /* @__PURE__ */ React7.createElement(
|
|
350
467
|
"label",
|
|
351
468
|
{
|
|
352
469
|
key: option.value,
|
|
353
|
-
className:
|
|
470
|
+
className: cn(
|
|
471
|
+
"w-full h-full flex gap-3 p-3 duration-200",
|
|
472
|
+
radioVariant === "boxed" && "border rounded-lg hover:ring-2",
|
|
473
|
+
radioVariant === "boxed" && isChecked && "ring-2",
|
|
474
|
+
isDisabled ? "opacity-50 cursor-not-allowed hover:ring-0" : "cursor-pointer"
|
|
475
|
+
),
|
|
354
476
|
htmlFor: radioId,
|
|
355
477
|
onKeyDown: (e) => handleKeyDown(e, index),
|
|
356
|
-
tabIndex: 0
|
|
478
|
+
tabIndex: isDisabled ? -1 : 0
|
|
357
479
|
},
|
|
358
|
-
/* @__PURE__ */ React7.createElement("div", { className: "
|
|
359
|
-
"span",
|
|
360
|
-
{
|
|
361
|
-
className: "radio-description",
|
|
362
|
-
id: `${radioId}-description`
|
|
363
|
-
},
|
|
364
|
-
option.description
|
|
365
|
-
)), /* @__PURE__ */ React7.createElement(
|
|
366
|
-
"input",
|
|
367
|
-
{
|
|
368
|
-
type: "radio",
|
|
369
|
-
id: radioId,
|
|
370
|
-
name,
|
|
371
|
-
value: option.value,
|
|
372
|
-
checked: isChecked,
|
|
373
|
-
onChange: (e) => handleChange(e.target.value),
|
|
374
|
-
onBlur: handleBlur,
|
|
375
|
-
disabled: isDisabled,
|
|
376
|
-
required,
|
|
377
|
-
className: "radio-input",
|
|
378
|
-
"aria-describedby": option.description ? `${radioId}-description` : props["aria-describedby"]
|
|
379
|
-
}
|
|
380
|
-
))
|
|
480
|
+
/* @__PURE__ */ React7.createElement("div", { className: "flex w-full flex-row items-center gap-2" }, radioVariant === "inline" && radioIndicator, /* @__PURE__ */ React7.createElement("div", { className: "flex flex-1 flex-col gap-0.5" }, labelContent), radioVariant === "boxed" && radioIndicator)
|
|
381
481
|
);
|
|
382
|
-
})
|
|
482
|
+
})
|
|
383
483
|
);
|
|
384
484
|
}
|
|
385
485
|
Radio.displayName = "Radio";
|
|
@@ -544,11 +644,7 @@ function Select({
|
|
|
544
644
|
};
|
|
545
645
|
}
|
|
546
646
|
}, [isOpen]);
|
|
547
|
-
const
|
|
548
|
-
const errorClassName = error ? "select--error" : "";
|
|
549
|
-
const disabledClassName = disabled ? "select--disabled" : "";
|
|
550
|
-
const openClassName = isOpen ? "select--open" : "";
|
|
551
|
-
const combinedClassName = `${baseClassName} ${errorClassName} ${disabledClassName} ${openClassName} ${className}`.trim();
|
|
647
|
+
const combinedClassName = `relative w-full ${className}`.trim();
|
|
552
648
|
return /* @__PURE__ */ React7.createElement(
|
|
553
649
|
"div",
|
|
554
650
|
{
|
|
@@ -576,7 +672,7 @@ function Select({
|
|
|
576
672
|
/* @__PURE__ */ React7.createElement(
|
|
577
673
|
"div",
|
|
578
674
|
{
|
|
579
|
-
className: "
|
|
675
|
+
className: `flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm cursor-pointer transition-colors hover:bg-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring ${disabled ? "cursor-not-allowed opacity-50 pointer-events-none" : ""} ${error ? "border-red-500 ring-1 ring-red-500" : ""}`,
|
|
580
676
|
onClick: handleToggle,
|
|
581
677
|
role: "combobox",
|
|
582
678
|
"aria-expanded": isOpen,
|
|
@@ -587,39 +683,39 @@ function Select({
|
|
|
587
683
|
"aria-disabled": disabled,
|
|
588
684
|
tabIndex: disabled ? -1 : 0
|
|
589
685
|
},
|
|
590
|
-
/* @__PURE__ */ React7.createElement("span", { className: "
|
|
591
|
-
/* @__PURE__ */ React7.createElement("div", { className: "
|
|
686
|
+
/* @__PURE__ */ React7.createElement("span", { className: "flex items-center flex-1 overflow-hidden text-ellipsis" }, selectedOption ? renderOption ? renderOption(selectedOption) : selectedOption.label : /* @__PURE__ */ React7.createElement("span", { className: "text-muted-foreground" }, placeholder)),
|
|
687
|
+
/* @__PURE__ */ React7.createElement("div", { className: "flex items-center gap-1 ml-2" }, loading && /* @__PURE__ */ React7.createElement("span", { className: "text-xs" }, "\u23F3"), clearable && value && !disabled && !loading && /* @__PURE__ */ React7.createElement(
|
|
592
688
|
"button",
|
|
593
689
|
{
|
|
594
690
|
type: "button",
|
|
595
|
-
className: "
|
|
691
|
+
className: "flex items-center justify-center h-4 w-4 rounded-sm border-none bg-transparent text-muted-foreground cursor-pointer text-xs p-0 transition-opacity hover:opacity-70",
|
|
596
692
|
onClick: handleClear,
|
|
597
693
|
"aria-label": "Clear selection",
|
|
598
694
|
tabIndex: -1
|
|
599
695
|
},
|
|
600
696
|
"\u2715"
|
|
601
|
-
), /* @__PURE__ */ React7.createElement("span", { className: "
|
|
697
|
+
), /* @__PURE__ */ React7.createElement("span", { className: "text-muted-foreground text-xs leading-none", "aria-hidden": "true" }, isOpen ? "\u25B2" : "\u25BC"))
|
|
602
698
|
),
|
|
603
|
-
isOpen && /* @__PURE__ */ React7.createElement("div", { id: dropdownId, className: "
|
|
699
|
+
isOpen && /* @__PURE__ */ React7.createElement("div", { id: dropdownId, className: "absolute z-50 top-full mt-1 min-w-full overflow-hidden rounded-md border border-border bg-popover text-popover-foreground shadow-md", role: "listbox" }, searchable && /* @__PURE__ */ React7.createElement("div", { className: "p-2 border-b border-border" }, /* @__PURE__ */ React7.createElement(
|
|
604
700
|
"input",
|
|
605
701
|
{
|
|
606
702
|
ref: searchInputRef,
|
|
607
703
|
type: "text",
|
|
608
|
-
className: "
|
|
704
|
+
className: "w-full border border-input rounded px-2 py-1 text-sm bg-transparent outline-none focus:ring-1 focus:ring-ring",
|
|
609
705
|
placeholder: "Search...",
|
|
610
706
|
value: searchQuery,
|
|
611
707
|
onChange: handleSearchChange,
|
|
612
708
|
onClick: (e) => e.stopPropagation(),
|
|
613
709
|
"aria-label": "Search options"
|
|
614
710
|
}
|
|
615
|
-
)), /* @__PURE__ */ React7.createElement("div", { className: "
|
|
711
|
+
)), /* @__PURE__ */ React7.createElement("div", { className: "max-h-64 overflow-y-auto p-1" }, filteredOptions.length === 0 ? /* @__PURE__ */ React7.createElement("div", { className: "py-2 px-3 text-center text-sm text-muted-foreground" }, "No options found") : optionGroups.length > 0 ? (
|
|
616
712
|
// Render grouped options
|
|
617
713
|
optionGroups.map((group, groupIndex) => {
|
|
618
714
|
const groupOptions = group.options.filter(
|
|
619
715
|
(opt) => filteredOptions.includes(opt)
|
|
620
716
|
);
|
|
621
717
|
if (groupOptions.length === 0) return null;
|
|
622
|
-
return /* @__PURE__ */ React7.createElement("div", { key: groupIndex, className: "
|
|
718
|
+
return /* @__PURE__ */ React7.createElement("div", { key: groupIndex, className: "py-1" }, /* @__PURE__ */ React7.createElement("div", { className: "py-1.5 px-2 text-xs font-semibold text-muted-foreground" }, group.label), groupOptions.map((option) => {
|
|
623
719
|
const globalIndex = filteredOptions.indexOf(option);
|
|
624
720
|
const isSelected = value === option.value;
|
|
625
721
|
const isFocused = globalIndex === focusedIndex;
|
|
@@ -628,7 +724,7 @@ function Select({
|
|
|
628
724
|
"div",
|
|
629
725
|
{
|
|
630
726
|
key: option.value,
|
|
631
|
-
className: `
|
|
727
|
+
className: `relative flex w-full cursor-pointer items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors hover:bg-accent hover:text-accent-foreground ${isFocused ? "bg-accent text-accent-foreground" : ""} ${isSelected ? "font-medium bg-accent" : ""} ${isDisabled ? "pointer-events-none opacity-50" : ""}`,
|
|
632
728
|
onClick: () => !isDisabled && handleSelect(option.value),
|
|
633
729
|
role: "option",
|
|
634
730
|
"aria-selected": isSelected,
|
|
@@ -648,7 +744,7 @@ function Select({
|
|
|
648
744
|
"div",
|
|
649
745
|
{
|
|
650
746
|
key: option.value,
|
|
651
|
-
className: `
|
|
747
|
+
className: `relative flex w-full cursor-pointer items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors hover:bg-accent hover:text-accent-foreground ${isFocused ? "bg-accent text-accent-foreground" : ""} ${isSelected ? "font-medium bg-accent" : ""} ${isDisabled ? "pointer-events-none opacity-50" : ""}`,
|
|
652
748
|
onClick: () => !isDisabled && handleSelect(option.value),
|
|
653
749
|
role: "option",
|
|
654
750
|
"aria-selected": isSelected,
|
|
@@ -928,11 +1024,7 @@ function FileInput({
|
|
|
928
1024
|
}
|
|
929
1025
|
};
|
|
930
1026
|
}, [value, imageToCrop]);
|
|
931
|
-
const
|
|
932
|
-
const errorClassName = error ? "file-input--error" : "";
|
|
933
|
-
const dragClassName = dragActive ? "file-input--drag-active" : "";
|
|
934
|
-
const disabledClassName = disabled ? "file-input--disabled" : "";
|
|
935
|
-
const combinedClassName = `${baseClassName} ${errorClassName} ${dragClassName} ${disabledClassName} ${className}`.trim();
|
|
1027
|
+
const combinedClassName = `${className}`.trim();
|
|
936
1028
|
return /* @__PURE__ */ React7.createElement("div", { className: combinedClassName }, /* @__PURE__ */ React7.createElement(
|
|
937
1029
|
"input",
|
|
938
1030
|
{
|
|
@@ -945,7 +1037,6 @@ function FileInput({
|
|
|
945
1037
|
multiple,
|
|
946
1038
|
disabled,
|
|
947
1039
|
required: required && value.length === 0,
|
|
948
|
-
className: "file-input__native",
|
|
949
1040
|
"aria-invalid": error || props["aria-invalid"],
|
|
950
1041
|
"aria-describedby": props["aria-describedby"],
|
|
951
1042
|
"aria-required": required || props["aria-required"],
|
|
@@ -954,7 +1045,7 @@ function FileInput({
|
|
|
954
1045
|
), /* @__PURE__ */ React7.createElement(
|
|
955
1046
|
"div",
|
|
956
1047
|
{
|
|
957
|
-
className: "
|
|
1048
|
+
className: `flex min-h-32 w-full cursor-pointer items-center justify-center rounded-md border-2 border-dashed border-input bg-transparent p-6 transition-colors hover:bg-accent/50 hover:border-ring ${dragActive ? "bg-accent border-ring" : ""} ${disabled ? "cursor-not-allowed opacity-50" : ""} ${error ? "border-red-500" : ""}`,
|
|
958
1049
|
onDragEnter: handleDrag,
|
|
959
1050
|
onDragLeave: handleDrag,
|
|
960
1051
|
onDragOver: handleDrag,
|
|
@@ -966,10 +1057,10 @@ function FileInput({
|
|
|
966
1057
|
"aria-label": placeholder,
|
|
967
1058
|
"aria-disabled": disabled
|
|
968
1059
|
},
|
|
969
|
-
/* @__PURE__ */ React7.createElement("div", { className: "
|
|
1060
|
+
/* @__PURE__ */ React7.createElement("div", { className: "flex flex-col items-center gap-2 text-center" }, /* @__PURE__ */ React7.createElement(
|
|
970
1061
|
"svg",
|
|
971
1062
|
{
|
|
972
|
-
className: "
|
|
1063
|
+
className: "text-muted-foreground",
|
|
973
1064
|
width: "48",
|
|
974
1065
|
height: "48",
|
|
975
1066
|
viewBox: "0 0 24 24",
|
|
@@ -983,30 +1074,36 @@ function FileInput({
|
|
|
983
1074
|
/* @__PURE__ */ React7.createElement("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }),
|
|
984
1075
|
/* @__PURE__ */ React7.createElement("polyline", { points: "17 8 12 3 7 8" }),
|
|
985
1076
|
/* @__PURE__ */ React7.createElement("line", { x1: "12", y1: "3", x2: "12", y2: "15" })
|
|
986
|
-
), /* @__PURE__ */ React7.createElement("p", { className: "
|
|
987
|
-
), value.length > 0 && /* @__PURE__ */ React7.createElement("ul", { className: "
|
|
1077
|
+
), /* @__PURE__ */ React7.createElement("p", { className: "text-sm font-medium" }, value.length > 0 ? `${value.length} file(s) selected` : placeholder), accept && /* @__PURE__ */ React7.createElement("p", { className: "text-xs text-muted-foreground" }, "Accepted: ", accept), maxSize && /* @__PURE__ */ React7.createElement("p", { className: "text-xs text-muted-foreground" }, "Max size: ", formatFileSize(maxSize)))
|
|
1078
|
+
), value.length > 0 && /* @__PURE__ */ React7.createElement("ul", { className: "flex flex-col gap-2 mt-4", role: "list" }, value.map((file, index) => {
|
|
988
1079
|
const previewUrl = showPreview ? getPreviewUrl(file) : null;
|
|
989
|
-
return /* @__PURE__ */ React7.createElement("li", { key: `${file.name}-${index}`, className: "
|
|
1080
|
+
return /* @__PURE__ */ React7.createElement("li", { key: `${file.name}-${index}`, className: "flex items-center gap-3 p-3 rounded-md border border-border bg-card hover:bg-accent/50 transition-colors" }, previewUrl && /* @__PURE__ */ React7.createElement(
|
|
990
1081
|
"img",
|
|
991
1082
|
{
|
|
992
1083
|
src: previewUrl,
|
|
993
1084
|
alt: file.name,
|
|
994
|
-
className: "
|
|
1085
|
+
className: "w-12 h-12 rounded object-cover",
|
|
995
1086
|
width: "48",
|
|
996
1087
|
height: "48"
|
|
997
1088
|
}
|
|
998
|
-
), /* @__PURE__ */ React7.createElement("div", { className: "
|
|
1089
|
+
), /* @__PURE__ */ React7.createElement("div", { className: "flex flex-col flex-1 min-w-0" }, /* @__PURE__ */ React7.createElement("span", { className: "text-sm font-medium truncate" }, file.name), /* @__PURE__ */ React7.createElement("span", { className: "text-xs text-muted-foreground" }, formatFileSize(file.size)), showProgress && uploadProgress[file.name] !== void 0 && /* @__PURE__ */ React7.createElement("div", { className: "flex items-center gap-2 mt-1" }, /* @__PURE__ */ React7.createElement(
|
|
999
1090
|
"div",
|
|
1000
1091
|
{
|
|
1001
|
-
className: "
|
|
1002
|
-
style: { width: `${uploadProgress[file.name]}%` },
|
|
1092
|
+
className: "h-1.5 bg-muted rounded-full overflow-hidden flex-1",
|
|
1003
1093
|
role: "progressbar",
|
|
1004
1094
|
"aria-valuenow": uploadProgress[file.name],
|
|
1005
1095
|
"aria-valuemin": 0,
|
|
1006
1096
|
"aria-valuemax": 100,
|
|
1007
1097
|
"aria-label": `Upload progress: ${uploadProgress[file.name]}%`
|
|
1008
|
-
}
|
|
1009
|
-
|
|
1098
|
+
},
|
|
1099
|
+
/* @__PURE__ */ React7.createElement(
|
|
1100
|
+
"div",
|
|
1101
|
+
{
|
|
1102
|
+
className: "h-full bg-primary transition-all",
|
|
1103
|
+
style: { width: `${uploadProgress[file.name]}%` }
|
|
1104
|
+
}
|
|
1105
|
+
)
|
|
1106
|
+
), /* @__PURE__ */ React7.createElement("span", { className: "text-xs text-muted-foreground" }, uploadProgress[file.name], "%"))), enableCropping && file.type.startsWith("image/") && /* @__PURE__ */ React7.createElement(
|
|
1010
1107
|
"button",
|
|
1011
1108
|
{
|
|
1012
1109
|
type: "button",
|
|
@@ -1015,7 +1112,7 @@ function FileInput({
|
|
|
1015
1112
|
handleCrop(file);
|
|
1016
1113
|
},
|
|
1017
1114
|
disabled,
|
|
1018
|
-
className: "
|
|
1115
|
+
className: "flex items-center justify-center h-8 w-8 rounded border-none bg-transparent hover:bg-accent text-muted-foreground hover:text-foreground transition-colors",
|
|
1019
1116
|
"aria-label": `Crop ${file.name}`
|
|
1020
1117
|
},
|
|
1021
1118
|
/* @__PURE__ */ React7.createElement(
|
|
@@ -1043,7 +1140,7 @@ function FileInput({
|
|
|
1043
1140
|
handleRemove(index);
|
|
1044
1141
|
},
|
|
1045
1142
|
disabled,
|
|
1046
|
-
className: "
|
|
1143
|
+
className: "flex items-center justify-center h-8 w-8 rounded border-none bg-transparent hover:bg-accent text-muted-foreground hover:text-foreground transition-colors",
|
|
1047
1144
|
"aria-label": `Remove ${file.name}`
|
|
1048
1145
|
},
|
|
1049
1146
|
/* @__PURE__ */ React7.createElement(
|
|
@@ -1063,26 +1160,26 @@ function FileInput({
|
|
|
1063
1160
|
/* @__PURE__ */ React7.createElement("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
1064
1161
|
)
|
|
1065
1162
|
));
|
|
1066
|
-
})), cropperOpen && imageToCrop && /* @__PURE__ */ React7.createElement("div", { className: "
|
|
1163
|
+
})), cropperOpen && imageToCrop && /* @__PURE__ */ React7.createElement("div", { className: "fixed inset-0 z-50 flex items-center justify-center" }, /* @__PURE__ */ React7.createElement(
|
|
1067
1164
|
"div",
|
|
1068
1165
|
{
|
|
1069
|
-
className: "
|
|
1166
|
+
className: "absolute inset-0 bg-black/50",
|
|
1070
1167
|
onClick: handleCropCancel,
|
|
1071
1168
|
"aria-label": "Close cropper"
|
|
1072
1169
|
}
|
|
1073
|
-
), /* @__PURE__ */ React7.createElement("div", { className: "
|
|
1170
|
+
), /* @__PURE__ */ React7.createElement("div", { className: "relative bg-popover border border-border rounded-lg shadow-lg max-w-3xl w-full mx-4" }, /* @__PURE__ */ React7.createElement("div", { className: "flex items-center justify-between p-4 border-b border-border" }, /* @__PURE__ */ React7.createElement("h3", { className: "text-lg font-semibold" }, "Crop Image"), /* @__PURE__ */ React7.createElement(
|
|
1074
1171
|
"button",
|
|
1075
1172
|
{
|
|
1076
1173
|
type: "button",
|
|
1077
|
-
className: "
|
|
1174
|
+
className: "flex items-center justify-center h-8 w-8 rounded hover:bg-accent text-muted-foreground hover:text-foreground transition-colors",
|
|
1078
1175
|
onClick: handleCropCancel,
|
|
1079
1176
|
"aria-label": "Close"
|
|
1080
1177
|
},
|
|
1081
1178
|
"\u2715"
|
|
1082
|
-
)), /* @__PURE__ */ React7.createElement("div", { className: "
|
|
1179
|
+
)), /* @__PURE__ */ React7.createElement("div", { className: "p-4" }, /* @__PURE__ */ React7.createElement(
|
|
1083
1180
|
"div",
|
|
1084
1181
|
{
|
|
1085
|
-
className: "
|
|
1182
|
+
className: "relative w-full h-96 bg-muted rounded-md overflow-hidden",
|
|
1086
1183
|
onMouseDown: (e) => {
|
|
1087
1184
|
e.preventDefault();
|
|
1088
1185
|
const startX = e.clientX - crop.x;
|
|
@@ -1106,7 +1203,7 @@ function FileInput({
|
|
|
1106
1203
|
{
|
|
1107
1204
|
src: imageToCrop.url,
|
|
1108
1205
|
alt: "Crop preview",
|
|
1109
|
-
className: "
|
|
1206
|
+
className: "absolute inset-0 w-full h-full object-contain",
|
|
1110
1207
|
style: {
|
|
1111
1208
|
transform: `translate(${crop.x}px, ${crop.y}px) scale(${zoom})`
|
|
1112
1209
|
},
|
|
@@ -1136,15 +1233,15 @@ function FileInput({
|
|
|
1136
1233
|
/* @__PURE__ */ React7.createElement(
|
|
1137
1234
|
"div",
|
|
1138
1235
|
{
|
|
1139
|
-
className: "
|
|
1236
|
+
className: "absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 border-2 border-primary rounded pointer-events-none",
|
|
1140
1237
|
style: {
|
|
1141
1238
|
width: cropAspectRatio ? `${Math.min(80, 80 * cropAspectRatio)}%` : "80%",
|
|
1142
1239
|
aspectRatio: cropAspectRatio ? String(cropAspectRatio) : void 0
|
|
1143
1240
|
}
|
|
1144
1241
|
},
|
|
1145
|
-
/* @__PURE__ */ React7.createElement("div", { className: "
|
|
1242
|
+
/* @__PURE__ */ React7.createElement("div", { className: "absolute inset-0 grid grid-cols-3 grid-rows-3" }, /* @__PURE__ */ React7.createElement("div", { className: "border-r border-b border-primary/30" }), /* @__PURE__ */ React7.createElement("div", { className: "border-r border-b border-primary/30" }), /* @__PURE__ */ React7.createElement("div", { className: "border-b border-primary/30" }), /* @__PURE__ */ React7.createElement("div", { className: "border-r border-b border-primary/30" }), /* @__PURE__ */ React7.createElement("div", { className: "border-r border-b border-primary/30" }), /* @__PURE__ */ React7.createElement("div", { className: "border-b border-primary/30" }), /* @__PURE__ */ React7.createElement("div", { className: "border-r border-primary/30" }), /* @__PURE__ */ React7.createElement("div", { className: "border-r border-primary/30" }), /* @__PURE__ */ React7.createElement("div", null))
|
|
1146
1243
|
)
|
|
1147
|
-
), /* @__PURE__ */ React7.createElement("div", { className: "
|
|
1244
|
+
), /* @__PURE__ */ React7.createElement("div", { className: "flex items-center gap-3 mt-4" }, /* @__PURE__ */ React7.createElement("label", { htmlFor: "zoom-slider", className: "text-sm font-medium whitespace-nowrap" }, "Zoom: ", zoom.toFixed(1), "x"), /* @__PURE__ */ React7.createElement(
|
|
1148
1245
|
"input",
|
|
1149
1246
|
{
|
|
1150
1247
|
id: "zoom-slider",
|
|
@@ -1154,14 +1251,14 @@ function FileInput({
|
|
|
1154
1251
|
step: "0.1",
|
|
1155
1252
|
value: zoom,
|
|
1156
1253
|
onChange: (e) => onZoomChange(parseFloat(e.target.value)),
|
|
1157
|
-
className: "
|
|
1254
|
+
className: "flex-1 h-2 bg-muted rounded-lg appearance-none cursor-pointer",
|
|
1158
1255
|
"aria-label": "Zoom level"
|
|
1159
1256
|
}
|
|
1160
|
-
))), /* @__PURE__ */ React7.createElement("div", { className: "
|
|
1257
|
+
))), /* @__PURE__ */ React7.createElement("div", { className: "flex items-center justify-end gap-2 p-4 border-t border-border" }, /* @__PURE__ */ React7.createElement(
|
|
1161
1258
|
"button",
|
|
1162
1259
|
{
|
|
1163
1260
|
type: "button",
|
|
1164
|
-
className: "
|
|
1261
|
+
className: "inline-flex items-center justify-center h-9 rounded-md px-4 text-sm font-medium border border-input bg-transparent hover:bg-accent hover:text-accent-foreground transition-colors",
|
|
1165
1262
|
onClick: handleCropCancel
|
|
1166
1263
|
},
|
|
1167
1264
|
"Cancel"
|
|
@@ -1169,7 +1266,7 @@ function FileInput({
|
|
|
1169
1266
|
"button",
|
|
1170
1267
|
{
|
|
1171
1268
|
type: "button",
|
|
1172
|
-
className: "
|
|
1269
|
+
className: "inline-flex items-center justify-center h-9 rounded-md px-4 text-sm font-medium bg-primary text-primary-foreground hover:bg-primary/90 transition-colors",
|
|
1173
1270
|
onClick: handleCropSave
|
|
1174
1271
|
},
|
|
1175
1272
|
"Save"
|
|
@@ -1230,7 +1327,9 @@ function DatePicker({
|
|
|
1230
1327
|
}) {
|
|
1231
1328
|
const [isOpen, setIsOpen] = React7.useState(false);
|
|
1232
1329
|
const [inputValue, setInputValue] = React7.useState("");
|
|
1233
|
-
const [selectedMonth, setSelectedMonth] = React7.useState(
|
|
1330
|
+
const [selectedMonth, setSelectedMonth] = React7.useState(
|
|
1331
|
+
value || /* @__PURE__ */ new Date()
|
|
1332
|
+
);
|
|
1234
1333
|
const containerRef = React7.useRef(null);
|
|
1235
1334
|
const inputRef = React7.useRef(null);
|
|
1236
1335
|
React7.useEffect(() => {
|
|
@@ -1317,27 +1416,34 @@ function DatePicker({
|
|
|
1317
1416
|
const handleNextMonth = () => {
|
|
1318
1417
|
setSelectedMonth(new Date(year, month + 1, 1));
|
|
1319
1418
|
};
|
|
1320
|
-
return /* @__PURE__ */ React7.createElement("div", {
|
|
1419
|
+
return /* @__PURE__ */ React7.createElement("div", { role: "grid", "aria-label": "Calendar" }, /* @__PURE__ */ React7.createElement("div", { className: "flex items-center justify-between pb-2 border-b border-border" }, /* @__PURE__ */ React7.createElement(
|
|
1321
1420
|
"button",
|
|
1322
1421
|
{
|
|
1323
1422
|
type: "button",
|
|
1324
|
-
className: "
|
|
1423
|
+
className: "flex items-center justify-center h-8 w-8 rounded border-none bg-transparent hover:bg-primary hover:text-primary-foreground cursor-pointer",
|
|
1325
1424
|
onClick: handlePrevMonth,
|
|
1326
1425
|
"aria-label": "Previous month"
|
|
1327
1426
|
},
|
|
1328
1427
|
"\u2190"
|
|
1329
|
-
), /* @__PURE__ */ React7.createElement("div", { className: "
|
|
1428
|
+
), /* @__PURE__ */ React7.createElement("div", { className: "font-medium text-sm" }, `${monthNames[month]} ${year}`), /* @__PURE__ */ React7.createElement(
|
|
1330
1429
|
"button",
|
|
1331
1430
|
{
|
|
1332
1431
|
type: "button",
|
|
1333
|
-
className: "
|
|
1432
|
+
className: "flex items-center justify-center h-8 w-8 rounded border-none bg-transparent hover:bg-primary hover:text-primary-foreground cursor-pointer",
|
|
1334
1433
|
onClick: handleNextMonth,
|
|
1335
1434
|
"aria-label": "Next month"
|
|
1336
1435
|
},
|
|
1337
1436
|
"\u2192"
|
|
1338
|
-
)), /* @__PURE__ */ React7.createElement("div", { className: "
|
|
1437
|
+
)), /* @__PURE__ */ React7.createElement("div", { className: "grid grid-cols-7 gap-1 mt-2" }, ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"].map((day) => /* @__PURE__ */ React7.createElement(
|
|
1438
|
+
"div",
|
|
1439
|
+
{
|
|
1440
|
+
key: day,
|
|
1441
|
+
className: "flex items-center justify-center h-8 w-full text-xs font-medium"
|
|
1442
|
+
},
|
|
1443
|
+
day
|
|
1444
|
+
))), /* @__PURE__ */ React7.createElement("div", { className: "grid grid-cols-7 gap-1" }, days.map((date, index) => {
|
|
1339
1445
|
if (!date) {
|
|
1340
|
-
return /* @__PURE__ */ React7.createElement("div", { key: `empty-${index}
|
|
1446
|
+
return /* @__PURE__ */ React7.createElement("div", { key: `empty-${index}` });
|
|
1341
1447
|
}
|
|
1342
1448
|
const isSelected = value && date.toDateString() === value.toDateString();
|
|
1343
1449
|
const isToday = date.toDateString() === (/* @__PURE__ */ new Date()).toDateString();
|
|
@@ -1347,7 +1453,7 @@ function DatePicker({
|
|
|
1347
1453
|
{
|
|
1348
1454
|
key: date.toISOString(),
|
|
1349
1455
|
type: "button",
|
|
1350
|
-
className: `
|
|
1456
|
+
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" : ""}`,
|
|
1351
1457
|
onClick: () => !disabled2 && handleDateSelect(date),
|
|
1352
1458
|
disabled: disabled2,
|
|
1353
1459
|
"aria-label": formatDate(date, format)
|
|
@@ -1356,11 +1462,7 @@ function DatePicker({
|
|
|
1356
1462
|
);
|
|
1357
1463
|
})));
|
|
1358
1464
|
};
|
|
1359
|
-
const
|
|
1360
|
-
const errorClassName = error ? "datepicker--error" : "";
|
|
1361
|
-
const disabledClassName = disabled ? "datepicker--disabled" : "";
|
|
1362
|
-
const openClassName = isOpen ? "datepicker--open" : "";
|
|
1363
|
-
const combinedClassName = `${baseClassName} ${errorClassName} ${disabledClassName} ${openClassName} ${className}`.trim();
|
|
1465
|
+
const combinedClassName = `relative ${className}`.trim();
|
|
1364
1466
|
return /* @__PURE__ */ React7.createElement("div", { ref: containerRef, className: combinedClassName }, /* @__PURE__ */ React7.createElement(
|
|
1365
1467
|
"input",
|
|
1366
1468
|
{
|
|
@@ -1368,26 +1470,33 @@ function DatePicker({
|
|
|
1368
1470
|
name,
|
|
1369
1471
|
value: value ? value.toISOString() : ""
|
|
1370
1472
|
}
|
|
1371
|
-
), /* @__PURE__ */ React7.createElement("div", { className: "
|
|
1372
|
-
"
|
|
1473
|
+
), /* @__PURE__ */ React7.createElement("div", { className: "relative" }, showIcon && /* @__PURE__ */ React7.createElement(
|
|
1474
|
+
"span",
|
|
1373
1475
|
{
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
height: "18",
|
|
1377
|
-
viewBox: "0 0 24 24",
|
|
1378
|
-
fill: "none",
|
|
1379
|
-
stroke: "currentColor",
|
|
1380
|
-
strokeLinecap: "round",
|
|
1381
|
-
strokeLinejoin: "round",
|
|
1382
|
-
strokeWidth: "2"
|
|
1476
|
+
className: "absolute left-3 top-1/2 -translate-y-1/2 pointer-events-none",
|
|
1477
|
+
"aria-hidden": "true"
|
|
1383
1478
|
},
|
|
1384
|
-
/* @__PURE__ */ React7.createElement(
|
|
1385
|
-
|
|
1479
|
+
/* @__PURE__ */ React7.createElement(
|
|
1480
|
+
"svg",
|
|
1481
|
+
{
|
|
1482
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1483
|
+
width: "18",
|
|
1484
|
+
height: "18",
|
|
1485
|
+
viewBox: "0 0 24 24",
|
|
1486
|
+
fill: "none",
|
|
1487
|
+
stroke: "currentColor",
|
|
1488
|
+
strokeLinecap: "round",
|
|
1489
|
+
strokeLinejoin: "round",
|
|
1490
|
+
strokeWidth: "2"
|
|
1491
|
+
},
|
|
1492
|
+
/* @__PURE__ */ React7.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" })
|
|
1493
|
+
)
|
|
1494
|
+
), /* @__PURE__ */ React7.createElement(
|
|
1386
1495
|
"input",
|
|
1387
1496
|
{
|
|
1388
1497
|
ref: inputRef,
|
|
1389
1498
|
type: "text",
|
|
1390
|
-
className:
|
|
1499
|
+
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" : ""}`,
|
|
1391
1500
|
value: inputValue,
|
|
1392
1501
|
onChange: handleInputChange,
|
|
1393
1502
|
onClick: handleToggle,
|
|
@@ -1404,13 +1513,13 @@ function DatePicker({
|
|
|
1404
1513
|
"button",
|
|
1405
1514
|
{
|
|
1406
1515
|
type: "button",
|
|
1407
|
-
className: "
|
|
1516
|
+
className: "absolute right-3 top-1/2 -translate-y-1/2 transition-colors",
|
|
1408
1517
|
onClick: handleClear,
|
|
1409
1518
|
"aria-label": "Clear date",
|
|
1410
1519
|
tabIndex: -1
|
|
1411
1520
|
},
|
|
1412
1521
|
"\u2715"
|
|
1413
|
-
)), isOpen && !disabled && /* @__PURE__ */ React7.createElement("div", { className: "
|
|
1522
|
+
)), isOpen && !disabled && /* @__PURE__ */ React7.createElement("div", { className: "absolute z-50 top-full mt-1 min-w-full rounded-md border border-border bg-popover text-popover-foreground shadow-md p-3" }, renderCalendar()));
|
|
1414
1523
|
}
|
|
1415
1524
|
DatePicker.displayName = "DatePicker";
|
|
1416
1525
|
function parseTimeString(timeStr, use24Hour) {
|
|
@@ -1543,11 +1652,7 @@ function TimePicker({
|
|
|
1543
1652
|
}
|
|
1544
1653
|
return mins;
|
|
1545
1654
|
}, [minuteStep]);
|
|
1546
|
-
const
|
|
1547
|
-
const errorClassName = error ? "timepicker--error" : "";
|
|
1548
|
-
const disabledClassName = disabled ? "timepicker--disabled" : "";
|
|
1549
|
-
const openClassName = isOpen ? "timepicker--open" : "";
|
|
1550
|
-
const combinedClassName = `${baseClassName} ${errorClassName} ${disabledClassName} ${openClassName} ${className}`.trim();
|
|
1655
|
+
const combinedClassName = `relative ${className}`.trim();
|
|
1551
1656
|
const displayValue = formatTimeValue(timeValue, use24Hour);
|
|
1552
1657
|
return /* @__PURE__ */ React7.createElement("div", { ref: containerRef, className: combinedClassName }, /* @__PURE__ */ React7.createElement(
|
|
1553
1658
|
"input",
|
|
@@ -1556,7 +1661,7 @@ function TimePicker({
|
|
|
1556
1661
|
name,
|
|
1557
1662
|
value
|
|
1558
1663
|
}
|
|
1559
|
-
), /* @__PURE__ */ React7.createElement("div", { className: "
|
|
1664
|
+
), /* @__PURE__ */ React7.createElement("div", { className: "relative" }, showIcon && /* @__PURE__ */ React7.createElement("span", { className: "absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none", "aria-hidden": "true" }, /* @__PURE__ */ React7.createElement(
|
|
1560
1665
|
"svg",
|
|
1561
1666
|
{
|
|
1562
1667
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -1576,7 +1681,7 @@ function TimePicker({
|
|
|
1576
1681
|
{
|
|
1577
1682
|
ref: inputRef,
|
|
1578
1683
|
type: "text",
|
|
1579
|
-
className:
|
|
1684
|
+
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 placeholder:text-muted-foreground 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" : ""}`,
|
|
1580
1685
|
value: displayValue,
|
|
1581
1686
|
onClick: handleToggle,
|
|
1582
1687
|
onBlur,
|
|
@@ -1592,13 +1697,13 @@ function TimePicker({
|
|
|
1592
1697
|
"button",
|
|
1593
1698
|
{
|
|
1594
1699
|
type: "button",
|
|
1595
|
-
className: "
|
|
1700
|
+
className: "absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors",
|
|
1596
1701
|
onClick: handleClear,
|
|
1597
1702
|
"aria-label": "Clear time",
|
|
1598
1703
|
tabIndex: -1
|
|
1599
1704
|
},
|
|
1600
1705
|
"\u2715"
|
|
1601
|
-
)), isOpen && !disabled && /* @__PURE__ */ React7.createElement("div", { className: "
|
|
1706
|
+
)), isOpen && !disabled && /* @__PURE__ */ React7.createElement("div", { className: "absolute z-50 top-full mt-1 min-w-full rounded-md border border-border bg-popover text-popover-foreground shadow-md p-3" }, /* @__PURE__ */ React7.createElement("div", { className: "flex gap-2" }, /* @__PURE__ */ React7.createElement("div", { className: "flex flex-col flex-1" }, /* @__PURE__ */ React7.createElement("div", { className: "text-xs font-medium text-muted-foreground mb-2 text-center" }, use24Hour ? "Hour" : "Hour"), /* @__PURE__ */ React7.createElement("div", { className: "flex flex-col gap-1 max-h-48 overflow-y-auto" }, hours.map((hour) => {
|
|
1602
1707
|
const displayHour = use24Hour ? hour : hour;
|
|
1603
1708
|
const isSelected = use24Hour ? timeValue?.hour === (hour === 0 ? 12 : hour > 12 ? hour - 12 : hour) && timeValue?.period === (hour >= 12 ? "PM" : "AM") : timeValue?.hour === hour;
|
|
1604
1709
|
return /* @__PURE__ */ React7.createElement(
|
|
@@ -1606,7 +1711,7 @@ function TimePicker({
|
|
|
1606
1711
|
{
|
|
1607
1712
|
key: hour,
|
|
1608
1713
|
type: "button",
|
|
1609
|
-
className: `
|
|
1714
|
+
className: `flex items-center justify-center h-8 w-full rounded border-none bg-transparent cursor-pointer text-sm transition-colors hover:bg-accent hover:text-accent-foreground ${isSelected ? "bg-primary text-primary-foreground font-semibold" : ""}`,
|
|
1610
1715
|
onClick: () => {
|
|
1611
1716
|
if (use24Hour) {
|
|
1612
1717
|
const hour12 = hour === 0 ? 12 : hour > 12 ? hour - 12 : hour;
|
|
@@ -1626,24 +1731,24 @@ function TimePicker({
|
|
|
1626
1731
|
},
|
|
1627
1732
|
String(displayHour).padStart(2, "0")
|
|
1628
1733
|
);
|
|
1629
|
-
}))), /* @__PURE__ */ React7.createElement("div", { className: "
|
|
1734
|
+
}))), /* @__PURE__ */ React7.createElement("div", { className: "flex flex-col flex-1" }, /* @__PURE__ */ React7.createElement("div", { className: "text-xs font-medium text-muted-foreground mb-2 text-center" }, "Minute"), /* @__PURE__ */ React7.createElement("div", { className: "flex flex-col gap-1 max-h-48 overflow-y-auto" }, minutes.map((minute) => {
|
|
1630
1735
|
const isSelected = timeValue?.minute === minute;
|
|
1631
1736
|
return /* @__PURE__ */ React7.createElement(
|
|
1632
1737
|
"button",
|
|
1633
1738
|
{
|
|
1634
1739
|
key: minute,
|
|
1635
1740
|
type: "button",
|
|
1636
|
-
className: `
|
|
1741
|
+
className: `flex items-center justify-center h-8 w-full rounded border-none bg-transparent cursor-pointer text-sm transition-colors hover:bg-accent hover:text-accent-foreground ${isSelected ? "bg-primary text-primary-foreground font-semibold" : ""}`,
|
|
1637
1742
|
onClick: () => handleMinuteChange(minute),
|
|
1638
1743
|
"aria-label": `${String(minute).padStart(2, "0")} minutes`
|
|
1639
1744
|
},
|
|
1640
1745
|
String(minute).padStart(2, "0")
|
|
1641
1746
|
);
|
|
1642
|
-
}))), !use24Hour && /* @__PURE__ */ React7.createElement("div", { className: "
|
|
1747
|
+
}))), !use24Hour && /* @__PURE__ */ React7.createElement("div", { className: "flex flex-col w-20" }, /* @__PURE__ */ React7.createElement("div", { className: "text-xs font-medium text-muted-foreground mb-2 text-center" }, "Period"), /* @__PURE__ */ React7.createElement("div", { className: "flex flex-col gap-1" }, /* @__PURE__ */ React7.createElement(
|
|
1643
1748
|
"button",
|
|
1644
1749
|
{
|
|
1645
1750
|
type: "button",
|
|
1646
|
-
className: `
|
|
1751
|
+
className: `flex items-center justify-center h-8 w-full rounded border-none bg-transparent cursor-pointer text-sm transition-colors hover:bg-accent hover:text-accent-foreground ${timeValue?.period === "AM" ? "bg-primary text-primary-foreground font-semibold" : ""}`,
|
|
1647
1752
|
onClick: () => handlePeriodChange("AM")
|
|
1648
1753
|
},
|
|
1649
1754
|
"AM"
|
|
@@ -1651,7 +1756,7 @@ function TimePicker({
|
|
|
1651
1756
|
"button",
|
|
1652
1757
|
{
|
|
1653
1758
|
type: "button",
|
|
1654
|
-
className: `
|
|
1759
|
+
className: `flex items-center justify-center h-8 w-full rounded border-none bg-transparent cursor-pointer text-sm transition-colors hover:bg-accent hover:text-accent-foreground ${timeValue?.period === "PM" ? "bg-primary text-primary-foreground font-semibold" : ""}`,
|
|
1655
1760
|
onClick: () => handlePeriodChange("PM")
|
|
1656
1761
|
},
|
|
1657
1762
|
"PM"
|
|
@@ -1790,27 +1895,27 @@ function DateRangePicker({
|
|
|
1790
1895
|
const handleNextMonth = () => {
|
|
1791
1896
|
setSelectedMonth(new Date(year, month + 1, 1));
|
|
1792
1897
|
};
|
|
1793
|
-
return /* @__PURE__ */ React7.createElement("div", {
|
|
1898
|
+
return /* @__PURE__ */ React7.createElement("div", { role: "grid", "aria-label": "Calendar" }, /* @__PURE__ */ React7.createElement("div", { className: "flex items-center justify-between pb-2 border-b border-border" }, /* @__PURE__ */ React7.createElement(
|
|
1794
1899
|
"button",
|
|
1795
1900
|
{
|
|
1796
1901
|
type: "button",
|
|
1797
|
-
className: "
|
|
1902
|
+
className: "flex items-center justify-center h-8 w-8 rounded border-none bg-transparent hover:bg-accent cursor-pointer",
|
|
1798
1903
|
onClick: handlePrevMonth,
|
|
1799
1904
|
"aria-label": "Previous month"
|
|
1800
1905
|
},
|
|
1801
1906
|
"\u2190"
|
|
1802
|
-
), /* @__PURE__ */ React7.createElement("div", { className: "
|
|
1907
|
+
), /* @__PURE__ */ React7.createElement("div", { className: "font-medium text-sm" }, `${monthNames[month]} ${year}`), /* @__PURE__ */ React7.createElement(
|
|
1803
1908
|
"button",
|
|
1804
1909
|
{
|
|
1805
1910
|
type: "button",
|
|
1806
|
-
className: "
|
|
1911
|
+
className: "flex items-center justify-center h-8 w-8 rounded border-none bg-transparent hover:bg-accent cursor-pointer",
|
|
1807
1912
|
onClick: handleNextMonth,
|
|
1808
1913
|
"aria-label": "Next month"
|
|
1809
1914
|
},
|
|
1810
1915
|
"\u2192"
|
|
1811
|
-
)), /* @__PURE__ */ React7.createElement("div", { className: "
|
|
1916
|
+
)), /* @__PURE__ */ React7.createElement("div", { className: "grid grid-cols-7 gap-1 mt-2" }, ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"].map((day) => /* @__PURE__ */ React7.createElement("div", { key: day, className: "flex items-center justify-center h-8 w-full text-xs text-muted-foreground font-medium" }, day))), /* @__PURE__ */ React7.createElement("div", { className: "grid grid-cols-7 gap-1" }, days.map((date, index) => {
|
|
1812
1917
|
if (!date) {
|
|
1813
|
-
return /* @__PURE__ */ React7.createElement("div", { key: `empty-${index}
|
|
1918
|
+
return /* @__PURE__ */ React7.createElement("div", { key: `empty-${index}` });
|
|
1814
1919
|
}
|
|
1815
1920
|
const isStart = rangeStart && date.toDateString() === rangeStart.toDateString();
|
|
1816
1921
|
const isEnd = rangeEnd && date.toDateString() === rangeEnd.toDateString();
|
|
@@ -1823,7 +1928,7 @@ function DateRangePicker({
|
|
|
1823
1928
|
{
|
|
1824
1929
|
key: date.toISOString(),
|
|
1825
1930
|
type: "button",
|
|
1826
|
-
className: `
|
|
1931
|
+
className: `flex items-center justify-center h-8 w-full rounded border-none bg-transparent cursor-pointer text-sm transition-colors hover:bg-accent hover:text-accent-foreground ${isStart || isEnd ? "bg-primary text-primary-foreground font-semibold" : ""} ${isInRange || isInHoverRange ? "bg-accent/50" : ""} ${isToday ? "border border-primary" : ""} ${disabled2 ? "cursor-not-allowed opacity-50 pointer-events-none" : ""}`,
|
|
1827
1932
|
onClick: () => !disabled2 && handleDateSelect(date),
|
|
1828
1933
|
onMouseEnter: () => setHoverDate(date),
|
|
1829
1934
|
onMouseLeave: () => setHoverDate(null),
|
|
@@ -1834,11 +1939,7 @@ function DateRangePicker({
|
|
|
1834
1939
|
);
|
|
1835
1940
|
})));
|
|
1836
1941
|
};
|
|
1837
|
-
const
|
|
1838
|
-
const errorClassName = error ? "daterangepicker--error" : "";
|
|
1839
|
-
const disabledClassName = disabled ? "daterangepicker--disabled" : "";
|
|
1840
|
-
const openClassName = isOpen ? "daterangepicker--open" : "";
|
|
1841
|
-
const combinedClassName = `${baseClassName} ${errorClassName} ${disabledClassName} ${openClassName} ${className}`.trim();
|
|
1942
|
+
const combinedClassName = `relative ${className}`.trim();
|
|
1842
1943
|
const displayValue = rangeStart && rangeEnd ? `${formatDate2(rangeStart, format)}${separator}${formatDate2(rangeEnd, format)}` : rangeStart ? formatDate2(rangeStart, format) : "";
|
|
1843
1944
|
return /* @__PURE__ */ React7.createElement("div", { ref: containerRef, className: combinedClassName }, /* @__PURE__ */ React7.createElement(
|
|
1844
1945
|
"input",
|
|
@@ -1854,7 +1955,7 @@ function DateRangePicker({
|
|
|
1854
1955
|
name: `${name}[end]`,
|
|
1855
1956
|
value: rangeEnd ? rangeEnd.toISOString() : ""
|
|
1856
1957
|
}
|
|
1857
|
-
), /* @__PURE__ */ React7.createElement("div", { className: "
|
|
1958
|
+
), /* @__PURE__ */ React7.createElement("div", { className: "relative" }, showIcon && /* @__PURE__ */ React7.createElement("span", { className: "absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none", "aria-hidden": "true" }, /* @__PURE__ */ React7.createElement(
|
|
1858
1959
|
"svg",
|
|
1859
1960
|
{
|
|
1860
1961
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -1872,7 +1973,7 @@ function DateRangePicker({
|
|
|
1872
1973
|
"input",
|
|
1873
1974
|
{
|
|
1874
1975
|
type: "text",
|
|
1875
|
-
className:
|
|
1976
|
+
className: `flex h-9 w-full rounded-md border border-input bg-transparent ${showIcon ? "pl-10" : "pl-3"} ${clearable && (rangeStart || rangeEnd) ? "pr-10" : "pr-3"} py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground 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" : ""}`,
|
|
1876
1977
|
value: displayValue,
|
|
1877
1978
|
onClick: handleToggle,
|
|
1878
1979
|
onBlur,
|
|
@@ -1888,13 +1989,13 @@ function DateRangePicker({
|
|
|
1888
1989
|
"button",
|
|
1889
1990
|
{
|
|
1890
1991
|
type: "button",
|
|
1891
|
-
className: "
|
|
1992
|
+
className: "absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors",
|
|
1892
1993
|
onClick: handleClear,
|
|
1893
1994
|
"aria-label": "Clear date range",
|
|
1894
1995
|
tabIndex: -1
|
|
1895
1996
|
},
|
|
1896
1997
|
"\u2715"
|
|
1897
|
-
)), isOpen && !disabled && /* @__PURE__ */ React7.createElement("div", { className: "
|
|
1998
|
+
)), isOpen && !disabled && /* @__PURE__ */ React7.createElement("div", { className: "absolute z-50 top-full mt-1 min-w-full rounded-md border border-border bg-popover text-popover-foreground shadow-md p-3" }, renderCalendar(), rangeStart && !rangeEnd && /* @__PURE__ */ React7.createElement("div", { className: "text-xs text-muted-foreground text-center pt-2 border-t border-border mt-2" }, "Select end date")));
|
|
1898
1999
|
}
|
|
1899
2000
|
DateRangePicker.displayName = "DateRangePicker";
|
|
1900
2001
|
function htmlToMarkdown(html) {
|
|
@@ -2049,17 +2150,13 @@ function RichTextEditor({
|
|
|
2049
2150
|
}
|
|
2050
2151
|
}
|
|
2051
2152
|
};
|
|
2052
|
-
const
|
|
2053
|
-
const errorClassName = error ? "richtexteditor--error" : "";
|
|
2054
|
-
const disabledClassName = disabled ? "richtexteditor--disabled" : "";
|
|
2055
|
-
const modeClassName = `richtexteditor--${currentMode}`;
|
|
2056
|
-
const combinedClassName = `${baseClassName} ${errorClassName} ${disabledClassName} ${modeClassName} ${className}`.trim();
|
|
2153
|
+
const combinedClassName = `rounded-md border border-input ${error ? "border-red-500 ring-1 ring-red-500" : ""} ${disabled ? "opacity-50 cursor-not-allowed" : ""} ${className}`.trim();
|
|
2057
2154
|
const editorStyle = {
|
|
2058
2155
|
minHeight,
|
|
2059
2156
|
maxHeight,
|
|
2060
2157
|
overflowY: maxHeight ? "auto" : void 0
|
|
2061
2158
|
};
|
|
2062
|
-
return /* @__PURE__ */ React7.createElement("div", { className: combinedClassName }, /* @__PURE__ */ React7.createElement("input", { type: "hidden", name, value: content }), showToolbar && /* @__PURE__ */ React7.createElement("div", { className: "
|
|
2159
|
+
return /* @__PURE__ */ React7.createElement("div", { className: combinedClassName }, /* @__PURE__ */ React7.createElement("input", { type: "hidden", name, value: content }), showToolbar && /* @__PURE__ */ React7.createElement("div", { className: "flex items-center justify-between p-2 border-b border-border bg-muted/50" }, /* @__PURE__ */ React7.createElement("div", { className: "flex items-center gap-1" }, toolbarButtons.map((buttonName) => {
|
|
2063
2160
|
const button = toolbarConfig[buttonName];
|
|
2064
2161
|
if (!button) return null;
|
|
2065
2162
|
return /* @__PURE__ */ React7.createElement(
|
|
@@ -2067,7 +2164,7 @@ function RichTextEditor({
|
|
|
2067
2164
|
{
|
|
2068
2165
|
key: buttonName,
|
|
2069
2166
|
type: "button",
|
|
2070
|
-
className: "
|
|
2167
|
+
className: "flex items-center justify-center h-8 w-8 rounded border-none bg-transparent hover:bg-accent text-muted-foreground hover:text-foreground cursor-pointer transition-colors disabled:cursor-not-allowed disabled:opacity-50",
|
|
2071
2168
|
onClick: () => editorRef.current && button.action(editorRef.current),
|
|
2072
2169
|
title: button.title,
|
|
2073
2170
|
disabled: disabled || currentMode === "markdown",
|
|
@@ -2079,18 +2176,18 @@ function RichTextEditor({
|
|
|
2079
2176
|
"button",
|
|
2080
2177
|
{
|
|
2081
2178
|
type: "button",
|
|
2082
|
-
className: "
|
|
2179
|
+
className: "flex items-center justify-center h-8 px-3 rounded border-none bg-transparent hover:bg-accent text-xs font-medium text-muted-foreground hover:text-foreground cursor-pointer transition-colors disabled:cursor-not-allowed disabled:opacity-50",
|
|
2083
2180
|
onClick: handleModeToggle,
|
|
2084
2181
|
disabled,
|
|
2085
2182
|
title: `Switch to ${currentMode === "wysiwyg" ? "Markdown" : "WYSIWYG"}`,
|
|
2086
2183
|
"aria-label": `Switch to ${currentMode === "wysiwyg" ? "Markdown" : "WYSIWYG"}`
|
|
2087
2184
|
},
|
|
2088
2185
|
currentMode === "wysiwyg" ? "MD" : "WYSIWYG"
|
|
2089
|
-
)), /* @__PURE__ */ React7.createElement("div", {
|
|
2186
|
+
)), /* @__PURE__ */ React7.createElement("div", { style: editorStyle }, currentMode === "wysiwyg" ? /* @__PURE__ */ React7.createElement(
|
|
2090
2187
|
"div",
|
|
2091
2188
|
{
|
|
2092
2189
|
ref: editorRef,
|
|
2093
|
-
className: "
|
|
2190
|
+
className: "w-full p-3 text-base md:text-sm outline-none bg-transparent focus-visible:outline-none [&:empty:before]:content-[attr(data-placeholder)] [&:empty:before]:text-muted-foreground",
|
|
2094
2191
|
role: "textbox",
|
|
2095
2192
|
contentEditable: !disabled,
|
|
2096
2193
|
onInput: handleWysiwygChange,
|
|
@@ -2105,7 +2202,7 @@ function RichTextEditor({
|
|
|
2105
2202
|
"textarea",
|
|
2106
2203
|
{
|
|
2107
2204
|
ref: textareaRef,
|
|
2108
|
-
className: "
|
|
2205
|
+
className: "w-full p-3 text-base md:text-sm outline-none bg-transparent resize-none focus-visible:outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
|
|
2109
2206
|
value: content,
|
|
2110
2207
|
onChange: handleMarkdownChange,
|
|
2111
2208
|
onBlur,
|
|
@@ -2114,7 +2211,8 @@ function RichTextEditor({
|
|
|
2114
2211
|
placeholder,
|
|
2115
2212
|
"aria-invalid": error || props["aria-invalid"] ? "true" : "false",
|
|
2116
2213
|
"aria-describedby": props["aria-describedby"],
|
|
2117
|
-
"aria-required": required || props["aria-required"]
|
|
2214
|
+
"aria-required": required || props["aria-required"],
|
|
2215
|
+
style: editorStyle
|
|
2118
2216
|
}
|
|
2119
2217
|
)));
|
|
2120
2218
|
}
|