@zcomponent/html 1.4.2 → 2.0.0-alpha.2

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.
@@ -1,194 +1,419 @@
1
- import { Component, Event, Observable } from '@zcomponent/core';
1
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
2
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
3
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
4
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
5
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
6
+ var _, done = false;
7
+ for (var i = decorators.length - 1; i >= 0; i--) {
8
+ var context = {};
9
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
10
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
11
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
12
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
13
+ if (kind === "accessor") {
14
+ if (result === void 0) continue;
15
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
16
+ if (_ = accept(result.get)) descriptor.get = _;
17
+ if (_ = accept(result.set)) descriptor.set = _;
18
+ if (_ = accept(result.init)) initializers.unshift(_);
19
+ }
20
+ else if (_ = accept(result)) {
21
+ if (kind === "field") initializers.unshift(_);
22
+ else descriptor[key] = _;
23
+ }
24
+ }
25
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
26
+ done = true;
27
+ };
28
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
29
+ var useValue = arguments.length > 2;
30
+ for (var i = 0; i < initializers.length; i++) {
31
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
32
+ }
33
+ return useValue ? value : void 0;
34
+ };
35
+ import { Component, Event, zIgnore, zObserve, zUI } from '@zcomponent/core';
2
36
  import { useOnNodeConstructed, useOnNodeDisposed } from './context';
