@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
|
@@ -144,7 +144,7 @@
|
|
|
144
144
|
const { is: is$1, defineProperty: defineProperty$1, getOwnPropertyDescriptor: getOwnPropertyDescriptor$1, getOwnPropertyNames: getOwnPropertyNames$1, getOwnPropertySymbols: getOwnPropertySymbols$1, getPrototypeOf: getPrototypeOf$1, } = Object;
|
|
145
145
|
// Lets a minifier replace globalThis references with a minified name
|
|
146
146
|
const global$3 = globalThis;
|
|
147
|
-
let issueWarning$
|
|
147
|
+
let issueWarning$4;
|
|
148
148
|
const trustedTypes$2 = global$3
|
|
149
149
|
.trustedTypes;
|
|
150
150
|
// Temporary workaround for https://crbug.com/993268
|
|
@@ -162,17 +162,17 @@
|
|
|
162
162
|
const issuedWarnings = (global$3.litIssuedWarnings ??=
|
|
163
163
|
new Set());
|
|
164
164
|
// Issue a warning, if we haven't already.
|
|
165
|
-
issueWarning$
|
|
165
|
+
issueWarning$4 = (code, warning) => {
|
|
166
166
|
warning += ` See https://lit.dev/msg/${code} for more information.`;
|
|
167
167
|
if (!issuedWarnings.has(warning)) {
|
|
168
168
|
console.warn(warning);
|
|
169
169
|
issuedWarnings.add(warning);
|
|
170
170
|
}
|
|
171
171
|
};
|
|
172
|
-
issueWarning$
|
|
172
|
+
issueWarning$4('dev-mode', `Lit is in dev mode. Not recommended for production!`);
|
|
173
173
|
// Issue polyfill support warning.
|
|
174
174
|
if (global$3.ShadyDOM?.inUse && polyfillSupport$3 === undefined) {
|
|
175
|
-
issueWarning$
|
|
175
|
+
issueWarning$4('polyfill-support-missing', `Shadow DOM is being polyfilled via \`ShadyDOM\` but ` +
|
|
176
176
|
`the \`polyfill-support\` module has not been loaded.`);
|
|
177
177
|
}
|
|
178
178
|
}
|
|
@@ -413,7 +413,7 @@
|
|
|
413
413
|
`but it's actually declared as a value on the prototype. ` +
|
|
414
414
|
`Usually this is due to using @property or @state on a method.`);
|
|
415
415
|
}
|
|
416
|
-
issueWarning$
|
|
416
|
+
issueWarning$4('reactive-property-without-getter', `Field ${JSON.stringify(String(name))} on ` +
|
|
417
417
|
`${this.name} was declared as a reactive property ` +
|
|
418
418
|
`but it does not have a getter. This will be an error in a ` +
|
|
419
419
|
`future version of Lit.`);
|
|
@@ -525,11 +525,11 @@
|
|
|
525
525
|
this.elementStyles = this.finalizeStyles(this.styles);
|
|
526
526
|
{
|
|
527
527
|
if (this.hasOwnProperty('createProperty')) {
|
|
528
|
-
issueWarning$
|
|
528
|
+
issueWarning$4('no-override-create-property', 'Overriding ReactiveElement.createProperty() is deprecated. ' +
|
|
529
529
|
'The override will not be called with standard decorators');
|
|
530
530
|
}
|
|
531
531
|
if (this.hasOwnProperty('getPropertyDescriptor')) {
|
|
532
|
-
issueWarning$
|
|
532
|
+
issueWarning$4('no-override-get-property-descriptor', 'Overriding ReactiveElement.getPropertyDescriptor() is deprecated. ' +
|
|
533
533
|
'The override will not be called with standard decorators');
|
|
534
534
|
}
|
|
535
535
|
}
|
|
@@ -737,7 +737,7 @@
|
|
|
737
737
|
const attrValue = converter.toAttribute(value, options.type);
|
|
738
738
|
if (this.constructor.enabledWarnings.includes('migration') &&
|
|
739
739
|
attrValue === undefined) {
|
|
740
|
-
issueWarning$
|
|
740
|
+
issueWarning$4('undefined-attribute-value', `The attribute value for the ${name} property is ` +
|
|
741
741
|
`undefined on element ${this.localName}. The attribute will be ` +
|
|
742
742
|
`removed, but in the previous version of \`ReactiveElement\`, ` +
|
|
743
743
|
`the attribute would not have changed.`);
|
|
@@ -803,7 +803,7 @@
|
|
|
803
803
|
// If we have a property key, perform property update steps.
|
|
804
804
|
if (name !== undefined) {
|
|
805
805
|
if (name instanceof Event) {
|
|
806
|
-
issueWarning$
|
|
806
|
+
issueWarning$4(``, `The requestUpdate() method was called with an Event as the property name. This is probably a mistake caused by binding this.requestUpdate as an event listener. Instead bind a function that will call it with no arguments: () => this.requestUpdate()`);
|
|
807
807
|
}
|
|
808
808
|
options ??= this.constructor.getPropertyOptions(name);
|
|
809
809
|
const hasChanged = options.hasChanged ?? notEqual$1;
|
|
@@ -885,7 +885,7 @@
|
|
|
885
885
|
if (this.constructor.enabledWarnings.includes('async-perform-update') &&
|
|
886
886
|
typeof result?.then ===
|
|
887
887
|
'function') {
|
|
888
|
-
issueWarning$
|
|
888
|
+
issueWarning$4('async-perform-update', `Element ${this.localName} returned a Promise from performUpdate(). ` +
|
|
889
889
|
`This behavior is deprecated and will be removed in a future ` +
|
|
890
890
|
`version of ReactiveElement.`);
|
|
891
891
|
}
|
|
@@ -1021,7 +1021,7 @@
|
|
|
1021
1021
|
this.updated(changedProperties);
|
|
1022
1022
|
if (this.isUpdatePending &&
|
|
1023
1023
|
this.constructor.enabledWarnings.includes('change-in-update')) {
|
|
1024
|
-
issueWarning$
|
|
1024
|
+
issueWarning$4('change-in-update', `Element ${this.localName} scheduled an update ` +
|
|
1025
1025
|
`(generally because a property was set) ` +
|
|
1026
1026
|
`after an update completed, causing a new update to be scheduled. ` +
|
|
1027
1027
|
`This is inefficient and should be avoided unless the next update ` +
|
|
@@ -1188,7 +1188,7 @@
|
|
|
1188
1188
|
// This line will be used in regexes to search for ReactiveElement usage.
|
|
1189
1189
|
(global$3.reactiveElementVersions ??= []).push('2.0.4');
|
|
1190
1190
|
if (global$3.reactiveElementVersions.length > 1) {
|
|
1191
|
-
issueWarning$
|
|
1191
|
+
issueWarning$4('multiple-versions', `Multiple versions of Lit loaded. Loading multiple versions ` +
|
|
1192
1192
|
`is not recommended.`);
|
|
1193
1193
|
}
|
|
1194
1194
|
|
|
@@ -1219,11 +1219,11 @@
|
|
|
1219
1219
|
// renders when errors are thrown preventing an endRender event from being
|
|
1220
1220
|
// called.
|
|
1221
1221
|
let debugLogRenderId = 0;
|
|
1222
|
-
let issueWarning$
|
|
1222
|
+
let issueWarning$3;
|
|
1223
1223
|
{
|
|
1224
1224
|
global$2.litIssuedWarnings ??= new Set();
|
|
1225
1225
|
// Issue a warning, if we haven't already.
|
|
1226
|
-
issueWarning$
|
|
1226
|
+
issueWarning$3 = (code, warning) => {
|
|
1227
1227
|
warning += code
|
|
1228
1228
|
? ` See https://lit.dev/msg/${code} for more information.`
|
|
1229
1229
|
: '';
|
|
@@ -1232,7 +1232,7 @@
|
|
|
1232
1232
|
global$2.litIssuedWarnings.add(warning);
|
|
1233
1233
|
}
|
|
1234
1234
|
};
|
|
1235
|
-
issueWarning$
|
|
1235
|
+
issueWarning$3('dev-mode', `Lit is in dev mode. Not recommended for production!`);
|
|
1236
1236
|
}
|
|
1237
1237
|
const wrap = global$2.ShadyDOM?.inUse &&
|
|
1238
1238
|
global$2.ShadyDOM?.noPatch === true
|
|
@@ -1383,7 +1383,7 @@
|
|
|
1383
1383
|
// handle. Instead we know that static values must have the field
|
|
1384
1384
|
// `_$litStatic$`.
|
|
1385
1385
|
if (values.some((val) => val?.['_$litStatic$'])) {
|
|
1386
|
-
issueWarning$
|
|
1386
|
+
issueWarning$3('', `Static values 'literal' or 'unsafeStatic' cannot be used as values to non-static templates.\n` +
|
|
1387
1387
|
`Please use the static 'html' tag function. See https://lit.dev/docs/templates/expressions/#static-expressions`);
|
|
1388
1388
|
}
|
|
1389
1389
|
}
|
|
@@ -1663,7 +1663,7 @@
|
|
|
1663
1663
|
throw new Error(m);
|
|
1664
1664
|
}
|
|
1665
1665
|
else
|
|
1666
|
-
issueWarning$
|
|
1666
|
+
issueWarning$3('', m);
|
|
1667
1667
|
}
|
|
1668
1668
|
}
|
|
1669
1669
|
// TODO (justinfagnani): for attempted dynamic tag names, we don't
|
|
@@ -2509,7 +2509,7 @@
|
|
|
2509
2509
|
// This line will be used in regexes to search for lit-html usage.
|
|
2510
2510
|
(global$2.litHtmlVersions ??= []).push('3.2.0');
|
|
2511
2511
|
if (global$2.litHtmlVersions.length > 1) {
|
|
2512
|
-
issueWarning$
|
|
2512
|
+
issueWarning$3('multiple-versions', `Multiple versions of Lit loaded. ` +
|
|
2513
2513
|
`Loading multiple versions is not recommended.`);
|
|
2514
2514
|
}
|
|
2515
2515
|
/**
|
|
@@ -2728,7 +2728,7 @@
|
|
|
2728
2728
|
const { is, defineProperty, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, } = Object;
|
|
2729
2729
|
// Lets a minifier replace globalThis references with a minified name
|
|
2730
2730
|
const global = globalThis;
|
|
2731
|
-
let issueWarning$
|
|
2731
|
+
let issueWarning$2;
|
|
2732
2732
|
const trustedTypes = global
|
|
2733
2733
|
.trustedTypes;
|
|
2734
2734
|
// Temporary workaround for https://crbug.com/993268
|
|
@@ -2746,17 +2746,17 @@
|
|
|
2746
2746
|
const issuedWarnings = (global.litIssuedWarnings ??=
|
|
2747
2747
|
new Set());
|
|
2748
2748
|
// Issue a warning, if we haven't already.
|
|
2749
|
-
issueWarning$
|
|
2749
|
+
issueWarning$2 = (code, warning) => {
|
|
2750
2750
|
warning += ` See https://lit.dev/msg/${code} for more information.`;
|
|
2751
2751
|
if (!issuedWarnings.has(warning)) {
|
|
2752
2752
|
console.warn(warning);
|
|
2753
2753
|
issuedWarnings.add(warning);
|
|
2754
2754
|
}
|
|
2755
2755
|
};
|
|
2756
|
-
issueWarning$
|
|
2756
|
+
issueWarning$2('dev-mode', `Lit is in dev mode. Not recommended for production!`);
|
|
2757
2757
|
// Issue polyfill support warning.
|
|
2758
2758
|
if (global.ShadyDOM?.inUse && polyfillSupport$1 === undefined) {
|
|
2759
|
-
issueWarning$
|
|
2759
|
+
issueWarning$2('polyfill-support-missing', `Shadow DOM is being polyfilled via \`ShadyDOM\` but ` +
|
|
2760
2760
|
`the \`polyfill-support\` module has not been loaded.`);
|
|
2761
2761
|
}
|
|
2762
2762
|
}
|
|
@@ -2997,7 +2997,7 @@
|
|
|
2997
2997
|
`but it's actually declared as a value on the prototype. ` +
|
|
2998
2998
|
`Usually this is due to using @property or @state on a method.`);
|
|
2999
2999
|
}
|
|
3000
|
-
issueWarning$
|
|
3000
|
+
issueWarning$2('reactive-property-without-getter', `Field ${JSON.stringify(String(name))} on ` +
|
|
3001
3001
|
`${this.name} was declared as a reactive property ` +
|
|
3002
3002
|
`but it does not have a getter. This will be an error in a ` +
|
|
3003
3003
|
`future version of Lit.`);
|
|
@@ -3109,11 +3109,11 @@
|
|
|
3109
3109
|
this.elementStyles = this.finalizeStyles(this.styles);
|
|
3110
3110
|
{
|
|
3111
3111
|
if (this.hasOwnProperty('createProperty')) {
|
|
3112
|
-
issueWarning$
|
|
3112
|
+
issueWarning$2('no-override-create-property', 'Overriding ReactiveElement.createProperty() is deprecated. ' +
|
|
3113
3113
|
'The override will not be called with standard decorators');
|
|
3114
3114
|
}
|
|
3115
3115
|
if (this.hasOwnProperty('getPropertyDescriptor')) {
|
|
3116
|
-
issueWarning$
|
|
3116
|
+
issueWarning$2('no-override-get-property-descriptor', 'Overriding ReactiveElement.getPropertyDescriptor() is deprecated. ' +
|
|
3117
3117
|
'The override will not be called with standard decorators');
|
|
3118
3118
|
}
|
|
3119
3119
|
}
|
|
@@ -3321,7 +3321,7 @@
|
|
|
3321
3321
|
const attrValue = converter.toAttribute(value, options.type);
|
|
3322
3322
|
if (this.constructor.enabledWarnings.includes('migration') &&
|
|
3323
3323
|
attrValue === undefined) {
|
|
3324
|
-
issueWarning$
|
|
3324
|
+
issueWarning$2('undefined-attribute-value', `The attribute value for the ${name} property is ` +
|
|
3325
3325
|
`undefined on element ${this.localName}. The attribute will be ` +
|
|
3326
3326
|
`removed, but in the previous version of \`ReactiveElement\`, ` +
|
|
3327
3327
|
`the attribute would not have changed.`);
|
|
@@ -3387,7 +3387,7 @@
|
|
|
3387
3387
|
// If we have a property key, perform property update steps.
|
|
3388
3388
|
if (name !== undefined) {
|
|
3389
3389
|
if (name instanceof Event) {
|
|
3390
|
-
issueWarning$
|
|
3390
|
+
issueWarning$2(``, `The requestUpdate() method was called with an Event as the property name. This is probably a mistake caused by binding this.requestUpdate as an event listener. Instead bind a function that will call it with no arguments: () => this.requestUpdate()`);
|
|
3391
3391
|
}
|
|
3392
3392
|
options ??= this.constructor.getPropertyOptions(name);
|
|
3393
3393
|
const hasChanged = options.hasChanged ?? notEqual;
|
|
@@ -3469,7 +3469,7 @@
|
|
|
3469
3469
|
if (this.constructor.enabledWarnings.includes('async-perform-update') &&
|
|
3470
3470
|
typeof result?.then ===
|
|
3471
3471
|
'function') {
|
|
3472
|
-
issueWarning$
|
|
3472
|
+
issueWarning$2('async-perform-update', `Element ${this.localName} returned a Promise from performUpdate(). ` +
|
|
3473
3473
|
`This behavior is deprecated and will be removed in a future ` +
|
|
3474
3474
|
`version of ReactiveElement.`);
|
|
3475
3475
|
}
|
|
@@ -3605,7 +3605,7 @@
|
|
|
3605
3605
|
this.updated(changedProperties);
|
|
3606
3606
|
if (this.isUpdatePending &&
|
|
3607
3607
|
this.constructor.enabledWarnings.includes('change-in-update')) {
|
|
3608
|
-
issueWarning$
|
|
3608
|
+
issueWarning$2('change-in-update', `Element ${this.localName} scheduled an update ` +
|
|
3609
3609
|
`(generally because a property was set) ` +
|
|
3610
3610
|
`after an update completed, causing a new update to be scheduled. ` +
|
|
3611
3611
|
`This is inefficient and should be avoided unless the next update ` +
|
|
@@ -3772,7 +3772,7 @@
|
|
|
3772
3772
|
// This line will be used in regexes to search for ReactiveElement usage.
|
|
3773
3773
|
(global.reactiveElementVersions ??= []).push('2.0.4');
|
|
3774
3774
|
if (global.reactiveElementVersions.length > 1) {
|
|
3775
|
-
issueWarning$
|
|
3775
|
+
issueWarning$2('multiple-versions', `Multiple versions of Lit loaded. Loading multiple versions ` +
|
|
3776
3776
|
`is not recommended.`);
|
|
3777
3777
|
}
|
|
3778
3778
|
|
|
@@ -3789,13 +3789,13 @@
|
|
|
3789
3789
|
*/
|
|
3790
3790
|
/*@__INLINE__*/
|
|
3791
3791
|
const JSCompiler_renameProperty = (prop, _obj) => prop;
|
|
3792
|
-
let issueWarning$
|
|
3792
|
+
let issueWarning$1;
|
|
3793
3793
|
{
|
|
3794
3794
|
// Ensure warnings are issued only 1x, even if multiple versions of Lit
|
|
3795
3795
|
// are loaded.
|
|
3796
3796
|
const issuedWarnings = (globalThis.litIssuedWarnings ??= new Set());
|
|
3797
3797
|
// Issue a warning, if we haven't already.
|
|
3798
|
-
issueWarning$
|
|
3798
|
+
issueWarning$1 = (code, warning) => {
|
|
3799
3799
|
warning += ` See https://lit.dev/msg/${code} for more information.`;
|
|
3800
3800
|
if (!issuedWarnings.has(warning)) {
|
|
3801
3801
|
console.warn(warning);
|
|
@@ -3930,7 +3930,7 @@
|
|
|
3930
3930
|
// This line will be used in regexes to search for LitElement usage.
|
|
3931
3931
|
(globalThis.litElementVersions ??= []).push('4.1.0');
|
|
3932
3932
|
if (globalThis.litElementVersions.length > 1) {
|
|
3933
|
-
issueWarning$
|
|
3933
|
+
issueWarning$1('multiple-versions', `Multiple versions of Lit loaded. Loading multiple versions ` +
|
|
3934
3934
|
`is not recommended.`);
|
|
3935
3935
|
}
|
|
3936
3936
|
|
|
@@ -3939,13 +3939,13 @@
|
|
|
3939
3939
|
* Copyright 2017 Google LLC
|
|
3940
3940
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
3941
3941
|
*/
|
|
3942
|
-
let issueWarning
|
|
3942
|
+
let issueWarning;
|
|
3943
3943
|
{
|
|
3944
3944
|
// Ensure warnings are issued only 1x, even if multiple versions of Lit
|
|
3945
3945
|
// are loaded.
|
|
3946
3946
|
const issuedWarnings = (globalThis.litIssuedWarnings ??= new Set());
|
|
3947
3947
|
// Issue a warning, if we haven't already.
|
|
3948
|
-
issueWarning
|
|
3948
|
+
issueWarning = (code, warning) => {
|
|
3949
3949
|
warning += ` See https://lit.dev/msg/${code} for more information.`;
|
|
3950
3950
|
if (!issuedWarnings.has(warning)) {
|
|
3951
3951
|
console.warn(warning);
|
|
@@ -3982,7 +3982,7 @@
|
|
|
3982
3982
|
const standardProperty = (options = defaultPropertyDeclaration, target, context) => {
|
|
3983
3983
|
const { kind, metadata } = context;
|
|
3984
3984
|
if (metadata == null) {
|
|
3985
|
-
issueWarning
|
|
3985
|
+
issueWarning('missing-class-metadata', `The class ${target} is missing decorator metadata. This ` +
|
|
3986
3986
|
`could mean that you're using a compiler that supports decorators ` +
|
|
3987
3987
|
`but doesn't support decorator metadata, such as TypeScript 5.1. ` +
|
|
3988
3988
|
`Please update your compiler.`);
|
|
@@ -4127,36 +4127,38 @@
|
|
|
4127
4127
|
* Copyright 2017 Google LLC
|
|
4128
4128
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
4129
4129
|
*/
|
|
4130
|
-
let issueWarning;
|
|
4131
4130
|
{
|
|
4132
4131
|
// Ensure warnings are issued only 1x, even if multiple versions of Lit
|
|
4133
4132
|
// are loaded.
|
|
4134
|
-
|
|
4135
|
-
// Issue a warning, if we haven't already.
|
|
4136
|
-
issueWarning = (code, warning) => {
|
|
4137
|
-
warning += code
|
|
4138
|
-
? ` See https://lit.dev/msg/${code} for more information.`
|
|
4139
|
-
: '';
|
|
4140
|
-
if (!issuedWarnings.has(warning)) {
|
|
4141
|
-
console.warn(warning);
|
|
4142
|
-
issuedWarnings.add(warning);
|
|
4143
|
-
}
|
|
4144
|
-
};
|
|
4133
|
+
(globalThis.litIssuedWarnings ??= new Set());
|
|
4145
4134
|
}
|
|
4135
|
+
|
|
4136
|
+
/**
|
|
4137
|
+
* @license
|
|
4138
|
+
* Copyright 2017 Google LLC
|
|
4139
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
4140
|
+
*/
|
|
4141
|
+
// Note, in the future, we may extend this decorator to support the use case
|
|
4142
|
+
// where the queried element may need to do work to become ready to interact
|
|
4143
|
+
// with (e.g. load some implementation code). If so, we might elect to
|
|
4144
|
+
// add a second argument defining a function that can be run to make the
|
|
4145
|
+
// queried element loaded/updated/ready.
|
|
4146
4146
|
/**
|
|
4147
4147
|
* A property decorator that converts a class property into a getter that
|
|
4148
|
-
*
|
|
4148
|
+
* returns a promise that resolves to the result of a querySelector on the
|
|
4149
|
+
* element's renderRoot done after the element's `updateComplete` promise
|
|
4150
|
+
* resolves. When the queried property may change with element state, this
|
|
4151
|
+
* decorator can be used instead of requiring users to await the
|
|
4152
|
+
* `updateComplete` before accessing the property.
|
|
4149
4153
|
*
|
|
4150
4154
|
* @param selector A DOMString containing one or more selectors to match.
|
|
4151
|
-
* @param cache An optional boolean which when true performs the DOM query only
|
|
4152
|
-
* once and caches the result.
|
|
4153
4155
|
*
|
|
4154
4156
|
* See: https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector
|
|
4155
4157
|
*
|
|
4156
4158
|
* ```ts
|
|
4157
4159
|
* class MyElement {
|
|
4158
|
-
* @
|
|
4159
|
-
* first: HTMLDivElement
|
|
4160
|
+
* @queryAsync('#first')
|
|
4161
|
+
* first: Promise<HTMLDivElement>;
|
|
4160
4162
|
*
|
|
4161
4163
|
* render() {
|
|
4162
4164
|
* return html`
|
|
@@ -4165,72 +4167,22 @@
|
|
|
4165
4167
|
* `;
|
|
4166
4168
|
* }
|
|
4167
4169
|
* }
|
|
4170
|
+
*
|
|
4171
|
+
* // external usage
|
|
4172
|
+
* async doSomethingWithFirst() {
|
|
4173
|
+
* (await aMyElement.first).doSomething();
|
|
4174
|
+
* }
|
|
4168
4175
|
* ```
|
|
4169
4176
|
* @category Decorator
|
|
4170
4177
|
*/
|
|
4171
|
-
function
|
|
4172
|
-
return ((
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
issueWarning('', `@query'd field ${JSON.stringify(String(name))} with the 'cache' ` +
|
|
4180
|
-
`flag set for selector '${selector}' has been accessed before ` +
|
|
4181
|
-
`the first update and returned null. This is expected if the ` +
|
|
4182
|
-
`renderRoot tree has not been provided beforehand (e.g. via ` +
|
|
4183
|
-
`Declarative Shadow DOM). Therefore the value hasn't been cached.`);
|
|
4184
|
-
}
|
|
4185
|
-
// TODO: if we want to allow users to assert that the query will never
|
|
4186
|
-
// return null, we need a new option and to throw here if the result
|
|
4187
|
-
// is null.
|
|
4188
|
-
return result;
|
|
4189
|
-
};
|
|
4190
|
-
if (cache) {
|
|
4191
|
-
// Accessors to wrap from either:
|
|
4192
|
-
// 1. The decorator target, in the case of standard decorators
|
|
4193
|
-
// 2. The property descriptor, in the case of experimental decorators
|
|
4194
|
-
// on auto-accessors.
|
|
4195
|
-
// 3. Functions that access our own cache-key property on the instance,
|
|
4196
|
-
// in the case of experimental decorators on fields.
|
|
4197
|
-
const { get, set } = typeof nameOrContext === 'object'
|
|
4198
|
-
? protoOrTarget
|
|
4199
|
-
: descriptor ??
|
|
4200
|
-
(() => {
|
|
4201
|
-
const key = Symbol(`${String(nameOrContext)} (@query() cache)`)
|
|
4202
|
-
;
|
|
4203
|
-
return {
|
|
4204
|
-
get() {
|
|
4205
|
-
return this[key];
|
|
4206
|
-
},
|
|
4207
|
-
set(v) {
|
|
4208
|
-
this[key] = v;
|
|
4209
|
-
},
|
|
4210
|
-
};
|
|
4211
|
-
})();
|
|
4212
|
-
return desc(protoOrTarget, nameOrContext, {
|
|
4213
|
-
get() {
|
|
4214
|
-
let result = get.call(this);
|
|
4215
|
-
if (result === undefined) {
|
|
4216
|
-
result = doQuery(this);
|
|
4217
|
-
if (result !== null || this.hasUpdated) {
|
|
4218
|
-
set.call(this, result);
|
|
4219
|
-
}
|
|
4220
|
-
}
|
|
4221
|
-
return result;
|
|
4222
|
-
},
|
|
4223
|
-
});
|
|
4224
|
-
}
|
|
4225
|
-
else {
|
|
4226
|
-
// This object works as the return type for both standard and
|
|
4227
|
-
// experimental decorators.
|
|
4228
|
-
return desc(protoOrTarget, nameOrContext, {
|
|
4229
|
-
get() {
|
|
4230
|
-
return doQuery(this);
|
|
4231
|
-
},
|
|
4232
|
-
});
|
|
4233
|
-
}
|
|
4178
|
+
function queryAsync(selector) {
|
|
4179
|
+
return ((obj, name) => {
|
|
4180
|
+
return desc(obj, name, {
|
|
4181
|
+
async get() {
|
|
4182
|
+
await this.updateComplete;
|
|
4183
|
+
return this.renderRoot?.querySelector(selector) ?? null;
|
|
4184
|
+
},
|
|
4185
|
+
});
|
|
4234
4186
|
});
|
|
4235
4187
|
}
|
|
4236
4188
|
|
|
@@ -4429,6 +4381,188 @@
|
|
|
4429
4381
|
*/
|
|
4430
4382
|
const ifDefined = (value) => value ?? nothing;
|
|
4431
4383
|
|
|
4384
|
+
/**
|
|
4385
|
+
* @license
|
|
4386
|
+
* Copyright 2020 Google LLC
|
|
4387
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
4388
|
+
*/
|
|
4389
|
+
window.ShadyDOM?.inUse &&
|
|
4390
|
+
window.ShadyDOM?.noPatch === true
|
|
4391
|
+
? window.ShadyDOM.wrap
|
|
4392
|
+
: (node) => node;
|
|
4393
|
+
/**
|
|
4394
|
+
* Tests whether a part has only a single-expression with no strings to
|
|
4395
|
+
* interpolate between.
|
|
4396
|
+
*
|
|
4397
|
+
* Only AttributePart and PropertyPart can have multiple expressions.
|
|
4398
|
+
* Multi-expression parts have a `strings` property and single-expression
|
|
4399
|
+
* parts do not.
|
|
4400
|
+
*/
|
|
4401
|
+
const isSingleExpression = (part) => part.strings === undefined;
|
|
4402
|
+
// A sentinel value that can never appear as a part value except when set by
|
|
4403
|
+
// live(). Used to force a dirty-check to fail and cause a re-render.
|
|
4404
|
+
const RESET_VALUE = {};
|
|
4405
|
+
/**
|
|
4406
|
+
* Sets the committed value of a ChildPart directly without triggering the
|
|
4407
|
+
* commit stage of the part.
|
|
4408
|
+
*
|
|
4409
|
+
* This is useful in cases where a directive needs to update the part such
|
|
4410
|
+
* that the next update detects a value change or not. When value is omitted,
|
|
4411
|
+
* the next update will be guaranteed to be detected as a change.
|
|
4412
|
+
*
|
|
4413
|
+
* @param part
|
|
4414
|
+
* @param value
|
|
4415
|
+
*/
|
|
4416
|
+
const setCommittedValue = (part, value = RESET_VALUE) => (part._$committedValue = value);
|
|
4417
|
+
|
|
4418
|
+
/**
|
|
4419
|
+
* @license
|
|
4420
|
+
* Copyright 2020 Google LLC
|
|
4421
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
4422
|
+
*/
|
|
4423
|
+
class LiveDirective extends Directive {
|
|
4424
|
+
constructor(partInfo) {
|
|
4425
|
+
super(partInfo);
|
|
4426
|
+
if (!(partInfo.type === PartType.PROPERTY ||
|
|
4427
|
+
partInfo.type === PartType.ATTRIBUTE ||
|
|
4428
|
+
partInfo.type === PartType.BOOLEAN_ATTRIBUTE)) {
|
|
4429
|
+
throw new Error('The `live` directive is not allowed on child or event bindings');
|
|
4430
|
+
}
|
|
4431
|
+
if (!isSingleExpression(partInfo)) {
|
|
4432
|
+
throw new Error('`live` bindings can only contain a single expression');
|
|
4433
|
+
}
|
|
4434
|
+
}
|
|
4435
|
+
render(value) {
|
|
4436
|
+
return value;
|
|
4437
|
+
}
|
|
4438
|
+
update(part, [value]) {
|
|
4439
|
+
if (value === noChange || value === nothing) {
|
|
4440
|
+
return value;
|
|
4441
|
+
}
|
|
4442
|
+
const element = part.element;
|
|
4443
|
+
const name = part.name;
|
|
4444
|
+
if (part.type === PartType.PROPERTY) {
|
|
4445
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4446
|
+
if (value === element[name]) {
|
|
4447
|
+
return noChange;
|
|
4448
|
+
}
|
|
4449
|
+
}
|
|
4450
|
+
else if (part.type === PartType.BOOLEAN_ATTRIBUTE) {
|
|
4451
|
+
if (!!value === element.hasAttribute(name)) {
|
|
4452
|
+
return noChange;
|
|
4453
|
+
}
|
|
4454
|
+
}
|
|
4455
|
+
else if (part.type === PartType.ATTRIBUTE) {
|
|
4456
|
+
if (element.getAttribute(name) === String(value)) {
|
|
4457
|
+
return noChange;
|
|
4458
|
+
}
|
|
4459
|
+
}
|
|
4460
|
+
// Resets the part's value, causing its dirty-check to fail so that it
|
|
4461
|
+
// always sets the value.
|
|
4462
|
+
setCommittedValue(part);
|
|
4463
|
+
return value;
|
|
4464
|
+
}
|
|
4465
|
+
}
|
|
4466
|
+
/**
|
|
4467
|
+
* Checks binding values against live DOM values, instead of previously bound
|
|
4468
|
+
* values, when determining whether to update the value.
|
|
4469
|
+
*
|
|
4470
|
+
* This is useful for cases where the DOM value may change from outside of
|
|
4471
|
+
* lit-html, such as with a binding to an `<input>` element's `value` property,
|
|
4472
|
+
* a content editable elements text, or to a custom element that changes it's
|
|
4473
|
+
* own properties or attributes.
|
|
4474
|
+
*
|
|
4475
|
+
* In these cases if the DOM value changes, but the value set through lit-html
|
|
4476
|
+
* bindings hasn't, lit-html won't know to update the DOM value and will leave
|
|
4477
|
+
* it alone. If this is not what you want--if you want to overwrite the DOM
|
|
4478
|
+
* value with the bound value no matter what--use the `live()` directive:
|
|
4479
|
+
*
|
|
4480
|
+
* ```js
|
|
4481
|
+
* html`<input .value=${live(x)}>`
|
|
4482
|
+
* ```
|
|
4483
|
+
*
|
|
4484
|
+
* `live()` performs a strict equality check against the live DOM value, and if
|
|
4485
|
+
* the new value is equal to the live value, does nothing. This means that
|
|
4486
|
+
* `live()` should not be used when the binding will cause a type conversion. If
|
|
4487
|
+
* you use `live()` with an attribute binding, make sure that only strings are
|
|
4488
|
+
* passed in, or the binding will update every render.
|
|
4489
|
+
*/
|
|
4490
|
+
const live = directive(LiveDirective);
|
|
4491
|
+
|
|
4492
|
+
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)}`;
|
|
4493
|
+
|
|
4494
|
+
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)}`;
|
|
4495
|
+
|
|
4496
|
+
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}`;
|
|
4497
|
+
|
|
4498
|
+
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)}`;
|
|
4499
|
+
|
|
4500
|
+
var css_248z$2 = 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}}`;
|
|
4501
|
+
|
|
4502
|
+
/**
|
|
4503
|
+
* @cssprop --sgds-{stateColor} - State colors in hexadecimal value
|
|
4504
|
+
* @cssprop --sgds-{stateColor}-rgb - State colors in rgb value
|
|
4505
|
+
* @cssprop --sgds-{stateColor}-{weights} - State colors with different weightage in hexadecimal value
|
|
4506
|
+
* @cssprop --sgds-gray-{weights} - State colors with different weightage in hexadecimal value
|
|
4507
|
+
* @cssprop --overlay-background-color - The drawer and modal component overlay background color
|
|
4508
|
+
* @cssprop --zindex-modal - The drawer and modal component z-index value
|
|
4509
|
+
*/
|
|
4510
|
+
class SgdsElement extends LitElement {
|
|
4511
|
+
/** Emits a custom event with more convenient defaults. */
|
|
4512
|
+
emit(name, options) {
|
|
4513
|
+
const event = new CustomEvent(name, Object.assign({ bubbles: true, cancelable: false, composed: true, detail: {} }, options));
|
|
4514
|
+
this.dispatchEvent(event);
|
|
4515
|
+
return event;
|
|
4516
|
+
}
|
|
4517
|
+
}
|
|
4518
|
+
SgdsElement.styles = [css_248z$2];
|
|
4519
|
+
|
|
4520
|
+
function generateId (componentName = "", elementName = "") {
|
|
4521
|
+
return `id-${Math.random().toString().substring(2, 6)}-sgds-${componentName}-${elementName}`;
|
|
4522
|
+
}
|
|
4523
|
+
|
|
4524
|
+
class FormControlElement extends SgdsElement {
|
|
4525
|
+
constructor() {
|
|
4526
|
+
super(...arguments);
|
|
4527
|
+
/** The input's label */
|
|
4528
|
+
this.label = "";
|
|
4529
|
+
/** The input's hint text */
|
|
4530
|
+
this.hintText = "";
|
|
4531
|
+
/** Disables the input. */
|
|
4532
|
+
this.disabled = false;
|
|
4533
|
+
/** Marks the component as invalid. Replace the pseudo :invalid selector for absent in custom elements */
|
|
4534
|
+
this.invalid = false;
|
|
4535
|
+
this._controlId = generateId("input");
|
|
4536
|
+
this._labelId = generateId("label");
|
|
4537
|
+
}
|
|
4538
|
+
/** Programatically sets the invalid state of the input. Pass in boolean value in the argument */
|
|
4539
|
+
setInvalid(bool) {
|
|
4540
|
+
this.invalid = bool;
|
|
4541
|
+
if (bool) {
|
|
4542
|
+
this.emit("sgds-invalid");
|
|
4543
|
+
}
|
|
4544
|
+
else {
|
|
4545
|
+
this.emit("sgds-valid");
|
|
4546
|
+
}
|
|
4547
|
+
}
|
|
4548
|
+
}
|
|
4549
|
+
FormControlElement.styles = [...SgdsElement.styles, css_248z$6, css_248z$5, css_248z$4, css_248z$3];
|
|
4550
|
+
__decorate([
|
|
4551
|
+
property({ reflect: true })
|
|
4552
|
+
], FormControlElement.prototype, "label", void 0);
|
|
4553
|
+
__decorate([
|
|
4554
|
+
property({ reflect: true })
|
|
4555
|
+
], FormControlElement.prototype, "hintText", void 0);
|
|
4556
|
+
__decorate([
|
|
4557
|
+
property({ reflect: true })
|
|
4558
|
+
], FormControlElement.prototype, "name", void 0);
|
|
4559
|
+
__decorate([
|
|
4560
|
+
property({ type: Boolean, reflect: true })
|
|
4561
|
+
], FormControlElement.prototype, "disabled", void 0);
|
|
4562
|
+
__decorate([
|
|
4563
|
+
property({ type: Boolean, reflect: true })
|
|
4564
|
+
], FormControlElement.prototype, "invalid", void 0);
|
|
4565
|
+
|
|
4432
4566
|
// @defaultValue decorator
|
|
4433
4567
|
const defaultValue = (propertyName = "value") => (proto, key) => {
|
|
4434
4568
|
const ctor = proto.constructor;
|
|
@@ -4449,135 +4583,225 @@
|
|
|
4449
4583
|
};
|
|
4450
4584
|
};
|
|
4451
4585
|
|
|
4452
|
-
|
|
4453
|
-
|
|
4586
|
+
/**
|
|
4587
|
+
* SGDS custom form validation methods and behaviours
|
|
4588
|
+
*/
|
|
4589
|
+
class InputValidationController {
|
|
4454
4590
|
constructor(host, options) {
|
|
4455
4591
|
(this.host = host).addController(this);
|
|
4456
|
-
this.
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
} }, options);
|
|
4463
|
-
this.handleFormData = this.handleFormData.bind(this);
|
|
4464
|
-
this.handleFormSubmit = this.handleFormSubmit.bind(this);
|
|
4465
|
-
this.handleFormReset = this.handleFormReset.bind(this);
|
|
4466
|
-
this.reportFormValidity = this.reportFormValidity.bind(this);
|
|
4592
|
+
this._internals = this.host.attachInternals();
|
|
4593
|
+
this.options = Object.assign({ setInvalid: (host, value) => {
|
|
4594
|
+
host.invalid = value;
|
|
4595
|
+
}, value: (host) => {
|
|
4596
|
+
return host.value;
|
|
4597
|
+
}, input: (host) => host.input }, options);
|
|
4467
4598
|
}
|
|
4468
4599
|
hostConnected() {
|
|
4469
|
-
this.
|
|
4470
|
-
if (this.form) {
|
|
4471
|
-
this.form.addEventListener("formdata", this.handleFormData);
|
|
4472
|
-
this.form.addEventListener("submit", this.handleFormSubmit);
|
|
4473
|
-
this.form.addEventListener("reset", this.handleFormReset);
|
|
4474
|
-
// Overload the form's reportValidity() method so it looks at Shoelace form controls
|
|
4475
|
-
if (!reportValidityOverloads.has(this.form)) {
|
|
4476
|
-
reportValidityOverloads.set(this.form, this.form.reportValidity);
|
|
4477
|
-
this.form.reportValidity = () => this.reportFormValidity();
|
|
4478
|
-
}
|
|
4479
|
-
}
|
|
4600
|
+
this.host.addEventListener("invalid", e => this.handleInvalid(e));
|
|
4480
4601
|
}
|
|
4481
4602
|
hostDisconnected() {
|
|
4482
|
-
|
|
4483
|
-
this.form.removeEventListener("formdata", this.handleFormData);
|
|
4484
|
-
this.form.removeEventListener("submit", this.handleFormSubmit);
|
|
4485
|
-
this.form.removeEventListener("reset", this.handleFormReset);
|
|
4486
|
-
// Remove the overload and restore the original method
|
|
4487
|
-
if (reportValidityOverloads.has(this.form)) {
|
|
4488
|
-
this.form.reportValidity = reportValidityOverloads.get(this.form);
|
|
4489
|
-
reportValidityOverloads.delete(this.form);
|
|
4490
|
-
}
|
|
4491
|
-
this.form = undefined;
|
|
4492
|
-
}
|
|
4603
|
+
this.host.removeEventListener("invalid", e => this.handleInvalid(e));
|
|
4493
4604
|
}
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4605
|
+
/**
|
|
4606
|
+
* Prevents the native browser error message pop up when reportValidity() called by
|
|
4607
|
+
* associated form or the component's reportValidity during constraint validation
|
|
4608
|
+
* Sets invalid reactive prop to true
|
|
4609
|
+
*/
|
|
4610
|
+
handleInvalid(e) {
|
|
4611
|
+
e.preventDefault();
|
|
4612
|
+
this.options.setInvalid(this.host, true);
|
|
4613
|
+
}
|
|
4614
|
+
/**
|
|
4615
|
+
* Sets invalid to false when invoked and
|
|
4616
|
+
* Updates the ValidityState based on new value, but
|
|
4617
|
+
* does not update invalid reactive prop
|
|
4618
|
+
* @param e
|
|
4619
|
+
*/
|
|
4620
|
+
handleInput(e) {
|
|
4621
|
+
const input = e.target;
|
|
4622
|
+
this.options.setInvalid(this.host, false);
|
|
4623
|
+
this.validateInput(input);
|
|
4624
|
+
}
|
|
4625
|
+
/**
|
|
4626
|
+
* Validate the input's new value after onChange and
|
|
4627
|
+
* update invalid reactive prop
|
|
4628
|
+
* @param e
|
|
4629
|
+
*/
|
|
4630
|
+
handleChange(e) {
|
|
4631
|
+
const input = e.target;
|
|
4632
|
+
this.validateInput(input);
|
|
4633
|
+
this.options.setInvalid(this.host, !this.checkValidity());
|
|
4634
|
+
}
|
|
4635
|
+
get form() {
|
|
4636
|
+
return this._internals.form;
|
|
4637
|
+
}
|
|
4638
|
+
get validity() {
|
|
4639
|
+
return this._internals.validity;
|
|
4640
|
+
}
|
|
4641
|
+
get validationMessage() {
|
|
4642
|
+
return this._internals.validationMessage;
|
|
4643
|
+
}
|
|
4644
|
+
get willValidate() {
|
|
4645
|
+
return this._internals.willValidate;
|
|
4646
|
+
}
|
|
4647
|
+
/**
|
|
4648
|
+
* Checks the validity and updates the invalid reactive prop of form components
|
|
4649
|
+
*/
|
|
4650
|
+
updateInvalidState() {
|
|
4651
|
+
this.options.setInvalid(this.host, !this.checkValidity());
|
|
4652
|
+
}
|
|
4653
|
+
/**
|
|
4654
|
+
* Resets the ValidityState of the control
|
|
4655
|
+
*/
|
|
4656
|
+
resetValidity() {
|
|
4657
|
+
return this._internals.setValidity({});
|
|
4658
|
+
}
|
|
4659
|
+
/**
|
|
4660
|
+
* Reports the validity
|
|
4661
|
+
*/
|
|
4662
|
+
checkValidity() {
|
|
4663
|
+
return this._internals.checkValidity();
|
|
4664
|
+
}
|
|
4665
|
+
/**
|
|
4666
|
+
* Reports the validity with a error popup message
|
|
4667
|
+
*/
|
|
4668
|
+
reportValidity() {
|
|
4669
|
+
return this._internals.reportValidity();
|
|
4670
|
+
}
|
|
4671
|
+
/**
|
|
4672
|
+
* Sets the form control value into FormData,
|
|
4673
|
+
* making the value of control accessible via FormData
|
|
4674
|
+
*/
|
|
4675
|
+
setFormValue() {
|
|
4497
4676
|
const value = this.options.value(this.host);
|
|
4498
|
-
|
|
4499
|
-
if (Array.isArray(value)) {
|
|
4500
|
-
value.forEach(val => {
|
|
4501
|
-
event.formData.append(name, val.toString());
|
|
4502
|
-
});
|
|
4503
|
-
}
|
|
4504
|
-
else {
|
|
4505
|
-
event.formData.append(name, value.toString());
|
|
4506
|
-
}
|
|
4507
|
-
}
|
|
4677
|
+
this._internals.setFormValue(value);
|
|
4508
4678
|
}
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
//
|
|
4531
|
-
// Note that we're also honoring the form's novalidate attribute.
|
|
4532
|
-
//
|
|
4533
|
-
if (this.form && !this.form.noValidate) {
|
|
4534
|
-
// This seems sloppy, but checking all elements will cover native inputs, Shoelace inputs, and other custom
|
|
4535
|
-
// elements that support the constraint validation API.
|
|
4536
|
-
const elements = this.form.querySelectorAll("*");
|
|
4537
|
-
for (const element of elements) {
|
|
4538
|
-
if (typeof element.reportValidity === "function") {
|
|
4539
|
-
if (!element.reportValidity()) {
|
|
4540
|
-
return false;
|
|
4541
|
-
}
|
|
4679
|
+
/**
|
|
4680
|
+
* Updates the ValidityState of the input in form component at current state
|
|
4681
|
+
*/
|
|
4682
|
+
validateInput(input) {
|
|
4683
|
+
/** When the form control is disabled, its always valid */
|
|
4684
|
+
if (this.options.input(this.host).disabled) {
|
|
4685
|
+
return this._internals.setValidity({});
|
|
4686
|
+
}
|
|
4687
|
+
// get the validity of the internal <input>
|
|
4688
|
+
const validState = input.validity;
|
|
4689
|
+
// if the input is invalid, show the correct error
|
|
4690
|
+
if (!validState.valid) {
|
|
4691
|
+
// loop through the error reasons
|
|
4692
|
+
for (const state in validState) {
|
|
4693
|
+
// if there is an error and corresponding attribute holding
|
|
4694
|
+
// the message
|
|
4695
|
+
if (validState[state]) {
|
|
4696
|
+
this.validationError = state.toString();
|
|
4697
|
+
// set the validity error reason and the corresponding
|
|
4698
|
+
// message
|
|
4699
|
+
this._internals.setValidity({ [this.validationError]: true }, input.validationMessage, input);
|
|
4542
4700
|
}
|
|
4543
4701
|
}
|
|
4544
4702
|
}
|
|
4545
|
-
|
|
4703
|
+
else {
|
|
4704
|
+
this._internals.setValidity({});
|
|
4705
|
+
}
|
|
4546
4706
|
}
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4707
|
+
}
|
|
4708
|
+
|
|
4709
|
+
/**
|
|
4710
|
+
* @summary The FormValidationMixin used by the form components
|
|
4711
|
+
* @param superClass
|
|
4712
|
+
* @returns
|
|
4713
|
+
*/
|
|
4714
|
+
const SgdsFormValidatorMixin = (superClass) => {
|
|
4715
|
+
class ToBeValidatedElement extends superClass {
|
|
4716
|
+
constructor() {
|
|
4717
|
+
super(...arguments);
|
|
4718
|
+
this._isTouched = false;
|
|
4719
|
+
}
|
|
4720
|
+
connectedCallback() {
|
|
4721
|
+
super.connectedCallback();
|
|
4722
|
+
this.inputValidationController = new InputValidationController(this);
|
|
4723
|
+
}
|
|
4724
|
+
async firstUpdated(changedProperties) {
|
|
4725
|
+
super.firstUpdated(changedProperties);
|
|
4726
|
+
/* Either input or sgds-input. For example, quantity-toggle uses sgds-input */
|
|
4727
|
+
this.input =
|
|
4728
|
+
this.shadowRoot.querySelector("input") || (await this.sgdsInput) || this.shadowRoot.querySelector("textarea");
|
|
4729
|
+
this._mixinValidate(this.input);
|
|
4730
|
+
}
|
|
4731
|
+
/**
|
|
4732
|
+
* Native lifecycle of Form-Associated Custom Element Callbacks
|
|
4733
|
+
*/
|
|
4734
|
+
formResetCallback() {
|
|
4735
|
+
if (this._mixinResetFormControl) {
|
|
4736
|
+
this._mixinResetFormControl();
|
|
4564
4737
|
}
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4738
|
+
else {
|
|
4739
|
+
this.value = this.defaultValue;
|
|
4740
|
+
this._mixinResetValidity(this.input);
|
|
4741
|
+
}
|
|
4742
|
+
this._mixinSetFormValue();
|
|
4743
|
+
}
|
|
4744
|
+
/**
|
|
4745
|
+
*
|
|
4746
|
+
* Methods use by classes using this mixin
|
|
4747
|
+
*/
|
|
4748
|
+
/**
|
|
4749
|
+
* OnChange of form component
|
|
4750
|
+
* 1. Make value of control accessible via FormData
|
|
4751
|
+
* 2. Run change handler
|
|
4752
|
+
*/
|
|
4753
|
+
_mixinHandleChange(e) {
|
|
4754
|
+
this._mixinSetFormValue();
|
|
4755
|
+
this.inputValidationController.handleChange(e);
|
|
4756
|
+
}
|
|
4757
|
+
/**
|
|
4758
|
+
* OnChange of form component
|
|
4759
|
+
* 1. Make value of control accessible via FormData
|
|
4760
|
+
* 2. Run input handler
|
|
4761
|
+
*/
|
|
4762
|
+
_mixinHandleInputChange(e) {
|
|
4763
|
+
this._mixinSetFormValue();
|
|
4764
|
+
this.inputValidationController.handleInput(e);
|
|
4765
|
+
}
|
|
4766
|
+
/**
|
|
4767
|
+
* During form resetting,
|
|
4768
|
+
* 1. ValidityState is reset
|
|
4769
|
+
* 2. invalid reactive prop is updated after the reset
|
|
4770
|
+
* 3. Revalidates the ValidityState (but do not update invalid prop)
|
|
4771
|
+
* to prepare for the next validity check
|
|
4772
|
+
* 4. Reset touched state to false for a pristine form
|
|
4773
|
+
*/
|
|
4774
|
+
_mixinResetValidity(input) {
|
|
4775
|
+
this.inputValidationController.resetValidity();
|
|
4776
|
+
this.inputValidationController.updateInvalidState();
|
|
4777
|
+
this.inputValidationController.validateInput(input);
|
|
4778
|
+
this._isTouched ? (this._isTouched = false) : null;
|
|
4779
|
+
}
|
|
4780
|
+
_mixinValidate(input) {
|
|
4781
|
+
this.inputValidationController.validateInput(input);
|
|
4782
|
+
}
|
|
4783
|
+
_mixinSetFormValue() {
|
|
4784
|
+
this.inputValidationController.setFormValue();
|
|
4785
|
+
}
|
|
4786
|
+
_mixinCheckValidity() {
|
|
4787
|
+
return this.inputValidationController.checkValidity();
|
|
4788
|
+
}
|
|
4789
|
+
_mixinReportValidity() {
|
|
4790
|
+
return this.inputValidationController.reportValidity();
|
|
4791
|
+
}
|
|
4792
|
+
_mixinGetValidity() {
|
|
4793
|
+
return this.inputValidationController.validity;
|
|
4794
|
+
}
|
|
4795
|
+
_mixinGetValidationMessage() {
|
|
4796
|
+
return this.inputValidationController.validationMessage;
|
|
4568
4797
|
}
|
|
4569
4798
|
}
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
// Calling form.submit() bypasses the submit event and constraint validation. To prevent this, we can inject a
|
|
4577
|
-
// native submit button into the form, "click" it, then remove it to simulate a standard form submission.
|
|
4578
|
-
this.doAction("submit", invoker);
|
|
4579
|
-
}
|
|
4580
|
-
}
|
|
4799
|
+
ToBeValidatedElement.formAssociated = true;
|
|
4800
|
+
__decorate([
|
|
4801
|
+
queryAsync("sgds-input")
|
|
4802
|
+
], ToBeValidatedElement.prototype, "sgdsInput", void 0);
|
|
4803
|
+
return ToBeValidatedElement;
|
|
4804
|
+
};
|
|
4581
4805
|
|
|
4582
4806
|
// @watch decorator
|
|
4583
4807
|
//
|
|
@@ -4616,188 +4840,7 @@
|
|
|
4616
4840
|
};
|
|
4617
4841
|
}
|
|
4618
4842
|
|
|
4619
|
-
var css_248z$
|
|
4620
|
-
|
|
4621
|
-
/**
|
|
4622
|
-
* @cssprop --sgds-{stateColor} - State colors in hexadecimal value
|
|
4623
|
-
* @cssprop --sgds-{stateColor}-rgb - State colors in rgb value
|
|
4624
|
-
* @cssprop --sgds-{stateColor}-{weights} - State colors with different weightage in hexadecimal value
|
|
4625
|
-
* @cssprop --sgds-gray-{weights} - State colors with different weightage in hexadecimal value
|
|
4626
|
-
* @cssprop --overlay-background-color - The drawer and modal component overlay background color
|
|
4627
|
-
* @cssprop --zindex-modal - The drawer and modal component z-index value
|
|
4628
|
-
*/
|
|
4629
|
-
class SgdsElement extends LitElement {
|
|
4630
|
-
/** Emits a custom event with more convenient defaults. */
|
|
4631
|
-
emit(name, options) {
|
|
4632
|
-
const event = new CustomEvent(name, Object.assign({ bubbles: true, cancelable: false, composed: true, detail: {} }, options));
|
|
4633
|
-
this.dispatchEvent(event);
|
|
4634
|
-
return event;
|
|
4635
|
-
}
|
|
4636
|
-
}
|
|
4637
|
-
SgdsElement.styles = [css_248z$5];
|
|
4638
|
-
|
|
4639
|
-
class FormCheckElement extends SgdsElement {
|
|
4640
|
-
constructor() {
|
|
4641
|
-
super(...arguments);
|
|
4642
|
-
/**@internal */
|
|
4643
|
-
this.formSubmitController = new FormSubmitController(this, {
|
|
4644
|
-
value: (control) => (control.checked ? control.value : undefined),
|
|
4645
|
-
defaultValue: (control) => control.defaultChecked,
|
|
4646
|
-
setValue: (control, checked) => (control.checked = checked)
|
|
4647
|
-
});
|
|
4648
|
-
/** For aria-label when there is no appropriate text label visible */
|
|
4649
|
-
this.ariaLabel = "checkbox";
|
|
4650
|
-
/** Makes the checkbox a required field. */
|
|
4651
|
-
this.required = false;
|
|
4652
|
-
/** Draws the checkbox in a checked state. */
|
|
4653
|
-
this.checked = false;
|
|
4654
|
-
/** Disables the checkbox (so the user can't check / uncheck it). */
|
|
4655
|
-
this.disabled = false;
|
|
4656
|
-
/** Allows invalidFeedback, invalid and valid styles to be visible with the input */
|
|
4657
|
-
this.hasFeedback = false;
|
|
4658
|
-
/** 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. */
|
|
4659
|
-
this.defaultChecked = false;
|
|
4660
|
-
/** Marks the checkbox input as invalid. Replace the pseudo :invalid selector for absent in custom elements */
|
|
4661
|
-
this.invalid = false;
|
|
4662
|
-
/** Marks the checkbox input as indeterminate , with indeterminate logo */
|
|
4663
|
-
this.indeterminate = false;
|
|
4664
|
-
}
|
|
4665
|
-
_handleInvalidChange() {
|
|
4666
|
-
this.emit("sgds-validity-change", { detail: { invalid: this.invalid } });
|
|
4667
|
-
}
|
|
4668
|
-
/** Simulates a click on the checkbox. */
|
|
4669
|
-
click() {
|
|
4670
|
-
this.input.click();
|
|
4671
|
-
}
|
|
4672
|
-
/** Sets focus on the checkbox. */
|
|
4673
|
-
focus(options) {
|
|
4674
|
-
this.input.focus(options);
|
|
4675
|
-
}
|
|
4676
|
-
/** Removes focus from the checkbox. */
|
|
4677
|
-
blur() {
|
|
4678
|
-
this.input.blur();
|
|
4679
|
-
}
|
|
4680
|
-
/** Checks for validity and shows the browser's validation message if the control is invalid. */
|
|
4681
|
-
reportValidity() {
|
|
4682
|
-
if (!this.input.reportValidity()) {
|
|
4683
|
-
this.invalid = !this.input.checkValidity();
|
|
4684
|
-
}
|
|
4685
|
-
return this.input.reportValidity();
|
|
4686
|
-
}
|
|
4687
|
-
_handleChange() {
|
|
4688
|
-
if (this.indeterminate) {
|
|
4689
|
-
this.indeterminate = !this.indeterminate;
|
|
4690
|
-
}
|
|
4691
|
-
this.checked = !this.checked;
|
|
4692
|
-
this.value = this.input.value;
|
|
4693
|
-
this.emit("sgds-change", { detail: { checked: this.checked, value: this.value } });
|
|
4694
|
-
}
|
|
4695
|
-
_handleKeyDown(event) {
|
|
4696
|
-
const hasModifier = event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;
|
|
4697
|
-
if (event.key === "Enter" && !hasModifier) {
|
|
4698
|
-
this.click();
|
|
4699
|
-
}
|
|
4700
|
-
}
|
|
4701
|
-
_handleInvalid(e) {
|
|
4702
|
-
e.preventDefault();
|
|
4703
|
-
this.invalid = true;
|
|
4704
|
-
}
|
|
4705
|
-
/** @internal */
|
|
4706
|
-
handleDisabledChange() {
|
|
4707
|
-
// Disabled form controls are always valid, so we need to recheck validity when the state changes
|
|
4708
|
-
this.input.disabled = this.disabled;
|
|
4709
|
-
this.invalid = !this.input.checkValidity();
|
|
4710
|
-
}
|
|
4711
|
-
/** @internal */
|
|
4712
|
-
handleStateChange() {
|
|
4713
|
-
this.invalid = !this.input.checkValidity();
|
|
4714
|
-
}
|
|
4715
|
-
render() {
|
|
4716
|
-
return html `
|
|
4717
|
-
<div
|
|
4718
|
-
class=${classMap({
|
|
4719
|
-
"form-check": true
|
|
4720
|
-
})}
|
|
4721
|
-
>
|
|
4722
|
-
<input
|
|
4723
|
-
class=${classMap({
|
|
4724
|
-
"form-check-input": true,
|
|
4725
|
-
"is-invalid": this.hasFeedback && this.invalid,
|
|
4726
|
-
md: this._size === "md"
|
|
4727
|
-
})}
|
|
4728
|
-
type="checkbox"
|
|
4729
|
-
id=${this._inputId}
|
|
4730
|
-
aria-invalid=${this.invalid ? "true" : "false"}
|
|
4731
|
-
name=${ifDefined(this.name)}
|
|
4732
|
-
value=${ifDefined(this.value)}
|
|
4733
|
-
?checked=${this.checked}
|
|
4734
|
-
?indeterminate=${this.indeterminate}
|
|
4735
|
-
?disabled=${this.disabled}
|
|
4736
|
-
?required=${this.required}
|
|
4737
|
-
aria-disabled=${this.disabled ? "true" : "false"}
|
|
4738
|
-
aria-checked=${this.checked ? "true" : "false"}
|
|
4739
|
-
@change=${this._handleChange}
|
|
4740
|
-
@keydown=${this._handleKeyDown}
|
|
4741
|
-
@invalid=${(e) => this._handleInvalid(e)}
|
|
4742
|
-
/>
|
|
4743
|
-
<label for="${this._inputId}" aria-label=${ifDefined(this.ariaLabel)} class="form-check-label"
|
|
4744
|
-
><slot></slot
|
|
4745
|
-
></label>
|
|
4746
|
-
</div>
|
|
4747
|
-
`;
|
|
4748
|
-
}
|
|
4749
|
-
}
|
|
4750
|
-
__decorate([
|
|
4751
|
-
query('input[type="checkbox"]')
|
|
4752
|
-
], FormCheckElement.prototype, "input", void 0);
|
|
4753
|
-
__decorate([
|
|
4754
|
-
property({ type: String, reflect: true })
|
|
4755
|
-
], FormCheckElement.prototype, "name", void 0);
|
|
4756
|
-
__decorate([
|
|
4757
|
-
property({ type: String, reflect: true })
|
|
4758
|
-
], FormCheckElement.prototype, "ariaLabel", void 0);
|
|
4759
|
-
__decorate([
|
|
4760
|
-
property({ type: String, reflect: true })
|
|
4761
|
-
], FormCheckElement.prototype, "value", void 0);
|
|
4762
|
-
__decorate([
|
|
4763
|
-
property({ type: Boolean, reflect: true })
|
|
4764
|
-
], FormCheckElement.prototype, "required", void 0);
|
|
4765
|
-
__decorate([
|
|
4766
|
-
property({ type: Boolean, reflect: true })
|
|
4767
|
-
], FormCheckElement.prototype, "checked", void 0);
|
|
4768
|
-
__decorate([
|
|
4769
|
-
property({ type: Boolean, reflect: true })
|
|
4770
|
-
], FormCheckElement.prototype, "disabled", void 0);
|
|
4771
|
-
__decorate([
|
|
4772
|
-
property({ type: Boolean, reflect: true })
|
|
4773
|
-
], FormCheckElement.prototype, "hasFeedback", void 0);
|
|
4774
|
-
__decorate([
|
|
4775
|
-
defaultValue("checked")
|
|
4776
|
-
], FormCheckElement.prototype, "defaultChecked", void 0);
|
|
4777
|
-
__decorate([
|
|
4778
|
-
property({ type: Boolean, reflect: true })
|
|
4779
|
-
], FormCheckElement.prototype, "invalid", void 0);
|
|
4780
|
-
__decorate([
|
|
4781
|
-
property({ type: Boolean, reflect: true })
|
|
4782
|
-
], FormCheckElement.prototype, "indeterminate", void 0);
|
|
4783
|
-
__decorate([
|
|
4784
|
-
watch("invalid", { waitUntilFirstUpdate: true })
|
|
4785
|
-
], FormCheckElement.prototype, "_handleInvalidChange", null);
|
|
4786
|
-
__decorate([
|
|
4787
|
-
property({ type: String })
|
|
4788
|
-
], FormCheckElement.prototype, "_size", void 0);
|
|
4789
|
-
__decorate([
|
|
4790
|
-
watch("disabled", { waitUntilFirstUpdate: true })
|
|
4791
|
-
], FormCheckElement.prototype, "handleDisabledChange", null);
|
|
4792
|
-
__decorate([
|
|
4793
|
-
watch("checked", { waitUntilFirstUpdate: true })
|
|
4794
|
-
], FormCheckElement.prototype, "handleStateChange", null);
|
|
4795
|
-
|
|
4796
|
-
function genId (componentName = "", elementName = "") {
|
|
4797
|
-
return `id-${Math.random().toString().substring(2, 6)}-sgds-${componentName}-${elementName}`;
|
|
4798
|
-
}
|
|
4799
|
-
|
|
4800
|
-
var css_248z$4 = 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)}`;
|
|
4843
|
+
var css_248z$1 = 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)}`;
|
|
4801
4844
|
|
|
4802
4845
|
/**
|
|
4803
4846
|
* @summary Checkbox component is used when you require users to select multiple items from a list.
|
|
@@ -4805,36 +4848,29 @@
|
|
|
4805
4848
|
* @slot default - The label of checkbox.
|
|
4806
4849
|
*
|
|
4807
4850
|
* @event sgds-change - Emitted when the checked state changes.
|
|
4851
|
+
* @event sgds-blur - Emitted when input is not in focus.
|
|
4852
|
+
* @event sgds-focus - Emitted when input is in focus.
|
|
4808
4853
|
* @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
|
|
4809
4854
|
*/
|
|
4810
|
-
class SgdsCheckbox extends
|
|
4855
|
+
class SgdsCheckbox extends SgdsFormValidatorMixin(FormControlElement) {
|
|
4811
4856
|
constructor() {
|
|
4812
4857
|
super(...arguments);
|
|
4813
|
-
/**@internal */
|
|
4814
|
-
this.formSubmitController = new FormSubmitController(this, {
|
|
4815
|
-
value: (control) => (control.checked ? control.value : undefined),
|
|
4816
|
-
defaultValue: (control) => control.defaultChecked,
|
|
4817
|
-
setValue: (control, checked) => (control.checked = checked)
|
|
4818
|
-
});
|
|
4819
|
-
/** Makes the checkbox a required field. */
|
|
4820
|
-
this.required = false;
|
|
4821
4858
|
/** Draws the checkbox in a checked state. */
|
|
4822
4859
|
this.checked = false;
|
|
4823
|
-
/** Disables the checkbox (so the user can't check / uncheck it). */
|
|
4824
|
-
this.disabled = false;
|
|
4825
4860
|
/** Allows invalidFeedback, invalid and valid styles to be visible with the input */
|
|
4826
4861
|
this.hasFeedback = false;
|
|
4827
4862
|
/** 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. */
|
|
4828
4863
|
this.defaultChecked = false;
|
|
4829
|
-
/** Marks the checkbox input as invalid. Replace the pseudo :invalid selector for absent in custom elements */
|
|
4830
|
-
this.invalid = false;
|
|
4831
4864
|
/** Marks the checkbox input as indeterminate , with indeterminate logo */
|
|
4832
4865
|
this.indeterminate = false;
|
|
4833
|
-
/**
|
|
4834
|
-
this.
|
|
4866
|
+
/** Makes the checkbox a required field. */
|
|
4867
|
+
this.required = false;
|
|
4868
|
+
this._isTouched = false;
|
|
4835
4869
|
}
|
|
4836
4870
|
_handleInvalidChange() {
|
|
4837
|
-
this.emit("sgds-validity-change", {
|
|
4871
|
+
this.emit("sgds-validity-change", {
|
|
4872
|
+
detail: { invalid: this.invalid, validationMessage: this.input.validationMessage }
|
|
4873
|
+
});
|
|
4838
4874
|
}
|
|
4839
4875
|
/** Simulates a click on the checkbox. */
|
|
4840
4876
|
click() {
|
|
@@ -4848,19 +4884,13 @@
|
|
|
4848
4884
|
blur() {
|
|
4849
4885
|
this.input.blur();
|
|
4850
4886
|
}
|
|
4851
|
-
|
|
4852
|
-
reportValidity() {
|
|
4853
|
-
if (!this.input.reportValidity()) {
|
|
4854
|
-
this.invalid = !this.input.checkValidity();
|
|
4855
|
-
}
|
|
4856
|
-
return this.input.reportValidity();
|
|
4857
|
-
}
|
|
4858
|
-
_handleChange() {
|
|
4887
|
+
_handleChange(e) {
|
|
4859
4888
|
if (this.indeterminate) {
|
|
4860
4889
|
this.indeterminate = !this.indeterminate;
|
|
4861
4890
|
}
|
|
4862
4891
|
this.checked = !this.checked;
|
|
4863
4892
|
this.value = this.input.value;
|
|
4893
|
+
super._mixinHandleChange(e);
|
|
4864
4894
|
this.emit("sgds-change", { detail: { checked: this.checked, value: this.value } });
|
|
4865
4895
|
}
|
|
4866
4896
|
_handleKeyDown(event) {
|
|
@@ -4869,6 +4899,13 @@
|
|
|
4869
4899
|
this.click();
|
|
4870
4900
|
}
|
|
4871
4901
|
}
|
|
4902
|
+
_handleBlur() {
|
|
4903
|
+
this._isTouched = true;
|
|
4904
|
+
this.emit("sgds-blur");
|
|
4905
|
+
}
|
|
4906
|
+
_handleFocus() {
|
|
4907
|
+
this.emit("sgds-focus");
|
|
4908
|
+
}
|
|
4872
4909
|
_handleInvalid(e) {
|
|
4873
4910
|
e.preventDefault();
|
|
4874
4911
|
this.invalid = true;
|
|
@@ -4876,12 +4913,43 @@
|
|
|
4876
4913
|
/** @internal */
|
|
4877
4914
|
_handleDisabledChange() {
|
|
4878
4915
|
// Disabled form controls are always valid, so we need to recheck validity when the state changes
|
|
4879
|
-
this.
|
|
4880
|
-
this.invalid = !this.input.checkValidity();
|
|
4916
|
+
this.setInvalid(false);
|
|
4881
4917
|
}
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4918
|
+
_handleIsTouched() {
|
|
4919
|
+
if (this._isTouched) {
|
|
4920
|
+
this.invalid = !this.input.checkValidity();
|
|
4921
|
+
}
|
|
4922
|
+
}
|
|
4923
|
+
_mixinResetFormControl() {
|
|
4924
|
+
this._isTouched = false;
|
|
4925
|
+
this.checked = this.input.checked = this.defaultChecked;
|
|
4926
|
+
this.input.dispatchEvent(new InputEvent("reset"));
|
|
4927
|
+
this._mixinResetValidity(this.input);
|
|
4928
|
+
}
|
|
4929
|
+
/**
|
|
4930
|
+
* Checks for validity. Under the hood, HTMLFormElement's reportValidity method calls this method to check for component's validity state
|
|
4931
|
+
* 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
|
|
4932
|
+
*/
|
|
4933
|
+
reportValidity() {
|
|
4934
|
+
return this._mixinReportValidity();
|
|
4935
|
+
}
|
|
4936
|
+
/**
|
|
4937
|
+
* Checks for validity without any native error popup message
|
|
4938
|
+
*/
|
|
4939
|
+
checkValidity() {
|
|
4940
|
+
return this._mixinCheckValidity();
|
|
4941
|
+
}
|
|
4942
|
+
/**
|
|
4943
|
+
* Returns the ValidityState object
|
|
4944
|
+
*/
|
|
4945
|
+
get validity() {
|
|
4946
|
+
return this._mixinGetValidity();
|
|
4947
|
+
}
|
|
4948
|
+
/**
|
|
4949
|
+
* Returns the validation message based on the ValidityState
|
|
4950
|
+
*/
|
|
4951
|
+
get validationMessage() {
|
|
4952
|
+
return this._mixinGetValidationMessage();
|
|
4885
4953
|
}
|
|
4886
4954
|
render() {
|
|
4887
4955
|
return html `
|
|
@@ -4893,45 +4961,35 @@
|
|
|
4893
4961
|
"is-invalid": this.hasFeedback && this.invalid
|
|
4894
4962
|
})}
|
|
4895
4963
|
type="checkbox"
|
|
4896
|
-
id=${this.
|
|
4964
|
+
id=${this._controlId}
|
|
4897
4965
|
aria-invalid=${this.invalid ? "true" : "false"}
|
|
4898
4966
|
name=${ifDefined(this.name)}
|
|
4899
|
-
value=${ifDefined(this.value)}
|
|
4900
|
-
?checked=${this.checked}
|
|
4901
4967
|
?indeterminate=${this.indeterminate}
|
|
4902
|
-
?disabled=${this.disabled}
|
|
4903
4968
|
?required=${this.required}
|
|
4904
4969
|
aria-disabled=${this.disabled ? "true" : "false"}
|
|
4905
4970
|
aria-checked=${this.checked ? "true" : "false"}
|
|
4906
|
-
@change=${this._handleChange}
|
|
4971
|
+
@change=${(e) => this._handleChange(e)}
|
|
4907
4972
|
@keydown=${this._handleKeyDown}
|
|
4908
4973
|
@invalid=${(e) => this._handleInvalid(e)}
|
|
4974
|
+
.checked=${live(this.checked)}
|
|
4975
|
+
.disabled=${this.disabled}
|
|
4976
|
+
.required=${this.required}
|
|
4977
|
+
@blur=${this._handleBlur}
|
|
4978
|
+
@focus=${this._handleFocus}
|
|
4909
4979
|
/>
|
|
4910
4980
|
</div>
|
|
4911
|
-
<label for="${this.
|
|
4981
|
+
<label for="${this._controlId}" class="form-check-label" id="${this._labelId}"><slot></slot></label>
|
|
4912
4982
|
</div>
|
|
4913
4983
|
`;
|
|
4914
4984
|
}
|
|
4915
4985
|
}
|
|
4916
|
-
SgdsCheckbox.styles = [...
|
|
4917
|
-
__decorate([
|
|
4918
|
-
query('input[type="checkbox"]')
|
|
4919
|
-
], SgdsCheckbox.prototype, "input", void 0);
|
|
4920
|
-
__decorate([
|
|
4921
|
-
property({ type: String, reflect: true })
|
|
4922
|
-
], SgdsCheckbox.prototype, "name", void 0);
|
|
4986
|
+
SgdsCheckbox.styles = [...FormControlElement.styles, css_248z$1];
|
|
4923
4987
|
__decorate([
|
|
4924
4988
|
property({ type: String, reflect: true })
|
|
4925
4989
|
], SgdsCheckbox.prototype, "value", void 0);
|
|
4926
|
-
__decorate([
|
|
4927
|
-
property({ type: Boolean, reflect: true })
|
|
4928
|
-
], SgdsCheckbox.prototype, "required", void 0);
|
|
4929
4990
|
__decorate([
|
|
4930
4991
|
property({ type: Boolean, reflect: true })
|
|
4931
4992
|
], SgdsCheckbox.prototype, "checked", void 0);
|
|
4932
|
-
__decorate([
|
|
4933
|
-
property({ type: Boolean, reflect: true })
|
|
4934
|
-
], SgdsCheckbox.prototype, "disabled", void 0);
|
|
4935
4993
|
__decorate([
|
|
4936
4994
|
property({ type: Boolean, reflect: true })
|
|
4937
4995
|
], SgdsCheckbox.prototype, "hasFeedback", void 0);
|
|
@@ -4940,10 +4998,13 @@
|
|
|
4940
4998
|
], SgdsCheckbox.prototype, "defaultChecked", void 0);
|
|
4941
4999
|
__decorate([
|
|
4942
5000
|
property({ type: Boolean, reflect: true })
|
|
4943
|
-
], SgdsCheckbox.prototype, "
|
|
5001
|
+
], SgdsCheckbox.prototype, "indeterminate", void 0);
|
|
4944
5002
|
__decorate([
|
|
4945
5003
|
property({ type: Boolean, reflect: true })
|
|
4946
|
-
], SgdsCheckbox.prototype, "
|
|
5004
|
+
], SgdsCheckbox.prototype, "required", void 0);
|
|
5005
|
+
__decorate([
|
|
5006
|
+
state()
|
|
5007
|
+
], SgdsCheckbox.prototype, "_isTouched", void 0);
|
|
4947
5008
|
__decorate([
|
|
4948
5009
|
watch("invalid", { waitUntilFirstUpdate: true })
|
|
4949
5010
|
], SgdsCheckbox.prototype, "_handleInvalidChange", null);
|
|
@@ -4951,21 +5012,20 @@
|
|
|
4951
5012
|
watch("disabled", { waitUntilFirstUpdate: true })
|
|
4952
5013
|
], SgdsCheckbox.prototype, "_handleDisabledChange", null);
|
|
4953
5014
|
__decorate([
|
|
4954
|
-
watch("
|
|
4955
|
-
], SgdsCheckbox.prototype, "
|
|
4956
|
-
|
|
4957
|
-
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)}`;
|
|
4958
|
-
|
|
4959
|
-
var css_248z$2 = 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}`;
|
|
5015
|
+
watch("_isTouched", { waitUntilFirstUpdate: true })
|
|
5016
|
+
], SgdsCheckbox.prototype, "_handleIsTouched", null);
|
|
4960
5017
|
|
|
4961
|
-
var css_248z
|
|
4962
|
-
|
|
4963
|
-
var css_248z = css`.form-text{color:var(--sgds-form-color-subtle);font-size:var(--sgds-font-size-1)}`;
|
|
5018
|
+
var css_248z = css`:host{--sgds-checkbox-group-gap:var(--sgds-spacer-2)}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)}.label-hint-container .form-label{color:var(--sgds-form-color);font-size:var(--sgds-font-size-2);font-weight:var(--sgds-font-weight-regular)}.checkbox-container{display:flex;flex-direction:column;gap:var(--sgds-form-gap-md)}`;
|
|
4964
5019
|
|
|
5020
|
+
/**
|
|
5021
|
+
* @summary CheckboxGroup is the container that group multiple checkboxes under a single question field.
|
|
5022
|
+
* It handles the display of validation feedback of its checkboxes children.
|
|
5023
|
+
*
|
|
5024
|
+
* @slot default - Pass in `sgds-checkbox` into the default slot
|
|
5025
|
+
*/
|
|
4965
5026
|
class SgdsCheckboxGroup extends SgdsElement {
|
|
4966
5027
|
constructor() {
|
|
4967
5028
|
super();
|
|
4968
|
-
/**@internal */
|
|
4969
5029
|
this.hasInvalidCheckbox = false;
|
|
4970
5030
|
/** The checkbox group's label */
|
|
4971
5031
|
this.label = "";
|
|
@@ -4977,6 +5037,7 @@
|
|
|
4977
5037
|
this.hintText = "";
|
|
4978
5038
|
this.addEventListener("sgds-validity-change", (e) => {
|
|
4979
5039
|
this.hasInvalidCheckbox = e.detail.invalid;
|
|
5040
|
+
this.validationMessage = e.detail.validationMessage;
|
|
4980
5041
|
});
|
|
4981
5042
|
}
|
|
4982
5043
|
_checkInvalidState() {
|
|
@@ -5004,7 +5065,7 @@
|
|
|
5004
5065
|
${this._renderHintText()}
|
|
5005
5066
|
</div>
|
|
5006
5067
|
<div class="checkbox-container">
|
|
5007
|
-
<slot
|
|
5068
|
+
<slot></slot>
|
|
5008
5069
|
</div>
|
|
5009
5070
|
${this.hasInvalidCheckbox && this.hasFeedback
|
|
5010
5071
|
? html `
|
|
@@ -5015,7 +5076,9 @@
|
|
|
5015
5076
|
fill="#B90000"
|
|
5016
5077
|
/>
|
|
5017
5078
|
</svg>
|
|
5018
|
-
<div id="checkbox-feedback" tabindex="0" class="invalid-feedback"
|
|
5079
|
+
<div id="checkbox-feedback" tabindex="0" class="invalid-feedback">
|
|
5080
|
+
${this.invalidFeedback ? this.invalidFeedback : this.validationMessage}
|
|
5081
|
+
</div>
|
|
5019
5082
|
</div>
|
|
5020
5083
|
`
|
|
5021
5084
|
: nothing}
|
|
@@ -5023,13 +5086,16 @@
|
|
|
5023
5086
|
`;
|
|
5024
5087
|
}
|
|
5025
5088
|
}
|
|
5026
|
-
SgdsCheckboxGroup.styles = [...SgdsElement.styles, css_248z$
|
|
5089
|
+
SgdsCheckboxGroup.styles = [...SgdsElement.styles, css_248z$6, css_248z$4, css_248z, css_248z$5];
|
|
5027
5090
|
__decorate([
|
|
5028
|
-
queryAssignedElements({
|
|
5091
|
+
queryAssignedElements({ flatten: true })
|
|
5029
5092
|
], SgdsCheckboxGroup.prototype, "checkboxes", void 0);
|
|
5030
5093
|
__decorate([
|
|
5031
5094
|
state()
|
|
5032
5095
|
], SgdsCheckboxGroup.prototype, "hasInvalidCheckbox", void 0);
|
|
5096
|
+
__decorate([
|
|
5097
|
+
state()
|
|
5098
|
+
], SgdsCheckboxGroup.prototype, "validationMessage", void 0);
|
|
5033
5099
|
__decorate([
|
|
5034
5100
|
property({ reflect: true })
|
|
5035
5101
|
], SgdsCheckboxGroup.prototype, "label", void 0);
|