@api-client/ui 0.3.3 → 0.3.5

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.
Files changed (50) hide show
  1. package/build/src/md/button/internals/base.d.ts.map +1 -1
  2. package/build/src/md/button/internals/base.js +2 -6
  3. package/build/src/md/button/internals/base.js.map +1 -1
  4. package/build/src/md/button/internals/button.styles.js +1 -1
  5. package/build/src/md/button/internals/button.styles.js.map +1 -1
  6. package/build/src/md/chip/internals/Chip.d.ts +11 -15
  7. package/build/src/md/chip/internals/Chip.d.ts.map +1 -1
  8. package/build/src/md/chip/internals/Chip.js +66 -104
  9. package/build/src/md/chip/internals/Chip.js.map +1 -1
  10. package/build/src/md/chip/internals/Chip.styles.d.ts.map +1 -1
  11. package/build/src/md/chip/internals/Chip.styles.js +114 -101
  12. package/build/src/md/chip/internals/Chip.styles.js.map +1 -1
  13. package/build/src/md/chip/internals/ChipSet.d.ts +16 -0
  14. package/build/src/md/chip/internals/ChipSet.d.ts.map +1 -0
  15. package/build/src/md/chip/internals/ChipSet.js +138 -0
  16. package/build/src/md/chip/internals/ChipSet.js.map +1 -0
  17. package/build/src/md/chip/internals/ChipSet.styles.d.ts +3 -0
  18. package/build/src/md/chip/internals/ChipSet.styles.d.ts.map +1 -0
  19. package/build/src/md/chip/internals/ChipSet.styles.js +9 -0
  20. package/build/src/md/chip/internals/ChipSet.styles.js.map +1 -0
  21. package/build/src/md/chip/ui-chip-set.d.ts +11 -0
  22. package/build/src/md/chip/ui-chip-set.d.ts.map +1 -0
  23. package/build/src/md/chip/ui-chip-set.js +27 -0
  24. package/build/src/md/chip/ui-chip-set.js.map +1 -0
  25. package/build/src/md/dialog/internals/Dialog.styles.d.ts.map +1 -1
  26. package/build/src/md/dialog/internals/Dialog.styles.js +5 -11
  27. package/build/src/md/dialog/internals/Dialog.styles.js.map +1 -1
  28. package/build/src/md/switch/internals/Switch.styles.js +1 -1
  29. package/build/src/md/switch/internals/Switch.styles.js.map +1 -1
  30. package/build/src/md/text-field/internals/outlined.styles.js +2 -2
  31. package/build/src/md/text-field/internals/outlined.styles.js.map +1 -1
  32. package/demo/md/chip/chip.html +33 -6
  33. package/demo/md/chip/chip.ts +111 -56
  34. package/package.json +2 -2
  35. package/src/md/button/internals/base.ts +2 -6
  36. package/src/md/button/internals/button.styles.ts +1 -1
  37. package/src/md/chip/internals/Chip.styles.ts +114 -101
  38. package/src/md/chip/internals/Chip.ts +58 -88
  39. package/src/md/chip/internals/ChipSet.styles.ts +9 -0
  40. package/src/md/chip/internals/ChipSet.ts +142 -0
  41. package/src/md/chip/ui-chip-set.ts +15 -0
  42. package/src/md/dialog/internals/Dialog.styles.ts +5 -11
  43. package/src/md/switch/internals/Switch.styles.ts +1 -1
  44. package/src/md/text-field/internals/outlined.styles.ts +2 -2
  45. package/test/ui/chip/UiChip.test.ts +18 -67
  46. package/build/src/events/BroadcastUiEvents.d.ts +0 -18
  47. package/build/src/events/BroadcastUiEvents.d.ts.map +0 -1
  48. package/build/src/events/BroadcastUiEvents.js +0 -2
  49. package/build/src/events/BroadcastUiEvents.js.map +0 -1
  50. package/src/events/BroadcastUiEvents.ts +0 -19
