@limetech/lime-elements 37.5.0 → 37.7.0
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 +16 -0
- package/dist/cjs/index.cjs.js +23 -8
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/lime-elements.cjs.js +1 -1
- package/dist/cjs/limel-chip_2.cjs.entry.js +2 -1
- package/dist/cjs/limel-chip_2.cjs.entry.js.map +1 -1
- package/dist/cjs/limel-form.cjs.entry.js +1 -2
- package/dist/cjs/limel-form.cjs.entry.js.map +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/chip/chip.css +9 -0
- package/dist/collection/components/chip/chip.js +19 -0
- package/dist/collection/components/chip/chip.js.map +1 -1
- package/dist/collection/components/form/adapters/widget-adapter.js.map +1 -1
- package/dist/collection/components/form/form.js +14 -5
- package/dist/collection/components/form/form.js.map +1 -1
- package/dist/collection/components/form/form.types.js +1 -0
- package/dist/collection/components/form/form.types.js.map +1 -1
- package/dist/collection/components/form/help/help.js.map +1 -1
- package/dist/collection/components/form/templates/object-field.js +1 -2
- package/dist/collection/components/form/templates/object-field.js.map +1 -1
- package/dist/collection/components/form/templates/types.js.map +1 -1
- package/dist/collection/components/form/widgets/types.js.map +1 -1
- package/dist/esm/index.js +24 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lime-elements.js +1 -1
- package/dist/esm/limel-chip_2.entry.js +2 -1
- package/dist/esm/limel-chip_2.entry.js.map +1 -1
- package/dist/esm/limel-form.entry.js +1 -2
- package/dist/esm/limel-form.entry.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/lime-elements/index.esm.js +1 -1
- package/dist/lime-elements/index.esm.js.map +1 -1
- package/dist/lime-elements/lime-elements.esm.js +1 -1
- package/dist/lime-elements/lime-elements.esm.js.map +1 -1
- package/dist/lime-elements/{p-870d72f1.entry.js → p-64e352ec.entry.js} +5 -5
- package/dist/lime-elements/p-64e352ec.entry.js.map +1 -0
- package/dist/lime-elements/p-953ce801.entry.js +2 -0
- package/dist/lime-elements/p-953ce801.entry.js.map +1 -0
- package/dist/types/components/chip/chip.d.ts +4 -0
- package/dist/types/components/form/form.d.ts +3 -6
- package/dist/types/components/form/form.types.d.ts +37 -7
- package/dist/types/components/form/help/help.d.ts +2 -2
- package/dist/types/components/form/templates/types.d.ts +2 -2
- package/dist/types/components/form/widgets/types.d.ts +2 -2
- package/dist/types/components.d.ts +14 -12
- package/package.json +8 -8
- package/dist/cjs/form.types-e76a78e1.js +0 -26
- package/dist/cjs/form.types-e76a78e1.js.map +0 -1
- package/dist/collection/components/form/internal.types.js +0 -2
- package/dist/collection/components/form/internal.types.js.map +0 -1
- package/dist/esm/form.types-e39f98a4.js +0 -26
- package/dist/esm/form.types-e39f98a4.js.map +0 -1
- package/dist/lime-elements/p-067efbaf.js +0 -2
- package/dist/lime-elements/p-067efbaf.js.map +0 -1
- package/dist/lime-elements/p-870d72f1.entry.js.map +0 -1
- package/dist/lime-elements/p-d5557031.entry.js +0 -2
- package/dist/lime-elements/p-d5557031.entry.js.map +0 -1
- package/dist/types/components/form/internal.types.d.ts +0 -6
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -14,7 +14,7 @@ const patchEsm = () => {
|
|
|
14
14
|
const defineCustomElements = (win, options) => {
|
|
15
15
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
16
16
|
return patchEsm().then(() => {
|
|
17
|
-
return index.bootstrapLazy(JSON.parse("[[\"limel-action-bar.cjs\",[[1,\"limel-action-bar\",{\"actions\":[16],\"accessibleLabel\":[513,\"accessible-label\"],\"layout\":[513],\"openDirection\":[513,\"open-direction\"],\"overflowCutoff\":[32]}]]],[\"limel-split-button.cjs\",[[1,\"limel-split-button\",{\"label\":[513],\"primary\":[516],\"icon\":[513],\"disabled\":[516],\"items\":[16]}]]],[\"limel-file-viewer.cjs\",[[1,\"limel-file-viewer\",{\"url\":[513],\"filename\":[513],\"alt\":[513],\"allowFullscreen\":[516,\"allow-fullscreen\"],\"allowOpenInNewTab\":[516,\"allow-open-in-new-tab\"],\"allowDownload\":[516,\"allow-download\"],\"language\":[1],\"officeViewer\":[513,\"office-viewer\"],\"actions\":[16],\"isFullscreen\":[32],\"fileType\":[32],\"loading\":[32],\"fileUrl\":[32]}]]],[\"limel-color-picker.cjs\",[[1,\"limel-color-picker\",{\"value\":[513],\"label\":[513],\"helperText\":[513,\"helper-text\"],\"tooltipLabel\":[513,\"tooltip-label\"],\"required\":[516],\"readonly\":[516],\"isOpen\":[32]}]]],[\"limel-picker.cjs\",[[1,\"limel-picker\",{\"disabled\":[4],\"readonly\":[516],\"label\":[1],\"searchLabel\":[1,\"search-label\"],\"helperText\":[513,\"helper-text\"],\"leadingIcon\":[1,\"leading-icon\"],\"emptyResultMessage\":[1,\"empty-result-message\"],\"required\":[4],\"invalid\":[516],\"value\":[16],\"searcher\":[16],\"multiple\":[4],\"delimiter\":[513],\"actions\":[16],\"actionPosition\":[1,\"action-position\"],\"actionScrollBehavior\":[1,\"action-scroll-behavior\"],\"badgeIcons\":[516,\"badge-icons\"],\"items\":[32],\"textValue\":[32],\"loading\":[32],\"chips\":[32]}]]],[\"limel-dock.cjs\",[[1,\"limel-dock\",{\"dockItems\":[16],\"dockFooterItems\":[16],\"accessibleLabel\":[513,\"accessible-label\"],\"expanded\":[516],\"allowResize\":[516,\"allow-resize\"],\"mobileBreakPoint\":[514,\"mobile-break-point\"],\"useMobileLayout\":[32]}]]],[\"limel-date-picker.cjs\",[[1,\"limel-date-picker\",{\"disabled\":[516],\"readonly\":[516],\"invalid\":[516],\"label\":[513],\"placeholder\":[513],\"helperText\":[513,\"helper-text\"],\"required\":[516],\"value\":[16],\"type\":[513],\"format\":[513],\"language\":[513],\"formatter\":[16],\"formattedValue\":[32],\"internalFormat\":[32],\"showPortal\":[32]}]]],[\"limel-snackbar.cjs\",[[1,\"limel-snackbar\",{\"message\":[1],\"timeout\":[2],\"actionText\":[1,\"action-text\"],\"dismissible\":[4],\"multiline\":[4],\"language\":[1],\"show\":[64]}]]],[\"limel-tab-panel.cjs\",[[1,\"limel-tab-panel\",{\"tabs\":[1040]}]]],[\"limel-file.cjs\",[[1,\"limel-file\",{\"value\":[16],\"label\":[513],\"required\":[516],\"disabled\":[516],\"readonly\":[516],\"invalid\":[516],\"accept\":[513],\"language\":[1],\"isDraggingOverDropZone\":[32]}]]],[\"limel-button-group.cjs\",[[1,\"limel-button-group\",{\"value\":[16],\"disabled\":[516],\"selectedButtonId\":[32]}]]],[\"limel-collapsible-section.cjs\",[[1,\"limel-collapsible-section\",{\"isOpen\":[1540,\"is-open\"],\"header\":[513],\"actions\":[16]}]]],[\"limel-help.cjs\",[[1,\"limel-help\",{\"value\":[1],\"trigger\":[1],\"readMoreLink\":[16],\"openDirection\":[513,\"open-direction\"],\"isOpen\":[32]}]]],[\"limel-select.cjs\",[[1,\"limel-select\",{\"disabled\":[516],\"readonly\":[516],\"invalid\":[516],\"required\":[516],\"label\":[513],\"helperText\":[513,\"helper-text\"],\"value\":[16],\"options\":[16],\"multiple\":[4],\"menuOpen\":[32]}]]],[\"limel-info-tile.cjs\",[[1,\"limel-info-tile\",{\"value\":[520],\"icon\":[1],\"label\":[513],\"prefix\":[513],\"suffix\":[513],\"disabled\":[516],\"badge\":[520],\"loading\":[516],\"link\":[16],\"progress\":[16]}]]],[\"limel-table.cjs\",[[1,\"limel-table\",{\"data\":[16],\"columns\":[16],\"mode\":[1],\"layout\":[1],\"pageSize\":[2,\"page-size\"],\"totalRows\":[2,\"total-rows\"],\"sorting\":[16],\"activeRow\":[1040],\"movableColumns\":[4,\"movable-columns\"],\"loading\":[4],\"page\":[2],\"emptyMessage\":[1,\"empty-message\"],\"aggregates\":[16],\"selectable\":[4],\"selection\":[16]}]]],[\"limel-dialog.cjs\",[[1,\"limel-dialog\",{\"heading\":[1],\"fullscreen\":[516],\"open\":[1540],\"closingActions\":[16]}]]],[\"limel-progress-flow.cjs\",[[1,\"limel-progress-flow\",{\"flowItems\":[16],\"disabled\":[4],\"readonly\":[4]}]]],[\"limel-shortcut.cjs\",[[1,\"limel-shortcut\",{\"icon\":[513],\"label\":[513],\"disabled\":[516],\"badge\":[520],\"link\":[16]}]]],[\"limel-banner.cjs\",[[1,\"limel-banner\",{\"message\":[513],\"icon\":[513],\"isOpen\":[32],\"open\":[64],\"close\":[64]}]]],[\"limel-callout.cjs\",[[1,\"limel-callout\",{\"heading\":[513],\"icon\":[513],\"type\":[513],\"language\":[1]}]]],[\"limel-slider.cjs\",[[1,\"limel-slider\",{\"disabled\":[516],\"readonly\":[516],\"factor\":[514],\"label\":[513],\"helperText\":[513,\"helper-text\"],\"unit\":[513],\"value\":[514],\"valuemax\":[514],\"valuemin\":[514],\"step\":[514],\"percentageClass\":[32]}]]],[\"limel-switch.cjs\",[[1,\"limel-switch\",{\"label\":[513],\"disabled\":[516],\"readonly\":[516],\"invalid\":[516],\"value\":[516],\"helperText\":[513,\"helper-text\"],\"fieldId\":[32]}]]],[\"limel-code-editor.cjs\",[[1,\"limel-code-editor\",{\"value\":[1],\"language\":[1],\"readonly\":[4],\"lineNumbers\":[4,\"line-numbers\"],\"fold\":[4],\"lint\":[4],\"colorScheme\":[1,\"color-scheme\"],\"random\":[32]}]]],[\"limel-config.cjs\",[[1,\"limel-config\",{\"config\":[16]}]]],[\"limel-flex-container.cjs\",[[1,\"limel-flex-container\",{\"direction\":[513],\"justify\":[513],\"align\":[513],\"reverse\":[516]}]]],[\"limel-form.cjs\",[[1,\"limel-form\",{\"schema\":[16],\"value\":[16],\"disabled\":[4],\"propsFactory\":[16],\"transformErrors\":[16],\"errors\":[16]}]]],[\"limel-grid.cjs\",[[1,\"limel-grid\"]]],[\"limel-dock-button.cjs\",[[0,\"limel-dock-button\",{\"item\":[16],\"expanded\":[516],\"useMobileLayout\":[516,\"use-mobile-layout\"],\"isOpen\":[32]}]]],[\"limel-color-picker-palette.cjs\",[[1,\"limel-color-picker-palette\",{\"value\":[513],\"label\":[513],\"helperText\":[513,\"helper-text\"],\"required\":[516]}]]],[\"limel-tab-bar.cjs\",[[1,\"limel-tab-bar\",{\"tabs\":[1040],\"canScrollLeft\":[32],\"canScrollRight\":[32]},[[9,\"resize\",\"handleWindowResize\"]]]]],[\"limel-helper-line.cjs\",[[1,\"limel-helper-line\",{\"helperText\":[513,\"helper-text\"],\"length\":[514],\"maxLength\":[514,\"max-length\"],\"invalid\":[516],\"helperTextId\":[513,\"helper-text-id\"]}]]],[\"limel-checkbox.cjs\",[[1,\"limel-checkbox\",{\"disabled\":[516],\"readonly\":[516],\"invalid\":[516],\"label\":[513],\"helperText\":[513,\"helper-text\"],\"checked\":[516],\"indeterminate\":[516],\"required\":[516],\"modified\":[32]}]]],[\"limel-header.cjs\",[[1,\"limel-header\",{\"icon\":[1],\"heading\":[1],\"subheading\":[1],\"supportingText\":[1,\"supporting-text\"],\"subheadingDivider\":[1,\"subheading-divider\"]}]]],[\"limel-help-content.cjs\",[[1,\"limel-help-content\",{\"value\":[1],\"readMoreLink\":[16]}]]],[\"limel-icon.cjs\",[[1,\"limel-icon\",{\"size\":[513],\"name\":[513],\"badge\":[516]}]]],[\"limel-progress-flow-item.cjs\",[[0,\"limel-progress-flow-item\",{\"item\":[16],\"disabled\":[4],\"readonly\":[4],\"currentStep\":[4,\"current-step\"]}]]],[\"limel-circular-progress.cjs\",[[1,\"limel-circular-progress\",{\"value\":[2],\"maxValue\":[2,\"max-value\"],\"prefix\":[513],\"suffix\":[1],\"displayPercentageColors\":[4,\"display-percentage-colors\"],\"size\":[513]}]]],[\"limel-flatpickr-adapter.cjs\",[[1,\"limel-flatpickr-adapter\",{\"value\":[16],\"type\":[1],\"format\":[1],\"isOpen\":[4,\"is-open\"],\"inputElement\":[16],\"language\":[1],\"formatter\":[16]}]]],[\"limel-breadcrumbs_3.cjs\",[[1,\"limel-menu\",{\"items\":[16],\"disabled\":[516],\"openDirection\":[513,\"open-direction\"],\"surfaceWidth\":[513,\"surface-width\"],\"open\":[1540],\"badgeIcons\":[516,\"badge-icons\"],\"gridLayout\":[516,\"grid-layout\"],\"loading\":[516],\"currentSubMenu\":[1040],\"searcher\":[16],\"emptyResultMessage\":[1,\"empty-result-message\"],\"loadingSubItems\":[32],\"menuBreadCrumb\":[32],\"searchValue\":[32],\"searchResults\":[32]}],[1,\"limel-breadcrumbs\",{\"items\":[16],\"divider\":[1]}],[1,\"limel-menu-list\",{\"items\":[16],\"badgeIcons\":[4,\"badge-icons\"],\"iconSize\":[1,\"icon-size\"],\"type\":[1],\"maxLinesSecondaryText\":[2,\"max-lines-secondary-text\"]}]]],[\"limel-action-bar-item_2.cjs\",[[0,\"limel-action-bar-overflow-menu\",{\"items\":[16],\"openDirection\":[513,\"open-direction\"]}],[0,\"limel-action-bar-item\",{\"item\":[16],\"isVisible\":[516,\"is-visible\"]}]]],[\"limel-button.cjs\",[[1,\"limel-button\",{\"label\":[513],\"primary\":[516],\"outlined\":[516],\"icon\":[513],\"disabled\":[516],\"loading\":[516],\"loadingFailed\":[516,\"loading-failed\"],\"justLoaded\":[32]}]]],[\"limel-markdown.cjs\",[[1,\"limel-markdown\",{\"value\":[1]}]]],[\"limel-icon-button.cjs\",[[1,\"limel-icon-button\",{\"icon\":[513],\"elevated\":[516],\"label\":[513],\"disabled\":[516]}]]],[\"limel-linear-progress.cjs\",[[1,\"limel-linear-progress\",{\"value\":[514],\"indeterminate\":[516]}]]],[\"limel-chip_2.cjs\",[[1,\"limel-chip-set\",{\"value\":[16],\"type\":[513],\"label\":[513],\"helperText\":[513,\"helper-text\"],\"disabled\":[516],\"readonly\":[516],\"invalid\":[516],\"inputType\":[513,\"input-type\"],\"maxItems\":[514,\"max-items\"],\"required\":[516],\"searchLabel\":[513,\"search-label\"],\"emptyInputOnBlur\":[516,\"empty-input-on-blur\"],\"clearAllButton\":[4,\"clear-all-button\"],\"leadingIcon\":[513,\"leading-icon\"],\"delimiter\":[513],\"language\":[1],\"editMode\":[32],\"textValue\":[32],\"blurred\":[32],\"inputChipIndexSelected\":[32],\"selectedChipIds\":[32],\"getEditMode\":[64],\"setFocus\":[64],\"emptyInput\":[64]}],[1,\"limel-chip\",{\"language\":[513],\"text\":[513],\"icon\":[1],\"link\":[16],\"badge\":[520],\"disabled\":[516],\"readonly\":[516],\"selected\":[516],\"removable\":[516],\"type\":[513],\"loading\":[516],\"progress\":[514],\"identifier\":[520]}]]],[\"limel-popover_2.cjs\",[[1,\"limel-popover\",{\"open\":[4],\"openDirection\":[513,\"open-direction\"]}],[1,\"limel-popover-surface\",{\"contentCollection\":[16]}]]],[\"limel-spinner.cjs\",[[1,\"limel-spinner\",{\"size\":[513],\"limeBranded\":[4,\"lime-branded\"]}]]],[\"limel-badge.cjs\",[[1,\"limel-badge\",{\"label\":[520]}]]],[\"limel-portal_3.cjs\",[[1,\"limel-tooltip\",{\"elementId\":[513,\"element-id\"],\"label\":[513],\"helperLabel\":[513,\"helper-label\"],\"maxlength\":[514],\"openDirection\":[513,\"open-direction\"],\"open\":[32]}],[1,\"limel-tooltip-content\",{\"label\":[513],\"helperLabel\":[513,\"helper-label\"],\"maxlength\":[514]}],[1,\"limel-portal\",{\"openDirection\":[513,\"open-direction\"],\"position\":[513],\"containerId\":[513,\"container-id\"],\"containerStyle\":[16],\"parent\":[16],\"inheritParentWidth\":[516,\"inherit-parent-width\"],\"visible\":[516],\"anchor\":[16]}]]],[\"limel-input-field_3.cjs\",[[1,\"limel-input-field\",{\"disabled\":[516],\"readonly\":[516],\"invalid\":[516],\"label\":[513],\"placeholder\":[513],\"helperText\":[513,\"helper-text\"],\"prefix\":[513],\"suffix\":[513],\"required\":[516],\"value\":[513],\"trailingIcon\":[513,\"trailing-icon\"],\"leadingIcon\":[513,\"leading-icon\"],\"pattern\":[513],\"type\":[513],\"formatNumber\":[516,\"format-number\"],\"step\":[520],\"max\":[514],\"min\":[514],\"maxlength\":[514],\"minlength\":[514],\"completions\":[16],\"showLink\":[516,\"show-link\"],\"locale\":[513],\"isFocused\":[32],\"isModified\":[32],\"showCompletions\":[32]}],[1,\"limel-list\",{\"items\":[16],\"badgeIcons\":[4,\"badge-icons\"],\"iconSize\":[1,\"icon-size\"],\"type\":[1],\"maxLinesSecondaryText\":[2,\"max-lines-secondary-text\"]}],[1,\"limel-menu-surface\",{\"open\":[4],\"allowClicksElement\":[16]}]]]]"), options);
|
|
17
|
+
return index.bootstrapLazy(JSON.parse("[[\"limel-action-bar.cjs\",[[1,\"limel-action-bar\",{\"actions\":[16],\"accessibleLabel\":[513,\"accessible-label\"],\"layout\":[513],\"openDirection\":[513,\"open-direction\"],\"overflowCutoff\":[32]}]]],[\"limel-split-button.cjs\",[[1,\"limel-split-button\",{\"label\":[513],\"primary\":[516],\"icon\":[513],\"disabled\":[516],\"items\":[16]}]]],[\"limel-file-viewer.cjs\",[[1,\"limel-file-viewer\",{\"url\":[513],\"filename\":[513],\"alt\":[513],\"allowFullscreen\":[516,\"allow-fullscreen\"],\"allowOpenInNewTab\":[516,\"allow-open-in-new-tab\"],\"allowDownload\":[516,\"allow-download\"],\"language\":[1],\"officeViewer\":[513,\"office-viewer\"],\"actions\":[16],\"isFullscreen\":[32],\"fileType\":[32],\"loading\":[32],\"fileUrl\":[32]}]]],[\"limel-color-picker.cjs\",[[1,\"limel-color-picker\",{\"value\":[513],\"label\":[513],\"helperText\":[513,\"helper-text\"],\"tooltipLabel\":[513,\"tooltip-label\"],\"required\":[516],\"readonly\":[516],\"isOpen\":[32]}]]],[\"limel-picker.cjs\",[[1,\"limel-picker\",{\"disabled\":[4],\"readonly\":[516],\"label\":[1],\"searchLabel\":[1,\"search-label\"],\"helperText\":[513,\"helper-text\"],\"leadingIcon\":[1,\"leading-icon\"],\"emptyResultMessage\":[1,\"empty-result-message\"],\"required\":[4],\"invalid\":[516],\"value\":[16],\"searcher\":[16],\"multiple\":[4],\"delimiter\":[513],\"actions\":[16],\"actionPosition\":[1,\"action-position\"],\"actionScrollBehavior\":[1,\"action-scroll-behavior\"],\"badgeIcons\":[516,\"badge-icons\"],\"items\":[32],\"textValue\":[32],\"loading\":[32],\"chips\":[32]}]]],[\"limel-dock.cjs\",[[1,\"limel-dock\",{\"dockItems\":[16],\"dockFooterItems\":[16],\"accessibleLabel\":[513,\"accessible-label\"],\"expanded\":[516],\"allowResize\":[516,\"allow-resize\"],\"mobileBreakPoint\":[514,\"mobile-break-point\"],\"useMobileLayout\":[32]}]]],[\"limel-date-picker.cjs\",[[1,\"limel-date-picker\",{\"disabled\":[516],\"readonly\":[516],\"invalid\":[516],\"label\":[513],\"placeholder\":[513],\"helperText\":[513,\"helper-text\"],\"required\":[516],\"value\":[16],\"type\":[513],\"format\":[513],\"language\":[513],\"formatter\":[16],\"formattedValue\":[32],\"internalFormat\":[32],\"showPortal\":[32]}]]],[\"limel-snackbar.cjs\",[[1,\"limel-snackbar\",{\"message\":[1],\"timeout\":[2],\"actionText\":[1,\"action-text\"],\"dismissible\":[4],\"multiline\":[4],\"language\":[1],\"show\":[64]}]]],[\"limel-tab-panel.cjs\",[[1,\"limel-tab-panel\",{\"tabs\":[1040]}]]],[\"limel-file.cjs\",[[1,\"limel-file\",{\"value\":[16],\"label\":[513],\"required\":[516],\"disabled\":[516],\"readonly\":[516],\"invalid\":[516],\"accept\":[513],\"language\":[1],\"isDraggingOverDropZone\":[32]}]]],[\"limel-button-group.cjs\",[[1,\"limel-button-group\",{\"value\":[16],\"disabled\":[516],\"selectedButtonId\":[32]}]]],[\"limel-collapsible-section.cjs\",[[1,\"limel-collapsible-section\",{\"isOpen\":[1540,\"is-open\"],\"header\":[513],\"actions\":[16]}]]],[\"limel-help.cjs\",[[1,\"limel-help\",{\"value\":[1],\"trigger\":[1],\"readMoreLink\":[16],\"openDirection\":[513,\"open-direction\"],\"isOpen\":[32]}]]],[\"limel-select.cjs\",[[1,\"limel-select\",{\"disabled\":[516],\"readonly\":[516],\"invalid\":[516],\"required\":[516],\"label\":[513],\"helperText\":[513,\"helper-text\"],\"value\":[16],\"options\":[16],\"multiple\":[4],\"menuOpen\":[32]}]]],[\"limel-info-tile.cjs\",[[1,\"limel-info-tile\",{\"value\":[520],\"icon\":[1],\"label\":[513],\"prefix\":[513],\"suffix\":[513],\"disabled\":[516],\"badge\":[520],\"loading\":[516],\"link\":[16],\"progress\":[16]}]]],[\"limel-table.cjs\",[[1,\"limel-table\",{\"data\":[16],\"columns\":[16],\"mode\":[1],\"layout\":[1],\"pageSize\":[2,\"page-size\"],\"totalRows\":[2,\"total-rows\"],\"sorting\":[16],\"activeRow\":[1040],\"movableColumns\":[4,\"movable-columns\"],\"loading\":[4],\"page\":[2],\"emptyMessage\":[1,\"empty-message\"],\"aggregates\":[16],\"selectable\":[4],\"selection\":[16]}]]],[\"limel-dialog.cjs\",[[1,\"limel-dialog\",{\"heading\":[1],\"fullscreen\":[516],\"open\":[1540],\"closingActions\":[16]}]]],[\"limel-progress-flow.cjs\",[[1,\"limel-progress-flow\",{\"flowItems\":[16],\"disabled\":[4],\"readonly\":[4]}]]],[\"limel-shortcut.cjs\",[[1,\"limel-shortcut\",{\"icon\":[513],\"label\":[513],\"disabled\":[516],\"badge\":[520],\"link\":[16]}]]],[\"limel-banner.cjs\",[[1,\"limel-banner\",{\"message\":[513],\"icon\":[513],\"isOpen\":[32],\"open\":[64],\"close\":[64]}]]],[\"limel-callout.cjs\",[[1,\"limel-callout\",{\"heading\":[513],\"icon\":[513],\"type\":[513],\"language\":[1]}]]],[\"limel-slider.cjs\",[[1,\"limel-slider\",{\"disabled\":[516],\"readonly\":[516],\"factor\":[514],\"label\":[513],\"helperText\":[513,\"helper-text\"],\"unit\":[513],\"value\":[514],\"valuemax\":[514],\"valuemin\":[514],\"step\":[514],\"percentageClass\":[32]}]]],[\"limel-switch.cjs\",[[1,\"limel-switch\",{\"label\":[513],\"disabled\":[516],\"readonly\":[516],\"invalid\":[516],\"value\":[516],\"helperText\":[513,\"helper-text\"],\"fieldId\":[32]}]]],[\"limel-code-editor.cjs\",[[1,\"limel-code-editor\",{\"value\":[1],\"language\":[1],\"readonly\":[4],\"lineNumbers\":[4,\"line-numbers\"],\"fold\":[4],\"lint\":[4],\"colorScheme\":[1,\"color-scheme\"],\"random\":[32]}]]],[\"limel-config.cjs\",[[1,\"limel-config\",{\"config\":[16]}]]],[\"limel-flex-container.cjs\",[[1,\"limel-flex-container\",{\"direction\":[513],\"justify\":[513],\"align\":[513],\"reverse\":[516]}]]],[\"limel-form.cjs\",[[1,\"limel-form\",{\"schema\":[16],\"value\":[16],\"disabled\":[4],\"propsFactory\":[16],\"transformErrors\":[16],\"errors\":[16]}]]],[\"limel-grid.cjs\",[[1,\"limel-grid\"]]],[\"limel-dock-button.cjs\",[[0,\"limel-dock-button\",{\"item\":[16],\"expanded\":[516],\"useMobileLayout\":[516,\"use-mobile-layout\"],\"isOpen\":[32]}]]],[\"limel-color-picker-palette.cjs\",[[1,\"limel-color-picker-palette\",{\"value\":[513],\"label\":[513],\"helperText\":[513,\"helper-text\"],\"required\":[516]}]]],[\"limel-tab-bar.cjs\",[[1,\"limel-tab-bar\",{\"tabs\":[1040],\"canScrollLeft\":[32],\"canScrollRight\":[32]},[[9,\"resize\",\"handleWindowResize\"]]]]],[\"limel-helper-line.cjs\",[[1,\"limel-helper-line\",{\"helperText\":[513,\"helper-text\"],\"length\":[514],\"maxLength\":[514,\"max-length\"],\"invalid\":[516],\"helperTextId\":[513,\"helper-text-id\"]}]]],[\"limel-checkbox.cjs\",[[1,\"limel-checkbox\",{\"disabled\":[516],\"readonly\":[516],\"invalid\":[516],\"label\":[513],\"helperText\":[513,\"helper-text\"],\"checked\":[516],\"indeterminate\":[516],\"required\":[516],\"modified\":[32]}]]],[\"limel-header.cjs\",[[1,\"limel-header\",{\"icon\":[1],\"heading\":[1],\"subheading\":[1],\"supportingText\":[1,\"supporting-text\"],\"subheadingDivider\":[1,\"subheading-divider\"]}]]],[\"limel-help-content.cjs\",[[1,\"limel-help-content\",{\"value\":[1],\"readMoreLink\":[16]}]]],[\"limel-icon.cjs\",[[1,\"limel-icon\",{\"size\":[513],\"name\":[513],\"badge\":[516]}]]],[\"limel-progress-flow-item.cjs\",[[0,\"limel-progress-flow-item\",{\"item\":[16],\"disabled\":[4],\"readonly\":[4],\"currentStep\":[4,\"current-step\"]}]]],[\"limel-circular-progress.cjs\",[[1,\"limel-circular-progress\",{\"value\":[2],\"maxValue\":[2,\"max-value\"],\"prefix\":[513],\"suffix\":[1],\"displayPercentageColors\":[4,\"display-percentage-colors\"],\"size\":[513]}]]],[\"limel-flatpickr-adapter.cjs\",[[1,\"limel-flatpickr-adapter\",{\"value\":[16],\"type\":[1],\"format\":[1],\"isOpen\":[4,\"is-open\"],\"inputElement\":[16],\"language\":[1],\"formatter\":[16]}]]],[\"limel-breadcrumbs_3.cjs\",[[1,\"limel-menu\",{\"items\":[16],\"disabled\":[516],\"openDirection\":[513,\"open-direction\"],\"surfaceWidth\":[513,\"surface-width\"],\"open\":[1540],\"badgeIcons\":[516,\"badge-icons\"],\"gridLayout\":[516,\"grid-layout\"],\"loading\":[516],\"currentSubMenu\":[1040],\"searcher\":[16],\"emptyResultMessage\":[1,\"empty-result-message\"],\"loadingSubItems\":[32],\"menuBreadCrumb\":[32],\"searchValue\":[32],\"searchResults\":[32]}],[1,\"limel-breadcrumbs\",{\"items\":[16],\"divider\":[1]}],[1,\"limel-menu-list\",{\"items\":[16],\"badgeIcons\":[4,\"badge-icons\"],\"iconSize\":[1,\"icon-size\"],\"type\":[1],\"maxLinesSecondaryText\":[2,\"max-lines-secondary-text\"]}]]],[\"limel-action-bar-item_2.cjs\",[[0,\"limel-action-bar-overflow-menu\",{\"items\":[16],\"openDirection\":[513,\"open-direction\"]}],[0,\"limel-action-bar-item\",{\"item\":[16],\"isVisible\":[516,\"is-visible\"]}]]],[\"limel-button.cjs\",[[1,\"limel-button\",{\"label\":[513],\"primary\":[516],\"outlined\":[516],\"icon\":[513],\"disabled\":[516],\"loading\":[516],\"loadingFailed\":[516,\"loading-failed\"],\"justLoaded\":[32]}]]],[\"limel-markdown.cjs\",[[1,\"limel-markdown\",{\"value\":[1]}]]],[\"limel-icon-button.cjs\",[[1,\"limel-icon-button\",{\"icon\":[513],\"elevated\":[516],\"label\":[513],\"disabled\":[516]}]]],[\"limel-linear-progress.cjs\",[[1,\"limel-linear-progress\",{\"value\":[514],\"indeterminate\":[516]}]]],[\"limel-chip_2.cjs\",[[1,\"limel-chip-set\",{\"value\":[16],\"type\":[513],\"label\":[513],\"helperText\":[513,\"helper-text\"],\"disabled\":[516],\"readonly\":[516],\"invalid\":[516],\"inputType\":[513,\"input-type\"],\"maxItems\":[514,\"max-items\"],\"required\":[516],\"searchLabel\":[513,\"search-label\"],\"emptyInputOnBlur\":[516,\"empty-input-on-blur\"],\"clearAllButton\":[4,\"clear-all-button\"],\"leadingIcon\":[513,\"leading-icon\"],\"delimiter\":[513],\"language\":[1],\"editMode\":[32],\"textValue\":[32],\"blurred\":[32],\"inputChipIndexSelected\":[32],\"selectedChipIds\":[32],\"getEditMode\":[64],\"setFocus\":[64],\"emptyInput\":[64]}],[1,\"limel-chip\",{\"language\":[513],\"text\":[513],\"icon\":[1],\"link\":[16],\"badge\":[520],\"disabled\":[516],\"readonly\":[516],\"selected\":[516],\"invalid\":[516],\"removable\":[516],\"type\":[513],\"loading\":[516],\"progress\":[514],\"identifier\":[520]}]]],[\"limel-popover_2.cjs\",[[1,\"limel-popover\",{\"open\":[4],\"openDirection\":[513,\"open-direction\"]}],[1,\"limel-popover-surface\",{\"contentCollection\":[16]}]]],[\"limel-spinner.cjs\",[[1,\"limel-spinner\",{\"size\":[513],\"limeBranded\":[4,\"lime-branded\"]}]]],[\"limel-badge.cjs\",[[1,\"limel-badge\",{\"label\":[520]}]]],[\"limel-portal_3.cjs\",[[1,\"limel-tooltip\",{\"elementId\":[513,\"element-id\"],\"label\":[513],\"helperLabel\":[513,\"helper-label\"],\"maxlength\":[514],\"openDirection\":[513,\"open-direction\"],\"open\":[32]}],[1,\"limel-tooltip-content\",{\"label\":[513],\"helperLabel\":[513,\"helper-label\"],\"maxlength\":[514]}],[1,\"limel-portal\",{\"openDirection\":[513,\"open-direction\"],\"position\":[513],\"containerId\":[513,\"container-id\"],\"containerStyle\":[16],\"parent\":[16],\"inheritParentWidth\":[516,\"inherit-parent-width\"],\"visible\":[516],\"anchor\":[16]}]]],[\"limel-input-field_3.cjs\",[[1,\"limel-input-field\",{\"disabled\":[516],\"readonly\":[516],\"invalid\":[516],\"label\":[513],\"placeholder\":[513],\"helperText\":[513,\"helper-text\"],\"prefix\":[513],\"suffix\":[513],\"required\":[516],\"value\":[513],\"trailingIcon\":[513,\"trailing-icon\"],\"leadingIcon\":[513,\"leading-icon\"],\"pattern\":[513],\"type\":[513],\"formatNumber\":[516,\"format-number\"],\"step\":[520],\"max\":[514],\"min\":[514],\"maxlength\":[514],\"minlength\":[514],\"completions\":[16],\"showLink\":[516,\"show-link\"],\"locale\":[513],\"isFocused\":[32],\"isModified\":[32],\"showCompletions\":[32]}],[1,\"limel-list\",{\"items\":[16],\"badgeIcons\":[4,\"badge-icons\"],\"iconSize\":[1,\"icon-size\"],\"type\":[1],\"maxLinesSecondaryText\":[2,\"max-lines-secondary-text\"]}],[1,\"limel-menu-surface\",{\"open\":[4],\"allowClicksElement\":[16]}]]]]"), options);
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -172,6 +172,15 @@
|
|
|
172
172
|
box-shadow: 0 0 0.375rem 0 rgb(var(--color-green-light)), 0 0 0 1px rgb(var(--color-white)) inset;
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
+
:host(limel-chip[invalid]) .chip {
|
|
176
|
+
background: url("data:image/svg+xml;charset=utf-8, <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8' style='fill-rule:evenodd;'><path fill='rgba(186,186,192,0.16)' d='M0 0h4v4H0zM4 4h4v4H4z'/></svg>");
|
|
177
|
+
background-size: 0.5rem;
|
|
178
|
+
background-color: rgb(var(--color-red-default));
|
|
179
|
+
}
|
|
180
|
+
:host(limel-chip[invalid]) .text {
|
|
181
|
+
color: rgb(var(--color-white));
|
|
182
|
+
}
|
|
183
|
+
|
|
175
184
|
limel-icon {
|
|
176
185
|
flex-shrink: 0;
|
|
177
186
|
width: calc(var(--limel-chip-height) - 0.25rem);
|
|
@@ -93,6 +93,7 @@ export class Chip {
|
|
|
93
93
|
this.disabled = false;
|
|
94
94
|
this.readonly = false;
|
|
95
95
|
this.selected = false;
|
|
96
|
+
this.invalid = false;
|
|
96
97
|
this.removable = false;
|
|
97
98
|
this.type = 'default';
|
|
98
99
|
this.loading = false;
|
|
@@ -318,6 +319,24 @@ export class Chip {
|
|
|
318
319
|
"reflect": true,
|
|
319
320
|
"defaultValue": "false"
|
|
320
321
|
},
|
|
322
|
+
"invalid": {
|
|
323
|
+
"type": "boolean",
|
|
324
|
+
"mutable": false,
|
|
325
|
+
"complexType": {
|
|
326
|
+
"original": "boolean",
|
|
327
|
+
"resolved": "boolean",
|
|
328
|
+
"references": {}
|
|
329
|
+
},
|
|
330
|
+
"required": false,
|
|
331
|
+
"optional": false,
|
|
332
|
+
"docs": {
|
|
333
|
+
"tags": [],
|
|
334
|
+
"text": "Set to `true` to visualize the chip in an \"invalid\" or \"error\" state."
|
|
335
|
+
},
|
|
336
|
+
"attribute": "invalid",
|
|
337
|
+
"reflect": true,
|
|
338
|
+
"defaultValue": "false"
|
|
339
|
+
},
|
|
321
340
|
"removable": {
|
|
322
341
|
"type": "boolean",
|
|
323
342
|
"mutable": false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chip.js","sourceRoot":"","sources":["../../../src/components/chip/chip.tsx"],"names":[],"mappings":"AAAA,OAAO,EACH,SAAS,EACT,OAAO,EACP,KAAK,EAEL,CAAC,EACD,IAAI,EACJ,IAAI,GACP,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EACH,kBAAkB,EAClB,oBAAoB,GACvB,MAAM,i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B,OAAO,GAAG,IAAI,CAAC,UAAU,EACxC,SAAS,EAAE,OAAO,EAClB,OAAO,EAAE,IAAI,CAAC,iBAAiB,GACjC,CACL,CAAC;EACN,CAAC;EA8BO,aAAa;IACjB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;MACf,OAAO;KACV;IAED,OAAO,6BAAuB,aAAa,EAAE,IAAI,GAAI,CAAC;EAC1D,CAAC;EAEO,iBAAiB;IACrB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;MAChB,OAAO;KACV;IAED,MAAM,iBAAiB,GAAG,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC;IAC9C,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAE3C,OAAO,CACH,WACI,IAAI,EAAC,aAAa,gBACP,GAAG,mBACA,GAAG,mBACH,KAAK,mBACJ,IAAI,CAAC,QAAQ,EAC5B,KAAK,EAAE;QACH,kCAAkC,EAAE,iBAAiB;OACxD;MAED;QAAO,QAAQ;YAAS,CACtB,CACT,CAAC;EACN,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACJ","sourcesContent":["import {\n Component,\n Element,\n Event,\n EventEmitter,\n h,\n Host,\n Prop,\n} from '@stencil/core';\nimport { Icon, Languages, Link } from '../../interface';\nimport { getIconName } from '../icon/get-icon-props';\nimport {\n makeEnterClickable,\n removeEnterClickable,\n} from '../../util/make-enter-clickable';\nimport translate from '../../global/translations';\nimport {\n BACKSPACE,\n BACKSPACE_KEY_CODE,\n DELETE,\n DELETE_KEY_CODE,\n} from '../../util/keycodes';\nimport { ChipType, Chip as OldChipInterface } from '../chip-set/chip.types';\n\ninterface ChipInterface extends Omit<OldChipInterface, 'id' | 'badge'> {\n /**\n * Identifier for the chip. Must be unique.\n */\n identifier?: number | string;\n\n /**\n * The value of the badge.\n */\n badge?: string | number;\n}\n\n/**\n * Chips and buttons are both interactive elements in UI design,\n * but they serve different purposes and are used in different contexts.\n *\n * :::warning\n * Do not use the chip component carelessly, as an alternative for\n * [`limel-button`](#/component/limel-button/) in the UI design!\n *\n * **Buttons:**\n * Buttons are used to trigger actions. They are typically used to\n * submit forms, open dialogs, initiate a process, or perform any action\n * that changes the state of the application.\n * Buttons' labels usually contain action words, in other words, the labels is\n * a _verb in imperative mood_ such as \"Submit\" or \"Delete\".\n * Buttons are placed in areas where it's clear they will initiate\n * an action when clicked.\n *\n * **Chips:**\n * Chips however are elements which may look like buttons, but they are\n * representing choices, filters, or tags, in a small block\n * or clearly bundled into a group. Chips are rarely used alone in the\n * user interface.\n * They are often used in a so called \"chip-set\", or placed together in\n * a section of the UI, where the user can expect more than one chip to be present.\n *\n * For example, a chip may represent a filter in a filter bar, or a tag in a tag list,\n * or an item in a shopping list.\n * Clicking a chip can also trigger an action, for example toggling a filter ON or OFF,\n * or opening a page with all posts tagged with the tag represented by the chip,\n * or navigating to a page with more information about the item in the shopping list.\n * :::\n *\n * @private\n * @exampleComponent limel-example-chip-button\n * @exampleComponent limel-example-chip-link\n * @exampleComponent limel-example-chip-icon-colors\n * @exampleComponent limel-example-chip-badge\n * @exampleComponent limel-example-chip-filter\n * @exampleComponent limel-example-chip-removable\n * @exampleComponent limel-example-chip-loading\n * @exampleComponent limel-example-chip-progress\n * @exampleComponent limel-example-chip-aria-role\n */\n@Component({\n tag: 'limel-chip',\n shadow: true,\n styleUrl: 'chip.scss',\n})\nexport class Chip implements ChipInterface {\n /**\n * Defines the language for translations.\n * Will translate the translatable strings on the components.\n */\n @Prop({ reflect: true })\n public language: Languages = 'en';\n\n /**\n * Label displayed on the chip\n */\n @Prop({ reflect: true })\n public text: string;\n\n /**\n * Icon of the chip.\n */\n @Prop()\n public icon?: string | Icon;\n\n /**\n * If supplied, the chip will become a clickable link.\n */\n @Prop()\n public link?: Omit<Link, 'text'>;\n\n /**\n * The value of the badge, displayed on the chip.\n */\n @Prop({ reflect: true })\n public badge?: string | number;\n\n /**\n * Set to `true` to disable the chip.\n */\n @Prop({ reflect: true })\n public disabled = false;\n\n /**\n * Set to `true` to render the chip as a static UI element.\n * Useful when the parent component has a `readonly` state.\n */\n @Prop({ reflect: true })\n public readonly = false;\n\n /**\n * Set to `true` to visualize the chip in a \"selected\" state.\n * This is typically used when the chip is used in a chip-set\n * along with other chips.\n */\n @Prop({ reflect: true })\n public selected = false;\n\n /**\n * Set to `true` to render a remove button on the chip.\n */\n @Prop({ reflect: true })\n public removable = false;\n\n /**\n * Set to `filter` to render the chip with a distinct style\n * suitable for visualizing filters.\n *\n * @beta\n */\n @Prop({ reflect: true })\n public type?: ChipType = 'default';\n\n /**\n * Set to `true` to put the component in the `loading` state,\n * and render an indeterminate progress indicator inside the chip.\n * This does _not_ disable the interactivity of the chip!\n */\n @Prop({ reflect: true })\n public loading? = false;\n\n /**\n * Reflects the current value of a progress bar on the chip,\n * visualizing the percentage of an ongoing process.\n * Must be a number between `0` and `100`.\n */\n @Prop({ reflect: true })\n public progress?: number;\n\n /**\n * Identifier for the chip. Must be unique.\n */\n @Prop({ reflect: true })\n public identifier?: number | string = crypto.randomUUID();\n\n /**\n * Fired when clicking on the remove button of a `removable` chip.\n * The value of `identifier` is emitted as the event detail.\n */\n @Event()\n public remove: EventEmitter<number | string>;\n\n @Element()\n private host: HTMLLimelChipElement;\n\n public componentWillLoad() {\n makeEnterClickable(this.host);\n }\n\n public disconnectedCallback() {\n removeEnterClickable(this.host);\n }\n\n public render() {\n return (\n <Host onClick={this.filterClickWhenDisabled}>\n {this.link ? this.renderAsLink() : this.renderAsButton()}\n </Host>\n );\n }\n\n private renderAsButton = () => {\n return [\n <button\n id={'chip-' + this.identifier}\n class=\"chip\"\n role=\"button\"\n disabled={this.disabled || this.readonly}\n onKeyDown={this.handleDeleteKeyDown}\n >\n {this.renderSpinner()}\n {this.renderIcon()}\n {this.renderLabel()}\n {this.renderBadge()}\n {this.renderProgressBar()}\n </button>,\n this.renderRemoveButton(),\n ];\n };\n\n private renderAsLink = () => {\n return [\n <a\n id={'chip-' + this.identifier}\n class=\"chip\"\n href={this.link.href}\n title={this.link.title}\n target={this.link.target}\n aria-disabled={this.disabled || this.readonly}\n tabindex={this.disabled || this.readonly ? -1 : 0}\n onKeyDown={this.handleDeleteKeyDown}\n >\n {this.renderSpinner()}\n {this.renderIcon()}\n {this.renderLabel()}\n {this.renderBadge()}\n {this.renderProgressBar()}\n </a>,\n this.renderRemoveButton(),\n ];\n };\n\n private renderLabel = () => {\n return <span class=\"text\">{this.text}</span>;\n };\n\n private renderIcon() {\n const icon = getIconName(this.icon);\n\n if (!icon) {\n return;\n }\n\n return (\n <limel-icon\n badge={true}\n name={icon}\n style={{\n color: `${(this.icon as Icon)?.color}`,\n 'background-color': `${\n (this.icon as Icon)?.backgroundColor\n }`,\n }}\n />\n );\n }\n\n private renderBadge() {\n if (!this.badge) {\n return;\n }\n\n return <limel-badge label={this.badge} />;\n }\n\n private renderRemoveButton() {\n if (!this.removable || this.readonly || this.disabled) {\n return;\n }\n\n const svgData =\n '<svg viewBox=\"0 0 32 32\" xmlns=\"http://www.w3.org/2000/svg\"><path fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" d=\"m8 8 16 16M24 8 8 24\"/></svg>';\n\n return (\n <button\n class=\"trailing-button remove-button\"\n tabIndex={-1}\n aria-label={this.removeChipLabel}\n aria-controls={'chip-' + this.identifier}\n innerHTML={svgData}\n onClick={this.handleRemoveClick}\n />\n );\n }\n\n private filterClickWhenDisabled = (e) => {\n if (this.disabled || this.readonly) {\n e.preventDefault();\n }\n };\n\n private handleRemoveClick = (event: MouseEvent | KeyboardEvent) => {\n event.stopPropagation();\n this.remove.emit(this.identifier);\n };\n\n private handleDeleteKeyDown = (event: KeyboardEvent) => {\n if (!this.removable) {\n return;\n }\n\n const keys = [DELETE, BACKSPACE];\n const keycodes = [DELETE_KEY_CODE, BACKSPACE_KEY_CODE];\n\n if (keys.includes(event.key) || keycodes.includes(event.keyCode)) {\n this.handleRemoveClick(event);\n }\n };\n\n private removeChipLabel = (): string => {\n return translate.get('chip-set.remove-chip', this.language);\n };\n\n private renderSpinner() {\n if (!this.loading) {\n return;\n }\n\n return <limel-linear-progress indeterminate={true} />;\n }\n\n private renderProgressBar() {\n if (!this.progress) {\n return;\n }\n\n const currentPercentage = this.progress + '%';\n const progress = Math.round(this.progress);\n\n return (\n <div\n role=\"progressbar\"\n aria-label=\"%\"\n aria-valuemin=\"0\"\n aria-valuemax=\"100\"\n aria-valuenow={this.progress}\n style={{\n '--limel-chip-progress-percentage': currentPercentage,\n }}\n >\n <span>{progress}%</span>\n </div>\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"chip.js","sourceRoot":"","sources":["../../../src/components/chip/chip.tsx"],"names":[],"mappings":"AAAA,OAAO,EACH,SAAS,EACT,OAAO,EACP,KAAK,EAEL,CAAC,EACD,IAAI,EACJ,IAAI,GACP,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EACH,kBAAkB,EAClB,oBAAoB,GACvB,MAAM,iCAAiC,CAAC;AACzC,OAAO,SAAS,MAAM,2BAA2B,CAAC;AAClD,OAAO,EACH,SAAS,EACT,kBAAkB,EAClB,MAAM,EACN,eAAe,GAClB,MAAM,qBAAqB,CAAC;AAe7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAMH,MAAM,OAAO,IAAI;;IA0HL,mBAAc,GAAG,GAAG,EAAE;MAC1B,O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;EAEO,iBAAiB;IACrB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;MAChB,OAAO;KACV;IAED,MAAM,iBAAiB,GAAG,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC;IAC9C,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAE3C,OAAO,CACH,WACI,IAAI,EAAC,aAAa,gBACP,GAAG,mBACA,GAAG,mBACH,KAAK,mBACJ,IAAI,CAAC,QAAQ,EAC5B,KAAK,EAAE;QACH,kCAAkC,EAAE,iBAAiB;OACxD;MAED;QAAO,QAAQ;YAAS,CACtB,CACT,CAAC;EACN,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACJ","sourcesContent":["import {\n Component,\n Element,\n Event,\n EventEmitter,\n h,\n Host,\n Prop,\n} from '@stencil/core';\nimport { Icon, Languages, Link } from '../../interface';\nimport { getIconName } from '../icon/get-icon-props';\nimport {\n makeEnterClickable,\n removeEnterClickable,\n} from '../../util/make-enter-clickable';\nimport translate from '../../global/translations';\nimport {\n BACKSPACE,\n BACKSPACE_KEY_CODE,\n DELETE,\n DELETE_KEY_CODE,\n} from '../../util/keycodes';\nimport { ChipType, Chip as OldChipInterface } from '../chip-set/chip.types';\n\ninterface ChipInterface extends Omit<OldChipInterface, 'id' | 'badge'> {\n /**\n * Identifier for the chip. Must be unique.\n */\n identifier?: number | string;\n\n /**\n * The value of the badge.\n */\n badge?: string | number;\n}\n\n/**\n * Chips and buttons are both interactive elements in UI design,\n * but they serve different purposes and are used in different contexts.\n *\n * :::warning\n * Do not use the chip component carelessly, as an alternative for\n * [`limel-button`](#/component/limel-button/) in the UI design!\n *\n * **Buttons:**\n * Buttons are used to trigger actions. They are typically used to\n * submit forms, open dialogs, initiate a process, or perform any action\n * that changes the state of the application.\n * Buttons' labels usually contain action words, in other words, the labels is\n * a _verb in imperative mood_ such as \"Submit\" or \"Delete\".\n * Buttons are placed in areas where it's clear they will initiate\n * an action when clicked.\n *\n * **Chips:**\n * Chips however are elements which may look like buttons, but they are\n * representing choices, filters, or tags, in a small block\n * or clearly bundled into a group. Chips are rarely used alone in the\n * user interface.\n * They are often used in a so called \"chip-set\", or placed together in\n * a section of the UI, where the user can expect more than one chip to be present.\n *\n * For example, a chip may represent a filter in a filter bar, or a tag in a tag list,\n * or an item in a shopping list.\n * Clicking a chip can also trigger an action, for example toggling a filter ON or OFF,\n * or opening a page with all posts tagged with the tag represented by the chip,\n * or navigating to a page with more information about the item in the shopping list.\n * :::\n *\n * @private\n * @exampleComponent limel-example-chip-button\n * @exampleComponent limel-example-chip-link\n * @exampleComponent limel-example-chip-icon-colors\n * @exampleComponent limel-example-chip-badge\n * @exampleComponent limel-example-chip-filter\n * @exampleComponent limel-example-chip-removable\n * @exampleComponent limel-example-chip-loading\n * @exampleComponent limel-example-chip-progress\n * @exampleComponent limel-example-chip-aria-role\n */\n@Component({\n tag: 'limel-chip',\n shadow: true,\n styleUrl: 'chip.scss',\n})\nexport class Chip implements ChipInterface {\n /**\n * Defines the language for translations.\n * Will translate the translatable strings on the components.\n */\n @Prop({ reflect: true })\n public language: Languages = 'en';\n\n /**\n * Label displayed on the chip\n */\n @Prop({ reflect: true })\n public text: string;\n\n /**\n * Icon of the chip.\n */\n @Prop()\n public icon?: string | Icon;\n\n /**\n * If supplied, the chip will become a clickable link.\n */\n @Prop()\n public link?: Omit<Link, 'text'>;\n\n /**\n * The value of the badge, displayed on the chip.\n */\n @Prop({ reflect: true })\n public badge?: string | number;\n\n /**\n * Set to `true` to disable the chip.\n */\n @Prop({ reflect: true })\n public disabled = false;\n\n /**\n * Set to `true` to render the chip as a static UI element.\n * Useful when the parent component has a `readonly` state.\n */\n @Prop({ reflect: true })\n public readonly = false;\n\n /**\n * Set to `true` to visualize the chip in a \"selected\" state.\n * This is typically used when the chip is used in a chip-set\n * along with other chips.\n */\n @Prop({ reflect: true })\n public selected = false;\n\n /**\n * Set to `true` to visualize the chip in an \"invalid\" or \"error\" state.\n */\n @Prop({ reflect: true })\n public invalid = false;\n\n /**\n * Set to `true` to render a remove button on the chip.\n */\n @Prop({ reflect: true })\n public removable = false;\n\n /**\n * Set to `filter` to render the chip with a distinct style\n * suitable for visualizing filters.\n *\n * @beta\n */\n @Prop({ reflect: true })\n public type?: ChipType = 'default';\n\n /**\n * Set to `true` to put the component in the `loading` state,\n * and render an indeterminate progress indicator inside the chip.\n * This does _not_ disable the interactivity of the chip!\n */\n @Prop({ reflect: true })\n public loading? = false;\n\n /**\n * Reflects the current value of a progress bar on the chip,\n * visualizing the percentage of an ongoing process.\n * Must be a number between `0` and `100`.\n */\n @Prop({ reflect: true })\n public progress?: number;\n\n /**\n * Identifier for the chip. Must be unique.\n */\n @Prop({ reflect: true })\n public identifier?: number | string = crypto.randomUUID();\n\n /**\n * Fired when clicking on the remove button of a `removable` chip.\n * The value of `identifier` is emitted as the event detail.\n */\n @Event()\n public remove: EventEmitter<number | string>;\n\n @Element()\n private host: HTMLLimelChipElement;\n\n public componentWillLoad() {\n makeEnterClickable(this.host);\n }\n\n public disconnectedCallback() {\n removeEnterClickable(this.host);\n }\n\n public render() {\n return (\n <Host onClick={this.filterClickWhenDisabled}>\n {this.link ? this.renderAsLink() : this.renderAsButton()}\n </Host>\n );\n }\n\n private renderAsButton = () => {\n return [\n <button\n id={'chip-' + this.identifier}\n class=\"chip\"\n role=\"button\"\n disabled={this.disabled || this.readonly}\n onKeyDown={this.handleDeleteKeyDown}\n >\n {this.renderSpinner()}\n {this.renderIcon()}\n {this.renderLabel()}\n {this.renderBadge()}\n {this.renderProgressBar()}\n </button>,\n this.renderRemoveButton(),\n ];\n };\n\n private renderAsLink = () => {\n return [\n <a\n id={'chip-' + this.identifier}\n class=\"chip\"\n href={this.link.href}\n title={this.link.title}\n target={this.link.target}\n aria-disabled={this.disabled || this.readonly}\n tabindex={this.disabled || this.readonly ? -1 : 0}\n onKeyDown={this.handleDeleteKeyDown}\n >\n {this.renderSpinner()}\n {this.renderIcon()}\n {this.renderLabel()}\n {this.renderBadge()}\n {this.renderProgressBar()}\n </a>,\n this.renderRemoveButton(),\n ];\n };\n\n private renderLabel = () => {\n return <span class=\"text\">{this.text}</span>;\n };\n\n private renderIcon() {\n const icon = getIconName(this.icon);\n\n if (!icon) {\n return;\n }\n\n return (\n <limel-icon\n badge={true}\n name={icon}\n style={{\n color: `${(this.icon as Icon)?.color}`,\n 'background-color': `${\n (this.icon as Icon)?.backgroundColor\n }`,\n }}\n />\n );\n }\n\n private renderBadge() {\n if (!this.badge) {\n return;\n }\n\n return <limel-badge label={this.badge} />;\n }\n\n private renderRemoveButton() {\n if (!this.removable || this.readonly || this.disabled) {\n return;\n }\n\n const svgData =\n '<svg viewBox=\"0 0 32 32\" xmlns=\"http://www.w3.org/2000/svg\"><path fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" d=\"m8 8 16 16M24 8 8 24\"/></svg>';\n\n return (\n <button\n class=\"trailing-button remove-button\"\n tabIndex={-1}\n aria-label={this.removeChipLabel}\n aria-controls={'chip-' + this.identifier}\n innerHTML={svgData}\n onClick={this.handleRemoveClick}\n />\n );\n }\n\n private filterClickWhenDisabled = (e) => {\n if (this.disabled || this.readonly) {\n e.preventDefault();\n }\n };\n\n private handleRemoveClick = (event: MouseEvent | KeyboardEvent) => {\n event.stopPropagation();\n this.remove.emit(this.identifier);\n };\n\n private handleDeleteKeyDown = (event: KeyboardEvent) => {\n if (!this.removable) {\n return;\n }\n\n const keys = [DELETE, BACKSPACE];\n const keycodes = [DELETE_KEY_CODE, BACKSPACE_KEY_CODE];\n\n if (keys.includes(event.key) || keycodes.includes(event.keyCode)) {\n this.handleRemoveClick(event);\n }\n };\n\n private removeChipLabel = (): string => {\n return translate.get('chip-set.remove-chip', this.language);\n };\n\n private renderSpinner() {\n if (!this.loading) {\n return;\n }\n\n return <limel-linear-progress indeterminate={true} />;\n }\n\n private renderProgressBar() {\n if (!this.progress) {\n return;\n }\n\n const currentPercentage = this.progress + '%';\n const progress = Math.round(this.progress);\n\n return (\n <div\n role=\"progressbar\"\n aria-label=\"%\"\n aria-valuemin=\"0\"\n aria-valuemax=\"100\"\n aria-valuenow={this.progress}\n style={{\n '--limel-chip-progress-percentage': currentPercentage,\n }}\n >\n <span>{progress}%</span>\n </div>\n );\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widget-adapter.js","sourceRoot":"","sources":["../../../../src/components/form/adapters/widget-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"widget-adapter.js","sourceRoot":"","sources":["../../../../src/components/form/adapters/widget-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAU3C;;;;;;;;;GASG;AACH,MAAM,OAAO,yBAA0B,SAAQ,KAAK,CAAC,SAAS;EAK1D,YAAmB,KAAyB;IACxC,KAAK,CAAC,KAAK,CAAC,CAAC;IADE,UAAK,GAAL,KAAK,CAAoB;IAJ5C,UAA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,EAAE,QAAQ,EAClB,QAAQ,EAAE,IAAI,CAAC,UAAU,EAAE,EAC3B,OAAO,EAAE,IAAI,CAAC,SAAS,EAAE,EACzB,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,IAChC,UAAU,CAChB;MACD,MAAM,EAAE,SAAS;KACpB,CAAC,EACF,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,CAClD,CAAC;EACN,CAAC;EAEO,UAAU;;IACd,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC;IAC3C,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC;IAExC,OAAO,CACH,WAAW,CAAC,QAAQ;OACpB,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,CAAA;OACjB,MAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,0CAAE,KAAK,0CAAE,QAAQ,CAAA,CACtC,CAAC;EACN,CAAC;EAEO,UAAU;IACd,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC;IAE3C,OAAO,WAAW,CAAC,QAAQ,CAAC;EAChC,CAAC;CACJ","sourcesContent":["import React from 'react';\nimport { WidgetProps } from '../widgets/types';\nimport { LimeElementsAdapter } from './base-adapter';\nimport { capitalize } from 'lodash-es';\nimport { getHelpComponent } from '../help';\n\ninterface WidgetAdapterProps {\n name: string;\n value?: any;\n widgetProps: WidgetProps;\n extraProps?: any;\n events?: { [key: string]: (event: any) => void };\n}\n\n/**\n * A widget is a concept in react-jsonschema-form (rjsf).\n * It represents a HTML tag for the user to enter data, eg. input, select, etc.\n *\n * We use the widget adapter exclusively so we can use lime-elements instead of the\n * default input/select/checkbox/etc fields that rjsf provides.\n *\n * Please read the docs for more info.\n * Link: https://react-jsonschema-form.readthedocs.io/\n */\nexport class LimeElementsWidgetAdapter extends React.Component {\n state = {\n modified: false,\n };\n\n constructor(public props: WidgetAdapterProps) {\n super(props);\n\n this.handleBlur = this.handleBlur.bind(this);\n }\n\n private hasValue() {\n const value = this.getValue();\n if (!value) {\n return false;\n }\n\n if (Array.isArray(value)) {\n return !!value.length;\n }\n\n if (typeof value === 'object') {\n return !!Object.entries(value).length;\n }\n\n return true;\n }\n\n private handleBlur() {\n this.setState({ modified: true });\n }\n\n private getLabel() {\n const { schema, label } = this.props.widgetProps;\n\n return label || schema.title;\n }\n\n private isInvalid() {\n const { modified } = this.state;\n const { rawErrors } = this.props.widgetProps;\n\n return (\n !!rawErrors && (modified || this.hasValue() || !this.isRequired())\n );\n }\n\n private isRequired() {\n const { required, schema } = this.props.widgetProps;\n\n return required || schema.minItems > 0;\n }\n\n private getHelperText() {\n const { rawErrors, schema } = this.props.widgetProps;\n\n if (!this.isInvalid()) {\n return schema.description;\n }\n\n if (rawErrors) {\n return capitalize(rawErrors[0]);\n }\n\n return schema.description;\n }\n\n private getValue() {\n const { value } = this.props;\n const { value: widgetValue } = this.props.widgetProps;\n\n // Use widgetValue unless its overriden in widget\n return value || widgetValue;\n }\n\n render() {\n const { name, events, extraProps } = this.props;\n const disabled = this.isDisabled();\n const value = this.getValue();\n const readonly = this.isReadOnly();\n\n const newEvents = {\n change: this.props.widgetProps.onChange,\n blur: this.handleBlur,\n ...events,\n };\n\n return React.createElement(\n React.Fragment,\n {},\n React.createElement(LimeElementsAdapter, {\n name: name,\n elementProps: {\n value: value,\n label: this.getLabel(),\n disabled: disabled,\n readonly: readonly,\n required: this.isRequired(),\n invalid: this.isInvalid(),\n 'helper-text': this.getHelperText(),\n ...extraProps,\n },\n events: newEvents,\n }),\n getHelpComponent(this.props.widgetProps.schema),\n );\n }\n\n private isDisabled() {\n const widgetProps = this.props.widgetProps;\n const options = widgetProps.schema.lime;\n\n return (\n widgetProps.disabled ||\n options?.disabled ||\n options?.component?.props?.disabled\n );\n }\n\n private isReadOnly() {\n const widgetProps = this.props.widgetProps;\n\n return widgetProps.readonly;\n }\n}\n"]}
|
|
@@ -205,9 +205,14 @@ export class Form {
|
|
|
205
205
|
"type": "unknown",
|
|
206
206
|
"mutable": false,
|
|
207
207
|
"complexType": {
|
|
208
|
-
"original": "
|
|
209
|
-
"resolved": "
|
|
210
|
-
"references": {
|
|
208
|
+
"original": "FormSchema",
|
|
209
|
+
"resolved": "FormSchema",
|
|
210
|
+
"references": {
|
|
211
|
+
"FormSchema": {
|
|
212
|
+
"location": "import",
|
|
213
|
+
"path": "./form.types"
|
|
214
|
+
}
|
|
215
|
+
}
|
|
211
216
|
},
|
|
212
217
|
"required": false,
|
|
213
218
|
"optional": false,
|
|
@@ -254,9 +259,13 @@ export class Form {
|
|
|
254
259
|
"type": "unknown",
|
|
255
260
|
"mutable": false,
|
|
256
261
|
"complexType": {
|
|
257
|
-
"original": "(schema:
|
|
258
|
-
"resolved": "(schema:
|
|
262
|
+
"original": "(schema: FormSchema) => Record<string, any>",
|
|
263
|
+
"resolved": "(schema: FormSchema) => Record<string, any>",
|
|
259
264
|
"references": {
|
|
265
|
+
"FormSchema": {
|
|
266
|
+
"location": "import",
|
|
267
|
+
"path": "./form.types"
|
|
268
|
+
},
|
|
260
269
|
"Record": {
|
|
261
270
|
"location": "global"
|
|
262
271
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form.js","sourceRoot":"","sources":["../../../src/components/form/form.tsx"],"names":[],"mappings":"AAAA,OAAO,EACH,SAAS,EACT,OAAO,EACP,KAAK,EAEL,CAAC,EACD,IAAI,EACJ,KAAK,GACR,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAQ,MAAM,kBAAkB,CAAC;AACpD,OAAO,cAA4B,MAAM,YAAY,CAAC;AACtD,OAAO,cAAc,MAAM,kCAAkC,CAAC;AAE9D,OAAO,EACH,kBAAkB,EAClB,aAAa,EACb,mBAAmB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,IAAI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C,OAAO;QACtB,6EAA6E;QAC7E,iEAAiE;QACjE,2DAA2D;QAC3D,UAAU,EAAE,KAAK,CAAC,YAAY,CAAC;OAClC,CAAC;IACN,CAAC,CAAC,CAAC;IAEH,uEAAuE;IACvE,sEAAsE;IACtE,8BAA8B;IAC9B,OAAO,IAAI,CAAC,eAAe;OACtB,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC;OAChB,GAAG,CAAC,CAAC,gBAA2B,EAAE,EAAE;MACjC,MAAM,aAAa,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC,KAAe,EAAE,EAAE;QAC1D,OAAO,gBAAgB,CAAC,QAAQ,KAAK,KAAK,CAAC,QAAQ,CAAC;MACxD,CAAC,CAAC,CAAC;MAEH,uCACO,aAAa,KAChB,OAAO,EAAE,gBAAgB,CAAC,OAAO,IACnC;IACN,CAAC,CAAC,CAAC;EACX,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACJ","sourcesContent":["import {\n Component,\n Element,\n Event,\n EventEmitter,\n h,\n Prop,\n Watch,\n} from '@stencil/core';\nimport React from 'react';\nimport { createRoot, Root } from 'react-dom/client';\nimport JSONSchemaForm, { AjvError } from '@rjsf/core';\nimport retargetEvents from 'react-shadow-dom-retarget-events';\nimport { FormError, ValidationError, ValidationStatus } from './form.types';\nimport {\n ArrayFieldTemplate,\n FieldTemplate,\n ObjectFieldTemplate,\n} from './templates';\nimport { SchemaField as CustomSchemaField } from './fields/schema-field';\nimport { ArrayField as CustomArrayField } from './fields/array-field';\nimport { ObjectField as CustomObjectField } from './fields/object-field';\nimport { widgets } from './widgets';\nimport { createRandomString } from '../../util/random-string';\nimport Ajv, { RequiredParams } from 'ajv';\nimport { isInteger } from './validators';\nimport { mapValues } from 'lodash-es';\n\n/**\n * @exampleComponent limel-example-form\n * @exampleComponent limel-example-nested-form\n * @exampleComponent limel-example-list-form\n * @exampleComponent limel-example-dynamic-form\n * @exampleComponent limel-example-custom-component-form\n * @exampleComponent limel-example-props-factory-form\n * @exampleComponent limel-example-form-layout\n * @exampleComponent limel-example-form-span-fields\n * @exampleComponent limel-example-custom-error-message\n * @exampleComponent limel-example-server-errors\n * @exampleComponent limel-example-form-with-help\n * @exampleComponent limel-example-form-row-layout\n */\n@Component({\n tag: 'limel-form',\n shadow: true,\n styleUrl: 'form.scss',\n})\nexport class Form {\n /**\n * The schema used to render the form\n */\n @Prop()\n public schema: {\n id?: string;\n [key: string]: any;\n } = {};\n\n /**\n * Value of the form\n */\n @Prop()\n public value: object;\n\n /**\n * Set to `true` to disable the whole form.\n */\n @Prop()\n public disabled = false;\n\n /**\n * Factory for creating properties for custom form components\n *\n * When using custom components in the form some properties might have to be\n * set dynamically. If this factory is set, it will be called with the\n * current schema for the field for each custom component in the form. The\n * factory must return an object where each key is the name of the property\n * that should be set, along with its value.\n */\n @Prop()\n public propsFactory?: (schema: Record<string, any>) => Record<string, any>;\n\n /**\n * Custom function to customize the default error messages\n */\n @Prop()\n public transformErrors?: (errors: FormError[]) => FormError[];\n\n /**\n * Extra errors to display in the form. Typical use case is asynchronous\n * errors generated server side.\n */\n @Prop()\n public errors: ValidationError;\n\n /**\n * Emitted when a change is made within the form\n */\n @Event()\n public change: EventEmitter<object>;\n\n /**\n * Emitted when the validity of the form changes, or when\n * a change is made to an invalid form\n */\n @Event()\n public validate: EventEmitter<ValidationStatus>;\n\n @Element()\n private host: HTMLLimelFormElement;\n\n private isValid = true;\n private modifiedSchema: object;\n private validator: Ajv.ValidateFunction;\n private root: Root;\n\n public constructor() {\n this.handleChange = this.handleChange.bind(this);\n this.getCustomErrorMessages = this.getCustomErrorMessages.bind(this);\n }\n\n public connectedCallback() {\n this.initialize();\n }\n\n public componentWillLoad() {\n this.setSchemaId();\n this.createValidator();\n }\n\n public componentDidLoad() {\n this.initialize();\n }\n\n private initialize() {\n if (!this.host.shadowRoot.querySelector('.root')) {\n return;\n }\n\n this.reactRender();\n retargetEvents(this.host.shadowRoot);\n this.validateForm(this.value);\n }\n\n public componentDidUpdate() {\n this.reactRender();\n this.validateForm(this.value);\n }\n\n public disconnectedCallback() {\n if (this.root) {\n this.root.unmount();\n this.root = undefined;\n }\n }\n\n public render() {\n return <div class=\"root\" />;\n }\n\n private reactRender() {\n if (!this.root) {\n const rootElement = this.host.shadowRoot.querySelector('.root');\n this.root = createRoot(rootElement);\n }\n\n this.root.render(\n React.createElement(\n JSONSchemaForm,\n {\n schema: this.modifiedSchema,\n formData: this.value,\n onChange: this.handleChange,\n widgets: widgets,\n liveValidate: true,\n showErrorList: false,\n extraErrors: this.getExtraErrors(this.errors),\n FieldTemplate: FieldTemplate,\n ArrayFieldTemplate: ArrayFieldTemplate as any,\n ObjectFieldTemplate: ObjectFieldTemplate,\n disabled: this.disabled,\n transformErrors: this.getCustomErrorMessages,\n formContext: {\n schema: this.modifiedSchema,\n rootValue: this.value,\n propsFactory: this.propsFactory,\n },\n fields: {\n SchemaField: CustomSchemaField as any,\n ArrayField: CustomArrayField as any,\n ObjectField: CustomObjectField as any,\n },\n },\n [],\n ),\n );\n }\n\n private handleChange(event: any) {\n this.change.emit(event.formData);\n }\n\n private validateForm(value: object) {\n const isValid = this.validator(value) === true;\n const errors: FormError[] = this.getValidationErrors();\n const status: ValidationStatus = {\n valid: isValid,\n errors: errors,\n };\n\n if (this.isValid !== status.valid || !status.valid) {\n this.validate.emit(status);\n }\n\n this.isValid = status.valid;\n }\n\n @Watch('schema')\n public setSchema() {\n this.setSchemaId();\n this.createValidator();\n }\n\n private setSchemaId() {\n // Due to a bug in react-jsonschema-form, validation will stop working if the schema is updated.\n // A workaround at the moment is to always give it a unique ID\n // https://github.com/rjsf-team/react-jsonschema-form/issues/1563\n const id = `${this.schema.$id}-${createRandomString()}`;\n this.modifiedSchema = {\n ...this.schema,\n id: id,\n $id: id,\n };\n }\n\n private createValidator() {\n const validator = new Ajv({\n unknownFormats: 'ignore',\n allErrors: true,\n multipleOfPrecision: 2,\n }).addFormat('integer', isInteger);\n this.validator = validator.compile(this.schema);\n }\n\n private getValidationErrors(): FormError[] {\n const errors = this.validator.errors || [];\n\n return errors.map((error: Ajv.ErrorObject): FormError => {\n let property = error.dataPath;\n if (error.keyword === 'required') {\n property = (error.params as RequiredParams).missingProperty;\n }\n\n return {\n name: error.keyword,\n property: property,\n message: error.message,\n schemaPath: error.schemaPath,\n };\n });\n }\n\n private getExtraErrors(errors: ValidationError): ExtraError | undefined {\n if (!errors) {\n return;\n }\n\n return mapValues(errors, (error) => {\n if (Array.isArray(error)) {\n return { __errors: error };\n }\n\n return this.getExtraErrors(error);\n });\n }\n\n private getCustomErrorMessages(originalErrors: AjvError[]): AjvError[] {\n if (!this.transformErrors) {\n return originalErrors;\n }\n\n const errors: FormError[] = originalErrors.map((error: AjvError) => {\n return {\n name: error.name,\n params: error.params,\n property: error.property,\n message: error.message,\n // For some reason 'schemaPath' is missing from the AjvError type definition:\n // https://github.com/rjsf-team/react-jsonschema-form/issues/2140\n // eslint-disable-next-line @typescript-eslint/dot-notation\n schemaPath: error['schemaPath'],\n };\n });\n\n // Use `.call({}, …)` here to bind `this` to an empty object to prevent\n // the consumer submitted `transformErrors` from getting access to our\n // component's internals. /Ads\n return this.transformErrors\n .call({}, errors)\n .map((transformedError: FormError) => {\n const originalError = originalErrors.find((error: AjvError) => {\n return transformedError.property === error.property;\n });\n\n return {\n ...originalError,\n message: transformedError.message,\n };\n });\n }\n}\n\ninterface ExtraError {\n [key: string]:\n | ExtraError\n | {\n __errors: string[];\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"form.js","sourceRoot":"","sources":["../../../src/components/form/form.tsx"],"names":[],"mappings":"AAAA,OAAO,EACH,SAAS,EACT,OAAO,EACP,KAAK,EAEL,CAAC,EACD,IAAI,EACJ,KAAK,GACR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IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;MACvB,OAAO,cAAc,CAAC;KACzB;IAED,MAAM,MAAM,GAAgB,cAAc,CAAC,GAAG,CAAC,CAAC,KAAe,EAAE,EAAE;MAC/D,OAAO;QACH,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,6EAA6E;QAC7E,iEAAiE;QACjE,2DAA2D;QAC3D,UAAU,EAAE,KAAK,CAAC,YAAY,CAAC;OAClC,CAAC;IACN,CAAC,CAAC,CAAC;IAEH,uEAAuE;IACvE,sEAAsE;IACtE,8BAA8B;IAC9B,OAAO,IAAI,CAAC,eAAe;OACtB,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC;OAChB,GAAG,CAAC,CAAC,gBAA2B,EAAE,EAAE;MACjC,MAAM,aAAa,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC,KAAe,EAAE,EAAE;QAC1D,OAAO,gBAAgB,CAAC,QAAQ,KAAK,KAAK,CAAC,QAAQ,CAAC;MACxD,CAAC,CAAC,CAAC;MAEH,uCACO,aAAa,KAChB,OAAO,EAAE,gBAAgB,CAAC,OAAO,IACnC;IACN,CAAC,CAAC,CAAC;EACX,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACJ","sourcesContent":["import {\n Component,\n Element,\n Event,\n EventEmitter,\n h,\n Prop,\n Watch,\n} from '@stencil/core';\nimport React from 'react';\nimport { createRoot, Root } from 'react-dom/client';\nimport JSONSchemaForm, { AjvError } from '@rjsf/core';\nimport retargetEvents from 'react-shadow-dom-retarget-events';\nimport {\n FormError,\n FormSchema,\n ValidationError,\n ValidationStatus,\n} from './form.types';\nimport {\n ArrayFieldTemplate,\n FieldTemplate,\n ObjectFieldTemplate,\n} from './templates';\nimport { SchemaField as CustomSchemaField } from './fields/schema-field';\nimport { ArrayField as CustomArrayField } from './fields/array-field';\nimport { ObjectField as CustomObjectField } from './fields/object-field';\nimport { widgets } from './widgets';\nimport { createRandomString } from '../../util/random-string';\nimport Ajv, { RequiredParams } from 'ajv';\nimport { isInteger } from './validators';\nimport { mapValues } from 'lodash-es';\n\n/**\n * @exampleComponent limel-example-form\n * @exampleComponent limel-example-nested-form\n * @exampleComponent limel-example-list-form\n * @exampleComponent limel-example-dynamic-form\n * @exampleComponent limel-example-custom-component-form\n * @exampleComponent limel-example-props-factory-form\n * @exampleComponent limel-example-form-layout\n * @exampleComponent limel-example-form-span-fields\n * @exampleComponent limel-example-custom-error-message\n * @exampleComponent limel-example-server-errors\n * @exampleComponent limel-example-form-with-help\n * @exampleComponent limel-example-form-row-layout\n */\n@Component({\n tag: 'limel-form',\n shadow: true,\n styleUrl: 'form.scss',\n})\nexport class Form {\n /**\n * The schema used to render the form\n */\n @Prop()\n public schema: FormSchema = {};\n\n /**\n * Value of the form\n */\n @Prop()\n public value: object;\n\n /**\n * Set to `true` to disable the whole form.\n */\n @Prop()\n public disabled = false;\n\n /**\n * Factory for creating properties for custom form components\n *\n * When using custom components in the form some properties might have to be\n * set dynamically. If this factory is set, it will be called with the\n * current schema for the field for each custom component in the form. The\n * factory must return an object where each key is the name of the property\n * that should be set, along with its value.\n */\n @Prop()\n public propsFactory?: (schema: FormSchema) => Record<string, any>;\n\n /**\n * Custom function to customize the default error messages\n */\n @Prop()\n public transformErrors?: (errors: FormError[]) => FormError[];\n\n /**\n * Extra errors to display in the form. Typical use case is asynchronous\n * errors generated server side.\n */\n @Prop()\n public errors: ValidationError;\n\n /**\n * Emitted when a change is made within the form\n */\n @Event()\n public change: EventEmitter<object>;\n\n /**\n * Emitted when the validity of the form changes, or when\n * a change is made to an invalid form\n */\n @Event()\n public validate: EventEmitter<ValidationStatus>;\n\n @Element()\n private host: HTMLLimelFormElement;\n\n private isValid = true;\n private modifiedSchema: FormSchema;\n private validator: Ajv.ValidateFunction;\n private root: Root;\n\n public constructor() {\n this.handleChange = this.handleChange.bind(this);\n this.getCustomErrorMessages = this.getCustomErrorMessages.bind(this);\n }\n\n public connectedCallback() {\n this.initialize();\n }\n\n public componentWillLoad() {\n this.setSchemaId();\n this.createValidator();\n }\n\n public componentDidLoad() {\n this.initialize();\n }\n\n private initialize() {\n if (!this.host.shadowRoot.querySelector('.root')) {\n return;\n }\n\n this.reactRender();\n retargetEvents(this.host.shadowRoot);\n this.validateForm(this.value);\n }\n\n public componentDidUpdate() {\n this.reactRender();\n this.validateForm(this.value);\n }\n\n public disconnectedCallback() {\n if (this.root) {\n this.root.unmount();\n this.root = undefined;\n }\n }\n\n public render() {\n return <div class=\"root\" />;\n }\n\n private reactRender() {\n if (!this.root) {\n const rootElement = this.host.shadowRoot.querySelector('.root');\n this.root = createRoot(rootElement);\n }\n\n this.root.render(\n React.createElement(\n JSONSchemaForm,\n {\n schema: this.modifiedSchema,\n formData: this.value,\n onChange: this.handleChange,\n widgets: widgets,\n liveValidate: true,\n showErrorList: false,\n extraErrors: this.getExtraErrors(this.errors),\n FieldTemplate: FieldTemplate,\n ArrayFieldTemplate: ArrayFieldTemplate as any,\n ObjectFieldTemplate: ObjectFieldTemplate,\n disabled: this.disabled,\n transformErrors: this.getCustomErrorMessages,\n formContext: {\n schema: this.modifiedSchema,\n rootValue: this.value,\n propsFactory: this.propsFactory,\n },\n fields: {\n SchemaField: CustomSchemaField as any,\n ArrayField: CustomArrayField as any,\n ObjectField: CustomObjectField as any,\n },\n },\n [],\n ),\n );\n }\n\n private handleChange(event: any) {\n this.change.emit(event.formData);\n }\n\n private validateForm(value: object) {\n const isValid = this.validator(value) === true;\n const errors: FormError[] = this.getValidationErrors();\n const status: ValidationStatus = {\n valid: isValid,\n errors: errors,\n };\n\n if (this.isValid !== status.valid || !status.valid) {\n this.validate.emit(status);\n }\n\n this.isValid = status.valid;\n }\n\n @Watch('schema')\n public setSchema() {\n this.setSchemaId();\n this.createValidator();\n }\n\n private setSchemaId() {\n // Due to a bug in react-jsonschema-form, validation will stop working if the schema is updated.\n // A workaround at the moment is to always give it a unique ID\n // https://github.com/rjsf-team/react-jsonschema-form/issues/1563\n const id = `${this.schema.$id}-${createRandomString()}`;\n this.modifiedSchema = {\n ...this.schema,\n id: id,\n $id: id,\n };\n }\n\n private createValidator() {\n const validator = new Ajv({\n unknownFormats: 'ignore',\n allErrors: true,\n multipleOfPrecision: 2,\n }).addFormat('integer', isInteger);\n this.validator = validator.compile(this.schema);\n }\n\n private getValidationErrors(): FormError[] {\n const errors = this.validator.errors || [];\n\n return errors.map((error: Ajv.ErrorObject): FormError => {\n let property = error.dataPath;\n if (error.keyword === 'required') {\n property = (error.params as RequiredParams).missingProperty;\n }\n\n return {\n name: error.keyword,\n property: property,\n message: error.message,\n schemaPath: error.schemaPath,\n };\n });\n }\n\n private getExtraErrors(errors: ValidationError): ExtraError | undefined {\n if (!errors) {\n return;\n }\n\n return mapValues(errors, (error) => {\n if (Array.isArray(error)) {\n return { __errors: error };\n }\n\n return this.getExtraErrors(error);\n });\n }\n\n private getCustomErrorMessages(originalErrors: AjvError[]): AjvError[] {\n if (!this.transformErrors) {\n return originalErrors;\n }\n\n const errors: FormError[] = originalErrors.map((error: AjvError) => {\n return {\n name: error.name,\n params: error.params,\n property: error.property,\n message: error.message,\n // For some reason 'schemaPath' is missing from the AjvError type definition:\n // https://github.com/rjsf-team/react-jsonschema-form/issues/2140\n // eslint-disable-next-line @typescript-eslint/dot-notation\n schemaPath: error['schemaPath'],\n };\n });\n\n // Use `.call({}, …)` here to bind `this` to an empty object to prevent\n // the consumer submitted `transformErrors` from getting access to our\n // component's internals. /Ads\n return this.transformErrors\n .call({}, errors)\n .map((transformedError: FormError) => {\n const originalError = originalErrors.find((error: AjvError) => {\n return transformedError.property === error.property;\n });\n\n return {\n ...originalError,\n message: transformedError.message,\n };\n });\n }\n}\n\ninterface ExtraError {\n [key: string]:\n | ExtraError\n | {\n __errors: string[];\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form.types.js","sourceRoot":"","sources":["../../../src/components/form/form.types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"form.types.js","sourceRoot":"","sources":["../../../src/components/form/form.types.ts"],"names":[],"mappings":"AAiSA;;;GAGG;AACH,MAAM,CAAN,IAAY,cAmBX;AAnBD,WAAY,cAAc;EACtB;;KAEG;EACH,qCAAmB,CAAA;EAEnB;;KAEG;EACH,+BAAa,CAAA;EAEb;;;;;;KAMG;EACH,6BAAW,CAAA;AACf,CAAC,EAnBW,cAAc,KAAd,cAAc,QAmBzB","sourcesContent":["import { JSONSchema7 } from 'json-schema';\nimport { Help } from '../help/help.types';\nimport { EventEmitter } from '@stencil/core';\n\ndeclare module 'json-schema' {\n interface JSONSchema7 {\n /**\n * @internal\n * Unique identifier for the schema\n */\n id?: string;\n\n /**\n * Lime elements specific options that can be specified in a schema\n */\n lime?: Omit<LimeSchemaOptions, 'layout'> & {\n layout?: Partial<LimeLayoutOptions>;\n };\n }\n}\n\n/**\n * @public\n */\nexport interface ValidationStatus {\n /**\n * True if the form is valid, false otherwise\n *\n * If the form is invalid, any errors can be found on the `errors` property\n */\n valid: boolean;\n\n /**\n * List of validation errors\n */\n errors?: FormError[];\n}\n\n/**\n * @public\n */\nexport interface FormError {\n /**\n * Name of the error\n */\n name: string;\n\n /**\n * Params of the error\n */\n params?: unknown;\n\n /**\n * Name of the invalid property\n */\n property: string;\n\n /**\n * Path to the property within the schema\n */\n schemaPath: string;\n\n /**\n * String describing the error\n */\n message: string;\n}\n\n/**\n * @public\n */\nexport type ValidationError = {\n /**\n * Name of the field the error belongs to\n */\n [key: string]: string[] | ValidationError;\n};\n\n/**\n * @public\n */\nexport interface FormComponent<T = any> {\n /**\n * The value of the current property\n */\n value: T;\n\n /**\n * Whether or not the current property is required\n */\n required?: boolean;\n\n /**\n * Whether or not the current property is readonly\n */\n readonly?: boolean;\n\n /**\n * Whether or not the current property is disabled\n */\n disabled?: boolean;\n\n /**\n * The label of the current property\n */\n label?: string;\n\n /**\n * The helper text for the current property\n */\n helperText?: string;\n\n /**\n * Additional contextual information about the form\n */\n formInfo?: FormInfo;\n\n /**\n * The event to emit when the value of the current property has changed\n */\n change: EventEmitter<T>;\n}\n\n/**\n * @public\n */\nexport interface FormInfo {\n /**\n * The schema of the current property\n */\n schema?: FormSchema;\n\n /**\n * The schema of the whole form\n */\n rootSchema?: FormSchema;\n\n /**\n * A tree of errors for this property and its children\n */\n errorSchema?: object;\n\n /**\n * The value of the whole form\n */\n rootValue?: any;\n\n /**\n * The name of the current property\n */\n name?: string;\n\n /**\n * Path to the property within the schema\n */\n schemaPath?: string[];\n}\n\n/**\n * Lime elements specific options that can be specified under the `lime` key in\n * a schema, e.g.\n *\n * ```ts\n * const schema = {\n * type: 'object',\n * lime: {\n * collapsible: true,\n * },\n * };\n * ```\n *\n * @public\n */\nexport interface LimeSchemaOptions {\n /**\n * When specified on an object it will render all sub components inside a\n * collapsible section\n */\n collapsible?: boolean;\n\n /**\n * When `collapsible` is `true`, set this to `false` to make the\n * collapsible section load in the open state.\n * Defaults to `true`.\n */\n collapsed?: boolean;\n\n /**\n * Will render the field using the specified component. The component\n * should implement the `FormComponent` interface\n */\n component?: FormComponentOptions;\n\n /**\n * When specified on an object it will render the sub components with the\n * specified layout\n */\n layout?: LimeLayoutOptions;\n\n /**\n * Mark the field as disabled\n */\n disabled?: boolean;\n\n help?: string | Partial<Help>;\n}\n\n/**\n * @public\n * Options for a layout to be used in a form\n */\nexport type LimeLayoutOptions = GridLayoutOptions & RowLayoutOptions;\n\n/**\n * Options for a component to be rendered inside a form\n *\n * @public\n */\nexport interface FormComponentOptions {\n /**\n * Name of the component\n */\n name?: string;\n\n /**\n * Extra properties to give the component in addition to the properties\n * specified on the `FormComponent` interface\n */\n props?: Record<string, any>;\n}\n\n/**\n * @public\n */\nexport interface FormLayoutOptions<\n T extends FormLayoutType | `${FormLayoutType}` = FormLayoutType.Default,\n> {\n /**\n * The type of layout to use\n */\n type: T;\n}\n\n/**\n * @public\n * Layout options for a grid layout\n */\nexport interface GridLayoutOptions\n extends FormLayoutOptions<FormLayoutType | `${FormLayoutType}`> {\n /**\n * When specified on a component within the grid, the component will take\n * up the the specified number of columns in the form\n */\n // eslint-disable-next-line no-magic-numbers\n colSpan?: 1 | 2 | 3 | 4 | 5 | 'all';\n\n /**\n * When specified on a component within the grid, the component will take\n * up the the specified number of rows in the form\n */\n rowSpan?: number;\n\n /**\n * Number of columns to use in the layout\n */\n // eslint-disable-next-line no-magic-numbers\n columns?: 1 | 2 | 3 | 4 | 5;\n\n /**\n * Attempts to fill in holes earlier in the grid, if smaller items come up\n * later. This may cause items to appear out-of-order, when doing so would\n * fill holes left by larger items. Defaults to `true`.\n */\n dense?: boolean;\n}\n\n/**\n * @public\n * Layout options for a row layout\n */\nexport interface RowLayoutOptions\n extends FormLayoutOptions<FormLayoutType | `${FormLayoutType}`> {\n /**\n * When specified on a field, the chosen icon will be displayed\n * on the left side of the row, beside the title.\n */\n icon?: string;\n}\n\n/**\n * @public\n * Represents the layout types for a form.\n */\nexport enum FormLayoutType {\n /**\n * The default layout\n */\n Default = 'default',\n\n /**\n * Render the form fields using a responsive grid layout\n */\n Grid = 'grid',\n\n /**\n * Render the form fields in full-width rows.\n * Each row can have a leading `icon`, and a field.\n * `title` and `description` provided by the schema will be placed\n * on the row itself, and not on the field.\n * This layout is good for creating UIs for user settings pages.\n */\n Row = 'row',\n}\n\n/**\n * @public\n * Represents the JSON schema with Lime specific options\n */\nexport interface FormSchema extends JSONSchema7 {}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help.js","sourceRoot":"","sources":["../../../../src/components/form/help/help.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAG/D,MAAM,UAAU,gBAAgB,CAAC,
|
|
1
|
+
{"version":3,"file":"help.js","sourceRoot":"","sources":["../../../../src/components/form/help/help.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAG/D,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,mBAAmB,EAAE;IAC5C,IAAI,EAAE,YAAY;IAClB,YAAY,EAAE,SAAS;GAC1B,CAAC,CAAC;AACP,CAAC","sourcesContent":["import React from 'react';\nimport { LimeElementsAdapter } from '../adapters/base-adapter';\nimport { FormSchema } from '../form.types';\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(LimeElementsAdapter, {\n name: 'limel-help',\n elementProps: helpProps,\n });\n}\n"]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { FormLayoutType } from '../form.types';
|
|
3
2
|
import { renderDescription, renderTitle } from './common';
|
|
4
3
|
import { GridLayout } from './grid-layout';
|
|
5
4
|
import { RowLayout } from './row-layout';
|
|
@@ -38,7 +37,7 @@ function renderProperties(properties, schema) {
|
|
|
38
37
|
return renderLayout(properties, layout);
|
|
39
38
|
}
|
|
40
39
|
function renderLayout(properties, layout) {
|
|
41
|
-
const type = (layout === null || layout === void 0 ? void 0 : layout.type) ||
|
|
40
|
+
const type = (layout === null || layout === void 0 ? void 0 : layout.type) || 'default';
|
|
42
41
|
const layouts = {
|
|
43
42
|
default: renderDefaultLayout,
|
|
44
43
|
grid: renderGridLayout,
|
|
@@ -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;
|
|
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,cAAc,CAAC;AAGzC,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAAmC,EAAE,EAAE;EACvE,MAAM,EAAE,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC;EAC9B,IAAI,EAAE,KAAK,MAAM,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;IAC/C,OAAO,oBAAoB,CAAC,KAAK,CAAC,CAAC;GACtC;EAED,IAAI,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;IAC7B,OAAO,sBAAsB,CAAC,KAAK,CAAC,CAAC;GACxC;EAED,OAAO,gBAAgB,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;AAC5D,CAAC,CAAC;AAEF,SAAS,oBAAoB,CAAC,KAAmC;EAC7D,OAAO,KAA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,KAAK,CAAC;AAC3C,CAAC","sourcesContent":["import React from 'react';\nimport {\n FormLayoutType,\n FormSchema,\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';\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(schema: any, subSchema: FormSchema) {\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: FormSchema,\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: FormSchema) {\n return !!schema.lime?.collapsible;\n}\n\nfunction isCollapsed(schema: FormSchema) {\n return schema.lime.collapsed !== false;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/components/form/templates/types.ts"],"names":[],"mappings":"","sourcesContent":["import { ObjectFieldTemplateProps, ArrayFieldTemplateProps } from '@rjsf/core';\nimport {
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/components/form/templates/types.ts"],"names":[],"mappings":"","sourcesContent":["import { ObjectFieldTemplateProps, ArrayFieldTemplateProps } from '@rjsf/core';\nimport { FormSchema } from '../form.types';\nexport { FieldTemplateProps, ArrayFieldTemplateProps } from '@rjsf/core';\n\nexport type TemplateProps = ObjectFieldTemplateProps | ArrayFieldTemplateProps;\n\nexport type ObjectFieldProperty = ObjectFieldTemplateProps['properties'][0];\n\nexport type ArrayFieldItem = ArrayFieldTemplateProps['items'][0];\n\nexport interface LimeObjectFieldTemplateProps extends ObjectFieldTemplateProps {\n schema: FormSchema;\n}\n\nexport interface Runnable {\n run: (event: any) => void;\n}\n\nexport interface RowProps {\n children?: any;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/components/form/widgets/types.ts"],"names":[],"mappings":"","sourcesContent":["import { WidgetProps as RjsfWidgetProps } from '@rjsf/core';\nimport {
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/components/form/widgets/types.ts"],"names":[],"mappings":"","sourcesContent":["import { WidgetProps as RjsfWidgetProps } from '@rjsf/core';\nimport { FormSchema } from '../form.types';\n\nexport interface WidgetProps extends RjsfWidgetProps {\n schema: FormSchema;\n}\n"]}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @public
|
|
3
|
+
* Represents the layout types for a form.
|
|
4
|
+
*/
|
|
5
|
+
var FormLayoutType;
|
|
6
|
+
(function (FormLayoutType) {
|
|
7
|
+
/**
|
|
8
|
+
* The default layout
|
|
9
|
+
*/
|
|
10
|
+
FormLayoutType["Default"] = "default";
|
|
11
|
+
/**
|
|
12
|
+
* Render the form fields using a responsive grid layout
|
|
13
|
+
*/
|
|
14
|
+
FormLayoutType["Grid"] = "grid";
|
|
15
|
+
/**
|
|
16
|
+
* Render the form fields in full-width rows.
|
|
17
|
+
* Each row can have a leading `icon`, and a field.
|
|
18
|
+
* `title` and `description` provided by the schema will be placed
|
|
19
|
+
* on the row itself, and not on the field.
|
|
20
|
+
* This layout is good for creating UIs for user settings pages.
|
|
21
|
+
*/
|
|
22
|
+
FormLayoutType["Row"] = "row";
|
|
23
|
+
})(FormLayoutType || (FormLayoutType = {}));
|
|
2
24
|
|
|
3
25
|
/**
|
|
4
26
|
* The built-in aggregators available for columns
|
|
@@ -28,6 +50,6 @@ var ColumnAggregatorType;
|
|
|
28
50
|
ColumnAggregatorType["Count"] = "count";
|
|
29
51
|
})(ColumnAggregatorType || (ColumnAggregatorType = {}));
|
|
30
52
|
|
|
31
|
-
export { ColumnAggregatorType };
|
|
53
|
+
export { ColumnAggregatorType, FormLayoutType };
|
|
32
54
|
|
|
33
55
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"index.js","mappings":";;AAqJA;;;;IAIY;AAAZ,WAAY,oBAAoB;;;;EAI5B,uCAAe,CAAA;;;;EAKf,uCAAe,CAAA;;;;EAKf,uCAAe,CAAA;;;;EAKf,mCAAW,CAAA;;;;EAKX,uCAAe,CAAA;AACnB,CAAC,EAzBW,oBAAoB,KAApB,oBAAoB;;;;","names":[],"sources":["./src/components/table/table.types.ts"],"sourcesContent":["/**\n * Defines the data for a table\n * @public\n */\nexport interface Column<T extends object = any> {\n /**\n * Column title to be displayed\n */\n title: string;\n\n /**\n * Name of the field in the data\n */\n field: keyof T;\n\n /**\n * Function to format the value before rendering\n */\n formatter?: TableFormatter;\n\n /**\n * Component used to render the field value\n */\n component?: TableComponentDefinition;\n\n /**\n * Type of aggregator to use for the column\n */\n aggregator?: ColumnAggregatorType | ColumnAggregatorFunction<T>;\n\n /**\n * A component used to render inside the column header\n */\n headerComponent?: TableComponentDefinition;\n\n /**\n * Sets the horizontal text alignment for the column\n */\n horizontalAlign?: 'left' | 'center' | 'right';\n\n /**\n * Defines whether end-user can sort a column\n */\n headerSort?: boolean;\n}\n\n/**\n * Definition for a formatter function\n * @param value - The value to be formatted\n * @param data - The data for the current row\n * @returns The formatted value\n * @public\n */\nexport type TableFormatter = (value: any, data?: object) => string;\n\n/**\n * The `component` key in the schema uses this interface to define a\n * component to be rendered inside a cell in the table.\n *\n * @note The table will display the component as `inline-block` in order\n * to give the column the correct size. If the component should have the\n * full width of the column, this might have to be overridden by setting\n * the display mode to `block`, e.g.\n *\n * ```css\n * :host(*) {\n * display: block !important;\n * }\n * ```\n * @public\n */\nexport interface TableComponentDefinition {\n /**\n * Name of the component\n */\n name: string;\n\n /**\n * Properties to send to the component\n */\n props?: Record<string, any>;\n\n /**\n * Factory for creating properties dynamically for a custom component.\n *\n * The properties returned from this function will be merged with the\n * `props` properties when the component is created.\n *\n * When the propsFactory is used for header components there will be no data available.\n *\n * @param data - The data for the current row\n * @returns Properties for the component\n */\n propsFactory?: (data: object) => Record<string, any>;\n}\n\n/**\n * Interface for custom components rendered inside a `limel-table`.\n * @public\n */\nexport interface TableComponent<T extends object = any> {\n /**\n * Name of the field being rendered\n */\n field?: string;\n\n /**\n * Value being rendered\n */\n value?: any;\n\n /**\n * Data for the current row of the table\n */\n data?: T;\n}\n\n/**\n * Indicates whether the specified column is sorted ascending or descending.\n * @public\n */\nexport interface ColumnSorter {\n /**\n * The column being sorted\n */\n column: Column;\n\n /**\n * The direction to sort on\n */\n direction: 'ASC' | 'DESC';\n}\n\n/**\n * Specifies the current page, and which columns the table is currently sorted on.\n * @public\n */\nexport interface TableParams {\n /**\n * The current page being set\n */\n page: number;\n\n /**\n * Sorters applied to the current page\n */\n sorters?: ColumnSorter[];\n}\n\n/**\n * The built-in aggregators available for columns\n * @public\n */\nexport enum ColumnAggregatorType {\n /**\n * Calculates the average value of all numerical cells in the column\n */\n Average = 'avg',\n\n /**\n * Displays the maximum value from all numerical cells in the column\n */\n Maximum = 'max',\n\n /**\n * Displays the minimum value from all numerical cells in the column\n */\n Minimum = 'min',\n\n /**\n * Displays the sum of all numerical cells in the column\n */\n Sum = 'sum',\n\n /**\n * Counts the number of non empty cells in the column\n */\n Count = 'count',\n}\n\n/**\n * Instead of using one of the built-in aggregators, it is possible to\n * define a custom aggregator function.\n *\n * @param column - the configuration for the column\n * @param values - list of all values to be aggregated\n * @param data - list of all objects to be aggregated\n * @returns the aggregated data\n *\n * @public\n */\nexport type ColumnAggregatorFunction<T = object> = (\n column?: Column,\n values?: any[],\n data?: T[],\n) => any;\n\n/**\n * Defines aggregate values for columns\n * @public\n */\nexport interface ColumnAggregate {\n /**\n * The name of the `Column` field\n */\n field: string;\n /**\n * The aggregate value\n */\n value: any;\n}\n"],"version":3}
|
|
1
|
+
{"file":"index.js","mappings":"AAiSA;;;;IAIY;AAAZ,WAAY,cAAc;;;;EAItB,qCAAmB,CAAA;;;;EAKnB,+BAAa,CAAA;;;;;;;;EASb,6BAAW,CAAA;AACf,CAAC,EAnBW,cAAc,KAAd,cAAc;;AChJ1B;;;;IAIY;AAAZ,WAAY,oBAAoB;;;;EAI5B,uCAAe,CAAA;;;;EAKf,uCAAe,CAAA;;;;EAKf,uCAAe,CAAA;;;;EAKf,mCAAW,CAAA;;;;EAKX,uCAAe,CAAA;AACnB,CAAC,EAzBW,oBAAoB,KAApB,oBAAoB;;;;","names":[],"sources":["./src/components/form/form.types.ts","./src/components/table/table.types.ts"],"sourcesContent":["import { JSONSchema7 } from 'json-schema';\nimport { Help } from '../help/help.types';\nimport { EventEmitter } from '@stencil/core';\n\ndeclare module 'json-schema' {\n interface JSONSchema7 {\n /**\n * @internal\n * Unique identifier for the schema\n */\n id?: string;\n\n /**\n * Lime elements specific options that can be specified in a schema\n */\n lime?: Omit<LimeSchemaOptions, 'layout'> & {\n layout?: Partial<LimeLayoutOptions>;\n };\n }\n}\n\n/**\n * @public\n */\nexport interface ValidationStatus {\n /**\n * True if the form is valid, false otherwise\n *\n * If the form is invalid, any errors can be found on the `errors` property\n */\n valid: boolean;\n\n /**\n * List of validation errors\n */\n errors?: FormError[];\n}\n\n/**\n * @public\n */\nexport interface FormError {\n /**\n * Name of the error\n */\n name: string;\n\n /**\n * Params of the error\n */\n params?: unknown;\n\n /**\n * Name of the invalid property\n */\n property: string;\n\n /**\n * Path to the property within the schema\n */\n schemaPath: string;\n\n /**\n * String describing the error\n */\n message: string;\n}\n\n/**\n * @public\n */\nexport type ValidationError = {\n /**\n * Name of the field the error belongs to\n */\n [key: string]: string[] | ValidationError;\n};\n\n/**\n * @public\n */\nexport interface FormComponent<T = any> {\n /**\n * The value of the current property\n */\n value: T;\n\n /**\n * Whether or not the current property is required\n */\n required?: boolean;\n\n /**\n * Whether or not the current property is readonly\n */\n readonly?: boolean;\n\n /**\n * Whether or not the current property is disabled\n */\n disabled?: boolean;\n\n /**\n * The label of the current property\n */\n label?: string;\n\n /**\n * The helper text for the current property\n */\n helperText?: string;\n\n /**\n * Additional contextual information about the form\n */\n formInfo?: FormInfo;\n\n /**\n * The event to emit when the value of the current property has changed\n */\n change: EventEmitter<T>;\n}\n\n/**\n * @public\n */\nexport interface FormInfo {\n /**\n * The schema of the current property\n */\n schema?: FormSchema;\n\n /**\n * The schema of the whole form\n */\n rootSchema?: FormSchema;\n\n /**\n * A tree of errors for this property and its children\n */\n errorSchema?: object;\n\n /**\n * The value of the whole form\n */\n rootValue?: any;\n\n /**\n * The name of the current property\n */\n name?: string;\n\n /**\n * Path to the property within the schema\n */\n schemaPath?: string[];\n}\n\n/**\n * Lime elements specific options that can be specified under the `lime` key in\n * a schema, e.g.\n *\n * ```ts\n * const schema = {\n * type: 'object',\n * lime: {\n * collapsible: true,\n * },\n * };\n * ```\n *\n * @public\n */\nexport interface LimeSchemaOptions {\n /**\n * When specified on an object it will render all sub components inside a\n * collapsible section\n */\n collapsible?: boolean;\n\n /**\n * When `collapsible` is `true`, set this to `false` to make the\n * collapsible section load in the open state.\n * Defaults to `true`.\n */\n collapsed?: boolean;\n\n /**\n * Will render the field using the specified component. The component\n * should implement the `FormComponent` interface\n */\n component?: FormComponentOptions;\n\n /**\n * When specified on an object it will render the sub components with the\n * specified layout\n */\n layout?: LimeLayoutOptions;\n\n /**\n * Mark the field as disabled\n */\n disabled?: boolean;\n\n help?: string | Partial<Help>;\n}\n\n/**\n * @public\n * Options for a layout to be used in a form\n */\nexport type LimeLayoutOptions = GridLayoutOptions & RowLayoutOptions;\n\n/**\n * Options for a component to be rendered inside a form\n *\n * @public\n */\nexport interface FormComponentOptions {\n /**\n * Name of the component\n */\n name?: string;\n\n /**\n * Extra properties to give the component in addition to the properties\n * specified on the `FormComponent` interface\n */\n props?: Record<string, any>;\n}\n\n/**\n * @public\n */\nexport interface FormLayoutOptions<\n T extends FormLayoutType | `${FormLayoutType}` = FormLayoutType.Default,\n> {\n /**\n * The type of layout to use\n */\n type: T;\n}\n\n/**\n * @public\n * Layout options for a grid layout\n */\nexport interface GridLayoutOptions\n extends FormLayoutOptions<FormLayoutType | `${FormLayoutType}`> {\n /**\n * When specified on a component within the grid, the component will take\n * up the the specified number of columns in the form\n */\n // eslint-disable-next-line no-magic-numbers\n colSpan?: 1 | 2 | 3 | 4 | 5 | 'all';\n\n /**\n * When specified on a component within the grid, the component will take\n * up the the specified number of rows in the form\n */\n rowSpan?: number;\n\n /**\n * Number of columns to use in the layout\n */\n // eslint-disable-next-line no-magic-numbers\n columns?: 1 | 2 | 3 | 4 | 5;\n\n /**\n * Attempts to fill in holes earlier in the grid, if smaller items come up\n * later. This may cause items to appear out-of-order, when doing so would\n * fill holes left by larger items. Defaults to `true`.\n */\n dense?: boolean;\n}\n\n/**\n * @public\n * Layout options for a row layout\n */\nexport interface RowLayoutOptions\n extends FormLayoutOptions<FormLayoutType | `${FormLayoutType}`> {\n /**\n * When specified on a field, the chosen icon will be displayed\n * on the left side of the row, beside the title.\n */\n icon?: string;\n}\n\n/**\n * @public\n * Represents the layout types for a form.\n */\nexport enum FormLayoutType {\n /**\n * The default layout\n */\n Default = 'default',\n\n /**\n * Render the form fields using a responsive grid layout\n */\n Grid = 'grid',\n\n /**\n * Render the form fields in full-width rows.\n * Each row can have a leading `icon`, and a field.\n * `title` and `description` provided by the schema will be placed\n * on the row itself, and not on the field.\n * This layout is good for creating UIs for user settings pages.\n */\n Row = 'row',\n}\n\n/**\n * @public\n * Represents the JSON schema with Lime specific options\n */\nexport interface FormSchema extends JSONSchema7 {}\n","/**\n * Defines the data for a table\n * @public\n */\nexport interface Column<T extends object = any> {\n /**\n * Column title to be displayed\n */\n title: string;\n\n /**\n * Name of the field in the data\n */\n field: keyof T;\n\n /**\n * Function to format the value before rendering\n */\n formatter?: TableFormatter;\n\n /**\n * Component used to render the field value\n */\n component?: TableComponentDefinition;\n\n /**\n * Type of aggregator to use for the column\n */\n aggregator?: ColumnAggregatorType | ColumnAggregatorFunction<T>;\n\n /**\n * A component used to render inside the column header\n */\n headerComponent?: TableComponentDefinition;\n\n /**\n * Sets the horizontal text alignment for the column\n */\n horizontalAlign?: 'left' | 'center' | 'right';\n\n /**\n * Defines whether end-user can sort a column\n */\n headerSort?: boolean;\n}\n\n/**\n * Definition for a formatter function\n * @param value - The value to be formatted\n * @param data - The data for the current row\n * @returns The formatted value\n * @public\n */\nexport type TableFormatter = (value: any, data?: object) => string;\n\n/**\n * The `component` key in the schema uses this interface to define a\n * component to be rendered inside a cell in the table.\n *\n * @note The table will display the component as `inline-block` in order\n * to give the column the correct size. If the component should have the\n * full width of the column, this might have to be overridden by setting\n * the display mode to `block`, e.g.\n *\n * ```css\n * :host(*) {\n * display: block !important;\n * }\n * ```\n * @public\n */\nexport interface TableComponentDefinition {\n /**\n * Name of the component\n */\n name: string;\n\n /**\n * Properties to send to the component\n */\n props?: Record<string, any>;\n\n /**\n * Factory for creating properties dynamically for a custom component.\n *\n * The properties returned from this function will be merged with the\n * `props` properties when the component is created.\n *\n * When the propsFactory is used for header components there will be no data available.\n *\n * @param data - The data for the current row\n * @returns Properties for the component\n */\n propsFactory?: (data: object) => Record<string, any>;\n}\n\n/**\n * Interface for custom components rendered inside a `limel-table`.\n * @public\n */\nexport interface TableComponent<T extends object = any> {\n /**\n * Name of the field being rendered\n */\n field?: string;\n\n /**\n * Value being rendered\n */\n value?: any;\n\n /**\n * Data for the current row of the table\n */\n data?: T;\n}\n\n/**\n * Indicates whether the specified column is sorted ascending or descending.\n * @public\n */\nexport interface ColumnSorter {\n /**\n * The column being sorted\n */\n column: Column;\n\n /**\n * The direction to sort on\n */\n direction: 'ASC' | 'DESC';\n}\n\n/**\n * Specifies the current page, and which columns the table is currently sorted on.\n * @public\n */\nexport interface TableParams {\n /**\n * The current page being set\n */\n page: number;\n\n /**\n * Sorters applied to the current page\n */\n sorters?: ColumnSorter[];\n}\n\n/**\n * The built-in aggregators available for columns\n * @public\n */\nexport enum ColumnAggregatorType {\n /**\n * Calculates the average value of all numerical cells in the column\n */\n Average = 'avg',\n\n /**\n * Displays the maximum value from all numerical cells in the column\n */\n Maximum = 'max',\n\n /**\n * Displays the minimum value from all numerical cells in the column\n */\n Minimum = 'min',\n\n /**\n * Displays the sum of all numerical cells in the column\n */\n Sum = 'sum',\n\n /**\n * Counts the number of non empty cells in the column\n */\n Count = 'count',\n}\n\n/**\n * Instead of using one of the built-in aggregators, it is possible to\n * define a custom aggregator function.\n *\n * @param column - the configuration for the column\n * @param values - list of all values to be aggregated\n * @param data - list of all objects to be aggregated\n * @returns the aggregated data\n *\n * @public\n */\nexport type ColumnAggregatorFunction<T = object> = (\n column?: Column,\n values?: any[],\n data?: T[],\n) => any;\n\n/**\n * Defines aggregate values for columns\n * @public\n */\nexport interface ColumnAggregate {\n /**\n * The name of the `Column` field\n */\n field: string;\n /**\n * The aggregate value\n */\n value: any;\n}\n"],"version":3}
|