@supersoniks/concorde 4.9.98-visual-stack.1 → 4.9.98-visual-stack.3
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/.gitlab-ci.yml +0 -13
- package/build-infos.json +1 -1
- package/concorde-3d.bundle.js +1 -1
- package/concorde-3d.es.js +2 -2
- package/concorde-core.bundle.js +557 -622
- package/concorde-core.es.js +6025 -5575
- package/concorde-hugging-face-infer.bundle.js +1 -1
- package/concorde-hugging-face-infer.es.js +1 -1
- package/concorde-interactive.bundle.js +1162 -0
- package/concorde-interactive.es.js +10723 -0
- package/concorde-shader.bundle.js +1 -1
- package/concorde-shader.es.js +2 -2
- package/concorde-webgpu.bundle.js +1 -1
- package/concorde-webgpu.es.js +2 -2
- package/dist/concorde-3d.bundle.js +1 -1
- package/dist/concorde-3d.es.js +2 -2
- package/dist/concorde-core.bundle.js +557 -622
- package/dist/concorde-core.es.js +6025 -5575
- package/dist/concorde-hugging-face-infer.bundle.js +1 -1
- package/dist/concorde-hugging-face-infer.es.js +1 -1
- package/dist/concorde-interactive.bundle.js +1162 -0
- package/dist/concorde-interactive.es.js +10723 -0
- package/dist/concorde-shader.bundle.js +1 -1
- package/dist/concorde-shader.es.js +2 -2
- package/dist/concorde-webgpu.bundle.js +1 -1
- package/dist/concorde-webgpu.es.js +2 -2
- package/dist/docs-mock-api-sw.js +5 -1
- package/dist/docs-mock-api-sw.js.map +2 -2
- package/dist/js/addons/interactive.js +6 -0
- package/dist/js/addons/interactive.js.map +1 -0
- package/dist/js/core/components/functional/if/if.js +65 -7
- package/dist/js/core/components/functional/if/if.js.map +1 -1
- package/dist/js/core/components/functional/interactive/action.js +96 -0
- package/dist/js/core/components/functional/interactive/action.js.map +1 -0
- package/dist/js/core/components/functional/interactive/gamepad.js +206 -0
- package/dist/js/core/components/functional/interactive/gamepad.js.map +1 -0
- package/dist/js/core/components/functional/interactive/gesture.js +148 -0
- package/dist/js/core/components/functional/interactive/gesture.js.map +1 -0
- package/dist/js/core/components/functional/interactive/helpers.js +82 -0
- package/dist/js/core/components/functional/interactive/helpers.js.map +1 -0
- package/dist/js/core/components/functional/interactive/index.js +20 -0
- package/dist/js/core/components/functional/interactive/index.js.map +1 -0
- package/dist/js/core/components/functional/interactive/keyboard.js +183 -0
- package/dist/js/core/components/functional/interactive/keyboard.js.map +1 -0
- package/dist/js/core/components/functional/interactive/matrix.js +201 -0
- package/dist/js/core/components/functional/interactive/matrix.js.map +1 -0
- package/dist/js/core/components/functional/interactive/registry.js +28 -0
- package/dist/js/core/components/functional/interactive/registry.js.map +1 -0
- package/dist/js/core/components/functional/interactive/store.js +264 -0
- package/dist/js/core/components/functional/interactive/store.js.map +1 -0
- package/dist/js/core/components/functional/interactive/ticker.js +182 -0
- package/dist/js/core/components/functional/interactive/ticker.js.map +1 -0
- package/dist/js/core/components/functional/value/value.js +49 -4
- package/dist/js/core/components/functional/value/value.js.map +1 -1
- package/dist/js/core/components/ui/_css/rounded.js +34 -0
- package/dist/js/core/components/ui/_css/rounded.js.map +1 -0
- package/dist/js/core/components/ui/_css/type.js +44 -0
- package/dist/js/core/components/ui/_css/type.js.map +1 -1
- package/dist/js/core/components/ui/_i18n/ui-aria-labels.js +95 -0
- package/dist/js/core/components/ui/_i18n/ui-aria-labels.js.map +1 -0
- package/dist/js/core/components/ui/alert/alert.js +72 -87
- package/dist/js/core/components/ui/alert/alert.js.map +1 -1
- package/dist/js/core/components/ui/alert-messages/alert-messages.js +1 -0
- package/dist/js/core/components/ui/alert-messages/alert-messages.js.map +1 -1
- package/dist/js/core/components/ui/badge/badge.js +29 -80
- package/dist/js/core/components/ui/badge/badge.js.map +1 -1
- package/dist/js/core/components/ui/button/button.js +8 -7
- package/dist/js/core/components/ui/button/button.js.map +1 -1
- package/dist/js/core/components/ui/card/card-header.js +7 -2
- package/dist/js/core/components/ui/card/card-header.js.map +1 -1
- package/dist/js/core/components/ui/divider/divider.js +1 -1
- package/dist/js/core/components/ui/divider/divider.js.map +1 -1
- package/dist/js/core/components/ui/form/checkbox/checkbox.js +4 -20
- package/dist/js/core/components/ui/form/checkbox/checkbox.js.map +1 -1
- package/dist/js/core/components/ui/form/fieldset/legend-description.js +1 -1
- package/dist/js/core/components/ui/form/fieldset/legend.js +1 -1
- package/dist/js/core/components/ui/form/input/input.js +12 -15
- package/dist/js/core/components/ui/form/input/input.js.map +1 -1
- package/dist/js/core/components/ui/form/input-autocomplete/input-autocomplete.js +363 -158
- package/dist/js/core/components/ui/form/input-autocomplete/input-autocomplete.js.map +1 -1
- package/dist/js/core/components/ui/form/radio/radio.js +1 -1
- package/dist/js/core/components/ui/form/select/select.js +3 -6
- package/dist/js/core/components/ui/form/select/select.js.map +1 -1
- package/dist/js/core/components/ui/form/textarea/textarea.js +1 -2
- package/dist/js/core/components/ui/form/textarea/textarea.js.map +1 -1
- package/dist/js/core/components/ui/image/image.js +9 -37
- package/dist/js/core/components/ui/image/image.js.map +1 -1
- package/dist/js/core/components/ui/link/link.js +25 -26
- package/dist/js/core/components/ui/link/link.js.map +1 -1
- package/dist/js/core/components/ui/modal/modal-close.js +3 -12
- package/dist/js/core/components/ui/modal/modal-close.js.map +1 -1
- package/dist/js/core/components/ui/modal/modal.js +18 -18
- package/dist/js/core/components/ui/modal/modal.js.map +1 -1
- package/dist/js/core/components/ui/pop/pop.js +131 -112
- package/dist/js/core/components/ui/pop/pop.js.map +1 -1
- package/dist/js/core/components/ui/table/table.js.map +1 -1
- package/dist/js/core/components/ui/theme/theme.js +1 -1
- package/dist/js/core/components/ui/toast/dismissed.js +9 -0
- package/dist/js/core/components/ui/toast/dismissed.js.map +1 -0
- package/dist/js/core/components/ui/toast/render-content.js +14 -0
- package/dist/js/core/components/ui/toast/render-content.js.map +1 -0
- package/dist/js/core/components/ui/toast/toast-item.js +150 -96
- package/dist/js/core/components/ui/toast/toast-item.js.map +1 -1
- package/dist/js/core/components/ui/toast/toast.js +41 -13
- package/dist/js/core/components/ui/toast/toast.js.map +1 -1
- package/dist/js/core/components/ui/tooltip/tooltip.js +144 -143
- package/dist/js/core/components/ui/tooltip/tooltip.js.map +1 -1
- package/dist/js/core/decorators/subscriber/ancestorAttribute.js.map +1 -1
- package/dist/js/core/decorators/subscriber/derive.js +3 -1
- package/dist/js/core/decorators/subscriber/derive.js.map +1 -1
- package/dist/js/core/mixins/Fetcher.js.map +1 -1
- package/dist/js/core/mixins/FormCheckable.js +1 -8
- package/dist/js/core/mixins/FormCheckable.js.map +1 -1
- package/dist/js/core/mixins/FormElement.js +26 -53
- package/dist/js/core/mixins/FormElement.js.map +1 -1
- package/dist/js/core/utils/AncestorAttributeObserver.js +130 -55
- package/dist/js/core/utils/AncestorAttributeObserver.js.map +1 -1
- package/dist/js/core/utils/LocationHandler.js +1 -1
- package/dist/js/core/utils/LocationHandler.js.map +1 -1
- package/dist/js/core/utils/dismissed.js +23 -0
- package/dist/js/core/utils/dismissed.js.map +1 -0
- package/dist/js/core/utils/positioning.js +110 -0
- package/dist/js/core/utils/positioning.js.map +1 -0
- package/dist/js/directives.js +1 -2
- package/dist/js/directives.js.map +1 -1
- package/dist/types/addons/interactive.d.ts +6 -0
- package/dist/types/addons/interactive.d.ts.map +1 -0
- package/dist/types/core/components/functional/if/if.d.ts +14 -5
- package/dist/types/core/components/functional/if/if.d.ts.map +1 -1
- package/dist/types/core/components/functional/interactive/action.d.ts +22 -0
- package/dist/types/core/components/functional/interactive/action.d.ts.map +1 -0
- package/dist/types/core/components/functional/interactive/gamepad.d.ts +37 -0
- package/dist/types/core/components/functional/interactive/gamepad.d.ts.map +1 -0
- package/dist/types/core/components/functional/interactive/gesture.d.ts +26 -0
- package/dist/types/core/components/functional/interactive/gesture.d.ts.map +1 -0
- package/dist/types/core/components/functional/interactive/helpers.d.ts +23 -0
- package/dist/types/core/components/functional/interactive/helpers.d.ts.map +1 -0
- package/dist/types/core/components/functional/interactive/index.d.ts +20 -0
- package/dist/types/core/components/functional/interactive/index.d.ts.map +1 -0
- package/dist/types/core/components/functional/interactive/keyboard.d.ts +37 -0
- package/dist/types/core/components/functional/interactive/keyboard.d.ts.map +1 -0
- package/dist/types/core/components/functional/interactive/matrix.d.ts +31 -0
- package/dist/types/core/components/functional/interactive/matrix.d.ts.map +1 -0
- package/dist/types/core/components/functional/interactive/registry.d.ts +23 -0
- package/dist/types/core/components/functional/interactive/registry.d.ts.map +1 -0
- package/dist/types/core/components/functional/interactive/store.d.ts +46 -0
- package/dist/types/core/components/functional/interactive/store.d.ts.map +1 -0
- package/dist/types/core/components/functional/interactive/ticker.d.ts +33 -0
- package/dist/types/core/components/functional/interactive/ticker.d.ts.map +1 -0
- package/dist/types/core/components/functional/value/value.d.ts +6 -0
- package/dist/types/core/components/functional/value/value.d.ts.map +1 -1
- package/dist/types/core/components/ui/_css/rounded.d.ts +3 -0
- package/dist/types/core/components/ui/_css/rounded.d.ts.map +1 -0
- package/dist/types/core/components/ui/_css/type.d.ts +13 -0
- package/dist/types/core/components/ui/_css/type.d.ts.map +1 -1
- package/dist/types/core/components/ui/_i18n/ui-aria-labels.d.ts +83 -0
- package/dist/types/core/components/ui/_i18n/ui-aria-labels.d.ts.map +1 -0
- package/dist/types/core/components/ui/alert/alert.d.ts +14 -12
- package/dist/types/core/components/ui/alert/alert.d.ts.map +1 -1
- package/dist/types/core/components/ui/alert-messages/alert-messages.d.ts.map +1 -1
- package/dist/types/core/components/ui/badge/badge.d.ts +1 -1
- package/dist/types/core/components/ui/badge/badge.d.ts.map +1 -1
- package/dist/types/core/components/ui/button/button.d.ts +13 -29
- package/dist/types/core/components/ui/button/button.d.ts.map +1 -1
- package/dist/types/core/components/ui/card/card-header.d.ts.map +1 -1
- package/dist/types/core/components/ui/divider/divider.d.ts +2 -1
- package/dist/types/core/components/ui/divider/divider.d.ts.map +1 -1
- package/dist/types/core/components/ui/form/checkbox/checkbox.d.ts +25 -73
- package/dist/types/core/components/ui/form/checkbox/checkbox.d.ts.map +1 -1
- package/dist/types/core/components/ui/form/input/input.d.ts +14 -29
- package/dist/types/core/components/ui/form/input/input.d.ts.map +1 -1
- package/dist/types/core/components/ui/form/input-autocomplete/input-autocomplete.d.ts +63 -65
- package/dist/types/core/components/ui/form/input-autocomplete/input-autocomplete.d.ts.map +1 -1
- package/dist/types/core/components/ui/form/radio/radio.d.ts +1 -1
- package/dist/types/core/components/ui/form/select/select.d.ts +3 -5
- package/dist/types/core/components/ui/form/select/select.d.ts.map +1 -1
- package/dist/types/core/components/ui/form/textarea/textarea.d.ts +12 -28
- package/dist/types/core/components/ui/form/textarea/textarea.d.ts.map +1 -1
- package/dist/types/core/components/ui/image/image.d.ts +2 -1
- package/dist/types/core/components/ui/image/image.d.ts.map +1 -1
- package/dist/types/core/components/ui/link/link.d.ts +10 -9
- package/dist/types/core/components/ui/link/link.d.ts.map +1 -1
- package/dist/types/core/components/ui/modal/modal-close.d.ts +2 -2
- package/dist/types/core/components/ui/modal/modal-close.d.ts.map +1 -1
- package/dist/types/core/components/ui/pop/pop.d.ts +12 -4
- package/dist/types/core/components/ui/pop/pop.d.ts.map +1 -1
- package/dist/types/core/components/ui/table/table.d.ts +2 -1
- package/dist/types/core/components/ui/table/table.d.ts.map +1 -1
- package/dist/types/core/components/ui/toast/dismissed.d.ts +3 -0
- package/dist/types/core/components/ui/toast/dismissed.d.ts.map +1 -0
- package/dist/types/core/components/ui/toast/render-content.d.ts +7 -0
- package/dist/types/core/components/ui/toast/render-content.d.ts.map +1 -0
- package/dist/types/core/components/ui/toast/toast-item.d.ts +26 -9
- package/dist/types/core/components/ui/toast/toast-item.d.ts.map +1 -1
- package/dist/types/core/components/ui/toast/toast.d.ts +6 -3
- package/dist/types/core/components/ui/toast/toast.d.ts.map +1 -1
- package/dist/types/core/components/ui/toast/types.d.ts +12 -2
- package/dist/types/core/components/ui/toast/types.d.ts.map +1 -1
- package/dist/types/core/components/ui/tooltip/tooltip.d.ts +19 -11
- package/dist/types/core/components/ui/tooltip/tooltip.d.ts.map +1 -1
- package/dist/types/core/decorators/subscriber/ancestorAttribute.d.ts +3 -4
- package/dist/types/core/decorators/subscriber/ancestorAttribute.d.ts.map +1 -1
- package/dist/types/core/decorators/subscriber/derive.d.ts.map +1 -1
- package/dist/types/core/mixins/FormCheckable.d.ts +10 -27
- package/dist/types/core/mixins/FormCheckable.d.ts.map +1 -1
- package/dist/types/core/mixins/FormElement.d.ts +21 -10
- package/dist/types/core/mixins/FormElement.d.ts.map +1 -1
- package/dist/types/core/mixins/FormInput.d.ts +11 -27
- package/dist/types/core/mixins/FormInput.d.ts.map +1 -1
- package/dist/types/core/utils/AncestorAttributeObserver.d.ts +17 -9
- package/dist/types/core/utils/AncestorAttributeObserver.d.ts.map +1 -1
- package/dist/types/core/utils/LocationHandler.d.ts +3 -2
- package/dist/types/core/utils/LocationHandler.d.ts.map +1 -1
- package/dist/types/core/utils/dismissed.d.ts +3 -0
- package/dist/types/core/utils/dismissed.d.ts.map +1 -0
- package/dist/types/core/utils/positioning.d.ts +44 -0
- package/dist/types/core/utils/positioning.d.ts.map +1 -0
- package/dist/types/directives.d.ts +1 -3
- package/dist/types/directives.d.ts.map +1 -1
- package/dist/types/mixins.d.ts +22 -55
- package/dist/types/mixins.d.ts.map +1 -1
- package/docs/assets/{index-FmK4JaIM.js → index-D8MVWqY6.js} +946 -687
- package/docs/assets/index-DiD0qYvE.css +1 -0
- package/docs/crawl/core/components/ui/form/input-autocomplete/input-autocomplete.html +17 -85
- package/docs/crawl/docs/_misc/formelement-subscriber-removal.html +1 -1
- package/docs/crawl/hubs/form-components.html +13 -11
- package/docs/docs-mock-api-sw.js +5 -1
- package/docs/docs-mock-api-sw.js.map +2 -2
- package/docs/index.html +2 -2
- package/docs/llms-full.txt +12 -38
- package/docs/llms.txt +1 -1
- package/docs/src/core/components/functional/sdui/sdui.md +0 -0
- package/docs/src/core/components/ui/form/checkbox/checkbox.md +0 -0
- package/docs/src/core/components/ui/form/input-autocomplete/input-autocomplete.md +14 -118
- package/docs/src/docs/_getting-started/create-a-component.md +0 -0
- package/docs/src/docs/_misc/formelement-subscriber-removal.md +1 -1
- package/docs/src/docs/search/docs-search.json +195 -200
- package/docs/src/tsconfig.json +324 -0
- package/gitlab/job_tests.sh +25 -12
- package/index.html +3 -3
- package/package.json +182 -10
- package/public/docs-mock-api-sw.js +5 -1
- package/public/docs-mock-api-sw.js.map +2 -2
- package/scripts/build-addons.mjs +2 -2
- package/scripts/post-build.mjs +9 -0
- package/src/addons/interactive.ts +5 -0
- package/src/core/components/functional/if/if.ts +54 -7
- package/src/core/components/functional/interactive/action.ts +84 -0
- package/src/core/components/functional/interactive/gamepad.ts +197 -0
- package/src/core/components/functional/interactive/gesture.ts +136 -0
- package/src/core/components/functional/interactive/helpers.spec.ts +50 -0
- package/src/core/components/functional/interactive/helpers.ts +97 -0
- package/src/core/components/functional/interactive/index.ts +25 -0
- package/src/core/components/functional/interactive/interactive.md +33 -0
- package/src/core/components/functional/interactive/keyboard.ts +171 -0
- package/src/core/components/functional/interactive/matrix.ts +185 -0
- package/src/core/components/functional/interactive/registry.ts +46 -0
- package/src/core/components/functional/interactive/store.ts +270 -0
- package/src/core/components/functional/interactive/ticker.ts +171 -0
- package/src/core/components/functional/list/list.ts +0 -0
- package/src/core/components/functional/subscriber/subscriber.ts +0 -0
- package/src/core/components/functional/value/value.ts +44 -4
- package/src/core/components/ui/_css/rounded.ts +36 -0
- package/src/core/components/ui/_css/type.ts +49 -0
- package/src/core/components/ui/_i18n/ui-aria-labels.ts +104 -0
- package/src/core/components/ui/alert/alert.md +128 -72
- package/src/core/components/ui/alert/alert.spec.ts +145 -0
- package/src/core/components/ui/alert/alert.ts +86 -91
- package/src/core/components/ui/alert-messages/alert-messages.ts +1 -1
- package/src/core/components/ui/badge/badge.md +126 -78
- package/src/core/components/ui/badge/badge.ts +29 -81
- package/src/core/components/ui/button/button.md +1 -0
- package/src/core/components/ui/button/button.ts +12 -10
- package/src/core/components/ui/card/card-header.ts +7 -2
- package/src/core/components/ui/card/card.md +120 -65
- package/src/core/components/ui/divider/divider.ts +4 -9
- package/src/core/components/ui/form/checkbox/checkbox.md +1 -1
- package/src/core/components/ui/form/checkbox/checkbox.ts +4 -20
- package/src/core/components/ui/form/fieldset/legend-description.ts +1 -1
- package/src/core/components/ui/form/fieldset/legend.ts +1 -1
- package/src/core/components/ui/form/input/input.md +1 -1
- package/src/core/components/ui/form/input/input.ts +25 -27
- package/src/core/components/ui/form/input-autocomplete/input-autocomplete.md +14 -118
- package/src/core/components/ui/form/input-autocomplete/input-autocomplete.ts +419 -187
- package/src/core/components/ui/form/radio/radio.ts +1 -1
- package/src/core/components/ui/form/select/select.ts +3 -6
- package/src/core/components/ui/form/textarea/textarea.md +1 -1
- package/src/core/components/ui/form/textarea/textarea.ts +1 -2
- package/src/core/components/ui/image/image.md +147 -53
- package/src/core/components/ui/image/image.ts +10 -44
- package/src/core/components/ui/link/link.md +2 -2
- package/src/core/components/ui/link/link.ts +42 -37
- package/src/core/components/ui/modal/modal-close.ts +8 -12
- package/src/core/components/ui/modal/modal.ts +18 -18
- package/src/core/components/ui/pop/pop.md +105 -1
- package/src/core/components/ui/pop/pop.ts +145 -141
- package/src/core/components/ui/table/table.ts +2 -8
- package/src/core/components/ui/theme/theme.ts +1 -1
- package/src/core/components/ui/toast/dismissed.ts +14 -0
- package/src/core/components/ui/toast/render-content.ts +13 -0
- package/src/core/components/ui/toast/toast-item.ts +179 -103
- package/src/core/components/ui/toast/toast.ts +58 -21
- package/src/core/components/ui/toast/types.ts +14 -2
- package/src/core/components/ui/tooltip/tooltip.ts +176 -154
- package/src/core/decorators/subscriber/ancestorAttribute.spec.ts +26 -0
- package/src/core/decorators/subscriber/ancestorAttribute.ts +3 -4
- package/src/core/decorators/subscriber/derive.ts +3 -3
- package/src/core/mixins/Fetcher.ts +1 -1
- package/src/core/mixins/FormCheckable.ts +1 -8
- package/src/core/mixins/FormElement.ts +74 -76
- package/src/core/mixins/Subscriber.ts +5 -1
- package/src/core/utils/AncestorAttributeObserver.ts +183 -70
- package/src/core/utils/DataBindObserver.ts +0 -0
- package/src/core/utils/LocationHandler.ts +12 -5
- package/src/core/utils/Objects.ts +0 -0
- package/src/core/utils/dismissed.ts +22 -0
- package/src/core/utils/positioning.spec.ts +208 -0
- package/src/core/utils/positioning.ts +183 -0
- package/src/directives.ts +1 -3
- package/src/docs/_core-concept/dataFlow.md +1 -1
- package/src/docs/_decorators/ancestor-attribute.md +3 -2
- package/src/docs/_getting-started/cdn-addons.md +1 -0
- package/src/docs/_getting-started/concorde-outside.md +3 -3
- package/src/docs/_misc/formelement-subscriber-removal.md +115 -0
- package/src/docs/_misc/html-integration.md +2 -0
- package/src/docs/code.ts +3 -1
- package/src/docs/components/docs-demo-sources.ts +60 -0
- package/src/docs/docs.ts +1 -0
- package/src/docs/example/docs-input-autocomplete-demos.ts +110 -0
- package/src/docs/mock-api/router.ts +17 -1
- package/src/docs/navigation/navigation.ts +8 -0
- package/src/docs/search/docs-search.json +956 -243
- package/src/docs/tailwind/css/tailwind.css +13 -6
- package/src/tsconfig.json +135 -6
- package/src/tsconfig.tsbuildinfo +1 -1
- package/tailwind.config.js +50 -3
- package/vite/config.js +23 -35
- package/vite.config.mts +5 -0
- package/vitest.setup.ts +49 -13
- package/docs/assets/index-BZiZXMU-.css +0 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { nothing } from "lit";
|
|
2
|
+
import { unsafeHTML } from "lit/directives/unsafe-html.js";
|
|
3
|
+
import { ToastContent } from "@supersoniks/concorde/core/components/ui/toast/types";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Renders toast title/text content: TemplateResult/DirectiveResult as-is,
|
|
7
|
+
* HTML strings via unsafeHTML (legacy).
|
|
8
|
+
*/
|
|
9
|
+
export function renderToastContent(content?: ToastContent) {
|
|
10
|
+
if (!content) return nothing;
|
|
11
|
+
if (content instanceof Object) return content;
|
|
12
|
+
return unsafeHTML(content);
|
|
13
|
+
}
|
|
@@ -1,23 +1,37 @@
|
|
|
1
|
-
import { html, LitElement, css, nothing } from "lit";
|
|
1
|
+
import { html, LitElement, css, nothing, PropertyValues } from "lit";
|
|
2
2
|
import { customElement, property, state } from "lit/decorators.js";
|
|
3
|
-
import { unsafeHTML } from "lit/directives/unsafe-html.js";
|
|
4
3
|
import "@supersoniks/concorde/core/components/ui/toast/types";
|
|
5
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
ToastContent,
|
|
6
|
+
ToastStatus,
|
|
7
|
+
ToastStyleSheetInput,
|
|
8
|
+
} from "@supersoniks/concorde/core/components/ui/toast/types";
|
|
9
|
+
import { renderToastContent } from "@supersoniks/concorde/core/components/ui/toast/render-content";
|
|
10
|
+
import { normalizeStyleSheets } from "@supersoniks/concorde/core/components/ui/modal/modal-utils";
|
|
6
11
|
import { customScroll } from "@supersoniks/concorde/core/components/ui/_css/scroll";
|
|
7
12
|
import { HTML } from "@supersoniks/concorde/utils";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
import {
|
|
14
|
+
isToastDismissed,
|
|
15
|
+
markToastDismissed,
|
|
16
|
+
} from "@supersoniks/concorde/core/components/ui/toast/dismissed";
|
|
17
|
+
import { resolveToastCloseLabel } from "@supersoniks/concorde/core/components/ui/_i18n/ui-aria-labels";
|
|
18
|
+
|
|
19
|
+
import {
|
|
20
|
+
statusAriaLive,
|
|
21
|
+
statusAriaRole,
|
|
22
|
+
statusColor,
|
|
23
|
+
statusIcon,
|
|
24
|
+
toStatus,
|
|
25
|
+
} from "@supersoniks/concorde/core/components/ui/_css/type";
|
|
26
|
+
|
|
27
|
+
const AUTO_HIDE_DELAY = 6000;
|
|
15
28
|
const tagName = "sonic-toast-item";
|
|
16
29
|
|
|
17
30
|
@customElement(tagName)
|
|
18
31
|
export class SonicToastItem extends LitElement {
|
|
19
32
|
static styles = [
|
|
20
33
|
customScroll,
|
|
34
|
+
statusColor,
|
|
21
35
|
css`
|
|
22
36
|
* {
|
|
23
37
|
box-sizing: border-box;
|
|
@@ -26,7 +40,6 @@ export class SonicToastItem extends LitElement {
|
|
|
26
40
|
display: block;
|
|
27
41
|
pointer-events: auto;
|
|
28
42
|
position: relative;
|
|
29
|
-
--sc-toast-status-color: transparent;
|
|
30
43
|
--sc-toast-color: var(--sc-base-content, #000);
|
|
31
44
|
--sc-toast-bg: var(--sc-base, #fff);
|
|
32
45
|
--sc-toast-rounded: var(--sc-rounded-md);
|
|
@@ -47,14 +60,13 @@ export class SonicToastItem extends LitElement {
|
|
|
47
60
|
pointer-events: auto;
|
|
48
61
|
overflow: hidden;
|
|
49
62
|
line-height: 1.25;
|
|
50
|
-
color: var(--sc-toast-color);
|
|
51
63
|
box-shadow: var(--sc-toast-shadow);
|
|
52
64
|
border-radius: var(--sc-toast-rounded);
|
|
53
65
|
background: var(--sc-toast-bg);
|
|
54
66
|
}
|
|
55
67
|
|
|
56
68
|
.sonic-toast-content {
|
|
57
|
-
padding:
|
|
69
|
+
padding: 0.8em 2.25rem 0.8em 0.8em;
|
|
58
70
|
display: flex;
|
|
59
71
|
gap: 0.5rem;
|
|
60
72
|
overflow: auto;
|
|
@@ -62,6 +74,7 @@ export class SonicToastItem extends LitElement {
|
|
|
62
74
|
}
|
|
63
75
|
|
|
64
76
|
.sonic-toast-text {
|
|
77
|
+
color: var(--sc-toast-color);
|
|
65
78
|
align-self: center;
|
|
66
79
|
margin-top: auto;
|
|
67
80
|
margin-bottom: auto;
|
|
@@ -109,6 +122,7 @@ export class SonicToastItem extends LitElement {
|
|
|
109
122
|
border-radius: 50%;
|
|
110
123
|
text-align: center;
|
|
111
124
|
opacity: 0.5;
|
|
125
|
+
color: var(--sc-toast-color);
|
|
112
126
|
background: rgba(0, 0, 0, 0);
|
|
113
127
|
}
|
|
114
128
|
|
|
@@ -128,39 +142,21 @@ export class SonicToastItem extends LitElement {
|
|
|
128
142
|
/*Title*/
|
|
129
143
|
.sonic-toast-title {
|
|
130
144
|
font-weight: bold;
|
|
131
|
-
font-size: 1.
|
|
132
|
-
margin: 0.15em 0 0.
|
|
145
|
+
font-size: 1.125rem;
|
|
146
|
+
margin: 0.15em 0 0.15em;
|
|
133
147
|
line-height: 1.2;
|
|
134
148
|
}
|
|
135
149
|
|
|
136
|
-
/*STATUS*/
|
|
137
|
-
.
|
|
138
|
-
|
|
139
|
-
--sc-success,
|
|
140
|
-
var(--sc-base-content, #000)
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
.error {
|
|
145
|
-
--sc-toast-status-color: var(--sc-danger, var(--sc-base-content, #000));
|
|
150
|
+
/*STATUS — accent via statusColor (--sc-_color) */
|
|
151
|
+
:host([status]) .sonic-toast {
|
|
152
|
+
border-top: 3px solid var(--sc-_color);
|
|
146
153
|
}
|
|
147
154
|
|
|
148
|
-
.
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
.info {
|
|
156
|
-
--sc-toast-status-color: var(--sc-info, var(--sc-base-content, #000));
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
.success,
|
|
160
|
-
.error,
|
|
161
|
-
.info,
|
|
162
|
-
.warning {
|
|
163
|
-
border-top: 3px solid var(--sc-toast-status-color, currentColor);
|
|
155
|
+
:host([status="success"]) .sonic-toast:before,
|
|
156
|
+
:host([status="error"]) .sonic-toast:before,
|
|
157
|
+
:host([status="info"]) .sonic-toast:before,
|
|
158
|
+
:host([status="warning"]) .sonic-toast:before {
|
|
159
|
+
background-color: var(--sc-_color);
|
|
164
160
|
}
|
|
165
161
|
|
|
166
162
|
.sonic-toast:before {
|
|
@@ -175,20 +171,12 @@ export class SonicToastItem extends LitElement {
|
|
|
175
171
|
pointer-events: none;
|
|
176
172
|
transition: 0.2s;
|
|
177
173
|
border-radius: var(--sc-toast-rounded);
|
|
178
|
-
background-color: var(--sc-toast-status-color);
|
|
179
174
|
}
|
|
180
175
|
|
|
181
176
|
.sonic-toast:hover:before {
|
|
182
177
|
opacity: 0.025;
|
|
183
178
|
}
|
|
184
179
|
|
|
185
|
-
.info .sonic-toast-icon,
|
|
186
|
-
.error .sonic-toast-icon,
|
|
187
|
-
.success .sonic-toast-icon,
|
|
188
|
-
.warning .sonic-toast-icon {
|
|
189
|
-
color: var(--sc-toast-status-color, currentColor);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
180
|
.sonic-toast-icon {
|
|
193
181
|
position: sticky;
|
|
194
182
|
top: 0;
|
|
@@ -201,16 +189,54 @@ export class SonicToastItem extends LitElement {
|
|
|
201
189
|
`,
|
|
202
190
|
];
|
|
203
191
|
|
|
204
|
-
@property(
|
|
192
|
+
@property() label: ToastContent = "";
|
|
205
193
|
@property({ type: String }) id = "";
|
|
206
|
-
@property(
|
|
207
|
-
@property({ type: String }) status: ToastStatus = "";
|
|
194
|
+
@property() text: ToastContent = "";
|
|
195
|
+
@property({ type: String, reflect: true }) status: ToastStatus = "";
|
|
208
196
|
@property({ type: Boolean }) ghost = false;
|
|
209
197
|
@property({ type: Boolean }) preserve = false;
|
|
210
198
|
@property({ type: Boolean }) dismissForever = false;
|
|
211
199
|
@property({ type: String }) maxHeight = "10rem";
|
|
200
|
+
@property({ type: Boolean }) useSlot = false;
|
|
201
|
+
@property({ attribute: false }) styleSheet?: ToastStyleSheetInput;
|
|
212
202
|
@state() visible = true;
|
|
213
203
|
@state() private _titleId: string = "";
|
|
204
|
+
@state() private _dismissed = false;
|
|
205
|
+
private _adoptedStyleSheets: Array<CSSStyleSheet> = [];
|
|
206
|
+
private _hideTimer?: ReturnType<typeof setTimeout>;
|
|
207
|
+
private _hideRemaining = AUTO_HIDE_DELAY;
|
|
208
|
+
private _hideStartedAt = 0;
|
|
209
|
+
private _hovered = false;
|
|
210
|
+
private _focused = false;
|
|
211
|
+
private _hidden = false;
|
|
212
|
+
|
|
213
|
+
connectedCallback(): void {
|
|
214
|
+
super.connectedCallback();
|
|
215
|
+
this.addEventListener("mouseenter", this._onMouseEnter);
|
|
216
|
+
this.addEventListener("mouseleave", this._onMouseLeave);
|
|
217
|
+
this.addEventListener("focusin", this._onFocusIn);
|
|
218
|
+
this.addEventListener("focusout", this._onFocusOut);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
disconnectedCallback(): void {
|
|
222
|
+
this._clearHideTimer();
|
|
223
|
+
this.removeEventListener("mouseenter", this._onMouseEnter);
|
|
224
|
+
this.removeEventListener("mouseleave", this._onMouseLeave);
|
|
225
|
+
this.removeEventListener("focusin", this._onFocusIn);
|
|
226
|
+
this.removeEventListener("focusout", this._onFocusOut);
|
|
227
|
+
super.disconnectedCallback();
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
protected willUpdate(changedProperties: PropertyValues): void {
|
|
231
|
+
if (
|
|
232
|
+
changedProperties.has("dismissForever") ||
|
|
233
|
+
changedProperties.has("id")
|
|
234
|
+
) {
|
|
235
|
+
this._dismissed =
|
|
236
|
+
this.dismissForever && !!this.id && isToastDismissed(this.id);
|
|
237
|
+
}
|
|
238
|
+
super.willUpdate(changedProperties);
|
|
239
|
+
}
|
|
214
240
|
|
|
215
241
|
// @queryAssignedElements({flatten: true, slot: main"})
|
|
216
242
|
// textSlot!: HTMLElement[];
|
|
@@ -221,7 +247,7 @@ export class SonicToastItem extends LitElement {
|
|
|
221
247
|
* - "status" pour les autres (messages informatifs)
|
|
222
248
|
*/
|
|
223
249
|
getAriaRole(): "alert" | "status" {
|
|
224
|
-
return this.status
|
|
250
|
+
return statusAriaRole(toStatus(this.status) ?? "default");
|
|
225
251
|
}
|
|
226
252
|
|
|
227
253
|
/**
|
|
@@ -230,7 +256,7 @@ export class SonicToastItem extends LitElement {
|
|
|
230
256
|
* - "polite" pour les autres (peut attendre)
|
|
231
257
|
*/
|
|
232
258
|
getAriaLive(): "polite" | null {
|
|
233
|
-
return this.status
|
|
259
|
+
return statusAriaLive(toStatus(this.status) ?? "default");
|
|
234
260
|
}
|
|
235
261
|
|
|
236
262
|
/**
|
|
@@ -246,56 +272,30 @@ export class SonicToastItem extends LitElement {
|
|
|
246
272
|
return this._titleId;
|
|
247
273
|
}
|
|
248
274
|
|
|
249
|
-
/**
|
|
250
|
-
* Génère un label ARIA descriptif pour le bouton de fermeture
|
|
251
|
-
*/
|
|
252
|
-
getCloseButtonLabel(): string {
|
|
253
|
-
const statusLabels: Record<string, string> = {
|
|
254
|
-
error: "Fermer le message d'erreur",
|
|
255
|
-
warning: "Fermer l'avertissement",
|
|
256
|
-
success: "Fermer le message de succès",
|
|
257
|
-
info: "Fermer l'information",
|
|
258
|
-
};
|
|
259
|
-
const statusLabel = this.status
|
|
260
|
-
? statusLabels[this.status] || "Fermer la notification"
|
|
261
|
-
: "Fermer la notification";
|
|
262
|
-
return statusLabel;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
275
|
render() {
|
|
266
|
-
|
|
267
|
-
if (this.dismissForever) {
|
|
268
|
-
const dismissed = localStorage.getItem("sonic-toast-dismissed") || "{}";
|
|
269
|
-
const dismissedObj = JSON.parse(dismissed);
|
|
270
|
-
if (dismissedObj[this.id]) {
|
|
271
|
-
return nothing;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
if (!this.visible) {
|
|
276
|
+
if (this._dismissed || !this.visible) {
|
|
276
277
|
return nothing;
|
|
277
278
|
}
|
|
278
279
|
|
|
279
|
-
const titleId = this.
|
|
280
|
+
const titleId = this.label ? this.getTitleId() : undefined;
|
|
280
281
|
// Extrait un label pour aria-label si pas de titre, en essayant de couper proprement
|
|
281
282
|
const ariaLabel =
|
|
282
|
-
!this.
|
|
283
|
+
!this.label && typeof this.text === "string"
|
|
283
284
|
? this.text.length > 100
|
|
284
285
|
? this.text.substring(0, 100).replace(/\s+\S*$/, "") + "..."
|
|
285
286
|
: this.text
|
|
286
287
|
: undefined;
|
|
287
288
|
|
|
288
289
|
const ariaLive = this.getAriaLive();
|
|
289
|
-
|
|
290
290
|
return html`<div
|
|
291
|
-
class="sonic-toast ${this.
|
|
291
|
+
class="sonic-toast ${this.ghost ? "ghost" : ""}"
|
|
292
292
|
role=${this.getAriaRole()}
|
|
293
293
|
aria-live=${ariaLive || nothing}
|
|
294
294
|
aria-atomic="true"
|
|
295
295
|
aria-label=${ariaLabel || nothing}
|
|
296
296
|
>
|
|
297
297
|
<button
|
|
298
|
-
aria-label=${this.
|
|
298
|
+
aria-label=${resolveToastCloseLabel(this.status)}
|
|
299
299
|
class="sonic-toast-close"
|
|
300
300
|
@click=${() => this.hide()}
|
|
301
301
|
>
|
|
@@ -307,52 +307,128 @@ export class SonicToastItem extends LitElement {
|
|
|
307
307
|
>
|
|
308
308
|
${this.status &&
|
|
309
309
|
html`<sonic-icon
|
|
310
|
-
name=${
|
|
310
|
+
name=${statusIcon[toStatus(this.status) ?? "default"]}
|
|
311
311
|
class="sonic-toast-icon"
|
|
312
|
-
size="
|
|
312
|
+
size="xl"
|
|
313
313
|
aria-hidden="true"
|
|
314
314
|
></sonic-icon>`}
|
|
315
315
|
|
|
316
316
|
<div class="sonic-toast-text">
|
|
317
|
-
${this.
|
|
317
|
+
${this.label
|
|
318
318
|
? html`<div class="sonic-toast-title" id=${titleId}>
|
|
319
|
-
${this.
|
|
319
|
+
${renderToastContent(this.label)}
|
|
320
320
|
</div>`
|
|
321
321
|
: ""}
|
|
322
|
-
${this.
|
|
322
|
+
${this.useSlot ? nothing : renderToastContent(this.text)}
|
|
323
323
|
<slot></slot>
|
|
324
324
|
</div>
|
|
325
|
-
|
|
326
|
-
${!this.preserve ? this.autoHide() : ""}
|
|
327
325
|
</div>
|
|
328
326
|
</div>`;
|
|
329
327
|
}
|
|
330
328
|
|
|
329
|
+
protected updated(_changedProperties: PropertyValues): void {
|
|
330
|
+
if (_changedProperties.has("styleSheet")) {
|
|
331
|
+
this.syncAdoptedStyleSheets();
|
|
332
|
+
}
|
|
333
|
+
if (
|
|
334
|
+
_changedProperties.has("preserve") ||
|
|
335
|
+
_changedProperties.has("visible") ||
|
|
336
|
+
_changedProperties.has("_dismissed")
|
|
337
|
+
) {
|
|
338
|
+
this._syncHideTimer();
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
syncAdoptedStyleSheets() {
|
|
343
|
+
if (!(this.renderRoot instanceof ShadowRoot)) return;
|
|
344
|
+
|
|
345
|
+
const nextStyleSheets = normalizeStyleSheets(this.styleSheet);
|
|
346
|
+
const currentStyleSheets = this.renderRoot.adoptedStyleSheets.filter(
|
|
347
|
+
(sheet) => !this._adoptedStyleSheets.includes(sheet),
|
|
348
|
+
);
|
|
349
|
+
|
|
350
|
+
this.renderRoot.adoptedStyleSheets = [
|
|
351
|
+
...currentStyleSheets,
|
|
352
|
+
...nextStyleSheets,
|
|
353
|
+
];
|
|
354
|
+
this._adoptedStyleSheets = nextStyleSheets;
|
|
355
|
+
}
|
|
356
|
+
|
|
331
357
|
hide() {
|
|
358
|
+
this._clearHideTimer();
|
|
359
|
+
this._hidden = true;
|
|
332
360
|
if (!HTML.getClosestElement(this, "sonic-toast")) {
|
|
333
361
|
this.visible = false;
|
|
334
362
|
}
|
|
335
363
|
|
|
336
364
|
if (this.dismissForever) {
|
|
337
|
-
|
|
338
|
-
const dismissed = localStorage.getItem("sonic-toast-dismissed") || "{}";
|
|
339
|
-
const dismissedObj = JSON.parse(dismissed);
|
|
340
|
-
dismissedObj[this.id] = true;
|
|
341
|
-
localStorage.setItem(
|
|
342
|
-
"sonic-toast-dismissed",
|
|
343
|
-
JSON.stringify(dismissedObj)
|
|
344
|
-
);
|
|
365
|
+
markToastDismissed(this.id);
|
|
345
366
|
}
|
|
346
367
|
this.dispatchEvent(new CustomEvent("hide", { bubbles: true }));
|
|
347
368
|
}
|
|
348
369
|
|
|
349
370
|
show() {
|
|
371
|
+
this._hidden = false;
|
|
372
|
+
this._hideRemaining = AUTO_HIDE_DELAY;
|
|
350
373
|
this.visible = true;
|
|
374
|
+
this._syncHideTimer();
|
|
351
375
|
}
|
|
352
376
|
|
|
353
|
-
|
|
354
|
-
|
|
377
|
+
private _syncHideTimer() {
|
|
378
|
+
const shouldRun =
|
|
379
|
+
!this.preserve &&
|
|
380
|
+
this.visible &&
|
|
381
|
+
!this._hidden &&
|
|
382
|
+
!this._dismissed &&
|
|
383
|
+
!this._hovered &&
|
|
384
|
+
!this._focused;
|
|
385
|
+
|
|
386
|
+
if (!shouldRun) {
|
|
387
|
+
this._pauseHideTimer();
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
if (this._hideTimer) return;
|
|
391
|
+
|
|
392
|
+
this._hideStartedAt = Date.now();
|
|
393
|
+
this._hideTimer = setTimeout(() => {
|
|
394
|
+
this._hideTimer = undefined;
|
|
355
395
|
this.hide();
|
|
356
|
-
},
|
|
396
|
+
}, this._hideRemaining);
|
|
357
397
|
}
|
|
398
|
+
|
|
399
|
+
private _pauseHideTimer() {
|
|
400
|
+
if (!this._hideTimer) return;
|
|
401
|
+
clearTimeout(this._hideTimer);
|
|
402
|
+
this._hideTimer = undefined;
|
|
403
|
+
this._hideRemaining = Math.max(
|
|
404
|
+
0,
|
|
405
|
+
this._hideRemaining - (Date.now() - this._hideStartedAt),
|
|
406
|
+
);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
private _clearHideTimer() {
|
|
410
|
+
clearTimeout(this._hideTimer);
|
|
411
|
+
this._hideTimer = undefined;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
private _onMouseEnter = () => {
|
|
415
|
+
this._hovered = true;
|
|
416
|
+
this._syncHideTimer();
|
|
417
|
+
};
|
|
418
|
+
|
|
419
|
+
private _onMouseLeave = () => {
|
|
420
|
+
this._hovered = false;
|
|
421
|
+
this._syncHideTimer();
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
private _onFocusIn = () => {
|
|
425
|
+
this._focused = true;
|
|
426
|
+
this._syncHideTimer();
|
|
427
|
+
};
|
|
428
|
+
|
|
429
|
+
private _onFocusOut = (e: FocusEvent) => {
|
|
430
|
+
if (this.contains(e.relatedTarget as Node | null)) return;
|
|
431
|
+
this._focused = false;
|
|
432
|
+
this._syncHideTimer();
|
|
433
|
+
};
|
|
358
434
|
}
|
|
@@ -5,13 +5,33 @@ import { animate } from "@lit-labs/motion";
|
|
|
5
5
|
import Objects from "@supersoniks/concorde/core/utils/Objects";
|
|
6
6
|
import "@supersoniks/concorde/core/components/ui/icon/icon";
|
|
7
7
|
import { ifDefined } from "lit/directives/if-defined.js";
|
|
8
|
-
import { unsafeHTML } from "lit/directives/unsafe-html.js";
|
|
9
8
|
import { styleMap, StyleInfo } from "lit/directives/style-map.js";
|
|
10
9
|
import "@supersoniks/concorde/core/components/ui/toast/toast-item";
|
|
10
|
+
import { renderToastContent } from "@supersoniks/concorde/core/components/ui/toast/render-content";
|
|
11
|
+
import { isToastDismissed } from "@supersoniks/concorde/core/components/ui/toast/dismissed";
|
|
11
12
|
import {
|
|
12
13
|
Toast,
|
|
14
|
+
ToastContent,
|
|
13
15
|
ToastStatus,
|
|
14
16
|
} from "@supersoniks/concorde/core/components/ui/toast/types";
|
|
17
|
+
|
|
18
|
+
let deprecatedTitleWarned = false;
|
|
19
|
+
|
|
20
|
+
function resolveToastLabel(
|
|
21
|
+
conf: Pick<Toast, "label" | "title">,
|
|
22
|
+
): ToastContent | undefined {
|
|
23
|
+
if (conf.label !== undefined) return conf.label;
|
|
24
|
+
if (conf.title !== undefined) {
|
|
25
|
+
if (!deprecatedTitleWarned) {
|
|
26
|
+
deprecatedTitleWarned = true;
|
|
27
|
+
console.warn(
|
|
28
|
+
"[concorde] Toast.title est déprécié, utiliser Toast.label.",
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
return conf.title;
|
|
32
|
+
}
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
15
35
|
import { ConcordeWindow } from "@supersoniks/concorde/core/_types/types";
|
|
16
36
|
import { Theme } from "@supersoniks/concorde/core/components/ui/theme/theme";
|
|
17
37
|
import { sonicClassPrefix } from "@supersoniks/concorde/core/utils/Utils";
|
|
@@ -47,7 +67,7 @@ export class SonicToast extends LitElement {
|
|
|
47
67
|
bottom: "1.25rem",
|
|
48
68
|
right: "1.25rem",
|
|
49
69
|
zIndex: "10000",
|
|
50
|
-
maxWidth: "
|
|
70
|
+
maxWidth: "45ch",
|
|
51
71
|
flexDirection: "column-reverse",
|
|
52
72
|
};
|
|
53
73
|
}
|
|
@@ -55,7 +75,6 @@ export class SonicToast extends LitElement {
|
|
|
55
75
|
// ${window.parent == window ? "fixed-area" : ""}
|
|
56
76
|
SonicToast.handleExistingToastDelegation();
|
|
57
77
|
if (!this.toasts) return nothing;
|
|
58
|
-
|
|
59
78
|
return html`<div style=${styleMap(styles)}>
|
|
60
79
|
${repeat(
|
|
61
80
|
this.toasts,
|
|
@@ -64,7 +83,10 @@ export class SonicToast extends LitElement {
|
|
|
64
83
|
<sonic-toast-item
|
|
65
84
|
maxHeight=${isIframe ? "none" : "10rem"}
|
|
66
85
|
status=${ifDefined(item.status)}
|
|
67
|
-
|
|
86
|
+
.label=${resolveToastLabel(item)}
|
|
87
|
+
.text=${item.useSlot ? undefined : item.text}
|
|
88
|
+
.styleSheet=${item.styleSheet}
|
|
89
|
+
?useSlot=${item.useSlot}
|
|
68
90
|
?ghost=${item.ghost}
|
|
69
91
|
?dismissForever=${item.dismissForever}
|
|
70
92
|
?preserve=${item.preserve}
|
|
@@ -93,10 +115,9 @@ export class SonicToast extends LitElement {
|
|
|
93
115
|
stabilizeOut: true,
|
|
94
116
|
})}
|
|
95
117
|
>
|
|
96
|
-
|
|
97
|
-
${item.text ? unsafeHTML(item.text) : ""}
|
|
118
|
+
${item.useSlot ? renderToastContent(item.text) : nothing}
|
|
98
119
|
</sonic-toast-item>
|
|
99
|
-
|
|
120
|
+
`,
|
|
100
121
|
)}
|
|
101
122
|
</div>`;
|
|
102
123
|
}
|
|
@@ -124,7 +145,21 @@ export class SonicToast extends LitElement {
|
|
|
124
145
|
|
|
125
146
|
// Filtrer pour garder seulement les toasts qui ne correspondent pas au statut donné
|
|
126
147
|
toastComponent.toasts = toastComponent.toasts.filter(
|
|
127
|
-
(toast) => toast.status !== status
|
|
148
|
+
(toast) => toast.status !== status,
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
static removeItemById(id: string | number) {
|
|
153
|
+
if (SonicToast.delegateToasts) {
|
|
154
|
+
SonicToast.handleExistingToastDelegation();
|
|
155
|
+
window.parent.postMessage({ type: "removeItemById", id }, "*");
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
const toastComponent: SonicToast = SonicToast.getInstance();
|
|
159
|
+
if (!toastComponent) return;
|
|
160
|
+
|
|
161
|
+
toastComponent.toasts = toastComponent.toasts.filter(
|
|
162
|
+
(toast) => toast.id !== id,
|
|
128
163
|
);
|
|
129
164
|
}
|
|
130
165
|
|
|
@@ -139,7 +174,7 @@ export class SonicToast extends LitElement {
|
|
|
139
174
|
if (!toastComponent) return;
|
|
140
175
|
|
|
141
176
|
toastComponent.toasts = toastComponent.toasts.filter(
|
|
142
|
-
(item) => item.preserve
|
|
177
|
+
(item) => item.preserve,
|
|
143
178
|
);
|
|
144
179
|
}
|
|
145
180
|
|
|
@@ -159,32 +194,30 @@ export class SonicToast extends LitElement {
|
|
|
159
194
|
}
|
|
160
195
|
// Init toast area si absente (au <sonic-theme> ou <body< à défaut)
|
|
161
196
|
const toastComponent = SonicToast.getInstance();
|
|
162
|
-
|
|
163
197
|
// Ajoute le toast à la liste
|
|
164
198
|
const nextId = conf.id ?? new Date().valueOf();
|
|
165
199
|
|
|
166
200
|
const interactiveRegExp = new RegExp(
|
|
167
|
-
"</a>|</.*?button>|</.*?input>|</.*?textarea>|</.*?select>"
|
|
201
|
+
"</a>|</.*?button>|</.*?input>|</.*?textarea>|</.*?select>",
|
|
168
202
|
);
|
|
169
|
-
const hasInteractive =
|
|
203
|
+
const hasInteractive =
|
|
204
|
+
typeof conf.text === "string" && interactiveRegExp.test(conf.text);
|
|
170
205
|
|
|
171
206
|
const currentToast = {
|
|
172
207
|
id: nextId,
|
|
173
208
|
text: conf.text,
|
|
174
|
-
|
|
209
|
+
label: resolveToastLabel(conf),
|
|
175
210
|
status: conf.status,
|
|
176
211
|
preserve: hasInteractive ? true : conf.preserve,
|
|
177
212
|
ghost: conf.ghost,
|
|
178
213
|
dismissForever: conf.dismissForever,
|
|
214
|
+
styleSheet: conf.styleSheet,
|
|
215
|
+
useSlot: conf.useSlot,
|
|
179
216
|
};
|
|
180
217
|
|
|
181
218
|
// check if the toast is dismissed
|
|
182
|
-
if (conf.dismissForever && conf.id) {
|
|
183
|
-
|
|
184
|
-
const dismissedObj = JSON.parse(dismissed);
|
|
185
|
-
if (dismissedObj[conf.id]) {
|
|
186
|
-
return null;
|
|
187
|
-
}
|
|
219
|
+
if (conf.dismissForever && conf.id && isToastDismissed(conf.id)) {
|
|
220
|
+
return null;
|
|
188
221
|
}
|
|
189
222
|
|
|
190
223
|
if (toastComponent?.toasts.length) {
|
|
@@ -210,7 +243,7 @@ export class SonicToast extends LitElement {
|
|
|
210
243
|
const toastComponent: SonicToast = SonicToast.getInstance();
|
|
211
244
|
window.parent.postMessage(
|
|
212
245
|
{ type: "addToasts", toasts: toastComponent.toasts },
|
|
213
|
-
"*"
|
|
246
|
+
"*",
|
|
214
247
|
);
|
|
215
248
|
toastComponent.toasts = [];
|
|
216
249
|
}
|
|
@@ -220,7 +253,7 @@ export class SonicToast extends LitElement {
|
|
|
220
253
|
SonicToast.handleExistingToastDelegation();
|
|
221
254
|
window.parent.postMessage(
|
|
222
255
|
{ type: "removeToast", toast: toastToRemove },
|
|
223
|
-
"*"
|
|
256
|
+
"*",
|
|
224
257
|
);
|
|
225
258
|
return;
|
|
226
259
|
}
|
|
@@ -257,6 +290,10 @@ function handleIframeContexts() {
|
|
|
257
290
|
SonicToast.removeItemsByStatus(e.data.status);
|
|
258
291
|
}
|
|
259
292
|
|
|
293
|
+
if (e.data.type == "removeItemById") {
|
|
294
|
+
SonicToast.removeItemById(e.data.id);
|
|
295
|
+
}
|
|
296
|
+
|
|
260
297
|
if (e.data.type == "removeTemporaryItems") {
|
|
261
298
|
SonicToast.removeTemporaryItems();
|
|
262
299
|
}
|
|
@@ -1,14 +1,26 @@
|
|
|
1
1
|
import { Message } from "@supersoniks/concorde/core/_types/types";
|
|
2
|
+
import { TemplateResult } from "lit";
|
|
3
|
+
import { DirectiveResult } from "lit/directive.js";
|
|
4
|
+
import { ModalStyleSheetInput } from "@supersoniks/concorde/core/components/ui/modal/modal-utils";
|
|
2
5
|
|
|
3
6
|
export type ToastStatus = Message["status"] | "" | "success";
|
|
4
7
|
|
|
8
|
+
export type ToastContent = string | TemplateResult | DirectiveResult;
|
|
9
|
+
|
|
10
|
+
export type ToastStyleSheetInput = ModalStyleSheetInput;
|
|
11
|
+
|
|
5
12
|
// Toast
|
|
6
13
|
export type Toast = {
|
|
7
14
|
id?: string | number;
|
|
8
|
-
text:
|
|
9
|
-
|
|
15
|
+
text: ToastContent;
|
|
16
|
+
label?: ToastContent;
|
|
17
|
+
/** @deprecated Utiliser `label`. */
|
|
18
|
+
title?: ToastContent;
|
|
10
19
|
status?: ToastStatus;
|
|
11
20
|
preserve?: boolean;
|
|
12
21
|
ghost?: boolean;
|
|
13
22
|
dismissForever?: boolean;
|
|
23
|
+
styleSheet?: ToastStyleSheetInput;
|
|
24
|
+
/** Legacy: project text into the light DOM slot instead of the shadow root. */
|
|
25
|
+
useSlot?: boolean;
|
|
14
26
|
};
|