@paperless/core 0.0.3-alpha.5 → 0.1.0-alpha.11
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 +160 -0
- package/README.md +31 -10
- package/dist/assets/icons/arrow.svg +2 -2
- package/dist/assets/icons/attachment.svg +2 -2
- package/dist/assets/icons/bread.svg +2 -2
- package/dist/assets/icons/calendar.svg +2 -2
- package/dist/assets/icons/car.svg +2 -2
- package/dist/assets/icons/checkmark.svg +2 -2
- package/dist/assets/icons/chevron.svg +2 -2
- package/dist/assets/icons/clock.svg +2 -2
- package/dist/assets/icons/cogs.svg +2 -2
- package/dist/assets/icons/comment.svg +2 -2
- package/dist/assets/icons/document.svg +2 -2
- package/dist/assets/icons/download.svg +2 -2
- package/dist/assets/icons/envelope.svg +2 -2
- package/dist/assets/icons/explanation.svg +2 -2
- package/dist/assets/icons/eye.svg +2 -2
- package/dist/assets/icons/filter.svg +2 -2
- package/dist/assets/icons/grid.svg +2 -2
- package/dist/assets/icons/headset.svg +2 -2
- package/dist/assets/icons/list.svg +2 -2
- package/dist/assets/icons/location.svg +2 -2
- package/dist/assets/icons/megaphone.svg +2 -2
- package/dist/assets/icons/minus.svg +2 -2
- package/dist/assets/icons/negative.svg +2 -2
- package/dist/assets/icons/pagination.svg +2 -2
- package/dist/assets/icons/payment.svg +2 -2
- package/dist/assets/icons/pencil.svg +2 -2
- package/dist/assets/icons/person.svg +2 -2
- package/dist/assets/icons/plus.svg +2 -2
- package/dist/assets/icons/question.svg +2 -2
- package/dist/assets/icons/receipt.svg +2 -2
- package/dist/assets/icons/report.svg +2 -2
- package/dist/assets/icons/search.svg +2 -2
- package/dist/assets/icons/settings.svg +2 -2
- package/dist/assets/icons/sick.svg +2 -2
- package/dist/assets/icons/tachometer.svg +2 -2
- package/dist/assets/icons/tool.svg +2 -2
- package/dist/assets/icons/trash.svg +2 -2
- package/dist/assets/icons/turn.svg +2 -2
- package/dist/assets/icons/upload.svg +2 -2
- package/dist/assets/icons/warning.svg +2 -2
- 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/build/p-23980fbb.entry.js +1 -0
- package/dist/build/p-31f80006.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-d750cdf6.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 +21 -10
- package/dist/build/paperless.esm.js +1 -1
- package/dist/cjs/{index-e3e940d8.js → index-6b6e08cc.js} +641 -15
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/p-avatar.cjs.entry.js +32 -0
- package/dist/cjs/p-button_3.cjs.entry.js +905 -0
- 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 +1423 -0
- 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 +164 -0
- package/dist/cjs/p-tooltip.cjs.entry.js +1915 -0
- package/dist/cjs/paperless.cjs.js +2 -2
- package/dist/collection/assets/icons/arrow.svg +2 -2
- package/dist/collection/assets/icons/attachment.svg +2 -2
- package/dist/collection/assets/icons/bread.svg +2 -2
- package/dist/collection/assets/icons/calendar.svg +2 -2
- package/dist/collection/assets/icons/car.svg +2 -2
- package/dist/collection/assets/icons/checkmark.svg +2 -2
- package/dist/collection/assets/icons/chevron.svg +2 -2
- package/dist/collection/assets/icons/clock.svg +2 -2
- package/dist/collection/assets/icons/cogs.svg +2 -2
- package/dist/collection/assets/icons/comment.svg +2 -2
- package/dist/collection/assets/icons/document.svg +2 -2
- package/dist/collection/assets/icons/download.svg +2 -2
- package/dist/collection/assets/icons/envelope.svg +2 -2
- package/dist/collection/assets/icons/explanation.svg +2 -2
- package/dist/collection/assets/icons/eye.svg +2 -2
- package/dist/collection/assets/icons/filter.svg +2 -2
- package/dist/collection/assets/icons/grid.svg +2 -2
- package/dist/collection/assets/icons/headset.svg +2 -2
- package/dist/collection/assets/icons/list.svg +2 -2
- package/dist/collection/assets/icons/location.svg +2 -2
- package/dist/collection/assets/icons/megaphone.svg +2 -2
- package/dist/collection/assets/icons/minus.svg +2 -2
- package/dist/collection/assets/icons/negative.svg +2 -2
- package/dist/collection/assets/icons/pagination.svg +2 -2
- package/dist/collection/assets/icons/payment.svg +2 -2
- package/dist/collection/assets/icons/pencil.svg +2 -2
- package/dist/collection/assets/icons/person.svg +2 -2
- package/dist/collection/assets/icons/plus.svg +2 -2
- package/dist/collection/assets/icons/question.svg +2 -2
- package/dist/collection/assets/icons/receipt.svg +2 -2
- package/dist/collection/assets/icons/report.svg +2 -2
- package/dist/collection/assets/icons/search.svg +2 -2
- package/dist/collection/assets/icons/settings.svg +2 -2
- package/dist/collection/assets/icons/sick.svg +2 -2
- package/dist/collection/assets/icons/tachometer.svg +2 -2
- package/dist/collection/assets/icons/tool.svg +2 -2
- package/dist/collection/assets/icons/trash.svg +2 -2
- package/dist/collection/assets/icons/turn.svg +2 -2
- package/dist/collection/assets/icons/upload.svg +2 -2
- package/dist/collection/assets/icons/warning.svg +2 -2
- 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 -1
- 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/atoms/icon/icon.component.js +107 -0
- package/dist/collection/components/atoms/illustration/illustration.component.js +32 -0
- 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/atoms/tooltip/tooltip.component.js +264 -0
- package/dist/collection/components/molecules/pagination/pagination.component.css +3 -0
- package/dist/collection/components/molecules/pagination/pagination.component.js +234 -0
- package/dist/collection/tailwind/border-radius.js +2 -0
- package/dist/collection/tailwind/grid.js +26 -0
- package/dist/collection/tailwind/rotate.js +8 -0
- package/dist/collection/tailwind/scale.js +3 -0
- package/dist/collection/tailwind.config.js +9 -5
- package/dist/collection/utils/icons.js +82 -0
- package/dist/collection/utils/illustrations.js +18 -0
- package/dist/components/icon.component.js +813 -0
- package/dist/components/index.d.ts +11 -0
- package/dist/components/index.js +11 -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 +68 -9
- 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.d.ts +11 -0
- package/dist/components/p-icon.js +6 -0
- package/dist/components/p-illustration.d.ts +11 -0
- package/dist/components/p-illustration.js +1437 -0
- 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 +193 -0
- package/dist/components/p-tooltip.d.ts +11 -0
- package/dist/components/p-tooltip.js +6 -0
- package/dist/components/pagination-item.component.js +36 -0
- package/dist/components/tooltip.component.js +1932 -0
- package/dist/esm/{index-100a5ae6.js → index-5c917d13.js} +639 -16
- 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 +1419 -0
- 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 +160 -0
- package/dist/esm/p-tooltip.entry.js +1911 -0
- 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/paperless/p-23980fbb.entry.js +1 -0
- package/dist/paperless/p-31f80006.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-d750cdf6.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 +11373 -7666
- package/dist/paperless/paperless.esm.js +1 -1
- package/dist/sw.js +301 -26
- package/dist/tailwind.config.js +9 -5
- 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/atoms/icon/icon.component.d.ts +23 -0
- package/dist/types/components/atoms/illustration/illustration.component.d.ts +9 -0
- 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 +36 -0
- package/dist/types/components.d.ts +456 -4
- package/dist/types/utils/icons.d.ts +43 -0
- package/dist/types/utils/illustrations.d.ts +11 -0
- package/package.json +5 -2
- package/dist/build/p-54459ae1.js +0 -2
- package/dist/build/p-e61ff856.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 -41
- package/dist/esm/p-button.entry.js +0 -19
- package/dist/paperless/p-54459ae1.js +0 -2
- package/dist/paperless/p-e61ff856.entry.js +0 -1
- package/dist/types/components/button/button.component.d.ts +0 -7
|
@@ -23,7 +23,12 @@ 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;
|
|
31
|
+
let isSvgMode = false;
|
|
27
32
|
let queuePending = false;
|
|
28
33
|
const win = typeof window !== 'undefined' ? window : {};
|
|
29
34
|
const doc = win.document || { head: {} };
|
|
@@ -46,6 +51,40 @@ const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
|
|
|
46
51
|
return false;
|
|
47
52
|
})()
|
|
48
53
|
;
|
|
54
|
+
const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
|
|
55
|
+
if (listeners) {
|
|
56
|
+
listeners.map(([flags, name, method]) => {
|
|
57
|
+
const target = getHostListenerTarget(elm, flags) ;
|
|
58
|
+
const handler = hostListenerProxy(hostRef, method);
|
|
59
|
+
const opts = hostListenerOpts(flags);
|
|
60
|
+
plt.ael(target, name, handler, opts);
|
|
61
|
+
(hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
66
|
+
try {
|
|
67
|
+
{
|
|
68
|
+
if (hostRef.$flags$ & 256 /* isListenReady */) {
|
|
69
|
+
// instance is ready, let's call it's member method for this event
|
|
70
|
+
hostRef.$lazyInstance$[methodName](ev);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
(hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
catch (e) {
|
|
78
|
+
consoleError(e);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const getHostListenerTarget = (elm, flags) => {
|
|
82
|
+
if (flags & 4 /* TargetDocument */)
|
|
83
|
+
return doc;
|
|
84
|
+
return elm;
|
|
85
|
+
};
|
|
86
|
+
// prettier-ignore
|
|
87
|
+
const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
|
|
49
88
|
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
50
89
|
const createTime = (fnName, tagName = '') => {
|
|
51
90
|
{
|
|
@@ -153,6 +192,7 @@ const isComplexType = (o) => {
|
|
|
153
192
|
// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
|
|
154
193
|
const h = (nodeName, vnodeData, ...children) => {
|
|
155
194
|
let child = null;
|
|
195
|
+
let slotName = null;
|
|
156
196
|
let simple = false;
|
|
157
197
|
let lastSimple = false;
|
|
158
198
|
const vNodeChildren = [];
|
|
@@ -180,6 +220,9 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
180
220
|
};
|
|
181
221
|
walk(children);
|
|
182
222
|
if (vnodeData) {
|
|
223
|
+
if (vnodeData.name) {
|
|
224
|
+
slotName = vnodeData.name;
|
|
225
|
+
}
|
|
183
226
|
{
|
|
184
227
|
const classData = vnodeData.className || vnodeData.class;
|
|
185
228
|
if (classData) {
|
|
@@ -192,11 +235,18 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
192
235
|
}
|
|
193
236
|
}
|
|
194
237
|
}
|
|
238
|
+
if (typeof nodeName === 'function') {
|
|
239
|
+
// nodeName is a functional component
|
|
240
|
+
return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
|
|
241
|
+
}
|
|
195
242
|
const vnode = newVNode(nodeName, null);
|
|
196
243
|
vnode.$attrs$ = vnodeData;
|
|
197
244
|
if (vNodeChildren.length > 0) {
|
|
198
245
|
vnode.$children$ = vNodeChildren;
|
|
199
246
|
}
|
|
247
|
+
{
|
|
248
|
+
vnode.$name$ = slotName;
|
|
249
|
+
}
|
|
200
250
|
return vnode;
|
|
201
251
|
};
|
|
202
252
|
const newVNode = (tag, text) => {
|
|
@@ -210,10 +260,43 @@ const newVNode = (tag, text) => {
|
|
|
210
260
|
{
|
|
211
261
|
vnode.$attrs$ = null;
|
|
212
262
|
}
|
|
263
|
+
{
|
|
264
|
+
vnode.$name$ = null;
|
|
265
|
+
}
|
|
213
266
|
return vnode;
|
|
214
267
|
};
|
|
215
268
|
const Host = {};
|
|
216
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
|
+
};
|
|
217
300
|
/**
|
|
218
301
|
* Production setAccessor() function based on Preact by
|
|
219
302
|
* Jason Miller (@developit)
|
|
@@ -224,7 +307,8 @@ const isHost = (node) => node && node.$tag$ === Host;
|
|
|
224
307
|
*/
|
|
225
308
|
const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
226
309
|
if (oldValue !== newValue) {
|
|
227
|
-
memberName
|
|
310
|
+
let isProp = isMemberInElement(elm, memberName);
|
|
311
|
+
let ln = memberName.toLowerCase();
|
|
228
312
|
if (memberName === 'class') {
|
|
229
313
|
const classList = elm.classList;
|
|
230
314
|
const oldClasses = parseClassList(oldValue);
|
|
@@ -232,6 +316,86 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
232
316
|
classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
|
|
233
317
|
classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
|
|
234
318
|
}
|
|
319
|
+
else if (memberName === 'ref') {
|
|
320
|
+
// minifier will clean this up
|
|
321
|
+
if (newValue) {
|
|
322
|
+
newValue(elm);
|
|
323
|
+
}
|
|
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
|
+
}
|
|
364
|
+
else {
|
|
365
|
+
// Set property if it exists and it's not a SVG
|
|
366
|
+
const isComplex = isComplexType(newValue);
|
|
367
|
+
if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
|
|
368
|
+
try {
|
|
369
|
+
if (!elm.tagName.includes('-')) {
|
|
370
|
+
const n = newValue == null ? '' : newValue;
|
|
371
|
+
// Workaround for Safari, moving the <input> caret when re-assigning the same valued
|
|
372
|
+
if (memberName === 'list') {
|
|
373
|
+
isProp = false;
|
|
374
|
+
}
|
|
375
|
+
else if (oldValue == null || elm[memberName] != n) {
|
|
376
|
+
elm[memberName] = n;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
else {
|
|
380
|
+
elm[memberName] = newValue;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
catch (e) { }
|
|
384
|
+
}
|
|
385
|
+
if (newValue == null || newValue === false) {
|
|
386
|
+
if (newValue !== false || elm.getAttribute(memberName) === '') {
|
|
387
|
+
{
|
|
388
|
+
elm.removeAttribute(memberName);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
|
|
393
|
+
newValue = newValue === true ? '' : newValue;
|
|
394
|
+
{
|
|
395
|
+
elm.setAttribute(memberName, newValue);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
235
399
|
}
|
|
236
400
|
};
|
|
237
401
|
const parseClassListRegex = /\s/;
|
|
@@ -249,13 +413,13 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
|
249
413
|
// remove attributes no longer present on the vnode by setting them to undefined
|
|
250
414
|
for (memberName in oldVnodeAttrs) {
|
|
251
415
|
if (!(memberName in newVnodeAttrs)) {
|
|
252
|
-
setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined);
|
|
416
|
+
setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
|
|
253
417
|
}
|
|
254
418
|
}
|
|
255
419
|
}
|
|
256
420
|
// add new & update changed attributes
|
|
257
421
|
for (memberName in newVnodeAttrs) {
|
|
258
|
-
setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName]);
|
|
422
|
+
setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
|
|
259
423
|
}
|
|
260
424
|
};
|
|
261
425
|
const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
@@ -264,12 +428,39 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
264
428
|
let i = 0;
|
|
265
429
|
let elm;
|
|
266
430
|
let childNode;
|
|
267
|
-
|
|
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
|
+
}
|
|
447
|
+
if (newVNode.$text$ !== null) {
|
|
448
|
+
// create text node
|
|
449
|
+
elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
|
|
450
|
+
}
|
|
451
|
+
else if (newVNode.$flags$ & 1 /* isSlotReference */) {
|
|
452
|
+
// create a slot reference node
|
|
453
|
+
elm = newVNode.$elm$ =
|
|
454
|
+
doc.createTextNode('');
|
|
455
|
+
}
|
|
456
|
+
else {
|
|
268
457
|
// create element
|
|
269
|
-
elm = newVNode.$elm$ = (doc.createElement(newVNode.$
|
|
458
|
+
elm = newVNode.$elm$ = (doc.createElement(newVNode.$flags$ & 2 /* isSlotFallback */
|
|
459
|
+
? 'slot-fb'
|
|
460
|
+
: newVNode.$tag$));
|
|
270
461
|
// add css classes, attrs, props, listeners, etc.
|
|
271
462
|
{
|
|
272
|
-
updateElement(null, newVNode);
|
|
463
|
+
updateElement(null, newVNode, isSvgMode);
|
|
273
464
|
}
|
|
274
465
|
if (isDef(scopeId) && elm['s-si'] !== scopeId) {
|
|
275
466
|
// if there is a scopeId and this is the initial render
|
|
@@ -279,7 +470,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
279
470
|
if (newVNode.$children$) {
|
|
280
471
|
for (i = 0; i < newVNode.$children$.length; ++i) {
|
|
281
472
|
// create the node
|
|
282
|
-
childNode = createElm(oldParentVNode, newVNode, i);
|
|
473
|
+
childNode = createElm(oldParentVNode, newVNode, i, elm);
|
|
283
474
|
// return node could have been null
|
|
284
475
|
if (childNode) {
|
|
285
476
|
// append our new node
|
|
@@ -288,20 +479,62 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
288
479
|
}
|
|
289
480
|
}
|
|
290
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
|
+
}
|
|
291
500
|
return elm;
|
|
292
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
|
+
};
|
|
293
526
|
const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
|
|
294
|
-
let containerElm = (parentElm);
|
|
527
|
+
let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
|
|
295
528
|
let childNode;
|
|
296
529
|
if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
|
|
297
530
|
containerElm = containerElm.shadowRoot;
|
|
298
531
|
}
|
|
299
532
|
for (; startIdx <= endIdx; ++startIdx) {
|
|
300
533
|
if (vnodes[startIdx]) {
|
|
301
|
-
childNode = createElm(null, parentVNode, startIdx);
|
|
534
|
+
childNode = createElm(null, parentVNode, startIdx, parentElm);
|
|
302
535
|
if (childNode) {
|
|
303
536
|
vnodes[startIdx].$elm$ = childNode;
|
|
304
|
-
containerElm.insertBefore(childNode, before);
|
|
537
|
+
containerElm.insertBefore(childNode, referenceNode(before) );
|
|
305
538
|
}
|
|
306
539
|
}
|
|
307
540
|
}
|
|
@@ -310,6 +543,21 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
|
|
|
310
543
|
for (; startIdx <= endIdx; ++startIdx) {
|
|
311
544
|
if ((vnode = vnodes[startIdx])) {
|
|
312
545
|
elm = vnode.$elm$;
|
|
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
|
+
}
|
|
313
561
|
// remove the vnode's element from the dom
|
|
314
562
|
elm.remove();
|
|
315
563
|
}
|
|
@@ -350,12 +598,20 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
350
598
|
newEndVnode = newCh[--newEndIdx];
|
|
351
599
|
}
|
|
352
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
|
+
}
|
|
353
605
|
patch(oldStartVnode, newEndVnode);
|
|
354
606
|
parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
|
|
355
607
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
356
608
|
newEndVnode = newCh[--newEndIdx];
|
|
357
609
|
}
|
|
358
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
|
+
}
|
|
359
615
|
patch(oldEndVnode, newStartVnode);
|
|
360
616
|
parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
|
|
361
617
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
@@ -364,12 +620,12 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
364
620
|
else {
|
|
365
621
|
{
|
|
366
622
|
// new element
|
|
367
|
-
node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
|
|
623
|
+
node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
|
|
368
624
|
newStartVnode = newCh[++newStartIdx];
|
|
369
625
|
}
|
|
370
626
|
if (node) {
|
|
371
627
|
{
|
|
372
|
-
oldStartVnode.$elm
|
|
628
|
+
parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
|
|
373
629
|
}
|
|
374
630
|
}
|
|
375
631
|
}
|
|
@@ -385,16 +641,29 @@ const isSameVnode = (vnode1, vnode2) => {
|
|
|
385
641
|
// compare if two vnode to see if they're "technically" the same
|
|
386
642
|
// need to have the same element tag, and same key to be the same
|
|
387
643
|
if (vnode1.$tag$ === vnode2.$tag$) {
|
|
644
|
+
if (vnode1.$tag$ === 'slot') {
|
|
645
|
+
return vnode1.$name$ === vnode2.$name$;
|
|
646
|
+
}
|
|
388
647
|
return true;
|
|
389
648
|
}
|
|
390
649
|
return false;
|
|
391
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;
|
|
392
659
|
const patch = (oldVNode, newVNode) => {
|
|
393
660
|
const elm = (newVNode.$elm$ = oldVNode.$elm$);
|
|
394
661
|
const oldChildren = oldVNode.$children$;
|
|
395
662
|
const newChildren = newVNode.$children$;
|
|
396
663
|
const tag = newVNode.$tag$;
|
|
397
|
-
|
|
664
|
+
const text = newVNode.$text$;
|
|
665
|
+
let defaultHolder;
|
|
666
|
+
if (text === null) {
|
|
398
667
|
// element node
|
|
399
668
|
{
|
|
400
669
|
if (tag === 'slot')
|
|
@@ -403,7 +672,7 @@ const patch = (oldVNode, newVNode) => {
|
|
|
403
672
|
// either this is the first render of an element OR it's an update
|
|
404
673
|
// AND we already know it's possible it could have changed
|
|
405
674
|
// this updates the element's css classes, attrs, props, listeners, etc.
|
|
406
|
-
updateElement(oldVNode, newVNode);
|
|
675
|
+
updateElement(oldVNode, newVNode, isSvgMode);
|
|
407
676
|
}
|
|
408
677
|
}
|
|
409
678
|
if (oldChildren !== null && newChildren !== null) {
|
|
@@ -411,6 +680,11 @@ const patch = (oldVNode, newVNode) => {
|
|
|
411
680
|
updateChildren(elm, oldChildren, newVNode, newChildren);
|
|
412
681
|
}
|
|
413
682
|
else if (newChildren !== null) {
|
|
683
|
+
// no old child vnodes, but there are new child vnodes to add
|
|
684
|
+
if (oldVNode.$text$ !== null) {
|
|
685
|
+
// the old vnode was text, so be sure to clear it out
|
|
686
|
+
elm.textContent = '';
|
|
687
|
+
}
|
|
414
688
|
// add the new vnode children
|
|
415
689
|
addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
|
|
416
690
|
}
|
|
@@ -419,9 +693,156 @@ const patch = (oldVNode, newVNode) => {
|
|
|
419
693
|
removeVnodes(oldChildren, 0, oldChildren.length - 1);
|
|
420
694
|
}
|
|
421
695
|
}
|
|
696
|
+
else if ((defaultHolder = elm['s-cr'])) {
|
|
697
|
+
// this element has slotted content
|
|
698
|
+
defaultHolder.parentNode.textContent = text;
|
|
699
|
+
}
|
|
700
|
+
else if (oldVNode.$text$ !== text) {
|
|
701
|
+
// update the text content for the text only vnode
|
|
702
|
+
// and also only if the text is different than before
|
|
703
|
+
elm.data = text;
|
|
704
|
+
}
|
|
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
|
+
};
|
|
837
|
+
const callNodeRefs = (vNode) => {
|
|
838
|
+
{
|
|
839
|
+
vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
|
|
840
|
+
vNode.$children$ && vNode.$children$.map(callNodeRefs);
|
|
841
|
+
}
|
|
422
842
|
};
|
|
423
843
|
const renderVdom = (hostRef, renderFnResults) => {
|
|
424
844
|
const hostElm = hostRef.$hostElement$;
|
|
845
|
+
const cmpMeta = hostRef.$cmpMeta$;
|
|
425
846
|
const oldVNode = hostRef.$vnode$ || newVNode(null, null);
|
|
426
847
|
const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
|
|
427
848
|
hostTagName = hostElm.tagName;
|
|
@@ -432,8 +853,104 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
432
853
|
{
|
|
433
854
|
scopeId = hostElm['s-sc'];
|
|
434
855
|
}
|
|
856
|
+
{
|
|
857
|
+
contentRef = hostElm['s-cr'];
|
|
858
|
+
useNativeShadowDom = (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
|
|
859
|
+
// always reset
|
|
860
|
+
checkSlotFallbackVisibility = false;
|
|
861
|
+
}
|
|
435
862
|
// synchronous patch
|
|
436
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
|
+
}
|
|
940
|
+
};
|
|
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
|
+
};
|
|
437
954
|
};
|
|
438
955
|
/**
|
|
439
956
|
* Helper function to create & dispatch a custom Event on a provided target
|
|
@@ -471,6 +988,18 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
|
471
988
|
const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
|
|
472
989
|
const instance = hostRef.$lazyInstance$ ;
|
|
473
990
|
let promise;
|
|
991
|
+
if (isInitialLoad) {
|
|
992
|
+
{
|
|
993
|
+
hostRef.$flags$ |= 256 /* isListenReady */;
|
|
994
|
+
if (hostRef.$queuedListeners$) {
|
|
995
|
+
hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
|
|
996
|
+
hostRef.$queuedListeners$ = null;
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
{
|
|
1001
|
+
promise = then(promise, () => safeCall(instance, 'componentWillRender'));
|
|
1002
|
+
}
|
|
474
1003
|
endSchedule();
|
|
475
1004
|
return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
|
|
476
1005
|
};
|
|
@@ -580,6 +1109,17 @@ const appDidLoad = (who) => {
|
|
|
580
1109
|
}
|
|
581
1110
|
nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
|
|
582
1111
|
};
|
|
1112
|
+
const safeCall = (instance, method, arg) => {
|
|
1113
|
+
if (instance && instance[method]) {
|
|
1114
|
+
try {
|
|
1115
|
+
return instance[method](arg);
|
|
1116
|
+
}
|
|
1117
|
+
catch (e) {
|
|
1118
|
+
consoleError(e);
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
return undefined;
|
|
1122
|
+
};
|
|
583
1123
|
const then = (promise, thenFn) => {
|
|
584
1124
|
return promise && promise.then ? promise.then(thenFn) : thenFn();
|
|
585
1125
|
};
|
|
@@ -611,6 +1151,15 @@ const addHydratedFlag = (elm) => elm.classList.add('hydrated')
|
|
|
611
1151
|
const parsePropertyValue = (propValue, propType) => {
|
|
612
1152
|
// ensure this value is of the correct prop type
|
|
613
1153
|
if (propValue != null && !isComplexType(propValue)) {
|
|
1154
|
+
if (propType & 4 /* Boolean */) {
|
|
1155
|
+
// per the HTML spec, any string value means it is a boolean true value
|
|
1156
|
+
// but we'll cheat here and say that the string "false" is the boolean false
|
|
1157
|
+
return propValue === 'false' ? false : propValue === '' || !!propValue;
|
|
1158
|
+
}
|
|
1159
|
+
if (propType & 2 /* Number */) {
|
|
1160
|
+
// force it to be a number
|
|
1161
|
+
return parseFloat(propValue);
|
|
1162
|
+
}
|
|
614
1163
|
if (propType & 1 /* String */) {
|
|
615
1164
|
// could have been passed as a number or boolean
|
|
616
1165
|
// but we still want it as a string
|
|
@@ -627,6 +1176,7 @@ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propNam
|
|
|
627
1176
|
const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
628
1177
|
// check our new property value against our internal value
|
|
629
1178
|
const hostRef = getHostRef(ref);
|
|
1179
|
+
const elm = hostRef.$hostElement$ ;
|
|
630
1180
|
const oldVal = hostRef.$instanceValues$.get(propName);
|
|
631
1181
|
const flags = hostRef.$flags$;
|
|
632
1182
|
const instance = hostRef.$lazyInstance$ ;
|
|
@@ -639,7 +1189,28 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
639
1189
|
// set our new value!
|
|
640
1190
|
hostRef.$instanceValues$.set(propName, newVal);
|
|
641
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
|
+
}
|
|
642
1208
|
if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
|
|
1209
|
+
if (instance.componentShouldUpdate) {
|
|
1210
|
+
if (instance.componentShouldUpdate(newVal, oldVal, propName) === false) {
|
|
1211
|
+
return;
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
643
1214
|
// looks like this value actually changed, so we've got work to do!
|
|
644
1215
|
// but only if we've already rendered, otherwise just chill out
|
|
645
1216
|
// queue that we need to do an update, but don't worry about queuing
|
|
@@ -651,6 +1222,9 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
651
1222
|
};
|
|
652
1223
|
const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
653
1224
|
if (cmpMeta.$members$) {
|
|
1225
|
+
if (Cstr.watchers) {
|
|
1226
|
+
cmpMeta.$watchers$ = Cstr.watchers;
|
|
1227
|
+
}
|
|
654
1228
|
// It's better to have a const than two Object.entries()
|
|
655
1229
|
const members = Object.entries(cmpMeta.$members$);
|
|
656
1230
|
const prototype = Cstr.prototype;
|
|
@@ -755,6 +1329,12 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
755
1329
|
endLoad();
|
|
756
1330
|
}
|
|
757
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
|
+
}
|
|
758
1338
|
proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
|
|
759
1339
|
Cstr.isProxied = true;
|
|
760
1340
|
}
|
|
@@ -778,6 +1358,9 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
778
1358
|
{
|
|
779
1359
|
hostRef.$flags$ &= ~8 /* isConstructingInstance */;
|
|
780
1360
|
}
|
|
1361
|
+
{
|
|
1362
|
+
hostRef.$flags$ |= 128 /* isWatchReady */;
|
|
1363
|
+
}
|
|
781
1364
|
endNewInstance();
|
|
782
1365
|
}
|
|
783
1366
|
if (Cstr.style) {
|
|
@@ -815,6 +1398,15 @@ const connectedCallback = (elm) => {
|
|
|
815
1398
|
if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
|
|
816
1399
|
// first time this component has connected
|
|
817
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
|
+
}
|
|
818
1410
|
{
|
|
819
1411
|
// find the first ancestor component (if there is one) and register
|
|
820
1412
|
// this component as one of the actively loading child components for its ancestor
|
|
@@ -845,12 +1437,35 @@ const connectedCallback = (elm) => {
|
|
|
845
1437
|
initializeComponent(elm, hostRef, cmpMeta);
|
|
846
1438
|
}
|
|
847
1439
|
}
|
|
1440
|
+
else {
|
|
1441
|
+
// not the first time this has connected
|
|
1442
|
+
// reattach any event listeners to the host
|
|
1443
|
+
// since they would have been removed when disconnected
|
|
1444
|
+
addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
|
|
1445
|
+
}
|
|
848
1446
|
endConnected();
|
|
849
1447
|
}
|
|
850
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
|
+
};
|
|
851
1460
|
const disconnectedCallback = (elm) => {
|
|
852
1461
|
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
853
|
-
getHostRef(elm);
|
|
1462
|
+
const hostRef = getHostRef(elm);
|
|
1463
|
+
{
|
|
1464
|
+
if (hostRef.$rmListeners$) {
|
|
1465
|
+
hostRef.$rmListeners$.map((rmListener) => rmListener());
|
|
1466
|
+
hostRef.$rmListeners$ = undefined;
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
854
1469
|
}
|
|
855
1470
|
};
|
|
856
1471
|
const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
@@ -877,6 +1492,12 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
877
1492
|
{
|
|
878
1493
|
cmpMeta.$members$ = compactMeta[2];
|
|
879
1494
|
}
|
|
1495
|
+
{
|
|
1496
|
+
cmpMeta.$listeners$ = compactMeta[3];
|
|
1497
|
+
}
|
|
1498
|
+
{
|
|
1499
|
+
cmpMeta.$watchers$ = {};
|
|
1500
|
+
}
|
|
880
1501
|
const tagName = cmpMeta.$tagName$;
|
|
881
1502
|
const HostElement = class extends HTMLElement {
|
|
882
1503
|
// StencilLazyHost
|
|
@@ -957,8 +1578,10 @@ const registerHost = (elm, cmpMeta) => {
|
|
|
957
1578
|
elm['s-p'] = [];
|
|
958
1579
|
elm['s-rc'] = [];
|
|
959
1580
|
}
|
|
1581
|
+
addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
|
|
960
1582
|
return hostRefs.set(elm, hostRef);
|
|
961
1583
|
};
|
|
1584
|
+
const isMemberInElement = (elm, memberName) => memberName in elm;
|
|
962
1585
|
const consoleError = (e, el) => (0, console.error)(e, el);
|
|
963
1586
|
const cmpModules = /*@__PURE__*/ new Map();
|
|
964
1587
|
const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
@@ -1026,7 +1649,10 @@ const flush = () => {
|
|
|
1026
1649
|
const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
|
|
1027
1650
|
const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
|
|
1028
1651
|
|
|
1652
|
+
exports.Host = Host;
|
|
1029
1653
|
exports.bootstrapLazy = bootstrapLazy;
|
|
1654
|
+
exports.createEvent = createEvent;
|
|
1655
|
+
exports.getElement = getElement;
|
|
1030
1656
|
exports.h = h;
|
|
1031
1657
|
exports.promiseResolve = promiseResolve;
|
|
1032
1658
|
exports.registerInstance = registerInstance;
|