3
- export class ZHTMLElement extends Component {
4
- constructor(contextManager, props, element) {
5
- super(contextManager, props);
6
- this.element = element;
7
- /** @zprop */
8
- this.onClick = new Event();
9
- /**
10
- * @zprop
37
+ let ZHTMLElement = (() => {
38
+ let _classSuper = Component;
39
+ let _onClick_decorators;
40
+ let _onClick_initializers = [];
41
+ let _onClick_extraInitializers = [];
42
+ let _innerText_decorators;
43
+ let _innerText_initializers = [];
44
+ let _innerText_extraInitializers = [];
45
+ let _element_decorators;
46
+ let _element_initializers = [];
47
+ let _element_extraInitializers = [];
48
+ let _id_decorators;
49
+ let _id_initializers = [];
50
+ let _id_extraInitializers = [];
51
+ let _classList_decorators;
52
+ let _classList_initializers = [];
53
+ let _classList_extraInitializers = [];
54
+ let _left_decorators;
55
+ let _left_initializers = [];
56
+ let _left_extraInitializers = [];
57
+ let _right_decorators;
58
+ let _right_initializers = [];
59
+ let _right_extraInitializers = [];
60
+ let _top_decorators;
61
+ let _top_initializers = [];
62
+ let _top_extraInitializers = [];
63
+ let _bottom_decorators;
64
+ let _bottom_initializers = [];
65
+ let _bottom_extraInitializers = [];
66
+ let _width_decorators;
67
+ let _width_initializers = [];
68
+ let _width_extraInitializers = [];
69
+ let _height_decorators;
70
+ let _height_initializers = [];
71
+ let _height_extraInitializers = [];
72
+ let _marginLeft_decorators;
73
+ let _marginLeft_initializers = [];
74
+ let _marginLeft_extraInitializers = [];
75
+ let _marginRight_decorators;
76
+ let _marginRight_initializers = [];
77
+ let _marginRight_extraInitializers = [];
78
+ let _marginTop_decorators;
79
+ let _marginTop_initializers = [];
80
+ let _marginTop_extraInitializers = [];
81
+ let _marginBottom_decorators;
82
+ let _marginBottom_initializers = [];
83
+ let _marginBottom_extraInitializers = [];
84
+ let _paddingLeft_decorators;
85
+ let _paddingLeft_initializers = [];
86
+ let _paddingLeft_extraInitializers = [];
87
+ let _paddingRight_decorators;
88
+ let _paddingRight_initializers = [];
89
+ let _paddingRight_extraInitializers = [];
90
+ let _paddingTop_decorators;
91
+ let _paddingTop_initializers = [];
92
+ let _paddingTop_extraInitializers = [];
93
+ let _paddingBottom_decorators;
94
+ let _paddingBottom_initializers = [];
95
+ let _paddingBottom_extraInitializers = [];
96
+ let _position_decorators;
97
+ let _position_initializers = [];
98
+ let _position_extraInitializers = [];
99
+ let _display_decorators;
100
+ let _display_initializers = [];
101
+ let _display_extraInitializers = [];
102
+ let _flexDirection_decorators;
103
+ let _flexDirection_initializers = [];
104
+ let _flexDirection_extraInitializers = [];
105
+ return class ZHTMLElement extends _classSuper {
106
+ static {
107
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
108
+ _onClick_decorators = [zUI()];
109
+ _innerText_decorators = [zUI({ type: 'text-multiline', priority: 21 }), zObserve((v, instance) => {
110
+ instance.element.innerText = v;
111
+ })];
112
+ _element_decorators = [zIgnore()];
113
+ _id_decorators = [zObserve((val, instance) => {
114
+ instance.element.id = val;
115
+ }), zUI()];
116
+ _classList_decorators = [zObserve((val, instance) => {
117
+ instance.element.className = val.join(' ');
118
+ }), zUI()];
119
+ _left_decorators = [zObserve((val, instance) => {
120
+ instance.element.style.left = converCSSLength(val) ?? '';
121
+ }), zUI({ group: 'Position' })];
122
+ _right_decorators = [zObserve((val, instance) => {
123
+ instance.element.style.right = converCSSLength(val) ?? '';
124
+ }), zUI({ group: 'Position' })];
125
+ _top_decorators = [zObserve((val, instance) => {
126
+ instance.element.style.top = converCSSLength(val) ?? '';
127
+ }), zUI({ group: 'Position' })];
128
+ _bottom_decorators = [zObserve((val, instance) => {
129
+ instance.element.style.bottom = converCSSLength(val) ?? '';
130
+ }), zUI({ group: 'Position' })];
131
+ _width_decorators = [zObserve((val, instance) => {
132
+ instance.element.style.width = converCSSLength(val) ?? '';
133
+ }), zUI({ group: 'Size' })];
134
+ _height_decorators = [zObserve((val, instance) => {
135
+ instance.element.style.height = converCSSLength(val) ?? '';
136
+ }), zUI({ group: 'Size' })];
137
+ _marginLeft_decorators = [zObserve((val, instance) => {
138
+ instance.element.style.marginLeft = converCSSLength(val) ?? '';
139
+ }), zUI({ group: 'Spacing' })];
140
+ _marginRight_decorators = [zObserve((val, instance) => {
141
+ instance.element.style.marginRight = converCSSLength(val) ?? '';
142
+ }), zUI({ group: 'Spacing' })];
143
+ _marginTop_decorators = [zObserve((val, instance) => {
144
+ instance.element.style.marginTop = converCSSLength(val) ?? '';
145
+ }), zUI({ group: 'Spacing' })];
146
+ _marginBottom_decorators = [zObserve((val, instance) => {
147
+ instance.element.style.marginBottom = converCSSLength(val) ?? '';
148
+ }), zUI({ group: 'Spacing' })];
149
+ _paddingLeft_decorators = [zObserve((val, instance) => {
150
+ instance.element.style.paddingLeft = converCSSLength(val) ?? '';
151
+ }), zUI({ group: 'Spacing' })];
152
+ _paddingRight_decorators = [zObserve((val, instance) => {
153
+ instance.element.style.paddingRight = converCSSLength(val) ?? '';
154
+ }), zUI({ group: 'Spacing' })];
155
+ _paddingTop_decorators = [zObserve((val, instance) => {
156
+ instance.element.style.paddingTop = converCSSLength(val) ?? '';
157
+ }), zUI({ group: 'Spacing' })];
158
+ _paddingBottom_decorators = [zObserve((val, instance) => {
159
+ instance.element.style.paddingBottom = converCSSLength(val) ?? '';
160
+ }), zUI({ group: 'Spacing' })];
161
+ _position_decorators = [zObserve((val, instance) => {
162
+ instance.element.style.position = val;
163
+ }), zUI({ group: 'Position' })];
164
+ _display_decorators = [zObserve((val, instance) => {
165
+ instance.element.style.display = val ?? '';
166
+ }), zUI({ group: 'Display' })];
167
+ _flexDirection_decorators = [zObserve((val, instance) => {
168
+ instance.element.style.flexDirection = val;
169
+ }), zUI({ group: 'Display' })];
170
+ __esDecorate(null, null, _onClick_decorators, { kind: "field", name: "onClick", static: false, private: false, access: { has: obj => "onClick" in obj, get: obj => obj.onClick, set: (obj, value) => { obj.onClick = value; } }, metadata: _metadata }, _onClick_initializers, _onClick_extraInitializers);
171
+ __esDecorate(null, null, _innerText_decorators, { kind: "field", name: "innerText", static: false, private: false, access: { has: obj => "innerText" in obj, get: obj => obj.innerText, set: (obj, value) => { obj.innerText = value; } }, metadata: _metadata }, _innerText_initializers, _innerText_extraInitializers);
172
+ __esDecorate(null, null, _element_decorators, { kind: "field", name: "element", static: false, private: false, access: { has: obj => "element" in obj, get: obj => obj.element, set: (obj, value) => { obj.element = value; } }, metadata: _metadata }, _element_initializers, _element_extraInitializers);
173
+ __esDecorate(null, null, _id_decorators, { kind: "field", name: "id", static: false, private: false, access: { has: obj => "id" in obj, get: obj => obj.id, set: (obj, value) => { obj.id = value; } }, metadata: _metadata }, _id_initializers, _id_extraInitializers);
174
+ __esDecorate(null, null, _classList_decorators, { kind: "field", name: "classList", static: false, private: false, access: { has: obj => "classList" in obj, get: obj => obj.classList, set: (obj, value) => { obj.classList = value; } }, metadata: _metadata }, _classList_initializers, _classList_extraInitializers);
175
+ __esDecorate(null, null, _left_decorators, { kind: "field", name: "left", static: false, private: false, access: { has: obj => "left" in obj, get: obj => obj.left, set: (obj, value) => { obj.left = value; } }, metadata: _metadata }, _left_initializers, _left_extraInitializers);
176
+ __esDecorate(null, null, _right_decorators, { kind: "field", name: "right", static: false, private: false, access: { has: obj => "right" in obj, get: obj => obj.right, set: (obj, value) => { obj.right = value; } }, metadata: _metadata }, _right_initializers, _right_extraInitializers);
177
+ __esDecorate(null, null, _top_decorators, { kind: "field", name: "top", static: false, private: false, access: { has: obj => "top" in obj, get: obj => obj.top, set: (obj, value) => { obj.top = value; } }, metadata: _metadata }, _top_initializers, _top_extraInitializers);
178
+ __esDecorate(null, null, _bottom_decorators, { kind: "field", name: "bottom", static: false, private: false, access: { has: obj => "bottom" in obj, get: obj => obj.bottom, set: (obj, value) => { obj.bottom = value; } }, metadata: _metadata }, _bottom_initializers, _bottom_extraInitializers);
179
+ __esDecorate(null, null, _width_decorators, { kind: "field", name: "width", static: false, private: false, access: { has: obj => "width" in obj, get: obj => obj.width, set: (obj, value) => { obj.width = value; } }, metadata: _metadata }, _width_initializers, _width_extraInitializers);
180
+ __esDecorate(null, null, _height_decorators, { kind: "field", name: "height", static: false, private: false, access: { has: obj => "height" in obj, get: obj => obj.height, set: (obj, value) => { obj.height = value; } }, metadata: _metadata }, _height_initializers, _height_extraInitializers);
181
+ __esDecorate(null, null, _marginLeft_decorators, { kind: "field", name: "marginLeft", static: false, private: false, access: { has: obj => "marginLeft" in obj, get: obj => obj.marginLeft, set: (obj, value) => { obj.marginLeft = value; } }, metadata: _metadata }, _marginLeft_initializers, _marginLeft_extraInitializers);
182
+ __esDecorate(null, null, _marginRight_decorators, { kind: "field", name: "marginRight", static: false, private: false, access: { has: obj => "marginRight" in obj, get: obj => obj.marginRight, set: (obj, value) => { obj.marginRight = value; } }, metadata: _metadata }, _marginRight_initializers, _marginRight_extraInitializers);
183
+ __esDecorate(null, null, _marginTop_decorators, { kind: "field", name: "marginTop", static: false, private: false, access: { has: obj => "marginTop" in obj, get: obj => obj.marginTop, set: (obj, value) => { obj.marginTop = value; } }, metadata: _metadata }, _marginTop_initializers, _marginTop_extraInitializers);
184
+ __esDecorate(null, null, _marginBottom_decorators, { kind: "field", name: "marginBottom", static: false, private: false, access: { has: obj => "marginBottom" in obj, get: obj => obj.marginBottom, set: (obj, value) => { obj.marginBottom = value; } }, metadata: _metadata }, _marginBottom_initializers, _marginBottom_extraInitializers);
185
+ __esDecorate(null, null, _paddingLeft_decorators, { kind: "field", name: "paddingLeft", static: false, private: false, access: { has: obj => "paddingLeft" in obj, get: obj => obj.paddingLeft, set: (obj, value) => { obj.paddingLeft = value; } }, metadata: _metadata }, _paddingLeft_initializers, _paddingLeft_extraInitializers);
186
+ __esDecorate(null, null, _paddingRight_decorators, { kind: "field", name: "paddingRight", static: false, private: false, access: { has: obj => "paddingRight" in obj, get: obj => obj.paddingRight, set: (obj, value) => { obj.paddingRight = value; } }, metadata: _metadata }, _paddingRight_initializers, _paddingRight_extraInitializers);
187
+ __esDecorate(null, null, _paddingTop_decorators, { kind: "field", name: "paddingTop", static: false, private: false, access: { has: obj => "paddingTop" in obj, get: obj => obj.paddingTop, set: (obj, value) => { obj.paddingTop = value; } }, metadata: _metadata }, _paddingTop_initializers, _paddingTop_extraInitializers);
188
+ __esDecorate(null, null, _paddingBottom_decorators, { kind: "field", name: "paddingBottom", static: false, private: false, access: { has: obj => "paddingBottom" in obj, get: obj => obj.paddingBottom, set: (obj, value) => { obj.paddingBottom = value; } }, metadata: _metadata }, _paddingBottom_initializers, _paddingBottom_extraInitializers);
189
+ __esDecorate(null, null, _position_decorators, { kind: "field", name: "position", static: false, private: false, access: { has: obj => "position" in obj, get: obj => obj.position, set: (obj, value) => { obj.position = value; } }, metadata: _metadata }, _position_initializers, _position_extraInitializers);
190
+ __esDecorate(null, null, _display_decorators, { kind: "field", name: "display", static: false, private: false, access: { has: obj => "display" in obj, get: obj => obj.display, set: (obj, value) => { obj.display = value; } }, metadata: _metadata }, _display_initializers, _display_extraInitializers);
191
+ __esDecorate(null, null, _flexDirection_decorators, { kind: "field", name: "flexDirection", static: false, private: false, access: { has: obj => "flexDirection" in obj, get: obj => obj.flexDirection, set: (obj, value) => { obj.flexDirection = value; } }, metadata: _metadata }, _flexDirection_initializers, _flexDirection_extraInitializers);
192
+ if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
193
+ }
194
+ onClick = __runInitializers(this, _onClick_initializers, new Event());
195
+ /**
196
+ * The inner text of the element.
197
+ * @default ""
198
+ * @zui
11
199
  * @ztype text-multiline
12
- * @zgrouppriority 21
13
- */
14
- this.innerText = new Observable('');
15
- /** @zprop */
16
- this.id = new Observable('', v => (this.element.id = v));
17
- /** @zprop */
18
- this.classList = new Observable([], v => (this.element.className = v.join(' ')));
19
- /** @zprop
20
- * @zdefault [0, "px"]
200
+ */
201
+ innerText = (__runInitializers(this, _onClick_extraInitializers), __runInitializers(this, _innerText_initializers, ''));
202
+ /**
203
+ * @zignore
204
+ */
205
+ element = (__runInitializers(this, _innerText_extraInitializers), __runInitializers(this, _element_initializers, void 0));
206
+ /**
207
+ * Creates a new ZHTMLElement.
208
+ * @param contextManager - The context manager
209
+ * @param props - The properties of the element
210
+ * @param element - The element to wrap
211
+ */
212
+ constructor(contextManager, props, element) {
213
+ super(contextManager, props);
214
+ __runInitializers(this, _flexDirection_extraInitializers);
215
+ this.element = element;
216
+ if (props.innerText !== undefined) {
217
+ this.innerText = props.innerText;
218
+ }
219
+ for (const child of this.children) {
220
+ child.connectElements();
221
+ }
222
+ this._attachEvent(this.onClick, 'click');
223
+ useOnNodeConstructed(contextManager).emit(this.element);
224
+ }
225
+ connectElements() {
226
+ let parent = this.parent;
227
+ while (parent) {
228
+ if (parent === undefined)
229
+ return;
230
+ if (parent.element === undefined) {
231
+ parent = parent.parent;
232
+ continue;
233
+ }
234
+ if (parent instanceof ZHTMLElement) {
235
+ parent.element.appendChild(this.element);
236
+ break;
237
+ }
238
+ else {
239
+ return; // stop if parent element exists but is not an HTMLElement
240
+ }
241
+ }
242
+ }
243
+ _attachEvent(evt, evtName) {
244
+ const handler = (e) => {
245
+ if (this.enabledResolved)
246
+ evt.emit(e);
247
+ };
248
+ evt.hasListeners.addListener(b => {
249
+ if (b)
250
+ this.element.addEventListener(evtName, handler);
251
+ else
252
+ this.element.removeEventListener(evtName, handler);
253
+ });
254
+ }
255
+ /**
256
+ * @default ""
257
+ */
258
+ id = (__runInitializers(this, _element_extraInitializers), __runInitializers(this, _id_initializers, ''));
259
+ /**
260
+ * @default []
261
+ */
262
+ classList = (__runInitializers(this, _id_extraInitializers), __runInitializers(this, _classList_initializers, []));
263
+ /**
264
+ * @default [0,"px"]
265
+ * @zui
21
266
  * @zgroup Position
22
267
  */
23
- this.left = this._cssLengthObservable('left');
24
- /** @zprop
25
- * @zdefault [0, "px"]
268
+ left = (__runInitializers(this, _classList_extraInitializers), __runInitializers(this, _left_initializers, [0, CSSLengthUnit.px]));
269
+ /**
270
+ * @default [0,"px"]
271
+ * @zui
26
272
  * @zgroup Position
27
273
  */
28
- this.right = this._cssLengthObservable('right');
29
- /** @zprop
30
- * @zdefault [0, "px"]
274
+ right = (__runInitializers(this, _left_extraInitializers), __runInitializers(this, _right_initializers, [0, CSSLengthUnit.px]));
275
+ /**
276
+ * @default [0,"px"]
277
+ * @zui
31
278
  * @zgroup Position
32
279
  */
33
- this.top = this._cssLengthObservable('top');
34
- /** @zprop
35
- * @zdefault [0, "px"]
280
+ top = (__runInitializers(this, _right_extraInitializers), __runInitializers(this, _top_initializers, [0, CSSLengthUnit.px]));
281
+ /**
282
+ * @default [0,"px"]
283
+ * @zui
36
284
  * @zgroup Position
37
285
  */
38
- this.bottom = this._cssLengthObservable('bottom');
39
- /** @zprop
40
- * @zdefault [0, "px"]
286
+ bottom = (__runInitializers(this, _top_extraInitializers), __runInitializers(this, _bottom_initializers, [0, CSSLengthUnit.px]));
287
+ /**
288
+ * @default [0,"px"]
289
+ * @zui
41
290
  * @zgroup Size
42
291
  */
43
- this.width = this._cssLengthObservable('width');
44
- /** @zprop
45
- * @zdefault [0, "px"]
292
+ width = (__runInitializers(this, _bottom_extraInitializers), __runInitializers(this, _width_initializers, [0, CSSLengthUnit.px]));
293
+ /**
294
+ * @default [0,"px"]
295
+ * @zui
46
296
  * @zgroup Size
47
297
  */
48
- this.height = this._cssLengthObservable('height');
49
- /** @zprop
50
- * @zdefault [0, "px"]
298
+ height = (__runInitializers(this, _width_extraInitializers), __runInitializers(this, _height_initializers, [0, CSSLengthUnit.px]));
299
+ /**
300
+ * @default [0,"px"]
301
+ * @zui
51
302
  * @zgroup Spacing
52
303
  */
53
- this.marginLeft = this._cssLengthObservable('marginLeft');
54
- /** @zprop
55
- * @zdefault [0, "px"]
304
+ marginLeft = (__runInitializers(this, _height_extraInitializers), __runInitializers(this, _marginLeft_initializers, [0, CSSLengthUnit.px]));
305
+ /**
306
+ * @default [0,"px"]
307
+ * @zui
56
308
  * @zgroup Spacing
57
309
  */
58
- this.marginRight = this._cssLengthObservable('marginRight');
59
- /** @zprop
60
- * @zdefault [0, "px"]
310
+ marginRight = (__runInitializers(this, _marginLeft_extraInitializers), __runInitializers(this, _marginRight_initializers, [0, CSSLengthUnit.px]));
311
+ /**
312
+ * @default [0,"px"]
313
+ * @zui
61
314
  * @zgroup Spacing
62
315
  */
63
- this.marginTop = this._cssLengthObservable('marginTop');
64
- /** @zprop
65
- * @zdefault [0, "px"]
316
+ marginTop = (__runInitializers(this, _marginRight_extraInitializers), __runInitializers(this, _marginTop_initializers, [0, CSSLengthUnit.px]));
317
+ /**
318
+ * @default [0,"px"]
319
+ * @zui
66
320
  * @zgroup Spacing
67
321
  */
68
- this.marginBottom = this._cssLengthObservable('marginBottom');
69
- /** @zprop
70
- * @zdefault [0, "px"]
322
+ marginBottom = (__runInitializers(this, _marginTop_extraInitializers), __runInitializers(this, _marginBottom_initializers, [0, CSSLengthUnit.px]));
323
+ /**
324
+ * @default [0,"px"]
325
+ * @zui
71
326
  * @zgroup Spacing
72
327
  */
73
- this.paddingLeft = this._cssLengthObservable('paddingLeft');
74
- /** @zprop
75
- * @zdefault [0, "px"]
328
+ paddingLeft = (__runInitializers(this, _marginBottom_extraInitializers), __runInitializers(this, _paddingLeft_initializers, [0, CSSLengthUnit.px]));
329
+ /**
330
+ * @default [0,"px"]
331
+ * @zui
76
332
  * @zgroup Spacing
77
333
  */
78
- this.paddingRight = this._cssLengthObservable('paddingRight');
79
- /** @zprop
80
- * @zdefault [0, "px"]
334
+ paddingRight = (__runInitializers(this, _paddingLeft_extraInitializers), __runInitializers(this, _paddingRight_initializers, [0, CSSLengthUnit.px]));
335
+ /**
336
+ * @default [0,"px"]
337
+ * @zui
81
338
  * @zgroup Spacing
82
339
  */
83
- this.paddingTop = this._cssLengthObservable('paddingTop');
84
- /** @zprop
85
- * @zdefault [0, "px"]
340
+ paddingTop = (__runInitializers(this, _paddingRight_extraInitializers), __runInitializers(this, _paddingTop_initializers, [0, CSSLengthUnit.px]));
341
+ /**
342
+ * @default [0,"px"]
343
+ * @zui
86
344
  * @zgroup Spacing
87
345
  */
88
- this.paddingBottom = this._cssLengthObservable('paddingBottom');
89
- /** @zprop
346
+ paddingBottom = (__runInitializers(this, _paddingTop_extraInitializers), __runInitializers(this, _paddingBottom_initializers, [0, CSSLengthUnit.px]));
347
+ /**
348
+ * @default "static"
349
+ * @zui
90
350
  * @zgroup Position
91
- * @zdefault static
92
351
  */
93
- this.position = new Observable(CSSPosition.static, v => (this.element.style.position = v));
94
- /** @zprop */
95
- this.display = new Observable(undefined, v => (this.element.style.display = v ?? ''));
96
- /** @zprop
97
- * @zdefault row
352
+ position = (__runInitializers(this, _paddingBottom_extraInitializers), __runInitializers(this, _position_initializers, CSSPosition.static));
353
+ /**
354
+ * @zui
355
+ * @zgroup Display
98
356
  */
99
- this.flexDirection = new Observable(CSSFlexDirection.row, v => (this.element.style.flexDirection = v));
100
- if (props.innerText === undefined) {
101
- this.innerText.addListener(v => (element.innerText = v));
102
- }
103
- else {
104
- element.innerText = props.innerText;
105
- }
106
- for (const child of this.children) {
107
- this._connectChild(child);
108
- }
109
- this._attachEvent(this.onClick, 'click');
110
- useOnNodeConstructed(contextManager).emit(this.element);
111
- }
112
- appendChild(c) {
113
- super.appendChild(c);
114
- this._connectChild(c);
115
- }
116
- _connectChild(c) {
117
- if (!this.element)
118
- return;
119
- for (const element of c.elementsResolved) {
120
- if (element instanceof Node)
121
- this.element.appendChild(element);
357
+ display = (__runInitializers(this, _position_extraInitializers), __runInitializers(this, _display_initializers, undefined));
358
+ /**
359
+ * @default "row"
360
+ * @zui
361
+ * @zgroup Display
362
+ */
363
+ flexDirection = (__runInitializers(this, _display_extraInitializers), __runInitializers(this, _flexDirection_initializers, CSSFlexDirection.row));
364
+ dispose() {
365
+ useOnNodeDisposed(this.contextManager).emit(this.element);
366
+ return super.dispose();
122
367
  }
123
- }
124
- _cssLengthObservable(prop) {
125
- return new Observable(undefined, v => {
126
- this.element.style[prop] = converCSSLength(v) ?? '';
127
- });
128
- }
129
- _attachEvent(evt, evtName) {
130
- const handler = (e) => {
131
- if (this.enabledResolved.value)
132
- evt.emit(e);
133
- };
134
- evt.hasListeners.addListener(b => {
135
- if (b)
136
- this.element.addEventListener(evtName, handler);
137
- else
138
- this.element.removeEventListener(evtName, handler);
139
- });
140
- }
141
- dispose() {
142
- useOnNodeDisposed(this.contextManager).emit(this.element);
143
- return super.dispose();
144
- }
145
- }
368
+ };
369
+ })();
370
+ export { ZHTMLElement };
146
371
  function converCSSLength(v) {
147
372
  if (v === undefined)
148
373
  return undefined;
149
374
  return v[0].toString() + v[1];
150
375
  }
