@krak-stack/registry 0.8.3 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -5
- package/dist/components/ui/animated-list.js +5 -0
- package/dist/components/ui/app-switcher.d.ts +2 -1
- package/dist/components/ui/app-switcher.js +5 -1
- package/dist/components/ui/async-action-button.d.ts +2 -1
- package/dist/components/ui/async-action-button.js +3 -1
- package/dist/components/ui/bulk-list-input.d.ts +2 -1
- package/dist/components/ui/bulk-list-input.js +6 -1
- package/dist/components/ui/calendar.d.ts +10 -0
- package/dist/components/ui/choice-cards.d.ts +1 -0
- package/dist/components/ui/choice-cards.js +7 -1
- package/dist/components/ui/color-picker.d.ts +2 -1
- package/dist/components/ui/color-picker.js +4 -1
- package/dist/components/ui/cron-expression-editor.d.ts +3 -1
- package/dist/components/ui/cron-expression-editor.js +13 -3
- package/dist/components/ui/danger-confirmation.d.ts +1 -0
- package/dist/components/ui/danger-confirmation.js +5 -1
- package/dist/components/ui/date-picker.d.ts +33 -0
- package/dist/components/ui/date-picker.js +470 -0
- package/dist/components/ui/date-picker.schema.d.ts +9 -0
- package/dist/components/ui/editable-text.js +8 -1
- package/dist/components/ui/form.d.ts +5 -5
- package/dist/components/ui/image-crop-editor.js +10 -1
- package/dist/components/ui/phone-number-input.d.ts +3 -1
- package/dist/components/ui/phone-number-input.js +53 -13
- package/dist/components/ui/phone-number-input.schema.d.ts +7 -0
- package/dist/components/ui/{copy-value.d.ts → secret-value.d.ts} +4 -6
- package/dist/components/ui/secret-value.js +222 -0
- package/dist/components/ui/select-with-custom-input.d.ts +36 -0
- package/dist/components/ui/select-with-custom-input.js +275 -0
- package/dist/components/ui/sidebar-layout.js +1 -0
- package/dist/components/ui/stepper.js +8 -0
- package/dist/components/ui/time-picker.d.ts +41 -0
- package/dist/components/ui/time-picker.js +488 -0
- package/dist/components/ui/time-picker.schema.d.ts +14 -0
- package/dist/components/ui/timezone-select.d.ts +2 -1
- package/dist/components/ui/timezone-select.js +5 -1
- package/dist/components/ui/toast.d.ts +18 -0
- package/dist/components/ui/toast.js +121 -0
- package/dist/components/ui/unsaved-changes-guard.d.ts +2 -1
- package/dist/components/ui/unsaved-changes-guard.js +4 -1
- package/dist/components/ui/upload-attachment.js +3 -0
- package/dist/lib/docs.js +1 -0
- package/package.json +23 -5
- package/dist/components/ui/copy-value.js +0 -319
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
// ../../src/components/ui/date-picker.tsx
|
|
2
|
+
import { useEffect as useEffect2, useId, useRef as useRef2, useState } from "react";
|
|
3
|
+
import { CalendarDays, X } from "lucide-react";
|
|
4
|
+
import { enUS, fr } from "react-day-picker/locale";
|
|
5
|
+
|
|
6
|
+
// ../../src/components/ui/calendar.tsx
|
|
7
|
+
import * as React from "react";
|
|
8
|
+
import { cn as cn2 } from "cn";
|
|
9
|
+
import {
|
|
10
|
+
DayPicker,
|
|
11
|
+
getDefaultClassNames
|
|
12
|
+
} from "react-day-picker";
|
|
13
|
+
|
|
14
|
+
// ../../src/components/ui/button.tsx
|
|
15
|
+
import { Button as ButtonPrimitive } from "@base-ui/react/button";
|
|
16
|
+
import { cva } from "class-variance-authority";
|
|
17
|
+
|
|
18
|
+
// ../../src/lib/utils.ts
|
|
19
|
+
import { cn } from "cn";
|
|
20
|
+
|
|
21
|
+
// ../../src/components/ui/button.tsx
|
|
22
|
+
import { jsx } from "react/jsx-runtime";
|
|
23
|
+
var buttonVariants = cva("group/button inline-flex shrink-0 items-center justify-center rounded-md border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", {
|
|
24
|
+
variants: {
|
|
25
|
+
variant: {
|
|
26
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/80",
|
|
27
|
+
outline: "border-border bg-background shadow-xs hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
|
|
28
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
|
|
29
|
+
ghost: "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
|
|
30
|
+
destructive: "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
|
|
31
|
+
link: "text-primary underline-offset-4 hover:underline"
|
|
32
|
+
},
|
|
33
|
+
size: {
|
|
34
|
+
default: "h-9 gap-1.5 px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
35
|
+
xs: "h-6 gap-1 rounded-[min(var(--radius-md),8px)] px-2 text-xs in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
|
|
36
|
+
sm: "h-8 gap-1 rounded-[min(var(--radius-md),10px)] px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5",
|
|
37
|
+
lg: "h-10 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
38
|
+
icon: "size-9",
|
|
39
|
+
"icon-xs": "size-6 rounded-[min(var(--radius-md),8px)] in-data-[slot=button-group]:rounded-md [&_svg:not([class*='size-'])]:size-3",
|
|
40
|
+
"icon-sm": "size-8 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-md",
|
|
41
|
+
"icon-lg": "size-10"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
defaultVariants: {
|
|
45
|
+
variant: "default",
|
|
46
|
+
size: "default"
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
function Button({
|
|
50
|
+
className,
|
|
51
|
+
variant = "default",
|
|
52
|
+
size = "default",
|
|
53
|
+
...props
|
|
54
|
+
}) {
|
|
55
|
+
return /* @__PURE__ */ jsx(ButtonPrimitive, {
|
|
56
|
+
"data-slot": "button",
|
|
57
|
+
className: cn(buttonVariants({ variant, size, className })),
|
|
58
|
+
...props
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// ../../src/components/ui/calendar.tsx
|
|
63
|
+
import { ChevronLeftIcon, ChevronRightIcon, ChevronDownIcon } from "lucide-react";
|
|
64
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
65
|
+
function Calendar({
|
|
66
|
+
className,
|
|
67
|
+
classNames,
|
|
68
|
+
showOutsideDays = true,
|
|
69
|
+
captionLayout = "label",
|
|
70
|
+
buttonVariant = "ghost",
|
|
71
|
+
locale,
|
|
72
|
+
formatters,
|
|
73
|
+
components,
|
|
74
|
+
...props
|
|
75
|
+
}) {
|
|
76
|
+
const defaultClassNames = getDefaultClassNames();
|
|
77
|
+
return /* @__PURE__ */ jsx2(DayPicker, {
|
|
78
|
+
showOutsideDays,
|
|
79
|
+
className: cn2("group/calendar bg-background p-3 [--cell-radius:var(--radius-md)] [--cell-size:--spacing(8)] in-data-[slot=card-content]:bg-transparent in-data-[slot=popover-content]:bg-transparent", String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`, String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`, className),
|
|
80
|
+
captionLayout,
|
|
81
|
+
locale,
|
|
82
|
+
formatters: {
|
|
83
|
+
formatMonthDropdown: (date) => date.toLocaleString(locale?.code, { month: "short" }),
|
|
84
|
+
...formatters
|
|
85
|
+
},
|
|
86
|
+
classNames: {
|
|
87
|
+
root: cn2("w-fit", defaultClassNames.root),
|
|
88
|
+
months: cn2("relative flex flex-col gap-4 md:flex-row", defaultClassNames.months),
|
|
89
|
+
month: cn2("flex w-full flex-col gap-4", defaultClassNames.month),
|
|
90
|
+
nav: cn2("absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1", defaultClassNames.nav),
|
|
91
|
+
button_previous: cn2(buttonVariants({ variant: buttonVariant }), "size-(--cell-size) p-0 select-none aria-disabled:opacity-50", defaultClassNames.button_previous),
|
|
92
|
+
button_next: cn2(buttonVariants({ variant: buttonVariant }), "size-(--cell-size) p-0 select-none aria-disabled:opacity-50", defaultClassNames.button_next),
|
|
93
|
+
month_caption: cn2("flex h-(--cell-size) w-full items-center justify-center px-(--cell-size)", defaultClassNames.month_caption),
|
|
94
|
+
dropdowns: cn2("flex h-(--cell-size) w-full items-center justify-center gap-1.5 text-sm font-medium", defaultClassNames.dropdowns),
|
|
95
|
+
dropdown_root: cn2("relative rounded-(--cell-radius)", defaultClassNames.dropdown_root),
|
|
96
|
+
dropdown: cn2("absolute inset-0 bg-popover opacity-0", defaultClassNames.dropdown),
|
|
97
|
+
caption_label: cn2("font-medium select-none", captionLayout === "label" ? "text-sm" : "flex items-center gap-1 rounded-(--cell-radius) text-sm [&>svg]:size-3.5 [&>svg]:text-muted-foreground", defaultClassNames.caption_label),
|
|
98
|
+
month_grid: cn2("w-full border-collapse", defaultClassNames.month_grid),
|
|
99
|
+
weekdays: cn2("flex", defaultClassNames.weekdays),
|
|
100
|
+
weekday: cn2("flex-1 rounded-(--cell-radius) text-[0.8rem] font-normal text-muted-foreground select-none", defaultClassNames.weekday),
|
|
101
|
+
week: cn2("mt-2 flex w-full", defaultClassNames.week),
|
|
102
|
+
week_number_header: cn2("w-(--cell-size) select-none", defaultClassNames.week_number_header),
|
|
103
|
+
week_number: cn2("text-[0.8rem] text-muted-foreground select-none", defaultClassNames.week_number),
|
|
104
|
+
day: cn2("group/day relative aspect-square h-full w-full rounded-(--cell-radius) p-0 text-center select-none [&:last-child[data-selected=true]_button]:rounded-r-(--cell-radius)", props.showWeekNumber ? "[&:nth-child(2)[data-selected=true]_button]:rounded-l-(--cell-radius)" : "[&:first-child[data-selected=true]_button]:rounded-l-(--cell-radius)", defaultClassNames.day),
|
|
105
|
+
range_start: cn2("relative isolate z-0 rounded-l-(--cell-radius) bg-muted after:absolute after:inset-y-0 after:right-0 after:w-4 after:bg-muted", defaultClassNames.range_start),
|
|
106
|
+
range_middle: cn2("rounded-none", defaultClassNames.range_middle),
|
|
107
|
+
range_end: cn2("relative isolate z-0 rounded-r-(--cell-radius) bg-muted after:absolute after:inset-y-0 after:left-0 after:w-4 after:bg-muted", defaultClassNames.range_end),
|
|
108
|
+
today: cn2("rounded-(--cell-radius) bg-muted text-foreground data-[selected=true]:rounded-none", defaultClassNames.today),
|
|
109
|
+
outside: cn2("text-muted-foreground aria-selected:text-muted-foreground", defaultClassNames.outside),
|
|
110
|
+
disabled: cn2("text-muted-foreground opacity-50", defaultClassNames.disabled),
|
|
111
|
+
hidden: cn2("invisible", defaultClassNames.hidden),
|
|
112
|
+
...classNames
|
|
113
|
+
},
|
|
114
|
+
components: {
|
|
115
|
+
Root: ({ className, rootRef, ...props }) => {
|
|
116
|
+
return /* @__PURE__ */ jsx2("div", {
|
|
117
|
+
"data-slot": "calendar",
|
|
118
|
+
ref: rootRef,
|
|
119
|
+
className: cn2(className),
|
|
120
|
+
...props
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
Chevron: ({ className, orientation, ...props }) => {
|
|
124
|
+
if (orientation === "left") {
|
|
125
|
+
return /* @__PURE__ */ jsx2(ChevronLeftIcon, {
|
|
126
|
+
className: cn2("size-4", className),
|
|
127
|
+
...props
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
if (orientation === "right") {
|
|
131
|
+
return /* @__PURE__ */ jsx2(ChevronRightIcon, {
|
|
132
|
+
className: cn2("size-4", className),
|
|
133
|
+
...props
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
return /* @__PURE__ */ jsx2(ChevronDownIcon, {
|
|
137
|
+
className: cn2("size-4", className),
|
|
138
|
+
...props
|
|
139
|
+
});
|
|
140
|
+
},
|
|
141
|
+
DayButton: ({ ...props }) => /* @__PURE__ */ jsx2(CalendarDayButton, {
|
|
142
|
+
locale,
|
|
143
|
+
...props
|
|
144
|
+
}),
|
|
145
|
+
WeekNumber: ({ children, ...props }) => {
|
|
146
|
+
return /* @__PURE__ */ jsx2("td", {
|
|
147
|
+
...props,
|
|
148
|
+
children: /* @__PURE__ */ jsx2("div", {
|
|
149
|
+
className: "flex size-(--cell-size) items-center justify-center text-center",
|
|
150
|
+
children
|
|
151
|
+
})
|
|
152
|
+
});
|
|
153
|
+
},
|
|
154
|
+
...components
|
|
155
|
+
},
|
|
156
|
+
...props
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
function CalendarDayButton({
|
|
160
|
+
className,
|
|
161
|
+
day,
|
|
162
|
+
modifiers,
|
|
163
|
+
locale,
|
|
164
|
+
...props
|
|
165
|
+
}) {
|
|
166
|
+
const defaultClassNames = getDefaultClassNames();
|
|
167
|
+
const ref = React.useRef(null);
|
|
168
|
+
React.useEffect(() => {
|
|
169
|
+
if (modifiers.focused)
|
|
170
|
+
ref.current?.focus();
|
|
171
|
+
}, [modifiers.focused]);
|
|
172
|
+
return /* @__PURE__ */ jsx2(Button, {
|
|
173
|
+
variant: "ghost",
|
|
174
|
+
size: "icon",
|
|
175
|
+
"data-day": day.date.toLocaleDateString(locale?.code),
|
|
176
|
+
"data-selected-single": modifiers.selected && !modifiers.range_start && !modifiers.range_end && !modifiers.range_middle,
|
|
177
|
+
"data-range-start": modifiers.range_start,
|
|
178
|
+
"data-range-end": modifiers.range_end,
|
|
179
|
+
"data-range-middle": modifiers.range_middle,
|
|
180
|
+
className: cn2("relative isolate z-10 flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 border-0 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-[3px] group-data-[focused=true]/day:ring-ring/50 data-[range-end=true]:rounded-(--cell-radius) data-[range-end=true]:rounded-r-(--cell-radius) data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground data-[range-middle=true]:rounded-none data-[range-middle=true]:bg-muted data-[range-middle=true]:text-foreground data-[range-start=true]:rounded-(--cell-radius) data-[range-start=true]:rounded-l-(--cell-radius) data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground dark:hover:text-foreground [&>span]:text-xs [&>span]:opacity-70", defaultClassNames.day, className),
|
|
181
|
+
...props
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// ../../src/components/ui/input.tsx
|
|
186
|
+
import { Input as InputPrimitive } from "@base-ui/react/input";
|
|
187
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
188
|
+
function Input({ className, type, ...props }) {
|
|
189
|
+
return /* @__PURE__ */ jsx3(InputPrimitive, {
|
|
190
|
+
type,
|
|
191
|
+
"data-slot": "input",
|
|
192
|
+
className: cn("h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-2.5 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40", className),
|
|
193
|
+
...props
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// ../../src/components/ui/popover.tsx
|
|
198
|
+
import { Popover as PopoverPrimitive } from "@base-ui/react/popover";
|
|
199
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
200
|
+
function Popover({ ...props }) {
|
|
201
|
+
return /* @__PURE__ */ jsx4(PopoverPrimitive.Root, {
|
|
202
|
+
"data-slot": "popover",
|
|
203
|
+
...props
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
function PopoverTrigger({ ...props }) {
|
|
207
|
+
return /* @__PURE__ */ jsx4(PopoverPrimitive.Trigger, {
|
|
208
|
+
"data-slot": "popover-trigger",
|
|
209
|
+
...props
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
function PopoverContent({
|
|
213
|
+
className,
|
|
214
|
+
align = "center",
|
|
215
|
+
alignOffset = 0,
|
|
216
|
+
side = "bottom",
|
|
217
|
+
sideOffset = 4,
|
|
218
|
+
...props
|
|
219
|
+
}) {
|
|
220
|
+
return /* @__PURE__ */ jsx4(PopoverPrimitive.Portal, {
|
|
221
|
+
children: /* @__PURE__ */ jsx4(PopoverPrimitive.Positioner, {
|
|
222
|
+
align,
|
|
223
|
+
alignOffset,
|
|
224
|
+
side,
|
|
225
|
+
sideOffset,
|
|
226
|
+
className: "isolate z-50",
|
|
227
|
+
children: /* @__PURE__ */ jsx4(PopoverPrimitive.Popup, {
|
|
228
|
+
"data-slot": "popover-content",
|
|
229
|
+
className: cn("z-50 flex w-72 origin-(--transform-origin) flex-col gap-4 rounded-md bg-popover p-4 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className),
|
|
230
|
+
...props
|
|
231
|
+
})
|
|
232
|
+
})
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
function PopoverTitle({ className, ...props }) {
|
|
236
|
+
return /* @__PURE__ */ jsx4(PopoverPrimitive.Title, {
|
|
237
|
+
"data-slot": "popover-title",
|
|
238
|
+
className: cn("font-medium", className),
|
|
239
|
+
...props
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// ../../src/components/ui/date-picker.tsx
|
|
244
|
+
import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider";
|
|
245
|
+
|
|
246
|
+
// ../../src/components/ui/date-picker.schema.ts
|
|
247
|
+
import { Option, Schema } from "effect";
|
|
248
|
+
var DateOnlySchema = Schema.String.check(Schema.isPattern(/^(?!0000)\d{4}-\d{2}-\d{2}$/), Schema.makeFilter((value) => {
|
|
249
|
+
const date = new Date(`${value}T00:00:00.000Z`);
|
|
250
|
+
return Number.isFinite(date.getTime()) && date.toISOString().slice(0, 10) === value;
|
|
251
|
+
})).annotate({ identifier: "DateOnly" });
|
|
252
|
+
var decodeDateOnly = Schema.decodeUnknownOption(DateOnlySchema);
|
|
253
|
+
var parseDateOnly = (value) => {
|
|
254
|
+
const decoded = decodeDateOnly(value);
|
|
255
|
+
return Option.isSome(decoded) ? new Date(`${decoded.value}T00:00:00.000Z`) : undefined;
|
|
256
|
+
};
|
|
257
|
+
var getDatePickerState = ({
|
|
258
|
+
value,
|
|
259
|
+
min,
|
|
260
|
+
max
|
|
261
|
+
}) => {
|
|
262
|
+
if (min !== undefined && !parseDateOnly(min) || max !== undefined && !parseDateOnly(max) || min && max && min > max)
|
|
263
|
+
return "invalid-range";
|
|
264
|
+
if (!value)
|
|
265
|
+
return "empty";
|
|
266
|
+
if (!parseDateOnly(value))
|
|
267
|
+
return "invalid";
|
|
268
|
+
if (min && value < min || max && value > max)
|
|
269
|
+
return "out-of-range";
|
|
270
|
+
return "valid";
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
// ../../src/components/ui/date-picker.tsx
|
|
274
|
+
import { jsx as jsx5, jsxs } from "react/jsx-runtime";
|
|
275
|
+
"use client";
|
|
276
|
+
var DatePickerDayButton = (props) => {
|
|
277
|
+
const ref = useRef2(null);
|
|
278
|
+
useEffect2(() => {
|
|
279
|
+
if (props.modifiers.focused)
|
|
280
|
+
ref.current?.focus();
|
|
281
|
+
}, [props.modifiers.focused]);
|
|
282
|
+
const buttonProps = { ...props, ref };
|
|
283
|
+
return /* @__PURE__ */ jsx5(CalendarDayButton, {
|
|
284
|
+
...buttonProps
|
|
285
|
+
});
|
|
286
|
+
};
|
|
287
|
+
var labels = {
|
|
288
|
+
en: {
|
|
289
|
+
label: "Date",
|
|
290
|
+
open: "Open calendar",
|
|
291
|
+
clear: "Clear date",
|
|
292
|
+
invalid: "Enter a valid date as YYYY-MM-DD.",
|
|
293
|
+
outOfRange: "Choose a date within the allowed range.",
|
|
294
|
+
invalidRange: "The allowed date range is invalid."
|
|
295
|
+
},
|
|
296
|
+
fr: {
|
|
297
|
+
label: "Date",
|
|
298
|
+
open: "Ouvrir le calendrier",
|
|
299
|
+
clear: "Effacer la date",
|
|
300
|
+
invalid: "Saisissez une date valide au format AAAA-MM-JJ.",
|
|
301
|
+
outOfRange: "Choisissez une date dans la plage autorisée.",
|
|
302
|
+
invalidRange: "La plage de dates autorisée est invalide."
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
var DatePicker = ({
|
|
306
|
+
value,
|
|
307
|
+
onValueChange,
|
|
308
|
+
min,
|
|
309
|
+
max,
|
|
310
|
+
label,
|
|
311
|
+
name,
|
|
312
|
+
required,
|
|
313
|
+
disabled,
|
|
314
|
+
readOnly,
|
|
315
|
+
clearable = true,
|
|
316
|
+
description,
|
|
317
|
+
locale: override,
|
|
318
|
+
messages,
|
|
319
|
+
className,
|
|
320
|
+
inputClassName,
|
|
321
|
+
contentClassName,
|
|
322
|
+
calendarClassName,
|
|
323
|
+
calendarClassNames
|
|
324
|
+
}) => {
|
|
325
|
+
const id = useId();
|
|
326
|
+
const language = useKrakstackLocale(override);
|
|
327
|
+
const copy = {
|
|
328
|
+
...language.startsWith("fr") ? labels.fr : labels.en,
|
|
329
|
+
...messages?.[language.split("-")[0] ?? language],
|
|
330
|
+
...messages?.[language]
|
|
331
|
+
};
|
|
332
|
+
const [open, setOpen] = useState(false);
|
|
333
|
+
const status = getDatePickerState({ value, min, max });
|
|
334
|
+
const error = status === "invalid" ? copy.invalid : status === "out-of-range" ? copy.outOfRange : status === "invalid-range" ? copy.invalidRange : undefined;
|
|
335
|
+
const selected = status === "valid" ? parseDateOnly(value) : undefined;
|
|
336
|
+
const minimum = min ? parseDateOnly(min) : undefined;
|
|
337
|
+
const maximum = max ? parseDateOnly(max) : undefined;
|
|
338
|
+
const locked = disabled || readOnly;
|
|
339
|
+
const describedBy = [description && `${id}-description`, error && `${id}-error`].filter(Boolean).join(" ") || undefined;
|
|
340
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
341
|
+
"data-slot": "date-picker",
|
|
342
|
+
"data-state": status,
|
|
343
|
+
className: cn("grid min-w-0 gap-2", className),
|
|
344
|
+
children: [
|
|
345
|
+
/* @__PURE__ */ jsx5("label", {
|
|
346
|
+
htmlFor: id,
|
|
347
|
+
"data-slot": "date-picker-label",
|
|
348
|
+
className: "text-sm font-medium",
|
|
349
|
+
children: label ?? copy.label
|
|
350
|
+
}),
|
|
351
|
+
/* @__PURE__ */ jsxs("div", {
|
|
352
|
+
"data-slot": "date-picker-controls",
|
|
353
|
+
className: "flex min-w-0 gap-2",
|
|
354
|
+
children: [
|
|
355
|
+
/* @__PURE__ */ jsx5(Input, {
|
|
356
|
+
ref: (element) => {
|
|
357
|
+
element?.setCustomValidity(error ?? "");
|
|
358
|
+
},
|
|
359
|
+
"data-component": "date-picker-input",
|
|
360
|
+
id,
|
|
361
|
+
name,
|
|
362
|
+
value,
|
|
363
|
+
required,
|
|
364
|
+
disabled,
|
|
365
|
+
readOnly,
|
|
366
|
+
placeholder: language.startsWith("fr") ? "AAAA-MM-JJ" : "YYYY-MM-DD",
|
|
367
|
+
autoComplete: "off",
|
|
368
|
+
spellCheck: false,
|
|
369
|
+
"aria-invalid": Boolean(error),
|
|
370
|
+
"aria-describedby": describedBy,
|
|
371
|
+
className: cn("min-w-0 flex-1 tabular-nums", inputClassName),
|
|
372
|
+
onChange: (event) => {
|
|
373
|
+
if (!locked)
|
|
374
|
+
onValueChange(event.target.value);
|
|
375
|
+
}
|
|
376
|
+
}),
|
|
377
|
+
/* @__PURE__ */ jsxs(Popover, {
|
|
378
|
+
open: open && !locked && status !== "invalid-range",
|
|
379
|
+
onOpenChange: setOpen,
|
|
380
|
+
children: [
|
|
381
|
+
/* @__PURE__ */ jsx5(PopoverTrigger, {
|
|
382
|
+
render: /* @__PURE__ */ jsx5(Button, {
|
|
383
|
+
type: "button",
|
|
384
|
+
variant: "outline",
|
|
385
|
+
size: "icon",
|
|
386
|
+
disabled: locked || status === "invalid-range",
|
|
387
|
+
"aria-label": copy.open,
|
|
388
|
+
"data-component": "date-picker-trigger"
|
|
389
|
+
}),
|
|
390
|
+
children: /* @__PURE__ */ jsx5(CalendarDays, {
|
|
391
|
+
"aria-hidden": "true"
|
|
392
|
+
})
|
|
393
|
+
}),
|
|
394
|
+
/* @__PURE__ */ jsxs(PopoverContent, {
|
|
395
|
+
initialFocus: false,
|
|
396
|
+
align: "end",
|
|
397
|
+
"data-component": "date-picker-content",
|
|
398
|
+
className: cn("w-auto max-w-[calc(100vw-2rem)] gap-0 p-0", contentClassName),
|
|
399
|
+
children: [
|
|
400
|
+
/* @__PURE__ */ jsx5(PopoverTitle, {
|
|
401
|
+
className: "sr-only",
|
|
402
|
+
children: label ?? copy.label
|
|
403
|
+
}),
|
|
404
|
+
open ? /* @__PURE__ */ jsx5(Calendar, {
|
|
405
|
+
components: { DayButton: DatePickerDayButton },
|
|
406
|
+
mode: "single",
|
|
407
|
+
required: true,
|
|
408
|
+
autoFocus: true,
|
|
409
|
+
timeZone: "UTC",
|
|
410
|
+
locale: language.startsWith("fr") ? fr : enUS,
|
|
411
|
+
selected,
|
|
412
|
+
defaultMonth: selected ?? minimum ?? maximum,
|
|
413
|
+
startMonth: minimum,
|
|
414
|
+
endMonth: maximum,
|
|
415
|
+
disabled: [
|
|
416
|
+
...minimum ? [{ before: minimum }] : [],
|
|
417
|
+
...maximum ? [{ after: maximum }] : []
|
|
418
|
+
],
|
|
419
|
+
className: calendarClassName,
|
|
420
|
+
classNames: calendarClassNames,
|
|
421
|
+
onSelect: (date) => {
|
|
422
|
+
if (locked)
|
|
423
|
+
return;
|
|
424
|
+
const next = date.toISOString().slice(0, 10);
|
|
425
|
+
if (getDatePickerState({ value: next, min, max }) !== "valid")
|
|
426
|
+
return;
|
|
427
|
+
onValueChange(next);
|
|
428
|
+
setOpen(false);
|
|
429
|
+
}
|
|
430
|
+
}) : null
|
|
431
|
+
]
|
|
432
|
+
})
|
|
433
|
+
]
|
|
434
|
+
}),
|
|
435
|
+
clearable && value ? /* @__PURE__ */ jsx5(Button, {
|
|
436
|
+
type: "button",
|
|
437
|
+
variant: "ghost",
|
|
438
|
+
size: "icon",
|
|
439
|
+
"data-component": "date-picker-clear",
|
|
440
|
+
disabled: locked,
|
|
441
|
+
"aria-label": copy.clear,
|
|
442
|
+
onClick: () => onValueChange(""),
|
|
443
|
+
children: /* @__PURE__ */ jsx5(X, {
|
|
444
|
+
"aria-hidden": "true"
|
|
445
|
+
})
|
|
446
|
+
}) : null
|
|
447
|
+
]
|
|
448
|
+
}),
|
|
449
|
+
description ? /* @__PURE__ */ jsx5("p", {
|
|
450
|
+
id: `${id}-description`,
|
|
451
|
+
"data-slot": "date-picker-description",
|
|
452
|
+
className: "text-muted-foreground text-xs",
|
|
453
|
+
children: description
|
|
454
|
+
}) : null,
|
|
455
|
+
error ? /* @__PURE__ */ jsx5("p", {
|
|
456
|
+
id: `${id}-error`,
|
|
457
|
+
"data-slot": "date-picker-error",
|
|
458
|
+
role: "status",
|
|
459
|
+
className: "text-destructive text-sm",
|
|
460
|
+
children: error
|
|
461
|
+
}) : null
|
|
462
|
+
]
|
|
463
|
+
});
|
|
464
|
+
};
|
|
465
|
+
export {
|
|
466
|
+
DateOnlySchema,
|
|
467
|
+
DatePicker,
|
|
468
|
+
getDatePickerState,
|
|
469
|
+
parseDateOnly
|
|
470
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
/** A calendar date, not a timestamp. UTC is only used to validate and display its parts. */
|
|
3
|
+
export declare const DateOnlySchema: Schema.String;
|
|
4
|
+
export declare const parseDateOnly: (value: string) => Date | undefined;
|
|
5
|
+
export declare const getDatePickerState: ({ value, min, max, }: {
|
|
6
|
+
value: string;
|
|
7
|
+
min?: string;
|
|
8
|
+
max?: string;
|
|
9
|
+
}) => "empty" | "invalid" | "invalid-range" | "out-of-range" | "valid";
|
|
@@ -78,6 +78,7 @@ var AsyncActionButton = ({
|
|
|
78
78
|
disabled,
|
|
79
79
|
locale: override,
|
|
80
80
|
messages,
|
|
81
|
+
containerClassName,
|
|
81
82
|
...props
|
|
82
83
|
}) => {
|
|
83
84
|
const locale = useKrakstackLocale(override);
|
|
@@ -115,7 +116,8 @@ var AsyncActionButton = ({
|
|
|
115
116
|
};
|
|
116
117
|
return /* @__PURE__ */ jsxs("span", {
|
|
117
118
|
"data-slot": "async-action-button",
|
|
118
|
-
|
|
119
|
+
"data-state": status,
|
|
120
|
+
className: cn("inline-flex min-w-0 flex-col items-start gap-2", containerClassName),
|
|
119
121
|
children: [
|
|
120
122
|
/* @__PURE__ */ jsxs(Button, {
|
|
121
123
|
...props,
|
|
@@ -216,6 +218,8 @@ var EditableText = ({
|
|
|
216
218
|
wasEditing.current = editing;
|
|
217
219
|
}, [editing]);
|
|
218
220
|
return /* @__PURE__ */ jsx5("div", {
|
|
221
|
+
"data-slot": "editable-text",
|
|
222
|
+
"data-state": editing ? "editing" : "idle",
|
|
219
223
|
className,
|
|
220
224
|
children: editing ? /* @__PURE__ */ jsx5(EditableTextEditor, {
|
|
221
225
|
value,
|
|
@@ -227,6 +231,7 @@ var EditableText = ({
|
|
|
227
231
|
copy,
|
|
228
232
|
onClose: () => setEditing(false)
|
|
229
233
|
}) : /* @__PURE__ */ jsxs2(Button, {
|
|
234
|
+
"data-component": "editable-text-trigger",
|
|
230
235
|
ref: trigger,
|
|
231
236
|
type: "button",
|
|
232
237
|
variant: "ghost",
|
|
@@ -266,6 +271,7 @@ var EditableTextEditor = ({
|
|
|
266
271
|
input.current?.select();
|
|
267
272
|
}, []);
|
|
268
273
|
return /* @__PURE__ */ jsxs2("div", {
|
|
274
|
+
"data-slot": "editable-text-editor",
|
|
269
275
|
className: "grid gap-3",
|
|
270
276
|
onKeyDown: (event) => {
|
|
271
277
|
if (event.nativeEvent.isComposing)
|
|
@@ -282,6 +288,7 @@ var EditableTextEditor = ({
|
|
|
282
288
|
children: label
|
|
283
289
|
}),
|
|
284
290
|
/* @__PURE__ */ jsx5(Input, {
|
|
291
|
+
"data-component": "editable-text-input",
|
|
285
292
|
ref: input,
|
|
286
293
|
id,
|
|
287
294
|
value: draft,
|
|
@@ -145,7 +145,7 @@ declare const RevertButton: ({ locale, messages, original, }: {
|
|
|
145
145
|
messages?: FormMessageTranslations;
|
|
146
146
|
original: string;
|
|
147
147
|
}) => JSX.Element | undefined;
|
|
148
|
-
declare const useAppForm: <TFormData, TOnMount extends undefined | import("@tanstack/form
|
|
148
|
+
declare const useAppForm: <TFormData, TOnMount extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnChange extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnChangeAsync extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TOnBlur extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnBlurAsync extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TOnSubmit extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnSubmitAsync extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TOnDynamic extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnDynamicAsync extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TOnServer extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TSubmitMeta>(props: import("@tanstack/react-form").FormOptions<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, TSubmitMeta>) => import("@tanstack/react-form").AppFieldExtendedReactFormApi<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, TSubmitMeta, {
|
|
149
149
|
readonly TextField: typeof TextField;
|
|
150
150
|
readonly TextAreaField: typeof TextAreaField;
|
|
151
151
|
readonly SelectField: typeof SelectField;
|
|
@@ -161,7 +161,7 @@ declare const useAppForm: <TFormData, TOnMount extends undefined | import("@tans
|
|
|
161
161
|
readonly FormError: typeof FormError;
|
|
162
162
|
readonly FieldWrapper: typeof FieldWrapper;
|
|
163
163
|
readonly BlockNavigation: typeof BlockNavigation;
|
|
164
|
-
}>, withForm: <TFormData, TOnMount extends undefined | import("@tanstack/form
|
|
164
|
+
}>, withForm: <TFormData, TOnMount extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnChange extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnChangeAsync extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TOnBlur extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnBlurAsync extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TOnSubmit extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnSubmitAsync extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TOnDynamic extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnDynamicAsync extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TOnServer extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TSubmitMeta, TRenderProps extends object = {}>({ render, props, }: import("@tanstack/react-form").WithFormProps<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, TSubmitMeta, {
|
|
165
165
|
readonly TextField: typeof TextField;
|
|
166
166
|
readonly TextAreaField: typeof TextAreaField;
|
|
167
167
|
readonly SelectField: typeof SelectField;
|
|
@@ -178,7 +178,7 @@ declare const useAppForm: <TFormData, TOnMount extends undefined | import("@tans
|
|
|
178
178
|
readonly FieldWrapper: typeof FieldWrapper;
|
|
179
179
|
readonly BlockNavigation: typeof BlockNavigation;
|
|
180
180
|
}, TRenderProps>) => import("react").FunctionComponent<import("react").PropsWithChildren<NoInfer<[unknown] extends [TRenderProps] ? any : TRenderProps> & {
|
|
181
|
-
form: import("@tanstack/react-form").AppFieldExtendedReactFormApi<[unknown] extends [TFormData] ? any : TFormData, [import("@tanstack/form
|
|
181
|
+
form: import("@tanstack/react-form").AppFieldExtendedReactFormApi<[unknown] extends [TFormData] ? any : TFormData, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnMount] ? [TOnMount] extends [TOnMount & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnMount : TOnMount, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnChange] ? [TOnChange] extends [TOnChange & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnChange : TOnChange, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnChangeAsync] ? [TOnChangeAsync] extends [TOnChangeAsync & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnChangeAsync : TOnChangeAsync, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnBlur] ? [TOnBlur] extends [TOnBlur & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnBlur : TOnBlur, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnBlurAsync] ? [TOnBlurAsync] extends [TOnBlurAsync & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnBlurAsync : TOnBlurAsync, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnSubmit] ? [TOnSubmit] extends [TOnSubmit & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnSubmit : TOnSubmit, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnSubmitAsync] ? [TOnSubmitAsync] extends [TOnSubmitAsync & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnSubmitAsync : TOnSubmitAsync, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnDynamic] ? [TOnDynamic] extends [TOnDynamic & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnDynamic : TOnDynamic, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnDynamicAsync] ? [TOnDynamicAsync] extends [TOnDynamicAsync & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnDynamicAsync : TOnDynamicAsync, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnServer] ? [TOnServer] extends [TOnServer & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnServer : TOnServer, [unknown] extends [TSubmitMeta] ? any : TSubmitMeta, {
|
|
182
182
|
readonly TextField: typeof TextField;
|
|
183
183
|
readonly TextAreaField: typeof TextAreaField;
|
|
184
184
|
readonly SelectField: typeof SelectField;
|
|
@@ -211,8 +211,8 @@ declare const useAppForm: <TFormData, TOnMount extends undefined | import("@tans
|
|
|
211
211
|
readonly FormError: typeof FormError;
|
|
212
212
|
readonly FieldWrapper: typeof FieldWrapper;
|
|
213
213
|
readonly BlockNavigation: typeof BlockNavigation;
|
|
214
|
-
}, TSubmitMeta, TRenderProps>) => <TFormData, TFields extends import("@tanstack/form
|
|
215
|
-
form: import("@tanstack/react-form").AppFieldExtendedReactFieldGroupApi<unknown, TFormData, string | import("@tanstack/form
|
|
214
|
+
}, TSubmitMeta, TRenderProps>) => <TFormData, TFields extends import("@tanstack/react-form").DeepKeysOfType<TFormData, TFieldGroupData | null | undefined> | import("@tanstack/react-form").FieldsMap<TFormData, TFieldGroupData>, TOnMount extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnChange extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnChangeAsync extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TOnBlur extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnBlurAsync extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TOnSubmit extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnSubmitAsync extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TOnDynamic extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnDynamicAsync extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TOnServer extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TFormSubmitMeta>(params: import("react").PropsWithChildren<NoInfer<TRenderProps> & {
|
|
215
|
+
form: import("@tanstack/react-form").AppFieldExtendedReactFieldGroupApi<unknown, TFormData, string | import("@tanstack/react-form").FieldsMap<unknown, TFormData>, any, any, any, any, any, any, any, any, any, any, unknown extends TSubmitMeta ? TFormSubmitMeta : TSubmitMeta, {
|
|
216
216
|
readonly TextField: typeof TextField;
|
|
217
217
|
readonly TextAreaField: typeof TextAreaField;
|
|
218
218
|
readonly SelectField: typeof SelectField;
|
|
@@ -77,6 +77,7 @@ var AsyncActionButton = ({
|
|
|
77
77
|
disabled,
|
|
78
78
|
locale: override,
|
|
79
79
|
messages,
|
|
80
|
+
containerClassName,
|
|
80
81
|
...props
|
|
81
82
|
}) => {
|
|
82
83
|
const locale = useKrakstackLocale(override);
|
|
@@ -114,7 +115,8 @@ var AsyncActionButton = ({
|
|
|
114
115
|
};
|
|
115
116
|
return /* @__PURE__ */ jsxs("span", {
|
|
116
117
|
"data-slot": "async-action-button",
|
|
117
|
-
|
|
118
|
+
"data-state": status,
|
|
119
|
+
className: cn("inline-flex min-w-0 flex-col items-start gap-2", containerClassName),
|
|
118
120
|
children: [
|
|
119
121
|
/* @__PURE__ */ jsxs(Button, {
|
|
120
122
|
...props,
|
|
@@ -239,6 +241,7 @@ var ImageCropSession = ({
|
|
|
239
241
|
const transform = size ? value.rotation === 90 ? `translate(${size.height} 0) rotate(90)` : value.rotation === 180 ? `translate(${size.width} ${size.height}) rotate(180)` : value.rotation === 270 ? `translate(0 ${size.width}) rotate(270)` : undefined : undefined;
|
|
240
242
|
const locked = disabled || pending;
|
|
241
243
|
return /* @__PURE__ */ jsxs2("div", {
|
|
244
|
+
"data-slot": "image-crop-editor",
|
|
242
245
|
className,
|
|
243
246
|
children: [
|
|
244
247
|
/* @__PURE__ */ jsx3("img", {
|
|
@@ -260,6 +263,7 @@ var ImageCropSession = ({
|
|
|
260
263
|
className: "grid min-w-0 gap-4",
|
|
261
264
|
children: [
|
|
262
265
|
crop && size ? /* @__PURE__ */ jsx3("svg", {
|
|
266
|
+
"data-slot": "image-crop-preview",
|
|
263
267
|
role: "img",
|
|
264
268
|
"aria-label": label,
|
|
265
269
|
viewBox: `${crop.x} ${crop.y} ${crop.width} ${crop.height}`,
|
|
@@ -312,10 +316,12 @@ var ImageCropSession = ({
|
|
|
312
316
|
children: failed ? copy.loadError : copy.loading
|
|
313
317
|
}),
|
|
314
318
|
/* @__PURE__ */ jsx3("p", {
|
|
319
|
+
"data-slot": "image-crop-help",
|
|
315
320
|
className: "text-muted-foreground text-sm",
|
|
316
321
|
children: copy.help
|
|
317
322
|
}),
|
|
318
323
|
/* @__PURE__ */ jsxs2("fieldset", {
|
|
324
|
+
"data-slot": "image-crop-controls",
|
|
319
325
|
disabled: locked || !crop,
|
|
320
326
|
className: "grid min-w-0 gap-3",
|
|
321
327
|
children: [
|
|
@@ -326,6 +332,8 @@ var ImageCropSession = ({
|
|
|
326
332
|
children: key === "zoom" ? copy.zoom : key === "x" ? copy.horizontal : copy.vertical
|
|
327
333
|
}),
|
|
328
334
|
/* @__PURE__ */ jsx3("input", {
|
|
335
|
+
"data-slot": "image-crop-slider",
|
|
336
|
+
"data-control": key,
|
|
329
337
|
type: "range",
|
|
330
338
|
min: key === "zoom" ? 1 : 0,
|
|
331
339
|
max: key === "zoom" ? 4 : 100,
|
|
@@ -340,6 +348,7 @@ var ImageCropSession = ({
|
|
|
340
348
|
]
|
|
341
349
|
}, key)),
|
|
342
350
|
/* @__PURE__ */ jsxs2("div", {
|
|
351
|
+
"data-slot": "image-crop-actions",
|
|
343
352
|
className: "flex flex-wrap gap-2",
|
|
344
353
|
children: [
|
|
345
354
|
/* @__PURE__ */ jsx3(Button, {
|