@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
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
const NAMESPACE = 'paperless';
|
|
2
2
|
|
|
3
3
|
let scopeId;
|
|
4
|
+
let contentRef;
|
|
4
5
|
let hostTagName;
|
|
6
|
+
let useNativeShadowDom = false;
|
|
7
|
+
let checkSlotFallbackVisibility = false;
|
|
8
|
+
let checkSlotRelocate = false;
|
|
5
9
|
let isSvgMode = false;
|
|
6
10
|
let queuePending = false;
|
|
7
11
|
const win = typeof window !== 'undefined' ? window : {};
|
|
@@ -28,7 +32,7 @@ const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
|
|
|
28
32
|
const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
|
|
29
33
|
if (listeners) {
|
|
30
34
|
listeners.map(([flags, name, method]) => {
|
|
31
|
-
const target = elm;
|
|
35
|
+
const target = getHostListenerTarget(elm, flags) ;
|
|
32
36
|
const handler = hostListenerProxy(hostRef, method);
|
|
33
37
|
const opts = hostListenerOpts(flags);
|
|
34
38
|
plt.ael(target, name, handler, opts);
|
|
@@ -52,6 +56,11 @@ const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
|
52
56
|
consoleError(e);
|
|
53
57
|
}
|
|
54
58
|
};
|
|
59
|
+
const getHostListenerTarget = (elm, flags) => {
|
|
60
|
+
if (flags & 4 /* TargetDocument */)
|
|
61
|
+
return doc;
|
|
62
|
+
return elm;
|
|
63
|
+
};
|
|
55
64
|
// prettier-ignore
|
|
56
65
|
const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
|
|
57
66
|
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
@@ -161,6 +170,7 @@ const isComplexType = (o) => {
|
|
|
161
170
|
// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
|
|
162
171
|
const h = (nodeName, vnodeData, ...children) => {
|
|
163
172
|
let child = null;
|
|
173
|
+
let slotName = null;
|
|
164
174
|
let simple = false;
|
|
165
175
|
let lastSimple = false;
|
|
166
176
|
const vNodeChildren = [];
|
|
@@ -188,6 +198,9 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
188
198
|
};
|
|
189
199
|
walk(children);
|
|
190
200
|
if (vnodeData) {
|
|
201
|
+
if (vnodeData.name) {
|
|
202
|
+
slotName = vnodeData.name;
|
|
203
|
+
}
|
|
191
204
|
{
|
|
192
205
|
const classData = vnodeData.className || vnodeData.class;
|
|
193
206
|
if (classData) {
|
|
@@ -200,11 +213,18 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
200
213
|
}
|
|
201
214
|
}
|
|
202
215
|
}
|
|
216
|
+
if (typeof nodeName === 'function') {
|
|
217
|
+
// nodeName is a functional component
|
|
218
|
+
return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
|
|
219
|
+
}
|
|
203
220
|
const vnode = newVNode(nodeName, null);
|
|
204
221
|
vnode.$attrs$ = vnodeData;
|
|
205
222
|
if (vNodeChildren.length > 0) {
|
|
206
223
|
vnode.$children$ = vNodeChildren;
|
|
207
224
|
}
|
|
225
|
+
{
|
|
226
|
+
vnode.$name$ = slotName;
|
|
227
|
+
}
|
|
208
228
|
return vnode;
|
|
209
229
|
};
|
|
210
230
|
const newVNode = (tag, text) => {
|
|
@@ -218,10 +238,43 @@ const newVNode = (tag, text) => {
|
|
|
218
238
|
{
|
|
219
239
|
vnode.$attrs$ = null;
|
|
220
240
|
}
|
|
241
|
+
{
|
|
242
|
+
vnode.$name$ = null;
|
|
243
|
+
}
|
|
221
244
|
return vnode;
|
|
222
245
|
};
|
|
223
246
|
const Host = {};
|
|
224
247
|
const isHost = (node) => node && node.$tag$ === Host;
|
|
248
|
+
const vdomFnUtils = {
|
|
249
|
+
forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
|
|
250
|
+
map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
|
|
251
|
+
};
|
|
252
|
+
const convertToPublic = (node) => ({
|
|
253
|
+
vattrs: node.$attrs$,
|
|
254
|
+
vchildren: node.$children$,
|
|
255
|
+
vkey: node.$key$,
|
|
256
|
+
vname: node.$name$,
|
|
257
|
+
vtag: node.$tag$,
|
|
258
|
+
vtext: node.$text$,
|
|
259
|
+
});
|
|
260
|
+
const convertToPrivate = (node) => {
|
|
261
|
+
if (typeof node.vtag === 'function') {
|
|
262
|
+
const vnodeData = Object.assign({}, node.vattrs);
|
|
263
|
+
if (node.vkey) {
|
|
264
|
+
vnodeData.key = node.vkey;
|
|
265
|
+
}
|
|
266
|
+
if (node.vname) {
|
|
267
|
+
vnodeData.name = node.vname;
|
|
268
|
+
}
|
|
269
|
+
return h(node.vtag, vnodeData, ...(node.vchildren || []));
|
|
270
|
+
}
|
|
271
|
+
const vnode = newVNode(node.vtag, node.vtext);
|
|
272
|
+
vnode.$attrs$ = node.vattrs;
|
|
273
|
+
vnode.$children$ = node.vchildren;
|
|
274
|
+
vnode.$key$ = node.vkey;
|
|
275
|
+
vnode.$name$ = node.vname;
|
|
276
|
+
return vnode;
|
|
277
|
+
};
|
|
225
278
|
/**
|
|
226
279
|
* Production setAccessor() function based on Preact by
|
|
227
280
|
* Jason Miller (@developit)
|
|
@@ -233,7 +286,7 @@ const isHost = (node) => node && node.$tag$ === Host;
|
|
|
233
286
|
const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
234
287
|
if (oldValue !== newValue) {
|
|
235
288
|
let isProp = isMemberInElement(elm, memberName);
|
|
236
|
-
memberName.toLowerCase();
|
|
289
|
+
let ln = memberName.toLowerCase();
|
|
237
290
|
if (memberName === 'class') {
|
|
238
291
|
const classList = elm.classList;
|
|
239
292
|
const oldClasses = parseClassList(oldValue);
|
|
@@ -247,6 +300,45 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
247
300
|
newValue(elm);
|
|
248
301
|
}
|
|
249
302
|
}
|
|
303
|
+
else if ((!isProp ) &&
|
|
304
|
+
memberName[0] === 'o' &&
|
|
305
|
+
memberName[1] === 'n') {
|
|
306
|
+
// Event Handlers
|
|
307
|
+
// so if the member name starts with "on" and the 3rd characters is
|
|
308
|
+
// a capital letter, and it's not already a member on the element,
|
|
309
|
+
// then we're assuming it's an event listener
|
|
310
|
+
if (memberName[2] === '-') {
|
|
311
|
+
// on- prefixed events
|
|
312
|
+
// allows to be explicit about the dom event to listen without any magic
|
|
313
|
+
// under the hood:
|
|
314
|
+
// <my-cmp on-click> // listens for "click"
|
|
315
|
+
// <my-cmp on-Click> // listens for "Click"
|
|
316
|
+
// <my-cmp on-ionChange> // listens for "ionChange"
|
|
317
|
+
// <my-cmp on-EVENTS> // listens for "EVENTS"
|
|
318
|
+
memberName = memberName.slice(3);
|
|
319
|
+
}
|
|
320
|
+
else if (isMemberInElement(win, ln)) {
|
|
321
|
+
// standard event
|
|
322
|
+
// the JSX attribute could have been "onMouseOver" and the
|
|
323
|
+
// member name "onmouseover" is on the window's prototype
|
|
324
|
+
// so let's add the listener "mouseover", which is all lowercased
|
|
325
|
+
memberName = ln.slice(2);
|
|
326
|
+
}
|
|
327
|
+
else {
|
|
328
|
+
// custom event
|
|
329
|
+
// the JSX attribute could have been "onMyCustomEvent"
|
|
330
|
+
// so let's trim off the "on" prefix and lowercase the first character
|
|
331
|
+
// and add the listener "myCustomEvent"
|
|
332
|
+
// except for the first character, we keep the event name case
|
|
333
|
+
memberName = ln[2] + memberName.slice(3);
|
|
334
|
+
}
|
|
335
|
+
if (oldValue) {
|
|
336
|
+
plt.rel(elm, memberName, oldValue, false);
|
|
337
|
+
}
|
|
338
|
+
if (newValue) {
|
|
339
|
+
plt.ael(elm, memberName, newValue, false);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
250
342
|
else {
|
|
251
343
|
// Set property if it exists and it's not a SVG
|
|
252
344
|
const isComplex = isComplexType(newValue);
|
|
@@ -314,13 +406,36 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
314
406
|
let i = 0;
|
|
315
407
|
let elm;
|
|
316
408
|
let childNode;
|
|
409
|
+
let oldVNode;
|
|
410
|
+
if (!useNativeShadowDom) {
|
|
411
|
+
// remember for later we need to check to relocate nodes
|
|
412
|
+
checkSlotRelocate = true;
|
|
413
|
+
if (newVNode.$tag$ === 'slot') {
|
|
414
|
+
if (scopeId) {
|
|
415
|
+
// scoped css needs to add its scoped id to the parent element
|
|
416
|
+
parentElm.classList.add(scopeId + '-s');
|
|
417
|
+
}
|
|
418
|
+
newVNode.$flags$ |= newVNode.$children$
|
|
419
|
+
? // slot element has fallback content
|
|
420
|
+
2 /* isSlotFallback */
|
|
421
|
+
: // slot element does not have fallback content
|
|
422
|
+
1 /* isSlotReference */;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
317
425
|
if (newVNode.$text$ !== null) {
|
|
318
426
|
// create text node
|
|
319
427
|
elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
|
|
320
428
|
}
|
|
429
|
+
else if (newVNode.$flags$ & 1 /* isSlotReference */) {
|
|
430
|
+
// create a slot reference node
|
|
431
|
+
elm = newVNode.$elm$ =
|
|
432
|
+
doc.createTextNode('');
|
|
433
|
+
}
|
|
321
434
|
else {
|
|
322
435
|
// create element
|
|
323
|
-
elm = newVNode.$elm$ = (doc.createElement(newVNode.$
|
|
436
|
+
elm = newVNode.$elm$ = (doc.createElement(newVNode.$flags$ & 2 /* isSlotFallback */
|
|
437
|
+
? 'slot-fb'
|
|
438
|
+
: newVNode.$tag$));
|
|
324
439
|
// add css classes, attrs, props, listeners, etc.
|
|
325
440
|
{
|
|
326
441
|
updateElement(null, newVNode, isSvgMode);
|
|
@@ -333,7 +448,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
333
448
|
if (newVNode.$children$) {
|
|
334
449
|
for (i = 0; i < newVNode.$children$.length; ++i) {
|
|
335
450
|
// create the node
|
|
336
|
-
childNode = createElm(oldParentVNode, newVNode, i);
|
|
451
|
+
childNode = createElm(oldParentVNode, newVNode, i, elm);
|
|
337
452
|
// return node could have been null
|
|
338
453
|
if (childNode) {
|
|
339
454
|
// append our new node
|
|
@@ -342,20 +457,62 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
342
457
|
}
|
|
343
458
|
}
|
|
344
459
|
}
|
|
460
|
+
{
|
|
461
|
+
elm['s-hn'] = hostTagName;
|
|
462
|
+
if (newVNode.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
|
|
463
|
+
// remember the content reference comment
|
|
464
|
+
elm['s-sr'] = true;
|
|
465
|
+
// remember the content reference comment
|
|
466
|
+
elm['s-cr'] = contentRef;
|
|
467
|
+
// remember the slot name, or empty string for default slot
|
|
468
|
+
elm['s-sn'] = newVNode.$name$ || '';
|
|
469
|
+
// check if we've got an old vnode for this slot
|
|
470
|
+
oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
|
|
471
|
+
if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
|
|
472
|
+
// we've got an old slot vnode and the wrapper is being replaced
|
|
473
|
+
// so let's move the old slot content back to it's original location
|
|
474
|
+
putBackInOriginalLocation(oldParentVNode.$elm$, false);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
}
|
|
345
478
|
return elm;
|
|
346
479
|
};
|
|
480
|
+
const putBackInOriginalLocation = (parentElm, recursive) => {
|
|
481
|
+
plt.$flags$ |= 1 /* isTmpDisconnected */;
|
|
482
|
+
const oldSlotChildNodes = parentElm.childNodes;
|
|
483
|
+
for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
|
|
484
|
+
const childNode = oldSlotChildNodes[i];
|
|
485
|
+
if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
|
|
486
|
+
// // this child node in the old element is from another component
|
|
487
|
+
// // remove this node from the old slot's parent
|
|
488
|
+
// childNode.remove();
|
|
489
|
+
// and relocate it back to it's original location
|
|
490
|
+
parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
|
|
491
|
+
// remove the old original location comment entirely
|
|
492
|
+
// later on the patch function will know what to do
|
|
493
|
+
// and move this to the correct spot in need be
|
|
494
|
+
childNode['s-ol'].remove();
|
|
495
|
+
childNode['s-ol'] = undefined;
|
|
496
|
+
checkSlotRelocate = true;
|
|
497
|
+
}
|
|
498
|
+
if (recursive) {
|
|
499
|
+
putBackInOriginalLocation(childNode, recursive);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
plt.$flags$ &= ~1 /* isTmpDisconnected */;
|
|
503
|
+
};
|
|
347
504
|
const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
|
|
348
|
-
let containerElm = (parentElm);
|
|
505
|
+
let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
|
|
349
506
|
let childNode;
|
|
350
507
|
if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
|
|
351
508
|
containerElm = containerElm.shadowRoot;
|
|
352
509
|
}
|
|
353
510
|
for (; startIdx <= endIdx; ++startIdx) {
|
|
354
511
|
if (vnodes[startIdx]) {
|
|
355
|
-
childNode = createElm(null, parentVNode, startIdx);
|
|
512
|
+
childNode = createElm(null, parentVNode, startIdx, parentElm);
|
|
356
513
|
if (childNode) {
|
|
357
514
|
vnodes[startIdx].$elm$ = childNode;
|
|
358
|
-
containerElm.insertBefore(childNode, before);
|
|
515
|
+
containerElm.insertBefore(childNode, referenceNode(before) );
|
|
359
516
|
}
|
|
360
517
|
}
|
|
361
518
|
}
|
|
@@ -365,6 +522,20 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
|
|
|
365
522
|
if ((vnode = vnodes[startIdx])) {
|
|
366
523
|
elm = vnode.$elm$;
|
|
367
524
|
callNodeRefs(vnode);
|
|
525
|
+
{
|
|
526
|
+
// we're removing this element
|
|
527
|
+
// so it's possible we need to show slot fallback content now
|
|
528
|
+
checkSlotFallbackVisibility = true;
|
|
529
|
+
if (elm['s-ol']) {
|
|
530
|
+
// remove the original location comment
|
|
531
|
+
elm['s-ol'].remove();
|
|
532
|
+
}
|
|
533
|
+
else {
|
|
534
|
+
// it's possible that child nodes of the node
|
|
535
|
+
// that's being removed are slot nodes
|
|
536
|
+
putBackInOriginalLocation(elm, true);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
368
539
|
// remove the vnode's element from the dom
|
|
369
540
|
elm.remove();
|
|
370
541
|
}
|
|
@@ -405,12 +576,20 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
405
576
|
newEndVnode = newCh[--newEndIdx];
|
|
406
577
|
}
|
|
407
578
|
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
579
|
+
// Vnode moved right
|
|
580
|
+
if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
581
|
+
putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
|
|
582
|
+
}
|
|
408
583
|
patch(oldStartVnode, newEndVnode);
|
|
409
584
|
parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
|
|
410
585
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
411
586
|
newEndVnode = newCh[--newEndIdx];
|
|
412
587
|
}
|
|
413
588
|
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
589
|
+
// Vnode moved left
|
|
590
|
+
if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
591
|
+
putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
|
|
592
|
+
}
|
|
414
593
|
patch(oldEndVnode, newStartVnode);
|
|
415
594
|
parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
|
|
416
595
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
@@ -419,12 +598,12 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
419
598
|
else {
|
|
420
599
|
{
|
|
421
600
|
// new element
|
|
422
|
-
node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
|
|
601
|
+
node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
|
|
423
602
|
newStartVnode = newCh[++newStartIdx];
|
|
424
603
|
}
|
|
425
604
|
if (node) {
|
|
426
605
|
{
|
|
427
|
-
oldStartVnode.$elm
|
|
606
|
+
parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
|
|
428
607
|
}
|
|
429
608
|
}
|
|
430
609
|
}
|
|
@@ -440,16 +619,28 @@ const isSameVnode = (vnode1, vnode2) => {
|
|
|
440
619
|
// compare if two vnode to see if they're "technically" the same
|
|
441
620
|
// need to have the same element tag, and same key to be the same
|
|
442
621
|
if (vnode1.$tag$ === vnode2.$tag$) {
|
|
622
|
+
if (vnode1.$tag$ === 'slot') {
|
|
623
|
+
return vnode1.$name$ === vnode2.$name$;
|
|
624
|
+
}
|
|
443
625
|
return true;
|
|
444
626
|
}
|
|
445
627
|
return false;
|
|
446
628
|
};
|
|
629
|
+
const referenceNode = (node) => {
|
|
630
|
+
// this node was relocated to a new location in the dom
|
|
631
|
+
// because of some other component's slot
|
|
632
|
+
// but we still have an html comment in place of where
|
|
633
|
+
// it's original location was according to it's original vdom
|
|
634
|
+
return (node && node['s-ol']) || node;
|
|
635
|
+
};
|
|
636
|
+
const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
|
|
447
637
|
const patch = (oldVNode, newVNode) => {
|
|
448
638
|
const elm = (newVNode.$elm$ = oldVNode.$elm$);
|
|
449
639
|
const oldChildren = oldVNode.$children$;
|
|
450
640
|
const newChildren = newVNode.$children$;
|
|
451
641
|
const tag = newVNode.$tag$;
|
|
452
642
|
const text = newVNode.$text$;
|
|
643
|
+
let defaultHolder;
|
|
453
644
|
if (text === null) {
|
|
454
645
|
// element node
|
|
455
646
|
{
|
|
@@ -480,12 +671,147 @@ const patch = (oldVNode, newVNode) => {
|
|
|
480
671
|
removeVnodes(oldChildren, 0, oldChildren.length - 1);
|
|
481
672
|
}
|
|
482
673
|
}
|
|
674
|
+
else if ((defaultHolder = elm['s-cr'])) {
|
|
675
|
+
// this element has slotted content
|
|
676
|
+
defaultHolder.parentNode.textContent = text;
|
|
677
|
+
}
|
|
483
678
|
else if (oldVNode.$text$ !== text) {
|
|
484
679
|
// update the text content for the text only vnode
|
|
485
680
|
// and also only if the text is different than before
|
|
486
681
|
elm.data = text;
|
|
487
682
|
}
|
|
488
683
|
};
|
|
684
|
+
const updateFallbackSlotVisibility = (elm) => {
|
|
685
|
+
// tslint:disable-next-line: prefer-const
|
|
686
|
+
const childNodes = elm.childNodes;
|
|
687
|
+
let childNode;
|
|
688
|
+
let i;
|
|
689
|
+
let ilen;
|
|
690
|
+
let j;
|
|
691
|
+
let slotNameAttr;
|
|
692
|
+
let nodeType;
|
|
693
|
+
for (i = 0, ilen = childNodes.length; i < ilen; i++) {
|
|
694
|
+
childNode = childNodes[i];
|
|
695
|
+
if (childNode.nodeType === 1 /* ElementNode */) {
|
|
696
|
+
if (childNode['s-sr']) {
|
|
697
|
+
// this is a slot fallback node
|
|
698
|
+
// get the slot name for this slot reference node
|
|
699
|
+
slotNameAttr = childNode['s-sn'];
|
|
700
|
+
// by default always show a fallback slot node
|
|
701
|
+
// then hide it if there are other slots in the light dom
|
|
702
|
+
childNode.hidden = false;
|
|
703
|
+
for (j = 0; j < ilen; j++) {
|
|
704
|
+
nodeType = childNodes[j].nodeType;
|
|
705
|
+
if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
|
|
706
|
+
// this sibling node is from a different component OR is a named fallback slot node
|
|
707
|
+
if (nodeType === 1 /* ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
|
|
708
|
+
childNode.hidden = true;
|
|
709
|
+
break;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
else {
|
|
713
|
+
// this is a default fallback slot node
|
|
714
|
+
// any element or text node (with content)
|
|
715
|
+
// should hide the default fallback slot node
|
|
716
|
+
if (nodeType === 1 /* ElementNode */ ||
|
|
717
|
+
(nodeType === 3 /* TextNode */ && childNodes[j].textContent.trim() !== '')) {
|
|
718
|
+
childNode.hidden = true;
|
|
719
|
+
break;
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
// keep drilling down
|
|
725
|
+
updateFallbackSlotVisibility(childNode);
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
};
|
|
729
|
+
const relocateNodes = [];
|
|
730
|
+
const relocateSlotContent = (elm) => {
|
|
731
|
+
// tslint:disable-next-line: prefer-const
|
|
732
|
+
let childNode;
|
|
733
|
+
let node;
|
|
734
|
+
let hostContentNodes;
|
|
735
|
+
let slotNameAttr;
|
|
736
|
+
let relocateNodeData;
|
|
737
|
+
let j;
|
|
738
|
+
let i = 0;
|
|
739
|
+
const childNodes = elm.childNodes;
|
|
740
|
+
const ilen = childNodes.length;
|
|
741
|
+
for (; i < ilen; i++) {
|
|
742
|
+
childNode = childNodes[i];
|
|
743
|
+
if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
|
|
744
|
+
// first got the content reference comment node
|
|
745
|
+
// then we got it's parent, which is where all the host content is in now
|
|
746
|
+
hostContentNodes = node.parentNode.childNodes;
|
|
747
|
+
slotNameAttr = childNode['s-sn'];
|
|
748
|
+
for (j = hostContentNodes.length - 1; j >= 0; j--) {
|
|
749
|
+
node = hostContentNodes[j];
|
|
750
|
+
if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
|
|
751
|
+
// let's do some relocating to its new home
|
|
752
|
+
// but never relocate a content reference node
|
|
753
|
+
// that is suppose to always represent the original content location
|
|
754
|
+
if (isNodeLocatedInSlot(node, slotNameAttr)) {
|
|
755
|
+
// it's possible we've already decided to relocate this node
|
|
756
|
+
relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
|
|
757
|
+
// made some changes to slots
|
|
758
|
+
// let's make sure we also double check
|
|
759
|
+
// fallbacks are correctly hidden or shown
|
|
760
|
+
checkSlotFallbackVisibility = true;
|
|
761
|
+
node['s-sn'] = node['s-sn'] || slotNameAttr;
|
|
762
|
+
if (relocateNodeData) {
|
|
763
|
+
// previously we never found a slot home for this node
|
|
764
|
+
// but turns out we did, so let's remember it now
|
|
765
|
+
relocateNodeData.$slotRefNode$ = childNode;
|
|
766
|
+
}
|
|
767
|
+
else {
|
|
768
|
+
// add to our list of nodes to relocate
|
|
769
|
+
relocateNodes.push({
|
|
770
|
+
$slotRefNode$: childNode,
|
|
771
|
+
$nodeToRelocate$: node,
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
if (node['s-sr']) {
|
|
775
|
+
relocateNodes.map((relocateNode) => {
|
|
776
|
+
if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
|
|
777
|
+
relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
|
|
778
|
+
if (relocateNodeData && !relocateNode.$slotRefNode$) {
|
|
779
|
+
relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
|
|
786
|
+
// so far this element does not have a slot home, not setting slotRefNode on purpose
|
|
787
|
+
// if we never find a home for this element then we'll need to hide it
|
|
788
|
+
relocateNodes.push({
|
|
789
|
+
$nodeToRelocate$: node,
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
if (childNode.nodeType === 1 /* ElementNode */) {
|
|
796
|
+
relocateSlotContent(childNode);
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
};
|
|
800
|
+
const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
|
|
801
|
+
if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
|
|
802
|
+
if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
|
|
803
|
+
return true;
|
|
804
|
+
}
|
|
805
|
+
if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
|
|
806
|
+
return true;
|
|
807
|
+
}
|
|
808
|
+
return false;
|
|
809
|
+
}
|
|
810
|
+
if (nodeToRelocate['s-sn'] === slotNameAttr) {
|
|
811
|
+
return true;
|
|
812
|
+
}
|
|
813
|
+
return slotNameAttr === '';
|
|
814
|
+
};
|
|
489
815
|
const callNodeRefs = (vNode) => {
|
|
490
816
|
{
|
|
491
817
|
vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
|
|
@@ -494,6 +820,7 @@ const callNodeRefs = (vNode) => {
|
|
|
494
820
|
};
|
|
495
821
|
const renderVdom = (hostRef, renderFnResults) => {
|
|
496
822
|
const hostElm = hostRef.$hostElement$;
|
|
823
|
+
const cmpMeta = hostRef.$cmpMeta$;
|
|
497
824
|
const oldVNode = hostRef.$vnode$ || newVNode(null, null);
|
|
498
825
|
const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
|
|
499
826
|
hostTagName = hostElm.tagName;
|
|
@@ -504,10 +831,105 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
504
831
|
{
|
|
505
832
|
scopeId = hostElm['s-sc'];
|
|
506
833
|
}
|
|
834
|
+
{
|
|
835
|
+
contentRef = hostElm['s-cr'];
|
|
836
|
+
useNativeShadowDom = (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
|
|
837
|
+
// always reset
|
|
838
|
+
checkSlotFallbackVisibility = false;
|
|
839
|
+
}
|
|
507
840
|
// synchronous patch
|
|
508
841
|
patch(oldVNode, rootVnode);
|
|
842
|
+
{
|
|
843
|
+
// while we're moving nodes around existing nodes, temporarily disable
|
|
844
|
+
// the disconnectCallback from working
|
|
845
|
+
plt.$flags$ |= 1 /* isTmpDisconnected */;
|
|
846
|
+
if (checkSlotRelocate) {
|
|
847
|
+
relocateSlotContent(rootVnode.$elm$);
|
|
848
|
+
let relocateData;
|
|
849
|
+
let nodeToRelocate;
|
|
850
|
+
let orgLocationNode;
|
|
851
|
+
let parentNodeRef;
|
|
852
|
+
let insertBeforeNode;
|
|
853
|
+
let refNode;
|
|
854
|
+
let i = 0;
|
|
855
|
+
for (; i < relocateNodes.length; i++) {
|
|
856
|
+
relocateData = relocateNodes[i];
|
|
857
|
+
nodeToRelocate = relocateData.$nodeToRelocate$;
|
|
858
|
+
if (!nodeToRelocate['s-ol']) {
|
|
859
|
+
// add a reference node marking this node's original location
|
|
860
|
+
// keep a reference to this node for later lookups
|
|
861
|
+
orgLocationNode =
|
|
862
|
+
doc.createTextNode('');
|
|
863
|
+
orgLocationNode['s-nr'] = nodeToRelocate;
|
|
864
|
+
nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
for (i = 0; i < relocateNodes.length; i++) {
|
|
868
|
+
relocateData = relocateNodes[i];
|
|
869
|
+
nodeToRelocate = relocateData.$nodeToRelocate$;
|
|
870
|
+
if (relocateData.$slotRefNode$) {
|
|
871
|
+
// by default we're just going to insert it directly
|
|
872
|
+
// after the slot reference node
|
|
873
|
+
parentNodeRef = relocateData.$slotRefNode$.parentNode;
|
|
874
|
+
insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
|
|
875
|
+
orgLocationNode = nodeToRelocate['s-ol'];
|
|
876
|
+
while ((orgLocationNode = orgLocationNode.previousSibling)) {
|
|
877
|
+
refNode = orgLocationNode['s-nr'];
|
|
878
|
+
if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
|
|
879
|
+
refNode = refNode.nextSibling;
|
|
880
|
+
if (!refNode || !refNode['s-nr']) {
|
|
881
|
+
insertBeforeNode = refNode;
|
|
882
|
+
break;
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
|
|
887
|
+
nodeToRelocate.nextSibling !== insertBeforeNode) {
|
|
888
|
+
// we've checked that it's worth while to relocate
|
|
889
|
+
// since that the node to relocate
|
|
890
|
+
// has a different next sibling or parent relocated
|
|
891
|
+
if (nodeToRelocate !== insertBeforeNode) {
|
|
892
|
+
if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
|
|
893
|
+
// probably a component in the index.html that doesn't have it's hostname set
|
|
894
|
+
nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
|
|
895
|
+
}
|
|
896
|
+
// add it back to the dom but in its new home
|
|
897
|
+
parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
else {
|
|
902
|
+
// this node doesn't have a slot home to go to, so let's hide it
|
|
903
|
+
if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
|
|
904
|
+
nodeToRelocate.hidden = true;
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
if (checkSlotFallbackVisibility) {
|
|
910
|
+
updateFallbackSlotVisibility(rootVnode.$elm$);
|
|
911
|
+
}
|
|
912
|
+
// done moving nodes around
|
|
913
|
+
// allow the disconnect callback to work again
|
|
914
|
+
plt.$flags$ &= ~1 /* isTmpDisconnected */;
|
|
915
|
+
// always reset
|
|
916
|
+
relocateNodes.length = 0;
|
|
917
|
+
}
|
|
509
918
|
};
|
|
510
919
|
const getElement = (ref) => (getHostRef(ref).$hostElement$ );
|
|
920
|
+
const createEvent = (ref, name, flags) => {
|
|
921
|
+
const elm = getElement(ref);
|
|
922
|
+
return {
|
|
923
|
+
emit: (detail) => {
|
|
924
|
+
return emitEvent(elm, name, {
|
|
925
|
+
bubbles: !!(flags & 4 /* Bubbles */),
|
|
926
|
+
composed: !!(flags & 2 /* Composed */),
|
|
927
|
+
cancelable: !!(flags & 1 /* Cancellable */),
|
|
928
|
+
detail,
|
|
929
|
+
});
|
|
930
|
+
},
|
|
931
|
+
};
|
|
932
|
+
};
|
|
511
933
|
/**
|
|
512
934
|
* Helper function to create & dispatch a custom Event on a provided target
|
|
513
935
|
* @param elm the target of the Event
|
|
@@ -553,6 +975,9 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
|
553
975
|
}
|
|
554
976
|
}
|
|
555
977
|
}
|
|
978
|
+
{
|
|
979
|
+
promise = then(promise, () => safeCall(instance, 'componentWillRender'));
|
|
980
|
+
}
|
|
556
981
|
endSchedule();
|
|
557
982
|
return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
|
|
558
983
|
};
|
|
@@ -729,6 +1154,7 @@ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propNam
|
|
|
729
1154
|
const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
730
1155
|
// check our new property value against our internal value
|
|
731
1156
|
const hostRef = getHostRef(ref);
|
|
1157
|
+
const elm = hostRef.$hostElement$ ;
|
|
732
1158
|
const oldVal = hostRef.$instanceValues$.get(propName);
|
|
733
1159
|
const flags = hostRef.$flags$;
|
|
734
1160
|
const instance = hostRef.$lazyInstance$ ;
|
|
@@ -741,6 +1167,22 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
741
1167
|
// set our new value!
|
|
742
1168
|
hostRef.$instanceValues$.set(propName, newVal);
|
|
743
1169
|
if (instance) {
|
|
1170
|
+
// get an array of method names of watch functions to call
|
|
1171
|
+
if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
|
|
1172
|
+
const watchMethods = cmpMeta.$watchers$[propName];
|
|
1173
|
+
if (watchMethods) {
|
|
1174
|
+
// this instance is watching for when this property changed
|
|
1175
|
+
watchMethods.map((watchMethodName) => {
|
|
1176
|
+
try {
|
|
1177
|
+
// fire off each of the watch methods that are watching this property
|
|
1178
|
+
instance[watchMethodName](newVal, oldVal, propName);
|
|
1179
|
+
}
|
|
1180
|
+
catch (e) {
|
|
1181
|
+
consoleError(e, elm);
|
|
1182
|
+
}
|
|
1183
|
+
});
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
744
1186
|
if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
|
|
745
1187
|
if (instance.componentShouldUpdate) {
|
|
746
1188
|
if (instance.componentShouldUpdate(newVal, oldVal, propName) === false) {
|
|
@@ -758,6 +1200,9 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
758
1200
|
};
|
|
759
1201
|
const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
760
1202
|
if (cmpMeta.$members$) {
|
|
1203
|
+
if (Cstr.watchers) {
|
|
1204
|
+
cmpMeta.$watchers$ = Cstr.watchers;
|
|
1205
|
+
}
|
|
761
1206
|
// It's better to have a const than two Object.entries()
|
|
762
1207
|
const members = Object.entries(cmpMeta.$members$);
|
|
763
1208
|
const prototype = Cstr.prototype;
|
|
@@ -862,6 +1307,12 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
862
1307
|
endLoad();
|
|
863
1308
|
}
|
|
864
1309
|
if (!Cstr.isProxied) {
|
|
1310
|
+
// we've never proxied this Constructor before
|
|
1311
|
+
// let's add the getters/setters to its prototype before
|
|
1312
|
+
// the first time we create an instance of the implementation
|
|
1313
|
+
{
|
|
1314
|
+
cmpMeta.$watchers$ = Cstr.watchers;
|
|
1315
|
+
}
|
|
865
1316
|
proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
|
|
866
1317
|
Cstr.isProxied = true;
|
|
867
1318
|
}
|
|
@@ -885,6 +1336,9 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
885
1336
|
{
|
|
886
1337
|
hostRef.$flags$ &= ~8 /* isConstructingInstance */;
|
|
887
1338
|
}
|
|
1339
|
+
{
|
|
1340
|
+
hostRef.$flags$ |= 128 /* isWatchReady */;
|
|
1341
|
+
}
|
|
888
1342
|
endNewInstance();
|
|
889
1343
|
}
|
|
890
1344
|
if (Cstr.style) {
|
|
@@ -922,6 +1376,15 @@ const connectedCallback = (elm) => {
|
|
|
922
1376
|
if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
|
|
923
1377
|
// first time this component has connected
|
|
924
1378
|
hostRef.$flags$ |= 1 /* hasConnected */;
|
|
1379
|
+
{
|
|
1380
|
+
// initUpdate
|
|
1381
|
+
// if the slot polyfill is required we'll need to put some nodes
|
|
1382
|
+
// in here to act as original content anchors as we move nodes around
|
|
1383
|
+
// host element has been connected to the DOM
|
|
1384
|
+
if ((cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */))) {
|
|
1385
|
+
setContentReference(elm);
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
925
1388
|
{
|
|
926
1389
|
// find the first ancestor component (if there is one) and register
|
|
927
1390
|
// this component as one of the actively loading child components for its ancestor
|
|
@@ -961,6 +1424,17 @@ const connectedCallback = (elm) => {
|
|
|
961
1424
|
endConnected();
|
|
962
1425
|
}
|
|
963
1426
|
};
|
|
1427
|
+
const setContentReference = (elm) => {
|
|
1428
|
+
// only required when we're NOT using native shadow dom (slot)
|
|
1429
|
+
// or this browser doesn't support native shadow dom
|
|
1430
|
+
// and this host element was NOT created with SSR
|
|
1431
|
+
// let's pick out the inner content for slot projection
|
|
1432
|
+
// create a node to represent where the original
|
|
1433
|
+
// content was first placed, which is useful later on
|
|
1434
|
+
const contentRefElm = (elm['s-cr'] = doc.createComment(''));
|
|
1435
|
+
contentRefElm['s-cn'] = true;
|
|
1436
|
+
elm.insertBefore(contentRefElm, elm.firstChild);
|
|
1437
|
+
};
|
|
964
1438
|
const disconnectedCallback = (elm) => {
|
|
965
1439
|
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
966
1440
|
const hostRef = getHostRef(elm);
|
|
@@ -999,6 +1473,9 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
999
1473
|
{
|
|
1000
1474
|
cmpMeta.$listeners$ = compactMeta[3];
|
|
1001
1475
|
}
|
|
1476
|
+
{
|
|
1477
|
+
cmpMeta.$watchers$ = {};
|
|
1478
|
+
}
|
|
1002
1479
|
const tagName = cmpMeta.$tagName$;
|
|
1003
1480
|
const HostElement = class extends HTMLElement {
|
|
1004
1481
|
// StencilLazyHost
|
|
@@ -1150,4 +1627,4 @@ const flush = () => {
|
|
|
1150
1627
|
const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
|
|
1151
1628
|
const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
|
|
1152
1629
|
|
|
1153
|
-
export { Host as H, bootstrapLazy as b, getElement as g, h, promiseResolve as p, registerInstance as r };
|
|
1630
|
+
export { Host as H, bootstrapLazy as b, createEvent as c, getElement as g, h, promiseResolve as p, registerInstance as r };
|