@krak-stack/registry 0.5.0 → 0.7.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 +14 -0
- package/dist/components/ui/animated-list.d.ts +22 -0
- package/dist/components/ui/animated-list.js +219 -0
- package/dist/components/ui/animated-number.d.ts +9 -0
- package/dist/components/ui/animated-number.js +52 -0
- package/dist/components/ui/async-action-button.d.ts +16 -0
- package/dist/components/ui/async-action-button.js +147 -0
- package/dist/components/ui/auto-height.d.ts +9 -0
- package/dist/components/ui/auto-height.js +45 -0
- package/dist/components/ui/danger-confirmation.d.ts +20 -0
- package/dist/components/ui/danger-confirmation.js +394 -0
- package/dist/components/ui/editable-text.d.ts +19 -0
- package/dist/components/ui/editable-text.js +334 -0
- package/dist/components/ui/image-crop-editor.d.ts +41 -0
- package/dist/components/ui/image-crop-editor.js +408 -0
- package/dist/components/ui/presence-transition.d.ts +9 -0
- package/dist/components/ui/presence-transition.js +41 -0
- package/dist/components/ui/timezone-select.d.ts +56 -0
- package/dist/components/ui/timezone-select.js +898 -0
- package/dist/components/ui/timezone-select.schema.d.ts +9 -0
- package/dist/components/ui/unsaved-changes-guard.d.ts +15 -0
- package/dist/components/ui/unsaved-changes-guard.js +235 -0
- package/package.json +42 -1
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
// ../../src/components/ui/image-crop-editor.tsx
|
|
2
|
+
import { useCallback, useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
|
|
3
|
+
|
|
4
|
+
// ../../src/components/ui/async-action-button.tsx
|
|
5
|
+
import { Check, LoaderCircle, RotateCcw } from "lucide-react";
|
|
6
|
+
import { useEffect, useRef, useState } from "react";
|
|
7
|
+
|
|
8
|
+
// ../../src/components/ui/button.tsx
|
|
9
|
+
import { Button as ButtonPrimitive } from "@base-ui/react/button";
|
|
10
|
+
import { cva } from "class-variance-authority";
|
|
11
|
+
|
|
12
|
+
// ../../src/lib/utils.ts
|
|
13
|
+
import { cn } from "cn";
|
|
14
|
+
|
|
15
|
+
// ../../src/components/ui/button.tsx
|
|
16
|
+
import { jsx } from "react/jsx-runtime";
|
|
17
|
+
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", {
|
|
18
|
+
variants: {
|
|
19
|
+
variant: {
|
|
20
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/80",
|
|
21
|
+
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",
|
|
22
|
+
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",
|
|
23
|
+
ghost: "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
|
|
24
|
+
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",
|
|
25
|
+
link: "text-primary underline-offset-4 hover:underline"
|
|
26
|
+
},
|
|
27
|
+
size: {
|
|
28
|
+
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",
|
|
29
|
+
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",
|
|
30
|
+
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",
|
|
31
|
+
lg: "h-10 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
32
|
+
icon: "size-9",
|
|
33
|
+
"icon-xs": "size-6 rounded-[min(var(--radius-md),8px)] in-data-[slot=button-group]:rounded-md [&_svg:not([class*='size-'])]:size-3",
|
|
34
|
+
"icon-sm": "size-8 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-md",
|
|
35
|
+
"icon-lg": "size-10"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
defaultVariants: {
|
|
39
|
+
variant: "default",
|
|
40
|
+
size: "default"
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
function Button({
|
|
44
|
+
className,
|
|
45
|
+
variant = "default",
|
|
46
|
+
size = "default",
|
|
47
|
+
...props
|
|
48
|
+
}) {
|
|
49
|
+
return /* @__PURE__ */ jsx(ButtonPrimitive, {
|
|
50
|
+
"data-slot": "button",
|
|
51
|
+
className: cn(buttonVariants({ variant, size, className })),
|
|
52
|
+
...props
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// ../../src/components/ui/async-action-button.tsx
|
|
57
|
+
import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider";
|
|
58
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
59
|
+
var labels = {
|
|
60
|
+
en: {
|
|
61
|
+
pending: "Working…",
|
|
62
|
+
success: "Completed",
|
|
63
|
+
retry: "Try again",
|
|
64
|
+
error: "The action failed. Please try again."
|
|
65
|
+
},
|
|
66
|
+
fr: {
|
|
67
|
+
pending: "En cours…",
|
|
68
|
+
success: "Terminé",
|
|
69
|
+
retry: "Réessayer",
|
|
70
|
+
error: "L’action a échoué. Veuillez réessayer."
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
var AsyncActionButton = ({
|
|
74
|
+
onAction,
|
|
75
|
+
onPendingChange,
|
|
76
|
+
children,
|
|
77
|
+
disabled,
|
|
78
|
+
locale: override,
|
|
79
|
+
messages,
|
|
80
|
+
...props
|
|
81
|
+
}) => {
|
|
82
|
+
const locale = useKrakstackLocale(override);
|
|
83
|
+
const copy = {
|
|
84
|
+
...locale.startsWith("fr") ? labels.fr : labels.en,
|
|
85
|
+
...messages?.[locale.split("-")[0] ?? locale],
|
|
86
|
+
...messages?.[locale]
|
|
87
|
+
};
|
|
88
|
+
const [status, setStatus] = useState("idle");
|
|
89
|
+
const locked = useRef(false);
|
|
90
|
+
const mounted = useRef(false);
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
mounted.current = true;
|
|
93
|
+
return () => {
|
|
94
|
+
mounted.current = false;
|
|
95
|
+
};
|
|
96
|
+
}, []);
|
|
97
|
+
const run = async () => {
|
|
98
|
+
if (locked.current || disabled)
|
|
99
|
+
return;
|
|
100
|
+
locked.current = true;
|
|
101
|
+
setStatus("pending");
|
|
102
|
+
onPendingChange?.(true);
|
|
103
|
+
try {
|
|
104
|
+
await onAction();
|
|
105
|
+
if (mounted.current)
|
|
106
|
+
setStatus("success");
|
|
107
|
+
} catch {
|
|
108
|
+
if (mounted.current)
|
|
109
|
+
setStatus("error");
|
|
110
|
+
} finally {
|
|
111
|
+
locked.current = false;
|
|
112
|
+
onPendingChange?.(false);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
116
|
+
"data-slot": "async-action-button",
|
|
117
|
+
className: "inline-flex min-w-0 flex-col items-start gap-2",
|
|
118
|
+
children: [
|
|
119
|
+
/* @__PURE__ */ jsxs(Button, {
|
|
120
|
+
...props,
|
|
121
|
+
type: "button",
|
|
122
|
+
disabled: disabled || status === "pending",
|
|
123
|
+
"aria-busy": status === "pending",
|
|
124
|
+
onClick: () => {
|
|
125
|
+
run();
|
|
126
|
+
},
|
|
127
|
+
children: [
|
|
128
|
+
status === "pending" ? /* @__PURE__ */ jsx2(LoaderCircle, {
|
|
129
|
+
"aria-hidden": "true",
|
|
130
|
+
className: "motion-safe:animate-spin"
|
|
131
|
+
}) : status === "success" ? /* @__PURE__ */ jsx2(Check, {
|
|
132
|
+
"aria-hidden": "true"
|
|
133
|
+
}) : status === "error" ? /* @__PURE__ */ jsx2(RotateCcw, {
|
|
134
|
+
"aria-hidden": "true"
|
|
135
|
+
}) : null,
|
|
136
|
+
status === "pending" ? copy.pending : status === "success" ? copy.success : status === "error" ? copy.retry : children
|
|
137
|
+
]
|
|
138
|
+
}),
|
|
139
|
+
/* @__PURE__ */ jsx2("span", {
|
|
140
|
+
"data-slot": "async-action-feedback",
|
|
141
|
+
role: "status",
|
|
142
|
+
className: status === "error" ? "text-destructive text-sm" : "sr-only",
|
|
143
|
+
children: status === "error" ? copy.error : status === "success" ? copy.success : status === "pending" ? copy.pending : ""
|
|
144
|
+
})
|
|
145
|
+
]
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
// ../../src/components/ui/image-crop-editor.tsx
|
|
150
|
+
import { useKrakstackLocale as useKrakstackLocale2 } from "@krak-stack/registry/krakstack-provider";
|
|
151
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
152
|
+
var labels2 = {
|
|
153
|
+
en: {
|
|
154
|
+
zoom: "Zoom",
|
|
155
|
+
horizontal: "Horizontal position",
|
|
156
|
+
vertical: "Vertical position",
|
|
157
|
+
rotate: "Rotate 90°",
|
|
158
|
+
reset: "Reset crop",
|
|
159
|
+
export: "Export image",
|
|
160
|
+
loading: "Loading image…",
|
|
161
|
+
loadError: "The image could not be loaded. Check the source and its cross-origin policy.",
|
|
162
|
+
help: "Drag to position the image, or use the position and zoom sliders with the arrow keys.",
|
|
163
|
+
exportError: "Could not export the image. Check image permissions and try again."
|
|
164
|
+
},
|
|
165
|
+
fr: {
|
|
166
|
+
zoom: "Zoom",
|
|
167
|
+
horizontal: "Position horizontale",
|
|
168
|
+
vertical: "Position verticale",
|
|
169
|
+
rotate: "Pivoter de 90°",
|
|
170
|
+
reset: "Réinitialiser le cadrage",
|
|
171
|
+
export: "Exporter l’image",
|
|
172
|
+
loading: "Chargement de l’image…",
|
|
173
|
+
loadError: "Impossible de charger l’image. Vérifiez sa source et sa politique d’accès interorigine.",
|
|
174
|
+
help: "Faites glisser l’image ou utilisez les curseurs de position et de zoom avec les touches fléchées.",
|
|
175
|
+
exportError: "Impossible d’exporter l’image. Vérifiez les autorisations de l’image et réessayez."
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
var clamp = (value, min, max) => Math.min(max, Math.max(min, Number.isFinite(value) ? value : min));
|
|
179
|
+
var getImageCropGeometry = (width, height, value, aspectRatio = 1) => {
|
|
180
|
+
const rotated = value.rotation === 90 || value.rotation === 270;
|
|
181
|
+
const sourceWidth = rotated ? height : width;
|
|
182
|
+
const sourceHeight = rotated ? width : height;
|
|
183
|
+
const ratio = clamp(aspectRatio, 0.1, 10);
|
|
184
|
+
const cropWidth = Math.min(sourceWidth, sourceHeight * ratio) / clamp(value.zoom, 1, 4);
|
|
185
|
+
const cropHeight = cropWidth / ratio;
|
|
186
|
+
return {
|
|
187
|
+
x: (sourceWidth - cropWidth) * clamp(value.x, 0, 100) / 100,
|
|
188
|
+
y: (sourceHeight - cropHeight) * clamp(value.y, 0, 100) / 100,
|
|
189
|
+
width: cropWidth,
|
|
190
|
+
height: cropHeight,
|
|
191
|
+
sourceWidth,
|
|
192
|
+
sourceHeight
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
var ImageCropEditor = (props) => /* @__PURE__ */ jsx3(ImageCropSession, {
|
|
196
|
+
...props
|
|
197
|
+
}, props.src);
|
|
198
|
+
var ImageCropSession = ({
|
|
199
|
+
src,
|
|
200
|
+
label,
|
|
201
|
+
value,
|
|
202
|
+
onValueChange,
|
|
203
|
+
onExport,
|
|
204
|
+
aspectRatio = 1,
|
|
205
|
+
maxOutputSize = 2048,
|
|
206
|
+
disabled,
|
|
207
|
+
className,
|
|
208
|
+
locale: override,
|
|
209
|
+
messages
|
|
210
|
+
}) => {
|
|
211
|
+
const locale = useKrakstackLocale2(override);
|
|
212
|
+
const copy = {
|
|
213
|
+
...locale.startsWith("fr") ? labels2.fr : labels2.en,
|
|
214
|
+
...messages?.[locale.split("-")[0] ?? locale],
|
|
215
|
+
...messages?.[locale]
|
|
216
|
+
};
|
|
217
|
+
const image = useRef2(null);
|
|
218
|
+
const [size, setSize] = useState2();
|
|
219
|
+
const [failed, setFailed] = useState2(false);
|
|
220
|
+
const [pending, setPending] = useState2(false);
|
|
221
|
+
const attachImage = useCallback((element) => {
|
|
222
|
+
image.current = element;
|
|
223
|
+
if (!element?.complete)
|
|
224
|
+
return;
|
|
225
|
+
if (element.naturalWidth > 0) {
|
|
226
|
+
setSize({ width: element.naturalWidth, height: element.naturalHeight });
|
|
227
|
+
} else
|
|
228
|
+
setFailed(true);
|
|
229
|
+
}, []);
|
|
230
|
+
const mounted = useRef2(false);
|
|
231
|
+
useEffect2(() => {
|
|
232
|
+
mounted.current = true;
|
|
233
|
+
return () => {
|
|
234
|
+
mounted.current = false;
|
|
235
|
+
};
|
|
236
|
+
}, []);
|
|
237
|
+
const drag = useRef2(null);
|
|
238
|
+
const crop = size ? getImageCropGeometry(size.width, size.height, value, aspectRatio) : undefined;
|
|
239
|
+
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
|
+
const locked = disabled || pending;
|
|
241
|
+
return /* @__PURE__ */ jsxs2("div", {
|
|
242
|
+
className,
|
|
243
|
+
children: [
|
|
244
|
+
/* @__PURE__ */ jsx3("img", {
|
|
245
|
+
ref: attachImage,
|
|
246
|
+
src,
|
|
247
|
+
crossOrigin: "anonymous",
|
|
248
|
+
alt: "",
|
|
249
|
+
className: "hidden",
|
|
250
|
+
onLoad: (event) => setSize({
|
|
251
|
+
width: event.currentTarget.naturalWidth,
|
|
252
|
+
height: event.currentTarget.naturalHeight
|
|
253
|
+
}),
|
|
254
|
+
onError: () => {
|
|
255
|
+
setFailed(true);
|
|
256
|
+
setSize(undefined);
|
|
257
|
+
}
|
|
258
|
+
}, src),
|
|
259
|
+
/* @__PURE__ */ jsxs2("div", {
|
|
260
|
+
className: "grid min-w-0 gap-4",
|
|
261
|
+
children: [
|
|
262
|
+
crop && size ? /* @__PURE__ */ jsx3("svg", {
|
|
263
|
+
role: "img",
|
|
264
|
+
"aria-label": label,
|
|
265
|
+
viewBox: `${crop.x} ${crop.y} ${crop.width} ${crop.height}`,
|
|
266
|
+
className: "bg-muted mx-auto w-full max-w-md touch-none overflow-hidden rounded-lg border select-none",
|
|
267
|
+
style: {
|
|
268
|
+
aspectRatio: crop.width / crop.height,
|
|
269
|
+
cursor: locked ? "default" : "move"
|
|
270
|
+
},
|
|
271
|
+
onPointerDown: (event) => {
|
|
272
|
+
if (locked || !event.isPrimary || event.button !== 0)
|
|
273
|
+
return;
|
|
274
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
275
|
+
drag.current = {
|
|
276
|
+
pointerId: event.pointerId,
|
|
277
|
+
x: event.clientX,
|
|
278
|
+
y: event.clientY,
|
|
279
|
+
value
|
|
280
|
+
};
|
|
281
|
+
},
|
|
282
|
+
onPointerMove: (event) => {
|
|
283
|
+
const start = drag.current;
|
|
284
|
+
if (locked || !start || start.pointerId !== event.pointerId)
|
|
285
|
+
return;
|
|
286
|
+
const scale = event.currentTarget.getBoundingClientRect().width / crop.width;
|
|
287
|
+
const travelX = crop.sourceWidth - crop.width;
|
|
288
|
+
const travelY = crop.sourceHeight - crop.height;
|
|
289
|
+
onValueChange({
|
|
290
|
+
...start.value,
|
|
291
|
+
x: travelX > 0 ? clamp(start.value.x - (event.clientX - start.x) / scale / travelX * 100, 0, 100) : 50,
|
|
292
|
+
y: travelY > 0 ? clamp(start.value.y - (event.clientY - start.y) / scale / travelY * 100, 0, 100) : 50
|
|
293
|
+
});
|
|
294
|
+
},
|
|
295
|
+
onPointerUp: () => {
|
|
296
|
+
drag.current = null;
|
|
297
|
+
},
|
|
298
|
+
onPointerCancel: () => {
|
|
299
|
+
drag.current = null;
|
|
300
|
+
},
|
|
301
|
+
onLostPointerCapture: () => {
|
|
302
|
+
drag.current = null;
|
|
303
|
+
},
|
|
304
|
+
children: /* @__PURE__ */ jsx3("image", {
|
|
305
|
+
href: src,
|
|
306
|
+
width: size.width,
|
|
307
|
+
height: size.height,
|
|
308
|
+
transform
|
|
309
|
+
})
|
|
310
|
+
}) : /* @__PURE__ */ jsx3("p", {
|
|
311
|
+
role: failed ? "alert" : "status",
|
|
312
|
+
children: failed ? copy.loadError : copy.loading
|
|
313
|
+
}),
|
|
314
|
+
/* @__PURE__ */ jsx3("p", {
|
|
315
|
+
className: "text-muted-foreground text-sm",
|
|
316
|
+
children: copy.help
|
|
317
|
+
}),
|
|
318
|
+
/* @__PURE__ */ jsxs2("fieldset", {
|
|
319
|
+
disabled: locked || !crop,
|
|
320
|
+
className: "grid min-w-0 gap-3",
|
|
321
|
+
children: [
|
|
322
|
+
["zoom", "x", "y"].map((key) => /* @__PURE__ */ jsxs2("label", {
|
|
323
|
+
className: "grid gap-1 text-sm",
|
|
324
|
+
children: [
|
|
325
|
+
/* @__PURE__ */ jsx3("span", {
|
|
326
|
+
children: key === "zoom" ? copy.zoom : key === "x" ? copy.horizontal : copy.vertical
|
|
327
|
+
}),
|
|
328
|
+
/* @__PURE__ */ jsx3("input", {
|
|
329
|
+
type: "range",
|
|
330
|
+
min: key === "zoom" ? 1 : 0,
|
|
331
|
+
max: key === "zoom" ? 4 : 100,
|
|
332
|
+
step: key === "zoom" ? 0.01 : 1,
|
|
333
|
+
value: value[key],
|
|
334
|
+
onChange: (event) => onValueChange({
|
|
335
|
+
...value,
|
|
336
|
+
[key]: event.currentTarget.valueAsNumber
|
|
337
|
+
}),
|
|
338
|
+
className: "accent-primary w-full"
|
|
339
|
+
})
|
|
340
|
+
]
|
|
341
|
+
}, key)),
|
|
342
|
+
/* @__PURE__ */ jsxs2("div", {
|
|
343
|
+
className: "flex flex-wrap gap-2",
|
|
344
|
+
children: [
|
|
345
|
+
/* @__PURE__ */ jsx3(Button, {
|
|
346
|
+
type: "button",
|
|
347
|
+
variant: "outline",
|
|
348
|
+
onClick: () => onValueChange({
|
|
349
|
+
...value,
|
|
350
|
+
rotation: value.rotation === 0 ? 90 : value.rotation === 90 ? 180 : value.rotation === 180 ? 270 : 0
|
|
351
|
+
}),
|
|
352
|
+
children: copy.rotate
|
|
353
|
+
}),
|
|
354
|
+
/* @__PURE__ */ jsx3(Button, {
|
|
355
|
+
type: "button",
|
|
356
|
+
variant: "outline",
|
|
357
|
+
onClick: () => onValueChange({ x: 50, y: 50, zoom: 1, rotation: 0 }),
|
|
358
|
+
children: copy.reset
|
|
359
|
+
})
|
|
360
|
+
]
|
|
361
|
+
})
|
|
362
|
+
]
|
|
363
|
+
}),
|
|
364
|
+
/* @__PURE__ */ jsx3(AsyncActionButton, {
|
|
365
|
+
locale,
|
|
366
|
+
disabled: disabled || !crop,
|
|
367
|
+
onPendingChange: setPending,
|
|
368
|
+
messages: { [locale]: { error: copy.exportError } },
|
|
369
|
+
onAction: async () => {
|
|
370
|
+
if (!crop || !image.current || !size)
|
|
371
|
+
return;
|
|
372
|
+
const canvas = document.createElement("canvas");
|
|
373
|
+
const scale = Math.min(1, clamp(maxOutputSize, 1, 8192) / Math.max(crop.width, crop.height));
|
|
374
|
+
canvas.width = Math.max(1, Math.round(crop.width * scale));
|
|
375
|
+
canvas.height = Math.max(1, Math.round(crop.height * scale));
|
|
376
|
+
const context = canvas.getContext("2d");
|
|
377
|
+
if (!context)
|
|
378
|
+
throw new Error("CanvasUnavailable");
|
|
379
|
+
context.scale(canvas.width / crop.width, canvas.height / crop.height);
|
|
380
|
+
context.translate(-crop.x, -crop.y);
|
|
381
|
+
if (value.rotation === 90) {
|
|
382
|
+
context.translate(size.height, 0);
|
|
383
|
+
context.rotate(Math.PI / 2);
|
|
384
|
+
}
|
|
385
|
+
if (value.rotation === 180) {
|
|
386
|
+
context.translate(size.width, size.height);
|
|
387
|
+
context.rotate(Math.PI);
|
|
388
|
+
}
|
|
389
|
+
if (value.rotation === 270) {
|
|
390
|
+
context.translate(0, size.width);
|
|
391
|
+
context.rotate(-Math.PI / 2);
|
|
392
|
+
}
|
|
393
|
+
context.drawImage(image.current, 0, 0);
|
|
394
|
+
const blob = await new Promise((resolve, reject) => canvas.toBlob((result) => result ? resolve(result) : reject(new Error("ImageEncodingFailed")), "image/png"));
|
|
395
|
+
if (mounted.current)
|
|
396
|
+
await onExport(blob);
|
|
397
|
+
},
|
|
398
|
+
children: copy.export
|
|
399
|
+
})
|
|
400
|
+
]
|
|
401
|
+
})
|
|
402
|
+
]
|
|
403
|
+
});
|
|
404
|
+
};
|
|
405
|
+
export {
|
|
406
|
+
ImageCropEditor,
|
|
407
|
+
getImageCropGeometry
|
|
408
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export type PresenceTransitionProps = {
|
|
3
|
+
open: boolean;
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
duration?: number;
|
|
6
|
+
className?: string;
|
|
7
|
+
};
|
|
8
|
+
/** Exit content becomes inert immediately, then unmounts after its animation. */
|
|
9
|
+
export declare const PresenceTransition: ({ open, ...props }: PresenceTransitionProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// ../../src/components/ui/presence-transition.tsx
|
|
2
|
+
import {
|
|
3
|
+
AnimatePresence,
|
|
4
|
+
motion,
|
|
5
|
+
useIsPresent,
|
|
6
|
+
useReducedMotion
|
|
7
|
+
} from "motion/react";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
var PresenceTransition = ({
|
|
10
|
+
open,
|
|
11
|
+
...props
|
|
12
|
+
}) => /* @__PURE__ */ jsx(AnimatePresence, {
|
|
13
|
+
initial: false,
|
|
14
|
+
children: open ? /* @__PURE__ */ jsx(PresenceContent, {
|
|
15
|
+
...props
|
|
16
|
+
}, "content") : null
|
|
17
|
+
});
|
|
18
|
+
var PresenceContent = ({
|
|
19
|
+
children,
|
|
20
|
+
duration = 180,
|
|
21
|
+
className
|
|
22
|
+
}) => {
|
|
23
|
+
const present = useIsPresent();
|
|
24
|
+
const reduced = useReducedMotion();
|
|
25
|
+
return /* @__PURE__ */ jsx(motion.div, {
|
|
26
|
+
"data-slot": "presence-transition",
|
|
27
|
+
className,
|
|
28
|
+
inert: !present,
|
|
29
|
+
"aria-hidden": !present ? true : undefined,
|
|
30
|
+
initial: { opacity: 0, y: reduced !== false ? 0 : 4 },
|
|
31
|
+
animate: { opacity: 1, y: 0 },
|
|
32
|
+
exit: { opacity: 0, y: reduced !== false ? 0 : 4 },
|
|
33
|
+
transition: {
|
|
34
|
+
duration: reduced !== false ? 0 : Math.max(0, duration) / 1000
|
|
35
|
+
},
|
|
36
|
+
children
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
PresenceTransition
|
|
41
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type TimeZoneContinent, type TimeZoneContinentFilter } from "./timezone-select.schema.js";
|
|
2
|
+
export { TimeZoneIdSchema, TimeZoneContinentFilterSchema, isTimeZoneId, } from "./timezone-select.schema.js";
|
|
3
|
+
export type { TimeZoneContinent, TimeZoneContinentFilter, } from "./timezone-select.schema.js";
|
|
4
|
+
export type TimeZoneDetails = {
|
|
5
|
+
timeZone: string;
|
|
6
|
+
name: string;
|
|
7
|
+
offset: string;
|
|
8
|
+
offsetMinutes: number;
|
|
9
|
+
time: string;
|
|
10
|
+
date: string;
|
|
11
|
+
};
|
|
12
|
+
export type TimezoneSelectMessages = {
|
|
13
|
+
label: string;
|
|
14
|
+
placeholder: string;
|
|
15
|
+
search: string;
|
|
16
|
+
empty: string;
|
|
17
|
+
clear: string;
|
|
18
|
+
yourTime: string;
|
|
19
|
+
comparisonTime: string;
|
|
20
|
+
selectedTime: string;
|
|
21
|
+
useLocal: string;
|
|
22
|
+
unavailable: string;
|
|
23
|
+
invalid: string;
|
|
24
|
+
invalidReference: string;
|
|
25
|
+
same: string;
|
|
26
|
+
ahead: (duration: string) => string;
|
|
27
|
+
behind: (duration: string) => string;
|
|
28
|
+
};
|
|
29
|
+
export type TimezoneSelectProps = {
|
|
30
|
+
value: string | null;
|
|
31
|
+
onValueChange: (timeZone: string | null) => void;
|
|
32
|
+
label?: string;
|
|
33
|
+
/** Code-only catalog filter; no continent control is rendered. */
|
|
34
|
+
continent?: TimeZoneContinentFilter;
|
|
35
|
+
/** Omit to detect the browser zone; null disables comparison. */
|
|
36
|
+
comparisonTimeZone?: string | null;
|
|
37
|
+
/** Omit for a live clock; fixed instants make DST comparisons reproducible. */
|
|
38
|
+
referenceTime?: Date;
|
|
39
|
+
name?: string;
|
|
40
|
+
disabled?: boolean;
|
|
41
|
+
className?: string;
|
|
42
|
+
locale?: string;
|
|
43
|
+
messages?: Partial<Record<string, Partial<TimezoneSelectMessages>>>;
|
|
44
|
+
};
|
|
45
|
+
/** Location-based continent groups. UTC and fixed-offset zones belong to All. */
|
|
46
|
+
export declare const getTimeZoneContinent: (timeZone: string) => TimeZoneContinent | null;
|
|
47
|
+
/** Primary runtime IANA zones, UTC and supported fixed-offset Etc zones; no duplicate alias catalog. */
|
|
48
|
+
export declare const getTimeZones: (additional?: readonly string[]) => string[];
|
|
49
|
+
/** The browser supplies these parts; no locale-dependent date-string parsing. */
|
|
50
|
+
export declare const getTimeZoneDetails: ({ timeZone, at, locale, }: {
|
|
51
|
+
timeZone: string;
|
|
52
|
+
at: Date;
|
|
53
|
+
locale?: string;
|
|
54
|
+
}) => TimeZoneDetails | undefined;
|
|
55
|
+
/** Adds time-zone semantics to the existing combobox; owns no generic picker behavior. */
|
|
56
|
+
export declare const TimezoneSelect: ({ value, onValueChange, label, continent, comparisonTimeZone, referenceTime, name, disabled, className, locale: override, messages, }: TimezoneSelectProps) => import("react").JSX.Element;
|