@bettercms-ai/kit 4.0.0 → 4.1.1

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.
Files changed (125) hide show
  1. package/dist/adapters/lossy.d.ts +4 -0
  2. package/dist/adapters/lossy.js +4 -0
  3. package/dist/adapters/lossy.js.map +1 -1
  4. package/dist/adapters/prod-types.d.ts +4 -0
  5. package/dist/adapters/prod-types.js +4 -1
  6. package/dist/adapters/prod-types.js.map +1 -1
  7. package/dist/adapters/schema.js +7 -0
  8. package/dist/adapters/schema.js.map +1 -1
  9. package/dist/context.d.ts +83 -0
  10. package/dist/context.js +58 -1
  11. package/dist/context.js.map +1 -1
  12. package/dist/controls/choice.d.ts +1 -1
  13. package/dist/controls/choice.js +21 -2
  14. package/dist/controls/choice.js.map +1 -1
  15. package/dist/controls/index.d.ts +1 -0
  16. package/dist/controls/index.js +3 -2
  17. package/dist/controls/index.js.map +1 -1
  18. package/dist/controls/link.d.ts +23 -2
  19. package/dist/controls/link.js +456 -4
  20. package/dist/controls/link.js.map +1 -1
  21. package/dist/controls/media-v16.d.ts +27 -0
  22. package/dist/controls/media-v16.js +261 -0
  23. package/dist/controls/media-v16.js.map +1 -0
  24. package/dist/controls/media.js +63 -1
  25. package/dist/controls/media.js.map +1 -1
  26. package/dist/controls/reference-services.d.ts +8 -0
  27. package/dist/controls/reference.js +78 -2
  28. package/dist/controls/reference.js.map +1 -1
  29. package/dist/controls/rich-text/ai-runs.d.ts +13 -0
  30. package/dist/controls/rich-text/ai-runs.js +71 -0
  31. package/dist/controls/rich-text/ai-runs.js.map +1 -0
  32. package/dist/controls/rich-text/block-tool.d.ts +31 -0
  33. package/dist/controls/rich-text/block-tool.js +62 -0
  34. package/dist/controls/rich-text/block-tool.js.map +1 -0
  35. package/dist/controls/rich-text/blocks.d.ts +6 -1
  36. package/dist/controls/rich-text/blocks.js +404 -24
  37. package/dist/controls/rich-text/blocks.js.map +1 -1
  38. package/dist/controls/rich-text/catalog.d.ts +21 -6
  39. package/dist/controls/rich-text/catalog.js +312 -23
  40. package/dist/controls/rich-text/catalog.js.map +1 -1
  41. package/dist/controls/rich-text/code-head.d.ts +30 -0
  42. package/dist/controls/rich-text/code-head.js +230 -0
  43. package/dist/controls/rich-text/code-head.js.map +1 -0
  44. package/dist/controls/rich-text/codec.d.ts +1 -1
  45. package/dist/controls/rich-text/codec.js +3 -1
  46. package/dist/controls/rich-text/codec.js.map +1 -1
  47. package/dist/controls/rich-text/dom.d.ts +27 -0
  48. package/dist/controls/rich-text/dom.js +69 -4
  49. package/dist/controls/rich-text/dom.js.map +1 -1
  50. package/dist/controls/rich-text/editor.js +212 -50
  51. package/dist/controls/rich-text/editor.js.map +1 -1
  52. package/dist/controls/rich-text/ops.js +1 -0
  53. package/dist/controls/rich-text/ops.js.map +1 -1
  54. package/dist/controls/rich-text/slash-preview.d.ts +8 -0
  55. package/dist/controls/rich-text/slash-preview.js +287 -0
  56. package/dist/controls/rich-text/slash-preview.js.map +1 -0
  57. package/dist/controls/rich-text/table-grid.d.ts +22 -0
  58. package/dist/controls/rich-text/table-grid.js +1052 -0
  59. package/dist/controls/rich-text/table-grid.js.map +1 -0
  60. package/dist/controls/rich-text/toolbar.js +60 -18
  61. package/dist/controls/rich-text/toolbar.js.map +1 -1
  62. package/dist/controls/text.d.ts +6 -0
  63. package/dist/controls/text.js +95 -5
  64. package/dist/controls/text.js.map +1 -1
  65. package/dist/core/facets.d.ts +1 -0
  66. package/dist/core/facets.js +1 -0
  67. package/dist/core/facets.js.map +1 -1
  68. package/dist/engine/array.d.ts +7 -0
  69. package/dist/engine/array.js +164 -45
  70. package/dist/engine/array.js.map +1 -1
  71. package/dist/engine/field-shell.d.ts +12 -0
  72. package/dist/engine/field-shell.js +217 -63
  73. package/dist/engine/field-shell.js.map +1 -1
  74. package/dist/engine/frame.js +39 -2
  75. package/dist/engine/frame.js.map +1 -1
  76. package/dist/engine/grouping.d.ts +71 -10
  77. package/dist/engine/grouping.js +223 -26
  78. package/dist/engine/grouping.js.map +1 -1
  79. package/dist/engine/kit-field.js +38 -4
  80. package/dist/engine/kit-field.js.map +1 -1
  81. package/dist/engine/schema-form.js +7 -2
  82. package/dist/engine/schema-form.js.map +1 -1
  83. package/dist/index.d.ts +1 -1
  84. package/dist/index.js +13 -6
  85. package/dist/index.js.map +1 -1
  86. package/dist/kit.css +85 -0
  87. package/dist/schema/table.d.ts +2 -1
  88. package/dist/schema/table.js +5 -0
  89. package/dist/schema/table.js.map +1 -1
  90. package/dist/schema/types.d.ts +6 -0
  91. package/dist/schema/types.js.map +1 -1
  92. package/dist/styles.css +1 -1
  93. package/dist/theme.css +115 -0
  94. package/dist/tokens.css +268 -0
  95. package/dist/ui/block-icon-picker.d.ts +38 -0
  96. package/dist/ui/block-icon-picker.js +141 -0
  97. package/dist/ui/block-icon-picker.js.map +1 -0
  98. package/dist/ui/button.js +1 -0
  99. package/dist/ui/button.js.map +1 -1
  100. package/dist/ui/code-language-menu.d.ts +24 -0
  101. package/dist/ui/code-language-menu.js +123 -0
  102. package/dist/ui/code-language-menu.js.map +1 -0
  103. package/dist/ui/content-fields.d.ts +47 -0
  104. package/dist/ui/content-fields.js +278 -0
  105. package/dist/ui/content-fields.js.map +1 -0
  106. package/dist/ui/foundations.d.ts +118 -0
  107. package/dist/ui/foundations.js +564 -0
  108. package/dist/ui/foundations.js.map +1 -0
  109. package/dist/ui/index.d.ts +6 -0
  110. package/dist/ui/index.js +7 -1
  111. package/dist/ui/inspector.d.ts +394 -0
  112. package/dist/ui/inspector.js +1173 -0
  113. package/dist/ui/inspector.js.map +1 -0
  114. package/dist/ui/overlay.d.ts +7 -2
  115. package/dist/ui/overlay.js +55 -20
  116. package/dist/ui/overlay.js.map +1 -1
  117. package/dist/ui/shortcut-hint.js +1 -1
  118. package/dist/ui/shortcut-hint.js.map +1 -1
  119. package/dist/ui/toast.d.ts +5 -3
  120. package/dist/ui/toast.js +83 -11
  121. package/dist/ui/toast.js.map +1 -1
  122. package/dist/ui/tooltip-card.d.ts +45 -0
  123. package/dist/ui/tooltip-card.js +135 -0
  124. package/dist/ui/tooltip-card.js.map +1 -0
  125. package/package.json +1 -1
