@twobirds/microcomponents 0.0.82 → 0.0.84
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/assets/documentation/MC.md +0 -1
- package/assets/test/test.html +1 -1
- package/dist/MC.d.ts +11 -10
- package/dist/MC.d.ts.map +1 -1
- package/dist/MC.js +137 -200
- package/dist/MC.min.js +157 -296
- package/dist/MC.ts +202 -337
- package/dist/elements.d.ts +1 -1
- package/dist/elements.d.ts.map +1 -1
- package/dist/elements.js +26 -6
- package/dist/elements.min.js +1 -1
- package/dist/elements.ts +50 -7
- package/dist/formValues.js +2 -2
- package/dist/formValues.min.js +1 -1
- package/dist/formValues.ts +3 -3
- package/dist/microcomponents.d.ts +0 -1
- package/dist/microcomponents.d.ts.map +1 -1
- package/dist/microcomponents.js +0 -1
- package/dist/microcomponents.min.js +1 -1
- package/dist/microcomponents.ts +1 -1
- package/dist/observables.d.ts.map +1 -1
- package/dist/observables.js +52 -57
- package/dist/observables.min.js +1 -1
- package/dist/observables.ts +68 -73
- package/package.json +6 -5
- package/public/MC.d.ts +11 -10
- package/public/MC.d.ts.map +1 -1
- package/public/MC.js +137 -200
- package/public/MC.js.map +1 -1
- package/public/MC.min.js +157 -296
- package/public/MC.ts +202 -337
- package/public/documentation/MC.md +0 -1
- package/public/elements.d.ts +1 -1
- package/public/elements.d.ts.map +1 -1
- package/public/elements.js +26 -6
- package/public/elements.js.map +1 -1
- package/public/elements.min.js +1 -1
- package/public/elements.ts +50 -7
- package/public/formValues.js +2 -2
- package/public/formValues.js.map +1 -1
- package/public/formValues.min.js +1 -1
- package/public/formValues.ts +3 -3
- package/public/microcomponents.d.ts +0 -1
- package/public/microcomponents.d.ts.map +1 -1
- package/public/microcomponents.js +0 -1
- package/public/microcomponents.js.map +1 -1
- package/public/microcomponents.min.js +1 -1
- package/public/microcomponents.ts +1 -1
- package/public/observables.d.ts.map +1 -1
- package/public/observables.js +52 -57
- package/public/observables.js.map +1 -1
- package/public/observables.min.js +1 -1
- package/public/observables.ts +68 -73
- package/public/{test/selectors.ts → selectors._ts} +2 -367
- package/public/src/MC.d.ts +37 -0
- package/public/src/MC.d.ts.map +1 -0
- package/public/src/MC.js +316 -0
- package/public/src/MC.js.map +1 -0
- package/public/src/MC.ts +202 -337
- package/public/src/elements.d.ts +5 -0
- package/public/src/elements.d.ts.map +1 -0
- package/public/src/elements.js +68 -0
- package/public/src/elements.js.map +1 -0
- package/public/src/elements.ts +50 -7
- package/public/src/formValues.d.ts +3 -0
- package/public/src/formValues.d.ts.map +1 -0
- package/public/src/formValues.js +162 -0
- package/public/src/formValues.js.map +1 -0
- package/public/src/formValues.ts +3 -3
- package/public/src/helpers.d.ts +14 -0
- package/public/src/helpers.d.ts.map +1 -0
- package/public/src/helpers.js +113 -0
- package/public/src/microcomponents.d.ts +6 -0
- package/public/src/microcomponents.d.ts.map +1 -0
- package/public/src/microcomponents.js +7 -0
- package/public/src/microcomponents.js.map +1 -0
- package/public/src/microcomponents.ts +1 -1
- package/public/src/observables.d.ts +11 -0
- package/public/src/observables.d.ts.map +1 -0
- package/public/src/observables.js +244 -0
- package/public/src/observables.js.map +1 -0
- package/public/src/observables.ts +68 -73
- package/public/{selectors.ts → src/selectors._ts} +2 -367
- package/public/src/test/grandparent.css +11 -0
- package/public/src/test/test/child.d.ts +2 -0
- package/public/src/test/test/child.d.ts.map +1 -0
- package/public/src/test/test/child.js +15 -0
- package/public/src/test/test/child.js.map +1 -0
- package/public/src/test/test/child.ts +21 -0
- package/public/src/test/test/grandchild.d.ts +2 -0
- package/public/src/test/test/grandchild.d.ts.map +1 -0
- package/public/src/test/test/grandchild.js +15 -0
- package/public/src/test/test/grandchild.js.map +1 -0
- package/public/src/test/test/grandchild.ts +21 -0
- package/public/src/test/test/grandparent.d.ts +2 -0
- package/public/src/test/test/grandparent.d.ts.map +1 -0
- package/public/src/test/test/grandparent.js +1 -0
- package/public/src/test/test/grandparent.js.map +1 -0
- package/public/src/test/test/grandparent.ts +29 -0
- package/public/src/test/test/greatgrandchild.d.ts +2 -0
- package/public/src/test/test/greatgrandchild.d.ts.map +1 -0
- package/public/src/test/test/greatgrandchild.js +29 -0
- package/public/src/test/test/greatgrandchild.js.map +1 -0
- package/public/src/test/test/greatgrandchild.ts +42 -0
- package/public/src/test/test/parent.d.ts +2 -0
- package/public/src/test/test/parent.d.ts.map +1 -0
- package/public/src/test/test/parent.js +15 -0
- package/public/src/test/test/parent.js.map +1 -0
- package/public/src/test/test/parent.ts +21 -0
- package/public/src/test/test/testform.d.ts +2 -0
- package/public/src/test/test/testform.d.ts.map +1 -0
- package/public/src/test/test/testform.js +1 -0
- package/public/src/test/test/testform.js.map +1 -0
- package/public/src/test/test/testform.ts +153 -0
- package/public/src/test/test/testfunction.d.ts +3 -0
- package/public/src/test/test/testfunction.d.ts.map +1 -0
- package/public/src/test/test/testfunction.js +7 -0
- package/public/src/test/test/testfunction.js.map +1 -0
- package/public/src/test/test/testfunction.ts +12 -0
- package/public/src/test/test/testmc.d.ts +3 -0
- package/public/src/test/test/testmc.d.ts.map +1 -0
- package/public/src/test/test/testmc.js +10 -0
- package/public/src/test/test/testmc.js.map +1 -0
- package/public/src/test/test/testmc.ts +16 -0
- package/public/src/test/test/testsimpleclass.d.ts +3 -0
- package/public/src/test/test/testsimpleclass.d.ts.map +1 -0
- package/public/src/test/test/testsimpleclass.js +9 -0
- package/public/src/test/test/testsimpleclass.js.map +1 -0
- package/public/src/test/test/testsimpleclass.ts +15 -0
- package/public/src/test/test.d.ts +2 -0
- package/public/src/test/test.d.ts.map +1 -0
- package/public/src/test/test.js +80 -0
- package/public/src/test/test.js.map +1 -0
- package/public/src/test/test.ts +188 -0
- package/public/src/test/testform.css +47 -0
- package/public/src/test/testform.html +56 -0
- package/public/src/test/testform.json +27 -0
- package/public/test/MC.d.ts +11 -10
- package/public/test/MC.d.ts.map +1 -1
- package/public/test/MC.js +137 -200
- package/public/test/MC.min.js +377 -0
- package/public/test/MC.ts +202 -337
- package/public/test/elements.d.ts +1 -1
- package/public/test/elements.d.ts.map +1 -1
- package/public/test/elements.js +26 -6
- package/public/test/elements.min.js +1 -0
- package/public/test/elements.ts +50 -7
- package/public/test/formValues.js +2 -2
- package/public/test/formValues.min.js +1 -0
- package/public/test/formValues.ts +3 -3
- package/public/test/grandparent.css +1 -3
- package/public/test/microcomponents.d.ts +0 -1
- package/public/test/microcomponents.d.ts.map +1 -1
- package/public/test/microcomponents.js +0 -1
- package/public/test/microcomponents.min.js +1 -1
- package/public/test/microcomponents.ts +1 -1
- package/public/test/observables.d.ts.map +1 -1
- package/public/test/observables.js +52 -57
- package/public/test/observables.min.js +1 -0
- package/public/test/observables.ts +68 -73
- package/public/test/test/child.ts +21 -0
- package/public/test/test/grandchild.ts +21 -0
- package/public/test/test/grandparent.d.ts.map +1 -1
- package/public/test/test/grandparent.js +1 -1
- package/public/test/test/grandparent.js.map +1 -1
- package/public/test/test/grandparent.ts +29 -0
- package/public/test/test/greatgrandchild.ts +42 -0
- package/public/test/test/parent.ts +21 -0
- package/public/test/test/testform.js +1 -1
- package/public/test/test/testform.js.map +1 -1
- package/public/test/test/testform.ts +153 -0
- package/public/test/test/testfunction.d.ts +3 -0
- package/public/test/test/testfunction.d.ts.map +1 -0
- package/public/test/test/testfunction.js +7 -0
- package/public/test/test/testfunction.js.map +1 -0
- package/public/test/test/testfunction.ts +12 -0
- package/public/test/test/testmc.d.ts +2 -5
- package/public/test/test/testmc.d.ts.map +1 -1
- package/public/test/test/testmc.js +4 -4
- package/public/test/test/testmc.js.map +1 -1
- package/public/test/test/testmc.ts +16 -0
- package/public/test/test/testsimpleclass.d.ts +3 -0
- package/public/test/test/testsimpleclass.d.ts.map +1 -0
- package/public/test/test/testsimpleclass.js +9 -0
- package/public/test/test/testsimpleclass.js.map +1 -0
- package/public/test/test/testsimpleclass.ts +15 -0
- package/public/test/test.html +1 -1
- package/public/test/test.js +5 -6
- package/public/test/test.js.map +1 -1
- package/public/test/test.ts +188 -0
- package/public/test/testform.css +47 -0
- package/public/test/testform.html +56 -0
- package/public/test/testform.json +3 -3
- package/public/typedoc/assets/navigation.js +1 -1
- package/public/typedoc/assets/search.js +1 -1
- package/public/typedoc/classes/MC.DC.html +6 -4
- package/public/typedoc/classes/MC.MC.html +3 -4
- package/public/typedoc/classes/MC.McBase.html +2 -2
- package/public/typedoc/functions/MC.autoload.html +1 -1
- package/public/typedoc/functions/MC.off.html +1 -0
- package/public/typedoc/functions/MC.on.html +1 -0
- package/public/typedoc/functions/MC.one.html +1 -0
- package/public/typedoc/functions/elements.defineCE.html +1 -1
- package/public/typedoc/functions/elements.getCE.html +1 -1
- package/public/typedoc/functions/formValues.formValues.html +1 -1
- package/public/typedoc/functions/observables.observe.html +1 -1
- package/public/typedoc/interfaces/MC.HTMLMcElement.html +2 -2
- package/public/typedoc/modules/MC.html +7 -6
- package/public/typedoc/modules/elements.html +1 -1
- package/public/typedoc/modules/formValues.html +1 -1
- package/public/typedoc/modules/observables.html +1 -1
- package/public/typedoc/types/observables.Observable.html +1 -1
- package/src/MC.ts +202 -337
- package/src/elements.ts +50 -7
- package/src/formValues.ts +3 -3
- package/src/microcomponents.ts +1 -1
- package/src/observables.ts +68 -73
- package/{dist/selectors.ts → src/selectors._ts} +2 -367
- package/src/test/test/grandparent.ts +12 -4
- package/src/test/test/testform.ts +13 -11
- package/src/test/test/testfunction.ts +12 -0
- package/src/test/test/testmc.ts +13 -9
- package/src/test/test/testsimpleclass.ts +15 -0
- package/src/test/test.ts +8 -20
- package/tasks.md +36 -0
- package/tsconfig.json +2 -2
- package/typedoc.json +1 -1
- package/webpack.config.js +2 -2
- package/dist/McEvent.d.ts +0 -15
- package/dist/McEvent.d.ts.map +0 -1
- package/dist/McEvent.js +0 -71
- package/dist/selectors.d.ts +0 -108
- package/dist/selectors.d.ts.map +0 -1
- package/dist/selectors.js +0 -971
- package/dist/selectors.min.js +0 -1
- package/public/McEvent.d.ts +0 -15
- package/public/McEvent.d.ts.map +0 -1
- package/public/McEvent.js +0 -71
- package/public/McEvent.js.map +0 -1
- package/public/selectors.d.ts +0 -108
- package/public/selectors.d.ts.map +0 -1
- package/public/selectors.js +0 -971
- package/public/selectors.js.map +0 -1
- package/public/selectors.min.js +0 -1
- package/public/src/selectors.ts +0 -1634
- package/public/test/MC.js.map +0 -1
- package/public/test/McEvent.d.ts +0 -15
- package/public/test/McEvent.d.ts.map +0 -1
- package/public/test/McEvent.js +0 -71
- package/public/test/McEvent.js.map +0 -1
- package/public/test/McEvent.ts +0 -96
- package/public/test/elements.js.map +0 -1
- package/public/test/formValues.js.map +0 -1
- package/public/test/microcomponents.js.map +0 -1
- package/public/test/observables.js.map +0 -1
- package/public/test/selectors.d.ts +0 -108
- package/public/test/selectors.d.ts.map +0 -1
- package/public/test/selectors.js +0 -971
- package/public/test/selectors.js.map +0 -1
- package/public/typedoc/classes/MC.McEvent.html +0 -9
- package/public/typedoc/functions/MC.addListener.html +0 -1
- package/public/typedoc/functions/MC.removeListener.html +0 -1
- package/src/McEvent.ts +0 -96
- package/src/selectors.ts +0 -1634
- /package/{dist/McEvent.ts → public/McEvent._ts} +0 -0
- /package/public/{McEvent.ts → src/McEvent._ts} +0 -0
- /package/public/{test → src}/helpers.js.map +0 -0
- /package/{public/src/McEvent.ts → src/McEvent._ts} +0 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
legend {
|
|
2
|
+
display: inherit;
|
|
3
|
+
margin: inherit;
|
|
4
|
+
vertical-align: inherit;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
label {
|
|
8
|
+
display: inline;
|
|
9
|
+
margin-top: 5px;
|
|
10
|
+
margin-left: 5px;
|
|
11
|
+
vertical-align: top;
|
|
12
|
+
width: 10em;
|
|
13
|
+
text-align: right;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
label::before {
|
|
17
|
+
content: ' ';
|
|
18
|
+
display: block;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
form input,
|
|
22
|
+
form select,
|
|
23
|
+
form textarea {
|
|
24
|
+
margin-left: 5px;
|
|
25
|
+
margin-top: 0px;
|
|
26
|
+
display: inline;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
form label + textarea {
|
|
30
|
+
display: inline-block;
|
|
31
|
+
margin-top: 3px;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
form input + label {
|
|
35
|
+
width: inherit;
|
|
36
|
+
margin-top: 3px;
|
|
37
|
+
text-align: left;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
body > form {
|
|
41
|
+
display: block;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
form fieldset {
|
|
45
|
+
border: 1px solid darkslategrey;
|
|
46
|
+
border-radius: 3px;
|
|
47
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<!-- test form -->
|
|
2
|
+
<fieldset>
|
|
3
|
+
<legend>Inputs</legend>
|
|
4
|
+
<label>text</label><input type="text" name="textInput" value="" /> <strong>2wB: </strong>{textInput}
|
|
5
|
+
<label>color</label><input type="color" name="colorInput" value="" />
|
|
6
|
+
<label>date</label><input type="date" name="dateInput" value="" />
|
|
7
|
+
<label>datetime-local</label><input type="datetime-local" name="dtlInput" value="" />
|
|
8
|
+
<label>email</label><input type="email" name="email" value="" />
|
|
9
|
+
<label>file</label><input type="file" name="fileInput" value="" />
|
|
10
|
+
<label>hidden</label><input type="hidden" name="hiddenInput" value="hiddenVal" />
|
|
11
|
+
<label>month</label><input type="month" name="month" value="" />
|
|
12
|
+
<label>number</label><input type="number" name="number" value="" />
|
|
13
|
+
<label>password</label><input type="password" name="passInput" value="" />
|
|
14
|
+
<label>range</label><input type="range" name="rangeInput" value="" />
|
|
15
|
+
<label>search</label><input type="search" name="searchInput" value="" />
|
|
16
|
+
<label>tel</label><input type="tel" name="telInput" value="" />
|
|
17
|
+
<label>time</label><input type="time" name="timeInput" value="" />
|
|
18
|
+
<label>url</label><input type="url" name="urlInput" value="" />
|
|
19
|
+
<label>week</label><input type="week" name="weekInput" value="" />
|
|
20
|
+
</fieldset>
|
|
21
|
+
<fieldset>
|
|
22
|
+
<legend>Selects</legend>
|
|
23
|
+
<label>singleSelect</label>
|
|
24
|
+
<select name="singleSelect">
|
|
25
|
+
<option disabled selected value> -- select -- </option>
|
|
26
|
+
<option value="1">Option 1</option>
|
|
27
|
+
<option value="2">Option 2</option>
|
|
28
|
+
<option value="3">Option 3</option>
|
|
29
|
+
<option value="4">Option 4</option>
|
|
30
|
+
</select>
|
|
31
|
+
<label>multiSelect</label>
|
|
32
|
+
<select name="multiSelect" multiple="multiple" type="select-multiple">
|
|
33
|
+
<option value="1">Option 1</option>
|
|
34
|
+
<option value="2" selected=true>Option 2</option>
|
|
35
|
+
<option value="3">Option 3</option>
|
|
36
|
+
<option value="4" selected=true>Option 4</option>
|
|
37
|
+
</select>
|
|
38
|
+
</fieldset>
|
|
39
|
+
<fieldset>
|
|
40
|
+
<legend>Radiobuttons <strong>2wB: </strong>{myRadio}</legend>
|
|
41
|
+
<label>radio1</label><input type="radio" name="myRadio" value="radio1">
|
|
42
|
+
<label>radio2</label><input type="radio" name="myRadio" value="radio2">
|
|
43
|
+
<label>radio3</label><input type="radio" name="myRadio" value="radio3">
|
|
44
|
+
</fieldset>
|
|
45
|
+
<fieldset>
|
|
46
|
+
<legend>Checkboxes</legend>
|
|
47
|
+
<label>cb1</label><input type="checkbox" name="cb1">
|
|
48
|
+
<label>cb2</label><input type="checkbox" name="cb2">
|
|
49
|
+
<label>cb3</label><input type="checkbox" name="cb3">
|
|
50
|
+
<label>cb4</label><input type="checkbox" name="cb4">
|
|
51
|
+
<label>cb5</label><input type="checkbox" name="cb5">
|
|
52
|
+
</fieldset>
|
|
53
|
+
<fieldset>
|
|
54
|
+
<legend>TextArea</legend>
|
|
55
|
+
<label>textArea</label><textarea name="textArea"></textarea>
|
|
56
|
+
</fieldset>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"textInput":"Hallo Welt",
|
|
3
|
+
"colorInput":"#eaf8f8",
|
|
4
|
+
"dateInput":"",
|
|
5
|
+
"dtlInput":"",
|
|
6
|
+
"email":"",
|
|
7
|
+
"hiddenInput":"",
|
|
8
|
+
"hiddenVal":"",
|
|
9
|
+
"month":"",
|
|
10
|
+
"number":"",
|
|
11
|
+
"passInput":"",
|
|
12
|
+
"rangeInput":"30",
|
|
13
|
+
"searchInput":"",
|
|
14
|
+
"telInput":"",
|
|
15
|
+
"timeInput":"",
|
|
16
|
+
"urlInput":"",
|
|
17
|
+
"weekInput":"",
|
|
18
|
+
"myRadio":"radio3",
|
|
19
|
+
"cb1":true,
|
|
20
|
+
"cb2":false,
|
|
21
|
+
"cb3":true,
|
|
22
|
+
"cb4":false,
|
|
23
|
+
"cb5":false,
|
|
24
|
+
"singleSelect":"",
|
|
25
|
+
"multiSelect":["2","4"],
|
|
26
|
+
"textArea":"This is some example\rtext..."
|
|
27
|
+
}
|
package/public/test/MC.d.ts
CHANGED
|
@@ -1,36 +1,37 @@
|
|
|
1
1
|
import { LooseObject } from './helpers.js';
|
|
2
|
-
import { McEvent } from './McEvent.js';
|
|
3
2
|
export interface HTMLMcElement extends HTMLElement {
|
|
4
3
|
_mc: LooseObject;
|
|
5
4
|
}
|
|
6
|
-
declare function
|
|
7
|
-
declare function
|
|
8
|
-
declare function
|
|
5
|
+
declare function off(domNode: Node, eventName: string, handler: EventListenerOrEventListenerObject): void;
|
|
6
|
+
declare function on(domNode: Node, eventName: string, handler: EventListenerOrEventListenerObject, once?: boolean): void;
|
|
7
|
+
declare function one(domNode: Node, eventName: string, handler: EventListenerOrEventListenerObject): void;
|
|
8
|
+
declare function trigger(domNode: HTMLElement, event: CustomEvent | string, data?: any, bubble?: string): void;
|
|
9
9
|
declare class McBase {
|
|
10
|
-
|
|
10
|
+
private _target;
|
|
11
11
|
constructor(target?: {
|
|
12
12
|
[key: string]: any;
|
|
13
13
|
}, debug?: boolean);
|
|
14
14
|
get target(): any;
|
|
15
15
|
}
|
|
16
16
|
declare class MC extends McBase {
|
|
17
|
-
_mc?: LooseObject;
|
|
18
17
|
constructor(target?: any);
|
|
19
18
|
static trigger: typeof trigger;
|
|
20
|
-
trigger(ev:
|
|
19
|
+
trigger(ev: string, data?: any, bubble?: string): void;
|
|
21
20
|
}
|
|
22
21
|
declare class DC extends McBase {
|
|
23
|
-
_mc?: LooseObject;
|
|
24
22
|
constructor(target: HTMLElement, debug?: boolean);
|
|
25
23
|
static add: Function;
|
|
26
24
|
static remove: Function;
|
|
27
25
|
static trigger: Function;
|
|
28
|
-
|
|
26
|
+
off(eventName: string, handler: EventListenerOrEventListenerObject): void;
|
|
27
|
+
on(eventName: string, handler: EventListenerOrEventListenerObject): void;
|
|
28
|
+
one(eventName: string, handler: EventListenerOrEventListenerObject): void;
|
|
29
|
+
trigger(ev: CustomEvent | string, data?: any, bubble?: string): void;
|
|
29
30
|
parent(search?: string): any[];
|
|
30
31
|
ancestors(search?: string): any[];
|
|
31
32
|
children(search?: string): any[];
|
|
32
33
|
descendants(search?: string): any[];
|
|
33
34
|
}
|
|
34
35
|
declare function autoload(enable?: boolean): boolean;
|
|
35
|
-
export {
|
|
36
|
+
export { McBase, MC, DC, autoload, on, one, off, trigger };
|
|
36
37
|
//# sourceMappingURL=MC.d.ts.map
|
package/public/test/MC.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MC.d.ts","sourceRoot":"","sources":["../src/MC.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"MC.d.ts","sourceRoot":"","sources":["../src/MC.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAiB3C,MAAM,WAAW,aAAc,SAAQ,WAAW;IACjD,GAAG,EAAE,WAAW,CAAC;CACjB;AA2HD,iBAAS,GAAG,CAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,kCAAkC,QAE1F;AAED,iBAAS,EAAE,CAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,kCAAkC,EAAE,IAAI,GAAE,OAAe,QAEhH;AAED,iBAAS,GAAG,CAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,kCAAkC,QAE1F;AAGD,iBAAS,OAAO,CACf,OAAO,EAAE,WAAW,EACpB,KAAK,EAAE,WAAW,GAAG,MAAM,EAC3B,IAAI,GAAE,GAAQ,EACd,MAAM,GAAE,MAAY,QAepB;AA4ED,cAAM,MAAM;IACX,OAAO,CAAC,OAAO,CAAe;gBAElB,MAAM,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,EAAE,KAAK,GAAE,OAAe;IAUnE,IAAI,MAAM,IAAI,GAAG,CAEhB;CAED;AAED,cAAM,EAAG,SAAQ,MAAM;gBACV,MAAM,CAAC,EAAE,GAAG;IAIxB,MAAM,CAAC,OAAO,iBAAW;IAEzB,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,GAAE,GAAQ,EAAE,MAAM,GAAE,MAAY;CAGxD;AAED,cAAM,EAAG,SAAQ,MAAM;gBACV,MAAM,EAAE,WAAW,EAAE,KAAK,GAAE,OAAe;IAIvD,MAAM,CAAC,GAAG,EAAE,QAAQ,CAAO;IAC3B,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAU;IACjC,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAW;IAEnC,GAAG,CAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,kCAAkC;IAInE,EAAE,CAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,kCAAkC;IAIlE,GAAG,CAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,kCAAkC;IAInE,OAAO,CAAC,EAAE,EAAE,WAAW,GAAG,MAAM,EAAE,IAAI,GAAE,GAAQ,EAAE,MAAM,GAAE,MAAY;IAOtE,MAAM,CAAC,MAAM,GAAE,MAAW,GAAG,GAAG,EAAE;IAMlC,SAAS,CAAC,MAAM,GAAE,MAAW,GAAG,GAAG,EAAE;IAMrC,QAAQ,CAAC,MAAM,GAAE,MAAW,GAAG,GAAG,EAAE;IAQpC,WAAW,CAAC,MAAM,GAAE,MAAW,GAAG,GAAG,EAAE;CAMvC;AA+GD,iBAAS,QAAQ,CAAC,MAAM,GAAE,OAAc,GAAG,OAAO,CAmBjD;AAID,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC"}
|
package/public/test/MC.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
import { McEvent } from './McEvent.js';
|
|
3
2
|
var isBrowser = new Function('try {return this===window;}catch(e){ return false;}');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
.
|
|
8
|
-
|
|
3
|
+
function getNativeEventNames(domNode) {
|
|
4
|
+
let nativeEventNames = [];
|
|
5
|
+
if (isBrowser()) {
|
|
6
|
+
Object.keys(HTMLElement.prototype)
|
|
7
|
+
.filter((key) => /^on/.test(key))
|
|
8
|
+
.forEach((eventName) => nativeEventNames.push(eventName));
|
|
9
|
+
}
|
|
10
|
+
return nativeEventNames;
|
|
9
11
|
}
|
|
10
12
|
function getMicroComponents(elements, search) {
|
|
11
13
|
let mcValues = [];
|
|
@@ -44,19 +46,6 @@ function traverseNodes(node, search, firstonly = true) {
|
|
|
44
46
|
function isDOM(element) {
|
|
45
47
|
return element && element instanceof HTMLElement;
|
|
46
48
|
}
|
|
47
|
-
function addListener(domNode, eventName, handler, capture = false, once = false) {
|
|
48
|
-
let options = { once: false };
|
|
49
|
-
if (capture) {
|
|
50
|
-
options.capture = capture;
|
|
51
|
-
}
|
|
52
|
-
if (once) {
|
|
53
|
-
options.once = once;
|
|
54
|
-
}
|
|
55
|
-
domNode.addEventListener(eventName, handler, options);
|
|
56
|
-
}
|
|
57
|
-
function removeListener(domNode, eventName, handler) {
|
|
58
|
-
domNode.removeEventListener(eventName, handler);
|
|
59
|
-
}
|
|
60
49
|
function add(target, key, element = {}) {
|
|
61
50
|
let node = target;
|
|
62
51
|
if (!node._mc) {
|
|
@@ -69,8 +58,8 @@ function add(target, key, element = {}) {
|
|
|
69
58
|
const _mc = node._mc;
|
|
70
59
|
if (key.length && !_mc[key]) {
|
|
71
60
|
_mc[key] = element;
|
|
72
|
-
if (target instanceof HTMLElement && !target.getAttribute('
|
|
73
|
-
target.setAttribute('
|
|
61
|
+
if (target instanceof HTMLElement && !target.getAttribute('data-mc')) {
|
|
62
|
+
target.setAttribute('data-mc', '');
|
|
74
63
|
}
|
|
75
64
|
}
|
|
76
65
|
return element;
|
|
@@ -84,25 +73,8 @@ function remove(target, key) {
|
|
|
84
73
|
}
|
|
85
74
|
if (!Object.keys(_mc).length &&
|
|
86
75
|
target instanceof HTMLElement &&
|
|
87
|
-
target.hasAttribute('
|
|
88
|
-
target.removeAttribute('
|
|
89
|
-
}
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
function trigger(target, ev, data = {}, bubble = 'l') {
|
|
93
|
-
let _mc = target?._mc;
|
|
94
|
-
if (!_mc)
|
|
95
|
-
return;
|
|
96
|
-
let event = ev instanceof McEvent
|
|
97
|
-
? new McEvent(ev.type, ev.data, 'l')
|
|
98
|
-
: new McEvent(ev, data, 'l'), mcEvent = typeof ev !== 'string' ? ev : new McEvent(ev, data, bubble);
|
|
99
|
-
[...Object.values(_mc)].forEach((mc) => {
|
|
100
|
-
if (mc?.trigger && typeof mc?.trigger === 'function') {
|
|
101
|
-
mc?.trigger(event);
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
if (/[ud]/.test(mcEvent.bubble)) {
|
|
105
|
-
bubbleEvent(target, mcEvent);
|
|
76
|
+
target.hasAttribute('data-mc')) {
|
|
77
|
+
target.removeAttribute('data-mc');
|
|
106
78
|
}
|
|
107
79
|
return;
|
|
108
80
|
}
|
|
@@ -113,6 +85,48 @@ function init(element) {
|
|
|
113
85
|
element.trigger('Init');
|
|
114
86
|
}, 0);
|
|
115
87
|
}
|
|
88
|
+
function getMcEventName(eventName) {
|
|
89
|
+
return '_mc' + eventName[0].toUpperCase() + eventName.substring(1);
|
|
90
|
+
}
|
|
91
|
+
function off(domNode, eventName, handler) {
|
|
92
|
+
domNode.removeEventListener(getMcEventName(eventName), handler);
|
|
93
|
+
}
|
|
94
|
+
function on(domNode, eventName, handler, once = false) {
|
|
95
|
+
domNode.addEventListener(getMcEventName(eventName), handler, { capture: false, once });
|
|
96
|
+
}
|
|
97
|
+
function one(domNode, eventName, handler) {
|
|
98
|
+
on(domNode, eventName, handler, true);
|
|
99
|
+
}
|
|
100
|
+
function trigger(domNode, event, data = {}, bubble = 'l') {
|
|
101
|
+
const ev = typeof event === 'string'
|
|
102
|
+
? new CustomEvent(getMcEventName(event), { detail: { data, bubble } })
|
|
103
|
+
: event;
|
|
104
|
+
if (bubble.length && bubble.indexOf('l') > -1) {
|
|
105
|
+
domNode.dispatchEvent(ev);
|
|
106
|
+
}
|
|
107
|
+
if (/[u|d]/.test(bubble)) {
|
|
108
|
+
bubbleEvent(domNode, ev);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function bubbleEvent(domNode, ev) {
|
|
112
|
+
setTimeout(() => {
|
|
113
|
+
if (ev.detail.bubble.indexOf('l') === -1) {
|
|
114
|
+
ev.detail.bubble += 'l';
|
|
115
|
+
}
|
|
116
|
+
if (ev.detail.bubble.indexOf('u') > -1) {
|
|
117
|
+
domNode.closest('[data-mc]')?.dispatchEvent(ev);
|
|
118
|
+
}
|
|
119
|
+
if (ev.detail.bubble.indexOf('d') > -1) {
|
|
120
|
+
let targets = new Set(domNode._mc
|
|
121
|
+
.children()
|
|
122
|
+
.map((c) => c?.target));
|
|
123
|
+
targets.forEach((target) => {
|
|
124
|
+
if (target)
|
|
125
|
+
DC.trigger(target, ev);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}, 0);
|
|
129
|
+
}
|
|
116
130
|
function autoAttachListeners(element) {
|
|
117
131
|
if (!isBrowser() || element.constructor === DC)
|
|
118
132
|
return;
|
|
@@ -123,117 +137,66 @@ function autoAttachListeners(element) {
|
|
|
123
137
|
.filter((key) => /^on[A-Z]|one[A-Z]/.test(key) &&
|
|
124
138
|
typeof that.constructor.prototype[key] === 'function')
|
|
125
139
|
.forEach((key) => {
|
|
126
|
-
let once = /^one/.test(key), withoutOnOne = key.replace(/^on[e]{0,1}/, ''), nativeEventName = withoutOnOne.toLowerCase()
|
|
127
|
-
|
|
140
|
+
let once = /^one/.test(key), withoutOnOne = key.replace(/^on[e]{0,1}/, ''), nativeEventName = withoutOnOne.toLowerCase();
|
|
141
|
+
let listener = (ev) => {
|
|
142
|
+
that[key](ev);
|
|
128
143
|
};
|
|
129
|
-
if (
|
|
130
|
-
|
|
131
|
-
configurable: true,
|
|
132
|
-
enumerable: false,
|
|
133
|
-
writable: true,
|
|
134
|
-
value: (ev) => {
|
|
135
|
-
that.constructor.prototype[key].bind(that)(ev);
|
|
136
|
-
},
|
|
137
|
-
});
|
|
144
|
+
if (!!target['on' + nativeEventName]) {
|
|
145
|
+
target.addEventListener(nativeEventName, listener);
|
|
138
146
|
}
|
|
139
|
-
|
|
140
|
-
|
|
147
|
+
else {
|
|
148
|
+
on(target, withoutOnOne, listener, once);
|
|
141
149
|
}
|
|
142
150
|
});
|
|
143
151
|
}
|
|
144
152
|
}
|
|
145
|
-
function
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
let parent = traverseNodes(target, '', true)?.[0].target;
|
|
153
|
-
if (parent)
|
|
154
|
-
DC.trigger(parent, ev);
|
|
155
|
-
}
|
|
156
|
-
if (ev.bubble.indexOf('d') > -1) {
|
|
157
|
-
let targets = new Set(target._mc
|
|
158
|
-
.children()
|
|
159
|
-
.map((c) => c?.target));
|
|
160
|
-
targets.forEach((target) => {
|
|
161
|
-
if (target)
|
|
162
|
-
DC.trigger(target, ev);
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
}, 0);
|
|
166
|
-
}
|
|
153
|
+
function getMcChildNodes(domNode) {
|
|
154
|
+
const id = Math.random().toString().replace('.', '');
|
|
155
|
+
const selector = '[data-mc]:not([temp_id="' + id + '"] [data-mc] [data-mc])';
|
|
156
|
+
domNode.setAttribute('temp_id', id);
|
|
157
|
+
const myDomElements = domNode.querySelectorAll(selector);
|
|
158
|
+
domNode.removeAttribute('temp_id');
|
|
159
|
+
return myDomElements;
|
|
167
160
|
}
|
|
168
161
|
class McBase {
|
|
169
|
-
|
|
162
|
+
_target;
|
|
170
163
|
constructor(target, debug = false) {
|
|
171
|
-
let
|
|
172
|
-
this
|
|
164
|
+
let element = this;
|
|
165
|
+
this._target = new WeakRef(target || {});
|
|
173
166
|
init(element);
|
|
174
167
|
autoAttachListeners(element);
|
|
175
168
|
}
|
|
176
169
|
get target() {
|
|
177
|
-
return this
|
|
170
|
+
return this._target.deref();
|
|
178
171
|
}
|
|
179
172
|
}
|
|
180
173
|
class MC extends McBase {
|
|
181
|
-
_mc = {};
|
|
182
174
|
constructor(target) {
|
|
183
175
|
super(target);
|
|
184
176
|
}
|
|
185
177
|
static trigger = trigger;
|
|
186
178
|
trigger(ev, data = {}, bubble = 'l') {
|
|
187
|
-
let that = this;
|
|
188
|
-
if (that.constructor === MC || that.constructor === DC) {
|
|
189
|
-
let event = ev instanceof McEvent
|
|
190
|
-
? new McEvent(ev.type, ev.data, 'l')
|
|
191
|
-
: new McEvent(ev, data, 'l'), mcEvent = typeof ev !== 'string'
|
|
192
|
-
? ev
|
|
193
|
-
: new McEvent(ev, data, bubble);
|
|
194
|
-
[...Object.getOwnPropertyNames(that)].forEach((mc) => {
|
|
195
|
-
if (that[mc]?.trigger &&
|
|
196
|
-
typeof that[mc]?.trigger === 'function') {
|
|
197
|
-
that[mc]?.trigger(event);
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
if (/[ud]/.test(mcEvent.bubble)) {
|
|
201
|
-
bubbleEvent(that.target, mcEvent);
|
|
202
|
-
}
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
if (that instanceof MC || that instanceof DC) {
|
|
206
|
-
const that = this, mcEvent = typeof ev !== 'string'
|
|
207
|
-
? ev
|
|
208
|
-
: new McEvent(ev, data, bubble), handlerName = 'on' + mcEvent.type[0].toUpperCase() + mcEvent.type.slice(1);
|
|
209
|
-
if (mcEvent.bubble.indexOf('l') > -1) {
|
|
210
|
-
if (!mcEvent.immediateStopped &&
|
|
211
|
-
typeof that[handlerName] === 'function') {
|
|
212
|
-
that[handlerName](mcEvent);
|
|
213
|
-
if (that.hasOwnProperty(handlerName)) {
|
|
214
|
-
delete that[handlerName];
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
if (mcEvent.stopped || mcEvent.bubble === 'l') {
|
|
219
|
-
return that;
|
|
220
|
-
}
|
|
221
|
-
if (/[ud]/.test(mcEvent.bubble)) {
|
|
222
|
-
bubbleEvent(that.target, mcEvent);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
179
|
}
|
|
226
180
|
}
|
|
227
181
|
class DC extends McBase {
|
|
228
|
-
_mc = {};
|
|
229
182
|
constructor(target, debug = false) {
|
|
230
183
|
super(target);
|
|
231
184
|
}
|
|
232
185
|
static add = add;
|
|
233
186
|
static remove = remove;
|
|
234
187
|
static trigger = trigger;
|
|
235
|
-
|
|
236
|
-
|
|
188
|
+
off(eventName, handler) {
|
|
189
|
+
off(this.target, eventName, handler);
|
|
190
|
+
}
|
|
191
|
+
on(eventName, handler) {
|
|
192
|
+
on(this.target, eventName, handler);
|
|
193
|
+
}
|
|
194
|
+
one(eventName, handler) {
|
|
195
|
+
one(this.target, eventName, handler);
|
|
196
|
+
}
|
|
197
|
+
trigger(ev, data = {}, bubble = 'l') {
|
|
198
|
+
if (typeof ev === 'string') {
|
|
199
|
+
}
|
|
237
200
|
}
|
|
238
201
|
parent(search = '') {
|
|
239
202
|
let target = this.target;
|
|
@@ -251,109 +214,83 @@ class DC extends McBase {
|
|
|
251
214
|
let target = this?.target;
|
|
252
215
|
if (!isDOM(target))
|
|
253
216
|
return [];
|
|
254
|
-
const
|
|
255
|
-
const selector = '[_mc]:not([temp_id="' + id + '"] [_mc] [_mc])';
|
|
256
|
-
target.setAttribute('temp_id', id);
|
|
257
|
-
const myDomElements = target.querySelectorAll(selector);
|
|
217
|
+
const myDomElements = getMcChildNodes(target);
|
|
258
218
|
const mcValues = getMicroComponents([...myDomElements], search);
|
|
259
|
-
target.removeAttribute('temp_id');
|
|
260
219
|
return mcValues;
|
|
261
220
|
}
|
|
262
221
|
descendants(search = '') {
|
|
263
222
|
let target = this?.target;
|
|
264
223
|
if (!isDOM(target))
|
|
265
224
|
return [];
|
|
266
|
-
const myDomElements = target.querySelectorAll('*[
|
|
225
|
+
const myDomElements = target.querySelectorAll('*[data-mc]');
|
|
267
226
|
return getMicroComponents([...myDomElements], search);
|
|
268
227
|
}
|
|
269
228
|
}
|
|
270
|
-
const
|
|
271
|
-
|
|
229
|
+
const loadingDCs = new Set();
|
|
230
|
+
function attachDC(element) {
|
|
231
|
+
return () => {
|
|
232
|
+
const elements = Array
|
|
233
|
+
.from(document.querySelectorAll(`[data-mc*="${element}"]`))
|
|
234
|
+
.filter(element => element instanceof HTMLElement);
|
|
235
|
+
if (elements.length === 0)
|
|
236
|
+
return;
|
|
237
|
+
const klass = customElements.get(element);
|
|
238
|
+
elements.forEach((node) => {
|
|
239
|
+
DC.add(node, klass.name, new klass(node));
|
|
240
|
+
const new_mc = node
|
|
241
|
+
.getAttribute('data-mc')
|
|
242
|
+
.split(' ')
|
|
243
|
+
.filter((name) => name !== element && name !== '')
|
|
244
|
+
.join(' ')
|
|
245
|
+
.trim();
|
|
246
|
+
node.setAttribute('data-mc', new_mc);
|
|
247
|
+
});
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
;
|
|
272
251
|
function makeLoadScript(element) {
|
|
252
|
+
if (loadingDCs.has(element))
|
|
253
|
+
return;
|
|
254
|
+
loadingDCs.add(element);
|
|
273
255
|
const fileName = './' + element.split('-').join('/') + '.js';
|
|
274
256
|
const se = document.createElement('script');
|
|
275
257
|
se.setAttribute('src', fileName);
|
|
276
258
|
se.setAttribute('blocking', 'render');
|
|
277
259
|
se.async = true;
|
|
278
260
|
se.setAttribute('type', 'module');
|
|
279
|
-
se.setAttribute('name', element);
|
|
261
|
+
se.setAttribute('data-name', element);
|
|
280
262
|
se.setAttribute('loading', '');
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
263
|
+
const loadedPromise = customElements.whenDefined(element);
|
|
264
|
+
loadedPromise.then(attachDC(element));
|
|
265
|
+
se.addEventListener('load', (ev) => {
|
|
266
|
+
loadingDCs.delete(element);
|
|
267
|
+
document.head.querySelector(`script[data-name="${element}"]`)?.remove();
|
|
284
268
|
});
|
|
285
|
-
|
|
286
|
-
console.error('could not load
|
|
269
|
+
se.addEventListener('error', (ev) => {
|
|
270
|
+
console.error('could not load DC code from', fileName);
|
|
287
271
|
});
|
|
288
|
-
|
|
272
|
+
document.head.append(se);
|
|
289
273
|
}
|
|
290
|
-
function
|
|
291
|
-
setTimeout(function () {
|
|
292
|
-
const importFileName = script.getAttribute('src');
|
|
293
|
-
const elementName = script.getAttribute('name');
|
|
294
|
-
const se = document.createElement('script');
|
|
295
|
-
se.async = true;
|
|
296
|
-
se.setAttribute('type', 'module');
|
|
297
|
-
const code = `
|
|
298
|
-
|
|
299
|
-
import _ from "${importFileName}";
|
|
300
|
-
import { DC } from "./microcomponents.js";
|
|
301
|
-
|
|
302
|
-
const elements = Array.from(document.querySelectorAll('[_mc*="${elementName}"]')).filter( element => element instanceof HTMLElement );
|
|
303
|
-
|
|
304
|
-
elements.forEach((element) => {
|
|
305
|
-
// add class to MCs repository
|
|
306
|
-
autoload.state.MCs.set( '${elementName}', _ );
|
|
307
|
-
// add instance to HTMLElement
|
|
308
|
-
DC.add(element, _.name, new _(element));
|
|
309
|
-
// remove instance name from elements "_mc" attribute
|
|
310
|
-
element.setAttribute('_mc', element.getAttribute('_mc').replace('${elementName}', '').replace( /\w\w/g, ' ').trim());
|
|
311
|
-
});
|
|
312
|
-
|
|
313
|
-
setTimeout( () => {
|
|
314
|
-
document.body.querySelector('script[name="${elementName}]"')?.remove();
|
|
315
|
-
},0);
|
|
316
|
-
|
|
317
|
-
`;
|
|
318
|
-
se.innerHTML = code;
|
|
319
|
-
document.body.append(se);
|
|
320
|
-
}, 0);
|
|
321
|
-
}
|
|
322
|
-
function loadUndefinedMicroComponents() {
|
|
274
|
+
function loadUndefinedMCs() {
|
|
323
275
|
[...document.querySelectorAll(':not(:defined)')]
|
|
324
276
|
.filter((element) => !!element
|
|
325
277
|
&& !customElements.get(element.tagName.toLowerCase())
|
|
326
|
-
&& !
|
|
278
|
+
&& !loadingDCs.has(element.tagName.toLowerCase()))
|
|
327
279
|
.forEach((el) => {
|
|
328
|
-
|
|
329
|
-
const se = makeLoadScript(elementName);
|
|
330
|
-
addListener(se, 'load', () => {
|
|
331
|
-
CEs.set(elementName, customElements.get(el.tagName.toLowerCase()));
|
|
332
|
-
});
|
|
333
|
-
CEs.set(elementName, 'loading');
|
|
334
|
-
document.head.append(se);
|
|
280
|
+
makeLoadScript(el.tagName.toLowerCase());
|
|
335
281
|
});
|
|
336
|
-
[...document.querySelectorAll('[
|
|
282
|
+
[...document.querySelectorAll('[data-mc]:not([data-mc=""]')]
|
|
337
283
|
.filter((element) => !!element)
|
|
338
284
|
.forEach((el) => {
|
|
339
|
-
const
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
elementsAlreadyLoaded?.forEach(elementName => {
|
|
349
|
-
setTimeout(() => {
|
|
350
|
-
DC.add(el, elementName, new (autoload.state.MCs.get(elementName))(el));
|
|
351
|
-
const newAttribute = el.getAttribute('_mc')
|
|
352
|
-
.replace('${elementName}', '')
|
|
353
|
-
.replace(/\w\w/g, ' ')
|
|
354
|
-
.trim() || '_mc';
|
|
355
|
-
el.setAttribute('_mc');
|
|
356
|
-
}, 5);
|
|
285
|
+
const _mc = el.getAttribute('data-mc')?.split(' ').filter(name => name !== '');
|
|
286
|
+
_mc?.forEach(element => {
|
|
287
|
+
const isDefined = customElements.get(element);
|
|
288
|
+
if (!loadingDCs.has(element) && !isDefined) {
|
|
289
|
+
makeLoadScript(element);
|
|
290
|
+
}
|
|
291
|
+
else if (isDefined) {
|
|
292
|
+
attachDC(element)();
|
|
293
|
+
}
|
|
357
294
|
});
|
|
358
295
|
});
|
|
359
296
|
}
|
|
@@ -366,14 +303,14 @@ function autoload(enable = true) {
|
|
|
366
303
|
return autoloadEnabled;
|
|
367
304
|
}
|
|
368
305
|
autoloadEnabled = enable;
|
|
369
|
-
observer = new MutationObserver(
|
|
306
|
+
observer = new MutationObserver(loadUndefinedMCs);
|
|
370
307
|
setTimeout(() => {
|
|
371
308
|
observer.observe(document.body, { childList: true, subtree: true });
|
|
372
|
-
|
|
309
|
+
loadUndefinedMCs();
|
|
373
310
|
}, 5);
|
|
374
311
|
window.autoload = window.autoload || autoload;
|
|
375
312
|
return autoloadEnabled;
|
|
376
313
|
}
|
|
377
|
-
autoload.state =
|
|
378
|
-
export {
|
|
314
|
+
autoload.state = loadingDCs;
|
|
315
|
+
export { McBase, MC, DC, autoload, on, one, off, trigger };
|
|
379
316
|
//# sourceMappingURL=MC.js.map
|