@quartzds/core 1.0.0-beta.21 → 1.0.0-beta.23

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 (123) hide show
  1. package/components/icon.js +3 -0
  2. package/components/icon.js.map +1 -1
  3. package/components/index.js.map +1 -1
  4. package/components/label.js +1 -1
  5. package/components/label.js.map +1 -1
  6. package/components/qds-button.js +28 -29
  7. package/components/qds-button.js.map +1 -1
  8. package/components/qds-checkbox.js +1 -1
  9. package/components/qds-checkbox.js.map +1 -1
  10. package/components/qds-dialog.js +2 -0
  11. package/components/qds-dialog.js.map +1 -1
  12. package/components/qds-dropdown.js +11 -1
  13. package/components/qds-dropdown.js.map +1 -1
  14. package/components/qds-inline-link.js +1 -1
  15. package/components/qds-inline-link.js.map +1 -1
  16. package/components/qds-input.js +6 -2
  17. package/components/qds-input.js.map +1 -1
  18. package/components/qds-radio.js +5 -2
  19. package/components/qds-radio.js.map +1 -1
  20. package/components/qds-select.js +8 -2
  21. package/components/qds-select.js.map +1 -1
  22. package/components/qds-switch.js +1 -1
  23. package/components/qds-switch.js.map +1 -1
  24. package/components/qds-textarea.js +5 -2
  25. package/components/qds-textarea.js.map +1 -1
  26. package/components/qds-tooltip.js +14 -1
  27. package/components/qds-tooltip.js.map +1 -1
  28. package/dist/cjs/{index-210f861c.js → index-54d11f50.js} +187 -72
  29. package/dist/cjs/index-54d11f50.js.map +1 -0
  30. package/dist/cjs/index.cjs.js +2 -2
  31. package/dist/cjs/index.cjs.js.map +1 -1
  32. package/dist/cjs/{library-4a3613dd.js → library-4c55a413.js} +2 -2
  33. package/dist/cjs/{library-4a3613dd.js.map → library-4c55a413.js.map} +1 -1
  34. package/dist/cjs/loader.cjs.js +2 -2
  35. package/dist/cjs/qds-button.cjs.entry.js +28 -29
  36. package/dist/cjs/qds-button.cjs.entry.js.map +1 -1
  37. package/dist/cjs/qds-checkbox.cjs.entry.js +2 -2
  38. package/dist/cjs/qds-checkbox.cjs.entry.js.map +1 -1
  39. package/dist/cjs/qds-dialog.cjs.entry.js +1 -1
  40. package/dist/cjs/qds-divider.cjs.entry.js +1 -1
  41. package/dist/cjs/qds-dropdown.cjs.entry.js +1 -1
  42. package/dist/cjs/qds-form-message.cjs.entry.js +1 -1
  43. package/dist/cjs/qds-icon.cjs.entry.js +2 -2
  44. package/dist/cjs/qds-inline-link.cjs.entry.js +2 -2
  45. package/dist/cjs/qds-inline-link.cjs.entry.js.map +1 -1
  46. package/dist/cjs/qds-input.cjs.entry.js +3 -3
  47. package/dist/cjs/qds-input.cjs.entry.js.map +1 -1
  48. package/dist/cjs/qds-label.cjs.entry.js +2 -2
  49. package/dist/cjs/qds-label.cjs.entry.js.map +1 -1
  50. package/dist/cjs/qds-radio.cjs.entry.js +6 -3
  51. package/dist/cjs/qds-radio.cjs.entry.js.map +1 -1
  52. package/dist/cjs/qds-select.cjs.entry.js +6 -3
  53. package/dist/cjs/qds-select.cjs.entry.js.map +1 -1
  54. package/dist/cjs/qds-switch.cjs.entry.js +2 -2
  55. package/dist/cjs/qds-switch.cjs.entry.js.map +1 -1
  56. package/dist/cjs/qds-table-body.cjs.entry.js +1 -1
  57. package/dist/cjs/qds-table-cell.cjs.entry.js +1 -1
  58. package/dist/cjs/qds-table-head-cell.cjs.entry.js +1 -1
  59. package/dist/cjs/qds-table-head.cjs.entry.js +1 -1
  60. package/dist/cjs/qds-table-row.cjs.entry.js +1 -1
  61. package/dist/cjs/qds-table.cjs.entry.js +1 -1
  62. package/dist/cjs/qds-textarea.cjs.entry.js +3 -3
  63. package/dist/cjs/qds-textarea.cjs.entry.js.map +1 -1
  64. package/dist/cjs/qds-title.cjs.entry.js +1 -1
  65. package/dist/cjs/qds-tooltip.cjs.entry.js +1 -1
  66. package/dist/cjs/qds.cjs.js +3 -3
  67. package/dist/cjs/qds.cjs.js.map +1 -1
  68. package/dist/custom-elements.json +45 -19
  69. package/dist/docs.json +34 -20
  70. package/dist/esm/{index-7b820913.js → index-5d80e9c2.js} +187 -72
  71. package/dist/esm/index-5d80e9c2.js.map +1 -0
  72. package/dist/esm/index.js +2 -2
  73. package/dist/esm/index.js.map +1 -1
  74. package/dist/esm/{library-68f03bea.js → library-376fa462.js} +2 -2
  75. package/dist/esm/{library-68f03bea.js.map → library-376fa462.js.map} +1 -1
  76. package/dist/esm/loader.js +3 -3
  77. package/dist/esm/qds-button.entry.js +28 -29
  78. package/dist/esm/qds-button.entry.js.map +1 -1
  79. package/dist/esm/qds-checkbox.entry.js +2 -2
  80. package/dist/esm/qds-checkbox.entry.js.map +1 -1
  81. package/dist/esm/qds-dialog.entry.js +1 -1
  82. package/dist/esm/qds-divider.entry.js +1 -1
  83. package/dist/esm/qds-dropdown.entry.js +1 -1
  84. package/dist/esm/qds-form-message.entry.js +1 -1
  85. package/dist/esm/qds-icon.entry.js +2 -2
  86. package/dist/esm/qds-inline-link.entry.js +2 -2
  87. package/dist/esm/qds-inline-link.entry.js.map +1 -1
  88. package/dist/esm/qds-input.entry.js +3 -3
  89. package/dist/esm/qds-input.entry.js.map +1 -1
  90. package/dist/esm/qds-label.entry.js +2 -2
  91. package/dist/esm/qds-label.entry.js.map +1 -1
  92. package/dist/esm/qds-radio.entry.js +6 -3
  93. package/dist/esm/qds-radio.entry.js.map +1 -1
  94. package/dist/esm/qds-select.entry.js +6 -3
  95. package/dist/esm/qds-select.entry.js.map +1 -1
  96. package/dist/esm/qds-switch.entry.js +2 -2
  97. package/dist/esm/qds-switch.entry.js.map +1 -1
  98. package/dist/esm/qds-table-body.entry.js +1 -1
  99. package/dist/esm/qds-table-cell.entry.js +1 -1
  100. package/dist/esm/qds-table-head-cell.entry.js +1 -1
  101. package/dist/esm/qds-table-head.entry.js +1 -1
  102. package/dist/esm/qds-table-row.entry.js +1 -1
  103. package/dist/esm/qds-table.entry.js +1 -1
  104. package/dist/esm/qds-textarea.entry.js +3 -3
  105. package/dist/esm/qds-textarea.entry.js.map +1 -1
  106. package/dist/esm/qds-title.entry.js +1 -1
  107. package/dist/esm/qds-tooltip.entry.js +1 -1
  108. package/dist/esm/qds.js +4 -4
  109. package/dist/esm/qds.js.map +1 -1
  110. package/dist/types/components/button/button.d.ts +1 -1
  111. package/dist/types/components/input/input.d.ts +1 -1
  112. package/dist/types/components/label/label.d.ts +1 -1
  113. package/dist/types/components/radio/radio.d.ts +2 -1
  114. package/dist/types/components/select/select.d.ts +2 -1
  115. package/dist/types/components/textarea/textarea.d.ts +1 -1
  116. package/dist/types/components.d.ts +158 -6
  117. package/dist/types/qds-test.d.ts +13 -2
  118. package/dist/types/stencil-public-runtime.d.ts +21 -0
  119. package/hydrate/index.js +135 -100
  120. package/package.json +30 -63
  121. package/dist/cjs/index-210f861c.js.map +0 -1
  122. package/dist/esm/index-7b820913.js.map +0 -1
  123. package/dist/types/components/create-story.d.ts +0 -5
@@ -168,6 +168,9 @@ const Icon = /*@__PURE__*/ proxyCustomElement(class Icon extends HTMLElement {
168
168
  "name": [513],
169
169
  "library": [513],
170
170
  "svg": [32]
171
+ }, undefined, {
172
+ "name": ["setIcon"],
173
+ "library": ["setIcon"]
171
174
  }]);
