@material/web 1.0.0 → 1.0.2-nightly.6a1fb38.0
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/all.d.ts +2 -0
- package/all.js +2 -0
- package/all.js.map +1 -1
- package/button/elevated-button.js +5 -1
- package/button/elevated-button.js.map +1 -1
- package/button/internal/_elevation.scss +32 -32
- package/button/internal/_icon.scss +22 -23
- package/button/internal/_outlined-button.scss +21 -19
- package/button/internal/_shared.scss +84 -77
- package/button/internal/_touch-target.scss +4 -0
- package/button/internal/button.d.ts +7 -11
- package/button/internal/button.js +52 -38
- package/button/internal/button.js.map +1 -1
- package/button/internal/elevated-button.d.ts +1 -1
- package/button/internal/elevated-button.js +1 -1
- package/button/internal/elevated-button.js.map +1 -1
- package/button/internal/filled-button.d.ts +1 -1
- package/button/internal/filled-button.js +1 -1
- package/button/internal/filled-button.js.map +1 -1
- package/button/internal/filled-tonal-button.d.ts +1 -1
- package/button/internal/filled-tonal-button.js +1 -1
- package/button/internal/filled-tonal-button.js.map +1 -1
- package/button/internal/outlined-button.d.ts +1 -1
- package/button/internal/outlined-button.js +2 -2
- package/button/internal/outlined-button.js.map +1 -1
- package/button/internal/outlined-styles.css.js +1 -1
- package/button/internal/outlined-styles.css.js.map +1 -1
- package/button/internal/shared-elevation-styles.css.js +1 -1
- package/button/internal/shared-elevation-styles.css.js.map +1 -1
- package/button/internal/shared-styles.css.js +1 -1
- package/button/internal/shared-styles.css.js.map +1 -1
- package/checkbox/internal/_checkbox.scss +6 -0
- package/checkbox/internal/checkbox-styles.css.js +1 -1
- package/checkbox/internal/checkbox-styles.css.js.map +1 -1
- package/checkbox/internal/checkbox.d.ts +16 -23
- package/checkbox/internal/checkbox.js +38 -52
- package/checkbox/internal/checkbox.js.map +1 -1
- package/chips/filter-chip.js +5 -1
- package/chips/filter-chip.js.map +1 -1
- package/chips/harness.js.map +1 -1
- package/chips/input-chip.js +6 -1
- package/chips/input-chip.js.map +1 -1
- package/chips/internal/assist-chip.js +8 -4
- package/chips/internal/assist-chip.js.map +1 -1
- package/chips/internal/chip-set.js +6 -4
- package/chips/internal/chip-set.js.map +1 -1
- package/chips/internal/chip.d.ts +3 -0
- package/chips/internal/chip.js +7 -5
- package/chips/internal/chip.js.map +1 -1
- package/chips/internal/filter-chip.d.ts +2 -0
- package/chips/internal/filter-chip.js +11 -5
- package/chips/internal/filter-chip.js.map +1 -1
- package/chips/internal/input-chip.d.ts +2 -0
- package/chips/internal/input-chip.js +10 -4
- package/chips/internal/input-chip.js.map +1 -1
- package/chips/internal/multi-action-chip.js.map +1 -1
- package/chips/internal/trailing-icons.d.ts +1 -1
- package/chips/internal/trailing-icons.js +6 -5
- package/chips/internal/trailing-icons.js.map +1 -1
- package/common.d.ts +2 -0
- package/common.js +2 -0
- package/common.js.map +1 -1
- package/dialog/harness.js +1 -2
- package/dialog/harness.js.map +1 -1
- package/dialog/internal/_dialog.scss +1 -1
- package/dialog/internal/animations.js +14 -12
- package/dialog/internal/animations.js.map +1 -1
- package/dialog/internal/dialog-styles.css.js +1 -1
- package/dialog/internal/dialog-styles.css.js.map +1 -1
- package/dialog/internal/dialog.d.ts +6 -6
- package/dialog/internal/dialog.js +24 -24
- package/dialog/internal/dialog.js.map +1 -1
- package/fab/harness.js.map +1 -1
- package/fab/internal/_fab.scss +4 -0
- package/fab/internal/fab-styles.css.js +1 -1
- package/fab/internal/fab-styles.css.js.map +1 -1
- package/fab/internal/fab.js.map +1 -1
- package/fab/internal/shared.js +10 -11
- package/fab/internal/shared.js.map +1 -1
- package/field/harness.js.map +1 -1
- package/field/internal/_content.scss +185 -174
- package/field/internal/_filled-field.scss +147 -135
- package/field/internal/_label.scss +83 -72
- package/field/internal/_outlined-field.scss +276 -261
- package/field/internal/_supporting-text.scss +53 -42
- package/field/internal/field.js +26 -22
- package/field/internal/field.js.map +1 -1
- package/field/internal/filled-styles.css.js +1 -1
- package/field/internal/filled-styles.css.js.map +1 -1
- package/field/internal/outlined-styles.css.js +1 -1
- package/field/internal/outlined-styles.css.js.map +1 -1
- package/field/internal/shared-styles.css.js +1 -1
- package/field/internal/shared-styles.css.js.map +1 -1
- package/focus/internal/focus-ring.d.ts +2 -0
- package/focus/internal/focus-ring.js +3 -3
- package/focus/internal/focus-ring.js.map +1 -1
- package/icon/internal/_icon.scss +7 -4
- package/icon/internal/icon-styles.css.js +1 -1
- package/icon/internal/icon-styles.css.js.map +1 -1
- package/iconbutton/internal/icon-button.d.ts +9 -4
- package/iconbutton/internal/icon-button.js +35 -22
- package/iconbutton/internal/icon-button.js.map +1 -1
- package/internal/aria/aria.d.ts +4 -26
- package/internal/aria/aria.js +10 -28
- package/internal/aria/aria.js.map +1 -1
- package/internal/aria/delegate.js +2 -2
- package/internal/aria/delegate.js.map +1 -1
- package/internal/controller/attachable-controller.js +3 -5
- package/internal/controller/attachable-controller.js.map +1 -1
- package/internal/controller/form-submitter.d.ts +3 -5
- package/internal/controller/form-submitter.js +5 -7
- package/internal/controller/form-submitter.js.map +1 -1
- package/internal/controller/is-rtl.js +2 -2
- package/internal/controller/is-rtl.js.map +1 -1
- package/internal/controller/string-converter.js +1 -1
- package/internal/controller/string-converter.js.map +1 -1
- package/internal/motion/animation.js.map +1 -1
- package/labs/behaviors/element-internals.d.ts +45 -0
- package/labs/behaviors/element-internals.js +50 -0
- package/labs/behaviors/element-internals.js.map +1 -0
- package/labs/behaviors/focusable.d.ts +39 -0
- package/labs/behaviors/focusable.js +82 -0
- package/labs/behaviors/focusable.js.map +1 -0
- package/labs/behaviors/form-associated.d.ts +199 -0
- package/labs/behaviors/form-associated.js +155 -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/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/elevated-card.d.ts +18 -0
- package/labs/card/elevated-card.js +21 -0
- package/labs/card/elevated-card.js.map +1 -0
- package/labs/card/filled-card.d.ts +18 -0
- package/labs/card/filled-card.js +21 -0
- package/labs/card/filled-card.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 +39 -0
- package/labs/card/internal/_shared.scss +40 -0
- package/labs/card/internal/card.d.ts +13 -0
- package/labs/card/internal/card.js +20 -0
- package/labs/card/internal/card.js.map +1 -0
- package/labs/card/internal/elevated-styles.css.js +9 -0
- package/labs/card/internal/elevated-styles.css.js.map +1 -0
- package/labs/card/internal/elevated-styles.scss +10 -0
- package/labs/card/internal/filled-styles.css.js +9 -0
- package/labs/card/internal/filled-styles.css.js.map +1 -0
- package/labs/card/internal/filled-styles.scss +10 -0
- package/labs/card/internal/outlined-styles.css.js +9 -0
- package/labs/card/internal/outlined-styles.css.js.map +1 -0
- package/labs/card/internal/outlined-styles.scss +10 -0
- package/labs/card/internal/shared-styles.css.js +9 -0
- package/labs/card/internal/shared-styles.css.js.map +1 -0
- package/labs/card/internal/shared-styles.scss +10 -0
- package/labs/card/outlined-card.d.ts +18 -0
- package/labs/card/outlined-card.js +21 -0
- package/labs/card/outlined-card.js.map +1 -0
- package/labs/item/internal/_item.scss +1 -1
- package/labs/item/internal/item-styles.css.js +1 -1
- package/labs/item/internal/item-styles.css.js.map +1 -1
- package/labs/item/internal/item.js +8 -8
- package/labs/item/internal/item.js.map +1 -1
- package/labs/navigationbar/internal/constants.js.map +1 -1
- package/labs/navigationbar/internal/navigation-bar.d.ts +3 -0
- package/labs/navigationbar/internal/navigation-bar.js +18 -11
- package/labs/navigationbar/internal/navigation-bar.js.map +1 -1
- package/labs/navigationdrawer/internal/navigation-drawer-modal.d.ts +3 -0
- package/labs/navigationdrawer/internal/navigation-drawer-modal.js +10 -3
- package/labs/navigationdrawer/internal/navigation-drawer-modal.js.map +1 -1
- package/labs/navigationdrawer/internal/navigation-drawer.d.ts +3 -0
- package/labs/navigationdrawer/internal/navigation-drawer.js +8 -1
- package/labs/navigationdrawer/internal/navigation-drawer.js.map +1 -1
- package/labs/navigationtab/harness.js.map +1 -1
- package/labs/navigationtab/internal/navigation-tab.d.ts +6 -0
- package/labs/navigationtab/internal/navigation-tab.js +43 -27
- package/labs/navigationtab/internal/navigation-tab.js.map +1 -1
- package/labs/navigationtab/internal/state.js.map +1 -1
- package/labs/segmentedbutton/internal/segmented-button.d.ts +3 -0
- package/labs/segmentedbutton/internal/segmented-button.js +26 -12
- package/labs/segmentedbutton/internal/segmented-button.js.map +1 -1
- package/labs/segmentedbuttonset/internal/segmented-button-set.d.ts +5 -0
- package/labs/segmentedbuttonset/internal/segmented-button-set.js +14 -9
- package/labs/segmentedbuttonset/internal/segmented-button-set.js.map +1 -1
- package/list/harness.d.ts +3 -2
- package/list/harness.js.map +1 -1
- package/list/internal/list-controller.d.ts +1 -1
- package/list/internal/list-controller.js +7 -3
- package/list/internal/list-controller.js.map +1 -1
- package/list/internal/list-navigation-helpers.js.map +1 -1
- package/list/internal/list.d.ts +2 -2
- package/list/internal/list.js +8 -6
- package/list/internal/list.js.map +1 -1
- package/list/internal/listitem/_list-item.scss +18 -0
- package/list/internal/listitem/harness.d.ts +3 -3
- package/list/internal/listitem/harness.js.map +1 -1
- package/list/internal/listitem/list-item-styles.css.js +1 -1
- package/list/internal/listitem/list-item-styles.css.js.map +1 -1
- package/list/internal/listitem/list-item.d.ts +3 -2
- package/list/internal/listitem/list-item.js +20 -21
- package/list/internal/listitem/list-item.js.map +1 -1
- package/list/list-item.d.ts +4 -12
- package/list/list-item.js +5 -14
- package/list/list-item.js.map +1 -1
- package/menu/harness.js.map +1 -1
- package/menu/internal/_menu.scss +20 -1
- package/menu/internal/controllers/menuItemController.d.ts +7 -0
- package/menu/internal/controllers/menuItemController.js +17 -4
- package/menu/internal/controllers/menuItemController.js.map +1 -1
- package/menu/internal/controllers/shared.d.ts +9 -1
- package/menu/internal/controllers/shared.js +4 -4
- package/menu/internal/controllers/shared.js.map +1 -1
- package/menu/internal/controllers/surfacePositionController.d.ts +15 -2
- package/menu/internal/controllers/surfacePositionController.js +134 -56
- package/menu/internal/controllers/surfacePositionController.js.map +1 -1
- package/menu/internal/controllers/typeaheadController.js +19 -14
- package/menu/internal/controllers/typeaheadController.js.map +1 -1
- package/menu/internal/menu-styles.css.js +1 -1
- package/menu/internal/menu-styles.css.js.map +1 -1
- package/menu/internal/menu.d.ts +55 -17
- package/menu/internal/menu.js +175 -88
- package/menu/internal/menu.js.map +1 -1
- package/menu/internal/menuitem/_menu-item.scss +24 -0
- package/menu/internal/menuitem/harness.d.ts +3 -1
- package/menu/internal/menuitem/harness.js.map +1 -1
- package/menu/internal/menuitem/menu-item-styles.css.js +1 -1
- package/menu/internal/menuitem/menu-item-styles.css.js.map +1 -1
- package/menu/internal/menuitem/menu-item.d.ts +3 -2
- package/menu/internal/menuitem/menu-item.js +20 -20
- package/menu/internal/menuitem/menu-item.js.map +1 -1
- package/menu/internal/submenu/sub-menu.d.ts +9 -8
- package/menu/internal/submenu/sub-menu.js +35 -22
- package/menu/internal/submenu/sub-menu.js.map +1 -1
- package/menu/internal/types.js.map +1 -1
- package/menu/menu-item.js +1 -2
- package/menu/menu-item.js.map +1 -1
- package/menu/menu.js +1 -2
- package/menu/menu.js.map +1 -1
- package/package.json +1 -1
- package/progress/internal/_circular-progress.scss +2 -2
- package/progress/internal/_linear-progress.scss +1 -1
- package/progress/internal/circular-progress-styles.css.js +1 -1
- package/progress/internal/circular-progress-styles.css.js.map +1 -1
- package/progress/internal/circular-progress.js +11 -10
- package/progress/internal/circular-progress.js.map +1 -1
- package/progress/internal/linear-progress-styles.css.js +1 -1
- package/progress/internal/linear-progress-styles.css.js.map +1 -1
- package/progress/internal/linear-progress.d.ts +1 -1
- package/progress/internal/linear-progress.js +3 -3
- package/progress/internal/linear-progress.js.map +1 -1
- package/progress/internal/progress.js +4 -2
- package/progress/internal/progress.js.map +1 -1
- package/radio/internal/_radio.scss +144 -123
- package/radio/internal/radio-styles.css.js +1 -1
- package/radio/internal/radio-styles.css.js.map +1 -1
- package/radio/internal/radio.d.ts +12 -23
- package/radio/internal/radio.js +31 -50
- package/radio/internal/radio.js.map +1 -1
- package/radio/internal/single-selection-controller.js +1 -1
- package/radio/internal/single-selection-controller.js.map +1 -1
- package/radio/radio.js +1 -2
- package/radio/radio.js.map +1 -1
- package/ripple/internal/ripple.js +21 -18
- package/ripple/internal/ripple.js.map +1 -1
- package/select/filled-select.js +1 -2
- package/select/filled-select.js.map +1 -1
- package/select/harness.js +1 -1
- package/select/harness.js.map +1 -1
- package/select/internal/_shared.scss +4 -0
- package/select/internal/select.d.ts +25 -34
- package/select/internal/select.js +101 -91
- package/select/internal/select.js.map +1 -1
- package/select/internal/selectoption/select-option.d.ts +8 -6
- package/select/internal/selectoption/select-option.js +25 -23
- package/select/internal/selectoption/select-option.js.map +1 -1
- package/select/internal/selectoption/selectOptionController.js +1 -1
- package/select/internal/selectoption/selectOptionController.js.map +1 -1
- package/select/internal/shared-styles.css.js +1 -1
- package/select/internal/shared-styles.css.js.map +1 -1
- package/select/outlined-select.js +1 -2
- package/select/outlined-select.js.map +1 -1
- package/select/select-option.js +1 -2
- package/select/select-option.js.map +1 -1
- package/slider/harness.js +5 -5
- package/slider/harness.js.map +1 -1
- package/slider/internal/_slider.scss +68 -30
- package/slider/internal/slider-styles.css.js +1 -1
- package/slider/internal/slider-styles.css.js.map +1 -1
- package/slider/internal/slider.d.ts +16 -25
- package/slider/internal/slider.js +111 -115
- package/slider/internal/slider.js.map +1 -1
- package/switch/internal/_handle.scss +159 -141
- package/switch/internal/_icon.scss +95 -72
- package/switch/internal/_switch.scss +90 -95
- package/switch/internal/_track.scss +110 -77
- package/switch/internal/switch-styles.css.js +1 -1
- package/switch/internal/switch-styles.css.js.map +1 -1
- package/switch/internal/switch.d.ts +9 -25
- package/switch/internal/switch.js +31 -57
- package/switch/internal/switch.js.map +1 -1
- package/switch/switch.js +1 -2
- package/switch/switch.js.map +1 -1
- package/tabs/harness.js +3 -3
- package/tabs/harness.js.map +1 -1
- package/tabs/internal/_tab.scss +27 -35
- package/tabs/internal/primary-tab.d.ts +0 -2
- package/tabs/internal/tab-styles.css.js +1 -1
- package/tabs/internal/tab-styles.css.js.map +1 -1
- package/tabs/internal/tab.d.ts +10 -5
- package/tabs/internal/tab.js +43 -22
- package/tabs/internal/tab.js.map +1 -1
- package/tabs/internal/tabs.d.ts +7 -4
- package/tabs/internal/tabs.js +23 -22
- package/tabs/internal/tabs.js.map +1 -1
- package/textfield/filled-text-field.js +1 -2
- package/textfield/filled-text-field.js.map +1 -1
- package/textfield/harness.js +3 -2
- package/textfield/harness.js.map +1 -1
- package/textfield/internal/text-field.d.ts +33 -18
- package/textfield/internal/text-field.js +96 -58
- package/textfield/internal/text-field.js.map +1 -1
- package/textfield/outlined-text-field.js +1 -2
- package/textfield/outlined-text-field.js.map +1 -1
- package/tokens/_index.scss +3 -0
- package/tokens/_md-comp-elevated-card.scss +63 -0
- package/tokens/_md-comp-filled-card.scss +63 -0
- package/tokens/_md-comp-icon.scss +2 -0
- package/tokens/_md-comp-outlined-card.scss +69 -0
- package/tokens/_md-comp-test-table.scss +1 -0
- package/internal/controller/element-internals.d.ts +0 -35
- package/internal/controller/element-internals.js +0 -24
- package/internal/controller/element-internals.js.map +0 -1
- package/list/internal/listitem/forced-colors-styles.css.js +0 -9
- package/list/internal/listitem/forced-colors-styles.css.js.map +0 -1
- package/list/internal/listitem/forced-colors-styles.scss +0 -19
- package/menu/internal/forced-colors-styles.css.js +0 -9
- package/menu/internal/forced-colors-styles.css.js.map +0 -1
- package/menu/internal/forced-colors-styles.scss +0 -12
- package/menu/internal/menuitem/forced-colors-styles.css.js +0 -9
- package/menu/internal/menuitem/forced-colors-styles.css.js.map +0 -1
- package/menu/internal/menuitem/forced-colors-styles.scss +0 -26
- package/radio/internal/forced-colors-styles.css.js +0 -9
- package/radio/internal/forced-colors-styles.css.js.map +0 -1
- package/radio/internal/forced-colors-styles.scss +0 -29
- package/select/internal/filled-forced-colors-styles.css.d.ts +0 -1
- package/select/internal/filled-forced-colors-styles.css.js +0 -9
- package/select/internal/filled-forced-colors-styles.css.js.map +0 -1
- package/select/internal/filled-forced-colors-styles.scss +0 -29
- package/select/internal/outlined-forced-colors-styles.css.d.ts +0 -1
- package/select/internal/outlined-forced-colors-styles.css.js +0 -9
- package/select/internal/outlined-forced-colors-styles.css.js.map +0 -1
- package/select/internal/outlined-forced-colors-styles.scss +0 -29
- package/switch/internal/forced-colors-styles.css.d.ts +0 -1
- package/switch/internal/forced-colors-styles.css.js +0 -9
- package/switch/internal/forced-colors-styles.css.js.map +0 -1
- package/switch/internal/forced-colors-styles.scss +0 -42
- package/textfield/internal/filled-forced-colors-styles.css.d.ts +0 -1
- package/textfield/internal/filled-forced-colors-styles.css.js +0 -9
- package/textfield/internal/filled-forced-colors-styles.css.js.map +0 -1
- package/textfield/internal/filled-forced-colors-styles.scss +0 -29
- package/textfield/internal/outlined-forced-colors-styles.css.d.ts +0 -1
- package/textfield/internal/outlined-forced-colors-styles.css.js +0 -9
- package/textfield/internal/outlined-forced-colors-styles.css.js.map +0 -1
- package/textfield/internal/outlined-forced-colors-styles.scss +0 -29
- /package/{list/internal/listitem/forced-colors-styles.css.d.ts → labs/card/internal/elevated-styles.css.d.ts} +0 -0
- /package/{menu/internal/forced-colors-styles.css.d.ts → labs/card/internal/filled-styles.css.d.ts} +0 -0
- /package/{menu/internal/menuitem/forced-colors-styles.css.d.ts → labs/card/internal/outlined-styles.css.d.ts} +0 -0
- /package/{radio/internal/forced-colors-styles.css.d.ts → labs/card/internal/shared-styles.css.d.ts} +0 -0
|
@@ -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';
|
|
@@ -0,0 +1,155 @@
|
|
|
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
|
+
import { internals } from './element-internals.js';
|
|
9
|
+
/**
|
|
10
|
+
* A symbol property to retrieve the form value for an element.
|
|
11
|
+
*/
|
|
12
|
+
export const getFormValue = Symbol('getFormValue');
|
|
13
|
+
/**
|
|
14
|
+
* A symbol property to retrieve the form state for an element.
|
|
15
|
+
*/
|
|
16
|
+
export const getFormState = Symbol('getFormState');
|
|
17
|
+
/**
|
|
18
|
+
* Mixes in form-associated behavior for a class. This allows an element to add
|
|
19
|
+
* values to `<form>` elements.
|
|
20
|
+
*
|
|
21
|
+
* Implementing classes should provide a `[formValue]` to return the current
|
|
22
|
+
* value of the element, as well as reset and restore callbacks.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* const base = mixinFormAssociated(mixinElementInternals(LitElement));
|
|
27
|
+
*
|
|
28
|
+
* class MyControl extends base {
|
|
29
|
+
* \@property()
|
|
30
|
+
* value = '';
|
|
31
|
+
*
|
|
32
|
+
* override [getFormValue]() {
|
|
33
|
+
* return this.value;
|
|
34
|
+
* }
|
|
35
|
+
*
|
|
36
|
+
* override formResetCallback() {
|
|
37
|
+
* const defaultValue = this.getAttribute('value');
|
|
38
|
+
* this.value = defaultValue;
|
|
39
|
+
* }
|
|
40
|
+
*
|
|
41
|
+
* override formStateRestoreCallback(state: string) {
|
|
42
|
+
* this.value = state;
|
|
43
|
+
* }
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* Elements may optionally provide a `[formState]` if their values do not
|
|
48
|
+
* represent the state of the component.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* const base = mixinFormAssociated(mixinElementInternals(LitElement));
|
|
53
|
+
*
|
|
54
|
+
* class MyCheckbox extends base {
|
|
55
|
+
* \@property()
|
|
56
|
+
* value = 'on';
|
|
57
|
+
*
|
|
58
|
+
* \@property({type: Boolean})
|
|
59
|
+
* checked = false;
|
|
60
|
+
*
|
|
61
|
+
* override [getFormValue]() {
|
|
62
|
+
* return this.checked ? this.value : null;
|
|
63
|
+
* }
|
|
64
|
+
*
|
|
65
|
+
* override [getFormState]() {
|
|
66
|
+
* return String(this.checked);
|
|
67
|
+
* }
|
|
68
|
+
*
|
|
69
|
+
* override formResetCallback() {
|
|
70
|
+
* const defaultValue = this.hasAttribute('checked');
|
|
71
|
+
* this.checked = defaultValue;
|
|
72
|
+
* }
|
|
73
|
+
*
|
|
74
|
+
* override formStateRestoreCallback(state: string) {
|
|
75
|
+
* this.checked = Boolean(state);
|
|
76
|
+
* }
|
|
77
|
+
* }
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* IMPORTANT: Requires declares for lit-analyzer
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts
|
|
83
|
+
* const base = mixinFormAssociated(mixinElementInternals(LitElement));
|
|
84
|
+
* class MyControl extends base {
|
|
85
|
+
* // Writable mixin properties for lit-html binding, needed for lit-analyzer
|
|
86
|
+
* declare disabled: boolean;
|
|
87
|
+
* declare name: string;
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* @param base The class to mix functionality into. The base class must use
|
|
92
|
+
* `mixinElementInternals()`.
|
|
93
|
+
* @return The provided class with `FormAssociated` mixed in.
|
|
94
|
+
*/
|
|
95
|
+
export function mixinFormAssociated(base) {
|
|
96
|
+
class FormAssociatedElement extends base {
|
|
97
|
+
get form() {
|
|
98
|
+
return this[internals].form;
|
|
99
|
+
}
|
|
100
|
+
get labels() {
|
|
101
|
+
return this[internals].labels;
|
|
102
|
+
}
|
|
103
|
+
// name attribute must be set synchronously
|
|
104
|
+
get name() {
|
|
105
|
+
return this.getAttribute('name') ?? '';
|
|
106
|
+
}
|
|
107
|
+
set name(name) {
|
|
108
|
+
const prev = this.name;
|
|
109
|
+
// Setting name to null or empty string does not remove the attribute.
|
|
110
|
+
this.setAttribute('name', name);
|
|
111
|
+
// Explicit requestUpdate needed for Lit 2.0
|
|
112
|
+
this.requestUpdate('name', prev);
|
|
113
|
+
}
|
|
114
|
+
// disabled attribute must be set synchronously
|
|
115
|
+
get disabled() {
|
|
116
|
+
return this.hasAttribute('disabled');
|
|
117
|
+
}
|
|
118
|
+
set disabled(disabled) {
|
|
119
|
+
const prev = this.disabled;
|
|
120
|
+
this.toggleAttribute('disabled', disabled);
|
|
121
|
+
// Explicit requestUpdate needed for Lit 2.0
|
|
122
|
+
this.requestUpdate('disabled', prev);
|
|
123
|
+
}
|
|
124
|
+
requestUpdate(name, oldValue, options) {
|
|
125
|
+
super.requestUpdate(name, oldValue, options);
|
|
126
|
+
// If any properties change, update the form value, which may have changed
|
|
127
|
+
// as well.
|
|
128
|
+
// Update the form value synchronously in `requestUpdate()` rather than
|
|
129
|
+
// `update()` or `updated()`, which are async. This is necessary to ensure
|
|
130
|
+
// that form data is updated in time for synchronous event listeners.
|
|
131
|
+
this[internals].setFormValue(this[getFormValue](), this[getFormState]());
|
|
132
|
+
}
|
|
133
|
+
[getFormValue]() {
|
|
134
|
+
// Closure does not allow abstract symbol members, so a default
|
|
135
|
+
// implementation is needed.
|
|
136
|
+
throw new Error('Implement [getFormValue]');
|
|
137
|
+
}
|
|
138
|
+
[getFormState]() {
|
|
139
|
+
return this[getFormValue]();
|
|
140
|
+
}
|
|
141
|
+
formDisabledCallback(disabled) {
|
|
142
|
+
this.disabled = disabled;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/** @nocollapse */
|
|
146
|
+
FormAssociatedElement.formAssociated = true;
|
|
147
|
+
__decorate([
|
|
148
|
+
property({ reflect: true })
|
|
149
|
+
], FormAssociatedElement.prototype, "name", null);
|
|
150
|
+
__decorate([
|
|
151
|
+
property({ type: Boolean, reflect: true })
|
|
152
|
+
], FormAssociatedElement.prototype, "disabled", null);
|
|
153
|
+
return FormAssociatedElement;
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=form-associated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-associated.js","sourceRoot":"","sources":["form-associated.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAGH,OAAO,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAC,SAAS,EAAuB,MAAM,wBAAwB,CAAC;AA0GvE;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;AAEnD;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6EG;AACH,MAAM,UAAU,mBAAmB,CAEjC,IAAO;IACP,MAAe,qBAAsB,SAAQ,IAAI;QAI/C,IAAI,IAAI;YACN,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC;QAC9B,CAAC;QAED,IAAI,MAAM;YACR,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC;QAChC,CAAC;QAED,2CAA2C;QAE3C,IAAI,IAAI;YACN,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACzC,CAAC;QACD,IAAI,IAAI,CAAC,IAAY;YACnB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;YACvB,sEAAsE;YACtE,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YAChC,4CAA4C;YAC5C,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACnC,CAAC;QAED,+CAA+C;QAE/C,IAAI,QAAQ;YACV,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;QACvC,CAAC;QACD,IAAI,QAAQ,CAAC,QAAiB;YAC5B,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC;YAC3B,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;YAC3C,4CAA4C;YAC5C,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QACvC,CAAC;QAEQ,aAAa,CACpB,IAAkB,EAClB,QAAkB,EAClB,OAA6B;YAE7B,KAAK,CAAC,aAAa,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;YAC7C,0EAA0E;YAC1E,WAAW;YACX,uEAAuE;YACvE,0EAA0E;YAC1E,qEAAqE;YACrE,IAAI,CAAC,SAAS,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,EAAE,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;QAC3E,CAAC;QAED,CAAC,YAAY,CAAC;YACZ,+DAA+D;YAC/D,4BAA4B;YAC5B,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAC9C,CAAC;QAED,CAAC,YAAY,CAAC;YACZ,OAAO,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC;QAC9B,CAAC;QAED,oBAAoB,CAAC,QAAiB;YACpC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAC3B,CAAC;;IA9DD,kBAAkB;IACF,oCAAc,GAAG,IAAI,CAAC;IAYtC;QADC,QAAQ,CAAC,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC;qDAGzB;IAWD;QADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;yDAGxC;IA4CH,OAAO,qBAAqB,CAAC;AAC/B,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {LitElement, PropertyDeclaration} from 'lit';\nimport {property} from 'lit/decorators.js';\n\nimport {internals, WithElementInternals} from './element-internals.js';\nimport {MixinBase, MixinReturn} from './mixin.js';\n\n/**\n * A form-associated element.\n *\n * IMPORTANT: Requires declares for lit-analyzer\n * @example\n * ```ts\n * const base = mixinFormAssociated(mixinElementInternals(LitElement));\n * class MyControl extends base {\n * // Writable mixin properties for lit-html binding, needed for lit-analyzer\n * declare disabled: boolean;\n * declare name: string;\n * }\n * ```\n */\nexport interface FormAssociated {\n /**\n * The associated form element with which this element's value will submit.\n */\n readonly form: HTMLFormElement | null;\n\n /**\n * The labels this element is associated with.\n */\n readonly labels: NodeList;\n\n /**\n * The HTML name to use in form submission.\n */\n name: string;\n\n /**\n * Whether or not the element is disabled.\n */\n disabled: boolean;\n\n /**\n * Gets the current form value of a component.\n *\n * @return The current form value.\n */\n [getFormValue](): FormValue | null;\n\n /**\n * Gets the current form state of a component. Defaults to the component's\n * `[formValue]`.\n *\n * Use this when the state of an element is different from its value, such as\n * checkboxes (internal boolean state and a user string value).\n *\n * @return The current form state, defaults to the form value.\n */\n [getFormState](): FormValue | null;\n\n /**\n * A callback for when a form component should be disabled or enabled. This\n * can be called in a variety of situations, such as disabled `<fieldset>`s.\n *\n * @param disabled Whether or not the form control should be disabled.\n */\n formDisabledCallback(disabled: boolean): void;\n\n /**\n * A callback for when the form requests to reset its value. Typically, the\n * default value that is reset is represented in the attribute of an element.\n *\n * This means the attribute used for the value should not update as the value\n * changes. For example, a checkbox should not change its default `checked`\n * attribute when selected. Ensure form values do not reflect.\n */\n formResetCallback(): void;\n\n /**\n * A callback for when the form restores the state of a component. For\n * example, when a page is reloaded or forms are autofilled.\n *\n * @param state The state to restore, or null to reset the form control's\n * value.\n * @param reason The reason state was restored, either `'restore'` or\n * `'autocomplete'`.\n */\n formStateRestoreCallback(\n state: FormRestoreState | null,\n reason: FormRestoreReason,\n ): void;\n\n /**\n * An optional callback for when the associated form changes.\n *\n * @param form The new associated form, or `null` if there is none.\n */\n formAssociatedCallback?(form: HTMLFormElement | null): void;\n}\n\n/**\n * The constructor of a `FormAssociated` element.\n */\nexport interface FormAssociatedConstructor {\n /**\n * Indicates that an element is participating in form association.\n */\n readonly formAssociated: true;\n}\n\n/**\n * A symbol property to retrieve the form value for an element.\n */\nexport const getFormValue = Symbol('getFormValue');\n\n/**\n * A symbol property to retrieve the form state for an element.\n */\nexport const getFormState = Symbol('getFormState');\n\n/**\n * Mixes in form-associated behavior for a class. This allows an element to add\n * values to `<form>` elements.\n *\n * Implementing classes should provide a `[formValue]` to return the current\n * value of the element, as well as reset and restore callbacks.\n *\n * @example\n * ```ts\n * const base = mixinFormAssociated(mixinElementInternals(LitElement));\n *\n * class MyControl extends base {\n * \\@property()\n * value = '';\n *\n * override [getFormValue]() {\n * return this.value;\n * }\n *\n * override formResetCallback() {\n * const defaultValue = this.getAttribute('value');\n * this.value = defaultValue;\n * }\n *\n * override formStateRestoreCallback(state: string) {\n * this.value = state;\n * }\n * }\n * ```\n *\n * Elements may optionally provide a `[formState]` if their values do not\n * represent the state of the component.\n *\n * @example\n * ```ts\n * const base = mixinFormAssociated(mixinElementInternals(LitElement));\n *\n * class MyCheckbox extends base {\n * \\@property()\n * value = 'on';\n *\n * \\@property({type: Boolean})\n * checked = false;\n *\n * override [getFormValue]() {\n * return this.checked ? this.value : null;\n * }\n *\n * override [getFormState]() {\n * return String(this.checked);\n * }\n *\n * override formResetCallback() {\n * const defaultValue = this.hasAttribute('checked');\n * this.checked = defaultValue;\n * }\n *\n * override formStateRestoreCallback(state: string) {\n * this.checked = Boolean(state);\n * }\n * }\n * ```\n *\n * IMPORTANT: Requires declares for lit-analyzer\n * @example\n * ```ts\n * const base = mixinFormAssociated(mixinElementInternals(LitElement));\n * class MyControl extends base {\n * // Writable mixin properties for lit-html binding, needed for lit-analyzer\n * declare disabled: boolean;\n * declare name: string;\n * }\n * ```\n *\n * @param base The class to mix functionality into. The base class must use\n * `mixinElementInternals()`.\n * @return The provided class with `FormAssociated` mixed in.\n */\nexport function mixinFormAssociated<\n T extends MixinBase<LitElement & WithElementInternals>,\n>(base: T): MixinReturn<T & FormAssociatedConstructor, FormAssociated> {\n abstract class FormAssociatedElement extends base implements FormAssociated {\n /** @nocollapse */\n static readonly formAssociated = true;\n\n get form() {\n return this[internals].form;\n }\n\n get labels() {\n return this[internals].labels;\n }\n\n // name attribute must be set synchronously\n @property({reflect: true})\n get name() {\n return this.getAttribute('name') ?? '';\n }\n set name(name: string) {\n const prev = this.name;\n // Setting name to null or empty string does not remove the attribute.\n this.setAttribute('name', name);\n // Explicit requestUpdate needed for Lit 2.0\n this.requestUpdate('name', prev);\n }\n\n // disabled attribute must be set synchronously\n @property({type: Boolean, reflect: true})\n get disabled() {\n return this.hasAttribute('disabled');\n }\n set disabled(disabled: boolean) {\n const prev = this.disabled;\n this.toggleAttribute('disabled', disabled);\n // Explicit requestUpdate needed for Lit 2.0\n this.requestUpdate('disabled', prev);\n }\n\n override requestUpdate(\n name?: PropertyKey,\n oldValue?: unknown,\n options?: PropertyDeclaration,\n ) {\n super.requestUpdate(name, oldValue, options);\n // If any properties change, update the form value, which may have changed\n // as well.\n // Update the form value synchronously in `requestUpdate()` rather than\n // `update()` or `updated()`, which are async. This is necessary to ensure\n // that form data is updated in time for synchronous event listeners.\n this[internals].setFormValue(this[getFormValue](), this[getFormState]());\n }\n\n [getFormValue](): FormValue | null {\n // Closure does not allow abstract symbol members, so a default\n // implementation is needed.\n throw new Error('Implement [getFormValue]');\n }\n\n [getFormState](): FormValue | null {\n return this[getFormValue]();\n }\n\n formDisabledCallback(disabled: boolean) {\n this.disabled = disabled;\n }\n\n abstract formResetCallback(): void;\n\n abstract formStateRestoreCallback(\n state: FormRestoreState | null,\n reason: FormRestoreReason,\n ): void;\n }\n\n return FormAssociatedElement;\n}\n\n/**\n * A value that can be provided for form submission and state.\n */\nexport type FormValue = File | string | FormData;\n\n/**\n * A value to be restored for a component's form value. If a component's form\n * state is a `FormData` object, its entry list of name and values will be\n * provided.\n */\nexport type FormRestoreState =\n | File\n | string\n | Array<[string, FormDataEntryValue]>;\n\n/**\n * The reason a form component is being restored for, either `'restore'` for\n * browser restoration or `'autocomplete'` for restoring user values.\n */\nexport type FormRestoreReason = 'restore' | 'autocomplete';\n"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* The base class for a mixin with an optional expected base class type.
|
|
8
|
+
*
|
|
9
|
+
* @template ExpectedBase Optional expected base class type, such as
|
|
10
|
+
* `LitElement`.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* interface Foo {
|
|
15
|
+
* isFoo: boolean;
|
|
16
|
+
* }
|
|
17
|
+
*
|
|
18
|
+
* function mixinFoo<T extends MixinBase>(base: T): MixinReturn<T, Foo> {
|
|
19
|
+
* // Mixins must be `abstract`
|
|
20
|
+
* abstract class FooImpl extends base implements Foo {
|
|
21
|
+
* isFoo = true;
|
|
22
|
+
* }
|
|
23
|
+
*
|
|
24
|
+
* return FooImpl;
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export type MixinBase<ExpectedBase = object> = abstract new (...args: any[]) => ExpectedBase;
|
|
29
|
+
/**
|
|
30
|
+
* The return value of a mixin.
|
|
31
|
+
*
|
|
32
|
+
* @template MixinBase The generic that extends `MixinBase` used for the mixin's
|
|
33
|
+
* base class argument.
|
|
34
|
+
* @template MixinClass Optional interface of fuctionality that was mixed in.
|
|
35
|
+
* Omit if no additional APIs were added (such as purely overriding base
|
|
36
|
+
* class functionality).
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* interface Foo {
|
|
41
|
+
* isFoo: boolean;
|
|
42
|
+
* }
|
|
43
|
+
*
|
|
44
|
+
* // Mixins must be `abstract`
|
|
45
|
+
* function mixinFoo<T extends MixinBase>(base: T): MixinReturn<T, Foo> {
|
|
46
|
+
* abstract class FooImpl extends base implements Foo {
|
|
47
|
+
* isFoo = true;
|
|
48
|
+
* }
|
|
49
|
+
*
|
|
50
|
+
* return FooImpl;
|
|
51
|
+
* }
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export type MixinReturn<MixinBase, MixinClass = object> = (abstract new (...args: any[]) => MixinClass) & MixinBase;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mixin.js","sourceRoot":"","sources":["mixin.ts"],"names":[],"mappings":"AAAA;;;;GAIG","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/**\n * The base class for a mixin with an optional expected base class type.\n *\n * @template ExpectedBase Optional expected base class type, such as\n * `LitElement`.\n *\n * @example\n * ```ts\n * interface Foo {\n * isFoo: boolean;\n * }\n *\n * function mixinFoo<T extends MixinBase>(base: T): MixinReturn<T, Foo> {\n * // Mixins must be `abstract`\n * abstract class FooImpl extends base implements Foo {\n * isFoo = true;\n * }\n *\n * return FooImpl;\n * }\n * ```\n */\nexport type MixinBase<ExpectedBase = object> = abstract new (\n // Mixins must have a constructor with `...args: any[]`\n // tslint:disable-next-line:no-any\n ...args: any[]\n) => ExpectedBase;\n\n/**\n * The return value of a mixin.\n *\n * @template MixinBase The generic that extends `MixinBase` used for the mixin's\n * base class argument.\n * @template MixinClass Optional interface of fuctionality that was mixed in.\n * Omit if no additional APIs were added (such as purely overriding base\n * class functionality).\n *\n * @example\n * ```ts\n * interface Foo {\n * isFoo: boolean;\n * }\n *\n * // Mixins must be `abstract`\n * function mixinFoo<T extends MixinBase>(base: T): MixinReturn<T, Foo> {\n * abstract class FooImpl extends base implements Foo {\n * isFoo = true;\n * }\n *\n * return FooImpl;\n * }\n * ```\n */\nexport type MixinReturn<MixinBase, MixinClass = object> =\n // Mixins must have a constructor with `...args: any[]`\n // tslint:disable-next-line:no-any\n (abstract new (...args: any[]) => MixinClass) & MixinBase;\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { Card } from './internal/card.js';
|
|
7
|
+
declare global {
|
|
8
|
+
interface HTMLElementTagNameMap {
|
|
9
|
+
'md-elevated-card': MdElevatedCard;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* @final
|
|
14
|
+
* @suppress {visibility}
|
|
15
|
+
*/
|
|
16
|
+
export declare class MdElevatedCard extends Card {
|
|
17
|
+
static styles: import("lit").CSSResult[];
|
|
18
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { __decorate } from "tslib";
|
|
7
|
+
import { customElement } from 'lit/decorators.js';
|
|
8
|
+
import { Card } from './internal/card.js';
|
|
9
|
+
import { styles as elevatedStyles } from './internal/elevated-styles.css.js';
|
|
10
|
+
import { styles as sharedStyles } from './internal/shared-styles.css.js';
|
|
11
|
+
/**
|
|
12
|
+
* @final
|
|
13
|
+
* @suppress {visibility}
|
|
14
|
+
*/
|
|
15
|
+
export let MdElevatedCard = class MdElevatedCard extends Card {
|
|
16
|
+
};
|
|
17
|
+
MdElevatedCard.styles = [sharedStyles, elevatedStyles];
|
|
18
|
+
MdElevatedCard = __decorate([
|
|
19
|
+
customElement('md-elevated-card')
|
|
20
|
+
], MdElevatedCard);
|
|
21
|
+
//# sourceMappingURL=elevated-card.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elevated-card.js","sourceRoot":"","sources":["elevated-card.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAC,IAAI,EAAC,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAC,MAAM,IAAI,cAAc,EAAC,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAC,MAAM,IAAI,YAAY,EAAC,MAAM,iCAAiC,CAAC;AAQvE;;;GAGG;AAEI,WAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,IAAI;;AACtB,qBAAM,GAAG,CAAC,YAAY,EAAE,cAAc,CAAC,AAAjC,CAAkC;AAD7C,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CAE1B","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {customElement} from 'lit/decorators.js';\n\nimport {Card} from './internal/card.js';\nimport {styles as elevatedStyles} from './internal/elevated-styles.css.js';\nimport {styles as sharedStyles} from './internal/shared-styles.css.js';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'md-elevated-card': MdElevatedCard;\n }\n}\n\n/**\n * @final\n * @suppress {visibility}\n */\n@customElement('md-elevated-card')\nexport class MdElevatedCard extends Card {\n static override styles = [sharedStyles, elevatedStyles];\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { Card } from './internal/card.js';
|
|
7
|
+
declare global {
|
|
8
|
+
interface HTMLElementTagNameMap {
|
|
9
|
+
'md-filled-card': MdFilledCard;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* @final
|
|
14
|
+
* @suppress {visibility}
|
|
15
|
+
*/
|
|
16
|
+
export declare class MdFilledCard extends Card {
|
|
17
|
+
static styles: import("lit").CSSResult[];
|
|
18
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { __decorate } from "tslib";
|
|
7
|
+
import { customElement } from 'lit/decorators.js';
|
|
8
|
+
import { Card } from './internal/card.js';
|
|
9
|
+
import { styles as filledStyles } from './internal/filled-styles.css.js';
|
|
10
|
+
import { styles as sharedStyles } from './internal/shared-styles.css.js';
|
|
11
|
+
/**
|
|
12
|
+
* @final
|
|
13
|
+
* @suppress {visibility}
|
|
14
|
+
*/
|
|
15
|
+
export let MdFilledCard = class MdFilledCard extends Card {
|
|
16
|
+
};
|
|
17
|
+
MdFilledCard.styles = [sharedStyles, filledStyles];
|
|
18
|
+
MdFilledCard = __decorate([
|
|
19
|
+
customElement('md-filled-card')
|
|
20
|
+
], MdFilledCard);
|
|
21
|
+
//# sourceMappingURL=filled-card.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filled-card.js","sourceRoot":"","sources":["filled-card.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAC,IAAI,EAAC,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAC,MAAM,IAAI,YAAY,EAAC,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAC,MAAM,IAAI,YAAY,EAAC,MAAM,iCAAiC,CAAC;AAQvE;;;GAGG;AAEI,WAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,IAAI;;AACpB,mBAAM,GAAG,CAAC,YAAY,EAAE,YAAY,CAAC,AAA/B,CAAgC;AAD3C,YAAY;IADxB,aAAa,CAAC,gBAAgB,CAAC;GACnB,YAAY,CAExB","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {customElement} from 'lit/decorators.js';\n\nimport {Card} from './internal/card.js';\nimport {styles as filledStyles} from './internal/filled-styles.css.js';\nimport {styles as sharedStyles} from './internal/shared-styles.css.js';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'md-filled-card': MdFilledCard;\n }\n}\n\n/**\n * @final\n * @suppress {visibility}\n */\n@customElement('md-filled-card')\nexport class MdFilledCard extends Card {\n static override styles = [sharedStyles, filledStyles];\n}\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 Google LLC
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
//
|
|
5
|
+
|
|
6
|
+
// go/keep-sorted start
|
|
7
|
+
@use 'sass:list';
|
|
8
|
+
// go/keep-sorted end
|
|
9
|
+
// go/keep-sorted start
|
|
10
|
+
@use '../../../tokens';
|
|
11
|
+
// go/keep-sorted end
|
|
12
|
+
|
|
13
|
+
@mixin theme($tokens) {
|
|
14
|
+
$supported-tokens: tokens.$md-comp-elevated-card-supported-tokens;
|
|
15
|
+
|
|
16
|
+
@each $token, $value in $tokens {
|
|
17
|
+
@if list.index($supported-tokens, $token) == null {
|
|
18
|
+
@error 'Elevated card `#{$token}` is not a supported token.';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@if $value {
|
|
22
|
+
--md-elevated-card-#{$token}: #{$value};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@mixin styles() {
|
|
28
|
+
$tokens: tokens.md-comp-elevated-card-values();
|
|
29
|
+
|
|
30
|
+
:host {
|
|
31
|
+
@each $token, $value in $tokens {
|
|
32
|
+
--_#{$token}: var(--md-elevated-card-#{$token}, #{$value});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 Google LLC
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
//
|
|
5
|
+
|
|
6
|
+
// go/keep-sorted start
|
|
7
|
+
@use 'sass:list';
|
|
8
|
+
// go/keep-sorted end
|
|
9
|
+
// go/keep-sorted start
|
|
10
|
+
@use '../../../tokens';
|
|
11
|
+
// go/keep-sorted end
|
|
12
|
+
|
|
13
|
+
@mixin theme($tokens) {
|
|
14
|
+
$supported-tokens: tokens.$md-comp-filled-card-supported-tokens;
|
|
15
|
+
|
|
16
|
+
@each $token, $value in $tokens {
|
|
17
|
+
@if list.index($supported-tokens, $token) == null {
|
|
18
|
+
@error 'Filled card `#{$token}` is not a supported token.';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@if $value {
|
|
22
|
+
--md-filled-card-#{$token}: #{$value};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@mixin styles() {
|
|
28
|
+
$tokens: tokens.md-comp-filled-card-values();
|
|
29
|
+
|
|
30
|
+
:host {
|
|
31
|
+
@each $token, $value in $tokens {
|
|
32
|
+
--_#{$token}: var(--md-filled-card-#{$token}, #{$value});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 Google LLC
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
//
|
|
5
|
+
|
|
6
|
+
// go/keep-sorted start
|
|
7
|
+
@use 'sass:list';
|
|
8
|
+
// go/keep-sorted end
|
|
9
|
+
// go/keep-sorted start
|
|
10
|
+
@use '../../../tokens';
|
|
11
|
+
// go/keep-sorted end
|
|
12
|
+
|
|
13
|
+
@mixin theme($tokens) {
|
|
14
|
+
$supported-tokens: tokens.$md-comp-outlined-card-supported-tokens;
|
|
15
|
+
|
|
16
|
+
@each $token, $value in $tokens {
|
|
17
|
+
@if list.index($supported-tokens, $token) == null {
|
|
18
|
+
@error 'Outlined card `#{$token}` is not a supported token.';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@if $value {
|
|
22
|
+
--md-outlined-card-#{$token}: #{$value};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@mixin styles() {
|
|
28
|
+
$tokens: tokens.md-comp-outlined-card-values();
|
|
29
|
+
|
|
30
|
+
:host {
|
|
31
|
+
@each $token, $value in $tokens {
|
|
32
|
+
--_#{$token}: var(--md-outlined-card-#{$token}, #{$value});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.container {
|
|
37
|
+
outline: var(--_outline-width) solid var(--_outline-color);
|
|
38
|
+
}
|
|
39
|
+
}
|