aeico-components 0.1.4 → 0.1.6

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.
Files changed (299) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +0 -0
  3. package/dist/chunks/action-button.cjs +296 -0
  4. package/dist/chunks/action-button.cjs.map +1 -0
  5. package/dist/chunks/action-button.js +297 -0
  6. package/dist/chunks/action-button.js.map +1 -0
  7. package/dist/chunks/alert.cjs +4 -4
  8. package/dist/chunks/alert.cjs.map +1 -1
  9. package/dist/chunks/alert.js +5 -5
  10. package/dist/chunks/alert.js.map +1 -1
  11. package/dist/chunks/badge.cjs +1 -1
  12. package/dist/chunks/badge.cjs.map +1 -1
  13. package/dist/chunks/badge.js +2 -2
  14. package/dist/chunks/badge.js.map +1 -1
  15. package/dist/chunks/breadcrumb-item.cjs +2 -2
  16. package/dist/chunks/breadcrumb-item.cjs.map +1 -1
  17. package/dist/chunks/breadcrumb-item.js +3 -3
  18. package/dist/chunks/breadcrumb-item.js.map +1 -1
  19. package/dist/chunks/button-group.cjs +1 -1
  20. package/dist/chunks/button-group.cjs.map +1 -1
  21. package/dist/chunks/button-group.js +2 -2
  22. package/dist/chunks/button-group.js.map +1 -1
  23. package/dist/chunks/button.cjs +12 -15
  24. package/dist/chunks/button.cjs.map +1 -1
  25. package/dist/chunks/button.js +13 -16
  26. package/dist/chunks/button.js.map +1 -1
  27. package/dist/chunks/card.cjs +1 -1
  28. package/dist/chunks/card.cjs.map +1 -1
  29. package/dist/chunks/card.js +2 -2
  30. package/dist/chunks/card.js.map +1 -1
  31. package/dist/chunks/checkbox.cjs +18 -5
  32. package/dist/chunks/checkbox.cjs.map +1 -1
  33. package/dist/chunks/checkbox.js +18 -5
  34. package/dist/chunks/checkbox.js.map +1 -1
  35. package/dist/chunks/copy-button.cjs +168 -0
  36. package/dist/chunks/copy-button.cjs.map +1 -0
  37. package/dist/chunks/copy-button.js +169 -0
  38. package/dist/chunks/copy-button.js.map +1 -0
  39. package/dist/chunks/detail.cjs +7 -4
  40. package/dist/chunks/detail.cjs.map +1 -1
  41. package/dist/chunks/detail.js +8 -5
  42. package/dist/chunks/detail.js.map +1 -1
  43. package/dist/chunks/dialog.cjs +1 -1
  44. package/dist/chunks/dialog.cjs.map +1 -1
  45. package/dist/chunks/dialog.js +2 -2
  46. package/dist/chunks/dialog.js.map +1 -1
  47. package/dist/chunks/divider.cjs +1 -1
  48. package/dist/chunks/divider.cjs.map +1 -1
  49. package/dist/chunks/divider.js +2 -2
  50. package/dist/chunks/divider.js.map +1 -1
  51. package/dist/chunks/drawer.cjs +180 -0
  52. package/dist/chunks/drawer.cjs.map +1 -0
  53. package/dist/chunks/drawer.js +181 -0
  54. package/dist/chunks/drawer.js.map +1 -0
  55. package/dist/chunks/dropdown-button.cjs +2 -2
  56. package/dist/chunks/dropdown-button.cjs.map +1 -1
  57. package/dist/chunks/dropdown-button.js +6 -6
  58. package/dist/chunks/dropdown-button.js.map +1 -1
  59. package/dist/chunks/icon.cjs +31 -1
  60. package/dist/chunks/icon.cjs.map +1 -1
  61. package/dist/chunks/icon.js +32 -2
  62. package/dist/chunks/icon.js.map +1 -1
  63. package/dist/chunks/menu.cjs +396 -0
  64. package/dist/chunks/menu.cjs.map +1 -0
  65. package/dist/chunks/menu.js +397 -0
  66. package/dist/chunks/menu.js.map +1 -0
  67. package/dist/chunks/navbar.cjs +2 -3
  68. package/dist/chunks/navbar.cjs.map +1 -1
  69. package/dist/chunks/navbar.js +3 -4
  70. package/dist/chunks/navbar.js.map +1 -1
  71. package/dist/chunks/pagination.cjs +475 -0
  72. package/dist/chunks/pagination.cjs.map +1 -0
  73. package/dist/chunks/pagination.js +476 -0
  74. package/dist/chunks/pagination.js.map +1 -0
  75. package/dist/chunks/progress-bar.cjs +101 -0
  76. package/dist/chunks/progress-bar.cjs.map +1 -0
  77. package/dist/chunks/progress-bar.js +102 -0
  78. package/dist/chunks/progress-bar.js.map +1 -0
  79. package/dist/chunks/radio.cjs +11 -7
  80. package/dist/chunks/radio.cjs.map +1 -1
  81. package/dist/chunks/radio.js +11 -7
  82. package/dist/chunks/radio.js.map +1 -1
  83. package/dist/chunks/select.cjs +97 -66
  84. package/dist/chunks/select.cjs.map +1 -1
  85. package/dist/chunks/select.js +97 -66
  86. package/dist/chunks/select.js.map +1 -1
  87. package/dist/chunks/slider.cjs +9 -46
  88. package/dist/chunks/slider.cjs.map +1 -1
  89. package/dist/chunks/slider.js +9 -46
  90. package/dist/chunks/slider.js.map +1 -1
  91. package/dist/chunks/spinner.cjs +102 -0
  92. package/dist/chunks/spinner.cjs.map +1 -0
  93. package/dist/chunks/spinner.js +103 -0
  94. package/dist/chunks/spinner.js.map +1 -0
  95. package/dist/chunks/switch.cjs +110 -16
  96. package/dist/chunks/switch.cjs.map +1 -1
  97. package/dist/chunks/switch.js +111 -17
  98. package/dist/chunks/switch.js.map +1 -1
  99. package/dist/chunks/tab-panel.cjs +6 -7
  100. package/dist/chunks/tab-panel.cjs.map +1 -1
  101. package/dist/chunks/tab-panel.js +7 -8
  102. package/dist/chunks/tab-panel.js.map +1 -1
  103. package/dist/chunks/tag.cjs +1 -1
  104. package/dist/chunks/tag.cjs.map +1 -1
  105. package/dist/chunks/tag.js +2 -2
  106. package/dist/chunks/tag.js.map +1 -1
  107. package/dist/chunks/text-input.cjs +11 -16
  108. package/dist/chunks/text-input.cjs.map +1 -1
  109. package/dist/chunks/text-input.js +11 -16
  110. package/dist/chunks/text-input.js.map +1 -1
  111. package/dist/chunks/textarea.cjs +137 -0
  112. package/dist/chunks/textarea.cjs.map +1 -0
  113. package/dist/chunks/textarea.js +138 -0
  114. package/dist/chunks/textarea.js.map +1 -0
  115. package/dist/chunks/tooltip.cjs +293 -0
  116. package/dist/chunks/tooltip.cjs.map +1 -0
  117. package/dist/chunks/tooltip.js +294 -0
  118. package/dist/chunks/tooltip.js.map +1 -0
  119. package/dist/chunks/tree.cjs +468 -0
  120. package/dist/chunks/tree.cjs.map +1 -0
  121. package/dist/chunks/tree.js +469 -0
  122. package/dist/chunks/tree.js.map +1 -0
  123. package/dist/chunks/variables.cjs +2 -2
  124. package/dist/chunks/variables.js +2 -2
  125. package/dist/copy-button.cjs +6 -0
  126. package/dist/copy-button.cjs.map +1 -0
  127. package/dist/copy-button.js +6 -0
  128. package/dist/copy-button.js.map +1 -0
  129. package/dist/drawer.cjs +6 -0
  130. package/dist/drawer.cjs.map +1 -0
  131. package/dist/drawer.js +6 -0
  132. package/dist/drawer.js.map +1 -0
  133. package/dist/dropdown.js +4 -4
  134. package/dist/index.cjs +186 -0
  135. package/dist/index.cjs.map +1 -1
  136. package/dist/index.js +201 -15
  137. package/dist/index.js.map +1 -1
  138. package/dist/menu.cjs +6 -0
  139. package/dist/menu.cjs.map +1 -0
  140. package/dist/menu.js +6 -0
  141. package/dist/menu.js.map +1 -0
  142. package/dist/pagination.cjs +6 -0
  143. package/dist/pagination.cjs.map +1 -0
  144. package/dist/pagination.js +6 -0
  145. package/dist/pagination.js.map +1 -0
  146. package/dist/progress-bar.cjs +6 -0
  147. package/dist/progress-bar.cjs.map +1 -0
  148. package/dist/progress-bar.js +6 -0
  149. package/dist/progress-bar.js.map +1 -0
  150. package/dist/select.cjs +1 -1
  151. package/dist/select.cjs.map +1 -1
  152. package/dist/select.js +2 -2
  153. package/dist/select.js.map +1 -1
  154. package/dist/spinner.cjs +6 -0
  155. package/dist/spinner.cjs.map +1 -0
  156. package/dist/spinner.js +6 -0
  157. package/dist/spinner.js.map +1 -0
  158. package/dist/textarea.cjs +5 -0
  159. package/dist/textarea.cjs.map +1 -0
  160. package/dist/textarea.js +5 -0
  161. package/dist/textarea.js.map +1 -0
  162. package/dist/tooltip.cjs +6 -0
  163. package/dist/tooltip.cjs.map +1 -0
  164. package/dist/tooltip.js +6 -0
  165. package/dist/tooltip.js.map +1 -0
  166. package/dist/tree.cjs +6 -0
  167. package/dist/tree.cjs.map +1 -0
  168. package/dist/tree.js +6 -0
  169. package/dist/tree.js.map +1 -0
  170. package/dist/types/aeico-field.d.ts +57 -5
  171. package/dist/types/alert/alert.d.ts +1 -0
  172. package/dist/types/button/button.d.ts +2 -1
  173. package/dist/types/checkbox/checkbox.d.ts +5 -5
  174. package/dist/types/copy-button/copy-button.d.ts +32 -0
  175. package/dist/types/copy-button/defines.d.ts +1 -0
  176. package/dist/types/copy-button/index.d.ts +3 -0
  177. package/dist/types/detail/defines.d.ts +1 -0
  178. package/dist/types/detail/detail.d.ts +3 -1
  179. package/dist/types/detail/index.d.ts +1 -1
  180. package/dist/types/detail-group/detail-group.d.ts +39 -0
  181. package/dist/types/detail-group/index.d.ts +2 -0
  182. package/dist/types/drawer/defines.d.ts +1 -0
  183. package/dist/types/drawer/drawer.d.ts +31 -0
  184. package/dist/types/drawer/index.d.ts +3 -0
  185. package/dist/types/icon/built-in-icons.d.ts +1 -0
  186. package/dist/types/icon/icon.d.ts +1 -0
  187. package/dist/types/icon/registry.d.ts +8 -0
  188. package/dist/types/index.d.ts +19 -0
  189. package/dist/types/menu/defines.d.ts +15 -0
  190. package/dist/types/menu/index.d.ts +5 -0
  191. package/dist/types/menu/menu-item.d.ts +63 -0
  192. package/dist/types/menu/menu.d.ts +34 -0
  193. package/dist/types/number-input/index.d.ts +2 -0
  194. package/dist/types/number-input/number-input.d.ts +35 -0
  195. package/dist/types/pagination/defines.d.ts +2 -0
  196. package/dist/types/pagination/index.d.ts +3 -0
  197. package/dist/types/pagination/pagination.d.ts +77 -0
  198. package/dist/types/progress-bar/defines.d.ts +1 -0
  199. package/dist/types/progress-bar/index.d.ts +3 -0
  200. package/dist/types/progress-bar/progress-bar.d.ts +37 -0
  201. package/dist/types/radio-group/radio-group.d.ts +1 -1
  202. package/dist/types/select/select.d.ts +3 -3
  203. package/dist/types/spinner/defines.d.ts +3 -0
  204. package/dist/types/spinner/index.d.ts +3 -0
  205. package/dist/types/spinner/spinner.d.ts +35 -0
  206. package/dist/types/switch/defines.d.ts +1 -0
  207. package/dist/types/switch/switch.d.ts +13 -9
  208. package/dist/types/text-input/text-input.d.ts +0 -4
  209. package/dist/types/textarea/index.d.ts +1 -0
  210. package/dist/types/textarea/textarea.d.ts +26 -0
  211. package/dist/types/tooltip/defines.d.ts +2 -0
  212. package/dist/types/tooltip/index.d.ts +4 -0
  213. package/dist/types/tooltip/tooltip.d.ts +48 -0
  214. package/dist/types/tree/defines.d.ts +23 -0
  215. package/dist/types/tree/index.d.ts +5 -0
  216. package/dist/types/tree/tree-item.d.ts +54 -0
  217. package/dist/types/tree/tree.d.ts +64 -0
  218. package/package.json +6 -6
  219. package/src/aeico-field.ts +154 -15
  220. package/src/alert/alert.ts +3 -2
  221. package/src/button/button.ts +11 -13
  222. package/src/checkbox/checkbox.ts +21 -6
  223. package/src/copy-button/copy-button.ts +146 -0
  224. package/src/copy-button/defines.ts +5 -0
  225. package/src/copy-button/index.ts +3 -0
  226. package/src/detail/defines.ts +1 -0
  227. package/src/detail/detail.ts +5 -1
  228. package/src/detail/index.ts +1 -1
  229. package/src/detail-group/detail-group.ts +104 -0
  230. package/src/detail-group/index.ts +2 -0
  231. package/src/drawer/defines.ts +1 -0
  232. package/src/drawer/drawer.ts +157 -0
  233. package/src/drawer/index.ts +3 -0
  234. package/src/icon/built-in-icons.ts +21 -0
  235. package/src/icon/icon.ts +1 -0
  236. package/src/icon/registry.ts +22 -0
  237. package/src/index.ts +32 -0
  238. package/src/menu/defines.ts +17 -0
  239. package/src/menu/index.ts +5 -0
  240. package/src/menu/menu-item.ts +315 -0
  241. package/src/menu/menu.ts +81 -0
  242. package/src/navbar/navbar.ts +1 -3
  243. package/src/number-input/index.ts +2 -0
  244. package/src/number-input/number-input.ts +137 -0
  245. package/src/pagination/defines.ts +2 -0
  246. package/src/pagination/index.ts +3 -0
  247. package/src/pagination/pagination.ts +310 -0
  248. package/src/progress-bar/defines.ts +8 -0
  249. package/src/progress-bar/index.ts +3 -0
  250. package/src/progress-bar/progress-bar.ts +80 -0
  251. package/src/radio-group/radio-group.ts +12 -5
  252. package/src/select/select.ts +112 -71
  253. package/src/slider/slider.ts +9 -2
  254. package/src/spinner/defines.ts +12 -0
  255. package/src/spinner/index.ts +3 -0
  256. package/src/spinner/spinner.ts +81 -0
  257. package/src/styles/components/action-button.css +37 -0
  258. package/src/styles/components/checkbox.css +4 -26
  259. package/src/styles/components/copy-button.css +119 -0
  260. package/src/styles/components/detail-group.css +10 -0
  261. package/src/styles/components/detail.css +10 -1
  262. package/src/styles/components/drawer.css +161 -0
  263. package/src/styles/components/field-label.css +120 -0
  264. package/src/styles/components/menu-item.css +168 -0
  265. package/src/styles/components/menu.css +17 -0
  266. package/src/styles/components/number-input.css +167 -0
  267. package/src/styles/components/pagination.css +205 -0
  268. package/src/styles/components/progress-bar.css +44 -0
  269. package/src/styles/components/radio-group.css +0 -23
  270. package/src/styles/components/select.css +12 -39
  271. package/src/styles/components/slider.css +0 -42
  272. package/src/styles/components/spinner.css +80 -0
  273. package/src/styles/components/switch.css +68 -19
  274. package/src/styles/components/tab-panel.css +1 -1
  275. package/src/styles/components/tabs.css +1 -0
  276. package/src/styles/components/text-input.css +7 -45
  277. package/src/styles/components/textarea.css +75 -0
  278. package/src/styles/components/tooltip.css +103 -0
  279. package/src/styles/components/tree-item.css +152 -0
  280. package/src/styles/components/tree.css +10 -0
  281. package/src/styles/layout.css +457 -25
  282. package/src/switch/defines.ts +1 -0
  283. package/src/switch/switch.ts +65 -16
  284. package/src/tabs/tab.ts +1 -1
  285. package/src/tabs/tabs.ts +1 -2
  286. package/src/text-input/text-input.ts +10 -15
  287. package/src/textarea/index.ts +1 -0
  288. package/src/textarea/textarea.ts +107 -0
  289. package/src/tooltip/defines.ts +11 -0
  290. package/src/tooltip/index.ts +4 -0
  291. package/src/tooltip/tooltip.ts +183 -0
  292. package/src/tree/defines.ts +26 -0
  293. package/src/tree/index.ts +5 -0
  294. package/src/tree/tree-item.ts +258 -0
  295. package/src/tree/tree.ts +237 -0
  296. package/dist/chunks/aeico-field.cjs +0 -179
  297. package/dist/chunks/aeico-field.cjs.map +0 -1
  298. package/dist/chunks/aeico-field.js +0 -180
  299. package/dist/chunks/aeico-field.js.map +0 -1
