@krak-stack/registry 0.10.0 → 0.10.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/CHANGELOG.md +17 -0
- package/README.md +50 -0
- package/dist/components/ui/app-brand.d.ts +2 -0
- package/dist/components/ui/app-brand.js +24 -9
- package/dist/components/ui/{secret-value.d.ts → copy-value.d.ts} +6 -4
- package/dist/components/ui/copy-value.js +319 -0
- package/dist/components/ui/data-table.d.ts +12 -0
- package/dist/components/ui/data-table.js +195 -137
- package/dist/components/ui/effect-form.d.ts +2 -0
- package/dist/components/ui/effect-form.js +3 -0
- package/dist/components/ui/pagination.d.ts +3 -1
- package/dist/components/ui/pagination.js +5 -1
- package/dist/components/ui/sidebar-layout.js +12 -9
- package/dist/lib/docs.integrations.server.d.ts +56 -0
- package/dist/lib/docs.integrations.server.js +945 -0
- package/dist/lib/docs.js +36 -23
- package/dist/lib/docs.server.js +3 -5
- package/dist/lib/docs.webhook-reference.server.d.ts +21 -0
- package/dist/lib/documentation-toolkit.js +3 -5
- package/dist/services/events/client/audit-log-table.js +195 -137
- package/dist/services/webhooks/client/delivery-table.js +195 -137
- package/package.json +9 -5
- package/dist/components/ui/secret-value.js +0 -222
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @krak-stack/registry
|
|
2
2
|
|
|
3
|
+
## 0.10.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 91114c4: Expose optional grouped DataTable styling hooks, including portalled menus, submenus, filter selects, page-size popups, feedback and gallery layouts. Add AppBrand part classes and stable slots, Pagination root/popup classes, and select-field popup classes. Preserve existing defaults and interaction/data behavior.
|
|
8
|
+
|
|
9
|
+
## 0.10.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 7bf29e1: Replace SecretValue with CopyValue, modeled on Kokobi's read-only copyable input. Values are visible by default; enable `secret` for reveal/hide and optional auto-hide. Add a borderless `variant="ghost"` with monospaced text and an icon-only copy button, and tighten spacing between actions.
|
|
14
|
+
|
|
15
|
+
Migrate imports from `@krak-stack/registry/secret-value` to `@krak-stack/registry/copy-value`, rename `SecretValue` to `CopyValue`, and add `secret` to preserve masking. The shadcn registry item is now `@krak-stack/copy-value`. Include updated English/French documentation and previews.
|
|
16
|
+
|
|
17
|
+
- Add the server-only `docs/integrations` export and `docs-integrations` registry item for configurable English/French API, OAuth MCP, and webhook guides. Generate linked event summaries and grouped payload-field references directly from Effect schemas, including required/conditional fields, nested structures, and shared definitions, without raw schema dumps. Include reusable verification and delivery documentation for the KrakStack webhook sender, plus application-owned page overrides.
|
|
18
|
+
- 72bcef6: Keep the sidebar layout header pinned to the viewport during document overscroll without disabling native bounce. Preserve sidebar collapse offsets, document scrolling, and full-page layouts.
|
|
19
|
+
|
|
3
20
|
## 0.10.0
|
|
4
21
|
|
|
5
22
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -18,6 +18,56 @@ Les composants animés nécessitent la dépendance paire facultative `motion` ;
|
|
|
18
18
|
champ de numéro de téléphone nécessite `libphonenumber-js`. Installez ces paquets
|
|
19
19
|
uniquement pour les composants concernés. Le menu de notifications n'en a pas besoin.
|
|
20
20
|
|
|
21
|
+
## Shared integration documentation
|
|
22
|
+
|
|
23
|
+
Generate API, OAuth MCP, and webhook guides in a Bun server loader:
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import {
|
|
27
|
+
createIntegrationDocs,
|
|
28
|
+
krakStackWebhookDocs,
|
|
29
|
+
} from "@krak-stack/registry/docs/integrations";
|
|
30
|
+
import { loadMdxDocsDirectory } from "@krak-stack/registry/docs/server";
|
|
31
|
+
import { webhookDefinitions } from "./webhook-definitions";
|
|
32
|
+
|
|
33
|
+
const pages = createIntegrationDocs({
|
|
34
|
+
appName: "My App",
|
|
35
|
+
origin: "https://app.example.com",
|
|
36
|
+
api: true,
|
|
37
|
+
mcp: true,
|
|
38
|
+
webhooks: { ...krakStackWebhookDocs, events: webhookDefinitions },
|
|
39
|
+
pages: await loadMdxDocsDirectory("src/content/docs"),
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Pass records to `createDocsSource({ pages, locales: ["en", "fr"] })` through your
|
|
44
|
+
existing server function. Do not import the generator into browser code.
|
|
45
|
+
Each webhook definition has a `name`, `description: { en, fr }`, and an Effect
|
|
46
|
+
`payload` schema for the complete delivered JSON body. Reuse the sender's
|
|
47
|
+
definitions. The guide links an event summary to grouped field tables, expanding
|
|
48
|
+
references and nested objects, arrays, and dictionaries without schema dumps.
|
|
49
|
+
Required status applies within the containing object; variant-specific fields
|
|
50
|
+
are marked conditional. Source schema annotations retain their authored language.
|
|
51
|
+
|
|
52
|
+
All guides are opt-in. MCP assumes remote Streamable HTTP with OAuth.
|
|
53
|
+
`krakStackWebhookDocs` explicitly selects the KrakStack webhook sender's public
|
|
54
|
+
signing and delivery policy. Other senders must supply localized `verification`
|
|
55
|
+
and `delivery` Markdown. Never pass secrets. `webhooks: true` keeps the generic
|
|
56
|
+
guide without event definitions or sender-specific policies.
|
|
57
|
+
|
|
58
|
+
Defaults are `/docs/api-access`, `/docs/mcp`, `/docs/webhooks`, English/French,
|
|
59
|
+
section `integration`, and orders 1000–1002. Configure `basePath`, `section`,
|
|
60
|
+
`order`, `locales`, `api: { referenceUrl }`, or `mcp: { url }` as needed.
|
|
61
|
+
Local `pages` replace defaults by locale and slug. Reserve unique orders and
|
|
62
|
+
matching routing metadata across translations. This does not install endpoints.
|
|
63
|
+
For copied sources, install `@krak-stack/docs-integrations`.
|
|
64
|
+
|
|
65
|
+
Générez les guides API, MCP OAuth et webhooks sur le serveur Bun. Les définitions
|
|
66
|
+
d’événements produisent des tableaux de champs lisibles et regroupés par charge
|
|
67
|
+
utile. Réutilisez `krakStackWebhookDocs` pour les instructions de vérification et
|
|
68
|
+
de livraison de l’émetteur KrakStack. Les guides sont facultatifs et disponibles
|
|
69
|
+
en français et en anglais ; les pages locales remplacent les valeurs par défaut.
|
|
70
|
+
|
|
21
71
|
## Use
|
|
22
72
|
|
|
23
73
|
Import from the specific package subpaths you need:
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { type LinkProps } from "@tanstack/react-router";
|
|
2
2
|
import type { ComponentProps } from "react";
|
|
3
3
|
import type { LucideIcon } from "lucide-react";
|
|
4
|
+
export type AppBrandClassNames = Partial<Record<"visual" | "image" | "icon" | "content" | "label" | "subtitle", string>>;
|
|
4
5
|
type AppBrandContentProps = {
|
|
5
6
|
label: string;
|
|
6
7
|
subtitle: string;
|
|
7
8
|
className?: string;
|
|
9
|
+
classNames?: AppBrandClassNames;
|
|
8
10
|
variant?: "default" | "sidebar";
|
|
9
11
|
};
|
|
10
12
|
type AppBrandVisualProps = {
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
// ../../src/components/ui/app-brand.tsx
|
|
2
2
|
import { Link } from "@tanstack/react-router";
|
|
3
|
+
|
|
4
|
+
// ../../src/lib/utils.ts
|
|
5
|
+
import { cn } from "cn";
|
|
6
|
+
|
|
7
|
+
// ../../src/components/ui/app-brand.tsx
|
|
3
8
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
4
9
|
var isStaticBrand = (props) => props.to === null;
|
|
5
10
|
var isAnchorBrand = (props) => props.href !== undefined;
|
|
6
11
|
function AppBrand(brandProps) {
|
|
7
12
|
const {
|
|
8
13
|
className,
|
|
14
|
+
classNames,
|
|
9
15
|
label,
|
|
10
16
|
subtitle,
|
|
11
17
|
icon: Icon,
|
|
@@ -18,28 +24,31 @@ function AppBrand(brandProps) {
|
|
|
18
24
|
const content = /* @__PURE__ */ jsxs(Fragment, {
|
|
19
25
|
children: [
|
|
20
26
|
/* @__PURE__ */ jsx("div", {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
imageSrc ? "border bg-background" : iconClassName
|
|
24
|
-
].join(" "),
|
|
27
|
+
"data-slot": "app-brand-visual",
|
|
28
|
+
className: cn("flex size-8 shrink-0 items-center justify-center overflow-hidden rounded-md", imageSrc ? "bg-background border" : iconClassName, classNames?.visual),
|
|
25
29
|
children: imageSrc ? /* @__PURE__ */ jsx("img", {
|
|
30
|
+
"data-slot": "app-brand-image",
|
|
26
31
|
src: imageSrc,
|
|
27
32
|
alt: label,
|
|
28
|
-
className: "size-full object-cover"
|
|
33
|
+
className: cn("size-full object-cover", classNames?.image)
|
|
29
34
|
}) : Icon ? /* @__PURE__ */ jsx(Icon, {
|
|
30
|
-
|
|
35
|
+
"data-slot": "app-brand-icon",
|
|
36
|
+
className: cn("size-4", classNames?.icon),
|
|
31
37
|
color: iconColor
|
|
32
38
|
}) : null
|
|
33
39
|
}),
|
|
34
40
|
/* @__PURE__ */ jsxs("div", {
|
|
35
|
-
|
|
41
|
+
"data-slot": "app-brand-content",
|
|
42
|
+
className: cn("flex min-w-0 flex-col leading-tight", contentClassName, classNames?.content),
|
|
36
43
|
children: [
|
|
37
44
|
/* @__PURE__ */ jsx("span", {
|
|
38
|
-
|
|
45
|
+
"data-slot": "app-brand-label",
|
|
46
|
+
className: cn("truncate font-semibold tracking-tight", classNames?.label),
|
|
39
47
|
children: label
|
|
40
48
|
}),
|
|
41
49
|
subtitle ? /* @__PURE__ */ jsx("span", {
|
|
42
|
-
|
|
50
|
+
"data-slot": "app-brand-subtitle",
|
|
51
|
+
className: cn("text-muted-foreground truncate text-xs", classNames?.subtitle),
|
|
43
52
|
children: subtitle
|
|
44
53
|
}) : null
|
|
45
54
|
]
|
|
@@ -54,6 +63,7 @@ function AppBrand(brandProps) {
|
|
|
54
63
|
if (isStaticBrand(brandProps)) {
|
|
55
64
|
const {
|
|
56
65
|
className: _className,
|
|
66
|
+
classNames: _classNames,
|
|
57
67
|
label: _label,
|
|
58
68
|
subtitle: _subtitle,
|
|
59
69
|
icon: _icon,
|
|
@@ -64,6 +74,7 @@ function AppBrand(brandProps) {
|
|
|
64
74
|
...props
|
|
65
75
|
} = brandProps;
|
|
66
76
|
return /* @__PURE__ */ jsx("div", {
|
|
77
|
+
"data-slot": "app-brand",
|
|
67
78
|
className: brandClassName,
|
|
68
79
|
...props,
|
|
69
80
|
children: content
|
|
@@ -72,6 +83,7 @@ function AppBrand(brandProps) {
|
|
|
72
83
|
if (isAnchorBrand(brandProps)) {
|
|
73
84
|
const {
|
|
74
85
|
className: _className,
|
|
86
|
+
classNames: _classNames,
|
|
75
87
|
label: _label,
|
|
76
88
|
subtitle: _subtitle,
|
|
77
89
|
icon: _icon,
|
|
@@ -82,6 +94,7 @@ function AppBrand(brandProps) {
|
|
|
82
94
|
...props
|
|
83
95
|
} = brandProps;
|
|
84
96
|
return /* @__PURE__ */ jsx("a", {
|
|
97
|
+
"data-slot": "app-brand",
|
|
85
98
|
className: brandClassName,
|
|
86
99
|
href,
|
|
87
100
|
...props,
|
|
@@ -90,6 +103,7 @@ function AppBrand(brandProps) {
|
|
|
90
103
|
}
|
|
91
104
|
const {
|
|
92
105
|
className: _className,
|
|
106
|
+
classNames: _classNames,
|
|
93
107
|
label: _label,
|
|
94
108
|
subtitle: _subtitle,
|
|
95
109
|
icon: _icon,
|
|
@@ -100,6 +114,7 @@ function AppBrand(brandProps) {
|
|
|
100
114
|
...props
|
|
101
115
|
} = brandProps;
|
|
102
116
|
return /* @__PURE__ */ jsx(Link, {
|
|
117
|
+
"data-slot": "app-brand",
|
|
103
118
|
to: to ?? "/",
|
|
104
119
|
className: brandClassName,
|
|
105
120
|
...props,
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import { type CopyButtonMessageTranslations } from "./copy-button.js";
|
|
2
|
-
export type
|
|
2
|
+
export type CopyValueMessages = {
|
|
3
3
|
show: string;
|
|
4
4
|
hide: string;
|
|
5
5
|
hidden: string;
|
|
6
6
|
};
|
|
7
|
-
export type
|
|
7
|
+
export type CopyValueProps = {
|
|
8
8
|
value: string;
|
|
9
9
|
label: string;
|
|
10
|
+
secret?: boolean;
|
|
11
|
+
variant?: "outline" | "ghost";
|
|
10
12
|
disabled?: boolean;
|
|
11
13
|
copyable?: boolean;
|
|
12
14
|
autoHideDelay?: number;
|
|
13
15
|
className?: string;
|
|
14
16
|
locale?: string;
|
|
15
|
-
messages?: Partial<Record<string, Partial<
|
|
17
|
+
messages?: Partial<Record<string, Partial<CopyValueMessages>>>;
|
|
16
18
|
copyMessages?: CopyButtonMessageTranslations;
|
|
17
19
|
};
|
|
18
20
|
/** Masking is presentation, not a security boundary. Never logs the value. */
|
|
19
|
-
export declare const
|
|
21
|
+
export declare const CopyValue: ({ value, label, secret, variant, disabled, copyable, autoHideDelay, className, locale: override, messages, copyMessages, }: CopyValueProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
// ../../src/components/ui/copy-value.tsx
|
|
2
|
+
import { Eye, EyeOff } from "lucide-react";
|
|
3
|
+
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
4
|
+
|
|
5
|
+
// ../../src/components/ui/input-group.tsx
|
|
6
|
+
import { cva as cva2 } from "class-variance-authority";
|
|
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/input.tsx
|
|
57
|
+
import { Input as InputPrimitive } from "@base-ui/react/input";
|
|
58
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
59
|
+
function Input({ className, type, ...props }) {
|
|
60
|
+
return /* @__PURE__ */ jsx2(InputPrimitive, {
|
|
61
|
+
type,
|
|
62
|
+
"data-slot": "input",
|
|
63
|
+
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),
|
|
64
|
+
...props
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// ../../src/components/ui/input-group.tsx
|
|
69
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
70
|
+
function InputGroup({ className, ...props }) {
|
|
71
|
+
return /* @__PURE__ */ jsx3("div", {
|
|
72
|
+
"data-slot": "input-group",
|
|
73
|
+
role: "group",
|
|
74
|
+
className: cn("group/input-group relative flex h-9 w-full min-w-0 items-center rounded-md border border-input shadow-xs transition-[color,box-shadow] outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5", className),
|
|
75
|
+
...props
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
var inputGroupAddonVariants = cva2("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4", {
|
|
79
|
+
variants: {
|
|
80
|
+
align: {
|
|
81
|
+
"inline-start": "order-first pl-2 has-[>button]:-ml-1 has-[>kbd]:ml-[-0.15rem]",
|
|
82
|
+
"inline-end": "order-last pr-2 has-[>button]:-mr-1 has-[>kbd]:mr-[-0.15rem]",
|
|
83
|
+
"block-start": "order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2",
|
|
84
|
+
"block-end": "order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2"
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
defaultVariants: { align: "inline-start" }
|
|
88
|
+
});
|
|
89
|
+
function InputGroupAddon({
|
|
90
|
+
className,
|
|
91
|
+
align = "inline-start",
|
|
92
|
+
...props
|
|
93
|
+
}) {
|
|
94
|
+
return /* @__PURE__ */ jsx3("div", {
|
|
95
|
+
role: "group",
|
|
96
|
+
"data-slot": "input-group-addon",
|
|
97
|
+
"data-align": align,
|
|
98
|
+
className: cn(inputGroupAddonVariants({ align }), className),
|
|
99
|
+
onClick: (event) => {
|
|
100
|
+
if (event.target instanceof HTMLElement && event.target.closest("button")) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
event.currentTarget.parentElement?.querySelector("input")?.focus();
|
|
104
|
+
},
|
|
105
|
+
...props
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
var inputGroupButtonVariants = cva2("flex items-center gap-2 text-sm shadow-none", {
|
|
109
|
+
variants: {
|
|
110
|
+
size: {
|
|
111
|
+
xs: "h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5",
|
|
112
|
+
sm: "",
|
|
113
|
+
"icon-xs": "size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0",
|
|
114
|
+
"icon-sm": "size-8 p-0 has-[>svg]:p-0"
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
defaultVariants: { size: "xs" }
|
|
118
|
+
});
|
|
119
|
+
function InputGroupButton({
|
|
120
|
+
className,
|
|
121
|
+
type = "button",
|
|
122
|
+
variant = "ghost",
|
|
123
|
+
size = "xs",
|
|
124
|
+
...props
|
|
125
|
+
}) {
|
|
126
|
+
return /* @__PURE__ */ jsx3(Button, {
|
|
127
|
+
type,
|
|
128
|
+
"data-size": size,
|
|
129
|
+
variant,
|
|
130
|
+
className: cn(inputGroupButtonVariants({ size }), className),
|
|
131
|
+
...props
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
function InputGroupInput({
|
|
135
|
+
className,
|
|
136
|
+
...props
|
|
137
|
+
}) {
|
|
138
|
+
return /* @__PURE__ */ jsx3(Input, {
|
|
139
|
+
"data-slot": "input-group-control",
|
|
140
|
+
className: cn("flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 aria-invalid:ring-0 dark:bg-transparent", className),
|
|
141
|
+
...props
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// ../../src/components/ui/copy-button.tsx
|
|
146
|
+
import { Check, Copy, TriangleAlert } from "lucide-react";
|
|
147
|
+
import { useEffect, useRef, useState } from "react";
|
|
148
|
+
import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider";
|
|
149
|
+
import { jsx as jsx4, jsxs } from "react/jsx-runtime";
|
|
150
|
+
var messages = {
|
|
151
|
+
en: { copy: "Copy", copied: "Copied", copyFailed: "Copy failed" },
|
|
152
|
+
fr: { copy: "Copier", copied: "Copié", copyFailed: "Échec de la copie" }
|
|
153
|
+
};
|
|
154
|
+
var copyButtonMessages = (locale = "en", translations) => ({
|
|
155
|
+
...locale.startsWith("fr") ? messages.fr : messages.en,
|
|
156
|
+
...translations?.[locale.split("-")[0] ?? locale],
|
|
157
|
+
...translations?.[locale]
|
|
158
|
+
});
|
|
159
|
+
function CopyButton({
|
|
160
|
+
value,
|
|
161
|
+
valueDescription,
|
|
162
|
+
copyVariant = "default",
|
|
163
|
+
locale: localeOverride,
|
|
164
|
+
messages,
|
|
165
|
+
onCopied,
|
|
166
|
+
onCopyError,
|
|
167
|
+
resetDelay = 1500,
|
|
168
|
+
disabled,
|
|
169
|
+
size,
|
|
170
|
+
"aria-label": ariaLabel,
|
|
171
|
+
...props
|
|
172
|
+
}) {
|
|
173
|
+
const locale = useKrakstackLocale(localeOverride);
|
|
174
|
+
const [copyState, setCopyState] = useState("idle");
|
|
175
|
+
const copyTimeout = useRef(undefined);
|
|
176
|
+
const labels = copyButtonMessages(locale, messages);
|
|
177
|
+
const accessibleLabel = ariaLabel ?? (valueDescription ? `${labels.copy} ${valueDescription}` : labels.copy);
|
|
178
|
+
const isLarge = copyVariant === "large";
|
|
179
|
+
const defaultSize = copyVariant === "sm" ? "icon-xs" : isLarge ? "sm" : "icon-sm";
|
|
180
|
+
useEffect(() => {
|
|
181
|
+
return () => {
|
|
182
|
+
if (copyTimeout.current)
|
|
183
|
+
clearTimeout(copyTimeout.current);
|
|
184
|
+
};
|
|
185
|
+
}, []);
|
|
186
|
+
const resetCopyState = () => {
|
|
187
|
+
if (copyTimeout.current)
|
|
188
|
+
clearTimeout(copyTimeout.current);
|
|
189
|
+
copyTimeout.current = setTimeout(() => setCopyState("idle"), resetDelay);
|
|
190
|
+
};
|
|
191
|
+
const copy = async () => {
|
|
192
|
+
try {
|
|
193
|
+
await navigator.clipboard.writeText(value);
|
|
194
|
+
setCopyState("copied");
|
|
195
|
+
onCopied?.();
|
|
196
|
+
} catch (error) {
|
|
197
|
+
setCopyState("failed");
|
|
198
|
+
onCopyError?.(error instanceof Error ? error : new Error(labels.copyFailed, { cause: error }));
|
|
199
|
+
}
|
|
200
|
+
resetCopyState();
|
|
201
|
+
};
|
|
202
|
+
const status = copyState === "copied" ? valueDescription ? `${labels.copied}: ${valueDescription}` : labels.copied : copyState === "failed" ? valueDescription ? `${labels.copyFailed}: ${valueDescription}` : labels.copyFailed : "";
|
|
203
|
+
return /* @__PURE__ */ jsxs(Button, {
|
|
204
|
+
"aria-label": accessibleLabel,
|
|
205
|
+
disabled,
|
|
206
|
+
onClick: copy,
|
|
207
|
+
size: size ?? defaultSize,
|
|
208
|
+
...props,
|
|
209
|
+
children: [
|
|
210
|
+
/* @__PURE__ */ jsx4("span", {
|
|
211
|
+
"aria-live": "polite",
|
|
212
|
+
className: "sr-only",
|
|
213
|
+
role: "status",
|
|
214
|
+
children: status
|
|
215
|
+
}),
|
|
216
|
+
copyState === "copied" ? /* @__PURE__ */ jsx4(Check, {
|
|
217
|
+
"aria-hidden": "true"
|
|
218
|
+
}) : null,
|
|
219
|
+
copyState === "failed" ? /* @__PURE__ */ jsx4(TriangleAlert, {
|
|
220
|
+
"aria-hidden": "true"
|
|
221
|
+
}) : null,
|
|
222
|
+
copyState === "idle" ? /* @__PURE__ */ jsx4(Copy, {
|
|
223
|
+
"aria-hidden": "true"
|
|
224
|
+
}) : null,
|
|
225
|
+
isLarge ? /* @__PURE__ */ jsx4("span", {
|
|
226
|
+
children: labels.copy
|
|
227
|
+
}) : null
|
|
228
|
+
]
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// ../../src/components/ui/copy-value.tsx
|
|
233
|
+
import { useKrakstackLocale as useKrakstackLocale2 } from "@krak-stack/registry/krakstack-provider";
|
|
234
|
+
import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
235
|
+
var labels = {
|
|
236
|
+
en: { show: "Show", hide: "Hide", hidden: "Hidden value" },
|
|
237
|
+
fr: { show: "Afficher", hide: "Masquer", hidden: "Valeur masquée" }
|
|
238
|
+
};
|
|
239
|
+
var CopyValue = ({
|
|
240
|
+
value,
|
|
241
|
+
label,
|
|
242
|
+
secret = false,
|
|
243
|
+
variant = "outline",
|
|
244
|
+
disabled,
|
|
245
|
+
copyable = true,
|
|
246
|
+
autoHideDelay = 0,
|
|
247
|
+
className,
|
|
248
|
+
locale: override,
|
|
249
|
+
messages,
|
|
250
|
+
copyMessages
|
|
251
|
+
}) => {
|
|
252
|
+
const locale = useKrakstackLocale2(override);
|
|
253
|
+
const copy = {
|
|
254
|
+
...locale.startsWith("fr") ? labels.fr : labels.en,
|
|
255
|
+
...messages?.[locale.split("-")[0] ?? locale],
|
|
256
|
+
...messages?.[locale]
|
|
257
|
+
};
|
|
258
|
+
const [revealedValue, setRevealedValue] = useState2(null);
|
|
259
|
+
const [previous, setPrevious] = useState2({ value, disabled, secret });
|
|
260
|
+
if (previous.value !== value || previous.disabled !== disabled || previous.secret !== secret) {
|
|
261
|
+
setPrevious({ value, disabled, secret });
|
|
262
|
+
setRevealedValue(null);
|
|
263
|
+
}
|
|
264
|
+
const revealed = secret && !disabled && revealedValue === value;
|
|
265
|
+
useEffect2(() => {
|
|
266
|
+
if (!revealed || autoHideDelay <= 0)
|
|
267
|
+
return;
|
|
268
|
+
const timer = setTimeout(() => setRevealedValue(null), autoHideDelay);
|
|
269
|
+
return () => clearTimeout(timer);
|
|
270
|
+
}, [revealed, autoHideDelay, value]);
|
|
271
|
+
return /* @__PURE__ */ jsxs2(InputGroup, {
|
|
272
|
+
className: cn("min-w-0", variant === "ghost" && "border-0 bg-transparent shadow-none dark:bg-transparent", className),
|
|
273
|
+
children: [
|
|
274
|
+
/* @__PURE__ */ jsx5(InputGroupInput, {
|
|
275
|
+
className: variant === "ghost" ? "pl-0 font-mono" : undefined,
|
|
276
|
+
"aria-label": secret && !revealed ? `${label}: ${copy.hidden}` : label,
|
|
277
|
+
value,
|
|
278
|
+
type: secret && !revealed ? "password" : "text",
|
|
279
|
+
autoComplete: secret ? "off" : undefined,
|
|
280
|
+
readOnly: true,
|
|
281
|
+
disabled,
|
|
282
|
+
onFocus: (event) => event.currentTarget.select()
|
|
283
|
+
}),
|
|
284
|
+
/* @__PURE__ */ jsxs2(InputGroupAddon, {
|
|
285
|
+
align: "inline-end",
|
|
286
|
+
className: "gap-0",
|
|
287
|
+
children: [
|
|
288
|
+
secret ? /* @__PURE__ */ jsx5(InputGroupButton, {
|
|
289
|
+
type: "button",
|
|
290
|
+
size: "icon-sm",
|
|
291
|
+
variant: "ghost",
|
|
292
|
+
disabled,
|
|
293
|
+
"aria-label": `${revealed ? copy.hide : copy.show} ${label}`,
|
|
294
|
+
"aria-pressed": revealed,
|
|
295
|
+
onClick: () => setRevealedValue(revealed ? null : value),
|
|
296
|
+
children: revealed ? /* @__PURE__ */ jsx5(EyeOff, {
|
|
297
|
+
"aria-hidden": "true"
|
|
298
|
+
}) : /* @__PURE__ */ jsx5(Eye, {
|
|
299
|
+
"aria-hidden": "true"
|
|
300
|
+
})
|
|
301
|
+
}) : null,
|
|
302
|
+
copyable ? /* @__PURE__ */ jsx5(CopyButton, {
|
|
303
|
+
type: "button",
|
|
304
|
+
value,
|
|
305
|
+
valueDescription: label,
|
|
306
|
+
disabled,
|
|
307
|
+
variant: "ghost",
|
|
308
|
+
copyVariant: variant === "ghost" ? "default" : "large",
|
|
309
|
+
locale,
|
|
310
|
+
messages: copyMessages
|
|
311
|
+
}) : null
|
|
312
|
+
]
|
|
313
|
+
})
|
|
314
|
+
]
|
|
315
|
+
});
|
|
316
|
+
};
|
|
317
|
+
export {
|
|
318
|
+
CopyValue
|
|
319
|
+
};
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { type ReactElement, type ReactNode } from "react";
|
|
2
2
|
import { type PaginationMessages } from "./pagination.js";
|
|
3
3
|
import { ColumnFilter, type QueryType } from "../../lib/query.js";
|
|
4
|
+
/** Presentation only. Popup classes are applied inside portals, not to their triggers. */
|
|
5
|
+
export type DataTableClassNames = {
|
|
6
|
+
table?: Partial<Record<"content" | "header" | "body" | "row" | "head" | "cell", string>>;
|
|
7
|
+
toolbar?: Partial<Record<"content" | "search" | "trigger", string>>;
|
|
8
|
+
menu?: Partial<Record<"content" | "subContent" | "label" | "item" | "separator" | "subTrigger", string>>;
|
|
9
|
+
popup?: Partial<Record<"select" | "tooltip", string>>;
|
|
10
|
+
pagination?: string;
|
|
11
|
+
gallery?: string;
|
|
12
|
+
feedback?: Partial<Record<"loading" | "empty" | "error", string>>;
|
|
13
|
+
};
|
|
4
14
|
type RowData = object;
|
|
5
15
|
export type DataTableView = "table" | "gallery";
|
|
6
16
|
export type DataTablePublicState = QueryType;
|
|
@@ -471,6 +481,8 @@ export declare const dataTableMessages: (locale?: string, translations?: DataTab
|
|
|
471
481
|
selected: string;
|
|
472
482
|
};
|
|
473
483
|
export interface DataTableProps<TData extends RowData> {
|
|
484
|
+
className?: string;
|
|
485
|
+
classNames?: DataTableClassNames;
|
|
474
486
|
rowData: readonly TData[];
|
|
475
487
|
columnDefs: readonly DataTableColDef<TData>[];
|
|
476
488
|
getRowId?: (row: TData) => string;
|