@kubex/zinc 0.0.3 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.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 +65 -0
- package/custom-elements-manifest.config.js +230 -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/web-test-runner.config.js +50 -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 -26
- package/layout/dist/zn-layout.js +0 -93
- 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/container.ts +0 -132
- 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,552 @@
|
|
|
1
|
+
---
|
|
2
|
+
meta:
|
|
3
|
+
title: Form Controls
|
|
4
|
+
description: Some things to note about Zinc and forms.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Form Controls
|
|
8
|
+
|
|
9
|
+
### Note
|
|
10
|
+
|
|
11
|
+
:::warning
|
|
12
|
+
This page contains form control documentation relevant to Zinc components in general, but **is not relevant
|
|
13
|
+
to `ts_form_for`**, our custom Simple Form wrapper. More `ts_form_for` documentation is in the works. In the meantime,
|
|
14
|
+
please **refer to the SLIM code examples for specific components** (
|
|
15
|
+
e.g. [Basic Select with Label](/components/select#basic-select-with-label)) to see how to render specific components
|
|
16
|
+
using `ts_form_for`.
|
|
17
|
+
:::
|
|
18
|
+
|
|
19
|
+
> Every Zinc component makes use of
|
|
20
|
+
> a [shadow DOM](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_shadow_DOM) to encapsulate markup,
|
|
21
|
+
> styles, and behavior. One caveat of this approach is that native `<form>` elements do not recognize form controls
|
|
22
|
+
> located inside a shadow root.
|
|
23
|
+
|
|
24
|
+
Zinc solves this problem by using the [
|
|
25
|
+
`formdata`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/formdata_event) event, which
|
|
26
|
+
is [available in all modern browsers](https://caniuse.com/mdn-api_htmlformelement_formdata_event). This means, when a
|
|
27
|
+
form is submitted, Zinc form controls will automatically append their values to the `FormData` object that's used to
|
|
28
|
+
submit the form. In most cases, things will "just work." However, if you're using a form serialization library, it might
|
|
29
|
+
need to be adapted to recognize Zinc form controls.
|
|
30
|
+
|
|
31
|
+
:::tip
|
|
32
|
+
Zinc uses event listeners to intercept the form's `formdata` and `submit` events. This allows it to inject data and
|
|
33
|
+
trigger validation as necessary. If you're also attaching an event listener to the form, _you must attach it after Zinc
|
|
34
|
+
form controls are connected to the DOM_, otherwise your logic will run before Zinc has a chance to inject form data and
|
|
35
|
+
validate form controls.
|
|
36
|
+
:::
|
|
37
|
+
|
|
38
|
+
## Data Serialization
|
|
39
|
+
|
|
40
|
+
Serialization is just a fancy word for collecting form data. If you're relying on standard form submissions, e.g.
|
|
41
|
+
`<form action="...">`, you can probably skip this section. However, most modern apps use
|
|
42
|
+
the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) or a library such
|
|
43
|
+
as [axios](https://github.com/axios/axios) to submit forms using JavaScript.
|
|
44
|
+
|
|
45
|
+
The [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData) interface offers a standard way to serialize
|
|
46
|
+
forms in the browser. You can create a `FormData` object from any `<form>` element like this.
|
|
47
|
+
|
|
48
|
+
```js
|
|
49
|
+
const form = document.querySelector('form');
|
|
50
|
+
const data = new FormData(form);
|
|
51
|
+
|
|
52
|
+
// All form control data is available in a FormData object
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
However, some folks find `FormData` tricky to work with or they need to pass a JSON payload to their server. To
|
|
56
|
+
accommodate this, Zinc offers a serialization utility that gathers form data and returns a simple JavaScript object
|
|
57
|
+
instead.
|
|
58
|
+
|
|
59
|
+
```js
|
|
60
|
+
import {serialize} from '@kubex/zinc/dist/utilities/form.js';
|
|
61
|
+
|
|
62
|
+
const form = document.querySelector('form');
|
|
63
|
+
const data = serialize(form);
|
|
64
|
+
|
|
65
|
+
// All form control data is available in a plain object
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
This results in an object with name/value pairs that map to each form control. If more than one form control shares the
|
|
69
|
+
same name, the values will be passed as an array, e.g. `{ name: ['value1', 'value2'] }`.
|
|
70
|
+
|
|
71
|
+
## Constraint Validation
|
|
72
|
+
|
|
73
|
+
Client-side validation can be enabled through the
|
|
74
|
+
browser's [Constraint Validation API](https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5/Constraint_validation)
|
|
75
|
+
for Zinc form controls. You can activate it using attributes such as `required`, `pattern`, `minlength`, `maxlength`,
|
|
76
|
+
etc. Zinc implements many of the same attributes as native form controls, but check the documentation for a list of
|
|
77
|
+
supported properties for each component.
|
|
78
|
+
|
|
79
|
+
If you don't want to use client-side validation, you can suppress this behavior by adding `novalidate` to the
|
|
80
|
+
surrounding `<form>` element.
|
|
81
|
+
|
|
82
|
+
:::tip
|
|
83
|
+
If this syntax looks unfamiliar, don't worry! Most of what you're learning on this page is platform knowledge that
|
|
84
|
+
applies to regular form controls, too.
|
|
85
|
+
:::
|
|
86
|
+
|
|
87
|
+
:::warning
|
|
88
|
+
Client-side validation can be used to improve the UX of forms, but it is not a replacement for server-side validation. *
|
|
89
|
+
*You should always validate and sanitize user input on the server!**
|
|
90
|
+
:::
|
|
91
|
+
|
|
92
|
+
### Required Fields
|
|
93
|
+
|
|
94
|
+
To make a field required, use the `required` attribute. Required fields will automatically receive a `*` after their
|
|
95
|
+
labels. This is configurable through the `--zn-input-required-content` custom property.
|
|
96
|
+
|
|
97
|
+
The form will not be submitted if a required field is incomplete.
|
|
98
|
+
|
|
99
|
+
```html:preview
|
|
100
|
+
<form class="input-validation-required">
|
|
101
|
+
<zn-input name="name" label="Name" required>
|
|
102
|
+
<input type="text" id="text" name="text">
|
|
103
|
+
</zn-input>
|
|
104
|
+
<br />
|
|
105
|
+
<zn-select label="Favorite Animal" clearable required>
|
|
106
|
+
<zn-option value="birds">Birds</zn-option>
|
|
107
|
+
<zn-option value="cats">Cats</zn-option>
|
|
108
|
+
<zn-option value="dogs">Dogs</zn-option>
|
|
109
|
+
<zn-option value="other">Other</zn-option>
|
|
110
|
+
</zn-select>
|
|
111
|
+
<br />
|
|
112
|
+
<zn-textarea name="comment" label="Comment" required></zn-textarea>
|
|
113
|
+
<br />
|
|
114
|
+
<zn-checkbox required>Check me before submitting</zn-checkbox>
|
|
115
|
+
<br /><br />
|
|
116
|
+
<zn-checkbox-group label="Checkbox group" help-text="Select at least one" label-tooltip="Do you need help?" required>
|
|
117
|
+
<zn-checkbox value="I'm option 1">Option 1</zn-checkbox>
|
|
118
|
+
<zn-checkbox value="I'm option 2">Option 2</zn-checkbox>
|
|
119
|
+
<zn-checkbox value="I'm option 3">Option 3</zn-checkbox>
|
|
120
|
+
</zn-checkbox-group>
|
|
121
|
+
<br /><br />
|
|
122
|
+
<zn-button type="submit" variant="primary">Submit</zn-button>
|
|
123
|
+
</form>
|
|
124
|
+
|
|
125
|
+
<script type="module">
|
|
126
|
+
const form = document.querySelector('.input-validation-required');
|
|
127
|
+
|
|
128
|
+
// Wait for controls to be defined before attaching form listeners
|
|
129
|
+
await Promise.all([
|
|
130
|
+
customElements.whenDefined('zn-button'),
|
|
131
|
+
customElements.whenDefined('zn-checkbox'),
|
|
132
|
+
customElements.whenDefined('zn-input'),
|
|
133
|
+
customElements.whenDefined('zn-option'),
|
|
134
|
+
customElements.whenDefined('zn-select'),
|
|
135
|
+
customElements.whenDefined('zn-textarea')
|
|
136
|
+
]).then(() => {
|
|
137
|
+
form.addEventListener('submit', event => {
|
|
138
|
+
event.preventDefault();
|
|
139
|
+
alert('All fields are valid!');
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
</script>
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Input Patterns
|
|
146
|
+
|
|
147
|
+
To restrict a value to a specific [pattern](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/pattern), use
|
|
148
|
+
the `pattern` attribute. This example only allows the letters A-Z, so the form will not submit if a number or symbol is
|
|
149
|
+
entered. This only works with `<zn-input>` elements.
|
|
150
|
+
|
|
151
|
+
```html:preview
|
|
152
|
+
<form class="input-validation-pattern">
|
|
153
|
+
<zn-input name="letters" required label="Letters" pattern="[A-Za-z]+">
|
|
154
|
+
<input type="text" id="text" name="text">
|
|
155
|
+
</zn-input>
|
|
156
|
+
<br />
|
|
157
|
+
<zn-button type="submit" variant="primary">Submit</zn-button>
|
|
158
|
+
<zn-button type="reset" variant="default">Reset</zn-button>
|
|
159
|
+
</form>
|
|
160
|
+
|
|
161
|
+
<script type="module">
|
|
162
|
+
const form = document.querySelector('.input-validation-pattern');
|
|
163
|
+
|
|
164
|
+
// Wait for controls to be defined before attaching form listeners
|
|
165
|
+
await Promise.all([
|
|
166
|
+
customElements.whenDefined('zn-button'),
|
|
167
|
+
customElements.whenDefined('zn-input')
|
|
168
|
+
]).then(() => {
|
|
169
|
+
form.addEventListener('submit', event => {
|
|
170
|
+
event.preventDefault();
|
|
171
|
+
alert('All fields are valid!');
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
</script>
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Input Types
|
|
178
|
+
|
|
179
|
+
Some input types will automatically trigger constraints, such as `email` and `url`.
|
|
180
|
+
|
|
181
|
+
```html:preview
|
|
182
|
+
<form class="input-validation-type">
|
|
183
|
+
<zn-input type="email" label="Email" placeholder="you@example.com" required>
|
|
184
|
+
<input type="text" id="text" name="text">
|
|
185
|
+
</zn-input>
|
|
186
|
+
<br />
|
|
187
|
+
<zn-input type="url" label="URL" placeholder="https://example.com/" required>
|
|
188
|
+
<input type="text" id="text" name="text">
|
|
189
|
+
</zn-input>
|
|
190
|
+
<br />
|
|
191
|
+
<zn-button type="submit" variant="primary">Submit</zn-button>
|
|
192
|
+
<zn-button type="reset" variant="default">Reset</zn-button>
|
|
193
|
+
</form>
|
|
194
|
+
|
|
195
|
+
<script type="module">
|
|
196
|
+
const form = document.querySelector('.input-validation-type');
|
|
197
|
+
|
|
198
|
+
// Wait for controls to be defined before attaching form listeners
|
|
199
|
+
await Promise.all([
|
|
200
|
+
customElements.whenDefined('zn-button'),
|
|
201
|
+
customElements.whenDefined('zn-input')
|
|
202
|
+
]).then(() => {
|
|
203
|
+
form.addEventListener('submit', event => {
|
|
204
|
+
event.preventDefault();
|
|
205
|
+
alert('All fields are valid!');
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
</script>
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Custom Error Messages
|
|
212
|
+
|
|
213
|
+
To create a custom validation error, pass a non-empty string to the `setCustomValidity()` method. This will override any
|
|
214
|
+
existing validation constraints. The form will not be submitted when a custom validity is set and the browser will show
|
|
215
|
+
a validation error when the containing form is submitted. To make the input valid again, call `setCustomValidity()`
|
|
216
|
+
again with an empty string.
|
|
217
|
+
|
|
218
|
+
```html:preview
|
|
219
|
+
<form class="input-validation-custom">
|
|
220
|
+
<zn-input label="Type “zinc”" required>
|
|
221
|
+
<input type="text" id="text" name="text">
|
|
222
|
+
</zn-input>
|
|
223
|
+
<br />
|
|
224
|
+
<zn-button type="submit" variant="primary">Submit</zn-button>
|
|
225
|
+
<zn-button type="reset" variant="default">Reset</zn-button>
|
|
226
|
+
</form>
|
|
227
|
+
|
|
228
|
+
<script type="module">
|
|
229
|
+
const form = document.querySelector('.input-validation-custom');
|
|
230
|
+
const input = form.querySelector('zn-input');
|
|
231
|
+
|
|
232
|
+
// Wait for controls to be defined before attaching form listeners
|
|
233
|
+
await Promise.all([
|
|
234
|
+
customElements.whenDefined('zn-button'),
|
|
235
|
+
customElements.whenDefined('zn-input')
|
|
236
|
+
]).then(() => {
|
|
237
|
+
form.addEventListener('submit', event => {
|
|
238
|
+
event.preventDefault();
|
|
239
|
+
alert('All fields are valid!');
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
input.addEventListener('zn-input', () => {
|
|
243
|
+
if (input.value === 'zinc') {
|
|
244
|
+
input.setCustomValidity('');
|
|
245
|
+
} else {
|
|
246
|
+
input.setCustomValidity("Hey, you're supposed to type 'zinc' before submitting this!");
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
</script>
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
:::tip
|
|
254
|
+
Custom validation can be applied to any form control that supports the `setCustomValidity()` method. It is not limited
|
|
255
|
+
to inputs and textareas.
|
|
256
|
+
:::
|
|
257
|
+
|
|
258
|
+
## Custom Validation Styles
|
|
259
|
+
|
|
260
|
+
Due to the many ways form controls are used, Zinc doesn't provide out of the box validation styles for form controls as
|
|
261
|
+
part of its default theme. Instead, the following attributes will be applied to reflect a control's validity as users
|
|
262
|
+
interact with it. You can use them to create custom styles for any of the validation states you're interested in.
|
|
263
|
+
|
|
264
|
+
- `data-required` - the form control is required
|
|
265
|
+
- `data-optional` - the form control is optional
|
|
266
|
+
- `data-invalid` - the form control is currently invalid
|
|
267
|
+
- `data-valid` - the form control is currently valid
|
|
268
|
+
- `data-user-invalid` - the form control is currently invalid and the user has interacted with it
|
|
269
|
+
- `data-user-valid` - the form control is currently valid and the user has interacted with it
|
|
270
|
+
|
|
271
|
+
These attributes map to the browser's built-in pseudo classes for validation: [
|
|
272
|
+
`:required`](https://developer.mozilla.org/en-US/docs/Web/CSS/:required), [
|
|
273
|
+
`:optional`](https://developer.mozilla.org/en-US/docs/Web/CSS/:optional), [
|
|
274
|
+
`:invalid`](https://developer.mozilla.org/en-US/docs/Web/CSS/:invalid), [
|
|
275
|
+
`:valid`](https://developer.mozilla.org/en-US/docs/Web/CSS/:valid), and the proposed [
|
|
276
|
+
`:user-invalid`](https://developer.mozilla.org/en-US/docs/Web/CSS/:user-invalid) and [
|
|
277
|
+
`:user-valid`](https://developer.mozilla.org/en-US/docs/Web/CSS/:user-valid).
|
|
278
|
+
|
|
279
|
+
:::tip
|
|
280
|
+
In the future, data attributes will be replaced with custom pseudo classes such as `:--valid` and `:--invalid`. Zinc is
|
|
281
|
+
using data attributes as a workaround until browsers support custom states through [
|
|
282
|
+
`ElementInternals.states`](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/states).
|
|
283
|
+
:::
|
|
284
|
+
|
|
285
|
+
### Styling Invalid Form Controls
|
|
286
|
+
|
|
287
|
+
You can target validity using any of the aforementioned data attributes, but it's usually preferable to target
|
|
288
|
+
`data-user-invalid` and `data-user-valid` since they get applied only after a user interaction such as typing or
|
|
289
|
+
submitting. This prevents empty form controls from appearing invalid immediately, which often results in a poor user
|
|
290
|
+
experience.
|
|
291
|
+
|
|
292
|
+
This example demonstrates custom validation styles using `data-user-invalid` and `data-user-valid`. Try Typing in the
|
|
293
|
+
fields to see how validity changes with user input.
|
|
294
|
+
|
|
295
|
+
```html:preview
|
|
296
|
+
<form class="validity-styles">
|
|
297
|
+
<zn-input
|
|
298
|
+
name="name"
|
|
299
|
+
label="Name"
|
|
300
|
+
help-text="What would you like people to call you?"
|
|
301
|
+
autocomplete="off"
|
|
302
|
+
required
|
|
303
|
+
>
|
|
304
|
+
<input type="text" id="text" name="text">
|
|
305
|
+
</zn-input>
|
|
306
|
+
|
|
307
|
+
<zn-select name="animal" label="Favorite Animal" help-text="Select the best option." clearable required>
|
|
308
|
+
<zn-option value="birds">Birds</zn-option>
|
|
309
|
+
<zn-option value="cats">Cats</zn-option>
|
|
310
|
+
<zn-option value="dogs">Dogs</zn-option>
|
|
311
|
+
<zn-option value="other">Other</zn-option>
|
|
312
|
+
</zn-select>
|
|
313
|
+
<br /><br />
|
|
314
|
+
|
|
315
|
+
<zn-checkbox-group label="Checkbox group required" help-text="Select at least one" label-tooltip="Do you need help?" required>
|
|
316
|
+
<zn-checkbox value="I'm option 1">Option 1</zn-checkbox>
|
|
317
|
+
<zn-checkbox value="I'm option 2">Option 2</zn-checkbox>
|
|
318
|
+
<zn-checkbox value="I'm option 3">Option 3</zn-checkbox>
|
|
319
|
+
</zn-checkbox-group>
|
|
320
|
+
<br /><br />
|
|
321
|
+
|
|
322
|
+
<zn-checkbox-group label="Checkbox group optional" help-text="Select whatever" label-tooltip="Do you need help?">
|
|
323
|
+
<zn-checkbox value="I'm option 1">Option 1</zn-checkbox>
|
|
324
|
+
<zn-checkbox value="I'm option 2" checked>Option 2</zn-checkbox>
|
|
325
|
+
<zn-checkbox value="I'm option 3">Option 3</zn-checkbox>
|
|
326
|
+
</zn-checkbox-group>
|
|
327
|
+
<br /><br />
|
|
328
|
+
|
|
329
|
+
<zn-checkbox value="accept" required>Accept terms and conditions</zn-checkbox>
|
|
330
|
+
|
|
331
|
+
<zn-button type="submit" variant="primary">Submit</zn-button>
|
|
332
|
+
<zn-button type="reset" variant="default">Reset</zn-button>
|
|
333
|
+
</form>
|
|
334
|
+
|
|
335
|
+
<script type="module">
|
|
336
|
+
const form = document.querySelector('.validity-styles');
|
|
337
|
+
|
|
338
|
+
// Wait for controls to be defined before attaching form listeners
|
|
339
|
+
await Promise.all([
|
|
340
|
+
customElements.whenDefined('zn-button'),
|
|
341
|
+
customElements.whenDefined('zn-checkbox'),
|
|
342
|
+
customElements.whenDefined('zn-input'),
|
|
343
|
+
customElements.whenDefined('zn-option'),
|
|
344
|
+
customElements.whenDefined('zn-select')
|
|
345
|
+
]).then(() => {
|
|
346
|
+
form.addEventListener('submit', event => {
|
|
347
|
+
event.preventDefault();
|
|
348
|
+
alert('All fields are valid!');
|
|
349
|
+
});
|
|
350
|
+
});
|
|
351
|
+
</script>
|
|
352
|
+
|
|
353
|
+
<style>
|
|
354
|
+
.validity-styles zn-input,
|
|
355
|
+
.validity-styles zn-select,
|
|
356
|
+
.validity-styles zn-checkbox {
|
|
357
|
+
display: block;
|
|
358
|
+
margin-bottom: var(--zn-spacing-medium);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/* user invalid styles */
|
|
362
|
+
.validity-styles zn-input[data-user-invalid]::part(base),
|
|
363
|
+
.validity-styles zn-select[data-user-invalid]::part(combobox),
|
|
364
|
+
.validity-styles zn-checkbox[data-user-invalid]::part(control) {
|
|
365
|
+
border-color: var(--zn-color-danger-600);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
.validity-styles [data-user-invalid]::part(form-control-label),
|
|
369
|
+
.validity-styles [data-user-invalid]::part(form-control-help-text),
|
|
370
|
+
.validity-styles zn-checkbox[data-user-invalid]::part(label) {
|
|
371
|
+
color: var(--zn-color-danger-700);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
.validity-styles zn-checkbox[data-user-invalid]::part(control) {
|
|
375
|
+
outline: none;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
.validity-styles zn-input:focus-within[data-user-invalid]::part(base),
|
|
379
|
+
.validity-styles zn-select:focus-within[data-user-invalid]::part(combobox),
|
|
380
|
+
.validity-styles zn-checkbox:focus-within[data-user-invalid]::part(control) {
|
|
381
|
+
border-color: var(--zn-color-danger-600);
|
|
382
|
+
box-shadow: 0 0 0 var(--zn-focus-ring-width) var(--zn-color-danger-300);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/* User valid styles */
|
|
386
|
+
.validity-styles zn-input[data-user-valid]::part(base),
|
|
387
|
+
.validity-styles zn-select[data-user-valid]::part(combobox),
|
|
388
|
+
.validity-styles zn-checkbox[data-user-valid]::part(control) {
|
|
389
|
+
border-color: var(--zn-color-success-600);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
.validity-styles [data-user-valid]::part(form-control-label),
|
|
393
|
+
.validity-styles [data-user-valid]::part(form-control-help-text),
|
|
394
|
+
.validity-styles zn-checkbox[data-user-valid]::part(label) {
|
|
395
|
+
color: var(--zn-color-success-700);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
.validity-styles zn-checkbox[data-user-valid]::part(control) {
|
|
399
|
+
background-color: var(--zn-color-success-600);
|
|
400
|
+
outline: none;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
.validity-styles zn-input:focus-within[data-user-valid]::part(base),
|
|
404
|
+
.validity-styles zn-select:focus-within[data-user-valid]::part(combobox),
|
|
405
|
+
.validity-styles zn-checkbox:focus-within[data-user-valid]::part(control) {
|
|
406
|
+
border-color: var(--zn-color-success-600);
|
|
407
|
+
box-shadow: 0 0 0 var(--zn-focus-ring-width) var(--zn-color-success-300);
|
|
408
|
+
}
|
|
409
|
+
</style>
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
## Inline Form Validation
|
|
413
|
+
|
|
414
|
+
By default, Zinc form controls use the browser's tooltip-style error messages. No mechanism is provided to show errors
|
|
415
|
+
inline, as there are too many opinions on how that would work when combined with native form controls and other custom
|
|
416
|
+
elements. You can, however, implement your own solution using the following technique.
|
|
417
|
+
|
|
418
|
+
To disable the browser's error messages, you need to cancel the `zn-invalid` event. Then you can apply your own inline
|
|
419
|
+
validation errors. This example demonstrates a primitive way to do this.
|
|
420
|
+
|
|
421
|
+
```html:preview
|
|
422
|
+
<form class="inline-validation">
|
|
423
|
+
<zn-input
|
|
424
|
+
name="name"
|
|
425
|
+
label="Name"
|
|
426
|
+
help-text="What would you like people to call you?"
|
|
427
|
+
autocomplete="off"
|
|
428
|
+
required
|
|
429
|
+
>
|
|
430
|
+
<input type="text" id="text" name="text" />
|
|
431
|
+
</zn-input>
|
|
432
|
+
<div id="name-error" aria-live="polite" hidden></div>
|
|
433
|
+
|
|
434
|
+
<zn-button type="submit" variant="primary">Submit</zn-button>
|
|
435
|
+
<zn-button type="reset" variant="default">Reset</zn-button>
|
|
436
|
+
</form>
|
|
437
|
+
|
|
438
|
+
<script type="module">
|
|
439
|
+
const form = document.querySelector('.inline-validation');
|
|
440
|
+
const nameError = document.querySelector('#name-error');
|
|
441
|
+
|
|
442
|
+
// Wait for controls to be defined before attaching form listeners
|
|
443
|
+
await Promise.all([
|
|
444
|
+
customElements.whenDefined('zn-button'),
|
|
445
|
+
customElements.whenDefined('zn-input')
|
|
446
|
+
]).then(() => {
|
|
447
|
+
// A form control is invalid
|
|
448
|
+
form.addEventListener(
|
|
449
|
+
'zn-invalid',
|
|
450
|
+
event => {
|
|
451
|
+
// Suppress the browser's constraint validation message
|
|
452
|
+
event.preventDefault();
|
|
453
|
+
|
|
454
|
+
nameError.textContent = `Error: ${event.target.validationMessage}`;
|
|
455
|
+
nameError.hidden = false;
|
|
456
|
+
|
|
457
|
+
event.target.focus();
|
|
458
|
+
},
|
|
459
|
+
{ capture: true } // you must use capture since zn-invalid doesn't bubble!
|
|
460
|
+
);
|
|
461
|
+
|
|
462
|
+
// Handle form submit
|
|
463
|
+
form.addEventListener('submit', event => {
|
|
464
|
+
event.preventDefault();
|
|
465
|
+
nameError.hidden = true;
|
|
466
|
+
nameError.textContent = '';
|
|
467
|
+
setTimeout(() => alert('All fields are valid'), 50);
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
// Handle form reset
|
|
471
|
+
form.addEventListener('reset', event => {
|
|
472
|
+
nameError.hidden = true;
|
|
473
|
+
nameError.textContent = '';
|
|
474
|
+
});
|
|
475
|
+
});
|
|
476
|
+
</script>
|
|
477
|
+
|
|
478
|
+
<style>
|
|
479
|
+
#name-error {
|
|
480
|
+
font-size: var(--zn-input-help-text-font-size-medium);
|
|
481
|
+
color: var(--zn-color-danger-700);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
#name-error ~ zn-button {
|
|
485
|
+
margin-top: var(--zn-spacing-medium);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
.inline-validation zn-input {
|
|
489
|
+
display: block;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/* user invalid styles */
|
|
493
|
+
.inline-validation zn-input[data-user-invalid]::part(base) {
|
|
494
|
+
border-color: var(--zn-color-danger-600);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
.inline-validation [data-user-invalid]::part(form-control-label),
|
|
498
|
+
.inline-validation [data-user-invalid]::part(form-control-help-text) {
|
|
499
|
+
color: var(--zn-color-danger-700);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
.inline-validation zn-input:focus-within[data-user-invalid]::part(base) {
|
|
503
|
+
border-color: var(--zn-color-danger-600);
|
|
504
|
+
box-shadow: 0 0 0 var(--zn-focus-ring-width) var(--zn-color-danger-300);
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
/* User valid styles */
|
|
508
|
+
.inline-validation zn-input[data-user-valid]::part(base) {
|
|
509
|
+
border-color: var(--zn-color-success-600);
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
.inline-validation [data-user-valid]::part(form-control-label),
|
|
513
|
+
.inline-validation [data-user-valid]::part(form-control-help-text) {
|
|
514
|
+
color: var(--zn-color-success-700);
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
.inline-validation zn-input:focus-within[data-user-valid]::part(base) {
|
|
518
|
+
border-color: var(--zn-color-success-600);
|
|
519
|
+
box-shadow: 0 0 0 var(--zn-focus-ring-width) var(--zn-color-success-300);
|
|
520
|
+
}
|
|
521
|
+
</style>
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
:::warning
|
|
525
|
+
This example is meant to demonstrate the concept of providing your own error messages inline. It is not intended to
|
|
526
|
+
scale to more complex forms. Users who want this functionality are encouraged to build a more appropriate validation
|
|
527
|
+
solution using the techniques shown below. Depending on how you implement this feature, custom error messages may affect
|
|
528
|
+
the accessibility of your form controls.
|
|
529
|
+
:::
|
|
530
|
+
|
|
531
|
+
## Getting Associated Form Controls
|
|
532
|
+
|
|
533
|
+
At this time, using [
|
|
534
|
+
`HTMLFormElement.elements`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/elements) will not return
|
|
535
|
+
Zinc form controls because the browser is unaware of their status as custom element form controls. Fortunately, Zinc
|
|
536
|
+
provides an `elements()` function that does something very similar. However, instead of returning an [
|
|
537
|
+
`HTMLFormControlsCollection`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormControlsCollection), it returns
|
|
538
|
+
an array of HTML and Zinc form controls in the order they appear in the DOM.
|
|
539
|
+
|
|
540
|
+
```js
|
|
541
|
+
import {getFormControls} from '@kubex/zinc/dist/utilities/form.js';
|
|
542
|
+
|
|
543
|
+
const form = document.querySelector('#my-form');
|
|
544
|
+
const formControls = getFormControls(form);
|
|
545
|
+
|
|
546
|
+
console.log(formControls); // e.g. [input, zn-input, ...]
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
:::tip
|
|
550
|
+
You probably don't need this function! If you're gathering form data for submission, you probably want to
|
|
551
|
+
use [Data Serialization](#data-serializing) instead.
|
|
552
|
+
:::
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
---
|
|
2
|
+
meta:
|
|
3
|
+
title: Form Examples
|
|
4
|
+
description: Examples of forms using Zinc components.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Form Examples
|
|
8
|
+
|
|
9
|
+
### Example Profile Form
|
|
10
|
+
|
|
11
|
+
This example demonstrates a simple profile form using Zinc form controls. The form includes a text input, a select
|
|
12
|
+
input,
|
|
13
|
+
|
|
14
|
+
:::tip
|
|
15
|
+
You can also wrap the form component in `<div class="form-spacing">` to give some automatic spacing between the
|
|
16
|
+
components.
|
|
17
|
+
:::
|
|
18
|
+
|
|
19
|
+
```html:preview
|
|
20
|
+
|
|
21
|
+
<form class="input-validation-required" action="" method="post">
|
|
22
|
+
<zn-sp pad-y divide gap="md">
|
|
23
|
+
<zn-form-group
|
|
24
|
+
label="Profile"
|
|
25
|
+
label-tooltip="huh"
|
|
26
|
+
help-text="This information will be displayed publicly so be careful what you share">
|
|
27
|
+
|
|
28
|
+
<zn-input type="text" name="name" label="Name" help-text="Hello World" required></zn-input>
|
|
29
|
+
<zn-select label="Favorite Animal" clearable required>
|
|
30
|
+
<zn-option value="birds">Birds</zn-option>
|
|
31
|
+
<zn-option value="cats">Cats</zn-option>
|
|
32
|
+
<zn-option value="dogs">Dogs</zn-option>
|
|
33
|
+
<zn-option value="other">Other</zn-option>
|
|
34
|
+
</zn-select>
|
|
35
|
+
|
|
36
|
+
<zn-textarea name="comment" label="Comment" required></zn-textarea>
|
|
37
|
+
|
|
38
|
+
<zn-checkbox required>Check me before submitting</zn-checkbox>
|
|
39
|
+
|
|
40
|
+
<zn-checkbox-group label="Checkbox group" help-text="Select at least one" label-tooltip="Do you need help?"
|
|
41
|
+
required>
|
|
42
|
+
<zn-checkbox value="I'm option 1">Option 1</zn-checkbox>
|
|
43
|
+
<zn-checkbox value="I'm option 2">Option 2</zn-checkbox>
|
|
44
|
+
<zn-checkbox value="I'm option 3">Option 3</zn-checkbox>
|
|
45
|
+
</zn-checkbox-group>
|
|
46
|
+
|
|
47
|
+
</zn-form-group>
|
|
48
|
+
|
|
49
|
+
<zn-form-group
|
|
50
|
+
label="Profile"
|
|
51
|
+
label-tooltip="huh"
|
|
52
|
+
help-text="This information will be displayed publicly so be careful what you share">
|
|
53
|
+
|
|
54
|
+
<zn-input name="name" label="Name" required>
|
|
55
|
+
<input type="text" id="text" name="text">
|
|
56
|
+
</zn-input>
|
|
57
|
+
|
|
58
|
+
<zn-select label="Favorite Animal" clearable required>
|
|
59
|
+
<zn-option value="birds">Birds</zn-option>
|
|
60
|
+
<zn-option value="cats">Cats</zn-option>
|
|
61
|
+
<zn-option value="dogs">Dogs</zn-option>
|
|
62
|
+
<zn-option value="other">Other</zn-option>
|
|
63
|
+
</zn-select>
|
|
64
|
+
|
|
65
|
+
<zn-textarea name="comment" label="Comment" required></zn-textarea>
|
|
66
|
+
|
|
67
|
+
<zn-checkbox required>Check me before submitting</zn-checkbox>
|
|
68
|
+
|
|
69
|
+
<zn-checkbox-group label="Checkbox group" help-text="Select at least one" label-tooltip="Do you need help?"
|
|
70
|
+
required>
|
|
71
|
+
<zn-checkbox value="I'm option 1">Option 1</zn-checkbox>
|
|
72
|
+
<zn-checkbox value="I'm option 2">Option 2</zn-checkbox>
|
|
73
|
+
<zn-checkbox value="I'm option 3">Option 3</zn-checkbox>
|
|
74
|
+
</zn-checkbox-group>
|
|
75
|
+
|
|
76
|
+
<zn-button type="submit" variant="primary">Submit</zn-button>
|
|
77
|
+
</zn-form-group>
|
|
78
|
+
</zn-sp>
|
|
79
|
+
</form>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Example Form With Columns
|
|
83
|
+
|
|
84
|
+
If you want more control of the appearance of your form, you can add the class `.form-spacing` around any elements you
|
|
85
|
+
want to control with the atrribute `span="x"`
|
|
86
|
+
|
|
87
|
+
```html:preview
|
|
88
|
+
|
|
89
|
+
<form class="input-validation-required">
|
|
90
|
+
<zn-form-group
|
|
91
|
+
label="Profile"
|
|
92
|
+
label-tooltip="huh"
|
|
93
|
+
help-text="This information will be displayed publicly so be careful what you share">
|
|
94
|
+
<zn-input type="text" name="name" label="Name" required></zn-input>
|
|
95
|
+
|
|
96
|
+
<zn-select span="3" label="Favorite Animal" clearable required>
|
|
97
|
+
<zn-option value="birds">Birds</zn-option>
|
|
98
|
+
<zn-option value="cats">Cats</zn-option>
|
|
99
|
+
<zn-option value="dogs">Dogs</zn-option>
|
|
100
|
+
<zn-option value="other">Other</zn-option>
|
|
101
|
+
</zn-select>
|
|
102
|
+
|
|
103
|
+
<zn-select span="3" label="Favorite Bird" clearable required>
|
|
104
|
+
<zn-option value="crow">Crow</zn-option>
|
|
105
|
+
<zn-option value="pidgeon">Pidgeon</zn-option>
|
|
106
|
+
<zn-option value="hawk">Hawk</zn-option>
|
|
107
|
+
<zn-option value="owl">Owl</zn-option>
|
|
108
|
+
</zn-select>
|
|
109
|
+
|
|
110
|
+
<zn-textarea name="comment" label="Comment" required></zn-textarea>
|
|
111
|
+
|
|
112
|
+
<zn-checkbox required>Check me before submitting</zn-checkbox>
|
|
113
|
+
|
|
114
|
+
<zn-checkbox-group label="Checkbox group" help-text="Select at least one" label-tooltip="Do you need help?"
|
|
115
|
+
required>
|
|
116
|
+
<zn-checkbox value="I'm option 1">Option 1</zn-checkbox>
|
|
117
|
+
<zn-checkbox value="I'm option 2">Option 2</zn-checkbox>
|
|
118
|
+
<zn-checkbox value="I'm option 3">Option 3</zn-checkbox>
|
|
119
|
+
</zn-checkbox-group>
|
|
120
|
+
</zn-form-group>
|
|
121
|
+
</form>
|
|
122
|
+
```
|