@bettercms-ai/kit 3.0.0 → 3.0.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/dist/brand/logo.js +67 -18
- package/dist/brand/logo.js.map +1 -1
- package/dist/context.js +8 -3
- package/dist/context.js.map +1 -1
- package/dist/controls/button.js +451 -134
- package/dist/controls/button.js.map +1 -1
- package/dist/controls/choice.js +336 -95
- package/dist/controls/choice.js.map +1 -1
- package/dist/controls/code.js +245 -72
- package/dist/controls/code.js.map +1 -1
- package/dist/controls/color.js +108 -31
- package/dist/controls/color.js.map +1 -1
- package/dist/controls/date.js +268 -83
- package/dist/controls/date.js.map +1 -1
- package/dist/controls/form-picker.js +26 -9
- package/dist/controls/form-picker.js.map +1 -1
- package/dist/controls/icon.js +341 -100
- package/dist/controls/icon.js.map +1 -1
- package/dist/controls/json.js +20 -7
- package/dist/controls/json.js.map +1 -1
- package/dist/controls/link.js +561 -156
- package/dist/controls/link.js.map +1 -1
- package/dist/controls/location.js +124 -35
- package/dist/controls/location.js.map +1 -1
- package/dist/controls/media.js +928 -267
- package/dist/controls/media.js.map +1 -1
- package/dist/controls/number.js +80 -23
- package/dist/controls/number.js.map +1 -1
- package/dist/controls/reference.js +516 -155
- package/dist/controls/reference.js.map +1 -1
- package/dist/controls/rich-text/article-shell.js +327 -86
- package/dist/controls/rich-text/article-shell.js.map +1 -1
- package/dist/controls/rich-text/author.js +78 -21
- package/dist/controls/rich-text/author.js.map +1 -1
- package/dist/controls/rich-text/blocks.js +1084 -315
- package/dist/controls/rich-text/blocks.js.map +1 -1
- package/dist/controls/rich-text/button.js +30 -9
- package/dist/controls/rich-text/button.js.map +1 -1
- package/dist/controls/rich-text/catalog.js +168 -51
- package/dist/controls/rich-text/catalog.js.map +1 -1
- package/dist/controls/rich-text/columns.js +104 -31
- package/dist/controls/rich-text/columns.js.map +1 -1
- package/dist/controls/rich-text/component-card.js +790 -209
- package/dist/controls/rich-text/component-card.js.map +1 -1
- package/dist/controls/rich-text/component-panel.js +102 -40
- package/dist/controls/rich-text/component-panel.js.map +1 -1
- package/dist/controls/rich-text/control.js +101 -32
- package/dist/controls/rich-text/control.js.map +1 -1
- package/dist/controls/rich-text/editor.js +423 -121
- package/dist/controls/rich-text/editor.js.map +1 -1
- package/dist/controls/rich-text/embed.js +184 -51
- package/dist/controls/rich-text/embed.js.map +1 -1
- package/dist/controls/rich-text/floating.js +171 -42
- package/dist/controls/rich-text/floating.js.map +1 -1
- package/dist/controls/rich-text/footnote.js +89 -28
- package/dist/controls/rich-text/footnote.js.map +1 -1
- package/dist/controls/rich-text/gallery.js +88 -27
- package/dist/controls/rich-text/gallery.js.map +1 -1
- package/dist/controls/rich-text/link-form.js +111 -34
- package/dist/controls/rich-text/link-form.js.map +1 -1
- package/dist/controls/rich-text/plain.js +8 -3
- package/dist/controls/rich-text/plain.js.map +1 -1
- package/dist/controls/rich-text/related.js +86 -25
- package/dist/controls/rich-text/related.js.map +1 -1
- package/dist/controls/rich-text/toc.js +48 -15
- package/dist/controls/rich-text/toc.js.map +1 -1
- package/dist/controls/rich-text/toolbar.js +408 -107
- package/dist/controls/rich-text/toolbar.js.map +1 -1
- package/dist/controls/scale.js +169 -52
- package/dist/controls/scale.js.map +1 -1
- package/dist/controls/slot.js +238 -73
- package/dist/controls/slot.js.map +1 -1
- package/dist/controls/table/table-editor.js +1766 -500
- package/dist/controls/table/table-editor.js.map +1 -1
- package/dist/controls/table/table-link.js +119 -38
- package/dist/controls/table/table-link.js.map +1 -1
- package/dist/controls/table/table.js +26 -9
- package/dist/controls/table/table.js.map +1 -1
- package/dist/controls/text.js +221 -68
- package/dist/controls/text.js.map +1 -1
- package/dist/controls/unknown-value.js +79 -22
- package/dist/controls/unknown-value.js.map +1 -1
- package/dist/engine/array.js +875 -233
- package/dist/engine/array.js.map +1 -1
- package/dist/engine/bits.js +38 -13
- package/dist/engine/bits.js.map +1 -1
- package/dist/engine/breadcrumb.js +25 -8
- package/dist/engine/breadcrumb.js.map +1 -1
- package/dist/engine/expand.js +38 -13
- package/dist/engine/expand.js.map +1 -1
- package/dist/engine/field-list.js +14 -5
- package/dist/engine/field-list.js.map +1 -1
- package/dist/engine/field-shell.js +849 -244
- package/dist/engine/field-shell.js.map +1 -1
- package/dist/engine/frame.js +275 -78
- package/dist/engine/frame.js.map +1 -1
- package/dist/engine/grouping.js +630 -193
- package/dist/engine/grouping.js.map +1 -1
- package/dist/engine/item-list.js +187 -50
- package/dist/engine/item-list.js.map +1 -1
- package/dist/engine/kit-field.js +320 -95
- package/dist/engine/kit-field.js.map +1 -1
- package/dist/engine/schema-form.js +101 -32
- package/dist/engine/schema-form.js.map +1 -1
- package/dist/engine/slot.js +146 -45
- package/dist/engine/slot.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/lib/icons.js +14 -5
- package/dist/lib/icons.js.map +1 -1
- package/dist/styles.css +5821 -1
- package/dist/table/table-view.js +49 -16
- package/dist/table/table-view.js.map +1 -1
- package/dist/testing/test-form.js +14 -5
- package/dist/testing/test-form.js.map +1 -1
- package/dist/theme.js +8 -3
- package/dist/theme.js.map +1 -1
- package/dist/ui/action-tray.js +97 -24
- package/dist/ui/action-tray.js.map +1 -1
- package/dist/ui/autocomplete.js +135 -38
- package/dist/ui/autocomplete.js.map +1 -1
- package/dist/ui/button.js +108 -31
- package/dist/ui/button.js.map +1 -1
- package/dist/ui/choice-switch.js +14 -5
- package/dist/ui/choice-switch.js.map +1 -1
- package/dist/ui/controls.js +279 -86
- package/dist/ui/controls.js.map +1 -1
- package/dist/ui/display.js +401 -116
- package/dist/ui/display.js.map +1 -1
- package/dist/ui/expanded-editor-modal.js +100 -27
- package/dist/ui/expanded-editor-modal.js.map +1 -1
- package/dist/ui/floating-panel.js +130 -37
- package/dist/ui/floating-panel.js.map +1 -1
- package/dist/ui/index.js +2 -2
- package/dist/ui/input.js +196 -59
- package/dist/ui/input.js.map +1 -1
- package/dist/ui/mode-bar.js +32 -11
- package/dist/ui/mode-bar.js.map +1 -1
- package/dist/ui/overlay.js +616 -179
- package/dist/ui/overlay.js.map +1 -1
- package/dist/ui/path-crumbs.js +374 -113
- package/dist/ui/path-crumbs.js.map +1 -1
- package/dist/ui/select.js +311 -78
- package/dist/ui/select.js.map +1 -1
- package/dist/ui/shortcut-hint.d.ts +3 -0
- package/dist/ui/shortcut-hint.js +33 -7
- package/dist/ui/shortcut-hint.js.map +1 -1
- package/dist/ui/spinner.js +20 -7
- package/dist/ui/spinner.js.map +1 -1
- package/dist/ui/split-button.js +35 -10
- package/dist/ui/split-button.js.map +1 -1
- package/dist/ui/tab.js +50 -17
- package/dist/ui/tab.js.map +1 -1
- package/dist/ui/toast.js +107 -30
- package/dist/ui/toast.js.map +1 -1
- package/dist/ui/tooltip-root.js +24 -7
- package/dist/ui/tooltip-root.js.map +1 -1
- package/package.json +2 -2
|
@@ -5,7 +5,7 @@ import { Popover, PopoverContent, PopoverTrigger } from "../../ui/overlay.js";
|
|
|
5
5
|
import { Input } from "../../ui/input.js";
|
|
6
6
|
import { Select } from "../../ui/select.js";
|
|
7
7
|
import * as React from "react";
|
|
8
|
-
import {
|
|
8
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
9
9
|
import { IconLink } from "@tabler/icons-react";
|
|
10
10
|
//#region src/controls/table/table-link.tsx
|
|
11
11
|
/**
|
|
@@ -16,6 +16,7 @@ import { IconLink } from "@tabler/icons-react";
|
|
|
16
16
|
* Refusals are named before anything is written: a script address (javascript:, data:, vbscript:) is refused here
|
|
17
17
|
* exactly as the backend refuses it (`link_value_invalid`).
|
|
18
18
|
*/
|
|
19
|
+
var _jsxFileName = "D:/Github/bettercms/bettercms-backend/packages/kit/src/controls/table/table-link.tsx";
|
|
19
20
|
var LINK_RELS = [
|
|
20
21
|
{
|
|
21
22
|
value: "follow",
|
|
@@ -54,18 +55,22 @@ function LinkAddressEditor({ link, onSave, onCancel, autoFocus }) {
|
|
|
54
55
|
const id = React.useId();
|
|
55
56
|
const problem = hrefProblem(href);
|
|
56
57
|
const save = () => !problem && onSave(tableLink(link.label, href.trim(), newTab, rel));
|
|
57
|
-
return /* @__PURE__ */
|
|
58
|
+
return /* @__PURE__ */ jsxDEV("div", {
|
|
58
59
|
className: "flex flex-col gap-3",
|
|
59
60
|
children: [
|
|
60
|
-
/* @__PURE__ */
|
|
61
|
+
/* @__PURE__ */ jsxDEV("div", {
|
|
61
62
|
className: "flex flex-col gap-1.5",
|
|
62
63
|
children: [
|
|
63
|
-
/* @__PURE__ */
|
|
64
|
+
/* @__PURE__ */ jsxDEV("label", {
|
|
64
65
|
htmlFor: `${id}-href`,
|
|
65
66
|
className: "text-kit-xs font-medium text-kit-fg-2",
|
|
66
67
|
children: "Address"
|
|
67
|
-
}
|
|
68
|
-
|
|
68
|
+
}, void 0, false, {
|
|
69
|
+
fileName: _jsxFileName,
|
|
70
|
+
lineNumber: 56,
|
|
71
|
+
columnNumber: 9
|
|
72
|
+
}, this),
|
|
73
|
+
/* @__PURE__ */ jsxDEV(Input, {
|
|
69
74
|
id: `${id}-href`,
|
|
70
75
|
size: "sm",
|
|
71
76
|
autoFocus,
|
|
@@ -80,89 +85,153 @@ function LinkAddressEditor({ link, onSave, onCancel, autoFocus }) {
|
|
|
80
85
|
save();
|
|
81
86
|
}
|
|
82
87
|
}
|
|
83
|
-
}
|
|
84
|
-
|
|
88
|
+
}, void 0, false, {
|
|
89
|
+
fileName: _jsxFileName,
|
|
90
|
+
lineNumber: 57,
|
|
91
|
+
columnNumber: 9
|
|
92
|
+
}, this),
|
|
93
|
+
problem ? /* @__PURE__ */ jsxDEV("p", {
|
|
85
94
|
id: `${id}-problem`,
|
|
86
95
|
role: "alert",
|
|
87
96
|
className: "text-kit-xs text-kit-danger-fg",
|
|
88
97
|
children: problem
|
|
89
|
-
}
|
|
98
|
+
}, void 0, false, {
|
|
99
|
+
fileName: _jsxFileName,
|
|
100
|
+
lineNumber: 70,
|
|
101
|
+
columnNumber: 20
|
|
102
|
+
}, this) : null
|
|
90
103
|
]
|
|
91
|
-
}
|
|
92
|
-
|
|
104
|
+
}, void 0, true, {
|
|
105
|
+
fileName: _jsxFileName,
|
|
106
|
+
lineNumber: 55,
|
|
107
|
+
columnNumber: 7
|
|
108
|
+
}, this),
|
|
109
|
+
/* @__PURE__ */ jsxDEV("div", {
|
|
93
110
|
className: "flex min-h-8 items-center justify-between gap-2 text-kit-sm text-kit-fg-2",
|
|
94
|
-
children: [/* @__PURE__ */
|
|
111
|
+
children: [/* @__PURE__ */ jsxDEV("span", {
|
|
95
112
|
"aria-hidden": true,
|
|
96
113
|
children: "Open in a new tab"
|
|
97
|
-
}
|
|
114
|
+
}, void 0, false, {
|
|
115
|
+
fileName: _jsxFileName,
|
|
116
|
+
lineNumber: 73,
|
|
117
|
+
columnNumber: 9
|
|
118
|
+
}, this), /* @__PURE__ */ jsxDEV(Switch, {
|
|
98
119
|
size: "sm",
|
|
99
120
|
checked: newTab,
|
|
100
121
|
onCheckedChange: setNewTab,
|
|
101
122
|
"aria-label": "Open in a new tab"
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
123
|
+
}, void 0, false, {
|
|
124
|
+
fileName: _jsxFileName,
|
|
125
|
+
lineNumber: 74,
|
|
126
|
+
columnNumber: 9
|
|
127
|
+
}, this)]
|
|
128
|
+
}, void 0, true, {
|
|
129
|
+
fileName: _jsxFileName,
|
|
130
|
+
lineNumber: 72,
|
|
131
|
+
columnNumber: 7
|
|
132
|
+
}, this),
|
|
133
|
+
/* @__PURE__ */ jsxDEV("div", {
|
|
105
134
|
className: "flex flex-col gap-1.5",
|
|
106
|
-
children: [/* @__PURE__ */
|
|
135
|
+
children: [/* @__PURE__ */ jsxDEV("span", {
|
|
107
136
|
id: `${id}-rel`,
|
|
108
137
|
className: "text-kit-xs font-medium text-kit-fg-2",
|
|
109
138
|
children: "Search engines"
|
|
110
|
-
}
|
|
139
|
+
}, void 0, false, {
|
|
140
|
+
fileName: _jsxFileName,
|
|
141
|
+
lineNumber: 77,
|
|
142
|
+
columnNumber: 9
|
|
143
|
+
}, this), /* @__PURE__ */ jsxDEV(Select, {
|
|
111
144
|
"aria-label": "Search engines",
|
|
112
145
|
size: "sm",
|
|
113
146
|
value: rel,
|
|
114
147
|
onValueChange: (v) => setRel(v),
|
|
115
148
|
options: LINK_RELS
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
|
|
149
|
+
}, void 0, false, {
|
|
150
|
+
fileName: _jsxFileName,
|
|
151
|
+
lineNumber: 78,
|
|
152
|
+
columnNumber: 9
|
|
153
|
+
}, this)]
|
|
154
|
+
}, void 0, true, {
|
|
155
|
+
fileName: _jsxFileName,
|
|
156
|
+
lineNumber: 76,
|
|
157
|
+
columnNumber: 7
|
|
158
|
+
}, this),
|
|
159
|
+
/* @__PURE__ */ jsxDEV("div", {
|
|
119
160
|
className: "flex items-center justify-end gap-1.5",
|
|
120
161
|
children: [
|
|
121
|
-
link.href ? /* @__PURE__ */
|
|
162
|
+
link.href ? /* @__PURE__ */ jsxDEV(Button, {
|
|
122
163
|
size: "sm",
|
|
123
164
|
variant: "ghost",
|
|
124
165
|
className: "mr-auto text-kit-fg-2",
|
|
125
166
|
onClick: () => onSave(tableLink(link.label, "")),
|
|
126
167
|
children: "Remove link"
|
|
127
|
-
}
|
|
128
|
-
|
|
168
|
+
}, void 0, false, {
|
|
169
|
+
fileName: _jsxFileName,
|
|
170
|
+
lineNumber: 82,
|
|
171
|
+
columnNumber: 11
|
|
172
|
+
}, this) : null,
|
|
173
|
+
onCancel ? /* @__PURE__ */ jsxDEV(Button, {
|
|
129
174
|
size: "sm",
|
|
130
175
|
variant: "ghost",
|
|
131
176
|
onClick: onCancel,
|
|
132
177
|
children: "Cancel"
|
|
133
|
-
}
|
|
134
|
-
|
|
178
|
+
}, void 0, false, {
|
|
179
|
+
fileName: _jsxFileName,
|
|
180
|
+
lineNumber: 87,
|
|
181
|
+
columnNumber: 11
|
|
182
|
+
}, this) : null,
|
|
183
|
+
/* @__PURE__ */ jsxDEV(Button, {
|
|
135
184
|
size: "sm",
|
|
136
185
|
variant: "primary",
|
|
137
186
|
disabled: !!problem,
|
|
138
187
|
onClick: save,
|
|
139
188
|
children: "Save"
|
|
140
|
-
}
|
|
189
|
+
}, void 0, false, {
|
|
190
|
+
fileName: _jsxFileName,
|
|
191
|
+
lineNumber: 91,
|
|
192
|
+
columnNumber: 9
|
|
193
|
+
}, this)
|
|
141
194
|
]
|
|
142
|
-
}
|
|
195
|
+
}, void 0, true, {
|
|
196
|
+
fileName: _jsxFileName,
|
|
197
|
+
lineNumber: 80,
|
|
198
|
+
columnNumber: 7
|
|
199
|
+
}, this)
|
|
143
200
|
]
|
|
144
|
-
}
|
|
201
|
+
}, void 0, true, {
|
|
202
|
+
fileName: _jsxFileName,
|
|
203
|
+
lineNumber: 54,
|
|
204
|
+
columnNumber: 5
|
|
205
|
+
}, this);
|
|
145
206
|
}
|
|
146
207
|
/** The small link button beside a link cell's words: opens the address editor. */
|
|
147
208
|
function LinkAddressButton({ link, onSave, readOnly, className }) {
|
|
148
209
|
const [open, setOpen] = React.useState(false);
|
|
149
210
|
if (readOnly && !link.href) return null;
|
|
150
|
-
return /* @__PURE__ */
|
|
211
|
+
return /* @__PURE__ */ jsxDEV(Popover, {
|
|
151
212
|
open,
|
|
152
213
|
onOpenChange: setOpen,
|
|
153
|
-
children: [/* @__PURE__ */
|
|
214
|
+
children: [/* @__PURE__ */ jsxDEV(PopoverTrigger, {
|
|
154
215
|
disabled: readOnly,
|
|
155
216
|
tabIndex: -1,
|
|
156
217
|
"aria-label": link.href ? `Link: ${link.href}` : "Add a link address",
|
|
157
218
|
className: cn("flex size-5 shrink-0 items-center justify-center rounded-kit-sm text-kit-fg-4 outline-none hover:bg-kit-hover hover:text-kit-fg", link.href && "text-kit-fg-2", className),
|
|
158
|
-
children: /* @__PURE__ */
|
|
219
|
+
children: /* @__PURE__ */ jsxDEV(IconLink, {
|
|
159
220
|
className: "size-3.5",
|
|
160
221
|
stroke: 1.75
|
|
161
|
-
}
|
|
162
|
-
|
|
222
|
+
}, void 0, false, {
|
|
223
|
+
fileName: _jsxFileName,
|
|
224
|
+
lineNumber: 115,
|
|
225
|
+
columnNumber: 9
|
|
226
|
+
}, this)
|
|
227
|
+
}, void 0, false, {
|
|
228
|
+
fileName: _jsxFileName,
|
|
229
|
+
lineNumber: 105,
|
|
230
|
+
columnNumber: 7
|
|
231
|
+
}, this), /* @__PURE__ */ jsxDEV(PopoverContent, {
|
|
163
232
|
align: "end",
|
|
164
233
|
className: "w-[320px] p-3",
|
|
165
|
-
children: /* @__PURE__ */
|
|
234
|
+
children: /* @__PURE__ */ jsxDEV(LinkAddressEditor, {
|
|
166
235
|
link,
|
|
167
236
|
autoFocus: true,
|
|
168
237
|
onCancel: () => setOpen(false),
|
|
@@ -170,9 +239,21 @@ function LinkAddressButton({ link, onSave, readOnly, className }) {
|
|
|
170
239
|
onSave(l);
|
|
171
240
|
setOpen(false);
|
|
172
241
|
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
|
|
242
|
+
}, void 0, false, {
|
|
243
|
+
fileName: _jsxFileName,
|
|
244
|
+
lineNumber: 118,
|
|
245
|
+
columnNumber: 9
|
|
246
|
+
}, this)
|
|
247
|
+
}, void 0, false, {
|
|
248
|
+
fileName: _jsxFileName,
|
|
249
|
+
lineNumber: 117,
|
|
250
|
+
columnNumber: 7
|
|
251
|
+
}, this)]
|
|
252
|
+
}, void 0, true, {
|
|
253
|
+
fileName: _jsxFileName,
|
|
254
|
+
lineNumber: 104,
|
|
255
|
+
columnNumber: 5
|
|
256
|
+
}, this);
|
|
176
257
|
}
|
|
177
258
|
//#endregion
|
|
178
259
|
export { LINK_RELS, LinkAddressButton, LinkAddressEditor, hrefProblem, isScriptHref, tableLink };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-link.js","names":[],"sources":["../../../src/controls/table/table-link.tsx"],"sourcesContent":["/**\n * A link cell's address (BE TableLink `{ label, href, newTab?, rel? }`): the address, \"Open in a new tab\" and the\n * relationship search engines read. V2 opened its global link panel (controls/link.tsx LinkPopoverBody); that panel is the\n * link lane's, so the table carries this one, writing the same four keys the backend takes and nothing else.\n *\n * Refusals are named before anything is written: a script address (javascript:, data:, vbscript:) is refused here\n * exactly as the backend refuses it (`link_value_invalid`).\n */\nimport * as React from \"react\";\nimport { IconLink } from \"@tabler/icons-react\";\nimport { cn } from \"../../lib/cn\";\nimport { Button } from \"../../ui/button\";\nimport { Input } from \"../../ui/input\";\nimport { Switch } from \"../../ui/controls\";\nimport { Select } from \"../../ui/select\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"../../ui/overlay\";\nimport type { TableLink } from \"../../schema/table\";\n\nexport const LINK_RELS: { value: NonNullable<TableLink[\"rel\"]>; label: string }[] = [\n { value: \"follow\", label: \"Follow (default)\" },\n { value: \"nofollow\", label: \"Don't vouch for it (nofollow)\" },\n { value: \"sponsored\", label: \"Paid or sponsored\" },\n { value: \"ugc\", label: \"Written by visitors\" },\n];\n\n/** BE link-value.ts isScriptHref: what no link may hold. */\nexport const isScriptHref = (href: string) => /^\\s*(javascript|data|vbscript):/i.test(href.replace(/[\\p{Cc}\\s]+/gu, \"\"));\nexport const hrefProblem = (href: string) => (isScriptHref(href) ? \"Script links (javascript:, data:, vbscript:) aren't allowed.\" : null);\n\n/** The stored link with only the keys it uses: `newTab` only when on, `rel` only when not the default. */\nexport function tableLink(label: string, href: string, newTab?: boolean, rel?: TableLink[\"rel\"]): TableLink {\n return { label, href, ...(newTab ? { newTab: true } : {}), ...(rel && rel !== \"follow\" ? { rel } : {}) };\n}\n\n/** Address + options, as one popover body (the spreadsheet's link button) or inline (a row's link cell). */\nexport function LinkAddressEditor({\n link,\n onSave,\n onCancel,\n autoFocus,\n}: {\n link: TableLink;\n onSave: (next: TableLink) => void;\n onCancel?: () => void;\n autoFocus?: boolean;\n}) {\n const [href, setHref] = React.useState(link.href);\n const [newTab, setNewTab] = React.useState(!!link.newTab);\n const [rel, setRel] = React.useState<NonNullable<TableLink[\"rel\"]>>(link.rel ?? \"follow\");\n const id = React.useId();\n const problem = hrefProblem(href);\n const save = () => !problem && onSave(tableLink(link.label, href.trim(), newTab, rel));\n return (\n <div className=\"flex flex-col gap-3\">\n <div className=\"flex flex-col gap-1.5\">\n <label htmlFor={`${id}-href`} className=\"text-kit-xs font-medium text-kit-fg-2\">Address</label>\n <Input\n id={`${id}-href`}\n size=\"sm\"\n autoFocus={autoFocus}\n value={href}\n placeholder=\"https://… or /pricing\"\n aria-invalid={problem ? true : undefined}\n aria-describedby={problem ? `${id}-problem` : undefined}\n onChange={(e) => setHref(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === \"Enter\") { e.preventDefault(); save(); }\n }}\n />\n {problem ? <p id={`${id}-problem`} role=\"alert\" className=\"text-kit-xs text-kit-danger-fg\">{problem}</p> : null}\n </div>\n <div className=\"flex min-h-8 items-center justify-between gap-2 text-kit-sm text-kit-fg-2\">\n <span aria-hidden>Open in a new tab</span>\n <Switch size=\"sm\" checked={newTab} onCheckedChange={setNewTab} aria-label=\"Open in a new tab\" />\n </div>\n <div className=\"flex flex-col gap-1.5\">\n <span id={`${id}-rel`} className=\"text-kit-xs font-medium text-kit-fg-2\">Search engines</span>\n <Select aria-label=\"Search engines\" size=\"sm\" value={rel} onValueChange={(v) => setRel(v as typeof rel)} options={LINK_RELS} />\n </div>\n <div className=\"flex items-center justify-end gap-1.5\">\n {link.href ? (\n <Button size=\"sm\" variant=\"ghost\" className=\"mr-auto text-kit-fg-2\" onClick={() => onSave(tableLink(link.label, \"\"))}>\n Remove link\n </Button>\n ) : null}\n {onCancel ? (\n <Button size=\"sm\" variant=\"ghost\" onClick={onCancel}>\n Cancel\n </Button>\n ) : null}\n <Button size=\"sm\" variant=\"primary\" disabled={!!problem} onClick={save}>\n Save\n </Button>\n </div>\n </div>\n );\n}\n\n/** The small link button beside a link cell's words: opens the address editor. */\nexport function LinkAddressButton({ link, onSave, readOnly, className }: { link: TableLink; onSave: (l: TableLink) => void; readOnly?: boolean; className?: string }) {\n const [open, setOpen] = React.useState(false);\n if (readOnly && !link.href) return null;\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger\n disabled={readOnly}\n tabIndex={-1}\n aria-label={link.href ? `Link: ${link.href}` : \"Add a link address\"}\n className={cn(\n \"flex size-5 shrink-0 items-center justify-center rounded-kit-sm text-kit-fg-4 outline-none hover:bg-kit-hover hover:text-kit-fg\",\n link.href && \"text-kit-fg-2\",\n className,\n )}\n >\n <IconLink className=\"size-3.5\" stroke={1.75} />\n </PopoverTrigger>\n <PopoverContent align=\"end\" className=\"w-[320px] p-3\">\n <LinkAddressEditor\n link={link}\n autoFocus\n onCancel={() => setOpen(false)}\n onSave={(l) => {\n onSave(l);\n setOpen(false);\n }}\n />\n </PopoverContent>\n </Popover>\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"table-link.js","names":[],"sources":["../../../src/controls/table/table-link.tsx"],"sourcesContent":["/**\n * A link cell's address (BE TableLink `{ label, href, newTab?, rel? }`): the address, \"Open in a new tab\" and the\n * relationship search engines read. V2 opened its global link panel (controls/link.tsx LinkPopoverBody); that panel is the\n * link lane's, so the table carries this one, writing the same four keys the backend takes and nothing else.\n *\n * Refusals are named before anything is written: a script address (javascript:, data:, vbscript:) is refused here\n * exactly as the backend refuses it (`link_value_invalid`).\n */\nimport * as React from \"react\";\nimport { IconLink } from \"@tabler/icons-react\";\nimport { cn } from \"../../lib/cn\";\nimport { Button } from \"../../ui/button\";\nimport { Input } from \"../../ui/input\";\nimport { Switch } from \"../../ui/controls\";\nimport { Select } from \"../../ui/select\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"../../ui/overlay\";\nimport type { TableLink } from \"../../schema/table\";\n\nexport const LINK_RELS: { value: NonNullable<TableLink[\"rel\"]>; label: string }[] = [\n { value: \"follow\", label: \"Follow (default)\" },\n { value: \"nofollow\", label: \"Don't vouch for it (nofollow)\" },\n { value: \"sponsored\", label: \"Paid or sponsored\" },\n { value: \"ugc\", label: \"Written by visitors\" },\n];\n\n/** BE link-value.ts isScriptHref: what no link may hold. */\nexport const isScriptHref = (href: string) => /^\\s*(javascript|data|vbscript):/i.test(href.replace(/[\\p{Cc}\\s]+/gu, \"\"));\nexport const hrefProblem = (href: string) => (isScriptHref(href) ? \"Script links (javascript:, data:, vbscript:) aren't allowed.\" : null);\n\n/** The stored link with only the keys it uses: `newTab` only when on, `rel` only when not the default. */\nexport function tableLink(label: string, href: string, newTab?: boolean, rel?: TableLink[\"rel\"]): TableLink {\n return { label, href, ...(newTab ? { newTab: true } : {}), ...(rel && rel !== \"follow\" ? { rel } : {}) };\n}\n\n/** Address + options, as one popover body (the spreadsheet's link button) or inline (a row's link cell). */\nexport function LinkAddressEditor({\n link,\n onSave,\n onCancel,\n autoFocus,\n}: {\n link: TableLink;\n onSave: (next: TableLink) => void;\n onCancel?: () => void;\n autoFocus?: boolean;\n}) {\n const [href, setHref] = React.useState(link.href);\n const [newTab, setNewTab] = React.useState(!!link.newTab);\n const [rel, setRel] = React.useState<NonNullable<TableLink[\"rel\"]>>(link.rel ?? \"follow\");\n const id = React.useId();\n const problem = hrefProblem(href);\n const save = () => !problem && onSave(tableLink(link.label, href.trim(), newTab, rel));\n return (\n <div className=\"flex flex-col gap-3\">\n <div className=\"flex flex-col gap-1.5\">\n <label htmlFor={`${id}-href`} className=\"text-kit-xs font-medium text-kit-fg-2\">Address</label>\n <Input\n id={`${id}-href`}\n size=\"sm\"\n autoFocus={autoFocus}\n value={href}\n placeholder=\"https://… or /pricing\"\n aria-invalid={problem ? true : undefined}\n aria-describedby={problem ? `${id}-problem` : undefined}\n onChange={(e) => setHref(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === \"Enter\") { e.preventDefault(); save(); }\n }}\n />\n {problem ? <p id={`${id}-problem`} role=\"alert\" className=\"text-kit-xs text-kit-danger-fg\">{problem}</p> : null}\n </div>\n <div className=\"flex min-h-8 items-center justify-between gap-2 text-kit-sm text-kit-fg-2\">\n <span aria-hidden>Open in a new tab</span>\n <Switch size=\"sm\" checked={newTab} onCheckedChange={setNewTab} aria-label=\"Open in a new tab\" />\n </div>\n <div className=\"flex flex-col gap-1.5\">\n <span id={`${id}-rel`} className=\"text-kit-xs font-medium text-kit-fg-2\">Search engines</span>\n <Select aria-label=\"Search engines\" size=\"sm\" value={rel} onValueChange={(v) => setRel(v as typeof rel)} options={LINK_RELS} />\n </div>\n <div className=\"flex items-center justify-end gap-1.5\">\n {link.href ? (\n <Button size=\"sm\" variant=\"ghost\" className=\"mr-auto text-kit-fg-2\" onClick={() => onSave(tableLink(link.label, \"\"))}>\n Remove link\n </Button>\n ) : null}\n {onCancel ? (\n <Button size=\"sm\" variant=\"ghost\" onClick={onCancel}>\n Cancel\n </Button>\n ) : null}\n <Button size=\"sm\" variant=\"primary\" disabled={!!problem} onClick={save}>\n Save\n </Button>\n </div>\n </div>\n );\n}\n\n/** The small link button beside a link cell's words: opens the address editor. */\nexport function LinkAddressButton({ link, onSave, readOnly, className }: { link: TableLink; onSave: (l: TableLink) => void; readOnly?: boolean; className?: string }) {\n const [open, setOpen] = React.useState(false);\n if (readOnly && !link.href) return null;\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger\n disabled={readOnly}\n tabIndex={-1}\n aria-label={link.href ? `Link: ${link.href}` : \"Add a link address\"}\n className={cn(\n \"flex size-5 shrink-0 items-center justify-center rounded-kit-sm text-kit-fg-4 outline-none hover:bg-kit-hover hover:text-kit-fg\",\n link.href && \"text-kit-fg-2\",\n className,\n )}\n >\n <IconLink className=\"size-3.5\" stroke={1.75} />\n </PopoverTrigger>\n <PopoverContent align=\"end\" className=\"w-[320px] p-3\">\n <LinkAddressEditor\n link={link}\n autoFocus\n onCancel={() => setOpen(false)}\n onSave={(l) => {\n onSave(l);\n setOpen(false);\n }}\n />\n </PopoverContent>\n </Popover>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAkBA,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KAE7C,GAAA,KAAA,GAAA,OAAA;;;;KACN,GAAA,IAAA,IAAA;KACJ,uBAAC,QAAD;MAAQ,MAAK;MAAK,SAAQ;MAAU,UAAU,CAAC,CAAC;MAAS,SAAS;MAAM,UAAA;KAEhE,GAAA,KAAA,GAAA,OAAA;;;;;IACL;;;;;;EACF;;;;;;AAET;;AAGA,SAAgB,kBAAkB,EAAE,MAAM,QAAQ,UAAU,aAA0G;CACpK,MAAM,CAAC,MAAM,WAAW,MAAM,SAAS,KAAK;CAC5C,IAAI,YAAY,CAAC,KAAK,MAAM,OAAO;CACnC,OACE,uBAAC,SAAD;EAAe;EAAM,cAAc;EAAnC,UAAA,CACE,uBAAC,gBAAD;GACE,UAAU;GACV,UAAU;GACV,cAAY,KAAK,OAAO,SAAS,KAAK,SAAS;GAC/C,WAAW,GACT,mIACA,KAAK,QAAQ,iBACb,SACF;GAEA,UAAA,uBAAC,UAAD;IAAU,WAAU;IAAW,QAAQ;GAAO,GAAA,KAAA,GAAA,OAAA;;;;;EAChC,GAAA,KAAA,GAAA,OAAA;;;;EAChB,GAAA,IAAA,GAAA,uBAAC,gBAAD;GAAgB,OAAM;GAAM,WAAU;GACpC,UAAA,uBAAC,mBAAD;IACQ;IACN,WAAA;IACA,gBAAgB,QAAQ,KAAK;IAC7B,SAAS,MAAM;KACb,OAAO,CAAC;KACR,QAAQ,KAAK;IACf;GACD,GAAA,KAAA,GAAA,OAAA;;;;;EACa,GAAA,KAAA,GAAA,OAAA;;;;EACT,GAAA,IAAA,CAAA;;;;;;AAEb"}
|
|
@@ -4,7 +4,7 @@ import { resolveFieldAccess, useForm, useKitEnv } from "../../context.js";
|
|
|
4
4
|
import { TableEditor, TableFullScreenButton, TableItemEditor } from "./table-editor.js";
|
|
5
5
|
import { storedTable } from "./stored.js";
|
|
6
6
|
import * as React from "react";
|
|
7
|
-
import {
|
|
7
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
8
8
|
//#region src/controls/table/table.tsx
|
|
9
9
|
/**
|
|
10
10
|
* TABLE control (CPO D42, D50, D52; port of V2 kit/controls/table.tsx): the `table` field type (a content-model `table`
|
|
@@ -18,6 +18,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
18
18
|
* Value: `TableValue` (schema/table.ts), written in the exact shape the backend stores (stored.ts): keys the editor
|
|
19
19
|
* fills in for itself are never written back unless the person changed them.
|
|
20
20
|
*/
|
|
21
|
+
var _jsxFileName = "D:/Github/bettercms/bettercms-backend/packages/kit/src/controls/table/table.tsx";
|
|
21
22
|
var fullKey = null;
|
|
22
23
|
var subs = /* @__PURE__ */ new Set();
|
|
23
24
|
var setFullKey = (k) => {
|
|
@@ -30,10 +31,14 @@ var fullKeyOf = (docId, path) => `${docId}:${pathKey(path)}`;
|
|
|
30
31
|
/** Label-row action of a table field (KitField ACTIONS.table): the one way into the full-screen spreadsheet (D49). */
|
|
31
32
|
function TableFullScreenAction({ path }) {
|
|
32
33
|
const env = useKitEnv();
|
|
33
|
-
return /* @__PURE__ */
|
|
34
|
+
return /* @__PURE__ */ jsxDEV(TableFullScreenButton, {
|
|
34
35
|
className: "-my-1",
|
|
35
36
|
onOpen: () => setFullKey(fullKeyOf(env.docId, path))
|
|
36
|
-
}
|
|
37
|
+
}, void 0, false, {
|
|
38
|
+
fileName: _jsxFileName,
|
|
39
|
+
lineNumber: 37,
|
|
40
|
+
columnNumber: 10
|
|
41
|
+
}, this);
|
|
37
42
|
}
|
|
38
43
|
function TableControl({ field, value, onChange, readOnly, path }) {
|
|
39
44
|
const env = useKitEnv();
|
|
@@ -57,11 +62,11 @@ function TableControl({ field, value, onChange, readOnly, path }) {
|
|
|
57
62
|
key,
|
|
58
63
|
path
|
|
59
64
|
]);
|
|
60
|
-
return /* @__PURE__ */
|
|
65
|
+
return /* @__PURE__ */ jsxDEV("div", {
|
|
61
66
|
ref: host,
|
|
62
67
|
className: "min-w-0",
|
|
63
68
|
"data-kit-control": "table",
|
|
64
|
-
children: /* @__PURE__ */
|
|
69
|
+
children: /* @__PURE__ */ jsxDEV(TableEditor, {
|
|
65
70
|
value: t ?? fallback,
|
|
66
71
|
onChange: (next) => onChange(storedTable(next, value)),
|
|
67
72
|
readOnly,
|
|
@@ -75,8 +80,16 @@ function TableControl({ field, value, onChange, readOnly, path }) {
|
|
|
75
80
|
onOpenChange: (o) => setFullKey(o ? key : null),
|
|
76
81
|
returnFocus: () => host.current?.closest("[data-field-key]")?.querySelector("button[aria-label=\"Edit in full screen\"]") ?? null
|
|
77
82
|
}
|
|
78
|
-
}
|
|
79
|
-
|
|
83
|
+
}, void 0, false, {
|
|
84
|
+
fileName: _jsxFileName,
|
|
85
|
+
lineNumber: 57,
|
|
86
|
+
columnNumber: 7
|
|
87
|
+
}, this)
|
|
88
|
+
}, void 0, false, {
|
|
89
|
+
fileName: _jsxFileName,
|
|
90
|
+
lineNumber: 56,
|
|
91
|
+
columnNumber: 5
|
|
92
|
+
}, this);
|
|
80
93
|
}
|
|
81
94
|
/** The body of a drilled table row or column frame (FrameView draws the standard header above it): FrameSlots.TableFrame. */
|
|
82
95
|
function TableFrame({ frame }) {
|
|
@@ -87,7 +100,7 @@ function TableFrame({ frame }) {
|
|
|
87
100
|
const tablePath = it.arrayPath.slice(0, -1);
|
|
88
101
|
const raw = form.getAt(tablePath);
|
|
89
102
|
const readOnly = resolveFieldAccess(field, env).readOnly;
|
|
90
|
-
return /* @__PURE__ */
|
|
103
|
+
return /* @__PURE__ */ jsxDEV(TableItemEditor, {
|
|
91
104
|
kind: frame.kind === "tableRow" ? "row" : "column",
|
|
92
105
|
index: it.index,
|
|
93
106
|
value: normalizeTable(raw),
|
|
@@ -95,7 +108,11 @@ function TableFrame({ frame }) {
|
|
|
95
108
|
options: field.table ?? GENERAL_TABLE,
|
|
96
109
|
developer: env.can("schema.manage"),
|
|
97
110
|
readOnly
|
|
98
|
-
}
|
|
111
|
+
}, void 0, false, {
|
|
112
|
+
fileName: _jsxFileName,
|
|
113
|
+
lineNumber: 86,
|
|
114
|
+
columnNumber: 5
|
|
115
|
+
}, this);
|
|
99
116
|
}
|
|
100
117
|
//#endregion
|
|
101
118
|
export { TableControl, TableFrame, TableFullScreenAction };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.js","names":[],"sources":["../../../src/controls/table/table.tsx"],"sourcesContent":["/**\n * TABLE control (CPO D42, D50, D52; port of V2 kit/controls/table.tsx): the `table` field type (a content-model `table`\n * field, or a component `table` prop with `config.mode: \"data\"`) edits like any nested array, with no container of its\n * own: Title, Columns, Rows (groups live in the row list), Note under the table, and a collapsed Table settings that\n * offers only what `field.table.settings` allows (no `table` options = a general table, everything offered). A row or a\n * column drills through the form's own navigation (TableFrame), so the breadcrumb and frame header are the ones every\n * FAQ or feature item uses. The ⤢ button in the field's label row (TableFullScreenAction) opens the spreadsheet in the\n * expanded-editor modal (D49).\n *\n * Value: `TableValue` (schema/table.ts), written in the exact shape the backend stores (stored.ts): keys the editor\n * fills in for itself are never written back unless the person changed them.\n */\nimport * as React from \"react\";\nimport { resolveFieldAccess, useForm, useKitEnv } from \"../../context\";\nimport type { Frame } from \"../../lib/frames\";\nimport { pathKey } from \"../../lib/path\";\nimport type { FieldPath } from \"../../schema/types\";\nimport { GENERAL_TABLE, emptyTable, isTableValue, normalizeTable, type TableValue } from \"../../schema/table\";\nimport type { ControlProps } from \"../../types\";\nimport { TableEditor, TableFullScreenButton, TableItemEditor } from \"./table-editor\";\nimport { storedTable } from \"./stored\";\n\n/* Which table field has its spreadsheet open (the label-row button and the control share it). */\nlet fullKey: string | null = null;\nconst subs = new Set<() => void>();\nconst setFullKey = (k: string | null) => {\n fullKey = k;\n subs.forEach((f) => f());\n};\nconst subscribe = (f: () => void) => (subs.add(f), () => void subs.delete(f));\nconst useFullOpen = (k: string) => React.useSyncExternalStore(subscribe, () => fullKey === k, () => false);\nconst fullKeyOf = (docId: string, path: FieldPath) => `${docId}:${pathKey(path)}`;\n\n/** Label-row action of a table field (KitField ACTIONS.table): the one way into the full-screen spreadsheet (D49). */\nexport function TableFullScreenAction({ path }: Pick<ControlProps, \"path\">) {\n const env = useKitEnv();\n return <TableFullScreenButton className=\"-my-1\" onOpen={() => setFullKey(fullKeyOf(env.docId, path))} />;\n}\n\nexport function TableControl({ field, value, onChange, readOnly, path }: ControlProps) {\n const env = useKitEnv();\n const form = useForm();\n const t = React.useMemo(() => (isTableValue(value) ? normalizeTable(value) : null), [value]);\n // no value yet: the field's default table, else an empty 3 × 2 one (nothing is written until the person edits it)\n const fallback = React.useMemo(() => (isTableValue(field.initialValue) ? normalizeTable(field.initialValue) : emptyTable()), [field.initialValue]);\n const key = fullKeyOf(env.docId, path);\n const full = useFullOpen(key);\n // the spreadsheet belongs to this mount: a dock closed with it open must not reopen it on the next visit\n React.useEffect(() => () => void (fullKey === key && setFullKey(null)), [key]);\n const host = React.useRef<HTMLDivElement>(null);\n const nav = React.useMemo(\n () => (form?.canNavigate ? { id: key, basePath: path, open: (kind: \"rows\" | \"columns\", i: number) => form.navigate([...path, kind, i]) } : undefined),\n [form, key, path],\n );\n return (\n <div ref={host} className=\"min-w-0\" data-kit-control=\"table\">\n <TableEditor\n value={t ?? fallback}\n onChange={(next: TableValue) => onChange(storedTable(next, value))}\n readOnly={readOnly}\n options={field.table ?? GENERAL_TABLE}\n developer={env.can(\"schema.manage\")}\n label={field.title}\n parentTitle={env.docTitle}\n nav={nav}\n fullScreen={{\n open: full,\n onOpenChange: (o) => setFullKey(o ? key : null),\n returnFocus: () => host.current?.closest(\"[data-field-key]\")?.querySelector<HTMLElement>('button[aria-label=\"Edit in full screen\"]') ?? null,\n }}\n />\n </div>\n );\n}\n\n/** The body of a drilled table row or column frame (FrameView draws the standard header above it): FrameSlots.TableFrame. */\nexport function TableFrame({ frame }: { frame: Frame }) {\n const form = useForm()!;\n const env = useKitEnv();\n const it = frame.item!;\n const field = frame.field!;\n const tablePath = it.arrayPath.slice(0, -1);\n const raw = form.getAt(tablePath);\n const readOnly = resolveFieldAccess(field, env).readOnly;\n return (\n <TableItemEditor\n kind={frame.kind === \"tableRow\" ? \"row\" : \"column\"}\n index={it.index}\n value={normalizeTable(raw)}\n onChange={(next) => form.setAt(tablePath, storedTable(next, raw))}\n options={field.table ?? GENERAL_TABLE}\n developer={env.can(\"schema.manage\")}\n readOnly={readOnly}\n />\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"table.js","names":[],"sources":["../../../src/controls/table/table.tsx"],"sourcesContent":["/**\n * TABLE control (CPO D42, D50, D52; port of V2 kit/controls/table.tsx): the `table` field type (a content-model `table`\n * field, or a component `table` prop with `config.mode: \"data\"`) edits like any nested array, with no container of its\n * own: Title, Columns, Rows (groups live in the row list), Note under the table, and a collapsed Table settings that\n * offers only what `field.table.settings` allows (no `table` options = a general table, everything offered). A row or a\n * column drills through the form's own navigation (TableFrame), so the breadcrumb and frame header are the ones every\n * FAQ or feature item uses. The ⤢ button in the field's label row (TableFullScreenAction) opens the spreadsheet in the\n * expanded-editor modal (D49).\n *\n * Value: `TableValue` (schema/table.ts), written in the exact shape the backend stores (stored.ts): keys the editor\n * fills in for itself are never written back unless the person changed them.\n */\nimport * as React from \"react\";\nimport { resolveFieldAccess, useForm, useKitEnv } from \"../../context\";\nimport type { Frame } from \"../../lib/frames\";\nimport { pathKey } from \"../../lib/path\";\nimport type { FieldPath } from \"../../schema/types\";\nimport { GENERAL_TABLE, emptyTable, isTableValue, normalizeTable, type TableValue } from \"../../schema/table\";\nimport type { ControlProps } from \"../../types\";\nimport { TableEditor, TableFullScreenButton, TableItemEditor } from \"./table-editor\";\nimport { storedTable } from \"./stored\";\n\n/* Which table field has its spreadsheet open (the label-row button and the control share it). */\nlet fullKey: string | null = null;\nconst subs = new Set<() => void>();\nconst setFullKey = (k: string | null) => {\n fullKey = k;\n subs.forEach((f) => f());\n};\nconst subscribe = (f: () => void) => (subs.add(f), () => void subs.delete(f));\nconst useFullOpen = (k: string) => React.useSyncExternalStore(subscribe, () => fullKey === k, () => false);\nconst fullKeyOf = (docId: string, path: FieldPath) => `${docId}:${pathKey(path)}`;\n\n/** Label-row action of a table field (KitField ACTIONS.table): the one way into the full-screen spreadsheet (D49). */\nexport function TableFullScreenAction({ path }: Pick<ControlProps, \"path\">) {\n const env = useKitEnv();\n return <TableFullScreenButton className=\"-my-1\" onOpen={() => setFullKey(fullKeyOf(env.docId, path))} />;\n}\n\nexport function TableControl({ field, value, onChange, readOnly, path }: ControlProps) {\n const env = useKitEnv();\n const form = useForm();\n const t = React.useMemo(() => (isTableValue(value) ? normalizeTable(value) : null), [value]);\n // no value yet: the field's default table, else an empty 3 × 2 one (nothing is written until the person edits it)\n const fallback = React.useMemo(() => (isTableValue(field.initialValue) ? normalizeTable(field.initialValue) : emptyTable()), [field.initialValue]);\n const key = fullKeyOf(env.docId, path);\n const full = useFullOpen(key);\n // the spreadsheet belongs to this mount: a dock closed with it open must not reopen it on the next visit\n React.useEffect(() => () => void (fullKey === key && setFullKey(null)), [key]);\n const host = React.useRef<HTMLDivElement>(null);\n const nav = React.useMemo(\n () => (form?.canNavigate ? { id: key, basePath: path, open: (kind: \"rows\" | \"columns\", i: number) => form.navigate([...path, kind, i]) } : undefined),\n [form, key, path],\n );\n return (\n <div ref={host} className=\"min-w-0\" data-kit-control=\"table\">\n <TableEditor\n value={t ?? fallback}\n onChange={(next: TableValue) => onChange(storedTable(next, value))}\n readOnly={readOnly}\n options={field.table ?? GENERAL_TABLE}\n developer={env.can(\"schema.manage\")}\n label={field.title}\n parentTitle={env.docTitle}\n nav={nav}\n fullScreen={{\n open: full,\n onOpenChange: (o) => setFullKey(o ? key : null),\n returnFocus: () => host.current?.closest(\"[data-field-key]\")?.querySelector<HTMLElement>('button[aria-label=\"Edit in full screen\"]') ?? null,\n }}\n />\n </div>\n );\n}\n\n/** The body of a drilled table row or column frame (FrameView draws the standard header above it): FrameSlots.TableFrame. */\nexport function TableFrame({ frame }: { frame: Frame }) {\n const form = useForm()!;\n const env = useKitEnv();\n const it = frame.item!;\n const field = frame.field!;\n const tablePath = it.arrayPath.slice(0, -1);\n const raw = form.getAt(tablePath);\n const readOnly = resolveFieldAccess(field, env).readOnly;\n return (\n <TableItemEditor\n kind={frame.kind === \"tableRow\" ? \"row\" : \"column\"}\n index={it.index}\n value={normalizeTable(raw)}\n onChange={(next) => form.setAt(tablePath, storedTable(next, raw))}\n options={field.table ?? GENERAL_TABLE}\n developer={env.can(\"schema.manage\")}\n readOnly={readOnly}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuBA,IAAI,UAAyB;AAC7B,IAAM,uBAAO,IAAI,IAAgB;AACjC,IAAM,cAAc,MAAqB;CACvC,UAAU;CACV,KAAK,SAAS,MAAM,EAAE,CAAC;AACzB;AACA,IAAM,aAAa,OAAmB,KAAK,IAAI,CAAC,SAAS,KAAK,KAAK,OAAO,CAAC;AAC3E,IAAM,eAAe,MAAc,MAAM,qBAAqB,iBAAiB,YAAY,SAAS,KAAK;AACzG,IAAM,aAAa,OAAe,SAAoB,GAAG,MAAM,GAAG,QAAQ,IAAI;;AAG9E,SAAgB,sBAAsB,EAAE,QAAoC;CAC1E,MAAM,MAAM,UAAU;CACtB,OAAO,uBAAC,uBAAD;EAAuB,WAAU;EAAQ,cAAc,WAAW,UAAU,IAAI,OAAO,IAAI,CAAC;CAAI,GAAA,KAAA,GAAA,OAAA;;;;;AACzG;AAEA,SAAgB,aAAa,EAAE,OAAO,OAAO,UAAU,UAAU,QAAsB;CACrF,MAAM,MAAM,UAAU;CACtB,MAAM,OAAO,QAAQ;CACrB,MAAM,IAAI,MAAM,cAAe,aAAa,KAAK,IAAI,eAAe,KAAK,IAAI,MAAO,CAAC,KAAK,CAAC;CAE3F,MAAM,WAAW,MAAM,cAAe,aAAa,MAAM,YAAY,IAAI,eAAe,MAAM,YAAY,IAAI,WAAW,GAAI,CAAC,MAAM,YAAY,CAAC;CACjJ,MAAM,MAAM,UAAU,IAAI,OAAO,IAAI;CACrC,MAAM,OAAO,YAAY,GAAG;CAE5B,MA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