@lo-tek/interfaces 0.0.0 → 0.38.0
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/CHANGELOG.md +3389 -0
- package/LICENSE +21 -0
- package/README.md +129 -1
- package/agent/astro.md +400 -0
- package/agent/bundles.md +429 -0
- package/agent/datastar.md +409 -0
- package/agent/html.md +388 -0
- package/agent/react.md +440 -0
- package/agent/templates.md +472 -0
- package/core/lotek-core.wasm +0 -0
- package/core/lotek.wasm +0 -0
- package/dist/cli.d.ts +12 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +14 -0
- package/dist/cli.js.map +1 -0
- package/dist/components/css/accordion/accordion.d.ts +37 -0
- package/dist/components/css/accordion/accordion.d.ts.map +1 -0
- package/dist/components/css/accordion/accordion.js +31 -0
- package/dist/components/css/accordion/accordion.js.map +1 -0
- package/dist/components/css/alert/alert.d.ts +35 -0
- package/dist/components/css/alert/alert.d.ts.map +1 -0
- package/dist/components/css/alert/alert.js +29 -0
- package/dist/components/css/alert/alert.js.map +1 -0
- package/dist/components/css/avatar/avatar.d.ts +40 -0
- package/dist/components/css/avatar/avatar.d.ts.map +1 -0
- package/dist/components/css/avatar/avatar.js +30 -0
- package/dist/components/css/avatar/avatar.js.map +1 -0
- package/dist/components/css/badge/badge.d.ts +24 -0
- package/dist/components/css/badge/badge.d.ts.map +1 -0
- package/dist/components/css/badge/badge.js +24 -0
- package/dist/components/css/badge/badge.js.map +1 -0
- package/dist/components/css/breadcrumbs/breadcrumbs.d.ts +26 -0
- package/dist/components/css/breadcrumbs/breadcrumbs.d.ts.map +1 -0
- package/dist/components/css/breadcrumbs/breadcrumbs.js +24 -0
- package/dist/components/css/breadcrumbs/breadcrumbs.js.map +1 -0
- package/dist/components/css/button/button.d.ts +26 -0
- package/dist/components/css/button/button.d.ts.map +1 -0
- package/dist/components/css/button/button.js +25 -0
- package/dist/components/css/button/button.js.map +1 -0
- package/dist/components/css/card/card.d.ts +36 -0
- package/dist/components/css/card/card.d.ts.map +1 -0
- package/dist/components/css/card/card.js +28 -0
- package/dist/components/css/card/card.js.map +1 -0
- package/dist/components/css/checkbox/checkbox.d.ts +32 -0
- package/dist/components/css/checkbox/checkbox.d.ts.map +1 -0
- package/dist/components/css/checkbox/checkbox.js +27 -0
- package/dist/components/css/checkbox/checkbox.js.map +1 -0
- package/dist/components/css/divider/divider.d.ts +29 -0
- package/dist/components/css/divider/divider.d.ts.map +1 -0
- package/dist/components/css/divider/divider.js +23 -0
- package/dist/components/css/divider/divider.js.map +1 -0
- package/dist/components/css/error-text/error-text.d.ts +24 -0
- package/dist/components/css/error-text/error-text.d.ts.map +1 -0
- package/dist/components/css/error-text/error-text.js +18 -0
- package/dist/components/css/error-text/error-text.js.map +1 -0
- package/dist/components/css/fieldset/fieldset.d.ts +55 -0
- package/dist/components/css/fieldset/fieldset.d.ts.map +1 -0
- package/dist/components/css/fieldset/fieldset.js +39 -0
- package/dist/components/css/fieldset/fieldset.js.map +1 -0
- package/dist/components/css/file-upload/file-upload.d.ts +41 -0
- package/dist/components/css/file-upload/file-upload.d.ts.map +1 -0
- package/dist/components/css/file-upload/file-upload.js +32 -0
- package/dist/components/css/file-upload/file-upload.js.map +1 -0
- package/dist/components/css/heading/heading.d.ts +29 -0
- package/dist/components/css/heading/heading.d.ts.map +1 -0
- package/dist/components/css/heading/heading.js +23 -0
- package/dist/components/css/heading/heading.js.map +1 -0
- package/dist/components/css/help-text/help-text.d.ts +24 -0
- package/dist/components/css/help-text/help-text.d.ts.map +1 -0
- package/dist/components/css/help-text/help-text.js +23 -0
- package/dist/components/css/help-text/help-text.js.map +1 -0
- package/dist/components/css/icon/icon.d.ts +34 -0
- package/dist/components/css/icon/icon.d.ts.map +1 -0
- package/dist/components/css/icon/icon.js +25 -0
- package/dist/components/css/icon/icon.js.map +1 -0
- package/dist/components/css/input/input.d.ts +40 -0
- package/dist/components/css/input/input.d.ts.map +1 -0
- package/dist/components/css/input/input.js +45 -0
- package/dist/components/css/input/input.js.map +1 -0
- package/dist/components/css/label/label.d.ts +33 -0
- package/dist/components/css/label/label.d.ts.map +1 -0
- package/dist/components/css/label/label.js +23 -0
- package/dist/components/css/label/label.js.map +1 -0
- package/dist/components/css/link/link.d.ts +28 -0
- package/dist/components/css/link/link.d.ts.map +1 -0
- package/dist/components/css/link/link.js +20 -0
- package/dist/components/css/link/link.js.map +1 -0
- package/dist/components/css/list/list.d.ts +31 -0
- package/dist/components/css/list/list.d.ts.map +1 -0
- package/dist/components/css/list/list.js +25 -0
- package/dist/components/css/list/list.js.map +1 -0
- package/dist/components/css/pagination/pagination.d.ts +27 -0
- package/dist/components/css/pagination/pagination.d.ts.map +1 -0
- package/dist/components/css/pagination/pagination.js +25 -0
- package/dist/components/css/pagination/pagination.js.map +1 -0
- package/dist/components/css/paragraph/paragraph.d.ts +36 -0
- package/dist/components/css/paragraph/paragraph.d.ts.map +1 -0
- package/dist/components/css/paragraph/paragraph.js +26 -0
- package/dist/components/css/paragraph/paragraph.js.map +1 -0
- package/dist/components/css/progress/progress.d.ts +53 -0
- package/dist/components/css/progress/progress.d.ts.map +1 -0
- package/dist/components/css/progress/progress.js +38 -0
- package/dist/components/css/progress/progress.js.map +1 -0
- package/dist/components/css/radio/radio.d.ts +32 -0
- package/dist/components/css/radio/radio.d.ts.map +1 -0
- package/dist/components/css/radio/radio.js +27 -0
- package/dist/components/css/radio/radio.js.map +1 -0
- package/dist/components/css/search/search.d.ts +34 -0
- package/dist/components/css/search/search.d.ts.map +1 -0
- package/dist/components/css/search/search.js +32 -0
- package/dist/components/css/search/search.js.map +1 -0
- package/dist/components/css/select/select.d.ts +40 -0
- package/dist/components/css/select/select.d.ts.map +1 -0
- package/dist/components/css/select/select.js +31 -0
- package/dist/components/css/select/select.js.map +1 -0
- package/dist/components/css/shared.d.ts +90 -0
- package/dist/components/css/shared.d.ts.map +1 -0
- package/dist/components/css/shared.js +167 -0
- package/dist/components/css/shared.js.map +1 -0
- package/dist/components/css/skeleton/skeleton.d.ts +29 -0
- package/dist/components/css/skeleton/skeleton.d.ts.map +1 -0
- package/dist/components/css/skeleton/skeleton.js +23 -0
- package/dist/components/css/skeleton/skeleton.js.map +1 -0
- package/dist/components/css/skip-link/skip-link.d.ts +18 -0
- package/dist/components/css/skip-link/skip-link.d.ts.map +1 -0
- package/dist/components/css/skip-link/skip-link.js +16 -0
- package/dist/components/css/skip-link/skip-link.js.map +1 -0
- package/dist/components/css/spinner/spinner.d.ts +33 -0
- package/dist/components/css/spinner/spinner.d.ts.map +1 -0
- package/dist/components/css/spinner/spinner.js +25 -0
- package/dist/components/css/spinner/spinner.js.map +1 -0
- package/dist/components/css/sr-only/sr-only.d.ts +17 -0
- package/dist/components/css/sr-only/sr-only.d.ts.map +1 -0
- package/dist/components/css/sr-only/sr-only.js +15 -0
- package/dist/components/css/sr-only/sr-only.js.map +1 -0
- package/dist/components/css/switch/switch.d.ts +37 -0
- package/dist/components/css/switch/switch.d.ts.map +1 -0
- package/dist/components/css/switch/switch.js +29 -0
- package/dist/components/css/switch/switch.js.map +1 -0
- package/dist/components/css/table/table.d.ts +76 -0
- package/dist/components/css/table/table.d.ts.map +1 -0
- package/dist/components/css/table/table.js +59 -0
- package/dist/components/css/table/table.js.map +1 -0
- package/dist/components/css/tag/tag.d.ts +35 -0
- package/dist/components/css/tag/tag.d.ts.map +1 -0
- package/dist/components/css/tag/tag.js +27 -0
- package/dist/components/css/tag/tag.js.map +1 -0
- package/dist/components/css/textarea/textarea.d.ts +23 -0
- package/dist/components/css/textarea/textarea.d.ts.map +1 -0
- package/dist/components/css/textarea/textarea.js +18 -0
- package/dist/components/css/textarea/textarea.js.map +1 -0
- package/dist/components/css/toggle-group/toggle-group.d.ts +31 -0
- package/dist/components/css/toggle-group/toggle-group.d.ts.map +1 -0
- package/dist/components/css/toggle-group/toggle-group.js +29 -0
- package/dist/components/css/toggle-group/toggle-group.js.map +1 -0
- package/dist/components/css/tooltip/tooltip.d.ts +31 -0
- package/dist/components/css/tooltip/tooltip.d.ts.map +1 -0
- package/dist/components/css/tooltip/tooltip.js +29 -0
- package/dist/components/css/tooltip/tooltip.js.map +1 -0
- package/dist/components/default-texts.d.ts +41 -0
- package/dist/components/default-texts.d.ts.map +1 -0
- package/dist/components/default-texts.js +41 -0
- package/dist/components/default-texts.js.map +1 -0
- package/dist/components/events.d.ts +77 -0
- package/dist/components/events.d.ts.map +1 -0
- package/dist/components/events.js +3 -0
- package/dist/components/events.js.map +1 -0
- package/dist/components/frame/dialog/dialog.d.ts +122 -0
- package/dist/components/frame/dialog/dialog.d.ts.map +1 -0
- package/dist/components/frame/dialog/dialog.js +112 -0
- package/dist/components/frame/dialog/dialog.js.map +1 -0
- package/dist/components/frame/dialog/lt-dialog.d.ts +104 -0
- package/dist/components/frame/dialog/lt-dialog.d.ts.map +1 -0
- package/dist/components/frame/dialog/lt-dialog.js +434 -0
- package/dist/components/frame/dialog/lt-dialog.js.map +1 -0
- package/dist/components/frame/error-summary/error-summary.d.ts +53 -0
- package/dist/components/frame/error-summary/error-summary.d.ts.map +1 -0
- package/dist/components/frame/error-summary/error-summary.js +54 -0
- package/dist/components/frame/error-summary/error-summary.js.map +1 -0
- package/dist/components/frame/error-summary/lt-error-summary.d.ts +93 -0
- package/dist/components/frame/error-summary/lt-error-summary.d.ts.map +1 -0
- package/dist/components/frame/error-summary/lt-error-summary.js +408 -0
- package/dist/components/frame/error-summary/lt-error-summary.js.map +1 -0
- package/dist/components/frame/field/field-core.d.ts +92 -0
- package/dist/components/frame/field/field-core.d.ts.map +1 -0
- package/dist/components/frame/field/field-core.js +63 -0
- package/dist/components/frame/field/field-core.js.map +1 -0
- package/dist/components/frame/field/lt-field.d.ts +173 -0
- package/dist/components/frame/field/lt-field.d.ts.map +1 -0
- package/dist/components/frame/field/lt-field.js +600 -0
- package/dist/components/frame/field/lt-field.js.map +1 -0
- package/dist/components/frame/popover/lt-popover.d.ts +136 -0
- package/dist/components/frame/popover/lt-popover.d.ts.map +1 -0
- package/dist/components/frame/popover/lt-popover.js +520 -0
- package/dist/components/frame/popover/lt-popover.js.map +1 -0
- package/dist/components/frame/popover/popover.d.ts +49 -0
- package/dist/components/frame/popover/popover.d.ts.map +1 -0
- package/dist/components/frame/popover/popover.js +64 -0
- package/dist/components/frame/popover/popover.js.map +1 -0
- package/dist/components/frame/session-timeout/lt-session-timeout.d.ts +198 -0
- package/dist/components/frame/session-timeout/lt-session-timeout.d.ts.map +1 -0
- package/dist/components/frame/session-timeout/lt-session-timeout.js +610 -0
- package/dist/components/frame/session-timeout/lt-session-timeout.js.map +1 -0
- package/dist/components/frame/session-timeout/session-timeout.d.ts +113 -0
- package/dist/components/frame/session-timeout/session-timeout.d.ts.map +1 -0
- package/dist/components/frame/session-timeout/session-timeout.js +101 -0
- package/dist/components/frame/session-timeout/session-timeout.js.map +1 -0
- package/dist/components/frame/suggestion/lt-suggestion.d.ts +367 -0
- package/dist/components/frame/suggestion/lt-suggestion.d.ts.map +1 -0
- package/dist/components/frame/suggestion/lt-suggestion.js +1171 -0
- package/dist/components/frame/suggestion/lt-suggestion.js.map +1 -0
- package/dist/components/frame/suggestion/suggestion.d.ts +143 -0
- package/dist/components/frame/suggestion/suggestion.d.ts.map +1 -0
- package/dist/components/frame/suggestion/suggestion.js +127 -0
- package/dist/components/frame/suggestion/suggestion.js.map +1 -0
- package/dist/components/frame/tabs/lt-tabs.d.ts +426 -0
- package/dist/components/frame/tabs/lt-tabs.d.ts.map +1 -0
- package/dist/components/frame/tabs/lt-tabs.js +1265 -0
- package/dist/components/frame/tabs/lt-tabs.js.map +1 -0
- package/dist/components/frame/tabs/tabs.d.ts +112 -0
- package/dist/components/frame/tabs/tabs.d.ts.map +1 -0
- package/dist/components/frame/tabs/tabs.js +107 -0
- package/dist/components/frame/tabs/tabs.js.map +1 -0
- package/dist/components/host-element.d.ts +184 -0
- package/dist/components/host-element.d.ts.map +1 -0
- package/dist/components/host-element.js +440 -0
- package/dist/components/host-element.js.map +1 -0
- package/dist/components/standalone/connection-status/connection-status.d.ts +32 -0
- package/dist/components/standalone/connection-status/connection-status.d.ts.map +1 -0
- package/dist/components/standalone/connection-status/connection-status.js +26 -0
- package/dist/components/standalone/connection-status/connection-status.js.map +1 -0
- package/dist/components/standalone/connection-status/lt-connection-status.d.ts +86 -0
- package/dist/components/standalone/connection-status/lt-connection-status.d.ts.map +1 -0
- package/dist/components/standalone/connection-status/lt-connection-status.js +240 -0
- package/dist/components/standalone/connection-status/lt-connection-status.js.map +1 -0
- package/dist/components/standalone/toast/lt-toast.d.ts +109 -0
- package/dist/components/standalone/toast/lt-toast.d.ts.map +1 -0
- package/dist/components/standalone/toast/lt-toast.js +256 -0
- package/dist/components/standalone/toast/lt-toast.js.map +1 -0
- package/dist/components/standalone/toast/toast.d.ts +52 -0
- package/dist/components/standalone/toast/toast.d.ts.map +1 -0
- package/dist/components/standalone/toast/toast.js +42 -0
- package/dist/components/standalone/toast/toast.js.map +1 -0
- package/dist/diagnostics/core.d.ts +171 -0
- package/dist/diagnostics/core.d.ts.map +1 -0
- package/dist/diagnostics/core.js +84 -0
- package/dist/diagnostics/core.js.map +1 -0
- package/dist/diagnostics/default-core.d.ts +10 -0
- package/dist/diagnostics/default-core.d.ts.map +1 -0
- package/dist/diagnostics/default-core.js +72 -0
- package/dist/diagnostics/default-core.js.map +1 -0
- package/dist/diagnostics/index.d.ts +84 -0
- package/dist/diagnostics/index.d.ts.map +1 -0
- package/dist/diagnostics/index.js +106 -0
- package/dist/diagnostics/index.js.map +1 -0
- package/dist/dom.d.ts +55 -0
- package/dist/dom.d.ts.map +1 -0
- package/dist/dom.js +162 -0
- package/dist/dom.js.map +1 -0
- package/dist/index.d.ts +97 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +58 -0
- package/dist/index.js.map +1 -0
- package/dist/jsx/react.d.ts +180 -0
- package/dist/jsx/react.d.ts.map +1 -0
- package/dist/jsx/react.js +2 -0
- package/dist/jsx/react.js.map +1 -0
- package/dist/lotek.css +3617 -0
- package/dist/lt.d.ts +325 -0
- package/dist/lt.d.ts.map +1 -0
- package/dist/lt.js +183 -0
- package/dist/lt.js.map +1 -0
- package/dist/react.d.ts +494 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +296 -0
- package/dist/react.js.map +1 -0
- package/dist/register.d.ts +17 -0
- package/dist/register.d.ts.map +1 -0
- package/dist/register.js +35 -0
- package/dist/register.js.map +1 -0
- package/dist/tokens/color.d.ts +43 -0
- package/dist/tokens/color.d.ts.map +1 -0
- package/dist/tokens/color.js +123 -0
- package/dist/tokens/color.js.map +1 -0
- package/dist/tokens/contract.d.ts +18 -0
- package/dist/tokens/contract.d.ts.map +1 -0
- package/dist/tokens/contract.js +18 -0
- package/dist/tokens/contract.js.map +1 -0
- package/dist/tokens/matrix-cells.d.ts +30 -0
- package/dist/tokens/matrix-cells.d.ts.map +1 -0
- package/dist/tokens/matrix-cells.js +273 -0
- package/dist/tokens/matrix-cells.js.map +1 -0
- package/dist/tokens/matrix.d.ts +18 -0
- package/dist/tokens/matrix.d.ts.map +1 -0
- package/dist/tokens/matrix.js +21 -0
- package/dist/tokens/matrix.js.map +1 -0
- package/dist/tokens/theme-check.d.ts +42 -0
- package/dist/tokens/theme-check.d.ts.map +1 -0
- package/dist/tokens/theme-check.js +10 -0
- package/dist/tokens/theme-check.js.map +1 -0
- package/dist/tokens/theme.d.ts +94 -0
- package/dist/tokens/theme.d.ts.map +1 -0
- package/dist/tokens/theme.js +14 -0
- package/dist/tokens/theme.js.map +1 -0
- package/dist/tokens/tokens.d.ts +122 -0
- package/dist/tokens/tokens.d.ts.map +1 -0
- package/dist/tokens/tokens.js +158 -0
- package/dist/tokens/tokens.js.map +1 -0
- package/dist/vocabulary/classes.d.ts +3 -0
- package/dist/vocabulary/classes.d.ts.map +1 -0
- package/dist/vocabulary/classes.js +1354 -0
- package/dist/vocabulary/classes.js.map +1 -0
- package/dist/vocabulary/elements.d.ts +3 -0
- package/dist/vocabulary/elements.d.ts.map +1 -0
- package/dist/vocabulary/elements.js +490 -0
- package/dist/vocabulary/elements.js.map +1 -0
- package/dist/vocabulary/types.d.ts +229 -0
- package/dist/vocabulary/types.d.ts.map +1 -0
- package/dist/vocabulary/types.js +11 -0
- package/dist/vocabulary/types.js.map +1 -0
- package/dist/wasi-host.d.ts +24 -0
- package/dist/wasi-host.d.ts.map +1 -0
- package/dist/wasi-host.js +140 -0
- package/dist/wasi-host.js.map +1 -0
- package/live-templates.xml +63 -0
- package/manifest/files.json +373 -0
- package/manifest/manifest.json +5090 -0
- package/manifest/manifest.schema.json +586 -0
- package/package.json +399 -5
- package/src/cli.ts +21 -0
- package/src/components/css/accordion/accordion.css +102 -0
- package/src/components/css/accordion/accordion.ts +50 -0
- package/src/components/css/alert/alert.css +53 -0
- package/src/components/css/alert/alert.ts +48 -0
- package/src/components/css/avatar/avatar.css +96 -0
- package/src/components/css/avatar/avatar.ts +57 -0
- package/src/components/css/badge/badge.css +42 -0
- package/src/components/css/badge/badge.ts +43 -0
- package/src/components/css/breadcrumbs/breadcrumbs.css +62 -0
- package/src/components/css/breadcrumbs/breadcrumbs.ts +30 -0
- package/src/components/css/button/button.css +128 -0
- package/src/components/css/button/button.ts +44 -0
- package/src/components/css/card/card.css +65 -0
- package/src/components/css/card/card.ts +50 -0
- package/src/components/css/checkbox/checkbox.css +114 -0
- package/src/components/css/checkbox/checkbox.ts +50 -0
- package/src/components/css/divider/divider.css +38 -0
- package/src/components/css/divider/divider.ts +42 -0
- package/src/components/css/error-text/error-text.css +21 -0
- package/src/components/css/error-text/error-text.ts +37 -0
- package/src/components/css/fieldset/fieldset.css +72 -0
- package/src/components/css/fieldset/fieldset.ts +87 -0
- package/src/components/css/file-upload/file-upload.css +102 -0
- package/src/components/css/file-upload/file-upload.ts +65 -0
- package/src/components/css/heading/heading.css +33 -0
- package/src/components/css/heading/heading.ts +42 -0
- package/src/components/css/help-text/help-text.css +24 -0
- package/src/components/css/help-text/help-text.ts +42 -0
- package/src/components/css/icon/icon.css +20 -0
- package/src/components/css/icon/icon.ts +44 -0
- package/src/components/css/input/input.css +145 -0
- package/src/components/css/input/input.ts +77 -0
- package/src/components/css/label/label.css +42 -0
- package/src/components/css/label/label.ts +51 -0
- package/src/components/css/link/link.css +38 -0
- package/src/components/css/link/link.ts +38 -0
- package/src/components/css/list/list.css +53 -0
- package/src/components/css/list/list.ts +44 -0
- package/src/components/css/pagination/pagination.css +95 -0
- package/src/components/css/pagination/pagination.ts +33 -0
- package/src/components/css/paragraph/paragraph.css +31 -0
- package/src/components/css/paragraph/paragraph.ts +53 -0
- package/src/components/css/progress/progress.css +161 -0
- package/src/components/css/progress/progress.ts +78 -0
- package/src/components/css/radio/radio.css +94 -0
- package/src/components/css/radio/radio.ts +50 -0
- package/src/components/css/search/search.css +50 -0
- package/src/components/css/search/search.ts +56 -0
- package/src/components/css/select/select.css +321 -0
- package/src/components/css/select/select.ts +63 -0
- package/src/components/css/shared.ts +199 -0
- package/src/components/css/skeleton/skeleton.css +62 -0
- package/src/components/css/skeleton/skeleton.ts +43 -0
- package/src/components/css/skip-link/skip-link.css +41 -0
- package/src/components/css/skip-link/skip-link.ts +22 -0
- package/src/components/css/spinner/spinner.css +48 -0
- package/src/components/css/spinner/spinner.ts +48 -0
- package/src/components/css/sr-only/sr-only.css +16 -0
- package/src/components/css/sr-only/sr-only.ts +21 -0
- package/src/components/css/switch/switch.css +105 -0
- package/src/components/css/switch/switch.ts +50 -0
- package/src/components/css/table/table.css +159 -0
- package/src/components/css/table/table.ts +107 -0
- package/src/components/css/tag/tag.css +58 -0
- package/src/components/css/tag/tag.ts +49 -0
- package/src/components/css/textarea/textarea.css +83 -0
- package/src/components/css/textarea/textarea.ts +40 -0
- package/src/components/css/toggle-group/toggle-group.css +92 -0
- package/src/components/css/toggle-group/toggle-group.ts +37 -0
- package/src/components/css/tooltip/tooltip.css +89 -0
- package/src/components/css/tooltip/tooltip.ts +37 -0
- package/src/components/default-texts.ts +41 -0
- package/src/components/events.ts +68 -0
- package/src/components/frame/dialog/dialog.css +306 -0
- package/src/components/frame/dialog/dialog.ts +166 -0
- package/src/components/frame/dialog/lt-dialog.ts +513 -0
- package/src/components/frame/error-summary/error-summary.css +47 -0
- package/src/components/frame/error-summary/error-summary.ts +90 -0
- package/src/components/frame/error-summary/lt-error-summary.ts +458 -0
- package/src/components/frame/field/field-core.ts +152 -0
- package/src/components/frame/field/field.css +17 -0
- package/src/components/frame/field/lt-field.ts +790 -0
- package/src/components/frame/popover/lt-popover.ts +586 -0
- package/src/components/frame/popover/popover.css +50 -0
- package/src/components/frame/popover/popover.ts +102 -0
- package/src/components/frame/session-timeout/lt-session-timeout.ts +715 -0
- package/src/components/frame/session-timeout/session-timeout.css +50 -0
- package/src/components/frame/session-timeout/session-timeout.ts +156 -0
- package/src/components/frame/suggestion/lt-suggestion.ts +1379 -0
- package/src/components/frame/suggestion/suggestion.css +132 -0
- package/src/components/frame/suggestion/suggestion.ts +172 -0
- package/src/components/frame/tabs/lt-tabs.ts +1395 -0
- package/src/components/frame/tabs/tabs.css +128 -0
- package/src/components/frame/tabs/tabs.ts +188 -0
- package/src/components/host-element.ts +493 -0
- package/src/components/standalone/connection-status/connection-status.css +41 -0
- package/src/components/standalone/connection-status/connection-status.ts +47 -0
- package/src/components/standalone/connection-status/lt-connection-status.ts +268 -0
- package/src/components/standalone/toast/lt-toast.ts +300 -0
- package/src/components/standalone/toast/toast.css +78 -0
- package/src/components/standalone/toast/toast.ts +70 -0
- package/src/diagnostics/core.ts +227 -0
- package/src/diagnostics/default-core.ts +81 -0
- package/src/diagnostics/index.ts +150 -0
- package/src/dom.ts +185 -0
- package/src/index.ts +218 -0
- package/src/jsx/react.ts +212 -0
- package/src/lt.ts +192 -0
- package/src/react.ts +411 -0
- package/src/register.ts +43 -0
- package/src/tailwind/tailwind.css +169 -0
- package/src/tokens/boundary.css +104 -0
- package/src/tokens/color-contract.json +231 -0
- package/src/tokens/color.ts +150 -0
- package/src/tokens/contract.ts +24 -0
- package/src/tokens/matrix-cells.ts +375 -0
- package/src/tokens/matrix.ts +32 -0
- package/src/tokens/theme-check.ts +51 -0
- package/src/tokens/theme.ts +104 -0
- package/src/tokens/tokens.css +569 -0
- package/src/tokens/tokens.ts +223 -0
- package/src/vocabulary/classes.ts +1356 -0
- package/src/vocabulary/elements.ts +492 -0
- package/src/vocabulary/types.ts +228 -0
- package/src/wasi-host.ts +155 -0
- package/web-types.json +800 -0
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { defineElement, HostElement, whenUpgraded } from "../../host-element.js";
|
|
2
|
+
import { CONNECTION_STATUS_BAR_CLASS, CONNECTION_STATUS_CLASS, } from "./connection-status.js";
|
|
3
|
+
export const LT_CONNECTION_STATUS_TAG = "lt-connection-status";
|
|
4
|
+
import { DEFAULT_TEXTS } from "../../default-texts.js";
|
|
5
|
+
const DEFAULT_OFFLINE = DEFAULT_TEXTS.connectionOffline;
|
|
6
|
+
const DEFAULT_ONLINE = DEFAULT_TEXTS.connectionOnline;
|
|
7
|
+
/** How long "back online" stays visible. */
|
|
8
|
+
const RECEIPT_MS = 4000;
|
|
9
|
+
/**
|
|
10
|
+
* Tells the user when the connection to the server is lost.
|
|
11
|
+
*
|
|
12
|
+
* By definition the server cannot tell you this. When it is unreachable,
|
|
13
|
+
* nothing comes from it. So this is a standalone component that creates all
|
|
14
|
+
* of its content itself.
|
|
15
|
+
*
|
|
16
|
+
* It is not decoration in an app that fetches content from the server as it
|
|
17
|
+
* goes. A page that loses its stream looks perfectly normal but is frozen,
|
|
18
|
+
* and a user filling in a form over a dead connection loses everything.
|
|
19
|
+
*
|
|
20
|
+
* `navigator.onLine` only says whether the machine has a network, not whether
|
|
21
|
+
* the server answers. That is why `reportFailure()` and `reportSuccess()`
|
|
22
|
+
* exist: the app calls them when a request fails or succeeds.
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* const status = document.querySelector("lt-connection-status")
|
|
26
|
+
* try {
|
|
27
|
+
* const response = await fetch("/api/save", { method: "POST", body })
|
|
28
|
+
* if (!response.ok) throw new Error(response.statusText)
|
|
29
|
+
* status.reportSuccess()
|
|
30
|
+
* } catch {
|
|
31
|
+
* status.reportFailure()
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export class LtConnectionStatus extends HostElement {
|
|
36
|
+
constructor() {
|
|
37
|
+
super(...arguments);
|
|
38
|
+
/** True when the app has reported a failed request, regardless of navigator. */
|
|
39
|
+
this.failing = false;
|
|
40
|
+
this.handleOffline = () => {
|
|
41
|
+
this.showOffline();
|
|
42
|
+
};
|
|
43
|
+
this.handleOnline = () => {
|
|
44
|
+
if (this.failing)
|
|
45
|
+
return;
|
|
46
|
+
this.showOnline();
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
get offlineText() {
|
|
50
|
+
return this.getAttribute("offline-text") ?? DEFAULT_OFFLINE;
|
|
51
|
+
}
|
|
52
|
+
set offlineText(value) {
|
|
53
|
+
this.setAttribute("offline-text", value);
|
|
54
|
+
}
|
|
55
|
+
get onlineText() {
|
|
56
|
+
return this.getAttribute("online-text") ?? DEFAULT_ONLINE;
|
|
57
|
+
}
|
|
58
|
+
set onlineText(value) {
|
|
59
|
+
this.setAttribute("online-text", value);
|
|
60
|
+
}
|
|
61
|
+
attributeChangedCallback() {
|
|
62
|
+
// If the text changes while the bar is showing, as when the language
|
|
63
|
+
// changes, the bar says the new one. `textContent` is only written when
|
|
64
|
+
// the text differs.
|
|
65
|
+
const bar = this.bar;
|
|
66
|
+
if (!bar || bar.textContent === "")
|
|
67
|
+
return;
|
|
68
|
+
const text = bar.dataset.state === "offline" ? this.offlineText : this.onlineText;
|
|
69
|
+
if (bar.textContent !== text)
|
|
70
|
+
bar.textContent = text;
|
|
71
|
+
}
|
|
72
|
+
connectedCallback() {
|
|
73
|
+
this.classList.add(CONNECTION_STATUS_CLASS);
|
|
74
|
+
/*
|
|
75
|
+
* The host is the live region, from the moment it is connected, so the
|
|
76
|
+
* region exists long before the bar and its text arrive. Only what is
|
|
77
|
+
* missing: a role or politeness the server wrote stays. When the bar was
|
|
78
|
+
* the region, it was inserted together with its text, and Firefox sent
|
|
79
|
+
* no live-region text through AT-SPI at all, so "No connection" was
|
|
80
|
+
* never announced. `check-accessibility-tree.ts` checks it.
|
|
81
|
+
*/
|
|
82
|
+
this.markRegion();
|
|
83
|
+
// A morph without `data-ignore-morph` takes both off, and then the next
|
|
84
|
+
// outage is never announced. Writing only what is missing keeps the
|
|
85
|
+
// observer from triggering itself.
|
|
86
|
+
this.regionObserver = new MutationObserver(() => this.markRegion());
|
|
87
|
+
this.regionObserver.observe(this, {
|
|
88
|
+
attributes: true,
|
|
89
|
+
attributeFilter: ["role", "aria-live"],
|
|
90
|
+
});
|
|
91
|
+
window.addEventListener("offline", this.handleOffline);
|
|
92
|
+
window.addEventListener("online", this.handleOnline);
|
|
93
|
+
if (!navigator.onLine) {
|
|
94
|
+
this.showOffline();
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
/*
|
|
98
|
+
* The element may have been out of the document, and then both the
|
|
99
|
+
* events and the timer are lost. If the receipt was showing, it stayed
|
|
100
|
+
* for good, and if the bar said "offline" while the network came back,
|
|
101
|
+
* it kept saying so until the next time the network dropped. `failing`
|
|
102
|
+
* is the app's word and not the network's, so it stays.
|
|
103
|
+
*/
|
|
104
|
+
if (this.bar?.dataset.state === "online")
|
|
105
|
+
this.scheduleRemoval(this.bar);
|
|
106
|
+
else if (this.bar?.dataset.state === "offline" && !this.failing) {
|
|
107
|
+
this.showOnline();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* The region, as a pair and only when both are missing. A role the server
|
|
112
|
+
* wrote carries its own politeness (`alert` is assertive), and an
|
|
113
|
+
* `aria-live` added next to it would override that.
|
|
114
|
+
*/
|
|
115
|
+
markRegion() {
|
|
116
|
+
if (this.hasAttribute("role") || this.hasAttribute("aria-live"))
|
|
117
|
+
return;
|
|
118
|
+
this.setAttribute("role", "status");
|
|
119
|
+
this.setAttribute("aria-live", "polite");
|
|
120
|
+
}
|
|
121
|
+
disconnectedCallback() {
|
|
122
|
+
this.regionObserver?.disconnect();
|
|
123
|
+
this.regionObserver = undefined;
|
|
124
|
+
window.removeEventListener("offline", this.handleOffline);
|
|
125
|
+
window.removeEventListener("online", this.handleOnline);
|
|
126
|
+
if (this.timer)
|
|
127
|
+
window.clearTimeout(this.timer);
|
|
128
|
+
this.timer = undefined;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* The bar, created empty first and filled afterwards.
|
|
132
|
+
*
|
|
133
|
+
* A live region must exist before its content arrives, or assistive
|
|
134
|
+
* technology does not announce the first change. The region is the host
|
|
135
|
+
* (see `connectedCallback`), so the bar is content inside a region that is
|
|
136
|
+
* already there; the text is still set in the next frame when the bar is
|
|
137
|
+
* new, so the bar and its text arrive as two changes.
|
|
138
|
+
*
|
|
139
|
+
* The bar is created only when it is needed, not on connection: when it
|
|
140
|
+
* was in the DOM before React hydrated, React found an element it had not
|
|
141
|
+
* rendered.
|
|
142
|
+
*/
|
|
143
|
+
ensureBar() {
|
|
144
|
+
if (this.bar)
|
|
145
|
+
return { bar: this.bar, fresh: false };
|
|
146
|
+
const bar = document.createElement("div");
|
|
147
|
+
bar.className = CONNECTION_STATUS_BAR_CLASS;
|
|
148
|
+
this.append(bar);
|
|
149
|
+
this.bar = bar;
|
|
150
|
+
return { bar, fresh: true };
|
|
151
|
+
}
|
|
152
|
+
write(bar, fresh, state) {
|
|
153
|
+
// The text is read when it is written, not when it is scheduled. If
|
|
154
|
+
// `offline-text` changed in the frame between, the bar wrote the old one.
|
|
155
|
+
const text = () => state === "offline" ? this.offlineText : this.onlineText;
|
|
156
|
+
if (!fresh || typeof requestAnimationFrame === "undefined") {
|
|
157
|
+
bar.textContent = text();
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
requestAnimationFrame(() => {
|
|
161
|
+
// The guard is the state, not the bar: if `reportSuccess()` came in
|
|
162
|
+
// the same frame, the bar already says "online", and the offline text
|
|
163
|
+
// must not be written over the receipt.
|
|
164
|
+
if (this.bar === bar && bar.dataset.state === state) {
|
|
165
|
+
bar.textContent = text();
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
showOffline() {
|
|
170
|
+
// Browsers often fire several `offline` events in a row, and the app
|
|
171
|
+
// can report a failure on top of a network that is already gone. If the
|
|
172
|
+
// bar already says "offline", there is nothing new to write or report:
|
|
173
|
+
// each write was announced again, and each report gave the app a new
|
|
174
|
+
// `connection-lost`.
|
|
175
|
+
if (this.bar?.dataset.state === "offline")
|
|
176
|
+
return;
|
|
177
|
+
if (this.timer)
|
|
178
|
+
window.clearTimeout(this.timer);
|
|
179
|
+
const { bar, fresh } = this.ensureBar();
|
|
180
|
+
bar.dataset.state = "offline";
|
|
181
|
+
this.write(bar, fresh, "offline");
|
|
182
|
+
this.emit("connection-lost");
|
|
183
|
+
}
|
|
184
|
+
showOnline() {
|
|
185
|
+
if (!this.bar || this.bar.dataset.state === "online")
|
|
186
|
+
return;
|
|
187
|
+
const bar = this.bar;
|
|
188
|
+
bar.dataset.state = "online";
|
|
189
|
+
this.write(bar, false, "online");
|
|
190
|
+
this.emit("connection-restored");
|
|
191
|
+
this.scheduleRemoval(bar);
|
|
192
|
+
}
|
|
193
|
+
scheduleRemoval(bar) {
|
|
194
|
+
if (this.timer)
|
|
195
|
+
window.clearTimeout(this.timer);
|
|
196
|
+
this.timer = window.setTimeout(() => {
|
|
197
|
+
bar.remove();
|
|
198
|
+
this.bar = undefined;
|
|
199
|
+
this.timer = undefined;
|
|
200
|
+
}, RECEIPT_MS);
|
|
201
|
+
}
|
|
202
|
+
emit(name) {
|
|
203
|
+
this.dispatchEvent(new CustomEvent(name, { bubbles: true, composed: true }));
|
|
204
|
+
}
|
|
205
|
+
/** Reports that a request to the server failed. */
|
|
206
|
+
reportFailure() {
|
|
207
|
+
if (this.failing)
|
|
208
|
+
return;
|
|
209
|
+
this.failing = true;
|
|
210
|
+
this.showOffline();
|
|
211
|
+
}
|
|
212
|
+
/** Reports that a request to the server succeeded again. */
|
|
213
|
+
reportSuccess() {
|
|
214
|
+
if (!this.failing)
|
|
215
|
+
return;
|
|
216
|
+
this.failing = false;
|
|
217
|
+
this.showOnline();
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
LtConnectionStatus.observedAttributes = ["offline-text", "online-text"];
|
|
221
|
+
export function defineLtConnectionStatus(tagName = LT_CONNECTION_STATUS_TAG) {
|
|
222
|
+
defineElement(tagName, LtConnectionStatus);
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* `element.reportFailure()`, but waits for the registration first.
|
|
226
|
+
*
|
|
227
|
+
* This is where the gap showed up in production: the first message from the
|
|
228
|
+
* event stream came before `defineLtConnectionStatus()`, and the app got
|
|
229
|
+
* "reportSuccess is not a function". See `whenUpgraded`.
|
|
230
|
+
*/
|
|
231
|
+
export async function reportFailure(element) {
|
|
232
|
+
const status = await whenUpgraded(element);
|
|
233
|
+
status.reportFailure();
|
|
234
|
+
}
|
|
235
|
+
/** `element.reportSuccess()`, but waits for the registration first. */
|
|
236
|
+
export async function reportSuccess(element) {
|
|
237
|
+
const status = await whenUpgraded(element);
|
|
238
|
+
status.reportSuccess();
|
|
239
|
+
}
|
|
240
|
+
//# sourceMappingURL=lt-connection-status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lt-connection-status.js","sourceRoot":"","sources":["../../../../src/components/standalone/connection-status/lt-connection-status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAChF,OAAO,EACL,2BAA2B,EAC3B,uBAAuB,GACxB,MAAM,wBAAwB,CAAA;AAE/B,MAAM,CAAC,MAAM,wBAAwB,GAAG,sBAA+B,CAAA;AAEvE,OAAO,EAAE,aAAa,EAAE,MAAM,w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M,CAAC,aAAa,EAAE,CAAA;AACxB,CAAC;AAED,uEAAuE;AACvE,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAAgB;IAClD,MAAM,MAAM,GAAG,MAAM,YAAY,CAAqB,OAAO,CAAC,CAAA;IAC9D,MAAM,CAAC,aAAa,EAAE,CAAA;AACxB,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { HostElement } from "../../host-element.js";
|
|
2
|
+
export declare const LT_TOAST_TAG: "lt-toast";
|
|
3
|
+
export declare const toastColors: readonly ["neutral", "success", "warning", "danger"];
|
|
4
|
+
export type ToastColor = (typeof toastColors)[number];
|
|
5
|
+
export declare function isToastColor(value: unknown): value is ToastColor;
|
|
6
|
+
export type ShowOptions = {
|
|
7
|
+
/** What the message means. Default: `neutral`. */
|
|
8
|
+
color?: ToastColor;
|
|
9
|
+
/** Milliseconds before the message disappears. `0` keeps it. */
|
|
10
|
+
duration?: number;
|
|
11
|
+
/**
|
|
12
|
+
* The screen reader name of the close button. Default: `close-label` on
|
|
13
|
+
* the host, and otherwise "Close message".
|
|
14
|
+
*/
|
|
15
|
+
closeLabel?: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The queue of short messages in the corner of the screen.
|
|
19
|
+
*
|
|
20
|
+
* This is one of the standalone components, and part of the package you call
|
|
21
|
+
* instead of writing markup. The element is the container, not the message:
|
|
22
|
+
* you put it in the app once and call `show()` when there is something to
|
|
23
|
+
* report. The messages do not exist until an event on the client creates
|
|
24
|
+
* them, so there is nothing for the server to render.
|
|
25
|
+
*
|
|
26
|
+
* The server writes the container with `lt.toast()`, which sets
|
|
27
|
+
* `data-ignore-morph`. Without it the Datastar morph tears the messages away
|
|
28
|
+
* at the next patch, because the server's version of the region is empty.
|
|
29
|
+
*
|
|
30
|
+
* The container is a `role="status"` region, not `role="alert"`. A message
|
|
31
|
+
* that appears in the corner should not interrupt what the screen reader is
|
|
32
|
+
* doing; if the message is important enough to interrupt, it belongs in an
|
|
33
|
+
* [Alert](../../css/alert/alert.js) in the page itself. The region has
|
|
34
|
+
* `aria-atomic="false"`: `status` is atomic by default, and then the whole
|
|
35
|
+
* stack was announced again for every new message.
|
|
36
|
+
*
|
|
37
|
+
* Messages that disappear by themselves are an accessibility trap: someone
|
|
38
|
+
* who reads slowly or uses magnification does not have time to read them. So
|
|
39
|
+
* the close button is always there, and the timer stops while the mouse or
|
|
40
|
+
* focus is in the message.
|
|
41
|
+
*
|
|
42
|
+
* ```ts
|
|
43
|
+
* document.querySelector("lt-toast").show("Application sent", {
|
|
44
|
+
* color: "success",
|
|
45
|
+
* })
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare class LtToast extends HostElement {
|
|
49
|
+
static observedAttributes: readonly ["duration", "label", "close-label"];
|
|
50
|
+
/**
|
|
51
|
+
* The screen reader name of the close button in each message shown.
|
|
52
|
+
* `closeLabel` in `show()` overrides it for one message.
|
|
53
|
+
*/
|
|
54
|
+
get closeLabel(): string;
|
|
55
|
+
set closeLabel(value: string);
|
|
56
|
+
/** Default lifetime in milliseconds. `0` keeps the messages. */
|
|
57
|
+
get duration(): number;
|
|
58
|
+
set duration(value: number);
|
|
59
|
+
/**
|
|
60
|
+
* Whether the component wrote `aria-label`. Before, `label` overwrote an
|
|
61
|
+
* `aria-label` the author had set, and when `label` was removed, the old
|
|
62
|
+
* one stayed.
|
|
63
|
+
*/
|
|
64
|
+
private ownsLabel;
|
|
65
|
+
/**
|
|
66
|
+
* The element focus came from before it entered a message. If the last
|
|
67
|
+
* message is removed while it has focus, focus goes back there. Before, it
|
|
68
|
+
* fell to `body`, and the next Tab started at the top of the page. If
|
|
69
|
+
* focus came from a screen reader or F6, the origin is not known, and focus
|
|
70
|
+
* still falls.
|
|
71
|
+
*/
|
|
72
|
+
private focusOrigin;
|
|
73
|
+
private rememberOrigin;
|
|
74
|
+
/**
|
|
75
|
+
* Focus left the region for somewhere else. Then the origin is stale:
|
|
76
|
+
* without this, focus later came back to an element the user left long
|
|
77
|
+
* ago, and the page scrolled there. Not when `relatedTarget` is `null`,
|
|
78
|
+
* because that is also what happens when the message with focus is
|
|
79
|
+
* removed.
|
|
80
|
+
*/
|
|
81
|
+
private forgetOrigin;
|
|
82
|
+
/**
|
|
83
|
+
* Whether focus is in the element. Read from the component's root node,
|
|
84
|
+
* not from `document`: when the region is in a shadow root, as in every
|
|
85
|
+
* preview in the documentation, `document.activeElement` points to the
|
|
86
|
+
* shadow host. Then it looked as if no message had focus, and focus fell
|
|
87
|
+
* to `body` instead of to the neighbouring message or where it came from.
|
|
88
|
+
*/
|
|
89
|
+
private holdsFocus;
|
|
90
|
+
private restoreFocus;
|
|
91
|
+
disconnectedCallback(): void;
|
|
92
|
+
connectedCallback(): void;
|
|
93
|
+
attributeChangedCallback(name: string, _old: string, value: string): void;
|
|
94
|
+
/** Shows a message, and returns the element it was put in. */
|
|
95
|
+
show(message: string, options?: ShowOptions): HTMLElement;
|
|
96
|
+
/** Removes a message. */
|
|
97
|
+
dismiss(toast: HTMLElement): void;
|
|
98
|
+
/** Removes all the messages. */
|
|
99
|
+
clear(): void;
|
|
100
|
+
}
|
|
101
|
+
export declare function defineLtToast(tagName?: string): void;
|
|
102
|
+
/**
|
|
103
|
+
* `element.show()`, but waits for `defineLtToast()` to have run first.
|
|
104
|
+
*
|
|
105
|
+
* See `whenUpgraded` for why: a call before the registration hit a plain
|
|
106
|
+
* `HTMLElement` without `show`.
|
|
107
|
+
*/
|
|
108
|
+
export declare function showToast(element: Element, message: string, options?: ShowOptions): Promise<HTMLElement>;
|
|
109
|
+
//# sourceMappingURL=lt-toast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lt-toast.d.ts","sourceRoot":"","sources":["../../../../src/components/standalone/toast/lt-toast.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,WAAW,EAAgB,MAAM,uBAAuB,CAAA;AAGhF,eAAO,MAAM,YAAY,EAAG,UAAmB,CAAA;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,WAAW,GAAG,IAAI;IAyBjC,gCAAgC;IAChC,KAAK,IAAI,IAAI;CAMd;AAED,wBAAgB,aAAa,CAAC,OAAO,GAAE,MAAqB,GAAG,IAAI,CAElE;AAED;;;;;GAKG;AACH,wBAAsB,SAAS,CAC7B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,WAAgB,GACxB,OAAO,CAAC,WAAW,CAAC,CAGtB"}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { DEFAULT_TEXTS } from "../../default-texts.js";
|
|
2
|
+
import { defineElement, HostElement, whenUpgraded } from "../../host-element.js";
|
|
3
|
+
import { TOAST_CLASS, TOAST_CLOSE_CLASS, TOAST_MESSAGE_CLASS } from "./toast.js";
|
|
4
|
+
export const LT_TOAST_TAG = "lt-toast";
|
|
5
|
+
export const toastColors = ["neutral", "success", "warning", "danger"];
|
|
6
|
+
export function isToastColor(value) {
|
|
7
|
+
return toastColors.includes(value);
|
|
8
|
+
}
|
|
9
|
+
const DEFAULT_DURATION = 6000;
|
|
10
|
+
const DEFAULT_LABEL = DEFAULT_TEXTS.toastRegion;
|
|
11
|
+
const DEFAULT_CLOSE_LABEL = DEFAULT_TEXTS.toastClose;
|
|
12
|
+
/**
|
|
13
|
+
* The queue of short messages in the corner of the screen.
|
|
14
|
+
*
|
|
15
|
+
* This is one of the standalone components, and part of the package you call
|
|
16
|
+
* instead of writing markup. The element is the container, not the message:
|
|
17
|
+
* you put it in the app once and call `show()` when there is something to
|
|
18
|
+
* report. The messages do not exist until an event on the client creates
|
|
19
|
+
* them, so there is nothing for the server to render.
|
|
20
|
+
*
|
|
21
|
+
* The server writes the container with `lt.toast()`, which sets
|
|
22
|
+
* `data-ignore-morph`. Without it the Datastar morph tears the messages away
|
|
23
|
+
* at the next patch, because the server's version of the region is empty.
|
|
24
|
+
*
|
|
25
|
+
* The container is a `role="status"` region, not `role="alert"`. A message
|
|
26
|
+
* that appears in the corner should not interrupt what the screen reader is
|
|
27
|
+
* doing; if the message is important enough to interrupt, it belongs in an
|
|
28
|
+
* [Alert](../../css/alert/alert.js) in the page itself. The region has
|
|
29
|
+
* `aria-atomic="false"`: `status` is atomic by default, and then the whole
|
|
30
|
+
* stack was announced again for every new message.
|
|
31
|
+
*
|
|
32
|
+
* Messages that disappear by themselves are an accessibility trap: someone
|
|
33
|
+
* who reads slowly or uses magnification does not have time to read them. So
|
|
34
|
+
* the close button is always there, and the timer stops while the mouse or
|
|
35
|
+
* focus is in the message.
|
|
36
|
+
*
|
|
37
|
+
* ```ts
|
|
38
|
+
* document.querySelector("lt-toast").show("Application sent", {
|
|
39
|
+
* color: "success",
|
|
40
|
+
* })
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export class LtToast extends HostElement {
|
|
44
|
+
constructor() {
|
|
45
|
+
super(...arguments);
|
|
46
|
+
/**
|
|
47
|
+
* Whether the component wrote `aria-label`. Before, `label` overwrote an
|
|
48
|
+
* `aria-label` the author had set, and when `label` was removed, the old
|
|
49
|
+
* one stayed.
|
|
50
|
+
*/
|
|
51
|
+
this.ownsLabel = false;
|
|
52
|
+
/**
|
|
53
|
+
* The element focus came from before it entered a message. If the last
|
|
54
|
+
* message is removed while it has focus, focus goes back there. Before, it
|
|
55
|
+
* fell to `body`, and the next Tab started at the top of the page. If
|
|
56
|
+
* focus came from a screen reader or F6, the origin is not known, and focus
|
|
57
|
+
* still falls.
|
|
58
|
+
*/
|
|
59
|
+
this.focusOrigin = null;
|
|
60
|
+
this.rememberOrigin = (event) => {
|
|
61
|
+
const from = event.relatedTarget;
|
|
62
|
+
if (from instanceof HTMLElement && !this.contains(from)) {
|
|
63
|
+
this.focusOrigin = from;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Focus left the region for somewhere else. Then the origin is stale:
|
|
68
|
+
* without this, focus later came back to an element the user left long
|
|
69
|
+
* ago, and the page scrolled there. Not when `relatedTarget` is `null`,
|
|
70
|
+
* because that is also what happens when the message with focus is
|
|
71
|
+
* removed.
|
|
72
|
+
*/
|
|
73
|
+
this.forgetOrigin = (event) => {
|
|
74
|
+
const to = event.relatedTarget;
|
|
75
|
+
if (to instanceof Node && !this.contains(to))
|
|
76
|
+
this.focusOrigin = null;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The screen reader name of the close button in each message shown.
|
|
81
|
+
* `closeLabel` in `show()` overrides it for one message.
|
|
82
|
+
*/
|
|
83
|
+
get closeLabel() {
|
|
84
|
+
return this.getAttribute("close-label") || DEFAULT_CLOSE_LABEL;
|
|
85
|
+
}
|
|
86
|
+
set closeLabel(value) {
|
|
87
|
+
this.setAttribute("close-label", value);
|
|
88
|
+
}
|
|
89
|
+
/** Default lifetime in milliseconds. `0` keeps the messages. */
|
|
90
|
+
get duration() {
|
|
91
|
+
// `0` is a valid value and means the messages stay. Without the check
|
|
92
|
+
// against null here they still disappeared after six seconds, and only
|
|
93
|
+
// `show(..., { duration: 0 })` worked. An empty attribute is not null:
|
|
94
|
+
// `Number("")` is 0, and `<lt-toast duration>` kept the messages.
|
|
95
|
+
const raw = this.getAttribute("duration");
|
|
96
|
+
if (raw === null || raw.trim() === "")
|
|
97
|
+
return DEFAULT_DURATION;
|
|
98
|
+
const value = Number(raw);
|
|
99
|
+
return Number.isFinite(value) && value >= 0 ? value : DEFAULT_DURATION;
|
|
100
|
+
}
|
|
101
|
+
set duration(value) {
|
|
102
|
+
this.setAttribute("duration", String(value));
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Whether focus is in the element. Read from the component's root node,
|
|
106
|
+
* not from `document`: when the region is in a shadow root, as in every
|
|
107
|
+
* preview in the documentation, `document.activeElement` points to the
|
|
108
|
+
* shadow host. Then it looked as if no message had focus, and focus fell
|
|
109
|
+
* to `body` instead of to the neighbouring message or where it came from.
|
|
110
|
+
*/
|
|
111
|
+
holdsFocus(element) {
|
|
112
|
+
const root = this.getRootNode();
|
|
113
|
+
return element.contains(root.activeElement);
|
|
114
|
+
}
|
|
115
|
+
restoreFocus() {
|
|
116
|
+
const origin = this.focusOrigin;
|
|
117
|
+
this.focusOrigin = null;
|
|
118
|
+
// A restore, not a navigation: the page must not scroll.
|
|
119
|
+
if (origin?.isConnected)
|
|
120
|
+
origin.focus({ preventScroll: true });
|
|
121
|
+
}
|
|
122
|
+
disconnectedCallback() {
|
|
123
|
+
this.removeEventListener("focusin", this.rememberOrigin);
|
|
124
|
+
this.removeEventListener("focusout", this.forgetOrigin);
|
|
125
|
+
this.focusOrigin = null;
|
|
126
|
+
}
|
|
127
|
+
connectedCallback() {
|
|
128
|
+
this.addEventListener("focusin", this.rememberOrigin);
|
|
129
|
+
this.addEventListener("focusout", this.forgetOrigin);
|
|
130
|
+
// If the server wrote the region with lt.toast(), all of this is
|
|
131
|
+
// already there. Here it is only set when missing, so a plain HTML page
|
|
132
|
+
// without a builder function also gets a region the screen reader
|
|
133
|
+
// understands.
|
|
134
|
+
// The class carries the position. It is set here too, so a region
|
|
135
|
+
// without a builder function, or registered under another name, ends up
|
|
136
|
+
// in the corner.
|
|
137
|
+
this.classList.add(TOAST_CLASS);
|
|
138
|
+
if (!this.hasAttribute("role"))
|
|
139
|
+
this.setAttribute("role", "status");
|
|
140
|
+
if (!this.hasAttribute("aria-live")) {
|
|
141
|
+
this.setAttribute("aria-live", "polite");
|
|
142
|
+
}
|
|
143
|
+
if (!this.hasAttribute("aria-atomic")) {
|
|
144
|
+
this.setAttribute("aria-atomic", "false");
|
|
145
|
+
}
|
|
146
|
+
if (!this.hasAttribute("aria-label")) {
|
|
147
|
+
this.ownsLabel = true;
|
|
148
|
+
this.setAttribute("aria-label", this.getAttribute("label") ?? DEFAULT_LABEL);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
attributeChangedCallback(name, _old, value) {
|
|
152
|
+
// `label` can be set after the element is in the DOM, for example by a
|
|
153
|
+
// framework that fills in the attributes in a later step.
|
|
154
|
+
if (name !== "label" || !this.ownsLabel)
|
|
155
|
+
return;
|
|
156
|
+
this.setAttribute("aria-label", value || DEFAULT_LABEL);
|
|
157
|
+
}
|
|
158
|
+
/** Shows a message, and returns the element it was put in. */
|
|
159
|
+
show(message, options = {}) {
|
|
160
|
+
const { color = "neutral", duration = this.duration, closeLabel = this.closeLabel, } = options;
|
|
161
|
+
const toast = document.createElement("div");
|
|
162
|
+
toast.className = TOAST_MESSAGE_CLASS;
|
|
163
|
+
// An unknown colour gives no border, instead of a `data-color` without a rule.
|
|
164
|
+
if (isToastColor(color) && color !== "neutral")
|
|
165
|
+
toast.dataset.color = color;
|
|
166
|
+
const text = document.createElement("span");
|
|
167
|
+
text.textContent = message;
|
|
168
|
+
toast.append(text);
|
|
169
|
+
const close = document.createElement("button");
|
|
170
|
+
close.type = "button";
|
|
171
|
+
close.className = TOAST_CLOSE_CLASS;
|
|
172
|
+
close.setAttribute("aria-label", closeLabel);
|
|
173
|
+
close.textContent = "×";
|
|
174
|
+
close.addEventListener("click", () => this.dismiss(toast));
|
|
175
|
+
toast.append(close);
|
|
176
|
+
this.prepend(toast);
|
|
177
|
+
if (duration > 0) {
|
|
178
|
+
let timer = window.setTimeout(() => this.dismiss(toast), duration);
|
|
179
|
+
/*
|
|
180
|
+
* The timer stops while the user reads or is on the way to the close
|
|
181
|
+
* button, and only runs when neither the mouse nor focus is in the
|
|
182
|
+
* message. The pause used to be two independent pairs, and the mouse
|
|
183
|
+
* leaving restarted the clock while focus was in the message: it
|
|
184
|
+
* disappeared from under the user's fingers.
|
|
185
|
+
*/
|
|
186
|
+
const holds = new Set();
|
|
187
|
+
const pause = (reason) => {
|
|
188
|
+
holds.add(reason);
|
|
189
|
+
window.clearTimeout(timer);
|
|
190
|
+
};
|
|
191
|
+
const resume = (reason) => {
|
|
192
|
+
holds.delete(reason);
|
|
193
|
+
if (holds.size > 0)
|
|
194
|
+
return;
|
|
195
|
+
window.clearTimeout(timer);
|
|
196
|
+
timer = window.setTimeout(() => this.dismiss(toast), duration);
|
|
197
|
+
};
|
|
198
|
+
toast.addEventListener("mouseenter", () => pause("pointer"));
|
|
199
|
+
toast.addEventListener("mouseleave", () => resume("pointer"));
|
|
200
|
+
toast.addEventListener("focusin", () => pause("focus"));
|
|
201
|
+
toast.addEventListener("focusout", (event) => {
|
|
202
|
+
// Within the message, from the text to the button: still paused.
|
|
203
|
+
const next = event.relatedTarget;
|
|
204
|
+
if (next instanceof Node && toast.contains(next))
|
|
205
|
+
return;
|
|
206
|
+
resume("focus");
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
return toast;
|
|
210
|
+
}
|
|
211
|
+
/** Removes a message. */
|
|
212
|
+
dismiss(toast) {
|
|
213
|
+
if (!this.contains(toast))
|
|
214
|
+
return;
|
|
215
|
+
/*
|
|
216
|
+
* If focus was in the message, as on the close button after Enter, it
|
|
217
|
+
* would otherwise fall to `body`, and the next Tab starts at the top of
|
|
218
|
+
* the page. The neighbouring message is the nearest place to continue
|
|
219
|
+
* from: the one below, otherwise the one above.
|
|
220
|
+
*/
|
|
221
|
+
const hadFocus = this.holdsFocus(toast);
|
|
222
|
+
const neighbour = toast.nextElementSibling ?? toast.previousElementSibling;
|
|
223
|
+
toast.remove();
|
|
224
|
+
if (hadFocus) {
|
|
225
|
+
const next = neighbour?.querySelector(`.${TOAST_CLOSE_CLASS}`);
|
|
226
|
+
if (next)
|
|
227
|
+
next.focus();
|
|
228
|
+
else
|
|
229
|
+
this.restoreFocus();
|
|
230
|
+
}
|
|
231
|
+
this.dispatchEvent(new CustomEvent("toast-dismiss", { bubbles: true, composed: true }));
|
|
232
|
+
}
|
|
233
|
+
/** Removes all the messages. */
|
|
234
|
+
clear() {
|
|
235
|
+
if (this.holdsFocus(this))
|
|
236
|
+
this.restoreFocus();
|
|
237
|
+
for (const toast of this.querySelectorAll(`.${TOAST_MESSAGE_CLASS}`)) {
|
|
238
|
+
toast.remove();
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
LtToast.observedAttributes = ["duration", "label", "close-label"];
|
|
243
|
+
export function defineLtToast(tagName = LT_TOAST_TAG) {
|
|
244
|
+
defineElement(tagName, LtToast);
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* `element.show()`, but waits for `defineLtToast()` to have run first.
|
|
248
|
+
*
|
|
249
|
+
* See `whenUpgraded` for why: a call before the registration hit a plain
|
|
250
|
+
* `HTMLElement` without `show`.
|
|
251
|
+
*/
|
|
252
|
+
export async function showToast(element, message, options = {}) {
|
|
253
|
+
const toast = await whenUpgraded(element);
|
|
254
|
+
return toast.show(message, options);
|
|
255
|
+
}
|
|
256
|
+
//# sourceMappingURL=lt-toast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lt-toast.js","sourceRoot":"","sources":["../../../../src/components/standalone/toast/lt-toast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAChF,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAEhF,MAAM,CAAC,MAAM,YAAY,GAAG,UAAmB,CAAA;AAE/C,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAU,CAAA;AAG/E,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,OAAQ,WAAkC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;AAC5D,CAAC;AAED,MAAM,gBAAgB,GAAG,IAAI,CAAA;AAC7B,MAAM,aAAa,GAAG,aAAa,CAAC,WAAW,CAAA;AAC/C,MAAM,mBAAmB,GAAG,aAAa,CAAC,UAAU,CAAA;AAcpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,OAAO,OAAQ,SAAQ,WAA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