@sandlada/mdc 0.1.0-20250907.a
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 +21 -0
- package/LICENSES/LICENSE-APACHE-2.0.txt +202 -0
- package/README.md +43 -0
- package/build/all.d.ts +24 -0
- package/build/all.d.ts.map +1 -0
- package/build/all.js +1 -0
- package/build/class-map-DlMb2KKL.js +11 -0
- package/build/color-CigMJnjV.js +1 -0
- package/build/component-definitions/badge.definition.d.ts +15 -0
- package/build/component-definitions/badge.definition.d.ts.map +1 -0
- package/build/component-definitions/badge.definition.js +6 -0
- package/build/component-definitions/button.definition.d.ts +1017 -0
- package/build/component-definitions/button.definition.d.ts.map +1 -0
- package/build/component-definitions/button.definition.js +6 -0
- package/build/component-definitions/card.definition.d.ts +99 -0
- package/build/component-definitions/card.definition.d.ts.map +1 -0
- package/build/component-definitions/card.definition.js +6 -0
- package/build/component-definitions/checkbox.definition.d.ts +74 -0
- package/build/component-definitions/checkbox.definition.d.ts.map +1 -0
- package/build/component-definitions/checkbox.definition.js +6 -0
- package/build/component-definitions/dialog.definition.d.ts +74 -0
- package/build/component-definitions/dialog.definition.d.ts.map +1 -0
- package/build/component-definitions/dialog.definition.js +1 -0
- package/build/component-definitions/divider.definition.d.ts +5 -0
- package/build/component-definitions/divider.definition.d.ts.map +1 -0
- package/build/component-definitions/divider.definition.js +6 -0
- package/build/component-definitions/elevation.definition.d.ts +5 -0
- package/build/component-definitions/elevation.definition.d.ts.map +1 -0
- package/build/component-definitions/elevation.definition.js +6 -0
- package/build/component-definitions/fab.definition.d.ts +643 -0
- package/build/component-definitions/fab.definition.d.ts.map +1 -0
- package/build/component-definitions/fab.definition.js +6 -0
- package/build/component-definitions/focus-ring.definition.d.ts +13 -0
- package/build/component-definitions/focus-ring.definition.d.ts.map +1 -0
- package/build/component-definitions/focus-ring.definition.js +6 -0
- package/build/component-definitions/icon-button.definition.d.ts +718 -0
- package/build/component-definitions/icon-button.definition.d.ts.map +1 -0
- package/build/component-definitions/icon-button.definition.js +6 -0
- package/build/component-definitions/icon.definition.d.ts +10 -0
- package/build/component-definitions/icon.definition.d.ts.map +1 -0
- package/build/component-definitions/icon.definition.js +6 -0
- package/build/component-definitions/navigation-bar.definition.d.ts +36 -0
- package/build/component-definitions/navigation-bar.definition.d.ts.map +1 -0
- package/build/component-definitions/navigation-bar.definition.js +1 -0
- package/build/component-definitions/navigation-rail.definition.d.ts +37 -0
- package/build/component-definitions/navigation-rail.definition.d.ts.map +1 -0
- package/build/component-definitions/navigation-rail.definition.js +1 -0
- package/build/component-definitions/navigation-tab.definition.d.ts +337 -0
- package/build/component-definitions/navigation-tab.definition.d.ts.map +1 -0
- package/build/component-definitions/navigation-tab.definition.js +23 -0
- package/build/component-definitions/progress-indicator.definition.d.ts +52 -0
- package/build/component-definitions/progress-indicator.definition.d.ts.map +1 -0
- package/build/component-definitions/progress-indicator.definition.js +1 -0
- package/build/component-definitions/radio-button.definition.d.ts +29 -0
- package/build/component-definitions/radio-button.definition.d.ts.map +1 -0
- package/build/component-definitions/radio-button.definition.js +6 -0
- package/build/component-definitions/ripple.definition.d.ts +9 -0
- package/build/component-definitions/ripple.definition.d.ts.map +1 -0
- package/build/component-definitions/ripple.definition.js +6 -0
- package/build/component-definitions/search.definition.d.ts +47 -0
- package/build/component-definitions/search.definition.d.ts.map +1 -0
- package/build/component-definitions/search.definition.js +1 -0
- package/build/component-definitions/slider.definition.d.ts +80 -0
- package/build/component-definitions/slider.definition.d.ts.map +1 -0
- package/build/component-definitions/slider.definition.js +1 -0
- package/build/component-definitions/switch.definition.d.ts +84 -0
- package/build/component-definitions/switch.definition.d.ts.map +1 -0
- package/build/component-definitions/switch.definition.js +6 -0
- package/build/components/button/base-button.d.ts +100 -0
- package/build/components/button/base-button.d.ts.map +1 -0
- package/build/components/button/base-button.js +1 -0
- package/build/components/button/button.d.ts +34 -0
- package/build/components/button/button.d.ts.map +1 -0
- package/build/components/button/button.js +1 -0
- package/build/components/button/button.style.d.ts +2 -0
- package/build/components/button/button.style.d.ts.map +1 -0
- package/build/components/button/button.style.js +468 -0
- package/build/components/button/toggle-button.d.ts +71 -0
- package/build/components/button/toggle-button.d.ts.map +1 -0
- package/build/components/button/toggle-button.js +1 -0
- package/build/components/button-group/base-button-group.d.ts +6 -0
- package/build/components/button-group/base-button-group.d.ts.map +1 -0
- package/build/components/button-group/base-button-group.js +1 -0
- package/build/components/button-group/connected-button-group.d.ts +8 -0
- package/build/components/button-group/connected-button-group.d.ts.map +1 -0
- package/build/components/button-group/connected-button-group.js +1 -0
- package/build/components/button-group/standard-button-group.d.ts +4 -0
- package/build/components/button-group/standard-button-group.d.ts.map +1 -0
- package/build/components/button-group/standard-button-group.js +1 -0
- package/build/components/dialog/base-dialog.d.ts +42 -0
- package/build/components/dialog/base-dialog.d.ts.map +1 -0
- package/build/components/dialog/base-dialog.js +1 -0
- package/build/components/dialog/basic-dialog.d.ts +10 -0
- package/build/components/dialog/basic-dialog.d.ts.map +1 -0
- package/build/components/dialog/basic-dialog.js +1 -0
- package/build/components/dialog/dialog-action.d.ts +62 -0
- package/build/components/dialog/dialog-action.d.ts.map +1 -0
- package/build/components/dialog/dialog-action.js +1 -0
- package/build/components/dialog/dialog-animations.d.ts +48 -0
- package/build/components/dialog/dialog-animations.d.ts.map +1 -0
- package/build/components/dialog/dialog-animations.js +6 -0
- package/build/components/dialog/dialog.style.d.ts +2 -0
- package/build/components/dialog/dialog.style.d.ts.map +1 -0
- package/build/components/dialog/dialog.style.js +217 -0
- package/build/components/divider/divider.d.ts +18 -0
- package/build/components/divider/divider.d.ts.map +1 -0
- package/build/components/divider/divider.js +1 -0
- package/build/components/divider/divider.style.d.ts +2 -0
- package/build/components/divider/divider.style.d.ts.map +1 -0
- package/build/components/divider/divider.style.js +6 -0
- package/build/components/elevation/elevation.d.ts +46 -0
- package/build/components/elevation/elevation.d.ts.map +1 -0
- package/build/components/elevation/elevation.js +1 -0
- package/build/components/elevation/elevation.style.d.ts +2 -0
- package/build/components/elevation/elevation.style.d.ts.map +1 -0
- package/build/components/elevation/elevation.style.js +6 -0
- package/build/components/fab/base-extended-fab.d.ts +23 -0
- package/build/components/fab/base-extended-fab.d.ts.map +1 -0
- package/build/components/fab/base-extended-fab.js +1 -0
- package/build/components/fab/base-fab.d.ts +47 -0
- package/build/components/fab/base-fab.d.ts.map +1 -0
- package/build/components/fab/base-fab.js +1 -0
- package/build/components/fab/fab.d.ts +29 -0
- package/build/components/fab/fab.d.ts.map +1 -0
- package/build/components/fab/fab.js +1 -0
- package/build/components/fab/fab.style.d.ts +2 -0
- package/build/components/fab/fab.style.d.ts.map +1 -0
- package/build/components/fab/fab.style.js +180 -0
- package/build/components/focus-ring/focus-ring.d.ts +56 -0
- package/build/components/focus-ring/focus-ring.d.ts.map +1 -0
- package/build/components/focus-ring/focus-ring.js +1 -0
- package/build/components/focus-ring/focus-ring.style.d.ts +2 -0
- package/build/components/focus-ring/focus-ring.style.d.ts.map +1 -0
- package/build/components/focus-ring/focus-ring.style.js +108 -0
- package/build/components/icon/icon.d.ts +50 -0
- package/build/components/icon/icon.d.ts.map +1 -0
- package/build/components/icon/icon.js +1 -0
- package/build/components/icon/icon.style.d.ts +2 -0
- package/build/components/icon/icon.style.d.ts.map +1 -0
- package/build/components/icon/icon.style.js +6 -0
- package/build/components/icon-button/base-icon-button.d.ts +69 -0
- package/build/components/icon-button/base-icon-button.d.ts.map +1 -0
- package/build/components/icon-button/base-icon-button.js +1 -0
- package/build/components/icon-button/icon-button.d.ts +24 -0
- package/build/components/icon-button/icon-button.d.ts.map +1 -0
- package/build/components/icon-button/icon-button.js +1 -0
- package/build/components/icon-button/icon-button.style.d.ts +2 -0
- package/build/components/icon-button/icon-button.style.d.ts.map +1 -0
- package/build/components/icon-button/icon-button.style.js +357 -0
- package/build/components/icon-button/toggle-icon-button.d.ts +68 -0
- package/build/components/icon-button/toggle-icon-button.d.ts.map +1 -0
- package/build/components/icon-button/toggle-icon-button.js +1 -0
- package/build/components/navigation-bar/navigation-bar-animations.d.ts +21 -0
- package/build/components/navigation-bar/navigation-bar-animations.d.ts.map +1 -0
- package/build/components/navigation-bar/navigation-bar-animations.js +1 -0
- package/build/components/navigation-bar/navigation-bar.d.ts +75 -0
- package/build/components/navigation-bar/navigation-bar.d.ts.map +1 -0
- package/build/components/navigation-bar/navigation-bar.js +1 -0
- package/build/components/navigation-bar/navigation-bar.style.d.ts +2 -0
- package/build/components/navigation-bar/navigation-bar.style.d.ts.map +1 -0
- package/build/components/navigation-bar/navigation-bar.style.js +1 -0
- package/build/components/navigation-item/base-navigation-tab.d.ts +67 -0
- package/build/components/navigation-item/base-navigation-tab.d.ts.map +1 -0
- package/build/components/navigation-item/base-navigation-tab.js +1 -0
- package/build/components/navigation-item/navigation-bar-tab.d.ts +30 -0
- package/build/components/navigation-item/navigation-bar-tab.d.ts.map +1 -0
- package/build/components/navigation-item/navigation-bar-tab.js +1 -0
- package/build/components/navigation-item/navigation-rail-tab.d.ts +32 -0
- package/build/components/navigation-item/navigation-rail-tab.d.ts.map +1 -0
- package/build/components/navigation-item/navigation-rail-tab.js +1 -0
- package/build/components/navigation-item/navigation-tab-sigle-selection-controller.d.ts +37 -0
- package/build/components/navigation-item/navigation-tab-sigle-selection-controller.d.ts.map +1 -0
- package/build/components/navigation-item/navigation-tab-sigle-selection-controller.js +6 -0
- package/build/components/navigation-item/navigation-tab.d.ts +6 -0
- package/build/components/navigation-item/navigation-tab.d.ts.map +1 -0
- package/build/components/navigation-item/navigation-tab.js +1 -0
- package/build/components/navigation-item/navigation-tab.style.d.ts +3 -0
- package/build/components/navigation-item/navigation-tab.style.d.ts.map +1 -0
- package/build/components/navigation-item/navigation-tab.style.js +353 -0
- package/build/components/navigation-rail/navigation-rail-animations.d.ts +21 -0
- package/build/components/navigation-rail/navigation-rail-animations.d.ts.map +1 -0
- package/build/components/navigation-rail/navigation-rail-animations.js +1 -0
- package/build/components/navigation-rail/navigation-rail.d.ts +94 -0
- package/build/components/navigation-rail/navigation-rail.d.ts.map +1 -0
- package/build/components/navigation-rail/navigation-rail.js +1 -0
- package/build/components/navigation-rail/navigation-rail.style.d.ts +2 -0
- package/build/components/navigation-rail/navigation-rail.style.d.ts.map +1 -0
- package/build/components/navigation-rail/navigation-rail.style.js +1 -0
- package/build/components/progress-indicator/base-progress-indicator.d.ts +33 -0
- package/build/components/progress-indicator/base-progress-indicator.d.ts.map +1 -0
- package/build/components/progress-indicator/base-progress-indicator.js +1 -0
- package/build/components/progress-indicator/linear-progress-indicator.d.ts +47 -0
- package/build/components/progress-indicator/linear-progress-indicator.d.ts.map +1 -0
- package/build/components/progress-indicator/linear-progress-indicator.js +1 -0
- package/build/components/progress-indicator/progress-indicator.style.d.ts +2 -0
- package/build/components/progress-indicator/progress-indicator.style.d.ts.map +1 -0
- package/build/components/progress-indicator/progress-indicator.style.js +154 -0
- package/build/components/radio-button/radio-button.d.ts +49 -0
- package/build/components/radio-button/radio-button.d.ts.map +1 -0
- package/build/components/radio-button/radio-button.js +1 -0
- package/build/components/radio-button/radio-button.style.d.ts +2 -0
- package/build/components/radio-button/radio-button.style.d.ts.map +1 -0
- package/build/components/radio-button/radio-button.style.js +143 -0
- package/build/components/ripple/ripple-action.d.ts +62 -0
- package/build/components/ripple/ripple-action.d.ts.map +1 -0
- package/build/components/ripple/ripple-action.js +10 -0
- package/build/components/ripple/ripple.d.ts +55 -0
- package/build/components/ripple/ripple.d.ts.map +1 -0
- package/build/components/ripple/ripple.js +1 -0
- package/build/components/ripple/ripple.style.d.ts +2 -0
- package/build/components/ripple/ripple.style.d.ts.map +1 -0
- package/build/components/ripple/ripple.style.js +6 -0
- package/build/components/search/search-bar.d.ts +30 -0
- package/build/components/search/search-bar.d.ts.map +1 -0
- package/build/components/search/search-bar.js +1 -0
- package/build/components/search/search-bar.style.d.ts +2 -0
- package/build/components/search/search-bar.style.d.ts.map +1 -0
- package/build/components/search/search-bar.style.js +1 -0
- package/build/components/slider/base-slider.d.ts +58 -0
- package/build/components/slider/base-slider.d.ts.map +1 -0
- package/build/components/slider/base-slider.js +1 -0
- package/build/components/slider/slider.d.ts +3 -0
- package/build/components/slider/slider.d.ts.map +1 -0
- package/build/components/slider/slider.js +1 -0
- package/build/components/switch/switch.d.ts +45 -0
- package/build/components/switch/switch.d.ts.map +1 -0
- package/build/components/switch/switch.js +1 -0
- package/build/components/switch/switch.style.d.ts +2 -0
- package/build/components/switch/switch.style.d.ts.map +1 -0
- package/build/components/switch/switch.style.js +329 -0
- package/build/components/typography/typography.d.ts +44 -0
- package/build/components/typography/typography.d.ts.map +1 -0
- package/build/components/typography/typography.js +1 -0
- package/build/components/typography/typography.styles.d.ts +3 -0
- package/build/components/typography/typography.styles.d.ts.map +1 -0
- package/build/components/typography/typography.styles.js +6 -0
- package/build/components/wave/base-wave.d.ts +12 -0
- package/build/components/wave/base-wave.d.ts.map +1 -0
- package/build/components/wave/base-wave.js +1 -0
- package/build/components/wave/circular-wave.d.ts +37 -0
- package/build/components/wave/circular-wave.d.ts.map +1 -0
- package/build/components/wave/circular-wave.js +1 -0
- package/build/components/wave/linear-wave.d.ts +26 -0
- package/build/components/wave/linear-wave.d.ts.map +1 -0
- package/build/components/wave/linear-wave.js +1 -0
- package/build/custom-element-Dz3n6kSt.js +6 -0
- package/build/definitions.d.ts +18 -0
- package/build/definitions.d.ts.map +1 -0
- package/build/definitions.js +1 -0
- package/build/duration-CDKuKTyT.js +1 -0
- package/build/easing-5hHInU7b.js +1 -0
- package/build/elevation-dUQez_WX.js +1 -0
- package/build/lit-element-Ho-VPzO1.js +22 -0
- package/build/property-Ck1wIidx.js +6 -0
- package/build/query-DifSdHBD.js +11 -0
- package/build/query-assigned-elements-CAhlPqtD.js +6 -0
- package/build/shape-CrZ0CLVJ.js +1 -0
- package/build/state--U2hSgGK.js +6 -0
- package/build/state-C-haZXan.js +1 -0
- package/build/tslib.es6-CmLYFWVC.js +1 -0
- package/build/typescale-Bh1NLwSE.js +1 -0
- package/build/utils/aria/aria.d.ts +71 -0
- package/build/utils/aria/aria.d.ts.map +1 -0
- package/build/utils/aria/aria.js +6 -0
- package/build/utils/aria/delegate.d.ts +55 -0
- package/build/utils/aria/delegate.d.ts.map +1 -0
- package/build/utils/aria/delegate.js +7 -0
- package/build/utils/behaviors/connected-promise-resolve.d.ts +8 -0
- package/build/utils/behaviors/connected-promise-resolve.d.ts.map +1 -0
- package/build/utils/behaviors/connected-promise-resolve.js +1 -0
- package/build/utils/behaviors/constraint-validation.d.ts +134 -0
- package/build/utils/behaviors/constraint-validation.d.ts.map +1 -0
- package/build/utils/behaviors/constraint-validation.js +6 -0
- package/build/utils/behaviors/element-internals.d.ts +46 -0
- package/build/utils/behaviors/element-internals.d.ts.map +1 -0
- package/build/utils/behaviors/element-internals.js +6 -0
- package/build/utils/behaviors/mixin.d.ts +55 -0
- package/build/utils/behaviors/mixin.d.ts.map +1 -0
- package/build/utils/behaviors/mixin.js +1 -0
- package/build/utils/behaviors/validators/checkbox-validator.d.ts +36 -0
- package/build/utils/behaviors/validators/checkbox-validator.d.ts.map +1 -0
- package/build/utils/behaviors/validators/checkbox-validator.js +6 -0
- package/build/utils/behaviors/validators/radio-validator.d.ts +39 -0
- package/build/utils/behaviors/validators/radio-validator.d.ts.map +1 -0
- package/build/utils/behaviors/validators/radio-validator.js +6 -0
- package/build/utils/behaviors/validators/select-validator.d.ts +36 -0
- package/build/utils/behaviors/validators/select-validator.d.ts.map +1 -0
- package/build/utils/behaviors/validators/select-validator.js +6 -0
- package/build/utils/behaviors/validators/text-field-validator.d.ts +111 -0
- package/build/utils/behaviors/validators/text-field-validator.d.ts.map +1 -0
- package/build/utils/behaviors/validators/text-field-validator.js +6 -0
- package/build/utils/behaviors/validators/validator.d.ts +97 -0
- package/build/utils/behaviors/validators/validator.d.ts.map +1 -0
- package/build/utils/behaviors/validators/validator.js +6 -0
- package/build/utils/controller/attachable-controller.d.ts +116 -0
- package/build/utils/controller/attachable-controller.d.ts.map +1 -0
- package/build/utils/controller/attachable-controller.js +9 -0
- package/build/utils/controller/form-submitter.d.ts +71 -0
- package/build/utils/controller/form-submitter.d.ts.map +1 -0
- package/build/utils/controller/form-submitter.js +6 -0
- package/build/utils/controller/selection-controller.d.ts +24 -0
- package/build/utils/controller/selection-controller.d.ts.map +1 -0
- package/build/utils/controller/selection-controller.js +1 -0
- package/build/utils/controller/single-selection-controller.d.ts +46 -0
- package/build/utils/controller/single-selection-controller.d.ts.map +1 -0
- package/build/utils/controller/single-selection-controller.js +6 -0
- package/build/utils/event/dispatch-hook.d.ts +86 -0
- package/build/utils/event/dispatch-hook.d.ts.map +1 -0
- package/build/utils/event/dispatch-hook.js +6 -0
- package/build/utils/event/form-label-activation.d.ts +56 -0
- package/build/utils/event/form-label-activation.d.ts.map +1 -0
- package/build/utils/event/form-label-activation.js +6 -0
- package/build/utils/event/redispatch-event.d.ts +28 -0
- package/build/utils/event/redispatch-event.d.ts.map +1 -0
- package/build/utils/event/redispatch-event.js +6 -0
- package/build/utils/form/form-associated.d.ts +200 -0
- package/build/utils/form/form-associated.d.ts.map +1 -0
- package/build/utils/form/form-associated.js +1 -0
- package/build/utils/string/to-kebab-case.d.ts +11 -0
- package/build/utils/string/to-kebab-case.d.ts.map +1 -0
- package/build/utils/string/to-kebab-case.js +6 -0
- package/build/utils/tokens/create-logic-shape-tokens.d.ts +14 -0
- package/build/utils/tokens/create-logic-shape-tokens.d.ts.map +1 -0
- package/build/utils/tokens/create-logic-shape-tokens.js +6 -0
- package/build/utils/tokens/create-var.d.ts +14 -0
- package/build/utils/tokens/create-var.d.ts.map +1 -0
- package/build/utils/tokens/create-var.js +6 -0
- package/build/utils/tokens/create-wrapped-tokens.d.ts +25 -0
- package/build/utils/tokens/create-wrapped-tokens.d.ts.map +1 -0
- package/build/utils/tokens/create-wrapped-tokens.js +6 -0
- package/build/utils/tokens/exclude-tokens.d.ts +7 -0
- package/build/utils/tokens/exclude-tokens.d.ts.map +1 -0
- package/build/utils/tokens/exclude-tokens.js +6 -0
- package/build/utils/tokens/index.d.ts +12 -0
- package/build/utils/tokens/index.d.ts.map +1 -0
- package/build/utils/tokens/index.js +1 -0
- package/build/utils/tokens/override-component-tokens.d.ts +34 -0
- package/build/utils/tokens/override-component-tokens.d.ts.map +1 -0
- package/build/utils/tokens/override-component-tokens.js +6 -0
- package/build/utils/tokens/string-tokens.d.ts +14 -0
- package/build/utils/tokens/string-tokens.d.ts.map +1 -0
- package/build/utils/tokens/string-tokens.js +6 -0
- package/build/utils/uuid/generate-uuid.d.ts +19 -0
- package/build/utils/uuid/generate-uuid.d.ts.map +1 -0
- package/build/utils/uuid/generate-uuid.js +6 -0
- package/build/utils.d.ts +3 -0
- package/build/utils.d.ts.map +1 -0
- package/build/utils.js +1 -0
- package/package.json +74 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { LitElement } from 'lit';
|
|
7
|
+
import { type FormAssociated } from '../form/form-associated';
|
|
8
|
+
import { type WithElementInternals } from './element-internals';
|
|
9
|
+
import type { MixinBase, MixinReturn } from './mixin';
|
|
10
|
+
import { Validator } from './validators/validator';
|
|
11
|
+
/**
|
|
12
|
+
* A form associated element that provides constraint validation APIs.
|
|
13
|
+
*
|
|
14
|
+
* https://developer.mozilla.org/en-US/docs/Web/HTML/Constraint_validation
|
|
15
|
+
*/
|
|
16
|
+
export interface ConstraintValidation extends FormAssociated {
|
|
17
|
+
/**
|
|
18
|
+
* Returns a ValidityState object that represents the validity states of the
|
|
19
|
+
* element.
|
|
20
|
+
*
|
|
21
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/ValidityState
|
|
22
|
+
*/
|
|
23
|
+
readonly validity: ValidityState;
|
|
24
|
+
/**
|
|
25
|
+
* Returns a validation error message or an empty string if the element is
|
|
26
|
+
* valid.
|
|
27
|
+
*
|
|
28
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/validationMessage
|
|
29
|
+
*/
|
|
30
|
+
readonly validationMessage: string;
|
|
31
|
+
/**
|
|
32
|
+
* Returns whether an element will successfully validate based on forms
|
|
33
|
+
* validation rules and constraints.
|
|
34
|
+
*
|
|
35
|
+
* Disabled and readonly elements will not validate.
|
|
36
|
+
*
|
|
37
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/willValidate
|
|
38
|
+
*/
|
|
39
|
+
readonly willValidate: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Checks the element's constraint validation and returns true if the element
|
|
42
|
+
* is valid or false if not.
|
|
43
|
+
*
|
|
44
|
+
* If invalid, this method will dispatch an `invalid` event.
|
|
45
|
+
*
|
|
46
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/checkValidity
|
|
47
|
+
*
|
|
48
|
+
* @return true if the element is valid, or false if not.
|
|
49
|
+
*/
|
|
50
|
+
checkValidity(): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Checks the element's constraint validation and returns true if the element
|
|
53
|
+
* is valid or false if not.
|
|
54
|
+
*
|
|
55
|
+
* If invalid, this method will dispatch a cancelable `invalid` event. If not
|
|
56
|
+
* canceled, a the current `validationMessage` will be reported to the user.
|
|
57
|
+
*
|
|
58
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/reportValidity
|
|
59
|
+
*
|
|
60
|
+
* @return true if the element is valid, or false if not.
|
|
61
|
+
*/
|
|
62
|
+
reportValidity(): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Sets the element's constraint validation error message. When set to a
|
|
65
|
+
* non-empty string, `validity.customError` will be true and
|
|
66
|
+
* `validationMessage` will display the provided error.
|
|
67
|
+
*
|
|
68
|
+
* Use this method to customize error messages reported.
|
|
69
|
+
*
|
|
70
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setCustomValidity
|
|
71
|
+
*
|
|
72
|
+
* @param error The error message to display, or an empty string.
|
|
73
|
+
*/
|
|
74
|
+
setCustomValidity(error: string): void;
|
|
75
|
+
/**
|
|
76
|
+
* Creates and returns a `Validator` that is used to compute and cache
|
|
77
|
+
* validity for the element.
|
|
78
|
+
*
|
|
79
|
+
* A validator that caches validity is important since constraint validation
|
|
80
|
+
* must be computed synchronously and frequently in response to constraint
|
|
81
|
+
* validation property changes.
|
|
82
|
+
*/
|
|
83
|
+
[createValidator](): Validator<unknown>;
|
|
84
|
+
/**
|
|
85
|
+
* Returns shadow DOM child that is used as the anchor for the platform
|
|
86
|
+
* `reportValidity()` popup. This is often the root element or the inner
|
|
87
|
+
* focus-delegated element.
|
|
88
|
+
*/
|
|
89
|
+
[getValidityAnchor](): HTMLElement | null;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* A symbol property used to create a constraint validation `Validator`.
|
|
93
|
+
* Required for all `mixinConstraintValidation()` elements.
|
|
94
|
+
*/
|
|
95
|
+
export declare const createValidator: unique symbol;
|
|
96
|
+
/**
|
|
97
|
+
* A symbol property used to return an anchor for constraint validation popups.
|
|
98
|
+
* Required for all `mixinConstraintValidation()` elements.
|
|
99
|
+
*/
|
|
100
|
+
export declare const getValidityAnchor: unique symbol;
|
|
101
|
+
/**
|
|
102
|
+
* Mixes in constraint validation APIs for an element.
|
|
103
|
+
*
|
|
104
|
+
* See https://developer.mozilla.org/en-US/docs/Web/HTML/Constraint_validation
|
|
105
|
+
* for more details.
|
|
106
|
+
*
|
|
107
|
+
* Implementations must provide a validator to cache and compute its validity,
|
|
108
|
+
* along with a shadow root element to anchor validation popups to.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```ts
|
|
112
|
+
* const baseClass = mixinConstraintValidation(
|
|
113
|
+
* mixinFormAssociated(mixinElementInternals(LitElement))
|
|
114
|
+
* );
|
|
115
|
+
*
|
|
116
|
+
* class MyCheckbox extends baseClass {
|
|
117
|
+
* \@property({type: Boolean}) checked = false;
|
|
118
|
+
* \@property({type: Boolean}) required = false;
|
|
119
|
+
*
|
|
120
|
+
* [createValidator]() {
|
|
121
|
+
* return new CheckboxValidator(() => this);
|
|
122
|
+
* }
|
|
123
|
+
*
|
|
124
|
+
* [getValidityAnchor]() {
|
|
125
|
+
* return this.renderRoot.querySelector('.root');
|
|
126
|
+
* }
|
|
127
|
+
* }
|
|
128
|
+
* ```
|
|
129
|
+
*
|
|
130
|
+
* @param base The class to mix functionality into.
|
|
131
|
+
* @return The provided class with `ConstraintValidation` mixed in.
|
|
132
|
+
*/
|
|
133
|
+
export declare function mixinConstraintValidation<T extends MixinBase<LitElement & FormAssociated & WithElementInternals>>(base: T): MixinReturn<T, ConstraintValidation>;
|
|
134
|
+
//# sourceMappingURL=constraint-validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constraint-validation.d.ts","sourceRoot":"","sources":["../../../src/utils/behaviors/constraint-validation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAY,UAAU,EAAiD,MAAM,KAAK,CAAA;AACzF,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,EAAa,KAAK,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC1E,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAElD;;;;GAIG;AACH,MAAM,WAAW,oBAAqB,SAAQ,cAAc;IACxD;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAA;IAEhC;;;;;OAKG;IACH,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAA;IAElC;;;;;;;OAOG;IACH,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAA;IAE9B;;;;;;;;;OASG;IACH,aAAa,IAAI,OAAO,CAAA;IAExB;;;;;;;;;;OAUG;IACH,cAAc,IAAI,OAAO,CAAA;IAEzB;;;;;;;;;;OAUG;IACH,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IAEtC;;;;;;;OAOG;IACH,CAAC,eAAe,CAAC,IAAI,SAAS,CAAC,OAAO,CAAC,CAAA;IAEvC;;;;OAIG;IACH,CAAC,iBAAiB,CAAC,IAAI,WAAW,GAAG,IAAI,CAAA;CAC5C;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,eAA4B,CAAA;AAExD;;;GAGG;AACH,eAAO,MAAM,iBAAiB,eAA8B,CAAA;AAO5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,yBAAyB,CACrC,CAAC,SAAS,SAAS,CAAC,UAAU,GAAG,cAAc,GAAG,oBAAoB,CAAC,EACzE,IAAI,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,EAAE,oBAAoB,CAAC,CAyG/C"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import"../../lit-element-Ho-VPzO1.js";import"../../tslib.es6-CmLYFWVC.js";import{internals as t}from"./element-internals.js";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2023 Google LLC
|
|
5
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
6
|
+
*/const i=Symbol("createValidator"),e=Symbol("getValidityAnchor"),s=Symbol("privateValidator"),r=Symbol("privateSyncValidity"),a=Symbol("privateCustomValidationMessage");function l(l){var o;class d extends l{constructor(){super(...arguments),this[o]=""}get validity(){return this[r](),this[t].validity}get validationMessage(){return this[r](),this[t].validationMessage}get willValidate(){return this[r](),this[t].willValidate}checkValidity(){return this[r](),this[t].checkValidity()}reportValidity(){return this[r](),this[t].reportValidity()}setCustomValidity(t){this[a]=t,this[r]()}requestUpdate(t,i,e){super.requestUpdate(t,i,e),this[r]()}firstUpdated(t){super.firstUpdated(t),this[r]()}[(o=a,r)](){this[s]||(this[s]=this[i]());const{validity:r,validationMessage:l}=this[s].getValidity(),o=!!this[a],d=this[a]||l;this[t].setValidity({...r,customError:o},d,this[e]()??void 0)}[i](){throw new Error("Implement [createValidator]")}[e](){throw new Error("Implement [getValidityAnchor]")}}return d}export{i as createValidator,e as getValidityAnchor,l as mixinConstraintValidation};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { LitElement } from 'lit';
|
|
7
|
+
import { type MixinBase, type MixinReturn } from './mixin';
|
|
8
|
+
/**
|
|
9
|
+
* A unique symbol used for protected access to an instance's
|
|
10
|
+
* `ElementInternals`.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* class MyElement extends mixinElementInternals(LitElement) {
|
|
15
|
+
* constructor() {
|
|
16
|
+
* super();
|
|
17
|
+
* this[internals].role = 'button';
|
|
18
|
+
* }
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare const internals: unique symbol;
|
|
23
|
+
/**
|
|
24
|
+
* An instance with an `internals` symbol property for the component's
|
|
25
|
+
* `ElementInternals`.
|
|
26
|
+
*
|
|
27
|
+
* Use this when protected access is needed for an instance's `ElementInternals`
|
|
28
|
+
* from other files. A unique symbol is used to access the internals.
|
|
29
|
+
*/
|
|
30
|
+
export interface WithElementInternals {
|
|
31
|
+
/**
|
|
32
|
+
* An instance's `ElementInternals`.
|
|
33
|
+
*/
|
|
34
|
+
[internals]: ElementInternals;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Mixes in an attached `ElementInternals` instance.
|
|
38
|
+
*
|
|
39
|
+
* This mixin is only needed when other shared code needs access to a
|
|
40
|
+
* component's `ElementInternals`, such as form-associated mixins.
|
|
41
|
+
*
|
|
42
|
+
* @param base The class to mix functionality into.
|
|
43
|
+
* @return The provided class with `WithElementInternals` mixed in.
|
|
44
|
+
*/
|
|
45
|
+
export declare function mixinElementInternals<T extends MixinBase<LitElement>>(base: T): MixinReturn<T, WithElementInternals>;
|
|
46
|
+
//# sourceMappingURL=element-internals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element-internals.d.ts","sourceRoot":"","sources":["../../../src/utils/behaviors/element-internals.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAChC,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1D;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,SAAS,eAAsB,CAAA;AAE5C;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACjC;;OAEG;IACH,CAAC,SAAS,CAAC,EAAE,gBAAgB,CAAA;CAChC;AAKD;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,SAAS,CAAC,UAAU,CAAC,EACjE,IAAI,EAAE,CAAC,GACR,WAAW,CAAC,CAAC,EAAE,oBAAoB,CAAC,CAmBtC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import"../../lit-element-Ho-VPzO1.js";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2023 Google LLC
|
|
5
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
6
|
+
*/const t=Symbol("internals"),e=Symbol("privateInternals");function n(n){return class extends n{get[t](){return this[e]||(this[e]=this.attachInternals()),this[e]}}}export{t as internals,n as mixinElementInternals};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* The base class for a mixin with an optional expected base class type.
|
|
8
|
+
*
|
|
9
|
+
* @template ExpectedBase Optional expected base class type, such as
|
|
10
|
+
* `LitElement`.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* interface Foo {
|
|
15
|
+
* isFoo: boolean;
|
|
16
|
+
* }
|
|
17
|
+
*
|
|
18
|
+
* function mixinFoo<T extends MixinBase>(base: T): MixinReturn<T, Foo> {
|
|
19
|
+
* // Mixins must be `abstract`
|
|
20
|
+
* abstract class FooImpl extends base implements Foo {
|
|
21
|
+
* isFoo = true;
|
|
22
|
+
* }
|
|
23
|
+
*
|
|
24
|
+
* return FooImpl;
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export type MixinBase<ExpectedBase = object> = abstract new (...args: any[]) => ExpectedBase;
|
|
29
|
+
/**
|
|
30
|
+
* The return value of a mixin.
|
|
31
|
+
*
|
|
32
|
+
* @template MixinBase The generic that extends `MixinBase` used for the mixin's
|
|
33
|
+
* base class argument.
|
|
34
|
+
* @template MixinClass Optional interface of fuctionality that was mixed in.
|
|
35
|
+
* Omit if no additional APIs were added (such as purely overriding base
|
|
36
|
+
* class functionality).
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* interface Foo {
|
|
41
|
+
* isFoo: boolean;
|
|
42
|
+
* }
|
|
43
|
+
*
|
|
44
|
+
* // Mixins must be `abstract`
|
|
45
|
+
* function mixinFoo<T extends MixinBase>(base: T): MixinReturn<T, Foo> {
|
|
46
|
+
* abstract class FooImpl extends base implements Foo {
|
|
47
|
+
* isFoo = true;
|
|
48
|
+
* }
|
|
49
|
+
*
|
|
50
|
+
* return FooImpl;
|
|
51
|
+
* }
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export type MixinReturn<MixinBase, MixinClass = object> = (abstract new (...args: any[]) => MixinClass) & MixinBase;
|
|
55
|
+
//# sourceMappingURL=mixin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mixin.d.ts","sourceRoot":"","sources":["../../../src/utils/behaviors/mixin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,MAAM,SAAS,CAAC,YAAY,GAAG,MAAM,IAAI,QAAQ,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,YAAY,CAAA;AAE5F;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,MAAM,WAAW,CAAC,SAAS,EAAE,UAAU,GAAG,MAAM,IAAI,CAAC,QAAQ,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,UAAU,CAAC,GAAG,SAAS,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { Validator } from './validator.js';
|
|
7
|
+
/**
|
|
8
|
+
* Constraint validation properties for a checkbox.
|
|
9
|
+
*/
|
|
10
|
+
export interface ICheckboxState {
|
|
11
|
+
/**
|
|
12
|
+
* Whether the checkbox is checked.
|
|
13
|
+
*/
|
|
14
|
+
readonly checked: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Whether the checkbox is required.
|
|
17
|
+
*/
|
|
18
|
+
readonly required: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A validator that provides constraint validation that emulates
|
|
22
|
+
* `<input type="checkbox">` validation.
|
|
23
|
+
*/
|
|
24
|
+
export declare class CheckboxValidator extends Validator<ICheckboxState> {
|
|
25
|
+
private checkboxControl?;
|
|
26
|
+
protected computeValidity(state: ICheckboxState): {
|
|
27
|
+
validity: ValidityState;
|
|
28
|
+
validationMessage: string;
|
|
29
|
+
};
|
|
30
|
+
protected equals(prev: ICheckboxState, next: ICheckboxState): boolean;
|
|
31
|
+
protected copy({ checked, required }: ICheckboxState): {
|
|
32
|
+
checked: boolean;
|
|
33
|
+
required: boolean;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=checkbox-validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkbox-validator.d.ts","sourceRoot":"","sources":["../../../../src/utils/behaviors/validators/checkbox-validator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C;;GAEG;AACH,MAAM,WAAW,cAAc;IAC3B;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IAEzB;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;CAC7B;AAED;;;GAGG;AACH,qBAAa,iBAAkB,SAAQ,SAAS,CAAC,cAAc,CAAC;IAC5D,OAAO,CAAC,eAAe,CAAC,CAAkB;cAEvB,eAAe,CAAC,KAAK,EAAE,cAAc;;;;cAerC,MAAM,CAAC,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,cAAc;cAIjD,IAAI,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,cAAc;;;;CAGhE"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{Validator as e}from"./validator.js";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2023 Google LLC
|
|
5
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
6
|
+
*/class c extends e{computeValidity(e){return this.checkboxControl||(this.checkboxControl=document.createElement("input"),this.checkboxControl.type="checkbox"),this.checkboxControl.checked=e.checked,this.checkboxControl.required=e.required,{validity:this.checkboxControl.validity,validationMessage:this.checkboxControl.validationMessage}}equals(e,c){return e.checked===c.checked&&e.required===c.required}copy({checked:e,required:c}){return{checked:e,required:c}}}export{c as CheckboxValidator};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { Validator } from './validator.js';
|
|
7
|
+
/**
|
|
8
|
+
* Constraint validation properties for a radio.
|
|
9
|
+
*/
|
|
10
|
+
export interface RadioState {
|
|
11
|
+
/**
|
|
12
|
+
* Whether the radio is checked.
|
|
13
|
+
*/
|
|
14
|
+
readonly checked: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Whether the radio is required.
|
|
17
|
+
*/
|
|
18
|
+
readonly required: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Radio constraint validation properties for a single radio and its siblings.
|
|
22
|
+
*/
|
|
23
|
+
export type RadioGroupState = readonly [RadioState, ...RadioState[]];
|
|
24
|
+
/**
|
|
25
|
+
* A validator that provides constraint validation that emulates
|
|
26
|
+
* `<input type="radio">` validation.
|
|
27
|
+
*/
|
|
28
|
+
export declare class RadioValidator extends Validator<RadioGroupState> {
|
|
29
|
+
private radioElement?;
|
|
30
|
+
protected computeValidity(states: RadioGroupState): {
|
|
31
|
+
validity: {
|
|
32
|
+
valueMissing: boolean;
|
|
33
|
+
};
|
|
34
|
+
validationMessage: string;
|
|
35
|
+
};
|
|
36
|
+
protected equals(prevGroup: RadioGroupState, nextGroup: RadioGroupState): boolean;
|
|
37
|
+
protected copy(states: RadioGroupState): RadioGroupState;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=radio-validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radio-validator.d.ts","sourceRoot":"","sources":["../../../../src/utils/behaviors/validators/radio-validator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,SAAS,CAAC,UAAU,EAAE,GAAG,UAAU,EAAE,CAAC,CAAC;AAErE;;;GAGG;AACH,qBAAa,cAAe,SAAQ,SAAS,CAAC,eAAe,CAAC;IAC5D,OAAO,CAAC,YAAY,CAAC,CAAmB;cAErB,eAAe,CAAC,MAAM,EAAE,eAAe;;;;;;cAmCvC,MAAM,CACvB,SAAS,EAAE,eAAe,EAC1B,SAAS,EAAE,eAAe;cAiBT,IAAI,CAAC,MAAM,EAAE,eAAe,GAAG,eAAe;CAQlE"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{Validator as e}from"./validator.js";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2023 Google LLC
|
|
5
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
6
|
+
*/class t extends e{computeValidity(e){this.radioElement||(this.radioElement=document.createElement("input"),this.radioElement.type="radio",this.radioElement.name="group");let t=!1,r=!1;for(const{checked:i,required:d}of e)d&&(t=!0),i&&(r=!0);return this.radioElement.checked=r,this.radioElement.required=t,{validity:{valueMissing:t&&!r},validationMessage:this.radioElement.validationMessage}}equals(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){const i=e[r],d=t[r];if(i.checked!==d.checked||i.required!==d.required)return!1}return!0}copy(e){return e.map(({checked:e,required:t})=>({checked:e,required:t}))}}export{t as RadioValidator};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { Validator } from './validator.js';
|
|
7
|
+
/**
|
|
8
|
+
* Constraint validation properties for a select dropdown.
|
|
9
|
+
*/
|
|
10
|
+
export interface SelectState {
|
|
11
|
+
/**
|
|
12
|
+
* The current selected value.
|
|
13
|
+
*/
|
|
14
|
+
readonly value: string;
|
|
15
|
+
/**
|
|
16
|
+
* Whether the select is required.
|
|
17
|
+
*/
|
|
18
|
+
readonly required: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A validator that provides constraint validation that emulates `<select>`
|
|
22
|
+
* validation.
|
|
23
|
+
*/
|
|
24
|
+
export declare class SelectValidator extends Validator<SelectState> {
|
|
25
|
+
private selectControl?;
|
|
26
|
+
protected computeValidity(state: SelectState): {
|
|
27
|
+
validity: ValidityState;
|
|
28
|
+
validationMessage: string;
|
|
29
|
+
};
|
|
30
|
+
protected equals(prev: SelectState, next: SelectState): boolean;
|
|
31
|
+
protected copy({ value, required }: SelectState): {
|
|
32
|
+
value: string;
|
|
33
|
+
required: boolean;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=select-validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select-validator.d.ts","sourceRoot":"","sources":["../../../../src/utils/behaviors/validators/select-validator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAED;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,SAAS,CAAC,WAAW,CAAC;IACzD,OAAO,CAAC,aAAa,CAAC,CAAoB;cAEvB,eAAe,CAAC,KAAK,EAAE,WAAW;;;;cAgBlC,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW;cAI3C,IAAI,CAAC,EAAC,KAAK,EAAE,QAAQ,EAAC,EAAE,WAAW;;;;CAGvD"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{B as e,x as t}from"../../../lit-element-Ho-VPzO1.js";import{Validator as l}from"./validator.js";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2023 Google LLC
|
|
5
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
6
|
+
*/class r extends l{computeValidity(l){return this.selectControl||(this.selectControl=document.createElement("select")),e(t`<option value="${l.value}"></option>`,this.selectControl),this.selectControl.value=l.value,this.selectControl.required=l.required,{validity:this.selectControl.validity,validationMessage:this.selectControl.validationMessage}}equals(e,t){return e.value===t.value&&e.required===t.required}copy({value:e,required:t}){return{value:e,required:t}}}export{r as SelectValidator};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { Validator } from './validator.js';
|
|
7
|
+
/**
|
|
8
|
+
* Constraint validation for a text field.
|
|
9
|
+
*/
|
|
10
|
+
export interface TextFieldState {
|
|
11
|
+
/**
|
|
12
|
+
* The input or textarea state to validate.
|
|
13
|
+
*/
|
|
14
|
+
state: InputState | TextAreaState;
|
|
15
|
+
/**
|
|
16
|
+
* The `<input>` or `<textarea>` that is rendered on the page.
|
|
17
|
+
*
|
|
18
|
+
* `minlength` and `maxlength` validation do not apply until a user has
|
|
19
|
+
* interacted with the control and the element is internally marked as dirty.
|
|
20
|
+
* This is a spec quirk, the two properties behave differently from other
|
|
21
|
+
* constraint validation.
|
|
22
|
+
*
|
|
23
|
+
* This means we need an actual rendered element instead of a virtual one,
|
|
24
|
+
* since the virtual element will never be marked as dirty.
|
|
25
|
+
*
|
|
26
|
+
* This can be `null` if the element has not yet rendered, and the validator
|
|
27
|
+
* will fall back to virtual elements for other constraint validation
|
|
28
|
+
* properties, which do apply even if the control is not dirty.
|
|
29
|
+
*/
|
|
30
|
+
renderedControl: HTMLInputElement | HTMLTextAreaElement | null;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Constraint validation properties for an `<input>`.
|
|
34
|
+
*/
|
|
35
|
+
export interface InputState extends SharedInputAndTextAreaState {
|
|
36
|
+
/**
|
|
37
|
+
* The `<input>` type.
|
|
38
|
+
*
|
|
39
|
+
* Not all constraint validation properties apply to every type. See
|
|
40
|
+
* https://developer.mozilla.org/en-US/docs/Web/HTML/Constraint_validation#validation-related_attributes
|
|
41
|
+
* for which properties will apply to which types.
|
|
42
|
+
*/
|
|
43
|
+
readonly type: string;
|
|
44
|
+
/**
|
|
45
|
+
* The regex pattern a value must match.
|
|
46
|
+
*/
|
|
47
|
+
readonly pattern: string;
|
|
48
|
+
/**
|
|
49
|
+
* The minimum value.
|
|
50
|
+
*/
|
|
51
|
+
readonly min: string;
|
|
52
|
+
/**
|
|
53
|
+
* The maximum value.
|
|
54
|
+
*/
|
|
55
|
+
readonly max: string;
|
|
56
|
+
/**
|
|
57
|
+
* The step interval of the value.
|
|
58
|
+
*/
|
|
59
|
+
readonly step: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Constraint validation properties for a `<textarea>`.
|
|
63
|
+
*/
|
|
64
|
+
export interface TextAreaState extends SharedInputAndTextAreaState {
|
|
65
|
+
/**
|
|
66
|
+
* The type, must be "textarea" to inform the validator to use `<textarea>`
|
|
67
|
+
* instead of `<input>`.
|
|
68
|
+
*/
|
|
69
|
+
readonly type: 'textarea';
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Constraint validation properties shared between an `<input>` and
|
|
73
|
+
* `<textarea>`.
|
|
74
|
+
*/
|
|
75
|
+
interface SharedInputAndTextAreaState {
|
|
76
|
+
/**
|
|
77
|
+
* The current value.
|
|
78
|
+
*/
|
|
79
|
+
readonly value: string;
|
|
80
|
+
/**
|
|
81
|
+
* Whether the textarea is required.
|
|
82
|
+
*/
|
|
83
|
+
readonly required: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* The minimum length of the value.
|
|
86
|
+
*/
|
|
87
|
+
readonly minLength: number;
|
|
88
|
+
/**
|
|
89
|
+
* The maximum length of the value.
|
|
90
|
+
*/
|
|
91
|
+
readonly maxLength: number;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* A validator that provides constraint validation that emulates `<input>` and
|
|
95
|
+
* `<textarea>` validation.
|
|
96
|
+
*/
|
|
97
|
+
export declare class TextFieldValidator extends Validator<TextFieldState> {
|
|
98
|
+
private inputControl?;
|
|
99
|
+
private textAreaControl?;
|
|
100
|
+
protected computeValidity({ state, renderedControl }: TextFieldState): {
|
|
101
|
+
validity: ValidityState;
|
|
102
|
+
validationMessage: string;
|
|
103
|
+
};
|
|
104
|
+
protected equals({ state: prev }: TextFieldState, { state: next }: TextFieldState): boolean;
|
|
105
|
+
protected copy({ state }: TextFieldState): TextFieldState;
|
|
106
|
+
private copyInput;
|
|
107
|
+
private copyTextArea;
|
|
108
|
+
private copySharedState;
|
|
109
|
+
}
|
|
110
|
+
export {};
|
|
111
|
+
//# sourceMappingURL=text-field-validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-field-validator.d.ts","sourceRoot":"","sources":["../../../../src/utils/behaviors/validators/text-field-validator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,KAAK,EAAE,UAAU,GAAG,aAAa,CAAC;IAElC;;;;;;;;;;;;;;OAcG;IACH,eAAe,EAAE,gBAAgB,GAAG,mBAAmB,GAAG,IAAI,CAAC;CAChE;AAED;;GAEG;AACH,MAAM,WAAW,UAAW,SAAQ,2BAA2B;IAC7D;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,aAAc,SAAQ,2BAA2B;IAChE;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;CAC3B;AAED;;;GAGG;AACH,UAAU,2BAA2B;IACnC;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAE3B;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED;;;GAGG;AACH,qBAAa,kBAAmB,SAAQ,SAAS,CAAC,cAAc,CAAC;IAC/D,OAAO,CAAC,YAAY,CAAC,CAAmB;IACxC,OAAO,CAAC,eAAe,CAAC,CAAsB;cAE3B,eAAe,CAAC,EAAC,KAAK,EAAE,eAAe,EAAC,EAAE,cAAc;;;;cA+FxD,MAAM,CACvB,EAAC,KAAK,EAAE,IAAI,EAAC,EAAE,cAAc,EAC7B,EAAC,KAAK,EAAE,IAAI,EAAC,EAAE,cAAc;cAyBZ,IAAI,CAAC,EAAC,KAAK,EAAC,EAAE,cAAc,GAAG,cAAc;IAWhE,OAAO,CAAC,SAAS;IAYjB,OAAO,CAAC,YAAY;IAOpB,OAAO,CAAC,eAAe;CAQxB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{Validator as t}from"./validator.js";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2023 Google LLC
|
|
5
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
6
|
+
*/class e extends t{computeValidity({state:t,renderedControl:e}){let r=e;n(t)&&!r?(r=this.inputControl||document.createElement("input"),this.inputControl=r):r||(r=this.textAreaControl||document.createElement("textarea"),this.textAreaControl=r);const a=n(t)?r:null;if(a&&(a.type=t.type),r.value!==t.value&&(r.value=t.value),r.required=t.required,a){const e=t;e.pattern?a.pattern=e.pattern:a.removeAttribute("pattern"),e.min?a.min=e.min:a.removeAttribute("min"),e.max?a.max=e.max:a.removeAttribute("max"),e.step?a.step=e.step:a.removeAttribute("step")}return(t.minLength??-1)>-1?r.setAttribute("minlength",String(t.minLength)):r.removeAttribute("minlength"),(t.maxLength??-1)>-1?r.setAttribute("maxlength",String(t.maxLength)):r.removeAttribute("maxlength"),{validity:r.validity,validationMessage:r.validationMessage}}equals({state:t},{state:e}){const r=t.type===e.type&&t.value===e.value&&t.required===e.required&&t.minLength===e.minLength&&t.maxLength===e.maxLength;return n(t)&&n(e)?r&&t.pattern===e.pattern&&t.min===e.min&&t.max===e.max&&t.step===e.step:r}copy({state:t}){return{state:n(t)?this.copyInput(t):this.copyTextArea(t),renderedControl:null}}copyInput(t){const{type:e,pattern:n,min:r,max:a,step:i}=t;return{...this.copySharedState(t),type:e,pattern:n,min:r,max:a,step:i}}copyTextArea(t){return{...this.copySharedState(t),type:t.type}}copySharedState({value:t,required:e,minLength:n,maxLength:r}){return{value:t,required:e,minLength:n,maxLength:r}}}function n(t){return"textarea"!==t.type}export{e as TextFieldValidator};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* A class that computes and caches `ValidityStateFlags` for a component with
|
|
8
|
+
* a given `State` interface.
|
|
9
|
+
*
|
|
10
|
+
* Cached performance before computing validity is important since constraint
|
|
11
|
+
* validation must be checked frequently and synchronously when properties
|
|
12
|
+
* change.
|
|
13
|
+
*
|
|
14
|
+
* @template State The expected interface of properties relevant to constraint
|
|
15
|
+
* validation.
|
|
16
|
+
*/
|
|
17
|
+
export declare abstract class Validator<State> {
|
|
18
|
+
/**
|
|
19
|
+
* The previous state, used to determine if state changed and validation needs
|
|
20
|
+
* to be re-computed.
|
|
21
|
+
*/
|
|
22
|
+
private prevState?;
|
|
23
|
+
/**
|
|
24
|
+
* The current validity state and message. This is cached and returns if
|
|
25
|
+
* constraint validation state does not change.
|
|
26
|
+
*/
|
|
27
|
+
private currentValidity;
|
|
28
|
+
private readonly getCurrentState;
|
|
29
|
+
/**
|
|
30
|
+
* Creates a new validator.
|
|
31
|
+
*
|
|
32
|
+
* @param getCurrentState A callback that returns the current state of
|
|
33
|
+
* constraint validation-related properties.
|
|
34
|
+
*/
|
|
35
|
+
constructor(getCurrentState: () => State);
|
|
36
|
+
/**
|
|
37
|
+
* Returns the current `ValidityStateFlags` and validation message for the
|
|
38
|
+
* validator.
|
|
39
|
+
*
|
|
40
|
+
* If the constraint validation state has not changed, this will return a
|
|
41
|
+
* cached result. This is important since `getValidity()` can be called
|
|
42
|
+
* frequently in response to synchronous property changes.
|
|
43
|
+
*
|
|
44
|
+
* @return The current validity and validation message.
|
|
45
|
+
*/
|
|
46
|
+
getValidity(): IValidityAndMessage;
|
|
47
|
+
/**
|
|
48
|
+
* Computes the `ValidityStateFlags` and validation message for a given set
|
|
49
|
+
* of constraint validation properties.
|
|
50
|
+
*
|
|
51
|
+
* Implementations can use platform elements like `<input>` and `<select>` to
|
|
52
|
+
* sync state and compute validation along with i18n'd messages. This function
|
|
53
|
+
* may be expensive, and is only called when state changes.
|
|
54
|
+
*
|
|
55
|
+
* @param state The new state of constraint validation properties.
|
|
56
|
+
* @return An object containing a `validity` property with
|
|
57
|
+
* `ValidityStateFlags` and a `validationMessage` property.
|
|
58
|
+
*/
|
|
59
|
+
protected abstract computeValidity(state: State): IValidityAndMessage;
|
|
60
|
+
/**
|
|
61
|
+
* Checks if two states are equal. This is used to check against cached state
|
|
62
|
+
* to see if validity needs to be re-computed.
|
|
63
|
+
*
|
|
64
|
+
* @param prev The previous state.
|
|
65
|
+
* @param next The next state.
|
|
66
|
+
* @return True if the states are equal, or false if not.
|
|
67
|
+
*/
|
|
68
|
+
protected abstract equals(prev: State, next: State): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Creates a copy of a state. This is used to cache state and check if it
|
|
71
|
+
* changes.
|
|
72
|
+
*
|
|
73
|
+
* Note: do NOT spread the {...state} to copy it. The actual state object is
|
|
74
|
+
* a web component, and trying to spread its getter/setter properties won't
|
|
75
|
+
* work.
|
|
76
|
+
*
|
|
77
|
+
* @param state The state to copy.
|
|
78
|
+
* @return A copy of the state.
|
|
79
|
+
*/
|
|
80
|
+
protected abstract copy(state: State): State;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* An object containing `ValidityStateFlags` and a corresponding validation
|
|
84
|
+
* message.
|
|
85
|
+
*/
|
|
86
|
+
export interface IValidityAndMessage {
|
|
87
|
+
/**
|
|
88
|
+
* Validity flags.
|
|
89
|
+
*/
|
|
90
|
+
validity: ValidityStateFlags;
|
|
91
|
+
/**
|
|
92
|
+
* The validation message for the associated flags. It may not be an empty
|
|
93
|
+
* string if any of the validity flags are `true`.
|
|
94
|
+
*/
|
|
95
|
+
validationMessage: string;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../../../src/utils/behaviors/validators/validator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;GAUG;AACH,8BAAsB,SAAS,CAAC,KAAK;IACjC;;;OAGG;IACH,OAAO,CAAC,SAAS,CAAC,CAAO;IAEzB;;;OAGG;IACH,OAAO,CAAC,eAAe,CAGrB;IAEF,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAa;IAE7C;;;;;OAKG;gBACS,eAAe,EAAE,MAAM,KAAK;IAIxC;;;;;;;;;OASG;IACH,WAAW,IAAI,mBAAmB;IA+BlC;;;;;;;;;;;OAWG;IACH,SAAS,CAAC,QAAQ,CAAC,eAAe,CAAC,KAAK,EAAE,KAAK,GAAG,mBAAmB;IAErE;;;;;;;OAOG;IACH,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,GAAG,OAAO;IAE5D;;;;;;;;;;OAUG;IACH,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK;CAC/C;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAChC;;OAEG;IACH,QAAQ,EAAE,kBAAkB,CAAA;IAE5B;;;OAGG;IACH,iBAAiB,EAAE,MAAM,CAAA;CAC5B"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
class t{constructor(t){this.currentValidity={validity:{},validationMessage:""},this.getCurrentState=t}getValidity(){const t=this.getCurrentState();if(!(!this.prevState||!this.equals(this.prevState,t)))return this.currentValidity;const{validity:i,validationMessage:e}=this.computeValidity(t);return this.prevState=this.copy(t),this.currentValidity={validationMessage:e,validity:{badInput:i.badInput,customError:i.customError,patternMismatch:i.patternMismatch,rangeOverflow:i.rangeOverflow,rangeUnderflow:i.rangeUnderflow,stepMismatch:i.stepMismatch,tooLong:i.tooLong,tooShort:i.tooShort,typeMismatch:i.typeMismatch,valueMissing:i.valueMissing}},this.currentValidity}}export{t as Validator};
|