@maggioli-design-system/mds-modal 3.1.0 → 3.2.1
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-90939077.js → index-d859a858.js} +217 -195
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/mds-modal.cjs.entry.js +34 -7
- package/dist/cjs/mds-modal.cjs.js +2 -2
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/common/aria.js +19 -0
- package/dist/collection/components/mds-modal/mds-modal.css +37 -67
- package/dist/collection/components/mds-modal/mds-modal.js +33 -6
- package/dist/collection/components/mds-modal/test/mds-modal.stories.js +8 -0
- package/dist/collection/dictionary/typography.js +3 -3
- package/dist/components/mds-modal.js +33 -6
- package/dist/esm/{index-5dfae565.js → index-a5a41aa8.js} +217 -195
- package/dist/esm/loader.js +2 -2
- package/dist/esm/mds-modal.entry.js +34 -7
- package/dist/esm/mds-modal.js +2 -2
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/esm-es5/index-a5a41aa8.js +2 -0
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/mds-modal.entry.js +1 -1
- package/dist/esm-es5/mds-modal.js +1 -1
- package/dist/mds-modal/mds-modal.esm.js +1 -1
- package/dist/mds-modal/mds-modal.js +1 -1
- package/dist/mds-modal/p-4fe02e5f.entry.js +1 -0
- package/dist/mds-modal/{p-4288d1a7.system.entry.js → p-52cd3b82.system.entry.js} +1 -1
- package/dist/mds-modal/p-76a04b9e.system.js +2 -0
- package/dist/mds-modal/p-931319fa.js +2 -0
- package/dist/mds-modal/{p-5935b9a5.system.js → p-a2cf985e.system.js} +1 -1
- package/dist/stats.json +36 -32
- package/dist/types/common/aria.d.ts +4 -0
- package/dist/types/components/mds-modal/test/mds-modal.stories.d.ts +1 -0
- package/dist/types/stencil-public-runtime.d.ts +20 -4
- package/dist/types/types/typography.d.ts +3 -3
- package/package.json +3 -3
- package/src/common/aria.ts +27 -0
- package/src/components/mds-modal/mds-modal.tsx +39 -4
- package/src/components/mds-modal/test/mds-modal.e2e.ts +2 -2
- package/src/components/mds-modal/test/mds-modal.stories.tsx +20 -0
- package/src/dictionary/typography.ts +3 -3
- package/src/fixtures/icons.json +2 -2
- package/src/types/typography.ts +3 -3
- package/www/build/mds-modal.esm.js +1 -1
- package/www/build/mds-modal.js +1 -1
- package/www/build/p-4fe02e5f.entry.js +1 -0
- package/www/build/{p-4288d1a7.system.entry.js → p-52cd3b82.system.entry.js} +1 -1
- package/www/build/p-76a04b9e.system.js +2 -0
- package/www/build/p-931319fa.js +2 -0
- package/www/build/{p-5935b9a5.system.js → p-a2cf985e.system.js} +1 -1
- package/dist/esm-es5/index-5dfae565.js +0 -2
- package/dist/mds-modal/p-19fa0f59.js +0 -2
- package/dist/mds-modal/p-9c47a964.system.js +0 -2
- package/dist/mds-modal/p-f1135a2e.entry.js +0 -1
- package/www/build/p-19fa0f59.js +0 -2
- package/www/build/p-9c47a964.system.js +0 -2
- package/www/build/p-f1135a2e.entry.js +0 -1
|
@@ -1,65 +1,17 @@
|
|
|
1
1
|
const NAMESPACE = 'mds-modal';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Virtual DOM patching algorithm based on Snabbdom by
|
|
5
|
+
* Simon Friis Vindum (@paldepind)
|
|
6
|
+
* Licensed under the MIT License
|
|
7
|
+
* https://github.com/snabbdom/snabbdom/blob/master/LICENSE
|
|
8
|
+
*
|
|
9
|
+
* Modified for Stencil's renderer and slot projection
|
|
10
|
+
*/
|
|
3
11
|
let scopeId;
|
|
4
12
|
let hostTagName;
|
|
5
13
|
let isSvgMode = false;
|
|
6
14
|
let queuePending = false;
|
|
7
|
-
const win = typeof window !== 'undefined' ? window : {};
|
|
8
|
-
const doc = win.document || { head: {} };
|
|
9
|
-
const plt = {
|
|
10
|
-
$flags$: 0,
|
|
11
|
-
$resourcesUrl$: '',
|
|
12
|
-
jmp: (h) => h(),
|
|
13
|
-
raf: (h) => requestAnimationFrame(h),
|
|
14
|
-
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
|
15
|
-
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
16
|
-
ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
|
17
|
-
};
|
|
18
|
-
const promiseResolve = (v) => Promise.resolve(v);
|
|
19
|
-
const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
|
|
20
|
-
try {
|
|
21
|
-
new CSSStyleSheet();
|
|
22
|
-
return typeof new CSSStyleSheet().replaceSync === 'function';
|
|
23
|
-
}
|
|
24
|
-
catch (e) { }
|
|
25
|
-
return false;
|
|
26
|
-
})()
|
|
27
|
-
;
|
|
28
|
-
const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
|
|
29
|
-
if (listeners) {
|
|
30
|
-
listeners.map(([flags, name, method]) => {
|
|
31
|
-
const target = getHostListenerTarget(elm, flags) ;
|
|
32
|
-
const handler = hostListenerProxy(hostRef, method);
|
|
33
|
-
const opts = hostListenerOpts(flags);
|
|
34
|
-
plt.ael(target, name, handler, opts);
|
|
35
|
-
(hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
40
|
-
try {
|
|
41
|
-
{
|
|
42
|
-
if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
|
|
43
|
-
// instance is ready, let's call it's member method for this event
|
|
44
|
-
hostRef.$lazyInstance$[methodName](ev);
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
(hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
catch (e) {
|
|
52
|
-
consoleError(e);
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
const getHostListenerTarget = (elm, flags) => {
|
|
56
|
-
if (flags & 4 /* LISTENER_FLAGS.TargetDocument */)
|
|
57
|
-
return doc;
|
|
58
|
-
return elm;
|
|
59
|
-
};
|
|
60
|
-
// prettier-ignore
|
|
61
|
-
const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
|
|
62
|
-
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
63
15
|
const createTime = (fnName, tagName = '') => {
|
|
64
16
|
{
|
|
65
17
|
return () => {
|
|
@@ -74,76 +26,7 @@ const uniqueTime = (key, measureText) => {
|
|
|
74
26
|
};
|
|
75
27
|
}
|
|
76
28
|
};
|
|
77
|
-
const
|
|
78
|
-
const registerStyle = (scopeId, cssText, allowCS) => {
|
|
79
|
-
let style = styles.get(scopeId);
|
|
80
|
-
if (supportsConstructableStylesheets && allowCS) {
|
|
81
|
-
style = (style || new CSSStyleSheet());
|
|
82
|
-
if (typeof style === 'string') {
|
|
83
|
-
style = cssText;
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
style.replaceSync(cssText);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
style = cssText;
|
|
91
|
-
}
|
|
92
|
-
styles.set(scopeId, style);
|
|
93
|
-
};
|
|
94
|
-
const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
95
|
-
let scopeId = getScopeId(cmpMeta);
|
|
96
|
-
const style = styles.get(scopeId);
|
|
97
|
-
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
98
|
-
// so the fallback is to always use the document for the root node in those cases
|
|
99
|
-
styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
|
|
100
|
-
if (style) {
|
|
101
|
-
if (typeof style === 'string') {
|
|
102
|
-
styleContainerNode = styleContainerNode.head || styleContainerNode;
|
|
103
|
-
let appliedStyles = rootAppliedStyles.get(styleContainerNode);
|
|
104
|
-
let styleElm;
|
|
105
|
-
if (!appliedStyles) {
|
|
106
|
-
rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
|
|
107
|
-
}
|
|
108
|
-
if (!appliedStyles.has(scopeId)) {
|
|
109
|
-
{
|
|
110
|
-
{
|
|
111
|
-
styleElm = doc.createElement('style');
|
|
112
|
-
styleElm.innerHTML = style;
|
|
113
|
-
}
|
|
114
|
-
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
115
|
-
}
|
|
116
|
-
if (appliedStyles) {
|
|
117
|
-
appliedStyles.add(scopeId);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
|
|
122
|
-
styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
return scopeId;
|
|
126
|
-
};
|
|
127
|
-
const attachStyles = (hostRef) => {
|
|
128
|
-
const cmpMeta = hostRef.$cmpMeta$;
|
|
129
|
-
const elm = hostRef.$hostElement$;
|
|
130
|
-
const flags = cmpMeta.$flags$;
|
|
131
|
-
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
132
|
-
const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
|
|
133
|
-
if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
|
|
134
|
-
// only required when we're NOT using native shadow dom (slot)
|
|
135
|
-
// or this browser doesn't support native shadow dom
|
|
136
|
-
// and this host element was NOT created with SSR
|
|
137
|
-
// let's pick out the inner content for slot projection
|
|
138
|
-
// create a node to represent where the original
|
|
139
|
-
// content was first placed, which is useful later on
|
|
140
|
-
// DOM WRITE!!
|
|
141
|
-
elm['s-sc'] = scopeId;
|
|
142
|
-
elm.classList.add(scopeId + '-h');
|
|
143
|
-
}
|
|
144
|
-
endAttachStyles();
|
|
145
|
-
};
|
|
146
|
-
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
29
|
+
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
147
30
|
/**
|
|
148
31
|
* Default style mode id
|
|
149
32
|
*/
|
|
@@ -232,6 +115,145 @@ const newVNode = (tag, text) => {
|
|
|
232
115
|
};
|
|
233
116
|
const Host = {};
|
|
234
117
|
const isHost = (node) => node && node.$tag$ === Host;
|
|
118
|
+
/**
|
|
119
|
+
* Parse a new property value for a given property type.
|
|
120
|
+
*
|
|
121
|
+
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
122
|
+
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
123
|
+
* 1. `any`, the type given to `propValue` in the function signature
|
|
124
|
+
* 2. the type stored from `propType`.
|
|
125
|
+
*
|
|
126
|
+
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
127
|
+
*
|
|
128
|
+
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
129
|
+
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
130
|
+
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
131
|
+
* ```tsx
|
|
132
|
+
* <my-cmp prop-val={0}></my-cmp>
|
|
133
|
+
* ```
|
|
134
|
+
*
|
|
135
|
+
* HTML prop values on the other hand, will always a string
|
|
136
|
+
*
|
|
137
|
+
* @param propValue the new value to coerce to some type
|
|
138
|
+
* @param propType the type of the prop, expressed as a binary number
|
|
139
|
+
* @returns the parsed/coerced value
|
|
140
|
+
*/
|
|
141
|
+
const parsePropertyValue = (propValue, propType) => {
|
|
142
|
+
// ensure this value is of the correct prop type
|
|
143
|
+
if (propValue != null && !isComplexType(propValue)) {
|
|
144
|
+
if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
|
|
145
|
+
// per the HTML spec, any string value means it is a boolean true value
|
|
146
|
+
// but we'll cheat here and say that the string "false" is the boolean false
|
|
147
|
+
return propValue === 'false' ? false : propValue === '' || !!propValue;
|
|
148
|
+
}
|
|
149
|
+
if (propType & 1 /* MEMBER_FLAGS.String */) {
|
|
150
|
+
// could have been passed as a number or boolean
|
|
151
|
+
// but we still want it as a string
|
|
152
|
+
return String(propValue);
|
|
153
|
+
}
|
|
154
|
+
// redundant return here for better minification
|
|
155
|
+
return propValue;
|
|
156
|
+
}
|
|
157
|
+
// not sure exactly what type we want
|
|
158
|
+
// so no need to change to a different type
|
|
159
|
+
return propValue;
|
|
160
|
+
};
|
|
161
|
+
const getElement = (ref) => (getHostRef(ref).$hostElement$ );
|
|
162
|
+
const createEvent = (ref, name, flags) => {
|
|
163
|
+
const elm = getElement(ref);
|
|
164
|
+
return {
|
|
165
|
+
emit: (detail) => {
|
|
166
|
+
return emitEvent(elm, name, {
|
|
167
|
+
bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
|
|
168
|
+
composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
|
|
169
|
+
cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
|
|
170
|
+
detail,
|
|
171
|
+
});
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* Helper function to create & dispatch a custom Event on a provided target
|
|
177
|
+
* @param elm the target of the Event
|
|
178
|
+
* @param name the name to give the custom Event
|
|
179
|
+
* @param opts options for configuring a custom Event
|
|
180
|
+
* @returns the custom Event
|
|
181
|
+
*/
|
|
182
|
+
const emitEvent = (elm, name, opts) => {
|
|
183
|
+
const ev = plt.ce(name, opts);
|
|
184
|
+
elm.dispatchEvent(ev);
|
|
185
|
+
return ev;
|
|
186
|
+
};
|
|
187
|
+
const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
|
|
188
|
+
const registerStyle = (scopeId, cssText, allowCS) => {
|
|
189
|
+
let style = styles.get(scopeId);
|
|
190
|
+
if (supportsConstructableStylesheets && allowCS) {
|
|
191
|
+
style = (style || new CSSStyleSheet());
|
|
192
|
+
if (typeof style === 'string') {
|
|
193
|
+
style = cssText;
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
style.replaceSync(cssText);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
style = cssText;
|
|
201
|
+
}
|
|
202
|
+
styles.set(scopeId, style);
|
|
203
|
+
};
|
|
204
|
+
const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
205
|
+
let scopeId = getScopeId(cmpMeta);
|
|
206
|
+
const style = styles.get(scopeId);
|
|
207
|
+
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
208
|
+
// so the fallback is to always use the document for the root node in those cases
|
|
209
|
+
styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
|
|
210
|
+
if (style) {
|
|
211
|
+
if (typeof style === 'string') {
|
|
212
|
+
styleContainerNode = styleContainerNode.head || styleContainerNode;
|
|
213
|
+
let appliedStyles = rootAppliedStyles.get(styleContainerNode);
|
|
214
|
+
let styleElm;
|
|
215
|
+
if (!appliedStyles) {
|
|
216
|
+
rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
|
|
217
|
+
}
|
|
218
|
+
if (!appliedStyles.has(scopeId)) {
|
|
219
|
+
{
|
|
220
|
+
{
|
|
221
|
+
styleElm = doc.createElement('style');
|
|
222
|
+
styleElm.innerHTML = style;
|
|
223
|
+
}
|
|
224
|
+
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
225
|
+
}
|
|
226
|
+
if (appliedStyles) {
|
|
227
|
+
appliedStyles.add(scopeId);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
|
|
232
|
+
styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return scopeId;
|
|
236
|
+
};
|
|
237
|
+
const attachStyles = (hostRef) => {
|
|
238
|
+
const cmpMeta = hostRef.$cmpMeta$;
|
|
239
|
+
const elm = hostRef.$hostElement$;
|
|
240
|
+
const flags = cmpMeta.$flags$;
|
|
241
|
+
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
242
|
+
const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
|
|
243
|
+
if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
|
|
244
|
+
// only required when we're NOT using native shadow dom (slot)
|
|
245
|
+
// or this browser doesn't support native shadow dom
|
|
246
|
+
// and this host element was NOT created with SSR
|
|
247
|
+
// let's pick out the inner content for slot projection
|
|
248
|
+
// create a node to represent where the original
|
|
249
|
+
// content was first placed, which is useful later on
|
|
250
|
+
// DOM WRITE!!
|
|
251
|
+
elm['s-sc'] = scopeId;
|
|
252
|
+
elm.classList.add(scopeId + '-h');
|
|
253
|
+
}
|
|
254
|
+
endAttachStyles();
|
|
255
|
+
};
|
|
256
|
+
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
235
257
|
/**
|
|
236
258
|
* Production setAccessor() function based on Preact by
|
|
237
259
|
* Jason Miller (@developit)
|
|
@@ -688,32 +710,6 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
688
710
|
// synchronous patch
|
|
689
711
|
patch(oldVNode, rootVnode);
|
|
690
712
|
};
|
|
691
|
-
const getElement = (ref) => (getHostRef(ref).$hostElement$ );
|
|
692
|
-
const createEvent = (ref, name, flags) => {
|
|
693
|
-
const elm = getElement(ref);
|
|
694
|
-
return {
|
|
695
|
-
emit: (detail) => {
|
|
696
|
-
return emitEvent(elm, name, {
|
|
697
|
-
bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
|
|
698
|
-
composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
|
|
699
|
-
cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
|
|
700
|
-
detail,
|
|
701
|
-
});
|
|
702
|
-
},
|
|
703
|
-
};
|
|
704
|
-
};
|
|
705
|
-
/**
|
|
706
|
-
* Helper function to create & dispatch a custom Event on a provided target
|
|
707
|
-
* @param elm the target of the Event
|
|
708
|
-
* @param name the name to give the custom Event
|
|
709
|
-
* @param opts options for configuring a custom Event
|
|
710
|
-
* @returns the custom Event
|
|
711
|
-
*/
|
|
712
|
-
const emitEvent = (elm, name, opts) => {
|
|
713
|
-
const ev = plt.ce(name, opts);
|
|
714
|
-
elm.dispatchEvent(ev);
|
|
715
|
-
return ev;
|
|
716
|
-
};
|
|
717
713
|
const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
718
714
|
if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
|
|
719
715
|
ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
|
|
@@ -882,49 +878,6 @@ const then = (promise, thenFn) => {
|
|
|
882
878
|
};
|
|
883
879
|
const addHydratedFlag = (elm) => elm.classList.add('hydrated')
|
|
884
880
|
;
|
|
885
|
-
/**
|
|
886
|
-
* Parse a new property value for a given property type.
|
|
887
|
-
*
|
|
888
|
-
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
889
|
-
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
890
|
-
* 1. `any`, the type given to `propValue` in the function signature
|
|
891
|
-
* 2. the type stored from `propType`.
|
|
892
|
-
*
|
|
893
|
-
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
894
|
-
*
|
|
895
|
-
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
896
|
-
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
897
|
-
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
898
|
-
* ```tsx
|
|
899
|
-
* <my-cmp prop-val={0}></my-cmp>
|
|
900
|
-
* ```
|
|
901
|
-
*
|
|
902
|
-
* HTML prop values on the other hand, will always a string
|
|
903
|
-
*
|
|
904
|
-
* @param propValue the new value to coerce to some type
|
|
905
|
-
* @param propType the type of the prop, expressed as a binary number
|
|
906
|
-
* @returns the parsed/coerced value
|
|
907
|
-
*/
|
|
908
|
-
const parsePropertyValue = (propValue, propType) => {
|
|
909
|
-
// ensure this value is of the correct prop type
|
|
910
|
-
if (propValue != null && !isComplexType(propValue)) {
|
|
911
|
-
if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
|
|
912
|
-
// per the HTML spec, any string value means it is a boolean true value
|
|
913
|
-
// but we'll cheat here and say that the string "false" is the boolean false
|
|
914
|
-
return propValue === 'false' ? false : propValue === '' || !!propValue;
|
|
915
|
-
}
|
|
916
|
-
if (propType & 1 /* MEMBER_FLAGS.String */) {
|
|
917
|
-
// could have been passed as a number or boolean
|
|
918
|
-
// but we still want it as a string
|
|
919
|
-
return String(propValue);
|
|
920
|
-
}
|
|
921
|
-
// redundant return here for better minification
|
|
922
|
-
return propValue;
|
|
923
|
-
}
|
|
924
|
-
// not sure exactly what type we want
|
|
925
|
-
// so no need to change to a different type
|
|
926
|
-
return propValue;
|
|
927
|
-
};
|
|
928
881
|
const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
|
|
929
882
|
const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
930
883
|
// check our new property value against our internal value
|
|
@@ -968,6 +921,16 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
968
921
|
}
|
|
969
922
|
}
|
|
970
923
|
};
|
|
924
|
+
/**
|
|
925
|
+
* Attach a series of runtime constructs to a compiled Stencil component
|
|
926
|
+
* constructor, including getters and setters for the `@Prop` and `@State`
|
|
927
|
+
* decorators, callbacks for when attributes change, and so on.
|
|
928
|
+
*
|
|
929
|
+
* @param Cstr the constructor for a component that we need to process
|
|
930
|
+
* @param cmpMeta metadata collected previously about the component
|
|
931
|
+
* @param flags a number used to store a series of bit flags
|
|
932
|
+
* @returns a reference to the same constructor passed in (but now mutated)
|
|
933
|
+
*/
|
|
971
934
|
const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
972
935
|
if (cmpMeta.$members$) {
|
|
973
936
|
if (Cstr.watchers) {
|
|
@@ -1191,12 +1154,16 @@ const connectedCallback = (elm) => {
|
|
|
1191
1154
|
const disconnectedCallback = (elm) => {
|
|
1192
1155
|
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
1193
1156
|
const hostRef = getHostRef(elm);
|
|
1157
|
+
const instance = hostRef.$lazyInstance$ ;
|
|
1194
1158
|
{
|
|
1195
1159
|
if (hostRef.$rmListeners$) {
|
|
1196
1160
|
hostRef.$rmListeners$.map((rmListener) => rmListener());
|
|
1197
1161
|
hostRef.$rmListeners$ = undefined;
|
|
1198
1162
|
}
|
|
1199
1163
|
}
|
|
1164
|
+
{
|
|
1165
|
+
safeCall(instance, 'disconnectedCallback');
|
|
1166
|
+
}
|
|
1200
1167
|
}
|
|
1201
1168
|
};
|
|
1202
1169
|
const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
@@ -1297,6 +1264,40 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1297
1264
|
// Fallback appLoad event
|
|
1298
1265
|
endBootstrap();
|
|
1299
1266
|
};
|
|
1267
|
+
const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
|
|
1268
|
+
if (listeners) {
|
|
1269
|
+
listeners.map(([flags, name, method]) => {
|
|
1270
|
+
const target = getHostListenerTarget(elm, flags) ;
|
|
1271
|
+
const handler = hostListenerProxy(hostRef, method);
|
|
1272
|
+
const opts = hostListenerOpts(flags);
|
|
1273
|
+
plt.ael(target, name, handler, opts);
|
|
1274
|
+
(hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
|
|
1275
|
+
});
|
|
1276
|
+
}
|
|
1277
|
+
};
|
|
1278
|
+
const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
1279
|
+
try {
|
|
1280
|
+
{
|
|
1281
|
+
if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
|
|
1282
|
+
// instance is ready, let's call it's member method for this event
|
|
1283
|
+
hostRef.$lazyInstance$[methodName](ev);
|
|
1284
|
+
}
|
|
1285
|
+
else {
|
|
1286
|
+
(hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
catch (e) {
|
|
1291
|
+
consoleError(e);
|
|
1292
|
+
}
|
|
1293
|
+
};
|
|
1294
|
+
const getHostListenerTarget = (elm, flags) => {
|
|
1295
|
+
if (flags & 4 /* LISTENER_FLAGS.TargetDocument */)
|
|
1296
|
+
return doc;
|
|
1297
|
+
return elm;
|
|
1298
|
+
};
|
|
1299
|
+
// prettier-ignore
|
|
1300
|
+
const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
|
|
1300
1301
|
const hostRefs = /*@__PURE__*/ new WeakMap();
|
|
1301
1302
|
const getHostRef = (ref) => hostRefs.get(ref);
|
|
1302
1303
|
const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
|
|
@@ -1340,6 +1341,27 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
1340
1341
|
}, consoleError);
|
|
1341
1342
|
};
|
|
1342
1343
|
const styles = /*@__PURE__*/ new Map();
|
|
1344
|
+
const win = typeof window !== 'undefined' ? window : {};
|
|
1345
|
+
const doc = win.document || { head: {} };
|
|
1346
|
+
const plt = {
|
|
1347
|
+
$flags$: 0,
|
|
1348
|
+
$resourcesUrl$: '',
|
|
1349
|
+
jmp: (h) => h(),
|
|
1350
|
+
raf: (h) => requestAnimationFrame(h),
|
|
1351
|
+
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
|
1352
|
+
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
1353
|
+
ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
|
1354
|
+
};
|
|
1355
|
+
const promiseResolve = (v) => Promise.resolve(v);
|
|
1356
|
+
const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
|
|
1357
|
+
try {
|
|
1358
|
+
new CSSStyleSheet();
|
|
1359
|
+
return typeof new CSSStyleSheet().replaceSync === 'function';
|
|
1360
|
+
}
|
|
1361
|
+
catch (e) { }
|
|
1362
|
+
return false;
|
|
1363
|
+
})()
|
|
1364
|
+
;
|
|
1343
1365
|
const queueDomReads = [];
|
|
1344
1366
|
const queueDomWrites = [];
|
|
1345
1367
|
const queueTask = (queue, write) => (cb) => {
|
package/dist/esm/loader.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { p as promiseResolve, b as bootstrapLazy } from './index-
|
|
1
|
+
import { p as promiseResolve, b as bootstrapLazy } from './index-a5a41aa8.js';
|
|
2
2
|
|
|
3
3
|
/*
|
|
4
|
-
Stencil Client Patch Esm v2.
|
|
4
|
+
Stencil Client Patch Esm v2.19.3 | MIT Licensed | https://stenciljs.com
|
|
5
5
|
*/
|
|
6
6
|
const patchEsm = () => {
|
|
7
7
|
return promiseResolve();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-
|
|
1
|
+
import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-a5a41aa8.js';
|
|
2
2
|
|
|
3
3
|
function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);else for(t in e)e[t]&&(n&&(n+=" "),n+=t);return n}function clsx(){for(var e,t,f=0,n="";f<arguments.length;)(e=arguments[f++])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
|
|
4
4
|
|
|
@@ -14,13 +14,14 @@ const MdsModal = class {
|
|
|
14
14
|
this.top = null;
|
|
15
15
|
this.bottom = null;
|
|
16
16
|
this.animationState = 'intro';
|
|
17
|
-
/**
|
|
18
|
-
* Specifies the animation position of the modal window
|
|
19
|
-
*/
|
|
20
|
-
this.position = null;
|
|
21
17
|
this.animationName = (customState = null, customPosition = null) => {
|
|
22
18
|
return `animate-${customPosition !== null ? customPosition : this.position}${customState !== null ? '-' + customState : ''}`;
|
|
23
19
|
};
|
|
20
|
+
this.checkKeyboardEscape = (event) => {
|
|
21
|
+
if (event.code === 'Escape') {
|
|
22
|
+
this.close.emit();
|
|
23
|
+
}
|
|
24
|
+
};
|
|
24
25
|
this.closeModal = (e = null) => {
|
|
25
26
|
var _a;
|
|
26
27
|
if (((_a = e.target) === null || _a === void 0 ? void 0 : _a.localName) !== 'mds-modal') {
|
|
@@ -31,6 +32,9 @@ const MdsModal = class {
|
|
|
31
32
|
this.close.emit();
|
|
32
33
|
}
|
|
33
34
|
};
|
|
35
|
+
this.stateOpened = undefined;
|
|
36
|
+
this.opened = undefined;
|
|
37
|
+
this.position = null;
|
|
34
38
|
}
|
|
35
39
|
componentWillLoad() {
|
|
36
40
|
this.bottom = this.hostElement.querySelector('[slot="bottom"]') !== null;
|
|
@@ -43,6 +47,10 @@ const MdsModal = class {
|
|
|
43
47
|
if (this.position === null) {
|
|
44
48
|
this.position = 'right';
|
|
45
49
|
}
|
|
50
|
+
if (this.window) {
|
|
51
|
+
const modal = this.hostElement.querySelector('[slot="window"]');
|
|
52
|
+
modal.setAttribute('role', 'modal');
|
|
53
|
+
}
|
|
46
54
|
}
|
|
47
55
|
componentWillRender() {
|
|
48
56
|
this.animationState = this.opened ? 'intro' : 'outro';
|
|
@@ -55,6 +63,14 @@ const MdsModal = class {
|
|
|
55
63
|
this.hostElement.classList.add(this.animationName(this.animationState));
|
|
56
64
|
window.clearTimeout(this.animationDeelay);
|
|
57
65
|
}, 500);
|
|
66
|
+
if (this.opened) {
|
|
67
|
+
this.addKeyboardEscapeListener();
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
this.removeKeyboardEscapeListener();
|
|
71
|
+
}
|
|
72
|
+
disconnectedCallback() {
|
|
73
|
+
this.removeKeyboardEscapeListener();
|
|
58
74
|
}
|
|
59
75
|
positionChange(_newValue, oldValue) {
|
|
60
76
|
window.clearTimeout(this.animationDeelay);
|
|
@@ -62,19 +78,30 @@ const MdsModal = class {
|
|
|
62
78
|
this.hostElement.classList.remove(this.animationName('intro', oldValue));
|
|
63
79
|
this.hostElement.classList.remove(this.animationName('outro', oldValue));
|
|
64
80
|
}
|
|
81
|
+
addKeyboardEscapeListener() {
|
|
82
|
+
window.addEventListener('keydown', this.checkKeyboardEscape.bind(this));
|
|
83
|
+
}
|
|
84
|
+
removeKeyboardEscapeListener() {
|
|
85
|
+
window.removeEventListener('keydown', this.checkKeyboardEscape.bind(this));
|
|
86
|
+
}
|
|
65
87
|
openedChange(newValue) {
|
|
66
88
|
this.stateOpened = newValue;
|
|
67
89
|
window.clearTimeout(this.animationDeelay);
|
|
90
|
+
if (newValue) {
|
|
91
|
+
this.addKeyboardEscapeListener();
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
this.removeKeyboardEscapeListener();
|
|
68
95
|
}
|
|
69
96
|
onCloseListener() {
|
|
70
97
|
this.opened = false;
|
|
71
98
|
}
|
|
72
99
|
render() {
|
|
73
|
-
return (h(Host, { class: clsx(this.stateOpened && this.animationName('opened')), onClick: (e) => { this.closeModal(e); } }, this.window
|
|
100
|
+
return (h(Host, { "aria-modal": clsx(this.opened ? 'true' : 'false'), class: clsx(this.stateOpened && this.animationName('opened')), onClick: (e) => { this.closeModal(e); } }, this.window
|
|
74
101
|
?
|
|
75
102
|
h("slot", { name: "window" })
|
|
76
103
|
:
|
|
77
|
-
h("div", { class: clsx('window', (this.top || this.bottom) && `window-${this.top ? '-top' : ''}${this.bottom ? '-bottom' : ''}`) }, this.top &&
|
|
104
|
+
h("div", { class: clsx('window', (this.top || this.bottom) && `window-${this.top ? '-top' : ''}${this.bottom ? '-bottom' : ''}`), role: "dialog" }, this.top &&
|
|
78
105
|
h("slot", { name: "top" }), h("slot", null), this.bottom &&
|
|
79
106
|
h("slot", { name: "bottom" })), !this.window && h("i", { innerHTML: miBaselineClose, class: "svg close" })));
|
|
80
107
|
}
|
package/dist/esm/mds-modal.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { p as promiseResolve, b as bootstrapLazy } from './index-
|
|
1
|
+
import { p as promiseResolve, b as bootstrapLazy } from './index-a5a41aa8.js';
|
|
2
2
|
|
|
3
3
|
/*
|
|
4
|
-
Stencil Client Patch Browser v2.
|
|
4
|
+
Stencil Client Patch Browser v2.19.3 | MIT Licensed | https://stenciljs.com
|
|
5
5
|
*/
|
|
6
6
|
const patchBrowser = () => {
|
|
7
7
|
const importMeta = import.meta.url;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var s in t=arguments[r])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e}).apply(this,arguments)},StyleNode=function(){this.start=0,this.end=0,this.previous=null,this.parent=null,this.rules=null,this.parsedCssText="",this.cssText="",this.atRule=!1,this.type=0,this.keyframesName="",this.selector="",this.parsedSelector=""};function parse(e){return parseCss(lex(e=clean(e)),e)}function clean(e){return e.replace(RX.comments,"").replace(RX.port,"")}function lex(e){var t=new StyleNode;t.start=0,t.end=e.length;for(var r=t,n=0,s=e.length;n<s;n++)if(e[n]===OPEN_BRACE){r.rules||(r.rules=[]);var o=r,a=o.rules[o.rules.length-1]||null;(r=new StyleNode).start=n+1,r.parent=o,r.previous=a,o.rules.push(r)}else e[n]===CLOSE_BRACE&&(r.end=n+1,r=r.parent||t);return t}function parseCss(e,t){var r=t.substring(e.start,e.end-1);if(e.parsedCssText=e.cssText=r.trim(),e.parent){var n=e.previous?e.previous.end:e.parent.start;r=(r=(r=_expandUnicodeEscapes(r=t.substring(n,e.start-1))).replace(RX.multipleSpaces," ")).substring(r.lastIndexOf(";")+1);var s=e.parsedSelector=e.selector=r.trim();e.atRule=0===s.indexOf(AT_START),e.atRule?0===s.indexOf(MEDIA_START)?e.type=types.MEDIA_RULE:s.match(RX.keyframesRule)&&(e.type=types.KEYFRAMES_RULE,e.keyframesName=e.selector.split(RX.multipleSpaces).pop()):0===s.indexOf(VAR_START)?e.type=types.MIXIN_RULE:e.type=types.STYLE_RULE}var o=e.rules;if(o)for(var a=0,i=o.length,l=void 0;a<i&&(l=o[a]);a++)parseCss(l,t);return e}function _expandUnicodeEscapes(e){return e.replace(/\\([0-9a-f]{1,6})\s/gi,(function(){for(var e=arguments[1],t=6-e.length;t--;)e="0"+e;return"\\"+e}))}var types={STYLE_RULE:1,KEYFRAMES_RULE:7,MEDIA_RULE:4,MIXIN_RULE:1e3},OPEN_BRACE="{",CLOSE_BRACE="}",RX={comments:/\/\*[^*]*\*+([^/*][^*]*\*+)*\//gim,port:/@import[^;]*;/gim,customProp:/(?:^[^;\-\s}]+)?--[^;{}]*?:[^{};]*?(?:[;\n]|$)/gim,mixinProp:/(?:^[^;\-\s}]+)?--[^;{}]*?:[^{};]*?{[^}]*?}(?:[;\n]|$)?/gim,mixinApply:/@apply\s*\(?[^);]*\)?\s*(?:[;\n]|$)?/gim,varApply:/[^;:]*?:[^;]*?var\([^;]*\)(?:[;\n]|$)?/gim,keyframesRule:/^@[^\s]*keyframes/,multipleSpaces:/\s+/g},VAR_START="--",MEDIA_START="@media",AT_START="@";function findRegex(e,t,r){e.lastIndex=0;var n=t.substring(r).match(e);if(n){var s=r+n.index;return{start:s,end:s+n[0].length}}return null}var VAR_USAGE_START=/\bvar\(/,VAR_ASSIGN_START=/\B--[\w-]+\s*:/,COMMENTS=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//gim,TRAILING_LINES=/^[\t ]+\n/gm;function resolveVar(e,t,r){return e[t]?e[t]:r?executeTemplate(r,e):""}function findVarEndIndex(e,t){for(var r=0,n=t;n<e.length;n++){var s=e[n];if("("===s)r++;else if(")"===s&&--r<=0)return n+1}return n}function parseVar(e,t){var r=findRegex(VAR_USAGE_START,e,t);if(!r)return null;var n=findVarEndIndex(e,r.start),s=e.substring(r.end,n-1).split(","),o=s[0],a=s.slice(1);return{start:r.start,end:n,propName:o.trim(),fallback:a.length>0?a.join(",").trim():void 0}}function compileVar(e,t,r){var n=parseVar(e,r);if(!n)return t.push(e.substring(r,e.length)),e.length;var s=n.propName,o=null!=n.fallback?compileTemplate(n.fallback):void 0;return t.push(e.substring(r,n.start),(function(e){return resolveVar(e,s,o)})),n.end}function executeTemplate(e,t){for(var r="",n=0;n<e.length;n++){var s=e[n];r+="string"==typeof s?s:s(t)}return r}function findEndValue(e,t){for(var r=!1,n=!1,s=t;s<e.length;s++){var o=e[s];if(r)n&&'"'===o&&(r=!1),n||"'"!==o||(r=!1);else if('"'===o)r=!0,n=!0;else if("'"===o)r=!0,n=!1;else{if(";"===o)return s+1;if("}"===o)return s}}return s}function removeCustomAssigns(e){for(var t="",r=0;;){var n=findRegex(VAR_ASSIGN_START,e,r),s=n?n.start:e.length;if(t+=e.substring(r,s),!n)break;r=findEndValue(e,s)}return t}function compileTemplate(e){var t=0;e=removeCustomAssigns(e=e.replace(COMMENTS,"")).replace(TRAILING_LINES,"");for(var r=[];t<e.length;)t=compileVar(e,r,t);return r}function resolveValues(e){var t={};e.forEach((function(e){e.declarations.forEach((function(e){t[e.prop]=e.value}))}));for(var r={},n=Object.entries(t),s=function(e){var t=!1;if(n.forEach((function(e){var n=e[0],s=executeTemplate(e[1],r);s!==r[n]&&(r[n]=s,t=!0)})),!t)return"break"},o=0;o<10;o++){if("break"===s())break}return r}function getSelectors(e,t){if(void 0===t&&(t=0),!e.rules)return[];var r=[];return e.rules.filter((function(e){return e.type===types.STYLE_RULE})).forEach((function(e){var n=getDeclarations(e.cssText);n.length>0&&e.parsedSelector.split(",").forEach((function(e){e=e.trim(),r.push({selector:e,declarations:n,specificity:computeSpecificity(),nu:t})})),t++})),r}function computeSpecificity(e){return 1}var IMPORTANT="!important",FIND_DECLARATIONS=/(?:^|[;\s{]\s*)(--[\w-]*?)\s*:\s*(?:((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};{])+)|\{([^}]*)\}(?:(?=[;\s}])|$))/gm;function getDeclarations(e){for(var t,r=[];t=FIND_DECLARATIONS.exec(e.trim());){var n=normalizeValue(t[2]),s=n.value,o=n.important;r.push({prop:t[1].trim(),value:compileTemplate(s),important:o})}return r}function normalizeValue(e){var t=(e=e.replace(/\s+/gim," ").trim()).endsWith(IMPORTANT);return t&&(e=e.slice(0,e.length-IMPORTANT.length).trim()),{value:e,important:t}}function getActiveSelectors(e,t,r){var n=[],s=getScopesForElement(t,e);return r.forEach((function(e){return n.push(e)})),s.forEach((function(e){return n.push(e)})),sortSelectors(getSelectorsForScopes(n).filter((function(t){return matches(e,t.selector)})))}function getScopesForElement(e,t){for(var r=[];t;){var n=e.get(t);n&&r.push(n),t=t.parentElement}return r}function getSelectorsForScopes(e){var t=[];return e.forEach((function(e){t.push.apply(t,e.selectors)})),t}function sortSelectors(e){return e.sort((function(e,t){return e.specificity===t.specificity?e.nu-t.nu:e.specificity-t.specificity})),e}function matches(e,t){return":root"===t||"html"===t||e.matches(t)}function parseCSS(e){var t=parse(e),r=compileTemplate(e);return{original:e,template:r,selectors:getSelectors(t),usesCssVars:r.length>1}}function addGlobalStyle(e,t){if(e.some((function(e){return e.styleEl===t})))return!1;var r=parseCSS(t.textContent);return r.styleEl=t,e.push(r),!0}function updateGlobalScopes(e){var t=resolveValues(getSelectorsForScopes(e));e.forEach((function(e){e.usesCssVars&&(e.styleEl.textContent=executeTemplate(e.template,t))}))}function reScope(e,t){var r=e.template.map((function(r){return"string"==typeof r?replaceScope(r,e.scopeId,t):r})),n=e.selectors.map((function(r){return __assign(__assign({},r),{selector:replaceScope(r.selector,e.scopeId,t)})}));return __assign(__assign({},e),{template:r,selectors:n,scopeId:t})}function replaceScope(e,t,r){return e=replaceAll(e,"\\.".concat(t),".".concat(r))}function replaceAll(e,t,r){return e.replace(new RegExp(t,"g"),r)}function loadDocument(e,t){return loadDocumentStyles(e,t),loadDocumentLinks(e,t).then((function(){updateGlobalScopes(t)}))}function startWatcher(e,t){"undefined"!=typeof MutationObserver&&new MutationObserver((function(){loadDocumentStyles(e,t)&&updateGlobalScopes(t)})).observe(document.head,{childList:!0})}function loadDocumentLinks(e,t){for(var r=[],n=e.querySelectorAll('link[rel="stylesheet"][href]:not([data-no-shim])'),s=0;s<n.length;s++)r.push(addGlobalLink(e,t,n[s]));return Promise.all(r)}function loadDocumentStyles(e,t){return Array.from(e.querySelectorAll("style:not([data-styles]):not([data-no-shim])")).map((function(e){return addGlobalStyle(t,e)})).some(Boolean)}function addGlobalLink(e,t,r){var n=r.href;return fetch(n).then((function(e){return e.text()})).then((function(s){if(hasCssVariables(s)&&r.parentNode){hasRelativeUrls(s)&&(s=fixRelativeUrls(s,n));var o=e.createElement("style");o.setAttribute("data-styles",""),o.textContent=s,addGlobalStyle(t,o),r.parentNode.insertBefore(o,r),r.remove()}})).catch((function(e){console.error(e)}))}var CSS_VARIABLE_REGEXP=/[\s;{]--[-a-zA-Z0-9]+\s*:/m;function hasCssVariables(e){return e.indexOf("var(")>-1||CSS_VARIABLE_REGEXP.test(e)}var CSS_URL_REGEXP=/url[\s]*\([\s]*['"]?(?!(?:https?|data)\:|\/)([^\'\"\)]*)[\s]*['"]?\)[\s]*/gim;function hasRelativeUrls(e){return CSS_URL_REGEXP.lastIndex=0,CSS_URL_REGEXP.test(e)}function fixRelativeUrls(e,t){var r=t.replace(/[^/]*$/,"");return e.replace(CSS_URL_REGEXP,(function(e,t){var n=r+t;return e.replace(t,n)}))}var CustomStyle=function(){function e(e,t){this.win=e,this.doc=t,this.count=0,this.hostStyleMap=new WeakMap,this.hostScopeMap=new WeakMap,this.globalScopes=[],this.scopesMap=new Map,this.didInit=!1}return e.prototype.i=function(){var e=this;return this.didInit||!this.win.requestAnimationFrame?Promise.resolve():(this.didInit=!0,new Promise((function(t){e.win.requestAnimationFrame((function(){startWatcher(e.doc,e.globalScopes),loadDocument(e.doc,e.globalScopes).then((function(){return t()}))}))})))},e.prototype.addLink=function(e){var t=this;return addGlobalLink(this.doc,this.globalScopes,e).then((function(){t.updateGlobal()}))},e.prototype.addGlobalStyle=function(e){addGlobalStyle(this.globalScopes,e)&&this.updateGlobal()},e.prototype.createHostStyle=function(e,t,r,n){if(this.hostScopeMap.has(e))throw new Error("host style already created");var s=this.registerHostTemplate(r,t,n),o=this.doc.createElement("style");return o.setAttribute("data-no-shim",""),s.usesCssVars?n?(o["s-sc"]=t="".concat(s.scopeId,"-").concat(this.count),o.textContent="/*needs update*/",this.hostStyleMap.set(e,o),this.hostScopeMap.set(e,reScope(s,t)),this.count++):(s.styleEl=o,s.usesCssVars||(o.textContent=executeTemplate(s.template,{})),this.globalScopes.push(s),this.updateGlobal(),this.hostScopeMap.set(e,s)):o.textContent=r,o},e.prototype.removeHost=function(e){var t=this.hostStyleMap.get(e);t&&t.remove(),this.hostStyleMap.delete(e),this.hostScopeMap.delete(e)},e.prototype.updateHost=function(e){var t=this.hostScopeMap.get(e);if(t&&t.usesCssVars&&t.isScoped){var r=this.hostStyleMap.get(e);if(r){var n=resolveValues(getActiveSelectors(e,this.hostScopeMap,this.globalScopes));r.textContent=executeTemplate(t.template,n)}}},e.prototype.updateGlobal=function(){updateGlobalScopes(this.globalScopes)},e.prototype.registerHostTemplate=function(e,t,r){var n=this.scopesMap.get(t);return n||((n=parseCSS(e)).scopeId=t,n.isScoped=r,this.scopesMap.set(t,n)),n},e}();!function(e){!e||e.__cssshim||e.CSS&&e.CSS.supports&&e.CSS.supports("color","var(--c)")||(e.__cssshim=new CustomStyle(e,e.document))}("undefined"!=typeof window&&window);
|
|
1
|
+
var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var s in t=arguments[r])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e}).apply(this,arguments)},StyleNode=function(){this.start=0,this.end=0,this.previous=null,this.parent=null,this.rules=null,this.parsedCssText="",this.cssText="",this.atRule=!1,this.type=0,this.keyframesName="",this.selector="",this.parsedSelector=""};function parse(e){return parseCss(lex(e=clean(e)),e)}function clean(e){return e.replace(RX.comments,"").replace(RX.port,"")}function lex(e){var t=new StyleNode;t.start=0,t.end=e.length;for(var r=t,n=0,s=e.length;n<s;n++)if(e[n]===OPEN_BRACE){r.rules||(r.rules=[]);var o=r,a=o.rules[o.rules.length-1]||null;(r=new StyleNode).start=n+1,r.parent=o,r.previous=a,o.rules.push(r)}else e[n]===CLOSE_BRACE&&(r.end=n+1,r=r.parent||t);return t}function parseCss(e,t){var r=t.substring(e.start,e.end-1);if(e.parsedCssText=e.cssText=r.trim(),e.parent){var n=e.previous?e.previous.end:e.parent.start;r=(r=(r=_expandUnicodeEscapes(r=t.substring(n,e.start-1))).replace(RX.multipleSpaces," ")).substring(r.lastIndexOf(";")+1);var s=e.parsedSelector=e.selector=r.trim();e.atRule=0===s.indexOf(AT_START),e.atRule?0===s.indexOf(MEDIA_START)?e.type=types.MEDIA_RULE:s.match(RX.keyframesRule)&&(e.type=types.KEYFRAMES_RULE,e.keyframesName=e.selector.split(RX.multipleSpaces).pop()):0===s.indexOf(VAR_START)?e.type=types.MIXIN_RULE:e.type=types.STYLE_RULE}var o=e.rules;if(o)for(var a=0,i=o.length,l=void 0;a<i&&(l=o[a]);a++)parseCss(l,t);return e}function _expandUnicodeEscapes(e){return e.replace(/\\([0-9a-f]{1,6})\s/gi,(function(){for(var e=arguments[1],t=6-e.length;t--;)e="0"+e;return"\\"+e}))}var types={STYLE_RULE:1,KEYFRAMES_RULE:7,MEDIA_RULE:4,MIXIN_RULE:1e3},OPEN_BRACE="{",CLOSE_BRACE="}",RX={comments:/\/\*[^*]*\*+([^/*][^*]*\*+)*\//gim,port:/@import[^;]*;/gim,customProp:/(?:^[^;\-\s}]+)?--[^;{}]*?:[^{};]*?(?:[;\n]|$)/gim,mixinProp:/(?:^[^;\-\s}]+)?--[^;{}]*?:[^{};]*?{[^}]*?}(?:[;\n]|$)?/gim,mixinApply:/@apply\s*\(?[^);]*\)?\s*(?:[;\n]|$)?/gim,varApply:/[^;:]*?:[^;]*?var\([^;]*\)(?:[;\n]|$)?/gim,keyframesRule:/^@[^\s]*keyframes/,multipleSpaces:/\s+/g},VAR_START="--",MEDIA_START="@media",AT_START="@",VAR_USAGE_START=/\bvar\(/,VAR_ASSIGN_START=/\B--[\w-]+\s*:/,COMMENTS=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//gim,TRAILING_LINES=/^[\t ]+\n/gm;function findRegex(e,t,r){e.lastIndex=0;var n=t.substring(r).match(e);if(n){var s=r+n.index;return{start:s,end:s+n[0].length}}return null}function resolveVar(e,t,r){return e[t]?e[t]:r?executeTemplate(r,e):""}function findVarEndIndex(e,t){for(var r=0,n=t;n<e.length;n++){var s=e[n];if("("===s)r++;else if(")"===s&&--r<=0)return n+1}return n}function parseVar(e,t){var r=findRegex(VAR_USAGE_START,e,t);if(!r)return null;var n=findVarEndIndex(e,r.start),s=e.substring(r.end,n-1).split(","),o=s[0],a=s.slice(1);return{start:r.start,end:n,propName:o.trim(),fallback:a.length>0?a.join(",").trim():void 0}}function compileVar(e,t,r){var n=parseVar(e,r);if(!n)return t.push(e.substring(r,e.length)),e.length;var s=n.propName,o=null!=n.fallback?compileTemplate(n.fallback):void 0;return t.push(e.substring(r,n.start),(function(e){return resolveVar(e,s,o)})),n.end}function executeTemplate(e,t){for(var r="",n=0;n<e.length;n++){var s=e[n];r+="string"==typeof s?s:s(t)}return r}function findEndValue(e,t){for(var r=!1,n=!1,s=t;s<e.length;s++){var o=e[s];if(r)n&&'"'===o&&(r=!1),n||"'"!==o||(r=!1);else if('"'===o)r=!0,n=!0;else if("'"===o)r=!0,n=!1;else{if(";"===o)return s+1;if("}"===o)return s}}return s}function removeCustomAssigns(e){for(var t="",r=0;;){var n=findRegex(VAR_ASSIGN_START,e,r),s=n?n.start:e.length;if(t+=e.substring(r,s),!n)break;r=findEndValue(e,s)}return t}function compileTemplate(e){var t=0;e=removeCustomAssigns(e=e.replace(COMMENTS,"")).replace(TRAILING_LINES,"");for(var r=[];t<e.length;)t=compileVar(e,r,t);return r}function resolveValues(e){var t={};e.forEach((function(e){e.declarations.forEach((function(e){t[e.prop]=e.value}))}));for(var r={},n=Object.entries(t),s=function(e){var t=!1;if(n.forEach((function(e){var n=e[0],s=executeTemplate(e[1],r);s!==r[n]&&(r[n]=s,t=!0)})),!t)return"break"},o=0;o<10;o++){if("break"===s())break}return r}function getSelectors(e,t){if(void 0===t&&(t=0),!e.rules)return[];var r=[];return e.rules.filter((function(e){return e.type===types.STYLE_RULE})).forEach((function(e){var n=getDeclarations(e.cssText);n.length>0&&e.parsedSelector.split(",").forEach((function(e){e=e.trim(),r.push({selector:e,declarations:n,specificity:computeSpecificity(),nu:t})})),t++})),r}function computeSpecificity(e){return 1}var IMPORTANT="!important",FIND_DECLARATIONS=/(?:^|[;\s{]\s*)(--[\w-]*?)\s*:\s*(?:((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};{])+)|\{([^}]*)\}(?:(?=[;\s}])|$))/gm;function getDeclarations(e){for(var t,r=[];t=FIND_DECLARATIONS.exec(e.trim());){var n=normalizeValue(t[2]),s=n.value,o=n.important;r.push({prop:t[1].trim(),value:compileTemplate(s),important:o})}return r}function normalizeValue(e){var t=(e=e.replace(/\s+/gim," ").trim()).endsWith(IMPORTANT);return t&&(e=e.slice(0,e.length-IMPORTANT.length).trim()),{value:e,important:t}}function getActiveSelectors(e,t,r){var n=[],s=getScopesForElement(t,e);return r.forEach((function(e){return n.push(e)})),s.forEach((function(e){return n.push(e)})),sortSelectors(getSelectorsForScopes(n).filter((function(t){return matches(e,t.selector)})))}function getScopesForElement(e,t){for(var r=[];t;){var n=e.get(t);n&&r.push(n),t=t.parentElement}return r}function getSelectorsForScopes(e){var t=[];return e.forEach((function(e){t.push.apply(t,e.selectors)})),t}function sortSelectors(e){return e.sort((function(e,t){return e.specificity===t.specificity?e.nu-t.nu:e.specificity-t.specificity})),e}function matches(e,t){return":root"===t||"html"===t||e.matches(t)}function parseCSS(e){var t=parse(e),r=compileTemplate(e);return{original:e,template:r,selectors:getSelectors(t),usesCssVars:r.length>1}}function addGlobalStyle(e,t){if(e.some((function(e){return e.styleEl===t})))return!1;var r=parseCSS(t.textContent);return r.styleEl=t,e.push(r),!0}function updateGlobalScopes(e){var t=resolveValues(getSelectorsForScopes(e));e.forEach((function(e){e.usesCssVars&&(e.styleEl.textContent=executeTemplate(e.template,t))}))}function reScope(e,t){var r=e.template.map((function(r){return"string"==typeof r?replaceScope(r,e.scopeId,t):r})),n=e.selectors.map((function(r){return __assign(__assign({},r),{selector:replaceScope(r.selector,e.scopeId,t)})}));return __assign(__assign({},e),{template:r,selectors:n,scopeId:t})}function replaceScope(e,t,r){return e=replaceAll(e,"\\.".concat(t),".".concat(r))}function replaceAll(e,t,r){return e.replace(new RegExp(t,"g"),r)}function loadDocument(e,t){return loadDocumentStyles(e,t),loadDocumentLinks(e,t).then((function(){updateGlobalScopes(t)}))}function startWatcher(e,t){"undefined"!=typeof MutationObserver&&new MutationObserver((function(){loadDocumentStyles(e,t)&&updateGlobalScopes(t)})).observe(document.head,{childList:!0})}function loadDocumentLinks(e,t){for(var r=[],n=e.querySelectorAll('link[rel="stylesheet"][href]:not([data-no-shim])'),s=0;s<n.length;s++)r.push(addGlobalLink(e,t,n[s]));return Promise.all(r)}function loadDocumentStyles(e,t){return Array.from(e.querySelectorAll("style:not([data-styles]):not([data-no-shim])")).map((function(e){return addGlobalStyle(t,e)})).some(Boolean)}function addGlobalLink(e,t,r){var n=r.href;return fetch(n).then((function(e){return e.text()})).then((function(s){if(hasCssVariables(s)&&r.parentNode){hasRelativeUrls(s)&&(s=fixRelativeUrls(s,n));var o=e.createElement("style");o.setAttribute("data-styles",""),o.textContent=s,addGlobalStyle(t,o),r.parentNode.insertBefore(o,r),r.remove()}})).catch((function(e){console.error(e)}))}var CSS_VARIABLE_REGEXP=/[\s;{]--[-a-zA-Z0-9]+\s*:/m;function hasCssVariables(e){return e.indexOf("var(")>-1||CSS_VARIABLE_REGEXP.test(e)}var CSS_URL_REGEXP=/url[\s]*\([\s]*['"]?(?!(?:https?|data)\:|\/)([^\'\"\)]*)[\s]*['"]?\)[\s]*/gim;function hasRelativeUrls(e){return CSS_URL_REGEXP.lastIndex=0,CSS_URL_REGEXP.test(e)}function fixRelativeUrls(e,t){var r=t.replace(/[^/]*$/,"");return e.replace(CSS_URL_REGEXP,(function(e,t){var n=r+t;return e.replace(t,n)}))}var CustomStyle=function(){function e(e,t){this.win=e,this.doc=t,this.count=0,this.hostStyleMap=new WeakMap,this.hostScopeMap=new WeakMap,this.globalScopes=[],this.scopesMap=new Map,this.didInit=!1}return e.prototype.i=function(){var e=this;return this.didInit||!this.win.requestAnimationFrame?Promise.resolve():(this.didInit=!0,new Promise((function(t){e.win.requestAnimationFrame((function(){startWatcher(e.doc,e.globalScopes),loadDocument(e.doc,e.globalScopes).then((function(){return t()}))}))})))},e.prototype.addLink=function(e){var t=this;return addGlobalLink(this.doc,this.globalScopes,e).then((function(){t.updateGlobal()}))},e.prototype.addGlobalStyle=function(e){addGlobalStyle(this.globalScopes,e)&&this.updateGlobal()},e.prototype.createHostStyle=function(e,t,r,n){if(this.hostScopeMap.has(e))throw new Error("host style already created");var s=this.registerHostTemplate(r,t,n),o=this.doc.createElement("style");return o.setAttribute("data-no-shim",""),s.usesCssVars?n?(o["s-sc"]=t="".concat(s.scopeId,"-").concat(this.count),o.textContent="/*needs update*/",this.hostStyleMap.set(e,o),this.hostScopeMap.set(e,reScope(s,t)),this.count++):(s.styleEl=o,s.usesCssVars||(o.textContent=executeTemplate(s.template,{})),this.globalScopes.push(s),this.updateGlobal(),this.hostScopeMap.set(e,s)):o.textContent=r,o},e.prototype.removeHost=function(e){var t=this.hostStyleMap.get(e);t&&t.remove(),this.hostStyleMap.delete(e),this.hostScopeMap.delete(e)},e.prototype.updateHost=function(e){var t=this.hostScopeMap.get(e);if(t&&t.usesCssVars&&t.isScoped){var r=this.hostStyleMap.get(e);if(r){var n=resolveValues(getActiveSelectors(e,this.hostScopeMap,this.globalScopes));r.textContent=executeTemplate(t.template,n)}}},e.prototype.updateGlobal=function(){updateGlobalScopes(this.globalScopes)},e.prototype.registerHostTemplate=function(e,t,r){var n=this.scopesMap.get(t);return n||((n=parseCSS(e)).scopeId=t,n.isScoped=r,this.scopesMap.set(t,n)),n},e}();!function(e){!e||e.__cssshim||e.CSS&&e.CSS.supports&&e.CSS.supports("color","var(--c)")||(e.__cssshim=new CustomStyle(e,e.document))}("undefined"!=typeof window&&window);
|