172
175
  function defineCustomElement() {
173
176
  if (typeof customElements === "undefined") {
@@ -1 +1 @@
1
- {"file":"icon.js","mappings":";;;;;;;;AAAA,MAAM,wBAAwB,GAAG,oTAAoT;;ACArV,MAAM,YAAY,GAAG,wOAAwO;;ACA7P,MAAM,QAAQ,GAAG,4NAA4N;;ACA7O,MAAM,cAAc,GAAG,gdAAgd;;ACAve,MAAM,cAAc,GAAG,geAAge;;ACAvf,MAAM,QAAQ,GAAG,gKAAgK;;ACAjL,MAAM,QAAQ,GAAG,oSAAoS;;ACArT;AAmBA,MAAM,KAAK,GAAuC;;EAEhD,eAAe,EAAEA,wBAAY;WAC7BC,QAAO;iBACPC,QAAa;EACb,QAAQ,EAAEC,YAAS;EACnB,cAAc,EAAEC,QAAW;EAC3B,aAAa,EAAEC,cAAU;EACzB,gBAAgB,EAAEJ,QAAO;EACzB,gBAAgB,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AAC,OAAO,CAAC,EAAE,EAAE;QACf,IAAI,CAAC,GAAG,GAAG,EAAE,CAAA;QACb,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,CAAA;QACxB,OAAM;OACP;;;;MAKD,MAAM,KAAN,MAAM,GAAK,IAAI,SAAS,EAAE,EAAA;MAC1B,MAAM,QAAQ,GAAG,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,CAAA;MAClE,MAAM,UAAU,GAAG,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;MACrD,IAAI,UAAU,KAAK,IAAI,EAAE;QACvB,IAAI,CAAC,GAAG,GAAG,EAAE,CAAA;QACb,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,CAAA;OACzB;WAAM;QACL,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,mBAAmB,CAAC;UACjE,UAAU,CAAC,YAAY,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QACrC,IAAI,CAAC,GAAG,GAAG,UAAU,CAAC,SAAS,CAAA;QAC/B,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAA;OACxB;KACF;IAAC,MAAM;MACN,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,CAAA;KACzB;GACF;EAEM,MAAM,iBAAiB;IAC5B,IAAI,CAAC,mBAAmB,GAAG,qBAAqB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAC9D,MAAM,IAAI,CAAC,OAAO,EAAE,CAAA;GACrB;EAEM,MAAM;IACX,OAAO,YAAM,KAAK,EAAC,aAAa,EAAC,SAAS,EAAE,IAAI,CAAC,GAAG,GAAI,CAAA;GACzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["externalLink","checked","indeterminate","caretDown","statusError","statusInfo","statusWarning","defaultLibrary"],"sources":["../../node_modules/@quartzds/generic-icons-core/dist/arrow-top-right-on-square.svg","../../node_modules/@quartzds/generic-icons-core/dist/caret-down.svg","../../node_modules/@quartzds/generic-icons-core/dist/check.svg","../../node_modules/@quartzds/generic-icons-core/dist/exclamation.svg","../../node_modules/@quartzds/generic-icons-core/dist/information.svg","../../node_modules/@quartzds/generic-icons-core/dist/minus.svg","../../node_modules/@quartzds/generic-icons-core/dist/x-mark.svg","src/components/icon/core-library.ts","src/components/icon/default-library.ts","src/components/icon/library.ts","src/components/icon/request.ts","src/components/icon/icon.css?tag=qds-icon&encapsulation=shadow","src/components/icon/icon.tsx"],"sourcesContent":["<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\"><path d=\"M12.03 13.01H3.02v-9h5.97v-1H2.03v11h10.99V6.98h-.99v6.03ZM10.99 1.98v1h1.36L9.1 6.23l.71.7 3.16-3.16-.01 1.21 1 .01.04-3.01h-3.01Z\"/></svg>","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\"><path d=\"M8 11 1.95 5.04 14.09 5 8 11.01V11ZM4.38 6.03 8 9.6l3.64-3.59-7.27.02h.01Z\"/></svg>","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\"><path d=\"M6.31 11.86 3.08 8.63l.71-.71 2.52 2.52 5.9-5.94.71.7-6.61 6.66Z\"/></svg>","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\"><path d=\"M7.129 12.06a.83.83 0 0 1 .239-.612c.16-.157.378-.246.667-.246.289 0 .498.079.667.246.16.158.239.365.239.611s-.08.434-.24.591c-.158.158-.377.237-.666.237-.289 0-.508-.08-.667-.237a.797.797 0 0 1-.24-.59Zm1.573-2.04H7.328l-.15-6.68h1.683l-.16 6.68Z\"/></svg>","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\"><path d=\"M6.18 13.12v-.25c.95-.16.99-.24.99-1.51V7.97c0-1.04-.06-1.11-.82-1.32v-.21c.88-.12 1.73-.33 2.48-.62-.02.35-.03 1.32-.03 2.01v3.53c0 1.25.09 1.33 1.02 1.51v.25H6.18Zm1.69-8.36c-.48 0-.9-.41-.9-.94 0-.56.42-.94.92-.94.54 0 .94.38.94.94 0 .56-.4.94-.95.94h-.01Z\"/></svg>","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\"><path d=\"M13 7.5H3.01v1H13v-1Z\"/></svg>","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\"><path d=\"m11.43 5.26-.71-.7-2.74 2.76-2.73-2.76-.71.7 2.74 2.77-2.74 2.77.71.71 2.73-2.77 2.74 2.77.71-.71-2.74-2.77 2.74-2.77Z\"/></svg>","// SPDX-FileCopyrightText: © 2023 Schneider Electric\n//\n// SPDX-License-Identifier: LGPL-2.1-only\n\n// FIXME: TypeScript and Webpack can resolve exports from the package.json\n// `exports` field but Rollup can't. `@quartzds/generic-icons-core/*.svg`\n// _should_ work but it doesn't.\n/* eslint-disable import/no-unresolved */\nimport externalLink from '@quartzds/generic-icons-core/dist/arrow-top-right-on-square.svg'\nimport caretDown from '@quartzds/generic-icons-core/dist/caret-down.svg'\nimport checked from '@quartzds/generic-icons-core/dist/check.svg'\nimport statusWarning from '@quartzds/generic-icons-core/dist/exclamation.svg'\nimport statusInfo from '@quartzds/generic-icons-core/dist/information.svg'\nimport indeterminate from '@quartzds/generic-icons-core/dist/minus.svg'\nimport statusError from '@quartzds/generic-icons-core/dist/x-mark.svg'\n\n/* eslint-enable import/no-unresolved */\nimport type { IconLibrary } from './library'\n\nconst icons: Record<string, string | undefined> = {\n /* eslint-disable @typescript-eslint/naming-convention */\n 'external-link': externalLink,\n checked,\n indeterminate,\n dropdown: caretDown,\n 'status-error': statusError,\n 'status-info': statusInfo,\n 'status-success': checked,\n 'status-warning': statusWarning,\n /* eslint-enable @typescript-eslint/naming-convention */\n}\n\nconst coreLibrary: IconLibrary = {\n name: 'core',\n resolver: (name) => icons[name] ?? '',\n}\n\nexport default coreLibrary\n","// SPDX-FileCopyrightText: © 2023 Schneider Electric\n//\n// SPDX-License-Identifier: LGPL-2.1-only\n\nimport { getAssetPath } from '@stencil/core'\n\nimport type { IconLibrary } from './library'\n\nconst library: IconLibrary = {\n name: 'default',\n resolver: (name) => getAssetPath(`icons/${name}.svg`),\n}\n\nexport default library\n","// SPDX-FileCopyrightText: © 2023 Schneider Electric\n//\n// SPDX-License-Identifier: LGPL-2.1-only\n\nimport type { Except } from 'type-fest'\n\nimport coreLibrary from './core-library'\nimport defaultLibrary from './default-library'\n\nexport type IconLibraryResolver = (name: string) => string\nexport interface IconLibrary {\n name: string\n resolver: IconLibraryResolver\n}\n\nlet registry: IconLibrary[] = [defaultLibrary, coreLibrary]\n\n/**\n * Returns a library from the registry.\n */\nexport const getIconLibrary = (name: string): IconLibrary | undefined =>\n registry.find((library) => library.name === name)\n\n/**\n * Removes an icon library from the registry.\n */\nexport const unregisterIconLibrary = (name: string): void => {\n registry = registry.filter((library) => library.name !== name)\n}\n\n/**\n * Adds an icon library to the registry or overrides an existing one.\n */\nexport const registerIconLibrary = (\n name: string,\n options: Except<IconLibrary, 'name'>,\n): void => {\n unregisterIconLibrary(name)\n registry.push({\n name,\n ...options,\n })\n}\n","// SPDX-FileCopyrightText: © 2023 Schneider Electric\n//\n// SPDX-License-Identifier: LGPL-2.1-only\n\ninterface Request {\n ok: boolean\n data: string\n}\n\ninterface IconRequestOk {\n ok: true\n data: string\n}\n\ninterface IconRequestError {\n ok: false\n data: undefined\n}\n\ntype IconRequest = IconRequestError | IconRequestOk\n\ninterface IconRequestUnknown {\n ok: boolean\n data?: string\n}\n\nconst request = async (source: string): Promise<Request> => {\n const response = await fetch(source, { mode: 'cors' })\n return {\n ok: response.ok,\n data: await response.text(),\n }\n}\n\nconst cachedIconRequests = new Map<string, IconRequest>()\n\nconst requestIcon = async (url: string): Promise<IconRequest> => {\n const cachedIconRequest = cachedIconRequests.get(url)\n if (cachedIconRequest) return cachedIconRequest\n\n const fileData = await request(url)\n const iconFileData: IconRequestUnknown = {\n ok: fileData.ok,\n }\n if (fileData.ok) {\n const div = document.createElement('div')\n div.innerHTML = fileData.data\n const child = div.firstElementChild\n iconFileData.data =\n child?.tagName.toLowerCase() === 'svg' ? child.outerHTML : ''\n }\n\n cachedIconRequests.set(url, iconFileData as IconRequest)\n return iconFileData as IconRequest\n}\n\nexport default requestIcon\n","/*\n * SPDX-FileCopyrightText: © 2023 Schneider Electric\n *\n * SPDX-License-Identifier: LGPL-2.1-only\n */\n\n@import url('../shared.css');\n\n:host {\n contain: strict;\n display: inline-block;\n height: 1em;\n width: 1em;\n}\n\n.qds-wrapper {\n display: contents;\n}\n\nsvg {\n display: block;\n fill: currentcolor;\n height: 100%;\n width: 100%;\n}\n","// SPDX-FileCopyrightText: © 2023 Schneider Electric\n//\n// SPDX-License-Identifier: LGPL-2.1-only\n\nimport type { ComponentInterface, EventEmitter } from '@stencil/core'\nimport { Component, Element, Event, h, Prop, State, Watch } from '@stencil/core'\n\nimport type { Attributes } from '../../helpers'\nimport { inheritAriaAttributes } from '../../helpers'\nimport { getIconLibrary } from './library'\nimport requestIcon from './request'\n\nlet parser: DOMParser | undefined\n\n/**\n * @experimental\n */\n@Component({\n tag: 'qds-icon',\n shadow: true,\n styleUrl: 'icon.css',\n})\nexport class Icon implements ComponentInterface {\n /**\n * The name of the icon to render.\n *\n * Available names depend on the icon library being used.\n */\n @Prop({ reflect: true }) public readonly name!: string\n\n /**\n * The name of a registered icon library.\n */\n @Prop({ reflect: true }) public readonly library: string = 'default'\n\n /**\n * Emitted when the icon has loaded.\n */\n @Event({ eventName: 'qdsLoad', cancelable: false })\n private readonly loadEmitter!: EventEmitter<void>\n\n /**\n * Emitted when the icon fails to load due to an error.\n */\n @Event({ eventName: 'qdsError', cancelable: false })\n private readonly errorEmitter!: EventEmitter<void>\n\n @Element() private readonly element!: HTMLQdsIconElement\n\n @State() private svg = ''\n\n private inheritedAttributes: Attributes = {}\n\n @Watch('name')\n @Watch('library')\n private async setIcon(): Promise<void> {\n if (!this.name) return\n\n const library = getIconLibrary(this.library)\n if (!library) return\n\n const url = library.resolver(this.name)\n if (!url) {\n this.svg = ''\n return\n }\n\n try {\n const request = await requestIcon(url)\n if (!request.ok) {\n this.svg = ''\n this.errorEmitter.emit()\n return\n }\n\n // Create an instance of the DOM parser. We do it here instead of at the\n // top-level to support SSR while maintaining a single parser instance\n // for optimal performance.\n parser ||= new DOMParser()\n const document = parser.parseFromString(request.data, 'text/html')\n const svgElement = document.body.querySelector('svg')\n if (svgElement === null) {\n this.svg = ''\n this.errorEmitter.emit()\n } else {\n for (const [key, value] of Object.entries(this.inheritedAttributes))\n svgElement.setAttribute(key, value)\n this.svg = svgElement.outerHTML\n this.loadEmitter.emit()\n }\n } catch {\n this.errorEmitter.emit()\n }\n }\n\n public async componentWillLoad(): Promise<void> {\n this.inheritedAttributes = inheritAriaAttributes(this.element)\n await this.setIcon()\n }\n\n public render() {\n return <span class=\"qds-wrapper\" innerHTML={this.svg} />\n }\n}\n"],"version":3}
1
+ {"file":"icon.js","mappings":";;;;;;;;AAAA,MAAM,wBAAwB,GAAG,oTAAoT;;ACArV,MAAM,YAAY,GAAG,wOAAwO;;ACA7P,MAAM,QAAQ,GAAG,4NAA4N;;ACA7O,MAAM,cAAc,GAAG,gdAAgd;;ACAve,MAAM,cAAc,GAAG,geAAge;;ACAvf,MAAM,QAAQ,GAAG,gKAAgK;;ACAjL,MAAM,QAAQ,GAAG,oSAAoS;;ACArT;AAmBA,MAAM,KAAK,GAAuC;;EAEhD,eAAe,EAAEA,wBAAY;WAC7BC,QAAO;iBACPC,QAAa;EACb,QAAQ,EAAEC,YAAS;EACnB,cAAc,EAAEC,QAAW;EAC3B,aAAa,EAAEC,cAAU;EACzB,gBAAgB,EAAEJ,QAAO;EACzB,gBAAgB,EAAEK,cAAa;;CAEhC,CAAA;AAED,MAAM,WAAW,GAAgB;EAC/B,IAAI,EAAE,MAAM;EACZ,QAAQ,EAAE,CA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IAAI,EAAE,CAAA;QACxB,OAAM;OACP;;;;MAKD,MAAM,KAAN,MAAM,GAAK,IAAI,SAAS,EAAE,EAAA;MAC1B,MAAM,QAAQ,GAAG,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,CAAA;MAClE,MAAM,UAAU,GAAG,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;MACrD,IAAI,UAAU,KAAK,IAAI,EAAE;QACvB,IAAI,CAAC,GAAG,GAAG,EAAE,CAAA;QACb,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,CAAA;OACzB;WAAM;QACL,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,mBAAmB,CAAC;UACjE,UAAU,CAAC,YAAY,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QACrC,IAAI,CAAC,GAAG,GAAG,UAAU,CAAC,SAAS,CAAA;QAC/B,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAA;OACxB;KACF;IAAC,MAAM;MACN,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,CAAA;KACzB;GACF;EAEM,MAAM,iBAAiB;IAC5B,IAAI,CAAC,mBAAmB,GAAG,qBAAqB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAC9D,MAAM,IAAI,CAAC,OAAO,EAAE,CAAA;GACrB;EAEM,MAAM;IACX,OAAO,YAAM,KAAK,EAAC,aAAa,EAAC,SAAS,EAAE,IAAI,CAAC,GAAG,GAAI,CAAA;GACzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["externalLink","checked","indeterminate","caretDown","statusError","statusInfo","statusWarning","defaultLibrary"],"sources":["../../node_modules/@quartzds/generic-icons-core/dist/arrow-top-right-on-square.svg","../../node_modules/@quartzds/generic-icons-core/dist/caret-down.svg","../../node_modules/@quartzds/generic-icons-core/dist/check.svg","../../node_modules/@quartzds/generic-icons-core/dist/exclamation.svg","../../node_modules/@quartzds/generic-icons-core/dist/information.svg","../../node_modules/@quartzds/generic-icons-core/dist/minus.svg","../../node_modules/@quartzds/generic-icons-core/dist/x-mark.svg","src/components/icon/core-library.ts","src/components/icon/default-library.ts","src/components/icon/library.ts","src/components/icon/request.ts","src/components/icon/icon.css?tag=qds-icon&encapsulation=shadow","src/components/icon/icon.tsx"],"sourcesContent":["<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\"><path d=\"M12.03 13.01H3.02v-9h5.97v-1H2.03v11h10.99V6.98h-.99v6.03ZM10.99 1.98v1h1.36L9.1 6.23l.71.7 3.16-3.16-.01 1.21 1 .01.04-3.01h-3.01Z\"/></svg>","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\"><path d=\"M8 11 1.95 5.04 14.09 5 8 11.01V11ZM4.38 6.03 8 9.6l3.64-3.59-7.27.02h.01Z\"/></svg>","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\"><path d=\"M6.31 11.86 3.08 8.63l.71-.71 2.52 2.52 5.9-5.94.71.7-6.61 6.66Z\"/></svg>","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\"><path d=\"M7.129 12.06a.83.83 0 0 1 .239-.612c.16-.157.378-.246.667-.246.289 0 .498.079.667.246.16.158.239.365.239.611s-.08.434-.24.591c-.158.158-.377.237-.666.237-.289 0-.508-.08-.667-.237a.797.797 0 0 1-.24-.59Zm1.573-2.04H7.328l-.15-6.68h1.683l-.16 6.68Z\"/></svg>","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\"><path d=\"M6.18 13.12v-.25c.95-.16.99-.24.99-1.51V7.97c0-1.04-.06-1.11-.82-1.32v-.21c.88-.12 1.73-.33 2.48-.62-.02.35-.03 1.32-.03 2.01v3.53c0 1.25.09 1.33 1.02 1.51v.25H6.18Zm1.69-8.36c-.48 0-.9-.41-.9-.94 0-.56.42-.94.92-.94.54 0 .94.38.94.94 0 .56-.4.94-.95.94h-.01Z\"/></svg>","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\"><path d=\"M13 7.5H3.01v1H13v-1Z\"/></svg>","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\"><path d=\"m11.43 5.26-.71-.7-2.74 2.76-2.73-2.76-.71.7 2.74 2.77-2.74 2.77.71.71 2.73-2.77 2.74 2.77.71-.71-2.74-2.77 2.74-2.77Z\"/></svg>","// SPDX-FileCopyrightText: © 2023 Schneider Electric\n//\n// SPDX-License-Identifier: LGPL-2.1-only\n\n// FIXME: TypeScript and Webpack can resolve exports from the package.json\n// `exports` field but Rollup can't. `@quartzds/generic-icons-core/*.svg`\n// _should_ work but it doesn't.\n/* eslint-disable import/no-unresolved */\nimport externalLink from '@quartzds/generic-icons-core/dist/arrow-top-right-on-square.svg'\nimport caretDown from '@quartzds/generic-icons-core/dist/caret-down.svg'\nimport checked from '@quartzds/generic-icons-core/dist/check.svg'\nimport statusWarning from '@quartzds/generic-icons-core/dist/exclamation.svg'\nimport statusInfo from '@quartzds/generic-icons-core/dist/information.svg'\nimport indeterminate from '@quartzds/generic-icons-core/dist/minus.svg'\nimport statusError from '@quartzds/generic-icons-core/dist/x-mark.svg'\n\n/* eslint-enable import/no-unresolved */\nimport type { IconLibrary } from './library'\n\nconst icons: Record<string, string | undefined> = {\n /* eslint-disable @typescript-eslint/naming-convention */\n 'external-link': externalLink,\n checked,\n indeterminate,\n dropdown: caretDown,\n 'status-error': statusError,\n 'status-info': statusInfo,\n 'status-success': checked,\n 'status-warning': statusWarning,\n /* eslint-enable @typescript-eslint/naming-convention */\n}\n\nconst coreLibrary: IconLibrary = {\n name: 'core',\n resolver: (name) => icons[name] ?? '',\n}\n\nexport default coreLibrary\n","// SPDX-FileCopyrightText: © 2023 Schneider Electric\n//\n// SPDX-License-Identifier: LGPL-2.1-only\n\nimport { getAssetPath } from '@stencil/core'\n\nimport type { IconLibrary } from './library'\n\nconst library: IconLibrary = {\n name: 'default',\n resolver: (name) => getAssetPath(`icons/${name}.svg`),\n}\n\nexport default library\n","// SPDX-FileCopyrightText: © 2023 Schneider Electric\n//\n// SPDX-License-Identifier: LGPL-2.1-only\n\nimport type { Except } from 'type-fest'\n\nimport coreLibrary from './core-library'\nimport defaultLibrary from './default-library'\n\nexport type IconLibraryResolver = (name: string) => string\nexport interface IconLibrary {\n name: string\n resolver: IconLibraryResolver\n}\n\nlet registry: IconLibrary[] = [defaultLibrary, coreLibrary]\n\n/**\n * Returns a library from the registry.\n */\nexport const getIconLibrary = (name: string): IconLibrary | undefined =>\n registry.find((library) => library.name === name)\n\n/**\n * Removes an icon library from the registry.\n */\nexport const unregisterIconLibrary = (name: string): void => {\n registry = registry.filter((library) => library.name !== name)\n}\n\n/**\n * Adds an icon library to the registry or overrides an existing one.\n */\nexport const registerIconLibrary = (\n name: string,\n options: Except<IconLibrary, 'name'>,\n): void => {\n unregisterIconLibrary(name)\n registry.push({\n name,\n ...options,\n })\n}\n","// SPDX-FileCopyrightText: © 2023 Schneider Electric\n//\n// SPDX-License-Identifier: LGPL-2.1-only\n\ninterface Request {\n ok: boolean\n data: string\n}\n\ninterface IconRequestOk {\n ok: true\n data: string\n}\n\ninterface IconRequestError {\n ok: false\n data: undefined\n}\n\ntype IconRequest = IconRequestError | IconRequestOk\n\ninterface IconRequestUnknown {\n ok: boolean\n data?: string\n}\n\nconst request = async (source: string): Promise<Request> => {\n const response = await fetch(source, { mode: 'cors' })\n return {\n ok: response.ok,\n data: await response.text(),\n }\n}\n\nconst cachedIconRequests = new Map<string, IconRequest>()\n\nconst requestIcon = async (url: string): Promise<IconRequest> => {\n const cachedIconRequest = cachedIconRequests.get(url)\n if (cachedIconRequest) return cachedIconRequest\n\n const fileData = await request(url)\n const iconFileData: IconRequestUnknown = {\n ok: fileData.ok,\n }\n if (fileData.ok) {\n const div = document.createElement('div')\n div.innerHTML = fileData.data\n const child = div.firstElementChild\n iconFileData.data =\n child?.tagName.toLowerCase() === 'svg' ? child.outerHTML : ''\n }\n\n cachedIconRequests.set(url, iconFileData as IconRequest)\n return iconFileData as IconRequest\n}\n\nexport default requestIcon\n","/*\n * SPDX-FileCopyrightText: © 2023 Schneider Electric\n *\n * SPDX-License-Identifier: LGPL-2.1-only\n */\n\n@import url('../shared.css');\n\n:host {\n contain: strict;\n display: inline-block;\n height: 1em;\n width: 1em;\n}\n\n.qds-wrapper {\n display: contents;\n}\n\nsvg {\n display: block;\n fill: currentcolor;\n height: 100%;\n width: 100%;\n}\n","// SPDX-FileCopyrightText: © 2023 Schneider Electric\n//\n// SPDX-License-Identifier: LGPL-2.1-only\n\nimport type { ComponentInterface, EventEmitter } from '@stencil/core'\nimport { Component, Element, Event, h, Prop, State, Watch } from '@stencil/core'\n\nimport type { Attributes } from '../../helpers'\nimport { inheritAriaAttributes } from '../../helpers'\nimport { getIconLibrary } from './library'\nimport requestIcon from './request'\n\nlet parser: DOMParser | undefined\n\n/**\n * @experimental\n */\n@Component({\n tag: 'qds-icon',\n shadow: true,\n styleUrl: 'icon.css',\n})\nexport class Icon implements ComponentInterface {\n /**\n * The name of the icon to render.\n *\n * Available names depend on the icon library being used.\n */\n @Prop({ reflect: true }) public readonly name!: string\n\n /**\n * The name of a registered icon library.\n */\n @Prop({ reflect: true }) public readonly library: string = 'default'\n\n /**\n * Emitted when the icon has loaded.\n */\n @Event({ eventName: 'qdsLoad', cancelable: false })\n private readonly loadEmitter!: EventEmitter<void>\n\n /**\n * Emitted when the icon fails to load due to an error.\n */\n @Event({ eventName: 'qdsError', cancelable: false })\n private readonly errorEmitter!: EventEmitter<void>\n\n @Element() private readonly element!: HTMLQdsIconElement\n\n @State() private svg = ''\n\n private inheritedAttributes: Attributes = {}\n\n @Watch('name')\n @Watch('library')\n private async setIcon(): Promise<void> {\n if (!this.name) return\n\n const library = getIconLibrary(this.library)\n if (!library) return\n\n const url = library.resolver(this.name)\n if (!url) {\n this.svg = ''\n return\n }\n\n try {\n const request = await requestIcon(url)\n if (!request.ok) {\n this.svg = ''\n this.errorEmitter.emit()\n return\n }\n\n // Create an instance of the DOM parser. We do it here instead of at the\n // top-level to support SSR while maintaining a single parser instance\n // for optimal performance.\n parser ||= new DOMParser()\n const document = parser.parseFromString(request.data, 'text/html')\n const svgElement = document.body.querySelector('svg')\n if (svgElement === null) {\n this.svg = ''\n this.errorEmitter.emit()\n } else {\n for (const [key, value] of Object.entries(this.inheritedAttributes))\n svgElement.setAttribute(key, value)\n this.svg = svgElement.outerHTML\n this.loadEmitter.emit()\n }\n } catch {\n this.errorEmitter.emit()\n }\n }\n\n public async componentWillLoad(): Promise<void> {\n this.inheritedAttributes = inheritAriaAttributes(this.element)\n await this.setIcon()\n }\n\n public render() {\n return <span class=\"qds-wrapper\" innerHTML={this.svg} />\n }\n}\n"],"version":3}
@@ -1 +1 @@
1
- {"file":"index.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AAEA,MAAM,WAAW,GAAG,CAAC,KAAwB;EAC3C,IAAI,KAAK,KAAK,SAAS;IAAE,OAAO,QAAQ,CAAC,eAAe,CAAC,SAAS,CAAA;EAClE,IAAI,OAAO,KAAK,KAAK,QAAQ;IAC3B,OAAO,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,SAAS,IAAI,SAAS,CAAA;EAC9D,OAAO,KAAK,CAAC,SAAS,CAAA;AACxB,CAAC,CAAA;AAED,MAAM,UAAU,GAAG,CACjB,IAAY,EACZ,SAAoC;EAEpC,IAAI,CAAC,SAAS;IAAE,OAAO,SAAS,CAAA;EAEhC,MAAM,MAAM,GAAG,OAAO,IAAI,GAAG,CAAA;EAE7B,OAAO,CAAC,GAAG,SAAS,CAAC;KAClB,IAAI,CAAC,CAAC,KAAa,KAAsB,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;MACjE,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;AACzB,CAAC,CAAA;AAED,MAAM,UAAU,GAAG,CACjB,IAAY,EACZ,KAAa,EACb,OAA0B;EAE1B,MAAM,SAAS,GAAG,WAAW,CAAC,OAAO,CAAC,CAAA;EACtC,IAAI,SAAS,KAAK,SAAS;IAAE,OAAM;EAEnC,MAAM,MAAM,GAAG,OAAO,IAAI,GAAG,CAAA;EAE7B,MAAM,cAAc,GAAG,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;EAClD,IAAI,cAAc,KAAK,SAAS;IAC9B,SAAS,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,cAAc,EAAE,CAAC,CAAA;EAChD,SAAS,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,KAAK,EAAE,CAAC,CAAA;AACpC,CAAC,CAAA;AAKD;;;;;;;;;;;;;;MAca,WAAW,GAAG,CACzB,OAAyB,KACF,UAAU,CAAC,UAAU,EAAE,WAAW,CAAC,OAAO,CAAC,EAAC;AAErE;;;;;;;;;;;;;;;MAea,WAAW,GAAG,CAKzB,QAAqB,EACrB,OAAyB;EAEzB,UAAU,CAAC,UAAU,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAA;AAC3C,EAAC;AAED;;;;;;;;;;;;;;MAca,QAAQ,GAAG,CACtB,OAAyB,KACF,UAAU,CAAC,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,EAAC;AAElE;;;;;;;;;;;;;;;MAea,QAAQ,GAAG,CAKtB,KAAkB,EAClB,OAAyB;EAEzB,UAAU,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAA;AACrC;;;;","names":[],"sources":["src/utils.ts"],"sourcesContent":["// SPDX-FileCopyrightText: © 2023 Schneider Electric\n//\n// SPDX-License-Identifier: LGPL-2.1-only\n\nconst toClassList = (value?: Element | string): DOMTokenList | undefined => {\n if (value === undefined) return document.documentElement.classList\n if (typeof value === 'string')\n return document.querySelector(value)?.classList ?? undefined\n return value.classList\n}\n\nconst getVariant = (\n type: string,\n classList?: DOMTokenList | undefined,\n): string | undefined => {\n if (!classList) return undefined\n\n const prefix = `qds-${type}-`\n\n return [...classList]\n .find((value: string): value is string => value.startsWith(prefix))\n ?.replace(prefix, '')\n}\n\nconst setVariant = (\n type: string,\n value: string,\n element?: Element | string,\n): void => {\n const classList = toClassList(element)\n if (classList === undefined) return\n\n const prefix = `qds-${type}-`\n\n const currentVariant = getVariant(type, classList)\n if (currentVariant !== undefined)\n classList.remove(`${prefix}${currentVariant}`)\n classList.add(`${prefix}${value}`)\n}\n\n// eslint-disable-next-line @typescript-eslint/no-type-alias\ntype NonEmpty<T extends string = string> = T extends '' ? never : T\n\n/**\n * Get the currently set platform.\n *\n * @param element The element where the platform will be retrieved from. Can be\n * either:\n *\n * - A non-empty CSS selector string\n * - A reference to an\n * [`Element`](https://developer.mozilla.org/docs/Web/API/Element)\n *\n * By default, this is the root node of the current document.\n *\n * @returns The currently set platform if one is set, `undefined` otherwise.\n */\nexport const getPlatform = <S extends string, E extends Element = Element>(\n element?: E | NonEmpty<S>,\n): string | undefined => getVariant('platform', toClassList(element))\n\n/**\n * Sets the current platform.\n *\n * The current platform represented by a `qds-platform-`-prefixed CSS class\n * will be removed.\n *\n * @param platform The platform to set. Must be a non-empty value.\n * @param element The element where the platform will be set. Can be either:\n *\n * - A non-empty CSS selector string\n * - A reference to an\n * [`Element`](https://developer.mozilla.org/docs/Web/API/Element)\n *\n * By default, this is the root node of the current document.\n */\nexport const setPlatform = <\n P extends string,\n S extends string = string,\n E extends Element = Element,\n>(\n platform: NonEmpty<P>,\n element?: E | NonEmpty<S>,\n): void => {\n setVariant('platform', platform, element)\n}\n\n/**\n * Get the currently set theme.\n *\n * @param element The element where the theme will be retrieved from. Can be\n * either:\n *\n * - A non-empty CSS selector string\n * - A reference to an\n * [`Element`](https://developer.mozilla.org/docs/Web/API/Element)\n *\n * By default, this is the root node of the current document.\n *\n * @returns The currently set theme if one is set, `undefined` otherwise.\n */\nexport const getTheme = <S extends string, E extends Element = Element>(\n element?: E | NonEmpty<S>,\n): string | undefined => getVariant('theme', toClassList(element))\n\n/**\n * Sets the current theme.\n *\n * The current theme represented by a `qds-theme-`-prefixed CSS class will be\n * removed.\n *\n * @param theme The theme to set. Must be a non-empty value.\n * @param element The element where the theme will be set. Can be either:\n *\n * - A non-empty CSS selector string\n * - A reference to an\n * [`Element`](https://developer.mozilla.org/docs/Web/API/Element)\n *\n * By default, this is the root node of the current document.\n */\nexport const setTheme = <\n T extends string,\n S extends string = string,\n E extends Element = Element,\n>(\n theme: NonEmpty<T>,\n element?: E | NonEmpty<S>,\n): void => {\n setVariant('theme', theme, element)\n}\n"],"version":3}
1
+ {"file":"index.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AAEA,MAAM,WAAW,GAAG,CAAC,KAAwB;EAC3C,IAAI,KAAK,KAAK,SAAS;IAAE,OAAO,QAAQ,CAAC,eAAe,CAAC,SAAS,CAAA;EAClE,IAAI,OAAO,KAAK,KAAK,QAAQ;IAC3B,OAAO,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,SAAS,IAAI,SAAS,CAAA;EAC9D,OAAO,KAAK,CAAC,SAAS,CAAA;AACxB,CAAC,CAAA;AAED,MAAM,UAAU,GAAG,CACjB,IAAY,EACZ,SAAoC;EAEpC,IAAI,CAAC,SAAS;IAAE,OAAO,SAAS,CAAA;EAEhC,MAAM,MAAM,GAAG,OAAO,IAAI,GAAG,CAAA;EAE7B,OAAO,CAAC,GAAG,SAAS,CAAC;KAClB,IAAI,CAAC,CAAC,KAAa,KAAsB,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;MACjE,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;AACzB,CAAC,CAAA;AAED,MAAM,UAAU,GAAG,CACjB,IAAY,EACZ,KAAa,EACb,OAA0B;EAE1B,MAAM,SAAS,GAAG,WAAW,CAAC,OAAO,CAAC,CAAA;EACtC,IAAI,SAAS,KAAK,SAAS;IAAE,OAAM;EAEnC,MAAM,MAAM,GAAG,OAAO,IAAI,GAAG,CAAA;EAE7B,MAAM,cAAc,GAAG,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;EAClD,IAAI,cAAc,KAAK,SAAS;IAC9B,SAAS,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,cAAc,EAAE,CAAC,CAAA;EAChD,SAAS,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,KAAK,EAAE,CAAC,CAAA;AACpC,CAAC,CAAA;AAID;;;;;;;;;;;;;;MAca,WAAW,GAAG,CACzB,OAAyB,KACF,UAAU,CAAC,UAAU,EAAE,WAAW,CAAC,OAAO,CAAC,EAAC;AAErE;;;;;;;;;;;;;;;MAea,WAAW,GAAG,CAKzB,QAAqB,EACrB,OAAyB;EAEzB,UAAU,CAAC,UAAU,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAA;AAC3C,EAAC;AAED;;;;;;;;;;;;;;MAca,QAAQ,GAAG,CACtB,OAAyB,KACF,UAAU,CAAC,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,EAAC;AAElE;;;;;;;;;;;;;;;MAea,QAAQ,GAAG,CAKtB,KAAkB,EAClB,OAAyB;EAEzB,UAAU,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAA;AACrC;;;;","names":[],"sources":["src/utils.ts"],"sourcesContent":["// SPDX-FileCopyrightText: © 2023 Schneider Electric\n//\n// SPDX-License-Identifier: LGPL-2.1-only\n\nconst toClassList = (value?: Element | string): DOMTokenList | undefined => {\n if (value === undefined) return document.documentElement.classList\n if (typeof value === 'string')\n return document.querySelector(value)?.classList ?? undefined\n return value.classList\n}\n\nconst getVariant = (\n type: string,\n classList?: DOMTokenList | undefined,\n): string | undefined => {\n if (!classList) return undefined\n\n const prefix = `qds-${type}-`\n\n return [...classList]\n .find((value: string): value is string => value.startsWith(prefix))\n ?.replace(prefix, '')\n}\n\nconst setVariant = (\n type: string,\n value: string,\n element?: Element | string,\n): void => {\n const classList = toClassList(element)\n if (classList === undefined) return\n\n const prefix = `qds-${type}-`\n\n const currentVariant = getVariant(type, classList)\n if (currentVariant !== undefined)\n classList.remove(`${prefix}${currentVariant}`)\n classList.add(`${prefix}${value}`)\n}\n\ntype NonEmpty<T extends string = string> = T extends '' ? never : T\n\n/**\n * Get the currently set platform.\n *\n * @param element The element where the platform will be retrieved from. Can be\n * either:\n *\n * - A non-empty CSS selector string\n * - A reference to an\n * [`Element`](https://developer.mozilla.org/docs/Web/API/Element)\n *\n * By default, this is the root node of the current document.\n *\n * @returns The currently set platform if one is set, `undefined` otherwise.\n */\nexport const getPlatform = <S extends string, E extends Element = Element>(\n element?: E | NonEmpty<S>,\n): string | undefined => getVariant('platform', toClassList(element))\n\n/**\n * Sets the current platform.\n *\n * The current platform represented by a `qds-platform-`-prefixed CSS class\n * will be removed.\n *\n * @param platform The platform to set. Must be a non-empty value.\n * @param element The element where the platform will be set. Can be either:\n *\n * - A non-empty CSS selector string\n * - A reference to an\n * [`Element`](https://developer.mozilla.org/docs/Web/API/Element)\n *\n * By default, this is the root node of the current document.\n */\nexport const setPlatform = <\n P extends string,\n S extends string = string,\n E extends Element = Element,\n>(\n platform: NonEmpty<P>,\n element?: E | NonEmpty<S>,\n): void => {\n setVariant('platform', platform, element)\n}\n\n/**\n * Get the currently set theme.\n *\n * @param element The element where the theme will be retrieved from. Can be\n * either:\n *\n * - A non-empty CSS selector string\n * - A reference to an\n * [`Element`](https://developer.mozilla.org/docs/Web/API/Element)\n *\n * By default, this is the root node of the current document.\n *\n * @returns The currently set theme if one is set, `undefined` otherwise.\n */\nexport const getTheme = <S extends string, E extends Element = Element>(\n element?: E | NonEmpty<S>,\n): string | undefined => getVariant('theme', toClassList(element))\n\n/**\n * Sets the current theme.\n *\n * The current theme represented by a `qds-theme-`-prefixed CSS class will be\n * removed.\n *\n * @param theme The theme to set. Must be a non-empty value.\n * @param element The element where the theme will be set. Can be either:\n *\n * - A non-empty CSS selector string\n * - A reference to an\n * [`Element`](https://developer.mozilla.org/docs/Web/API/Element)\n *\n * By default, this is the root node of the current document.\n */\nexport const setTheme = <\n T extends string,\n S extends string = string,\n E extends Element = Element,\n>(\n theme: NonEmpty<T>,\n element?: E | NonEmpty<S>,\n): void => {\n setVariant('theme', theme, element)\n}\n"],"version":3}
@@ -26,7 +26,7 @@ const Label = /*@__PURE__*/ proxyCustomElement(class Label extends HTMLElement {
26
26
  return (h("span", { class: {
27
27
  'qds-inline': this.inline,
28
28
  'qds-label': true,
29
- }, "data-size": this.size, ...this.inheritedAttributes }, this.required && h("span", { class: "qds-required" }, "*"), this.text));
29
+ }, "data-size": this.size ?? 'standard', ...this.inheritedAttributes }, this.required && h("span", { class: "qds-required" }, "*"), this.text));
30
30
  }
