aeico-components 0.1.3 → 0.1.4
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/alert.cjs +6 -0
- package/dist/alert.cjs.map +1 -0
- package/dist/alert.js +6 -0
- package/dist/alert.js.map +1 -0
- package/dist/badge.cjs +6 -0
- package/dist/badge.cjs.map +1 -0
- package/dist/badge.js +6 -0
- package/dist/badge.js.map +1 -0
- package/dist/breadcrumb.cjs +7 -0
- package/dist/breadcrumb.cjs.map +1 -0
- package/dist/breadcrumb.js +7 -0
- package/dist/breadcrumb.js.map +1 -0
- package/dist/button-group.cjs +6 -0
- package/dist/button-group.cjs.map +1 -0
- package/dist/button-group.js +6 -0
- package/dist/button-group.js.map +1 -0
- package/dist/button.cjs +6 -0
- package/dist/button.cjs.map +1 -0
- package/dist/button.js +6 -0
- package/dist/button.js.map +1 -0
- package/dist/card.cjs +6 -0
- package/dist/card.cjs.map +1 -0
- package/dist/card.js +6 -0
- package/dist/card.js.map +1 -0
- package/dist/checkbox.cjs +6 -0
- package/dist/checkbox.cjs.map +1 -0
- package/dist/checkbox.js +6 -0
- package/dist/checkbox.js.map +1 -0
- package/dist/chunks/aeico-component.cjs +17 -0
- package/dist/chunks/aeico-component.cjs.map +1 -0
- package/dist/chunks/aeico-component.js +18 -0
- package/dist/chunks/aeico-component.js.map +1 -0
- package/dist/chunks/aeico-field.cjs +179 -0
- package/dist/chunks/aeico-field.cjs.map +1 -0
- package/dist/chunks/aeico-field.js +180 -0
- package/dist/chunks/aeico-field.js.map +1 -0
- package/dist/chunks/alert.cjs +170 -0
- package/dist/chunks/alert.cjs.map +1 -0
- package/dist/chunks/alert.js +171 -0
- package/dist/chunks/alert.js.map +1 -0
- package/dist/chunks/badge.cjs +85 -0
- package/dist/chunks/badge.cjs.map +1 -0
- package/dist/chunks/badge.js +86 -0
- package/dist/chunks/badge.js.map +1 -0
- package/dist/chunks/breadcrumb-item.cjs +261 -0
- package/dist/chunks/breadcrumb-item.cjs.map +1 -0
- package/dist/chunks/breadcrumb-item.js +262 -0
- package/dist/chunks/breadcrumb-item.js.map +1 -0
- package/dist/chunks/button-group.cjs +79 -0
- package/dist/chunks/button-group.cjs.map +1 -0
- package/dist/chunks/button-group.js +80 -0
- package/dist/chunks/button-group.js.map +1 -0
- package/dist/chunks/button.cjs +351 -0
- package/dist/chunks/button.cjs.map +1 -0
- package/dist/chunks/button.js +352 -0
- package/dist/chunks/button.js.map +1 -0
- package/dist/chunks/card.cjs +93 -0
- package/dist/chunks/card.cjs.map +1 -0
- package/dist/chunks/card.js +94 -0
- package/dist/chunks/card.js.map +1 -0
- package/dist/chunks/checkbox.cjs +73 -0
- package/dist/chunks/checkbox.cjs.map +1 -0
- package/dist/chunks/checkbox.js +74 -0
- package/dist/chunks/checkbox.js.map +1 -0
- package/dist/chunks/color.cjs +4 -0
- package/dist/chunks/color.cjs.map +1 -0
- package/dist/chunks/color.js +5 -0
- package/dist/chunks/color.js.map +1 -0
- package/dist/chunks/detail.cjs +143 -0
- package/dist/chunks/detail.cjs.map +1 -0
- package/dist/chunks/detail.js +144 -0
- package/dist/chunks/detail.js.map +1 -0
- package/dist/chunks/dialog.cjs +117 -0
- package/dist/chunks/dialog.cjs.map +1 -0
- package/dist/chunks/dialog.js +118 -0
- package/dist/chunks/dialog.js.map +1 -0
- package/dist/chunks/divider.cjs +80 -0
- package/dist/chunks/divider.cjs.map +1 -0
- package/dist/chunks/divider.js +81 -0
- package/dist/chunks/divider.js.map +1 -0
- package/dist/chunks/dropdown-button.cjs +534 -0
- package/dist/chunks/dropdown-button.cjs.map +1 -0
- package/dist/chunks/dropdown-button.js +535 -0
- package/dist/chunks/dropdown-button.js.map +1 -0
- package/dist/chunks/icon-button.cjs +35 -0
- package/dist/chunks/icon-button.cjs.map +1 -0
- package/dist/chunks/icon-button.js +36 -0
- package/dist/chunks/icon-button.js.map +1 -0
- package/dist/chunks/icon.cjs +78 -0
- package/dist/chunks/icon.cjs.map +1 -0
- package/dist/chunks/icon.js +79 -0
- package/dist/chunks/icon.js.map +1 -0
- package/dist/chunks/navbar.cjs +143 -0
- package/dist/chunks/navbar.cjs.map +1 -0
- package/dist/chunks/navbar.js +144 -0
- package/dist/chunks/navbar.js.map +1 -0
- package/dist/chunks/radio.cjs +181 -0
- package/dist/chunks/radio.cjs.map +1 -0
- package/dist/chunks/radio.js +182 -0
- package/dist/chunks/radio.js.map +1 -0
- package/dist/chunks/select.cjs +350 -0
- package/dist/chunks/select.cjs.map +1 -0
- package/dist/chunks/select.js +351 -0
- package/dist/chunks/select.js.map +1 -0
- package/dist/chunks/size.cjs +4 -0
- package/dist/chunks/size.cjs.map +1 -0
- package/dist/chunks/size.js +5 -0
- package/dist/chunks/size.js.map +1 -0
- package/dist/chunks/slider.cjs +648 -0
- package/dist/chunks/slider.cjs.map +1 -0
- package/dist/chunks/slider.js +649 -0
- package/dist/chunks/slider.js.map +1 -0
- package/dist/chunks/switch.cjs +73 -0
- package/dist/chunks/switch.cjs.map +1 -0
- package/dist/chunks/switch.js +74 -0
- package/dist/chunks/switch.js.map +1 -0
- package/dist/chunks/tab-panel.cjs +166 -0
- package/dist/chunks/tab-panel.cjs.map +1 -0
- package/dist/chunks/tab-panel.js +167 -0
- package/dist/chunks/tab-panel.js.map +1 -0
- package/dist/chunks/tag.cjs +108 -0
- package/dist/chunks/tag.cjs.map +1 -0
- package/dist/chunks/tag.js +109 -0
- package/dist/chunks/tag.js.map +1 -0
- package/dist/chunks/text-input.cjs +59 -0
- package/dist/chunks/text-input.cjs.map +1 -0
- package/dist/chunks/text-input.js +60 -0
- package/dist/chunks/text-input.js.map +1 -0
- package/dist/chunks/variables.cjs +372 -0
- package/dist/chunks/variables.cjs.map +1 -0
- package/dist/chunks/variables.js +373 -0
- package/dist/chunks/variables.js.map +1 -0
- package/dist/detail.cjs +6 -0
- package/dist/detail.cjs.map +1 -0
- package/dist/detail.js +6 -0
- package/dist/detail.js.map +1 -0
- package/dist/dialog.cjs +6 -0
- package/dist/dialog.cjs.map +1 -0
- package/dist/dialog.js +6 -0
- package/dist/dialog.js.map +1 -0
- package/dist/divider.cjs +6 -0
- package/dist/divider.cjs.map +1 -0
- package/dist/divider.js +6 -0
- package/dist/divider.js.map +1 -0
- package/dist/dropdown.cjs +7 -0
- package/dist/dropdown.cjs.map +1 -0
- package/dist/dropdown.js +7 -0
- package/dist/dropdown.js.map +1 -0
- package/dist/icon-button.cjs +6 -0
- package/dist/icon-button.cjs.map +1 -0
- package/dist/icon-button.js +6 -0
- package/dist/icon-button.js.map +1 -0
- package/dist/icon.cjs +6 -0
- package/dist/icon.cjs.map +1 -0
- package/dist/icon.js +6 -0
- package/dist/icon.js.map +1 -0
- package/dist/index.cjs +49 -4223
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +49 -4223
- package/dist/index.js.map +1 -1
- package/dist/navbar.cjs +6 -0
- package/dist/navbar.cjs.map +1 -0
- package/dist/navbar.js +6 -0
- package/dist/navbar.js.map +1 -0
- package/dist/radio-group.cjs +7 -0
- package/dist/radio-group.cjs.map +1 -0
- package/dist/radio-group.js +7 -0
- package/dist/radio-group.js.map +1 -0
- package/dist/select.cjs +99 -0
- package/dist/select.cjs.map +1 -0
- package/dist/select.js +99 -0
- package/dist/select.js.map +1 -0
- package/dist/slider.cjs +6 -0
- package/dist/slider.cjs.map +1 -0
- package/dist/slider.js +6 -0
- package/dist/slider.js.map +1 -0
- package/dist/switch.cjs +6 -0
- package/dist/switch.cjs.map +1 -0
- package/dist/switch.js +6 -0
- package/dist/switch.js.map +1 -0
- package/dist/tabs.cjs +8 -0
- package/dist/tabs.cjs.map +1 -0
- package/dist/tabs.js +8 -0
- package/dist/tabs.js.map +1 -0
- package/dist/tag.cjs +5 -0
- package/dist/tag.cjs.map +1 -0
- package/dist/tag.js +5 -0
- package/dist/tag.js.map +1 -0
- package/dist/text-input.cjs +6 -0
- package/dist/text-input.cjs.map +1 -0
- package/dist/text-input.js +6 -0
- package/dist/text-input.js.map +1 -0
- package/package.json +15 -3
- package/src/utils.ts +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button-group.cjs","sources":["../../src/button-group/button-group.ts"],"sourcesContent":["import type { InferProps, Props } from 'aeico';\nimport styleVariables from '../styles/variables.css?inline';\nimport buttonGroupStyle from '../styles/components/button-group.css?inline';\nimport AeicoComponent from '../aeico-component';\nimport { html } from 'aeico';\nimport type { ButtonColor, ButtonVariant, ButtonSize } from '../button';\nimport Button from '../button/button';\nimport DropdownButton from '../dropdown/dropdown-button';\n\n/**\n * ButtonGroup Component\n *\n * Groups multiple `ae-button` elements, propagating shared `variant`, `color`,\n * `size`, and `disabled` props to each child. Supports a `compact` mode that\n * joins buttons into a seamless connected strip (like Bootstrap's button group).\n *\n * @example\n * ```html\n * <!-- Loose group (gap between buttons) -->\n * <ae-button-group variant=\"outlined\" color=\"primary\">\n * <ae-button>One</ae-button>\n * <ae-button>Two</ae-button>\n * <ae-button>Three</ae-button>\n * </ae-button-group>\n *\n * <!-- Compact — joined strip -->\n * <ae-button-group compact color=\"primary\">\n * <ae-button>Left</ae-button>\n * <ae-button>Middle</ae-button>\n * <ae-button>Right</ae-button>\n * </ae-button-group>\n *\n * <!-- Full-width -->\n * <ae-button-group block color=\"danger\" variant=\"outlined\">\n * <ae-button>Delete</ae-button>\n * <ae-button>Archive</ae-button>\n * </ae-button-group>\n * ```\n */\nclass ButtonGroup extends AeicoComponent {\n static props: Props = {\n variant: { type: String },\n color: { type: String },\n size: { type: String },\n compact: { type: Boolean },\n block: { type: Boolean },\n disabled: { type: Boolean },\n };\n\n protected static styles = [styleVariables, buttonGroupStyle];\n\n declare variant?: ButtonVariant;\n declare color?: ButtonColor;\n declare size?: ButtonSize;\n declare compact?: boolean;\n declare block?: boolean;\n declare disabled?: boolean;\n\n private slotEl: HTMLSlotElement | null = null;\n\n connectedCallback() {\n super.connectedCallback();\n\n if (this.variant === undefined) this.variant = 'filled';\n if (this.color === undefined) this.color = 'default';\n if (this.size === undefined) this.size = 'md';\n }\n\n protected render() {\n return html(({ slot }) => {\n this.slotEl = slot({\n '@slotchange': () => this._syncChildren(),\n });\n this._syncChildren();\n });\n }\n\n private _getButtons(): Array<Button | DropdownButton> {\n if (!this.slotEl) return [];\n\n return (\n this.slotEl.assignedElements({ flatten: true }) as Array<Button | DropdownButton>\n ).filter((el) => {\n const tag = el.tagName.toLowerCase();\n return tag === 'ae-button' || tag === 'ae-dropdown-button';\n });\n }\n\n private _syncChildren() {\n const buttons = this._getButtons();\n const r = this.size === 'xs' || this.size === 'sm' ? 3 : 4;\n\n buttons.forEach((btn: Button | DropdownButton, i) => {\n btn.variant = this.variant;\n btn.color = this.color;\n btn.size = this.size;\n\n if (this.disabled) {\n btn.disabled = true;\n } else {\n btn.disabled = false;\n }\n\n if (this.compact) {\n const isFirst = i === 0;\n const isLast = i === buttons.length - 1;\n\n // Overlap adjacent borders by pulling non-first buttons left 1px\n btn.style.marginLeft = isFirst ? '' : '-1px';\n\n // Shape corners: only the outer edges of the strip keep radius\n btn.style.setProperty('--_btn-r-tl', isFirst ? `${r}px` : '0');\n btn.style.setProperty('--_btn-r-bl', isFirst ? `${r}px` : '0');\n btn.style.setProperty('--_btn-r-tr', isLast ? `${r}px` : '0');\n btn.style.setProperty('--_btn-r-br', isLast ? `${r}px` : '0');\n } else {\n btn.style.marginLeft = '';\n this._clearRadius(btn);\n }\n });\n }\n\n private _clearRadius(btn: HTMLElement) {\n btn.style.removeProperty('--_btn-r-tl');\n btn.style.removeProperty('--_btn-r-tr');\n btn.style.removeProperty('--_btn-r-br');\n btn.style.removeProperty('--_btn-r-bl');\n }\n}\n\nButtonGroup.register();\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ae-button-group': ButtonGroup;\n }\n}\n\nexport default ButtonGroup;\nexport type ButtonGroupProps = InferProps<typeof ButtonGroup>;\n"],"names":["AeicoComponent","html","styleVariables"],"mappings":";;;;;;;;AAuCA,MAAM,oBAAoBA,eAAAA,e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M,YAAY,eAAe,SAAS,GAAG,CAAC,OAAO,GAAG;AAC5D,YAAI,MAAM,YAAY,eAAe,SAAS,GAAG,CAAC,OAAO,GAAG;AAAA,MAC9D,OAAO;AACL,YAAI,MAAM,aAAa;AACvB,aAAK,aAAa,GAAG;AAAA,MACvB;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEQ,aAAa,KAAkB;AACrC,QAAI,MAAM,eAAe,aAAa;AACtC,QAAI,MAAM,eAAe,aAAa;AACtC,QAAI,MAAM,eAAe,aAAa;AACtC,QAAI,MAAM,eAAe,aAAa;AAAA,EACxC;AACF;AAxFE,cADI,aACG,SAAe;AAAA,EACpB,SAAS,EAAE,MAAM,OAAA;AAAA,EACjB,OAAO,EAAE,MAAM,OAAA;AAAA,EACf,MAAM,EAAE,MAAM,OAAA;AAAA,EACd,SAAS,EAAE,MAAM,QAAA;AAAA,EACjB,OAAO,EAAE,MAAM,QAAA;AAAA,EACf,UAAU,EAAE,MAAM,QAAA;AAAQ;AAG5B,cAVI,aAUa,UAAS,CAACC,UAAAA,gBAAgB,gBAAgB;AAiF7D,YAAY,SAAA;;"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
import { s as styleVariables } from "./variables.js";
|
|
5
|
+
import { A as AeicoComponent } from "./aeico-component.js";
|
|
6
|
+
import { html } from "aeico";
|
|
7
|
+
const buttonGroupStyle = ":host {\n display: inline-flex;\n align-items: stretch;\n gap: 8px;\n}\n\n:host([block]) {\n display: flex;\n width: 100%;\n}\n\n:host([block]) ::slotted(ae-button) {\n flex: 1;\n}\n\n:host([compact]) {\n gap: 0;\n}\n\n/* Raise hovered/focused button so its border shows above neighbours */\n:host([compact]) ::slotted(ae-button:hover),\n:host([compact]) ::slotted(ae-button:focus-within) {\n position: relative;\n z-index: 1;\n}\n";
|
|
8
|
+
class ButtonGroup extends AeicoComponent {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
__publicField(this, "slotEl", null);
|
|
12
|
+
}
|
|
13
|
+
connectedCallback() {
|
|
14
|
+
super.connectedCallback();
|
|
15
|
+
if (this.variant === void 0) this.variant = "filled";
|
|
16
|
+
if (this.color === void 0) this.color = "default";
|
|
17
|
+
if (this.size === void 0) this.size = "md";
|
|
18
|
+
}
|
|
19
|
+
render() {
|
|
20
|
+
return html(({ slot }) => {
|
|
21
|
+
this.slotEl = slot({
|
|
22
|
+
"@slotchange": () => this._syncChildren()
|
|
23
|
+
});
|
|
24
|
+
this._syncChildren();
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
_getButtons() {
|
|
28
|
+
if (!this.slotEl) return [];
|
|
29
|
+
return this.slotEl.assignedElements({ flatten: true }).filter((el) => {
|
|
30
|
+
const tag = el.tagName.toLowerCase();
|
|
31
|
+
return tag === "ae-button" || tag === "ae-dropdown-button";
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
_syncChildren() {
|
|
35
|
+
const buttons = this._getButtons();
|
|
36
|
+
const r = this.size === "xs" || this.size === "sm" ? 3 : 4;
|
|
37
|
+
buttons.forEach((btn, i) => {
|
|
38
|
+
btn.variant = this.variant;
|
|
39
|
+
btn.color = this.color;
|
|
40
|
+
btn.size = this.size;
|
|
41
|
+
if (this.disabled) {
|
|
42
|
+
btn.disabled = true;
|
|
43
|
+
} else {
|
|
44
|
+
btn.disabled = false;
|
|
45
|
+
}
|
|
46
|
+
if (this.compact) {
|
|
47
|
+
const isFirst = i === 0;
|
|
48
|
+
const isLast = i === buttons.length - 1;
|
|
49
|
+
btn.style.marginLeft = isFirst ? "" : "-1px";
|
|
50
|
+
btn.style.setProperty("--_btn-r-tl", isFirst ? `${r}px` : "0");
|
|
51
|
+
btn.style.setProperty("--_btn-r-bl", isFirst ? `${r}px` : "0");
|
|
52
|
+
btn.style.setProperty("--_btn-r-tr", isLast ? `${r}px` : "0");
|
|
53
|
+
btn.style.setProperty("--_btn-r-br", isLast ? `${r}px` : "0");
|
|
54
|
+
} else {
|
|
55
|
+
btn.style.marginLeft = "";
|
|
56
|
+
this._clearRadius(btn);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
_clearRadius(btn) {
|
|
61
|
+
btn.style.removeProperty("--_btn-r-tl");
|
|
62
|
+
btn.style.removeProperty("--_btn-r-tr");
|
|
63
|
+
btn.style.removeProperty("--_btn-r-br");
|
|
64
|
+
btn.style.removeProperty("--_btn-r-bl");
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
__publicField(ButtonGroup, "props", {
|
|
68
|
+
variant: { type: String },
|
|
69
|
+
color: { type: String },
|
|
70
|
+
size: { type: String },
|
|
71
|
+
compact: { type: Boolean },
|
|
72
|
+
block: { type: Boolean },
|
|
73
|
+
disabled: { type: Boolean }
|
|
74
|
+
});
|
|
75
|
+
__publicField(ButtonGroup, "styles", [styleVariables, buttonGroupStyle]);
|
|
76
|
+
ButtonGroup.register();
|
|
77
|
+
export {
|
|
78
|
+
ButtonGroup as B
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=button-group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button-group.js","sources":["../../src/button-group/button-group.ts"],"sourcesContent":["import type { InferProps, Props } from 'aeico';\nimport styleVariables from '../styles/variables.css?inline';\nimport buttonGroupStyle from '../styles/components/button-group.css?inline';\nimport AeicoComponent from '../aeico-component';\nimport { html } from 'aeico';\nimport type { ButtonColor, ButtonVariant, ButtonSize } from '../button';\nimport Button from '../button/button';\nimport DropdownButton from '../dropdown/dropdown-button';\n\n/**\n * ButtonGroup Component\n *\n * Groups multiple `ae-button` elements, propagating shared `variant`, `color`,\n * `size`, and `disabled` props to each child. Supports a `compact` mode that\n * joins buttons into a seamless connected strip (like Bootstrap's button group).\n *\n * @example\n * ```html\n * <!-- Loose group (gap between buttons) -->\n * <ae-button-group variant=\"outlined\" color=\"primary\">\n * <ae-button>One</ae-button>\n * <ae-button>Two</ae-button>\n * <ae-button>Three</ae-button>\n * </ae-button-group>\n *\n * <!-- Compact — joined strip -->\n * <ae-button-group compact color=\"primary\">\n * <ae-button>Left</ae-button>\n * <ae-button>Middle</ae-button>\n * <ae-button>Right</ae-button>\n * </ae-button-group>\n *\n * <!-- Full-width -->\n * <ae-button-group block color=\"danger\" variant=\"outlined\">\n * <ae-button>Delete</ae-button>\n * <ae-button>Archive</ae-button>\n * </ae-button-group>\n * ```\n */\nclass ButtonGroup extends AeicoComponent {\n static props: Props = {\n variant: { type: String },\n color: { type: String },\n size: { type: String },\n compact: { type: Boolean },\n block: { type: Boolean },\n disabled: { type: Boolean },\n };\n\n protected static styles = [styleVariables, buttonGroupStyle];\n\n declare variant?: ButtonVariant;\n declare color?: ButtonColor;\n declare size?: ButtonSize;\n declare compact?: boolean;\n declare block?: boolean;\n declare disabled?: boolean;\n\n private slotEl: HTMLSlotElement | null = null;\n\n connectedCallback() {\n super.connectedCallback();\n\n if (this.variant === undefined) this.variant = 'filled';\n if (this.color === undefined) this.color = 'default';\n if (this.size === undefined) this.size = 'md';\n }\n\n protected render() {\n return html(({ slot }) => {\n this.slotEl = slot({\n '@slotchange': () => this._syncChildren(),\n });\n this._syncChildren();\n });\n }\n\n private _getButtons(): Array<Button | DropdownButton> {\n if (!this.slotEl) return [];\n\n return (\n this.slotEl.assignedElements({ flatten: true }) as Array<Button | DropdownButton>\n ).filter((el) => {\n const tag = el.tagName.toLowerCase();\n return tag === 'ae-button' || tag === 'ae-dropdown-button';\n });\n }\n\n private _syncChildren() {\n const buttons = this._getButtons();\n const r = this.size === 'xs' || this.size === 'sm' ? 3 : 4;\n\n buttons.forEach((btn: Button | DropdownButton, i) => {\n btn.variant = this.variant;\n btn.color = this.color;\n btn.size = this.size;\n\n if (this.disabled) {\n btn.disabled = true;\n } else {\n btn.disabled = false;\n }\n\n if (this.compact) {\n const isFirst = i === 0;\n const isLast = i === buttons.length - 1;\n\n // Overlap adjacent borders by pulling non-first buttons left 1px\n btn.style.marginLeft = isFirst ? '' : '-1px';\n\n // Shape corners: only the outer edges of the strip keep radius\n btn.style.setProperty('--_btn-r-tl', isFirst ? `${r}px` : '0');\n btn.style.setProperty('--_btn-r-bl', isFirst ? `${r}px` : '0');\n btn.style.setProperty('--_btn-r-tr', isLast ? `${r}px` : '0');\n btn.style.setProperty('--_btn-r-br', isLast ? `${r}px` : '0');\n } else {\n btn.style.marginLeft = '';\n this._clearRadius(btn);\n }\n });\n }\n\n private _clearRadius(btn: HTMLElement) {\n btn.style.removeProperty('--_btn-r-tl');\n btn.style.removeProperty('--_btn-r-tr');\n btn.style.removeProperty('--_btn-r-br');\n btn.style.removeProperty('--_btn-r-bl');\n }\n}\n\nButtonGroup.register();\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ae-button-group': ButtonGroup;\n }\n}\n\nexport default ButtonGroup;\nexport type ButtonGroupProps = InferProps<typeof ButtonGroup>;\n"],"names":[],"mappings":";;;;;;;AAuCA,MAAM,oBAAoB,eAAe;AAAA,EAAzC;AAAA;AAmBU,kCAAiC;AAAA;AAAA,EAEzC,oBAAoB;AAClB,UAAM,kBAAA;AAEN,QAAI,KAAK,YAAY,OAAW,MAAK,UAAU;AAC/C,QAAI,KAAK,UAAU,OAAW,MAAK,QAAQ;AAC3C,QAAI,KAAK,SAAS,OAAW,MAAK,OAAO;AAAA,EAC3C;AAAA,EAEU,SAAS;AACjB,WAAO,KAAK,CAAC,EAAE,WAAW;AACxB,WAAK,SAAS,KAAK;AAAA,QACjB,eAAe,MAAM,KAAK,cAAA;AAAA,MAAc,CACzC;AACD,WAAK,cAAA;AAAA,IACP,CAAC;AAAA,EACH;AAAA,EAEQ,cAA8C;AACpD,QAAI,CAAC,KAAK,OA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M,OAAA;AAAA,EACf,MAAM,EAAE,MAAM,OAAA;AAAA,EACd,SAAS,EAAE,MAAM,QAAA;AAAA,EACjB,OAAO,EAAE,MAAM,QAAA;AAAA,EACf,UAAU,EAAE,MAAM,QAAA;AAAQ;AAG5B,cAVI,aAUa,UAAS,CAAC,gBAAgB,gBAAgB;AAiF7D,YAAY,SAAA;"}
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const variables = require("./variables.cjs");
|
|
3
|
+
const size = require("./size.cjs");
|
|
4
|
+
const color = require("./color.cjs");
|
|
5
|
+
const aeicoComponent = require("./aeico-component.cjs");
|
|
6
|
+
const aeico = require("aeico");
|
|
7
|
+
const buttonStyle = `:host {
|
|
8
|
+
display: inline-block;
|
|
9
|
+
--btn-solid-bg: var(--color-solid);
|
|
10
|
+
--btn-solid-bg-hover: var(--color-solid-hover);
|
|
11
|
+
--btn-solid-bg-active: var(--color-solid-active);
|
|
12
|
+
--btn-solid-color: var(--color-on-solid);
|
|
13
|
+
--btn-solid-color-hover: var(--color-on-solid-hover);
|
|
14
|
+
--btn-border: var(--color-border);
|
|
15
|
+
--btn-border-hover: var(--color-border-hover);
|
|
16
|
+
--btn-accent: var(--color-accent);
|
|
17
|
+
--btn-accent-hover: var(--color-accent-hover);
|
|
18
|
+
--btn-subtle-bg: var(--color-subtle);
|
|
19
|
+
--btn-subtle-bg-hover: var(--color-subtle-hover);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
button {
|
|
23
|
+
display: inline-flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
justify-content: center;
|
|
26
|
+
gap: 6px;
|
|
27
|
+
font-family: inherit;
|
|
28
|
+
font-weight: 400;
|
|
29
|
+
text-align: center;
|
|
30
|
+
white-space: nowrap;
|
|
31
|
+
vertical-align: middle;
|
|
32
|
+
user-select: none;
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
transition: all 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
|
|
35
|
+
outline: none;
|
|
36
|
+
position: relative;
|
|
37
|
+
padding: 0.429em 1.071em;
|
|
38
|
+
font-size: 1em;
|
|
39
|
+
line-height: 1.5;
|
|
40
|
+
border-radius: var(--_btn-r-tl, 4px) var(--_btn-r-tr, 4px) var(--_btn-r-br, 4px) var(--_btn-r-bl, 4px);
|
|
41
|
+
min-width: 4.571em;
|
|
42
|
+
height: 2.286em;
|
|
43
|
+
width: 100%;
|
|
44
|
+
|
|
45
|
+
background: var(--btn-solid-bg);
|
|
46
|
+
border: 1px solid var(--btn-solid-bg);
|
|
47
|
+
color: var(--btn-solid-color);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
button:focus { outline: none; }
|
|
51
|
+
button:active { transform: translateY(1px); }
|
|
52
|
+
|
|
53
|
+
button:hover:not(:disabled) {
|
|
54
|
+
background: var(--btn-solid-bg-hover);
|
|
55
|
+
border-color: var(--btn-border-hover);
|
|
56
|
+
color: var(--btn-solid-color-hover, var(--btn-solid-color));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
button:active:not(:disabled) { background: var(--btn-solid-bg-active); }
|
|
60
|
+
|
|
61
|
+
button:disabled {
|
|
62
|
+
opacity: 0.5;
|
|
63
|
+
cursor: not-allowed;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
:host([size="xs"]) button { border-radius: var(--_btn-r-tl, 3px) var(--_btn-r-tr, 3px) var(--_btn-r-br, 3px) var(--_btn-r-bl, 3px); }
|
|
67
|
+
:host([size="sm"]) button { border-radius: var(--_btn-r-tl, 3px) var(--_btn-r-tr, 3px) var(--_btn-r-br, 3px) var(--_btn-r-bl, 3px); }
|
|
68
|
+
|
|
69
|
+
/* --- Variants --- */
|
|
70
|
+
|
|
71
|
+
:host([variant="outlined"]) button {
|
|
72
|
+
background: transparent;
|
|
73
|
+
border-color: var(--btn-border);
|
|
74
|
+
color: var(--btn-accent);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
:host([variant="outlined"]) button:hover:not(:disabled) {
|
|
78
|
+
background: var(--btn-subtle-bg);
|
|
79
|
+
border-color: var(--btn-border-hover);
|
|
80
|
+
color: var(--btn-accent-hover);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
:host([variant="outlined"]) button:active:not(:disabled) {
|
|
84
|
+
background: var(--btn-subtle-bg-hover);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
:host([variant="subtle"]) button {
|
|
88
|
+
background: var(--btn-subtle-bg);
|
|
89
|
+
border-color: transparent;
|
|
90
|
+
color: var(--btn-accent);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
:host([variant="subtle"]) button:hover:not(:disabled) {
|
|
94
|
+
background: var(--btn-subtle-bg-hover);
|
|
95
|
+
color: var(--btn-accent-hover);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
:host([variant="subtle"]) button:active:not(:disabled) {
|
|
99
|
+
background: var(--btn-subtle-bg-hover);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
:host([variant="faint"]) button {
|
|
103
|
+
background: var(--btn-subtle-bg);
|
|
104
|
+
border-color: var(--btn-border);
|
|
105
|
+
color: var(--btn-accent);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
:host([variant="faint"]) button:hover:not(:disabled) {
|
|
109
|
+
background: var(--btn-subtle-bg-hover);
|
|
110
|
+
border-color: var(--btn-border-hover);
|
|
111
|
+
color: var(--btn-accent-hover);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
:host([variant="faint"]) button:active:not(:disabled) {
|
|
115
|
+
background: var(--btn-subtle-bg-hover);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
:host([variant="text"]) button {
|
|
119
|
+
background: transparent;
|
|
120
|
+
border-color: transparent;
|
|
121
|
+
color: var(--btn-accent);
|
|
122
|
+
min-width: auto;
|
|
123
|
+
padding-left: 4px;
|
|
124
|
+
padding-right: 4px;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
:host([variant="text"]) button:hover:not(:disabled) {
|
|
128
|
+
background: var(--btn-subtle-bg);
|
|
129
|
+
color: var(--btn-accent-hover);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
:host([variant="text"]) button:active:not(:disabled) {
|
|
133
|
+
background: var(--btn-subtle-bg-hover);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/* Icon-only: single ae-icon child → square compact layout */
|
|
137
|
+
:host([icon-only]) {
|
|
138
|
+
display: inline-flex;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
:host([icon-only]:not([size])) {
|
|
142
|
+
font-size: var(--size-m);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
:host([icon-only]) button {
|
|
146
|
+
padding: 0;
|
|
147
|
+
min-width: auto;
|
|
148
|
+
width: 2.286em;
|
|
149
|
+
height: 2.286em;
|
|
150
|
+
line-height: 1;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
:host([icon-only]) ::slotted(ae-icon) {
|
|
154
|
+
font-size: 1.5em;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
:host([active]) button {
|
|
158
|
+
background: var(--btn-solid-bg-active);
|
|
159
|
+
border-color: var(--btn-border-hover);
|
|
160
|
+
color: var(--btn-solid-color-hover, var(--btn-solid-color));
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.btn-icon {
|
|
164
|
+
padding: 0;
|
|
165
|
+
min-width: auto;
|
|
166
|
+
width: 2.286em;
|
|
167
|
+
height: 2.286em;
|
|
168
|
+
display: inline-flex;
|
|
169
|
+
align-items: center;
|
|
170
|
+
justify-content: center;
|
|
171
|
+
border-radius: 4px;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.btn-icon.btn-lg {
|
|
175
|
+
width: 2.857em;
|
|
176
|
+
height: 2.857em;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.btn-circle {
|
|
180
|
+
border-radius: 50%;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
:host([block]) {
|
|
184
|
+
display: block;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
button.btn-loading {
|
|
188
|
+
position: relative;
|
|
189
|
+
pointer-events: none;
|
|
190
|
+
color: transparent;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
button.btn-loading::before {
|
|
194
|
+
content: '';
|
|
195
|
+
position: absolute;
|
|
196
|
+
width: 1em;
|
|
197
|
+
height: 1em;
|
|
198
|
+
border: 2px solid currentColor;
|
|
199
|
+
border-top-color: transparent;
|
|
200
|
+
border-radius: 50%;
|
|
201
|
+
animation: btn-spin 0.6s linear infinite;
|
|
202
|
+
color: currentColor;
|
|
203
|
+
opacity: 0.8;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
@keyframes btn-spin {
|
|
207
|
+
to {
|
|
208
|
+
transform: rotate(360deg);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.btn-icon-left {
|
|
213
|
+
margin-right: -2px;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.btn-icon-right {
|
|
217
|
+
margin-left: -2px;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
`;
|
|
221
|
+
var __create = Object.create;
|
|
222
|
+
var __defProp = Object.defineProperty;
|
|
223
|
+
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
|
|
224
|
+
var __typeError = (msg) => {
|
|
225
|
+
throw TypeError(msg);
|
|
226
|
+
};
|
|
227
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
228
|
+
var __decoratorStart = (base) => [, , , __create((base == null ? void 0 : base[__knownSymbol("metadata")]) ?? null)];
|
|
229
|
+
var __decoratorStrings = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"];
|
|
230
|
+
var __expectFn = (fn) => fn !== void 0 && typeof fn !== "function" ? __typeError("Function expected") : fn;
|
|
231
|
+
var __decoratorContext = (kind, name, done, metadata, fns) => ({ kind: __decoratorStrings[kind], name, metadata, addInitializer: (fn) => done._ ? __typeError("Already initialized") : fns.push(__expectFn(fn || null)) });
|
|
232
|
+
var __decoratorMetadata = (array, target) => __defNormalProp(target, __knownSymbol("metadata"), array[3]);
|
|
233
|
+
var __runInitializers = (array, flags, self, value) => {
|
|
234
|
+
for (var i = 0, fns = array[flags >> 1], n = fns && fns.length; i < n; i++) flags & 1 ? fns[i].call(self) : value = fns[i].call(self, value);
|
|
235
|
+
return value;
|
|
236
|
+
};
|
|
237
|
+
var __decorateElement = (array, flags, name, decorators, target, extra) => {
|
|
238
|
+
var it, done, ctx, access, k = flags & 7, s = false, p = false;
|
|
239
|
+
var j = array.length + 1;
|
|
240
|
+
var initializers = array[j - 1] = [], extraInitializers = array[j] || (array[j] = []);
|
|
241
|
+
target = target.prototype, k < 5;
|
|
242
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
243
|
+
ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers);
|
|
244
|
+
{
|
|
245
|
+
ctx.static = s, ctx.private = p, access = ctx.access = { has: (x) => name in x };
|
|
246
|
+
access.get = (x) => x[name];
|
|
247
|
+
access.set = (x, y) => x[name] = y;
|
|
248
|
+
}
|
|
249
|
+
it = (0, decorators[i])(void 0, ctx), done._ = 1;
|
|
250
|
+
__expectFn(it) && initializers.unshift(it);
|
|
251
|
+
}
|
|
252
|
+
return target;
|
|
253
|
+
};
|
|
254
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
255
|
+
var _block_dec, _active_dec, _type_dec, _disabled_dec, _size_dec, _variant_dec, _color_dec, _a, _init;
|
|
256
|
+
class Button extends (_a = aeicoComponent.AeicoComponent, _color_dec = [aeico.prop({ type: String })], _variant_dec = [aeico.prop({ type: String })], _size_dec = [aeico.prop({ type: String })], _disabled_dec = [aeico.prop({ type: Boolean })], _type_dec = [aeico.prop({ type: String })], _active_dec = [aeico.prop({ type: Boolean })], _block_dec = [aeico.prop({ type: Boolean })], _a) {
|
|
257
|
+
constructor() {
|
|
258
|
+
super(...arguments);
|
|
259
|
+
__publicField(this, "color", __runInitializers(_init, 8, this)), __runInitializers(_init, 11, this);
|
|
260
|
+
__publicField(this, "variant", __runInitializers(_init, 12, this)), __runInitializers(_init, 15, this);
|
|
261
|
+
__publicField(this, "size", __runInitializers(_init, 16, this)), __runInitializers(_init, 19, this);
|
|
262
|
+
__publicField(this, "disabled", __runInitializers(_init, 20, this)), __runInitializers(_init, 23, this);
|
|
263
|
+
__publicField(this, "type", __runInitializers(_init, 24, this)), __runInitializers(_init, 27, this);
|
|
264
|
+
__publicField(this, "active", __runInitializers(_init, 28, this)), __runInitializers(_init, 31, this);
|
|
265
|
+
__publicField(this, "block", __runInitializers(_init, 32, this)), __runInitializers(_init, 35, this);
|
|
266
|
+
__publicField(this, "buttonElement", null);
|
|
267
|
+
__publicField(this, "_autoAriaLabel", false);
|
|
268
|
+
__publicField(this, "_handleSlotChange", () => {
|
|
269
|
+
var _a2;
|
|
270
|
+
const slot = (_a2 = this.shadowRoot) == null ? void 0 : _a2.querySelector("slot:not([name])");
|
|
271
|
+
const nodes = (slot == null ? void 0 : slot.assignedNodes()) ?? [];
|
|
272
|
+
const elements = nodes.filter((n) => n.nodeType === Node.ELEMENT_NODE);
|
|
273
|
+
const hasText = nodes.some(
|
|
274
|
+
(n) => n.nodeType === Node.TEXT_NODE && n.textContent.trim() !== ""
|
|
275
|
+
);
|
|
276
|
+
const isIconOnly = !hasText && elements.length === 1 && elements[0].tagName.toLowerCase() === "ae-icon";
|
|
277
|
+
if (isIconOnly) {
|
|
278
|
+
this.setAttribute("icon-only", "");
|
|
279
|
+
if (!this.hasAttribute("aria-label") || this._autoAriaLabel) {
|
|
280
|
+
this.setAttribute("aria-label", elements[0].getAttribute("name") ?? "");
|
|
281
|
+
this._autoAriaLabel = true;
|
|
282
|
+
}
|
|
283
|
+
} else {
|
|
284
|
+
this.removeAttribute("icon-only");
|
|
285
|
+
if (this._autoAriaLabel) {
|
|
286
|
+
this.removeAttribute("aria-label");
|
|
287
|
+
this._autoAriaLabel = false;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
onMounted() {
|
|
293
|
+
var _a2;
|
|
294
|
+
const slot = (_a2 = this.shadowRoot) == null ? void 0 : _a2.querySelector("slot:not([name])");
|
|
295
|
+
if (slot) this.listen(slot, "slotchange", this._handleSlotChange);
|
|
296
|
+
this._handleSlotChange();
|
|
297
|
+
}
|
|
298
|
+
render() {
|
|
299
|
+
return aeico.html(({ button, slot }) => {
|
|
300
|
+
this.buttonElement = button(
|
|
301
|
+
{
|
|
302
|
+
type: this.type || "button",
|
|
303
|
+
disabled: this.disabled,
|
|
304
|
+
part: "button",
|
|
305
|
+
"aria-pressed": this.active,
|
|
306
|
+
"aria-disabled": this.disabled
|
|
307
|
+
},
|
|
308
|
+
() => {
|
|
309
|
+
slot();
|
|
310
|
+
}
|
|
311
|
+
);
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Programmatically click the button
|
|
316
|
+
*/
|
|
317
|
+
click() {
|
|
318
|
+
if (!this.disabled && this.buttonElement) {
|
|
319
|
+
this.buttonElement.click();
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Focus the button
|
|
324
|
+
*/
|
|
325
|
+
focus() {
|
|
326
|
+
if (this.buttonElement) {
|
|
327
|
+
this.buttonElement.focus();
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Blur the button
|
|
332
|
+
*/
|
|
333
|
+
blur() {
|
|
334
|
+
if (this.buttonElement) {
|
|
335
|
+
this.buttonElement.blur();
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
_init = __decoratorStart(_a);
|
|
340
|
+
__decorateElement(_init, 5, "color", _color_dec, Button);
|
|
341
|
+
__decorateElement(_init, 5, "variant", _variant_dec, Button);
|
|
342
|
+
__decorateElement(_init, 5, "size", _size_dec, Button);
|
|
343
|
+
__decorateElement(_init, 5, "disabled", _disabled_dec, Button);
|
|
344
|
+
__decorateElement(_init, 5, "type", _type_dec, Button);
|
|
345
|
+
__decorateElement(_init, 5, "active", _active_dec, Button);
|
|
346
|
+
__decorateElement(_init, 5, "block", _block_dec, Button);
|
|
347
|
+
__decoratorMetadata(_init, Button);
|
|
348
|
+
__publicField(Button, "styles", [variables.styleVariables, size.sizeCSS, color.colorCSS, buttonStyle]);
|
|
349
|
+
Button.register();
|
|
350
|
+
exports.Button = Button;
|
|
351
|
+
//# sourceMappingURL=button.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button.cjs","sources":["../../src/button/button.ts"],"sourcesContent":["import type { InferProps } from 'aeico';\nimport styleVariables from '../styles/variables.css?inline';\nimport sizeCSS from '../styles/size.css?inline';\nimport colorCSS from '../styles/color.css?inline';\nimport buttonStyle from '../styles/components/button.css?inline';\nimport AeicoComponent from '../aeico-component';\nimport { html } from 'aeico';\nimport { ButtonColor, ButtonSize, ButtonVariant } from './defines';\nimport { prop } from 'aeico';\n\n/**\n * Button Component\n *\n * A customizable button component with multiple variants and sizes.\n * Supports theme and internationalization through mixins.\n *\n * @example\n * ```typescript\n * // Using the static create method\n * const button = Button.create({\n * variant: 'primary',\n * size: 'md'\n * })\n * ```\n *\n * @example\n * ```html\n * <!-- Using as Web Component -->\n * <ae-button variant=\"primary\" size=\"md\">Save</ae-button>\n * <ae-button variant=\"danger\" size=\"sm\">Delete</ae-button>\n * <ae-button variant=\"subtle\">Cancel</ae-button>\n * ```\n */\nclass Button extends AeicoComponent {\n protected static styles = [styleVariables, sizeCSS, colorCSS, buttonStyle];\n\n @prop({ type: String })\n color?: ButtonColor;\n\n @prop({ type: String })\n variant?: ButtonVariant;\n\n @prop({ type: String })\n size?: ButtonSize;\n\n @prop({ type: Boolean })\n disabled?: boolean;\n\n @prop({ type: String })\n type?: 'button' | 'submit' | 'reset';\n\n @prop({ type: Boolean })\n active?: boolean;\n\n @prop({ type: Boolean })\n block?: boolean;\n\n private buttonElement: HTMLButtonElement | null = null;\n private _autoAriaLabel = false;\n\n protected onMounted() {\n const slot = this.shadowRoot?.querySelector('slot:not([name])');\n if (slot) this.listen(slot, 'slotchange', this._handleSlotChange);\n this._handleSlotChange();\n }\n\n private _handleSlotChange = () => {\n const slot = this.shadowRoot?.querySelector('slot:not([name])') as HTMLSlotElement | null;\n const nodes = slot?.assignedNodes() ?? [];\n // Icon-only: exactly one element (ae-icon) and no meaningful text nodes\n const elements = nodes.filter((n): n is Element => n.nodeType === Node.ELEMENT_NODE);\n const hasText = nodes.some(\n (n) => n.nodeType === Node.TEXT_NODE && n.textContent!.trim() !== '',\n );\n const isIconOnly =\n !hasText && elements.length === 1 && elements[0].tagName.toLowerCase() === 'ae-icon';\n\n if (isIconOnly) {\n this.setAttribute('icon-only', '');\n if (!this.hasAttribute('aria-label') || this._autoAriaLabel) {\n this.setAttribute('aria-label', elements[0].getAttribute('name') ?? '');\n this._autoAriaLabel = true;\n }\n } else {\n this.removeAttribute('icon-only');\n if (this._autoAriaLabel) {\n this.removeAttribute('aria-label');\n this._autoAriaLabel = false;\n }\n }\n };\n\n protected render() {\n return html(({ button, slot }) => {\n this.buttonElement = button(\n {\n type: this.type || 'button',\n disabled: this.disabled,\n part: 'button',\n 'aria-pressed': this.active,\n 'aria-disabled': this.disabled,\n },\n () => {\n slot();\n },\n );\n });\n }\n\n /**\n * Programmatically click the button\n */\n click() {\n if (!this.disabled && this.buttonElement) {\n this.buttonElement.click();\n }\n }\n\n /**\n * Focus the button\n */\n focus() {\n if (this.buttonElement) {\n this.buttonElement.focus();\n }\n }\n\n /**\n * Blur the button\n */\n blur() {\n if (this.buttonElement) {\n this.buttonElement.blur();\n }\n }\n}\n\nButton.register();\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ae-button': Button;\n }\n}\n\nexport default Button;\nexport type ButtonProps = InferProps<typeof Button>;\n"],"names":["prop","_a","html","styleVariables","sizeCSS","colorCSS"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAA,YAAA,aAAA,WAAA,eAAA,WAAA,cAAA,YAAA,IAAA;AAiCA,MAAM,gBAAe,oCAGnB,aAAA,CAACA,MAAAA,KAAK,EAAE,MAAM,OAAA,CAAQ,CAAA,GAGtB,eAAA,CAACA,MAAAA,KAAK,EAAE,MAAM,OAAA,CAAQ,CAAA,GAGtB,YAAA,CAACA,MAAAA,KAAK,EAAE,MAAM,OAAA,CAAQ,CAAA,GAGtB,gBAAA,CAACA,MAAAA,KAAK,EAAE,MAAM,QAAA,CAAS,CAAA,GAGvB,YAAA,CAACA,WAAK,EAAE,MAAM,QAAQ,CAAA,GAGtB,cAAA,CAACA,WAAK,EAAE,MAAM,SAAS,CAAA,GAGvB,aAAA,CAACA,WAAK,EAAE,MAAM,SAAS,CAAA,GArBJ,IAAe;AAAA,EAApC,cAAA;AAAA,UAAA,GAAA,SAAA;AAIE,kBAAA,MAAA,SAAA,kBAAA,OAAA,GAAA,IAAA,CAAA,GAAA,kBAAA,OAAA,IAAA,IAAA;AAGA,kBAAA,MAAA,WAAA,kBAAA,OAAA,IAAA,IAAA,CAAA,GAAA,kBAAA,OAAA,IAAA,IAAA;AAGA,kBAAA,MAAA,QAAA,kBAAA,OAAA,IAAA,IAAA,CAAA,GAAA,kBAAA,OAAA,IAAA,IAA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