@govtechsg/sgds-web-component 3.0.0-rc.1 → 3.0.0-rc.2
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 +5 -5
- package/base/button.js +1 -1
- package/base/form-control-element.d.ts +4 -11
- package/base/form-control-element.js +13 -23
- package/base/form-control-element.js.map +1 -1
- package/components/Accordion/accordion-item.js +1 -1
- package/components/Accordion/index.umd.js +7 -19
- package/components/Accordion/index.umd.js.map +1 -1
- package/components/Accordion/sgds-accordion-item.d.ts +3 -7
- package/components/Accordion/sgds-accordion-item.js +6 -18
- package/components/Accordion/sgds-accordion-item.js.map +1 -1
- package/components/ActionCard/index.umd.js +407 -329
- package/components/ActionCard/index.umd.js.map +1 -1
- package/components/Alert/alert.js +1 -1
- package/components/Alert/index.umd.js +553 -485
- package/components/Alert/index.umd.js.map +1 -1
- package/components/Alert/sgds-alert.d.ts +2 -2
- package/components/Alert/sgds-alert.js +6 -13
- package/components/Alert/sgds-alert.js.map +1 -1
- package/components/Badge/badge.js +1 -1
- package/components/Badge/index.umd.js +8 -9
- package/components/Badge/index.umd.js.map +1 -1
- package/components/Badge/sgds-badge.d.ts +4 -5
- package/components/Badge/sgds-badge.js +5 -6
- package/components/Badge/sgds-badge.js.map +1 -1
- package/components/Button/index.umd.js +8 -81
- package/components/Button/index.umd.js.map +1 -1
- package/components/Button/sgds-button.js +1 -1
- package/components/Button/sgds-button.js.map +1 -1
- package/components/Checkbox/checkbox.js +1 -1
- package/components/Checkbox/index.umd.js +541 -475
- package/components/Checkbox/index.umd.js.map +1 -1
- package/components/Checkbox/sgds-checkbox-group.d.ts +7 -1
- package/components/Checkbox/sgds-checkbox-group.js +15 -4
- package/components/Checkbox/sgds-checkbox-group.js.map +1 -1
- package/components/Checkbox/sgds-checkbox.d.ts +30 -21
- package/components/Checkbox/sgds-checkbox.js +77 -60
- package/components/Checkbox/sgds-checkbox.js.map +1 -1
- package/components/ComboBox/index.umd.js +385 -216
- package/components/ComboBox/index.umd.js.map +1 -1
- package/components/Datepicker/datepicker-input.d.ts +4 -2
- package/components/Datepicker/datepicker-input.js +24 -7
- package/components/Datepicker/datepicker-input.js.map +1 -1
- package/components/Datepicker/index.umd.js +433 -244
- package/components/Datepicker/index.umd.js.map +1 -1
- package/components/Datepicker/sgds-datepicker.d.ts +1 -1
- package/components/Datepicker/sgds-datepicker.js.map +1 -1
- package/components/Drawer/index.umd.js +2 -2
- package/components/Drawer/index.umd.js.map +1 -1
- package/components/Dropdown/index.umd.js +8 -81
- package/components/Dropdown/index.umd.js.map +1 -1
- package/components/FileUpload/file-upload.js +1 -1
- package/components/FileUpload/index.umd.js +579 -272
- package/components/FileUpload/index.umd.js.map +1 -1
- package/components/FileUpload/sgds-file-upload.d.ts +42 -30
- package/components/FileUpload/sgds-file-upload.js +147 -103
- package/components/FileUpload/sgds-file-upload.js.map +1 -1
- package/components/Footer/footer-item.js +6 -0
- package/components/Footer/footer-item.js.map +1 -0
- package/components/Footer/footer.js +1 -1
- package/components/Footer/index.d.ts +2 -0
- package/components/Footer/index.js +2 -0
- package/components/Footer/index.js.map +1 -1
- package/components/Footer/index.umd.js +93 -94
- package/components/Footer/index.umd.js.map +1 -1
- package/components/Footer/sgds-footer-item.d.ts +13 -0
- package/components/Footer/sgds-footer-item.js +27 -0
- package/components/Footer/sgds-footer-item.js.map +1 -0
- package/components/Footer/sgds-footer.d.ts +9 -30
- package/components/Footer/sgds-footer.js +65 -90
- package/components/Footer/sgds-footer.js.map +1 -1
- package/components/Icon/icon.js +6 -0
- package/components/Icon/icon.js.map +1 -0
- package/components/Icon/index.d.ts +6 -0
- package/components/Icon/index.js +4 -0
- package/components/Icon/index.js.map +1 -0
- package/components/Icon/index.umd.js +4389 -0
- package/components/Icon/index.umd.js.map +1 -0
- package/components/Icon/sgds-icon.d.ts +21 -0
- package/components/Icon/sgds-icon.js +64 -0
- package/components/Icon/sgds-icon.js.map +1 -0
- package/components/IconButton/icon-button.js +1 -1
- package/components/IconButton/index.umd.js +6 -9
- package/components/IconButton/index.umd.js.map +1 -1
- package/components/IconButton/sgds-icon-button.d.ts +2 -2
- package/components/IconButton/sgds-icon-button.js +4 -9
- package/components/IconButton/sgds-icon-button.js.map +1 -1
- package/components/Input/index.umd.js +1734 -1376
- package/components/Input/index.umd.js.map +1 -1
- package/components/Input/sgds-input.d.ts +41 -21
- package/components/Input/sgds-input.js +103 -66
- package/components/Input/sgds-input.js.map +1 -1
- package/components/Modal/index.umd.js +2 -2
- package/components/Modal/index.umd.js.map +1 -1
- package/components/QuantityToggle/index.umd.js +894 -316
- package/components/QuantityToggle/index.umd.js.map +1 -1
- package/components/QuantityToggle/sgds-quantity-toggle.d.ts +42 -15
- package/components/QuantityToggle/sgds-quantity-toggle.js +129 -62
- package/components/QuantityToggle/sgds-quantity-toggle.js.map +1 -1
- package/components/Radio/index.umd.js +516 -203
- package/components/Radio/index.umd.js.map +1 -1
- package/components/Radio/sgds-radio-group.d.ts +38 -27
- package/components/Radio/sgds-radio-group.js +100 -84
- package/components/Radio/sgds-radio-group.js.map +1 -1
- package/components/Radio/sgds-radio.js +1 -1
- package/components/Radio/sgds-radio.js.map +1 -1
- package/components/Stepper/index.umd.js +1 -0
- package/components/Stepper/index.umd.js.map +1 -1
- package/components/Stepper/sgds-stepper.d.ts +1 -0
- package/components/Stepper/sgds-stepper.js +1 -0
- package/components/Stepper/sgds-stepper.js.map +1 -1
- package/components/Switch/index.umd.js +21 -321
- package/components/Switch/index.umd.js.map +1 -1
- package/components/Switch/sgds-switch.js +1 -2
- package/components/Switch/sgds-switch.js.map +1 -1
- package/components/Textarea/index.umd.js +1554 -1336
- package/components/Textarea/index.umd.js.map +1 -1
- package/components/Textarea/sgds-textarea.d.ts +33 -22
- package/components/Textarea/sgds-textarea.js +78 -75
- package/components/Textarea/sgds-textarea.js.map +1 -1
- package/components/Textarea/textarea.js +1 -1
- package/components/Toast/index.umd.js +9 -21
- package/components/Toast/index.umd.js.map +1 -1
- package/components/Toast/sgds-toast.d.ts +2 -1
- package/components/Toast/sgds-toast.js +6 -18
- package/components/Toast/sgds-toast.js.map +1 -1
- package/components/Toast/toast.js +1 -1
- package/components/Tooltip/index.umd.js +14 -14
- package/components/Tooltip/index.umd.js.map +1 -1
- package/components/Tooltip/sgds-tooltip.d.ts +4 -7
- package/components/Tooltip/sgds-tooltip.js +14 -14
- package/components/Tooltip/sgds-tooltip.js.map +1 -1
- package/components/index.d.ts +1 -0
- package/components/index.js +1 -0
- package/components/index.js.map +1 -1
- package/components/index.umd.js +1318 -1124
- package/components/index.umd.js.map +1 -1
- package/icons/arrow-bar-down.svg +3 -0
- package/icons/arrow-bar-left.svg +3 -0
- package/icons/arrow-bar-right.svg +3 -0
- package/icons/arrow-bar-up.svg +3 -0
- package/icons/arrow-clockwise.svg +3 -0
- package/icons/arrow-down.svg +3 -0
- package/icons/arrow-left.svg +3 -0
- package/icons/arrow-repeat.svg +3 -0
- package/icons/arrow-right.svg +3 -0
- package/icons/arrow-up.svg +3 -0
- package/icons/bank-fill.svg +3 -0
- package/icons/bell-slash.svg +3 -0
- package/icons/bell.svg +3 -0
- package/icons/bi-funnel.svg +3 -0
- package/icons/bookmark-fill.svg +3 -0
- package/icons/bookmark.svg +3 -0
- package/icons/box-arrow-up-right.svg +3 -0
- package/icons/box-seam.svg +3 -0
- package/icons/building.svg +3 -0
- package/icons/calculator.svg +3 -0
- package/icons/calendar-check.svg +4 -0
- package/icons/calendar-x.svg +4 -0
- package/icons/calendar.svg +3 -0
- package/icons/camera.svg +3 -0
- package/icons/chat-left-text.svg +3 -0
- package/icons/check-circle-fill.svg +3 -0
- package/icons/check-circle.svg +3 -0
- package/icons/check.svg +3 -0
- package/icons/chevron-down.svg +3 -0
- package/icons/chevron-left.svg +3 -0
- package/icons/chevron-right.svg +3 -0
- package/icons/chevron-up .svg +3 -0
- package/icons/clock.svg +4 -0
- package/icons/cloud-check.svg +4 -0
- package/icons/cloud-download.svg +3 -0
- package/icons/cloud-upload.svg +3 -0
- package/icons/cloud.svg +3 -0
- package/icons/compass.svg +4 -0
- package/icons/cross.svg +3 -0
- package/icons/cursor-fill.svg +3 -0
- package/icons/cursor.svg +3 -0
- package/icons/dash-circle.svg +3 -0
- package/icons/dash-square.svg +3 -0
- package/icons/dash.svg +3 -0
- package/icons/download.svg +3 -0
- package/icons/exclamation-circle-fill.svg +3 -0
- package/icons/exclamation-circle.svg +4 -0
- package/icons/exclamation-triangle-fill.svg +3 -0
- package/icons/exclamation-triangle.svg +4 -0
- package/icons/exclamation.svg +4 -0
- package/icons/eye-fill.svg +3 -0
- package/icons/eye-slash-fill.svg +4 -0
- package/icons/eye-slash.svg +3 -0
- package/icons/eye.svg +3 -0
- package/icons/facebook.svg +3 -0
- package/icons/file-earmark-text.svg +3 -0
- package/icons/file-pdf.svg +4 -0
- package/icons/file-plus.svg +4 -0
- package/icons/file-text.svg +3 -0
- package/icons/file.svg +3 -0
- package/icons/files.svg +4 -0
- package/icons/folder-check.svg +4 -0
- package/icons/folder-minus.svg +4 -0
- package/icons/folder-plus.svg +4 -0
- package/icons/folder.svg +3 -0
- package/icons/gear.svg +3 -0
- package/icons/geo-alt.svg +4 -0
- package/icons/geo-fill.svg +4 -0
- package/icons/geo.svg +4 -0
- package/icons/google.svg +3 -0
- package/icons/grid-fill.svg +3 -0
- package/icons/hand-thumbs-down.svg +3 -0
- package/icons/hand-thumbs-up.svg +3 -0
- package/icons/hdd.svg +3 -0
- package/icons/house-door.svg +3 -0
- package/icons/house.svg +3 -0
- package/icons/image.svg +3 -0
- package/icons/inbox.svg +3 -0
- package/icons/info-circle-fill.svg +3 -0
- package/icons/info-circle.svg +4 -0
- package/icons/instagram.svg +3 -0
- package/icons/layers.svg +3 -0
- package/icons/layout-text-window-reverse.svg +3 -0
- package/icons/layout-text-window.svg +3 -0
- package/icons/layout.svg +3 -0
- package/icons/link.svg +3 -0
- package/icons/linkedin.svg +3 -0
- package/icons/list.svg +3 -0
- package/icons/lock-fill.svg +3 -0
- package/icons/lock.svg +3 -0
- package/icons/mail.svg +3 -0
- package/icons/map.svg +3 -0
- package/icons/paperclip.svg +3 -0
- package/icons/pencil.svg +3 -0
- package/icons/pending-circle.svg +3 -0
- package/icons/person-dash.svg +3 -0
- package/icons/person-plus.svg +3 -0
- package/icons/person-x.svg +3 -0
- package/icons/person.svg +3 -0
- package/icons/pin-map-fill.svg +3 -0
- package/icons/pin.svg +3 -0
- package/icons/placeholder.svg +3 -0
- package/icons/plus-circle.svg +3 -0
- package/icons/plus-square.svg +3 -0
- package/icons/plus.svg +3 -0
- package/icons/printer.svg +3 -0
- package/icons/question-circle.svg +4 -0
- package/icons/save.svg +3 -0
- package/icons/search.svg +3 -0
- package/icons/share.svg +3 -0
- package/icons/slash-circle.svg +3 -0
- package/icons/sliders.svg +3 -0
- package/icons/speedometer.svg +3 -0
- package/icons/star-fill.svg +3 -0
- package/icons/star.svg +3 -0
- package/icons/stoplights.svg +4 -0
- package/icons/telephone.svg +3 -0
- package/icons/three-dots-vertical.svg +3 -0
- package/icons/three-dots.svg +3 -0
- package/icons/toggle-off.svg +3 -0
- package/icons/toggle-on.svg +3 -0
- package/icons/trash.svg +3 -0
- package/icons/twitter-x.svg +3 -0
- package/icons/unlock.svg +3 -0
- package/icons/upload.svg +3 -0
- package/icons/window-dash.svg +4 -0
- package/icons/window-desktop.svg +4 -0
- package/icons/window-dock.svg +4 -0
- package/icons/window-fullscreen.svg +3 -0
- package/icons/window-plus.svg +4 -0
- package/icons/window-sidebar.svg +3 -0
- package/icons/window-split.svg +3 -0
- package/icons/window-stack.svg +3 -0
- package/icons/window-x.svg +4 -0
- package/icons/window.svg +3 -0
- package/icons/x-circle-fill.svg +3 -0
- package/icons/x-circle.svg +3 -0
- package/icons/youtube.svg +3 -0
- package/icons/zoom-in.svg +3 -0
- package/icons/zoom-out.svg +3 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/index.umd.js +1338 -1119
- package/index.umd.js.map +1 -1
- package/internals/CloseButton/close-button.js +1 -1
- package/internals/CloseButton/sgds-close-button.js +1 -1
- package/internals/CloseButton/sgds-close-button.js.map +1 -1
- package/package.json +1 -1
- package/react/base/button.cjs.js +1 -1
- package/react/base/button.js +1 -1
- package/react/base/form-control-element.cjs.js +13 -23
- package/react/base/form-control-element.cjs.js.map +1 -1
- package/react/base/form-control-element.js +13 -23
- package/react/base/form-control-element.js.map +1 -1
- package/react/checkbox/index.cjs.js +2 -0
- package/react/checkbox/index.cjs.js.map +1 -1
- package/react/checkbox/index.d.ts +2 -0
- package/react/checkbox/index.js +2 -0
- package/react/checkbox/index.js.map +1 -1
- package/react/components/Accordion/accordion-item.cjs.js +1 -1
- package/react/components/Accordion/accordion-item.js +1 -1
- package/react/components/Accordion/sgds-accordion-item.cjs.js +6 -18
- package/react/components/Accordion/sgds-accordion-item.cjs.js.map +1 -1
- package/react/components/Accordion/sgds-accordion-item.js +6 -18
- package/react/components/Accordion/sgds-accordion-item.js.map +1 -1
- package/react/components/Alert/alert.cjs.js +1 -1
- package/react/components/Alert/alert.js +1 -1
- package/react/components/Alert/sgds-alert.cjs.js +5 -12
- package/react/components/Alert/sgds-alert.cjs.js.map +1 -1
- package/react/components/Alert/sgds-alert.js +6 -13
- package/react/components/Alert/sgds-alert.js.map +1 -1
- package/react/components/Badge/badge.cjs.js +1 -1
- package/react/components/Badge/badge.js +1 -1
- package/react/components/Badge/sgds-badge.cjs.js +5 -6
- package/react/components/Badge/sgds-badge.cjs.js.map +1 -1
- package/react/components/Badge/sgds-badge.js +5 -6
- package/react/components/Badge/sgds-badge.js.map +1 -1
- package/react/components/Button/sgds-button.cjs.js +2 -2
- package/react/components/Button/sgds-button.cjs.js.map +1 -1
- package/react/components/Button/sgds-button.js +1 -1
- package/react/components/Button/sgds-button.js.map +1 -1
- package/react/components/Checkbox/checkbox.cjs.js +1 -1
- package/react/components/Checkbox/checkbox.js +1 -1
- package/react/components/Checkbox/sgds-checkbox-group.cjs.js +15 -4
- package/react/components/Checkbox/sgds-checkbox-group.cjs.js.map +1 -1
- package/react/components/Checkbox/sgds-checkbox-group.js +15 -4
- package/react/components/Checkbox/sgds-checkbox-group.js.map +1 -1
- package/react/components/Checkbox/sgds-checkbox.cjs.js +77 -60
- package/react/components/Checkbox/sgds-checkbox.cjs.js.map +1 -1
- package/react/components/Checkbox/sgds-checkbox.js +77 -60
- package/react/components/Checkbox/sgds-checkbox.js.map +1 -1
- package/react/components/Datepicker/datepicker-input.cjs.js +24 -7
- package/react/components/Datepicker/datepicker-input.cjs.js.map +1 -1
- package/react/components/Datepicker/datepicker-input.js +24 -7
- package/react/components/Datepicker/datepicker-input.js.map +1 -1
- package/react/components/Datepicker/sgds-datepicker.cjs.js.map +1 -1
- package/react/components/Datepicker/sgds-datepicker.js.map +1 -1
- package/react/components/FileUpload/file-upload.cjs.js +1 -1
- package/react/components/FileUpload/file-upload.js +1 -1
- package/react/components/FileUpload/sgds-file-upload.cjs.js +145 -101
- package/react/components/FileUpload/sgds-file-upload.cjs.js.map +1 -1
- package/react/components/FileUpload/sgds-file-upload.js +147 -103
- package/react/components/FileUpload/sgds-file-upload.js.map +1 -1
- package/react/components/Footer/footer-item.cjs.js +11 -0
- package/react/components/Footer/footer-item.cjs.js.map +1 -0
- package/react/components/Footer/footer-item.js +7 -0
- package/react/components/Footer/footer-item.js.map +1 -0
- package/react/components/Footer/footer.cjs.js +1 -1
- package/react/components/Footer/footer.js +1 -1
- package/react/components/Footer/sgds-footer-item.cjs.js +33 -0
- package/react/components/Footer/sgds-footer-item.cjs.js.map +1 -0
- package/react/components/Footer/sgds-footer-item.js +28 -0
- package/react/components/Footer/sgds-footer-item.js.map +1 -0
- package/react/components/Footer/sgds-footer.cjs.js +65 -90
- package/react/components/Footer/sgds-footer.cjs.js.map +1 -1
- package/react/components/Footer/sgds-footer.js +65 -90
- package/react/components/Footer/sgds-footer.js.map +1 -1
- package/react/components/Icon/icon.cjs.js +11 -0
- package/react/components/Icon/icon.cjs.js.map +1 -0
- package/react/components/Icon/icon.js +7 -0
- package/react/components/Icon/icon.js.map +1 -0
- package/react/components/Icon/sgds-icon.cjs.js +70 -0
- package/react/components/Icon/sgds-icon.cjs.js.map +1 -0
- package/react/components/Icon/sgds-icon.js +65 -0
- package/react/components/Icon/sgds-icon.js.map +1 -0
- package/react/components/IconButton/icon-button.cjs.js +1 -1
- package/react/components/IconButton/icon-button.js +1 -1
- package/react/components/IconButton/sgds-icon-button.cjs.js +4 -9
- package/react/components/IconButton/sgds-icon-button.cjs.js.map +1 -1
- package/react/components/IconButton/sgds-icon-button.js +4 -9
- package/react/components/IconButton/sgds-icon-button.js.map +1 -1
- package/react/components/Input/sgds-input.cjs.js +101 -64
- package/react/components/Input/sgds-input.cjs.js.map +1 -1
- package/react/components/Input/sgds-input.js +103 -66
- package/react/components/Input/sgds-input.js.map +1 -1
- package/react/components/QuantityToggle/sgds-quantity-toggle.cjs.js +128 -61
- package/react/components/QuantityToggle/sgds-quantity-toggle.cjs.js.map +1 -1
- package/react/components/QuantityToggle/sgds-quantity-toggle.js +129 -62
- package/react/components/QuantityToggle/sgds-quantity-toggle.js.map +1 -1
- package/react/components/Radio/sgds-radio-group.cjs.js +99 -83
- package/react/components/Radio/sgds-radio-group.cjs.js.map +1 -1
- package/react/components/Radio/sgds-radio-group.js +100 -84
- package/react/components/Radio/sgds-radio-group.js.map +1 -1
- package/react/components/Radio/sgds-radio.cjs.js +1 -1
- package/react/components/Radio/sgds-radio.cjs.js.map +1 -1
- package/react/components/Radio/sgds-radio.js +1 -1
- package/react/components/Radio/sgds-radio.js.map +1 -1
- package/react/components/Stepper/sgds-stepper.cjs.js +1 -0
- package/react/components/Stepper/sgds-stepper.cjs.js.map +1 -1
- package/react/components/Stepper/sgds-stepper.js +1 -0
- package/react/components/Stepper/sgds-stepper.js.map +1 -1
- package/react/components/Switch/sgds-switch.cjs.js +1 -2
- package/react/components/Switch/sgds-switch.cjs.js.map +1 -1
- package/react/components/Switch/sgds-switch.js +1 -2
- package/react/components/Switch/sgds-switch.js.map +1 -1
- package/react/components/Textarea/sgds-textarea.cjs.js +76 -73
- package/react/components/Textarea/sgds-textarea.cjs.js.map +1 -1
- package/react/components/Textarea/sgds-textarea.js +78 -75
- package/react/components/Textarea/sgds-textarea.js.map +1 -1
- package/react/components/Textarea/textarea.cjs.js +1 -1
- package/react/components/Textarea/textarea.js +1 -1
- package/react/components/Toast/sgds-toast.cjs.js +6 -18
- package/react/components/Toast/sgds-toast.cjs.js.map +1 -1
- package/react/components/Toast/sgds-toast.js +6 -18
- package/react/components/Toast/sgds-toast.js.map +1 -1
- package/react/components/Toast/toast.cjs.js +1 -1
- package/react/components/Toast/toast.js +1 -1
- package/react/components/Tooltip/sgds-tooltip.cjs.js +14 -14
- package/react/components/Tooltip/sgds-tooltip.cjs.js.map +1 -1
- package/react/components/Tooltip/sgds-tooltip.js +14 -14
- package/react/components/Tooltip/sgds-tooltip.js.map +1 -1
- package/react/footer-item/index.cjs.js +39 -0
- package/react/footer-item/index.cjs.js.map +1 -0
- package/react/footer-item/index.d.ts +3 -0
- package/react/footer-item/index.js +15 -0
- package/react/footer-item/index.js.map +1 -0
- package/react/icon/index.cjs.js +42 -0
- package/react/icon/index.cjs.js.map +1 -0
- package/react/icon/index.d.ts +6 -0
- package/react/icon/index.js +18 -0
- package/react/icon/index.js.map +1 -0
- package/react/index.cjs.js +64 -60
- package/react/index.cjs.js.map +1 -1
- package/react/index.d.ts +2 -0
- package/react/index.js +2 -0
- package/react/index.js.map +1 -1
- package/react/input/index.cjs.js +3 -1
- package/react/input/index.cjs.js.map +1 -1
- package/react/input/index.d.ts +2 -0
- package/react/input/index.js +3 -1
- package/react/input/index.js.map +1 -1
- package/react/internals/CloseButton/close-button.cjs.js +1 -1
- package/react/internals/CloseButton/close-button.js +1 -1
- package/react/internals/CloseButton/sgds-close-button.cjs.js +1 -1
- package/react/internals/CloseButton/sgds-close-button.cjs.js.map +1 -1
- package/react/internals/CloseButton/sgds-close-button.js +1 -1
- package/react/internals/CloseButton/sgds-close-button.js.map +1 -1
- package/react/styles/form-hint.cjs.js +1 -1
- package/react/styles/form-hint.js +1 -1
- package/react/styles/form-label.cjs.js +1 -1
- package/react/styles/form-label.js +1 -1
- package/react/utils/formSubmitController.cjs.js +64 -0
- package/react/utils/formSubmitController.cjs.js.map +1 -0
- package/react/utils/formSubmitController.js +60 -0
- package/react/utils/formSubmitController.js.map +1 -0
- package/react/utils/inputValidationController.cjs.js +130 -0
- package/react/utils/inputValidationController.cjs.js.map +1 -0
- package/react/utils/inputValidationController.js +126 -0
- package/react/utils/inputValidationController.js.map +1 -0
- package/react/utils/validatorMixin.cjs.js +108 -0
- package/react/utils/validatorMixin.cjs.js.map +1 -0
- package/react/utils/validatorMixin.js +104 -0
- package/react/utils/validatorMixin.js.map +1 -0
- package/styles/form-hint.js +1 -1
- package/styles/form-label.js +1 -1
- package/themes/day.css +1 -1
- package/themes/night.css +3 -2
- package/themes/root.css +1 -0
- package/utils/{form.d.ts → formSubmitController.d.ts} +10 -20
- package/utils/formSubmitController.js +59 -0
- package/utils/formSubmitController.js.map +1 -0
- package/utils/inputValidationController.d.ts +70 -0
- package/utils/inputValidationController.js +125 -0
- package/utils/inputValidationController.js.map +1 -0
- package/utils/validatorMixin.d.ts +24 -0
- package/utils/validatorMixin.js +103 -0
- package/utils/validatorMixin.js.map +1 -0
- package/base/form-check-element.d.ts +0 -50
- package/base/form-check-element.js +0 -169
- package/base/form-check-element.js.map +0 -1
- package/react/base/form-check-element.cjs.js +0 -175
- package/react/base/form-check-element.cjs.js.map +0 -1
- package/react/base/form-check-element.js +0 -170
- package/react/base/form-check-element.js.map +0 -1
- package/react/utils/form.cjs.js +0 -137
- package/react/utils/form.cjs.js.map +0 -1
- package/react/utils/form.js +0 -133
- package/react/utils/form.js.map +0 -1
- package/utils/form.js +0 -132
- package/utils/form.js.map +0 -1
|
@@ -1586,6 +1586,32 @@
|
|
|
1586
1586
|
};
|
|
1587
1587
|
}
|
|
1588
1588
|
|
|
1589
|
+
/**
|
|
1590
|
+
* @license
|
|
1591
|
+
* Copyright 2017 Google LLC
|
|
1592
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
1593
|
+
*/
|
|
1594
|
+
/**
|
|
1595
|
+
* Declares a private or protected reactive property that still triggers
|
|
1596
|
+
* updates to the element when it changes. It does not reflect from the
|
|
1597
|
+
* corresponding attribute.
|
|
1598
|
+
*
|
|
1599
|
+
* Properties declared this way must not be used from HTML or HTML templating
|
|
1600
|
+
* systems, they're solely for properties internal to the element. These
|
|
1601
|
+
* properties may be renamed by optimization tools like closure compiler.
|
|
1602
|
+
* @category Decorator
|
|
1603
|
+
*/
|
|
1604
|
+
function state(options) {
|
|
1605
|
+
return property({
|
|
1606
|
+
...options,
|
|
1607
|
+
// Add both `state` and `attribute` because we found a third party
|
|
1608
|
+
// controller that is keying off of PropertyOptions.state to determine
|
|
1609
|
+
// whether a field is a private internal property or not.
|
|
1610
|
+
state: true,
|
|
1611
|
+
attribute: false,
|
|
1612
|
+
});
|
|
1613
|
+
}
|
|
1614
|
+
|
|
1589
1615
|
/**
|
|
1590
1616
|
* @license
|
|
1591
1617
|
* Copyright 2017 Google LLC
|
|
@@ -1730,6 +1756,59 @@
|
|
|
1730
1756
|
});
|
|
1731
1757
|
}
|
|
1732
1758
|
|
|
1759
|
+
/**
|
|
1760
|
+
* @license
|
|
1761
|
+
* Copyright 2017 Google LLC
|
|
1762
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
1763
|
+
*/
|
|
1764
|
+
// Note, in the future, we may extend this decorator to support the use case
|
|
1765
|
+
// where the queried element may need to do work to become ready to interact
|
|
1766
|
+
// with (e.g. load some implementation code). If so, we might elect to
|
|
1767
|
+
// add a second argument defining a function that can be run to make the
|
|
1768
|
+
// queried element loaded/updated/ready.
|
|
1769
|
+
/**
|
|
1770
|
+
* A property decorator that converts a class property into a getter that
|
|
1771
|
+
* returns a promise that resolves to the result of a querySelector on the
|
|
1772
|
+
* element's renderRoot done after the element's `updateComplete` promise
|
|
1773
|
+
* resolves. When the queried property may change with element state, this
|
|
1774
|
+
* decorator can be used instead of requiring users to await the
|
|
1775
|
+
* `updateComplete` before accessing the property.
|
|
1776
|
+
*
|
|
1777
|
+
* @param selector A DOMString containing one or more selectors to match.
|
|
1778
|
+
*
|
|
1779
|
+
* See: https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector
|
|
1780
|
+
*
|
|
1781
|
+
* ```ts
|
|
1782
|
+
* class MyElement {
|
|
1783
|
+
* @queryAsync('#first')
|
|
1784
|
+
* first: Promise<HTMLDivElement>;
|
|
1785
|
+
*
|
|
1786
|
+
* render() {
|
|
1787
|
+
* return html`
|
|
1788
|
+
* <div id="first"></div>
|
|
1789
|
+
* <div id="second"></div>
|
|
1790
|
+
* `;
|
|
1791
|
+
* }
|
|
1792
|
+
* }
|
|
1793
|
+
*
|
|
1794
|
+
* // external usage
|
|
1795
|
+
* async doSomethingWithFirst() {
|
|
1796
|
+
* (await aMyElement.first).doSomething();
|
|
1797
|
+
* }
|
|
1798
|
+
* ```
|
|
1799
|
+
* @category Decorator
|
|
1800
|
+
*/
|
|
1801
|
+
function queryAsync(selector) {
|
|
1802
|
+
return ((obj, name) => {
|
|
1803
|
+
return desc(obj, name, {
|
|
1804
|
+
async get() {
|
|
1805
|
+
await this.updateComplete;
|
|
1806
|
+
return this.renderRoot?.querySelector(selector) ?? null;
|
|
1807
|
+
},
|
|
1808
|
+
});
|
|
1809
|
+
});
|
|
1810
|
+
}
|
|
1811
|
+
|
|
1733
1812
|
/**
|
|
1734
1813
|
* @license
|
|
1735
1814
|
* Copyright 2017 Google LLC
|
|
@@ -5160,19 +5239,19 @@
|
|
|
5160
5239
|
`is not recommended.`);
|
|
5161
5240
|
}
|
|
5162
5241
|
|
|
5163
|
-
var css_248z$
|
|
5242
|
+
var css_248z$d = css`.card{word-wrap:break-word;background-clip:border-box;background-color:var(--sgds-body-bg);border:var(--sgds-border-width) solid var(--sgds-border-color-translucent);border-radius:var(--sgds-border-radius);box-shadow:none;display:flex;flex-direction:column;height:auto;min-width:0;position:relative}.card,.card-body{color:var(--sgds-body-color)}.card-body{flex:1 1 auto;padding:var(--sgds-spacer-4)}.card-title{color:var(--sgds-body-color);margin-bottom:var(--sgds-spacer-2)}.card-subtitle,.card-text:last-child{margin-bottom:0}slot[name=card-image]::slotted(img){border-top-left-radius:calc(var(--sgds-border-radius) - var(--sgds-border-width));border-top-right-radius:calc(var(--sgds-border-radius) - var(--sgds-border-width))}slot[name=card-link]::slotted(*){font-weight:700}`;
|
|
5164
5243
|
|
|
5165
|
-
var css_248z$
|
|
5244
|
+
var css_248z$c = css`.text-primary{color:var(--sgds-primary-rgb)!important}.text-secondary{color:var(--sgds-secondary-rgb)!important}.text-success{color:var(--sgds-success-rgb)!important}.text-info{color:var(--sgds-info-rgb)!important}.text-warning{color:var(--sgds-warning-rgb)!important}.text-danger{color:var(--sgds-danger-rgb)!important}.text-light{color:var(--sgds-light-rgb)!important}.text-dark{color:var(--sgds-dark-rgb)!important}.text-muted{color:var(--sgds-secondary-color)!important}`;
|
|
5166
5245
|
|
|
5167
|
-
var css_248z$
|
|
5246
|
+
var css_248z$b = css`.bg-primary{background-color:var(--sgds-primary)!important}.bg-secondary{background-color:var(--sgds-secondary)!important}.bg-success{background-color:var(--sgds-success)!important}.bg-info{background-color:var(--sgds-info)!important}.bg-warning{background-color:var(--sgds-warning)!important}.bg-danger{background-color:var(--sgds-danger)!important}.bg-light{background-color:var(--sgds-light)!important}.bg-dark{background-color:var(--sgds-dark)!important}`;
|
|
5168
5247
|
|
|
5169
|
-
var css_248z$
|
|
5248
|
+
var css_248z$a = css`.border-primary{border-color:var(--sgds-primary)!important}.border-secondary{border-color:var(--sgds-secondary)!important}.border-success{border-color:var(--sgds-success)!important}.border-info{border-color:var(--sgds-info)!important}.border-warning{border-color:var(--sgds-warning)!important}.border-danger{border-color:var(--sgds-danger)!important}.border-light{border-color:var(--sgds-light)!important}.border-dark{border-color:var(--sgds-dark)!important}`;
|
|
5170
5249
|
|
|
5171
|
-
var css_248z$
|
|
5250
|
+
var css_248z$9 = css`.h1,.h2,.h3,.h4,.h5,.h6 ::slotted(h6),::slotted(h1),::slotted(h2),::slotted(h3),::slotted(h4),::slotted(h5),h1,h2,h3,h4,h5,h6{color:var(--sgds-heading-color);font-weight:700;line-height:1.2;margin-bottom:.5rem;margin-top:0}.h1,::slotted(h1),h1{font-size:calc(1.375rem + 1.5vw)}@media (min-width:1200px){.h1,::slotted(h1),h1{font-size:2.5rem}}.h2,::slotted(h2),h2{font-size:calc(1.325rem + .9vw)}@media (min-width:1200px){.h2,::slotted(h2),h2{font-size:2rem}}.h3,::slotted(h3),h3{font-size:calc(1.275rem + .3vw)}@media (min-width:1200px){.h3,::slotted(h3),h3{font-size:1.5rem}}.h4,::slotted(h4),h4{font-size:1.125rem}.h5,.h6 ::slotted(h6),::slotted(h5),h5,h6{font-size:1rem}.h1,::slotted(h1),h1{line-height:1.2}.h2,::slotted(h2),h2{line-height:1.25}.h3,::slotted(h3),h3{line-height:1.33}.h4,::slotted(h4),h4{line-height:1.78}.h5,.h6 ::slotted(h6),::slotted(h5),h5,h6{line-height:1.2}`;
|
|
5172
5251
|
|
|
5173
|
-
var css_248z$
|
|
5252
|
+
var css_248z$8 = css`p{margin-bottom:1.5rem;margin-top:0}`;
|
|
5174
5253
|
|
|
5175
|
-
var css_248z$
|
|
5254
|
+
var css_248z$7 = css`:host{-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:rgba(0,0,0,0);color:var(--sgds-body-color);font-family:var(--sgds-font-family-brand);font-size:var(--sgds-font-size-2);font-weight:var(--sgds-font-weight-regular);line-height:var(--sgds-line-height-heading);margin:0;*,:after,:before{box-sizing:border-box}:disabled{cursor:not-allowed}@media (prefers-reduced-motion:no-preference){:root{scroll-behavior:smooth}}::slotted(a[target=_blank]):after{background-color:currentColor;content:"/";display:inline-block;margin:0 .125rem;-webkit-mask-image:url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-box-arrow-up-right"><path fill-rule="evenodd" d="M8.636 3.5a.5.5 0 0 0-.5-.5H1.5A1.5 1.5 0 0 0 0 4.5v10A1.5 1.5 0 0 0 1.5 16h10a1.5 1.5 0 0 0 1.5-1.5V7.864a.5.5 0 0 0-1 0V14.5a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h6.636a.5.5 0 0 0 .5-.5z"/><path fill-rule="evenodd" d="M16 .5a.5.5 0 0 0-.5-.5h-5a.5.5 0 0 0 0 1h3.793L6.146 9.146a.5.5 0 1 0 .708.708L15 1.707V5.5a.5.5 0 0 0 1 0v-5z"/></svg>');mask-image:url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-box-arrow-up-right"><path fill-rule="evenodd" d="M8.636 3.5a.5.5 0 0 0-.5-.5H1.5A1.5 1.5 0 0 0 0 4.5v10A1.5 1.5 0 0 0 1.5 16h10a1.5 1.5 0 0 0 1.5-1.5V7.864a.5.5 0 0 0-1 0V14.5a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h6.636a.5.5 0 0 0 .5-.5z"/><path fill-rule="evenodd" d="M16 .5a.5.5 0 0 0-.5-.5h-5a.5.5 0 0 0 0 1h3.793L6.146 9.146a.5.5 0 1 0 .708.708L15 1.707V5.5a.5.5 0 0 0 1 0v-5z"/></svg>');-webkit-mask-position:center;mask-position:center;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;mask-size:73%;-webkit-mask-size:73%;padding:0 .45em}::slotted(a){color:var(--sgds-link);text-decoration:var(--sgds-link-decoration)}::slotted(a:hover){color:var(--sgds-link-hover-color)}::slotted(svg){vertical-align:middle}}`;
|
|
5176
5255
|
|
|
5177
5256
|
/**
|
|
5178
5257
|
* @cssprop --sgds-{stateColor} - State colors in hexadecimal value
|
|
@@ -5190,11 +5269,11 @@
|
|
|
5190
5269
|
return event;
|
|
5191
5270
|
}
|
|
5192
5271
|
}
|
|
5193
|
-
SgdsElement.styles = [css_248z$
|
|
5272
|
+
SgdsElement.styles = [css_248z$7];
|
|
5194
5273
|
|
|
5195
5274
|
class CardElement extends SgdsElement {
|
|
5196
5275
|
}
|
|
5197
|
-
CardElement.styles = [...SgdsElement.styles, css_248z$
|
|
5276
|
+
CardElement.styles = [...SgdsElement.styles, css_248z$c, css_248z$b, css_248z$a, css_248z$9, css_248z$8, css_248z$d];
|
|
5198
5277
|
__decorate([
|
|
5199
5278
|
property()
|
|
5200
5279
|
], CardElement.prototype, "borderColor", void 0);
|
|
@@ -5259,6 +5338,56 @@
|
|
|
5259
5338
|
*/
|
|
5260
5339
|
const ifDefined = (value) => value ?? nothing;
|
|
5261
5340
|
|
|
5341
|
+
var css_248z$6 = css`.invalid-feedback-container{display:flex;gap:var(--sgds-form-gap-sm)}.invalid-feedback{color:var(--sgds-form-danger-color);font-size:var(--sgds-font-size-1);font-weight:var(--sgds-font-weight-regular)}`;
|
|
5342
|
+
|
|
5343
|
+
var css_248z$5 = css`.form-text{color:var(--sgds-form-color-subtle);font-size:var(--sgds-font-size-1)}.form-text.disabled{opacity:var(--sgds-opacity-50)}`;
|
|
5344
|
+
|
|
5345
|
+
var css_248z$4 = css`.form-label{color:var(--sgds-form-color);margin-bottom:0}.form-label.disabled{opacity:var(--sgds-opacity-50)}.form-check-label{color:var(--sgds-form-color)}.form-check-input:disabled~.form-check-label,.form-check-input[disabled]~.form-check-label{cursor:not-allowed}`;
|
|
5346
|
+
|
|
5347
|
+
var css_248z$3 = css`.form-control::placeholder{color:var(--sgds-form-color-subtle);font-family:var(--sgds-font-family-brand);font-weight:var(--sgds-font-weight-light);line-height:var(--sgds-line-height-heading)}`;
|
|
5348
|
+
|
|
5349
|
+
class FormControlElement extends SgdsElement {
|
|
5350
|
+
constructor() {
|
|
5351
|
+
super(...arguments);
|
|
5352
|
+
/** The input's label */
|
|
5353
|
+
this.label = "";
|
|
5354
|
+
/** The input's hint text */
|
|
5355
|
+
this.hintText = "";
|
|
5356
|
+
/** Disables the input. */
|
|
5357
|
+
this.disabled = false;
|
|
5358
|
+
/** Marks the component as invalid. Replace the pseudo :invalid selector for absent in custom elements */
|
|
5359
|
+
this.invalid = false;
|
|
5360
|
+
this._controlId = genId("input");
|
|
5361
|
+
this._labelId = genId("label");
|
|
5362
|
+
}
|
|
5363
|
+
/** Programatically sets the invalid state of the input. Pass in boolean value in the argument */
|
|
5364
|
+
setInvalid(bool) {
|
|
5365
|
+
this.invalid = bool;
|
|
5366
|
+
if (bool) {
|
|
5367
|
+
this.emit("sgds-invalid");
|
|
5368
|
+
}
|
|
5369
|
+
else {
|
|
5370
|
+
this.emit("sgds-valid");
|
|
5371
|
+
}
|
|
5372
|
+
}
|
|
5373
|
+
}
|
|
5374
|
+
FormControlElement.styles = [...SgdsElement.styles, css_248z$6, css_248z$5, css_248z$4, css_248z$3];
|
|
5375
|
+
__decorate([
|
|
5376
|
+
property({ reflect: true })
|
|
5377
|
+
], FormControlElement.prototype, "label", void 0);
|
|
5378
|
+
__decorate([
|
|
5379
|
+
property({ reflect: true })
|
|
5380
|
+
], FormControlElement.prototype, "hintText", void 0);
|
|
5381
|
+
__decorate([
|
|
5382
|
+
property({ reflect: true })
|
|
5383
|
+
], FormControlElement.prototype, "name", void 0);
|
|
5384
|
+
__decorate([
|
|
5385
|
+
property({ type: Boolean, reflect: true })
|
|
5386
|
+
], FormControlElement.prototype, "disabled", void 0);
|
|
5387
|
+
__decorate([
|
|
5388
|
+
property({ type: Boolean, reflect: true })
|
|
5389
|
+
], FormControlElement.prototype, "invalid", void 0);
|
|
5390
|
+
|
|
5262
5391
|
// @defaultValue decorator
|
|
5263
5392
|
const defaultValue = (propertyName = "value") => (proto, key) => {
|
|
5264
5393
|
const ctor = proto.constructor;
|
|
@@ -5279,294 +5408,227 @@
|
|
|
5279
5408
|
};
|
|
5280
5409
|
};
|
|
5281
5410
|
|
|
5282
|
-
|
|
5283
|
-
|
|
5411
|
+
/**
|
|
5412
|
+
* SGDS custom form validation methods and behaviours
|
|
5413
|
+
*/
|
|
5414
|
+
class InputValidationController {
|
|
5284
5415
|
constructor(host, options) {
|
|
5285
5416
|
(this.host = host).addController(this);
|
|
5286
|
-
this.
|
|
5287
|
-
|
|
5288
|
-
|
|
5289
|
-
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
} }, options);
|
|
5293
|
-
this.handleFormData = this.handleFormData.bind(this);
|
|
5294
|
-
this.handleFormSubmit = this.handleFormSubmit.bind(this);
|
|
5295
|
-
this.handleFormReset = this.handleFormReset.bind(this);
|
|
5296
|
-
this.reportFormValidity = this.reportFormValidity.bind(this);
|
|
5417
|
+
this._internals = this.host.attachInternals();
|
|
5418
|
+
this.options = Object.assign({ setInvalid: (host, value) => {
|
|
5419
|
+
host.invalid = value;
|
|
5420
|
+
}, value: (host) => {
|
|
5421
|
+
return host.value;
|
|
5422
|
+
}, input: (host) => host.input }, options);
|
|
5297
5423
|
}
|
|
5298
5424
|
hostConnected() {
|
|
5299
|
-
this.
|
|
5300
|
-
if (this.form) {
|
|
5301
|
-
this.form.addEventListener("formdata", this.handleFormData);
|
|
5302
|
-
this.form.addEventListener("submit", this.handleFormSubmit);
|
|
5303
|
-
this.form.addEventListener("reset", this.handleFormReset);
|
|
5304
|
-
// Overload the form's reportValidity() method so it looks at Shoelace form controls
|
|
5305
|
-
if (!reportValidityOverloads.has(this.form)) {
|
|
5306
|
-
reportValidityOverloads.set(this.form, this.form.reportValidity);
|
|
5307
|
-
this.form.reportValidity = () => this.reportFormValidity();
|
|
5308
|
-
}
|
|
5309
|
-
}
|
|
5425
|
+
this.host.addEventListener("invalid", e => this.handleInvalid(e));
|
|
5310
5426
|
}
|
|
5311
5427
|
hostDisconnected() {
|
|
5312
|
-
|
|
5313
|
-
this.form.removeEventListener("formdata", this.handleFormData);
|
|
5314
|
-
this.form.removeEventListener("submit", this.handleFormSubmit);
|
|
5315
|
-
this.form.removeEventListener("reset", this.handleFormReset);
|
|
5316
|
-
// Remove the overload and restore the original method
|
|
5317
|
-
if (reportValidityOverloads.has(this.form)) {
|
|
5318
|
-
this.form.reportValidity = reportValidityOverloads.get(this.form);
|
|
5319
|
-
reportValidityOverloads.delete(this.form);
|
|
5320
|
-
}
|
|
5321
|
-
this.form = undefined;
|
|
5322
|
-
}
|
|
5428
|
+
this.host.removeEventListener("invalid", e => this.handleInvalid(e));
|
|
5323
5429
|
}
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
});
|
|
5333
|
-
}
|
|
5334
|
-
else {
|
|
5335
|
-
event.formData.append(name, value.toString());
|
|
5336
|
-
}
|
|
5337
|
-
}
|
|
5430
|
+
/**
|
|
5431
|
+
* Prevents the native browser error message pop up when reportValidity() called by
|
|
5432
|
+
* associated form or the component's reportValidity during constraint validation
|
|
5433
|
+
* Sets invalid reactive prop to true
|
|
5434
|
+
*/
|
|
5435
|
+
handleInvalid(e) {
|
|
5436
|
+
e.preventDefault();
|
|
5437
|
+
this.options.setInvalid(this.host, true);
|
|
5338
5438
|
}
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
|
|
5343
|
-
|
|
5344
|
-
|
|
5345
|
-
|
|
5346
|
-
|
|
5347
|
-
|
|
5348
|
-
this.
|
|
5349
|
-
}
|
|
5350
|
-
reportFormValidity() {
|
|
5351
|
-
//
|
|
5352
|
-
// Shoelace form controls work hard to act like regular form controls. They support the Constraint Validation API
|
|
5353
|
-
// and its associated methods such as setCustomValidity() and reportValidity(). However, the HTMLFormElement also
|
|
5354
|
-
// has a reportValidity() method that will trigger validation on all child controls. Since we're not yet using
|
|
5355
|
-
// ElementInternals, we need to overload this method so it looks for any element with the reportValidity() method.
|
|
5356
|
-
//
|
|
5357
|
-
// We preserve the original method in a WeakMap, but we don't call it from the overload because that would trigger
|
|
5358
|
-
// validations in an unexpected order. When the element disconnects, we revert to the original behavior. This won't
|
|
5359
|
-
// be necessary once we can use ElementInternals.
|
|
5360
|
-
//
|
|
5361
|
-
// Note that we're also honoring the form's novalidate attribute.
|
|
5362
|
-
//
|
|
5363
|
-
if (this.form && !this.form.noValidate) {
|
|
5364
|
-
// This seems sloppy, but checking all elements will cover native inputs, Shoelace inputs, and other custom
|
|
5365
|
-
// elements that support the constraint validation API.
|
|
5366
|
-
const elements = this.form.querySelectorAll("*");
|
|
5367
|
-
for (const element of elements) {
|
|
5368
|
-
if (typeof element.reportValidity === "function") {
|
|
5369
|
-
if (!element.reportValidity()) {
|
|
5370
|
-
return false;
|
|
5371
|
-
}
|
|
5372
|
-
}
|
|
5373
|
-
}
|
|
5374
|
-
}
|
|
5375
|
-
return true;
|
|
5439
|
+
/**
|
|
5440
|
+
* Sets invalid to false when invoked and
|
|
5441
|
+
* Updates the ValidityState based on new value, but
|
|
5442
|
+
* does not update invalid reactive prop
|
|
5443
|
+
* @param e
|
|
5444
|
+
*/
|
|
5445
|
+
handleInput(e) {
|
|
5446
|
+
const input = e.target;
|
|
5447
|
+
this.options.setInvalid(this.host, false);
|
|
5448
|
+
this.validateInput(input);
|
|
5376
5449
|
}
|
|
5377
|
-
|
|
5378
|
-
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
|
|
5384
|
-
|
|
5385
|
-
|
|
5386
|
-
button.style.whiteSpace = "nowrap";
|
|
5387
|
-
// Pass form attributes through to the temporary button
|
|
5388
|
-
if (invoker) {
|
|
5389
|
-
["formaction", "formmethod", "formnovalidate", "formtarget"].forEach(attr => {
|
|
5390
|
-
if (invoker.hasAttribute(attr)) {
|
|
5391
|
-
button.setAttribute(attr, invoker.getAttribute(attr));
|
|
5392
|
-
}
|
|
5393
|
-
});
|
|
5394
|
-
}
|
|
5395
|
-
this.form.append(button);
|
|
5396
|
-
button.click();
|
|
5397
|
-
button.remove();
|
|
5398
|
-
}
|
|
5450
|
+
/**
|
|
5451
|
+
* Validate the input's new value after onChange and
|
|
5452
|
+
* update invalid reactive prop
|
|
5453
|
+
* @param e
|
|
5454
|
+
*/
|
|
5455
|
+
handleChange(e) {
|
|
5456
|
+
const input = e.target;
|
|
5457
|
+
this.validateInput(input);
|
|
5458
|
+
this.options.setInvalid(this.host, !this.checkValidity());
|
|
5399
5459
|
}
|
|
5400
|
-
|
|
5401
|
-
|
|
5402
|
-
this.doAction("reset", invoker);
|
|
5460
|
+
get form() {
|
|
5461
|
+
return this._internals.form;
|
|
5403
5462
|
}
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
// Calling form.submit() bypasses the submit event and constraint validation. To prevent this, we can inject a
|
|
5407
|
-
// native submit button into the form, "click" it, then remove it to simulate a standard form submission.
|
|
5408
|
-
this.doAction("submit", invoker);
|
|
5463
|
+
get validity() {
|
|
5464
|
+
return this._internals.validity;
|
|
5409
5465
|
}
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
class FormCheckElement extends SgdsElement {
|
|
5413
|
-
constructor() {
|
|
5414
|
-
super(...arguments);
|
|
5415
|
-
/**@internal */
|
|
5416
|
-
this.formSubmitController = new FormSubmitController(this, {
|
|
5417
|
-
value: (control) => (control.checked ? control.value : undefined),
|
|
5418
|
-
defaultValue: (control) => control.defaultChecked,
|
|
5419
|
-
setValue: (control, checked) => (control.checked = checked)
|
|
5420
|
-
});
|
|
5421
|
-
/** For aria-label when there is no appropriate text label visible */
|
|
5422
|
-
this.ariaLabel = "checkbox";
|
|
5423
|
-
/** Makes the checkbox a required field. */
|
|
5424
|
-
this.required = false;
|
|
5425
|
-
/** Draws the checkbox in a checked state. */
|
|
5426
|
-
this.checked = false;
|
|
5427
|
-
/** Disables the checkbox (so the user can't check / uncheck it). */
|
|
5428
|
-
this.disabled = false;
|
|
5429
|
-
/** Allows invalidFeedback, invalid and valid styles to be visible with the input */
|
|
5430
|
-
this.hasFeedback = false;
|
|
5431
|
-
/** Gets or sets the default value used to reset this element. The initial value corresponds to the one originally specified in the HTML that created this element. */
|
|
5432
|
-
this.defaultChecked = false;
|
|
5433
|
-
/** Marks the checkbox input as invalid. Replace the pseudo :invalid selector for absent in custom elements */
|
|
5434
|
-
this.invalid = false;
|
|
5435
|
-
/** Marks the checkbox input as indeterminate , with indeterminate logo */
|
|
5436
|
-
this.indeterminate = false;
|
|
5466
|
+
get validationMessage() {
|
|
5467
|
+
return this._internals.validationMessage;
|
|
5437
5468
|
}
|
|
5438
|
-
|
|
5439
|
-
|
|
5469
|
+
get willValidate() {
|
|
5470
|
+
return this._internals.willValidate;
|
|
5440
5471
|
}
|
|
5441
|
-
/**
|
|
5442
|
-
|
|
5443
|
-
|
|
5472
|
+
/**
|
|
5473
|
+
* Checks the validity and updates the invalid reactive prop of form components
|
|
5474
|
+
*/
|
|
5475
|
+
updateInvalidState() {
|
|
5476
|
+
this.options.setInvalid(this.host, !this.checkValidity());
|
|
5444
5477
|
}
|
|
5445
|
-
/**
|
|
5446
|
-
|
|
5447
|
-
|
|
5478
|
+
/**
|
|
5479
|
+
* Resets the ValidityState of the control
|
|
5480
|
+
*/
|
|
5481
|
+
resetValidity() {
|
|
5482
|
+
return this._internals.setValidity({});
|
|
5448
5483
|
}
|
|
5449
|
-
/**
|
|
5450
|
-
|
|
5451
|
-
|
|
5484
|
+
/**
|
|
5485
|
+
* Reports the validity
|
|
5486
|
+
*/
|
|
5487
|
+
checkValidity() {
|
|
5488
|
+
return this._internals.checkValidity();
|
|
5452
5489
|
}
|
|
5453
|
-
/**
|
|
5490
|
+
/**
|
|
5491
|
+
* Reports the validity with a error popup message
|
|
5492
|
+
*/
|
|
5454
5493
|
reportValidity() {
|
|
5455
|
-
|
|
5456
|
-
this.invalid = !this.input.checkValidity();
|
|
5457
|
-
}
|
|
5458
|
-
return this.input.reportValidity();
|
|
5494
|
+
return this._internals.reportValidity();
|
|
5459
5495
|
}
|
|
5460
|
-
|
|
5461
|
-
|
|
5462
|
-
|
|
5463
|
-
|
|
5464
|
-
|
|
5465
|
-
|
|
5466
|
-
this.
|
|
5496
|
+
/**
|
|
5497
|
+
* Sets the form control value into FormData,
|
|
5498
|
+
* making the value of control accessible via FormData
|
|
5499
|
+
*/
|
|
5500
|
+
setFormValue() {
|
|
5501
|
+
const value = this.options.value(this.host);
|
|
5502
|
+
this._internals.setFormValue(value);
|
|
5467
5503
|
}
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
|
|
5471
|
-
|
|
5504
|
+
/**
|
|
5505
|
+
* Updates the ValidityState of the input in form component at current state
|
|
5506
|
+
*/
|
|
5507
|
+
validateInput(input) {
|
|
5508
|
+
/** When the form control is disabled, its always valid */
|
|
5509
|
+
if (this.options.input(this.host).disabled) {
|
|
5510
|
+
return this._internals.setValidity({});
|
|
5511
|
+
}
|
|
5512
|
+
// get the validity of the internal <input>
|
|
5513
|
+
const validState = input.validity;
|
|
5514
|
+
// if the input is invalid, show the correct error
|
|
5515
|
+
if (!validState.valid) {
|
|
5516
|
+
// loop through the error reasons
|
|
5517
|
+
for (const state in validState) {
|
|
5518
|
+
// if there is an error and corresponding attribute holding
|
|
5519
|
+
// the message
|
|
5520
|
+
if (validState[state]) {
|
|
5521
|
+
this.validationError = state.toString();
|
|
5522
|
+
// set the validity error reason and the corresponding
|
|
5523
|
+
// message
|
|
5524
|
+
this._internals.setValidity({ [this.validationError]: true }, input.validationMessage, input);
|
|
5525
|
+
}
|
|
5526
|
+
}
|
|
5527
|
+
}
|
|
5528
|
+
else {
|
|
5529
|
+
this._internals.setValidity({});
|
|
5472
5530
|
}
|
|
5473
|
-
}
|
|
5474
|
-
_handleInvalid(e) {
|
|
5475
|
-
e.preventDefault();
|
|
5476
|
-
this.invalid = true;
|
|
5477
|
-
}
|
|
5478
|
-
/** @internal */
|
|
5479
|
-
handleDisabledChange() {
|
|
5480
|
-
// Disabled form controls are always valid, so we need to recheck validity when the state changes
|
|
5481
|
-
this.input.disabled = this.disabled;
|
|
5482
|
-
this.invalid = !this.input.checkValidity();
|
|
5483
|
-
}
|
|
5484
|
-
/** @internal */
|
|
5485
|
-
handleStateChange() {
|
|
5486
|
-
this.invalid = !this.input.checkValidity();
|
|
5487
|
-
}
|
|
5488
|
-
render() {
|
|
5489
|
-
return html$1 `
|
|
5490
|
-
<div
|
|
5491
|
-
class=${classMap({
|
|
5492
|
-
"form-check": true
|
|
5493
|
-
})}
|
|
5494
|
-
>
|
|
5495
|
-
<input
|
|
5496
|
-
class=${classMap({
|
|
5497
|
-
"form-check-input": true,
|
|
5498
|
-
"is-invalid": this.hasFeedback && this.invalid,
|
|
5499
|
-
md: this._size === "md"
|
|
5500
|
-
})}
|
|
5501
|
-
type="checkbox"
|
|
5502
|
-
id=${this._inputId}
|
|
5503
|
-
aria-invalid=${this.invalid ? "true" : "false"}
|
|
5504
|
-
name=${ifDefined(this.name)}
|
|
5505
|
-
value=${ifDefined(this.value)}
|
|
5506
|
-
?checked=${this.checked}
|
|
5507
|
-
?indeterminate=${this.indeterminate}
|
|
5508
|
-
?disabled=${this.disabled}
|
|
5509
|
-
?required=${this.required}
|
|
5510
|
-
aria-disabled=${this.disabled ? "true" : "false"}
|
|
5511
|
-
aria-checked=${this.checked ? "true" : "false"}
|
|
5512
|
-
@change=${this._handleChange}
|
|
5513
|
-
@keydown=${this._handleKeyDown}
|
|
5514
|
-
@invalid=${(e) => this._handleInvalid(e)}
|
|
5515
|
-
/>
|
|
5516
|
-
<label for="${this._inputId}" aria-label=${ifDefined(this.ariaLabel)} class="form-check-label"
|
|
5517
|
-
><slot></slot
|
|
5518
|
-
></label>
|
|
5519
|
-
</div>
|
|
5520
|
-
`;
|
|
5521
5531
|
}
|
|
5522
5532
|
}
|
|
5523
|
-
__decorate([
|
|
5524
|
-
query('input[type="checkbox"]')
|
|
5525
|
-
], FormCheckElement.prototype, "input", void 0);
|
|
5526
|
-
__decorate([
|
|
5527
|
-
property({ type: String, reflect: true })
|
|
5528
|
-
], FormCheckElement.prototype, "name", void 0);
|
|
5529
|
-
__decorate([
|
|
5530
|
-
property({ type: String, reflect: true })
|
|
5531
|
-
], FormCheckElement.prototype, "ariaLabel", void 0);
|
|
5532
|
-
__decorate([
|
|
5533
|
-
property({ type: String, reflect: true })
|
|
5534
|
-
], FormCheckElement.prototype, "value", void 0);
|
|
5535
|
-
__decorate([
|
|
5536
|
-
property({ type: Boolean, reflect: true })
|
|
5537
|
-
], FormCheckElement.prototype, "required", void 0);
|
|
5538
|
-
__decorate([
|
|
5539
|
-
property({ type: Boolean, reflect: true })
|
|
5540
|
-
], FormCheckElement.prototype, "checked", void 0);
|
|
5541
|
-
__decorate([
|
|
5542
|
-
property({ type: Boolean, reflect: true })
|
|
5543
|
-
], FormCheckElement.prototype, "disabled", void 0);
|
|
5544
|
-
__decorate([
|
|
5545
|
-
property({ type: Boolean, reflect: true })
|
|
5546
|
-
], FormCheckElement.prototype, "hasFeedback", void 0);
|
|
5547
|
-
__decorate([
|
|
5548
|
-
defaultValue("checked")
|
|
5549
|
-
], FormCheckElement.prototype, "defaultChecked", void 0);
|
|
5550
|
-
__decorate([
|
|
5551
|
-
property({ type: Boolean, reflect: true })
|
|
5552
|
-
], FormCheckElement.prototype, "invalid", void 0);
|
|
5553
|
-
__decorate([
|
|
5554
|
-
property({ type: Boolean, reflect: true })
|
|
5555
|
-
], FormCheckElement.prototype, "indeterminate", void 0);
|
|
5556
|
-
__decorate([
|
|
5557
|
-
watch("invalid", { waitUntilFirstUpdate: true })
|
|
5558
|
-
], FormCheckElement.prototype, "_handleInvalidChange", null);
|
|
5559
|
-
__decorate([
|
|
5560
|
-
property({ type: String })
|
|
5561
|
-
], FormCheckElement.prototype, "_size", void 0);
|
|
5562
|
-
__decorate([
|
|
5563
|
-
watch("disabled", { waitUntilFirstUpdate: true })
|
|
5564
|
-
], FormCheckElement.prototype, "handleDisabledChange", null);
|
|
5565
|
-
__decorate([
|
|
5566
|
-
watch("checked", { waitUntilFirstUpdate: true })
|
|
5567
|
-
], FormCheckElement.prototype, "handleStateChange", null);
|
|
5568
5533
|
|
|
5569
|
-
|
|
5534
|
+
/**
|
|
5535
|
+
* @summary The FormValidationMixin used by the form components
|
|
5536
|
+
* @param superClass
|
|
5537
|
+
* @returns
|
|
5538
|
+
*/
|
|
5539
|
+
const SgdsFormValidatorMixin = (superClass) => {
|
|
5540
|
+
class ToBeValidatedElement extends superClass {
|
|
5541
|
+
constructor() {
|
|
5542
|
+
super(...arguments);
|
|
5543
|
+
this._isTouched = false;
|
|
5544
|
+
}
|
|
5545
|
+
connectedCallback() {
|
|
5546
|
+
super.connectedCallback();
|
|
5547
|
+
this.inputValidationController = new InputValidationController(this);
|
|
5548
|
+
}
|
|
5549
|
+
async firstUpdated(changedProperties) {
|
|
5550
|
+
super.firstUpdated(changedProperties);
|
|
5551
|
+
/* Either input or sgds-input. For example, quantity-toggle uses sgds-input */
|
|
5552
|
+
this.input =
|
|
5553
|
+
this.shadowRoot.querySelector("input") || (await this.sgdsInput) || this.shadowRoot.querySelector("textarea");
|
|
5554
|
+
this._mixinValidate(this.input);
|
|
5555
|
+
}
|
|
5556
|
+
/**
|
|
5557
|
+
* Native lifecycle of Form-Associated Custom Element Callbacks
|
|
5558
|
+
*/
|
|
5559
|
+
formResetCallback() {
|
|
5560
|
+
if (this._mixinResetFormControl) {
|
|
5561
|
+
this._mixinResetFormControl();
|
|
5562
|
+
}
|
|
5563
|
+
else {
|
|
5564
|
+
this.value = this.defaultValue;
|
|
5565
|
+
this._mixinResetValidity(this.input);
|
|
5566
|
+
}
|
|
5567
|
+
this._mixinSetFormValue();
|
|
5568
|
+
}
|
|
5569
|
+
/**
|
|
5570
|
+
*
|
|
5571
|
+
* Methods use by classes using this mixin
|
|
5572
|
+
*/
|
|
5573
|
+
/**
|
|
5574
|
+
* OnChange of form component
|
|
5575
|
+
* 1. Make value of control accessible via FormData
|
|
5576
|
+
* 2. Run change handler
|
|
5577
|
+
*/
|
|
5578
|
+
_mixinHandleChange(e) {
|
|
5579
|
+
this._mixinSetFormValue();
|
|
5580
|
+
this.inputValidationController.handleChange(e);
|
|
5581
|
+
}
|
|
5582
|
+
/**
|
|
5583
|
+
* OnChange of form component
|
|
5584
|
+
* 1. Make value of control accessible via FormData
|
|
5585
|
+
* 2. Run input handler
|
|
5586
|
+
*/
|
|
5587
|
+
_mixinHandleInputChange(e) {
|
|
5588
|
+
this._mixinSetFormValue();
|
|
5589
|
+
this.inputValidationController.handleInput(e);
|
|
5590
|
+
}
|
|
5591
|
+
/**
|
|
5592
|
+
* During form resetting,
|
|
5593
|
+
* 1. ValidityState is reset
|
|
5594
|
+
* 2. invalid reactive prop is updated after the reset
|
|
5595
|
+
* 3. Revalidates the ValidityState (but do not update invalid prop)
|
|
5596
|
+
* to prepare for the next validity check
|
|
5597
|
+
* 4. Reset touched state to false for a pristine form
|
|
5598
|
+
*/
|
|
5599
|
+
_mixinResetValidity(input) {
|
|
5600
|
+
this.inputValidationController.resetValidity();
|
|
5601
|
+
this.inputValidationController.updateInvalidState();
|
|
5602
|
+
this.inputValidationController.validateInput(input);
|
|
5603
|
+
this._isTouched ? (this._isTouched = false) : null;
|
|
5604
|
+
}
|
|
5605
|
+
_mixinValidate(input) {
|
|
5606
|
+
this.inputValidationController.validateInput(input);
|
|
5607
|
+
}
|
|
5608
|
+
_mixinSetFormValue() {
|
|
5609
|
+
this.inputValidationController.setFormValue();
|
|
5610
|
+
}
|
|
5611
|
+
_mixinCheckValidity() {
|
|
5612
|
+
return this.inputValidationController.checkValidity();
|
|
5613
|
+
}
|
|
5614
|
+
_mixinReportValidity() {
|
|
5615
|
+
return this.inputValidationController.reportValidity();
|
|
5616
|
+
}
|
|
5617
|
+
_mixinGetValidity() {
|
|
5618
|
+
return this.inputValidationController.validity;
|
|
5619
|
+
}
|
|
5620
|
+
_mixinGetValidationMessage() {
|
|
5621
|
+
return this.inputValidationController.validationMessage;
|
|
5622
|
+
}
|
|
5623
|
+
}
|
|
5624
|
+
ToBeValidatedElement.formAssociated = true;
|
|
5625
|
+
__decorate([
|
|
5626
|
+
queryAsync("sgds-input")
|
|
5627
|
+
], ToBeValidatedElement.prototype, "sgdsInput", void 0);
|
|
5628
|
+
return ToBeValidatedElement;
|
|
5629
|
+
};
|
|
5630
|
+
|
|
5631
|
+
var css_248z$2 = css`input{margin:0}.form-check{display:flex;gap:var(--sgds-form-gap-md);padding:var(--sgds-form-padding-inline-sm) 0}.form-check-input,.form-check-input-container{height:var(--sgds-form-height-sm);width:var(--sgds-form-width-xs)}.form-check-input{appearance:none;background-color:var(--sgds-form-bg);background-image:var(--sgds-radio-bg-image);background-position:50%;background-repeat:no-repeat;background-size:auto;border:var(--sgds-form-border-width-default) solid var(--sgds-form-border-color);border-radius:var(--sgds-form-border-radius-md)}.form-check-input:focus,.form-check-input:focus-visible{box-shadow:var(--sgds-form-box-shadow-focus);outline:0}.form-check-input:checked,.form-check-input[checked]{--sgds-radio-bg-image:url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="17" height="16" fill="none"><path d="M14.347 3.979a.522.522 0 0 1 0 .739L7.043 12.02a.521.521 0 0 1-.738 0L2.653 8.369a.522.522 0 1 1 .739-.738l3.282 3.283 6.934-6.935a.52.52 0 0 1 .739 0Z" fill="%23fff"/></svg>');background-color:var(--sgds-form-primary-bg)}.form-check-input:indeterminate,.form-check-input[indeterminate]{--sgds-radio-bg-image:url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="17" height="16" fill="none"><path fill-rule="evenodd" clip-rule="evenodd" d="M2.5 8a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5Z" fill="%23fff"/></svg>');background-color:var(--sgds-form-primary-bg)}:host([disabled]) .form-check{cursor:not-allowed;opacity:var(--sgds-opacity-50)}.form-check-input.is-invalid{border:var(--sgds-form-border-width-thick) solid var(--sgds-form-danger-border-color)}.form-check-input:checked.is-invalid,.form-check-input[checked].is-invalid{background-color:var(--sgds-form-danger-bg)}.form-check-input:indeterminate.is-invalid,.form-check-input[indeterminate].is-invalid{background-color:var(--sgds-form-danger-bg)}`;
|
|
5570
5632
|
|
|
5571
5633
|
/**
|
|
5572
5634
|
* @summary Checkbox component is used when you require users to select multiple items from a list.
|
|
@@ -5574,36 +5636,29 @@
|
|
|
5574
5636
|
* @slot default - The label of checkbox.
|
|
5575
5637
|
*
|
|
5576
5638
|
* @event sgds-change - Emitted when the checked state changes.
|
|
5639
|
+
* @event sgds-blur - Emitted when input is not in focus.
|
|
5640
|
+
* @event sgds-focus - Emitted when input is in focus.
|
|
5577
5641
|
* @event sgds-validity-change - Emitted when the invalid state changes. This event is used by sgds-checkbox-group to check the invalid state change of its children
|
|
5578
5642
|
*/
|
|
5579
|
-
class SgdsCheckbox extends
|
|
5643
|
+
class SgdsCheckbox extends SgdsFormValidatorMixin(FormControlElement) {
|
|
5580
5644
|
constructor() {
|
|
5581
5645
|
super(...arguments);
|
|
5582
|
-
/**@internal */
|
|
5583
|
-
this.formSubmitController = new FormSubmitController(this, {
|
|
5584
|
-
value: (control) => (control.checked ? control.value : undefined),
|
|
5585
|
-
defaultValue: (control) => control.defaultChecked,
|
|
5586
|
-
setValue: (control, checked) => (control.checked = checked)
|
|
5587
|
-
});
|
|
5588
|
-
/** Makes the checkbox a required field. */
|
|
5589
|
-
this.required = false;
|
|
5590
5646
|
/** Draws the checkbox in a checked state. */
|
|
5591
5647
|
this.checked = false;
|
|
5592
|
-
/** Disables the checkbox (so the user can't check / uncheck it). */
|
|
5593
|
-
this.disabled = false;
|
|
5594
5648
|
/** Allows invalidFeedback, invalid and valid styles to be visible with the input */
|
|
5595
5649
|
this.hasFeedback = false;
|
|
5596
5650
|
/** Gets or sets the default value used to reset this element. The initial value corresponds to the one originally specified in the HTML that created this element. */
|
|
5597
5651
|
this.defaultChecked = false;
|
|
5598
|
-
/** Marks the checkbox input as invalid. Replace the pseudo :invalid selector for absent in custom elements */
|
|
5599
|
-
this.invalid = false;
|
|
5600
5652
|
/** Marks the checkbox input as indeterminate , with indeterminate logo */
|
|
5601
5653
|
this.indeterminate = false;
|
|
5602
|
-
/**
|
|
5603
|
-
this.
|
|
5654
|
+
/** Makes the checkbox a required field. */
|
|
5655
|
+
this.required = false;
|
|
5656
|
+
this._isTouched = false;
|
|
5604
5657
|
}
|
|
5605
5658
|
_handleInvalidChange() {
|
|
5606
|
-
this.emit("sgds-validity-change", {
|
|
5659
|
+
this.emit("sgds-validity-change", {
|
|
5660
|
+
detail: { invalid: this.invalid, validationMessage: this.input.validationMessage }
|
|
5661
|
+
});
|
|
5607
5662
|
}
|
|
5608
5663
|
/** Simulates a click on the checkbox. */
|
|
5609
5664
|
click() {
|
|
@@ -5617,19 +5672,13 @@
|
|
|
5617
5672
|
blur() {
|
|
5618
5673
|
this.input.blur();
|
|
5619
5674
|
}
|
|
5620
|
-
|
|
5621
|
-
reportValidity() {
|
|
5622
|
-
if (!this.input.reportValidity()) {
|
|
5623
|
-
this.invalid = !this.input.checkValidity();
|
|
5624
|
-
}
|
|
5625
|
-
return this.input.reportValidity();
|
|
5626
|
-
}
|
|
5627
|
-
_handleChange() {
|
|
5675
|
+
_handleChange(e) {
|
|
5628
5676
|
if (this.indeterminate) {
|
|
5629
5677
|
this.indeterminate = !this.indeterminate;
|
|
5630
5678
|
}
|
|
5631
5679
|
this.checked = !this.checked;
|
|
5632
5680
|
this.value = this.input.value;
|
|
5681
|
+
super._mixinHandleChange(e);
|
|
5633
5682
|
this.emit("sgds-change", { detail: { checked: this.checked, value: this.value } });
|
|
5634
5683
|
}
|
|
5635
5684
|
_handleKeyDown(event) {
|
|
@@ -5638,6 +5687,13 @@
|
|
|
5638
5687
|
this.click();
|
|
5639
5688
|
}
|
|
5640
5689
|
}
|
|
5690
|
+
_handleBlur() {
|
|
5691
|
+
this._isTouched = true;
|
|
5692
|
+
this.emit("sgds-blur");
|
|
5693
|
+
}
|
|
5694
|
+
_handleFocus() {
|
|
5695
|
+
this.emit("sgds-focus");
|
|
5696
|
+
}
|
|
5641
5697
|
_handleInvalid(e) {
|
|
5642
5698
|
e.preventDefault();
|
|
5643
5699
|
this.invalid = true;
|
|
@@ -5645,12 +5701,43 @@
|
|
|
5645
5701
|
/** @internal */
|
|
5646
5702
|
_handleDisabledChange() {
|
|
5647
5703
|
// Disabled form controls are always valid, so we need to recheck validity when the state changes
|
|
5648
|
-
this.
|
|
5649
|
-
this.invalid = !this.input.checkValidity();
|
|
5704
|
+
this.setInvalid(false);
|
|
5650
5705
|
}
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
|
|
5706
|
+
_handleIsTouched() {
|
|
5707
|
+
if (this._isTouched) {
|
|
5708
|
+
this.invalid = !this.input.checkValidity();
|
|
5709
|
+
}
|
|
5710
|
+
}
|
|
5711
|
+
_mixinResetFormControl() {
|
|
5712
|
+
this._isTouched = false;
|
|
5713
|
+
this.checked = this.input.checked = this.defaultChecked;
|
|
5714
|
+
this.input.dispatchEvent(new InputEvent("reset"));
|
|
5715
|
+
this._mixinResetValidity(this.input);
|
|
5716
|
+
}
|
|
5717
|
+
/**
|
|
5718
|
+
* Checks for validity. Under the hood, HTMLFormElement's reportValidity method calls this method to check for component's validity state
|
|
5719
|
+
* Note that the native error popup is prevented for SGDS form components by default. Instead the validation message shows up in the feedback container of SgdsInput
|
|
5720
|
+
*/
|
|
5721
|
+
reportValidity() {
|
|
5722
|
+
return this._mixinReportValidity();
|
|
5723
|
+
}
|
|
5724
|
+
/**
|
|
5725
|
+
* Checks for validity without any native error popup message
|
|
5726
|
+
*/
|
|
5727
|
+
checkValidity() {
|
|
5728
|
+
return this._mixinCheckValidity();
|
|
5729
|
+
}
|
|
5730
|
+
/**
|
|
5731
|
+
* Returns the ValidityState object
|
|
5732
|
+
*/
|
|
5733
|
+
get validity() {
|
|
5734
|
+
return this._mixinGetValidity();
|
|
5735
|
+
}
|
|
5736
|
+
/**
|
|
5737
|
+
* Returns the validation message based on the ValidityState
|
|
5738
|
+
*/
|
|
5739
|
+
get validationMessage() {
|
|
5740
|
+
return this._mixinGetValidationMessage();
|
|
5654
5741
|
}
|
|
5655
5742
|
render() {
|
|
5656
5743
|
return html$1 `
|
|
@@ -5662,45 +5749,35 @@
|
|
|
5662
5749
|
"is-invalid": this.hasFeedback && this.invalid
|
|
5663
5750
|
})}
|
|
5664
5751
|
type="checkbox"
|
|
5665
|
-
id=${this.
|
|
5752
|
+
id=${this._controlId}
|
|
5666
5753
|
aria-invalid=${this.invalid ? "true" : "false"}
|
|
5667
5754
|
name=${ifDefined(this.name)}
|
|
5668
|
-
value=${ifDefined(this.value)}
|
|
5669
|
-
?checked=${this.checked}
|
|
5670
5755
|
?indeterminate=${this.indeterminate}
|
|
5671
|
-
?disabled=${this.disabled}
|
|
5672
5756
|
?required=${this.required}
|
|
5673
5757
|
aria-disabled=${this.disabled ? "true" : "false"}
|
|
5674
5758
|
aria-checked=${this.checked ? "true" : "false"}
|
|
5675
|
-
@change=${this._handleChange}
|
|
5759
|
+
@change=${(e) => this._handleChange(e)}
|
|
5676
5760
|
@keydown=${this._handleKeyDown}
|
|
5677
5761
|
@invalid=${(e) => this._handleInvalid(e)}
|
|
5762
|
+
.checked=${live(this.checked)}
|
|
5763
|
+
.disabled=${this.disabled}
|
|
5764
|
+
.required=${this.required}
|
|
5765
|
+
@blur=${this._handleBlur}
|
|
5766
|
+
@focus=${this._handleFocus}
|
|
5678
5767
|
/>
|
|
5679
5768
|
</div>
|
|
5680
|
-
<label for="${this.
|
|
5769
|
+
<label for="${this._controlId}" class="form-check-label" id="${this._labelId}"><slot></slot></label>
|
|
5681
5770
|
</div>
|
|
5682
5771
|
`;
|
|
5683
5772
|
}
|
|
5684
5773
|
}
|
|
5685
|
-
SgdsCheckbox.styles = [...
|
|
5686
|
-
__decorate([
|
|
5687
|
-
query('input[type="checkbox"]')
|
|
5688
|
-
], SgdsCheckbox.prototype, "input", void 0);
|
|
5689
|
-
__decorate([
|
|
5690
|
-
property({ type: String, reflect: true })
|
|
5691
|
-
], SgdsCheckbox.prototype, "name", void 0);
|
|
5774
|
+
SgdsCheckbox.styles = [...FormControlElement.styles, css_248z$2];
|
|
5692
5775
|
__decorate([
|
|
5693
5776
|
property({ type: String, reflect: true })
|
|
5694
5777
|
], SgdsCheckbox.prototype, "value", void 0);
|
|
5695
|
-
__decorate([
|
|
5696
|
-
property({ type: Boolean, reflect: true })
|
|
5697
|
-
], SgdsCheckbox.prototype, "required", void 0);
|
|
5698
5778
|
__decorate([
|
|
5699
5779
|
property({ type: Boolean, reflect: true })
|
|
5700
5780
|
], SgdsCheckbox.prototype, "checked", void 0);
|
|
5701
|
-
__decorate([
|
|
5702
|
-
property({ type: Boolean, reflect: true })
|
|
5703
|
-
], SgdsCheckbox.prototype, "disabled", void 0);
|
|
5704
5781
|
__decorate([
|
|
5705
5782
|
property({ type: Boolean, reflect: true })
|
|
5706
5783
|
], SgdsCheckbox.prototype, "hasFeedback", void 0);
|
|
@@ -5709,10 +5786,13 @@
|
|
|
5709
5786
|
], SgdsCheckbox.prototype, "defaultChecked", void 0);
|
|
5710
5787
|
__decorate([
|
|
5711
5788
|
property({ type: Boolean, reflect: true })
|
|
5712
|
-
], SgdsCheckbox.prototype, "
|
|
5789
|
+
], SgdsCheckbox.prototype, "indeterminate", void 0);
|
|
5713
5790
|
__decorate([
|
|
5714
5791
|
property({ type: Boolean, reflect: true })
|
|
5715
|
-
], SgdsCheckbox.prototype, "
|
|
5792
|
+
], SgdsCheckbox.prototype, "required", void 0);
|
|
5793
|
+
__decorate([
|
|
5794
|
+
state()
|
|
5795
|
+
], SgdsCheckbox.prototype, "_isTouched", void 0);
|
|
5716
5796
|
__decorate([
|
|
5717
5797
|
watch("invalid", { waitUntilFirstUpdate: true })
|
|
5718
5798
|
], SgdsCheckbox.prototype, "_handleInvalidChange", null);
|
|
@@ -5720,12 +5800,10 @@
|
|
|
5720
5800
|
watch("disabled", { waitUntilFirstUpdate: true })
|
|
5721
5801
|
], SgdsCheckbox.prototype, "_handleDisabledChange", null);
|
|
5722
5802
|
__decorate([
|
|
5723
|
-
watch("
|
|
5724
|
-
], SgdsCheckbox.prototype, "
|
|
5725
|
-
|
|
5726
|
-
var css_248z$2 = css`:host{outline:0}input{margin:0}.form-check{display:flex;gap:var(--sgds-form-gap-md);padding:var(--sgds-form-padding-inline-sm) 0}.form-check-input-container{height:var(--sgds-form-height-sm);width:var(--sgds-form-width-xs)}.form-check-input{appearance:none;background-color:var(--sgds-form-bg);background-image:var(--sgds-radio-bg-image);background-position:50%;background-repeat:no-repeat;background-size:auto;border:var(--sgds-form-border-width-default) solid var(--sgds-form-border-color);border-radius:50%;height:var(--sgds-form-height-sm);width:var(--sgds-form-height-sm)}.form-check-input:not([disabled]):not(.is-invalid):not([aria-checked=true]):hover{border:var(--sgds-form-border-width-thick) solid var(--sgds-form-border-color-emphasis)}.form-check-input:focus,.form-check-input:focus-visible{border:var(--sgds-form-border-width-default) solid var(--sgds-form-border-color-emphasis);box-shadow:var(--sgds-form-box-shadow-focus);outline:0}.form-check-input:checked,.form-check-input[checked]{--sgds-radio-bg-image:url('data:image/svg+xml;charset=utf-8,<svg width="8" height="8" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0 4a4 4 0 1 1 8 0 4 4 0 0 1-8 0Z" fill="%23fff"/></svg>');background-color:var(--sgds-form-primary-bg);border:var(--sgds-form-border-width-default) solid var(--sgds-default-border-color-transparent)}.form-check-input:not([disabled]):not(.is-invalid):checked:focus-visible,.form-check-input:not([disabled]):not(.is-invalid):checked:hover,.form-check-input:not([disabled]):not(.is-invalid)[checked]:focus-visible,.form-check-input:not([disabled]):not(.is-invalid)[checked]:hover{background-color:var(--sgds-form-primary-bg-emphasis)}:host([disabled]) .form-check{cursor:not-allowed;opacity:var(--sgds-opacity-50)}.form-check-input:not([disabled]).is-invalid{border:var(--sgds-form-border-width-thick) solid var(--sgds-form-danger-border-color)}.form-check-input:checked.is-invalid,.form-check-input[checked].is-invalid{background-color:var(--sgds-form-danger-bg)}`;
|
|
5803
|
+
watch("_isTouched", { waitUntilFirstUpdate: true })
|
|
5804
|
+
], SgdsCheckbox.prototype, "_handleIsTouched", null);
|
|
5727
5805
|
|
|
5728
|
-
var css_248z$1 = css
|
|
5806
|
+
var css_248z$1 = css`:host{outline:0}input{margin:0}.form-check{display:flex;gap:var(--sgds-form-gap-md);padding:var(--sgds-form-padding-inline-sm) 0}.form-check-input-container{height:var(--sgds-form-height-sm);width:var(--sgds-form-width-xs)}.form-check-input{appearance:none;background-color:var(--sgds-form-bg);background-image:var(--sgds-radio-bg-image);background-position:50%;background-repeat:no-repeat;background-size:auto;border:var(--sgds-form-border-width-default) solid var(--sgds-form-border-color);border-radius:50%;height:var(--sgds-form-height-sm);width:var(--sgds-form-height-sm)}.form-check-input:not([disabled]):not(.is-invalid):not([aria-checked=true]):hover{border:var(--sgds-form-border-width-thick) solid var(--sgds-form-border-color-emphasis)}.form-check-input:focus,.form-check-input:focus-visible{border:var(--sgds-form-border-width-default) solid var(--sgds-form-border-color-emphasis);box-shadow:var(--sgds-form-box-shadow-focus);outline:0}.form-check-input:checked,.form-check-input[checked]{--sgds-radio-bg-image:url('data:image/svg+xml;charset=utf-8,<svg width="8" height="8" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0 4a4 4 0 1 1 8 0 4 4 0 0 1-8 0Z" fill="%23fff"/></svg>');background-color:var(--sgds-form-primary-bg);border:var(--sgds-form-border-width-default) solid var(--sgds-default-border-color-transparent)}.form-check-input:not([disabled]):not(.is-invalid):checked:focus-visible,.form-check-input:not([disabled]):not(.is-invalid):checked:hover,.form-check-input:not([disabled]):not(.is-invalid)[checked]:focus-visible,.form-check-input:not([disabled]):not(.is-invalid)[checked]:hover{background-color:var(--sgds-form-primary-bg-emphasis)}:host([disabled]) .form-check{cursor:not-allowed;opacity:var(--sgds-opacity-50)}.form-check-input:not([disabled]).is-invalid{border:var(--sgds-form-border-width-thick) solid var(--sgds-form-danger-border-color)}.form-check-input:checked.is-invalid,.form-check-input[checked].is-invalid{background-color:var(--sgds-form-danger-bg)}`;
|
|
5729
5807
|
|
|
5730
5808
|
/**
|
|
5731
5809
|
* @summary Radio allows the user to select one option from a set while seeing all available options.
|
|
@@ -5811,7 +5889,7 @@
|
|
|
5811
5889
|
`;
|
|
5812
5890
|
}
|
|
5813
5891
|
}
|
|
5814
|
-
SgdsRadio.styles = [...SgdsElement.styles, css_248z$
|
|
5892
|
+
SgdsRadio.styles = [...SgdsElement.styles, css_248z$4, css_248z$1];
|
|
5815
5893
|
__decorate([
|
|
5816
5894
|
property({ type: Boolean, reflect: true })
|
|
5817
5895
|
], SgdsRadio.prototype, "checked", void 0);
|