@six-group/ui-library 0.0.0-insider.db2b416 → 0.0.0-insider.ddecb41
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/README.md +9 -0
- package/dist/cjs/{form-control-d369af14.js → form-control-9769b310.js} +10 -7
- package/dist/cjs/form-control-9769b310.js.map +1 -0
- package/dist/cjs/index-900437fc.js +214 -1
- package/dist/cjs/index-900437fc.js.map +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{scroll-03678de1.js → scroll-2c4200dc.js} +1 -2
- package/dist/cjs/scroll-2c4200dc.js.map +1 -0
- package/dist/cjs/six-button.cjs.entry.js +3 -3
- package/dist/cjs/six-button.cjs.entry.js.map +1 -1
- package/dist/cjs/six-checkbox.cjs.entry.js +8 -13
- package/dist/cjs/six-checkbox.cjs.entry.js.map +1 -1
- package/dist/cjs/six-datepicker.cjs.entry.js +5 -8
- package/dist/cjs/six-datepicker.cjs.entry.js.map +1 -1
- package/dist/cjs/six-details.cjs.entry.js +1 -1
- package/dist/cjs/six-details.cjs.entry.js.map +1 -1
- package/dist/cjs/six-dialog.cjs.entry.js +1 -1
- package/dist/cjs/six-drawer.cjs.entry.js +2 -2
- package/dist/cjs/six-drawer.cjs.entry.js.map +1 -1
- package/dist/cjs/six-dropdown_2.cjs.entry.js +1 -1
- package/dist/cjs/six-dropdown_2.cjs.entry.js.map +1 -1
- package/dist/cjs/six-error.cjs.entry.js +21 -0
- package/dist/cjs/six-error.cjs.entry.js.map +1 -0
- package/dist/cjs/six-group-label.cjs.entry.js +2 -2
- package/dist/cjs/six-group-label.cjs.entry.js.map +1 -1
- package/dist/cjs/six-icon-button.cjs.entry.js +1 -1
- package/dist/cjs/six-icon-button.cjs.entry.js.map +1 -1
- package/dist/cjs/six-input.cjs.entry.js +6 -3
- package/dist/cjs/six-input.cjs.entry.js.map +1 -1
- package/dist/cjs/six-radio.cjs.entry.js +9 -17
- package/dist/cjs/six-radio.cjs.entry.js.map +1 -1
- package/dist/cjs/six-range.cjs.entry.js +6 -3
- package/dist/cjs/six-range.cjs.entry.js.map +1 -1
- package/dist/cjs/six-select.cjs.entry.js +12 -8
- package/dist/cjs/six-select.cjs.entry.js.map +1 -1
- package/dist/cjs/six-sidebar-item-group.cjs.entry.js +2 -1
- package/dist/cjs/six-sidebar-item-group.cjs.entry.js.map +1 -1
- package/dist/cjs/six-sidebar.cjs.entry.js +1 -1
- package/dist/cjs/six-switch.cjs.entry.js +25 -5
- package/dist/cjs/six-switch.cjs.entry.js.map +1 -1
- package/dist/cjs/six-tab-group.cjs.entry.js +45 -50
- package/dist/cjs/six-tab-group.cjs.entry.js.map +1 -1
- package/dist/cjs/six-tab.cjs.entry.js +19 -3
- package/dist/cjs/six-tab.cjs.entry.js.map +1 -1
- package/dist/cjs/six-tag.cjs.entry.js +24 -2
- package/dist/cjs/six-tag.cjs.entry.js.map +1 -1
- package/dist/cjs/six-textarea.cjs.entry.js +6 -3
- package/dist/cjs/six-textarea.cjs.entry.js.map +1 -1
- package/dist/cjs/six-timepicker.cjs.entry.js +4 -9
- package/dist/cjs/six-timepicker.cjs.entry.js.map +1 -1
- package/dist/cjs/six-tooltip.cjs.entry.js +2 -2
- package/dist/cjs/six-tooltip.cjs.entry.js.map +1 -1
- package/dist/cjs/ui-library.cjs.js +2 -2
- package/dist/cjs/ui-library.cjs.js.map +1 -1
- package/dist/collection/collection-manifest.json +2 -1
- package/dist/collection/components/six-button/six-button.css +5 -30
- package/dist/collection/components/six-button/six-button.js +2 -2
- package/dist/collection/components/six-button/six-button.js.map +1 -1
- package/dist/collection/components/six-checkbox/six-checkbox.css +1 -1
- package/dist/collection/components/six-checkbox/six-checkbox.js +27 -31
- package/dist/collection/components/six-checkbox/six-checkbox.js.map +1 -1
- package/dist/collection/components/six-checkbox/test/six-checkbox.spec.js +6 -2
- package/dist/collection/components/six-checkbox/test/six-checkbox.spec.js.map +1 -1
- package/dist/collection/components/six-datepicker/six-datepicker.js +25 -12
- package/dist/collection/components/six-datepicker/six-datepicker.js.map +1 -1
- package/dist/collection/components/six-datepicker/test/six-datepicker.spec.js +1 -1
- package/dist/collection/components/six-datepicker/test/six-datepicker.spec.js.map +1 -1
- package/dist/collection/components/six-details/six-details.css +3 -1
- package/dist/collection/components/six-drawer/six-drawer.js +1 -1
- package/dist/collection/components/six-drawer/six-drawer.js.map +1 -1
- package/dist/collection/components/six-drawer/test/six-drawer.spec.js +1 -1
- package/dist/collection/components/six-drawer/test/six-drawer.spec.js.map +1 -1
- package/dist/collection/components/six-dropdown/six-dropdown.css +2 -1
- package/dist/collection/components/six-error/six-error.css +5 -0
- package/dist/collection/components/six-error/six-error.js +25 -0
- package/dist/collection/components/six-error/six-error.js.map +1 -0
- package/dist/collection/components/six-group-label/six-group-label.css +1 -1
- package/dist/collection/components/six-group-label/test/six-group-label.spec.js +3 -1
- package/dist/collection/components/six-group-label/test/six-group-label.spec.js.map +1 -1
- package/dist/collection/components/six-icon-button/six-icon-button.css +4 -4
- package/dist/collection/components/six-input/six-input.css +2 -2
- package/dist/collection/components/six-input/six-input.js +27 -4
- package/dist/collection/components/six-input/six-input.js.map +1 -1
- package/dist/collection/components/six-input/test/six-input.spec.js +3 -1
- package/dist/collection/components/six-input/test/six-input.spec.js.map +1 -1
- package/dist/collection/components/six-radio/six-radio.js +9 -34
- package/dist/collection/components/six-radio/six-radio.js.map +1 -1
- package/dist/collection/components/six-range/six-range.css +1 -1
- package/dist/collection/components/six-range/six-range.js +24 -3
- package/dist/collection/components/six-range/six-range.js.map +1 -1
- package/dist/collection/components/six-range/test/six-range.spec.js +3 -1
- package/dist/collection/components/six-range/test/six-range.spec.js.map +1 -1
- package/dist/collection/components/six-select/six-select.css +7 -10
- package/dist/collection/components/six-select/six-select.js +30 -8
- package/dist/collection/components/six-select/six-select.js.map +1 -1
- package/dist/collection/components/six-select/test/six-select.spec.js +8 -4
- package/dist/collection/components/six-select/test/six-select.spec.js.map +1 -1
- package/dist/collection/components/six-sidebar-item-group/six-sidebar-item-group.css +4 -0
- package/dist/collection/components/six-sidebar-item-group/six-sidebar-item-group.js +1 -0
- package/dist/collection/components/six-sidebar-item-group/six-sidebar-item-group.js.map +1 -1
- package/dist/collection/components/six-sidebar-item-group/test/six-sidebar-item-group.spec.js +2 -2
- package/dist/collection/components/six-sidebar-item-group/test/six-sidebar-item-group.spec.js.map +1 -1
- package/dist/collection/components/six-switch/six-switch.css +1 -1
- package/dist/collection/components/six-switch/six-switch.js +48 -5
- package/dist/collection/components/six-switch/six-switch.js.map +1 -1
- package/dist/collection/components/six-switch/test/six-switch.spec.js +6 -2
- package/dist/collection/components/six-switch/test/six-switch.spec.js.map +1 -1
- package/dist/collection/components/six-tab/six-tab.css +54 -5
- package/dist/collection/components/six-tab/six-tab.js +18 -2
- package/dist/collection/components/six-tab/six-tab.js.map +1 -1
- package/dist/collection/components/six-tab-group/six-tab-group.css +0 -31
- package/dist/collection/components/six-tab-group/six-tab-group.js +10 -51
- package/dist/collection/components/six-tab-group/six-tab-group.js.map +1 -1
- package/dist/collection/components/six-tag/six-tag.css +6 -0
- package/dist/collection/components/six-tag/six-tag.js +23 -1
- package/dist/collection/components/six-tag/six-tag.js.map +1 -1
- package/dist/collection/components/six-tag/test/six-tag.spec.js +12 -0
- package/dist/collection/components/six-tag/test/six-tag.spec.js.map +1 -1
- package/dist/collection/components/six-textarea/six-textarea.css +1 -1
- package/dist/collection/components/six-textarea/six-textarea.js +25 -4
- package/dist/collection/components/six-textarea/six-textarea.js.map +1 -1
- package/dist/collection/components/six-textarea/test/six-textarea.spec.js +3 -1
- package/dist/collection/components/six-textarea/test/six-textarea.spec.js.map +1 -1
- package/dist/collection/components/six-timepicker/six-timepicker.js +24 -12
- package/dist/collection/components/six-timepicker/six-timepicker.js.map +1 -1
- package/dist/collection/components/six-timepicker/test/six-timepicker.spec.js +15 -15
- package/dist/collection/components/six-timepicker/test/six-timepicker.spec.js.map +1 -1
- package/dist/collection/components/six-tooltip/six-tooltip.css +1 -1
- package/dist/collection/components/six-tooltip/six-tooltip.js +1 -1
- package/dist/collection/components/six-tooltip/six-tooltip.js.map +1 -1
- package/dist/collection/functional-components/form-control/form-control.js +8 -6
- package/dist/collection/functional-components/form-control/form-control.js.map +1 -1
- package/dist/collection/utils/animation.js +34 -0
- package/dist/collection/utils/animation.js.map +1 -0
- package/dist/components/form-control.js +9 -6
- package/dist/components/form-control.js.map +1 -1
- package/dist/components/index.js +2 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/scroll.js +1 -1
- package/dist/components/six-button.js +3 -3
- package/dist/components/six-button.js.map +1 -1
- package/dist/components/six-checkbox.js +17 -15
- package/dist/components/six-checkbox.js.map +1 -1
- package/dist/components/six-datepicker.js +13 -9
- package/dist/components/six-datepicker.js.map +1 -1
- package/dist/components/six-details2.js +1 -1
- package/dist/components/six-details2.js.map +1 -1
- package/dist/components/six-drawer.js +1 -1
- package/dist/components/six-drawer.js.map +1 -1
- package/dist/components/six-dropdown2.js +8 -2
- package/dist/components/six-dropdown2.js.map +1 -1
- package/dist/components/six-error.d.ts +11 -0
- package/dist/components/six-error.js +8 -0
- package/dist/components/six-error.js.map +1 -0
- package/dist/components/six-error2.js +32 -0
- package/dist/components/six-error2.js.map +1 -0
- package/dist/components/six-group-label.js +8 -2
- package/dist/components/six-group-label.js.map +1 -1
- package/dist/components/six-header.js +8 -2
- package/dist/components/six-header.js.map +1 -1
- package/dist/components/six-icon-button2.js +1 -1
- package/dist/components/six-icon-button2.js.map +1 -1
- package/dist/components/six-input2.js +14 -3
- package/dist/components/six-input2.js.map +1 -1
- package/dist/components/six-radio.js +10 -19
- package/dist/components/six-radio.js.map +1 -1
- package/dist/components/six-range.js +14 -3
- package/dist/components/six-range.js.map +1 -1
- package/dist/components/six-search-field.js +7 -1
- package/dist/components/six-search-field.js.map +1 -1
- package/dist/components/six-select.js +39 -21
- package/dist/components/six-select.js.map +1 -1
- package/dist/components/six-sidebar-item-group.js +2 -1
- package/dist/components/six-sidebar-item-group.js.map +1 -1
- package/dist/components/six-switch.js +33 -5
- package/dist/components/six-switch.js.map +1 -1
- package/dist/components/six-tab-group.js +45 -50
- package/dist/components/six-tab-group.js.map +1 -1
- package/dist/components/six-tab.js +19 -3
- package/dist/components/six-tab.js.map +1 -1
- package/dist/components/six-tag2.js +34 -6
- package/dist/components/six-tag2.js.map +1 -1
- package/dist/components/six-textarea.js +14 -3
- package/dist/components/six-textarea.js.map +1 -1
- package/dist/components/six-timepicker2.js +12 -10
- package/dist/components/six-timepicker2.js.map +1 -1
- package/dist/components/six-tooltip2.js +2 -2
- package/dist/components/six-tooltip2.js.map +1 -1
- package/dist/components.json +426 -100
- package/dist/esm/{form-control-32cb533f.js → form-control-b0febe88.js} +10 -7
- package/dist/esm/form-control-b0febe88.js.map +1 -0
- package/dist/esm/index-8a74f992.js +214 -1
- package/dist/esm/index-8a74f992.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{scroll-3fb087a2.js → scroll-774762d6.js} +2 -2
- package/dist/esm/{scroll-3fb087a2.js.map → scroll-774762d6.js.map} +1 -1
- package/dist/esm/six-button.entry.js +3 -3
- package/dist/esm/six-button.entry.js.map +1 -1
- package/dist/esm/six-checkbox.entry.js +8 -13
- package/dist/esm/six-checkbox.entry.js.map +1 -1
- package/dist/esm/six-datepicker.entry.js +5 -8
- package/dist/esm/six-datepicker.entry.js.map +1 -1
- package/dist/esm/six-details.entry.js +1 -1
- package/dist/esm/six-details.entry.js.map +1 -1
- package/dist/esm/six-dialog.entry.js +1 -1
- package/dist/esm/six-drawer.entry.js +2 -2
- package/dist/esm/six-drawer.entry.js.map +1 -1
- package/dist/esm/six-dropdown_2.entry.js +1 -1
- package/dist/esm/six-dropdown_2.entry.js.map +1 -1
- package/dist/esm/six-error.entry.js +17 -0
- package/dist/esm/six-error.entry.js.map +1 -0
- package/dist/esm/six-group-label.entry.js +2 -2
- package/dist/esm/six-group-label.entry.js.map +1 -1
- package/dist/esm/six-icon-button.entry.js +1 -1
- package/dist/esm/six-icon-button.entry.js.map +1 -1
- package/dist/esm/six-input.entry.js +6 -3
- package/dist/esm/six-input.entry.js.map +1 -1
- package/dist/esm/six-radio.entry.js +9 -17
- package/dist/esm/six-radio.entry.js.map +1 -1
- package/dist/esm/six-range.entry.js +6 -3
- package/dist/esm/six-range.entry.js.map +1 -1
- package/dist/esm/six-select.entry.js +12 -8
- package/dist/esm/six-select.entry.js.map +1 -1
- package/dist/esm/six-sidebar-item-group.entry.js +2 -1
- package/dist/esm/six-sidebar-item-group.entry.js.map +1 -1
- package/dist/esm/six-sidebar.entry.js +1 -1
- package/dist/esm/six-switch.entry.js +25 -5
- package/dist/esm/six-switch.entry.js.map +1 -1
- package/dist/esm/six-tab-group.entry.js +45 -50
- package/dist/esm/six-tab-group.entry.js.map +1 -1
- package/dist/esm/six-tab.entry.js +19 -3
- package/dist/esm/six-tab.entry.js.map +1 -1
- package/dist/esm/six-tag.entry.js +24 -2
- package/dist/esm/six-tag.entry.js.map +1 -1
- package/dist/esm/six-textarea.entry.js +6 -3
- package/dist/esm/six-textarea.entry.js.map +1 -1
- package/dist/esm/six-timepicker.entry.js +4 -9
- package/dist/esm/six-timepicker.entry.js.map +1 -1
- package/dist/esm/six-tooltip.entry.js +2 -2
- package/dist/esm/six-tooltip.entry.js.map +1 -1
- package/dist/esm/ui-library.js +2 -2
- package/dist/esm/ui-library.js.map +1 -1
- package/dist/types/components/six-checkbox/six-checkbox.d.ts +4 -5
- package/dist/types/components/six-datepicker/six-datepicker.d.ts +4 -2
- package/dist/types/components/six-error/six-error.d.ts +9 -0
- package/dist/types/components/six-input/six-input.d.ts +7 -2
- package/dist/types/components/six-radio/six-radio.d.ts +0 -5
- package/dist/types/components/six-range/six-range.d.ts +4 -1
- package/dist/types/components/six-select/six-select.d.ts +4 -1
- package/dist/types/components/six-switch/six-switch.d.ts +8 -1
- package/dist/types/components/six-tab-group/six-tab-group.d.ts +0 -3
- package/dist/types/components/six-tag/six-tag.d.ts +8 -0
- package/dist/types/components/six-textarea/six-textarea.d.ts +4 -1
- package/dist/types/components/six-timepicker/six-timepicker.d.ts +5 -2
- package/dist/types/components.d.ts +109 -24
- package/dist/types/functional-components/form-control/form-control.d.ts +6 -2
- package/dist/types/utils/animation.d.ts +12 -0
- package/dist/ui-library/{p-1f18768a.js → p-052aa8d3.js} +2 -2
- package/dist/ui-library/{p-da19c7ce.entry.js → p-14c1ec31.entry.js} +2 -2
- package/dist/ui-library/p-14c1ec31.entry.js.map +1 -0
- package/dist/ui-library/p-22c9b8c3.entry.js +2 -0
- package/dist/ui-library/p-22c9b8c3.entry.js.map +1 -0
- package/dist/ui-library/p-25bb1752.entry.js +2 -0
- package/dist/ui-library/p-25bb1752.entry.js.map +1 -0
- package/dist/ui-library/p-264d4ea8.entry.js +2 -0
- package/dist/ui-library/p-264d4ea8.entry.js.map +1 -0
- package/dist/ui-library/p-3f1a5ecb.entry.js +2 -0
- package/dist/ui-library/p-3f1a5ecb.entry.js.map +1 -0
- package/dist/ui-library/p-4435ff73.entry.js +2 -0
- package/dist/ui-library/p-4435ff73.entry.js.map +1 -0
- package/dist/ui-library/p-538f3c50.entry.js +2 -0
- package/dist/ui-library/p-538f3c50.entry.js.map +1 -0
- package/dist/ui-library/{p-330a4988.entry.js → p-5800663b.entry.js} +2 -2
- package/dist/ui-library/p-5ba3a0fe.entry.js +2 -0
- package/dist/ui-library/p-5ba3a0fe.entry.js.map +1 -0
- package/dist/ui-library/{p-99e24daf.entry.js → p-5ef2bdb3.entry.js} +2 -2
- package/dist/ui-library/{p-99e24daf.entry.js.map → p-5ef2bdb3.entry.js.map} +1 -1
- package/dist/ui-library/p-6153045b.js.map +1 -1
- package/dist/ui-library/p-658d9f79.entry.js +2 -0
- package/dist/ui-library/p-658d9f79.entry.js.map +1 -0
- package/dist/ui-library/p-66fe54b3.entry.js +2 -0
- package/dist/ui-library/p-66fe54b3.entry.js.map +1 -0
- package/dist/ui-library/p-a457fee8.entry.js +2 -0
- package/dist/ui-library/p-a457fee8.entry.js.map +1 -0
- package/dist/ui-library/p-ab91c2a9.entry.js +2 -0
- package/dist/ui-library/p-ab91c2a9.entry.js.map +1 -0
- package/dist/ui-library/p-b57afbe4.entry.js +2 -0
- package/dist/ui-library/p-b57afbe4.entry.js.map +1 -0
- package/dist/ui-library/p-b6f47c9d.entry.js +2 -0
- package/dist/ui-library/p-b6f47c9d.entry.js.map +1 -0
- package/dist/ui-library/p-cba69e9d.entry.js +2 -0
- package/dist/ui-library/p-cba69e9d.entry.js.map +1 -0
- package/dist/ui-library/{p-19ed7a4c.entry.js → p-d1bda563.entry.js} +2 -2
- package/dist/ui-library/p-db34a6cc.entry.js +2 -0
- package/dist/ui-library/p-db34a6cc.entry.js.map +1 -0
- package/dist/ui-library/p-db936ad7.entry.js +2 -0
- package/dist/ui-library/{p-d367f4f9.entry.js.map → p-db936ad7.entry.js.map} +1 -1
- package/dist/ui-library/p-dc4f41d8.entry.js +2 -0
- package/dist/ui-library/p-dc4f41d8.entry.js.map +1 -0
- package/dist/ui-library/p-e5020f0d.js +2 -0
- package/dist/ui-library/p-e5020f0d.js.map +1 -0
- package/dist/ui-library/p-e775dcb4.entry.js +2 -0
- package/dist/ui-library/p-e775dcb4.entry.js.map +1 -0
- package/dist/ui-library/p-f1dc3a88.entry.js +2 -0
- package/dist/ui-library/p-f1dc3a88.entry.js.map +1 -0
- package/dist/ui-library/ui-library.css +2 -2
- package/dist/ui-library/ui-library.esm.js +1 -1
- package/dist/ui-library/ui-library.esm.js.map +1 -1
- package/package.json +6 -3
- package/dist/cjs/form-control-d369af14.js.map +0 -1
- package/dist/cjs/scroll-03678de1.js.map +0 -1
- package/dist/collection/components/six-tab/test/six-tab.spec.js +0 -20
- package/dist/collection/components/six-tab/test/six-tab.spec.js.map +0 -1
- package/dist/collection/components/six-tab-group/test/six-tab-group.spec.js +0 -45
- package/dist/collection/components/six-tab-group/test/six-tab-group.spec.js.map +0 -1
- package/dist/esm/form-control-32cb533f.js.map +0 -1
- package/dist/ui-library/p-1256cc0a.entry.js +0 -2
- package/dist/ui-library/p-1256cc0a.entry.js.map +0 -1
- package/dist/ui-library/p-1730a174.entry.js +0 -2
- package/dist/ui-library/p-1730a174.entry.js.map +0 -1
- package/dist/ui-library/p-1d0bee53.entry.js +0 -2
- package/dist/ui-library/p-1d0bee53.entry.js.map +0 -1
- package/dist/ui-library/p-21b3b321.entry.js +0 -2
- package/dist/ui-library/p-21b3b321.entry.js.map +0 -1
- package/dist/ui-library/p-29ac3d7d.entry.js +0 -2
- package/dist/ui-library/p-29ac3d7d.entry.js.map +0 -1
- package/dist/ui-library/p-314b2096.entry.js +0 -2
- package/dist/ui-library/p-314b2096.entry.js.map +0 -1
- package/dist/ui-library/p-4705a51e.entry.js +0 -2
- package/dist/ui-library/p-4705a51e.entry.js.map +0 -1
- package/dist/ui-library/p-4abed9df.entry.js +0 -2
- package/dist/ui-library/p-4abed9df.entry.js.map +0 -1
- package/dist/ui-library/p-5d6b7353.entry.js +0 -2
- package/dist/ui-library/p-5d6b7353.entry.js.map +0 -1
- package/dist/ui-library/p-6eb24bcb.entry.js +0 -2
- package/dist/ui-library/p-6eb24bcb.entry.js.map +0 -1
- package/dist/ui-library/p-72254eef.entry.js +0 -2
- package/dist/ui-library/p-72254eef.entry.js.map +0 -1
- package/dist/ui-library/p-83864cfe.entry.js +0 -2
- package/dist/ui-library/p-83864cfe.entry.js.map +0 -1
- package/dist/ui-library/p-cf49252a.entry.js +0 -2
- package/dist/ui-library/p-cf49252a.entry.js.map +0 -1
- package/dist/ui-library/p-d367f4f9.entry.js +0 -2
- package/dist/ui-library/p-d42c2025.js +0 -2
- package/dist/ui-library/p-d42c2025.js.map +0 -1
- package/dist/ui-library/p-da19c7ce.entry.js.map +0 -1
- package/dist/ui-library/p-e0b13ad3.entry.js +0 -2
- package/dist/ui-library/p-e0b13ad3.entry.js.map +0 -1
- package/dist/ui-library/p-ee8342e1.entry.js +0 -2
- package/dist/ui-library/p-ee8342e1.entry.js.map +0 -1
- package/dist/ui-library/p-f1eb03ba.entry.js +0 -2
- package/dist/ui-library/p-f1eb03ba.entry.js.map +0 -1
- package/dist/ui-library/p-ff90ffd1.entry.js +0 -2
- package/dist/ui-library/p-ff90ffd1.entry.js.map +0 -1
- package/readme.md +0 -156
- /package/dist/ui-library/{p-1f18768a.js.map → p-052aa8d3.js.map} +0 -0
- /package/dist/ui-library/{p-330a4988.entry.js.map → p-5800663b.entry.js.map} +0 -0
- /package/dist/ui-library/{p-19ed7a4c.entry.js.map → p-d1bda563.entry.js.map} +0 -0
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
}
|
|
15
15
|
.form-control .form-control__error-text {
|
|
16
16
|
display: none;
|
|
17
|
+
text-align: left;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
.form-control--has-label .form-control__label {
|
|
@@ -56,7 +57,6 @@
|
|
|
56
57
|
|
|
57
58
|
.form-control--has-error-text .form-control__error-text {
|
|
58
59
|
display: block;
|
|
59
|
-
color: var(--six-color-danger-800);
|
|
60
60
|
margin-top: var(--six-spacing-xxx-small);
|
|
61
61
|
}
|
|
62
62
|
.form-control--has-error-text .form-control__error-text ::slotted(*) {
|
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
.input__control {
|
|
148
148
|
flex: 1 1 auto;
|
|
149
149
|
font-family: inherit;
|
|
150
|
-
font-size:
|
|
150
|
+
font-size: inherit;
|
|
151
151
|
font-weight: inherit;
|
|
152
152
|
min-width: 0;
|
|
153
153
|
color: var(--six-input-color);
|
|
@@ -22,9 +22,10 @@ let id = 0;
|
|
|
22
22
|
* @slot show-password-icon - An icon to use in lieu of the default show password icon.
|
|
23
23
|
* @slot hide-password-icon - An icon to use in lieu of the default hide password icon.
|
|
24
24
|
* @slot help-text - Help text that describes how to use the input. Alternatively, you can use the help-text prop.
|
|
25
|
+
* @slot error-text - Error text that is shown when the status is set to invalid. Alternatively, you can use the error-text prop.
|
|
25
26
|
*
|
|
26
27
|
* @part base - The component's base wrapper.
|
|
27
|
-
* @part form-control - The form control that wraps the label, input, and help-text.
|
|
28
|
+
* @part form-control - The form control that wraps the label, input, error-text and help-text.
|
|
28
29
|
* @part label - The input label.
|
|
29
30
|
* @part input - The input control.
|
|
30
31
|
* @part prefix - The input prefix container.
|
|
@@ -32,6 +33,7 @@ let id = 0;
|
|
|
32
33
|
* @part password-toggle-button - The password toggle button.
|
|
33
34
|
* @part suffix - The input suffix container.
|
|
34
35
|
* @part help-text - The input help text.
|
|
36
|
+
* @part error-text - The input error text.
|
|
35
37
|
*/
|
|
36
38
|
export class SixInput {
|
|
37
39
|
constructor() {
|
|
@@ -88,10 +90,12 @@ export class SixInput {
|
|
|
88
90
|
this.handleSlotChange = () => {
|
|
89
91
|
this.hasHelpTextSlot = hasSlot(this.host, 'help-text');
|
|
90
92
|
this.hasLabelSlot = hasSlot(this.host, 'label');
|
|
93
|
+
this.hasErrorSlot = hasSlot(this.host, 'error-text');
|
|
91
94
|
};
|
|
92
95
|
this.hasFocus = false;
|
|
93
96
|
this.hasHelpTextSlot = false;
|
|
94
97
|
this.hasLabelSlot = false;
|
|
98
|
+
this.hasErrorSlot = false;
|
|
95
99
|
this.isPasswordVisible = false;
|
|
96
100
|
this.type = 'text';
|
|
97
101
|
this.size = 'medium';
|
|
@@ -116,6 +120,7 @@ export class SixInput {
|
|
|
116
120
|
this.spellcheck = false;
|
|
117
121
|
this.label = '';
|
|
118
122
|
this.errorText = '';
|
|
123
|
+
this.errorTextCount = undefined;
|
|
119
124
|
this.invalid = false;
|
|
120
125
|
this.clearable = false;
|
|
121
126
|
this.togglePassword = false;
|
|
@@ -184,7 +189,7 @@ export class SixInput {
|
|
|
184
189
|
return ((_a = this.value) !== null && _a !== void 0 ? _a : '').toString();
|
|
185
190
|
}
|
|
186
191
|
render() {
|
|
187
|
-
return (h(FormControl, { inputId: this.inputId, label: this.label, labelId: this.labelId, hasLabelSlot: this.hasLabelSlot, helpTextId: this.helpTextId, helpText: this.helpText, hasHelpTextSlot: this.hasHelpTextSlot, errorTextId: this.errorTextId, errorText: this.errorText, size: this.size, disabled: this.disabled, required: this.required, displayError: this.invalid }, h("div", { part: "base", class: {
|
|
192
|
+
return (h(FormControl, { inputId: this.inputId, label: this.label, labelId: this.labelId, hasLabelSlot: this.hasLabelSlot, helpTextId: this.helpTextId, helpText: this.helpText, hasHelpTextSlot: this.hasHelpTextSlot, errorTextId: this.errorTextId, errorText: this.errorText, errorTextCount: this.errorTextCount, hasErrorTextSlot: this.hasErrorSlot, size: this.size, disabled: this.disabled, required: this.required, displayError: this.invalid }, h("div", { part: "base", class: {
|
|
188
193
|
input: true,
|
|
189
194
|
// Sizes
|
|
190
195
|
'input--small': this.size === 'small',
|
|
@@ -609,8 +614,8 @@ export class SixInput {
|
|
|
609
614
|
"type": "string",
|
|
610
615
|
"mutable": false,
|
|
611
616
|
"complexType": {
|
|
612
|
-
"original": "string",
|
|
613
|
-
"resolved": "string",
|
|
617
|
+
"original": "string | string[]",
|
|
618
|
+
"resolved": "string | string[]",
|
|
614
619
|
"references": {}
|
|
615
620
|
},
|
|
616
621
|
"required": false,
|
|
@@ -623,6 +628,23 @@ export class SixInput {
|
|
|
623
628
|
"reflect": false,
|
|
624
629
|
"defaultValue": "''"
|
|
625
630
|
},
|
|
631
|
+
"errorTextCount": {
|
|
632
|
+
"type": "number",
|
|
633
|
+
"mutable": false,
|
|
634
|
+
"complexType": {
|
|
635
|
+
"original": "number",
|
|
636
|
+
"resolved": "number | undefined",
|
|
637
|
+
"references": {}
|
|
638
|
+
},
|
|
639
|
+
"required": false,
|
|
640
|
+
"optional": true,
|
|
641
|
+
"docs": {
|
|
642
|
+
"tags": [],
|
|
643
|
+
"text": "The number of error texts to be shown (if the error-text slot isn't used). Defaults to 1"
|
|
644
|
+
},
|
|
645
|
+
"attribute": "error-text-count",
|
|
646
|
+
"reflect": false
|
|
647
|
+
},
|
|
626
648
|
"invalid": {
|
|
627
649
|
"type": "boolean",
|
|
628
650
|
"mutable": false,
|
|
@@ -719,6 +741,7 @@ export class SixInput {
|
|
|
719
741
|
"hasFocus": {},
|
|
720
742
|
"hasHelpTextSlot": {},
|
|
721
743
|
"hasLabelSlot": {},
|
|
744
|
+
"hasErrorSlot": {},
|
|
722
745
|
"isPasswordVisible": {}
|
|
723
746
|
};
|
|
724
747
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"six-input.js","sourceRoot":"","sources":["../../../src/components/six-input/six-input.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACvG,OAAO,WAAW,MAAM,uDAAuD,CAAC;AAChF,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,UAAU,GAAwE;EACtF,KAAK,EAAE,QAAQ;EACf,MAAM,EAAE,OAAO;EACf,KAAK,EAAE,QAAQ;CAChB,CAAC;AAEF,IAAI,EAAE,GAAG,CAAC,CAAC;AAEX;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAOH,MAAM,OAAO,QAAQ;;IACX,YAAO,GAAG,SAAS,EAAE,EAAE,EAAE,CAAC;IAC1B,YAAO,GAAG,eAAe,EAAE,EAAE,CAAC;IAC9B,eAAU,GAAG,mBAAmB,EAAE,EAAE,CAAC;IACrC,gBAAW,GAAG,oBAAoB,EAAE,EAAE,CAAC;IAEvC,mBAAc,GAAG,IAAI,cAAc,EAAE,CAAC;IA2LtC,iBAAY,GAAG,CAAC,KAAY,EAAE,EAAE;MACtC,KAAK,CAAC,eAAe,EAAE,CAAC;MACxB,IAAI,IAAI,CAAC,WAAW,IAAI,IAAI,EAAE;QAC5B,IAAI,CAAC,KAAK,GAAG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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, EventEmitter, h, Method, Prop, State, Watch } from '@stencil/core';\nimport FormControl from '../../functional-components/form-control/form-control';\nimport { hasSlot } from '../../utils/slot';\nimport { EmptyPayload } from '../../utils/types';\nimport { EventListeners } from '../../utils/event-listeners';\nimport { submitForm } from '../../utils/form';\n\nconst ICON_SIZES: Record<'small' | 'medium' | 'large', 'xSmall' | 'small' | 'medium'> = {\n large: 'medium',\n medium: 'small',\n small: 'xSmall',\n};\n\nlet id = 0;\n\n/**\n * @since 1.0\n * @status stable\n *\n * Forked from https://github.com/shoelace-style/shoelace version v2.0.0-beta27.\n *\n * @slot label - The input's label. Alternatively, you can use the label prop.\n * @slot prefix - Used to prepend an icon or similar element to the input.\n * @slot suffix - Used to append an icon or similar element to the input.\n * @slot clear-icon - An icon to use in lieu of the default clear icon.\n * @slot show-password-icon - An icon to use in lieu of the default show password icon.\n * @slot hide-password-icon - An icon to use in lieu of the default hide password icon.\n * @slot help-text - Help text that describes how to use the input. Alternatively, you can use the help-text prop.\n *\n * @part base - The component's base wrapper.\n * @part form-control - The form control that wraps the label, input, and help-text.\n * @part label - The input label.\n * @part input - The input control.\n * @part prefix - The input prefix container.\n * @part clear-button - The clear button.\n * @part password-toggle-button - The password toggle button.\n * @part suffix - The input suffix container.\n * @part help-text - The input help text.\n */\n\n@Component({\n tag: 'six-input',\n styleUrl: 'six-input.scss',\n shadow: true,\n})\nexport class SixInput {\n private inputId = `input-${++id}`;\n private labelId = `input-label-${id}`;\n private helpTextId = `input-help-text-${id}`;\n private errorTextId = `input-error-text-${id}`;\n private nativeInput?: HTMLInputElement;\n private eventListeners = new EventListeners();\n\n @Element() host!: HTMLSixInputElement;\n\n @State() hasFocus = false;\n @State() hasHelpTextSlot = false;\n @State() hasLabelSlot = false;\n @State() isPasswordVisible = false;\n\n /** The input's type. */\n @Prop({ reflect: true }) type: 'email' | 'number' | 'password' | 'search' | 'tel' | 'text' | 'url' = 'text';\n\n /** The input's size. */\n @Prop({ reflect: true }) size: 'small' | 'medium' | 'large' = 'medium';\n\n /** The input's name attribute. */\n @Prop({ reflect: true }) name = '';\n\n /** The input's value attribute. */\n @Prop({ mutable: true, reflect: true }) value = '';\n\n /** Set to true to draw a pill-style input with rounded edges. */\n @Prop({ reflect: true }) pill = false;\n\n /** The input's help text. Alternatively, you can use the help-text slot. */\n @Prop() helpText = '';\n\n /** The input's placeholder text. */\n @Prop() placeholder?: string;\n\n /** Set to true to disable the input. */\n @Prop({ reflect: true }) disabled = false;\n\n /** Set to true to make the input readonly. */\n @Prop({ reflect: true }) readonly = false;\n\n /** The minimum length of input that will be considered valid. */\n @Prop({ reflect: true }) minlength?: number;\n\n /** The maximum length of input that will be considered valid. */\n @Prop({ reflect: true }) maxlength?: number;\n\n /** The input's minimum value. */\n @Prop({ reflect: true }) min?: number;\n\n /** The input's maximum value. */\n @Prop({ reflect: true }) max?: number;\n\n /** The input's step attribute. */\n @Prop({ reflect: true }) step?: number;\n\n /** A pattern to validate input against. */\n @Prop({ reflect: true }) pattern?: string;\n\n /** Set to true to show an asterisk beneath the label. */\n @Prop() required = false;\n\n /** The input's autocaptialize attribute. */\n @Prop() autocapitalize = 'off';\n\n /** The input's autocorrect attribute. */\n @Prop() autocorrect: 'on' | 'off' = 'off';\n\n /** The input's autocomplete attribute. */\n @Prop() autocomplete = 'off';\n\n /** The input's autofocus attribute. */\n @Prop() autofocus = false;\n\n /** Enables spell checking on the input. */\n @Prop() spellcheck = false;\n\n /** The label text. */\n @Prop() label = '';\n\n /** The error message shown, if `invalid` is set to true. */\n @Prop() errorText = '';\n\n /** If this property is set to true and an error message is provided by `errorText`, the error message is displayed. */\n @Prop({ reflect: true }) invalid = false;\n\n /** Set to true to add a clear button when the input is populated. */\n @Prop() clearable = false;\n\n /** Set to true to add a password toggle button for password inputs. */\n @Prop() togglePassword = false;\n\n /** The input's inputmode attribute. */\n @Prop() inputmode?: 'none' | 'text' | 'decimal' | 'numeric' | 'tel' | 'search' | 'email' | 'url';\n\n /** Set to render as line */\n @Prop() line = false;\n\n @Watch('helpText')\n @Watch('errorText')\n @Watch('label')\n handleLabelChange() {\n this.handleSlotChange();\n }\n\n @Watch('value')\n handleValueChange() {\n this.value = this.getValue();\n if (this.nativeInput != null && this.nativeInput.value !== this.value) {\n this.nativeInput.value = this.value;\n }\n }\n\n /** Emitted when the control's value changes. Access the new value via event.target.value. */\n @Event({ eventName: 'six-input-change' }) sixChange!: EventEmitter<EmptyPayload>;\n\n /** Emitted when the clear button is activated. */\n @Event({ eventName: 'six-input-clear' }) sixClear!: EventEmitter<EmptyPayload>;\n\n /** Emitted when the control receives input. Access the new value via event.target.value. */\n @Event({ eventName: 'six-input-input' }) sixInput!: EventEmitter<EmptyPayload>;\n\n /** Emitted when the control gains focus. */\n @Event({ eventName: 'six-input-focus' }) sixFocus!: EventEmitter<EmptyPayload>;\n\n /** Emitted when the control loses focus. Access the new value via event.target.value. */\n @Event({ eventName: 'six-input-blur' }) sixBlur!: EventEmitter<EmptyPayload>;\n\n connectedCallback() {\n this.host.shadowRoot?.addEventListener('slotchange', this.handleSlotChange);\n this.eventListeners.forward('six-input-input', 'input', this.host);\n this.eventListeners.forward('six-input-change', 'change', this.host);\n this.eventListeners.forward('six-input-focus', 'focus', this.host);\n this.eventListeners.forward('six-input-blur', 'blur', this.host);\n }\n\n componentWillLoad() {\n this.handleSlotChange();\n }\n\n disconnectedCallback() {\n this.host.shadowRoot?.removeEventListener('slotchange', this.handleSlotChange);\n this.eventListeners.removeAll();\n }\n\n /** Sets focus on the input. */\n @Method()\n async setFocus(options?: FocusOptions) {\n this.nativeInput?.focus(options);\n }\n\n /** Removes focus from the input. */\n @Method()\n async removeFocus() {\n this.nativeInput?.blur();\n }\n\n /** Selects all the text in the input. */\n @Method()\n async select() {\n return this.nativeInput?.select();\n }\n\n /** Sets the start and end positions of the text selection (0-based). */\n @Method()\n async setSelectionRange(\n selectionStart: number,\n selectionEnd: number,\n selectionDirection: 'forward' | 'backward' | 'none' = 'none'\n ) {\n return this.nativeInput?.setSelectionRange(selectionStart, selectionEnd, selectionDirection);\n }\n\n /** Replaces a range of text with a new string. */\n @Method()\n async setRangeText(\n replacement: string,\n start: number,\n end: number,\n selectMode: 'select' | 'start' | 'end' | 'preserve' = 'preserve'\n ) {\n if (this.nativeInput == null) {\n return;\n }\n this.nativeInput.setRangeText(replacement, start, end, selectMode);\n if (this.getValue() !== this.nativeInput.value) {\n this.value = this.nativeInput.value;\n this.sixChange.emit();\n this.sixInput.emit();\n }\n }\n\n private handleChange = (event: Event) => {\n event.stopPropagation();\n if (this.nativeInput != null) {\n this.value = this.nativeInput.value;\n this.sixChange.emit();\n }\n };\n\n private handleInput = (event: Event) => {\n event.stopPropagation();\n if (this.nativeInput != null) {\n this.value = this.nativeInput.value;\n this.sixInput.emit();\n }\n };\n\n private handleBlur = () => {\n this.hasFocus = false;\n this.sixBlur.emit();\n };\n\n private handleFocus = () => {\n this.hasFocus = true;\n this.sixFocus.emit();\n };\n\n private handleClearClick = (event: MouseEvent) => {\n this.value = '';\n this.sixClear.emit();\n this.sixInput.emit();\n this.sixChange.emit();\n if (this.nativeInput != null) {\n this.nativeInput.focus();\n }\n event.stopPropagation();\n };\n\n private handleKeyDown = (event: KeyboardEvent) => {\n const hasModifier = event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;\n if (event.key === 'Enter' && !hasModifier) {\n setTimeout(() => {\n if (!event.defaultPrevented && !event.isComposing) {\n submitForm(this.host);\n }\n });\n }\n };\n\n private handlePasswordToggle = () => {\n this.isPasswordVisible = !this.isPasswordVisible;\n };\n\n private handleSlotChange = () => {\n this.hasHelpTextSlot = hasSlot(this.host, 'help-text');\n this.hasLabelSlot = hasSlot(this.host, 'label');\n };\n\n private getValue(): string {\n return (this.value ?? '').toString();\n }\n\n render() {\n return (\n <FormControl\n inputId={this.inputId}\n label={this.label}\n labelId={this.labelId}\n hasLabelSlot={this.hasLabelSlot}\n helpTextId={this.helpTextId}\n helpText={this.helpText}\n hasHelpTextSlot={this.hasHelpTextSlot}\n errorTextId={this.errorTextId}\n errorText={this.errorText}\n size={this.size}\n disabled={this.disabled}\n required={this.required}\n displayError={this.invalid}\n >\n <div\n part=\"base\"\n class={{\n input: true,\n\n // Sizes\n 'input--small': this.size === 'small',\n 'input--medium': this.size === 'medium',\n 'input--large': this.size === 'large',\n\n // States\n 'input--line': this.line,\n 'input--pill': this.pill,\n 'input--disabled': this.disabled,\n 'input--focused': this.hasFocus,\n 'input--empty': this.getValue().length === 0,\n 'input--invalid': this.invalid,\n }}\n >\n <span part=\"prefix\" class=\"input__prefix\">\n <slot name=\"prefix\" />\n </span>\n\n <input\n part=\"input\"\n ref={(el) => (this.nativeInput = el)}\n id={this.inputId}\n size={1} // needed for firefox to overrule the default of 20\n class={{\n input__control: true,\n input__control__prefix: hasSlot(this.host, 'prefix'),\n }}\n type={this.type === 'password' && this.isPasswordVisible ? 'text' : this.type}\n name={this.name}\n placeholder={this.placeholder}\n disabled={this.disabled}\n readonly={this.readonly}\n minLength={this.minlength}\n maxLength={this.maxlength}\n min={this.min}\n max={this.max}\n step={this.step}\n value={this.getValue()}\n autoCapitalize={this.autocapitalize}\n autoComplete={this.autocomplete}\n autoCorrect={this.autocorrect}\n autoFocus={this.autofocus}\n spellcheck={this.spellcheck}\n pattern={this.pattern}\n required={this.required}\n inputMode={this.inputmode}\n aria-labelledby={this.labelId}\n aria-describedby={this.helpTextId}\n aria-invalid={this.invalid ? 'true' : 'false'}\n onChange={this.handleChange}\n onInput={this.handleInput}\n onFocus={this.handleFocus}\n onBlur={this.handleBlur}\n onKeyDown={this.handleKeyDown}\n data-testid=\"input-control\"\n />\n\n {this.clearable && (\n <button\n part=\"clear-button\"\n class=\"input__clear\"\n type=\"button\"\n onClick={this.handleClearClick}\n tabindex=\"-1\"\n data-testid=\"input-clear-button\"\n >\n <slot name=\"clear-icon\">\n <six-icon size={ICON_SIZES[this.size]}>clear</six-icon>\n </slot>\n </button>\n )}\n\n {this.togglePassword && (\n <button\n part=\"password-toggle-button\"\n class=\"input__password-toggle\"\n type=\"button\"\n onClick={this.handlePasswordToggle}\n tabindex=\"-1\"\n >\n {this.isPasswordVisible ? (\n <slot name=\"show-password-icon\">\n <six-icon size={ICON_SIZES[this.size]}>visibility_off</six-icon>\n </slot>\n ) : (\n <slot name=\"hide-password-icon\">\n <six-icon size={ICON_SIZES[this.size]}>visibility</six-icon>\n </slot>\n )}\n </button>\n )}\n\n <span part=\"suffix\" class=\"input__suffix\">\n <slot name=\"suffix\" />\n </span>\n </div>\n </FormControl>\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"six-input.js","sourceRoot":"","sources":["../../../src/components/six-input/six-input.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACvG,OAAO,WAAW,MAAM,uDAAuD,CAAC;AAChF,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,UAAU,GAAwE;EACtF,KAAK,EAAE,QAAQ;EACf,MAAM,EAAE,OAAO;EACf,KAAK,EAAE,QAAQ;CAChB,CAAC;AAEF,IAAI,EAAE,GAAG,CAAC,CAAC;AAEX;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAOH,MAAM,OAAO,QAAQ;;IACX,YAAO,GAAG,SAAS,EAAE,EAAE,EAAE,CAAC;IAC1B,YA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, EventEmitter, h, Method, Prop, State, Watch } from '@stencil/core';\nimport FormControl from '../../functional-components/form-control/form-control';\nimport { hasSlot } from '../../utils/slot';\nimport { EmptyPayload } from '../../utils/types';\nimport { EventListeners } from '../../utils/event-listeners';\nimport { submitForm } from '../../utils/form';\n\nconst ICON_SIZES: Record<'small' | 'medium' | 'large', 'xSmall' | 'small' | 'medium'> = {\n large: 'medium',\n medium: 'small',\n small: 'xSmall',\n};\n\nlet id = 0;\n\n/**\n * @since 1.0\n * @status stable\n *\n * Forked from https://github.com/shoelace-style/shoelace version v2.0.0-beta27.\n *\n * @slot label - The input's label. Alternatively, you can use the label prop.\n * @slot prefix - Used to prepend an icon or similar element to the input.\n * @slot suffix - Used to append an icon or similar element to the input.\n * @slot clear-icon - An icon to use in lieu of the default clear icon.\n * @slot show-password-icon - An icon to use in lieu of the default show password icon.\n * @slot hide-password-icon - An icon to use in lieu of the default hide password icon.\n * @slot help-text - Help text that describes how to use the input. Alternatively, you can use the help-text prop.\n * @slot error-text - Error text that is shown when the status is set to invalid. Alternatively, you can use the error-text prop.\n *\n * @part base - The component's base wrapper.\n * @part form-control - The form control that wraps the label, input, error-text and help-text.\n * @part label - The input label.\n * @part input - The input control.\n * @part prefix - The input prefix container.\n * @part clear-button - The clear button.\n * @part password-toggle-button - The password toggle button.\n * @part suffix - The input suffix container.\n * @part help-text - The input help text.\n * @part error-text - The input error text.\n */\n\n@Component({\n tag: 'six-input',\n styleUrl: 'six-input.scss',\n shadow: true,\n})\nexport class SixInput {\n private inputId = `input-${++id}`;\n private labelId = `input-label-${id}`;\n private helpTextId = `input-help-text-${id}`;\n private errorTextId = `input-error-text-${id}`;\n private nativeInput?: HTMLInputElement;\n private eventListeners = new EventListeners();\n\n @Element() host!: HTMLSixInputElement;\n\n @State() hasFocus = false;\n @State() hasHelpTextSlot = false;\n @State() hasLabelSlot = false;\n @State() hasErrorSlot = false;\n @State() isPasswordVisible = false;\n\n /** The input's type. */\n @Prop({ reflect: true }) type: 'email' | 'number' | 'password' | 'search' | 'tel' | 'text' | 'url' = 'text';\n\n /** The input's size. */\n @Prop({ reflect: true }) size: 'small' | 'medium' | 'large' = 'medium';\n\n /** The input's name attribute. */\n @Prop({ reflect: true }) name = '';\n\n /** The input's value attribute. */\n @Prop({ mutable: true, reflect: true }) value = '';\n\n /** Set to true to draw a pill-style input with rounded edges. */\n @Prop({ reflect: true }) pill = false;\n\n /** The input's help text. Alternatively, you can use the help-text slot. */\n @Prop() helpText = '';\n\n /** The input's placeholder text. */\n @Prop() placeholder?: string;\n\n /** Set to true to disable the input. */\n @Prop({ reflect: true }) disabled = false;\n\n /** Set to true to make the input readonly. */\n @Prop({ reflect: true }) readonly = false;\n\n /** The minimum length of input that will be considered valid. */\n @Prop({ reflect: true }) minlength?: number;\n\n /** The maximum length of input that will be considered valid. */\n @Prop({ reflect: true }) maxlength?: number;\n\n /** The input's minimum value. */\n @Prop({ reflect: true }) min?: number;\n\n /** The input's maximum value. */\n @Prop({ reflect: true }) max?: number;\n\n /** The input's step attribute. */\n @Prop({ reflect: true }) step?: number;\n\n /** A pattern to validate input against. */\n @Prop({ reflect: true }) pattern?: string;\n\n /** Set to true to show an asterisk beneath the label. */\n @Prop() required = false;\n\n /** The input's autocaptialize attribute. */\n @Prop() autocapitalize = 'off';\n\n /** The input's autocorrect attribute. */\n @Prop() autocorrect: 'on' | 'off' = 'off';\n\n /** The input's autocomplete attribute. */\n @Prop() autocomplete = 'off';\n\n /** The input's autofocus attribute. */\n @Prop() autofocus = false;\n\n /** Enables spell checking on the input. */\n @Prop() spellcheck = false;\n\n /** The label text. */\n @Prop() label = '';\n\n /** The error message shown, if `invalid` is set to true. */\n @Prop() errorText: string | string[] = '';\n\n /** The number of error texts to be shown (if the error-text slot isn't used). Defaults to 1 */\n @Prop() errorTextCount?: number;\n\n /** If this property is set to true and an error message is provided by `errorText`, the error message is displayed. */\n @Prop({ reflect: true }) invalid = false;\n\n /** Set to true to add a clear button when the input is populated. */\n @Prop() clearable = false;\n\n /** Set to true to add a password toggle button for password inputs. */\n @Prop() togglePassword = false;\n\n /** The input's inputmode attribute. */\n @Prop() inputmode?: 'none' | 'text' | 'decimal' | 'numeric' | 'tel' | 'search' | 'email' | 'url';\n\n /** Set to render as line */\n @Prop() line = false;\n\n @Watch('helpText')\n @Watch('errorText')\n @Watch('label')\n handleLabelChange() {\n this.handleSlotChange();\n }\n\n @Watch('value')\n handleValueChange() {\n this.value = this.getValue();\n if (this.nativeInput != null && this.nativeInput.value !== this.value) {\n this.nativeInput.value = this.value;\n }\n }\n\n /** Emitted when the control's value changes. Access the new value via event.target.value. */\n @Event({ eventName: 'six-input-change' }) sixChange!: EventEmitter<EmptyPayload>;\n\n /** Emitted when the clear button is activated. */\n @Event({ eventName: 'six-input-clear' }) sixClear!: EventEmitter<EmptyPayload>;\n\n /** Emitted when the control receives input. Access the new value via event.target.value. */\n @Event({ eventName: 'six-input-input' }) sixInput!: EventEmitter<EmptyPayload>;\n\n /** Emitted when the control gains focus. */\n @Event({ eventName: 'six-input-focus' }) sixFocus!: EventEmitter<EmptyPayload>;\n\n /** Emitted when the control loses focus. Access the new value via event.target.value. */\n @Event({ eventName: 'six-input-blur' }) sixBlur!: EventEmitter<EmptyPayload>;\n\n connectedCallback() {\n this.host.shadowRoot?.addEventListener('slotchange', this.handleSlotChange);\n this.eventListeners.forward('six-input-input', 'input', this.host);\n this.eventListeners.forward('six-input-change', 'change', this.host);\n this.eventListeners.forward('six-input-focus', 'focus', this.host);\n this.eventListeners.forward('six-input-blur', 'blur', this.host);\n }\n\n componentWillLoad() {\n this.handleSlotChange();\n }\n\n disconnectedCallback() {\n this.host.shadowRoot?.removeEventListener('slotchange', this.handleSlotChange);\n this.eventListeners.removeAll();\n }\n\n /** Sets focus on the input. */\n @Method()\n async setFocus(options?: FocusOptions) {\n this.nativeInput?.focus(options);\n }\n\n /** Removes focus from the input. */\n @Method()\n async removeFocus() {\n this.nativeInput?.blur();\n }\n\n /** Selects all the text in the input. */\n @Method()\n async select() {\n return this.nativeInput?.select();\n }\n\n /** Sets the start and end positions of the text selection (0-based). */\n @Method()\n async setSelectionRange(\n selectionStart: number,\n selectionEnd: number,\n selectionDirection: 'forward' | 'backward' | 'none' = 'none'\n ) {\n return this.nativeInput?.setSelectionRange(selectionStart, selectionEnd, selectionDirection);\n }\n\n /** Replaces a range of text with a new string. */\n @Method()\n async setRangeText(\n replacement: string,\n start: number,\n end: number,\n selectMode: 'select' | 'start' | 'end' | 'preserve' = 'preserve'\n ) {\n if (this.nativeInput == null) {\n return;\n }\n this.nativeInput.setRangeText(replacement, start, end, selectMode);\n if (this.getValue() !== this.nativeInput.value) {\n this.value = this.nativeInput.value;\n this.sixChange.emit();\n this.sixInput.emit();\n }\n }\n\n private handleChange = (event: Event) => {\n event.stopPropagation();\n if (this.nativeInput != null) {\n this.value = this.nativeInput.value;\n this.sixChange.emit();\n }\n };\n\n private handleInput = (event: Event) => {\n event.stopPropagation();\n if (this.nativeInput != null) {\n this.value = this.nativeInput.value;\n this.sixInput.emit();\n }\n };\n\n private handleBlur = () => {\n this.hasFocus = false;\n this.sixBlur.emit();\n };\n\n private handleFocus = () => {\n this.hasFocus = true;\n this.sixFocus.emit();\n };\n\n private handleClearClick = (event: MouseEvent) => {\n this.value = '';\n this.sixClear.emit();\n this.sixInput.emit();\n this.sixChange.emit();\n if (this.nativeInput != null) {\n this.nativeInput.focus();\n }\n event.stopPropagation();\n };\n\n private handleKeyDown = (event: KeyboardEvent) => {\n const hasModifier = event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;\n if (event.key === 'Enter' && !hasModifier) {\n setTimeout(() => {\n if (!event.defaultPrevented && !event.isComposing) {\n submitForm(this.host);\n }\n });\n }\n };\n\n private handlePasswordToggle = () => {\n this.isPasswordVisible = !this.isPasswordVisible;\n };\n\n private handleSlotChange = () => {\n this.hasHelpTextSlot = hasSlot(this.host, 'help-text');\n this.hasLabelSlot = hasSlot(this.host, 'label');\n this.hasErrorSlot = hasSlot(this.host, 'error-text');\n };\n\n private getValue(): string {\n return (this.value ?? '').toString();\n }\n\n render() {\n return (\n <FormControl\n inputId={this.inputId}\n label={this.label}\n labelId={this.labelId}\n hasLabelSlot={this.hasLabelSlot}\n helpTextId={this.helpTextId}\n helpText={this.helpText}\n hasHelpTextSlot={this.hasHelpTextSlot}\n errorTextId={this.errorTextId}\n errorText={this.errorText}\n errorTextCount={this.errorTextCount}\n hasErrorTextSlot={this.hasErrorSlot}\n size={this.size}\n disabled={this.disabled}\n required={this.required}\n displayError={this.invalid}\n >\n <div\n part=\"base\"\n class={{\n input: true,\n\n // Sizes\n 'input--small': this.size === 'small',\n 'input--medium': this.size === 'medium',\n 'input--large': this.size === 'large',\n\n // States\n 'input--line': this.line,\n 'input--pill': this.pill,\n 'input--disabled': this.disabled,\n 'input--focused': this.hasFocus,\n 'input--empty': this.getValue().length === 0,\n 'input--invalid': this.invalid,\n }}\n >\n <span part=\"prefix\" class=\"input__prefix\">\n <slot name=\"prefix\" />\n </span>\n\n <input\n part=\"input\"\n ref={(el) => (this.nativeInput = el)}\n id={this.inputId}\n size={1} // needed for firefox to overrule the default of 20\n class={{\n input__control: true,\n input__control__prefix: hasSlot(this.host, 'prefix'),\n }}\n type={this.type === 'password' && this.isPasswordVisible ? 'text' : this.type}\n name={this.name}\n placeholder={this.placeholder}\n disabled={this.disabled}\n readonly={this.readonly}\n minLength={this.minlength}\n maxLength={this.maxlength}\n min={this.min}\n max={this.max}\n step={this.step}\n value={this.getValue()}\n autoCapitalize={this.autocapitalize}\n autoComplete={this.autocomplete}\n autoCorrect={this.autocorrect}\n autoFocus={this.autofocus}\n spellcheck={this.spellcheck}\n pattern={this.pattern}\n required={this.required}\n inputMode={this.inputmode}\n aria-labelledby={this.labelId}\n aria-describedby={this.helpTextId}\n aria-invalid={this.invalid ? 'true' : 'false'}\n onChange={this.handleChange}\n onInput={this.handleInput}\n onFocus={this.handleFocus}\n onBlur={this.handleBlur}\n onKeyDown={this.handleKeyDown}\n data-testid=\"input-control\"\n />\n\n {this.clearable && (\n <button\n part=\"clear-button\"\n class=\"input__clear\"\n type=\"button\"\n onClick={this.handleClearClick}\n tabindex=\"-1\"\n data-testid=\"input-clear-button\"\n >\n <slot name=\"clear-icon\">\n <six-icon size={ICON_SIZES[this.size]}>clear</six-icon>\n </slot>\n </button>\n )}\n\n {this.togglePassword && (\n <button\n part=\"password-toggle-button\"\n class=\"input__password-toggle\"\n type=\"button\"\n onClick={this.handlePasswordToggle}\n tabindex=\"-1\"\n >\n {this.isPasswordVisible ? (\n <slot name=\"show-password-icon\">\n <six-icon size={ICON_SIZES[this.size]}>visibility_off</six-icon>\n </slot>\n ) : (\n <slot name=\"hide-password-icon\">\n <six-icon size={ICON_SIZES[this.size]}>visibility</six-icon>\n </slot>\n )}\n </button>\n )}\n\n <span part=\"suffix\" class=\"input__suffix\">\n <slot name=\"suffix\" />\n </span>\n </div>\n </FormControl>\n );\n }\n}\n"]}
|
|
@@ -24,7 +24,9 @@ describe('six-input', () => {
|
|
|
24
24
|
</span>
|
|
25
25
|
</div>
|
|
26
26
|
</div>
|
|
27
|
-
<div aria-hidden="true" class="form-control__error-text" id="input-error-text-1" part="error-text"
|
|
27
|
+
<div aria-hidden="true" class="form-control__error-text" id="input-error-text-1" part="error-text">
|
|
28
|
+
<slot name="error-text"></slot>
|
|
29
|
+
</div>
|
|
28
30
|
<div aria-hidden="true" class="form-control__help-text" id="input-help-text-1" part="help-text">
|
|
29
31
|
<slot name="help-text"></slot>
|
|
30
32
|
</div>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"six-input.spec.js","sourceRoot":"","sources":["../../../../src/components/six-input/test/six-input.spec.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;EACzB,EAAE,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;IACvB,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;MAC7B,UAAU,EAAE,CAAC,QAAQ,CAAC;MACtB,IAAI,EAAE,yBAAyB;KAChC,CAAC,CAAC;IACH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC
|
|
1
|
+
{"version":3,"file":"six-input.spec.js","sourceRoot":"","sources":["../../../../src/components/six-input/test/six-input.spec.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;EACzB,EAAE,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;IACvB,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;MAC7B,UAAU,EAAE,CAAC,QAAQ,CAAC;MACtB,IAAI,EAAE,yBAAyB;KAChC,CAAC,CAAC;IACH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2B7B,CAAC,CAAC;EACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { newSpecPage } from '@stencil/core/testing';\nimport { SixInput } from '../six-input';\n\ndescribe('six-input', () => {\n it('renders', async () => {\n const page = await newSpecPage({\n components: [SixInput],\n html: `<six-input></six-input>`,\n });\n expect(page.root).toEqualHtml(`\n <six-input size=\"medium\" type=\"text\" value=\"\">\n <mock:shadow-root>\n <div class=\"form-control form-control--medium\" part=\"form-control\">\n <label aria-hidden=\"true\" class=\"form-control__label\" htmlfor=\"input-1\" id=\"input-label-1\" part=\"label\">\n <slot name=\"label\"></slot>\n </label>\n <div class=\"form-control__input\">\n <div class=\"input input--empty input--medium\" part=\"base\">\n <span class=\"input__prefix\" part=\"prefix\">\n <slot name=\"prefix\"></slot>\n </span>\n <input aria-describedby=\"input-help-text-1\" aria-invalid=\"false\" aria-labelledby=\"input-label-1\" autocapitalize=\"off\" autocomplete=\"off\" autocorrect=\"off\" class=\"input__control\" data-testid=\"input-control\" id=\"input-1\" part=\"input\" size=\"1\" type=\"text\" value=\"\">\n <span class=\"input__suffix\" part=\"suffix\">\n <slot name=\"suffix\"></slot>\n </span>\n </div>\n </div>\n <div aria-hidden=\"true\" class=\"form-control__error-text\" id=\"input-error-text-1\" part=\"error-text\">\n <slot name=\"error-text\"></slot>\n </div>\n <div aria-hidden=\"true\" class=\"form-control__help-text\" id=\"input-help-text-1\" part=\"help-text\">\n <slot name=\"help-text\"></slot>\n </div>\n </div>\n </mock:shadow-root>\n </six-input>\n `);\n });\n});\n"]}
|
|
@@ -19,11 +19,10 @@ export class SixRadio {
|
|
|
19
19
|
this.inputId = `radio-${++id}`;
|
|
20
20
|
this.labelId = `radio-label-${id}`;
|
|
21
21
|
this.eventListeners = new EventListeners();
|
|
22
|
-
/** default state whether the radio button should be checked or not when resetting */
|
|
23
|
-
this.defaultState = false;
|
|
24
22
|
this.handleClick = () => {
|
|
25
23
|
if (this.nativeInput != null) {
|
|
26
24
|
this.checked = this.nativeInput.checked;
|
|
25
|
+
this.sixChange.emit();
|
|
27
26
|
}
|
|
28
27
|
};
|
|
29
28
|
this.handleBlur = () => {
|
|
@@ -34,19 +33,20 @@ export class SixRadio {
|
|
|
34
33
|
this.hasFocus = true;
|
|
35
34
|
this.sixFocus.emit();
|
|
36
35
|
};
|
|
37
|
-
this.handleKeyDown = (
|
|
38
|
-
if (['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(
|
|
36
|
+
this.handleKeyDown = (keyboardEvent) => {
|
|
37
|
+
if (['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(keyboardEvent.key)) {
|
|
39
38
|
const radios = this.getAllRadios().filter((radio) => !radio.disabled);
|
|
40
|
-
const incr = ['ArrowUp', 'ArrowLeft'].includes(
|
|
39
|
+
const incr = ['ArrowUp', 'ArrowLeft'].includes(keyboardEvent.key) ? -1 : 1;
|
|
41
40
|
let index = radios.indexOf(this.host) + incr;
|
|
42
41
|
if (index < 0)
|
|
43
42
|
index = radios.length - 1;
|
|
44
43
|
if (index > radios.length - 1)
|
|
45
44
|
index = 0;
|
|
46
|
-
this.getAllRadios().
|
|
45
|
+
this.getAllRadios().forEach((radio) => (radio.checked = false));
|
|
47
46
|
radios[index].setFocus();
|
|
48
47
|
radios[index].checked = true;
|
|
49
|
-
|
|
48
|
+
radios[index].dispatchEvent(new CustomEvent('six-radio-change', { bubbles: true, cancelable: true }));
|
|
49
|
+
keyboardEvent.preventDefault();
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
this.handleMouseDown = (event) => {
|
|
@@ -64,11 +64,10 @@ export class SixRadio {
|
|
|
64
64
|
}
|
|
65
65
|
handleCheckedChange() {
|
|
66
66
|
if (this.checked) {
|
|
67
|
-
this.getSiblingRadios().
|
|
67
|
+
this.getSiblingRadios().forEach((radio) => (radio.checked = false));
|
|
68
68
|
}
|
|
69
69
|
if (this.nativeInput != null) {
|
|
70
70
|
this.nativeInput.checked = this.checked;
|
|
71
|
-
this.sixChange.emit();
|
|
72
71
|
}
|
|
73
72
|
}
|
|
74
73
|
handleNameChange(name) {
|
|
@@ -81,9 +80,6 @@ export class SixRadio {
|
|
|
81
80
|
this.eventListeners.forward('six-radio-blur', 'blur', this.host);
|
|
82
81
|
this.eventListeners.forward('six-radio-focus', 'focus', this.host);
|
|
83
82
|
}
|
|
84
|
-
componentWillLoad() {
|
|
85
|
-
this.defaultState = this.checked;
|
|
86
|
-
}
|
|
87
83
|
disconnectedCallback() {
|
|
88
84
|
this.eventListeners.removeAll();
|
|
89
85
|
}
|
|
@@ -97,12 +93,8 @@ export class SixRadio {
|
|
|
97
93
|
var _a;
|
|
98
94
|
(_a = this.nativeInput) === null || _a === void 0 ? void 0 : _a.blur();
|
|
99
95
|
}
|
|
100
|
-
/** Resets the formcontrol */
|
|
101
|
-
async reset() {
|
|
102
|
-
this.checked = this.defaultState;
|
|
103
|
-
}
|
|
104
96
|
getAllRadios() {
|
|
105
|
-
const form = this.host.closest('
|
|
97
|
+
const form = this.host.closest('form') || document.body;
|
|
106
98
|
if (this.name === '')
|
|
107
99
|
return [];
|
|
108
100
|
return [...form.querySelectorAll('six-radio')].filter((radio) => radio.name === this.name);
|
|
@@ -337,23 +329,6 @@ export class SixRadio {
|
|
|
337
329
|
"text": "Removes focus from the radio.",
|
|
338
330
|
"tags": []
|
|
339
331
|
}
|
|
340
|
-
},
|
|
341
|
-
"reset": {
|
|
342
|
-
"complexType": {
|
|
343
|
-
"signature": "() => Promise<void>",
|
|
344
|
-
"parameters": [],
|
|
345
|
-
"references": {
|
|
346
|
-
"Promise": {
|
|
347
|
-
"location": "global",
|
|
348
|
-
"id": "global::Promise"
|
|
349
|
-
}
|
|
350
|
-
},
|
|
351
|
-
"return": "Promise<void>"
|
|
352
|
-
},
|
|
353
|
-
"docs": {
|
|
354
|
-
"text": "Resets the formcontrol",
|
|
355
|
-
"tags": []
|
|
356
|
-
}
|
|
357
332
|
}
|
|
358
333
|
};
|
|
359
334
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"six-radio.js","sourceRoot":"","sources":["../../../src/components/six-radio/six-radio.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEvG,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,IAAI,EAAE,GAAG,CAAC,CAAC;AAEX;;;;;;;;;;;;GAYG;AAOH,MAAM,OAAO,QAAQ;;IACX,YAAO,GAAG,SAAS,EAAE,EAAE,EAAE,CAAC;IAC1B,YAAO,GAAG,eAAe,EAAE,EAAE,CAAC;IAE9B,mBAAc,GAAG,IAAI,cAAc,EAAE,CAAC;IAgD9C,qFAAqF;IAC7E,iBAAY,GAAG,KAAK,CAAC;IAgDrB,gBAAW,GAAG,GAAG,EAAE;MACzB,IAAI,IAAI,CAAC,WAAW,IAAI,IAAI,EAAE;QAC5B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;OACzC;IACH,CAAC,CAAC;IAEM,eAAU,GAAG,GAAG,EAAE;MACxB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;MACtB,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IACtB,CAAC,CAAC;IAEM,gBAAW,GAAG,GAAG,EAAE;MACzB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;MACrB,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;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,MAAM,eAAW,SAAS;cAC/D,SAAG,IAAI,EAAC,cAAc;gBACpB,cAAQ,EAAE,EAAC,GAAG,EAAC,EAAE,EAAC,GAAG,EAAC,CAAC,EAAC,GAAG,GAAU,CACnC,CACF,CACA,CACD;QAEP,aACE,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC,EACpC,EAAE,EAAE,IAAI,CAAC,OAAO,EAChB,IAAI,EAAC,OAAO,EACZ,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,IAAI,EAAC,OAAO,kBACE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,qBAC5B,IAAI,CAAC,OAAO,EAC7B,OAAO,EAAE,IAAI,CAAC,WAAW,EACzB,MAAM,EAAE,IAAI,CAAC,UAAU,EACvB,OAAO,EAAE,IAAI,CAAC,WAAW,GACzB,CACG;MAEP,YAAM,IAAI,EAAC,OAAO,EAAC,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,KAAK,EAAC,cAAc;QACvD,eAAQ,CACH,CACD,CACT,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, EventEmitter, h, Method, Prop, State, Watch } from '@stencil/core';\nimport { EmptyPayload } from '../../utils/types';\nimport { EventListeners } from '../../utils/event-listeners';\n\nlet id = 0;\n\n/**\n * @since 1.0\n * @status stable\n *\n * Forked from https://github.com/shoelace-style/shoelace version v2.0.0-beta27.\n *\n * @slot - The radio's label.\n *\n * @part base - The component's base wrapper.\n * @part control - The radio control.\n * @part checked-icon - The container the wraps the checked icon.\n * @part label - The radio label.\n */\n\n@Component({\n tag: 'six-radio',\n styleUrl: 'six-radio.scss',\n shadow: true,\n})\nexport class SixRadio {\n private inputId = `radio-${++id}`;\n private labelId = `radio-label-${id}`;\n private nativeInput?: HTMLInputElement;\n private eventListeners = new EventListeners();\n\n @Element() host!: HTMLSixRadioElement;\n\n @State() hasFocus = false;\n\n /** The radio's name attribute. */\n @Prop() name = '';\n\n /** The radio's value attribute. */\n @Prop({ reflect: true }) value = 'on';\n\n /** Set to true to disable the radio. */\n @Prop() disabled = false;\n\n /** Set to true to draw the radio in a checked state. */\n @Prop({ mutable: true, reflect: true }) checked = false;\n\n /** If this property is set to true and an error message is provided by `errorText`, the error message is displayed. */\n @Prop({ reflect: true }) invalid = false;\n\n @Watch('checked')\n handleCheckedChange() {\n if (this.checked) {\n this.getSiblingRadios().map((radio) => (radio.checked = false));\n }\n if (this.nativeInput != null) {\n this.nativeInput.checked = this.checked;\n this.sixChange.emit();\n }\n }\n\n @Watch('name')\n handleNameChange(name: string) {\n if (this.nativeInput != null) {\n this.nativeInput.name = name;\n }\n }\n\n /** Emitted when the control loses focus. */\n @Event({ eventName: 'six-radio-blur' }) sixBlur!: EventEmitter<EmptyPayload>;\n\n /** Emitted when the control's checked state changes. */\n @Event({ eventName: 'six-radio-change' }) sixChange!: EventEmitter<EmptyPayload>;\n\n /** Emitted when the control gains focus. */\n @Event({ eventName: 'six-radio-focus' }) sixFocus!: EventEmitter<EmptyPayload>;\n\n /** default state whether the radio button should be checked or not when resetting */\n private defaultState = false;\n\n connectedCallback() {\n this.eventListeners.forward('six-radio-change', 'change', this.host);\n this.eventListeners.forward('six-radio-blur', 'blur', this.host);\n this.eventListeners.forward('six-radio-focus', 'focus', this.host);\n }\n\n componentWillLoad() {\n this.defaultState = this.checked;\n }\n\n disconnectedCallback() {\n this.eventListeners.removeAll();\n }\n\n /** Sets focus on the radio. */\n @Method()\n async setFocus(options?: FocusOptions) {\n this.nativeInput?.focus(options);\n }\n\n /** Removes focus from the radio. */\n @Method()\n async removeFocus() {\n this.nativeInput?.blur();\n }\n\n /** Resets the formcontrol */\n @Method()\n async reset() {\n this.checked = this.defaultState;\n }\n\n private getAllRadios() {\n const form = this.host.closest('six-form, form') || document.body;\n\n if (this.name === '') return [];\n\n return [...form.querySelectorAll('six-radio')].filter(\n (radio: HTMLSixRadioElement) => radio.name === this.name\n ) as HTMLSixRadioElement[];\n }\n\n private getSiblingRadios() {\n return this.getAllRadios().filter((radio) => radio !== this.host) as HTMLSixRadioElement[];\n }\n\n private handleClick = () => {\n if (this.nativeInput != null) {\n this.checked = this.nativeInput.checked;\n }\n };\n\n private handleBlur = () => {\n this.hasFocus = false;\n this.sixBlur.emit();\n };\n\n private handleFocus = () => {\n this.hasFocus = true;\n this.sixFocus.emit();\n };\n\n private handleKeyDown = (event: KeyboardEvent) => {\n if (['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(event.key)) {\n const radios = this.getAllRadios().filter((radio) => !radio.disabled);\n const incr = ['ArrowUp', 'ArrowLeft'].includes(event.key) ? -1 : 1;\n let index = radios.indexOf(this.host) + incr;\n if (index < 0) index = radios.length - 1;\n if (index > radios.length - 1) index = 0;\n\n this.getAllRadios().map((radio) => (radio.checked = false));\n radios[index].setFocus();\n radios[index].checked = true;\n\n event.preventDefault();\n }\n };\n\n private handleMouseDown = (event: MouseEvent) => {\n // Prevent clicks on the label from briefly blurring the input\n event.preventDefault();\n this.nativeInput?.focus();\n };\n\n render() {\n return (\n <label\n part=\"base\"\n class={{\n radio: true,\n 'radio--checked': this.checked,\n 'radio--disabled': this.disabled,\n 'radio--focused': this.hasFocus,\n }}\n htmlFor={this.inputId}\n onKeyDown={this.handleKeyDown}\n onMouseDown={this.handleMouseDown}\n >\n <span part=\"control\" class=\"radio__control\">\n <span part=\"checked-icon\" class=\"radio__icon\">\n <svg viewBox=\"0 0 16 16\">\n <g stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\">\n <g fill=\"currentColor\">\n <circle cx=\"8\" cy=\"8\" r=\"5\"></circle>\n </g>\n </g>\n </svg>\n </span>\n\n <input\n ref={(el) => (this.nativeInput = el)}\n id={this.inputId}\n type=\"radio\"\n name={this.name}\n value={this.value}\n checked={this.checked}\n disabled={this.disabled}\n role=\"radio\"\n aria-checked={this.checked ? 'true' : 'false'}\n aria-labelledby={this.labelId}\n onClick={this.handleClick}\n onBlur={this.handleBlur}\n onFocus={this.handleFocus}\n />\n </span>\n\n <span part=\"label\" id={this.labelId} class=\"radio__label\">\n <slot />\n </span>\n </label>\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"six-radio.js","sourceRoot":"","sources":["../../../src/components/six-radio/six-radio.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEvG,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,IAAI,EAAE,GAAG,CAAC,CAAC;AAEX;;;;;;;;;;;;GAYG;AAOH,MAAM,OAAO,QAAQ;;IACX,YAAO,GAAG,SAAS,EAAE,EAAE,EAAE,CAAC;IAC1B,YAAO,GAAG,eAAe,EAAE,EAAE,CAAC;IAE9B,mBAAc,GAAG,IAAI,cAAc,EAAE,CAAC;IAmFtC,gBAAW,GAAG,GAAG,EAAE;MACzB,IAAI,IAAI,CAAC,WAAW,IAAI,IAAI,EAAE;QAC5B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;QACxC,IAAI,CAAC,SAAS,CAAC,IA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, EventEmitter, h, Method, Prop, State, Watch } from '@stencil/core';\nimport { EmptyPayload } from '../../utils/types';\nimport { EventListeners } from '../../utils/event-listeners';\n\nlet id = 0;\n\n/**\n * @since 1.0\n * @status stable\n *\n * Forked from https://github.com/shoelace-style/shoelace version v2.0.0-beta27.\n *\n * @slot - The radio's label.\n *\n * @part base - The component's base wrapper.\n * @part control - The radio control.\n * @part checked-icon - The container the wraps the checked icon.\n * @part label - The radio label.\n */\n\n@Component({\n tag: 'six-radio',\n styleUrl: 'six-radio.scss',\n shadow: true,\n})\nexport class SixRadio {\n private inputId = `radio-${++id}`;\n private labelId = `radio-label-${id}`;\n private nativeInput?: HTMLInputElement;\n private eventListeners = new EventListeners();\n\n @Element() host!: HTMLSixRadioElement;\n\n @State() hasFocus = false;\n\n /** The radio's name attribute. */\n @Prop() name = '';\n\n /** The radio's value attribute. */\n @Prop({ reflect: true }) value = 'on';\n\n /** Set to true to disable the radio. */\n @Prop() disabled = false;\n\n /** Set to true to draw the radio in a checked state. */\n @Prop({ mutable: true, reflect: true }) checked = false;\n\n /** If this property is set to true and an error message is provided by `errorText`, the error message is displayed. */\n @Prop({ reflect: true }) invalid = false;\n\n @Watch('checked')\n handleCheckedChange() {\n if (this.checked) {\n this.getSiblingRadios().forEach((radio) => (radio.checked = false));\n }\n if (this.nativeInput != null) {\n this.nativeInput.checked = this.checked;\n }\n }\n\n @Watch('name')\n handleNameChange(name: string) {\n if (this.nativeInput != null) {\n this.nativeInput.name = name;\n }\n }\n\n /** Emitted when the control loses focus. */\n @Event({ eventName: 'six-radio-blur' }) sixBlur!: EventEmitter<EmptyPayload>;\n\n /** Emitted when the control's checked state changes. */\n @Event({ eventName: 'six-radio-change' }) sixChange!: EventEmitter<EmptyPayload>;\n\n /** Emitted when the control gains focus. */\n @Event({ eventName: 'six-radio-focus' }) sixFocus!: EventEmitter<EmptyPayload>;\n\n connectedCallback() {\n this.eventListeners.forward('six-radio-change', 'change', this.host);\n this.eventListeners.forward('six-radio-blur', 'blur', this.host);\n this.eventListeners.forward('six-radio-focus', 'focus', this.host);\n }\n\n disconnectedCallback() {\n this.eventListeners.removeAll();\n }\n\n /** Sets focus on the radio. */\n @Method()\n async setFocus(options?: FocusOptions) {\n this.nativeInput?.focus(options);\n }\n\n /** Removes focus from the radio. */\n @Method()\n async removeFocus() {\n this.nativeInput?.blur();\n }\n\n private getAllRadios() {\n const form = this.host.closest('form') || document.body;\n\n if (this.name === '') return [];\n\n return [...form.querySelectorAll('six-radio')].filter(\n (radio: HTMLSixRadioElement) => radio.name === this.name\n ) as HTMLSixRadioElement[];\n }\n\n private getSiblingRadios() {\n return this.getAllRadios().filter((radio) => radio !== this.host) as HTMLSixRadioElement[];\n }\n\n private handleClick = () => {\n if (this.nativeInput != null) {\n this.checked = this.nativeInput.checked;\n this.sixChange.emit();\n }\n };\n\n private handleBlur = () => {\n this.hasFocus = false;\n this.sixBlur.emit();\n };\n\n private handleFocus = () => {\n this.hasFocus = true;\n this.sixFocus.emit();\n };\n\n private handleKeyDown = (keyboardEvent: KeyboardEvent) => {\n if (['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(keyboardEvent.key)) {\n const radios = this.getAllRadios().filter((radio) => !radio.disabled);\n const incr = ['ArrowUp', 'ArrowLeft'].includes(keyboardEvent.key) ? -1 : 1;\n let index = radios.indexOf(this.host) + incr;\n if (index < 0) index = radios.length - 1;\n if (index > radios.length - 1) index = 0;\n\n this.getAllRadios().forEach((radio) => (radio.checked = false));\n radios[index].setFocus();\n radios[index].checked = true;\n radios[index].dispatchEvent(new CustomEvent('six-radio-change', { bubbles: true, cancelable: true }));\n keyboardEvent.preventDefault();\n }\n };\n\n private handleMouseDown = (event: MouseEvent) => {\n // Prevent clicks on the label from briefly blurring the input\n event.preventDefault();\n this.nativeInput?.focus();\n };\n\n render() {\n return (\n <label\n part=\"base\"\n class={{\n radio: true,\n 'radio--checked': this.checked,\n 'radio--disabled': this.disabled,\n 'radio--focused': this.hasFocus,\n }}\n htmlFor={this.inputId}\n onKeyDown={this.handleKeyDown}\n onMouseDown={this.handleMouseDown}\n >\n <span part=\"control\" class=\"radio__control\">\n <span part=\"checked-icon\" class=\"radio__icon\">\n <svg viewBox=\"0 0 16 16\">\n <g stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\">\n <g fill=\"currentColor\">\n <circle cx=\"8\" cy=\"8\" r=\"5\"></circle>\n </g>\n </g>\n </svg>\n </span>\n\n <input\n ref={(el) => (this.nativeInput = el)}\n id={this.inputId}\n type=\"radio\"\n name={this.name}\n value={this.value}\n checked={this.checked}\n disabled={this.disabled}\n role=\"radio\"\n aria-checked={this.checked ? 'true' : 'false'}\n aria-labelledby={this.labelId}\n onClick={this.handleClick}\n onBlur={this.handleBlur}\n onFocus={this.handleFocus}\n />\n </span>\n\n <span part=\"label\" id={this.labelId} class=\"radio__label\">\n <slot />\n </span>\n </label>\n );\n }\n}\n"]}
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
}
|
|
15
15
|
.form-control .form-control__error-text {
|
|
16
16
|
display: none;
|
|
17
|
+
text-align: left;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
.form-control--has-label .form-control__label {
|
|
@@ -56,7 +57,6 @@
|
|
|
56
57
|
|
|
57
58
|
.form-control--has-error-text .form-control__error-text {
|
|
58
59
|
display: block;
|
|
59
|
-
color: var(--six-color-danger-800);
|
|
60
60
|
margin-top: var(--six-spacing-xxx-small);
|
|
61
61
|
}
|
|
62
62
|
.form-control--has-error-text .form-control__error-text ::slotted(*) {
|
|
@@ -53,12 +53,14 @@ export class SixRange {
|
|
|
53
53
|
this.handleSlotChange = () => {
|
|
54
54
|
this.hasHelpTextSlot = hasSlot(this.host, 'help-text');
|
|
55
55
|
this.hasLabelSlot = hasSlot(this.host, 'label');
|
|
56
|
+
this.hasErrorTextSlot = hasSlot(this.host, 'error-text');
|
|
56
57
|
};
|
|
57
58
|
this.handleTouchStart = () => {
|
|
58
59
|
this.setFocus();
|
|
59
60
|
};
|
|
60
61
|
this.hasFocus = false;
|
|
61
62
|
this.hasHelpTextSlot = false;
|
|
63
|
+
this.hasErrorTextSlot = false;
|
|
62
64
|
this.hasLabelSlot = false;
|
|
63
65
|
this.hasTooltip = false;
|
|
64
66
|
this.name = '';
|
|
@@ -68,6 +70,7 @@ export class SixRange {
|
|
|
68
70
|
this.disabled = false;
|
|
69
71
|
this.label = '';
|
|
70
72
|
this.errorText = '';
|
|
73
|
+
this.errorTextCount = undefined;
|
|
71
74
|
this.invalid = false;
|
|
72
75
|
this.min = 0;
|
|
73
76
|
this.max = 100;
|
|
@@ -175,7 +178,7 @@ export class SixRange {
|
|
|
175
178
|
}
|
|
176
179
|
}
|
|
177
180
|
render() {
|
|
178
|
-
return (h(FormControl, { inputId: this.inputId, label: this.label, labelId: this.labelId, hasLabelSlot: this.hasLabelSlot, helpTextId: this.helpTextId, helpText: this.helpText, hasHelpTextSlot: this.hasHelpTextSlot, size: "medium", errorTextId: this.errorTextId, errorText: this.errorText, disabled: this.disabled, required: this.required, displayError: this.invalid }, h("div", { part: "base", class: {
|
|
181
|
+
return (h(FormControl, { inputId: this.inputId, label: this.label, labelId: this.labelId, hasLabelSlot: this.hasLabelSlot, helpTextId: this.helpTextId, helpText: this.helpText, hasHelpTextSlot: this.hasHelpTextSlot, size: "medium", errorTextId: this.errorTextId, errorText: this.errorText, hasErrorTextSlot: this.hasErrorTextSlot, errorTextCount: this.errorTextCount, disabled: this.disabled, required: this.required, displayError: this.invalid }, h("div", { part: "base", class: {
|
|
179
182
|
range: true,
|
|
180
183
|
// States
|
|
181
184
|
'range--disabled': this.disabled,
|
|
@@ -311,8 +314,8 @@ export class SixRange {
|
|
|
311
314
|
"type": "string",
|
|
312
315
|
"mutable": false,
|
|
313
316
|
"complexType": {
|
|
314
|
-
"original": "string",
|
|
315
|
-
"resolved": "string",
|
|
317
|
+
"original": "string | string[]",
|
|
318
|
+
"resolved": "string | string[]",
|
|
316
319
|
"references": {}
|
|
317
320
|
},
|
|
318
321
|
"required": false,
|
|
@@ -325,6 +328,23 @@ export class SixRange {
|
|
|
325
328
|
"reflect": false,
|
|
326
329
|
"defaultValue": "''"
|
|
327
330
|
},
|
|
331
|
+
"errorTextCount": {
|
|
332
|
+
"type": "number",
|
|
333
|
+
"mutable": false,
|
|
334
|
+
"complexType": {
|
|
335
|
+
"original": "number",
|
|
336
|
+
"resolved": "number | undefined",
|
|
337
|
+
"references": {}
|
|
338
|
+
},
|
|
339
|
+
"required": false,
|
|
340
|
+
"optional": true,
|
|
341
|
+
"docs": {
|
|
342
|
+
"tags": [],
|
|
343
|
+
"text": "The number of error texts to be shown (if the error-text slot isn't used). Defaults to 1"
|
|
344
|
+
},
|
|
345
|
+
"attribute": "error-text-count",
|
|
346
|
+
"reflect": false
|
|
347
|
+
},
|
|
328
348
|
"invalid": {
|
|
329
349
|
"type": "boolean",
|
|
330
350
|
"mutable": false,
|
|
@@ -437,6 +457,7 @@ export class SixRange {
|
|
|
437
457
|
return {
|
|
438
458
|
"hasFocus": {},
|
|
439
459
|
"hasHelpTextSlot": {},
|
|
460
|
+
"hasErrorTextSlot": {},
|
|
440
461
|
"hasLabelSlot": {},
|
|
441
462
|
"hasTooltip": {}
|
|
442
463
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"six-range.js","sourceRoot":"","sources":["../../../src/components/six-range/six-range.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACvG,OAAO,WAAW,MAAM,uDAAuD,CAAC;AAChF,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, EventEmitter, h, Method, Prop, State, Watch } from '@stencil/core';\nimport FormControl from '../../functional-components/form-control/form-control';\nimport { hasSlot } from '../../utils/slot';\nimport { EmptyPayload } from '../../utils/types';\nimport { EventListeners } from '../../utils/event-listeners';\n\nlet id = 0;\n\n/**\n * @since 1.0\n * @status stable\n *\n * Forked from https://github.com/shoelace-style/shoelace version v2.0.0-beta27.\n *\n * @slot label - The input's label. Alternatively, you can use the label prop.\n * @slot help-text - Help text that describes how to use the input. Alternatively, you can use the help-text prop.\n * @slot error-text - Error text that is shown for validation errors. Alternatively, you can use the error-text prop.\n *\n * @part base - The component's base wrapper.\n * @part input - The native range input.\n * @part tooltip - The range tooltip.\n */\n@Component({\n tag: 'six-range',\n styleUrl: 'six-range.scss',\n shadow: true,\n})\nexport class SixRange {\n private inputId = `input-${++id}`;\n private labelId = `input-label-${id}`;\n private helpTextId = `input-help-text-${id}`;\n private errorTextId = `input-error-text-${id}`;\n private eventListeners = new EventListeners();\n private resizeObserver?: ResizeObserver;\n\n private output?: HTMLElement;\n private nativeInput?: HTMLInputElement;\n\n @Element() host!: HTMLSixRangeElement;\n\n @State() hasFocus = false;\n @State() hasHelpTextSlot = false;\n @State() hasLabelSlot = false;\n @State() hasTooltip = false;\n\n /** The input's name attribute. */\n @Prop() name = '';\n\n /** The input's value attribute. */\n @Prop({ mutable: true }) value = 0;\n\n /** Set to true to show an asterisk beneath the label. */\n @Prop() required = false;\n\n /** The range's help text. Alternatively, you can use the help-text slot. */\n @Prop() helpText = '';\n\n /** Set to true to disable the input. */\n @Prop() disabled = false;\n\n /** The label text. */\n @Prop() label = '';\n\n /** The error message shown, if `invalid` is set to true. */\n @Prop() errorText = '';\n\n /** If this property is set to true and an error message is provided by `errorText`, the error message is displayed. */\n @Prop({ reflect: true }) invalid = false;\n\n /** The input's min attribute. */\n @Prop() min = 0;\n\n /** The input's max attribute. */\n @Prop() max = 100;\n\n /** The input's step attribute. */\n @Prop() step = 1;\n\n /** The preferred placedment of the tooltip. */\n @Prop() tooltip: 'top' | 'bottom' | 'none' = 'top';\n\n /** A function used to format the tooltip's value. */\n @Prop() tooltipFormatter = (value: number) => value.toString();\n\n /** Emitted when the control's value changes. */\n @Event({ eventName: 'six-range-change' }) sixChange!: EventEmitter<EmptyPayload>;\n\n /** Emitted when the control loses focus. */\n @Event({ eventName: 'six-range-blur' }) sixBlur!: EventEmitter<EmptyPayload>;\n\n /** Emitted when the control gains focus. */\n @Event({ eventName: 'six-range-focus' }) sixFocus!: EventEmitter<EmptyPayload>;\n\n @Watch('label')\n @Watch('errorText')\n @Watch('helpText')\n handleLabelChange() {\n this.handleSlotChange();\n }\n\n @Watch('value')\n @Watch('min')\n @Watch('max')\n handleValueChange() {\n this.update();\n }\n\n connectedCallback() {\n this.host.shadowRoot?.addEventListener('slotchange', this.handleSlotChange);\n }\n\n componentWillLoad() {\n this.update();\n this.handleSlotChange();\n }\n\n componentDidLoad() {\n const nativeInput = this.nativeInput;\n if (nativeInput == null) {\n return;\n }\n this.update();\n this.resizeObserver = new ResizeObserver(() => this.update());\n }\n\n disconnectedCallback() {\n this.host.shadowRoot?.removeEventListener('slotchange', this.handleSlotChange);\n this.eventListeners.removeAll();\n }\n\n /** Sets focus on the input. */\n @Method()\n async setFocus(options?: FocusOptions) {\n this.nativeInput?.focus(options);\n }\n\n /** Removes focus from the input. */\n @Method()\n async removeFocus() {\n this.nativeInput?.blur();\n }\n\n private handleInput = () => {\n if (this.nativeInput != null) {\n this.update(parseFloat(this.nativeInput.value));\n }\n requestAnimationFrame(() => {\n this.sixChange.emit();\n });\n };\n\n private handleBlur = () => {\n this.hasFocus = false;\n this.hasTooltip = false;\n this.sixBlur.emit();\n if (this.nativeInput != null) {\n this.resizeObserver?.unobserve(this.nativeInput);\n }\n };\n\n private handleFocus = () => {\n this.hasFocus = true;\n this.hasTooltip = true;\n this.sixFocus.emit();\n if (this.nativeInput != null) {\n this.resizeObserver?.observe(this.nativeInput);\n }\n };\n\n private handleSlotChange = () => {\n this.hasHelpTextSlot = hasSlot(this.host, 'help-text');\n this.hasLabelSlot = hasSlot(this.host, 'label');\n };\n\n private handleTouchStart = () => {\n this.setFocus();\n };\n\n private syncTooltip(min: number, max: number, value: number) {\n if (this.tooltip !== 'none' && this.nativeInput != null && this.output != null) {\n const percent = Math.max(0, (value - min) / (max - min));\n const inputWidth = this.nativeInput.offsetWidth;\n const tooltipWidth = this.output.offsetWidth;\n const thumbSize = getComputedStyle(this.nativeInput).getPropertyValue('--thumb-size');\n const x = `calc(${inputWidth * percent}px - calc(calc(${percent} * ${thumbSize}) - calc(${thumbSize} / 2)))`;\n this.output.style.transform = `translateX(${x})`;\n this.output.style.marginLeft = `-${tooltipWidth / 2}px`;\n }\n }\n\n private isFirefox() {\n return navigator.userAgent.toLowerCase().indexOf('firefox') > -1;\n }\n\n private update(updateValue?: number) {\n if (updateValue != null) {\n this.value = updateValue;\n }\n\n const min = Number(this.min) ?? 0;\n const max = Number(this.max) ?? 0;\n let value;\n const parsedValue = parseFloat(this.value as never);\n if (isNaN(parsedValue)) {\n value = this.getDefaultValue(min, max);\n } else {\n value = parsedValue;\n }\n\n if (this.nativeInput != null) {\n // The value may have constraints, so we set the native control's\n // value and sync it back to ensure it adheres to min, max, and step\n // properly.\n this.nativeInput.value = value.toString();\n this.value = parseFloat(this.nativeInput.value);\n } else {\n this.value = value;\n }\n this.calculateColorRunnableTrack(min, max, this.value);\n this.syncTooltip(min, max, this.value);\n }\n\n /**\n * from https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/range#value\n */\n private getDefaultValue(min: number, max: number): number {\n return max < min ? min : min + (max - min) / 2;\n }\n\n /**\n * For Firefox this functionality is not needed because it is supported by standard CSS.\n */\n private calculateColorRunnableTrack(min: number, max: number, value: number) {\n if (!this.isFirefox() && this.nativeInput != null) {\n const percent = Math.ceil(((value - min) / (max - min)) * 100);\n this.nativeInput.style.background =\n '-webkit-linear-gradient(left, var(--track-color) 0%, var(--track-color) ' +\n percent +\n '%, var(--six-color-web-rock-300) ' +\n percent +\n '%)';\n }\n }\n\n render() {\n return (\n <FormControl\n inputId={this.inputId}\n label={this.label}\n labelId={this.labelId}\n hasLabelSlot={this.hasLabelSlot}\n helpTextId={this.helpTextId}\n helpText={this.helpText}\n hasHelpTextSlot={this.hasHelpTextSlot}\n size=\"medium\"\n errorTextId={this.errorTextId}\n errorText={this.errorText}\n disabled={this.disabled}\n required={this.required}\n displayError={this.invalid}\n >\n <div\n part=\"base\"\n class={{\n range: true,\n\n // States\n 'range--disabled': this.disabled,\n 'range--focused': this.hasFocus,\n 'range--tooltip-visible': this.hasTooltip,\n 'range--tooltip-top': this.tooltip === 'top',\n 'range--tooltip-bottom': this.tooltip === 'bottom',\n }}\n onTouchStart={this.handleTouchStart}\n >\n <input\n part=\"input\"\n ref={(el) => (this.nativeInput = el)}\n type=\"range\"\n class=\"range__control\"\n name={this.name}\n disabled={this.disabled}\n min={this.min}\n max={this.max}\n step={this.step}\n value={this.value}\n onInput={this.handleInput}\n onFocus={this.handleFocus}\n onBlur={this.handleBlur}\n />\n {this.tooltip !== 'none' && (\n <output part=\"tooltip\" ref={(el) => (this.output = el)} class=\"range__tooltip\">\n {this.tooltipFormatter(this.value)}\n </output>\n )}\n </div>\n </FormControl>\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"six-range.js","sourceRoot":"","sources":["../../../src/components/six-range/six-range.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK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C,IAAI,CAAC,KAAK,CAAC,CAC3B,CACV,CACG,CACM,CACf,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, EventEmitter, h, Method, Prop, State, Watch } from '@stencil/core';\nimport FormControl from '../../functional-components/form-control/form-control';\nimport { hasSlot } from '../../utils/slot';\nimport { EmptyPayload } from '../../utils/types';\nimport { EventListeners } from '../../utils/event-listeners';\n\nlet id = 0;\n\n/**\n * @since 1.0\n * @status stable\n *\n * Forked from https://github.com/shoelace-style/shoelace version v2.0.0-beta27.\n *\n * @slot label - The input's label. Alternatively, you can use the label prop.\n * @slot help-text - Help text that describes how to use the input. Alternatively, you can use the help-text prop.\n * @slot error-text - Error text that is shown for validation errors. Alternatively, you can use the error-text prop.\n *\n * @part base - The component's base wrapper.\n * @part input - The native range input.\n * @part tooltip - The range tooltip.\n */\n@Component({\n tag: 'six-range',\n styleUrl: 'six-range.scss',\n shadow: true,\n})\nexport class SixRange {\n private inputId = `input-${++id}`;\n private labelId = `input-label-${id}`;\n private helpTextId = `input-help-text-${id}`;\n private errorTextId = `input-error-text-${id}`;\n private eventListeners = new EventListeners();\n private resizeObserver?: ResizeObserver;\n\n private output?: HTMLElement;\n private nativeInput?: HTMLInputElement;\n\n @Element() host!: HTMLSixRangeElement;\n\n @State() hasFocus = false;\n @State() hasHelpTextSlot = false;\n @State() hasErrorTextSlot = false;\n @State() hasLabelSlot = false;\n @State() hasTooltip = false;\n\n /** The input's name attribute. */\n @Prop() name = '';\n\n /** The input's value attribute. */\n @Prop({ mutable: true }) value = 0;\n\n /** Set to true to show an asterisk beneath the label. */\n @Prop() required = false;\n\n /** The range's help text. Alternatively, you can use the help-text slot. */\n @Prop() helpText = '';\n\n /** Set to true to disable the input. */\n @Prop() disabled = false;\n\n /** The label text. */\n @Prop() label = '';\n\n /** The error message shown, if `invalid` is set to true. */\n @Prop() errorText: string | string[] = '';\n\n /** The number of error texts to be shown (if the error-text slot isn't used). Defaults to 1 */\n @Prop() errorTextCount?: number;\n\n /** If this property is set to true and an error message is provided by `errorText`, the error message is displayed. */\n @Prop({ reflect: true }) invalid = false;\n\n /** The input's min attribute. */\n @Prop() min = 0;\n\n /** The input's max attribute. */\n @Prop() max = 100;\n\n /** The input's step attribute. */\n @Prop() step = 1;\n\n /** The preferred placedment of the tooltip. */\n @Prop() tooltip: 'top' | 'bottom' | 'none' = 'top';\n\n /** A function used to format the tooltip's value. */\n @Prop() tooltipFormatter = (value: number) => value.toString();\n\n /** Emitted when the control's value changes. */\n @Event({ eventName: 'six-range-change' }) sixChange!: EventEmitter<EmptyPayload>;\n\n /** Emitted when the control loses focus. */\n @Event({ eventName: 'six-range-blur' }) sixBlur!: EventEmitter<EmptyPayload>;\n\n /** Emitted when the control gains focus. */\n @Event({ eventName: 'six-range-focus' }) sixFocus!: EventEmitter<EmptyPayload>;\n\n @Watch('label')\n @Watch('errorText')\n @Watch('helpText')\n handleLabelChange() {\n this.handleSlotChange();\n }\n\n @Watch('value')\n @Watch('min')\n @Watch('max')\n handleValueChange() {\n this.update();\n }\n\n connectedCallback() {\n this.host.shadowRoot?.addEventListener('slotchange', this.handleSlotChange);\n }\n\n componentWillLoad() {\n this.update();\n this.handleSlotChange();\n }\n\n componentDidLoad() {\n const nativeInput = this.nativeInput;\n if (nativeInput == null) {\n return;\n }\n this.update();\n this.resizeObserver = new ResizeObserver(() => this.update());\n }\n\n disconnectedCallback() {\n this.host.shadowRoot?.removeEventListener('slotchange', this.handleSlotChange);\n this.eventListeners.removeAll();\n }\n\n /** Sets focus on the input. */\n @Method()\n async setFocus(options?: FocusOptions) {\n this.nativeInput?.focus(options);\n }\n\n /** Removes focus from the input. */\n @Method()\n async removeFocus() {\n this.nativeInput?.blur();\n }\n\n private handleInput = () => {\n if (this.nativeInput != null) {\n this.update(parseFloat(this.nativeInput.value));\n }\n requestAnimationFrame(() => {\n this.sixChange.emit();\n });\n };\n\n private handleBlur = () => {\n this.hasFocus = false;\n this.hasTooltip = false;\n this.sixBlur.emit();\n if (this.nativeInput != null) {\n this.resizeObserver?.unobserve(this.nativeInput);\n }\n };\n\n private handleFocus = () => {\n this.hasFocus = true;\n this.hasTooltip = true;\n this.sixFocus.emit();\n if (this.nativeInput != null) {\n this.resizeObserver?.observe(this.nativeInput);\n }\n };\n\n private handleSlotChange = () => {\n this.hasHelpTextSlot = hasSlot(this.host, 'help-text');\n this.hasLabelSlot = hasSlot(this.host, 'label');\n this.hasErrorTextSlot = hasSlot(this.host, 'error-text');\n };\n\n private handleTouchStart = () => {\n this.setFocus();\n };\n\n private syncTooltip(min: number, max: number, value: number) {\n if (this.tooltip !== 'none' && this.nativeInput != null && this.output != null) {\n const percent = Math.max(0, (value - min) / (max - min));\n const inputWidth = this.nativeInput.offsetWidth;\n const tooltipWidth = this.output.offsetWidth;\n const thumbSize = getComputedStyle(this.nativeInput).getPropertyValue('--thumb-size');\n const x = `calc(${inputWidth * percent}px - calc(calc(${percent} * ${thumbSize}) - calc(${thumbSize} / 2)))`;\n this.output.style.transform = `translateX(${x})`;\n this.output.style.marginLeft = `-${tooltipWidth / 2}px`;\n }\n }\n\n private isFirefox() {\n return navigator.userAgent.toLowerCase().indexOf('firefox') > -1;\n }\n\n private update(updateValue?: number) {\n if (updateValue != null) {\n this.value = updateValue;\n }\n\n const min = Number(this.min) ?? 0;\n const max = Number(this.max) ?? 0;\n let value;\n const parsedValue = parseFloat(this.value as never);\n if (isNaN(parsedValue)) {\n value = this.getDefaultValue(min, max);\n } else {\n value = parsedValue;\n }\n\n if (this.nativeInput != null) {\n // The value may have constraints, so we set the native control's\n // value and sync it back to ensure it adheres to min, max, and step\n // properly.\n this.nativeInput.value = value.toString();\n this.value = parseFloat(this.nativeInput.value);\n } else {\n this.value = value;\n }\n this.calculateColorRunnableTrack(min, max, this.value);\n this.syncTooltip(min, max, this.value);\n }\n\n /**\n * from https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/range#value\n */\n private getDefaultValue(min: number, max: number): number {\n return max < min ? min : min + (max - min) / 2;\n }\n\n /**\n * For Firefox this functionality is not needed because it is supported by standard CSS.\n */\n private calculateColorRunnableTrack(min: number, max: number, value: number) {\n if (!this.isFirefox() && this.nativeInput != null) {\n const percent = Math.ceil(((value - min) / (max - min)) * 100);\n this.nativeInput.style.background =\n '-webkit-linear-gradient(left, var(--track-color) 0%, var(--track-color) ' +\n percent +\n '%, var(--six-color-web-rock-300) ' +\n percent +\n '%)';\n }\n }\n\n render() {\n return (\n <FormControl\n inputId={this.inputId}\n label={this.label}\n labelId={this.labelId}\n hasLabelSlot={this.hasLabelSlot}\n helpTextId={this.helpTextId}\n helpText={this.helpText}\n hasHelpTextSlot={this.hasHelpTextSlot}\n size=\"medium\"\n errorTextId={this.errorTextId}\n errorText={this.errorText}\n hasErrorTextSlot={this.hasErrorTextSlot}\n errorTextCount={this.errorTextCount}\n disabled={this.disabled}\n required={this.required}\n displayError={this.invalid}\n >\n <div\n part=\"base\"\n class={{\n range: true,\n\n // States\n 'range--disabled': this.disabled,\n 'range--focused': this.hasFocus,\n 'range--tooltip-visible': this.hasTooltip,\n 'range--tooltip-top': this.tooltip === 'top',\n 'range--tooltip-bottom': this.tooltip === 'bottom',\n }}\n onTouchStart={this.handleTouchStart}\n >\n <input\n part=\"input\"\n ref={(el) => (this.nativeInput = el)}\n type=\"range\"\n class=\"range__control\"\n name={this.name}\n disabled={this.disabled}\n min={this.min}\n max={this.max}\n step={this.step}\n value={this.value}\n onInput={this.handleInput}\n onFocus={this.handleFocus}\n onBlur={this.handleBlur}\n />\n {this.tooltip !== 'none' && (\n <output part=\"tooltip\" ref={(el) => (this.output = el)} class=\"range__tooltip\">\n {this.tooltipFormatter(this.value)}\n </output>\n )}\n </div>\n </FormControl>\n );\n }\n}\n"]}
|
|
@@ -19,7 +19,9 @@ describe('six-range', () => {
|
|
|
19
19
|
<input class="range__control" max="100" min="0" part="input" step="1" type="range" value="0" style="background: -webkit-linear-gradient(left, var(--track-color) 0%, var(--track-color) 0%, var(--six-color-web-rock-300) 0%);">
|
|
20
20
|
</div>
|
|
21
21
|
</div>
|
|
22
|
-
<div aria-hidden="true" class="form-control__error-text" id="input-error-text-1" part="error-text"
|
|
22
|
+
<div aria-hidden="true" class="form-control__error-text" id="input-error-text-1" part="error-text">
|
|
23
|
+
<slot name="error-text"></slot>
|
|
24
|
+
</div>
|
|
23
25
|
<div aria-hidden="true" class="form-control__help-text" id="input-help-text-1" part="help-text">
|
|
24
26
|
<slot name="help-text"></slot>
|
|
25
27
|
</div>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"six-range.spec.js","sourceRoot":"","sources":["../../../../src/components/six-range/test/six-range.spec.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;EACzB,EAAE,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;IACvB,MAAM,CAAC,cAAc,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;IAElC,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;MAC7B,UAAU,EAAE,CAAC,QAAQ,CAAC;MACtB,IAAI,EAAE,wCAAwC;KAC/C,CAAC,CAAC;IACH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC
|
|
1
|
+
{"version":3,"file":"six-range.spec.js","sourceRoot":"","sources":["../../../../src/components/six-range/test/six-range.spec.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;EACzB,EAAE,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;IACvB,MAAM,CAAC,cAAc,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;IAElC,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;MAC7B,UAAU,EAAE,CAAC,QAAQ,CAAC;MACtB,IAAI,EAAE,wCAAwC;KAC/C,CAAC,CAAC;IACH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;;KAqB7B,CAAC,CAAC;EACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { newSpecPage } from '@stencil/core/testing';\nimport { SixRange } from '../six-range';\n\ndescribe('six-range', () => {\n it('renders', async () => {\n global.ResizeObserver = jest.fn();\n\n const page = await newSpecPage({\n components: [SixRange],\n html: `<six-range tooltip=\"none\"></six-range>`,\n });\n expect(page.root).toEqualHtml(`\n <six-range tooltip=\"none\">\n <mock:shadow-root>\n <div class=\"form-control form-control--medium\" part=\"form-control\">\n <label aria-hidden=\"true\" class=\"form-control__label\" htmlfor=\"input-1\" id=\"input-label-1\" part=\"label\">\n <slot name=\"label\"></slot>\n </label>\n <div class=\"form-control__input\">\n <div class=\"range\" part=\"base\">\n <input class=\"range__control\" max=\"100\" min=\"0\" part=\"input\" step=\"1\" type=\"range\" value=\"0\" style=\"background: -webkit-linear-gradient(left, var(--track-color) 0%, var(--track-color) 0%, var(--six-color-web-rock-300) 0%);\">\n </div>\n </div>\n <div aria-hidden=\"true\" class=\"form-control__error-text\" id=\"input-error-text-1\" part=\"error-text\">\n <slot name=\"error-text\"></slot>\n </div>\n <div aria-hidden=\"true\" class=\"form-control__help-text\" id=\"input-help-text-1\" part=\"help-text\">\n <slot name=\"help-text\"></slot>\n </div>\n </div>\n </mock:shadow-root>\n </six-range>\n `);\n });\n});\n"]}
|