@@ -0,0 +1,237 @@
1
+ import AeicoComponent from '../aeico-component';
2
+ import type { InferProps } from 'aeico';
3
+ import { html, prop } from 'aeico';
4
+ import style from '../styles/components/tree.css?inline';
5
+ import variables from '../styles/variables.css?inline';
6
+ import type { TreeSelectDetail, TreeExpandDetail, TreeCheckDetail } from './defines';
7
+ import './tree-item';
8
+ import type TreeItem from './tree-item';
9
+
10
+ /**
11
+ * Tree component. Renders a hierarchical tree of `<ae-tree-item>` elements.
12
+ *
13
+ * @prop {boolean} checkable - Enable checkbox selection mode with parent-child sync.
14
+ * @prop {boolean} multiple - Allow multi-select (click to toggle). Ignored when checkable.
15
+ * @prop {boolean} showLine - Show dashed connecting lines between items.
16
+ * @prop {boolean} defaultExpandAll - Expand all items on initial connect.
17
+ * @prop {string} selectedKey - Currently selected key (single-select convenience prop).
18
+ *
19
+ * @property {string[]} selectedKeys - Currently selected keys (multi-select).
20
+ * @property {string[]} checkedKeys - Currently checked keys (checkable mode).
21
+ * @property {string[]} expandedKeys - Currently expanded keys.
22
+ *
23
+ * @event {CustomEvent<TreeSelectDetail>} select - Fires when an item is selected/deselected.
24
+ * @event {CustomEvent<TreeExpandDetail>} expand - Fires when an item is expanded/collapsed.
25
+ * @event {CustomEvent<TreeCheckDetail>} check - Fires when an item checkbox changes.
26
+ *
27
+ * @example
28
+ * ```html
29
+ * <ae-tree>
30
+ * <ae-tree-item key="1" label="Parent">
31
+ * <ae-tree-item key="1-1" label="Child A"></ae-tree-item>
32
+ * <ae-tree-item key="1-2" label="Child B"></ae-tree-item>
33
+ * </ae-tree-item>
34
+ * </ae-tree>
35
+ * ```
36
+ */
37
+ class Tree extends AeicoComponent {
38
+ static tagName = 'tree';
39
+
40
+ protected static styles = [variables, style];
41
+
42
+ @prop({ type: Boolean })
43
+ accessor checkable: boolean = false;
44
+
45
+ @prop({ type: Boolean })
46
+ accessor multiple: boolean = false;
47
+
48
+ @prop({ type: Boolean })
49
+ accessor showLine: boolean = false;
50
+
51
+ @prop({ type: Boolean })
52
+ accessor defaultExpandAll: boolean = false;
53
+
54
+ @prop({ type: String })
55
+ accessor selectedKey: string | undefined;
56
+
57
+ /** Icon name used for the expand/collapse toggle on all items (overridable per item). */
58
+ @prop({ type: String })
59
+ accessor icon: string | undefined;
60
+
61
+ /** Currently selected keys (multi-select). Set programmatically. */
62
+ selectedKeys: string[] = [];
63
+
64
+ /** Currently checked keys (checkable mode). Set programmatically. */
65
+ checkedKeys: string[] = [];
66
+
67
+ /** Currently expanded keys. Set programmatically. */
68
+ expandedKeys: string[] = [];
69
+
70
+ connectedCallback() {
71
+ super.connectedCallback();
72
+ this.listen('_tree-item-toggle-expand', this._handleItemToggleExpand as EventListener);
73
+ this.listen('_tree-item-select', this._handleItemSelect as EventListener);
74
+ this.listen('_tree-item-check', this._handleItemCheck as EventListener);
75
+ }
76
+
77
+ private _getAllItems(): TreeItem[] {
78
+ return Array.from(this.querySelectorAll<TreeItem>('ae-tree-item'));
79
+ }
80
+
81
+ private _getDirectChildren(node: Element): TreeItem[] {
82
+ return Array.from(node.querySelectorAll<TreeItem>(':scope > ae-tree-item'));
83
+ }
84
+
85
+ private _computeCheckedKeys(): string[] {
86
+ const keys: string[] = [];
87
+ for (const item of this._getAllItems()) {
88
+ if (item.checked && !item.indeterminate) {
89
+ keys.push(item.key ?? '');
90
+ }
91
+ }
92
+ return keys.filter(Boolean);
93
+ }
94
+
95
+ private _handleItemToggleExpand = (e: CustomEvent<{ key: string }>): void => {
96
+ const node = e.target as TreeItem;
97
+ const newExpanded = !node.expanded;
98
+ node.expanded = newExpanded;
99
+
100
+ const key = node.key ?? '';
101
+ if (newExpanded) {
102
+ if (!this.expandedKeys.includes(key)) {
103
+ this.expandedKeys = [...this.expandedKeys, key];
104
+ }
105
+ } else {
106
+ this.expandedKeys = this.expandedKeys.filter((k) => k !== key);
107
+ }
108
+
109
+ this.emit('expand', {
110
+ detail: {
111
+ key,
112
+ expanded: newExpanded,
113
+ expandedKeys: [...this.expandedKeys],
114
+ } satisfies TreeExpandDetail,
115
+ });
116
+ };
117
+
118
+ private _handleItemSelect = (e: CustomEvent<{ key: string }>): void => {
119
+ const { key } = e.detail;
120
+
121
+ if (this.multiple) {
122
+ // Toggle selection
123
+ const alreadySelected = this.selectedKeys.includes(key);
124
+ if (alreadySelected) {
125
+ this.selectedKeys = this.selectedKeys.filter((k) => k !== key);
126
+ } else {
127
+ this.selectedKeys = [...this.selectedKeys, key];
128
+ }
129
+ this.selectedKey = this.selectedKeys[this.selectedKeys.length - 1];
130
+
131
+ // Sync visual state
132
+ this._getAllItems().forEach((item) => {
133
+ item.selected = this.selectedKeys.includes(item.key ?? '');
134
+ });
135
+
136
+ this.emit('select', {
137
+ detail: {
138
+ key,
139
+ selected: !alreadySelected,
140
+ selectedKeys: [...this.selectedKeys],
141
+ } satisfies TreeSelectDetail,
142
+ });
143
+ } else {
144
+ // Single select — deselect all, select target
145
+ const alreadySelected = this.selectedKey === key;
146
+ this._getAllItems().forEach((item) => {
147
+ item.selected = !alreadySelected && item.key === key;
148
+ });
149
+ this.selectedKey = alreadySelected ? undefined : key;
150
+ this.selectedKeys = this.selectedKey ? [this.selectedKey] : [];
151
+
152
+ this.emit('select', {
153
+ detail: {
154
+ key,
155
+ selected: !alreadySelected,
156
+ selectedKeys: [...this.selectedKeys],
157
+ } satisfies TreeSelectDetail,
158
+ });
159
+ }
160
+ };
161
+
162
+ private _handleItemCheck = (e: CustomEvent<{ key: string; checked: boolean }>): void => {
163
+ const { key, checked } = e.detail;
164
+ const sourceNode = e.target as TreeItem;
165
+
166
+ this._setCheckedRecursive(sourceNode, checked);
167
+ this._syncAncestors(sourceNode);
168
+ this.checkedKeys = this._computeCheckedKeys();
169
+
170
+ this.emit('check', {
171
+ detail: { key, checked, checkedKeys: [...this.checkedKeys] } satisfies TreeCheckDetail,
172
+ });
173
+ };
174
+
175
+ private _setCheckedRecursive(node: TreeItem, checked: boolean): void {
176
+ if (node.disabled) return;
177
+ node.checked = checked;
178
+ node.indeterminate = false;
179
+ for (const child of this._getDirectChildren(node)) {
180
+ this._setCheckedRecursive(child, checked);
181
+ }
182
+ }
183
+
184
+ private _syncAncestors(sourceNode: TreeItem): void {
185
+ let el: Element | null = sourceNode.parentElement;
186
+ while (el) {
187
+ const tag = el.tagName.toLowerCase();
188
+ if (tag === 'ae-tree-item') {
189
+ const parent = el as TreeItem;
190
+ const children = this._getDirectChildren(parent).filter((c) => !c.disabled);
191
+ if (children.length === 0) break;
192
+ const checkedCount = children.filter((c) => c.checked && !c.indeterminate).length;
193
+ const indeterminateCount = children.filter((c) => c.indeterminate).length;
194
+
195
+ if (checkedCount === children.length) {
196
+ parent.checked = true;
197
+ parent.indeterminate = false;
198
+ } else if (checkedCount > 0 || indeterminateCount > 0) {
199
+ parent.checked = false;
200
+ parent.indeterminate = true;
201
+ } else {
202
+ parent.checked = false;
203
+ parent.indeterminate = false;
204
+ }
205
+ } else if (tag === 'ae-tree') {
206
+ break;
207
+ }
208
+ el = el.parentElement;
209
+ }
210
+ }
211
+
212
+ protected render() {
213
+ return html(({ div, slot }) => {
214
+ div(
215
+ {
216
+ className: 'tree',
217
+ role: 'tree',
218
+ 'aria-multiselectable': this.multiple ? 'true' : 'false',
219
+ },
220
+ () => {
221
+ slot();
222
+ },
223
+ );
224
+ });
225
+ }
226
+ }
227
+
228
+ Tree.register();
229
+
230
+ declare global {
231
+ interface HTMLElementTagNameMap {
232
+ 'ae-tree': Tree;
233
+ }
234
+ }
235
+
236
+ export default Tree;
237
+ export type TreeProps = InferProps<typeof Tree>;
@@ -1,179 +0,0 @@
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
@@ -1 +0,0 @@
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}\n\nexport default AeicoField;\nexport type AeicoFieldProps = InferProps<typeof AeicoField>;\n"],"names":["AeicoComponent","tags","t"],"mappings":";;;;;;;AAkBA,MAAM,mBAAoCA,eAAAA,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,M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B,MAAM,EAAE,MAAM,OAAA;AAAA,EACd,UAAU,EAAE,MAAM,QAAA;AAAQ;AAAA;AAAA;AAAA;AAM5B,cAlBI,YAkBG,YAAqB;AAAA,EAC1B,UAAU;AAAA;;"}
@@ -1,180 +0,0 @@
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
@@ -1 +0,0 @@
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":";;;;;;AA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