schema-components 1.29.0 → 2.0.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/README.md +38 -16
- package/dist/core/adapter.d.mts +213 -3
- package/dist/core/adapter.mjs +1 -1
- package/dist/core/constraintHint.d.mts +15 -0
- package/dist/core/constraintHint.mjs +24 -0
- package/dist/core/constraints.d.mts +2 -2
- package/dist/core/constraints.mjs +1 -1
- 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/core/formats.d.mts +1 -1
- package/dist/core/idPath.d.mts +35 -5
- package/dist/core/idPath.mjs +79 -7
- package/dist/core/inferValue.d.mts +2 -0
- package/dist/core/inferValue.mjs +1 -0
- package/dist/core/limits.d.mts +1 -1
- package/dist/core/limits.mjs +5 -0
- package/dist/core/merge.d.mts +12 -1
- package/dist/core/merge.mjs +66 -3
- package/dist/core/normalise.d.mts +1 -1
- package/dist/core/normalise.mjs +1 -1
- package/dist/core/openapi30.mjs +1 -1
- package/dist/core/ref.d.mts +1 -1
- package/dist/core/refChain.d.mts +3 -4
- package/dist/core/refChain.mjs +2 -3
- package/dist/core/renderer.d.mts +199 -2
- package/dist/core/swagger2.d.mts +1 -1
- package/dist/core/swagger2.mjs +1 -1
- package/dist/core/typeInference.d.mts +3 -3
- package/dist/core/types.d.mts +1 -1
- package/dist/core/unionMatch.d.mts +1 -1
- package/dist/core/uri.d.mts +12 -4
- package/dist/core/uri.mjs +30 -4
- package/dist/core/walkBuilders.d.mts +18 -6
- package/dist/core/walkBuilders.mjs +3 -1
- package/dist/core/walker.d.mts +1 -1
- package/dist/core/walker.mjs +5 -0
- package/dist/{diagnostics-ByEzkjrA.d.mts → diagnostics-BTrm3O6J.d.mts} +1 -1
- package/dist/{errors-D8JndRwI.d.mts → errors-Dki7tji4.d.mts} +1 -1
- package/dist/html/a11y.d.mts +3 -7
- package/dist/html/a11y.mjs +1 -16
- package/dist/html/renderToHtml.d.mts +22 -9
- package/dist/html/renderToHtml.mjs +2 -1
- package/dist/html/renderToHtmlStream.d.mts +24 -11
- package/dist/html/renderToHtmlStream.mjs +2 -1
- package/dist/html/renderers.d.mts +2 -33
- package/dist/html/renderers.mjs +39 -91
- package/dist/html/streamRenderers.d.mts +3 -3
- package/dist/html/streamRenderers.mjs +13 -8
- package/dist/inferValue-PPXWJpbN.d.mts +77 -0
- package/dist/{limits-DswmqWuy.d.mts → limits-x4OiyJxh.d.mts} +5 -0
- package/dist/{normalise-Db1xaxgx.mjs → normalise-DB-Xtjmn.mjs} +43 -2
- 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/ApiSecurity.mjs +21 -8
- package/dist/openapi/bundle.d.mts +31 -0
- package/dist/openapi/components.d.mts +41 -10
- package/dist/openapi/components.mjs +19 -13
- package/dist/openapi/parser.d.mts +13 -13
- package/dist/openapi/parser.mjs +12 -12
- package/dist/openapi/resolve.d.mts +38 -49
- package/dist/openapi/resolve.mjs +62 -56
- package/dist/react/SchemaComponent.d.mts +19 -95
- package/dist/react/SchemaComponent.mjs +12 -1
- package/dist/react/SchemaView.d.mts +11 -7
- package/dist/react/SchemaView.mjs +3 -1
- package/dist/react/a11y.d.mts +74 -7
- package/dist/react/a11y.mjs +67 -6
- package/dist/react/fieldPath.d.mts +16 -1
- package/dist/react/fieldPath.mjs +25 -1
- package/dist/react/fieldShell.d.mts +49 -0
- package/dist/react/fieldShell.mjs +37 -0
- package/dist/react/headless.d.mts +1 -1
- package/dist/react/headlessRenderers.d.mts +2 -2
- package/dist/react/headlessRenderers.mjs +123 -54
- package/dist/{ref-CPh8rKQ3.d.mts → ref-DdsbekXX.d.mts} +33 -1
- package/dist/themes/mantine.d.mts +36 -20
- package/dist/themes/mantine.mjs +179 -150
- package/dist/themes/mui.d.mts +47 -21
- package/dist/themes/mui.mjs +259 -222
- package/dist/themes/radix.d.mts +38 -23
- package/dist/themes/radix.mjs +208 -180
- package/dist/themes/shadcn.d.mts +6 -3
- package/dist/themes/shadcn.mjs +93 -93
- package/dist/{types-C2Ay1FEh.d.mts → types-BrYbjC7_.d.mts} +7 -0
- package/package.json +5 -1
- package/dist/adapter-DcWi4XXn.d.mts +0 -223
- package/dist/renderer-OaOz-n6-.d.mts +0 -185
package/dist/themes/mantine.mjs
CHANGED
|
@@ -1,187 +1,216 @@
|
|
|
1
1
|
import { isObject } from "../core/guards.mjs";
|
|
2
2
|
import { sortFieldsByOrder } from "../core/fieldOrder.mjs";
|
|
3
3
|
import { inputId, toReactNode } from "../react/headlessRenderers.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { FieldShell } from "../react/fieldShell.mjs";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
//#region src/themes/mantine.tsx
|
|
7
7
|
function getLabel(props) {
|
|
8
8
|
if (typeof props.meta.description === "string") return props.meta.description;
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
...props
|
|
18
|
-
});
|
|
19
|
-
let MantineSelect = (props) => /* @__PURE__ */ jsx("select", { ...props });
|
|
20
|
-
let MantineFieldset = (props) => /* @__PURE__ */ jsx("fieldset", { ...props });
|
|
21
|
-
let MantineText = (props) => /* @__PURE__ */ jsx("span", { ...props });
|
|
22
|
-
/**
|
|
23
|
-
* Inject real Mantine element types into the resolver. Call once at
|
|
24
|
-
* application startup before rendering any schema-driven component so
|
|
25
|
-
* that {@link mantineResolver}'s renderers delegate to the supplied
|
|
26
|
-
* Mantine primitives.
|
|
27
|
-
*
|
|
28
|
-
* `Text` is required so read-only scalars render as a styled Mantine
|
|
29
|
-
* `<Text>` element instead of a bare `<span>`, matching the visual
|
|
30
|
-
* weight of the editable variants.
|
|
31
|
-
*
|
|
32
|
-
* @group Themes
|
|
33
|
-
*/
|
|
34
|
-
function registerMantineComponents(components) {
|
|
35
|
-
MantineTextInput = components.TextInput;
|
|
36
|
-
MantineNumberInput = components.NumberInput;
|
|
37
|
-
MantineSwitch = components.Switch;
|
|
38
|
-
MantineSelect = components.Select;
|
|
39
|
-
MantineFieldset = components.Fieldset;
|
|
40
|
-
MantineText = components.Text;
|
|
41
|
-
}
|
|
42
|
-
function renderStringInput(props) {
|
|
43
|
-
const strValue = typeof props.value === "string" ? props.value : "";
|
|
44
|
-
const label = getLabel(props);
|
|
45
|
-
const id = inputId(props.path);
|
|
46
|
-
if (props.readOnly) return /* @__PURE__ */ jsx(MantineText, {
|
|
47
|
-
id,
|
|
48
|
-
children: strValue || "—"
|
|
49
|
-
});
|
|
50
|
-
return /* @__PURE__ */ jsx(MantineTextInput, {
|
|
51
|
-
id,
|
|
52
|
-
label,
|
|
53
|
-
value: props.writeOnly ? "" : strValue,
|
|
54
|
-
onChange: (e) => {
|
|
55
|
-
props.onChange(e.target.value);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
function renderNumberInput(props) {
|
|
60
|
-
const label = getLabel(props);
|
|
61
|
-
const id = inputId(props.path);
|
|
62
|
-
if (props.readOnly) {
|
|
63
|
-
if (typeof props.value !== "number") return /* @__PURE__ */ jsx(MantineText, {
|
|
10
|
+
function makeRenderStringInput(components) {
|
|
11
|
+
const { TextInput, Text } = components;
|
|
12
|
+
return function renderStringInput(props) {
|
|
13
|
+
const strValue = typeof props.value === "string" ? props.value : "";
|
|
14
|
+
const label = getLabel(props);
|
|
15
|
+
const id = inputId(props.path);
|
|
16
|
+
if (props.readOnly) return /* @__PURE__ */ jsx(Text, {
|
|
64
17
|
id,
|
|
65
|
-
children: "—"
|
|
18
|
+
children: strValue || "—"
|
|
66
19
|
});
|
|
67
|
-
return /* @__PURE__ */ jsx(
|
|
68
|
-
|
|
69
|
-
|
|
20
|
+
return /* @__PURE__ */ jsx(FieldShell, {
|
|
21
|
+
props,
|
|
22
|
+
inputId: id,
|
|
23
|
+
hideLabel: true,
|
|
24
|
+
children: (aria) => /* @__PURE__ */ jsx(TextInput, {
|
|
25
|
+
id,
|
|
26
|
+
label,
|
|
27
|
+
value: props.writeOnly ? "" : strValue,
|
|
28
|
+
onChange: (e) => {
|
|
29
|
+
props.onChange(e.target.value);
|
|
30
|
+
},
|
|
31
|
+
...aria
|
|
32
|
+
})
|
|
70
33
|
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function makeRenderNumberInput(components) {
|
|
37
|
+
const { NumberInput, Text } = components;
|
|
38
|
+
return function renderNumberInput(props) {
|
|
39
|
+
const label = getLabel(props);
|
|
40
|
+
const id = inputId(props.path);
|
|
41
|
+
if (props.readOnly) {
|
|
42
|
+
if (typeof props.value !== "number") return /* @__PURE__ */ jsx(Text, {
|
|
43
|
+
id,
|
|
44
|
+
children: "—"
|
|
45
|
+
});
|
|
46
|
+
return /* @__PURE__ */ jsx(Text, {
|
|
47
|
+
id,
|
|
48
|
+
children: props.value.toLocaleString()
|
|
49
|
+
});
|
|
78
50
|
}
|
|
79
|
-
|
|
51
|
+
return /* @__PURE__ */ jsx(FieldShell, {
|
|
52
|
+
props,
|
|
53
|
+
inputId: id,
|
|
54
|
+
hideLabel: true,
|
|
55
|
+
children: (aria) => /* @__PURE__ */ jsx(NumberInput, {
|
|
56
|
+
id,
|
|
57
|
+
label,
|
|
58
|
+
value: props.writeOnly ? void 0 : typeof props.value === "number" ? props.value : void 0,
|
|
59
|
+
onChange: (v) => {
|
|
60
|
+
if (typeof v === "number") props.onChange(v);
|
|
61
|
+
},
|
|
62
|
+
...aria
|
|
63
|
+
})
|
|
64
|
+
});
|
|
65
|
+
};
|
|
80
66
|
}
|
|
81
|
-
function
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
67
|
+
function makeRenderBooleanInput(components) {
|
|
68
|
+
const { Switch, Text } = components;
|
|
69
|
+
return function renderBooleanInput(props) {
|
|
70
|
+
const label = getLabel(props);
|
|
71
|
+
const id = inputId(props.path);
|
|
72
|
+
if (props.readOnly) {
|
|
73
|
+
if (typeof props.value !== "boolean") return /* @__PURE__ */ jsx(Text, {
|
|
74
|
+
id,
|
|
75
|
+
children: "—"
|
|
76
|
+
});
|
|
77
|
+
return /* @__PURE__ */ jsx(Text, {
|
|
78
|
+
id,
|
|
79
|
+
children: props.value ? "Yes" : "No"
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
return /* @__PURE__ */ jsx(FieldShell, {
|
|
83
|
+
props,
|
|
84
|
+
inputId: id,
|
|
85
|
+
hideLabel: true,
|
|
86
|
+
children: (aria) => /* @__PURE__ */ jsx(Switch, {
|
|
87
|
+
id,
|
|
88
|
+
label,
|
|
89
|
+
checked: props.writeOnly ? false : props.value === true,
|
|
90
|
+
onChange: (e) => {
|
|
91
|
+
props.onChange(e.target.checked);
|
|
92
|
+
},
|
|
93
|
+
...aria
|
|
94
|
+
})
|
|
88
95
|
});
|
|
89
|
-
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function makeRenderEnumInput(components) {
|
|
99
|
+
const { Select, Text } = components;
|
|
100
|
+
return function renderEnumInput(props) {
|
|
101
|
+
const enumValue = typeof props.value === "string" ? props.value : "";
|
|
102
|
+
const label = getLabel(props);
|
|
103
|
+
const id = inputId(props.path);
|
|
104
|
+
if (props.readOnly) return /* @__PURE__ */ jsx(Text, {
|
|
90
105
|
id,
|
|
91
|
-
children:
|
|
106
|
+
children: enumValue || "—"
|
|
92
107
|
});
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
id,
|
|
114
|
-
label,
|
|
115
|
-
value: props.writeOnly ? null : enumValue || null,
|
|
116
|
-
onChange: (v) => {
|
|
117
|
-
if (typeof v === "string") props.onChange(v);
|
|
118
|
-
},
|
|
119
|
-
data: enumValues.map((v) => ({
|
|
120
|
-
value: v,
|
|
121
|
-
label: v
|
|
122
|
-
}))
|
|
123
|
-
});
|
|
108
|
+
const enumValues = props.tree.type === "enum" ? props.tree.enumValues : [];
|
|
109
|
+
return /* @__PURE__ */ jsx(FieldShell, {
|
|
110
|
+
props,
|
|
111
|
+
inputId: id,
|
|
112
|
+
hideLabel: true,
|
|
113
|
+
children: (aria) => /* @__PURE__ */ jsx(Select, {
|
|
114
|
+
id,
|
|
115
|
+
label,
|
|
116
|
+
value: props.writeOnly ? null : enumValue || null,
|
|
117
|
+
onChange: (v) => {
|
|
118
|
+
if (typeof v === "string") props.onChange(v);
|
|
119
|
+
},
|
|
120
|
+
data: enumValues.map((v) => ({
|
|
121
|
+
value: v,
|
|
122
|
+
label: v
|
|
123
|
+
})),
|
|
124
|
+
...aria
|
|
125
|
+
})
|
|
126
|
+
});
|
|
127
|
+
};
|
|
124
128
|
}
|
|
125
|
-
function
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
129
|
+
function makeRenderObjectContainer(components) {
|
|
130
|
+
const { Fieldset } = components;
|
|
131
|
+
return function renderObjectContainer(props) {
|
|
132
|
+
if (props.tree.type !== "object") return null;
|
|
133
|
+
const fields = props.tree.fields;
|
|
134
|
+
const obj = isObject(props.value) ? props.value : {};
|
|
135
|
+
return /* @__PURE__ */ jsx(Fieldset, {
|
|
136
|
+
legend: getLabel(props),
|
|
137
|
+
children: sortFieldsByOrder(fields).filter(([, field]) => field.meta.visible !== false).map(([key, field]) => {
|
|
138
|
+
const childValue = obj[key];
|
|
139
|
+
const childOnChange = (v) => {
|
|
140
|
+
const updated = {};
|
|
141
|
+
for (const [k, val] of Object.entries(obj)) updated[k] = val;
|
|
142
|
+
updated[key] = v;
|
|
143
|
+
props.onChange(updated);
|
|
144
|
+
};
|
|
145
|
+
return /* @__PURE__ */ jsx("div", {
|
|
146
|
+
style: { marginBottom: "0.5rem" },
|
|
147
|
+
children: toReactNode(props.renderChild(field, childValue, childOnChange, key))
|
|
148
|
+
}, key);
|
|
149
|
+
})
|
|
150
|
+
});
|
|
151
|
+
};
|
|
145
152
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
+
const STUB_COMPONENTS = {
|
|
154
|
+
TextInput: (props) => /* @__PURE__ */ jsx("input", { ...props }),
|
|
155
|
+
NumberInput: (props) => /* @__PURE__ */ jsx("input", {
|
|
156
|
+
type: "number",
|
|
157
|
+
...props
|
|
158
|
+
}),
|
|
159
|
+
Switch: (props) => /* @__PURE__ */ jsx("input", {
|
|
160
|
+
type: "checkbox",
|
|
161
|
+
...props
|
|
162
|
+
}),
|
|
163
|
+
Select: (props) => /* @__PURE__ */ jsx("select", { ...props }),
|
|
164
|
+
Fieldset: (props) => /* @__PURE__ */ jsx("fieldset", { ...props }),
|
|
165
|
+
Text: (props) => /* @__PURE__ */ jsx("span", { ...props })
|
|
166
|
+
};
|
|
167
|
+
/**
|
|
168
|
+
* Build a Mantine-flavoured {@link ComponentResolver} bound to the
|
|
169
|
+
* supplied element types. Each render function captures the supplied
|
|
170
|
+
* components in a closure so two consumers can build different
|
|
171
|
+
* resolvers from the same package without leaking element types
|
|
172
|
+
* through module-level mutable state.
|
|
173
|
+
*
|
|
174
|
+
* Returns only the keys this theme actually overrides. The runtime
|
|
175
|
+
* `mergeResolvers` call inside `<SchemaComponent>` / `<SchemaView>`
|
|
176
|
+
* fills unset keys from `headlessResolver`, so variants this adapter
|
|
177
|
+
* leaves unset (literal, union, discriminatedUnion, array, record,
|
|
178
|
+
* file, unknown, …) still render via the headless fallback.
|
|
179
|
+
*
|
|
180
|
+
* @group Themes
|
|
181
|
+
*/
|
|
182
|
+
function createMantineResolver(components) {
|
|
183
|
+
return {
|
|
184
|
+
string: makeRenderStringInput(components),
|
|
185
|
+
number: makeRenderNumberInput(components),
|
|
186
|
+
boolean: makeRenderBooleanInput(components),
|
|
187
|
+
enum: makeRenderEnumInput(components),
|
|
188
|
+
object: makeRenderObjectContainer(components)
|
|
153
189
|
};
|
|
154
|
-
if (headlessResolver.literal !== void 0) resolver.literal = headlessResolver.literal;
|
|
155
|
-
if (headlessResolver.union !== void 0) resolver.union = headlessResolver.union;
|
|
156
|
-
if (headlessResolver.discriminatedUnion !== void 0) resolver.discriminatedUnion = headlessResolver.discriminatedUnion;
|
|
157
|
-
if (headlessResolver.array !== void 0) resolver.array = headlessResolver.array;
|
|
158
|
-
if (headlessResolver.record !== void 0) resolver.record = headlessResolver.record;
|
|
159
|
-
if (headlessResolver.file !== void 0) resolver.file = headlessResolver.file;
|
|
160
|
-
if (headlessResolver.unknown !== void 0) resolver.unknown = headlessResolver.unknown;
|
|
161
|
-
return resolver;
|
|
162
190
|
}
|
|
163
191
|
/**
|
|
164
192
|
* Component resolver mapping schema field types to Mantine primitives —
|
|
165
193
|
* `TextInput`, `NumberInput`, `Switch`, `Select`, `Fieldset`, `Text`.
|
|
166
194
|
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
* actual Mantine element types.
|
|
195
|
+
* Built against minimal HTML stubs so the resolver is usable without
|
|
196
|
+
* wiring up `@mantine/core` first — production usage should call
|
|
197
|
+
* {@link createMantineResolver} with real Mantine element types.
|
|
171
198
|
*
|
|
172
199
|
* @group Themes
|
|
173
200
|
* @example
|
|
174
201
|
* ```tsx
|
|
175
202
|
* import { TextInput, NumberInput, Switch, Select, Fieldset, Text } from "@mantine/core";
|
|
176
|
-
* import {
|
|
203
|
+
* import { createMantineResolver } from "schema-components/themes/mantine";
|
|
177
204
|
*
|
|
178
|
-
*
|
|
205
|
+
* const mantineResolver = createMantineResolver({
|
|
206
|
+
* TextInput, NumberInput, Switch, Select, Fieldset, Text,
|
|
207
|
+
* });
|
|
179
208
|
*
|
|
180
209
|
* <SchemaProvider resolver={mantineResolver}>
|
|
181
210
|
* <SchemaComponent schema={userSchema} value={user} onChange={setUser} />
|
|
182
211
|
* </SchemaProvider>
|
|
183
212
|
* ```
|
|
184
213
|
*/
|
|
185
|
-
const mantineResolver =
|
|
214
|
+
const mantineResolver = createMantineResolver(STUB_COMPONENTS);
|
|
186
215
|
//#endregion
|
|
187
|
-
export {
|
|
216
|
+
export { createMantineResolver, mantineResolver };
|
package/dist/themes/mui.d.mts
CHANGED
|
@@ -1,38 +1,64 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentResolver } from "../core/renderer.mjs";
|
|
2
|
+
import { ElementType } from "react";
|
|
2
3
|
|
|
3
4
|
//#region src/themes/mui.d.ts
|
|
4
5
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* Element types the MUI resolver renders into. Every slot is the MUI
|
|
7
|
+
* component the corresponding render function expects to find at the
|
|
8
|
+
* call site; consumers wire these in once via `createMuiResolver` so
|
|
9
|
+
* the resolver can be used in SSR and multi-tenant contexts where two
|
|
10
|
+
* callers might inject different element types.
|
|
11
|
+
*/
|
|
12
|
+
interface MuiComponents {
|
|
13
|
+
TextField: ElementType;
|
|
14
|
+
Checkbox: ElementType;
|
|
15
|
+
Typography: ElementType;
|
|
16
|
+
Box: ElementType;
|
|
17
|
+
MenuItem: ElementType;
|
|
18
|
+
FormControlLabel: ElementType;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Build a MUI-flavoured {@link ComponentResolver} bound to the supplied
|
|
22
|
+
* element types. Each render function captures the supplied components
|
|
23
|
+
* in a closure so two consumers can build different resolvers from the
|
|
24
|
+
* same package without leaking element types through module-level
|
|
25
|
+
* mutable state — making the adapter safe to use in SSR and multi-tenant
|
|
26
|
+
* environments.
|
|
27
|
+
*
|
|
28
|
+
* Returns only the keys this theme actually overrides. The runtime
|
|
29
|
+
* `mergeResolvers` call inside `<SchemaComponent>` / `<SchemaView>`
|
|
30
|
+
* fills any unset keys from `headlessResolver`, so consumers never see
|
|
31
|
+
* an unhandled field type even though this resolver leaves variants
|
|
32
|
+
* like `union`, `discriminatedUnion`, `record`, `file`, and `unknown`
|
|
33
|
+
* unset on purpose.
|
|
9
34
|
*
|
|
10
35
|
* @group Themes
|
|
11
36
|
*/
|
|
12
|
-
declare function
|
|
13
|
-
TextField: React.ElementType;
|
|
14
|
-
Checkbox: React.ElementType;
|
|
15
|
-
Typography: React.ElementType;
|
|
16
|
-
Box: React.ElementType;
|
|
17
|
-
MenuItem: React.ElementType;
|
|
18
|
-
FormControlLabel: React.ElementType;
|
|
19
|
-
}): void;
|
|
37
|
+
declare function createMuiResolver(components: MuiComponents): ComponentResolver;
|
|
20
38
|
/**
|
|
21
39
|
* Component resolver mapping schema field types to MUI (Material UI)
|
|
22
40
|
* primitives — `TextField`, `Checkbox`, `Typography`, etc.
|
|
23
41
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
42
|
+
* This default export is built against minimal HTML stubs so it is
|
|
43
|
+
* usable without wiring up `@mui/material` first — handy for tests,
|
|
44
|
+
* stories, and tree-shaken bundles that want the resolver shape
|
|
45
|
+
* without the runtime dependency. For production usage call
|
|
46
|
+
* {@link createMuiResolver} with the real MUI element types.
|
|
28
47
|
*
|
|
29
48
|
* @group Themes
|
|
30
49
|
* @example
|
|
31
50
|
* ```tsx
|
|
32
|
-
* import
|
|
33
|
-
* import
|
|
51
|
+
* import TextField from "@mui/material/TextField";
|
|
52
|
+
* import Checkbox from "@mui/material/Checkbox";
|
|
53
|
+
* import Typography from "@mui/material/Typography";
|
|
54
|
+
* import Box from "@mui/material/Box";
|
|
55
|
+
* import MenuItem from "@mui/material/MenuItem";
|
|
56
|
+
* import FormControlLabel from "@mui/material/FormControlLabel";
|
|
57
|
+
* import { createMuiResolver } from "schema-components/themes/mui";
|
|
34
58
|
*
|
|
35
|
-
*
|
|
59
|
+
* const muiResolver = createMuiResolver({
|
|
60
|
+
* TextField, Checkbox, Typography, Box, MenuItem, FormControlLabel,
|
|
61
|
+
* });
|
|
36
62
|
*
|
|
37
63
|
* <SchemaProvider resolver={muiResolver}>
|
|
38
64
|
* <SchemaComponent schema={userSchema} value={user} onChange={setUser} />
|
|
@@ -41,4 +67,4 @@ declare function registerMuiComponents(components: {
|
|
|
41
67
|
*/
|
|
42
68
|
declare const muiResolver: ComponentResolver;
|
|
43
69
|
//#endregion
|
|
44
|
-
export {
|
|
70
|
+
export { MuiComponents, createMuiResolver, muiResolver };
|