@limetech/lime-elements 40.17.0 → 40.17.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/CHANGELOG.md +8 -0
- package/dist/cjs/heading-level-BxCuIKkm.js +14 -0
- package/dist/cjs/limel-collapsible-section.cjs.entry.js +4 -9
- package/dist/cjs/limel-file-viewer.cjs.entry.js +422 -248
- package/dist/cjs/limel-form-header.cjs.entry.js +1 -1
- package/dist/cjs/limel-form.cjs.entry.js +23 -20
- package/dist/collection/components/collapsible-section/collapsible-section.js +11 -9
- package/dist/collection/components/form/form.js +8 -6
- package/dist/collection/components/form/form.test-schemas.js +68 -0
- package/dist/collection/components/form/templates/array-field-collapsible-item.js +13 -3
- package/dist/collection/components/form/templates/heading-level.js +0 -10
- package/dist/collection/components/form/templates/object-field.js +6 -3
- package/dist/collection/components/form-header/form-header.js +3 -3
- package/dist/collection/global/shared-types/heading-level.types.js +1 -0
- package/dist/collection/interface.js +1 -0
- package/dist/collection/util/heading-level.js +10 -0
- package/dist/esm/heading-level-B3C0kDpZ.js +12 -0
- package/dist/esm/limel-collapsible-section.entry.js +2 -7
- package/dist/esm/limel-file-viewer.entry.js +422 -248
- package/dist/esm/limel-form-header.entry.js +1 -1
- package/dist/esm/limel-form.entry.js +21 -18
- package/dist/lime-elements/lime-elements.esm.js +1 -1
- package/dist/lime-elements/p-49a53f0b.entry.js +1 -0
- package/dist/lime-elements/{p-72907ffd.entry.js → p-68129487.entry.js} +1 -1
- package/dist/lime-elements/{p-9436aba6.entry.js → p-74db50a8.entry.js} +4 -4
- package/dist/lime-elements/p-B3C0kDpZ.js +1 -0
- package/dist/lime-elements/p-e8255f0b.entry.js +1 -0
- package/dist/types/components/collapsible-section/collapsible-section.d.ts +2 -1
- package/dist/types/components/form/form.d.ts +4 -2
- package/dist/types/components/form/form.test-schemas.d.ts +3 -0
- package/dist/types/components/form/form.types.d.ts +0 -6
- package/dist/types/components/form/row/row.d.ts +1 -1
- package/dist/types/components/form/templates/array-field-collapsible-item.d.ts +5 -1
- package/dist/types/components/form/templates/heading-level.d.ts +1 -6
- package/dist/types/components/form/templates/object-field.d.ts +2 -0
- package/dist/types/components/form-header/form-header.d.ts +1 -1
- package/dist/types/components.d.ts +9 -7
- package/dist/types/global/shared-types/heading-level.types.d.ts +7 -0
- package/dist/types/interface.d.ts +2 -1
- package/dist/types/util/heading-level.d.ts +7 -0
- package/package.json +2 -2
- package/dist/lime-elements/p-1d13245d.entry.js +0 -1
- package/dist/lime-elements/p-e6be5819.entry.js +0 -1
|
@@ -32,7 +32,7 @@ const FormHeader = class {
|
|
|
32
32
|
this.headingLevel = 1;
|
|
33
33
|
}
|
|
34
34
|
render() {
|
|
35
|
-
return (index.h(index.Host, { key: '
|
|
35
|
+
return (index.h(index.Host, { key: '0d8282124405665c18b93aa753dd40cf616a6e6b' }, this.renderHeading(), this.renderHelp(), this.renderDescription()));
|
|
36
36
|
}
|
|
37
37
|
renderHeading() {
|
|
38
38
|
if (!this.heading) {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var index = require('./index-BlsqxTB1.js');
|
|
4
4
|
var _commonjsHelpers = require('./_commonjsHelpers-CFO10eej.js');
|
|
5
|
+
var headingLevel = require('./heading-level-BxCuIKkm.js');
|
|
5
6
|
var _baseIteratee = require('./_baseIteratee-Cistiy8H.js');
|
|
6
7
|
var isEmpty = require('./isEmpty-BsdhcVKT.js');
|
|
7
8
|
var helpProps = require('./help-props-Ds30nnt1.js');
|
|
@@ -44023,16 +44024,6 @@ function isType(input, type) {
|
|
|
44023
44024
|
return input === type;
|
|
44024
44025
|
}
|
|
44025
44026
|
|
|
44026
|
-
/**
|
|
44027
|
-
* @param level - any value
|
|
44028
|
-
* @returns whether the value is a heading level, from `1` to `6`
|
|
44029
|
-
*/
|
|
44030
|
-
function isHeadingLevel(level) {
|
|
44031
|
-
return (typeof level === 'number' &&
|
|
44032
|
-
Number.isSafeInteger(level) &&
|
|
44033
|
-
level >= 1 &&
|
|
44034
|
-
level <= 6);
|
|
44035
|
-
}
|
|
44036
44027
|
/**
|
|
44037
44028
|
* The heading level that a title at the current depth in the form gets.
|
|
44038
44029
|
*/
|
|
@@ -44398,6 +44389,7 @@ const ArrayItemErrorsContext = reactExports.createContext(null);
|
|
|
44398
44389
|
|
|
44399
44390
|
const ObjectFieldTemplate = (props) => {
|
|
44400
44391
|
const arrayContext = reactExports.useContext(ArrayFieldContext);
|
|
44392
|
+
const headingLevel = reactExports.useContext(HeadingLevelContext);
|
|
44401
44393
|
const id = props.fieldPathId.$id;
|
|
44402
44394
|
if (arrayContext && id !== 'root') {
|
|
44403
44395
|
return React.createElement(ArrayFieldContext.Provider, { value: null }, renderProperties(props.properties, props.schema, props.fieldPathId.path.map(String)));
|
|
@@ -44405,13 +44397,13 @@ const ObjectFieldTemplate = (props) => {
|
|
|
44405
44397
|
if (id === 'root' || !isCollapsible(props.schema)) {
|
|
44406
44398
|
return renderFieldWithTitle(props);
|
|
44407
44399
|
}
|
|
44408
|
-
return renderCollapsibleField(props);
|
|
44400
|
+
return renderCollapsibleField(props, headingLevel);
|
|
44409
44401
|
};
|
|
44410
44402
|
function renderFieldWithTitle(props) {
|
|
44411
44403
|
var _a;
|
|
44412
44404
|
return renderSection(props.title, props.description, (_a = props.schema.lime) === null || _a === void 0 ? void 0 : _a.help, renderProperties(props.properties, props.schema, props.fieldPathId.path.map(String)));
|
|
44413
44405
|
}
|
|
44414
|
-
function renderCollapsibleField(props) {
|
|
44406
|
+
function renderCollapsibleField(props, headingLevel) {
|
|
44415
44407
|
var _a;
|
|
44416
44408
|
const defaultOpen = !isCollapsed(props.schema);
|
|
44417
44409
|
const helpElement = getHelpComponent(props.schema, {
|
|
@@ -44421,10 +44413,11 @@ function renderCollapsibleField(props) {
|
|
|
44421
44413
|
const invalid = revealErrors && hasNestedErrors(props.errorSchema);
|
|
44422
44414
|
return React.createElement('limel-collapsible-section', {
|
|
44423
44415
|
header: props.title,
|
|
44416
|
+
headingLevel: headingLevel,
|
|
44424
44417
|
id: getSchemaObjectPropertyPath(props.registry.formContext.schema, props.fieldPathId),
|
|
44425
44418
|
'is-open': defaultOpen,
|
|
44426
44419
|
invalid: invalid,
|
|
44427
|
-
}, helpElement, renderDescription(props.description), renderProperties(props.properties, props.schema, props.fieldPathId.path.map(String)));
|
|
44420
|
+
}, helpElement, renderDescription(props.description), React.createElement(BelowHeading, { hasHeading: !!props.title }, renderProperties(props.properties, props.schema, props.fieldPathId.path.map(String))));
|
|
44428
44421
|
}
|
|
44429
44422
|
function getSchemaObjectPropertyPath(schema, fieldPathId) {
|
|
44430
44423
|
var _a, _b;
|
|
@@ -44821,10 +44814,11 @@ class CollapsibleItemTemplate extends React.Component {
|
|
|
44821
44814
|
section.removeEventListener('open', this.handleOpen);
|
|
44822
44815
|
}
|
|
44823
44816
|
render() {
|
|
44824
|
-
const {
|
|
44817
|
+
const { errorSchema, revealErrors } = this.props;
|
|
44818
|
+
const header = getItemHeader(this.props);
|
|
44825
44819
|
let children;
|
|
44826
44820
|
if (this.state.isOpen) {
|
|
44827
|
-
children = this.props.children;
|
|
44821
|
+
children = React.createElement(BelowHeading, { hasHeading: !!header }, this.props.children);
|
|
44828
44822
|
}
|
|
44829
44823
|
const dragHandle = this.props.allowItemReorder
|
|
44830
44824
|
? React.createElement('limel-drag-handle', {
|
|
@@ -44834,7 +44828,8 @@ class CollapsibleItemTemplate extends React.Component {
|
|
|
44834
44828
|
: null;
|
|
44835
44829
|
const invalid = revealErrors === true && hasNestedErrors(errorSchema);
|
|
44836
44830
|
return React.createElement('limel-collapsible-section', {
|
|
44837
|
-
header:
|
|
44831
|
+
header: header,
|
|
44832
|
+
headingLevel: this.context,
|
|
44838
44833
|
class: 'array-item limel-form-array-item--object',
|
|
44839
44834
|
ref: (section) => {
|
|
44840
44835
|
this.section = section;
|
|
@@ -44866,6 +44861,13 @@ class CollapsibleItemTemplate extends React.Component {
|
|
|
44866
44861
|
event.detail.run(event);
|
|
44867
44862
|
}
|
|
44868
44863
|
}
|
|
44864
|
+
CollapsibleItemTemplate.contextType = HeadingLevelContext;
|
|
44865
|
+
function getItemHeader(props) {
|
|
44866
|
+
const { data, schema, formSchema } = props;
|
|
44867
|
+
const title = findTitle(data, schema, formSchema);
|
|
44868
|
+
const text = Array.isArray(title) ? title.join(', ') : title;
|
|
44869
|
+
return text ? String(text) : 'New item';
|
|
44870
|
+
}
|
|
44869
44871
|
/**
|
|
44870
44872
|
* An item counts as new while it holds nothing the user entered. Since
|
|
44871
44873
|
* `@rjsf/core` 6.10 fills a required property with its default as soon as the
|
|
@@ -46158,7 +46160,8 @@ const Form = class {
|
|
|
46158
46160
|
/**
|
|
46159
46161
|
* The level, from `1` to `6`, of the topmost headings in the form.
|
|
46160
46162
|
* The headings of the sections inside them get one level more for each
|
|
46161
|
-
* level of nesting, down to `6`.
|
|
46163
|
+
* level of nesting, down to `6`. A collapsible section, and each item
|
|
46164
|
+
* of a list that is shown as one, counts as a level too.
|
|
46162
46165
|
*
|
|
46163
46166
|
* Set it so that the headings of the form fit below the headings of
|
|
46164
46167
|
* the page around it. For example, when the form is in a section with
|
|
@@ -46191,7 +46194,7 @@ const Form = class {
|
|
|
46191
46194
|
this.warnIfHeadingLevelIsInvalid();
|
|
46192
46195
|
}
|
|
46193
46196
|
warnIfHeadingLevelIsInvalid() {
|
|
46194
|
-
if (!isHeadingLevel(this.headingLevel)) {
|
|
46197
|
+
if (!headingLevel.isHeadingLevel(this.headingLevel)) {
|
|
46195
46198
|
console.warn(`limel-form: headingLevel must be a number from 1 to 6, but it is ${this.headingLevel}. The headings start at level 1 instead.`);
|
|
46196
46199
|
}
|
|
46197
46200
|
}
|
|
@@ -46221,7 +46224,7 @@ const Form = class {
|
|
|
46221
46224
|
this.initialized = false;
|
|
46222
46225
|
}
|
|
46223
46226
|
render() {
|
|
46224
|
-
return index.h("div", { key: '
|
|
46227
|
+
return index.h("div", { key: 'e986502a86c34465c7e3f2af89372e00809e4705', class: "root" });
|
|
46225
46228
|
}
|
|
46226
46229
|
reactRender() {
|
|
46227
46230
|
if (!this.root) {
|
|
@@ -46229,7 +46232,7 @@ const Form = class {
|
|
|
46229
46232
|
this.root = clientExports.createRoot(rootElement);
|
|
46230
46233
|
}
|
|
46231
46234
|
this.root.render(React.createElement(HeadingLevelContext.Provider, {
|
|
46232
|
-
value: isHeadingLevel(this.headingLevel)
|
|
46235
|
+
value: headingLevel.isHeadingLevel(this.headingLevel)
|
|
46233
46236
|
? this.headingLevel
|
|
46234
46237
|
: 1,
|
|
46235
46238
|
}, React.createElement(Form$1, {
|
|
@@ -4,13 +4,8 @@ import { makeEnterClickable, removeEnterClickable, } from "../../util/make-enter
|
|
|
4
4
|
import { createRandomString } from "../../util/random-string";
|
|
5
5
|
import { getIconColor, getIconName, getIconTitle, } from "../icon/get-icon-props";
|
|
6
6
|
import translate from "../../global/translations";
|
|
7
|
+
import { isHeadingLevel } from "../../util/heading-level";
|
|
7
8
|
const DEFAULT_HEADING_LEVEL = 2;
|
|
8
|
-
function isHeadingLevel(level) {
|
|
9
|
-
return (typeof level === 'number' &&
|
|
10
|
-
Number.isSafeInteger(level) &&
|
|
11
|
-
level >= 1 &&
|
|
12
|
-
level <= 6);
|
|
13
|
-
}
|
|
14
9
|
/**
|
|
15
10
|
* A collapsible section can be used to group related content together
|
|
16
11
|
* and hide the group when not needed.
|
|
@@ -135,7 +130,7 @@ export class CollapsibleSection {
|
|
|
135
130
|
removeEnterClickable(button);
|
|
136
131
|
}
|
|
137
132
|
render() {
|
|
138
|
-
return (h("section", { key: '
|
|
133
|
+
return (h("section", { key: 'ff18dacc5e74d3bd8d16da55be3e5340922acf86', class: `${this.isOpen ? 'open' : ''}`, "aria-invalid": this.invalid, "aria-labelledby": this.header ? this.headingId : null }, h("header", { key: 'f4dba35493c7ce7344ff34d2fbaeeb769f8c87eb' }, h("button", { key: 'd3a632b4002d01774c9bb88f250be4e196340ef3', class: "open-close-toggle", onClick: this.onClick, "aria-controls": this.bodyId, "aria-expanded": this.isOpen ? 'true' : 'false', "aria-label": this.getCollapsibleSectionAriaLabel(), type: "button" }), this.renderExpandCollapseSign(), this.renderIcon(), this.renderHeading(), h("div", { key: '8d8489917d5e1bfa8de3cca8294651f448c8129c', class: "divider-line", role: "presentation" }), this.renderHeaderSlot(), this.renderActions()), h("div", { key: 'fd7e13cf3bd26815d62c3fbac0ef04ed4db364b5', class: "body", inert: !this.isOpen, "aria-hidden": String(!this.isOpen), id: this.bodyId, role: "region" }, h("slot", { key: '90ed08286c1091f5c5c5feec827729cfa65588fc' }))));
|
|
139
134
|
}
|
|
140
135
|
getHeadingLevel() {
|
|
141
136
|
return isHeadingLevel(this.headingLevel)
|
|
@@ -207,9 +202,16 @@ export class CollapsibleSection {
|
|
|
207
202
|
"type": "number",
|
|
208
203
|
"mutable": false,
|
|
209
204
|
"complexType": {
|
|
210
|
-
"original": "
|
|
205
|
+
"original": "HeadingLevel",
|
|
211
206
|
"resolved": "1 | 2 | 3 | 4 | 5 | 6",
|
|
212
|
-
"references": {
|
|
207
|
+
"references": {
|
|
208
|
+
"HeadingLevel": {
|
|
209
|
+
"location": "import",
|
|
210
|
+
"path": "../../global/shared-types/heading-level.types",
|
|
211
|
+
"id": "src/global/shared-types/heading-level.types.ts::HeadingLevel",
|
|
212
|
+
"referenceLocation": "HeadingLevel"
|
|
213
|
+
}
|
|
214
|
+
}
|
|
213
215
|
},
|
|
214
216
|
"required": false,
|
|
215
217
|
"optional": false,
|
|
@@ -14,6 +14,7 @@ import { h, } from "@stencil/core";
|
|
|
14
14
|
import React from "react";
|
|
15
15
|
import { createRoot } from "react-dom/client";
|
|
16
16
|
import JSONSchemaForm from "@rjsf/core";
|
|
17
|
+
import { isHeadingLevel } from "../../util/heading-level";
|
|
17
18
|
import { ArrayFieldTemplate, ArrayFieldItemTemplate, FieldTemplate, ObjectFieldTemplate, } from "./templates";
|
|
18
19
|
import { SchemaField as CustomSchemaField } from "./fields/schema-field";
|
|
19
20
|
import { ArrayField as CustomArrayField } from "./fields/array-field";
|
|
@@ -22,7 +23,7 @@ import { widgets } from "./widgets";
|
|
|
22
23
|
import { rjsfValidator } from "./validator";
|
|
23
24
|
import { isEqual, mapValues } from "lodash-es";
|
|
24
25
|
import { showField } from "./show-field";
|
|
25
|
-
import { HeadingLevelContext
|
|
26
|
+
import { HeadingLevelContext } from "./templates/heading-level";
|
|
26
27
|
/**
|
|
27
28
|
* @exampleComponent limel-example-form
|
|
28
29
|
* @exampleComponent limel-example-nested-form
|
|
@@ -56,7 +57,8 @@ export class Form {
|
|
|
56
57
|
/**
|
|
57
58
|
* The level, from `1` to `6`, of the topmost headings in the form.
|
|
58
59
|
* The headings of the sections inside them get one level more for each
|
|
59
|
-
* level of nesting, down to `6`.
|
|
60
|
+
* level of nesting, down to `6`. A collapsible section, and each item
|
|
61
|
+
* of a list that is shown as one, counts as a level too.
|
|
60
62
|
*
|
|
61
63
|
* Set it so that the headings of the form fit below the headings of
|
|
62
64
|
* the page around it. For example, when the form is in a section with
|
|
@@ -119,7 +121,7 @@ export class Form {
|
|
|
119
121
|
this.initialized = false;
|
|
120
122
|
}
|
|
121
123
|
render() {
|
|
122
|
-
return h("div", { key: '
|
|
124
|
+
return h("div", { key: 'e986502a86c34465c7e3f2af89372e00809e4705', class: "root" });
|
|
123
125
|
}
|
|
124
126
|
reactRender() {
|
|
125
127
|
if (!this.root) {
|
|
@@ -419,8 +421,8 @@ export class Form {
|
|
|
419
421
|
"references": {
|
|
420
422
|
"HeadingLevel": {
|
|
421
423
|
"location": "import",
|
|
422
|
-
"path": "
|
|
423
|
-
"id": "src/
|
|
424
|
+
"path": "../../global/shared-types/heading-level.types",
|
|
425
|
+
"id": "src/global/shared-types/heading-level.types.ts::HeadingLevel",
|
|
424
426
|
"referenceLocation": "HeadingLevel"
|
|
425
427
|
}
|
|
426
428
|
}
|
|
@@ -429,7 +431,7 @@ export class Form {
|
|
|
429
431
|
"optional": false,
|
|
430
432
|
"docs": {
|
|
431
433
|
"tags": [],
|
|
432
|
-
"text": "The level, from `1` to `6`, of the topmost headings in the form.\nThe headings of the sections inside them get one level more for each\nlevel of nesting, down to `6
|
|
434
|
+
"text": "The level, from `1` to `6`, of the topmost headings in the form.\nThe headings of the sections inside them get one level more for each\nlevel of nesting, down to `6`. A collapsible section, and each item\nof a list that is shown as one, counts as a level too.\n\nSet it so that the headings of the form fit below the headings of\nthe page around it. For example, when the form is in a section with\nan `h2` heading, set it to `3`."
|
|
433
435
|
},
|
|
434
436
|
"getter": false,
|
|
435
437
|
"setter": false,
|
|
@@ -455,6 +455,26 @@ export const nestedArrayObjectSchema = {
|
|
|
455
455
|
},
|
|
456
456
|
},
|
|
457
457
|
};
|
|
458
|
+
export const arrayItemWithEmptyListSchema = {
|
|
459
|
+
type: 'object',
|
|
460
|
+
properties: {
|
|
461
|
+
people: {
|
|
462
|
+
type: 'array',
|
|
463
|
+
title: 'People',
|
|
464
|
+
items: {
|
|
465
|
+
type: 'object',
|
|
466
|
+
properties: {
|
|
467
|
+
tags: {
|
|
468
|
+
type: 'array',
|
|
469
|
+
title: 'Tags',
|
|
470
|
+
items: { type: 'string' },
|
|
471
|
+
},
|
|
472
|
+
role: { type: 'string', title: 'Role' },
|
|
473
|
+
},
|
|
474
|
+
},
|
|
475
|
+
},
|
|
476
|
+
},
|
|
477
|
+
};
|
|
458
478
|
export const topLevelStringCustomComponentSchema = {
|
|
459
479
|
type: 'object',
|
|
460
480
|
properties: {
|
|
@@ -729,6 +749,54 @@ export const untitledRootSchema = {
|
|
|
729
749
|
},
|
|
730
750
|
},
|
|
731
751
|
};
|
|
752
|
+
export const nestedCollapsibleSchema = {
|
|
753
|
+
type: 'object',
|
|
754
|
+
title: 'Form',
|
|
755
|
+
properties: {
|
|
756
|
+
details: {
|
|
757
|
+
type: 'object',
|
|
758
|
+
title: 'Details',
|
|
759
|
+
lime: { collapsible: true },
|
|
760
|
+
properties: {
|
|
761
|
+
address: {
|
|
762
|
+
type: 'object',
|
|
763
|
+
title: 'Address',
|
|
764
|
+
lime: { collapsible: true },
|
|
765
|
+
properties: {
|
|
766
|
+
street: { type: 'string', title: 'Street' },
|
|
767
|
+
position: {
|
|
768
|
+
type: 'object',
|
|
769
|
+
title: 'Position',
|
|
770
|
+
properties: {
|
|
771
|
+
latitude: { type: 'number', title: 'Latitude' },
|
|
772
|
+
},
|
|
773
|
+
},
|
|
774
|
+
},
|
|
775
|
+
},
|
|
776
|
+
},
|
|
777
|
+
},
|
|
778
|
+
},
|
|
779
|
+
};
|
|
780
|
+
export const untitledCollapsibleSchema = {
|
|
781
|
+
type: 'object',
|
|
782
|
+
title: 'Form',
|
|
783
|
+
properties: {
|
|
784
|
+
details: {
|
|
785
|
+
type: 'object',
|
|
786
|
+
title: '',
|
|
787
|
+
lime: { collapsible: true },
|
|
788
|
+
properties: {
|
|
789
|
+
section: {
|
|
790
|
+
type: 'object',
|
|
791
|
+
title: 'Section',
|
|
792
|
+
properties: {
|
|
793
|
+
name: { type: 'string', title: 'Name' },
|
|
794
|
+
},
|
|
795
|
+
},
|
|
796
|
+
},
|
|
797
|
+
},
|
|
798
|
+
},
|
|
799
|
+
};
|
|
732
800
|
export const untitledRowSchema = {
|
|
733
801
|
type: 'object',
|
|
734
802
|
title: 'Form',
|
|
@@ -3,6 +3,7 @@ import { findTitle, hasNestedErrors } from "./common";
|
|
|
3
3
|
import { getDefaultFormState, } from "@rjsf/utils";
|
|
4
4
|
import { isEmpty, isEqual } from "lodash-es";
|
|
5
5
|
import { rjsfValidator } from "../validator";
|
|
6
|
+
import { BelowHeading, HeadingLevelContext } from "./heading-level";
|
|
6
7
|
export class CollapsibleItemTemplate extends React.Component {
|
|
7
8
|
constructor(props) {
|
|
8
9
|
super(props);
|
|
@@ -35,10 +36,11 @@ export class CollapsibleItemTemplate extends React.Component {
|
|
|
35
36
|
section.removeEventListener('open', this.handleOpen);
|
|
36
37
|
}
|
|
37
38
|
render() {
|
|
38
|
-
const {
|
|
39
|
+
const { errorSchema, revealErrors } = this.props;
|
|
40
|
+
const header = getItemHeader(this.props);
|
|
39
41
|
let children;
|
|
40
42
|
if (this.state.isOpen) {
|
|
41
|
-
children = this.props.children;
|
|
43
|
+
children = React.createElement(BelowHeading, { hasHeading: !!header }, this.props.children);
|
|
42
44
|
}
|
|
43
45
|
const dragHandle = this.props.allowItemReorder
|
|
44
46
|
? React.createElement('limel-drag-handle', {
|
|
@@ -48,7 +50,8 @@ export class CollapsibleItemTemplate extends React.Component {
|
|
|
48
50
|
: null;
|
|
49
51
|
const invalid = revealErrors === true && hasNestedErrors(errorSchema);
|
|
50
52
|
return React.createElement('limel-collapsible-section', {
|
|
51
|
-
header:
|
|
53
|
+
header: header,
|
|
54
|
+
headingLevel: this.context,
|
|
52
55
|
class: 'array-item limel-form-array-item--object',
|
|
53
56
|
ref: (section) => {
|
|
54
57
|
this.section = section;
|
|
@@ -80,6 +83,13 @@ export class CollapsibleItemTemplate extends React.Component {
|
|
|
80
83
|
event.detail.run(event);
|
|
81
84
|
}
|
|
82
85
|
}
|
|
86
|
+
CollapsibleItemTemplate.contextType = HeadingLevelContext;
|
|
87
|
+
function getItemHeader(props) {
|
|
88
|
+
const { data, schema, formSchema } = props;
|
|
89
|
+
const title = findTitle(data, schema, formSchema);
|
|
90
|
+
const text = Array.isArray(title) ? title.join(', ') : title;
|
|
91
|
+
return text ? String(text) : 'New item';
|
|
92
|
+
}
|
|
83
93
|
/**
|
|
84
94
|
* An item counts as new while it holds nothing the user entered. Since
|
|
85
95
|
* `@rjsf/core` 6.10 fills a required property with its default as soon as the
|
|
@@ -1,14 +1,4 @@
|
|
|
1
1
|
import React, { useContext } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* @param level - any value
|
|
4
|
-
* @returns whether the value is a heading level, from `1` to `6`
|
|
5
|
-
*/
|
|
6
|
-
export function isHeadingLevel(level) {
|
|
7
|
-
return (typeof level === 'number' &&
|
|
8
|
-
Number.isSafeInteger(level) &&
|
|
9
|
-
level >= 1 &&
|
|
10
|
-
level <= 6);
|
|
11
|
-
}
|
|
12
2
|
/**
|
|
13
3
|
* The heading level that a title at the current depth in the form gets.
|
|
14
4
|
*/
|
|
@@ -4,8 +4,10 @@ import { GridLayout } from "./grid-layout";
|
|
|
4
4
|
import { RowLayout } from "./row-layout";
|
|
5
5
|
import { getHelpComponent } from "../help";
|
|
6
6
|
import { ArrayFieldContext } from "./array-context";
|
|
7
|
+
import { BelowHeading, HeadingLevelContext } from "./heading-level";
|
|
7
8
|
export const ObjectFieldTemplate = (props) => {
|
|
8
9
|
const arrayContext = useContext(ArrayFieldContext);
|
|
10
|
+
const headingLevel = useContext(HeadingLevelContext);
|
|
9
11
|
const id = props.fieldPathId.$id;
|
|
10
12
|
if (arrayContext && id !== 'root') {
|
|
11
13
|
return React.createElement(ArrayFieldContext.Provider, { value: null }, renderProperties(props.properties, props.schema, props.fieldPathId.path.map(String)));
|
|
@@ -13,13 +15,13 @@ export const ObjectFieldTemplate = (props) => {
|
|
|
13
15
|
if (id === 'root' || !isCollapsible(props.schema)) {
|
|
14
16
|
return renderFieldWithTitle(props);
|
|
15
17
|
}
|
|
16
|
-
return renderCollapsibleField(props);
|
|
18
|
+
return renderCollapsibleField(props, headingLevel);
|
|
17
19
|
};
|
|
18
20
|
function renderFieldWithTitle(props) {
|
|
19
21
|
var _a;
|
|
20
22
|
return renderSection(props.title, props.description, (_a = props.schema.lime) === null || _a === void 0 ? void 0 : _a.help, renderProperties(props.properties, props.schema, props.fieldPathId.path.map(String)));
|
|
21
23
|
}
|
|
22
|
-
function renderCollapsibleField(props) {
|
|
24
|
+
function renderCollapsibleField(props, headingLevel) {
|
|
23
25
|
var _a;
|
|
24
26
|
const defaultOpen = !isCollapsed(props.schema);
|
|
25
27
|
const helpElement = getHelpComponent(props.schema, {
|
|
@@ -29,10 +31,11 @@ function renderCollapsibleField(props) {
|
|
|
29
31
|
const invalid = revealErrors && hasNestedErrors(props.errorSchema);
|
|
30
32
|
return React.createElement('limel-collapsible-section', {
|
|
31
33
|
header: props.title,
|
|
34
|
+
headingLevel: headingLevel,
|
|
32
35
|
id: getSchemaObjectPropertyPath(props.registry.formContext.schema, props.fieldPathId),
|
|
33
36
|
'is-open': defaultOpen,
|
|
34
37
|
invalid: invalid,
|
|
35
|
-
}, helpElement, renderDescription(props.description), renderProperties(props.properties, props.schema, props.fieldPathId.path.map(String)));
|
|
38
|
+
}, helpElement, renderDescription(props.description), React.createElement(BelowHeading, { hasHeading: !!props.title }, renderProperties(props.properties, props.schema, props.fieldPathId.path.map(String))));
|
|
36
39
|
}
|
|
37
40
|
function getSchemaObjectPropertyPath(schema, fieldPathId) {
|
|
38
41
|
var _a, _b;
|
|
@@ -29,7 +29,7 @@ export class FormHeader {
|
|
|
29
29
|
this.headingLevel = 1;
|
|
30
30
|
}
|
|
31
31
|
render() {
|
|
32
|
-
return (h(Host, { key: '
|
|
32
|
+
return (h(Host, { key: '0d8282124405665c18b93aa753dd40cf616a6e6b' }, this.renderHeading(), this.renderHelp(), this.renderDescription()));
|
|
33
33
|
}
|
|
34
34
|
renderHeading() {
|
|
35
35
|
if (!this.heading) {
|
|
@@ -91,8 +91,8 @@ export class FormHeader {
|
|
|
91
91
|
"references": {
|
|
92
92
|
"HeadingLevel": {
|
|
93
93
|
"location": "import",
|
|
94
|
-
"path": "
|
|
95
|
-
"id": "src/
|
|
94
|
+
"path": "../../global/shared-types/heading-level.types",
|
|
95
|
+
"id": "src/global/shared-types/heading-level.types.ts::HeadingLevel",
|
|
96
96
|
"referenceLocation": "HeadingLevel"
|
|
97
97
|
}
|
|
98
98
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -44,6 +44,7 @@ export * from './global/shared-types/separator.types';
|
|
|
44
44
|
export * from './global/shared-types/icon.types';
|
|
45
45
|
export * from './global/shared-types/image.types';
|
|
46
46
|
export * from './global/shared-types/color.types';
|
|
47
|
+
export * from './global/shared-types/heading-level.types';
|
|
47
48
|
export * from './components/text-editor/text-editor.types';
|
|
48
49
|
export * from './components/text-editor/types';
|
|
49
50
|
export * from './components/text-editor/prosemirror-adapter/menu/types';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param level - any value
|
|
3
|
+
* @returns whether the value is a heading level, from `1` to `6`
|
|
4
|
+
*/
|
|
5
|
+
function isHeadingLevel(level) {
|
|
6
|
+
return (typeof level === 'number' &&
|
|
7
|
+
Number.isSafeInteger(level) &&
|
|
8
|
+
level >= 1 &&
|
|
9
|
+
level <= 6);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { isHeadingLevel as i };
|
|
@@ -4,17 +4,12 @@ import { m as makeEnterClickable, r as removeEnterClickable } from './make-enter
|
|
|
4
4
|
import { c as createRandomString } from './random-string-BrjD-ITe.js';
|
|
5
5
|
import { b as getIconColor, d as getIconTitle, g as getIconName } from './get-icon-props-CgNJbSP4.js';
|
|
6
6
|
import { t as translations } from './translations-Drl5LNAD.js';
|
|
7
|
+
import { i as isHeadingLevel } from './heading-level-B3C0kDpZ.js';
|
|
7
8
|
import './language-ChagAaNf.js';
|
|
8
9
|
|
|
9
10
|
const collapsibleSectionCss = () => `@charset "UTF-8";.expand-icon{position:relative;display:flex;align-items:center;justify-content:center;height:1.875rem;margin:0 0 0 0.5rem;width:0.75rem;flex-shrink:0}.line{position:absolute;inset:auto;margin:auto;width:100%;border-radius:1rem;height:0.125rem}.line:first-of-type,.line:last-of-type{transition:opacity 0.2s ease 0.1s, transform 0.4s ease 0.3s;opacity:0;background-color:var(--header-stroke-color, rgb(var(--contrast-900)))}.line:nth-of-type(2){transform:translate3d(0, 0.25rem, 0) rotate(90deg)}.line:nth-of-type(3){transform:translate3d(0, -0.25rem, 0) rotate(-90deg)}.line:nth-of-type(2),.line:nth-of-type(3){transition:opacity 0.2s ease, transform 0.18s ease}.line:nth-of-type(2):before,.line:nth-of-type(2):after,.line:nth-of-type(3):before,.line:nth-of-type(3):after{content:"";position:absolute;inset:0;margin:auto;width:50%;height:100%;border-radius:inherit;background-color:var(--header-stroke-color, rgb(var(--contrast-900)))}.line:nth-of-type(2):before,.line:nth-of-type(3):before{transform:translate3d(0, -0.1rem, 0) rotate(45deg)}.line:nth-of-type(2):after,.line:nth-of-type(3):after{transform:translate3d(0, 0.1rem, 0) rotate(-45deg)}.open-close-toggle:hover+.expand-icon .line:first-of-type,.open-close-toggle:hover+.expand-icon .line:last-of-type,.open-close-toggle:focus-visible+.expand-icon .line:first-of-type,.open-close-toggle:focus-visible+.expand-icon .line:last-of-type{transition:opacity 0.8s ease 0.4s, transform 0.4s ease 0.3s;opacity:1}.open-close-toggle:hover+.expand-icon .line:first-of-type,.open-close-toggle:focus-visible+.expand-icon .line:first-of-type{transform:rotate3d(0, 0, 1, 0deg)}.open-close-toggle:hover+.expand-icon .line:last-of-type,.open-close-toggle:focus-visible+.expand-icon .line:last-of-type{transform:rotate3d(0, 0, 1, 0deg)}.open-close-toggle:hover+.expand-icon .line:nth-of-type(2),.open-close-toggle:hover+.expand-icon .line:nth-of-type(3),.open-close-toggle:focus-visible+.expand-icon .line:nth-of-type(2),.open-close-toggle:focus-visible+.expand-icon .line:nth-of-type(3){transition:opacity 0.5s ease 0.4s, transform 0.7s cubic-bezier(0.85, 0.11, 0.14, 1.35) 0.2s}.open-close-toggle:hover+.expand-icon .line:nth-of-type(2),.open-close-toggle:focus-visible+.expand-icon .line:nth-of-type(2){transform:translate3d(0, 0.5rem, 0) rotate(90deg);opacity:0.4}.open-close-toggle:hover+.expand-icon .line:nth-of-type(3),.open-close-toggle:focus-visible+.expand-icon .line:nth-of-type(3){transform:translate3d(0, -0.5rem, 0) rotate(-90deg);opacity:0.4}section.open .line:first-of-type,section.open .line:last-of-type{transition:opacity 0.2s ease 0.1s, transform 0.4s ease 0.3s;opacity:1}section.open .line:first-of-type{transform:rotate3d(0, 0, 1, 0deg)}section.open .line:last-of-type{transform:rotate3d(0, 0, 1, 0deg)}section.open .line:nth-of-type(2),section.open .line:nth-of-type(3){transition:opacity 1s ease, transform 0.4s ease}section.open .line:nth-of-type(2){transform:translate3d(0, 1rem, 0) rotate(90deg);opacity:0}section.open .line:nth-of-type(3){transform:translate3d(0, -1rem, 0) rotate(-90deg);opacity:0}section.open .open-close-toggle:hover+.expand-icon .line:first-of-type,section.open .open-close-toggle:hover+.expand-icon .line:last-of-type,section.open .open-close-toggle:focus-visible+.expand-icon .line:first-of-type,section.open .open-close-toggle:focus-visible+.expand-icon .line:last-of-type{transition:opacity 0.2s ease 0.4s, transform 0.4s cubic-bezier(0.85, 0.11, 0.14, 1.35) 0.2s}section.open .open-close-toggle:hover+.expand-icon .line:first-of-type,section.open .open-close-toggle:focus-visible+.expand-icon .line:first-of-type{transform:rotate3d(0, 0, 1, 45deg)}section.open .open-close-toggle:hover+.expand-icon .line:last-of-type,section.open .open-close-toggle:focus-visible+.expand-icon .line:last-of-type{transform:rotate3d(0, 0, 1, -45deg)}section.open .open-close-toggle:hover+.expand-icon .line:nth-of-type(2),section.open .open-close-toggle:focus-visible+.expand-icon .line:nth-of-type(2){transform:translate3d(0, 1rem, 0) rotate(90deg);opacity:0}section.open .open-close-toggle:hover+.expand-icon .line:nth-of-type(3),section.open .open-close-toggle:focus-visible+.expand-icon .line:nth-of-type(3){transform:translate3d(0, -1rem, 0) rotate(-90deg);opacity:0}:host(limel-collapsible-section){--border-radius-of-header:0.75rem;display:block}:host([hidden]){display:none}button.open-close-toggle{appearance:none;background:none;border:none;padding:0;margin:0;font:inherit;color:inherit;text-align:inherit;position:absolute;inset:0;width:100%}button.open-close-toggle:focus{outline:none}button.open-close-toggle:focus-visible{outline:none;box-shadow:var(--shadow-depth-8-focused)}button.open-close-toggle{transition:background-color 0.4s ease, border-radius 0.1s ease;cursor:pointer;z-index:-1;background-color:var(--closed-header-background-color, rgb(var(--contrast-200)));border-radius:var(--border-radius-of-header)}button.open-close-toggle:hover,button.open-close-toggle:focus-visible{background-color:var(--open-header-background-color, rgb(var(--contrast-300)))}section.open button.open-close-toggle{background-color:var(--open-header-background-color, rgb(var(--contrast-100)));border-radius:var(--border-radius-of-header) var(--border-radius-of-header) var(--limel-cs-open-header-bottom-border-radius, 0) var(--limel-cs-open-header-bottom-border-radius, 0)}section.open button.open-close-toggle:hover,section.open button.open-close-toggle:focus-visible{background-color:var(--open-header-background-color, rgb(var(--contrast-300)))}.title,.divider-line,.expand-icon{pointer-events:none}section{transition:box-shadow 0.4s ease;border-radius:var(--border-radius-of-header)}section[aria-invalid]:not([aria-invalid=false]){--header-stroke-color:rgb(var(--color-red-default)) !important}section[aria-invalid]:not([aria-invalid=false]):not(.open){box-shadow:0 0 0 1px rgb(var(--color-red-default))}header{isolation:isolate;position:relative;align-items:center;display:flex;justify-content:space-between;gap:0.5rem;padding-left:0.5rem;height:2.5rem}limel-icon{width:1.5rem;flex-shrink:0}.title{font-size:1rem;font-weight:300;color:var(--limel-theme-on-surface-color);justify-self:flex-start;user-select:none;height:auto;max-height:3rem;line-height:1.2rem;display:-webkit-box;overflow:hidden;white-space:normal;-webkit-box-orient:vertical;-webkit-line-clamp:2}.divider-line{transition:opacity 0.3s ease 0.3s;flex-grow:1;height:0.125rem;border-radius:1rem;background-color:var(--header-stroke-color, rgb(var(--contrast-900)));opacity:0;margin-right:0.5rem}section.open .divider-line{opacity:0.16}.actions{justify-self:flex-end;flex-shrink:0}::slotted([slot=header]){margin-right:0.5rem}.body{background-color:var(--body-background-color, var(--contrast-100));padding-left:var(--body-padding, 1.25rem);padding-right:var(--body-padding, 1.25rem);border-radius:0 0 var(--border-radius-of-header) var(--border-radius-of-header)}.body{transition:grid-template-rows var(--limel-cs-grid-template-rows-transition-speed) cubic-bezier(1, 0.09, 0, 0.89);display:grid;grid-template-rows:var(--limel-cs-grid-template-rows)}.body slot{transition:opacity var(--limel-cs-opacity-transition-speed) ease var(--limel-cs-opacity-transition-delay);display:block;overflow:hidden}:host(limel-collapsible-section:not([is-open])){--limel-cs-opacity-transition-speed:0.1s;--limel-cs-opacity-transition-delay:0s;--limel-cs-grid-template-rows-transition-speed:0.3s;--limel-cs-grid-template-rows:0fr}:host(limel-collapsible-section:not([is-open])) slot{opacity:0}:host(limel-collapsible-section[is-open]){--limel-cs-opacity-transition-speed:0.4s;--limel-cs-opacity-transition-delay:0.3s;--limel-cs-grid-template-rows-transition-speed:0.46s;--limel-cs-grid-template-rows:1fr}:host(limel-collapsible-section[is-open]) slot{opacity:1}header:hover+.body,header:has(.open-close-toggle:hover)+.body,header:has(.open-close-toggle:focus-visible)+.body{will-change:grid-template-rows}header:hover+.body slot,header:has(.open-close-toggle:hover)+.body slot,header:has(.open-close-toggle:focus-visible)+.body slot{will-change:opacity}`;
|
|
10
11
|
|
|
11
12
|
const DEFAULT_HEADING_LEVEL = 2;
|
|
12
|
-
function isHeadingLevel(level) {
|
|
13
|
-
return (typeof level === 'number' &&
|
|
14
|
-
Number.isSafeInteger(level) &&
|
|
15
|
-
level >= 1 &&
|
|
16
|
-
level <= 6);
|
|
17
|
-
}
|
|
18
13
|
const CollapsibleSection = class {
|
|
19
14
|
constructor(hostRef) {
|
|
20
15
|
registerInstance(this, hostRef);
|
|
@@ -121,7 +116,7 @@ const CollapsibleSection = class {
|
|
|
121
116
|
removeEnterClickable(button);
|
|
122
117
|
}
|
|
123
118
|
render() {
|
|
124
|
-
return (h("section", { key: '
|
|
119
|
+
return (h("section", { key: 'ff18dacc5e74d3bd8d16da55be3e5340922acf86', class: `${this.isOpen ? 'open' : ''}`, "aria-invalid": this.invalid, "aria-labelledby": this.header ? this.headingId : null }, h("header", { key: 'f4dba35493c7ce7344ff34d2fbaeeb769f8c87eb' }, h("button", { key: 'd3a632b4002d01774c9bb88f250be4e196340ef3', class: "open-close-toggle", onClick: this.onClick, "aria-controls": this.bodyId, "aria-expanded": this.isOpen ? 'true' : 'false', "aria-label": this.getCollapsibleSectionAriaLabel(), type: "button" }), this.renderExpandCollapseSign(), this.renderIcon(), this.renderHeading(), h("div", { key: '8d8489917d5e1bfa8de3cca8294651f448c8129c', class: "divider-line", role: "presentation" }), this.renderHeaderSlot(), this.renderActions()), h("div", { key: 'fd7e13cf3bd26815d62c3fbac0ef04ed4db364b5', class: "body", inert: !this.isOpen, "aria-hidden": String(!this.isOpen), id: this.bodyId, role: "region" }, h("slot", { key: '90ed08286c1091f5c5c5feec827729cfa65588fc' }))));
|
|
125
120
|
}
|
|
126
121
|
getHeadingLevel() {
|
|
127
122
|
return isHeadingLevel(this.headingLevel)
|