@@ -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,E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AAa;UAChB,CAAA;gBACJ,CAAC;YACH,CAAC;YACD,IAAI,IAAI,KAAK,QAAQ,CAAC,KAAK,IAAI,QAAQ,EAAE,CAAC;gBACxC,OAAO,IAAI,CAAA;;kBAEC,IAAI,CAAC,WAAW;qBACb,WAAW;;;WAGrB,KAAK;QACR,CAAA;YACJ,CAAC;YACD,OAAO,OAAO,CAAA;QAChB,CAAC;QAES,YAAY,GAAG,GAAmB,EAAE;YAC5C,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAA;YACzB,OAAO,IAAI,CAAA,wCAAwC,QAAQ,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,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAE9C,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAxB,MAAO,SAAQ,WAAS;;;oCAK1C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gCAQ1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oCAM1B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;qCAM1C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;mCAO1C,QAAQ,CAAC,EAAE,IAA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AI,CAAA;YAC9C,IAAI,IAAI,KAAK,QAAQ,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC;gBACrC,OAAO,IAAI,CAAA;YACb,CAAC;YACD,IAAI,IAAI,KAAK,QAAQ,CAAC,KAAK,IAAI,SAAS,EAAE,CAAC;gBACzC,OAAO,IAAI,CAAA;YACb,CAAC;YACD,OAAO,KAAK,CAAA;QACd,CAAC;;;AA/PH;;;;;;;GAOG;AACH,sBAwPC","sourcesContent":["import { cancelEvent } from '@api-client/core/lib/events/Utils.js'\nimport { html, nothing, PropertyValues, 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,wBAwKC"}
1
+ {"version":3,"file":"Chip.styles.d.ts","sourceRoot":"","sources":["../../../../../src/md/chip/internals/Chip.styles.ts"],"names":[],"mappings":";AAEA,wBAqLC"}
@@ -5,167 +5,180 @@ export default css `
5
5
  vertical-align: middle;
6
6
  outline: none;
7
7
  -webkit-tap-highlight-color: transparent;
8
- height: 32px;
8
+ position: relative;
9
+ user-select: none;
9
10
 
10
11
  font-family: var(--md-sys-typescale-label-large-font);
11
12
  font-size: var(--md-sys-typescale-label-large-size);
12
13
  letter-spacing: var(--md-sys-typescale-label-large-tracking);
13
14
  line-height: var(--md-sys-typescale-label-large-height);
14
15
 
15
- border-radius: var(--md-sys-shape-corner-small);
16
- color: var(--md-sys-color-on-surface);
17
- fill: var(--md-sys-color-primary);
18
-
19
- user-select: none;
20
-
21
16
  --md-ripple-hover-state-layer-color: var(--md-sys-color-on-surface);
22
17
  --md-ripple-focus-state-layer-color: var(--md-sys-color-on-surface);
23
18
  --md-ripple-pressed-state-layer-color: var(--md-sys-color-primary);
24
- }
25
19
 
26
- :host([disabled]) {
27
- pointer-events: none;
28
- }
29
-
30
- :host([disabled]) .container {
31
- border-color: var(--md-sys-color-on-surface);
32
- opacity: 0.12;
33
- }
20
+ --_leading-icon-color: currentColor;
21
+ --_trailing-icon-color: currentColor;
22
+ --_background-color: transparent;
23
+ --_color: inherit;
24
+ --_shadow: var(--md-sys-elevation-0);
25
+ --_outline-color: transparent;
26
+ --_outline-size: 0;
27
+ --_inline-padding-start: 16px;
28
+ --_inline-padding-end: 16px;
29
+ --_avatar-size: 24px;
30
+ --_avatar-shape: 24px;
31
+ --_icon-size: 18px;
34
32
 
35
- :host([disabled][elevated]) .container {
36
- background-color: var(--md-sys-color-on-surface);
37
- opacity: 0.12;
38
- box-shadow: none;
39
- }
40
-
41
- :host([disabled]) .content {
42
- color: var(--md-sys-color-on-surface);
43
- opacity: 0.68;
44
- }
45
-
46
- .surface {
47
- position: relative;
48
- height: inherit;
49
- border-radius: inherit;
33
+ height: 32px;
34
+ border-radius: var(--md-sys-shape-corner-small);
35
+ box-shadow: var(--_shadow);
36
+ border: var(--_outline-size) solid var(--_outline-color);
50
37
  }
51
38
 
52
39
  .ripple {
53
- z-index: 0;
54
40
  border-radius: inherit;
41
+ transition: border-radius var(--md-sys-motion-duration-medium1) var(--md-sys-motion-easing-standard);
55
42
  }
56
43
 
57
- .container {
58
- position: absolute;
59
- inset: 0;
44
+ .ripple.activated {
45
+ z-index: 1;
46
+ }
60
47
 
61
- box-sizing: border-box;
62
- border-radius: inherit;
63
- border: 1px var(--md-sys-color-outline) solid;
64
- z-index: 0;
48
+ :host([disabled]) {
49
+ --_background-color: color-mix(in srgb, var(--md-sys-color-on-surface) 12%, transparent);
50
+ --_color: color-mix(in srgb, var(--md-sys-color-on-surface) 38%, transparent);
51
+ --_leading-icon-color: color-mix(in srgb, var(--md-sys-color-on-surface) 38%, transparent);
52
+ --_trailing-icon-color: color-mix(in srgb, var(--md-sys-color-on-surface) 38%, transparent);
53
+ --_outline-color: color-mix(in srgb, var(--md-sys-color-on-surface) 12%, transparent);
54
+ box-shadow: none;
55
+ cursor: not-allowed;
56
+ pointer-events: none;
65
57
  }
66
58
 
67
- .content {
59
+ .surface {
68
60
  height: inherit;
69
61
  display: flex;
70
62
  align-items: center;
71
63
  justify-content: start;
72
64
  box-sizing: border-box;
73
- padding: 0 16px;
65
+ padding: 0 var(--_inline-padding-end) 0 var(--_inline-padding-start);
74
66
  border-radius: inherit;
75
- border: 1px transparent solid;
76
- position: relative;
77
- z-index: 1;
67
+ background-color: var(--_background-color);
68
+ color: var(--_color);
69
+ gap: 0;
78
70
  }
79
71
 
80
- :host([elevated]) .container {
81
- background-color: var(--md-sys-color-surface);
82
- box-shadow: var(--md-sys-elevation-1);
83
- border-width: 0;
72
+ .leading-icon {
73
+ height: var(--_icon-size);
74
+ width: 0px;
75
+ overflow: hidden;
76
+ transition: width 230ms var(--md-sys-animation-easing-standard);
77
+ color: var(--_leading-icon-color);
78
+ fill: currentColor;
84
79
  }
85
80
 
86
- .withIcon .content,
87
- :host([type='filter'][checked]) .content {
88
- padding-left: 8px;
81
+ .leading-icon::slotted(*) {
82
+ width: var(--_icon-size);
83
+ height: var(--_icon-size);
84
+ margin-right: 8px;
89
85
  }
90
86
 
91
- .withAvatar .content {
92
- padding-left: 4px;
87
+ slot[name='avatar']::slotted(*) {
88
+ width: var(--_avatar-size);
89
+ height: var(--_avatar-size);
90
+ border-radius: var(--_avatar-shape);
91
+ flex-shrink: 0;
92
+ flex-grow: 0;
93
+ margin-right: 8px;
93
94
  }
94
95
 
95
- :host([closable]) .content,
96
- :host([type='filter'][list]) .content {
97
- padding-right: 8px;
96
+ .check-mark.checked {
97
+ width: 18px;
98
+ margin-right: 8px;
98
99
  }
99
100
 
100
- .withIcon slot[name='icon']::slotted(*),
101
- .withAvatar slot[name='avatar']::slotted(*) {
102
- margin-right: 8px;
101
+ .trailing-icon {
102
+ margin-left: 8px;
103
+ width: 18px;
104
+ height: 18px;
105
+ color: var(--_trailing-icon-color);
106
+ fill: currentColor;
103
107
  }
104
108
 
105
- slot[name='icon']::slotted(*) {
106
- width: 16px;
107
- height: 16px;
109
+ :host([elevated]) {
110
+ --_shadow: var(--md-sys-elevation-1);
111
+ border: none;
112
+ --_background-color: var(--md-sys-color-surface-container-low);
108
113
  }
109
114
 
110
- slot[name='avatar']::slotted(*) {
111
- width: 24px;
112
- height: 24px;
113
- border-radius: var(--md-sys-shape-corner-medium);
115
+ :host([elevated]:hover:not([disabled])) {
116
+ --_shadow: var(--md-sys-elevation-2);
114
117
  }
115
118
 
116
- .leading-icon {
117
- height: 18px;
118
- width: 0px;
119
- overflow: hidden;
120
- transition: width 230ms var(--md-sys-animation-easing-standard);
119
+ .surface.has-trailing-icon {
120
+ --_inline-padding-end: 8px;
121
121
  }
122
122
 
123
- .check-mark.checked {
124
- width: 18px;
125
- margin-right: 8px;
123
+ :host([type='assist']:not([disabled])) {
124
+ --_outline-color: var(--md-sys-color-outline-variant);
125
+ --_outline-size: 1px;
126
+ --_color: var(--md-sys-color-on-surface);
127
+ --_leading-icon-color: var(--md-sys-color-primary);
126
128
  }
127
129
 
128
- .trailing-icon {
129
- margin-left: 8px;
130
- width: 18px;
131
- height: 18px;
132
- fill: var(--md-sys-color-on-surface-variant);
130
+ :host .has-icon {
131
+ --_inline-padding-start: 8px;
132
+ }
133
+
134
+ :host .has-avatar {
135
+ --_inline-padding-start: 4px;
136
+ }
137
+
138
+ :host([checked]) {
139
+ --_inline-padding-start: 8px;
140
+ --_background-color: var(--md-sys-color-secondary-container);
133
141
  }
134
142
 
135
- :host([elevated]:hover) .container,
136
- :host([elevated]:focus) .container {
137
- box-shadow: var(--md-sys-elevation-2);
143
+ :host([type='filter']:not([disabled])) {
144
+ --_leading-icon-color: var(--md-sys-color-primary);
145
+ --_trailing-icon-color: var(--md-sys-on-surface-variant);
146
+ --_outline-color: var(--md-sys-color-outline-variant);
147
+ --_outline-size: 1px;
148
+ --_color: var(--md-sys-color-on-surface-variant);
138
149
  }
139
150
 
140
- :host([elevated][dragged]) .container {
141
- box-shadow: var(--md-sys-elevation-4);
151
+ :host([type='filter'][checked]) {
152
+ --_outline-size: 1px;
142
153
  }
143
154
 
144
- :host([checked]) .container {
145
- background-color: var(--md-sys-color-secondary-container);
146
- border-width: 0;
155
+ :host([type='filter'][checked]:not([disabled])) {
156
+ --_leading-icon-color: var(--md-sys-color-on-secondary-container);
157
+ --_trailing-icon-color: var(--md-sys-on-secondary-container);
158
+ --_outline-color: var(--md-sys-color-secondary-container);
159
+ --_color: var(--md-sys-color-on-secondary-container);
147
160
  }
148
161
 
149
- :host([type='filter']),
150
- :host([type='filter']) .leading-icon {
151
- color: var(--md-sys-color-on-surface-variant);
152
- fill: var(--md-sys-color-on-surface-variant);
162
+ :host([type='input']:not([disabled])) {
163
+ --_outline-color: var(--md-sys-color-outline-variant);
164
+ --_outline-size: 1px;
165
+ --_leading-icon-color: var(--md-sys-color-primary);
166
+ --_trailing-icon-color: var(--md-sys-color-on-surface-variant);
167
+ --_color: var(--md-sys-color-on-surface-variant);
153
168
  }
154
169
 
155
- :host([type='filter'][checked]),
156
- :host([type='filter'][checked]) .leading-icon {
157
- color: var(--md-sys-color-on-secondary-container);
170
+ :host([type='input'][checked]) {
171
+ --_outline-size: 0px;
158
172
  }
159
173
 
160
- :host([type='input']) .container {
161
- background-color: var(--md-sys-color-surface);
162
- color: var(--md-sys-color-on-surface-variant);
174
+ :host([type='suggestion']) {
175
+ --_outline-size: 1px;
176
+ --_outline-color: var(--md-sys-color-outline-variant);
177
+ --_color: var(--md-sys-color-on-surface-variant);
163
178
  }
164
179
 
165
- :host([type='input']) .leading-icon,
166
- :host([type='input']) .trailing-icon {
167
- color: var(--md-sys-color-on-surface-variant);
168
- fill: var(--md-sys-color-on-surface-variant);
180
+ :host([type='suggestion']:not([disabled])) {
181
+ --_leading-icon-color: var(--md-sys-color-primary);
169
182
  }
170
183
  `;
171
184
  //# sourceMappingURL=Chip.styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Chip.styles.js","sourceRoot":"","sources":["../../../../../src/md/chip/internals/Chip.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAEzB,eAAe,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwKjB,CAAA","sourcesContent":["import { css } from 'lit'\n\nexport default css`\n :host {\n display: inline-block;\n vertical-align: middle;\n outline: none;\n -webkit-tap-highlight-color: transparent;\n height: 32px;\n\n font-family: var(--md-sys-typescale-label-large-font);\n font-size: var(--md-sys-typescale-label-large-size);\n letter-spacing: var(--md-sys-typescale-label-large-tracking);\n line-height: var(--md-sys-typescale-label-large-height);\n\n border-radius: var(--md-sys-shape-corner-small);\n color: var(--md-sys-color-on-surface);\n fill: var(--md-sys-color-primary);\n\n user-select: none;\n\n --md-ripple-hover-state-layer-color: var(--md-sys-color-on-surface);\n --md-ripple-focus-state-layer-color: var(--md-sys-color-on-surface);\n --md-ripple-pressed-state-layer-color: var(--md-sys-color-primary);\n }\n\n :host([disabled]) {\n pointer-events: none;\n }\n\n :host([disabled]) .container {\n border-color: var(--md-sys-color-on-surface);\n opacity: 0.12;\n }\n\n :host([disabled][elevated]) .container {\n background-color: var(--md-sys-color-on-surface);\n opacity: 0.12;\n box-shadow: none;\n }\n\n :host([disabled]) .content {\n color: var(--md-sys-color-on-surface);\n opacity: 0.68;\n }\n\n .surface {\n position: relative;\n height: inherit;\n border-radius: inherit;\n }\n\n .ripple {\n z-index: 0;\n border-radius: inherit;\n }\n\n .container {\n position: absolute;\n inset: 0;\n\n box-sizing: border-box;\n border-radius: inherit;\n border: 1px var(--md-sys-color-outline) solid;\n z-index: 0;\n }\n\n .content {\n height: inherit;\n display: flex;\n align-items: center;\n justify-content: start;\n box-sizing: border-box;\n padding: 0 16px;\n border-radius: inherit;\n border: 1px transparent solid;\n position: relative;\n z-index: 1;\n }\n\n :host([elevated]) .container {\n background-color: var(--md-sys-color-surface);\n box-shadow: var(--md-sys-elevation-1);\n border-width: 0;\n }\n\n .withIcon .content,\n :host([type='filter'][checked]) .content {\n padding-left: 8px;\n }\n\n .withAvatar .content {\n padding-left: 4px;\n }\n\n :host([closable]) .content,\n :host([type='filter'][list]) .content {\n padding-right: 8px;\n }\n\n .withIcon slot[name='icon']::slotted(*),\n .withAvatar slot[name='avatar']::slotted(*) {\n margin-right: 8px;\n }\n\n slot[name='icon']::slotted(*) {\n width: 16px;\n height: 16px;\n }\n\n slot[name='avatar']::slotted(*) {\n width: 24px;\n height: 24px;\n border-radius: var(--md-sys-shape-corner-medium);\n }\n\n .leading-icon {\n height: 18px;\n width: 0px;\n overflow: hidden;\n transition: width 230ms var(--md-sys-animation-easing-standard);\n }\n\n .check-mark.checked {\n width: 18px;\n margin-right: 8px;\n }\n\n .trailing-icon {\n margin-left: 8px;\n width: 18px;\n height: 18px;\n fill: var(--md-sys-color-on-surface-variant);\n }\n\n :host([elevated]:hover) .container,\n :host([elevated]:focus) .container {\n box-shadow: var(--md-sys-elevation-2);\n }\n\n :host([elevated][dragged]) .container {\n box-shadow: var(--md-sys-elevation-4);\n }\n\n :host([checked]) .container {\n background-color: var(--md-sys-color-secondary-container);\n border-width: 0;\n }\n\n :host([type='filter']),\n :host([type='filter']) .leading-icon {\n color: var(--md-sys-color-on-surface-variant);\n fill: var(--md-sys-color-on-surface-variant);\n }\n\n :host([type='filter'][checked]),\n :host([type='filter'][checked]) .leading-icon {\n color: var(--md-sys-color-on-secondary-container);\n }\n\n :host([type='input']) .container {\n background-color: var(--md-sys-color-surface);\n color: var(--md-sys-color-on-surface-variant);\n }\n\n :host([type='input']) .leading-icon,\n :host([type='input']) .trailing-icon {\n color: var(--md-sys-color-on-surface-variant);\n fill: var(--md-sys-color-on-surface-variant);\n }\n`\n"]}
1
+ {"version":3,"file":"Chip.styles.js","sourceRoot":"","sources":["../../../../../src/md/chip/internals/Chip.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAEzB,eAAe,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqLjB,CAAA","sourcesContent":["import { css } from 'lit'\n\nexport default css`\n :host {\n display: inline-block;\n vertical-align: middle;\n outline: none;\n -webkit-tap-highlight-color: transparent;\n position: relative;\n user-select: none;\n\n font-family: var(--md-sys-typescale-label-large-font);\n font-size: var(--md-sys-typescale-label-large-size);\n letter-spacing: var(--md-sys-typescale-label-large-tracking);\n line-height: var(--md-sys-typescale-label-large-height);\n\n --md-ripple-hover-state-layer-color: var(--md-sys-color-on-surface);\n --md-ripple-focus-state-layer-color: var(--md-sys-color-on-surface);\n --md-ripple-pressed-state-layer-color: var(--md-sys-color-primary);\n\n --_leading-icon-color: currentColor;\n --_trailing-icon-color: currentColor;\n --_background-color: transparent;\n --_color: inherit;\n --_shadow: var(--md-sys-elevation-0);\n --_outline-color: transparent;\n --_outline-size: 0;\n --_inline-padding-start: 16px;\n --_inline-padding-end: 16px;\n --_avatar-size: 24px;\n --_avatar-shape: 24px;\n --_icon-size: 18px;\n\n height: 32px;\n border-radius: var(--md-sys-shape-corner-small);\n box-shadow: var(--_shadow);\n border: var(--_outline-size) solid var(--_outline-color);\n }\n\n .ripple {\n border-radius: inherit;\n transition: border-radius var(--md-sys-motion-duration-medium1) var(--md-sys-motion-easing-standard);\n }\n\n .ripple.activated {\n z-index: 1;\n }\n\n :host([disabled]) {\n --_background-color: color-mix(in srgb, var(--md-sys-color-on-surface) 12%, transparent);\n --_color: color-mix(in srgb, var(--md-sys-color-on-surface) 38%, transparent);\n --_leading-icon-color: color-mix(in srgb, var(--md-sys-color-on-surface) 38%, transparent);\n --_trailing-icon-color: color-mix(in srgb, var(--md-sys-color-on-surface) 38%, transparent);\n --_outline-color: color-mix(in srgb, var(--md-sys-color-on-surface) 12%, transparent);\n box-shadow: none;\n cursor: not-allowed;\n pointer-events: none;\n }\n\n .surface {\n height: inherit;\n display: flex;\n align-items: center;\n justify-content: start;\n box-sizing: border-box;\n padding: 0 var(--_inline-padding-end) 0 var(--_inline-padding-start);\n border-radius: inherit;\n background-color: var(--_background-color);\n color: var(--_color);\n gap: 0;\n }\n\n .leading-icon {\n height: var(--_icon-size);\n width: 0px;\n overflow: hidden;\n transition: width 230ms var(--md-sys-animation-easing-standard);\n color: var(--_leading-icon-color);\n fill: currentColor;\n }\n\n .leading-icon::slotted(*) {\n width: var(--_icon-size);\n height: var(--_icon-size);\n margin-right: 8px;\n }\n\n slot[name='avatar']::slotted(*) {\n width: var(--_avatar-size);\n height: var(--_avatar-size);\n border-radius: var(--_avatar-shape);\n flex-shrink: 0;\n flex-grow: 0;\n margin-right: 8px;\n }\n\n .check-mark.checked {\n width: 18px;\n margin-right: 8px;\n }\n\n .trailing-icon {\n margin-left: 8px;\n width: 18px;\n height: 18px;\n color: var(--_trailing-icon-color);\n fill: currentColor;\n }\n\n :host([elevated]) {\n --_shadow: var(--md-sys-elevation-1);\n border: none;\n --_background-color: var(--md-sys-color-surface-container-low);\n }\n\n :host([elevated]:hover:not([disabled])) {\n --_shadow: var(--md-sys-elevation-2);\n }\n\n .surface.has-trailing-icon {\n --_inline-padding-end: 8px;\n }\n\n :host([type='assist']:not([disabled])) {\n --_outline-color: var(--md-sys-color-outline-variant);\n --_outline-size: 1px;\n --_color: var(--md-sys-color-on-surface);\n --_leading-icon-color: var(--md-sys-color-primary);\n }\n\n :host .has-icon {\n --_inline-padding-start: 8px;\n }\n\n :host .has-avatar {\n --_inline-padding-start: 4px;\n }\n\n :host([checked]) {\n --_inline-padding-start: 8px;\n --_background-color: var(--md-sys-color-secondary-container);\n }\n\n :host([type='filter']:not([disabled])) {\n --_leading-icon-color: var(--md-sys-color-primary);\n --_trailing-icon-color: var(--md-sys-on-surface-variant);\n --_outline-color: var(--md-sys-color-outline-variant);\n --_outline-size: 1px;\n --_color: var(--md-sys-color-on-surface-variant);\n }\n\n :host([type='filter'][checked]) {\n --_outline-size: 1px;\n }\n\n :host([type='filter'][checked]:not([disabled])) {\n --_leading-icon-color: var(--md-sys-color-on-secondary-container);\n --_trailing-icon-color: var(--md-sys-on-secondary-container);\n --_outline-color: var(--md-sys-color-secondary-container);\n --_color: var(--md-sys-color-on-secondary-container);\n }\n\n :host([type='input']:not([disabled])) {\n --_outline-color: var(--md-sys-color-outline-variant);\n --_outline-size: 1px;\n --_leading-icon-color: var(--md-sys-color-primary);\n --_trailing-icon-color: var(--md-sys-color-on-surface-variant);\n --_color: var(--md-sys-color-on-surface-variant);\n }\n\n :host([type='input'][checked]) {\n --_outline-size: 0px;\n }\n\n :host([type='suggestion']) {\n --_outline-size: 1px;\n --_outline-color: var(--md-sys-color-outline-variant);\n --_color: var(--md-sys-color-on-surface-variant);\n }\n\n :host([type='suggestion']:not([disabled])) {\n --_leading-icon-color: var(--md-sys-color-primary);\n }\n`\n"]}
@@ -0,0 +1,16 @@
1
+ import { LitElement } from 'lit';
2
+ import Chip from './Chip.js';
3
+ /**
4
+ * A chip set component.
5
+ */
6
+ export default class ChipSet extends LitElement {
7
+ get chips(): Chip[];
8
+ private accessor childElements;
9
+ private readonly internals;
10
+ constructor();
11
+ connectedCallback(): void;
12
+ protected render(): import("lit-html").TemplateResult<1>;
13
+ private handleKeyDown;
14
+ private updateTabIndices;
15
+ }
16
+ //# sourceMappingURL=ChipSet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChipSet.d.ts","sourceRoot":"","sources":["../../../../../src/md/chip/internals/ChipSet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,UAAU,EAAE,MAAM,KAAK,CAAA;AAGtC,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,OAAQ,SAAQ,UAAU;IAC7C,IAAI,KAAK,WAER;IAEwB,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;IACvE,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAyB;;IAU1C,iBAAiB,IAAI,IAAI;cAOf,MAAM;IAIzB,OAAO,CAAC,aAAa;IA0ErB,OAAO,CAAC,gBAAgB;CA4BzB"}
@@ -0,0 +1,138 @@
1
+ import { __esDecorate, __runInitializers } from "tslib";
2
+ import { html, LitElement } from 'lit';
3
+ import { queryAssignedElements } from 'lit/decorators.js';
4
+ import Chip from './Chip.js';
5
+ let ChipSet = (() => {
6
+ let _classSuper = LitElement;
7
+ let _childElements_decorators;
8
+ let _childElements_initializers = [];
9
+ let _childElements_extraInitializers = [];
10
+ return class ChipSet extends _classSuper {
11
+ static {
12
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
13
+ _childElements_decorators = [queryAssignedElements()];
14
+ __esDecorate(this, null, _childElements_decorators, { kind: "accessor", name: "childElements", static: false, private: false, access: { has: obj => "childElements" in obj, get: obj => obj.childElements, set: (obj, value) => { obj.childElements = value; } }, metadata: _metadata }, _childElements_initializers, _childElements_extraInitializers);
15
+ if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
16
+ }
17
+ get chips() {
18
+ return this.childElements.filter((child) => child instanceof Chip);
19
+ }
20
+ #childElements_accessor_storage = __runInitializers(this, _childElements_initializers, void 0);
21
+ get childElements() { return this.#childElements_accessor_storage; }
22
+ set childElements(value) { this.#childElements_accessor_storage = value; }
23
+ internals = (__runInitializers(this, _childElements_extraInitializers), this.attachInternals());
24
+ constructor() {
25
+ super();
26
+ this.addEventListener('focusin', this.updateTabIndices.bind(this));
27
+ this.addEventListener('update-focus', this.updateTabIndices.bind(this));
28
+ this.addEventListener('keydown', this.handleKeyDown.bind(this));
29
+ this.internals.role = 'toolbar';
30
+ }
31
+ connectedCallback() {
32
+ super.connectedCallback();
33
+ if (!this.hasAttribute('role')) {
34
+ this.setAttribute('role', 'toolbar');
35
+ }
36
+ }
37
+ render() {
38
+ return html `<slot @slotchange=${this.updateTabIndices}></slot>`;
39
+ }
40
+ handleKeyDown(event) {
41
+ const isLeft = event.key === 'ArrowLeft';
42
+ const isRight = event.key === 'ArrowRight';
43
+ const isHome = event.key === 'Home';
44
+ const isEnd = event.key === 'End';
45
+ // Ignore non-navigation keys
46
+ if (!isLeft && !isRight && !isHome && !isEnd) {
47
+ return;
48
+ }
49
+ const { chips } = this;
50
+ // Don't try to select another chip if there aren't any.
51
+ if (chips.length < 2) {
52
+ return;
53
+ }
54
+ // Prevent default interactions, such as scrolling.
55
+ event.preventDefault();
56
+ if (isHome || isEnd) {
57
+ const index = isHome ? 0 : chips.length - 1;
58
+ chips[index].focus({ trailing: isEnd });
59
+ this.updateTabIndices();
60
+ return;
61
+ }
62
+ // Check if moving forwards or backwards
63
+ const isRtl = getComputedStyle(this).direction === 'rtl';
64
+ const forwards = isRtl ? isLeft : isRight;
65
+ const focusedChip = chips.find((chip) => chip.matches(':focus-within'));
66
+ if (!focusedChip) {
67
+ // If there is not already a chip focused, select the first or last chip
68
+ // based on the direction we're traveling.
69
+ const nextChip = forwards ? chips[0] : chips[chips.length - 1];
70
+ nextChip.focus({ trailing: !forwards });
71
+ this.updateTabIndices();
72
+ return;
73
+ }
74
+ const currentIndex = chips.indexOf(focusedChip);
75
+ let nextIndex = forwards ? currentIndex + 1 : currentIndex - 1;
76
+ // Search for the next sibling that is not disabled to select.
77
+ // If we return to the host index, there is nothing to select.
78
+ while (nextIndex !== currentIndex) {
79
+ if (nextIndex >= chips.length) {
80
+ // Return to start if moving past the last item.
81
+ nextIndex = 0;
82
+ }
83
+ else if (nextIndex < 0) {
84
+ // Go to end if moving before the first item.
85
+ nextIndex = chips.length - 1;
86
+ }
87
+ // Check if the next sibling is disabled. If so,
88
+ // move the index and continue searching.
89
+ //
90
+ // Some toolbar items may be focusable when disabled for increased
91
+ // visibility.
92
+ const nextChip = chips[nextIndex];
93
+ if (nextChip.disabled) {
94
+ if (forwards) {
95
+ nextIndex++;
96
+ }
97
+ else {
98
+ nextIndex--;
99
+ }
100
+ continue;
101
+ }
102
+ nextChip.focus({ trailing: !forwards });
103
+ this.updateTabIndices();
104
+ break;
105
+ }
106
+ }
107
+ updateTabIndices() {
108
+ // The chip that should be focusable is either the chip that currently has
109
+ // focus or the first chip that can be focused.
110
+ const { chips } = this;
111
+ let chipToFocus;
112
+ for (const chip of chips) {
113
+ const isChipFocusable = !chip.disabled;
114
+ const chipIsFocused = chip.matches(':focus-within');
115
+ if (chipIsFocused && isChipFocusable) {
116
+ // Found the first chip that is actively focused. This overrides the
117
+ // first focusable chip found.
118
+ chipToFocus = chip;
119
+ continue;
120
+ }
121
+ if (isChipFocusable && !chipToFocus) {
122
+ chipToFocus = chip;
123
+ }
124
+ // Disable non-focused chips. If we disable all of them, we'll grant focus
125
+ // to the first focusable child that was found.
126
+ chip.tabIndex = -1;
127
+ }
128
+ if (chipToFocus) {
129
+ chipToFocus.tabIndex = 0;
130
+ }
131
+ }
132
+ };
133
+ })();
134
+ /**
135
+ * A chip set component.
136
+ */
137
+ export default ChipSet;
138
+ //# sourceMappingURL=ChipSet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChipSet.js","sourceRoot":"","sources":["../../../../../src/md/chip/internals/ChipSet.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AACtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAEzD,OAAO,IAAI,MAAM,WAAW,CAAA;;sBAKS,UAAU;;;;iBAA1B,OAAQ,SAAQ,WAAU;;;yCAK5C,qBAAqB,EAAE;YAAC,4LAAiB,aAAa,6BAAb,aAAa,qGAAgB;;;QAJvE,IAAI,KAAK;YACP,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,KAAK,EAAiB,EAAE,CAAC,KAAK,YAAY,IAAI,CAAC,CAAA;QACnF,CAAC;QAEwB,+FAA8C;QAA9C,IAAiB,aAAa,mDAAgB;QAA9C,IAAiB,aAAa,yDAAgB;QACtD,SAAS,+DAAG,IAAI,CAAC,eAAe,EAAE,EAAA;QAEnD;YACE,KAAK,EAAE,CAAA;YACP,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;YAClE,IAAI,CAAC,gBAAgB,CAAC,cAAc,EAAE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;YACvE,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;YAC/D,IAAI,CAAC,SAAS,CAAC,IAAI,GAAG,SAAS,CAAA;QACjC,CAAC;QAEQ,iBAAiB;YACxB,KAAK,CAAC,iBAAi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AQ,CAAC,QAAQ,EAAE,CAAC;oBACtB,IAAI,QAAQ,EAAE,CAAC;wBACb,SAAS,EAAE,CAAA;oBACb,CAAC;yBAAM,CAAC;wBACN,SAAS,EAAE,CAAA;oBACb,CAAC;oBAED,SAAQ;gBACV,CAAC;gBAED,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAA;gBACvC,IAAI,CAAC,gBAAgB,EAAE,CAAA;gBACvB,MAAK;YACP,CAAC;QACH,CAAC;QAEO,gBAAgB;YACtB,0EAA0E;YAC1E,+CAA+C;YAC/C,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAA;YACtB,IAAI,WAA6B,CAAA;YACjC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,MAAM,eAAe,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAA;gBACtC,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,CAAA;gBACnD,IAAI,aAAa,IAAI,eAAe,EAAE,CAAC;oBACrC,oEAAoE;oBACpE,8BAA8B;oBAC9B,WAAW,GAAG,IAAI,CAAA;oBAClB,SAAQ;gBACV,CAAC;gBAED,IAAI,eAAe,IAAI,CAAC,WAAW,EAAE,CAAC;oBACpC,WAAW,GAAG,IAAI,CAAA;gBACpB,CAAC;gBAED,0EAA0E;gBAC1E,+CAA+C;gBAC/C,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAA;YACpB,CAAC;YAED,IAAI,WAAW,EAAE,CAAC;gBAChB,WAAW,CAAC,QAAQ,GAAG,CAAC,CAAA;YAC1B,CAAC;QACH,CAAC;;;AAnIH;;GAEG;AACH,uBAiIC","sourcesContent":["import { html, LitElement } from 'lit'\nimport { queryAssignedElements } from 'lit/decorators.js'\n\nimport Chip from './Chip.js'\n\n/**\n * A chip set component.\n */\nexport default class ChipSet extends LitElement {\n get chips() {\n return this.childElements.filter((child): child is Chip => child instanceof Chip)\n }\n\n @queryAssignedElements() private accessor childElements!: HTMLElement[]\n private readonly internals = this.attachInternals()\n\n constructor() {\n super()\n this.addEventListener('focusin', this.updateTabIndices.bind(this))\n this.addEventListener('update-focus', this.updateTabIndices.bind(this))\n this.addEventListener('keydown', this.handleKeyDown.bind(this))\n this.internals.role = 'toolbar'\n }\n\n override connectedCallback(): void {\n super.connectedCallback()\n if (!this.hasAttribute('role')) {\n this.setAttribute('role', 'toolbar')\n }\n }\n\n protected override render() {\n return html`<slot @slotchange=${this.updateTabIndices}></slot>`\n }\n\n private handleKeyDown(event: KeyboardEvent) {\n const isLeft = event.key === 'ArrowLeft'\n const isRight = event.key === 'ArrowRight'\n const isHome = event.key === 'Home'\n const isEnd = event.key === 'End'\n // Ignore non-navigation keys\n if (!isLeft && !isRight && !isHome && !isEnd) {\n return\n }\n\n const { chips } = this as { chips: MaybeMultiActionChip[] }\n // Don't try to select another chip if there aren't any.\n if (chips.length < 2) {\n return\n }\n\n // Prevent default interactions, such as scrolling.\n event.preventDefault()\n\n if (isHome || isEnd) {\n const index = isHome ? 0 : chips.length - 1\n chips[index].focus({ trailing: isEnd })\n this.updateTabIndices()\n return\n }\n\n // Check if moving forwards or backwards\n const isRtl = getComputedStyle(this).direction === 'rtl'\n const forwards = isRtl ? isLeft : isRight\n const focusedChip = chips.find((chip) => chip.matches(':focus-within'))\n if (!focusedChip) {\n // If there is not already a chip focused, select the first or last chip\n // based on the direction we're traveling.\n const nextChip = forwards ? chips[0] : chips[chips.length - 1]\n nextChip.focus({ trailing: !forwards })\n this.updateTabIndices()\n return\n }\n\n const currentIndex = chips.indexOf(focusedChip)\n let nextIndex = forwards ? currentIndex + 1 : currentIndex - 1\n // Search for the next sibling that is not disabled to select.\n // If we return to the host index, there is nothing to select.\n while (nextIndex !== currentIndex) {\n if (nextIndex >= chips.length) {\n // Return to start if moving past the last item.\n nextIndex = 0\n } else if (nextIndex < 0) {\n // Go to end if moving before the first item.\n nextIndex = chips.length - 1\n }\n\n // Check if the next sibling is disabled. If so,\n // move the index and continue searching.\n //\n // Some toolbar items may be focusable when disabled for increased\n // visibility.\n const nextChip = chips[nextIndex]\n if (nextChip.disabled) {\n if (forwards) {\n nextIndex++\n } else {\n nextIndex--\n }\n\n continue\n }\n\n nextChip.focus({ trailing: !forwards })\n this.updateTabIndices()\n break\n }\n }\n\n private updateTabIndices() {\n // The chip that should be focusable is either the chip that currently has\n // focus or the first chip that can be focused.\n const { chips } = this\n let chipToFocus: Chip | undefined\n for (const chip of chips) {\n const isChipFocusable = !chip.disabled\n const chipIsFocused = chip.matches(':focus-within')\n if (chipIsFocused && isChipFocusable) {\n // Found the first chip that is actively focused. This overrides the\n // first focusable chip found.\n chipToFocus = chip\n continue\n }\n\n if (isChipFocusable && !chipToFocus) {\n chipToFocus = chip\n }\n\n // Disable non-focused chips. If we disable all of them, we'll grant focus\n // to the first focusable child that was found.\n chip.tabIndex = -1\n }\n\n if (chipToFocus) {\n chipToFocus.tabIndex = 0\n }\n }\n}\n\ninterface MaybeMultiActionChip extends Chip {\n focus(options?: FocusOptions & { trailing?: boolean }): void\n}\n"]}
@@ -0,0 +1,3 @@
1
+ declare const _default: import("lit").CSSResult;
2
+ export default _default;
3
+ //# sourceMappingURL=ChipSet.styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChipSet.styles.d.ts","sourceRoot":"","sources":["../../../../../src/md/chip/internals/ChipSet.styles.ts"],"names":[],"mappings":";AAEA,wBAMC"}
@@ -0,0 +1,9 @@
1
+ import { css } from 'lit';
2
+ export default css `
3
+ :host {
4
+ display: flex;
5
+ flex-wrap: wrap;
6
+ gap: 8px;
7
+ }
8
+ `;
9
+ //# sourceMappingURL=ChipSet.styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChipSet.styles.js","sourceRoot":"","sources":["../../../../../src/md/chip/internals/ChipSet.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAEzB,eAAe,GAAG,CAAA;;;;;;CAMjB,CAAA","sourcesContent":["import { css } from 'lit'\n\nexport default css`\n :host {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n }\n`\n"]}
@@ -0,0 +1,11 @@
1
+ import type { CSSResultOrNative } from 'lit';
2
+ import Element from './internals/ChipSet.js';
3
+ export declare class UiChipSetElement extends Element {
4
+ static styles: CSSResultOrNative[];
5
+ }
6
+ declare global {
7
+ interface HTMLElementTagNameMap {
8
+ 'ui-chip-set': UiChipSetElement;
9
+ }
10
+ }
11
+ //# sourceMappingURL=ui-chip-set.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui-chip-set.d.ts","sourceRoot":"","sources":["../../../../src/md/chip/ui-chip-set.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,KAAK,CAAA;AAE5C,OAAO,OAAO,MAAM,wBAAwB,CAAA;AAG5C,qBACa,gBAAiB,SAAQ,OAAO;IAC3C,OAAgB,MAAM,EAAE,iBAAiB,EAAE,CAAW;CACvD;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,aAAa,EAAE,gBAAgB,CAAA;KAChC;CACF"}