@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,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Accessibility Object Model reflective aria properties.
|
|
8
|
+
*/
|
|
9
|
+
export const ARIA_PROPERTIES = [
|
|
10
|
+
'role',
|
|
11
|
+
'ariaAtomic',
|
|
12
|
+
'ariaAutoComplete',
|
|
13
|
+
'ariaBusy',
|
|
14
|
+
'ariaChecked',
|
|
15
|
+
'ariaColCount',
|
|
16
|
+
'ariaColIndex',
|
|
17
|
+
'ariaColSpan',
|
|
18
|
+
'ariaCurrent',
|
|
19
|
+
'ariaDisabled',
|
|
20
|
+
'ariaExpanded',
|
|
21
|
+
'ariaHasPopup',
|
|
22
|
+
'ariaHidden',
|
|
23
|
+
'ariaInvalid',
|
|
24
|
+
'ariaKeyShortcuts',
|
|
25
|
+
'ariaLabel',
|
|
26
|
+
'ariaLevel',
|
|
27
|
+
'ariaLive',
|
|
28
|
+
'ariaModal',
|
|
29
|
+
'ariaMultiLine',
|
|
30
|
+
'ariaMultiSelectable',
|
|
31
|
+
'ariaOrientation',
|
|
32
|
+
'ariaPlaceholder',
|
|
33
|
+
'ariaPosInSet',
|
|
34
|
+
'ariaPressed',
|
|
35
|
+
'ariaReadOnly',
|
|
36
|
+
'ariaRequired',
|
|
37
|
+
'ariaRoleDescription',
|
|
38
|
+
'ariaRowCount',
|
|
39
|
+
'ariaRowIndex',
|
|
40
|
+
'ariaRowSpan',
|
|
41
|
+
'ariaSelected',
|
|
42
|
+
'ariaSetSize',
|
|
43
|
+
'ariaSort',
|
|
44
|
+
'ariaValueMax',
|
|
45
|
+
'ariaValueMin',
|
|
46
|
+
'ariaValueNow',
|
|
47
|
+
'ariaValueText',
|
|
48
|
+
];
|
|
49
|
+
/**
|
|
50
|
+
* Accessibility Object Model aria attributes.
|
|
51
|
+
*/
|
|
52
|
+
export const ARIA_ATTRIBUTES = ARIA_PROPERTIES.map(ariaPropertyToAttribute);
|
|
53
|
+
/**
|
|
54
|
+
* Checks if an attribute is one of the AOM aria attributes.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* isAriaAttribute('aria-label'); // true
|
|
58
|
+
*
|
|
59
|
+
* @param attribute The attribute to check.
|
|
60
|
+
* @return True if the attribute is an aria attribute, or false if not.
|
|
61
|
+
*/
|
|
62
|
+
export function isAriaAttribute(attribute) {
|
|
63
|
+
return ARIA_ATTRIBUTES.includes(attribute);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Converts an AOM aria property into its corresponding attribute.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ariaPropertyToAttribute('ariaLabel'); // 'aria-label'
|
|
70
|
+
*
|
|
71
|
+
* @param property The aria property.
|
|
72
|
+
* @return The aria attribute.
|
|
73
|
+
*/
|
|
74
|
+
export function ariaPropertyToAttribute(property) {
|
|
75
|
+
return property
|
|
76
|
+
.replace('aria', 'aria-')
|
|
77
|
+
// IDREF attributes also include an "Element" or "Elements" suffix
|
|
78
|
+
.replace(/Elements?/g, '')
|
|
79
|
+
.toLowerCase();
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=aria.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aria.js","sourceRoot":"","sources":["aria.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAmB;IAC7C,MAAM;IACN,YAAY;IACZ,kBAAkB;IAClB,UAAU;IACV,aAAa;IACb,cAAc;IACd,cAAc;IACd,aAAa;IACb,aAAa;IACb,cAAc;IACd,cAAc;IACd,cAAc;IACd,YAAY;IACZ,aAAa;IACb,kBAAkB;IAClB,WAAW;IACX,WAAW;IACX,UAAU;IACV,WAAW;IACX,eAAe;IACf,qBAAqB;IACrB,iBAAiB;IACjB,iBAAiB;IACjB,cAAc;IACd,aAAa;IACb,cAAc;IACd,cAAc;IACd,qBAAqB;IACrB,cAAc;IACd,cAAc;IACd,aAAa;IACb,cAAc;IACd,aAAa;IACb,UAAU;IACV,cAAc;IACd,cAAc;IACd,cAAc;IACd,eAAe;CAChB,CAAC;AAOF;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,eAAe,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;AAE5E;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,SAAiB;IAC/C,OAAO,eAAe,CAAC,QAAQ,CAAC,SAA0B,CAAC,CAAC;AAC9D,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,uBAAuB,CAAyB,QAAW;IACzE,OACE,QAAQ;SACL,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC;QACzB,kEAAkE;SACjE,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC;SACzB,WAAW,EACf,CAAC;AACJ,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/**\n * Accessibility Object Model reflective aria property name types.\n */\nexport type ARIAProperty = keyof ARIAMixin;\n\n/**\n * Accessibility Object Model reflective aria properties.\n */\nexport const ARIA_PROPERTIES: ARIAProperty[] = [\n 'role',\n 'ariaAtomic',\n 'ariaAutoComplete',\n 'ariaBusy',\n 'ariaChecked',\n 'ariaColCount',\n 'ariaColIndex',\n 'ariaColSpan',\n 'ariaCurrent',\n 'ariaDisabled',\n 'ariaExpanded',\n 'ariaHasPopup',\n 'ariaHidden',\n 'ariaInvalid',\n 'ariaKeyShortcuts',\n 'ariaLabel',\n 'ariaLevel',\n 'ariaLive',\n 'ariaModal',\n 'ariaMultiLine',\n 'ariaMultiSelectable',\n 'ariaOrientation',\n 'ariaPlaceholder',\n 'ariaPosInSet',\n 'ariaPressed',\n 'ariaReadOnly',\n 'ariaRequired',\n 'ariaRoleDescription',\n 'ariaRowCount',\n 'ariaRowIndex',\n 'ariaRowSpan',\n 'ariaSelected',\n 'ariaSetSize',\n 'ariaSort',\n 'ariaValueMax',\n 'ariaValueMin',\n 'ariaValueNow',\n 'ariaValueText',\n];\n\n/**\n * Accessibility Object Model aria attribute name types.\n */\nexport type ARIAAttribute = ARIAPropertyToAttribute<ARIAProperty>;\n\n/**\n * Accessibility Object Model aria attributes.\n */\nexport const ARIA_ATTRIBUTES = ARIA_PROPERTIES.map(ariaPropertyToAttribute);\n\n/**\n * Checks if an attribute is one of the AOM aria attributes.\n *\n * @example\n * isAriaAttribute('aria-label'); // true\n *\n * @param attribute The attribute to check.\n * @return True if the attribute is an aria attribute, or false if not.\n */\nexport function isAriaAttribute(attribute: string): attribute is ARIAAttribute {\n return ARIA_ATTRIBUTES.includes(attribute as ARIAAttribute);\n}\n\n/**\n * Converts an AOM aria property into its corresponding attribute.\n *\n * @example\n * ariaPropertyToAttribute('ariaLabel'); // 'aria-label'\n *\n * @param property The aria property.\n * @return The aria attribute.\n */\nexport function ariaPropertyToAttribute<K extends ARIAProperty>(property: K) {\n return (\n property\n .replace('aria', 'aria-')\n // IDREF attributes also include an \"Element\" or \"Elements\" suffix\n .replace(/Elements?/g, '')\n .toLowerCase() as ARIAPropertyToAttribute<K>\n );\n}\n\n// Converts an `ariaFoo` string type to an `aria-foo` string type.\ntype ARIAPropertyToAttribute<K extends string> =\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n K extends `aria${infer Suffix}Element${infer OptS}`\n ? `aria-${Lowercase<Suffix>}`\n : K extends `aria${infer Suffix}`\n ? `aria-${Lowercase<Suffix>}`\n : K;\n\n/**\n * An extension of `ARIAMixin` that enforces strict value types for aria\n * properties.\n *\n * This is needed for correct typing in render functions with lit analyzer.\n *\n * @example\n * render() {\n * const {ariaLabel} = this as ARIAMixinStrict;\n * return html`\n * <button aria-label=${ariaLabel || nothing}>\n * <slot></slot>\n * </button>\n * `;\n * }\n */\nexport interface ARIAMixinStrict extends ARIAMixin {\n ariaAtomic: 'true' | 'false' | null;\n ariaAutoComplete: 'none' | 'inline' | 'list' | 'both' | null;\n ariaBusy: 'true' | 'false' | null;\n ariaChecked: 'true' | 'false' | null;\n ariaColCount: `${number}` | null;\n ariaColIndex: `${number}` | null;\n ariaColSpan: `${number}` | null;\n ariaCurrent:\n | 'page'\n | 'step'\n | 'location'\n | 'date'\n | 'time'\n | 'true'\n | 'false'\n | null;\n ariaDisabled: 'true' | 'false' | null;\n ariaExpanded: 'true' | 'false' | null;\n ariaHasPopup:\n | 'false'\n | 'true'\n | 'menu'\n | 'listbox'\n | 'tree'\n | 'grid'\n | 'dialog'\n | null;\n ariaHidden: 'true' | 'false' | null;\n ariaInvalid: 'true' | 'false' | null;\n ariaKeyShortcuts: string | null;\n ariaLabel: string | null;\n ariaLevel: `${number}` | null;\n ariaLive: 'assertive' | 'off' | 'polite' | null;\n ariaModal: 'true' | 'false' | null;\n ariaMultiLine: 'true' | 'false' | null;\n ariaMultiSelectable: 'true' | 'false' | null;\n ariaOrientation: 'horizontal' | 'vertical' | 'undefined' | null;\n ariaPlaceholder: string | null;\n ariaPosInSet: `${number}` | null;\n ariaPressed: 'true' | 'false' | null;\n ariaReadOnly: 'true' | 'false' | null;\n ariaRequired: 'true' | 'false' | null;\n ariaRoleDescription: string | null;\n ariaRowCount: `${number}` | null;\n ariaRowIndex: `${number}` | null;\n ariaRowSpan: `${number}` | null;\n ariaSelected: 'true' | 'false' | null;\n ariaSetSize: `${number}` | null;\n ariaSort: 'ascending' | 'descending' | 'none' | 'other' | null;\n ariaValueMax: `${number}` | null;\n ariaValueMin: `${number}` | null;\n ariaValueNow: `${number}` | null;\n ariaValueText: string | null;\n role: ARIARole | null;\n}\n\n/**\n * Valid values for `role`.\n */\nexport type ARIARole =\n | 'alert'\n | 'alertdialog'\n | 'button'\n | 'checkbox'\n | 'dialog'\n | 'gridcell'\n | 'link'\n | 'log'\n | 'marquee'\n | 'menuitem'\n | 'menuitemcheckbox'\n | 'menuitemradio'\n | 'option'\n | 'progressbar'\n | 'radio'\n | 'scrollbar'\n | 'searchbox'\n | 'slider'\n | 'spinbutton'\n | 'status'\n | 'switch'\n | 'tab'\n | 'tabpanel'\n | 'textbox'\n | 'timer'\n | 'tooltip'\n | 'treeitem'\n | 'combobox'\n | 'grid'\n | 'listbox'\n | 'menu'\n | 'menubar'\n | 'radiogroup'\n | 'tablist'\n | 'tree'\n | 'treegrid'\n | 'application'\n | 'article'\n | 'cell'\n | 'columnheader'\n | 'definition'\n | 'directory'\n | 'document'\n | 'feed'\n | 'figure'\n | 'group'\n | 'heading'\n | 'img'\n | 'list'\n | 'listitem'\n | 'math'\n | 'none'\n | 'note'\n | 'presentation'\n | 'region'\n | 'row'\n | 'rowgroup'\n | 'rowheader'\n | 'separator'\n | 'table'\n | 'term'\n | 'text'\n | 'toolbar'\n | 'banner'\n | 'complementary'\n | 'contentinfo'\n | 'form'\n | 'main'\n | 'navigation'\n | 'region'\n | 'search'\n | 'doc-abstract'\n | 'doc-acknowledgments'\n | 'doc-afterword'\n | 'doc-appendix'\n | 'doc-backlink'\n | 'doc-biblioentry'\n | 'doc-bibliography'\n | 'doc-biblioref'\n | 'doc-chapter'\n | 'doc-colophon'\n | 'doc-conclusion'\n | 'doc-cover'\n | 'doc-credit'\n | 'doc-credits'\n | 'doc-dedication'\n | 'doc-endnote'\n | 'doc-endnotes'\n | 'doc-epigraph'\n | 'doc-epilogue'\n | 'doc-errata'\n | 'doc-example'\n | 'doc-footnote'\n | 'doc-foreword'\n | 'doc-glossary'\n | 'doc-glossref'\n | 'doc-index'\n | 'doc-introduction'\n | 'doc-noteref'\n | 'doc-notice'\n | 'doc-pagebreak'\n | 'doc-pagelist'\n | 'doc-part'\n | 'doc-preface'\n | 'doc-prologue'\n | 'doc-pullquote'\n | 'doc-qna'\n | 'doc-subtitle'\n | 'doc-tip'\n | 'doc-toc';\n"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
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 '../../labs/behaviors/mixin.js';
|
|
8
|
+
/**
|
|
9
|
+
* Mixes in aria delegation for elements that delegate focus and aria to inner
|
|
10
|
+
* shadow root elements.
|
|
11
|
+
*
|
|
12
|
+
* This mixin fixes invalid aria announcements with shadow roots, caused by
|
|
13
|
+
* duplicate aria attributes on both the host and the inner shadow root element.
|
|
14
|
+
*
|
|
15
|
+
* Note: this mixin **does not yet support** ID reference attributes, such as
|
|
16
|
+
* `aria-labelledby` or `aria-controls`.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* class MyButton extends mixinDelegatesAria(LitElement) {
|
|
21
|
+
* static shadowRootOptions = {mode: 'open', delegatesFocus: true};
|
|
22
|
+
*
|
|
23
|
+
* render() {
|
|
24
|
+
* return html`
|
|
25
|
+
* <button aria-label=${this.ariaLabel || nothing}>
|
|
26
|
+
* <slot></slot>
|
|
27
|
+
* </button>
|
|
28
|
+
* `;
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
* ```html
|
|
33
|
+
* <my-button aria-label="Plus one">+1</my-button>
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* Use `ARIAMixinStrict` for lit analyzer strict types, such as the "role"
|
|
37
|
+
* attribute.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* return html`
|
|
42
|
+
* <button role=${(this as ARIAMixinStrict).role || nothing}>
|
|
43
|
+
* <slot></slot>
|
|
44
|
+
* </button>
|
|
45
|
+
* `;
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* In the future, updates to the Accessibility Object Model (AOM) will provide
|
|
49
|
+
* built-in aria delegation features that will replace this mixin.
|
|
50
|
+
*
|
|
51
|
+
* @param base The class to mix functionality into.
|
|
52
|
+
* @return The provided class with aria delegation mixed in.
|
|
53
|
+
*/
|
|
54
|
+
export declare function mixinDelegatesAria<T extends MixinBase<LitElement>>(base: T): MixinReturn<T>;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { isServer } from 'lit';
|
|
7
|
+
import { ARIA_PROPERTIES, ariaPropertyToAttribute, isAriaAttribute, } from './aria.js';
|
|
8
|
+
// Private symbols
|
|
9
|
+
const privateIgnoreAttributeChangesFor = Symbol('privateIgnoreAttributeChangesFor');
|
|
10
|
+
/**
|
|
11
|
+
* Mixes in aria delegation for elements that delegate focus and aria to inner
|
|
12
|
+
* shadow root elements.
|
|
13
|
+
*
|
|
14
|
+
* This mixin fixes invalid aria announcements with shadow roots, caused by
|
|
15
|
+
* duplicate aria attributes on both the host and the inner shadow root element.
|
|
16
|
+
*
|
|
17
|
+
* Note: this mixin **does not yet support** ID reference attributes, such as
|
|
18
|
+
* `aria-labelledby` or `aria-controls`.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* class MyButton extends mixinDelegatesAria(LitElement) {
|
|
23
|
+
* static shadowRootOptions = {mode: 'open', delegatesFocus: true};
|
|
24
|
+
*
|
|
25
|
+
* render() {
|
|
26
|
+
* return html`
|
|
27
|
+
* <button aria-label=${this.ariaLabel || nothing}>
|
|
28
|
+
* <slot></slot>
|
|
29
|
+
* </button>
|
|
30
|
+
* `;
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
* ```html
|
|
35
|
+
* <my-button aria-label="Plus one">+1</my-button>
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* Use `ARIAMixinStrict` for lit analyzer strict types, such as the "role"
|
|
39
|
+
* attribute.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* return html`
|
|
44
|
+
* <button role=${(this as ARIAMixinStrict).role || nothing}>
|
|
45
|
+
* <slot></slot>
|
|
46
|
+
* </button>
|
|
47
|
+
* `;
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* In the future, updates to the Accessibility Object Model (AOM) will provide
|
|
51
|
+
* built-in aria delegation features that will replace this mixin.
|
|
52
|
+
*
|
|
53
|
+
* @param base The class to mix functionality into.
|
|
54
|
+
* @return The provided class with aria delegation mixed in.
|
|
55
|
+
*/
|
|
56
|
+
export function mixinDelegatesAria(base) {
|
|
57
|
+
var _a;
|
|
58
|
+
if (isServer) {
|
|
59
|
+
// Don't shift attributes when running with lit-ssr. The SSR renderer
|
|
60
|
+
// implements a subset of DOM APIs, including the methods this mixin
|
|
61
|
+
// overrides, causing errors. We don't need to shift on the server anyway
|
|
62
|
+
// since elements will shift attributes immediately once they hydrate.
|
|
63
|
+
return base;
|
|
64
|
+
}
|
|
65
|
+
class WithDelegatesAriaElement extends base {
|
|
66
|
+
constructor() {
|
|
67
|
+
super(...arguments);
|
|
68
|
+
this[_a] = new Set();
|
|
69
|
+
}
|
|
70
|
+
static { _a = privateIgnoreAttributeChangesFor; }
|
|
71
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
72
|
+
if (!isAriaAttribute(name)) {
|
|
73
|
+
super.attributeChangedCallback(name, oldValue, newValue);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (this[privateIgnoreAttributeChangesFor].has(name)) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
// Don't trigger another `attributeChangedCallback` once we remove the
|
|
80
|
+
// aria attribute from the host. We check the explicit name of the
|
|
81
|
+
// attribute to ignore since `attributeChangedCallback` can be called
|
|
82
|
+
// multiple times out of an expected order when hydrating an element with
|
|
83
|
+
// multiple attributes.
|
|
84
|
+
this[privateIgnoreAttributeChangesFor].add(name);
|
|
85
|
+
this.removeAttribute(name);
|
|
86
|
+
this[privateIgnoreAttributeChangesFor].delete(name);
|
|
87
|
+
const dataProperty = ariaAttributeToDataProperty(name);
|
|
88
|
+
if (newValue === null) {
|
|
89
|
+
delete this.dataset[dataProperty];
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
this.dataset[dataProperty] = newValue;
|
|
93
|
+
}
|
|
94
|
+
this.requestUpdate(ariaAttributeToDataProperty(name), oldValue);
|
|
95
|
+
}
|
|
96
|
+
getAttribute(name) {
|
|
97
|
+
if (isAriaAttribute(name)) {
|
|
98
|
+
return super.getAttribute(ariaAttributeToDataAttribute(name));
|
|
99
|
+
}
|
|
100
|
+
return super.getAttribute(name);
|
|
101
|
+
}
|
|
102
|
+
removeAttribute(name) {
|
|
103
|
+
super.removeAttribute(name);
|
|
104
|
+
if (isAriaAttribute(name)) {
|
|
105
|
+
super.removeAttribute(ariaAttributeToDataAttribute(name));
|
|
106
|
+
// Since `aria-*` attributes are already removed`, we need to request
|
|
107
|
+
// an update because `attributeChangedCallback` will not be called.
|
|
108
|
+
this.requestUpdate();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
setupDelegatesAriaProperties(WithDelegatesAriaElement);
|
|
113
|
+
return WithDelegatesAriaElement;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Overrides the constructor's native `ARIAMixin` properties to ensure that
|
|
117
|
+
* aria properties reflect the values that were shifted to a data attribute.
|
|
118
|
+
*
|
|
119
|
+
* @param ctor The `ReactiveElement` constructor to patch.
|
|
120
|
+
*/
|
|
121
|
+
function setupDelegatesAriaProperties(ctor) {
|
|
122
|
+
for (const ariaProperty of ARIA_PROPERTIES) {
|
|
123
|
+
// The casing between ariaProperty and the dataProperty may be different.
|
|
124
|
+
// ex: aria-haspopup -> ariaHasPopup
|
|
125
|
+
const ariaAttribute = ariaPropertyToAttribute(ariaProperty);
|
|
126
|
+
// ex: aria-haspopup -> data-aria-haspopup
|
|
127
|
+
const dataAttribute = ariaAttributeToDataAttribute(ariaAttribute);
|
|
128
|
+
// ex: aria-haspopup -> dataset.ariaHaspopup
|
|
129
|
+
const dataProperty = ariaAttributeToDataProperty(ariaAttribute);
|
|
130
|
+
// Call `ReactiveElement.createProperty()` so that the `aria-*` and `data-*`
|
|
131
|
+
// attributes are added to the `static observedAttributes` array. This
|
|
132
|
+
// triggers `attributeChangedCallback` for the delegates aria mixin to
|
|
133
|
+
// handle.
|
|
134
|
+
ctor.createProperty(ariaProperty, {
|
|
135
|
+
attribute: ariaAttribute,
|
|
136
|
+
noAccessor: true,
|
|
137
|
+
});
|
|
138
|
+
ctor.createProperty(Symbol(dataAttribute), {
|
|
139
|
+
attribute: dataAttribute,
|
|
140
|
+
noAccessor: true,
|
|
141
|
+
});
|
|
142
|
+
// Re-define the `ARIAMixin` properties to handle data attribute shifting.
|
|
143
|
+
// It is safe to use `Object.defineProperty` here because the properties
|
|
144
|
+
// are native and not renamed.
|
|
145
|
+
// tslint:disable-next-line:ban-unsafe-reflection
|
|
146
|
+
Object.defineProperty(ctor.prototype, ariaProperty, {
|
|
147
|
+
configurable: true,
|
|
148
|
+
enumerable: true,
|
|
149
|
+
get() {
|
|
150
|
+
return this.dataset[dataProperty] ?? null;
|
|
151
|
+
},
|
|
152
|
+
set(value) {
|
|
153
|
+
const prevValue = this.dataset[dataProperty] ?? null;
|
|
154
|
+
if (value === prevValue) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
if (value === null) {
|
|
158
|
+
delete this.dataset[dataProperty];
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
this.dataset[dataProperty] = value;
|
|
162
|
+
}
|
|
163
|
+
this.requestUpdate(ariaProperty, prevValue);
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
function ariaAttributeToDataAttribute(ariaAttribute) {
|
|
169
|
+
// aria-haspopup -> data-aria-haspopup
|
|
170
|
+
return `data-${ariaAttribute}`;
|
|
171
|
+
}
|
|
172
|
+
function ariaAttributeToDataProperty(ariaAttribute) {
|
|
173
|
+
// aria-haspopup -> dataset.ariaHaspopup
|
|
174
|
+
return ariaAttribute.replace(/-\w/, dashLetter => dashLetter[1].toUpperCase());
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=delegate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delegate.js","sourceRoot":"","sources":["delegate.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAA+B,QAAQ,EAAE,MAAM,KAAK,CAAC;AAG5D,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,eAAe,GAChB,MAAM,WAAW,CAAC;AAEnB,kBAAkB;AAClB,MAAM,gCAAgC,GAAG,MAAM,CAC7C,kCAAkC,CACnC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,MAAM,UAAU,kBAAkB,CAChC,IAAO;;IAEP,IAAI,QAAQ,EAAE,CAAC;QACb,qEAAqE;QACrE,oEAAoE;QACpE,yEAAyE;QACzE,sEAAsE;QACtE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAe,wBAAyB,SAAQ,IAAI;QAApD;;YACE,QAAkC,GAAG,IAAI,GAAG,EAAE,CAAC;QAmDjD,CAAC;sBAnDE,gCAAgC;QAExB,wBAAwB,CAC/B,IAAY,EACZ,QAAuB,EACvB,QAAuB;YAEvB,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC3B,KAAK,CAAC,wBAAwB,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;gBACzD,OAAO;YACT,CAAC;YAED,IAA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AC;qBAAM,CAAC;oBACN,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC;gBACrC,CAAC;gBAED,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;YAC9C,CAAC;SACF,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAED,SAAS,4BAA4B,CAAC,aAAqB;IACzD,sCAAsC;IACtC,OAAO,QAAQ,aAAa,EAAE,CAAC;AACjC,CAAC;AAED,SAAS,2BAA2B,CAAC,aAAqB;IACxD,wCAAwC;IACxC,OAAO,aAAa,CAAC,OAAO,CAAC,KAAK,EAAE,UAAU,CAAC,EAAE,CAC/C,UAAU,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAC5B,CAAC;AACJ,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { LitElement, ReactiveElement, isServer } from 'lit';\n\nimport { MixinBase, MixinReturn } from '../../labs/behaviors/mixin.js';\nimport {\n ARIA_PROPERTIES,\n ariaPropertyToAttribute,\n isAriaAttribute,\n} from './aria.js';\n\n// Private symbols\nconst privateIgnoreAttributeChangesFor = Symbol(\n 'privateIgnoreAttributeChangesFor',\n);\n\n/**\n * Mixes in aria delegation for elements that delegate focus and aria to inner\n * shadow root elements.\n *\n * This mixin fixes invalid aria announcements with shadow roots, caused by\n * duplicate aria attributes on both the host and the inner shadow root element.\n *\n * Note: this mixin **does not yet support** ID reference attributes, such as\n * `aria-labelledby` or `aria-controls`.\n *\n * @example\n * ```ts\n * class MyButton extends mixinDelegatesAria(LitElement) {\n * static shadowRootOptions = {mode: 'open', delegatesFocus: true};\n *\n * render() {\n * return html`\n * <button aria-label=${this.ariaLabel || nothing}>\n * <slot></slot>\n * </button>\n * `;\n * }\n * }\n * ```\n * ```html\n * <my-button aria-label=\"Plus one\">+1</my-button>\n * ```\n *\n * Use `ARIAMixinStrict` for lit analyzer strict types, such as the \"role\"\n * attribute.\n *\n * @example\n * ```ts\n * return html`\n * <button role=${(this as ARIAMixinStrict).role || nothing}>\n * <slot></slot>\n * </button>\n * `;\n * ```\n *\n * In the future, updates to the Accessibility Object Model (AOM) will provide\n * built-in aria delegation features that will replace this mixin.\n *\n * @param base The class to mix functionality into.\n * @return The provided class with aria delegation mixed in.\n */\nexport function mixinDelegatesAria<T extends MixinBase<LitElement>>(\n base: T,\n): MixinReturn<T> {\n if (isServer) {\n // Don't shift attributes when running with lit-ssr. The SSR renderer\n // implements a subset of DOM APIs, including the methods this mixin\n // overrides, causing errors. We don't need to shift on the server anyway\n // since elements will shift attributes immediately once they hydrate.\n return base;\n }\n\n abstract class WithDelegatesAriaElement extends base {\n [privateIgnoreAttributeChangesFor] = new Set();\n\n override attributeChangedCallback(\n name: string,\n oldValue: string | null,\n newValue: string | null,\n ) {\n if (!isAriaAttribute(name)) {\n super.attributeChangedCallback(name, oldValue, newValue);\n return;\n }\n\n if (this[privateIgnoreAttributeChangesFor].has(name)) {\n return;\n }\n\n // Don't trigger another `attributeChangedCallback` once we remove the\n // aria attribute from the host. We check the explicit name of the\n // attribute to ignore since `attributeChangedCallback` can be called\n // multiple times out of an expected order when hydrating an element with\n // multiple attributes.\n this[privateIgnoreAttributeChangesFor].add(name);\n this.removeAttribute(name);\n this[privateIgnoreAttributeChangesFor].delete(name);\n const dataProperty = ariaAttributeToDataProperty(name);\n if (newValue === null) {\n delete this.dataset[dataProperty];\n } else {\n this.dataset[dataProperty] = newValue;\n }\n\n this.requestUpdate(ariaAttributeToDataProperty(name), oldValue);\n }\n\n override getAttribute(name: string) {\n if (isAriaAttribute(name)) {\n return super.getAttribute(ariaAttributeToDataAttribute(name));\n }\n\n return super.getAttribute(name);\n }\n\n override removeAttribute(name: string) {\n super.removeAttribute(name);\n if (isAriaAttribute(name)) {\n super.removeAttribute(ariaAttributeToDataAttribute(name));\n // Since `aria-*` attributes are already removed`, we need to request\n // an update because `attributeChangedCallback` will not be called.\n this.requestUpdate();\n }\n }\n }\n\n setupDelegatesAriaProperties(\n WithDelegatesAriaElement as unknown as typeof ReactiveElement,\n );\n\n return WithDelegatesAriaElement;\n}\n\n/**\n * Overrides the constructor's native `ARIAMixin` properties to ensure that\n * aria properties reflect the values that were shifted to a data attribute.\n *\n * @param ctor The `ReactiveElement` constructor to patch.\n */\nfunction setupDelegatesAriaProperties(ctor: typeof ReactiveElement) {\n for (const ariaProperty of ARIA_PROPERTIES) {\n // The casing between ariaProperty and the dataProperty may be different.\n // ex: aria-haspopup -> ariaHasPopup\n const ariaAttribute = ariaPropertyToAttribute(ariaProperty);\n // ex: aria-haspopup -> data-aria-haspopup\n const dataAttribute = ariaAttributeToDataAttribute(ariaAttribute);\n // ex: aria-haspopup -> dataset.ariaHaspopup\n const dataProperty = ariaAttributeToDataProperty(ariaAttribute);\n\n // Call `ReactiveElement.createProperty()` so that the `aria-*` and `data-*`\n // attributes are added to the `static observedAttributes` array. This\n // triggers `attributeChangedCallback` for the delegates aria mixin to\n // handle.\n ctor.createProperty(ariaProperty, {\n attribute: ariaAttribute,\n noAccessor: true,\n });\n ctor.createProperty(Symbol(dataAttribute), {\n attribute: dataAttribute,\n noAccessor: true,\n });\n\n // Re-define the `ARIAMixin` properties to handle data attribute shifting.\n // It is safe to use `Object.defineProperty` here because the properties\n // are native and not renamed.\n // tslint:disable-next-line:ban-unsafe-reflection\n Object.defineProperty(ctor.prototype, ariaProperty, {\n configurable: true,\n enumerable: true,\n get(this: ReactiveElement): string | null {\n return this.dataset[dataProperty] ?? null;\n },\n set(this: ReactiveElement, value: string | null): void {\n const prevValue = this.dataset[dataProperty] ?? null;\n if (value === prevValue) {\n return;\n }\n\n if (value === null) {\n delete this.dataset[dataProperty];\n } else {\n this.dataset[dataProperty] = value;\n }\n\n this.requestUpdate(ariaProperty, prevValue);\n },\n });\n }\n}\n\nfunction ariaAttributeToDataAttribute(ariaAttribute: string) {\n // aria-haspopup -> data-aria-haspopup\n return `data-${ariaAttribute}`;\n}\n\nfunction ariaAttributeToDataProperty(ariaAttribute: string) {\n // aria-haspopup -> dataset.ariaHaspopup\n return ariaAttribute.replace(/-\\w/, dashLetter =>\n dashLetter[1].toUpperCase(),\n );\n}\n"]}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { ReactiveController, ReactiveControllerHost } from 'lit';
|
|
7
|
+
/**
|
|
8
|
+
* An element that can be attached to an associated controlling element.
|
|
9
|
+
*/
|
|
10
|
+
export interface Attachable {
|
|
11
|
+
/**
|
|
12
|
+
* Reflects the value of the `for` attribute, which is the ID of the element's
|
|
13
|
+
* associated control.
|
|
14
|
+
*
|
|
15
|
+
* Use this when the elements's associated control is not its parent.
|
|
16
|
+
*
|
|
17
|
+
* To manually control an element, set its `for` attribute to `""`.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```html
|
|
21
|
+
* <div class="container">
|
|
22
|
+
* <oscd-attachable for="interactive"></oscd-attachable>
|
|
23
|
+
* <button id="interactive">Action</button>
|
|
24
|
+
* </div>
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```html
|
|
29
|
+
* <button class="manually-controlled">
|
|
30
|
+
* <oscd-attachable for=""></oscd-attachable>
|
|
31
|
+
* </button>
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
htmlFor: string | null;
|
|
35
|
+
/**
|
|
36
|
+
* Gets or sets the element that controls the visibility of the attachable
|
|
37
|
+
* element. It is one of:
|
|
38
|
+
*
|
|
39
|
+
* - The control referenced by the `for` attribute.
|
|
40
|
+
* - The control provided to `element.attach(control)`
|
|
41
|
+
* - The element's parent.
|
|
42
|
+
* - `null` if the element is not controlled.
|
|
43
|
+
*/
|
|
44
|
+
control: HTMLElement | null;
|
|
45
|
+
/**
|
|
46
|
+
* Attaches the element to an interactive control.
|
|
47
|
+
*
|
|
48
|
+
* @param control The element that controls the attachable element.
|
|
49
|
+
*/
|
|
50
|
+
attach(control: HTMLElement): void;
|
|
51
|
+
/**
|
|
52
|
+
* Detaches the element from its current control.
|
|
53
|
+
*/
|
|
54
|
+
detach(): void;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* A key to retrieve an `Attachable` element's `AttachableController` from a
|
|
58
|
+
* global `MutationObserver`.
|
|
59
|
+
*/
|
|
60
|
+
declare const ATTACHABLE_CONTROLLER: unique symbol;
|
|
61
|
+
/**
|
|
62
|
+
* The host of an `AttachableController`. The controller will add itself to
|
|
63
|
+
* the host so it can be retrieved in a global `MutationObserver`.
|
|
64
|
+
*/
|
|
65
|
+
interface AttachableControllerHost extends ReactiveControllerHost, HTMLElement {
|
|
66
|
+
[ATTACHABLE_CONTROLLER]?: AttachableController;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* A controller that provides an implementation for `Attachable` elements.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* class MyElement extends LitElement implements Attachable {
|
|
74
|
+
* get control() { return this.attachableController.control; }
|
|
75
|
+
*
|
|
76
|
+
* private readonly attachableController = new AttachableController(
|
|
77
|
+
* this,
|
|
78
|
+
* (previousControl, newControl) => {
|
|
79
|
+
* previousControl?.removeEventListener('click', this.handleClick);
|
|
80
|
+
* newControl?.addEventListener('click', this.handleClick);
|
|
81
|
+
* }
|
|
82
|
+
* );
|
|
83
|
+
*
|
|
84
|
+
* // Implement remaining `Attachable` properties/methods that call the
|
|
85
|
+
* // controller's properties/methods.
|
|
86
|
+
* }
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
export declare class AttachableController implements ReactiveController, Attachable {
|
|
90
|
+
private readonly host;
|
|
91
|
+
private readonly onControlChange;
|
|
92
|
+
get htmlFor(): string | null;
|
|
93
|
+
set htmlFor(htmlFor: string | null);
|
|
94
|
+
get control(): HTMLElement | null;
|
|
95
|
+
set control(control: HTMLElement | null);
|
|
96
|
+
private currentControl;
|
|
97
|
+
/**
|
|
98
|
+
* Creates a new controller for an `Attachable` element.
|
|
99
|
+
*
|
|
100
|
+
* @param host The `Attachable` element.
|
|
101
|
+
* @param onControlChange A callback with two parameters for the previous and
|
|
102
|
+
* next control. An `Attachable` element may perform setup or teardown
|
|
103
|
+
* logic whenever the control changes.
|
|
104
|
+
*/
|
|
105
|
+
constructor(host: AttachableControllerHost, onControlChange: (prev: HTMLElement | null, next: HTMLElement | null) => void);
|
|
106
|
+
attach(control: HTMLElement): void;
|
|
107
|
+
detach(): void;
|
|
108
|
+
/** @private */
|
|
109
|
+
hostConnected(): void;
|
|
110
|
+
/** @private */
|
|
111
|
+
hostDisconnected(): void;
|
|
112
|
+
private setCurrentControl;
|
|
113
|
+
}
|
|
114
|
+
export {};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { isServer } from 'lit';
|
|
7
|
+
/**
|
|
8
|
+
* A key to retrieve an `Attachable` element's `AttachableController` from a
|
|
9
|
+
* global `MutationObserver`.
|
|
10
|
+
*/
|
|
11
|
+
const ATTACHABLE_CONTROLLER = Symbol('attachableController');
|
|
12
|
+
let FOR_ATTRIBUTE_OBSERVER;
|
|
13
|
+
if (!isServer) {
|
|
14
|
+
/**
|
|
15
|
+
* A global `MutationObserver` that reacts to `for` attribute changes on
|
|
16
|
+
* `Attachable` elements. If the `for` attribute changes, the controller will
|
|
17
|
+
* re-attach to the new referenced element.
|
|
18
|
+
*/
|
|
19
|
+
FOR_ATTRIBUTE_OBSERVER = new MutationObserver(records => {
|
|
20
|
+
for (const record of records) {
|
|
21
|
+
// When a control's `for` attribute changes, inform its
|
|
22
|
+
// `AttachableController` to update to a new control.
|
|
23
|
+
record.target[ATTACHABLE_CONTROLLER]?.hostConnected();
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A controller that provides an implementation for `Attachable` elements.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* class MyElement extends LitElement implements Attachable {
|
|
33
|
+
* get control() { return this.attachableController.control; }
|
|
34
|
+
*
|
|
35
|
+
* private readonly attachableController = new AttachableController(
|
|
36
|
+
* this,
|
|
37
|
+
* (previousControl, newControl) => {
|
|
38
|
+
* previousControl?.removeEventListener('click', this.handleClick);
|
|
39
|
+
* newControl?.addEventListener('click', this.handleClick);
|
|
40
|
+
* }
|
|
41
|
+
* );
|
|
42
|
+
*
|
|
43
|
+
* // Implement remaining `Attachable` properties/methods that call the
|
|
44
|
+
* // controller's properties/methods.
|
|
45
|
+
* }
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export class AttachableController {
|
|
49
|
+
get htmlFor() {
|
|
50
|
+
return this.host.getAttribute('for');
|
|
51
|
+
}
|
|
52
|
+
set htmlFor(htmlFor) {
|
|
53
|
+
if (htmlFor === null) {
|
|
54
|
+
this.host.removeAttribute('for');
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
this.host.setAttribute('for', htmlFor);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
get control() {
|
|
61
|
+
if (this.host.hasAttribute('for')) {
|
|
62
|
+
if (!this.htmlFor || !this.host.isConnected) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
return this.host.getRootNode().querySelector(`#${this.htmlFor}`);
|
|
66
|
+
}
|
|
67
|
+
return this.currentControl || this.host.parentElement;
|
|
68
|
+
}
|
|
69
|
+
set control(control) {
|
|
70
|
+
if (control) {
|
|
71
|
+
this.attach(control);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
this.detach();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Creates a new controller for an `Attachable` element.
|
|
79
|
+
*
|
|
80
|
+
* @param host The `Attachable` element.
|
|
81
|
+
* @param onControlChange A callback with two parameters for the previous and
|
|
82
|
+
* next control. An `Attachable` element may perform setup or teardown
|
|
83
|
+
* logic whenever the control changes.
|
|
84
|
+
*/
|
|
85
|
+
constructor(host, onControlChange) {
|
|
86
|
+
this.host = host;
|
|
87
|
+
this.onControlChange = onControlChange;
|
|
88
|
+
this.currentControl = null;
|
|
89
|
+
host.addController(this);
|
|
90
|
+
host[ATTACHABLE_CONTROLLER] = this;
|
|
91
|
+
FOR_ATTRIBUTE_OBSERVER?.observe(host, { attributeFilter: ['for'] });
|
|
92
|
+
}
|
|
93
|
+
attach(control) {
|
|
94
|
+
if (control === this.currentControl) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
this.setCurrentControl(control);
|
|
98
|
+
// When imperatively attaching, remove the `for` attribute so
|
|
99
|
+
// that the attached control is used instead of a referenced one.
|
|
100
|
+
this.host.removeAttribute('for');
|
|
101
|
+
}
|
|
102
|
+
detach() {
|
|
103
|
+
this.setCurrentControl(null);
|
|
104
|
+
// When imperatively detaching, add an empty `for=""` attribute. This will
|
|
105
|
+
// ensure the control is `null` rather than the `parentElement`.
|
|
106
|
+
this.host.setAttribute('for', '');
|
|
107
|
+
}
|
|
108
|
+
/** @private */
|
|
109
|
+
hostConnected() {
|
|
110
|
+
this.setCurrentControl(this.control);
|
|
111
|
+
}
|
|
112
|
+
/** @private */
|
|
113
|
+
hostDisconnected() {
|
|
114
|
+
this.setCurrentControl(null);
|
|
115
|
+
}
|
|
116
|
+
setCurrentControl(control) {
|
|
117
|
+
this.onControlChange(this.currentControl, control);
|
|
118
|
+
this.currentControl = control;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=attachable-controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachable-controller.js","sourceRo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AAI,CAAC,CAAC;IAC/B,CAAC;IAEO,iBAAiB,CAAC,OAA2B;QACnD,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;QACnD,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC;IAChC,CAAC;CACF","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { isServer, ReactiveController, ReactiveControllerHost } from 'lit';\n\n/**\n * An element that can be attached to an associated controlling element.\n */\nexport interface Attachable {\n /**\n * Reflects the value of the `for` attribute, which is the ID of the element's\n * associated control.\n *\n * Use this when the elements's associated control is not its parent.\n *\n * To manually control an element, set its `for` attribute to `\"\"`.\n *\n * @example\n * ```html\n * <div class=\"container\">\n * <oscd-attachable for=\"interactive\"></oscd-attachable>\n * <button id=\"interactive\">Action</button>\n * </div>\n * ```\n *\n * @example\n * ```html\n * <button class=\"manually-controlled\">\n * <oscd-attachable for=\"\"></oscd-attachable>\n * </button>\n * ```\n */\n htmlFor: string | null;\n\n /**\n * Gets or sets the element that controls the visibility of the attachable\n * element. It is one of:\n *\n * - The control referenced by the `for` attribute.\n * - The control provided to `element.attach(control)`\n * - The element's parent.\n * - `null` if the element is not controlled.\n */\n control: HTMLElement | null;\n\n /**\n * Attaches the element to an interactive control.\n *\n * @param control The element that controls the attachable element.\n */\n attach(control: HTMLElement): void;\n\n /**\n * Detaches the element from its current control.\n */\n detach(): void;\n}\n\n/**\n * A key to retrieve an `Attachable` element's `AttachableController` from a\n * global `MutationObserver`.\n */\nconst ATTACHABLE_CONTROLLER = Symbol('attachableController');\n\n/**\n * The host of an `AttachableController`. The controller will add itself to\n * the host so it can be retrieved in a global `MutationObserver`.\n */\ninterface AttachableControllerHost extends ReactiveControllerHost, HTMLElement {\n [ATTACHABLE_CONTROLLER]?: AttachableController;\n}\n\nlet FOR_ATTRIBUTE_OBSERVER: MutationObserver | undefined;\n\nif (!isServer) {\n /**\n * A global `MutationObserver` that reacts to `for` attribute changes on\n * `Attachable` elements. If the `for` attribute changes, the controller will\n * re-attach to the new referenced element.\n */\n FOR_ATTRIBUTE_OBSERVER = new MutationObserver(records => {\n for (const record of records) {\n // When a control's `for` attribute changes, inform its\n // `AttachableController` to update to a new control.\n (record.target as AttachableControllerHost)[\n ATTACHABLE_CONTROLLER\n ]?.hostConnected();\n }\n });\n}\n\n/**\n * A controller that provides an implementation for `Attachable` elements.\n *\n * @example\n * ```ts\n * class MyElement extends LitElement implements Attachable {\n * get control() { return this.attachableController.control; }\n *\n * private readonly attachableController = new AttachableController(\n * this,\n * (previousControl, newControl) => {\n * previousControl?.removeEventListener('click', this.handleClick);\n * newControl?.addEventListener('click', this.handleClick);\n * }\n * );\n *\n * // Implement remaining `Attachable` properties/methods that call the\n * // controller's properties/methods.\n * }\n * ```\n */\nexport class AttachableController implements ReactiveController, Attachable {\n get htmlFor() {\n return this.host.getAttribute('for');\n }\n\n set htmlFor(htmlFor: string | null) {\n if (htmlFor === null) {\n this.host.removeAttribute('for');\n } else {\n this.host.setAttribute('for', htmlFor);\n }\n }\n\n get control() {\n if (this.host.hasAttribute('for')) {\n if (!this.htmlFor || !this.host.isConnected) {\n return null;\n }\n\n return (\n this.host.getRootNode() as Document | ShadowRoot\n ).querySelector<HTMLElement>(`#${this.htmlFor}`);\n }\n\n return this.currentControl || this.host.parentElement;\n }\n set control(control: HTMLElement | null) {\n if (control) {\n this.attach(control);\n } else {\n this.detach();\n }\n }\n\n private currentControl: HTMLElement | null = null;\n\n /**\n * Creates a new controller for an `Attachable` element.\n *\n * @param host The `Attachable` element.\n * @param onControlChange A callback with two parameters for the previous and\n * next control. An `Attachable` element may perform setup or teardown\n * logic whenever the control changes.\n */\n constructor(\n private readonly host: AttachableControllerHost,\n private readonly onControlChange: (\n prev: HTMLElement | null,\n next: HTMLElement | null,\n ) => void,\n ) {\n host.addController(this);\n host[ATTACHABLE_CONTROLLER] = this;\n FOR_ATTRIBUTE_OBSERVER?.observe(host, { attributeFilter: ['for'] });\n }\n\n attach(control: HTMLElement) {\n if (control === this.currentControl) {\n return;\n }\n\n this.setCurrentControl(control);\n // When imperatively attaching, remove the `for` attribute so\n // that the attached control is used instead of a referenced one.\n this.host.removeAttribute('for');\n }\n\n detach() {\n this.setCurrentControl(null);\n // When imperatively detaching, add an empty `for=\"\"` attribute. This will\n // ensure the control is `null` rather than the `parentElement`.\n this.host.setAttribute('for', '');\n }\n\n /** @private */\n hostConnected() {\n this.setCurrentControl(this.control);\n }\n\n /** @private */\n hostDisconnected() {\n this.setCurrentControl(null);\n }\n\n private setCurrentControl(control: HTMLElement | null) {\n this.onControlChange(this.currentControl, control);\n this.currentControl = control;\n }\n}\n"]}
|