@3t-transform/threeteeui 0.0.6 → 0.0.7
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-253ca97c.js} +239 -415
- 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-single-input.cjs.entry.js +44 -0
- package/dist/cjs/tttx-text-box.cjs.entry.js +38 -0
- package/dist/cjs/tttx.cjs.js +7 -3
- package/dist/collection/collection-manifest.json +7 -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 +30 -0
- package/dist/collection/components/atoms/tttx-single-input/tttx-single-input.css +142 -0
- package/dist/collection/components/atoms/tttx-single-input/tttx-single-input.js +259 -0
- package/dist/collection/components/atoms/tttx-single-input/tttx-single-input.stories.js +92 -0
- package/dist/collection/components/atoms/tttx-text-box/tttx-text-box.css +142 -0
- package/dist/collection/components/atoms/tttx-text-box/tttx-text-box.js +150 -0
- package/dist/collection/components/atoms/tttx-text-box/tttx-text-box.stories.js +17 -0
- package/dist/collection/components/atoms/ttx-checkbox/tttx-checkbox.css +138 -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 +37 -0
- package/dist/collection/icons.js +2838 -0
- package/dist/components/index.d.ts +14 -3
- package/dist/components/index.js +6 -4
- package/dist/components/{tttx-page.d.ts → tttx-button.d.ts} +4 -4
- package/dist/components/tttx-button.js +45 -0
- package/dist/components/{tttx-worksheet.d.ts → tttx-checkbox.d.ts} +4 -4
- package/dist/components/tttx-checkbox.js +46 -0
- package/dist/components/{tttx-icon.d.ts → tttx-form.d.ts} +4 -4
- package/dist/components/tttx-form.js +75 -0
- package/dist/components/tttx-single-input.d.ts +11 -0
- package/dist/components/tttx-single-input.js +71 -0
- package/dist/components/tttx-text-box.d.ts +11 -0
- package/dist/components/tttx-text-box.js +59 -0
- package/dist/esm/{index-854ff56f.js → index-fcca6c58.js} +237 -416
- 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-single-input.entry.js +40 -0
- package/dist/esm/tttx-text-box.entry.js +34 -0
- package/dist/esm/tttx.js +4 -3
- package/dist/tttx/p-05d7d002.entry.js +1 -0
- package/dist/tttx/p-40709c59.entry.js +1 -0
- package/dist/tttx/p-64703252.entry.js +1 -0
- package/dist/tttx/p-8d1f2e5c.entry.js +1 -0
- package/dist/tttx/p-9bf836ed.entry.js +1 -0
- package/dist/tttx/p-a7b95fd2.js +2 -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-single-input/tttx-single-input.d.ts +20 -0
- package/dist/types/components/atoms/tttx-single-input/tttx-single-input.stories.d.ts +27 -0
- package/dist/types/components/atoms/tttx-text-box/tttx-text-box.d.ts +14 -0
- package/dist/types/components/atoms/tttx-text-box/tttx-text-box.stories.d.ts +6 -0
- package/dist/types/components/atoms/ttx-checkbox/tttx-checkbox.d.ts +9 -0
- package/dist/types/components/atoms/ttx-checkbox/tttx-checkbox.stories.d.ts +6 -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 +6 -0
- package/dist/types/components.d.ts +128 -51
- 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 +58 -59
- package/readme.md +1 -6
- package/dist/cjs/toolbar-656be6e6.js +0 -34259
- package/dist/cjs/tttx-icon.cjs.entry.js +0 -21
- 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/components/tttx-icon.js +0 -37
- 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-icon.entry.js +0 -17
- 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
|
@@ -30,11 +30,8 @@ const NAMESPACE = 'tttx';
|
|
|
30
30
|
*
|
|
31
31
|
* Modified for Stencil's renderer and slot projection
|
|
32
32
|
*/
|
|
33
|
-
let
|
|
33
|
+
let scopeId;
|
|
34
34
|
let hostTagName;
|
|
35
|
-
let useNativeShadowDom = false;
|
|
36
|
-
let checkSlotFallbackVisibility = false;
|
|
37
|
-
let checkSlotRelocate = false;
|
|
38
35
|
let isSvgMode = false;
|
|
39
36
|
let queuePending = false;
|
|
40
37
|
const createTime = (fnName, tagName = '') => {
|
|
@@ -60,11 +57,24 @@ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
|
60
57
|
* Don't add values to these!!
|
|
61
58
|
*/
|
|
62
59
|
const EMPTY_OBJ = {};
|
|
60
|
+
const isDef = (v) => v != null;
|
|
63
61
|
const isComplexType = (o) => {
|
|
64
62
|
// https://jsperf.com/typeof-fn-object/5
|
|
65
63
|
o = typeof o;
|
|
66
64
|
return o === 'object' || o === 'function';
|
|
67
65
|
};
|
|
66
|
+
/**
|
|
67
|
+
* Helper method for querying a `meta` tag that contains a nonce value
|
|
68
|
+
* out of a DOM's head.
|
|
69
|
+
*
|
|
70
|
+
* @param doc The DOM containing the `head` to query against
|
|
71
|
+
* @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
|
|
72
|
+
* exists or the tag has no content.
|
|
73
|
+
*/
|
|
74
|
+
function queryNonceMetaTagContent(doc) {
|
|
75
|
+
var _a, _b, _c;
|
|
76
|
+
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;
|
|
77
|
+
}
|
|
68
78
|
/**
|
|
69
79
|
* Production h() function based on Preact by
|
|
70
80
|
* Jason Miller (@developit)
|
|
@@ -73,12 +83,10 @@ const isComplexType = (o) => {
|
|
|
73
83
|
*
|
|
74
84
|
* Modified for Stencil's compiler and vdom
|
|
75
85
|
*/
|
|
76
|
-
// const stack: any[] = [];
|
|
77
86
|
// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
|
|
78
87
|
// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
|
|
79
88
|
const h = (nodeName, vnodeData, ...children) => {
|
|
80
89
|
let child = null;
|
|
81
|
-
let slotName = null;
|
|
82
90
|
let simple = false;
|
|
83
91
|
let lastSimple = false;
|
|
84
92
|
const vNodeChildren = [];
|
|
@@ -106,9 +114,6 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
106
114
|
};
|
|
107
115
|
walk(children);
|
|
108
116
|
if (vnodeData) {
|
|
109
|
-
if (vnodeData.name) {
|
|
110
|
-
slotName = vnodeData.name;
|
|
111
|
-
}
|
|
112
117
|
{
|
|
113
118
|
const classData = vnodeData.className || vnodeData.class;
|
|
114
119
|
if (classData) {
|
|
@@ -126,11 +131,16 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
126
131
|
if (vNodeChildren.length > 0) {
|
|
127
132
|
vnode.$children$ = vNodeChildren;
|
|
128
133
|
}
|
|
129
|
-
{
|
|
130
|
-
vnode.$name$ = slotName;
|
|
131
|
-
}
|
|
132
134
|
return vnode;
|
|
133
135
|
};
|
|
136
|
+
/**
|
|
137
|
+
* A utility function for creating a virtual DOM node from a tag and some
|
|
138
|
+
* possible text content.
|
|
139
|
+
*
|
|
140
|
+
* @param tag the tag for this element
|
|
141
|
+
* @param text possible text content for the node
|
|
142
|
+
* @returns a newly-minted virtual DOM node
|
|
143
|
+
*/
|
|
134
144
|
const newVNode = (tag, text) => {
|
|
135
145
|
const vnode = {
|
|
136
146
|
$flags$: 0,
|
|
@@ -142,12 +152,15 @@ const newVNode = (tag, text) => {
|
|
|
142
152
|
{
|
|
143
153
|
vnode.$attrs$ = null;
|
|
144
154
|
}
|
|
145
|
-
{
|
|
146
|
-
vnode.$name$ = null;
|
|
147
|
-
}
|
|
148
155
|
return vnode;
|
|
149
156
|
};
|
|
150
157
|
const Host = {};
|
|
158
|
+
/**
|
|
159
|
+
* Check whether a given node is a Host node or not
|
|
160
|
+
*
|
|
161
|
+
* @param node the virtual DOM node to check
|
|
162
|
+
* @returns whether it's a Host node or not
|
|
163
|
+
*/
|
|
151
164
|
const isHost = (node) => node && node.$tag$ === Host;
|
|
152
165
|
/**
|
|
153
166
|
* Parse a new property value for a given property type.
|
|
@@ -175,6 +188,11 @@ const isHost = (node) => node && node.$tag$ === Host;
|
|
|
175
188
|
const parsePropertyValue = (propValue, propType) => {
|
|
176
189
|
// ensure this value is of the correct prop type
|
|
177
190
|
if (propValue != null && !isComplexType(propValue)) {
|
|
191
|
+
if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
|
|
192
|
+
// per the HTML spec, any string value means it is a boolean true value
|
|
193
|
+
// but we'll cheat here and say that the string "false" is the boolean false
|
|
194
|
+
return propValue === 'false' ? false : propValue === '' || !!propValue;
|
|
195
|
+
}
|
|
178
196
|
if (propType & 1 /* MEMBER_FLAGS.String */) {
|
|
179
197
|
// could have been passed as a number or boolean
|
|
180
198
|
// but we still want it as a string
|
|
@@ -187,6 +205,20 @@ const parsePropertyValue = (propValue, propType) => {
|
|
|
187
205
|
// so no need to change to a different type
|
|
188
206
|
return propValue;
|
|
189
207
|
};
|
|
208
|
+
const getElement = (ref) => (getHostRef(ref).$hostElement$ );
|
|
209
|
+
const createEvent = (ref, name, flags) => {
|
|
210
|
+
const elm = getElement(ref);
|
|
211
|
+
return {
|
|
212
|
+
emit: (detail) => {
|
|
213
|
+
return emitEvent(elm, name, {
|
|
214
|
+
bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
|
|
215
|
+
composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
|
|
216
|
+
cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
|
|
217
|
+
detail,
|
|
218
|
+
});
|
|
219
|
+
},
|
|
220
|
+
};
|
|
221
|
+
};
|
|
190
222
|
/**
|
|
191
223
|
* Helper function to create & dispatch a custom Event on a provided target
|
|
192
224
|
* @param elm the target of the Event
|
|
@@ -217,6 +249,7 @@ const registerStyle = (scopeId, cssText, allowCS) => {
|
|
|
217
249
|
styles.set(scopeId, style);
|
|
218
250
|
};
|
|
219
251
|
const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
252
|
+
var _a;
|
|
220
253
|
let scopeId = getScopeId(cmpMeta);
|
|
221
254
|
const style = styles.get(scopeId);
|
|
222
255
|
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
@@ -236,6 +269,11 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
|
236
269
|
styleElm = doc.createElement('style');
|
|
237
270
|
styleElm.innerHTML = style;
|
|
238
271
|
}
|
|
272
|
+
// Apply CSP nonce to the style tag if it exists
|
|
273
|
+
const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
|
|
274
|
+
if (nonce != null) {
|
|
275
|
+
styleElm.setAttribute('nonce', nonce);
|
|
276
|
+
}
|
|
239
277
|
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
240
278
|
}
|
|
241
279
|
if (appliedStyles) {
|
|
@@ -252,8 +290,20 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
|
252
290
|
const attachStyles = (hostRef) => {
|
|
253
291
|
const cmpMeta = hostRef.$cmpMeta$;
|
|
254
292
|
const elm = hostRef.$hostElement$;
|
|
293
|
+
const flags = cmpMeta.$flags$;
|
|
255
294
|
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
256
|
-
addStyle(elm.getRootNode(), cmpMeta);
|
|
295
|
+
const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
|
|
296
|
+
if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
|
|
297
|
+
// only required when we're NOT using native shadow dom (slot)
|
|
298
|
+
// or this browser doesn't support native shadow dom
|
|
299
|
+
// and this host element was NOT created with SSR
|
|
300
|
+
// let's pick out the inner content for slot projection
|
|
301
|
+
// create a node to represent where the original
|
|
302
|
+
// content was first placed, which is useful later on
|
|
303
|
+
// DOM WRITE!!
|
|
304
|
+
elm['s-sc'] = scopeId;
|
|
305
|
+
elm.classList.add(scopeId + '-h');
|
|
306
|
+
}
|
|
257
307
|
endAttachStyles();
|
|
258
308
|
};
|
|
259
309
|
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
@@ -268,7 +318,7 @@ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
|
268
318
|
const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
269
319
|
if (oldValue !== newValue) {
|
|
270
320
|
let isProp = isMemberInElement(elm, memberName);
|
|
271
|
-
memberName.toLowerCase();
|
|
321
|
+
let ln = memberName.toLowerCase();
|
|
272
322
|
if (memberName === 'class') {
|
|
273
323
|
const classList = elm.classList;
|
|
274
324
|
const oldClasses = parseClassList(oldValue);
|
|
@@ -276,35 +326,43 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
276
326
|
classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
|
|
277
327
|
classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
|
|
278
328
|
}
|
|
279
|
-
else if (
|
|
280
|
-
|
|
281
|
-
{
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
329
|
+
else if ((!isProp ) &&
|
|
330
|
+
memberName[0] === 'o' &&
|
|
331
|
+
memberName[1] === 'n') {
|
|
332
|
+
// Event Handlers
|
|
333
|
+
// so if the member name starts with "on" and the 3rd characters is
|
|
334
|
+
// a capital letter, and it's not already a member on the element,
|
|
335
|
+
// then we're assuming it's an event listener
|
|
336
|
+
if (memberName[2] === '-') {
|
|
337
|
+
// on- prefixed events
|
|
338
|
+
// allows to be explicit about the dom event to listen without any magic
|
|
339
|
+
// under the hood:
|
|
340
|
+
// <my-cmp on-click> // listens for "click"
|
|
341
|
+
// <my-cmp on-Click> // listens for "Click"
|
|
342
|
+
// <my-cmp on-ionChange> // listens for "ionChange"
|
|
343
|
+
// <my-cmp on-EVENTS> // listens for "EVENTS"
|
|
344
|
+
memberName = memberName.slice(3);
|
|
292
345
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
346
|
+
else if (isMemberInElement(win, ln)) {
|
|
347
|
+
// standard event
|
|
348
|
+
// the JSX attribute could have been "onMouseOver" and the
|
|
349
|
+
// member name "onmouseover" is on the window's prototype
|
|
350
|
+
// so let's add the listener "mouseover", which is all lowercased
|
|
351
|
+
memberName = ln.slice(2);
|
|
352
|
+
}
|
|
353
|
+
else {
|
|
354
|
+
// custom event
|
|
355
|
+
// the JSX attribute could have been "onMyCustomEvent"
|
|
356
|
+
// so let's trim off the "on" prefix and lowercase the first character
|
|
357
|
+
// and add the listener "myCustomEvent"
|
|
358
|
+
// except for the first character, we keep the event name case
|
|
359
|
+
memberName = ln[2] + memberName.slice(3);
|
|
360
|
+
}
|
|
361
|
+
if (oldValue) {
|
|
362
|
+
plt.rel(elm, memberName, oldValue, false);
|
|
302
363
|
}
|
|
303
|
-
}
|
|
304
|
-
else if (memberName === 'ref') {
|
|
305
|
-
// minifier will clean this up
|
|
306
364
|
if (newValue) {
|
|
307
|
-
|
|
365
|
+
plt.ael(elm, memberName, newValue, false);
|
|
308
366
|
}
|
|
309
367
|
}
|
|
310
368
|
else {
|
|
@@ -384,36 +442,22 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
384
442
|
let i = 0;
|
|
385
443
|
let elm;
|
|
386
444
|
let childNode;
|
|
387
|
-
let oldVNode;
|
|
388
|
-
if (!useNativeShadowDom) {
|
|
389
|
-
// remember for later we need to check to relocate nodes
|
|
390
|
-
checkSlotRelocate = true;
|
|
391
|
-
if (newVNode.$tag$ === 'slot') {
|
|
392
|
-
newVNode.$flags$ |= newVNode.$children$
|
|
393
|
-
? // slot element has fallback content
|
|
394
|
-
2 /* VNODE_FLAGS.isSlotFallback */
|
|
395
|
-
: // slot element does not have fallback content
|
|
396
|
-
1 /* VNODE_FLAGS.isSlotReference */;
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
445
|
if (newVNode.$text$ !== null) {
|
|
400
446
|
// create text node
|
|
401
447
|
elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
|
|
402
448
|
}
|
|
403
|
-
else if (newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
|
|
404
|
-
// create a slot reference node
|
|
405
|
-
elm = newVNode.$elm$ =
|
|
406
|
-
doc.createTextNode('');
|
|
407
|
-
}
|
|
408
449
|
else {
|
|
409
450
|
// create element
|
|
410
|
-
elm = newVNode.$elm$ = (doc.createElement(newVNode.$
|
|
411
|
-
? 'slot-fb'
|
|
412
|
-
: newVNode.$tag$));
|
|
451
|
+
elm = newVNode.$elm$ = (doc.createElement(newVNode.$tag$));
|
|
413
452
|
// add css classes, attrs, props, listeners, etc.
|
|
414
453
|
{
|
|
415
454
|
updateElement(null, newVNode, isSvgMode);
|
|
416
455
|
}
|
|
456
|
+
if (isDef(scopeId) && elm['s-si'] !== scopeId) {
|
|
457
|
+
// if there is a scopeId and this is the initial render
|
|
458
|
+
// then let's add the scopeId as a css class
|
|
459
|
+
elm.classList.add((elm['s-si'] = scopeId));
|
|
460
|
+
}
|
|
417
461
|
if (newVNode.$children$) {
|
|
418
462
|
for (i = 0; i < newVNode.$children$.length; ++i) {
|
|
419
463
|
// create the node
|
|
@@ -426,82 +470,56 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
426
470
|
}
|
|
427
471
|
}
|
|
428
472
|
}
|
|
429
|
-
{
|
|
430
|
-
elm['s-hn'] = hostTagName;
|
|
431
|
-
if (newVNode.$flags$ & (2 /* VNODE_FLAGS.isSlotFallback */ | 1 /* VNODE_FLAGS.isSlotReference */)) {
|
|
432
|
-
// remember the content reference comment
|
|
433
|
-
elm['s-sr'] = true;
|
|
434
|
-
// remember the content reference comment
|
|
435
|
-
elm['s-cr'] = contentRef;
|
|
436
|
-
// remember the slot name, or empty string for default slot
|
|
437
|
-
elm['s-sn'] = newVNode.$name$ || '';
|
|
438
|
-
// check if we've got an old vnode for this slot
|
|
439
|
-
oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
|
|
440
|
-
if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
|
|
441
|
-
// we've got an old slot vnode and the wrapper is being replaced
|
|
442
|
-
// so let's move the old slot content back to it's original location
|
|
443
|
-
putBackInOriginalLocation(oldParentVNode.$elm$, false);
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
473
|
return elm;
|
|
448
474
|
};
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
childNode['s-ol'] = undefined;
|
|
465
|
-
checkSlotRelocate = true;
|
|
466
|
-
}
|
|
467
|
-
if (recursive) {
|
|
468
|
-
putBackInOriginalLocation(childNode, recursive);
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
472
|
-
};
|
|
475
|
+
/**
|
|
476
|
+
* Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
|
|
477
|
+
* add them to the DOM in the appropriate place.
|
|
478
|
+
*
|
|
479
|
+
* @param parentElm the DOM node which should be used as a parent for the new
|
|
480
|
+
* DOM nodes
|
|
481
|
+
* @param before a child of the `parentElm` which the new children should be
|
|
482
|
+
* inserted before (optional)
|
|
483
|
+
* @param parentVNode the parent virtual DOM node
|
|
484
|
+
* @param vnodes the new child virtual DOM nodes to produce DOM nodes for
|
|
485
|
+
* @param startIdx the index in the child virtual DOM nodes at which to start
|
|
486
|
+
* creating DOM nodes (inclusive)
|
|
487
|
+
* @param endIdx the index in the child virtual DOM nodes at which to stop
|
|
488
|
+
* creating DOM nodes (inclusive)
|
|
489
|
+
*/
|
|
473
490
|
const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
|
|
474
|
-
let containerElm = (
|
|
491
|
+
let containerElm = (parentElm);
|
|
475
492
|
let childNode;
|
|
493
|
+
if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
|
|
494
|
+
containerElm = containerElm.shadowRoot;
|
|
495
|
+
}
|
|
476
496
|
for (; startIdx <= endIdx; ++startIdx) {
|
|
477
497
|
if (vnodes[startIdx]) {
|
|
478
498
|
childNode = createElm(null, parentVNode, startIdx);
|
|
479
499
|
if (childNode) {
|
|
480
500
|
vnodes[startIdx].$elm$ = childNode;
|
|
481
|
-
containerElm.insertBefore(childNode,
|
|
501
|
+
containerElm.insertBefore(childNode, before);
|
|
482
502
|
}
|
|
483
503
|
}
|
|
484
504
|
}
|
|
485
505
|
};
|
|
506
|
+
/**
|
|
507
|
+
* Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
|
|
508
|
+
* This can be used to, for instance, clean up after a list of children which
|
|
509
|
+
* should no longer be shown.
|
|
510
|
+
*
|
|
511
|
+
* This function also handles some of Stencil's slot relocation logic.
|
|
512
|
+
*
|
|
513
|
+
* @param vnodes a list of virtual DOM nodes to remove
|
|
514
|
+
* @param startIdx the index at which to start removing nodes (inclusive)
|
|
515
|
+
* @param endIdx the index at which to stop removing nodes (inclusive)
|
|
516
|
+
* @param vnode a VNode
|
|
517
|
+
* @param elm an element
|
|
518
|
+
*/
|
|
486
519
|
const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
|
|
487
520
|
for (; startIdx <= endIdx; ++startIdx) {
|
|
488
521
|
if ((vnode = vnodes[startIdx])) {
|
|
489
522
|
elm = vnode.$elm$;
|
|
490
|
-
callNodeRefs(vnode);
|
|
491
|
-
{
|
|
492
|
-
// we're removing this element
|
|
493
|
-
// so it's possible we need to show slot fallback content now
|
|
494
|
-
checkSlotFallbackVisibility = true;
|
|
495
|
-
if (elm['s-ol']) {
|
|
496
|
-
// remove the original location comment
|
|
497
|
-
elm['s-ol'].remove();
|
|
498
|
-
}
|
|
499
|
-
else {
|
|
500
|
-
// it's possible that child nodes of the node
|
|
501
|
-
// that's being removed are slot nodes
|
|
502
|
-
putBackInOriginalLocation(elm, true);
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
523
|
// remove the vnode's element from the dom
|
|
506
524
|
elm.remove();
|
|
507
525
|
}
|
|
@@ -617,23 +635,6 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
617
635
|
newEndVnode = newCh[--newEndIdx];
|
|
618
636
|
}
|
|
619
637
|
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
620
|
-
// case: "Vnode moved right"
|
|
621
|
-
//
|
|
622
|
-
// We've found that the last node in our window on the new children is
|
|
623
|
-
// the same VNode as the _first_ node in our window on the old children
|
|
624
|
-
// we're dealing with now. Visually, this is the layout of these two
|
|
625
|
-
// nodes:
|
|
626
|
-
//
|
|
627
|
-
// newCh: [..., newStartVnode , ... , newEndVnode , ...]
|
|
628
|
-
// ^^^^^^^^^^^
|
|
629
|
-
// oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
|
|
630
|
-
// ^^^^^^^^^^^^^
|
|
631
|
-
//
|
|
632
|
-
// In this situation we need to patch `newEndVnode` onto `oldStartVnode`
|
|
633
|
-
// and move the DOM element for `oldStartVnode`.
|
|
634
|
-
if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
635
|
-
putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
|
|
636
|
-
}
|
|
637
638
|
patch(oldStartVnode, newEndVnode);
|
|
638
639
|
// We need to move the element for `oldStartVnode` into a position which
|
|
639
640
|
// will be appropriate for `newEndVnode`. For this we can use
|
|
@@ -657,24 +658,6 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
657
658
|
newEndVnode = newCh[--newEndIdx];
|
|
658
659
|
}
|
|
659
660
|
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
660
|
-
// case: "Vnode moved left"
|
|
661
|
-
//
|
|
662
|
-
// We've found that the first node in our window on the new children is
|
|
663
|
-
// the same VNode as the _last_ node in our window on the old children.
|
|
664
|
-
// Visually, this is the layout of these two nodes:
|
|
665
|
-
//
|
|
666
|
-
// newCh: [..., newStartVnode , ... , newEndVnode , ...]
|
|
667
|
-
// ^^^^^^^^^^^^^
|
|
668
|
-
// oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
|
|
669
|
-
// ^^^^^^^^^^^
|
|
670
|
-
//
|
|
671
|
-
// In this situation we need to patch `newStartVnode` onto `oldEndVnode`
|
|
672
|
-
// (which will handle updating any changed attributes, reconciling their
|
|
673
|
-
// children etc) but we also need to move the DOM node to which
|
|
674
|
-
// `oldEndVnode` corresponds.
|
|
675
|
-
if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
676
|
-
putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
|
|
677
|
-
}
|
|
678
661
|
patch(oldEndVnode, newStartVnode);
|
|
679
662
|
// We've already checked above if `oldStartVnode` and `newStartVnode` are
|
|
680
663
|
// the same node, so since we're here we know that they are not. Thus we
|
|
@@ -697,7 +680,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
697
680
|
if (node) {
|
|
698
681
|
// if we created a new node then handle inserting it to the DOM
|
|
699
682
|
{
|
|
700
|
-
|
|
683
|
+
oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
|
|
701
684
|
}
|
|
702
685
|
}
|
|
703
686
|
}
|
|
@@ -724,7 +707,8 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
724
707
|
*
|
|
725
708
|
* So, in other words, if `key` attrs are not set on VNodes which may be
|
|
726
709
|
* changing order within a `children` array or something along those lines then
|
|
727
|
-
* we could obtain a false
|
|
710
|
+
* we could obtain a false negative and then have to do needless re-rendering
|
|
711
|
+
* (i.e. we'd say two VNodes aren't equal when in fact they should be).
|
|
728
712
|
*
|
|
729
713
|
* @param leftVNode the first VNode to check
|
|
730
714
|
* @param rightVNode the second VNode to check
|
|
@@ -734,21 +718,10 @@ const isSameVnode = (leftVNode, rightVNode) => {
|
|
|
734
718
|
// compare if two vnode to see if they're "technically" the same
|
|
735
719
|
// need to have the same element tag, and same key to be the same
|
|
736
720
|
if (leftVNode.$tag$ === rightVNode.$tag$) {
|
|
737
|
-
if (leftVNode.$tag$ === 'slot') {
|
|
738
|
-
return leftVNode.$name$ === rightVNode.$name$;
|
|
739
|
-
}
|
|
740
721
|
return true;
|
|
741
722
|
}
|
|
742
723
|
return false;
|
|
743
724
|
};
|
|
744
|
-
const referenceNode = (node) => {
|
|
745
|
-
// this node was relocated to a new location in the dom
|
|
746
|
-
// because of some other component's slot
|
|
747
|
-
// but we still have an html comment in place of where
|
|
748
|
-
// it's original location was according to it's original vdom
|
|
749
|
-
return (node && node['s-ol']) || node;
|
|
750
|
-
};
|
|
751
|
-
const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
|
|
752
725
|
/**
|
|
753
726
|
* Handle reconciling an outdated VNode with a new one which corresponds to
|
|
754
727
|
* it. This function handles flushing updates to the DOM and reconciling the
|
|
@@ -763,7 +736,6 @@ const patch = (oldVNode, newVNode) => {
|
|
|
763
736
|
const newChildren = newVNode.$children$;
|
|
764
737
|
const tag = newVNode.$tag$;
|
|
765
738
|
const text = newVNode.$text$;
|
|
766
|
-
let defaultHolder;
|
|
767
739
|
if (text === null) {
|
|
768
740
|
{
|
|
769
741
|
if (tag === 'slot')
|
|
@@ -794,247 +766,38 @@ const patch = (oldVNode, newVNode) => {
|
|
|
794
766
|
removeVnodes(oldChildren, 0, oldChildren.length - 1);
|
|
795
767
|
}
|
|
796
768
|
}
|
|
797
|
-
else if ((defaultHolder = elm['s-cr'])) {
|
|
798
|
-
// this element has slotted content
|
|
799
|
-
defaultHolder.parentNode.textContent = text;
|
|
800
|
-
}
|
|
801
769
|
else if (oldVNode.$text$ !== text) {
|
|
802
770
|
// update the text content for the text only vnode
|
|
803
771
|
// and also only if the text is different than before
|
|
804
772
|
elm.data = text;
|
|
805
773
|
}
|
|
806
774
|
};
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
if (childNode['s-sr']) {
|
|
820
|
-
// this is a slot fallback node
|
|
821
|
-
// get the slot name for this slot reference node
|
|
822
|
-
slotNameAttr = childNode['s-sn'];
|
|
823
|
-
// by default always show a fallback slot node
|
|
824
|
-
// then hide it if there are other slots in the light dom
|
|
825
|
-
childNode.hidden = false;
|
|
826
|
-
for (j = 0; j < ilen; j++) {
|
|
827
|
-
nodeType = childNodes[j].nodeType;
|
|
828
|
-
if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
|
|
829
|
-
// this sibling node is from a different component OR is a named fallback slot node
|
|
830
|
-
if (nodeType === 1 /* NODE_TYPE.ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
|
|
831
|
-
childNode.hidden = true;
|
|
832
|
-
break;
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
else {
|
|
836
|
-
// this is a default fallback slot node
|
|
837
|
-
// any element or text node (with content)
|
|
838
|
-
// should hide the default fallback slot node
|
|
839
|
-
if (nodeType === 1 /* NODE_TYPE.ElementNode */ ||
|
|
840
|
-
(nodeType === 3 /* NODE_TYPE.TextNode */ && childNodes[j].textContent.trim() !== '')) {
|
|
841
|
-
childNode.hidden = true;
|
|
842
|
-
break;
|
|
843
|
-
}
|
|
844
|
-
}
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
// keep drilling down
|
|
848
|
-
updateFallbackSlotVisibility(childNode);
|
|
849
|
-
}
|
|
850
|
-
}
|
|
851
|
-
};
|
|
852
|
-
const relocateNodes = [];
|
|
853
|
-
const relocateSlotContent = (elm) => {
|
|
854
|
-
// tslint:disable-next-line: prefer-const
|
|
855
|
-
let childNode;
|
|
856
|
-
let node;
|
|
857
|
-
let hostContentNodes;
|
|
858
|
-
let slotNameAttr;
|
|
859
|
-
let relocateNodeData;
|
|
860
|
-
let j;
|
|
861
|
-
let i = 0;
|
|
862
|
-
const childNodes = elm.childNodes;
|
|
863
|
-
const ilen = childNodes.length;
|
|
864
|
-
for (; i < ilen; i++) {
|
|
865
|
-
childNode = childNodes[i];
|
|
866
|
-
if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
|
|
867
|
-
// first got the content reference comment node
|
|
868
|
-
// then we got it's parent, which is where all the host content is in now
|
|
869
|
-
hostContentNodes = node.parentNode.childNodes;
|
|
870
|
-
slotNameAttr = childNode['s-sn'];
|
|
871
|
-
for (j = hostContentNodes.length - 1; j >= 0; j--) {
|
|
872
|
-
node = hostContentNodes[j];
|
|
873
|
-
if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
|
|
874
|
-
// let's do some relocating to its new home
|
|
875
|
-
// but never relocate a content reference node
|
|
876
|
-
// that is suppose to always represent the original content location
|
|
877
|
-
if (isNodeLocatedInSlot(node, slotNameAttr)) {
|
|
878
|
-
// it's possible we've already decided to relocate this node
|
|
879
|
-
relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
|
|
880
|
-
// made some changes to slots
|
|
881
|
-
// let's make sure we also double check
|
|
882
|
-
// fallbacks are correctly hidden or shown
|
|
883
|
-
checkSlotFallbackVisibility = true;
|
|
884
|
-
node['s-sn'] = node['s-sn'] || slotNameAttr;
|
|
885
|
-
if (relocateNodeData) {
|
|
886
|
-
// previously we never found a slot home for this node
|
|
887
|
-
// but turns out we did, so let's remember it now
|
|
888
|
-
relocateNodeData.$slotRefNode$ = childNode;
|
|
889
|
-
}
|
|
890
|
-
else {
|
|
891
|
-
// add to our list of nodes to relocate
|
|
892
|
-
relocateNodes.push({
|
|
893
|
-
$slotRefNode$: childNode,
|
|
894
|
-
$nodeToRelocate$: node,
|
|
895
|
-
});
|
|
896
|
-
}
|
|
897
|
-
if (node['s-sr']) {
|
|
898
|
-
relocateNodes.map((relocateNode) => {
|
|
899
|
-
if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
|
|
900
|
-
relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
|
|
901
|
-
if (relocateNodeData && !relocateNode.$slotRefNode$) {
|
|
902
|
-
relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
|
|
903
|
-
}
|
|
904
|
-
}
|
|
905
|
-
});
|
|
906
|
-
}
|
|
907
|
-
}
|
|
908
|
-
else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
|
|
909
|
-
// so far this element does not have a slot home, not setting slotRefNode on purpose
|
|
910
|
-
// if we never find a home for this element then we'll need to hide it
|
|
911
|
-
relocateNodes.push({
|
|
912
|
-
$nodeToRelocate$: node,
|
|
913
|
-
});
|
|
914
|
-
}
|
|
915
|
-
}
|
|
916
|
-
}
|
|
917
|
-
}
|
|
918
|
-
if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
919
|
-
relocateSlotContent(childNode);
|
|
920
|
-
}
|
|
921
|
-
}
|
|
922
|
-
};
|
|
923
|
-
const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
|
|
924
|
-
if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
925
|
-
if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
|
|
926
|
-
return true;
|
|
927
|
-
}
|
|
928
|
-
if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
|
|
929
|
-
return true;
|
|
930
|
-
}
|
|
931
|
-
return false;
|
|
932
|
-
}
|
|
933
|
-
if (nodeToRelocate['s-sn'] === slotNameAttr) {
|
|
934
|
-
return true;
|
|
935
|
-
}
|
|
936
|
-
return slotNameAttr === '';
|
|
937
|
-
};
|
|
938
|
-
const callNodeRefs = (vNode) => {
|
|
939
|
-
{
|
|
940
|
-
vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
|
|
941
|
-
vNode.$children$ && vNode.$children$.map(callNodeRefs);
|
|
942
|
-
}
|
|
943
|
-
};
|
|
775
|
+
/**
|
|
776
|
+
* The main entry point for Stencil's virtual DOM-based rendering engine
|
|
777
|
+
*
|
|
778
|
+
* Given a {@link d.HostRef} container and some virtual DOM nodes, this
|
|
779
|
+
* function will handle creating a virtual DOM tree with a single root, patching
|
|
780
|
+
* the current virtual DOM tree onto an old one (if any), dealing with slot
|
|
781
|
+
* relocation, and reflecting attributes.
|
|
782
|
+
*
|
|
783
|
+
* @param hostRef data needed to root and render the virtual DOM tree, such as
|
|
784
|
+
* the DOM node into which it should be rendered.
|
|
785
|
+
* @param renderFnResults the virtual DOM nodes to be rendered
|
|
786
|
+
*/
|
|
944
787
|
const renderVdom = (hostRef, renderFnResults) => {
|
|
945
788
|
const hostElm = hostRef.$hostElement$;
|
|
946
|
-
const cmpMeta = hostRef.$cmpMeta$;
|
|
947
789
|
const oldVNode = hostRef.$vnode$ || newVNode(null, null);
|
|
948
790
|
const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
|
|
949
791
|
hostTagName = hostElm.tagName;
|
|
950
792
|
rootVnode.$tag$ = null;
|
|
951
793
|
rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
|
|
952
794
|
hostRef.$vnode$ = rootVnode;
|
|
953
|
-
rootVnode.$elm$ = oldVNode.$elm$ = (hostElm);
|
|
795
|
+
rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
|
|
954
796
|
{
|
|
955
|
-
|
|
956
|
-
useNativeShadowDom = (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
|
|
957
|
-
// always reset
|
|
958
|
-
checkSlotFallbackVisibility = false;
|
|
797
|
+
scopeId = hostElm['s-sc'];
|
|
959
798
|
}
|
|
960
799
|
// synchronous patch
|
|
961
800
|
patch(oldVNode, rootVnode);
|
|
962
|
-
{
|
|
963
|
-
// while we're moving nodes around existing nodes, temporarily disable
|
|
964
|
-
// the disconnectCallback from working
|
|
965
|
-
plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
966
|
-
if (checkSlotRelocate) {
|
|
967
|
-
relocateSlotContent(rootVnode.$elm$);
|
|
968
|
-
let relocateData;
|
|
969
|
-
let nodeToRelocate;
|
|
970
|
-
let orgLocationNode;
|
|
971
|
-
let parentNodeRef;
|
|
972
|
-
let insertBeforeNode;
|
|
973
|
-
let refNode;
|
|
974
|
-
let i = 0;
|
|
975
|
-
for (; i < relocateNodes.length; i++) {
|
|
976
|
-
relocateData = relocateNodes[i];
|
|
977
|
-
nodeToRelocate = relocateData.$nodeToRelocate$;
|
|
978
|
-
if (!nodeToRelocate['s-ol']) {
|
|
979
|
-
// add a reference node marking this node's original location
|
|
980
|
-
// keep a reference to this node for later lookups
|
|
981
|
-
orgLocationNode =
|
|
982
|
-
doc.createTextNode('');
|
|
983
|
-
orgLocationNode['s-nr'] = nodeToRelocate;
|
|
984
|
-
nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
|
|
985
|
-
}
|
|
986
|
-
}
|
|
987
|
-
for (i = 0; i < relocateNodes.length; i++) {
|
|
988
|
-
relocateData = relocateNodes[i];
|
|
989
|
-
nodeToRelocate = relocateData.$nodeToRelocate$;
|
|
990
|
-
if (relocateData.$slotRefNode$) {
|
|
991
|
-
// by default we're just going to insert it directly
|
|
992
|
-
// after the slot reference node
|
|
993
|
-
parentNodeRef = relocateData.$slotRefNode$.parentNode;
|
|
994
|
-
insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
|
|
995
|
-
orgLocationNode = nodeToRelocate['s-ol'];
|
|
996
|
-
while ((orgLocationNode = orgLocationNode.previousSibling)) {
|
|
997
|
-
refNode = orgLocationNode['s-nr'];
|
|
998
|
-
if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
|
|
999
|
-
refNode = refNode.nextSibling;
|
|
1000
|
-
if (!refNode || !refNode['s-nr']) {
|
|
1001
|
-
insertBeforeNode = refNode;
|
|
1002
|
-
break;
|
|
1003
|
-
}
|
|
1004
|
-
}
|
|
1005
|
-
}
|
|
1006
|
-
if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
|
|
1007
|
-
nodeToRelocate.nextSibling !== insertBeforeNode) {
|
|
1008
|
-
// we've checked that it's worth while to relocate
|
|
1009
|
-
// since that the node to relocate
|
|
1010
|
-
// has a different next sibling or parent relocated
|
|
1011
|
-
if (nodeToRelocate !== insertBeforeNode) {
|
|
1012
|
-
if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
|
|
1013
|
-
// probably a component in the index.html that doesn't have it's hostname set
|
|
1014
|
-
nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
|
|
1015
|
-
}
|
|
1016
|
-
// add it back to the dom but in its new home
|
|
1017
|
-
parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
|
|
1018
|
-
}
|
|
1019
|
-
}
|
|
1020
|
-
}
|
|
1021
|
-
else {
|
|
1022
|
-
// this node doesn't have a slot home to go to, so let's hide it
|
|
1023
|
-
if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
1024
|
-
nodeToRelocate.hidden = true;
|
|
1025
|
-
}
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
}
|
|
1029
|
-
if (checkSlotFallbackVisibility) {
|
|
1030
|
-
updateFallbackSlotVisibility(rootVnode.$elm$);
|
|
1031
|
-
}
|
|
1032
|
-
// done moving nodes around
|
|
1033
|
-
// allow the disconnect callback to work again
|
|
1034
|
-
plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
1035
|
-
// always reset
|
|
1036
|
-
relocateNodes.length = 0;
|
|
1037
|
-
}
|
|
1038
801
|
};
|
|
1039
802
|
const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
1040
803
|
if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
|
|
@@ -1060,6 +823,15 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
|
1060
823
|
const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
|
|
1061
824
|
const instance = hostRef.$lazyInstance$ ;
|
|
1062
825
|
let promise;
|
|
826
|
+
if (isInitialLoad) {
|
|
827
|
+
{
|
|
828
|
+
hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
|
|
829
|
+
if (hostRef.$queuedListeners$) {
|
|
830
|
+
hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
|
|
831
|
+
hostRef.$queuedListeners$ = null;
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
}
|
|
1063
835
|
endSchedule();
|
|
1064
836
|
return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
|
|
1065
837
|
};
|
|
@@ -1391,15 +1163,6 @@ const connectedCallback = (elm) => {
|
|
|
1391
1163
|
if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
|
|
1392
1164
|
// first time this component has connected
|
|
1393
1165
|
hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
|
|
1394
|
-
{
|
|
1395
|
-
// initUpdate
|
|
1396
|
-
// if the slot polyfill is required we'll need to put some nodes
|
|
1397
|
-
// in here to act as original content anchors as we move nodes around
|
|
1398
|
-
// host element has been connected to the DOM
|
|
1399
|
-
if ((cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
|
|
1400
|
-
setContentReference(elm);
|
|
1401
|
-
}
|
|
1402
|
-
}
|
|
1403
1166
|
{
|
|
1404
1167
|
// find the first ancestor component (if there is one) and register
|
|
1405
1168
|
// this component as one of the actively loading child components for its ancestor
|
|
@@ -1430,26 +1193,28 @@ const connectedCallback = (elm) => {
|
|
|
1430
1193
|
initializeComponent(elm, hostRef, cmpMeta);
|
|
1431
1194
|
}
|
|
1432
1195
|
}
|
|
1196
|
+
else {
|
|
1197
|
+
// not the first time this has connected
|
|
1198
|
+
// reattach any event listeners to the host
|
|
1199
|
+
// since they would have been removed when disconnected
|
|
1200
|
+
addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
|
|
1201
|
+
}
|
|
1433
1202
|
endConnected();
|
|
1434
1203
|
}
|
|
1435
1204
|
};
|
|
1436
|
-
const setContentReference = (elm) => {
|
|
1437
|
-
// only required when we're NOT using native shadow dom (slot)
|
|
1438
|
-
// or this browser doesn't support native shadow dom
|
|
1439
|
-
// and this host element was NOT created with SSR
|
|
1440
|
-
// let's pick out the inner content for slot projection
|
|
1441
|
-
// create a node to represent where the original
|
|
1442
|
-
// content was first placed, which is useful later on
|
|
1443
|
-
const contentRefElm = (elm['s-cr'] = doc.createComment(''));
|
|
1444
|
-
contentRefElm['s-cn'] = true;
|
|
1445
|
-
elm.insertBefore(contentRefElm, elm.firstChild);
|
|
1446
|
-
};
|
|
1447
1205
|
const disconnectedCallback = (elm) => {
|
|
1448
1206
|
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
1449
|
-
getHostRef(elm);
|
|
1207
|
+
const hostRef = getHostRef(elm);
|
|
1208
|
+
{
|
|
1209
|
+
if (hostRef.$rmListeners$) {
|
|
1210
|
+
hostRef.$rmListeners$.map((rmListener) => rmListener());
|
|
1211
|
+
hostRef.$rmListeners$ = undefined;
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1450
1214
|
}
|
|
1451
1215
|
};
|
|
1452
1216
|
const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
1217
|
+
var _a;
|
|
1453
1218
|
const endBootstrap = createTime();
|
|
1454
1219
|
const cmpTags = [];
|
|
1455
1220
|
const exclude = options.exclude || [];
|
|
@@ -1473,6 +1238,9 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1473
1238
|
{
|
|
1474
1239
|
cmpMeta.$members$ = compactMeta[2];
|
|
1475
1240
|
}
|
|
1241
|
+
{
|
|
1242
|
+
cmpMeta.$listeners$ = compactMeta[3];
|
|
1243
|
+
}
|
|
1476
1244
|
const tagName = cmpMeta.$tagName$;
|
|
1477
1245
|
const HostElement = class extends HTMLElement {
|
|
1478
1246
|
// StencilLazyHost
|
|
@@ -1481,6 +1249,17 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1481
1249
|
super(self);
|
|
1482
1250
|
self = this;
|
|
1483
1251
|
registerHost(self, cmpMeta);
|
|
1252
|
+
if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
|
|
1253
|
+
// this component is using shadow dom
|
|
1254
|
+
// and this browser supports shadow dom
|
|
1255
|
+
// add the read-only property "shadowRoot" to the host element
|
|
1256
|
+
// adding the shadow root build conditionals to minimize runtime
|
|
1257
|
+
{
|
|
1258
|
+
{
|
|
1259
|
+
self.attachShadow({ mode: 'open' });
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1484
1263
|
}
|
|
1485
1264
|
connectedCallback() {
|
|
1486
1265
|
if (appLoadFallback) {
|
|
@@ -1512,6 +1291,11 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1512
1291
|
{
|
|
1513
1292
|
visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
|
|
1514
1293
|
visibilityStyle.setAttribute('data-styles', '');
|
|
1294
|
+
// Apply CSP nonce to the style tag if it exists
|
|
1295
|
+
const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
|
|
1296
|
+
if (nonce != null) {
|
|
1297
|
+
visibilityStyle.setAttribute('nonce', nonce);
|
|
1298
|
+
}
|
|
1515
1299
|
head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
|
|
1516
1300
|
}
|
|
1517
1301
|
// Process deferred connectedCallbacks now all components have been registered
|
|
@@ -1527,6 +1311,42 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1527
1311
|
// Fallback appLoad event
|
|
1528
1312
|
endBootstrap();
|
|
1529
1313
|
};
|
|
1314
|
+
const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
|
|
1315
|
+
if (listeners) {
|
|
1316
|
+
listeners.map(([flags, name, method]) => {
|
|
1317
|
+
const target = elm;
|
|
1318
|
+
const handler = hostListenerProxy(hostRef, method);
|
|
1319
|
+
const opts = hostListenerOpts(flags);
|
|
1320
|
+
plt.ael(target, name, handler, opts);
|
|
1321
|
+
(hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
|
|
1322
|
+
});
|
|
1323
|
+
}
|
|
1324
|
+
};
|
|
1325
|
+
const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
1326
|
+
try {
|
|
1327
|
+
{
|
|
1328
|
+
if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
|
|
1329
|
+
// instance is ready, let's call it's member method for this event
|
|
1330
|
+
hostRef.$lazyInstance$[methodName](ev);
|
|
1331
|
+
}
|
|
1332
|
+
else {
|
|
1333
|
+
(hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
catch (e) {
|
|
1338
|
+
consoleError(e);
|
|
1339
|
+
}
|
|
1340
|
+
};
|
|
1341
|
+
// prettier-ignore
|
|
1342
|
+
const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
|
|
1343
|
+
/**
|
|
1344
|
+
* Assigns the given value to the nonce property on the runtime platform object.
|
|
1345
|
+
* During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
|
|
1346
|
+
* @param nonce The value to be assigned to the platform nonce property.
|
|
1347
|
+
* @returns void
|
|
1348
|
+
*/
|
|
1349
|
+
const setNonce = (nonce) => (plt.$nonce$ = nonce);
|
|
1530
1350
|
const hostRefs = /*@__PURE__*/ new WeakMap();
|
|
1531
1351
|
const getHostRef = (ref) => hostRefs.get(ref);
|
|
1532
1352
|
const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
|
|
@@ -1542,6 +1362,7 @@ const registerHost = (elm, cmpMeta) => {
|
|
|
1542
1362
|
elm['s-p'] = [];
|
|
1543
1363
|
elm['s-rc'] = [];
|
|
1544
1364
|
}
|
|
1365
|
+
addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
|
|
1545
1366
|
return hostRefs.set(elm, hostRef);
|
|
1546
1367
|
};
|
|
1547
1368
|
const isMemberInElement = (elm, memberName) => memberName in elm;
|
|
@@ -1635,6 +1456,9 @@ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
|
|
|
1635
1456
|
|
|
1636
1457
|
exports.Host = Host;
|
|
1637
1458
|
exports.bootstrapLazy = bootstrapLazy;
|
|
1459
|
+
exports.createEvent = createEvent;
|
|
1460
|
+
exports.getElement = getElement;
|
|
1638
1461
|
exports.h = h;
|
|
1639
1462
|
exports.promiseResolve = promiseResolve;
|
|
1640
1463
|
exports.registerInstance = registerInstance;
|
|
1464
|
+
exports.setNonce = setNonce;
|