schema-components 1.15.1 → 1.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/walker.mjs +1 -1
- package/dist/html/renderToHtml.mjs +2 -2
- package/dist/html/renderToHtmlStream.mjs +1 -1
- package/dist/html/streamRenderers.mjs +2 -2
- package/dist/html/styles.css +66 -19
- package/dist/openapi/components.mjs +1 -1
- package/dist/react/SchemaComponent.d.mts +1 -1
- package/dist/react/SchemaComponent.mjs +2 -2
- package/dist/react/SchemaView.mjs +2 -2
- package/dist/react/headlessRenderers.mjs +1 -1
- package/dist/themes/mui.mjs +1 -1
- package/package.json +1 -1
package/dist/core/walker.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { isObject } from "./guards.mjs";
|
|
2
2
|
import { appendPointer, emitDiagnostic } from "./diagnostics.mjs";
|
|
3
3
|
import { countDistinctRefs, resolveRef } from "./ref.mjs";
|
|
4
|
-
import { extractArrayConstraints, extractObjectConstraints, stripInapplicableConstraints } from "./constraints.mjs";
|
|
5
4
|
import { ANNOTATION_SIBLINGS, detectDiscriminated, mergeAllOf, mergeRefSiblings, normaliseAnyOf } from "./merge.mjs";
|
|
5
|
+
import { extractArrayConstraints, extractObjectConstraints, stripInapplicableConstraints } from "./constraints.mjs";
|
|
6
6
|
import { buildBase, buildBooleanField, buildFileField, buildNullField, buildNumberField, buildStringField, buildUnknownField, extractChildOverride, extractSchemaMetaFields, getArray, getObject, getString, isPrimitive, walkDependentRequiredMap, walkSubSchemaMap, withoutKeys } from "./walkBuilders.mjs";
|
|
7
7
|
//#region src/core/walker.ts
|
|
8
8
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { h, serialize } from "./html.mjs";
|
|
1
2
|
import { normaliseSchema } from "../core/adapter.mjs";
|
|
2
|
-
import { getHtmlRenderFn, mergeHtmlResolvers } from "../core/renderer.mjs";
|
|
3
3
|
import { walk } from "../core/walker.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { getHtmlRenderFn, mergeHtmlResolvers } from "../core/renderer.mjs";
|
|
5
5
|
import { defaultHtmlResolver } from "./renderers.mjs";
|
|
6
6
|
//#region src/html/renderToHtml.ts
|
|
7
7
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { normaliseSchema } from "../core/adapter.mjs";
|
|
2
|
-
import { mergeHtmlResolvers } from "../core/renderer.mjs";
|
|
3
2
|
import { walk } from "../core/walker.mjs";
|
|
3
|
+
import { mergeHtmlResolvers } from "../core/renderer.mjs";
|
|
4
4
|
import { defaultHtmlResolver } from "./renderers.mjs";
|
|
5
5
|
import { streamField } from "./streamRenderers.mjs";
|
|
6
6
|
//#region src/html/renderToHtmlStream.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { isObject } from "../core/guards.mjs";
|
|
2
|
-
import { getHtmlRenderFn } from "../core/renderer.mjs";
|
|
3
1
|
import { VOID_ELEMENTS, h, raw, serialize, serializeAttributes } from "./html.mjs";
|
|
4
2
|
import { ariaLabelAttrs, buildHintElement, buildInputId, requiredIndicator } from "./a11y.mjs";
|
|
3
|
+
import { isObject } from "../core/guards.mjs";
|
|
4
|
+
import { getHtmlRenderFn } from "../core/renderer.mjs";
|
|
5
5
|
//#region src/html/streamRenderers.ts
|
|
6
6
|
function yieldOpen(el) {
|
|
7
7
|
const attrStr = serializeAttributes(el.attributes);
|
package/dist/html/styles.css
CHANGED
|
@@ -8,14 +8,61 @@
|
|
|
8
8
|
* ```html
|
|
9
9
|
* <link rel="stylesheet" href="node_modules/@scalar/schema-components/dist/styles.css">
|
|
10
10
|
* ```
|
|
11
|
+
*
|
|
12
|
+
* Every colour flows through a --sc-* custom property. The defaults below
|
|
13
|
+
* cover light mode; the @media (prefers-color-scheme: dark) block redefines
|
|
14
|
+
* them for dark mode. Consumers can override either set of variables to
|
|
15
|
+
* brand the rendered output without forking the stylesheet.
|
|
11
16
|
*/
|
|
12
17
|
|
|
18
|
+
:root {
|
|
19
|
+
--sc-object-border: #e2e8f0;
|
|
20
|
+
--sc-legend-text: #334155;
|
|
21
|
+
--sc-label-text: #374151;
|
|
22
|
+
--sc-required-text: #dc2626;
|
|
23
|
+
--sc-input-text: #111827;
|
|
24
|
+
--sc-input-bg: #ffffff;
|
|
25
|
+
--sc-input-border: #d1d5db;
|
|
26
|
+
--sc-focus-ring: #3b82f6;
|
|
27
|
+
--sc-value-text: #111827;
|
|
28
|
+
--sc-value-empty-text: #9ca3af;
|
|
29
|
+
--sc-value-link-text: #2563eb;
|
|
30
|
+
--sc-hint-text: #6b7280;
|
|
31
|
+
--sc-tab-border: #d1d5db;
|
|
32
|
+
--sc-tab-text: #374151;
|
|
33
|
+
--sc-tab-active-bg: #eff6ff;
|
|
34
|
+
--sc-tab-active-border: #3b82f6;
|
|
35
|
+
--sc-tab-active-text: #1d4ed8;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@media (prefers-color-scheme: dark) {
|
|
39
|
+
:root {
|
|
40
|
+
--sc-object-border: #334155;
|
|
41
|
+
--sc-legend-text: #cbd5e1;
|
|
42
|
+
--sc-label-text: #cbd5e1;
|
|
43
|
+
--sc-required-text: #fca5a5;
|
|
44
|
+
--sc-input-text: #e2e8f0;
|
|
45
|
+
--sc-input-bg: #1e293b;
|
|
46
|
+
--sc-input-border: #475569;
|
|
47
|
+
--sc-focus-ring: #60a5fa;
|
|
48
|
+
--sc-value-text: #e2e8f0;
|
|
49
|
+
--sc-value-empty-text: #64748b;
|
|
50
|
+
--sc-value-link-text: #93c5fd;
|
|
51
|
+
--sc-hint-text: #94a3b8;
|
|
52
|
+
--sc-tab-border: #475569;
|
|
53
|
+
--sc-tab-text: #cbd5e1;
|
|
54
|
+
--sc-tab-active-bg: #1e3a5f;
|
|
55
|
+
--sc-tab-active-border: #60a5fa;
|
|
56
|
+
--sc-tab-active-text: #93c5fd;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
13
60
|
/* ---------------------------------------------------------------------- */
|
|
14
61
|
/* Object containers */
|
|
15
62
|
/* ---------------------------------------------------------------------- */
|
|
16
63
|
|
|
17
64
|
.sc-object {
|
|
18
|
-
border: 1px solid
|
|
65
|
+
border: 1px solid var(--sc-object-border);
|
|
19
66
|
border-radius: 0.375rem;
|
|
20
67
|
padding: 1rem;
|
|
21
68
|
}
|
|
@@ -23,7 +70,7 @@
|
|
|
23
70
|
.sc-object legend {
|
|
24
71
|
font-weight: 600;
|
|
25
72
|
font-size: 0.875rem;
|
|
26
|
-
color:
|
|
73
|
+
color: var(--sc-legend-text);
|
|
27
74
|
padding: 0 0.25rem;
|
|
28
75
|
}
|
|
29
76
|
|
|
@@ -43,12 +90,12 @@
|
|
|
43
90
|
display: block;
|
|
44
91
|
font-size: 0.875rem;
|
|
45
92
|
font-weight: 500;
|
|
46
|
-
color:
|
|
93
|
+
color: var(--sc-label-text);
|
|
47
94
|
margin-bottom: 0.25rem;
|
|
48
95
|
}
|
|
49
96
|
|
|
50
97
|
.sc-required {
|
|
51
|
-
color:
|
|
98
|
+
color: var(--sc-required-text);
|
|
52
99
|
font-weight: 600;
|
|
53
100
|
}
|
|
54
101
|
|
|
@@ -59,17 +106,17 @@
|
|
|
59
106
|
.sc-input {
|
|
60
107
|
width: 100%;
|
|
61
108
|
padding: 0.375rem 0.5rem;
|
|
62
|
-
border: 1px solid
|
|
109
|
+
border: 1px solid var(--sc-input-border);
|
|
63
110
|
border-radius: 0.25rem;
|
|
64
111
|
font-size: 0.875rem;
|
|
65
112
|
line-height: 1.25rem;
|
|
66
|
-
color:
|
|
67
|
-
background-color:
|
|
113
|
+
color: var(--sc-input-text);
|
|
114
|
+
background-color: var(--sc-input-bg);
|
|
68
115
|
box-sizing: border-box;
|
|
69
116
|
}
|
|
70
117
|
|
|
71
118
|
.sc-input:focus {
|
|
72
|
-
outline: 2px solid
|
|
119
|
+
outline: 2px solid var(--sc-focus-ring);
|
|
73
120
|
outline-offset: -1px;
|
|
74
121
|
border-color: transparent;
|
|
75
122
|
}
|
|
@@ -91,11 +138,11 @@
|
|
|
91
138
|
|
|
92
139
|
.sc-value {
|
|
93
140
|
font-size: 0.875rem;
|
|
94
|
-
color:
|
|
141
|
+
color: var(--sc-value-text);
|
|
95
142
|
}
|
|
96
143
|
|
|
97
144
|
.sc-value--empty {
|
|
98
|
-
color:
|
|
145
|
+
color: var(--sc-value-empty-text);
|
|
99
146
|
}
|
|
100
147
|
|
|
101
148
|
.sc-value--boolean {
|
|
@@ -103,7 +150,7 @@
|
|
|
103
150
|
}
|
|
104
151
|
|
|
105
152
|
.sc-value[href] {
|
|
106
|
-
color:
|
|
153
|
+
color: var(--sc-value-link-text);
|
|
107
154
|
text-decoration: none;
|
|
108
155
|
}
|
|
109
156
|
|
|
@@ -152,7 +199,7 @@
|
|
|
152
199
|
.sc-hint {
|
|
153
200
|
display: block;
|
|
154
201
|
font-size: 0.75rem;
|
|
155
|
-
color:
|
|
202
|
+
color: var(--sc-hint-text);
|
|
156
203
|
margin-top: 0.25rem;
|
|
157
204
|
}
|
|
158
205
|
|
|
@@ -161,7 +208,7 @@
|
|
|
161
208
|
/* ---------------------------------------------------------------------- */
|
|
162
209
|
|
|
163
210
|
.sc-discriminated-union {
|
|
164
|
-
border: 1px solid
|
|
211
|
+
border: 1px solid var(--sc-object-border);
|
|
165
212
|
border-radius: 0.375rem;
|
|
166
213
|
padding: 1rem;
|
|
167
214
|
}
|
|
@@ -174,21 +221,21 @@
|
|
|
174
221
|
|
|
175
222
|
.sc-tab {
|
|
176
223
|
padding: 0.25rem 0.75rem;
|
|
177
|
-
border: 1px solid
|
|
224
|
+
border: 1px solid var(--sc-tab-border);
|
|
178
225
|
border-radius: 0.25rem;
|
|
179
226
|
background: transparent;
|
|
180
227
|
cursor: pointer;
|
|
181
228
|
font-size: 0.875rem;
|
|
182
|
-
color:
|
|
229
|
+
color: var(--sc-tab-text);
|
|
183
230
|
}
|
|
184
231
|
|
|
185
232
|
.sc-tab:focus-visible {
|
|
186
|
-
outline: 2px solid
|
|
233
|
+
outline: 2px solid var(--sc-focus-ring);
|
|
187
234
|
outline-offset: 2px;
|
|
188
235
|
}
|
|
189
236
|
|
|
190
237
|
.sc-tab--active {
|
|
191
|
-
border-color:
|
|
192
|
-
background:
|
|
193
|
-
color:
|
|
238
|
+
border-color: var(--sc-tab-active-border);
|
|
239
|
+
background: var(--sc-tab-active-bg);
|
|
240
|
+
color: var(--sc-tab-active-text);
|
|
194
241
|
}
|
|
@@ -2,12 +2,12 @@ import { toRecordOrUndefined } from "../core/guards.mjs";
|
|
|
2
2
|
import { SchemaNormalisationError } from "../core/errors.mjs";
|
|
3
3
|
import { normaliseSchema } from "../core/adapter.mjs";
|
|
4
4
|
import { walk } from "../core/walker.mjs";
|
|
5
|
+
import { renderField } from "../react/SchemaComponent.mjs";
|
|
5
6
|
import { ApiCallbacks } from "./ApiCallbacks.mjs";
|
|
6
7
|
import { ApiLinks } from "./ApiLinks.mjs";
|
|
7
8
|
import { ApiResponseHeaders } from "./ApiResponseHeaders.mjs";
|
|
8
9
|
import { ApiSecurity } from "./ApiSecurity.mjs";
|
|
9
10
|
import { getLinks, getSecurityRequirements, getSecuritySchemes, listCallbacks } from "./parser.mjs";
|
|
10
|
-
import { renderField } from "../react/SchemaComponent.mjs";
|
|
11
11
|
import { getParsed, resolveOperation, resolveParameters, resolveRequestBody, resolveResponse, toDoc } from "./resolve.mjs";
|
|
12
12
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
13
13
|
//#region src/openapi/components.tsx
|
|
@@ -4,8 +4,8 @@ import { t as SchemaError } from "../errors-C5zRC2PU.mjs";
|
|
|
4
4
|
import { l as RenderProps, r as ComponentResolver } from "../renderer-BdSqllx5.mjs";
|
|
5
5
|
import { c as ResolveOpenAPIRef, s as PathOfType, t as FromJSONSchema } from "../typeInference-k7FXfTVO.mjs";
|
|
6
6
|
import { z } from "zod";
|
|
7
|
-
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
8
7
|
import { ReactNode } from "react";
|
|
8
|
+
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
9
9
|
|
|
10
10
|
//#region src/react/SchemaComponent.d.ts
|
|
11
11
|
/**
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
import { isObject, toRecordOrUndefined } from "../core/guards.mjs";
|
|
3
3
|
import { SchemaFieldError, SchemaNormalisationError, SchemaRenderError } from "../core/errors.mjs";
|
|
4
4
|
import { normaliseSchema } from "../core/adapter.mjs";
|
|
5
|
-
import { getRenderFunction, mergeResolvers } from "../core/renderer.mjs";
|
|
6
5
|
import { walk } from "../core/walker.mjs";
|
|
6
|
+
import { getRenderFunction, mergeResolvers } from "../core/renderer.mjs";
|
|
7
7
|
import { headlessResolver } from "./headless.mjs";
|
|
8
8
|
import { resolvePath, resolveValue, setNestedValue } from "./fieldPath.mjs";
|
|
9
9
|
import { z } from "zod";
|
|
10
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
10
|
import { createContext, isValidElement, useCallback, useContext, useMemo } from "react";
|
|
11
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
12
|
//#region src/react/SchemaComponent.tsx
|
|
13
13
|
/**
|
|
14
14
|
* <SchemaComponent> — renders UI from Zod, JSON Schema, or OpenAPI schemas.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { SchemaNormalisationError, SchemaRenderError } from "../core/errors.mjs";
|
|
2
2
|
import { normaliseSchema } from "../core/adapter.mjs";
|
|
3
|
-
import { getRenderFunction, mergeResolvers } from "../core/renderer.mjs";
|
|
4
3
|
import { walk } from "../core/walker.mjs";
|
|
4
|
+
import { getRenderFunction, mergeResolvers } from "../core/renderer.mjs";
|
|
5
5
|
import { headlessResolver } from "./headless.mjs";
|
|
6
|
-
import { jsx } from "react/jsx-runtime";
|
|
7
6
|
import { createElement, isValidElement } from "react";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
8
|
//#region src/react/SchemaView.tsx
|
|
9
9
|
/**
|
|
10
10
|
* React Server Component for read-only schema rendering.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isObject } from "../core/guards.mjs";
|
|
2
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
2
|
import { isValidElement, useCallback, useRef } from "react";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
//#region src/react/headlessRenderers.tsx
|
|
5
5
|
/**
|
|
6
6
|
* Headless renderer functions — one per schema type.
|
package/dist/themes/mui.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { isObject } from "../core/guards.mjs";
|
|
2
2
|
import { toReactNode } from "../react/headlessRenderers.mjs";
|
|
3
3
|
import { headlessResolver } from "../react/headless.mjs";
|
|
4
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
4
|
import { isValidElement } from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
//#region src/themes/mui.tsx
|
|
7
7
|
function ariaRequired(tree) {
|
|
8
8
|
return { required: tree.isOptional === false };
|