@ppg_pl/pallete 0.0.2 → 0.0.4

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.
Files changed (98) hide show
  1. package/README.md +11 -0
  2. package/dist/pallete/app-globals-0f993ce5.js +3 -0
  3. package/dist/pallete/css-shim-60f618b9.js +4 -0
  4. package/dist/pallete/dom-4eeb3fee.js +73 -0
  5. package/dist/pallete/index-1ac7471e.js +3059 -0
  6. package/dist/pallete/index.esm.js +1 -0
  7. package/dist/pallete/my-backdrop.entry.js +15 -0
  8. package/dist/pallete/my-colorbox.entry.js +40 -0
  9. package/dist/{components/my-colorinfo2.js → pallete/my-colorinfo.entry.js} +7 -35
  10. package/dist/{components/my-component.js → pallete/my-component.entry.js} +10 -72
  11. package/dist/pallete/my-loader.entry.js +15 -0
  12. package/dist/{components/my-modal2.js → pallete/my-modal.entry.js} +84 -76
  13. package/dist/pallete/my-search.entry.js +36 -0
  14. package/dist/pallete/my-slider.entry.js +11333 -0
  15. package/dist/pallete/pallete.css +3 -1
  16. package/dist/pallete/pallete.esm.js +129 -1
  17. package/dist/pallete/shadow-css-02866686.js +387 -0
  18. package/package.json +1 -1
  19. package/www/build/app-globals-0f993ce5.js +3 -0
  20. package/www/build/css-shim-60f618b9.js +4 -0
  21. package/www/build/dom-4eeb3fee.js +73 -0
  22. package/www/build/gtmUtils-dcdac4ce.js +5 -0
  23. package/www/build/index-1ac7471e.js +3059 -0
  24. package/www/build/index.esm.js +1 -0
  25. package/www/build/my-backdrop.entry.js +15 -0
  26. package/www/build/my-colorbox.entry.js +40 -0
  27. package/www/build/my-colorinfo.entry.js +36 -0
  28. package/www/build/my-component.entry.js +154 -0
  29. package/www/build/my-loader.entry.js +15 -0
  30. package/www/build/my-modal.entry.js +2459 -0
  31. package/www/build/my-search.entry.js +36 -0
  32. package/www/build/my-slider.entry.js +11333 -0
  33. package/www/build/pallete.css +3 -1
  34. package/www/build/pallete.esm.js +129 -1
  35. package/www/build/shadow-css-02866686.js +387 -0
  36. package/www/index.html +40 -2
  37. package/dist/cjs/index-029079e0.js +0 -1365
  38. package/dist/cjs/index.cjs.js +0 -2
  39. package/dist/cjs/loader.cjs.js +0 -21
  40. package/dist/cjs/my-backdrop_8.cjs.entry.js +0 -8109
  41. package/dist/cjs/pallete.cjs.js +0 -19
  42. package/dist/collection/collection-manifest.json +0 -19
  43. package/dist/collection/components/api/index.js +0 -19
  44. package/dist/collection/components/api/services.js +0 -81
  45. package/dist/collection/components/my-backdrop/my-backdrop.css +0 -21
  46. package/dist/collection/components/my-backdrop/my-backdrop.js +0 -13
  47. package/dist/collection/components/my-colorbox/my-colorbox.css +0 -60
  48. package/dist/collection/components/my-colorbox/my-colorbox.js +0 -145
  49. package/dist/collection/components/my-colorinfo/my-colorinfo.js +0 -197
  50. package/dist/collection/components/my-component/my-component.css +0 -6
  51. package/dist/collection/components/my-component/my-component.js +0 -107
  52. package/dist/collection/components/my-loader/my-loader.css +0 -85
  53. package/dist/collection/components/my-loader/my-loader.js +0 -18
  54. package/dist/collection/components/my-modal/assets/arrow_down.png +0 -0
  55. package/dist/collection/components/my-modal/assets/close.png +0 -0
  56. package/dist/collection/components/my-modal/my-modal.css +0 -323
  57. package/dist/collection/components/my-modal/my-modal.js +0 -430
  58. package/dist/collection/components/my-search/assets/search.svg +0 -15
  59. package/dist/collection/components/my-search/my-search.css +0 -43
  60. package/dist/collection/components/my-search/my-search.js +0 -113
  61. package/dist/collection/components/my-slider/index.js +0 -145
  62. package/dist/collection/components/my-slider/my-slider.css +0 -96
  63. package/dist/collection/gtmUtils.js +0 -3
  64. package/dist/collection/index.js +0 -1
  65. package/dist/collection/types.js +0 -1
  66. package/dist/components/index.js +0 -9
  67. package/dist/components/index2.js +0 -5458
  68. package/dist/components/my-backdrop.js +0 -6
  69. package/dist/components/my-backdrop2.js +0 -29
  70. package/dist/components/my-colorbox.js +0 -6
  71. package/dist/components/my-colorbox2.js +0 -61
  72. package/dist/components/my-colorinfo.js +0 -6
  73. package/dist/components/my-loader.js +0 -6
  74. package/dist/components/my-loader2.js +0 -29
  75. package/dist/components/my-modal.js +0 -6
  76. package/dist/components/my-search.js +0 -6
  77. package/dist/components/my-search2.js +0 -55
  78. package/dist/components/my-slider.js +0 -6
  79. package/dist/esm/index-faf4241e.js +0 -1337
  80. package/dist/esm/index.js +0 -1
  81. package/dist/esm/loader.js +0 -17
  82. package/dist/esm/my-backdrop_8.entry.js +0 -8098
  83. package/dist/esm/pallete.js +0 -17
  84. package/dist/esm/polyfills/core-js.js +0 -11
  85. package/dist/esm/polyfills/css-shim.js +0 -1
  86. package/dist/esm/polyfills/dom.js +0 -79
  87. package/dist/esm/polyfills/es5-html-element.js +0 -1
  88. package/dist/esm/polyfills/index.js +0 -34
  89. package/dist/esm/polyfills/system.js +0 -6
  90. package/dist/index.cjs.js +0 -1
  91. package/dist/index.js +0 -1
  92. package/dist/pallete/p-562ae52f.js +0 -2
  93. package/dist/pallete/p-e260bfb9.entry.js +0 -1
  94. package/www/build/p-562ae52f.js +0 -2
  95. package/www/build/p-b6a676fa.css +0 -11
  96. package/www/build/p-e260bfb9.entry.js +0 -1
  97. package/www/build/p-ef55983a.js +0 -129
  98. /package/dist/{components/gtmUtils.js → pallete/gtmUtils-dcdac4ce.js} +0 -0
