@quartzds/core 1.0.0-beta.1
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/README.md +136 -0
- package/components/floating-ui.dom.esm.js +1402 -0
- package/components/floating-ui.dom.esm.js.map +1 -0
- package/components/helpers.js +174 -0
- package/components/helpers.js.map +1 -0
- package/components/icon.js +175 -0
- package/components/icon.js.map +1 -0
- package/components/index.d.ts +52 -0
- package/components/index.js +117 -0
- package/components/index.js.map +1 -0
- package/components/label.js +55 -0
- package/components/label.js.map +1 -0
- package/components/qds-button.d.ts +11 -0
- package/components/qds-button.js +148 -0
- package/components/qds-button.js.map +1 -0
- package/components/qds-checkbox.d.ts +11 -0
- package/components/qds-checkbox.js +156 -0
- package/components/qds-checkbox.js.map +1 -0
- package/components/qds-dropdown.d.ts +11 -0
- package/components/qds-dropdown.js +259 -0
- package/components/qds-dropdown.js.map +1 -0
- package/components/qds-icon.d.ts +11 -0
- package/components/qds-icon.js +13 -0
- package/components/qds-icon.js.map +1 -0
- package/components/qds-inline-link.d.ts +11 -0
- package/components/qds-inline-link.js +89 -0
- package/components/qds-inline-link.js.map +1 -0
- package/components/qds-input.d.ts +11 -0
- package/components/qds-input.js +244 -0
- package/components/qds-input.js.map +1 -0
- package/components/qds-label.d.ts +11 -0
- package/components/qds-label.js +13 -0
- package/components/qds-label.js.map +1 -0
- package/components/qds-radio.d.ts +11 -0
- package/components/qds-radio.js +109 -0
- package/components/qds-radio.js.map +1 -0
- package/components/qds-switch.d.ts +11 -0
- package/components/qds-switch.js +119 -0
- package/components/qds-switch.js.map +1 -0
- package/components/qds-title.d.ts +11 -0
- package/components/qds-title.js +94 -0
- package/components/qds-title.js.map +1 -0
- package/components/qds-tooltip.d.ts +11 -0
- package/components/qds-tooltip.js +325 -0
- package/components/qds-tooltip.js.map +1 -0
- package/dist/cjs/floating-ui.dom.esm-71fa96af.js +1410 -0
- package/dist/cjs/floating-ui.dom.esm-71fa96af.js.map +1 -0
- package/dist/cjs/helpers-0b23af3f.js +184 -0
- package/dist/cjs/helpers-0b23af3f.js.map +1 -0
- package/dist/cjs/index-f19b2823.js +2030 -0
- package/dist/cjs/index-f19b2823.js.map +1 -0
- package/dist/cjs/index.cjs.js +115 -0
- package/dist/cjs/index.cjs.js.map +1 -0
- package/dist/cjs/library-4803c801.js +62 -0
- package/dist/cjs/library-4803c801.js.map +1 -0
- package/dist/cjs/loader.cjs.js +29 -0
- package/dist/cjs/loader.cjs.js.map +1 -0
- package/dist/cjs/qds-button.cjs.entry.js +110 -0
- package/dist/cjs/qds-button.cjs.entry.js.map +1 -0
- package/dist/cjs/qds-checkbox.cjs.entry.js +116 -0
- package/dist/cjs/qds-checkbox.cjs.entry.js.map +1 -0
- package/dist/cjs/qds-dropdown.cjs.entry.js +227 -0
- package/dist/cjs/qds-dropdown.cjs.entry.js.map +1 -0
- package/dist/cjs/qds-icon.cjs.entry.js +113 -0
- package/dist/cjs/qds-icon.cjs.entry.js.map +1 -0
- package/dist/cjs/qds-inline-link.cjs.entry.js +61 -0
- package/dist/cjs/qds-inline-link.cjs.entry.js.map +1 -0
- package/dist/cjs/qds-input.cjs.entry.js +200 -0
- package/dist/cjs/qds-input.cjs.entry.js.map +1 -0
- package/dist/cjs/qds-label.cjs.entry.js +39 -0
- package/dist/cjs/qds-label.cjs.entry.js.map +1 -0
- package/dist/cjs/qds-radio.cjs.entry.js +74 -0
- package/dist/cjs/qds-radio.cjs.entry.js.map +1 -0
- package/dist/cjs/qds-switch.cjs.entry.js +79 -0
- package/dist/cjs/qds-switch.cjs.entry.js.map +1 -0
- package/dist/cjs/qds-title.cjs.entry.js +66 -0
- package/dist/cjs/qds-title.cjs.entry.js.map +1 -0
- package/dist/cjs/qds-tooltip.cjs.entry.js +284 -0
- package/dist/cjs/qds-tooltip.cjs.entry.js.map +1 -0
- package/dist/cjs/qds.cjs.js +33 -0
- package/dist/cjs/qds.cjs.js.map +1 -0
- package/dist/custom-elements.json +3976 -0
- package/dist/docs.d.ts +148 -0
- package/dist/docs.json +3918 -0
- package/dist/esm/floating-ui.dom.esm-f96ac766.js +1402 -0
- package/dist/esm/floating-ui.dom.esm-f96ac766.js.map +1 -0
- package/dist/esm/helpers-5c189a19.js +174 -0
- package/dist/esm/helpers-5c189a19.js.map +1 -0
- package/dist/esm/index-1bc8e218.js +2000 -0
- package/dist/esm/index-1bc8e218.js.map +1 -0
- package/dist/esm/index.js +106 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/library-aa6893c0.js +58 -0
- package/dist/esm/library-aa6893c0.js.map +1 -0
- package/dist/esm/loader.js +25 -0
- package/dist/esm/loader.js.map +1 -0
- package/dist/esm/polyfills/core-js.js +11 -0
- package/dist/esm/polyfills/css-shim.js +1 -0
- package/dist/esm/polyfills/dom.js +79 -0
- package/dist/esm/polyfills/es5-html-element.js +1 -0
- package/dist/esm/polyfills/index.js +34 -0
- package/dist/esm/polyfills/system.js +6 -0
- package/dist/esm/qds-button.entry.js +106 -0
- package/dist/esm/qds-button.entry.js.map +1 -0
- package/dist/esm/qds-checkbox.entry.js +112 -0
- package/dist/esm/qds-checkbox.entry.js.map +1 -0
- package/dist/esm/qds-dropdown.entry.js +223 -0
- package/dist/esm/qds-dropdown.entry.js.map +1 -0
- package/dist/esm/qds-icon.entry.js +109 -0
- package/dist/esm/qds-icon.entry.js.map +1 -0
- package/dist/esm/qds-inline-link.entry.js +57 -0
- package/dist/esm/qds-inline-link.entry.js.map +1 -0
- package/dist/esm/qds-input.entry.js +196 -0
- package/dist/esm/qds-input.entry.js.map +1 -0
- package/dist/esm/qds-label.entry.js +35 -0
- package/dist/esm/qds-label.entry.js.map +1 -0
- package/dist/esm/qds-radio.entry.js +70 -0
- package/dist/esm/qds-radio.entry.js.map +1 -0
- package/dist/esm/qds-switch.entry.js +75 -0
- package/dist/esm/qds-switch.entry.js.map +1 -0
- package/dist/esm/qds-title.entry.js +62 -0
- package/dist/esm/qds-title.entry.js.map +1 -0
- package/dist/esm/qds-tooltip.entry.js +280 -0
- package/dist/esm/qds-tooltip.entry.js.map +1 -0
- package/dist/esm/qds.js +28 -0
- package/dist/esm/qds.js.map +1 -0
- package/dist/types/components/button/button.d.ts +209 -0
- package/dist/types/components/checkbox/checkbox.d.ts +136 -0
- package/dist/types/components/create-story.d.ts +5 -0
- package/dist/types/components/dropdown/dropdown.d.ts +135 -0
- package/dist/types/components/icon/default-library.d.ts +4 -0
- package/dist/types/components/icon/icon.d.ts +31 -0
- package/dist/types/components/icon/library.d.ts +19 -0
- package/dist/types/components/icon/request.d.ts +12 -0
- package/dist/types/components/icon/system-library.d.ts +4 -0
- package/dist/types/components/inline-link/inline-link.d.ts +208 -0
- package/dist/types/components/input/input.d.ts +386 -0
- package/dist/types/components/label/label.d.ts +33 -0
- package/dist/types/components/radio/radio.d.ts +110 -0
- package/dist/types/components/switch/switch.d.ts +115 -0
- package/dist/types/components/title/title.d.ts +42 -0
- package/dist/types/components/tooltip/tooltip.d.ts +147 -0
- package/dist/types/components.d.ts +1692 -0
- package/dist/types/helpers.d.ts +49 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/qds-test.d.ts +18 -0
- package/dist/types/stencil-public-runtime.d.ts +1638 -0
- package/dist/types/utils.d.ts +65 -0
- package/dist/vscode.html-custom-data.json +947 -0
- package/hydrate/index.d.ts +218 -0
- package/hydrate/index.js +9690 -0
- package/hydrate/package.json +6 -0
- package/loader/cdn.js +7 -0
- package/loader/index.cjs.js +7 -0
- package/loader/index.d.ts +21 -0
- package/loader/index.es2017.js +7 -0
- package/loader/index.js +8 -0
- package/loader/package.json +11 -0
- package/package.json +231 -0
- package/styles/core.css +379 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"icon.js","mappings":";;;;;;;;AAAA;AAQA,MAAM,OAAO,GAAgB;EAC3B,IAAI,EAAE,SAAS;EACf,QAAQ,EAAE,CAAC,IAAI,KAAK,YAAY,CAAC,SAAS,IAAI,MAAM,CAAC;CACtD;;ACXD,M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_modules/@quartzds/generic-icons-core/dist/arrow-top-right-on-square.svg","../../node_modules/@quartzds/generic-icons-core/dist/check.svg","../../node_modules/@quartzds/generic-icons-core/dist/minus.svg","./src/components/icon/system-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":["// 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","<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.03Z\"/><path d=\"M10.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=\"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=\"M13 7.5H3.01v1H13v-1Z\"/></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 arrowTopRightOnSquare from '@quartzds/generic-icons-core/dist/arrow-top-right-on-square.svg'\nimport check from '@quartzds/generic-icons-core/dist/check.svg'\nimport minus from '@quartzds/generic-icons-core/dist/minus.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 'arrow-top-right-on-square': arrowTopRightOnSquare,\n check,\n minus,\n /* eslint-enable @typescript-eslint/naming-convention */\n}\n\nconst systemLibrary: IconLibrary = {\n name: 'system',\n resolver: (name) => icons[name] ?? '',\n}\n\nexport default systemLibrary\n","// SPDX-FileCopyrightText: © 2023 Schneider Electric\n//\n// SPDX-License-Identifier: LGPL-2.1-only\n\nimport type { Except } from 'type-fest'\n\nimport defaultLibrary from './default-library'\nimport systemLibrary from './system-library'\n\nexport type IconLibraryResolver = (name: string) => string\nexport interface IconLibrary {\n name: string\n resolver: IconLibraryResolver\n}\n\nlet registry: IconLibrary[] = [defaultLibrary, systemLibrary]\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.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\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=\"wrapper\" innerHTML={this.svg} />\n }\n}\n"],"version":3}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/* qds custom elements */
|
|
2
|
+
export { Button as QdsButton } from '../dist/types/components/button/button';
|
|
3
|
+
export { defineCustomElement as defineCustomElementQdsButton } from './qds-button';
|
|
4
|
+
export { Checkbox as QdsCheckbox } from '../dist/types/components/checkbox/checkbox';
|
|
5
|
+
export { defineCustomElement as defineCustomElementQdsCheckbox } from './qds-checkbox';
|
|
6
|
+
export { Dropdown as QdsDropdown } from '../dist/types/components/dropdown/dropdown';
|
|
7
|
+
export { defineCustomElement as defineCustomElementQdsDropdown } from './qds-dropdown';
|
|
8
|
+
export { Icon as QdsIcon } from '../dist/types/components/icon/icon';
|
|
9
|
+
export { defineCustomElement as defineCustomElementQdsIcon } from './qds-icon';
|
|
10
|
+
export { InlineLink as QdsInlineLink } from '../dist/types/components/inline-link/inline-link';
|
|
11
|
+
export { defineCustomElement as defineCustomElementQdsInlineLink } from './qds-inline-link';
|
|
12
|
+
export { Input as QdsInput } from '../dist/types/components/input/input';
|
|
13
|
+
export { defineCustomElement as defineCustomElementQdsInput } from './qds-input';
|
|
14
|
+
export { Label as QdsLabel } from '../dist/types/components/label/label';
|
|
15
|
+
export { defineCustomElement as defineCustomElementQdsLabel } from './qds-label';
|
|
16
|
+
export { Radio as QdsRadio } from '../dist/types/components/radio/radio';
|
|
17
|
+
export { defineCustomElement as defineCustomElementQdsRadio } from './qds-radio';
|
|
18
|
+
export { Switch as QdsSwitch } from '../dist/types/components/switch/switch';
|
|
19
|
+
export { defineCustomElement as defineCustomElementQdsSwitch } from './qds-switch';
|
|
20
|
+
export { Title as QdsTitle } from '../dist/types/components/title/title';
|
|
21
|
+
export { defineCustomElement as defineCustomElementQdsTitle } from './qds-title';
|
|
22
|
+
export { Tooltip as QdsTooltip } from '../dist/types/components/tooltip/tooltip';
|
|
23
|
+
export { defineCustomElement as defineCustomElementQdsTooltip } from './qds-tooltip';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Used to manually set the base path where assets can be found.
|
|
27
|
+
* If the script is used as "module", it's recommended to use "import.meta.url",
|
|
28
|
+
* such as "setAssetPath(import.meta.url)". Other options include
|
|
29
|
+
* "setAssetPath(document.currentScript.src)", or using a bundler's replace plugin to
|
|
30
|
+
* dynamically set the path at build time, such as "setAssetPath(process.env.ASSET_PATH)".
|
|
31
|
+
* But do note that this configuration depends on how your script is bundled, or lack of
|
|
32
|
+
* bundling, and where your assets can be loaded from. Additionally custom bundling
|
|
33
|
+
* will have to ensure the static assets are copied to its build directory.
|
|
34
|
+
*/
|
|
35
|
+
export declare const setAssetPath: (path: string) => void;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Used to specify a nonce value that corresponds with an application's CSP.
|
|
39
|
+
* When set, the nonce will be added to all dynamically created script and style tags at runtime.
|
|
40
|
+
* Alternatively, the nonce value can be set on a meta tag in the DOM head
|
|
41
|
+
* (<meta name="csp-nonce" content="{ nonce value here }" />) which
|
|
42
|
+
* will result in the same behavior.
|
|
43
|
+
*/
|
|
44
|
+
export declare const setNonce: (nonce: string) => void
|
|
45
|
+
|
|
46
|
+
export interface SetPlatformOptions {
|
|
47
|
+
raf?: (c: FrameRequestCallback) => number;
|
|
48
|
+
ael?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
|
|
49
|
+
rel?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
|
|
50
|
+
}
|
|
51
|
+
export declare const setPlatformOptions: (opts: SetPlatformOptions) => void;
|
|
52
|
+
export * from '../dist/types';
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* SPDX-FileCopyrightText: © 2023 Schneider Electric
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: LGPL-2.1-only
|
|
5
|
+
*/
|
|
6
|
+
export { setAssetPath, setNonce, setPlatformOptions } from '@stencil/core/internal/client';
|
|
7
|
+
export { r as registerIconLibrary, u as unregisterIconLibrary } from './icon.js';
|
|
8
|
+
export { QdsButton, defineCustomElement as defineCustomElementQdsButton } from './qds-button.js';
|
|
9
|
+
export { QdsCheckbox, defineCustomElement as defineCustomElementQdsCheckbox } from './qds-checkbox.js';
|
|
10
|
+
export { QdsDropdown, defineCustomElement as defineCustomElementQdsDropdown } from './qds-dropdown.js';
|
|
11
|
+
export { QdsIcon, defineCustomElement as defineCustomElementQdsIcon } from './qds-icon.js';
|
|
12
|
+
export { QdsInlineLink, defineCustomElement as defineCustomElementQdsInlineLink } from './qds-inline-link.js';
|
|
13
|
+
export { QdsInput, defineCustomElement as defineCustomElementQdsInput } from './qds-input.js';
|
|
14
|
+
export { QdsLabel, defineCustomElement as defineCustomElementQdsLabel } from './qds-label.js';
|
|
15
|
+
export { QdsRadio, defineCustomElement as defineCustomElementQdsRadio } from './qds-radio.js';
|
|
16
|
+
export { QdsSwitch, defineCustomElement as defineCustomElementQdsSwitch } from './qds-switch.js';
|
|
17
|
+
export { QdsTitle, defineCustomElement as defineCustomElementQdsTitle } from './qds-title.js';
|
|
18
|
+
export { QdsTooltip, defineCustomElement as defineCustomElementQdsTooltip } from './qds-tooltip.js';
|
|
19
|
+
|
|
20
|
+
// SPDX-FileCopyrightText: © 2023 Schneider Electric
|
|
21
|
+
//
|
|
22
|
+
// SPDX-License-Identifier: LGPL-2.1-only
|
|
23
|
+
const toClassList = (value) => {
|
|
24
|
+
if (value === undefined)
|
|
25
|
+
return document.documentElement.classList;
|
|
26
|
+
if (typeof value === 'string')
|
|
27
|
+
return document.querySelector(value)?.classList ?? undefined;
|
|
28
|
+
return value.classList;
|
|
29
|
+
};
|
|
30
|
+
const getVariant = (type, classList) => {
|
|
31
|
+
if (!classList)
|
|
32
|
+
return undefined;
|
|
33
|
+
const prefix = `qds-${type}-`;
|
|
34
|
+
return [...classList]
|
|
35
|
+
.find((value) => value.startsWith(prefix))
|
|
36
|
+
?.replace(prefix, '');
|
|
37
|
+
};
|
|
38
|
+
const setVariant = (type, value, element) => {
|
|
39
|
+
const classList = toClassList(element);
|
|
40
|
+
if (classList === undefined)
|
|
41
|
+
return;
|
|
42
|
+
const prefix = `qds-${type}-`;
|
|
43
|
+
const currentVariant = getVariant(type, classList);
|
|
44
|
+
if (currentVariant !== undefined)
|
|
45
|
+
classList.remove(`${prefix}${currentVariant}`);
|
|
46
|
+
classList.add(`${prefix}${value}`);
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Get the currently set platform.
|
|
50
|
+
*
|
|
51
|
+
* @param element The element where the platform will be retrieved from. Can be
|
|
52
|
+
* either:
|
|
53
|
+
*
|
|
54
|
+
* - A non-empty CSS selector string
|
|
55
|
+
* - A reference to an
|
|
56
|
+
* [`Element`](https://developer.mozilla.org/docs/Web/API/Element)
|
|
57
|
+
*
|
|
58
|
+
* By default, this is the root node of the current document.
|
|
59
|
+
*
|
|
60
|
+
* @returns The currently set platform if one is set, `undefined` otherwise.
|
|
61
|
+
*/
|
|
62
|
+
const getPlatform = (element) => getVariant('platform', toClassList(element));
|
|
63
|
+
/**
|
|
64
|
+
* Sets the current platform.
|
|
65
|
+
*
|
|
66
|
+
* The current platform represented by a `qds-platform-`-prefixed CSS class
|
|
67
|
+
* will be removed.
|
|
68
|
+
*
|
|
69
|
+
* @param platform The platform to set. Must be a non-empty value.
|
|
70
|
+
* @param element The element where the platform will be set. Can be either:
|
|
71
|
+
*
|
|
72
|
+
* - A non-empty CSS selector string
|
|
73
|
+
* - A reference to an
|
|
74
|
+
* [`Element`](https://developer.mozilla.org/docs/Web/API/Element)
|
|
75
|
+
*
|
|
76
|
+
* By default, this is the root node of the current document.
|
|
77
|
+
*/
|
|
78
|
+
const setPlatform = (platform, element) => {
|
|
79
|
+
setVariant('platform', platform, element);
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Get the currently set theme.
|
|
83
|
+
*
|
|
84
|
+
* @param element The element where the theme will be retrieved from. Can be
|
|
85
|
+
* either:
|
|
86
|
+
*
|
|
87
|
+
* - A non-empty CSS selector string
|
|
88
|
+
* - A reference to an
|
|
89
|
+
* [`Element`](https://developer.mozilla.org/docs/Web/API/Element)
|
|
90
|
+
*
|
|
91
|
+
* By default, this is the root node of the current document.
|
|
92
|
+
*
|
|
93
|
+
* @returns The currently set theme if one is set, `undefined` otherwise.
|
|
94
|
+
*/
|
|
95
|
+
const getTheme = (element) => getVariant('theme', toClassList(element));
|
|
96
|
+
/**
|
|
97
|
+
* Sets the current theme.
|
|
98
|
+
*
|
|
99
|
+
* The current theme represented by a `qds-theme-`-prefixed CSS class will be
|
|
100
|
+
* removed.
|
|
101
|
+
*
|
|
102
|
+
* @param theme The theme to set. Must be a non-empty value.
|
|
103
|
+
* @param element The element where the theme will be set. Can be either:
|
|
104
|
+
*
|
|
105
|
+
* - A non-empty CSS selector string
|
|
106
|
+
* - A reference to an
|
|
107
|
+
* [`Element`](https://developer.mozilla.org/docs/Web/API/Element)
|
|
108
|
+
*
|
|
109
|
+
* By default, this is the root node of the current document.
|
|
110
|
+
*/
|
|
111
|
+
const setTheme = (theme, element) => {
|
|
112
|
+
setVariant('theme', theme, element);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export { getPlatform, getTheme, setPlatform, setTheme };
|
|
116
|
+
|
|
117
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* SPDX-FileCopyrightText: © 2023 Schneider Electric
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: LGPL-2.1-only
|
|
5
|
+
*/
|
|
6
|
+
import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
|
|
7
|
+
import { i as inheritAriaAttributes } from './helpers.js';
|
|
8
|
+
|
|
9
|
+
const labelCss = ":host{box-sizing:border-box}:host([hidden]){display:none !important}:host([hidden]){}:host *,:host *::before,:host *::after{box-sizing:inherit}:host{display:inline-block}.label{color:var(--qds-theme-control-text-standard);display:inline-block}.required{color:var(--qds-theme-feedback-field-required);-webkit-user-select:none;user-select:none}[data-size='small']{font:var(--qds-control-small-text)}.inline[data-size='small']{margin-block:var(--qds-control-small-padding-auto-height)}[data-size='standard']{font:var(--qds-control-standard-text)}.inline[data-size='standard']{margin-block:var(--qds-control-standard-padding-auto-height)}[data-size='large']{font:var(--qds-control-large-text)}.inline[data-size='large']{margin-block:var(--qds-control-large-padding-auto-height)}";
|
|
10
|
+
|
|
11
|
+
const Label = /*@__PURE__*/ proxyCustomElement(class Label extends HTMLElement {
|
|
12
|
+
constructor() {
|
|
13
|
+
super();
|
|
14
|
+
this.__registerHost();
|
|
15
|
+
this.__attachShadow();
|
|
16
|
+
this.inheritedAttributes = {};
|
|
17
|
+
this.inline = false;
|
|
18
|
+
this.required = false;
|
|
19
|
+
this.size = 'standard';
|
|
20
|
+
this.text = undefined;
|
|
21
|
+
}
|
|
22
|
+
componentWillLoad() {
|
|
23
|
+
this.inheritedAttributes = inheritAriaAttributes(this.element);
|
|
24
|
+
}
|
|
25
|
+
render() {
|
|
26
|
+
return (h("span", { class: {
|
|
27
|
+
inline: this.inline,
|
|
28
|
+
label: true,
|
|
29
|
+
}, "data-size": this.size, ...this.inheritedAttributes }, this.required && h("span", { class: "required" }, "*"), this.text));
|
|
30
|
+
}
|
|
31
|
+
get element() { return this; }
|
|
32
|
+
static get style() { return labelCss; }
|
|
33
|
+
}, [1, "qds-label", {
|
|
34
|
+
"inline": [4],
|
|
35
|
+
"required": [4],
|
|
36
|
+
"size": [513],
|
|
37
|
+
"text": [513]
|
|
38
|
+
}]);
|
|
39
|
+
function defineCustomElement() {
|
|
40
|
+
if (typeof customElements === "undefined") {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const components = ["qds-label"];
|
|
44
|
+
components.forEach(tagName => { switch (tagName) {
|
|
45
|
+
case "qds-label":
|
|
46
|
+
if (!customElements.get(tagName)) {
|
|
47
|
+
customElements.define(tagName, Label);
|
|
48
|
+
}
|
|
49
|
+
break;
|
|
50
|
+
} });
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export { Label as L, defineCustomElement as d };
|
|
54
|
+
|
|
55
|
+
//# sourceMappingURL=label.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"label.js","mappings":";;;;;;;;AAAA,MAAM,QAAQ,GAAG,wwBAAwwB;;MCsB5wB,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,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,KAAK,EAAE,IAAI;OACZ,eACU,IAAI,CAAC,IAAI,KAEhB,IAAI,CAAC,mBAAmB,IAE3B,IAAI,CAAC,QAAQ,IAAI,YAAM,KAAK,EAAC,UAAU,QAAS,EAChD,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.label {\n color: var(--qds-theme-control-text-standard);\n display: inline-block;\n}\n\n.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 &.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 &.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 &.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 inline: this.inline,\n 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=\"required\">*</span>}\n {this.text}\n </span>\n )\n }\n}\n"],"version":3}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../dist/types/components";
|
|
2
|
+
|
|
3
|
+
interface QdsButton extends Components.QdsButton, HTMLElement {}
|
|
4
|
+
export const QdsButton: {
|
|
5
|
+
prototype: QdsButton;
|
|
6
|
+
new (): QdsButton;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* SPDX-FileCopyrightText: © 2023 Schneider Electric
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: LGPL-2.1-only
|
|
5
|
+
*/
|
|
6
|
+
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
7
|
+
import { p as pickFocusEventAttributes, i as inheritAriaAttributes } from './helpers.js';
|
|
8
|
+
import { d as defineCustomElement$2 } from './icon.js';
|
|
9
|
+
|
|
10
|
+
const buttonCss = ":host{box-sizing:border-box}:host([hidden]){display:none !important}:host([hidden]){}:host *,:host *::before,:host *::after{box-sizing:inherit}:host{display:inline-block}.button{-webkit-appearance:none;appearance:none;background-color:transparent;background-color:initial;border:none;padding-block:0;align-items:center;border-radius:var(--qds-control-border-radius);cursor:pointer;display:inline-flex;gap:var(--qds-control-button-gap-internal);justify-content:center;padding-inline:var(--qds-control-button-padding-horizontal);-webkit-print-color-adjust:exact;print-color-adjust:exact;-webkit-user-select:none;user-select:none;white-space:nowrap;width:100%}.button.icon-only{padding-inline:0}.button:link,.button:visited,area[href].button{-webkit-text-decoration:none;text-decoration:none}.button:any-link{-webkit-text-decoration:none;text-decoration:none}.button:focus-visible{outline:var(--qds-theme-focus-border) solid var(--qds-focus-border-width);outline-offset:var(--qds-focus-border-offset)}[aria-disabled='true']{opacity:var(--qds-theme-disabled);pointer-events:none}[data-size='small']{font:var(--qds-control-small-text);height:var(--qds-control-small-height)}.icon-only[data-size='small']{width:var(--qds-control-small-height)}.icon[data-size='small']{font-size:var(--qds-control-small-icon-size)}[data-size='standard']{font:var(--qds-control-standard-text);height:var(--qds-control-standard-height)}.icon-only[data-size='standard']{width:var(--qds-control-standard-height)}.icon[data-size='standard']{font-size:var(--qds-control-standard-icon-size)}[data-size='large']{font:var(--qds-control-large-text);height:var(--qds-control-large-height)}.icon-only[data-size='large']{width:var(--qds-control-large-height)}.icon[data-size='large']{font-size:var(--qds-control-large-icon-size)}[data-importance='subdued']{border:var(--qds-control-border-width) solid transparent;color:var(--qds-theme-link-default)}.icon-only[data-importance='subdued']{color:var(--qds-theme-control-text-standard)}[data-importance='subdued']:hover{border:var(--qds-control-border-width) solid var(--qds-theme-link-default)}.icon-only[data-importance='subdued']:hover{background-color:var(--qds-theme-interactive-background-hover);border:none;color:var(--qds-theme-control-text-standard)}[data-importance='subdued']:active{border:var(--qds-control-border-width) solid var(--qds-theme-link-pressed);color:var(--qds-theme-link-pressed)}.icon-only[data-importance='subdued']:active{background-color:var(--qds-theme-interactive-background-pressed);border:none;color:var(--qds-theme-control-text-standard)}[data-importance='standard']{border:var(--qds-control-border-width) solid var(--qds-theme-control-border);color:var(--qds-theme-control-text-standard)}[data-importance='standard']:hover{background-color:var(--qds-theme-interactive-background-hover)}[data-importance='standard']:active{background-color:var(--qds-theme-interactive-background-pressed)}[data-importance='emphasized']{background-color:var(--qds-theme-signature-color-default);color:var(--qds-theme-signature-color-contrast)}[data-importance='emphasized']:hover{background-color:var(--qds-theme-signature-color-hover)}[data-importance='emphasized']:active{background-color:var(--qds-theme-signature-color-pressed)}[data-importance='destructive']{background-color:var(--qds-theme-feedback-action-destructive-default);color:var(--qds-theme-feedback-action-destructive-contrast)}[data-importance='destructive']:hover{background-color:var(--qds-theme-feedback-action-destructive-hover)}[data-importance='destructive']:active{background-color:var(--qds-theme-feedback-action-destructive-pressed)}";
|
|
11
|
+
|
|
12
|
+
const Button = /*@__PURE__*/ proxyCustomElement(class Button extends HTMLElement {
|
|
13
|
+
constructor() {
|
|
14
|
+
super();
|
|
15
|
+
this.__registerHost();
|
|
16
|
+
this.__attachShadow();
|
|
17
|
+
this.blurEmitter = createEvent(this, "qdsBlur", 2);
|
|
18
|
+
this.focusEmitter = createEvent(this, "qdsFocus", 2);
|
|
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
|
+
this.onBlur = (event) => {
|
|
47
|
+
this.blurEmitter.emit(pickFocusEventAttributes(event));
|
|
48
|
+
};
|
|
49
|
+
this.onFocus = (event) => {
|
|
50
|
+
this.focusEmitter.emit(pickFocusEventAttributes(event));
|
|
51
|
+
};
|
|
52
|
+
this.iconName = undefined;
|
|
53
|
+
this.iconLibrary = 'default';
|
|
54
|
+
this.importance = 'standard';
|
|
55
|
+
this.size = 'standard';
|
|
56
|
+
this.text = undefined;
|
|
57
|
+
this.disabled = undefined;
|
|
58
|
+
this.download = undefined;
|
|
59
|
+
this.form = undefined;
|
|
60
|
+
this.formAction = undefined;
|
|
61
|
+
this.formMethod = undefined;
|
|
62
|
+
this.formNoValidate = false;
|
|
63
|
+
this.formTarget = '_self';
|
|
64
|
+
this.href = undefined;
|
|
65
|
+
this.name = undefined;
|
|
66
|
+
this.target = '_self';
|
|
67
|
+
this.type = undefined;
|
|
68
|
+
this.value = undefined;
|
|
69
|
+
}
|
|
70
|
+
get formElement() {
|
|
71
|
+
return this.form !== undefined && this.form !== ''
|
|
72
|
+
? document.querySelector(`#${this.form}`)
|
|
73
|
+
: this.element.closest('form');
|
|
74
|
+
}
|
|
75
|
+
get buttonType() {
|
|
76
|
+
if (this.type === undefined)
|
|
77
|
+
return this.formElement ? 'submit' : 'button';
|
|
78
|
+
return this.type;
|
|
79
|
+
}
|
|
80
|
+
get iconOnly() {
|
|
81
|
+
const hasIcon = this.iconName !== undefined && this.iconName !== '';
|
|
82
|
+
const hasNoLabel = this.text === undefined || this.text === '';
|
|
83
|
+
return hasIcon && hasNoLabel;
|
|
84
|
+
}
|
|
85
|
+
get computedDisabled() {
|
|
86
|
+
return this.disabled ?? false;
|
|
87
|
+
}
|
|
88
|
+
get computedTabIndex() {
|
|
89
|
+
const parsedValue = Number.parseInt(this.inheritedAttributes.tabindex, 10);
|
|
90
|
+
return Number.isNaN(parsedValue) ? 0 : parsedValue;
|
|
91
|
+
}
|
|
92
|
+
componentWillLoad() {
|
|
93
|
+
this.inheritedAttributes = inheritAriaAttributes(this.element);
|
|
94
|
+
}
|
|
95
|
+
render() {
|
|
96
|
+
const Tag = this.href === undefined ? 'button' : 'a';
|
|
97
|
+
return (h(Tag, { "aria-disabled": this.computedDisabled ? 'true' : 'false', class: {
|
|
98
|
+
button: true,
|
|
99
|
+
'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: "icon", "data-size": this.size, library: this.iconLibrary, name: this.iconName })), this.text));
|
|
101
|
+
}
|
|
102
|
+
static get delegatesFocus() { return true; }
|
|
103
|
+
get element() { return this; }
|
|
104
|
+
static get style() { return buttonCss; }
|
|
105
|
+
}, [17, "qds-button", {
|
|
106
|
+
"iconName": [513, "icon-name"],
|
|
107
|
+
"iconLibrary": [513, "icon-library"],
|
|
108
|
+
"importance": [513],
|
|
109
|
+
"size": [513],
|
|
110
|
+
"text": [1537],
|
|
111
|
+
"disabled": [1540],
|
|
112
|
+
"download": [1],
|
|
113
|
+
"form": [1],
|
|
114
|
+
"formAction": [1, "formaction"],
|
|
115
|
+
"formMethod": [1, "formmethod"],
|
|
116
|
+
"formNoValidate": [4, "formnovalidate"],
|
|
117
|
+
"formTarget": [1, "formtarget"],
|
|
118
|
+
"href": [1],
|
|
119
|
+
"name": [1],
|
|
120
|
+
"target": [1],
|
|
121
|
+
"type": [1],
|
|
122
|
+
"value": [1]
|
|
123
|
+
}]);
|
|
124
|
+
function defineCustomElement$1() {
|
|
125
|
+
if (typeof customElements === "undefined") {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const components = ["qds-button", "qds-icon"];
|
|
129
|
+
components.forEach(tagName => { switch (tagName) {
|
|
130
|
+
case "qds-button":
|
|
131
|
+
if (!customElements.get(tagName)) {
|
|
132
|
+
customElements.define(tagName, Button);
|
|
133
|
+
}
|
|
134
|
+
break;
|
|
135
|
+
case "qds-icon":
|
|
136
|
+
if (!customElements.get(tagName)) {
|
|
137
|
+
defineCustomElement$2();
|
|
138
|
+
}
|
|
139
|
+
break;
|
|
140
|
+
} });
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const QdsButton = Button;
|
|
144
|
+
const defineCustomElement = defineCustomElement$1;
|
|
145
|
+
|
|
146
|
+
export { QdsButton, defineCustomElement };
|
|
147
|
+
|
|
148
|
+
//# sourceMappingURL=qds-button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"qds-button.js","mappings":";;;;;;;;;AAAA,MAAM,SAAS,GAAG,qjHAAqjH;;MC+B1jH,MAAM;;;;;;;IA4MT,wBAAmB,GAAe,EAAE,CAAA;IA0E3B,YAAO,GAAG,CAAC,KAAiB;MAC3C,IAAI,IAAI,CAAC,gBAAgB,EAAE;QACzB,KAAK,CAAC,cAAc,EAAE,CAAA;QACtB,KAAK,CAAC,eAAe,EAAE,CAAA;QACvB,OAAM;OACP;MAED,IAAI,IAAI,CAAC,UAAU,KAAK,QAAQ,IAAI,CAAC,IAAI,CAAC,WAAW;QAAE,OAAM;MAC7D,KAAK,CAAC,cAAc,EAAE,CAAA;MAEtB,MAAM,UAAU,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;MACnD,UAAU,CAAC,IAAI,GAAG,IAAI,CAAC,UAAU,CAAA;MACjC,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS;QAAE,UAAU,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAA;MACxD,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS;QAAE,UAAU,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAA;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AAG,GAAG,SAAS,GAAG,IAAI,CAAC,IAAI,EACzC,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,GAAG,EAAE,GAAG,KAAK,GAAG,GAAG,qBAAqB,GAAG,SAAS,EACpD,IAAI,EAAE,GAAG,KAAK,GAAG,GAAG,QAAQ,GAAG,SAAS,EACxC,QAAQ,EAAE,IAAI,CAAC,gBAAgB,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,gBAAgB,EAC5D,MAAM,EAAE,GAAG,KAAK,GAAG,GAAG,IAAI,CAAC,MAAM,GAAG,SAAS,EAC7C,IAAI,EAAE,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,MAAM,eACD,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.button {\n appearance: none;\n background-color: initial;\n border: none;\n padding-block: 0;\n align-items: center;\n border-radius: var(--qds-control-border-radius);\n cursor: pointer;\n display: inline-flex;\n gap: var(--qds-control-button-gap-internal);\n justify-content: center;\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 &.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 &.icon-only {\n width: var(--qds-control-small-height);\n }\n\n &.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 &.icon-only {\n width: var(--qds-control-standard-height);\n }\n\n &.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 &.icon-only {\n width: var(--qds-control-large-height);\n }\n\n &.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 &.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 &.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 &.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 = '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](https://developer.mozilla.org/docs/Web/HTTP/Methods) used to\n * submit 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 *\n * If specified, this attribute overrides the method attribute of the button's form owner.\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 button: true,\n '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=\"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}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../dist/types/components";
|
|
2
|
+
|
|
3
|
+
interface QdsCheckbox extends Components.QdsCheckbox, HTMLElement {}
|
|
4
|
+
export const QdsCheckbox: {
|
|
5
|
+
prototype: QdsCheckbox;
|
|
6
|
+
new (): QdsCheckbox;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|