@api-client/ui 0.2.7 → 0.2.9
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/build/src/core/ModalActivity.d.ts +4 -0
- package/build/src/core/ModalActivity.d.ts.map +1 -1
- package/build/src/core/ModalActivity.js +4 -1
- package/build/src/core/ModalActivity.js.map +1 -1
- package/build/src/lib/disabled.js +2 -2
- package/build/src/lib/disabled.js.map +1 -1
- package/build/src/md/list/internals/ListItem.d.ts +7 -0
- package/build/src/md/list/internals/ListItem.d.ts.map +1 -1
- package/build/src/md/list/internals/ListItem.js +17 -3
- package/build/src/md/list/internals/ListItem.js.map +1 -1
- package/build/src/md/list/internals/ListItem.styles.d.ts.map +1 -1
- package/build/src/md/list/internals/ListItem.styles.js +18 -1
- package/build/src/md/list/internals/ListItem.styles.js.map +1 -1
- package/demo/md/list/list.ts +32 -0
- package/package.json +1 -1
- package/src/core/ModalActivity.ts +8 -1
- package/src/lib/disabled.ts +2 -2
- package/src/md/list/internals/ListItem.styles.ts +18 -1
- package/src/md/list/internals/ListItem.ts +10 -2
|
@@ -12,6 +12,10 @@ export interface ActionButtonInit {
|
|
|
12
12
|
* Whether the button is disabled.
|
|
13
13
|
*/
|
|
14
14
|
disabled?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Optional callback to be called when the button is clicked.
|
|
17
|
+
*/
|
|
18
|
+
callback?: (e: MouseEvent) => void;
|
|
15
19
|
}
|
|
16
20
|
/**
|
|
17
21
|
* A special kind of activity that renders content in a modal dialog.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalActivity.d.ts","sourceRoot":"","sources":["../../../src/core/ModalActivity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,cAAc,EAAE,MAAM,KAAK,CAAA;AAG/C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CA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AS,CAAC,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAIpD;;;OAGG;IACH,SAAS,CAAC,YAAY,CAAC,CAAC,EAAE,WAAW,GAAG,IAAI;IAI5C;;;OAGG;IACH,YAAY,IAAI,cAAc;IAW9B;;;;;OAKG;IACH,SAAS,CAAC,UAAU,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,cAAc;IAc5E;;;OAGG;IACH,SAAS,CAAC,oBAAoB,CAAC,IAAI,GAAE,gBAAqB,GAAG,cAAc;IAO3E;;;;;OAKG;IACH,SAAS,CAAC,oBAAoB,CAAC,IAAI,GAAE,gBAAqB,GAAG,cAAc;IAgB3E;;;OAGG;IACH,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc;CAGrD"}
|
|
@@ -134,7 +134,9 @@ let ModalActivity = (() => {
|
|
|
134
134
|
*/
|
|
135
135
|
renderNegativeButton(init = {}) {
|
|
136
136
|
const { label = 'Cancel' } = init;
|
|
137
|
-
return html `<ui-text-button slot="button" type="button" value="dismiss"
|
|
137
|
+
return html `<ui-text-button slot="button" type="button" value="dismiss" @click="${init.callback}"
|
|
138
|
+
>${label}</ui-text-button
|
|
139
|
+
>`;
|
|
138
140
|
}
|
|
139
141
|
/**
|
|
140
142
|
* Renders the submit button for the dialog.
|
|
@@ -153,6 +155,7 @@ let ModalActivity = (() => {
|
|
|
153
155
|
type="${type}"
|
|
154
156
|
value="confirm"
|
|
155
157
|
form="${ifDefined(formId)}"
|
|
158
|
+
@click="${init.callback}"
|
|
156
159
|
>${label}</ui-text-button
|
|
157
160
|
>`;
|
|
158
161
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalActivity.js","sourceRoot":"","sources":["../../../src/core/ModalActivity.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAuB,MAAM,KAAK,CAAA;AAC/C,OAAO,EAAE,SAAS,EAAE,MA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ult } from 'lit'\nimport { ifDefined } from 'lit/directives/if-defined.js'\nimport { classMap } from 'lit/directives/class-map.js'\nimport { Activity } from './Activity.js'\nimport type { UiDialogClosingReason } from '../md/dialog/internals/Dialog.js'\nimport state from '../decorators/state.js'\nimport { IntentResult } from './ActivityManager.js'\n\nimport '../md/dialog/ui-dialog.js'\nimport '../md/button/ui-text-button.js'\n\nexport interface ActionButtonInit {\n /**\n * The label to use for the button.\n */\n label?: string\n /**\n * Whether the button is disabled.\n */\n disabled?: boolean\n /**\n * Optional callback to be called when the button is clicked.\n */\n callback?: (e: MouseEvent) => void\n}\n\n/**\n * A special kind of activity that renders content in a modal dialog.\n * When a modal activity is running the underlying activities are paused.\n *\n * A modal activity uses the UiDialogElement to render its content. The dialog\n * is inserted directly into the `<body>` element of the document and rendered\n * in the top layer. Because of that, the modal activity does not support\n * regular rendering logic. It creates its own render root that is used to render\n * the template.\n */\nexport abstract class ModalActivity extends Activity {\n /**\n * The list of classes to apply to the dialog.\n */\n protected dialogClasses: Record<string, boolean> = {}\n /**\n * Controls dialog visibility without controlling the activity state.\n */\n @state() accessor opened = true\n\n /**\n * The id of the form used to render the dialog.\n */\n protected formId?: string\n\n override onResume(): void | Promise<void> {\n this.renderRoot = document.createElement('div')\n this.renderRoot.classList.add('modal-activity-container')\n document.body.appendChild(this.renderRoot)\n super.onResume()\n this.requestUpdate()\n }\n\n override async finish(): Promise<void> {\n if (this.renderRoot) {\n document.body.removeChild(this.renderRoot)\n this.renderRoot = undefined\n }\n await super.finish()\n }\n\n protected handleDialogClosed(e: CustomEvent<UiDialogClosingReason>): void {\n const { cancelled, value } = e.detail\n if (cancelled) {\n this.handleNegativeAction(value)\n } else {\n this.handlePositiveAction(value)\n }\n }\n\n /**\n * Called when the dialog is closed with a negative action.\n * Override this function to handle the negative action.\n * @param value The value passed to the dialog when it is closed.\n */\n protected handleNegativeAction(value: unknown): void {\n this.setResult(IntentResult.RESULT_CANCELED, value)\n this.finish()\n }\n\n /**\n * Called when the dialog is closed with a positive action.\n * Override this function to handle the positive action.\n * @param value The value passed to the dialog when it is closed.\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n protected handlePositiveAction(value: unknown): void {\n this.finish()\n }\n\n /**\n * Override this method to handle the form submission.\n * @param e The submit event.\n */\n protected handleSubmit(e: SubmitEvent): void {\n e.preventDefault()\n }\n\n /**\n * The function called by the rendered when rendering this dialog.\n * This way, the `render()` function is still used as the primary template provider.\n */\n renderDialog(): TemplateResult {\n const classes = {\n activityDialog: true,\n [this.constructor.name.toLowerCase()]: true,\n ...this.dialogClasses,\n }\n return html`<ui-dialog modal .open=\"${this.opened}\" class=\"${classMap(classes)}\" @close=\"${this.handleDialogClosed}\"\n >${this.render()}</ui-dialog\n >`\n }\n\n /**\n * Used with dialogs that render forms. Override the `handleSubmit` method\n * to handle the form submission.\n * @param content The content to render in the form.\n * @param name Optional form name\n */\n protected renderForm(content: TemplateResult, name?: string): TemplateResult {\n if (!this.formId) {\n this.formId = `form-${this.constructor.name.toLowerCase()}`\n }\n return html`<form\n id=\"${this.formId}\"\n name=\"${ifDefined(name)}\"\n class=\"dialog-content\"\n @submit=\"${this.handleSubmit}\"\n >\n ${content}\n </form>`\n }\n\n /**\n * Renders the cancel button for the dialog.\n * @param label The label to use for the cancel button.\n */\n protected renderNegativeButton(init: ActionButtonInit = {}): TemplateResult {\n const { label = 'Cancel' } = init\n return html`<ui-text-button slot=\"button\" type=\"button\" value=\"dismiss\" @click=\"${init.callback}\"\n >${label}</ui-text-button\n >`\n }\n\n /**\n * Renders the submit button for the dialog.\n * If the formId is set, the button will be a submit button.\n * Otherwise, it will be a regular button.\n * @param label The label to use for the submit button.\n */\n protected renderPositiveButton(init: ActionButtonInit = {}): TemplateResult {\n const { label = 'OK', disabled = false } = init\n const { formId } = this\n const type = formId ? 'submit' : 'button'\n // UI buttons have a proper support for form association.\n return html`<ui-text-button\n slot=\"button\"\n ?disabled=\"${disabled}\"\n type=\"${type}\"\n value=\"confirm\"\n form=\"${ifDefined(formId)}\"\n @click=\"${init.callback}\"\n >${label}</ui-text-button\n >`\n }\n\n /**\n * Renders the title for the dialog.\n * @param title The title to render in the dialog.\n */\n protected renderTitle(title: string): TemplateResult {\n return html`<span slot=\"title\">${title}</span>`\n }\n}\n"]}
|
|
@@ -25,8 +25,8 @@ export function setDisabled(target, disabled) {
|
|
|
25
25
|
target.removeAttribute('tabindex');
|
|
26
26
|
target.setAttribute('aria-disabled', 'true');
|
|
27
27
|
}
|
|
28
|
-
else {
|
|
29
|
-
target.setAttribute('tabindex', state.tabindexBeforeDisabled
|
|
28
|
+
else if (state.tabindexBeforeDisabled) {
|
|
29
|
+
target.setAttribute('tabindex', state.tabindexBeforeDisabled);
|
|
30
30
|
delete state.tabindexBeforeDisabled;
|
|
31
31
|
target.removeAttribute('aria-disabled');
|
|
32
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"disabled.js","sourceRoot":"","sources":["../../../src/lib/disabled.ts"],"names":[],"mappings":"AAKA,MAAM,QAAQ,GAAG,IAAI,OAAO,EAA8B,CAAA;AAE1D;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,MAAmB;IAC5C,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IAClC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,KAAK,CAAA;IACd,CAAC;IACD,OAAO,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAA;AACzB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,MAAmB,EAAE,QAA6B;IAC5E,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAA;IACxC,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAA;IACzB,IAAI,QAAQ,EAAE,CAAC;QACb,KAAK,CAAC,sBAAsB,GAAG,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,GAAG,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C7B,CAAC","sourcesContent":["interface IDisabledInfo {\n disabled?: boolean\n tabindexBeforeDisabled?: string\n}\n\nconst elements = new WeakMap<HTMLElement, IDisabledInfo>()\n\n/**\n * A helper function to unify the way how the `disabled` state is read.\n * @param target The HTML element target.\n * @returns Whether the element is disabled\n */\nexport function isDisabled(target: HTMLElement): boolean {\n const state = elements.get(target)\n if (!state) {\n return false\n }\n return !!state.disabled\n}\n\n/**\n * A helper function to unify the way how the `disabled` state is set.\n * Note, call `requestUpdate()` on the element to trigger the update.\n * @param target The HTML element target.\n * @param disabled Whether the element is to be set as disabled\n */\nexport function setDisabled(target: HTMLElement, disabled: boolean | undefined): void {\n const state = elements.get(target) || {}\n state.disabled = disabled\n if (disabled) {\n state.tabindexBeforeDisabled = target.getAttribute('tabindex') || '0'\n target.removeAttribute('tabindex')\n target.setAttribute('aria-disabled', 'true')\n } else if (state.tabindexBeforeDisabled) {\n target.setAttribute('tabindex', state.tabindexBeforeDisabled)\n delete state.tabindexBeforeDisabled\n target.removeAttribute('aria-disabled')\n }\n elements.set(target, state)\n}\n"]}
|
|
@@ -41,6 +41,13 @@ export default class UiListItem extends UiElement {
|
|
|
41
41
|
* @attribute
|
|
42
42
|
*/
|
|
43
43
|
accessor image: ListItemImage;
|
|
44
|
+
/**
|
|
45
|
+
* Whether the list item is static and should not be focusable.
|
|
46
|
+
* The ripple effect will not be applied when `true`.
|
|
47
|
+
* @default false
|
|
48
|
+
* @attribute
|
|
49
|
+
*/
|
|
50
|
+
accessor static: boolean;
|
|
44
51
|
constructor();
|
|
45
52
|
connectedCallback(): void;
|
|
46
53
|
protected willUpdate(cp: PropertyValues<this>): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItem.d.ts","sourceRoot":"","sources":["../../../../../src/md/list/internals/ListItem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,cAAc,EAAE,cAAc,EAAE,MAAM,KAAK,CAAA;AAG1D,OAAO,EAAE,SAAS,EAAE,M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static_initializers = [];
|
|
39
|
+
let _static_extraInitializers = [];
|
|
37
40
|
return class UiListItem extends _classSuper {
|
|
38
41
|
static {
|
|
39
42
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
@@ -41,10 +44,12 @@ let UiListItem = (() => {
|
|
|
41
44
|
_disabled_decorators = [property({ type: Boolean, reflect: true })];
|
|
42
45
|
_lines_decorators = [property({ type: String, reflect: true })];
|
|
43
46
|
_image_decorators = [property({ type: String, reflect: true })];
|
|
47
|
+
_static_decorators = [property({ type: Boolean, reflect: true })];
|
|
44
48
|
__esDecorate(this, null, _ripple_decorators, { kind: "accessor", name: "ripple", static: false, private: false, access: { has: obj => "ripple" in obj, get: obj => obj.ripple, set: (obj, value) => { obj.ripple = value; } }, metadata: _metadata }, _ripple_initializers, _ripple_extraInitializers);
|
|
45
49
|
__esDecorate(this, null, _disabled_decorators, { kind: "accessor", name: "disabled", static: false, private: false, access: { has: obj => "disabled" in obj, get: obj => obj.disabled, set: (obj, value) => { obj.disabled = value; } }, metadata: _metadata }, _disabled_initializers, _disabled_extraInitializers);
|
|
46
50
|
__esDecorate(this, null, _lines_decorators, { kind: "accessor", name: "lines", static: false, private: false, access: { has: obj => "lines" in obj, get: obj => obj.lines, set: (obj, value) => { obj.lines = value; } }, metadata: _metadata }, _lines_initializers, _lines_extraInitializers);
|
|
47
51
|
__esDecorate(this, null, _image_decorators, { kind: "accessor", name: "image", static: false, private: false, access: { has: obj => "image" in obj, get: obj => obj.image, set: (obj, value) => { obj.image = value; } }, metadata: _metadata }, _image_initializers, _image_extraInitializers);
|
|
52
|
+
__esDecorate(this, null, _static_decorators, { kind: "accessor", name: "static", static: false, private: false, access: { has: obj => "static" in obj, get: obj => obj.static, set: (obj, value) => { obj.static = value; } }, metadata: _metadata }, _static_initializers, _static_extraInitializers);
|
|
48
53
|
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
49
54
|
}
|
|
50
55
|
#ripple_accessor_storage = __runInitializers(this, _ripple_initializers, void 0);
|
|
@@ -79,6 +84,15 @@ let UiListItem = (() => {
|
|
|
79
84
|
*/
|
|
80
85
|
get image() { return this.#image_accessor_storage; }
|
|
81
86
|
set image(value) { this.#image_accessor_storage = value; }
|
|
87
|
+
#static_accessor_storage = (__runInitializers(this, _image_extraInitializers), __runInitializers(this, _static_initializers, false));
|
|
88
|
+
/**
|
|
89
|
+
* Whether the list item is static and should not be focusable.
|
|
90
|
+
* The ripple effect will not be applied when `true`.
|
|
91
|
+
* @default false
|
|
92
|
+
* @attribute
|
|
93
|
+
*/
|
|
94
|
+
get static() { return this.#static_accessor_storage; }
|
|
95
|
+
set static(value) { this.#static_accessor_storage = value; }
|
|
82
96
|
constructor() {
|
|
83
97
|
super();
|
|
84
98
|
this.lines = ListItemLines.one;
|
|
@@ -179,9 +193,9 @@ let UiListItem = (() => {
|
|
|
179
193
|
</div>
|
|
180
194
|
`;
|
|
181
195
|
}
|
|
182
|
-
renderRipple = (__runInitializers(this,
|
|
183
|
-
const { disabled } = this;
|
|
184
|
-
return html `<ui-ripple class="ripple" ?disabled="${disabled}"></ui-ripple>`;
|
|
196
|
+
renderRipple = (__runInitializers(this, _static_extraInitializers), () => {
|
|
197
|
+
const { disabled, static: isStatic } = this;
|
|
198
|
+
return html `<ui-ripple class="ripple" ?disabled="${disabled || isStatic}"></ui-ripple>`;
|
|
185
199
|
});
|
|
186
200
|
renderStart() {
|
|
187
201
|
return html `<div class="start">
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItem.js","sourceRoot":"","sources":["../../../../../src/md/list/internals/ListItem.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAkC,MAAM,KAAK,CAAA;AAC1D,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CA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I,CAAC,WAAW,EAAE,IAAI,IAAI,CAAC,UAAU,EAAE,IAAI,IAAI,CAAC,SAAS,EAAE;UAChF,IAAI,CAAC,YAAY,EAAE;;KAExB,CAAA;QACH,CAAC;QAES,YAAY,uDAAG,GAAmB,EAAE;YAC5C,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAA;YACzB,OAAO,IAAI,CAAA,wCAAwC,QAAQ,gBAAgB,CAAA;QAC7E,CAAC,EAAA;QAES,WAAW;YACnB,OAAO,IAAI,CAAA;uCACwB,IAAI,CAAC,gBAAgB;WACjD,CAAA;QACT,CAAC;QAES,SAAS;YACjB,OAAO,IAAI,CAAA;qCACsB,IAAI,CAAC,gBAAgB;;WAE/C,CAAA;QACT,CAAC;QAES,UAAU;YAClB,MAAM,EAAE,KAAK,GAAG,aAAa,CAAC,GAAG,EAAE,GAAG,IAAI,CAAA;YAC1C,MAAM,iBAAiB,GAAG,KAAK,KAAK,aAAa,CAAC,GAAG,CAAA;YACrD,OAAO,IAAI,CAAA;;;UAGL,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAA,2EAA2E,CAAC,CAAC,CAAC,EAAE;;KAE7G,CAAA;QACH,CAAC;;;AAjLH;;;;;;GAMG;AACH,0BA2KC","sourcesContent":["import { html, PropertyValues, TemplateResult } from 'lit'\nimport { property, query } from 'lit/decorators.js'\nimport { classMap } from 'lit/directives/class-map.js'\nimport { UiElement } from '../../UiElement.js'\nimport { BeginPressConfig, EndPressConfig } from '../../../controllers/ActionController.js'\nimport UiRipple from '../../ripple/internals/ripple.js'\nimport { setDisabled } from '../../../lib/disabled.js'\nimport { ripple } from '../../effects/rippleDirective.js'\nimport '../../ripple/ui-ripple.js'\n\nexport enum ListItemLines {\n one = 'one',\n two = 'two',\n three = 'three',\n}\n\nexport enum ListItemImage {\n icon = 'icon',\n avatar = 'avatar',\n image = 'image',\n video = 'video',\n auto = 'auto',\n}\n\n/**\n * @slot\n * @slot start\n * @slot end\n * @slot end-text\n * @slot supporting-text\n */\nexport default class UiListItem extends UiElement {\n @query('ui-ripple') accessor ripple!: UiRipple\n\n /**\n * Whether the chip is disabled. The user can't interact with the chip when `true`.\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) accessor disabled = false\n\n /**\n * The number of lines to render the list template for.\n * @default ListItemLines.one\n * @attribute\n */\n @property({ type: String, reflect: true }) accessor lines: ListItemLines\n\n /**\n * The type of the list image.\n * @default ListItemImage.icon\n * @attribute\n */\n @property({ type: String, reflect: true }) accessor image: ListItemImage\n\n constructor() {\n super()\n\n this.lines = ListItemLines.one\n this.image = ListItemImage.icon\n\n this.addEventListener('click', this.handleClick.bind(this))\n this.addEventListener('pointerdown', this.handlePointerDown.bind(this))\n this.addEventListener('pointerup', this.handlePointerUp.bind(this))\n this.addEventListener('pointercancel', this.handlePointerCancel.bind(this))\n this.addEventListener('pointerleave', this.handlePointerLeave.bind(this))\n this.addEventListener('contextmenu', this.handleContextMenu.bind(this))\n this.addEventListener('keydown', this.handleKeyDown.bind(this))\n this.addEventListener('keyup', this.handleKeyUp.bind(this))\n this.addEventListener('focus', this.handleFocus.bind(this))\n this.addEventListener('blur', this.handleBlur.bind(this))\n }\n\n override connectedCallback(): void {\n super.connectedCallback()\n if (!this.hasAttribute('role')) {\n this.setAttribute('role', 'listitem')\n }\n }\n\n protected override willUpdate(cp: PropertyValues<this>): void {\n if (cp.has('disabled')) {\n setDisabled(this, cp.get('disabled'))\n }\n }\n\n override handleKeyDown(e: KeyboardEvent): void {\n if (e.key !== ' ' && e.key !== 'Enter') return\n\n e.preventDefault()\n this.beginPress({ positionEvent: e })\n }\n\n override handleKeyUp(e: KeyboardEvent): void {\n if (e.key !== ' ' && e.key !== 'Enter') return\n\n e.preventDefault()\n this.endPress({ cancelled: false, actionData: { item: this } })\n }\n\n override beginPress(options: BeginPressConfig): void {\n super.beginPress(options)\n this.ripple.beginPress(options.positionEvent)\n }\n\n override endPress(options: EndPressConfig): void {\n super.endPress(options)\n this.ripple.endPress()\n }\n\n protected handlePointerEnter(e: PointerEvent): void {\n this.ripple.beginHover(e)\n }\n\n override handlePointerLeave(e: PointerEvent): void {\n super.handlePointerLeave(e)\n\n this.ripple.endHover()\n }\n\n protected handleFocus(): void {\n this.ripple.beginFocus()\n }\n\n protected handleBlur(): void {\n // if (this.matches(':focus-within')) {\n // return;\n // }\n this.ripple.endFocus()\n }\n\n /**\n * Focuses list item and makes list item focusable via keyboard.\n */\n activate(): void {\n this.setAttribute('tabindex', '0')\n this.focus()\n this.ripple.beginFocus()\n }\n\n /**\n * Returns true if list item is currently focused and is focusable.\n */\n isActive(): boolean {\n return this.getAttribute('tabindex') === '0'\n }\n\n /**\n * Removes list item from sequential keyboard navigation.\n */\n deactivate(): void {\n this.removeAttribute('tabindex')\n }\n\n protected handleSlotChange(): void {\n this.requestUpdate()\n }\n\n protected override render(): TemplateResult {\n const { pressed = false } = this\n const surfaceClasses = classMap({\n surface: true,\n pressed,\n })\n\n return html`\n <div class=\"${surfaceClasses}\" ${ripple(() => this.ripple)}>\n <div class=\"container\"></div>\n <div class=\"state\"></div>\n <div class=\"content\">${this.renderStart()} ${this.renderBody()} ${this.renderEnd()}</div>\n ${this.renderRipple()}\n </div>\n `\n }\n\n protected renderRipple = (): TemplateResult => {\n const { disabled } = this\n return html`<ui-ripple class=\"ripple\" ?disabled=\"${disabled}\"></ui-ripple>`\n }\n\n protected renderStart(): TemplateResult {\n return html`<div class=\"start\">\n <slot name=\"start\" @slotchange=${this.handleSlotChange}></slot>\n </div>`\n }\n\n protected renderEnd(): TemplateResult {\n return html`<div class=\"end\">\n <slot name=\"end\" @slotchange=${this.handleSlotChange}></slot>\n <span class=\"trailing-supporting-text\"><slot name=\"end-text\"></slot></span>\n </div>`\n }\n\n protected renderBody(): TemplateResult {\n const { lines = ListItemLines.one } = this\n const hasSupportingText = lines !== ListItemLines.one\n return html`\n <div class=\"body\">\n <span class=\"headline\"><slot></slot></span>\n ${hasSupportingText ? html`<span class=\"supporting-text\"><slot name=\"supporting-text\"></slot></span>` : ''}\n </div>\n `\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ListItem.js","sourceRoot":"","sources":["../../../../../src/md/list/internals/ListItem.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAkC,MAAM,KAAK,CAAA;AAC1D,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAG9C,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAA;AACzD,OAAO,2BAA2B,CAAA;AAElC,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,4BAAW,CAAA;IACX,4BAAW,CAAA;IACX,gCAAe,CAAA;AACjB,CAAC,EAJW,aAAa,KAAb,aAAa,QAIxB;AAED,MAAM,CAAN,IAAY,aAMX;AAND,WAAY,aAAa;IACvB,8BAAa,CAAA;IACb,kCAAiB,CAAA;IACjB,gCAAe,CAAA;IACf,gCAAe,CAAA;IACf,8BAAa,CAAA;AACf,CAAC,EANW,aAAa,KAAb,aAAa,QAMxB;;sBASuC,SAAS;;;;;;;;;;;;;;;;iBAA5B,UAAW,SAAQ,WAAS;;;kCAC9C,KAAK,CAAC,WAAW,CAAC;oCAMlB,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;iCAO1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;iCAOzC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;kCAQzC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;YA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AAC,IAAI,CAAA,2EAA2E,CAAC,CAAC,CAAC,EAAE;;KAE7G,CAAA;QACH,CAAC;;;AAzLH;;;;;;GAMG;AACH,0BAmLC","sourcesContent":["import { html, PropertyValues, TemplateResult } from 'lit'\nimport { property, query } from 'lit/decorators.js'\nimport { classMap } from 'lit/directives/class-map.js'\nimport { UiElement } from '../../UiElement.js'\nimport { BeginPressConfig, EndPressConfig } from '../../../controllers/ActionController.js'\nimport UiRipple from '../../ripple/internals/ripple.js'\nimport { setDisabled } from '../../../lib/disabled.js'\nimport { ripple } from '../../effects/rippleDirective.js'\nimport '../../ripple/ui-ripple.js'\n\nexport enum ListItemLines {\n one = 'one',\n two = 'two',\n three = 'three',\n}\n\nexport enum ListItemImage {\n icon = 'icon',\n avatar = 'avatar',\n image = 'image',\n video = 'video',\n auto = 'auto',\n}\n\n/**\n * @slot\n * @slot start\n * @slot end\n * @slot end-text\n * @slot supporting-text\n */\nexport default class UiListItem extends UiElement {\n @query('ui-ripple') accessor ripple!: UiRipple\n\n /**\n * Whether the chip is disabled. The user can't interact with the chip when `true`.\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) accessor disabled = false\n\n /**\n * The number of lines to render the list template for.\n * @default ListItemLines.one\n * @attribute\n */\n @property({ type: String, reflect: true }) accessor lines: ListItemLines\n\n /**\n * The type of the list image.\n * @default ListItemImage.icon\n * @attribute\n */\n @property({ type: String, reflect: true }) accessor image: ListItemImage\n\n /**\n * Whether the list item is static and should not be focusable.\n * The ripple effect will not be applied when `true`.\n * @default false\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) accessor static = false\n\n constructor() {\n super()\n\n this.lines = ListItemLines.one\n this.image = ListItemImage.icon\n\n this.addEventListener('click', this.handleClick.bind(this))\n this.addEventListener('pointerdown', this.handlePointerDown.bind(this))\n this.addEventListener('pointerup', this.handlePointerUp.bind(this))\n this.addEventListener('pointercancel', this.handlePointerCancel.bind(this))\n this.addEventListener('pointerleave', this.handlePointerLeave.bind(this))\n this.addEventListener('contextmenu', this.handleContextMenu.bind(this))\n this.addEventListener('keydown', this.handleKeyDown.bind(this))\n this.addEventListener('keyup', this.handleKeyUp.bind(this))\n this.addEventListener('focus', this.handleFocus.bind(this))\n this.addEventListener('blur', this.handleBlur.bind(this))\n }\n\n override connectedCallback(): void {\n super.connectedCallback()\n if (!this.hasAttribute('role')) {\n this.setAttribute('role', 'listitem')\n }\n }\n\n protected override willUpdate(cp: PropertyValues<this>): void {\n if (cp.has('disabled')) {\n setDisabled(this, cp.get('disabled'))\n }\n }\n\n override handleKeyDown(e: KeyboardEvent): void {\n if (e.key !== ' ' && e.key !== 'Enter') return\n\n e.preventDefault()\n this.beginPress({ positionEvent: e })\n }\n\n override handleKeyUp(e: KeyboardEvent): void {\n if (e.key !== ' ' && e.key !== 'Enter') return\n\n e.preventDefault()\n this.endPress({ cancelled: false, actionData: { item: this } })\n }\n\n override beginPress(options: BeginPressConfig): void {\n super.beginPress(options)\n this.ripple.beginPress(options.positionEvent)\n }\n\n override endPress(options: EndPressConfig): void {\n super.endPress(options)\n this.ripple.endPress()\n }\n\n protected handlePointerEnter(e: PointerEvent): void {\n this.ripple.beginHover(e)\n }\n\n override handlePointerLeave(e: PointerEvent): void {\n super.handlePointerLeave(e)\n\n this.ripple.endHover()\n }\n\n protected handleFocus(): void {\n this.ripple.beginFocus()\n }\n\n protected handleBlur(): void {\n // if (this.matches(':focus-within')) {\n // return;\n // }\n this.ripple.endFocus()\n }\n\n /**\n * Focuses list item and makes list item focusable via keyboard.\n */\n activate(): void {\n this.setAttribute('tabindex', '0')\n this.focus()\n this.ripple.beginFocus()\n }\n\n /**\n * Returns true if list item is currently focused and is focusable.\n */\n isActive(): boolean {\n return this.getAttribute('tabindex') === '0'\n }\n\n /**\n * Removes list item from sequential keyboard navigation.\n */\n deactivate(): void {\n this.removeAttribute('tabindex')\n }\n\n protected handleSlotChange(): void {\n this.requestUpdate()\n }\n\n protected override render(): TemplateResult {\n const { pressed = false } = this\n const surfaceClasses = classMap({\n surface: true,\n pressed,\n })\n\n return html`\n <div class=\"${surfaceClasses}\" ${ripple(() => this.ripple)}>\n <div class=\"container\"></div>\n <div class=\"state\"></div>\n <div class=\"content\">${this.renderStart()} ${this.renderBody()} ${this.renderEnd()}</div>\n ${this.renderRipple()}\n </div>\n `\n }\n\n protected renderRipple = (): TemplateResult => {\n const { disabled, static: isStatic } = this\n return html`<ui-ripple class=\"ripple\" ?disabled=\"${disabled || isStatic}\"></ui-ripple>`\n }\n\n protected renderStart(): TemplateResult {\n return html`<div class=\"start\">\n <slot name=\"start\" @slotchange=${this.handleSlotChange}></slot>\n </div>`\n }\n\n protected renderEnd(): TemplateResult {\n return html`<div class=\"end\">\n <slot name=\"end\" @slotchange=${this.handleSlotChange}></slot>\n <span class=\"trailing-supporting-text\"><slot name=\"end-text\"></slot></span>\n </div>`\n }\n\n protected renderBody(): TemplateResult {\n const { lines = ListItemLines.one } = this\n const hasSupportingText = lines !== ListItemLines.one\n return html`\n <div class=\"body\">\n <span class=\"headline\"><slot></slot></span>\n ${hasSupportingText ? html`<span class=\"supporting-text\"><slot name=\"supporting-text\"></slot></span>` : ''}\n </div>\n `\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItem.styles.d.ts","sourceRoot":"","sources":["../../../../../src/md/list/internals/ListItem.styles.ts"],"names":[],"mappings":";AAEA,
|
|
1
|
+
{"version":3,"file":"ListItem.styles.d.ts","sourceRoot":"","sources":["../../../../../src/md/list/internals/ListItem.styles.ts"],"names":[],"mappings":";AAEA,wBAuMC"}
|
|
@@ -109,7 +109,16 @@ export default css `
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
:host([lines='three']) .supporting-text {
|
|
112
|
-
height: calc(
|
|
112
|
+
height: calc(2 * var(--md-sys-typescale-body-medium-height, 1.1));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
:host([lines='three']) .supporting-text ::slotted(*) {
|
|
116
|
+
display: -webkit-box;
|
|
117
|
+
-webkit-box-orient: vertical;
|
|
118
|
+
-webkit-line-clamp: 2;
|
|
119
|
+
line-clamp: 2;
|
|
120
|
+
overflow: hidden;
|
|
121
|
+
text-overflow: ellipsis;
|
|
113
122
|
}
|
|
114
123
|
|
|
115
124
|
:host([lines='two']) .supporting-text ::slotted(*) {
|
|
@@ -181,5 +190,13 @@ export default css `
|
|
|
181
190
|
inset: 0;
|
|
182
191
|
z-index: 1;
|
|
183
192
|
}
|
|
193
|
+
|
|
194
|
+
:host([static]:hover) .state {
|
|
195
|
+
background-color: var(--md-sys-color-on-surface);
|
|
196
|
+
opacity: var(--md-sys-state-hover-state-layer-opacity);
|
|
197
|
+
position: absolute;
|
|
198
|
+
inset: 0;
|
|
199
|
+
z-index: 1;
|
|
200
|
+
}
|
|
184
201
|
`;
|
|
185
202
|
//# sourceMappingURL=ListItem.styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItem.styles.js","sourceRoot":"","sources":["../../../../../src/md/list/internals/ListItem.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAEzB,eAAe,GAAG,CAAA
|
|
1
|
+
{"version":3,"file":"ListItem.styles.js","sourceRoot":"","sources":["../../../../../src/md/list/internals/ListItem.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAEzB,eAAe,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuMjB,CAAA","sourcesContent":["import { css } from 'lit'\n\nexport default css`\n :host {\n display: block;\n height: 56px;\n outline: none;\n cursor: default;\n }\n\n :host([disabled]) {\n cursor: not-allowed;\n }\n\n :host([hidden]) {\n display: none;\n }\n\n :host([lines='two']),\n :host([lines='one'][image='image']) {\n height: 72px;\n }\n\n :host([lines='three']),\n :host([lines='one'][image='video']) {\n height: 88px;\n }\n\n .surface {\n height: inherit;\n position: relative;\n\n display: flex;\n align-items: center;\n }\n\n .surface,\n .content {\n width: 100%;\n }\n\n .container {\n position: absolute;\n inset: 0;\n z-index: 1;\n\n /* background-color: var(--md-sys-color-surface); */\n }\n\n .content {\n position: relative;\n z-index: 2;\n display: flex;\n align-items: center;\n overflow: hidden;\n padding: 8px 16px 8px 16px;\n }\n\n .ripple {\n z-index: 3;\n }\n\n :host([image='video']) .content {\n /* The spec says the right padding is 24px but counting from the checkbox check border.\n This does not include spacing presented by the checkbox itself (18 box, 40px state layer)\n */\n padding: 12px 16px 12px 0px;\n }\n\n .headline {\n color: var(--md-sys-color-on-surface);\n\n font-family: var(--md-sys-typescale-body-large-font);\n font-weight: var(--md-sys-typescale-body-large-weight);\n font-size: var(--md-sys-typescale-body-large-size);\n letter-spacing: var(--md-sys-typescale-body-large-tracking);\n line-height: var(--md-sys-typescale-body-large-height);\n\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n\n display: flex;\n align-items: center;\n }\n\n .supporting-text {\n color: var(--md-sys-color-on-surface-variant);\n\n font-family: var(--md-sys-typescale-body-medium-font);\n font-weight: var(--md-sys-typescale-body-medium-weight);\n font-size: var(--md-sys-typescale-body-medium-size);\n letter-spacing: var(--md-sys-typescale-body-medium-tracking);\n line-height: var(--md-sys-typescale-body-medium-height);\n\n overflow: hidden;\n }\n\n .supporting-text ::slotted(*),\n slot[name='end-text']::slotted(*) {\n margin: 0;\n padding: 0;\n overflow: hidden;\n }\n\n slot[name='end-text']::slotted(*) {\n /* this is to make up to the 24px right padding defined in the spec. */\n margin-right: 8px;\n margin-left: 16px;\n }\n\n :host([lines='three']) .supporting-text {\n height: calc(2 * var(--md-sys-typescale-body-medium-height, 1.1));\n }\n\n :host([lines='three']) .supporting-text ::slotted(*) {\n display: -webkit-box;\n -webkit-box-orient: vertical;\n -webkit-line-clamp: 2;\n line-clamp: 2;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n\n :host([lines='two']) .supporting-text ::slotted(*) {\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .trailing-supporting-text {\n color: var(--md-sys-color-on-surface-variant);\n\n font-family: var(--md-sys-typescale-body-small-font);\n font-weight: var(--md-sys-typescale-body-small-weight);\n font-size: var(--md-sys-typescale-body-small-size);\n letter-spacing: var(--md-sys-typescale-body-small-tracking);\n line-height: var(--md-sys-typescale-body-small-height);\n }\n\n :host slot[name='end']::slotted(*) {\n color: var(--md-sys-color-on-surface-variant);\n fill: var(--md-sys-color-on-surface-variant);\n margin-left: 16px;\n }\n\n :host slot[name='start']::slotted(*) {\n display: block;\n margin-right: 16px;\n }\n\n :host([image='icon']) slot[name='start']::slotted(*) {\n width: 24px;\n height: 24px;\n }\n\n :host([image='avatar']) slot[name='start']::slotted(*) {\n width: 40px;\n height: 40px;\n }\n\n :host([image='image']) slot[name='start']::slotted(*) {\n width: 56px;\n height: 56px;\n }\n\n :host([image='video']) slot[name='start']::slotted(*) {\n width: 114px;\n height: 64px;\n }\n\n .body {\n flex: 1;\n overflow: hidden;\n display: flex;\n flex-direction: column;\n }\n\n :host(.highlight) .state {\n background-color: var(--md-sys-color-on-surface);\n opacity: var(--md-sys-state-hover-state-layer-opacity);\n position: absolute;\n inset: 0;\n z-index: 1;\n }\n\n :host(.select) .state {\n background-color: var(--md-sys-color-secondary-container);\n color: var(--md-sys-color-on-secondary-container);\n opacity: var(--md-sys-state-focus-state-layer-opacity);\n position: absolute;\n inset: 0;\n z-index: 1;\n }\n\n :host([static]:hover) .state {\n background-color: var(--md-sys-color-on-surface);\n opacity: var(--md-sys-state-hover-state-layer-opacity);\n position: absolute;\n inset: 0;\n z-index: 1;\n }\n`\n"]}
|
package/demo/md/list/list.ts
CHANGED
|
@@ -157,6 +157,38 @@ class ComponentDemoPage extends DemoPage {
|
|
|
157
157
|
></ui-checkbox>
|
|
158
158
|
</ui-list-item>
|
|
159
159
|
</div>
|
|
160
|
+
|
|
161
|
+
<h2 class="title-large">Static (no interaction)</h2>
|
|
162
|
+
|
|
163
|
+
<div class="demo-row">
|
|
164
|
+
<ui-list-item static>Single list item</ui-list-item>
|
|
165
|
+
<ui-list-item static>
|
|
166
|
+
<span slot="start">${chatIcon}</span>
|
|
167
|
+
Single list item with an icon
|
|
168
|
+
</ui-list-item>
|
|
169
|
+
<ui-list-item image="avatar" static>
|
|
170
|
+
<span slot="start" class="avatar">PUP</span>
|
|
171
|
+
Pawel Uchida-Psztyc
|
|
172
|
+
<ui-checkbox slot="end" @pointerdown="${EventUtils.cancelEvent}"></ui-checkbox>
|
|
173
|
+
</ui-list-item>
|
|
174
|
+
<ui-list-item image="image" static>
|
|
175
|
+
<img src="../chip/pawel6c9a.jpg" alt="Avatar" slot="start" />
|
|
176
|
+
<p slot="end-text">100+</p>
|
|
177
|
+
Image element
|
|
178
|
+
</ui-list-item>
|
|
179
|
+
|
|
180
|
+
<ui-list-item image="video" static>
|
|
181
|
+
<span slot="start" class="video-image">
|
|
182
|
+
<img src="../chip/pawel6c9a.jpg" alt="video" />
|
|
183
|
+
</span>
|
|
184
|
+
Video image element
|
|
185
|
+
<ui-checkbox
|
|
186
|
+
slot="end"
|
|
187
|
+
@click="${EventUtils.cancelEvent}"
|
|
188
|
+
@pointerdown="${EventUtils.cancelEvent}"
|
|
189
|
+
></ui-checkbox>
|
|
190
|
+
</ui-list-item>
|
|
191
|
+
</div>
|
|
160
192
|
</section>
|
|
161
193
|
`
|
|
162
194
|
}
|
package/package.json
CHANGED
|
@@ -18,6 +18,10 @@ export interface ActionButtonInit {
|
|
|
18
18
|
* Whether the button is disabled.
|
|
19
19
|
*/
|
|
20
20
|
disabled?: boolean
|
|
21
|
+
/**
|
|
22
|
+
* Optional callback to be called when the button is clicked.
|
|
23
|
+
*/
|
|
24
|
+
callback?: (e: MouseEvent) => void
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
/**
|
|
@@ -139,7 +143,9 @@ export abstract class ModalActivity extends Activity {
|
|
|
139
143
|
*/
|
|
140
144
|
protected renderNegativeButton(init: ActionButtonInit = {}): TemplateResult {
|
|
141
145
|
const { label = 'Cancel' } = init
|
|
142
|
-
return html`<ui-text-button slot="button" type="button" value="dismiss"
|
|
146
|
+
return html`<ui-text-button slot="button" type="button" value="dismiss" @click="${init.callback}"
|
|
147
|
+
>${label}</ui-text-button
|
|
148
|
+
>`
|
|
143
149
|
}
|
|
144
150
|
|
|
145
151
|
/**
|
|
@@ -159,6 +165,7 @@ export abstract class ModalActivity extends Activity {
|
|
|
159
165
|
type="${type}"
|
|
160
166
|
value="confirm"
|
|
161
167
|
form="${ifDefined(formId)}"
|
|
168
|
+
@click="${init.callback}"
|
|
162
169
|
>${label}</ui-text-button
|
|
163
170
|
>`
|
|
164
171
|
}
|
package/src/lib/disabled.ts
CHANGED
|
@@ -31,8 +31,8 @@ export function setDisabled(target: HTMLElement, disabled: boolean | undefined):
|
|
|
31
31
|
state.tabindexBeforeDisabled = target.getAttribute('tabindex') || '0'
|
|
32
32
|
target.removeAttribute('tabindex')
|
|
33
33
|
target.setAttribute('aria-disabled', 'true')
|
|
34
|
-
} else {
|
|
35
|
-
target.setAttribute('tabindex', state.tabindexBeforeDisabled
|
|
34
|
+
} else if (state.tabindexBeforeDisabled) {
|
|
35
|
+
target.setAttribute('tabindex', state.tabindexBeforeDisabled)
|
|
36
36
|
delete state.tabindexBeforeDisabled
|
|
37
37
|
target.removeAttribute('aria-disabled')
|
|
38
38
|
}
|
|
@@ -110,7 +110,16 @@ export default css`
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
:host([lines='three']) .supporting-text {
|
|
113
|
-
height: calc(
|
|
113
|
+
height: calc(2 * var(--md-sys-typescale-body-medium-height, 1.1));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
:host([lines='three']) .supporting-text ::slotted(*) {
|
|
117
|
+
display: -webkit-box;
|
|
118
|
+
-webkit-box-orient: vertical;
|
|
119
|
+
-webkit-line-clamp: 2;
|
|
120
|
+
line-clamp: 2;
|
|
121
|
+
overflow: hidden;
|
|
122
|
+
text-overflow: ellipsis;
|
|
114
123
|
}
|
|
115
124
|
|
|
116
125
|
:host([lines='two']) .supporting-text ::slotted(*) {
|
|
@@ -182,4 +191,12 @@ export default css`
|
|
|
182
191
|
inset: 0;
|
|
183
192
|
z-index: 1;
|
|
184
193
|
}
|
|
194
|
+
|
|
195
|
+
:host([static]:hover) .state {
|
|
196
|
+
background-color: var(--md-sys-color-on-surface);
|
|
197
|
+
opacity: var(--md-sys-state-hover-state-layer-opacity);
|
|
198
|
+
position: absolute;
|
|
199
|
+
inset: 0;
|
|
200
|
+
z-index: 1;
|
|
201
|
+
}
|
|
185
202
|
`
|
|
@@ -52,6 +52,14 @@ export default class UiListItem extends UiElement {
|
|
|
52
52
|
*/
|
|
53
53
|
@property({ type: String, reflect: true }) accessor image: ListItemImage
|
|
54
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Whether the list item is static and should not be focusable.
|
|
57
|
+
* The ripple effect will not be applied when `true`.
|
|
58
|
+
* @default false
|
|
59
|
+
* @attribute
|
|
60
|
+
*/
|
|
61
|
+
@property({ type: Boolean, reflect: true }) accessor static = false
|
|
62
|
+
|
|
55
63
|
constructor() {
|
|
56
64
|
super()
|
|
57
65
|
|
|
@@ -173,8 +181,8 @@ export default class UiListItem extends UiElement {
|
|
|
173
181
|
}
|
|
174
182
|
|
|
175
183
|
protected renderRipple = (): TemplateResult => {
|
|
176
|
-
const { disabled } = this
|
|
177
|
-
return html`<ui-ripple class="ripple" ?disabled="${disabled}"></ui-ripple>`
|
|
184
|
+
const { disabled, static: isStatic } = this
|
|
185
|
+
return html`<ui-ripple class="ripple" ?disabled="${disabled || isStatic}"></ui-ripple>`
|
|
178
186
|
}
|
|
179
187
|
|
|
180
188
|
protected renderStart(): TemplateResult {
|