151
- export var CSSLengthUnit;
152
- (function (CSSLengthUnit) {
153
- CSSLengthUnit["cm"] = "cm";
154
- CSSLengthUnit["mm"] = "mm";
155
- CSSLengthUnit["in"] = "in";
156
- CSSLengthUnit["px"] = "px";
157
- CSSLengthUnit["pt"] = "pt";
158
- CSSLengthUnit["pc"] = "pc";
159
- CSSLengthUnit["em"] = "em";
160
- CSSLengthUnit["ex"] = "ex";
161
- CSSLengthUnit["ch"] = "ch";
162
- CSSLengthUnit["rem"] = "rem";
163
- CSSLengthUnit["vw"] = "vw";
164
- CSSLengthUnit["vh"] = "vh";
165
- CSSLengthUnit["vmin"] = "vmin";
166
- CSSLengthUnit["vmax"] = "vmax";
167
- CSSLengthUnit["%"] = "%";
168
- })(CSSLengthUnit || (CSSLengthUnit = {}));
169
- export var CSSPosition;
170
- (function (CSSPosition) {
171
- CSSPosition["static"] = "static";
172
- CSSPosition["relative"] = "relative";
173
- CSSPosition["absolute"] = "absolute";
174
- CSSPosition["fixed"] = "fixed";
175
- CSSPosition["sticky"] = "sticky";
176
- })(CSSPosition || (CSSPosition = {}));
177
- export var CSSDisplay;
178
- (function (CSSDisplay) {
179
- CSSDisplay["none"] = "none";
180
- CSSDisplay["block"] = "block";
181
- CSSDisplay["inline"] = "inline";
182
- CSSDisplay["inline-block"] = "inline-block";
183
- CSSDisplay["flex"] = "flex";
184
- CSSDisplay["inline-flex"] = "inline-flex";
185
- CSSDisplay["grid"] = "grid";
186
- CSSDisplay["inline-grid"] = "inline-grid";
187
- })(CSSDisplay || (CSSDisplay = {}));
188
- export var CSSFlexDirection;
189
- (function (CSSFlexDirection) {
190
- CSSFlexDirection["row"] = "row";
191
- CSSFlexDirection["row-reverse"] = "row-reverse";
192
- CSSFlexDirection["column"] = "column";
193
- CSSFlexDirection["column-reverse"] = "column-reverse";
194
- })(CSSFlexDirection || (CSSFlexDirection = {}));
376
+ export const CSSLengthUnit = {
377
+ cm: 'cm',
378
+ mm: 'mm',
379
+ in: 'in',
380
+ px: 'px',
381
+ pt: 'pt',
382
+ pc: 'pc',
383
+ em: 'em',
384
+ ex: 'ex',
385
+ ch: 'ch',
386
+ rem: 'rem',
387
+ vw: 'vw',
388
+ vh: 'vh',
389
+ vmin: 'vmin',
390
+ vmax: 'vmax',
391
+ '%': '%',
392
+ };
393
+ Object.freeze(CSSLengthUnit);
394
+ export const CSSPosition = {
395
+ static: 'static',
396
+ relative: 'relative',
397
+ absolute: 'absolute',
398
+ fixed: 'fixed',
399
+ sticky: 'sticky',
400
+ };
401
+ Object.freeze(CSSPosition);
402
+ export const CSSDisplay = {
403
+ none: 'none',
404
+ block: 'block',
405
+ inline: 'inline',
406
+ 'inline-block': 'inline-block',
407
+ flex: 'flex',
408
+ 'inline-flex': 'inline-flex',
409
+ grid: 'grid',
410
+ 'inline-grid': 'inline-grid',
411
+ };
412
+ Object.freeze(CSSDisplay);
413
+ export const CSSFlexDirection = {
414
+ row: 'row',
415
+ 'row-reverse': 'row-reverse',
416
+ column: 'column',
417
+ 'column-reverse': 'column-reverse',
418
+ };
419
+ Object.freeze(CSSFlexDirection);
package/lib/button.d.ts CHANGED
@@ -1,10 +1,20 @@
1
1
  import { ContextManager } from '@zcomponent/core';
2
2
  import { HTMLElementProps, ZHTMLElement } from './HTMLElement';
3
- /** @zcomponent
3
+ /**
4
+ *
5
+ * A HTML Button component.
6
+ *
7
+ * You can access the underlying HTMLButtonElement using the `element` property.
8
+ * @zcomponent
9
+ * @zicon html
4
10
  * @ztag html/element/button
5
11
  * @zparents html/element/**
6
- * @zicon html
7
12
  */
8
13
  export declare class Button extends ZHTMLElement<HTMLButtonElement> {
14
+ /**
15
+ *
16
+ * @param mgr - The context manager
17
+ * @param props - The properties of the button
18
+ */
9
19
  constructor(mgr: ContextManager, props: HTMLElementProps);
10
20
  }