@twobirds/microcomponents 0.0.21 → 0.0.22

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 (122) hide show
  1. package/.gitlab-ci.yml +1 -0
  2. package/README.md +31 -12
  3. package/assets/documentation/MicroComponents.md +228 -0
  4. package/assets/my-tag.css +4 -0
  5. package/assets/test.html +5 -1
  6. package/dist/MC.d.ts +32 -0
  7. package/dist/MC.d.ts.map +1 -0
  8. package/dist/MC.min.js +414 -0
  9. package/dist/MC.ts +350 -0
  10. package/dist/MCbundle.d.ts +8 -0
  11. package/dist/MCbundle.d.ts.map +1 -0
  12. package/dist/MCbundle.min.js +1 -0
  13. package/dist/MCbundle.ts +8 -0
  14. package/dist/McEvent.d.ts +15 -0
  15. package/dist/McEvent.d.ts.map +1 -0
  16. package/dist/McEvent.ts +96 -0
  17. package/dist/autoloader.d.ts +2 -0
  18. package/dist/autoloader.d.ts.map +1 -0
  19. package/dist/autoloader.ts +98 -0
  20. package/dist/customElements.d.ts +5 -0
  21. package/dist/customElements.d.ts.map +1 -0
  22. package/dist/customElements.min.js +1 -0
  23. package/dist/customElements.ts +67 -0
  24. package/dist/customObservables.d.ts +3 -0
  25. package/dist/customObservables.d.ts.map +1 -0
  26. package/dist/customObservables.min.js +1 -0
  27. package/dist/customObservables.ts +340 -0
  28. package/dist/customSelectors.d.ts +108 -0
  29. package/dist/customSelectors.d.ts.map +1 -0
  30. package/dist/customSelectors.min.js +1 -0
  31. package/dist/customSelectors.ts +1634 -0
  32. package/dist/formValues.d.ts +4 -0
  33. package/dist/formValues.d.ts.map +1 -0
  34. package/dist/formValues.ts +275 -0
  35. package/dist/formvValues.min.js +1 -0
  36. package/dist/helpers.d.ts +11 -0
  37. package/dist/helpers.d.ts.map +1 -0
  38. package/dist/helpers.ts +173 -0
  39. package/dist/microcomponents.es3.d.ts +1 -20
  40. package/dist/microcomponents.es3.d.ts.map +1 -1
  41. package/dist/test.d.ts +2 -0
  42. package/dist/test.d.ts.map +1 -0
  43. package/package.json +11 -7
  44. package/public/MC.js +273 -0
  45. package/public/MC.min.js +414 -0
  46. package/public/MCbundle.js +8 -0
  47. package/public/MCbundle.min.js +1 -0
  48. package/public/McEvent.js +74 -0
  49. package/public/MicroComponents.svg +15 -0
  50. package/public/assets/search.js +1 -1
  51. package/public/autoloader.js +57 -0
  52. package/public/classes/MC.DC.html +247 -0
  53. package/public/classes/MC.MC.html +150 -0
  54. package/public/classes/MC.McBase.html +123 -0
  55. package/public/classes/MCbundle.McEvent.html +184 -0
  56. package/public/customElements.js +48 -0
  57. package/public/customElements.min.js +1 -0
  58. package/public/customObservables.js +255 -0
  59. package/public/customObservables.min.js +1 -0
  60. package/public/customSelectors.js +1088 -0
  61. package/public/customSelectors.min.js +1 -0
  62. package/public/documentation/MicroComponents.md +228 -0
  63. package/public/formValues.js +211 -0
  64. package/public/formvValues.min.js +1 -0
  65. package/public/functions/MC.addListener.html +73 -0
  66. package/public/functions/MC.removeListener.html +69 -0
  67. package/public/functions/MCbundle._d.html +85 -0
  68. package/public/functions/MCbundle._t.html +85 -0
  69. package/public/functions/MCbundle.debounce.html +85 -0
  70. package/public/functions/MCbundle.deepEqual.html +85 -0
  71. package/public/functions/MCbundle.defineCE.html +98 -0
  72. package/public/functions/MCbundle.formValues.html +89 -0
  73. package/public/functions/MCbundle.getCE.html +83 -0
  74. package/public/functions/MCbundle.htmlToElements.html +83 -0
  75. package/public/functions/MCbundle.isObject.html +83 -0
  76. package/public/functions/MCbundle.kebabToPascal.html +83 -0
  77. package/public/functions/MCbundle.makeCO.html +85 -0
  78. package/public/functions/MCbundle.nameSpace.html +89 -0
  79. package/public/functions/MCbundle.parse.html +85 -0
  80. package/public/helpers.js +128 -0
  81. package/public/index.html +22 -13
  82. package/public/interfaces/MC.HTMLMcElement.html +3605 -0
  83. package/public/interfaces/MCbundle.DSelector.html +1010 -0
  84. package/public/interfaces/MCbundle.LooseObject.html +80 -0
  85. package/public/interfaces/MCbundle.TSelector.html +709 -0
  86. package/public/microcomponents.es3.js +348 -0
  87. package/public/modules/MC.html +84 -0
  88. package/public/modules/MCbundle.html +133 -0
  89. package/public/modules.html +4 -4
  90. package/public/my-tag.css +4 -0
  91. package/public/test.html +5 -1
  92. package/public/test.js +100 -202
  93. package/public/types/MCbundle.selection.html +74 -0
  94. package/public/types/MCbundle.singleSelector.html +74 -0
  95. package/src/MC.ts +350 -0
  96. package/src/MCbundle.ts +8 -0
  97. package/src/McEvent.ts +96 -0
  98. package/src/autoloader.ts +98 -0
  99. package/src/customElements.ts +67 -0
  100. package/src/customObservables.ts +340 -0
  101. package/src/customSelectors.ts +1634 -0
  102. package/src/formValues.ts +275 -0
  103. package/src/helpers.ts +173 -0
  104. package/src/microcomponents.es3.js +353 -82
  105. package/src/test.js +137 -218
  106. package/tsconfig.json +2 -2
  107. package/typedoc.json +1 -1
  108. package/webpack.config.js +233 -0
  109. package/dist/microcomponents.d.ts +0 -26
  110. package/dist/microcomponents.d.ts.map +0 -1
  111. package/dist/microcomponents.es3.js +0 -96
  112. package/dist/microcomponents.es3.min.js +0 -15
  113. package/dist/microcomponents.js +0 -176
  114. package/dist/microcomponents.min.js +0 -38
  115. package/dist/microcomponents.ts +0 -216
  116. package/public/classes/microcomponents.MC.html +0 -313
  117. package/public/classes/microcomponents_es3.MC.html +0 -336
  118. package/public/functions/microcomponents_es3.__isEmpty.html +0 -60
  119. package/public/microcomponents.js +0 -176
  120. package/public/modules/microcomponents.html +0 -57
  121. package/public/modules/microcomponents_es3.html +0 -60
  122. package/src/microcomponents.ts +0 -216
