@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,9 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
export declare const TimeZoneIdSchema: Schema.NonEmptyString;
|
|
3
|
+
export declare const TimeZoneReferenceDateSchema: Schema.Date;
|
|
4
|
+
export declare const isTimeZoneId: <I>(input: I) => input is I & string;
|
|
5
|
+
export declare const isTimeZoneReferenceDate: <I>(input: I) => input is I & Date;
|
|
6
|
+
export declare const TimeZoneContinentFilterSchema: Schema.Literals<readonly ["all", "north-america", "south-america", "europe", "africa", "asia", "oceania", "antarctica"]>;
|
|
7
|
+
export type TimeZoneContinentFilter = typeof TimeZoneContinentFilterSchema.Type;
|
|
8
|
+
export type TimeZoneContinent = Exclude<TimeZoneContinentFilter, "all">;
|
|
9
|
+
export declare const isTimeZoneContinentFilter: <I>(input: I) => input is I & ("africa" | "all" | "antarctica" | "asia" | "europe" | "north-america" | "oceania" | "south-america");
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type UnsavedChangesGuardMessages = {
|
|
2
|
+
title: string;
|
|
3
|
+
description: string;
|
|
4
|
+
stay: string;
|
|
5
|
+
leave: string;
|
|
6
|
+
};
|
|
7
|
+
export type UnsavedChangesGuardProps = {
|
|
8
|
+
dirty: boolean;
|
|
9
|
+
enabled?: boolean;
|
|
10
|
+
protectBeforeUnload?: boolean;
|
|
11
|
+
locale?: string;
|
|
12
|
+
messages?: Partial<Record<string, Partial<UnsavedChangesGuardMessages>>>;
|
|
13
|
+
};
|
|
14
|
+
/** Mount once per editing route, inside a TanStack Router provider. */
|
|
15
|
+
export declare const UnsavedChangesGuard: ({ dirty, enabled, protectBeforeUnload, locale: override, messages, }: UnsavedChangesGuardProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
// ../../src/components/ui/unsaved-changes-guard.tsx
|
|
2
|
+
import { useBlocker } from "@tanstack/react-router";
|
|
3
|
+
|
|
4
|
+
// ../../src/components/ui/alert-dialog.tsx
|
|
5
|
+
import { AlertDialog as AlertDialogPrimitive } from "@base-ui/react/alert-dialog";
|
|
6
|
+
|
|
7
|
+
// ../../src/lib/utils.ts
|
|
8
|
+
import { cn } from "cn";
|
|
9
|
+
|
|
10
|
+
// ../../src/components/ui/button.tsx
|
|
11
|
+
import { Button as ButtonPrimitive } from "@base-ui/react/button";
|
|
12
|
+
import { cva } from "class-variance-authority";
|
|
13
|
+
import { jsx } from "react/jsx-runtime";
|
|
14
|
+
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", {
|
|
15
|
+
variants: {
|
|
16
|
+
variant: {
|
|
17
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/80",
|
|
18
|
+
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",
|
|
19
|
+
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",
|
|
20
|
+
ghost: "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
|
|
21
|
+
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",
|
|
22
|
+
link: "text-primary underline-offset-4 hover:underline"
|
|
23
|
+
},
|
|
24
|
+
size: {
|
|
25
|
+
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",
|
|
26
|
+
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",
|
|
27
|
+
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",
|
|
28
|
+
lg: "h-10 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
29
|
+
icon: "size-9",
|
|
30
|
+
"icon-xs": "size-6 rounded-[min(var(--radius-md),8px)] in-data-[slot=button-group]:rounded-md [&_svg:not([class*='size-'])]:size-3",
|
|
31
|
+
"icon-sm": "size-8 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-md",
|
|
32
|
+
"icon-lg": "size-10"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
defaultVariants: {
|
|
36
|
+
variant: "default",
|
|
37
|
+
size: "default"
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
function Button({
|
|
41
|
+
className,
|
|
42
|
+
variant = "default",
|
|
43
|
+
size = "default",
|
|
44
|
+
...props
|
|
45
|
+
}) {
|
|
46
|
+
return /* @__PURE__ */ jsx(ButtonPrimitive, {
|
|
47
|
+
"data-slot": "button",
|
|
48
|
+
className: cn(buttonVariants({ variant, size, className })),
|
|
49
|
+
...props
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// ../../src/components/ui/alert-dialog.tsx
|
|
54
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
55
|
+
"use client";
|
|
56
|
+
function AlertDialog({ ...props }) {
|
|
57
|
+
return /* @__PURE__ */ jsx2(AlertDialogPrimitive.Root, {
|
|
58
|
+
"data-slot": "alert-dialog",
|
|
59
|
+
...props
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function AlertDialogPortal({ ...props }) {
|
|
63
|
+
return /* @__PURE__ */ jsx2(AlertDialogPrimitive.Portal, {
|
|
64
|
+
"data-slot": "alert-dialog-portal",
|
|
65
|
+
...props
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function AlertDialogOverlay({
|
|
69
|
+
className,
|
|
70
|
+
...props
|
|
71
|
+
}) {
|
|
72
|
+
return /* @__PURE__ */ jsx2(AlertDialogPrimitive.Backdrop, {
|
|
73
|
+
"data-slot": "alert-dialog-overlay",
|
|
74
|
+
className: cn("fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0", className),
|
|
75
|
+
...props
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
function AlertDialogContent({
|
|
79
|
+
className,
|
|
80
|
+
size = "default",
|
|
81
|
+
...props
|
|
82
|
+
}) {
|
|
83
|
+
return /* @__PURE__ */ jsxs(AlertDialogPortal, {
|
|
84
|
+
children: [
|
|
85
|
+
/* @__PURE__ */ jsx2(AlertDialogOverlay, {}),
|
|
86
|
+
/* @__PURE__ */ jsx2(AlertDialogPrimitive.Popup, {
|
|
87
|
+
"data-slot": "alert-dialog-content",
|
|
88
|
+
"data-size": size,
|
|
89
|
+
className: cn("group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-6 rounded-xl bg-popover p-6 text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-lg 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),
|
|
90
|
+
...props
|
|
91
|
+
})
|
|
92
|
+
]
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
function AlertDialogHeader({
|
|
96
|
+
className,
|
|
97
|
+
...props
|
|
98
|
+
}) {
|
|
99
|
+
return /* @__PURE__ */ jsx2("div", {
|
|
100
|
+
"data-slot": "alert-dialog-header",
|
|
101
|
+
className: cn("grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-6 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]", className),
|
|
102
|
+
...props
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function AlertDialogFooter({
|
|
106
|
+
className,
|
|
107
|
+
...props
|
|
108
|
+
}) {
|
|
109
|
+
return /* @__PURE__ */ jsx2("div", {
|
|
110
|
+
"data-slot": "alert-dialog-footer",
|
|
111
|
+
className: cn("flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end", className),
|
|
112
|
+
...props
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
function AlertDialogTitle({
|
|
116
|
+
className,
|
|
117
|
+
...props
|
|
118
|
+
}) {
|
|
119
|
+
return /* @__PURE__ */ jsx2(AlertDialogPrimitive.Title, {
|
|
120
|
+
"data-slot": "alert-dialog-title",
|
|
121
|
+
className: cn("text-lg font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2", className),
|
|
122
|
+
...props
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
function AlertDialogDescription({
|
|
126
|
+
className,
|
|
127
|
+
...props
|
|
128
|
+
}) {
|
|
129
|
+
return /* @__PURE__ */ jsx2(AlertDialogPrimitive.Description, {
|
|
130
|
+
"data-slot": "alert-dialog-description",
|
|
131
|
+
className: cn("text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground", className),
|
|
132
|
+
...props
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
function AlertDialogAction({
|
|
136
|
+
className,
|
|
137
|
+
...props
|
|
138
|
+
}) {
|
|
139
|
+
return /* @__PURE__ */ jsx2(Button, {
|
|
140
|
+
"data-slot": "alert-dialog-action",
|
|
141
|
+
className: cn(className),
|
|
142
|
+
...props
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
function AlertDialogCancel({
|
|
146
|
+
className,
|
|
147
|
+
variant = "outline",
|
|
148
|
+
size = "default",
|
|
149
|
+
...props
|
|
150
|
+
}) {
|
|
151
|
+
return /* @__PURE__ */ jsx2(AlertDialogPrimitive.Close, {
|
|
152
|
+
"data-slot": "alert-dialog-cancel",
|
|
153
|
+
className: cn(className),
|
|
154
|
+
render: /* @__PURE__ */ jsx2(Button, {
|
|
155
|
+
variant,
|
|
156
|
+
size
|
|
157
|
+
}),
|
|
158
|
+
...props
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// ../../src/components/ui/unsaved-changes-guard.tsx
|
|
163
|
+
import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider";
|
|
164
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
165
|
+
var labels = {
|
|
166
|
+
en: {
|
|
167
|
+
title: "Leave without saving?",
|
|
168
|
+
description: "You have unsaved changes. Leaving this page will discard them.",
|
|
169
|
+
stay: "Keep editing",
|
|
170
|
+
leave: "Leave page"
|
|
171
|
+
},
|
|
172
|
+
fr: {
|
|
173
|
+
title: "Quitter sans enregistrer ?",
|
|
174
|
+
description: "Des modifications n’ont pas été enregistrées. Elles seront perdues si vous quittez cette page.",
|
|
175
|
+
stay: "Continuer la modification",
|
|
176
|
+
leave: "Quitter la page"
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
var UnsavedChangesGuard = ({
|
|
180
|
+
dirty,
|
|
181
|
+
enabled = true,
|
|
182
|
+
protectBeforeUnload = true,
|
|
183
|
+
locale: override,
|
|
184
|
+
messages
|
|
185
|
+
}) => {
|
|
186
|
+
const locale = useKrakstackLocale(override);
|
|
187
|
+
const copy = {
|
|
188
|
+
...locale.startsWith("fr") ? labels.fr : labels.en,
|
|
189
|
+
...messages?.[locale.split("-")[0] ?? locale],
|
|
190
|
+
...messages?.[locale]
|
|
191
|
+
};
|
|
192
|
+
const blocker = useBlocker({
|
|
193
|
+
shouldBlockFn: () => dirty && enabled,
|
|
194
|
+
enableBeforeUnload: dirty && enabled && protectBeforeUnload,
|
|
195
|
+
withResolver: true
|
|
196
|
+
});
|
|
197
|
+
return /* @__PURE__ */ jsx3(AlertDialog, {
|
|
198
|
+
open: blocker.status === "blocked",
|
|
199
|
+
onOpenChange: (open) => {
|
|
200
|
+
if (!open)
|
|
201
|
+
blocker.reset?.();
|
|
202
|
+
},
|
|
203
|
+
children: /* @__PURE__ */ jsxs2(AlertDialogContent, {
|
|
204
|
+
children: [
|
|
205
|
+
/* @__PURE__ */ jsxs2(AlertDialogHeader, {
|
|
206
|
+
children: [
|
|
207
|
+
/* @__PURE__ */ jsx3(AlertDialogTitle, {
|
|
208
|
+
children: copy.title
|
|
209
|
+
}),
|
|
210
|
+
/* @__PURE__ */ jsx3(AlertDialogDescription, {
|
|
211
|
+
children: copy.description
|
|
212
|
+
})
|
|
213
|
+
]
|
|
214
|
+
}),
|
|
215
|
+
/* @__PURE__ */ jsxs2(AlertDialogFooter, {
|
|
216
|
+
children: [
|
|
217
|
+
/* @__PURE__ */ jsx3(AlertDialogCancel, {
|
|
218
|
+
type: "button",
|
|
219
|
+
children: copy.stay
|
|
220
|
+
}),
|
|
221
|
+
/* @__PURE__ */ jsx3(AlertDialogAction, {
|
|
222
|
+
type: "button",
|
|
223
|
+
variant: "destructive",
|
|
224
|
+
onClick: () => blocker.proceed?.(),
|
|
225
|
+
children: copy.leave
|
|
226
|
+
})
|
|
227
|
+
]
|
|
228
|
+
})
|
|
229
|
+
]
|
|
230
|
+
})
|
|
231
|
+
});
|
|
232
|
+
};
|
|
233
|
+
export {
|
|
234
|
+
UnsavedChangesGuard
|
|
235
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@krak-stack/registry",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Tree-shakable KrakStack components and Effect services.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -17,6 +17,46 @@
|
|
|
17
17
|
"type": "module",
|
|
18
18
|
"sideEffects": false,
|
|
19
19
|
"exports": {
|
|
20
|
+
"./image-crop-editor": {
|
|
21
|
+
"types": "./dist/components/ui/image-crop-editor.d.ts",
|
|
22
|
+
"import": "./dist/components/ui/image-crop-editor.js"
|
|
23
|
+
},
|
|
24
|
+
"./timezone-select": {
|
|
25
|
+
"types": "./dist/components/ui/timezone-select.d.ts",
|
|
26
|
+
"import": "./dist/components/ui/timezone-select.js"
|
|
27
|
+
},
|
|
28
|
+
"./async-action-button": {
|
|
29
|
+
"types": "./dist/components/ui/async-action-button.d.ts",
|
|
30
|
+
"import": "./dist/components/ui/async-action-button.js"
|
|
31
|
+
},
|
|
32
|
+
"./unsaved-changes-guard": {
|
|
33
|
+
"types": "./dist/components/ui/unsaved-changes-guard.d.ts",
|
|
34
|
+
"import": "./dist/components/ui/unsaved-changes-guard.js"
|
|
35
|
+
},
|
|
36
|
+
"./danger-confirmation": {
|
|
37
|
+
"types": "./dist/components/ui/danger-confirmation.d.ts",
|
|
38
|
+
"import": "./dist/components/ui/danger-confirmation.js"
|
|
39
|
+
},
|
|
40
|
+
"./editable-text": {
|
|
41
|
+
"types": "./dist/components/ui/editable-text.d.ts",
|
|
42
|
+
"import": "./dist/components/ui/editable-text.js"
|
|
43
|
+
},
|
|
44
|
+
"./presence-transition": {
|
|
45
|
+
"types": "./dist/components/ui/presence-transition.d.ts",
|
|
46
|
+
"import": "./dist/components/ui/presence-transition.js"
|
|
47
|
+
},
|
|
48
|
+
"./auto-height": {
|
|
49
|
+
"types": "./dist/components/ui/auto-height.d.ts",
|
|
50
|
+
"import": "./dist/components/ui/auto-height.js"
|
|
51
|
+
},
|
|
52
|
+
"./animated-list": {
|
|
53
|
+
"types": "./dist/components/ui/animated-list.d.ts",
|
|
54
|
+
"import": "./dist/components/ui/animated-list.js"
|
|
55
|
+
},
|
|
56
|
+
"./animated-number": {
|
|
57
|
+
"types": "./dist/components/ui/animated-number.d.ts",
|
|
58
|
+
"import": "./dist/components/ui/animated-number.js"
|
|
59
|
+
},
|
|
20
60
|
"./app-switcher": {
|
|
21
61
|
"types": "./dist/components/ui/app-switcher.d.ts",
|
|
22
62
|
"import": "./dist/components/ui/app-switcher.js"
|
|
@@ -330,6 +370,7 @@
|
|
|
330
370
|
"dependencies": {
|
|
331
371
|
"@oxlint/plugins": "1.78.0",
|
|
332
372
|
"bowser": "^2.14.1",
|
|
373
|
+
"motion": "^14.12.0",
|
|
333
374
|
"react-colorful": "^5.8.1",
|
|
334
375
|
"web-vitals": "^5.1.0"
|
|
335
376
|
},
|