@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,225 @@
|
|
|
1
|
+
import {classMap} from "lit/directives/class-map.js";
|
|
2
|
+
import {HasSlotController} from "../../internal/slot";
|
|
3
|
+
import {html, unsafeCSS} from 'lit';
|
|
4
|
+
import {property, queryAssignedNodes, queryAsync} from 'lit/decorators.js';
|
|
5
|
+
import {unsafeHTML} from 'lit-html/directives/unsafe-html.js';
|
|
6
|
+
import ZincElement from "../../internal/zinc-element";
|
|
7
|
+
import type {PropertyValues} from 'lit';
|
|
8
|
+
|
|
9
|
+
import styles from './content-block.scss';
|
|
10
|
+
|
|
11
|
+
interface TextRow {
|
|
12
|
+
lines: string[];
|
|
13
|
+
type: 'reply' | 'text';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @summary Short summary of the component's intended use.
|
|
18
|
+
* @documentation https://zinc.style/components/content-block
|
|
19
|
+
* @status experimental
|
|
20
|
+
* @since 1.0
|
|
21
|
+
*/
|
|
22
|
+
export default class ContentBlock extends ZincElement {
|
|
23
|
+
static styles = unsafeCSS(styles);
|
|
24
|
+
|
|
25
|
+
@property() time = '';
|
|
26
|
+
@property() sender = '';
|
|
27
|
+
@property() avatar = '';
|
|
28
|
+
|
|
29
|
+
@property({type: Boolean, reflect: true}) outbound = false;
|
|
30
|
+
@property({type: Boolean, reflect: true}) short = false;
|
|
31
|
+
|
|
32
|
+
@queryAssignedNodes({slot: 'html', flatten: true}) htmlNodes!: Node[];
|
|
33
|
+
|
|
34
|
+
@queryAsync('iframe') iframe!: Promise<HTMLIFrameElement>;
|
|
35
|
+
|
|
36
|
+
private readonly hasSlotController = new HasSlotController(this, 'text', 'html');
|
|
37
|
+
|
|
38
|
+
private _textRows: TextRow[] = [];
|
|
39
|
+
|
|
40
|
+
connectedCallback() {
|
|
41
|
+
super.connectedCallback();
|
|
42
|
+
this.iframe.then((iframe) => {
|
|
43
|
+
if (iframe.contentDocument) {
|
|
44
|
+
const div = this.htmlNodes[0] as HTMLDivElement;
|
|
45
|
+
if (div) {
|
|
46
|
+
let convertedHtml = div?.innerHTML ?? '';
|
|
47
|
+
convertedHtml = convertedHtml.replace(/ /g, ' ');
|
|
48
|
+
convertedHtml = convertedHtml.replace(/</g, '<');
|
|
49
|
+
convertedHtml = convertedHtml.replace(/>/g, '>');
|
|
50
|
+
convertedHtml = convertedHtml.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, '');
|
|
51
|
+
|
|
52
|
+
const baseStyles = "<style>body,html{padding: 0; margin: 0; font-size: 13px; font-family: Arial;}</style>";
|
|
53
|
+
iframe.srcdoc = baseStyles + convertedHtml;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private _collapseContent(e: Event) {
|
|
60
|
+
const target = e.target as HTMLElement;
|
|
61
|
+
const headerClick = target.classList.contains('content-block-header') ||
|
|
62
|
+
target.parentElement?.classList.contains('content-block-header');
|
|
63
|
+
|
|
64
|
+
if (headerClick && target.slot !== 'nav') {
|
|
65
|
+
this.short = !this.short;
|
|
66
|
+
this.requestUpdate();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
private _toggleText() {
|
|
71
|
+
const textContent = this.shadowRoot?.querySelector('.text-content') as HTMLDivElement | null;
|
|
72
|
+
this.iframe.then((iframe) => {
|
|
73
|
+
if (textContent) {
|
|
74
|
+
iframe.classList.add('hidden');
|
|
75
|
+
textContent.classList.remove('hidden');
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
private _toggleHtml() {
|
|
81
|
+
const textContent = this.shadowRoot?.querySelector('.text-content') as HTMLDivElement | null;
|
|
82
|
+
this.iframe.then((iframe) => {
|
|
83
|
+
if (textContent) {
|
|
84
|
+
iframe.classList.remove('hidden');
|
|
85
|
+
textContent.classList.add('hidden');
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
protected firstUpdated(_changedProperties: PropertyValues) {
|
|
91
|
+
super.firstUpdated(_changedProperties);
|
|
92
|
+
|
|
93
|
+
const textContent = this.shadowRoot?.querySelectorAll('.text-section');
|
|
94
|
+
if (textContent && textContent.length > 0) {
|
|
95
|
+
textContent.forEach((content) => {
|
|
96
|
+
content.innerHTML = content.innerHTML.replace(/ /g, ' ');
|
|
97
|
+
content.innerHTML = content.innerHTML.replace(/<!--[\s\S]*?-->/g, '');
|
|
98
|
+
content.innerHTML = content.innerHTML.replace(/<\/p><br>/g, '</p>');
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
protected render() {
|
|
104
|
+
const text = this.getTextSections();
|
|
105
|
+
const hasFooter = this.querySelector(`:scope > [slot="footer"]`) !== null;
|
|
106
|
+
const hasTextSlot = this.hasSlotController.test('text');
|
|
107
|
+
const hasHtmlSlot = this.hasSlotController.test('html');
|
|
108
|
+
const showActions = hasTextSlot && hasHtmlSlot;
|
|
109
|
+
|
|
110
|
+
return html`
|
|
111
|
+
<zn-panel flush tabbed class="${classMap({
|
|
112
|
+
'content-block--outbound': this.outbound,
|
|
113
|
+
'content-block--short': this.short
|
|
114
|
+
})}">
|
|
115
|
+
|
|
116
|
+
<zn-header class="content-block-header"
|
|
117
|
+
caption="${this.sender}"
|
|
118
|
+
description="${this.truncateText()}"
|
|
119
|
+
@click="${this._collapseContent}">
|
|
120
|
+
|
|
121
|
+
<zn-icon src="${this.avatar}"
|
|
122
|
+
library="avatar"
|
|
123
|
+
round></zn-icon>
|
|
124
|
+
|
|
125
|
+
<div slot="actions">
|
|
126
|
+
<small>${this.time}</small>
|
|
127
|
+
${showActions ? html`
|
|
128
|
+
<zn-dropdown>
|
|
129
|
+
<zn-button slot="trigger" icon="more_vert" icon-size="24" color="transparent"
|
|
130
|
+
size="content"></zn-button>
|
|
131
|
+
<zn-menu>
|
|
132
|
+
<zn-menu-item @click="${this._toggleHtml}">
|
|
133
|
+
Show HTML
|
|
134
|
+
</zn-menu-item>
|
|
135
|
+
<zn-menu-item @click="${this._toggleText}">
|
|
136
|
+
Show Text
|
|
137
|
+
</zn-menu-item>
|
|
138
|
+
</zn-menu>
|
|
139
|
+
</zn-dropdown>
|
|
140
|
+
` : ''}
|
|
141
|
+
</div>
|
|
142
|
+
|
|
143
|
+
</zn-header>
|
|
144
|
+
|
|
145
|
+
<zn-sp no-gap>
|
|
146
|
+
<iframe class="hidden" title="Content block HTML preview"></iframe>
|
|
147
|
+
<slot class="html-content" name="html" style="display: none;"></slot>
|
|
148
|
+
<slot name="text" style="display: none;"></slot>
|
|
149
|
+
<div class="text-content">
|
|
150
|
+
${text.map((section) => html`
|
|
151
|
+
${section.type === 'reply' ? html`
|
|
152
|
+
<div class="toggle-reply" @click="${this.showReply}">...</div>` : ''}
|
|
153
|
+
<div class=${classMap({
|
|
154
|
+
'text-section': true,
|
|
155
|
+
'text-section--reply': section.type === 'reply',
|
|
156
|
+
'text-section--text': section.type === 'text',
|
|
157
|
+
'hidden': section.type === 'reply'
|
|
158
|
+
})}>
|
|
159
|
+
${section.lines.map((line) => html`${unsafeHTML(line)}<br>`)}
|
|
160
|
+
</div>
|
|
161
|
+
`)}
|
|
162
|
+
</div>
|
|
163
|
+
</zn-sp>
|
|
164
|
+
|
|
165
|
+
${hasFooter ? html`
|
|
166
|
+
<slot slot="footer" name="footer"></slot>` : ''}
|
|
167
|
+
</zn-panel>
|
|
168
|
+
`;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
protected truncateText() {
|
|
172
|
+
const textContent = this.querySelector('[slot="text"]') as HTMLDivElement | null;
|
|
173
|
+
if (!textContent) return '';
|
|
174
|
+
const trimmed = textContent.innerText.replace(/<[^>]*>/g, '').trim();
|
|
175
|
+
return trimmed.length > 32 ? trimmed.substring(0, 32) + '...' : trimmed;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
protected getTextSections(): TextRow[] {
|
|
179
|
+
const textContent = this.querySelector('[slot="text"]') as HTMLDivElement | null;
|
|
180
|
+
const textRows: TextRow[] = [];
|
|
181
|
+
|
|
182
|
+
if (textContent) {
|
|
183
|
+
const text = textContent.innerText;
|
|
184
|
+
const rows = text.split('\n');
|
|
185
|
+
let previousType: TextRow['type'] | null = null;
|
|
186
|
+
let forceReply = false;
|
|
187
|
+
let type: TextRow['type'] = 'text';
|
|
188
|
+
|
|
189
|
+
const containsGraterThan = rows.some((row) => row.startsWith('>'));
|
|
190
|
+
|
|
191
|
+
rows.forEach((rowOrig) => {
|
|
192
|
+
let row = rowOrig;
|
|
193
|
+
if (((row.startsWith('On') && row.endsWith('wrote:')) || row.startsWith('From:')) && !containsGraterThan) forceReply = true;
|
|
194
|
+
if (row.startsWith('--')) forceReply = false;
|
|
195
|
+
type = (forceReply || row.startsWith('>')) ? 'reply' : 'text';
|
|
196
|
+
if (row.startsWith('Sent from')) type = 'reply';
|
|
197
|
+
if (row.trim() === '' && previousType === 'reply') type = 'reply';
|
|
198
|
+
if (type === 'reply' && row.startsWith('>')) row = row.substring(1).trim();
|
|
199
|
+
|
|
200
|
+
if (previousType === type) {
|
|
201
|
+
if (textRows.length === 0) {
|
|
202
|
+
textRows.push({lines: [row], type});
|
|
203
|
+
previousType = type;
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
textRows[textRows.length - 1].lines.push(row);
|
|
207
|
+
} else {
|
|
208
|
+
textRows.push({lines: [row], type});
|
|
209
|
+
previousType = type;
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
this._textRows = textRows;
|
|
215
|
+
return this._textRows;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
showReply(e: MouseEvent) {
|
|
219
|
+
const target = e.target as HTMLElement;
|
|
220
|
+
const nextElement = target.nextElementSibling;
|
|
221
|
+
if (nextElement) {
|
|
222
|
+
nextElement.classList.toggle('hidden');
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
text-rendering: optimizeLegibility;
|
|
3
|
+
-webkit-font-smoothing: antialiased;
|
|
4
|
+
-moz-osx-font-smoothing: grayscale;
|
|
5
|
+
|
|
6
|
+
*, *::before, *::after {
|
|
7
|
+
box-sizing: border-box;
|
|
8
|
+
border-width: 0;
|
|
9
|
+
border-style: solid;
|
|
10
|
+
border-color: rgb(var(--zn-border-color));
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
zn-header div[slot='actions'] {
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
gap: 10px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
zn-header::part(base) {
|
|
21
|
+
cursor: pointer;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
zn-header::part(header-left) {
|
|
25
|
+
flex-direction: row;
|
|
26
|
+
align-items: center;
|
|
27
|
+
gap: 10px;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
zn-navbar {
|
|
31
|
+
cursor: default;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.content-block--short {
|
|
35
|
+
zn-sp, zn-navbar {
|
|
36
|
+
display: none;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
zn-header::part(base) {
|
|
40
|
+
border-bottom: none;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
zn-panel.content-block--short::part(mid) {
|
|
45
|
+
display: none;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
zn-panel:not(.content-block--short) zn-header::part(header-description) {
|
|
49
|
+
display: none;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.text-section {
|
|
53
|
+
font-size: 13px;
|
|
54
|
+
line-height: 19px;
|
|
55
|
+
|
|
56
|
+
a {
|
|
57
|
+
font-size: 10px;
|
|
58
|
+
opacity: 0.8;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.hidden {
|
|
63
|
+
display: none;
|
|
64
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import '../../../dist/zn.min.js';
|
|
2
|
+
import { expect, fixture, html } from '@open-wc/testing';
|
|
3
|
+
|
|
4
|
+
describe('<zn-content-block>', () => {
|
|
5
|
+
it('should render a component', async () => {
|
|
6
|
+
const el = await fixture(html` <zn-content-block></zn-content-block> `);
|
|
7
|
+
|
|
8
|
+
expect(el).to.exist;
|
|
9
|
+
});
|
|
10
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import ZnContentBlock from './content-block.component';
|
|
2
|
+
|
|
3
|
+
export * from './content-block.component';
|
|
4
|
+
export default ZnContentBlock;
|
|
5
|
+
|
|
6
|
+
ZnContentBlock.define('zn-content-block');
|
|
7
|
+
|
|
8
|
+
declare global {
|
|
9
|
+
interface HTMLElementTagNameMap {
|
|
10
|
+
'zn-content-block': ZnContentBlock;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import {property, query, state} from 'lit/decorators.js';
|
|
2
|
+
import {type CSSResultGroup, html, unsafeCSS} from 'lit';
|
|
3
|
+
import ZincElement from '../../internal/zinc-element';
|
|
4
|
+
|
|
5
|
+
import styles from './copy-button.scss';
|
|
6
|
+
import {classMap} from "lit/directives/class-map.js";
|
|
7
|
+
import ZnTooltip from "../tooltip";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @summary Short summary of the component's intended use.
|
|
11
|
+
* @documentation https://zinc.style/components/copy-button
|
|
12
|
+
* @status experimental
|
|
13
|
+
* @since 1.0
|
|
14
|
+
*
|
|
15
|
+
* @dependency zn-example
|
|
16
|
+
*
|
|
17
|
+
* @event zn-event-name - Emitted as an example.
|
|
18
|
+
*
|
|
19
|
+
* @slot - The default slot.
|
|
20
|
+
* @slot example - An example slot.
|
|
21
|
+
*
|
|
22
|
+
* @csspart base - The component's base wrapper.
|
|
23
|
+
*
|
|
24
|
+
* @cssproperty --example - An example CSS custom property.
|
|
25
|
+
*/
|
|
26
|
+
export default class ZnCopyButton extends ZincElement {
|
|
27
|
+
static styles: CSSResultGroup = unsafeCSS(styles);
|
|
28
|
+
|
|
29
|
+
@query('slot[name="copy-icon"') copyIcon: HTMLSlotElement;
|
|
30
|
+
|
|
31
|
+
@query('slot[name="success-icon"') successIcon: HTMLSlotElement;
|
|
32
|
+
|
|
33
|
+
@query('slot[name="error-icon"') errorIcon: HTMLSlotElement;
|
|
34
|
+
|
|
35
|
+
@query('zn-tooltip') tooltip: ZnTooltip;
|
|
36
|
+
|
|
37
|
+
@state() isCopying = false;
|
|
38
|
+
|
|
39
|
+
@state() status: 'rest' | 'success' | 'error' = 'rest';
|
|
40
|
+
|
|
41
|
+
@property() value = '';
|
|
42
|
+
|
|
43
|
+
@property({attribute: 'copy-label'}) copyLabel = '';
|
|
44
|
+
|
|
45
|
+
@property() src = '';
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* An id that references an element in the same document from which data will be copied. If both this and `value` are
|
|
50
|
+
* present, this value will take precedence. By default, the target element's `textContent` will be copied. To copy an
|
|
51
|
+
* attribute, append the attribute name wrapped in square brackets, e.g. `from="el[value]"`. To copy a property,
|
|
52
|
+
* append a dot and the property name, e.g. `from="el.value"`.
|
|
53
|
+
*/
|
|
54
|
+
@property() from = '';
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
render() {
|
|
58
|
+
const copyLabel = this.copyLabel || 'Copy';
|
|
59
|
+
|
|
60
|
+
return html`
|
|
61
|
+
<zn-tooltip
|
|
62
|
+
class=${classMap({
|
|
63
|
+
'copy-button': true,
|
|
64
|
+
'copy-button--error': this.status === 'error',
|
|
65
|
+
'copy-button--success': this.status === 'success',
|
|
66
|
+
})}
|
|
67
|
+
content=${copyLabel}>
|
|
68
|
+
<button class="copy-button__button" part="button" @click=${this.handleCopy}>
|
|
69
|
+
<slot part="copy-icon" name="copy-icon">
|
|
70
|
+
<zn-icon src="${this.src ? this.src : 'content_copy'}"></zn-icon>
|
|
71
|
+
</slot>
|
|
72
|
+
<slot part="success-icon" name="success-icon" hidden>
|
|
73
|
+
<zn-icon src="check"></zn-icon>
|
|
74
|
+
</slot>
|
|
75
|
+
<slot part="error-icon" name="error-icon" hidden>
|
|
76
|
+
<zn-icon src="priority_high"></zn-icon>
|
|
77
|
+
</slot>
|
|
78
|
+
</button>
|
|
79
|
+
</zn-tooltip>
|
|
80
|
+
`;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
private async showStatus(status: 'success' | 'error') {
|
|
84
|
+
const iconToShow = status === 'success' ? this.successIcon : this.errorIcon;
|
|
85
|
+
this.tooltip.content = status === 'success' ? 'Copied!' : 'Error!';
|
|
86
|
+
|
|
87
|
+
this.copyIcon.hidden = true;
|
|
88
|
+
this.status = status;
|
|
89
|
+
iconToShow.hidden = false;
|
|
90
|
+
|
|
91
|
+
setTimeout(() => {
|
|
92
|
+
this.status = 'rest';
|
|
93
|
+
this.copyIcon.hidden = false;
|
|
94
|
+
iconToShow.hidden = true;
|
|
95
|
+
this.tooltip.content = this.copyLabel || 'Copy';
|
|
96
|
+
this.isCopying = false;
|
|
97
|
+
}, 1500);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
private async handleCopy() {
|
|
101
|
+
if (this.isCopying) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
this.isCopying = true;
|
|
105
|
+
|
|
106
|
+
let valueToCopy = this.value||this.textContent;
|
|
107
|
+
|
|
108
|
+
if (this.from) {
|
|
109
|
+
const root = this.getRootNode() as ShadowRoot | Document;
|
|
110
|
+
|
|
111
|
+
const isProperty = this.from.includes('.');
|
|
112
|
+
const isAttribute = this.from.includes('[') && this.from.includes(']');
|
|
113
|
+
let id = this.from;
|
|
114
|
+
let field = '';
|
|
115
|
+
|
|
116
|
+
if (isProperty) {
|
|
117
|
+
[id, field] = this.from.trim().split('.');
|
|
118
|
+
} else if (isAttribute) {
|
|
119
|
+
[id, field] = this.from.trim().replace(/]$/, '').split('[');
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const target = 'getElementById' in root ? root.getElementById(id) : null;
|
|
123
|
+
|
|
124
|
+
if (target) {
|
|
125
|
+
if (isAttribute) {
|
|
126
|
+
valueToCopy = target.getAttribute(field) || '';
|
|
127
|
+
} else if (isProperty) {
|
|
128
|
+
// @ts-expect-error Not really an error tbh.
|
|
129
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
130
|
+
valueToCopy = target[field] || '';
|
|
131
|
+
} else {
|
|
132
|
+
valueToCopy = target.textContent || '';
|
|
133
|
+
}
|
|
134
|
+
} else {
|
|
135
|
+
console.error("No target element found with id:", id);
|
|
136
|
+
this.showStatus('error');
|
|
137
|
+
this.emit('zn-error');
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (!valueToCopy) {
|
|
142
|
+
console.error('No value to copy. Please provide a value or a valid "from" attribute.');
|
|
143
|
+
await this.showStatus('error');
|
|
144
|
+
this.emit('zn-error');
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
try {
|
|
149
|
+
await navigator.clipboard.writeText(valueToCopy);
|
|
150
|
+
await this.showStatus('success');
|
|
151
|
+
this.emit('zn-copy', {
|
|
152
|
+
detail: {
|
|
153
|
+
value: valueToCopy
|
|
154
|
+
}
|
|
155
|
+
})
|
|
156
|
+
} catch (error) {
|
|
157
|
+
console.error('Failed to copy text: ', error);
|
|
158
|
+
await this.showStatus('error');
|
|
159
|
+
this.emit('zn-error');
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
}
|
|
163
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
@use "../../wc";
|
|
2
|
+
|
|
3
|
+
:host {
|
|
4
|
+
display: inline-block;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
slot {
|
|
8
|
+
display: inline-flex;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.copy-button {
|
|
12
|
+
&--success {
|
|
13
|
+
// color: rgb(var(--zn-color-success));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
&--error {
|
|
17
|
+
// color: rgb(var(--zn-color-error));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.copy-button__button {
|
|
22
|
+
flex: 0 0 auto;
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
background: none;
|
|
26
|
+
border: none;
|
|
27
|
+
border-radius: 3px;
|
|
28
|
+
font-size: inherit;
|
|
29
|
+
color: inherit;
|
|
30
|
+
padding: var(--zn-spacing-2x-small);
|
|
31
|
+
cursor: pointer;
|
|
32
|
+
transition: color 0.2s;
|
|
33
|
+
|
|
34
|
+
&:focus-visible {
|
|
35
|
+
outline: none;
|
|
36
|
+
box-shadow: 0 0 0 2px rgb(var(--zn-primary));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&[disabled] {
|
|
40
|
+
opacity: 0.5;
|
|
41
|
+
cursor: not-allowed !important
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
[hidden] {
|
|
46
|
+
display: none;
|
|
47
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import '../../../dist/zn.min.js';
|
|
2
|
+
import { expect, fixture, html } from '@open-wc/testing';
|
|
3
|
+
|
|
4
|
+
describe('<zn-copy-button>', () => {
|
|
5
|
+
it('should render a component', async () => {
|
|
6
|
+
const el = await fixture(html` <zn-copy-button></zn-copy-button> `);
|
|
7
|
+
|
|
8
|
+
expect(el).to.exist;
|
|
9
|
+
});
|
|
10
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import ZnCopyButton from './copy-button.component';
|
|
2
|
+
|
|
3
|
+
export * from './copy-button.component';
|
|
4
|
+
export default ZnCopyButton;
|
|
5
|
+
|
|
6
|
+
ZnCopyButton.define('zn-copy-button');
|
|
7
|
+
|
|
8
|
+
declare global {
|
|
9
|
+
interface HTMLElementTagNameMap {
|
|
10
|
+
'zn-copy-button': ZnCopyButton;
|
|
11
|
+
}
|
|
12
|
+
}
|