@quartzds/core 1.0.0-beta.43 → 1.0.0-beta.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/icon.js +3 -2
- package/components/icon.js.map +1 -1
- package/components/index.d.ts +2 -0
- package/components/index.js +1 -0
- package/components/index.js.map +1 -1
- package/components/label.js +1 -1
- package/components/qds-chip.d.ts +11 -0
- package/components/qds-chip.js +243 -0
- package/components/qds-chip.js.map +1 -0
- package/components/qds-dialog.js +1 -1
- package/components/qds-divider.js +1 -1
- package/components/qds-dropdown.js +2 -2
- package/components/qds-form-message.js +2 -2
- package/components/qds-inline-link.js +1 -1
- package/components/qds-input.js +2 -2
- package/components/qds-list-item.js +3 -3
- package/components/qds-nav-list-item.js +2 -2
- package/components/qds-radio.js +2 -2
- package/components/qds-select.js +3 -3
- package/components/qds-standalone-link.js +1 -1
- package/components/qds-switch.js +3 -3
- package/components/qds-table-body.js +1 -1
- package/components/qds-table-cell.js +1 -1
- package/components/qds-table-head-cell.js +1 -1
- package/components/qds-table-head.js +1 -1
- package/components/qds-table-row.js +1 -1
- package/components/qds-table.js +1 -1
- package/components/qds-textarea.js +2 -2
- package/components/qds-title.js +2 -2
- package/components/tooltip.js +3 -3
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/{library-3260efce.js → library-77ad6298.js} +2 -1
- package/dist/cjs/library-77ad6298.js.map +1 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/qds-chip.cjs.entry.js +211 -0
- package/dist/cjs/qds-chip.cjs.entry.js.map +1 -0
- package/dist/cjs/qds-dialog.cjs.entry.js +1 -1
- package/dist/cjs/qds-divider.cjs.entry.js +1 -1
- package/dist/cjs/qds-dropdown.cjs.entry.js +2 -2
- package/dist/cjs/qds-form-message.cjs.entry.js +2 -2
- package/dist/cjs/qds-icon.cjs.entry.js +3 -3
- package/dist/cjs/qds-icon.cjs.entry.js.map +1 -1
- package/dist/cjs/qds-inline-link.cjs.entry.js +1 -1
- package/dist/cjs/qds-input.cjs.entry.js +2 -2
- package/dist/cjs/qds-label.cjs.entry.js +1 -1
- package/dist/cjs/qds-list-item.cjs.entry.js +3 -3
- package/dist/cjs/qds-nav-list-item.cjs.entry.js +2 -2
- package/dist/cjs/qds-radio.cjs.entry.js +2 -2
- package/dist/cjs/qds-select.cjs.entry.js +3 -3
- package/dist/cjs/qds-standalone-link.cjs.entry.js +1 -1
- package/dist/cjs/qds-switch.cjs.entry.js +3 -3
- package/dist/cjs/qds-table-body.cjs.entry.js +1 -1
- package/dist/cjs/qds-table-cell.cjs.entry.js +1 -1
- package/dist/cjs/qds-table-head-cell.cjs.entry.js +1 -1
- package/dist/cjs/qds-table-head.cjs.entry.js +1 -1
- package/dist/cjs/qds-table-row.cjs.entry.js +1 -1
- package/dist/cjs/qds-table.cjs.entry.js +1 -1
- package/dist/cjs/qds-textarea.cjs.entry.js +2 -2
- package/dist/cjs/qds-title.cjs.entry.js +2 -2
- package/dist/cjs/qds-tooltip.cjs.entry.js +3 -3
- package/dist/cjs/qds.cjs.js +1 -1
- package/dist/custom-elements.json +488 -0
- package/dist/docs.json +451 -6
- package/dist/esm/index.js +1 -1
- package/dist/esm/{library-fbe2886c.js → library-c7d10d5a.js} +2 -1
- package/dist/esm/library-c7d10d5a.js.map +1 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/qds-chip.entry.js +207 -0
- package/dist/esm/qds-chip.entry.js.map +1 -0
- package/dist/esm/qds-dialog.entry.js +1 -1
- package/dist/esm/qds-divider.entry.js +1 -1
- package/dist/esm/qds-dropdown.entry.js +2 -2
- package/dist/esm/qds-form-message.entry.js +2 -2
- package/dist/esm/qds-icon.entry.js +3 -3
- package/dist/esm/qds-icon.entry.js.map +1 -1
- package/dist/esm/qds-inline-link.entry.js +1 -1
- package/dist/esm/qds-input.entry.js +2 -2
- package/dist/esm/qds-label.entry.js +1 -1
- package/dist/esm/qds-list-item.entry.js +3 -3
- package/dist/esm/qds-nav-list-item.entry.js +2 -2
- package/dist/esm/qds-radio.entry.js +2 -2
- package/dist/esm/qds-select.entry.js +3 -3
- package/dist/esm/qds-standalone-link.entry.js +1 -1
- package/dist/esm/qds-switch.entry.js +3 -3
- package/dist/esm/qds-table-body.entry.js +1 -1
- package/dist/esm/qds-table-cell.entry.js +1 -1
- package/dist/esm/qds-table-head-cell.entry.js +1 -1
- package/dist/esm/qds-table-head.entry.js +1 -1
- package/dist/esm/qds-table-row.entry.js +1 -1
- package/dist/esm/qds-table.entry.js +1 -1
- package/dist/esm/qds-textarea.entry.js +2 -2
- package/dist/esm/qds-title.entry.js +2 -2
- package/dist/esm/qds-tooltip.entry.js +3 -3
- package/dist/esm/qds.js +1 -1
- package/dist/types/components/chip/chip.d.ts +121 -0
- package/dist/types/components.d.ts +173 -2
- package/dist/vscode.html-custom-data.json +72 -0
- package/hydrate/index.js +265 -39
- package/package.json +1 -1
- package/dist/cjs/library-3260efce.js.map +0 -1
- package/dist/esm/library-fbe2886c.js.map +0 -1
package/components/icon.js
CHANGED
|
@@ -39,6 +39,7 @@ const icons = {
|
|
|
39
39
|
indeterminate: indeterminateSvg,
|
|
40
40
|
navigation: navigationSvg,
|
|
41
41
|
next: nextSvg,
|
|
42
|
+
close: statusErrorSvg,
|
|
42
43
|
'status-error': statusErrorSvg,
|
|
43
44
|
'status-info': statusInfoSvg,
|
|
44
45
|
'status-success': checkedSvg,
|
|
@@ -109,7 +110,7 @@ const requestIcon = async (url) => {
|
|
|
109
110
|
return iconFileData;
|
|
110
111
|
};
|
|
111
112
|
|
|
112
|
-
const iconCss = ":host([hidden]){display:none !important}:host{
|
|
113
|
+
const iconCss = ":host([hidden]){display:none !important}:host{display:inline-block;height:1em;width:1em}.qds-container{position:relative}.qds-icon-wrapper{display:contents}svg{display:block;fill:currentcolor;height:100%;width:100%}.qds-click-target{height:var(--qds-icon-click-target-size);left:calc(-1 * (var(--qds-icon-click-target-size) - 100%) / 2);position:absolute;top:calc(-1 * (var(--qds-icon-click-target-size) - 100%) / 2);width:var(--qds-icon-click-target-size)}";
|
|
113
114
|
const QdsIconStyle0 = iconCss;
|
|
114
115
|
|
|
115
116
|
let parser;
|
|
@@ -170,7 +171,7 @@ const Icon = /*@__PURE__*/ proxyCustomElement(class Icon extends HTMLElement {
|
|
|
170
171
|
await this.setIcon();
|
|
171
172
|
}
|
|
172
173
|
render() {
|
|
173
|
-
return h("span", { key: '
|
|
174
|
+
return (h("div", { key: '28eb1a5f4cd12e7f24bb5408eeeacaac86079320', class: "qds-container" }, h("span", { key: '4143990a4734e6892df3630236773f0e11b66934', class: "qds-icon-wrapper", innerHTML: this.svg }), h("div", { key: '39cd4f18ace6212dd49b16f995fd1385201ae184', class: "qds-click-target" })));
|
|
174
175
|
}
|
|
175
176
|
get element() { return this; }
|
|
176
177
|
static get watchers() { return {
|
package/components/icon.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"icon.js","mappings":";;;;;;;;AAAA,MAAM,UAAU,GAAG,4bAA4b;;ACA/c,MAAM,YAAY,GAAG,oeAAoe;;ACAzf,MAAM,WAAW,GAAG,4UAA4U;;ACAhW,MAAM,gBAAgB,GAAG,4VAA4V;;ACArX,MAAM,eAAe,GAAG,oWAAoW;;ACA5X,MAAM,gBAAgB,GAAG,wOAAwO;;ACAjQ,MAAM,aAAa,GAAG,4VAA4V;;ACAlX,MAAM,OAAO,GAAG,4VAA4V;;ACA5W,MAAM,cAAc,GAAG,gVAAgV;;ACAvW,MAAM,aAAa,GAAG,wNAAwN;;ACA9O,MAAM,gBAAgB,GAAG,oPAAoP;;ACA7Q;AAuBA,MAAM,KAAK,GAAuC;;aAEhDA,UAAO;eACPC,YAAS;cACTC,WAAQ;IACR,gBAAgB,EAAEC,gBAAa;IAC/B,eAAe,EAAEC,eAAY;mBAC7BC,gBAAa;gBACbC,aAAU;UACVC,OAAI;IACJ,cAAc,EAAEC,cAAW;IAC3B,aAAa,EAAEC,aAAU;IACzB,gBAAgB,EAA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":["checked","draggable","dropdown","dropdownClose","externalLink","indeterminate","navigation","next","statusError","statusInfo","statusWarning","defaultLibrary"],"sources":["../../node_modules/@quartzds/generic-icons-core/dist/checked.svg","../../node_modules/@quartzds/generic-icons-core/dist/draggable.svg","../../node_modules/@quartzds/generic-icons-core/dist/dropdown.svg","../../node_modules/@quartzds/generic-icons-core/dist/dropdown-close.svg","../../node_modules/@quartzds/generic-icons-core/dist/external-link.svg","../../node_modules/@quartzds/generic-icons-core/dist/indeterminate.svg","../../node_modules/@quartzds/generic-icons-core/dist/navigation.svg","../../node_modules/@quartzds/generic-icons-core/dist/next.svg","../../node_modules/@quartzds/generic-icons-core/dist/status-error.svg","../../node_modules/@quartzds/generic-icons-core/dist/status-info.svg","../../node_modules/@quartzds/generic-icons-core/dist/status-warning.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 20 20\"><path fill=\"currentColor\" fill-rule=\"evenodd\" d=\"m8.13 12.97 4.76-7.24.84.54-5.79 8.8-.35-.88v-.01l-.01-.02a7 7 0 0 0-.16-.36 9.4 9.4 0 0 0-1.06-1.87c-.23-.3-.43-.48-.59-.57l.46-.88c.36.18.67.5.92.84a8.6 8.6 0 0 1 .98 1.65\" clip-rule=\"evenodd\"/></svg>","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\"><path fill=\"currentColor\" d=\"M6 6a2 2 0 1 0 .001-3.999A2 2 0 0 0 6 6m8 0a2 2 0 1 0 .001-3.999A2 2 0 0 0 14 6M6 18a2 2 0 1 0 .001-3.999A2 2 0 0 0 6 18m0-6a2 2 0 1 0 .001-3.999A2 2 0 0 0 6 12m8 0a2 2 0 1 0 .001-3.999A2 2 0 0 0 14 12m0 6a2 2 0 1 0 .001-3.999A2 2 0 0 0 14 18\"/></svg>","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\"><path fill=\"currentColor\" fill-rule=\"evenodd\" d=\"m.85 5 8.67 8.67c.27.26.7.26.97 0L19.15 5l.7.7-8.66 8.66c-.65.66-1.72.66-2.37 0L.15 5.7z\" clip-rule=\"evenodd\"/></svg>","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\"><path fill=\"currentColor\" fill-rule=\"evenodd\" d=\"m.85 14.855 8.67-8.67a.7.7 0 0 1 .97 0l8.66 8.67.7-.7-8.66-8.66c-.65-.66-1.72-.66-2.37 0l-8.67 8.66z\" clip-rule=\"evenodd\"/></svg>","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\"><path fill=\"currentColor\" fill-rule=\"evenodd\" d=\"M13.16 0H20v6.72h-1.03V1.76l-6.46 6.46-.73-.73 6.46-6.46h-5.08zM0 3h11.05v1.02H1.03v14.95h15V8.53h1.02V20H0z\" clip-rule=\"evenodd\"/></svg>","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\"><path fill=\"currentColor\" fill-rule=\"evenodd\" d=\"M14 10H6V9h8z\" clip-rule=\"evenodd\"/></svg>","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\"><path fill=\"currentColor\" fill-rule=\"evenodd\" d=\"M13.66 9.51 5 .85l.7-.7 8.66 8.66c.66.65.66 1.72 0 2.37L5.7 19.85l-.7-.7 8.66-8.67a.68.68 0 0 0 0-.97\" clip-rule=\"evenodd\"/></svg>","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\"><path fill=\"currentColor\" fill-rule=\"evenodd\" d=\"M13.66 9.51 5 .85l.7-.7 8.66 8.66c.66.65.66 1.72 0 2.37L5.7 19.85l-.7-.7 8.66-8.67a.68.68 0 0 0 0-.97\" clip-rule=\"evenodd\"/></svg>","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\"><path fill=\"currentColor\" fill-rule=\"evenodd\" d=\"m9.87 9.2 3.2-3.2.71.7-3.2 3.21 3.2 3.2-.71.7-3.2-3.2-3.16 3.16-.7-.7L9.16 9.9 6 6.74l.7-.7z\" clip-rule=\"evenodd\"/></svg>","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\"><path fill=\"currentColor\" d=\"M9 4h2.41v2.15H9zm.13 12.51V7.97h2.18v8.54z\"/></svg>","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\"><path fill=\"currentColor\" d=\"m9.32 12.54-.7-8.89 2.77.02-.7 8.87zm-.58 1.34h2.52v2.48H8.74z\"/></svg>","// SPDX-FileCopyrightText: © 2024 Schneider Electric\n//\n// SPDX-License-Identifier: Apache-2.0\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 checked from '@quartzds/generic-icons-core/dist/checked.svg'\nimport draggable from '@quartzds/generic-icons-core/dist/draggable.svg'\nimport dropdown from '@quartzds/generic-icons-core/dist/dropdown.svg'\nimport dropdownClose from '@quartzds/generic-icons-core/dist/dropdown-close.svg'\nimport externalLink from '@quartzds/generic-icons-core/dist/external-link.svg'\nimport indeterminate from '@quartzds/generic-icons-core/dist/indeterminate.svg'\nimport navigation from '@quartzds/generic-icons-core/dist/navigation.svg'\nimport next from '@quartzds/generic-icons-core/dist/next.svg'\nimport statusError from '@quartzds/generic-icons-core/dist/status-error.svg'\nimport statusInfo from '@quartzds/generic-icons-core/dist/status-info.svg'\nimport statusWarning from '@quartzds/generic-icons-core/dist/status-warning.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 checked,\n draggable,\n dropdown,\n 'dropdown-close': dropdownClose,\n 'external-link': externalLink,\n indeterminate,\n navigation,\n next,\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: © 2024 Schneider Electric\n//\n// SPDX-License-Identifier: Apache-2.0\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: © 2024 Schneider Electric\n//\n// SPDX-License-Identifier: Apache-2.0\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: © 2024 Schneider Electric\n//\n// SPDX-License-Identifier: Apache-2.0\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: © 2024 Schneider Electric\n *\n * SPDX-License-Identifier: Apache-2.0\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: © 2024 Schneider Electric\n//\n// SPDX-License-Identifier: Apache-2.0\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() public readonly name!: string\n\n /**\n * The name of a registered icon library.\n */\n @Prop() 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 if (value !== undefined) 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,UAAU,GAAG,4bAA4b;;ACA/c,MAAM,YAAY,GAAG,oeAAoe;;ACAzf,MAAM,WAAW,GAAG,4UAA4U;;ACAhW,MAAM,gBAAgB,GAAG,4VAA4V;;ACArX,MAAM,eAAe,GAAG,oWAAoW;;ACA5X,MAAM,gBAAgB,GAAG,wOAAwO;;ACAjQ,MAAM,aAAa,GAAG,4VAA4V;;ACAlX,MAAM,OAAO,GAAG,4VAA4V;;ACA5W,MAAM,cAAc,GAAG,gVAAgV;;ACAvW,MAAM,aAAa,GAAG,wNAAwN;;ACA9O,MAAM,gBAAgB,GAA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AM,iBAAiB;QAC5B,IAAI,CAAC,mBAAmB,GAAG,qBAAqB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC9D,MAAM,IAAI,CAAC,OAAO,EAAE,CAAA;KACrB;IAEM,MAAM;QACX,QACE,4DAAK,KAAK,EAAC,eAAe,IACxB,6DAAM,KAAK,EAAC,kBAAkB,EAAC,SAAS,EAAE,IAAI,CAAC,GAAG,GAAI,EACtD,4DAAK,KAAK,EAAC,kBAAkB,GAAG,CAC5B,EACP;KACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["checked","draggable","dropdown","dropdownClose","externalLink","indeterminate","navigation","next","statusError","statusInfo","statusWarning","defaultLibrary"],"sources":["../../node_modules/@quartzds/generic-icons-core/dist/checked.svg","../../node_modules/@quartzds/generic-icons-core/dist/draggable.svg","../../node_modules/@quartzds/generic-icons-core/dist/dropdown.svg","../../node_modules/@quartzds/generic-icons-core/dist/dropdown-close.svg","../../node_modules/@quartzds/generic-icons-core/dist/external-link.svg","../../node_modules/@quartzds/generic-icons-core/dist/indeterminate.svg","../../node_modules/@quartzds/generic-icons-core/dist/navigation.svg","../../node_modules/@quartzds/generic-icons-core/dist/next.svg","../../node_modules/@quartzds/generic-icons-core/dist/status-error.svg","../../node_modules/@quartzds/generic-icons-core/dist/status-info.svg","../../node_modules/@quartzds/generic-icons-core/dist/status-warning.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 20 20\"><path fill=\"currentColor\" fill-rule=\"evenodd\" d=\"m8.13 12.97 4.76-7.24.84.54-5.79 8.8-.35-.88v-.01l-.01-.02a7 7 0 0 0-.16-.36 9.4 9.4 0 0 0-1.06-1.87c-.23-.3-.43-.48-.59-.57l.46-.88c.36.18.67.5.92.84a8.6 8.6 0 0 1 .98 1.65\" clip-rule=\"evenodd\"/></svg>","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\"><path fill=\"currentColor\" d=\"M6 6a2 2 0 1 0 .001-3.999A2 2 0 0 0 6 6m8 0a2 2 0 1 0 .001-3.999A2 2 0 0 0 14 6M6 18a2 2 0 1 0 .001-3.999A2 2 0 0 0 6 18m0-6a2 2 0 1 0 .001-3.999A2 2 0 0 0 6 12m8 0a2 2 0 1 0 .001-3.999A2 2 0 0 0 14 12m0 6a2 2 0 1 0 .001-3.999A2 2 0 0 0 14 18\"/></svg>","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\"><path fill=\"currentColor\" fill-rule=\"evenodd\" d=\"m.85 5 8.67 8.67c.27.26.7.26.97 0L19.15 5l.7.7-8.66 8.66c-.65.66-1.72.66-2.37 0L.15 5.7z\" clip-rule=\"evenodd\"/></svg>","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\"><path fill=\"currentColor\" fill-rule=\"evenodd\" d=\"m.85 14.855 8.67-8.67a.7.7 0 0 1 .97 0l8.66 8.67.7-.7-8.66-8.66c-.65-.66-1.72-.66-2.37 0l-8.67 8.66z\" clip-rule=\"evenodd\"/></svg>","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\"><path fill=\"currentColor\" fill-rule=\"evenodd\" d=\"M13.16 0H20v6.72h-1.03V1.76l-6.46 6.46-.73-.73 6.46-6.46h-5.08zM0 3h11.05v1.02H1.03v14.95h15V8.53h1.02V20H0z\" clip-rule=\"evenodd\"/></svg>","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\"><path fill=\"currentColor\" fill-rule=\"evenodd\" d=\"M14 10H6V9h8z\" clip-rule=\"evenodd\"/></svg>","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\"><path fill=\"currentColor\" fill-rule=\"evenodd\" d=\"M13.66 9.51 5 .85l.7-.7 8.66 8.66c.66.65.66 1.72 0 2.37L5.7 19.85l-.7-.7 8.66-8.67a.68.68 0 0 0 0-.97\" clip-rule=\"evenodd\"/></svg>","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\"><path fill=\"currentColor\" fill-rule=\"evenodd\" d=\"M13.66 9.51 5 .85l.7-.7 8.66 8.66c.66.65.66 1.72 0 2.37L5.7 19.85l-.7-.7 8.66-8.67a.68.68 0 0 0 0-.97\" clip-rule=\"evenodd\"/></svg>","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\"><path fill=\"currentColor\" fill-rule=\"evenodd\" d=\"m9.87 9.2 3.2-3.2.71.7-3.2 3.21 3.2 3.2-.71.7-3.2-3.2-3.16 3.16-.7-.7L9.16 9.9 6 6.74l.7-.7z\" clip-rule=\"evenodd\"/></svg>","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\"><path fill=\"currentColor\" d=\"M9 4h2.41v2.15H9zm.13 12.51V7.97h2.18v8.54z\"/></svg>","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\"><path fill=\"currentColor\" d=\"m9.32 12.54-.7-8.89 2.77.02-.7 8.87zm-.58 1.34h2.52v2.48H8.74z\"/></svg>","// SPDX-FileCopyrightText: © 2024 Schneider Electric\n//\n// SPDX-License-Identifier: Apache-2.0\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 checked from '@quartzds/generic-icons-core/dist/checked.svg'\nimport draggable from '@quartzds/generic-icons-core/dist/draggable.svg'\nimport dropdown from '@quartzds/generic-icons-core/dist/dropdown.svg'\nimport dropdownClose from '@quartzds/generic-icons-core/dist/dropdown-close.svg'\nimport externalLink from '@quartzds/generic-icons-core/dist/external-link.svg'\nimport indeterminate from '@quartzds/generic-icons-core/dist/indeterminate.svg'\nimport navigation from '@quartzds/generic-icons-core/dist/navigation.svg'\nimport next from '@quartzds/generic-icons-core/dist/next.svg'\nimport statusError from '@quartzds/generic-icons-core/dist/status-error.svg'\nimport statusInfo from '@quartzds/generic-icons-core/dist/status-info.svg'\nimport statusWarning from '@quartzds/generic-icons-core/dist/status-warning.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 checked,\n draggable,\n dropdown,\n 'dropdown-close': dropdownClose,\n 'external-link': externalLink,\n indeterminate,\n navigation,\n next,\n close: statusError,\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: © 2024 Schneider Electric\n//\n// SPDX-License-Identifier: Apache-2.0\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: © 2024 Schneider Electric\n//\n// SPDX-License-Identifier: Apache-2.0\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: © 2024 Schneider Electric\n//\n// SPDX-License-Identifier: Apache-2.0\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: © 2024 Schneider Electric\n *\n * SPDX-License-Identifier: Apache-2.0\n */\n\n@import url('../shared.css');\n\n:host {\n display: inline-block;\n height: 1em;\n width: 1em;\n}\n\n.qds-container {\n position: relative;\n}\n\n.qds-icon-wrapper {\n display: contents;\n}\n\nsvg {\n display: block;\n fill: currentcolor;\n height: 100%;\n width: 100%;\n}\n\n.qds-click-target {\n height: var(--qds-icon-click-target-size);\n left: calc(-1 * (var(--qds-icon-click-target-size) - 100%) / 2);\n position: absolute;\n top: calc(-1 * (var(--qds-icon-click-target-size) - 100%) / 2);\n width: var(--qds-icon-click-target-size);\n}\n","// SPDX-FileCopyrightText: © 2024 Schneider Electric\n//\n// SPDX-License-Identifier: Apache-2.0\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() public readonly name!: string\n\n /**\n * The name of a registered icon library.\n */\n @Prop() 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 if (value !== undefined) 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 (\n <div class=\"qds-container\">\n <span class=\"qds-icon-wrapper\" innerHTML={this.svg} />\n <div class=\"qds-click-target\" />\n </div>\n )\n }\n}\n"],"version":3}
|
package/components/index.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ export { Button as QdsButton } from '../dist/types/components/button/button';
|
|
|
3
3
|
export { defineCustomElement as defineCustomElementQdsButton } from './qds-button';
|
|
4
4
|
export { Checkbox as QdsCheckbox } from '../dist/types/components/checkbox/checkbox';
|
|
5
5
|
export { defineCustomElement as defineCustomElementQdsCheckbox } from './qds-checkbox';
|
|
6
|
+
export { Chip as QdsChip } from '../dist/types/components/chip/chip';
|
|
7
|
+
export { defineCustomElement as defineCustomElementQdsChip } from './qds-chip';
|
|
6
8
|
export { Dialog as QdsDialog } from '../dist/types/components/dialog/dialog';
|
|
7
9
|
export { defineCustomElement as defineCustomElementQdsDialog } from './qds-dialog';
|
|
8
10
|
export { Divider as QdsDivider } from '../dist/types/components/divider/divider';
|
package/components/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export { getAssetPath, setAssetPath, setNonce, setPlatformOptions } from '@stenc
|
|
|
7
7
|
export { r as registerIconLibrary, u as unregisterIconLibrary } from './icon.js';
|
|
8
8
|
export { QdsButton, defineCustomElement as defineCustomElementQdsButton } from './qds-button.js';
|
|
9
9
|
export { QdsCheckbox, defineCustomElement as defineCustomElementQdsCheckbox } from './qds-checkbox.js';
|
|
10
|
+
export { QdsChip, defineCustomElement as defineCustomElementQdsChip } from './qds-chip.js';
|
|
10
11
|
export { QdsDialog, defineCustomElement as defineCustomElementQdsDialog } from './qds-dialog.js';
|
|
11
12
|
export { QdsDivider, defineCustomElement as defineCustomElementQdsDivider } from './qds-divider.js';
|
|
12
13
|
export { QdsDropdown, defineCustomElement as defineCustomElementQdsDropdown } from './qds-dropdown.js';
|
package/components/index.js.map
CHANGED
|
@@ -1 +1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ca,WAAW,GAAG,CACzB,OAAyB,KACF,UAAU,CAAC,UAAU,EAAE,WAAW,CAAC,OAAO,CAAC,EAAC;AAErE;;;;;;;;;;;;;;;MAea,WAAW,GAAG,CAKzB,QAAqB,EACrB,OAAyB;IAEzB,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;IAEzB,UAAU,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAA;AACrC;;;;","names":[],"sources":["src/utils.ts"],"sourcesContent":["// SPDX-FileCopyrightText: © 2024 Schneider Electric\n//\n// SPDX-License-Identifier: Apache-2.0\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}
|
package/components/label.js
CHANGED
|
@@ -36,7 +36,7 @@ const Label = /*@__PURE__*/ proxyCustomElement(class Label extends HTMLElement {
|
|
|
36
36
|
this.inheritedAttributes = inheritAriaAttributes(this.element);
|
|
37
37
|
}
|
|
38
38
|
render() {
|
|
39
|
-
return (h("span", { key: '
|
|
39
|
+
return (h("span", { key: '6ffca86718674dbfaa917f1e4d0620f4398ab569', class: {
|
|
40
40
|
'qds-inline': this.inline,
|
|
41
41
|
'qds-label': true,
|
|
42
42
|
}, "data-size": this.computedSize, ...this.inheritedAttributes }, this.required && h("span", { class: "qds-required" }, "*"), this.text));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../dist/types/components";
|
|
2
|
+
|
|
3
|
+
interface QdsChip extends Components.QdsChip, HTMLElement {}
|
|
4
|
+
export const QdsChip: {
|
|
5
|
+
prototype: QdsChip;
|
|
6
|
+
new (): QdsChip;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* SPDX-FileCopyrightText: © 2024 Schneider Electric
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
|
7
|
+
import { p as pickFocusEventAttributes, i as inheritAriaAttributes, a as inheritAttributes } from './helpers.js';
|
|
8
|
+
import { d as defineCustomElement$2 } from './icon.js';
|
|
9
|
+
|
|
10
|
+
const chipCss = ":host([hidden]){display:none !important}:host{display:inline-block;line-height:0}[aria-disabled='true']{opacity:var(--qds-theme-disabled);pointer-events:none}.qds-target{-webkit-appearance:none;appearance:none;display:flex;border:none;padding:0;background-color:transparent;color:inherit;cursor:pointer;pointer-events:auto}.qds-target:disabled{pointer-events:none}.qds-alignment{display:flex;align-items:center}.qds-cursor{cursor:pointer}.qds-icon{flex-shrink:0}.qds-closable-chip,.qds-container{display:inline-flex;align-items:center;justify-content:center;padding-block:0;-webkit-user-select:none;user-select:none;white-space:nowrap;border:var(--qds-control-border-width) solid var(--qds-theme-control-border);border-radius:var(--qds-control-rounded-border-radius);color:var(--qds-theme-control-text-standard);background-color:initial;-webkit-appearance:none;appearance:none}.qds-closable-chip{pointer-events:none}.qds-closable-chip:focus-visible{outline:var(--qds-theme-focus-border) solid var(--qds-focus-border-width);outline-offset:var(--qds-focus-border-offset)}.qds-container:hover{background-color:var(--qds-theme-interactive-background-hover)}.qds-checkbox:active~.qds-container,.qds-closable-chip:has(.qds-target:active),.qds-container.qds-pressed-state{background-color:var(--qds-theme-interactive-background-pressed)}.qds-checkbox{-webkit-clip-path:inset(50%);clip-path:inset(50%);margin:0;position:absolute;white-space:nowrap}.qds-checkbox:focus-visible~.qds-container{outline:var(--qds-theme-focus-border) solid var(--qds-focus-border-width);outline-offset:var(--qds-focus-border-offset)}.qds-closable-chip[data-size='small'],.qds-container[data-size='small']{height:var(--qds-control-small-height);padding-inline:var(--qds-control-chip-small-padding-horizontal);gap:var(--qds-control-small-gap-internal)}.qds-icon[data-size='small']{--qds-icon-click-target-size:var(--qds-control-small-height);height:var(--qds-control-small-icon-size);width:var(--qds-control-small-icon-size)}.qds-text[data-size='small']{font:var(--qds-control-small-text)}.qds-closable-chip[data-size='standard'],.qds-container[data-size='standard']{height:var(--qds-control-standard-height);padding-inline:var(--qds-control-chip-standard-padding-horizontal);gap:var(--qds-control-standard-gap-internal)}.qds-icon[data-size='standard']{--qds-icon-click-target-size:var(--qds-control-standard-height);height:var(--qds-control-standard-icon-size);width:var(--qds-control-standard-icon-size)}.qds-text[data-size='standard']{font:var(--qds-control-standard-text)}.qds-closable-chip[data-size='large'],.qds-container[data-size='large']{height:var(--qds-control-large-height);padding-inline:var(--qds-control-chip-large-padding-horizontal);gap:var(--qds-control-large-gap-internal)}.qds-icon[data-size='large']{--qds-icon-click-target-size:var(--qds-control-large-height);height:var(--qds-control-large-icon-size);width:var(--qds-control-large-icon-size)}.qds-text[data-size='large']{font:var(--qds-control-large-text)}";
|
|
11
|
+
const QdsChipStyle0 = chipCss;
|
|
12
|
+
|
|
13
|
+
const Chip = /*@__PURE__*/ proxyCustomElement(class Chip extends HTMLElement {
|
|
14
|
+
constructor() {
|
|
15
|
+
super();
|
|
16
|
+
this.__registerHost();
|
|
17
|
+
this.__attachShadow();
|
|
18
|
+
this.blurEmitter = createEvent(this, "qdsBlur", 2);
|
|
19
|
+
this.focusEmitter = createEvent(this, "qdsFocus", 2);
|
|
20
|
+
this.closeEmitter = createEvent(this, "qdsClose", 6);
|
|
21
|
+
this.changeEmitter = createEvent(this, "qdsChange", 6);
|
|
22
|
+
this.internals = this.attachInternals();
|
|
23
|
+
this.inheritedAttributes = {};
|
|
24
|
+
this.close = () => {
|
|
25
|
+
this.closeEmitter.emit();
|
|
26
|
+
};
|
|
27
|
+
this.onIconClick = (event) => {
|
|
28
|
+
if (!event.defaultPrevented && this.computedType === 'closable')
|
|
29
|
+
this.close();
|
|
30
|
+
};
|
|
31
|
+
this.onFocus = (event) => {
|
|
32
|
+
this.focusEmitter.emit(pickFocusEventAttributes(event));
|
|
33
|
+
};
|
|
34
|
+
this.onBlur = (event) => {
|
|
35
|
+
this.blurEmitter.emit(pickFocusEventAttributes(event));
|
|
36
|
+
};
|
|
37
|
+
this.iconName = undefined;
|
|
38
|
+
this.iconLibrary = 'default';
|
|
39
|
+
this.size = 'standard';
|
|
40
|
+
this.type = 'selectable';
|
|
41
|
+
this.text = undefined;
|
|
42
|
+
this.checked = undefined;
|
|
43
|
+
this.form = undefined;
|
|
44
|
+
this.disabled = undefined;
|
|
45
|
+
this.name = undefined;
|
|
46
|
+
this.autoFocus = undefined;
|
|
47
|
+
this.value = 'on';
|
|
48
|
+
this.isPressed = false;
|
|
49
|
+
}
|
|
50
|
+
get computedDisabled() {
|
|
51
|
+
return this.disabled ?? false;
|
|
52
|
+
}
|
|
53
|
+
get computedSize() {
|
|
54
|
+
switch (this.size) {
|
|
55
|
+
case 'standard':
|
|
56
|
+
case 'small':
|
|
57
|
+
case 'large': {
|
|
58
|
+
return this.size;
|
|
59
|
+
}
|
|
60
|
+
default: {
|
|
61
|
+
return 'standard';
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
get computedType() {
|
|
66
|
+
switch (this.type) {
|
|
67
|
+
case 'selectable':
|
|
68
|
+
case 'closable': {
|
|
69
|
+
return this.type;
|
|
70
|
+
}
|
|
71
|
+
default: {
|
|
72
|
+
return 'selectable';
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
get computedTabIndex() {
|
|
77
|
+
const parsedValue = Number.parseInt(this.inheritedAttributes.tabindex ?? '0', 10);
|
|
78
|
+
return Number.isNaN(parsedValue) ? 0 : parsedValue;
|
|
79
|
+
}
|
|
80
|
+
get computedChecked() {
|
|
81
|
+
return this.checked ?? false;
|
|
82
|
+
}
|
|
83
|
+
get computedValue() {
|
|
84
|
+
// eslint-disable-next-line unicorn/no-null
|
|
85
|
+
return this.value == null ? null : this.value.toString();
|
|
86
|
+
}
|
|
87
|
+
onClick(event) {
|
|
88
|
+
if (this.computedDisabled) {
|
|
89
|
+
event.stopImmediatePropagation();
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
event.preventDefault();
|
|
93
|
+
if (this.computedType === 'selectable') {
|
|
94
|
+
this.checked = !this.computedChecked;
|
|
95
|
+
this.changeEmitter.emit();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
handleKeyDown(event) {
|
|
99
|
+
if (this.computedDisabled) {
|
|
100
|
+
event.stopImmediatePropagation();
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (event.key === ' ') {
|
|
104
|
+
this.isPressed = true;
|
|
105
|
+
event.preventDefault();
|
|
106
|
+
}
|
|
107
|
+
else if (event.key === 'Enter') {
|
|
108
|
+
if (this.internals.form) {
|
|
109
|
+
this.internals.form.requestSubmit();
|
|
110
|
+
event.preventDefault();
|
|
111
|
+
}
|
|
112
|
+
if (this.computedType === 'closable')
|
|
113
|
+
this.closeEmitter.emit();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
handleKeyUp(event) {
|
|
117
|
+
if (event.key !== ' ')
|
|
118
|
+
return;
|
|
119
|
+
this.isPressed = false;
|
|
120
|
+
if (this.computedType === 'closable')
|
|
121
|
+
this.closeEmitter.emit();
|
|
122
|
+
else
|
|
123
|
+
this.changeEmitter.emit();
|
|
124
|
+
}
|
|
125
|
+
checkedChanged() {
|
|
126
|
+
this.internals.setFormValue(this.computedChecked && !this.computedDisabled
|
|
127
|
+
? this.computedValue
|
|
128
|
+
: // eslint-disable-next-line unicorn/no-null
|
|
129
|
+
null);
|
|
130
|
+
}
|
|
131
|
+
disabledChanged() {
|
|
132
|
+
if (this.computedChecked && !this.computedDisabled) {
|
|
133
|
+
this.inheritedAttributes = {
|
|
134
|
+
...this.inheritedAttributes,
|
|
135
|
+
tabindex: this.savedTabindex,
|
|
136
|
+
};
|
|
137
|
+
this.internals.setFormValue(this.computedValue);
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
this.savedTabindex = this.inheritedAttributes.tabindex;
|
|
141
|
+
this.inheritedAttributes = {
|
|
142
|
+
...this.inheritedAttributes,
|
|
143
|
+
tabindex: undefined,
|
|
144
|
+
};
|
|
145
|
+
// eslint-disable-next-line unicorn/no-null
|
|
146
|
+
this.internals.setFormValue(null);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
tabindexChanged(newValue) {
|
|
150
|
+
if (this.computedDisabled)
|
|
151
|
+
this.savedTabindex = newValue;
|
|
152
|
+
else
|
|
153
|
+
this.inheritedAttributes = {
|
|
154
|
+
...this.inheritedAttributes,
|
|
155
|
+
tabindex: newValue,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
valueChanged() {
|
|
159
|
+
if (this.computedChecked && !this.computedDisabled)
|
|
160
|
+
this.internals.setFormValue(this.computedValue);
|
|
161
|
+
}
|
|
162
|
+
componentWillLoad() {
|
|
163
|
+
this.valueChanged();
|
|
164
|
+
Object.defineProperty(this.element, 'form', {
|
|
165
|
+
enumerable: true,
|
|
166
|
+
get: () => this.internals.form,
|
|
167
|
+
});
|
|
168
|
+
this.inheritedAttributes = {
|
|
169
|
+
...inheritAriaAttributes(this.element),
|
|
170
|
+
...inheritAttributes(this.element, ['tabindex']),
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
render() {
|
|
174
|
+
return (h(Host, { key: '8898971924de5e4a864a86ae3ccd0d110fcb7347' }, this.computedType === 'closable' && (h("div", { "aria-disabled": this.computedDisabled.toString(), class: {
|
|
175
|
+
'qds-container': true,
|
|
176
|
+
'qds-closable-chip': true,
|
|
177
|
+
'qds-pressed-state': this.isPressed,
|
|
178
|
+
}, "data-size": this.computedSize, tabIndex: this.computedDisabled ? -1 : this.computedTabIndex }, this.iconName !== undefined && this.iconName !== '' && (h("qds-icon", { class: "qds-icon", "data-size": this.computedSize, library: this.iconLibrary, name: this.iconName })), h("span", { class: "qds-text", "data-size": this.computedSize }, this.text), h("button", { "aria-label": "close", class: "qds-target", "data-size": this.computedSize, disabled: this.computedDisabled, onClick: this.onIconClick, tabIndex: this.computedDisabled ? -1 : -1, type: "button", ...this.inheritedAttributes }, h("qds-icon", { class: "qds-icon", "data-size": this.computedSize, library: "core", name: "close" })))), this.computedType === 'selectable' && (
|
|
179
|
+
// eslint-disable-next-line jsx-a11y/label-has-associated-control
|
|
180
|
+
h("label", { "aria-disabled": this.computedDisabled.toString() }, h("input", {
|
|
181
|
+
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
182
|
+
autoFocus: this.autoFocus, checked: this.checked, class: "qds-checkbox", "data-size": this.computedSize, disabled: this.computedDisabled, form: this.form, name: this.name, onBlur: this.onBlur, onFocus: this.onFocus, type: "checkbox", value: this.value ?? undefined, ...this.inheritedAttributes
|
|
183
|
+
}), h("div", { class: {
|
|
184
|
+
'qds-container': true,
|
|
185
|
+
'qds-pressed-state': this.isPressed,
|
|
186
|
+
'qds-padding-end': true,
|
|
187
|
+
'qds-cursor': true,
|
|
188
|
+
}, "data-size": this.computedSize }, this.iconName !== undefined && this.iconName !== '' && (h("qds-icon", { class: "qds-icon", "data-size": this.computedSize, library: this.iconLibrary, name: this.iconName })), h("span", { class: "qds-text", "data-size": this.computedSize }, this.text), (this.checked ?? false) && (h("qds-icon", { "aria-hidden": "true", class: "qds-icon", "data-size": this.computedSize, library: "core", name: "checked" })))))));
|
|
189
|
+
}
|
|
190
|
+
static get delegatesFocus() { return true; }
|
|
191
|
+
static get formAssociated() { return true; }
|
|
192
|
+
get element() { return this; }
|
|
193
|
+
static get watchers() { return {
|
|
194
|
+
"checked": ["checkedChanged"],
|
|
195
|
+
"disabled": ["disabledChanged"],
|
|
196
|
+
"tabindex": ["tabindexChanged"],
|
|
197
|
+
"value": ["valueChanged"]
|
|
198
|
+
}; }
|
|
199
|
+
static get style() { return QdsChipStyle0; }
|
|
200
|
+
}, [81, "qds-chip", {
|
|
201
|
+
"iconName": [1, "icon-name"],
|
|
202
|
+
"iconLibrary": [1, "icon-library"],
|
|
203
|
+
"size": [1],
|
|
204
|
+
"type": [1],
|
|
205
|
+
"text": [1],
|
|
206
|
+
"checked": [1028],
|
|
207
|
+
"form": [1],
|
|
208
|
+
"disabled": [4],
|
|
209
|
+
"name": [1],
|
|
210
|
+
"autoFocus": [4, "autofocus"],
|
|
211
|
+
"value": [8],
|
|
212
|
+
"isPressed": [32]
|
|
213
|
+
}, [[0, "click", "onClick"], [0, "keydown", "handleKeyDown"], [0, "keyup", "handleKeyUp"]], {
|
|
214
|
+
"checked": ["checkedChanged"],
|
|
215
|
+
"disabled": ["disabledChanged"],
|
|
216
|
+
"tabindex": ["tabindexChanged"],
|
|
217
|
+
"value": ["valueChanged"]
|
|
218
|
+
}]);
|
|
219
|
+
function defineCustomElement$1() {
|
|
220
|
+
if (typeof customElements === "undefined") {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
const components = ["qds-chip", "qds-icon"];
|
|
224
|
+
components.forEach(tagName => { switch (tagName) {
|
|
225
|
+
case "qds-chip":
|
|
226
|
+
if (!customElements.get(tagName)) {
|
|
227
|
+
customElements.define(tagName, Chip);
|
|
228
|
+
}
|
|
229
|
+
break;
|
|
230
|
+
case "qds-icon":
|
|
231
|
+
if (!customElements.get(tagName)) {
|
|
232
|
+
defineCustomElement$2();
|
|
233
|
+
}
|
|
234
|
+
break;
|
|
235
|
+
} });
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
const QdsChip = Chip;
|
|
239
|
+
const defineCustomElement = defineCustomElement$1;
|
|
240
|
+
|
|
241
|
+
export { QdsChip, defineCustomElement };
|
|
242
|
+
|
|
243
|
+
//# sourceMappingURL=qds-chip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"qds-chip.js","mappings":";;;;;;;;;AAAA,MAAM,OAAO,GAAG,w7FAAw7F,CAAC;AACz8F,sBAAe,OAAO;;MCyCT,IAAI;;;;;;;;;;QA+GP,wBAAmB,GAAe,EAAE,CAAA;QA2P3B,UAAK,GAAG;YACvB,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,CAAA;SACzB,CAAA;QAEgB,gBAAW,GAAG,CAAC,KAAiB;YAC/C,IAAI,CAAC,KAAK,CAAC,gBAAgB,IAAI,IAAI,CAAC,YAAY,KAAK,UAAU;gBAC7D,IAAI,CAAC,KAAK,EAAE,CAAA;SACf,CAAA;QAEgB,YAAO,GAAG,CAAC,KAAiB;YAC3C,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC,CAAA;SACxD,CAAA;QAEgB,WAAM,GAAG,CAAC,KAAiB;YAC1C,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC,CAAA;SACvD,CAAA;;2BA9W6C,SAAS;oBAKlB,UAAU;oBAKL,YAAY;;;;;;;qBAwDd,IAAI;yBA8Bf,KAAK;;IAMlC,IAAY,gBAAgB;Q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C,UAAU,EACf,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,SAAS,KAE1B,IAAI,CAAC,mBAAmB;UAC5B,EACF,WACE,KAAK,EAAE;gBACL,eAAe,EAAE,IAAI;gBACrB,mBAAmB,EAAE,IAAI,CAAC,SAAS;gBACnC,iBAAiB,EAAE,IAAI;gBACvB,YAAY,EAAE,IAAI;aACnB,eACU,IAAI,CAAC,YAAY,IAE3B,IAAI,CAAC,QAAQ,KAAK,SAAS,IAAI,IAAI,CAAC,QAAQ,KAAK,EAAE,KAClD,gBACE,KAAK,EAAC,UAAU,eACL,IAAI,CAAC,YAAY,EAC5B,OAAO,EAAE,IAAI,CAAC,WAAW,EACzB,IAAI,EAAE,IAAI,CAAC,QAAQ,GACnB,CACH,EACD,YAAM,KAAK,EAAC,UAAU,eAAY,IAAI,CAAC,YAAY,IAChD,IAAI,CAAC,IAAI,CACL,EACN,CAAC,IAAI,CAAC,OAAO,IAAI,KAAK,MACrB,+BACc,MAAM,EAClB,KAAK,EAAC,UAAU,eACL,IAAI,CAAC,YAAY,EAC5B,OAAO,EAAC,MAAM,EACd,IAAI,EAAC,SAAS,GACd,CACH,CACG,CACA,CACT,CACI,EACR;KACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/chip/chip.css?tag=qds-chip&encapsulation=shadow","src/components/chip/chip.tsx"],"sourcesContent":["/*\n * SPDX-FileCopyrightText: © 2024 Schneider Electric\n *\n * SPDX-License-Identifier: Apache-2.0\n */\n\n@import url('../shared.css');\n\n:host {\n display: inline-block;\n line-height: 0;\n}\n\n[aria-disabled='true'] {\n opacity: var(--qds-theme-disabled);\n pointer-events: none;\n}\n\n.qds-target {\n appearance: none;\n display: flex;\n border: none;\n padding: 0;\n background-color: transparent;\n color: inherit;\n cursor: pointer;\n pointer-events: auto;\n\n &:disabled {\n pointer-events: none;\n }\n}\n\n.qds-alignment {\n display: flex;\n align-items: center;\n}\n\n.qds-cursor {\n cursor: pointer;\n}\n\n.qds-icon {\n flex-shrink: 0;\n}\n\n.qds-closable-chip,\n.qds-container {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n padding-block: 0;\n user-select: none;\n white-space: nowrap;\n border: var(--qds-control-border-width) solid var(--qds-theme-control-border);\n border-radius: var(--qds-control-rounded-border-radius);\n color: var(--qds-theme-control-text-standard);\n background-color: initial;\n appearance: none;\n}\n\n.qds-closable-chip {\n pointer-events: none;\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.qds-container:hover {\n background-color: var(--qds-theme-interactive-background-hover);\n}\n\n.qds-checkbox:active ~ .qds-container,\n.qds-closable-chip:has(.qds-target:active),\n.qds-container.qds-pressed-state {\n background-color: var(--qds-theme-interactive-background-pressed);\n}\n\n.qds-checkbox {\n clip-path: inset(50%);\n margin: 0;\n position: absolute;\n white-space: nowrap;\n\n &:focus-visible ~ .qds-container {\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[data-size='small'] {\n &.qds-closable-chip,\n &.qds-container {\n height: var(--qds-control-small-height);\n padding-inline: var(--qds-control-chip-small-padding-horizontal);\n gap: var(--qds-control-small-gap-internal);\n }\n\n &.qds-icon {\n --qds-icon-click-target-size: var(--qds-control-small-height);\n\n height: var(--qds-control-small-icon-size);\n width: var(--qds-control-small-icon-size);\n }\n\n &.qds-text {\n font: var(--qds-control-small-text);\n }\n}\n\n[data-size='standard'] {\n &.qds-closable-chip,\n &.qds-container {\n height: var(--qds-control-standard-height);\n padding-inline: var(--qds-control-chip-standard-padding-horizontal);\n gap: var(--qds-control-standard-gap-internal);\n }\n\n &.qds-icon {\n --qds-icon-click-target-size: var(--qds-control-standard-height);\n\n height: var(--qds-control-standard-icon-size);\n width: var(--qds-control-standard-icon-size);\n }\n\n &.qds-text {\n font: var(--qds-control-standard-text);\n }\n}\n\n[data-size='large'] {\n &.qds-closable-chip,\n &.qds-container {\n height: var(--qds-control-large-height);\n padding-inline: var(--qds-control-chip-large-padding-horizontal);\n gap: var(--qds-control-large-gap-internal);\n }\n\n &.qds-icon {\n --qds-icon-click-target-size: var(--qds-control-large-height);\n\n height: var(--qds-control-large-icon-size);\n width: var(--qds-control-large-icon-size);\n }\n\n &.qds-text {\n font: var(--qds-control-large-text);\n }\n}\n","// SPDX-FileCopyrightText: © 2024 Schneider Electric\n//\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { ComponentInterface, EventEmitter } from '@stencil/core'\nimport {\n AttachInternals,\n Component,\n Element,\n Event,\n h,\n Host,\n Listen,\n Prop,\n State,\n Watch,\n} from '@stencil/core'\n\nimport type { Attributes, QdsFocusEventDetail } from '../../helpers'\nimport {\n inheritAriaAttributes,\n inheritAttributes,\n pickFocusEventAttributes,\n} from '../../helpers'\nimport type { Value } from '../controls'\nimport type { Size } from '../shared'\n\nexport type ChipType = 'closable' | 'selectable'\n\n/**\n * `<qds-chip>` elements are interactive elements that represent selections.\n * Chips allow users to make a selection from a list of options or display\n * items like filters or tags.\n *\n * @see https://quartz.se.com/build/components/chip\n */\n@Component({\n tag: 'qds-chip',\n formAssociated: true,\n shadow: { delegatesFocus: true },\n styleUrl: 'chip.css',\n})\nexport class Chip 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() public readonly iconName?: string\n\n /**\n * The name of a registered icon library.\n */\n @Prop() public readonly iconLibrary: string = 'default'\n\n /**\n * The chip's size.\n */\n @Prop() public readonly size: Size = 'standard'\n\n /**\n * The chip's type.\n */\n @Prop() public readonly type?: ChipType = 'selectable'\n\n /**\n * The chip's text.\n */\n @Prop() public readonly text?: string\n\n /**\n * Sets the selectable chip's state.\n *\n * @webnative\n */\n @Prop({ mutable: true }) public checked?: boolean\n\n /**\n * The [`<form>`](https://developer.mozilla.org/docs/Web/HTML/Element/form)\n * element to associate the chip 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-chip>` is associated\n * with its ancestor `<form>` element, if any.\n *\n * This property lets you associate `<qds-chip>` 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 * Prevents the chip from being interacted with: it cannot be pressed or\n * focused.\n *\n */\n @Prop() public readonly disabled?: boolean\n\n /**\n * The name of the chip, which is submitted with the form data.\n *\n * @webnative\n */\n @Prop() public readonly name?: string\n\n /**\n * Specify whether the chip should have focus when the page loads.\n *\n * @webnative\n */\n @Prop({ attribute: 'autofocus' }) public readonly autoFocus?: boolean\n\n /**\n * The value of the chip, submitted as a name/value pair with form data.\n *\n * @webnative\n */\n @Prop() public readonly value?: Value = 'on'\n\n /**\n * Emitted when the chip loses focus.\n */\n @Event({ eventName: 'qdsBlur', bubbles: false, cancelable: false })\n private readonly blurEmitter!: EventEmitter<QdsFocusEventDetail>\n\n /**\n * Emitted when the chip gains focus.\n */\n @Event({ eventName: 'qdsFocus', bubbles: false, cancelable: false })\n private readonly focusEmitter!: EventEmitter<QdsFocusEventDetail>\n\n /**\n * Emitted when the chip is closed.\n */\n @Event({ eventName: 'qdsClose', cancelable: false })\n private readonly closeEmitter!: EventEmitter<void>\n\n /**\n * Emitted when a change to the selectable chip's state is committed by the user.\n */\n @Event({ eventName: 'qdsChange', cancelable: false })\n private readonly changeEmitter!: EventEmitter<void>\n\n @Element() private readonly element!: HTMLQdsChipElement\n\n @AttachInternals() private readonly internals!: ElementInternals\n\n @State() private isPressed = false\n\n private savedTabindex?: string\n\n private inheritedAttributes: Attributes = {}\n\n private get computedDisabled(): boolean {\n return this.disabled ?? false\n }\n\n private get computedSize(): Size {\n switch (this.size) {\n case 'standard':\n case 'small':\n case 'large': {\n return this.size\n }\n default: {\n return 'standard'\n }\n }\n }\n\n private get computedType(): ChipType {\n switch (this.type) {\n case 'selectable':\n case 'closable': {\n return this.type\n }\n default: {\n return 'selectable'\n }\n }\n }\n\n private get computedTabIndex(): number {\n const parsedValue = Number.parseInt(\n this.inheritedAttributes.tabindex ?? '0',\n 10,\n )\n return Number.isNaN(parsedValue) ? 0 : parsedValue\n }\n\n private get computedChecked(): boolean {\n return this.checked ?? false\n }\n\n private get computedValue(): string | null {\n // eslint-disable-next-line unicorn/no-null\n return this.value == null ? null : this.value.toString()\n }\n\n @Listen('click')\n protected onClick(event: MouseEvent): void {\n if (this.computedDisabled) {\n event.stopImmediatePropagation()\n return\n }\n\n event.preventDefault()\n\n if (this.computedType === 'selectable') {\n this.checked = !this.computedChecked\n this.changeEmitter.emit()\n }\n }\n\n @Listen('keydown')\n protected handleKeyDown(event: KeyboardEvent): void {\n if (this.computedDisabled) {\n event.stopImmediatePropagation()\n return\n }\n\n if (event.key === ' ') {\n this.isPressed = true\n event.preventDefault()\n } else if (event.key === 'Enter') {\n if (this.internals.form) {\n this.internals.form.requestSubmit()\n event.preventDefault()\n }\n\n if (this.computedType === 'closable') this.closeEmitter.emit()\n }\n }\n\n @Listen('keyup')\n protected handleKeyUp(event: KeyboardEvent): void {\n if (event.key !== ' ') return\n\n this.isPressed = false\n if (this.computedType === 'closable') this.closeEmitter.emit()\n else this.changeEmitter.emit()\n }\n\n @Watch('checked')\n protected checkedChanged(): void {\n this.internals.setFormValue(\n this.computedChecked && !this.computedDisabled\n ? this.computedValue\n : // eslint-disable-next-line unicorn/no-null\n null,\n )\n }\n\n @Watch('disabled')\n protected disabledChanged(): void {\n if (this.computedChecked && !this.computedDisabled) {\n this.inheritedAttributes = {\n ...this.inheritedAttributes,\n tabindex: this.savedTabindex,\n }\n this.internals.setFormValue(this.computedValue)\n } else {\n this.savedTabindex = this.inheritedAttributes.tabindex\n this.inheritedAttributes = {\n ...this.inheritedAttributes,\n tabindex: undefined,\n }\n // eslint-disable-next-line unicorn/no-null\n this.internals.setFormValue(null)\n }\n }\n\n @Watch('tabindex')\n protected tabindexChanged(newValue: string): void {\n if (this.computedDisabled) this.savedTabindex = newValue\n else\n this.inheritedAttributes = {\n ...this.inheritedAttributes,\n tabindex: newValue,\n }\n }\n\n @Watch('value')\n protected valueChanged(): void {\n if (this.computedChecked && !this.computedDisabled)\n this.internals.setFormValue(this.computedValue)\n }\n\n public componentWillLoad(): void {\n this.valueChanged()\n\n Object.defineProperty(this.element, 'form', {\n enumerable: true,\n get: () => this.internals.form,\n })\n\n this.inheritedAttributes = {\n ...inheritAriaAttributes(this.element),\n ...inheritAttributes(this.element, ['tabindex']),\n }\n }\n\n public render() {\n return (\n <Host>\n {this.computedType === 'closable' && (\n <div\n aria-disabled={this.computedDisabled.toString()}\n class={{\n 'qds-container': true,\n 'qds-closable-chip': true,\n 'qds-pressed-state': this.isPressed,\n }}\n data-size={this.computedSize}\n tabIndex={this.computedDisabled ? -1 : this.computedTabIndex}\n >\n {this.iconName !== undefined && this.iconName !== '' && (\n <qds-icon\n class=\"qds-icon\"\n data-size={this.computedSize}\n library={this.iconLibrary}\n name={this.iconName}\n />\n )}\n <span class=\"qds-text\" data-size={this.computedSize}>\n {this.text}\n </span>\n <button\n aria-label=\"close\"\n class=\"qds-target\"\n data-size={this.computedSize}\n disabled={this.computedDisabled}\n onClick={this.onIconClick}\n tabIndex={this.computedDisabled ? -1 : -1}\n type=\"button\"\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...this.inheritedAttributes}\n >\n <qds-icon\n class=\"qds-icon\"\n data-size={this.computedSize}\n library=\"core\"\n name=\"close\"\n />\n </button>\n </div>\n )}\n {this.computedType === 'selectable' && (\n // eslint-disable-next-line jsx-a11y/label-has-associated-control\n <label aria-disabled={this.computedDisabled.toString()}>\n <input\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={this.autoFocus}\n checked={this.checked}\n class=\"qds-checkbox\"\n data-size={this.computedSize}\n disabled={this.computedDisabled}\n form={this.form}\n name={this.name}\n onBlur={this.onBlur}\n onFocus={this.onFocus}\n type=\"checkbox\"\n value={this.value ?? undefined}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...this.inheritedAttributes}\n />\n <div\n class={{\n 'qds-container': true,\n 'qds-pressed-state': this.isPressed,\n 'qds-padding-end': true,\n 'qds-cursor': true,\n }}\n data-size={this.computedSize}\n >\n {this.iconName !== undefined && this.iconName !== '' && (\n <qds-icon\n class=\"qds-icon\"\n data-size={this.computedSize}\n library={this.iconLibrary}\n name={this.iconName}\n />\n )}\n <span class=\"qds-text\" data-size={this.computedSize}>\n {this.text}\n </span>\n {(this.checked ?? false) && (\n <qds-icon\n aria-hidden=\"true\"\n class=\"qds-icon\"\n data-size={this.computedSize}\n library=\"core\"\n name=\"checked\"\n />\n )}\n </div>\n </label>\n )}\n </Host>\n )\n }\n\n private readonly close = (): void => {\n this.closeEmitter.emit()\n }\n\n private readonly onIconClick = (event: MouseEvent): void => {\n if (!event.defaultPrevented && this.computedType === 'closable')\n this.close()\n }\n\n private readonly onFocus = (event: FocusEvent): void => {\n this.focusEmitter.emit(pickFocusEventAttributes(event))\n }\n\n private readonly onBlur = (event: FocusEvent): void => {\n this.blurEmitter.emit(pickFocusEventAttributes(event))\n }\n}\n"],"version":3}
|
package/components/qds-dialog.js
CHANGED
|
@@ -64,7 +64,7 @@ const Dialog = /*@__PURE__*/ proxyCustomElement(class Dialog extends HTMLElement
|
|
|
64
64
|
await this.show();
|
|
65
65
|
}
|
|
66
66
|
render() {
|
|
67
|
-
return (h(Host, { key: '
|
|
67
|
+
return (h(Host, { key: '6c07f0d511c79f8bc9d1c9e230c44471e6655eaa' }, h("dialog", { key: '9e3c3ce9fa270664c3281aec28dc1a0507146063', class: "qds-dialog", ref: this.ref, onSubmit: this.boundSubmit, onCancel: this.onCancel, onClose: this.onClose, ...this.inheritedAttributes }, h("div", { key: '60dded49326a06648ad8098efcaa52e29bcfe64b', class: "qds-content" }, h("slot", { key: 'b356237b1f9943e0151f582d58532ab3c126b01d' }))), h("div", { key: 'e4f3284dd1b72ef89517eaa0de36efe65d42588d', class: "qds-backdrop" })));
|
|
68
68
|
}
|
|
69
69
|
async handleSubmit(event) {
|
|
70
70
|
if ((event instanceof SubmitEvent &&
|
|
@@ -32,7 +32,7 @@ const Divider = /*@__PURE__*/ proxyCustomElement(class Divider extends HTMLEleme
|
|
|
32
32
|
this.inheritedAttributes = inheritAriaAttributes(this.element);
|
|
33
33
|
}
|
|
34
34
|
render() {
|
|
35
|
-
return (h("hr", { key: '
|
|
35
|
+
return (h("hr", { key: 'b2b5829d2de270f396292d8f8d38480c735d69bb', class: {
|
|
36
36
|
'qds-divider': true,
|
|
37
37
|
'qds-vertical': this.vertical,
|
|
38
38
|
}, "data-importance": this.computedImportance, ...this.inheritedAttributes }));
|
|
@@ -162,11 +162,11 @@ const Dropdown = /*@__PURE__*/ proxyCustomElement(class Dropdown extends HTMLEle
|
|
|
162
162
|
this.disconnectReferenceElement();
|
|
163
163
|
}
|
|
164
164
|
render() {
|
|
165
|
-
return (h(Host, { key: '
|
|
165
|
+
return (h(Host, { key: 'f8aae856bf88e8f4b42bbe9ebca7442135840e1a', "aria-labelledby": this.hostAriaLabelledBy, onKeyDown: this.boundEscape, onFocusout: this.boundFocusout, style: {
|
|
166
166
|
display: this.hostDisplay,
|
|
167
167
|
position: this.hostPosition,
|
|
168
168
|
transform: this.hostTransform,
|
|
169
|
-
} }, h("slot", { key: '
|
|
169
|
+
} }, h("slot", { key: '4f0b2d071d7236eb7c11b47f3ad61b78e1555574' })));
|
|
170
170
|
}
|
|
171
171
|
async handleFocusout(event) {
|
|
172
172
|
if (!(event instanceof FocusEvent))
|
|
@@ -40,10 +40,10 @@ const FormMessage = /*@__PURE__*/ proxyCustomElement(class FormMessage extends H
|
|
|
40
40
|
this.inheritedAttributes = inheritAriaAttributes(this.element);
|
|
41
41
|
}
|
|
42
42
|
render() {
|
|
43
|
-
return (h("span", { key: '
|
|
43
|
+
return (h("span", { key: 'ab7bccd8c944fe6f9e78b10e5528191daa4ab53d', class: {
|
|
44
44
|
'qds-form-message': true,
|
|
45
45
|
'qds-inline': this.inline,
|
|
46
|
-
}, "data-size": this.computedSize, ...this.inheritedAttributes }, h("div", { key: '
|
|
46
|
+
}, "data-size": this.computedSize, ...this.inheritedAttributes }, h("div", { key: '5035aa7a2f4c3ee1d0ec542e1fed7156b38b961f', class: "qds-icon-container", "data-size": this.computedSize }, h("div", { key: 'cb4ce6f302f655edf8544121a433e0b7cba90a08', class: "qds-icon-background", "data-size": this.computedSize, "data-status": this.status }, h("qds-icon", { key: '312158bb8a6b2c80b44bc9a8573a7175615b3244', class: "qds-icon", "data-size": this.computedSize, name: `status-${this.status}`, library: "core" }))), h("span", { key: '3bdb4d0c9b7f2be5372b531f0d0131f731fd035c', class: "qds-text", "data-status": this.computedStatus }, this.text)));
|
|
47
47
|
}
|
|
48
48
|
get element() { return this; }
|
|
49
49
|
static get style() { return QdsFormMessageStyle0; }
|
|
@@ -59,7 +59,7 @@ const InlineLink = /*@__PURE__*/ proxyCustomElement(class InlineLink extends HTM
|
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
61
|
render() {
|
|
62
|
-
return (h("a", { key: '
|
|
62
|
+
return (h("a", { key: '647e435a33996594a3f5bd330e8940f022e232c5', "aria-disabled": this.disabled.toString(), class: "qds-inline-link", "data-importance": this.computedImportance, 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", { key: 'd5d7a3888dbe9344b4833dd48bd8dfdbb15134a7' }), h("qds-icon", { key: '7b6a9fb18c93e02dd2834de8efae0ab570043d9b', class: "qds-external", library: "core", name: "external-link" })));
|
|
63
63
|
}
|
|
64
64
|
static get delegatesFocus() { return true; }
|
|
65
65
|
get element() { return this; }
|
package/components/qds-input.js
CHANGED
|
@@ -244,9 +244,9 @@ const Input = /*@__PURE__*/ proxyCustomElement(class Input extends HTMLElement {
|
|
|
244
244
|
this.selectionEnd = this.input.selectionEnd;
|
|
245
245
|
}
|
|
246
246
|
render() {
|
|
247
|
-
return (h("div", { key: '
|
|
247
|
+
return (h("div", { key: '5357bff41a786f85b7af91c4737cc04cb4c7dbdc', class: "qds-container" }, h("input", { key: '345e2958da2827a7ba09aea3edb3e003390dc655', "aria-invalid": this.invalid.toString(), autoCapitalize: this.autoCapitalize, autoComplete: this.autoComplete,
|
|
248
248
|
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
249
|
-
autoFocus: this.autoFocus, class: "qds-input", "data-size": this.computedSize, disabled: this.disabled, enterKeyHint: this.enterkeyhint, inputMode: this.inputmode, max: this.max, maxLength: this.maxLength, min: this.min, minLength: this.minLength, multiple: this.multiple, onBlur: this.onBlur, onChange: this.onChange, onFocus: this.onFocus, onInput: this.onInput, placeholder: this.placeholder, ref: this.ref, spellcheck: this.spellCheck, step: this.step, type: this.type, ...this.inheritedAttributes }), h("div", { key: '
|
|
249
|
+
autoFocus: this.autoFocus, class: "qds-input", "data-size": this.computedSize, disabled: this.disabled, enterKeyHint: this.enterkeyhint, inputMode: this.inputmode, max: this.max, maxLength: this.maxLength, min: this.min, minLength: this.minLength, multiple: this.multiple, onBlur: this.onBlur, onChange: this.onChange, onFocus: this.onFocus, onInput: this.onInput, placeholder: this.placeholder, ref: this.ref, spellcheck: this.spellCheck, step: this.step, type: this.type, ...this.inheritedAttributes }), h("div", { key: 'caf883d83a874e63c4e60e3b7df42fc0249e915f', class: "qds-focus-ring" })));
|
|
250
250
|
}
|
|
251
251
|
defineGetter(p, get) {
|
|
252
252
|
Object.defineProperty(this.element, p, { enumerable: true, get });
|
|
@@ -67,15 +67,15 @@ const ListItem = /*@__PURE__*/ proxyCustomElement(class ListItem extends HTMLEle
|
|
|
67
67
|
this.tabIndex = Number.isNaN(parsedValue) ? 0 : parsedValue;
|
|
68
68
|
}
|
|
69
69
|
render() {
|
|
70
|
-
return (h("li", { key: '
|
|
70
|
+
return (h("li", { key: 'b20795ed88464d141f847f6129715d4d5c5792d9', class: {
|
|
71
71
|
'qds-list-item': true,
|
|
72
72
|
'qds-disabled': this.disabled,
|
|
73
73
|
'qds-selected': this.selected,
|
|
74
|
-
}, ...this.inheritedAttributes }, h("button", { key: '
|
|
74
|
+
}, ...this.inheritedAttributes }, h("button", { key: 'a2cf98d90a13e708ffdfa442c20cd5d2f67d4cfa', class: {
|
|
75
75
|
'qds-button': true,
|
|
76
76
|
'qds-draggable': this.draggable,
|
|
77
77
|
'qds-selected': this.selected,
|
|
78
|
-
}, "data-size": this.computedSize, disabled: this.disabled, onBlur: this.onBlur, onFocus: this.onFocus, tabIndex: this.tabIndex, type: "button" }, this.draggable && (h("div", { class: "qds-draggable" }, h("qds-icon", { class: "qds-control-icon", library: "core", name: "draggable" }))), this.iconName !== undefined && this.iconName !== '' && (h("qds-icon", { class: "qds-icon", library: this.iconLibrary, name: this.iconName })), h("div", { key: '
|
|
78
|
+
}, "data-size": this.computedSize, disabled: this.disabled, onBlur: this.onBlur, onFocus: this.onFocus, tabIndex: this.tabIndex, type: "button" }, this.draggable && (h("div", { class: "qds-draggable" }, h("qds-icon", { class: "qds-control-icon", library: "core", name: "draggable" }))), this.iconName !== undefined && this.iconName !== '' && (h("qds-icon", { class: "qds-icon", library: this.iconLibrary, name: this.iconName })), h("div", { key: '1c11728778a78fc5ddca1725f5d63f2762e0d419', class: "qds-texts" }, h("div", { key: '6d44c2bce65143fb6f030da0c2e80676504554a7', class: "qds-text" }, this.text), this.subtext !== undefined && this.subtext !== '' && (h("div", { class: "qds-subtext" }, this.subtext)), this.kicker !== undefined && this.kicker !== '' && (h("div", { class: "qds-kicker" }, this.kicker))), this.navigation && (h("qds-icon", { class: "qds-control-icon qds-navigation", library: "core", name: "navigation" })))));
|
|
79
79
|
}
|
|
80
80
|
static get delegatesFocus() { return true; }
|
|
81
81
|
get element() { return this; }
|
|
@@ -73,11 +73,11 @@ const NavListItem = /*@__PURE__*/ proxyCustomElement(class NavListItem extends H
|
|
|
73
73
|
this.tabIndex = Number.isNaN(parsedValue) ? 0 : parsedValue;
|
|
74
74
|
}
|
|
75
75
|
render() {
|
|
76
|
-
return (h(Host, { key: '
|
|
76
|
+
return (h(Host, { key: '5d4db7d598100e8a899d8d73b26acbd296e78bc5' }, h("li", { key: '1eae3293c5408b89529799cb75b41ce67e01060c', class: {
|
|
77
77
|
'qds-nav-list-item': true,
|
|
78
78
|
'qds-disabled': this.disabled,
|
|
79
79
|
'qds-selected': this.selected,
|
|
80
|
-
}, ref: this.liRef, ...this.inheritedAttributes }, h("button", { key: '
|
|
80
|
+
}, ref: this.liRef, ...this.inheritedAttributes }, h("button", { key: '4998baf9f281e0aa3e64e5771fbede97ec19f67d', class: {
|
|
81
81
|
'qds-button': true,
|
|
82
82
|
'qds-selected': this.selected,
|
|
83
83
|
}, "data-size": this.computedSize, disabled: this.disabled, onBlur: this.onBlur, onFocus: this.onFocus, tabIndex: this.tabIndex, type: "button" }, this.iconName !== undefined && this.iconName !== '' && (h("qds-icon", { class: "qds-icon", library: this.iconLibrary, name: this.iconName })), !this.shouldCollapse && this.text && this.renderText())), this.shouldCollapse && this.text && (h("qds-tooltip", { placement: "right", ref: this.tooltipRef }, this.renderText()))));
|