@maggioli-design-system/mds-tab 6.8.5 → 7.0.0
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-a9a1a9d2.js → index-7cc6e10e.js} +236 -8
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/mds-tab.cjs.entry.js +31 -21
- package/dist/cjs/mds-tab.cjs.js +3 -3
- package/dist/collection/collection-manifest.json +2 -2
- package/dist/collection/common/date.js +13 -0
- package/dist/collection/common/locale.js +25 -7
- package/dist/collection/components/mds-tab/mds-tab.css +73 -313
- package/dist/collection/components/mds-tab/mds-tab.js +48 -19
- package/dist/collection/components/mds-tab/test/mds-tab.stories.js +12 -0
- package/dist/collection/dictionary/button.js +7 -1
- package/dist/collection/dictionary/variant.js +15 -1
- package/dist/collection/type/variant-file-format.js +0 -34
- package/dist/components/mds-tab.js +33 -21
- package/dist/documentation.json +59 -4
- package/dist/esm/{index-031b9050.js → index-f8310307.js} +236 -8
- package/dist/esm/loader.js +3 -3
- package/dist/esm/mds-tab.entry.js +31 -21
- package/dist/esm/mds-tab.js +4 -4
- package/dist/esm-es5/index-f8310307.js +1 -0
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/mds-tab.entry.js +1 -1
- package/dist/esm-es5/mds-tab.js +1 -1
- package/dist/mds-tab/mds-tab.esm.js +1 -1
- package/dist/mds-tab/mds-tab.js +1 -1
- package/dist/mds-tab/p-6c416a14.entry.js +1 -0
- package/dist/mds-tab/p-c5a4ac65.system.js +2 -0
- package/dist/mds-tab/p-d9d8efef.system.js +1 -0
- package/dist/mds-tab/p-e3daf78d.system.entry.js +1 -0
- package/dist/mds-tab/p-e71ab9d0.js +2 -0
- package/dist/stats.json +129 -44
- package/dist/types/common/date.d.ts +4 -0
- package/dist/types/common/file.d.ts +3 -4
- package/dist/types/common/locale.d.ts +5 -2
- package/dist/types/components/mds-tab/mds-tab.d.ts +5 -1
- package/dist/types/components/mds-tab/test/mds-tab.stories.d.ts +10 -0
- package/dist/types/components.d.ts +8 -0
- package/dist/types/dictionary/button.d.ts +2 -1
- package/dist/types/dictionary/file-extensions.d.ts +2 -1
- package/dist/types/dictionary/variant.d.ts +3 -1
- package/dist/types/stencil-public-runtime.d.ts +6 -0
- package/dist/types/type/autocomplete.d.ts +1 -1
- package/dist/types/type/button.d.ts +1 -1
- package/dist/types/type/date.d.ts +5 -0
- package/dist/types/type/header-bar.d.ts +2 -0
- package/dist/types/type/input.d.ts +3 -0
- package/dist/types/type/variant-file-format.d.ts +4 -4
- package/dist/types/type/variant.d.ts +3 -2
- package/documentation.json +116 -36
- package/package.json +5 -5
- package/readme.md +19 -7
- package/src/common/date.ts +21 -0
- package/src/common/file.ts +2 -3
- package/src/common/locale.ts +29 -9
- package/src/common/unit.ts +1 -1
- package/src/components/mds-tab/.gitlab-ci.yml +5 -10
- package/src/components/mds-tab/css/mds-tab-scrollbar.css +34 -0
- package/src/components/mds-tab/mds-tab.css +22 -10
- package/src/components/mds-tab/mds-tab.tsx +29 -22
- package/src/components/mds-tab/readme.md +16 -4
- package/src/components/mds-tab/test/mds-tab.stories.tsx +27 -0
- package/src/components.d.ts +8 -0
- package/src/dictionary/button.ts +8 -0
- package/src/dictionary/file-extensions.ts +3 -1
- package/src/dictionary/variant.ts +18 -0
- package/src/fixtures/icons.json +29 -3
- package/src/fixtures/iconsauce.json +21 -1
- package/src/tailwind/components.css +1 -1
- package/src/type/autocomplete.ts +0 -1
- package/src/type/button.ts +1 -0
- package/src/type/date.ts +10 -0
- package/src/type/header-bar.ts +11 -0
- package/src/type/input.ts +4 -0
- package/src/type/variant-file-format.ts +20 -37
- package/src/type/variant.ts +10 -2
- package/www/build/mds-tab.esm.js +1 -1
- package/www/build/mds-tab.js +1 -1
- package/www/build/p-6c416a14.entry.js +1 -0
- package/www/build/p-c5a4ac65.system.js +2 -0
- package/www/build/p-d9d8efef.system.js +1 -0
- package/www/build/p-e3daf78d.system.entry.js +1 -0
- package/www/build/p-e71ab9d0.js +2 -0
- package/dist/esm-es5/index-031b9050.js +0 -1
- package/dist/mds-tab/p-0473c0a7.system.js +0 -1
- package/dist/mds-tab/p-699c0b98.js +0 -2
- package/dist/mds-tab/p-8b73828a.system.entry.js +0 -1
- package/dist/mds-tab/p-ddd0b40f.system.js +0 -2
- package/dist/mds-tab/p-fc6f521e.entry.js +0 -1
- package/dist/types/interface/input-value.d.ts +0 -4
- package/dist/types/type/language.d.ts +0 -1
- package/src/interface/input-value.ts +0 -5
- package/src/type/language.ts +0 -4
- package/www/build/p-0473c0a7.system.js +0 -1
- package/www/build/p-699c0b98.js +0 -2
- package/www/build/p-8b73828a.system.entry.js +0 -1
- package/www/build/p-ddd0b40f.system.js +0 -2
- package/www/build/p-fc6f521e.entry.js +0 -1
- /package/dist/collection/{interface/input-value.js → type/date.js} +0 -0
- /package/dist/collection/type/{language.js → header-bar.js} +0 -0
|
@@ -21,10 +21,10 @@ function _interopNamespace(e) {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
const NAMESPACE = 'mds-tab';
|
|
24
|
-
const BUILD = /* mds-tab */ { allRenderFn: true, appendChildSlotFix: false, asyncLoading: true, asyncQueue: false, attachStyles: true, cloneNodeFix: false, cmpDidLoad: true, cmpDidRender: false, cmpDidUnload: false, cmpDidUpdate: false, cmpShouldUpdate: false, cmpWillLoad: true, cmpWillRender: false, cmpWillUpdate: false, connectedCallback: false, constructableCSS: true, cssAnnotations: true, devTools: false, disconnectedCallback: false, element: false, event: true, experimentalScopedSlotChanges: false, experimentalSlotFixes: false, formAssociated: false, hasRenderFn: true, hostListener: true, hostListenerTarget: false, hostListenerTargetBody: false, hostListenerTargetDocument: false, hostListenerTargetParent: false, hostListenerTargetWindow: false, hotModuleReplacement: false, hydrateClientSide: false, hydrateServerSide: false, hydratedAttribute: true, hydratedClass: false, hydratedSelectorName: "hydrated", initializeNextTick: false, invisiblePrehydration: true, isDebug: false, isDev: false, isTesting: false, lazyLoad: true, lifecycle: true, lifecycleDOMEvents: false, member: true, method: false, mode: false, observeAttribute:
|
|
24
|
+
const BUILD = /* mds-tab */ { allRenderFn: true, appendChildSlotFix: false, asyncLoading: true, asyncQueue: false, attachStyles: true, cloneNodeFix: false, cmpDidLoad: true, cmpDidRender: false, cmpDidUnload: false, cmpDidUpdate: false, cmpShouldUpdate: false, cmpWillLoad: true, cmpWillRender: false, cmpWillUpdate: false, connectedCallback: false, constructableCSS: true, cssAnnotations: true, devTools: false, disconnectedCallback: false, element: false, event: true, experimentalScopedSlotChanges: false, experimentalSlotFixes: false, formAssociated: false, hasRenderFn: true, hostListener: true, hostListenerTarget: false, hostListenerTargetBody: false, hostListenerTargetDocument: false, hostListenerTargetParent: false, hostListenerTargetWindow: false, hotModuleReplacement: false, hydrateClientSide: false, hydrateServerSide: false, hydratedAttribute: true, hydratedClass: false, hydratedSelectorName: "hydrated", initializeNextTick: false, invisiblePrehydration: true, isDebug: false, isDev: false, isTesting: false, lazyLoad: true, lifecycle: true, lifecycleDOMEvents: false, member: true, method: false, mode: false, observeAttribute: true, profile: false, prop: true, propBoolean: true, propMutable: false, propNumber: false, propString: false, reflect: true, scoped: false, scopedSlotTextContentFix: false, scriptDataOpts: false, shadowDelegatesFocus: false, shadowDom: true, slot: true, slotChildNodesFix: false, slotRelocation: false, state: false, style: true, svg: false, taskQueue: true, transformTagName: false, updatable: true, vdomAttribute: true, vdomClass: true, vdomFunctional: false, vdomKey: true, vdomListener: false, vdomPropOrAttr: true, vdomRef: false, vdomRender: true, vdomStyle: false, vdomText: false, vdomXlink: false, watchCallback: false };
|
|
25
25
|
|
|
26
26
|
/*
|
|
27
|
-
Stencil Client Platform v4.
|
|
27
|
+
Stencil Client Platform v4.22.2 | MIT Licensed | https://stenciljs.com
|
|
28
28
|
*/
|
|
29
29
|
var __defProp = Object.defineProperty;
|
|
30
30
|
var __export = (target, all) => {
|
|
@@ -309,6 +309,15 @@ var newVNode = (tag, text) => {
|
|
|
309
309
|
};
|
|
310
310
|
var Host = {};
|
|
311
311
|
var isHost = (node) => node && node.$tag$ === Host;
|
|
312
|
+
var parsePropertyValue = (propValue, propType) => {
|
|
313
|
+
if (propValue != null && !isComplexType(propValue)) {
|
|
314
|
+
if (propType & 4 /* Boolean */) {
|
|
315
|
+
return propValue === "false" ? false : propValue === "" || !!propValue;
|
|
316
|
+
}
|
|
317
|
+
return propValue;
|
|
318
|
+
}
|
|
319
|
+
return propValue;
|
|
320
|
+
};
|
|
312
321
|
var getElement = (ref) => getHostRef(ref).$hostElement$ ;
|
|
313
322
|
|
|
314
323
|
// src/runtime/event-emitter.ts
|
|
@@ -369,10 +378,21 @@ var addStyle = (styleContainerNode, cmpMeta, mode) => {
|
|
|
369
378
|
if (!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */)) {
|
|
370
379
|
if (styleContainerNode.nodeName === "HEAD") {
|
|
371
380
|
const preconnectLinks = styleContainerNode.querySelectorAll("link[rel=preconnect]");
|
|
372
|
-
const referenceNode2 = preconnectLinks.length > 0 ? preconnectLinks[preconnectLinks.length - 1].nextSibling :
|
|
381
|
+
const referenceNode2 = preconnectLinks.length > 0 ? preconnectLinks[preconnectLinks.length - 1].nextSibling : styleContainerNode.querySelector("style");
|
|
373
382
|
styleContainerNode.insertBefore(styleElm, referenceNode2);
|
|
374
383
|
} else if ("host" in styleContainerNode) {
|
|
375
|
-
|
|
384
|
+
if (supportsConstructableStylesheets) {
|
|
385
|
+
const stylesheet = new CSSStyleSheet();
|
|
386
|
+
stylesheet.replaceSync(style);
|
|
387
|
+
styleContainerNode.adoptedStyleSheets = [stylesheet, ...styleContainerNode.adoptedStyleSheets];
|
|
388
|
+
} else {
|
|
389
|
+
const existingStyleContainer = styleContainerNode.querySelector("style");
|
|
390
|
+
if (existingStyleContainer) {
|
|
391
|
+
existingStyleContainer.innerHTML = style + existingStyleContainer.innerHTML;
|
|
392
|
+
} else {
|
|
393
|
+
styleContainerNode.prepend(styleElm);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
376
396
|
} else {
|
|
377
397
|
styleContainerNode.append(styleElm);
|
|
378
398
|
}
|
|
@@ -463,6 +483,13 @@ var updateElement = (oldVnode, newVnode, isSvgMode2) => {
|
|
|
463
483
|
const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host ? newVnode.$elm$.host : newVnode.$elm$;
|
|
464
484
|
const oldVnodeAttrs = oldVnode && oldVnode.$attrs$ || EMPTY_OBJ;
|
|
465
485
|
const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
|
|
486
|
+
{
|
|
487
|
+
for (const memberName of sortedAttrNames(Object.keys(oldVnodeAttrs))) {
|
|
488
|
+
if (!(memberName in newVnodeAttrs)) {
|
|
489
|
+
setAccessor(elm, memberName, oldVnodeAttrs[memberName], void 0, isSvgMode2, newVnode.$flags$);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}
|
|
466
493
|
for (const memberName of sortedAttrNames(Object.keys(newVnodeAttrs))) {
|
|
467
494
|
setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode2, newVnode.$flags$);
|
|
468
495
|
}
|
|
@@ -538,6 +565,99 @@ var removeVnodes = (vnodes, startIdx, endIdx) => {
|
|
|
538
565
|
}
|
|
539
566
|
}
|
|
540
567
|
};
|
|
568
|
+
var updateChildren = (parentElm, oldCh, newVNode2, newCh, isInitialRender = false) => {
|
|
569
|
+
let oldStartIdx = 0;
|
|
570
|
+
let newStartIdx = 0;
|
|
571
|
+
let idxInOld = 0;
|
|
572
|
+
let i2 = 0;
|
|
573
|
+
let oldEndIdx = oldCh.length - 1;
|
|
574
|
+
let oldStartVnode = oldCh[0];
|
|
575
|
+
let oldEndVnode = oldCh[oldEndIdx];
|
|
576
|
+
let newEndIdx = newCh.length - 1;
|
|
577
|
+
let newStartVnode = newCh[0];
|
|
578
|
+
let newEndVnode = newCh[newEndIdx];
|
|
579
|
+
let node;
|
|
580
|
+
let elmToMove;
|
|
581
|
+
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
582
|
+
if (oldStartVnode == null) {
|
|
583
|
+
oldStartVnode = oldCh[++oldStartIdx];
|
|
584
|
+
} else if (oldEndVnode == null) {
|
|
585
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
586
|
+
} else if (newStartVnode == null) {
|
|
587
|
+
newStartVnode = newCh[++newStartIdx];
|
|
588
|
+
} else if (newEndVnode == null) {
|
|
589
|
+
newEndVnode = newCh[--newEndIdx];
|
|
590
|
+
} else if (isSameVnode(oldStartVnode, newStartVnode, isInitialRender)) {
|
|
591
|
+
patch(oldStartVnode, newStartVnode, isInitialRender);
|
|
592
|
+
oldStartVnode = oldCh[++oldStartIdx];
|
|
593
|
+
newStartVnode = newCh[++newStartIdx];
|
|
594
|
+
} else if (isSameVnode(oldEndVnode, newEndVnode, isInitialRender)) {
|
|
595
|
+
patch(oldEndVnode, newEndVnode, isInitialRender);
|
|
596
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
597
|
+
newEndVnode = newCh[--newEndIdx];
|
|
598
|
+
} else if (isSameVnode(oldStartVnode, newEndVnode, isInitialRender)) {
|
|
599
|
+
patch(oldStartVnode, newEndVnode, isInitialRender);
|
|
600
|
+
insertBefore(parentElm, oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
|
|
601
|
+
oldStartVnode = oldCh[++oldStartIdx];
|
|
602
|
+
newEndVnode = newCh[--newEndIdx];
|
|
603
|
+
} else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
|
|
604
|
+
patch(oldEndVnode, newStartVnode, isInitialRender);
|
|
605
|
+
insertBefore(parentElm, oldEndVnode.$elm$, oldStartVnode.$elm$);
|
|
606
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
607
|
+
newStartVnode = newCh[++newStartIdx];
|
|
608
|
+
} else {
|
|
609
|
+
idxInOld = -1;
|
|
610
|
+
{
|
|
611
|
+
for (i2 = oldStartIdx; i2 <= oldEndIdx; ++i2) {
|
|
612
|
+
if (oldCh[i2] && oldCh[i2].$key$ !== null && oldCh[i2].$key$ === newStartVnode.$key$) {
|
|
613
|
+
idxInOld = i2;
|
|
614
|
+
break;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
if (idxInOld >= 0) {
|
|
619
|
+
elmToMove = oldCh[idxInOld];
|
|
620
|
+
if (elmToMove.$tag$ !== newStartVnode.$tag$) {
|
|
621
|
+
node = createElm(oldCh && oldCh[newStartIdx], newVNode2, idxInOld);
|
|
622
|
+
} else {
|
|
623
|
+
patch(elmToMove, newStartVnode, isInitialRender);
|
|
624
|
+
oldCh[idxInOld] = void 0;
|
|
625
|
+
node = elmToMove.$elm$;
|
|
626
|
+
}
|
|
627
|
+
newStartVnode = newCh[++newStartIdx];
|
|
628
|
+
} else {
|
|
629
|
+
node = createElm(oldCh && oldCh[newStartIdx], newVNode2, newStartIdx);
|
|
630
|
+
newStartVnode = newCh[++newStartIdx];
|
|
631
|
+
}
|
|
632
|
+
if (node) {
|
|
633
|
+
{
|
|
634
|
+
insertBefore(oldStartVnode.$elm$.parentNode, node, oldStartVnode.$elm$);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
if (oldStartIdx > oldEndIdx) {
|
|
640
|
+
addVnodes(
|
|
641
|
+
parentElm,
|
|
642
|
+
newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$,
|
|
643
|
+
newVNode2,
|
|
644
|
+
newCh,
|
|
645
|
+
newStartIdx,
|
|
646
|
+
newEndIdx
|
|
647
|
+
);
|
|
648
|
+
} else if (newStartIdx > newEndIdx) {
|
|
649
|
+
removeVnodes(oldCh, oldStartIdx, oldEndIdx);
|
|
650
|
+
}
|
|
651
|
+
};
|
|
652
|
+
var isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
|
|
653
|
+
if (leftVNode.$tag$ === rightVNode.$tag$) {
|
|
654
|
+
if (!isInitialRender) {
|
|
655
|
+
return leftVNode.$key$ === rightVNode.$key$;
|
|
656
|
+
}
|
|
657
|
+
return true;
|
|
658
|
+
}
|
|
659
|
+
return false;
|
|
660
|
+
};
|
|
541
661
|
var patch = (oldVNode, newVNode2, isInitialRender = false) => {
|
|
542
662
|
const elm = newVNode2.$elm$ = oldVNode.$elm$;
|
|
543
663
|
const oldChildren = oldVNode.$children$;
|
|
@@ -549,7 +669,9 @@ var patch = (oldVNode, newVNode2, isInitialRender = false) => {
|
|
|
549
669
|
updateElement(oldVNode, newVNode2, isSvgMode);
|
|
550
670
|
}
|
|
551
671
|
}
|
|
552
|
-
if (newChildren !== null) {
|
|
672
|
+
if (oldChildren !== null && newChildren !== null) {
|
|
673
|
+
updateChildren(elm, oldChildren, newVNode2, newChildren, isInitialRender);
|
|
674
|
+
} else if (newChildren !== null) {
|
|
553
675
|
addVnodes(elm, null, newVNode2, newChildren, 0, newChildren.length - 1);
|
|
554
676
|
} else if (
|
|
555
677
|
// don't do this on initial render as it can cause non-hydrated content to be removed
|
|
@@ -569,6 +691,12 @@ var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
|
|
|
569
691
|
const oldVNode = hostRef.$vnode$ || newVNode(null, null);
|
|
570
692
|
const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
|
|
571
693
|
hostTagName = hostElm.tagName;
|
|
694
|
+
if (cmpMeta.$attrsToReflect$) {
|
|
695
|
+
rootVnode.$attrs$ = rootVnode.$attrs$ || {};
|
|
696
|
+
cmpMeta.$attrsToReflect$.map(
|
|
697
|
+
([propName, attribute]) => rootVnode.$attrs$[attribute] = hostElm[propName]
|
|
698
|
+
);
|
|
699
|
+
}
|
|
572
700
|
if (isInitialLoad && rootVnode.$attrs$) {
|
|
573
701
|
for (const key of Object.keys(rootVnode.$attrs$)) {
|
|
574
702
|
if (hostElm.hasAttribute(key) && !["key", "ref", "style", "class"].includes(key)) {
|
|
@@ -594,6 +722,9 @@ var attachToAncestor = (hostRef, ancestorComponent) => {
|
|
|
594
722
|
}
|
|
595
723
|
};
|
|
596
724
|
var scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
725
|
+
{
|
|
726
|
+
hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
|
|
727
|
+
}
|
|
597
728
|
if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
|
|
598
729
|
hostRef.$flags$ |= 512 /* needsRerender */;
|
|
599
730
|
return;
|
|
@@ -665,6 +796,9 @@ var updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
|
665
796
|
var callRender = (hostRef, instance, elm, isInitialLoad) => {
|
|
666
797
|
try {
|
|
667
798
|
instance = instance.render() ;
|
|
799
|
+
{
|
|
800
|
+
hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
|
|
801
|
+
}
|
|
668
802
|
{
|
|
669
803
|
hostRef.$flags$ |= 2 /* hasRendered */;
|
|
670
804
|
}
|
|
@@ -736,13 +870,95 @@ var addHydratedFlag = (elm) => {
|
|
|
736
870
|
return elm.setAttribute((_b = BUILD.hydratedSelectorName) != null ? _b : "hydrated", "") ;
|
|
737
871
|
};
|
|
738
872
|
|
|
873
|
+
// src/runtime/set-value.ts
|
|
874
|
+
var getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
|
|
875
|
+
var setValue = (ref, propName, newVal, cmpMeta) => {
|
|
876
|
+
const hostRef = getHostRef(ref);
|
|
877
|
+
if (!hostRef) {
|
|
878
|
+
throw new Error(
|
|
879
|
+
`Couldn't find host element for "${cmpMeta.$tagName$}" as it is unknown to this Stencil runtime. This usually happens when integrating a 3rd party Stencil component with another Stencil component or application. Please reach out to the maintainers of the 3rd party Stencil component or report this on the Stencil Discord server (https://chat.stenciljs.com) or comment on this similar [GitHub issue](https://github.com/ionic-team/stencil/issues/5457).`
|
|
880
|
+
);
|
|
881
|
+
}
|
|
882
|
+
const oldVal = hostRef.$instanceValues$.get(propName);
|
|
883
|
+
const flags = hostRef.$flags$;
|
|
884
|
+
const instance = hostRef.$lazyInstance$ ;
|
|
885
|
+
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
886
|
+
const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
|
|
887
|
+
const didValueChange = newVal !== oldVal && !areBothNaN;
|
|
888
|
+
if ((!(flags & 8 /* isConstructingInstance */) || oldVal === void 0) && didValueChange) {
|
|
889
|
+
hostRef.$instanceValues$.set(propName, newVal);
|
|
890
|
+
if (instance) {
|
|
891
|
+
if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
|
|
892
|
+
scheduleUpdate(hostRef, false);
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
};
|
|
897
|
+
|
|
739
898
|
// src/runtime/proxy-component.ts
|
|
740
899
|
var proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
741
|
-
var _a;
|
|
900
|
+
var _a, _b;
|
|
901
|
+
const prototype = Cstr.prototype;
|
|
742
902
|
if (cmpMeta.$members$ || BUILD.watchCallback ) {
|
|
743
903
|
const members = Object.entries((_a = cmpMeta.$members$) != null ? _a : {});
|
|
744
904
|
members.map(([memberName, [memberFlags]]) => {
|
|
905
|
+
if ((memberFlags & 31 /* Prop */ || (flags & 2 /* proxyState */) && memberFlags & 32 /* State */)) {
|
|
906
|
+
Object.defineProperty(prototype, memberName, {
|
|
907
|
+
get() {
|
|
908
|
+
return getValue(this, memberName);
|
|
909
|
+
},
|
|
910
|
+
set(newValue) {
|
|
911
|
+
setValue(this, memberName, newValue, cmpMeta);
|
|
912
|
+
},
|
|
913
|
+
configurable: true,
|
|
914
|
+
enumerable: true
|
|
915
|
+
});
|
|
916
|
+
}
|
|
745
917
|
});
|
|
918
|
+
if ((flags & 1 /* isElementConstructor */)) {
|
|
919
|
+
const attrNameToPropName = /* @__PURE__ */ new Map();
|
|
920
|
+
prototype.attributeChangedCallback = function(attrName, oldValue, newValue) {
|
|
921
|
+
plt.jmp(() => {
|
|
922
|
+
var _a2;
|
|
923
|
+
const propName = attrNameToPropName.get(attrName);
|
|
924
|
+
if (this.hasOwnProperty(propName)) {
|
|
925
|
+
newValue = this[propName];
|
|
926
|
+
delete this[propName];
|
|
927
|
+
} else if (prototype.hasOwnProperty(propName) && typeof this[propName] === "number" && // cast type to number to avoid TS compiler issues
|
|
928
|
+
this[propName] == newValue) {
|
|
929
|
+
return;
|
|
930
|
+
} else if (propName == null) {
|
|
931
|
+
const hostRef = getHostRef(this);
|
|
932
|
+
const flags2 = hostRef == null ? void 0 : hostRef.$flags$;
|
|
933
|
+
if (flags2 && !(flags2 & 8 /* isConstructingInstance */) && flags2 & 128 /* isWatchReady */ && newValue !== oldValue) {
|
|
934
|
+
const instance = hostRef.$lazyInstance$ ;
|
|
935
|
+
const entry = (_a2 = cmpMeta.$watchers$) == null ? void 0 : _a2[attrName];
|
|
936
|
+
entry == null ? void 0 : entry.forEach((callbackName) => {
|
|
937
|
+
if (instance[callbackName] != null) {
|
|
938
|
+
instance[callbackName].call(instance, newValue, oldValue, attrName);
|
|
939
|
+
}
|
|
940
|
+
});
|
|
941
|
+
}
|
|
942
|
+
return;
|
|
943
|
+
}
|
|
944
|
+
this[propName] = newValue === null && typeof this[propName] === "boolean" ? false : newValue;
|
|
945
|
+
});
|
|
946
|
+
};
|
|
947
|
+
Cstr.observedAttributes = Array.from(
|
|
948
|
+
/* @__PURE__ */ new Set([
|
|
949
|
+
...Object.keys((_b = cmpMeta.$watchers$) != null ? _b : {}),
|
|
950
|
+
...members.filter(([_, m]) => m[0] & 15 /* HasAttribute */).map(([propName, m]) => {
|
|
951
|
+
var _a2;
|
|
952
|
+
const attrName = m[1] || propName;
|
|
953
|
+
attrNameToPropName.set(attrName, propName);
|
|
954
|
+
if (m[0] & 512 /* ReflectAttr */) {
|
|
955
|
+
(_a2 = cmpMeta.$attrsToReflect$) == null ? void 0 : _a2.push([propName, attrName]);
|
|
956
|
+
}
|
|
957
|
+
return attrName;
|
|
958
|
+
})
|
|
959
|
+
])
|
|
960
|
+
);
|
|
961
|
+
}
|
|
746
962
|
}
|
|
747
963
|
return Cstr;
|
|
748
964
|
};
|
|
@@ -766,7 +982,7 @@ var initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
|
766
982
|
throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
|
|
767
983
|
}
|
|
768
984
|
if (!Cstr.isProxied) {
|
|
769
|
-
proxyComponent(Cstr, cmpMeta);
|
|
985
|
+
proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
|
|
770
986
|
Cstr.isProxied = true;
|
|
771
987
|
}
|
|
772
988
|
const endNewInstance = createTime("createInstance", cmpMeta.$tagName$);
|
|
@@ -828,6 +1044,15 @@ var connectedCallback = (elm) => {
|
|
|
828
1044
|
}
|
|
829
1045
|
}
|
|
830
1046
|
}
|
|
1047
|
+
if (cmpMeta.$members$) {
|
|
1048
|
+
Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
|
|
1049
|
+
if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
|
|
1050
|
+
const value = elm[memberName];
|
|
1051
|
+
delete elm[memberName];
|
|
1052
|
+
elm[memberName] = value;
|
|
1053
|
+
}
|
|
1054
|
+
});
|
|
1055
|
+
}
|
|
831
1056
|
{
|
|
832
1057
|
initializeComponent(elm, hostRef, cmpMeta);
|
|
833
1058
|
}
|
|
@@ -890,6 +1115,9 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
890
1115
|
{
|
|
891
1116
|
cmpMeta.$listeners$ = compactMeta[3];
|
|
892
1117
|
}
|
|
1118
|
+
{
|
|
1119
|
+
cmpMeta.$attrsToReflect$ = [];
|
|
1120
|
+
}
|
|
893
1121
|
const tagName = cmpMeta.$tagName$;
|
|
894
1122
|
const HostElement = class extends HTMLElement {
|
|
895
1123
|
// StencilLazyHost
|
|
@@ -942,7 +1170,7 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
942
1170
|
cmpTags.push(tagName);
|
|
943
1171
|
customElements2.define(
|
|
944
1172
|
tagName,
|
|
945
|
-
proxyComponent(HostElement, cmpMeta)
|
|
1173
|
+
proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */)
|
|
946
1174
|
);
|
|
947
1175
|
}
|
|
948
1176
|
});
|
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
5
|
+
const index = require('./index-7cc6e10e.js');
|
|
6
6
|
const appGlobals = require('./app-globals-3a1e7e63.js');
|
|
7
7
|
|
|
8
8
|
const defineCustomElements = async (win, options) => {
|
|
9
9
|
if (typeof window === 'undefined') return undefined;
|
|
10
10
|
await appGlobals.globalScripts();
|
|
11
|
-
return index.bootstrapLazy([["mds-tab.cjs",[[1,"mds-tab",
|
|
11
|
+
return index.bootstrapLazy([["mds-tab.cjs",[[1,"mds-tab",{"scrollbar":[516]},[[0,"mdsTabItemSelect","changeEventHandler"],[0,"mdsTabItemFocus","focusEventHandler"]]]]]], options);
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
exports.setNonce = index.setNonce;
|
|
@@ -2,9 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
5
|
+
const index = require('./index-7cc6e10e.js');
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const setAttributeIfEmpty = (element, attribute, value) => {
|
|
8
|
+
var _a;
|
|
9
|
+
if (element.hasAttribute(attribute)) {
|
|
10
|
+
return (_a = element.getAttribute(attribute)) !== null && _a !== void 0 ? _a : '';
|
|
11
|
+
}
|
|
12
|
+
element.setAttribute(attribute, value);
|
|
13
|
+
return value;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const mdsTabCss = "@tailwind components;\n@tailwind utilities;\n\n@tailwind components;\n@tailwind utilities;\n\n/**\n * @prop --mds-tab-duration: Sets the animation duration on how the contents height is resized when the component switch from a content to another one\n * @prop --mds-tab-scrollbar-margin: Sets the margin of the browser scroll bar (if supported)\n * @prop --mds-tab-scrollbar-radius: Sets the border-radius of the browser scroll bar (if supported)\n * @prop --mds-tab-scrollbar-size: Sets the height and width of the browser scroll bar (if supported)\n * @prop --mds-tab-scrollbar-thumb-background: Sets the background-color of the browser scroll bar thumb (if supported)\n * @prop --mds-tab-scrollbar-track-background: Sets the background-color of the browser scroll bar track (if supported)\n * @prop --mds-tab-timing-function: Sets the animation timing function on how the contents height is resized when the component switch from a content to another one\n */\n\n:host {\n\n --mds-tab-duration: .75s;\n --mds-tab-timing-function: cubic-bezier(1, 0, 0, 1);\n --mds-tab-current-item: 2;\n --mds-tab-scroll-scrollbar-radius: 0;\n --mds-tab-scroll-scrollbar-margin: 0;\n --mds-tab-scroll-scrollbar-size: 0.5rem;\n --mds-tab-scroll-scrollbar-thumb-background: rgb(var(--tone-neutral-02) 0.3);\n --mds-tab-scroll-scrollbar-track-background: rgb(var(--tone-neutral-06) 0.3);\n\n display: grid;\n}\n\n.tabs{\n\n gap: 0.5rem;\n\n border-width: 0.125rem;\n\n border-style: solid;\n\n border-color: transparent;\n\n padding: 0.5rem;\n\n -webkit-transition-duration: 200ms;\n\n transition-duration: 200ms;\n\n -webkit-transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n\n background-color: rgb(var(--theme-default-06-secondary-background));\n border-radius: 1rem;\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n display: -ms-flexbox;\n display: flex;\n overflow: auto;\n scroll-behavior: smooth;\n -webkit-scroll-snap-type: x mandatory;\n -ms-scroll-snap-type: x mandatory;\n scroll-snap-type: x mandatory;\n -webkit-transition-property: background-color;\n transition-property: background-color;\n}\n\n.contents {\n\n --mds-tab-contents-height: auto;\n -webkit-overflow-scrolling: touch;\n -ms-overflow-style: none;\n scrollbar-width: none;\n gap: 1.5rem;\n\n -ms-flex-align: start;\n\n align-items: flex-start;\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n display: -ms-flexbox;\n display: flex;\n height: var(--mds-tab-contents-height);\n overflow-x: auto;\n overflow-y: hidden;\n position: relative;\n scroll-behavior: smooth;\n -webkit-scroll-snap-type: x mandatory;\n -ms-scroll-snap-type: x mandatory;\n scroll-snap-type: x mandatory;\n -webkit-transition: height var(--mds-tab-duration) var(--mds-tab-timing-function);\n transition: height var(--mds-tab-duration) var(--mds-tab-timing-function);\n}\n\n::slotted( [slot=\"content\"] ){\n\n width: 100%;\n\n min-width: 100%;\n\n -webkit-animation-duration: var(--mds-tab-duration);\n\n animation-duration: var(--mds-tab-duration);\n -webkit-animation-fill-mode: forwards;\n animation-fill-mode: forwards;\n -webkit-animation-timing-function: var(--mds-tab-timing-function);\n animation-timing-function: var(--mds-tab-timing-function);\n -ms-flex-preferred-size: 0;\n flex-basis: 0;\n -ms-flex-positive: 1;\n flex-grow: 1;\n scroll-snap-align: start;\n}\n\n::slotted( [slot=\"content\"][mds-tab-content-hidden] ) {\n display: none !important;\n}\n\n@import '~@maggioli-design-system/styles/dist/tailwind/components.css';\n@tailwind components;\n@tailwind utilities;\n\n:host(:not([scrollbar])) .tabs {\n -webkit-overflow-scrolling: touch;\n -ms-overflow-style: none;\n scrollbar-width: none;\n }\n\n:host(:not([scrollbar])) .tabs::-webkit-scrollbar {\n display: none;\n}\n\n:host([scrollbar]:not([scrollbar=\"false\"])) .tabs::-webkit-scrollbar {\n height: var(--mds-tab-scroll-scrollbar-size);\n width: var(--mds-tab-scroll-scrollbar-size);\n}\n\n:host([scrollbar]:not([scrollbar=\"false\"])) .tabs::-webkit-scrollbar-track {\n background-color: var(--mds-tab-scroll-scrollbar-track-background);\n border-radius: var(--mds-tab-scroll-scrollbar-radius);\n margin-block: var(--mds-tab-scroll-scrollbar-margin);\n margin-inline: var(--mds-tab-scroll-scrollbar-margin);\n}\n\n:host([scrollbar]:not([scrollbar=\"false\"])) .tabs::-webkit-scrollbar-thumb {\n background-color: var(--mds-tab-scroll-scrollbar-thumb-background);\n border-radius: var(--mds-tab-scroll-scrollbar-radius);\n}\n\n@supports (scrollbar-color: transparent transparent) {\n .tabs {\n scrollbar-color: var(--mds-tab-scroll-scrollbar-thumb-background) var(--mds-tab-scroll-scrollbar-track-background);\n scrollbar-width: thin;\n }\n}\n\n@tailwind utilities;\n\n@container style(--magma-pref-animation: reduce) {\n :host {\n\n --mds-tab-duration: 0s;\n\n -webkit-transition-duration: 0s;\n\n transition-duration: 0s;\n }\n\n .contents,\n .tabs {\n -webkit-transition-duration: 0s;\n transition-duration: 0s;\n }\n}\n\n@container style(--magma-pref-animation: system) {\n\n @media (prefers-reduced-motion) {\n :host {\n\n --mds-tab-duration: 0s;\n\n -webkit-transition-duration: 0s;\n\n transition-duration: 0s;\n }\n \n .contents,\n .tabs {\n -webkit-transition-duration: 0s;\n transition-duration: 0s;\n }\n }\n}\n\n@tailwind utilities;\n\n@container style(--magma-pref-theme: dark) {\n .tabs {\n border-color: rgb(var(--tone-neutral-08));\n }\n}\n\n@container style(--magma-pref-theme: system) {\n\n @media (prefers-color-scheme: dark) {\n .tabs {\n border-color: rgb(var(--tone-neutral-08));\n }\n }\n}\n\n@container style(--magma-pref-contrast: more) {\n .tabs {\n border-color: rgb(var(--tone-neutral-06));\n }\n}\n\n@container style(--magma-pref-contrast: system) {\n\n @media (prefers-contrast: more) {\n .tabs {\n border-color: rgb(var(--tone-neutral-06));\n }\n }\n}\n\n\n";
|
|
8
17
|
const MdsTabStyle0 = mdsTabCss;
|
|
9
18
|
|
|
10
19
|
const MdsTab = class {
|
|
@@ -13,31 +22,19 @@ const MdsTab = class {
|
|
|
13
22
|
this.changedEvent = index.createEvent(this, "mdsTabChange", 7);
|
|
14
23
|
this.currentItem = -1;
|
|
15
24
|
this.queryContentItems = () => this.element.querySelectorAll('[slot=content]');
|
|
16
|
-
this.scrollTabs = () => {
|
|
17
|
-
const tabItem = this.tabItems[
|
|
25
|
+
this.scrollTabs = (key) => {
|
|
26
|
+
const tabItem = this.tabItems[key];
|
|
18
27
|
this.tabs.scrollLeft = tabItem.offsetLeft - this.tabs.offsetLeft - (this.tabs.offsetWidth / 2) + (tabItem.offsetWidth / 2);
|
|
19
28
|
};
|
|
20
|
-
this.selectTabItem = (scrollItem) => {
|
|
21
|
-
this.tabItems.forEach((item, key) => {
|
|
22
|
-
if (key === scrollItem) {
|
|
23
|
-
item.selected = true;
|
|
24
|
-
this.changedEvent.emit({ id: key, value: item.value });
|
|
25
|
-
this.currentItem = key;
|
|
26
|
-
this.scrollTabs();
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
item.selected = false;
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
29
|
this.selectContentItem = () => {
|
|
34
30
|
this.contentItems.forEach((item, index) => {
|
|
35
|
-
item.
|
|
31
|
+
item.setAttribute('mds-tab-content-hidden', '');
|
|
36
32
|
if (index === this.currentItem) {
|
|
37
|
-
item.
|
|
33
|
+
item.removeAttribute('mds-tab-content-hidden');
|
|
38
34
|
}
|
|
39
35
|
});
|
|
40
36
|
};
|
|
37
|
+
this.scrollbar = undefined;
|
|
41
38
|
}
|
|
42
39
|
componentWillLoad() {
|
|
43
40
|
this.tabItems = this.element.querySelectorAll('mds-tab-item');
|
|
@@ -54,6 +51,9 @@ const MdsTab = class {
|
|
|
54
51
|
var _a;
|
|
55
52
|
this.tabs = (_a = this.element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.tabs');
|
|
56
53
|
this.contentItems = this.queryContentItems();
|
|
54
|
+
this.contentItems.forEach((item) => {
|
|
55
|
+
setAttributeIfEmpty(item, 'role', 'tabpanel');
|
|
56
|
+
});
|
|
57
57
|
this.selectContentItem();
|
|
58
58
|
}
|
|
59
59
|
changeEventHandler(event) {
|
|
@@ -61,7 +61,10 @@ const MdsTab = class {
|
|
|
61
61
|
// we must find the key from event.detail
|
|
62
62
|
this.tabItems.forEach((item, key) => {
|
|
63
63
|
if (item.id === event.detail.target.id) {
|
|
64
|
-
|
|
64
|
+
item.selected = true;
|
|
65
|
+
this.changedEvent.emit({ id: key, value: item.value });
|
|
66
|
+
this.currentItem = key;
|
|
67
|
+
this.scrollTabs(key);
|
|
65
68
|
}
|
|
66
69
|
else {
|
|
67
70
|
item.selected = false;
|
|
@@ -69,8 +72,15 @@ const MdsTab = class {
|
|
|
69
72
|
});
|
|
70
73
|
this.selectContentItem();
|
|
71
74
|
}
|
|
75
|
+
focusEventHandler(event) {
|
|
76
|
+
this.tabItems.forEach((item, key) => {
|
|
77
|
+
if (item.id === event.detail.target.id) {
|
|
78
|
+
this.scrollTabs(key);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
72
82
|
render() {
|
|
73
|
-
return (index.h(index.Host, { key: '
|
|
83
|
+
return (index.h(index.Host, { key: 'c1d8f059b1728fc43b00fa981c71f8c8d921db41' }, index.h("div", { key: '207c442cca5a2044064dbbff0f66169fae810a14', class: "tabs", part: "tabs", role: "tablist" }, index.h("slot", { key: '156989b7e0c0d31a58240d6851e4f6181227e7d5' })), index.h("div", { key: 'ef1ccd815767b98f6ceedacb23b49abbcb181930', class: "contents", part: "contents" }, index.h("slot", { key: '9ebe3581dd533a45a7e2f6f2501a8fa39537e2fc', name: "content" }))));
|
|
74
84
|
}
|
|
75
85
|
get element() { return index.getElement(this); }
|
|
76
86
|
};
|
package/dist/cjs/mds-tab.cjs.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
5
|
+
const index = require('./index-7cc6e10e.js');
|
|
6
6
|
const appGlobals = require('./app-globals-3a1e7e63.js');
|
|
7
7
|
|
|
8
8
|
/*
|
|
9
|
-
Stencil Client Patch Browser v4.
|
|
9
|
+
Stencil Client Patch Browser v4.22.2 | MIT Licensed | https://stenciljs.com
|
|
10
10
|
*/
|
|
11
11
|
var patchBrowser = () => {
|
|
12
12
|
const importMeta = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('mds-tab.cjs.js', document.baseURI).href));
|
|
@@ -19,7 +19,7 @@ var patchBrowser = () => {
|
|
|
19
19
|
|
|
20
20
|
patchBrowser().then(async (options) => {
|
|
21
21
|
await appGlobals.globalScripts();
|
|
22
|
-
return index.bootstrapLazy([["mds-tab.cjs",[[1,"mds-tab",
|
|
22
|
+
return index.bootstrapLazy([["mds-tab.cjs",[[1,"mds-tab",{"scrollbar":[516]},[[0,"mdsTabItemSelect","changeEventHandler"],[0,"mdsTabItemFocus","focusEventHandler"]]]]]], options);
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
exports.setNonce = index.setNonce;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// ISO 8601 date regex allowing optional components (month, day, time)
|
|
2
|
+
const ISO8601RegexString = '^\\d{4}(-\\d{2})?(-\\d{2})?(T\\d{2}(:\\d{2})?(:\\d{2})?(\\.\\d{3})?)?([+-]\\d{2}:\\d{2}|Z)?$';
|
|
3
|
+
const isISO8601Date = (dateString) => {
|
|
4
|
+
const ISO8601Regex = new RegExp(ISO8601RegexString);
|
|
5
|
+
return ISO8601Regex.test(dateString);
|
|
6
|
+
};
|
|
7
|
+
const sanitizeISO8601Date = (dateString) => {
|
|
8
|
+
if (isISO8601Date(dateString)) {
|
|
9
|
+
return dateString;
|
|
10
|
+
}
|
|
11
|
+
return new Date(dateString).toISOString();
|
|
12
|
+
};
|
|
13
|
+
export { sanitizeISO8601Date, isISO8601Date, };
|
|
@@ -1,16 +1,33 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { render } from "mustache";
|
|
2
2
|
export class Locale {
|
|
3
3
|
constructor(configData) {
|
|
4
4
|
this.rollbackLanguage = 'en';
|
|
5
|
-
this.
|
|
6
|
-
this.
|
|
5
|
+
this.set = (configData) => {
|
|
6
|
+
this.config = configData;
|
|
7
|
+
};
|
|
8
|
+
this.lang = (el) => {
|
|
9
|
+
this.element = el;
|
|
10
|
+
this.closestElement = this.element.closest('[lang]');
|
|
7
11
|
if (this.closestElement) {
|
|
8
12
|
if (this.closestElement.lang) {
|
|
9
13
|
this.language = this.closestElement.lang;
|
|
10
|
-
return;
|
|
14
|
+
return this.language;
|
|
11
15
|
}
|
|
12
16
|
}
|
|
13
17
|
this.language = this.rollbackLanguage;
|
|
18
|
+
return this.language;
|
|
19
|
+
};
|
|
20
|
+
this.update = (doc) => {
|
|
21
|
+
const context = doc !== null && doc !== void 0 ? doc : this.element.shadowRoot;
|
|
22
|
+
context && context.querySelectorAll('*').forEach(el => {
|
|
23
|
+
if (el.tagName.toLowerCase().startsWith('mds-')) {
|
|
24
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
25
|
+
if (el && 'updateLang' in el) {
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
|
+
el.updateLang();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
14
31
|
};
|
|
15
32
|
this.pluralize = (tag, context) => {
|
|
16
33
|
const languagePhrase = this.config[this.language] ? this.config[this.language][tag] : this.config[this.rollbackLanguage][tag];
|
|
@@ -34,8 +51,7 @@ export class Locale {
|
|
|
34
51
|
}
|
|
35
52
|
}
|
|
36
53
|
}
|
|
37
|
-
|
|
38
|
-
return template(context);
|
|
54
|
+
return render(translatePhrase, context);
|
|
39
55
|
};
|
|
40
56
|
this.get = (tag, context) => {
|
|
41
57
|
if (context) {
|
|
@@ -43,6 +59,8 @@ export class Locale {
|
|
|
43
59
|
}
|
|
44
60
|
return this.config[this.language] ? this.config[this.language][tag] : this.config[this.rollbackLanguage][tag];
|
|
45
61
|
};
|
|
46
|
-
|
|
62
|
+
if (configData) {
|
|
63
|
+
this.set(configData);
|
|
64
|
+
}
|
|
47
65
|
}
|
|
48
66
|
}
|