@material/web 2.4.2-nightly.2fe7e22.0 → 2.4.2-nightly.3758f46.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/button/internal/button.d.ts +0 -4
- package/button/internal/button.js.map +1 -1
- package/checkbox/internal/checkbox.d.ts +2 -2
- package/checkbox/internal/checkbox.js.map +1 -1
- package/chips/internal/chip.d.ts +2 -0
- package/icon/internal/icon.d.ts +1 -1
- package/icon/internal/icon.js +1 -1
- package/icon/internal/icon.js.map +1 -1
- package/iconbutton/internal/icon-button.d.ts +0 -4
- package/iconbutton/internal/icon-button.js.map +1 -1
- package/internal/aria/aria.d.ts +1 -1
- package/internal/events/dispatch-hooks.js +31 -35
- package/internal/events/dispatch-hooks.js.map +1 -1
- package/labs/behaviors/form-associated.d.ts +0 -22
- package/labs/behaviors/form-associated.js +0 -11
- package/labs/behaviors/form-associated.js.map +1 -1
- package/labs/gb/components/button/_button-tokens.scss +30 -30
- package/labs/gb/components/button/button.css +1 -1
- package/labs/gb/components/button/button.css.map +1 -1
- package/labs/gb/components/button/button.cssresult.js +1 -1
- package/labs/gb/components/button/button.cssresult.js.map +1 -1
- package/labs/gb/components/button/button.d.ts +1 -16
- package/labs/gb/components/button/button.js +10 -33
- package/labs/gb/components/button/button.js.map +1 -1
- package/labs/gb/components/button/button.scss +25 -25
- package/labs/gb/components/button/md-button.d.ts +1 -1
- package/labs/gb/components/button/md-button.js +9 -9
- package/labs/gb/components/button/md-button.js.map +1 -1
- package/labs/gb/components/card/card.d.ts +1 -11
- package/labs/gb/components/card/card.js +6 -13
- package/labs/gb/components/card/card.js.map +1 -1
- package/labs/gb/components/card/md-card.js +6 -6
- package/labs/gb/components/card/md-card.js.map +1 -1
- package/labs/gb/components/checkbox/checkbox.css +1 -1
- package/labs/gb/components/checkbox/checkbox.css.map +1 -1
- package/labs/gb/components/checkbox/checkbox.cssresult.js +1 -1
- package/labs/gb/components/checkbox/checkbox.cssresult.js.map +1 -1
- package/labs/gb/components/checkbox/checkbox.d.ts +1 -16
- package/labs/gb/components/checkbox/checkbox.js +8 -31
- package/labs/gb/components/checkbox/checkbox.js.map +1 -1
- package/labs/gb/components/checkbox/checkbox.scss +13 -13
- package/labs/gb/components/checkbox/md-checkbox.d.ts +4 -4
- package/labs/gb/components/checkbox/md-checkbox.js +10 -10
- package/labs/gb/components/checkbox/md-checkbox.js.map +1 -1
- package/labs/gb/components/divider/divider.d.ts +1 -11
- package/labs/gb/components/divider/divider.js +4 -11
- package/labs/gb/components/divider/divider.js.map +1 -1
- package/labs/gb/components/fab/fab.d.ts +1 -16
- package/labs/gb/components/fab/fab.js +8 -31
- package/labs/gb/components/fab/fab.js.map +1 -1
- package/labs/gb/components/fab/md-fab.js +4 -4
- package/labs/gb/components/fab/md-fab.js.map +1 -1
- package/labs/gb/components/focus/focus-ring.js +1 -1
- package/labs/gb/components/focus/focus-ring.js.map +1 -1
- package/labs/gb/components/iconbutton/_icon-button-tokens.scss +202 -0
- package/labs/gb/components/iconbutton/icon-button.css +4 -0
- package/labs/gb/components/iconbutton/icon-button.css.map +1 -0
- package/labs/gb/components/iconbutton/icon-button.cssresult.d.ts +3 -0
- package/labs/gb/components/iconbutton/icon-button.cssresult.js +14 -0
- package/labs/gb/components/iconbutton/icon-button.cssresult.js.map +1 -0
- package/labs/gb/components/iconbutton/icon-button.d.ts +97 -0
- package/labs/gb/components/iconbutton/icon-button.js +122 -0
- package/labs/gb/components/iconbutton/icon-button.js.map +1 -0
- package/labs/gb/components/iconbutton/icon-button.scss +153 -0
- package/labs/gb/components/iconbutton/md-icon-button.d.ts +73 -0
- package/labs/gb/components/iconbutton/md-icon-button.js +176 -0
- package/labs/gb/components/iconbutton/md-icon-button.js.map +1 -0
- package/labs/gb/components/list/_list-tokens.scss +102 -0
- package/labs/gb/components/list/list.css +4 -0
- package/labs/gb/components/list/list.css.map +1 -0
- package/labs/gb/components/list/list.cssresult.d.ts +3 -0
- package/labs/gb/components/list/list.cssresult.js +14 -0
- package/labs/gb/components/list/list.cssresult.js.map +1 -0
- package/labs/gb/components/list/list.d.ts +103 -0
- package/labs/gb/components/list/list.js +109 -0
- package/labs/gb/components/list/list.js.map +1 -0
- package/labs/gb/components/list/list.scss +212 -0
- package/labs/gb/components/list/md-list-item.d.ts +44 -0
- package/labs/gb/components/list/md-list-item.js +122 -0
- package/labs/gb/components/list/md-list-item.js.map +1 -0
- package/labs/gb/components/list/md-list.d.ts +26 -0
- package/labs/gb/components/list/md-list.js +51 -0
- package/labs/gb/components/list/md-list.js.map +1 -0
- package/labs/gb/components/menu/_menu-tokens.scss +128 -0
- package/labs/gb/components/menu/md-menu-group.d.ts +26 -0
- package/labs/gb/components/menu/md-menu-group.js +65 -0
- package/labs/gb/components/menu/md-menu-group.js.map +1 -0
- package/labs/gb/components/menu/md-menu-item.d.ts +30 -0
- package/labs/gb/components/menu/md-menu-item.js +165 -0
- package/labs/gb/components/menu/md-menu-item.js.map +1 -0
- package/labs/gb/components/menu/md-menu.d.ts +28 -0
- package/labs/gb/components/menu/md-menu.js +141 -0
- package/labs/gb/components/menu/md-menu.js.map +1 -0
- package/labs/gb/components/menu/menu.css +4 -0
- package/labs/gb/components/menu/menu.css.map +1 -0
- package/labs/gb/components/menu/menu.cssresult.d.ts +3 -0
- package/labs/gb/components/menu/menu.cssresult.js +14 -0
- package/labs/gb/components/menu/menu.cssresult.js.map +1 -0
- package/labs/gb/components/menu/menu.d.ts +117 -0
- package/labs/gb/components/menu/menu.js +107 -0
- package/labs/gb/components/menu/menu.js.map +1 -0
- package/labs/gb/components/menu/menu.scss +171 -0
- package/labs/gb/components/radio/md-radio.d.ts +4 -4
- package/labs/gb/components/radio/md-radio.js +11 -11
- package/labs/gb/components/radio/md-radio.js.map +1 -1
- package/labs/gb/components/radio/radio.css +1 -1
- package/labs/gb/components/radio/radio.css.map +1 -1
- package/labs/gb/components/radio/radio.cssresult.js +1 -1
- package/labs/gb/components/radio/radio.cssresult.js.map +1 -1
- package/labs/gb/components/radio/radio.d.ts +1 -14
- package/labs/gb/components/radio/radio.js +8 -23
- package/labs/gb/components/radio/radio.js.map +1 -1
- package/labs/gb/components/radio/radio.scss +4 -5
- package/labs/gb/components/ripple/ripple.d.ts +1 -10
- package/labs/gb/components/ripple/ripple.js +28 -32
- package/labs/gb/components/ripple/ripple.js.map +1 -1
- package/labs/gb/components/shared/directives.d.ts +93 -0
- package/labs/gb/components/shared/directives.js +111 -0
- package/labs/gb/components/shared/directives.js.map +1 -0
- package/labs/gb/components/shared/has-slotted.d.ts +10 -0
- package/labs/gb/components/shared/has-slotted.js +19 -0
- package/labs/gb/components/shared/has-slotted.js.map +1 -0
- package/labs/gb/components/shared/pseudo-classes.d.ts +7 -0
- package/labs/gb/components/shared/pseudo-classes.js +9 -0
- package/labs/gb/components/shared/pseudo-classes.js.map +1 -1
- package/labs/gb/components/splitbutton/_split-button-tokens.scss +135 -0
- package/labs/gb/components/splitbutton/md-split-button.d.ts +26 -0
- package/labs/gb/components/splitbutton/md-split-button.js +119 -0
- package/labs/gb/components/splitbutton/md-split-button.js.map +1 -0
- package/labs/gb/components/splitbutton/split-button.css +4 -0
- package/labs/gb/components/splitbutton/split-button.css.map +1 -0
- package/labs/gb/components/splitbutton/split-button.cssresult.d.ts +3 -0
- package/labs/gb/components/splitbutton/split-button.cssresult.js +14 -0
- package/labs/gb/components/splitbutton/split-button.cssresult.js.map +1 -0
- package/labs/gb/components/splitbutton/split-button.d.ts +47 -0
- package/labs/gb/components/splitbutton/split-button.js +46 -0
- package/labs/gb/components/splitbutton/split-button.js.map +1 -0
- package/labs/gb/components/splitbutton/split-button.scss +164 -0
- package/labs/gb/components/switch/_switch-tokens.scss +56 -0
- package/labs/gb/components/switch/md-switch.d.ts +66 -0
- package/labs/gb/components/switch/md-switch.js +162 -0
- package/labs/gb/components/switch/md-switch.js.map +1 -0
- package/labs/gb/components/switch/switch.css +4 -0
- package/labs/gb/components/switch/switch.css.map +1 -0
- package/labs/gb/components/switch/switch.cssresult.d.ts +3 -0
- package/labs/gb/components/switch/switch.cssresult.js +14 -0
- package/labs/gb/components/switch/switch.cssresult.js.map +1 -0
- package/labs/gb/components/switch/switch.d.ts +54 -0
- package/labs/gb/components/switch/switch.js +85 -0
- package/labs/gb/components/switch/switch.js.map +1 -0
- package/labs/gb/components/switch/switch.scss +109 -0
- package/labs/gb/styles/icon/md-icon.css +1 -1
- package/labs/gb/styles/icon/md-icon.css.map +1 -1
- package/labs/gb/styles/icon/md-icon.cssresult.js +1 -1
- package/labs/gb/styles/icon/md-icon.cssresult.js.map +1 -1
- package/labs/gb/styles/icon/md-icon.d.ts +20 -0
- package/labs/gb/styles/icon/md-icon.js +24 -0
- package/labs/gb/styles/icon/md-icon.js.map +1 -0
- package/labs/gb/styles/icon/md-icon.scss +2 -1
- package/labs/gb/styles/m3.css +5 -2
- package/labs/gb/styles/m3.css.map +1 -1
- package/labs/gb/styles/m3.cssresult.js +5 -2
- package/labs/gb/styles/m3.cssresult.js.map +1 -1
- package/labs/gb/styles/m3.scss +1 -0
- package/labs/gb/styles/space/md-space-tokens.css +4 -0
- package/labs/gb/styles/space/md-space-tokens.css.map +1 -0
- package/labs/gb/styles/space/md-space-tokens.cssresult.d.ts +3 -0
- package/labs/gb/styles/space/md-space-tokens.cssresult.js +14 -0
- package/labs/gb/styles/space/md-space-tokens.cssresult.js.map +1 -0
- package/labs/gb/styles/space/md-space-tokens.scss +28 -0
- package/labs/gb/styles/tailwind.css +4 -0
- package/labs/gb/styles/tailwind.css.map +1 -0
- package/labs/gb/styles/tailwind.cssresult.d.ts +3 -0
- package/labs/gb/styles/tailwind.cssresult.js +14 -0
- package/labs/gb/styles/tailwind.cssresult.js.map +1 -0
- package/labs/gb/styles/tailwind.scss +250 -0
- package/labs/gb/styles/typography/internal/_typography-tokens.scss +85 -16
- package/labs/gb/styles/typography/md-typography-tokens.css +1 -1
- package/labs/gb/styles/typography/md-typography-tokens.css.map +1 -1
- package/labs/gb/styles/typography/md-typography-tokens.cssresult.js +1 -1
- package/labs/gb/styles/typography/md-typography-tokens.cssresult.js.map +1 -1
- package/list/internal/listitem/list-item.d.ts +2 -0
- package/menu/internal/menuitem/menu-item.d.ts +2 -0
- package/package.json +7 -3
- package/radio/internal/radio.d.ts +0 -2
- package/radio/internal/radio.js.map +1 -1
- package/select/internal/select.d.ts +2 -2
- package/select/internal/select.js.map +1 -1
- package/select/internal/selectoption/select-option.d.ts +2 -0
- package/slider/internal/slider.d.ts +0 -2
- package/slider/internal/slider.js.map +1 -1
- package/switch/internal/_switch.scss +1 -0
- package/switch/internal/switch-styles.css +1 -1
- package/switch/internal/switch-styles.css.map +1 -1
- package/switch/internal/switch-styles.cssresult.js +1 -1
- package/switch/internal/switch-styles.cssresult.js.map +1 -1
- package/switch/internal/switch.d.ts +0 -2
- package/switch/internal/switch.js.map +1 -1
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
* Copyright 2026 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { createValidator, getValidityAnchor } from '@material/web/labs/behaviors/constraint-validation.js';
|
|
7
|
-
import { getFormState, getFormValue } from '@material/web/labs/behaviors/form-associated.js';
|
|
8
|
-
import { RadioValidator } from '@material/web/labs/behaviors/validators/radio-validator.js';
|
|
9
6
|
import { CSSResultOrNative, LitElement } from 'lit';
|
|
7
|
+
import { createValidator, getValidityAnchor } from '../../../behaviors/constraint-validation.js';
|
|
8
|
+
import { getFormState, getFormValue } from '../../../behaviors/form-associated.js';
|
|
9
|
+
import { RadioValidator } from '../../../behaviors/validators/radio-validator.js';
|
|
10
10
|
declare global {
|
|
11
11
|
interface HTMLElementTagNameMap {
|
|
12
12
|
/** A Material Design radio component. */
|
|
13
13
|
'md-radio': Radio;
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
declare const radioBaseClass: import("@material/web/labs/behaviors/mixin.js").MixinReturn<import("@material/web/labs/behaviors/mixin.js").MixinReturn<(abstract new (...args: any[]) => import("
|
|
16
|
+
declare const radioBaseClass: import("@material/web/labs/behaviors/mixin.js").MixinReturn<import("@material/web/labs/behaviors/mixin.js").MixinReturn<(abstract new (...args: any[]) => import("../../../behaviors/element-internals.js").WithElementInternals) & (abstract new (...args: any[]) => import("../../../behaviors/focusable.js").Focusable) & typeof LitElement & import("../../../behaviors/form-associated.js").FormAssociatedConstructor, import("../../../behaviors/form-associated.js").FormAssociated>, import("../../../behaviors/constraint-validation.js").ConstraintValidation>;
|
|
17
17
|
/**
|
|
18
18
|
* A Material Design radio component.
|
|
19
19
|
*/
|
|
@@ -4,19 +4,19 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import { __decorate } from "tslib";
|
|
7
|
-
import { afterDispatch, setupDispatchHooks, } from '@material/web/internal/events/dispatch-hooks.js';
|
|
8
|
-
import { createValidator, getValidityAnchor, mixinConstraintValidation, } from '@material/web/labs/behaviors/constraint-validation.js';
|
|
9
|
-
import { internals, mixinElementInternals, } from '@material/web/labs/behaviors/element-internals.js';
|
|
10
|
-
import { mixinFocusable } from '@material/web/labs/behaviors/focusable.js';
|
|
11
|
-
import { getFormState, getFormValue, mixinFormAssociated, } from '@material/web/labs/behaviors/form-associated.js';
|
|
12
|
-
import { RadioValidator } from '@material/web/labs/behaviors/validators/radio-validator.js';
|
|
13
|
-
import { SingleSelectionController } from '@material/web/radio/internal/single-selection-controller.js';
|
|
14
7
|
import { css, html, isServer, LitElement } from 'lit';
|
|
15
8
|
import { customElement, property, query, state } from 'lit/decorators.js';
|
|
16
|
-
import
|
|
17
|
-
|
|
18
|
-
import
|
|
19
|
-
|
|
9
|
+
import { afterDispatch, setupDispatchHooks, } from '../../../../internal/events/dispatch-hooks.js';
|
|
10
|
+
import { SingleSelectionController } from '../../../../radio/internal/single-selection-controller.js';
|
|
11
|
+
import { createValidator, getValidityAnchor, mixinConstraintValidation, } from '../../../behaviors/constraint-validation.js';
|
|
12
|
+
import { internals, mixinElementInternals, } from '../../../behaviors/element-internals.js';
|
|
13
|
+
import { mixinFocusable } from '../../../behaviors/focusable.js';
|
|
14
|
+
import { getFormState, getFormValue, mixinFormAssociated, } from '../../../behaviors/form-associated.js';
|
|
15
|
+
import { RadioValidator } from '../../../behaviors/validators/radio-validator.js';
|
|
16
|
+
import focusRingStyles from '../focus/focus-ring.css' with { type: 'css' }; // github-only
|
|
17
|
+
// import focusRingStyles from '../focus/focus-ring.cssresult.js'; // google3-only
|
|
18
|
+
import rippleStyles from '../ripple/ripple.css' with { type: 'css' }; // github-only
|
|
19
|
+
// import rippleStyles from '../ripple/ripple.cssresult.js'; // google3-only
|
|
20
20
|
import radioStyles from './radio.css' with { type: 'css' }; // github-only
|
|
21
21
|
// import {styles as radioStyles} from './radio.cssresult.js'; // google3-only
|
|
22
22
|
import { radio } from './radio.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"md-radio.js","sourceRoot":"","sources":["md-radio.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EACL,aAAa,EACb,kBAAkB,GACnB,MAAM,iDAAiD,CAAC;AACzD,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,yBAAyB,GAC1B,MAAM,uDAAuD,CAAC;AAC/D,OAAO,EACL,SAAS,EACT,qBAAqB,GACtB,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EAAC,cAAc,EAAC,MAAM,2CAA2C,CAAC;AACzE,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,mBAAmB,GACpB,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAC,cAAc,EAAC,MAAM,4DAA4D,CAAC;AAC1F,OAAO,EAAC,yBAAyB,EAAC,MAAM,6DAA6D,CAAC;AACtG,OAAO,EAAC,GAAG,EAAqB,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAC,MAAM,KAAK,CAAC;AACvE,OAAO,EAAC,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KA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QAC9B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC;IACrC,CAAC;IAEQ,wBAAwB,CAAC,KAAa;QAC7C,IAAI,CAAC,OAAO,GAAG,KAAK,KAAK,MAAM,CAAC;IAClC,CAAC;IAEQ,CAAC,eAAe,CAAC;QACxB,OAAO,IAAI,cAAc,CAAC,GAAG,EAAE;YAC7B,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC;gBAC9B,sEAAsE;gBACtE,2DAA2D;gBAC3D,OAAO,CAAC,IAAI,CAAC,CAAC;YAChB,CAAC;YAED,OAAO,IAAI,CAAC,mBAAmB,CAAC,QAA+B,CAAC;QAClE,CAAC,CAAC,CAAC;IACL,CAAC;IAEQ,CAAC,iBAAiB,CAAC;QAC1B,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;;AAlKe,YAAM,GAAwB;IAC5C,eAAe;IACf,YAAY;IACZ,WAAW;IACX,GAAG,CAAA;;;;;;;;KAQF;CACF,AAbqB,CAapB;AAMF;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;oCAGzB;AA0B0B;IAA1B,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;uCAAkB;AAKhC;IAAX,QAAQ,EAAE;oCAAc;AAEe;IAAvC,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC;oCAAsC;AAU3C;IAAhB,KAAK,EAAE;wCAA2B;AAjExB,KAAK;IADjB,aAAa,CAAC,UAAU,CAAC;GACb,KAAK,CAoKjB","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n afterDispatch,\n setupDispatchHooks,\n} from '@material/web/internal/events/dispatch-hooks.js';\nimport {\n createValidator,\n getValidityAnchor,\n mixinConstraintValidation,\n} from '@material/web/labs/behaviors/constraint-validation.js';\nimport {\n internals,\n mixinElementInternals,\n} from '@material/web/labs/behaviors/element-internals.js';\nimport {mixinFocusable} from '@material/web/labs/behaviors/focusable.js';\nimport {\n getFormState,\n getFormValue,\n mixinFormAssociated,\n} from '@material/web/labs/behaviors/form-associated.js';\nimport {RadioValidator} from '@material/web/labs/behaviors/validators/radio-validator.js';\nimport {SingleSelectionController} from '@material/web/radio/internal/single-selection-controller.js';\nimport {css, CSSResultOrNative, html, isServer, LitElement} from 'lit';\nimport {customElement, property, query, state} from 'lit/decorators.js';\n\nimport focusRingStyles from '@material/web/labs/gb/components/focus/focus-ring.css' with {type: 'css'}; // github-only\n// import focusRingStyles from '@material/web/labs/gb/components/focus/focus-ring.cssresult.js'; // google3-only\nimport rippleStyles from '@material/web/labs/gb/components/ripple/ripple.css' with {type: 'css'}; // github-only\n// import rippleStyles from '@material/web/labs/gb/components/ripple/ripple.cssresult.js'; // google3-only\nimport radioStyles from './radio.css' with {type: 'css'}; // github-only\n// import {styles as radioStyles} from './radio.cssresult.js'; // google3-only\n\nimport {radio} from './radio.js';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n /** A Material Design radio component. */\n 'md-radio': Radio;\n }\n}\n\n// Separate variable needed for closure.\nconst radioBaseClass = mixinConstraintValidation(\n mixinFormAssociated(mixinElementInternals(mixinFocusable(LitElement))),\n);\n\n/**\n * A Material Design radio component.\n */\n@customElement('md-radio')\nexport class Radio extends radioBaseClass {\n static override styles: CSSResultOrNative[] = [\n focusRingStyles,\n rippleStyles,\n radioStyles,\n css`\n :host {\n display: inline-flex;\n outline: none;\n }\n .radio {\n flex: 1;\n }\n `,\n ];\n\n /**\n * Whether or not the radio is selected.\n */\n @property({type: Boolean})\n get checked() {\n return this[internals].ariaChecked === 'true';\n }\n set checked(checked: boolean) {\n const wasChecked = this.checked;\n if (wasChecked === checked) {\n return;\n }\n\n this[internals].ariaChecked = String(checked);\n this.requestUpdate('checked', wasChecked);\n this.selectionController.handleCheckedChange();\n }\n\n /**\n * The default checked state of the radio.\n */\n get defaultChecked(): boolean {\n return this.hasAttribute('checked');\n }\n set defaultChecked(value: boolean) {\n this.toggleAttribute('checked', value || false);\n }\n\n /**\n * Whether or not the radio is required. If any radio is required in a group,\n * all radios are implicitly required.\n */\n @property({type: Boolean}) required = false;\n\n /**\n * The element value to use in form submission when checked.\n */\n @property() value = 'on';\n\n @query('.radio', true) private readonly radio!: HTMLElement;\n private readonly selectionController = new SingleSelectionController(this);\n /**\n * Mimics the behavior of <input> dirty checkedness, where the `checked`\n * attribute only updates the checked state if the radio has not been\n * interacted with.\n *\n * @see https://html.spec.whatwg.org/multipage/input.html#concept-input-checked-dirty-flag\n */\n private dirtyCheckedness = false;\n @state() private isFocused = false;\n\n constructor() {\n super();\n if (isServer) return;\n this[internals].role = 'radio';\n this.addController(this.selectionController);\n setupDispatchHooks(this, 'click', 'keydown');\n this.addEventListener('click', (event) => {\n // Return if disabled, or already checked since clicking on a checked\n // radio does not dispatch events.\n if (this.disabled || this.checked) return;\n afterDispatch(event, () => {\n if (event.defaultPrevented) return;\n // Per spec, clicking on a radio input always selects it.\n this.checked = true;\n this.dirtyCheckedness = true;\n this.dispatchEvent(new Event('change', {bubbles: true}));\n this.dispatchEvent(\n new InputEvent('input', {bubbles: true, composed: true}),\n );\n });\n });\n\n this.addEventListener('keydown', (event) => {\n afterDispatch(event, () => {\n if (event.key !== ' ' || event.defaultPrevented) {\n return;\n }\n\n this.click();\n });\n });\n\n this.addEventListener('focus', () => {\n this.isFocused = true;\n });\n\n this.addEventListener('blur', () => {\n this.isFocused = false;\n });\n }\n\n protected override render() {\n return html`<div\n part=\"radio\"\n class=\"ripple-host focus-ring-host ${radio({\n checked: this.checked,\n disabled: this.disabled,\n focus: this.isFocused,\n })}\"></div>`;\n }\n\n override attributeChangedCallback(\n name: string,\n oldValue: string | null,\n newValue: string | null,\n ) {\n if (name === 'checked' && this.dirtyCheckedness) {\n // The 'checked' attribute does not update radios that have been\n // interacted with.\n return;\n }\n\n super.attributeChangedCallback(name, oldValue, newValue);\n }\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 this.dirtyCheckedness = false;\n this.checked = this.defaultChecked;\n }\n\n override formStateRestoreCallback(state: string) {\n this.checked = state === 'true';\n }\n\n override [createValidator]() {\n return new RadioValidator(() => {\n if (!this.selectionController) {\n // Validation runs on superclass construction, so selection controller\n // might not actually be ready until this class constructs.\n return [this];\n }\n\n return this.selectionController.controls as [Radio, ...Radio[]];\n });\n }\n\n override [getValidityAnchor]() {\n return this.radio;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"md-radio.js","sourceRoot":"","sources":["md-radio.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAC,GAAG,EAAqB,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAC,MAAM,KAAK,CAAC;AACvE,OAAO,EAAC,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,mBAAmB,CAAC;AACxE,OAAO,EACL,aAAa,EACb,kBAAkB,GACnB,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAAC,yBAAyB,EAAC,MAAM,2DAA2D,CAAC;AACpG,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,yBAAyB,GAC1B,MAAM,6CAA6C,CAAC;AACrD,OAAO,EACL,SAAS,EACT,qBAAqB,GACtB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAC,cAAc,EAAC,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,mBAAmB,GACpB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAC,cAAc,EAAC,MAAM,kDAAkD,CAAC;AAEhF,OAAO,eAAe,MAAM,yBAAyB,CAAC,OAAM,IAAI,EAAE,KAAK,EAAC,CAAC,CAAC,cAAc;AACxF,kFAAkF;AAClF,OAAO,YAAY,MAAM,sBAAsB,CAAC,OAAM,IAAI,EAAE,KAAK,EAAC,CAAC,CAAC,cAAc;AAClF,4EAA4E;A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7B,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC;gBAC9B,sEAAsE;gBACtE,2DAA2D;gBAC3D,OAAO,CAAC,IAAI,CAAC,CAAC;YAChB,CAAC;YAED,OAAO,IAAI,CAAC,mBAAmB,CAAC,QAA+B,CAAC;QAClE,CAAC,CAAC,CAAC;IACL,CAAC;IAEQ,CAAC,iBAAiB,CAAC;QAC1B,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;;AAlKe,YAAM,GAAwB;IAC5C,eAAe;IACf,YAAY;IACZ,WAAW;IACX,GAAG,CAAA;;;;;;;;KAQF;CACF,AAbqB,CAapB;AAMF;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;oCAGzB;AA0B0B;IAA1B,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;uCAAkB;AAKhC;IAAX,QAAQ,EAAE;oCAAc;AAEe;IAAvC,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC;oCAAsC;AAU3C;IAAhB,KAAK,EAAE;wCAA2B;AAjExB,KAAK;IADjB,aAAa,CAAC,UAAU,CAAC;GACb,KAAK,CAoKjB","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {css, CSSResultOrNative, html, isServer, LitElement} from 'lit';\nimport {customElement, property, query, state} from 'lit/decorators.js';\nimport {\n afterDispatch,\n setupDispatchHooks,\n} from '../../../../internal/events/dispatch-hooks.js';\nimport {SingleSelectionController} from '../../../../radio/internal/single-selection-controller.js';\nimport {\n createValidator,\n getValidityAnchor,\n mixinConstraintValidation,\n} from '../../../behaviors/constraint-validation.js';\nimport {\n internals,\n mixinElementInternals,\n} from '../../../behaviors/element-internals.js';\nimport {mixinFocusable} from '../../../behaviors/focusable.js';\nimport {\n getFormState,\n getFormValue,\n mixinFormAssociated,\n} from '../../../behaviors/form-associated.js';\nimport {RadioValidator} from '../../../behaviors/validators/radio-validator.js';\n\nimport focusRingStyles from '../focus/focus-ring.css' with {type: 'css'}; // github-only\n// import focusRingStyles from '../focus/focus-ring.cssresult.js'; // google3-only\nimport rippleStyles from '../ripple/ripple.css' with {type: 'css'}; // github-only\n// import rippleStyles from '../ripple/ripple.cssresult.js'; // google3-only\nimport radioStyles from './radio.css' with {type: 'css'}; // github-only\n// import {styles as radioStyles} from './radio.cssresult.js'; // google3-only\n\nimport {radio} from './radio.js';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n /** A Material Design radio component. */\n 'md-radio': Radio;\n }\n}\n\n// Separate variable needed for closure.\nconst radioBaseClass = mixinConstraintValidation(\n mixinFormAssociated(mixinElementInternals(mixinFocusable(LitElement))),\n);\n\n/**\n * A Material Design radio component.\n */\n@customElement('md-radio')\nexport class Radio extends radioBaseClass {\n static override styles: CSSResultOrNative[] = [\n focusRingStyles,\n rippleStyles,\n radioStyles,\n css`\n :host {\n display: inline-flex;\n outline: none;\n }\n .radio {\n flex: 1;\n }\n `,\n ];\n\n /**\n * Whether or not the radio is selected.\n */\n @property({type: Boolean})\n get checked() {\n return this[internals].ariaChecked === 'true';\n }\n set checked(checked: boolean) {\n const wasChecked = this.checked;\n if (wasChecked === checked) {\n return;\n }\n\n this[internals].ariaChecked = String(checked);\n this.requestUpdate('checked', wasChecked);\n this.selectionController.handleCheckedChange();\n }\n\n /**\n * The default checked state of the radio.\n */\n get defaultChecked(): boolean {\n return this.hasAttribute('checked');\n }\n set defaultChecked(value: boolean) {\n this.toggleAttribute('checked', value || false);\n }\n\n /**\n * Whether or not the radio is required. If any radio is required in a group,\n * all radios are implicitly required.\n */\n @property({type: Boolean}) required = false;\n\n /**\n * The element value to use in form submission when checked.\n */\n @property() value = 'on';\n\n @query('.radio', true) private readonly radio!: HTMLElement;\n private readonly selectionController = new SingleSelectionController(this);\n /**\n * Mimics the behavior of <input> dirty checkedness, where the `checked`\n * attribute only updates the checked state if the radio has not been\n * interacted with.\n *\n * @see https://html.spec.whatwg.org/multipage/input.html#concept-input-checked-dirty-flag\n */\n private dirtyCheckedness = false;\n @state() private isFocused = false;\n\n constructor() {\n super();\n if (isServer) return;\n this[internals].role = 'radio';\n this.addController(this.selectionController);\n setupDispatchHooks(this, 'click', 'keydown');\n this.addEventListener('click', (event) => {\n // Return if disabled, or already checked since clicking on a checked\n // radio does not dispatch events.\n if (this.disabled || this.checked) return;\n afterDispatch(event, () => {\n if (event.defaultPrevented) return;\n // Per spec, clicking on a radio input always selects it.\n this.checked = true;\n this.dirtyCheckedness = true;\n this.dispatchEvent(new Event('change', {bubbles: true}));\n this.dispatchEvent(\n new InputEvent('input', {bubbles: true, composed: true}),\n );\n });\n });\n\n this.addEventListener('keydown', (event) => {\n afterDispatch(event, () => {\n if (event.key !== ' ' || event.defaultPrevented) {\n return;\n }\n\n this.click();\n });\n });\n\n this.addEventListener('focus', () => {\n this.isFocused = true;\n });\n\n this.addEventListener('blur', () => {\n this.isFocused = false;\n });\n }\n\n protected override render() {\n return html`<div\n part=\"radio\"\n class=\"ripple-host focus-ring-host ${radio({\n checked: this.checked,\n disabled: this.disabled,\n focus: this.isFocused,\n })}\"></div>`;\n }\n\n override attributeChangedCallback(\n name: string,\n oldValue: string | null,\n newValue: string | null,\n ) {\n if (name === 'checked' && this.dirtyCheckedness) {\n // The 'checked' attribute does not update radios that have been\n // interacted with.\n return;\n }\n\n super.attributeChangedCallback(name, oldValue, newValue);\n }\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 this.dirtyCheckedness = false;\n this.checked = this.defaultChecked;\n }\n\n override formStateRestoreCallback(state: string) {\n this.checked = state === 'true';\n }\n\n override [createValidator]() {\n return new RadioValidator(() => {\n if (!this.selectionController) {\n // Validation runs on superclass construction, so selection controller\n // might not actually be ready until this class constructs.\n return [this];\n }\n\n return this.selectionController.controls as [Radio, ...Radio[]];\n });\n }\n\n override [getValidityAnchor]() {\n return this.radio;\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Copyright 2026 Google LLC
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/@layer md.sys, md.comp.ripple, md.comp.focus-ring;@layer md.comp.radio{.radio{--icon-color: var(--md-sys-color-on-surface-variant);--icon-size: 20px;--state-layer-color: var(--md-sys-color-on-surface);--state-layer-shape: 50%;--state-layer-size: 40px}.radio:where(:hover,.hover){--icon-color: var(--md-sys-color-on-surface)}.radio:where(:focus-within,.focus){--icon-color: var(--md-sys-color-on-surface)}.radio:where(:active,.active){--state-layer-color: var(--md-sys-color-primary)}.radio:is(:checked,.checked){--icon-color: var(--md-sys-color-primary);--state-layer-color: var(--md-sys-color-primary)}.radio:is(:checked,.checked):where(:active,.active){--state-layer-color: var(--md-sys-color-on-surface)}.radio:is(:disabled,.disabled){--icon-color: hsl(from var(--md-sys-color-on-surface) h s l / 38%)}.radio{appearance:none;position:relative;display:inline-flex;align-items:center;justify-content:center;width:48px;height:48px;background-image:none;outline:none}.radio::before{content:
|
|
4
|
+
*/@layer md.sys, md.comp.ripple, md.comp.focus-ring;@layer md.comp.radio{.radio{--icon-color: var(--md-sys-color-on-surface-variant);--icon-size: 20px;--state-layer-color: var(--md-sys-color-on-surface);--state-layer-shape: 50%;--state-layer-size: 40px}.radio:where(:hover,.hover){--icon-color: var(--md-sys-color-on-surface)}.radio:where(:focus-within,.focus){--icon-color: var(--md-sys-color-on-surface)}.radio:where(:active,.active){--state-layer-color: var(--md-sys-color-primary)}.radio:is(:checked,.checked){--icon-color: var(--md-sys-color-primary);--state-layer-color: var(--md-sys-color-primary)}.radio:is(:checked,.checked):where(:active,.active){--state-layer-color: var(--md-sys-color-on-surface)}.radio:is(:disabled,.disabled){--icon-color: hsl(from var(--md-sys-color-on-surface) h s l / 38%)}.radio{appearance:none;position:relative;display:inline-flex;align-items:center;justify-content:center;width:48px;height:48px;background-image:none;outline:none;--icon: "radio_button_unchecked"}.radio::before{content:var(--icon);color:var(--icon-color);font:var(--icon-size)/1 var(--md-icon-font);width:var(--icon-size);aspect-ratio:1}.radio:is(:checked,.checked)::before{--icon: "radio_button_checked"}.radio::after{content:"";position:absolute;aspect-ratio:1;background-image:var(--ripple);color:var(--state-layer-color);width:var(--state-layer-size);border-radius:var(--state-layer-shape);outline:var(--focus-ring-outline);outline-offset:var(--focus-ring-offset);transition:var(--ripple-transition);animation:var(--ripple-animation),var(--focus-ring-animation)}}/*# sourceMappingURL=radio.css.map */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sourceRoot":"","sources":["radio.scss","_radio-tokens.scss"],"names":[],"mappings":"AAAA;AAAA;AAAA;AAAA,GASA,kDACA,qBAEI,OCNF,qDACA,kBACA,oDACA,yBACA,yBDKI,4BCDJ,6CDII,gFAGA,8BCCJ,iDDGE,6BCCF,0CACA,iDDCI,oDCGJ,oDDCE,+BCGF,mEDCE,OACE,gBACA,kBACA,oBACA,mBACA,uBACA,WACA,YACA,sBACA,
|
|
1
|
+
{"version":3,"sourceRoot":"","sources":["radio.scss","_radio-tokens.scss"],"names":[],"mappings":"AAAA;AAAA;AAAA;AAAA,GASA,kDACA,qBAEI,OCNF,qDACA,kBACA,oDACA,yBACA,yBDKI,4BCDJ,6CDII,gFAGA,8BCCJ,iDDGE,6BCCF,0CACA,iDDCI,oDCGJ,oDDCE,+BCGF,mEDCE,OACE,gBACA,kBACA,oBACA,mBACA,uBACA,WACA,YACA,sBACA,aACA,iCAEA,eACE,oBACA,wBACA,4CACA,uBACA,eAEF,qCACE,+BAEF,cACE,WACA,kBACA,eACA,+BACA,+BACA,8BACA,uCACA,kCACA,wCACA,oCACA","file":"radio.css"}
|
|
@@ -8,7 +8,7 @@ import { css } from 'lit';
|
|
|
8
8
|
export const styles = css `/*!
|
|
9
9
|
* Copyright 2026 Google LLC
|
|
10
10
|
* SPDX-License-Identifier: Apache-2.0
|
|
11
|
-
*/@layer md.sys, md.comp.ripple, md.comp.focus-ring;@layer md.comp.radio{.radio{--icon-color: var(--md-sys-color-on-surface-variant);--icon-size: 20px;--state-layer-color: var(--md-sys-color-on-surface);--state-layer-shape: 50%;--state-layer-size: 40px}.radio:where(:hover,.hover){--icon-color: var(--md-sys-color-on-surface)}.radio:where(:focus-within,.focus){--icon-color: var(--md-sys-color-on-surface)}.radio:where(:active,.active){--state-layer-color: var(--md-sys-color-primary)}.radio:is(:checked,.checked){--icon-color: var(--md-sys-color-primary);--state-layer-color: var(--md-sys-color-primary)}.radio:is(:checked,.checked):where(:active,.active){--state-layer-color: var(--md-sys-color-on-surface)}.radio:is(:disabled,.disabled){--icon-color: hsl(from var(--md-sys-color-on-surface) h s l / 38%)}.radio{appearance:none;position:relative;display:inline-flex;align-items:center;justify-content:center;width:48px;height:48px;background-image:none;outline:none}.radio::before{content:
|
|
11
|
+
*/@layer md.sys, md.comp.ripple, md.comp.focus-ring;@layer md.comp.radio{.radio{--icon-color: var(--md-sys-color-on-surface-variant);--icon-size: 20px;--state-layer-color: var(--md-sys-color-on-surface);--state-layer-shape: 50%;--state-layer-size: 40px}.radio:where(:hover,.hover){--icon-color: var(--md-sys-color-on-surface)}.radio:where(:focus-within,.focus){--icon-color: var(--md-sys-color-on-surface)}.radio:where(:active,.active){--state-layer-color: var(--md-sys-color-primary)}.radio:is(:checked,.checked){--icon-color: var(--md-sys-color-primary);--state-layer-color: var(--md-sys-color-primary)}.radio:is(:checked,.checked):where(:active,.active){--state-layer-color: var(--md-sys-color-on-surface)}.radio:is(:disabled,.disabled){--icon-color: hsl(from var(--md-sys-color-on-surface) h s l / 38%)}.radio{appearance:none;position:relative;display:inline-flex;align-items:center;justify-content:center;width:48px;height:48px;background-image:none;outline:none;--icon: "radio_button_unchecked"}.radio::before{content:var(--icon);color:var(--icon-color);font:var(--icon-size)/1 var(--md-icon-font);width:var(--icon-size);aspect-ratio:1}.radio:is(:checked,.checked)::before{--icon: "radio_button_checked"}.radio::after{content:"";position:absolute;aspect-ratio:1;background-image:var(--ripple);color:var(--state-layer-color);width:var(--state-layer-size);border-radius:var(--state-layer-shape);outline:var(--focus-ring-outline);outline-offset:var(--focus-ring-offset);transition:var(--ripple-transition);animation:var(--ripple-animation),var(--focus-ring-animation)}}
|
|
12
12
|
`;
|
|
13
13
|
export default styles.styleSheet;
|
|
14
14
|
//# sourceMappingURL=radio.cssresult.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radio.cssresult.js","sourceRoot":"","sources":["radio.cssresult.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,iEAAiE;AACjE,OAAO,EAAC,GAAG,EAAC,MAAM,KAAK,CAAC;AACxB,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;CAIxB,CAAC;AACF,eAAe,MAAM,CAAC,UAAW,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n// Generated stylesheet for ./labs/gb/components/radio/radio.css.\nimport {css} from 'lit';\nexport const styles = css`/*!\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */@layer md.sys, md.comp.ripple, md.comp.focus-ring;@layer md.comp.radio{.radio{--icon-color: var(--md-sys-color-on-surface-variant);--icon-size: 20px;--state-layer-color: var(--md-sys-color-on-surface);--state-layer-shape: 50%;--state-layer-size: 40px}.radio:where(:hover,.hover){--icon-color: var(--md-sys-color-on-surface)}.radio:where(:focus-within,.focus){--icon-color: var(--md-sys-color-on-surface)}.radio:where(:active,.active){--state-layer-color: var(--md-sys-color-primary)}.radio:is(:checked,.checked){--icon-color: var(--md-sys-color-primary);--state-layer-color: var(--md-sys-color-primary)}.radio:is(:checked,.checked):where(:active,.active){--state-layer-color: var(--md-sys-color-on-surface)}.radio:is(:disabled,.disabled){--icon-color: hsl(from var(--md-sys-color-on-surface) h s l / 38%)}.radio{appearance:none;position:relative;display:inline-flex;align-items:center;justify-content:center;width:48px;height:48px;background-image:none;outline:none}.radio::before{content
|
|
1
|
+
{"version":3,"file":"radio.cssresult.js","sourceRoot":"","sources":["radio.cssresult.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,iEAAiE;AACjE,OAAO,EAAC,GAAG,EAAC,MAAM,KAAK,CAAC;AACxB,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;CAIxB,CAAC;AACF,eAAe,MAAM,CAAC,UAAW,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n// Generated stylesheet for ./labs/gb/components/radio/radio.css.\nimport {css} from 'lit';\nexport const styles = css`/*!\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */@layer md.sys, md.comp.ripple, md.comp.focus-ring;@layer md.comp.radio{.radio{--icon-color: var(--md-sys-color-on-surface-variant);--icon-size: 20px;--state-layer-color: var(--md-sys-color-on-surface);--state-layer-shape: 50%;--state-layer-size: 40px}.radio:where(:hover,.hover){--icon-color: var(--md-sys-color-on-surface)}.radio:where(:focus-within,.focus){--icon-color: var(--md-sys-color-on-surface)}.radio:where(:active,.active){--state-layer-color: var(--md-sys-color-primary)}.radio:is(:checked,.checked){--icon-color: var(--md-sys-color-primary);--state-layer-color: var(--md-sys-color-primary)}.radio:is(:checked,.checked):where(:active,.active){--state-layer-color: var(--md-sys-color-on-surface)}.radio:is(:disabled,.disabled){--icon-color: hsl(from var(--md-sys-color-on-surface) h s l / 38%)}.radio{appearance:none;position:relative;display:inline-flex;align-items:center;justify-content:center;width:48px;height:48px;background-image:none;outline:none;--icon: \"radio_button_unchecked\"}.radio::before{content:var(--icon);color:var(--icon-color);font:var(--icon-size)/1 var(--md-icon-font);width:var(--icon-size);aspect-ratio:1}.radio:is(:checked,.checked)::before{--icon: \"radio_button_checked\"}.radio::after{content:\"\";position:absolute;aspect-ratio:1;background-image:var(--ripple);color:var(--state-layer-color);width:var(--state-layer-size);border-radius:var(--state-layer-shape);outline:var(--focus-ring-outline);outline-offset:var(--focus-ring-offset);transition:var(--ripple-transition);animation:var(--ripple-animation),var(--focus-ring-animation)}}\n`;\nexport default styles.styleSheet!;\n"]}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* Copyright 2026 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { AttributePart, Directive, DirectiveParameters } from 'lit/async-directive.js';
|
|
7
6
|
import { type ClassInfo } from 'lit/directives/class-map.js';
|
|
8
7
|
/** Radio classes. */
|
|
9
8
|
export declare const RADIO_CLASSES: {
|
|
@@ -43,17 +42,6 @@ export declare function radioClasses({ hover, focus, active, checked, disabled,
|
|
|
43
42
|
export declare function setupRadio(radio: HTMLElement, opts?: {
|
|
44
43
|
signal?: AbortSignal;
|
|
45
44
|
}): void;
|
|
46
|
-
/** The state provided to the `radio()` directive. */
|
|
47
|
-
export interface RadioDirectiveState extends RadioClassesState {
|
|
48
|
-
/** Additional classes to apply to the element. */
|
|
49
|
-
classes?: ClassInfo;
|
|
50
|
-
}
|
|
51
|
-
declare class RadioDirective extends Directive {
|
|
52
|
-
private element?;
|
|
53
|
-
private cleanup?;
|
|
54
|
-
render(state?: RadioDirectiveState): import("lit-html/directive.js").DirectiveResult<typeof import("lit-html/directives/class-map.js").ClassMapDirective>;
|
|
55
|
-
update({ element }: AttributePart, [state]: DirectiveParameters<this>): import("lit-html/directive.js").DirectiveResult<typeof import("lit-html/directives/class-map.js").ClassMapDirective>;
|
|
56
|
-
}
|
|
57
45
|
/**
|
|
58
46
|
* A Lit directive that adds radio styling and functionality to its element.
|
|
59
47
|
*
|
|
@@ -66,5 +54,4 @@ declare class RadioDirective extends Directive {
|
|
|
66
54
|
* `;
|
|
67
55
|
* ```
|
|
68
56
|
*/
|
|
69
|
-
export declare const radio: (state?:
|
|
70
|
-
export {};
|
|
57
|
+
export declare const radio: (state?: RadioClassesState & import("../shared/directives.js").AdditionalClasses) => import("lit-html/directive.js").DirectiveResult;
|
|
@@ -3,11 +3,10 @@
|
|
|
3
3
|
* Copyright 2026 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { focusRingClasses } from '
|
|
7
|
-
import { rippleClasses, setupRipple
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { classMap } from 'lit/directives/class-map.js';
|
|
6
|
+
import { focusRingClasses } from '../focus/focus-ring.js';
|
|
7
|
+
import { rippleClasses, setupRipple } from '../ripple/ripple.js';
|
|
8
|
+
import { createClassMapDirective } from '../shared/directives.js';
|
|
9
|
+
import { PSEUDO_CLASSES } from '../shared/pseudo-classes.js';
|
|
11
10
|
/** Radio classes. */
|
|
12
11
|
export const RADIO_CLASSES = {
|
|
13
12
|
radio: 'radio',
|
|
@@ -44,23 +43,6 @@ export function radioClasses({ hover = false, focus = false, active = false, che
|
|
|
44
43
|
export function setupRadio(radio, opts) {
|
|
45
44
|
setupRipple(radio, opts);
|
|
46
45
|
}
|
|
47
|
-
class RadioDirective extends Directive {
|
|
48
|
-
render(state = {}) {
|
|
49
|
-
return classMap({
|
|
50
|
-
...(state.classes || {}),
|
|
51
|
-
...radioClasses(state),
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
update({ element }, [state]) {
|
|
55
|
-
if (element !== this.element) {
|
|
56
|
-
this.element = element;
|
|
57
|
-
this.cleanup?.abort();
|
|
58
|
-
this.cleanup = new AbortController();
|
|
59
|
-
setupRadio(this.element, { signal: this.cleanup.signal });
|
|
60
|
-
}
|
|
61
|
-
return this.render(state);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
46
|
/**
|
|
65
47
|
* A Lit directive that adds radio styling and functionality to its element.
|
|
66
48
|
*
|
|
@@ -73,5 +55,8 @@ class RadioDirective extends Directive {
|
|
|
73
55
|
* `;
|
|
74
56
|
* ```
|
|
75
57
|
*/
|
|
76
|
-
export const radio =
|
|
58
|
+
export const radio = createClassMapDirective({
|
|
59
|
+
getClasses: radioClasses,
|
|
60
|
+
setupElement: setupRadio,
|
|
61
|
+
});
|
|
77
62
|
//# sourceMappingURL=radio.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radio.js","sourceRoot":"","sources":["radio.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"radio.js","sourceRoot":"","sources":["radio.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAC,gBAAgB,EAAC,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAC,aAAa,EAAE,WAAW,EAAC,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAC,uBAAuB,EAAC,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAC,cAAc,EAAC,MAAM,6BAA6B,CAAC;AAE3D,qBAAqB;AACrB,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,cAAc,CAAC,KAAK;IAC3B,KAAK,EAAE,cAAc,CAAC,KAAK;IAC3B,MAAM,EAAE,cAAc,CAAC,MAAM;IAC7B,OAAO,EAAE,cAAc,CAAC,OAAO;IAC/B,QAAQ,EAAE,cAAc,CAAC,QAAQ;CACzB,CAAC;AAgBX;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,EAC3B,KAAK,GAAG,KAAK,EACb,KAAK,GAAG,KAAK,EACb,MAAM,GAAG,KAAK,EACd,OAAO,GAAG,KAAK,EACf,QAAQ,GAAG,KAAK,MACK,EAAE;IACvB,OAAO;QACL,GAAG,aAAa,EAAE;QAClB,GAAG,gBAAgB,EAAE;QACrB,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,IAAI;QAC3B,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,KAAK;QAC5B,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,KAAK;QAC5B,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM;QAC9B,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,OAAO;QAChC,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,QAAQ;KACnC,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CACxB,KAAkB,EAClB,IAA6B;IAE7B,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAC3B,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,uBAAuB,CAAC;IAC3C,UAAU,EAAE,YAAY;IACxB,YAAY,EAAE,UAAU;CACzB,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {type ClassInfo} from 'lit/directives/class-map.js';\nimport {focusRingClasses} from '../focus/focus-ring.js';\nimport {rippleClasses, setupRipple} from '../ripple/ripple.js';\nimport {createClassMapDirective} from '../shared/directives.js';\nimport {PSEUDO_CLASSES} from '../shared/pseudo-classes.js';\n\n/** Radio classes. */\nexport const RADIO_CLASSES = {\n radio: 'radio',\n hover: PSEUDO_CLASSES.hover,\n focus: PSEUDO_CLASSES.focus,\n active: PSEUDO_CLASSES.active,\n checked: PSEUDO_CLASSES.checked,\n disabled: PSEUDO_CLASSES.disabled,\n} as const;\n\n/** The state provided to the `radioClasses()` function. */\nexport interface RadioClassesState {\n /** Emulates `:hover`. */\n hover?: boolean;\n /** Emulates `:focus`. */\n focus?: boolean;\n /** Emulates `:active`. */\n active?: boolean;\n /** Emulates `:checked`. */\n checked?: boolean;\n /** Emulates `:disabled`. */\n disabled?: boolean;\n}\n\n/**\n * Returns the radio classes to apply to an element based on the given state.\n *\n * @param state The state of the radio.\n * @return An object of class names and truthy values if they apply.\n */\nexport function radioClasses({\n hover = false,\n focus = false,\n active = false,\n checked = false,\n disabled = false,\n}: RadioClassesState = {}): ClassInfo {\n return {\n ...rippleClasses(),\n ...focusRingClasses(),\n [RADIO_CLASSES.radio]: true,\n [RADIO_CLASSES.hover]: hover,\n [RADIO_CLASSES.focus]: focus,\n [RADIO_CLASSES.active]: active,\n [RADIO_CLASSES.checked]: checked,\n [RADIO_CLASSES.disabled]: disabled,\n };\n}\n\n/**\n * Sets up radio functionality for the given element.\n *\n * @param radio The element on which to set up radio functionality.\n * @param opts Setup options, supports a cleanup `signal`.\n */\nexport function setupRadio(\n radio: HTMLElement,\n opts?: {signal?: AbortSignal},\n): void {\n setupRipple(radio, opts);\n}\n\n/**\n * A Lit directive that adds radio styling and functionality to its element.\n *\n * @example\n * ```ts\n * html`\n * <input type=\"radio\" class=\"${radio()}\" name=\"radio-group\">\n * <input type=\"radio\" class=\"${radio()}\" name=\"radio-group\">\n * <input type=\"radio\" class=\"${radio()}\" name=\"radio-group\">\n * `;\n * ```\n */\nexport const radio = createClassMapDirective({\n getClasses: radioClasses,\n setupElement: setupRadio,\n});\n"]}
|
|
@@ -44,18 +44,17 @@
|
|
|
44
44
|
height: 48px;
|
|
45
45
|
background-image: none;
|
|
46
46
|
outline: none;
|
|
47
|
+
--icon: 'radio_button_unchecked';
|
|
47
48
|
|
|
48
49
|
&::before {
|
|
49
|
-
content:
|
|
50
|
+
content: var(--icon);
|
|
50
51
|
color: var(--icon-color);
|
|
51
|
-
font
|
|
52
|
-
font-size: var(--icon-size);
|
|
53
|
-
line-height: 1;
|
|
52
|
+
font: var(--icon-size) / 1 var(--md-icon-font);
|
|
54
53
|
width: var(--icon-size);
|
|
55
54
|
aspect-ratio: 1;
|
|
56
55
|
}
|
|
57
56
|
&:is(:checked, .checked)::before {
|
|
58
|
-
|
|
57
|
+
--icon: 'radio_button_checked';
|
|
59
58
|
}
|
|
60
59
|
&::after {
|
|
61
60
|
content: '';
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* Copyright 2026 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { Directive, ElementPart, PartInfo } from 'lit/directive.js';
|
|
7
6
|
import { type ClassInfo } from 'lit/directives/class-map.js';
|
|
8
7
|
/** Ripple classes. */
|
|
9
8
|
export declare const RIPPLE_CLASSES: {
|
|
@@ -39,13 +38,6 @@ export declare function rippleClasses({ hover, active, disabled, }?: RippleClass
|
|
|
39
38
|
export declare function setupRipple(ripple: HTMLElement, opts?: {
|
|
40
39
|
signal?: AbortSignal;
|
|
41
40
|
}): void;
|
|
42
|
-
declare class RippleDirective extends Directive {
|
|
43
|
-
private element?;
|
|
44
|
-
private cleanup?;
|
|
45
|
-
constructor(partInfo: PartInfo);
|
|
46
|
-
render(): void;
|
|
47
|
-
update({ element }: ElementPart): symbol;
|
|
48
|
-
}
|
|
49
41
|
/**
|
|
50
42
|
* A Lit directive that adds updates the position of a ripple to match pointer
|
|
51
43
|
* interactions. Use with the `.ripple` class.
|
|
@@ -82,5 +74,4 @@ declare class RippleDirective extends Directive {
|
|
|
82
74
|
* `;
|
|
83
75
|
* ```
|
|
84
76
|
*/
|
|
85
|
-
export declare const ripple: () => import("lit-html/directive.js").DirectiveResult
|
|
86
|
-
export {};
|
|
77
|
+
export declare const ripple: () => import("lit-html/directive.js").DirectiveResult;
|
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
* Copyright 2026 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { Directive, directive, PartType, } from 'lit/directive.js';
|
|
6
|
+
import { createElementDirective } from '../shared/directives.js';
|
|
7
|
+
import { PSEUDO_CLASSES, isDisabled } from '../shared/pseudo-classes.js';
|
|
9
8
|
/** Ripple classes. */
|
|
10
9
|
export const RIPPLE_CLASSES = {
|
|
11
10
|
ripple: 'ripple',
|
|
@@ -56,22 +55,16 @@ export function setupRipple(ripple, opts) {
|
|
|
56
55
|
});
|
|
57
56
|
}
|
|
58
57
|
}
|
|
58
|
+
catch {
|
|
59
|
+
// Ignore errors if the properties are already registered.
|
|
60
|
+
}
|
|
59
61
|
finally {
|
|
60
62
|
ripplePropertiesRegistered = true;
|
|
61
63
|
}
|
|
62
64
|
}
|
|
63
65
|
let minimumPressTimeoutId;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return;
|
|
67
|
-
// Set ripple position to the pointer position.
|
|
68
|
-
const rect = ripple.getBoundingClientRect();
|
|
69
|
-
const x = (event.clientX - rect.x) / rect.width;
|
|
70
|
-
const y = (event.clientY - rect.y) / rect.height;
|
|
71
|
-
ripple.style.setProperty('--ripple-x', `${x * 100}%`);
|
|
72
|
-
ripple.style.setProperty('--ripple-y', `${y * 100}%`);
|
|
73
|
-
// If another pointerdown is received while the ripple is active, restart
|
|
74
|
-
// the active press animation.
|
|
66
|
+
const activateRipple = () => {
|
|
67
|
+
// If the ripple is already active, restart the current press animation.
|
|
75
68
|
if (ripple.classList.contains(RIPPLE_CLASSES.active)) {
|
|
76
69
|
const pressAnimation = ripple
|
|
77
70
|
.getAnimations()
|
|
@@ -87,30 +80,33 @@ export function setupRipple(ripple, opts) {
|
|
|
87
80
|
minimumPressTimeoutId = setTimeout(() => {
|
|
88
81
|
ripple.classList.remove(RIPPLE_CLASSES.active);
|
|
89
82
|
}, MINIMUM_PRESS_MS);
|
|
83
|
+
};
|
|
84
|
+
// Return true if the ripple is disabled, or if the ripple class has been
|
|
85
|
+
// removed. This allows components to disable and re-enable ripple behavior.
|
|
86
|
+
const isRippleDisabled = () => isDisabled(ripple) || !ripple.matches(`.${RIPPLE_CLASSES.ripple}`);
|
|
87
|
+
ripple.addEventListener('pointerdown', (event) => {
|
|
88
|
+
if (isRippleDisabled())
|
|
89
|
+
return;
|
|
90
|
+
// Set ripple position to the pointer position.
|
|
91
|
+
const rect = ripple.getBoundingClientRect();
|
|
92
|
+
const x = (event.clientX - rect.x) / rect.width;
|
|
93
|
+
const y = (event.clientY - rect.y) / rect.height;
|
|
94
|
+
ripple.style.setProperty('--ripple-x', `${x * 100}%`);
|
|
95
|
+
ripple.style.setProperty('--ripple-y', `${y * 100}%`);
|
|
96
|
+
activateRipple();
|
|
90
97
|
}, opts);
|
|
91
98
|
ripple.addEventListener('keydown', (event) => {
|
|
92
99
|
// Reset ripple pointer position when a key is pressed.
|
|
93
100
|
ripple.style.removeProperty('--ripple-x');
|
|
94
101
|
ripple.style.removeProperty('--ripple-y');
|
|
95
102
|
}, opts);
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
throw new Error('The `ripple` directive must be used on an element');
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
render() { }
|
|
105
|
-
update({ element }) {
|
|
106
|
-
if (this.element !== element) {
|
|
107
|
-
this.element = element;
|
|
108
|
-
this.cleanup?.abort();
|
|
109
|
-
this.cleanup = new AbortController();
|
|
110
|
-
setupRipple(this.element, { signal: this.cleanup.signal });
|
|
103
|
+
ripple.addEventListener('click', (event) => {
|
|
104
|
+
// A UIEvent.detail click count of 0 indicates the click was not triggered
|
|
105
|
+
// by a pointer. Show the ripple press effect for these clicks as well.
|
|
106
|
+
if (event.detail === 0 && !isRippleDisabled()) {
|
|
107
|
+
activateRipple();
|
|
111
108
|
}
|
|
112
|
-
|
|
113
|
-
}
|
|
109
|
+
}, opts);
|
|
114
110
|
}
|
|
115
111
|
/**
|
|
116
112
|
* A Lit directive that adds updates the position of a ripple to match pointer
|
|
@@ -148,5 +144,5 @@ class RippleDirective extends Directive {
|
|
|
148
144
|
* `;
|
|
149
145
|
* ```
|
|
150
146
|
*/
|
|
151
|
-
export const ripple =
|
|
147
|
+
export const ripple = createElementDirective(setupRipple);
|
|
152
148
|
//# sourceMappingURL=ripple.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ripple.js","sourceRoot":"","sources":["ripple.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"ripple.js","sourceRoot":"","sources":["ripple.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAC,sBAAsB,E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: Apache-2.0\n */\n\nimport {type ClassInfo} from 'lit/directives/class-map.js';\nimport {createElementDirective} from '../shared/directives.js';\nimport {PSEUDO_CLASSES, isDisabled} from '../shared/pseudo-classes.js';\n\n/** Ripple classes. */\nexport const RIPPLE_CLASSES = {\n ripple: 'ripple',\n rippleTarget: 'ripple-target',\n rippleHost: 'ripple-host',\n hover: PSEUDO_CLASSES.hover,\n active: PSEUDO_CLASSES.active,\n disabled: PSEUDO_CLASSES.disabled,\n};\n\n/** The state provided to the `rippleClasses()` function. */\nexport interface RippleClassesState {\n /** Emulates `:hover`. */\n hover?: boolean;\n /** Emulates `:active`. */\n active?: boolean;\n /** Emulates `:disabled`. */\n disabled?: boolean;\n}\n\n/**\n * Returns the ripple classes to apply to an element based on the given state.\n *\n * @param state The state of the ripple.\n * @return An object of class names and truthy values if they apply.\n */\nexport function rippleClasses({\n hover = false,\n active = false,\n disabled = false,\n}: RippleClassesState = {}): ClassInfo {\n return {\n [RIPPLE_CLASSES.ripple]: true,\n [RIPPLE_CLASSES.hover]: hover,\n [RIPPLE_CLASSES.active]: active,\n [RIPPLE_CLASSES.disabled]: disabled,\n };\n}\n\nconst MINIMUM_PRESS_MS = 225;\nlet ripplePropertiesRegistered = false;\n\n/**\n * Sets up ripple functionality for the given element.\n *\n * @param ripple The element on which to set up ripple functionality.\n * @param opts Setup options, supports a cleanup `signal`.\n */\nexport function setupRipple(\n ripple: HTMLElement,\n opts?: {signal?: AbortSignal},\n): void {\n if (!ripplePropertiesRegistered) {\n const properties = [\n ['--ripple-scale', '0%'],\n ['--ripple-hover-opacity', '0%'],\n ['--ripple-press-opacity', '0%'],\n ['--ripple-x', '50%'],\n ['--ripple-y', '50%'],\n ];\n\n try {\n for (const [property, value] of properties) {\n CSS.registerProperty({\n name: property,\n syntax: '<percentage>',\n inherits: false,\n initialValue: value,\n });\n }\n } catch {\n // Ignore errors if the properties are already registered.\n } finally {\n ripplePropertiesRegistered = true;\n }\n }\n\n let minimumPressTimeoutId: number | undefined;\n const activateRipple = () => {\n // If the ripple is already active, restart the current press animation.\n if (ripple.classList.contains(RIPPLE_CLASSES.active)) {\n const pressAnimation = ripple\n .getAnimations()\n .find(\n (animation) =>\n (animation as Partial<CSSAnimation>).animationName ===\n 'ripple-press',\n );\n pressAnimation?.cancel();\n pressAnimation?.play();\n }\n\n // Emulate the `:active` class for a minimum press duration to show the\n // ripple effect on short clicks.\n ripple.classList.add(RIPPLE_CLASSES.active);\n clearTimeout(minimumPressTimeoutId);\n minimumPressTimeoutId = setTimeout(() => {\n ripple.classList.remove(RIPPLE_CLASSES.active);\n }, MINIMUM_PRESS_MS);\n };\n\n // Return true if the ripple is disabled, or if the ripple class has been\n // removed. This allows components to disable and re-enable ripple behavior.\n const isRippleDisabled = () =>\n isDisabled(ripple) || !ripple.matches(`.${RIPPLE_CLASSES.ripple}`);\n\n ripple.addEventListener(\n 'pointerdown',\n (event: PointerEvent): void => {\n if (isRippleDisabled()) return;\n // Set ripple position to the pointer position.\n const rect = ripple.getBoundingClientRect();\n const x = (event.clientX - rect.x) / rect.width;\n const y = (event.clientY - rect.y) / rect.height;\n ripple.style.setProperty('--ripple-x', `${x * 100}%`);\n ripple.style.setProperty('--ripple-y', `${y * 100}%`);\n activateRipple();\n },\n opts,\n );\n\n ripple.addEventListener(\n 'keydown',\n (event: KeyboardEvent): void => {\n // Reset ripple pointer position when a key is pressed.\n ripple.style.removeProperty('--ripple-x');\n ripple.style.removeProperty('--ripple-y');\n },\n opts,\n );\n\n ripple.addEventListener(\n 'click',\n (event) => {\n // A UIEvent.detail click count of 0 indicates the click was not triggered\n // by a pointer. Show the ripple press effect for these clicks as well.\n if (event.detail === 0 && !isRippleDisabled()) {\n activateRipple();\n }\n },\n opts,\n );\n}\n\n/**\n * A Lit directive that adds updates the position of a ripple to match pointer\n * interactions. Use with the `.ripple` class.\n *\n * @example\n * ```ts\n * class Component extends LitElement {\n * static styles = [rippleStyles, css`...`];\n *\n * render() {\n * return html`<button class=\"ripple\" ${ripple()}>Ripple effect</button>`;\n * }\n * }\n * ```\n *\n * Use the `.ripple-target` class if the interactive element is a parent or\n * child of the ripple element.\n *\n * The `ripple()` directive should be applied to the parent element, which may\n * be the `.ripple-target` instead of the `.ripple`.\n *\n * @example\n * ```ts\n * html`\n * <div class=\"card ripple\" ${ripple()}>\n * Child interactive element\n * <button class=\"ripple-target card-btn\"></button>\n * </div>\n *\n * <button class=\"ripple-target\" ${ripple()}>\n * Parent interactive element\n * <span class=\"ripple\"></span>\n * </button>\n * `;\n * ```\n */\nexport const ripple = createElementDirective(setupRipple);\n"]}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { DirectiveResult } from 'lit/async-directive.js';
|
|
7
|
+
import { type ClassInfo } from 'lit/directives/class-map.js';
|
|
8
|
+
/**
|
|
9
|
+
* A function that sets up logic for a directive's element.
|
|
10
|
+
*
|
|
11
|
+
* @param element The element attached to the directive.
|
|
12
|
+
* @param opts Options for setting up the element, including an AbortSignal for
|
|
13
|
+
* cleanup.
|
|
14
|
+
*/
|
|
15
|
+
export type SetupElementFunction = (element: HTMLElement, opts: {
|
|
16
|
+
signal: AbortSignal;
|
|
17
|
+
}) => void;
|
|
18
|
+
/**
|
|
19
|
+
* All class map directives include AdditionalClasses to allow adding dynamic
|
|
20
|
+
* classes to the element using `classMap()`.
|
|
21
|
+
*/
|
|
22
|
+
export interface AdditionalClasses {
|
|
23
|
+
/**
|
|
24
|
+
* Additional classes to apply to the element.
|
|
25
|
+
*/
|
|
26
|
+
classes?: ClassInfo;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Options for creating a class map directive.
|
|
30
|
+
*
|
|
31
|
+
* @param getClasses A function that returns the class names and truthy values
|
|
32
|
+
* if they apply.
|
|
33
|
+
* @param setupElement An optional function to set up logic for the directive's
|
|
34
|
+
* element.
|
|
35
|
+
*/
|
|
36
|
+
export interface ClassMapDirectiveOptions<State> {
|
|
37
|
+
getClasses: (state?: State) => ClassInfo;
|
|
38
|
+
setupElement?: SetupElementFunction;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Creates a Lit directive that behaves like `classMap()`, but also provides
|
|
42
|
+
* element setup and cleanup logic.
|
|
43
|
+
*
|
|
44
|
+
* These directives bind to `class="${componentDirectiveName()}"`.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* const toggleButton = createClassMapDirective({
|
|
49
|
+
* getClasses: (state: ToggleButtonState) => ({
|
|
50
|
+
* 'toggle-button': true,
|
|
51
|
+
* 'toggle-button-selected': state.selected,
|
|
52
|
+
* }),
|
|
53
|
+
* setupElement: (element, opts) => {
|
|
54
|
+
* element.addEventListener('click', () => {
|
|
55
|
+
* state.selected = !state.selected;
|
|
56
|
+
* }, opts);
|
|
57
|
+
* },
|
|
58
|
+
* });
|
|
59
|
+
*
|
|
60
|
+
* html`
|
|
61
|
+
* <button class="${toggleButton()}">Unselected</button>
|
|
62
|
+
* <button class="${toggleButton({selected: true})}">Selected</button>
|
|
63
|
+
* <button class="${toggleButton({classes: {'visible': isVisible}})}">
|
|
64
|
+
* With additional classes
|
|
65
|
+
* </button>
|
|
66
|
+
* `;
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @param options Options for creating the class map directive.
|
|
70
|
+
* @return A Lit `directive()` that binds to the class attribute.
|
|
71
|
+
*/
|
|
72
|
+
export declare function createClassMapDirective<State = {}>(options: ClassMapDirectiveOptions<State>): (state?: State & AdditionalClasses) => DirectiveResult;
|
|
73
|
+
/**
|
|
74
|
+
* Creates a Lit directive that can be used to add setup and cleanup logic to
|
|
75
|
+
* an element.
|
|
76
|
+
*
|
|
77
|
+
* These directives bind as element parts.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```ts
|
|
81
|
+
* const logClick = createElementDirective((element, opts) => {
|
|
82
|
+
* element.addEventListener('click', (event) => {
|
|
83
|
+
* console.log('click', event);
|
|
84
|
+
* }, opts);
|
|
85
|
+
* });
|
|
86
|
+
*
|
|
87
|
+
* html`<button ${logClick()}>Click me</button>`;
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* @param setupElement The function to set up logic for the directive's element.
|
|
91
|
+
* @return A Lit `directive()` that binds as an element part.
|
|
92
|
+
*/
|
|
93
|
+
export declare function createElementDirective(setupElement: SetupElementFunction): () => DirectiveResult;
|