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
package/dist/alert.cjs
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const alert = require("./chunks/alert.cjs");
|
|
4
|
+
exports.Alert = alert.Alert;
|
|
5
|
+
exports.default = alert.Alert;
|
|
6
|
+
//# sourceMappingURL=alert.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alert.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
package/dist/alert.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alert.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
package/dist/badge.cjs
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const badge = require("./chunks/badge.cjs");
|
|
4
|
+
exports.Badge = badge.Badge;
|
|
5
|
+
exports.default = badge.Badge;
|
|
6
|
+
//# sourceMappingURL=badge.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"badge.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
package/dist/badge.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"badge.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const breadcrumbItem = require("./chunks/breadcrumb-item.cjs");
|
|
4
|
+
exports.Breadcrumb = breadcrumbItem.Breadcrumb;
|
|
5
|
+
exports.BreadcrumbItem = breadcrumbItem.BreadcrumbItem;
|
|
6
|
+
exports.default = breadcrumbItem.Breadcrumb;
|
|
7
|
+
//# sourceMappingURL=breadcrumb.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"breadcrumb.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"breadcrumb.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const buttonGroup = require("./chunks/button-group.cjs");
|
|
4
|
+
exports.ButtonGroup = buttonGroup.ButtonGroup;
|
|
5
|
+
exports.default = buttonGroup.ButtonGroup;
|
|
6
|
+
//# sourceMappingURL=button-group.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button-group.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button-group.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
package/dist/button.cjs
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const button = require("./chunks/button.cjs");
|
|
4
|
+
exports.Button = button.Button;
|
|
5
|
+
exports.default = button.Button;
|
|
6
|
+
//# sourceMappingURL=button.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
package/dist/button.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
package/dist/card.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"card.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
package/dist/card.js
ADDED
package/dist/card.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"card.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const checkbox = require("./chunks/checkbox.cjs");
|
|
4
|
+
exports.Checkbox = checkbox.Checkbox;
|
|
5
|
+
exports.default = checkbox.Checkbox;
|
|
6
|
+
//# sourceMappingURL=checkbox.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkbox.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
package/dist/checkbox.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkbox.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const aeico = require("aeico");
|
|
3
|
+
const SVG_NS = "http://www.w3.org/2000/svg";
|
|
4
|
+
function toKebab(str) {
|
|
5
|
+
const cleaned = str.replace(/^[_\d]+/, "");
|
|
6
|
+
return cleaned.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
7
|
+
}
|
|
8
|
+
const TAG_NAME_PREFIX = "ae";
|
|
9
|
+
class AeicoComponent extends aeico.AeicoElement {
|
|
10
|
+
static register(name) {
|
|
11
|
+
const tagName = name || `${TAG_NAME_PREFIX}-${this.tagName || toKebab(this.name)}`;
|
|
12
|
+
super.register(tagName);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.AeicoComponent = AeicoComponent;
|
|
16
|
+
exports.SVG_NS = SVG_NS;
|
|
17
|
+
//# sourceMappingURL=aeico-component.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aeico-component.cjs","sources":["../../src/utils.ts","../../src/aeico-component.ts"],"sourcesContent":["export const SVG_NS = 'http://www.w3.org/2000/svg';\n\nexport function toKebab(str: string): string {\n const cleaned = str.replace(/^[_\\d]+/, '');\n\n return cleaned.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();\n}\n","import { AeicoElement } from 'aeico';\nimport { toKebab } from './utils';\n\nconst TAG_NAME_PREFIX = 'ae';\n\n/**\n * AeicoComponent is the base class for all built-in Aeico components.\n */\nclass AeicoComponent extends AeicoElement {\n static register(name?: string) {\n const tagName = name || `${TAG_NAME_PREFIX}-${this.tagName || toKebab(this.name)}`;\n\n super.register(tagName);\n }\n}\n\nexport default AeicoComponent;\n"],"names":["AeicoElement"],"mappings":";;AAAO,MAAM,SAAS;AAEf,SAAS,QAAQ,KAAqB;AAC3C,QAAM,UAAU,IAAI,QAAQ,WAAW,EAAE;AAEzC,SAAO,QAAQ,QAAQ,mBAAmB,OAAO,EAAE,YAAA;AACrD;ACHA,MAAM,kBAAkB;AAKxB,MAAM,uBAAuBA,MAAAA,aAAa;AAAA,EACxC,OAAO,SAAS,MAAe;AAC7B,UAAM,UAAU,QAAQ,GAAG,eAAe,IAAI,KAAK,WAAW,QAAQ,KAAK,IAAI,CAAC;AAEhF,UAAM,SAAS,OAAO;AAAA,EACxB;AACF;;;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AeicoElement } from "aeico";
|
|
2
|
+
const SVG_NS = "http://www.w3.org/2000/svg";
|
|
3
|
+
function toKebab(str) {
|
|
4
|
+
const cleaned = str.replace(/^[_\d]+/, "");
|
|
5
|
+
return cleaned.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
6
|
+
}
|
|
7
|
+
const TAG_NAME_PREFIX = "ae";
|
|
8
|
+
class AeicoComponent extends AeicoElement {
|
|
9
|
+
static register(name) {
|
|
10
|
+
const tagName = name || `${TAG_NAME_PREFIX}-${this.tagName || toKebab(this.name)}`;
|
|
11
|
+
super.register(tagName);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
AeicoComponent as A,
|
|
16
|
+
SVG_NS as S
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=aeico-component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aeico-component.js","sources":["../../src/utils.ts","../../src/aeico-component.ts"],"sourcesContent":["export const SVG_NS = 'http://www.w3.org/2000/svg';\n\nexport function toKebab(str: string): string {\n const cleaned = str.replace(/^[_\\d]+/, '');\n\n return cleaned.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();\n}\n","import { AeicoElement } from 'aeico';\nimport { toKebab } from './utils';\n\nconst TAG_NAME_PREFIX = 'ae';\n\n/**\n * AeicoComponent is the base class for all built-in Aeico components.\n */\nclass AeicoComponent extends AeicoElement {\n static register(name?: string) {\n const tagName = name || `${TAG_NAME_PREFIX}-${this.tagName || toKebab(this.name)}`;\n\n super.register(tagName);\n }\n}\n\nexport default AeicoComponent;\n"],"names":[],"mappings":";AAAO,MAAM,SAAS;AAEf,SAAS,QAAQ,KAAqB;AAC3C,QAAM,UAAU,IAAI,QAAQ,WAAW,EAAE;AAEzC,SAAO,QAAQ,QAAQ,mBAAmB,OAAO,EAAE,YAAA;AACrD;ACHA,MAAM,kBAAkB;AAKxB,MAAM,uBAAuB,aAAa;AAAA,EACxC,OAAO,SAAS,MAAe;AAC7B,UAAM,UAAU,QAAQ,GAAG,eAAe,IAAI,KAAK,WAAW,QAAQ,KAAK,IAAI,CAAC;AAEhF,UAAM,SAAS,OAAO;AAAA,EACxB;AACF;"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
const aeico = require("aeico");
|
|
6
|
+
const aeicoComponent = require("./aeico-component.cjs");
|
|
7
|
+
const aeicoLocalize = require("aeico-localize");
|
|
8
|
+
class AeicoField extends aeicoComponent.AeicoComponent {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
/**
|
|
12
|
+
* The underlying form control element (input, select, etc.)
|
|
13
|
+
* Subclasses should set this to their specific element
|
|
14
|
+
*/
|
|
15
|
+
__publicField(this, "fieldElement", null);
|
|
16
|
+
__publicField(this, "resetBtn", null);
|
|
17
|
+
__publicField(this, "clearBtn", null);
|
|
18
|
+
__publicField(this, "boundOnChange", () => this.setValue(this.getValue(), { silent: false, action: "change" }));
|
|
19
|
+
__publicField(this, "boundOnReset", () => this.onReset());
|
|
20
|
+
__publicField(this, "boundOnClear", () => this.onClear());
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Lifecycle: Component connected to DOM
|
|
24
|
+
*/
|
|
25
|
+
connectedCallback() {
|
|
26
|
+
super.connectedCallback();
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Lifecycle: Component disconnected from DOM
|
|
30
|
+
*/
|
|
31
|
+
disconnectedCallback() {
|
|
32
|
+
super.disconnectedCallback();
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Render action buttons (clear/reset) using this.builder.
|
|
36
|
+
* Must be called from within a build() callback.
|
|
37
|
+
*/
|
|
38
|
+
renderActionButtons(force = false) {
|
|
39
|
+
this.renderClearButton(force);
|
|
40
|
+
this.renderResetButton(force);
|
|
41
|
+
}
|
|
42
|
+
renderResetButton(force = false) {
|
|
43
|
+
const { button } = aeico.tags;
|
|
44
|
+
if (force || this.resettable) {
|
|
45
|
+
this.resetBtn = button({
|
|
46
|
+
className: "reset-btn",
|
|
47
|
+
textContent: this.resetText || "↺",
|
|
48
|
+
title: aeicoLocalize.t("buttons.reset", "↺"),
|
|
49
|
+
"@click": this.boundOnReset
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
renderClearButton(force = false) {
|
|
54
|
+
const { button } = aeico.tags;
|
|
55
|
+
if (force || this.clearable) {
|
|
56
|
+
this.clearBtn = button({
|
|
57
|
+
className: "clear-btn",
|
|
58
|
+
textContent: this.clearText || "✕",
|
|
59
|
+
title: aeicoLocalize.t("buttons.clear", "✕"),
|
|
60
|
+
"@click": this.boundOnClear
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Watcher for disabled property
|
|
66
|
+
*/
|
|
67
|
+
onDisabledChanged(newValue) {
|
|
68
|
+
if (this.fieldElement) {
|
|
69
|
+
this.fieldElement.disabled = Boolean(newValue);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Render the field component
|
|
74
|
+
* Override in subclass to provide custom rendering
|
|
75
|
+
*/
|
|
76
|
+
render() {
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Get current value from the field element
|
|
80
|
+
* Default implementation returns the value property of fieldElement
|
|
81
|
+
* Override in subclasses if needed (e.g., checkbox uses checked instead of value)
|
|
82
|
+
*
|
|
83
|
+
* @returns Current field value
|
|
84
|
+
*/
|
|
85
|
+
getValue() {
|
|
86
|
+
var _a;
|
|
87
|
+
return ((_a = this.fieldElement) == null ? void 0 : _a.value) || "";
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Write value to the underlying UI element and sync props
|
|
91
|
+
* Subclasses must override this to update their specific UI element
|
|
92
|
+
*
|
|
93
|
+
* @param _value New value to write to the element
|
|
94
|
+
*/
|
|
95
|
+
writeValue(_value) {
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Get event payload for change events
|
|
99
|
+
* Override in subclasses to customize event data (e.g., { checked, oldChecked } for checkbox)
|
|
100
|
+
*
|
|
101
|
+
* @param value New value
|
|
102
|
+
* @param oldValue Previous value
|
|
103
|
+
* @param action Action type
|
|
104
|
+
* @returns Event payload object
|
|
105
|
+
*/
|
|
106
|
+
getEventPayload(value, oldValue, action) {
|
|
107
|
+
return { value, oldValue, action };
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Update field value programmatically (internal method)
|
|
111
|
+
* Subclasses should provide type-safe public wrappers (e.g., change() method)
|
|
112
|
+
*
|
|
113
|
+
* @param value New value
|
|
114
|
+
* @param options.silent If true, won't emit change event (default: true)
|
|
115
|
+
* @param options.action Action type for the event (default: 'change')
|
|
116
|
+
*/
|
|
117
|
+
setValue(value, options) {
|
|
118
|
+
const oldValue = this.getValue();
|
|
119
|
+
this.value = value;
|
|
120
|
+
this.writeValue(value);
|
|
121
|
+
if ((options == null ? void 0 : options.silent) === false) {
|
|
122
|
+
const payload = this.getEventPayload(value, oldValue, options.action || "change");
|
|
123
|
+
this.emit("change", { detail: payload });
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Reset field to specified value or default value
|
|
128
|
+
*
|
|
129
|
+
* @param value Value to reset to, defaults to defaultValue prop
|
|
130
|
+
* @param options.silent If false, will emit reset event (default: true)
|
|
131
|
+
*/
|
|
132
|
+
reset(value, options) {
|
|
133
|
+
const resetValue = value !== void 0 ? value : this.defaultValue;
|
|
134
|
+
this.setValue(resetValue, { ...options, action: "reset" });
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Clear the field value
|
|
138
|
+
*
|
|
139
|
+
* @param options.silent If false, will emit clear event (default: true)
|
|
140
|
+
*/
|
|
141
|
+
clear(options) {
|
|
142
|
+
this.setValue("", { ...options, action: "clear" });
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Handle clear button click
|
|
146
|
+
* Clears the field and dispatches event
|
|
147
|
+
*/
|
|
148
|
+
onClear() {
|
|
149
|
+
this.clear({ silent: false });
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Handle reset button click
|
|
153
|
+
* Resets to default value and dispatches event
|
|
154
|
+
*/
|
|
155
|
+
onReset() {
|
|
156
|
+
this.reset(void 0, { silent: false });
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Define base field properties (extends AeicoElement properties)
|
|
161
|
+
*/
|
|
162
|
+
__publicField(AeicoField, "props", {
|
|
163
|
+
value: { type: String },
|
|
164
|
+
defaultValue: { type: String },
|
|
165
|
+
resettable: { type: Boolean },
|
|
166
|
+
resetText: { type: String },
|
|
167
|
+
clearable: { type: Boolean },
|
|
168
|
+
clearText: { type: String },
|
|
169
|
+
size: { type: String },
|
|
170
|
+
disabled: { type: Boolean }
|
|
171
|
+
});
|
|
172
|
+
/**
|
|
173
|
+
* Property watchers
|
|
174
|
+
*/
|
|
175
|
+
__publicField(AeicoField, "watchers", {
|
|
176
|
+
disabled: "onDisabledChanged"
|
|
177
|
+
});
|
|
178
|
+
exports.AeicoField = AeicoField;
|
|
179
|
+
//# sourceMappingURL=aeico-field.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aeico-field.cjs","sources":["../../src/aeico-field.ts"],"sourcesContent":["import type { InferProps, Props, Watchers } from 'aeico';\nimport { tags } from 'aeico';\nimport AeicoComponent from './aeico-component';\nimport { t } from 'aeico-localize';\n\nexport type FieldAction = 'clear' | 'reset' | 'change';\nexport type FieldElement = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;\n\n/**\n * Base class for form field components\n *\n * Provides common functionality for field components including:\n * - Theme support\n * - i18n integration (via Localizable mixin)\n * - Reset button management\n * - Value management\n * - Common configuration handling\n */\nclass AeicoField<TValue = string> extends AeicoComponent {\n /**\n * Define base field properties (extends AeicoElement properties)\n */\n static props: Props = {\n value: { type: String },\n defaultValue: { type: String },\n resettable: { type: Boolean },\n resetText: { type: String },\n clearable: { type: Boolean },\n clearText: { type: String },\n size: { type: String },\n disabled: { type: Boolean },\n };\n\n /**\n * Property watchers\n */\n static watchers: Watchers = {\n disabled: 'onDisabledChanged',\n };\n\n /**\n * The underlying form control element (input, select, etc.)\n * Subclasses should set this to their specific element\n */\n protected fieldElement: FieldElement | null = null;\n\n protected resetBtn: HTMLButtonElement | null = null;\n protected clearBtn: HTMLButtonElement | null = null;\n\n protected readonly boundOnChange = () =>\n this.setValue(this.getValue(), { silent: false, action: 'change' });\n\n protected readonly boundOnReset = () => this.onReset();\n protected readonly boundOnClear = () => this.onClear();\n\n // Declare reactive properties for TypeScript\n declare value?: TValue;\n declare defaultValue?: TValue | string;\n declare resettable?: boolean;\n declare resetText?: string;\n declare clearable?: boolean;\n declare clearText?: string;\n declare size?: string;\n declare disabled?: boolean;\n\n /**\n * Lifecycle: Component connected to DOM\n */\n connectedCallback() {\n super.connectedCallback();\n }\n\n /**\n * Lifecycle: Component disconnected from DOM\n */\n disconnectedCallback() {\n super.disconnectedCallback();\n }\n\n /**\n * Render action buttons (clear/reset) using this.builder.\n * Must be called from within a build() callback.\n */\n protected renderActionButtons(force: boolean = false) {\n this.renderClearButton(force);\n this.renderResetButton(force);\n }\n\n protected renderResetButton(force: boolean = false) {\n const { button } = tags;\n\n if (force || this.resettable) {\n this.resetBtn = button({\n className: 'reset-btn',\n textContent: this.resetText || '↺',\n title: t('buttons.reset', '↺'),\n '@click': this.boundOnReset,\n });\n }\n }\n\n protected renderClearButton(force: boolean = false) {\n const { button } = tags;\n\n if (force || this.clearable) {\n this.clearBtn = button({\n className: 'clear-btn',\n textContent: this.clearText || '✕',\n title: t('buttons.clear', '✕'),\n '@click': this.boundOnClear,\n });\n }\n }\n\n /**\n * Watcher for disabled property\n */\n protected onDisabledChanged(newValue: boolean) {\n if (this.fieldElement) {\n (this.fieldElement as HTMLInputElement | HTMLSelectElement).disabled = Boolean(newValue);\n }\n }\n\n /**\n * Render the field component\n * Override in subclass to provide custom rendering\n */\n render(): void {\n // Default implementation - subclasses can override\n }\n\n /**\n * Get current value from the field element\n * Default implementation returns the value property of fieldElement\n * Override in subclasses if needed (e.g., checkbox uses checked instead of value)\n *\n * @returns Current field value\n */\n protected getValue(): any {\n return this.fieldElement?.value || '';\n }\n\n /**\n * Write value to the underlying UI element and sync props\n * Subclasses must override this to update their specific UI element\n *\n * @param _value New value to write to the element\n */\n protected writeValue(_value: any): void {\n // Base implementation - subclasses override\n }\n\n /**\n * Get event payload for change events\n * Override in subclasses to customize event data (e.g., { checked, oldChecked } for checkbox)\n *\n * @param value New value\n * @param oldValue Previous value\n * @param action Action type\n * @returns Event payload object\n */\n protected getEventPayload(value: any, oldValue: any, action: FieldAction): Record<string, any> {\n return { value, oldValue, action };\n }\n\n /**\n * Update field value programmatically (internal method)\n * Subclasses should provide type-safe public wrappers (e.g., change() method)\n *\n * @param value New value\n * @param options.silent If true, won't emit change event (default: true)\n * @param options.action Action type for the event (default: 'change')\n */\n protected setValue(value: any, options?: { silent?: boolean; action?: FieldAction }): void {\n const oldValue = this.getValue();\n\n // Update property value\n this.value = value;\n\n // Write to UI element (DOM only)\n this.writeValue(value);\n\n // Emit event if not silent\n if (options?.silent === false) {\n const payload = this.getEventPayload(value, oldValue, options.action || 'change');\n this.emit('change', { detail: payload });\n }\n }\n\n /**\n * Reset field to specified value or default value\n *\n * @param value Value to reset to, defaults to defaultValue prop\n * @param options.silent If false, will emit reset event (default: true)\n */\n public reset(value?: any, options?: { silent?: boolean }): void {\n const resetValue = value !== undefined ? value : this.defaultValue;\n this.setValue(resetValue, { ...options, action: 'reset' });\n }\n\n /**\n * Clear the field value\n *\n * @param options.silent If false, will emit clear event (default: true)\n */\n public clear(options?: { silent?: boolean }): void {\n this.setValue('', { ...options, action: 'clear' });\n }\n\n /**\n * Handle clear button click\n * Clears the field and dispatches event\n */\n protected onClear(): void {\n this.clear({ silent: false });\n }\n\n /**\n * Handle reset button click\n * Resets to default value and dispatches event\n */\n protected onReset(): void {\n this.reset(undefined, { silent: false });\n }\n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AA;AAAA,EAMU,UAAgB;AACxB,SAAK,MAAM,QAAW,EAAE,QAAQ,OAAO;AAAA,EACzC;AACF;AAAA;AAAA;AAAA;AA1ME,cAJI,YAIG,SAAe;AAAA,EACpB,OAAO,EAAE,MAAM,OAAA;AAAA,EACf,cAAc,EAAE,MAAM,OAAA;AAAA,EACtB,YAAY,EAAE,MAAM,QAAA;AAAA,EACpB,WAAW,EAAE,MAAM,OAAA;AAAA,EACnB,WAAW,EAAE,MAAM,QAAA;AAAA,EACnB,WAAW,EAAE,MAAM,OAAA;AAAA,EACnB,MAAM,EAAE,MAAM,OAAA;AAAA,EACd,UAAU,EAAE,MAAM,QAAA;AAAQ;AAAA;AAAA;AAAA;AAM5B,cAlBI,YAkBG,YAAqB;AAAA,EAC1B,UAAU;AAAA;;"}
|
|
@@ -0,0 +1,180 @@
|
|
|
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 { tags } from "aeico";
|
|
5
|
+
import { A as AeicoComponent } from "./aeico-component.js";
|
|
6
|
+
import { t } from "aeico-localize";
|
|
7
|
+
class AeicoField extends AeicoComponent {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
/**
|
|
11
|
+
* The underlying form control element (input, select, etc.)
|
|
12
|
+
* Subclasses should set this to their specific element
|
|
13
|
+
*/
|
|
14
|
+
__publicField(this, "fieldElement", null);
|
|
15
|
+
__publicField(this, "resetBtn", null);
|
|
16
|
+
__publicField(this, "clearBtn", null);
|
|
17
|
+
__publicField(this, "boundOnChange", () => this.setValue(this.getValue(), { silent: false, action: "change" }));
|
|
18
|
+
__publicField(this, "boundOnReset", () => this.onReset());
|
|
19
|
+
__publicField(this, "boundOnClear", () => this.onClear());
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Lifecycle: Component connected to DOM
|
|
23
|
+
*/
|
|
24
|
+
connectedCallback() {
|
|
25
|
+
super.connectedCallback();
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Lifecycle: Component disconnected from DOM
|
|
29
|
+
*/
|
|
30
|
+
disconnectedCallback() {
|
|
31
|
+
super.disconnectedCallback();
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Render action buttons (clear/reset) using this.builder.
|
|
35
|
+
* Must be called from within a build() callback.
|
|
36
|
+
*/
|
|
37
|
+
renderActionButtons(force = false) {
|
|
38
|
+
this.renderClearButton(force);
|
|
39
|
+
this.renderResetButton(force);
|
|
40
|
+
}
|
|
41
|
+
renderResetButton(force = false) {
|
|
42
|
+
const { button } = tags;
|
|
43
|
+
if (force || this.resettable) {
|
|
44
|
+
this.resetBtn = button({
|
|
45
|
+
className: "reset-btn",
|
|
46
|
+
textContent: this.resetText || "↺",
|
|
47
|
+
title: t("buttons.reset", "↺"),
|
|
48
|
+
"@click": this.boundOnReset
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
renderClearButton(force = false) {
|
|
53
|
+
const { button } = tags;
|
|
54
|
+
if (force || this.clearable) {
|
|
55
|
+
this.clearBtn = button({
|
|
56
|
+
className: "clear-btn",
|
|
57
|
+
textContent: this.clearText || "✕",
|
|
58
|
+
title: t("buttons.clear", "✕"),
|
|
59
|
+
"@click": this.boundOnClear
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Watcher for disabled property
|
|
65
|
+
*/
|
|
66
|
+
onDisabledChanged(newValue) {
|
|
67
|
+
if (this.fieldElement) {
|
|
68
|
+
this.fieldElement.disabled = Boolean(newValue);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Render the field component
|
|
73
|
+
* Override in subclass to provide custom rendering
|
|
74
|
+
*/
|
|
75
|
+
render() {
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Get current value from the field element
|
|
79
|
+
* Default implementation returns the value property of fieldElement
|
|
80
|
+
* Override in subclasses if needed (e.g., checkbox uses checked instead of value)
|
|
81
|
+
*
|
|
82
|
+
* @returns Current field value
|
|
83
|
+
*/
|
|
84
|
+
getValue() {
|
|
85
|
+
var _a;
|
|
86
|
+
return ((_a = this.fieldElement) == null ? void 0 : _a.value) || "";
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Write value to the underlying UI element and sync props
|
|
90
|
+
* Subclasses must override this to update their specific UI element
|
|
91
|
+
*
|
|
92
|
+
* @param _value New value to write to the element
|
|
93
|
+
*/
|
|
94
|
+
writeValue(_value) {
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Get event payload for change events
|
|
98
|
+
* Override in subclasses to customize event data (e.g., { checked, oldChecked } for checkbox)
|
|
99
|
+
*
|
|
100
|
+
* @param value New value
|
|
101
|
+
* @param oldValue Previous value
|
|
102
|
+
* @param action Action type
|
|
103
|
+
* @returns Event payload object
|
|
104
|
+
*/
|
|
105
|
+
getEventPayload(value, oldValue, action) {
|
|
106
|
+
return { value, oldValue, action };
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Update field value programmatically (internal method)
|
|
110
|
+
* Subclasses should provide type-safe public wrappers (e.g., change() method)
|
|
111
|
+
*
|
|
112
|
+
* @param value New value
|
|
113
|
+
* @param options.silent If true, won't emit change event (default: true)
|
|
114
|
+
* @param options.action Action type for the event (default: 'change')
|
|
115
|
+
*/
|
|
116
|
+
setValue(value, options) {
|
|
117
|
+
const oldValue = this.getValue();
|
|
118
|
+
this.value = value;
|
|
119
|
+
this.writeValue(value);
|
|
120
|
+
if ((options == null ? void 0 : options.silent) === false) {
|
|
121
|
+
const payload = this.getEventPayload(value, oldValue, options.action || "change");
|
|
122
|
+
this.emit("change", { detail: payload });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Reset field to specified value or default value
|
|
127
|
+
*
|
|
128
|
+
* @param value Value to reset to, defaults to defaultValue prop
|
|
129
|
+
* @param options.silent If false, will emit reset event (default: true)
|
|
130
|
+
*/
|
|
131
|
+
reset(value, options) {
|
|
132
|
+
const resetValue = value !== void 0 ? value : this.defaultValue;
|
|
133
|
+
this.setValue(resetValue, { ...options, action: "reset" });
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Clear the field value
|
|
137
|
+
*
|
|
138
|
+
* @param options.silent If false, will emit clear event (default: true)
|
|
139
|
+
*/
|
|
140
|
+
clear(options) {
|
|
141
|
+
this.setValue("", { ...options, action: "clear" });
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Handle clear button click
|
|
145
|
+
* Clears the field and dispatches event
|
|
146
|
+
*/
|
|
147
|
+
onClear() {
|
|
148
|
+
this.clear({ silent: false });
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Handle reset button click
|
|
152
|
+
* Resets to default value and dispatches event
|
|
153
|
+
*/
|
|
154
|
+
onReset() {
|
|
155
|
+
this.reset(void 0, { silent: false });
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Define base field properties (extends AeicoElement properties)
|
|
160
|
+
*/
|
|
161
|
+
__publicField(AeicoField, "props", {
|
|
162
|
+
value: { type: String },
|
|
163
|
+
defaultValue: { type: String },
|
|
164
|
+
resettable: { type: Boolean },
|
|
165
|
+
resetText: { type: String },
|
|
166
|
+
clearable: { type: Boolean },
|
|
167
|
+
clearText: { type: String },
|
|
168
|
+
size: { type: String },
|
|
169
|
+
disabled: { type: Boolean }
|
|
170
|
+
});
|
|
171
|
+
/**
|
|
172
|
+
* Property watchers
|
|
173
|
+
*/
|
|
174
|
+
__publicField(AeicoField, "watchers", {
|
|
175
|
+
disabled: "onDisabledChanged"
|
|
176
|
+
});
|
|
177
|
+
export {
|
|
178
|
+
AeicoField as A
|
|
179
|
+
};
|
|
180
|
+
//# sourceMappingURL=aeico-field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aeico-field.js","sources":["../../src/aeico-field.ts"],"sourcesContent":["import type { InferProps, Props, Watchers } from 'aeico';\nimport { tags } from 'aeico';\nimport AeicoComponent from './aeico-component';\nimport { t } from 'aeico-localize';\n\nexport type FieldAction = 'clear' | 'reset' | 'change';\nexport type FieldElement = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;\n\n/**\n * Base class for form field components\n *\n * Provides common functionality for field components including:\n * - Theme support\n * - i18n integration (via Localizable mixin)\n * - Reset button management\n * - Value management\n * - Common configuration handling\n */\nclass AeicoField<TValue = string> extends AeicoComponent {\n /**\n * Define base field properties (extends AeicoElement properties)\n */\n static props: Props = {\n value: { type: String },\n defaultValue: { type: String },\n resettable: { type: Boolean },\n resetText: { type: String },\n clearable: { type: Boolean },\n clearText: { type: String },\n size: { type: String },\n disabled: { type: Boolean },\n };\n\n /**\n * Property watchers\n */\n static watchers: Watchers = {\n disabled: 'onDisabledChanged',\n };\n\n /**\n * The underlying form control element (input, select, etc.)\n * Subclasses should set this to their specific element\n */\n protected fieldElement: FieldElement | null = null;\n\n protected resetBtn: HTMLButtonElement | null = null;\n protected clearBtn: HTMLButtonElement | null = null;\n\n protected readonly boundOnChange = () =>\n this.setValue(this.getValue(), { silent: false, action: 'change' });\n\n protected readonly boundOnReset = () => this.onReset();\n protected readonly boundOnClear = () => this.onClear();\n\n // Declare reactive properties for TypeScript\n declare value?: TValue;\n declare defaultValue?: TValue | string;\n declare resettable?: boolean;\n declare resetText?: string;\n declare clearable?: boolean;\n declare clearText?: string;\n declare size?: string;\n declare disabled?: boolean;\n\n /**\n * Lifecycle: Component connected to DOM\n */\n connectedCallback() {\n super.connectedCallback();\n }\n\n /**\n * Lifecycle: Component disconnected from DOM\n */\n disconnectedCallback() {\n super.disconnectedCallback();\n }\n\n /**\n * Render action buttons (clear/reset) using this.builder.\n * Must be called from within a build() callback.\n */\n protected renderActionButtons(force: boolean = false) {\n this.renderClearButton(force);\n this.renderResetButton(force);\n }\n\n protected renderResetButton(force: boolean = false) {\n const { button } = tags;\n\n if (force || this.resettable) {\n this.resetBtn = button({\n className: 'reset-btn',\n textContent: this.resetText || '↺',\n title: t('buttons.reset', '↺'),\n '@click': this.boundOnReset,\n });\n }\n }\n\n protected renderClearButton(force: boolean = false) {\n const { button } = tags;\n\n if (force || this.clearable) {\n this.clearBtn = button({\n className: 'clear-btn',\n textContent: this.clearText || '✕',\n title: t('buttons.clear', '✕'),\n '@click': this.boundOnClear,\n });\n }\n }\n\n /**\n * Watcher for disabled property\n */\n protected onDisabledChanged(newValue: boolean) {\n if (this.fieldElement) {\n (this.fieldElement as HTMLInputElement | HTMLSelectElement).disabled = Boolean(newValue);\n }\n }\n\n /**\n * Render the field component\n * Override in subclass to provide custom rendering\n */\n render(): void {\n // Default implementation - subclasses can override\n }\n\n /**\n * Get current value from the field element\n * Default implementation returns the value property of fieldElement\n * Override in subclasses if needed (e.g., checkbox uses checked instead of value)\n *\n * @returns Current field value\n */\n protected getValue(): any {\n return this.fieldElement?.value || '';\n }\n\n /**\n * Write value to the underlying UI element and sync props\n * Subclasses must override this to update their specific UI element\n *\n * @param _value New value to write to the element\n */\n protected writeValue(_value: any): void {\n // Base implementation - subclasses override\n }\n\n /**\n * Get event payload for change events\n * Override in subclasses to customize event data (e.g., { checked, oldChecked } for checkbox)\n *\n * @param value New value\n * @param oldValue Previous value\n * @param action Action type\n * @returns Event payload object\n */\n protected getEventPayload(value: any, oldValue: any, action: FieldAction): Record<string, any> {\n return { value, oldValue, action };\n }\n\n /**\n * Update field value programmatically (internal method)\n * Subclasses should provide type-safe public wrappers (e.g., change() method)\n *\n * @param value New value\n * @param options.silent If true, won't emit change event (default: true)\n * @param options.action Action type for the event (default: 'change')\n */\n protected setValue(value: any, options?: { silent?: boolean; action?: FieldAction }): void {\n const oldValue = this.getValue();\n\n // Update property value\n this.value = value;\n\n // Write to UI element (DOM only)\n this.writeValue(value);\n\n // Emit event if not silent\n if (options?.silent === false) {\n const payload = this.getEventPayload(value, oldValue, options.action || 'change');\n this.emit('change', { detail: payload });\n }\n }\n\n /**\n * Reset field to specified value or default value\n *\n * @param value Value to reset to, defaults to defaultValue prop\n * @param options.silent If false, will emit reset event (default: true)\n */\n public reset(value?: any, options?: { silent?: boolean }): void {\n const resetValue = value !== undefined ? value : this.defaultValue;\n this.setValue(resetValue, { ...options, action: 'reset' });\n }\n\n /**\n * Clear the field value\n *\n * @param options.silent If false, will emit clear event (default: true)\n */\n public clear(options?: { silent?: boolean }): void {\n this.setValue('', { ...options, action: 'clear' });\n }\n\n /**\n * Handle clear button click\n * Clears the field and dispatches event\n */\n protected onClear(): void {\n this.clear({ silent: false });\n }\n\n /**\n * Handle reset button click\n * Resets to default value and dispatches event\n */\n protected onReset(): void {\n this.reset(undefined, { silent: false });\n }\n}\n\nexport default AeicoField;\nexport type AeicoFieldProps = InferProps<typeof AeicoField>;\n"],"names":[],"mappings":";;;;;;AAkBA,MAAM,mBAAoC,eAAe;AAAA,EAAzD;AAAA;AA0BY;AAAA;AAAA;AAAA;AAAA,wCAAoC;AAEpC,oCAAqC;AACrC,oCAAqC;AAE5B,yCAAgB,MACjC,KAAK,SAAS,KAAK,YAAY,EAAE,QAAQ,OAAO,QAAQ,SAAA,CAAU;AAEjD,wCAAe,MAAM,KAAK,QAAA;AAC1B,wCAAe,MAAM,KAAK,QAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAe7C,oBAAoB;AAClB,UAAM,kBAAA;AAAA,EACR;AAAA;AAAA;AAAA;AAAA,EAKA,uBAAuB;AACrB,UAAM,qBAAA;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA,EAMU,oBAAoB,QAAiB,OAAO;AACpD,SAAK,kBAAkB,KAAK;AAC5B,SAAK,kBAAkB,KAAK;AAAA,EAC9B;AAAA,EAEU,kBAAkB,Q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