schema-components 2.0.2 → 2.1.0
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/README.md +98 -1
- package/dist/SchemaComponent-B__6-5-E.d.mts +277 -0
- package/dist/SchemaComponent-BxzzsHsK.mjs +668 -0
- package/dist/adapter-ktQaheWB.d.mts +213 -0
- package/dist/constructorTypes-BdCiMS6e.d.mts +30 -0
- package/dist/core/adapter.d.mts +3 -213
- package/dist/core/constraintHint.d.mts +1 -1
- package/dist/core/constraints.d.mts +2 -2
- package/dist/core/contexts.d.mts +71 -0
- package/dist/core/contexts.mjs +1 -0
- package/dist/core/diagnostics.d.mts +1 -1
- package/dist/core/errors.d.mts +1 -1
- package/dist/core/fieldOrder.d.mts +1 -1
- package/dist/{react → core}/fieldPath.d.mts +2 -2
- package/dist/{react → core}/fieldPath.mjs +3 -3
- package/dist/core/formats.d.mts +1 -1
- package/dist/core/inferValue.d.mts +1 -1
- package/dist/core/limits.d.mts +1 -1
- package/dist/core/merge.d.mts +1 -1
- package/dist/core/normalise.d.mts +2 -2
- package/dist/core/ref.d.mts +1 -1
- package/dist/core/renderField.d.mts +147 -0
- package/dist/core/renderField.mjs +81 -0
- package/dist/core/renderer.d.mts +2 -199
- package/dist/core/swagger2.d.mts +1 -1
- package/dist/core/typeInference.d.mts +1 -982
- package/dist/core/types.d.mts +1 -1
- package/dist/core/unionMatch.d.mts +1 -1
- package/dist/core/version.d.mts +1 -1
- package/dist/core/walkBuilders.d.mts +3 -3
- package/dist/core/walker.d.mts +1 -1
- package/dist/{errors-Dki7tji4.d.mts → errors-DbaI04x2.d.mts} +1 -1
- package/dist/html/a11y.d.mts +2 -2
- package/dist/html/renderToHtml.d.mts +5 -5
- package/dist/html/renderToHtml.mjs +33 -18
- package/dist/html/renderToHtmlStream.d.mts +5 -5
- package/dist/html/renderers.d.mts +1 -1
- package/dist/html/streamRenderers.d.mts +3 -3
- package/dist/{inferValue-Ce-PviSD.d.mts → inferValue-eAnh50EM.d.mts} +3 -3
- package/dist/lit/SchemaComponent.d.mts +125 -0
- package/dist/lit/SchemaComponent.mjs +2 -0
- package/dist/lit/SchemaField.d.mts +65 -0
- package/dist/lit/SchemaField.mjs +2 -0
- package/dist/lit/SchemaView.d.mts +14 -0
- package/dist/lit/SchemaView.mjs +2 -0
- package/dist/lit/constructorTypes.d.mts +2 -0
- package/dist/lit/constructorTypes.mjs +1 -0
- package/dist/lit/contexts.d.mts +78 -0
- package/dist/lit/contexts.mjs +238 -0
- package/dist/lit/defaultResolver.d.mts +33 -0
- package/dist/lit/defaultResolver.mjs +2 -0
- package/dist/lit/registry.d.mts +66 -0
- package/dist/lit/registry.mjs +2 -0
- package/dist/lit/renderers/baseElement.d.mts +131 -0
- package/dist/lit/renderers/baseElement.mjs +109 -0
- package/dist/lit/renderers/recordHelpers.d.mts +25 -0
- package/dist/lit/renderers/recordHelpers.mjs +55 -0
- package/dist/lit/renderers/scArray.d.mts +14 -0
- package/dist/lit/renderers/scArray.mjs +86 -0
- package/dist/lit/renderers/scBoolean.d.mts +15 -0
- package/dist/lit/renderers/scBoolean.mjs +47 -0
- package/dist/lit/renderers/scConditional.d.mts +23 -0
- package/dist/lit/renderers/scConditional.mjs +65 -0
- package/dist/lit/renderers/scDiscriminated.d.mts +23 -0
- package/dist/lit/renderers/scDiscriminated.mjs +138 -0
- package/dist/lit/renderers/scEnum.d.mts +16 -0
- package/dist/lit/renderers/scEnum.mjs +66 -0
- package/dist/lit/renderers/scFile.d.mts +15 -0
- package/dist/lit/renderers/scFile.mjs +53 -0
- package/dist/lit/renderers/scLiteralNullNever.d.mts +30 -0
- package/dist/lit/renderers/scLiteralNullNever.mjs +57 -0
- package/dist/lit/renderers/scNumber.d.mts +15 -0
- package/dist/lit/renderers/scNumber.mjs +64 -0
- package/dist/lit/renderers/scObject.d.mts +14 -0
- package/dist/lit/renderers/scObject.mjs +57 -0
- package/dist/lit/renderers/scRecord.d.mts +14 -0
- package/dist/lit/renderers/scRecord.mjs +112 -0
- package/dist/lit/renderers/scString.d.mts +19 -0
- package/dist/lit/renderers/scString.mjs +165 -0
- package/dist/lit/renderers/scTuple.d.mts +14 -0
- package/dist/lit/renderers/scTuple.mjs +58 -0
- package/dist/lit/renderers/scUnion.d.mts +14 -0
- package/dist/lit/renderers/scUnion.mjs +44 -0
- package/dist/lit/renderers/scUnknown.d.mts +15 -0
- package/dist/lit/renderers/scUnknown.mjs +45 -0
- package/dist/lit/ssr.d.mts +37 -0
- package/dist/lit/ssr.mjs +9565 -0
- package/dist/lit/types.d.mts +2 -0
- package/dist/lit/types.mjs +1 -0
- package/dist/lit/widget.d.mts +71 -0
- package/dist/lit/widget.mjs +87 -0
- package/dist/openapi/ApiCallbacks.d.mts +1 -1
- package/dist/openapi/ApiLinks.d.mts +1 -1
- package/dist/openapi/ApiResponseHeaders.d.mts +1 -1
- package/dist/openapi/ApiSecurity.d.mts +1 -1
- package/dist/openapi/components.d.mts +4 -4
- package/dist/openapi/parser.d.mts +2 -2
- package/dist/openapi/resolve.d.mts +1 -1
- package/dist/preact/SchemaComponent.d.mts +3 -0
- package/dist/preact/SchemaComponent.mjs +26 -0
- package/dist/preact/SchemaErrorBoundary.d.mts +2 -0
- package/dist/preact/SchemaErrorBoundary.mjs +20 -0
- package/dist/preact/SchemaView.d.mts +2 -0
- package/dist/preact/SchemaView.mjs +22 -0
- package/dist/preact/headless.d.mts +2 -0
- package/dist/preact/headless.mjs +18 -0
- package/dist/react/SchemaComponent.d.mts +3 -270
- package/dist/react/SchemaComponent.mjs +41 -32
- package/dist/react/SchemaView.d.mts +6 -6
- package/dist/react/SchemaView.mjs +32 -29
- package/dist/react/a11y.d.mts +2 -2
- package/dist/react/fieldShell.d.mts +1 -1
- package/dist/react/headless.d.mts +1 -1
- package/dist/react/headlessRenderers.d.mts +2 -2
- package/dist/{ref-DdsbekXX.d.mts → ref-DWrQG1Er.d.mts} +1 -1
- package/dist/renderer-ab9E52Bp.d.mts +245 -0
- package/dist/solid/SchemaComponent.d.mts +136 -0
- package/dist/solid/SchemaComponent.mjs +391 -0
- package/dist/solid/SchemaErrorBoundary.d.mts +38 -0
- package/dist/solid/SchemaErrorBoundary.mjs +57 -0
- package/dist/solid/SchemaField.d.mts +40 -0
- package/dist/solid/SchemaField.mjs +113 -0
- package/dist/solid/SchemaView.d.mts +54 -0
- package/dist/solid/SchemaView.mjs +168 -0
- package/dist/solid/a11y.d.mts +70 -0
- package/dist/solid/a11y.mjs +71 -0
- package/dist/solid/contexts.d.mts +37 -0
- package/dist/solid/contexts.mjs +66 -0
- package/dist/solid/headless.d.mts +10 -0
- package/dist/solid/headless.mjs +27 -0
- package/dist/solid/renderers.d.mts +79 -0
- package/dist/solid/renderers.mjs +840 -0
- package/dist/solid/types.d.mts +90 -0
- package/dist/solid/types.mjs +1 -0
- package/dist/solid/widget.d.mts +29 -0
- package/dist/solid/widget.mjs +35 -0
- package/dist/themes/mantine.d.mts +1 -1
- package/dist/themes/mui.d.mts +1 -1
- package/dist/themes/radix.d.mts +1 -1
- package/dist/themes/shadcn.d.mts +1 -1
- package/dist/typeInference-Y8tNEQJk.d.mts +983 -0
- package/dist/types-BCy7K3nk.d.mts +125 -0
- package/package.json +71 -1
- package/src/svelte/SchemaComponent.svelte +427 -0
- package/src/svelte/SchemaErrorBoundary.svelte +66 -0
- package/src/svelte/SchemaField.svelte +216 -0
- package/src/svelte/SchemaProvider.svelte +46 -0
- package/src/svelte/SchemaView.svelte +244 -0
- package/src/svelte/a11y.ts +112 -0
- package/src/svelte/contexts.ts +79 -0
- package/src/svelte/dispatch.ts +267 -0
- package/src/svelte/headless.ts +73 -0
- package/src/svelte/headlessFns.ts +124 -0
- package/src/svelte/renderers/Array.svelte +98 -0
- package/src/svelte/renderers/Boolean.svelte +43 -0
- package/src/svelte/renderers/Conditional.svelte +67 -0
- package/src/svelte/renderers/DiscriminatedUnion.svelte +197 -0
- package/src/svelte/renderers/Enum.svelte +53 -0
- package/src/svelte/renderers/Fallback.svelte +24 -0
- package/src/svelte/renderers/File.svelte +46 -0
- package/src/svelte/renderers/Literal.svelte +29 -0
- package/src/svelte/renderers/Mount.svelte +24 -0
- package/src/svelte/renderers/Negation.svelte +35 -0
- package/src/svelte/renderers/Never.svelte +24 -0
- package/src/svelte/renderers/Null.svelte +19 -0
- package/src/svelte/renderers/Number.svelte +68 -0
- package/src/svelte/renderers/Object.svelte +74 -0
- package/src/svelte/renderers/Record.svelte +134 -0
- package/src/svelte/renderers/RecursionSentinel.svelte +27 -0
- package/src/svelte/renderers/String.svelte +152 -0
- package/src/svelte/renderers/Tuple.svelte +84 -0
- package/src/svelte/renderers/Union.svelte +49 -0
- package/src/svelte/renderers/Unknown.svelte +42 -0
- package/src/svelte/svelte-modules.d.ts +25 -0
- package/src/svelte/types.ts +238 -0
- package/src/svelte/widget.ts +62 -0
- /package/dist/{diagnostics-BTrm3O6J.d.mts → diagnostics-mftUZI7c.d.mts} +0 -0
- /package/dist/{limits-x4OiyJxh.d.mts → limits-Vv9hUbI_.d.mts} +0 -0
- /package/dist/{types-BrYbjC7_.d.mts → types-BBQaEPfE.d.mts} +0 -0
- /package/dist/{version-DL8U5RuA.d.mts → version-BEBx10ND.d.mts} +0 -0
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/@lit+context@1.1.6/node_modules/@lit/context/lib/context-request-event.js
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2021 Google LLC
|
|
5
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
6
|
+
*/
|
|
7
|
+
var s$2 = class extends Event {
|
|
8
|
+
constructor(s, t, e, o) {
|
|
9
|
+
super("context-request", {
|
|
10
|
+
bubbles: !0,
|
|
11
|
+
composed: !0
|
|
12
|
+
}), this.context = s, this.contextTarget = t, this.callback = e, this.subscribe = o ?? !1;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region ../../node_modules/.pnpm/@lit+context@1.1.6/node_modules/@lit/context/lib/create-context.js
|
|
17
|
+
/**
|
|
18
|
+
* @license
|
|
19
|
+
* Copyright 2021 Google LLC
|
|
20
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
21
|
+
*/
|
|
22
|
+
function n(n) {
|
|
23
|
+
return n;
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region ../../node_modules/.pnpm/@lit+context@1.1.6/node_modules/@lit/context/lib/controllers/context-consumer.js
|
|
27
|
+
/**
|
|
28
|
+
* @license
|
|
29
|
+
* Copyright 2021 Google LLC
|
|
30
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
31
|
+
*/ var s$1 = class {
|
|
32
|
+
constructor(t, s, i, h) {
|
|
33
|
+
if (this.subscribe = !1, this.provided = !1, this.value = void 0, this.t = (t, s) => {
|
|
34
|
+
this.unsubscribe && (this.unsubscribe !== s && (this.provided = !1, this.unsubscribe()), this.subscribe || this.unsubscribe()), this.value = t, this.host.requestUpdate(), this.provided && !this.subscribe || (this.provided = !0, this.callback && this.callback(t, s)), this.unsubscribe = s;
|
|
35
|
+
}, this.host = t, void 0 !== s.context) {
|
|
36
|
+
const t = s;
|
|
37
|
+
this.context = t.context, this.callback = t.callback, this.subscribe = t.subscribe ?? !1;
|
|
38
|
+
} else this.context = s, this.callback = i, this.subscribe = h ?? !1;
|
|
39
|
+
this.host.addController(this);
|
|
40
|
+
}
|
|
41
|
+
hostConnected() {
|
|
42
|
+
this.dispatchRequest();
|
|
43
|
+
}
|
|
44
|
+
hostDisconnected() {
|
|
45
|
+
this.unsubscribe && (this.unsubscribe(), this.unsubscribe = void 0);
|
|
46
|
+
}
|
|
47
|
+
dispatchRequest() {
|
|
48
|
+
this.host.dispatchEvent(new s$2(this.context, this.host, this.t, this.subscribe));
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region ../../node_modules/.pnpm/@lit+context@1.1.6/node_modules/@lit/context/lib/value-notifier.js
|
|
53
|
+
/**
|
|
54
|
+
* @license
|
|
55
|
+
* Copyright 2021 Google LLC
|
|
56
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
57
|
+
*/
|
|
58
|
+
var s = class {
|
|
59
|
+
get value() {
|
|
60
|
+
return this.o;
|
|
61
|
+
}
|
|
62
|
+
set value(s) {
|
|
63
|
+
this.setValue(s);
|
|
64
|
+
}
|
|
65
|
+
setValue(s, t = !1) {
|
|
66
|
+
const i = t || !Object.is(s, this.o);
|
|
67
|
+
this.o = s, i && this.updateObservers();
|
|
68
|
+
}
|
|
69
|
+
constructor(s) {
|
|
70
|
+
this.subscriptions = /* @__PURE__ */ new Map(), this.updateObservers = () => {
|
|
71
|
+
for (const [s, { disposer: t }] of this.subscriptions) s(this.o, t);
|
|
72
|
+
}, void 0 !== s && (this.value = s);
|
|
73
|
+
}
|
|
74
|
+
addCallback(s, t, i) {
|
|
75
|
+
if (!i) return void s(this.value);
|
|
76
|
+
this.subscriptions.has(s) || this.subscriptions.set(s, {
|
|
77
|
+
disposer: () => {
|
|
78
|
+
this.subscriptions.delete(s);
|
|
79
|
+
},
|
|
80
|
+
consumerHost: t
|
|
81
|
+
});
|
|
82
|
+
const { disposer: h } = this.subscriptions.get(s);
|
|
83
|
+
s(this.value, h);
|
|
84
|
+
}
|
|
85
|
+
clearCallbacks() {
|
|
86
|
+
this.subscriptions.clear();
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region ../../node_modules/.pnpm/@lit+context@1.1.6/node_modules/@lit/context/lib/controllers/context-provider.js
|
|
91
|
+
/**
|
|
92
|
+
* @license
|
|
93
|
+
* Copyright 2021 Google LLC
|
|
94
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
95
|
+
*/ var e = class extends Event {
|
|
96
|
+
constructor(t, s) {
|
|
97
|
+
super("context-provider", {
|
|
98
|
+
bubbles: !0,
|
|
99
|
+
composed: !0
|
|
100
|
+
}), this.context = t, this.contextTarget = s;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
var i = class extends s {
|
|
104
|
+
constructor(s, e, i) {
|
|
105
|
+
super(void 0 !== e.context ? e.initialValue : i), this.onContextRequest = (t) => {
|
|
106
|
+
if (t.context !== this.context) return;
|
|
107
|
+
const s = t.contextTarget ?? t.composedPath()[0];
|
|
108
|
+
s !== this.host && (t.stopPropagation(), this.addCallback(t.callback, s, t.subscribe));
|
|
109
|
+
}, this.onProviderRequest = (s) => {
|
|
110
|
+
if (s.context !== this.context) return;
|
|
111
|
+
if ((s.contextTarget ?? s.composedPath()[0]) === this.host) return;
|
|
112
|
+
const e = /* @__PURE__ */ new Set();
|
|
113
|
+
for (const [s, { consumerHost: i }] of this.subscriptions) e.has(s) || (e.add(s), i.dispatchEvent(new s$2(this.context, i, s, !0)));
|
|
114
|
+
s.stopPropagation();
|
|
115
|
+
}, this.host = s, void 0 !== e.context ? this.context = e.context : this.context = e, this.attachListeners(), this.host.addController?.(this);
|
|
116
|
+
}
|
|
117
|
+
attachListeners() {
|
|
118
|
+
this.host.addEventListener("context-request", this.onContextRequest), this.host.addEventListener("context-provider", this.onProviderRequest);
|
|
119
|
+
}
|
|
120
|
+
hostConnected() {
|
|
121
|
+
this.host.dispatchEvent(new e(this.context, this.host));
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/lit/contexts.ts
|
|
126
|
+
/**
|
|
127
|
+
* Context ports for the Lit adapter.
|
|
128
|
+
*
|
|
129
|
+
* Implements the `ContextPort<T>` abstraction described in the
|
|
130
|
+
* multi-framework research note. The port is the framework-agnostic
|
|
131
|
+
* contract for "provide a value at a parent and consume it at any
|
|
132
|
+
* descendant" — every framework adapter (React `createContext`, Vue
|
|
133
|
+
* `provide`/`inject`, Svelte `setContext`/`getContext`, Lit
|
|
134
|
+
* `@lit/context`) wires the same shape into its native primitive so
|
|
135
|
+
* the core renderer dispatch loop never reaches for a framework-
|
|
136
|
+
* specific API.
|
|
137
|
+
*
|
|
138
|
+
* For Lit, the port is implemented on top of
|
|
139
|
+
* [`@lit/context`](https://lit.dev/docs/data/context/), which uses the
|
|
140
|
+
* proposed [Context Protocol](https://github.com/webcomponents/community-protocols/blob/main/proposals/context.md)
|
|
141
|
+
* — DOM events bubble up from a consumer until a provider catches them
|
|
142
|
+
* and seeds the consumer with the requested value. The protocol is
|
|
143
|
+
* synchronous, DOM-scoped, and runs only in the browser.
|
|
144
|
+
*
|
|
145
|
+
* **SSR caveat.** `@lit/context` does NOT server-render. The Lit SSR
|
|
146
|
+
* package (`@lit-labs/ssr`) emits Custom Element markup without firing
|
|
147
|
+
* the consumer-side context request events, so any value provided via
|
|
148
|
+
* a `ContextPort` is `undefined` on the server. Consumers must default
|
|
149
|
+
* gracefully — the built-in Lit renderers fall back to the default
|
|
150
|
+
* resolver when the resolver context is unset, matching their browser
|
|
151
|
+
* behaviour when no consumer wraps the schema element.
|
|
152
|
+
*
|
|
153
|
+
* **Canonical {@link ContextPort} compatibility.** The canonical
|
|
154
|
+
* {@link ContextPort} interface declared in `core/contexts.ts` is
|
|
155
|
+
* deliberately host-agnostic: `provide(value, children): unknown` and
|
|
156
|
+
* `consume(): T`. Lit's `@lit/context` requires a `ReactiveControllerHost`
|
|
157
|
+
* at every call site to register provider / consumer controllers, so
|
|
158
|
+
* the Lit ports below cannot match the canonical signature directly.
|
|
159
|
+
* Rather than declaring a parallel local `ContextPort<T>` (which would
|
|
160
|
+
* shadow the canonical type), the Lit adapter exports the port objects
|
|
161
|
+
* with inferred local types and re-exports the canonical
|
|
162
|
+
* {@link ContextPort} so consumers retain a single source of truth for
|
|
163
|
+
* the type name.
|
|
164
|
+
*
|
|
165
|
+
* @packageDocumentation
|
|
166
|
+
*/
|
|
167
|
+
/**
|
|
168
|
+
* Context key identifying the {@link LitComponentResolver} provided at
|
|
169
|
+
* a host element. Re-used by every built-in `<sc-*>` Custom Element so
|
|
170
|
+
* a single `<schema-component>` provider seeds the whole subtree —
|
|
171
|
+
* matching the behaviour of `<SchemaProvider>` on the React side.
|
|
172
|
+
*
|
|
173
|
+
* The literal `"sc-resolver"` value is the runtime key carried in the
|
|
174
|
+
* Context Protocol's `context-request` event; consumers and providers
|
|
175
|
+
* must use the same `Context` object (not just the same string) to
|
|
176
|
+
* match, which is why this is exported rather than redeclared per
|
|
177
|
+
* element.
|
|
178
|
+
*/
|
|
179
|
+
const resolverContext = n(Symbol.for("sc-resolver"));
|
|
180
|
+
/**
|
|
181
|
+
* Lit binding wrapping `ContextProvider` / `ContextConsumer` from
|
|
182
|
+
* `@lit/context` for the {@link resolverContext}.
|
|
183
|
+
*
|
|
184
|
+
* The port is host-scoped — both `provide` and `consume` require a
|
|
185
|
+
* `ReactiveControllerHost` reference so `@lit/context` can register
|
|
186
|
+
* its controllers on the element's lifecycle. This is unavoidable
|
|
187
|
+
* given Lit's reactive update model and is the reason the Lit port
|
|
188
|
+
* does not match the canonical {@link ContextPort} signature in
|
|
189
|
+
* `core/contexts.ts` directly — see this module's docstring for the
|
|
190
|
+
* rationale.
|
|
191
|
+
*/
|
|
192
|
+
const resolverContextPort = {
|
|
193
|
+
provide(host, value) {
|
|
194
|
+
const controller = new i(host, {
|
|
195
|
+
context: resolverContext,
|
|
196
|
+
initialValue: value
|
|
197
|
+
});
|
|
198
|
+
return { setValue(next) {
|
|
199
|
+
controller.setValue(next);
|
|
200
|
+
} };
|
|
201
|
+
},
|
|
202
|
+
consume(host) {
|
|
203
|
+
return new s$1(host, {
|
|
204
|
+
context: resolverContext,
|
|
205
|
+
subscribe: true
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
/**
|
|
210
|
+
* Context key for {@link LitWidgetMap}.
|
|
211
|
+
*/
|
|
212
|
+
const widgetsContext = n(Symbol.for("sc-widgets"));
|
|
213
|
+
/**
|
|
214
|
+
* Lit binding wrapping `ContextProvider` / `ContextConsumer` from
|
|
215
|
+
* `@lit/context` for the {@link widgetsContext}. Parallel to
|
|
216
|
+
* {@link resolverContextPort}; see that export for the rationale on
|
|
217
|
+
* why the Lit port is host-scoped rather than matching the canonical
|
|
218
|
+
* {@link ContextPort} signature directly.
|
|
219
|
+
*/
|
|
220
|
+
const widgetsContextPort = {
|
|
221
|
+
provide(host, value) {
|
|
222
|
+
const controller = new i(host, {
|
|
223
|
+
context: widgetsContext,
|
|
224
|
+
initialValue: value
|
|
225
|
+
});
|
|
226
|
+
return { setValue(next) {
|
|
227
|
+
controller.setValue(next);
|
|
228
|
+
} };
|
|
229
|
+
},
|
|
230
|
+
consume(host) {
|
|
231
|
+
return new s$1(host, {
|
|
232
|
+
context: widgetsContext,
|
|
233
|
+
subscribe: true
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
//#endregion
|
|
238
|
+
export { resolverContext, resolverContextPort, widgetsContext, widgetsContextPort };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { j as WalkedField } from "../types-BBQaEPfE.mjs";
|
|
2
|
+
import { t as LitComponentResolver } from "../types-BCy7K3nk.mjs";
|
|
3
|
+
import { RegistrationResult } from "./registry.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/lit/defaultResolver.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Map of every `WalkedField.type` to its matching canonical `<sc-*>`
|
|
8
|
+
* tag. Exhaustive over the discriminated union — adding a new variant
|
|
9
|
+
* to the walker forces a deliberate update here.
|
|
10
|
+
*
|
|
11
|
+
* Exported so theme adapters can introspect the mapping when building
|
|
12
|
+
* their own resolvers (e.g. a shadcn-flavoured Web Components theme
|
|
13
|
+
* that wraps `<sc-string>` in a `<sl-input>`-style shell).
|
|
14
|
+
*/
|
|
15
|
+
declare const TYPE_TO_CANONICAL_TAG: Readonly<Record<WalkedField["type"], string>>;
|
|
16
|
+
/**
|
|
17
|
+
* Build the default Lit resolver for the supplied
|
|
18
|
+
* {@link RegistrationResult}.
|
|
19
|
+
*
|
|
20
|
+
* Each render function emits a Lit `html` template whose body is a
|
|
21
|
+
* dynamically-created `<sc-*>` element with every field prop assigned.
|
|
22
|
+
* The change callback is forwarded directly so user input on a leaf
|
|
23
|
+
* renderer reaches the orchestrator without going through a Custom
|
|
24
|
+
* Event boundary on the fast path.
|
|
25
|
+
*
|
|
26
|
+
* When no `registration` is supplied, the resolver emits the
|
|
27
|
+
* canonical `sc-*` tags. Useful in tests where `customElements.define`
|
|
28
|
+
* may have been called separately and the consumer doesn't need a
|
|
29
|
+
* prefixed registration object.
|
|
30
|
+
*/
|
|
31
|
+
declare function createDefaultLitResolver(registration?: RegistrationResult): LitComponentResolver;
|
|
32
|
+
//#endregion
|
|
33
|
+
export { TYPE_TO_CANONICAL_TAG, createDefaultLitResolver };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { t as Constructor } from "../constructorTypes-BdCiMS6e.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/lit/registry.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Mapping from the canonical built-in tag (without prefix) to the
|
|
6
|
+
* `BaseScElement` subclass that backs it. Exported so consumers can
|
|
7
|
+
* introspect what {@link registerSchemaComponents} will register —
|
|
8
|
+
* useful for diagnostics and for building documentation surfaces.
|
|
9
|
+
*
|
|
10
|
+
* The top-level orchestrator elements (`schema-component`,
|
|
11
|
+
* `schema-view`, `schema-field`) are listed alongside the per-type
|
|
12
|
+
* `<sc-*>` elements; the structural type relaxes to `HTMLElement` so
|
|
13
|
+
* every constructor is assignable.
|
|
14
|
+
*/
|
|
15
|
+
declare const BUILT_IN_ELEMENTS: Readonly<Record<string, Constructor<HTMLElement>>>;
|
|
16
|
+
/**
|
|
17
|
+
* Register every built-in `<sc-*>` Custom Element on the global
|
|
18
|
+
* `customElements` registry, optionally namespaced under `prefix`.
|
|
19
|
+
*
|
|
20
|
+
* Re-registering the same tag is a no-op — `customElements.get(tag)`
|
|
21
|
+
* is checked first so calling this function twice (or alongside
|
|
22
|
+
* another library that registered the same tag) does not throw.
|
|
23
|
+
*
|
|
24
|
+
* @param prefix - Optional prefix prepended to every built-in tag.
|
|
25
|
+
* E.g. `registerSchemaComponents("myapp-")` registers
|
|
26
|
+
* `<myapp-sc-string>`, `<myapp-sc-number>`, …, avoiding collisions
|
|
27
|
+
* with another library that may have shipped its own `<sc-*>`
|
|
28
|
+
* elements. Pass an empty string (the default) to use the
|
|
29
|
+
* canonical names.
|
|
30
|
+
* @returns A {@link RegistrationResult} carrying the canonical-tag →
|
|
31
|
+
* registered-tag map and the list of elements skipped because the
|
|
32
|
+
* tag was already registered. The map is used by the default
|
|
33
|
+
* resolver to look up the right tag when the consumer chose a
|
|
34
|
+
* custom prefix.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* // Default registration — tags are <sc-string>, <sc-number>, ...
|
|
39
|
+
* import { registerSchemaComponents } from "schema-components/lit/registry";
|
|
40
|
+
* const tags = registerSchemaComponents();
|
|
41
|
+
*
|
|
42
|
+
* // Namespaced registration — tags are <myapp-sc-string>, ...
|
|
43
|
+
* const namespaced = registerSchemaComponents("myapp-");
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
declare function registerSchemaComponents(prefix?: string): RegistrationResult;
|
|
47
|
+
/**
|
|
48
|
+
* Return value of {@link registerSchemaComponents}.
|
|
49
|
+
*
|
|
50
|
+
* The `tags` map carries the canonical-tag → registered-tag mapping
|
|
51
|
+
* for every built-in element. The default Lit resolver reads this map
|
|
52
|
+
* to dispatch from a `WalkedField.type` to the matching Custom
|
|
53
|
+
* Element tag — see `lit/renderers/defaultResolver.ts`.
|
|
54
|
+
*
|
|
55
|
+
* The `skipped` array lists tags that were already registered (a
|
|
56
|
+
* second call to `registerSchemaComponents` with the same prefix, or
|
|
57
|
+
* a deliberate consumer-side registration that pre-empted the
|
|
58
|
+
* default). Skipped tags are NOT re-registered — the consumer's
|
|
59
|
+
* implementation wins.
|
|
60
|
+
*/
|
|
61
|
+
interface RegistrationResult {
|
|
62
|
+
tags: Readonly<Record<string, string>>;
|
|
63
|
+
skipped: readonly string[];
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
export { BUILT_IN_ELEMENTS, RegistrationResult, registerSchemaComponents };
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { j as WalkedField, w as SchemaMeta } from "../../types-BBQaEPfE.mjs";
|
|
2
|
+
import { t as AllConstraints } from "../../renderer-ab9E52Bp.mjs";
|
|
3
|
+
import { r as LitRenderProps } from "../../types-BCy7K3nk.mjs";
|
|
4
|
+
import { LitElement, TemplateResult } from "lit";
|
|
5
|
+
|
|
6
|
+
//#region src/lit/renderers/baseElement.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Detail payload emitted on the `sc-change` Custom Event.
|
|
9
|
+
*
|
|
10
|
+
* The event bubbles and is composed so cross-Shadow-DOM listeners
|
|
11
|
+
* (e.g. the orchestrating `<schema-component>` outside the child's
|
|
12
|
+
* shadow tree) receive it without breaking encapsulation.
|
|
13
|
+
*/
|
|
14
|
+
interface ScChangeEventDetail {
|
|
15
|
+
value: unknown;
|
|
16
|
+
/** Path of the field that produced the change. */
|
|
17
|
+
path: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Canonical Custom Event name emitted by every built-in `<sc-*>`
|
|
21
|
+
* element when its user-facing input changes.
|
|
22
|
+
*
|
|
23
|
+
* The orchestrating `<schema-component>` listens for this internal
|
|
24
|
+
* event, applies the resulting structural update to the root value,
|
|
25
|
+
* and re-emits a public `change` Custom Event on its own host so
|
|
26
|
+
* framework consumers observe a single, well-typed boundary event.
|
|
27
|
+
*/
|
|
28
|
+
declare const SC_CHANGE_EVENT = "sc-change";
|
|
29
|
+
/**
|
|
30
|
+
* Base class for the built-in `<sc-*>` Custom Elements.
|
|
31
|
+
*
|
|
32
|
+
* Subclasses declare:
|
|
33
|
+
*
|
|
34
|
+
* 1. A `static properties` table extending `BaseScElement.properties`.
|
|
35
|
+
* 2. A `render()` method returning the per-type `TemplateResult`.
|
|
36
|
+
*
|
|
37
|
+
* The class deliberately does not implement `render()` itself — a
|
|
38
|
+
* `LitElement` without `render()` is still constructible, but its
|
|
39
|
+
* default behaviour is to render nothing. Subclasses are required to
|
|
40
|
+
* override.
|
|
41
|
+
*/
|
|
42
|
+
declare abstract class BaseScElement extends LitElement {
|
|
43
|
+
/**
|
|
44
|
+
* Property declarations shared by every built-in Custom Element.
|
|
45
|
+
*
|
|
46
|
+
* Subclasses spread this in:
|
|
47
|
+
*
|
|
48
|
+
* ```ts
|
|
49
|
+
* static override properties = {
|
|
50
|
+
* ...BaseScElement.properties,
|
|
51
|
+
* ...
|
|
52
|
+
* };
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* Every shared property uses `attribute: false` — none of the
|
|
56
|
+
* payloads (`tree`, `value`, `meta`, `constraints`) round-trip
|
|
57
|
+
* safely through HTML attribute strings.
|
|
58
|
+
*/
|
|
59
|
+
static readonly properties: {
|
|
60
|
+
tree: {
|
|
61
|
+
attribute: boolean;
|
|
62
|
+
};
|
|
63
|
+
value: {
|
|
64
|
+
attribute: boolean;
|
|
65
|
+
};
|
|
66
|
+
readOnly: {
|
|
67
|
+
attribute: boolean;
|
|
68
|
+
};
|
|
69
|
+
writeOnly: {
|
|
70
|
+
attribute: boolean;
|
|
71
|
+
};
|
|
72
|
+
path: {
|
|
73
|
+
attribute: boolean;
|
|
74
|
+
};
|
|
75
|
+
meta: {
|
|
76
|
+
attribute: boolean;
|
|
77
|
+
};
|
|
78
|
+
constraints: {
|
|
79
|
+
attribute: boolean;
|
|
80
|
+
};
|
|
81
|
+
examples: {
|
|
82
|
+
attribute: boolean;
|
|
83
|
+
};
|
|
84
|
+
change: {
|
|
85
|
+
attribute: boolean;
|
|
86
|
+
};
|
|
87
|
+
renderChild: {
|
|
88
|
+
attribute: boolean;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
tree: WalkedField;
|
|
92
|
+
value: unknown;
|
|
93
|
+
readOnly: boolean;
|
|
94
|
+
writeOnly: boolean;
|
|
95
|
+
path: string;
|
|
96
|
+
meta: SchemaMeta;
|
|
97
|
+
constraints: AllConstraints;
|
|
98
|
+
examples?: unknown[];
|
|
99
|
+
change: (value: unknown) => void;
|
|
100
|
+
renderChild: LitRenderProps["renderChild"];
|
|
101
|
+
constructor();
|
|
102
|
+
/**
|
|
103
|
+
* Dispatch the canonical `sc-change` event. Renderers call this
|
|
104
|
+
* inside DOM event handlers (`@input`, `@change`, `@click` on
|
|
105
|
+
* add/remove controls) — the orchestrating ancestor catches the
|
|
106
|
+
* event, propagates the structural update to the root value, and
|
|
107
|
+
* re-emits a top-level `change` event on its own host.
|
|
108
|
+
*/
|
|
109
|
+
protected emitChange(value: unknown): void;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Build a `renderChild` closure that delegates back to the
|
|
113
|
+
* orchestrating resolver dispatch. Container renderers (object, array,
|
|
114
|
+
* tuple, record, union, discriminatedUnion, conditional, negation)
|
|
115
|
+
* call this to recursively render their children without re-running
|
|
116
|
+
* the resolver dispatch loop themselves.
|
|
117
|
+
*
|
|
118
|
+
* The closure is stored on the parent's render props and forwarded to
|
|
119
|
+
* the resolver render function, mirroring the `renderChild` signatures
|
|
120
|
+
* on the React and HTML render-props (see `core/renderer.ts`).
|
|
121
|
+
*/
|
|
122
|
+
type LitRenderChild = LitRenderProps["renderChild"];
|
|
123
|
+
/**
|
|
124
|
+
* Trivial pass-through helper used by renderers that need to emit a
|
|
125
|
+
* `nothing` placeholder rather than a full `TemplateResult`. Keeps the
|
|
126
|
+
* dispatch table strictly typed without forcing callers to import
|
|
127
|
+
* `nothing` from Lit.
|
|
128
|
+
*/
|
|
129
|
+
declare const emptyTemplate: () => TemplateResult;
|
|
130
|
+
//#endregion
|
|
131
|
+
export { BaseScElement, LitRenderChild, SC_CHANGE_EVENT, ScChangeEventDetail, emptyTemplate };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { LitElement, html } from "lit";
|
|
2
|
+
//#region src/lit/renderers/baseElement.ts
|
|
3
|
+
/**
|
|
4
|
+
* Shared base class for every built-in `<sc-*>` Custom Element.
|
|
5
|
+
*
|
|
6
|
+
* Centralises the per-field property declarations and a small helper
|
|
7
|
+
* for dispatching the canonical `sc-change` Custom Event that wires
|
|
8
|
+
* an internal change through to whichever ancestor element is
|
|
9
|
+
* orchestrating value flow (typically `<schema-component>`).
|
|
10
|
+
*
|
|
11
|
+
* Every Custom Element on the Lit side reads the per-field data from
|
|
12
|
+
* declarative properties — schemas, walked field trees, constraints,
|
|
13
|
+
* and example arrays cannot be safely serialised through HTML
|
|
14
|
+
* attributes, so the declarations use `attribute: false`. This is the
|
|
15
|
+
* single largest difference from the React adapter, where the same
|
|
16
|
+
* data flows through component props.
|
|
17
|
+
*
|
|
18
|
+
* @packageDocumentation
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Canonical Custom Event name emitted by every built-in `<sc-*>`
|
|
22
|
+
* element when its user-facing input changes.
|
|
23
|
+
*
|
|
24
|
+
* The orchestrating `<schema-component>` listens for this internal
|
|
25
|
+
* event, applies the resulting structural update to the root value,
|
|
26
|
+
* and re-emits a public `change` Custom Event on its own host so
|
|
27
|
+
* framework consumers observe a single, well-typed boundary event.
|
|
28
|
+
*/
|
|
29
|
+
const SC_CHANGE_EVENT = "sc-change";
|
|
30
|
+
/**
|
|
31
|
+
* Base class for the built-in `<sc-*>` Custom Elements.
|
|
32
|
+
*
|
|
33
|
+
* Subclasses declare:
|
|
34
|
+
*
|
|
35
|
+
* 1. A `static properties` table extending `BaseScElement.properties`.
|
|
36
|
+
* 2. A `render()` method returning the per-type `TemplateResult`.
|
|
37
|
+
*
|
|
38
|
+
* The class deliberately does not implement `render()` itself — a
|
|
39
|
+
* `LitElement` without `render()` is still constructible, but its
|
|
40
|
+
* default behaviour is to render nothing. Subclasses are required to
|
|
41
|
+
* override.
|
|
42
|
+
*/
|
|
43
|
+
var BaseScElement = class extends LitElement {
|
|
44
|
+
/**
|
|
45
|
+
* Property declarations shared by every built-in Custom Element.
|
|
46
|
+
*
|
|
47
|
+
* Subclasses spread this in:
|
|
48
|
+
*
|
|
49
|
+
* ```ts
|
|
50
|
+
* static override properties = {
|
|
51
|
+
* ...BaseScElement.properties,
|
|
52
|
+
* ...
|
|
53
|
+
* };
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* Every shared property uses `attribute: false` — none of the
|
|
57
|
+
* payloads (`tree`, `value`, `meta`, `constraints`) round-trip
|
|
58
|
+
* safely through HTML attribute strings.
|
|
59
|
+
*/
|
|
60
|
+
static properties = {
|
|
61
|
+
tree: { attribute: false },
|
|
62
|
+
value: { attribute: false },
|
|
63
|
+
readOnly: { attribute: false },
|
|
64
|
+
writeOnly: { attribute: false },
|
|
65
|
+
path: { attribute: false },
|
|
66
|
+
meta: { attribute: false },
|
|
67
|
+
constraints: { attribute: false },
|
|
68
|
+
examples: { attribute: false },
|
|
69
|
+
change: { attribute: false },
|
|
70
|
+
renderChild: { attribute: false }
|
|
71
|
+
};
|
|
72
|
+
constructor() {
|
|
73
|
+
super();
|
|
74
|
+
this.readOnly = false;
|
|
75
|
+
this.writeOnly = false;
|
|
76
|
+
this.path = "";
|
|
77
|
+
this.meta = {};
|
|
78
|
+
this.constraints = {};
|
|
79
|
+
this.change = () => {};
|
|
80
|
+
this.renderChild = () => html``;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Dispatch the canonical `sc-change` event. Renderers call this
|
|
84
|
+
* inside DOM event handlers (`@input`, `@change`, `@click` on
|
|
85
|
+
* add/remove controls) — the orchestrating ancestor catches the
|
|
86
|
+
* event, propagates the structural update to the root value, and
|
|
87
|
+
* re-emits a top-level `change` event on its own host.
|
|
88
|
+
*/
|
|
89
|
+
emitChange(value) {
|
|
90
|
+
this.change(value);
|
|
91
|
+
this.dispatchEvent(new CustomEvent(SC_CHANGE_EVENT, {
|
|
92
|
+
detail: {
|
|
93
|
+
value,
|
|
94
|
+
path: this.path
|
|
95
|
+
},
|
|
96
|
+
bubbles: true,
|
|
97
|
+
composed: true
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Trivial pass-through helper used by renderers that need to emit a
|
|
103
|
+
* `nothing` placeholder rather than a full `TemplateResult`. Keeps the
|
|
104
|
+
* dispatch table strictly typed without forcing callers to import
|
|
105
|
+
* `nothing` from Lit.
|
|
106
|
+
*/
|
|
107
|
+
const emptyTemplate = () => html``;
|
|
108
|
+
//#endregion
|
|
109
|
+
export { BaseScElement, SC_CHANGE_EVENT, emptyTemplate };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { j as WalkedField } from "../../types-BBQaEPfE.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/lit/renderers/recordHelpers.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Compute the default value for a freshly added array element or
|
|
6
|
+
* record entry based on its element / value schema. Mirrors
|
|
7
|
+
* `react/headlessRenderers.tsx::defaultRecordValue` so the same
|
|
8
|
+
* field type produces the same default across renderers.
|
|
9
|
+
*/
|
|
10
|
+
declare function defaultRecordValueLit(valueType: WalkedField): unknown;
|
|
11
|
+
/**
|
|
12
|
+
* Generate a unique, currently-unused key for a new record entry.
|
|
13
|
+
* Picks the first of `key`, `key-1`, `key-2`, … that is not in
|
|
14
|
+
* `existing`. Mirrors `react/headlessRenderers.tsx::nextRecordKey`.
|
|
15
|
+
*/
|
|
16
|
+
declare function nextRecordKeyLit(existing: readonly string[], base?: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Rename a key in an object while preserving insertion order. Returns
|
|
19
|
+
* the original reference when the rename is a no-op (same key) or
|
|
20
|
+
* when the new key collides with an existing entry. Mirrors
|
|
21
|
+
* `react/headlessRenderers.tsx::renameRecordKey`.
|
|
22
|
+
*/
|
|
23
|
+
declare function renameRecordKeyLit(obj: Record<string, unknown>, oldKey: string, newKey: string): Record<string, unknown>;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { defaultRecordValueLit, nextRecordKeyLit, renameRecordKeyLit };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
//#region src/lit/renderers/recordHelpers.ts
|
|
2
|
+
/**
|
|
3
|
+
* Compute the default value for a freshly added array element or
|
|
4
|
+
* record entry based on its element / value schema. Mirrors
|
|
5
|
+
* `react/headlessRenderers.tsx::defaultRecordValue` so the same
|
|
6
|
+
* field type produces the same default across renderers.
|
|
7
|
+
*/
|
|
8
|
+
function defaultRecordValueLit(valueType) {
|
|
9
|
+
if (valueType.defaultValue !== void 0) return valueType.defaultValue;
|
|
10
|
+
switch (valueType.type) {
|
|
11
|
+
case "string": return "";
|
|
12
|
+
case "number": return 0;
|
|
13
|
+
case "boolean": return false;
|
|
14
|
+
case "array": return [];
|
|
15
|
+
case "object":
|
|
16
|
+
case "record": return {};
|
|
17
|
+
case "null": return null;
|
|
18
|
+
case "unknown":
|
|
19
|
+
case "enum":
|
|
20
|
+
case "literal":
|
|
21
|
+
case "tuple":
|
|
22
|
+
case "union":
|
|
23
|
+
case "discriminatedUnion":
|
|
24
|
+
case "conditional":
|
|
25
|
+
case "negation":
|
|
26
|
+
case "file":
|
|
27
|
+
case "never": return;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Generate a unique, currently-unused key for a new record entry.
|
|
32
|
+
* Picks the first of `key`, `key-1`, `key-2`, … that is not in
|
|
33
|
+
* `existing`. Mirrors `react/headlessRenderers.tsx::nextRecordKey`.
|
|
34
|
+
*/
|
|
35
|
+
function nextRecordKeyLit(existing, base = "key") {
|
|
36
|
+
if (!existing.includes(base)) return base;
|
|
37
|
+
let i = 1;
|
|
38
|
+
while (existing.includes(`${base}-${String(i)}`)) i += 1;
|
|
39
|
+
return `${base}-${String(i)}`;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Rename a key in an object while preserving insertion order. Returns
|
|
43
|
+
* the original reference when the rename is a no-op (same key) or
|
|
44
|
+
* when the new key collides with an existing entry. Mirrors
|
|
45
|
+
* `react/headlessRenderers.tsx::renameRecordKey`.
|
|
46
|
+
*/
|
|
47
|
+
function renameRecordKeyLit(obj, oldKey, newKey) {
|
|
48
|
+
if (oldKey === newKey) return obj;
|
|
49
|
+
if (newKey in obj && newKey !== oldKey) return obj;
|
|
50
|
+
const renamed = {};
|
|
51
|
+
for (const [k, v] of Object.entries(obj)) renamed[k === oldKey ? newKey : k] = v;
|
|
52
|
+
return renamed;
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
export { defaultRecordValueLit, nextRecordKeyLit, renameRecordKeyLit };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BaseScElement } from "./baseElement.mjs";
|
|
2
|
+
import { TemplateResult } from "lit";
|
|
3
|
+
|
|
4
|
+
//#region src/lit/renderers/scArray.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Lit Custom Element rendering an array schema field.
|
|
7
|
+
*
|
|
8
|
+
* Tag: `<sc-array>` (registered by `registerSchemaComponents`).
|
|
9
|
+
*/
|
|
10
|
+
declare class ScArray extends BaseScElement {
|
|
11
|
+
render(): TemplateResult;
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { ScArray };
|