@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
|
@@ -30,6 +30,270 @@
|
|
|
30
30
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
+
const appliedClassMixins = new WeakMap();
|
|
34
|
+
|
|
35
|
+
/** Vefify if the Mixin was previously applyed
|
|
36
|
+
* @private
|
|
37
|
+
* @param {function} mixin Mixin being applyed
|
|
38
|
+
* @param {object} superClass Class receiving the new mixin
|
|
39
|
+
* @returns {boolean}
|
|
40
|
+
*/
|
|
41
|
+
function wasMixinPreviouslyApplied(mixin, superClass) {
|
|
42
|
+
let klass = superClass;
|
|
43
|
+
while (klass) {
|
|
44
|
+
if (appliedClassMixins.get(klass) === mixin) {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
klass = Object.getPrototypeOf(klass);
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Apply each mixin in the chain to make sure they are not applied more than once to the final class.
|
|
53
|
+
* @export
|
|
54
|
+
* @param {function} mixin Mixin to be applyed
|
|
55
|
+
* @returns {object} Mixed class with mixin applied
|
|
56
|
+
*/
|
|
57
|
+
function dedupeMixin(mixin) {
|
|
58
|
+
return superClass => {
|
|
59
|
+
if (wasMixinPreviouslyApplied(mixin, superClass)) {
|
|
60
|
+
return superClass;
|
|
61
|
+
}
|
|
62
|
+
const mixedClass = mixin(superClass);
|
|
63
|
+
appliedClassMixins.set(mixedClass, mixin);
|
|
64
|
+
return mixedClass;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @license
|
|
70
|
+
* Copyright 2019 Google LLC
|
|
71
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
72
|
+
*/
|
|
73
|
+
const global$5 = window;
|
|
74
|
+
/**
|
|
75
|
+
* Whether the current browser supports `adoptedStyleSheets`.
|
|
76
|
+
*/
|
|
77
|
+
const supportsAdoptingStyleSheets$2 = global$5.ShadowRoot &&
|
|
78
|
+
(global$5.ShadyCSS === undefined || global$5.ShadyCSS.nativeShadow) &&
|
|
79
|
+
'adoptedStyleSheets' in Document.prototype &&
|
|
80
|
+
'replace' in CSSStyleSheet.prototype;
|
|
81
|
+
/**
|
|
82
|
+
* Applies the given styles to a `shadowRoot`. When Shadow DOM is
|
|
83
|
+
* available but `adoptedStyleSheets` is not, styles are appended to the
|
|
84
|
+
* `shadowRoot` to [mimic spec behavior](https://wicg.github.io/construct-stylesheets/#using-constructed-stylesheets).
|
|
85
|
+
* Note, when shimming is used, any styles that are subsequently placed into
|
|
86
|
+
* the shadowRoot should be placed *before* any shimmed adopted styles. This
|
|
87
|
+
* will match spec behavior that gives adopted sheets precedence over styles in
|
|
88
|
+
* shadowRoot.
|
|
89
|
+
*/
|
|
90
|
+
const adoptStyles$2 = (renderRoot, styles) => {
|
|
91
|
+
if (supportsAdoptingStyleSheets$2) {
|
|
92
|
+
renderRoot.adoptedStyleSheets = styles.map((s) => s instanceof CSSStyleSheet ? s : s.styleSheet);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
styles.forEach((s) => {
|
|
96
|
+
const style = document.createElement('style');
|
|
97
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
98
|
+
const nonce = global$5['litNonce'];
|
|
99
|
+
if (nonce !== undefined) {
|
|
100
|
+
style.setAttribute('nonce', nonce);
|
|
101
|
+
}
|
|
102
|
+
style.textContent = s.cssText;
|
|
103
|
+
renderRoot.appendChild(style);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @typedef {import('./types').RenderOptions} RenderOptions
|
|
110
|
+
* @typedef {import('./types').ScopedElementsMixin} ScopedElementsMixin
|
|
111
|
+
* @typedef {import('./types').ScopedElementsHost} ScopedElementsHost
|
|
112
|
+
* @typedef {import('./types').ScopedElementsMap} ScopedElementsMap
|
|
113
|
+
* @typedef {import('@lit/reactive-element').CSSResultOrNative} CSSResultOrNative
|
|
114
|
+
*/
|
|
115
|
+
|
|
116
|
+
// @ts-ignore
|
|
117
|
+
const supportsScopedRegistry = !!ShadowRoot.prototype.createElement;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* @template {import('./types').Constructor<HTMLElement>} T
|
|
121
|
+
* @param {T} superclass
|
|
122
|
+
* @return {T & import('./types').Constructor<ScopedElementsHost>}
|
|
123
|
+
*/
|
|
124
|
+
const ScopedElementsMixinImplementation = superclass =>
|
|
125
|
+
/** @type {ScopedElementsHost} */
|
|
126
|
+
class ScopedElementsHost extends superclass {
|
|
127
|
+
/**
|
|
128
|
+
* Obtains the scoped elements definitions map if specified.
|
|
129
|
+
*
|
|
130
|
+
* @returns {ScopedElementsMap}
|
|
131
|
+
*/
|
|
132
|
+
static get scopedElements() {
|
|
133
|
+
return {};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Obtains the ShadowRoot options.
|
|
138
|
+
*
|
|
139
|
+
* @type {ShadowRootInit}
|
|
140
|
+
*/
|
|
141
|
+
static get shadowRootOptions() {
|
|
142
|
+
return this.__shadowRootOptions;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Set the shadowRoot options.
|
|
147
|
+
*
|
|
148
|
+
* @param {ShadowRootInit} value
|
|
149
|
+
*/
|
|
150
|
+
static set shadowRootOptions(value) {
|
|
151
|
+
this.__shadowRootOptions = value;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Obtains the element styles.
|
|
156
|
+
*
|
|
157
|
+
* @returns {CSSResultOrNative[]}
|
|
158
|
+
*/
|
|
159
|
+
static get elementStyles() {
|
|
160
|
+
return this.__elementStyles;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
static set elementStyles(styles) {
|
|
164
|
+
this.__elementStyles = styles;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// either TS or ESLint will complain here
|
|
168
|
+
// eslint-disable-next-line no-unused-vars
|
|
169
|
+
constructor(..._args) {
|
|
170
|
+
super();
|
|
171
|
+
/** @type {RenderOptions} */
|
|
172
|
+
this.renderOptions = this.renderOptions || undefined;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Obtains the CustomElementRegistry associated to the ShadowRoot.
|
|
177
|
+
*
|
|
178
|
+
* @returns {CustomElementRegistry}
|
|
179
|
+
*/
|
|
180
|
+
get registry() {
|
|
181
|
+
// @ts-ignore
|
|
182
|
+
return this.constructor.__registry;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Set the CustomElementRegistry associated to the ShadowRoot
|
|
187
|
+
*
|
|
188
|
+
* @param {CustomElementRegistry} registry
|
|
189
|
+
*/
|
|
190
|
+
set registry(registry) {
|
|
191
|
+
// @ts-ignore
|
|
192
|
+
this.constructor.__registry = registry;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
createRenderRoot() {
|
|
196
|
+
const { scopedElements, shadowRootOptions, elementStyles } =
|
|
197
|
+
/** @type {typeof ScopedElementsHost} */ (this.constructor);
|
|
198
|
+
|
|
199
|
+
const shouldCreateRegistry =
|
|
200
|
+
!this.registry ||
|
|
201
|
+
// @ts-ignore
|
|
202
|
+
(this.registry === this.constructor.__registry &&
|
|
203
|
+
!Object.prototype.hasOwnProperty.call(this.constructor, '__registry'));
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Create a new registry if:
|
|
207
|
+
* - the registry is not defined
|
|
208
|
+
* - this class doesn't have its own registry *AND* has no shared registry
|
|
209
|
+
*/
|
|
210
|
+
if (shouldCreateRegistry) {
|
|
211
|
+
this.registry = supportsScopedRegistry ? new CustomElementRegistry() : customElements;
|
|
212
|
+
for (const [tagName, klass] of Object.entries(scopedElements)) {
|
|
213
|
+
this.defineScopedElement(tagName, klass);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/** @type {ShadowRootInit} */
|
|
218
|
+
const options = {
|
|
219
|
+
mode: 'open',
|
|
220
|
+
...shadowRootOptions,
|
|
221
|
+
customElements: this.registry,
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
const createdRoot = this.attachShadow(options);
|
|
225
|
+
if (supportsScopedRegistry) {
|
|
226
|
+
this.renderOptions.creationScope = createdRoot;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (createdRoot instanceof ShadowRoot) {
|
|
230
|
+
adoptStyles$2(createdRoot, elementStyles);
|
|
231
|
+
this.renderOptions.renderBefore = this.renderOptions.renderBefore || createdRoot.firstChild;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return createdRoot;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
createScopedElement(tagName) {
|
|
238
|
+
const root = supportsScopedRegistry ? this.shadowRoot : document;
|
|
239
|
+
// @ts-ignore polyfill to support createElement on shadowRoot is loaded
|
|
240
|
+
return root.createElement(tagName);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Defines a scoped element.
|
|
245
|
+
*
|
|
246
|
+
* @param {string} tagName
|
|
247
|
+
* @param {typeof HTMLElement} klass
|
|
248
|
+
*/
|
|
249
|
+
defineScopedElement(tagName, klass) {
|
|
250
|
+
const registeredClass = this.registry.get(tagName);
|
|
251
|
+
if (registeredClass && supportsScopedRegistry === false && registeredClass !== klass) {
|
|
252
|
+
// eslint-disable-next-line no-console
|
|
253
|
+
console.error(
|
|
254
|
+
[
|
|
255
|
+
`You are trying to re-register the "${tagName}" custom element with a different class via ScopedElementsMixin.`,
|
|
256
|
+
'This is only possible with a CustomElementRegistry.',
|
|
257
|
+
'Your browser does not support this feature so you will need to load a polyfill for it.',
|
|
258
|
+
'Load "@webcomponents/scoped-custom-element-registry" before you register ANY web component to the global customElements registry.',
|
|
259
|
+
'e.g. add "<script src="/node_modules/@webcomponents/scoped-custom-element-registry/scoped-custom-element-registry.min.js"></script>" as your first script tag.',
|
|
260
|
+
'For more details you can visit https://open-wc.org/docs/development/scoped-elements/',
|
|
261
|
+
].join('\n'),
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
if (!registeredClass) {
|
|
265
|
+
return this.registry.define(tagName, klass);
|
|
266
|
+
}
|
|
267
|
+
return this.registry.get(tagName);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* @deprecated use the native el.tagName instead
|
|
272
|
+
*
|
|
273
|
+
* @param {string} tagName
|
|
274
|
+
* @returns {string} the tag name
|
|
275
|
+
*/
|
|
276
|
+
// eslint-disable-next-line class-methods-use-this
|
|
277
|
+
getScopedTagName(tagName) {
|
|
278
|
+
// @ts-ignore
|
|
279
|
+
return this.constructor.getScopedTagName(tagName);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* @deprecated use the native el.tagName instead
|
|
284
|
+
*
|
|
285
|
+
* @param {string} tagName
|
|
286
|
+
* @returns {string} the tag name
|
|
287
|
+
*/
|
|
288
|
+
// eslint-disable-next-line class-methods-use-this
|
|
289
|
+
static getScopedTagName(tagName) {
|
|
290
|
+
// @ts-ignore
|
|
291
|
+
return this.__registry.get(tagName) ? tagName : undefined;
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
const ScopedElementsMixin = dedupeMixin(ScopedElementsMixinImplementation);
|
|
296
|
+
|
|
33
297
|
/**
|
|
34
298
|
* @license
|
|
35
299
|
* Copyright 2019 Google LLC
|
|
@@ -144,7 +408,7 @@
|
|
|
144
408
|
const { is: is$1, defineProperty: defineProperty$1, getOwnPropertyDescriptor: getOwnPropertyDescriptor$1, getOwnPropertyNames: getOwnPropertyNames$1, getOwnPropertySymbols: getOwnPropertySymbols$1, getPrototypeOf: getPrototypeOf$1, } = Object;
|
|
145
409
|
// Lets a minifier replace globalThis references with a minified name
|
|
146
410
|
const global$3 = globalThis;
|
|
147
|
-
let issueWarning$
|
|
411
|
+
let issueWarning$4;
|
|
148
412
|
const trustedTypes$2 = global$3
|
|
149
413
|
.trustedTypes;
|
|
150
414
|
// Temporary workaround for https://crbug.com/993268
|
|
@@ -162,17 +426,17 @@
|
|
|
162
426
|
const issuedWarnings = (global$3.litIssuedWarnings ??=
|
|
163
427
|
new Set());
|
|
164
428
|
// Issue a warning, if we haven't already.
|
|
165
|
-
issueWarning$
|
|
429
|
+
issueWarning$4 = (code, warning) => {
|
|
166
430
|
warning += ` See https://lit.dev/msg/${code} for more information.`;
|
|
167
431
|
if (!issuedWarnings.has(warning)) {
|
|
168
432
|
console.warn(warning);
|
|
169
433
|
issuedWarnings.add(warning);
|
|
170
434
|
}
|
|
171
435
|
};
|
|
172
|
-
issueWarning$
|
|
436
|
+
issueWarning$4('dev-mode', `Lit is in dev mode. Not recommended for production!`);
|
|
173
437
|
// Issue polyfill support warning.
|
|
174
438
|
if (global$3.ShadyDOM?.inUse && polyfillSupport$3 === undefined) {
|
|
175
|
-
issueWarning$
|
|
439
|
+
issueWarning$4('polyfill-support-missing', `Shadow DOM is being polyfilled via \`ShadyDOM\` but ` +
|
|
176
440
|
`the \`polyfill-support\` module has not been loaded.`);
|
|
177
441
|
}
|
|
178
442
|
}
|
|
@@ -413,7 +677,7 @@
|
|
|
413
677
|
`but it's actually declared as a value on the prototype. ` +
|
|
414
678
|
`Usually this is due to using @property or @state on a method.`);
|
|
415
679
|
}
|
|
416
|
-
issueWarning$
|
|
680
|
+
issueWarning$4('reactive-property-without-getter', `Field ${JSON.stringify(String(name))} on ` +
|
|
417
681
|
`${this.name} was declared as a reactive property ` +
|
|
418
682
|
`but it does not have a getter. This will be an error in a ` +
|
|
419
683
|
`future version of Lit.`);
|
|
@@ -525,11 +789,11 @@
|
|
|
525
789
|
this.elementStyles = this.finalizeStyles(this.styles);
|
|
526
790
|
{
|
|
527
791
|
if (this.hasOwnProperty('createProperty')) {
|
|
528
|
-
issueWarning$
|
|
792
|
+
issueWarning$4('no-override-create-property', 'Overriding ReactiveElement.createProperty() is deprecated. ' +
|
|
529
793
|
'The override will not be called with standard decorators');
|
|
530
794
|
}
|
|
531
795
|
if (this.hasOwnProperty('getPropertyDescriptor')) {
|
|
532
|
-
issueWarning$
|
|
796
|
+
issueWarning$4('no-override-get-property-descriptor', 'Overriding ReactiveElement.getPropertyDescriptor() is deprecated. ' +
|
|
533
797
|
'The override will not be called with standard decorators');
|
|
534
798
|
}
|
|
535
799
|
}
|
|
@@ -737,7 +1001,7 @@
|
|
|
737
1001
|
const attrValue = converter.toAttribute(value, options.type);
|
|
738
1002
|
if (this.constructor.enabledWarnings.includes('migration') &&
|
|
739
1003
|
attrValue === undefined) {
|
|
740
|
-
issueWarning$
|
|
1004
|
+
issueWarning$4('undefined-attribute-value', `The attribute value for the ${name} property is ` +
|
|
741
1005
|
`undefined on element ${this.localName}. The attribute will be ` +
|
|
742
1006
|
`removed, but in the previous version of \`ReactiveElement\`, ` +
|
|
743
1007
|
`the attribute would not have changed.`);
|
|
@@ -803,7 +1067,7 @@
|
|
|
803
1067
|
// If we have a property key, perform property update steps.
|
|
804
1068
|
if (name !== undefined) {
|
|
805
1069
|
if (name instanceof Event) {
|
|
806
|
-
issueWarning$
|
|
1070
|
+
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
1071
|
}
|
|
808
1072
|
options ??= this.constructor.getPropertyOptions(name);
|
|
809
1073
|
const hasChanged = options.hasChanged ?? notEqual$1;
|
|
@@ -885,7 +1149,7 @@
|
|
|
885
1149
|
if (this.constructor.enabledWarnings.includes('async-perform-update') &&
|
|
886
1150
|
typeof result?.then ===
|
|
887
1151
|
'function') {
|
|
888
|
-
issueWarning$
|
|
1152
|
+
issueWarning$4('async-perform-update', `Element ${this.localName} returned a Promise from performUpdate(). ` +
|
|
889
1153
|
`This behavior is deprecated and will be removed in a future ` +
|
|
890
1154
|
`version of ReactiveElement.`);
|
|
891
1155
|
}
|
|
@@ -1021,7 +1285,7 @@
|
|
|
1021
1285
|
this.updated(changedProperties);
|
|
1022
1286
|
if (this.isUpdatePending &&
|
|
1023
1287
|
this.constructor.enabledWarnings.includes('change-in-update')) {
|
|
1024
|
-
issueWarning$
|
|
1288
|
+
issueWarning$4('change-in-update', `Element ${this.localName} scheduled an update ` +
|
|
1025
1289
|
`(generally because a property was set) ` +
|
|
1026
1290
|
`after an update completed, causing a new update to be scheduled. ` +
|
|
1027
1291
|
`This is inefficient and should be avoided unless the next update ` +
|
|
@@ -1188,7 +1452,7 @@
|
|
|
1188
1452
|
// This line will be used in regexes to search for ReactiveElement usage.
|
|
1189
1453
|
(global$3.reactiveElementVersions ??= []).push('2.0.4');
|
|
1190
1454
|
if (global$3.reactiveElementVersions.length > 1) {
|
|
1191
|
-
issueWarning$
|
|
1455
|
+
issueWarning$4('multiple-versions', `Multiple versions of Lit loaded. Loading multiple versions ` +
|
|
1192
1456
|
`is not recommended.`);
|
|
1193
1457
|
}
|
|
1194
1458
|
|
|
@@ -1197,344 +1461,70 @@
|
|
|
1197
1461
|
* Copyright 2017 Google LLC
|
|
1198
1462
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
1199
1463
|
*/
|
|
1200
|
-
|
|
1464
|
+
// Allows minifiers to rename references to globalThis
|
|
1465
|
+
const global$2 = globalThis;
|
|
1466
|
+
/**
|
|
1467
|
+
* Useful for visualizing and logging insights into what the Lit template system is doing.
|
|
1468
|
+
*
|
|
1469
|
+
* Compiled out of prod mode builds.
|
|
1470
|
+
*/
|
|
1471
|
+
const debugLogEvent$1 = (event) => {
|
|
1472
|
+
const shouldEmit = global$2
|
|
1473
|
+
.emitLitDebugLogEvents;
|
|
1474
|
+
if (!shouldEmit) {
|
|
1475
|
+
return;
|
|
1476
|
+
}
|
|
1477
|
+
global$2.dispatchEvent(new CustomEvent('lit-debug', {
|
|
1478
|
+
detail: event,
|
|
1479
|
+
}));
|
|
1480
|
+
}
|
|
1481
|
+
;
|
|
1482
|
+
// Used for connecting beginRender and endRender events when there are nested
|
|
1483
|
+
// renders when errors are thrown preventing an endRender event from being
|
|
1484
|
+
// called.
|
|
1485
|
+
let debugLogRenderId = 0;
|
|
1486
|
+
let issueWarning$3;
|
|
1201
1487
|
{
|
|
1202
|
-
|
|
1203
|
-
// are loaded.
|
|
1204
|
-
const issuedWarnings = (globalThis.litIssuedWarnings ??= new Set());
|
|
1488
|
+
global$2.litIssuedWarnings ??= new Set();
|
|
1205
1489
|
// Issue a warning, if we haven't already.
|
|
1206
|
-
issueWarning$
|
|
1207
|
-
warning +=
|
|
1208
|
-
|
|
1490
|
+
issueWarning$3 = (code, warning) => {
|
|
1491
|
+
warning += code
|
|
1492
|
+
? ` See https://lit.dev/msg/${code} for more information.`
|
|
1493
|
+
: '';
|
|
1494
|
+
if (!global$2.litIssuedWarnings.has(warning)) {
|
|
1209
1495
|
console.warn(warning);
|
|
1210
|
-
|
|
1496
|
+
global$2.litIssuedWarnings.add(warning);
|
|
1211
1497
|
}
|
|
1212
1498
|
};
|
|
1499
|
+
issueWarning$3('dev-mode', `Lit is in dev mode. Not recommended for production!`);
|
|
1213
1500
|
}
|
|
1214
|
-
const
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
// define in createProperty() with the original descriptor. We don't do this
|
|
1220
|
-
// for fields, which don't have a descriptor, because this could overwrite
|
|
1221
|
-
// descriptor defined by other decorators.
|
|
1222
|
-
return hasOwnProperty
|
|
1223
|
-
? Object.getOwnPropertyDescriptor(proto, name)
|
|
1224
|
-
: undefined;
|
|
1225
|
-
};
|
|
1226
|
-
// This is duplicated from a similar variable in reactive-element.ts, but
|
|
1227
|
-
// actually makes sense to have this default defined with the decorator, so
|
|
1228
|
-
// that different decorators could have different defaults.
|
|
1229
|
-
const defaultPropertyDeclaration$1 = {
|
|
1230
|
-
attribute: true,
|
|
1231
|
-
type: String,
|
|
1232
|
-
converter: defaultConverter$1,
|
|
1233
|
-
reflect: false,
|
|
1234
|
-
hasChanged: notEqual$1,
|
|
1235
|
-
};
|
|
1501
|
+
const wrap = global$2.ShadyDOM?.inUse &&
|
|
1502
|
+
global$2.ShadyDOM?.noPatch === true
|
|
1503
|
+
? global$2.ShadyDOM.wrap
|
|
1504
|
+
: (node) => node;
|
|
1505
|
+
const trustedTypes$1 = global$2.trustedTypes;
|
|
1236
1506
|
/**
|
|
1237
|
-
*
|
|
1238
|
-
*
|
|
1507
|
+
* Our TrustedTypePolicy for HTML which is declared using the html template
|
|
1508
|
+
* tag function.
|
|
1509
|
+
*
|
|
1510
|
+
* That HTML is a developer-authored constant, and is parsed with innerHTML
|
|
1511
|
+
* before any untrusted expressions have been mixed in. Therefor it is
|
|
1512
|
+
* considered safe by construction.
|
|
1239
1513
|
*/
|
|
1240
|
-
const
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
}
|
|
1253
|
-
properties.set(context.name, options);
|
|
1254
|
-
if (kind === 'accessor') {
|
|
1255
|
-
// Standard decorators cannot dynamically modify the class, so we can't
|
|
1256
|
-
// replace a field with accessors. The user must use the new `accessor`
|
|
1257
|
-
// keyword instead.
|
|
1258
|
-
const { name } = context;
|
|
1259
|
-
return {
|
|
1260
|
-
set(v) {
|
|
1261
|
-
const oldValue = target.get.call(this);
|
|
1262
|
-
target.set.call(this, v);
|
|
1263
|
-
this.requestUpdate(name, oldValue, options);
|
|
1264
|
-
},
|
|
1265
|
-
init(v) {
|
|
1266
|
-
if (v !== undefined) {
|
|
1267
|
-
this._$changeProperty(name, undefined, options);
|
|
1268
|
-
}
|
|
1269
|
-
return v;
|
|
1270
|
-
},
|
|
1271
|
-
};
|
|
1272
|
-
}
|
|
1273
|
-
else if (kind === 'setter') {
|
|
1274
|
-
const { name } = context;
|
|
1275
|
-
return function (value) {
|
|
1276
|
-
const oldValue = this[name];
|
|
1277
|
-
target.call(this, value);
|
|
1278
|
-
this.requestUpdate(name, oldValue, options);
|
|
1279
|
-
};
|
|
1514
|
+
const policy = trustedTypes$1
|
|
1515
|
+
? trustedTypes$1.createPolicy('lit-html', {
|
|
1516
|
+
createHTML: (s) => s,
|
|
1517
|
+
})
|
|
1518
|
+
: undefined;
|
|
1519
|
+
const identityFunction = (value) => value;
|
|
1520
|
+
const noopSanitizer = (_node, _name, _type) => identityFunction;
|
|
1521
|
+
/** Sets the global sanitizer factory. */
|
|
1522
|
+
const setSanitizer = (newSanitizer) => {
|
|
1523
|
+
if (sanitizerFactoryInternal !== noopSanitizer) {
|
|
1524
|
+
throw new Error(`Attempted to overwrite existing lit-html security policy.` +
|
|
1525
|
+
` setSanitizeDOMValueFactory should be called at most once.`);
|
|
1280
1526
|
}
|
|
1281
|
-
|
|
1282
|
-
};
|
|
1283
|
-
/**
|
|
1284
|
-
* A class field or accessor decorator which creates a reactive property that
|
|
1285
|
-
* reflects a corresponding attribute value. When a decorated property is set
|
|
1286
|
-
* the element will update and render. A {@linkcode PropertyDeclaration} may
|
|
1287
|
-
* optionally be supplied to configure property features.
|
|
1288
|
-
*
|
|
1289
|
-
* This decorator should only be used for public fields. As public fields,
|
|
1290
|
-
* properties should be considered as primarily settable by element users,
|
|
1291
|
-
* either via attribute or the property itself.
|
|
1292
|
-
*
|
|
1293
|
-
* Generally, properties that are changed by the element should be private or
|
|
1294
|
-
* protected fields and should use the {@linkcode state} decorator.
|
|
1295
|
-
*
|
|
1296
|
-
* However, sometimes element code does need to set a public property. This
|
|
1297
|
-
* should typically only be done in response to user interaction, and an event
|
|
1298
|
-
* should be fired informing the user; for example, a checkbox sets its
|
|
1299
|
-
* `checked` property when clicked and fires a `changed` event. Mutating public
|
|
1300
|
-
* properties should typically not be done for non-primitive (object or array)
|
|
1301
|
-
* properties. In other cases when an element needs to manage state, a private
|
|
1302
|
-
* property decorated via the {@linkcode state} decorator should be used. When
|
|
1303
|
-
* needed, state properties can be initialized via public properties to
|
|
1304
|
-
* facilitate complex interactions.
|
|
1305
|
-
*
|
|
1306
|
-
* ```ts
|
|
1307
|
-
* class MyElement {
|
|
1308
|
-
* @property({ type: Boolean })
|
|
1309
|
-
* clicked = false;
|
|
1310
|
-
* }
|
|
1311
|
-
* ```
|
|
1312
|
-
* @category Decorator
|
|
1313
|
-
* @ExportDecoratedItems
|
|
1314
|
-
*/
|
|
1315
|
-
function property(options) {
|
|
1316
|
-
return (protoOrTarget, nameOrContext
|
|
1317
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1318
|
-
) => {
|
|
1319
|
-
return (typeof nameOrContext === 'object'
|
|
1320
|
-
? standardProperty(options, protoOrTarget, nameOrContext)
|
|
1321
|
-
: legacyProperty(options, protoOrTarget, nameOrContext));
|
|
1322
|
-
};
|
|
1323
|
-
}
|
|
1324
|
-
|
|
1325
|
-
/**
|
|
1326
|
-
* @license
|
|
1327
|
-
* Copyright 2017 Google LLC
|
|
1328
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
1329
|
-
*/
|
|
1330
|
-
/**
|
|
1331
|
-
* Wraps up a few best practices when returning a property descriptor from a
|
|
1332
|
-
* decorator.
|
|
1333
|
-
*
|
|
1334
|
-
* Marks the defined property as configurable, and enumerable, and handles
|
|
1335
|
-
* the case where we have a busted Reflect.decorate zombiefill (e.g. in Angular
|
|
1336
|
-
* apps).
|
|
1337
|
-
*
|
|
1338
|
-
* @internal
|
|
1339
|
-
*/
|
|
1340
|
-
const desc = (obj, name, descriptor) => {
|
|
1341
|
-
// For backwards compatibility, we keep them configurable and enumerable.
|
|
1342
|
-
descriptor.configurable = true;
|
|
1343
|
-
descriptor.enumerable = true;
|
|
1344
|
-
if (
|
|
1345
|
-
// We check for Reflect.decorate each time, in case the zombiefill
|
|
1346
|
-
// is applied via lazy loading some Angular code.
|
|
1347
|
-
Reflect.decorate &&
|
|
1348
|
-
typeof name !== 'object') {
|
|
1349
|
-
// If we're called as a legacy decorator, and Reflect.decorate is present
|
|
1350
|
-
// then we have no guarantees that the returned descriptor will be
|
|
1351
|
-
// defined on the class, so we must apply it directly ourselves.
|
|
1352
|
-
Object.defineProperty(obj, name, descriptor);
|
|
1353
|
-
}
|
|
1354
|
-
return descriptor;
|
|
1355
|
-
};
|
|
1356
|
-
|
|
1357
|
-
/**
|
|
1358
|
-
* @license
|
|
1359
|
-
* Copyright 2017 Google LLC
|
|
1360
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
1361
|
-
*/
|
|
1362
|
-
let issueWarning$3;
|
|
1363
|
-
{
|
|
1364
|
-
// Ensure warnings are issued only 1x, even if multiple versions of Lit
|
|
1365
|
-
// are loaded.
|
|
1366
|
-
const issuedWarnings = (globalThis.litIssuedWarnings ??= new Set());
|
|
1367
|
-
// Issue a warning, if we haven't already.
|
|
1368
|
-
issueWarning$3 = (code, warning) => {
|
|
1369
|
-
warning += code
|
|
1370
|
-
? ` See https://lit.dev/msg/${code} for more information.`
|
|
1371
|
-
: '';
|
|
1372
|
-
if (!issuedWarnings.has(warning)) {
|
|
1373
|
-
console.warn(warning);
|
|
1374
|
-
issuedWarnings.add(warning);
|
|
1375
|
-
}
|
|
1376
|
-
};
|
|
1377
|
-
}
|
|
1378
|
-
/**
|
|
1379
|
-
* A property decorator that converts a class property into a getter that
|
|
1380
|
-
* executes a querySelector on the element's renderRoot.
|
|
1381
|
-
*
|
|
1382
|
-
* @param selector A DOMString containing one or more selectors to match.
|
|
1383
|
-
* @param cache An optional boolean which when true performs the DOM query only
|
|
1384
|
-
* once and caches the result.
|
|
1385
|
-
*
|
|
1386
|
-
* See: https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector
|
|
1387
|
-
*
|
|
1388
|
-
* ```ts
|
|
1389
|
-
* class MyElement {
|
|
1390
|
-
* @query('#first')
|
|
1391
|
-
* first: HTMLDivElement;
|
|
1392
|
-
*
|
|
1393
|
-
* render() {
|
|
1394
|
-
* return html`
|
|
1395
|
-
* <div id="first"></div>
|
|
1396
|
-
* <div id="second"></div>
|
|
1397
|
-
* `;
|
|
1398
|
-
* }
|
|
1399
|
-
* }
|
|
1400
|
-
* ```
|
|
1401
|
-
* @category Decorator
|
|
1402
|
-
*/
|
|
1403
|
-
function query(selector, cache) {
|
|
1404
|
-
return ((protoOrTarget, nameOrContext, descriptor) => {
|
|
1405
|
-
const doQuery = (el) => {
|
|
1406
|
-
const result = (el.renderRoot?.querySelector(selector) ?? null);
|
|
1407
|
-
if (result === null && cache && !el.hasUpdated) {
|
|
1408
|
-
const name = typeof nameOrContext === 'object'
|
|
1409
|
-
? nameOrContext.name
|
|
1410
|
-
: nameOrContext;
|
|
1411
|
-
issueWarning$3('', `@query'd field ${JSON.stringify(String(name))} with the 'cache' ` +
|
|
1412
|
-
`flag set for selector '${selector}' has been accessed before ` +
|
|
1413
|
-
`the first update and returned null. This is expected if the ` +
|
|
1414
|
-
`renderRoot tree has not been provided beforehand (e.g. via ` +
|
|
1415
|
-
`Declarative Shadow DOM). Therefore the value hasn't been cached.`);
|
|
1416
|
-
}
|
|
1417
|
-
// TODO: if we want to allow users to assert that the query will never
|
|
1418
|
-
// return null, we need a new option and to throw here if the result
|
|
1419
|
-
// is null.
|
|
1420
|
-
return result;
|
|
1421
|
-
};
|
|
1422
|
-
if (cache) {
|
|
1423
|
-
// Accessors to wrap from either:
|
|
1424
|
-
// 1. The decorator target, in the case of standard decorators
|
|
1425
|
-
// 2. The property descriptor, in the case of experimental decorators
|
|
1426
|
-
// on auto-accessors.
|
|
1427
|
-
// 3. Functions that access our own cache-key property on the instance,
|
|
1428
|
-
// in the case of experimental decorators on fields.
|
|
1429
|
-
const { get, set } = typeof nameOrContext === 'object'
|
|
1430
|
-
? protoOrTarget
|
|
1431
|
-
: descriptor ??
|
|
1432
|
-
(() => {
|
|
1433
|
-
const key = Symbol(`${String(nameOrContext)} (@query() cache)`)
|
|
1434
|
-
;
|
|
1435
|
-
return {
|
|
1436
|
-
get() {
|
|
1437
|
-
return this[key];
|
|
1438
|
-
},
|
|
1439
|
-
set(v) {
|
|
1440
|
-
this[key] = v;
|
|
1441
|
-
},
|
|
1442
|
-
};
|
|
1443
|
-
})();
|
|
1444
|
-
return desc(protoOrTarget, nameOrContext, {
|
|
1445
|
-
get() {
|
|
1446
|
-
let result = get.call(this);
|
|
1447
|
-
if (result === undefined) {
|
|
1448
|
-
result = doQuery(this);
|
|
1449
|
-
if (result !== null || this.hasUpdated) {
|
|
1450
|
-
set.call(this, result);
|
|
1451
|
-
}
|
|
1452
|
-
}
|
|
1453
|
-
return result;
|
|
1454
|
-
},
|
|
1455
|
-
});
|
|
1456
|
-
}
|
|
1457
|
-
else {
|
|
1458
|
-
// This object works as the return type for both standard and
|
|
1459
|
-
// experimental decorators.
|
|
1460
|
-
return desc(protoOrTarget, nameOrContext, {
|
|
1461
|
-
get() {
|
|
1462
|
-
return doQuery(this);
|
|
1463
|
-
},
|
|
1464
|
-
});
|
|
1465
|
-
}
|
|
1466
|
-
});
|
|
1467
|
-
}
|
|
1468
|
-
|
|
1469
|
-
/**
|
|
1470
|
-
* @license
|
|
1471
|
-
* Copyright 2017 Google LLC
|
|
1472
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
1473
|
-
*/
|
|
1474
|
-
// Allows minifiers to rename references to globalThis
|
|
1475
|
-
const global$2 = globalThis;
|
|
1476
|
-
/**
|
|
1477
|
-
* Useful for visualizing and logging insights into what the Lit template system is doing.
|
|
1478
|
-
*
|
|
1479
|
-
* Compiled out of prod mode builds.
|
|
1480
|
-
*/
|
|
1481
|
-
const debugLogEvent$1 = (event) => {
|
|
1482
|
-
const shouldEmit = global$2
|
|
1483
|
-
.emitLitDebugLogEvents;
|
|
1484
|
-
if (!shouldEmit) {
|
|
1485
|
-
return;
|
|
1486
|
-
}
|
|
1487
|
-
global$2.dispatchEvent(new CustomEvent('lit-debug', {
|
|
1488
|
-
detail: event,
|
|
1489
|
-
}));
|
|
1490
|
-
}
|
|
1491
|
-
;
|
|
1492
|
-
// Used for connecting beginRender and endRender events when there are nested
|
|
1493
|
-
// renders when errors are thrown preventing an endRender event from being
|
|
1494
|
-
// called.
|
|
1495
|
-
let debugLogRenderId = 0;
|
|
1496
|
-
let issueWarning$2;
|
|
1497
|
-
{
|
|
1498
|
-
global$2.litIssuedWarnings ??= new Set();
|
|
1499
|
-
// Issue a warning, if we haven't already.
|
|
1500
|
-
issueWarning$2 = (code, warning) => {
|
|
1501
|
-
warning += code
|
|
1502
|
-
? ` See https://lit.dev/msg/${code} for more information.`
|
|
1503
|
-
: '';
|
|
1504
|
-
if (!global$2.litIssuedWarnings.has(warning)) {
|
|
1505
|
-
console.warn(warning);
|
|
1506
|
-
global$2.litIssuedWarnings.add(warning);
|
|
1507
|
-
}
|
|
1508
|
-
};
|
|
1509
|
-
issueWarning$2('dev-mode', `Lit is in dev mode. Not recommended for production!`);
|
|
1510
|
-
}
|
|
1511
|
-
const wrap = global$2.ShadyDOM?.inUse &&
|
|
1512
|
-
global$2.ShadyDOM?.noPatch === true
|
|
1513
|
-
? global$2.ShadyDOM.wrap
|
|
1514
|
-
: (node) => node;
|
|
1515
|
-
const trustedTypes$1 = global$2.trustedTypes;
|
|
1516
|
-
/**
|
|
1517
|
-
* Our TrustedTypePolicy for HTML which is declared using the html template
|
|
1518
|
-
* tag function.
|
|
1519
|
-
*
|
|
1520
|
-
* That HTML is a developer-authored constant, and is parsed with innerHTML
|
|
1521
|
-
* before any untrusted expressions have been mixed in. Therefor it is
|
|
1522
|
-
* considered safe by construction.
|
|
1523
|
-
*/
|
|
1524
|
-
const policy = trustedTypes$1
|
|
1525
|
-
? trustedTypes$1.createPolicy('lit-html', {
|
|
1526
|
-
createHTML: (s) => s,
|
|
1527
|
-
})
|
|
1528
|
-
: undefined;
|
|
1529
|
-
const identityFunction = (value) => value;
|
|
1530
|
-
const noopSanitizer = (_node, _name, _type) => identityFunction;
|
|
1531
|
-
/** Sets the global sanitizer factory. */
|
|
1532
|
-
const setSanitizer = (newSanitizer) => {
|
|
1533
|
-
if (sanitizerFactoryInternal !== noopSanitizer) {
|
|
1534
|
-
throw new Error(`Attempted to overwrite existing lit-html security policy.` +
|
|
1535
|
-
` setSanitizeDOMValueFactory should be called at most once.`);
|
|
1536
|
-
}
|
|
1537
|
-
sanitizerFactoryInternal = newSanitizer;
|
|
1527
|
+
sanitizerFactoryInternal = newSanitizer;
|
|
1538
1528
|
};
|
|
1539
1529
|
/**
|
|
1540
1530
|
* Only used in internal tests, not a part of the public API.
|
|
@@ -1657,7 +1647,7 @@
|
|
|
1657
1647
|
// handle. Instead we know that static values must have the field
|
|
1658
1648
|
// `_$litStatic$`.
|
|
1659
1649
|
if (values.some((val) => val?.['_$litStatic$'])) {
|
|
1660
|
-
issueWarning$
|
|
1650
|
+
issueWarning$3('', `Static values 'literal' or 'unsafeStatic' cannot be used as values to non-static templates.\n` +
|
|
1661
1651
|
`Please use the static 'html' tag function. See https://lit.dev/docs/templates/expressions/#static-expressions`);
|
|
1662
1652
|
}
|
|
1663
1653
|
}
|
|
@@ -1937,7 +1927,7 @@
|
|
|
1937
1927
|
throw new Error(m);
|
|
1938
1928
|
}
|
|
1939
1929
|
else
|
|
1940
|
-
issueWarning$
|
|
1930
|
+
issueWarning$3('', m);
|
|
1941
1931
|
}
|
|
1942
1932
|
}
|
|
1943
1933
|
// TODO (justinfagnani): for attempted dynamic tag names, we don't
|
|
@@ -2783,7 +2773,7 @@
|
|
|
2783
2773
|
// This line will be used in regexes to search for lit-html usage.
|
|
2784
2774
|
(global$2.litHtmlVersions ??= []).push('3.2.0');
|
|
2785
2775
|
if (global$2.litHtmlVersions.length > 1) {
|
|
2786
|
-
issueWarning$
|
|
2776
|
+
issueWarning$3('multiple-versions', `Multiple versions of Lit loaded. ` +
|
|
2787
2777
|
`Loading multiple versions is not recommended.`);
|
|
2788
2778
|
}
|
|
2789
2779
|
/**
|
|
@@ -2862,681 +2852,267 @@
|
|
|
2862
2852
|
|
|
2863
2853
|
/**
|
|
2864
2854
|
* @license
|
|
2865
|
-
* Copyright
|
|
2855
|
+
* Copyright 2019 Google LLC
|
|
2866
2856
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
2867
2857
|
*/
|
|
2868
|
-
const
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
PROPERTY: 3,
|
|
2872
|
-
BOOLEAN_ATTRIBUTE: 4,
|
|
2873
|
-
EVENT: 5,
|
|
2874
|
-
ELEMENT: 6,
|
|
2875
|
-
};
|
|
2858
|
+
const NODE_MODE = false;
|
|
2859
|
+
// Allows minifiers to rename references to globalThis
|
|
2860
|
+
const global$1 = globalThis;
|
|
2876
2861
|
/**
|
|
2877
|
-
*
|
|
2878
|
-
* function has the same parameters as the directive's render() method.
|
|
2862
|
+
* Whether the current browser supports `adoptedStyleSheets`.
|
|
2879
2863
|
*/
|
|
2880
|
-
const
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2864
|
+
const supportsAdoptingStyleSheets = global$1.ShadowRoot &&
|
|
2865
|
+
(global$1.ShadyCSS === undefined || global$1.ShadyCSS.nativeShadow) &&
|
|
2866
|
+
'adoptedStyleSheets' in Document.prototype &&
|
|
2867
|
+
'replace' in CSSStyleSheet.prototype;
|
|
2868
|
+
const constructionToken = Symbol();
|
|
2869
|
+
const cssTagCache = new WeakMap();
|
|
2885
2870
|
/**
|
|
2886
|
-
*
|
|
2887
|
-
*
|
|
2888
|
-
* `
|
|
2871
|
+
* A container for a string of CSS text, that may be used to create a CSSStyleSheet.
|
|
2872
|
+
*
|
|
2873
|
+
* CSSResult is the return value of `css`-tagged template literals and
|
|
2874
|
+
* `unsafeCSS()`. In order to ensure that CSSResults are only created via the
|
|
2875
|
+
* `css` tag and `unsafeCSS()`, CSSResult cannot be constructed directly.
|
|
2889
2876
|
*/
|
|
2890
|
-
class
|
|
2891
|
-
constructor(
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2877
|
+
class CSSResult {
|
|
2878
|
+
constructor(cssText, strings, safeToken) {
|
|
2879
|
+
// This property needs to remain unminified.
|
|
2880
|
+
this['_$cssResult$'] = true;
|
|
2881
|
+
if (safeToken !== constructionToken) {
|
|
2882
|
+
throw new Error('CSSResult is not constructable. Use `unsafeCSS` or `css` instead.');
|
|
2883
|
+
}
|
|
2884
|
+
this.cssText = cssText;
|
|
2885
|
+
this._strings = strings;
|
|
2895
2886
|
}
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2887
|
+
// This is a getter so that it's lazy. In practice, this means stylesheets
|
|
2888
|
+
// are not created until the first element instance is made.
|
|
2889
|
+
get styleSheet() {
|
|
2890
|
+
// If `supportsAdoptingStyleSheets` is true then we assume CSSStyleSheet is
|
|
2891
|
+
// constructable.
|
|
2892
|
+
let styleSheet = this._styleSheet;
|
|
2893
|
+
const strings = this._strings;
|
|
2894
|
+
if (supportsAdoptingStyleSheets && styleSheet === undefined) {
|
|
2895
|
+
const cacheable = strings !== undefined && strings.length === 1;
|
|
2896
|
+
if (cacheable) {
|
|
2897
|
+
styleSheet = cssTagCache.get(strings);
|
|
2898
|
+
}
|
|
2899
|
+
if (styleSheet === undefined) {
|
|
2900
|
+
(this._styleSheet = styleSheet = new CSSStyleSheet()).replaceSync(this.cssText);
|
|
2901
|
+
if (cacheable) {
|
|
2902
|
+
cssTagCache.set(strings, styleSheet);
|
|
2903
|
+
}
|
|
2904
|
+
}
|
|
2905
|
+
}
|
|
2906
|
+
return styleSheet;
|
|
2901
2907
|
}
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
return this.update(part, props);
|
|
2905
|
-
}
|
|
2906
|
-
update(_part, props) {
|
|
2907
|
-
return this.render(...props);
|
|
2908
|
+
toString() {
|
|
2909
|
+
return this.cssText;
|
|
2908
2910
|
}
|
|
2909
2911
|
}
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
2915
|
-
*/
|
|
2916
|
-
class ClassMapDirective extends Directive {
|
|
2917
|
-
constructor(partInfo) {
|
|
2918
|
-
super(partInfo);
|
|
2919
|
-
if (partInfo.type !== PartType.ATTRIBUTE ||
|
|
2920
|
-
partInfo.name !== 'class' ||
|
|
2921
|
-
partInfo.strings?.length > 2) {
|
|
2922
|
-
throw new Error('`classMap()` can only be used in the `class` attribute ' +
|
|
2923
|
-
'and must be the only part in the attribute.');
|
|
2924
|
-
}
|
|
2912
|
+
const textFromCSSResult = (value) => {
|
|
2913
|
+
// This property needs to remain unminified.
|
|
2914
|
+
if (value['_$cssResult$'] === true) {
|
|
2915
|
+
return value.cssText;
|
|
2925
2916
|
}
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
return (' ' +
|
|
2929
|
-
Object.keys(classInfo)
|
|
2930
|
-
.filter((key) => classInfo[key])
|
|
2931
|
-
.join(' ') +
|
|
2932
|
-
' ');
|
|
2917
|
+
else if (typeof value === 'number') {
|
|
2918
|
+
return value;
|
|
2933
2919
|
}
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
if (part.strings !== undefined) {
|
|
2939
|
-
this._staticClasses = new Set(part.strings
|
|
2940
|
-
.join(' ')
|
|
2941
|
-
.split(/\s/)
|
|
2942
|
-
.filter((s) => s !== ''));
|
|
2943
|
-
}
|
|
2944
|
-
for (const name in classInfo) {
|
|
2945
|
-
if (classInfo[name] && !this._staticClasses?.has(name)) {
|
|
2946
|
-
this._previousClasses.add(name);
|
|
2947
|
-
}
|
|
2948
|
-
}
|
|
2949
|
-
return this.render(classInfo);
|
|
2950
|
-
}
|
|
2951
|
-
const classList = part.element.classList;
|
|
2952
|
-
// Remove old classes that no longer apply
|
|
2953
|
-
for (const name of this._previousClasses) {
|
|
2954
|
-
if (!(name in classInfo)) {
|
|
2955
|
-
classList.remove(name);
|
|
2956
|
-
this._previousClasses.delete(name);
|
|
2957
|
-
}
|
|
2958
|
-
}
|
|
2959
|
-
// Add or remove classes based on their classMap value
|
|
2960
|
-
for (const name in classInfo) {
|
|
2961
|
-
// We explicitly want a loose truthy check of `value` because it seems
|
|
2962
|
-
// more convenient that '' and 0 are skipped.
|
|
2963
|
-
const value = !!classInfo[name];
|
|
2964
|
-
if (value !== this._previousClasses.has(name) &&
|
|
2965
|
-
!this._staticClasses?.has(name)) {
|
|
2966
|
-
if (value) {
|
|
2967
|
-
classList.add(name);
|
|
2968
|
-
this._previousClasses.add(name);
|
|
2969
|
-
}
|
|
2970
|
-
else {
|
|
2971
|
-
classList.remove(name);
|
|
2972
|
-
this._previousClasses.delete(name);
|
|
2973
|
-
}
|
|
2974
|
-
}
|
|
2975
|
-
}
|
|
2976
|
-
return noChange;
|
|
2920
|
+
else {
|
|
2921
|
+
throw new Error(`Value passed to 'css' function must be a 'css' function result: ` +
|
|
2922
|
+
`${value}. Use 'unsafeCSS' to pass non-literal values, but take care ` +
|
|
2923
|
+
`to ensure page security.`);
|
|
2977
2924
|
}
|
|
2978
|
-
}
|
|
2979
|
-
/**
|
|
2980
|
-
* A directive that applies dynamic CSS classes.
|
|
2981
|
-
*
|
|
2982
|
-
* This must be used in the `class` attribute and must be the only part used in
|
|
2983
|
-
* the attribute. It takes each property in the `classInfo` argument and adds
|
|
2984
|
-
* the property name to the element's `classList` if the property value is
|
|
2985
|
-
* truthy; if the property value is falsy, the property name is removed from
|
|
2986
|
-
* the element's `class`.
|
|
2987
|
-
*
|
|
2988
|
-
* For example `{foo: bar}` applies the class `foo` if the value of `bar` is
|
|
2989
|
-
* truthy.
|
|
2990
|
-
*
|
|
2991
|
-
* @param classInfo
|
|
2992
|
-
*/
|
|
2993
|
-
const classMap = directive(ClassMapDirective);
|
|
2994
|
-
|
|
2995
|
-
/**
|
|
2996
|
-
* @license
|
|
2997
|
-
* Copyright 2018 Google LLC
|
|
2998
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
2999
|
-
*/
|
|
3000
|
-
/**
|
|
3001
|
-
* For AttributeParts, sets the attribute if the value is defined and removes
|
|
3002
|
-
* the attribute if the value is undefined.
|
|
3003
|
-
*
|
|
3004
|
-
* For other part types, this directive is a no-op.
|
|
3005
|
-
*/
|
|
3006
|
-
const ifDefined = (value) => value ?? nothing;
|
|
3007
|
-
|
|
3008
|
-
/**
|
|
3009
|
-
* @license
|
|
3010
|
-
* Copyright 2020 Google LLC
|
|
3011
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
3012
|
-
*/
|
|
3013
|
-
window.ShadyDOM?.inUse &&
|
|
3014
|
-
window.ShadyDOM?.noPatch === true
|
|
3015
|
-
? window.ShadyDOM.wrap
|
|
3016
|
-
: (node) => node;
|
|
2925
|
+
};
|
|
3017
2926
|
/**
|
|
3018
|
-
*
|
|
3019
|
-
* interpolate between.
|
|
2927
|
+
* Wrap a value for interpolation in a {@linkcode css} tagged template literal.
|
|
3020
2928
|
*
|
|
3021
|
-
*
|
|
3022
|
-
*
|
|
3023
|
-
*
|
|
2929
|
+
* This is unsafe because untrusted CSS text can be used to phone home
|
|
2930
|
+
* or exfiltrate data to an attacker controlled site. Take care to only use
|
|
2931
|
+
* this with trusted input.
|
|
3024
2932
|
*/
|
|
3025
|
-
const
|
|
3026
|
-
// A sentinel value that can never appear as a part value except when set by
|
|
3027
|
-
// live(). Used to force a dirty-check to fail and cause a re-render.
|
|
3028
|
-
const RESET_VALUE = {};
|
|
2933
|
+
const unsafeCSS = (value) => new CSSResult(typeof value === 'string' ? value : String(value), undefined, constructionToken);
|
|
3029
2934
|
/**
|
|
3030
|
-
*
|
|
3031
|
-
*
|
|
3032
|
-
*
|
|
3033
|
-
* This is useful in cases where a directive needs to update the part such
|
|
3034
|
-
* that the next update detects a value change or not. When value is omitted,
|
|
3035
|
-
* the next update will be guaranteed to be detected as a change.
|
|
2935
|
+
* A template literal tag which can be used with LitElement's
|
|
2936
|
+
* {@linkcode LitElement.styles} property to set element styles.
|
|
3036
2937
|
*
|
|
3037
|
-
*
|
|
3038
|
-
* @
|
|
2938
|
+
* For security reasons, only literal string values and number may be used in
|
|
2939
|
+
* embedded expressions. To incorporate non-literal values {@linkcode unsafeCSS}
|
|
2940
|
+
* may be used inside an expression.
|
|
3039
2941
|
*/
|
|
3040
|
-
const
|
|
3041
|
-
|
|
2942
|
+
const css = (strings, ...values) => {
|
|
2943
|
+
const cssText = strings.length === 1
|
|
2944
|
+
? strings[0]
|
|
2945
|
+
: values.reduce((acc, v, idx) => acc + textFromCSSResult(v) + strings[idx + 1], strings[0]);
|
|
2946
|
+
return new CSSResult(cssText, strings, constructionToken);
|
|
2947
|
+
};
|
|
3042
2948
|
/**
|
|
3043
|
-
*
|
|
3044
|
-
*
|
|
3045
|
-
*
|
|
2949
|
+
* Applies the given styles to a `shadowRoot`. When Shadow DOM is
|
|
2950
|
+
* available but `adoptedStyleSheets` is not, styles are appended to the
|
|
2951
|
+
* `shadowRoot` to [mimic spec behavior](https://wicg.github.io/construct-stylesheets/#using-constructed-stylesheets).
|
|
2952
|
+
* Note, when shimming is used, any styles that are subsequently placed into
|
|
2953
|
+
* the shadowRoot should be placed *before* any shimmed adopted styles. This
|
|
2954
|
+
* will match spec behavior that gives adopted sheets precedence over styles in
|
|
2955
|
+
* shadowRoot.
|
|
3046
2956
|
*/
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
if (!(partInfo.type === PartType.PROPERTY ||
|
|
3051
|
-
partInfo.type === PartType.ATTRIBUTE ||
|
|
3052
|
-
partInfo.type === PartType.BOOLEAN_ATTRIBUTE)) {
|
|
3053
|
-
throw new Error('The `live` directive is not allowed on child or event bindings');
|
|
3054
|
-
}
|
|
3055
|
-
if (!isSingleExpression(partInfo)) {
|
|
3056
|
-
throw new Error('`live` bindings can only contain a single expression');
|
|
3057
|
-
}
|
|
3058
|
-
}
|
|
3059
|
-
render(value) {
|
|
3060
|
-
return value;
|
|
2957
|
+
const adoptStyles = (renderRoot, styles) => {
|
|
2958
|
+
if (supportsAdoptingStyleSheets) {
|
|
2959
|
+
renderRoot.adoptedStyleSheets = styles.map((s) => s instanceof CSSStyleSheet ? s : s.styleSheet);
|
|
3061
2960
|
}
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
}
|
|
3066
|
-
const element = part.element;
|
|
3067
|
-
const name = part.name;
|
|
3068
|
-
if (part.type === PartType.PROPERTY) {
|
|
2961
|
+
else {
|
|
2962
|
+
for (const s of styles) {
|
|
2963
|
+
const style = document.createElement('style');
|
|
3069
2964
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
}
|
|
3074
|
-
else if (part.type === PartType.BOOLEAN_ATTRIBUTE) {
|
|
3075
|
-
if (!!value === element.hasAttribute(name)) {
|
|
3076
|
-
return noChange;
|
|
3077
|
-
}
|
|
3078
|
-
}
|
|
3079
|
-
else if (part.type === PartType.ATTRIBUTE) {
|
|
3080
|
-
if (element.getAttribute(name) === String(value)) {
|
|
3081
|
-
return noChange;
|
|
2965
|
+
const nonce = global$1['litNonce'];
|
|
2966
|
+
if (nonce !== undefined) {
|
|
2967
|
+
style.setAttribute('nonce', nonce);
|
|
3082
2968
|
}
|
|
2969
|
+
style.textContent = s.cssText;
|
|
2970
|
+
renderRoot.appendChild(style);
|
|
3083
2971
|
}
|
|
3084
|
-
// Resets the part's value, causing its dirty-check to fail so that it
|
|
3085
|
-
// always sets the value.
|
|
3086
|
-
setCommittedValue(part);
|
|
3087
|
-
return value;
|
|
3088
2972
|
}
|
|
3089
|
-
}
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
* it alone. If this is not what you want--if you want to overwrite the DOM
|
|
3102
|
-
* value with the bound value no matter what--use the `live()` directive:
|
|
3103
|
-
*
|
|
3104
|
-
* ```js
|
|
3105
|
-
* html`<input .value=${live(x)}>`
|
|
3106
|
-
* ```
|
|
3107
|
-
*
|
|
3108
|
-
* `live()` performs a strict equality check against the live DOM value, and if
|
|
3109
|
-
* the new value is equal to the live value, does nothing. This means that
|
|
3110
|
-
* `live()` should not be used when the binding will cause a type conversion. If
|
|
3111
|
-
* you use `live()` with an attribute binding, make sure that only strings are
|
|
3112
|
-
* passed in, or the binding will update every render.
|
|
3113
|
-
*/
|
|
3114
|
-
const live = directive(LiveDirective);
|
|
2973
|
+
};
|
|
2974
|
+
const cssResultFromStyleSheet = (sheet) => {
|
|
2975
|
+
let cssText = '';
|
|
2976
|
+
for (const rule of sheet.cssRules) {
|
|
2977
|
+
cssText += rule.cssText;
|
|
2978
|
+
}
|
|
2979
|
+
return unsafeCSS(cssText);
|
|
2980
|
+
};
|
|
2981
|
+
const getCompatibleStyle = supportsAdoptingStyleSheets ||
|
|
2982
|
+
(NODE_MODE )
|
|
2983
|
+
? (s) => s
|
|
2984
|
+
: (s) => s instanceof CSSStyleSheet ? cssResultFromStyleSheet(s) : s;
|
|
3115
2985
|
|
|
3116
2986
|
/**
|
|
3117
2987
|
* @license
|
|
3118
2988
|
* Copyright 2017 Google LLC
|
|
3119
2989
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
3120
2990
|
*/
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
2991
|
+
// TODO (justinfagnani): Add `hasOwn` here when we ship ES2022
|
|
2992
|
+
const { is, defineProperty, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, } = Object;
|
|
2993
|
+
// Lets a minifier replace globalThis references with a minified name
|
|
2994
|
+
const global = globalThis;
|
|
2995
|
+
let issueWarning$2;
|
|
2996
|
+
const trustedTypes = global
|
|
2997
|
+
.trustedTypes;
|
|
2998
|
+
// Temporary workaround for https://crbug.com/993268
|
|
2999
|
+
// Currently, any attribute starting with "on" is considered to be a
|
|
3000
|
+
// TrustedScript source. Such boolean attributes must be set to the equivalent
|
|
3001
|
+
// trusted emptyScript value.
|
|
3002
|
+
const emptyStringForBooleanAttribute = trustedTypes
|
|
3003
|
+
? trustedTypes.emptyScript
|
|
3004
|
+
: '';
|
|
3005
|
+
const polyfillSupport$1 = global.reactiveElementPolyfillSupportDevMode
|
|
3006
|
+
;
|
|
3007
|
+
{
|
|
3008
|
+
// Ensure warnings are issued only 1x, even if multiple versions of Lit
|
|
3009
|
+
// are loaded.
|
|
3010
|
+
const issuedWarnings = (global.litIssuedWarnings ??=
|
|
3011
|
+
new Set());
|
|
3012
|
+
// Issue a warning, if we haven't already.
|
|
3013
|
+
issueWarning$2 = (code, warning) => {
|
|
3014
|
+
warning += ` See https://lit.dev/msg/${code} for more information.`;
|
|
3015
|
+
if (!issuedWarnings.has(warning)) {
|
|
3016
|
+
console.warn(warning);
|
|
3017
|
+
issuedWarnings.add(warning);
|
|
3143
3018
|
}
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
return (this._templateResult = {
|
|
3151
|
-
// Cast to a known set of integers that satisfy ResultType so that we
|
|
3152
|
-
// don't have to export ResultType and possibly encourage this pattern.
|
|
3153
|
-
// This property needs to remain unminified.
|
|
3154
|
-
['_$litType$']: this.constructor
|
|
3155
|
-
.resultType,
|
|
3156
|
-
strings,
|
|
3157
|
-
values: [],
|
|
3158
|
-
});
|
|
3019
|
+
};
|
|
3020
|
+
issueWarning$2('dev-mode', `Lit is in dev mode. Not recommended for production!`);
|
|
3021
|
+
// Issue polyfill support warning.
|
|
3022
|
+
if (global.ShadyDOM?.inUse && polyfillSupport$1 === undefined) {
|
|
3023
|
+
issueWarning$2('polyfill-support-missing', `Shadow DOM is being polyfilled via \`ShadyDOM\` but ` +
|
|
3024
|
+
`the \`polyfill-support\` module has not been loaded.`);
|
|
3159
3025
|
}
|
|
3160
3026
|
}
|
|
3161
|
-
UnsafeHTMLDirective.directiveName = 'unsafeHTML';
|
|
3162
|
-
UnsafeHTMLDirective.resultType = HTML_RESULT;
|
|
3163
|
-
|
|
3164
|
-
/**
|
|
3165
|
-
* @license
|
|
3166
|
-
* Copyright 2017 Google LLC
|
|
3167
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
3168
|
-
*/
|
|
3169
|
-
const SVG_RESULT = 2;
|
|
3170
|
-
class UnsafeSVGDirective extends UnsafeHTMLDirective {
|
|
3171
|
-
}
|
|
3172
|
-
UnsafeSVGDirective.directiveName = 'unsafeSVG';
|
|
3173
|
-
UnsafeSVGDirective.resultType = SVG_RESULT;
|
|
3174
|
-
/**
|
|
3175
|
-
* Renders the result as SVG, rather than text.
|
|
3176
|
-
*
|
|
3177
|
-
* The values `undefined`, `null`, and `nothing`, will all result in no content
|
|
3178
|
-
* (empty string) being rendered.
|
|
3179
|
-
*
|
|
3180
|
-
* Note, this is unsafe to use with any user-provided input that hasn't been
|
|
3181
|
-
* sanitized or escaped, as it may lead to cross-site-scripting
|
|
3182
|
-
* vulnerabilities.
|
|
3183
|
-
*/
|
|
3184
|
-
const unsafeSVG = directive(UnsafeSVGDirective);
|
|
3185
|
-
|
|
3186
|
-
/**
|
|
3187
|
-
* @license
|
|
3188
|
-
* Copyright 2020 Google LLC
|
|
3189
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
3190
|
-
*/
|
|
3191
3027
|
/**
|
|
3192
|
-
*
|
|
3193
|
-
*
|
|
3194
|
-
* The goals of this brand:
|
|
3195
|
-
* 1) fast to check
|
|
3196
|
-
* 2) code is small on the wire
|
|
3197
|
-
* 3) multiple versions of Lit in a single page will all produce mutually
|
|
3198
|
-
* interoperable StaticValues
|
|
3199
|
-
* 4) normal JSON.parse (without an unusual reviver) can not produce a
|
|
3200
|
-
* StaticValue
|
|
3028
|
+
* Useful for visualizing and logging insights into what the Lit template system is doing.
|
|
3201
3029
|
*
|
|
3202
|
-
*
|
|
3203
|
-
* we don't care about the key, so we break ties via (2) and use the empty
|
|
3204
|
-
* string.
|
|
3030
|
+
* Compiled out of prod mode builds.
|
|
3205
3031
|
*/
|
|
3206
|
-
const
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3032
|
+
const debugLogEvent = (event) => {
|
|
3033
|
+
const shouldEmit = global
|
|
3034
|
+
.emitLitDebugLogEvents;
|
|
3035
|
+
if (!shouldEmit) {
|
|
3036
|
+
return;
|
|
3037
|
+
}
|
|
3038
|
+
global.dispatchEvent(new CustomEvent('lit-debug', {
|
|
3039
|
+
detail: event,
|
|
3040
|
+
}));
|
|
3211
3041
|
}
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
*
|
|
3042
|
+
;
|
|
3043
|
+
/*
|
|
3044
|
+
* When using Closure Compiler, JSCompiler_renameProperty(property, object) is
|
|
3045
|
+
* replaced at compile time by the munged name for object[property]. We cannot
|
|
3046
|
+
* alias this function, so we have to use a small shim that has the same
|
|
3047
|
+
* behavior when not compiling.
|
|
3217
3048
|
*/
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
while (i < l &&
|
|
3233
|
-
((dynamicValue = values[i]),
|
|
3234
|
-
(staticValue = unwrapStaticValue(dynamicValue))) !== undefined) {
|
|
3235
|
-
s += staticValue + strings[++i];
|
|
3236
|
-
hasStatics = true;
|
|
3237
|
-
}
|
|
3238
|
-
// If the last value is static, we don't need to push it.
|
|
3239
|
-
if (i !== l) {
|
|
3240
|
-
dynamicValues.push(dynamicValue);
|
|
3049
|
+
/*@__INLINE__*/
|
|
3050
|
+
const JSCompiler_renameProperty$1 = (prop, _obj) => prop;
|
|
3051
|
+
const defaultConverter = {
|
|
3052
|
+
toAttribute(value, type) {
|
|
3053
|
+
switch (type) {
|
|
3054
|
+
case Boolean:
|
|
3055
|
+
value = value ? emptyStringForBooleanAttribute : null;
|
|
3056
|
+
break;
|
|
3057
|
+
case Object:
|
|
3058
|
+
case Array:
|
|
3059
|
+
// if the value is `null` or `undefined` pass this through
|
|
3060
|
+
// to allow removing/no change behavior.
|
|
3061
|
+
value = value == null ? value : JSON.stringify(value);
|
|
3062
|
+
break;
|
|
3241
3063
|
}
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3064
|
+
return value;
|
|
3065
|
+
},
|
|
3066
|
+
fromAttribute(value, type) {
|
|
3067
|
+
let fromValue = value;
|
|
3068
|
+
switch (type) {
|
|
3069
|
+
case Boolean:
|
|
3070
|
+
fromValue = value !== null;
|
|
3071
|
+
break;
|
|
3072
|
+
case Number:
|
|
3073
|
+
fromValue = value === null ? null : Number(value);
|
|
3074
|
+
break;
|
|
3075
|
+
case Object:
|
|
3076
|
+
case Array:
|
|
3077
|
+
// Do *not* generate exception when invalid JSON is set as elements
|
|
3078
|
+
// don't normally complain on being mis-configured.
|
|
3079
|
+
// TODO(sorvell): Do generate exception in *dev mode*.
|
|
3080
|
+
try {
|
|
3081
|
+
// Assert to adhere to Bazel's "must type assert JSON parse" rule.
|
|
3082
|
+
fromValue = JSON.parse(value);
|
|
3083
|
+
}
|
|
3084
|
+
catch (e) {
|
|
3085
|
+
fromValue = null;
|
|
3086
|
+
}
|
|
3087
|
+
break;
|
|
3260
3088
|
}
|
|
3261
|
-
|
|
3262
|
-
}
|
|
3263
|
-
return coreTag(strings, ...values);
|
|
3089
|
+
return fromValue;
|
|
3090
|
+
},
|
|
3264
3091
|
};
|
|
3265
3092
|
/**
|
|
3266
|
-
*
|
|
3267
|
-
*
|
|
3268
|
-
*
|
|
3269
|
-
* Includes static value support from `lit-html/static.js`.
|
|
3270
|
-
*/
|
|
3271
|
-
const html = withStatic(html$1);
|
|
3272
|
-
|
|
3273
|
-
function genId (componentName = "", elementName = "") {
|
|
3274
|
-
return `id-${Math.random().toString().substring(2, 6)}-sgds-${componentName}-${elementName}`;
|
|
3275
|
-
}
|
|
3276
|
-
|
|
3277
|
-
/**
|
|
3278
|
-
* @license
|
|
3279
|
-
* Copyright 2019 Google LLC
|
|
3280
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
3093
|
+
* Change function that returns true if `value` is different from `oldValue`.
|
|
3094
|
+
* This method is used as the default for a property's `hasChanged` function.
|
|
3281
3095
|
*/
|
|
3282
|
-
const
|
|
3283
|
-
|
|
3284
|
-
|
|
3096
|
+
const notEqual = (value, old) => !is(value, old);
|
|
3097
|
+
const defaultPropertyDeclaration$1 = {
|
|
3098
|
+
attribute: true,
|
|
3099
|
+
type: String,
|
|
3100
|
+
converter: defaultConverter,
|
|
3101
|
+
reflect: false,
|
|
3102
|
+
hasChanged: notEqual,
|
|
3103
|
+
};
|
|
3104
|
+
// Ensure metadata is enabled. TypeScript does not polyfill
|
|
3105
|
+
// Symbol.metadata, so we must ensure that it exists.
|
|
3106
|
+
Symbol.metadata ??= Symbol('metadata');
|
|
3107
|
+
// Map from a class's metadata object to property options
|
|
3108
|
+
// Note that we must use nullish-coalescing assignment so that we only use one
|
|
3109
|
+
// map even if we load multiple version of this module.
|
|
3110
|
+
global.litPropertyMetadata ??= new WeakMap();
|
|
3285
3111
|
/**
|
|
3286
|
-
*
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
'adoptedStyleSheets' in Document.prototype &&
|
|
3291
|
-
'replace' in CSSStyleSheet.prototype;
|
|
3292
|
-
const constructionToken = Symbol();
|
|
3293
|
-
const cssTagCache = new WeakMap();
|
|
3294
|
-
/**
|
|
3295
|
-
* A container for a string of CSS text, that may be used to create a CSSStyleSheet.
|
|
3296
|
-
*
|
|
3297
|
-
* CSSResult is the return value of `css`-tagged template literals and
|
|
3298
|
-
* `unsafeCSS()`. In order to ensure that CSSResults are only created via the
|
|
3299
|
-
* `css` tag and `unsafeCSS()`, CSSResult cannot be constructed directly.
|
|
3300
|
-
*/
|
|
3301
|
-
class CSSResult {
|
|
3302
|
-
constructor(cssText, strings, safeToken) {
|
|
3303
|
-
// This property needs to remain unminified.
|
|
3304
|
-
this['_$cssResult$'] = true;
|
|
3305
|
-
if (safeToken !== constructionToken) {
|
|
3306
|
-
throw new Error('CSSResult is not constructable. Use `unsafeCSS` or `css` instead.');
|
|
3307
|
-
}
|
|
3308
|
-
this.cssText = cssText;
|
|
3309
|
-
this._strings = strings;
|
|
3310
|
-
}
|
|
3311
|
-
// This is a getter so that it's lazy. In practice, this means stylesheets
|
|
3312
|
-
// are not created until the first element instance is made.
|
|
3313
|
-
get styleSheet() {
|
|
3314
|
-
// If `supportsAdoptingStyleSheets` is true then we assume CSSStyleSheet is
|
|
3315
|
-
// constructable.
|
|
3316
|
-
let styleSheet = this._styleSheet;
|
|
3317
|
-
const strings = this._strings;
|
|
3318
|
-
if (supportsAdoptingStyleSheets && styleSheet === undefined) {
|
|
3319
|
-
const cacheable = strings !== undefined && strings.length === 1;
|
|
3320
|
-
if (cacheable) {
|
|
3321
|
-
styleSheet = cssTagCache.get(strings);
|
|
3322
|
-
}
|
|
3323
|
-
if (styleSheet === undefined) {
|
|
3324
|
-
(this._styleSheet = styleSheet = new CSSStyleSheet()).replaceSync(this.cssText);
|
|
3325
|
-
if (cacheable) {
|
|
3326
|
-
cssTagCache.set(strings, styleSheet);
|
|
3327
|
-
}
|
|
3328
|
-
}
|
|
3329
|
-
}
|
|
3330
|
-
return styleSheet;
|
|
3331
|
-
}
|
|
3332
|
-
toString() {
|
|
3333
|
-
return this.cssText;
|
|
3334
|
-
}
|
|
3335
|
-
}
|
|
3336
|
-
const textFromCSSResult = (value) => {
|
|
3337
|
-
// This property needs to remain unminified.
|
|
3338
|
-
if (value['_$cssResult$'] === true) {
|
|
3339
|
-
return value.cssText;
|
|
3340
|
-
}
|
|
3341
|
-
else if (typeof value === 'number') {
|
|
3342
|
-
return value;
|
|
3343
|
-
}
|
|
3344
|
-
else {
|
|
3345
|
-
throw new Error(`Value passed to 'css' function must be a 'css' function result: ` +
|
|
3346
|
-
`${value}. Use 'unsafeCSS' to pass non-literal values, but take care ` +
|
|
3347
|
-
`to ensure page security.`);
|
|
3348
|
-
}
|
|
3349
|
-
};
|
|
3350
|
-
/**
|
|
3351
|
-
* Wrap a value for interpolation in a {@linkcode css} tagged template literal.
|
|
3352
|
-
*
|
|
3353
|
-
* This is unsafe because untrusted CSS text can be used to phone home
|
|
3354
|
-
* or exfiltrate data to an attacker controlled site. Take care to only use
|
|
3355
|
-
* this with trusted input.
|
|
3356
|
-
*/
|
|
3357
|
-
const unsafeCSS = (value) => new CSSResult(typeof value === 'string' ? value : String(value), undefined, constructionToken);
|
|
3358
|
-
/**
|
|
3359
|
-
* A template literal tag which can be used with LitElement's
|
|
3360
|
-
* {@linkcode LitElement.styles} property to set element styles.
|
|
3361
|
-
*
|
|
3362
|
-
* For security reasons, only literal string values and number may be used in
|
|
3363
|
-
* embedded expressions. To incorporate non-literal values {@linkcode unsafeCSS}
|
|
3364
|
-
* may be used inside an expression.
|
|
3365
|
-
*/
|
|
3366
|
-
const css = (strings, ...values) => {
|
|
3367
|
-
const cssText = strings.length === 1
|
|
3368
|
-
? strings[0]
|
|
3369
|
-
: values.reduce((acc, v, idx) => acc + textFromCSSResult(v) + strings[idx + 1], strings[0]);
|
|
3370
|
-
return new CSSResult(cssText, strings, constructionToken);
|
|
3371
|
-
};
|
|
3372
|
-
/**
|
|
3373
|
-
* Applies the given styles to a `shadowRoot`. When Shadow DOM is
|
|
3374
|
-
* available but `adoptedStyleSheets` is not, styles are appended to the
|
|
3375
|
-
* `shadowRoot` to [mimic spec behavior](https://wicg.github.io/construct-stylesheets/#using-constructed-stylesheets).
|
|
3376
|
-
* Note, when shimming is used, any styles that are subsequently placed into
|
|
3377
|
-
* the shadowRoot should be placed *before* any shimmed adopted styles. This
|
|
3378
|
-
* will match spec behavior that gives adopted sheets precedence over styles in
|
|
3379
|
-
* shadowRoot.
|
|
3380
|
-
*/
|
|
3381
|
-
const adoptStyles = (renderRoot, styles) => {
|
|
3382
|
-
if (supportsAdoptingStyleSheets) {
|
|
3383
|
-
renderRoot.adoptedStyleSheets = styles.map((s) => s instanceof CSSStyleSheet ? s : s.styleSheet);
|
|
3384
|
-
}
|
|
3385
|
-
else {
|
|
3386
|
-
for (const s of styles) {
|
|
3387
|
-
const style = document.createElement('style');
|
|
3388
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3389
|
-
const nonce = global$1['litNonce'];
|
|
3390
|
-
if (nonce !== undefined) {
|
|
3391
|
-
style.setAttribute('nonce', nonce);
|
|
3392
|
-
}
|
|
3393
|
-
style.textContent = s.cssText;
|
|
3394
|
-
renderRoot.appendChild(style);
|
|
3395
|
-
}
|
|
3396
|
-
}
|
|
3397
|
-
};
|
|
3398
|
-
const cssResultFromStyleSheet = (sheet) => {
|
|
3399
|
-
let cssText = '';
|
|
3400
|
-
for (const rule of sheet.cssRules) {
|
|
3401
|
-
cssText += rule.cssText;
|
|
3402
|
-
}
|
|
3403
|
-
return unsafeCSS(cssText);
|
|
3404
|
-
};
|
|
3405
|
-
const getCompatibleStyle = supportsAdoptingStyleSheets ||
|
|
3406
|
-
(NODE_MODE )
|
|
3407
|
-
? (s) => s
|
|
3408
|
-
: (s) => s instanceof CSSStyleSheet ? cssResultFromStyleSheet(s) : s;
|
|
3409
|
-
|
|
3410
|
-
/**
|
|
3411
|
-
* @license
|
|
3412
|
-
* Copyright 2017 Google LLC
|
|
3413
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
3414
|
-
*/
|
|
3415
|
-
// TODO (justinfagnani): Add `hasOwn` here when we ship ES2022
|
|
3416
|
-
const { is, defineProperty, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, } = Object;
|
|
3417
|
-
// Lets a minifier replace globalThis references with a minified name
|
|
3418
|
-
const global = globalThis;
|
|
3419
|
-
let issueWarning$1;
|
|
3420
|
-
const trustedTypes = global
|
|
3421
|
-
.trustedTypes;
|
|
3422
|
-
// Temporary workaround for https://crbug.com/993268
|
|
3423
|
-
// Currently, any attribute starting with "on" is considered to be a
|
|
3424
|
-
// TrustedScript source. Such boolean attributes must be set to the equivalent
|
|
3425
|
-
// trusted emptyScript value.
|
|
3426
|
-
const emptyStringForBooleanAttribute = trustedTypes
|
|
3427
|
-
? trustedTypes.emptyScript
|
|
3428
|
-
: '';
|
|
3429
|
-
const polyfillSupport$1 = global.reactiveElementPolyfillSupportDevMode
|
|
3430
|
-
;
|
|
3431
|
-
{
|
|
3432
|
-
// Ensure warnings are issued only 1x, even if multiple versions of Lit
|
|
3433
|
-
// are loaded.
|
|
3434
|
-
const issuedWarnings = (global.litIssuedWarnings ??=
|
|
3435
|
-
new Set());
|
|
3436
|
-
// Issue a warning, if we haven't already.
|
|
3437
|
-
issueWarning$1 = (code, warning) => {
|
|
3438
|
-
warning += ` See https://lit.dev/msg/${code} for more information.`;
|
|
3439
|
-
if (!issuedWarnings.has(warning)) {
|
|
3440
|
-
console.warn(warning);
|
|
3441
|
-
issuedWarnings.add(warning);
|
|
3442
|
-
}
|
|
3443
|
-
};
|
|
3444
|
-
issueWarning$1('dev-mode', `Lit is in dev mode. Not recommended for production!`);
|
|
3445
|
-
// Issue polyfill support warning.
|
|
3446
|
-
if (global.ShadyDOM?.inUse && polyfillSupport$1 === undefined) {
|
|
3447
|
-
issueWarning$1('polyfill-support-missing', `Shadow DOM is being polyfilled via \`ShadyDOM\` but ` +
|
|
3448
|
-
`the \`polyfill-support\` module has not been loaded.`);
|
|
3449
|
-
}
|
|
3450
|
-
}
|
|
3451
|
-
/**
|
|
3452
|
-
* Useful for visualizing and logging insights into what the Lit template system is doing.
|
|
3453
|
-
*
|
|
3454
|
-
* Compiled out of prod mode builds.
|
|
3455
|
-
*/
|
|
3456
|
-
const debugLogEvent = (event) => {
|
|
3457
|
-
const shouldEmit = global
|
|
3458
|
-
.emitLitDebugLogEvents;
|
|
3459
|
-
if (!shouldEmit) {
|
|
3460
|
-
return;
|
|
3461
|
-
}
|
|
3462
|
-
global.dispatchEvent(new CustomEvent('lit-debug', {
|
|
3463
|
-
detail: event,
|
|
3464
|
-
}));
|
|
3465
|
-
}
|
|
3466
|
-
;
|
|
3467
|
-
/*
|
|
3468
|
-
* When using Closure Compiler, JSCompiler_renameProperty(property, object) is
|
|
3469
|
-
* replaced at compile time by the munged name for object[property]. We cannot
|
|
3470
|
-
* alias this function, so we have to use a small shim that has the same
|
|
3471
|
-
* behavior when not compiling.
|
|
3472
|
-
*/
|
|
3473
|
-
/*@__INLINE__*/
|
|
3474
|
-
const JSCompiler_renameProperty$1 = (prop, _obj) => prop;
|
|
3475
|
-
const defaultConverter = {
|
|
3476
|
-
toAttribute(value, type) {
|
|
3477
|
-
switch (type) {
|
|
3478
|
-
case Boolean:
|
|
3479
|
-
value = value ? emptyStringForBooleanAttribute : null;
|
|
3480
|
-
break;
|
|
3481
|
-
case Object:
|
|
3482
|
-
case Array:
|
|
3483
|
-
// if the value is `null` or `undefined` pass this through
|
|
3484
|
-
// to allow removing/no change behavior.
|
|
3485
|
-
value = value == null ? value : JSON.stringify(value);
|
|
3486
|
-
break;
|
|
3487
|
-
}
|
|
3488
|
-
return value;
|
|
3489
|
-
},
|
|
3490
|
-
fromAttribute(value, type) {
|
|
3491
|
-
let fromValue = value;
|
|
3492
|
-
switch (type) {
|
|
3493
|
-
case Boolean:
|
|
3494
|
-
fromValue = value !== null;
|
|
3495
|
-
break;
|
|
3496
|
-
case Number:
|
|
3497
|
-
fromValue = value === null ? null : Number(value);
|
|
3498
|
-
break;
|
|
3499
|
-
case Object:
|
|
3500
|
-
case Array:
|
|
3501
|
-
// Do *not* generate exception when invalid JSON is set as elements
|
|
3502
|
-
// don't normally complain on being mis-configured.
|
|
3503
|
-
// TODO(sorvell): Do generate exception in *dev mode*.
|
|
3504
|
-
try {
|
|
3505
|
-
// Assert to adhere to Bazel's "must type assert JSON parse" rule.
|
|
3506
|
-
fromValue = JSON.parse(value);
|
|
3507
|
-
}
|
|
3508
|
-
catch (e) {
|
|
3509
|
-
fromValue = null;
|
|
3510
|
-
}
|
|
3511
|
-
break;
|
|
3512
|
-
}
|
|
3513
|
-
return fromValue;
|
|
3514
|
-
},
|
|
3515
|
-
};
|
|
3516
|
-
/**
|
|
3517
|
-
* Change function that returns true if `value` is different from `oldValue`.
|
|
3518
|
-
* This method is used as the default for a property's `hasChanged` function.
|
|
3519
|
-
*/
|
|
3520
|
-
const notEqual = (value, old) => !is(value, old);
|
|
3521
|
-
const defaultPropertyDeclaration = {
|
|
3522
|
-
attribute: true,
|
|
3523
|
-
type: String,
|
|
3524
|
-
converter: defaultConverter,
|
|
3525
|
-
reflect: false,
|
|
3526
|
-
hasChanged: notEqual,
|
|
3527
|
-
};
|
|
3528
|
-
// Ensure metadata is enabled. TypeScript does not polyfill
|
|
3529
|
-
// Symbol.metadata, so we must ensure that it exists.
|
|
3530
|
-
Symbol.metadata ??= Symbol('metadata');
|
|
3531
|
-
// Map from a class's metadata object to property options
|
|
3532
|
-
// Note that we must use nullish-coalescing assignment so that we only use one
|
|
3533
|
-
// map even if we load multiple version of this module.
|
|
3534
|
-
global.litPropertyMetadata ??= new WeakMap();
|
|
3535
|
-
/**
|
|
3536
|
-
* Base element class which manages element properties and attributes. When
|
|
3537
|
-
* properties change, the `update` method is asynchronously called. This method
|
|
3538
|
-
* should be supplied by subclasses to render updates as desired.
|
|
3539
|
-
* @noInheritDoc
|
|
3112
|
+
* Base element class which manages element properties and attributes. When
|
|
3113
|
+
* properties change, the `update` method is asynchronously called. This method
|
|
3114
|
+
* should be supplied by subclasses to render updates as desired.
|
|
3115
|
+
* @noInheritDoc
|
|
3540
3116
|
*/
|
|
3541
3117
|
class ReactiveElement
|
|
3542
3118
|
// In the Node build, this `extends` clause will be substituted with
|
|
@@ -3624,7 +3200,7 @@
|
|
|
3624
3200
|
* @nocollapse
|
|
3625
3201
|
* @category properties
|
|
3626
3202
|
*/
|
|
3627
|
-
static createProperty(name, options = defaultPropertyDeclaration) {
|
|
3203
|
+
static createProperty(name, options = defaultPropertyDeclaration$1) {
|
|
3628
3204
|
// If this is a state property, force the attribute to false.
|
|
3629
3205
|
if (options.state) {
|
|
3630
3206
|
options.attribute = false;
|
|
@@ -3685,7 +3261,7 @@
|
|
|
3685
3261
|
`but it's actually declared as a value on the prototype. ` +
|
|
3686
3262
|
`Usually this is due to using @property or @state on a method.`);
|
|
3687
3263
|
}
|
|
3688
|
-
issueWarning$
|
|
3264
|
+
issueWarning$2('reactive-property-without-getter', `Field ${JSON.stringify(String(name))} on ` +
|
|
3689
3265
|
`${this.name} was declared as a reactive property ` +
|
|
3690
3266
|
`but it does not have a getter. This will be an error in a ` +
|
|
3691
3267
|
`future version of Lit.`);
|
|
@@ -3718,7 +3294,7 @@
|
|
|
3718
3294
|
* @category properties
|
|
3719
3295
|
*/
|
|
3720
3296
|
static getPropertyOptions(name) {
|
|
3721
|
-
return this.elementProperties.get(name) ?? defaultPropertyDeclaration;
|
|
3297
|
+
return this.elementProperties.get(name) ?? defaultPropertyDeclaration$1;
|
|
3722
3298
|
}
|
|
3723
3299
|
/**
|
|
3724
3300
|
* Initializes static own properties of the class used in bookkeeping
|
|
@@ -3797,11 +3373,11 @@
|
|
|
3797
3373
|
this.elementStyles = this.finalizeStyles(this.styles);
|
|
3798
3374
|
{
|
|
3799
3375
|
if (this.hasOwnProperty('createProperty')) {
|
|
3800
|
-
issueWarning$
|
|
3376
|
+
issueWarning$2('no-override-create-property', 'Overriding ReactiveElement.createProperty() is deprecated. ' +
|
|
3801
3377
|
'The override will not be called with standard decorators');
|
|
3802
3378
|
}
|
|
3803
3379
|
if (this.hasOwnProperty('getPropertyDescriptor')) {
|
|
3804
|
-
issueWarning$
|
|
3380
|
+
issueWarning$2('no-override-get-property-descriptor', 'Overriding ReactiveElement.getPropertyDescriptor() is deprecated. ' +
|
|
3805
3381
|
'The override will not be called with standard decorators');
|
|
3806
3382
|
}
|
|
3807
3383
|
}
|
|
@@ -4009,7 +3585,7 @@
|
|
|
4009
3585
|
const attrValue = converter.toAttribute(value, options.type);
|
|
4010
3586
|
if (this.constructor.enabledWarnings.includes('migration') &&
|
|
4011
3587
|
attrValue === undefined) {
|
|
4012
|
-
issueWarning$
|
|
3588
|
+
issueWarning$2('undefined-attribute-value', `The attribute value for the ${name} property is ` +
|
|
4013
3589
|
`undefined on element ${this.localName}. The attribute will be ` +
|
|
4014
3590
|
`removed, but in the previous version of \`ReactiveElement\`, ` +
|
|
4015
3591
|
`the attribute would not have changed.`);
|
|
@@ -4075,7 +3651,7 @@
|
|
|
4075
3651
|
// If we have a property key, perform property update steps.
|
|
4076
3652
|
if (name !== undefined) {
|
|
4077
3653
|
if (name instanceof Event) {
|
|
4078
|
-
issueWarning$
|
|
3654
|
+
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()`);
|
|
4079
3655
|
}
|
|
4080
3656
|
options ??= this.constructor.getPropertyOptions(name);
|
|
4081
3657
|
const hasChanged = options.hasChanged ?? notEqual;
|
|
@@ -4157,7 +3733,7 @@
|
|
|
4157
3733
|
if (this.constructor.enabledWarnings.includes('async-perform-update') &&
|
|
4158
3734
|
typeof result?.then ===
|
|
4159
3735
|
'function') {
|
|
4160
|
-
issueWarning$
|
|
3736
|
+
issueWarning$2('async-perform-update', `Element ${this.localName} returned a Promise from performUpdate(). ` +
|
|
4161
3737
|
`This behavior is deprecated and will be removed in a future ` +
|
|
4162
3738
|
`version of ReactiveElement.`);
|
|
4163
3739
|
}
|
|
@@ -4293,7 +3869,7 @@
|
|
|
4293
3869
|
this.updated(changedProperties);
|
|
4294
3870
|
if (this.isUpdatePending &&
|
|
4295
3871
|
this.constructor.enabledWarnings.includes('change-in-update')) {
|
|
4296
|
-
issueWarning$
|
|
3872
|
+
issueWarning$2('change-in-update', `Element ${this.localName} scheduled an update ` +
|
|
4297
3873
|
`(generally because a property was set) ` +
|
|
4298
3874
|
`after an update completed, causing a new update to be scheduled. ` +
|
|
4299
3875
|
`This is inefficient and should be avoided unless the next update ` +
|
|
@@ -4454,179 +4030,841 @@
|
|
|
4454
4030
|
if (i >= 0) {
|
|
4455
4031
|
this.enabledWarnings.splice(i, 1);
|
|
4456
4032
|
}
|
|
4457
|
-
};
|
|
4458
|
-
}
|
|
4459
|
-
// IMPORTANT: do not change the property name or the assignment expression.
|
|
4460
|
-
// This line will be used in regexes to search for ReactiveElement usage.
|
|
4461
|
-
(global.reactiveElementVersions ??= []).push('2.0.4');
|
|
4462
|
-
if (global.reactiveElementVersions.length > 1) {
|
|
4463
|
-
issueWarning$
|
|
4464
|
-
`is not recommended.`);
|
|
4033
|
+
};
|
|
4034
|
+
}
|
|
4035
|
+
// IMPORTANT: do not change the property name or the assignment expression.
|
|
4036
|
+
// This line will be used in regexes to search for ReactiveElement usage.
|
|
4037
|
+
(global.reactiveElementVersions ??= []).push('2.0.4');
|
|
4038
|
+
if (global.reactiveElementVersions.length > 1) {
|
|
4039
|
+
issueWarning$2('multiple-versions', `Multiple versions of Lit loaded. Loading multiple versions ` +
|
|
4040
|
+
`is not recommended.`);
|
|
4041
|
+
}
|
|
4042
|
+
|
|
4043
|
+
/**
|
|
4044
|
+
* @license
|
|
4045
|
+
* Copyright 2017 Google LLC
|
|
4046
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
4047
|
+
*/
|
|
4048
|
+
/*
|
|
4049
|
+
* When using Closure Compiler, JSCompiler_renameProperty(property, object) is
|
|
4050
|
+
* replaced at compile time by the munged name for object[property]. We cannot
|
|
4051
|
+
* alias this function, so we have to use a small shim that has the same
|
|
4052
|
+
* behavior when not compiling.
|
|
4053
|
+
*/
|
|
4054
|
+
/*@__INLINE__*/
|
|
4055
|
+
const JSCompiler_renameProperty = (prop, _obj) => prop;
|
|
4056
|
+
let issueWarning$1;
|
|
4057
|
+
{
|
|
4058
|
+
// Ensure warnings are issued only 1x, even if multiple versions of Lit
|
|
4059
|
+
// are loaded.
|
|
4060
|
+
const issuedWarnings = (globalThis.litIssuedWarnings ??= new Set());
|
|
4061
|
+
// Issue a warning, if we haven't already.
|
|
4062
|
+
issueWarning$1 = (code, warning) => {
|
|
4063
|
+
warning += ` See https://lit.dev/msg/${code} for more information.`;
|
|
4064
|
+
if (!issuedWarnings.has(warning)) {
|
|
4065
|
+
console.warn(warning);
|
|
4066
|
+
issuedWarnings.add(warning);
|
|
4067
|
+
}
|
|
4068
|
+
};
|
|
4069
|
+
}
|
|
4070
|
+
/**
|
|
4071
|
+
* Base element class that manages element properties and attributes, and
|
|
4072
|
+
* renders a lit-html template.
|
|
4073
|
+
*
|
|
4074
|
+
* To define a component, subclass `LitElement` and implement a
|
|
4075
|
+
* `render` method to provide the component's template. Define properties
|
|
4076
|
+
* using the {@linkcode LitElement.properties properties} property or the
|
|
4077
|
+
* {@linkcode property} decorator.
|
|
4078
|
+
*/
|
|
4079
|
+
class LitElement extends ReactiveElement {
|
|
4080
|
+
constructor() {
|
|
4081
|
+
super(...arguments);
|
|
4082
|
+
/**
|
|
4083
|
+
* @category rendering
|
|
4084
|
+
*/
|
|
4085
|
+
this.renderOptions = { host: this };
|
|
4086
|
+
this.__childPart = undefined;
|
|
4087
|
+
}
|
|
4088
|
+
/**
|
|
4089
|
+
* @category rendering
|
|
4090
|
+
*/
|
|
4091
|
+
createRenderRoot() {
|
|
4092
|
+
const renderRoot = super.createRenderRoot();
|
|
4093
|
+
// When adoptedStyleSheets are shimmed, they are inserted into the
|
|
4094
|
+
// shadowRoot by createRenderRoot. Adjust the renderBefore node so that
|
|
4095
|
+
// any styles in Lit content render before adoptedStyleSheets. This is
|
|
4096
|
+
// important so that adoptedStyleSheets have precedence over styles in
|
|
4097
|
+
// the shadowRoot.
|
|
4098
|
+
this.renderOptions.renderBefore ??= renderRoot.firstChild;
|
|
4099
|
+
return renderRoot;
|
|
4100
|
+
}
|
|
4101
|
+
/**
|
|
4102
|
+
* Updates the element. This method reflects property values to attributes
|
|
4103
|
+
* and calls `render` to render DOM via lit-html. Setting properties inside
|
|
4104
|
+
* this method will *not* trigger another update.
|
|
4105
|
+
* @param changedProperties Map of changed properties with old values
|
|
4106
|
+
* @category updates
|
|
4107
|
+
*/
|
|
4108
|
+
update(changedProperties) {
|
|
4109
|
+
// Setting properties in `render` should not trigger an update. Since
|
|
4110
|
+
// updates are allowed after super.update, it's important to call `render`
|
|
4111
|
+
// before that.
|
|
4112
|
+
const value = this.render();
|
|
4113
|
+
if (!this.hasUpdated) {
|
|
4114
|
+
this.renderOptions.isConnected = this.isConnected;
|
|
4115
|
+
}
|
|
4116
|
+
super.update(changedProperties);
|
|
4117
|
+
this.__childPart = render(value, this.renderRoot, this.renderOptions);
|
|
4118
|
+
}
|
|
4119
|
+
/**
|
|
4120
|
+
* Invoked when the component is added to the document's DOM.
|
|
4121
|
+
*
|
|
4122
|
+
* In `connectedCallback()` you should setup tasks that should only occur when
|
|
4123
|
+
* the element is connected to the document. The most common of these is
|
|
4124
|
+
* adding event listeners to nodes external to the element, like a keydown
|
|
4125
|
+
* event handler added to the window.
|
|
4126
|
+
*
|
|
4127
|
+
* ```ts
|
|
4128
|
+
* connectedCallback() {
|
|
4129
|
+
* super.connectedCallback();
|
|
4130
|
+
* addEventListener('keydown', this._handleKeydown);
|
|
4131
|
+
* }
|
|
4132
|
+
* ```
|
|
4133
|
+
*
|
|
4134
|
+
* Typically, anything done in `connectedCallback()` should be undone when the
|
|
4135
|
+
* element is disconnected, in `disconnectedCallback()`.
|
|
4136
|
+
*
|
|
4137
|
+
* @category lifecycle
|
|
4138
|
+
*/
|
|
4139
|
+
connectedCallback() {
|
|
4140
|
+
super.connectedCallback();
|
|
4141
|
+
this.__childPart?.setConnected(true);
|
|
4142
|
+
}
|
|
4143
|
+
/**
|
|
4144
|
+
* Invoked when the component is removed from the document's DOM.
|
|
4145
|
+
*
|
|
4146
|
+
* This callback is the main signal to the element that it may no longer be
|
|
4147
|
+
* used. `disconnectedCallback()` should ensure that nothing is holding a
|
|
4148
|
+
* reference to the element (such as event listeners added to nodes external
|
|
4149
|
+
* to the element), so that it is free to be garbage collected.
|
|
4150
|
+
*
|
|
4151
|
+
* ```ts
|
|
4152
|
+
* disconnectedCallback() {
|
|
4153
|
+
* super.disconnectedCallback();
|
|
4154
|
+
* window.removeEventListener('keydown', this._handleKeydown);
|
|
4155
|
+
* }
|
|
4156
|
+
* ```
|
|
4157
|
+
*
|
|
4158
|
+
* An element may be re-connected after being disconnected.
|
|
4159
|
+
*
|
|
4160
|
+
* @category lifecycle
|
|
4161
|
+
*/
|
|
4162
|
+
disconnectedCallback() {
|
|
4163
|
+
super.disconnectedCallback();
|
|
4164
|
+
this.__childPart?.setConnected(false);
|
|
4165
|
+
}
|
|
4166
|
+
/**
|
|
4167
|
+
* Invoked on each update to perform rendering tasks. This method may return
|
|
4168
|
+
* any value renderable by lit-html's `ChildPart` - typically a
|
|
4169
|
+
* `TemplateResult`. Setting properties inside this method will *not* trigger
|
|
4170
|
+
* the element to update.
|
|
4171
|
+
* @category rendering
|
|
4172
|
+
*/
|
|
4173
|
+
render() {
|
|
4174
|
+
return noChange;
|
|
4175
|
+
}
|
|
4176
|
+
}
|
|
4177
|
+
// This property needs to remain unminified.
|
|
4178
|
+
LitElement['_$litElement$'] = true;
|
|
4179
|
+
/**
|
|
4180
|
+
* Ensure this class is marked as `finalized` as an optimization ensuring
|
|
4181
|
+
* it will not needlessly try to `finalize`.
|
|
4182
|
+
*
|
|
4183
|
+
* Note this property name is a string to prevent breaking Closure JS Compiler
|
|
4184
|
+
* optimizations. See @lit/reactive-element for more information.
|
|
4185
|
+
*/
|
|
4186
|
+
LitElement[JSCompiler_renameProperty('finalized')] = true;
|
|
4187
|
+
// Install hydration if available
|
|
4188
|
+
globalThis.litElementHydrateSupport?.({ LitElement });
|
|
4189
|
+
// Apply polyfills if available
|
|
4190
|
+
const polyfillSupport = globalThis.litElementPolyfillSupportDevMode
|
|
4191
|
+
;
|
|
4192
|
+
polyfillSupport?.({ LitElement });
|
|
4193
|
+
// IMPORTANT: do not change the property name or the assignment expression.
|
|
4194
|
+
// This line will be used in regexes to search for LitElement usage.
|
|
4195
|
+
(globalThis.litElementVersions ??= []).push('4.1.0');
|
|
4196
|
+
if (globalThis.litElementVersions.length > 1) {
|
|
4197
|
+
issueWarning$1('multiple-versions', `Multiple versions of Lit loaded. Loading multiple versions ` +
|
|
4198
|
+
`is not recommended.`);
|
|
4199
|
+
}
|
|
4200
|
+
|
|
4201
|
+
/**
|
|
4202
|
+
* @license
|
|
4203
|
+
* Copyright 2017 Google LLC
|
|
4204
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
4205
|
+
*/
|
|
4206
|
+
let issueWarning;
|
|
4207
|
+
{
|
|
4208
|
+
// Ensure warnings are issued only 1x, even if multiple versions of Lit
|
|
4209
|
+
// are loaded.
|
|
4210
|
+
const issuedWarnings = (globalThis.litIssuedWarnings ??= new Set());
|
|
4211
|
+
// Issue a warning, if we haven't already.
|
|
4212
|
+
issueWarning = (code, warning) => {
|
|
4213
|
+
warning += ` See https://lit.dev/msg/${code} for more information.`;
|
|
4214
|
+
if (!issuedWarnings.has(warning)) {
|
|
4215
|
+
console.warn(warning);
|
|
4216
|
+
issuedWarnings.add(warning);
|
|
4217
|
+
}
|
|
4218
|
+
};
|
|
4219
|
+
}
|
|
4220
|
+
const legacyProperty = (options, proto, name) => {
|
|
4221
|
+
const hasOwnProperty = proto.hasOwnProperty(name);
|
|
4222
|
+
proto.constructor.createProperty(name, hasOwnProperty ? { ...options, wrapped: true } : options);
|
|
4223
|
+
// For accessors (which have a descriptor on the prototype) we need to
|
|
4224
|
+
// return a descriptor, otherwise TypeScript overwrites the descriptor we
|
|
4225
|
+
// define in createProperty() with the original descriptor. We don't do this
|
|
4226
|
+
// for fields, which don't have a descriptor, because this could overwrite
|
|
4227
|
+
// descriptor defined by other decorators.
|
|
4228
|
+
return hasOwnProperty
|
|
4229
|
+
? Object.getOwnPropertyDescriptor(proto, name)
|
|
4230
|
+
: undefined;
|
|
4231
|
+
};
|
|
4232
|
+
// This is duplicated from a similar variable in reactive-element.ts, but
|
|
4233
|
+
// actually makes sense to have this default defined with the decorator, so
|
|
4234
|
+
// that different decorators could have different defaults.
|
|
4235
|
+
const defaultPropertyDeclaration = {
|
|
4236
|
+
attribute: true,
|
|
4237
|
+
type: String,
|
|
4238
|
+
converter: defaultConverter$1,
|
|
4239
|
+
reflect: false,
|
|
4240
|
+
hasChanged: notEqual$1,
|
|
4241
|
+
};
|
|
4242
|
+
/**
|
|
4243
|
+
* Wraps a class accessor or setter so that `requestUpdate()` is called with the
|
|
4244
|
+
* property name and old value when the accessor is set.
|
|
4245
|
+
*/
|
|
4246
|
+
const standardProperty = (options = defaultPropertyDeclaration, target, context) => {
|
|
4247
|
+
const { kind, metadata } = context;
|
|
4248
|
+
if (metadata == null) {
|
|
4249
|
+
issueWarning('missing-class-metadata', `The class ${target} is missing decorator metadata. This ` +
|
|
4250
|
+
`could mean that you're using a compiler that supports decorators ` +
|
|
4251
|
+
`but doesn't support decorator metadata, such as TypeScript 5.1. ` +
|
|
4252
|
+
`Please update your compiler.`);
|
|
4253
|
+
}
|
|
4254
|
+
// Store the property options
|
|
4255
|
+
let properties = globalThis.litPropertyMetadata.get(metadata);
|
|
4256
|
+
if (properties === undefined) {
|
|
4257
|
+
globalThis.litPropertyMetadata.set(metadata, (properties = new Map()));
|
|
4258
|
+
}
|
|
4259
|
+
properties.set(context.name, options);
|
|
4260
|
+
if (kind === 'accessor') {
|
|
4261
|
+
// Standard decorators cannot dynamically modify the class, so we can't
|
|
4262
|
+
// replace a field with accessors. The user must use the new `accessor`
|
|
4263
|
+
// keyword instead.
|
|
4264
|
+
const { name } = context;
|
|
4265
|
+
return {
|
|
4266
|
+
set(v) {
|
|
4267
|
+
const oldValue = target.get.call(this);
|
|
4268
|
+
target.set.call(this, v);
|
|
4269
|
+
this.requestUpdate(name, oldValue, options);
|
|
4270
|
+
},
|
|
4271
|
+
init(v) {
|
|
4272
|
+
if (v !== undefined) {
|
|
4273
|
+
this._$changeProperty(name, undefined, options);
|
|
4274
|
+
}
|
|
4275
|
+
return v;
|
|
4276
|
+
},
|
|
4277
|
+
};
|
|
4278
|
+
}
|
|
4279
|
+
else if (kind === 'setter') {
|
|
4280
|
+
const { name } = context;
|
|
4281
|
+
return function (value) {
|
|
4282
|
+
const oldValue = this[name];
|
|
4283
|
+
target.call(this, value);
|
|
4284
|
+
this.requestUpdate(name, oldValue, options);
|
|
4285
|
+
};
|
|
4286
|
+
}
|
|
4287
|
+
throw new Error(`Unsupported decorator location: ${kind}`);
|
|
4288
|
+
};
|
|
4289
|
+
/**
|
|
4290
|
+
* A class field or accessor decorator which creates a reactive property that
|
|
4291
|
+
* reflects a corresponding attribute value. When a decorated property is set
|
|
4292
|
+
* the element will update and render. A {@linkcode PropertyDeclaration} may
|
|
4293
|
+
* optionally be supplied to configure property features.
|
|
4294
|
+
*
|
|
4295
|
+
* This decorator should only be used for public fields. As public fields,
|
|
4296
|
+
* properties should be considered as primarily settable by element users,
|
|
4297
|
+
* either via attribute or the property itself.
|
|
4298
|
+
*
|
|
4299
|
+
* Generally, properties that are changed by the element should be private or
|
|
4300
|
+
* protected fields and should use the {@linkcode state} decorator.
|
|
4301
|
+
*
|
|
4302
|
+
* However, sometimes element code does need to set a public property. This
|
|
4303
|
+
* should typically only be done in response to user interaction, and an event
|
|
4304
|
+
* should be fired informing the user; for example, a checkbox sets its
|
|
4305
|
+
* `checked` property when clicked and fires a `changed` event. Mutating public
|
|
4306
|
+
* properties should typically not be done for non-primitive (object or array)
|
|
4307
|
+
* properties. In other cases when an element needs to manage state, a private
|
|
4308
|
+
* property decorated via the {@linkcode state} decorator should be used. When
|
|
4309
|
+
* needed, state properties can be initialized via public properties to
|
|
4310
|
+
* facilitate complex interactions.
|
|
4311
|
+
*
|
|
4312
|
+
* ```ts
|
|
4313
|
+
* class MyElement {
|
|
4314
|
+
* @property({ type: Boolean })
|
|
4315
|
+
* clicked = false;
|
|
4316
|
+
* }
|
|
4317
|
+
* ```
|
|
4318
|
+
* @category Decorator
|
|
4319
|
+
* @ExportDecoratedItems
|
|
4320
|
+
*/
|
|
4321
|
+
function property(options) {
|
|
4322
|
+
return (protoOrTarget, nameOrContext
|
|
4323
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4324
|
+
) => {
|
|
4325
|
+
return (typeof nameOrContext === 'object'
|
|
4326
|
+
? standardProperty(options, protoOrTarget, nameOrContext)
|
|
4327
|
+
: legacyProperty(options, protoOrTarget, nameOrContext));
|
|
4328
|
+
};
|
|
4329
|
+
}
|
|
4330
|
+
|
|
4331
|
+
/**
|
|
4332
|
+
* @license
|
|
4333
|
+
* Copyright 2017 Google LLC
|
|
4334
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
4335
|
+
*/
|
|
4336
|
+
/**
|
|
4337
|
+
* Declares a private or protected reactive property that still triggers
|
|
4338
|
+
* updates to the element when it changes. It does not reflect from the
|
|
4339
|
+
* corresponding attribute.
|
|
4340
|
+
*
|
|
4341
|
+
* Properties declared this way must not be used from HTML or HTML templating
|
|
4342
|
+
* systems, they're solely for properties internal to the element. These
|
|
4343
|
+
* properties may be renamed by optimization tools like closure compiler.
|
|
4344
|
+
* @category Decorator
|
|
4345
|
+
*/
|
|
4346
|
+
function state(options) {
|
|
4347
|
+
return property({
|
|
4348
|
+
...options,
|
|
4349
|
+
// Add both `state` and `attribute` because we found a third party
|
|
4350
|
+
// controller that is keying off of PropertyOptions.state to determine
|
|
4351
|
+
// whether a field is a private internal property or not.
|
|
4352
|
+
state: true,
|
|
4353
|
+
attribute: false,
|
|
4354
|
+
});
|
|
4355
|
+
}
|
|
4356
|
+
|
|
4357
|
+
/**
|
|
4358
|
+
* @license
|
|
4359
|
+
* Copyright 2017 Google LLC
|
|
4360
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
4361
|
+
*/
|
|
4362
|
+
/**
|
|
4363
|
+
* Wraps up a few best practices when returning a property descriptor from a
|
|
4364
|
+
* decorator.
|
|
4365
|
+
*
|
|
4366
|
+
* Marks the defined property as configurable, and enumerable, and handles
|
|
4367
|
+
* the case where we have a busted Reflect.decorate zombiefill (e.g. in Angular
|
|
4368
|
+
* apps).
|
|
4369
|
+
*
|
|
4370
|
+
* @internal
|
|
4371
|
+
*/
|
|
4372
|
+
const desc = (obj, name, descriptor) => {
|
|
4373
|
+
// For backwards compatibility, we keep them configurable and enumerable.
|
|
4374
|
+
descriptor.configurable = true;
|
|
4375
|
+
descriptor.enumerable = true;
|
|
4376
|
+
if (
|
|
4377
|
+
// We check for Reflect.decorate each time, in case the zombiefill
|
|
4378
|
+
// is applied via lazy loading some Angular code.
|
|
4379
|
+
Reflect.decorate &&
|
|
4380
|
+
typeof name !== 'object') {
|
|
4381
|
+
// If we're called as a legacy decorator, and Reflect.decorate is present
|
|
4382
|
+
// then we have no guarantees that the returned descriptor will be
|
|
4383
|
+
// defined on the class, so we must apply it directly ourselves.
|
|
4384
|
+
Object.defineProperty(obj, name, descriptor);
|
|
4385
|
+
}
|
|
4386
|
+
return descriptor;
|
|
4387
|
+
};
|
|
4388
|
+
|
|
4389
|
+
/**
|
|
4390
|
+
* @license
|
|
4391
|
+
* Copyright 2017 Google LLC
|
|
4392
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
4393
|
+
*/
|
|
4394
|
+
{
|
|
4395
|
+
// Ensure warnings are issued only 1x, even if multiple versions of Lit
|
|
4396
|
+
// are loaded.
|
|
4397
|
+
(globalThis.litIssuedWarnings ??= new Set());
|
|
4398
|
+
}
|
|
4399
|
+
|
|
4400
|
+
/**
|
|
4401
|
+
* @license
|
|
4402
|
+
* Copyright 2017 Google LLC
|
|
4403
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
4404
|
+
*/
|
|
4405
|
+
// Note, in the future, we may extend this decorator to support the use case
|
|
4406
|
+
// where the queried element may need to do work to become ready to interact
|
|
4407
|
+
// with (e.g. load some implementation code). If so, we might elect to
|
|
4408
|
+
// add a second argument defining a function that can be run to make the
|
|
4409
|
+
// queried element loaded/updated/ready.
|
|
4410
|
+
/**
|
|
4411
|
+
* A property decorator that converts a class property into a getter that
|
|
4412
|
+
* returns a promise that resolves to the result of a querySelector on the
|
|
4413
|
+
* element's renderRoot done after the element's `updateComplete` promise
|
|
4414
|
+
* resolves. When the queried property may change with element state, this
|
|
4415
|
+
* decorator can be used instead of requiring users to await the
|
|
4416
|
+
* `updateComplete` before accessing the property.
|
|
4417
|
+
*
|
|
4418
|
+
* @param selector A DOMString containing one or more selectors to match.
|
|
4419
|
+
*
|
|
4420
|
+
* See: https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector
|
|
4421
|
+
*
|
|
4422
|
+
* ```ts
|
|
4423
|
+
* class MyElement {
|
|
4424
|
+
* @queryAsync('#first')
|
|
4425
|
+
* first: Promise<HTMLDivElement>;
|
|
4426
|
+
*
|
|
4427
|
+
* render() {
|
|
4428
|
+
* return html`
|
|
4429
|
+
* <div id="first"></div>
|
|
4430
|
+
* <div id="second"></div>
|
|
4431
|
+
* `;
|
|
4432
|
+
* }
|
|
4433
|
+
* }
|
|
4434
|
+
*
|
|
4435
|
+
* // external usage
|
|
4436
|
+
* async doSomethingWithFirst() {
|
|
4437
|
+
* (await aMyElement.first).doSomething();
|
|
4438
|
+
* }
|
|
4439
|
+
* ```
|
|
4440
|
+
* @category Decorator
|
|
4441
|
+
*/
|
|
4442
|
+
function queryAsync(selector) {
|
|
4443
|
+
return ((obj, name) => {
|
|
4444
|
+
return desc(obj, name, {
|
|
4445
|
+
async get() {
|
|
4446
|
+
await this.updateComplete;
|
|
4447
|
+
return this.renderRoot?.querySelector(selector) ?? null;
|
|
4448
|
+
},
|
|
4449
|
+
});
|
|
4450
|
+
});
|
|
4451
|
+
}
|
|
4452
|
+
|
|
4453
|
+
/**
|
|
4454
|
+
* @license
|
|
4455
|
+
* Copyright 2017 Google LLC
|
|
4456
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
4457
|
+
*/
|
|
4458
|
+
const PartType = {
|
|
4459
|
+
ATTRIBUTE: 1,
|
|
4460
|
+
CHILD: 2,
|
|
4461
|
+
PROPERTY: 3,
|
|
4462
|
+
BOOLEAN_ATTRIBUTE: 4,
|
|
4463
|
+
EVENT: 5,
|
|
4464
|
+
ELEMENT: 6,
|
|
4465
|
+
};
|
|
4466
|
+
/**
|
|
4467
|
+
* Creates a user-facing directive function from a Directive class. This
|
|
4468
|
+
* function has the same parameters as the directive's render() method.
|
|
4469
|
+
*/
|
|
4470
|
+
const directive = (c) => (...values) => ({
|
|
4471
|
+
// This property needs to remain unminified.
|
|
4472
|
+
['_$litDirective$']: c,
|
|
4473
|
+
values,
|
|
4474
|
+
});
|
|
4475
|
+
/**
|
|
4476
|
+
* Base class for creating custom directives. Users should extend this class,
|
|
4477
|
+
* implement `render` and/or `update`, and then pass their subclass to
|
|
4478
|
+
* `directive`.
|
|
4479
|
+
*/
|
|
4480
|
+
class Directive {
|
|
4481
|
+
constructor(_partInfo) { }
|
|
4482
|
+
// See comment in Disconnectable interface for why this is a getter
|
|
4483
|
+
get _$isConnected() {
|
|
4484
|
+
return this._$parent._$isConnected;
|
|
4485
|
+
}
|
|
4486
|
+
/** @internal */
|
|
4487
|
+
_$initialize(part, parent, attributeIndex) {
|
|
4488
|
+
this.__part = part;
|
|
4489
|
+
this._$parent = parent;
|
|
4490
|
+
this.__attributeIndex = attributeIndex;
|
|
4491
|
+
}
|
|
4492
|
+
/** @internal */
|
|
4493
|
+
_$resolve(part, props) {
|
|
4494
|
+
return this.update(part, props);
|
|
4495
|
+
}
|
|
4496
|
+
update(_part, props) {
|
|
4497
|
+
return this.render(...props);
|
|
4498
|
+
}
|
|
4499
|
+
}
|
|
4500
|
+
|
|
4501
|
+
/**
|
|
4502
|
+
* @license
|
|
4503
|
+
* Copyright 2018 Google LLC
|
|
4504
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
4505
|
+
*/
|
|
4506
|
+
class ClassMapDirective extends Directive {
|
|
4507
|
+
constructor(partInfo) {
|
|
4508
|
+
super(partInfo);
|
|
4509
|
+
if (partInfo.type !== PartType.ATTRIBUTE ||
|
|
4510
|
+
partInfo.name !== 'class' ||
|
|
4511
|
+
partInfo.strings?.length > 2) {
|
|
4512
|
+
throw new Error('`classMap()` can only be used in the `class` attribute ' +
|
|
4513
|
+
'and must be the only part in the attribute.');
|
|
4514
|
+
}
|
|
4515
|
+
}
|
|
4516
|
+
render(classInfo) {
|
|
4517
|
+
// Add spaces to ensure separation from static classes
|
|
4518
|
+
return (' ' +
|
|
4519
|
+
Object.keys(classInfo)
|
|
4520
|
+
.filter((key) => classInfo[key])
|
|
4521
|
+
.join(' ') +
|
|
4522
|
+
' ');
|
|
4523
|
+
}
|
|
4524
|
+
update(part, [classInfo]) {
|
|
4525
|
+
// Remember dynamic classes on the first render
|
|
4526
|
+
if (this._previousClasses === undefined) {
|
|
4527
|
+
this._previousClasses = new Set();
|
|
4528
|
+
if (part.strings !== undefined) {
|
|
4529
|
+
this._staticClasses = new Set(part.strings
|
|
4530
|
+
.join(' ')
|
|
4531
|
+
.split(/\s/)
|
|
4532
|
+
.filter((s) => s !== ''));
|
|
4533
|
+
}
|
|
4534
|
+
for (const name in classInfo) {
|
|
4535
|
+
if (classInfo[name] && !this._staticClasses?.has(name)) {
|
|
4536
|
+
this._previousClasses.add(name);
|
|
4537
|
+
}
|
|
4538
|
+
}
|
|
4539
|
+
return this.render(classInfo);
|
|
4540
|
+
}
|
|
4541
|
+
const classList = part.element.classList;
|
|
4542
|
+
// Remove old classes that no longer apply
|
|
4543
|
+
for (const name of this._previousClasses) {
|
|
4544
|
+
if (!(name in classInfo)) {
|
|
4545
|
+
classList.remove(name);
|
|
4546
|
+
this._previousClasses.delete(name);
|
|
4547
|
+
}
|
|
4548
|
+
}
|
|
4549
|
+
// Add or remove classes based on their classMap value
|
|
4550
|
+
for (const name in classInfo) {
|
|
4551
|
+
// We explicitly want a loose truthy check of `value` because it seems
|
|
4552
|
+
// more convenient that '' and 0 are skipped.
|
|
4553
|
+
const value = !!classInfo[name];
|
|
4554
|
+
if (value !== this._previousClasses.has(name) &&
|
|
4555
|
+
!this._staticClasses?.has(name)) {
|
|
4556
|
+
if (value) {
|
|
4557
|
+
classList.add(name);
|
|
4558
|
+
this._previousClasses.add(name);
|
|
4559
|
+
}
|
|
4560
|
+
else {
|
|
4561
|
+
classList.remove(name);
|
|
4562
|
+
this._previousClasses.delete(name);
|
|
4563
|
+
}
|
|
4564
|
+
}
|
|
4565
|
+
}
|
|
4566
|
+
return noChange;
|
|
4567
|
+
}
|
|
4568
|
+
}
|
|
4569
|
+
/**
|
|
4570
|
+
* A directive that applies dynamic CSS classes.
|
|
4571
|
+
*
|
|
4572
|
+
* This must be used in the `class` attribute and must be the only part used in
|
|
4573
|
+
* the attribute. It takes each property in the `classInfo` argument and adds
|
|
4574
|
+
* the property name to the element's `classList` if the property value is
|
|
4575
|
+
* truthy; if the property value is falsy, the property name is removed from
|
|
4576
|
+
* the element's `class`.
|
|
4577
|
+
*
|
|
4578
|
+
* For example `{foo: bar}` applies the class `foo` if the value of `bar` is
|
|
4579
|
+
* truthy.
|
|
4580
|
+
*
|
|
4581
|
+
* @param classInfo
|
|
4582
|
+
*/
|
|
4583
|
+
const classMap = directive(ClassMapDirective);
|
|
4584
|
+
|
|
4585
|
+
/**
|
|
4586
|
+
* @license
|
|
4587
|
+
* Copyright 2018 Google LLC
|
|
4588
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
4589
|
+
*/
|
|
4590
|
+
/**
|
|
4591
|
+
* For AttributeParts, sets the attribute if the value is defined and removes
|
|
4592
|
+
* the attribute if the value is undefined.
|
|
4593
|
+
*
|
|
4594
|
+
* For other part types, this directive is a no-op.
|
|
4595
|
+
*/
|
|
4596
|
+
const ifDefined = (value) => value ?? nothing;
|
|
4597
|
+
|
|
4598
|
+
/**
|
|
4599
|
+
* @license
|
|
4600
|
+
* Copyright 2020 Google LLC
|
|
4601
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
4602
|
+
*/
|
|
4603
|
+
window.ShadyDOM?.inUse &&
|
|
4604
|
+
window.ShadyDOM?.noPatch === true
|
|
4605
|
+
? window.ShadyDOM.wrap
|
|
4606
|
+
: (node) => node;
|
|
4607
|
+
/**
|
|
4608
|
+
* Tests whether a part has only a single-expression with no strings to
|
|
4609
|
+
* interpolate between.
|
|
4610
|
+
*
|
|
4611
|
+
* Only AttributePart and PropertyPart can have multiple expressions.
|
|
4612
|
+
* Multi-expression parts have a `strings` property and single-expression
|
|
4613
|
+
* parts do not.
|
|
4614
|
+
*/
|
|
4615
|
+
const isSingleExpression = (part) => part.strings === undefined;
|
|
4616
|
+
// A sentinel value that can never appear as a part value except when set by
|
|
4617
|
+
// live(). Used to force a dirty-check to fail and cause a re-render.
|
|
4618
|
+
const RESET_VALUE = {};
|
|
4619
|
+
/**
|
|
4620
|
+
* Sets the committed value of a ChildPart directly without triggering the
|
|
4621
|
+
* commit stage of the part.
|
|
4622
|
+
*
|
|
4623
|
+
* This is useful in cases where a directive needs to update the part such
|
|
4624
|
+
* that the next update detects a value change or not. When value is omitted,
|
|
4625
|
+
* the next update will be guaranteed to be detected as a change.
|
|
4626
|
+
*
|
|
4627
|
+
* @param part
|
|
4628
|
+
* @param value
|
|
4629
|
+
*/
|
|
4630
|
+
const setCommittedValue = (part, value = RESET_VALUE) => (part._$committedValue = value);
|
|
4631
|
+
|
|
4632
|
+
/**
|
|
4633
|
+
* @license
|
|
4634
|
+
* Copyright 2020 Google LLC
|
|
4635
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
4636
|
+
*/
|
|
4637
|
+
class LiveDirective extends Directive {
|
|
4638
|
+
constructor(partInfo) {
|
|
4639
|
+
super(partInfo);
|
|
4640
|
+
if (!(partInfo.type === PartType.PROPERTY ||
|
|
4641
|
+
partInfo.type === PartType.ATTRIBUTE ||
|
|
4642
|
+
partInfo.type === PartType.BOOLEAN_ATTRIBUTE)) {
|
|
4643
|
+
throw new Error('The `live` directive is not allowed on child or event bindings');
|
|
4644
|
+
}
|
|
4645
|
+
if (!isSingleExpression(partInfo)) {
|
|
4646
|
+
throw new Error('`live` bindings can only contain a single expression');
|
|
4647
|
+
}
|
|
4648
|
+
}
|
|
4649
|
+
render(value) {
|
|
4650
|
+
return value;
|
|
4651
|
+
}
|
|
4652
|
+
update(part, [value]) {
|
|
4653
|
+
if (value === noChange || value === nothing) {
|
|
4654
|
+
return value;
|
|
4655
|
+
}
|
|
4656
|
+
const element = part.element;
|
|
4657
|
+
const name = part.name;
|
|
4658
|
+
if (part.type === PartType.PROPERTY) {
|
|
4659
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4660
|
+
if (value === element[name]) {
|
|
4661
|
+
return noChange;
|
|
4662
|
+
}
|
|
4663
|
+
}
|
|
4664
|
+
else if (part.type === PartType.BOOLEAN_ATTRIBUTE) {
|
|
4665
|
+
if (!!value === element.hasAttribute(name)) {
|
|
4666
|
+
return noChange;
|
|
4667
|
+
}
|
|
4668
|
+
}
|
|
4669
|
+
else if (part.type === PartType.ATTRIBUTE) {
|
|
4670
|
+
if (element.getAttribute(name) === String(value)) {
|
|
4671
|
+
return noChange;
|
|
4672
|
+
}
|
|
4673
|
+
}
|
|
4674
|
+
// Resets the part's value, causing its dirty-check to fail so that it
|
|
4675
|
+
// always sets the value.
|
|
4676
|
+
setCommittedValue(part);
|
|
4677
|
+
return value;
|
|
4678
|
+
}
|
|
4679
|
+
}
|
|
4680
|
+
/**
|
|
4681
|
+
* Checks binding values against live DOM values, instead of previously bound
|
|
4682
|
+
* values, when determining whether to update the value.
|
|
4683
|
+
*
|
|
4684
|
+
* This is useful for cases where the DOM value may change from outside of
|
|
4685
|
+
* lit-html, such as with a binding to an `<input>` element's `value` property,
|
|
4686
|
+
* a content editable elements text, or to a custom element that changes it's
|
|
4687
|
+
* own properties or attributes.
|
|
4688
|
+
*
|
|
4689
|
+
* In these cases if the DOM value changes, but the value set through lit-html
|
|
4690
|
+
* bindings hasn't, lit-html won't know to update the DOM value and will leave
|
|
4691
|
+
* it alone. If this is not what you want--if you want to overwrite the DOM
|
|
4692
|
+
* value with the bound value no matter what--use the `live()` directive:
|
|
4693
|
+
*
|
|
4694
|
+
* ```js
|
|
4695
|
+
* html`<input .value=${live(x)}>`
|
|
4696
|
+
* ```
|
|
4697
|
+
*
|
|
4698
|
+
* `live()` performs a strict equality check against the live DOM value, and if
|
|
4699
|
+
* the new value is equal to the live value, does nothing. This means that
|
|
4700
|
+
* `live()` should not be used when the binding will cause a type conversion. If
|
|
4701
|
+
* you use `live()` with an attribute binding, make sure that only strings are
|
|
4702
|
+
* passed in, or the binding will update every render.
|
|
4703
|
+
*/
|
|
4704
|
+
const live = directive(LiveDirective);
|
|
4705
|
+
|
|
4706
|
+
/**
|
|
4707
|
+
* @license
|
|
4708
|
+
* Copyright 2017 Google LLC
|
|
4709
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
4710
|
+
*/
|
|
4711
|
+
const HTML_RESULT = 1;
|
|
4712
|
+
class UnsafeHTMLDirective extends Directive {
|
|
4713
|
+
constructor(partInfo) {
|
|
4714
|
+
super(partInfo);
|
|
4715
|
+
this._value = nothing;
|
|
4716
|
+
if (partInfo.type !== PartType.CHILD) {
|
|
4717
|
+
throw new Error(`${this.constructor.directiveName}() can only be used in child bindings`);
|
|
4718
|
+
}
|
|
4719
|
+
}
|
|
4720
|
+
render(value) {
|
|
4721
|
+
if (value === nothing || value == null) {
|
|
4722
|
+
this._templateResult = undefined;
|
|
4723
|
+
return (this._value = value);
|
|
4724
|
+
}
|
|
4725
|
+
if (value === noChange) {
|
|
4726
|
+
return value;
|
|
4727
|
+
}
|
|
4728
|
+
if (typeof value != 'string') {
|
|
4729
|
+
throw new Error(`${this.constructor.directiveName}() called with a non-string value`);
|
|
4730
|
+
}
|
|
4731
|
+
if (value === this._value) {
|
|
4732
|
+
return this._templateResult;
|
|
4733
|
+
}
|
|
4734
|
+
this._value = value;
|
|
4735
|
+
const strings = [value];
|
|
4736
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4737
|
+
strings.raw = strings;
|
|
4738
|
+
// WARNING: impersonating a TemplateResult like this is extremely
|
|
4739
|
+
// dangerous. Third-party directives should not do this.
|
|
4740
|
+
return (this._templateResult = {
|
|
4741
|
+
// Cast to a known set of integers that satisfy ResultType so that we
|
|
4742
|
+
// don't have to export ResultType and possibly encourage this pattern.
|
|
4743
|
+
// This property needs to remain unminified.
|
|
4744
|
+
['_$litType$']: this.constructor
|
|
4745
|
+
.resultType,
|
|
4746
|
+
strings,
|
|
4747
|
+
values: [],
|
|
4748
|
+
});
|
|
4749
|
+
}
|
|
4465
4750
|
}
|
|
4751
|
+
UnsafeHTMLDirective.directiveName = 'unsafeHTML';
|
|
4752
|
+
UnsafeHTMLDirective.resultType = HTML_RESULT;
|
|
4466
4753
|
|
|
4467
4754
|
/**
|
|
4468
4755
|
* @license
|
|
4469
4756
|
* Copyright 2017 Google LLC
|
|
4470
4757
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
4471
4758
|
*/
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
* replaced at compile time by the munged name for object[property]. We cannot
|
|
4475
|
-
* alias this function, so we have to use a small shim that has the same
|
|
4476
|
-
* behavior when not compiling.
|
|
4477
|
-
*/
|
|
4478
|
-
/*@__INLINE__*/
|
|
4479
|
-
const JSCompiler_renameProperty = (prop, _obj) => prop;
|
|
4480
|
-
let issueWarning;
|
|
4481
|
-
{
|
|
4482
|
-
// Ensure warnings are issued only 1x, even if multiple versions of Lit
|
|
4483
|
-
// are loaded.
|
|
4484
|
-
const issuedWarnings = (globalThis.litIssuedWarnings ??= new Set());
|
|
4485
|
-
// Issue a warning, if we haven't already.
|
|
4486
|
-
issueWarning = (code, warning) => {
|
|
4487
|
-
warning += ` See https://lit.dev/msg/${code} for more information.`;
|
|
4488
|
-
if (!issuedWarnings.has(warning)) {
|
|
4489
|
-
console.warn(warning);
|
|
4490
|
-
issuedWarnings.add(warning);
|
|
4491
|
-
}
|
|
4492
|
-
};
|
|
4759
|
+
const SVG_RESULT = 2;
|
|
4760
|
+
class UnsafeSVGDirective extends UnsafeHTMLDirective {
|
|
4493
4761
|
}
|
|
4762
|
+
UnsafeSVGDirective.directiveName = 'unsafeSVG';
|
|
4763
|
+
UnsafeSVGDirective.resultType = SVG_RESULT;
|
|
4494
4764
|
/**
|
|
4495
|
-
*
|
|
4496
|
-
* renders a lit-html template.
|
|
4765
|
+
* Renders the result as SVG, rather than text.
|
|
4497
4766
|
*
|
|
4498
|
-
*
|
|
4499
|
-
*
|
|
4500
|
-
*
|
|
4501
|
-
*
|
|
4767
|
+
* The values `undefined`, `null`, and `nothing`, will all result in no content
|
|
4768
|
+
* (empty string) being rendered.
|
|
4769
|
+
*
|
|
4770
|
+
* Note, this is unsafe to use with any user-provided input that hasn't been
|
|
4771
|
+
* sanitized or escaped, as it may lead to cross-site-scripting
|
|
4772
|
+
* vulnerabilities.
|
|
4502
4773
|
*/
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4774
|
+
const unsafeSVG = directive(UnsafeSVGDirective);
|
|
4775
|
+
|
|
4776
|
+
/**
|
|
4777
|
+
* @license
|
|
4778
|
+
* Copyright 2020 Google LLC
|
|
4779
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
4780
|
+
*/
|
|
4781
|
+
/**
|
|
4782
|
+
* Prevents JSON injection attacks.
|
|
4783
|
+
*
|
|
4784
|
+
* The goals of this brand:
|
|
4785
|
+
* 1) fast to check
|
|
4786
|
+
* 2) code is small on the wire
|
|
4787
|
+
* 3) multiple versions of Lit in a single page will all produce mutually
|
|
4788
|
+
* interoperable StaticValues
|
|
4789
|
+
* 4) normal JSON.parse (without an unusual reviver) can not produce a
|
|
4790
|
+
* StaticValue
|
|
4791
|
+
*
|
|
4792
|
+
* Symbols satisfy (1), (2), and (4). We use Symbol.for to satisfy (3), but
|
|
4793
|
+
* we don't care about the key, so we break ties via (2) and use the empty
|
|
4794
|
+
* string.
|
|
4795
|
+
*/
|
|
4796
|
+
const brand = Symbol.for('');
|
|
4797
|
+
/** Safely extracts the string part of a StaticValue. */
|
|
4798
|
+
const unwrapStaticValue = (value) => {
|
|
4799
|
+
if (value?.r !== brand) {
|
|
4800
|
+
return undefined;
|
|
4524
4801
|
}
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4802
|
+
return value?.['_$litStatic$'];
|
|
4803
|
+
};
|
|
4804
|
+
const stringsCache = new Map();
|
|
4805
|
+
/**
|
|
4806
|
+
* Wraps a lit-html template tag (`html` or `svg`) to add static value support.
|
|
4807
|
+
*/
|
|
4808
|
+
const withStatic = (coreTag) => (strings, ...values) => {
|
|
4809
|
+
const l = values.length;
|
|
4810
|
+
let staticValue;
|
|
4811
|
+
let dynamicValue;
|
|
4812
|
+
const staticStrings = [];
|
|
4813
|
+
const dynamicValues = [];
|
|
4814
|
+
let i = 0;
|
|
4815
|
+
let hasStatics = false;
|
|
4816
|
+
let s;
|
|
4817
|
+
while (i < l) {
|
|
4818
|
+
s = strings[i];
|
|
4819
|
+
// Collect any unsafeStatic values, and their following template strings
|
|
4820
|
+
// so that we treat a run of template strings and unsafe static values as
|
|
4821
|
+
// a single template string.
|
|
4822
|
+
while (i < l &&
|
|
4823
|
+
((dynamicValue = values[i]),
|
|
4824
|
+
(staticValue = unwrapStaticValue(dynamicValue))) !== undefined) {
|
|
4825
|
+
s += staticValue + strings[++i];
|
|
4826
|
+
hasStatics = true;
|
|
4539
4827
|
}
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
* In `connectedCallback()` you should setup tasks that should only occur when
|
|
4547
|
-
* the element is connected to the document. The most common of these is
|
|
4548
|
-
* adding event listeners to nodes external to the element, like a keydown
|
|
4549
|
-
* event handler added to the window.
|
|
4550
|
-
*
|
|
4551
|
-
* ```ts
|
|
4552
|
-
* connectedCallback() {
|
|
4553
|
-
* super.connectedCallback();
|
|
4554
|
-
* addEventListener('keydown', this._handleKeydown);
|
|
4555
|
-
* }
|
|
4556
|
-
* ```
|
|
4557
|
-
*
|
|
4558
|
-
* Typically, anything done in `connectedCallback()` should be undone when the
|
|
4559
|
-
* element is disconnected, in `disconnectedCallback()`.
|
|
4560
|
-
*
|
|
4561
|
-
* @category lifecycle
|
|
4562
|
-
*/
|
|
4563
|
-
connectedCallback() {
|
|
4564
|
-
super.connectedCallback();
|
|
4565
|
-
this.__childPart?.setConnected(true);
|
|
4566
|
-
}
|
|
4567
|
-
/**
|
|
4568
|
-
* Invoked when the component is removed from the document's DOM.
|
|
4569
|
-
*
|
|
4570
|
-
* This callback is the main signal to the element that it may no longer be
|
|
4571
|
-
* used. `disconnectedCallback()` should ensure that nothing is holding a
|
|
4572
|
-
* reference to the element (such as event listeners added to nodes external
|
|
4573
|
-
* to the element), so that it is free to be garbage collected.
|
|
4574
|
-
*
|
|
4575
|
-
* ```ts
|
|
4576
|
-
* disconnectedCallback() {
|
|
4577
|
-
* super.disconnectedCallback();
|
|
4578
|
-
* window.removeEventListener('keydown', this._handleKeydown);
|
|
4579
|
-
* }
|
|
4580
|
-
* ```
|
|
4581
|
-
*
|
|
4582
|
-
* An element may be re-connected after being disconnected.
|
|
4583
|
-
*
|
|
4584
|
-
* @category lifecycle
|
|
4585
|
-
*/
|
|
4586
|
-
disconnectedCallback() {
|
|
4587
|
-
super.disconnectedCallback();
|
|
4588
|
-
this.__childPart?.setConnected(false);
|
|
4828
|
+
// If the last value is static, we don't need to push it.
|
|
4829
|
+
if (i !== l) {
|
|
4830
|
+
dynamicValues.push(dynamicValue);
|
|
4831
|
+
}
|
|
4832
|
+
staticStrings.push(s);
|
|
4833
|
+
i++;
|
|
4589
4834
|
}
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
* the element to update.
|
|
4595
|
-
* @category rendering
|
|
4596
|
-
*/
|
|
4597
|
-
render() {
|
|
4598
|
-
return noChange;
|
|
4835
|
+
// If the last value isn't static (which would have consumed the last
|
|
4836
|
+
// string), then we need to add the last string.
|
|
4837
|
+
if (i === l) {
|
|
4838
|
+
staticStrings.push(strings[l]);
|
|
4599
4839
|
}
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
`is not recommended.`);
|
|
4623
|
-
}
|
|
4840
|
+
if (hasStatics) {
|
|
4841
|
+
const key = staticStrings.join('$$lit$$');
|
|
4842
|
+
strings = stringsCache.get(key);
|
|
4843
|
+
if (strings === undefined) {
|
|
4844
|
+
// Beware: in general this pattern is unsafe, and doing so may bypass
|
|
4845
|
+
// lit's security checks and allow an attacker to execute arbitrary
|
|
4846
|
+
// code and inject arbitrary content.
|
|
4847
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4848
|
+
staticStrings.raw = staticStrings;
|
|
4849
|
+
stringsCache.set(key, (strings = staticStrings));
|
|
4850
|
+
}
|
|
4851
|
+
values = dynamicValues;
|
|
4852
|
+
}
|
|
4853
|
+
return coreTag(strings, ...values);
|
|
4854
|
+
};
|
|
4855
|
+
/**
|
|
4856
|
+
* Interprets a template literal as an HTML template that can efficiently
|
|
4857
|
+
* render to and update a container.
|
|
4858
|
+
*
|
|
4859
|
+
* Includes static value support from `lit-html/static.js`.
|
|
4860
|
+
*/
|
|
4861
|
+
const html = withStatic(html$1);
|
|
4624
4862
|
|
|
4625
4863
|
var css_248z$7 = 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)}`;
|
|
4626
4864
|
|
|
4627
|
-
var css_248z$6 = css`.form-text{color:var(--sgds-form-color-subtle);font-size:var(--sgds-font-size-1)}`;
|
|
4865
|
+
var css_248z$6 = css`.form-text{color:var(--sgds-form-color-subtle);font-size:var(--sgds-font-size-1)}.form-text.disabled{opacity:var(--sgds-opacity-50)}`;
|
|
4628
4866
|
|
|
4629
|
-
var css_248z$5 = css`.form-label{margin-bottom:0}.form-
|
|
4867
|
+
var css_248z$5 = css`.form-label{color:var(--sgds-form-color);margin-bottom:0}.form-label.disabled{opacity:var(--sgds-opacity-50)}.form-check-label{color:var(--sgds-form-color)}.form-check-input:disabled~.form-check-label,.form-check-input[disabled]~.form-check-label{cursor:not-allowed}`;
|
|
4630
4868
|
|
|
4631
4869
|
var css_248z$4 = 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)}`;
|
|
4632
4870
|
|
|
@@ -4650,6 +4888,10 @@
|
|
|
4650
4888
|
}
|
|
4651
4889
|
SgdsElement.styles = [css_248z$3];
|
|
4652
4890
|
|
|
4891
|
+
function generateId (componentName = "", elementName = "") {
|
|
4892
|
+
return `id-${Math.random().toString().substring(2, 6)}-sgds-${componentName}-${elementName}`;
|
|
4893
|
+
}
|
|
4894
|
+
|
|
4653
4895
|
class FormControlElement extends SgdsElement {
|
|
4654
4896
|
constructor() {
|
|
4655
4897
|
super(...arguments);
|
|
@@ -4659,15 +4901,20 @@
|
|
|
4659
4901
|
this.hintText = "";
|
|
4660
4902
|
/** Disables the input. */
|
|
4661
4903
|
this.disabled = false;
|
|
4662
|
-
/** Allows invalidFeedback, invalid and valid styles to be visible with the input */
|
|
4663
|
-
this.hasFeedback = false;
|
|
4664
|
-
/**Feedback text for error state when validated */
|
|
4665
|
-
this.invalidFeedback = "";
|
|
4666
4904
|
/** Marks the component as invalid. Replace the pseudo :invalid selector for absent in custom elements */
|
|
4667
4905
|
this.invalid = false;
|
|
4668
|
-
|
|
4669
|
-
this.
|
|
4670
|
-
|
|
4906
|
+
this._controlId = generateId("input");
|
|
4907
|
+
this._labelId = generateId("label");
|
|
4908
|
+
}
|
|
4909
|
+
/** Programatically sets the invalid state of the input. Pass in boolean value in the argument */
|
|
4910
|
+
setInvalid(bool) {
|
|
4911
|
+
this.invalid = bool;
|
|
4912
|
+
if (bool) {
|
|
4913
|
+
this.emit("sgds-invalid");
|
|
4914
|
+
}
|
|
4915
|
+
else {
|
|
4916
|
+
this.emit("sgds-valid");
|
|
4917
|
+
}
|
|
4671
4918
|
}
|
|
4672
4919
|
}
|
|
4673
4920
|
FormControlElement.styles = [...SgdsElement.styles, css_248z$7, css_248z$6, css_248z$5, css_248z$4];
|
|
@@ -4683,69 +4930,9 @@
|
|
|
4683
4930
|
__decorate([
|
|
4684
4931
|
property({ type: Boolean, reflect: true })
|
|
4685
4932
|
], FormControlElement.prototype, "disabled", void 0);
|
|
4686
|
-
__decorate([
|
|
4687
|
-
property()
|
|
4688
|
-
], FormControlElement.prototype, "min", void 0);
|
|
4689
|
-
__decorate([
|
|
4690
|
-
property()
|
|
4691
|
-
], FormControlElement.prototype, "max", void 0);
|
|
4692
|
-
__decorate([
|
|
4693
|
-
property({ type: Boolean, reflect: true })
|
|
4694
|
-
], FormControlElement.prototype, "hasFeedback", void 0);
|
|
4695
|
-
__decorate([
|
|
4696
|
-
property({ type: String, reflect: true })
|
|
4697
|
-
], FormControlElement.prototype, "invalidFeedback", void 0);
|
|
4698
4933
|
__decorate([
|
|
4699
4934
|
property({ type: Boolean, reflect: true })
|
|
4700
4935
|
], FormControlElement.prototype, "invalid", void 0);
|
|
4701
|
-
__decorate([
|
|
4702
|
-
property({ type: Boolean, reflect: true })
|
|
4703
|
-
], FormControlElement.prototype, "required", void 0);
|
|
4704
|
-
|
|
4705
|
-
var css_248z$2 = css`:host{--sgds-spinner-bg:var(--sgds-primary-bg);display:inline-flex}:host([variant=neutral]){--sgds-spinner-bg:var(--sgds-neutral-color-emphasis)}.spinner-wrapper{align-items:center;display:flex;flex-direction:column;gap:var(--sgds-gap-2-xs)}.spinner{animation:spinner .75s linear infinite;border-radius:50%;border-right:.25em solid var(--sgds-alternate-bg);border:.25em solid var(--sgds-alternate-bg);border-right-color:var(--sgds-spinner-bg);color:var(--sgds-spinner-color);display:inline-flex;height:var(--sgds-dimension-32);width:var(--sgds-dimension-32)}.spinner-sm{height:var(--sgds-dimension-24);width:var(--sgds-dimension-24)}.spinner-lg{height:var(--sgds-dimension-48);width:var(--sgds-dimension-48)}.spinner-label{font-size:var(--sgds-font-size-1)}@media (prefers-reduced-motion:reduce){.spinner{animation-duration:1.5s}}
|
|
4706
|
-
|
|
4707
|
-
/*! CSS Used keyframes */@keyframes spinner{to{transform:rotate(1turn)}}.sr-only{clip:rect(0,0,0,0);border:0;height:1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}`;
|
|
4708
|
-
|
|
4709
|
-
var css_248z$1 = css`.text-primary{color:var(--sgds-primary-rgb)!important}.text-secondary{color:var(--sgds-secondary-rgb)!important}.text-success{color:var(--sgds-success-rgb)!important}.text-info{color:var(--sgds-info-rgb)!important}.text-warning{color:var(--sgds-warning-rgb)!important}.text-danger{color:var(--sgds-danger-rgb)!important}.text-light{color:var(--sgds-light-rgb)!important}.text-dark{color:var(--sgds-dark-rgb)!important}.text-muted{color:var(--sgds-secondary-color)!important}`;
|
|
4710
|
-
|
|
4711
|
-
/**
|
|
4712
|
-
* @summary Spinners notify the users that their request is being processed.
|
|
4713
|
-
*
|
|
4714
|
-
*/
|
|
4715
|
-
class SgdsSpinner extends SgdsElement {
|
|
4716
|
-
constructor() {
|
|
4717
|
-
super(...arguments);
|
|
4718
|
-
/** The variant of spinner */
|
|
4719
|
-
this.variant = "primary";
|
|
4720
|
-
/** Specifies a small, medium or large button, the size is medium by default. */
|
|
4721
|
-
this.size = "md";
|
|
4722
|
-
}
|
|
4723
|
-
render() {
|
|
4724
|
-
return html `
|
|
4725
|
-
<div class="spinner-wrapper">
|
|
4726
|
-
<div
|
|
4727
|
-
class="spinner ${classMap({
|
|
4728
|
-
[`spinner-${this.size}`]: this.size
|
|
4729
|
-
})}"
|
|
4730
|
-
role="status"
|
|
4731
|
-
>
|
|
4732
|
-
${this.label ? nothing : html `<span class="sr-only">Loading...</span>`}
|
|
4733
|
-
</div>
|
|
4734
|
-
${this.label ? html `<span class="spinner-label">${this.label}</span>` : nothing}
|
|
4735
|
-
</div>
|
|
4736
|
-
`;
|
|
4737
|
-
}
|
|
4738
|
-
}
|
|
4739
|
-
SgdsSpinner.styles = [...SgdsElement.styles, css_248z$1, css_248z$2];
|
|
4740
|
-
__decorate([
|
|
4741
|
-
property({ type: String, reflect: true })
|
|
4742
|
-
], SgdsSpinner.prototype, "variant", void 0);
|
|
4743
|
-
__decorate([
|
|
4744
|
-
property({ reflect: true })
|
|
4745
|
-
], SgdsSpinner.prototype, "size", void 0);
|
|
4746
|
-
__decorate([
|
|
4747
|
-
property({ reflect: true, type: String })
|
|
4748
|
-
], SgdsSpinner.prototype, "label", void 0);
|
|
4749
4936
|
|
|
4750
4937
|
// @defaultValue decorator
|
|
4751
4938
|
const defaultValue = (propertyName = "value") => (proto, key) => {
|
|
@@ -4767,135 +4954,225 @@
|
|
|
4767
4954
|
};
|
|
4768
4955
|
};
|
|
4769
4956
|
|
|
4770
|
-
|
|
4771
|
-
|
|
4957
|
+
/**
|
|
4958
|
+
* SGDS custom form validation methods and behaviours
|
|
4959
|
+
*/
|
|
4960
|
+
class InputValidationController {
|
|
4772
4961
|
constructor(host, options) {
|
|
4773
4962
|
(this.host = host).addController(this);
|
|
4774
|
-
this.
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
} }, options);
|
|
4781
|
-
this.handleFormData = this.handleFormData.bind(this);
|
|
4782
|
-
this.handleFormSubmit = this.handleFormSubmit.bind(this);
|
|
4783
|
-
this.handleFormReset = this.handleFormReset.bind(this);
|
|
4784
|
-
this.reportFormValidity = this.reportFormValidity.bind(this);
|
|
4963
|
+
this._internals = this.host.attachInternals();
|
|
4964
|
+
this.options = Object.assign({ setInvalid: (host, value) => {
|
|
4965
|
+
host.invalid = value;
|
|
4966
|
+
}, value: (host) => {
|
|
4967
|
+
return host.value;
|
|
4968
|
+
}, input: (host) => host.input }, options);
|
|
4785
4969
|
}
|
|
4786
4970
|
hostConnected() {
|
|
4787
|
-
this.
|
|
4788
|
-
if (this.form) {
|
|
4789
|
-
this.form.addEventListener("formdata", this.handleFormData);
|
|
4790
|
-
this.form.addEventListener("submit", this.handleFormSubmit);
|
|
4791
|
-
this.form.addEventListener("reset", this.handleFormReset);
|
|
4792
|
-
// Overload the form's reportValidity() method so it looks at Shoelace form controls
|
|
4793
|
-
if (!reportValidityOverloads.has(this.form)) {
|
|
4794
|
-
reportValidityOverloads.set(this.form, this.form.reportValidity);
|
|
4795
|
-
this.form.reportValidity = () => this.reportFormValidity();
|
|
4796
|
-
}
|
|
4797
|
-
}
|
|
4971
|
+
this.host.addEventListener("invalid", e => this.handleInvalid(e));
|
|
4798
4972
|
}
|
|
4799
4973
|
hostDisconnected() {
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4974
|
+
this.host.removeEventListener("invalid", e => this.handleInvalid(e));
|
|
4975
|
+
}
|
|
4976
|
+
/**
|
|
4977
|
+
* Prevents the native browser error message pop up when reportValidity() called by
|
|
4978
|
+
* associated form or the component's reportValidity during constraint validation
|
|
4979
|
+
* Sets invalid reactive prop to true
|
|
4980
|
+
*/
|
|
4981
|
+
handleInvalid(e) {
|
|
4982
|
+
e.preventDefault();
|
|
4983
|
+
this.options.setInvalid(this.host, true);
|
|
4984
|
+
}
|
|
4985
|
+
/**
|
|
4986
|
+
* Sets invalid to false when invoked and
|
|
4987
|
+
* Updates the ValidityState based on new value, but
|
|
4988
|
+
* does not update invalid reactive prop
|
|
4989
|
+
* @param e
|
|
4990
|
+
*/
|
|
4991
|
+
handleInput(e) {
|
|
4992
|
+
const input = e.target;
|
|
4993
|
+
this.options.setInvalid(this.host, false);
|
|
4994
|
+
this.validateInput(input);
|
|
4995
|
+
}
|
|
4996
|
+
/**
|
|
4997
|
+
* Validate the input's new value after onChange and
|
|
4998
|
+
* update invalid reactive prop
|
|
4999
|
+
* @param e
|
|
5000
|
+
*/
|
|
5001
|
+
handleChange(e) {
|
|
5002
|
+
const input = e.target;
|
|
5003
|
+
this.validateInput(input);
|
|
5004
|
+
this.options.setInvalid(this.host, !this.checkValidity());
|
|
5005
|
+
}
|
|
5006
|
+
get form() {
|
|
5007
|
+
return this._internals.form;
|
|
5008
|
+
}
|
|
5009
|
+
get validity() {
|
|
5010
|
+
return this._internals.validity;
|
|
4811
5011
|
}
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
5012
|
+
get validationMessage() {
|
|
5013
|
+
return this._internals.validationMessage;
|
|
5014
|
+
}
|
|
5015
|
+
get willValidate() {
|
|
5016
|
+
return this._internals.willValidate;
|
|
5017
|
+
}
|
|
5018
|
+
/**
|
|
5019
|
+
* Checks the validity and updates the invalid reactive prop of form components
|
|
5020
|
+
*/
|
|
5021
|
+
updateInvalidState() {
|
|
5022
|
+
this.options.setInvalid(this.host, !this.checkValidity());
|
|
5023
|
+
}
|
|
5024
|
+
/**
|
|
5025
|
+
* Resets the ValidityState of the control
|
|
5026
|
+
*/
|
|
5027
|
+
resetValidity() {
|
|
5028
|
+
return this._internals.setValidity({});
|
|
5029
|
+
}
|
|
5030
|
+
/**
|
|
5031
|
+
* Reports the validity
|
|
5032
|
+
*/
|
|
5033
|
+
checkValidity() {
|
|
5034
|
+
return this._internals.checkValidity();
|
|
5035
|
+
}
|
|
5036
|
+
/**
|
|
5037
|
+
* Reports the validity with a error popup message
|
|
5038
|
+
*/
|
|
5039
|
+
reportValidity() {
|
|
5040
|
+
return this._internals.reportValidity();
|
|
5041
|
+
}
|
|
5042
|
+
/**
|
|
5043
|
+
* Sets the form control value into FormData,
|
|
5044
|
+
* making the value of control accessible via FormData
|
|
5045
|
+
*/
|
|
5046
|
+
setFormValue() {
|
|
4815
5047
|
const value = this.options.value(this.host);
|
|
4816
|
-
|
|
4817
|
-
if (Array.isArray(value)) {
|
|
4818
|
-
value.forEach(val => {
|
|
4819
|
-
event.formData.append(name, val.toString());
|
|
4820
|
-
});
|
|
4821
|
-
}
|
|
4822
|
-
else {
|
|
4823
|
-
event.formData.append(name, value.toString());
|
|
4824
|
-
}
|
|
4825
|
-
}
|
|
5048
|
+
this._internals.setFormValue(value);
|
|
4826
5049
|
}
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
//
|
|
4849
|
-
// Note that we're also honoring the form's novalidate attribute.
|
|
4850
|
-
//
|
|
4851
|
-
if (this.form && !this.form.noValidate) {
|
|
4852
|
-
// This seems sloppy, but checking all elements will cover native inputs, Shoelace inputs, and other custom
|
|
4853
|
-
// elements that support the constraint validation API.
|
|
4854
|
-
const elements = this.form.querySelectorAll("*");
|
|
4855
|
-
for (const element of elements) {
|
|
4856
|
-
if (typeof element.reportValidity === "function") {
|
|
4857
|
-
if (!element.reportValidity()) {
|
|
4858
|
-
return false;
|
|
4859
|
-
}
|
|
5050
|
+
/**
|
|
5051
|
+
* Updates the ValidityState of the input in form component at current state
|
|
5052
|
+
*/
|
|
5053
|
+
validateInput(input) {
|
|
5054
|
+
/** When the form control is disabled, its always valid */
|
|
5055
|
+
if (this.options.input(this.host).disabled) {
|
|
5056
|
+
return this._internals.setValidity({});
|
|
5057
|
+
}
|
|
5058
|
+
// get the validity of the internal <input>
|
|
5059
|
+
const validState = input.validity;
|
|
5060
|
+
// if the input is invalid, show the correct error
|
|
5061
|
+
if (!validState.valid) {
|
|
5062
|
+
// loop through the error reasons
|
|
5063
|
+
for (const state in validState) {
|
|
5064
|
+
// if there is an error and corresponding attribute holding
|
|
5065
|
+
// the message
|
|
5066
|
+
if (validState[state]) {
|
|
5067
|
+
this.validationError = state.toString();
|
|
5068
|
+
// set the validity error reason and the corresponding
|
|
5069
|
+
// message
|
|
5070
|
+
this._internals.setValidity({ [this.validationError]: true }, input.validationMessage, input);
|
|
4860
5071
|
}
|
|
4861
5072
|
}
|
|
4862
5073
|
}
|
|
4863
|
-
|
|
5074
|
+
else {
|
|
5075
|
+
this._internals.setValidity({});
|
|
5076
|
+
}
|
|
4864
5077
|
}
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
5078
|
+
}
|
|
5079
|
+
|
|
5080
|
+
/**
|
|
5081
|
+
* @summary The FormValidationMixin used by the form components
|
|
5082
|
+
* @param superClass
|
|
5083
|
+
* @returns
|
|
5084
|
+
*/
|
|
5085
|
+
const SgdsFormValidatorMixin = (superClass) => {
|
|
5086
|
+
class ToBeValidatedElement extends superClass {
|
|
5087
|
+
constructor() {
|
|
5088
|
+
super(...arguments);
|
|
5089
|
+
this._isTouched = false;
|
|
5090
|
+
}
|
|
5091
|
+
connectedCallback() {
|
|
5092
|
+
super.connectedCallback();
|
|
5093
|
+
this.inputValidationController = new InputValidationController(this);
|
|
5094
|
+
}
|
|
5095
|
+
async firstUpdated(changedProperties) {
|
|
5096
|
+
super.firstUpdated(changedProperties);
|
|
5097
|
+
/* Either input or sgds-input. For example, quantity-toggle uses sgds-input */
|
|
5098
|
+
this.input =
|
|
5099
|
+
this.shadowRoot.querySelector("input") || (await this.sgdsInput) || this.shadowRoot.querySelector("textarea");
|
|
5100
|
+
this._mixinValidate(this.input);
|
|
5101
|
+
}
|
|
5102
|
+
/**
|
|
5103
|
+
* Native lifecycle of Form-Associated Custom Element Callbacks
|
|
5104
|
+
*/
|
|
5105
|
+
formResetCallback() {
|
|
5106
|
+
if (this._mixinResetFormControl) {
|
|
5107
|
+
this._mixinResetFormControl();
|
|
5108
|
+
}
|
|
5109
|
+
else {
|
|
5110
|
+
this.value = this.defaultValue;
|
|
5111
|
+
this._mixinResetValidity(this.input);
|
|
4882
5112
|
}
|
|
4883
|
-
this.
|
|
4884
|
-
|
|
4885
|
-
|
|
5113
|
+
this._mixinSetFormValue();
|
|
5114
|
+
}
|
|
5115
|
+
/**
|
|
5116
|
+
*
|
|
5117
|
+
* Methods use by classes using this mixin
|
|
5118
|
+
*/
|
|
5119
|
+
/**
|
|
5120
|
+
* OnChange of form component
|
|
5121
|
+
* 1. Make value of control accessible via FormData
|
|
5122
|
+
* 2. Run change handler
|
|
5123
|
+
*/
|
|
5124
|
+
_mixinHandleChange(e) {
|
|
5125
|
+
this._mixinSetFormValue();
|
|
5126
|
+
this.inputValidationController.handleChange(e);
|
|
5127
|
+
}
|
|
5128
|
+
/**
|
|
5129
|
+
* OnChange of form component
|
|
5130
|
+
* 1. Make value of control accessible via FormData
|
|
5131
|
+
* 2. Run input handler
|
|
5132
|
+
*/
|
|
5133
|
+
_mixinHandleInputChange(e) {
|
|
5134
|
+
this._mixinSetFormValue();
|
|
5135
|
+
this.inputValidationController.handleInput(e);
|
|
5136
|
+
}
|
|
5137
|
+
/**
|
|
5138
|
+
* During form resetting,
|
|
5139
|
+
* 1. ValidityState is reset
|
|
5140
|
+
* 2. invalid reactive prop is updated after the reset
|
|
5141
|
+
* 3. Revalidates the ValidityState (but do not update invalid prop)
|
|
5142
|
+
* to prepare for the next validity check
|
|
5143
|
+
* 4. Reset touched state to false for a pristine form
|
|
5144
|
+
*/
|
|
5145
|
+
_mixinResetValidity(input) {
|
|
5146
|
+
this.inputValidationController.resetValidity();
|
|
5147
|
+
this.inputValidationController.updateInvalidState();
|
|
5148
|
+
this.inputValidationController.validateInput(input);
|
|
5149
|
+
this._isTouched ? (this._isTouched = false) : null;
|
|
5150
|
+
}
|
|
5151
|
+
_mixinValidate(input) {
|
|
5152
|
+
this.inputValidationController.validateInput(input);
|
|
5153
|
+
}
|
|
5154
|
+
_mixinSetFormValue() {
|
|
5155
|
+
this.inputValidationController.setFormValue();
|
|
5156
|
+
}
|
|
5157
|
+
_mixinCheckValidity() {
|
|
5158
|
+
return this.inputValidationController.checkValidity();
|
|
5159
|
+
}
|
|
5160
|
+
_mixinReportValidity() {
|
|
5161
|
+
return this.inputValidationController.reportValidity();
|
|
5162
|
+
}
|
|
5163
|
+
_mixinGetValidity() {
|
|
5164
|
+
return this.inputValidationController.validity;
|
|
5165
|
+
}
|
|
5166
|
+
_mixinGetValidationMessage() {
|
|
5167
|
+
return this.inputValidationController.validationMessage;
|
|
4886
5168
|
}
|
|
4887
5169
|
}
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
// Calling form.submit() bypasses the submit event and constraint validation. To prevent this, we can inject a
|
|
4895
|
-
// native submit button into the form, "click" it, then remove it to simulate a standard form submission.
|
|
4896
|
-
this.doAction("submit", invoker);
|
|
4897
|
-
}
|
|
4898
|
-
}
|
|
5170
|
+
ToBeValidatedElement.formAssociated = true;
|
|
5171
|
+
__decorate([
|
|
5172
|
+
queryAsync("sgds-input")
|
|
5173
|
+
], ToBeValidatedElement.prototype, "sgdsInput", void 0);
|
|
5174
|
+
return ToBeValidatedElement;
|
|
5175
|
+
};
|
|
4899
5176
|
|
|
4900
5177
|
// @watch decorator
|
|
4901
5178
|
//
|
|
@@ -4934,6 +5211,51 @@
|
|
|
4934
5211
|
};
|
|
4935
5212
|
}
|
|
4936
5213
|
|
|
5214
|
+
var css_248z$2 = css`:host{--sgds-spinner-bg:var(--sgds-primary-bg);display:inline-flex}:host([variant=neutral]){--sgds-spinner-bg:var(--sgds-neutral-color-emphasis)}.spinner-wrapper{align-items:center;display:flex;flex-direction:column;gap:var(--sgds-gap-2-xs)}.spinner{animation:spinner .75s linear infinite;border-radius:50%;border-right:.25em solid var(--sgds-alternate-bg);border:.25em solid var(--sgds-alternate-bg);border-right-color:var(--sgds-spinner-bg);color:var(--sgds-spinner-color);display:inline-flex;height:var(--sgds-dimension-32);width:var(--sgds-dimension-32)}.spinner-sm{height:var(--sgds-dimension-24);width:var(--sgds-dimension-24)}.spinner-lg{height:var(--sgds-dimension-48);width:var(--sgds-dimension-48)}.spinner-label{font-size:var(--sgds-font-size-1)}@media (prefers-reduced-motion:reduce){.spinner{animation-duration:1.5s}}
|
|
5215
|
+
|
|
5216
|
+
/*! CSS Used keyframes */@keyframes spinner{to{transform:rotate(1turn)}}.sr-only{clip:rect(0,0,0,0);border:0;height:1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}`;
|
|
5217
|
+
|
|
5218
|
+
var css_248z$1 = css`.text-primary{color:var(--sgds-primary-rgb)!important}.text-secondary{color:var(--sgds-secondary-rgb)!important}.text-success{color:var(--sgds-success-rgb)!important}.text-info{color:var(--sgds-info-rgb)!important}.text-warning{color:var(--sgds-warning-rgb)!important}.text-danger{color:var(--sgds-danger-rgb)!important}.text-light{color:var(--sgds-light-rgb)!important}.text-dark{color:var(--sgds-dark-rgb)!important}.text-muted{color:var(--sgds-secondary-color)!important}`;
|
|
5219
|
+
|
|
5220
|
+
/**
|
|
5221
|
+
* @summary Spinners notify the users that their request is being processed.
|
|
5222
|
+
*
|
|
5223
|
+
*/
|
|
5224
|
+
class SgdsSpinner extends SgdsElement {
|
|
5225
|
+
constructor() {
|
|
5226
|
+
super(...arguments);
|
|
5227
|
+
/** The variant of spinner */
|
|
5228
|
+
this.variant = "primary";
|
|
5229
|
+
/** Specifies a small, medium or large button, the size is medium by default. */
|
|
5230
|
+
this.size = "md";
|
|
5231
|
+
}
|
|
5232
|
+
render() {
|
|
5233
|
+
return html `
|
|
5234
|
+
<div class="spinner-wrapper">
|
|
5235
|
+
<div
|
|
5236
|
+
class="spinner ${classMap({
|
|
5237
|
+
[`spinner-${this.size}`]: this.size
|
|
5238
|
+
})}"
|
|
5239
|
+
role="status"
|
|
5240
|
+
>
|
|
5241
|
+
${this.label ? nothing : html `<span class="sr-only">Loading...</span>`}
|
|
5242
|
+
</div>
|
|
5243
|
+
${this.label ? html `<span class="spinner-label">${this.label}</span>` : nothing}
|
|
5244
|
+
</div>
|
|
5245
|
+
`;
|
|
5246
|
+
}
|
|
5247
|
+
}
|
|
5248
|
+
SgdsSpinner.styles = [...SgdsElement.styles, css_248z$1, css_248z$2];
|
|
5249
|
+
__decorate([
|
|
5250
|
+
property({ type: String, reflect: true })
|
|
5251
|
+
], SgdsSpinner.prototype, "variant", void 0);
|
|
5252
|
+
__decorate([
|
|
5253
|
+
property({ reflect: true })
|
|
5254
|
+
], SgdsSpinner.prototype, "size", void 0);
|
|
5255
|
+
__decorate([
|
|
5256
|
+
property({ reflect: true, type: String })
|
|
5257
|
+
], SgdsSpinner.prototype, "label", void 0);
|
|
5258
|
+
|
|
4937
5259
|
var css_248z = css`.form-control-container{display:flex;flex-direction:column;gap:var(--sgds-form-gap-md)}.form-control-container.disabled{opacity:var(--sgds-opacity-50)}.form-control-group{align-items:center;background-color:var(--sgds-form-bg);border:var(--sgds-form-border-width-default) solid var(--sgds-form-border-color);border-radius:var(--sgds-form-border-radius-md);display:flex;gap:var(--sgds-form-gap-md);height:var(--sgds-dimension-48);justify-content:center;min-width:var(--sgds-dimension-256);padding:0 var(--sgds-form-padding-x);transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out;width:-webkit-fill-available;width:-moz-available}.form-control{appearance:none;background-clip:padding-box;background:none;border:none;color:var(--sgds-form-color);display:block;flex-grow:1;font-size:var(--sgds-font-size-2);line-height:var(--sgds-line-height-heading);outline:none;padding:0}.form-control-group>.form-control:focus{z-index:3}@media (prefers-reduced-motion:reduce){.form-control-group{transition:none}}.form-control-group.readonly{border-color:var(--sgds-form-border-color-muted)}.form-control-group:not(.disabled):not(.is-invalid):hover{border:var(--sgds-form-border-width-thick) solid var(--sgds-form-border-color-emphasis)}.form-control-group:not(.disabled):not(.is-invalid):focus,.form-control-group:not(.disabled):not(.is-invalid):focus-within{border:var(--sgds-form-border-width-thick) solid var(--sgds-form-border-color-emphasis);box-shadow:var(--sgds-form-box-shadow-focus);outline:0}.form-control-group.is-invalid{border:var(--sgds-form-border-width-thick) solid var(--sgds-form-danger-border-color)}.form-control-group.disabled{background-color:var(--sgds-form-bg-muted)}:host(.quantity-toggle) input::-webkit-inner-spin-button{appearance:none;margin:0}:host(.quantity-toggle) input{text-align:center}.form-control-icon{align-items:center;display:flex;height:var(--sgds-form-icon-size-lg);justify-content:center;width:var(--sgds-form-icon-size-lg)}.form-control-prefix,.form-control-suffix{color:var(--sgds-form-color-subtle)}.form-control-group.quantity-toggle{padding:0}`;
|
|
4938
5260
|
|
|
4939
5261
|
/**
|
|
@@ -4943,14 +5265,13 @@
|
|
|
4943
5265
|
* @event sgds-input - Emitted when the control receives input and its value changes.
|
|
4944
5266
|
* @event sgds-focus - Emitted when input is in focus.
|
|
4945
5267
|
* @event sgds-blur - Emitted when input is not in focus.
|
|
5268
|
+
* @event sgds-invalid - Emitted when input is invalid
|
|
5269
|
+
* @event sgds-valid - Emitted when input is valid
|
|
4946
5270
|
*
|
|
4947
5271
|
*/
|
|
4948
|
-
class SgdsInput extends FormControlElement {
|
|
5272
|
+
class SgdsInput extends SgdsFormValidatorMixin(ScopedElementsMixin(FormControlElement)) {
|
|
4949
5273
|
constructor() {
|
|
4950
5274
|
super(...arguments);
|
|
4951
|
-
/**@internal */
|
|
4952
|
-
this.formSubmitController = new FormSubmitController(this);
|
|
4953
|
-
/** The type of input which works the same as HTMLInputElement */
|
|
4954
5275
|
this.type = "text";
|
|
4955
5276
|
/** The input's placeholder text. */
|
|
4956
5277
|
this.placeholder = "placeholder";
|
|
@@ -4958,16 +5279,17 @@
|
|
|
4958
5279
|
this.autofocus = false;
|
|
4959
5280
|
/** Makes the input readonly. */
|
|
4960
5281
|
this.readonly = false;
|
|
4961
|
-
/**The input's value attribute. */
|
|
4962
|
-
this.value = "";
|
|
4963
5282
|
/**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. */
|
|
4964
5283
|
this.defaultValue = "";
|
|
4965
5284
|
/** Marks the component as valid. */
|
|
4966
5285
|
this.valid = false;
|
|
4967
5286
|
/** Marks the component as loading. */
|
|
4968
5287
|
this.loading = false;
|
|
4969
|
-
|
|
4970
|
-
this.
|
|
5288
|
+
/** Makes the input a required field. */
|
|
5289
|
+
this.required = false;
|
|
5290
|
+
/**The input's value attribute. */
|
|
5291
|
+
this.value = "";
|
|
5292
|
+
this._isTouched = false;
|
|
4971
5293
|
}
|
|
4972
5294
|
/**@internal */
|
|
4973
5295
|
static get scopedElements() {
|
|
@@ -4983,60 +5305,79 @@
|
|
|
4983
5305
|
blur() {
|
|
4984
5306
|
this.input.blur();
|
|
4985
5307
|
}
|
|
4986
|
-
/** Checks for validity and shows the browser's validation message if the control is invalid. */
|
|
4987
|
-
reportValidity() {
|
|
4988
|
-
return this.input.reportValidity();
|
|
4989
|
-
}
|
|
4990
|
-
/** Sets a custom validation message. Pass an empty string to restore validity */
|
|
4991
|
-
setCustomValidity(err) {
|
|
4992
|
-
return this.input.setCustomValidity(err);
|
|
4993
|
-
}
|
|
4994
5308
|
/** Programatically sets the invalid state of the input. Pass in boolean value in the argument */
|
|
4995
5309
|
setInvalid(bool) {
|
|
4996
5310
|
this.invalid = bool;
|
|
5311
|
+
if (bool) {
|
|
5312
|
+
this.emit("sgds-invalid");
|
|
5313
|
+
}
|
|
5314
|
+
else {
|
|
5315
|
+
this.emit("sgds-valid");
|
|
5316
|
+
}
|
|
4997
5317
|
}
|
|
4998
|
-
|
|
4999
|
-
|
|
5318
|
+
/**
|
|
5319
|
+
* Checks for validity. Under the hood, HTMLFormElement's reportValidity method calls this method to check for component's validity state
|
|
5320
|
+
* 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
|
|
5321
|
+
*/
|
|
5322
|
+
reportValidity() {
|
|
5323
|
+
return this._mixinReportValidity();
|
|
5000
5324
|
}
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5325
|
+
/**
|
|
5326
|
+
* Checks for validity without any native error popup message
|
|
5327
|
+
*/
|
|
5328
|
+
checkValidity() {
|
|
5329
|
+
return this._mixinCheckValidity();
|
|
5330
|
+
}
|
|
5331
|
+
/**
|
|
5332
|
+
* Returns the ValidityState object
|
|
5333
|
+
*/
|
|
5334
|
+
get validity() {
|
|
5335
|
+
return this._mixinGetValidity();
|
|
5336
|
+
}
|
|
5337
|
+
/**
|
|
5338
|
+
* Returns the validation message based on the ValidityState
|
|
5339
|
+
*/
|
|
5340
|
+
get validationMessage() {
|
|
5341
|
+
return this._mixinGetValidationMessage();
|
|
5004
5342
|
}
|
|
5005
5343
|
_handleFocus() {
|
|
5006
5344
|
this.emit("sgds-focus");
|
|
5007
5345
|
}
|
|
5008
5346
|
_handleBlur() {
|
|
5347
|
+
this._isTouched = true;
|
|
5009
5348
|
this.emit("sgds-blur");
|
|
5010
5349
|
}
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5350
|
+
_handleClick() {
|
|
5351
|
+
this.focus();
|
|
5352
|
+
}
|
|
5353
|
+
_handleChange(e) {
|
|
5354
|
+
this.value = this.input.value;
|
|
5355
|
+
this.emit("sgds-change");
|
|
5356
|
+
super._mixinHandleChange(e);
|
|
5357
|
+
}
|
|
5358
|
+
_handleInputChange(e) {
|
|
5359
|
+
this.value = this.input.value;
|
|
5360
|
+
this.emit("sgds-input");
|
|
5361
|
+
super._mixinHandleInputChange(e);
|
|
5362
|
+
}
|
|
5363
|
+
/** @internal */
|
|
5364
|
+
_handleIsTouched() {
|
|
5365
|
+
if (this._isTouched) {
|
|
5366
|
+
this.setInvalid(!this._mixinCheckValidity());
|
|
5022
5367
|
}
|
|
5023
5368
|
}
|
|
5024
5369
|
_handleDisabledChange() {
|
|
5025
5370
|
// Disabled form controls are always valid, so we need to recheck validity when the state changes
|
|
5026
|
-
this.
|
|
5027
|
-
this.invalid = !this.input.checkValidity();
|
|
5028
|
-
}
|
|
5029
|
-
_handleValueChange() {
|
|
5030
|
-
this.invalid = !this.input.checkValidity();
|
|
5371
|
+
this.setInvalid(false);
|
|
5031
5372
|
}
|
|
5032
5373
|
_renderInput() {
|
|
5374
|
+
const wantFeedbackStyle = this.hasFeedback === "both" || this.hasFeedback === "style";
|
|
5033
5375
|
return html `
|
|
5034
5376
|
<div
|
|
5035
5377
|
class="form-control-group ${classMap({
|
|
5036
5378
|
disabled: this.disabled,
|
|
5037
5379
|
readonly: this.readonly,
|
|
5038
|
-
"is-invalid": this.invalid &&
|
|
5039
|
-
"quantity-toggle": this.classList.contains("quantity-toggle")
|
|
5380
|
+
"is-invalid": this.invalid && wantFeedbackStyle
|
|
5040
5381
|
})}"
|
|
5041
5382
|
@click=${this._handleClick}
|
|
5042
5383
|
>
|
|
@@ -5045,7 +5386,7 @@
|
|
|
5045
5386
|
<input
|
|
5046
5387
|
class="form-control"
|
|
5047
5388
|
type=${this.type}
|
|
5048
|
-
id=${this.
|
|
5389
|
+
id=${this._controlId}
|
|
5049
5390
|
name=${ifDefined(this.name)}
|
|
5050
5391
|
placeholder=${ifDefined(this.placeholder)}
|
|
5051
5392
|
aria-invalid=${this.invalid ? "true" : "false"}
|
|
@@ -5060,15 +5401,14 @@
|
|
|
5060
5401
|
min=${ifDefined(this.min)}
|
|
5061
5402
|
max=${ifDefined(this.max)}
|
|
5062
5403
|
step=${ifDefined(this.step)}
|
|
5063
|
-
@input=${() => this.
|
|
5064
|
-
@change=${() => this._handleChange(
|
|
5065
|
-
@keydown=${this._handleKeyDown}
|
|
5404
|
+
@input=${(e) => this._handleInputChange(e)}
|
|
5405
|
+
@change=${(e) => this._handleChange(e)}
|
|
5066
5406
|
@invalid=${() => this.setInvalid(true)}
|
|
5067
5407
|
@focus=${this._handleFocus}
|
|
5068
5408
|
@blur=${this._handleBlur}
|
|
5069
|
-
aria-describedby=${ifDefined(this.invalid && this.hasFeedback ? `${this.
|
|
5070
|
-
aria-labelledby="${this.
|
|
5071
|
-
? `${this.
|
|
5409
|
+
aria-describedby=${ifDefined(this.invalid && this.hasFeedback ? `${this._controlId}-invalid` : undefined)}
|
|
5410
|
+
aria-labelledby="${this._labelId} ${this._controlId}Help ${this.invalid && this.hasFeedback
|
|
5411
|
+
? `${this._controlId}-invalid`
|
|
5072
5412
|
: ""}"
|
|
5073
5413
|
/>
|
|
5074
5414
|
${this.loading ? html `<sgds-spinner size="sm"></sgds-spinner>` : nothing}
|
|
@@ -5085,7 +5425,8 @@
|
|
|
5085
5425
|
`;
|
|
5086
5426
|
}
|
|
5087
5427
|
_renderFeedback() {
|
|
5088
|
-
|
|
5428
|
+
const wantFeedbackText = this.hasFeedback === "both" || this.hasFeedback === "text";
|
|
5429
|
+
return this.invalid && wantFeedbackText
|
|
5089
5430
|
? html ` <div class="invalid-feedback-container">
|
|
5090
5431
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="none">
|
|
5091
5432
|
<path
|
|
@@ -5093,15 +5434,17 @@
|
|
|
5093
5434
|
fill="#B90000"
|
|
5094
5435
|
/>
|
|
5095
5436
|
</svg>
|
|
5096
|
-
<div id="${this.
|
|
5437
|
+
<div id="${this._controlId}-invalid" class="invalid-feedback">
|
|
5438
|
+
${this.invalidFeedback ? this.invalidFeedback : this.input.validationMessage}
|
|
5439
|
+
</div>
|
|
5097
5440
|
</div>`
|
|
5098
5441
|
: html `${this._renderHintText()}`;
|
|
5099
5442
|
}
|
|
5100
5443
|
_renderLabel() {
|
|
5101
5444
|
const labelTemplate = html `
|
|
5102
5445
|
<label
|
|
5103
|
-
for=${this.
|
|
5104
|
-
id=${this.
|
|
5446
|
+
for=${this._controlId}
|
|
5447
|
+
id=${this._labelId}
|
|
5105
5448
|
class=${classMap({
|
|
5106
5449
|
"form-label": true,
|
|
5107
5450
|
required: this.required
|
|
@@ -5112,7 +5455,7 @@
|
|
|
5112
5455
|
return this.label && labelTemplate;
|
|
5113
5456
|
}
|
|
5114
5457
|
_renderHintText() {
|
|
5115
|
-
const hintTextTemplate = html ` <div id="${this.
|
|
5458
|
+
const hintTextTemplate = html ` <div id="${this._controlId}Help" class="form-text">${this.hintText}</div> `;
|
|
5116
5459
|
return this.hintText && hintTextTemplate;
|
|
5117
5460
|
}
|
|
5118
5461
|
render() {
|
|
@@ -5127,10 +5470,7 @@
|
|
|
5127
5470
|
`;
|
|
5128
5471
|
}
|
|
5129
5472
|
}
|
|
5130
|
-
SgdsInput.styles = [...FormControlElement.styles, css_248z];
|
|
5131
|
-
__decorate([
|
|
5132
|
-
query("input.form-control")
|
|
5133
|
-
], SgdsInput.prototype, "input", void 0);
|
|
5473
|
+
SgdsInput.styles = [...FormControlElement.styles, css_248z$4, css_248z];
|
|
5134
5474
|
__decorate([
|
|
5135
5475
|
property({ reflect: true })
|
|
5136
5476
|
], SgdsInput.prototype, "type", void 0);
|
|
@@ -5149,6 +5489,12 @@
|
|
|
5149
5489
|
__decorate([
|
|
5150
5490
|
property({ type: Number, reflect: true })
|
|
5151
5491
|
], SgdsInput.prototype, "maxlength", void 0);
|
|
5492
|
+
__decorate([
|
|
5493
|
+
property()
|
|
5494
|
+
], SgdsInput.prototype, "min", void 0);
|
|
5495
|
+
__decorate([
|
|
5496
|
+
property()
|
|
5497
|
+
], SgdsInput.prototype, "max", void 0);
|
|
5152
5498
|
__decorate([
|
|
5153
5499
|
property({ type: String, reflect: true })
|
|
5154
5500
|
], SgdsInput.prototype, "placeholder", void 0);
|
|
@@ -5165,8 +5511,11 @@
|
|
|
5165
5511
|
property()
|
|
5166
5512
|
], SgdsInput.prototype, "step", void 0);
|
|
5167
5513
|
__decorate([
|
|
5168
|
-
property({ reflect: true })
|
|
5169
|
-
], SgdsInput.prototype, "
|
|
5514
|
+
property({ type: String, reflect: true })
|
|
5515
|
+
], SgdsInput.prototype, "hasFeedback", void 0);
|
|
5516
|
+
__decorate([
|
|
5517
|
+
property({ type: String, reflect: true })
|
|
5518
|
+
], SgdsInput.prototype, "invalidFeedback", void 0);
|
|
5170
5519
|
__decorate([
|
|
5171
5520
|
defaultValue()
|
|
5172
5521
|
], SgdsInput.prototype, "defaultValue", void 0);
|
|
@@ -5176,12 +5525,21 @@
|
|
|
5176
5525
|
__decorate([
|
|
5177
5526
|
property({ type: Boolean, reflect: true })
|
|
5178
5527
|
], SgdsInput.prototype, "loading", void 0);
|
|
5528
|
+
__decorate([
|
|
5529
|
+
property({ type: Boolean, reflect: true })
|
|
5530
|
+
], SgdsInput.prototype, "required", void 0);
|
|
5531
|
+
__decorate([
|
|
5532
|
+
property({ reflect: true })
|
|
5533
|
+
], SgdsInput.prototype, "value", void 0);
|
|
5534
|
+
__decorate([
|
|
5535
|
+
state()
|
|
5536
|
+
], SgdsInput.prototype, "_isTouched", void 0);
|
|
5537
|
+
__decorate([
|
|
5538
|
+
watch("_isTouched", { waitUntilFirstUpdate: true })
|
|
5539
|
+
], SgdsInput.prototype, "_handleIsTouched", null);
|
|
5179
5540
|
__decorate([
|
|
5180
5541
|
watch("disabled", { waitUntilFirstUpdate: true })
|
|
5181
5542
|
], SgdsInput.prototype, "_handleDisabledChange", null);
|
|
5182
|
-
__decorate([
|
|
5183
|
-
watch("value", { waitUntilFirstUpdate: true })
|
|
5184
|
-
], SgdsInput.prototype, "_handleValueChange", null);
|
|
5185
5543
|
|
|
5186
5544
|
customElements.define("sgds-input", SgdsInput);
|
|
5187
5545
|
|