@omicronenergy/oscd-ui 0.0.6 → 0.0.7
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/app-bar/OscdAppBar.d.ts +3 -3
- package/app-bar/OscdAppBar.js +12 -10
- package/app-bar/OscdAppBar.js.map +1 -1
- package/button/OscdFilledButton.js +2 -2
- package/button/OscdFilledButton.js.map +1 -1
- package/button/OscdOutlinedButton.js +1 -1
- package/button/OscdOutlinedButton.js.map +1 -1
- package/button/OscdTextButton.js +1 -1
- package/button/OscdTextButton.js.map +1 -1
- package/button/oscd-outlined-button.d.ts +1 -1
- package/button/oscd-outlined-button.js.map +1 -1
- package/dialog/OscdDialog.js +1 -1
- package/dialog/OscdDialog.js.map +1 -1
- package/divider/OscdDivider.js +1 -1
- package/divider/OscdDivider.js.map +1 -1
- package/elevation/OscdElevation.d.ts +1 -2
- package/elevation/OscdElevation.js +3 -4
- package/elevation/OscdElevation.js.map +1 -1
- package/elevation/_elevation.scss +6 -0
- package/elevation/internal/_elevation.scss +176 -0
- package/elevation/internal/elevation-styles.css +1 -0
- package/elevation/internal/elevation-styles.css.map +1 -0
- package/elevation/internal/elevation-styles.d.ts +1 -0
- package/elevation/internal/elevation-styles.js +10 -0
- package/elevation/internal/elevation-styles.js.map +1 -0
- package/elevation/internal/elevation-styles.scss +10 -0
- package/elevation/internal/elevation.d.ts +13 -0
- package/elevation/internal/elevation.js +21 -0
- package/elevation/internal/elevation.js.map +1 -0
- package/field/OscdFilledField.js +1 -1
- package/field/OscdFilledField.js.map +1 -1
- package/field/OscdOutlinedField.js +1 -1
- package/field/OscdOutlinedField.js.map +1 -1
- package/focus/OscdFocusRing.d.ts +5 -0
- package/focus/OscdFocusRing.js +6 -0
- package/focus/OscdFocusRing.js.map +1 -0
- package/focus/_focus-ring.scss +6 -0
- package/focus/internal/_focus-ring.scss +113 -0
- package/focus/internal/focus-ring-styles.css +1 -0
- package/focus/internal/focus-ring-styles.css.map +1 -0
- package/focus/internal/focus-ring-styles.d.ts +1 -0
- package/focus/internal/focus-ring-styles.js +10 -0
- package/focus/internal/focus-ring-styles.js.map +1 -0
- package/focus/internal/focus-ring-styles.scss +10 -0
- package/focus/internal/focus-ring.d.ts +39 -0
- package/focus/internal/focus-ring.js +101 -0
- package/focus/internal/focus-ring.js.map +1 -0
- package/focus/oscd-focus-ring.d.ts +21 -0
- package/focus/oscd-focus-ring.js +23 -0
- package/focus/oscd-focus-ring.js.map +1 -0
- package/icon/OscdIcon.js +1 -1
- package/icon/OscdIcon.js.map +1 -1
- package/iconbutton/OscdFilledIconButton.js +1 -1
- package/iconbutton/OscdFilledIconButton.js.map +1 -1
- package/iconbutton/OscdFilledTonalIconButton.js +1 -1
- package/iconbutton/OscdFilledTonalIconButton.js.map +1 -1
- package/iconbutton/OscdIconButton.js +1 -1
- package/iconbutton/OscdIconButton.js.map +1 -1
- package/iconbutton/OscdOutlinedIconButton.js +1 -1
- package/iconbutton/OscdOutlinedIconButton.js.map +1 -1
- package/internal/aria/aria.d.ts +103 -0
- package/internal/aria/aria.js +81 -0
- package/internal/aria/aria.js.map +1 -0
- package/internal/aria/delegate.d.ts +54 -0
- package/internal/aria/delegate.js +176 -0
- package/internal/aria/delegate.js.map +1 -0
- package/internal/controller/attachable-controller.d.ts +114 -0
- package/internal/controller/attachable-controller.js +121 -0
- package/internal/controller/attachable-controller.js.map +1 -0
- package/internal/controller/form-submitter.d.ts +70 -0
- package/internal/controller/form-submitter.js +69 -0
- package/internal/controller/form-submitter.js.map +1 -0
- package/internal/controller/is-rtl.d.ts +14 -0
- package/internal/controller/is-rtl.js +18 -0
- package/internal/controller/is-rtl.js.map +1 -0
- package/internal/controller/string-converter.d.ts +9 -0
- package/internal/controller/string-converter.js +14 -0
- package/internal/controller/string-converter.js.map +1 -0
- package/internal/events/dispatch-hooks.d.ts +85 -0
- package/internal/events/dispatch-hooks.js +151 -0
- package/internal/events/dispatch-hooks.js.map +1 -0
- package/internal/events/form-label-activation.d.ts +55 -0
- package/internal/events/form-label-activation.js +96 -0
- package/internal/events/form-label-activation.js.map +1 -0
- package/internal/events/redispatch-event.d.ts +27 -0
- package/internal/events/redispatch-event.js +40 -0
- package/internal/events/redispatch-event.js.map +1 -0
- package/internal/motion/_animation.scss +33 -0
- package/internal/motion/animation.d.ts +80 -0
- package/internal/motion/animation.js +101 -0
- package/internal/motion/animation.js.map +1 -0
- package/internal/sass/_string-ext.scss +195 -0
- package/internal/sass/_var.scss +237 -0
- package/labs/badge/OscdBadge.d.ts +14 -0
- package/labs/badge/OscdBadge.js +15 -0
- package/labs/badge/OscdBadge.js.map +1 -0
- package/labs/badge/_badge.scss +6 -0
- package/labs/badge/internal/_badge.scss +76 -0
- package/labs/badge/internal/badge-styles.css +1 -0
- package/labs/badge/internal/badge-styles.css.map +1 -0
- package/labs/badge/internal/badge-styles.d.ts +1 -0
- package/labs/badge/internal/badge-styles.js +10 -0
- package/labs/badge/internal/badge-styles.js.map +1 -0
- package/labs/badge/internal/badge-styles.scss +10 -0
- package/labs/badge/internal/badge.d.ts +13 -0
- package/labs/badge/internal/badge.js +28 -0
- package/labs/badge/internal/badge.js.map +1 -0
- package/labs/badge/oscd-badge.d.ts +19 -0
- package/labs/badge/oscd-badge.js +21 -0
- package/labs/badge/oscd-badge.js.map +1 -0
- package/labs/behaviors/constraint-validation.d.ts +133 -0
- package/labs/behaviors/constraint-validation.js +131 -0
- package/labs/behaviors/constraint-validation.js.map +1 -0
- package/labs/behaviors/element-internals.d.ts +45 -0
- package/labs/behaviors/element-internals.js +46 -0
- package/labs/behaviors/element-internals.js.map +1 -0
- package/labs/behaviors/focusable.d.ts +39 -0
- package/labs/behaviors/focusable.js +87 -0
- package/labs/behaviors/focusable.js.map +1 -0
- package/labs/behaviors/form-associated.d.ts +199 -0
- package/labs/behaviors/form-associated.js +175 -0
- package/labs/behaviors/form-associated.js.map +1 -0
- package/labs/behaviors/mixin.d.ts +54 -0
- package/labs/behaviors/mixin.js +7 -0
- package/labs/behaviors/mixin.js.map +1 -0
- package/labs/behaviors/on-report-validity.d.ts +71 -0
- package/labs/behaviors/on-report-validity.js +289 -0
- package/labs/behaviors/on-report-validity.js.map +1 -0
- package/labs/behaviors/validators/checkbox-validator.d.ts +35 -0
- package/labs/behaviors/validators/checkbox-validator.js +34 -0
- package/labs/behaviors/validators/checkbox-validator.js.map +1 -0
- package/labs/behaviors/validators/radio-validator.d.ts +38 -0
- package/labs/behaviors/validators/radio-validator.js +67 -0
- package/labs/behaviors/validators/radio-validator.js.map +1 -0
- package/labs/behaviors/validators/select-validator.d.ts +35 -0
- package/labs/behaviors/validators/select-validator.js +35 -0
- package/labs/behaviors/validators/select-validator.js.map +1 -0
- package/labs/behaviors/validators/text-field-validator.d.ts +110 -0
- package/labs/behaviors/validators/text-field-validator.js +156 -0
- package/labs/behaviors/validators/text-field-validator.js.map +1 -0
- package/labs/behaviors/validators/validator.d.ts +96 -0
- package/labs/behaviors/validators/validator.js +73 -0
- package/labs/behaviors/validators/validator.js.map +1 -0
- package/labs/card/OscdElevatedCard.d.ts +20 -0
- package/labs/card/OscdElevatedCard.js +23 -0
- package/labs/card/OscdElevatedCard.js.map +1 -0
- package/labs/card/OscdFilledCard.d.ts +20 -0
- package/labs/card/OscdFilledCard.js +23 -0
- package/labs/card/OscdFilledCard.js.map +1 -0
- package/labs/card/OscdOutlinedCard.d.ts +20 -0
- package/labs/card/OscdOutlinedCard.js +23 -0
- package/labs/card/OscdOutlinedCard.js.map +1 -0
- package/labs/card/_elevated-card.scss +6 -0
- package/labs/card/_filled-card.scss +6 -0
- package/labs/card/_outlined-card.scss +6 -0
- package/labs/card/demo/demo.d.ts +7 -0
- package/labs/card/demo/demo.js +13 -0
- package/labs/card/demo/demo.js.map +1 -0
- package/labs/card/demo/stories.d.ts +15 -0
- package/labs/card/demo/stories.js +104 -0
- package/labs/card/demo/stories.js.map +1 -0
- package/labs/card/internal/_elevated-card.scss +35 -0
- package/labs/card/internal/_filled-card.scss +35 -0
- package/labs/card/internal/_outlined-card.scss +40 -0
- package/labs/card/internal/_shared.scss +62 -0
- package/labs/card/internal/card.d.ts +12 -0
- package/labs/card/internal/card.js +21 -0
- package/labs/card/internal/card.js.map +1 -0
- package/labs/card/internal/elevated-styles.css +1 -0
- package/labs/card/internal/elevated-styles.css.map +1 -0
- package/labs/card/internal/elevated-styles.d.ts +1 -0
- package/labs/card/internal/elevated-styles.js +10 -0
- package/labs/card/internal/elevated-styles.js.map +1 -0
- package/labs/card/internal/elevated-styles.scss +10 -0
- package/labs/card/internal/filled-styles.css +1 -0
- package/labs/card/internal/filled-styles.css.map +1 -0
- package/labs/card/internal/filled-styles.d.ts +1 -0
- package/labs/card/internal/filled-styles.js +10 -0
- package/labs/card/internal/filled-styles.js.map +1 -0
- package/labs/card/internal/filled-styles.scss +10 -0
- package/labs/card/internal/outlined-styles.css +1 -0
- package/labs/card/internal/outlined-styles.css.map +1 -0
- package/labs/card/internal/outlined-styles.d.ts +1 -0
- package/labs/card/internal/outlined-styles.js +10 -0
- package/labs/card/internal/outlined-styles.js.map +1 -0
- package/labs/card/internal/outlined-styles.scss +10 -0
- package/labs/card/internal/shared-styles.css +1 -0
- package/labs/card/internal/shared-styles.css.map +1 -0
- package/labs/card/internal/shared-styles.d.ts +1 -0
- package/labs/card/internal/shared-styles.js +10 -0
- package/labs/card/internal/shared-styles.js.map +1 -0
- package/labs/card/internal/shared-styles.scss +10 -0
- package/labs/card/oscd-elevated-card.d.ts +20 -0
- package/labs/card/oscd-elevated-card.js +23 -0
- package/labs/card/oscd-elevated-card.js.map +1 -0
- package/labs/card/oscd-filled-card.d.ts +25 -0
- package/labs/card/oscd-filled-card.js +28 -0
- package/labs/card/oscd-filled-card.js.map +1 -0
- package/labs/card/oscd-outlined-card.d.ts +20 -0
- package/labs/card/oscd-outlined-card.js +23 -0
- package/labs/card/oscd-outlined-card.js.map +1 -0
- package/list/OscdList.js +1 -1
- package/list/OscdList.js.map +1 -1
- package/list/OscdListItem.d.ts +4 -0
- package/list/OscdListItem.js +13 -1
- package/list/OscdListItem.js.map +1 -1
- package/menu/OscdMenu.js +1 -1
- package/menu/OscdMenu.js.map +1 -1
- package/menu/OscdMenuItem.js +1 -1
- package/menu/OscdMenuItem.js.map +1 -1
- package/navigation-drawer/OscdNavigationDrawer.js +2 -2
- package/navigation-drawer/OscdNavigationDrawer.js.map +1 -1
- package/navigation-drawer/OscdNavigationDrawerHeader.js +2 -2
- package/navigation-drawer/OscdNavigationDrawerHeader.js.map +1 -1
- package/package.json +76 -110
- package/radio/OscdRadio.d.ts +31 -0
- package/radio/OscdRadio.js +27 -0
- package/radio/OscdRadio.js.map +1 -0
- package/radio/demo/demo.d.ts +7 -0
- package/radio/demo/demo.js +14 -0
- package/radio/demo/demo.js.map +1 -0
- package/radio/demo/stories.d.ts +13 -0
- package/radio/demo/stories.js +97 -0
- package/radio/demo/stories.js.map +1 -0
- package/radio/internal/_radio.scss +198 -0
- package/radio/internal/radio-styles.css +1 -0
- package/radio/internal/radio-styles.css.map +1 -0
- package/radio/internal/radio-styles.d.ts +1 -0
- package/radio/internal/radio-styles.js +10 -0
- package/radio/internal/radio-styles.js.map +1 -0
- package/radio/internal/radio-styles.scss +10 -0
- package/radio/internal/radio.d.ts +59 -0
- package/radio/internal/radio.js +175 -0
- package/radio/internal/radio.js.map +1 -0
- package/radio/internal/single-selection-controller.d.ts +80 -0
- package/radio/internal/single-selection-controller.js +199 -0
- package/radio/internal/single-selection-controller.js.map +1 -0
- package/radio/oscd-radio.d.ts +32 -0
- package/radio/oscd-radio.js +34 -0
- package/radio/oscd-radio.js.map +1 -0
- package/ripple/OscdRipple.d.ts +5 -0
- package/ripple/OscdRipple.js +6 -0
- package/ripple/OscdRipple.js.map +1 -0
- package/ripple/_ripple.scss +6 -0
- package/ripple/internal/_ripple.scss +92 -0
- package/ripple/internal/ripple-styles.css +1 -0
- package/ripple/internal/ripple-styles.css.map +1 -0
- package/ripple/internal/ripple-styles.d.ts +1 -0
- package/ripple/internal/ripple-styles.js +10 -0
- package/ripple/internal/ripple-styles.js.map +1 -0
- package/ripple/internal/ripple-styles.scss +10 -0
- package/ripple/internal/ripple.d.ts +76 -0
- package/ripple/internal/ripple.js +425 -0
- package/ripple/internal/ripple.js.map +1 -0
- package/ripple/oscd-ripple.d.ts +29 -0
- package/ripple/oscd-ripple.js +31 -0
- package/ripple/oscd-ripple.js.map +1 -0
- package/select/OscdFilledSelect.js +1 -1
- package/select/OscdFilledSelect.js.map +1 -1
- package/select/OscdOutlinedSelect.js +1 -1
- package/select/OscdOutlinedSelect.js.map +1 -1
- package/select/OscdSelectOption.js +1 -1
- package/select/OscdSelectOption.js.map +1 -1
- package/tabs/OscdPrimaryTab.js +1 -1
- package/tabs/OscdPrimaryTab.js.map +1 -1
- package/tabs/OscdSecondaryTab.js +1 -1
- package/tabs/OscdSecondaryTab.js.map +1 -1
- package/tabs/OscdTabs.js +1 -1
- package/tabs/OscdTabs.js.map +1 -1
- package/textfield/OscdFilledTextField.js +5 -2
- package/textfield/OscdFilledTextField.js.map +1 -1
- package/textfield/OscdOutlinedTextField.js +5 -2
- package/textfield/OscdOutlinedTextField.js.map +1 -1
- package/tokens/_index.scss +66 -0
- package/tokens/_md-comp-assist-chip.scss +153 -0
- package/tokens/_md-comp-badge.scss +39 -0
- package/tokens/_md-comp-checkbox.scss +156 -0
- package/tokens/_md-comp-circular-progress.scss +79 -0
- package/tokens/_md-comp-dialog.scss +112 -0
- package/tokens/_md-comp-divider.scss +43 -0
- package/tokens/_md-comp-elevated-button.scss +143 -0
- package/tokens/_md-comp-elevated-card.scss +80 -0
- package/tokens/_md-comp-elevation.scss +48 -0
- package/tokens/_md-comp-fab-branded.scss +155 -0
- package/tokens/_md-comp-fab.scss +296 -0
- package/tokens/_md-comp-filled-button.scss +143 -0
- package/tokens/_md-comp-filled-card.scss +80 -0
- package/tokens/_md-comp-filled-field.scss +293 -0
- package/tokens/_md-comp-filled-icon-button.scss +119 -0
- package/tokens/_md-comp-filled-select.scss +198 -0
- package/tokens/_md-comp-filled-text-field.scss +200 -0
- package/tokens/_md-comp-filled-tonal-button.scss +143 -0
- package/tokens/_md-comp-filled-tonal-icon-button.scss +123 -0
- package/tokens/_md-comp-filter-chip.scss +265 -0
- package/tokens/_md-comp-focus-ring.scss +78 -0
- package/tokens/_md-comp-full-screen-dialog.scss +25 -0
- package/tokens/_md-comp-icon-button.scss +94 -0
- package/tokens/_md-comp-icon.scss +46 -0
- package/tokens/_md-comp-input-chip.scss +247 -0
- package/tokens/_md-comp-item.scss +88 -0
- package/tokens/_md-comp-linear-progress.scss +64 -0
- package/tokens/_md-comp-list-item.scss +173 -0
- package/tokens/_md-comp-list.scss +44 -0
- package/tokens/_md-comp-menu-item.scss +125 -0
- package/tokens/_md-comp-menu.scss +59 -0
- package/tokens/_md-comp-navigation-bar.scss +44 -0
- package/tokens/_md-comp-navigation-drawer.scss +44 -0
- package/tokens/_md-comp-outlined-button.scss +139 -0
- package/tokens/_md-comp-outlined-card.scss +86 -0
- package/tokens/_md-comp-outlined-field.scss +268 -0
- package/tokens/_md-comp-outlined-icon-button.scss +117 -0
- package/tokens/_md-comp-outlined-segmented-button.scss +123 -0
- package/tokens/_md-comp-outlined-select.scss +186 -0
- package/tokens/_md-comp-outlined-text-field.scss +187 -0
- package/tokens/_md-comp-primary-tab.scss +160 -0
- package/tokens/_md-comp-radio.scss +86 -0
- package/tokens/_md-comp-ripple.scss +48 -0
- package/tokens/_md-comp-secondary-tab.scss +158 -0
- package/tokens/_md-comp-slider.scss +117 -0
- package/tokens/_md-comp-suggestion-chip.scss +157 -0
- package/tokens/_md-comp-switch.scss +187 -0
- package/tokens/_md-comp-test-table.scss +43 -0
- package/tokens/_md-comp-text-button.scss +132 -0
- package/tokens/_md-ref-palette.scss +112 -0
- package/tokens/_md-ref-typeface.scss +46 -0
- package/tokens/_md-sys-color.scss +119 -0
- package/tokens/_md-sys-elevation.scss +31 -0
- package/tokens/_md-sys-motion.scss +12 -0
- package/tokens/_md-sys-shape.scss +102 -0
- package/tokens/_md-sys-state.scss +12 -0
- package/tokens/_md-sys-typescale.scss +149 -0
- package/tokens/internal/_shape.scss +93 -0
- package/tokens/internal/_validate.scss +109 -0
- package/tokens/v0_192/_index.scss +107 -0
- package/tokens/v0_192/_md-comp-assist-chip.scss +111 -0
- package/tokens/v0_192/_md-comp-badge.scss +61 -0
- package/tokens/v0_192/_md-comp-banner.scss +76 -0
- package/tokens/v0_192/_md-comp-bottom-app-bar.scss +36 -0
- package/tokens/v0_192/_md-comp-carousel-item.scss +66 -0
- package/tokens/v0_192/_md-comp-checkbox.scss +129 -0
- package/tokens/v0_192/_md-comp-circular-progress-indicator.scss +41 -0
- package/tokens/v0_192/_md-comp-data-table.scss +99 -0
- package/tokens/v0_192/_md-comp-date-input-modal.scss +90 -0
- package/tokens/v0_192/_md-comp-date-picker-docked.scss +247 -0
- package/tokens/v0_192/_md-comp-date-picker-modal.scss +306 -0
- package/tokens/v0_192/_md-comp-dialog.scss +124 -0
- package/tokens/v0_192/_md-comp-divider.scss +28 -0
- package/tokens/v0_192/_md-comp-elevated-button.scss +92 -0
- package/tokens/v0_192/_md-comp-elevated-card.scss +60 -0
- package/tokens/v0_192/_md-comp-extended-fab-branded.scss +89 -0
- package/tokens/v0_192/_md-comp-extended-fab-primary.scss +97 -0
- package/tokens/v0_192/_md-comp-extended-fab-secondary.scss +98 -0
- package/tokens/v0_192/_md-comp-extended-fab-surface.scss +93 -0
- package/tokens/v0_192/_md-comp-extended-fab-tertiary.scss +98 -0
- package/tokens/v0_192/_md-comp-fab-branded-large.scss +63 -0
- package/tokens/v0_192/_md-comp-fab-branded.scss +63 -0
- package/tokens/v0_192/_md-comp-fab-primary-large.scss +68 -0
- package/tokens/v0_192/_md-comp-fab-primary-small.scss +68 -0
- package/tokens/v0_192/_md-comp-fab-primary.scss +68 -0
- package/tokens/v0_192/_md-comp-fab-secondary-large.scss +69 -0
- package/tokens/v0_192/_md-comp-fab-secondary-small.scss +69 -0
- package/tokens/v0_192/_md-comp-fab-secondary.scss +69 -0
- package/tokens/v0_192/_md-comp-fab-surface-large.scss +67 -0
- package/tokens/v0_192/_md-comp-fab-surface-small.scss +67 -0
- package/tokens/v0_192/_md-comp-fab-surface.scss +67 -0
- package/tokens/v0_192/_md-comp-fab-tertiary-large.scss +69 -0
- package/tokens/v0_192/_md-comp-fab-tertiary-small.scss +69 -0
- package/tokens/v0_192/_md-comp-fab-tertiary.scss +69 -0
- package/tokens/v0_192/_md-comp-filled-autocomplete.scss +239 -0
- package/tokens/v0_192/_md-comp-filled-button.scss +92 -0
- package/tokens/v0_192/_md-comp-filled-card.scss +62 -0
- package/tokens/v0_192/_md-comp-filled-icon-button.scss +83 -0
- package/tokens/v0_192/_md-comp-filled-menu-button.scss +101 -0
- package/tokens/v0_192/_md-comp-filled-select.scss +273 -0
- package/tokens/v0_192/_md-comp-filled-text-field.scss +193 -0
- package/tokens/v0_192/_md-comp-filled-tonal-button.scss +102 -0
- package/tokens/v0_192/_md-comp-filled-tonal-icon-button.scss +90 -0
- package/tokens/v0_192/_md-comp-filter-chip.scss +210 -0
- package/tokens/v0_192/_md-comp-full-screen-dialog.scss +114 -0
- package/tokens/v0_192/_md-comp-icon-button.scss +74 -0
- package/tokens/v0_192/_md-comp-input-chip.scss +187 -0
- package/tokens/v0_192/_md-comp-linear-progress-indicator.scss +43 -0
- package/tokens/v0_192/_md-comp-list.scss +255 -0
- package/tokens/v0_192/_md-comp-menu.scss +44 -0
- package/tokens/v0_192/_md-comp-navigation-bar.scss +115 -0
- package/tokens/v0_192/_md-comp-navigation-drawer.scss +165 -0
- package/tokens/v0_192/_md-comp-navigation-rail.scss +119 -0
- package/tokens/v0_192/_md-comp-outlined-autocomplete.scss +229 -0
- package/tokens/v0_192/_md-comp-outlined-button.scss +87 -0
- package/tokens/v0_192/_md-comp-outlined-card.scss +66 -0
- package/tokens/v0_192/_md-comp-outlined-icon-button.scss +83 -0
- package/tokens/v0_192/_md-comp-outlined-menu-button.scss +97 -0
- package/tokens/v0_192/_md-comp-outlined-segmented-button.scss +115 -0
- package/tokens/v0_192/_md-comp-outlined-select.scss +263 -0
- package/tokens/v0_192/_md-comp-outlined-text-field.scss +174 -0
- package/tokens/v0_192/_md-comp-plain-tooltip.scss +58 -0
- package/tokens/v0_192/_md-comp-primary-navigation-tab.scss +124 -0
- package/tokens/v0_192/_md-comp-radio-button.scss +71 -0
- package/tokens/v0_192/_md-comp-rich-tooltip.scss +122 -0
- package/tokens/v0_192/_md-comp-scrim.scss +28 -0
- package/tokens/v0_192/_md-comp-search-bar.scss +100 -0
- package/tokens/v0_192/_md-comp-search-view.scss +94 -0
- package/tokens/v0_192/_md-comp-secondary-navigation-tab.scss +87 -0
- package/tokens/v0_192/_md-comp-sheet-bottom.scss +46 -0
- package/tokens/v0_192/_md-comp-sheet-floating.scss +35 -0
- package/tokens/v0_192/_md-comp-sheet-side.scss +94 -0
- package/tokens/v0_192/_md-comp-slider.scss +118 -0
- package/tokens/v0_192/_md-comp-snackbar.scss +130 -0
- package/tokens/v0_192/_md-comp-standard-menu-button.scss +101 -0
- package/tokens/v0_192/_md-comp-suggestion-chip.scss +127 -0
- package/tokens/v0_192/_md-comp-switch.scss +141 -0
- package/tokens/v0_192/_md-comp-text-button.scss +80 -0
- package/tokens/v0_192/_md-comp-time-input.scss +220 -0
- package/tokens/v0_192/_md-comp-time-picker.scss +267 -0
- package/tokens/v0_192/_md-comp-top-app-bar-large.scss +64 -0
- package/tokens/v0_192/_md-comp-top-app-bar-medium.scss +64 -0
- package/tokens/v0_192/_md-comp-top-app-bar-small-centered.scss +71 -0
- package/tokens/v0_192/_md-comp-top-app-bar-small.scss +67 -0
- package/tokens/v0_192/_md-ref-palette.scss +109 -0
- package/tokens/v0_192/_md-ref-typeface.scss +23 -0
- package/tokens/v0_192/_md-sys-color.scss +135 -0
- package/tokens/v0_192/_md-sys-elevation.scss +24 -0
- package/tokens/v0_192/_md-sys-motion.scss +55 -0
- package/tokens/v0_192/_md-sys-shape.scss +33 -0
- package/tokens/v0_192/_md-sys-state.scss +22 -0
- package/tokens/v0_192/_md-sys-typescale.scss +286 -0
- package/tokens/v0_192/index.test.css +1 -0
- package/tokens/v0_192/index.test.css.map +1 -0
- package/tokens/v0_192/index.test.scss +584 -0
- package/tokens/v0_192/lib.test.css +1 -0
- package/tokens/v0_192/lib.test.css.map +1 -0
- package/tokens/v0_192/lib.test.scss +663 -0
- package/utils/storybook/getStorybookHelpers.js +0 -1
- package/utils/storybook/getStorybookHelpers.js.map +1 -1
- package/utils/storybook/scopedWcDecorator.js +1 -0
- package/utils/storybook/scopedWcDecorator.js.map +1 -1
- package/utils/storybook/stories/components/knob-ui-components.d.ts +103 -0
- package/utils/storybook/stories/components/knob-ui-components.js +414 -0
- package/utils/storybook/stories/components/knob-ui-components.js.map +1 -0
- package/utils/storybook/stories/components/stories-renderer.d.ts +40 -0
- package/utils/storybook/stories/components/stories-renderer.js +204 -0
- package/utils/storybook/stories/components/stories-renderer.js.map +1 -0
- package/utils/storybook/stories/components/story-knob-panel.d.ts +53 -0
- package/utils/storybook/stories/components/story-knob-panel.js +333 -0
- package/utils/storybook/stories/components/story-knob-panel.js.map +1 -0
- package/utils/storybook/stories/components/story-renderer.d.ts +27 -0
- package/utils/storybook/stories/components/story-renderer.js +84 -0
- package/utils/storybook/stories/components/story-renderer.js.map +1 -0
- package/utils/storybook/stories/index.d.ts +8 -0
- package/utils/storybook/stories/index.js +11 -0
- package/utils/storybook/stories/index.js.map +1 -0
- package/utils/storybook/stories/knobs.d.ts +143 -0
- package/utils/storybook/stories/knobs.js +177 -0
- package/utils/storybook/stories/knobs.js.map +1 -0
- package/utils/storybook/stories/material-collection.d.ts +75 -0
- package/utils/storybook/stories/material-collection.js +59 -0
- package/utils/storybook/stories/material-collection.js.map +1 -0
- package/utils/storybook/stories/story.d.ts +85 -0
- package/utils/storybook/stories/story.js +142 -0
- package/utils/storybook/stories/story.js.map +1 -0
- package/utils/storybook/stories/theme-loader.d.ts +13 -0
- package/utils/storybook/stories/theme-loader.js +43 -0
- package/utils/storybook/stories/theme-loader.js.map +1 -0
- package/utils/storybook/themingDecorator.d.ts +15 -2
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { isServer } from 'lit';
|
|
7
|
+
import { internals } from './element-internals.js';
|
|
8
|
+
/**
|
|
9
|
+
* A symbol property used to create a constraint validation `Validator`.
|
|
10
|
+
* Required for all `mixinConstraintValidation()` elements.
|
|
11
|
+
*/
|
|
12
|
+
export const createValidator = Symbol('createValidator');
|
|
13
|
+
/**
|
|
14
|
+
* A symbol property used to return an anchor for constraint validation popups.
|
|
15
|
+
* Required for all `mixinConstraintValidation()` elements.
|
|
16
|
+
*/
|
|
17
|
+
export const getValidityAnchor = Symbol('getValidityAnchor');
|
|
18
|
+
// Private symbol members, used to avoid name clashing.
|
|
19
|
+
const privateValidator = Symbol('privateValidator');
|
|
20
|
+
const privateSyncValidity = Symbol('privateSyncValidity');
|
|
21
|
+
const privateCustomValidationMessage = Symbol('privateCustomValidationMessage');
|
|
22
|
+
/**
|
|
23
|
+
* Mixes in constraint validation APIs for an element.
|
|
24
|
+
*
|
|
25
|
+
* See https://developer.mozilla.org/en-US/docs/Web/HTML/Constraint_validation
|
|
26
|
+
* for more details.
|
|
27
|
+
*
|
|
28
|
+
* Implementations must provide a validator to cache and compute its validity,
|
|
29
|
+
* along with a shadow root element to anchor validation popups to.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* const baseClass = mixinConstraintValidation(
|
|
34
|
+
* mixinFormAssociated(mixinElementInternals(LitElement))
|
|
35
|
+
* );
|
|
36
|
+
*
|
|
37
|
+
* class MyCheckbox extends baseClass {
|
|
38
|
+
* \@property({type: Boolean}) checked = false;
|
|
39
|
+
* \@property({type: Boolean}) required = false;
|
|
40
|
+
*
|
|
41
|
+
* [createValidator]() {
|
|
42
|
+
* return new CheckboxValidator(() => this);
|
|
43
|
+
* }
|
|
44
|
+
*
|
|
45
|
+
* [getValidityAnchor]() {
|
|
46
|
+
* return this.renderRoot.querySelector('.root');
|
|
47
|
+
* }
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @param base The class to mix functionality into.
|
|
52
|
+
* @return The provided class with `ConstraintValidation` mixed in.
|
|
53
|
+
*/
|
|
54
|
+
export function mixinConstraintValidation(base) {
|
|
55
|
+
var _a;
|
|
56
|
+
class ConstraintValidationElement extends base {
|
|
57
|
+
constructor() {
|
|
58
|
+
super(...arguments);
|
|
59
|
+
/**
|
|
60
|
+
* Needed for Safari, see https://bugs.webkit.org/show_bug.cgi?id=261432
|
|
61
|
+
* Replace with this[internals].validity.customError when resolved.
|
|
62
|
+
*/
|
|
63
|
+
this[_a] = '';
|
|
64
|
+
}
|
|
65
|
+
get validity() {
|
|
66
|
+
this[privateSyncValidity]();
|
|
67
|
+
return this[internals].validity;
|
|
68
|
+
}
|
|
69
|
+
get validationMessage() {
|
|
70
|
+
this[privateSyncValidity]();
|
|
71
|
+
return this[internals].validationMessage;
|
|
72
|
+
}
|
|
73
|
+
get willValidate() {
|
|
74
|
+
this[privateSyncValidity]();
|
|
75
|
+
return this[internals].willValidate;
|
|
76
|
+
}
|
|
77
|
+
checkValidity() {
|
|
78
|
+
this[privateSyncValidity]();
|
|
79
|
+
return this[internals].checkValidity();
|
|
80
|
+
}
|
|
81
|
+
reportValidity() {
|
|
82
|
+
this[privateSyncValidity]();
|
|
83
|
+
return this[internals].reportValidity();
|
|
84
|
+
}
|
|
85
|
+
setCustomValidity(error) {
|
|
86
|
+
this[privateCustomValidationMessage] = error;
|
|
87
|
+
this[privateSyncValidity]();
|
|
88
|
+
}
|
|
89
|
+
requestUpdate(name, oldValue, options) {
|
|
90
|
+
super.requestUpdate(name, oldValue, options);
|
|
91
|
+
this[privateSyncValidity]();
|
|
92
|
+
}
|
|
93
|
+
firstUpdated(changed) {
|
|
94
|
+
super.firstUpdated(changed);
|
|
95
|
+
// Sync the validity again when the element first renders, since the
|
|
96
|
+
// validity anchor is now available.
|
|
97
|
+
//
|
|
98
|
+
// Elements that `delegatesFocus: true` to an `<input>` will throw an
|
|
99
|
+
// error in Chrome and Safari when a form tries to submit or call
|
|
100
|
+
// `form.reportValidity()`:
|
|
101
|
+
// "An invalid form control with name='' is not focusable"
|
|
102
|
+
//
|
|
103
|
+
// The validity anchor MUST be provided in `internals.setValidity()` and
|
|
104
|
+
// MUST be the `<input>` element rendered.
|
|
105
|
+
//
|
|
106
|
+
// See https://lit.dev/playground/#gist=6c26e418e0010f7a5aac15005cde8bde
|
|
107
|
+
// for a reproduction.
|
|
108
|
+
this[privateSyncValidity]();
|
|
109
|
+
}
|
|
110
|
+
[(_a = privateCustomValidationMessage, privateSyncValidity)]() {
|
|
111
|
+
if (isServer) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (!this[privateValidator]) {
|
|
115
|
+
this[privateValidator] = this[createValidator]();
|
|
116
|
+
}
|
|
117
|
+
const { validity, validationMessage: nonCustomValidationMessage } = this[privateValidator].getValidity();
|
|
118
|
+
const customError = !!this[privateCustomValidationMessage];
|
|
119
|
+
const validationMessage = this[privateCustomValidationMessage] || nonCustomValidationMessage;
|
|
120
|
+
this[internals].setValidity({ ...validity, customError }, validationMessage, this[getValidityAnchor]() ?? undefined);
|
|
121
|
+
}
|
|
122
|
+
[createValidator]() {
|
|
123
|
+
throw new Error(`Implement [createValidator] in ${this.constructor.name}`);
|
|
124
|
+
}
|
|
125
|
+
[getValidityAnchor]() {
|
|
126
|
+
throw new Error(`Implement [getValidityAnchor] in ${this.constructor.name}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return ConstraintValidationElement;
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=constraint-validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constraint-validation.js","sourceRoot":"","sources":["constraint-validation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAmD,MAAM,KAAK,CAAC;AAEhF,OAAO,EAAE,SAAS,EAAwB,MAAM,wBAAwB,CAAC;AA6FzE;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAEzD;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC;AAE7D,uDAAuD;AACvD,MAAM,gBAAgB,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC;AACpD,MAAM,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC;AAC1D,MAAM,8BAA8B,GAAG,MAAM,CAAC,gCAAgC,CAAC,CAAC;AAEhF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,yBAAyB,CAEvC,IAAO;;IACP,MAAe,2BACb,SAAQ,IAAI;QADd;;YAwBE;;;eAGG;YACH,QAAgC,GAAG,EAAE,CAAC;QA8ExC,CAAC;QAtGC,IAAI,QAAQ;YACV,IAAI,CAAC,mBAAmB,CAAC,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC;QAClC,CAAC;QAED,IAAI,iBAAiB;YACnB,IAAI,CAAC,mBAAmB,CAAC,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,iBAAiB,CAAC;QAC3C,CAAC;QAED,IAAI,YAAY;YACd,IAAI,CAAC,mBAAmB,CAAC,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,YAAY,CAAC;QACtC,CAAC;QAaD,aAAa;YACX,IAAI,CAAC,mBAAmB,CAAC,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,aAAa,EAAE,CAAC;QACzC,CAAC;QAED,cAAc;YACZ,IAAI,CAAC,mBAAmB,CAAC,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,cAAc,EAAE,CAAC;QAC1C,CAAC;QAED,iBAAiB,CAAC,KAAa;YAC7B,IAAI,CAAC,8BAA8B,CAAC,GAAG,KAAK,CAAC;YAC7C,IAAI,CAAC,mBAAmB,CAAC,EAAE,CAAC;QAC9B,CAAC;QAEQ,aAAa,CACpB,IAAkB,EAClB,QAAkB,EAClB,OAA6B;YAE7B,KAAK,CAAC,aAAa,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;YAC7C,IAAI,CAAC,mBAAmB,CAAC,EAAE,CAAC;QAC9B,CAAC;QAEQ,YAAY,CAAC,OAAuB;YAC3C,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;YAC5B,oEAAoE;YACpE,oCAAoC;YACpC,EAAE;YACF,qEAAqE;YACrE,iEAAiE;YACjE,2BAA2B;YAC3B,0DAA0D;YAC1D,EAAE;YACF,wEAAwE;YACxE,0CAA0C;YAC1C,EAAE;YACF,wEAAwE;YACxE,sBAAsB;YACtB,IAAI,CAAC,mBAAmB,CAAC,EAAE,CAAC;QAC9B,CAAC;QAED,OA5CC,8BAA8B,EA4C9B,mBAAmB,EAAC;YACnB,IAAI,QAAQ,EAAE,CAAC;gBACb,OAAO;YACT,CAAC;YAED,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,CAAC;gBAC5B,IAAI,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC;YACnD,CAAC;YAED,MAAM,EAAE,QAAQ,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,GAC/D,IAAI,CAAC,gBAAgB,CAAC,CAAC,WAAW,EAAE,CAAC;YAEvC,MAAM,WAAW,GAAG,CAAC,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;YAC3D,MAAM,iBAAiB,GACrB,IAAI,CAAC,8BAA8B,CAAC,IAAI,0BAA0B,CAAC;YAErE,IAAI,CAAC,SAAS,CAAC,CAAC,WAAW,CACzB,EAAE,GAAG,QAAQ,EAAE,WAAW,EAAE,EAC5B,iBAAiB,EACjB,IAAI,CAAC,iBAAiB,CAAC,EAAE,IAAI,SAAS,CACvC,CAAC;QACJ,CAAC;QAED,CAAC,eAAe,CAAC;YACf,MAAM,IAAI,KAAK,CACb,kCAAkC,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAC1D,CAAC;QACJ,CAAC;QAED,CAAC,iBAAiB,CAAC;YACjB,MAAM,IAAI,KAAK,CACb,oCAAoC,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAC5D,CAAC;QACJ,CAAC;KACF;IAED,OAAO,2BAA2B,CAAC;AACrC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { isServer, LitElement, PropertyDeclaration, PropertyValues } from 'lit';\n\nimport { internals, WithElementInternals } from './element-internals.js';\nimport { FormAssociated } from './form-associated.js';\nimport { MixinBase, MixinReturn } from './mixin.js';\nimport { Validator } from './validators/validator.js';\n\n/**\n * A form associated element that provides constraint validation APIs.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Constraint_validation\n */\nexport interface ConstraintValidation extends FormAssociated {\n /**\n * Returns a ValidityState object that represents the validity states of the\n * element.\n *\n * https://developer.mozilla.org/en-US/docs/Web/API/ValidityState\n */\n readonly validity: ValidityState;\n\n /**\n * Returns a validation error message or an empty string if the element is\n * valid.\n *\n * https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/validationMessage\n */\n readonly validationMessage: string;\n\n /**\n * Returns whether an element will successfully validate based on forms\n * validation rules and constraints.\n *\n * Disabled and readonly elements will not validate.\n *\n * https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/willValidate\n */\n readonly willValidate: boolean;\n\n /**\n * Checks the element's constraint validation and returns true if the element\n * is valid or false if not.\n *\n * If invalid, this method will dispatch an `invalid` event.\n *\n * https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/checkValidity\n *\n * @return true if the element is valid, or false if not.\n */\n checkValidity(): boolean;\n\n /**\n * Checks the element's constraint validation and returns true if the element\n * is valid or false if not.\n *\n * If invalid, this method will dispatch a cancelable `invalid` event. If not\n * canceled, a the current `validationMessage` will be reported to the user.\n *\n * https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/reportValidity\n *\n * @return true if the element is valid, or false if not.\n */\n reportValidity(): boolean;\n\n /**\n * Sets the element's constraint validation error message. When set to a\n * non-empty string, `validity.customError` will be true and\n * `validationMessage` will display the provided error.\n *\n * Use this method to customize error messages reported.\n *\n * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setCustomValidity\n *\n * @param error The error message to display, or an empty string.\n */\n setCustomValidity(error: string): void;\n\n /**\n * Creates and returns a `Validator` that is used to compute and cache\n * validity for the element.\n *\n * A validator that caches validity is important since constraint validation\n * must be computed synchronously and frequently in response to constraint\n * validation property changes.\n */\n [createValidator](): Validator<unknown>;\n\n /**\n * Returns shadow DOM child that is used as the anchor for the platform\n * `reportValidity()` popup. This is often the root element or the inner\n * focus-delegated element.\n */\n [getValidityAnchor](): HTMLElement | null;\n}\n\n/**\n * A symbol property used to create a constraint validation `Validator`.\n * Required for all `mixinConstraintValidation()` elements.\n */\nexport const createValidator = Symbol('createValidator');\n\n/**\n * A symbol property used to return an anchor for constraint validation popups.\n * Required for all `mixinConstraintValidation()` elements.\n */\nexport const getValidityAnchor = Symbol('getValidityAnchor');\n\n// Private symbol members, used to avoid name clashing.\nconst privateValidator = Symbol('privateValidator');\nconst privateSyncValidity = Symbol('privateSyncValidity');\nconst privateCustomValidationMessage = Symbol('privateCustomValidationMessage');\n\n/**\n * Mixes in constraint validation APIs for an element.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTML/Constraint_validation\n * for more details.\n *\n * Implementations must provide a validator to cache and compute its validity,\n * along with a shadow root element to anchor validation popups to.\n *\n * @example\n * ```ts\n * const baseClass = mixinConstraintValidation(\n * mixinFormAssociated(mixinElementInternals(LitElement))\n * );\n *\n * class MyCheckbox extends baseClass {\n * \\@property({type: Boolean}) checked = false;\n * \\@property({type: Boolean}) required = false;\n *\n * [createValidator]() {\n * return new CheckboxValidator(() => this);\n * }\n *\n * [getValidityAnchor]() {\n * return this.renderRoot.querySelector('.root');\n * }\n * }\n * ```\n *\n * @param base The class to mix functionality into.\n * @return The provided class with `ConstraintValidation` mixed in.\n */\nexport function mixinConstraintValidation<\n T extends MixinBase<LitElement & FormAssociated & WithElementInternals>,\n>(base: T): MixinReturn<T, ConstraintValidation> {\n abstract class ConstraintValidationElement\n extends base\n implements ConstraintValidation\n {\n get validity() {\n this[privateSyncValidity]();\n return this[internals].validity;\n }\n\n get validationMessage() {\n this[privateSyncValidity]();\n return this[internals].validationMessage;\n }\n\n get willValidate() {\n this[privateSyncValidity]();\n return this[internals].willValidate;\n }\n\n /**\n * A validator instance created from `[createValidator]()`.\n */\n [privateValidator]?: Validator<unknown>;\n\n /**\n * Needed for Safari, see https://bugs.webkit.org/show_bug.cgi?id=261432\n * Replace with this[internals].validity.customError when resolved.\n */\n [privateCustomValidationMessage] = '';\n\n checkValidity() {\n this[privateSyncValidity]();\n return this[internals].checkValidity();\n }\n\n reportValidity() {\n this[privateSyncValidity]();\n return this[internals].reportValidity();\n }\n\n setCustomValidity(error: string) {\n this[privateCustomValidationMessage] = error;\n this[privateSyncValidity]();\n }\n\n override requestUpdate(\n name?: PropertyKey,\n oldValue?: unknown,\n options?: PropertyDeclaration,\n ) {\n super.requestUpdate(name, oldValue, options);\n this[privateSyncValidity]();\n }\n\n override firstUpdated(changed: PropertyValues) {\n super.firstUpdated(changed);\n // Sync the validity again when the element first renders, since the\n // validity anchor is now available.\n //\n // Elements that `delegatesFocus: true` to an `<input>` will throw an\n // error in Chrome and Safari when a form tries to submit or call\n // `form.reportValidity()`:\n // \"An invalid form control with name='' is not focusable\"\n //\n // The validity anchor MUST be provided in `internals.setValidity()` and\n // MUST be the `<input>` element rendered.\n //\n // See https://lit.dev/playground/#gist=6c26e418e0010f7a5aac15005cde8bde\n // for a reproduction.\n this[privateSyncValidity]();\n }\n\n [privateSyncValidity]() {\n if (isServer) {\n return;\n }\n\n if (!this[privateValidator]) {\n this[privateValidator] = this[createValidator]();\n }\n\n const { validity, validationMessage: nonCustomValidationMessage } =\n this[privateValidator].getValidity();\n\n const customError = !!this[privateCustomValidationMessage];\n const validationMessage =\n this[privateCustomValidationMessage] || nonCustomValidationMessage;\n\n this[internals].setValidity(\n { ...validity, customError },\n validationMessage,\n this[getValidityAnchor]() ?? undefined,\n );\n }\n\n [createValidator](): Validator<unknown> {\n throw new Error(\n `Implement [createValidator] in ${this.constructor.name}`,\n );\n }\n\n [getValidityAnchor](): HTMLElement | null {\n throw new Error(\n `Implement [getValidityAnchor] in ${this.constructor.name}`,\n );\n }\n }\n\n return ConstraintValidationElement;\n}\n"]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { LitElement } from 'lit';
|
|
7
|
+
import { MixinBase, MixinReturn } from './mixin.js';
|
|
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>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* A unique symbol used for protected access to an instance's
|
|
8
|
+
* `ElementInternals`.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* class MyElement extends mixinElementInternals(LitElement) {
|
|
13
|
+
* constructor() {
|
|
14
|
+
* super();
|
|
15
|
+
* this[internals].role = 'button';
|
|
16
|
+
* }
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export const internals = Symbol('internals');
|
|
21
|
+
// Private symbols
|
|
22
|
+
const privateInternals = Symbol('privateInternals');
|
|
23
|
+
/**
|
|
24
|
+
* Mixes in an attached `ElementInternals` instance.
|
|
25
|
+
*
|
|
26
|
+
* This mixin is only needed when other shared code needs access to a
|
|
27
|
+
* component's `ElementInternals`, such as form-associated mixins.
|
|
28
|
+
*
|
|
29
|
+
* @param base The class to mix functionality into.
|
|
30
|
+
* @return The provided class with `WithElementInternals` mixed in.
|
|
31
|
+
*/
|
|
32
|
+
export function mixinElementInternals(base) {
|
|
33
|
+
class WithElementInternalsElement extends base {
|
|
34
|
+
get [internals]() {
|
|
35
|
+
// Create internals in getter so that it can be used in methods called on
|
|
36
|
+
// construction in `ReactiveElement`, such as `requestUpdate()`.
|
|
37
|
+
if (!this[privateInternals]) {
|
|
38
|
+
// Cast needed for closure
|
|
39
|
+
this[privateInternals] = this.attachInternals();
|
|
40
|
+
}
|
|
41
|
+
return this[privateInternals];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return WithElementInternalsElement;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=element-internals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element-internals.js","sourceRoot":"","sources":["element-internals.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;AAgB7C,kBAAkB;AAClB,MAAM,gBAAgB,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC;AAEpD;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CACnC,IAAO;IAEP,MAAe,2BACb,SAAQ,IAAI;QAGZ,IAAI,CAAC,SAAS,CAAC;YACb,yEAAyE;YACzE,gEAAgE;YAChE,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,CAAC;gBAC5B,0BAA0B;gBAC1B,IAAI,CAAC,gBAAgB,CAAC,GAAI,IAAoB,CAAC,eAAe,EAAE,CAAC;YACnE,CAAC;YAED,OAAO,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAChC,CAAC;KAGF;IAED,OAAO,2BAA2B,CAAC;AACrC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { LitElement } from 'lit';\n\nimport { MixinBase, MixinReturn } from './mixin.js';\n\n/**\n * A unique symbol used for protected access to an instance's\n * `ElementInternals`.\n *\n * @example\n * ```ts\n * class MyElement extends mixinElementInternals(LitElement) {\n * constructor() {\n * super();\n * this[internals].role = 'button';\n * }\n * }\n * ```\n */\nexport const internals = Symbol('internals');\n\n/**\n * An instance with an `internals` symbol property for the component's\n * `ElementInternals`.\n *\n * Use this when protected access is needed for an instance's `ElementInternals`\n * from other files. A unique symbol is used to access the internals.\n */\nexport interface WithElementInternals {\n /**\n * An instance's `ElementInternals`.\n */\n [internals]: ElementInternals;\n}\n\n// Private symbols\nconst privateInternals = Symbol('privateInternals');\n\n/**\n * Mixes in an attached `ElementInternals` instance.\n *\n * This mixin is only needed when other shared code needs access to a\n * component's `ElementInternals`, such as form-associated mixins.\n *\n * @param base The class to mix functionality into.\n * @return The provided class with `WithElementInternals` mixed in.\n */\nexport function mixinElementInternals<T extends MixinBase<LitElement>>(\n base: T,\n): MixinReturn<T, WithElementInternals> {\n abstract class WithElementInternalsElement\n extends base\n implements WithElementInternals\n {\n get [internals]() {\n // Create internals in getter so that it can be used in methods called on\n // construction in `ReactiveElement`, such as `requestUpdate()`.\n if (!this[privateInternals]) {\n // Cast needed for closure\n this[privateInternals] = (this as HTMLElement).attachInternals();\n }\n\n return this[privateInternals];\n }\n\n [privateInternals]?: ElementInternals;\n }\n\n return WithElementInternalsElement;\n}\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { LitElement } from 'lit';
|
|
7
|
+
import { MixinBase, MixinReturn } from './mixin.js';
|
|
8
|
+
/**
|
|
9
|
+
* An element that can enable and disable `tabindex` focusability.
|
|
10
|
+
*/
|
|
11
|
+
export interface Focusable {
|
|
12
|
+
/**
|
|
13
|
+
* Whether or not the element can be focused. Defaults to true. Set to false
|
|
14
|
+
* to disable focusing (unless a user has set a `tabindex`).
|
|
15
|
+
*/
|
|
16
|
+
[isFocusable]: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A property symbol that indicates whether or not a `Focusable` element can be
|
|
20
|
+
* focused.
|
|
21
|
+
*/
|
|
22
|
+
export declare const isFocusable: unique symbol;
|
|
23
|
+
/**
|
|
24
|
+
* Mixes in focusable functionality for a class.
|
|
25
|
+
*
|
|
26
|
+
* Elements can enable and disable their focusability with the `isFocusable`
|
|
27
|
+
* symbol property. Changing `tabIndex` will trigger a lit render, meaning
|
|
28
|
+
* `this.tabIndex` can be used in template expressions.
|
|
29
|
+
*
|
|
30
|
+
* This mixin will preserve externally-set tabindices. If an element turns off
|
|
31
|
+
* focusability, but a user sets `tabindex="0"`, it will still be focusable.
|
|
32
|
+
*
|
|
33
|
+
* To remove user overrides and restore focusability control to the element,
|
|
34
|
+
* remove the `tabindex` attribute.
|
|
35
|
+
*
|
|
36
|
+
* @param base The class to mix functionality into.
|
|
37
|
+
* @return The provided class with `Focusable` mixed in.
|
|
38
|
+
*/
|
|
39
|
+
export declare function mixinFocusable<T extends MixinBase<LitElement>>(base: T): MixinReturn<T, Focusable>;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { __decorate } from "tslib";
|
|
7
|
+
import { property } from 'lit/decorators.js';
|
|
8
|
+
/**
|
|
9
|
+
* A property symbol that indicates whether or not a `Focusable` element can be
|
|
10
|
+
* focused.
|
|
11
|
+
*/
|
|
12
|
+
export const isFocusable = Symbol('isFocusable');
|
|
13
|
+
const privateIsFocusable = Symbol('privateIsFocusable');
|
|
14
|
+
const externalTabIndex = Symbol('externalTabIndex');
|
|
15
|
+
const isUpdatingTabIndex = Symbol('isUpdatingTabIndex');
|
|
16
|
+
const updateTabIndex = Symbol('updateTabIndex');
|
|
17
|
+
/**
|
|
18
|
+
* Mixes in focusable functionality for a class.
|
|
19
|
+
*
|
|
20
|
+
* Elements can enable and disable their focusability with the `isFocusable`
|
|
21
|
+
* symbol property. Changing `tabIndex` will trigger a lit render, meaning
|
|
22
|
+
* `this.tabIndex` can be used in template expressions.
|
|
23
|
+
*
|
|
24
|
+
* This mixin will preserve externally-set tabindices. If an element turns off
|
|
25
|
+
* focusability, but a user sets `tabindex="0"`, it will still be focusable.
|
|
26
|
+
*
|
|
27
|
+
* To remove user overrides and restore focusability control to the element,
|
|
28
|
+
* remove the `tabindex` attribute.
|
|
29
|
+
*
|
|
30
|
+
* @param base The class to mix functionality into.
|
|
31
|
+
* @return The provided class with `Focusable` mixed in.
|
|
32
|
+
*/
|
|
33
|
+
export function mixinFocusable(base) {
|
|
34
|
+
var _a, _b, _c;
|
|
35
|
+
class FocusableElement extends base {
|
|
36
|
+
constructor() {
|
|
37
|
+
super(...arguments);
|
|
38
|
+
this[_a] = true;
|
|
39
|
+
this[_b] = null;
|
|
40
|
+
this[_c] = false;
|
|
41
|
+
}
|
|
42
|
+
get [isFocusable]() {
|
|
43
|
+
return this[privateIsFocusable];
|
|
44
|
+
}
|
|
45
|
+
set [isFocusable](value) {
|
|
46
|
+
if (this[isFocusable] === value) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
this[privateIsFocusable] = value;
|
|
50
|
+
this[updateTabIndex]();
|
|
51
|
+
}
|
|
52
|
+
connectedCallback() {
|
|
53
|
+
super.connectedCallback();
|
|
54
|
+
this[updateTabIndex]();
|
|
55
|
+
}
|
|
56
|
+
attributeChangedCallback(name, old, value) {
|
|
57
|
+
if (name !== 'tabindex') {
|
|
58
|
+
super.attributeChangedCallback(name, old, value);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
this.requestUpdate('tabIndex', Number(old ?? -1));
|
|
62
|
+
if (this[isUpdatingTabIndex]) {
|
|
63
|
+
// Not an externally-initiated update.
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (!this.hasAttribute('tabindex')) {
|
|
67
|
+
// User removed the attribute, can now use internal tabIndex
|
|
68
|
+
this[externalTabIndex] = null;
|
|
69
|
+
this[updateTabIndex]();
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
this[externalTabIndex] = this.tabIndex;
|
|
73
|
+
}
|
|
74
|
+
[(_a = privateIsFocusable, _b = externalTabIndex, _c = isUpdatingTabIndex, updateTabIndex)]() {
|
|
75
|
+
const internalTabIndex = this[isFocusable] ? 0 : -1;
|
|
76
|
+
const computedTabIndex = this[externalTabIndex] ?? internalTabIndex;
|
|
77
|
+
this[isUpdatingTabIndex] = true;
|
|
78
|
+
this.tabIndex = computedTabIndex;
|
|
79
|
+
this[isUpdatingTabIndex] = false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
__decorate([
|
|
83
|
+
property({ noAccessor: true })
|
|
84
|
+
], FocusableElement.prototype, "tabIndex", void 0);
|
|
85
|
+
return FocusableElement;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=focusable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focusable.js","sourceRoot":"","sources":["focusable.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAe7C;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;AAEjD,MAAM,kBAAkB,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAC;AACxD,MAAM,gBAAgB,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC;AACpD,MAAM,kBAAkB,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAC;AACxD,MAAM,cAAc,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAEhD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,cAAc,CAC5B,IAAO;;IAEP,MAAe,gBAAiB,SAAQ,IAAI;QAA5C;;YAiBE,QAAoB,GAAG,IAAI,CAAC;YAC5B,QAAkB,GAAkB,IAAI,CAAC;YACzC,QAAoB,GAAG,KAAK,CAAC;QAyC/B,CAAC;QAxDC,IAAI,CAAC,WAAW,CAAC;YACf,OAAO,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAClC,CAAC;QAED,IAAI,CAAC,WAAW,CAAC,CAAC,KAAc;YAC9B,IAAI,IAAI,CAAC,WAAW,CAAC,KAAK,KAAK,EAAE,CAAC;gBAChC,OAAO;YACT,CAAC;YAED,IAAI,CAAC,kBAAkB,CAAC,GAAG,KAAK,CAAC;YACjC,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC;QACzB,CAAC;QAMQ,iBAAiB;YACxB,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC1B,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC;QACzB,CAAC;QAEQ,wBAAwB,CAC/B,IAAY,EACZ,GAAkB,EAClB,KAAoB;YAEpB,IAAI,IAAI,KAAK,UAAU,EAAE,CAAC;gBACxB,KAAK,CAAC,wBAAwB,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;gBACjD,OAAO;YACT,CAAC;YAED,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YAClD,IAAI,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC;gBAC7B,sCAAsC;gBACtC,OAAO;YACT,CAAC;YAED,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,CAAC;gBACnC,4DAA4D;gBAC5D,IAAI,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAC;gBAC9B,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC;gBACvB,OAAO;YACT,CAAC;YAED,IAAI,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC;QACzC,CAAC;QAED,OAnCC,kBAAkB,OAClB,gBAAgB,OAChB,kBAAkB,EAiClB,cAAc,EAAC;YACd,MAAM,gBAAgB,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACpD,MAAM,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,gBAAgB,CAAC;YAEpE,IAAI,CAAC,kBAAkB,CAAC,GAAG,IAAI,CAAC;YAChC,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC;YACjC,IAAI,CAAC,kBAAkB,CAAC,GAAG,KAAK,CAAC;QACnC,CAAC;KACF;IA1DS;QADP,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;sDACN;IA4D3B,OAAO,gBAAgB,CAAC;AAC1B,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport { MixinBase, MixinReturn } from './mixin.js';\n\n/**\n * An element that can enable and disable `tabindex` focusability.\n */\nexport interface Focusable {\n /**\n * Whether or not the element can be focused. Defaults to true. Set to false\n * to disable focusing (unless a user has set a `tabindex`).\n */\n [isFocusable]: boolean;\n}\n\n/**\n * A property symbol that indicates whether or not a `Focusable` element can be\n * focused.\n */\nexport const isFocusable = Symbol('isFocusable');\n\nconst privateIsFocusable = Symbol('privateIsFocusable');\nconst externalTabIndex = Symbol('externalTabIndex');\nconst isUpdatingTabIndex = Symbol('isUpdatingTabIndex');\nconst updateTabIndex = Symbol('updateTabIndex');\n\n/**\n * Mixes in focusable functionality for a class.\n *\n * Elements can enable and disable their focusability with the `isFocusable`\n * symbol property. Changing `tabIndex` will trigger a lit render, meaning\n * `this.tabIndex` can be used in template expressions.\n *\n * This mixin will preserve externally-set tabindices. If an element turns off\n * focusability, but a user sets `tabindex=\"0\"`, it will still be focusable.\n *\n * To remove user overrides and restore focusability control to the element,\n * remove the `tabindex` attribute.\n *\n * @param base The class to mix functionality into.\n * @return The provided class with `Focusable` mixed in.\n */\nexport function mixinFocusable<T extends MixinBase<LitElement>>(\n base: T,\n): MixinReturn<T, Focusable> {\n abstract class FocusableElement extends base implements Focusable {\n @property({ noAccessor: true })\n declare tabIndex: number;\n\n get [isFocusable]() {\n return this[privateIsFocusable];\n }\n\n set [isFocusable](value: boolean) {\n if (this[isFocusable] === value) {\n return;\n }\n\n this[privateIsFocusable] = value;\n this[updateTabIndex]();\n }\n\n [privateIsFocusable] = true;\n [externalTabIndex]: number | null = null;\n [isUpdatingTabIndex] = false;\n\n override connectedCallback() {\n super.connectedCallback();\n this[updateTabIndex]();\n }\n\n override attributeChangedCallback(\n name: string,\n old: string | null,\n value: string | null,\n ) {\n if (name !== 'tabindex') {\n super.attributeChangedCallback(name, old, value);\n return;\n }\n\n this.requestUpdate('tabIndex', Number(old ?? -1));\n if (this[isUpdatingTabIndex]) {\n // Not an externally-initiated update.\n return;\n }\n\n if (!this.hasAttribute('tabindex')) {\n // User removed the attribute, can now use internal tabIndex\n this[externalTabIndex] = null;\n this[updateTabIndex]();\n return;\n }\n\n this[externalTabIndex] = this.tabIndex;\n }\n\n [updateTabIndex]() {\n const internalTabIndex = this[isFocusable] ? 0 : -1;\n const computedTabIndex = this[externalTabIndex] ?? internalTabIndex;\n\n this[isUpdatingTabIndex] = true;\n this.tabIndex = computedTabIndex;\n this[isUpdatingTabIndex] = false;\n }\n }\n\n return FocusableElement;\n}\n"]}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { LitElement } from 'lit';
|
|
7
|
+
import { WithElementInternals } from './element-internals.js';
|
|
8
|
+
import { MixinBase, MixinReturn } from './mixin.js';
|
|
9
|
+
/**
|
|
10
|
+
* A form-associated element.
|
|
11
|
+
*
|
|
12
|
+
* IMPORTANT: Requires declares for lit-analyzer
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const base = mixinFormAssociated(mixinElementInternals(LitElement));
|
|
16
|
+
* class MyControl extends base {
|
|
17
|
+
* // Writable mixin properties for lit-html binding, needed for lit-analyzer
|
|
18
|
+
* declare disabled: boolean;
|
|
19
|
+
* declare name: string;
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export interface FormAssociated {
|
|
24
|
+
/**
|
|
25
|
+
* The associated form element with which this element's value will submit.
|
|
26
|
+
*/
|
|
27
|
+
readonly form: HTMLFormElement | null;
|
|
28
|
+
/**
|
|
29
|
+
* The labels this element is associated with.
|
|
30
|
+
*/
|
|
31
|
+
readonly labels: NodeList;
|
|
32
|
+
/**
|
|
33
|
+
* The HTML name to use in form submission.
|
|
34
|
+
*/
|
|
35
|
+
name: string;
|
|
36
|
+
/**
|
|
37
|
+
* Whether or not the element is disabled.
|
|
38
|
+
*/
|
|
39
|
+
disabled: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Gets the current form value of a component.
|
|
42
|
+
*
|
|
43
|
+
* @return The current form value.
|
|
44
|
+
*/
|
|
45
|
+
[getFormValue](): FormValue | null;
|
|
46
|
+
/**
|
|
47
|
+
* Gets the current form state of a component. Defaults to the component's
|
|
48
|
+
* `[formValue]`.
|
|
49
|
+
*
|
|
50
|
+
* Use this when the state of an element is different from its value, such as
|
|
51
|
+
* checkboxes (internal boolean state and a user string value).
|
|
52
|
+
*
|
|
53
|
+
* @return The current form state, defaults to the form value.
|
|
54
|
+
*/
|
|
55
|
+
[getFormState](): FormValue | null;
|
|
56
|
+
/**
|
|
57
|
+
* A callback for when a form component should be disabled or enabled. This
|
|
58
|
+
* can be called in a variety of situations, such as disabled `<fieldset>`s.
|
|
59
|
+
*
|
|
60
|
+
* @param disabled Whether or not the form control should be disabled.
|
|
61
|
+
*/
|
|
62
|
+
formDisabledCallback(disabled: boolean): void;
|
|
63
|
+
/**
|
|
64
|
+
* A callback for when the form requests to reset its value. Typically, the
|
|
65
|
+
* default value that is reset is represented in the attribute of an element.
|
|
66
|
+
*
|
|
67
|
+
* This means the attribute used for the value should not update as the value
|
|
68
|
+
* changes. For example, a checkbox should not change its default `checked`
|
|
69
|
+
* attribute when selected. Ensure form values do not reflect.
|
|
70
|
+
*/
|
|
71
|
+
formResetCallback(): void;
|
|
72
|
+
/**
|
|
73
|
+
* A callback for when the form restores the state of a component. For
|
|
74
|
+
* example, when a page is reloaded or forms are autofilled.
|
|
75
|
+
*
|
|
76
|
+
* @param state The state to restore, or null to reset the form control's
|
|
77
|
+
* value.
|
|
78
|
+
* @param reason The reason state was restored, either `'restore'` or
|
|
79
|
+
* `'autocomplete'`.
|
|
80
|
+
*/
|
|
81
|
+
formStateRestoreCallback(state: FormRestoreState | null, reason: FormRestoreReason): void;
|
|
82
|
+
/**
|
|
83
|
+
* An optional callback for when the associated form changes.
|
|
84
|
+
*
|
|
85
|
+
* @param form The new associated form, or `null` if there is none.
|
|
86
|
+
*/
|
|
87
|
+
formAssociatedCallback?(form: HTMLFormElement | null): void;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The constructor of a `FormAssociated` element.
|
|
91
|
+
*/
|
|
92
|
+
export interface FormAssociatedConstructor {
|
|
93
|
+
/**
|
|
94
|
+
* Indicates that an element is participating in form association.
|
|
95
|
+
*/
|
|
96
|
+
readonly formAssociated: true;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* A symbol property to retrieve the form value for an element.
|
|
100
|
+
*/
|
|
101
|
+
export declare const getFormValue: unique symbol;
|
|
102
|
+
/**
|
|
103
|
+
* A symbol property to retrieve the form state for an element.
|
|
104
|
+
*/
|
|
105
|
+
export declare const getFormState: unique symbol;
|
|
106
|
+
/**
|
|
107
|
+
* Mixes in form-associated behavior for a class. This allows an element to add
|
|
108
|
+
* values to `<form>` elements.
|
|
109
|
+
*
|
|
110
|
+
* Implementing classes should provide a `[formValue]` to return the current
|
|
111
|
+
* value of the element, as well as reset and restore callbacks.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```ts
|
|
115
|
+
* const base = mixinFormAssociated(mixinElementInternals(LitElement));
|
|
116
|
+
*
|
|
117
|
+
* class MyControl extends base {
|
|
118
|
+
* \@property()
|
|
119
|
+
* value = '';
|
|
120
|
+
*
|
|
121
|
+
* override [getFormValue]() {
|
|
122
|
+
* return this.value;
|
|
123
|
+
* }
|
|
124
|
+
*
|
|
125
|
+
* override formResetCallback() {
|
|
126
|
+
* const defaultValue = this.getAttribute('value');
|
|
127
|
+
* this.value = defaultValue;
|
|
128
|
+
* }
|
|
129
|
+
*
|
|
130
|
+
* override formStateRestoreCallback(state: string) {
|
|
131
|
+
* this.value = state;
|
|
132
|
+
* }
|
|
133
|
+
* }
|
|
134
|
+
* ```
|
|
135
|
+
*
|
|
136
|
+
* Elements may optionally provide a `[formState]` if their values do not
|
|
137
|
+
* represent the state of the component.
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```ts
|
|
141
|
+
* const base = mixinFormAssociated(mixinElementInternals(LitElement));
|
|
142
|
+
*
|
|
143
|
+
* class MyCheckbox extends base {
|
|
144
|
+
* \@property()
|
|
145
|
+
* value = 'on';
|
|
146
|
+
*
|
|
147
|
+
* \@property({type: Boolean})
|
|
148
|
+
* checked = false;
|
|
149
|
+
*
|
|
150
|
+
* override [getFormValue]() {
|
|
151
|
+
* return this.checked ? this.value : null;
|
|
152
|
+
* }
|
|
153
|
+
*
|
|
154
|
+
* override [getFormState]() {
|
|
155
|
+
* return String(this.checked);
|
|
156
|
+
* }
|
|
157
|
+
*
|
|
158
|
+
* override formResetCallback() {
|
|
159
|
+
* const defaultValue = this.hasAttribute('checked');
|
|
160
|
+
* this.checked = defaultValue;
|
|
161
|
+
* }
|
|
162
|
+
*
|
|
163
|
+
* override formStateRestoreCallback(state: string) {
|
|
164
|
+
* this.checked = Boolean(state);
|
|
165
|
+
* }
|
|
166
|
+
* }
|
|
167
|
+
* ```
|
|
168
|
+
*
|
|
169
|
+
* IMPORTANT: Requires declares for lit-analyzer
|
|
170
|
+
* @example
|
|
171
|
+
* ```ts
|
|
172
|
+
* const base = mixinFormAssociated(mixinElementInternals(LitElement));
|
|
173
|
+
* class MyControl extends base {
|
|
174
|
+
* // Writable mixin properties for lit-html binding, needed for lit-analyzer
|
|
175
|
+
* declare disabled: boolean;
|
|
176
|
+
* declare name: string;
|
|
177
|
+
* }
|
|
178
|
+
* ```
|
|
179
|
+
*
|
|
180
|
+
* @param base The class to mix functionality into. The base class must use
|
|
181
|
+
* `mixinElementInternals()`.
|
|
182
|
+
* @return The provided class with `FormAssociated` mixed in.
|
|
183
|
+
*/
|
|
184
|
+
export declare function mixinFormAssociated<T extends MixinBase<LitElement & WithElementInternals>>(base: T): MixinReturn<T & FormAssociatedConstructor, FormAssociated>;
|
|
185
|
+
/**
|
|
186
|
+
* A value that can be provided for form submission and state.
|
|
187
|
+
*/
|
|
188
|
+
export type FormValue = File | string | FormData;
|
|
189
|
+
/**
|
|
190
|
+
* A value to be restored for a component's form value. If a component's form
|
|
191
|
+
* state is a `FormData` object, its entry list of name and values will be
|
|
192
|
+
* provided.
|
|
193
|
+
*/
|
|
194
|
+
export type FormRestoreState = File | string | Array<[string, FormDataEntryValue]>;
|
|
195
|
+
/**
|
|
196
|
+
* The reason a form component is being restored for, either `'restore'` for
|
|
197
|
+
* browser restoration or `'autocomplete'` for restoring user values.
|
|
198
|
+
*/
|
|
199
|
+
export type FormRestoreReason = 'restore' | 'autocomplete';
|