@@ -1 +1,3 @@
1
- html{font-size:62.5%}body{font-size:1.5rem}*{font-family:"Galatea", sans-serif}
1
+ .pallete-wrapper * {
2
+ font-family: "Galatea", sans-serif;
3
+ }
@@ -1 +1,129 @@
1
- import{p as o,b as e}from"./p-562ae52f.js";(()=>{const e=import.meta.url,r={};return""!==e&&(r.resourcesUrl=new URL(".",e).href),o(r)})().then((o=>e([["p-e260bfb9",[[2,"my-component",{shop:[1],product:[1],show:[32],open:[64]},[[0,"close","closeModalHandler"]]],[0,"my-modal",{shop:[1],product:[1],closeImage:[1,"close-image"],arrowDown:[1,"arrow-down"],chunksNum:[32],data:[32],preloader:[32],loading:[32],colors:[32],currentColor:[32],currentIndex:[32],infoBoxWidth:[32],boxWidth:[32],padding:[32],isMobile:[32],showRange:[32],colorCategories:[32],selectedCategory:[32],page:[32],open:[64]},[[0,"closeInfoBox","closeInfoBoxHandler"],[9,"resize","handleResize"],[0,"searchColors","searchColorsHandler"]]],[0,"my-backdrop"],[0,"my-colorinfo",{currentColor:[16],shop:[1],product:[1],data:[16],isMobile:[4,"is-mobile"],infoBoxWidth:[2,"info-box-width"],closeImage:[1,"close-image"]}],[0,"my-colorbox",{color:[1],name:[1],shop:[1],product:[1],isActive:[4,"is-active"],isCategoryActive:[4,"is-category-active"]}],[0,"my-loader"],[2,"my-search",{productId:[2,"product-id"],isMobile:[4,"is-mobile"],searchIcon:[1,"search-icon"],searchText:[32]}],[0,"my-slider",{slides:[16],shop:[1],product:[1],color:[1]}]]]],o)));
1
+ import { B as BUILD, c as consoleDevInfo, p as plt, w as win, H, d as doc, N as NAMESPACE, a as promiseResolve, b as bootstrapLazy } from './index-1ac7471e.js';
2
+ import { g as globalScripts } from './app-globals-0f993ce5.js';
3
+
4
+ /*
5
+ Stencil Client Patch Browser v2.17.0 | MIT Licensed | https://stenciljs.com
6
+ */
7
+ const getDynamicImportFunction = (namespace) => `__sc_import_${namespace.replace(/\s|-/g, '_')}`;
8
+ const patchBrowser = () => {
9
+ // NOTE!! This fn cannot use async/await!
10
+ if (BUILD.isDev && !BUILD.isTesting) {
11
+ consoleDevInfo('Running in development mode.');
12
+ }
13
+ if (BUILD.cssVarShim) {
14
+ // shim css vars
15
+ plt.$cssShim$ = win.__cssshim;
16
+ }
17
+ if (BUILD.cloneNodeFix) {
18
+ // opted-in to polyfill cloneNode() for slot polyfilled components
19
+ patchCloneNodeFix(H.prototype);
20
+ }
21
+ if (BUILD.profile && !performance.mark) {
22
+ // not all browsers support performance.mark/measure (Safari 10)
23
+ // because the mark/measure APIs are designed to write entries to a buffer in the browser that does not exist,
24
+ // simply stub the implementations out.
25
+ // TODO(STENCIL-323): Remove this patch when support for older browsers is removed (breaking)
26
+ // @ts-ignore
27
+ performance.mark = performance.measure = () => {
28
+ /*noop*/
29
+ };
30
+ performance.getEntriesByName = () => [];
31
+ }
32
+ // @ts-ignore
33
+ const scriptElm = BUILD.scriptDataOpts || BUILD.safari10 || BUILD.dynamicImportShim
34
+ ? Array.from(doc.querySelectorAll('script')).find((s) => new RegExp(`\/${NAMESPACE}(\\.esm)?\\.js($|\\?|#)`).test(s.src) ||
35
+ s.getAttribute('data-stencil-namespace') === NAMESPACE)
36
+ : null;
37
+ const importMeta = import.meta.url;
38
+ const opts = BUILD.scriptDataOpts ? scriptElm['data-opts'] || {} : {};
39
+ if (BUILD.safari10 && 'onbeforeload' in scriptElm && !history.scrollRestoration /* IS_ESM_BUILD */) {
40
+ // Safari < v11 support: This IF is true if it's Safari below v11.
41
+ // This fn cannot use async/await since Safari didn't support it until v11,
42
+ // however, Safari 10 did support modules. Safari 10 also didn't support "nomodule",
43
+ // so both the ESM file and nomodule file would get downloaded. Only Safari
44
+ // has 'onbeforeload' in the script, and "history.scrollRestoration" was added
45
+ // to Safari in v11. Return a noop then() so the async/await ESM code doesn't continue.
46
+ // IS_ESM_BUILD is replaced at build time so this check doesn't happen in systemjs builds.
47
+ return {
48
+ then() {
49
+ /* promise noop */
50
+ },
51
+ };
52
+ }
53
+ if (!BUILD.safari10 && importMeta !== '') {
54
+ opts.resourcesUrl = new URL('.', importMeta).href;
55
+ }
56
+ else if (BUILD.dynamicImportShim || BUILD.safari10) {
57
+ opts.resourcesUrl = new URL('.', new URL(scriptElm.getAttribute('data-resources-url') || scriptElm.src, win.location.href)).href;
58
+ if (BUILD.dynamicImportShim) {
59
+ patchDynamicImport(opts.resourcesUrl, scriptElm);
60
+ }
61
+ if (BUILD.dynamicImportShim && !win.customElements) {
62
+ // module support, but no custom elements support (Old Edge)
63
+ // @ts-ignore
64
+ return import(/* webpackChunkName: "polyfills-dom" */ './dom-4eeb3fee.js').then(() => opts);
65
+ }
66
+ }
67
+ return promiseResolve(opts);
68
+ };
69
+ const patchDynamicImport = (base, orgScriptElm) => {
70
+ const importFunctionName = getDynamicImportFunction(NAMESPACE);
71
+ try {
72
+ // test if this browser supports dynamic imports
73
+ // There is a caching issue in V8, that breaks using import() in Function
74
+ // By generating a random string, we can workaround it
75
+ // Check https://bugs.chromium.org/p/chromium/issues/detail?id=990810 for more info
76
+ win[importFunctionName] = new Function('w', `return import(w);//${Math.random()}`);
77
+ }
78
+ catch (e) {
79
+ // this shim is specifically for browsers that do support "esm" imports
80
+ // however, they do NOT support "dynamic" imports
81
+ // basically this code is for old Edge, v18 and below
82
+ const moduleMap = new Map();
83
+ win[importFunctionName] = (src) => {
84
+ const url = new URL(src, base).href;
85
+ let mod = moduleMap.get(url);
86
+ if (!mod) {
87
+ const script = doc.createElement('script');
88
+ script.type = 'module';
89
+ script.crossOrigin = orgScriptElm.crossOrigin;
90
+ script.src = URL.createObjectURL(new Blob([`import * as m from '${url}'; window.${importFunctionName}.m = m;`], {
91
+ type: 'application/javascript',
92
+ }));
93
+ mod = new Promise((resolve) => {
94
+ script.onload = () => {
95
+ resolve(win[importFunctionName].m);
96
+ script.remove();
97
+ };
98
+ });
99
+ moduleMap.set(url, mod);
100
+ doc.head.appendChild(script);
101
+ }
102
+ return mod;
103
+ };
104
+ }
105
+ };
106
+ const patchCloneNodeFix = (HTMLElementPrototype) => {
107
+ const nativeCloneNodeFn = HTMLElementPrototype.cloneNode;
108
+ HTMLElementPrototype.cloneNode = function (deep) {
109
+ if (this.nodeName === 'TEMPLATE') {
110
+ return nativeCloneNodeFn.call(this, deep);
111
+ }
112
+ const clonedNode = nativeCloneNodeFn.call(this, false);
113
+ const srcChildNodes = this.childNodes;
114
+ if (deep) {
115
+ for (let i = 0; i < srcChildNodes.length; i++) {
116
+ // Node.ATTRIBUTE_NODE === 2, and checking because IE11
117
+ if (srcChildNodes[i].nodeType !== 2) {
118
+ clonedNode.appendChild(srcChildNodes[i].cloneNode(true));
119
+ }
120
+ }
121
+ }
122
+ return clonedNode;
123
+ };
124
+ };
125
+
126
+ patchBrowser().then(options => {
127
+ globalScripts();
128
+ return bootstrapLazy([["my-colorinfo",[[0,"my-colorinfo",{"currentColor":[16],"shop":[1],"product":[1],"data":[16],"isMobile":[4,"is-mobile"],"infoBoxWidth":[2,"info-box-width"],"closeImage":[1,"close-image"]}]]],["my-colorbox",[[0,"my-colorbox",{"color":[1],"name":[1],"shop":[1],"product":[1],"isActive":[4,"is-active"],"isCategoryActive":[4,"is-category-active"]}]]],["my-loader",[[2,"my-loader"]]],["my-search",[[2,"my-search",{"productId":[2,"product-id"],"isMobile":[4,"is-mobile"],"searchIcon":[1,"search-icon"],"searchText":[32]}]]],["my-modal",[[0,"my-modal",{"shop":[1],"product":[1],"closeImage":[1,"close-image"],"arrowDown":[1,"arrow-down"],"chunksNum":[32],"data":[32],"preloader":[32],"loading":[32],"colors":[32],"currentColor":[32],"currentIndex":[32],"infoBoxWidth":[32],"boxWidth":[32],"padding":[32],"isMobile":[32],"showRange":[32],"colorCategories":[32],"selectedCategory":[32],"page":[32],"open":[64]},[[0,"closeInfoBox","closeInfoBoxHandler"],[9,"resize","handleResize"],[0,"searchColors","searchColorsHandler"]]]]],["my-backdrop",[[0,"my-backdrop"]]],["my-slider",[[0,"my-slider",{"slides":[16],"shop":[1],"product":[1],"color":[1]}]]],["my-component",[[2,"my-component",{"shop":[1],"product":[1],"show":[32],"open":[64]},[[0,"close","closeModalHandler"]]]]]], options);
129
+ });
@@ -0,0 +1,387 @@
1
+ /*
2
+ Stencil Client Platform v2.17.0 | MIT Licensed | https://stenciljs.com
3
+ */
4
+ /**
5
+ * @license
6
+ * Copyright Google Inc. All Rights Reserved.
7
+ *
8
+ * Use of this source code is governed by an MIT-style license that can be
9
+ * found in the LICENSE file at https://angular.io/license
10
+ *
11
+ * This file is a port of shadowCSS from webcomponents.js to TypeScript.
12
+ * https://github.com/webcomponents/webcomponentsjs/blob/4efecd7e0e/src/ShadowCSS/ShadowCSS.js
13
+ * https://github.com/angular/angular/blob/master/packages/compiler/src/shadow_css.ts
14
+ */
15
+ const safeSelector = (selector) => {
16
+ const placeholders = [];
17
+ let index = 0;
18
+ // Replaces attribute selectors with placeholders.
19
+ // The WS in [attr="va lue"] would otherwise be interpreted as a selector separator.
20
+ selector = selector.replace(/(\[[^\]]*\])/g, (_, keep) => {
21
+ const replaceBy = `__ph-${index}__`;
22
+ placeholders.push(keep);
23
+ index++;
24
+ return replaceBy;
25
+ });
26
+ // Replaces the expression in `:nth-child(2n + 1)` with a placeholder.
27
+ // WS and "+" would otherwise be interpreted as selector separators.
28
+ const content = selector.replace(/(:nth-[-\w]+)(\([^)]+\))/g, (_, pseudo, exp) => {
29
+ const replaceBy = `__ph-${index}__`;
30
+ placeholders.push(exp);
31
+ index++;
32
+ return pseudo + replaceBy;
33
+ });
34
+ const ss = {
35
+ content,
36
+ placeholders,
37
+ };
38
+ return ss;
39
+ };
40
+ const restoreSafeSelector = (placeholders, content) => {
41
+ return content.replace(/__ph-(\d+)__/g, (_, index) => placeholders[+index]);
42
+ };
43
+ const _polyfillHost = '-shadowcsshost';
44
+ const _polyfillSlotted = '-shadowcssslotted';
45
+ // note: :host-context pre-processed to -shadowcsshostcontext.
46
+ const _polyfillHostContext = '-shadowcsscontext';
47
+ const _parenSuffix = ')(?:\\((' + '(?:\\([^)(]*\\)|[^)(]*)+?' + ')\\))?([^,{]*)';
48
+ const _cssColonHostRe = new RegExp('(' + _polyfillHost + _parenSuffix, 'gim');
49
+ const _cssColonHostContextRe = new RegExp('(' + _polyfillHostContext + _parenSuffix, 'gim');
50
+ const _cssColonSlottedRe = new RegExp('(' + _polyfillSlotted + _parenSuffix, 'gim');
51
+ const _polyfillHostNoCombinator = _polyfillHost + '-no-combinator';
52
+ const _polyfillHostNoCombinatorRe = /-shadowcsshost-no-combinator([^\s]*)/;
53
+ const _shadowDOMSelectorsRe = [/::shadow/g, /::content/g];
54
+ const _selectorReSuffix = '([>\\s~+[.,{:][\\s\\S]*)?$';
55
+ const _polyfillHostRe = /-shadowcsshost/gim;
56
+ const _colonHostRe = /:host/gim;
57
+ const _colonSlottedRe = /::slotted/gim;
58
+ const _colonHostContextRe = /:host-context/gim;
59
+ const _commentRe = /\/\*\s*[\s\S]*?\*\//g;
60
+ const stripComments = (input) => {
61
+ return input.replace(_commentRe, '');
62
+ };
63
+ const _commentWithHashRe = /\/\*\s*#\s*source(Mapping)?URL=[\s\S]+?\*\//g;
64
+ const extractCommentsWithHash = (input) => {
65
+ return input.match(_commentWithHashRe) || [];
66
+ };
67
+ const _ruleRe = /(\s*)([^;\{\}]+?)(\s*)((?:{%BLOCK%}?\s*;?)|(?:\s*;))/g;
68
+ const _curlyRe = /([{}])/g;
69
+ const _selectorPartsRe = /(^.*?[^\\])??((:+)(.*)|$)/;
70
+ const OPEN_CURLY = '{';
71
+ const CLOSE_CURLY = '}';
72
+ const BLOCK_PLACEHOLDER = '%BLOCK%';
73
+ const processRules = (input, ruleCallback) => {
74
+ const inputWithEscapedBlocks = escapeBlocks(input);
75
+ let nextBlockIndex = 0;
76
+ return inputWithEscapedBlocks.escapedString.replace(_ruleRe, (...m) => {
77
+ const selector = m[2];
78
+ let content = '';
79
+ let suffix = m[4];
80
+ let contentPrefix = '';
81
+ if (suffix && suffix.startsWith('{' + BLOCK_PLACEHOLDER)) {
82
+ content = inputWithEscapedBlocks.blocks[nextBlockIndex++];
83
+ suffix = suffix.substring(BLOCK_PLACEHOLDER.length + 1);
84
+ contentPrefix = '{';
85
+ }
86
+ const cssRule = {
87
+ selector,
88
+ content,
89
+ };
90
+ const rule = ruleCallback(cssRule);
91
+ return `${m[1]}${rule.selector}${m[3]}${contentPrefix}${rule.content}${suffix}`;
92
+ });
93
+ };
94
+ const escapeBlocks = (input) => {
95
+ const inputParts = input.split(_curlyRe);
96
+ const resultParts = [];
97
+ const escapedBlocks = [];
98
+ let bracketCount = 0;
99
+ let currentBlockParts = [];
100
+ for (let partIndex = 0; partIndex < inputParts.length; partIndex++) {
101
+ const part = inputParts[partIndex];
102
+ if (part === CLOSE_CURLY) {
103
+ bracketCount--;
104
+ }
105
+ if (bracketCount > 0) {
106
+ currentBlockParts.push(part);
107
+ }
108
+ else {
109
+ if (currentBlockParts.length > 0) {
110
+ escapedBlocks.push(currentBlockParts.join(''));
111
+ resultParts.push(BLOCK_PLACEHOLDER);
112
+ currentBlockParts = [];
113
+ }
114
+ resultParts.push(part);
115
+ }
116
+ if (part === OPEN_CURLY) {
117
+ bracketCount++;
118
+ }
119
+ }
120
+ if (currentBlockParts.length > 0) {
121
+ escapedBlocks.push(currentBlockParts.join(''));
122
+ resultParts.push(BLOCK_PLACEHOLDER);
123
+ }
124
+ const strEscapedBlocks = {
125
+ escapedString: resultParts.join(''),
126
+ blocks: escapedBlocks,
127
+ };
128
+ return strEscapedBlocks;
129
+ };
130
+ const insertPolyfillHostInCssText = (selector) => {
131
+ selector = selector
132
+ .replace(_colonHostContextRe, _polyfillHostContext)
133
+ .replace(_colonHostRe, _polyfillHost)
134
+ .replace(_colonSlottedRe, _polyfillSlotted);
135
+ return selector;
136
+ };
137
+ const convertColonRule = (cssText, regExp, partReplacer) => {
138
+ // m[1] = :host(-context), m[2] = contents of (), m[3] rest of rule
139
+ return cssText.replace(regExp, (...m) => {
140
+ if (m[2]) {
141
+ const parts = m[2].split(',');
142
+ const r = [];
143
+ for (let i = 0; i < parts.length; i++) {
144
+ const p = parts[i].trim();
145
+ if (!p)
146
+ break;
147
+ r.push(partReplacer(_polyfillHostNoCombinator, p, m[3]));
148
+ }
149
+ return r.join(',');
150
+ }
151
+ else {
152
+ return _polyfillHostNoCombinator + m[3];
153
+ }
154
+ });
155
+ };
156
+ const colonHostPartReplacer = (host, part, suffix) => {
157
+ return host + part.replace(_polyfillHost, '') + suffix;
158
+ };
159
+ const convertColonHost = (cssText) => {
160
+ return convertColonRule(cssText, _cssColonHostRe, colonHostPartReplacer);
161
+ };
162
+ const colonHostContextPartReplacer = (host, part, suffix) => {
163
+ if (part.indexOf(_polyfillHost) > -1) {
164
+ return colonHostPartReplacer(host, part, suffix);
165
+ }
166
+ else {
167
+ return host + part + suffix + ', ' + part + ' ' + host + suffix;
168
+ }
169
+ };
170
+ const convertColonSlotted = (cssText, slotScopeId) => {
171
+ const slotClass = '.' + slotScopeId + ' > ';
172
+ const selectors = [];
173
+ cssText = cssText.replace(_cssColonSlottedRe, (...m) => {
174
+ if (m[2]) {
175
+ const compound = m[2].trim();
176
+ const suffix = m[3];
177
+ const slottedSelector = slotClass + compound + suffix;
178
+ let prefixSelector = '';
179
+ for (let i = m[4] - 1; i >= 0; i--) {
180
+ const char = m[5][i];
181
+ if (char === '}' || char === ',') {
182
+ break;
183
+ }
184
+ prefixSelector = char + prefixSelector;
185
+ }
186
+ const orgSelector = prefixSelector + slottedSelector;
187
+ const addedSelector = `${prefixSelector.trimRight()}${slottedSelector.trim()}`;
188
+ if (orgSelector.trim() !== addedSelector.trim()) {
189
+ const updatedSelector = `${addedSelector}, ${orgSelector}`;
190
+ selectors.push({
191
+ orgSelector,
192
+ updatedSelector,
193
+ });
194
+ }
195
+ return slottedSelector;
196
+ }
197
+ else {
198
+ return _polyfillHostNoCombinator + m[3];
199
+ }
200
+ });
201
+ return {
202
+ selectors,
203
+ cssText,
204
+ };
205
+ };
206
+ const convertColonHostContext = (cssText) => {
207
+ return convertColonRule(cssText, _cssColonHostContextRe, colonHostContextPartReplacer);
208
+ };
209
+ const convertShadowDOMSelectors = (cssText) => {
210
+ return _shadowDOMSelectorsRe.reduce((result, pattern) => result.replace(pattern, ' '), cssText);
211
+ };
212
+ const makeScopeMatcher = (scopeSelector) => {
213
+ const lre = /\[/g;
214
+ const rre = /\]/g;
215
+ scopeSelector = scopeSelector.replace(lre, '\\[').replace(rre, '\\]');
216
+ return new RegExp('^(' + scopeSelector + ')' + _selectorReSuffix, 'm');
217
+ };
218
+ const selectorNeedsScoping = (selector, scopeSelector) => {
219
+ const re = makeScopeMatcher(scopeSelector);
220
+ return !re.test(selector);
221
+ };
222
+ const injectScopingSelector = (selector, scopingSelector) => {
223
+ return selector.replace(_selectorPartsRe, (_, before = '', _colonGroup, colon = '', after = '') => {
224
+ return before + scopingSelector + colon + after;
225
+ });
226
+ };
227
+ const applySimpleSelectorScope = (selector, scopeSelector, hostSelector) => {
228
+ // In Android browser, the lastIndex is not reset when the regex is used in String.replace()
229
+ _polyfillHostRe.lastIndex = 0;
230
+ if (_polyfillHostRe.test(selector)) {
231
+ const replaceBy = `.${hostSelector}`;
232
+ return selector
233
+ .replace(_polyfillHostNoCombinatorRe, (_, selector) => injectScopingSelector(selector, replaceBy))
234
+ .replace(_polyfillHostRe, replaceBy + ' ');
235
+ }
236
+ return scopeSelector + ' ' + selector;
237
+ };
238
+ const applyStrictSelectorScope = (selector, scopeSelector, hostSelector) => {
239
+ const isRe = /\[is=([^\]]*)\]/g;
240
+ scopeSelector = scopeSelector.replace(isRe, (_, ...parts) => parts[0]);
241
+ const className = '.' + scopeSelector;
242
+ const _scopeSelectorPart = (p) => {
243
+ let scopedP = p.trim();
244
+ if (!scopedP) {
245
+ return '';
246
+ }
247
+ if (p.indexOf(_polyfillHostNoCombinator) > -1) {
248
+ scopedP = applySimpleSelectorScope(p, scopeSelector, hostSelector);
249
+ }
250
+ else {
251
+ // remove :host since it should be unnecessary
252
+ const t = p.replace(_polyfillHostRe, '');
253
+ if (t.length > 0) {
254
+ scopedP = injectScopingSelector(t, className);
255
+ }
256
+ }
257
+ return scopedP;
258
+ };
259
+ const safeContent = safeSelector(selector);
260
+ selector = safeContent.content;
261
+ let scopedSelector = '';
262
+ let startIndex = 0;
263
+ let res;
264
+ const sep = /( |>|\+|~(?!=))\s*/g;
265
+ // If a selector appears before :host it should not be shimmed as it
266
+ // matches on ancestor elements and not on elements in the host's shadow
267
+ // `:host-context(div)` is transformed to
268
+ // `-shadowcsshost-no-combinatordiv, div -shadowcsshost-no-combinator`
269
+ // the `div` is not part of the component in the 2nd selectors and should not be scoped.
270
+ // Historically `component-tag:host` was matching the component so we also want to preserve
271
+ // this behavior to avoid breaking legacy apps (it should not match).
272
+ // The behavior should be:
273
+ // - `tag:host` -> `tag[h]` (this is to avoid breaking legacy apps, should not match anything)
274
+ // - `tag :host` -> `tag [h]` (`tag` is not scoped because it's considered part of a
275
+ // `:host-context(tag)`)
276
+ const hasHost = selector.indexOf(_polyfillHostNoCombinator) > -1;
277
+ // Only scope parts after the first `-shadowcsshost-no-combinator` when it is present
278
+ let shouldScope = !hasHost;
279
+ while ((res = sep.exec(selector)) !== null) {
280
+ const separator = res[1];
281
+ const part = selector.slice(startIndex, res.index).trim();
282
+ shouldScope = shouldScope || part.indexOf(_polyfillHostNoCombinator) > -1;
283
+ const scopedPart = shouldScope ? _scopeSelectorPart(part) : part;
284
+ scopedSelector += `${scopedPart} ${separator} `;
285
+ startIndex = sep.lastIndex;
286
+ }
287
+ const part = selector.substring(startIndex);
288
+ shouldScope = shouldScope || part.indexOf(_polyfillHostNoCombinator) > -1;
289
+ scopedSelector += shouldScope ? _scopeSelectorPart(part) : part;
290
+ // replace the placeholders with their original values
291
+ return restoreSafeSelector(safeContent.placeholders, scopedSelector);
292
+ };
293
+ const scopeSelector = (selector, scopeSelectorText, hostSelector, slotSelector) => {
294
+ return selector
295
+ .split(',')
296
+ .map((shallowPart) => {
297
+ if (slotSelector && shallowPart.indexOf('.' + slotSelector) > -1) {
298
+ return shallowPart.trim();
299
+ }
300
+ if (selectorNeedsScoping(shallowPart, scopeSelectorText)) {
301
+ return applyStrictSelectorScope(shallowPart, scopeSelectorText, hostSelector).trim();
302
+ }
303
+ else {
304
+ return shallowPart.trim();
305
+ }
306
+ })
307
+ .join(', ');
308
+ };
309
+ const scopeSelectors = (cssText, scopeSelectorText, hostSelector, slotSelector, commentOriginalSelector) => {
310
+ return processRules(cssText, (rule) => {
311
+ let selector = rule.selector;
312
+ let content = rule.content;
313
+ if (rule.selector[0] !== '@') {
314
+ selector = scopeSelector(rule.selector, scopeSelectorText, hostSelector, slotSelector);
315
+ }
316
+ else if (rule.selector.startsWith('@media') ||
317
+ rule.selector.startsWith('@supports') ||
318
+ rule.selector.startsWith('@page') ||
319
+ rule.selector.startsWith('@document')) {
320
+ content = scopeSelectors(rule.content, scopeSelectorText, hostSelector, slotSelector);
321
+ }
322
+ const cssRule = {
323
+ selector: selector.replace(/\s{2,}/g, ' ').trim(),
324
+ content,
325
+ };
326
+ return cssRule;
327
+ });
328
+ };
329
+ const scopeCssText = (cssText, scopeId, hostScopeId, slotScopeId, commentOriginalSelector) => {
330
+ cssText = insertPolyfillHostInCssText(cssText);
331
+ cssText = convertColonHost(cssText);
332
+ cssText = convertColonHostContext(cssText);
333
+ const slotted = convertColonSlotted(cssText, slotScopeId);
334
+ cssText = slotted.cssText;
335
+ cssText = convertShadowDOMSelectors(cssText);
336
+ if (scopeId) {
337
+ cssText = scopeSelectors(cssText, scopeId, hostScopeId, slotScopeId);
338
+ }
339
+ cssText = cssText.replace(/-shadowcsshost-no-combinator/g, `.${hostScopeId}`);
340
+ cssText = cssText.replace(/>\s*\*\s+([^{, ]+)/gm, ' $1 ');
341
+ return {
342
+ cssText: cssText.trim(),
343
+ slottedSelectors: slotted.selectors,
344
+ };
345
+ };
346
+ const scopeCss = (cssText, scopeId, commentOriginalSelector) => {
347
+ const hostScopeId = scopeId + '-h';
348
+ const slotScopeId = scopeId + '-s';
349
+ const commentsWithHash = extractCommentsWithHash(cssText);
350
+ cssText = stripComments(cssText);
351
+ const orgSelectors = [];
352
+ if (commentOriginalSelector) {
353
+ const processCommentedSelector = (rule) => {
354
+ const placeholder = `/*!@___${orgSelectors.length}___*/`;
355
+ const comment = `/*!@${rule.selector}*/`;
356
+ orgSelectors.push({ placeholder, comment });
357
+ rule.selector = placeholder + rule.selector;
358
+ return rule;
359
+ };
360
+ cssText = processRules(cssText, (rule) => {
361
+ if (rule.selector[0] !== '@') {
362
+ return processCommentedSelector(rule);
363
+ }
364
+ else if (rule.selector.startsWith('@media') ||
365
+ rule.selector.startsWith('@supports') ||
366
+ rule.selector.startsWith('@page') ||
367
+ rule.selector.startsWith('@document')) {
368
+ rule.content = processRules(rule.content, processCommentedSelector);
369
+ return rule;
370
+ }
371
+ return rule;
372
+ });
373
+ }
374
+ const scoped = scopeCssText(cssText, scopeId, hostScopeId, slotScopeId);
375
+ cssText = [scoped.cssText, ...commentsWithHash].join('\n');
376
+ if (commentOriginalSelector) {
377
+ orgSelectors.forEach(({ placeholder, comment }) => {
378
+ cssText = cssText.replace(placeholder, comment);
379
+ });
380
+ }
381
+ scoped.slottedSelectors.forEach((slottedSelector) => {
382
+ cssText = cssText.replace(slottedSelector.orgSelector, slottedSelector.updatedSelector);
383
+ });
384
+ return cssText;
385
+ };
386
+
387
+ export { scopeCss };
package/www/index.html CHANGED
@@ -4,7 +4,36 @@
4
4
  url(./assets/fonts/Galatea-Regular.ttf) format('truetype'), url(./assets/fonts/Galatea-Regular.eot) format('embedded-opentype');
5
5
  font-weight: 400;
6
6
  font-style: normal;
7
- }</style> <link rel="modulepreload" href="/build/p-ef55983a.js"><script type="module" src="/build/p-ef55983a.js" data-stencil data-resources-url="/build/" data-stencil-namespace="pallete"></script> <script nomodule="" src="/build/pallete.js" data-stencil></script> </head> <body> <!-- shop="DEKORAL" product="Dekoral Łazienka & Kuchnia" --> <my-component class="modal_pallete"></my-component> <label for="shop">Shop</label> <input name="shop" type="shop"> <label for="product">Product</label><input name="product" type="product"> <button>open modal</button> <script>
7
+ }</style> <script type="module" src="/build/pallete.esm.js" data-stencil></script> <script nomodule="" src="/build/pallete.js" data-stencil></script> </head> <body> <div> Lorem ipsum dolor sit amet consectetur adipisicing elit. Enim ea sunt expedita, placeat distinctio quasi et deleniti ex aperiam, excepturi soluta voluptates eveniet impedit
8
+ corrupti a illum accusamus quo, consequuntur dignissimos aliquid. Quisquam voluptatem ipsam dolor non recusandae accusantium asperiores aliquam minus placeat, illum error
9
+ totam eum beatae atque commodi nisi quis veniam repellat culpa corrupti, impedit, dolore soluta? Mollitia iure vero nihil rerum aperiam, debitis enim illum magnam itaque ex
10
+ voluptas minus! Placeat adipisci beatae ex ab dolores dolore ratione, porro quasi itaque quos pariatur! Asperiores, sunt nemo recusandae incidunt aliquid nobis assumenda
11
+ ducimus dignissimos, amet, necessitatibus inventore at veniam tempore mollitia earum eligendi perspiciatis obcaecati. Mollitia, porro? Earum quaerat ad vitae? Dolore
12
+ voluptates officia corporis eos? Numquam qui sint itaque hic architecto a harum laborum quae doloremque earum, magni deleniti rerum illum sequi facilis fugit doloribus quo
13
+ iusto iure officia cumque minus ratione! Omnis facilis amet ipsam atque laudantium, nam debitis non, ducimus sint tempora, quae exercitationem ratione quasi nemo illo
14
+ recusandae! Minima reprehenderit odit, iure nisi quibusdam beatae molestiae ullam doloribus rerum, libero a amet ratione exercitationem cumque dolorem, inventore assumenda
15
+ error. Iste quod, aut consectetur vero ad voluptas voluptatibus molestias! Laudantium, dolore voluptas? Tempora, ratione veniam! </div> <!-- shop="DEKORAL" product="Dekoral Łazienka & Kuchnia" --> <my-component class="modal_pallete"></my-component> <label for="shop">Shop</label> <input name="shop" type="shop"> <label for="product">Product</label><input name="product" type="product"> <button>open modal</button> <div> Lorem ipsum dolor sit amet consectetur adipisicing elit. Eos quisquam repellendus culpa placeat cupiditate sequi. Cum ducimus soluta, iste culpa quis expedita fuga
16
+ dignissimos officia commodi eveniet laudantium ipsum, nobis asperiores beatae quae similique. Nulla nobis, exercitationem mollitia minus maxime commodi quas tempore, itaque
17
+ nam quidem ea excepturi reiciendis dolor temporibus, adipisci praesentium illo perspiciatis. Quibusdam modi adipisci, illo asperiores vel natus nihil ipsum earum minima
18
+ repellendus. Nam quam tempore aut voluptates, in doloremque officiis eius est. Voluptates facilis ex repellendus omnis officiis molestias nostrum quis reiciendis voluptate
19
+ quidem ullam quos, libero officia ducimus praesentium dicta vitae ea consequatur quam, nulla deserunt doloribus. Mollitia cum tenetur ea in ab nobis numquam suscipit
20
+ dignissimos cumque, totam velit obcaecati. Provident iste corrupti, culpa qui quibusdam illo commodi aliquam ea ipsum porro velit vel non expedita blanditiis temporibus, vero
21
+ quasi voluptatem ex aut dicta id iusto eos. Corporis nobis neque temporibus, ducimus dolorum laborum, suscipit, sed exercitationem perspiciatis facere nihil aspernatur? Sunt
22
+ hic optio maxime iusto, consequatur iure at voluptatum, sit voluptatibus quos facilis! In exercitationem quod nisi impedit quo quia neque earum assumenda nesciunt aliquam
23
+ suscipit id ipsa eaque repudiandae tempora, recusandae reprehenderit. Recusandae, cum enim, impedit, aliquid ex placeat modi ipsa quo eum eveniet blanditiis itaque.
24
+ Voluptatibus quo distinctio non voluptatum officiis voluptates tempora illo. Deserunt excepturi numquam non possimus, quos distinctio saepe velit quas tempora. Ipsa totam
25
+ magnam praesentium mollitia? Placeat distinctio dignissimos eius expedita nulla optio aliquam laudantium. Aliquid autem reprehenderit obcaecati eveniet animi soluta odio,
26
+ saepe ad quia iste accusamus doloremque quae nihil repellat quaerat dolore maiores fuga eligendi facilis aperiam nisi rerum! Architecto nesciunt iure, quo laboriosam qui
27
+ dolor voluptate velit cupiditate ullam ab esse, consequuntur alias aliquam voluptas soluta reiciendis quis libero, beatae iste. Veritatis doloremque totam, culpa nobis magni
28
+ at deserunt necessitatibus ab ea deleniti temporibus quidem aspernatur facere facilis eum debitis nisi vero libero nemo, minima quam! Suscipit debitis eos corporis! Excepturi
29
+ nesciunt ratione nostrum libero, quo consectetur nihil accusantium aliquid corporis voluptate eum doloribus, quaerat ea. Ducimus suscipit laborum molestias, excepturi dolor
30
+ expedita placeat. Accusantium eius iusto facilis suscipit distinctio quod? Beatae porro quasi magni impedit dolorum laudantium provident, eos quaerat sint ducimus, ipsam illo
31
+ nostrum, autem earum consequatur voluptas ad natus harum sapiente ea! Recusandae laboriosam assumenda non. Iste soluta, quod magni recusandae quas similique iure iusto amet
32
+ deserunt eaque quo quasi, temporibus, illo ex consectetur! Iure consequuntur, commodi officiis iste sed error velit provident dolorem! Aperiam adipisci, dolorum quis earum
33
+ distinctio porro veniam natus consectetur nam, ad, voluptate ducimus harum quam incidunt omnis dolor doloribus laboriosam tenetur culpa quia odio quae facilis! Sit nesciunt
34
+ qui, deserunt, necessitatibus cum porro velit similique eius doloribus iusto tempora quaerat distinctio consectetur obcaecati quo, dolorum non aperiam vel expedita
35
+ repudiandae neque! Maxime facere eum quasi amet facilis sapiente numquam quam explicabo! Fugit doloribus cum amet excepturi distinctio totam recusandae autem porro qui quia
36
+ eligendi eos beatae, quis possimus sint iure unde! Tempora ullam voluptas sapiente beatae nemo placeat, necessitatibus veritatis odit sint mollitia sequi reiciendis? </div> <div class="buy-tester-category power-section"> <div class="container"> <h2>Potrzebujesz więcej czasu na decyzję?</h2> <h3>Zamów wzornik Moc Koloru, porównuj kolory do woli i&nbsp;wybierz swój wymarzony odcień</h3> <h4>MOC KOLORU - wzornik kolorów</h4> <div class="power"> <img src="/wachlarz.png" alt="Moc koloru"> <div class="power-info"> <div class="quantity"> <input type="text" name="quantity" value="1" size="2" id="input-quantity" class="form-control"> <div class="plus"></div> <div class="minus"></div> </div> <div class="quantity-info"> <p><strong>Cena:</strong> <br>19,99 zł (z VAT)</p> </div> <input type="hidden" name="product_id" value="609"> <button type="button" id="button-cart" data-loading-text="Ładowanie..." class="btn btn-primary btn-lg btn-block btn-default" data-price="19.99" data-id="609" data-category="wzornik koloru" data-name="Moc Koloru"> <img src="/basket.svg" alt="dodaj do koszyka">Dodaj do koszyka </button> </div> </div> </div> </div> <div class="buy-tester-category power-section"> <div class="container"> <h2>Potrzebujesz więcej czasu na decyzję?</h2> <h3>Zamów wzornik Moc Koloru, porównuj kolory do woli i&nbsp;wybierz swój wymarzony odcień</h3> <h4>MOC KOLORU - wzornik kolorów</h4> <div class="power"> <img src="/wachlarz.png" alt="Moc koloru"> <div class="power-info"> <div class="quantity"> <input type="text" name="quantity" value="1" size="2" id="input-quantity" class="form-control"> <div class="plus"></div> <div class="minus"></div> </div> <div class="quantity-info"> <p><strong>Cena:</strong> <br>19,99 zł (z VAT)</p> </div> <input type="hidden" name="product_id" value="609"> <button type="button" id="button-cart" data-loading-text="Ładowanie..." class="btn btn-primary btn-lg btn-block btn-default" data-price="19.99" data-id="609" data-category="wzornik koloru" data-name="Moc Koloru"> <img src="/basket.svg" alt="dodaj do koszyka">Dodaj do koszyka </button> </div> </div> </div> </div> <div class="buy-tester-category power-section"> <div class="container"> <h2>Potrzebujesz więcej czasu na decyzję?</h2> <h3>Zamów wzornik Moc Koloru, porównuj kolory do woli i&nbsp;wybierz swój wymarzony odcień</h3> <h4>MOC KOLORU - wzornik kolorów</h4> <div class="power"> <img src="/wachlarz.png" alt="Moc koloru"> <div class="power-info"> <div class="quantity"> <input type="text" name="quantity" value="1" size="2" id="input-quantity" class="form-control"> <div class="plus"></div> <div class="minus"></div> </div> <div class="quantity-info"> <p><strong>Cena:</strong> <br>19,99 zł (z VAT)</p> </div> <input type="hidden" name="product_id" value="609"> <button type="button" id="button-cart" data-loading-text="Ładowanie..." class="btn btn-primary btn-lg btn-block btn-default" data-price="19.99" data-id="609" data-category="wzornik koloru" data-name="Moc Koloru"> <img src="/basket.svg" alt="dodaj do koszyka">Dodaj do koszyka </button> </div> </div> </div> </div> <div class="buy-tester-category power-section"> <div class="container"> <h2>Potrzebujesz więcej czasu na decyzję?</h2> <h3>Zamów wzornik Moc Koloru, porównuj kolory do woli i&nbsp;wybierz swój wymarzony odcień</h3> <h4>MOC KOLORU - wzornik kolorów</h4> <div class="power"> <img src="/wachlarz.png" alt="Moc koloru"> <div class="power-info"> <div class="quantity"> <input type="text" name="quantity" value="1" size="2" id="input-quantity" class="form-control"> <div class="plus"></div> <div class="minus"></div> </div> <div class="quantity-info"> <p><strong>Cena:</strong> <br>19,99 zł (z VAT)</p> </div> <input type="hidden" name="product_id" value="609"> <button type="button" id="button-cart" data-loading-text="Ładowanie..." class="btn btn-primary btn-lg btn-block btn-default" data-price="19.99" data-id="609" data-category="wzornik koloru" data-name="Moc Koloru"> <img src="/basket.svg" alt="dodaj do koszyka">Dodaj do koszyka </button> </div> </div> </div> </div> <script>
8
37
  const btn = document.querySelector('button');
9
38
  const modal = document.querySelector('.modal_pallete');
10
39
  const shop = document.querySelector('input[name="shop"]');
@@ -19,4 +48,13 @@
19
48
  modal.open();
20
49
  }
21
50
  });
22
- </script> </body></html>
51
+ </script> <script>
52
+ if ('serviceWorker' in navigator && location.protocol !== 'file:') {
53
+ // auto-unregister service worker during dev mode
54
+ navigator.serviceWorker.getRegistration().then(function(registration) {
55
+ if (registration) {
56
+ registration.unregister().then(function() { location.reload(true) });
57
+ }
58
+ });
59
+ }
60
+ </script></body></html>