@lo-tek/interfaces 0.0.0-stage → 0.37.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 +3254 -0
- package/LICENSE +21 -0
- package/README.md +129 -2
- 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 +35 -0
- package/dist/components/default-texts.d.ts.map +1 -0
- package/dist/components/default-texts.js +35 -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 +431 -0
- package/dist/components/frame/dialog/lt-dialog.js.map +1 -0
- package/dist/components/frame/error-summary/error-summary.d.ts +40 -0
- package/dist/components/frame/error-summary/error-summary.d.ts.map +1 -0
- package/dist/components/frame/error-summary/error-summary.js +32 -0
- package/dist/components/frame/error-summary/error-summary.js.map +1 -0
- package/dist/components/frame/error-summary/lt-error-summary.d.ts +82 -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 +302 -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 +580 -0
- package/dist/components/frame/field/lt-field.js.map +1 -0
- package/dist/components/frame/popover/lt-popover.d.ts +132 -0
- package/dist/components/frame/popover/lt-popover.d.ts.map +1 -0
- package/dist/components/frame/popover/lt-popover.js +490 -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 +573 -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 +361 -0
- package/dist/components/frame/suggestion/lt-suggestion.d.ts.map +1 -0
- package/dist/components/frame/suggestion/lt-suggestion.js +1152 -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 +404 -0
- package/dist/components/frame/tabs/lt-tabs.d.ts.map +1 -0
- package/dist/components/frame/tabs/lt-tabs.js +1201 -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 +135 -0
- package/dist/components/host-element.d.ts.map +1 -0
- package/dist/components/host-element.js +366 -0
- package/dist/components/host-element.js.map +1 -0
- package/dist/components/standalone/connection-status/connection-status.d.ts +28 -0
- package/dist/components/standalone/connection-status/connection-status.d.ts.map +1 -0
- package/dist/components/standalone/connection-status/connection-status.js +22 -0
- package/dist/components/standalone/connection-status/connection-status.js.map +1 -0
- package/dist/components/standalone/connection-status/lt-connection-status.d.ts +81 -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 +216 -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 +137 -0
- package/dist/diagnostics/core.d.ts.map +1 -0
- package/dist/diagnostics/core.js +72 -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 +492 -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 +1320 -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 +410 -0
- package/dist/vocabulary/elements.js.map +1 -0
- package/dist/vocabulary/types.d.ts +175 -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 +62 -0
- package/manifest/files.json +373 -0
- package/manifest/manifest.json +4965 -0
- package/manifest/manifest.schema.json +513 -0
- package/package.json +404 -4
- 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 +34 -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 +510 -0
- package/src/components/frame/error-summary/error-summary.css +47 -0
- package/src/components/frame/error-summary/error-summary.ts +56 -0
- package/src/components/frame/error-summary/lt-error-summary.ts +344 -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 +753 -0
- package/src/components/frame/popover/lt-popover.ts +555 -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 +681 -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 +1358 -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 +1319 -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 +400 -0
- package/src/components/standalone/connection-status/connection-status.css +41 -0
- package/src/components/standalone/connection-status/connection-status.ts +41 -0
- package/src/components/standalone/connection-status/lt-connection-status.ts +242 -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 +210 -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 +1322 -0
- package/src/vocabulary/elements.ts +412 -0
- package/src/vocabulary/types.ts +178 -0
- package/src/wasi-host.ts +155 -0
- package/web-types.json +800 -0
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import {
|
|
2
|
+
addClass,
|
|
3
|
+
defineElement,
|
|
4
|
+
HostElement,
|
|
5
|
+
setAttr,
|
|
6
|
+
warnAboutMarkup,
|
|
7
|
+
} from "../../host-element.js"
|
|
8
|
+
import {
|
|
9
|
+
ERROR_SUMMARY_CLASS,
|
|
10
|
+
ERROR_SUMMARY_TITLE_CLASS,
|
|
11
|
+
} from "./error-summary.js"
|
|
12
|
+
export const LT_ERROR_SUMMARY_TAG = "lt-error-summary" as const
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The parts the error summary looks for, as selectors relative to the
|
|
16
|
+
* element. The component finds its parts with these, and the manifest
|
|
17
|
+
* describes them for whoever assembles the markup by hand, so the two cannot
|
|
18
|
+
* say different things.
|
|
19
|
+
*/
|
|
20
|
+
export const LT_ERROR_SUMMARY_PARTS = {
|
|
21
|
+
title: "h1, h2, h3, h4, h5, h6",
|
|
22
|
+
link: "li a[href^='#']",
|
|
23
|
+
} as const
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Takes the user from an error in the summary to the field that failed.
|
|
27
|
+
*
|
|
28
|
+
* The server writes the content: the heading and the list of links. When the
|
|
29
|
+
* markup is written with JavaScript, `lt.errorSummary()` also writes the
|
|
30
|
+
* class, `role="alert"` and `tabindex="-1"` on the box, and the component
|
|
31
|
+
* leaves them alone. When the markup comes from a template without
|
|
32
|
+
* JavaScript, the component fills in those three and the class on the
|
|
33
|
+
* heading, and sets them back when a patch removes them. The component
|
|
34
|
+
* creates no nodes: it used to, and then the heading disappeared on the
|
|
35
|
+
* first morph in Datastar and never came back.
|
|
36
|
+
*
|
|
37
|
+
* What is left are two things the browser does not do by itself:
|
|
38
|
+
*
|
|
39
|
+
* 1. Focus moves to the box when it becomes visible, so someone listening to
|
|
40
|
+
* the page learns that the submission stopped.
|
|
41
|
+
* 2. Focus goes to the control itself when a link is followed. A plain anchor
|
|
42
|
+
* link only gives focus to a target that can take it; if it points to a
|
|
43
|
+
* label or a heading, `document.activeElement` becomes `<body>`, and the
|
|
44
|
+
* screen reader is not told where the user is. Tab continues from the
|
|
45
|
+
* target either way.
|
|
46
|
+
*
|
|
47
|
+
* ```html
|
|
48
|
+
* <lt-error-summary>
|
|
49
|
+
* <h2>The form has two errors</h2>
|
|
50
|
+
* <ul class="lt-list">
|
|
51
|
+
* <li><a href="#email">Enter a valid email address</a></li>
|
|
52
|
+
* </ul>
|
|
53
|
+
* </lt-error-summary>
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
/** Decodes a fragment, and returns it untouched if it is not valid. */
|
|
57
|
+
function decodeFragment(fragment: string): string {
|
|
58
|
+
try {
|
|
59
|
+
return decodeURIComponent(fragment)
|
|
60
|
+
} catch {
|
|
61
|
+
return fragment
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export class LtErrorSummary extends HostElement {
|
|
66
|
+
static observedAttributes = ["data-autofocus", "hidden"] as const
|
|
67
|
+
|
|
68
|
+
private hasFocused = false
|
|
69
|
+
/**
|
|
70
|
+
* Whether the component has tried to move focus since the box last became
|
|
71
|
+
* visible.
|
|
72
|
+
*
|
|
73
|
+
* The first attempt happens wherever focus is: a new submission has
|
|
74
|
+
* failed, and that is the message. If it did not land, because the box was
|
|
75
|
+
* in a hidden panel, the component tries again on the next change to the
|
|
76
|
+
* list, but only when nobody is in a field. Without that distinction the
|
|
77
|
+
* retry pulled focus out of the field the user was correcting, as soon as
|
|
78
|
+
* live validation patched the list.
|
|
79
|
+
*/
|
|
80
|
+
private focusAttempted = false
|
|
81
|
+
private observer?: MutationObserver
|
|
82
|
+
|
|
83
|
+
connectedCallback(): void {
|
|
84
|
+
// One listener on the host, not one per link. The set of links was only
|
|
85
|
+
// emptied on disconnect, so every link a patch replaced stayed in
|
|
86
|
+
// memory.
|
|
87
|
+
this.addEventListener("click", this.handleLinkClick)
|
|
88
|
+
// The errors come and go while the user corrects them, and `slotchange`
|
|
89
|
+
// does not fire in plain DOM. The attributes are the ones the component
|
|
90
|
+
// fills in itself, so a patch that removes them gets them back. Every
|
|
91
|
+
// write compares first, or the observer would trigger itself.
|
|
92
|
+
this.observer = new MutationObserver(() => this.sync())
|
|
93
|
+
this.observer.observe(this, {
|
|
94
|
+
childList: true,
|
|
95
|
+
subtree: true,
|
|
96
|
+
attributes: true,
|
|
97
|
+
attributeFilter: ["class", "role", "tabindex"],
|
|
98
|
+
})
|
|
99
|
+
this.sync()
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
attributeChangedCallback(): void {
|
|
103
|
+
// The server can send the box hidden and later only remove `hidden` on
|
|
104
|
+
// the same node. Without this, a summary that just became visible never
|
|
105
|
+
// gets focus, and that is the whole reason the component exists.
|
|
106
|
+
if (this.isConnected) this.sync()
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
disconnectedCallback(): void {
|
|
110
|
+
this.observer?.disconnect()
|
|
111
|
+
this.observer = undefined
|
|
112
|
+
this.removeEventListener("click", this.handleLinkClick)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Whether the box takes focus when it becomes visible. Default: yes.
|
|
117
|
+
*
|
|
118
|
+
* The attribute is called `data-autofocus` and not `autofocus`, even
|
|
119
|
+
* though the latter reads better. `autofocus` is a boolean property on
|
|
120
|
+
* `HTMLElement`, and React 19 sets properties rather than attributes on web
|
|
121
|
+
* components. `autofocus="false"` then became `el.autofocus = "false"`,
|
|
122
|
+
* which is true, while the attribute never reached the markup, and the
|
|
123
|
+
* opt-out did not work. `data-*` is passed on as an attribute in every
|
|
124
|
+
* React version.
|
|
125
|
+
*/
|
|
126
|
+
private get shouldFocus(): boolean {
|
|
127
|
+
return this.dataset.autofocus !== "false"
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Fills in what a template without JavaScript did not write. Only what is
|
|
132
|
+
* missing: a role the server chose stays, and so does a `tabindex`.
|
|
133
|
+
*/
|
|
134
|
+
private wire(): void {
|
|
135
|
+
addClass(this, ERROR_SUMMARY_CLASS)
|
|
136
|
+
if (!this.hasAttribute("role")) setAttr(this, "role", "alert")
|
|
137
|
+
// Without `tabindex`, `focus()` does nothing, and the whole reason for
|
|
138
|
+
// the component silently disappears.
|
|
139
|
+
if (!this.hasAttribute("tabindex")) setAttr(this, "tabindex", "-1")
|
|
140
|
+
|
|
141
|
+
const title = this.querySelector(LT_ERROR_SUMMARY_PARTS.title)
|
|
142
|
+
if (title) addClass(title, ERROR_SUMMARY_TITLE_CLASS)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
private sync(): void {
|
|
146
|
+
this.wire()
|
|
147
|
+
|
|
148
|
+
const links = [
|
|
149
|
+
...this.querySelectorAll<HTMLAnchorElement>(LT_ERROR_SUMMARY_PARTS.link),
|
|
150
|
+
]
|
|
151
|
+
|
|
152
|
+
// If the server hides the box again, that submission is over. Without
|
|
153
|
+
// this reset the box only took focus the first time: the pattern in a
|
|
154
|
+
// Datastar app is that the list keeps the same links throughout and only
|
|
155
|
+
// `hidden` is toggled, so "have I moved focus here before" does not
|
|
156
|
+
// answer whether this is a new submission. It comes before the return
|
|
157
|
+
// for an empty list: React removes the items before it sets `hidden` on
|
|
158
|
+
// the host, so the list is already empty in the round where the box is
|
|
159
|
+
// hidden.
|
|
160
|
+
if (this.hidden) {
|
|
161
|
+
this.hasFocused = false
|
|
162
|
+
this.focusAttempted = false
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (links.length === 0) {
|
|
166
|
+
// The flags are not reset by an empty list, only by `hidden` above. A
|
|
167
|
+
// visible list that is emptied and filled while the user corrects
|
|
168
|
+
// would otherwise pull focus out of the field they were in.
|
|
169
|
+
warnAboutMarkup(
|
|
170
|
+
this,
|
|
171
|
+
"found no links to the fields. Each item needs an <a " +
|
|
172
|
+
'href="#id"> pointing to the control or its label, or the user ' +
|
|
173
|
+
"cannot get from the error to the field.",
|
|
174
|
+
// An empty box is not an error: the pattern is that the server leaves
|
|
175
|
+
// it with `hidden` and fills it when the submission fails. A box with
|
|
176
|
+
// items but no links to the fields is something else.
|
|
177
|
+
() =>
|
|
178
|
+
this.querySelector("li") !== null &&
|
|
179
|
+
this.querySelector(LT_ERROR_SUMMARY_PARTS.link) === null,
|
|
180
|
+
)
|
|
181
|
+
return
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
for (const link of links) {
|
|
185
|
+
/*
|
|
186
|
+
* A link that leads nowhere, reported here and not only on a click.
|
|
187
|
+
*
|
|
188
|
+
* The check used to be only in the click handler, and then a box with a
|
|
189
|
+
* link to a field that does not exist was completely silent until
|
|
190
|
+
* someone actually followed it. An error summary is read by someone who
|
|
191
|
+
* just failed with a form, and a link that does not work is exactly
|
|
192
|
+
* what makes the box worthless. The id is in the message, and each link
|
|
193
|
+
* has its own, so a box with two broken links reports both.
|
|
194
|
+
*/
|
|
195
|
+
const id = link.getAttribute("href")?.slice(1)
|
|
196
|
+
if (id) {
|
|
197
|
+
warnAboutMarkup(
|
|
198
|
+
this,
|
|
199
|
+
`the link points to #${id}, but no element has that id. The link scrolls nowhere, and focus stays where it is.`,
|
|
200
|
+
() => this.resolveTarget(id) === null,
|
|
201
|
+
)
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (this.hidden) return
|
|
206
|
+
|
|
207
|
+
// If the box is visible now and we have not moved focus here yet, it is
|
|
208
|
+
// this submission that failed. The flag is only set when focus actually
|
|
209
|
+
// landed: if the box is in a hidden panel or a closed dialog, `focus()`
|
|
210
|
+
// does nothing, and the next attempt is then allowed, as long as nobody
|
|
211
|
+
// is in a field.
|
|
212
|
+
if (this.shouldFocus && !this.hasFocused) {
|
|
213
|
+
// `document.activeElement` and not the root's: if the box is in a
|
|
214
|
+
// shadow root and the field in plain DOM, the root's `activeElement` is
|
|
215
|
+
// null, and the user would have counted as "nobody". The document's
|
|
216
|
+
// points to the shadow host when focus is in a shadow tree, and is
|
|
217
|
+
// never null for a field on the page.
|
|
218
|
+
const active = document.activeElement
|
|
219
|
+
const nobodyTyping = !active || active === document.body
|
|
220
|
+
if (this.focusAttempted && !nobodyTyping) return
|
|
221
|
+
const root = this.getRootNode() as Document | ShadowRoot
|
|
222
|
+
|
|
223
|
+
this.focusAttempted = true
|
|
224
|
+
this.focus()
|
|
225
|
+
this.hasFocused = root.activeElement === this
|
|
226
|
+
if (
|
|
227
|
+
this.hasFocused &&
|
|
228
|
+
root === document &&
|
|
229
|
+
active &&
|
|
230
|
+
active !== document.body
|
|
231
|
+
)
|
|
232
|
+
this.reclaimFocusFrom(active)
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Takes focus back once, if it went back to where it was.
|
|
238
|
+
*
|
|
239
|
+
* React gives focus back to the element that had it before a commit, right
|
|
240
|
+
* after the DOM has changed. The box moves focus as `hidden` is removed or
|
|
241
|
+
* as it is connected, that is inside the same commit, so focus ended up on
|
|
242
|
+
* the submit button again in Chromium and Firefox, and on the field in all
|
|
243
|
+
* three engines when the form was submitted with Enter. A microtask runs
|
|
244
|
+
* after the commit. If focus is then on the same element as before, the
|
|
245
|
+
* framework took it, and the box takes it again. If a script has moved
|
|
246
|
+
* focus somewhere else, it stays.
|
|
247
|
+
*
|
|
248
|
+
* Only when the box is directly in the document. React does not enter a
|
|
249
|
+
* shadow root when it restores focus, and there `document.activeElement`
|
|
250
|
+
* is the shadow host both before and after, so the comparison would take
|
|
251
|
+
* focus from a field in the same root. The condition is deliberately
|
|
252
|
+
* coarse: a box portalled into a shadow root from a React app in plain DOM
|
|
253
|
+
* does not take focus back.
|
|
254
|
+
*/
|
|
255
|
+
private reclaimFocusFrom(previous: Element): void {
|
|
256
|
+
queueMicrotask(() => {
|
|
257
|
+
if (
|
|
258
|
+
this.isConnected &&
|
|
259
|
+
!this.hidden &&
|
|
260
|
+
document.activeElement === previous
|
|
261
|
+
)
|
|
262
|
+
this.focus()
|
|
263
|
+
})
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* The element a link points to.
|
|
268
|
+
*
|
|
269
|
+
* The lookup goes to the root the component is in, not to `document`. If
|
|
270
|
+
* the form is in a shadow root, as in a preview or inside another
|
|
271
|
+
* component, `document.getElementById` finds nothing, and the link becomes
|
|
272
|
+
* a plain anchor link without moving focus.
|
|
273
|
+
*/
|
|
274
|
+
private resolveTarget(raw: string): HTMLElement | null {
|
|
275
|
+
const root = this.getRootNode() as Document | ShadowRoot
|
|
276
|
+
// A link to a field with non-ASCII characters in its id is often
|
|
277
|
+
// percent-encoded, `#f%C3%B8dselsdato`. The browser decodes it when the
|
|
278
|
+
// link is followed, so the lookup must do the same, or a working link is
|
|
279
|
+
// reported.
|
|
280
|
+
for (const id of new Set([raw, decodeFragment(raw)])) {
|
|
281
|
+
const target = root.getElementById?.(id) ?? document.getElementById(id)
|
|
282
|
+
if (target) return target
|
|
283
|
+
}
|
|
284
|
+
return null
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
private handleLinkClick = (event: Event): void => {
|
|
288
|
+
const link = (event.target as Element | null)?.closest?.(
|
|
289
|
+
LT_ERROR_SUMMARY_PARTS.link,
|
|
290
|
+
)
|
|
291
|
+
if (!link || !this.contains(link)) return
|
|
292
|
+
const id = link.getAttribute("href")?.slice(1)
|
|
293
|
+
if (!id) return
|
|
294
|
+
|
|
295
|
+
// The guard stays for the race: the target may have disappeared in a
|
|
296
|
+
// patch between the sync and the click. `sync()` has already reported a
|
|
297
|
+
// link that never had a target.
|
|
298
|
+
const target = this.resolveTarget(id)
|
|
299
|
+
if (!target) return
|
|
300
|
+
|
|
301
|
+
event.preventDefault()
|
|
302
|
+
|
|
303
|
+
// If the link is to a label, focus goes to what the label belongs to,
|
|
304
|
+
// whether it points with `for` or wraps the control. `control` covers
|
|
305
|
+
// both for real controls; if `for` points to something else, such as a
|
|
306
|
+
// group, the id is followed there.
|
|
307
|
+
const focusable =
|
|
308
|
+
target instanceof HTMLLabelElement
|
|
309
|
+
? (target.control ??
|
|
310
|
+
(target.htmlFor ? this.resolveTarget(target.htmlFor) : null) ??
|
|
311
|
+
target)
|
|
312
|
+
: target
|
|
313
|
+
|
|
314
|
+
// A target that cannot take focus, such as a heading, gets a `tabindex`
|
|
315
|
+
// for this one jump. It is a write on markup that comes from the server,
|
|
316
|
+
// and a patch may remove it again; by then the jump has happened.
|
|
317
|
+
if (!focusable.hasAttribute("tabindex") && !isFocusable(focusable)) {
|
|
318
|
+
setAttr(focusable, "tabindex", "-1")
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
focusable.focus()
|
|
322
|
+
// Without `behavior`: the page's own `scroll-behavior` decides. The
|
|
323
|
+
// browser does not turn off `smooth` by itself under
|
|
324
|
+
// `prefers-reduced-motion`, so that is up to the page, and "Accessibility"
|
|
325
|
+
// in the documentation says so.
|
|
326
|
+
focusable.scrollIntoView({ block: "center" })
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function isFocusable(element: Element): boolean {
|
|
331
|
+
return (
|
|
332
|
+
element instanceof HTMLInputElement ||
|
|
333
|
+
element instanceof HTMLSelectElement ||
|
|
334
|
+
element instanceof HTMLTextAreaElement ||
|
|
335
|
+
element instanceof HTMLButtonElement ||
|
|
336
|
+
element instanceof HTMLAnchorElement
|
|
337
|
+
)
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export function defineLtErrorSummary(
|
|
341
|
+
tagName: string = LT_ERROR_SUMMARY_TAG,
|
|
342
|
+
): void {
|
|
343
|
+
defineElement(tagName, LtErrorSummary)
|
|
344
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import type { FieldState, RequiredMarker } from "../../css/shared.js"
|
|
2
|
+
import { attributes, createFieldId, idOrFallback } from "../../css/shared.js"
|
|
3
|
+
|
|
4
|
+
// Re-exported here, where it used to live, so consumers that import from
|
|
5
|
+
// `./field-core` do not notice the move.
|
|
6
|
+
export { createFieldId }
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Computes the wiring between label, field, help text and error text.
|
|
10
|
+
*
|
|
11
|
+
* This is the one implementation of the accessibility contract in the system.
|
|
12
|
+
* `<lt-field>` applies it to elements already in the DOM, and `lt.field()`
|
|
13
|
+
* returns the same result as data, for whoever writes the markup with
|
|
14
|
+
* JavaScript. Without sharing it, the contract would exist in two places and
|
|
15
|
+
* could drift apart.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export type FieldOptions = {
|
|
19
|
+
/**
|
|
20
|
+
* The id of the control. Required.
|
|
21
|
+
*
|
|
22
|
+
* In React it comes from `useId()`. Otherwise the field's name is usually
|
|
23
|
+
* the obvious choice. If you know for certain that the markup is rendered
|
|
24
|
+
* once, call `createFieldId()` yourself.
|
|
25
|
+
*
|
|
26
|
+
* It used to be optional, and the function created one when it was
|
|
27
|
+
* missing. That id is random, so two runs give two different ones, and if
|
|
28
|
+
* the same field is rendered on a server and then in the browser, `for`
|
|
29
|
+
* and `aria-describedby` point to something other than what is there.
|
|
30
|
+
* React reports a mismatch on hydration, and the warning itself says the
|
|
31
|
+
* mismatch is not repaired.
|
|
32
|
+
*
|
|
33
|
+
* The type requires it, and that is not enough on its own: a consumer
|
|
34
|
+
* without TypeScript sees no type. If the id is left out anyway, the
|
|
35
|
+
* function creates one and says so in the console. The field then works,
|
|
36
|
+
* and the developer learns why the id should be given anyway. Without the
|
|
37
|
+
* fallback they got `for=""`, `aria-describedby="undefined-help"` and no
|
|
38
|
+
* wiring at all, which is worse than the unstable id the requirement was
|
|
39
|
+
* meant to remove.
|
|
40
|
+
*/
|
|
41
|
+
id: string
|
|
42
|
+
/** The field has a help text to connect with `aria-describedby`. */
|
|
43
|
+
help?: boolean
|
|
44
|
+
/** The field has an error text. It is hidden until the field is invalid. */
|
|
45
|
+
error?: boolean
|
|
46
|
+
/** A separate id for the help text. Derived from `id` if left out. */
|
|
47
|
+
helpId?: string
|
|
48
|
+
/** A separate id for the error text. Derived from `id` if left out. */
|
|
49
|
+
errorId?: string
|
|
50
|
+
/** Marks the label as required. */
|
|
51
|
+
required?: RequiredMarker
|
|
52
|
+
/** Marks the label as optional. */
|
|
53
|
+
optional?: boolean
|
|
54
|
+
/** The field is invalid: shows the error text and sets `aria-invalid`. */
|
|
55
|
+
invalid?: boolean
|
|
56
|
+
/** The control is disabled. */
|
|
57
|
+
disabled?: boolean
|
|
58
|
+
/** Extra ids to include in `aria-describedby`. */
|
|
59
|
+
describedBy?: string[]
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export type FieldAttributes = {
|
|
63
|
+
label: {
|
|
64
|
+
class: "lt-label"
|
|
65
|
+
for: string
|
|
66
|
+
"data-required"?: RequiredMarker
|
|
67
|
+
"data-optional"?: ""
|
|
68
|
+
"aria-disabled"?: "true"
|
|
69
|
+
}
|
|
70
|
+
control: {
|
|
71
|
+
id: string
|
|
72
|
+
"aria-describedby"?: string
|
|
73
|
+
"aria-invalid"?: "true"
|
|
74
|
+
"data-state"?: "invalid"
|
|
75
|
+
disabled?: true
|
|
76
|
+
}
|
|
77
|
+
help: { id: string }
|
|
78
|
+
error: { id: string; hidden?: true }
|
|
79
|
+
/** The state the control should have, for `input()`, `textarea()` and `select()`. */
|
|
80
|
+
state: FieldState
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Joins `aria-describedby` from the help text, the error text and whatever
|
|
85
|
+
* the caller added.
|
|
86
|
+
*
|
|
87
|
+
* The error text is only included when the field is actually invalid.
|
|
88
|
+
* Otherwise `aria-describedby` would point to a hidden element, and screen
|
|
89
|
+
* readers then announce either nothing or something that is not on the
|
|
90
|
+
* screen.
|
|
91
|
+
*/
|
|
92
|
+
export function joinDescribedBy(
|
|
93
|
+
ids: Array<string | undefined | false>,
|
|
94
|
+
): string | undefined {
|
|
95
|
+
const unique = new Set<string>()
|
|
96
|
+
for (const id of ids) {
|
|
97
|
+
if (!id) continue
|
|
98
|
+
for (const part of id.split(/\s+/)) {
|
|
99
|
+
if (part) unique.add(part)
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return unique.size > 0 ? [...unique].join(" ") : undefined
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function computeFieldAttributes(options: FieldOptions): FieldAttributes {
|
|
106
|
+
const {
|
|
107
|
+
id: givenId,
|
|
108
|
+
help = false,
|
|
109
|
+
error = false,
|
|
110
|
+
required,
|
|
111
|
+
optional,
|
|
112
|
+
invalid = false,
|
|
113
|
+
disabled = false,
|
|
114
|
+
describedBy = [],
|
|
115
|
+
} = options
|
|
116
|
+
|
|
117
|
+
// The fallback is only for callers without a type check. See `idOrFallback`.
|
|
118
|
+
const id = idOrFallback("lt.field()", givenId)
|
|
119
|
+
const helpId = options.helpId ?? `${id}-help`
|
|
120
|
+
const errorId = options.errorId ?? `${id}-error`
|
|
121
|
+
|
|
122
|
+
return {
|
|
123
|
+
label: attributes({
|
|
124
|
+
class: "lt-label" as const,
|
|
125
|
+
for: id,
|
|
126
|
+
"data-required": required,
|
|
127
|
+
"data-optional": optional && !required ? ("" as const) : undefined,
|
|
128
|
+
"aria-disabled": disabled ? ("true" as const) : undefined,
|
|
129
|
+
}),
|
|
130
|
+
control: attributes({
|
|
131
|
+
id,
|
|
132
|
+
"aria-describedby": joinDescribedBy([
|
|
133
|
+
help && helpId,
|
|
134
|
+
invalid && error && errorId,
|
|
135
|
+
...describedBy,
|
|
136
|
+
]),
|
|
137
|
+
"aria-invalid": invalid ? ("true" as const) : undefined,
|
|
138
|
+
// The colour comes from here, not from input()/textarea()/select().
|
|
139
|
+
// Otherwise both would set aria-invalid, and in templates that write
|
|
140
|
+
// the attributes out literally, such as Astro and plain HTML, it
|
|
141
|
+
// appeared twice.
|
|
142
|
+
"data-state": invalid ? ("invalid" as const) : undefined,
|
|
143
|
+
disabled: disabled ? (true as const) : undefined,
|
|
144
|
+
}),
|
|
145
|
+
help: attributes({ id: helpId }),
|
|
146
|
+
error: attributes({
|
|
147
|
+
id: errorId,
|
|
148
|
+
hidden: invalid ? undefined : (true as const),
|
|
149
|
+
}),
|
|
150
|
+
state: invalid ? "invalid" : "default",
|
|
151
|
+
}
|
|
152
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
@import "../../css/label/label.css";
|
|
2
|
+
@import "../../css/input/input.css";
|
|
3
|
+
@import "../../css/textarea/textarea.css";
|
|
4
|
+
@import "../../css/select/select.css";
|
|
5
|
+
@import "../../css/help-text/help-text.css";
|
|
6
|
+
@import "../../css/error-text/error-text.css";
|
|
7
|
+
|
|
8
|
+
@layer lotek {
|
|
9
|
+
/* A web component is `display: inline` until something says otherwise,
|
|
10
|
+
and `<lt-field>` was the only one that wraps other elements without
|
|
11
|
+
saying so. The children are blocks, so it looked right until someone
|
|
12
|
+
gave the element a margin or put it in a grid. `<lt-suggestion>` has
|
|
13
|
+
always said the same about itself. */
|
|
14
|
+
lt-field {
|
|
15
|
+
display: block;
|
|
16
|
+
}
|
|
17
|
+
}
|