@@ -0,0 +1,118 @@
1
+ /**
2
+ * FOUNDATIONS · V1.6 (prototype editor-v16 `Btn`, `Checkbox`, `StatusIcon`, `Badge`, `ProBadge`, `TextField`, `Popover`,
3
+ * `ButtonStylePicker`, `SearchClear`, save status; kit.jsx:9-43, 255-296; ui.jsx:332-345, 393-398; foundations.css;
4
+ * kit.css:112-131; shellx.css:2-16, 199-204; faq.css:99-101).
5
+ *
6
+ * New names, so nothing of the stock kit changes: the kit's own `Button`, `Checkbox`, `Badge` and `Input` stay as they
7
+ * are. Colours are `--kit-insp-*` tokens (tokens.css). Every part is presentational: the host owns the state.
8
+ *
9
+ * <FoundationButton variant size icon> primary (ink) or secondary (grey), 28 / 32 / 34 high
10
+ * <FoundationCheckbox on mixed onChange label> 16, radius 4, violet when on, a dash when mixed
11
+ * <StatusIcon kind size> a 10% tint disc with a tick or an exclamation mark
12
+ * <FoundationBadge tone dot size> 20 (24) high tag with a 5 tone dot
13
+ * <ProBadge /> <BcmsMark size /> the white "PRO" pill with the gradient mark
14
+ * <FoundationTextField icon error /> 34 high grey field, violet focus ring, red edge on error
15
+ * <SearchClear show onClear /> the 16 round × that fades in when a search field has text
16
+ * <SaveStatus state onRetry /> Saved · Saving… · Couldn’t save · Retry · Offline
17
+ * <InspectorPopover anchor onClose label> anchored panel: 6 under the anchor, flips above, 8 from the edges
18
+ * <ButtonStylePicker anchor value onPick> "Button style": five radio rows with a live button preview
19
+ */
20
+ import * as React from "react";
21
+ export interface FoundationButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
22
+ variant?: "primary" | "secondary";
23
+ /** sm 28 · md 32 (default) · lg 34, beside a 34 high field */
24
+ size?: "sm" | "md" | "lg";
25
+ icon?: React.ReactNode;
26
+ }
27
+ export declare const FoundationButton: React.ForwardRefExoticComponent<FoundationButtonProps & React.RefAttributes<HTMLButtonElement>>;
28
+ export declare function FoundationCheckbox({ on, mixed, disabled, onChange, label, className, "aria-labelledby": labelledBy, }: {
29
+ on?: boolean;
30
+ mixed?: boolean;
31
+ disabled?: boolean;
32
+ onChange?: (on: boolean) => void;
33
+ label?: string;
34
+ className?: string;
35
+ "aria-labelledby"?: string;
36
+ }): import("react/jsx-runtime").JSX.Element;
37
+ export declare function StatusIcon({ kind, size, className }: {
38
+ kind?: "success" | "error";
39
+ size?: number;
40
+ className?: string;
41
+ }): import("react/jsx-runtime").JSX.Element;
42
+ export type FoundationBadgeTone = "gray" | "green" | "amber" | "red" | "blue" | "violet" | "outline";
43
+ export declare function FoundationBadge({ tone, dot, size, className, children, }: {
44
+ tone?: FoundationBadgeTone;
45
+ dot?: boolean;
46
+ size?: "sm" | "md";
47
+ className?: string;
48
+ children: React.ReactNode;
49
+ }): import("react/jsx-runtime").JSX.Element;
50
+ export declare function BcmsMark({ size }: {
51
+ size?: number;
52
+ }): import("react/jsx-runtime").JSX.Element;
53
+ export declare function ProBadge({ className }: {
54
+ className?: string;
55
+ }): import("react/jsx-runtime").JSX.Element;
56
+ export interface FoundationTextFieldProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "size"> {
57
+ icon?: React.ReactNode;
58
+ error?: boolean;
59
+ /** after the input: a `SearchClear`, a unit */
60
+ trailing?: React.ReactNode;
61
+ boxClassName?: string;
62
+ }
63
+ export declare const FoundationTextField: React.ForwardRefExoticComponent<FoundationTextFieldProps & React.RefAttributes<HTMLInputElement>>;
64
+ /** Out of the tab order: Escape clears from the keyboard (the field's owner handles it). */
65
+ export declare function SearchClear({ show, onClear, className }: {
66
+ show: boolean;
67
+ onClear: () => void;
68
+ className?: string;
69
+ }): import("react/jsx-runtime").JSX.Element;
70
+ export type SaveState = "saved" | "saving" | "error" | "offline";
71
+ /**
72
+ * The save status chip. `error` makes the whole chip the Retry button. `savedTitle` overrides the hover text of Saved
73
+ * (the prototype's reads "All changes saved to main": the branch is the host's to name).
74
+ */
75
+ export declare function SaveStatus({ state, onRetry, savedTitle, className }: {
76
+ state: SaveState;
77
+ onRetry?: () => void;
78
+ savedTitle?: string;
79
+ className?: string;
80
+ }): import("react/jsx-runtime").JSX.Element;
81
+ /**
82
+ * A panel on an anchor element: in a portal, 6 under the anchor (left edges aligned, or right with `align="right"`),
83
+ * above it when it would cross the window's bottom, never closer than 8 to the left or right edge. A press outside
84
+ * the panel and its anchor closes it, and so does Escape (captured, so nothing behind it also reacts).
85
+ */
86
+ export declare function InspectorPopover({ anchor, onClose, width, align, label, className, children, }: {
87
+ anchor: HTMLElement | null;
88
+ onClose: () => void;
89
+ width?: number;
90
+ align?: "left" | "right";
91
+ label: string;
92
+ className?: string;
93
+ children: React.ReactNode;
94
+ }): React.ReactPortal | null;
95
+ export type ButtonStyleKey = "primary" | "brand" | "secondary" | "outline" | "ghost";
96
+ export declare const BUTTON_STYLES: {
97
+ value: ButtonStyleKey;
98
+ label: string;
99
+ hint: string;
100
+ }[];
101
+ /**
102
+ * "Button style": five radio rows, each a live preview of the button in that style, its name and a hint, a check on
103
+ * the current one. `styles` narrows the list to what the site's button stores. The footer's "Edit" is drawn only when
104
+ * the host says where it goes (`onEdit`). ↑ ↓ move between rows.
105
+ */
106
+ export declare function ButtonStylePicker({ anchor, value, label, brand, styles, onPick, onClose, onEdit, align, }: {
107
+ anchor: HTMLElement | null;
108
+ value: ButtonStyleKey;
109
+ /** the button's own text, drawn in every preview */
110
+ label?: string;
111
+ /** the site's brand colour (a CSS colour) for the Color row */
112
+ brand?: string;
113
+ styles?: ButtonStyleKey[];
114
+ onPick: (value: ButtonStyleKey) => void;
115
+ onClose: () => void;
116
+ onEdit?: () => void;
117
+ align?: "left" | "right";
118
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,564 @@
1
+ import { cn } from "../lib/cn.js";
2
+ import * as React from "react";
3
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
+ import { motion, useReducedMotion } from "framer-motion";
5
+ import { createPortal } from "react-dom";
6
+ //#region src/ui/foundations.tsx
7
+ /**
8
+ * FOUNDATIONS · V1.6 (prototype editor-v16 `Btn`, `Checkbox`, `StatusIcon`, `Badge`, `ProBadge`, `TextField`, `Popover`,
9
+ * `ButtonStylePicker`, `SearchClear`, save status; kit.jsx:9-43, 255-296; ui.jsx:332-345, 393-398; foundations.css;
10
+ * kit.css:112-131; shellx.css:2-16, 199-204; faq.css:99-101).
11
+ *
12
+ * New names, so nothing of the stock kit changes: the kit's own `Button`, `Checkbox`, `Badge` and `Input` stay as they
13
+ * are. Colours are `--kit-insp-*` tokens (tokens.css). Every part is presentational: the host owns the state.
14
+ *
15
+ * <FoundationButton variant size icon> primary (ink) or secondary (grey), 28 / 32 / 34 high
16
+ * <FoundationCheckbox on mixed onChange label> 16, radius 4, violet when on, a dash when mixed
17
+ * <StatusIcon kind size> a 10% tint disc with a tick or an exclamation mark
18
+ * <FoundationBadge tone dot size> 20 (24) high tag with a 5 tone dot
19
+ * <ProBadge /> <BcmsMark size /> the white "PRO" pill with the gradient mark
20
+ * <FoundationTextField icon error /> 34 high grey field, violet focus ring, red edge on error
21
+ * <SearchClear show onClear /> the 16 round × that fades in when a search field has text
22
+ * <SaveStatus state onRetry /> Saved · Saving… · Couldn’t save · Retry · Offline
23
+ * <InspectorPopover anchor onClose label> anchored panel: 6 under the anchor, flips above, 8 from the edges
24
+ * <ButtonStylePicker anchor value onPick> "Button style": five radio rows with a live button preview
25
+ */
26
+ var FOCUS_HALO = "focus-visible:shadow-[0_0_0_3px_color-mix(in_srgb,var(--kit-insp-accent)_30%,transparent)]";
27
+ var FoundationButton = React.forwardRef(function FoundationButton({ variant = "primary", size = "md", icon, className, children, type = "button", ...rest }, ref) {
28
+ return /* @__PURE__ */ jsxs("button", {
29
+ ref,
30
+ type,
31
+ "data-slot": "kit-fbtn",
32
+ className: cn("inline-flex shrink-0 items-center justify-center gap-1.5 whitespace-nowrap rounded-[6px] font-medium outline-none transition-[background-color,color,opacity] duration-150", size === "sm" ? "h-7 px-2.5 text-[12px]" : size === "lg" ? "h-[34px] px-3.5 text-[13px]" : "h-8 px-3 text-[13px]", variant === "primary" ? "bg-kit-insp-tip-title text-kit-insp-tip-bg enabled:hover:bg-kit-insp-ink disabled:opacity-35" : "bg-kit-insp-card text-kit-insp-tip-title enabled:hover:bg-kit-insp-divider disabled:text-kit-insp-faint", FOCUS_HALO, className),
33
+ ...rest,
34
+ children: [icon, children]
35
+ });
36
+ });
37
+ function FoundationCheckbox({ on, mixed, disabled, onChange, label, className, "aria-labelledby": labelledBy }) {
38
+ const filled = !!on || !!mixed;
39
+ return /* @__PURE__ */ jsx("button", {
40
+ type: "button",
41
+ role: "checkbox",
42
+ "aria-checked": mixed ? "mixed" : !!on,
43
+ "aria-label": label,
44
+ "aria-labelledby": labelledBy,
45
+ disabled,
46
+ "data-slot": "kit-fcb",
47
+ onClick: (e) => {
48
+ e.stopPropagation();
49
+ onChange?.(!on);
50
+ },
51
+ className: cn("grid size-4 shrink-0 place-items-center rounded-[4px] outline-none transition-[background-color,box-shadow] duration-150 disabled:cursor-not-allowed disabled:opacity-40", filled ? "bg-kit-insp-accent-fg focus-visible:shadow-[0_0_0_3px_color-mix(in_srgb,var(--kit-insp-accent-fg)_20%,transparent)]" : "bg-kit-insp-tip-bg shadow-[inset_0_0_0_1.5px_var(--kit-insp-line-strong)] focus-visible:shadow-[0_0_0_3px_color-mix(in_srgb,var(--kit-insp-accent-fg)_20%,transparent),inset_0_0_0_1.5px_var(--kit-insp-line-strong)]", className),
52
+ children: filled ? /* @__PURE__ */ jsx("svg", {
53
+ width: "16",
54
+ height: "16",
55
+ viewBox: "0 0 16 16",
56
+ fill: "none",
57
+ "aria-hidden": true,
58
+ children: mixed ? /* @__PURE__ */ jsx("path", {
59
+ d: "M4.5 8h7",
60
+ stroke: "#fff",
61
+ strokeWidth: "1.8",
62
+ strokeLinecap: "round"
63
+ }) : /* @__PURE__ */ jsx("path", {
64
+ d: "M3.6 8.3l2.7 2.7l6-6.2",
65
+ stroke: "#fff",
66
+ strokeWidth: "1.8",
67
+ strokeLinecap: "round",
68
+ strokeLinejoin: "round"
69
+ })
70
+ }) : null
71
+ });
72
+ }
73
+ function StatusIcon({ kind = "success", size = 14, className }) {
74
+ const tint = kind === "success" ? "var(--kit-insp-ok-tint)" : "var(--kit-insp-err-tint)";
75
+ const ink = kind === "success" ? "var(--kit-insp-ok)" : "var(--kit-insp-err)";
76
+ return /* @__PURE__ */ jsxs("svg", {
77
+ width: size,
78
+ height: size,
79
+ viewBox: "0 0 14 14",
80
+ fill: "none",
81
+ "aria-hidden": true,
82
+ className: cn("shrink-0", className),
83
+ children: [/* @__PURE__ */ jsx("circle", {
84
+ cx: "7",
85
+ cy: "7",
86
+ r: "7",
87
+ fill: tint
88
+ }), kind === "success" ? /* @__PURE__ */ jsx("path", {
89
+ d: "M4.4 7.2 6.2 9 9.7 5.3",
90
+ stroke: ink,
91
+ strokeWidth: "1.6",
92
+ strokeLinecap: "round",
93
+ strokeLinejoin: "round"
94
+ }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("path", {
95
+ d: "M7 4.2v3.4",
96
+ stroke: ink,
97
+ strokeWidth: "1.6",
98
+ strokeLinecap: "round"
99
+ }), /* @__PURE__ */ jsx("path", {
100
+ d: "M7 9.8h.01",
101
+ stroke: ink,
102
+ strokeWidth: "1.9",
103
+ strokeLinecap: "round"
104
+ })] })]
105
+ });
106
+ }
107
+ var BADGE_TONE = {
108
+ gray: {
109
+ box: "bg-kit-insp-card text-kit-insp-tip-body",
110
+ dot: "bg-kit-group-sub"
111
+ },
112
+ green: {
113
+ box: "bg-[var(--kit-insp-badge-green)] text-[var(--kit-insp-badge-green-fg)]",
114
+ dot: "bg-[var(--kit-insp-badge-green-dot)]"
115
+ },
116
+ amber: {
117
+ box: "bg-[var(--kit-insp-badge-amber)] text-kit-insp-count-near",
118
+ dot: "bg-[var(--kit-insp-badge-amber-dot)]"
119
+ },
120
+ red: {
121
+ box: "bg-kit-insp-delete-bg text-kit-insp-count-over",
122
+ dot: "bg-kit-insp-ring-over"
123
+ },
124
+ blue: {
125
+ box: "bg-kit-insp-card text-kit-insp-tip-body",
126
+ dot: "bg-[var(--kit-insp-badge-blue-dot)]"
127
+ },
128
+ violet: {
129
+ box: "bg-kit-insp-card text-kit-insp-tip-body",
130
+ dot: "bg-kit-insp-accent"
131
+ },
132
+ outline: {
133
+ box: "bg-kit-insp-tip-bg text-kit-insp-tip-body shadow-[inset_0_0_0_1px_var(--kit-insp-line)]",
134
+ dot: "bg-kit-group-sub"
135
+ }
136
+ };
137
+ function FoundationBadge({ tone = "gray", dot = true, size = "sm", className, children }) {
138
+ const t = BADGE_TONE[tone];
139
+ return /* @__PURE__ */ jsxs("span", {
140
+ "data-slot": "kit-fbadge",
141
+ className: cn("inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap text-[12px] font-medium leading-4", size === "md" ? "h-6 rounded-[6px] pl-2 pr-2.5" : "h-5 rounded-[4px] pl-1.5 pr-2", t.box, className),
142
+ children: [dot ? /* @__PURE__ */ jsx("i", {
143
+ "aria-hidden": true,
144
+ className: cn("size-[5px] rounded-full", t.dot)
145
+ }) : null, children]
146
+ });
147
+ }
148
+ function BcmsMark({ size = 10 }) {
149
+ const id = React.useId();
150
+ return /* @__PURE__ */ jsxs("svg", {
151
+ width: size,
152
+ height: size * 28 / 24,
153
+ viewBox: "0 0 24 28",
154
+ fill: "none",
155
+ "aria-hidden": true,
156
+ children: [
157
+ /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("linearGradient", {
158
+ id,
159
+ x1: "8.8",
160
+ y1: "-2.8",
161
+ x2: "18.9",
162
+ y2: "29.1",
163
+ gradientUnits: "userSpaceOnUse",
164
+ children: [
165
+ /* @__PURE__ */ jsx("stop", {
166
+ offset: ".08",
167
+ stopColor: "#A878D2"
168
+ }),
169
+ /* @__PURE__ */ jsx("stop", {
170
+ offset: ".48",
171
+ stopColor: "#ED6262"
172
+ }),
173
+ /* @__PURE__ */ jsx("stop", {
174
+ offset: ".92",
175
+ stopColor: "#D13A3A"
176
+ })
177
+ ]
178
+ }) }),
179
+ /* @__PURE__ */ jsx("path", {
180
+ fill: `url(#${id})`,
181
+ d: "M12.76 27L1.51 20.09A3.1 3.1 0 0 1 0 17.4V8.6c0-1.15.62-2.21 1.63-2.77L9.59 1.4a3.2 3.2 0 0 1 2.92-.09l11.32 5.43-9.48 5.42a2.8 2.8 0 0 0-1.6 2.75V27z"
182
+ }),
183
+ /* @__PURE__ */ jsx("path", {
184
+ fill: `url(#${id})`,
185
+ d: "M14.34 16.02v2.85l7.88-5.01c.91-.58 1.47-1.59 1.47-2.67V8.3l-7.89 5.06a3.2 3.2 0 0 0-1.46 2.66zM14.34 22.26v2.85l7.88-5.01c.91-.58 1.47-1.59 1.47-2.67v-2.89l-7.89 5.06a3.2 3.2 0 0 0-1.46 2.66z"
186
+ })
187
+ ]
188
+ });
189
+ }
190
+ function ProBadge({ className }) {
191
+ return /* @__PURE__ */ jsxs("span", {
192
+ "data-slot": "kit-fpro",
193
+ className: cn("inline-flex h-5 shrink-0 items-center gap-1 rounded-full bg-kit-insp-tip-bg pl-[5px] pr-[7px] text-[10px] font-semibold leading-3 text-kit-insp-tip-body shadow-[inset_0_0_0_1px_var(--kit-insp-line)]", className),
194
+ children: [/* @__PURE__ */ jsx(BcmsMark, { size: 10 }), "PRO"]
195
+ });
196
+ }
197
+ var FoundationTextField = React.forwardRef(function FoundationTextField({ icon, error, trailing, boxClassName, className, ...rest }, ref) {
198
+ return /* @__PURE__ */ jsxs("label", {
199
+ "data-slot": "kit-fin",
200
+ className: cn("flex h-[34px] min-w-0 flex-1 items-center gap-2 rounded-[6px] px-2.5 text-kit-insp-faint transition-[background-color,box-shadow] duration-150 [&>svg]:size-4 [&>svg]:shrink-0", error ? "bg-kit-insp-tip-bg shadow-[inset_0_0_0_1px_var(--kit-insp-error)]" : "bg-kit-insp-card focus-within:bg-kit-insp-tip-bg focus-within:shadow-[inset_0_0_0_1px_var(--kit-insp-accent),0_0_0_3px_color-mix(in_srgb,var(--kit-insp-accent)_15%,transparent)]", boxClassName),
201
+ children: [
202
+ icon,
203
+ /* @__PURE__ */ jsx("input", {
204
+ ref,
205
+ "aria-invalid": error || void 0,
206
+ className: cn("h-full min-w-0 flex-1 border-0 bg-transparent text-[13px] text-kit-insp-tip-title outline-none placeholder:text-kit-group-sub focus-visible:shadow-none", className),
207
+ ...rest
208
+ }),
209
+ trailing
210
+ ]
211
+ });
212
+ });
213
+ /** Out of the tab order: Escape clears from the keyboard (the field's owner handles it). */
214
+ function SearchClear({ show, onClear, className }) {
215
+ return /* @__PURE__ */ jsx("button", {
216
+ type: "button",
217
+ tabIndex: -1,
218
+ "aria-label": "Clear search",
219
+ "aria-hidden": !show || void 0,
220
+ "data-slot": "kit-search-clear",
221
+ onMouseDown: (e) => e.preventDefault(),
222
+ onClick: onClear,
223
+ className: cn("grid size-4 shrink-0 place-items-center rounded-full bg-kit-insp-chip text-kit-insp-label transition-[opacity,transform] duration-150 ease-out hover:bg-[var(--kit-insp-chip-hover)]", show ? "opacity-100" : "pointer-events-none scale-50 opacity-0", className),
224
+ children: /* @__PURE__ */ jsx("svg", {
225
+ width: "10",
226
+ height: "10",
227
+ viewBox: "0 0 24 24",
228
+ fill: "none",
229
+ stroke: "currentColor",
230
+ strokeWidth: "2.2",
231
+ strokeLinecap: "round",
232
+ "aria-hidden": true,
233
+ children: /* @__PURE__ */ jsx("path", { d: "M18 6 6 18M6 6l12 12" })
234
+ })
235
+ });
236
+ }
237
+ var SAVE_COPY = {
238
+ saved: {
239
+ label: "Saved",
240
+ title: "All changes saved"
241
+ },
242
+ saving: { label: "Saving…" },
243
+ error: {
244
+ label: "Couldn’t save · Retry",
245
+ title: "Your latest changes didn’t reach the server. Try again"
246
+ },
247
+ offline: { label: "Offline · changes kept on this device" }
248
+ };
249
+ var SAVE_BOX = "inline-flex h-7 min-w-0 items-center gap-[5px] whitespace-nowrap rounded-[6px] px-1.5 text-[12px] font-medium leading-[18px]";
250
+ /**
251
+ * The save status chip. `error` makes the whole chip the Retry button. `savedTitle` overrides the hover text of Saved
252
+ * (the prototype's reads "All changes saved to main": the branch is the host's to name).
253
+ */
254
+ function SaveStatus({ state, onRetry, savedTitle, className }) {
255
+ const copy = SAVE_COPY[state];
256
+ const glyph = /* @__PURE__ */ jsx("span", {
257
+ "aria-hidden": true,
258
+ className: cn("relative grid h-3.5 shrink-0 place-items-center transition-[width] duration-150", state === "error" ? "w-[18px]" : "w-3.5"),
259
+ children: state === "saving" ? /* @__PURE__ */ jsxs("svg", {
260
+ width: "14",
261
+ height: "14",
262
+ viewBox: "0 0 14 14",
263
+ fill: "none",
264
+ className: "animate-spin [animation-duration:0.8s] motion-reduce:animate-none",
265
+ children: [/* @__PURE__ */ jsx("circle", {
266
+ cx: "7",
267
+ cy: "7",
268
+ r: "5.25",
269
+ stroke: "currentColor",
270
+ strokeOpacity: "0.25",
271
+ strokeWidth: "1.5"
272
+ }), /* @__PURE__ */ jsx("path", {
273
+ d: "M12.25 7A5.25 5.25 0 0 0 7 1.75",
274
+ stroke: "currentColor",
275
+ strokeWidth: "1.5",
276
+ strokeLinecap: "round"
277
+ })]
278
+ }) : state === "error" ? /* @__PURE__ */ jsx("svg", {
279
+ width: "18",
280
+ height: "16",
281
+ viewBox: "0 0 24 24",
282
+ fill: "none",
283
+ stroke: "currentColor",
284
+ strokeWidth: "1.8",
285
+ strokeLinecap: "round",
286
+ strokeLinejoin: "round",
287
+ children: /* @__PURE__ */ jsx("path", { d: "M7 18a4.6 4.4 0 0 1 0-9 5 4.5 0 0 1 11 2h1a3.5 3.5 0 0 1 0 7H7M12 11v3M12 16.5h.01" })
288
+ }) : state === "offline" ? /* @__PURE__ */ jsx("svg", {
289
+ width: "14",
290
+ height: "14",
291
+ viewBox: "0 0 24 24",
292
+ fill: "none",
293
+ stroke: "currentColor",
294
+ strokeWidth: "1.8",
295
+ strokeLinecap: "round",
296
+ strokeLinejoin: "round",
297
+ children: /* @__PURE__ */ jsx("path", { d: "M3 3l18 18M9.6 5.6A5 4.5 0 0 1 18 11h1a3.5 3.5 0 0 1 2.2 6.2M16 18H7a4.6 4.4 0 0 1-1.3-8.6" })
298
+ }) : /* @__PURE__ */ jsx(StatusIcon, { kind: "success" })
299
+ });
300
+ const text = /* @__PURE__ */ jsx("span", {
301
+ className: "min-w-0 truncate",
302
+ children: copy.label
303
+ });
304
+ if (state === "error") return /* @__PURE__ */ jsxs("button", {
305
+ type: "button",
306
+ "data-slot": "kit-save-status",
307
+ "data-state": state,
308
+ title: copy.title,
309
+ onClick: onRetry,
310
+ className: cn(SAVE_BOX, "text-kit-insp-count-over outline-none transition-[background-color] duration-[120ms] hover:bg-kit-insp-delete-bg focus-visible:shadow-[0_0_0_2px_var(--kit-insp-tip-bg),0_0_0_4px_var(--kit-insp-accent)]", className),
311
+ children: [glyph, text]
312
+ });
313
+ return /* @__PURE__ */ jsxs("span", {
314
+ "data-slot": "kit-save-status",
315
+ "data-state": state,
316
+ role: "status",
317
+ "aria-live": "polite",
318
+ title: state === "saved" ? savedTitle ?? copy.title : copy.title,
319
+ className: cn(SAVE_BOX, "text-kit-insp-desc", className),
320
+ children: [glyph, text]
321
+ });
322
+ }
323
+ /**
324
+ * A panel on an anchor element: in a portal, 6 under the anchor (left edges aligned, or right with `align="right"`),
325
+ * above it when it would cross the window's bottom, never closer than 8 to the left or right edge. A press outside
326
+ * the panel and its anchor closes it, and so does Escape (captured, so nothing behind it also reacts).
327
+ */
328
+ function InspectorPopover({ anchor, onClose, width = 300, align = "left", label, className, children }) {
329
+ const ref = React.useRef(null);
330
+ const reduce = useReducedMotion();
331
+ const [pos, setPos] = React.useState({
332
+ left: -9999,
333
+ top: 0,
334
+ origin: "top left"
335
+ });
336
+ React.useLayoutEffect(() => {
337
+ if (!anchor || !ref.current) return;
338
+ const r = anchor.getBoundingClientRect();
339
+ const h = ref.current.offsetHeight;
340
+ const left = align === "right" ? r.right - width : r.left;
341
+ let top = r.bottom + 6;
342
+ let above = false;
343
+ if (top + h > window.innerHeight - 8) {
344
+ top = Math.max(8, r.top - h - 6);
345
+ above = true;
346
+ }
347
+ setPos({
348
+ left: Math.max(8, Math.min(left, window.innerWidth - width - 8)),
349
+ top,
350
+ origin: `${above ? "bottom" : "top"} ${align}`
351
+ });
352
+ }, [
353
+ anchor,
354
+ width,
355
+ align
356
+ ]);
357
+ const close = React.useRef(onClose);
358
+ close.current = onClose;
359
+ React.useEffect(() => {
360
+ const down = (e) => {
361
+ const t = e.target;
362
+ if (!ref.current?.contains(t) && !anchor?.contains(t)) close.current();
363
+ };
364
+ const key = (e) => {
365
+ if (e.key !== "Escape") return;
366
+ e.stopPropagation();
367
+ close.current();
368
+ };
369
+ document.addEventListener("mousedown", down);
370
+ document.addEventListener("keydown", key, true);
371
+ return () => {
372
+ document.removeEventListener("mousedown", down);
373
+ document.removeEventListener("keydown", key, true);
374
+ };
375
+ }, [anchor]);
376
+ if (typeof document === "undefined") return null;
377
+ return createPortal(/* @__PURE__ */ jsx(motion.div, {
378
+ ref,
379
+ role: "dialog",
380
+ "aria-label": label,
381
+ "data-kit-scope": "",
382
+ "data-floating-layer": "",
383
+ "data-slot": "kit-insp-popover",
384
+ className: cn("fixed z-[var(--kit-z-popover,84)] overflow-hidden rounded-[10px] border border-kit-insp-line bg-kit-insp-tip-bg shadow-[0_1px_1px_rgb(0_0_0/0.04),0_6px_24px_rgb(0_0_0/0.1),0_9px_48px_rgb(0_0_0/0.08)]", className),
385
+ style: {
386
+ left: pos.left,
387
+ top: pos.top,
388
+ width,
389
+ transformOrigin: pos.origin
390
+ },
391
+ initial: reduce ? false : {
392
+ opacity: 0,
393
+ scale: .95,
394
+ filter: "blur(2px)"
395
+ },
396
+ animate: {
397
+ opacity: 1,
398
+ scale: 1,
399
+ filter: "blur(0px)"
400
+ },
401
+ transition: {
402
+ duration: .15,
403
+ ease: "easeOut"
404
+ },
405
+ children
406
+ }), document.body);
407
+ }
408
+ var BUTTON_STYLES = [
409
+ {
410
+ value: "primary",
411
+ label: "Solid",
412
+ hint: "Main action"
413
+ },
414
+ {
415
+ value: "brand",
416
+ label: "Color",
417
+ hint: "Brand colour"
418
+ },
419
+ {
420
+ value: "secondary",
421
+ label: "Soft",
422
+ hint: "Quiet"
423
+ },
424
+ {
425
+ value: "outline",
426
+ label: "Outline",
427
+ hint: "Low emphasis"
428
+ },
429
+ {
430
+ value: "ghost",
431
+ label: "Ghost",
432
+ hint: "Text only"
433
+ }
434
+ ];
435
+ /** How each style draws the preview button (the site's own button looks; `brand` is the site's brand colour). */
436
+ var previewStyle = (k, brand) => k === "primary" ? {
437
+ background: "#101010",
438
+ color: "#fff"
439
+ } : k === "brand" ? {
440
+ background: brand,
441
+ color: "#fff"
442
+ } : k === "secondary" ? {
443
+ background: "#E8E8E6",
444
+ color: "#101010"
445
+ } : k === "outline" ? {
446
+ background: "#fff",
447
+ color: "#101010",
448
+ borderColor: "#D4D4D2"
449
+ } : {
450
+ background: "transparent",
451
+ color: "#101010"
452
+ };
453
+ /**
454
+ * "Button style": five radio rows, each a live preview of the button in that style, its name and a hint, a check on
455
+ * the current one. `styles` narrows the list to what the site's button stores. The footer's "Edit" is drawn only when
456
+ * the host says where it goes (`onEdit`). ↑ ↓ move between rows.
457
+ */
458
+ function ButtonStylePicker({ anchor, value, label = "Get Started", brand = "var(--kit-insp-accent-fg)", styles, onPick, onClose, onEdit, align }) {
459
+ const list = styles ? BUTTON_STYLES.filter((s) => styles.includes(s.value)) : BUTTON_STYLES;
460
+ const rows = React.useRef(null);
461
+ const move = (e, i) => {
462
+ if (e.key !== "ArrowDown" && e.key !== "ArrowUp") return;
463
+ e.preventDefault();
464
+ const next = Math.max(0, Math.min(list.length - 1, i + (e.key === "ArrowDown" ? 1 : -1)));
465
+ rows.current?.querySelectorAll("[role=radio]")[next]?.focus();
466
+ };
467
+ return /* @__PURE__ */ jsxs(InspectorPopover, {
468
+ anchor,
469
+ onClose,
470
+ width: 300,
471
+ label: "Button style",
472
+ align,
473
+ children: [
474
+ /* @__PURE__ */ jsxs("div", {
475
+ className: "flex items-center gap-2 border-b border-kit-insp-divider px-3 py-2.5",
476
+ children: [
477
+ /* @__PURE__ */ jsx("svg", {
478
+ width: "14",
479
+ height: "14",
480
+ viewBox: "0 0 24 24",
481
+ fill: "none",
482
+ stroke: "currentColor",
483
+ strokeWidth: "1.8",
484
+ strokeLinecap: "round",
485
+ strokeLinejoin: "round",
486
+ "aria-hidden": true,
487
+ className: "shrink-0 text-kit-insp-label",
488
+ children: /* @__PURE__ */ jsx("path", { d: "m19 11-8-8-8.6 8.6a2 2 0 0 0 0 2.8l5.2 5.2c.8.8 2 .8 2.8 0L19 11ZM5 2l5 5M2 13h15M22 20a2 2 0 1 1-4 0c0-1.6 1.7-2.4 2-4 .3 1.6 2 2.4 2 4Z" })
489
+ }),
490
+ /* @__PURE__ */ jsx("b", {
491
+ className: "flex-1 text-[13px] font-medium text-kit-insp-ink",
492
+ children: "Button style"
493
+ }),
494
+ /* @__PURE__ */ jsx("kbd", {
495
+ className: "rounded-[4px] bg-[var(--kit-insp-kbd)] px-[5px] font-kit-sans text-[11px] font-medium leading-[18px] text-kit-insp-desc",
496
+ children: "Esc"
497
+ })
498
+ ]
499
+ }),
500
+ /* @__PURE__ */ jsx("div", {
501
+ ref: rows,
502
+ role: "radiogroup",
503
+ "aria-label": "Button style",
504
+ className: "flex flex-col gap-1.5 p-2",
505
+ children: list.map((o, i) => {
506
+ const on = value === o.value;
507
+ return /* @__PURE__ */ jsxs("button", {
508
+ type: "button",
509
+ role: "radio",
510
+ "aria-checked": on,
511
+ tabIndex: on || !list.some((x) => x.value === value) && i === 0 ? 0 : -1,
512
+ onClick: () => onPick(o.value),
513
+ onKeyDown: (e) => move(e, i),
514
+ className: cn("flex items-center gap-3 rounded-[8px] border p-2 text-left outline-none transition-[background-color,border-color] duration-[120ms] focus-visible:shadow-[0_0_0_2px_var(--kit-focus-ring)]", on ? "border-[var(--kit-insp-opt-on-line)] bg-[var(--kit-insp-opt-on)]" : "border-transparent bg-kit-insp-card-focus hover:bg-[var(--kit-insp-opt-hover)]"),
515
+ children: [
516
+ /* @__PURE__ */ jsx("span", {
517
+ "aria-hidden": true,
518
+ className: "pointer-events-none grid h-8 w-[112px] shrink-0 place-items-center truncate rounded-[6px] border border-transparent px-2 text-[12px] font-semibold leading-[18px]",
519
+ style: previewStyle(o.value, brand),
520
+ children: label
521
+ }),
522
+ /* @__PURE__ */ jsxs("span", {
523
+ className: "flex min-w-0 flex-1 flex-col gap-px",
524
+ children: [/* @__PURE__ */ jsx("b", {
525
+ className: "text-[13px] font-medium text-kit-insp-ink",
526
+ children: o.label
527
+ }), /* @__PURE__ */ jsx("small", {
528
+ className: "text-[12px] text-kit-insp-quiet",
529
+ children: o.hint
530
+ })]
531
+ }),
532
+ on ? /* @__PURE__ */ jsx("svg", {
533
+ width: "14",
534
+ height: "14",
535
+ viewBox: "0 0 24 24",
536
+ fill: "none",
537
+ stroke: "currentColor",
538
+ strokeWidth: "2",
539
+ strokeLinecap: "round",
540
+ strokeLinejoin: "round",
541
+ "aria-hidden": true,
542
+ className: "shrink-0 text-kit-insp-label",
543
+ children: /* @__PURE__ */ jsx("path", { d: "M5 12l5 5L20 7" })
544
+ }) : null
545
+ ]
546
+ }, o.value);
547
+ })
548
+ }),
549
+ /* @__PURE__ */ jsxs("div", {
550
+ className: "flex items-center justify-between gap-3 border-t border-kit-insp-divider px-3 py-2.5 text-[12px] leading-[18px] text-kit-insp-quiet",
551
+ children: [/* @__PURE__ */ jsx("span", { children: "Styles come from the site style guide" }), onEdit ? /* @__PURE__ */ jsx("button", {
552
+ type: "button",
553
+ onClick: onEdit,
554
+ className: "whitespace-nowrap rounded-[4px] text-[12px] font-medium text-kit-insp-accent-fg outline-none hover:underline hover:underline-offset-2 focus-visible:shadow-[0_0_0_2px_var(--kit-focus-ring)]",
555
+ children: "Edit"
556
+ }) : null]
557
+ })
558
+ ]
559
+ });
560
+ }
561
+ //#endregion
562
+ export { BUTTON_STYLES, BcmsMark, ButtonStylePicker, FoundationBadge, FoundationButton, FoundationCheckbox, FoundationTextField, InspectorPopover, ProBadge, SaveStatus, SearchClear, StatusIcon };
563
+
564
+ //# sourceMappingURL=foundations.js.map