@limetech/lime-elements 38.32.0 → 38.33.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.
@@ -88,7 +88,7 @@ export class CodeEditor {
88
88
  // the space count
89
89
  editor.setOption('extraKeys', {
90
90
  Tab: (codeMirror) => {
91
- const spaces = [codeMirror.getOption('indentUnit') + 1].join(' ');
91
+ const spaces = ' '.repeat(codeMirror.getOption('indentUnit'));
92
92
  codeMirror.replaceSelection(spaces);
93
93
  },
94
94
  });
@@ -1 +1 @@
1
- {"version":3,"file":"code-editor.js","sourceRoot":"","sources":["../../../src/components/code-editor/code-editor.tsx"],"names":[],"mappings":"AAAA,OAAO,EACH,SAAS,EACT,CAAC,EACD,IAAI,EACJ,OAAO,EACP,KAAK,EAEL,KAAK,EACL,KAAK,GACR,MAAM,eAAe,CAAC;AAEvB,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,yBAAyB,CAAC;AACjC,OAAO,qCAAqC,CAAC;AAC7C,OAAO,uCAAuC,CAAC;AAC/C,OAAO,+BAA+B,CAAC;AACvC,OAAO,wCAAwC,CAAC;AAChD,OAAO,qCAAqC,CAAC;AAC7C,OAAO,iCAAiC,CAAC;AACzC,OAAO,4BAA4B,CAAC;AACpC,OAAO,iCAAiC,CAAC;AACzC,OAAO,kCAAkC,CAAC;AAC1C,OAAO,kCAAkC,CAAC;AAC1C,OAAO,gCAAgC,CAAC;AACxC,OAAO,MAAM,MAAM,cAAc,CAAC;AAElC;;;;GAIG;AAMH,MAAM,OAAO,UAAU;;IAkHX,yBAAoB,GAAG,GAAG,EAAE;MAChC,IAAI,IAAI,CAAC,WAAW,KAAK,MAAM,EAAE;QAC7B,OAAO;OACV;MAED,IAAI,CAAC,WAAW,EAAE,CAAC;IACvB,CAAC,CAAC;IAEM,iBAAY,GAAG,GAAG,EAAE;MACxB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ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CAAC;KACtC;IAED,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;EACjC,CAAC;EAEM,MAAM;IACT,MAAM,SAAS,GAAG;MACd,MAAM,EAAE,IAAI;MACZ,QAAQ,EAAE,IAAI,CAAC,QAAQ;MACvB,cAAc,EAAE,IAAI,CAAC,UAAU,EAAE;MACjC,eAAe,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE;KACtC,CAAC;IAEF,OAAO,WAAK,KAAK,EAAE,SAAS,GAAI,CAAC;EACrC,CAAC;EAEO,WAAW;IACf,iDAAiD;IACjD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;EAChC,CAAC;EAED,IAAY,QAAQ;IAChB,OAAO,UAAU,CAAC,8BAA8B,CAAC,CAAC;EACtD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACJ","sourcesContent":["import {\n Component,\n h,\n Prop,\n Element,\n Event,\n EventEmitter,\n State,\n Watch,\n} from '@stencil/core';\nimport { ColorScheme, Language } from './code-editor.types';\nimport CodeMirror from 'codemirror';\nimport 'codemirror/mode/css/css';\nimport 'codemirror/mode/htmlmixed/htmlmixed';\nimport 'codemirror/mode/javascript/javascript';\nimport 'codemirror/mode/jinja2/jinja2';\nimport 'codemirror/addon/selection/active-line';\nimport 'codemirror/addon/edit/matchbrackets';\nimport 'codemirror/addon/edit/matchtags';\nimport 'codemirror/addon/lint/lint';\nimport 'codemirror/addon/lint/json-lint';\nimport 'codemirror/addon/fold/foldgutter';\nimport 'codemirror/addon/fold/brace-fold';\nimport 'codemirror/addon/fold/xml-fold';\nimport jslint from 'jsonlint-mod';\n\n/**\n * @exampleComponent limel-example-code-editor\n * @exampleComponent limel-example-code-editor-readonly-with-line-numbers\n * @exampleComponent limel-example-code-editor-fold-lint-wrap\n */\n@Component({\n tag: 'limel-code-editor',\n shadow: true,\n styleUrl: 'code-editor.scss',\n})\nexport class CodeEditor {\n /**\n * The code to be rendered\n */\n @Prop()\n public value: string = '';\n\n /**\n * The language of the code\n */\n @Prop()\n public language: Language;\n\n /**\n * Disables editing of the editor content\n */\n @Prop()\n public readonly: boolean = false;\n\n /**\n * Displays line numbers in the editor\n */\n @Prop()\n public lineNumbers: boolean = false;\n\n /**\n * Wraps long lines instead of showing horizontal scrollbar\n */\n @Prop()\n public lineWrapping: boolean = false;\n\n /**\n * Allows the user to fold code\n */\n @Prop()\n public fold: boolean = false;\n\n /**\n * Enables linting of JSON content\n */\n @Prop()\n public lint: boolean = false;\n\n /**\n * Select color scheme for the editor\n */\n @Prop()\n public colorScheme: ColorScheme = 'auto';\n\n /**\n * Emitted when the code has changed. Will only be emitted when the code\n * area has lost focus\n */\n @Event()\n public change: EventEmitter<string>;\n\n @Element()\n private host: HTMLLimelCodeEditorElement;\n\n /**\n * This is only used to trigger a redraw if the\n * `(prefers-color-scheme: dark)` media query is changed\n */\n @State()\n protected random: number;\n\n private editor: CodeMirror.Editor;\n private observer: ResizeObserver;\n\n public connectedCallback() {\n this.observer = new ResizeObserver(this.handleResize) as any;\n this.observer.observe(this.host);\n\n this.darkMode.addEventListener('change', this.handleChangeDarkMode);\n }\n\n public disconnectedCallback() {\n this.observer.unobserve(this.host);\n this.editor?.off('change', this.handleChange);\n this.editor = null;\n\n this.darkMode.removeEventListener('change', this.handleChangeDarkMode);\n\n const editorElement = this.host.shadowRoot.querySelector('.editor');\n // eslint-disable-next-line no-unsafe-optional-chaining\n for (const child of editorElement?.childNodes) {\n child.remove();\n }\n }\n\n public componentDidRender() {\n if (this.editor) {\n return;\n }\n\n this.editor = this.createEditor();\n }\n\n @Watch('value')\n protected watchValue(newValue: string) {\n if (!this.editor) {\n return;\n }\n\n const currentValue = this.editor.getValue();\n if (newValue === currentValue) {\n // Circuit breaker for when the change comes from the editor itself\n // The caret position will be reset without this\n return;\n }\n\n this.editor.getDoc().setValue(newValue || '');\n }\n\n private handleChangeDarkMode = () => {\n if (this.colorScheme !== 'auto') {\n return;\n }\n\n this.forceRedraw();\n };\n\n private handleChange = () => {\n this.change.emit(this.editor.getValue());\n };\n\n private handleResize = () => {\n if (!this.editor) {\n return;\n }\n\n this.editor.refresh();\n };\n\n private createEditor() {\n const options = this.getOptions();\n\n const editor = CodeMirror(\n this.host.shadowRoot.querySelector('.editor'),\n options\n );\n\n editor.on('change', this.handleChange);\n\n // Replace tab with spaces and use the actual indent setting for\n // the space count\n editor.setOption('extraKeys', {\n Tab: (codeMirror) => {\n const spaces = [codeMirror.getOption('indentUnit') + 1].join(\n ' '\n );\n codeMirror.replaceSelection(spaces);\n },\n });\n\n return editor;\n }\n\n private getOptions(): CodeMirror.EditorConfiguration {\n let mode: string | CodeMirror.ModeSpec<any> = this.language;\n const TAB_SIZE = 4;\n let theme = 'lime light';\n const gutters = [];\n\n if (this.isDarkMode()) {\n theme = 'lime dark';\n }\n\n if (this.language === 'json') {\n mode = {\n name: 'application/json',\n json: true,\n };\n if (this.lint) {\n gutters.push('CodeMirror-lint-markers');\n if (!('jsonlint' in window)) {\n window['jsonlint'] = jslint;\n }\n }\n } else if (this.language === 'typescript') {\n mode = {\n name: 'application/typescript',\n typescript: true,\n };\n } else if (this.language === 'html') {\n mode = 'htmlmixed';\n }\n\n if (this.fold) {\n gutters.push('CodeMirror-foldgutter');\n }\n\n return {\n mode: mode,\n value: this.value || '',\n theme: theme,\n readOnly: this.readonly,\n tabSize: TAB_SIZE,\n indentUnit: TAB_SIZE,\n lineNumbers: this.lineNumbers,\n lineWrapping: this.lineWrapping,\n styleActiveLine: true,\n matchBrackets: true,\n matchTags: { bothTags: true },\n lint: this.lint,\n foldGutter: this.fold,\n gutters: gutters,\n };\n }\n\n private isDarkMode(): boolean {\n if (this.colorScheme !== 'auto') {\n return this.colorScheme === 'dark';\n }\n\n return this.darkMode.matches;\n }\n\n public render() {\n const classList = {\n editor: true,\n readonly: this.readonly,\n 'is-dark-mode': this.isDarkMode(),\n 'is-light-mode': !this.isDarkMode(),\n };\n\n return <div class={classList} />;\n }\n\n private forceRedraw() {\n // eslint-disable-next-line sonarjs/pseudo-random\n this.random = Math.random();\n }\n\n private get darkMode(): MediaQueryList {\n return matchMedia('(prefers-color-scheme: dark)');\n }\n}\n"]}
1
+ {"version":3,"file":"code-editor.js","sourceRoot":"","sources":["../../../src/components/code-editor/code-editor.tsx"],"names":[],"mappings":"AAAA,OAAO,EACH,SAAS,EACT,CAAC,EACD,IAAI,EACJ,OAAO,EACP,KAAK,EAEL,KAAK,EACL,KAAK,GACR,MAAM,eAAe,CAAC;AAEvB,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,yBAAyB,CAAC;AACjC,OAAO,qCAAqC,CAAC;AAC7C,OAAO,uCAAuC,CAAC;AAC/C,OAAO,+BAA+B,CAAC;AACvC,OAAO,wCAAwC,CAAC;AAChD,OAAO,qCAAqC,CAAC;AAC7C,OAAO,iCAAiC,CAAC;AACzC,OAAO,4BAA4B,CAAC;AACpC,OAAO,iCAAiC,CAAC;AACzC,OAAO,kCAAkC,CAAC;AAC1C,OAAO,kCAAkC,CAAC;AAC1C,OAAO,gCAAgC,CAAC;AACxC,OAAO,MAAM,MAAM,cAAc,CAAC;AAElC;;;;GAIG;AAMH,MAAM,OAAO,UAAU;;IAkHX,yBAAoB,GAAG,GAAG,EAAE;MAChC,IAAI,IAAI,CAAC,WAAW,KAAK,MAAM,EAAE;QAC7B,OAAO;OACV;MAED,IAAI,CAAC,WAAW,EAAE,CAAC;IACvB,CAAC,CAAC;IAEM,iBAAY,GAAG,GAAG,EAAE;MACxB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC7C,CAAC,CA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AC;EACjC,CAAC;EAEM,MAAM;IACT,MAAM,SAAS,GAAG;MACd,MAAM,EAAE,IAAI;MACZ,QAAQ,EAAE,IAAI,CAAC,QAAQ;MACvB,cAAc,EAAE,IAAI,CAAC,UAAU,EAAE;MACjC,eAAe,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE;KACtC,CAAC;IAEF,OAAO,WAAK,KAAK,EAAE,SAAS,GAAI,CAAC;EACrC,CAAC;EAEO,WAAW;IACf,iDAAiD;IACjD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;EAChC,CAAC;EAED,IAAY,QAAQ;IAChB,OAAO,UAAU,CAAC,8BAA8B,CAAC,CAAC;EACtD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACJ","sourcesContent":["import {\n Component,\n h,\n Prop,\n Element,\n Event,\n EventEmitter,\n State,\n Watch,\n} from '@stencil/core';\nimport { ColorScheme, Language } from './code-editor.types';\nimport CodeMirror from 'codemirror';\nimport 'codemirror/mode/css/css';\nimport 'codemirror/mode/htmlmixed/htmlmixed';\nimport 'codemirror/mode/javascript/javascript';\nimport 'codemirror/mode/jinja2/jinja2';\nimport 'codemirror/addon/selection/active-line';\nimport 'codemirror/addon/edit/matchbrackets';\nimport 'codemirror/addon/edit/matchtags';\nimport 'codemirror/addon/lint/lint';\nimport 'codemirror/addon/lint/json-lint';\nimport 'codemirror/addon/fold/foldgutter';\nimport 'codemirror/addon/fold/brace-fold';\nimport 'codemirror/addon/fold/xml-fold';\nimport jslint from 'jsonlint-mod';\n\n/**\n * @exampleComponent limel-example-code-editor\n * @exampleComponent limel-example-code-editor-readonly-with-line-numbers\n * @exampleComponent limel-example-code-editor-fold-lint-wrap\n */\n@Component({\n tag: 'limel-code-editor',\n shadow: true,\n styleUrl: 'code-editor.scss',\n})\nexport class CodeEditor {\n /**\n * The code to be rendered\n */\n @Prop()\n public value: string = '';\n\n /**\n * The language of the code\n */\n @Prop()\n public language: Language;\n\n /**\n * Disables editing of the editor content\n */\n @Prop()\n public readonly: boolean = false;\n\n /**\n * Displays line numbers in the editor\n */\n @Prop()\n public lineNumbers: boolean = false;\n\n /**\n * Wraps long lines instead of showing horizontal scrollbar\n */\n @Prop()\n public lineWrapping: boolean = false;\n\n /**\n * Allows the user to fold code\n */\n @Prop()\n public fold: boolean = false;\n\n /**\n * Enables linting of JSON content\n */\n @Prop()\n public lint: boolean = false;\n\n /**\n * Select color scheme for the editor\n */\n @Prop()\n public colorScheme: ColorScheme = 'auto';\n\n /**\n * Emitted when the code has changed. Will only be emitted when the code\n * area has lost focus\n */\n @Event()\n public change: EventEmitter<string>;\n\n @Element()\n private host: HTMLLimelCodeEditorElement;\n\n /**\n * This is only used to trigger a redraw if the\n * `(prefers-color-scheme: dark)` media query is changed\n */\n @State()\n protected random: number;\n\n private editor: CodeMirror.Editor;\n private observer: ResizeObserver;\n\n public connectedCallback() {\n this.observer = new ResizeObserver(this.handleResize) as any;\n this.observer.observe(this.host);\n\n this.darkMode.addEventListener('change', this.handleChangeDarkMode);\n }\n\n public disconnectedCallback() {\n this.observer.unobserve(this.host);\n this.editor?.off('change', this.handleChange);\n this.editor = null;\n\n this.darkMode.removeEventListener('change', this.handleChangeDarkMode);\n\n const editorElement = this.host.shadowRoot.querySelector('.editor');\n // eslint-disable-next-line no-unsafe-optional-chaining\n for (const child of editorElement?.childNodes) {\n child.remove();\n }\n }\n\n public componentDidRender() {\n if (this.editor) {\n return;\n }\n\n this.editor = this.createEditor();\n }\n\n @Watch('value')\n protected watchValue(newValue: string) {\n if (!this.editor) {\n return;\n }\n\n const currentValue = this.editor.getValue();\n if (newValue === currentValue) {\n // Circuit breaker for when the change comes from the editor itself\n // The caret position will be reset without this\n return;\n }\n\n this.editor.getDoc().setValue(newValue || '');\n }\n\n private handleChangeDarkMode = () => {\n if (this.colorScheme !== 'auto') {\n return;\n }\n\n this.forceRedraw();\n };\n\n private handleChange = () => {\n this.change.emit(this.editor.getValue());\n };\n\n private handleResize = () => {\n if (!this.editor) {\n return;\n }\n\n this.editor.refresh();\n };\n\n private createEditor() {\n const options = this.getOptions();\n\n const editor = CodeMirror(\n this.host.shadowRoot.querySelector('.editor'),\n options\n );\n\n editor.on('change', this.handleChange);\n\n // Replace tab with spaces and use the actual indent setting for\n // the space count\n editor.setOption('extraKeys', {\n Tab: (codeMirror) => {\n const spaces = ' '.repeat(codeMirror.getOption('indentUnit'));\n codeMirror.replaceSelection(spaces);\n },\n });\n\n return editor;\n }\n\n private getOptions(): CodeMirror.EditorConfiguration {\n let mode: string | CodeMirror.ModeSpec<any> = this.language;\n const TAB_SIZE = 4;\n let theme = 'lime light';\n const gutters = [];\n\n if (this.isDarkMode()) {\n theme = 'lime dark';\n }\n\n if (this.language === 'json') {\n mode = {\n name: 'application/json',\n json: true,\n };\n if (this.lint) {\n gutters.push('CodeMirror-lint-markers');\n if (!('jsonlint' in window)) {\n window['jsonlint'] = jslint;\n }\n }\n } else if (this.language === 'typescript') {\n mode = {\n name: 'application/typescript',\n typescript: true,\n };\n } else if (this.language === 'html') {\n mode = 'htmlmixed';\n }\n\n if (this.fold) {\n gutters.push('CodeMirror-foldgutter');\n }\n\n return {\n mode: mode,\n value: this.value || '',\n theme: theme,\n readOnly: this.readonly,\n tabSize: TAB_SIZE,\n indentUnit: TAB_SIZE,\n lineNumbers: this.lineNumbers,\n lineWrapping: this.lineWrapping,\n styleActiveLine: true,\n matchBrackets: true,\n matchTags: { bothTags: true },\n lint: this.lint,\n foldGutter: this.fold,\n gutters: gutters,\n };\n }\n\n private isDarkMode(): boolean {\n if (this.colorScheme !== 'auto') {\n return this.colorScheme === 'dark';\n }\n\n return this.darkMode.matches;\n }\n\n public render() {\n const classList = {\n editor: true,\n readonly: this.readonly,\n 'is-dark-mode': this.isDarkMode(),\n 'is-light-mode': !this.isDarkMode(),\n };\n\n return <div class={classList} />;\n }\n\n private forceRedraw() {\n // eslint-disable-next-line sonarjs/pseudo-random\n this.random = Math.random();\n }\n\n private get darkMode(): MediaQueryList {\n return matchMedia('(prefers-color-scheme: dark)');\n }\n}\n"]}
@@ -2,17 +2,18 @@ import React from 'react';
2
2
  /**
3
3
  *
4
4
  * @param schema
5
+ * @param extraProps - additional props to pass to the limel-help element
5
6
  */
6
- export function getHelpComponent(schema) {
7
+ export function getHelpComponent(schema, extraProps) {
7
8
  var _a;
8
9
  const help = (_a = schema.lime) === null || _a === void 0 ? void 0 : _a.help;
9
10
  if (!help) {
10
11
  return;
11
12
  }
12
13
  if (typeof help === 'string') {
13
- return React.createElement('limel-help', { value: help });
14
+ return React.createElement('limel-help', Object.assign({ value: help }, extraProps));
14
15
  }
15
16
  const helpProps = help;
16
- return React.createElement('limel-help', helpProps);
17
+ return React.createElement('limel-help', Object.assign(Object.assign({}, helpProps), extraProps));
17
18
  }
18
19
  //# sourceMappingURL=help.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"help.js","sourceRoot":"","sources":["../../../../src/components/form/help/help.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAkB;;EAC/C,MAAM,IAAI,GAAG,MAAA,MAAM,CAAC,IAAI,0CAAE,IAAI,CAAC;EAE/B,IAAI,CAAC,IAAI,EAAE;IACP,OAAO;GACV;EAED,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;IAC1B,OAAO,KAAK,CAAC,aAAa,CAAC,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;GAC7D;EAED,MAAM,SAAS,GAAG,IAAI,CAAC;EAEvB,OAAO,KAAK,CAAC,aAAa,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;AACxD,CAAC","sourcesContent":["import React from 'react';\nimport { FormSchema } from '../form.types';\n\n/**\n *\n * @param schema\n */\nexport function getHelpComponent(schema: FormSchema) {\n const help = schema.lime?.help;\n\n if (!help) {\n return;\n }\n\n if (typeof help === 'string') {\n return React.createElement('limel-help', { value: help });\n }\n\n const helpProps = help;\n\n return React.createElement('limel-help', helpProps);\n}\n"]}
1
+ {"version":3,"file":"help.js","sourceRoot":"","sources":["../../../../src/components/form/help/help.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAC5B,MAAkB,EAClB,UAAoC;;EAEpC,MAAM,IAAI,GAAG,MAAA,MAAM,CAAC,IAAI,0CAAE,IAAI,CAAC;EAE/B,IAAI,CAAC,IAAI,EAAE;IACP,OAAO;GACV;EAED,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;IAC1B,OAAO,KAAK,CAAC,aAAa,CAAC,YAAY,kBACnC,KAAK,EAAE,IAAI,IACR,UAAU,EACf,CAAC;GACN;EAED,MAAM,SAAS,GAAG,IAAI,CAAC;EAEvB,OAAO,KAAK,CAAC,aAAa,CAAC,YAAY,kCAAO,SAAS,GAAK,UAAU,EAAG,CAAC;AAC9E,CAAC","sourcesContent":["import React from 'react';\nimport { FormSchema } from '../form.types';\n\n/**\n *\n * @param schema\n * @param extraProps - additional props to pass to the limel-help element\n */\nexport function getHelpComponent(\n schema: FormSchema,\n extraProps?: Record<string, unknown>\n) {\n const help = schema.lime?.help;\n\n if (!help) {\n return;\n }\n\n if (typeof help === 'string') {\n return React.createElement('limel-help', {\n value: help,\n ...extraProps,\n });\n }\n\n const helpProps = help;\n\n return React.createElement('limel-help', { ...helpProps, ...extraProps });\n}\n"]}
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import { renderDescription, renderTitle } from './common';
3
3
  import { GridLayout } from './grid-layout';
4
4
  import { RowLayout } from './row-layout';
5
+ import { getHelpComponent } from '../help';
5
6
  export const ObjectFieldTemplate = (props) => {
6
7
  const id = props.idSchema.$id;
7
8
  if (id === 'root' || !isCollapsible(props.schema)) {
@@ -13,15 +14,25 @@ export const ObjectFieldTemplate = (props) => {
13
14
  return renderProperties(props.properties, props.schema);
14
15
  };
15
16
  function renderFieldWithTitle(props) {
16
- return React.createElement(React.Fragment, {}, renderTitle(props.title), renderDescription(props.description), renderProperties(props.properties, props.schema));
17
+ return React.createElement(React.Fragment, {}, renderSectionHeader(props), renderDescription(props.description), renderProperties(props.properties, props.schema));
18
+ }
19
+ function renderSectionHeader(props) {
20
+ const help = getHelpComponent(props.schema);
21
+ if (!help) {
22
+ return renderTitle(props.title);
23
+ }
24
+ return React.createElement(React.Fragment, {}, renderTitle(props.title), help);
17
25
  }
18
26
  function renderCollapsibleField(props) {
19
27
  const defaultOpen = !isCollapsed(props.schema);
28
+ const helpElement = getHelpComponent(props.schema, {
29
+ slot: 'header',
30
+ });
20
31
  return React.createElement('limel-collapsible-section', {
21
32
  header: props.title,
22
33
  id: getSchemaObjectPropertyPath(props.formContext.schema, props.idSchema),
23
34
  'is-open': defaultOpen,
24
- }, renderDescription(props.description), renderProperties(props.properties, props.schema));
35
+ }, helpElement, renderDescription(props.description), renderProperties(props.properties, props.schema));
25
36
  }
26
37
  function getSchemaObjectPropertyPath(schema, subSchema) {
27
38
  var _a, _b;
@@ -1 +1 @@
1
- {"version":3,"file":"object-field.js","sourceRoot":"","sources":["../../../../src/components/form/templates/object-field.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAIzC,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAAmC,EAAE,EAAE;EACvE,MAAM,EA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AC,OAAO,CAAC,OAAO,CAAC,CAC/C,CAAC;AACN,CAAC;AAED,SAAS,eAAe,CAAC,UAAiC;EACtD,OAAO,KAAK,CAAC,aAAa,CACtB,SAAS,EACT,EAAE,EACF,UAAU,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAC/C,CAAC;AACN,CAAC;AAED,SAAS,aAAa,CAAC,MAAmB;;EACtC,OAAO,CAAC,CAAC,CAAA,MAAA,MAAM,CAAC,IAAI,0CAAE,WAAW,CAAA,CAAC;AACtC,CAAC;AAED,SAAS,WAAW,CAAC,MAAmB;EACpC,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,KAAK,KAAK,CAAC;AAC3C,CAAC","sourcesContent":["import React from 'react';\nimport {\n FormLayoutType,\n LimeLayoutOptions,\n FormLayoutOptions,\n} from '../form.types';\nimport { renderDescription, renderTitle } from './common';\nimport { GridLayout } from './grid-layout';\nimport { RowLayout } from './row-layout';\nimport { LimeObjectFieldTemplateProps, ObjectFieldProperty } from './types';\nimport { JSONSchema7 } from 'json-schema';\n\nexport const ObjectFieldTemplate = (props: LimeObjectFieldTemplateProps) => {\n const id = props.idSchema.$id;\n if (id === 'root' || !isCollapsible(props.schema)) {\n return renderFieldWithTitle(props);\n }\n\n if (isCollapsible(props.schema)) {\n return renderCollapsibleField(props);\n }\n\n return renderProperties(props.properties, props.schema);\n};\n\nfunction renderFieldWithTitle(props: LimeObjectFieldTemplateProps) {\n return React.createElement(\n React.Fragment,\n {},\n renderTitle(props.title),\n renderDescription(props.description),\n renderProperties(props.properties, props.schema)\n );\n}\n\nfunction renderCollapsibleField(props: LimeObjectFieldTemplateProps) {\n const defaultOpen = !isCollapsed(props.schema);\n\n return React.createElement(\n 'limel-collapsible-section',\n {\n header: props.title,\n id: getSchemaObjectPropertyPath(\n props.formContext.schema,\n props.idSchema\n ),\n 'is-open': defaultOpen,\n },\n renderDescription(props.description),\n renderProperties(props.properties, props.schema)\n );\n}\n\nfunction getSchemaObjectPropertyPath(\n schema: JSONSchema7,\n subSchema: JSONSchema7\n) {\n const refPrefixLength = 2;\n const matchAllForwardSlashes = /\\//g;\n const rootPath = (schema.$ref as string)\n ?.replace(matchAllForwardSlashes, '.')\n .slice(refPrefixLength);\n const subSchemaPath = subSchema.$id?.replace('_', '.properties.');\n\n return subSchemaPath.replace('root', rootPath);\n}\n\nfunction renderProperties(\n properties: ObjectFieldProperty[],\n schema: JSONSchema7\n) {\n const layout = schema.lime?.layout;\n\n return renderLayout(properties, layout);\n}\n\nfunction renderLayout(\n properties: ObjectFieldProperty[],\n layout: Partial<LimeLayoutOptions>\n) {\n const type = layout?.type || 'default';\n const layouts: Record<FormLayoutType, Function> = {\n default: renderDefaultLayout,\n grid: renderGridLayout,\n row: renderRowLayout,\n };\n\n return layouts[type](properties, layout);\n}\n\nfunction renderDefaultLayout(properties: ObjectFieldProperty[]) {\n return React.createElement(\n 'div',\n {\n className: 'limel-form-layout--default',\n },\n properties.map((element) => element.content)\n );\n}\n\nfunction renderGridLayout(\n properties: ObjectFieldProperty[],\n layout: FormLayoutOptions\n) {\n return React.createElement(\n GridLayout,\n {\n options: layout,\n },\n properties.map((element) => element.content)\n );\n}\n\nfunction renderRowLayout(properties: ObjectFieldProperty[]) {\n return React.createElement(\n RowLayout,\n {},\n properties.map((element) => element.content)\n );\n}\n\nfunction isCollapsible(schema: JSONSchema7) {\n return !!schema.lime?.collapsible;\n}\n\nfunction isCollapsed(schema: JSONSchema7) {\n return schema.lime.collapsed !== false;\n}\n"]}
1
+ {"version":3,"file":"object-field.js","sourceRoot":"","sources":["../../../../src/components/form/templates/object-field.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,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AAO,GAAqC;IAC9C,OAAO,EAAE,mBAAmB;IAC5B,IAAI,EAAE,gBAAgB;IACtB,GAAG,EAAE,eAAe;GACvB,CAAC;EAEF,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;AAC7C,CAAC;AAED,SAAS,mBAAmB,CAAC,UAAiC;EAC1D,OAAO,KAAK,CAAC,aAAa,CACtB,KAAK,EACL;IACI,SAAS,EAAE,4BAA4B;GAC1C,EACD,UAAU,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAC/C,CAAC;AACN,CAAC;AAED,SAAS,gBAAgB,CACrB,UAAiC,EACjC,MAAyB;EAEzB,OAAO,KAAK,CAAC,aAAa,CACtB,UAAU,EACV;IACI,OAAO,EAAE,MAAM;GAClB,EACD,UAAU,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAC/C,CAAC;AACN,CAAC;AAED,SAAS,eAAe,CAAC,UAAiC;EACtD,OAAO,KAAK,CAAC,aAAa,CACtB,SAAS,EACT,EAAE,EACF,UAAU,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAC/C,CAAC;AACN,CAAC;AAED,SAAS,aAAa,CAAC,MAAmB;;EACtC,OAAO,CAAC,CAAC,CAAA,MAAA,MAAM,CAAC,IAAI,0CAAE,WAAW,CAAA,CAAC;AACtC,CAAC;AAED,SAAS,WAAW,CAAC,MAAmB;EACpC,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,KAAK,KAAK,CAAC;AAC3C,CAAC","sourcesContent":["import React from 'react';\nimport {\n FormLayoutType,\n LimeLayoutOptions,\n FormLayoutOptions,\n FormSchema,\n} from '../form.types';\nimport { renderDescription, renderTitle } from './common';\nimport { GridLayout } from './grid-layout';\nimport { RowLayout } from './row-layout';\nimport { LimeObjectFieldTemplateProps, ObjectFieldProperty } from './types';\nimport { JSONSchema7 } from 'json-schema';\nimport { getHelpComponent } from '../help';\n\nexport const ObjectFieldTemplate = (props: LimeObjectFieldTemplateProps) => {\n const id = props.idSchema.$id;\n if (id === 'root' || !isCollapsible(props.schema)) {\n return renderFieldWithTitle(props);\n }\n\n if (isCollapsible(props.schema)) {\n return renderCollapsibleField(props);\n }\n\n return renderProperties(props.properties, props.schema);\n};\n\nfunction renderFieldWithTitle(props: LimeObjectFieldTemplateProps) {\n return React.createElement(\n React.Fragment,\n {},\n renderSectionHeader(props),\n renderDescription(props.description),\n renderProperties(props.properties, props.schema)\n );\n}\n\nfunction renderSectionHeader(props: LimeObjectFieldTemplateProps) {\n const help = getHelpComponent(props.schema as FormSchema);\n if (!help) {\n return renderTitle(props.title);\n }\n\n return React.createElement(\n React.Fragment,\n {},\n renderTitle(props.title),\n help\n );\n}\n\nfunction renderCollapsibleField(props: LimeObjectFieldTemplateProps) {\n const defaultOpen = !isCollapsed(props.schema);\n const helpElement = getHelpComponent(props.schema as FormSchema, {\n slot: 'header',\n });\n\n return React.createElement(\n 'limel-collapsible-section',\n {\n header: props.title,\n id: getSchemaObjectPropertyPath(\n props.formContext.schema,\n props.idSchema\n ),\n 'is-open': defaultOpen,\n },\n helpElement,\n renderDescription(props.description),\n renderProperties(props.properties, props.schema)\n );\n}\n\nfunction getSchemaObjectPropertyPath(\n schema: JSONSchema7,\n subSchema: JSONSchema7\n) {\n const refPrefixLength = 2;\n const matchAllForwardSlashes = /\\//g;\n const rootPath = (schema.$ref as string)\n ?.replace(matchAllForwardSlashes, '.')\n .slice(refPrefixLength);\n const subSchemaPath = subSchema.$id?.replace('_', '.properties.');\n\n return subSchemaPath.replace('root', rootPath);\n}\n\nfunction renderProperties(\n properties: ObjectFieldProperty[],\n schema: JSONSchema7\n) {\n const layout = schema.lime?.layout;\n\n return renderLayout(properties, layout);\n}\n\nfunction renderLayout(\n properties: ObjectFieldProperty[],\n layout: Partial<LimeLayoutOptions>\n) {\n const type = layout?.type || 'default';\n const layouts: Record<FormLayoutType, Function> = {\n default: renderDefaultLayout,\n grid: renderGridLayout,\n row: renderRowLayout,\n };\n\n return layouts[type](properties, layout);\n}\n\nfunction renderDefaultLayout(properties: ObjectFieldProperty[]) {\n return React.createElement(\n 'div',\n {\n className: 'limel-form-layout--default',\n },\n properties.map((element) => element.content)\n );\n}\n\nfunction renderGridLayout(\n properties: ObjectFieldProperty[],\n layout: FormLayoutOptions\n) {\n return React.createElement(\n GridLayout,\n {\n options: layout,\n },\n properties.map((element) => element.content)\n );\n}\n\nfunction renderRowLayout(properties: ObjectFieldProperty[]) {\n return React.createElement(\n RowLayout,\n {},\n properties.map((element) => element.content)\n );\n}\n\nfunction isCollapsible(schema: JSONSchema7) {\n return !!schema.lime?.collapsible;\n}\n\nfunction isCollapsed(schema: JSONSchema7) {\n return schema.lime.collapsed !== false;\n}\n"]}
@@ -14540,7 +14540,7 @@ const CodeEditor = class {
14540
14540
  // the space count
14541
14541
  editor.setOption('extraKeys', {
14542
14542
  Tab: (codeMirror) => {
14543
- const spaces = [codeMirror.getOption('indentUnit') + 1].join(' ');
14543
+ const spaces = ' '.repeat(codeMirror.getOption('indentUnit'));
14544
14544
  codeMirror.replaceSelection(spaces);
14545
14545
  },
14546
14546
  });