@ganpatiinfo/gids-core-web 0.0.6 → 2.0.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/dist/custom-elements.json +16 -0
- package/dist/elements.css +3 -2
- package/dist/elements.css.map +1 -1
- package/dist/gids-toggle-button.d.ts +11 -0
- package/dist/gids-toggle-button.js +130 -0
- package/dist/gids-toggle-button.js.map +1 -0
- package/dist/index.css +731 -5
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -332
- package/dist/index.js.map +1 -1
- package/dist/p-C7NwBdoN.js +1227 -0
- package/dist/p-C7NwBdoN.js.map +1 -0
- package/dist/p-DXWsIVvG.js +1227 -0
- package/dist/p-DXWsIVvG.js.map +1 -0
- package/dist/p-Dl9wTOvC.js +748 -0
- package/dist/p-Dl9wTOvC.js.map +1 -0
- package/dist/types/components/gids-toggle-button/gids-toggle-button.d.ts +3 -0
- package/dist/types/components/html/GidsButton/GidsButton.d.ts +24 -0
- package/dist/types/components/html/GidsIcon/GidsIcon.d.ts +5 -0
- package/dist/types/components/html/GidsSpinner/GidsSpinner.d.ts +4 -0
- package/dist/types/components/html/_GidsSpinnerControl/GidsSpinnerControl.d.ts +6 -0
- package/dist/types/components/webComponents/GidsToggleButton/GidsToggleButton.d.ts +58 -0
- package/dist/types/components.d.ts +91 -0
- package/dist/types/index.d.ts +10 -0
- package/package.json +22 -12
|
@@ -22,6 +22,22 @@
|
|
|
22
22
|
"name": "*",
|
|
23
23
|
"package": "./components.d.ts"
|
|
24
24
|
}
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"kind": "js",
|
|
28
|
+
"name": "setGidsAssetFilePaths",
|
|
29
|
+
"declaration": {
|
|
30
|
+
"name": "setGidsAssetFilePaths",
|
|
31
|
+
"module": "src/index.ts"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"kind": "js",
|
|
36
|
+
"name": "setGidsDefaultAssetDirPath",
|
|
37
|
+
"declaration": {
|
|
38
|
+
"name": "setGidsDefaultAssetDirPath",
|
|
39
|
+
"module": "src/index.ts"
|
|
40
|
+
}
|
|
25
41
|
}
|
|
26
42
|
]
|
|
27
43
|
},
|
package/dist/elements.css
CHANGED
|
@@ -8,7 +8,7 @@ body {
|
|
|
8
8
|
letter-spacing: var(--gids-typography-paragraph-medium__letter-spacing);
|
|
9
9
|
line-height: var(--gids-typography-paragraph-medium__line-height);
|
|
10
10
|
text-transform: var(--gids-typography-paragraph-medium__text-transform, inherit);
|
|
11
|
-
font-variant: var(--gids-typography-paragraph-medium__font-variant-caps, inherit);
|
|
11
|
+
font-variant-caps: var(--gids-typography-paragraph-medium__font-variant-caps, inherit);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
h2 {
|
|
@@ -25,9 +25,10 @@ a {
|
|
|
25
25
|
a:visited {
|
|
26
26
|
color: var(--gids-color-link-visited-default);
|
|
27
27
|
}
|
|
28
|
-
a:active {
|
|
28
|
+
a:active, gids-card[clickable]:defined:is(--active, :state(active)) a[data-gids-card-primary-control] {
|
|
29
29
|
color: var(--gids-color-link-pressed);
|
|
30
30
|
}
|
|
31
|
+
|
|
31
32
|
a::before {
|
|
32
33
|
display: inline;
|
|
33
34
|
content: "";
|
package/dist/elements.css.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sourceRoot":"","sources":["../src/styles/4-elements/body.scss","../src/styles/2-tools/typography.scss","../src/styles/4-elements/headings.scss","../src/styles/2-tools/links.scss"],"names":[],"mappings":"AAEA;EACC;EACA;EACA;ECFA;EACA;EACA;EACA;EACA;EAGC;EAGD;;;ACbD;EACC;;;
|
|
1
|
+
{"version":3,"sourceRoot":"","sources":["../src/styles/4-elements/body.scss","../src/styles/2-tools/typography.scss","../src/styles/4-elements/headings.scss","../src/styles/2-tools/links.scss","../src/styles/2-tools/card.scss"],"names":[],"mappings":"AAEA;EACC;EACA;EACA;ECFA;EACA;EACA;EACA;EACA;EAGC;EAGD;;;ACbD;EACC;;;ACCD;EAEC;EAEA;EACA;EACA;EAEA;;AAEA;EACC;;ACmKC;ED1JD;;;AAWD;EACC;EACA;EAWA;EACA;EACA","file":"elements.css"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "./types/components";
|
|
2
|
+
|
|
3
|
+
interface GidsToggleButton extends Components.GidsToggleButton, HTMLElement {}
|
|
4
|
+
export const GidsToggleButton: {
|
|
5
|
+
prototype: GidsToggleButton;
|
|
6
|
+
new (): GidsToggleButton;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { h, p as proxyCustomElement, H, e as createEvent, d as getConstructedGidsStylesheet, f as Host } from './p-DXWsIVvG.js';
|
|
2
|
+
import { GidsSpinnerControlWebUtils, GidsButtonWebUtils, nonEmpty } from '@ganpatiinfo/gids-web-shared';
|
|
3
|
+
import { GidsSpinnerControlCommonUtils } from '@ganpatiinfo/gids-core-shared';
|
|
4
|
+
|
|
5
|
+
const { getGidsSpinnerControlClassNames } = GidsSpinnerControlWebUtils;
|
|
6
|
+
const { calculateStrokeDasharray, thickness, radius, centerPosition, viewBox } = GidsSpinnerControlCommonUtils;
|
|
7
|
+
const GidsSpinnerControl = ({ size, indeterminate, value, max, ...rest }) => {
|
|
8
|
+
let style = undefined;
|
|
9
|
+
if (!indeterminate) {
|
|
10
|
+
const dashArray = calculateStrokeDasharray(value, max ? max : 0);
|
|
11
|
+
style = { strokeDashArray: dashArray, strokeDashoffset: '0' };
|
|
12
|
+
}
|
|
13
|
+
return (h("svg", { class: getGidsSpinnerControlClassNames({ size, indeterminate, value }), viewBox: viewBox, ...rest },
|
|
14
|
+
h("circle", { class: "gids-spinner-control__track", cx: centerPosition, cy: centerPosition, r: radius, "stroke-width": thickness }),
|
|
15
|
+
h("circle", { style: style, class: "gids-spinner-control__progress", cx: centerPosition, cy: centerPosition, r: radius, "stroke-width": thickness })));
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const { getGidsButtonClassNames } = GidsButtonWebUtils;
|
|
19
|
+
/**
|
|
20
|
+
* Stencil functional component implementation of GIDS Button component.
|
|
21
|
+
*
|
|
22
|
+
* Only used internally by Stencil web components that need to render Buttons within their
|
|
23
|
+
* JSX templates.
|
|
24
|
+
*
|
|
25
|
+
* @internal
|
|
26
|
+
*
|
|
27
|
+
* @param props
|
|
28
|
+
* @param children
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
const GidsButton = ({ appearance, size, destructive, loading, width, leadingIcon, trailingIcon, as, disabled, class: className, forceIconOnly = false, ...rest }, children) => {
|
|
32
|
+
const Element = as || 'button';
|
|
33
|
+
const spinnerSize = size === 'lg' || size === undefined ? 'md' : size;
|
|
34
|
+
// Default to type="button" if not provided, since HTML's default is "submit"
|
|
35
|
+
if (Element === 'button' && !('type' in rest)) {
|
|
36
|
+
rest.type = 'button';
|
|
37
|
+
}
|
|
38
|
+
return (
|
|
39
|
+
// @ts-expect-error: TODO This used to work in TypeScript 4.x but not anymore
|
|
40
|
+
h(Element, { class: getGidsButtonClassNames({ appearance, size, destructive, loading, width }, forceIconOnly ||
|
|
41
|
+
(children.length === 0 &&
|
|
42
|
+
nonEmpty(leadingIcon) &&
|
|
43
|
+
!nonEmpty(trailingIcon)), className), disabled: Element === 'button' ? disabled : undefined, ...rest },
|
|
44
|
+
h("span", { class: "gids-button__content" },
|
|
45
|
+
leadingIcon,
|
|
46
|
+
children),
|
|
47
|
+
loading && (h(GidsSpinnerControl, { size: spinnerSize, indeterminate: true })),
|
|
48
|
+
trailingIcon));
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const GidsToggleButton$1 = /*@__PURE__*/ proxyCustomElement(class GidsToggleButton extends H {
|
|
52
|
+
/**
|
|
53
|
+
*
|
|
54
|
+
* Only available as a property. There is no `selected` attribute
|
|
55
|
+
*
|
|
56
|
+
* @inheritdoc
|
|
57
|
+
*/
|
|
58
|
+
get selected() {
|
|
59
|
+
return this.#selected ?? this.defaultSelected;
|
|
60
|
+
}
|
|
61
|
+
set selected(value) {
|
|
62
|
+
this.#selected = value === undefined ? undefined : Boolean(value);
|
|
63
|
+
}
|
|
64
|
+
constructor() {
|
|
65
|
+
super();
|
|
66
|
+
this.__registerHost();
|
|
67
|
+
this.__attachShadow();
|
|
68
|
+
this.select = createEvent(this, "select");
|
|
69
|
+
this._toggle = this._toggle.bind(this);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* @internal
|
|
73
|
+
*/
|
|
74
|
+
#selected;
|
|
75
|
+
connectedCallback() {
|
|
76
|
+
const constructedGidsStylesheet = getConstructedGidsStylesheet();
|
|
77
|
+
if (constructedGidsStylesheet !== undefined) {
|
|
78
|
+
this._el.shadowRoot?.adoptedStyleSheets.push(constructedGidsStylesheet);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
_toggle() {
|
|
82
|
+
const toggledValue = !this.selected;
|
|
83
|
+
this._el.selected = toggledValue;
|
|
84
|
+
this.select?.emit(toggledValue);
|
|
85
|
+
}
|
|
86
|
+
render() {
|
|
87
|
+
return (h(Host, { key: '5325aafb2311b47df024410009b368e84ae23e35' }, h("style", { key: 'bf7e5a1623ed267a5f558e2b61baea50d298cabb' }, `:host {
|
|
88
|
+
display: ${this.width === 'full' ? 'block' : 'inline-block'}
|
|
89
|
+
}`), h(GidsButton, { key: '90cb7509ac3972f45040c621bbf2850947a11c8b', appearance: this.appearance, size: this.size, width: this.width, disabled: this.disabled, onClick: this._toggle, "aria-pressed": this.selected ? 'true' : 'false', leadingIcon: h("slot", { name: "leadingIcon" }), trailingIcon: h("slot", { name: "trailingIcon" }), forceIconOnly: this._onlyHasLeadingIcon() }, h("slot", { key: '071bf6162ebc2870e7a075a45a1bf9d38b2e286f' }))));
|
|
90
|
+
}
|
|
91
|
+
_onlyHasLeadingIcon() {
|
|
92
|
+
const childNodes = this._el.childNodes;
|
|
93
|
+
if (childNodes.length === 1 &&
|
|
94
|
+
childNodes[0] instanceof window.Element &&
|
|
95
|
+
childNodes[0].slot === 'leadingIcon') {
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
get _el() { return this; }
|
|
101
|
+
}, [1, "gids-toggle-button", {
|
|
102
|
+
"disabled": [516],
|
|
103
|
+
"appearance": [513],
|
|
104
|
+
"size": [513],
|
|
105
|
+
"width": [513],
|
|
106
|
+
"defaultSelected": [516, "default-selected"],
|
|
107
|
+
"selected": [6660]
|
|
108
|
+
}]);
|
|
109
|
+
function defineCustomElement$1() {
|
|
110
|
+
if (typeof customElements === "undefined") {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const components = ["gids-toggle-button"];
|
|
114
|
+
components.forEach(tagName => { switch (tagName) {
|
|
115
|
+
case "gids-toggle-button":
|
|
116
|
+
if (!customElements.get(tagName)) {
|
|
117
|
+
customElements.define(tagName, GidsToggleButton$1);
|
|
118
|
+
}
|
|
119
|
+
break;
|
|
120
|
+
} });
|
|
121
|
+
}
|
|
122
|
+
defineCustomElement$1();
|
|
123
|
+
|
|
124
|
+
const GidsToggleButton = GidsToggleButton$1;
|
|
125
|
+
const defineCustomElement = defineCustomElement$1;
|
|
126
|
+
|
|
127
|
+
export { GidsToggleButton, defineCustomElement };
|
|
128
|
+
//# sourceMappingURL=gids-toggle-button.js.map
|
|
129
|
+
|
|
130
|
+
//# sourceMappingURL=gids-toggle-button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"gids-toggle-button.js","mappings":";;;;AAQA,MAAM,EAAE,+BAA+B,EAAE,GAAG,0BAA0B;AACtE,MAAM,EAAE,wBAAwB,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,GAC7E,6BAA6B;AAOvB,MA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AAA,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU;AACtC,QAAA,IACC,UAAU,CAAC,MAAM,KAAK,CAAC;AACvB,YAAA,UAAU,CAAC,CAAC,CAAC,YAAY,MAAM,CAAC,OAAO;YACvC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,aAAa,EACnC;AACD,YAAA,OAAO,IAAI;;AAEZ,QAAA,OAAO,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["GidsToggleButton","__stencil_proxyCustomElement","HTMLElement"],"sources":["src/components/html/_GidsSpinnerControl/GidsSpinnerControl.tsx","src/components/html/GidsButton/GidsButton.tsx","src/components/webComponents/GidsToggleButton/GidsToggleButton.tsx"],"sourcesContent":["import { h } from '@stencil/core';\nimport type { FunctionalComponent, JSXBase } from '@stencil/core/internal';\nimport { GidsSpinnerControlWebUtils } from '@ganpatiinfo/gids-web-shared';\nimport {\n\tGidsSpinnerControlCommonProps,\n\tGidsSpinnerControlCommonUtils,\n} from '@ganpatiinfo/gids-core-shared';\n\nconst { getGidsSpinnerControlClassNames } = GidsSpinnerControlWebUtils;\nconst { calculateStrokeDasharray, thickness, radius, centerPosition, viewBox } =\n\tGidsSpinnerControlCommonUtils;\n\nexport type GidsSpinnerControlProps = GidsSpinnerControlCommonProps &\n\tJSXBase.IntrinsicElements['svg'] & {\n\t\tclass?: string;\n\t};\n\nexport const GidsSpinnerControl: FunctionalComponent<\n\tGidsSpinnerControlCommonProps\n> = ({ size, indeterminate, value, max, ...rest }) => {\n\tlet style: Record<string, string> | undefined = undefined;\n\n\tif (!indeterminate) {\n\t\tconst dashArray = calculateStrokeDasharray(value, max ? max : 0);\n\t\tstyle = { strokeDashArray: dashArray, strokeDashoffset: '0' };\n\t}\n\n\treturn (\n\t\t<svg\n\t\t\tclass={getGidsSpinnerControlClassNames({ size, indeterminate, value })}\n\t\t\tviewBox={viewBox}\n\t\t\t{...rest}\n\t\t>\n\t\t\t<circle\n\t\t\t\tclass=\"gids-spinner-control__track\"\n\t\t\t\tcx={centerPosition}\n\t\t\t\tcy={centerPosition}\n\t\t\t\tr={radius}\n\t\t\t\tstroke-width={thickness}\n\t\t\t/>\n\t\t\t<circle\n\t\t\t\tstyle={style}\n\t\t\t\tclass=\"gids-spinner-control__progress\"\n\t\t\t\tcx={centerPosition}\n\t\t\t\tcy={centerPosition}\n\t\t\t\tr={radius}\n\t\t\t\tstroke-width={thickness}\n\t\t\t/>\n\t\t</svg>\n\t);\n};\n","import { h } from '@stencil/core';\nimport type { JSXBase, VNode } from '@stencil/core/internal';\nimport {\n\ttype PermittedGidsButtonElements,\n\ttype GidsButtonWebProps,\n\tGidsButtonWebUtils,\n\tnonEmpty,\n} from '@ganpatiinfo/gids-web-shared';\nimport { GidsSpinnerControl } from '../_GidsSpinnerControl/GidsSpinnerControl';\n\nconst { getGidsButtonClassNames } = GidsButtonWebUtils;\n\n/**\n * Props for the Stencil Functional Component implementation of GIDS Button.\n */\nexport type GidsButtonProps<E extends PermittedGidsButtonElements> =\n\tGidsButtonWebProps<VNode | VNode[], VNode | VNode[], E> &\n\t\tJSXBase.IntrinsicElements[E] & {\n\t\t\t/**\n\t\t\t * Whether to force the button to icon-only styling.\n\t\t\t */\n\t\t\tforceIconOnly?: boolean;\n\t\t};\n\n/**\n * Stencil functional component implementation of GIDS Button component.\n *\n * Only used internally by Stencil web components that need to render Buttons within their\n * JSX templates.\n *\n * @internal\n *\n * @param props\n * @param children\n * @returns\n */\nexport const GidsButton = <E extends PermittedGidsButtonElements = 'button'>(\n\t{\n\t\tappearance,\n\t\tsize,\n\t\tdestructive,\n\t\tloading,\n\t\twidth,\n\t\tleadingIcon,\n\t\ttrailingIcon,\n\t\tas,\n\t\tdisabled,\n\t\tclass: className,\n\t\tforceIconOnly = false,\n\t\t...rest\n\t}: GidsButtonProps<E>,\n\tchildren: VNode[],\n): VNode | VNode[] => {\n\tconst Element = as || 'button';\n\tconst spinnerSize = size === 'lg' || size === undefined ? 'md' : size;\n\n\t// Default to type=\"button\" if not provided, since HTML's default is \"submit\"\n\tif (Element === 'button' && !('type' in rest)) {\n\t\t(rest as JSXBase.IntrinsicElements['button']).type = 'button';\n\t}\n\n\treturn (\n\t\t// @ts-expect-error: TODO This used to work in TypeScript 4.x but not anymore\n\t\t<Element\n\t\t\tclass={getGidsButtonClassNames(\n\t\t\t\t{ appearance, size, destructive, loading, width },\n\t\t\t\tforceIconOnly ||\n\t\t\t\t\t(children.length === 0 &&\n\t\t\t\t\t\tnonEmpty(leadingIcon) &&\n\t\t\t\t\t\t!nonEmpty(trailingIcon)),\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\tdisabled={Element === 'button' ? disabled : undefined}\n\t\t\t{...rest}\n\t\t>\n\t\t\t<span class=\"gids-button__content\">\n\t\t\t\t{leadingIcon}\n\t\t\t\t{children}\n\t\t\t</span>\n\t\t\t{loading && (\n\t\t\t\t<GidsSpinnerControl size={spinnerSize} indeterminate></GidsSpinnerControl>\n\t\t\t)}\n\t\t\t{trailingIcon}\n\t\t</Element>\n\t);\n};\n","import {\n\th,\n\tComponent,\n\tProp,\n\tElement,\n\tHost,\n\tEvent,\n\tEventEmitter,\n} from '@stencil/core';\nimport { GidsButton } from '../../html/GidsButton/GidsButton';\nimport { getConstructedGidsStylesheet } from '../../../utils/constructedGidsStylesheet';\nimport {\n\ttype GidsButtonSize,\n\ttype GidsToggleButtonAppearance,\n\ttype GidsButtonWidth,\n} from '@ganpatiinfo/gids-core-shared';\nimport { type GidsToggleButtonWebProps } from '@ganpatiinfo/gids-web-shared';\n\n@Component({\n\ttag: 'gids-toggle-button',\n\tshadow: true,\n})\nexport class GidsToggleButton\n\timplements Omit<GidsToggleButtonWebProps, 'children'>\n{\n\t/**\n\t * @internal\n\t */\n\t@Element() private _el: HTMLGidsToggleButtonElement;\n\n\t@Event()\n\tprivate select?: EventEmitter<boolean>;\n\n\t/**\n\t *\n\t * Reflected by `disabled` property\n\t *\n\t * @inheritdoc\n\t */\n\t@Prop({\n\t\treflect: true,\n\t})\n\tdisabled?: boolean;\n\n\t/**\n\t *\n\t * Reflected by `appearance` property\n\t *\n\t * @inheritdoc\n\t */\n\t@Prop({\n\t\treflect: true,\n\t})\n\tappearance?: GidsToggleButtonAppearance;\n\n\t/**\n\t *\n\t * Reflected by `size` property\n\t *\n\t * @inheritdoc\n\t */\n\t@Prop({\n\t\treflect: true,\n\t})\n\tsize?: GidsButtonSize;\n\n\t/**\n\t *\n\t * Reflected by `width` property\n\t *\n\t * @inheritdoc\n\t */\n\t@Prop({\n\t\treflect: true,\n\t})\n\twidth?: GidsButtonWidth;\n\n\t/**\n\t *\n\t * Reflected by `defaultSelected` property\n\t *\n\t * @inheritdoc\n\t */\n\t@Prop({\n\t\treflect: true,\n\t})\n\tdefaultSelected?: boolean;\n\n\t/**\n\t *\n\t * Only available as a property. There is no `selected` attribute\n\t *\n\t * @inheritdoc\n\t */\n\t@Prop({\n\t\treflect: true,\n\t\tattribute: null,\n\t})\n\tget selected(): boolean | undefined {\n\t\treturn this.#selected ?? this.defaultSelected;\n\t}\n\tset selected(value: unknown) {\n\t\tthis.#selected = value === undefined ? undefined : Boolean(value);\n\t}\n\n\tconstructor() {\n\t\tthis._toggle = this._toggle.bind(this);\n\t}\n\n\t/**\n\t * @internal\n\t */\n\t#selected?: boolean;\n\n\tconnectedCallback() {\n\t\tconst constructedGidsStylesheet = getConstructedGidsStylesheet();\n\t\tif (constructedGidsStylesheet !== undefined) {\n\t\t\tthis._el.shadowRoot?.adoptedStyleSheets.push(constructedGidsStylesheet);\n\t\t}\n\t}\n\n\tprivate _toggle() {\n\t\tconst toggledValue = !this.selected;\n\t\tthis._el.selected = toggledValue;\n\t\tthis.select?.emit(toggledValue);\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<Host>\n\t\t\t\t<style>{`:host {\n display: ${this.width === 'full' ? 'block' : 'inline-block'}\n }`}</style>\n\t\t\t\t<GidsButton\n\t\t\t\t\tappearance={this.appearance}\n\t\t\t\t\tsize={this.size}\n\t\t\t\t\twidth={this.width}\n\t\t\t\t\tdisabled={this.disabled}\n\t\t\t\t\tonClick={this._toggle}\n\t\t\t\t\taria-pressed={this.selected ? 'true' : 'false'}\n\t\t\t\t\tleadingIcon={<slot name=\"leadingIcon\" />}\n\t\t\t\t\ttrailingIcon={<slot name=\"trailingIcon\" />}\n\t\t\t\t\tforceIconOnly={this._onlyHasLeadingIcon()}\n\t\t\t\t>\n\t\t\t\t\t<slot />\n\t\t\t\t</GidsButton>\n\t\t\t</Host>\n\t\t);\n\t}\n\n\tprivate _onlyHasLeadingIcon(): boolean {\n\t\tconst childNodes = this._el.childNodes;\n\t\tif (\n\t\t\tchildNodes.length === 1 &&\n\t\t\tchildNodes[0] instanceof window.Element &&\n\t\t\tchildNodes[0].slot === 'leadingIcon'\n\t\t) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n}\n"],"version":3}
|