@bettercms-ai/kit 3.0.2 → 3.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.
- package/dist/adapters/lossy.d.ts +1 -1
- package/dist/adapters/lossy.js +3 -2
- package/dist/adapters/lossy.js.map +1 -1
- package/dist/adapters/schema.js +5 -5
- package/dist/adapters/schema.js.map +1 -1
- package/dist/brand/logo.js +18 -67
- package/dist/brand/logo.js.map +1 -1
- package/dist/context.js +3 -8
- package/dist/context.js.map +1 -1
- package/dist/controls/button.js +134 -451
- package/dist/controls/button.js.map +1 -1
- package/dist/controls/choice.js +95 -336
- package/dist/controls/choice.js.map +1 -1
- package/dist/controls/code.js +72 -245
- package/dist/controls/code.js.map +1 -1
- package/dist/controls/color.js +31 -108
- package/dist/controls/color.js.map +1 -1
- package/dist/controls/date.js +83 -268
- package/dist/controls/date.js.map +1 -1
- package/dist/controls/form-picker.js +9 -26
- package/dist/controls/form-picker.js.map +1 -1
- package/dist/controls/icon.js +100 -341
- package/dist/controls/icon.js.map +1 -1
- package/dist/controls/json.js +7 -20
- package/dist/controls/json.js.map +1 -1
- package/dist/controls/link.js +156 -561
- package/dist/controls/link.js.map +1 -1
- package/dist/controls/location.js +35 -124
- package/dist/controls/location.js.map +1 -1
- package/dist/controls/media.js +267 -928
- package/dist/controls/media.js.map +1 -1
- package/dist/controls/number.js +23 -80
- package/dist/controls/number.js.map +1 -1
- package/dist/controls/reference.js +155 -516
- package/dist/controls/reference.js.map +1 -1
- package/dist/controls/rich-text/article-shell.js +86 -327
- package/dist/controls/rich-text/article-shell.js.map +1 -1
- package/dist/controls/rich-text/author.js +21 -78
- package/dist/controls/rich-text/author.js.map +1 -1
- package/dist/controls/rich-text/blocks.js +317 -1086
- package/dist/controls/rich-text/blocks.js.map +1 -1
- package/dist/controls/rich-text/button.js +10 -31
- package/dist/controls/rich-text/button.js.map +1 -1
- package/dist/controls/rich-text/catalog.js +51 -168
- package/dist/controls/rich-text/catalog.js.map +1 -1
- package/dist/controls/rich-text/columns.js +31 -104
- package/dist/controls/rich-text/columns.js.map +1 -1
- package/dist/controls/rich-text/component-card.js +209 -790
- package/dist/controls/rich-text/component-card.js.map +1 -1
- package/dist/controls/rich-text/component-panel.js +40 -102
- package/dist/controls/rich-text/component-panel.js.map +1 -1
- package/dist/controls/rich-text/control.js +32 -101
- package/dist/controls/rich-text/control.js.map +1 -1
- package/dist/controls/rich-text/editor.js +108 -369
- package/dist/controls/rich-text/editor.js.map +1 -1
- package/dist/controls/rich-text/embed.js +51 -184
- package/dist/controls/rich-text/embed.js.map +1 -1
- package/dist/controls/rich-text/floating.js +42 -171
- package/dist/controls/rich-text/floating.js.map +1 -1
- package/dist/controls/rich-text/footnote.js +28 -89
- package/dist/controls/rich-text/footnote.js.map +1 -1
- package/dist/controls/rich-text/gallery.js +27 -88
- package/dist/controls/rich-text/gallery.js.map +1 -1
- package/dist/controls/rich-text/link-form.d.ts +10 -0
- package/dist/controls/rich-text/link-form.js +16 -204
- package/dist/controls/rich-text/link-form.js.map +1 -1
- package/dist/controls/rich-text/plain.js +3 -8
- package/dist/controls/rich-text/plain.js.map +1 -1
- package/dist/controls/rich-text/related.js +25 -86
- package/dist/controls/rich-text/related.js.map +1 -1
- package/dist/controls/rich-text/toc.js +15 -48
- package/dist/controls/rich-text/toc.js.map +1 -1
- package/dist/controls/rich-text/toolbar.js +105 -402
- package/dist/controls/rich-text/toolbar.js.map +1 -1
- package/dist/controls/scale.js +52 -169
- package/dist/controls/scale.js.map +1 -1
- package/dist/controls/slot.js +73 -238
- package/dist/controls/slot.js.map +1 -1
- package/dist/controls/table/table-editor.js +500 -1766
- package/dist/controls/table/table-editor.js.map +1 -1
- package/dist/controls/table/table-link.js +41 -121
- package/dist/controls/table/table-link.js.map +1 -1
- package/dist/controls/table/table.js +9 -26
- package/dist/controls/table/table.js.map +1 -1
- package/dist/controls/text.js +68 -221
- package/dist/controls/text.js.map +1 -1
- package/dist/controls/unknown-value.js +22 -79
- package/dist/controls/unknown-value.js.map +1 -1
- package/dist/engine/array.js +228 -821
- package/dist/engine/array.js.map +1 -1
- package/dist/engine/bits.js +13 -38
- package/dist/engine/bits.js.map +1 -1
- package/dist/engine/breadcrumb.js +8 -25
- package/dist/engine/breadcrumb.js.map +1 -1
- package/dist/engine/expand.js +13 -38
- package/dist/engine/expand.js.map +1 -1
- package/dist/engine/field-list.js +5 -14
- package/dist/engine/field-list.js.map +1 -1
- package/dist/engine/field-shell.js +244 -849
- package/dist/engine/field-shell.js.map +1 -1
- package/dist/engine/frame.js +78 -275
- package/dist/engine/frame.js.map +1 -1
- package/dist/engine/grouping.js +193 -630
- package/dist/engine/grouping.js.map +1 -1
- package/dist/engine/item-list.js +50 -187
- package/dist/engine/item-list.js.map +1 -1
- package/dist/engine/kit-field.js +95 -320
- package/dist/engine/kit-field.js.map +1 -1
- package/dist/engine/schema-form.js +32 -101
- package/dist/engine/schema-form.js.map +1 -1
- package/dist/engine/slot.js +45 -146
- package/dist/engine/slot.js.map +1 -1
- package/dist/lib/icons.js +5 -14
- package/dist/lib/icons.js.map +1 -1
- package/dist/library/kit-catalog.json +2 -1
- package/dist/styles.css +1 -5821
- package/dist/table/table-view.js +16 -49
- package/dist/table/table-view.js.map +1 -1
- package/dist/testing/test-form.js +5 -14
- package/dist/testing/test-form.js.map +1 -1
- package/dist/theme.js +3 -8
- package/dist/theme.js.map +1 -1
- package/dist/ui/action-tray.js +24 -97
- package/dist/ui/action-tray.js.map +1 -1
- package/dist/ui/autocomplete.js +38 -135
- package/dist/ui/autocomplete.js.map +1 -1
- package/dist/ui/button.js +31 -108
- package/dist/ui/button.js.map +1 -1
- package/dist/ui/choice-switch.js +5 -14
- package/dist/ui/choice-switch.js.map +1 -1
- package/dist/ui/controls.js +86 -279
- package/dist/ui/controls.js.map +1 -1
- package/dist/ui/display.js +116 -401
- package/dist/ui/display.js.map +1 -1
- package/dist/ui/expanded-editor-modal.js +27 -100
- package/dist/ui/expanded-editor-modal.js.map +1 -1
- package/dist/ui/floating-panel.js +37 -130
- package/dist/ui/floating-panel.js.map +1 -1
- package/dist/ui/input.js +59 -196
- package/dist/ui/input.js.map +1 -1
- package/dist/ui/mode-bar.js +11 -32
- package/dist/ui/mode-bar.js.map +1 -1
- package/dist/ui/overlay.js +176 -613
- package/dist/ui/overlay.js.map +1 -1
- package/dist/ui/path-crumbs.js +113 -374
- package/dist/ui/path-crumbs.js.map +1 -1
- package/dist/ui/select.js +78 -311
- package/dist/ui/select.js.map +1 -1
- package/dist/ui/shortcut-hint.js +6 -19
- package/dist/ui/shortcut-hint.js.map +1 -1
- package/dist/ui/spinner.js +7 -20
- package/dist/ui/spinner.js.map +1 -1
- package/dist/ui/split-button.js +10 -35
- package/dist/ui/split-button.js.map +1 -1
- package/dist/ui/tab.js +17 -50
- package/dist/ui/tab.js.map +1 -1
- package/dist/ui/toast.js +30 -107
- package/dist/ui/toast.js.map +1 -1
- package/dist/ui/tooltip-root.js +7 -24
- package/dist/ui/tooltip-root.js.map +1 -1
- package/package.json +1 -1
package/dist/table/table-view.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { cellText, normalizeTable, renderTableHtml, tableJsonLd } from "../schema/table.js";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
import "./table.css";
|
|
5
5
|
//#region src/table/table-view.tsx
|
|
6
6
|
/**
|
|
@@ -9,7 +9,6 @@ import "./table.css";
|
|
|
9
9
|
* sort buttons in sortable headers (aria-sort) and a filter box (live row count for screen readers). JSON-LD, when the
|
|
10
10
|
* editor opted in, is written next to the table.
|
|
11
11
|
*/
|
|
12
|
-
var _jsxFileName = "D:/Github/bettercms/bettercms-backend/packages/kit/src/table/table-view.tsx";
|
|
13
12
|
function TableView({ value, resolveRef, interactive = true, jsonLd = true, url, className, idScope }) {
|
|
14
13
|
const uid = React.useId().replace(/[^\w-]/g, "");
|
|
15
14
|
const scope = (idScope ?? uid).replace(/[^\w-]/g, "");
|
|
@@ -77,15 +76,15 @@ function TableView({ value, resolveRef, interactive = true, jsonLd = true, url,
|
|
|
77
76
|
host.current?.querySelector(`button.bt-sort[data-sort-key="${CSS.escape(key)}"]`)?.focus({ preventScroll: true });
|
|
78
77
|
});
|
|
79
78
|
const shown = visible ? visible.size : t.rows.length;
|
|
80
|
-
return /* @__PURE__ */
|
|
79
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
81
80
|
ref: host,
|
|
82
81
|
className,
|
|
83
82
|
onClick: interactive ? onClick : void 0,
|
|
84
83
|
children: [
|
|
85
|
-
interactive && t.filterable ? /* @__PURE__ */
|
|
84
|
+
interactive && t.filterable ? /* @__PURE__ */ jsxs("div", {
|
|
86
85
|
className: "bt-filter",
|
|
87
86
|
children: [
|
|
88
|
-
/* @__PURE__ */
|
|
87
|
+
/* @__PURE__ */ jsxs("label", {
|
|
89
88
|
htmlFor: filterId,
|
|
90
89
|
className: "bt-sr",
|
|
91
90
|
style: {
|
|
@@ -96,24 +95,16 @@ function TableView({ value, resolveRef, interactive = true, jsonLd = true, url,
|
|
|
96
95
|
clip: "rect(0 0 0 0)"
|
|
97
96
|
},
|
|
98
97
|
children: ["Filter ", t.caption || "table"]
|
|
99
|
-
},
|
|
100
|
-
|
|
101
|
-
lineNumber: 65,
|
|
102
|
-
columnNumber: 11
|
|
103
|
-
}, this),
|
|
104
|
-
/* @__PURE__ */ jsxDEV("input", {
|
|
98
|
+
}),
|
|
99
|
+
/* @__PURE__ */ jsx("input", {
|
|
105
100
|
id: filterId,
|
|
106
101
|
type: "search",
|
|
107
102
|
placeholder: "Filter rows…",
|
|
108
103
|
value: query,
|
|
109
104
|
onChange: (e) => setQuery(e.target.value),
|
|
110
105
|
"aria-controls": `${t.id}-caption`
|
|
111
|
-
},
|
|
112
|
-
|
|
113
|
-
lineNumber: 68,
|
|
114
|
-
columnNumber: 11
|
|
115
|
-
}, this),
|
|
116
|
-
/* @__PURE__ */ jsxDEV("span", {
|
|
106
|
+
}),
|
|
107
|
+
/* @__PURE__ */ jsx("span", {
|
|
117
108
|
role: "status",
|
|
118
109
|
"aria-live": "polite",
|
|
119
110
|
style: {
|
|
@@ -124,48 +115,24 @@ function TableView({ value, resolveRef, interactive = true, jsonLd = true, url,
|
|
|
124
115
|
clip: "rect(0 0 0 0)"
|
|
125
116
|
},
|
|
126
117
|
children: query ? `${shown} of ${t.rows.length} rows` : ""
|
|
127
|
-
}
|
|
128
|
-
fileName: _jsxFileName,
|
|
129
|
-
lineNumber: 69,
|
|
130
|
-
columnNumber: 11
|
|
131
|
-
}, this)
|
|
118
|
+
})
|
|
132
119
|
]
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
columnNumber: 9
|
|
137
|
-
}, this) : null,
|
|
138
|
-
/* @__PURE__ */ jsxDEV("div", { dangerouslySetInnerHTML: { __html: html } }, void 0, false, {
|
|
139
|
-
fileName: _jsxFileName,
|
|
140
|
-
lineNumber: 74,
|
|
141
|
-
columnNumber: 7
|
|
142
|
-
}, this),
|
|
143
|
-
interactive && visible && !visible.size ? /* @__PURE__ */ jsxDEV("p", {
|
|
120
|
+
}) : null,
|
|
121
|
+
/* @__PURE__ */ jsx("div", { dangerouslySetInnerHTML: { __html: html } }),
|
|
122
|
+
interactive && visible && !visible.size ? /* @__PURE__ */ jsxs("p", {
|
|
144
123
|
className: "bt-empty-filter",
|
|
145
124
|
children: [
|
|
146
125
|
"No rows match “",
|
|
147
126
|
query,
|
|
148
127
|
"”."
|
|
149
128
|
]
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
lineNumber: 75,
|
|
153
|
-
columnNumber: 50
|
|
154
|
-
}, this) : null,
|
|
155
|
-
ld ? /* @__PURE__ */ jsxDEV("script", {
|
|
129
|
+
}) : null,
|
|
130
|
+
ld ? /* @__PURE__ */ jsx("script", {
|
|
156
131
|
type: "application/ld+json",
|
|
157
132
|
dangerouslySetInnerHTML: { __html: JSON.stringify(ld).replace(/</g, "\\u003c") }
|
|
158
|
-
}
|
|
159
|
-
fileName: _jsxFileName,
|
|
160
|
-
lineNumber: 76,
|
|
161
|
-
columnNumber: 13
|
|
162
|
-
}, this) : null
|
|
133
|
+
}) : null
|
|
163
134
|
]
|
|
164
|
-
}
|
|
165
|
-
fileName: _jsxFileName,
|
|
166
|
-
lineNumber: 62,
|
|
167
|
-
columnNumber: 5
|
|
168
|
-
}, this);
|
|
135
|
+
});
|
|
169
136
|
}
|
|
170
137
|
//#endregion
|
|
171
138
|
export { TableView };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-view.js","names":[],"sources":["../../src/table/table-view.tsx"],"sourcesContent":["/**\n * <TableView> — the live-page face of the ONE table renderer (CPO D42). It renders `renderTableHtml()` (the same\n * semantic HTML stored in rich text and written to published pages) and adds the visitor tools a static page can't:\n * sort buttons in sortable headers (aria-sort) and a filter box (live row count for screen readers). JSON-LD, when the\n * editor opted in, is written next to the table.\n */\nimport * as React from \"react\";\nimport { cellText, normalizeTable, renderTableHtml, tableJsonLd, type RefResolver, type TableValue } from \"../schema/table\";\nimport \"./table.css\";\n\nexport interface TableViewProps {\n value: TableValue | null | undefined;\n resolveRef?: RefResolver;\n /** Visitor tools (sort, filter). Off in thumbnails and editors. Default true. */\n interactive?: boolean;\n /** Write the table's JSON-LD (opt-in on the table). Default true. */\n jsonLd?: boolean;\n url?: string;\n className?: string;\n /** Makes element ids unique when the same table renders twice on one page (block id). Default: a React id. */\n idScope?: string;\n}\n\nexport function TableView({ value, resolveRef, interactive = true, jsonLd = true, url, className, idScope }: TableViewProps) {\n const uid = React.useId().replace(/[^\\w-]/g, \"\");\n const scope = (idScope ?? uid).replace(/[^\\w-]/g, \"\");\n const t = React.useMemo(() => {\n const n = normalizeTable(value);\n return { ...n, id: `${n.id}-${scope}` };\n }, [value, scope]);\n const [sort, setSort] = React.useState<{ key: string; dir: 1 | -1 } | null>(null);\n const [query, setQuery] = React.useState(\"\");\n const filterId = React.useId();\n const visible = React.useMemo(() => {\n const q = query.trim().toLowerCase();\n if (!q) return undefined;\n return new Set(t.rows.filter((r) => t.columns.some((c) => cellText(c, r, r.cells[c._key], resolveRef).toLowerCase().includes(q))).map((r) => r._key));\n }, [query, t, resolveRef]);\n const html = React.useMemo(\n () => renderTableHtml(t, { resolveRef, interactive, sort: interactive ? sort : null, visibleRows: visible, marks: false }),\n [t, resolveRef, interactive, sort, visible],\n );\n const ld = React.useMemo(() => (jsonLd ? tableJsonLd(t, { url, resolveRef }) : null), [jsonLd, t, url, resolveRef]);\n const onClick = (e: React.MouseEvent) => {\n const b = (e.target as HTMLElement).closest<HTMLButtonElement>(\"button.bt-sort\");\n if (!b) return;\n const key = b.dataset.sortKey!;\n e.stopPropagation();\n setSort((s) => (s?.key !== key ? { key, dir: 1 } : s.dir === 1 ? { key, dir: -1 } : null));\n refocus.current = key; // the header HTML is rewritten; keep focus on the same sort button\n };\n const refocus = React.useRef<string | null>(null);\n const host = React.useRef<HTMLDivElement>(null);\n React.useLayoutEffect(() => {\n const key = refocus.current;\n if (!key) return;\n refocus.current = null;\n host.current?.querySelector<HTMLButtonElement>(`button.bt-sort[data-sort-key=\"${CSS.escape(key)}\"]`)?.focus({ preventScroll: true });\n });\n const shown = visible ? visible.size : t.rows.length;\n return (\n <div ref={host} className={className} onClick={interactive ? onClick : undefined}>\n {interactive && t.filterable ? (\n <div className=\"bt-filter\">\n <label htmlFor={filterId} className=\"bt-sr\" style={{ position: \"absolute\", width: 1, height: 1, overflow: \"hidden\", clip: \"rect(0 0 0 0)\" }}>\n Filter {t.caption || \"table\"}\n </label>\n <input id={filterId} type=\"search\" placeholder=\"Filter rows…\" value={query} onChange={(e) => setQuery(e.target.value)} aria-controls={`${t.id}-caption`} />\n <span role=\"status\" aria-live=\"polite\" style={{ position: \"absolute\", width: 1, height: 1, overflow: \"hidden\", clip: \"rect(0 0 0 0)\" }}>\n {query ? `${shown} of ${t.rows.length} rows` : \"\"}\n </span>\n </div>\n ) : null}\n <div dangerouslySetInnerHTML={{ __html: html }} />\n {interactive && visible && !visible.size ? <p className=\"bt-empty-filter\">No rows match “{query}”.</p> : null}\n {ld ? <script type=\"application/ld+json\" dangerouslySetInnerHTML={{ __html: JSON.stringify(ld).replace(/</g, \"\\\\u003c\") }} /> : null}\n </div>\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"table-view.js","names":[],"sources":["../../src/table/table-view.tsx"],"sourcesContent":["/**\n * <TableView> — the live-page face of the ONE table renderer (CPO D42). It renders `renderTableHtml()` (the same\n * semantic HTML stored in rich text and written to published pages) and adds the visitor tools a static page can't:\n * sort buttons in sortable headers (aria-sort) and a filter box (live row count for screen readers). JSON-LD, when the\n * editor opted in, is written next to the table.\n */\nimport * as React from \"react\";\nimport { cellText, normalizeTable, renderTableHtml, tableJsonLd, type RefResolver, type TableValue } from \"../schema/table\";\nimport \"./table.css\";\n\nexport interface TableViewProps {\n value: TableValue | null | undefined;\n resolveRef?: RefResolver;\n /** Visitor tools (sort, filter). Off in thumbnails and editors. Default true. */\n interactive?: boolean;\n /** Write the table's JSON-LD (opt-in on the table). Default true. */\n jsonLd?: boolean;\n url?: string;\n className?: string;\n /** Makes element ids unique when the same table renders twice on one page (block id). Default: a React id. */\n idScope?: string;\n}\n\nexport function TableView({ value, resolveRef, interactive = true, jsonLd = true, url, className, idScope }: TableViewProps) {\n const uid = React.useId().replace(/[^\\w-]/g, \"\");\n const scope = (idScope ?? uid).replace(/[^\\w-]/g, \"\");\n const t = React.useMemo(() => {\n const n = normalizeTable(value);\n return { ...n, id: `${n.id}-${scope}` };\n }, [value, scope]);\n const [sort, setSort] = React.useState<{ key: string; dir: 1 | -1 } | null>(null);\n const [query, setQuery] = React.useState(\"\");\n const filterId = React.useId();\n const visible = React.useMemo(() => {\n const q = query.trim().toLowerCase();\n if (!q) return undefined;\n return new Set(t.rows.filter((r) => t.columns.some((c) => cellText(c, r, r.cells[c._key], resolveRef).toLowerCase().includes(q))).map((r) => r._key));\n }, [query, t, resolveRef]);\n const html = React.useMemo(\n () => renderTableHtml(t, { resolveRef, interactive, sort: interactive ? sort : null, visibleRows: visible, marks: false }),\n [t, resolveRef, interactive, sort, visible],\n );\n const ld = React.useMemo(() => (jsonLd ? tableJsonLd(t, { url, resolveRef }) : null), [jsonLd, t, url, resolveRef]);\n const onClick = (e: React.MouseEvent) => {\n const b = (e.target as HTMLElement).closest<HTMLButtonElement>(\"button.bt-sort\");\n if (!b) return;\n const key = b.dataset.sortKey!;\n e.stopPropagation();\n setSort((s) => (s?.key !== key ? { key, dir: 1 } : s.dir === 1 ? { key, dir: -1 } : null));\n refocus.current = key; // the header HTML is rewritten; keep focus on the same sort button\n };\n const refocus = React.useRef<string | null>(null);\n const host = React.useRef<HTMLDivElement>(null);\n React.useLayoutEffect(() => {\n const key = refocus.current;\n if (!key) return;\n refocus.current = null;\n host.current?.querySelector<HTMLButtonElement>(`button.bt-sort[data-sort-key=\"${CSS.escape(key)}\"]`)?.focus({ preventScroll: true });\n });\n const shown = visible ? visible.size : t.rows.length;\n return (\n <div ref={host} className={className} onClick={interactive ? onClick : undefined}>\n {interactive && t.filterable ? (\n <div className=\"bt-filter\">\n <label htmlFor={filterId} className=\"bt-sr\" style={{ position: \"absolute\", width: 1, height: 1, overflow: \"hidden\", clip: \"rect(0 0 0 0)\" }}>\n Filter {t.caption || \"table\"}\n </label>\n <input id={filterId} type=\"search\" placeholder=\"Filter rows…\" value={query} onChange={(e) => setQuery(e.target.value)} aria-controls={`${t.id}-caption`} />\n <span role=\"status\" aria-live=\"polite\" style={{ position: \"absolute\", width: 1, height: 1, overflow: \"hidden\", clip: \"rect(0 0 0 0)\" }}>\n {query ? `${shown} of ${t.rows.length} rows` : \"\"}\n </span>\n </div>\n ) : null}\n <div dangerouslySetInnerHTML={{ __html: html }} />\n {interactive && visible && !visible.size ? <p className=\"bt-empty-filter\">No rows match “{query}”.</p> : null}\n {ld ? <script type=\"application/ld+json\" danger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,MAAM;MAAgB;MAClI,UAAA,QAAQ,GAAG,MAAM,MAAM,EAAE,KAAK,OAAO,SAAS;KAC3C,CAAA;IACH;GACH,CAAA,IAAA;GACJ,oBAAC,OAAD,EAAK,yBAAyB,EAAE,QAAQ,KAAK,EAAI,CAAA;GAChD,eAAe,WAAW,CAAC,QAAQ,OAAO,qBAAC,KAAD;IAAG,WAAU;IAAb,UAAA;KAA+B;KAAgB;KAAM;IAAK;GAAI,CAAA,IAAA;GACxG,KAAK,oBAAC,UAAD;IAAQ,MAAK;IAAsB,yBAAyB,EAAE,QAAQ,KAAK,UAAU,EAAE,CAAC,CAAC,QAAQ,MAAM,SAAS,EAAE;GAAI,CAAA,IAAI;EAC7H;;AAET"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { SchemaForm } from "../engine/schema-form.js";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
//#region src/testing/test-form.tsx
|
|
5
|
-
var _jsxFileName = "D:/Github/bettercms/bettercms-backend/packages/kit/src/testing/test-form.tsx";
|
|
6
5
|
/** A controlled SchemaForm over `fields`, with the latest value readable from `onValue`. */
|
|
7
6
|
function TestForm({ fields, initial = {}, onValue, ...rest }) {
|
|
8
7
|
const [value, setValue] = React.useState(initial);
|
|
@@ -12,7 +11,7 @@ function TestForm({ fields, initial = {}, onValue, ...rest }) {
|
|
|
12
11
|
kind: "entry",
|
|
13
12
|
fields
|
|
14
13
|
}), [fields]);
|
|
15
|
-
return /* @__PURE__ */
|
|
14
|
+
return /* @__PURE__ */ jsx(SchemaForm, {
|
|
16
15
|
schema,
|
|
17
16
|
value,
|
|
18
17
|
onChange: (v) => {
|
|
@@ -20,26 +19,18 @@ function TestForm({ fields, initial = {}, onValue, ...rest }) {
|
|
|
20
19
|
onValue?.(v);
|
|
21
20
|
},
|
|
22
21
|
...rest
|
|
23
|
-
}
|
|
24
|
-
fileName: _jsxFileName,
|
|
25
|
-
lineNumber: 20,
|
|
26
|
-
columnNumber: 5
|
|
27
|
-
}, this);
|
|
22
|
+
});
|
|
28
23
|
}
|
|
29
24
|
/** A plain input standing in for a real control: it sets an aria-describedby id of its own, which the shell keeps. */
|
|
30
25
|
function TestInput({ id, value, onChange, invalid, readOnly }) {
|
|
31
|
-
return /* @__PURE__ */
|
|
26
|
+
return /* @__PURE__ */ jsx("input", {
|
|
32
27
|
id,
|
|
33
28
|
"aria-describedby": "own-id",
|
|
34
29
|
"aria-invalid": invalid || void 0,
|
|
35
30
|
readOnly,
|
|
36
31
|
value: typeof value === "string" ? value : "",
|
|
37
32
|
onChange: (e) => onChange(e.target.value)
|
|
38
|
-
}
|
|
39
|
-
fileName: _jsxFileName,
|
|
40
|
-
lineNumber: 35,
|
|
41
|
-
columnNumber: 5
|
|
42
|
-
}, this);
|
|
33
|
+
});
|
|
43
34
|
}
|
|
44
35
|
//#endregion
|
|
45
36
|
export { TestForm, TestInput };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-form.js","names":[],"sources":["../../src/testing/test-form.tsx"],"sourcesContent":["import * as React from \"react\";\nimport type { FieldSchema } from \"../schema/types\";\nimport type { ControlProps } from \"../types\";\nimport { SchemaForm, type SchemaFormProps } from \"../engine/schema-form\";\n\n/** A controlled SchemaForm over `fields`, with the latest value readable from `onValue`. */\nexport function TestForm({\n fields,\n initial = {},\n onValue,\n ...rest\n}: Omit<SchemaFormProps, \"schema\" | \"value\" | \"onChange\"> & {\n fields: FieldSchema[];\n initial?: Record<string, unknown>;\n onValue?: (v: Record<string, unknown>) => void;\n}) {\n const [value, setValue] = React.useState(initial);\n const schema = React.useMemo(() => ({ name: \"doc\", title: \"Doc\", kind: \"entry\" as const, fields }), [fields]);\n return (\n <SchemaForm\n schema={schema}\n value={value}\n onChange={(v) => {\n setValue(v);\n onValue?.(v);\n }}\n {...rest}\n />\n );\n}\n\n/** A plain input standing in for a real control: it sets an aria-describedby id of its own, which the shell keeps. */\nexport function TestInput({ id, value, onChange, invalid, readOnly }: ControlProps) {\n return (\n <input\n id={id}\n aria-describedby=\"own-id\"\n aria-invalid={invalid || undefined}\n readOnly={readOnly}\n value={typeof value === \"string\" ? value : \"\"}\n onChange={(e) => onChange(e.target.value)}\n />\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"test-form.js","names":[],"sources":["../../src/testing/test-form.tsx"],"sourcesContent":["import * as React from \"react\";\nimport type { FieldSchema } from \"../schema/types\";\nimport type { ControlProps } from \"../types\";\nimport { SchemaForm, type SchemaFormProps } from \"../engine/schema-form\";\n\n/** A controlled SchemaForm over `fields`, with the latest value readable from `onValue`. */\nexport function TestForm({\n fields,\n initial = {},\n onValue,\n ...rest\n}: Omit<SchemaFormProps, \"schema\" | \"value\" | \"onChange\"> & {\n fields: FieldSchema[];\n initial?: Record<string, unknown>;\n onValue?: (v: Record<string, unknown>) => void;\n}) {\n const [value, setValue] = React.useState(initial);\n const schema = React.useMemo(() => ({ name: \"doc\", title: \"Doc\", kind: \"entry\" as const, fields }), [fields]);\n return (\n <SchemaForm\n schema={schema}\n value={value}\n onChange={(v) => {\n setValue(v);\n onValue?.(v);\n }}\n {...rest}\n />\n );\n}\n\n/** A plain input standing in for a real control: it sets an aria-describedby id of its own, which the shell keeps. */\nexport function TestInput({ id, value, onChange, invalid, readOnly }: ControlProps) {\n return (\n <input\n id={id}\n aria-describedby=\"own-id\"\n aria-invalid={invalid || undefined}\n readOnly={readOnly}\n value={typeof value === \"string\" ? value : \"\"}\n onChange={(e) => onChange(e.target.value)}\n />\n );\n}\n"],"mappings":";;;;;AAMA,SAAgB,SAAS,EACvB,QACA,UAAU,CAAC,GACX,SACA,GAAG,QAKF;CACD,MAAM,CAAC,OAAO,YAAY,MAAM,SAAS,OAAO;CAChD,MAAM,SAAS,MAAM,eAAe;EAAE,MAAM;EAAO,OAAO;EAAO,MAAM;EAAkB;CAAO,IAAI,CAAC,MAAM,CAAC;CAC5G,OACE,oBAAC,YAAD;EACU;EACD;EACP,WAAW,MAAM;GACf,SAAS,CAAC;GACV,UAAU,CAAC;EACb;EACA,GAAI;CACL,CAAA;AAEL;;AAGA,SAAgB,UAAU,EAAE,IAAI,OAAO,UAAU,SAAS,YAA0B;CAClF,OACE,oBAAC,SAAD;EACM;EACJ,oBAAiB;EACjB,gBAAc,WAAW,KAAA;EACf;EACV,OAAO,OAAO,UAAU,WAAW,QAAQ;EAC3C,WAAW,MAAM,SAAS,EAAE,OAAO,KAAK;CACzC,CAAA;AAEL"}
|
package/dist/theme.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { KIT_SCOPE } from "./ui/surfaces.js";
|
|
2
2
|
import { useLayoutEffect } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
//#region src/theme.tsx
|
|
5
5
|
/**
|
|
6
6
|
* `@bettercms-ai/kit/theme`: the light/dark scheme for a kit surface outside the dashboard (a custom dock input's
|
|
@@ -10,7 +10,6 @@ import { jsxDEV } from "react/jsx-dev-runtime";
|
|
|
10
10
|
* inside a light document would render its layers light. A scheme is therefore applied to the document element, never
|
|
11
11
|
* to the island. The mismatch warning and the rest of the KitRoot contract are spec'd in kit-ports-spec.md §5.
|
|
12
12
|
*/
|
|
13
|
-
var _jsxFileName = "D:/Github/bettercms/bettercms-backend/packages/kit/src/theme.tsx";
|
|
14
13
|
/** Puts `scheme` on `root`: `.dark` on or off, and the native color-scheme. */
|
|
15
14
|
function applyScheme(root, scheme) {
|
|
16
15
|
root.classList.toggle("dark", scheme === "dark");
|
|
@@ -32,15 +31,11 @@ function KitRoot({ children, scheme = "inherit", surface = "surface", className
|
|
|
32
31
|
applyScheme(root, scheme);
|
|
33
32
|
}, [scheme]);
|
|
34
33
|
const cls = [surface === "surface" ? "bg-kit-surface text-kit-fg" : null, className].filter(Boolean).join(" ");
|
|
35
|
-
return /* @__PURE__ */
|
|
34
|
+
return /* @__PURE__ */ jsx("div", {
|
|
36
35
|
...KIT_SCOPE,
|
|
37
36
|
className: cls || void 0,
|
|
38
37
|
children
|
|
39
|
-
}
|
|
40
|
-
fileName: _jsxFileName,
|
|
41
|
-
lineNumber: 55,
|
|
42
|
-
columnNumber: 5
|
|
43
|
-
}, this);
|
|
38
|
+
});
|
|
44
39
|
}
|
|
45
40
|
//#endregion
|
|
46
41
|
export { KitRoot, applyScheme };
|
package/dist/theme.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.js","names":[],"sources":["../src/theme.tsx"],"sourcesContent":["/**\n * `@bettercms-ai/kit/theme`: the light/dark scheme for a kit surface outside the dashboard (a custom dock input's\n * iframe, a standalone page). Dark is `.dark` on an ancestor (tokens.css `.dark`), kit islands are `data-kit-scope`.\n *\n * The scheme belongs to the document: portalled layers (popovers, tooltips, toasts) mount on <body>, so a dark island\n * inside a light document would render its layers light. A scheme is therefore applied to the document element, never\n * to the island. The mismatch warning and the rest of the KitRoot contract are spec'd in kit-ports-spec.md §5.\n */\nimport { useLayoutEffect, type ReactNode } from \"react\";\nimport { KIT_SCOPE } from \"./ui/surfaces\";\n\nexport type KitScheme = \"light\" | \"dark\";\n\n/** Puts `scheme` on `root`: `.dark` on or off, and the native color-scheme. */\nexport function applyScheme(root: HTMLElement, scheme: KitScheme): void {\n root.classList.toggle(\"dark\", scheme === \"dark\");\n root.style.colorScheme = scheme;\n}\n\nexport interface KitRootProps {\n children?: ReactNode;\n /** \"inherit\" (default) keeps the document's scheme; light / dark applies it to the document element */\n scheme?: KitScheme | \"inherit\";\n /** \"surface\" paints bg-kit-surface (the default); \"transparent\" lets a host-provided surface show through */\n surface?: \"surface\" | \"transparent\";\n className?: string;\n}\n\n/** The scheme the document already declares (`.dark`, or an inline color-scheme from applyScheme); null = none yet. */\nfunction declaredScheme(root: HTMLElement): KitScheme | null {\n if (root.classList.contains(\"dark\")) return \"dark\";\n return root.style.colorScheme === \"light\" || root.style.colorScheme === \"dark\" ? root.style.colorScheme : null;\n}\n\n// The kit ships unbundled; a consumer's bundler replaces process.env.NODE_ENV, a no-bundler page has no `process`.\nconst isProduction = () => (globalThis as { process?: { env?: { NODE_ENV?: string } } }).process?.env?.NODE_ENV === \"production\";\n\n/** A kit island: `data-kit-scope` (the kit's base element defaults) on the kit surface, in the document's scheme. */\nexport function KitRoot({ children, scheme = \"inherit\", surface = \"surface\", className }: KitRootProps) {\n useLayoutEffect(() => {\n if (scheme === \"inherit\") return;\n const root = document.documentElement;\n const current = declaredScheme(root);\n // kit-ports-spec.md §5: a scoped scheme that differs from the document's is forbidden (portalled layers follow the\n // document). Say so in development; the document still takes `scheme`, as before.\n if (current && current !== scheme && !isProduction()) {\n console.warn(\n `KitRoot scheme=\"${scheme}\" differs from the document (${current}). Portalled menus, tooltips and toasts follow the document, not KitRoot. Call applyScheme(document.documentElement, \"${scheme}\") from the host instead.`,\n );\n }\n applyScheme(root, scheme);\n }, [scheme]);\n const cls = [surface === \"surface\" ? \"bg-kit-surface text-kit-fg\" : null, className].filter(Boolean).join(\" \");\n return (\n <div {...KIT_SCOPE} className={cls || undefined}>\n {children}\n </div>\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"theme.js","names":[],"sources":["../src/theme.tsx"],"sourcesContent":["/**\n * `@bettercms-ai/kit/theme`: the light/dark scheme for a kit surface outside the dashboard (a custom dock input's\n * iframe, a standalone page). Dark is `.dark` on an ancestor (tokens.css `.dark`), kit islands are `data-kit-scope`.\n *\n * The scheme belongs to the document: portalled layers (popovers, tooltips, toasts) mount on <body>, so a dark island\n * inside a light document would render its layers light. A scheme is therefore applied to the document element, never\n * to the island. The mismatch warning and the rest of the KitRoot contract are spec'd in kit-ports-spec.md §5.\n */\nimport { useLayoutEffect, type ReactNode } from \"react\";\nimport { KIT_SCOPE } from \"./ui/surfaces\";\n\nexport type KitScheme = \"light\" | \"dark\";\n\n/** Puts `scheme` on `root`: `.dark` on or off, and the native color-scheme. */\nexport function applyScheme(root: HTMLElement, scheme: KitScheme): void {\n root.classList.toggle(\"dark\", scheme === \"dark\");\n root.style.colorScheme = scheme;\n}\n\nexport interface KitRootProps {\n children?: ReactNode;\n /** \"inherit\" (default) keeps the document's scheme; light / dark applies it to the document element */\n scheme?: KitScheme | \"inherit\";\n /** \"surface\" paints bg-kit-surface (the default); \"transparent\" lets a host-provided surface show through */\n surface?: \"surface\" | \"transparent\";\n className?: string;\n}\n\n/** The scheme the document already declares (`.dark`, or an inline color-scheme from applyScheme); null = none yet. */\nfunction declaredScheme(root: HTMLElement): KitScheme | null {\n if (root.classList.contains(\"dark\")) return \"dark\";\n return root.style.colorScheme === \"light\" || root.style.colorScheme === \"dark\" ? root.style.colorScheme : null;\n}\n\n// The kit ships unbundled; a consumer's bundler replaces process.env.NODE_ENV, a no-bundler page has no `process`.\nconst isProduction = () => (globalThis as { process?: { env?: { NODE_ENV?: string } } }).process?.env?.NODE_ENV === \"production\";\n\n/** A kit island: `data-kit-scope` (the kit's base element defaults) on the kit surface, in the document's scheme. */\nexport function KitRoot({ children, scheme = \"inherit\", surface = \"surface\", className }: KitRootProps) {\n useLayoutEffect(() => {\n if (scheme === \"inherit\") return;\n const root = document.documentElement;\n const current = declaredScheme(root);\n // kit-ports-spec.md §5: a scoped scheme that differs from the document's is forbidden (portalled layers follow the\n // document). Say so in development; the document still takes `scheme`, as before.\n if (current && current !== scheme && !isProduction()) {\n console.warn(\n `KitRoot scheme=\"${scheme}\" differs from the document (${current}). Portalled menus, tooltips and toasts follow the document, not KitRoot. Call applyScheme(document.documentElement, \"${scheme}\") from the host instead.`,\n );\n }\n applyScheme(root, scheme);\n }, [scheme]);\n const cls = [surface === \"surface\" ? \"bg-kit-surface text-kit-fg\" : null, className].filter(Boolean).join(\" \");\n return (\n <div {...KIT_SCOPE} className={cls || undefined}>\n {children}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAcA,SAAgB,YAAY,MAAmB,QAAyB;CACtE,KAAK,UAAU,OAAO,QAAQ,WAAW,MAAM;CAC/C,KAAK,MAAM,cAAc;AAC3B;;AAYA,SAAS,eAAe,MAAqC;CAC3D,IAAI,KAAK,UAAU,SAAS,MAAM,GAAG,OAAO;CAC5C,OAAO,KAAK,MAAM,gBAAgB,WAAW,KAAK,MAAM,gBAAgB,SAAS,KAAK,MAAM,cAAc;AAC5G;AAGA,IAAM,qBAAsB,WAA6D,SAAS,KAAK,aAAa;;AAGpH,SAAgB,QAAQ,EAAE,UAAU,SAAS,WAAW,UAAU,WAAW,aAA2B;CACtG,sBAAsB;EACpB,IAAI,WAAW,WAAW;EAC1B,MAAM,OAAO,SAAS;EACtB,MAAM,UAAU,eAAe,IAAI;EAGnC,IAAI,WAAW,YAAY,UAAU,CAAC,aAAa,GACjD,QAAQ,KACN,mBAAmB,OAAO,+BAA+B,QAAQ,wHAAwH,OAAO,0BAClM;EAEF,YAAY,MAAM,MAAM;CAC1B,GAAG,CAAC,MAAM,CAAC;CACX,MAAM,MAAM,CAAC,YAAY,YAAY,+BAA+B,MAAM,SAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;CAC7G,OACE,oBAAC,OAAD;EAAK,GAAI;EAAW,WAAW,OAAO,KAAA;EACnC;CACE,CAAA;AAET"}
|
package/dist/ui/action-tray.js
CHANGED
|
@@ -4,7 +4,7 @@ import { Menu, MenuContent, MenuTrigger } from "./overlay.js";
|
|
|
4
4
|
import { relTime } from "../lib/utils.js";
|
|
5
5
|
import { Avatar, AvatarStack } from "./display.js";
|
|
6
6
|
import * as React from "react";
|
|
7
|
-
import { Fragment,
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import { IconDots } from "@tabler/icons-react";
|
|
9
9
|
//#region src/ui/action-tray.tsx
|
|
10
10
|
/**
|
|
@@ -19,7 +19,6 @@ import { IconDots } from "@tabler/icons-react";
|
|
|
19
19
|
*
|
|
20
20
|
* Use for sticky bottom ACTION bars only, never on cards or content areas.
|
|
21
21
|
*/
|
|
22
|
-
var _jsxFileName = "D:/Github/bettercms/bettercms-backend/packages/kit/src/ui/action-tray.tsx";
|
|
23
22
|
var clearing = /* @__PURE__ */ new Set();
|
|
24
23
|
function syncToastOffset() {
|
|
25
24
|
if (typeof document === "undefined") return;
|
|
@@ -53,31 +52,19 @@ var actionTrayClass = "shrink-0 border-t border-kit-tray-line bg-tray";
|
|
|
53
52
|
function ActionTray({ meta, children, className, as: Tag = "div", clearToasts = false, ...props }) {
|
|
54
53
|
const ref = React.useRef(null);
|
|
55
54
|
useToastClearance(ref, clearToasts);
|
|
56
|
-
return /* @__PURE__ */
|
|
55
|
+
return /* @__PURE__ */ jsxs(Tag, {
|
|
57
56
|
ref,
|
|
58
57
|
"data-action-tray": "",
|
|
59
58
|
className: cn(actionTrayClass, "@container/tray flex min-h-[45px] items-center justify-between gap-2 px-3 py-1.5", className),
|
|
60
59
|
...props,
|
|
61
|
-
children: [/* @__PURE__ */
|
|
60
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
62
61
|
className: "flex min-w-0 flex-1 items-center gap-2",
|
|
63
62
|
children: meta
|
|
64
|
-
},
|
|
65
|
-
fileName: _jsxFileName,
|
|
66
|
-
lineNumber: 81,
|
|
67
|
-
columnNumber: 7
|
|
68
|
-
}, this), children ? /* @__PURE__ */ jsxDEV("div", {
|
|
63
|
+
}), children ? /* @__PURE__ */ jsx("div", {
|
|
69
64
|
className: "flex shrink-0 items-center gap-[5px]",
|
|
70
65
|
children
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
lineNumber: 82,
|
|
74
|
-
columnNumber: 19
|
|
75
|
-
}, this) : null]
|
|
76
|
-
}, void 0, true, {
|
|
77
|
-
fileName: _jsxFileName,
|
|
78
|
-
lineNumber: 75,
|
|
79
|
-
columnNumber: 5
|
|
80
|
-
}, this);
|
|
66
|
+
}) : null]
|
|
67
|
+
});
|
|
81
68
|
}
|
|
82
69
|
var fullStamp = (at) => new Date(at).toLocaleString("en-US", {
|
|
83
70
|
weekday: "short",
|
|
@@ -93,116 +80,56 @@ var fullStamp = (at) => new Date(at).toLocaleString("en-US", {
|
|
|
93
80
|
*/
|
|
94
81
|
function TrayMeta({ name, avatarName, src, people, at, verb = "Edited", note, onClick, actionHint = "Open history" }) {
|
|
95
82
|
const when = note ?? (at ? `${verb} ${relTime(at).replace("just now", "a moment ago")}` : verb);
|
|
96
|
-
const inner = /* @__PURE__ */
|
|
83
|
+
const inner = /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("span", {
|
|
97
84
|
className: "flex shrink-0 items-center gap-1",
|
|
98
|
-
children: [people && people.length > 1 ? /* @__PURE__ */
|
|
85
|
+
children: [people && people.length > 1 ? /* @__PURE__ */ jsx(AvatarStack, {
|
|
99
86
|
people,
|
|
100
87
|
size: 20,
|
|
101
88
|
max: 3
|
|
102
|
-
}
|
|
103
|
-
fileName: _jsxFileName,
|
|
104
|
-
lineNumber: 125,
|
|
105
|
-
columnNumber: 11
|
|
106
|
-
}, this) : /* @__PURE__ */ jsxDEV(Avatar, {
|
|
89
|
+
}) : /* @__PURE__ */ jsx(Avatar, {
|
|
107
90
|
name: avatarName ?? name,
|
|
108
91
|
src,
|
|
109
92
|
size: 20,
|
|
110
93
|
decorative: true
|
|
111
|
-
},
|
|
112
|
-
fileName: _jsxFileName,
|
|
113
|
-
lineNumber: 127,
|
|
114
|
-
columnNumber: 11
|
|
115
|
-
}, this), /* @__PURE__ */ jsxDEV("span", {
|
|
94
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
116
95
|
className: "hidden whitespace-nowrap text-kit-sm font-medium text-kit-fg @[34rem]/tray:inline",
|
|
117
96
|
children: name
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
lineNumber: 130,
|
|
121
|
-
columnNumber: 9
|
|
122
|
-
}, this)]
|
|
123
|
-
}, void 0, true, {
|
|
124
|
-
fileName: _jsxFileName,
|
|
125
|
-
lineNumber: 123,
|
|
126
|
-
columnNumber: 7
|
|
127
|
-
}, this), /* @__PURE__ */ jsxDEV("span", {
|
|
97
|
+
})]
|
|
98
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
128
99
|
className: "hidden min-w-0 truncate text-kit-sm text-kit-fg-3 @[34rem]/tray:inline",
|
|
129
100
|
children: when
|
|
130
|
-
}
|
|
131
|
-
fileName: _jsxFileName,
|
|
132
|
-
lineNumber: 132,
|
|
133
|
-
columnNumber: 7
|
|
134
|
-
}, this)] }, void 0, true, {
|
|
135
|
-
fileName: _jsxFileName,
|
|
136
|
-
lineNumber: 122,
|
|
137
|
-
columnNumber: 5
|
|
138
|
-
}, this);
|
|
101
|
+
})] });
|
|
139
102
|
const tip = at ? `${name} · ${verb} ${fullStamp(at)}${onClick ? ` · ${actionHint}` : ""}` : onClick ? `${name} · ${when} · ${actionHint}` : `${name} · ${when}`;
|
|
140
|
-
const body = onClick ? /* @__PURE__ */
|
|
103
|
+
const body = onClick ? /* @__PURE__ */ jsx("button", {
|
|
141
104
|
type: "button",
|
|
142
105
|
onClick,
|
|
143
106
|
"aria-label": `${name}, ${when}. ${actionHint}`,
|
|
144
107
|
className: "-mx-1 flex min-w-0 items-center gap-2 rounded-kit-md px-1 py-0.5 transition-colors hover:bg-kit-hover",
|
|
145
108
|
children: inner
|
|
146
|
-
}
|
|
147
|
-
fileName: _jsxFileName,
|
|
148
|
-
lineNumber: 141,
|
|
149
|
-
columnNumber: 5
|
|
150
|
-
}, this) : /* @__PURE__ */ jsxDEV("span", {
|
|
109
|
+
}) : /* @__PURE__ */ jsxs("span", {
|
|
151
110
|
className: "flex min-w-0 items-center gap-2",
|
|
152
|
-
children: [inner, /* @__PURE__ */
|
|
111
|
+
children: [inner, /* @__PURE__ */ jsx("span", {
|
|
153
112
|
className: "sr-only @[34rem]/tray:hidden",
|
|
154
113
|
children: `${name}, ${when}`
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
columnNumber: 7
|
|
159
|
-
}, this)]
|
|
160
|
-
}, void 0, true, {
|
|
161
|
-
fileName: _jsxFileName,
|
|
162
|
-
lineNumber: 150,
|
|
163
|
-
columnNumber: 5
|
|
164
|
-
}, this);
|
|
165
|
-
return /* @__PURE__ */ jsxDEV(HintTooltip, {
|
|
114
|
+
})]
|
|
115
|
+
});
|
|
116
|
+
return /* @__PURE__ */ jsx(HintTooltip, {
|
|
166
117
|
content: tip,
|
|
167
118
|
children: body
|
|
168
|
-
}
|
|
169
|
-
fileName: _jsxFileName,
|
|
170
|
-
lineNumber: 156,
|
|
171
|
-
columnNumber: 10
|
|
172
|
-
}, this);
|
|
119
|
+
});
|
|
173
120
|
}
|
|
174
121
|
/** The tray's "⋯" (32×32 ghost, Figma "Button - Modal actions") opening a menu above the bar. Children are menu items. */
|
|
175
122
|
function TrayMore({ label = "More options", children, menuClassName }) {
|
|
176
|
-
return /* @__PURE__ */
|
|
123
|
+
return /* @__PURE__ */ jsxs(Menu, { children: [/* @__PURE__ */ jsx(MenuTrigger, { render: /* @__PURE__ */ jsx(IconButton, {
|
|
177
124
|
label,
|
|
178
125
|
size: "md",
|
|
179
|
-
children: /* @__PURE__ */
|
|
180
|
-
|
|
181
|
-
lineNumber: 175,
|
|
182
|
-
columnNumber: 13
|
|
183
|
-
}, this)
|
|
184
|
-
}, void 0, false, {
|
|
185
|
-
fileName: _jsxFileName,
|
|
186
|
-
lineNumber: 174,
|
|
187
|
-
columnNumber: 11
|
|
188
|
-
}, this) }, void 0, false, {
|
|
189
|
-
fileName: _jsxFileName,
|
|
190
|
-
lineNumber: 172,
|
|
191
|
-
columnNumber: 7
|
|
192
|
-
}, this), /* @__PURE__ */ jsxDEV(MenuContent, {
|
|
126
|
+
children: /* @__PURE__ */ jsx(IconDots, { "aria-hidden": true })
|
|
127
|
+
}) }), /* @__PURE__ */ jsx(MenuContent, {
|
|
193
128
|
side: "top",
|
|
194
129
|
align: "end",
|
|
195
130
|
className: cn("w-60", menuClassName),
|
|
196
131
|
children
|
|
197
|
-
}
|
|
198
|
-
fileName: _jsxFileName,
|
|
199
|
-
lineNumber: 179,
|
|
200
|
-
columnNumber: 7
|
|
201
|
-
}, this)] }, void 0, true, {
|
|
202
|
-
fileName: _jsxFileName,
|
|
203
|
-
lineNumber: 171,
|
|
204
|
-
columnNumber: 5
|
|
205
|
-
}, this);
|
|
132
|
+
})] });
|
|
206
133
|
}
|
|
207
134
|
//#endregion
|
|
208
135
|
export { ActionTray, TrayMeta, TrayMore, actionTrayClass };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-tray.js","names":[],"sources":["../../src/ui/action-tray.tsx"],"sourcesContent":["/**\n * ACTION TRAY: Figma 61014:66265 \"Bottom\". The soft, slightly raised bar at the bottom of editors, inspectors,\n * sheets and dialogs: surface → light grey gradient, 1px top hairline, 12px side padding, 6px vertical, 44px tall +\n * hairline (a 32px button fits exactly). No blur (D21).\n *\n * <ActionTray meta={<TrayMeta name=\"Priya Nair\" at={iso} onClick={openHistory} />}>\n * <Button variant=\"primary\" leftIcon={<IconUpload />}>Publish</Button>\n * <TrayMore>…menu items…</TrayMore>\n * </ActionTray>\n *\n * Use for sticky bottom ACTION bars only, never on cards or content areas.\n */\nimport * as React from \"react\";\nimport { IconDots } from \"@tabler/icons-react\";\nimport { cn } from \"../lib/cn\";\nimport { relTime } from \"../lib/utils\";\nimport { HintTooltip, IconButton } from \"./button\";\nimport { Avatar, AvatarStack } from \"./display\";\nimport { Menu, MenuContent, MenuTrigger } from \"./overlay\";\n\n/* ── Toasts clear the tray (S1: a toast covered the schema draft bar's Apply) ─────────────────────────────────────────\n A tray with `clearToasts` lifts the app's bottom toasts above itself while it is mounted: it writes\n `--toast-offset-bottom` on the root (the host's Toaster reads it as its bottom offset), the highest tray winning. */\nconst clearing = new Set<HTMLElement>();\nfunction syncToastOffset() {\n if (typeof document === \"undefined\") return;\n let lift = 0;\n for (const el of clearing) {\n const r = el.getBoundingClientRect();\n if (r.height) lift = Math.max(lift, window.innerHeight - r.top + 12);\n }\n if (lift > 0) document.documentElement.style.setProperty(\"--toast-offset-bottom\", `${Math.round(lift)}px`);\n else document.documentElement.style.removeProperty(\"--toast-offset-bottom\");\n}\nfunction useToastClearance(ref: React.RefObject<HTMLElement | null>, on: boolean) {\n React.useLayoutEffect(() => {\n const el = ref.current;\n if (!on || !el) return;\n clearing.add(el);\n syncToastOffset();\n const ro = typeof ResizeObserver !== \"undefined\" ? new ResizeObserver(syncToastOffset) : null;\n ro?.observe(el);\n window.addEventListener(\"resize\", syncToastOffset);\n return () => {\n clearing.delete(el);\n ro?.disconnect();\n window.removeEventListener(\"resize\", syncToastOffset);\n syncToastOffset();\n };\n }, [ref, on]);\n}\n\n/** Class string for footers that can't take the component (e.g. a shared footer primitive). */\nexport const actionTrayClass = \"shrink-0 border-t border-kit-tray-line bg-tray\";\n\nexport function ActionTray({\n meta,\n children,\n className,\n as: Tag = \"div\",\n clearToasts = false,\n ...props\n}: Omit<React.HTMLAttributes<HTMLElement>, \"children\"> & {\n /** Left slot, usually <TrayMeta>. */\n meta?: React.ReactNode;\n /** Right slot: actions (primary last-but-one, ⋯ last). */\n children?: React.ReactNode;\n as?: \"div\" | \"footer\";\n /** a page-level bar at the bottom of the window: bottom toasts sit above it, never over its buttons */\n clearToasts?: boolean;\n}) {\n const ref = React.useRef<HTMLElement>(null);\n useToastClearance(ref, clearToasts);\n return (\n <Tag\n ref={ref as React.Ref<HTMLDivElement>}\n data-action-tray=\"\"\n className={cn(actionTrayClass, \"@container/tray flex min-h-[45px] items-center justify-between gap-2 px-3 py-1.5\", className)}\n {...props}\n >\n <div className=\"flex min-w-0 flex-1 items-center gap-2\">{meta}</div>\n {children ? <div className=\"flex shrink-0 items-center gap-[5px]\">{children}</div> : null}\n </Tag>\n );\n}\n\n\nconst fullStamp = (at: string | number | Date) =>\n new Date(at).toLocaleString(\"en-US\", { weekday: \"short\", month: \"short\", day: \"numeric\", year: \"numeric\", hour: \"numeric\", minute: \"2-digit\" });\n\n/**\n * Left meta: avatar 20 · name 13/500 · \"Edited 3h ago\" 13 muted (Figma). The tooltip carries the full timestamp;\n * when `onClick` is set the whole line is a button (opens History).\n */\nexport function TrayMeta({\n name,\n avatarName,\n src,\n people,\n at,\n verb = \"Edited\",\n note,\n onClick,\n actionHint = \"Open history\",\n}: {\n name: string;\n /** Full name for the avatar when `name` is shortened (\"You\", first names). */\n avatarName?: string;\n src?: string;\n /** Several editors → avatar stack (first is the last editor). */\n people?: { name: string; src?: string }[];\n /** When it was edited; omit for \"just now\" states you phrase yourself via `note`. */\n at?: string | number | Date;\n verb?: string;\n /** Overrides the relative-time text, e.g. \"Edited just now\". */\n note?: string;\n onClick?: () => void;\n actionHint?: string;\n}) {\n const when = note ?? (at ? `${verb} ${relTime(at).replace(\"just now\", \"a moment ago\")}` : verb);\n const inner = (\n <>\n <span className=\"flex shrink-0 items-center gap-1\">\n {people && people.length > 1 ? (\n <AvatarStack people={people} size={20} max={3} />\n ) : (\n <Avatar name={avatarName ?? name} src={src} size={20} decorative />\n )}\n {/* narrow trays (the grid drawer): just the avatar, the words move into the tooltip; never a clipped \"Edit…\" */}\n <span className=\"hidden whitespace-nowrap text-kit-sm font-medium text-kit-fg @[34rem]/tray:inline\">{name}</span>\n </span>\n <span className=\"hidden min-w-0 truncate text-kit-sm text-kit-fg-3 @[34rem]/tray:inline\">{when}</span>\n </>\n );\n const tip = at\n ? `${name} · ${verb} ${fullStamp(at)}${onClick ? ` · ${actionHint}` : \"\"}`\n : onClick\n ? `${name} · ${when} · ${actionHint}`\n : `${name} · ${when}`;\n const body = onClick ? (\n <button\n type=\"button\"\n onClick={onClick}\n aria-label={`${name}, ${when}. ${actionHint}`}\n className=\"-mx-1 flex min-w-0 items-center gap-2 rounded-kit-md px-1 py-0.5 transition-colors hover:bg-kit-hover\"\n >\n {inner}\n </button>\n ) : (\n <span className=\"flex min-w-0 items-center gap-2\">\n {inner}\n {/* the words hide in narrow trays; screen readers always get them */}\n <span className=\"sr-only @[34rem]/tray:hidden\">{`${name}, ${when}`}</span>\n </span>\n );\n return <HintTooltip content={tip}>{body}</HintTooltip>;\n}\n\n/** The tray's \"⋯\" (32×32 ghost, Figma \"Button - Modal actions\") opening a menu above the bar. Children are menu items. */\nexport function TrayMore({\n label = \"More options\",\n children,\n menuClassName,\n}: {\n label?: string;\n children: React.ReactNode;\n menuClassName?: string;\n}) {\n return (\n // the kit Menu: §12 dismiss guards, the modal-layer marker (an open tooltip closes) and V2's non-looping arrows\n <Menu>\n <MenuTrigger\n render={\n <IconButton label={label} size=\"md\">\n <IconDots aria-hidden />\n </IconButton>\n }\n />\n <MenuContent side=\"top\" align=\"end\" className={cn(\"w-60\", menuClassName)}>\n {children}\n </MenuContent>\n </Menu>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuBA,IAAM,2BAAW,IAAI,IAAiB;AACtC,SAAS,kBAAkB;CACzB,IAAI,OAAO,aAAa,aAAa;CACrC,IAAI,OAAO;CACX,KAAK,MAAM,MAAM,UAAU;EACzB,MAAM,IAAI,GAAG,sBAAsB;EACnC,IAAI,EAAE,QAAQ,OAAO,KAAK,IAAI,MAAM,OAAO,cAAc,EAAE,MAAM,EAAE;CACrE;CACA,IAAI,OAAO,GAAG,SAAS,gBAAgB,MAAM,YAAY,yBAAyB,GAAG,KAAK,MAAM,IAAI,EAAE,GAAG;MACpG,SAAS,gBAAgB,MAAM,eAAe,uBAAuB;AAC5E;AACA,SAAS,kBAAkB,KAA0C,IAAa;CAChF,MAAM,sBAAsB;EAC1B,MAAM,KAAK,IAAI;EACf,IAAI,CAAC,MAAM,CAAC,IAAI;EAChB,SAAS,IAAI,EAAE;EACf,gBAAgB;EAChB,MAAM,KAAK,OAAO,mBAAmB,cAAc,IAAI,eAAe,eAAe,IAAI;EACzF,IAAI,QAAQ,EAAE;EACd,OAAO,iBAAiB,UAAU,eAAe;EACjD,aAAa;GACX,SAAS,OAAO,EAAE;GAClB,IAAI,WAAW;GACf,OAAO,oBAAoB,UAAU,eAAe;GACpD,gBAAgB;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,GAAA,KAAA,GAAA,OAAA;;;;CACT,GAAA,IAAA,CAAA,EAAA,GAAA,KAAA,GAAA,MAAA;;;;;AAEV"}
|
|
1
|
+
{"version":3,"file":"action-tray.js","names":[],"sources":["../../src/ui/action-tray.tsx"],"sourcesContent":["/**\n * ACTION TRAY: Figma 61014:66265 \"Bottom\". The soft, slightly raised bar at the bottom of editors, inspectors,\n * sheets and dialogs: surface → light grey gradient, 1px top hairline, 12px side padding, 6px vertical, 44px tall +\n * hairline (a 32px button fits exactly). No blur (D21).\n *\n * <ActionTray meta={<TrayMeta name=\"Priya Nair\" at={iso} onClick={openHistory} />}>\n * <Button variant=\"primary\" leftIcon={<IconUpload />}>Publish</Button>\n * <TrayMore>…menu items…</TrayMore>\n * </ActionTray>\n *\n * Use for sticky bottom ACTION bars only, never on cards or content areas.\n */\nimport * as React from \"react\";\nimport { IconDots } from \"@tabler/icons-react\";\nimport { cn } from \"../lib/cn\";\nimport { relTime } from \"../lib/utils\";\nimport { HintTooltip, IconButton } from \"./button\";\nimport { Avatar, AvatarStack } from \"./display\";\nimport { Menu, MenuContent, MenuTrigger } from \"./overlay\";\n\n/* ── Toasts clear the tray (S1: a toast covered the schema draft bar's Apply) ─────────────────────────────────────────\n A tray with `clearToasts` lifts the app's bottom toasts above itself while it is mounted: it writes\n `--toast-offset-bottom` on the root (the host's Toaster reads it as its bottom offset), the highest tray winning. */\nconst clearing = new Set<HTMLElement>();\nfunction syncToastOffset() {\n if (typeof document === \"undefined\") return;\n let lift = 0;\n for (const el of clearing) {\n const r = el.getBoundingClientRect();\n if (r.height) lift = Math.max(lift, window.innerHeight - r.top + 12);\n }\n if (lift > 0) document.documentElement.style.setProperty(\"--toast-offset-bottom\", `${Math.round(lift)}px`);\n else document.documentElement.style.removeProperty(\"--toast-offset-bottom\");\n}\nfunction useToastClearance(ref: React.RefObject<HTMLElement | null>, on: boolean) {\n React.useLayoutEffect(() => {\n const el = ref.current;\n if (!on || !el) return;\n clearing.add(el);\n syncToastOffset();\n const ro = typeof ResizeObserver !== \"undefined\" ? new ResizeObserver(syncToastOffset) : null;\n ro?.observe(el);\n window.addEventListener(\"resize\", syncToastOffset);\n return () => {\n clearing.delete(el);\n ro?.disconnect();\n window.removeEventListener(\"resize\", syncToastOffset);\n syncToastOffset();\n };\n }, [ref, on]);\n}\n\n/** Class string for footers that can't take the component (e.g. a shared footer primitive). */\nexport const actionTrayClass = \"shrink-0 border-t border-kit-tray-line bg-tray\";\n\nexport function ActionTray({\n meta,\n children,\n className,\n as: Tag = \"div\",\n clearToasts = false,\n ...props\n}: Omit<React.HTMLAttributes<HTMLElement>, \"children\"> & {\n /** Left slot, usually <TrayMeta>. */\n meta?: React.ReactNode;\n /** Right slot: actions (primary last-but-one, ⋯ last). */\n children?: React.ReactNode;\n as?: \"div\" | \"footer\";\n /** a page-level bar at the bottom of the window: bottom toasts sit above it, never over its buttons */\n clearToasts?: boolean;\n}) {\n const ref = React.useRef<HTMLElement>(null);\n useToastClearance(ref, clearToasts);\n return (\n <Tag\n ref={ref as React.Ref<HTMLDivElement>}\n data-action-tray=\"\"\n className={cn(actionTrayClass, \"@container/tray flex min-h-[45px] items-center justify-between gap-2 px-3 py-1.5\", className)}\n {...props}\n >\n <div className=\"flex min-w-0 flex-1 items-center gap-2\">{meta}</div>\n {children ? <div className=\"flex shrink-0 items-center gap-[5px]\">{children}</div> : null}\n </Tag>\n );\n}\n\n\nconst fullStamp = (at: string | number | Date) =>\n new Date(at).toLocaleString(\"en-US\", { weekday: \"short\", month: \"short\", day: \"numeric\", year: \"numeric\", hour: \"numeric\", minute: \"2-digit\" });\n\n/**\n * Left meta: avatar 20 · name 13/500 · \"Edited 3h ago\" 13 muted (Figma). The tooltip carries the full timestamp;\n * when `onClick` is set the whole line is a button (opens History).\n */\nexport function TrayMeta({\n name,\n avatarName,\n src,\n people,\n at,\n verb = \"Edited\",\n note,\n onClick,\n actionHint = \"Open history\",\n}: {\n name: string;\n /** Full name for the avatar when `name` is shortened (\"You\", first names). */\n avatarName?: string;\n src?: string;\n /** Several editors → avatar stack (first is the last editor). */\n people?: { name: string; src?: string }[];\n /** When it was edited; omit for \"just now\" states you phrase yourself via `note`. */\n at?: string | number | Date;\n verb?: string;\n /** Overrides the relative-time text, e.g. \"Edited just now\". */\n note?: string;\n onClick?: () => void;\n actionHint?: string;\n}) {\n const when = note ?? (at ? `${verb} ${relTime(at).replace(\"just now\", \"a moment ago\")}` : verb);\n const inner = (\n <>\n <span className=\"flex shrink-0 items-center gap-1\">\n {people && people.length > 1 ? (\n <AvatarStack people={people} size={20} max={3} />\n ) : (\n <Avatar name={avatarName ?? name} src={src} size={20} decorative />\n )}\n {/* narrow trays (the grid drawer): just the avatar, the words move into the tooltip; never a clipped \"Edit…\" */}\n <span className=\"hidden whitespace-nowrap text-kit-sm font-medium text-kit-fg @[34rem]/tray:inline\">{name}</span>\n </span>\n <span className=\"hidden min-w-0 truncate text-kit-sm text-kit-fg-3 @[34rem]/tray:inline\">{when}</span>\n </>\n );\n const tip = at\n ? `${name} · ${verb} ${fullStamp(at)}${onClick ? ` · ${actionHint}` : \"\"}`\n : onClick\n ? `${name} · ${when} · ${actionHint}`\n : `${name} · ${when}`;\n const body = onClick ? (\n <button\n type=\"button\"\n onClick={onClick}\n aria-label={`${name}, ${when}. ${actionHint}`}\n className=\"-mx-1 flex min-w-0 items-center gap-2 rounded-kit-md px-1 py-0.5 transition-colors hover:bg-kit-hover\"\n >\n {inner}\n </button>\n ) : (\n <span className=\"flex min-w-0 items-center gap-2\">\n {inner}\n {/* the words hide in narrow trays; screen readers always get them */}\n <span className=\"sr-only @[34rem]/tray:hidden\">{`${name}, ${when}`}</span>\n </span>\n );\n return <HintTooltip content={tip}>{body}</HintTooltip>;\n}\n\n/** The tray's \"⋯\" (32×32 ghost, Figma \"Button - Modal actions\") opening a menu above the bar. Children are menu items. */\nexport function TrayMore({\n label = \"More options\",\n children,\n menuClassName,\n}: {\n label?: string;\n children: React.ReactNode;\n menuClassName?: string;\n}) {\n return (\n // the kit Menu: §12 dismiss guards, the modal-layer marker (an open tooltip closes) and V2's non-looping arrows\n <Menu>\n <MenuTrigger\n render={\n <IconButton label={label} size=\"md\">\n <IconDots aria-hidden />\n </IconButton>\n }\n />\n <MenuContent side=\"top\" align=\"end\" className={cn(\"w-60\", menuClassName)}>\n {children}\n </MenuContent>\n </Menu>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuBA,IAAM,2BAAW,IAAI,IAAiB;AACtC,SAAS,kBAAkB;CACzB,IAAI,OAAO,aAAa,aAAa;CACrC,IAAI,OAAO;CACX,KAAK,MAAM,MAAM,UAAU;EACzB,MAAM,IAAI,GAAG,sBAAsB;EACnC,IAAI,EAAE,QAAQ,OAAO,KAAK,IAAI,MAAM,OAAO,cAAc,EAAE,MAAM,EAAE;CACrE;CACA,IAAI,OAAO,GAAG,SAAS,gBAAgB,MAAM,YAAY,yBAAyB,GAAG,KAAK,MAAM,IAAI,EAAE,GAAG;MACpG,SAAS,gBAAgB,MAAM,eAAe,uBAAuB;AAC5E;AACA,SAAS,kBAAkB,KAA0C,IAAa;CAChF,MAAM,sBAAsB;EAC1B,MAAM,KAAK,IAAI;EACf,IAAI,CAAC,MAAM,CAAC,IAAI;EAChB,SAAS,IAAI,EAAE;EACf,gBAAgB;EAChB,MAAM,KAAK,OAAO,mBAAmB,cAAc,IAAI,eAAe,eAAe,IAAI;EACzF,IAAI,QAAQ,EAAE;EACd,OAAO,iBAAiB,UAAU,eAAe;EACjD,aAAa;GACX,SAAS,OAAO,EAAE;GAClB,IAAI,WAAW;GACf,OAAO,oBAAoB,UAAU,eAAe;GACpD,gBAAgB;EAClB;CACF,GAAG,CAAC,KAAK,EAAE,CAAC;AACd;;AAGA,IAAa,kBAAkB;AAE/B,SAAgB,WAAW,EACzB,MACA,UACA,WACA,IAAI,MAAM,OACV,cAAc,OACd,GAAG,SASF;CACD,MAAM,MAAM,MAAM,OAAoB,IAAI;CAC1C,kBAAkB,KAAK,WA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