@paperless/core 0.1.0-alpha.0 → 0.1.0-alpha.13
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/CHANGELOG.md +125 -0
- package/README.md +17 -0
- package/dist/assets/icons/arrow.svg +1 -1
- package/dist/assets/icons/attachment.svg +1 -1
- package/dist/assets/icons/bread.svg +1 -1
- package/dist/assets/icons/calendar.svg +1 -1
- package/dist/assets/icons/car.svg +1 -1
- package/dist/assets/icons/checkmark.svg +1 -1
- package/dist/assets/icons/chevron.svg +1 -1
- package/dist/assets/icons/clock.svg +1 -1
- package/dist/assets/icons/cogs.svg +1 -1
- package/dist/assets/icons/comment.svg +1 -1
- package/dist/assets/icons/document.svg +1 -1
- package/dist/assets/icons/download.svg +1 -1
- package/dist/assets/icons/envelope.svg +1 -1
- package/dist/assets/icons/explanation.svg +1 -1
- package/dist/assets/icons/eye.svg +1 -1
- package/dist/assets/icons/filter.svg +1 -1
- package/dist/assets/icons/grid.svg +1 -1
- package/dist/assets/icons/headset.svg +1 -1
- package/dist/assets/icons/list.svg +1 -1
- package/dist/assets/icons/location.svg +1 -1
- package/dist/assets/icons/megaphone.svg +1 -1
- package/dist/assets/icons/minus.svg +1 -1
- package/dist/assets/icons/negative.svg +1 -1
- package/dist/assets/icons/pagination.svg +1 -1
- package/dist/assets/icons/payment.svg +1 -1
- package/dist/assets/icons/pencil.svg +1 -1
- package/dist/assets/icons/person.svg +1 -1
- package/dist/assets/icons/plus.svg +1 -1
- package/dist/assets/icons/question.svg +1 -1
- package/dist/assets/icons/receipt.svg +1 -1
- package/dist/assets/icons/report.svg +1 -1
- package/dist/assets/icons/search.svg +1 -1
- package/dist/assets/icons/settings.svg +1 -1
- package/dist/assets/icons/sick.svg +1 -1
- package/dist/assets/icons/tachometer.svg +1 -1
- package/dist/assets/icons/tool.svg +1 -1
- package/dist/assets/icons/trash.svg +1 -1
- package/dist/assets/icons/turn.svg +1 -1
- package/dist/assets/icons/upload.svg +1 -1
- package/dist/assets/icons/warning.svg +1 -1
- package/dist/assets/images/avatar/company-default.svg +12 -0
- package/dist/assets/images/avatar/user-default.svg +12 -0
- package/dist/assets/images/helper/helper-hover.svg +15 -0
- package/dist/assets/images/helper/helper.svg +15 -0
- package/dist/build/p-06a38756.entry.js +1 -0
- package/dist/build/p-19afe191.entry.js +1 -0
- package/dist/build/p-229f113b.js +2 -0
- package/dist/{paperless/p-98d636b6.entry.js → build/p-23980fbb.entry.js} +1 -1
- package/dist/build/p-31f80006.entry.js +1 -0
- package/dist/build/p-332028c6.entry.js +1 -0
- package/dist/build/p-5f0ec763.entry.js +1 -0
- package/dist/build/p-6c6c1137.entry.js +1 -0
- package/dist/build/p-80bf9d06.entry.js +1 -0
- package/dist/build/p-e80637b9.entry.js +1 -0
- package/dist/build/p-ec52095f.entry.js +1 -0
- package/dist/build/paperless.css +4 -3
- package/dist/build/paperless.esm.js +1 -1
- package/dist/cjs/{index-6758a39e.js → index-6b6e08cc.js} +487 -9
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/p-avatar.cjs.entry.js +32 -0
- package/dist/cjs/{p-icon.cjs.entry.js → p-button_3.cjs.entry.js} +149 -46
- package/dist/cjs/p-counter.cjs.entry.js +19 -0
- package/dist/cjs/p-divider.cjs.entry.js +19 -0
- package/dist/cjs/p-helper.cjs.entry.js +19 -0
- package/dist/cjs/p-illustration.cjs.entry.js +11 -14
- package/dist/cjs/p-info-panel.cjs.entry.js +31 -0
- package/dist/cjs/p-pagination-item.cjs.entry.js +23 -0
- package/dist/cjs/p-pagination.cjs.entry.js +163 -0
- package/dist/cjs/p-tooltip.cjs.entry.js +62 -20
- package/dist/cjs/paperless.cjs.js +2 -2
- package/dist/collection/assets/icons/arrow.svg +1 -1
- package/dist/collection/assets/icons/attachment.svg +1 -1
- package/dist/collection/assets/icons/bread.svg +1 -1
- package/dist/collection/assets/icons/calendar.svg +1 -1
- package/dist/collection/assets/icons/car.svg +1 -1
- package/dist/collection/assets/icons/checkmark.svg +1 -1
- package/dist/collection/assets/icons/chevron.svg +1 -1
- package/dist/collection/assets/icons/clock.svg +1 -1
- package/dist/collection/assets/icons/cogs.svg +1 -1
- package/dist/collection/assets/icons/comment.svg +1 -1
- package/dist/collection/assets/icons/document.svg +1 -1
- package/dist/collection/assets/icons/download.svg +1 -1
- package/dist/collection/assets/icons/envelope.svg +1 -1
- package/dist/collection/assets/icons/explanation.svg +1 -1
- package/dist/collection/assets/icons/eye.svg +1 -1
- package/dist/collection/assets/icons/filter.svg +1 -1
- package/dist/collection/assets/icons/grid.svg +1 -1
- package/dist/collection/assets/icons/headset.svg +1 -1
- package/dist/collection/assets/icons/list.svg +1 -1
- package/dist/collection/assets/icons/location.svg +1 -1
- package/dist/collection/assets/icons/megaphone.svg +1 -1
- package/dist/collection/assets/icons/minus.svg +1 -1
- package/dist/collection/assets/icons/negative.svg +1 -1
- package/dist/collection/assets/icons/pagination.svg +1 -1
- package/dist/collection/assets/icons/payment.svg +1 -1
- package/dist/collection/assets/icons/pencil.svg +1 -1
- package/dist/collection/assets/icons/person.svg +1 -1
- package/dist/collection/assets/icons/plus.svg +1 -1
- package/dist/collection/assets/icons/question.svg +1 -1
- package/dist/collection/assets/icons/receipt.svg +1 -1
- package/dist/collection/assets/icons/report.svg +1 -1
- package/dist/collection/assets/icons/search.svg +1 -1
- package/dist/collection/assets/icons/settings.svg +1 -1
- package/dist/collection/assets/icons/sick.svg +1 -1
- package/dist/collection/assets/icons/tachometer.svg +1 -1
- package/dist/collection/assets/icons/tool.svg +1 -1
- package/dist/collection/assets/icons/trash.svg +1 -1
- package/dist/collection/assets/icons/turn.svg +1 -1
- package/dist/collection/assets/icons/upload.svg +1 -1
- package/dist/collection/assets/icons/warning.svg +1 -1
- package/dist/collection/assets/images/avatar/company-default.svg +12 -0
- package/dist/collection/assets/images/avatar/user-default.svg +12 -0
- package/dist/collection/assets/images/helper/helper-hover.svg +15 -0
- package/dist/collection/assets/images/helper/helper.svg +15 -0
- package/dist/collection/collection-manifest.json +12 -4
- package/dist/collection/components/atoms/avatar/avatar.component.css +31 -0
- package/dist/collection/components/atoms/avatar/avatar.component.js +105 -0
- package/dist/collection/components/atoms/button/button.component.css +71 -0
- package/dist/collection/components/atoms/button/button.component.js +276 -0
- package/dist/collection/components/atoms/counter/counter.component.css +5 -0
- package/dist/collection/components/atoms/counter/counter.component.js +15 -0
- package/dist/collection/components/atoms/divider/divider.component.css +3 -0
- package/dist/collection/components/atoms/divider/divider.component.js +14 -0
- package/dist/collection/components/atoms/helper/helper.component.css +7 -0
- package/dist/collection/components/atoms/helper/helper.component.js +18 -0
- package/dist/collection/components/{icon → atoms/icon}/icon.component.js +10 -11
- package/dist/collection/components/{illustration → atoms/illustration}/illustration.component.js +4 -11
- package/dist/collection/components/atoms/info-panel/info-panel.component.css +28 -0
- package/dist/collection/components/atoms/info-panel/info-panel.component.js +106 -0
- package/dist/collection/components/atoms/loader/loader.component.css +26 -0
- package/dist/collection/components/atoms/loader/loader.component.js +153 -0
- package/dist/collection/components/atoms/pagination-item/pagination-item.component.css +16 -0
- package/dist/collection/components/atoms/pagination-item/pagination-item.component.js +41 -0
- package/dist/collection/components/atoms/tooltip/tooltip.component.css +37 -0
- package/dist/collection/components/{tooltip → atoms/tooltip}/tooltip.component.js +122 -32
- package/dist/collection/components/molecules/pagination/pagination.component.css +3 -0
- package/dist/collection/components/molecules/pagination/pagination.component.js +219 -0
- package/dist/collection/tailwind/border-radius.js +1 -0
- package/dist/collection/tailwind/grid.js +24 -4
- package/dist/collection/tailwind/rotate.js +8 -0
- package/dist/collection/tailwind/scale.js +3 -0
- package/dist/collection/tailwind.config.js +6 -7
- package/dist/{esm/p-icon.entry.js → components/icon.component.js} +67 -52
- package/dist/components/index.d.ts +9 -1
- package/dist/components/index.js +8 -0
- package/dist/components/loader.component.js +74 -0
- package/dist/components/p-avatar.d.ts +11 -0
- package/dist/components/p-avatar.js +52 -0
- package/dist/components/p-button.js +67 -8
- package/dist/components/p-counter.d.ts +11 -0
- package/dist/components/p-counter.js +33 -0
- package/dist/components/p-divider.d.ts +11 -0
- package/dist/components/p-divider.js +33 -0
- package/dist/components/p-helper.d.ts +11 -0
- package/dist/components/p-helper.js +39 -0
- package/dist/components/p-icon.js +1 -815
- package/dist/components/p-illustration.js +3 -7
- package/dist/components/p-info-panel.d.ts +11 -0
- package/dist/components/p-info-panel.js +56 -0
- package/dist/components/p-loader.d.ts +11 -0
- package/dist/components/p-loader.js +6 -0
- package/dist/components/p-pagination-item.d.ts +11 -0
- package/dist/components/p-pagination-item.js +6 -0
- package/dist/components/p-pagination.d.ts +11 -0
- package/dist/components/p-pagination.js +192 -0
- package/dist/components/p-tooltip.js +1 -1886
- package/dist/components/pagination-item.component.js +36 -0
- package/dist/components/tooltip.component.js +1932 -0
- package/dist/esm/{index-e4d80e41.js → index-5c917d13.js} +487 -10
- package/dist/esm/loader.js +2 -2
- package/dist/esm/p-avatar.entry.js +28 -0
- package/dist/esm/p-button_3.entry.js +899 -0
- package/dist/esm/p-counter.entry.js +15 -0
- package/dist/esm/p-divider.entry.js +15 -0
- package/dist/esm/p-helper.entry.js +15 -0
- package/dist/esm/p-illustration.entry.js +11 -14
- package/dist/esm/p-info-panel.entry.js +27 -0
- package/dist/esm/p-pagination-item.entry.js +19 -0
- package/dist/esm/p-pagination.entry.js +159 -0
- package/dist/esm/p-tooltip.entry.js +62 -20
- package/dist/esm/paperless.js +2 -2
- package/dist/index.html +1 -1
- package/dist/paperless/p-06a38756.entry.js +1 -0
- package/dist/paperless/p-19afe191.entry.js +1 -0
- package/dist/paperless/p-229f113b.js +2 -0
- package/dist/{build/p-98d636b6.entry.js → paperless/p-23980fbb.entry.js} +1 -1
- package/dist/paperless/p-31f80006.entry.js +1 -0
- package/dist/paperless/p-332028c6.entry.js +1 -0
- package/dist/paperless/p-5f0ec763.entry.js +1 -0
- package/dist/paperless/p-6c6c1137.entry.js +1 -0
- package/dist/paperless/p-80bf9d06.entry.js +1 -0
- package/dist/paperless/p-e80637b9.entry.js +1 -0
- package/dist/paperless/p-ec52095f.entry.js +1 -0
- package/dist/paperless/paperless.css +3843 -201
- package/dist/paperless/paperless.esm.js +1 -1
- package/dist/sw.js +245 -49
- package/dist/tailwind.config.js +6 -7
- package/dist/types/components/atoms/avatar/avatar.component.d.ts +21 -0
- package/dist/types/components/atoms/button/button.component.d.ts +51 -0
- package/dist/types/components/atoms/counter/counter.component.d.ts +3 -0
- package/dist/types/components/atoms/divider/divider.component.d.ts +3 -0
- package/dist/types/components/atoms/helper/helper.component.d.ts +3 -0
- package/dist/types/components/{icon → atoms/icon}/icon.component.d.ts +3 -2
- package/dist/types/components/{illustration → atoms/illustration}/illustration.component.d.ts +2 -2
- package/dist/types/components/atoms/info-panel/info-panel.component.d.ts +24 -0
- package/dist/types/components/atoms/loader/loader.component.d.ts +30 -0
- package/dist/types/components/atoms/pagination-item/pagination-item.component.d.ts +7 -0
- package/dist/types/components/atoms/tooltip/tooltip.component.d.ts +40 -0
- package/dist/types/components/molecules/pagination/pagination.component.d.ts +31 -0
- package/dist/types/components.d.ts +358 -20
- package/package.json +3 -2
- package/dist/build/p-3318b73b.entry.js +0 -1
- package/dist/build/p-6f9229a6.js +0 -2
- package/dist/build/p-711630fb.entry.js +0 -1
- package/dist/build/p-c3d80205.entry.js +0 -1
- package/dist/cjs/p-button.cjs.entry.js +0 -23
- package/dist/collection/components/button/button.component.css +0 -6
- package/dist/collection/components/button/button.component.js +0 -42
- package/dist/collection/components/tooltip/tooltip.component.css +0 -34
- package/dist/esm/p-button.entry.js +0 -19
- package/dist/paperless/p-3318b73b.entry.js +0 -1
- package/dist/paperless/p-6f9229a6.js +0 -2
- package/dist/paperless/p-711630fb.entry.js +0 -1
- package/dist/paperless/p-c3d80205.entry.js +0 -1
- package/dist/types/components/button/button.component.d.ts +0 -7
- package/dist/types/components/tooltip/tooltip.component.d.ts +0 -28
|
@@ -23,7 +23,11 @@ function _interopNamespace(e) {
|
|
|
23
23
|
const NAMESPACE = 'paperless';
|
|
24
24
|
|
|
25
25
|
let scopeId;
|
|
26
|
+
let contentRef;
|
|
26
27
|
let hostTagName;
|
|
28
|
+
let useNativeShadowDom = false;
|
|
29
|
+
let checkSlotFallbackVisibility = false;
|
|
30
|
+
let checkSlotRelocate = false;
|
|
27
31
|
let isSvgMode = false;
|
|
28
32
|
let queuePending = false;
|
|
29
33
|
const win = typeof window !== 'undefined' ? window : {};
|
|
@@ -50,7 +54,7 @@ const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
|
|
|
50
54
|
const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
|
|
51
55
|
if (listeners) {
|
|
52
56
|
listeners.map(([flags, name, method]) => {
|
|
53
|
-
const target = elm;
|
|
57
|
+
const target = getHostListenerTarget(elm, flags) ;
|
|
54
58
|
const handler = hostListenerProxy(hostRef, method);
|
|
55
59
|
const opts = hostListenerOpts(flags);
|
|
56
60
|
plt.ael(target, name, handler, opts);
|
|
@@ -74,6 +78,11 @@ const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
|
74
78
|
consoleError(e);
|
|
75
79
|
}
|
|
76
80
|
};
|
|
81
|
+
const getHostListenerTarget = (elm, flags) => {
|
|
82
|
+
if (flags & 4 /* TargetDocument */)
|
|
83
|
+
return doc;
|
|
84
|
+
return elm;
|
|
85
|
+
};
|
|
77
86
|
// prettier-ignore
|
|
78
87
|
const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
|
|
79
88
|
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
@@ -183,6 +192,7 @@ const isComplexType = (o) => {
|
|
|
183
192
|
// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
|
|
184
193
|
const h = (nodeName, vnodeData, ...children) => {
|
|
185
194
|
let child = null;
|
|
195
|
+
let slotName = null;
|
|
186
196
|
let simple = false;
|
|
187
197
|
let lastSimple = false;
|
|
188
198
|
const vNodeChildren = [];
|
|
@@ -210,6 +220,9 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
210
220
|
};
|
|
211
221
|
walk(children);
|
|
212
222
|
if (vnodeData) {
|
|
223
|
+
if (vnodeData.name) {
|
|
224
|
+
slotName = vnodeData.name;
|
|
225
|
+
}
|
|
213
226
|
{
|
|
214
227
|
const classData = vnodeData.className || vnodeData.class;
|
|
215
228
|
if (classData) {
|
|
@@ -222,11 +235,18 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
222
235
|
}
|
|
223
236
|
}
|
|
224
237
|
}
|
|
238
|
+
if (typeof nodeName === 'function') {
|
|
239
|
+
// nodeName is a functional component
|
|
240
|
+
return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
|
|
241
|
+
}
|
|
225
242
|
const vnode = newVNode(nodeName, null);
|
|
226
243
|
vnode.$attrs$ = vnodeData;
|
|
227
244
|
if (vNodeChildren.length > 0) {
|
|
228
245
|
vnode.$children$ = vNodeChildren;
|
|
229
246
|
}
|
|
247
|
+
{
|
|
248
|
+
vnode.$name$ = slotName;
|
|
249
|
+
}
|
|
230
250
|
return vnode;
|
|
231
251
|
};
|
|
232
252
|
const newVNode = (tag, text) => {
|
|
@@ -240,10 +260,43 @@ const newVNode = (tag, text) => {
|
|
|
240
260
|
{
|
|
241
261
|
vnode.$attrs$ = null;
|
|
242
262
|
}
|
|
263
|
+
{
|
|
264
|
+
vnode.$name$ = null;
|
|
265
|
+
}
|
|
243
266
|
return vnode;
|
|
244
267
|
};
|
|
245
268
|
const Host = {};
|
|
246
269
|
const isHost = (node) => node && node.$tag$ === Host;
|
|
270
|
+
const vdomFnUtils = {
|
|
271
|
+
forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
|
|
272
|
+
map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
|
|
273
|
+
};
|
|
274
|
+
const convertToPublic = (node) => ({
|
|
275
|
+
vattrs: node.$attrs$,
|
|
276
|
+
vchildren: node.$children$,
|
|
277
|
+
vkey: node.$key$,
|
|
278
|
+
vname: node.$name$,
|
|
279
|
+
vtag: node.$tag$,
|
|
280
|
+
vtext: node.$text$,
|
|
281
|
+
});
|
|
282
|
+
const convertToPrivate = (node) => {
|
|
283
|
+
if (typeof node.vtag === 'function') {
|
|
284
|
+
const vnodeData = Object.assign({}, node.vattrs);
|
|
285
|
+
if (node.vkey) {
|
|
286
|
+
vnodeData.key = node.vkey;
|
|
287
|
+
}
|
|
288
|
+
if (node.vname) {
|
|
289
|
+
vnodeData.name = node.vname;
|
|
290
|
+
}
|
|
291
|
+
return h(node.vtag, vnodeData, ...(node.vchildren || []));
|
|
292
|
+
}
|
|
293
|
+
const vnode = newVNode(node.vtag, node.vtext);
|
|
294
|
+
vnode.$attrs$ = node.vattrs;
|
|
295
|
+
vnode.$children$ = node.vchildren;
|
|
296
|
+
vnode.$key$ = node.vkey;
|
|
297
|
+
vnode.$name$ = node.vname;
|
|
298
|
+
return vnode;
|
|
299
|
+
};
|
|
247
300
|
/**
|
|
248
301
|
* Production setAccessor() function based on Preact by
|
|
249
302
|
* Jason Miller (@developit)
|
|
@@ -255,7 +308,7 @@ const isHost = (node) => node && node.$tag$ === Host;
|
|
|
255
308
|
const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
256
309
|
if (oldValue !== newValue) {
|
|
257
310
|
let isProp = isMemberInElement(elm, memberName);
|
|
258
|
-
memberName.toLowerCase();
|
|
311
|
+
let ln = memberName.toLowerCase();
|
|
259
312
|
if (memberName === 'class') {
|
|
260
313
|
const classList = elm.classList;
|
|
261
314
|
const oldClasses = parseClassList(oldValue);
|
|
@@ -269,6 +322,45 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
269
322
|
newValue(elm);
|
|
270
323
|
}
|
|
271
324
|
}
|
|
325
|
+
else if ((!isProp ) &&
|
|
326
|
+
memberName[0] === 'o' &&
|
|
327
|
+
memberName[1] === 'n') {
|
|
328
|
+
// Event Handlers
|
|
329
|
+
// so if the member name starts with "on" and the 3rd characters is
|
|
330
|
+
// a capital letter, and it's not already a member on the element,
|
|
331
|
+
// then we're assuming it's an event listener
|
|
332
|
+
if (memberName[2] === '-') {
|
|
333
|
+
// on- prefixed events
|
|
334
|
+
// allows to be explicit about the dom event to listen without any magic
|
|
335
|
+
// under the hood:
|
|
336
|
+
// <my-cmp on-click> // listens for "click"
|
|
337
|
+
// <my-cmp on-Click> // listens for "Click"
|
|
338
|
+
// <my-cmp on-ionChange> // listens for "ionChange"
|
|
339
|
+
// <my-cmp on-EVENTS> // listens for "EVENTS"
|
|
340
|
+
memberName = memberName.slice(3);
|
|
341
|
+
}
|
|
342
|
+
else if (isMemberInElement(win, ln)) {
|
|
343
|
+
// standard event
|
|
344
|
+
// the JSX attribute could have been "onMouseOver" and the
|
|
345
|
+
// member name "onmouseover" is on the window's prototype
|
|
346
|
+
// so let's add the listener "mouseover", which is all lowercased
|
|
347
|
+
memberName = ln.slice(2);
|
|
348
|
+
}
|
|
349
|
+
else {
|
|
350
|
+
// custom event
|
|
351
|
+
// the JSX attribute could have been "onMyCustomEvent"
|
|
352
|
+
// so let's trim off the "on" prefix and lowercase the first character
|
|
353
|
+
// and add the listener "myCustomEvent"
|
|
354
|
+
// except for the first character, we keep the event name case
|
|
355
|
+
memberName = ln[2] + memberName.slice(3);
|
|
356
|
+
}
|
|
357
|
+
if (oldValue) {
|
|
358
|
+
plt.rel(elm, memberName, oldValue, false);
|
|
359
|
+
}
|
|
360
|
+
if (newValue) {
|
|
361
|
+
plt.ael(elm, memberName, newValue, false);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
272
364
|
else {
|
|
273
365
|
// Set property if it exists and it's not a SVG
|
|
274
366
|
const isComplex = isComplexType(newValue);
|
|
@@ -336,13 +428,36 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
336
428
|
let i = 0;
|
|
337
429
|
let elm;
|
|
338
430
|
let childNode;
|
|
431
|
+
let oldVNode;
|
|
432
|
+
if (!useNativeShadowDom) {
|
|
433
|
+
// remember for later we need to check to relocate nodes
|
|
434
|
+
checkSlotRelocate = true;
|
|
435
|
+
if (newVNode.$tag$ === 'slot') {
|
|
436
|
+
if (scopeId) {
|
|
437
|
+
// scoped css needs to add its scoped id to the parent element
|
|
438
|
+
parentElm.classList.add(scopeId + '-s');
|
|
439
|
+
}
|
|
440
|
+
newVNode.$flags$ |= newVNode.$children$
|
|
441
|
+
? // slot element has fallback content
|
|
442
|
+
2 /* isSlotFallback */
|
|
443
|
+
: // slot element does not have fallback content
|
|
444
|
+
1 /* isSlotReference */;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
339
447
|
if (newVNode.$text$ !== null) {
|
|
340
448
|
// create text node
|
|
341
449
|
elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
|
|
342
450
|
}
|
|
451
|
+
else if (newVNode.$flags$ & 1 /* isSlotReference */) {
|
|
452
|
+
// create a slot reference node
|
|
453
|
+
elm = newVNode.$elm$ =
|
|
454
|
+
doc.createTextNode('');
|
|
455
|
+
}
|
|
343
456
|
else {
|
|
344
457
|
// create element
|
|
345
|
-
elm = newVNode.$elm$ = (doc.createElement(newVNode.$
|
|
458
|
+
elm = newVNode.$elm$ = (doc.createElement(newVNode.$flags$ & 2 /* isSlotFallback */
|
|
459
|
+
? 'slot-fb'
|
|
460
|
+
: newVNode.$tag$));
|
|
346
461
|
// add css classes, attrs, props, listeners, etc.
|
|
347
462
|
{
|
|
348
463
|
updateElement(null, newVNode, isSvgMode);
|
|
@@ -355,7 +470,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
355
470
|
if (newVNode.$children$) {
|
|
356
471
|
for (i = 0; i < newVNode.$children$.length; ++i) {
|
|
357
472
|
// create the node
|
|
358
|
-
childNode = createElm(oldParentVNode, newVNode, i);
|
|
473
|
+
childNode = createElm(oldParentVNode, newVNode, i, elm);
|
|
359
474
|
// return node could have been null
|
|
360
475
|
if (childNode) {
|
|
361
476
|
// append our new node
|
|
@@ -364,20 +479,62 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
364
479
|
}
|
|
365
480
|
}
|
|
366
481
|
}
|
|
482
|
+
{
|
|
483
|
+
elm['s-hn'] = hostTagName;
|
|
484
|
+
if (newVNode.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
|
|
485
|
+
// remember the content reference comment
|
|
486
|
+
elm['s-sr'] = true;
|
|
487
|
+
// remember the content reference comment
|
|
488
|
+
elm['s-cr'] = contentRef;
|
|
489
|
+
// remember the slot name, or empty string for default slot
|
|
490
|
+
elm['s-sn'] = newVNode.$name$ || '';
|
|
491
|
+
// check if we've got an old vnode for this slot
|
|
492
|
+
oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
|
|
493
|
+
if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
|
|
494
|
+
// we've got an old slot vnode and the wrapper is being replaced
|
|
495
|
+
// so let's move the old slot content back to it's original location
|
|
496
|
+
putBackInOriginalLocation(oldParentVNode.$elm$, false);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
}
|
|
367
500
|
return elm;
|
|
368
501
|
};
|
|
502
|
+
const putBackInOriginalLocation = (parentElm, recursive) => {
|
|
503
|
+
plt.$flags$ |= 1 /* isTmpDisconnected */;
|
|
504
|
+
const oldSlotChildNodes = parentElm.childNodes;
|
|
505
|
+
for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
|
|
506
|
+
const childNode = oldSlotChildNodes[i];
|
|
507
|
+
if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
|
|
508
|
+
// // this child node in the old element is from another component
|
|
509
|
+
// // remove this node from the old slot's parent
|
|
510
|
+
// childNode.remove();
|
|
511
|
+
// and relocate it back to it's original location
|
|
512
|
+
parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
|
|
513
|
+
// remove the old original location comment entirely
|
|
514
|
+
// later on the patch function will know what to do
|
|
515
|
+
// and move this to the correct spot in need be
|
|
516
|
+
childNode['s-ol'].remove();
|
|
517
|
+
childNode['s-ol'] = undefined;
|
|
518
|
+
checkSlotRelocate = true;
|
|
519
|
+
}
|
|
520
|
+
if (recursive) {
|
|
521
|
+
putBackInOriginalLocation(childNode, recursive);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
plt.$flags$ &= ~1 /* isTmpDisconnected */;
|
|
525
|
+
};
|
|
369
526
|
const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
|
|
370
|
-
let containerElm = (parentElm);
|
|
527
|
+
let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
|
|
371
528
|
let childNode;
|
|
372
529
|
if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
|
|
373
530
|
containerElm = containerElm.shadowRoot;
|
|
374
531
|
}
|
|
375
532
|
for (; startIdx <= endIdx; ++startIdx) {
|
|
376
533
|
if (vnodes[startIdx]) {
|
|
377
|
-
childNode = createElm(null, parentVNode, startIdx);
|
|
534
|
+
childNode = createElm(null, parentVNode, startIdx, parentElm);
|
|
378
535
|
if (childNode) {
|
|
379
536
|
vnodes[startIdx].$elm$ = childNode;
|
|
380
|
-
containerElm.insertBefore(childNode, before);
|
|
537
|
+
containerElm.insertBefore(childNode, referenceNode(before) );
|
|
381
538
|
}
|
|
382
539
|
}
|
|
383
540
|
}
|
|
@@ -387,6 +544,20 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
|
|
|
387
544
|
if ((vnode = vnodes[startIdx])) {
|
|
388
545
|
elm = vnode.$elm$;
|
|
389
546
|
callNodeRefs(vnode);
|
|
547
|
+
{
|
|
548
|
+
// we're removing this element
|
|
549
|
+
// so it's possible we need to show slot fallback content now
|
|
550
|
+
checkSlotFallbackVisibility = true;
|
|
551
|
+
if (elm['s-ol']) {
|
|
552
|
+
// remove the original location comment
|
|
553
|
+
elm['s-ol'].remove();
|
|
554
|
+
}
|
|
555
|
+
else {
|
|
556
|
+
// it's possible that child nodes of the node
|
|
557
|
+
// that's being removed are slot nodes
|
|
558
|
+
putBackInOriginalLocation(elm, true);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
390
561
|
// remove the vnode's element from the dom
|
|
391
562
|
elm.remove();
|
|
392
563
|
}
|
|
@@ -427,12 +598,20 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
427
598
|
newEndVnode = newCh[--newEndIdx];
|
|
428
599
|
}
|
|
429
600
|
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
601
|
+
// Vnode moved right
|
|
602
|
+
if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
603
|
+
putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
|
|
604
|
+
}
|
|
430
605
|
patch(oldStartVnode, newEndVnode);
|
|
431
606
|
parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
|
|
432
607
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
433
608
|
newEndVnode = newCh[--newEndIdx];
|
|
434
609
|
}
|
|
435
610
|
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
611
|
+
// Vnode moved left
|
|
612
|
+
if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
613
|
+
putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
|
|
614
|
+
}
|
|
436
615
|
patch(oldEndVnode, newStartVnode);
|
|
437
616
|
parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
|
|
438
617
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
@@ -441,12 +620,12 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
441
620
|
else {
|
|
442
621
|
{
|
|
443
622
|
// new element
|
|
444
|
-
node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
|
|
623
|
+
node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
|
|
445
624
|
newStartVnode = newCh[++newStartIdx];
|
|
446
625
|
}
|
|
447
626
|
if (node) {
|
|
448
627
|
{
|
|
449
|
-
oldStartVnode.$elm
|
|
628
|
+
parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
|
|
450
629
|
}
|
|
451
630
|
}
|
|
452
631
|
}
|
|
@@ -462,16 +641,28 @@ const isSameVnode = (vnode1, vnode2) => {
|
|
|
462
641
|
// compare if two vnode to see if they're "technically" the same
|
|
463
642
|
// need to have the same element tag, and same key to be the same
|
|
464
643
|
if (vnode1.$tag$ === vnode2.$tag$) {
|
|
644
|
+
if (vnode1.$tag$ === 'slot') {
|
|
645
|
+
return vnode1.$name$ === vnode2.$name$;
|
|
646
|
+
}
|
|
465
647
|
return true;
|
|
466
648
|
}
|
|
467
649
|
return false;
|
|
468
650
|
};
|
|
651
|
+
const referenceNode = (node) => {
|
|
652
|
+
// this node was relocated to a new location in the dom
|
|
653
|
+
// because of some other component's slot
|
|
654
|
+
// but we still have an html comment in place of where
|
|
655
|
+
// it's original location was according to it's original vdom
|
|
656
|
+
return (node && node['s-ol']) || node;
|
|
657
|
+
};
|
|
658
|
+
const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
|
|
469
659
|
const patch = (oldVNode, newVNode) => {
|
|
470
660
|
const elm = (newVNode.$elm$ = oldVNode.$elm$);
|
|
471
661
|
const oldChildren = oldVNode.$children$;
|
|
472
662
|
const newChildren = newVNode.$children$;
|
|
473
663
|
const tag = newVNode.$tag$;
|
|
474
664
|
const text = newVNode.$text$;
|
|
665
|
+
let defaultHolder;
|
|
475
666
|
if (text === null) {
|
|
476
667
|
// element node
|
|
477
668
|
{
|
|
@@ -502,12 +693,147 @@ const patch = (oldVNode, newVNode) => {
|
|
|
502
693
|
removeVnodes(oldChildren, 0, oldChildren.length - 1);
|
|
503
694
|
}
|
|
504
695
|
}
|
|
696
|
+
else if ((defaultHolder = elm['s-cr'])) {
|
|
697
|
+
// this element has slotted content
|
|
698
|
+
defaultHolder.parentNode.textContent = text;
|
|
699
|
+
}
|
|
505
700
|
else if (oldVNode.$text$ !== text) {
|
|
506
701
|
// update the text content for the text only vnode
|
|
507
702
|
// and also only if the text is different than before
|
|
508
703
|
elm.data = text;
|
|
509
704
|
}
|
|
510
705
|
};
|
|
706
|
+
const updateFallbackSlotVisibility = (elm) => {
|
|
707
|
+
// tslint:disable-next-line: prefer-const
|
|
708
|
+
const childNodes = elm.childNodes;
|
|
709
|
+
let childNode;
|
|
710
|
+
let i;
|
|
711
|
+
let ilen;
|
|
712
|
+
let j;
|
|
713
|
+
let slotNameAttr;
|
|
714
|
+
let nodeType;
|
|
715
|
+
for (i = 0, ilen = childNodes.length; i < ilen; i++) {
|
|
716
|
+
childNode = childNodes[i];
|
|
717
|
+
if (childNode.nodeType === 1 /* ElementNode */) {
|
|
718
|
+
if (childNode['s-sr']) {
|
|
719
|
+
// this is a slot fallback node
|
|
720
|
+
// get the slot name for this slot reference node
|
|
721
|
+
slotNameAttr = childNode['s-sn'];
|
|
722
|
+
// by default always show a fallback slot node
|
|
723
|
+
// then hide it if there are other slots in the light dom
|
|
724
|
+
childNode.hidden = false;
|
|
725
|
+
for (j = 0; j < ilen; j++) {
|
|
726
|
+
nodeType = childNodes[j].nodeType;
|
|
727
|
+
if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
|
|
728
|
+
// this sibling node is from a different component OR is a named fallback slot node
|
|
729
|
+
if (nodeType === 1 /* ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
|
|
730
|
+
childNode.hidden = true;
|
|
731
|
+
break;
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
else {
|
|
735
|
+
// this is a default fallback slot node
|
|
736
|
+
// any element or text node (with content)
|
|
737
|
+
// should hide the default fallback slot node
|
|
738
|
+
if (nodeType === 1 /* ElementNode */ ||
|
|
739
|
+
(nodeType === 3 /* TextNode */ && childNodes[j].textContent.trim() !== '')) {
|
|
740
|
+
childNode.hidden = true;
|
|
741
|
+
break;
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
// keep drilling down
|
|
747
|
+
updateFallbackSlotVisibility(childNode);
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
};
|
|
751
|
+
const relocateNodes = [];
|
|
752
|
+
const relocateSlotContent = (elm) => {
|
|
753
|
+
// tslint:disable-next-line: prefer-const
|
|
754
|
+
let childNode;
|
|
755
|
+
let node;
|
|
756
|
+
let hostContentNodes;
|
|
757
|
+
let slotNameAttr;
|
|
758
|
+
let relocateNodeData;
|
|
759
|
+
let j;
|
|
760
|
+
let i = 0;
|
|
761
|
+
const childNodes = elm.childNodes;
|
|
762
|
+
const ilen = childNodes.length;
|
|
763
|
+
for (; i < ilen; i++) {
|
|
764
|
+
childNode = childNodes[i];
|
|
765
|
+
if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
|
|
766
|
+
// first got the content reference comment node
|
|
767
|
+
// then we got it's parent, which is where all the host content is in now
|
|
768
|
+
hostContentNodes = node.parentNode.childNodes;
|
|
769
|
+
slotNameAttr = childNode['s-sn'];
|
|
770
|
+
for (j = hostContentNodes.length - 1; j >= 0; j--) {
|
|
771
|
+
node = hostContentNodes[j];
|
|
772
|
+
if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
|
|
773
|
+
// let's do some relocating to its new home
|
|
774
|
+
// but never relocate a content reference node
|
|
775
|
+
// that is suppose to always represent the original content location
|
|
776
|
+
if (isNodeLocatedInSlot(node, slotNameAttr)) {
|
|
777
|
+
// it's possible we've already decided to relocate this node
|
|
778
|
+
relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
|
|
779
|
+
// made some changes to slots
|
|
780
|
+
// let's make sure we also double check
|
|
781
|
+
// fallbacks are correctly hidden or shown
|
|
782
|
+
checkSlotFallbackVisibility = true;
|
|
783
|
+
node['s-sn'] = node['s-sn'] || slotNameAttr;
|
|
784
|
+
if (relocateNodeData) {
|
|
785
|
+
// previously we never found a slot home for this node
|
|
786
|
+
// but turns out we did, so let's remember it now
|
|
787
|
+
relocateNodeData.$slotRefNode$ = childNode;
|
|
788
|
+
}
|
|
789
|
+
else {
|
|
790
|
+
// add to our list of nodes to relocate
|
|
791
|
+
relocateNodes.push({
|
|
792
|
+
$slotRefNode$: childNode,
|
|
793
|
+
$nodeToRelocate$: node,
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
if (node['s-sr']) {
|
|
797
|
+
relocateNodes.map((relocateNode) => {
|
|
798
|
+
if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
|
|
799
|
+
relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
|
|
800
|
+
if (relocateNodeData && !relocateNode.$slotRefNode$) {
|
|
801
|
+
relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
});
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
|
|
808
|
+
// so far this element does not have a slot home, not setting slotRefNode on purpose
|
|
809
|
+
// if we never find a home for this element then we'll need to hide it
|
|
810
|
+
relocateNodes.push({
|
|
811
|
+
$nodeToRelocate$: node,
|
|
812
|
+
});
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
if (childNode.nodeType === 1 /* ElementNode */) {
|
|
818
|
+
relocateSlotContent(childNode);
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
};
|
|
822
|
+
const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
|
|
823
|
+
if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
|
|
824
|
+
if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
|
|
825
|
+
return true;
|
|
826
|
+
}
|
|
827
|
+
if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
|
|
828
|
+
return true;
|
|
829
|
+
}
|
|
830
|
+
return false;
|
|
831
|
+
}
|
|
832
|
+
if (nodeToRelocate['s-sn'] === slotNameAttr) {
|
|
833
|
+
return true;
|
|
834
|
+
}
|
|
835
|
+
return slotNameAttr === '';
|
|
836
|
+
};
|
|
511
837
|
const callNodeRefs = (vNode) => {
|
|
512
838
|
{
|
|
513
839
|
vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
|
|
@@ -516,6 +842,7 @@ const callNodeRefs = (vNode) => {
|
|
|
516
842
|
};
|
|
517
843
|
const renderVdom = (hostRef, renderFnResults) => {
|
|
518
844
|
const hostElm = hostRef.$hostElement$;
|
|
845
|
+
const cmpMeta = hostRef.$cmpMeta$;
|
|
519
846
|
const oldVNode = hostRef.$vnode$ || newVNode(null, null);
|
|
520
847
|
const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
|
|
521
848
|
hostTagName = hostElm.tagName;
|
|
@@ -526,10 +853,105 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
526
853
|
{
|
|
527
854
|
scopeId = hostElm['s-sc'];
|
|
528
855
|
}
|
|
856
|
+
{
|
|
857
|
+
contentRef = hostElm['s-cr'];
|
|
858
|
+
useNativeShadowDom = (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
|
|
859
|
+
// always reset
|
|
860
|
+
checkSlotFallbackVisibility = false;
|
|
861
|
+
}
|
|
529
862
|
// synchronous patch
|
|
530
863
|
patch(oldVNode, rootVnode);
|
|
864
|
+
{
|
|
865
|
+
// while we're moving nodes around existing nodes, temporarily disable
|
|
866
|
+
// the disconnectCallback from working
|
|
867
|
+
plt.$flags$ |= 1 /* isTmpDisconnected */;
|
|
868
|
+
if (checkSlotRelocate) {
|
|
869
|
+
relocateSlotContent(rootVnode.$elm$);
|
|
870
|
+
let relocateData;
|
|
871
|
+
let nodeToRelocate;
|
|
872
|
+
let orgLocationNode;
|
|
873
|
+
let parentNodeRef;
|
|
874
|
+
let insertBeforeNode;
|
|
875
|
+
let refNode;
|
|
876
|
+
let i = 0;
|
|
877
|
+
for (; i < relocateNodes.length; i++) {
|
|
878
|
+
relocateData = relocateNodes[i];
|
|
879
|
+
nodeToRelocate = relocateData.$nodeToRelocate$;
|
|
880
|
+
if (!nodeToRelocate['s-ol']) {
|
|
881
|
+
// add a reference node marking this node's original location
|
|
882
|
+
// keep a reference to this node for later lookups
|
|
883
|
+
orgLocationNode =
|
|
884
|
+
doc.createTextNode('');
|
|
885
|
+
orgLocationNode['s-nr'] = nodeToRelocate;
|
|
886
|
+
nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
for (i = 0; i < relocateNodes.length; i++) {
|
|
890
|
+
relocateData = relocateNodes[i];
|
|
891
|
+
nodeToRelocate = relocateData.$nodeToRelocate$;
|
|
892
|
+
if (relocateData.$slotRefNode$) {
|
|
893
|
+
// by default we're just going to insert it directly
|
|
894
|
+
// after the slot reference node
|
|
895
|
+
parentNodeRef = relocateData.$slotRefNode$.parentNode;
|
|
896
|
+
insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
|
|
897
|
+
orgLocationNode = nodeToRelocate['s-ol'];
|
|
898
|
+
while ((orgLocationNode = orgLocationNode.previousSibling)) {
|
|
899
|
+
refNode = orgLocationNode['s-nr'];
|
|
900
|
+
if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
|
|
901
|
+
refNode = refNode.nextSibling;
|
|
902
|
+
if (!refNode || !refNode['s-nr']) {
|
|
903
|
+
insertBeforeNode = refNode;
|
|
904
|
+
break;
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
|
|
909
|
+
nodeToRelocate.nextSibling !== insertBeforeNode) {
|
|
910
|
+
// we've checked that it's worth while to relocate
|
|
911
|
+
// since that the node to relocate
|
|
912
|
+
// has a different next sibling or parent relocated
|
|
913
|
+
if (nodeToRelocate !== insertBeforeNode) {
|
|
914
|
+
if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
|
|
915
|
+
// probably a component in the index.html that doesn't have it's hostname set
|
|
916
|
+
nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
|
|
917
|
+
}
|
|
918
|
+
// add it back to the dom but in its new home
|
|
919
|
+
parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
else {
|
|
924
|
+
// this node doesn't have a slot home to go to, so let's hide it
|
|
925
|
+
if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
|
|
926
|
+
nodeToRelocate.hidden = true;
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
if (checkSlotFallbackVisibility) {
|
|
932
|
+
updateFallbackSlotVisibility(rootVnode.$elm$);
|
|
933
|
+
}
|
|
934
|
+
// done moving nodes around
|
|
935
|
+
// allow the disconnect callback to work again
|
|
936
|
+
plt.$flags$ &= ~1 /* isTmpDisconnected */;
|
|
937
|
+
// always reset
|
|
938
|
+
relocateNodes.length = 0;
|
|
939
|
+
}
|
|
531
940
|
};
|
|
532
941
|
const getElement = (ref) => (getHostRef(ref).$hostElement$ );
|
|
942
|
+
const createEvent = (ref, name, flags) => {
|
|
943
|
+
const elm = getElement(ref);
|
|
944
|
+
return {
|
|
945
|
+
emit: (detail) => {
|
|
946
|
+
return emitEvent(elm, name, {
|
|
947
|
+
bubbles: !!(flags & 4 /* Bubbles */),
|
|
948
|
+
composed: !!(flags & 2 /* Composed */),
|
|
949
|
+
cancelable: !!(flags & 1 /* Cancellable */),
|
|
950
|
+
detail,
|
|
951
|
+
});
|
|
952
|
+
},
|
|
953
|
+
};
|
|
954
|
+
};
|
|
533
955
|
/**
|
|
534
956
|
* Helper function to create & dispatch a custom Event on a provided target
|
|
535
957
|
* @param elm the target of the Event
|
|
@@ -575,6 +997,9 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
|
575
997
|
}
|
|
576
998
|
}
|
|
577
999
|
}
|
|
1000
|
+
{
|
|
1001
|
+
promise = then(promise, () => safeCall(instance, 'componentWillRender'));
|
|
1002
|
+
}
|
|
578
1003
|
endSchedule();
|
|
579
1004
|
return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
|
|
580
1005
|
};
|
|
@@ -751,6 +1176,7 @@ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propNam
|
|
|
751
1176
|
const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
752
1177
|
// check our new property value against our internal value
|
|
753
1178
|
const hostRef = getHostRef(ref);
|
|
1179
|
+
const elm = hostRef.$hostElement$ ;
|
|
754
1180
|
const oldVal = hostRef.$instanceValues$.get(propName);
|
|
755
1181
|
const flags = hostRef.$flags$;
|
|
756
1182
|
const instance = hostRef.$lazyInstance$ ;
|
|
@@ -763,6 +1189,22 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
763
1189
|
// set our new value!
|
|
764
1190
|
hostRef.$instanceValues$.set(propName, newVal);
|
|
765
1191
|
if (instance) {
|
|
1192
|
+
// get an array of method names of watch functions to call
|
|
1193
|
+
if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
|
|
1194
|
+
const watchMethods = cmpMeta.$watchers$[propName];
|
|
1195
|
+
if (watchMethods) {
|
|
1196
|
+
// this instance is watching for when this property changed
|
|
1197
|
+
watchMethods.map((watchMethodName) => {
|
|
1198
|
+
try {
|
|
1199
|
+
// fire off each of the watch methods that are watching this property
|
|
1200
|
+
instance[watchMethodName](newVal, oldVal, propName);
|
|
1201
|
+
}
|
|
1202
|
+
catch (e) {
|
|
1203
|
+
consoleError(e, elm);
|
|
1204
|
+
}
|
|
1205
|
+
});
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
766
1208
|
if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
|
|
767
1209
|
if (instance.componentShouldUpdate) {
|
|
768
1210
|
if (instance.componentShouldUpdate(newVal, oldVal, propName) === false) {
|
|
@@ -780,6 +1222,9 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
780
1222
|
};
|
|
781
1223
|
const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
782
1224
|
if (cmpMeta.$members$) {
|
|
1225
|
+
if (Cstr.watchers) {
|
|
1226
|
+
cmpMeta.$watchers$ = Cstr.watchers;
|
|
1227
|
+
}
|
|
783
1228
|
// It's better to have a const than two Object.entries()
|
|
784
1229
|
const members = Object.entries(cmpMeta.$members$);
|
|
785
1230
|
const prototype = Cstr.prototype;
|
|
@@ -884,6 +1329,12 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
884
1329
|
endLoad();
|
|
885
1330
|
}
|
|
886
1331
|
if (!Cstr.isProxied) {
|
|
1332
|
+
// we've never proxied this Constructor before
|
|
1333
|
+
// let's add the getters/setters to its prototype before
|
|
1334
|
+
// the first time we create an instance of the implementation
|
|
1335
|
+
{
|
|
1336
|
+
cmpMeta.$watchers$ = Cstr.watchers;
|
|
1337
|
+
}
|
|
887
1338
|
proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
|
|
888
1339
|
Cstr.isProxied = true;
|
|
889
1340
|
}
|
|
@@ -907,6 +1358,9 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
907
1358
|
{
|
|
908
1359
|
hostRef.$flags$ &= ~8 /* isConstructingInstance */;
|
|
909
1360
|
}
|
|
1361
|
+
{
|
|
1362
|
+
hostRef.$flags$ |= 128 /* isWatchReady */;
|
|
1363
|
+
}
|
|
910
1364
|
endNewInstance();
|
|
911
1365
|
}
|
|
912
1366
|
if (Cstr.style) {
|
|
@@ -944,6 +1398,15 @@ const connectedCallback = (elm) => {
|
|
|
944
1398
|
if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
|
|
945
1399
|
// first time this component has connected
|
|
946
1400
|
hostRef.$flags$ |= 1 /* hasConnected */;
|
|
1401
|
+
{
|
|
1402
|
+
// initUpdate
|
|
1403
|
+
// if the slot polyfill is required we'll need to put some nodes
|
|
1404
|
+
// in here to act as original content anchors as we move nodes around
|
|
1405
|
+
// host element has been connected to the DOM
|
|
1406
|
+
if ((cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */))) {
|
|
1407
|
+
setContentReference(elm);
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
947
1410
|
{
|
|
948
1411
|
// find the first ancestor component (if there is one) and register
|
|
949
1412
|
// this component as one of the actively loading child components for its ancestor
|
|
@@ -983,6 +1446,17 @@ const connectedCallback = (elm) => {
|
|
|
983
1446
|
endConnected();
|
|
984
1447
|
}
|
|
985
1448
|
};
|
|
1449
|
+
const setContentReference = (elm) => {
|
|
1450
|
+
// only required when we're NOT using native shadow dom (slot)
|
|
1451
|
+
// or this browser doesn't support native shadow dom
|
|
1452
|
+
// and this host element was NOT created with SSR
|
|
1453
|
+
// let's pick out the inner content for slot projection
|
|
1454
|
+
// create a node to represent where the original
|
|
1455
|
+
// content was first placed, which is useful later on
|
|
1456
|
+
const contentRefElm = (elm['s-cr'] = doc.createComment(''));
|
|
1457
|
+
contentRefElm['s-cn'] = true;
|
|
1458
|
+
elm.insertBefore(contentRefElm, elm.firstChild);
|
|
1459
|
+
};
|
|
986
1460
|
const disconnectedCallback = (elm) => {
|
|
987
1461
|
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
988
1462
|
const hostRef = getHostRef(elm);
|
|
@@ -1021,6 +1495,9 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1021
1495
|
{
|
|
1022
1496
|
cmpMeta.$listeners$ = compactMeta[3];
|
|
1023
1497
|
}
|
|
1498
|
+
{
|
|
1499
|
+
cmpMeta.$watchers$ = {};
|
|
1500
|
+
}
|
|
1024
1501
|
const tagName = cmpMeta.$tagName$;
|
|
1025
1502
|
const HostElement = class extends HTMLElement {
|
|
1026
1503
|
// StencilLazyHost
|
|
@@ -1174,6 +1651,7 @@ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
|
|
|
1174
1651
|
|
|
1175
1652
|
exports.Host = Host;
|
|
1176
1653
|
exports.bootstrapLazy = bootstrapLazy;
|
|
1654
|
+
exports.createEvent = createEvent;
|
|
1177
1655
|
exports.getElement = getElement;
|
|
1178
1656
|
exports.h = h;
|
|
1179
1657
|
exports.promiseResolve = promiseResolve;
|