@sankhyalabs/sankhyablocks 1.3.0 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{index-4720dab8.js → index-8272993f.js} +439 -7
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/sankhyablocks.cjs.js +2 -2
- package/dist/cjs/snk-application.cjs.entry.js +227 -57
- package/dist/cjs/snk-pesquisa.cjs.entry.js +19 -0
- package/dist/cjs/teste-pesquisa.cjs.entry.js +37 -0
- package/dist/collection/collection-manifest.json +3 -1
- package/dist/collection/components/snk-application/snk-application.js +104 -3
- package/dist/collection/components/snk-pesquisa/snk-pesquisa.css +3 -0
- package/dist/collection/components/snk-pesquisa/snk-pesquisa.js +74 -0
- package/dist/collection/components/teste-pesquisa/teste-pesquisa.css +3 -0
- package/dist/collection/components/teste-pesquisa/teste-pesquisa.js +33 -0
- package/dist/collection/lib/http/data-fetcher/DataFetcher.js +47 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/dataunit-fetcher.js +17 -16
- package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +82 -0
- package/dist/collection/lib/workspace/workspace.js +2 -1
- package/dist/components/snk-application.js +1 -7089
- package/dist/components/snk-application2.js +7269 -0
- package/dist/components/snk-pesquisa.d.ts +11 -0
- package/dist/components/snk-pesquisa.js +6 -0
- package/dist/components/snk-pesquisa2.js +34 -0
- package/dist/components/teste-pesquisa.d.ts +11 -0
- package/dist/components/teste-pesquisa.js +63 -0
- package/dist/esm/{index-72d4e2e0.js → index-427447f8.js} +439 -8
- package/dist/esm/loader.js +2 -2
- package/dist/esm/sankhyablocks.js +2 -2
- package/dist/esm/snk-application.entry.js +228 -58
- package/dist/esm/snk-pesquisa.entry.js +15 -0
- package/dist/esm/teste-pesquisa.entry.js +33 -0
- package/dist/sankhyablocks/p-106c4d7b.entry.js +63 -0
- package/dist/sankhyablocks/p-91ca1a98.entry.js +1 -0
- package/dist/sankhyablocks/p-e6ba985e.entry.js +1 -0
- package/dist/sankhyablocks/p-ee5a384b.js +2 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-application/snk-application.d.ts +8 -0
- package/dist/types/components/snk-pesquisa/snk-pesquisa.d.ts +7 -0
- package/dist/types/components/teste-pesquisa/teste-pesquisa.d.ts +6 -0
- package/dist/types/components.d.ts +34 -0
- package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +3 -0
- package/dist/types/lib/http/data-fetcher/fetchers/dataunit-fetcher.d.ts +1 -1
- package/dist/types/lib/http/data-fetcher/fetchers/pesquisa-fetcher.d.ts +17 -0
- package/package.json +9 -5
- package/react/components.d.ts +2 -0
- package/react/components.js +2 -0
- package/react/components.js.map +1 -1
- package/dist/sankhyablocks/p-5d8ddbda.entry.js +0 -57
- package/dist/sankhyablocks/p-a33afc3b.js +0 -2
|
@@ -23,6 +23,8 @@ function _interopNamespace(e) {
|
|
|
23
23
|
const NAMESPACE = 'sankhyablocks';
|
|
24
24
|
|
|
25
25
|
let scopeId;
|
|
26
|
+
let hostTagName;
|
|
27
|
+
let isSvgMode = false;
|
|
26
28
|
let queuePending = false;
|
|
27
29
|
const win = typeof window !== 'undefined' ? window : {};
|
|
28
30
|
const doc = win.document || { head: {} };
|
|
@@ -110,7 +112,7 @@ const attachStyles = (hostRef) => {
|
|
|
110
112
|
const elm = hostRef.$hostElement$;
|
|
111
113
|
const flags = cmpMeta.$flags$;
|
|
112
114
|
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
113
|
-
const scopeId = addStyle(elm.getRootNode(), cmpMeta);
|
|
115
|
+
const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
|
|
114
116
|
if (flags & 10 /* needsScopedEncapsulation */) {
|
|
115
117
|
// only required when we're NOT using native shadow dom (slot)
|
|
116
118
|
// or this browser doesn't support native shadow dom
|
|
@@ -128,6 +130,14 @@ const attachStyles = (hostRef) => {
|
|
|
128
130
|
endAttachStyles();
|
|
129
131
|
};
|
|
130
132
|
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
133
|
+
/**
|
|
134
|
+
* Default style mode id
|
|
135
|
+
*/
|
|
136
|
+
/**
|
|
137
|
+
* Reusable empty obj/array
|
|
138
|
+
* Don't add values to these!!
|
|
139
|
+
*/
|
|
140
|
+
const EMPTY_OBJ = {};
|
|
131
141
|
const isDef = (v) => v != null;
|
|
132
142
|
const isComplexType = (o) => {
|
|
133
143
|
// https://jsperf.com/typeof-fn-object/5
|
|
@@ -188,19 +198,146 @@ const newVNode = (tag, text) => {
|
|
|
188
198
|
$elm$: null,
|
|
189
199
|
$children$: null,
|
|
190
200
|
};
|
|
201
|
+
{
|
|
202
|
+
vnode.$attrs$ = null;
|
|
203
|
+
}
|
|
191
204
|
return vnode;
|
|
192
205
|
};
|
|
193
206
|
const Host = {};
|
|
194
207
|
const isHost = (node) => node && node.$tag$ === Host;
|
|
208
|
+
/**
|
|
209
|
+
* Production setAccessor() function based on Preact by
|
|
210
|
+
* Jason Miller (@developit)
|
|
211
|
+
* Licensed under the MIT License
|
|
212
|
+
* https://github.com/developit/preact/blob/master/LICENSE
|
|
213
|
+
*
|
|
214
|
+
* Modified for Stencil's compiler and vdom
|
|
215
|
+
*/
|
|
216
|
+
const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
217
|
+
if (oldValue !== newValue) {
|
|
218
|
+
let isProp = isMemberInElement(elm, memberName);
|
|
219
|
+
let ln = memberName.toLowerCase();
|
|
220
|
+
if (memberName === 'ref') {
|
|
221
|
+
// minifier will clean this up
|
|
222
|
+
if (newValue) {
|
|
223
|
+
newValue(elm);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
else if ((!isProp ) &&
|
|
227
|
+
memberName[0] === 'o' &&
|
|
228
|
+
memberName[1] === 'n') {
|
|
229
|
+
// Event Handlers
|
|
230
|
+
// so if the member name starts with "on" and the 3rd characters is
|
|
231
|
+
// a capital letter, and it's not already a member on the element,
|
|
232
|
+
// then we're assuming it's an event listener
|
|
233
|
+
if (memberName[2] === '-') {
|
|
234
|
+
// on- prefixed events
|
|
235
|
+
// allows to be explicit about the dom event to listen without any magic
|
|
236
|
+
// under the hood:
|
|
237
|
+
// <my-cmp on-click> // listens for "click"
|
|
238
|
+
// <my-cmp on-Click> // listens for "Click"
|
|
239
|
+
// <my-cmp on-ionChange> // listens for "ionChange"
|
|
240
|
+
// <my-cmp on-EVENTS> // listens for "EVENTS"
|
|
241
|
+
memberName = memberName.slice(3);
|
|
242
|
+
}
|
|
243
|
+
else if (isMemberInElement(win, ln)) {
|
|
244
|
+
// standard event
|
|
245
|
+
// the JSX attribute could have been "onMouseOver" and the
|
|
246
|
+
// member name "onmouseover" is on the window's prototype
|
|
247
|
+
// so let's add the listener "mouseover", which is all lowercased
|
|
248
|
+
memberName = ln.slice(2);
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
// custom event
|
|
252
|
+
// the JSX attribute could have been "onMyCustomEvent"
|
|
253
|
+
// so let's trim off the "on" prefix and lowercase the first character
|
|
254
|
+
// and add the listener "myCustomEvent"
|
|
255
|
+
// except for the first character, we keep the event name case
|
|
256
|
+
memberName = ln[2] + memberName.slice(3);
|
|
257
|
+
}
|
|
258
|
+
if (oldValue) {
|
|
259
|
+
plt.rel(elm, memberName, oldValue, false);
|
|
260
|
+
}
|
|
261
|
+
if (newValue) {
|
|
262
|
+
plt.ael(elm, memberName, newValue, false);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
// Set property if it exists and it's not a SVG
|
|
267
|
+
const isComplex = isComplexType(newValue);
|
|
268
|
+
if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
|
|
269
|
+
try {
|
|
270
|
+
if (!elm.tagName.includes('-')) {
|
|
271
|
+
const n = newValue == null ? '' : newValue;
|
|
272
|
+
// Workaround for Safari, moving the <input> caret when re-assigning the same valued
|
|
273
|
+
if (memberName === 'list') {
|
|
274
|
+
isProp = false;
|
|
275
|
+
}
|
|
276
|
+
else if (oldValue == null || elm[memberName] != n) {
|
|
277
|
+
elm[memberName] = n;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
elm[memberName] = newValue;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
catch (e) { }
|
|
285
|
+
}
|
|
286
|
+
if (newValue == null || newValue === false) {
|
|
287
|
+
if (newValue !== false || elm.getAttribute(memberName) === '') {
|
|
288
|
+
{
|
|
289
|
+
elm.removeAttribute(memberName);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
|
|
294
|
+
newValue = newValue === true ? '' : newValue;
|
|
295
|
+
{
|
|
296
|
+
elm.setAttribute(memberName, newValue);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
303
|
+
// if the element passed in is a shadow root, which is a document fragment
|
|
304
|
+
// then we want to be adding attrs/props to the shadow root's "host" element
|
|
305
|
+
// if it's not a shadow root, then we add attrs/props to the same element
|
|
306
|
+
const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
|
|
307
|
+
? newVnode.$elm$.host
|
|
308
|
+
: newVnode.$elm$;
|
|
309
|
+
const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
|
|
310
|
+
const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
|
|
311
|
+
{
|
|
312
|
+
// remove attributes no longer present on the vnode by setting them to undefined
|
|
313
|
+
for (memberName in oldVnodeAttrs) {
|
|
314
|
+
if (!(memberName in newVnodeAttrs)) {
|
|
315
|
+
setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
// add new & update changed attributes
|
|
320
|
+
for (memberName in newVnodeAttrs) {
|
|
321
|
+
setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
|
|
322
|
+
}
|
|
323
|
+
};
|
|
195
324
|
const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
196
325
|
// tslint:disable-next-line: prefer-const
|
|
197
326
|
const newVNode = newParentVNode.$children$[childIndex];
|
|
198
327
|
let i = 0;
|
|
199
328
|
let elm;
|
|
200
329
|
let childNode;
|
|
201
|
-
{
|
|
330
|
+
if (newVNode.$text$ !== null) {
|
|
331
|
+
// create text node
|
|
332
|
+
elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
202
335
|
// create element
|
|
203
336
|
elm = newVNode.$elm$ = (doc.createElement(newVNode.$tag$));
|
|
337
|
+
// add css classes, attrs, props, listeners, etc.
|
|
338
|
+
{
|
|
339
|
+
updateElement(null, newVNode, isSvgMode);
|
|
340
|
+
}
|
|
204
341
|
if (isDef(scopeId) && elm['s-si'] !== scopeId) {
|
|
205
342
|
// if there is a scopeId and this is the initial render
|
|
206
343
|
// then let's add the scopeId as a css class
|
|
@@ -223,6 +360,9 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
223
360
|
const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
|
|
224
361
|
let containerElm = (parentElm);
|
|
225
362
|
let childNode;
|
|
363
|
+
if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
|
|
364
|
+
containerElm = containerElm.shadowRoot;
|
|
365
|
+
}
|
|
226
366
|
for (; startIdx <= endIdx; ++startIdx) {
|
|
227
367
|
if (vnodes[startIdx]) {
|
|
228
368
|
childNode = createElm(null, parentVNode, startIdx);
|
|
@@ -233,25 +373,144 @@ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) =>
|
|
|
233
373
|
}
|
|
234
374
|
}
|
|
235
375
|
};
|
|
376
|
+
const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
|
|
377
|
+
for (; startIdx <= endIdx; ++startIdx) {
|
|
378
|
+
if ((vnode = vnodes[startIdx])) {
|
|
379
|
+
elm = vnode.$elm$;
|
|
380
|
+
callNodeRefs(vnode);
|
|
381
|
+
// remove the vnode's element from the dom
|
|
382
|
+
elm.remove();
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
387
|
+
let oldStartIdx = 0;
|
|
388
|
+
let newStartIdx = 0;
|
|
389
|
+
let oldEndIdx = oldCh.length - 1;
|
|
390
|
+
let oldStartVnode = oldCh[0];
|
|
391
|
+
let oldEndVnode = oldCh[oldEndIdx];
|
|
392
|
+
let newEndIdx = newCh.length - 1;
|
|
393
|
+
let newStartVnode = newCh[0];
|
|
394
|
+
let newEndVnode = newCh[newEndIdx];
|
|
395
|
+
let node;
|
|
396
|
+
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
397
|
+
if (oldStartVnode == null) {
|
|
398
|
+
// Vnode might have been moved left
|
|
399
|
+
oldStartVnode = oldCh[++oldStartIdx];
|
|
400
|
+
}
|
|
401
|
+
else if (oldEndVnode == null) {
|
|
402
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
403
|
+
}
|
|
404
|
+
else if (newStartVnode == null) {
|
|
405
|
+
newStartVnode = newCh[++newStartIdx];
|
|
406
|
+
}
|
|
407
|
+
else if (newEndVnode == null) {
|
|
408
|
+
newEndVnode = newCh[--newEndIdx];
|
|
409
|
+
}
|
|
410
|
+
else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
411
|
+
patch(oldStartVnode, newStartVnode);
|
|
412
|
+
oldStartVnode = oldCh[++oldStartIdx];
|
|
413
|
+
newStartVnode = newCh[++newStartIdx];
|
|
414
|
+
}
|
|
415
|
+
else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
416
|
+
patch(oldEndVnode, newEndVnode);
|
|
417
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
418
|
+
newEndVnode = newCh[--newEndIdx];
|
|
419
|
+
}
|
|
420
|
+
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
421
|
+
patch(oldStartVnode, newEndVnode);
|
|
422
|
+
parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
|
|
423
|
+
oldStartVnode = oldCh[++oldStartIdx];
|
|
424
|
+
newEndVnode = newCh[--newEndIdx];
|
|
425
|
+
}
|
|
426
|
+
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
427
|
+
patch(oldEndVnode, newStartVnode);
|
|
428
|
+
parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
|
|
429
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
430
|
+
newStartVnode = newCh[++newStartIdx];
|
|
431
|
+
}
|
|
432
|
+
else {
|
|
433
|
+
{
|
|
434
|
+
// new element
|
|
435
|
+
node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
|
|
436
|
+
newStartVnode = newCh[++newStartIdx];
|
|
437
|
+
}
|
|
438
|
+
if (node) {
|
|
439
|
+
{
|
|
440
|
+
oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
if (oldStartIdx > oldEndIdx) {
|
|
446
|
+
addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
|
|
447
|
+
}
|
|
448
|
+
else if (newStartIdx > newEndIdx) {
|
|
449
|
+
removeVnodes(oldCh, oldStartIdx, oldEndIdx);
|
|
450
|
+
}
|
|
451
|
+
};
|
|
452
|
+
const isSameVnode = (vnode1, vnode2) => {
|
|
453
|
+
// compare if two vnode to see if they're "technically" the same
|
|
454
|
+
// need to have the same element tag, and same key to be the same
|
|
455
|
+
if (vnode1.$tag$ === vnode2.$tag$) {
|
|
456
|
+
return true;
|
|
457
|
+
}
|
|
458
|
+
return false;
|
|
459
|
+
};
|
|
236
460
|
const patch = (oldVNode, newVNode) => {
|
|
237
461
|
const elm = (newVNode.$elm$ = oldVNode.$elm$);
|
|
462
|
+
const oldChildren = oldVNode.$children$;
|
|
238
463
|
const newChildren = newVNode.$children$;
|
|
239
|
-
|
|
240
|
-
|
|
464
|
+
const text = newVNode.$text$;
|
|
465
|
+
if (text === null) {
|
|
466
|
+
// element node
|
|
467
|
+
{
|
|
468
|
+
{
|
|
469
|
+
// either this is the first render of an element OR it's an update
|
|
470
|
+
// AND we already know it's possible it could have changed
|
|
471
|
+
// this updates the element's css classes, attrs, props, listeners, etc.
|
|
472
|
+
updateElement(oldVNode, newVNode, isSvgMode);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
if (oldChildren !== null && newChildren !== null) {
|
|
476
|
+
// looks like there's child vnodes for both the old and new vnodes
|
|
477
|
+
updateChildren(elm, oldChildren, newVNode, newChildren);
|
|
478
|
+
}
|
|
479
|
+
else if (newChildren !== null) {
|
|
480
|
+
// no old child vnodes, but there are new child vnodes to add
|
|
481
|
+
if (oldVNode.$text$ !== null) {
|
|
482
|
+
// the old vnode was text, so be sure to clear it out
|
|
483
|
+
elm.textContent = '';
|
|
484
|
+
}
|
|
241
485
|
// add the new vnode children
|
|
242
486
|
addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
|
|
243
487
|
}
|
|
244
|
-
else
|
|
488
|
+
else if (oldChildren !== null) {
|
|
489
|
+
// no new child vnodes, but there are old child vnodes to remove
|
|
490
|
+
removeVnodes(oldChildren, 0, oldChildren.length - 1);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
else if (oldVNode.$text$ !== text) {
|
|
494
|
+
// update the text content for the text only vnode
|
|
495
|
+
// and also only if the text is different than before
|
|
496
|
+
elm.data = text;
|
|
497
|
+
}
|
|
498
|
+
};
|
|
499
|
+
const callNodeRefs = (vNode) => {
|
|
500
|
+
{
|
|
501
|
+
vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
|
|
502
|
+
vNode.$children$ && vNode.$children$.map(callNodeRefs);
|
|
245
503
|
}
|
|
246
504
|
};
|
|
247
505
|
const renderVdom = (hostRef, renderFnResults) => {
|
|
248
506
|
const hostElm = hostRef.$hostElement$;
|
|
249
507
|
const oldVNode = hostRef.$vnode$ || newVNode(null, null);
|
|
250
508
|
const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
|
|
509
|
+
hostTagName = hostElm.tagName;
|
|
251
510
|
rootVnode.$tag$ = null;
|
|
252
511
|
rootVnode.$flags$ |= 4 /* isHost */;
|
|
253
512
|
hostRef.$vnode$ = rootVnode;
|
|
254
|
-
rootVnode.$elm$ = oldVNode.$elm$ = (hostElm);
|
|
513
|
+
rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
|
|
255
514
|
{
|
|
256
515
|
scopeId = hostElm['s-sc'];
|
|
257
516
|
}
|
|
@@ -290,6 +549,9 @@ const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
|
290
549
|
}
|
|
291
550
|
};
|
|
292
551
|
const scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
552
|
+
{
|
|
553
|
+
hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
|
|
554
|
+
}
|
|
293
555
|
if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
|
|
294
556
|
hostRef.$flags$ |= 512 /* needsRerender */;
|
|
295
557
|
return;
|
|
@@ -351,6 +613,9 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
|
351
613
|
const callRender = (hostRef, instance, elm) => {
|
|
352
614
|
try {
|
|
353
615
|
instance = instance.render() ;
|
|
616
|
+
{
|
|
617
|
+
hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
|
|
618
|
+
}
|
|
354
619
|
{
|
|
355
620
|
hostRef.$flags$ |= 2 /* hasRendered */;
|
|
356
621
|
}
|
|
@@ -439,13 +704,93 @@ const then = (promise, thenFn) => {
|
|
|
439
704
|
};
|
|
440
705
|
const addHydratedFlag = (elm) => elm.classList.add('hydrated')
|
|
441
706
|
;
|
|
707
|
+
/**
|
|
708
|
+
* Parse a new property value for a given property type.
|
|
709
|
+
*
|
|
710
|
+
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
711
|
+
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
712
|
+
* 1. `any`, the type given to `propValue` in the function signature
|
|
713
|
+
* 2. the type stored from `propType`.
|
|
714
|
+
*
|
|
715
|
+
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
716
|
+
*
|
|
717
|
+
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
718
|
+
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
719
|
+
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
720
|
+
* ```tsx
|
|
721
|
+
* <my-cmp prop-val={0}></my-cmp>
|
|
722
|
+
* ```
|
|
723
|
+
*
|
|
724
|
+
* HTML prop values on the other hand, will always a string
|
|
725
|
+
*
|
|
726
|
+
* @param propValue the new value to coerce to some type
|
|
727
|
+
* @param propType the type of the prop, expressed as a binary number
|
|
728
|
+
* @returns the parsed/coerced value
|
|
729
|
+
*/
|
|
730
|
+
const parsePropertyValue = (propValue, propType) => {
|
|
731
|
+
// ensure this value is of the correct prop type
|
|
732
|
+
if (propValue != null && !isComplexType(propValue)) {
|
|
733
|
+
if (propType & 1 /* String */) {
|
|
734
|
+
// could have been passed as a number or boolean
|
|
735
|
+
// but we still want it as a string
|
|
736
|
+
return String(propValue);
|
|
737
|
+
}
|
|
738
|
+
// redundant return here for better minification
|
|
739
|
+
return propValue;
|
|
740
|
+
}
|
|
741
|
+
// not sure exactly what type we want
|
|
742
|
+
// so no need to change to a different type
|
|
743
|
+
return propValue;
|
|
744
|
+
};
|
|
745
|
+
const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
|
|
746
|
+
const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
747
|
+
// check our new property value against our internal value
|
|
748
|
+
const hostRef = getHostRef(ref);
|
|
749
|
+
const oldVal = hostRef.$instanceValues$.get(propName);
|
|
750
|
+
const flags = hostRef.$flags$;
|
|
751
|
+
const instance = hostRef.$lazyInstance$ ;
|
|
752
|
+
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
753
|
+
// explicitly check for NaN on both sides, as `NaN === NaN` is always false
|
|
754
|
+
const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
|
|
755
|
+
const didValueChange = newVal !== oldVal && !areBothNaN;
|
|
756
|
+
if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
|
|
757
|
+
// gadzooks! the property's value has changed!!
|
|
758
|
+
// set our new value!
|
|
759
|
+
hostRef.$instanceValues$.set(propName, newVal);
|
|
760
|
+
if (instance) {
|
|
761
|
+
if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
|
|
762
|
+
// looks like this value actually changed, so we've got work to do!
|
|
763
|
+
// but only if we've already rendered, otherwise just chill out
|
|
764
|
+
// queue that we need to do an update, but don't worry about queuing
|
|
765
|
+
// up millions cuz this function ensures it only runs once
|
|
766
|
+
scheduleUpdate(hostRef, false);
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
};
|
|
442
771
|
const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
443
772
|
if (cmpMeta.$members$) {
|
|
444
773
|
// It's better to have a const than two Object.entries()
|
|
445
774
|
const members = Object.entries(cmpMeta.$members$);
|
|
446
775
|
const prototype = Cstr.prototype;
|
|
447
776
|
members.map(([memberName, [memberFlags]]) => {
|
|
448
|
-
if (
|
|
777
|
+
if ((memberFlags & 31 /* Prop */ ||
|
|
778
|
+
((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
|
|
779
|
+
// proxyComponent - prop
|
|
780
|
+
Object.defineProperty(prototype, memberName, {
|
|
781
|
+
get() {
|
|
782
|
+
// proxyComponent, get value
|
|
783
|
+
return getValue(this, memberName);
|
|
784
|
+
},
|
|
785
|
+
set(newValue) {
|
|
786
|
+
// proxyComponent, set value
|
|
787
|
+
setValue(this, memberName, newValue, cmpMeta);
|
|
788
|
+
},
|
|
789
|
+
configurable: true,
|
|
790
|
+
enumerable: true,
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
else if (flags & 1 /* isElementConstructor */ &&
|
|
449
794
|
memberFlags & 64 /* Method */) {
|
|
450
795
|
// proxyComponent - method
|
|
451
796
|
Object.defineProperty(prototype, memberName, {
|
|
@@ -456,6 +801,69 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
456
801
|
});
|
|
457
802
|
}
|
|
458
803
|
});
|
|
804
|
+
if ((flags & 1 /* isElementConstructor */)) {
|
|
805
|
+
const attrNameToPropName = new Map();
|
|
806
|
+
prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
|
|
807
|
+
plt.jmp(() => {
|
|
808
|
+
const propName = attrNameToPropName.get(attrName);
|
|
809
|
+
// In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
|
|
810
|
+
// in the case where an attribute was set inline.
|
|
811
|
+
// ```html
|
|
812
|
+
// <my-component some-attribute="some-value"></my-component>
|
|
813
|
+
// ```
|
|
814
|
+
//
|
|
815
|
+
// There is an edge case where a developer sets the attribute inline on a custom element and then
|
|
816
|
+
// programmatically changes it before it has been upgraded as shown below:
|
|
817
|
+
//
|
|
818
|
+
// ```html
|
|
819
|
+
// <!-- this component has _not_ been upgraded yet -->
|
|
820
|
+
// <my-component id="test" some-attribute="some-value"></my-component>
|
|
821
|
+
// <script>
|
|
822
|
+
// // grab non-upgraded component
|
|
823
|
+
// el = document.querySelector("#test");
|
|
824
|
+
// el.someAttribute = "another-value";
|
|
825
|
+
// // upgrade component
|
|
826
|
+
// customElements.define('my-component', MyComponent);
|
|
827
|
+
// </script>
|
|
828
|
+
// ```
|
|
829
|
+
// In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
|
|
830
|
+
// will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
|
|
831
|
+
// to the value that was set inline i.e. "some-value" from above example. When
|
|
832
|
+
// the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
|
|
833
|
+
//
|
|
834
|
+
// The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
|
|
835
|
+
// by connectedCallback as this attributeChangedCallback will not fire.
|
|
836
|
+
//
|
|
837
|
+
// https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
|
|
838
|
+
//
|
|
839
|
+
// TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
|
|
840
|
+
// properties here given that this goes against best practices outlined here
|
|
841
|
+
// https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
|
|
842
|
+
if (this.hasOwnProperty(propName)) {
|
|
843
|
+
newValue = this[propName];
|
|
844
|
+
delete this[propName];
|
|
845
|
+
}
|
|
846
|
+
else if (prototype.hasOwnProperty(propName) &&
|
|
847
|
+
typeof this[propName] === 'number' &&
|
|
848
|
+
this[propName] == newValue) {
|
|
849
|
+
// if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
|
|
850
|
+
// APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
|
|
851
|
+
// `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
|
|
852
|
+
return;
|
|
853
|
+
}
|
|
854
|
+
this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
|
|
855
|
+
});
|
|
856
|
+
};
|
|
857
|
+
// create an array of attributes to observe
|
|
858
|
+
// and also create a map of html attribute name to js property name
|
|
859
|
+
Cstr.observedAttributes = members
|
|
860
|
+
.filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
|
|
861
|
+
.map(([propName, m]) => {
|
|
862
|
+
const attrName = m[1] || propName;
|
|
863
|
+
attrNameToPropName.set(attrName, propName);
|
|
864
|
+
return attrName;
|
|
865
|
+
});
|
|
866
|
+
}
|
|
459
867
|
}
|
|
460
868
|
return Cstr;
|
|
461
869
|
};
|
|
@@ -551,6 +959,17 @@ const connectedCallback = (elm) => {
|
|
|
551
959
|
}
|
|
552
960
|
}
|
|
553
961
|
}
|
|
962
|
+
// Lazy properties
|
|
963
|
+
// https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
|
|
964
|
+
if (cmpMeta.$members$) {
|
|
965
|
+
Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
|
|
966
|
+
if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
|
|
967
|
+
const value = elm[memberName];
|
|
968
|
+
delete elm[memberName];
|
|
969
|
+
elm[memberName] = value;
|
|
970
|
+
}
|
|
971
|
+
});
|
|
972
|
+
}
|
|
554
973
|
{
|
|
555
974
|
initializeComponent(elm, hostRef, cmpMeta);
|
|
556
975
|
}
|
|
@@ -595,6 +1014,17 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
595
1014
|
super(self);
|
|
596
1015
|
self = this;
|
|
597
1016
|
registerHost(self, cmpMeta);
|
|
1017
|
+
if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
|
|
1018
|
+
// this component is using shadow dom
|
|
1019
|
+
// and this browser supports shadow dom
|
|
1020
|
+
// add the read-only property "shadowRoot" to the host element
|
|
1021
|
+
// adding the shadow root build conditionals to minimize runtime
|
|
1022
|
+
{
|
|
1023
|
+
{
|
|
1024
|
+
self.attachShadow({ mode: 'open' });
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
598
1028
|
}
|
|
599
1029
|
connectedCallback() {
|
|
600
1030
|
if (appLoadFallback) {
|
|
@@ -661,6 +1091,7 @@ const registerHost = (elm, cmpMeta) => {
|
|
|
661
1091
|
}
|
|
662
1092
|
return hostRefs.set(elm, hostRef);
|
|
663
1093
|
};
|
|
1094
|
+
const isMemberInElement = (elm, memberName) => memberName in elm;
|
|
664
1095
|
const consoleError = (e, el) => (0, console.error)(e, el);
|
|
665
1096
|
const cmpModules = /*@__PURE__*/ new Map();
|
|
666
1097
|
const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
@@ -728,6 +1159,7 @@ const flush = () => {
|
|
|
728
1159
|
const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
|
|
729
1160
|
const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
|
|
730
1161
|
|
|
1162
|
+
exports.Host = Host;
|
|
731
1163
|
exports.bootstrapLazy = bootstrapLazy;
|
|
732
1164
|
exports.createEvent = createEvent;
|
|
733
1165
|
exports.h = h;
|
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
5
|
+
const index = require('./index-8272993f.js');
|
|
6
6
|
|
|
7
7
|
/*
|
|
8
8
|
Stencil Client Patch Esm v2.16.1 | MIT Licensed | https://stenciljs.com
|
|
@@ -14,7 +14,7 @@ const patchEsm = () => {
|
|
|
14
14
|
const defineCustomElements = (win, options) => {
|
|
15
15
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
16
16
|
return patchEsm().then(() => {
|
|
17
|
-
return index.bootstrapLazy([["snk-application.cjs",[[2,"snk-application",{"getStringParam":[64],"getIntParam":[64],"getFloatParam":[64],"getBooleanParam":[64],"getDateParam":[64],"temOpcional":[64],"getAttributeFromHTMLWrapper":[64],"openApp":[64],"createDataunit":[64],"getResourceID":[64],"alert":[64],"error":[64],"confirm":[64],"info":[64],"loadFormConfig":[64]}]]]], options);
|
|
17
|
+
return index.bootstrapLazy([["snk-pesquisa.cjs",[[1,"snk-pesquisa",{"searchLoader":[16],"onSelectItem":[16],"argument":[1025]}]]],["snk-application.cjs",[[2,"snk-application",{"getStringParam":[64],"getIntParam":[64],"getFloatParam":[64],"getBooleanParam":[64],"getDateParam":[64],"showPopUp":[64],"closePopUp":[64],"temOpcional":[64],"getAttributeFromHTMLWrapper":[64],"openApp":[64],"createDataunit":[64],"getResourceID":[64],"alert":[64],"error":[64],"confirm":[64],"info":[64],"loadFormConfig":[64]}]]],["teste-pesquisa.cjs",[[1,"teste-pesquisa"]]]], options);
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const index = require('./index-
|
|
3
|
+
const index = require('./index-8272993f.js');
|
|
4
4
|
|
|
5
5
|
/*
|
|
6
6
|
Stencil Client Patch Browser v2.16.1 | MIT Licensed | https://stenciljs.com
|
|
@@ -15,5 +15,5 @@ const patchBrowser = () => {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
patchBrowser().then(options => {
|
|
18
|
-
return index.bootstrapLazy([["snk-application.cjs",[[2,"snk-application",{"getStringParam":[64],"getIntParam":[64],"getFloatParam":[64],"getBooleanParam":[64],"getDateParam":[64],"temOpcional":[64],"getAttributeFromHTMLWrapper":[64],"openApp":[64],"createDataunit":[64],"getResourceID":[64],"alert":[64],"error":[64],"confirm":[64],"info":[64],"loadFormConfig":[64]}]]]], options);
|
|
18
|
+
return index.bootstrapLazy([["snk-pesquisa.cjs",[[1,"snk-pesquisa",{"searchLoader":[16],"onSelectItem":[16],"argument":[1025]}]]],["snk-application.cjs",[[2,"snk-application",{"getStringParam":[64],"getIntParam":[64],"getFloatParam":[64],"getBooleanParam":[64],"getDateParam":[64],"showPopUp":[64],"closePopUp":[64],"temOpcional":[64],"getAttributeFromHTMLWrapper":[64],"openApp":[64],"createDataunit":[64],"getResourceID":[64],"alert":[64],"error":[64],"confirm":[64],"info":[64],"loadFormConfig":[64]}]]],["teste-pesquisa.cjs",[[1,"teste-pesquisa"]]]], options);
|
|
19
19
|
});
|