@api-client/ui 0.3.3 → 0.3.4
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/md/button/internals/base.d.ts.map +1 -1
- package/build/src/md/button/internals/base.js +2 -6
- package/build/src/md/button/internals/base.js.map +1 -1
- package/build/src/md/chip/internals/Chip.d.ts +11 -15
- package/build/src/md/chip/internals/Chip.d.ts.map +1 -1
- package/build/src/md/chip/internals/Chip.js +66 -104
- package/build/src/md/chip/internals/Chip.js.map +1 -1
- package/build/src/md/chip/internals/Chip.styles.d.ts.map +1 -1
- package/build/src/md/chip/internals/Chip.styles.js +114 -101
- package/build/src/md/chip/internals/Chip.styles.js.map +1 -1
- package/build/src/md/chip/internals/ChipSet.d.ts +16 -0
- package/build/src/md/chip/internals/ChipSet.d.ts.map +1 -0
- package/build/src/md/chip/internals/ChipSet.js +138 -0
- package/build/src/md/chip/internals/ChipSet.js.map +1 -0
- package/build/src/md/chip/internals/ChipSet.styles.d.ts +3 -0
- package/build/src/md/chip/internals/ChipSet.styles.d.ts.map +1 -0
- package/build/src/md/chip/internals/ChipSet.styles.js +9 -0
- package/build/src/md/chip/internals/ChipSet.styles.js.map +1 -0
- package/build/src/md/chip/ui-chip-set.d.ts +11 -0
- package/build/src/md/chip/ui-chip-set.d.ts.map +1 -0
- package/build/src/md/chip/ui-chip-set.js +27 -0
- package/build/src/md/chip/ui-chip-set.js.map +1 -0
- package/build/src/md/switch/internals/Switch.styles.js +1 -1
- package/build/src/md/switch/internals/Switch.styles.js.map +1 -1
- package/demo/md/chip/chip.html +33 -6
- package/demo/md/chip/chip.ts +111 -56
- package/package.json +1 -1
- package/src/md/button/internals/base.ts +2 -6
- package/src/md/chip/internals/Chip.styles.ts +114 -101
- package/src/md/chip/internals/Chip.ts +58 -88
- package/src/md/chip/internals/ChipSet.styles.ts +9 -0
- package/src/md/chip/internals/ChipSet.ts +142 -0
- package/src/md/chip/ui-chip-set.ts +15 -0
- package/src/md/switch/internals/Switch.styles.ts +1 -1
- package/test/ui/chip/UiChip.test.ts +18 -67
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../../src/md/button/internals/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,KAAK,CAAA;AAE7E,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAA;AAEhG,OAAO,KAAK,QAAQ,MAAM,kCAAkC,CAAA;AAE5D,OAAO,2BAA2B,CAAA;AAClC,OAAO,sCAAsC,CAAA;AAE7C,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAA;AACtD,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,QAAQ,CAAA;AAC9C,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,CAAA;AAExD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,SAAS;;IAC/C,MAAM,CAAC,QAAQ,CAAC,cAAc,QAAO;IAIrC;;;OAGG;IACH,IAAI,IAAI,IAAI,eAAe,GAAG,IAAI,GAAG,MAAM,CAE1C;IAED,IAAI,QAAQ,kBAEX;IAED,IAAI,iBAAiB,WAEpB;IAED,IAAI,YAAY,YAEf;IAED;;;OAGG;IACyB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAA;IAI7D,IAAI,KAAK,IAAI,MAAM,GAAG,SAAS,CAE9B;IAED;;;OAGG;IACH,IACI,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAMlC;IAED;;;OAGG;IACoE,QAAQ,CAAC,YAAY,UAAQ;IAEpG;;;OAGG;IACwC,QAAQ,CAAC,IAAI,EAAE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,IAAI;IAiB1D,SAAS,CAAC,kBAAkB,IAAI,IAAI;IASpC,aAAa;IAIb,cAAc;cAIK,YAAY,IAAI,IAAI;IAI9B,UAAU,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI;IAM3C,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI;IAgBtC,WAAW,CAAC,CAAC,EAAE,UAAU,GAAG,IAAI;IAqBzC,SAAS,CAAC,YAAY,IAAI,IAAI;IA6BrB,kBAAkB,CAAC,CAAC,EAAE,YAAY,GAAG,IAAI;IAKzC,kBAAkB,CAAC,CAAC,EAAE,YAAY,GAAG,IAAI;cAK/B,MAAM,IAAI,cAAc;IAW3C,SAAS,CAAC,UAAU,IAAI,cAAc;IAItC,SAAS,CAAC,eAAe,IAAI,cAAc;IAI3C,SAAS,CAAC,YAAY,IAAI,cAAc;CAGzC"}
|
|
@@ -308,15 +308,11 @@ let BaseButton = (() => {
|
|
|
308
308
|
}
|
|
309
309
|
handlePointerEnter(e) {
|
|
310
310
|
super.handlePointerEnter(e);
|
|
311
|
-
|
|
312
|
-
this.ripple.beginHover(e);
|
|
313
|
-
}
|
|
311
|
+
this.ripple?.beginHover(e);
|
|
314
312
|
}
|
|
315
313
|
handlePointerLeave(e) {
|
|
316
314
|
super.handlePointerLeave(e);
|
|
317
|
-
|
|
318
|
-
this.ripple.endHover();
|
|
319
|
-
}
|
|
315
|
+
this.ripple?.endHover();
|
|
320
316
|
}
|
|
321
317
|
render() {
|
|
322
318
|
const { trailingIcon = false } = this;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../../src/md/button/internals/base.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAA4C,MAAM,KAAK,CAAA;AAC7E,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAE9C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,MAAM,EAAE,CAAC;gBAChB,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAA;YACxB,CAAC;QACH,CAAC;QAEkB,MAAM;YACvB,MAAM,EAAE,YAAY,GAAG,KAAK,EAAE,GAAG,IAAI,CAAA;YACrC,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,EAAE,CAAA;YAE9B,OAAO,IAAI,CAAA;QACP,IAAI,CAAC,eAAe,EAAE,IAAI,IAAI,CAAC,YAAY,EAAE,IAAI,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI;;QAE9E,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO;KAChC,CAAA;QACH,CAAC;QAES,UAAU;YAClB,OAAO,IAAI,CAAA,2BAA2B,CAAA;QACxC,CAAC;QAES,eAAe;YACvB,OAAO,IAAI,CAAA,iEAAiE,IAAmB,oBAAoB,CAAA;QACrH,CAAC;QAES,YAAY;YACpB,OAAO,IAAI,CAAA,wCAAwC,IAAI,CAAC,QAAQ,gBAAgB,CAAA;QAClF,CAAC;;;AA3RH;;;;;;;;;;GAUG;AACH","sourcesContent":["import { html, nothing, type PropertyValues, type TemplateResult } from 'lit'\nimport { property, query } from 'lit/decorators.js'\nimport { UiElement } from '../../UiElement.js'\nimport type { BeginPressConfig, EndPressConfig } from '../../../controllers/ActionController.js'\nimport { isDisabled, setDisabled } from '../../../lib/disabled.js'\nimport type UiRipple from '../../ripple/internals/ripple.js'\n\nimport '../../ripple/ui-ripple.js'\nimport '@material/web/focus/md-focus-ring.js'\n\nexport type ButtonType = 'submit' | 'reset' | 'button'\nexport type MdButtonShape = 'round' | 'square'\nexport type MdButtonSize = 'xs' | 's' | 'm' | 'l' | 'xl'\n\n/**\n * A material design button with M3 Expressive features - CSS-native implementation.\n *\n * @slot icon - A slot for the icon element\n * @slot - The default slot for the label\n * @attribute {string} form - The form associated with this element when the element is outside the form.\n * @fires {ToggleEvent} toggle - Fired when the `toggle` property is true and the button is clicked,\n * changing its selection state.\n * The event's `newState` and `oldState` properties (string values: 'selected' or\n * 'unselected') detail this selection change.\n */\nexport default class BaseButton extends UiElement {\n static readonly formAssociated = true\n\n #internals = this.attachInternals()\n\n /**\n * The form associated with this element\n * @attribute\n */\n get form(): HTMLFormElement | null | string {\n return this.#internals.form\n }\n\n get validity() {\n return this.#internals.validity\n }\n\n get validationMessage() {\n return this.#internals.validationMessage\n }\n\n get willValidate() {\n return this.#internals.willValidate\n }\n\n /**\n * The name of the button, submitted as a pair with the button's value as part of the form data.\n * @attribute\n */\n @property({ type: String }) accessor name: string | undefined\n\n #value?: string\n\n get value(): string | undefined {\n return this.#value\n }\n\n /**\n * Defines the value associated with the button's name when it's submitted with the form data.\n * @attribute\n */\n @property({ type: String })\n set value(value: string | undefined) {\n if (this.#value === value) {\n return\n }\n this.#value = value\n this.#internals?.setFormValue(value || null)\n }\n\n /**\n * Whether to render the icon at the inline end of the label rather than the inline start.\n * @attribute\n */\n @property({ type: Boolean, attribute: 'trailingicon', reflect: true }) accessor trailingIcon = false\n\n /**\n * The default behavior of the button.\n * @attribute\n */\n @property({ type: String, reflect: true }) accessor type: ButtonType = 'button'\n\n /**\n * When set, the button is a toggle button.\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) accessor toggle = false\n\n /**\n * Indicates that the button is currently selected.\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) accessor selected = false\n\n /**\n * The shape of the button.\n * @attribute\n */\n @property({ type: String, reflect: true }) accessor shape: MdButtonShape = 'round'\n\n /**\n * The size of the button.\n * @attribute\n */\n @property({ type: String, reflect: true }) accessor size: MdButtonSize = 's'\n\n get disabled(): boolean {\n return isDisabled(this)\n }\n\n /**\n * When set, the button is in a disabled state.\n * @attribute\n */\n @property({ reflect: true, type: Boolean })\n set disabled(value: boolean) {\n const old = isDisabled(this)\n setDisabled(this, value)\n this.requestUpdate('disabled', old)\n }\n\n @query('ui-ripple') protected accessor ripple!: UiRipple | null\n\n constructor() {\n super()\n this.actionController.cancelKeyboardEvents = true\n this.addEventListener('keydown', this.handleKeyDown.bind(this))\n this.addEventListener('keyup', this.handleKeyUp.bind(this))\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('pointerenter', this.handlePointerEnter.bind(this))\n this.addEventListener('contextmenu', this.handleContextMenu.bind(this))\n }\n\n override connectedCallback(): void {\n super.connectedCallback()\n if (!this.hasAttribute('role')) {\n this.setAttribute('role', 'button')\n }\n if (!this.hasAttribute('tabindex') && !this.disabled) {\n this.setAttribute('tabindex', '0')\n }\n }\n\n protected override updated(cp: PropertyValues<this>): void {\n super.updated(cp)\n\n // If the button is disabled, remove the tabindex attribute\n if (cp.has('disabled')) {\n if (this.disabled) {\n this.removeAttribute('tabindex')\n } else if (!this.hasAttribute('tabindex')) {\n this.setAttribute('tabindex', '0')\n }\n }\n\n if (cp.has('toggle') || cp.has('selected')) {\n this.updatePressedState()\n }\n }\n\n protected updatePressedState(): void {\n if (this.toggle) {\n this.ariaPressed = String(this.selected)\n } else {\n this.selected = false\n this.removeAttribute('aria-pressed')\n }\n }\n\n checkValidity() {\n return this.#internals.checkValidity()\n }\n\n reportValidity() {\n return this.#internals.reportValidity()\n }\n\n protected override firstUpdated(): void {\n this.#internals?.setFormValue(this.value || null)\n }\n\n override beginPress(options: BeginPressConfig): void {\n super.beginPress(options)\n this.classList.add('pressed')\n this.ripple?.beginFocus()\n }\n\n override endPress(config: EndPressConfig): void {\n super.endPress(config)\n this.classList.remove('pressed')\n this.ripple?.endFocus()\n const { cancelled, reason } = config\n if (cancelled) {\n return\n }\n const allowedReasons = reason === 'enter' || reason === 'space'\n if (this.type === 'submit' && (!reason || allowedReasons)) {\n this.handleSubmit()\n } else if (allowedReasons) {\n this.click()\n }\n }\n\n override handleClick(e: MouseEvent): void {\n super.handleClick(e)\n if (this.disabled) {\n e.preventDefault()\n e.stopPropagation()\n return\n }\n\n if (this.toggle) {\n this.selected = !this.selected\n const e = new ToggleEvent('toggle', {\n bubbles: true,\n composed: true,\n newState: this.selected ? 'selected' : 'unselected',\n oldState: this.selected ? 'unselected' : 'selected',\n })\n this.dispatchEvent(e)\n }\n this.endPress({ cancelled: false, actionData: { event: e } })\n }\n\n protected handleSubmit(): void {\n const { name, value, type, disabled, form } = this\n if (!form || !type || disabled) {\n return\n }\n const typedForm = form as HTMLFormElement\n let button: HTMLButtonElement | undefined\n if (name || value) {\n button = document.createElement('button')\n if (name) {\n button.name = name\n }\n if (value) {\n button.value = value\n }\n button.type = type\n button.hidden = true\n typedForm.append(button)\n }\n try {\n typedForm.requestSubmit(button)\n } catch {\n // Ignore errors\n }\n if (button) {\n typedForm.removeChild(button)\n }\n }\n\n override handlePointerEnter(e: PointerEvent): void {\n super.handlePointerEnter(e)\n if (this.ripple) {\n this.ripple.beginHover(e)\n }\n }\n\n override handlePointerLeave(e: PointerEvent): void {\n super.handlePointerLeave(e)\n if (this.ripple) {\n this.ripple.endHover()\n }\n }\n\n protected override render(): TemplateResult {\n const { trailingIcon = false } = this\n const icon = this.renderIcon()\n\n return html`\n ${this.renderFocusRing()} ${this.renderRipple()} ${trailingIcon ? nothing : icon}\n <slot></slot>\n ${trailingIcon ? icon : nothing}\n `\n }\n\n protected renderIcon(): TemplateResult {\n return html`<slot name=\"icon\"></slot>`\n }\n\n protected renderFocusRing(): TemplateResult {\n return html`<md-focus-ring part=\"focus-ring\" class=\"focus-ring\" .control=\"${this as HTMLElement}\"></md-focus-ring>`\n }\n\n protected renderRipple(): TemplateResult {\n return html`<ui-ripple class=\"ripple\" ?disabled=\"${this.disabled}\"></ui-ripple>`\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../../src/md/button/internals/base.ts"],"names":[],"mappings":";AAA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AC,CAAA;QAC5B,CAAC;QAEQ,kBAAkB,CAAC,CAAe;YACzC,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAA;YAC3B,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAA;QACzB,CAAC;QAEkB,MAAM;YACvB,MAAM,EAAE,YAAY,GAAG,KAAK,EAAE,GAAG,IAAI,CAAA;YACrC,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,EAAE,CAAA;YAE9B,OAAO,IAAI,CAAA;QACP,IAAI,CAAC,eAAe,EAAE,IAAI,IAAI,CAAC,YAAY,EAAE,IAAI,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI;;QAE9E,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO;KAChC,CAAA;QACH,CAAC;QAES,UAAU;YAClB,OAAO,IAAI,CAAA,2BAA2B,CAAA;QACxC,CAAC;QAES,eAAe;YACvB,OAAO,IAAI,CAAA,iEAAiE,IAAmB,oBAAoB,CAAA;QACrH,CAAC;QAES,YAAY;YACpB,OAAO,IAAI,CAAA,wCAAwC,IAAI,CAAC,QAAQ,gBAAgB,CAAA;QAClF,CAAC;;;AAvRH;;;;;;;;;;GAUG;AACH","sourcesContent":["import { html, nothing, type PropertyValues, type TemplateResult } from 'lit'\nimport { property, query } from 'lit/decorators.js'\nimport { UiElement } from '../../UiElement.js'\nimport type { BeginPressConfig, EndPressConfig } from '../../../controllers/ActionController.js'\nimport { isDisabled, setDisabled } from '../../../lib/disabled.js'\nimport type UiRipple from '../../ripple/internals/ripple.js'\n\nimport '../../ripple/ui-ripple.js'\nimport '@material/web/focus/md-focus-ring.js'\n\nexport type ButtonType = 'submit' | 'reset' | 'button'\nexport type MdButtonShape = 'round' | 'square'\nexport type MdButtonSize = 'xs' | 's' | 'm' | 'l' | 'xl'\n\n/**\n * A material design button with M3 Expressive features - CSS-native implementation.\n *\n * @slot icon - A slot for the icon element\n * @slot - The default slot for the label\n * @attribute {string} form - The form associated with this element when the element is outside the form.\n * @fires {ToggleEvent} toggle - Fired when the `toggle` property is true and the button is clicked,\n * changing its selection state.\n * The event's `newState` and `oldState` properties (string values: 'selected' or\n * 'unselected') detail this selection change.\n */\nexport default class BaseButton extends UiElement {\n static readonly formAssociated = true\n\n #internals = this.attachInternals()\n\n /**\n * The form associated with this element\n * @attribute\n */\n get form(): HTMLFormElement | null | string {\n return this.#internals.form\n }\n\n get validity() {\n return this.#internals.validity\n }\n\n get validationMessage() {\n return this.#internals.validationMessage\n }\n\n get willValidate() {\n return this.#internals.willValidate\n }\n\n /**\n * The name of the button, submitted as a pair with the button's value as part of the form data.\n * @attribute\n */\n @property({ type: String }) accessor name: string | undefined\n\n #value?: string\n\n get value(): string | undefined {\n return this.#value\n }\n\n /**\n * Defines the value associated with the button's name when it's submitted with the form data.\n * @attribute\n */\n @property({ type: String })\n set value(value: string | undefined) {\n if (this.#value === value) {\n return\n }\n this.#value = value\n this.#internals?.setFormValue(value || null)\n }\n\n /**\n * Whether to render the icon at the inline end of the label rather than the inline start.\n * @attribute\n */\n @property({ type: Boolean, attribute: 'trailingicon', reflect: true }) accessor trailingIcon = false\n\n /**\n * The default behavior of the button.\n * @attribute\n */\n @property({ type: String, reflect: true }) accessor type: ButtonType = 'button'\n\n /**\n * When set, the button is a toggle button.\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) accessor toggle = false\n\n /**\n * Indicates that the button is currently selected.\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) accessor selected = false\n\n /**\n * The shape of the button.\n * @attribute\n */\n @property({ type: String, reflect: true }) accessor shape: MdButtonShape = 'round'\n\n /**\n * The size of the button.\n * @attribute\n */\n @property({ type: String, reflect: true }) accessor size: MdButtonSize = 's'\n\n get disabled(): boolean {\n return isDisabled(this)\n }\n\n /**\n * When set, the button is in a disabled state.\n * @attribute\n */\n @property({ reflect: true, type: Boolean })\n set disabled(value: boolean) {\n const old = isDisabled(this)\n setDisabled(this, value)\n this.requestUpdate('disabled', old)\n }\n\n @query('ui-ripple') protected accessor ripple!: UiRipple | null\n\n constructor() {\n super()\n this.actionController.cancelKeyboardEvents = true\n this.addEventListener('keydown', this.handleKeyDown.bind(this))\n this.addEventListener('keyup', this.handleKeyUp.bind(this))\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('pointerenter', this.handlePointerEnter.bind(this))\n this.addEventListener('contextmenu', this.handleContextMenu.bind(this))\n }\n\n override connectedCallback(): void {\n super.connectedCallback()\n if (!this.hasAttribute('role')) {\n this.setAttribute('role', 'button')\n }\n if (!this.hasAttribute('tabindex') && !this.disabled) {\n this.setAttribute('tabindex', '0')\n }\n }\n\n protected override updated(cp: PropertyValues<this>): void {\n super.updated(cp)\n\n // If the button is disabled, remove the tabindex attribute\n if (cp.has('disabled')) {\n if (this.disabled) {\n this.removeAttribute('tabindex')\n } else if (!this.hasAttribute('tabindex')) {\n this.setAttribute('tabindex', '0')\n }\n }\n\n if (cp.has('toggle') || cp.has('selected')) {\n this.updatePressedState()\n }\n }\n\n protected updatePressedState(): void {\n if (this.toggle) {\n this.ariaPressed = String(this.selected)\n } else {\n this.selected = false\n this.removeAttribute('aria-pressed')\n }\n }\n\n checkValidity() {\n return this.#internals.checkValidity()\n }\n\n reportValidity() {\n return this.#internals.reportValidity()\n }\n\n protected override firstUpdated(): void {\n this.#internals?.setFormValue(this.value || null)\n }\n\n override beginPress(options: BeginPressConfig): void {\n super.beginPress(options)\n this.classList.add('pressed')\n this.ripple?.beginFocus()\n }\n\n override endPress(config: EndPressConfig): void {\n super.endPress(config)\n this.classList.remove('pressed')\n this.ripple?.endFocus()\n const { cancelled, reason } = config\n if (cancelled) {\n return\n }\n const allowedReasons = reason === 'enter' || reason === 'space'\n if (this.type === 'submit' && (!reason || allowedReasons)) {\n this.handleSubmit()\n } else if (allowedReasons) {\n this.click()\n }\n }\n\n override handleClick(e: MouseEvent): void {\n super.handleClick(e)\n if (this.disabled) {\n e.preventDefault()\n e.stopPropagation()\n return\n }\n\n if (this.toggle) {\n this.selected = !this.selected\n const e = new ToggleEvent('toggle', {\n bubbles: true,\n composed: true,\n newState: this.selected ? 'selected' : 'unselected',\n oldState: this.selected ? 'unselected' : 'selected',\n })\n this.dispatchEvent(e)\n }\n this.endPress({ cancelled: false, actionData: { event: e } })\n }\n\n protected handleSubmit(): void {\n const { name, value, type, disabled, form } = this\n if (!form || !type || disabled) {\n return\n }\n const typedForm = form as HTMLFormElement\n let button: HTMLButtonElement | undefined\n if (name || value) {\n button = document.createElement('button')\n if (name) {\n button.name = name\n }\n if (value) {\n button.value = value\n }\n button.type = type\n button.hidden = true\n typedForm.append(button)\n }\n try {\n typedForm.requestSubmit(button)\n } catch {\n // Ignore errors\n }\n if (button) {\n typedForm.removeChild(button)\n }\n }\n\n override handlePointerEnter(e: PointerEvent): void {\n super.handlePointerEnter(e)\n this.ripple?.beginHover(e)\n }\n\n override handlePointerLeave(e: PointerEvent): void {\n super.handlePointerLeave(e)\n this.ripple?.endHover()\n }\n\n protected override render(): TemplateResult {\n const { trailingIcon = false } = this\n const icon = this.renderIcon()\n\n return html`\n ${this.renderFocusRing()} ${this.renderRipple()} ${trailingIcon ? nothing : icon}\n <slot></slot>\n ${trailingIcon ? icon : nothing}\n `\n }\n\n protected renderIcon(): TemplateResult {\n return html`<slot name=\"icon\"></slot>`\n }\n\n protected renderFocusRing(): TemplateResult {\n return html`<md-focus-ring part=\"focus-ring\" class=\"focus-ring\" .control=\"${this as HTMLElement}\"></md-focus-ring>`\n }\n\n protected renderRipple(): TemplateResult {\n return html`<ui-ripple class=\"ripple\" ?disabled=\"${this.disabled}\"></ui-ripple>`\n }\n}\n"]}
|
|
@@ -13,9 +13,9 @@ export declare enum ChipType {
|
|
|
13
13
|
* @slot The content of the chip.
|
|
14
14
|
* @slot icon - The leading icon, sized 18x18 px
|
|
15
15
|
* @slot avatar - The leading image, sized 24x24 px
|
|
16
|
-
* @fires list - When the user requested to activate the list associated with the element.
|
|
17
16
|
* @fires select - When the checked state changed through a user interaction. This only related to
|
|
18
17
|
* `filter` chips. Note, `select` is dispatched just before the `click` event.
|
|
18
|
+
* @fires remove - When the user clicks the "remove" icon on the chip.
|
|
19
19
|
*/
|
|
20
20
|
export default class UiChip extends UiElement {
|
|
21
21
|
/**
|
|
@@ -39,7 +39,7 @@ export default class UiChip extends UiElement {
|
|
|
39
39
|
* Whether the chip renders the "close" icon at the end.
|
|
40
40
|
* @attribute
|
|
41
41
|
*/
|
|
42
|
-
accessor
|
|
42
|
+
accessor removable: boolean | undefined;
|
|
43
43
|
/**
|
|
44
44
|
* Whether the chip is currently checked.
|
|
45
45
|
* Note, this controls the presentation layer only. It has no meaning when it comes to forms and inputs.
|
|
@@ -47,15 +47,13 @@ export default class UiChip extends UiElement {
|
|
|
47
47
|
*/
|
|
48
48
|
accessor checked: boolean | undefined;
|
|
49
49
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* attributes informing the assistive technology that this chip controls a list.
|
|
50
|
+
* When set, the chip will render a trailing icon that indicates that the chip is associated
|
|
51
|
+
* with a list. It does not do anything.
|
|
53
52
|
*
|
|
54
53
|
* @attribute
|
|
55
54
|
*/
|
|
56
|
-
accessor list:
|
|
57
|
-
protected accessor ripple:
|
|
58
|
-
protected accessor showRipple: boolean;
|
|
55
|
+
accessor list: boolean | undefined;
|
|
56
|
+
protected accessor ripple: UiRipple | null;
|
|
59
57
|
/**
|
|
60
58
|
* Determines when the element has an icon in the "icon" slot.
|
|
61
59
|
*/
|
|
@@ -67,15 +65,14 @@ export default class UiChip extends UiElement {
|
|
|
67
65
|
constructor();
|
|
68
66
|
connectedCallback(): void;
|
|
69
67
|
protected willUpdate(cp: PropertyValues<this>): void;
|
|
70
|
-
protected pressRipple(): Promise<void>;
|
|
71
|
-
protected endRipple(): Promise<void>;
|
|
72
68
|
beginPress(options: BeginPressConfig): void;
|
|
73
69
|
handleKeyDown(e: KeyboardEvent): Promise<void>;
|
|
74
70
|
protected handleFocus(): Promise<void>;
|
|
75
71
|
protected handleBlur(): Promise<void>;
|
|
76
|
-
protected readonly getRipple: () => Promise<UiRipple | null>;
|
|
77
72
|
endPress(info: EndPressConfig): void;
|
|
78
73
|
handleClick(e: MouseEvent): void;
|
|
74
|
+
handlePointerEnter(e: PointerEvent): void;
|
|
75
|
+
handlePointerLeave(e: PointerEvent): void;
|
|
79
76
|
/**
|
|
80
77
|
* Toggles the "filter" type of the chip.
|
|
81
78
|
*/
|
|
@@ -88,14 +85,13 @@ export default class UiChip extends UiElement {
|
|
|
88
85
|
* Sets the `_hasAvatar` state property when the "avatar" slot change event is dispatched.
|
|
89
86
|
*/
|
|
90
87
|
protected handleAvatarSlotChange(e: Event): void;
|
|
91
|
-
protected handleListClick(e: Event): void;
|
|
92
88
|
protected handleClose(e: Event): void;
|
|
93
|
-
protected
|
|
94
|
-
protected listAction(): Promise<void>;
|
|
89
|
+
protected removeAction(): Promise<void>;
|
|
95
90
|
protected render(): TemplateResult;
|
|
91
|
+
protected renderRipple(): TemplateResult;
|
|
96
92
|
protected renderLeadingIcon(): TemplateResult | typeof nothing;
|
|
97
93
|
protected renderAvatar(): TemplateResult | typeof nothing;
|
|
98
94
|
protected renderTrailingIcon(): TemplateResult | typeof nothing;
|
|
99
|
-
|
|
95
|
+
get hasTrailingIcon(): boolean;
|
|
100
96
|
}
|
|
101
97
|
//# sourceMappingURL=Chip.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chip.d.ts","sourceRoot":"","sources":["../../../../../src/md/chip/internals/Chip.ts"],"names":[],"mappings":"AACA,OAAO,EAAQ,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"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GAAG,IAAI;IAMrC,aAAa,CAAC,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;cAQ7C,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;cAI5B,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAIlC,QAAQ,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI;IAapC,WAAW,CAAC,CAAC,EAAE,UAAU,GAAG,IAAI;IAOhC,kBAAkB,CAAC,CAAC,EAAE,YAAY,GAAG,IAAI;IAKzC,kBAAkB,CAAC,CAAC,EAAE,YAAY,GAAG,IAAI;IAKlD;;OAEG;IACH,aAAa,IAAI,IAAI;IAKrB;;OAEG;IACH,SAAS,CAAC,oBAAoB,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI;IAK9C;;OAEG;IACH,SAAS,CAAC,sBAAsB,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI;IAKhD,SAAS,CAAC,WAAW,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI;cAMrB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;cAI1B,MAAM,IAAI,cAAc;IAiB3C,SAAS,CAAC,YAAY,IAAI,cAAc;IAIxC,SAAS,CAAC,iBAAiB,IAAI,cAAc,GAAG,OAAO,OAAO;IAgB9D,SAAS,CAAC,YAAY,IAAI,cAAc,GAAG,OAAO,OAAO;IAIzD,SAAS,CAAC,kBAAkB,IAAI,cAAc,GAAG,OAAO,OAAO;IAkB/D,IAAI,eAAe,IAAI,OAAO,CAS7B;CACF"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { __esDecorate, __runInitializers } from "tslib";
|
|
2
2
|
import { cancelEvent } from '@api-client/core/lib/events/Utils.js';
|
|
3
3
|
import { html, nothing } from 'lit';
|
|
4
|
-
import { property,
|
|
4
|
+
import { property, query, state } from 'lit/decorators.js';
|
|
5
5
|
import { classMap } from 'lit/directives/class-map.js';
|
|
6
|
-
import { when } from 'lit/directives/when.js';
|
|
7
6
|
import { UiElement } from '../../UiElement.js';
|
|
8
|
-
import { ripple } from '../../effects/rippleDirective.js';
|
|
9
7
|
import { close, arrowDropDown, check } from '../../icons/Icons.js';
|
|
10
8
|
import { setDisabled } from '../../../lib/disabled.js';
|
|
11
9
|
import '../../ripple/ui-ripple.js';
|
|
@@ -27,9 +25,9 @@ let UiChip = (() => {
|
|
|
27
25
|
let _elevated_decorators;
|
|
28
26
|
let _elevated_initializers = [];
|
|
29
27
|
let _elevated_extraInitializers = [];
|
|
30
|
-
let
|
|
31
|
-
let
|
|
32
|
-
let
|
|
28
|
+
let _removable_decorators;
|
|
29
|
+
let _removable_initializers = [];
|
|
30
|
+
let _removable_extraInitializers = [];
|
|
33
31
|
let _checked_decorators;
|
|
34
32
|
let _checked_initializers = [];
|
|
35
33
|
let _checked_extraInitializers = [];
|
|
@@ -39,9 +37,6 @@ let UiChip = (() => {
|
|
|
39
37
|
let _ripple_decorators;
|
|
40
38
|
let _ripple_initializers = [];
|
|
41
39
|
let _ripple_extraInitializers = [];
|
|
42
|
-
let _showRipple_decorators;
|
|
43
|
-
let _showRipple_initializers = [];
|
|
44
|
-
let _showRipple_extraInitializers = [];
|
|
45
40
|
let _hasIcon_decorators;
|
|
46
41
|
let _hasIcon_initializers = [];
|
|
47
42
|
let _hasIcon_extraInitializers = [];
|
|
@@ -54,21 +49,19 @@ let UiChip = (() => {
|
|
|
54
49
|
_disabled_decorators = [property({ type: Boolean, reflect: true })];
|
|
55
50
|
_type_decorators = [property({ type: String })];
|
|
56
51
|
_elevated_decorators = [property({ type: Boolean, reflect: true })];
|
|
57
|
-
|
|
52
|
+
_removable_decorators = [property({ type: Boolean, reflect: true })];
|
|
58
53
|
_checked_decorators = [property({ type: Boolean, reflect: true })];
|
|
59
|
-
_list_decorators = [property({ type:
|
|
60
|
-
_ripple_decorators = [
|
|
61
|
-
_showRipple_decorators = [state()];
|
|
54
|
+
_list_decorators = [property({ type: Boolean, reflect: true })];
|
|
55
|
+
_ripple_decorators = [query('ui-ripple')];
|
|
62
56
|
_hasIcon_decorators = [state()];
|
|
63
57
|
_hasAvatar_decorators = [state()];
|
|
64
58
|
__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);
|
|
65
59
|
__esDecorate(this, null, _type_decorators, { kind: "accessor", name: "type", static: false, private: false, access: { has: obj => "type" in obj, get: obj => obj.type, set: (obj, value) => { obj.type = value; } }, metadata: _metadata }, _type_initializers, _type_extraInitializers);
|
|
66
60
|
__esDecorate(this, null, _elevated_decorators, { kind: "accessor", name: "elevated", static: false, private: false, access: { has: obj => "elevated" in obj, get: obj => obj.elevated, set: (obj, value) => { obj.elevated = value; } }, metadata: _metadata }, _elevated_initializers, _elevated_extraInitializers);
|
|
67
|
-
__esDecorate(this, null,
|
|
61
|
+
__esDecorate(this, null, _removable_decorators, { kind: "accessor", name: "removable", static: false, private: false, access: { has: obj => "removable" in obj, get: obj => obj.removable, set: (obj, value) => { obj.removable = value; } }, metadata: _metadata }, _removable_initializers, _removable_extraInitializers);
|
|
68
62
|
__esDecorate(this, null, _checked_decorators, { kind: "accessor", name: "checked", static: false, private: false, access: { has: obj => "checked" in obj, get: obj => obj.checked, set: (obj, value) => { obj.checked = value; } }, metadata: _metadata }, _checked_initializers, _checked_extraInitializers);
|
|
69
63
|
__esDecorate(this, null, _list_decorators, { kind: "accessor", name: "list", static: false, private: false, access: { has: obj => "list" in obj, get: obj => obj.list, set: (obj, value) => { obj.list = value; } }, metadata: _metadata }, _list_initializers, _list_extraInitializers);
|
|
70
64
|
__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);
|
|
71
|
-
__esDecorate(this, null, _showRipple_decorators, { kind: "accessor", name: "showRipple", static: false, private: false, access: { has: obj => "showRipple" in obj, get: obj => obj.showRipple, set: (obj, value) => { obj.showRipple = value; } }, metadata: _metadata }, _showRipple_initializers, _showRipple_extraInitializers);
|
|
72
65
|
__esDecorate(this, null, _hasIcon_decorators, { kind: "accessor", name: "hasIcon", static: false, private: false, access: { has: obj => "hasIcon" in obj, get: obj => obj.hasIcon, set: (obj, value) => { obj.hasIcon = value; } }, metadata: _metadata }, _hasIcon_initializers, _hasIcon_extraInitializers);
|
|
73
66
|
__esDecorate(this, null, _hasAvatar_decorators, { kind: "accessor", name: "hasAvatar", static: false, private: false, access: { has: obj => "hasAvatar" in obj, get: obj => obj.hasAvatar, set: (obj, value) => { obj.hasAvatar = value; } }, metadata: _metadata }, _hasAvatar_initializers, _hasAvatar_extraInitializers);
|
|
74
67
|
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
@@ -103,14 +96,14 @@ let UiChip = (() => {
|
|
|
103
96
|
*/
|
|
104
97
|
get elevated() { return this.#elevated_accessor_storage; }
|
|
105
98
|
set elevated(value) { this.#elevated_accessor_storage = value; }
|
|
106
|
-
#
|
|
99
|
+
#removable_accessor_storage = (__runInitializers(this, _elevated_extraInitializers), __runInitializers(this, _removable_initializers, void 0));
|
|
107
100
|
/**
|
|
108
101
|
* Whether the chip renders the "close" icon at the end.
|
|
109
102
|
* @attribute
|
|
110
103
|
*/
|
|
111
|
-
get
|
|
112
|
-
set
|
|
113
|
-
#checked_accessor_storage = (__runInitializers(this,
|
|
104
|
+
get removable() { return this.#removable_accessor_storage; }
|
|
105
|
+
set removable(value) { this.#removable_accessor_storage = value; }
|
|
106
|
+
#checked_accessor_storage = (__runInitializers(this, _removable_extraInitializers), __runInitializers(this, _checked_initializers, void 0));
|
|
114
107
|
/**
|
|
115
108
|
* Whether the chip is currently checked.
|
|
116
109
|
* Note, this controls the presentation layer only. It has no meaning when it comes to forms and inputs.
|
|
@@ -120,9 +113,8 @@ let UiChip = (() => {
|
|
|
120
113
|
set checked(value) { this.#checked_accessor_storage = value; }
|
|
121
114
|
#list_accessor_storage = (__runInitializers(this, _checked_extraInitializers), __runInitializers(this, _list_initializers, void 0));
|
|
122
115
|
/**
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
* attributes informing the assistive technology that this chip controls a list.
|
|
116
|
+
* When set, the chip will render a trailing icon that indicates that the chip is associated
|
|
117
|
+
* with a list. It does not do anything.
|
|
126
118
|
*
|
|
127
119
|
* @attribute
|
|
128
120
|
*/
|
|
@@ -131,14 +123,7 @@ let UiChip = (() => {
|
|
|
131
123
|
#ripple_accessor_storage = (__runInitializers(this, _list_extraInitializers), __runInitializers(this, _ripple_initializers, void 0));
|
|
132
124
|
get ripple() { return this.#ripple_accessor_storage; }
|
|
133
125
|
set ripple(value) { this.#ripple_accessor_storage = value; }
|
|
134
|
-
#
|
|
135
|
-
/**
|
|
136
|
-
* Determines when the element has an icon in the "icon" slot.
|
|
137
|
-
*/
|
|
138
|
-
));
|
|
139
|
-
get showRipple() { return this.#showRipple_accessor_storage; }
|
|
140
|
-
set showRipple(value) { this.#showRipple_accessor_storage = value; }
|
|
141
|
-
#hasIcon_accessor_storage = (__runInitializers(this, _showRipple_extraInitializers), __runInitializers(this, _hasIcon_initializers, void 0));
|
|
126
|
+
#hasIcon_accessor_storage = (__runInitializers(this, _ripple_extraInitializers), __runInitializers(this, _hasIcon_initializers, void 0));
|
|
142
127
|
/**
|
|
143
128
|
* Determines when the element has an icon in the "icon" slot.
|
|
144
129
|
*/
|
|
@@ -152,18 +137,20 @@ let UiChip = (() => {
|
|
|
152
137
|
set hasAvatar(value) { this.#hasAvatar_accessor_storage = value; }
|
|
153
138
|
constructor() {
|
|
154
139
|
super();
|
|
140
|
+
__runInitializers(this, _hasAvatar_extraInitializers);
|
|
155
141
|
this.disabled = false;
|
|
156
142
|
this.type = ChipType.assist;
|
|
157
143
|
this.hasIcon = false;
|
|
158
144
|
this.hasAvatar = false;
|
|
159
145
|
this.actionController.cancelKeyboardEvents = true;
|
|
160
|
-
this.addEventListener('click', this.handleClick.bind(this));
|
|
161
146
|
this.addEventListener('keydown', this.handleKeyDown.bind(this));
|
|
162
147
|
this.addEventListener('keyup', this.handleKeyUp.bind(this));
|
|
148
|
+
this.addEventListener('click', this.handleClick.bind(this));
|
|
163
149
|
this.addEventListener('pointerdown', this.handlePointerDown.bind(this));
|
|
164
150
|
this.addEventListener('pointerup', this.handlePointerUp.bind(this));
|
|
165
151
|
this.addEventListener('pointercancel', this.handlePointerCancel.bind(this));
|
|
166
152
|
this.addEventListener('pointerleave', this.handlePointerLeave.bind(this));
|
|
153
|
+
this.addEventListener('pointerenter', this.handlePointerEnter.bind(this));
|
|
167
154
|
this.addEventListener('contextmenu', this.handleContextMenu.bind(this));
|
|
168
155
|
this.addEventListener('focus', this.handleFocus.bind(this));
|
|
169
156
|
this.addEventListener('blur', this.handleBlur.bind(this));
|
|
@@ -182,46 +169,28 @@ let UiChip = (() => {
|
|
|
182
169
|
setDisabled(this, cp.get('disabled'));
|
|
183
170
|
}
|
|
184
171
|
}
|
|
185
|
-
async pressRipple() {
|
|
186
|
-
const element = await this.getRipple();
|
|
187
|
-
if (element && !element.isPressed) {
|
|
188
|
-
element.beginPress();
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
async endRipple() {
|
|
192
|
-
const element = await this.getRipple();
|
|
193
|
-
element?.endPress();
|
|
194
|
-
}
|
|
195
172
|
beginPress(options) {
|
|
196
173
|
super.beginPress(options);
|
|
197
|
-
this.
|
|
174
|
+
this.classList.add('pressed');
|
|
175
|
+
this.ripple?.beginPress(options.positionEvent);
|
|
198
176
|
}
|
|
199
177
|
async handleKeyDown(e) {
|
|
200
178
|
super.handleKeyDown(e);
|
|
201
|
-
if (this.
|
|
202
|
-
e.preventDefault();
|
|
203
|
-
this.listAction();
|
|
204
|
-
}
|
|
205
|
-
else if (this.closable && e.code === 'Backspace') {
|
|
179
|
+
if (this.removable && e.code === 'Backspace') {
|
|
206
180
|
e.preventDefault();
|
|
207
|
-
this.
|
|
181
|
+
this.removeAction();
|
|
208
182
|
}
|
|
209
183
|
}
|
|
210
184
|
async handleFocus() {
|
|
211
|
-
|
|
212
|
-
element?.beginFocus();
|
|
185
|
+
this.ripple?.beginFocus();
|
|
213
186
|
}
|
|
214
187
|
async handleBlur() {
|
|
215
|
-
|
|
216
|
-
element?.endFocus();
|
|
188
|
+
this.ripple?.endFocus();
|
|
217
189
|
}
|
|
218
|
-
getRipple = (__runInitializers(this, _hasAvatar_extraInitializers), () => {
|
|
219
|
-
this.showRipple = true;
|
|
220
|
-
return this.ripple;
|
|
221
|
-
});
|
|
222
190
|
endPress(info) {
|
|
223
191
|
super.endPress(info);
|
|
224
|
-
this.
|
|
192
|
+
this.classList.remove('pressed');
|
|
193
|
+
this.ripple?.endPress();
|
|
225
194
|
const { cancelled, reason } = info;
|
|
226
195
|
if (cancelled) {
|
|
227
196
|
return;
|
|
@@ -236,6 +205,14 @@ let UiChip = (() => {
|
|
|
236
205
|
this.toggleChecked();
|
|
237
206
|
}
|
|
238
207
|
}
|
|
208
|
+
handlePointerEnter(e) {
|
|
209
|
+
super.handlePointerEnter(e);
|
|
210
|
+
this.ripple?.beginHover(e);
|
|
211
|
+
}
|
|
212
|
+
handlePointerLeave(e) {
|
|
213
|
+
super.handlePointerLeave(e);
|
|
214
|
+
this.ripple?.endHover();
|
|
215
|
+
}
|
|
239
216
|
/**
|
|
240
217
|
* Toggles the "filter" type of the chip.
|
|
241
218
|
*/
|
|
@@ -257,42 +234,33 @@ let UiChip = (() => {
|
|
|
257
234
|
const slot = e.target;
|
|
258
235
|
this.hasAvatar = !!slot.assignedNodes().length;
|
|
259
236
|
}
|
|
260
|
-
handleListClick(e) {
|
|
261
|
-
e.preventDefault();
|
|
262
|
-
e.stopPropagation();
|
|
263
|
-
this.listAction();
|
|
264
|
-
}
|
|
265
237
|
handleClose(e) {
|
|
266
238
|
e.preventDefault();
|
|
267
239
|
e.stopPropagation();
|
|
268
|
-
this.
|
|
240
|
+
this.removeAction();
|
|
269
241
|
}
|
|
270
|
-
async
|
|
271
|
-
this.dispatchEvent(new Event('
|
|
272
|
-
}
|
|
273
|
-
async listAction() {
|
|
274
|
-
this.dispatchEvent(new Event('list'));
|
|
242
|
+
async removeAction() {
|
|
243
|
+
this.dispatchEvent(new Event('remove'));
|
|
275
244
|
}
|
|
276
245
|
render() {
|
|
277
|
-
const { pressed = false } = this;
|
|
278
246
|
const containerClasses = classMap({
|
|
279
|
-
surface: true,
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
247
|
+
'surface': true,
|
|
248
|
+
'has-icon': this.hasIcon,
|
|
249
|
+
'has-avatar': this.hasAvatar,
|
|
250
|
+
'has-trailing-icon': this.hasTrailingIcon,
|
|
283
251
|
});
|
|
284
252
|
return html `
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
${
|
|
288
|
-
<
|
|
289
|
-
|
|
290
|
-
<slot></slot>
|
|
291
|
-
${this.renderTrailingIcon()}
|
|
292
|
-
</div>
|
|
253
|
+
${this.renderRipple()}
|
|
254
|
+
<div class="${containerClasses}">
|
|
255
|
+
${this.renderLeadingIcon()} ${this.renderAvatar()}
|
|
256
|
+
<slot></slot>
|
|
257
|
+
${this.renderTrailingIcon()}
|
|
293
258
|
</div>
|
|
294
259
|
`;
|
|
295
260
|
}
|
|
261
|
+
renderRipple() {
|
|
262
|
+
return html `<ui-ripple class="ripple" ?disabled="${this.disabled}"></ui-ripple>`;
|
|
263
|
+
}
|
|
296
264
|
renderLeadingIcon() {
|
|
297
265
|
const { type } = this;
|
|
298
266
|
if (type === ChipType.suggestion) {
|
|
@@ -306,29 +274,17 @@ let UiChip = (() => {
|
|
|
306
274
|
});
|
|
307
275
|
return html `<span class="${iconClasses}" role="presentation">${check}</span>`;
|
|
308
276
|
}
|
|
309
|
-
return html `<slot name="icon" @slotchange="${this.handleIconSlotChange}"></slot>`;
|
|
277
|
+
return html `<slot class="leading-icon" name="icon" @slotchange="${this.handleIconSlotChange}"></slot>`;
|
|
310
278
|
}
|
|
311
279
|
renderAvatar() {
|
|
312
|
-
|
|
313
|
-
if (type === ChipType.input) {
|
|
314
|
-
return html `<slot name="avatar" @slotchange="${this.handleAvatarSlotChange}"></slot>`;
|
|
315
|
-
}
|
|
316
|
-
return nothing;
|
|
280
|
+
return html `<slot name="avatar" @slotchange="${this.handleAvatarSlotChange}"></slot>`;
|
|
317
281
|
}
|
|
318
282
|
renderTrailingIcon() {
|
|
319
|
-
const {
|
|
320
|
-
if (type === ChipType.filter) {
|
|
321
|
-
|
|
322
|
-
return html `<span
|
|
323
|
-
class="trailing-icon"
|
|
324
|
-
role="presentation"
|
|
325
|
-
@click="${this.handleListClick}"
|
|
326
|
-
@keypress="${cancelEvent}"
|
|
327
|
-
>${arrowDropDown}</span
|
|
328
|
-
>`;
|
|
329
|
-
}
|
|
283
|
+
const { removable = false, list, type } = this;
|
|
284
|
+
if (type === ChipType.filter && list) {
|
|
285
|
+
return html `<span class="trailing-icon" role="presentation">${arrowDropDown}</span>`;
|
|
330
286
|
}
|
|
331
|
-
if (type === ChipType.input &&
|
|
287
|
+
if (type === ChipType.input && removable) {
|
|
332
288
|
return html `<span
|
|
333
289
|
class="trailing-icon"
|
|
334
290
|
@click="${this.handleClose}"
|
|
@@ -340,19 +296,25 @@ let UiChip = (() => {
|
|
|
340
296
|
}
|
|
341
297
|
return nothing;
|
|
342
298
|
}
|
|
343
|
-
|
|
344
|
-
const {
|
|
345
|
-
|
|
346
|
-
|
|
299
|
+
get hasTrailingIcon() {
|
|
300
|
+
const { removable = false, list, type } = this;
|
|
301
|
+
if (type === ChipType.filter && list) {
|
|
302
|
+
return true;
|
|
303
|
+
}
|
|
304
|
+
if (type === ChipType.input && removable) {
|
|
305
|
+
return true;
|
|
306
|
+
}
|
|
307
|
+
return false;
|
|
308
|
+
}
|
|
347
309
|
};
|
|
348
310
|
})();
|
|
349
311
|
/**
|
|
350
312
|
* @slot The content of the chip.
|
|
351
313
|
* @slot icon - The leading icon, sized 18x18 px
|
|
352
314
|
* @slot avatar - The leading image, sized 24x24 px
|
|
353
|
-
* @fires list - When the user requested to activate the list associated with the element.
|
|
354
315
|
* @fires select - When the checked state changed through a user interaction. This only related to
|
|
355
316
|
* `filter` chips. Note, `select` is dispatched just before the `click` event.
|
|
317
|
+
* @fires remove - When the user clicks the "remove" icon on the chip.
|
|
356
318
|
*/
|
|
357
319
|
export default UiChip;
|
|
358
320
|
//# sourceMappingURL=Chip.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chip.js","sourceRoot":"","sources":["../../../../../src/md/chip/internals/Chip.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAA;AAClE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAkC,MAAM,KAAK,CAAA;AACnE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAE9C,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAA;AACzD,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAEtD,OAAO,2BAA2B,CAAA;AAElC,MAAM,CAAN,IAAY,QAKX;AALD,WAAY,QAAQ;IAClB,6BAAiB,CAAA;IACjB,6BAAiB,CAAA;IACjB,2BAAe,CAAA;IACf,qCAAyB,CAAA;AAC3B,CAAC,EALW,QAAQ,KAAR,QAAQ,QAKnB;;sBAUmC,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAQ,gBAAgB,CAAA;QAC7E,CAAC,CAAA;;;AA3RH;;;;;;;GAOG;AACH,sBAoRC","sourcesContent":["import { cancelEvent } from '@api-client/core/lib/events/Utils.js'\nimport { html, nothing, PropertyValues, TemplateResult } from 'lit'\nimport { property, queryAsync, state } from 'lit/decorators.js'\nimport { classMap } from 'lit/directives/class-map.js'\nimport { when } from 'lit/directives/when.js'\nimport { UiElement } from '../../UiElement.js'\nimport UiRipple from '../../ripple/internals/ripple.js'\nimport { ripple } from '../../effects/rippleDirective.js'\nimport { close, arrowDropDown, check } from '../../icons/Icons.js'\nimport { setDisabled } from '../../../lib/disabled.js'\nimport { BeginPressConfig, EndPressConfig } from '../../../controllers/ActionController.js'\nimport '../../ripple/ui-ripple.js'\n\nexport enum ChipType {\n assist = 'assist',\n filter = 'filter',\n input = 'input',\n suggestion = 'suggestion',\n}\n\n/**\n * @slot The content of the chip.\n * @slot icon - The leading icon, sized 18x18 px\n * @slot avatar - The leading image, sized 24x24 px\n * @fires list - When the user requested to activate the list associated with the element.\n * @fires select - When the checked state changed through a user interaction. This only related to\n * `filter` chips. Note, `select` is dispatched just before the `click` event.\n */\nexport default class UiChip extends UiElement {\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 type of the rendered chip.\n * @attribute\n *\n * @see https://m3.material.io/components/chips/guidelines\n */\n @property({ type: String }) accessor type: ChipType\n\n /**\n * Whether the chip should be rendered as elevated.\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) accessor elevated: boolean | undefined\n\n /**\n * Whether the chip renders the \"close\" icon at the end.\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) accessor closable: boolean | undefined\n\n /**\n * Whether the chip is currently checked.\n * Note, this controls the presentation layer only. It has no meaning when it comes to forms and inputs.\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) accessor checked: boolean | undefined\n\n /**\n * The ID attribute of the list element that is rendered after activating the chip.\n * When this is set the chip renders the dropdown icon at the end and sets `aria-*`\n * attributes informing the assistive technology that this chip controls a list.\n *\n * @attribute\n */\n @property({ type: String, reflect: true }) accessor list: string | undefined\n\n @queryAsync('ui-ripple') protected accessor ripple!: Promise<UiRipple | null>\n\n @state() protected accessor showRipple = false\n\n /**\n * Determines when the element has an icon in the \"icon\" slot.\n */\n @state() protected accessor hasIcon: boolean\n\n /**\n * Determines when the element has an image in the \"avatar\" slot.\n */\n @state() protected accessor hasAvatar: boolean\n\n constructor() {\n super()\n\n this.disabled = false\n this.type = ChipType.assist\n this.hasIcon = false\n this.hasAvatar = false\n\n this.actionController.cancelKeyboardEvents = true\n\n this.addEventListener('click', this.handleClick.bind(this))\n this.addEventListener('keydown', this.handleKeyDown.bind(this))\n this.addEventListener('keyup', this.handleKeyUp.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('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', 'button')\n }\n if (!this.hasAttribute('tabindex') && !this.disabled) {\n this.setAttribute('tabindex', '0')\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 protected async pressRipple(): Promise<void> {\n const element = await this.getRipple()\n if (element && !element.isPressed) {\n element.beginPress()\n }\n }\n\n protected async endRipple(): Promise<void> {\n const element = await this.getRipple()\n element?.endPress()\n }\n\n override beginPress(options: BeginPressConfig): void {\n super.beginPress(options)\n this.pressRipple()\n }\n\n override async handleKeyDown(e: KeyboardEvent): Promise<void> {\n super.handleKeyDown(e)\n if (this.type === ChipType.filter && e.code === 'ArrowDown') {\n e.preventDefault()\n this.listAction()\n } else if (this.closable && e.code === 'Backspace') {\n e.preventDefault()\n this.closeAction()\n }\n }\n\n protected async handleFocus(): Promise<void> {\n const element = await this.getRipple()\n element?.beginFocus()\n }\n\n protected async handleBlur(): Promise<void> {\n const element = await this.getRipple()\n element?.endFocus()\n }\n\n protected readonly getRipple = (): Promise<UiRipple | null> => {\n this.showRipple = true\n return this.ripple\n }\n\n override endPress(info: EndPressConfig): void {\n super.endPress(info)\n this.endRipple()\n const { cancelled, reason } = info\n if (cancelled) {\n return\n }\n if (reason === 'enter' || reason === 'space') {\n this.click()\n }\n }\n\n override handleClick(e: MouseEvent): void {\n super.handleClick(e)\n if (this.type === ChipType.filter) {\n this.toggleChecked()\n }\n }\n\n /**\n * Toggles the \"filter\" type of the chip.\n */\n toggleChecked(): void {\n this.checked = !this.checked\n this.dispatchEvent(new Event('select'))\n }\n\n /**\n * Sets the `hasIcon` state property when the \"icon\" slot change event is dispatched.\n */\n protected handleIconSlotChange(e: Event): void {\n const slot = e.target as HTMLSlotElement\n this.hasIcon = !!slot.assignedNodes().length\n }\n\n /**\n * Sets the `_hasAvatar` state property when the \"avatar\" slot change event is dispatched.\n */\n protected handleAvatarSlotChange(e: Event): void {\n const slot = e.target as HTMLSlotElement\n this.hasAvatar = !!slot.assignedNodes().length\n }\n\n protected handleListClick(e: Event): void {\n e.preventDefault()\n e.stopPropagation()\n this.listAction()\n }\n\n protected handleClose(e: Event): void {\n e.preventDefault()\n e.stopPropagation()\n this.closeAction()\n }\n\n protected async closeAction(): Promise<void> {\n this.dispatchEvent(new Event('close'))\n }\n\n protected async listAction(): Promise<void> {\n this.dispatchEvent(new Event('list'))\n }\n\n protected override render(): TemplateResult {\n const { pressed = false } = this\n const containerClasses = classMap({\n surface: true,\n withIcon: this.hasIcon,\n withAvatar: this.hasAvatar,\n pressed,\n })\n return html`\n <div class=\"${containerClasses}\" ${ripple(this.getRipple)}>\n <div class=\"container\"></div>\n ${when(this.showRipple, this.renderRipple)}\n <div class=\"content\">\n ${this.renderLeadingIcon()} ${this.renderAvatar()}\n <slot></slot>\n ${this.renderTrailingIcon()}\n </div>\n </div>\n `\n }\n\n protected renderLeadingIcon(): TemplateResult | typeof nothing {\n const { type } = this\n if (type === ChipType.suggestion) {\n return nothing\n }\n if (type === ChipType.filter) {\n const iconClasses = classMap({\n 'leading-icon': true,\n 'check-mark': true,\n 'checked': !!this.checked,\n })\n return html`<span class=\"${iconClasses}\" role=\"presentation\">${check}</span>`\n }\n return html`<slot name=\"icon\" @slotchange=\"${this.handleIconSlotChange}\"></slot>`\n }\n\n protected renderAvatar(): TemplateResult | typeof nothing {\n const { type } = this\n if (type === ChipType.input) {\n return html`<slot name=\"avatar\" @slotchange=\"${this.handleAvatarSlotChange}\"></slot>`\n }\n return nothing\n }\n\n protected renderTrailingIcon(): TemplateResult | typeof nothing {\n const { closable = false, list, type } = this\n if (type === ChipType.filter) {\n if (list) {\n return html`<span\n class=\"trailing-icon\"\n role=\"presentation\"\n @click=\"${this.handleListClick}\"\n @keypress=\"${cancelEvent}\"\n >${arrowDropDown}</span\n >`\n }\n }\n if (type === ChipType.input && closable) {\n return html`<span\n class=\"trailing-icon\"\n @click=\"${this.handleClose}\"\n @keypress=\"${cancelEvent}\"\n role=\"button\"\n aria-label=\"Activate to close or disabled this chip.\"\n >${close}</span\n >`\n }\n return nothing\n }\n\n protected renderRipple = (): TemplateResult => {\n const { disabled } = this\n return html`<ui-ripple class=\"ripple\" ?disabled=\"${disabled}\"></ui-ripple>`\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Chip.js","sourceRoot":"","sources":["../../../../../src/md/chip/internals/Chip.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAA;AAClE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAkC,MAAM,KAAK,CAAA;AACnE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAA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TemplateResult } from 'lit'\nimport { property, query, state } from 'lit/decorators.js'\nimport { classMap } from 'lit/directives/class-map.js'\nimport { UiElement } from '../../UiElement.js'\nimport UiRipple from '../../ripple/internals/ripple.js'\nimport { close, arrowDropDown, check } from '../../icons/Icons.js'\nimport { setDisabled } from '../../../lib/disabled.js'\nimport { BeginPressConfig, EndPressConfig } from '../../../controllers/ActionController.js'\nimport '../../ripple/ui-ripple.js'\n\nexport enum ChipType {\n assist = 'assist',\n filter = 'filter',\n input = 'input',\n suggestion = 'suggestion',\n}\n\n/**\n * @slot The content of the chip.\n * @slot icon - The leading icon, sized 18x18 px\n * @slot avatar - The leading image, sized 24x24 px\n * @fires select - When the checked state changed through a user interaction. This only related to\n * `filter` chips. Note, `select` is dispatched just before the `click` event.\n * @fires remove - When the user clicks the \"remove\" icon on the chip.\n */\nexport default class UiChip extends UiElement {\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 type of the rendered chip.\n * @attribute\n *\n * @see https://m3.material.io/components/chips/guidelines\n */\n @property({ type: String }) accessor type: ChipType\n\n /**\n * Whether the chip should be rendered as elevated.\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) accessor elevated: boolean | undefined\n\n /**\n * Whether the chip renders the \"close\" icon at the end.\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) accessor removable: boolean | undefined\n\n /**\n * Whether the chip is currently checked.\n * Note, this controls the presentation layer only. It has no meaning when it comes to forms and inputs.\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) accessor checked: boolean | undefined\n\n /**\n * When set, the chip will render a trailing icon that indicates that the chip is associated\n * with a list. It does not do anything.\n *\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) accessor list: boolean | undefined\n\n @query('ui-ripple') protected accessor ripple!: UiRipple | null\n\n /**\n * Determines when the element has an icon in the \"icon\" slot.\n */\n @state() protected accessor hasIcon: boolean\n\n /**\n * Determines when the element has an image in the \"avatar\" slot.\n */\n @state() protected accessor hasAvatar: boolean\n\n constructor() {\n super()\n\n this.disabled = false\n this.type = ChipType.assist\n this.hasIcon = false\n this.hasAvatar = false\n\n this.actionController.cancelKeyboardEvents = true\n\n this.addEventListener('keydown', this.handleKeyDown.bind(this))\n this.addEventListener('keyup', this.handleKeyUp.bind(this))\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('pointerenter', this.handlePointerEnter.bind(this))\n this.addEventListener('contextmenu', this.handleContextMenu.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', 'button')\n }\n if (!this.hasAttribute('tabindex') && !this.disabled) {\n this.setAttribute('tabindex', '0')\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 beginPress(options: BeginPressConfig): void {\n super.beginPress(options)\n this.classList.add('pressed')\n this.ripple?.beginPress(options.positionEvent)\n }\n\n override async handleKeyDown(e: KeyboardEvent): Promise<void> {\n super.handleKeyDown(e)\n if (this.removable && e.code === 'Backspace') {\n e.preventDefault()\n this.removeAction()\n }\n }\n\n protected async handleFocus(): Promise<void> {\n this.ripple?.beginFocus()\n }\n\n protected async handleBlur(): Promise<void> {\n this.ripple?.endFocus()\n }\n\n override endPress(info: EndPressConfig): void {\n super.endPress(info)\n this.classList.remove('pressed')\n this.ripple?.endPress()\n const { cancelled, reason } = info\n if (cancelled) {\n return\n }\n if (reason === 'enter' || reason === 'space') {\n this.click()\n }\n }\n\n override handleClick(e: MouseEvent): void {\n super.handleClick(e)\n if (this.type === ChipType.filter) {\n this.toggleChecked()\n }\n }\n\n override handlePointerEnter(e: PointerEvent): void {\n super.handlePointerEnter(e)\n this.ripple?.beginHover(e)\n }\n\n override handlePointerLeave(e: PointerEvent): void {\n super.handlePointerLeave(e)\n this.ripple?.endHover()\n }\n\n /**\n * Toggles the \"filter\" type of the chip.\n */\n toggleChecked(): void {\n this.checked = !this.checked\n this.dispatchEvent(new Event('select'))\n }\n\n /**\n * Sets the `hasIcon` state property when the \"icon\" slot change event is dispatched.\n */\n protected handleIconSlotChange(e: Event): void {\n const slot = e.target as HTMLSlotElement\n this.hasIcon = !!slot.assignedNodes().length\n }\n\n /**\n * Sets the `_hasAvatar` state property when the \"avatar\" slot change event is dispatched.\n */\n protected handleAvatarSlotChange(e: Event): void {\n const slot = e.target as HTMLSlotElement\n this.hasAvatar = !!slot.assignedNodes().length\n }\n\n protected handleClose(e: Event): void {\n e.preventDefault()\n e.stopPropagation()\n this.removeAction()\n }\n\n protected async removeAction(): Promise<void> {\n this.dispatchEvent(new Event('remove'))\n }\n\n protected override render(): TemplateResult {\n const containerClasses = classMap({\n 'surface': true,\n 'has-icon': this.hasIcon,\n 'has-avatar': this.hasAvatar,\n 'has-trailing-icon': this.hasTrailingIcon,\n })\n return html`\n ${this.renderRipple()}\n <div class=\"${containerClasses}\">\n ${this.renderLeadingIcon()} ${this.renderAvatar()}\n <slot></slot>\n ${this.renderTrailingIcon()}\n </div>\n `\n }\n\n protected renderRipple(): TemplateResult {\n return html`<ui-ripple class=\"ripple\" ?disabled=\"${this.disabled}\"></ui-ripple>`\n }\n\n protected renderLeadingIcon(): TemplateResult | typeof nothing {\n const { type } = this\n if (type === ChipType.suggestion) {\n return nothing\n }\n if (type === ChipType.filter) {\n const iconClasses = classMap({\n 'leading-icon': true,\n 'check-mark': true,\n 'checked': !!this.checked,\n })\n return html`<span class=\"${iconClasses}\" role=\"presentation\">${check}</span>`\n }\n return html`<slot class=\"leading-icon\" name=\"icon\" @slotchange=\"${this.handleIconSlotChange}\"></slot>`\n }\n\n protected renderAvatar(): TemplateResult | typeof nothing {\n return html`<slot name=\"avatar\" @slotchange=\"${this.handleAvatarSlotChange}\"></slot>`\n }\n\n protected renderTrailingIcon(): TemplateResult | typeof nothing {\n const { removable = false, list, type } = this\n if (type === ChipType.filter && list) {\n return html`<span class=\"trailing-icon\" role=\"presentation\">${arrowDropDown}</span>`\n }\n if (type === ChipType.input && removable) {\n return html`<span\n class=\"trailing-icon\"\n @click=\"${this.handleClose}\"\n @keypress=\"${cancelEvent}\"\n role=\"button\"\n aria-label=\"Activate to close or disabled this chip.\"\n >${close}</span\n >`\n }\n return nothing\n }\n\n get hasTrailingIcon(): boolean {\n const { removable = false, list, type } = this\n if (type === ChipType.filter && list) {\n return true\n }\n if (type === ChipType.input && removable) {\n return true\n }\n return false\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chip.styles.d.ts","sourceRoot":"","sources":["../../../../../src/md/chip/internals/Chip.styles.ts"],"names":[],"mappings":";AAEA,
|
|
1
|
+
{"version":3,"file":"Chip.styles.d.ts","sourceRoot":"","sources":["../../../../../src/md/chip/internals/Chip.styles.ts"],"names":[],"mappings":";AAEA,wBAqLC"}
|