@zcomponent/html 2.0.0-alpha.1 → 2.0.0-alpha.3
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/index.js +0 -3
- package/lib/CSS.d.ts +6 -8
- package/lib/CSS.js +89 -37
- package/lib/HTMLElement.d.ts +183 -103
- package/lib/HTMLElement.js +380 -155
- package/lib/button.d.ts +12 -2
- package/lib/button.js +69 -7
- package/lib/context.d.ts +1 -1
- package/lib/context.js +4 -7
- package/lib/div.d.ts +11 -2
- package/lib/div.js +68 -7
- package/lib/headings.d.ts +24 -18
- package/lib/headings.js +193 -45
- package/lib/i.d.ts +3 -2
- package/lib/i.js +60 -7
- package/lib/img.d.ts +8 -8
- package/lib/img.js +74 -14
- package/lib/span.d.ts +3 -2
- package/lib/span.js +60 -7
- package/package.json +73 -56
package/index.js
CHANGED
package/lib/CSS.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { Component, ContextManager } from '@zcomponent/core';
|
|
2
|
-
interface CSSConstructorProps {
|
|
3
|
-
/**
|
|
4
|
-
* @zvalues files *.css
|
|
1
|
+
import { Component, ConstructorProps, ContextManager, ProjectFile } from '@zcomponent/core';
|
|
2
|
+
interface CSSConstructorProps extends ConstructorProps {
|
|
3
|
+
/**
|
|
5
4
|
*/
|
|
6
|
-
source:
|
|
5
|
+
source: ProjectFile<'*.css'>;
|
|
7
6
|
/**
|
|
8
|
-
*
|
|
9
|
-
* @
|
|
7
|
+
*
|
|
8
|
+
* @default true
|
|
10
9
|
*/
|
|
11
10
|
includeAtDesignTime: boolean;
|
|
12
11
|
}
|
|
@@ -14,7 +13,6 @@ interface CSSConstructorProps {
|
|
|
14
13
|
* The CSS component will ensure that the CSS file referenced by its `source` constructor prop is added to your page and loaded by the browser.
|
|
15
14
|
*
|
|
16
15
|
* This component is particularly useful if you'd like to style with CSS any HTML elements that you've added to your Hierarchy.
|
|
17
|
-
*
|
|
18
16
|
* @zcomponent
|
|
19
17
|
* @zicon html
|
|
20
18
|
*/
|
package/lib/CSS.js
CHANGED
|
@@ -1,49 +1,101 @@
|
|
|
1
|
-
|
|
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, isDesignTime, registerLoadable, zComponent } from '@zcomponent/core';
|
|
2
36
|
import { HTMLContext } from './context';
|
|
3
37
|
const alreadyAdded = new Map();
|
|
4
38
|
/**
|
|
5
39
|
* The CSS component will ensure that the CSS file referenced by its `source` constructor prop is added to your page and loaded by the browser.
|
|
6
40
|
*
|
|
7
41
|
* This component is particularly useful if you'd like to style with CSS any HTML elements that you've added to your Hierarchy.
|
|
8
|
-
*
|
|
9
42
|
* @zcomponent
|
|
10
43
|
* @zicon html
|
|
11
44
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
resolve();
|
|
27
|
-
});
|
|
28
|
-
this._elm[1].addEventListener('error', reject);
|
|
29
|
-
}));
|
|
30
|
-
this._elm[1].setAttribute('rel', 'stylesheet');
|
|
31
|
-
this._elm[1].setAttribute('href', constructorProps.source);
|
|
32
|
-
if (document.head)
|
|
33
|
-
document.head.appendChild(this._elm[1]);
|
|
34
|
-
else if (document.body)
|
|
35
|
-
document.body.appendChild(this._elm[1]);
|
|
36
|
-
alreadyAdded.set(constructorProps.source, this._elm);
|
|
45
|
+
let CSS = (() => {
|
|
46
|
+
let _classDecorators = [zComponent({ icon: 'html' })];
|
|
47
|
+
let _classDescriptor;
|
|
48
|
+
let _classExtraInitializers = [];
|
|
49
|
+
let _classThis;
|
|
50
|
+
let _classSuper = Component;
|
|
51
|
+
var CSS = class extends _classSuper {
|
|
52
|
+
static { _classThis = this; }
|
|
53
|
+
static {
|
|
54
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
55
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
56
|
+
CSS = _classThis = _classDescriptor.value;
|
|
57
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
58
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
37
59
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
60
|
+
constructorProps;
|
|
61
|
+
_elm;
|
|
62
|
+
constructor(contextManager, constructorProps) {
|
|
63
|
+
super(contextManager, constructorProps);
|
|
64
|
+
this.constructorProps = constructorProps;
|
|
65
|
+
if (!constructorProps.source || (constructorProps.includeAtDesignTime === false && isDesignTime(contextManager)))
|
|
66
|
+
return;
|
|
67
|
+
this._elm = alreadyAdded.get(constructorProps.source);
|
|
68
|
+
if (this._elm)
|
|
69
|
+
this._elm[0]++;
|
|
70
|
+
else {
|
|
71
|
+
this._elm = [1, document.createElement('link')];
|
|
72
|
+
registerLoadable(contextManager, new Promise((resolve, reject) => {
|
|
73
|
+
this._elm[1].addEventListener('load', () => {
|
|
74
|
+
contextManager.get(HTMLContext).onCSSChanged.emit();
|
|
75
|
+
resolve();
|
|
76
|
+
});
|
|
77
|
+
this._elm[1].addEventListener('error', reject);
|
|
78
|
+
}));
|
|
79
|
+
this._elm[1].setAttribute('rel', 'stylesheet');
|
|
80
|
+
this._elm[1].setAttribute('href', constructorProps.source);
|
|
81
|
+
if (document.head)
|
|
82
|
+
document.head.appendChild(this._elm[1]);
|
|
83
|
+
else if (document.body)
|
|
84
|
+
document.body.appendChild(this._elm[1]);
|
|
85
|
+
alreadyAdded.set(constructorProps.source, this._elm);
|
|
45
86
|
}
|
|
46
87
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
88
|
+
dispose() {
|
|
89
|
+
if (this._elm) {
|
|
90
|
+
this._elm[0] = this._elm[0] - 1;
|
|
91
|
+
if (this._elm[0] <= 0) {
|
|
92
|
+
this._elm[1]?.remove();
|
|
93
|
+
alreadyAdded.delete(this.constructorProps.source);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return super.dispose();
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
return CSS = _classThis;
|
|
100
|
+
})();
|
|
101
|
+
export { CSS };
|
package/lib/HTMLElement.d.ts
CHANGED
|
@@ -1,146 +1,226 @@
|
|
|
1
|
-
import { Component, ConstructorProps, ContextManager, Event,
|
|
1
|
+
import { Component, ConstructorProps, ContextManager, Event, ValueOf } from '@zcomponent/core';
|
|
2
2
|
export interface HTMLElementProps extends ConstructorProps {
|
|
3
|
+
/**
|
|
4
|
+
* @zignore
|
|
5
|
+
*/
|
|
3
6
|
innerText?: string;
|
|
4
7
|
}
|
|
5
8
|
export declare class ZHTMLElement<T extends HTMLElement> extends Component {
|
|
6
|
-
element: T;
|
|
7
|
-
/** @zprop */
|
|
8
9
|
onClick: Event<[MouseEvent]>;
|
|
9
10
|
/**
|
|
10
|
-
*
|
|
11
|
+
* The inner text of the element.
|
|
12
|
+
* @default ""
|
|
13
|
+
* @zui
|
|
11
14
|
* @ztype text-multiline
|
|
12
|
-
* @zgrouppriority 21
|
|
13
15
|
*/
|
|
14
|
-
innerText:
|
|
16
|
+
innerText: string;
|
|
17
|
+
/**
|
|
18
|
+
* @zignore
|
|
19
|
+
*/
|
|
20
|
+
element: T;
|
|
21
|
+
/**
|
|
22
|
+
* Creates a new ZHTMLElement.
|
|
23
|
+
* @param contextManager - The context manager
|
|
24
|
+
* @param props - The properties of the element
|
|
25
|
+
* @param element - The element to wrap
|
|
26
|
+
*/
|
|
15
27
|
constructor(contextManager: ContextManager, props: HTMLElementProps, element: T);
|
|
16
|
-
|
|
17
|
-
private _connectChild;
|
|
18
|
-
private _cssLengthObservable;
|
|
28
|
+
connectElements(): void;
|
|
19
29
|
private _attachEvent;
|
|
20
|
-
/**
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* @
|
|
30
|
+
/**
|
|
31
|
+
* @default ""
|
|
32
|
+
*/
|
|
33
|
+
id: string;
|
|
34
|
+
/**
|
|
35
|
+
* @default []
|
|
36
|
+
*/
|
|
37
|
+
classList: string[];
|
|
38
|
+
/**
|
|
39
|
+
* @default [0,"px"]
|
|
40
|
+
* @zui
|
|
26
41
|
* @zgroup Position
|
|
27
42
|
*/
|
|
28
|
-
left:
|
|
29
|
-
|
|
30
|
-
|
|
43
|
+
left: [
|
|
44
|
+
number,
|
|
45
|
+
CSSLengthUnitValue
|
|
46
|
+
] | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* @default [0,"px"]
|
|
49
|
+
* @zui
|
|
31
50
|
* @zgroup Position
|
|
32
51
|
*/
|
|
33
|
-
right:
|
|
34
|
-
|
|
35
|
-
|
|
52
|
+
right: [
|
|
53
|
+
number,
|
|
54
|
+
CSSLengthUnitValue
|
|
55
|
+
] | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* @default [0,"px"]
|
|
58
|
+
* @zui
|
|
36
59
|
* @zgroup Position
|
|
37
60
|
*/
|
|
38
|
-
top:
|
|
39
|
-
|
|
40
|
-
|
|
61
|
+
top: [
|
|
62
|
+
number,
|
|
63
|
+
CSSLengthUnitValue
|
|
64
|
+
] | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* @default [0,"px"]
|
|
67
|
+
* @zui
|
|
41
68
|
* @zgroup Position
|
|
42
69
|
*/
|
|
43
|
-
bottom:
|
|
44
|
-
|
|
45
|
-
|
|
70
|
+
bottom: [
|
|
71
|
+
number,
|
|
72
|
+
CSSLengthUnitValue
|
|
73
|
+
] | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* @default [0,"px"]
|
|
76
|
+
* @zui
|
|
46
77
|
* @zgroup Size
|
|
47
78
|
*/
|
|
48
|
-
width:
|
|
49
|
-
|
|
50
|
-
|
|
79
|
+
width: [
|
|
80
|
+
number,
|
|
81
|
+
CSSLengthUnitValue
|
|
82
|
+
] | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* @default [0,"px"]
|
|
85
|
+
* @zui
|
|
51
86
|
* @zgroup Size
|
|
52
87
|
*/
|
|
53
|
-
height:
|
|
54
|
-
|
|
55
|
-
|
|
88
|
+
height: [
|
|
89
|
+
number,
|
|
90
|
+
CSSLengthUnitValue
|
|
91
|
+
] | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* @default [0,"px"]
|
|
94
|
+
* @zui
|
|
56
95
|
* @zgroup Spacing
|
|
57
96
|
*/
|
|
58
|
-
marginLeft:
|
|
59
|
-
|
|
60
|
-
|
|
97
|
+
marginLeft: [
|
|
98
|
+
number,
|
|
99
|
+
CSSLengthUnitValue
|
|
100
|
+
] | undefined;
|
|
101
|
+
/**
|
|
102
|
+
* @default [0,"px"]
|
|
103
|
+
* @zui
|
|
61
104
|
* @zgroup Spacing
|
|
62
105
|
*/
|
|
63
|
-
marginRight:
|
|
64
|
-
|
|
65
|
-
|
|
106
|
+
marginRight: [
|
|
107
|
+
number,
|
|
108
|
+
CSSLengthUnitValue
|
|
109
|
+
] | undefined;
|
|
110
|
+
/**
|
|
111
|
+
* @default [0,"px"]
|
|
112
|
+
* @zui
|
|
66
113
|
* @zgroup Spacing
|
|
67
114
|
*/
|
|
68
|
-
marginTop:
|
|
69
|
-
|
|
70
|
-
|
|
115
|
+
marginTop: [
|
|
116
|
+
number,
|
|
117
|
+
CSSLengthUnitValue
|
|
118
|
+
] | undefined;
|
|
119
|
+
/**
|
|
120
|
+
* @default [0,"px"]
|
|
121
|
+
* @zui
|
|
71
122
|
* @zgroup Spacing
|
|
72
123
|
*/
|
|
73
|
-
marginBottom:
|
|
74
|
-
|
|
75
|
-
|
|
124
|
+
marginBottom: [
|
|
125
|
+
number,
|
|
126
|
+
CSSLengthUnitValue
|
|
127
|
+
] | undefined;
|
|
128
|
+
/**
|
|
129
|
+
* @default [0,"px"]
|
|
130
|
+
* @zui
|
|
76
131
|
* @zgroup Spacing
|
|
77
132
|
*/
|
|
78
|
-
paddingLeft:
|
|
79
|
-
|
|
80
|
-
|
|
133
|
+
paddingLeft: [
|
|
134
|
+
number,
|
|
135
|
+
CSSLengthUnitValue
|
|
136
|
+
] | undefined;
|
|
137
|
+
/**
|
|
138
|
+
* @default [0,"px"]
|
|
139
|
+
* @zui
|
|
81
140
|
* @zgroup Spacing
|
|
82
141
|
*/
|
|
83
|
-
paddingRight:
|
|
84
|
-
|
|
85
|
-
|
|
142
|
+
paddingRight: [
|
|
143
|
+
number,
|
|
144
|
+
CSSLengthUnitValue
|
|
145
|
+
] | undefined;
|
|
146
|
+
/**
|
|
147
|
+
* @default [0,"px"]
|
|
148
|
+
* @zui
|
|
86
149
|
* @zgroup Spacing
|
|
87
150
|
*/
|
|
88
|
-
paddingTop:
|
|
89
|
-
|
|
90
|
-
|
|
151
|
+
paddingTop: [
|
|
152
|
+
number,
|
|
153
|
+
CSSLengthUnitValue
|
|
154
|
+
] | undefined;
|
|
155
|
+
/**
|
|
156
|
+
* @default [0,"px"]
|
|
157
|
+
* @zui
|
|
91
158
|
* @zgroup Spacing
|
|
92
159
|
*/
|
|
93
|
-
paddingBottom:
|
|
94
|
-
|
|
160
|
+
paddingBottom: [
|
|
161
|
+
number,
|
|
162
|
+
CSSLengthUnitValue
|
|
163
|
+
] | undefined;
|
|
164
|
+
/**
|
|
165
|
+
* @default "static"
|
|
166
|
+
* @zui
|
|
95
167
|
* @zgroup Position
|
|
96
|
-
* @zdefault static
|
|
97
168
|
*/
|
|
98
|
-
position:
|
|
99
|
-
/**
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
169
|
+
position: CSSPositionValue;
|
|
170
|
+
/**
|
|
171
|
+
* @zui
|
|
172
|
+
* @zgroup Display
|
|
173
|
+
*/
|
|
174
|
+
display: CSSDisplayValue | undefined;
|
|
175
|
+
/**
|
|
176
|
+
* @default "row"
|
|
177
|
+
* @zui
|
|
178
|
+
* @zgroup Display
|
|
103
179
|
*/
|
|
104
|
-
flexDirection:
|
|
180
|
+
flexDirection: CSSFlexDirectionValue;
|
|
105
181
|
dispose(): never;
|
|
106
182
|
}
|
|
107
|
-
export declare
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
'%'
|
|
123
|
-
}
|
|
124
|
-
export
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
'inline-
|
|
138
|
-
|
|
139
|
-
'inline-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
183
|
+
export declare const CSSLengthUnit: {
|
|
184
|
+
readonly cm: "cm";
|
|
185
|
+
readonly mm: "mm";
|
|
186
|
+
readonly in: "in";
|
|
187
|
+
readonly px: "px";
|
|
188
|
+
readonly pt: "pt";
|
|
189
|
+
readonly pc: "pc";
|
|
190
|
+
readonly em: "em";
|
|
191
|
+
readonly ex: "ex";
|
|
192
|
+
readonly ch: "ch";
|
|
193
|
+
readonly rem: "rem";
|
|
194
|
+
readonly vw: "vw";
|
|
195
|
+
readonly vh: "vh";
|
|
196
|
+
readonly vmin: "vmin";
|
|
197
|
+
readonly vmax: "vmax";
|
|
198
|
+
readonly '%': "%";
|
|
199
|
+
};
|
|
200
|
+
export type CSSLengthUnitValue = ValueOf<typeof CSSLengthUnit>;
|
|
201
|
+
export declare const CSSPosition: {
|
|
202
|
+
readonly static: "static";
|
|
203
|
+
readonly relative: "relative";
|
|
204
|
+
readonly absolute: "absolute";
|
|
205
|
+
readonly fixed: "fixed";
|
|
206
|
+
readonly sticky: "sticky";
|
|
207
|
+
};
|
|
208
|
+
export type CSSPositionValue = ValueOf<typeof CSSPosition>;
|
|
209
|
+
export declare const CSSDisplay: {
|
|
210
|
+
readonly none: "none";
|
|
211
|
+
readonly block: "block";
|
|
212
|
+
readonly inline: "inline";
|
|
213
|
+
readonly 'inline-block': "inline-block";
|
|
214
|
+
readonly flex: "flex";
|
|
215
|
+
readonly 'inline-flex': "inline-flex";
|
|
216
|
+
readonly grid: "grid";
|
|
217
|
+
readonly 'inline-grid': "inline-grid";
|
|
218
|
+
};
|
|
219
|
+
export type CSSDisplayValue = ValueOf<typeof CSSDisplay>;
|
|
220
|
+
export declare const CSSFlexDirection: {
|
|
221
|
+
readonly row: "row";
|
|
222
|
+
readonly 'row-reverse': "row-reverse";
|
|
223
|
+
readonly column: "column";
|
|
224
|
+
readonly 'column-reverse': "column-reverse";
|
|
225
|
+
};
|
|
226
|
+
export type CSSFlexDirectionValue = ValueOf<typeof CSSFlexDirection>;
|