@m3e/core 1.0.0-rc.1 → 1.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -2
- package/dist/a11y.js +6 -18
- package/dist/a11y.js.map +1 -1
- package/dist/a11y.min.js +5 -5
- package/dist/a11y.min.js.map +1 -1
- package/dist/custom-elements.json +3449 -3429
- package/dist/html-custom-data.json +14 -6
- package/dist/index.js +198 -29
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +87 -87
- package/dist/index.min.js.map +1 -1
- package/package.json +1 -1
- package/cem.config.mjs +0 -16
- package/demo/index.html +0 -58
- package/dist/src/a11y/AriaDescriber.d.ts +0 -31
- package/dist/src/a11y/AriaDescriber.d.ts.map +0 -1
- package/dist/src/a11y/FocusTrapElement.d.ts +0 -25
- package/dist/src/a11y/FocusTrapElement.d.ts.map +0 -1
- package/dist/src/a11y/InteractivityChecker.d.ts +0 -22
- package/dist/src/a11y/InteractivityChecker.d.ts.map +0 -1
- package/dist/src/a11y/LiveAnnouncer.d.ts +0 -56
- package/dist/src/a11y/LiveAnnouncer.d.ts.map +0 -1
- package/dist/src/a11y/aria-reference.d.ts +0 -30
- package/dist/src/a11y/aria-reference.d.ts.map +0 -1
- package/dist/src/a11y/index.d.ts +0 -8
- package/dist/src/a11y/index.d.ts.map +0 -1
- package/dist/src/a11y/keycodes/KeyCode.d.ts +0 -118
- package/dist/src/a11y/keycodes/KeyCode.d.ts.map +0 -1
- package/dist/src/a11y/keycodes/ModifierKeys.d.ts +0 -5
- package/dist/src/a11y/keycodes/ModifierKeys.d.ts.map +0 -1
- package/dist/src/a11y/keycodes/getKeyCode.d.ts +0 -7
- package/dist/src/a11y/keycodes/getKeyCode.d.ts.map +0 -1
- package/dist/src/a11y/keycodes/hasModifierKey.d.ts +0 -9
- package/dist/src/a11y/keycodes/hasModifierKey.d.ts.map +0 -1
- package/dist/src/a11y/keycodes/index.d.ts +0 -6
- package/dist/src/a11y/keycodes/index.d.ts.map +0 -1
- package/dist/src/a11y/keycodes/isModifierAllowed.d.ts +0 -9
- package/dist/src/a11y/keycodes/isModifierAllowed.d.ts.map +0 -1
- package/dist/src/a11y/list-key/FocusKeyManager.d.ts +0 -17
- package/dist/src/a11y/list-key/FocusKeyManager.d.ts.map +0 -1
- package/dist/src/a11y/list-key/ListKeyManager.d.ts +0 -114
- package/dist/src/a11y/list-key/ListKeyManager.d.ts.map +0 -1
- package/dist/src/a11y/list-key/ListManager.d.ts +0 -37
- package/dist/src/a11y/list-key/ListManager.d.ts.map +0 -1
- package/dist/src/a11y/list-key/RadioKeyManager.d.ts +0 -20
- package/dist/src/a11y/list-key/RadioKeyManager.d.ts.map +0 -1
- package/dist/src/a11y/list-key/RovingTabIndexManager.d.ts +0 -22
- package/dist/src/a11y/list-key/RovingTabIndexManager.d.ts.map +0 -1
- package/dist/src/a11y/list-key/SelectionManager.d.ts +0 -46
- package/dist/src/a11y/list-key/SelectionManager.d.ts.map +0 -1
- package/dist/src/a11y/list-key/Typeahead.d.ts +0 -64
- package/dist/src/a11y/list-key/Typeahead.d.ts.map +0 -1
- package/dist/src/a11y/list-key/index.d.ts +0 -8
- package/dist/src/a11y/list-key/index.d.ts.map +0 -1
- package/dist/src/a11y/visuallyHide.d.ts +0 -6
- package/dist/src/a11y/visuallyHide.d.ts.map +0 -1
- package/dist/src/anchoring/AnchorOptions.d.ts +0 -15
- package/dist/src/anchoring/AnchorOptions.d.ts.map +0 -1
- package/dist/src/anchoring/AnchorPosition.d.ts +0 -3
- package/dist/src/anchoring/AnchorPosition.d.ts.map +0 -1
- package/dist/src/anchoring/index.d.ts +0 -4
- package/dist/src/anchoring/index.d.ts.map +0 -1
- package/dist/src/anchoring/positionAnchor.d.ts +0 -12
- package/dist/src/anchoring/positionAnchor.d.ts.map +0 -1
- package/dist/src/bidi/Directionality.d.ts +0 -27
- package/dist/src/bidi/Directionality.d.ts.map +0 -1
- package/dist/src/bidi/index.d.ts +0 -2
- package/dist/src/bidi/index.d.ts.map +0 -1
- package/dist/src/index.d.ts +0 -2
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/layout/Breakpoint.d.ts +0 -26
- package/dist/src/layout/Breakpoint.d.ts.map +0 -1
- package/dist/src/layout/BreakpointObserver.d.ts +0 -18
- package/dist/src/layout/BreakpointObserver.d.ts.map +0 -1
- package/dist/src/layout/index.d.ts +0 -3
- package/dist/src/layout/index.d.ts.map +0 -1
- package/dist/src/platform/Platform.d.ts +0 -34
- package/dist/src/platform/Platform.d.ts.map +0 -1
- package/dist/src/platform/index.d.ts +0 -2
- package/dist/src/platform/index.d.ts.map +0 -1
- package/dist/src/shared/controllers/FocusController.d.ts +0 -30
- package/dist/src/shared/controllers/FocusController.d.ts.map +0 -1
- package/dist/src/shared/controllers/HoverController.d.ts +0 -40
- package/dist/src/shared/controllers/HoverController.d.ts.map +0 -1
- package/dist/src/shared/controllers/IntersectionController.d.ts +0 -40
- package/dist/src/shared/controllers/IntersectionController.d.ts.map +0 -1
- package/dist/src/shared/controllers/LongPressController.d.ts +0 -32
- package/dist/src/shared/controllers/LongPressController.d.ts.map +0 -1
- package/dist/src/shared/controllers/MonitorControllerBase.d.ts +0 -62
- package/dist/src/shared/controllers/MonitorControllerBase.d.ts.map +0 -1
- package/dist/src/shared/controllers/MutationController.d.ts +0 -37
- package/dist/src/shared/controllers/MutationController.d.ts.map +0 -1
- package/dist/src/shared/controllers/PressedController.d.ts +0 -45
- package/dist/src/shared/controllers/PressedController.d.ts.map +0 -1
- package/dist/src/shared/controllers/ResizeController.d.ts +0 -40
- package/dist/src/shared/controllers/ResizeController.d.ts.map +0 -1
- package/dist/src/shared/controllers/ScrollController.d.ts +0 -34
- package/dist/src/shared/controllers/ScrollController.d.ts.map +0 -1
- package/dist/src/shared/controllers/index.d.ts +0 -9
- package/dist/src/shared/controllers/index.d.ts.map +0 -1
- package/dist/src/shared/decorators/debounce.d.ts +0 -7
- package/dist/src/shared/decorators/debounce.d.ts.map +0 -1
- package/dist/src/shared/decorators/index.d.ts +0 -2
- package/dist/src/shared/decorators/index.d.ts.map +0 -1
- package/dist/src/shared/directives/index.d.ts +0 -2
- package/dist/src/shared/directives/index.d.ts.map +0 -1
- package/dist/src/shared/directives/safeStyleMap.d.ts +0 -44
- package/dist/src/shared/directives/safeStyleMap.d.ts.map +0 -1
- package/dist/src/shared/index.d.ts +0 -8
- package/dist/src/shared/index.d.ts.map +0 -1
- package/dist/src/shared/mixins/AttachInternals.d.ts +0 -24
- package/dist/src/shared/mixins/AttachInternals.d.ts.map +0 -1
- package/dist/src/shared/mixins/Checked.d.ts +0 -24
- package/dist/src/shared/mixins/Checked.d.ts.map +0 -1
- package/dist/src/shared/mixins/CheckedIndeterminate.d.ts +0 -25
- package/dist/src/shared/mixins/CheckedIndeterminate.d.ts.map +0 -1
- package/dist/src/shared/mixins/CheckedOrSelected.d.ts +0 -23
- package/dist/src/shared/mixins/CheckedOrSelected.d.ts.map +0 -1
- package/dist/src/shared/mixins/ConstraintValidation.d.ts +0 -48
- package/dist/src/shared/mixins/ConstraintValidation.d.ts.map +0 -1
- package/dist/src/shared/mixins/Constructor.d.ts +0 -3
- package/dist/src/shared/mixins/Constructor.d.ts.map +0 -1
- package/dist/src/shared/mixins/Dirty.d.ts +0 -27
- package/dist/src/shared/mixins/Dirty.d.ts.map +0 -1
- package/dist/src/shared/mixins/Disabled.d.ts +0 -25
- package/dist/src/shared/mixins/Disabled.d.ts.map +0 -1
- package/dist/src/shared/mixins/DisabledInteractive.d.ts +0 -25
- package/dist/src/shared/mixins/DisabledInteractive.d.ts.map +0 -1
- package/dist/src/shared/mixins/EventAttribute.d.ts +0 -11
- package/dist/src/shared/mixins/EventAttribute.d.ts.map +0 -1
- package/dist/src/shared/mixins/Focusable.d.ts +0 -11
- package/dist/src/shared/mixins/Focusable.d.ts.map +0 -1
- package/dist/src/shared/mixins/FormAssociated.d.ts +0 -34
- package/dist/src/shared/mixins/FormAssociated.d.ts.map +0 -1
- package/dist/src/shared/mixins/FormSubmitter.d.ts +0 -31
- package/dist/src/shared/mixins/FormSubmitter.d.ts.map +0 -1
- package/dist/src/shared/mixins/HtmlFor.d.ts +0 -30
- package/dist/src/shared/mixins/HtmlFor.d.ts.map +0 -1
- package/dist/src/shared/mixins/KeyboardClick.d.ts +0 -11
- package/dist/src/shared/mixins/KeyboardClick.d.ts.map +0 -1
- package/dist/src/shared/mixins/Labelled.d.ts +0 -22
- package/dist/src/shared/mixins/Labelled.d.ts.map +0 -1
- package/dist/src/shared/mixins/LinkButton.d.ts +0 -36
- package/dist/src/shared/mixins/LinkButton.d.ts.map +0 -1
- package/dist/src/shared/mixins/ReadOnly.d.ts +0 -25
- package/dist/src/shared/mixins/ReadOnly.d.ts.map +0 -1
- package/dist/src/shared/mixins/Required.d.ts +0 -26
- package/dist/src/shared/mixins/Required.d.ts.map +0 -1
- package/dist/src/shared/mixins/RequiredConstraintValidation.d.ts +0 -21
- package/dist/src/shared/mixins/RequiredConstraintValidation.d.ts.map +0 -1
- package/dist/src/shared/mixins/Role.d.ts +0 -13
- package/dist/src/shared/mixins/Role.d.ts.map +0 -1
- package/dist/src/shared/mixins/Selected.d.ts +0 -24
- package/dist/src/shared/mixins/Selected.d.ts.map +0 -1
- package/dist/src/shared/mixins/Touched.d.ts +0 -27
- package/dist/src/shared/mixins/Touched.d.ts.map +0 -1
- package/dist/src/shared/mixins/Vertical.d.ts +0 -24
- package/dist/src/shared/mixins/Vertical.d.ts.map +0 -1
- package/dist/src/shared/mixins/hasKeys.d.ts +0 -9
- package/dist/src/shared/mixins/hasKeys.d.ts.map +0 -1
- package/dist/src/shared/mixins/index.d.ts +0 -25
- package/dist/src/shared/mixins/index.d.ts.map +0 -1
- package/dist/src/shared/primitives/CollapsibleElement.d.ts +0 -58
- package/dist/src/shared/primitives/CollapsibleElement.d.ts.map +0 -1
- package/dist/src/shared/primitives/ElevationElement.d.ts +0 -88
- package/dist/src/shared/primitives/ElevationElement.d.ts.map +0 -1
- package/dist/src/shared/primitives/ElevationLevel.d.ts +0 -3
- package/dist/src/shared/primitives/ElevationLevel.d.ts.map +0 -1
- package/dist/src/shared/primitives/ElevationToken.d.ts +0 -15
- package/dist/src/shared/primitives/ElevationToken.d.ts.map +0 -1
- package/dist/src/shared/primitives/FocusRingElement.d.ts +0 -78
- package/dist/src/shared/primitives/FocusRingElement.d.ts.map +0 -1
- package/dist/src/shared/primitives/FocusRingToken.d.ts +0 -17
- package/dist/src/shared/primitives/FocusRingToken.d.ts.map +0 -1
- package/dist/src/shared/primitives/PseudoCheckboxElement.d.ts +0 -50
- package/dist/src/shared/primitives/PseudoCheckboxElement.d.ts.map +0 -1
- package/dist/src/shared/primitives/PseudoRadioElement.d.ts +0 -41
- package/dist/src/shared/primitives/PseudoRadioElement.d.ts.map +0 -1
- package/dist/src/shared/primitives/RippleElement.d.ts +0 -110
- package/dist/src/shared/primitives/RippleElement.d.ts.map +0 -1
- package/dist/src/shared/primitives/RippleToken.d.ts +0 -12
- package/dist/src/shared/primitives/RippleToken.d.ts.map +0 -1
- package/dist/src/shared/primitives/ScrollContainerElement.d.ts +0 -64
- package/dist/src/shared/primitives/ScrollContainerElement.d.ts.map +0 -1
- package/dist/src/shared/primitives/ScrollDividers.d.ts +0 -3
- package/dist/src/shared/primitives/ScrollDividers.d.ts.map +0 -1
- package/dist/src/shared/primitives/SlideElement.d.ts +0 -48
- package/dist/src/shared/primitives/SlideElement.d.ts.map +0 -1
- package/dist/src/shared/primitives/StateLayerElement.d.ts +0 -77
- package/dist/src/shared/primitives/StateLayerElement.d.ts.map +0 -1
- package/dist/src/shared/primitives/StateLayerToken.d.ts +0 -13
- package/dist/src/shared/primitives/StateLayerToken.d.ts.map +0 -1
- package/dist/src/shared/primitives/TextOverflowElement.d.ts +0 -39
- package/dist/src/shared/primitives/TextOverflowElement.d.ts.map +0 -1
- package/dist/src/shared/primitives/index.d.ts +0 -13
- package/dist/src/shared/primitives/index.d.ts.map +0 -1
- package/dist/src/shared/tokens/ColorToken.d.ts +0 -96
- package/dist/src/shared/tokens/ColorToken.d.ts.map +0 -1
- package/dist/src/shared/tokens/DensityToken.d.ts +0 -15
- package/dist/src/shared/tokens/DensityToken.d.ts.map +0 -1
- package/dist/src/shared/tokens/DesignToken.d.ts +0 -366
- package/dist/src/shared/tokens/DesignToken.d.ts.map +0 -1
- package/dist/src/shared/tokens/ElevationToken.d.ts +0 -16
- package/dist/src/shared/tokens/ElevationToken.d.ts.map +0 -1
- package/dist/src/shared/tokens/MotionToken.d.ts +0 -69
- package/dist/src/shared/tokens/MotionToken.d.ts.map +0 -1
- package/dist/src/shared/tokens/ScrollbarToken.d.ts +0 -10
- package/dist/src/shared/tokens/ScrollbarToken.d.ts.map +0 -1
- package/dist/src/shared/tokens/ShapeToken.d.ts +0 -79
- package/dist/src/shared/tokens/ShapeToken.d.ts.map +0 -1
- package/dist/src/shared/tokens/StateToken.d.ts +0 -10
- package/dist/src/shared/tokens/StateToken.d.ts.map +0 -1
- package/dist/src/shared/tokens/TypescaleToken.d.ts +0 -220
- package/dist/src/shared/tokens/TypescaleToken.d.ts.map +0 -1
- package/dist/src/shared/tokens/index.d.ts +0 -2
- package/dist/src/shared/tokens/index.d.ts.map +0 -1
- package/dist/src/shared/utils/getTextContent.d.ts +0 -8
- package/dist/src/shared/utils/getTextContent.d.ts.map +0 -1
- package/dist/src/shared/utils/guid.d.ts +0 -6
- package/dist/src/shared/utils/guid.d.ts.map +0 -1
- package/dist/src/shared/utils/hasAssignedNodes.d.ts +0 -7
- package/dist/src/shared/utils/hasAssignedNodes.d.ts.map +0 -1
- package/dist/src/shared/utils/index.d.ts +0 -6
- package/dist/src/shared/utils/index.d.ts.map +0 -1
- package/dist/src/shared/utils/prefersReducedMotion.d.ts +0 -6
- package/dist/src/shared/utils/prefersReducedMotion.d.ts.map +0 -1
- package/dist/src/shared/utils/scrollIntoViewIfNeeded.d.ts +0 -8
- package/dist/src/shared/utils/scrollIntoViewIfNeeded.d.ts.map +0 -1
- package/eslint.config.mjs +0 -21
- package/rollup.config.js +0 -132
- package/src/a11y/AriaDescriber.ts +0 -130
- package/src/a11y/FocusTrapElement.ts +0 -136
- package/src/a11y/InteractivityChecker.ts +0 -62
- package/src/a11y/LiveAnnouncer.ts +0 -143
- package/src/a11y/aria-reference.ts +0 -51
- package/src/a11y/index.ts +0 -8
- package/src/a11y/keycodes/KeyCode.ts +0 -128
- package/src/a11y/keycodes/ModifierKeys.ts +0 -5
- package/src/a11y/keycodes/getKeyCode.ts +0 -8
- package/src/a11y/keycodes/hasModifierKey.ts +0 -11
- package/src/a11y/keycodes/index.ts +0 -5
- package/src/a11y/keycodes/isModifierAllowed.ts +0 -12
- package/src/a11y/list-key/FocusKeyManager.ts +0 -25
- package/src/a11y/list-key/ListKeyManager.ts +0 -350
- package/src/a11y/list-key/ListManager.ts +0 -66
- package/src/a11y/list-key/RadioKeyManager.ts +0 -49
- package/src/a11y/list-key/RovingTabIndexManager.ts +0 -56
- package/src/a11y/list-key/SelectionManager.ts +0 -132
- package/src/a11y/list-key/Typeahead.ts +0 -131
- package/src/a11y/list-key/index.ts +0 -7
- package/src/a11y/visuallyHide.ts +0 -18
- package/src/anchoring/AnchorOptions.ts +0 -19
- package/src/anchoring/AnchorPosition.ts +0 -14
- package/src/anchoring/index.ts +0 -3
- package/src/anchoring/positionAnchor.ts +0 -53
- package/src/bidi/Directionality.ts +0 -85
- package/src/bidi/index.ts +0 -1
- package/src/index.ts +0 -1
- package/src/layout/Breakpoint.ts +0 -26
- package/src/layout/BreakpointObserver.ts +0 -44
- package/src/layout/index.ts +0 -2
- package/src/platform/Platform.ts +0 -67
- package/src/platform/index.ts +0 -1
- package/src/shared/controllers/FocusController.ts +0 -60
- package/src/shared/controllers/HoverController.ts +0 -140
- package/src/shared/controllers/IntersectionController.ts +0 -81
- package/src/shared/controllers/LongPressController.ts +0 -87
- package/src/shared/controllers/MonitorControllerBase.ts +0 -99
- package/src/shared/controllers/MutationController.ts +0 -89
- package/src/shared/controllers/PressedController.ts +0 -137
- package/src/shared/controllers/ResizeController.ts +0 -83
- package/src/shared/controllers/ScrollController.ts +0 -100
- package/src/shared/controllers/index.ts +0 -8
- package/src/shared/decorators/debounce.ts +0 -19
- package/src/shared/decorators/index.ts +0 -1
- package/src/shared/directives/index.ts +0 -1
- package/src/shared/directives/safeStyleMap.ts +0 -108
- package/src/shared/index.ts +0 -7
- package/src/shared/mixins/AttachInternals.ts +0 -48
- package/src/shared/mixins/Checked.ts +0 -50
- package/src/shared/mixins/CheckedIndeterminate.ts +0 -47
- package/src/shared/mixins/CheckedOrSelected.ts +0 -36
- package/src/shared/mixins/ConstraintValidation.ts +0 -213
- package/src/shared/mixins/Constructor.ts +0 -2
- package/src/shared/mixins/Dirty.ts +0 -71
- package/src/shared/mixins/Disabled.ts +0 -49
- package/src/shared/mixins/DisabledInteractive.ts +0 -78
- package/src/shared/mixins/EventAttribute.ts +0 -25
- package/src/shared/mixins/Focusable.ts +0 -52
- package/src/shared/mixins/FormAssociated.ts +0 -152
- package/src/shared/mixins/FormSubmitter.ts +0 -123
- package/src/shared/mixins/HtmlFor.ts +0 -89
- package/src/shared/mixins/KeyboardClick.ts +0 -46
- package/src/shared/mixins/Labelled.ts +0 -88
- package/src/shared/mixins/LinkButton.ts +0 -169
- package/src/shared/mixins/ReadOnly.ts +0 -48
- package/src/shared/mixins/Required.ts +0 -50
- package/src/shared/mixins/RequiredConstraintValidation.ts +0 -45
- package/src/shared/mixins/Role.ts +0 -134
- package/src/shared/mixins/Selected.ts +0 -50
- package/src/shared/mixins/Touched.ts +0 -71
- package/src/shared/mixins/Vertical.ts +0 -44
- package/src/shared/mixins/hasKeys.ts +0 -10
- package/src/shared/mixins/index.ts +0 -24
- package/src/shared/primitives/CollapsibleElement.ts +0 -227
- package/src/shared/primitives/ElevationElement.ts +0 -254
- package/src/shared/primitives/ElevationLevel.ts +0 -2
- package/src/shared/primitives/ElevationToken.ts +0 -18
- package/src/shared/primitives/FocusRingElement.ts +0 -199
- package/src/shared/primitives/FocusRingToken.ts +0 -24
- package/src/shared/primitives/PseudoCheckboxElement.ts +0 -116
- package/src/shared/primitives/PseudoRadioElement.ts +0 -83
- package/src/shared/primitives/RippleElement.ts +0 -289
- package/src/shared/primitives/RippleToken.ts +0 -15
- package/src/shared/primitives/ScrollContainerElement.ts +0 -151
- package/src/shared/primitives/ScrollDividers.ts +0 -2
- package/src/shared/primitives/SlideElement.ts +0 -128
- package/src/shared/primitives/StateLayerElement.ts +0 -191
- package/src/shared/primitives/StateLayerToken.ts +0 -16
- package/src/shared/primitives/TextOverflowElement.ts +0 -60
- package/src/shared/primitives/index.ts +0 -12
- package/src/shared/tokens/ColorToken.ts +0 -142
- package/src/shared/tokens/DensityToken.ts +0 -23
- package/src/shared/tokens/DesignToken.ts +0 -35
- package/src/shared/tokens/ElevationToken.ts +0 -115
- package/src/shared/tokens/MotionToken.ts +0 -107
- package/src/shared/tokens/ScrollbarToken.ts +0 -13
- package/src/shared/tokens/ShapeToken.ts +0 -138
- package/src/shared/tokens/StateToken.ts +0 -13
- package/src/shared/tokens/TypescaleToken.ts +0 -230
- package/src/shared/tokens/index.ts +0 -1
- package/src/shared/utils/getTextContent.ts +0 -31
- package/src/shared/utils/guid.ts +0 -11
- package/src/shared/utils/hasAssignedNodes.ts +0 -8
- package/src/shared/utils/index.ts +0 -5
- package/src/shared/utils/prefersReducedMotion.ts +0 -9
- package/src/shared/utils/scrollIntoViewIfNeeded.ts +0 -18
- package/tsconfig.json +0 -9
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
import { LitElement, PropertyDeclaration, PropertyValues, isServer } from "lit";
|
|
2
|
-
|
|
3
|
-
import { internals } from "./AttachInternals";
|
|
4
|
-
import { Constructor } from "./Constructor";
|
|
5
|
-
import { FormAssociatedMixin, isFormAssociatedMixin } from "./FormAssociated";
|
|
6
|
-
import { hasKeys } from "./hasKeys";
|
|
7
|
-
import { isTouchedMixin } from "./Touched";
|
|
8
|
-
|
|
9
|
-
/** A symbol through which a "Form Associated" custom element validates its current state. */
|
|
10
|
-
export const validate = Symbol("validate");
|
|
11
|
-
|
|
12
|
-
/** Defines functionality for a "Form Associated" custom element that supports constraint validation. */
|
|
13
|
-
export interface ConstraintValidationMixin extends FormAssociatedMixin {
|
|
14
|
-
/** Whether the element is a submittable element that is a candidate for constraint validation. */
|
|
15
|
-
readonly willValidate: boolean;
|
|
16
|
-
|
|
17
|
-
/** The validity state of the element. */
|
|
18
|
-
readonly validity: ValidityState;
|
|
19
|
-
|
|
20
|
-
/** The error message that would be displayed if the user submits the form, or an empty string if no error message. */
|
|
21
|
-
readonly validationMessage: string;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Validates the current state of the control.
|
|
25
|
-
* @returns {ValidityStateFlags | undefined} The current validity state.
|
|
26
|
-
*/
|
|
27
|
-
[validate](): ValidityStateFlags | undefined;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Returns `true` if the element has no validity problems; otherwise, returns `false`, fires
|
|
31
|
-
* an invalid event, and (if the event isn't canceled) reports the problem to the user.
|
|
32
|
-
*/
|
|
33
|
-
reportValidity(): boolean;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Returns `true` if the element has no validity problems; otherwise,
|
|
37
|
-
* returns `false`, fires an invalid event.
|
|
38
|
-
*/
|
|
39
|
-
checkValidity(): boolean;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Sets a custom validity message for the element.
|
|
43
|
-
* @param error The message to use for validity errors.
|
|
44
|
-
*/
|
|
45
|
-
setCustomValidity(error: string): void;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Determines whether a value is a `ConstraintValidationMixin`.
|
|
50
|
-
* @param {unknown} value The value to test.
|
|
51
|
-
* @returns Whether `value` is a `ConstraintValidationMixin`.
|
|
52
|
-
*/
|
|
53
|
-
export function isConstraintValidationMixin(value: unknown): value is ConstraintValidationMixin {
|
|
54
|
-
return (
|
|
55
|
-
hasKeys<ConstraintValidationMixin>(
|
|
56
|
-
value,
|
|
57
|
-
"willValidate",
|
|
58
|
-
"validity",
|
|
59
|
-
"validationMessage",
|
|
60
|
-
"reportValidity",
|
|
61
|
-
"checkValidity",
|
|
62
|
-
"setCustomValidity"
|
|
63
|
-
) && isFormAssociatedMixin(value)
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const _updateValidity = Symbol("_updateValidity");
|
|
68
|
-
const _validityMessage = Symbol("_validityMessage");
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Mixin to augment an element with "Form Associated" behavior that supports constraint validation.
|
|
72
|
-
* @template T The type of the base class.
|
|
73
|
-
* @param {T} base The base class.
|
|
74
|
-
* @returns {Constructor<ConstraintValidationMixin> & T} A constructor that implements `ConstraintValidationMixin`.
|
|
75
|
-
*/
|
|
76
|
-
export function ConstraintValidation<T extends Constructor<LitElement & FormAssociatedMixin>>(
|
|
77
|
-
base: T
|
|
78
|
-
): Constructor<ConstraintValidationMixin> & T {
|
|
79
|
-
abstract class _ConstraintValidation extends base implements ConstraintValidationMixin {
|
|
80
|
-
private [_validityMessage]?: string;
|
|
81
|
-
|
|
82
|
-
get willValidate(): boolean {
|
|
83
|
-
return this[internals].willValidate;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
get validity(): ValidityState {
|
|
87
|
-
this[_updateValidity]();
|
|
88
|
-
return this[internals].validity;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
get validationMessage(): string {
|
|
92
|
-
this[_updateValidity]();
|
|
93
|
-
return this[internals].validationMessage;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
[validate](): ValidityStateFlags | undefined {
|
|
97
|
-
return this[_validityMessage] ? { customError: true } : undefined;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
reportValidity(): boolean {
|
|
101
|
-
if (isTouchedMixin(this)) {
|
|
102
|
-
this.markAsTouched();
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
this[_updateValidity]();
|
|
106
|
-
return this[internals].reportValidity();
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
checkValidity(): boolean {
|
|
110
|
-
this[_updateValidity]();
|
|
111
|
-
return this[internals].checkValidity();
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
setCustomValidity(error: string): void {
|
|
115
|
-
if (error) {
|
|
116
|
-
this[_validityMessage] = error;
|
|
117
|
-
} else {
|
|
118
|
-
this[_validityMessage] = undefined;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
this[_updateValidity]();
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
override requestUpdate(name?: PropertyKey, oldValue?: unknown, options?: PropertyDeclaration): void {
|
|
125
|
-
super.requestUpdate(name, oldValue, options);
|
|
126
|
-
this[_updateValidity]();
|
|
127
|
-
}
|
|
128
|
-
protected override firstUpdated(_changedProperties: PropertyValues): void {
|
|
129
|
-
super.firstUpdated(_changedProperties);
|
|
130
|
-
this[_updateValidity]();
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
private [_updateValidity](): void {
|
|
134
|
-
if (isServer || !this.isConnected) return;
|
|
135
|
-
|
|
136
|
-
const validity = this[validate]();
|
|
137
|
-
const invalid = validity && Object.keys(validity).some((x) => validity[<keyof ValidityStateFlags>x] === true);
|
|
138
|
-
|
|
139
|
-
let validityMessage = validity?.customError ? this[_validityMessage] : "";
|
|
140
|
-
if (validity && !validityMessage) {
|
|
141
|
-
validityMessage = this.#getNativeMessage(validity);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
this[internals].setValidity(validity, validityMessage);
|
|
145
|
-
this.ariaInvalid = invalid ? "true" : null;
|
|
146
|
-
this.classList.toggle("-invalid", invalid === true);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/** @private */
|
|
150
|
-
#getNativeMessage(flags: ValidityStateFlags): string {
|
|
151
|
-
const input = document.createElement("input");
|
|
152
|
-
|
|
153
|
-
// Default to text input unless overridden
|
|
154
|
-
input.type = "text";
|
|
155
|
-
|
|
156
|
-
// Simulate constraints and values based on flags
|
|
157
|
-
if (flags.valueMissing) {
|
|
158
|
-
input.required = true;
|
|
159
|
-
input.value = ""; // triggers valueMissing
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
if (flags.typeMismatch) {
|
|
163
|
-
input.type = "email";
|
|
164
|
-
input.value = "not-an-email"; // triggers typeMismatch
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
if (flags.patternMismatch) {
|
|
168
|
-
input.pattern = "[0-9]{4}";
|
|
169
|
-
input.value = "abcd"; // triggers patternMismatch
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
if (flags.tooShort) {
|
|
173
|
-
input.minLength = 5;
|
|
174
|
-
input.value = "abc"; // triggers tooShort
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
if (flags.tooLong) {
|
|
178
|
-
input.maxLength = 2;
|
|
179
|
-
input.value = "abcdef"; // triggers tooLong
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
if (flags.rangeUnderflow) {
|
|
183
|
-
input.type = "number";
|
|
184
|
-
input.min = "10";
|
|
185
|
-
input.value = "5"; // triggers rangeUnderflow
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
if (flags.rangeOverflow) {
|
|
189
|
-
input.type = "number";
|
|
190
|
-
input.max = "5";
|
|
191
|
-
input.value = "10"; // triggers rangeOverflow
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
if (flags.stepMismatch) {
|
|
195
|
-
input.type = "number";
|
|
196
|
-
input.step = "2";
|
|
197
|
-
input.value = "3"; // triggers stepMismatch
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
if (flags.badInput) {
|
|
201
|
-
input.type = "number";
|
|
202
|
-
input.value = "abc"; // triggers badInput
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
input.setCustomValidity("");
|
|
206
|
-
input.checkValidity();
|
|
207
|
-
|
|
208
|
-
return input.validationMessage;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
return _ConstraintValidation;
|
|
213
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { LitElement } from "lit";
|
|
2
|
-
|
|
3
|
-
import { Constructor } from "./Constructor";
|
|
4
|
-
import { hasKeys } from "./hasKeys";
|
|
5
|
-
|
|
6
|
-
/** Defines functionality for an element that can be marked as dirty. */
|
|
7
|
-
export interface DirtyMixin {
|
|
8
|
-
/** Whether the user has not modified the value of the element. */
|
|
9
|
-
readonly pristine: boolean;
|
|
10
|
-
|
|
11
|
-
/** Whether the user has modified the value of the element. */
|
|
12
|
-
readonly dirty: boolean;
|
|
13
|
-
|
|
14
|
-
/** Marks the element as pristine. */
|
|
15
|
-
markAsPristine(): void;
|
|
16
|
-
|
|
17
|
-
/** Marks the element as dirty. */
|
|
18
|
-
markAsDirty(): void;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Determines whether a value is a `DirtyMixin`.
|
|
23
|
-
* @param {unknown} value The value to test.
|
|
24
|
-
* @returns A value indicating whether `value` is a `DirtyMixin`.
|
|
25
|
-
*/
|
|
26
|
-
export function isDirtyMixin(value: unknown): value is DirtyMixin {
|
|
27
|
-
return hasKeys<DirtyMixin>(value, "dirty", "pristine", "markAsDirty", "markAsPristine");
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const _eventHandler = Symbol("_eventHandler");
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Mixin to augment an element with functionality used to mark it as dirty.
|
|
34
|
-
* @template T The type of the base class.
|
|
35
|
-
* @param {T} base The base class.
|
|
36
|
-
* @returns {Constructor<DirtyMixin> & T} A constructor that implements `DirtyMixin`.
|
|
37
|
-
*/
|
|
38
|
-
export function Dirty<T extends Constructor<LitElement>>(base: T): Constructor<DirtyMixin> & T {
|
|
39
|
-
abstract class _Dirty extends base implements DirtyMixin {
|
|
40
|
-
private [_eventHandler] = () => this.markAsDirty();
|
|
41
|
-
|
|
42
|
-
get dirty(): boolean {
|
|
43
|
-
return this.classList.contains("-dirty");
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
get pristine(): boolean {
|
|
47
|
-
return !this.dirty;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
override connectedCallback(): void {
|
|
51
|
-
this.markAsPristine();
|
|
52
|
-
super.connectedCallback();
|
|
53
|
-
this.addEventListener("change", this[_eventHandler]);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
override disconnectedCallback(): void {
|
|
57
|
-
super.disconnectedCallback();
|
|
58
|
-
this.removeEventListener("change", this[_eventHandler]);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
markAsPristine(): void {
|
|
62
|
-
this.classList.toggle("-dirty", false);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
markAsDirty(): void {
|
|
66
|
-
this.classList.toggle("-dirty", true);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return _Dirty;
|
|
71
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
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 disabled state. */
|
|
8
|
-
export interface DisabledMixin {
|
|
9
|
-
/**
|
|
10
|
-
* Whether the element is disabled.
|
|
11
|
-
* @default false
|
|
12
|
-
*/
|
|
13
|
-
disabled: boolean;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Determines whether a value is a `DisabledMixin`.
|
|
18
|
-
* @param {unknown} value The value to test.
|
|
19
|
-
* @returns {value is DisabledMixin} Whether `value` is a `DisabledMixin`.
|
|
20
|
-
*/
|
|
21
|
-
export function isDisabledMixin(value: unknown): value is DisabledMixin {
|
|
22
|
-
return hasKeys<DisabledMixin>(value, "disabled");
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Mixin to augment an element with behavior that supports a disabled state.
|
|
27
|
-
* @template T The type of the base class.
|
|
28
|
-
* @param {T} base The base class.
|
|
29
|
-
* @param {boolean} [reflect=true] Whether the disabled property is reflected as an attribute.
|
|
30
|
-
* @returns {Constructor<DisabledMixin> & T} A constructor that implements `DisabledMixin`.
|
|
31
|
-
*/
|
|
32
|
-
export function Disabled<T extends Constructor<LitElement>>(
|
|
33
|
-
base: T,
|
|
34
|
-
reflect: boolean = true
|
|
35
|
-
): Constructor<DisabledMixin> & T {
|
|
36
|
-
abstract class _DisabledMixin extends base implements DisabledMixin {
|
|
37
|
-
@property({ type: Boolean, reflect: reflect }) disabled = false;
|
|
38
|
-
|
|
39
|
-
protected override update(changedProperties: PropertyValues<this>): void {
|
|
40
|
-
super.update(changedProperties);
|
|
41
|
-
|
|
42
|
-
if (changedProperties.has("disabled") && this.role && this.role !== "none" && this.role !== "presentation") {
|
|
43
|
-
this.ariaDisabled = this.disabled ? "true" : null;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return _DisabledMixin;
|
|
49
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { LitElement, PropertyValues } from "lit";
|
|
2
|
-
import { property } from "lit/decorators.js";
|
|
3
|
-
|
|
4
|
-
import { Constructor } from "./Constructor";
|
|
5
|
-
import { DisabledMixin, isDisabledMixin } from "./Disabled";
|
|
6
|
-
import { hasKeys } from "./hasKeys";
|
|
7
|
-
|
|
8
|
-
/** Defines functionality for an element which supports an interactive disabled state. */
|
|
9
|
-
export interface DisabledInteractiveMixin extends DisabledMixin {
|
|
10
|
-
/**
|
|
11
|
-
* Whether the element is disabled and interactive.
|
|
12
|
-
* @default false
|
|
13
|
-
*/
|
|
14
|
-
disabledInteractive: boolean;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Determines whether a value is a `DisabledInteractiveMixin`.
|
|
19
|
-
* @param {unknown} value The value to test.
|
|
20
|
-
* @returns {value is DisabledInteractiveMixin} Whether `value` is a `DisabledInteractiveMixin`.
|
|
21
|
-
*/
|
|
22
|
-
export function isDisabledInteractiveMixin(value: unknown): value is DisabledInteractiveMixin {
|
|
23
|
-
return hasKeys<DisabledInteractiveMixin>(value, "disabledInteractive") && isDisabledMixin(value);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const SUPPRESSED_EVENTS = ["click", "dblclick", "auxclick", "keydown", "keyup"];
|
|
27
|
-
const INTERACTIVE_KEYS = ["Tab", "ArrowLeft", "ArrowUp", "ArrowRight", "ArrowDown", "Left", "Up", "Right", "Down"];
|
|
28
|
-
const _suppressedEventHandler = Symbol("_suppressedEventHandler");
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Mixin to augment an element with behavior that supports an interactive disabled state.
|
|
32
|
-
* @template T The type of the base class.
|
|
33
|
-
* @param {T} base The base class.
|
|
34
|
-
* @returns {Constructor<DisabledInteractiveMixin>} A constructor that implements `DisabledInteractiveMixin`.
|
|
35
|
-
*/
|
|
36
|
-
export function DisabledInteractive<T extends Constructor<LitElement & DisabledMixin>>(
|
|
37
|
-
base: T
|
|
38
|
-
): Constructor<DisabledInteractiveMixin> & T {
|
|
39
|
-
abstract class _DisabledInteractiveMixin extends base implements DisabledInteractiveMixin {
|
|
40
|
-
private readonly [_suppressedEventHandler] = (e: Event) => {
|
|
41
|
-
if (this.disabledInteractive) {
|
|
42
|
-
// Only allow specific keys when disabled and interactive.
|
|
43
|
-
if (e instanceof KeyboardEvent && INTERACTIVE_KEYS.includes(e.key)) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
e.stopImmediatePropagation();
|
|
47
|
-
e.preventDefault();
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
@property({ attribute: "disabled-interactive", type: Boolean, reflect: true }) disabledInteractive = false;
|
|
51
|
-
|
|
52
|
-
override connectedCallback(): void {
|
|
53
|
-
SUPPRESSED_EVENTS.forEach((x) => this.addEventListener(x, this[_suppressedEventHandler], true));
|
|
54
|
-
super.connectedCallback();
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
override disconnectedCallback(): void {
|
|
58
|
-
SUPPRESSED_EVENTS.forEach((x) => this.removeEventListener(x, this[_suppressedEventHandler], true));
|
|
59
|
-
super.disconnectedCallback();
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
protected override update(changedProperties: PropertyValues<this>): void {
|
|
63
|
-
super.update(changedProperties);
|
|
64
|
-
|
|
65
|
-
if (
|
|
66
|
-
(changedProperties.has("disabled") || changedProperties.has("disabledInteractive")) &&
|
|
67
|
-
this.role &&
|
|
68
|
-
this.role !== "none" &&
|
|
69
|
-
this.role !== "presentation" &&
|
|
70
|
-
this.role !== "none"
|
|
71
|
-
) {
|
|
72
|
-
this.ariaDisabled = this.disabled || this.disabledInteractive ? "true" : null;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return _DisabledInteractiveMixin;
|
|
78
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { LitElement } from "lit";
|
|
2
|
-
|
|
3
|
-
import { Constructor } from "./Constructor";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Mixin that adds support for custom event attributes.
|
|
7
|
-
* @template T The type of base class from which to inherit.
|
|
8
|
-
* @param {T} base The base class from which to inherit.
|
|
9
|
-
* @param {string[]} types The types of event attributes.
|
|
10
|
-
* @returns {T} A class extending `base` that supports custom event attributes.
|
|
11
|
-
*/
|
|
12
|
-
export function EventAttribute<T extends Constructor<LitElement>>(base: T, ...types: string[]): T {
|
|
13
|
-
abstract class _EventAttribute extends base {
|
|
14
|
-
override dispatchEvent(event: Event): boolean {
|
|
15
|
-
if (types.includes(event.type)) {
|
|
16
|
-
const eventAttribute = this.getAttribute(`on${event.type}`);
|
|
17
|
-
if (eventAttribute) {
|
|
18
|
-
new Function("e", `${eventAttribute};`).call(this, event);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return super.dispatchEvent(event);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return _EventAttribute;
|
|
25
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { LitElement, PropertyValues } from "lit";
|
|
2
|
-
|
|
3
|
-
import { Constructor } from "./Constructor";
|
|
4
|
-
import { DisabledMixin } from "./Disabled";
|
|
5
|
-
|
|
6
|
-
const _tabindex = Symbol("_tabindex");
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Mixin to augment an element with behavior that supports a focused state.
|
|
10
|
-
* @template T The type of the base class.
|
|
11
|
-
* @param {T} base The base class.
|
|
12
|
-
* @returns {Constructor & T} A constructor that implements focusable behavior.
|
|
13
|
-
*/
|
|
14
|
-
export function Focusable<T extends Constructor<LitElement & DisabledMixin>>(base: T): Constructor & T {
|
|
15
|
-
abstract class _FocusableMixin extends base {
|
|
16
|
-
private [_tabindex] = 0;
|
|
17
|
-
|
|
18
|
-
/** @inheritdoc */
|
|
19
|
-
override connectedCallback(): void {
|
|
20
|
-
this[_tabindex] = Number.parseInt(this.getAttribute("tabindex") ?? "0");
|
|
21
|
-
super.connectedCallback();
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
protected override firstUpdated(_changedProperties: PropertyValues<this>): void {
|
|
25
|
-
super.firstUpdated(_changedProperties);
|
|
26
|
-
|
|
27
|
-
if (!this.hasAttribute("tabindex") && !_changedProperties.has("disabled")) {
|
|
28
|
-
this.setAttribute("tabindex", `${this[_tabindex]}`);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
protected override update(changedProperties: PropertyValues<this>): void {
|
|
33
|
-
super.update(changedProperties);
|
|
34
|
-
|
|
35
|
-
if (changedProperties.has("disabled")) {
|
|
36
|
-
if (!this.disabled && this.role !== "none") {
|
|
37
|
-
if (!this.hasAttribute("tabindex")) {
|
|
38
|
-
this.setAttribute("tabindex", `${this[_tabindex]}`);
|
|
39
|
-
}
|
|
40
|
-
} else {
|
|
41
|
-
const tabIndex = this.getAttribute("tabindex");
|
|
42
|
-
if (tabIndex) {
|
|
43
|
-
this[_tabindex] = Number.parseInt(tabIndex);
|
|
44
|
-
}
|
|
45
|
-
this.removeAttribute("tabindex");
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return _FocusableMixin;
|
|
52
|
-
}
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { LitElement, PropertyDeclaration } from "lit";
|
|
2
|
-
import { property } from "lit/decorators.js";
|
|
3
|
-
|
|
4
|
-
import { AttachInternalsMixin, internals, isAttachInternalsMixin } from "./AttachInternals";
|
|
5
|
-
import { Constructor } from "./Constructor";
|
|
6
|
-
import { DisabledMixin } from "./Disabled";
|
|
7
|
-
import { isCheckedMixin } from "./Checked";
|
|
8
|
-
import { isCheckedIndeterminateMixin } from "./CheckedIndeterminate";
|
|
9
|
-
import { isDirtyMixin } from "./Dirty";
|
|
10
|
-
import { isTouchedMixin } from "./Touched";
|
|
11
|
-
import { isLabelledMixin, LabelledMixin } from "./Labelled";
|
|
12
|
-
import { hasKeys } from "./hasKeys";
|
|
13
|
-
|
|
14
|
-
/** A symbol through which a "Form Associated" custom element provides a value for a form. */
|
|
15
|
-
export const formValue = Symbol("formValue");
|
|
16
|
-
|
|
17
|
-
/** A symbol through which a "Form Associated" custom element provides a default value for resetting a form. */
|
|
18
|
-
export const defaultValue = Symbol("defaultValue");
|
|
19
|
-
|
|
20
|
-
/** Defines functionality for a "Form Associated" custom element. */
|
|
21
|
-
export interface FormAssociatedMixin extends LabelledMixin, DisabledMixin, AttachInternalsMixin {
|
|
22
|
-
/** The `HTMLFormElement` associated with this element. */
|
|
23
|
-
readonly form: HTMLFormElement | null;
|
|
24
|
-
|
|
25
|
-
/** The form value of the element. */
|
|
26
|
-
readonly [formValue]: string | File | FormData | null;
|
|
27
|
-
|
|
28
|
-
/** The default value (value or checked state) of the element. */
|
|
29
|
-
readonly [defaultValue]: unknown;
|
|
30
|
-
|
|
31
|
-
/** The name that identifies the element when submitting the associated form. */
|
|
32
|
-
name: string;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Determines whether a value is a `FormAssociatedMixin`.
|
|
37
|
-
* @param {unknown} value The value to test.
|
|
38
|
-
* @returns A value indicating whether `value` is a `FormAssociatedMixin`.
|
|
39
|
-
*/
|
|
40
|
-
export function isFormAssociatedMixin(value: unknown): value is FormAssociatedMixin {
|
|
41
|
-
return (
|
|
42
|
-
hasKeys<FormAssociatedMixin>(value, "disabled", "form", "name") &&
|
|
43
|
-
isLabelledMixin(value) &&
|
|
44
|
-
isAttachInternalsMixin(value)
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const _defaultValue = Symbol("_defaultValue");
|
|
49
|
-
const _defaultIndeterminate = Symbol("_defaultIndeterminate");
|
|
50
|
-
const _formDisabled = Symbol("_formDisabled");
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Mixin to augment an element with "Form Associated" behavior.
|
|
54
|
-
* @template T The type of the base class.
|
|
55
|
-
* @param {T} base The base class.
|
|
56
|
-
* @returns {Constructor<FormAssociatedMixin> & T} A constructor that implements `FormAssociatedMixin`.
|
|
57
|
-
*/
|
|
58
|
-
export function FormAssociated<T extends Constructor<LitElement & DisabledMixin & AttachInternalsMixin>>(
|
|
59
|
-
base: T
|
|
60
|
-
): Constructor<FormAssociatedMixin> & T {
|
|
61
|
-
abstract class _FormAssociatedMixin extends base implements FormAssociatedMixin {
|
|
62
|
-
static readonly formAssociated = true;
|
|
63
|
-
private [_defaultValue]: unknown;
|
|
64
|
-
private [_defaultIndeterminate] = false;
|
|
65
|
-
private [_formDisabled] = false;
|
|
66
|
-
|
|
67
|
-
get form(): HTMLFormElement | null {
|
|
68
|
-
return this[internals].form;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
get labels(): NodeListOf<HTMLLabelElement> {
|
|
72
|
-
return this[internals].labels as NodeListOf<HTMLLabelElement>;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
get [formValue](): string | File | FormData | null {
|
|
76
|
-
return null;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
get [defaultValue](): unknown {
|
|
80
|
-
return this[_defaultValue];
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
@property({ noAccessor: true }) get name() {
|
|
84
|
-
return this.getAttribute("name") ?? "";
|
|
85
|
-
}
|
|
86
|
-
set name(value: string) {
|
|
87
|
-
if (value) {
|
|
88
|
-
this.setAttribute("name", value);
|
|
89
|
-
} else {
|
|
90
|
-
this.removeAttribute("name");
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// Disabled attributes should not be reflected for form associated elements due to
|
|
95
|
-
// how the formDisabledCallback overrides an element's disabled state.
|
|
96
|
-
// See https://github.com/whatwg/html/issues/8365
|
|
97
|
-
|
|
98
|
-
@property({ type: Boolean })
|
|
99
|
-
override get disabled(): boolean {
|
|
100
|
-
return super.disabled || this[_formDisabled];
|
|
101
|
-
}
|
|
102
|
-
override set disabled(value: boolean) {
|
|
103
|
-
super.disabled = value;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
override connectedCallback(): void {
|
|
107
|
-
super.connectedCallback();
|
|
108
|
-
|
|
109
|
-
if (isCheckedMixin(this)) {
|
|
110
|
-
this[_defaultValue] = this.checked;
|
|
111
|
-
if (isCheckedIndeterminateMixin(this)) {
|
|
112
|
-
this[_defaultIndeterminate] = this.indeterminate;
|
|
113
|
-
}
|
|
114
|
-
} else if ("value" in this) {
|
|
115
|
-
this[_defaultValue] = this.value;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
override requestUpdate(name?: PropertyKey, oldValue?: unknown, options?: PropertyDeclaration): void {
|
|
120
|
-
super.requestUpdate(name, oldValue, options);
|
|
121
|
-
this[internals].setFormValue(this[formValue]);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
formDisabledCallback(disabled: boolean): void {
|
|
125
|
-
const wasDisabled = this.disabled;
|
|
126
|
-
this[_formDisabled] = disabled;
|
|
127
|
-
if (this.disabled != wasDisabled) {
|
|
128
|
-
this.requestUpdate("disabled", wasDisabled);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
formResetCallback(): void {
|
|
133
|
-
if (isCheckedMixin(this)) {
|
|
134
|
-
this.checked = this[_defaultValue] === true;
|
|
135
|
-
if (isCheckedIndeterminateMixin(this)) {
|
|
136
|
-
this.indeterminate = this[_defaultIndeterminate];
|
|
137
|
-
}
|
|
138
|
-
} else if ("value" in this) {
|
|
139
|
-
this.value = this[defaultValue];
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if (isDirtyMixin(this)) {
|
|
143
|
-
this.markAsPristine();
|
|
144
|
-
}
|
|
145
|
-
if (isTouchedMixin(this)) {
|
|
146
|
-
this.markAsUntouched();
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
return _FormAssociatedMixin;
|
|
152
|
-
}
|