@kubex/zinc 0.0.2 → 1.0.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/.editorconfig +18 -0
- package/.eslintignore +8 -0
- package/.eslintrc.cjs +208 -0
- package/.github/workflows/eleventy_build.yml +42 -0
- package/.github/workflows/js_build_and_deploy.yaml +62 -0
- package/custom-elements-manifest.config.js +230 -0
- package/custom-elements.json +24227 -0
- package/docs/_includes/component.njk +340 -0
- package/docs/_includes/default.njk +137 -0
- package/docs/_includes/sidebar.njk +24 -0
- package/docs/_utilities/active-links.cjs +41 -0
- package/docs/_utilities/anchor-headings.cjs +74 -0
- package/docs/_utilities/cem.cjs +89 -0
- package/docs/_utilities/code-previews.cjs +98 -0
- package/docs/_utilities/copy-code-buttons.cjs +26 -0
- package/docs/_utilities/external-links.cjs +53 -0
- package/docs/_utilities/highlight-code.cjs +74 -0
- package/docs/_utilities/markdown.cjs +74 -0
- package/docs/_utilities/prettier.cjs +26 -0
- package/docs/_utilities/replacer.cjs +24 -0
- package/docs/_utilities/scrolling-tables.cjs +23 -0
- package/docs/_utilities/strings.cjs +16 -0
- package/docs/_utilities/table-of-contents.cjs +48 -0
- package/docs/_utilities/typography.cjs +24 -0
- package/docs/assets/icons.json +57989 -0
- package/docs/assets/images/chrome.png +0 -0
- package/docs/assets/images/edge.png +0 -0
- package/docs/assets/images/firefox.png +0 -0
- package/docs/assets/images/opera.png +0 -0
- package/docs/assets/images/safari.png +0 -0
- package/docs/assets/images/watermark.svg +1 -0
- package/docs/assets/rip.js +78 -0
- package/docs/assets/scripts/code-previews.js +250 -0
- package/docs/assets/scripts/docs.js +374 -0
- package/docs/assets/scripts/search.js +441 -0
- package/docs/assets/scripts/turbo.js +29 -0
- package/docs/assets/styles/code-previews.css +169 -0
- package/docs/assets/styles/docs.css +1168 -0
- package/docs/assets/styles/search.css +347 -0
- package/docs/eleventy.config.cjs +262 -0
- package/docs/pages/components/absolute-container.md +35 -0
- package/docs/pages/components/action-bar.md +58 -0
- package/docs/pages/components/alert.md +45 -0
- package/docs/pages/components/bulk-actions.md +26 -0
- package/docs/pages/components/button-group.md +78 -0
- package/docs/pages/components/button-menu.md +127 -0
- package/docs/pages/components/button.md +80 -0
- package/docs/pages/components/chart.md +27 -0
- package/docs/pages/components/checkbox-group.md +196 -0
- package/docs/pages/components/checkbox.md +157 -0
- package/docs/pages/components/chip.md +61 -0
- package/docs/pages/components/collapsible.md +52 -0
- package/docs/pages/components/cols.md +66 -0
- package/docs/pages/components/confirm.md +52 -0
- package/docs/pages/components/content-block.md +108 -0
- package/docs/pages/components/copy-button.md +22 -0
- package/docs/pages/components/data-select.md +54 -0
- package/docs/pages/components/data-table-filter.md +23 -0
- package/docs/pages/components/data-table-sort.md +20 -0
- package/docs/pages/components/data-table.md +74 -0
- package/docs/pages/components/datepicker.md +25 -0
- package/docs/pages/components/defined-label.md +26 -0
- package/docs/pages/components/dialog.md +145 -0
- package/docs/pages/components/dropdown.md +22 -0
- package/docs/pages/components/editor.md +26 -0
- package/docs/pages/components/empty-state.md +51 -0
- package/docs/pages/components/expanding-action.md +55 -0
- package/docs/pages/components/file.md +45 -0
- package/docs/pages/components/form-group.md +22 -0
- package/docs/pages/components/header.md +103 -0
- package/docs/pages/components/icon.md +322 -0
- package/docs/pages/components/inline-edit.md +41 -0
- package/docs/pages/components/input.md +261 -0
- package/docs/pages/components/item.md +78 -0
- package/docs/pages/components/linked-select.md +41 -0
- package/docs/pages/components/menu-item.md +22 -0
- package/docs/pages/components/menu.md +36 -0
- package/docs/pages/components/navbar.md +57 -0
- package/docs/pages/components/note.md +55 -0
- package/docs/pages/components/option.md +22 -0
- package/docs/pages/components/order-table.md +22 -0
- package/docs/pages/components/page-nav.md +23 -0
- package/docs/pages/components/pagination.md +22 -0
- package/docs/pages/components/pane.md +22 -0
- package/docs/pages/components/panel.md +124 -0
- package/docs/pages/components/popup.md +22 -0
- package/docs/pages/components/progress-bar.md +22 -0
- package/docs/pages/components/progress-tile.md +22 -0
- package/docs/pages/components/query-builder.md +148 -0
- package/docs/pages/components/radio-group.md +129 -0
- package/docs/pages/components/radio.md +20 -0
- package/docs/pages/components/rating.md +28 -0
- package/docs/pages/components/scroll-container.md +22 -0
- package/docs/pages/components/select.md +452 -0
- package/docs/pages/components/sidebar.md +28 -0
- package/docs/pages/components/simple-chart.md +23 -0
- package/docs/pages/components/skeleton.md +70 -0
- package/docs/pages/components/slideout.md +23 -0
- package/docs/pages/components/sp.md +87 -0
- package/docs/pages/components/split-button.md +32 -0
- package/docs/pages/components/split-pane.md +22 -0
- package/docs/pages/components/stat.md +24 -0
- package/docs/pages/components/status-indicator.md +13 -0
- package/docs/pages/components/stepper.md +20 -0
- package/docs/pages/components/style.md +106 -0
- package/docs/pages/components/table.md +22 -0
- package/docs/pages/components/tabs.md +57 -0
- package/docs/pages/components/textarea.md +120 -0
- package/docs/pages/components/tile-property.md +29 -0
- package/docs/pages/components/tile.md +51 -0
- package/docs/pages/components/timer.md +22 -0
- package/docs/pages/components/toggle.md +22 -0
- package/docs/pages/components/tooltip.md +242 -0
- package/docs/pages/components/vertical-stepper.md +22 -0
- package/docs/pages/components/well.md +13 -0
- package/docs/pages/getting-started/example-layout.md +143 -0
- package/docs/pages/getting-started/example-page.md +83 -0
- package/docs/pages/getting-started/form-controls.md +552 -0
- package/docs/pages/getting-started/form-examples.md +122 -0
- package/docs/pages/getting-started/table-examples.md +43 -0
- package/docs/pages/index.md +32 -0
- package/index.html +22 -0
- package/package.json +111 -11
- package/scripts/build.js +381 -0
- package/scripts/generator/generator.js +102 -0
- package/scripts/generator/index.js +17 -0
- package/scripts/generator/preprocess.js +20 -0
- package/scripts/generator/resolver.js +86 -0
- package/scripts/generator/tailwind.config.js +14 -0
- package/scripts/make-metadata.js +10 -0
- package/scripts/make-themes.js +27 -0
- package/scripts/plop/plopfile.js +63 -0
- package/scripts/plop/templates/component.hbs +43 -0
- package/scripts/plop/templates/define.hbs +12 -0
- package/scripts/plop/templates/docs.hbs +20 -0
- package/scripts/plop/templates/style.hbs +5 -0
- package/scripts/plop/templates/test.hbs +10 -0
- package/scss/_global-components.scss +4 -0
- package/scss/_global-spacing.scss +96 -0
- package/scss/_root.scss +202 -0
- package/scss/boot.scss +29 -0
- package/scss/mixins/_helper-mixins.scss +24 -0
- package/scss/mixins/_spacing-mixins.scss +84 -0
- package/scss/mixins/index.scss +2 -0
- package/scss/shared/_base.scss +138 -0
- package/scss/shared/_button.scss +27 -0
- package/scss/shared/_form-elements.scss +162 -0
- package/scss/shared/_opacity.scss +27 -0
- package/scss/shared/_reset.scss +288 -0
- package/scss/shared/_table.scss +73 -0
- package/scss/shared/divide.scss +41 -0
- package/scss/shared/index.scss +12 -0
- package/scss/shared/layout.scss +290 -0
- package/scss/shared/nav.scss +71 -0
- package/scss/themes/_dark.scss +277 -0
- package/scss/themes/_index.scss +3 -0
- package/scss/themes/_light.scss +540 -0
- package/scss/themes/_utility.scss +44 -0
- package/scss/variables/_spacing.scss +35 -0
- package/scss/variables/index.scss +1 -0
- package/src/components/absolute-container/absolute-container.component.ts +62 -0
- package/src/components/absolute-container/absolute-container.test.ts +10 -0
- package/src/components/absolute-container/index.ts +12 -0
- package/src/components/action-bar/action-bar.component.ts +41 -0
- package/src/components/action-bar/action-bar.scss +33 -0
- package/src/components/action-bar/action-bar.test.ts +10 -0
- package/src/components/action-bar/index.ts +12 -0
- package/src/components/alert/alert.component.ts +71 -0
- package/src/components/alert/alert.scss +170 -0
- package/src/components/alert/alert.test.ts +10 -0
- package/src/components/alert/index.ts +12 -0
- package/src/components/bulk-actions/bulk-actions.component.ts +229 -0
- package/src/components/bulk-actions/bulk-actions.scss +56 -0
- package/src/components/bulk-actions/bulk-actions.test.ts +10 -0
- package/src/components/bulk-actions/index.ts +12 -0
- package/src/components/button/button.component.ts +242 -0
- package/src/components/button/button.scss +346 -0
- package/src/components/button/button.test.ts +32 -0
- package/src/components/button/index.ts +12 -0
- package/src/components/button-group/button-group.component.ts +74 -0
- package/src/components/button-group/button-group.scss +39 -0
- package/src/components/button-group/button-group.test.ts +10 -0
- package/src/components/button-group/index.ts +12 -0
- package/src/components/button-menu/button-menu.component.ts +353 -0
- package/src/components/button-menu/button-menu.scss +41 -0
- package/src/components/button-menu/button-menu.test.ts +10 -0
- package/src/components/button-menu/index.ts +12 -0
- package/src/components/chart/chart.component.ts +206 -0
- package/src/components/chart/chart.scss +11 -0
- package/src/components/chart/chart.test.ts +10 -0
- package/src/components/chart/index.ts +12 -0
- package/src/components/checkbox/checkbox.component.ts +326 -0
- package/src/components/checkbox/checkbox.scss +202 -0
- package/src/components/checkbox/checkbox.test.ts +10 -0
- package/src/components/checkbox/index.ts +12 -0
- package/src/components/checkbox-group/checkbox-group.component.ts +351 -0
- package/src/components/checkbox-group/checkbox-group.scss +60 -0
- package/src/components/checkbox-group/checkbox-group.test.ts +10 -0
- package/src/components/checkbox-group/index.ts +12 -0
- package/src/components/chip/chip.component.ts +70 -0
- package/src/components/chip/chip.scss +101 -0
- package/src/components/chip/chip.test.ts +10 -0
- package/src/components/chip/index.ts +12 -0
- package/src/components/collapsible/collapsible.component.ts +86 -0
- package/src/components/collapsible/collapsible.scss +100 -0
- package/src/components/collapsible/collapsible.test.ts +10 -0
- package/src/components/collapsible/index.ts +12 -0
- package/src/components/cols/cols.component.ts +76 -0
- package/src/components/cols/cols.scss +99 -0
- package/src/components/cols/cols.test.ts +10 -0
- package/src/components/cols/index.ts +12 -0
- package/src/components/confirm/confirm.component.ts +181 -0
- package/src/components/confirm/confirm.scss +44 -0
- package/src/components/confirm/confirm.test.ts +10 -0
- package/src/components/confirm/index.ts +12 -0
- package/src/components/content-block/content-block.component.ts +225 -0
- package/src/components/content-block/content-block.scss +64 -0
- package/src/components/content-block/content-block.test.ts +10 -0
- package/src/components/content-block/index.ts +12 -0
- package/src/components/copy-button/copy-button.component.ts +163 -0
- package/src/components/copy-button/copy-button.scss +47 -0
- package/src/components/copy-button/copy-button.test.ts +10 -0
- package/src/components/copy-button/index.ts +12 -0
- package/src/components/data-select/data-select.component.ts +219 -0
- package/src/components/data-select/data-select.scss +43 -0
- package/src/components/data-select/data-select.test.ts +10 -0
- package/src/components/data-select/index.ts +12 -0
- package/src/components/data-select/providers/color-data-provider.ts +16 -0
- package/src/components/data-select/providers/country-code-data-provider.ts +517 -0
- package/src/components/data-select/providers/country-data-provider.ts +527 -0
- package/src/components/data-select/providers/currency-data-provider.ts +328 -0
- package/src/components/data-select/providers/provider.ts +32 -0
- package/src/components/data-table/data-table.component.ts +1093 -0
- package/src/components/data-table/data-table.scss +330 -0
- package/src/components/data-table/data-table.test.ts +10 -0
- package/src/components/data-table/index.ts +12 -0
- package/src/components/data-table-filter/data-table-filter.component.ts +126 -0
- package/src/components/data-table-filter/data-table-filter.scss +22 -0
- package/src/components/data-table-filter/data-table-filter.test.ts +10 -0
- package/src/components/data-table-filter/index.ts +12 -0
- package/src/components/data-table-sort/data-table-sort.component.ts +56 -0
- package/src/components/data-table-sort/data-table-sort.scss +37 -0
- package/src/components/data-table-sort/data-table-sort.test.ts +10 -0
- package/src/components/data-table-sort/index.ts +12 -0
- package/src/components/datepicker/datepicker.component.ts +315 -0
- package/src/components/datepicker/datepicker.scss +237 -0
- package/src/components/datepicker/datepicker.test.ts +10 -0
- package/src/components/datepicker/index.ts +12 -0
- package/src/components/defined-label/defined-label.component.ts +241 -0
- package/src/components/defined-label/defined-label.scss +43 -0
- package/src/components/defined-label/defined-label.test.ts +10 -0
- package/src/components/defined-label/index.ts +12 -0
- package/src/components/dialog/dialog.component.ts +237 -0
- package/src/components/dialog/dialog.scss +197 -0
- package/src/components/dialog/dialog.test.ts +10 -0
- package/src/components/dialog/index.ts +12 -0
- package/src/components/dropdown/dropdown.component.ts +380 -0
- package/src/components/dropdown/dropdown.scss +9 -0
- package/src/components/dropdown/dropdown.test.ts +10 -0
- package/src/components/dropdown/index.ts +12 -0
- package/src/components/editor/editor.component.ts +423 -0
- package/src/components/editor/editor.scss +131 -0
- package/src/components/editor/editor.test.ts +10 -0
- package/src/components/editor/index.ts +12 -0
- package/src/components/editor/modules/attachment-module.ts +195 -0
- package/src/components/editor/modules/dialog-module/dialog-module.component.ts +289 -0
- package/src/components/editor/modules/dialog-module/dialog-module.scss +115 -0
- package/src/components/editor/modules/dialog-module/dialog-module.ts +99 -0
- package/src/components/editor/modules/drag-drop-module.ts +125 -0
- package/src/components/editor/modules/events/zn-command-select.ts +7 -0
- package/src/components/editor/modules/events/zn-editor-update.ts +7 -0
- package/src/components/editor/modules/events/zn-show-canned-response-dialog.ts +15 -0
- package/src/components/editor/modules/image-resize-module/image-resize-module.ts +157 -0
- package/src/components/editor/modules/menu-module/menu-module.component.ts +149 -0
- package/src/components/editor/modules/menu-module/menu-module.scss +17 -0
- package/src/components/editor/modules/menu-module/menu-module.ts +203 -0
- package/src/components/editor/modules/time-tracking-module.ts +35 -0
- package/src/components/empty-state/empty-state.component.ts +63 -0
- package/src/components/empty-state/empty-state.scss +91 -0
- package/src/components/empty-state/empty-state.test.ts +10 -0
- package/src/components/empty-state/index.ts +12 -0
- package/src/components/expanding-action/expanding-action.component.ts +312 -0
- package/src/components/expanding-action/expanding-action.scss +87 -0
- package/src/components/expanding-action/expanding-action.test.ts +10 -0
- package/src/components/expanding-action/index.ts +12 -0
- package/src/components/file/file.component.ts +619 -0
- package/src/components/file/file.scss +200 -0
- package/src/components/file/file.test.ts +10 -0
- package/src/components/file/index.ts +12 -0
- package/src/components/form-group/form-group.component.ts +93 -0
- package/src/components/form-group/form-group.scss +84 -0
- package/src/components/form-group/form-group.test.ts +10 -0
- package/src/components/form-group/index.ts +12 -0
- package/src/components/header/header.component.ts +186 -0
- package/src/components/header/header.scss +244 -0
- package/src/components/header/header.test.ts +10 -0
- package/src/components/header/index.ts +12 -0
- package/src/components/hover-container/hover-container.component.ts +214 -0
- package/src/components/hover-container/hover-container.scss +59 -0
- package/src/components/hover-container/hover-container.ts +10 -0
- package/src/components/hover-container/index.ts +12 -0
- package/src/components/icon/icon.component.ts +251 -0
- package/src/components/icon/icon.scss +186 -0
- package/src/components/icon/icon.test.ts +10 -0
- package/src/components/icon/index.ts +13 -0
- package/src/components/icon/lni.scss +2492 -0
- package/src/components/inline-edit/index.ts +12 -0
- package/src/components/inline-edit/inline-edit.component.ts +289 -0
- package/src/components/inline-edit/inline-edit.scss +139 -0
- package/src/components/inline-edit/inline-edit.test.ts +10 -0
- package/src/components/input/index.ts +12 -0
- package/src/components/input/input.component.ts +614 -0
- package/src/components/input/input.scss +355 -0
- package/src/components/input/input.test.ts +10 -0
- package/src/components/item/index.ts +12 -0
- package/src/components/item/item.component.ts +102 -0
- package/src/components/item/item.scss +161 -0
- package/src/components/item/item.test.ts +10 -0
- package/src/components/linked-select/index.ts +12 -0
- package/src/components/linked-select/linked-select.component.ts +156 -0
- package/src/components/linked-select/linked-select.scss +9 -0
- package/src/components/linked-select/linked-select.test.ts +17 -0
- package/src/components/menu/index.ts +12 -0
- package/src/components/menu/menu.component.ts +243 -0
- package/src/components/menu/menu.scss +14 -0
- package/src/components/menu/menu.test.ts +10 -0
- package/src/components/menu-item/index.ts +12 -0
- package/src/components/menu-item/menu-item.component.ts +220 -0
- package/src/components/menu-item/menu-item.scss +157 -0
- package/src/components/menu-item/menu-item.test.ts +10 -0
- package/src/components/menu-item/submenu-controller.ts +291 -0
- package/src/components/navbar/index.ts +12 -0
- package/src/components/navbar/navbar.component.ts +240 -0
- package/src/components/navbar/navbar.scss +411 -0
- package/src/components/navbar/navbar.test.ts +10 -0
- package/src/components/note/index.ts +12 -0
- package/src/components/note/note.component.ts +60 -0
- package/src/components/note/note.scss +69 -0
- package/src/components/note/note.test.ts +10 -0
- package/src/components/option/index.ts +12 -0
- package/src/components/option/option.component.ts +152 -0
- package/src/components/option/option.scss +88 -0
- package/src/components/option/option.test.ts +10 -0
- package/src/components/order-table/index.ts +12 -0
- package/src/components/order-table/order-table.component.ts +323 -0
- package/src/components/order-table/order-table.scss +154 -0
- package/src/components/order-table/order-table.test.ts +10 -0
- package/src/components/page-nav/index.ts +12 -0
- package/src/components/page-nav/page-nav.component.ts +117 -0
- package/src/components/page-nav/page-nav.scss +155 -0
- package/src/components/page-nav/page-nav.test.ts +10 -0
- package/src/components/pagination/index.ts +12 -0
- package/src/components/pagination/pagination.component.ts +91 -0
- package/src/components/pagination/pagination.scss +76 -0
- package/src/components/pagination/pagination.test.ts +10 -0
- package/src/components/pane/index.ts +12 -0
- package/src/components/pane/pane.component.ts +52 -0
- package/src/components/pane/pane.scss +45 -0
- package/src/components/pane/pane.test.ts +10 -0
- package/src/components/panel/index.ts +12 -0
- package/src/components/panel/panel.component.ts +100 -0
- package/src/components/panel/panel.scss +129 -0
- package/src/components/panel/panel.test.ts +10 -0
- package/src/components/popup/index.ts +12 -0
- package/src/components/popup/popup.component.ts +543 -0
- package/src/components/popup/popup.scss +59 -0
- package/src/components/popup/popup.test.ts +10 -0
- package/src/components/progress-bar/index.ts +12 -0
- package/src/components/progress-bar/progress-bar.component.ts +80 -0
- package/src/components/progress-bar/progress-bar.scss +46 -0
- package/src/components/progress-bar/progress-bar.test.ts +10 -0
- package/src/components/progress-tile/index.ts +12 -0
- package/src/components/progress-tile/progress-tile.component.ts +127 -0
- package/src/components/progress-tile/progress-tile.scss +116 -0
- package/src/components/progress-tile/progress-tile.test.ts +10 -0
- package/src/components/query-builder/index.ts +12 -0
- package/src/components/query-builder/query-builder.component.ts +544 -0
- package/src/components/query-builder/query-builder.scss +53 -0
- package/src/components/query-builder/query-builder.test.ts +10 -0
- package/src/components/radio/index.ts +12 -0
- package/src/components/radio/radio.component.ts +305 -0
- package/src/components/radio/radio.scss +197 -0
- package/src/components/radio/radio.test.ts +10 -0
- package/src/components/radio-group/index.ts +12 -0
- package/src/components/radio-group/radio-group.component.ts +362 -0
- package/src/components/radio-group/radio-group.scss +60 -0
- package/src/components/radio-group/radio-group.test.ts +10 -0
- package/src/components/rating/index.ts +12 -0
- package/src/components/rating/rating.component.ts +235 -0
- package/src/components/rating/rating.scss +82 -0
- package/src/components/rating/rating.test.ts +10 -0
- package/src/components/scroll-container/index.ts +12 -0
- package/src/components/scroll-container/scroll-container.component.ts +41 -0
- package/src/components/scroll-container/scroll-container.scss +17 -0
- package/src/components/scroll-container/scroll-container.test.ts +10 -0
- package/src/components/select/index.ts +12 -0
- package/src/components/select/select.component.ts +984 -0
- package/src/components/select/select.scss +325 -0
- package/src/components/select/select.test.ts +10 -0
- package/src/components/sidebar/index.ts +12 -0
- package/src/components/sidebar/sidebar.component.ts +98 -0
- package/src/components/sidebar/sidebar.scss +294 -0
- package/src/components/sidebar/sidebar.test.ts +10 -0
- package/src/components/simple-chart/index.ts +12 -0
- package/src/components/simple-chart/simple-chart.component.ts +204 -0
- package/src/components/simple-chart/simple-chart.scss +9 -0
- package/src/components/simple-chart/simple-chart.test.ts +10 -0
- package/src/components/skeleton/index.ts +12 -0
- package/src/components/skeleton/skeleton.component.ts +34 -0
- package/src/components/skeleton/skeleton.scss +39 -0
- package/src/components/skeleton/skeleton.test.ts +10 -0
- package/src/components/slideout/index.ts +12 -0
- package/src/components/slideout/slideout.component.ts +223 -0
- package/src/components/slideout/slideout.scss +96 -0
- package/src/components/slideout/slideout.test.ts +10 -0
- package/src/components/sp/index.ts +12 -0
- package/src/components/sp/sp.component.ts +86 -0
- package/src/components/sp/sp.scss +88 -0
- package/src/components/sp/sp.test.ts +10 -0
- package/src/components/split-button/index.ts +12 -0
- package/src/components/split-button/split-button.component.ts +154 -0
- package/src/components/split-button/split-button.scss +9 -0
- package/src/components/split-button/split-button.test.ts +10 -0
- package/src/components/split-pane/index.ts +12 -0
- package/src/components/split-pane/split-pane.component.ts +195 -0
- package/src/components/split-pane/split-pane.scss +303 -0
- package/src/components/split-pane/split-pane.test.ts +10 -0
- package/src/components/stat/index.ts +12 -0
- package/src/components/stat/stat.component.ts +117 -0
- package/src/components/stat/stat.scss +92 -0
- package/src/components/stat/stat.test.ts +10 -0
- package/src/components/status-indicator/index.ts +12 -0
- package/src/components/status-indicator/status-indicator.component.ts +31 -0
- package/src/components/status-indicator/status-indicator.scss +32 -0
- package/src/components/status-indicator/status-indicator.test.ts +10 -0
- package/src/components/stepper/index.ts +12 -0
- package/src/components/stepper/stepper.component.ts +80 -0
- package/src/components/stepper/stepper.scss +88 -0
- package/src/components/stepper/stepper.test.ts +10 -0
- package/src/components/style/index.ts +12 -0
- package/src/components/style/style.component.ts +150 -0
- package/src/components/style/style.scss +1 -0
- package/src/components/style/style.test.ts +10 -0
- package/src/components/table/index.ts +12 -0
- package/src/components/table/table.component.ts +297 -0
- package/src/components/table/table.scss +209 -0
- package/src/components/table/table.test.ts +10 -0
- package/src/components/tabs/index.ts +12 -0
- package/src/components/tabs/tabs.component.ts +496 -0
- package/src/components/tabs/tabs.scss +147 -0
- package/src/components/tabs/tabs.test.ts +10 -0
- package/src/components/textarea/index.ts +12 -0
- package/src/components/textarea/textarea.component.ts +417 -0
- package/src/components/textarea/textarea.scss +152 -0
- package/src/components/textarea/textarea.test.ts +10 -0
- package/src/components/tile/index.ts +12 -0
- package/src/components/tile/tile.component.ts +105 -0
- package/src/components/tile/tile.scss +144 -0
- package/src/components/tile/tile.test.ts +10 -0
- package/src/components/tile-property/index.ts +12 -0
- package/src/components/tile-property/tile-property.component.ts +43 -0
- package/src/components/tile-property/tile-property.scss +43 -0
- package/src/components/tile-property/tile-property.test.ts +10 -0
- package/src/components/timer/index.ts +12 -0
- package/src/components/timer/timer.component.ts +88 -0
- package/src/components/timer/timer.scss +40 -0
- package/src/components/timer/timer.test.ts +10 -0
- package/src/components/toggle/index.ts +12 -0
- package/src/components/toggle/toggle.component.ts +203 -0
- package/src/components/toggle/toggle.scss +93 -0
- package/src/components/toggle/toggle.test.ts +10 -0
- package/src/components/tooltip/index.ts +12 -0
- package/src/components/tooltip/tooltip.component.ts +215 -0
- package/src/components/tooltip/tooltip.scss +43 -0
- package/src/components/tooltip/tooltip.test.ts +10 -0
- package/src/components/vertical-stepper/index.ts +12 -0
- package/src/components/vertical-stepper/vertical-stepper.component.ts +53 -0
- package/src/components/vertical-stepper/vertical-stepper.scss +84 -0
- package/src/components/vertical-stepper/vertical-stepper.test.ts +10 -0
- package/src/components/well/index.ts +12 -0
- package/src/components/well/well.component.ts +43 -0
- package/src/components/well/well.scss +19 -0
- package/src/components/well/well.test.ts +10 -0
- package/src/declaration.d.ts +39 -0
- package/src/events/events.ts +7 -0
- package/src/events/zn-after-collapse.ts +7 -0
- package/src/events/zn-after-expand.ts +7 -0
- package/src/events/zn-after-hide.ts +7 -0
- package/src/events/zn-after-show.ts +7 -0
- package/src/events/zn-blur.ts +7 -0
- package/src/events/zn-cancel.ts +7 -0
- package/src/events/zn-change.ts +7 -0
- package/src/events/zn-clear.ts +7 -0
- package/src/events/zn-close.ts +7 -0
- package/src/events/zn-collapse.ts +7 -0
- package/src/events/zn-copy.ts +7 -0
- package/src/events/zn-element-added.ts +7 -0
- package/src/events/zn-error.ts +7 -0
- package/src/events/zn-expand.ts +7 -0
- package/src/events/zn-filter-change.ts +7 -0
- package/src/events/zn-finish.ts +7 -0
- package/src/events/zn-focus.ts +7 -0
- package/src/events/zn-hide.ts +7 -0
- package/src/events/zn-hover.ts +10 -0
- package/src/events/zn-initial-focus.ts +7 -0
- package/src/events/zn-input.ts +7 -0
- package/src/events/zn-invalid.ts +7 -0
- package/src/events/zn-load.ts +7 -0
- package/src/events/zn-menu-ready.ts +9 -0
- package/src/events/zn-menu-select.ts +9 -0
- package/src/events/zn-open.ts +7 -0
- package/src/events/zn-remove.ts +7 -0
- package/src/events/zn-request-close.ts +7 -0
- package/src/events/zn-select.ts +9 -0
- package/src/events/zn-show.ts +7 -0
- package/src/events/zn-sort-change.ts +7 -0
- package/src/events/zn-submit.ts +7 -0
- package/src/form-control.scss +123 -0
- package/src/internal/animate.ts +64 -0
- package/src/internal/default-value.ts +49 -0
- package/src/internal/event.ts +75 -0
- package/src/internal/form.ts +527 -0
- package/src/internal/offset.ts +13 -0
- package/src/internal/scroll.ts +69 -0
- package/src/internal/slot.ts +110 -0
- package/src/internal/storage.ts +70 -0
- package/src/internal/tabbable.ts +198 -0
- package/src/internal/theme.ts +54 -0
- package/src/internal/watch.ts +63 -0
- package/src/internal/zinc-element.ts +113 -0
- package/src/translations/en.ts +30 -0
- package/src/utilities/animation-registry.ts +74 -0
- package/src/utilities/base-path.ts +46 -0
- package/src/utilities/lit-to-html.ts +7 -0
- package/src/utilities/localize.ts +37 -0
- package/src/utilities/md5.ts +216 -0
- package/src/utilities/on.ts +29 -0
- package/src/utilities/query.ts +36 -0
- package/src/wc.scss +33 -0
- package/src/zinc-autoloader.ts +58 -0
- package/src/zinc.ts +83 -0
- package/tsconfig.json +41 -0
- package/tsconfig.prod.json +12 -0
- package/vscode.html-custom-data.json +2804 -0
- package/web-test-runner.config.js +50 -0
- package/web-types.json +6420 -0
- package/zn.d.ts +6318 -0
- package/zn.min.css +1 -0
- package/zn.min.js +3701 -0
- package/.idea/.name +0 -1
- package/.idea/fusion.iml +0 -9
- package/.idea/modules.xml +0 -8
- package/.idea/php.xml +0 -4
- package/.idea/vcs.xml +0 -6
- package/.idea/watcherTasks.xml +0 -25
- package/components/Blank/demo/demo.html +0 -11
- package/components/Blank/dist/zn-blank.js +0 -39
- package/components/Blank/go/component.go +0 -18
- package/components/Blank/go/go.mod +0 -3
- package/components/Blank/package.json +0 -33
- package/components/Blank/php/composer.json +0 -25
- package/components/Blank/php/src/Blank.php +0 -15
- package/components/Blank/rollup.config.js +0 -32
- package/components/Blank/scss/Styles.scss +0 -6
- package/components/Blank/ts/Component.ts +0 -15
- package/components/Blank/tsconfig.json +0 -7
- package/components/Icon/demo/demo.html +0 -90
- package/components/Icon/dist/zn-icon.js +0 -55
- package/components/Icon/go/component.go +0 -56
- package/components/Icon/go/go.mod +0 -3
- package/components/Icon/package.json +0 -33
- package/components/Icon/php/composer.json +0 -26
- package/components/Icon/php/src/Icon.php +0 -38
- package/components/Icon/php/src/Library.php +0 -17
- package/components/Icon/php/src/Size.php +0 -42
- package/components/Icon/roadmap.md +0 -7
- package/components/Icon/rollup.config.js +0 -32
- package/components/Icon/scss/Styles.scss +0 -65
- package/components/Icon/ts/Component.ts +0 -108
- package/components/Icon/ts/md5.ts +0 -215
- package/components/Icon/tsconfig.json +0 -7
- package/components/MaxWidth/demo/demo.html +0 -11
- package/components/MaxWidth/dist/zn-max-width.js +0 -51
- package/components/MaxWidth/go/component.go +0 -24
- package/components/MaxWidth/go/go.mod +0 -3
- package/components/MaxWidth/package.json +0 -33
- package/components/MaxWidth/php/composer.json +0 -25
- package/components/MaxWidth/php/src/MaxWidth.php +0 -32
- package/components/MaxWidth/rollup.config.js +0 -32
- package/components/MaxWidth/scss/Styles.scss +0 -13
- package/components/MaxWidth/ts/Component.ts +0 -27
- package/components/MaxWidth/tsconfig.json +0 -7
- package/components/roadmap.md +0 -4
- package/layout/components/Columns/demo/demo.html +0 -16
- package/layout/components/Columns/ts/Component.ts +0 -59
- package/layout/demo/index.html +0 -24
- package/layout/dist/zn-layout.js +0 -87
- package/layout/package.json +0 -38
- package/layout/rollup.config.js +0 -38
- package/layout/scss/layout.scss +0 -24
- package/layout/tailwind.config.js +0 -42
- package/layout/ts/import.ts +0 -2
- package/layout/tsconfig.json +0 -7
- /package/{layout/components/Columns/scss/Styles.scss → src/internal/zinc-element.test.ts} +0 -0
|
@@ -0,0 +1,1093 @@
|
|
|
1
|
+
import {classMap} from "lit/directives/class-map.js";
|
|
2
|
+
import {type CSSResultGroup, html, nothing, type TemplateResult, unsafeCSS} from 'lit';
|
|
3
|
+
import {HasSlotController} from "../../internal/slot";
|
|
4
|
+
import {ifDefined} from "lit/directives/if-defined.js";
|
|
5
|
+
import {property} from 'lit/decorators.js';
|
|
6
|
+
import {ref} from "lit/directives/ref.js";
|
|
7
|
+
import {Task} from "@lit/task";
|
|
8
|
+
import {unsafeHTML} from "lit/directives/unsafe-html.js";
|
|
9
|
+
import {type ZnFilterChangeEvent} from "../../events/zn-filter-change";
|
|
10
|
+
import ZincElement from '../../internal/zinc-element';
|
|
11
|
+
import ZnButton from "../button";
|
|
12
|
+
import ZnButtonGroup from "../button-group";
|
|
13
|
+
import ZnChip from "../chip";
|
|
14
|
+
import ZnConfirm from "../confirm";
|
|
15
|
+
import ZnDataTableFilter from "../data-table-filter";
|
|
16
|
+
import ZnDropdown from "../dropdown";
|
|
17
|
+
import ZnEmptyState from "../empty-state";
|
|
18
|
+
import ZnHoverContainer from "../hover-container";
|
|
19
|
+
import ZnMenu from "../menu";
|
|
20
|
+
import ZnMenuItem from "../menu-item";
|
|
21
|
+
import ZnSkeleton from "../skeleton";
|
|
22
|
+
import type ZnSelect from "../select";
|
|
23
|
+
|
|
24
|
+
import styles from './data-table.scss';
|
|
25
|
+
|
|
26
|
+
const DEFAULT_PAGE = 1;
|
|
27
|
+
const DEFAULT_PER_PAGE = 10;
|
|
28
|
+
const DEFAULT_TOTAL_PAGES = 10;
|
|
29
|
+
|
|
30
|
+
interface TableData {
|
|
31
|
+
page: number;
|
|
32
|
+
per_page: number;
|
|
33
|
+
total: number;
|
|
34
|
+
total_pages: number;
|
|
35
|
+
data: any[];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export enum ActionSlots {
|
|
39
|
+
delete = 'delete-action',
|
|
40
|
+
modify = 'modify-action',
|
|
41
|
+
create = 'create-action',
|
|
42
|
+
filter = 'filter',
|
|
43
|
+
sort = 'sort',
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface RowData {
|
|
47
|
+
[key: string]: string | number | object | undefined;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
interface RenderDataValue {
|
|
51
|
+
value: string | number;
|
|
52
|
+
type: string;
|
|
53
|
+
tag: string;
|
|
54
|
+
url: string;
|
|
55
|
+
target: string;
|
|
56
|
+
gaid?: string;
|
|
57
|
+
html?: string;
|
|
58
|
+
color?: string;
|
|
59
|
+
caption: CaptionConfig;
|
|
60
|
+
buttons: ButtonConfig[];
|
|
61
|
+
menu: MenuConfig[];
|
|
62
|
+
icon: IconConfig;
|
|
63
|
+
hover: HoverContainerConfig;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
interface CaptionConfig {
|
|
67
|
+
title: string;
|
|
68
|
+
summary: string;
|
|
69
|
+
uri: string;
|
|
70
|
+
target: string;
|
|
71
|
+
gaid: string;
|
|
72
|
+
icon: IconConfig;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
interface IconConfig {
|
|
76
|
+
src: string;
|
|
77
|
+
size: number;
|
|
78
|
+
color: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
interface HoverContainerConfig {
|
|
82
|
+
label: string;
|
|
83
|
+
content: string;
|
|
84
|
+
anchor: string;
|
|
85
|
+
placement:
|
|
86
|
+
| 'top'
|
|
87
|
+
| 'top-start'
|
|
88
|
+
| 'top-end'
|
|
89
|
+
| 'bottom'
|
|
90
|
+
| 'bottom-start'
|
|
91
|
+
| 'bottom-end'
|
|
92
|
+
| 'right'
|
|
93
|
+
| 'right-start'
|
|
94
|
+
| 'right-end'
|
|
95
|
+
| 'left'
|
|
96
|
+
| 'left-start'
|
|
97
|
+
| 'left-end';
|
|
98
|
+
icon: IconConfig;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
interface ButtonConfig {
|
|
102
|
+
id: string;
|
|
103
|
+
href: string;
|
|
104
|
+
gaid: string;
|
|
105
|
+
uri: string;
|
|
106
|
+
size: string;
|
|
107
|
+
color: string;
|
|
108
|
+
icon: string;
|
|
109
|
+
iconSize: string;
|
|
110
|
+
tooltip: string;
|
|
111
|
+
target: string;
|
|
112
|
+
label: string;
|
|
113
|
+
outline: boolean;
|
|
114
|
+
confirm: ConfirmConfig;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
interface MenuConfig {
|
|
118
|
+
id: string;
|
|
119
|
+
href: string;
|
|
120
|
+
gaid: string;
|
|
121
|
+
target: string;
|
|
122
|
+
label: string;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
interface ConfirmConfig {
|
|
126
|
+
type: string;
|
|
127
|
+
trigger: string;
|
|
128
|
+
fid: string;
|
|
129
|
+
caption: string;
|
|
130
|
+
content: string;
|
|
131
|
+
action: string;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
interface HeaderConfig {
|
|
135
|
+
title: string;
|
|
136
|
+
position: string;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* @summary Short summary of the component's intended use.
|
|
141
|
+
* @documentation https://zinc.style/components/data-table
|
|
142
|
+
* @status experimental
|
|
143
|
+
* @since 1.0
|
|
144
|
+
*
|
|
145
|
+
* @dependency zn-button
|
|
146
|
+
* @dependency zn-empty-state
|
|
147
|
+
* @dependency zn-chip
|
|
148
|
+
* @dependency zn-hover-container
|
|
149
|
+
* @dependency zn-dropdown
|
|
150
|
+
* @dependency zn-menu
|
|
151
|
+
* @dependency zn-menu-item
|
|
152
|
+
* @dependency zn-button-group
|
|
153
|
+
* @dependency zn-confirm
|
|
154
|
+
* @dependency zn-skeleton
|
|
155
|
+
*
|
|
156
|
+
* @event zn-event-name - Emitted as an example.
|
|
157
|
+
*
|
|
158
|
+
* @slot - The default slot.
|
|
159
|
+
* @slot example - An example slot.
|
|
160
|
+
*
|
|
161
|
+
* @csspart base - The component's base wrapper.
|
|
162
|
+
*
|
|
163
|
+
* @cssproperty --example - An example CSS custom property.
|
|
164
|
+
*/
|
|
165
|
+
export default class ZnDataTable extends ZincElement {
|
|
166
|
+
static styles: CSSResultGroup = unsafeCSS(styles);
|
|
167
|
+
static dependencies = {
|
|
168
|
+
'zn-button': ZnButton,
|
|
169
|
+
'zn-empty-state': ZnEmptyState,
|
|
170
|
+
'zn-chip': ZnChip,
|
|
171
|
+
'zn-hover-container': ZnHoverContainer,
|
|
172
|
+
'zn-dropdown': ZnDropdown,
|
|
173
|
+
'zn-menu': ZnMenu,
|
|
174
|
+
'zn-menu-item': ZnMenuItem,
|
|
175
|
+
'zn-button-group': ZnButtonGroup,
|
|
176
|
+
'zn-confirm': ZnConfirm,
|
|
177
|
+
'zn-skeleton': ZnSkeleton,
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
@property({attribute: 'data-uri'}) dataUri: string;
|
|
181
|
+
@property({attribute: 'data', type: Object, reflect: true}) data: any;
|
|
182
|
+
@property({attribute: 'sort-column'}) sortColumn: string;
|
|
183
|
+
@property({attribute: 'sort-direction'}) sortDirection: string;
|
|
184
|
+
@property({attribute: 'filter'}) filter: string = '';
|
|
185
|
+
|
|
186
|
+
@property({attribute: 'wide-column'}) wideColumn: string;
|
|
187
|
+
@property({attribute: 'key'}) key: string = 'id';
|
|
188
|
+
|
|
189
|
+
@property({attribute: 'headers', type: Object})
|
|
190
|
+
headers: Record<string, string | HeaderConfig> = {};
|
|
191
|
+
|
|
192
|
+
// Hide header text keeping the content - e.g. Action buttons without a header
|
|
193
|
+
@property({attribute: 'hide-headers', type: Object}) hiddenHeaders = '{}';
|
|
194
|
+
|
|
195
|
+
// Hide entire columns of data - e.g IDs
|
|
196
|
+
@property({attribute: 'hide-columns', type: Object}) hiddenColumns = '{}';
|
|
197
|
+
|
|
198
|
+
// Specify individual unsortable headers
|
|
199
|
+
@property({attribute: 'unsortable-headers', type: Object}) unsortableHeaders = '{}';
|
|
200
|
+
|
|
201
|
+
// Make table unsortable
|
|
202
|
+
@property({attribute: 'unsortable', type: Boolean}) unsortable: boolean = false;
|
|
203
|
+
|
|
204
|
+
// Hide pagination
|
|
205
|
+
@property({attribute: 'hide-pagination', type: Boolean}) hidePagination: boolean;
|
|
206
|
+
|
|
207
|
+
@property({type: Boolean}) standalone: boolean = false;
|
|
208
|
+
|
|
209
|
+
@property() caption: string;
|
|
210
|
+
|
|
211
|
+
// Hide the checkbox column
|
|
212
|
+
@property({attribute: 'hide-checkboxes', type: Boolean}) hideCheckboxes: boolean;
|
|
213
|
+
@property() filters: [] = [];
|
|
214
|
+
|
|
215
|
+
// Data Table Properties
|
|
216
|
+
private _initialLoad = true;
|
|
217
|
+
private _lastTableContent: TemplateResult = html``;
|
|
218
|
+
|
|
219
|
+
private resizeObserver: ResizeObserver;
|
|
220
|
+
|
|
221
|
+
private itemsPerPage: number = DEFAULT_PER_PAGE;
|
|
222
|
+
private page: number = DEFAULT_PAGE;
|
|
223
|
+
private totalPages: number;
|
|
224
|
+
|
|
225
|
+
private _rows: any[] = [];
|
|
226
|
+
private _filteredRows: any[] = [];
|
|
227
|
+
|
|
228
|
+
private numberOfRowsSelected: number = 0;
|
|
229
|
+
private selectedRows: any[] = [];
|
|
230
|
+
private tableContainer: Element | undefined;
|
|
231
|
+
|
|
232
|
+
private hasSlotController = new HasSlotController(
|
|
233
|
+
this,
|
|
234
|
+
'[default]',
|
|
235
|
+
'search-action',
|
|
236
|
+
ActionSlots.delete.valueOf(),
|
|
237
|
+
ActionSlots.modify.valueOf(),
|
|
238
|
+
ActionSlots.create.valueOf(),
|
|
239
|
+
ActionSlots.filter.valueOf(),
|
|
240
|
+
ActionSlots.sort.valueOf()
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
private _dataTask = new Task(this, {
|
|
244
|
+
task: async ([dataUri], {signal}) => {
|
|
245
|
+
let url = dataUri;
|
|
246
|
+
|
|
247
|
+
const params = new URLSearchParams();
|
|
248
|
+
params.append('page', this.page.toString());
|
|
249
|
+
params.append('per_page', this.itemsPerPage.toString());
|
|
250
|
+
if (this.sortColumn) {
|
|
251
|
+
params.append('sort_column', this.sortColumn);
|
|
252
|
+
}
|
|
253
|
+
if (this.sortDirection) {
|
|
254
|
+
params.append('sort_direction', this.sortDirection);
|
|
255
|
+
}
|
|
256
|
+
if (this.filter) {
|
|
257
|
+
params.append('filter', this.filter);
|
|
258
|
+
}
|
|
259
|
+
url += '?' + params.toString();
|
|
260
|
+
|
|
261
|
+
if (!this.dataUri) {
|
|
262
|
+
return new Promise<TableData>((resolve) => {
|
|
263
|
+
if (!this.data) throw new Error('No data provided, please provide data or dataUri');
|
|
264
|
+
let localData = Array.isArray(this.data?.data) ? this.data.data as RowData[] : [];
|
|
265
|
+
|
|
266
|
+
if (this.sortColumn) {
|
|
267
|
+
localData = localData.sort((a, b) => {
|
|
268
|
+
const aValue = a?.[this.sortColumn];
|
|
269
|
+
const bValue = b?.[this.sortColumn];
|
|
270
|
+
return this.sortData(aValue, bValue);
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
275
|
+
const totalPages = Math.ceil(localData.length / (this.data.per_page as number ?? this.itemsPerPage));
|
|
276
|
+
const start = (this.page - 1) * this.itemsPerPage;
|
|
277
|
+
const end = start + this.itemsPerPage;
|
|
278
|
+
const paginatedData = localData.slice(start, end);
|
|
279
|
+
|
|
280
|
+
resolve({
|
|
281
|
+
page: this.page,
|
|
282
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
283
|
+
per_page: this.data.per_page as number ?? this.itemsPerPage,
|
|
284
|
+
total: localData.length,
|
|
285
|
+
total_pages: totalPages,
|
|
286
|
+
data: paginatedData,
|
|
287
|
+
} satisfies TableData);
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// This is also used for Rubix, so it may not work for your application.
|
|
292
|
+
const response = await fetch(url, {
|
|
293
|
+
signal,
|
|
294
|
+
credentials: 'same-origin',
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
if (!response.ok) throw new Error(response.statusText);
|
|
298
|
+
return response.json();
|
|
299
|
+
},
|
|
300
|
+
args: () => [this.dataUri]
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
render() {
|
|
304
|
+
const tableBody = this._dataTask.render({
|
|
305
|
+
pending: () => {
|
|
306
|
+
if (this._initialLoad) {
|
|
307
|
+
return html`
|
|
308
|
+
<div>${this.loadingTable()}</div>`;
|
|
309
|
+
}
|
|
310
|
+
return html`
|
|
311
|
+
<div class="reduced-opacity">${this._lastTableContent}</div>`;
|
|
312
|
+
},
|
|
313
|
+
complete: (data) => {
|
|
314
|
+
this._initialLoad = false;
|
|
315
|
+
this._lastTableContent = html`
|
|
316
|
+
<div>${this.renderTable(data as TableData)}</div>`;
|
|
317
|
+
return this._lastTableContent;
|
|
318
|
+
},
|
|
319
|
+
error: (error) => html`
|
|
320
|
+
<div>${error}</div>`
|
|
321
|
+
}) as TemplateResult;
|
|
322
|
+
|
|
323
|
+
const hasActions = this.hasSlotController.test(ActionSlots.delete.valueOf())
|
|
324
|
+
|| this.hasSlotController.test(ActionSlots.modify.valueOf())
|
|
325
|
+
|| this.hasSlotController.test(ActionSlots.create.valueOf())
|
|
326
|
+
|| this.hasSlotController.test(ActionSlots.sort.valueOf())
|
|
327
|
+
|| this.hasSlotController.test(ActionSlots.filter.valueOf());
|
|
328
|
+
|
|
329
|
+
// Headers do not need to be re-rendered with new data
|
|
330
|
+
return html`
|
|
331
|
+
<div class="table-container" ${ref((el) => (this.tableContainer = el))}>
|
|
332
|
+
${hasActions ? this.getTableHeader() : html``}
|
|
333
|
+
${tableBody}
|
|
334
|
+
</div>
|
|
335
|
+
`;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
connectedCallback() {
|
|
339
|
+
super.connectedCallback();
|
|
340
|
+
|
|
341
|
+
this.resizeObserver = new ResizeObserver(() => {
|
|
342
|
+
if (this.tableContainer) {
|
|
343
|
+
this.tableContainer.scrollIntoView({behavior: 'smooth', block: 'nearest'});
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
this.addEventListener('zn-filter-change', this.changeEventListener);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
disconnectedCallback() {
|
|
351
|
+
super.disconnectedCallback();
|
|
352
|
+
if (this.resizeObserver) {
|
|
353
|
+
this.resizeObserver.disconnect();
|
|
354
|
+
}
|
|
355
|
+
this.removeEventListener('zn-filter-change', this.changeEventListener);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
changeEventListener = (e: ZnFilterChangeEvent) => {
|
|
359
|
+
if (e.target instanceof ZnDataTableFilter) {
|
|
360
|
+
this.filter = (e.target as ZnDataTableFilter).value as string;
|
|
361
|
+
this._dataTask.run().then(r => r);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
renderTable(data: TableData) {
|
|
366
|
+
this.itemsPerPage = data.per_page ?? DEFAULT_PER_PAGE;
|
|
367
|
+
this.page = data.page ?? DEFAULT_PAGE;
|
|
368
|
+
this.totalPages = data.total_pages ?? DEFAULT_TOTAL_PAGES;
|
|
369
|
+
|
|
370
|
+
if (!data?.data || data.data.length === 0) {
|
|
371
|
+
return html`
|
|
372
|
+
<div class="table--empty">
|
|
373
|
+
<zn-empty-state
|
|
374
|
+
caption="${this.caption ? "No " + this.caption.toLowerCase() + " found" : "No data found"}"
|
|
375
|
+
icon="data_alert">
|
|
376
|
+
</zn-empty-state>
|
|
377
|
+
</div>`;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
const keys = Object.entries(this.headers).map(([key, _]) => key);
|
|
381
|
+
const filteredKeys = keys.filter((key) => !Object.values(this.hiddenColumns).includes(key));
|
|
382
|
+
|
|
383
|
+
this._filteredRows = this.getRows(filteredKeys, data);
|
|
384
|
+
this._rows = this.getRows(keys, data);
|
|
385
|
+
|
|
386
|
+
const hasSelectedRows = this.selectedRows.length > 0;
|
|
387
|
+
|
|
388
|
+
return html`
|
|
389
|
+
<div style="overflow-x: auto">
|
|
390
|
+
<table class="${classMap({
|
|
391
|
+
'table': true,
|
|
392
|
+
'table--standalone': this.standalone,
|
|
393
|
+
'with-hover': !this.unsortable,
|
|
394
|
+
'table-with--checkboxes': !this.hideCheckboxes,
|
|
395
|
+
})}">
|
|
396
|
+
<thead>
|
|
397
|
+
<tr>
|
|
398
|
+
${this.hideCheckboxes || !hasSelectedRows ? html`` : html`
|
|
399
|
+
<th>
|
|
400
|
+
<div><input type="checkbox" @change="${this.selectAll}"></div>
|
|
401
|
+
</th>`}
|
|
402
|
+
${filteredKeys.map((key: any) => this.renderCellHeader(key))}
|
|
403
|
+
</tr>
|
|
404
|
+
</thead>
|
|
405
|
+
<tbody>
|
|
406
|
+
${this._filteredRows.map((row: any) => html`
|
|
407
|
+
<tr>
|
|
408
|
+
${this.hideCheckboxes ? html`` : html`
|
|
409
|
+
<td class="${classMap({'hidden': !hasSelectedRows})}">
|
|
410
|
+
<div><input type="checkbox" @change="${this.selectRow}"></div>
|
|
411
|
+
</td>`}
|
|
412
|
+
${row.map((value: RenderDataValue, index: number) => this.renderCellBody(index, value))}
|
|
413
|
+
</tr>`)}
|
|
414
|
+
</tbody>
|
|
415
|
+
</table>
|
|
416
|
+
</div>
|
|
417
|
+
|
|
418
|
+
${this.getTableFooter()}
|
|
419
|
+
`;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
getTableHeader() {
|
|
423
|
+
return html`
|
|
424
|
+
<div class="table__header">
|
|
425
|
+
<div class="table__header__actions">
|
|
426
|
+
${this.getActions()}
|
|
427
|
+
</div>
|
|
428
|
+
<div class="table__header__right">
|
|
429
|
+
<slot name="${ActionSlots.sort.valueOf()}"></slot>
|
|
430
|
+
<slot name="${ActionSlots.filter.valueOf()}"></slot>
|
|
431
|
+
</div>
|
|
432
|
+
</div>
|
|
433
|
+
`;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
getTableFooter() {
|
|
437
|
+
const rowSelected = this.getRowsSelected();
|
|
438
|
+
const pagination = this.getPagination();
|
|
439
|
+
|
|
440
|
+
if (rowSelected !== null || pagination !== null) {
|
|
441
|
+
return html`
|
|
442
|
+
<div class="table__footer">
|
|
443
|
+
<div class="table__footer__left">
|
|
444
|
+
${rowSelected}
|
|
445
|
+
</div>
|
|
446
|
+
<div class="table__footer__right">
|
|
447
|
+
${pagination}
|
|
448
|
+
</div>
|
|
449
|
+
</div>`;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
return html``;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
getRowsSelected() {
|
|
456
|
+
if (this.hideCheckboxes || this.selectedRows.length <= 0) return null;
|
|
457
|
+
|
|
458
|
+
return html`
|
|
459
|
+
<p>${this.numberOfRowsSelected} of ${this._rows.length} rows selected</p>`
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
getPagination() {
|
|
463
|
+
if (this.hidePagination || (this.totalPages <= 1 && this._rows.length <= 10)) return null;
|
|
464
|
+
|
|
465
|
+
const optionsRowsPerPage = [10, 20, 30, 40, 50];
|
|
466
|
+
optionsRowsPerPage.filter((option) => option <= this._rows.length);
|
|
467
|
+
|
|
468
|
+
return html`
|
|
469
|
+
<div class="table__footer__rows-per-page">
|
|
470
|
+
<p>Rows per page</p>
|
|
471
|
+
<zn-select name="rowPerPage"
|
|
472
|
+
size="small"
|
|
473
|
+
value="${this.itemsPerPage}"
|
|
474
|
+
@zn-change="${this.updateRowsPerPage}">
|
|
475
|
+
${optionsRowsPerPage.map((option) => html`
|
|
476
|
+
<zn-option value="${option}"
|
|
477
|
+
selected="${option === this.itemsPerPage || nothing}">${option}
|
|
478
|
+
</zn-option>`
|
|
479
|
+
)}
|
|
480
|
+
</zn-select>
|
|
481
|
+
</div>
|
|
482
|
+
|
|
483
|
+
${this.totalPages <= 1
|
|
484
|
+
? html``
|
|
485
|
+
: html`
|
|
486
|
+
<div class="table__footer__pagination-count">
|
|
487
|
+
<p>Page ${this.page} of ${this.totalPages}</p>
|
|
488
|
+
</div>
|
|
489
|
+
|
|
490
|
+
<div class="table__footer__pagination-buttons">
|
|
491
|
+
<zn-button @click="${this.page !== 1 ? this.goToFirstPage : undefined}"
|
|
492
|
+
?disabled="${this.page === 1}"
|
|
493
|
+
icon-size="16"
|
|
494
|
+
size="small"
|
|
495
|
+
icon="keyboard_double_arrow_left"
|
|
496
|
+
outline>
|
|
497
|
+
</zn-button>
|
|
498
|
+
<zn-button @click="${this.page !== 1 ? this.goToPreviousPage : undefined}"
|
|
499
|
+
?disabled="${this.page === 1}"
|
|
500
|
+
icon-size="16"
|
|
501
|
+
size="small"
|
|
502
|
+
icon="chevron_left"
|
|
503
|
+
outline>
|
|
504
|
+
</zn-button>
|
|
505
|
+
<zn-button @click="${this.page !== this.totalPages ? this.goToNextPage : undefined}"
|
|
506
|
+
?disabled="${this.page === this.totalPages}"
|
|
507
|
+
icon-size="16"
|
|
508
|
+
size="small"
|
|
509
|
+
icon="chevron_right"
|
|
510
|
+
outline>
|
|
511
|
+
</zn-button>
|
|
512
|
+
<zn-button @click="${this.page !== this.totalPages ? this.goToLastPage : undefined}"
|
|
513
|
+
?disabled="${this.page === this.totalPages}"
|
|
514
|
+
icon-size="16"
|
|
515
|
+
size="small"
|
|
516
|
+
icon="keyboard_double_arrow_right"
|
|
517
|
+
outline>
|
|
518
|
+
</zn-button>
|
|
519
|
+
</div>`}`;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
getActions() {
|
|
523
|
+
const actions = [];
|
|
524
|
+
|
|
525
|
+
if (this.selectedRows.length > 0) {
|
|
526
|
+
actions.push(html`
|
|
527
|
+
<zn-button @click="${this.clearSelectedRows}" size="small" outline>
|
|
528
|
+
Clear Selection
|
|
529
|
+
</zn-button>`);
|
|
530
|
+
|
|
531
|
+
if (this.hasSlotController.test(ActionSlots.delete.valueOf())) {
|
|
532
|
+
actions.push(html`
|
|
533
|
+
<slot name="${ActionSlots.delete.valueOf()}"></slot>`);
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
if (this.hasSlotController.test(ActionSlots.modify.valueOf())) {
|
|
537
|
+
actions.push(html`
|
|
538
|
+
<slot name="${ActionSlots.modify.valueOf()}"></slot>`);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
if (this.hasSlotController.test(ActionSlots.create.valueOf())) {
|
|
543
|
+
actions.push(html`
|
|
544
|
+
<slot name="${ActionSlots.create.valueOf()}"></slot>`);
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
return actions;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
goToPage(page: number) {
|
|
551
|
+
this.page = page;
|
|
552
|
+
this.selectedRows = [];
|
|
553
|
+
this.numberOfRowsSelected = 0;
|
|
554
|
+
this._dataTask.run().then(r => r);
|
|
555
|
+
|
|
556
|
+
if (this.resizeObserver) {
|
|
557
|
+
this.resizeObserver.observe(this);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
goToFirstPage() {
|
|
562
|
+
this.goToPage(1);
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
goToPreviousPage() {
|
|
566
|
+
this.goToPage(Math.max(this.page - 1, 1));
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
goToNextPage() {
|
|
570
|
+
this.goToPage(Math.min(this.page + 1, this.totalPages));
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
goToLastPage() {
|
|
574
|
+
this.goToPage(this.totalPages);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
updateRowsPerPage(event: Event) {
|
|
578
|
+
const select = event.target as ZnSelect;
|
|
579
|
+
this.itemsPerPage = parseInt(select.value as string);
|
|
580
|
+
this.page = 1; // reset the page to 1 when changing the number of rows per page
|
|
581
|
+
this.requestUpdate();
|
|
582
|
+
this._dataTask.run().then(r => r);
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
selectAll(event: Event) {
|
|
586
|
+
const checkbox = event.target as HTMLInputElement;
|
|
587
|
+
const checked = checkbox.checked;
|
|
588
|
+
|
|
589
|
+
// go through all the checkboxes and check them
|
|
590
|
+
for (const row of this.renderRoot.querySelectorAll('tbody input[type="checkbox"]')) {
|
|
591
|
+
(row as HTMLInputElement).checked = checked;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
this.selectedRows = checked ? this._rows : [];
|
|
595
|
+
this.numberOfRowsSelected = this.selectedRows.length;
|
|
596
|
+
this.updateKeys();
|
|
597
|
+
this.requestUpdate();
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
|
|
601
|
+
private updateActionKeys(slotName: string) {
|
|
602
|
+
if (this.hasSlotController.test(slotName)) {
|
|
603
|
+
// we need to look into the slot controller for the keys input
|
|
604
|
+
const slots = this.hasSlotController.getSlots(slotName);
|
|
605
|
+
if (slots) {
|
|
606
|
+
slots.forEach((slot) => {
|
|
607
|
+
const input = slot.querySelector('input[name="keys"]');
|
|
608
|
+
if (input && input instanceof HTMLInputElement) {
|
|
609
|
+
input.value = this.getSelectedKeys().join(',');
|
|
610
|
+
}
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
selectRow(e: PointerEvent) {
|
|
617
|
+
if (!(e.target && (e.target instanceof Element))) {
|
|
618
|
+
return;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
let target: HTMLElement = e.target as HTMLElement;
|
|
622
|
+
// if is a button or a link continue
|
|
623
|
+
if (target.tagName === 'ZN-BUTTON' || target.tagName === 'A' || target.tagName === 'BUTTON') {
|
|
624
|
+
return
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
// traverse parent until we reach a tr
|
|
628
|
+
while (target && target.tagName !== 'TR') {
|
|
629
|
+
target = target.parentElement as HTMLElement;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
if (target === null) {
|
|
633
|
+
return;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
const checkbox = target.querySelector('input[type="checkbox"]') as HTMLInputElement;
|
|
637
|
+
if (checkbox) {
|
|
638
|
+
checkbox.checked = !checkbox.checked;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
this.selectedRows = this._rows.filter((_, index) => {
|
|
642
|
+
return (this.renderRoot.querySelectorAll('tbody input[type="checkbox"]')[index] as HTMLInputElement)?.checked;
|
|
643
|
+
});
|
|
644
|
+
|
|
645
|
+
this.numberOfRowsSelected = this.selectedRows.length;
|
|
646
|
+
this.updateKeys();
|
|
647
|
+
this.requestUpdate();
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
clearSelectedRows(event: Event) {
|
|
651
|
+
const button = event.target as ZnButton;
|
|
652
|
+
if (button.disabled) return;
|
|
653
|
+
|
|
654
|
+
(this.renderRoot.querySelectorAll('thead input[type="checkbox"]')[0] as HTMLInputElement).checked = false;
|
|
655
|
+
for (const row of this.renderRoot.querySelectorAll('tbody input[type="checkbox"]')) {
|
|
656
|
+
(row as HTMLInputElement).checked = false;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
this.selectedRows = [];
|
|
660
|
+
this.numberOfRowsSelected = 0;
|
|
661
|
+
this.requestUpdate();
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
updateSort(key: string) {
|
|
665
|
+
// Rerun the render task with the extra params
|
|
666
|
+
return () => {
|
|
667
|
+
this.sortColumn = key;
|
|
668
|
+
this.sortDirection = this.sortDirection === 'asc' ? 'desc' : 'asc';
|
|
669
|
+
this._dataTask.run().then(r => r);
|
|
670
|
+
};
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
renderData(data: RenderDataValue) {
|
|
674
|
+
if (data && typeof data === 'object') {
|
|
675
|
+
let content: TemplateResult = html`${data['value']}`;
|
|
676
|
+
|
|
677
|
+
if (data['html']) {
|
|
678
|
+
return html`${unsafeHTML(data['html'])}`;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
if (data['type'] === 'timestamp') {
|
|
682
|
+
const timestamp = typeof data['value'] === 'string' ? parseInt(data['value']) : data['value'];
|
|
683
|
+
content = html`${new Intl.DateTimeFormat('en-GB', {
|
|
684
|
+
dateStyle: 'medium',
|
|
685
|
+
timeStyle: 'short',
|
|
686
|
+
hourCycle: 'h12',
|
|
687
|
+
timeZone: 'UTC'
|
|
688
|
+
}).format(new Date(timestamp < 10000000000 ? timestamp * 1000 : timestamp))}`;
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
if (data['tag'] === 'zn-chip') {
|
|
692
|
+
const type = data['type'];
|
|
693
|
+
content = html`
|
|
694
|
+
<zn-chip type="${type}">${content}</zn-chip>`;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
if (data['tag'] === 'code') {
|
|
698
|
+
content = html`
|
|
699
|
+
<code>${content}</code>`;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
if (data['url']) {
|
|
703
|
+
content = html`
|
|
704
|
+
<a href="${data['url']}"
|
|
705
|
+
data-target="${ifDefined(data['target'])}"
|
|
706
|
+
gaid="${ifDefined(data['gaid'])}">${content}</a>`;
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
if (data['caption']) {
|
|
710
|
+
let title = html`<span class="title">${data['caption'].title}</span>`;
|
|
711
|
+
let captionIcon = html``;
|
|
712
|
+
|
|
713
|
+
if (data['caption'].icon) {
|
|
714
|
+
const icon = data['caption'].icon;
|
|
715
|
+
const src = icon['src'] ?? icon;
|
|
716
|
+
const size = icon['size'] ?? 16;
|
|
717
|
+
const color = icon['color'] ?? '';
|
|
718
|
+
|
|
719
|
+
captionIcon = html`
|
|
720
|
+
<zn-icon src="${src}" size="${size}" color="${color}"></zn-icon>`;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
if (data['caption'].uri) {
|
|
724
|
+
title = html` <a data-target="${ifDefined(data['caption'].target || nothing)}"
|
|
725
|
+
href="${data['caption'].uri}"
|
|
726
|
+
gaid="${ifDefined(data['caption'].gaid)}"
|
|
727
|
+
class="title">
|
|
728
|
+
${data['caption'].title}
|
|
729
|
+
</a>`
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
content = html`
|
|
733
|
+
<div class="${classMap({
|
|
734
|
+
'caption': true,
|
|
735
|
+
'caption--icon': data['caption'].icon !== undefined,
|
|
736
|
+
})}">
|
|
737
|
+
${captionIcon}
|
|
738
|
+
<div>
|
|
739
|
+
${title}
|
|
740
|
+
<span class="summary">${data['caption'].summary}</span>
|
|
741
|
+
</div>
|
|
742
|
+
</div>`;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
if (data['hover']) {
|
|
746
|
+
const placement = data['hover'].placement ?? 'top';
|
|
747
|
+
|
|
748
|
+
if (data['hover'].icon) {
|
|
749
|
+
const icon = data['hover'].icon;
|
|
750
|
+
const src = icon['src'] ?? icon;
|
|
751
|
+
const size = icon['size'] ?? 16;
|
|
752
|
+
const color = icon['color'] ?? '';
|
|
753
|
+
|
|
754
|
+
return html`
|
|
755
|
+
${data['hover'].label}
|
|
756
|
+
<zn-hover-container placement="${placement}"
|
|
757
|
+
flip>
|
|
758
|
+
<zn-icon src="${src}" size="${size}" color="${color}"></zn-icon>
|
|
759
|
+
<div slot="content">
|
|
760
|
+
${unsafeHTML(data['hover'].content)}
|
|
761
|
+
</div>
|
|
762
|
+
</zn-hover-container>`;
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
return html`
|
|
766
|
+
${data['hover'].label}
|
|
767
|
+
<zn-hover-container placement="${placement}"
|
|
768
|
+
flip>
|
|
769
|
+
<div slot="anchor">${data['hover'].anchor}</div>
|
|
770
|
+
${unsafeHTML(data['hover'].content)}
|
|
771
|
+
</zn-hover-container>`;
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
if (data['menu']) {
|
|
775
|
+
return html`
|
|
776
|
+
<zn-dropdown>
|
|
777
|
+
<zn-button slot="trigger" icon="more_horiz" icon-size="24" color="transparent" size="content"></zn-button>
|
|
778
|
+
<zn-menu>
|
|
779
|
+
${data['menu'].map((item: MenuConfig) => {
|
|
780
|
+
return html`
|
|
781
|
+
<zn-menu-item id="${item.id}"
|
|
782
|
+
href="${item.href}"
|
|
783
|
+
gaid="${item.gaid}"
|
|
784
|
+
data-target="${ifDefined(item.target)}">
|
|
785
|
+
${item.label}
|
|
786
|
+
</zn-menu-item>`;
|
|
787
|
+
})}
|
|
788
|
+
</zn-menu>
|
|
789
|
+
</zn-dropdown>`
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
if (data['buttons']) {
|
|
793
|
+
content = html`
|
|
794
|
+
${Object.values(data['buttons']).map((button) => {
|
|
795
|
+
if (button.confirm) {
|
|
796
|
+
return html`
|
|
797
|
+
<div>
|
|
798
|
+
<zn-button
|
|
799
|
+
id="${button.id}"
|
|
800
|
+
size="${button.size}"
|
|
801
|
+
color="${button.color}"
|
|
802
|
+
icon="${button.icon}"
|
|
803
|
+
icon-size="${button.iconSize}"
|
|
804
|
+
tooltip="${button.tooltip}"
|
|
805
|
+
outline="${ifDefined(button.outline)}">
|
|
806
|
+
${button.label || nothing}
|
|
807
|
+
</zn-button>
|
|
808
|
+
<zn-confirm
|
|
809
|
+
fid="${button.confirm.fid}"
|
|
810
|
+
trigger="${button.confirm.trigger}"
|
|
811
|
+
type="${button.confirm.type}"
|
|
812
|
+
caption="${button.confirm.caption}"
|
|
813
|
+
content="${button.confirm.content}"
|
|
814
|
+
action="${button.confirm.action}"></zn-confirm>
|
|
815
|
+
</div>`;
|
|
816
|
+
}
|
|
817
|
+
return html`
|
|
818
|
+
<zn-button
|
|
819
|
+
id="${button.id}"
|
|
820
|
+
href="${button.href}"
|
|
821
|
+
gaid="${button.gaid}"
|
|
822
|
+
size="${button.size}"
|
|
823
|
+
color="${button.color}"
|
|
824
|
+
icon="${button.icon}"
|
|
825
|
+
icon-size="${button.iconSize}"
|
|
826
|
+
tooltip="${button.tooltip}"
|
|
827
|
+
data-uri="${button.uri}"
|
|
828
|
+
data-target="${['modal', 'slide'].includes(button.target) ? button.target : nothing}"
|
|
829
|
+
target="${!['modal', 'slide'].includes(button.target) ? button.target : nothing}"
|
|
830
|
+
outline="${ifDefined(button.outline)}">
|
|
831
|
+
${button.label || nothing}
|
|
832
|
+
</zn-button>`;
|
|
833
|
+
})}`;
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
if (data['icon']) {
|
|
837
|
+
const icon = data['icon']?.['src'] ?? data['icon'];
|
|
838
|
+
const size = data['icon']?.['size'] ?? 16;
|
|
839
|
+
const color = data['icon']?.['color'] ?? '';
|
|
840
|
+
|
|
841
|
+
content = html`
|
|
842
|
+
<zn-icon src="${icon}" size="${size}" color="${color}"></zn-icon> ${content}`;
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
if (data['color']) {
|
|
846
|
+
content = html`
|
|
847
|
+
<zn-style color="${data['color']}">${content}</zn-style>`;
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
return content;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
return data;
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
private getTableSortIcon(key: any) {
|
|
857
|
+
if (this.sortColumn !== key) {
|
|
858
|
+
return html`
|
|
859
|
+
<div class="table__head__sort">
|
|
860
|
+
<zn-icon src="unfold_more" size="14"></zn-icon>
|
|
861
|
+
</div>`;
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
if (this.sortDirection === 'asc') {
|
|
865
|
+
return html`
|
|
866
|
+
<div class="table__head__sort table__head__sort--active">
|
|
867
|
+
<zn-icon src="arrow_downward_alt" size="16"></zn-icon>
|
|
868
|
+
</div>`;
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
return html`
|
|
872
|
+
<div class="table__head__sort table__head__sort--active">
|
|
873
|
+
<zn-icon src="arrow_upward_alt" size="16"></zn-icon>
|
|
874
|
+
</div>`;
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
private renderCellHeader(key: string) {
|
|
878
|
+
const sortable = !Object.values(this.unsortableHeaders).includes(key) && !Object.values(this.hiddenHeaders).includes(key) && !this.unsortable;
|
|
879
|
+
let headerKeys = Object.keys(this.headers);
|
|
880
|
+
headerKeys = headerKeys.filter((k) => !Object.values(this.hiddenColumns).includes(k));
|
|
881
|
+
const header: string | HeaderConfig = this.headers[key];
|
|
882
|
+
|
|
883
|
+
if (this.hasHeaderPosition(header)) {
|
|
884
|
+
return html`
|
|
885
|
+
<th
|
|
886
|
+
class="${classMap({
|
|
887
|
+
'table__head': true,
|
|
888
|
+
'table__head--wide': key === this.wideColumn,
|
|
889
|
+
'table__head--last': key === headerKeys[headerKeys.length - 1],
|
|
890
|
+
'table__head--hidden': Object.values(this.hiddenHeaders).includes(key),
|
|
891
|
+
[`table__head--${header.position}`]: true
|
|
892
|
+
})}"
|
|
893
|
+
@click="${sortable ? this.updateSort(key) : undefined}">
|
|
894
|
+
<div>
|
|
895
|
+
${header.title}
|
|
896
|
+
${sortable ? this.getTableSortIcon(key) : nothing}
|
|
897
|
+
</div>
|
|
898
|
+
</th>
|
|
899
|
+
`;
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
return html`
|
|
903
|
+
<th
|
|
904
|
+
class="${classMap({
|
|
905
|
+
'table__head': true,
|
|
906
|
+
'table__head--wide': key === this.wideColumn,
|
|
907
|
+
'table__head--last': key === headerKeys[headerKeys.length - 1],
|
|
908
|
+
'table__head--hidden': Object.values(this.hiddenHeaders).includes(key),
|
|
909
|
+
})}"
|
|
910
|
+
@click="${sortable ? this.updateSort(key) : undefined}">
|
|
911
|
+
<div>
|
|
912
|
+
${header}
|
|
913
|
+
${sortable ? this.getTableSortIcon(key) : nothing}
|
|
914
|
+
</div>
|
|
915
|
+
</th>
|
|
916
|
+
`;
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
private renderCellBody(index: number, value: RenderDataValue) {
|
|
920
|
+
const headerKeys: string[] = Object.keys(this.headers).filter(
|
|
921
|
+
(key) => !Object.values(this.hiddenColumns).includes(key)
|
|
922
|
+
);
|
|
923
|
+
const headerKey: string = headerKeys[index];
|
|
924
|
+
const header = this.headers[headerKey];
|
|
925
|
+
|
|
926
|
+
if (this.hasHeaderPosition(header)) {
|
|
927
|
+
return html`
|
|
928
|
+
<td
|
|
929
|
+
@click="${this.selectRow}"
|
|
930
|
+
class="${classMap({
|
|
931
|
+
'table__cell': true,
|
|
932
|
+
'table__cell--wide': headerKey === this.wideColumn,
|
|
933
|
+
'table__cell--last': headerKey === headerKeys[headerKeys.length - 1],
|
|
934
|
+
[`table__cell--${header.position}`]: true
|
|
935
|
+
})}">
|
|
936
|
+
<div>${this.renderData(value)}</div>
|
|
937
|
+
</td>`;
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
return html`
|
|
941
|
+
<td
|
|
942
|
+
@click="${this.selectRow}"
|
|
943
|
+
class="${classMap({
|
|
944
|
+
'table__cell': true,
|
|
945
|
+
'table__cell--wide': headerKey === this.wideColumn,
|
|
946
|
+
'table__cell--last': headerKey === headerKeys[headerKeys.length - 1],
|
|
947
|
+
})}">
|
|
948
|
+
<div>${this.renderData(value)}</div>
|
|
949
|
+
</td>`;
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
private hasHeaderPosition(header: string | HeaderConfig) {
|
|
953
|
+
return typeof header === 'object' && header !== null && 'position' in header && 'title' in header;
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
private getRows(keys: string[], data: TableData) {
|
|
957
|
+
let rows = Object.values(data.data).map((row: any) => {
|
|
958
|
+
return keys.map((header: any) => row[header]);
|
|
959
|
+
});
|
|
960
|
+
|
|
961
|
+
if (this.dataUri && this.sortColumn) {
|
|
962
|
+
// sort the rows by the key
|
|
963
|
+
rows = rows.sort((a, b) => {
|
|
964
|
+
return this.sortData(a[keys.indexOf(this.sortColumn)], b[keys.indexOf(this.sortColumn)]);
|
|
965
|
+
});
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
return rows;
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
private getSelectedKeys() {
|
|
972
|
+
const headerKeys = Object.keys(this.headers);
|
|
973
|
+
return this.selectedRows.map((row) => row[headerKeys.indexOf(this.key)]);
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
private updateKeys() {
|
|
977
|
+
this.updateModifyKeys();
|
|
978
|
+
this.updateDeleteKeys();
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
private updateModifyKeys() {
|
|
982
|
+
this.updateActionKeys('modify-action');
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
private updateDeleteKeys() {
|
|
986
|
+
this.updateActionKeys('delete-action');
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
private sortData(a: RenderDataValue | string | number | object | undefined, b: RenderDataValue | string | number | object | undefined) {
|
|
990
|
+
if (a === undefined || b === undefined) {
|
|
991
|
+
return 0;
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
if (typeof a === 'object' && 'caption' in a && 'title' in a.caption) {
|
|
995
|
+
a = a.caption.title as string;
|
|
996
|
+
} else if (typeof a === 'object' && a && 'value' in a) {
|
|
997
|
+
a = a.value as string | number;
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
if (typeof b === 'object' && 'caption' in b && 'title' in b.caption) {
|
|
1001
|
+
b = b.caption.title as string;
|
|
1002
|
+
} else if (typeof b === 'object' && b && 'value' in b) {
|
|
1003
|
+
b = b.value as string | number;
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
if (typeof a === 'string') {
|
|
1007
|
+
a = a.toLowerCase();
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
if (typeof b === 'string') {
|
|
1011
|
+
b = b.toLowerCase();
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
if (this.sortDirection === 'asc') {
|
|
1015
|
+
return a > b ? 1 : a < b ? -1 : 0;
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
return a < b ? 1 : a > b ? -1 : 0;
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
private loadingTable() {
|
|
1022
|
+
return html`
|
|
1023
|
+
<div class="table-container">
|
|
1024
|
+
<table class="${classMap({
|
|
1025
|
+
'table': true,
|
|
1026
|
+
'table--standalone': this.standalone,
|
|
1027
|
+
})}">
|
|
1028
|
+
<thead>
|
|
1029
|
+
<tr>
|
|
1030
|
+
<th colspan="30%"></th>
|
|
1031
|
+
<th colspan="25%"></th>
|
|
1032
|
+
<th colspan="20%"></th>
|
|
1033
|
+
<th colspan="15%"></th>
|
|
1034
|
+
<th colspan="10%"></th>
|
|
1035
|
+
</tr>
|
|
1036
|
+
</thead>
|
|
1037
|
+
<tbody>
|
|
1038
|
+
<tr>
|
|
1039
|
+
<td colspan="30%">
|
|
1040
|
+
<zn-skeleton></zn-skeleton>
|
|
1041
|
+
</td>
|
|
1042
|
+
<td colspan="25%">
|
|
1043
|
+
<zn-skeleton></zn-skeleton>
|
|
1044
|
+
</td>
|
|
1045
|
+
<td colspan="20%">
|
|
1046
|
+
<zn-skeleton></zn-skeleton>
|
|
1047
|
+
</td>
|
|
1048
|
+
<td colspan="15%">
|
|
1049
|
+
<zn-skeleton></zn-skeleton>
|
|
1050
|
+
</td>
|
|
1051
|
+
<td colspan="10%">
|
|
1052
|
+
<zn-skeleton></zn-skeleton>
|
|
1053
|
+
</td>
|
|
1054
|
+
</tr>
|
|
1055
|
+
<tr>
|
|
1056
|
+
<td colspan="30%">
|
|
1057
|
+
<zn-skeleton></zn-skeleton>
|
|
1058
|
+
</td>
|
|
1059
|
+
<td colspan="25%">
|
|
1060
|
+
<zn-skeleton></zn-skeleton>
|
|
1061
|
+
</td>
|
|
1062
|
+
<td colspan="20%">
|
|
1063
|
+
<zn-skeleton></zn-skeleton>
|
|
1064
|
+
</td>
|
|
1065
|
+
<td colspan="15%">
|
|
1066
|
+
<zn-skeleton></zn-skeleton>
|
|
1067
|
+
</td>
|
|
1068
|
+
<td colspan="10%">
|
|
1069
|
+
<zn-skeleton></zn-skeleton>
|
|
1070
|
+
</td>
|
|
1071
|
+
</tr>
|
|
1072
|
+
<tr>
|
|
1073
|
+
<td colspan="30%">
|
|
1074
|
+
<zn-skeleton></zn-skeleton>
|
|
1075
|
+
</td>
|
|
1076
|
+
<td colspan="25%">
|
|
1077
|
+
<zn-skeleton></zn-skeleton>
|
|
1078
|
+
</td>
|
|
1079
|
+
<td colspan="20%">
|
|
1080
|
+
<zn-skeleton></zn-skeleton>
|
|
1081
|
+
</td>
|
|
1082
|
+
<td colspan="15%">
|
|
1083
|
+
<zn-skeleton></zn-skeleton>
|
|
1084
|
+
</td>
|
|
1085
|
+
<td colspan="10%">
|
|
1086
|
+
<zn-skeleton></zn-skeleton>
|
|
1087
|
+
</td>
|
|
1088
|
+
</tr>
|
|
1089
|
+
</tbody>
|
|
1090
|
+
</table>
|
|
1091
|
+
</div>`;
|
|
1092
|
+
}
|
|
1093
|
+
}
|