@3t-transform/threeteeui 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{index-8a7479e4.js → index-8a4cb9bc.js} +256 -407
- package/dist/cjs/loader.cjs.js +4 -3
- package/dist/cjs/tttx-button.cjs.entry.js +28 -0
- package/dist/cjs/tttx-checkbox.cjs.entry.js +28 -0
- package/dist/cjs/tttx-form.cjs.entry.js +58 -0
- package/dist/cjs/tttx-icon.cjs.entry.js +1845 -5
- package/dist/cjs/tttx-input.cjs.entry.js +44 -0
- package/dist/cjs/tttx-loading-spinner.cjs.entry.js +26 -0
- package/dist/cjs/tttx-popover-content.cjs.entry.js +23 -0
- package/dist/cjs/tttx.cjs.js +7 -3
- package/dist/collection/collection-manifest.json +9 -5
- package/dist/collection/components/atoms/tttx-button/tttx-button.css +61 -0
- package/dist/collection/components/atoms/tttx-button/tttx-button.js +93 -0
- package/dist/collection/components/atoms/tttx-button/tttx-button.stories.js +27 -0
- package/dist/collection/components/atoms/tttx-icon/tttx-icon.css +101 -0
- package/dist/collection/components/atoms/tttx-icon/tttx-icon.js +114 -0
- package/dist/collection/components/atoms/tttx-icon/tttx-icon.stories.js +47 -0
- package/dist/collection/components/atoms/tttx-loading-spinner/tttx-loading-spinner.css +48 -0
- package/dist/collection/components/atoms/tttx-loading-spinner/tttx-loading-spinner.js +66 -0
- package/dist/collection/components/atoms/tttx-loading-spinner/tttx-loading-spinner.stories.js +15 -0
- package/dist/collection/components/atoms/tttx-popover-content/tttx-popover-content.css +30 -0
- package/dist/collection/components/atoms/tttx-popover-content/tttx-popover-content.js +96 -0
- package/dist/collection/components/atoms/tttx-popover-content/tttx-popover-content.stories.js +23 -0
- package/dist/collection/components/atoms/ttx-checkbox/tttx-checkbox.css +135 -0
- package/dist/collection/components/atoms/ttx-checkbox/tttx-checkbox.js +101 -0
- package/dist/collection/components/atoms/ttx-checkbox/tttx-checkbox.stories.js +13 -0
- package/dist/collection/components/molecules/tttx-form/tttx-form.js +109 -0
- package/dist/collection/components/molecules/tttx-form/tttx-form.stories.js +33 -0
- package/dist/collection/components/molecules/tttx-input/tttx-input.css +149 -0
- package/dist/collection/components/molecules/tttx-input/tttx-input.js +259 -0
- package/dist/collection/components/molecules/tttx-input/tttx-input.stories.js +106 -0
- package/dist/collection/components/palette.stories.js +88 -0
- package/dist/collection/icons.js +2838 -0
- package/dist/components/index.d.ts +16 -3
- package/dist/components/index.js +7 -3
- package/dist/components/{tttx-worksheet.d.ts → tttx-button.d.ts} +4 -4
- package/dist/components/tttx-button.js +45 -0
- package/dist/components/tttx-checkbox.d.ts +11 -0
- package/dist/components/tttx-checkbox.js +46 -0
- package/dist/components/{tttx-page.d.ts → tttx-form.d.ts} +4 -4
- package/dist/components/tttx-form.js +75 -0
- package/dist/components/tttx-icon.js +1 -32
- package/dist/components/tttx-icon2.js +1875 -0
- package/dist/components/tttx-input.d.ts +11 -0
- package/dist/components/tttx-input.js +77 -0
- package/dist/components/tttx-loading-spinner.d.ts +11 -0
- package/dist/components/tttx-loading-spinner.js +43 -0
- package/dist/components/tttx-popover-content.d.ts +11 -0
- package/dist/components/tttx-popover-content.js +42 -0
- package/dist/esm/{index-854ff56f.js → index-9654537d.js} +254 -408
- package/dist/esm/loader.js +4 -3
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/esm/tttx-button.entry.js +24 -0
- package/dist/esm/tttx-checkbox.entry.js +24 -0
- package/dist/esm/tttx-form.entry.js +54 -0
- package/dist/esm/tttx-icon.entry.js +1845 -5
- package/dist/esm/tttx-input.entry.js +40 -0
- package/dist/esm/tttx-loading-spinner.entry.js +22 -0
- package/dist/esm/tttx-popover-content.entry.js +19 -0
- package/dist/esm/tttx.js +4 -3
- package/dist/tttx/p-1884203f.entry.js +1 -0
- package/dist/tttx/p-317b13d3.entry.js +1 -0
- package/dist/tttx/p-3cb692d6.entry.js +1 -0
- package/dist/tttx/p-3cd7ad04.entry.js +1 -0
- package/dist/tttx/p-674e2f18.entry.js +1 -0
- package/dist/tttx/p-a23389f1.entry.js +1 -0
- package/dist/tttx/p-b6cc2780.js +2 -0
- package/dist/tttx/p-f30a0e84.entry.js +1 -0
- package/dist/tttx/tttx.esm.js +1 -1
- package/dist/types/components/atoms/tttx-button/tttx-button.d.ts +9 -0
- package/dist/types/components/atoms/tttx-button/tttx-button.stories.d.ts +20 -0
- package/dist/types/components/atoms/tttx-icon/tttx-icon.d.ts +14 -0
- package/dist/types/components/atoms/tttx-icon/tttx-icon.stories.d.ts +21 -0
- package/dist/types/components/atoms/tttx-loading-spinner/tttx-loading-spinner.d.ts +6 -0
- package/dist/types/components/atoms/tttx-loading-spinner/tttx-loading-spinner.stories.d.ts +5 -0
- package/dist/types/components/atoms/tttx-popover-content/tttx-popover-content.d.ts +7 -0
- package/dist/types/components/atoms/tttx-popover-content/tttx-popover-content.stories.d.ts +18 -0
- package/dist/types/components/atoms/ttx-checkbox/tttx-checkbox.d.ts +9 -0
- package/dist/types/{docs/template.stories.d.ts → components/atoms/ttx-checkbox/tttx-checkbox.stories.d.ts} +1 -0
- package/dist/types/components/molecules/tttx-form/tttx-form.d.ts +11 -0
- package/dist/types/components/molecules/tttx-form/tttx-form.stories.d.ts +13 -0
- package/dist/types/components/molecules/tttx-input/tttx-input.d.ts +20 -0
- package/dist/types/components/molecules/tttx-input/tttx-input.stories.d.ts +60 -0
- package/dist/types/components/palette.stories.d.ts +6 -0
- package/dist/types/components.d.ts +142 -38
- package/dist/types/icons.d.ts +2 -0
- package/dist/types/stencil-public-runtime.d.ts +59 -3
- package/loader/index.d.ts +9 -0
- package/package.json +33 -25
- package/readme.md +14 -32
- package/dist/cjs/toolbar-656be6e6.js +0 -34259
- package/dist/cjs/tttx-page.cjs.entry.js +0 -927
- package/dist/cjs/tttx-worksheet.cjs.entry.js +0 -47
- package/dist/collection/components/components/tttx-icon/tttx-icon.css +0 -89
- package/dist/collection/components/components/tttx-icon/tttx-icon.js +0 -59
- package/dist/collection/components/components/tttx-icon/tttx-icon.stories.js +0 -40
- package/dist/collection/components/patterns/tttx-page/tttx-page.css +0 -162
- package/dist/collection/components/patterns/tttx-page/tttx-page.js +0 -213
- package/dist/collection/components/patterns/tttx-page/tttx-page.stories.js +0 -80
- package/dist/collection/components/patterns/tttx-worksheet/tttx-worksheet.css +0 -134
- package/dist/collection/components/patterns/tttx-worksheet/tttx-worksheet.js +0 -70
- package/dist/collection/components/patterns/tttx-worksheet/tttx-worksheet.stories.js +0 -44
- package/dist/collection/docs/template.stories.js +0 -10
- package/dist/components/tttx-page.js +0 -953
- package/dist/components/tttx-worksheet.js +0 -6
- package/dist/components/tttx-worksheet2.js +0 -34288
- package/dist/esm/toolbar-cede4385.js +0 -34231
- package/dist/esm/tttx-page.entry.js +0 -923
- package/dist/esm/tttx-worksheet.entry.js +0 -43
- package/dist/tttx/p-4b57de2e.entry.js +0 -1
- package/dist/tttx/p-61f78304.entry.js +0 -1
- package/dist/tttx/p-7244abd4.entry.js +0 -1
- package/dist/tttx/p-d038fe18.js +0 -1
- package/dist/tttx/p-ddfeb0ba.js +0 -2
- package/dist/tttx/tttx.css +0 -1
- package/dist/types/components/components/tttx-icon/tttx-icon.d.ts +0 -5
- package/dist/types/components/components/tttx-icon/tttx-icon.stories.d.ts +0 -24
- package/dist/types/components/patterns/tttx-page/tttx-page.d.ts +0 -21
- package/dist/types/components/patterns/tttx-page/tttx-page.stories.d.ts +0 -48
- package/dist/types/components/patterns/tttx-worksheet/tttx-worksheet.d.ts +0 -9
- package/dist/types/components/patterns/tttx-worksheet/tttx-worksheet.stories.d.ts +0 -23
|
@@ -8,11 +8,8 @@ const NAMESPACE = 'tttx';
|
|
|
8
8
|
*
|
|
9
9
|
* Modified for Stencil's renderer and slot projection
|
|
10
10
|
*/
|
|
11
|
-
let
|
|
11
|
+
let scopeId;
|
|
12
12
|
let hostTagName;
|
|
13
|
-
let useNativeShadowDom = false;
|
|
14
|
-
let checkSlotFallbackVisibility = false;
|
|
15
|
-
let checkSlotRelocate = false;
|
|
16
13
|
let isSvgMode = false;
|
|
17
14
|
let queuePending = false;
|
|
18
15
|
const createTime = (fnName, tagName = '') => {
|
|
@@ -38,11 +35,24 @@ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
|
38
35
|
* Don't add values to these!!
|
|
39
36
|
*/
|
|
40
37
|
const EMPTY_OBJ = {};
|
|
38
|
+
const isDef = (v) => v != null;
|
|
41
39
|
const isComplexType = (o) => {
|
|
42
40
|
// https://jsperf.com/typeof-fn-object/5
|
|
43
41
|
o = typeof o;
|
|
44
42
|
return o === 'object' || o === 'function';
|
|
45
43
|
};
|
|
44
|
+
/**
|
|
45
|
+
* Helper method for querying a `meta` tag that contains a nonce value
|
|
46
|
+
* out of a DOM's head.
|
|
47
|
+
*
|
|
48
|
+
* @param doc The DOM containing the `head` to query against
|
|
49
|
+
* @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
|
|
50
|
+
* exists or the tag has no content.
|
|
51
|
+
*/
|
|
52
|
+
function queryNonceMetaTagContent(doc) {
|
|
53
|
+
var _a, _b, _c;
|
|
54
|
+
return (_c = (_b = (_a = doc.head) === null || _a === void 0 ? void 0 : _a.querySelector('meta[name="csp-nonce"]')) === null || _b === void 0 ? void 0 : _b.getAttribute('content')) !== null && _c !== void 0 ? _c : undefined;
|
|
55
|
+
}
|
|
46
56
|
/**
|
|
47
57
|
* Production h() function based on Preact by
|
|
48
58
|
* Jason Miller (@developit)
|
|
@@ -51,12 +61,10 @@ const isComplexType = (o) => {
|
|
|
51
61
|
*
|
|
52
62
|
* Modified for Stencil's compiler and vdom
|
|
53
63
|
*/
|
|
54
|
-
// const stack: any[] = [];
|
|
55
64
|
// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
|
|
56
65
|
// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
|
|
57
66
|
const h = (nodeName, vnodeData, ...children) => {
|
|
58
67
|
let child = null;
|
|
59
|
-
let slotName = null;
|
|
60
68
|
let simple = false;
|
|
61
69
|
let lastSimple = false;
|
|
62
70
|
const vNodeChildren = [];
|
|
@@ -84,9 +92,6 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
84
92
|
};
|
|
85
93
|
walk(children);
|
|
86
94
|
if (vnodeData) {
|
|
87
|
-
if (vnodeData.name) {
|
|
88
|
-
slotName = vnodeData.name;
|
|
89
|
-
}
|
|
90
95
|
{
|
|
91
96
|
const classData = vnodeData.className || vnodeData.class;
|
|
92
97
|
if (classData) {
|
|
@@ -104,11 +109,16 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
104
109
|
if (vNodeChildren.length > 0) {
|
|
105
110
|
vnode.$children$ = vNodeChildren;
|
|
106
111
|
}
|
|
107
|
-
{
|
|
108
|
-
vnode.$name$ = slotName;
|
|
109
|
-
}
|
|
110
112
|
return vnode;
|
|
111
113
|
};
|
|
114
|
+
/**
|
|
115
|
+
* A utility function for creating a virtual DOM node from a tag and some
|
|
116
|
+
* possible text content.
|
|
117
|
+
*
|
|
118
|
+
* @param tag the tag for this element
|
|
119
|
+
* @param text possible text content for the node
|
|
120
|
+
* @returns a newly-minted virtual DOM node
|
|
121
|
+
*/
|
|
112
122
|
const newVNode = (tag, text) => {
|
|
113
123
|
const vnode = {
|
|
114
124
|
$flags$: 0,
|
|
@@ -120,12 +130,15 @@ const newVNode = (tag, text) => {
|
|
|
120
130
|
{
|
|
121
131
|
vnode.$attrs$ = null;
|
|
122
132
|
}
|
|
123
|
-
{
|
|
124
|
-
vnode.$name$ = null;
|
|
125
|
-
}
|
|
126
133
|
return vnode;
|
|
127
134
|
};
|
|
128
135
|
const Host = {};
|
|
136
|
+
/**
|
|
137
|
+
* Check whether a given node is a Host node or not
|
|
138
|
+
*
|
|
139
|
+
* @param node the virtual DOM node to check
|
|
140
|
+
* @returns whether it's a Host node or not
|
|
141
|
+
*/
|
|
129
142
|
const isHost = (node) => node && node.$tag$ === Host;
|
|
130
143
|
/**
|
|
131
144
|
* Parse a new property value for a given property type.
|
|
@@ -153,6 +166,11 @@ const isHost = (node) => node && node.$tag$ === Host;
|
|
|
153
166
|
const parsePropertyValue = (propValue, propType) => {
|
|
154
167
|
// ensure this value is of the correct prop type
|
|
155
168
|
if (propValue != null && !isComplexType(propValue)) {
|
|
169
|
+
if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
|
|
170
|
+
// per the HTML spec, any string value means it is a boolean true value
|
|
171
|
+
// but we'll cheat here and say that the string "false" is the boolean false
|
|
172
|
+
return propValue === 'false' ? false : propValue === '' || !!propValue;
|
|
173
|
+
}
|
|
156
174
|
if (propType & 1 /* MEMBER_FLAGS.String */) {
|
|
157
175
|
// could have been passed as a number or boolean
|
|
158
176
|
// but we still want it as a string
|
|
@@ -165,6 +183,20 @@ const parsePropertyValue = (propValue, propType) => {
|
|
|
165
183
|
// so no need to change to a different type
|
|
166
184
|
return propValue;
|
|
167
185
|
};
|
|
186
|
+
const getElement = (ref) => (getHostRef(ref).$hostElement$ );
|
|
187
|
+
const createEvent = (ref, name, flags) => {
|
|
188
|
+
const elm = getElement(ref);
|
|
189
|
+
return {
|
|
190
|
+
emit: (detail) => {
|
|
191
|
+
return emitEvent(elm, name, {
|
|
192
|
+
bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
|
|
193
|
+
composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
|
|
194
|
+
cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
|
|
195
|
+
detail,
|
|
196
|
+
});
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
};
|
|
168
200
|
/**
|
|
169
201
|
* Helper function to create & dispatch a custom Event on a provided target
|
|
170
202
|
* @param elm the target of the Event
|
|
@@ -195,6 +227,7 @@ const registerStyle = (scopeId, cssText, allowCS) => {
|
|
|
195
227
|
styles.set(scopeId, style);
|
|
196
228
|
};
|
|
197
229
|
const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
230
|
+
var _a;
|
|
198
231
|
let scopeId = getScopeId(cmpMeta);
|
|
199
232
|
const style = styles.get(scopeId);
|
|
200
233
|
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
@@ -214,6 +247,11 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
|
214
247
|
styleElm = doc.createElement('style');
|
|
215
248
|
styleElm.innerHTML = style;
|
|
216
249
|
}
|
|
250
|
+
// Apply CSP nonce to the style tag if it exists
|
|
251
|
+
const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
|
|
252
|
+
if (nonce != null) {
|
|
253
|
+
styleElm.setAttribute('nonce', nonce);
|
|
254
|
+
}
|
|
217
255
|
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
218
256
|
}
|
|
219
257
|
if (appliedStyles) {
|
|
@@ -230,8 +268,20 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
|
230
268
|
const attachStyles = (hostRef) => {
|
|
231
269
|
const cmpMeta = hostRef.$cmpMeta$;
|
|
232
270
|
const elm = hostRef.$hostElement$;
|
|
271
|
+
const flags = cmpMeta.$flags$;
|
|
233
272
|
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
234
|
-
addStyle(elm.getRootNode(), cmpMeta);
|
|
273
|
+
const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
|
|
274
|
+
if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
|
|
275
|
+
// only required when we're NOT using native shadow dom (slot)
|
|
276
|
+
// or this browser doesn't support native shadow dom
|
|
277
|
+
// and this host element was NOT created with SSR
|
|
278
|
+
// let's pick out the inner content for slot projection
|
|
279
|
+
// create a node to represent where the original
|
|
280
|
+
// content was first placed, which is useful later on
|
|
281
|
+
// DOM WRITE!!
|
|
282
|
+
elm['s-sc'] = scopeId;
|
|
283
|
+
elm.classList.add(scopeId + '-h');
|
|
284
|
+
}
|
|
235
285
|
endAttachStyles();
|
|
236
286
|
};
|
|
237
287
|
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
@@ -246,7 +296,7 @@ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
|
246
296
|
const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
247
297
|
if (oldValue !== newValue) {
|
|
248
298
|
let isProp = isMemberInElement(elm, memberName);
|
|
249
|
-
memberName.toLowerCase();
|
|
299
|
+
let ln = memberName.toLowerCase();
|
|
250
300
|
if (memberName === 'class') {
|
|
251
301
|
const classList = elm.classList;
|
|
252
302
|
const oldClasses = parseClassList(oldValue);
|
|
@@ -254,37 +304,51 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
254
304
|
classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
|
|
255
305
|
classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
|
|
256
306
|
}
|
|
257
|
-
else if (memberName === 'style') {
|
|
258
|
-
// update style attribute, css properties and values
|
|
259
|
-
{
|
|
260
|
-
for (const prop in oldValue) {
|
|
261
|
-
if (!newValue || newValue[prop] == null) {
|
|
262
|
-
if (prop.includes('-')) {
|
|
263
|
-
elm.style.removeProperty(prop);
|
|
264
|
-
}
|
|
265
|
-
else {
|
|
266
|
-
elm.style[prop] = '';
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
for (const prop in newValue) {
|
|
272
|
-
if (!oldValue || newValue[prop] !== oldValue[prop]) {
|
|
273
|
-
if (prop.includes('-')) {
|
|
274
|
-
elm.style.setProperty(prop, newValue[prop]);
|
|
275
|
-
}
|
|
276
|
-
else {
|
|
277
|
-
elm.style[prop] = newValue[prop];
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
307
|
else if (memberName === 'ref') {
|
|
283
308
|
// minifier will clean this up
|
|
284
309
|
if (newValue) {
|
|
285
310
|
newValue(elm);
|
|
286
311
|
}
|
|
287
312
|
}
|
|
313
|
+
else if ((!isProp ) &&
|
|
314
|
+
memberName[0] === 'o' &&
|
|
315
|
+
memberName[1] === 'n') {
|
|
316
|
+
// Event Handlers
|
|
317
|
+
// so if the member name starts with "on" and the 3rd characters is
|
|
318
|
+
// a capital letter, and it's not already a member on the element,
|
|
319
|
+
// then we're assuming it's an event listener
|
|
320
|
+
if (memberName[2] === '-') {
|
|
321
|
+
// on- prefixed events
|
|
322
|
+
// allows to be explicit about the dom event to listen without any magic
|
|
323
|
+
// under the hood:
|
|
324
|
+
// <my-cmp on-click> // listens for "click"
|
|
325
|
+
// <my-cmp on-Click> // listens for "Click"
|
|
326
|
+
// <my-cmp on-ionChange> // listens for "ionChange"
|
|
327
|
+
// <my-cmp on-EVENTS> // listens for "EVENTS"
|
|
328
|
+
memberName = memberName.slice(3);
|
|
329
|
+
}
|
|
330
|
+
else if (isMemberInElement(win, ln)) {
|
|
331
|
+
// standard event
|
|
332
|
+
// the JSX attribute could have been "onMouseOver" and the
|
|
333
|
+
// member name "onmouseover" is on the window's prototype
|
|
334
|
+
// so let's add the listener "mouseover", which is all lowercased
|
|
335
|
+
memberName = ln.slice(2);
|
|
336
|
+
}
|
|
337
|
+
else {
|
|
338
|
+
// custom event
|
|
339
|
+
// the JSX attribute could have been "onMyCustomEvent"
|
|
340
|
+
// so let's trim off the "on" prefix and lowercase the first character
|
|
341
|
+
// and add the listener "myCustomEvent"
|
|
342
|
+
// except for the first character, we keep the event name case
|
|
343
|
+
memberName = ln[2] + memberName.slice(3);
|
|
344
|
+
}
|
|
345
|
+
if (oldValue) {
|
|
346
|
+
plt.rel(elm, memberName, oldValue, false);
|
|
347
|
+
}
|
|
348
|
+
if (newValue) {
|
|
349
|
+
plt.ael(elm, memberName, newValue, false);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
288
352
|
else {
|
|
289
353
|
// Set property if it exists and it's not a SVG
|
|
290
354
|
const isComplex = isComplexType(newValue);
|
|
@@ -362,36 +426,22 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
362
426
|
let i = 0;
|
|
363
427
|
let elm;
|
|
364
428
|
let childNode;
|
|
365
|
-
let oldVNode;
|
|
366
|
-
if (!useNativeShadowDom) {
|
|
367
|
-
// remember for later we need to check to relocate nodes
|
|
368
|
-
checkSlotRelocate = true;
|
|
369
|
-
if (newVNode.$tag$ === 'slot') {
|
|
370
|
-
newVNode.$flags$ |= newVNode.$children$
|
|
371
|
-
? // slot element has fallback content
|
|
372
|
-
2 /* VNODE_FLAGS.isSlotFallback */
|
|
373
|
-
: // slot element does not have fallback content
|
|
374
|
-
1 /* VNODE_FLAGS.isSlotReference */;
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
429
|
if (newVNode.$text$ !== null) {
|
|
378
430
|
// create text node
|
|
379
431
|
elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
|
|
380
432
|
}
|
|
381
|
-
else if (newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
|
|
382
|
-
// create a slot reference node
|
|
383
|
-
elm = newVNode.$elm$ =
|
|
384
|
-
doc.createTextNode('');
|
|
385
|
-
}
|
|
386
433
|
else {
|
|
387
434
|
// create element
|
|
388
|
-
elm = newVNode.$elm$ = (doc.createElement(newVNode.$
|
|
389
|
-
? 'slot-fb'
|
|
390
|
-
: newVNode.$tag$));
|
|
435
|
+
elm = newVNode.$elm$ = (doc.createElement(newVNode.$tag$));
|
|
391
436
|
// add css classes, attrs, props, listeners, etc.
|
|
392
437
|
{
|
|
393
438
|
updateElement(null, newVNode, isSvgMode);
|
|
394
439
|
}
|
|
440
|
+
if (isDef(scopeId) && elm['s-si'] !== scopeId) {
|
|
441
|
+
// if there is a scopeId and this is the initial render
|
|
442
|
+
// then let's add the scopeId as a css class
|
|
443
|
+
elm.classList.add((elm['s-si'] = scopeId));
|
|
444
|
+
}
|
|
395
445
|
if (newVNode.$children$) {
|
|
396
446
|
for (i = 0; i < newVNode.$children$.length; ++i) {
|
|
397
447
|
// create the node
|
|
@@ -404,82 +454,57 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
404
454
|
}
|
|
405
455
|
}
|
|
406
456
|
}
|
|
407
|
-
{
|
|
408
|
-
elm['s-hn'] = hostTagName;
|
|
409
|
-
if (newVNode.$flags$ & (2 /* VNODE_FLAGS.isSlotFallback */ | 1 /* VNODE_FLAGS.isSlotReference */)) {
|
|
410
|
-
// remember the content reference comment
|
|
411
|
-
elm['s-sr'] = true;
|
|
412
|
-
// remember the content reference comment
|
|
413
|
-
elm['s-cr'] = contentRef;
|
|
414
|
-
// remember the slot name, or empty string for default slot
|
|
415
|
-
elm['s-sn'] = newVNode.$name$ || '';
|
|
416
|
-
// check if we've got an old vnode for this slot
|
|
417
|
-
oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
|
|
418
|
-
if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
|
|
419
|
-
// we've got an old slot vnode and the wrapper is being replaced
|
|
420
|
-
// so let's move the old slot content back to it's original location
|
|
421
|
-
putBackInOriginalLocation(oldParentVNode.$elm$, false);
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
457
|
return elm;
|
|
426
458
|
};
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
childNode['s-ol'] = undefined;
|
|
443
|
-
checkSlotRelocate = true;
|
|
444
|
-
}
|
|
445
|
-
if (recursive) {
|
|
446
|
-
putBackInOriginalLocation(childNode, recursive);
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
450
|
-
};
|
|
459
|
+
/**
|
|
460
|
+
* Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
|
|
461
|
+
* add them to the DOM in the appropriate place.
|
|
462
|
+
*
|
|
463
|
+
* @param parentElm the DOM node which should be used as a parent for the new
|
|
464
|
+
* DOM nodes
|
|
465
|
+
* @param before a child of the `parentElm` which the new children should be
|
|
466
|
+
* inserted before (optional)
|
|
467
|
+
* @param parentVNode the parent virtual DOM node
|
|
468
|
+
* @param vnodes the new child virtual DOM nodes to produce DOM nodes for
|
|
469
|
+
* @param startIdx the index in the child virtual DOM nodes at which to start
|
|
470
|
+
* creating DOM nodes (inclusive)
|
|
471
|
+
* @param endIdx the index in the child virtual DOM nodes at which to stop
|
|
472
|
+
* creating DOM nodes (inclusive)
|
|
473
|
+
*/
|
|
451
474
|
const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
|
|
452
|
-
let containerElm = (
|
|
475
|
+
let containerElm = (parentElm);
|
|
453
476
|
let childNode;
|
|
477
|
+
if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
|
|
478
|
+
containerElm = containerElm.shadowRoot;
|
|
479
|
+
}
|
|
454
480
|
for (; startIdx <= endIdx; ++startIdx) {
|
|
455
481
|
if (vnodes[startIdx]) {
|
|
456
482
|
childNode = createElm(null, parentVNode, startIdx);
|
|
457
483
|
if (childNode) {
|
|
458
484
|
vnodes[startIdx].$elm$ = childNode;
|
|
459
|
-
containerElm.insertBefore(childNode,
|
|
485
|
+
containerElm.insertBefore(childNode, before);
|
|
460
486
|
}
|
|
461
487
|
}
|
|
462
488
|
}
|
|
463
489
|
};
|
|
490
|
+
/**
|
|
491
|
+
* Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
|
|
492
|
+
* This can be used to, for instance, clean up after a list of children which
|
|
493
|
+
* should no longer be shown.
|
|
494
|
+
*
|
|
495
|
+
* This function also handles some of Stencil's slot relocation logic.
|
|
496
|
+
*
|
|
497
|
+
* @param vnodes a list of virtual DOM nodes to remove
|
|
498
|
+
* @param startIdx the index at which to start removing nodes (inclusive)
|
|
499
|
+
* @param endIdx the index at which to stop removing nodes (inclusive)
|
|
500
|
+
* @param vnode a VNode
|
|
501
|
+
* @param elm an element
|
|
502
|
+
*/
|
|
464
503
|
const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
|
|
465
504
|
for (; startIdx <= endIdx; ++startIdx) {
|
|
466
505
|
if ((vnode = vnodes[startIdx])) {
|
|
467
506
|
elm = vnode.$elm$;
|
|
468
507
|
callNodeRefs(vnode);
|
|
469
|
-
{
|
|
470
|
-
// we're removing this element
|
|
471
|
-
// so it's possible we need to show slot fallback content now
|
|
472
|
-
checkSlotFallbackVisibility = true;
|
|
473
|
-
if (elm['s-ol']) {
|
|
474
|
-
// remove the original location comment
|
|
475
|
-
elm['s-ol'].remove();
|
|
476
|
-
}
|
|
477
|
-
else {
|
|
478
|
-
// it's possible that child nodes of the node
|
|
479
|
-
// that's being removed are slot nodes
|
|
480
|
-
putBackInOriginalLocation(elm, true);
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
508
|
// remove the vnode's element from the dom
|
|
484
509
|
elm.remove();
|
|
485
510
|
}
|
|
@@ -595,23 +620,6 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
595
620
|
newEndVnode = newCh[--newEndIdx];
|
|
596
621
|
}
|
|
597
622
|
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
598
|
-
// case: "Vnode moved right"
|
|
599
|
-
//
|
|
600
|
-
// We've found that the last node in our window on the new children is
|
|
601
|
-
// the same VNode as the _first_ node in our window on the old children
|
|
602
|
-
// we're dealing with now. Visually, this is the layout of these two
|
|
603
|
-
// nodes:
|
|
604
|
-
//
|
|
605
|
-
// newCh: [..., newStartVnode , ... , newEndVnode , ...]
|
|
606
|
-
// ^^^^^^^^^^^
|
|
607
|
-
// oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
|
|
608
|
-
// ^^^^^^^^^^^^^
|
|
609
|
-
//
|
|
610
|
-
// In this situation we need to patch `newEndVnode` onto `oldStartVnode`
|
|
611
|
-
// and move the DOM element for `oldStartVnode`.
|
|
612
|
-
if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
613
|
-
putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
|
|
614
|
-
}
|
|
615
623
|
patch(oldStartVnode, newEndVnode);
|
|
616
624
|
// We need to move the element for `oldStartVnode` into a position which
|
|
617
625
|
// will be appropriate for `newEndVnode`. For this we can use
|
|
@@ -635,24 +643,6 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
635
643
|
newEndVnode = newCh[--newEndIdx];
|
|
636
644
|
}
|
|
637
645
|
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
638
|
-
// case: "Vnode moved left"
|
|
639
|
-
//
|
|
640
|
-
// We've found that the first node in our window on the new children is
|
|
641
|
-
// the same VNode as the _last_ node in our window on the old children.
|
|
642
|
-
// Visually, this is the layout of these two nodes:
|
|
643
|
-
//
|
|
644
|
-
// newCh: [..., newStartVnode , ... , newEndVnode , ...]
|
|
645
|
-
// ^^^^^^^^^^^^^
|
|
646
|
-
// oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
|
|
647
|
-
// ^^^^^^^^^^^
|
|
648
|
-
//
|
|
649
|
-
// In this situation we need to patch `newStartVnode` onto `oldEndVnode`
|
|
650
|
-
// (which will handle updating any changed attributes, reconciling their
|
|
651
|
-
// children etc) but we also need to move the DOM node to which
|
|
652
|
-
// `oldEndVnode` corresponds.
|
|
653
|
-
if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
654
|
-
putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
|
|
655
|
-
}
|
|
656
646
|
patch(oldEndVnode, newStartVnode);
|
|
657
647
|
// We've already checked above if `oldStartVnode` and `newStartVnode` are
|
|
658
648
|
// the same node, so since we're here we know that they are not. Thus we
|
|
@@ -675,7 +665,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
675
665
|
if (node) {
|
|
676
666
|
// if we created a new node then handle inserting it to the DOM
|
|
677
667
|
{
|
|
678
|
-
|
|
668
|
+
oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
|
|
679
669
|
}
|
|
680
670
|
}
|
|
681
671
|
}
|
|
@@ -702,7 +692,8 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
702
692
|
*
|
|
703
693
|
* So, in other words, if `key` attrs are not set on VNodes which may be
|
|
704
694
|
* changing order within a `children` array or something along those lines then
|
|
705
|
-
* we could obtain a false
|
|
695
|
+
* we could obtain a false negative and then have to do needless re-rendering
|
|
696
|
+
* (i.e. we'd say two VNodes aren't equal when in fact they should be).
|
|
706
697
|
*
|
|
707
698
|
* @param leftVNode the first VNode to check
|
|
708
699
|
* @param rightVNode the second VNode to check
|
|
@@ -712,21 +703,10 @@ const isSameVnode = (leftVNode, rightVNode) => {
|
|
|
712
703
|
// compare if two vnode to see if they're "technically" the same
|
|
713
704
|
// need to have the same element tag, and same key to be the same
|
|
714
705
|
if (leftVNode.$tag$ === rightVNode.$tag$) {
|
|
715
|
-
if (leftVNode.$tag$ === 'slot') {
|
|
716
|
-
return leftVNode.$name$ === rightVNode.$name$;
|
|
717
|
-
}
|
|
718
706
|
return true;
|
|
719
707
|
}
|
|
720
708
|
return false;
|
|
721
709
|
};
|
|
722
|
-
const referenceNode = (node) => {
|
|
723
|
-
// this node was relocated to a new location in the dom
|
|
724
|
-
// because of some other component's slot
|
|
725
|
-
// but we still have an html comment in place of where
|
|
726
|
-
// it's original location was according to it's original vdom
|
|
727
|
-
return (node && node['s-ol']) || node;
|
|
728
|
-
};
|
|
729
|
-
const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
|
|
730
710
|
/**
|
|
731
711
|
* Handle reconciling an outdated VNode with a new one which corresponds to
|
|
732
712
|
* it. This function handles flushing updates to the DOM and reconciling the
|
|
@@ -741,7 +721,6 @@ const patch = (oldVNode, newVNode) => {
|
|
|
741
721
|
const newChildren = newVNode.$children$;
|
|
742
722
|
const tag = newVNode.$tag$;
|
|
743
723
|
const text = newVNode.$text$;
|
|
744
|
-
let defaultHolder;
|
|
745
724
|
if (text === null) {
|
|
746
725
|
{
|
|
747
726
|
if (tag === 'slot')
|
|
@@ -772,247 +751,44 @@ const patch = (oldVNode, newVNode) => {
|
|
|
772
751
|
removeVnodes(oldChildren, 0, oldChildren.length - 1);
|
|
773
752
|
}
|
|
774
753
|
}
|
|
775
|
-
else if ((defaultHolder = elm['s-cr'])) {
|
|
776
|
-
// this element has slotted content
|
|
777
|
-
defaultHolder.parentNode.textContent = text;
|
|
778
|
-
}
|
|
779
754
|
else if (oldVNode.$text$ !== text) {
|
|
780
755
|
// update the text content for the text only vnode
|
|
781
756
|
// and also only if the text is different than before
|
|
782
757
|
elm.data = text;
|
|
783
758
|
}
|
|
784
759
|
};
|
|
785
|
-
const updateFallbackSlotVisibility = (elm) => {
|
|
786
|
-
// tslint:disable-next-line: prefer-const
|
|
787
|
-
const childNodes = elm.childNodes;
|
|
788
|
-
let childNode;
|
|
789
|
-
let i;
|
|
790
|
-
let ilen;
|
|
791
|
-
let j;
|
|
792
|
-
let slotNameAttr;
|
|
793
|
-
let nodeType;
|
|
794
|
-
for (i = 0, ilen = childNodes.length; i < ilen; i++) {
|
|
795
|
-
childNode = childNodes[i];
|
|
796
|
-
if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
797
|
-
if (childNode['s-sr']) {
|
|
798
|
-
// this is a slot fallback node
|
|
799
|
-
// get the slot name for this slot reference node
|
|
800
|
-
slotNameAttr = childNode['s-sn'];
|
|
801
|
-
// by default always show a fallback slot node
|
|
802
|
-
// then hide it if there are other slots in the light dom
|
|
803
|
-
childNode.hidden = false;
|
|
804
|
-
for (j = 0; j < ilen; j++) {
|
|
805
|
-
nodeType = childNodes[j].nodeType;
|
|
806
|
-
if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
|
|
807
|
-
// this sibling node is from a different component OR is a named fallback slot node
|
|
808
|
-
if (nodeType === 1 /* NODE_TYPE.ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
|
|
809
|
-
childNode.hidden = true;
|
|
810
|
-
break;
|
|
811
|
-
}
|
|
812
|
-
}
|
|
813
|
-
else {
|
|
814
|
-
// this is a default fallback slot node
|
|
815
|
-
// any element or text node (with content)
|
|
816
|
-
// should hide the default fallback slot node
|
|
817
|
-
if (nodeType === 1 /* NODE_TYPE.ElementNode */ ||
|
|
818
|
-
(nodeType === 3 /* NODE_TYPE.TextNode */ && childNodes[j].textContent.trim() !== '')) {
|
|
819
|
-
childNode.hidden = true;
|
|
820
|
-
break;
|
|
821
|
-
}
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
|
-
}
|
|
825
|
-
// keep drilling down
|
|
826
|
-
updateFallbackSlotVisibility(childNode);
|
|
827
|
-
}
|
|
828
|
-
}
|
|
829
|
-
};
|
|
830
|
-
const relocateNodes = [];
|
|
831
|
-
const relocateSlotContent = (elm) => {
|
|
832
|
-
// tslint:disable-next-line: prefer-const
|
|
833
|
-
let childNode;
|
|
834
|
-
let node;
|
|
835
|
-
let hostContentNodes;
|
|
836
|
-
let slotNameAttr;
|
|
837
|
-
let relocateNodeData;
|
|
838
|
-
let j;
|
|
839
|
-
let i = 0;
|
|
840
|
-
const childNodes = elm.childNodes;
|
|
841
|
-
const ilen = childNodes.length;
|
|
842
|
-
for (; i < ilen; i++) {
|
|
843
|
-
childNode = childNodes[i];
|
|
844
|
-
if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
|
|
845
|
-
// first got the content reference comment node
|
|
846
|
-
// then we got it's parent, which is where all the host content is in now
|
|
847
|
-
hostContentNodes = node.parentNode.childNodes;
|
|
848
|
-
slotNameAttr = childNode['s-sn'];
|
|
849
|
-
for (j = hostContentNodes.length - 1; j >= 0; j--) {
|
|
850
|
-
node = hostContentNodes[j];
|
|
851
|
-
if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
|
|
852
|
-
// let's do some relocating to its new home
|
|
853
|
-
// but never relocate a content reference node
|
|
854
|
-
// that is suppose to always represent the original content location
|
|
855
|
-
if (isNodeLocatedInSlot(node, slotNameAttr)) {
|
|
856
|
-
// it's possible we've already decided to relocate this node
|
|
857
|
-
relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
|
|
858
|
-
// made some changes to slots
|
|
859
|
-
// let's make sure we also double check
|
|
860
|
-
// fallbacks are correctly hidden or shown
|
|
861
|
-
checkSlotFallbackVisibility = true;
|
|
862
|
-
node['s-sn'] = node['s-sn'] || slotNameAttr;
|
|
863
|
-
if (relocateNodeData) {
|
|
864
|
-
// previously we never found a slot home for this node
|
|
865
|
-
// but turns out we did, so let's remember it now
|
|
866
|
-
relocateNodeData.$slotRefNode$ = childNode;
|
|
867
|
-
}
|
|
868
|
-
else {
|
|
869
|
-
// add to our list of nodes to relocate
|
|
870
|
-
relocateNodes.push({
|
|
871
|
-
$slotRefNode$: childNode,
|
|
872
|
-
$nodeToRelocate$: node,
|
|
873
|
-
});
|
|
874
|
-
}
|
|
875
|
-
if (node['s-sr']) {
|
|
876
|
-
relocateNodes.map((relocateNode) => {
|
|
877
|
-
if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
|
|
878
|
-
relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
|
|
879
|
-
if (relocateNodeData && !relocateNode.$slotRefNode$) {
|
|
880
|
-
relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
|
|
881
|
-
}
|
|
882
|
-
}
|
|
883
|
-
});
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
|
|
887
|
-
// so far this element does not have a slot home, not setting slotRefNode on purpose
|
|
888
|
-
// if we never find a home for this element then we'll need to hide it
|
|
889
|
-
relocateNodes.push({
|
|
890
|
-
$nodeToRelocate$: node,
|
|
891
|
-
});
|
|
892
|
-
}
|
|
893
|
-
}
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
897
|
-
relocateSlotContent(childNode);
|
|
898
|
-
}
|
|
899
|
-
}
|
|
900
|
-
};
|
|
901
|
-
const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
|
|
902
|
-
if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
903
|
-
if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
|
|
904
|
-
return true;
|
|
905
|
-
}
|
|
906
|
-
if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
|
|
907
|
-
return true;
|
|
908
|
-
}
|
|
909
|
-
return false;
|
|
910
|
-
}
|
|
911
|
-
if (nodeToRelocate['s-sn'] === slotNameAttr) {
|
|
912
|
-
return true;
|
|
913
|
-
}
|
|
914
|
-
return slotNameAttr === '';
|
|
915
|
-
};
|
|
916
760
|
const callNodeRefs = (vNode) => {
|
|
917
761
|
{
|
|
918
762
|
vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
|
|
919
763
|
vNode.$children$ && vNode.$children$.map(callNodeRefs);
|
|
920
764
|
}
|
|
921
765
|
};
|
|
766
|
+
/**
|
|
767
|
+
* The main entry point for Stencil's virtual DOM-based rendering engine
|
|
768
|
+
*
|
|
769
|
+
* Given a {@link d.HostRef} container and some virtual DOM nodes, this
|
|
770
|
+
* function will handle creating a virtual DOM tree with a single root, patching
|
|
771
|
+
* the current virtual DOM tree onto an old one (if any), dealing with slot
|
|
772
|
+
* relocation, and reflecting attributes.
|
|
773
|
+
*
|
|
774
|
+
* @param hostRef data needed to root and render the virtual DOM tree, such as
|
|
775
|
+
* the DOM node into which it should be rendered.
|
|
776
|
+
* @param renderFnResults the virtual DOM nodes to be rendered
|
|
777
|
+
*/
|
|
922
778
|
const renderVdom = (hostRef, renderFnResults) => {
|
|
923
779
|
const hostElm = hostRef.$hostElement$;
|
|
924
|
-
const cmpMeta = hostRef.$cmpMeta$;
|
|
925
780
|
const oldVNode = hostRef.$vnode$ || newVNode(null, null);
|
|
926
781
|
const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
|
|
927
782
|
hostTagName = hostElm.tagName;
|
|
928
783
|
rootVnode.$tag$ = null;
|
|
929
784
|
rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
|
|
930
785
|
hostRef.$vnode$ = rootVnode;
|
|
931
|
-
rootVnode.$elm$ = oldVNode.$elm$ = (hostElm);
|
|
786
|
+
rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
|
|
932
787
|
{
|
|
933
|
-
|
|
934
|
-
useNativeShadowDom = (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
|
|
935
|
-
// always reset
|
|
936
|
-
checkSlotFallbackVisibility = false;
|
|
788
|
+
scopeId = hostElm['s-sc'];
|
|
937
789
|
}
|
|
938
790
|
// synchronous patch
|
|
939
791
|
patch(oldVNode, rootVnode);
|
|
940
|
-
{
|
|
941
|
-
// while we're moving nodes around existing nodes, temporarily disable
|
|
942
|
-
// the disconnectCallback from working
|
|
943
|
-
plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
944
|
-
if (checkSlotRelocate) {
|
|
945
|
-
relocateSlotContent(rootVnode.$elm$);
|
|
946
|
-
let relocateData;
|
|
947
|
-
let nodeToRelocate;
|
|
948
|
-
let orgLocationNode;
|
|
949
|
-
let parentNodeRef;
|
|
950
|
-
let insertBeforeNode;
|
|
951
|
-
let refNode;
|
|
952
|
-
let i = 0;
|
|
953
|
-
for (; i < relocateNodes.length; i++) {
|
|
954
|
-
relocateData = relocateNodes[i];
|
|
955
|
-
nodeToRelocate = relocateData.$nodeToRelocate$;
|
|
956
|
-
if (!nodeToRelocate['s-ol']) {
|
|
957
|
-
// add a reference node marking this node's original location
|
|
958
|
-
// keep a reference to this node for later lookups
|
|
959
|
-
orgLocationNode =
|
|
960
|
-
doc.createTextNode('');
|
|
961
|
-
orgLocationNode['s-nr'] = nodeToRelocate;
|
|
962
|
-
nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
for (i = 0; i < relocateNodes.length; i++) {
|
|
966
|
-
relocateData = relocateNodes[i];
|
|
967
|
-
nodeToRelocate = relocateData.$nodeToRelocate$;
|
|
968
|
-
if (relocateData.$slotRefNode$) {
|
|
969
|
-
// by default we're just going to insert it directly
|
|
970
|
-
// after the slot reference node
|
|
971
|
-
parentNodeRef = relocateData.$slotRefNode$.parentNode;
|
|
972
|
-
insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
|
|
973
|
-
orgLocationNode = nodeToRelocate['s-ol'];
|
|
974
|
-
while ((orgLocationNode = orgLocationNode.previousSibling)) {
|
|
975
|
-
refNode = orgLocationNode['s-nr'];
|
|
976
|
-
if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
|
|
977
|
-
refNode = refNode.nextSibling;
|
|
978
|
-
if (!refNode || !refNode['s-nr']) {
|
|
979
|
-
insertBeforeNode = refNode;
|
|
980
|
-
break;
|
|
981
|
-
}
|
|
982
|
-
}
|
|
983
|
-
}
|
|
984
|
-
if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
|
|
985
|
-
nodeToRelocate.nextSibling !== insertBeforeNode) {
|
|
986
|
-
// we've checked that it's worth while to relocate
|
|
987
|
-
// since that the node to relocate
|
|
988
|
-
// has a different next sibling or parent relocated
|
|
989
|
-
if (nodeToRelocate !== insertBeforeNode) {
|
|
990
|
-
if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
|
|
991
|
-
// probably a component in the index.html that doesn't have it's hostname set
|
|
992
|
-
nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
|
|
993
|
-
}
|
|
994
|
-
// add it back to the dom but in its new home
|
|
995
|
-
parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
|
|
996
|
-
}
|
|
997
|
-
}
|
|
998
|
-
}
|
|
999
|
-
else {
|
|
1000
|
-
// this node doesn't have a slot home to go to, so let's hide it
|
|
1001
|
-
if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
1002
|
-
nodeToRelocate.hidden = true;
|
|
1003
|
-
}
|
|
1004
|
-
}
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
1007
|
-
if (checkSlotFallbackVisibility) {
|
|
1008
|
-
updateFallbackSlotVisibility(rootVnode.$elm$);
|
|
1009
|
-
}
|
|
1010
|
-
// done moving nodes around
|
|
1011
|
-
// allow the disconnect callback to work again
|
|
1012
|
-
plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
1013
|
-
// always reset
|
|
1014
|
-
relocateNodes.length = 0;
|
|
1015
|
-
}
|
|
1016
792
|
};
|
|
1017
793
|
const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
1018
794
|
if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
|
|
@@ -1038,6 +814,18 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
|
1038
814
|
const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
|
|
1039
815
|
const instance = hostRef.$lazyInstance$ ;
|
|
1040
816
|
let promise;
|
|
817
|
+
if (isInitialLoad) {
|
|
818
|
+
{
|
|
819
|
+
hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
|
|
820
|
+
if (hostRef.$queuedListeners$) {
|
|
821
|
+
hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
|
|
822
|
+
hostRef.$queuedListeners$ = null;
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
{
|
|
826
|
+
promise = safeCall(instance, 'componentWillLoad');
|
|
827
|
+
}
|
|
828
|
+
}
|
|
1041
829
|
endSchedule();
|
|
1042
830
|
return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
|
|
1043
831
|
};
|
|
@@ -1369,15 +1157,6 @@ const connectedCallback = (elm) => {
|
|
|
1369
1157
|
if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
|
|
1370
1158
|
// first time this component has connected
|
|
1371
1159
|
hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
|
|
1372
|
-
{
|
|
1373
|
-
// initUpdate
|
|
1374
|
-
// if the slot polyfill is required we'll need to put some nodes
|
|
1375
|
-
// in here to act as original content anchors as we move nodes around
|
|
1376
|
-
// host element has been connected to the DOM
|
|
1377
|
-
if ((cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
|
|
1378
|
-
setContentReference(elm);
|
|
1379
|
-
}
|
|
1380
|
-
}
|
|
1381
1160
|
{
|
|
1382
1161
|
// find the first ancestor component (if there is one) and register
|
|
1383
1162
|
// this component as one of the actively loading child components for its ancestor
|
|
@@ -1408,26 +1187,32 @@ const connectedCallback = (elm) => {
|
|
|
1408
1187
|
initializeComponent(elm, hostRef, cmpMeta);
|
|
1409
1188
|
}
|
|
1410
1189
|
}
|
|
1190
|
+
else {
|
|
1191
|
+
// not the first time this has connected
|
|
1192
|
+
// reattach any event listeners to the host
|
|
1193
|
+
// since they would have been removed when disconnected
|
|
1194
|
+
addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
|
|
1195
|
+
}
|
|
1411
1196
|
endConnected();
|
|
1412
1197
|
}
|
|
1413
1198
|
};
|
|
1414
|
-
const setContentReference = (elm) => {
|
|
1415
|
-
// only required when we're NOT using native shadow dom (slot)
|
|
1416
|
-
// or this browser doesn't support native shadow dom
|
|
1417
|
-
// and this host element was NOT created with SSR
|
|
1418
|
-
// let's pick out the inner content for slot projection
|
|
1419
|
-
// create a node to represent where the original
|
|
1420
|
-
// content was first placed, which is useful later on
|
|
1421
|
-
const contentRefElm = (elm['s-cr'] = doc.createComment(''));
|
|
1422
|
-
contentRefElm['s-cn'] = true;
|
|
1423
|
-
elm.insertBefore(contentRefElm, elm.firstChild);
|
|
1424
|
-
};
|
|
1425
1199
|
const disconnectedCallback = (elm) => {
|
|
1426
1200
|
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
1427
|
-
getHostRef(elm);
|
|
1201
|
+
const hostRef = getHostRef(elm);
|
|
1202
|
+
const instance = hostRef.$lazyInstance$ ;
|
|
1203
|
+
{
|
|
1204
|
+
if (hostRef.$rmListeners$) {
|
|
1205
|
+
hostRef.$rmListeners$.map((rmListener) => rmListener());
|
|
1206
|
+
hostRef.$rmListeners$ = undefined;
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
{
|
|
1210
|
+
safeCall(instance, 'disconnectedCallback');
|
|
1211
|
+
}
|
|
1428
1212
|
}
|
|
1429
1213
|
};
|
|
1430
1214
|
const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
1215
|
+
var _a;
|
|
1431
1216
|
const endBootstrap = createTime();
|
|
1432
1217
|
const cmpTags = [];
|
|
1433
1218
|
const exclude = options.exclude || [];
|
|
@@ -1451,6 +1236,9 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1451
1236
|
{
|
|
1452
1237
|
cmpMeta.$members$ = compactMeta[2];
|
|
1453
1238
|
}
|
|
1239
|
+
{
|
|
1240
|
+
cmpMeta.$listeners$ = compactMeta[3];
|
|
1241
|
+
}
|
|
1454
1242
|
const tagName = cmpMeta.$tagName$;
|
|
1455
1243
|
const HostElement = class extends HTMLElement {
|
|
1456
1244
|
// StencilLazyHost
|
|
@@ -1459,6 +1247,17 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1459
1247
|
super(self);
|
|
1460
1248
|
self = this;
|
|
1461
1249
|
registerHost(self, cmpMeta);
|
|
1250
|
+
if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
|
|
1251
|
+
// this component is using shadow dom
|
|
1252
|
+
// and this browser supports shadow dom
|
|
1253
|
+
// add the read-only property "shadowRoot" to the host element
|
|
1254
|
+
// adding the shadow root build conditionals to minimize runtime
|
|
1255
|
+
{
|
|
1256
|
+
{
|
|
1257
|
+
self.attachShadow({ mode: 'open' });
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1462
1261
|
}
|
|
1463
1262
|
connectedCallback() {
|
|
1464
1263
|
if (appLoadFallback) {
|
|
@@ -1490,6 +1289,11 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1490
1289
|
{
|
|
1491
1290
|
visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
|
|
1492
1291
|
visibilityStyle.setAttribute('data-styles', '');
|
|
1292
|
+
// Apply CSP nonce to the style tag if it exists
|
|
1293
|
+
const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
|
|
1294
|
+
if (nonce != null) {
|
|
1295
|
+
visibilityStyle.setAttribute('nonce', nonce);
|
|
1296
|
+
}
|
|
1493
1297
|
head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
|
|
1494
1298
|
}
|
|
1495
1299
|
// Process deferred connectedCallbacks now all components have been registered
|
|
@@ -1505,6 +1309,47 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1505
1309
|
// Fallback appLoad event
|
|
1506
1310
|
endBootstrap();
|
|
1507
1311
|
};
|
|
1312
|
+
const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
|
|
1313
|
+
if (listeners) {
|
|
1314
|
+
listeners.map(([flags, name, method]) => {
|
|
1315
|
+
const target = getHostListenerTarget(elm, flags) ;
|
|
1316
|
+
const handler = hostListenerProxy(hostRef, method);
|
|
1317
|
+
const opts = hostListenerOpts(flags);
|
|
1318
|
+
plt.ael(target, name, handler, opts);
|
|
1319
|
+
(hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
|
|
1320
|
+
});
|
|
1321
|
+
}
|
|
1322
|
+
};
|
|
1323
|
+
const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
1324
|
+
try {
|
|
1325
|
+
{
|
|
1326
|
+
if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
|
|
1327
|
+
// instance is ready, let's call it's member method for this event
|
|
1328
|
+
hostRef.$lazyInstance$[methodName](ev);
|
|
1329
|
+
}
|
|
1330
|
+
else {
|
|
1331
|
+
(hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
catch (e) {
|
|
1336
|
+
consoleError(e);
|
|
1337
|
+
}
|
|
1338
|
+
};
|
|
1339
|
+
const getHostListenerTarget = (elm, flags) => {
|
|
1340
|
+
if (flags & 4 /* LISTENER_FLAGS.TargetDocument */)
|
|
1341
|
+
return doc;
|
|
1342
|
+
return elm;
|
|
1343
|
+
};
|
|
1344
|
+
// prettier-ignore
|
|
1345
|
+
const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
|
|
1346
|
+
/**
|
|
1347
|
+
* Assigns the given value to the nonce property on the runtime platform object.
|
|
1348
|
+
* During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
|
|
1349
|
+
* @param nonce The value to be assigned to the platform nonce property.
|
|
1350
|
+
* @returns void
|
|
1351
|
+
*/
|
|
1352
|
+
const setNonce = (nonce) => (plt.$nonce$ = nonce);
|
|
1508
1353
|
const hostRefs = /*@__PURE__*/ new WeakMap();
|
|
1509
1354
|
const getHostRef = (ref) => hostRefs.get(ref);
|
|
1510
1355
|
const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
|
|
@@ -1520,6 +1365,7 @@ const registerHost = (elm, cmpMeta) => {
|
|
|
1520
1365
|
elm['s-p'] = [];
|
|
1521
1366
|
elm['s-rc'] = [];
|
|
1522
1367
|
}
|
|
1368
|
+
addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
|
|
1523
1369
|
return hostRefs.set(elm, hostRef);
|
|
1524
1370
|
};
|
|
1525
1371
|
const isMemberInElement = (elm, memberName) => memberName in elm;
|
|
@@ -1611,4 +1457,4 @@ const flush = () => {
|
|
|
1611
1457
|
const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
|
|
1612
1458
|
const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
|
|
1613
1459
|
|
|
1614
|
-
export { Host as H, bootstrapLazy as b, h, promiseResolve as p, registerInstance as r };
|
|
1460
|
+
export { Host as H, bootstrapLazy as b, createEvent as c, getElement as g, h, promiseResolve as p, registerInstance as r, setNonce as s };
|