Skip to content

Commit d802845

Browse files
committed
Fix schemaContext
1 parent 49247a0 commit d802845

File tree

6 files changed

+38
-8
lines changed

6 files changed

+38
-8
lines changed

build/index.es.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18225,6 +18225,15 @@ function SchemaFormArray(_a) {
1822518225
updatable && React.createElement("span", { className: "sf-control-button sf-add-button", onClick: handleAdd, title: "Add new" }, "+")));
1822618226
}
1822718227

18228+
var firstNestedString = function (list) {
18229+
if (typeof list === 'string') {
18230+
return [list, 0];
18231+
}
18232+
else {
18233+
var _a = firstNestedString(list[0]), item = _a[0], innerDepth = _a[1];
18234+
return [item, innerDepth + 1];
18235+
}
18236+
};
1822818237
function SchemaFormObject(_a) {
1822918238
var schema = _a.schema, path = _a.path, value = _a.value, errors = _a.errors, onFocus = _a.onFocus, onBlur = _a.onBlur, onEditor = _a.onEditor, context = _a.context;
1823018239
var _b = useState(false), collapsed = _b[0], setCollapsed = _b[1];
@@ -18241,7 +18250,8 @@ function SchemaFormObject(_a) {
1824118250
}
1824218251
}
1824318252
else { // recurse into a section list
18244-
return (React.createElement("section", { key: i || 0 }, order.map(function (subOrder, i) { return renderSection(subOrder, properties, requireds, i); })));
18253+
var _b = firstNestedString(order), firstKey = _b[0], depth = _b[1];
18254+
return (React.createElement("section", { key: i || 0, className: "group-" + depth + "-" + firstKey }, order.map(function (subOrder, i) { return renderSection(subOrder, properties, requireds, i); })));
1824518255
}
1824618256
return React.createElement(React.Fragment, null);
1824718257
}
@@ -27862,7 +27872,7 @@ var SchemaContext = /** @class */ (function () {
2786227872
schema[key] = this.rootSchema['$id'] + schema[key];
2786327873
}
2786427874
else if (schema[key] !== null && typeof (schema[key]) === 'object') {
27865-
schema[key] = this.baseRefsOnRootInner(schema[key]);
27875+
this.baseRefsOnRootInner(schema[key]);
2786627876
}
2786727877
}
2786827878
};

build/index.es.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/index.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18232,6 +18232,15 @@ function SchemaFormArray(_a) {
1823218232
updatable && React__default.createElement("span", { className: "sf-control-button sf-add-button", onClick: handleAdd, title: "Add new" }, "+")));
1823318233
}
1823418234

18235+
var firstNestedString = function (list) {
18236+
if (typeof list === 'string') {
18237+
return [list, 0];
18238+
}
18239+
else {
18240+
var _a = firstNestedString(list[0]), item = _a[0], innerDepth = _a[1];
18241+
return [item, innerDepth + 1];
18242+
}
18243+
};
1823518244
function SchemaFormObject(_a) {
1823618245
var schema = _a.schema, path = _a.path, value = _a.value, errors = _a.errors, onFocus = _a.onFocus, onBlur = _a.onBlur, onEditor = _a.onEditor, context = _a.context;
1823718246
var _b = React.useState(false), collapsed = _b[0], setCollapsed = _b[1];
@@ -18248,7 +18257,8 @@ function SchemaFormObject(_a) {
1824818257
}
1824918258
}
1825018259
else { // recurse into a section list
18251-
return (React__default.createElement("section", { key: i || 0 }, order.map(function (subOrder, i) { return renderSection(subOrder, properties, requireds, i); })));
18260+
var _b = firstNestedString(order), firstKey = _b[0], depth = _b[1];
18261+
return (React__default.createElement("section", { key: i || 0, className: "group-" + depth + "-" + firstKey }, order.map(function (subOrder, i) { return renderSection(subOrder, properties, requireds, i); })));
1825218262
}
1825318263
return React__default.createElement(React__default.Fragment, null);
1825418264
}
@@ -27869,7 +27879,7 @@ var SchemaContext = /** @class */ (function () {
2786927879
schema[key] = this.rootSchema['$id'] + schema[key];
2787027880
}
2787127881
else if (schema[key] !== null && typeof (schema[key]) === 'object') {
27872-
schema[key] = this.baseRefsOnRootInner(schema[key]);
27882+
this.baseRefsOnRootInner(schema[key]);
2787327883
}
2787427884
}
2787527885
};

build/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/schema-form-object.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ import _ from 'lodash';
88
type NestedList = string | NestedListArray;
99
interface NestedListArray extends Array<NestedList> {}
1010

11+
const firstNestedString = (list: NestedList): [ string, number ] => {
12+
if (typeof list === 'string') {
13+
return [ list, 0 ];
14+
} else {
15+
const [ item, innerDepth ] = firstNestedString(list[0]);
16+
return [ item, innerDepth + 1];
17+
}
18+
}
19+
1120
export function SchemaFormObject({
1221
schema,
1322
path,
@@ -41,8 +50,9 @@ export function SchemaFormObject({
4150
)
4251
}
4352
} else { // recurse into a section list
53+
const [ firstKey, depth ] = firstNestedString(order);
4454
return (
45-
<section key={i || 0}>
55+
<section key={i || 0} className={`group-${depth}-${firstKey}`}>
4656
{order.map((subOrder, i) => renderSection(subOrder, properties, requireds, i))}
4757
</section>
4858
)

src/schema/schemaContext.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class SchemaContext {
4040
if (key === '$ref' && schema[key].startsWith('#')) {
4141
schema[key] = this.rootSchema['$id'] + schema[key];
4242
} else if (schema[key] !== null && typeof(schema[key]) === 'object') {
43-
schema[key] = this.baseRefsOnRootInner(schema[key]);
43+
this.baseRefsOnRootInner(schema[key]);
4444
}
4545
}
4646
}

0 commit comments

Comments
 (0)