@m3e/core 1.0.0-rc.1
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/LICENSE +22 -0
- package/NOTICE.md +8 -0
- package/README.md +59 -0
- package/cem.config.mjs +16 -0
- package/demo/index.html +58 -0
- package/dist/a11y.js +1431 -0
- package/dist/a11y.js.map +1 -0
- package/dist/a11y.min.js +87 -0
- package/dist/a11y.min.js.map +1 -0
- package/dist/anchoring.js +1748 -0
- package/dist/anchoring.js.map +1 -0
- package/dist/anchoring.min.js +7 -0
- package/dist/anchoring.min.js.map +1 -0
- package/dist/bidi.js +106 -0
- package/dist/bidi.js.map +1 -0
- package/dist/bidi.min.js +16 -0
- package/dist/bidi.min.js.map +1 -0
- package/dist/css-custom-data.json +257 -0
- package/dist/custom-elements.json +13504 -0
- package/dist/html-custom-data.json +199 -0
- package/dist/index.js +4342 -0
- package/dist/index.js.map +1 -0
- package/dist/index.min.js +520 -0
- package/dist/index.min.js.map +1 -0
- package/dist/layout.js +64 -0
- package/dist/layout.js.map +1 -0
- package/dist/layout.min.js +15 -0
- package/dist/layout.min.js.map +1 -0
- package/dist/platform.js +56 -0
- package/dist/platform.js.map +1 -0
- package/dist/platform.min.js +15 -0
- package/dist/platform.min.js.map +1 -0
- package/dist/src/a11y/AriaDescriber.d.ts +31 -0
- package/dist/src/a11y/AriaDescriber.d.ts.map +1 -0
- package/dist/src/a11y/FocusTrapElement.d.ts +25 -0
- package/dist/src/a11y/FocusTrapElement.d.ts.map +1 -0
- package/dist/src/a11y/InteractivityChecker.d.ts +22 -0
- package/dist/src/a11y/InteractivityChecker.d.ts.map +1 -0
- package/dist/src/a11y/LiveAnnouncer.d.ts +56 -0
- package/dist/src/a11y/LiveAnnouncer.d.ts.map +1 -0
- package/dist/src/a11y/aria-reference.d.ts +30 -0
- package/dist/src/a11y/aria-reference.d.ts.map +1 -0
- package/dist/src/a11y/index.d.ts +8 -0
- package/dist/src/a11y/index.d.ts.map +1 -0
- package/dist/src/a11y/keycodes/KeyCode.d.ts +118 -0
- package/dist/src/a11y/keycodes/KeyCode.d.ts.map +1 -0
- package/dist/src/a11y/keycodes/ModifierKeys.d.ts +5 -0
- package/dist/src/a11y/keycodes/ModifierKeys.d.ts.map +1 -0
- package/dist/src/a11y/keycodes/getKeyCode.d.ts +7 -0
- package/dist/src/a11y/keycodes/getKeyCode.d.ts.map +1 -0
- package/dist/src/a11y/keycodes/hasModifierKey.d.ts +9 -0
- package/dist/src/a11y/keycodes/hasModifierKey.d.ts.map +1 -0
- package/dist/src/a11y/keycodes/index.d.ts +6 -0
- package/dist/src/a11y/keycodes/index.d.ts.map +1 -0
- package/dist/src/a11y/keycodes/isModifierAllowed.d.ts +9 -0
- package/dist/src/a11y/keycodes/isModifierAllowed.d.ts.map +1 -0
- package/dist/src/a11y/list-key/FocusKeyManager.d.ts +17 -0
- package/dist/src/a11y/list-key/FocusKeyManager.d.ts.map +1 -0
- package/dist/src/a11y/list-key/ListKeyManager.d.ts +114 -0
- package/dist/src/a11y/list-key/ListKeyManager.d.ts.map +1 -0
- package/dist/src/a11y/list-key/ListManager.d.ts +37 -0
- package/dist/src/a11y/list-key/ListManager.d.ts.map +1 -0
- package/dist/src/a11y/list-key/RadioKeyManager.d.ts +20 -0
- package/dist/src/a11y/list-key/RadioKeyManager.d.ts.map +1 -0
- package/dist/src/a11y/list-key/RovingTabIndexManager.d.ts +22 -0
- package/dist/src/a11y/list-key/RovingTabIndexManager.d.ts.map +1 -0
- package/dist/src/a11y/list-key/SelectionManager.d.ts +46 -0
- package/dist/src/a11y/list-key/SelectionManager.d.ts.map +1 -0
- package/dist/src/a11y/list-key/Typeahead.d.ts +64 -0
- package/dist/src/a11y/list-key/Typeahead.d.ts.map +1 -0
- package/dist/src/a11y/list-key/index.d.ts +8 -0
- package/dist/src/a11y/list-key/index.d.ts.map +1 -0
- package/dist/src/a11y/visuallyHide.d.ts +6 -0
- package/dist/src/a11y/visuallyHide.d.ts.map +1 -0
- package/dist/src/anchoring/AnchorOptions.d.ts +15 -0
- package/dist/src/anchoring/AnchorOptions.d.ts.map +1 -0
- package/dist/src/anchoring/AnchorPosition.d.ts +3 -0
- package/dist/src/anchoring/AnchorPosition.d.ts.map +1 -0
- package/dist/src/anchoring/index.d.ts +4 -0
- package/dist/src/anchoring/index.d.ts.map +1 -0
- package/dist/src/anchoring/positionAnchor.d.ts +12 -0
- package/dist/src/anchoring/positionAnchor.d.ts.map +1 -0
- package/dist/src/bidi/Directionality.d.ts +27 -0
- package/dist/src/bidi/Directionality.d.ts.map +1 -0
- package/dist/src/bidi/index.d.ts +2 -0
- package/dist/src/bidi/index.d.ts.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/layout/Breakpoint.d.ts +26 -0
- package/dist/src/layout/Breakpoint.d.ts.map +1 -0
- package/dist/src/layout/BreakpointObserver.d.ts +18 -0
- package/dist/src/layout/BreakpointObserver.d.ts.map +1 -0
- package/dist/src/layout/index.d.ts +3 -0
- package/dist/src/layout/index.d.ts.map +1 -0
- package/dist/src/platform/Platform.d.ts +34 -0
- package/dist/src/platform/Platform.d.ts.map +1 -0
- package/dist/src/platform/index.d.ts +2 -0
- package/dist/src/platform/index.d.ts.map +1 -0
- package/dist/src/shared/controllers/FocusController.d.ts +30 -0
- package/dist/src/shared/controllers/FocusController.d.ts.map +1 -0
- package/dist/src/shared/controllers/HoverController.d.ts +40 -0
- package/dist/src/shared/controllers/HoverController.d.ts.map +1 -0
- package/dist/src/shared/controllers/IntersectionController.d.ts +40 -0
- package/dist/src/shared/controllers/IntersectionController.d.ts.map +1 -0
- package/dist/src/shared/controllers/LongPressController.d.ts +32 -0
- package/dist/src/shared/controllers/LongPressController.d.ts.map +1 -0
- package/dist/src/shared/controllers/MonitorControllerBase.d.ts +62 -0
- package/dist/src/shared/controllers/MonitorControllerBase.d.ts.map +1 -0
- package/dist/src/shared/controllers/MutationController.d.ts +37 -0
- package/dist/src/shared/controllers/MutationController.d.ts.map +1 -0
- package/dist/src/shared/controllers/PressedController.d.ts +45 -0
- package/dist/src/shared/controllers/PressedController.d.ts.map +1 -0
- package/dist/src/shared/controllers/ResizeController.d.ts +40 -0
- package/dist/src/shared/controllers/ResizeController.d.ts.map +1 -0
- package/dist/src/shared/controllers/ScrollController.d.ts +34 -0
- package/dist/src/shared/controllers/ScrollController.d.ts.map +1 -0
- package/dist/src/shared/controllers/index.d.ts +9 -0
- package/dist/src/shared/controllers/index.d.ts.map +1 -0
- package/dist/src/shared/decorators/debounce.d.ts +7 -0
- package/dist/src/shared/decorators/debounce.d.ts.map +1 -0
- package/dist/src/shared/decorators/index.d.ts +2 -0
- package/dist/src/shared/decorators/index.d.ts.map +1 -0
- package/dist/src/shared/directives/index.d.ts +2 -0
- package/dist/src/shared/directives/index.d.ts.map +1 -0
- package/dist/src/shared/directives/safeStyleMap.d.ts +44 -0
- package/dist/src/shared/directives/safeStyleMap.d.ts.map +1 -0
- package/dist/src/shared/index.d.ts +8 -0
- package/dist/src/shared/index.d.ts.map +1 -0
- package/dist/src/shared/mixins/AttachInternals.d.ts +24 -0
- package/dist/src/shared/mixins/AttachInternals.d.ts.map +1 -0
- package/dist/src/shared/mixins/Checked.d.ts +24 -0
- package/dist/src/shared/mixins/Checked.d.ts.map +1 -0
- package/dist/src/shared/mixins/CheckedIndeterminate.d.ts +25 -0
- package/dist/src/shared/mixins/CheckedIndeterminate.d.ts.map +1 -0
- package/dist/src/shared/mixins/CheckedOrSelected.d.ts +23 -0
- package/dist/src/shared/mixins/CheckedOrSelected.d.ts.map +1 -0
- package/dist/src/shared/mixins/ConstraintValidation.d.ts +48 -0
- package/dist/src/shared/mixins/ConstraintValidation.d.ts.map +1 -0
- package/dist/src/shared/mixins/Constructor.d.ts +3 -0
- package/dist/src/shared/mixins/Constructor.d.ts.map +1 -0
- package/dist/src/shared/mixins/Dirty.d.ts +27 -0
- package/dist/src/shared/mixins/Dirty.d.ts.map +1 -0
- package/dist/src/shared/mixins/Disabled.d.ts +25 -0
- package/dist/src/shared/mixins/Disabled.d.ts.map +1 -0
- package/dist/src/shared/mixins/DisabledInteractive.d.ts +25 -0
- package/dist/src/shared/mixins/DisabledInteractive.d.ts.map +1 -0
- package/dist/src/shared/mixins/EventAttribute.d.ts +11 -0
- package/dist/src/shared/mixins/EventAttribute.d.ts.map +1 -0
- package/dist/src/shared/mixins/Focusable.d.ts +11 -0
- package/dist/src/shared/mixins/Focusable.d.ts.map +1 -0
- package/dist/src/shared/mixins/FormAssociated.d.ts +34 -0
- package/dist/src/shared/mixins/FormAssociated.d.ts.map +1 -0
- package/dist/src/shared/mixins/FormSubmitter.d.ts +31 -0
- package/dist/src/shared/mixins/FormSubmitter.d.ts.map +1 -0
- package/dist/src/shared/mixins/HtmlFor.d.ts +30 -0
- package/dist/src/shared/mixins/HtmlFor.d.ts.map +1 -0
- package/dist/src/shared/mixins/KeyboardClick.d.ts +11 -0
- package/dist/src/shared/mixins/KeyboardClick.d.ts.map +1 -0
- package/dist/src/shared/mixins/Labelled.d.ts +22 -0
- package/dist/src/shared/mixins/Labelled.d.ts.map +1 -0
- package/dist/src/shared/mixins/LinkButton.d.ts +36 -0
- package/dist/src/shared/mixins/LinkButton.d.ts.map +1 -0
- package/dist/src/shared/mixins/ReadOnly.d.ts +25 -0
- package/dist/src/shared/mixins/ReadOnly.d.ts.map +1 -0
- package/dist/src/shared/mixins/Required.d.ts +26 -0
- package/dist/src/shared/mixins/Required.d.ts.map +1 -0
- package/dist/src/shared/mixins/RequiredConstraintValidation.d.ts +21 -0
- package/dist/src/shared/mixins/RequiredConstraintValidation.d.ts.map +1 -0
- package/dist/src/shared/mixins/Role.d.ts +13 -0
- package/dist/src/shared/mixins/Role.d.ts.map +1 -0
- package/dist/src/shared/mixins/Selected.d.ts +24 -0
- package/dist/src/shared/mixins/Selected.d.ts.map +1 -0
- package/dist/src/shared/mixins/Touched.d.ts +27 -0
- package/dist/src/shared/mixins/Touched.d.ts.map +1 -0
- package/dist/src/shared/mixins/Vertical.d.ts +24 -0
- package/dist/src/shared/mixins/Vertical.d.ts.map +1 -0
- package/dist/src/shared/mixins/hasKeys.d.ts +9 -0
- package/dist/src/shared/mixins/hasKeys.d.ts.map +1 -0
- package/dist/src/shared/mixins/index.d.ts +25 -0
- package/dist/src/shared/mixins/index.d.ts.map +1 -0
- package/dist/src/shared/primitives/CollapsibleElement.d.ts +58 -0
- package/dist/src/shared/primitives/CollapsibleElement.d.ts.map +1 -0
- package/dist/src/shared/primitives/ElevationElement.d.ts +88 -0
- package/dist/src/shared/primitives/ElevationElement.d.ts.map +1 -0
- package/dist/src/shared/primitives/ElevationLevel.d.ts +3 -0
- package/dist/src/shared/primitives/ElevationLevel.d.ts.map +1 -0
- package/dist/src/shared/primitives/ElevationToken.d.ts +15 -0
- package/dist/src/shared/primitives/ElevationToken.d.ts.map +1 -0
- package/dist/src/shared/primitives/FocusRingElement.d.ts +78 -0
- package/dist/src/shared/primitives/FocusRingElement.d.ts.map +1 -0
- package/dist/src/shared/primitives/FocusRingToken.d.ts +17 -0
- package/dist/src/shared/primitives/FocusRingToken.d.ts.map +1 -0
- package/dist/src/shared/primitives/PseudoCheckboxElement.d.ts +50 -0
- package/dist/src/shared/primitives/PseudoCheckboxElement.d.ts.map +1 -0
- package/dist/src/shared/primitives/PseudoRadioElement.d.ts +41 -0
- package/dist/src/shared/primitives/PseudoRadioElement.d.ts.map +1 -0
- package/dist/src/shared/primitives/RippleElement.d.ts +110 -0
- package/dist/src/shared/primitives/RippleElement.d.ts.map +1 -0
- package/dist/src/shared/primitives/RippleToken.d.ts +12 -0
- package/dist/src/shared/primitives/RippleToken.d.ts.map +1 -0
- package/dist/src/shared/primitives/ScrollContainerElement.d.ts +64 -0
- package/dist/src/shared/primitives/ScrollContainerElement.d.ts.map +1 -0
- package/dist/src/shared/primitives/ScrollDividers.d.ts +3 -0
- package/dist/src/shared/primitives/ScrollDividers.d.ts.map +1 -0
- package/dist/src/shared/primitives/SlideElement.d.ts +48 -0
- package/dist/src/shared/primitives/SlideElement.d.ts.map +1 -0
- package/dist/src/shared/primitives/StateLayerElement.d.ts +77 -0
- package/dist/src/shared/primitives/StateLayerElement.d.ts.map +1 -0
- package/dist/src/shared/primitives/StateLayerToken.d.ts +13 -0
- package/dist/src/shared/primitives/StateLayerToken.d.ts.map +1 -0
- package/dist/src/shared/primitives/TextOverflowElement.d.ts +39 -0
- package/dist/src/shared/primitives/TextOverflowElement.d.ts.map +1 -0
- package/dist/src/shared/primitives/index.d.ts +13 -0
- package/dist/src/shared/primitives/index.d.ts.map +1 -0
- package/dist/src/shared/tokens/ColorToken.d.ts +96 -0
- package/dist/src/shared/tokens/ColorToken.d.ts.map +1 -0
- package/dist/src/shared/tokens/DensityToken.d.ts +15 -0
- package/dist/src/shared/tokens/DensityToken.d.ts.map +1 -0
- package/dist/src/shared/tokens/DesignToken.d.ts +366 -0
- package/dist/src/shared/tokens/DesignToken.d.ts.map +1 -0
- package/dist/src/shared/tokens/ElevationToken.d.ts +16 -0
- package/dist/src/shared/tokens/ElevationToken.d.ts.map +1 -0
- package/dist/src/shared/tokens/MotionToken.d.ts +69 -0
- package/dist/src/shared/tokens/MotionToken.d.ts.map +1 -0
- package/dist/src/shared/tokens/ScrollbarToken.d.ts +10 -0
- package/dist/src/shared/tokens/ScrollbarToken.d.ts.map +1 -0
- package/dist/src/shared/tokens/ShapeToken.d.ts +79 -0
- package/dist/src/shared/tokens/ShapeToken.d.ts.map +1 -0
- package/dist/src/shared/tokens/StateToken.d.ts +10 -0
- package/dist/src/shared/tokens/StateToken.d.ts.map +1 -0
- package/dist/src/shared/tokens/TypescaleToken.d.ts +220 -0
- package/dist/src/shared/tokens/TypescaleToken.d.ts.map +1 -0
- package/dist/src/shared/tokens/index.d.ts +2 -0
- package/dist/src/shared/tokens/index.d.ts.map +1 -0
- package/dist/src/shared/utils/getTextContent.d.ts +8 -0
- package/dist/src/shared/utils/getTextContent.d.ts.map +1 -0
- package/dist/src/shared/utils/guid.d.ts +6 -0
- package/dist/src/shared/utils/guid.d.ts.map +1 -0
- package/dist/src/shared/utils/hasAssignedNodes.d.ts +7 -0
- package/dist/src/shared/utils/hasAssignedNodes.d.ts.map +1 -0
- package/dist/src/shared/utils/index.d.ts +6 -0
- package/dist/src/shared/utils/index.d.ts.map +1 -0
- package/dist/src/shared/utils/prefersReducedMotion.d.ts +6 -0
- package/dist/src/shared/utils/prefersReducedMotion.d.ts.map +1 -0
- package/dist/src/shared/utils/scrollIntoViewIfNeeded.d.ts +8 -0
- package/dist/src/shared/utils/scrollIntoViewIfNeeded.d.ts.map +1 -0
- package/eslint.config.mjs +21 -0
- package/package.json +87 -0
- package/rollup.config.js +132 -0
- package/src/a11y/AriaDescriber.ts +130 -0
- package/src/a11y/FocusTrapElement.ts +136 -0
- package/src/a11y/InteractivityChecker.ts +62 -0
- package/src/a11y/LiveAnnouncer.ts +143 -0
- package/src/a11y/aria-reference.ts +51 -0
- package/src/a11y/index.ts +8 -0
- package/src/a11y/keycodes/KeyCode.ts +128 -0
- package/src/a11y/keycodes/ModifierKeys.ts +5 -0
- package/src/a11y/keycodes/getKeyCode.ts +8 -0
- package/src/a11y/keycodes/hasModifierKey.ts +11 -0
- package/src/a11y/keycodes/index.ts +5 -0
- package/src/a11y/keycodes/isModifierAllowed.ts +12 -0
- package/src/a11y/list-key/FocusKeyManager.ts +25 -0
- package/src/a11y/list-key/ListKeyManager.ts +350 -0
- package/src/a11y/list-key/ListManager.ts +66 -0
- package/src/a11y/list-key/RadioKeyManager.ts +49 -0
- package/src/a11y/list-key/RovingTabIndexManager.ts +56 -0
- package/src/a11y/list-key/SelectionManager.ts +132 -0
- package/src/a11y/list-key/Typeahead.ts +131 -0
- package/src/a11y/list-key/index.ts +7 -0
- package/src/a11y/visuallyHide.ts +18 -0
- package/src/anchoring/AnchorOptions.ts +19 -0
- package/src/anchoring/AnchorPosition.ts +14 -0
- package/src/anchoring/index.ts +3 -0
- package/src/anchoring/positionAnchor.ts +53 -0
- package/src/bidi/Directionality.ts +85 -0
- package/src/bidi/index.ts +1 -0
- package/src/index.ts +1 -0
- package/src/layout/Breakpoint.ts +26 -0
- package/src/layout/BreakpointObserver.ts +44 -0
- package/src/layout/index.ts +2 -0
- package/src/platform/Platform.ts +67 -0
- package/src/platform/index.ts +1 -0
- package/src/shared/controllers/FocusController.ts +60 -0
- package/src/shared/controllers/HoverController.ts +140 -0
- package/src/shared/controllers/IntersectionController.ts +81 -0
- package/src/shared/controllers/LongPressController.ts +87 -0
- package/src/shared/controllers/MonitorControllerBase.ts +99 -0
- package/src/shared/controllers/MutationController.ts +89 -0
- package/src/shared/controllers/PressedController.ts +137 -0
- package/src/shared/controllers/ResizeController.ts +83 -0
- package/src/shared/controllers/ScrollController.ts +100 -0
- package/src/shared/controllers/index.ts +8 -0
- package/src/shared/decorators/debounce.ts +19 -0
- package/src/shared/decorators/index.ts +1 -0
- package/src/shared/directives/index.ts +1 -0
- package/src/shared/directives/safeStyleMap.ts +108 -0
- package/src/shared/index.ts +7 -0
- package/src/shared/mixins/AttachInternals.ts +48 -0
- package/src/shared/mixins/Checked.ts +50 -0
- package/src/shared/mixins/CheckedIndeterminate.ts +47 -0
- package/src/shared/mixins/CheckedOrSelected.ts +36 -0
- package/src/shared/mixins/ConstraintValidation.ts +213 -0
- package/src/shared/mixins/Constructor.ts +2 -0
- package/src/shared/mixins/Dirty.ts +71 -0
- package/src/shared/mixins/Disabled.ts +49 -0
- package/src/shared/mixins/DisabledInteractive.ts +78 -0
- package/src/shared/mixins/EventAttribute.ts +25 -0
- package/src/shared/mixins/Focusable.ts +52 -0
- package/src/shared/mixins/FormAssociated.ts +152 -0
- package/src/shared/mixins/FormSubmitter.ts +123 -0
- package/src/shared/mixins/HtmlFor.ts +89 -0
- package/src/shared/mixins/KeyboardClick.ts +46 -0
- package/src/shared/mixins/Labelled.ts +88 -0
- package/src/shared/mixins/LinkButton.ts +169 -0
- package/src/shared/mixins/ReadOnly.ts +48 -0
- package/src/shared/mixins/Required.ts +50 -0
- package/src/shared/mixins/RequiredConstraintValidation.ts +45 -0
- package/src/shared/mixins/Role.ts +134 -0
- package/src/shared/mixins/Selected.ts +50 -0
- package/src/shared/mixins/Touched.ts +71 -0
- package/src/shared/mixins/Vertical.ts +44 -0
- package/src/shared/mixins/hasKeys.ts +10 -0
- package/src/shared/mixins/index.ts +24 -0
- package/src/shared/primitives/CollapsibleElement.ts +227 -0
- package/src/shared/primitives/ElevationElement.ts +254 -0
- package/src/shared/primitives/ElevationLevel.ts +2 -0
- package/src/shared/primitives/ElevationToken.ts +18 -0
- package/src/shared/primitives/FocusRingElement.ts +199 -0
- package/src/shared/primitives/FocusRingToken.ts +24 -0
- package/src/shared/primitives/PseudoCheckboxElement.ts +116 -0
- package/src/shared/primitives/PseudoRadioElement.ts +83 -0
- package/src/shared/primitives/RippleElement.ts +289 -0
- package/src/shared/primitives/RippleToken.ts +15 -0
- package/src/shared/primitives/ScrollContainerElement.ts +151 -0
- package/src/shared/primitives/ScrollDividers.ts +2 -0
- package/src/shared/primitives/SlideElement.ts +128 -0
- package/src/shared/primitives/StateLayerElement.ts +191 -0
- package/src/shared/primitives/StateLayerToken.ts +16 -0
- package/src/shared/primitives/TextOverflowElement.ts +60 -0
- package/src/shared/primitives/index.ts +12 -0
- package/src/shared/tokens/ColorToken.ts +142 -0
- package/src/shared/tokens/DensityToken.ts +23 -0
- package/src/shared/tokens/DesignToken.ts +35 -0
- package/src/shared/tokens/ElevationToken.ts +115 -0
- package/src/shared/tokens/MotionToken.ts +107 -0
- package/src/shared/tokens/ScrollbarToken.ts +13 -0
- package/src/shared/tokens/ShapeToken.ts +138 -0
- package/src/shared/tokens/StateToken.ts +13 -0
- package/src/shared/tokens/TypescaleToken.ts +230 -0
- package/src/shared/tokens/index.ts +1 -0
- package/src/shared/utils/getTextContent.ts +31 -0
- package/src/shared/utils/guid.ts +11 -0
- package/src/shared/utils/hasAssignedNodes.ts +8 -0
- package/src/shared/utils/index.ts +5 -0
- package/src/shared/utils/prefersReducedMotion.ts +9 -0
- package/src/shared/utils/scrollIntoViewIfNeeded.ts +18 -0
- package/tsconfig.json +9 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
import { property } from "lit/decorators.js";
|
|
3
|
+
|
|
4
|
+
import { AttachInternalsMixin, internals, isAttachInternalsMixin } from "./AttachInternals";
|
|
5
|
+
import { Constructor } from "./Constructor";
|
|
6
|
+
import { hasKeys } from "./hasKeys";
|
|
7
|
+
import { isDisabledMixin } from "./Disabled";
|
|
8
|
+
import { isDisabledInteractiveMixin } from "./DisabledInteractive";
|
|
9
|
+
|
|
10
|
+
/** Specifies the form submission behaviors. */
|
|
11
|
+
export type FormSubmitterType = "button" | "submit" | "reset";
|
|
12
|
+
|
|
13
|
+
/** Defines functionality for an element which can be used to submit a form. */
|
|
14
|
+
export interface FormSubmitterMixin extends AttachInternalsMixin {
|
|
15
|
+
/**
|
|
16
|
+
* The name of the element, submitted as a pair with the element's `value`
|
|
17
|
+
* as part of form data, when the element is used to submit a form.
|
|
18
|
+
*/
|
|
19
|
+
name: string;
|
|
20
|
+
|
|
21
|
+
/** The value associated with the element's name when it's submitted with form data. */
|
|
22
|
+
value: string | null;
|
|
23
|
+
|
|
24
|
+
/** The type of the element. */
|
|
25
|
+
type: FormSubmitterType;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Determines whether a value is a `FormSubmitterMixin`.
|
|
30
|
+
* @param {unknown} value The value to test.
|
|
31
|
+
* @returns {value is FormSubmitterMixin} Whether `value` is a `FormSubmitterMixin`.
|
|
32
|
+
*/
|
|
33
|
+
export function isFormSubmitterMixin(value: unknown): value is FormSubmitterMixin {
|
|
34
|
+
return hasKeys<FormSubmitterMixin>(value, "name", "type", "value") && isAttachInternalsMixin(value);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const _clickHandler = Symbol("_clickHandler");
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Mixin to augment an element with behavior used to submit a form.
|
|
41
|
+
* @template T The type of the base class.
|
|
42
|
+
* @param {T} base The base class.
|
|
43
|
+
* @returns {Constructor<FormSubmitterMixin>} A constructor that implements `FormSubmitterMixin`.
|
|
44
|
+
*/
|
|
45
|
+
export function FormSubmitter<T extends Constructor<LitElement & AttachInternalsMixin>>(
|
|
46
|
+
base: T
|
|
47
|
+
): Constructor<FormSubmitterMixin> & T {
|
|
48
|
+
abstract class _FormSubmitterMixin extends base implements FormSubmitterMixin {
|
|
49
|
+
@property() get name() {
|
|
50
|
+
return this.getAttribute("name") ?? "";
|
|
51
|
+
}
|
|
52
|
+
set name(value: string) {
|
|
53
|
+
if (value) {
|
|
54
|
+
this.setAttribute("name", value);
|
|
55
|
+
} else {
|
|
56
|
+
this.removeAttribute("name");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
@property() get value() {
|
|
60
|
+
return this.getAttribute("value");
|
|
61
|
+
}
|
|
62
|
+
set value(value: string | null) {
|
|
63
|
+
if (value !== null && value !== undefined) {
|
|
64
|
+
this.setAttribute("value", value);
|
|
65
|
+
} else {
|
|
66
|
+
this.removeAttribute("value");
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@property() type: FormSubmitterType = "button";
|
|
71
|
+
|
|
72
|
+
override connectedCallback(): void {
|
|
73
|
+
super.connectedCallback();
|
|
74
|
+
this.addEventListener("click", this[_clickHandler]);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
override disconnectedCallback(): void {
|
|
78
|
+
super.disconnectedCallback();
|
|
79
|
+
this.removeEventListener("click", this[_clickHandler]);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
private [_clickHandler] = async (e: Event) => {
|
|
83
|
+
if ((isDisabledMixin(this) && this.disabled) || (isDisabledInteractiveMixin(this) && this.disabledInteractive)) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const form = this[internals].form;
|
|
88
|
+
if (!form || this.type === "button") {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
await new Promise<void>((resolve) => setTimeout(resolve));
|
|
93
|
+
|
|
94
|
+
if (e.defaultPrevented) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
switch (this.type) {
|
|
99
|
+
case "reset":
|
|
100
|
+
form.reset();
|
|
101
|
+
break;
|
|
102
|
+
|
|
103
|
+
case "submit":
|
|
104
|
+
form.addEventListener(
|
|
105
|
+
"submit",
|
|
106
|
+
(e) =>
|
|
107
|
+
Object.defineProperty(e, "submitter", {
|
|
108
|
+
configurable: true,
|
|
109
|
+
enumerable: true,
|
|
110
|
+
get: () => this,
|
|
111
|
+
}),
|
|
112
|
+
{ capture: true, once: true }
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
this[internals].setFormValue(this.value);
|
|
116
|
+
form.requestSubmit();
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return _FormSubmitterMixin;
|
|
123
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { LitElement, PropertyValues } from "lit";
|
|
2
|
+
import { property } from "lit/decorators.js";
|
|
3
|
+
|
|
4
|
+
import { Constructor } from "./Constructor";
|
|
5
|
+
import { hasKeys } from "./hasKeys";
|
|
6
|
+
|
|
7
|
+
/** Defines functionality for an attached element associated with an interactive control. */
|
|
8
|
+
export interface HtmlForMixin {
|
|
9
|
+
/** The identifier of the interactive control to which this element is attached. */
|
|
10
|
+
htmlFor: string | null;
|
|
11
|
+
|
|
12
|
+
/** The interactive element to which this element is attached. */
|
|
13
|
+
readonly control: HTMLElement | null;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Attaches the element to an interactive control.
|
|
17
|
+
* @param {HTMLElement} control The element that controls the attachable element.
|
|
18
|
+
*/
|
|
19
|
+
attach(control: HTMLElement): void;
|
|
20
|
+
|
|
21
|
+
/** Detaches the element from its current interactive control. */
|
|
22
|
+
detach(): void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Determines whether a value is a `HtmlForMixin`.
|
|
27
|
+
* @param {unknown} value The value to test.
|
|
28
|
+
* @returns {value is HtmlForMixin} Whether `value` is a `HtmlForMixin`.
|
|
29
|
+
*/
|
|
30
|
+
export function isHtmlForMixin(value: unknown): value is HtmlForMixin {
|
|
31
|
+
return hasKeys<HtmlForMixin>(value, "htmlFor", "control", "attach", "detach");
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const _control = Symbol("_control");
|
|
35
|
+
const _firstUpdated = Symbol("_firstUpdated");
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Mixin that creates an attached element associated with an interactive control.
|
|
39
|
+
* @template T The type of the base class.
|
|
40
|
+
* @param {T} base The base class.
|
|
41
|
+
* @returns {Constructor<HtmlForMixin> & T} A constructor extends `base` and implements `HtmlForMixin`.
|
|
42
|
+
*/
|
|
43
|
+
export function HtmlFor<T extends Constructor<LitElement>>(base: T): Constructor<HtmlForMixin> & T {
|
|
44
|
+
abstract class _HtmlForMixin extends base implements HtmlForMixin {
|
|
45
|
+
/** @private */ private [_control]: HTMLElement | null = null;
|
|
46
|
+
/** @private */ private [_firstUpdated] = false;
|
|
47
|
+
|
|
48
|
+
@property({ attribute: "for" }) htmlFor: string | null = null;
|
|
49
|
+
|
|
50
|
+
get control() {
|
|
51
|
+
return this[_control];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
protected override firstUpdated(_changedProperties: PropertyValues): void {
|
|
55
|
+
super.firstUpdated(_changedProperties);
|
|
56
|
+
this[_firstUpdated] = true;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
protected override update(changedProperties: PropertyValues<this>): void {
|
|
60
|
+
super.update(changedProperties);
|
|
61
|
+
|
|
62
|
+
if (changedProperties.has("htmlFor")) {
|
|
63
|
+
if (this.htmlFor) {
|
|
64
|
+
const control = (this.getRootNode() as ParentNode)?.querySelector(`#${this.htmlFor}`);
|
|
65
|
+
if (control !== this.control) {
|
|
66
|
+
if (this.control) {
|
|
67
|
+
this.detach();
|
|
68
|
+
}
|
|
69
|
+
if (control instanceof HTMLElement) {
|
|
70
|
+
this.attach(control);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
} else if (this.control && this[_firstUpdated]) {
|
|
74
|
+
this.detach();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
attach(control: HTMLElement): void {
|
|
80
|
+
this[_control] = control;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
detach(): void {
|
|
84
|
+
this[_control] = null;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return _HtmlForMixin;
|
|
89
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
|
|
3
|
+
import { Constructor } from "./Constructor";
|
|
4
|
+
import { isDisabledMixin } from "./Disabled";
|
|
5
|
+
import { isDisabledInteractiveMixin } from "./DisabledInteractive";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Mixin to augment an element with behavior emits a click event on keyboard events.
|
|
9
|
+
* @template T The type of the base class.
|
|
10
|
+
* @param {T} base The base class.
|
|
11
|
+
* @param {boolean} [allowEnter=true] Whether the `ENTER` key emits a click event.
|
|
12
|
+
* @returns {T} A class that extends `base` with keyboard click behavior.
|
|
13
|
+
*/
|
|
14
|
+
export function KeyboardClick<T extends Constructor<LitElement>>(base: T, allowEnter: boolean = true): T {
|
|
15
|
+
abstract class _KeyboardClickMixin extends base {
|
|
16
|
+
readonly #keyUpHandler = (e: KeyboardEvent) => this.#handleKeyUp(e);
|
|
17
|
+
|
|
18
|
+
override connectedCallback(): void {
|
|
19
|
+
super.connectedCallback();
|
|
20
|
+
this.addEventListener("keyup", this.#keyUpHandler);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
override disconnectedCallback(): void {
|
|
24
|
+
super.disconnectedCallback();
|
|
25
|
+
this.removeEventListener("keyup", this.#keyUpHandler);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
#handleKeyUp(e: KeyboardEvent): void {
|
|
29
|
+
if ((isDisabledMixin(this) && this.disabled) || (isDisabledInteractiveMixin(this) && this.disabledInteractive)) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (e.key === " " || (allowEnter && e.key === "Enter")) {
|
|
34
|
+
// NOTE: the dispatched click event will not be trusted since it is synthetic.
|
|
35
|
+
this.dispatchEvent(
|
|
36
|
+
new MouseEvent("click", {
|
|
37
|
+
cancelable: true,
|
|
38
|
+
bubbles: true,
|
|
39
|
+
composed: true,
|
|
40
|
+
})
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return _KeyboardClickMixin;
|
|
46
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { LitElement, PropertyValues } from "lit";
|
|
2
|
+
|
|
3
|
+
import { DesignToken } from "../tokens";
|
|
4
|
+
|
|
5
|
+
import { AttachInternalsMixin, internals, isAttachInternalsMixin } from "./AttachInternals";
|
|
6
|
+
import { Constructor } from "./Constructor";
|
|
7
|
+
import { isDisabledMixin } from "./Disabled";
|
|
8
|
+
import { isDisabledInteractiveMixin } from "./DisabledInteractive";
|
|
9
|
+
import { isTouchedMixin } from "./Touched";
|
|
10
|
+
import { hasKeys } from "./hasKeys";
|
|
11
|
+
|
|
12
|
+
/** Defines functionality for a labelled custom element. */
|
|
13
|
+
export interface LabelledMixin extends AttachInternalsMixin {
|
|
14
|
+
/** The label elements that the element is associated with. */
|
|
15
|
+
readonly labels: NodeListOf<HTMLLabelElement>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Determines whether a value is a `LabelledMixin`.
|
|
20
|
+
* @param {unknown} value The value to test.
|
|
21
|
+
* @returns A value indicating whether `value` is a `LabelledMixin`.
|
|
22
|
+
*/
|
|
23
|
+
export function isLabelledMixin(value: unknown): value is LabelledMixin {
|
|
24
|
+
return hasKeys<LabelledMixin>(value, "labels") && isAttachInternalsMixin(value);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const _updateLabels = Symbol("_updateLabels");
|
|
28
|
+
const _eventHandler = Symbol("_eventHandler");
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Mixin to augment an element with support for labelling.
|
|
32
|
+
* @template T The type of the base class.
|
|
33
|
+
* @param {T} base The base class.
|
|
34
|
+
* @returns {Constructor<FormAssociatedMixin> & T} A constructor that implements `FormAssociatedMixin`.
|
|
35
|
+
*/
|
|
36
|
+
export function Labelled<T extends Constructor<LitElement & AttachInternalsMixin>>(
|
|
37
|
+
base: T
|
|
38
|
+
): Constructor<LabelledMixin> & T {
|
|
39
|
+
abstract class _Labelled extends base implements LabelledMixin {
|
|
40
|
+
static readonly formAssociated = true;
|
|
41
|
+
|
|
42
|
+
private readonly [_eventHandler] = (e: Event) => {
|
|
43
|
+
if (!e.defaultPrevented) {
|
|
44
|
+
this[_updateLabels]();
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
get labels(): NodeListOf<HTMLLabelElement> {
|
|
49
|
+
return this[internals].labels as NodeListOf<HTMLLabelElement>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
override connectedCallback(): void {
|
|
53
|
+
super.connectedCallback();
|
|
54
|
+
this.addEventListener("focusout", this[_eventHandler]);
|
|
55
|
+
this.addEventListener("change", this[_eventHandler]);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
override disconnectedCallback(): void {
|
|
59
|
+
super.disconnectedCallback();
|
|
60
|
+
this.removeEventListener("focusout", this[_eventHandler]);
|
|
61
|
+
this.removeEventListener("change", this[_eventHandler]);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
protected override update(changedProperties: PropertyValues): void {
|
|
65
|
+
super.update(changedProperties);
|
|
66
|
+
this[_updateLabels]();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
private [_updateLabels](): void {
|
|
70
|
+
const focusable = this.hasAttribute("tabindex");
|
|
71
|
+
const disabled =
|
|
72
|
+
(isDisabledMixin(this) && this.disabled) || (isDisabledInteractiveMixin(this) && this.disabledInteractive);
|
|
73
|
+
|
|
74
|
+
for (const label of this.labels) {
|
|
75
|
+
label.style.userSelect = focusable ? "none" : "";
|
|
76
|
+
label.style.cursor = !disabled ? "pointer" : "";
|
|
77
|
+
|
|
78
|
+
label.style.color = disabled
|
|
79
|
+
? `color-mix(in srgb, ${DesignToken.color.onSurface} 38%, transparent)`
|
|
80
|
+
: isTouchedMixin(this) && this.touched && this.ariaInvalid
|
|
81
|
+
? `${DesignToken.color.error}`
|
|
82
|
+
: "";
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return _Labelled;
|
|
88
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { html, LitElement, nothing } from "lit";
|
|
2
|
+
import { property } from "lit/decorators.js";
|
|
3
|
+
import { ifDefined } from "lit/directives/if-defined.js";
|
|
4
|
+
|
|
5
|
+
import { Constructor } from "./Constructor";
|
|
6
|
+
import { isDisabledInteractiveMixin } from "./DisabledInteractive";
|
|
7
|
+
import { isDisabledMixin } from "./Disabled";
|
|
8
|
+
import { hasKeys } from "./hasKeys";
|
|
9
|
+
|
|
10
|
+
/** A symbol through which to access a function used to render a pseudo link. */
|
|
11
|
+
export const renderPseudoLink = Symbol("renderPseudoLink");
|
|
12
|
+
|
|
13
|
+
/** Specifies the possible targets for a link. */
|
|
14
|
+
export type LinkTarget = "_self" | "_blank" | "_parent" | "_top" | (string & {});
|
|
15
|
+
|
|
16
|
+
/** Defines functionality for an interactive element that functions as a link. */
|
|
17
|
+
export interface LinkButtonMixin {
|
|
18
|
+
/** The URL to which the link button points. */
|
|
19
|
+
href: string;
|
|
20
|
+
|
|
21
|
+
/** The target of the link button. */
|
|
22
|
+
target: LinkTarget;
|
|
23
|
+
|
|
24
|
+
/** The relationship between the `target` of the link button and the document. */
|
|
25
|
+
rel: string;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* A value indicating whether the `target` of the link button will be downloaded,
|
|
29
|
+
* optionally specifying the new name of the file.
|
|
30
|
+
*/
|
|
31
|
+
download: string | null;
|
|
32
|
+
|
|
33
|
+
/** Function used to render a pseudo link. */
|
|
34
|
+
[renderPseudoLink](): unknown;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Determines whether a value is a `LinkButtonMixin`.
|
|
39
|
+
* @param {unknown} value The value to test.
|
|
40
|
+
* @returns {value is LinkButtonMixin} Whether `value` is a `LinkButtonMixin`.
|
|
41
|
+
*/
|
|
42
|
+
export function isLinkButtonMixin(value: unknown): value is LinkButtonMixin {
|
|
43
|
+
return hasKeys<LinkButtonMixin>(value, "download", "href", "rel", "target");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const _clickHandler = Symbol("_clickHandler");
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Mixin to augment an element with behavior that supports functioning as a link.
|
|
50
|
+
* @template T The type of the base class.
|
|
51
|
+
* @param {T} base The base class.
|
|
52
|
+
* @returns {Constructor<LinkButtonMixin>} A constructor that implements `LinkButtonMixin`.
|
|
53
|
+
*/
|
|
54
|
+
export function LinkButton<T extends Constructor<LitElement>>(base: T): Constructor<LinkButtonMixin> & T {
|
|
55
|
+
abstract class _LinkButtonMixin extends base implements LinkButtonMixin {
|
|
56
|
+
private [_clickHandler] = async (e: Event) => {
|
|
57
|
+
if (isDisabledInteractiveMixin(this) && this.disabledInteractive) {
|
|
58
|
+
e.preventDefault();
|
|
59
|
+
e.stopPropagation();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
await new Promise<void>((resolve) => resolve());
|
|
63
|
+
if (e.defaultPrevented) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (this.href) {
|
|
68
|
+
e.preventDefault();
|
|
69
|
+
e.stopImmediatePropagation();
|
|
70
|
+
|
|
71
|
+
const link = document.createElement("a");
|
|
72
|
+
link.href = this.href;
|
|
73
|
+
link.rel = this.rel;
|
|
74
|
+
link.target = this.target;
|
|
75
|
+
if (this.download != null) {
|
|
76
|
+
link.download = this.download;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
link.addEventListener("click", async () => {
|
|
80
|
+
await new Promise<void>((resolve) => resolve());
|
|
81
|
+
link.remove();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
document.body.appendChild(link);
|
|
85
|
+
link.click();
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
@property() href = "";
|
|
90
|
+
@property() target: LinkTarget = "";
|
|
91
|
+
@property() rel = "";
|
|
92
|
+
|
|
93
|
+
@property({ reflect: false }) get download(): string | null {
|
|
94
|
+
return this.getAttribute("download");
|
|
95
|
+
}
|
|
96
|
+
set download(value: string | null) {
|
|
97
|
+
const old = this.download;
|
|
98
|
+
if (old !== value) {
|
|
99
|
+
if (value) {
|
|
100
|
+
this.setAttribute("download", value);
|
|
101
|
+
} else {
|
|
102
|
+
this.removeAttribute("download");
|
|
103
|
+
}
|
|
104
|
+
this.requestUpdate("download", old);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
override connectedCallback(): void {
|
|
109
|
+
super.connectedCallback();
|
|
110
|
+
this.addEventListener("click", this[_clickHandler]);
|
|
111
|
+
|
|
112
|
+
if (this.hasAttribute("href") && this.role === "button") {
|
|
113
|
+
this.role = "link";
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
override disconnectedCallback(): void {
|
|
118
|
+
super.disconnectedCallback();
|
|
119
|
+
this.removeEventListener("click", this[_clickHandler]);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
[renderPseudoLink](): unknown {
|
|
123
|
+
const disabled = isDisabledMixin(this) && this.disabled;
|
|
124
|
+
const disabledInteractive = isDisabledInteractiveMixin(this) && this.disabledInteractive;
|
|
125
|
+
|
|
126
|
+
return !disabled && !disabledInteractive && this.href
|
|
127
|
+
? html`<a
|
|
128
|
+
href="${this.href}"
|
|
129
|
+
target="${ifDefined(this.target || undefined)}"
|
|
130
|
+
rel="${ifDefined(this.rel || undefined)}"
|
|
131
|
+
download="${ifDefined(this.download || undefined)}"
|
|
132
|
+
tabindex="-1"
|
|
133
|
+
aria-hidden="true"
|
|
134
|
+
@pointerdown="${this.#handleLinkPointerDown}"
|
|
135
|
+
@focus="${this.#handleLinkFocus}"
|
|
136
|
+
@blur="${this.#handleLinkBlur}"
|
|
137
|
+
></a>`
|
|
138
|
+
: nothing;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
#handleLinkPointerDown(e: PointerEvent): void {
|
|
142
|
+
if (e.button !== 2) {
|
|
143
|
+
e.preventDefault();
|
|
144
|
+
e.stopImmediatePropagation();
|
|
145
|
+
|
|
146
|
+
this.dispatchEvent(
|
|
147
|
+
new MouseEvent("click", {
|
|
148
|
+
bubbles: true,
|
|
149
|
+
cancelable: true,
|
|
150
|
+
view: window,
|
|
151
|
+
})
|
|
152
|
+
);
|
|
153
|
+
} else {
|
|
154
|
+
(e.target as HTMLLinkElement).removeAttribute("aria-hidden");
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
#handleLinkFocus(e: Event): void {
|
|
159
|
+
(e.target as HTMLLinkElement).blur();
|
|
160
|
+
this.focus();
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
#handleLinkBlur(e: Event): void {
|
|
164
|
+
(e.target as HTMLLinkElement).setAttribute("aria-hidden", "true");
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return _LinkButtonMixin;
|
|
169
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { LitElement, PropertyValues } from "lit";
|
|
2
|
+
import { property } from "lit/decorators.js";
|
|
3
|
+
|
|
4
|
+
import { Constructor } from "./Constructor";
|
|
5
|
+
import { hasKeys } from "./hasKeys";
|
|
6
|
+
|
|
7
|
+
/** Defines functionality for an element which supports a read-only state. */
|
|
8
|
+
export interface ReadOnlyMixin {
|
|
9
|
+
/**
|
|
10
|
+
* A value indicating whether the element is read-only.
|
|
11
|
+
* @default false
|
|
12
|
+
*/
|
|
13
|
+
readOnly: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Determines whether a value is a `ReadOnlyMixin`.
|
|
18
|
+
* @param {unknown} value The value to test.
|
|
19
|
+
* @returns A value indicating whether `value` is a `ReadOnlyMixin`.
|
|
20
|
+
*/
|
|
21
|
+
export function isReadOnlyMixin(value: unknown): value is ReadOnlyMixin {
|
|
22
|
+
return hasKeys<ReadOnlyMixin>(value, "readOnly");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Mixin to augment an element with behavior that supports a read-only state.
|
|
27
|
+
* @template T The type of the base class.
|
|
28
|
+
* @param {T} base The base class.
|
|
29
|
+
* @param {boolean} reflect A value indicating whether the read-only state is reflected as an attribute. The default value is `true`.
|
|
30
|
+
* @returns {Constructor<ReadOnlyMixin> & T} A constructor that implements `ReadOnlyMixin`.
|
|
31
|
+
*/
|
|
32
|
+
export function ReadOnly<T extends Constructor<LitElement>>(
|
|
33
|
+
base: T,
|
|
34
|
+
reflect: boolean = true
|
|
35
|
+
): Constructor<ReadOnlyMixin> & T {
|
|
36
|
+
abstract class _ReadOnlyMixin extends base implements ReadOnlyMixin {
|
|
37
|
+
@property({ attribute: "readonly", type: Boolean, reflect: reflect }) readOnly = false;
|
|
38
|
+
|
|
39
|
+
protected override update(changedProperties: PropertyValues<this>): void {
|
|
40
|
+
super.update(changedProperties);
|
|
41
|
+
|
|
42
|
+
if (changedProperties.has("readOnly")) {
|
|
43
|
+
this.ariaReadOnly = this.readOnly ? "true" : null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return _ReadOnlyMixin;
|
|
48
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { LitElement, PropertyValues } from "lit";
|
|
2
|
+
import { property } from "lit/decorators.js";
|
|
3
|
+
|
|
4
|
+
import { Constructor } from "./Constructor";
|
|
5
|
+
import { hasKeys } from "./hasKeys";
|
|
6
|
+
|
|
7
|
+
/** Defines functionality for an element which supports a required state. */
|
|
8
|
+
export interface RequiredMixin {
|
|
9
|
+
/**
|
|
10
|
+
* Whether a value is required for the element.
|
|
11
|
+
* @default false
|
|
12
|
+
*/
|
|
13
|
+
required: boolean;
|
|
14
|
+
|
|
15
|
+
/** Whether a value is not required for the element. */
|
|
16
|
+
readonly optional: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Determines whether a value is a `RequiredMixin`.
|
|
21
|
+
* @param {unknown} value The value to test.
|
|
22
|
+
* @returns A value indicating whether `value` is a `RequiredMixin`.
|
|
23
|
+
*/
|
|
24
|
+
export function isRequiredMixin(value: unknown): value is RequiredMixin {
|
|
25
|
+
return hasKeys<RequiredMixin>(value, "required", "optional");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Mixin to augment an element with behavior that supports a required state.
|
|
30
|
+
* @template T The type of the base class.
|
|
31
|
+
* @param {T} base The base class.
|
|
32
|
+
* @returns {Constructor<RequiredMixin> & T} A constructor that implements `RequiredMixin`.
|
|
33
|
+
*/
|
|
34
|
+
export function Required<T extends Constructor<LitElement>>(base: T): Constructor<RequiredMixin> & T {
|
|
35
|
+
abstract class _RequiredMixin extends base implements RequiredMixin {
|
|
36
|
+
@property({ type: Boolean, reflect: true }) required = false;
|
|
37
|
+
|
|
38
|
+
get optional() {
|
|
39
|
+
return !this.required;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
protected override update(changedProperties: PropertyValues<this>): void {
|
|
43
|
+
super.update(changedProperties);
|
|
44
|
+
if (changedProperties.has("required")) {
|
|
45
|
+
this.ariaRequired = `${this.required}`;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return _RequiredMixin;
|
|
50
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
|
|
3
|
+
import { Constructor } from "./Constructor";
|
|
4
|
+
import { ConstraintValidationMixin, isConstraintValidationMixin, validate } from "./ConstraintValidation";
|
|
5
|
+
import { isCheckedMixin } from "./Checked";
|
|
6
|
+
import { isRequiredMixin, RequiredMixin } from "./Required";
|
|
7
|
+
|
|
8
|
+
/** Defines functionality for an element which supports validating a required state. */
|
|
9
|
+
export interface RequiredConstraintValidationMixin extends RequiredMixin, ConstraintValidationMixin {}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Determines whether a value is a `RequiredConstraintValidationMixin`.
|
|
13
|
+
* @param {unknown} value The value to test.
|
|
14
|
+
* @returns A value indicating whether `value` is a `RequiredConstraintValidationMixin`.
|
|
15
|
+
*/
|
|
16
|
+
export function isRequiredConstraintValidationMixin(value: unknown): value is RequiredConstraintValidationMixin {
|
|
17
|
+
return isRequiredMixin(value) && isConstraintValidationMixin(value);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Mixin to augment an element with behavior that supports a required state.
|
|
22
|
+
* @template T The type of the base class.
|
|
23
|
+
* @param {T} base The base class.
|
|
24
|
+
* @returns {Constructor<RequiredConstraintValidationMixin> & T} A constructor that implements `RequiredConstraintValidationMixin`.
|
|
25
|
+
*/
|
|
26
|
+
export function RequiredConstraintValidation<
|
|
27
|
+
T extends Constructor<LitElement & RequiredMixin & ConstraintValidationMixin>
|
|
28
|
+
>(base: T): Constructor<RequiredConstraintValidationMixin> & T {
|
|
29
|
+
abstract class _RequiredConstraintValidation extends base implements RequiredConstraintValidationMixin {
|
|
30
|
+
override [validate](): ValidityStateFlags | undefined {
|
|
31
|
+
const validity = super[validate]();
|
|
32
|
+
if (!validity && this.required) {
|
|
33
|
+
if (isCheckedMixin(this) && !this.checked) {
|
|
34
|
+
return { valueMissing: true };
|
|
35
|
+
}
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
|
+
if (!(<any>this).value) {
|
|
38
|
+
return { valueMissing: true };
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return validity;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return _RequiredConstraintValidation;
|
|
45
|
+
}
|