@@ -1,176 +0,0 @@
1
- 'use strict';
2
- /*
3
- helper methods
4
- */
5
- // get all microcomponents from a list of HTMLElements
6
- function getMicroComponents(elements, search) {
7
- let mcValues = [];
8
- elements.forEach(e => {
9
- if (e) {
10
- if (e instanceof HTMLElement) {
11
- const _mc = e?._mc;
12
- if (!search && _mc) {
13
- mcValues = mcValues.concat(Object.values(e._mc));
14
- }
15
- else if (search && _mc && _mc[search]) {
16
- mcValues.push(_mc[search]);
17
- }
18
- }
19
- }
20
- });
21
- return mcValues;
22
- }
23
- // get all ancestor DOM nodes up to the document
24
- function traverseNodes(node, search, firstonly = true) {
25
- let mcValues = [];
26
- while (node) {
27
- if (node._mc) {
28
- if (!search) {
29
- mcValues = mcValues.concat(Object.values(node._mc));
30
- }
31
- else if (search && node._mc[search]) {
32
- mcValues.push(node._mc[search]);
33
- }
34
- if (firstonly)
35
- return mcValues;
36
- }
37
- node = node.parentNode;
38
- }
39
- return mcValues;
40
- }
41
- function isDOM(element) {
42
- return element && element instanceof HTMLElement;
43
- }
44
- export class MC {
45
- #target = {};
46
- #_mc = {};
47
- static debug = false;
48
- constructor(target) {
49
- this.#target = target;
50
- this.#_mc = {};
51
- }
52
- get _mc() {
53
- if (!MC.debug)
54
- return undefined;
55
- return this.#_mc;
56
- }
57
- get target() {
58
- return this.#target;
59
- }
60
- // return all top-level micro components from an HTMLElement, or the searched one
61
- static siblings(target, search = '') {
62
- const mc = target;
63
- if (!mc._mc) {
64
- return [];
65
- }
66
- const _mc = mc._mc;
67
- if (search.length) {
68
- return _mc?.[search] || [];
69
- }
70
- return [...Object.values(_mc)];
71
- }
72
- // add a microcomponent to a target DOM node
73
- static add(target, key, element = {}) {
74
- let node = target;
75
- // create the _mc property if necessary
76
- if (!node._mc) {
77
- node._mc = new MC(target);
78
- }
79
- const _mc = node._mc;
80
- // add the element with the given property key to the _mc property
81
- if (key.length && !_mc[key]) {
82
- _mc[key] = element;
83
- // add attribute if HTMLElement
84
- if (target instanceof HTMLElement) {
85
- target.setAttribute('_mc', '');
86
- }
87
- }
88
- return element;
89
- }
90
- // remove a micro component from the DOM
91
- static remove(target, key) {
92
- if (!key)
93
- return; // silent fail
94
- const _mc = target?._mc || {};
95
- // delete the property from the HTMLElement _mc collection
96
- if (_mc && _mc[key]) {
97
- delete _mc[key];
98
- }
99
- // remove the _mc attribute if the DOM collection is empty
100
- if (!Object.keys(_mc).length && target instanceof HTMLElement && target.hasAttribute('_mc')) {
101
- target.removeAttribute('_mc');
102
- }
103
- return;
104
- }
105
- // add a microcomponent to the collection
106
- add(key, element, target) {
107
- if (this.#_mc[key])
108
- return;
109
- // if target parameter exists ( a DOM node )
110
- // you want a top level (public) MC
111
- if (target) {
112
- // ... add the new micro component to the DOM node _mc
113
- MC.add(target, key, element);
114
- }
115
- // add the new micro component to the private collection anyway
116
- this.#_mc[key] = element;
117
- return element;
118
- }
119
- // remove a micro component from the collection
120
- remove(key, target) {
121
- const _mc = this.#_mc;
122
- const t = target;
123
- // if target parameter exists ( a DOM node )
124
- // you want to remove a top level (public) MC
125
- if (target) {
126
- // ... remove the new micro component from the DOM node _mc
127
- MC.remove(t, key);
128
- }
129
- // remove the new micro component from the private collection anyway
130
- delete _mc?.[key];
131
- }
132
- // return all micro components from the collection, or the searched one
133
- // in a top level DOM MC, this refers to the inner collection always
134
- // use MC.siblings() to get the public MCs
135
- siblings(search = '') {
136
- const _mc = this.#_mc;
137
- if (!_mc)
138
- return [];
139
- const result = _mc[search || ''];
140
- return search && result ? [result] : [...Object.values(_mc)];
141
- }
142
- /*
143
- the following selectors will only work for the DOM top level MCs and return [] otherwise
144
- */
145
- // first anchestor DOM node, all public MCs
146
- parent(search = '') {
147
- if (!isDOM(this.#target))
148
- return [];
149
- return traverseNodes(this.#target.parentNode, search, true);
150
- }
151
- // all anchestor DOM nodes, beginning with the closest, all public MCs
152
- parents(search = '') {
153
- if (!isDOM(this.#target))
154
- return [];
155
- return traverseNodes(this.#target.parentNode, search, false);
156
- }
157
- // nearest child DOM nodes, all puclic MCs
158
- children(search = '') {
159
- if (!isDOM(this.#target))
160
- return [];
161
- const id = Math.random().toString().replace('.', '');
162
- const selector = '[_mc]:not([temp_id="' + id + '"] [_mc] [_mc])'; // HOTFIX: minifier or tsc compiler error, dont use backtick string, cuts out blanks
163
- this.#target.setAttribute('temp_id', id);
164
- const myDomElements = this.#target.querySelectorAll(selector);
165
- const mcValues = getMicroComponents([...myDomElements], search);
166
- this.#target.removeAttribute('temp_id');
167
- return mcValues;
168
- }
169
- // all descendant DOM nodes, all puclic MCs
170
- descendants(search = '') {
171
- if (!isDOM(this.#target))
172
- return [];
173
- const myDomElements = this.#target.querySelectorAll('*[_mc]');
174
- return getMicroComponents([...myDomElements], search);
175
- }
176
- }
@@ -1,57 +0,0 @@
1
- <!DOCTYPE html><html class="default" lang="en"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>microcomponents | Micro Components</title><meta name="description" content="Documentation for Micro Components"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script async src="../assets/search.js" id="search-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"</script><header class="tsd-page-toolbar">
2
- <div class="tsd-toolbar-contents container">
3
- <div class="table-cell" id="tsd-search" data-base="..">
4
- <div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><path d="M15.7824 13.833L12.6666 10.7177C12.5259 10.5771 12.3353 10.499 12.1353 10.499H11.6259C12.4884 9.39596 13.001 8.00859 13.001 6.49937C13.001 2.90909 10.0914 0 6.50048 0C2.90959 0 0 2.90909 0 6.49937C0 10.0896 2.90959 12.9987 6.50048 12.9987C8.00996 12.9987 9.39756 12.4863 10.5008 11.6239V12.1332C10.5008 12.3332 10.5789 12.5238 10.7195 12.6644L13.8354 15.7797C14.1292 16.0734 14.6042 16.0734 14.8948 15.7797L15.7793 14.8954C16.0731 14.6017 16.0731 14.1267 15.7824 13.833ZM6.50048 10.499C4.29094 10.499 2.50018 8.71165 2.50018 6.49937C2.50018 4.29021 4.28781 2.49976 6.50048 2.49976C8.71001 2.49976 10.5008 4.28708 10.5008 6.49937C10.5008 8.70852 8.71314 10.499 6.50048 10.499Z" fill="var(--color-text)"></path></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div>
5
- <div class="field">
6
- <div id="tsd-toolbar-links"></div></div>
7
- <ul class="results">
8
- <li class="state loading">Preparing search index...</li>
9
- <li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">Micro Components</a></div>
10
- <div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><rect x="1" y="3" width="14" height="2" fill="var(--color-text)"></rect><rect x="1" y="7" width="14" height="2" fill="var(--color-text)"></rect><rect x="1" y="11" width="14" height="2" fill="var(--color-text)"></rect></svg></a></div></div></header>
11
- <div class="container container-main">
12
- <div class="col-8 col-content">
13
- <div class="tsd-page-title">
14
- <ul class="tsd-breadcrumb">
15
- <li><a href="../modules.html">Micro Components</a></li>
16
- <li><a href="microcomponents.html">microcomponents</a></li></ul>
17
- <h1>Module microcomponents</h1></div><aside class="tsd-sources">
18
- <ul>
19
- <li>Defined in <a href="https://gitlab.com/twoBirds/microcomponents/-/blob/7c25a6b/src/microcomponents.ts#L1">microcomponents.ts:1</a></li></ul></aside>
20
- <section class="tsd-panel-group">
21
- <section class="tsd-panel tsd-typography"></section></section>
22
- <section class="tsd-panel-group tsd-index-group">
23
- <section class="tsd-panel tsd-index-panel">
24
- <h3 class="tsd-index-heading uppercase">Index</h3>
25
- <section class="tsd-index-section">
26
- <h3 class="tsd-index-heading">Classes</h3>
27
- <div class="tsd-index-list"><a href="../classes/microcomponents.MC.html" class="tsd-index-link tsd-kind-class tsd-parent-kind-module"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-class)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6" id="icon-128-path"></rect><path d="M11.898 16.1201C11.098 16.1201 10.466 15.8961 10.002 15.4481C9.53803 15.0001 9.30603 14.3841 9.30603 13.6001V9.64012C9.30603 8.85612 9.53803 8.24012 10.002 7.79212C10.466 7.34412 11.098 7.12012 11.898 7.12012C12.682 7.12012 13.306 7.34812 13.77 7.80412C14.234 8.25212 14.466 8.86412 14.466 9.64012H13.386C13.386 9.14412 13.254 8.76412 12.99 8.50012C12.734 8.22812 12.37 8.09212 11.898 8.09212C11.426 8.09212 11.054 8.22412 10.782 8.48812C10.518 8.75212 10.386 9.13212 10.386 9.62812V13.6001C10.386 14.0961 10.518 14.4801 10.782 14.7521C11.054 15.0161 11.426 15.1481 11.898 15.1481C12.37 15.1481 12.734 15.0161 12.99 14.7521C13.254 14.4801 13.386 14.0961 13.386 13.6001H14.466C14.466 14.3761 14.234 14.9921 13.77 15.4481C13.306 15.8961 12.682 16.1201 11.898 16.1201Z" fill="var(--color-text)" id="icon-128-text"></path></svg><span>MC</span></a>
28
- </div></section></section></section></div>
29
- <div class="col-4 col-menu menu-sticky-wrap menu-highlight">
30
- <div class="tsd-navigation settings">
31
- <details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
32
- <h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M4.93896 8.531L12 15.591L19.061 8.531L16.939 6.409L12 11.349L7.06098 6.409L4.93896 8.531Z" fill="var(--color-text)"></path></svg> Settings</h3></summary>
33
- <div class="tsd-accordion-details">
34
- <div class="tsd-filter-visibility">
35
- <h4 class="uppercase">Member Visibility</h4><form>
36
- <ul id="tsd-filter-options">
37
- <li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li>
38
- <li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-private" name="private"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Private</span></label></li>
39
- <li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li>
40
- <li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></form></div>
41
- <div class="tsd-theme-toggle">
42
- <h4 class="uppercase">Theme</h4><select id="theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div>
43
- <nav class="tsd-navigation primary">
44
- <details class="tsd-index-accordion" open><summary class="tsd-accordion-summary">
45
- <h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M4.93896 8.531L12 15.591L19.061 8.531L16.939 6.409L12 11.349L7.06098 6.409L4.93896 8.531Z" fill="var(--color-text)"></path></svg> Modules</h3></summary>
46
- <div class="tsd-accordion-details">
47
- <ul>
48
- <li class="current"><a href="../modules.html">Micro <wbr/>Components</a>
49
- <ul>
50
- <li class="current selected tsd-kind-module"><a href="microcomponents.html">microcomponents</a></li>
51
- <li class="tsd-kind-module"><a href="microcomponents_es3.html">microcomponents.es3</a></li></ul></li></ul></div></details></nav>
52
- <nav class="tsd-navigation secondary menu-sticky">
53
- <ul>
54
- <li class="tsd-kind-class tsd-parent-kind-module"><a href="../classes/microcomponents.MC.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>MC</a></li></ul></nav></div></div>
55
- <div class="container tsd-generator">
56
- <p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div>
57
- <div class="overlay"></div><script src="../assets/main.js"></script></body></html>
@@ -1,60 +0,0 @@
1
- <!DOCTYPE html><html class="default" lang="en"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>microcomponents.es3 | Micro Components</title><meta name="description" content="Documentation for Micro Components"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script async src="../assets/search.js" id="search-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"</script><header class="tsd-page-toolbar">
2
- <div class="tsd-toolbar-contents container">
3
- <div class="table-cell" id="tsd-search" data-base="..">
4
- <div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><path d="M15.7824 13.833L12.6666 10.7177C12.5259 10.5771 12.3353 10.499 12.1353 10.499H11.6259C12.4884 9.39596 13.001 8.00859 13.001 6.49937C13.001 2.90909 10.0914 0 6.50048 0C2.90959 0 0 2.90909 0 6.49937C0 10.0896 2.90959 12.9987 6.50048 12.9987C8.00996 12.9987 9.39756 12.4863 10.5008 11.6239V12.1332C10.5008 12.3332 10.5789 12.5238 10.7195 12.6644L13.8354 15.7797C14.1292 16.0734 14.6042 16.0734 14.8948 15.7797L15.7793 14.8954C16.0731 14.6017 16.0731 14.1267 15.7824 13.833ZM6.50048 10.499C4.29094 10.499 2.50018 8.71165 2.50018 6.49937C2.50018 4.29021 4.28781 2.49976 6.50048 2.49976C8.71001 2.49976 10.5008 4.28708 10.5008 6.49937C10.5008 8.70852 8.71314 10.499 6.50048 10.499Z" fill="var(--color-text)"></path></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div>
5
- <div class="field">
6
- <div id="tsd-toolbar-links"></div></div>
7
- <ul class="results">
8
- <li class="state loading">Preparing search index...</li>
9
- <li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">Micro Components</a></div>
10
- <div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><rect x="1" y="3" width="14" height="2" fill="var(--color-text)"></rect><rect x="1" y="7" width="14" height="2" fill="var(--color-text)"></rect><rect x="1" y="11" width="14" height="2" fill="var(--color-text)"></rect></svg></a></div></div></header>
11
- <div class="container container-main">
12
- <div class="col-8 col-content">
13
- <div class="tsd-page-title">
14
- <ul class="tsd-breadcrumb">
15
- <li><a href="../modules.html">Micro Components</a></li>
16
- <li><a href="microcomponents_es3.html">microcomponents.es3</a></li></ul>
17
- <h1>Module microcomponents.es3</h1></div>
18
- <section class="tsd-panel-group">
19
- <section class="tsd-panel tsd-typography"></section></section>
20
- <section class="tsd-panel-group tsd-index-group">
21
- <section class="tsd-panel tsd-index-panel">
22
- <h3 class="tsd-index-heading uppercase">Index</h3>
23
- <section class="tsd-index-section">
24
- <h3 class="tsd-index-heading">Classes</h3>
25
- <div class="tsd-index-list"><a href="../classes/microcomponents_es3.MC.html" class="tsd-index-link tsd-kind-class tsd-parent-kind-module"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-class)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6" id="icon-128-path"></rect><path d="M11.898 16.1201C11.098 16.1201 10.466 15.8961 10.002 15.4481C9.53803 15.0001 9.30603 14.3841 9.30603 13.6001V9.64012C9.30603 8.85612 9.53803 8.24012 10.002 7.79212C10.466 7.34412 11.098 7.12012 11.898 7.12012C12.682 7.12012 13.306 7.34812 13.77 7.80412C14.234 8.25212 14.466 8.86412 14.466 9.64012H13.386C13.386 9.14412 13.254 8.76412 12.99 8.50012C12.734 8.22812 12.37 8.09212 11.898 8.09212C11.426 8.09212 11.054 8.22412 10.782 8.48812C10.518 8.75212 10.386 9.13212 10.386 9.62812V13.6001C10.386 14.0961 10.518 14.4801 10.782 14.7521C11.054 15.0161 11.426 15.1481 11.898 15.1481C12.37 15.1481 12.734 15.0161 12.99 14.7521C13.254 14.4801 13.386 14.0961 13.386 13.6001H14.466C14.466 14.3761 14.234 14.9921 13.77 15.4481C13.306 15.8961 12.682 16.1201 11.898 16.1201Z" fill="var(--color-text)" id="icon-128-text"></path></svg><span>MC</span></a>
26
- </div></section>
27
- <section class="tsd-index-section">
28
- <h3 class="tsd-index-heading">Functions</h3>
29
- <div class="tsd-index-list"><a href="../functions/microcomponents_es3.__isEmpty.html" class="tsd-index-link tsd-kind-function tsd-parent-kind-module"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-function)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6" id="icon-64-path"></rect><path d="M9.39 16V7.24H14.55V8.224H10.446V11.128H14.238V12.112H10.47V16H9.39Z" fill="var(--color-text)" id="icon-64-text"></path></svg><span>__is<wbr/>Empty</span></a>
30
- </div></section></section></section></div>
31
- <div class="col-4 col-menu menu-sticky-wrap menu-highlight">
32
- <div class="tsd-navigation settings">
33
- <details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
34
- <h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M4.93896 8.531L12 15.591L19.061 8.531L16.939 6.409L12 11.349L7.06098 6.409L4.93896 8.531Z" fill="var(--color-text)"></path></svg> Settings</h3></summary>
35
- <div class="tsd-accordion-details">
36
- <div class="tsd-filter-visibility">
37
- <h4 class="uppercase">Member Visibility</h4><form>
38
- <ul id="tsd-filter-options">
39
- <li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li>
40
- <li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-private" name="private"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Private</span></label></li>
41
- <li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li>
42
- <li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></form></div>
43
- <div class="tsd-theme-toggle">
44
- <h4 class="uppercase">Theme</h4><select id="theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div>
45
- <nav class="tsd-navigation primary">
46
- <details class="tsd-index-accordion" open><summary class="tsd-accordion-summary">
47
- <h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M4.93896 8.531L12 15.591L19.061 8.531L16.939 6.409L12 11.349L7.06098 6.409L4.93896 8.531Z" fill="var(--color-text)"></path></svg> Modules</h3></summary>
48
- <div class="tsd-accordion-details">
49
- <ul>
50
- <li class="current"><a href="../modules.html">Micro <wbr/>Components</a>
51
- <ul>
52
- <li class="tsd-kind-module"><a href="microcomponents.html">microcomponents</a></li>
53
- <li class="current selected tsd-kind-module"><a href="microcomponents_es3.html">microcomponents.es3</a></li></ul></li></ul></div></details></nav>
54
- <nav class="tsd-navigation secondary menu-sticky">
55
- <ul>
56
- <li class="tsd-kind-class tsd-parent-kind-module"><a href="../classes/microcomponents_es3.MC.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>MC</a></li>
57
- <li class="tsd-kind-function tsd-parent-kind-module"><a href="../functions/microcomponents_es3.__isEmpty.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-64-path"></use><use href="#icon-64-text"></use></svg>__is<wbr/>Empty</a></li></ul></nav></div></div>
58
- <div class="container tsd-generator">
59
- <p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div>
60
- <div class="overlay"></div><script src="../assets/main.js"></script></body></html>
@@ -1,216 +0,0 @@
1
- 'use strict';
2
-
3
- /*
4
- helper methods
5
- */
6
-
7
- // get all microcomponents from a list of HTMLElements
8
- function getMicroComponents( elements: any[], search: string): any[] {
9
- let mcValues: any[] = [];
10
-
11
- elements.forEach( e => {
12
- if (e) {
13
- if (e instanceof HTMLElement) {
14
- const _mc = ( e as any )?._mc;
15
- if ( !search && _mc ) {
16
- mcValues = mcValues.concat(Object.values(( e as any )._mc));
17
- }
18
- else if ( search && _mc && _mc[search] ) {
19
- mcValues.push( _mc[search] );
20
- }
21
- }
22
- }
23
- });
24
- return mcValues;
25
- }
26
-
27
- // get all ancestor DOM nodes up to the document
28
- function traverseNodes(node: { [key:string]: any }, search: string, firstonly = true): any[] {
29
- let mcValues: any[] = [];
30
- while (node) {
31
- if (node._mc) {
32
- if (!search) {
33
- mcValues = mcValues.concat(Object.values(node._mc));
34
- }
35
- else if (search && node._mc[search]) {
36
- mcValues.push(node._mc[search]);
37
- }
38
- if (firstonly)
39
- return mcValues;
40
- }
41
- node = node.parentNode;
42
- }
43
- return mcValues;
44
- }
45
-
46
- function isDOM(element: { [key:string]: any } ) {
47
- return element && element instanceof HTMLElement;
48
- }
49
-
50
- type HTMLElementMC = HTMLElement & { _mc: { [key:string]: any } }
51
-
52
- export class MC {
53
-
54
- #target: { [key:string]: any } = {};
55
-
56
- #_mc: { [key:string]: any } = {};
57
-
58
- static debug: boolean = false;
59
-
60
- constructor( target: { [key:string]: any } ) {
61
- this.#target = target;
62
- this.#_mc = {};
63
- }
64
-
65
- get _mc(): undefined | any {
66
- if ( !MC.debug ) return undefined;
67
- return this.#_mc;
68
- }
69
-
70
- get target(): any {
71
- return this.#target;
72
- }
73
-
74
- // return all top-level micro components from an HTMLElement, or the searched one
75
- static siblings( target: HTMLElementMC, search: string = '' ): any[] {
76
- const mc = target as any;
77
-
78
- if (!mc._mc) {
79
- return [];
80
- }
81
-
82
- const _mc = mc._mc;
83
-
84
- if ( search.length ){
85
- return _mc?.[search] || [];
86
- }
87
-
88
- return [ ...Object.values(_mc) ];
89
- }
90
-
91
- // add a microcomponent to a target DOM node
92
- static add( target: HTMLElement, key: string, element = {} ): any {
93
-
94
- let node = target as HTMLElementMC;
95
-
96
- // create the _mc property if necessary
97
- if (!node._mc) {
98
- node._mc = new MC( target );
99
- }
100
-
101
- const _mc = node._mc;
102
-
103
- // add the element with the given property key to the _mc property
104
- if ( key.length && !_mc[key]) {
105
- _mc[key] = element;
106
- // add attribute if HTMLElement
107
- if ( target instanceof HTMLElement ) {
108
- target.setAttribute('_mc', '');
109
- }
110
- }
111
- return element;
112
- }
113
-
114
- // remove a micro component from the DOM
115
- static remove( target: HTMLElementMC, key: string) {
116
- if ( !key ) return; // silent fail
117
-
118
- const _mc = target?._mc || {};
119
-
120
- // delete the property from the HTMLElement _mc collection
121
- if ( _mc && _mc[key] ) {
122
- delete _mc[key];
123
- }
124
-
125
- // remove the _mc attribute if the DOM collection is empty
126
- if ( !Object.keys(_mc).length && target instanceof HTMLElement && target.hasAttribute('_mc') ) {
127
- target.removeAttribute('_mc');
128
- }
129
- return;
130
- }
131
-
132
- // add a microcomponent to the collection
133
- add( key: string, element: any, target?: HTMLElement ): any {
134
- if ( this.#_mc[key] ) return;
135
-
136
- // if target parameter exists ( a DOM node )
137
- // you want a top level (public) MC
138
- if ( target ){
139
- // ... add the new micro component to the DOM node _mc
140
- MC.add( target, key, element );
141
- }
142
- // add the new micro component to the private collection anyway
143
- this.#_mc[key] = element;
144
-
145
- return element;
146
- }
147
-
148
- // remove a micro component from the collection
149
- remove( key: string, target?: HTMLElement ): void {
150
- const _mc = this.#_mc;
151
- const t = target as HTMLElementMC;
152
-
153
- // if target parameter exists ( a DOM node )
154
- // you want to remove a top level (public) MC
155
- if ( target ){
156
- // ... remove the new micro component from the DOM node _mc
157
- MC.remove( t, key );
158
- }
159
- // remove the new micro component from the private collection anyway
160
- delete _mc?.[key];
161
- }
162
-
163
- // return all micro components from the collection, or the searched one
164
- // in a top level DOM MC, this refers to the inner collection always
165
- // use MC.siblings() to get the public MCs
166
- siblings( search: string = '' ): any[] {
167
- const _mc = this.#_mc;
168
-
169
- if ( !_mc ) return [];
170
-
171
- const result = _mc[search || ''];
172
-
173
- return search && result ? [result] : [ ...Object.values(_mc) ];
174
- }
175
-
176
- /*
177
- the following selectors will only work for the DOM top level MCs and return [] otherwise
178
- */
179
-
180
- // first anchestor DOM node, all public MCs
181
- parent( search: string = '' ): any[] {
182
- if ( !isDOM(this.#target) ) return [];
183
-
184
- return traverseNodes( (this as any).#target.parentNode, search, true);
185
- }
186
-
187
- // all anchestor DOM nodes, beginning with the closest, all public MCs
188
- parents( search: string = '' ): any[] {
189
- if ( !isDOM(this.#target) ) return [];
190
-
191
- return traverseNodes( (this as any).#target.parentNode, search, false);
192
- }
193
-
194
- // nearest child DOM nodes, all puclic MCs
195
- children( search: string = '' ): any[] {
196
- if ( !isDOM(this.#target) ) return [];
197
-
198
- const id = Math.random().toString().replace('.','');
199
- const selector = '[_mc]:not([temp_id="' + id +'"] [_mc] [_mc])'; // HOTFIX: minifier or tsc compiler error, dont use backtick string, cuts out blanks
200
- this.#target.setAttribute('temp_id', id);
201
- const myDomElements = this.#target.querySelectorAll(selector);
202
- const mcValues = getMicroComponents([...myDomElements], search);
203
- this.#target.removeAttribute('temp_id');
204
-
205
- return mcValues;
206
- }
207
-
208
- // all descendant DOM nodes, all puclic MCs
209
- descendants( search: string = '' ): any[] {
210
- if ( !isDOM(this.#target) ) return [];
211
-
212
- const myDomElements = this.#target.querySelectorAll('*[_mc]');
213
-
214
- return getMicroComponents([...myDomElements], search);
215
- }
216
- }