@govtechsg/sgds-web-component 3.0.0-rc.0 → 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/Masthead/index.js +1 -1
- 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 +9 -10
- package/components/Badge/index.umd.js.map +1 -1
- package/components/Badge/sgds-badge.d.ts +4 -5
- package/components/Badge/sgds-badge.js +6 -7
- 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/Masthead/index.umd.js +1 -1
- package/components/Masthead/masthead.js +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 +2 -1
- 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/Stepper/stepper.js +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 +1320 -1126
- package/components/index.umd.js.map +1 -1
- package/css/reboot.css +39 -6
- package/css/sgds.css +0 -2
- 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 +1340 -1121
- 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 +6 -7
- package/react/components/Badge/sgds-badge.cjs.js.map +1 -1
- package/react/components/Badge/sgds-badge.js +6 -7
- 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/Masthead/masthead.cjs.js +1 -1
- package/react/components/Masthead/masthead.js +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/Stepper/stepper.cjs.js +1 -1
- package/react/components/Stepper/stepper.js +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 +2 -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/css/body.css +0 -28
- package/css/caption.css +0 -7
- package/css/label.css +0 -28
- 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
|
@@ -4234,6 +4234,59 @@
|
|
|
4234
4234
|
});
|
|
4235
4235
|
}
|
|
4236
4236
|
|
|
4237
|
+
/**
|
|
4238
|
+
* @license
|
|
4239
|
+
* Copyright 2017 Google LLC
|
|
4240
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
4241
|
+
*/
|
|
4242
|
+
// Note, in the future, we may extend this decorator to support the use case
|
|
4243
|
+
// where the queried element may need to do work to become ready to interact
|
|
4244
|
+
// with (e.g. load some implementation code). If so, we might elect to
|
|
4245
|
+
// add a second argument defining a function that can be run to make the
|
|
4246
|
+
// queried element loaded/updated/ready.
|
|
4247
|
+
/**
|
|
4248
|
+
* A property decorator that converts a class property into a getter that
|
|
4249
|
+
* returns a promise that resolves to the result of a querySelector on the
|
|
4250
|
+
* element's renderRoot done after the element's `updateComplete` promise
|
|
4251
|
+
* resolves. When the queried property may change with element state, this
|
|
4252
|
+
* decorator can be used instead of requiring users to await the
|
|
4253
|
+
* `updateComplete` before accessing the property.
|
|
4254
|
+
*
|
|
4255
|
+
* @param selector A DOMString containing one or more selectors to match.
|
|
4256
|
+
*
|
|
4257
|
+
* See: https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector
|
|
4258
|
+
*
|
|
4259
|
+
* ```ts
|
|
4260
|
+
* class MyElement {
|
|
4261
|
+
* @queryAsync('#first')
|
|
4262
|
+
* first: Promise<HTMLDivElement>;
|
|
4263
|
+
*
|
|
4264
|
+
* render() {
|
|
4265
|
+
* return html`
|
|
4266
|
+
* <div id="first"></div>
|
|
4267
|
+
* <div id="second"></div>
|
|
4268
|
+
* `;
|
|
4269
|
+
* }
|
|
4270
|
+
* }
|
|
4271
|
+
*
|
|
4272
|
+
* // external usage
|
|
4273
|
+
* async doSomethingWithFirst() {
|
|
4274
|
+
* (await aMyElement.first).doSomething();
|
|
4275
|
+
* }
|
|
4276
|
+
* ```
|
|
4277
|
+
* @category Decorator
|
|
4278
|
+
*/
|
|
4279
|
+
function queryAsync(selector) {
|
|
4280
|
+
return ((obj, name) => {
|
|
4281
|
+
return desc(obj, name, {
|
|
4282
|
+
async get() {
|
|
4283
|
+
await this.updateComplete;
|
|
4284
|
+
return this.renderRoot?.querySelector(selector) ?? null;
|
|
4285
|
+
},
|
|
4286
|
+
});
|
|
4287
|
+
});
|
|
4288
|
+
}
|
|
4289
|
+
|
|
4237
4290
|
/**
|
|
4238
4291
|
* @license
|
|
4239
4292
|
* Copyright 2021 Google LLC
|
|
@@ -4429,7 +4482,7 @@
|
|
|
4429
4482
|
*/
|
|
4430
4483
|
const ifDefined = (value) => value ?? nothing;
|
|
4431
4484
|
|
|
4432
|
-
var css_248z$
|
|
4485
|
+
var css_248z$6 = 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}}`;
|
|
4433
4486
|
|
|
4434
4487
|
/**
|
|
4435
4488
|
* @cssprop --sgds-{stateColor} - State colors in hexadecimal value
|
|
@@ -4447,9 +4500,11 @@
|
|
|
4447
4500
|
return event;
|
|
4448
4501
|
}
|
|
4449
4502
|
}
|
|
4450
|
-
SgdsElement.styles = [css_248z$
|
|
4503
|
+
SgdsElement.styles = [css_248z$6];
|
|
4451
4504
|
|
|
4452
|
-
|
|
4505
|
+
var css_248z$5 = 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}`;
|
|
4506
|
+
|
|
4507
|
+
function generateId (componentName = "", elementName = "") {
|
|
4453
4508
|
return `id-${Math.random().toString().substring(2, 6)}-sgds-${componentName}-${elementName}`;
|
|
4454
4509
|
}
|
|
4455
4510
|
|
|
@@ -4492,8 +4547,6 @@
|
|
|
4492
4547
|
|
|
4493
4548
|
var css_248z$4 = 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)}`;
|
|
4494
4549
|
|
|
4495
|
-
var css_248z$3 = css`.form-label{margin-bottom:0}.form-check-label,.form-label{color:var(--sgds-form-color)}.form-check-input:disabled~.form-check-label,.form-check-input[disabled]~.form-check-label{cursor:not-allowed}`;
|
|
4496
|
-
|
|
4497
4550
|
/**
|
|
4498
4551
|
* @summary Radio allows the user to select one option from a set while seeing all available options.
|
|
4499
4552
|
*
|
|
@@ -4513,7 +4566,7 @@
|
|
|
4513
4566
|
this.disabled = false;
|
|
4514
4567
|
/** Marks the radio input as invalid. Replace the pseudo :invalid selector for absent in custom elements */
|
|
4515
4568
|
this.invalid = false;
|
|
4516
|
-
this.radioId =
|
|
4569
|
+
this.radioId = generateId("radio");
|
|
4517
4570
|
}
|
|
4518
4571
|
connectedCallback() {
|
|
4519
4572
|
super.connectedCallback();
|
|
@@ -4578,7 +4631,7 @@
|
|
|
4578
4631
|
`;
|
|
4579
4632
|
}
|
|
4580
4633
|
}
|
|
4581
|
-
SgdsRadio.styles = [...SgdsElement.styles, css_248z$
|
|
4634
|
+
SgdsRadio.styles = [...SgdsElement.styles, css_248z$5, css_248z$4];
|
|
4582
4635
|
__decorate([
|
|
4583
4636
|
property({ type: Boolean, reflect: true })
|
|
4584
4637
|
], SgdsRadio.prototype, "checked", void 0);
|
|
@@ -4601,141 +4654,383 @@
|
|
|
4601
4654
|
watch("disabled", { waitUntilFirstUpdate: true })
|
|
4602
4655
|
], SgdsRadio.prototype, "handleDisabledChange", null);
|
|
4603
4656
|
|
|
4604
|
-
|
|
4605
|
-
|
|
4657
|
+
/**
|
|
4658
|
+
* @license
|
|
4659
|
+
* Copyright 2020 Google LLC
|
|
4660
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
4661
|
+
*/
|
|
4662
|
+
window.ShadyDOM?.inUse &&
|
|
4663
|
+
window.ShadyDOM?.noPatch === true
|
|
4664
|
+
? window.ShadyDOM.wrap
|
|
4665
|
+
: (node) => node;
|
|
4666
|
+
/**
|
|
4667
|
+
* Tests whether a part has only a single-expression with no strings to
|
|
4668
|
+
* interpolate between.
|
|
4669
|
+
*
|
|
4670
|
+
* Only AttributePart and PropertyPart can have multiple expressions.
|
|
4671
|
+
* Multi-expression parts have a `strings` property and single-expression
|
|
4672
|
+
* parts do not.
|
|
4673
|
+
*/
|
|
4674
|
+
const isSingleExpression = (part) => part.strings === undefined;
|
|
4675
|
+
// A sentinel value that can never appear as a part value except when set by
|
|
4676
|
+
// live(). Used to force a dirty-check to fail and cause a re-render.
|
|
4677
|
+
const RESET_VALUE = {};
|
|
4678
|
+
/**
|
|
4679
|
+
* Sets the committed value of a ChildPart directly without triggering the
|
|
4680
|
+
* commit stage of the part.
|
|
4681
|
+
*
|
|
4682
|
+
* This is useful in cases where a directive needs to update the part such
|
|
4683
|
+
* that the next update detects a value change or not. When value is omitted,
|
|
4684
|
+
* the next update will be guaranteed to be detected as a change.
|
|
4685
|
+
*
|
|
4686
|
+
* @param part
|
|
4687
|
+
* @param value
|
|
4688
|
+
*/
|
|
4689
|
+
const setCommittedValue = (part, value = RESET_VALUE) => (part._$committedValue = value);
|
|
4690
|
+
|
|
4691
|
+
/**
|
|
4692
|
+
* @license
|
|
4693
|
+
* Copyright 2020 Google LLC
|
|
4694
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
4695
|
+
*/
|
|
4696
|
+
class LiveDirective extends Directive {
|
|
4697
|
+
constructor(partInfo) {
|
|
4698
|
+
super(partInfo);
|
|
4699
|
+
if (!(partInfo.type === PartType.PROPERTY ||
|
|
4700
|
+
partInfo.type === PartType.ATTRIBUTE ||
|
|
4701
|
+
partInfo.type === PartType.BOOLEAN_ATTRIBUTE)) {
|
|
4702
|
+
throw new Error('The `live` directive is not allowed on child or event bindings');
|
|
4703
|
+
}
|
|
4704
|
+
if (!isSingleExpression(partInfo)) {
|
|
4705
|
+
throw new Error('`live` bindings can only contain a single expression');
|
|
4706
|
+
}
|
|
4707
|
+
}
|
|
4708
|
+
render(value) {
|
|
4709
|
+
return value;
|
|
4710
|
+
}
|
|
4711
|
+
update(part, [value]) {
|
|
4712
|
+
if (value === noChange || value === nothing) {
|
|
4713
|
+
return value;
|
|
4714
|
+
}
|
|
4715
|
+
const element = part.element;
|
|
4716
|
+
const name = part.name;
|
|
4717
|
+
if (part.type === PartType.PROPERTY) {
|
|
4718
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4719
|
+
if (value === element[name]) {
|
|
4720
|
+
return noChange;
|
|
4721
|
+
}
|
|
4722
|
+
}
|
|
4723
|
+
else if (part.type === PartType.BOOLEAN_ATTRIBUTE) {
|
|
4724
|
+
if (!!value === element.hasAttribute(name)) {
|
|
4725
|
+
return noChange;
|
|
4726
|
+
}
|
|
4727
|
+
}
|
|
4728
|
+
else if (part.type === PartType.ATTRIBUTE) {
|
|
4729
|
+
if (element.getAttribute(name) === String(value)) {
|
|
4730
|
+
return noChange;
|
|
4731
|
+
}
|
|
4732
|
+
}
|
|
4733
|
+
// Resets the part's value, causing its dirty-check to fail so that it
|
|
4734
|
+
// always sets the value.
|
|
4735
|
+
setCommittedValue(part);
|
|
4736
|
+
return value;
|
|
4737
|
+
}
|
|
4738
|
+
}
|
|
4739
|
+
/**
|
|
4740
|
+
* Checks binding values against live DOM values, instead of previously bound
|
|
4741
|
+
* values, when determining whether to update the value.
|
|
4742
|
+
*
|
|
4743
|
+
* This is useful for cases where the DOM value may change from outside of
|
|
4744
|
+
* lit-html, such as with a binding to an `<input>` element's `value` property,
|
|
4745
|
+
* a content editable elements text, or to a custom element that changes it's
|
|
4746
|
+
* own properties or attributes.
|
|
4747
|
+
*
|
|
4748
|
+
* In these cases if the DOM value changes, but the value set through lit-html
|
|
4749
|
+
* bindings hasn't, lit-html won't know to update the DOM value and will leave
|
|
4750
|
+
* it alone. If this is not what you want--if you want to overwrite the DOM
|
|
4751
|
+
* value with the bound value no matter what--use the `live()` directive:
|
|
4752
|
+
*
|
|
4753
|
+
* ```js
|
|
4754
|
+
* html`<input .value=${live(x)}>`
|
|
4755
|
+
* ```
|
|
4756
|
+
*
|
|
4757
|
+
* `live()` performs a strict equality check against the live DOM value, and if
|
|
4758
|
+
* the new value is equal to the live value, does nothing. This means that
|
|
4759
|
+
* `live()` should not be used when the binding will cause a type conversion. If
|
|
4760
|
+
* you use `live()` with an attribute binding, make sure that only strings are
|
|
4761
|
+
* passed in, or the binding will update every render.
|
|
4762
|
+
*/
|
|
4763
|
+
const live = directive(LiveDirective);
|
|
4764
|
+
|
|
4765
|
+
var css_248z$3 = 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)}`;
|
|
4766
|
+
|
|
4767
|
+
var css_248z$2 = css`.form-text{color:var(--sgds-form-color-subtle);font-size:var(--sgds-font-size-1)}.form-text.disabled{opacity:var(--sgds-opacity-50)}`;
|
|
4768
|
+
|
|
4769
|
+
var css_248z$1 = 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)}`;
|
|
4770
|
+
|
|
4771
|
+
class FormControlElement extends SgdsElement {
|
|
4772
|
+
constructor() {
|
|
4773
|
+
super(...arguments);
|
|
4774
|
+
/** The input's label */
|
|
4775
|
+
this.label = "";
|
|
4776
|
+
/** The input's hint text */
|
|
4777
|
+
this.hintText = "";
|
|
4778
|
+
/** Disables the input. */
|
|
4779
|
+
this.disabled = false;
|
|
4780
|
+
/** Marks the component as invalid. Replace the pseudo :invalid selector for absent in custom elements */
|
|
4781
|
+
this.invalid = false;
|
|
4782
|
+
this._controlId = generateId("input");
|
|
4783
|
+
this._labelId = generateId("label");
|
|
4784
|
+
}
|
|
4785
|
+
/** Programatically sets the invalid state of the input. Pass in boolean value in the argument */
|
|
4786
|
+
setInvalid(bool) {
|
|
4787
|
+
this.invalid = bool;
|
|
4788
|
+
if (bool) {
|
|
4789
|
+
this.emit("sgds-invalid");
|
|
4790
|
+
}
|
|
4791
|
+
else {
|
|
4792
|
+
this.emit("sgds-valid");
|
|
4793
|
+
}
|
|
4794
|
+
}
|
|
4795
|
+
}
|
|
4796
|
+
FormControlElement.styles = [...SgdsElement.styles, css_248z$3, css_248z$2, css_248z$5, css_248z$1];
|
|
4797
|
+
__decorate([
|
|
4798
|
+
property({ reflect: true })
|
|
4799
|
+
], FormControlElement.prototype, "label", void 0);
|
|
4800
|
+
__decorate([
|
|
4801
|
+
property({ reflect: true })
|
|
4802
|
+
], FormControlElement.prototype, "hintText", void 0);
|
|
4803
|
+
__decorate([
|
|
4804
|
+
property({ reflect: true })
|
|
4805
|
+
], FormControlElement.prototype, "name", void 0);
|
|
4806
|
+
__decorate([
|
|
4807
|
+
property({ type: Boolean, reflect: true })
|
|
4808
|
+
], FormControlElement.prototype, "disabled", void 0);
|
|
4809
|
+
__decorate([
|
|
4810
|
+
property({ type: Boolean, reflect: true })
|
|
4811
|
+
], FormControlElement.prototype, "invalid", void 0);
|
|
4812
|
+
|
|
4813
|
+
/**
|
|
4814
|
+
* SGDS custom form validation methods and behaviours
|
|
4815
|
+
*/
|
|
4816
|
+
class InputValidationController {
|
|
4606
4817
|
constructor(host, options) {
|
|
4607
4818
|
(this.host = host).addController(this);
|
|
4608
|
-
this.
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
} }, options);
|
|
4615
|
-
this.handleFormData = this.handleFormData.bind(this);
|
|
4616
|
-
this.handleFormSubmit = this.handleFormSubmit.bind(this);
|
|
4617
|
-
this.handleFormReset = this.handleFormReset.bind(this);
|
|
4618
|
-
this.reportFormValidity = this.reportFormValidity.bind(this);
|
|
4819
|
+
this._internals = this.host.attachInternals();
|
|
4820
|
+
this.options = Object.assign({ setInvalid: (host, value) => {
|
|
4821
|
+
host.invalid = value;
|
|
4822
|
+
}, value: (host) => {
|
|
4823
|
+
return host.value;
|
|
4824
|
+
}, input: (host) => host.input }, options);
|
|
4619
4825
|
}
|
|
4620
4826
|
hostConnected() {
|
|
4621
|
-
this.
|
|
4622
|
-
if (this.form) {
|
|
4623
|
-
this.form.addEventListener("formdata", this.handleFormData);
|
|
4624
|
-
this.form.addEventListener("submit", this.handleFormSubmit);
|
|
4625
|
-
this.form.addEventListener("reset", this.handleFormReset);
|
|
4626
|
-
// Overload the form's reportValidity() method so it looks at Shoelace form controls
|
|
4627
|
-
if (!reportValidityOverloads.has(this.form)) {
|
|
4628
|
-
reportValidityOverloads.set(this.form, this.form.reportValidity);
|
|
4629
|
-
this.form.reportValidity = () => this.reportFormValidity();
|
|
4630
|
-
}
|
|
4631
|
-
}
|
|
4827
|
+
this.host.addEventListener("invalid", e => this.handleInvalid(e));
|
|
4632
4828
|
}
|
|
4633
4829
|
hostDisconnected() {
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4830
|
+
this.host.removeEventListener("invalid", e => this.handleInvalid(e));
|
|
4831
|
+
}
|
|
4832
|
+
/**
|
|
4833
|
+
* Prevents the native browser error message pop up when reportValidity() called by
|
|
4834
|
+
* associated form or the component's reportValidity during constraint validation
|
|
4835
|
+
* Sets invalid reactive prop to true
|
|
4836
|
+
*/
|
|
4837
|
+
handleInvalid(e) {
|
|
4838
|
+
e.preventDefault();
|
|
4839
|
+
this.options.setInvalid(this.host, true);
|
|
4840
|
+
}
|
|
4841
|
+
/**
|
|
4842
|
+
* Sets invalid to false when invoked and
|
|
4843
|
+
* Updates the ValidityState based on new value, but
|
|
4844
|
+
* does not update invalid reactive prop
|
|
4845
|
+
* @param e
|
|
4846
|
+
*/
|
|
4847
|
+
handleInput(e) {
|
|
4848
|
+
const input = e.target;
|
|
4849
|
+
this.options.setInvalid(this.host, false);
|
|
4850
|
+
this.validateInput(input);
|
|
4851
|
+
}
|
|
4852
|
+
/**
|
|
4853
|
+
* Validate the input's new value after onChange and
|
|
4854
|
+
* update invalid reactive prop
|
|
4855
|
+
* @param e
|
|
4856
|
+
*/
|
|
4857
|
+
handleChange(e) {
|
|
4858
|
+
const input = e.target;
|
|
4859
|
+
this.validateInput(input);
|
|
4860
|
+
this.options.setInvalid(this.host, !this.checkValidity());
|
|
4861
|
+
}
|
|
4862
|
+
get form() {
|
|
4863
|
+
return this._internals.form;
|
|
4864
|
+
}
|
|
4865
|
+
get validity() {
|
|
4866
|
+
return this._internals.validity;
|
|
4867
|
+
}
|
|
4868
|
+
get validationMessage() {
|
|
4869
|
+
return this._internals.validationMessage;
|
|
4645
4870
|
}
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4871
|
+
get willValidate() {
|
|
4872
|
+
return this._internals.willValidate;
|
|
4873
|
+
}
|
|
4874
|
+
/**
|
|
4875
|
+
* Checks the validity and updates the invalid reactive prop of form components
|
|
4876
|
+
*/
|
|
4877
|
+
updateInvalidState() {
|
|
4878
|
+
this.options.setInvalid(this.host, !this.checkValidity());
|
|
4879
|
+
}
|
|
4880
|
+
/**
|
|
4881
|
+
* Resets the ValidityState of the control
|
|
4882
|
+
*/
|
|
4883
|
+
resetValidity() {
|
|
4884
|
+
return this._internals.setValidity({});
|
|
4885
|
+
}
|
|
4886
|
+
/**
|
|
4887
|
+
* Reports the validity
|
|
4888
|
+
*/
|
|
4889
|
+
checkValidity() {
|
|
4890
|
+
return this._internals.checkValidity();
|
|
4891
|
+
}
|
|
4892
|
+
/**
|
|
4893
|
+
* Reports the validity with a error popup message
|
|
4894
|
+
*/
|
|
4895
|
+
reportValidity() {
|
|
4896
|
+
return this._internals.reportValidity();
|
|
4897
|
+
}
|
|
4898
|
+
/**
|
|
4899
|
+
* Sets the form control value into FormData,
|
|
4900
|
+
* making the value of control accessible via FormData
|
|
4901
|
+
*/
|
|
4902
|
+
setFormValue() {
|
|
4649
4903
|
const value = this.options.value(this.host);
|
|
4650
|
-
|
|
4651
|
-
if (Array.isArray(value)) {
|
|
4652
|
-
value.forEach(val => {
|
|
4653
|
-
event.formData.append(name, val.toString());
|
|
4654
|
-
});
|
|
4655
|
-
}
|
|
4656
|
-
else {
|
|
4657
|
-
event.formData.append(name, value.toString());
|
|
4658
|
-
}
|
|
4659
|
-
}
|
|
4904
|
+
this._internals.setFormValue(value);
|
|
4660
4905
|
}
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
//
|
|
4683
|
-
// Note that we're also honoring the form's novalidate attribute.
|
|
4684
|
-
//
|
|
4685
|
-
if (this.form && !this.form.noValidate) {
|
|
4686
|
-
// This seems sloppy, but checking all elements will cover native inputs, Shoelace inputs, and other custom
|
|
4687
|
-
// elements that support the constraint validation API.
|
|
4688
|
-
const elements = this.form.querySelectorAll("*");
|
|
4689
|
-
for (const element of elements) {
|
|
4690
|
-
if (typeof element.reportValidity === "function") {
|
|
4691
|
-
if (!element.reportValidity()) {
|
|
4692
|
-
return false;
|
|
4693
|
-
}
|
|
4906
|
+
/**
|
|
4907
|
+
* Updates the ValidityState of the input in form component at current state
|
|
4908
|
+
*/
|
|
4909
|
+
validateInput(input) {
|
|
4910
|
+
/** When the form control is disabled, its always valid */
|
|
4911
|
+
if (this.options.input(this.host).disabled) {
|
|
4912
|
+
return this._internals.setValidity({});
|
|
4913
|
+
}
|
|
4914
|
+
// get the validity of the internal <input>
|
|
4915
|
+
const validState = input.validity;
|
|
4916
|
+
// if the input is invalid, show the correct error
|
|
4917
|
+
if (!validState.valid) {
|
|
4918
|
+
// loop through the error reasons
|
|
4919
|
+
for (const state in validState) {
|
|
4920
|
+
// if there is an error and corresponding attribute holding
|
|
4921
|
+
// the message
|
|
4922
|
+
if (validState[state]) {
|
|
4923
|
+
this.validationError = state.toString();
|
|
4924
|
+
// set the validity error reason and the corresponding
|
|
4925
|
+
// message
|
|
4926
|
+
this._internals.setValidity({ [this.validationError]: true }, input.validationMessage, input);
|
|
4694
4927
|
}
|
|
4695
4928
|
}
|
|
4696
4929
|
}
|
|
4697
|
-
|
|
4698
|
-
|
|
4699
|
-
doAction(type, invoker) {
|
|
4700
|
-
if (this.form) {
|
|
4701
|
-
const button = document.createElement("button");
|
|
4702
|
-
button.type = type;
|
|
4703
|
-
button.style.position = "absolute";
|
|
4704
|
-
button.style.width = "0";
|
|
4705
|
-
button.style.height = "0";
|
|
4706
|
-
button.style.clipPath = "inset(50%)";
|
|
4707
|
-
button.style.overflow = "hidden";
|
|
4708
|
-
button.style.whiteSpace = "nowrap";
|
|
4709
|
-
// Pass form attributes through to the temporary button
|
|
4710
|
-
if (invoker) {
|
|
4711
|
-
["formaction", "formmethod", "formnovalidate", "formtarget"].forEach(attr => {
|
|
4712
|
-
if (invoker.hasAttribute(attr)) {
|
|
4713
|
-
button.setAttribute(attr, invoker.getAttribute(attr));
|
|
4714
|
-
}
|
|
4715
|
-
});
|
|
4716
|
-
}
|
|
4717
|
-
this.form.append(button);
|
|
4718
|
-
button.click();
|
|
4719
|
-
button.remove();
|
|
4930
|
+
else {
|
|
4931
|
+
this._internals.setValidity({});
|
|
4720
4932
|
}
|
|
4721
4933
|
}
|
|
4722
|
-
/** Resets the form, restoring all the control to their default value */
|
|
4723
|
-
reset(invoker) {
|
|
4724
|
-
this.doAction("reset", invoker);
|
|
4725
|
-
}
|
|
4726
|
-
/** Submits the form, triggering validation and form data injection. */
|
|
4727
|
-
submit(invoker) {
|
|
4728
|
-
// Calling form.submit() bypasses the submit event and constraint validation. To prevent this, we can inject a
|
|
4729
|
-
// native submit button into the form, "click" it, then remove it to simulate a standard form submission.
|
|
4730
|
-
this.doAction("submit", invoker);
|
|
4731
|
-
}
|
|
4732
4934
|
}
|
|
4733
4935
|
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4936
|
+
/**
|
|
4937
|
+
* @summary The FormValidationMixin used by the form components
|
|
4938
|
+
* @param superClass
|
|
4939
|
+
* @returns
|
|
4940
|
+
*/
|
|
4941
|
+
const SgdsFormValidatorMixin = (superClass) => {
|
|
4942
|
+
class ToBeValidatedElement extends superClass {
|
|
4943
|
+
constructor() {
|
|
4944
|
+
super(...arguments);
|
|
4945
|
+
this._isTouched = false;
|
|
4946
|
+
}
|
|
4947
|
+
connectedCallback() {
|
|
4948
|
+
super.connectedCallback();
|
|
4949
|
+
this.inputValidationController = new InputValidationController(this);
|
|
4950
|
+
}
|
|
4951
|
+
async firstUpdated(changedProperties) {
|
|
4952
|
+
super.firstUpdated(changedProperties);
|
|
4953
|
+
/* Either input or sgds-input. For example, quantity-toggle uses sgds-input */
|
|
4954
|
+
this.input =
|
|
4955
|
+
this.shadowRoot.querySelector("input") || (await this.sgdsInput) || this.shadowRoot.querySelector("textarea");
|
|
4956
|
+
this._mixinValidate(this.input);
|
|
4957
|
+
}
|
|
4958
|
+
/**
|
|
4959
|
+
* Native lifecycle of Form-Associated Custom Element Callbacks
|
|
4960
|
+
*/
|
|
4961
|
+
formResetCallback() {
|
|
4962
|
+
if (this._mixinResetFormControl) {
|
|
4963
|
+
this._mixinResetFormControl();
|
|
4964
|
+
}
|
|
4965
|
+
else {
|
|
4966
|
+
this.value = this.defaultValue;
|
|
4967
|
+
this._mixinResetValidity(this.input);
|
|
4968
|
+
}
|
|
4969
|
+
this._mixinSetFormValue();
|
|
4970
|
+
}
|
|
4971
|
+
/**
|
|
4972
|
+
*
|
|
4973
|
+
* Methods use by classes using this mixin
|
|
4974
|
+
*/
|
|
4975
|
+
/**
|
|
4976
|
+
* OnChange of form component
|
|
4977
|
+
* 1. Make value of control accessible via FormData
|
|
4978
|
+
* 2. Run change handler
|
|
4979
|
+
*/
|
|
4980
|
+
_mixinHandleChange(e) {
|
|
4981
|
+
this._mixinSetFormValue();
|
|
4982
|
+
this.inputValidationController.handleChange(e);
|
|
4983
|
+
}
|
|
4984
|
+
/**
|
|
4985
|
+
* OnChange of form component
|
|
4986
|
+
* 1. Make value of control accessible via FormData
|
|
4987
|
+
* 2. Run input handler
|
|
4988
|
+
*/
|
|
4989
|
+
_mixinHandleInputChange(e) {
|
|
4990
|
+
this._mixinSetFormValue();
|
|
4991
|
+
this.inputValidationController.handleInput(e);
|
|
4992
|
+
}
|
|
4993
|
+
/**
|
|
4994
|
+
* During form resetting,
|
|
4995
|
+
* 1. ValidityState is reset
|
|
4996
|
+
* 2. invalid reactive prop is updated after the reset
|
|
4997
|
+
* 3. Revalidates the ValidityState (but do not update invalid prop)
|
|
4998
|
+
* to prepare for the next validity check
|
|
4999
|
+
* 4. Reset touched state to false for a pristine form
|
|
5000
|
+
*/
|
|
5001
|
+
_mixinResetValidity(input) {
|
|
5002
|
+
this.inputValidationController.resetValidity();
|
|
5003
|
+
this.inputValidationController.updateInvalidState();
|
|
5004
|
+
this.inputValidationController.validateInput(input);
|
|
5005
|
+
this._isTouched ? (this._isTouched = false) : null;
|
|
5006
|
+
}
|
|
5007
|
+
_mixinValidate(input) {
|
|
5008
|
+
this.inputValidationController.validateInput(input);
|
|
5009
|
+
}
|
|
5010
|
+
_mixinSetFormValue() {
|
|
5011
|
+
this.inputValidationController.setFormValue();
|
|
5012
|
+
}
|
|
5013
|
+
_mixinCheckValidity() {
|
|
5014
|
+
return this.inputValidationController.checkValidity();
|
|
5015
|
+
}
|
|
5016
|
+
_mixinReportValidity() {
|
|
5017
|
+
return this.inputValidationController.reportValidity();
|
|
5018
|
+
}
|
|
5019
|
+
_mixinGetValidity() {
|
|
5020
|
+
return this.inputValidationController.validity;
|
|
5021
|
+
}
|
|
5022
|
+
_mixinGetValidationMessage() {
|
|
5023
|
+
return this.inputValidationController.validationMessage;
|
|
5024
|
+
}
|
|
5025
|
+
}
|
|
5026
|
+
ToBeValidatedElement.formAssociated = true;
|
|
5027
|
+
__decorate([
|
|
5028
|
+
queryAsync("sgds-input")
|
|
5029
|
+
], ToBeValidatedElement.prototype, "sgdsInput", void 0);
|
|
5030
|
+
return ToBeValidatedElement;
|
|
5031
|
+
};
|
|
4737
5032
|
|
|
4738
|
-
var css_248z = css
|
|
5033
|
+
var css_248z = css`fieldset{border:0;gap:var(--sgds-form-gap-md);margin:0;min-width:0;padding:0}.label-hint-container,fieldset{display:flex;flex-direction:column}.label-hint-container{gap:var(--sgds-form-gap-sm)}.radio-group-validation-input{display:none}.radio-container{display:flex;flex-direction:column;gap:var(--sgds-form-gap-md)}`;
|
|
4739
5034
|
|
|
4740
5035
|
/**
|
|
4741
5036
|
* @summary RadioGroup group multiple radios so they function as a single form control.
|
|
@@ -4746,43 +5041,46 @@
|
|
|
4746
5041
|
*
|
|
4747
5042
|
*
|
|
4748
5043
|
*/
|
|
4749
|
-
class SgdsRadioGroup extends
|
|
5044
|
+
class SgdsRadioGroup extends SgdsFormValidatorMixin(FormControlElement) {
|
|
4750
5045
|
constructor() {
|
|
4751
5046
|
super(...arguments);
|
|
4752
5047
|
/**@internal */
|
|
4753
|
-
this.formSubmitController = new FormSubmitController(this, {
|
|
4754
|
-
defaultValue: (control) => control.defaultValue
|
|
4755
|
-
});
|
|
4756
|
-
/**@internal */
|
|
4757
5048
|
this.defaultValue = "";
|
|
4758
|
-
/**@internal */
|
|
4759
|
-
this.customErrorMessage = "";
|
|
4760
|
-
/** The radio group's label */
|
|
4761
|
-
this.label = "";
|
|
4762
|
-
/** This will be true when the control is in an invalid state. */
|
|
4763
|
-
this.invalid = false;
|
|
4764
5049
|
/** The selected value of the control. */
|
|
4765
5050
|
this.value = "";
|
|
4766
|
-
/** The name assigned to the radio controls. */
|
|
4767
|
-
this.name = "option";
|
|
4768
|
-
/** Ensures a child radio is checked before allowing the containing form to submit. */
|
|
4769
|
-
this.required = false;
|
|
4770
5051
|
/**Feedback text for error state when validated */
|
|
4771
5052
|
this.invalidFeedback = "";
|
|
4772
5053
|
/** Allows invalidFeedback, invalid and valid styles to be visible with the input */
|
|
4773
5054
|
this.hasFeedback = false;
|
|
4774
|
-
/**
|
|
4775
|
-
this.
|
|
5055
|
+
/** Makes the input as a required field. */
|
|
5056
|
+
this.required = false;
|
|
5057
|
+
this._isTouched = false;
|
|
4776
5058
|
}
|
|
4777
5059
|
_handleValueChange() {
|
|
4778
5060
|
this.emit("sgds-change", { detail: { value: this.value } });
|
|
4779
5061
|
this._updateCheckedRadio();
|
|
4780
5062
|
}
|
|
5063
|
+
_handleInvalidChange() {
|
|
5064
|
+
this._radios.forEach(r => (r.invalid = this.invalid));
|
|
5065
|
+
}
|
|
5066
|
+
/**
|
|
5067
|
+
* radio requries a custom _mixinResetFormControl as the update of input value
|
|
5068
|
+
* requires to fire a reset event manually
|
|
5069
|
+
* */
|
|
5070
|
+
_mixinResetFormControl() {
|
|
5071
|
+
this.value = this.input.value = this.defaultValue;
|
|
5072
|
+
this._updateInputValue("reset");
|
|
5073
|
+
this._mixinResetValidity(this.input);
|
|
5074
|
+
}
|
|
4781
5075
|
connectedCallback() {
|
|
4782
5076
|
super.connectedCallback();
|
|
4783
5077
|
this.defaultValue = this.value;
|
|
5078
|
+
this.addEventListener("sgds-blur", () => {
|
|
5079
|
+
this._isTouched = true;
|
|
5080
|
+
});
|
|
4784
5081
|
}
|
|
4785
|
-
firstUpdated() {
|
|
5082
|
+
firstUpdated(changedProperties) {
|
|
5083
|
+
super.firstUpdated(changedProperties);
|
|
4786
5084
|
const radios = this._radios;
|
|
4787
5085
|
radios.forEach((item, index) => {
|
|
4788
5086
|
if (radios.length > 1) {
|
|
@@ -4798,33 +5096,9 @@
|
|
|
4798
5096
|
}
|
|
4799
5097
|
}
|
|
4800
5098
|
});
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
get validity() {
|
|
4804
|
-
const hasMissingData = !((this.value && this.required) || !this.required);
|
|
4805
|
-
const hasCustomError = this.customErrorMessage !== "";
|
|
4806
|
-
return {
|
|
4807
|
-
badInput: false,
|
|
4808
|
-
customError: hasCustomError,
|
|
4809
|
-
patternMismatch: false,
|
|
4810
|
-
rangeOverflow: false,
|
|
4811
|
-
rangeUnderflow: false,
|
|
4812
|
-
stepMismatch: false,
|
|
4813
|
-
tooLong: false,
|
|
4814
|
-
tooShort: false,
|
|
4815
|
-
typeMismatch: false,
|
|
4816
|
-
valid: hasMissingData ? false : true,
|
|
4817
|
-
valueMissing: !hasMissingData
|
|
4818
|
-
};
|
|
4819
|
-
}
|
|
4820
|
-
/** Checks for validity and shows the browser's validation message if the control is invalid. */
|
|
4821
|
-
reportValidity() {
|
|
4822
|
-
const validity = this.validity;
|
|
4823
|
-
this.invalid = !validity.valid;
|
|
4824
|
-
if (!validity.valid) {
|
|
4825
|
-
this._showNativeErrorMessage();
|
|
5099
|
+
if (this.value) {
|
|
5100
|
+
this._updateInputValue("change");
|
|
4826
5101
|
}
|
|
4827
|
-
return !this.invalid;
|
|
4828
5102
|
}
|
|
4829
5103
|
_handleRadioClick(event) {
|
|
4830
5104
|
event.preventDefault();
|
|
@@ -4833,11 +5107,20 @@
|
|
|
4833
5107
|
return;
|
|
4834
5108
|
}
|
|
4835
5109
|
this.value = target.value;
|
|
5110
|
+
this._updateInputValue();
|
|
4836
5111
|
const radios = this._radios;
|
|
4837
5112
|
radios.forEach(radio => {
|
|
4838
5113
|
return (radio.checked = radio === target);
|
|
4839
5114
|
});
|
|
4840
5115
|
}
|
|
5116
|
+
/**
|
|
5117
|
+
* when input value is set programatically, need to manually dispatch a change event
|
|
5118
|
+
* In order to prevent race conditions and ensure sequence of events, set input's value here instead of binding to value prop of input
|
|
5119
|
+
*/
|
|
5120
|
+
_updateInputValue(eventName = "change") {
|
|
5121
|
+
this.input.value = this.value;
|
|
5122
|
+
this.input.dispatchEvent(new InputEvent(eventName));
|
|
5123
|
+
}
|
|
4841
5124
|
_handleKeyDown(event) {
|
|
4842
5125
|
var _a;
|
|
4843
5126
|
if (!["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", " "].includes(event.key)) {
|
|
@@ -4859,6 +5142,7 @@
|
|
|
4859
5142
|
radio.tabIndex = -1;
|
|
4860
5143
|
});
|
|
4861
5144
|
this.value = radios[index].value;
|
|
5145
|
+
this._updateInputValue();
|
|
4862
5146
|
radios[index].checked = true;
|
|
4863
5147
|
radios[index].tabIndex = 0;
|
|
4864
5148
|
// preventDefault at the end to allow Tab
|
|
@@ -4867,29 +5151,61 @@
|
|
|
4867
5151
|
_handleSlotChange() {
|
|
4868
5152
|
const radios = this._radios;
|
|
4869
5153
|
radios.forEach(radio => (radio.checked = radio.value === this.value));
|
|
5154
|
+
this._disabledChildRadios();
|
|
4870
5155
|
if (!radios.some(radio => radio.checked)) {
|
|
4871
5156
|
if (radios[0])
|
|
4872
5157
|
radios[0].tabIndex = 0;
|
|
4873
5158
|
}
|
|
4874
5159
|
}
|
|
4875
|
-
_handleInvalid(e) {
|
|
4876
|
-
e.preventDefault();
|
|
4877
|
-
this.invalid = true;
|
|
4878
|
-
this._radios.forEach(radio => (radio.invalid = true));
|
|
4879
|
-
}
|
|
4880
|
-
_showNativeErrorMessage() {
|
|
4881
|
-
this.input.reportValidity();
|
|
4882
|
-
}
|
|
4883
5160
|
_updateCheckedRadio() {
|
|
4884
5161
|
const radios = this._radios;
|
|
4885
5162
|
radios.forEach(radio => (radio.checked = radio.value === this.value));
|
|
4886
|
-
this.invalid = !this.validity.valid;
|
|
4887
|
-
this._radios.forEach(radio => (radio.invalid = this.invalid));
|
|
4888
5163
|
}
|
|
4889
5164
|
_renderHintText() {
|
|
4890
|
-
const hintTextTemplate = html ` <div class="form-text">${this.hintText}</div> `;
|
|
5165
|
+
const hintTextTemplate = html ` <div id="${this._controlId}Help" class="form-text">${this.hintText}</div> `;
|
|
4891
5166
|
return this.hintText && hintTextTemplate;
|
|
4892
5167
|
}
|
|
5168
|
+
/**
|
|
5169
|
+
* Checks for validity. Under the hood, HTMLFormElement's reportValidity method calls this method to check for component's validity state
|
|
5170
|
+
* 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
|
|
5171
|
+
*/
|
|
5172
|
+
reportValidity() {
|
|
5173
|
+
return this._mixinReportValidity();
|
|
5174
|
+
}
|
|
5175
|
+
/**
|
|
5176
|
+
* Checks for validity without any native error popup message
|
|
5177
|
+
*/
|
|
5178
|
+
checkValidity() {
|
|
5179
|
+
return this._mixinCheckValidity();
|
|
5180
|
+
}
|
|
5181
|
+
/**
|
|
5182
|
+
* Returns the ValidityState object
|
|
5183
|
+
*/
|
|
5184
|
+
get validity() {
|
|
5185
|
+
return this._mixinGetValidity();
|
|
5186
|
+
}
|
|
5187
|
+
/**
|
|
5188
|
+
* Returns the validation message based on the ValidityState
|
|
5189
|
+
*/
|
|
5190
|
+
get validationMessage() {
|
|
5191
|
+
return this._mixinGetValidationMessage();
|
|
5192
|
+
}
|
|
5193
|
+
_handleIsTouched() {
|
|
5194
|
+
if (this._isTouched) {
|
|
5195
|
+
this.invalid = !this.input.checkValidity();
|
|
5196
|
+
}
|
|
5197
|
+
}
|
|
5198
|
+
_handleDisabledChange() {
|
|
5199
|
+
// Disabled form controls are always valid, so we need to recheck validity when the state changes
|
|
5200
|
+
this.setInvalid(false);
|
|
5201
|
+
this._disabledChildRadios();
|
|
5202
|
+
}
|
|
5203
|
+
_disabledChildRadios() {
|
|
5204
|
+
if (this.disabled) {
|
|
5205
|
+
const radios = this._radios;
|
|
5206
|
+
radios.forEach(radio => (radio.disabled = this.disabled));
|
|
5207
|
+
}
|
|
5208
|
+
}
|
|
4893
5209
|
render() {
|
|
4894
5210
|
const defaultSlot = html `
|
|
4895
5211
|
<slot
|
|
@@ -4921,7 +5237,8 @@
|
|
|
4921
5237
|
})}"
|
|
4922
5238
|
?required=${this.required}
|
|
4923
5239
|
tabindex="-1"
|
|
4924
|
-
@
|
|
5240
|
+
@change=${(e) => super._mixinHandleChange(e)}
|
|
5241
|
+
.value=${live(this.value)}
|
|
4925
5242
|
/>
|
|
4926
5243
|
${this.invalid && this.hasFeedback
|
|
4927
5244
|
? html `
|
|
@@ -4932,7 +5249,9 @@
|
|
|
4932
5249
|
fill="#B90000"
|
|
4933
5250
|
/>
|
|
4934
5251
|
</svg>
|
|
4935
|
-
<div id="radio-group-feedback" tabindex="0" class="invalid-feedback"
|
|
5252
|
+
<div id="radio-group-feedback" tabindex="0" class="invalid-feedback">
|
|
5253
|
+
${this.invalidFeedback ? this.invalidFeedback : this.input.validationMessage}
|
|
5254
|
+
</div>
|
|
4936
5255
|
</div>
|
|
4937
5256
|
`
|
|
4938
5257
|
: nothing}
|
|
@@ -4940,34 +5259,16 @@
|
|
|
4940
5259
|
`;
|
|
4941
5260
|
}
|
|
4942
5261
|
}
|
|
4943
|
-
SgdsRadioGroup.styles = [...
|
|
5262
|
+
SgdsRadioGroup.styles = [...FormControlElement.styles, css_248z];
|
|
4944
5263
|
__decorate([
|
|
4945
5264
|
query("slot:not([name])")
|
|
4946
5265
|
], SgdsRadioGroup.prototype, "defaultSlot", void 0);
|
|
4947
|
-
__decorate([
|
|
4948
|
-
query(".radio-group-validation-input")
|
|
4949
|
-
], SgdsRadioGroup.prototype, "input", void 0);
|
|
4950
5266
|
__decorate([
|
|
4951
5267
|
state()
|
|
4952
5268
|
], SgdsRadioGroup.prototype, "defaultValue", void 0);
|
|
4953
|
-
__decorate([
|
|
4954
|
-
state()
|
|
4955
|
-
], SgdsRadioGroup.prototype, "customErrorMessage", void 0);
|
|
4956
|
-
__decorate([
|
|
4957
|
-
property({ reflect: true })
|
|
4958
|
-
], SgdsRadioGroup.prototype, "label", void 0);
|
|
4959
|
-
__decorate([
|
|
4960
|
-
property({ type: Boolean, reflect: true })
|
|
4961
|
-
], SgdsRadioGroup.prototype, "invalid", void 0);
|
|
4962
5269
|
__decorate([
|
|
4963
5270
|
property({ reflect: true })
|
|
4964
5271
|
], SgdsRadioGroup.prototype, "value", void 0);
|
|
4965
|
-
__decorate([
|
|
4966
|
-
property({ reflect: true })
|
|
4967
|
-
], SgdsRadioGroup.prototype, "name", void 0);
|
|
4968
|
-
__decorate([
|
|
4969
|
-
property({ type: Boolean, reflect: true })
|
|
4970
|
-
], SgdsRadioGroup.prototype, "required", void 0);
|
|
4971
5272
|
__decorate([
|
|
4972
5273
|
property({ type: String, reflect: true })
|
|
4973
5274
|
], SgdsRadioGroup.prototype, "invalidFeedback", void 0);
|
|
@@ -4975,14 +5276,26 @@
|
|
|
4975
5276
|
property({ type: Boolean, reflect: true })
|
|
4976
5277
|
], SgdsRadioGroup.prototype, "hasFeedback", void 0);
|
|
4977
5278
|
__decorate([
|
|
4978
|
-
property({ reflect: true })
|
|
4979
|
-
], SgdsRadioGroup.prototype, "
|
|
5279
|
+
property({ type: Boolean, reflect: true })
|
|
5280
|
+
], SgdsRadioGroup.prototype, "required", void 0);
|
|
4980
5281
|
__decorate([
|
|
4981
5282
|
watch("value", { waitUntilFirstUpdate: true })
|
|
4982
5283
|
], SgdsRadioGroup.prototype, "_handleValueChange", null);
|
|
5284
|
+
__decorate([
|
|
5285
|
+
watch("invalid", { waitUntilFirstUpdate: true })
|
|
5286
|
+
], SgdsRadioGroup.prototype, "_handleInvalidChange", null);
|
|
5287
|
+
__decorate([
|
|
5288
|
+
state()
|
|
5289
|
+
], SgdsRadioGroup.prototype, "_isTouched", void 0);
|
|
4983
5290
|
__decorate([
|
|
4984
5291
|
queryAssignedElements()
|
|
4985
5292
|
], SgdsRadioGroup.prototype, "_radios", void 0);
|
|
5293
|
+
__decorate([
|
|
5294
|
+
watch("_isTouched", { waitUntilFirstUpdate: true })
|
|
5295
|
+
], SgdsRadioGroup.prototype, "_handleIsTouched", null);
|
|
5296
|
+
__decorate([
|
|
5297
|
+
watch("disabled", { waitUntilFirstUpdate: true })
|
|
5298
|
+
], SgdsRadioGroup.prototype, "_handleDisabledChange", null);
|
|
4986
5299
|
|
|
4987
5300
|
customElements.define("sgds-radio", SgdsRadio);
|
|
4988
5301
|
customElements.define("sgds-radio-group", SgdsRadioGroup);
|