31
31
  get element() { return this; }
32
32
  static get style() { return labelCss; }
@@ -1 +1 @@
1
- {"file":"label.js","mappings":";;;;;;;;AAAA,MAAM,QAAQ,GAAG,2sBAA2sB;;MCsB/sB,KAAK;;;;;IA0BR,wBAAmB,GAAe,EAAE,CAAA;kBAnBF,KAAK;oBAKH,KAAK;gBAKU,UAAU;;;EAW9D,iBAAiB;IACtB,IAAI,CAAC,mBAAmB,GAAG,qBAAqB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;GAC/D;EAEM,MAAM;IACX,QACE,YACE,KAAK,EAAE;QACL,YAAY,EAAE,IAAI,CAAC,MAAM;QACzB,WAAW,EAAE,IAAI;OAClB,eACU,IAAI,CAAC,IAAI,KAEhB,IAAI,CAAC,mBAAmB,IAE3B,IAAI,CAAC,QAAQ,IAAI,YAAM,KAAK,EAAC,cAAc,QAAS,EACpD,IAAI,CAAC,IAAI,CACL,EACR;GACF;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/label/label.css?tag=qds-label&encapsulation=shadow","src/components/label/label.tsx"],"sourcesContent":["/*\n * SPDX-FileCopyrightText: © 2023 Schneider Electric\n *\n * SPDX-License-Identifier: LGPL-2.1-only\n */\n\n@import url('../shared.css');\n\n:host {\n display: inline-block;\n}\n\n.qds-label {\n box-sizing: border-box;\n color: var(--qds-theme-control-text-standard);\n display: inline-block;\n}\n\n.qds-required {\n color: var(--qds-theme-feedback-field-required);\n user-select: none;\n}\n\n[data-size='small'] {\n font: var(--qds-control-small-text);\n\n &.qds-inline {\n margin-block: var(--qds-control-small-padding-auto-height);\n }\n}\n\n[data-size='standard'] {\n font: var(--qds-control-standard-text);\n\n &.qds-inline {\n margin-block: var(--qds-control-standard-padding-auto-height);\n }\n}\n\n[data-size='large'] {\n font: var(--qds-control-large-text);\n\n &.qds-inline {\n margin-block: var(--qds-control-large-padding-auto-height);\n }\n}\n","// SPDX-FileCopyrightText: © 2023 Schneider Electric\n//\n// SPDX-License-Identifier: LGPL-2.1-only\n\nimport type { ComponentInterface } from '@stencil/core'\nimport { Component, Element, h, Prop } from '@stencil/core'\n\nimport type { Attributes } from '../../helpers'\nimport { inheritAriaAttributes } from '../../helpers'\n\nexport type LabelSize = 'large' | 'small' | 'standard'\n\n/**\n * `<qds-label>` elements represent a caption for an item in a user interface.\n *\n * @see https://quartz.se.com/build/components/label\n */\n@Component({\n tag: 'qds-label',\n shadow: true,\n styleUrl: 'label.css',\n})\nexport class Label implements ComponentInterface {\n /**\n * Adds vertical margin to the label for alignment.\n *\n * This is useful when creating inline layouts so that the first lines have\n * the correct vertical centering.\n */\n @Prop() public readonly inline: boolean = false\n\n /**\n * Specify the labelled item as required by appending a red asterisk (*).\n */\n @Prop() public readonly required: boolean = false\n\n /**\n * The label's size.\n */\n @Prop({ reflect: true }) public readonly size: LabelSize = 'standard'\n\n /**\n * The label's text.\n */\n @Prop({ reflect: true }) public readonly text?: string\n\n @Element() private readonly element!: HTMLQdsLabelElement\n\n private inheritedAttributes: Attributes = {}\n\n public componentWillLoad(): void {\n this.inheritedAttributes = inheritAriaAttributes(this.element)\n }\n\n public render() {\n return (\n <span\n class={{\n 'qds-inline': this.inline,\n 'qds-label': true,\n }}\n data-size={this.size}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...this.inheritedAttributes}\n >\n {this.required && <span class=\"qds-required\">*</span>}\n {this.text}\n </span>\n )\n }\n}\n"],"version":3}
1
+ {"file":"label.js","mappings":";;;;;;;;AAAA,MAAM,QAAQ,GAAG,2sBAA2sB;;MCsB/sB,KAAK;;;;;IA0BR,wBAAmB,GAAe,EAAE,CAAA;kBAnBF,KAAK;oBAKH,KAAK;gBAKW,UAAU;;;EAW/D,iBAAiB;IACtB,IAAI,CAAC,mBAAmB,GAAG,qBAAqB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;GAC/D;EAEM,MAAM;IACX,QACE,YACE,KAAK,EAAE;QACL,YAAY,EAAE,IAAI,CAAC,MAAM;QACzB,WAAW,EAAE,IAAI;OAClB,eACU,IAAI,CAAC,IAAI,IAAI,UAAU,KAE9B,IAAI,CAAC,mBAAmB,IAE3B,IAAI,CAAC,QAAQ,IAAI,YAAM,KAAK,EAAC,cAAc,QAAS,EACpD,IAAI,CAAC,IAAI,CACL,EACR;GACF;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/label/label.css?tag=qds-label&encapsulation=shadow","src/components/label/label.tsx"],"sourcesContent":["/*\n * SPDX-FileCopyrightText: © 2023 Schneider Electric\n *\n * SPDX-License-Identifier: LGPL-2.1-only\n */\n\n@import url('../shared.css');\n\n:host {\n display: inline-block;\n}\n\n.qds-label {\n box-sizing: border-box;\n color: var(--qds-theme-control-text-standard);\n display: inline-block;\n}\n\n.qds-required {\n color: var(--qds-theme-feedback-field-required);\n user-select: none;\n}\n\n[data-size='small'] {\n font: var(--qds-control-small-text);\n\n &.qds-inline {\n margin-block: var(--qds-control-small-padding-auto-height);\n }\n}\n\n[data-size='standard'] {\n font: var(--qds-control-standard-text);\n\n &.qds-inline {\n margin-block: var(--qds-control-standard-padding-auto-height);\n }\n}\n\n[data-size='large'] {\n font: var(--qds-control-large-text);\n\n &.qds-inline {\n margin-block: var(--qds-control-large-padding-auto-height);\n }\n}\n","// SPDX-FileCopyrightText: © 2023 Schneider Electric\n//\n// SPDX-License-Identifier: LGPL-2.1-only\n\nimport type { ComponentInterface } from '@stencil/core'\nimport { Component, Element, h, Prop } from '@stencil/core'\n\nimport type { Attributes } from '../../helpers'\nimport { inheritAriaAttributes } from '../../helpers'\n\nexport type LabelSize = 'large' | 'small' | 'standard'\n\n/**\n * `<qds-label>` elements represent a caption for an item in a user interface.\n *\n * @see https://quartz.se.com/build/components/label\n */\n@Component({\n tag: 'qds-label',\n shadow: true,\n styleUrl: 'label.css',\n})\nexport class Label implements ComponentInterface {\n /**\n * Adds vertical margin to the label for alignment.\n *\n * This is useful when creating inline layouts so that the first lines have\n * the correct vertical centering.\n */\n @Prop() public readonly inline: boolean = false\n\n /**\n * Specify the labelled item as required by appending a red asterisk (*).\n */\n @Prop() public readonly required: boolean = false\n\n /**\n * The label's size.\n */\n @Prop({ reflect: true }) public readonly size?: LabelSize = 'standard'\n\n /**\n * The label's text.\n */\n @Prop({ reflect: true }) public readonly text?: string\n\n @Element() private readonly element!: HTMLQdsLabelElement\n\n private inheritedAttributes: Attributes = {}\n\n public componentWillLoad(): void {\n this.inheritedAttributes = inheritAriaAttributes(this.element)\n }\n\n public render() {\n return (\n <span\n class={{\n 'qds-inline': this.inline,\n 'qds-label': true,\n }}\n data-size={this.size ?? 'standard'}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...this.inheritedAttributes}\n >\n {this.required && <span class=\"qds-required\">*</span>}\n {this.text}\n </span>\n )\n }\n}\n"],"version":3}
@@ -17,32 +17,6 @@ const Button = /*@__PURE__*/ proxyCustomElement(class Button extends HTMLElement
17
17
  this.blurEmitter = createEvent(this, "qdsBlur", 2);
18
18
  this.focusEmitter = createEvent(this, "qdsFocus", 2);
19
19
  this.inheritedAttributes = {};
20
- this.onClick = (event) => {
21
- if (this.computedDisabled) {
22
- event.preventDefault();
23
- event.stopPropagation();
24
- return;
25
- }
26
- if (this.buttonType === 'button' || !this.formElement)
27
- return;
28
- event.preventDefault();
29
- const fakeButton = document.createElement('button');
30
- fakeButton.type = this.buttonType;
31
- if (this.name !== undefined)
32
- fakeButton.name = this.name;
33
- if (this.value !== undefined)
34
- fakeButton.value = this.value;
35
- if (this.formAction !== undefined)
36
- fakeButton.formAction = this.formAction;
37
- if (this.formMethod !== undefined)
38
- fakeButton.formMethod = this.formMethod;
39
- fakeButton.formNoValidate = this.formNoValidate;
40
- fakeButton.formTarget = this.formTarget;
41
- fakeButton.style.display = 'none';
42
- this.formElement.append(fakeButton);
43
- fakeButton.click();
44
- fakeButton.remove();
45
- };
46
20
  this.onBlur = (event) => {
47
21
  this.blurEmitter.emit(pickFocusEventAttributes(event));
48
22
  };
@@ -89,15 +63,40 @@ const Button = /*@__PURE__*/ proxyCustomElement(class Button extends HTMLElement
89
63
  const parsedValue = Number.parseInt(this.inheritedAttributes.tabindex, 10);
90
64
  return Number.isNaN(parsedValue) ? 0 : parsedValue;
91
65
  }
66
+ onClick(event) {
67
+ if (this.computedDisabled) {
68
+ event.preventDefault();
69
+ event.stopPropagation();
70
+ }
71
+ if (this.buttonType === 'button' || !this.formElement)
72
+ return;
73
+ event.preventDefault();
74
+ const fakeButton = document.createElement('button');
75
+ fakeButton.type = this.buttonType;
76
+ if (this.name !== undefined)
77
+ fakeButton.name = this.name;
78
+ if (this.value !== undefined)
79
+ fakeButton.value = this.value;
80
+ if (this.formAction !== undefined)
81
+ fakeButton.formAction = this.formAction;
82
+ if (this.formMethod !== undefined)
83
+ fakeButton.formMethod = this.formMethod;
84
+ fakeButton.formNoValidate = this.formNoValidate;
85
+ fakeButton.formTarget = this.formTarget;
86
+ fakeButton.style.display = 'none';
87
+ this.formElement.append(fakeButton);
88
+ fakeButton.click();
89
+ fakeButton.remove();
90
+ }
92
91
  componentWillLoad() {
93
92
  this.inheritedAttributes = inheritAriaAttributes(this.element);
94
93
  }
95
94
  render() {
96
95
  const Tag = this.href === undefined ? 'button' : 'a';
97
- return (h(Tag, { "aria-disabled": this.computedDisabled ? 'true' : 'false', class: {
96
+ return (h(Tag, { "aria-disabled": this.computedDisabled.toString(), class: {
98
97
  'qds-button': true,
99
98
  'qds-icon-only': this.iconOnly,
100
- }, "data-importance": this.importance, "data-size": this.size, disabled: Tag === 'a' ? undefined : this.disabled, download: Tag === 'a' ? this.download : undefined, href: Tag === 'a' ? this.href : undefined, name: Tag === 'a' ? undefined : this.name, onBlur: this.onBlur, onClick: this.onClick, onFocus: this.onFocus, rel: Tag === 'a' ? 'noreferrer noopener' : undefined, role: Tag === 'a' ? 'button' : undefined, tabIndex: this.computedDisabled ? -1 : this.computedTabIndex, target: Tag === 'a' ? this.target : undefined, type: Tag === 'a' ? undefined : this.buttonType, value: Tag === 'a' ? undefined : this.value, ...this.inheritedAttributes }, this.iconName !== undefined && this.iconName !== '' && (h("qds-icon", { class: "qds-icon", "data-size": this.size, library: this.iconLibrary, name: this.iconName })), this.text));
99
+ }, "data-importance": this.importance, "data-size": this.size, disabled: Tag === 'a' ? undefined : this.disabled, download: Tag === 'a' ? this.download : undefined, href: Tag === 'a' ? this.href : undefined, name: Tag === 'a' ? undefined : this.name, onBlur: this.onBlur, onFocus: this.onFocus, rel: Tag === 'a' ? 'noreferrer noopener' : undefined, role: Tag === 'a' ? 'button' : undefined, tabIndex: this.computedDisabled ? -1 : this.computedTabIndex, target: Tag === 'a' ? this.target : undefined, type: Tag === 'a' ? undefined : this.buttonType, value: Tag === 'a' ? undefined : this.value, ...this.inheritedAttributes }, this.iconName !== undefined && this.iconName !== '' && (h("qds-icon", { class: "qds-icon", "data-size": this.size, library: this.iconLibrary, name: this.iconName })), this.text));
101
100
  }
102
101
  static get delegatesFocus() { return true; }
103
102
  get element() { return this; }
@@ -120,7 +119,7 @@ const Button = /*@__PURE__*/ proxyCustomElement(class Button extends HTMLElement
120
119
  "target": [1],
121
120
  "type": [1],
122
121
  "value": [1]
123
- }]);
122
+ }, [[0, "click", "onClick"]]]);
124
123
  function define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AAE,GAAG,KAAK,GAAG,GAAG,SAAS,GAAG,IAAI,CAAC,UAAU,EAC/C,KAAK,EAAE,GAAG,KAAK,GAAG,GAAG,SAAS,GAAG,IAAI,CAAC,KAAK,KAEvC,IAAI,CAAC,mBAAmB,IAE3B,IAAI,CAAC,QAAQ,KAAK,SAAS,IAAI,IAAI,CAAC,QAAQ,KAAK,EAAE,KAClD,gBACE,KAAK,EAAC,UAAU,eACL,IAAI,CAAC,IAAI,EACpB,OAAO,EAAE,IAAI,CAAC,WAAW,EACzB,IAAI,EAAE,IAAI,CAAC,QAAQ,GACnB,CACH,EACA,IAAI,CAAC,IAAI,CACN,EACP;GACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/button/button.css?tag=qds-button&encapsulation=shadow","src/components/button/button.tsx"],"sourcesContent":["/*\n * SPDX-FileCopyrightText: © 2023 Schneider Electric\n *\n * SPDX-License-Identifier: LGPL-2.1-only\n */\n\n@import url('../shared.css');\n\n:host {\n display: inline-block;\n}\n\n.qds-button {\n align-items: center;\n appearance: none;\n background-color: initial;\n border-radius: var(--qds-control-border-radius);\n border: none;\n box-sizing: border-box;\n cursor: pointer;\n display: inline-flex;\n gap: var(--qds-control-button-gap-internal);\n justify-content: center;\n padding-block: 0;\n padding-inline: var(--qds-control-button-padding-horizontal);\n print-color-adjust: exact;\n user-select: none;\n white-space: nowrap;\n width: 100%;\n\n &.qds-icon-only {\n padding-inline: 0;\n }\n\n &:any-link {\n text-decoration: none;\n }\n\n &:focus-visible {\n outline: var(--qds-theme-focus-border) solid var(--qds-focus-border-width);\n outline-offset: var(--qds-focus-border-offset);\n }\n}\n\n[aria-disabled='true'] {\n opacity: var(--qds-theme-disabled);\n pointer-events: none;\n}\n\n[data-size='small'] {\n font: var(--qds-control-small-text);\n height: var(--qds-control-small-height);\n\n &.qds-icon-only {\n width: var(--qds-control-small-height);\n }\n\n &.qds-icon {\n font-size: var(--qds-control-small-icon-size);\n }\n}\n\n[data-size='standard'] {\n font: var(--qds-control-standard-text);\n height: var(--qds-control-standard-height);\n\n &.qds-icon-only {\n width: var(--qds-control-standard-height);\n }\n\n &.qds-icon {\n font-size: var(--qds-control-standard-icon-size);\n }\n}\n\n[data-size='large'] {\n font: var(--qds-control-large-text);\n height: var(--qds-control-large-height);\n\n &.qds-icon-only {\n width: var(--qds-control-large-height);\n }\n\n &.qds-icon {\n font-size: var(--qds-control-large-icon-size);\n }\n}\n\n[data-importance='subdued'] {\n border: var(--qds-control-border-width) solid transparent;\n color: var(--qds-theme-link-default);\n\n &.qds-icon-only {\n color: var(--qds-theme-control-text-standard);\n }\n\n &:hover {\n border: var(--qds-control-border-width) solid var(--qds-theme-link-default);\n\n &.qds-icon-only {\n background-color: var(--qds-theme-interactive-background-hover);\n border: none;\n color: var(--qds-theme-control-text-standard);\n }\n }\n\n &:active {\n border: var(--qds-control-border-width) solid var(--qds-theme-link-pressed);\n color: var(--qds-theme-link-pressed);\n\n &.qds-icon-only {\n background-color: var(--qds-theme-interactive-background-pressed);\n border: none;\n color: var(--qds-theme-control-text-standard);\n }\n }\n}\n\n[data-importance='standard'] {\n border: var(--qds-control-border-width) solid var(--qds-theme-control-border);\n color: var(--qds-theme-control-text-standard);\n\n &:hover {\n background-color: var(--qds-theme-interactive-background-hover);\n }\n\n &:active {\n background-color: var(--qds-theme-interactive-background-pressed);\n }\n}\n\n[data-importance='emphasized'] {\n background-color: var(--qds-theme-signature-color-default);\n color: var(--qds-theme-signature-color-contrast);\n\n &:hover {\n background-color: var(--qds-theme-signature-color-hover);\n }\n\n &:active {\n background-color: var(--qds-theme-signature-color-pressed);\n }\n}\n\n[data-importance='destructive'] {\n background-color: var(--qds-theme-feedback-action-destructive-default);\n color: var(--qds-theme-feedback-action-destructive-contrast);\n\n &:hover {\n background-color: var(--qds-theme-feedback-action-destructive-hover);\n }\n\n &:active {\n background-color: var(--qds-theme-feedback-action-destructive-pressed);\n }\n}\n","// SPDX-FileCopyrightText: © 2023 Schneider Electric\n//\n// SPDX-License-Identifier: LGPL-2.1-only\n\nimport type { ComponentInterface, EventEmitter } from '@stencil/core'\nimport { Component, Element, Event, h, Prop } from '@stencil/core'\nimport type { LiteralUnion } from 'type-fest'\n\nimport type { Attributes, QdsFocusEventDetail } from '../../helpers'\nimport { inheritAriaAttributes, pickFocusEventAttributes } from '../../helpers'\n\nexport type ButtonType = 'button' | 'reset' | 'submit'\nexport type Importance = 'destructive' | 'emphasized' | 'standard' | 'subdued'\nexport type ButtonSize = 'large' | 'small' | 'standard'\nexport type FormMethod = 'dialog' | 'get' | 'post'\nexport type ButtonTarget = '_blank' | '_parent' | '_self' | '_top'\n\n/**\n * The `<qds-button>` element is an interactive element activated by a user\n * with a mouse, keyboard, finger, voice command, or other assistive technology.\n * Once activated, it then performs a programmable action, such as submitting a\n * [form](https://developer.mozilla.org/docs/Learn/Forms)\n * or opening a dialog.\n *\n * @see https://quartz.se.com/build/components/button\n */\n@Component({\n tag: 'qds-button',\n shadow: { delegatesFocus: true },\n styleUrl: 'button.css',\n})\nexport class Button implements ComponentInterface {\n /**\n * The name of the icon to render.\n *\n * Available names depend on the icon library being used.\n */\n @Prop({ reflect: true }) public readonly iconName?: string\n\n /**\n * The name of a registered icon library.\n */\n @Prop({ reflect: true }) public readonly iconLibrary: string = 'default'\n\n /**\n * The button's importance.\n */\n @Prop({ reflect: true }) public readonly importance: Importance = 'standard'\n\n /**\n * The button's size.\n */\n @Prop({ reflect: true }) public readonly size: ButtonSize = 'standard'\n\n /**\n * The button's text.\n */\n @Prop({ mutable: true, reflect: true }) public readonly text?: string\n\n /**\n * Prevents the button from being interacted with: it cannot be pressed or\n * focused.\n *\n * @webnative\n */\n @Prop({ mutable: true, reflect: true }) public disabled?: boolean\n\n /**\n * Tells the browser to download the linked file as this filename. Only used\n * when `href` is set.\n *\n * @webnative\n */\n @Prop() public readonly download?: string\n\n /**\n * The [`<form>`](https://developer.mozilla.org/docs/Web/HTML/Element/form)\n * element to associate the button with (its form owner).\n *\n * The value of this attribute must be the id of a `<form>` in the same\n * document. If this attribute is not set, the `<button>` is associated with\n * its ancestor `<form>` element, if any.\n *\n * This attribute lets you associate `<button>` elements to `<form>`s\n * anywhere in the document, not just inside a `<form>`. It can also override\n * an ancestor `<form>` element.\n *\n * @webnative\n */\n @Prop() public readonly form?: string\n\n /**\n * The URL that processes the information submitted by the button. Overrides\n * the [`action`](https://developer.mozilla.org/docs/Web/HTML/Element/button#attr-formaction)\n * attribute of the button's form owner. Does nothing if there is no form owner.\n *\n * @webnative\n */\n @Prop({ attribute: 'formaction' }) public readonly formAction?: string\n\n /**\n * If the button is a submit button (it's inside/associated with a `<form>`\n * and doesn't have `type=\"button\"`), this attribute specifies the\n * [HTTP method][] used to submit the form, or `dialog` which won't submit\n * the form. Possible values:\n *\n * - `get`: The form data are appended to the form's action URL, with a ? as\n * a separator, and the resulting URL is sent to the server. Use this method\n * when the form has no side effects, like search forms.\n * - `post`: The data from the form are included in the body of the HTTP\n * request when sent to the server. Use when the form contains information\n * that shouldn't be public, like login credentials.\n * - `dialog`: Close the dialog box in which the button finds itself, if any,\n * and do not submit the button's form owner.\n *\n * If specified, this attribute overrides the `method` attribute of the\n * button's form owner.\n *\n * [HTTP method]: https://developer.mozilla.org/docs/Web/HTTP/Methods\n *\n * @webnative\n */\n @Prop({ attribute: 'formmethod' }) public readonly formMethod?: FormMethod\n\n /**\n * If the button is a submit button, this attribute specifies that the form\n * is not to be\n * [validated](https://developer.mozilla.org/docs/Learn/Forms/Form_validation)\n * when it is submitted. If this attribute is specified, it overrides the\n * [`novalidate`](https://developer.mozilla.org/docs/Web/HTML/Element/form#attr-novalidate)\n * attribute of the button's form owner.\n *\n * @webnative\n */\n @Prop({ attribute: 'formnovalidate' })\n public readonly formNoValidate: boolean = false\n\n /**\n * If the button is a submit button, this attribute is an author-defined name\n * or standardized, underscore-prefixed keyword indicating where to display\n * the response from submitting the form. This is the `name` of, or keyword\n * for, a browsing context (a tab, window, or\n * [`<iframe>`](https://developer.mozilla.org/docs/Web/HTML/Element/iframe)).\n * If this attribute is specified, it overrides the\n * [`target`](https://developer.mozilla.org/docs/Web/HTML/Element/form#attr-target)\n * attribute of the button's form owner. The following keywords have special\n * meanings:\n *\n * - `_blank`: Load the response into a new unnamed browsing context — usually\n * a new tab or window, depending on the user's browser settings.\n * - `_parent`: Load the response into the parent browsing context of the\n * current one. If there is no parent, this option behaves the same way as\n * `_self`.\n * - `_self`: Load the response into the same browsing context as the current\n * one.\n * - `_top`: Load the response into the top-level browsing context (that is,\n * the browsing context that is an ancestor of the current one, and has no\n * parent). If there is no parent, this option behaves the same way as\n * `_self`.\n *\n * @webnative\n */\n @Prop({ attribute: 'formtarget' })\n public readonly formTarget: LiteralUnion<ButtonTarget, string> = '_self'\n\n /**\n * When set, the underlying button will be rendered as an `<a>` with this\n * `href` instead of a `<button>`.\n *\n * @webnative\n */\n @Prop() public readonly href?: string\n\n /**\n * The name of the button, submitted as a pair with the button's `value` as\n * part of the form data, when that button is used to submit the form.\n * Ignored when `href` is set.\n *\n * @webnative\n */\n @Prop() public readonly name?: string\n\n /**\n * Where to display the linked URL, as the name for a browsing context (a\n * tab, window, or\n * [`<iframe>`](https://developer.mozilla.org/docs/Web/HTML/Element/iframe).\n * The following keywords have special meanings for where to load the URL:\n *\n * - `_blank`: usually a new tab, but users can configure browsers to open a new\n * window instead.\n * - `_parent`: the parent browsing context of the current one. If no parent,\n * behaves as `_self`.\n * - `_self`: the current browsing context.\n * - `_top`: the topmost browsing context (the \"highest\" context that's an\n * ancestor of the current one). If no ancestors, behaves as `_self`.\n *\n * @webnative\n */\n @Prop() public readonly target: LiteralUnion<ButtonTarget, string> = '_self'\n\n /**\n * The type of button.\n *\n * `button`: The button has no default behavior, and does nothing when\n * pressed by default. It can have client-side scripts listen to the\n * element's events, which are triggered when the events occur.\n *\n * `submit`: The button submits the form data to the server. This is the\n * default if the attribute is not specified for buttons associated with a\n * `<form>`, or if the attribute is an empty or invalid value.\n *\n * `reset`: The button resets all the controls to their initial values.\n *\n * @webnative\n */\n @Prop() public readonly type?: ButtonType\n\n /**\n * Defines the value associated with the button's `name` when it's submitted\n * with the form data. This value is passed to the server in params when the\n * form is submitted using this button. Ignored when `href` is set.\n *\n * @webnative\n */\n @Prop() public readonly value?: string\n\n /**\n * Emitted when the button loses focus.\n */\n @Event({ eventName: 'qdsBlur', bubbles: false, cancelable: false })\n private readonly blurEmitter!: EventEmitter<QdsFocusEventDetail>\n\n /**\n * Emitted when the button gains focus.\n */\n @Event({ eventName: 'qdsFocus', bubbles: false, cancelable: false })\n private readonly focusEmitter!: EventEmitter<QdsFocusEventDetail>\n\n @Element() private readonly element!: HTMLQdsButtonElement\n\n private inheritedAttributes: Attributes = {}\n\n private get formElement(): HTMLElement | null {\n return this.form !== undefined && this.form !== ''\n ? document.querySelector(`#${this.form}`)\n : this.element.closest('form')\n }\n\n private get buttonType(): ButtonType {\n if (this.type === undefined) return this.formElement ? 'submit' : 'button'\n return this.type\n }\n\n private get iconOnly(): boolean {\n const hasIcon = this.iconName !== undefined && this.iconName !== ''\n const hasNoLabel = this.text === undefined || this.text === ''\n\n return hasIcon && hasNoLabel\n }\n\n private get computedDisabled(): boolean {\n return this.disabled ?? false\n }\n\n private get computedTabIndex(): number {\n const parsedValue = Number.parseInt(this.inheritedAttributes.tabindex, 10)\n return Number.isNaN(parsedValue) ? 0 : parsedValue\n }\n\n public componentWillLoad(): void {\n this.inheritedAttributes = inheritAriaAttributes(this.element)\n }\n\n public render() {\n const Tag = this.href === undefined ? 'button' : 'a'\n\n return (\n <Tag\n aria-disabled={this.computedDisabled ? 'true' : 'false'}\n class={{\n 'qds-button': true,\n 'qds-icon-only': this.iconOnly,\n }}\n data-importance={this.importance}\n data-size={this.size}\n disabled={Tag === 'a' ? undefined : this.disabled}\n download={Tag === 'a' ? this.download : undefined}\n href={Tag === 'a' ? this.href : undefined}\n name={Tag === 'a' ? undefined : this.name}\n onBlur={this.onBlur}\n onClick={this.onClick}\n onFocus={this.onFocus}\n rel={Tag === 'a' ? 'noreferrer noopener' : undefined}\n role={Tag === 'a' ? 'button' : undefined}\n tabIndex={this.computedDisabled ? -1 : this.computedTabIndex}\n target={Tag === 'a' ? this.target : undefined}\n type={Tag === 'a' ? undefined : this.buttonType}\n value={Tag === 'a' ? undefined : this.value}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...this.inheritedAttributes}\n >\n {this.iconName !== undefined && this.iconName !== '' && (\n <qds-icon\n class=\"qds-icon\"\n data-size={this.size}\n library={this.iconLibrary}\n name={this.iconName}\n />\n )}\n {this.text}\n </Tag>\n )\n }\n\n private readonly onClick = (event: MouseEvent): void => {\n if (this.computedDisabled) {\n event.preventDefault()\n event.stopPropagation()\n return\n }\n\n if (this.buttonType === 'button' || !this.formElement) return\n event.preventDefault()\n\n const fakeButton = document.createElement('button')\n fakeButton.type = this.buttonType\n if (this.name !== undefined) fakeButton.name = this.name\n if (this.value !== undefined) fakeButton.value = this.value\n if (this.formAction !== undefined) fakeButton.formAction = this.formAction\n if (this.formMethod !== undefined) fakeButton.formMethod = this.formMethod\n fakeButton.formNoValidate = this.formNoValidate\n fakeButton.formTarget = this.formTarget\n fakeButton.style.display = 'none'\n\n this.formElement.append(fakeButton)\n fakeButton.click()\n fakeButton.remove()\n }\n\n private readonly onBlur = (event: FocusEvent): void => {\n this.blurEmitter.emit(pickFocusEventAttributes(event))\n }\n\n private readonly onFocus = (event: FocusEvent): void => {\n this.focusEmitter.emit(pickFocusEventAttributes(event))\n }\n}\n"],"version":3}
