@kerfjs/ui 5.0.0-beta.129 → 5.0.0-beta.130
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/ai/component-catalog.json +14 -9
- package/ai/component-composition-rules.json +1 -1
- package/ai/component-composition.d.ts +17 -0
- package/ai/component-composition.json +4 -3
- package/ai/component-composition.schema.json +326 -80
- package/ai/component-props-overlay.json +8568 -628
- package/ai/component-props-overlay.schema.json +15 -1
- package/ai/component-props.json +6221 -2069
- package/ai/component-props.schema.json +7 -0
- package/ai/components/radio-group.md +5 -1
- package/ai/components/state-banner.md +1 -1
- package/ai/components/surface-scaffold.md +3 -2
- package/ai/components/tab-bar.md +1 -1
- package/ai/components/toolbar-control-group.md +1 -1
- package/ai/public-api-signatures-v1.md +205 -42
- package/ai/skill.md +21 -8
- package/ai/view-document.schema.json +140 -86
- package/ai/webawesome-jsx-signatures-v1.md +1 -1
- package/dist/browser/column-explorer.js +5 -1
- package/dist/browser/radio-group.js +1 -0
- package/dist/catalog-resources.d.ts +2 -2
- package/dist/catalog.d.ts +2 -2
- package/dist/catalog.js +5 -5
- package/dist/{chunk-E2MTHHLS.js → chunk-2FA3SX57.js} +2 -2
- package/dist/{chunk-E2MTHHLS.js.map → chunk-2FA3SX57.js.map} +1 -1
- package/dist/{chunk-ZC4KSRAF.js → chunk-4CYCJ3NY.js} +6 -4
- package/dist/chunk-4CYCJ3NY.js.map +1 -0
- package/dist/{chunk-IMXLOMTF.js → chunk-76BLSFEA.js} +30 -12
- package/dist/chunk-76BLSFEA.js.map +1 -0
- package/dist/{chunk-IR32NI2O.js → chunk-ALBFHXMZ.js} +3 -3
- package/dist/chunk-ALBFHXMZ.js.map +1 -0
- package/dist/{chunk-3ZWYGGEC.js → chunk-ASU4ODOH.js} +38 -7
- package/dist/chunk-ASU4ODOH.js.map +1 -0
- package/dist/chunk-BMUYZKXW.js +155 -0
- package/dist/chunk-BMUYZKXW.js.map +1 -0
- package/dist/{chunk-GQUDCWOD.js → chunk-D2KHQNJ6.js} +49 -23
- package/dist/chunk-D2KHQNJ6.js.map +1 -0
- package/dist/{chunk-34FWYJX6.js → chunk-ECJHCPBN.js} +8 -2
- package/dist/chunk-ECJHCPBN.js.map +1 -0
- package/dist/{chunk-DBCDYBZP.js → chunk-HHEBNP6Z.js} +2 -2
- package/dist/{chunk-DBCDYBZP.js.map → chunk-HHEBNP6Z.js.map} +1 -1
- package/dist/{chunk-3ZKUXWAV.js → chunk-IPYQYLSX.js} +16 -9
- package/dist/chunk-IPYQYLSX.js.map +1 -0
- package/dist/{chunk-SJEPM5ZU.js → chunk-LETAE6SX.js} +2 -2
- package/dist/{chunk-SJEPM5ZU.js.map → chunk-LETAE6SX.js.map} +1 -1
- package/dist/chunk-MVWR5WRX.js +99 -0
- package/dist/chunk-MVWR5WRX.js.map +1 -0
- package/dist/{chunk-6T7AX365.js → chunk-OSL4LQ7T.js} +52 -23
- package/dist/chunk-OSL4LQ7T.js.map +1 -0
- package/dist/{chunk-OHT2AXER.js → chunk-QSJAIXLM.js} +19 -3
- package/dist/chunk-QSJAIXLM.js.map +1 -0
- package/dist/{chunk-UQ4FRQ6M.js → chunk-R4JK2C6D.js} +13 -3
- package/dist/chunk-R4JK2C6D.js.map +1 -0
- package/dist/{chunk-5A2DN3LR.js → chunk-SGYBIKQA.js} +3 -1
- package/dist/chunk-SGYBIKQA.js.map +1 -0
- package/dist/{chunk-K3C35KGR.js → chunk-XO5IOPM5.js} +2 -2
- package/dist/{chunk-K3C35KGR.js.map → chunk-XO5IOPM5.js.map} +1 -1
- package/dist/collapsible-panel.d.ts +2 -2
- package/dist/collapsible-panel.js +2 -2
- package/dist/column-explorer.d.ts +5 -1
- package/dist/column-explorer.js +5 -1
- package/dist/column-track.d.ts +3 -1
- package/dist/column-track.js +1 -1
- package/dist/editor.d.ts +87 -2
- package/dist/editor.js +2249 -1320
- package/dist/editor.js.map +1 -1
- package/dist/index.js +12 -12
- package/dist/list-detail-dialog.d.ts +2 -2
- package/dist/list-detail-dialog.js +4 -4
- package/dist/list-header.d.ts +47 -5
- package/dist/list-header.js +1 -1
- package/dist/message-composer.js +1 -1
- package/dist/{nav-stack-vQ3ieerq.d.ts → nav-stack-DKrvqFjA.d.ts} +1 -1
- package/dist/nav-stack.d.ts +2 -2
- package/dist/nav-stack.js +1 -1
- package/dist/{panel-toolbar-vg6Ir5Dy.d.ts → panel-toolbar-CEcHHDkn.d.ts} +8 -0
- package/dist/radio-group.d.ts +19 -2
- package/dist/radio-group.js +3 -1
- package/dist/split-view.d.ts +2 -2
- package/dist/split-view.js +1 -1
- package/dist/styles/column-track.css +7 -2
- package/dist/styles/components/actions/toolbar-control-group/toolbar-control-group.css +11 -4
- package/dist/styles/components/collections/list-header/list-header.css +50 -0
- package/dist/styles/components/collections/list-item/list-item.css +6 -1
- package/dist/styles/components/collections/tree-list/tree-list.css +3 -2
- package/dist/styles/components/forms/radio-group/radio-group.css +107 -0
- package/dist/styles/components/layout/column-track/column-track.css +7 -2
- package/dist/styles/components/surfaces/surface-scaffold/surface-scaffold.css +30 -1
- package/dist/styles/editor/editor.css +0 -23
- package/dist/styles/list-header.css +50 -0
- package/dist/styles/list-item.css +6 -1
- package/dist/styles/radio-group.css +107 -0
- package/dist/styles/surface-scaffold.css +30 -1
- package/dist/styles/toolbar-control-group.css +11 -4
- package/dist/styles/tree-list.css +3 -2
- package/dist/surface-scaffold-register.js +1 -1
- package/dist/surface-scaffold.d.ts +46 -11
- package/dist/surface-scaffold.js +2 -2
- package/dist/toolbar-control-group.d.ts +10 -1
- package/dist/toolbar-control-group.js +1 -1
- package/dist/tree-list.d.ts +7 -1
- package/dist/tree-list.js +1 -1
- package/dist/view-runtime.d.ts +9 -0
- package/dist/view-runtime.js +8 -0
- package/dist/view-runtime.js.map +1 -0
- package/dist/wire-catalog.d.ts +2 -2
- package/dist/wire-catalog.js +1 -1
- package/dist/wire-search-fields.js +1 -1
- package/dist/wire-tab-bars.d.ts +10 -0
- package/dist/wire-tab-bars.js +1 -1
- package/dist/wire-tag-fields.js +1 -1
- package/dist/wire-workbench.d.ts +17 -1
- package/dist/wire-workbench.js +1 -1
- package/dist/workbench-dialog.d.ts +2 -2
- package/dist/workbench-dialog.js +4 -4
- package/dist/workbench.d.ts +10 -2
- package/dist/workbench.js +1 -1
- package/docs/accessibility.md +1 -1
- package/docs/column-explorer.md +4 -0
- package/docs/component-contract.md +10 -4
- package/docs/component-integration.md +7 -3
- package/docs/component-selection.md +2 -1
- package/docs/design/sketch/Kerf-UI.sketch +0 -0
- package/docs/design/sketch/coverage.md +7 -6
- package/docs/design/sketch/forms/README.md +5 -4
- package/docs/design/sketch/unified/pages/forms.png +0 -0
- package/docs/design/templates/radio-group/tiles-dark.svg +1 -0
- package/docs/design/templates/radio-group/tiles.svg +1 -0
- package/docs/design/templates/radio-group-dark.svg +1 -1
- package/docs/design/templates/radio-group.svg +1 -1
- package/docs/editor-host.md +90 -5
- package/docs/interaction-conventions.md +2 -0
- package/docs/layout.md +1 -1
- package/docs/surface-scaffold.md +49 -2
- package/docs/tree-list.md +10 -0
- package/docs/workbench.md +16 -0
- package/evaluator/firefox-app-data.d.mts +4 -0
- package/evaluator/firefox-app-data.mjs +35 -0
- package/evaluator/index.mjs +19 -5
- package/llms.txt +20 -4
- package/package.json +8 -1
- package/props/component-props.d.mts +3 -0
- package/view/cli.mjs +36 -5
- package/view/contract.mjs +3 -0
- package/view/generate.mjs +8 -7
- package/view/index.d.mts +14 -0
- package/view/project-types-worker.mjs +55 -0
- package/view/project-types.d.mts +43 -0
- package/view/project-types.mjs +618 -0
- package/view/type-expression.d.mts +15 -0
- package/view/type-expression.mjs +162 -0
- package/view/types.mjs +4 -0
- package/view/validate.mjs +20 -1
- package/vite-editor.d.mts +31 -3
- package/vite-editor.mjs +168 -4
- package/dist/chunk-34FWYJX6.js.map +0 -1
- package/dist/chunk-3ZKUXWAV.js.map +0 -1
- package/dist/chunk-3ZWYGGEC.js.map +0 -1
- package/dist/chunk-5A2DN3LR.js.map +0 -1
- package/dist/chunk-6T7AX365.js.map +0 -1
- package/dist/chunk-BMOZSNDU.js +0 -133
- package/dist/chunk-BMOZSNDU.js.map +0 -1
- package/dist/chunk-GQUDCWOD.js.map +0 -1
- package/dist/chunk-IMXLOMTF.js.map +0 -1
- package/dist/chunk-IR32NI2O.js.map +0 -1
- package/dist/chunk-MLDO7WLA.js +0 -82
- package/dist/chunk-MLDO7WLA.js.map +0 -1
- package/dist/chunk-OHT2AXER.js.map +0 -1
- package/dist/chunk-UQ4FRQ6M.js.map +0 -1
- package/dist/chunk-ZC4KSRAF.js.map +0 -1
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
// Browser-safe transport for a compiler-checked TypeScript parameter expression.
|
|
2
|
+
// The projection is for navigation; Node's project compiler remains the semantic
|
|
3
|
+
// authority. Module-token spans let exports rebase imports without regex-parsing TS.
|
|
4
|
+
|
|
5
|
+
const OPEN = new Map([
|
|
6
|
+
['(', ')'],
|
|
7
|
+
['[', ']'],
|
|
8
|
+
['{', '}'],
|
|
9
|
+
['<', '>'],
|
|
10
|
+
]);
|
|
11
|
+
const DECLARATION =
|
|
12
|
+
/^(?:export|declare|const|let|var|class|interface|namespace|module|function|debugger)$/;
|
|
13
|
+
|
|
14
|
+
/** A lexical containment check, not TypeScript syntax or semantic validation. */
|
|
15
|
+
export function containedTypeExpression(text) {
|
|
16
|
+
if (typeof text !== 'string' || !text.trim() || text.length > 16384)
|
|
17
|
+
return false;
|
|
18
|
+
const stack = [];
|
|
19
|
+
let quote = '';
|
|
20
|
+
for (let at = 0; at < text.length; at += 1) {
|
|
21
|
+
const char = text[at];
|
|
22
|
+
if (quote) {
|
|
23
|
+
if (char === '\\') at += 1;
|
|
24
|
+
else if (char === quote) quote = '';
|
|
25
|
+
else if (quote === '`' && char === '$' && text[at + 1] === '{') {
|
|
26
|
+
stack.push('template');
|
|
27
|
+
quote = '';
|
|
28
|
+
at += 1;
|
|
29
|
+
}
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (char === '"' || char === "'" || char === '`') {
|
|
33
|
+
quote = char;
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (char === '/' && text[at + 1] === '/') {
|
|
37
|
+
const end = text.indexOf('\n', at + 2);
|
|
38
|
+
if (end === -1) break;
|
|
39
|
+
at = end;
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (char === '/' && text[at + 1] === '*') {
|
|
43
|
+
const end = text.indexOf('*/', at + 2);
|
|
44
|
+
if (end === -1) return false;
|
|
45
|
+
at = end + 1;
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (char === '>' && text[at - 1] === '=') continue;
|
|
49
|
+
if (OPEN.has(char)) stack.push(OPEN.get(char));
|
|
50
|
+
else if (')]}>'.includes(char)) {
|
|
51
|
+
const expected = stack.pop();
|
|
52
|
+
if (char === '}' && expected === 'template') quote = '`';
|
|
53
|
+
else if (expected !== char) return false;
|
|
54
|
+
} else if (stack.length === 0) {
|
|
55
|
+
if (
|
|
56
|
+
char === ';' ||
|
|
57
|
+
char === ',' ||
|
|
58
|
+
(char === '=' && text[at + 1] !== '>')
|
|
59
|
+
)
|
|
60
|
+
return false;
|
|
61
|
+
if (/[A-Za-z_$]/.test(char)) {
|
|
62
|
+
const word = /^[A-Za-z_$][\w$]*/.exec(text.slice(at))[0];
|
|
63
|
+
if (DECLARATION.test(word)) return false;
|
|
64
|
+
at += word.length - 1;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return !quote && stack.length === 0;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** A stable project-relative source name (never an absolute clone path). */
|
|
72
|
+
export function typeSourcePath(value) {
|
|
73
|
+
return (
|
|
74
|
+
typeof value === 'string' &&
|
|
75
|
+
value.length > 0 &&
|
|
76
|
+
!value.includes('\\') &&
|
|
77
|
+
!value.includes(':') &&
|
|
78
|
+
!value.startsWith('/') &&
|
|
79
|
+
!value
|
|
80
|
+
.split('/')
|
|
81
|
+
.some((part) => part === '..' || part === '.' || part === '')
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function validTypeExpression(type) {
|
|
86
|
+
const value = type?.typescript;
|
|
87
|
+
if (
|
|
88
|
+
!value ||
|
|
89
|
+
!containedTypeExpression(value.text) ||
|
|
90
|
+
!typeSourcePath(value.source) ||
|
|
91
|
+
!Array.isArray(value.references)
|
|
92
|
+
)
|
|
93
|
+
return false;
|
|
94
|
+
let end = 0;
|
|
95
|
+
return value.references.every((item) => {
|
|
96
|
+
if (
|
|
97
|
+
!Number.isInteger(item.start) ||
|
|
98
|
+
!Number.isInteger(item.length) ||
|
|
99
|
+
item.start < end ||
|
|
100
|
+
item.length < 2 ||
|
|
101
|
+
typeof item.module !== 'string'
|
|
102
|
+
)
|
|
103
|
+
return false;
|
|
104
|
+
end = item.start + item.length;
|
|
105
|
+
return (
|
|
106
|
+
end <= value.text.length &&
|
|
107
|
+
value.text.slice(item.start, end) === JSON.stringify(item.module) &&
|
|
108
|
+
(!item.module.startsWith('.') ||
|
|
109
|
+
parts(
|
|
110
|
+
[...value.source.split('/').slice(0, -1), item.module].join('/'),
|
|
111
|
+
) !== undefined)
|
|
112
|
+
);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const parts = (value) => {
|
|
117
|
+
const result = [];
|
|
118
|
+
for (const part of value.split('/')) {
|
|
119
|
+
if (part === '..') {
|
|
120
|
+
if (!result.length) return undefined;
|
|
121
|
+
result.pop();
|
|
122
|
+
} else if (part && part !== '.') result.push(part);
|
|
123
|
+
}
|
|
124
|
+
return result;
|
|
125
|
+
};
|
|
126
|
+
const relative = (from, to) => {
|
|
127
|
+
while (from.length && to.length && from[0] === to[0]) {
|
|
128
|
+
from.shift();
|
|
129
|
+
to.shift();
|
|
130
|
+
}
|
|
131
|
+
const value = [...from.map(() => '..'), ...to].join('/');
|
|
132
|
+
return value.startsWith('.') ? value : `./${value}`;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
/** Rebase only the module literal tokens the compiler identified in the expression. */
|
|
136
|
+
export function typeExpressionText(type, source = type.typescript.source) {
|
|
137
|
+
if (!validTypeExpression(type) || !typeSourcePath(source))
|
|
138
|
+
throw new Error('Invalid TypeScript parameter expression metadata.');
|
|
139
|
+
const { text, references } = type.typescript;
|
|
140
|
+
const original = type.typescript.source.split('/').slice(0, -1);
|
|
141
|
+
const target = source.split('/').slice(0, -1);
|
|
142
|
+
let result = text;
|
|
143
|
+
for (const item of [...references].reverse()) {
|
|
144
|
+
if (!item.module.startsWith('.')) continue;
|
|
145
|
+
const module = relative(
|
|
146
|
+
[...target],
|
|
147
|
+
parts([...original, item.module].join('/')),
|
|
148
|
+
);
|
|
149
|
+
result =
|
|
150
|
+
result.slice(0, item.start) +
|
|
151
|
+
JSON.stringify(module) +
|
|
152
|
+
result.slice(item.start + item.length);
|
|
153
|
+
}
|
|
154
|
+
return result;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** Whether a document needs the project compiler in addition to structural checks. */
|
|
158
|
+
export function hasTypeExpressions(document) {
|
|
159
|
+
return Object.values(document.params ?? {}).some(
|
|
160
|
+
(param) => param.type?.typescript !== undefined,
|
|
161
|
+
);
|
|
162
|
+
}
|
package/view/types.mjs
CHANGED
|
@@ -9,6 +9,9 @@ export const ICON_NAME = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
|
9
9
|
|
|
10
10
|
/** Whether a value of type `from` (a param or binding) fits type `to`. */
|
|
11
11
|
export function isAssignable(from, to, definitions = {}) {
|
|
12
|
+
// Project TypeScript types are checked by the Node language service against
|
|
13
|
+
// the generated module. The structural pass cannot prove TS assignability.
|
|
14
|
+
if (from?.typescript || to?.typescript) return true;
|
|
12
15
|
// A component prop's type fits only that same component prop.
|
|
13
16
|
if (from?.kind === 'prop' || to?.kind === 'prop')
|
|
14
17
|
return (
|
|
@@ -93,6 +96,7 @@ export function literalOf(value, type, definitions, hooks) {
|
|
|
93
96
|
('$param' in value || '$bind' in value)
|
|
94
97
|
)
|
|
95
98
|
return hooks.dynamic(value, type);
|
|
99
|
+
if (type?.typescript) return true;
|
|
96
100
|
const target = resolveType(type, definitions);
|
|
97
101
|
if (value === null) return target.nullable === true;
|
|
98
102
|
switch (target.kind) {
|
package/view/validate.mjs
CHANGED
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
import { childKind } from './child-kind.mjs';
|
|
21
21
|
import { CSS_HELPERS, parseCssCall } from './css-grammar.mjs';
|
|
22
22
|
import { ICON_NAME, isAssignable, isLiteralOf, literalOf } from './types.mjs';
|
|
23
|
+
import { hasTypeExpressions, validTypeExpression } from './type-expression.mjs';
|
|
23
24
|
|
|
24
25
|
export const VIEW_DOCUMENT_SCHEMA_ID = 'kerf-ui-document/v1';
|
|
25
26
|
|
|
@@ -55,6 +56,15 @@ function describe(type) {
|
|
|
55
56
|
|
|
56
57
|
/** Validates one param or slot-input type in the document's own grammar. */
|
|
57
58
|
function validateDeclaredType(ctx, type, path) {
|
|
59
|
+
if (type?.typescript !== undefined) {
|
|
60
|
+
if (!validTypeExpression(type))
|
|
61
|
+
ctx.report(
|
|
62
|
+
'KUI-V001',
|
|
63
|
+
path,
|
|
64
|
+
'invalid TypeScript expression or portable import context',
|
|
65
|
+
);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
58
68
|
if (!isObject(type) || !PARAM_KINDS.has(type.kind)) {
|
|
59
69
|
ctx.report(
|
|
60
70
|
'KUI-V001',
|
|
@@ -132,9 +142,11 @@ function bindingType(ctx, path, scope, at) {
|
|
|
132
142
|
);
|
|
133
143
|
return undefined;
|
|
134
144
|
}
|
|
145
|
+
const project = type.typescript;
|
|
135
146
|
for (const segment of rest) {
|
|
136
147
|
const prop = propsOf(type, {})?.find((item) => item.name === segment);
|
|
137
148
|
if (!prop) {
|
|
149
|
+
if (project) return { kind: 'unknown', typescript: project };
|
|
138
150
|
ctx.report(
|
|
139
151
|
'KUI-V007',
|
|
140
152
|
at,
|
|
@@ -144,7 +156,7 @@ function bindingType(ctx, path, scope, at) {
|
|
|
144
156
|
}
|
|
145
157
|
type = prop.type;
|
|
146
158
|
}
|
|
147
|
-
return type;
|
|
159
|
+
return project ? { ...type, typescript: project } : type;
|
|
148
160
|
}
|
|
149
161
|
|
|
150
162
|
/**
|
|
@@ -1587,6 +1599,13 @@ export function runView(document, catalog, options, trace) {
|
|
|
1587
1599
|
checkNode(ctx, document.root, '$.root', new Map(), false, undefined);
|
|
1588
1600
|
}
|
|
1589
1601
|
const hints = [];
|
|
1602
|
+
if (hasTypeExpressions(document))
|
|
1603
|
+
hints.push({
|
|
1604
|
+
code: 'KUI-H002',
|
|
1605
|
+
path: '$.params',
|
|
1606
|
+
message:
|
|
1607
|
+
'TypeScript parameter expressions require the owning project compiler; this pass checks structure only.',
|
|
1608
|
+
});
|
|
1590
1609
|
hintUnsizedLayouts(document.root, '$.root', true, hints, true);
|
|
1591
1610
|
return { valid: diagnostics.length === 0, diagnostics, hints, actions };
|
|
1592
1611
|
}
|
package/vite-editor.d.mts
CHANGED
|
@@ -4,10 +4,14 @@ export declare const KERF_UI_EDITOR_ROUTE: '/__kerf-ui-editor/';
|
|
|
4
4
|
export declare const DEFAULT_REGISTRY: 'src/kerf-ui-registry.ts';
|
|
5
5
|
/** The field editors module the plugin loads when it exists and none is named. */
|
|
6
6
|
export declare const DEFAULT_FIELD_EDITORS: 'src/kerf-ui-field-editors.ts';
|
|
7
|
+
/** Default Library-only executable preview registrations. */
|
|
8
|
+
export declare const DEFAULT_LIBRARY_PREVIEWS: 'src/kerf-ui-library-previews.ts';
|
|
7
9
|
/** Where the editor reads and writes documents. */
|
|
8
10
|
export declare const KERF_UI_EDITOR_FILE_API: '/__kerf-ui-editor/api/file';
|
|
9
11
|
/** Where the editor lists the project's documents (GET: a JSON array of paths). */
|
|
10
12
|
export declare const KERF_UI_EDITOR_LIST_API: '/__kerf-ui-editor/api/files';
|
|
13
|
+
/** Project TypeScript service; POST requires the editor header. */
|
|
14
|
+
export declare const KERF_UI_EDITOR_TYPES_API: '/__kerf-ui-editor/api/types';
|
|
11
15
|
/** The most documents the list answers. */
|
|
12
16
|
export declare const KERF_UI_EDITOR_LIST_LIMIT: 5000;
|
|
13
17
|
/** The project folder unsaved drafts autosave into; it ignores itself in git. */
|
|
@@ -29,6 +33,8 @@ export interface EditorPropsCatalog {
|
|
|
29
33
|
|
|
30
34
|
/** The catalogs an application declares for the editor. */
|
|
31
35
|
export interface ApplicationCatalogs {
|
|
36
|
+
/** Existing preview modules, resolved relative to each composition catalog. */
|
|
37
|
+
readonly libraryPreviewModules?: readonly string[];
|
|
32
38
|
readonly props: readonly EditorPropsCatalog[];
|
|
33
39
|
readonly composition: readonly {
|
|
34
40
|
readonly package?: string;
|
|
@@ -53,6 +59,8 @@ export interface KerfUiEditorOptions {
|
|
|
53
59
|
* `src/kerf-ui-field-editors.ts` when it exists.
|
|
54
60
|
*/
|
|
55
61
|
fieldEditors?: string;
|
|
62
|
+
/** Library-only preview registrations; defaults to src/kerf-ui-library-previews.ts when present. */
|
|
63
|
+
libraryPreviews?: string;
|
|
56
64
|
/**
|
|
57
65
|
* A module, resolved against Vite's `root`, whose default export is play
|
|
58
66
|
* mode's device presets (`DevicePresetsOption` from `@kerfjs/ui/editor`):
|
|
@@ -120,15 +128,33 @@ export declare function editorDocuments(
|
|
|
120
128
|
): Promise<string[]>;
|
|
121
129
|
/**
|
|
122
130
|
* Connect middleware reading (GET) and writing (PUT) documents under `root`,
|
|
123
|
-
*
|
|
131
|
+
* listing them (GET `KERF_UI_EDITOR_LIST_API`), and answering project-type
|
|
132
|
+
* requests (POST `KERF_UI_EDITOR_TYPES_API`) from a worker thread, so a type
|
|
133
|
+
* analysis never delays the server's other responses. Call `dispose()` when
|
|
134
|
+
* the server closes to stop that worker; it never keeps the process alive.
|
|
124
135
|
*/
|
|
125
136
|
export declare function editorFileMiddleware(
|
|
126
137
|
root: string,
|
|
127
|
-
): (
|
|
138
|
+
): ((
|
|
128
139
|
request: import('node:http').IncomingMessage,
|
|
129
140
|
response: import('node:http').ServerResponse,
|
|
130
141
|
next: (error?: unknown) => void,
|
|
131
|
-
) => Promise<void
|
|
142
|
+
) => Promise<void>) & { dispose(): Promise<number> | undefined };
|
|
143
|
+
/** A type request's reply from the worker. */
|
|
144
|
+
export type ProjectTypeReply =
|
|
145
|
+
{ result: unknown } | { status: 400 | 500; error: string };
|
|
146
|
+
/**
|
|
147
|
+
* The project-type service in a worker thread for `root`, created on the
|
|
148
|
+
* first request and again after a crash. Internal; `entry` replaces the
|
|
149
|
+
* worker module in tests.
|
|
150
|
+
*/
|
|
151
|
+
export declare function projectTypeWorker(
|
|
152
|
+
root: string,
|
|
153
|
+
entry?: URL,
|
|
154
|
+
): {
|
|
155
|
+
request(body: Record<string, unknown>): Promise<ProjectTypeReply>;
|
|
156
|
+
dispose(): Promise<number> | undefined;
|
|
157
|
+
};
|
|
132
158
|
/** The editor page the route serves. */
|
|
133
159
|
export declare function editorPage(): string;
|
|
134
160
|
/** The generated entry module that mounts the editor. */
|
|
@@ -136,6 +162,8 @@ export declare function editorEntry(options: {
|
|
|
136
162
|
app: ApplicationCatalogs;
|
|
137
163
|
registry?: string;
|
|
138
164
|
fieldEditors?: string;
|
|
165
|
+
/** Library-only preview registrations; defaults to src/kerf-ui-library-previews.ts when present. */
|
|
166
|
+
libraryPreviews?: string;
|
|
139
167
|
devicePresets?: string;
|
|
140
168
|
playHandlers?: string;
|
|
141
169
|
}): string;
|
package/vite-editor.mjs
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* production build.
|
|
14
14
|
*/
|
|
15
15
|
import { existsSync, readFileSync } from 'node:fs';
|
|
16
|
+
import { createRequire } from 'node:module';
|
|
16
17
|
import { mkdir, readdir, readFile, rename, writeFile } from 'node:fs/promises';
|
|
17
18
|
import {
|
|
18
19
|
basename,
|
|
@@ -25,6 +26,7 @@ import {
|
|
|
25
26
|
} from 'node:path';
|
|
26
27
|
import process from 'node:process';
|
|
27
28
|
import { URL } from 'node:url';
|
|
29
|
+
import { Worker } from 'node:worker_threads';
|
|
28
30
|
|
|
29
31
|
import { profileCatalogPaths } from './view/cli.mjs';
|
|
30
32
|
|
|
@@ -37,6 +39,8 @@ export const DEFAULT_REGISTRY = 'src/kerf-ui-registry.ts';
|
|
|
37
39
|
* named (KF-EXA2WH: field editor API).
|
|
38
40
|
*/
|
|
39
41
|
export const DEFAULT_FIELD_EDITORS = 'src/kerf-ui-field-editors.ts';
|
|
42
|
+
/** Library-only registration module loaded when present. */
|
|
43
|
+
export const DEFAULT_LIBRARY_PREVIEWS = 'src/kerf-ui-library-previews.ts';
|
|
40
44
|
|
|
41
45
|
/** Where the editor reads and writes documents (KF-0SY9M6: autosave). */
|
|
42
46
|
export const KERF_UI_EDITOR_FILE_API = '/__kerf-ui-editor/api/file';
|
|
@@ -45,6 +49,8 @@ export const KERF_UI_EDITOR_FILE_API = '/__kerf-ui-editor/api/file';
|
|
|
45
49
|
* existing document): GET answers a JSON array of `.kui.json` paths.
|
|
46
50
|
*/
|
|
47
51
|
export const KERF_UI_EDITOR_LIST_API = '/__kerf-ui-editor/api/files';
|
|
52
|
+
/** Node-only project language-service endpoint; POST requires the editor header. */
|
|
53
|
+
export const KERF_UI_EDITOR_TYPES_API = '/__kerf-ui-editor/api/types';
|
|
48
54
|
/** The most documents the list answers. */
|
|
49
55
|
export const KERF_UI_EDITOR_LIST_LIMIT = 5000;
|
|
50
56
|
/** Folders the list never walks, beside every dot-folder. */
|
|
@@ -87,9 +93,32 @@ export function readAppPropsCatalog(path) {
|
|
|
87
93
|
*/
|
|
88
94
|
export function applicationCatalogs(root) {
|
|
89
95
|
const paths = profileCatalogPaths(join(root, 'index.html'));
|
|
96
|
+
const composition = paths.composition.map(readJson);
|
|
97
|
+
const libraryPreviewModules = [
|
|
98
|
+
...new Set(
|
|
99
|
+
composition.flatMap((catalog, index) => {
|
|
100
|
+
if (
|
|
101
|
+
typeof catalog.libraryPreviewModule !== 'string' ||
|
|
102
|
+
!catalog.libraryPreviewModule
|
|
103
|
+
)
|
|
104
|
+
return [];
|
|
105
|
+
try {
|
|
106
|
+
const named = catalog.libraryPreviewModule;
|
|
107
|
+
const file =
|
|
108
|
+
named.startsWith('.') || isAbsolute(named)
|
|
109
|
+
? resolve(dirname(paths.composition[index]), named)
|
|
110
|
+
: createRequire(paths.composition[index]).resolve(named);
|
|
111
|
+
return existsSync(file) ? [file] : [];
|
|
112
|
+
} catch {
|
|
113
|
+
return [];
|
|
114
|
+
}
|
|
115
|
+
}),
|
|
116
|
+
),
|
|
117
|
+
];
|
|
90
118
|
return {
|
|
91
119
|
props: paths.props.map(readAppPropsCatalog),
|
|
92
|
-
composition
|
|
120
|
+
composition,
|
|
121
|
+
libraryPreviewModules,
|
|
93
122
|
};
|
|
94
123
|
}
|
|
95
124
|
|
|
@@ -144,8 +173,65 @@ const send = (response, status, body, type = 'text/plain; charset=utf-8') => {
|
|
|
144
173
|
* itself in git.
|
|
145
174
|
*/
|
|
146
175
|
export function editorFileMiddleware(root) {
|
|
147
|
-
|
|
176
|
+
const types = projectTypeWorker(root);
|
|
177
|
+
const middleware = async (request, response, next) => {
|
|
148
178
|
const url = new URL(request.url ?? '/', 'http://localhost');
|
|
179
|
+
if (url.pathname === KERF_UI_EDITOR_TYPES_API) {
|
|
180
|
+
if (request.method !== 'POST') {
|
|
181
|
+
send(response, 405, 'Use POST.');
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
if (request.headers[KERF_UI_EDITOR_HEADER] !== '1') {
|
|
185
|
+
send(response, 403, 'Type requests come from the editor only.');
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
let text = '';
|
|
189
|
+
let body;
|
|
190
|
+
try {
|
|
191
|
+
for await (const chunk of request) {
|
|
192
|
+
text += chunk;
|
|
193
|
+
if (Buffer.byteLength(text) > 1024 * 1024) {
|
|
194
|
+
send(response, 413, 'Type request is too large.');
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
body = JSON.parse(text);
|
|
199
|
+
if (
|
|
200
|
+
!editorFilePath(root, body.source) ||
|
|
201
|
+
!['analyze', 'validate'].includes(body.action) ||
|
|
202
|
+
(body.action === 'analyze' &&
|
|
203
|
+
(typeof body.text !== 'string' ||
|
|
204
|
+
(body.cursor !== undefined && !Number.isInteger(body.cursor)) ||
|
|
205
|
+
(body.suggest !== undefined &&
|
|
206
|
+
typeof body.suggest !== 'boolean'))) ||
|
|
207
|
+
(body.action === 'validate' &&
|
|
208
|
+
(!body.document ||
|
|
209
|
+
typeof body.document !== 'object' ||
|
|
210
|
+
Array.isArray(body.document)))
|
|
211
|
+
) {
|
|
212
|
+
send(
|
|
213
|
+
response,
|
|
214
|
+
400,
|
|
215
|
+
'Name a project document and a valid type request.',
|
|
216
|
+
);
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
} catch (error) {
|
|
220
|
+
send(
|
|
221
|
+
response,
|
|
222
|
+
400,
|
|
223
|
+
error instanceof Error ? error.message : String(error),
|
|
224
|
+
);
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
// The analysis runs in the worker, so this server keeps answering
|
|
228
|
+
// every other request (a Play page, a file save) meanwhile.
|
|
229
|
+
const reply = await types.request(body);
|
|
230
|
+
if ('result' in reply)
|
|
231
|
+
send(response, 200, JSON.stringify(reply.result), 'application/json');
|
|
232
|
+
else send(response, reply.status, reply.error);
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
149
235
|
if (url.pathname === KERF_UI_EDITOR_LIST_API) {
|
|
150
236
|
if (request.method !== 'GET') {
|
|
151
237
|
send(response, 405, 'Use GET.');
|
|
@@ -221,6 +307,70 @@ export function editorFileMiddleware(root) {
|
|
|
221
307
|
);
|
|
222
308
|
}
|
|
223
309
|
};
|
|
310
|
+
// Stops the type worker; the server calls it when it closes.
|
|
311
|
+
middleware.dispose = () => types.dispose();
|
|
312
|
+
return middleware;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* The project-type service in a worker thread for `root`, created on the
|
|
317
|
+
* first request and again after a crash (KF-EQFF9K: TypeScript's synchronous
|
|
318
|
+
* work used to run on the server's event loop, so every other response
|
|
319
|
+
* waited behind it). `request(body)` posts a validated type request and
|
|
320
|
+
* resolves `{ result }`, or `{ status, error }`: 400 for a request the
|
|
321
|
+
* service rejects, 500 when the worker fails. A crash fails the requests in
|
|
322
|
+
* flight. The worker never keeps the process alive. Internal; `entry`
|
|
323
|
+
* replaces the worker module in tests.
|
|
324
|
+
*/
|
|
325
|
+
export function projectTypeWorker(
|
|
326
|
+
root,
|
|
327
|
+
entry = new URL('./view/project-types-worker.mjs', import.meta.url),
|
|
328
|
+
) {
|
|
329
|
+
let worker;
|
|
330
|
+
let nextId = 0;
|
|
331
|
+
const pending = new Map();
|
|
332
|
+
const fail = (message) => {
|
|
333
|
+
for (const settle of pending.values())
|
|
334
|
+
settle({ status: 500, error: message });
|
|
335
|
+
pending.clear();
|
|
336
|
+
};
|
|
337
|
+
const start = () => {
|
|
338
|
+
const current = new Worker(entry, { workerData: { root } });
|
|
339
|
+
current.unref();
|
|
340
|
+
current.on('message', ({ id, result, error }) => {
|
|
341
|
+
const settle = pending.get(id);
|
|
342
|
+
pending.delete(id);
|
|
343
|
+
settle?.(error === undefined ? { result } : { status: 400, error });
|
|
344
|
+
});
|
|
345
|
+
const lost = (message) => {
|
|
346
|
+
if (worker !== current) return;
|
|
347
|
+
worker = undefined;
|
|
348
|
+
fail(message);
|
|
349
|
+
};
|
|
350
|
+
current.on('error', (error) =>
|
|
351
|
+
lost(`The type service failed: ${error.message}`),
|
|
352
|
+
);
|
|
353
|
+
current.on('exit', (code) =>
|
|
354
|
+
lost(`The type service stopped (exit code ${code}).`),
|
|
355
|
+
);
|
|
356
|
+
return current;
|
|
357
|
+
};
|
|
358
|
+
return {
|
|
359
|
+
request(body) {
|
|
360
|
+
worker ??= start();
|
|
361
|
+
const id = nextId++;
|
|
362
|
+
return new Promise((settle) => {
|
|
363
|
+
pending.set(id, settle);
|
|
364
|
+
worker.postMessage({ id, body });
|
|
365
|
+
});
|
|
366
|
+
},
|
|
367
|
+
dispose() {
|
|
368
|
+
const current = worker;
|
|
369
|
+
worker = undefined;
|
|
370
|
+
fail('The type service was disposed.');
|
|
371
|
+
return current?.terminate();
|
|
372
|
+
},
|
|
373
|
+
};
|
|
224
374
|
}
|
|
225
375
|
|
|
226
376
|
/** The page the route serves; Vite injects its client into it. */
|
|
@@ -251,6 +401,7 @@ export function editorEntry({
|
|
|
251
401
|
app,
|
|
252
402
|
registry,
|
|
253
403
|
fieldEditors,
|
|
404
|
+
libraryPreviews,
|
|
254
405
|
devicePresets,
|
|
255
406
|
playHandlers,
|
|
256
407
|
}) {
|
|
@@ -289,6 +440,13 @@ export function editorEntry({
|
|
|
289
440
|
registry
|
|
290
441
|
? `import registry from ${JSON.stringify(registry)};`
|
|
291
442
|
: 'const registry = {};',
|
|
443
|
+
...(app.libraryPreviewModules ?? []).map(
|
|
444
|
+
(module, index) =>
|
|
445
|
+
`import libraryPreview${index} from ${JSON.stringify(module)};`,
|
|
446
|
+
),
|
|
447
|
+
libraryPreviews
|
|
448
|
+
? `import libraryPreviews from ${JSON.stringify(libraryPreviews)};`
|
|
449
|
+
: 'const libraryPreviews = undefined;',
|
|
292
450
|
fieldEditors
|
|
293
451
|
? `import fieldEditors from ${JSON.stringify(fieldEditors)};`
|
|
294
452
|
: 'const fieldEditors = undefined;',
|
|
@@ -309,9 +467,10 @@ export function editorEntry({
|
|
|
309
467
|
' composition: [kerfComposition, ...appComposition],',
|
|
310
468
|
' selection: [kerfSelection],',
|
|
311
469
|
' components: { ...componentMap(props, modules), ...registry },',
|
|
470
|
+
` libraryPreviews: { ${(app.libraryPreviewModules ?? []).map((_module, index) => `...libraryPreview${index}`).join(', ')} },`,
|
|
312
471
|
'});',
|
|
313
472
|
"const root = document.getElementById('kerf-ui-editor');",
|
|
314
|
-
'const editor = createEditor({ catalog, storage: devServerStorage(), fieldEditors, devicePresets, playHandlers });',
|
|
473
|
+
'const editor = createEditor({ catalog, storage: devServerStorage(), fieldEditors, devicePresets, playHandlers, libraryPreviews });',
|
|
315
474
|
'mount(root, editor.render);',
|
|
316
475
|
'editor.wire(root);',
|
|
317
476
|
'',
|
|
@@ -348,6 +507,9 @@ export function kerfUiEditor(options = {}) {
|
|
|
348
507
|
app: applicationCatalogs(root),
|
|
349
508
|
registry: found(options.registry ?? DEFAULT_REGISTRY),
|
|
350
509
|
fieldEditors: found(options.fieldEditors ?? DEFAULT_FIELD_EDITORS),
|
|
510
|
+
libraryPreviews: found(
|
|
511
|
+
options.libraryPreviews ?? DEFAULT_LIBRARY_PREVIEWS,
|
|
512
|
+
),
|
|
351
513
|
// KF-R7KXSN: play mode's extra or replacement device presets.
|
|
352
514
|
devicePresets: options.devicePresets
|
|
353
515
|
? found(options.devicePresets)
|
|
@@ -359,7 +521,9 @@ export function kerfUiEditor(options = {}) {
|
|
|
359
521
|
});
|
|
360
522
|
},
|
|
361
523
|
configureServer(server) {
|
|
362
|
-
|
|
524
|
+
const files = editorFileMiddleware(root);
|
|
525
|
+
server.httpServer?.once('close', files.dispose);
|
|
526
|
+
server.middlewares.use(files);
|
|
363
527
|
server.middlewares.use(async (request, response, next) => {
|
|
364
528
|
const path = (request.url ?? '').split(/[?#]/)[0];
|
|
365
529
|
if (path !== route && `${path}/` !== route) {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/layout/column-track/column-track.tsx"],"names":[],"mappings":";;;AAUA,IAAM,uCAAuB,IAAI,GAAA,CAAI,CAAC,gBAAA,EAAkB,aAAa,CAAC,CAAA;AAEtE,IAAM,2BAAA,GAA8B,CAAC,MAAA,EAAQ,YAAY,CAAA;AA0ClD,SAAS,WAAA,CAAY;AAAA,EAC1B,QAAA;AAAA,EACA,MAAA,GAAS,QAAA;AAAA,EACT,cAAA;AAAA,EACA,IAAA;AAAA,EACA,SAAA;AAAA,EACA,EAAA;AAAA,EACA,SAAA,GAAY,EAAA;AAAA,EACZ,iBAAiB,EAAC;AAAA,EAClB;AACF,CAAA,EAAqB;AACnB,EAAA,MAAM,KAAA,GAAQ;AAAA,IACZ,cAAA,KAAmB,MAAA,GACf,EAAA,GACA,CAAA,8BAAA,EAAiC,cAAc,CAAA,CAAA;AAAA,IACnD,IAAA,KAAS,MAAA,GAAY,EAAA,GAAK,CAAA,yBAAA,EAA4B,IAAI,CAAA;AAAA,GAC5D,CACG,MAAA,CAAO,OAAO,CAAA,CACd,KAAK,GAAG,CAAA;AACX,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACE,GAAG,oBAAA;AAAA,QACF,cAAA;AAAA,QACA,SAAA,uBACQ,GAAA,CAAI,CAAC,GAAG,oBAAA,EAAsB,GAAG,2BAA2B,CAAC,CAAA,GACjE;AAAA,OACN;AAAA,MACC,GAAI,YAAY,EAAE,IAAA,EAAM,UAAU,YAAA,EAAc,SAAA,KAAc,EAAC;AAAA,MAChE,EAAA;AAAA,MACA,KAAA,EAAO,CAAA,iBAAA,EAAoB,SAAS,CAAA,CAAA,CAAG,IAAA,EAAK;AAAA,MAC5C,gBAAA,EAAe,cAAA;AAAA,MACf,aAAA,EAAa,MAAA;AAAA,MACb,OAAO,KAAA,IAAS,MAAA;AAAA,MAChB,IAAA;AAAA,MAEA,QAAA,kBAAA,GAAA,CAAC,KAAA,EAAA,EAAI,KAAA,EAAM,2BAAA,EAA6B,QAAA,EAAS;AAAA;AAAA,GACnD;AAEJ","file":"chunk-34FWYJX6.js","sourcesContent":["import type { KerfUiContent } from '../../../shared/content/semantic-content.js';\nimport {\n filterRootAttributes,\n type StructuralRootAttributes,\n} from '../../../shared/dom/extension-attributes.js';\nimport type { CssLength } from '../../../shared/styles/css-values.js';\n\n/** `scroll` keeps equal min-width columns; `paged` shows one near-full-width column per page. */\nexport type ColumnTrackLayout = 'scroll' | 'paged';\n\nconst columnTrackProtected = new Set(['data-component', 'data-layout']);\n/** Attributes a named track owns as a region. */\nconst columnTrackRegionAttributes = ['role', 'aria-label'];\n\ntype ColumnTrackRootAttributes = StructuralRootAttributes &\n Readonly<{ 'data-component'?: never; 'data-layout'?: never }>;\n\nexport interface ColumnTrackProps {\n /** The columns, in order; each owns its own inset and scrolling. */\n children: KerfUiContent;\n /**\n * `scroll` (default): equal columns that never shrink below\n * `minColumnWidth`, so a narrow track scrolls sideways instead of crushing\n * them. `paged`: each column is nearly the visible width, the next one peeks\n * in, and scrolling snaps to column starts.\n */\n layout?: ColumnTrackLayout;\n /** Narrowest a `scroll` column gets before the track scrolls; default 250px. */\n minColumnWidth?: CssLength;\n /** How much of the next column a `paged` track shows; default 24px. */\n peek?: CssLength;\n /**\n * Name the track (a board) for assistive technology: the scroller becomes\n * a `role=\"region\"` landmark with this `aria-label`. Name each column with\n * `List landmark=\"region\"` and its own `ariaLabel`.\n */\n ariaLabel?: string;\n id?: string;\n className?: string;\n /**\n * Safe `data-*`, `aria-*`, and structural `role` metadata on the scroller;\n * with `ariaLabel` the track owns its role and name.\n */\n rootAttributes?: ColumnTrackRootAttributes;\n /** Native named-slot assignment when composed inside a web component. */\n slot?: string;\n}\n\n/**\n * A horizontal track of columns (a kanban board): the track is the sideways\n * scroll owner and fills its parent's height; columns sit flush and own their\n * insets and vertical scrolling. Kerf owns the overflow, the paged snapping,\n * and reduced motion.\n */\nexport function ColumnTrack({\n children,\n layout = 'scroll',\n minColumnWidth,\n peek,\n ariaLabel,\n id,\n className = '',\n rootAttributes = {},\n slot,\n}: ColumnTrackProps) {\n const style = [\n minColumnWidth === undefined\n ? ''\n : `--_kui-column-track-min-width:${minColumnWidth}`,\n peek === undefined ? '' : `--_kui-column-track-peek:${peek}`,\n ]\n .filter(Boolean)\n .join(';');\n return (\n <div\n {...filterRootAttributes(\n rootAttributes,\n ariaLabel\n ? new Set([...columnTrackProtected, ...columnTrackRegionAttributes])\n : columnTrackProtected,\n )}\n {...(ariaLabel ? { role: 'region', 'aria-label': ariaLabel } : {})}\n id={id}\n class={`kui-column-track ${className}`.trim()}\n data-component=\"column-track\"\n data-layout={layout}\n style={style || undefined}\n slot={slot}\n >\n <div class=\"kui-column-track__columns\">{children}</div>\n </div>\n );\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/composition/panels/panel-toolbar.tsx"],"names":[],"mappings":";;;;;;;;;AAsCO,SAAS,0BAAA,CACd,MACA,SAAA,EACkE;AAClE,EAAA,IAAI,IAAA,KAAS,MAAA;AACX,IAAA,OAAO,SAAA,GACH,EAAE,IAAA,EAAM,aAAA,EAAe,IAAA,EAAM,iBAAA,EAAkB,GAC/C,EAAE,IAAA,EAAM,cAAA,EAAgB,IAAA,EAAM,kBAAA,EAAmB;AACvD,EAAA,IAAI,IAAA,KAAS,OAAA;AACX,IAAA,OAAO,SAAA,GACH,EAAE,IAAA,EAAM,cAAA,EAAgB,IAAA,EAAM,kBAAA,EAAmB,GACjD,EAAE,IAAA,EAAM,eAAA,EAAiB,IAAA,EAAM,mBAAA,EAAoB;AACzD,EAAA,OAAO,SAAA,GACH,EAAE,IAAA,EAAM,eAAA,EAAiB,IAAA,EAAM,mBAAA,EAAoB,GACnD,EAAE,IAAA,EAAM,gBAAA,EAAkB,IAAA,EAAM,oBAAA,EAAqB;AAC3D;AAgEA,SAAS,eAAA,CAAgB,SAAwB,MAAA,EAAqB;AACpE,EAAA,uBACE,GAAA;AAAA,IAAC,IAAA;AAAA,IAAA;AAAA,MACC,cAAc,MAAA,EAAQ,YAAA;AAAA,MACtB,KAAK,MAAA,EAAQ,GAAA;AAAA,MACb,QAAQ,MAAA,EAAQ,MAAA;AAAA,MAChB,QAAQ,MAAA,EAAQ,MAAA;AAAA,MAChB,YAAY,MAAA,EAAQ,UAAA;AAAA,MACpB,eAAe,MAAA,EAAQ,aAAA;AAAA,MAEtB,QAA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;AACjC,EAAA,MAAM,OAAA,GAAU,CAAC,OAAA,KAAiC;AAChD,IAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,OAAO,CAAA,EAAG;AAC1B,MAAA,KAAA,MAAW,IAAA,IAAQ,OAAA,EAAS,OAAA,CAAQ,IAAI,CAAA;AAAA,IAC1C,CAAA,MAAA,IAAW,kBAAA,CAAmB,OAAO,CAAA,EAAG;AACtC,MAAA,MAAA,CAAO,KAAK,OAAO,CAAA;AAAA,IACrB;AAAA,EACF,CAAA;AACA,EAAA,OAAA,CAAQ,QAAQ,OAAO,CAAA;AACvB,EAAA,OAAA,CAAQ,QAAQ,MAAM,CAAA;AACtB,EAAA,OAAA,CAAQ,QAAQ,QAAQ,CAAA;AACxB,EAAA,OAAO;AAAA,IACL,GAAG,MAAA;AAAA,IACH,OAAA,CAAQ,SACJ,gBAAA,CAAiB,IAAA,EAAM,QAAQ,MAAA,EAAQ,IAAA,EAAM,UAAA,EAAY,IAAI,CAAA,GAC7D;AAAA,GACN,CAAE,OAAO,CAAC,KAAA,KAAU,UAAU,MAAA,IAAa,KAAA,KAAU,IAAA,IAAQ,KAAA,KAAU,KAAK,CAAA;AAC9E","file":"chunk-3ZKUXWAV.js","sourcesContent":["import type { SafeHtml } from 'kerfjs';\nimport {\n PanelBottomClose,\n PanelBottomOpen,\n PanelLeftClose,\n PanelLeftOpen,\n PanelRightClose,\n PanelRightOpen,\n} from 'lucide';\n\nimport {\n Toolbar,\n type ToolbarConfig,\n} from '../../components/actions/toolbar/toolbar.js';\nimport {\n ToolbarControlGroup,\n type ToolbarControlGroupSize,\n} from '../../components/actions/toolbar-control-group/toolbar-control-group.js';\nimport {\n List,\n type ListConfig,\n} from '../../components/collections/list/list.js';\nimport { paneConfigProps } from '../../components/layout/pane/model/pane-config-props.js';\nimport { Pane, type PaneConfig } from '../../components/layout/pane/pane.js';\nimport { LucideIcon } from '../../components/media/lucide-icon/lucide-icon.js';\nimport type { KerfUiContent } from '../../shared/content/semantic-content.js';\nimport { isRelocatableGroup } from '../../shared/toolbar/panel-toolbar-group.js';\n\n/** Which edge a collapsible panel docks to. */\nexport type PanelSide = 'left' | 'right' | 'bottom';\n\n/**\n * The standard collapse/expand icon for a panel `side` and `collapsed` state,\n * so every app's sidebars and drawers use one recognizable convention:\n * `PanelLeft*` for a left rail, `PanelRight*` for a right rail, `PanelBottom*`\n * for a bottom drawer — the `Close` glyph while open, the `Open` glyph while\n * collapsed. Exposed so an app can render its own toggle affordance.\n */\nexport function collapsiblePanelToggleIcon(\n side: PanelSide,\n collapsed: boolean,\n): { icon: Parameters<typeof LucideIcon>[0]['icon']; name: string } {\n if (side === 'left')\n return collapsed\n ? { icon: PanelLeftOpen, name: 'panel-left-open' }\n : { icon: PanelLeftClose, name: 'panel-left-close' };\n if (side === 'right')\n return collapsed\n ? { icon: PanelRightOpen, name: 'panel-right-open' }\n : { icon: PanelRightClose, name: 'panel-right-close' };\n return collapsed\n ? { icon: PanelBottomOpen, name: 'panel-bottom-open' }\n : { icon: PanelBottomClose, name: 'panel-bottom-close' };\n}\n\n/**\n * The standard collapse toggle a panel toolbar renders. The app handles the\n * button's `data-action` and flips its own `collapsed` flag.\n */\nexport interface PanelToggle {\n /** The `data-action` the toggle button carries. */\n action: string;\n /**\n * The panel's short title-style name (\"Navigator\", \"Build Output\"). It is\n * the toggle group's accessible name and completes the default \"Show …\" /\n * \"Hide …\" label (\"Show Navigator\"), so it follows the title-style rule in\n * `docs/writing.md`; it is never recapitalized.\n */\n name: string;\n /** Accessible label while the panel is collapsed. Defaults to `Show {name}`. */\n showLabel?: string;\n /** Accessible label while the panel is open. Defaults to `Hide {name}`. */\n hideLabel?: string;\n}\n\n/**\n * A collapsible panel's top toolbar, composed so its groups follow the\n * panel's open state.\n *\n * - `title` precedes the `leading` zone. Groups may appear in any of the\n * `leading`, `center`, and `trailing` zones while the panel is open.\n * - Groups marked `relocateOnCollapse` move to the work area's toolbar while\n * the panel is collapsed, preserving their order across the three zones.\n * - `toggle` is always the last group: in the panel's toolbar while it is\n * open, and right after the relocated groups in the work area's toolbar\n * while it is collapsed.\n *\n * Relocated content renders in both places while the panel is collapsed (the\n * panel's copy is inert), so give it no `id`s. Pass groups directly or in\n * arrays so their render-time annotation remains available to the panel.\n *\n * The toolbar's configuration (`dividerSides`, `centerAlign`, `responsive`,\n * `responsiveAt`, `safeAreaEdges`) forwards to its `Toolbar`. It draws no\n * divider of its own: the panel's `Pane` draws the line under it while the\n * content is scrolled (its `chromeDividers`, wired by `wireScrollDividers`).\n */\nexport interface PanelToolbar extends ToolbarConfig {\n /** Accessible name of the panel's toolbar. */\n label: string;\n title?: KerfUiContent;\n leading?: KerfUiContent;\n center?: KerfUiContent;\n trailing?: KerfUiContent;\n toggle?: PanelToggle;\n}\n\n/** A panel's fixed bottom toolbar, below its optional footer content. */\nexport interface PanelBottomToolbar extends ToolbarConfig {\n label: string;\n leading?: KerfUiContent;\n center?: KerfUiContent;\n trailing?: KerfUiContent;\n}\n\n/** Whether panel chrome stays fixed, scrolls, or follows Pane's auto rule. */\nexport type PanelChromePlacement = 'fixed' | 'scroll' | 'auto';\n\nfunction panelChromeList(content: KerfUiContent, config?: ListConfig) {\n return (\n <List\n dividerSides={config?.dividerSides}\n gap={config?.gap}\n hAlign={config?.hAlign}\n vAlign={config?.vAlign}\n textInsets={config?.textInsets}\n controlInsets={config?.controlInsets}\n >\n {content}\n </List>\n );\n}\n\n/** Owner-specific attributes a toggle button carries (its wiring hooks). */\nexport type PanelToggleAttributes = Readonly<Record<string, string>>;\n\n/** The group size that fits a toolbar of this density. */\nexport function groupSizeFor(\n density: ToolbarConfig['density'],\n): ToolbarControlGroupSize {\n return density === 'compact' ? 'compact' : 'default';\n}\n\n/** The standard toggle, alone in a borderless group. */\nexport function panelToggleGroup(\n side: PanelSide,\n toggle: PanelToggle,\n collapsed: boolean,\n attributes: PanelToggleAttributes,\n size: ToolbarControlGroupSize = 'default',\n): SafeHtml {\n const glyph = collapsiblePanelToggleIcon(side, collapsed);\n return (\n <ToolbarControlGroup\n label={toggle.name}\n appearance=\"borderless\"\n size={size}\n single\n >\n <button\n type=\"button\"\n {...attributes}\n data-action={toggle.action}\n aria-expanded={String(!collapsed)}\n aria-label={\n collapsed\n ? (toggle.showLabel ?? `Show ${toggle.name}`)\n : (toggle.hideLabel ?? `Hide ${toggle.name}`)\n }\n >\n <LucideIcon icon={glyph.icon} name={glyph.name} />\n </button>\n </ToolbarControlGroup>\n );\n}\n\n/**\n * The panel's own toolbar: content keeps its chosen zones and the toggle trails.\n */\nexport function composedPanelToolbar(\n toolbar: PanelToolbar,\n side: PanelSide,\n collapsed: boolean,\n attributes: PanelToggleAttributes,\n): SafeHtml {\n return (\n <Toolbar\n label={toolbar.label}\n density={toolbar.density}\n dividerSides={toolbar.dividerSides}\n centerAlign={toolbar.centerAlign}\n responsive={toolbar.responsive}\n responsiveAt={toolbar.responsiveAt}\n safeAreaEdges={toolbar.safeAreaEdges}\n center={toolbar.center}\n leading={\n <>\n {toolbar.title}\n {toolbar.leading}\n </>\n }\n trailing={\n <>\n {toolbar.trailing}\n {toolbar.toggle\n ? panelToggleGroup(\n side,\n toolbar.toggle,\n collapsed,\n attributes,\n groupSizeFor(toolbar.density),\n )\n : null}\n </>\n }\n />\n );\n}\n\n/**\n * A toolbar panel's body: its content in a `Pane` under its composed toolbar,\n * with its optional `footer` below. The panel's `pane` configuration forwards\n * to that `Pane`; an omitted or `undefined` field keeps the `Pane` default.\n */\nexport function composedPanelBody({\n toolbar,\n side,\n collapsed,\n attributes,\n pane,\n header,\n headerList,\n headerPlacement = 'fixed',\n footer,\n footerList,\n bottomToolbar,\n footerPlacement = 'fixed',\n content,\n}: {\n toolbar: PanelToolbar;\n side: PanelSide;\n collapsed: boolean;\n attributes: PanelToggleAttributes;\n pane: PaneConfig | undefined;\n header?: KerfUiContent;\n headerList?: ListConfig;\n headerPlacement?: PanelChromePlacement;\n footer?: KerfUiContent;\n footerList?: ListConfig;\n bottomToolbar?: PanelBottomToolbar;\n footerPlacement?: PanelChromePlacement;\n content: KerfUiContent;\n}): SafeHtml {\n const panelHeader = (\n <>\n {composedPanelToolbar(toolbar, side, collapsed, attributes)}\n {header ? panelChromeList(header, headerList) : null}\n </>\n );\n const panelFooter =\n footer || bottomToolbar ? (\n <>\n {footer ? panelChromeList(footer, footerList) : null}\n {bottomToolbar ? (\n <Toolbar\n position=\"footer\"\n label={bottomToolbar.label}\n density={bottomToolbar.density}\n dividerSides={bottomToolbar.dividerSides}\n centerAlign={bottomToolbar.centerAlign}\n responsive={bottomToolbar.responsive}\n responsiveAt={bottomToolbar.responsiveAt}\n safeAreaEdges={bottomToolbar.safeAreaEdges}\n leading={bottomToolbar.leading}\n center={bottomToolbar.center}\n trailing={bottomToolbar.trailing}\n />\n ) : null}\n </>\n ) : undefined;\n const scrollHeader = headerPlacement === 'scroll';\n const scrollFooter = footerPlacement === 'scroll';\n return (\n <Pane\n header={scrollHeader ? undefined : panelHeader}\n footer={scrollFooter ? undefined : panelFooter}\n chromePlacement={\n headerPlacement === 'auto' || footerPlacement === 'auto'\n ? 'auto'\n : 'fixed'\n }\n {...paneConfigProps(pane)}\n >\n {scrollHeader ? panelHeader : null}\n {content}\n {scrollFooter ? panelFooter : null}\n </Pane>\n );\n}\n\n/**\n * The groups a collapsed panel hands to the work area, in zone order, then its\n * toggle. Empty while the panel is open or has no toolbar.\n */\nexport function relocatedPanelGroups(\n toolbar: PanelToolbar | undefined,\n side: PanelSide,\n collapsed: boolean,\n attributes: PanelToggleAttributes,\n size: ToolbarControlGroupSize = 'default',\n): KerfUiContent[] {\n if (!collapsed || !toolbar) return [];\n const groups: KerfUiContent[] = [];\n const collect = (content: KerfUiContent): void => {\n if (Array.isArray(content)) {\n for (const item of content) collect(item);\n } else if (isRelocatableGroup(content)) {\n groups.push(content);\n }\n };\n collect(toolbar.leading);\n collect(toolbar.center);\n collect(toolbar.trailing);\n return [\n ...groups,\n toolbar.toggle\n ? panelToggleGroup(side, toolbar.toggle, true, attributes, size)\n : null,\n ].filter((group) => group !== undefined && group !== null && group !== false);\n}\n"]}
|