1
+ {"file":"qds-button.js","mappings":";;;;;;;;;AAAA,MAAM,SAAS,GAAG,85GAA85G;;MC+Bn6G,MAAM;;;;;;;IAiNT,wBAAmB,GAAe,EAAE,CAAA;IAkG3B,WAAM,GAAG,CAAC,KAAiB;MAC1C,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC,CAAA;KACvD,CAAA;IAEgB,YAAO,GAA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CACN,EACP;GACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/button/button.css?tag=qds-button&encapsulation=shadow","src/components/button/button.tsx"],"sourcesContent":["/*\n * SPDX-FileCopyrightText: © 2023 Schneider Electric\n *\n * SPDX-License-Identifier: LGPL-2.1-only\n */\n\n@import url('../shared.css');\n\n:host {\n display: inline-block;\n}\n\n.qds-button {\n align-items: center;\n appearance: none;\n background-color: initial;\n border-radius: var(--qds-control-border-radius);\n border: none;\n box-sizing: border-box;\n cursor: pointer;\n display: inline-flex;\n gap: var(--qds-control-button-gap-internal);\n justify-content: center;\n padding-block: 0;\n padding-inline: var(--qds-control-button-padding-horizontal);\n print-color-adjust: exact;\n user-select: none;\n white-space: nowrap;\n width: 100%;\n\n &.qds-icon-only {\n padding-inline: 0;\n }\n\n &:any-link {\n text-decoration: none;\n }\n\n &:focus-visible {\n outline: var(--qds-theme-focus-border) solid var(--qds-focus-border-width);\n outline-offset: var(--qds-focus-border-offset);\n }\n}\n\n[aria-disabled='true'] {\n opacity: var(--qds-theme-disabled);\n pointer-events: none;\n}\n\n[data-size='small'] {\n font: var(--qds-control-small-text);\n height: var(--qds-control-small-height);\n\n &.qds-icon-only {\n width: var(--qds-control-small-height);\n }\n\n &.qds-icon {\n font-size: var(--qds-control-small-icon-size);\n }\n}\n\n[data-size='standard'] {\n font: var(--qds-control-standard-text);\n height: var(--qds-control-standard-height);\n\n &.qds-icon-only {\n width: var(--qds-control-standard-height);\n }\n\n &.qds-icon {\n font-size: var(--qds-control-standard-icon-size);\n }\n}\n\n[data-size='large'] {\n font: var(--qds-control-large-text);\n height: var(--qds-control-large-height);\n\n &.qds-icon-only {\n width: var(--qds-control-large-height);\n }\n\n &.qds-icon {\n font-size: var(--qds-control-large-icon-size);\n }\n}\n\n[data-importance='subdued'] {\n border: var(--qds-control-border-width) solid transparent;\n color: var(--qds-theme-link-default);\n\n &.qds-icon-only {\n color: var(--qds-theme-control-text-standard);\n }\n\n &:hover {\n border: var(--qds-control-border-width) solid var(--qds-theme-link-default);\n\n &.qds-icon-only {\n background-color: var(--qds-theme-interactive-background-hover);\n border: none;\n color: var(--qds-theme-control-text-standard);\n }\n }\n\n &:active {\n border: var(--qds-control-border-width) solid var(--qds-theme-link-pressed);\n color: var(--qds-theme-link-pressed);\n\n &.qds-icon-only {\n background-color: var(--qds-theme-interactive-background-pressed);\n border: none;\n color: var(--qds-theme-control-text-standard);\n }\n }\n}\n\n[data-importance='standard'] {\n border: var(--qds-control-border-width) solid var(--qds-theme-control-border);\n color: var(--qds-theme-control-text-standard);\n\n &:hover {\n background-color: var(--qds-theme-interactive-background-hover);\n }\n\n &:active {\n background-color: var(--qds-theme-interactive-background-pressed);\n }\n}\n\n[data-importance='emphasized'] {\n background-color: var(--qds-theme-signature-color-default);\n color: var(--qds-theme-signature-color-contrast);\n\n &:hover {\n background-color: var(--qds-theme-signature-color-hover);\n }\n\n &:active {\n background-color: var(--qds-theme-signature-color-pressed);\n }\n}\n\n[data-importance='destructive'] {\n background-color: var(--qds-theme-feedback-action-destructive-default);\n color: var(--qds-theme-feedback-action-destructive-contrast);\n\n &:hover {\n background-color: var(--qds-theme-feedback-action-destructive-hover);\n }\n\n &:active {\n background-color: var(--qds-theme-feedback-action-destructive-pressed);\n }\n}\n","// SPDX-FileCopyrightText: © 2023 Schneider Electric\n//\n// SPDX-License-Identifier: LGPL-2.1-only\n\nimport type { ComponentInterface, EventEmitter } from '@stencil/core'\nimport { Component, Element, Event, h, Listen, Prop } from '@stencil/core'\nimport type { LiteralUnion } from 'type-fest'\n\nimport type { Attributes, QdsFocusEventDetail } from '../../helpers'\nimport { inheritAriaAttributes, pickFocusEventAttributes } from '../../helpers'\n\nexport type ButtonType = 'button' | 'reset' | 'submit'\nexport type Importance = 'destructive' | 'emphasized' | 'standard' | 'subdued'\nexport type ButtonSize = 'large' | 'small' | 'standard'\nexport type FormMethod = 'dialog' | 'get' | 'post'\nexport type ButtonTarget = '_blank' | '_parent' | '_self' | '_top'\n\n/**\n * The `<qds-button>` element is an interactive element activated by a user\n * with a mouse, keyboard, finger, voice command, or other assistive technology.\n * Once activated, it then performs a programmable action, such as submitting a\n * [form](https://developer.mozilla.org/docs/Learn/Forms)\n * or opening a dialog.\n *\n * @see https://quartz.se.com/build/components/button\n */\n@Component({\n tag: 'qds-button',\n shadow: { delegatesFocus: true },\n styleUrl: 'button.css',\n})\nexport class Button implements ComponentInterface {\n /**\n * The name of the icon to render.\n *\n * Available names depend on the icon library being used.\n */\n @Prop({ reflect: true }) public readonly iconName?: string\n\n /**\n * The name of a registered icon library.\n */\n @Prop({ reflect: true }) public readonly iconLibrary: string = 'default'\n\n /**\n * The button's importance.\n */\n @Prop({ reflect: true }) public readonly importance: Importance = 'standard'\n\n /**\n * The button's size.\n */\n @Prop({ reflect: true }) public readonly size: ButtonSize = 'standard'\n\n /**\n * The button's text.\n */\n @Prop({ mutable: true, reflect: true }) public readonly text?: string\n\n /**\n * Prevents the button from being interacted with: it cannot be pressed or\n * focused.\n *\n * @webnative\n */\n @Prop({ mutable: true, reflect: true }) public disabled?: boolean\n\n /**\n * Tells the browser to download the linked file as this filename. Only used\n * when `href` is set.\n *\n * @webnative\n */\n @Prop() public readonly download?: string\n\n /**\n * The [`<form>`](https://developer.mozilla.org/docs/Web/HTML/Element/form)\n * element to associate the button with (its form owner).\n *\n * The value of this attribute must be the id of a `<form>` in the same\n * document. If this attribute is not set, the `<button>` is associated with\n * its ancestor `<form>` element, if any.\n *\n * This attribute lets you associate `<button>` elements to `<form>`s\n * anywhere in the document, not just inside a `<form>`. It can also override\n * an ancestor `<form>` element.\n *\n * @webnative\n */\n @Prop() public readonly form?: string\n\n /**\n * The URL that processes the information submitted by the button. Overrides\n * the [`action`](https://developer.mozilla.org/docs/Web/HTML/Element/button#attr-formaction)\n * attribute of the button's form owner. Does nothing if there is no form owner.\n *\n * @webnative\n */\n @Prop({ attribute: 'formaction' }) public readonly formAction?: string\n\n /**\n * If the button is a submit button (it's inside/associated with a `<form>`\n * and doesn't have `type=\"button\"`), this attribute specifies the\n * [HTTP method][] used to submit the form, or `dialog` which won't submit\n * the form. Possible values:\n *\n * - `get`: The form data are appended to the form's action URL, with a ? as\n * a separator, and the resulting URL is sent to the server. Use this method\n * when the form has no side effects, like search forms.\n * - `post`: The data from the form are included in the body of the HTTP\n * request when sent to the server. Use when the form contains information\n * that shouldn't be public, like login credentials.\n * - `dialog`: Close the dialog box in which the button finds itself, if any,\n * and do not submit the button's form owner.\n *\n * If specified, this attribute overrides the `method` attribute of the\n * button's form owner.\n *\n * [HTTP method]: https://developer.mozilla.org/docs/Web/HTTP/Methods\n *\n * @webnative\n */\n @Prop({ attribute: 'formmethod' }) public readonly formMethod?: FormMethod\n\n /**\n * If the button is a submit button, this attribute specifies that the form\n * is not to be\n * [validated](https://developer.mozilla.org/docs/Learn/Forms/Form_validation)\n * when it is submitted. If this attribute is specified, it overrides the\n * [`novalidate`](https://developer.mozilla.org/docs/Web/HTML/Element/form#attr-novalidate)\n * attribute of the button's form owner.\n *\n * @webnative\n */\n @Prop({ attribute: 'formnovalidate' })\n public readonly formNoValidate: boolean = false\n\n /**\n * If the button is a submit button, this attribute is an author-defined name\n * or standardized, underscore-prefixed keyword indicating where to display\n * the response from submitting the form. This is the `name` of, or keyword\n * for, a browsing context (a tab, window, or\n * [`<iframe>`](https://developer.mozilla.org/docs/Web/HTML/Element/iframe)).\n * If this attribute is specified, it overrides the\n * [`target`](https://developer.mozilla.org/docs/Web/HTML/Element/form#attr-target)\n * attribute of the button's form owner. The following keywords have special\n * meanings:\n *\n * - `_blank`: Load the response into a new unnamed browsing context — usually\n * a new tab or window, depending on the user's browser settings.\n * - `_parent`: Load the response into the parent browsing context of the\n * current one. If there is no parent, this option behaves the same way as\n * `_self`.\n * - `_self`: Load the response into the same browsing context as the current\n * one.\n * - `_top`: Load the response into the top-level browsing context (that is,\n * the browsing context that is an ancestor of the current one, and has no\n * parent). If there is no parent, this option behaves the same way as\n * `_self`.\n *\n * @webnative\n */\n @Prop({ attribute: 'formtarget' })\n public readonly formTarget: LiteralUnion<ButtonTarget, string> = '_self'\n\n /**\n * When set, the underlying button will be rendered as an `<a>` with this\n * `href` instead of a `<button>`.\n *\n * @webnative\n */\n @Prop() public readonly href?: string\n\n /**\n * The name of the button, submitted as a pair with the button's `value` as\n * part of the form data, when that button is used to submit the form.\n * Ignored when `href` is set.\n *\n * @webnative\n */\n @Prop() public readonly name?: string\n\n /**\n * Where to display the linked URL, as the name for a browsing context (a\n * tab, window, or\n * [`<iframe>`](https://developer.mozilla.org/docs/Web/HTML/Element/iframe).\n * The following keywords have special meanings for where to load the URL:\n *\n * - `_blank`: usually a new tab, but users can configure browsers to open a new\n * window instead.\n * - `_parent`: the parent browsing context of the current one. If no parent,\n * behaves as `_self`.\n * - `_self`: the current browsing context.\n * - `_top`: the topmost browsing context (the \"highest\" context that's an\n * ancestor of the current one). If no ancestors, behaves as `_self`.\n *\n * @webnative\n */\n @Prop() public readonly target: LiteralUnion<ButtonTarget, string> = '_self'\n\n /**\n * The type of button.\n *\n * `button`: The button has no default behavior, and does nothing when\n * pressed by default. It can have client-side scripts listen to the\n * element's events, which are triggered when the events occur.\n *\n * `submit`: The button submits the form data to the server. This is the\n * default if the attribute is not specified for buttons associated with a\n * `<form>`, or if the attribute is an empty or invalid value.\n *\n * `reset`: The button resets all the controls to their initial values.\n *\n * @webnative\n */\n @Prop() public readonly type?: ButtonType\n\n /**\n * Defines the value associated with the button's `name` when it's submitted\n * with the form data. This value is passed to the server in params when the\n * form is submitted using this button. Ignored when `href` is set.\n *\n * @webnative\n */\n @Prop() public readonly value?: string\n\n /**\n * Emitted when the button loses focus.\n */\n @Event({ eventName: 'qdsBlur', bubbles: false, cancelable: false })\n private readonly blurEmitter!: EventEmitter<QdsFocusEventDetail>\n\n /**\n * Emitted when the button gains focus.\n */\n @Event({ eventName: 'qdsFocus', bubbles: false, cancelable: false })\n private readonly focusEmitter!: EventEmitter<QdsFocusEventDetail>\n\n @Element() private readonly element!: HTMLQdsButtonElement\n\n private inheritedAttributes: Attributes = {}\n\n private get formElement(): HTMLElement | null {\n return this.form !== undefined && this.form !== ''\n ? document.querySelector(`#${this.form}`)\n : this.element.closest('form')\n }\n\n private get buttonType(): ButtonType {\n if (this.type === undefined) return this.formElement ? 'submit' : 'button'\n return this.type\n }\n\n private get iconOnly(): boolean {\n const hasIcon = this.iconName !== undefined && this.iconName !== ''\n const hasNoLabel = this.text === undefined || this.text === ''\n\n return hasIcon && hasNoLabel\n }\n\n private get computedDisabled(): boolean {\n return this.disabled ?? false\n }\n\n private get computedTabIndex(): number {\n const parsedValue = Number.parseInt(this.inheritedAttributes.tabindex, 10)\n return Number.isNaN(parsedValue) ? 0 : parsedValue\n }\n\n @Listen('click')\n protected onClick(event: MouseEvent): void {\n if (this.computedDisabled) {\n event.preventDefault()\n event.stopPropagation()\n }\n\n if (this.buttonType === 'button' || !this.formElement) return\n event.preventDefault()\n\n const fakeButton = document.createElement('button')\n fakeButton.type = this.buttonType\n if (this.name !== undefined) fakeButton.name = this.name\n if (this.value !== undefined) fakeButton.value = this.value\n if (this.formAction !== undefined) fakeButton.formAction = this.formAction\n if (this.formMethod !== undefined) fakeButton.formMethod = this.formMethod\n fakeButton.formNoValidate = this.formNoValidate\n fakeButton.formTarget = this.formTarget\n fakeButton.style.display = 'none'\n\n this.formElement.append(fakeButton)\n fakeButton.click()\n fakeButton.remove()\n }\n\n public componentWillLoad(): void {\n this.inheritedAttributes = inheritAriaAttributes(this.element)\n }\n\n public render() {\n const Tag = this.href === undefined ? 'button' : 'a'\n\n return (\n <Tag\n aria-disabled={this.computedDisabled.toString()}\n class={{\n 'qds-button': true,\n 'qds-icon-only': this.iconOnly,\n }}\n data-importance={this.importance}\n data-size={this.size}\n disabled={Tag === 'a' ? undefined : this.disabled}\n download={Tag === 'a' ? this.download : undefined}\n href={Tag === 'a' ? this.href : undefined}\n name={Tag === 'a' ? undefined : this.name}\n onBlur={this.onBlur}\n onFocus={this.onFocus}\n rel={Tag === 'a' ? 'noreferrer noopener' : undefined}\n role={Tag === 'a' ? 'button' : undefined}\n tabIndex={this.computedDisabled ? -1 : this.computedTabIndex}\n target={Tag === 'a' ? this.target : undefined}\n type={Tag === 'a' ? undefined : this.buttonType}\n value={Tag === 'a' ? undefined : this.value}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...this.inheritedAttributes}\n >\n {this.iconName !== undefined && this.iconName !== '' && (\n <qds-icon\n class=\"qds-icon\"\n data-size={this.size}\n library={this.iconLibrary}\n name={this.iconName}\n />\n )}\n {this.text}\n </Tag>\n )\n }\n\n private readonly onBlur = (event: FocusEvent): void => {\n this.blurEmitter.emit(pickFocusEventAttributes(event))\n }\n\n private readonly onFocus = (event: FocusEvent): void => {\n this.focusEmitter.emit(pickFocusEventAttributes(event))\n }\n}\n"],"version":3}
@@ -92,7 +92,7 @@ const Checkbox = /*@__PURE__*/ proxyCustomElement(class Checkbox extends HTMLEle
92
92
  render() {
93
93
  return (
94
94
  // eslint-disable-next-line jsx-a11y/label-has-associated-control
95
- h("label", { "aria-disabled": this.computedDisabled ? 'true' : 'false', class: {
95
+ h("label", { "aria-disabled": this.computedDisabled.toString(), class: {
96
96
  'qds-inline': this.inline,
97
97
  'qds-label': true,
98
98
  }, "data-size": this.size }, h("input", {
@@ -1 +1 @@
1
- {"file":"qds-checkbox.js","mappings":";;;;;;;;;;AAAA,MAAM,WAAW,GAAG,kgGAAkgG;;AC0BthG,IAAI,kBAAkB,GAAG,CAAC,CAAA;MAcb,QAAQ;;;;;;;IAmHX,wBAAmB,GAAe,EAAE,CAAA;IAoI3B,QAAG,GAAG,CAAC,QAA2B;MACjD,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAA;KACtB,CAAA;IAEgB,WAAM,GAAG,CAAC,KAAiB;MAC1C,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC,CAAA;KACvD,CAAA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,eACU,IAAI,CAAC,IAAI,EACpB,OAAO,EAAC,MAAM,EACd,IAAI,EAAC,eAAe,GACpB,EACD,IAAI,CAAC,OAAO,KACX,iBACE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,IAAI,EAAE,IAAI,CAAC,IAAI,GACf,CACH,CACK,EACT;GACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/checkbox/checkbox.css?tag=qds-checkbox&encapsulation=scoped","src/components/checkbox/checkbox.tsx"],"sourcesContent":["/*\n * SPDX-FileCopyrightText: © 2023 Schneider Electric\n *\n * SPDX-License-Identifier: LGPL-2.1-only\n */\n\n@import url('../shared.css');\n\n:host {\n display: inline-block;\n line-height: 0;\n}\n\n.qds-icon {\n display: none;\n color: var(--qds-theme-signature-color-contrast);\n inset-inline-start: 0;\n pointer-events: none;\n position: absolute;\n}\n\n.qds-label {\n box-sizing: border-box;\n cursor: pointer;\n display: inline-flex;\n position: relative;\n}\n\n.qds-checkbox {\n align-items: center;\n appearance: none;\n background-color: var(--qds-theme-control-input-background);\n border-radius: var(--qds-control-border-radius);\n border: var(--qds-control-border-width) solid var(--qds-theme-control-border);\n cursor: pointer;\n display: flex;\n flex-shrink: 0;\n justify-content: center;\n margin: 0;\n print-color-adjust: exact;\n\n &:focus-visible {\n outline: var(--qds-theme-focus-border) solid var(--qds-focus-border-width);\n outline-offset: var(--qds-focus-border-offset);\n }\n\n &::before {\n content: '';\n height: 10px;\n position: absolute;\n width: 10px;\n }\n\n &:hover::before {\n box-shadow: inset 1em 1em var(--qds-theme-signature-color-hover);\n }\n\n &:active::before {\n box-shadow: inset 1em 1em var(--qds-theme-signature-color-pressed);\n }\n\n &:checked ~ .qds-checked,\n &:indeterminate ~ .qds-indeterminate {\n display: inline-block;\n }\n\n &:checked,\n &:indeterminate {\n background-color: var(--qds-theme-signature-color-default);\n border-color: transparent;\n\n &:hover {\n background-color: var(--qds-theme-signature-color-hover);\n }\n\n &:active {\n background-color: var(--qds-theme-signature-color-pressed);\n }\n }\n}\n\n[aria-disabled='true'] {\n opacity: var(--qds-theme-disabled);\n pointer-events: none;\n}\n\n[data-size='small'] {\n &:is(.qds-icon, .qds-checkbox) {\n width: var(--qds-control-small-icon-size);\n height: var(--qds-control-small-icon-size);\n }\n\n &.qds-inline {\n margin-block: var(--qds-control-small-padding-auto-height);\n }\n\n &.qds-label {\n gap: var(--qds-control-small-gap-siblings-related);\n }\n}\n\n[data-size='standard'] {\n &:is(.qds-icon, .qds-checkbox) {\n width: var(--qds-control-standard-icon-size);\n height: var(--qds-control-standard-icon-size);\n }\n\n &.qds-inline {\n margin-block: var(--qds-control-standard-padding-auto-height);\n }\n\n &.qds-label {\n gap: var(--qds-control-standard-gap-siblings-related);\n }\n}\n\n[data-size='large'] {\n &:is(.qds-icon, .qds-checkbox) {\n width: var(--qds-control-large-icon-size);\n height: var(--qds-control-large-icon-size);\n }\n\n &.qds-inline {\n margin-block: var(--qds-control-large-padding-auto-height);\n }\n\n &.qds-label {\n gap: var(--qds-control-large-gap-siblings-related);\n }\n}\n","// SPDX-FileCopyrightText: © 2023 Schneider Electric\n//\n// SPDX-License-Identifier: LGPL-2.1-only\n\nimport type { ComponentInterface, EventEmitter } from '@stencil/core'\nimport {\n Component,\n Element,\n Event,\n h,\n Listen,\n Method,\n Prop,\n} from '@stencil/core'\n\nimport type { Attributes, QdsFocusEventDetail } from '../../helpers'\nimport {\n inheritAriaAttributes,\n inheritAttributes,\n invariant,\n pickFocusEventAttributes,\n} from '../../helpers'\n\nexport type CheckboxValue = number | string | null\nexport type CheckboxSize = 'large' | 'small' | 'standard'\n\nlet autoIncrementingId = 1\n\n/**\n * `<qds-checkbox>` elements are rendered as boxes that are checked (ticked)\n * when activated, like you might see in an official government paper form. A\n * checkbox allows you to select single values for submission in a form (or not).\n *\n * @see https://quartz.se.com/build/components/checkbox\n */\n@Component({\n tag: 'qds-checkbox',\n scoped: true,\n styleUrl: 'checkbox.css',\n})\nexport class Checkbox implements ComponentInterface {\n /**\n * Adds vertical margin to the checkbox for alignment.\n *\n * This is useful when creating inline layouts so that the first lines have\n * the correct vertical centering.\n */\n @Prop() public readonly inline: boolean = false\n\n /**\n * The checkbox's size.\n */\n @Prop({ reflect: true }) public readonly size: CheckboxSize = 'standard'\n\n /**\n * The checkbox's text.\n */\n @Prop({ mutable: true, reflect: true }) public readonly text?: string\n\n /**\n * Specify whether the checkbox should have focus when the page loads.\n *\n * @webnative\n */\n @Prop({ attribute: 'autofocus' }) public readonly autoFocus?: boolean\n\n /**\n * Sets the checkbox's state.\n *\n * @webnative\n */\n @Prop({ mutable: true, reflect: true }) public checked?: boolean\n\n /**\n * Prevents the checkbox from being interacted with: it cannot be pressed or\n * focused.\n *\n * @webnative\n */\n @Prop({ mutable: true, reflect: true }) public disabled?: boolean\n\n /**\n * The [`<form>`](https://developer.mozilla.org/docs/Web/HTML/Element/form)\n * element to associate the checkbox with (its form owner).\n *\n * The value of this property must be the id of a `<form>` in the same\n * document. If this property is not set, the `<qds-checkbox>` is associated\n * with its ancestor `<form>` element, if any.\n *\n * This property lets you associate `<qds-checkbox>` elements to `<form>`s\n * anywhere in the document, not just inside a `<form>`. It can also override\n * an ancestor `<form>` element.\n *\n * @webnative\n */\n @Prop() public readonly form?: string\n\n /**\n * Sets the checkbox to an indeterminate state. This is usually applied to\n * checkboxes that represents a \"select all/none\" behavior when associated\n * checkboxes have a mix of checked and unchecked states.\n *\n * @webnative\n */\n @Prop({ mutable: true, reflect: true }) public indeterminate?: boolean\n\n /**\n * The name of the checkbox, which is submitted with the form data. An\n * incrementing ID is used by default.\n *\n * @webnative\n */\n @Prop() public readonly name = `qds-checkbox-${autoIncrementingId}`\n\n /**\n * A value must be specified for the checkbox before the owning form can be\n * submitted.\n *\n * See\n * [Client-side validation](https://developer.mozilla.org/docs/Web/HTML/Element/input#client-side_validation)\n * and the\n * [HTML attribute: `required`](https://developer.mozilla.org/docs/Web/HTML/Attributes/required)\n * for more information.\n *\n * @webnative\n */\n @Prop() public readonly required?: boolean\n\n /**\n * The value of the checkbox, submitted as a name/value pair with form data.\n *\n * @webnative\n */\n @Prop({ mutable: true }) public value?: CheckboxValue\n\n /**\n * Emitted when the checkbox loses focus.\n */\n @Event({ eventName: 'qdsBlur', bubbles: false, cancelable: false })\n private readonly blurEmitter!: EventEmitter<QdsFocusEventDetail>\n\n /**\n * Emitted when a change to the checkbox's state is committed by the user.\n */\n @Event({ eventName: 'qdsChange', cancelable: false })\n private readonly changeEmitter!: EventEmitter<void>\n\n /**\n * Emitted when the checkbox gains focus.\n */\n @Event({ eventName: 'qdsFocus', bubbles: false, cancelable: false })\n private readonly focusEmitter!: EventEmitter<QdsFocusEventDetail>\n\n @Element() private readonly element!: HTMLQdsCheckboxElement\n\n private inheritedAttributes: Attributes = {}\n\n private input?: HTMLInputElement\n\n private get computedDisabled(): boolean {\n return this.disabled ?? false\n }\n\n private get computedIndeterminate(): boolean {\n return this.indeterminate ?? false\n }\n\n private get hasText(): boolean {\n return (\n (this.text !== undefined && this.text !== '') || this.required === true\n )\n }\n\n /**\n * Returns whether a form will validate this checkbox when it is submitted\n * without having to submit it.\n */\n @Method()\n public async checkValidity(): Promise<boolean> {\n invariant(this.input)\n\n return this.input.checkValidity()\n }\n\n /**\n * Returns true if the checkbox's value passes validity checks; otherwise,\n * returns false, and (if the event isn't canceled) reports the problem to\n * the user.\n */\n @Method()\n public async reportValidity(): Promise<boolean> {\n invariant(this.input)\n\n return this.input.reportValidity()\n }\n\n /**\n * Sets a custom validity message for the checkbox. If this message is not the\n * empty string, then the checkbox is considered invalid.\n */\n @Method()\n public async setCustomValidity(message: string): Promise<void> {\n invariant(this.input)\n\n this.input.setCustomValidity(message)\n }\n\n @Listen('click')\n protected onClick(event: MouseEvent): void {\n if (this.computedDisabled) return\n\n event.preventDefault()\n\n this.checked = this.computedIndeterminate ? true : !(this.checked ?? false)\n this.changeEmitter.emit()\n this.indeterminate = false\n }\n\n public componentWillLoad(): void {\n autoIncrementingId += 1\n this.inheritedAttributes = {\n ...inheritAriaAttributes(this.element),\n ...inheritAttributes(this.element, ['tabindex']),\n }\n }\n\n public render() {\n return (\n // eslint-disable-next-line jsx-a11y/label-has-associated-control\n <label\n aria-disabled={this.computedDisabled ? 'true' : 'false'}\n class={{\n 'qds-inline': this.inline,\n 'qds-label': true,\n }}\n data-size={this.size}\n >\n <input\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={this.autoFocus}\n checked={this.computedIndeterminate ? false : this.checked}\n class=\"qds-checkbox\"\n data-size={this.size}\n disabled={this.disabled}\n form={this.form}\n indeterminate={this.indeterminate}\n name={this.name}\n onBlur={this.onBlur}\n onFocus={this.onFocus}\n ref={this.ref}\n required={this.required}\n type=\"checkbox\"\n value={this.value ?? undefined}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...this.inheritedAttributes}\n />\n <qds-icon\n aria-hidden=\"true\"\n class={{\n 'qds-icon': true,\n 'qds-checked': true,\n }}\n data-size={this.size}\n library=\"core\"\n name=\"checked\"\n />\n <qds-icon\n aria-hidden=\"true\"\n class={{\n 'qds-icon': true,\n 'qds-indeterminate': true,\n }}\n data-size={this.size}\n library=\"core\"\n name=\"indeterminate\"\n />\n {this.hasText && (\n <qds-label\n required={this.required}\n size={this.size}\n text={this.text}\n />\n )}\n </label>\n )\n }\n\n private readonly ref = (checkbox?: HTMLInputElement): void => {\n this.input = checkbox\n }\n\n private readonly onBlur = (event: FocusEvent): void => {\n this.blurEmitter.emit(pickFocusEventAttributes(event))\n }\n\n private readonly onFocus = (event: FocusEvent): void => {\n this.focusEmitter.emit(pickFocusEventAttributes(event))\n }\n}\n"],"version":3}
1
+ {"file":"qds-checkbox.js","mappings":";;;;;;;;;;AAAA,MAAM,WAAW,GAAG,kgGAAkgG;;AC0BthG,IAAI,kBAAkB,GAAG,CAAC,CAAA;MAcb,QAAQ;;;;;;;IAmHX,wBAAmB,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AAK,EAAE;QACL,UAAU,EAAE,IAAI;QAChB,aAAa,EAAE,IAAI;OACpB,eACU,IAAI,CAAC,IAAI,EACpB,OAAO,EAAC,MAAM,EACd,IAAI,EAAC,SAAS,GACd,EACF,+BACc,MAAM,EAClB,KAAK,EAAE;QACL,UAAU,EAAE,IAAI;QAChB,mBAAmB,EAAE,IAAI;OAC1B,eACU,IAAI,CAAC,IAAI,EACpB,OAAO,EAAC,MAAM,EACd,IAAI,EAAC,eAAe,GACpB,EACD,IAAI,CAAC,OAAO,KACX,iBACE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,IAAI,EAAE,IAAI,CAAC,IAAI,GACf,CACH,CACK,EACT;GACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/checkbox/checkbox.css?tag=qds-checkbox&encapsulation=scoped","src/components/checkbox/checkbox.tsx"],"sourcesContent":["/*\n * SPDX-FileCopyrightText: © 2023 Schneider Electric\n *\n * SPDX-License-Identifier: LGPL-2.1-only\n */\n\n@import url('../shared.css');\n\n:host {\n display: inline-block;\n line-height: 0;\n}\n\n.qds-icon {\n display: none;\n color: var(--qds-theme-signature-color-contrast);\n inset-inline-start: 0;\n pointer-events: none;\n position: absolute;\n}\n\n.qds-label {\n box-sizing: border-box;\n cursor: pointer;\n display: inline-flex;\n position: relative;\n}\n\n.qds-checkbox {\n align-items: center;\n appearance: none;\n background-color: var(--qds-theme-control-input-background);\n border-radius: var(--qds-control-border-radius);\n border: var(--qds-control-border-width) solid var(--qds-theme-control-border);\n cursor: pointer;\n display: flex;\n flex-shrink: 0;\n justify-content: center;\n margin: 0;\n print-color-adjust: exact;\n\n &:focus-visible {\n outline: var(--qds-theme-focus-border) solid var(--qds-focus-border-width);\n outline-offset: var(--qds-focus-border-offset);\n }\n\n &::before {\n content: '';\n height: 10px;\n position: absolute;\n width: 10px;\n }\n\n &:hover::before {\n box-shadow: inset 1em 1em var(--qds-theme-signature-color-hover);\n }\n\n &:active::before {\n box-shadow: inset 1em 1em var(--qds-theme-signature-color-pressed);\n }\n\n &:checked ~ .qds-checked,\n &:indeterminate ~ .qds-indeterminate {\n display: inline-block;\n }\n\n &:checked,\n &:indeterminate {\n background-color: var(--qds-theme-signature-color-default);\n border-color: transparent;\n\n &:hover {\n background-color: var(--qds-theme-signature-color-hover);\n }\n\n &:active {\n background-color: var(--qds-theme-signature-color-pressed);\n }\n }\n}\n\n[aria-disabled='true'] {\n opacity: var(--qds-theme-disabled);\n pointer-events: none;\n}\n\n[data-size='small'] {\n &:is(.qds-icon, .qds-checkbox) {\n width: var(--qds-control-small-icon-size);\n height: var(--qds-control-small-icon-size);\n }\n\n &.qds-inline {\n margin-block: var(--qds-control-small-padding-auto-height);\n }\n\n &.qds-label {\n gap: var(--qds-control-small-gap-siblings-related);\n }\n}\n\n[data-size='standard'] {\n &:is(.qds-icon, .qds-checkbox) {\n width: var(--qds-control-standard-icon-size);\n height: var(--qds-control-standard-icon-size);\n }\n\n &.qds-inline {\n margin-block: var(--qds-control-standard-padding-auto-height);\n }\n\n &.qds-label {\n gap: var(--qds-control-standard-gap-siblings-related);\n }\n}\n\n[data-size='large'] {\n &:is(.qds-icon, .qds-checkbox) {\n width: var(--qds-control-large-icon-size);\n height: var(--qds-control-large-icon-size);\n }\n\n &.qds-inline {\n margin-block: var(--qds-control-large-padding-auto-height);\n }\n\n &.qds-label {\n gap: var(--qds-control-large-gap-siblings-related);\n }\n}\n","// SPDX-FileCopyrightText: © 2023 Schneider Electric\n//\n// SPDX-License-Identifier: LGPL-2.1-only\n\nimport type { ComponentInterface, EventEmitter } from '@stencil/core'\nimport {\n Component,\n Element,\n Event,\n h,\n Listen,\n Method,\n Prop,\n} from '@stencil/core'\n\nimport type { Attributes, QdsFocusEventDetail } from '../../helpers'\nimport {\n inheritAriaAttributes,\n inheritAttributes,\n invariant,\n pickFocusEventAttributes,\n} from '../../helpers'\n\nexport type CheckboxValue = number | string | null\nexport type CheckboxSize = 'large' | 'small' | 'standard'\n\nlet autoIncrementingId = 1\n\n/**\n * `<qds-checkbox>` elements are rendered as boxes that are checked (ticked)\n * when activated, like you might see in an official government paper form. A\n * checkbox allows you to select single values for submission in a form (or not).\n *\n * @see https://quartz.se.com/build/components/checkbox\n */\n@Component({\n tag: 'qds-checkbox',\n scoped: true,\n styleUrl: 'checkbox.css',\n})\nexport class Checkbox implements ComponentInterface {\n /**\n * Adds vertical margin to the checkbox for alignment.\n *\n * This is useful when creating inline layouts so that the first lines have\n * the correct vertical centering.\n */\n @Prop() public readonly inline: boolean = false\n\n /**\n * The checkbox's size.\n */\n @Prop({ reflect: true }) public readonly size: CheckboxSize = 'standard'\n\n /**\n * The checkbox's text.\n */\n @Prop({ mutable: true, reflect: true }) public readonly text?: string\n\n /**\n * Specify whether the checkbox should have focus when the page loads.\n *\n * @webnative\n */\n @Prop({ attribute: 'autofocus' }) public readonly autoFocus?: boolean\n\n /**\n * Sets the checkbox's state.\n *\n * @webnative\n */\n @Prop({ mutable: true, reflect: true }) public checked?: boolean\n\n /**\n * Prevents the checkbox from being interacted with: it cannot be pressed or\n * focused.\n *\n * @webnative\n */\n @Prop({ mutable: true, reflect: true }) public disabled?: boolean\n\n /**\n * The [`<form>`](https://developer.mozilla.org/docs/Web/HTML/Element/form)\n * element to associate the checkbox with (its form owner).\n *\n * The value of this property must be the id of a `<form>` in the same\n * document. If this property is not set, the `<qds-checkbox>` is associated\n * with its ancestor `<form>` element, if any.\n *\n * This property lets you associate `<qds-checkbox>` elements to `<form>`s\n * anywhere in the document, not just inside a `<form>`. It can also override\n * an ancestor `<form>` element.\n *\n * @webnative\n */\n @Prop() public readonly form?: string\n\n /**\n * Sets the checkbox to an indeterminate state. This is usually applied to\n * checkboxes that represents a \"select all/none\" behavior when associated\n * checkboxes have a mix of checked and unchecked states.\n *\n * @webnative\n */\n @Prop({ mutable: true, reflect: true }) public indeterminate?: boolean\n\n /**\n * The name of the checkbox, which is submitted with the form data. An\n * incrementing ID is used by default.\n *\n * @webnative\n */\n @Prop() public readonly name = `qds-checkbox-${autoIncrementingId}`\n\n /**\n * A value must be specified for the checkbox before the owning form can be\n * submitted.\n *\n * See\n * [Client-side validation](https://developer.mozilla.org/docs/Web/HTML/Element/input#client-side_validation)\n * and the\n * [HTML attribute: `required`](https://developer.mozilla.org/docs/Web/HTML/Attributes/required)\n * for more information.\n *\n * @webnative\n */\n @Prop() public readonly required?: boolean\n\n /**\n * The value of the checkbox, submitted as a name/value pair with form data.\n *\n * @webnative\n */\n @Prop({ mutable: true }) public value?: CheckboxValue\n\n /**\n * Emitted when the checkbox loses focus.\n */\n @Event({ eventName: 'qdsBlur', bubbles: false, cancelable: false })\n private readonly blurEmitter!: EventEmitter<QdsFocusEventDetail>\n\n /**\n * Emitted when a change to the checkbox's state is committed by the user.\n */\n @Event({ eventName: 'qdsChange', cancelable: false })\n private readonly changeEmitter!: EventEmitter<void>\n\n /**\n * Emitted when the checkbox gains focus.\n */\n @Event({ eventName: 'qdsFocus', bubbles: false, cancelable: false })\n private readonly focusEmitter!: EventEmitter<QdsFocusEventDetail>\n\n @Element() private readonly element!: HTMLQdsCheckboxElement\n\n private inheritedAttributes: Attributes = {}\n\n private input?: HTMLInputElement\n\n private get computedDisabled(): boolean {\n return this.disabled ?? false\n }\n\n private get computedIndeterminate(): boolean {\n return this.indeterminate ?? false\n }\n\n private get hasText(): boolean {\n return (\n (this.text !== undefined && this.text !== '') || this.required === true\n )\n }\n\n /**\n * Returns whether a form will validate this checkbox when it is submitted\n * without having to submit it.\n */\n @Method()\n public async checkValidity(): Promise<boolean> {\n invariant(this.input)\n\n return this.input.checkValidity()\n }\n\n /**\n * Returns true if the checkbox's value passes validity checks; otherwise,\n * returns false, and (if the event isn't canceled) reports the problem to\n * the user.\n */\n @Method()\n public async reportValidity(): Promise<boolean> {\n invariant(this.input)\n\n return this.input.reportValidity()\n }\n\n /**\n * Sets a custom validity message for the checkbox. If this message is not the\n * empty string, then the checkbox is considered invalid.\n */\n @Method()\n public async setCustomValidity(message: string): Promise<void> {\n invariant(this.input)\n\n this.input.setCustomValidity(message)\n }\n\n @Listen('click')\n protected onClick(event: MouseEvent): void {\n if (this.computedDisabled) return\n\n event.preventDefault()\n\n this.checked = this.computedIndeterminate ? true : !(this.checked ?? false)\n this.changeEmitter.emit()\n this.indeterminate = false\n }\n\n public componentWillLoad(): void {\n autoIncrementingId += 1\n this.inheritedAttributes = {\n ...inheritAriaAttributes(this.element),\n ...inheritAttributes(this.element, ['tabindex']),\n }\n }\n\n public render() {\n return (\n // eslint-disable-next-line jsx-a11y/label-has-associated-control\n <label\n aria-disabled={this.computedDisabled.toString()}\n class={{\n 'qds-inline': this.inline,\n 'qds-label': true,\n }}\n data-size={this.size}\n >\n <input\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={this.autoFocus}\n checked={this.computedIndeterminate ? false : this.checked}\n class=\"qds-checkbox\"\n data-size={this.size}\n disabled={this.disabled}\n form={this.form}\n indeterminate={this.indeterminate}\n name={this.name}\n onBlur={this.onBlur}\n onFocus={this.onFocus}\n ref={this.ref}\n required={this.required}\n type=\"checkbox\"\n value={this.value ?? undefined}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...this.inheritedAttributes}\n />\n <qds-icon\n aria-hidden=\"true\"\n class={{\n 'qds-icon': true,\n 'qds-checked': true,\n }}\n data-size={this.size}\n library=\"core\"\n name=\"checked\"\n />\n <qds-icon\n aria-hidden=\"true\"\n class={{\n 'qds-icon': true,\n 'qds-indeterminate': true,\n }}\n data-size={this.size}\n library=\"core\"\n name=\"indeterminate\"\n />\n {this.hasText && (\n <qds-label\n required={this.required}\n size={this.size}\n text={this.text}\n />\n )}\n </label>\n )\n }\n\n private readonly ref = (checkbox?: HTMLInputElement): void => {\n this.input = checkbox\n }\n\n private readonly onBlur = (event: FocusEvent): void => {\n this.blurEmitter.emit(pickFocusEventAttributes(event))\n }\n\n private readonly onFocus = (event: FocusEvent): void => {\n this.focusEmitter.emit(pickFocusEventAttributes(event))\n }\n}\n"],"version":3}
@@ -85,6 +85,8 @@ const Dialog = /*@__PURE__*/ proxyCustomElement(class Dialog extends HTMLElement
85
85
  "open": [1540],
86
86
  "show": [64],
87
87
  "close": [64]
88
+ }, undefined, {
89
+ "open": ["openChanged"]
88
90
  }]);
89
91
  function defineCustomElement$1() {
90
92
  if (typeof customElements === "undefined") {
@@ -1 +1 @@
1
- {"file":"qds-dialog.js","mappings":";;;;;;;;AAAA,MAAM,SAAS,GAAG,0kCAA0kC;;MC8B/kC,MAAM;;;;;;;IA8BT,wBAAmB,GAAe,EAAE,CAAA;IA6E3B,gBAAW,GAAG,CAAC,KAAY;MAC1C,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAA;KACxC,CAAA;IAEgB,aAAQ,GAAG,CAAC,KAAY;MACvC,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC,gBAAgB;QAAE,KAAK,CAAC,cAAc,EAAE,CAAA;KACvE,CAAA;IAEgB,YAAO,GAAG;MACzB,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;MAEtB,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,CAAA;MACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAA;KAC7B,CAAA;IAEgB,QAAG,GAAG,CAAC,MAA0B;MAChD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;KACrB,CAAA;gBAtHqD,KAAK;;;;;;;;;EAoCpD,MAAM,IAAI;IACf,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAEtB,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAA;IACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAA;GAC7B;;;;EAMM,MAAM,KAAK;IAChB,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,C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sourcesContent":["/*\n * SPDX-FileCopyrightText: © 2023 Schneider Electric\n *\n * SPDX-License-Identifier: LGPL-2.1-only\n */\n\n@import url('../shared.css');\n\n:host {\n display: none;\n position: fixed;\n inset: 0;\n}\n\n:host([open]) {\n display: block;\n}\n\n.qds-dialog {\n border-radius: var(--qds-popup-border-radius);\n border: none;\n box-shadow: var(--qds-theme-popup-elevation);\n padding: 0;\n\n &::backdrop {\n background: initial;\n }\n\n &[open] ~ .qds-backdrop {\n backdrop-filter: blur(var(--qds-theme-popup-overlay-blur));\n background-color: var(--qds-theme-popup-overlay-background);\n inset: 0;\n opacity: var(--qds-theme-popup-overlay-opacity);\n position: fixed;\n }\n}\n\n.qds-content {\n align-items: flex-start;\n background-color: var(--qds-theme-popup-background);\n display: flex;\n flex-direction: column;\n gap: var(--qds-popup-gap-children-related);\n padding: var(--qds-popup-padding);\n}\n\n::slotted(blockquote),\n::slotted(button),\n::slotted(dd),\n::slotted(dl),\n::slotted(fieldset),\n::slotted(figure),\n::slotted(h1),\n::slotted(h2),\n::slotted(h3),\n::slotted(h4),\n::slotted(h5),\n::slotted(h6),\n::slotted(hr),\n::slotted(input),\n::slotted(menu),\n::slotted(ol),\n::slotted(p),\n::slotted(pre),\n::slotted(select),\n::slotted(textarea),\n::slotted(ul) {\n margin: 0;\n}\n","// SPDX-FileCopyrightText: © 2023 Schneider Electric\n//\n// SPDX-License-Identifier: LGPL-2.1-only\n\nimport type { ComponentInterface, EventEmitter } from '@stencil/core'\nimport {\n Component,\n Element,\n Event,\n h,\n Host,\n Method,\n Prop,\n Watch,\n} from '@stencil/core'\n\nimport type { Attributes } from '../../helpers'\nimport { ignorePromise, inheritAriaAttributes, invariant } from '../../helpers'\n\n/**\n * The `<qds-dialog>` element represent a dialog box or other interactive\n * component, such as a dismissible alert, inspector, or subwindow.\n *\n * @see https://quartz.se.com/build/components/dialog\n */\n@Component({\n tag: 'qds-dialog',\n shadow: true,\n styleUrl: 'dialog.css',\n})\nexport class Dialog implements ComponentInterface {\n /**\n * Indicates whether or not the dialog is open. You can toggle this attribute\n * to show and hide the dialog, or you can use the `show()` and `close()`\n * methods and this attribute will reflect the dialog’s open state.\n */\n @Prop({ mutable: true, reflect: true }) public open = false\n\n @Element() private readonly element!: HTMLQdsDialogElement\n\n /**\n * Emitted when the user instructs the browser that they wish to dismiss the\n * currently open dialog. The browser fires this event when the user presses\n * the `Esc` key.\n *\n * When a dialog is dismissed with the `Esc` key, both the `qdsCancel` and\n * `qdsClose` events are fired.\n */\n @Event({ eventName: 'qdsCancel', bubbles: false, composed: false })\n private readonly cancelEmitter!: EventEmitter<void>\n\n /** Emitted when the dialog has been closed. */\n @Event({\n eventName: 'qdsClose',\n bubbles: false,\n cancelable: false,\n composed: false,\n })\n private readonly closeEmitter!: EventEmitter<void>\n\n private inheritedAttributes: Attributes = {}\n\n private dialog?: HTMLDialogElement\n\n /**\n * Displays the dialog over the top of any other dialogs that might be\n * present. Everything outside of the dialog is [inert][] with interactions\n * outside of the dialog being blocked.\n *\n * [inert]: https://developer.mozilla.org/docs/Web/API/HTMLElement/inert\n */\n @Method()\n public async show(): Promise<void> {\n invariant(this.dialog)\n\n this.dialog.showModal()\n this.open = this.dialog.open\n }\n\n /**\n * Closes the dialog.\n */\n @Method()\n public async close(): Promise<void> {\n invariant(this.dialog)\n\n this.dialog.close()\n }\n\n @Watch('open')\n protected async openChanged(): Promise<void> {\n await (this.open ? this.show() : this.close())\n }\n\n public componentWillLoad(): void {\n this.inheritedAttributes = inheritAriaAttributes(this.element)\n }\n\n public async componentDidLoad(): Promise<void> {\n if (this.open) await this.show()\n }\n\n public render() {\n return (\n <Host>\n <dialog\n class=\"qds-dialog\"\n ref={this.ref}\n onSubmit={this.boundSubmit}\n onCancel={this.onCancel}\n onClose={this.onClose}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...this.inheritedAttributes}\n >\n <div class=\"qds-content\">\n <slot />\n </div>\n </dialog>\n <div class=\"qds-backdrop\" />\n </Host>\n )\n }\n\n private async handleSubmit(event: Event): Promise<void> {\n if (\n (event instanceof SubmitEvent &&\n (event.submitter instanceof HTMLButtonElement ||\n (event.submitter instanceof HTMLInputElement &&\n event.submitter.formMethod === 'dialog'))) ||\n (event.target instanceof HTMLFormElement &&\n event.target.method === 'dialog')\n ) {\n event.preventDefault()\n await this.close()\n }\n }\n\n private readonly boundSubmit = (event: Event): void => {\n ignorePromise(this.handleSubmit(event))\n }\n\n private readonly onCancel = (event: Event): void => {\n if (this.cancelEmitter.emit().defaultPrevented) event.preventDefault()\n }\n\n private readonly onClose = (): void => {\n invariant(this.dialog)\n\n this.closeEmitter.emit()\n this.open = this.dialog.open\n }\n\n private readonly ref = (dialog?: HTMLDialogElement): void => {\n this.dialog = dialog\n }\n}\n"],"version":3}
1
+ {"file":"qds-dialog.js","mappings":";;;;;;;;AAAA,MAAM,SAAS,GAAG,0kCAA0kC;;MC8B/kC,MAAM;;;;;;;IA8BT,wBAAmB,GAAe,EAAE,CAAA;IA6E3B,gBAAW,GAAG,CAAC,KAAY;MAC1C,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAA;KACxC,CAAA;IAEgB,aAAQ,GAAG,CAAC,KAAY;MACvC,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC,gBAAgB;QAAE,KAAK,CAAC,cAAc,EAAE,CAAA;KACvE,CAAA;IAEgB,YAAO,GAAG;MACzB,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;MAEtB,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,CAAA;MACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAA;KAC7B,CAAA;IAEgB,QAAG,GAAG,CAAC,MAA0B;MAChD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;KACrB,CAAA;gBAtHqD,KAAK;;;;;;;;;EAoCpD,MAAM,IAAI;IACf,SAAS,CAAC,IAAI,CAAC,MAAM,CAA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ACA,KAAK,CAAC,cAAc,EAAE,CAAA;MACtB,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;KACnB;GACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/dialog/dialog.css?tag=qds-dialog&encapsulation=shadow","src/components/dialog/dialog.tsx"],"sourcesContent":["/*\n * SPDX-FileCopyrightText: © 2023 Schneider Electric\n *\n * SPDX-License-Identifier: LGPL-2.1-only\n */\n\n@import url('../shared.css');\n\n:host {\n display: none;\n position: fixed;\n inset: 0;\n}\n\n:host([open]) {\n display: block;\n}\n\n.qds-dialog {\n border-radius: var(--qds-popup-border-radius);\n border: none;\n box-shadow: var(--qds-theme-popup-elevation);\n padding: 0;\n\n &::backdrop {\n background: initial;\n }\n\n &[open] ~ .qds-backdrop {\n backdrop-filter: blur(var(--qds-theme-popup-overlay-blur));\n background-color: var(--qds-theme-popup-overlay-background);\n inset: 0;\n opacity: var(--qds-theme-popup-overlay-opacity);\n position: fixed;\n }\n}\n\n.qds-content {\n align-items: flex-start;\n background-color: var(--qds-theme-popup-background);\n display: flex;\n flex-direction: column;\n gap: var(--qds-popup-gap-children-related);\n padding: var(--qds-popup-padding);\n}\n\n::slotted(blockquote),\n::slotted(button),\n::slotted(dd),\n::slotted(dl),\n::slotted(fieldset),\n::slotted(figure),\n::slotted(h1),\n::slotted(h2),\n::slotted(h3),\n::slotted(h4),\n::slotted(h5),\n::slotted(h6),\n::slotted(hr),\n::slotted(input),\n::slotted(menu),\n::slotted(ol),\n::slotted(p),\n::slotted(pre),\n::slotted(select),\n::slotted(textarea),\n::slotted(ul) {\n margin: 0;\n}\n","// SPDX-FileCopyrightText: © 2023 Schneider Electric\n//\n// SPDX-License-Identifier: LGPL-2.1-only\n\nimport type { ComponentInterface, EventEmitter } from '@stencil/core'\nimport {\n Component,\n Element,\n Event,\n h,\n Host,\n Method,\n Prop,\n Watch,\n} from '@stencil/core'\n\nimport type { Attributes } from '../../helpers'\nimport { ignorePromise, inheritAriaAttributes, invariant } from '../../helpers'\n\n/**\n * The `<qds-dialog>` element represent a dialog box or other interactive\n * component, such as a dismissible alert, inspector, or subwindow.\n *\n * @see https://quartz.se.com/build/components/dialog\n */\n@Component({\n tag: 'qds-dialog',\n shadow: true,\n styleUrl: 'dialog.css',\n})\nexport class Dialog implements ComponentInterface {\n /**\n * Indicates whether or not the dialog is open. You can toggle this attribute\n * to show and hide the dialog, or you can use the `show()` and `close()`\n * methods and this attribute will reflect the dialog’s open state.\n */\n @Prop({ mutable: true, reflect: true }) public open = false\n\n @Element() private readonly element!: HTMLQdsDialogElement\n\n /**\n * Emitted when the user instructs the browser that they wish to dismiss the\n * currently open dialog. The browser fires this event when the user presses\n * the `Esc` key.\n *\n * When a dialog is dismissed with the `Esc` key, both the `qdsCancel` and\n * `qdsClose` events are fired.\n */\n @Event({ eventName: 'qdsCancel', bubbles: false, composed: false })\n private readonly cancelEmitter!: EventEmitter<void>\n\n /** Emitted when the dialog has been closed. */\n @Event({\n eventName: 'qdsClose',\n bubbles: false,\n cancelable: false,\n composed: false,\n })\n private readonly closeEmitter!: EventEmitter<void>\n\n private inheritedAttributes: Attributes = {}\n\n private dialog?: HTMLDialogElement\n\n /**\n * Displays the dialog over the top of any other dialogs that might be\n * present. Everything outside of the dialog is [inert][] with interactions\n * outside of the dialog being blocked.\n *\n * [inert]: https://developer.mozilla.org/docs/Web/API/HTMLElement/inert\n */\n @Method()\n public async show(): Promise<void> {\n invariant(this.dialog)\n\n this.dialog.showModal()\n this.open = this.dialog.open\n }\n\n /**\n * Closes the dialog.\n */\n @Method()\n public async close(): Promise<void> {\n invariant(this.dialog)\n\n this.dialog.close()\n }\n\n @Watch('open')\n protected async openChanged(): Promise<void> {\n await (this.open ? this.show() : this.close())\n }\n\n public componentWillLoad(): void {\n this.inheritedAttributes = inheritAriaAttributes(this.element)\n }\n\n public async componentDidLoad(): Promise<void> {\n if (this.open) await this.show()\n }\n\n public render() {\n return (\n <Host>\n <dialog\n class=\"qds-dialog\"\n ref={this.ref}\n onSubmit={this.boundSubmit}\n onCancel={this.onCancel}\n onClose={this.onClose}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...this.inheritedAttributes}\n >\n <div class=\"qds-content\">\n <slot />\n </div>\n </dialog>\n <div class=\"qds-backdrop\" />\n </Host>\n )\n }\n\n private async handleSubmit(event: Event): Promise<void> {\n if (\n (event instanceof SubmitEvent &&\n (event.submitter instanceof HTMLButtonElement ||\n (event.submitter instanceof HTMLInputElement &&\n event.submitter.formMethod === 'dialog'))) ||\n (event.target instanceof HTMLFormElement &&\n event.target.method === 'dialog')\n ) {\n event.preventDefault()\n await this.close()\n }\n }\n\n private readonly boundSubmit = (event: Event): void => {\n ignorePromise(this.handleSubmit(event))\n }\n\n private readonly onCancel = (event: Event): void => {\n if (this.cancelEmitter.emit().defaultPrevented) event.preventDefault()\n }\n\n private readonly onClose = (): void => {\n invariant(this.dialog)\n\n this.closeEmitter.emit()\n this.open = this.dialog.open\n }\n\n private readonly ref = (dialog?: HTMLDialogElement): void => {\n this.dialog = dialog\n }\n}\n"],"version":3}
@@ -236,7 +236,17 @@ const Dropdown = /*@__PURE__*/ proxyCustomElement(class Dropdown extends HTMLEle
236
236
  "show": [64],
237
237
  "close": [64],
238
238
  "update": [64]
239
- }, [[4, "click", "handleMouseDown"]]]);
239
+ }, [[4, "click", "handleMouseDown"]], {
240
+ "target": ["updateReferenceElement"],
241
+ "flipOptions": ["updateMiddleware"],
242
+ "noFlip": ["updateMiddleware"],
243
+ "noShift": ["updateMiddleware"],
244
+ "offsetOptions": ["updateMiddleware"],
245
+ "shiftOptions": ["updateMiddleware"],
246
+ "placement": ["updatePosition"],
247
+ "strategy": ["updatePosition"],
248
+ "autoUpdateOptions": ["startAutoUpdate"]
249
+ }]);
240
250
  function defineCustomElement$1() {
241
251
  if (typeof customElements === "undefined") {
242
252
  return;
@@ -1 +1 @@
1
- {"file":"qds-dropdown.js","mappings":";;;;;;;;;AAAA,MAAM,WAAW,GA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,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;GACnE;EAMO,0BAA0B;IAChC,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAA;IAEnC,IAAI,EAAE,IAAI,CAAC,gBAAgB,YAAY,UAAU,CAAC,OAAO,CAAC;MAAE,OAAM;IAElE,IAAI,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAA;IAC5E,IAAI,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,UAAU,EAAE,IAAI,CAAC,aAAa,CAAC,CAAA;IACzE,IAAI,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;IACtE,IAAI,CAAC,gBAAgB,CAAC,eAAe,CAAC,eAAe,CAAC,CAAA;IACtD,IAAI,CAAC,gBAAgB,CAAC,eAAe,CAAC,eAAe,CAAC,CAAA;GACvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/dropdown/dropdown.css?tag=qds-dropdown&encapsulation=shadow","src/components/dropdown/dropdown.tsx"],"sourcesContent":["/*\n * SPDX-FileCopyrightText: © 2023 Schneider Electric\n *\n * SPDX-License-Identifier: LGPL-2.1-only\n */\n\n@import url('../shared.css');\n\n:host {\n background: var(--qds-theme-accessory-background);\n border-radius: var(--qds-accessory-border-radius);\n box-shadow: var(--qds-theme-accessory-elevation);\n box-sizing: border-box;\n display: inline-block;\n left: 0;\n top: 0;\n}\n","// SPDX-FileCopyrightText: © 2023 Schneider Electric\n//\n// SPDX-License-Identifier: LGPL-2.1-only\n\nimport type {\n AutoUpdateOptions,\n DetectOverflowOptions,\n FlipOptions,\n Middleware,\n Placement,\n ReferenceElement,\n ShiftOptions,\n Strategy,\n} from '@floating-ui/dom'\nimport {\n autoUpdate,\n computePosition,\n flip,\n limitShift,\n offset,\n shift,\n} from '@floating-ui/dom'\nimport type { ComponentInterface, EventEmitter } from '@stencil/core'\nimport {\n Component,\n Element,\n Event,\n h,\n Host,\n Listen,\n Method,\n Prop,\n State,\n Watch,\n} from '@stencil/core'\n\nimport type { OffsetOptions } from '../../helpers'\nimport {\n ignorePromise,\n invariant,\n propertyToPx,\n roundByDPR,\n} from '../../helpers'\n\nlet autoIncrementingId = 1\n\n/**\n * @experimental\n * @slot Content to display in the dropdown.\n * @see https://quartz.se.com/build/components/dropdown\n */\n@Component({\n tag: 'qds-dropdown',\n shadow: true,\n styleUrl: 'dropdown.css',\n})\nexport class Dropdown implements ComponentInterface {\n /**\n * Options to pass to Floating UI's\n * [`autoUpdate()` function](https://floating-ui.com/docs/autoUpdate).\n *\n * @see https://floating-ui.com/docs/autoupdate#options\n */\n @Prop() public readonly autoUpdateOptions?: AutoUpdateOptions\n\n /**\n * Prevents the dropdown from being shown by user interaction. The dropdown\n * can still be displayed by calling the `show()` method.\n */\n @Prop({ mutable: true }) public disabled = false\n\n /**\n * Options to pass to Floating UI's\n * [`flip` middleware](https://floating-ui.com/docs/flip).\n *\n * The [`crossAxis` option](https://floating-ui.com/docs/flip#crossaxis) is\n * set to the value of the `noShift` property by default for interoperability\n * with the [`shift` middleware](https://floating-ui.com/docs/shift).\n *\n * @see https://floating-ui.com/docs/flip#options\n */\n @Prop() public readonly flipOptions?: Partial<\n DetectOverflowOptions & FlipOptions\n >\n\n /**\n * Disable Floating UI's\n * [`flip` middleware](https://floating-ui.com/docs/flip).\n */\n @Prop() public readonly noFlip: boolean = false\n\n /**\n * Disable Floating UI's\n * [`shift` middleware](https://floating-ui.com/docs/shift).\n */\n @Prop() public readonly noShift: boolean = false\n\n /**\n * Options to pass to Floating UI's\n * [`offset` middleware](https://floating-ui.com/docs/offset).\n *\n * The [`mainAxis` option](https://floating-ui.com/docs/offset#mainaxis) is\n * not supported.\n *\n * @see https://floating-ui.com/docs/offset#options\n */\n @Prop() public readonly offsetOptions?: OffsetOptions\n\n /**\n * Where to place the dropdown relative to the `target`.\n *\n * @see https://floating-ui.com/docs/tutorial#placements\n */\n @Prop() public readonly placement: Placement = 'bottom-start'\n\n /**\n * Options to pass to Floating UI's\n * [`shift` middleware](https://floating-ui.com/docs/shift).\n *\n * @see https://floating-ui.com/docs/shift#options\n */\n @Prop() public readonly shiftOptions?: Partial<\n DetectOverflowOptions & ShiftOptions\n >\n\n /**\n * The CSS position strategy to use.\n *\n * @see https://floating-ui.com/docs/computeposition#strategy\n */\n @Prop() public readonly strategy?: Strategy\n\n /**\n * The trigger element that will trigger the dropdown. The target specified\n * can be any of the follow:\n *\n * - A CSS selector string\n * - A reference to an\n * [`Element`](https://developer.mozilla.org/docs/Web/API/Element) or\n * [Virtual Element](https://floating-ui.com/docs/virtual-elements)\n * - A function returning a reference to an\n * [`Element`](https://developer.mozilla.org/docs/Web/API/Element),\n * [Virtual Element](https://floating-ui.com/docs/virtual-elements),\n * or a CSS selector string\n */\n @Prop() public readonly target!:\n | ReferenceElement\n | string\n | (() => ReferenceElement | string)\n\n /**\n * Emitted when the user instructs the browser that they wish to dismiss the\n * current open dropdown by pressing the `Esc` key.\n *\n * When a dropdown is dismissed with the `Esc` key, both the `qdsCancel` and\n * `qdsClose` events are emitted.\n */\n @Event({ eventName: 'qdsCancel', bubbles: false })\n private readonly cancelEmitter!: EventEmitter<void>\n\n /**\n * Emitted when the dropdown is closed.\n */\n @Event({ eventName: 'qdsClose', bubbles: false, cancelable: false })\n private readonly closeEmitter!: EventEmitter<void>\n\n @Element() private readonly element!: HTMLQdsDropdownElement\n\n @State() private hostAriaLabelledBy?: string\n\n @State() private hostDisplay?: string\n\n @State() private hostPosition?: string\n\n @State() private hostTransform?: string\n\n private cleanup?: () => void\n\n private middleware?: Middleware[]\n\n private referenceElement?: ReferenceElement\n\n private open = false\n\n /**\n * Show the dropdown.\n */\n @Method()\n public async show(): Promise<void> {\n if (this.open) return\n\n if (this.referenceElement instanceof globalThis.Element) {\n this.referenceElement.setAttribute('aria-expanded', 'true')\n this.referenceElement.setAttribute('aria-controls', this.element.id)\n }\n\n this.open = true\n this.hostDisplay = undefined\n this.startAutoUpdate()\n }\n\n /**\n * Close the dropdown.\n */\n @Method()\n public async close(): Promise<void> {\n if (!this.open) return\n\n if (this.referenceElement instanceof globalThis.Element) {\n this.referenceElement.setAttribute('aria-expanded', 'false')\n this.referenceElement.removeAttribute('aria-controls')\n }\n\n this.open = false\n this.hostDisplay = 'none'\n if (this.cleanup) this.cleanup()\n\n this.closeEmitter.emit()\n }\n\n /**\n * Update the dropdown's middleware and position.\n */\n @Method()\n public async update(): Promise<void> {\n await this.updateMiddleware()\n }\n\n @Listen('click', { target: 'document' })\n protected async handleMouseDown(event: MouseEvent): Promise<void> {\n if (!this.open) return\n\n const composedPath = event.composedPath()\n const withinBounds =\n composedPath.includes(this.element) ||\n (this.referenceElement instanceof globalThis.Element &&\n composedPath.includes(this.referenceElement))\n if (!withinBounds) await this.close()\n }\n\n @Watch('target')\n private async updateReferenceElement(): Promise<void> {\n this.disconnectReferenceElement()\n\n const resolvedTarget =\n typeof this.target === 'function' ? this.target() : this.target\n if (typeof resolvedTarget === 'string') {\n const element = document.querySelector(resolvedTarget)\n if (element === null)\n throw new Error('String `target` must resolve to an Element.')\n this.referenceElement = element\n } else this.referenceElement = resolvedTarget\n\n if (!(this.referenceElement instanceof globalThis.Element)) return\n\n this.referenceElement.setAttribute('aria-expanded', 'false')\n this.referenceElement.addEventListener('click', this.boundReferenceClick)\n this.referenceElement.addEventListener('focusout', this.boundFocusout)\n this.referenceElement.addEventListener('keydown', this.boundEscape)\n if (this.element.role === 'menu') {\n this.referenceElement.id ||= `qds-dropdown-trigger-${autoIncrementingId}`\n this.hostAriaLabelledBy = this.referenceElement.id\n }\n }\n\n @Watch('flipOptions')\n @Watch('noFlip')\n @Watch('noShift')\n @Watch('offsetOptions')\n @Watch('shiftOptions')\n private async updateMiddleware(): Promise<void> {\n this.middleware = [\n offset({\n ...this.offsetOptions,\n mainAxis:\n propertyToPx(this.element, '--qds-accessory-gap-floating') ?? 0,\n }),\n !this.noFlip &&\n flip({\n crossAxis: this.noShift,\n ...this.flipOptions,\n }),\n !this.noShift &&\n shift({\n limiter: limitShift(),\n ...this.shiftOptions,\n }),\n ].filter((middleware): middleware is Middleware => middleware !== false)\n await this.updatePosition()\n }\n\n @Watch('placement')\n @Watch('strategy')\n private async updatePosition(): Promise<void> {\n invariant(this.referenceElement)\n\n const { x, y, strategy } = await computePosition(\n this.referenceElement,\n this.element,\n {\n middleware: this.middleware,\n placement: this.placement,\n strategy: this.strategy,\n },\n )\n this.hostPosition = strategy\n this.hostTransform = `translate(${roundByDPR(x)}px,${roundByDPR(y)}px)`\n }\n\n @Watch('autoUpdateOptions')\n private startAutoUpdate(): void {\n invariant(this.referenceElement)\n\n if (this.cleanup) this.cleanup()\n this.cleanup = autoUpdate(\n this.referenceElement,\n this.element,\n () => {\n ignorePromise(this.updatePosition())\n },\n this.autoUpdateOptions,\n )\n }\n\n public async componentWillLoad(): Promise<void> {\n this.hostDisplay = 'none'\n this.element.role ??= 'menu'\n this.element.id ||= `qds-dropdown-${autoIncrementingId}`\n await this.updateReferenceElement()\n autoIncrementingId += 1\n await this.updateMiddleware()\n }\n\n public disconnectedCallback(): void {\n this.disconnectReferenceElement()\n }\n\n public render() {\n return (\n <Host\n aria-labelledby={this.hostAriaLabelledBy}\n onKeyDown={this.boundEscape}\n onFocusout={this.boundFocusout}\n style={{\n display: this.hostDisplay,\n position: this.hostPosition,\n transform: this.hostTransform,\n }}\n >\n <slot />\n </Host>\n )\n }\n\n private async handleFocusout(event: Event): Promise<void> {\n if (!(event instanceof FocusEvent)) return\n const { relatedTarget } = event\n\n if (\n relatedTarget instanceof globalThis.Element &&\n !this.element.contains(relatedTarget) &&\n this.referenceElement !== relatedTarget\n )\n await this.close()\n }\n\n private readonly boundFocusout = (event: Event): void => {\n ignorePromise(this.handleFocusout(event))\n }\n\n private async handleEscape(event: Event): Promise<void> {\n if (\n !(event instanceof KeyboardEvent) ||\n event.key !== 'Escape' ||\n (event.target !== this.referenceElement &&\n event.target instanceof globalThis.Element &&\n event.target.closest('qds-dropdown') !== this.element)\n )\n return\n\n const cancelEvent = this.cancelEmitter.emit()\n if (cancelEvent.defaultPrevented) return\n\n await this.close()\n if (\n this.referenceElement instanceof globalThis.HTMLElement ||\n this.referenceElement instanceof globalThis.SVGElement\n )\n this.referenceElement.focus()\n }\n\n private readonly boundEscape = (event: Event): void => {\n ignorePromise(this.handleEscape(event))\n }\n\n private async handleReferenceClick(): Promise<void> {\n if (!this.disabled) await (this.open ? this.close() : this.show())\n }\n\n private readonly boundReferenceClick = (): void => {\n ignorePromise(this.handleReferenceClick())\n }\n\n private disconnectReferenceElement(): void {\n this.hostAriaLabelledBy = undefined\n\n if (!(this.referenceElement instanceof globalThis.Element)) return\n\n this.referenceElement.removeEventListener('click', this.boundReferenceClick)\n this.referenceElement.removeEventListener('focusout', this.boundFocusout)\n this.referenceElement.removeEventListener('keydown', this.boundEscape)\n this.referenceElement.removeAttribute('aria-expanded')\n this.referenceElement.removeAttribute('aria-controls')\n }\n}\n"],"version":3}
1
+ {"file":"qds-dropdown.js","mappings":";;;;;;;;;AAAA,MAAM,WAAW,GAAG,0PAA0P;;AC4C9Q,IAAI,kBAAkB,GAAG,CAAC,CAAA;MAYb,QAAQ;;;;;;;IA8HX,SAAI,GAAG,KAAK,CAAA;IAwLH,kBAAa,GAAG,CAAC,KAAY;MAC5C,aAAa,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAA;KAC1C,CAAA;IAuBgB,gBAAW,GAAG,CAAC,KAAY;MAC1C,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAA;KACxC,CAAA;IAMgB,wBAAmB,GAAG;MACrC,aAAa,CAAC,IAAI,CAAC,oBAAoB,EAAE,CAAC,CAAA;KAC3C,CAAA;;oBA5U0C,KAAK;;kBAoBN,KAAK;mBAMJ,KAAK;;qBAkBD,cAAc;;;;;;;;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AC,eAAe,CAAC,CAAA;IACtD,IAAI,CAAC,gBAAgB,CAAC,eAAe,CAAC,eAAe,CAAC,CAAA;GACvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/dropdown/dropdown.css?tag=qds-dropdown&encapsulation=shadow","src/components/dropdown/dropdown.tsx"],"sourcesContent":["/*\n * SPDX-FileCopyrightText: © 2023 Schneider Electric\n *\n * SPDX-License-Identifier: LGPL-2.1-only\n */\n\n@import url('../shared.css');\n\n:host {\n background: var(--qds-theme-accessory-background);\n border-radius: var(--qds-accessory-border-radius);\n box-shadow: var(--qds-theme-accessory-elevation);\n box-sizing: border-box;\n display: inline-block;\n left: 0;\n top: 0;\n}\n","// SPDX-FileCopyrightText: © 2023 Schneider Electric\n//\n// SPDX-License-Identifier: LGPL-2.1-only\n\nimport type {\n AutoUpdateOptions,\n DetectOverflowOptions,\n FlipOptions,\n Middleware,\n Placement,\n ReferenceElement,\n ShiftOptions,\n Strategy,\n} from '@floating-ui/dom'\nimport {\n autoUpdate,\n computePosition,\n flip,\n limitShift,\n offset,\n shift,\n} from '@floating-ui/dom'\nimport type { ComponentInterface, EventEmitter } from '@stencil/core'\nimport {\n Component,\n Element,\n Event,\n h,\n Host,\n Listen,\n Method,\n Prop,\n State,\n Watch,\n} from '@stencil/core'\n\nimport type { OffsetOptions } from '../../helpers'\nimport {\n ignorePromise,\n invariant,\n propertyToPx,\n roundByDPR,\n} from '../../helpers'\n\nlet autoIncrementingId = 1\n\n/**\n * @experimental\n * @slot Content to display in the dropdown.\n * @see https://quartz.se.com/build/components/dropdown\n */\n@Component({\n tag: 'qds-dropdown',\n shadow: true,\n styleUrl: 'dropdown.css',\n})\nexport class Dropdown implements ComponentInterface {\n /**\n * Options to pass to Floating UI's\n * [`autoUpdate()` function](https://floating-ui.com/docs/autoUpdate).\n *\n * @see https://floating-ui.com/docs/autoupdate#options\n */\n @Prop() public readonly autoUpdateOptions?: AutoUpdateOptions\n\n /**\n * Prevents the dropdown from being shown by user interaction. The dropdown\n * can still be displayed by calling the `show()` method.\n */\n @Prop({ mutable: true }) public disabled = false\n\n /**\n * Options to pass to Floating UI's\n * [`flip` middleware](https://floating-ui.com/docs/flip).\n *\n * The [`crossAxis` option](https://floating-ui.com/docs/flip#crossaxis) is\n * set to the value of the `noShift` property by default for interoperability\n * with the [`shift` middleware](https://floating-ui.com/docs/shift).\n *\n * @see https://floating-ui.com/docs/flip#options\n */\n @Prop() public readonly flipOptions?: Partial<\n DetectOverflowOptions & FlipOptions\n >\n\n /**\n * Disable Floating UI's\n * [`flip` middleware](https://floating-ui.com/docs/flip).\n */\n @Prop() public readonly noFlip: boolean = false\n\n /**\n * Disable Floating UI's\n * [`shift` middleware](https://floating-ui.com/docs/shift).\n */\n @Prop() public readonly noShift: boolean = false\n\n /**\n * Options to pass to Floating UI's\n * [`offset` middleware](https://floating-ui.com/docs/offset).\n *\n * The [`mainAxis` option](https://floating-ui.com/docs/offset#mainaxis) is\n * not supported.\n *\n * @see https://floating-ui.com/docs/offset#options\n */\n @Prop() public readonly offsetOptions?: OffsetOptions\n\n /**\n * Where to place the dropdown relative to the `target`.\n *\n * @see https://floating-ui.com/docs/tutorial#placements\n */\n @Prop() public readonly placement: Placement = 'bottom-start'\n\n /**\n * Options to pass to Floating UI's\n * [`shift` middleware](https://floating-ui.com/docs/shift).\n *\n * @see https://floating-ui.com/docs/shift#options\n */\n @Prop() public readonly shiftOptions?: Partial<\n DetectOverflowOptions & ShiftOptions\n >\n\n /**\n * The CSS position strategy to use.\n *\n * @see https://floating-ui.com/docs/computeposition#strategy\n */\n @Prop() public readonly strategy?: Strategy\n\n /**\n * The trigger element that will trigger the dropdown. The target specified\n * can be any of the follow:\n *\n * - A CSS selector string\n * - A reference to an\n * [`Element`](https://developer.mozilla.org/docs/Web/API/Element) or\n * [Virtual Element](https://floating-ui.com/docs/virtual-elements)\n * - A function returning a reference to an\n * [`Element`](https://developer.mozilla.org/docs/Web/API/Element),\n * [Virtual Element](https://floating-ui.com/docs/virtual-elements),\n * or a CSS selector string\n */\n @Prop() public readonly target!:\n | ReferenceElement\n | string\n | (() => ReferenceElement | string)\n\n /**\n * Emitted when the user instructs the browser that they wish to dismiss the\n * current open dropdown by pressing the `Esc` key.\n *\n * When a dropdown is dismissed with the `Esc` key, both the `qdsCancel` and\n * `qdsClose` events are emitted.\n */\n @Event({ eventName: 'qdsCancel', bubbles: false })\n private readonly cancelEmitter!: EventEmitter<void>\n\n /**\n * Emitted when the dropdown is closed.\n */\n @Event({ eventName: 'qdsClose', bubbles: false, cancelable: false })\n private readonly closeEmitter!: EventEmitter<void>\n\n @Element() private readonly element!: HTMLQdsDropdownElement\n\n @State() private hostAriaLabelledBy?: string\n\n @State() private hostDisplay?: string\n\n @State() private hostPosition?: string\n\n @State() private hostTransform?: string\n\n private cleanup?: () => void\n\n private middleware?: Middleware[]\n\n private referenceElement?: ReferenceElement\n\n private open = false\n\n /**\n * Show the dropdown.\n */\n @Method()\n public async show(): Promise<void> {\n if (this.open) return\n\n if (this.referenceElement instanceof globalThis.Element) {\n this.referenceElement.setAttribute('aria-expanded', 'true')\n this.referenceElement.setAttribute('aria-controls', this.element.id)\n }\n\n this.open = true\n this.hostDisplay = undefined\n this.startAutoUpdate()\n }\n\n /**\n * Close the dropdown.\n */\n @Method()\n public async close(): Promise<void> {\n if (!this.open) return\n\n if (this.referenceElement instanceof globalThis.Element) {\n this.referenceElement.setAttribute('aria-expanded', 'false')\n this.referenceElement.removeAttribute('aria-controls')\n }\n\n this.open = false\n this.hostDisplay = 'none'\n if (this.cleanup) this.cleanup()\n\n this.closeEmitter.emit()\n }\n\n /**\n * Update the dropdown's middleware and position.\n */\n @Method()\n public async update(): Promise<void> {\n await this.updateMiddleware()\n }\n\n @Listen('click', { target: 'document' })\n protected async handleMouseDown(event: MouseEvent): Promise<void> {\n if (!this.open) return\n\n const composedPath = event.composedPath()\n const withinBounds =\n composedPath.includes(this.element) ||\n (this.referenceElement instanceof globalThis.Element &&\n composedPath.includes(this.referenceElement))\n if (!withinBounds) await this.close()\n }\n\n @Watch('target')\n private async updateReferenceElement(): Promise<void> {\n this.disconnectReferenceElement()\n\n const resolvedTarget =\n typeof this.target === 'function' ? this.target() : this.target\n if (typeof resolvedTarget === 'string') {\n const element = document.querySelector(resolvedTarget)\n if (element === null)\n throw new Error('String `target` must resolve to an Element.')\n this.referenceElement = element\n } else this.referenceElement = resolvedTarget\n\n if (!(this.referenceElement instanceof globalThis.Element)) return\n\n this.referenceElement.setAttribute('aria-expanded', 'false')\n this.referenceElement.addEventListener('click', this.boundReferenceClick)\n this.referenceElement.addEventListener('focusout', this.boundFocusout)\n this.referenceElement.addEventListener('keydown', this.boundEscape)\n if (this.element.role === 'menu') {\n this.referenceElement.id ||= `qds-dropdown-trigger-${autoIncrementingId}`\n this.hostAriaLabelledBy = this.referenceElement.id\n }\n }\n\n @Watch('flipOptions')\n @Watch('noFlip')\n @Watch('noShift')\n @Watch('offsetOptions')\n @Watch('shiftOptions')\n private async updateMiddleware(): Promise<void> {\n this.middleware = [\n offset({\n ...this.offsetOptions,\n mainAxis:\n propertyToPx(this.element, '--qds-accessory-gap-floating') ?? 0,\n }),\n !this.noFlip &&\n flip({\n crossAxis: this.noShift,\n ...this.flipOptions,\n }),\n !this.noShift &&\n shift({\n limiter: limitShift(),\n ...this.shiftOptions,\n }),\n ].filter((middleware): middleware is Middleware => middleware !== false)\n await this.updatePosition()\n }\n\n @Watch('placement')\n @Watch('strategy')\n private async updatePosition(): Promise<void> {\n invariant(this.referenceElement)\n\n const { x, y, strategy } = await computePosition(\n this.referenceElement,\n this.element,\n {\n middleware: this.middleware,\n placement: this.placement,\n strategy: this.strategy,\n },\n )\n this.hostPosition = strategy\n this.hostTransform = `translate(${roundByDPR(x)}px,${roundByDPR(y)}px)`\n }\n\n @Watch('autoUpdateOptions')\n private startAutoUpdate(): void {\n invariant(this.referenceElement)\n\n if (this.cleanup) this.cleanup()\n this.cleanup = autoUpdate(\n this.referenceElement,\n this.element,\n () => {\n ignorePromise(this.updatePosition())\n },\n this.autoUpdateOptions,\n )\n }\n\n public async componentWillLoad(): Promise<void> {\n this.hostDisplay = 'none'\n this.element.role ??= 'menu'\n this.element.id ||= `qds-dropdown-${autoIncrementingId}`\n await this.updateReferenceElement()\n autoIncrementingId += 1\n await this.updateMiddleware()\n }\n\n public disconnectedCallback(): void {\n this.disconnectReferenceElement()\n }\n\n public render() {\n return (\n <Host\n aria-labelledby={this.hostAriaLabelledBy}\n onKeyDown={this.boundEscape}\n onFocusout={this.boundFocusout}\n style={{\n display: this.hostDisplay,\n position: this.hostPosition,\n transform: this.hostTransform,\n }}\n >\n <slot />\n </Host>\n )\n }\n\n private async handleFocusout(event: Event): Promise<void> {\n if (!(event instanceof FocusEvent)) return\n const { relatedTarget } = event\n\n if (\n relatedTarget instanceof globalThis.Element &&\n !this.element.contains(relatedTarget) &&\n this.referenceElement !== relatedTarget\n )\n await this.close()\n }\n\n private readonly boundFocusout = (event: Event): void => {\n ignorePromise(this.handleFocusout(event))\n }\n\n private async handleEscape(event: Event): Promise<void> {\n if (\n !(event instanceof KeyboardEvent) ||\n event.key !== 'Escape' ||\n (event.target !== this.referenceElement &&\n event.target instanceof globalThis.Element &&\n event.target.closest('qds-dropdown') !== this.element)\n )\n return\n\n const cancelEvent = this.cancelEmitter.emit()\n if (cancelEvent.defaultPrevented) return\n\n await this.close()\n if (\n this.referenceElement instanceof globalThis.HTMLElement ||\n this.referenceElement instanceof globalThis.SVGElement\n )\n this.referenceElement.focus()\n }\n\n private readonly boundEscape = (event: Event): void => {\n ignorePromise(this.handleEscape(event))\n }\n\n private async handleReferenceClick(): Promise<void> {\n if (!this.disabled) await (this.open ? this.close() : this.show())\n }\n\n private readonly boundReferenceClick = (): void => {\n ignorePromise(this.handleReferenceClick())\n }\n\n private disconnectReferenceElement(): void {\n this.hostAriaLabelledBy = undefined\n\n if (!(this.referenceElement instanceof globalThis.Element)) return\n\n this.referenceElement.removeEventListener('click', this.boundReferenceClick)\n this.referenceElement.removeEventListener('focusout', this.boundFocusout)\n this.referenceElement.removeEventListener('keydown', this.boundEscape)\n this.referenceElement.removeAttribute('aria-expanded')\n this.referenceElement.removeAttribute('aria-controls')\n }\n}\n"],"version":3}
@@ -48,7 +48,7 @@ const InlineLink = /*@__PURE__*/ proxyCustomElement(class InlineLink extends HTM
48
48
  };
49
49
  }
50
50
  render() {
51
- return (h("a", { "aria-disabled": this.disabled ? 'true' : 'false', class: "qds-inline-link", download: this.download, href: this.href, hrefLang: this.hreflang, onBlur: this.onBlur, onFocus: this.onFocus, referrerPolicy: this.referrerPolicy, rel: this.rel, target: this.target, ...this.inheritedAttributes, tabIndex: this.disabled ? -1 : this.computedTabIndex }, h("slot", null), h("qds-icon", { class: "qds-external", library: "core", name: "external-link" })));
51
+ return (h("a", { "aria-disabled": this.disabled.toString(), class: "qds-inline-link", download: this.download, href: this.href, hrefLang: this.hreflang, onBlur: this.onBlur, onFocus: this.onFocus, referrerPolicy: this.referrerPolicy, rel: this.rel, target: this.target, ...this.inheritedAttributes, tabIndex: this.disabled ? -1 : this.computedTabIndex }, h("slot", null), h("qds-icon", { class: "qds-external", library: "core", name: "external-link" })));
52
52
  }
53
53
  static get delegatesFocus() { return true; }
54
54
  get element() { return this; }