material-inspired-component-library 8.1.1 → 9.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (283) hide show
  1. package/README.md +106 -18
  2. package/components/README.md +1 -1
  3. package/components/accordion/README.md +6 -6
  4. package/components/alert/README.md +10 -10
  5. package/components/alert/index.scss +27 -52
  6. package/components/appbar/README.md +19 -6
  7. package/components/appbar/index.scss +40 -44
  8. package/components/badge/README.md +12 -10
  9. package/components/badge/index.scss +21 -25
  10. package/components/bottomsheet/README.md +26 -1
  11. package/components/bottomsheet/index.scss +58 -44
  12. package/components/button/README.md +7 -5
  13. package/components/button/_shared.scss +210 -0
  14. package/components/button/index.scss +49 -283
  15. package/components/card/README.md +97 -85
  16. package/components/card/index.scss +46 -65
  17. package/components/checkbox/README.md +25 -14
  18. package/{tools/shapes/check.mjs → components/checkbox/_label.scss} +37 -42
  19. package/components/checkbox/index.scss +66 -66
  20. package/components/chip/README.md +186 -0
  21. package/components/chip/index.scss +285 -0
  22. package/components/datepicker/README.md +79 -0
  23. package/components/datepicker/index.scss +346 -315
  24. package/components/dialog/README.md +20 -10
  25. package/components/dialog/index.scss +55 -66
  26. package/components/divider/README.md +16 -15
  27. package/components/divider/index.scss +9 -25
  28. package/components/iconbutton/README.md +8 -3
  29. package/components/iconbutton/index.scss +83 -186
  30. package/components/list/README.md +89 -156
  31. package/components/list/index.scss +34 -36
  32. package/components/menu/README.md +81 -155
  33. package/components/menu/index.scss +52 -58
  34. package/components/navigationbar/README.md +108 -0
  35. package/components/navigationbar/index.scss +185 -0
  36. package/components/navigationrail/README.md +60 -36
  37. package/components/navigationrail/_navitem.scss +96 -0
  38. package/components/navigationrail/index.scss +76 -130
  39. package/components/progressindicator/README.md +83 -47
  40. package/components/progressindicator/index.scss +622 -172
  41. package/components/radio/README.md +11 -9
  42. package/components/radio/index.scss +36 -33
  43. package/components/select/README.md +12 -7
  44. package/components/select/index.scss +26 -34
  45. package/components/shapes/README.md +3 -3
  46. package/components/shapes/index.scss +0 -1
  47. package/components/sidesheet/README.md +21 -9
  48. package/components/sidesheet/index.scss +38 -46
  49. package/components/slider/README.md +21 -0
  50. package/components/slider/index.scss +108 -139
  51. package/components/snackbar/README.md +32 -35
  52. package/components/snackbar/index.scss +10 -22
  53. package/components/stepper/README.md +14 -7
  54. package/components/stepper/index.scss +58 -39
  55. package/components/switch/README.md +22 -15
  56. package/components/switch/index.scss +68 -60
  57. package/components/textfield/README.md +48 -5
  58. package/components/textfield/index.scss +192 -248
  59. package/components/timepicker/README.md +53 -23
  60. package/components/timepicker/index.scss +110 -128
  61. package/dist/alert.css +1 -1
  62. package/dist/alert.js +1 -1
  63. package/dist/appbar.css +1 -1
  64. package/dist/appbar.js +1 -1
  65. package/dist/badge.css +1 -1
  66. package/dist/badge.js +1 -1
  67. package/dist/base.css +1 -0
  68. package/dist/base.js +1 -0
  69. package/dist/bottomsheet.css +1 -1
  70. package/dist/bottomsheet.js +1 -1
  71. package/dist/button.css +1 -1
  72. package/dist/button.js +1 -1
  73. package/dist/card.css +1 -1
  74. package/dist/card.js +1 -1
  75. package/dist/checkbox.css +1 -1
  76. package/dist/checkbox.js +1 -1
  77. package/dist/chip.css +1 -0
  78. package/dist/chip.js +1 -0
  79. package/dist/components/iconbutton/index.d.ts +2 -7
  80. package/dist/components/slider/index.d.ts +1 -1
  81. package/dist/components/textfield/index.d.ts +2 -2
  82. package/dist/datepicker.css +1 -1
  83. package/dist/datepicker.js +1 -1
  84. package/dist/dialog.css +1 -1
  85. package/dist/dialog.js +1 -1
  86. package/dist/divider.css +1 -1
  87. package/dist/divider.js +1 -1
  88. package/dist/field.css +1 -0
  89. package/dist/field.js +1 -0
  90. package/dist/foundations/form/index.js +1 -1
  91. package/dist/foundations/runtime.d.ts +15 -0
  92. package/dist/foundations/runtime.js +1 -0
  93. package/dist/iconbutton.css +1 -1
  94. package/dist/iconbutton.js +1 -1
  95. package/dist/layout.css +1 -1
  96. package/dist/layout.js +1 -1
  97. package/dist/list.css +1 -1
  98. package/dist/list.js +1 -1
  99. package/dist/menu.css +1 -1
  100. package/dist/menu.js +1 -1
  101. package/dist/micl.css +1 -1
  102. package/dist/micl.d.ts +14 -5
  103. package/dist/micl.js +1 -1
  104. package/dist/navigationbar.css +1 -0
  105. package/dist/navigationbar.js +1 -0
  106. package/dist/navigationrail.css +1 -1
  107. package/dist/navigationrail.js +1 -1
  108. package/dist/progressindicator.css +1 -1
  109. package/dist/progressindicator.js +1 -1
  110. package/dist/radio.css +1 -1
  111. package/dist/radio.js +1 -1
  112. package/dist/scrollbar.js +1 -1
  113. package/dist/select.css +1 -1
  114. package/dist/select.js +1 -1
  115. package/dist/shapes.css +1 -1
  116. package/dist/shapes.js +1 -1
  117. package/dist/sidesheet.css +1 -1
  118. package/dist/sidesheet.js +1 -1
  119. package/dist/slider.css +1 -1
  120. package/dist/slider.js +1 -1
  121. package/dist/snackbar.css +1 -1
  122. package/dist/snackbar.js +1 -1
  123. package/dist/stepper.css +1 -1
  124. package/dist/stepper.js +1 -1
  125. package/dist/switch.css +1 -1
  126. package/dist/switch.js +1 -1
  127. package/dist/textfield.css +1 -1
  128. package/dist/textfield.js +1 -1
  129. package/dist/timepicker.css +1 -1
  130. package/dist/timepicker.js +1 -1
  131. package/foundations/_index.scss +35 -0
  132. package/foundations/{index.scss → base/index.scss} +21 -56
  133. package/foundations/field/index.scss +37 -0
  134. package/foundations/layout/index.scss +64 -65
  135. package/package.json +23 -9
  136. package/styles/statelayer.scss +20 -5
  137. package/styles.scss +5 -2
  138. package/.claude/settings.local.json +0 -17
  139. package/.editorconfig +0 -12
  140. package/.gitattributes +0 -9
  141. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -35
  142. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  143. package/CLAUDE.md +0 -53
  144. package/CODE_OF_CONDUCT.md +0 -128
  145. package/components/bottomsheet/index.ts +0 -153
  146. package/components/button/index.ts +0 -79
  147. package/components/checkbox/index.ts +0 -148
  148. package/components/datepicker/index.ts +0 -693
  149. package/components/iconbutton/index.ts +0 -77
  150. package/components/list/index.ts +0 -138
  151. package/components/menu/index.ts +0 -145
  152. package/components/navigationrail/index.ts +0 -87
  153. package/components/progressindicator/index.ts +0 -77
  154. package/components/slider/index.ts +0 -149
  155. package/components/snackbar/index.ts +0 -118
  156. package/components/stepper/index.ts +0 -248
  157. package/components/textfield/index.ts +0 -188
  158. package/components/timepicker/index.ts +0 -413
  159. package/dist/components/progressindicator/index.d.ts +0 -6
  160. package/dist/foundations.css +0 -1
  161. package/dist/foundations.js +0 -1
  162. package/docs/accordion.html +0 -344
  163. package/docs/alert.html +0 -177
  164. package/docs/bottomsheet.html +0 -240
  165. package/docs/button.html +0 -291
  166. package/docs/card-awards.webp +0 -0
  167. package/docs/card-cabinet.webp +0 -0
  168. package/docs/card-city.webp +0 -0
  169. package/docs/card-fingerprint.webp +0 -0
  170. package/docs/card-holiday.webp +0 -0
  171. package/docs/card-names.webp +0 -0
  172. package/docs/card.html +0 -159
  173. package/docs/checkbox.html +0 -147
  174. package/docs/datepicker.html +0 -274
  175. package/docs/dialog.html +0 -195
  176. package/docs/divider.html +0 -139
  177. package/docs/docs.css +0 -26
  178. package/docs/docs.js +0 -139
  179. package/docs/iconbutton.html +0 -331
  180. package/docs/index.html +0 -431
  181. package/docs/list.html +0 -310
  182. package/docs/menu.html +0 -574
  183. package/docs/micl.css +0 -1
  184. package/docs/micl.js +0 -1
  185. package/docs/navigationrail.html +0 -138
  186. package/docs/progressindicator.html +0 -288
  187. package/docs/radio.html +0 -123
  188. package/docs/select.html +0 -337
  189. package/docs/shapes.css +0 -1
  190. package/docs/shapes.html +0 -159
  191. package/docs/shapes.js +0 -1
  192. package/docs/sidesheet.html +0 -149
  193. package/docs/slider.html +0 -141
  194. package/docs/snackbar.html +0 -102
  195. package/docs/stepper.html +0 -319
  196. package/docs/switch.html +0 -196
  197. package/docs/textfield.html +0 -208
  198. package/docs/themes/airblue/dark-hc.css +0 -51
  199. package/docs/themes/airblue/dark-mc.css +0 -51
  200. package/docs/themes/airblue/dark.css +0 -51
  201. package/docs/themes/airblue/light-hc.css +0 -51
  202. package/docs/themes/airblue/light-mc.css +0 -51
  203. package/docs/themes/airblue/light.css +0 -51
  204. package/docs/themes/airblue/theme.css +0 -306
  205. package/docs/themes/barnred/dark-hc.css +0 -51
  206. package/docs/themes/barnred/dark-mc.css +0 -51
  207. package/docs/themes/barnred/dark.css +0 -51
  208. package/docs/themes/barnred/light-hc.css +0 -51
  209. package/docs/themes/barnred/light-mc.css +0 -51
  210. package/docs/themes/barnred/light.css +0 -51
  211. package/docs/themes/barnred/theme.css +0 -306
  212. package/docs/themes/citrine/dark-hc.css +0 -51
  213. package/docs/themes/citrine/dark-mc.css +0 -51
  214. package/docs/themes/citrine/dark.css +0 -51
  215. package/docs/themes/citrine/light-hc.css +0 -51
  216. package/docs/themes/citrine/light-mc.css +0 -51
  217. package/docs/themes/citrine/light.css +0 -51
  218. package/docs/themes/citrine/theme.css +0 -306
  219. package/docs/themes/gray/dark-hc.css +0 -51
  220. package/docs/themes/gray/dark-mc.css +0 -51
  221. package/docs/themes/gray/dark.css +0 -51
  222. package/docs/themes/gray/light-hc.css +0 -51
  223. package/docs/themes/gray/light-mc.css +0 -51
  224. package/docs/themes/gray/light.css +0 -51
  225. package/docs/themes/gray/theme.css +0 -306
  226. package/docs/themes/greenery/dark-hc.css +0 -51
  227. package/docs/themes/greenery/dark-mc.css +0 -51
  228. package/docs/themes/greenery/dark.css +0 -51
  229. package/docs/themes/greenery/light-hc.css +0 -51
  230. package/docs/themes/greenery/light-mc.css +0 -51
  231. package/docs/themes/greenery/light.css +0 -51
  232. package/docs/themes/greenery/theme.css +0 -306
  233. package/docs/themes/hermana/dark-hc.css +0 -51
  234. package/docs/themes/hermana/dark-mc.css +0 -51
  235. package/docs/themes/hermana/dark.css +0 -51
  236. package/docs/themes/hermana/light-hc.css +0 -51
  237. package/docs/themes/hermana/light-mc.css +0 -51
  238. package/docs/themes/hermana/light.css +0 -51
  239. package/docs/themes/hermana/theme.css +0 -306
  240. package/docs/themes/illuminating/dark-hc.css +0 -51
  241. package/docs/themes/illuminating/dark-mc.css +0 -51
  242. package/docs/themes/illuminating/dark.css +0 -51
  243. package/docs/themes/illuminating/light-hc.css +0 -51
  244. package/docs/themes/illuminating/light-mc.css +0 -51
  245. package/docs/themes/illuminating/light.css +0 -51
  246. package/docs/themes/illuminating/theme.css +0 -306
  247. package/docs/themes/magenta/dark-hc.css +0 -51
  248. package/docs/themes/magenta/dark-mc.css +0 -51
  249. package/docs/themes/magenta/dark.css +0 -51
  250. package/docs/themes/magenta/light-hc.css +0 -51
  251. package/docs/themes/magenta/light-mc.css +0 -51
  252. package/docs/themes/magenta/light.css +0 -51
  253. package/docs/themes/magenta/theme.css +0 -306
  254. package/docs/themes/mocha/dark-hc.css +0 -51
  255. package/docs/themes/mocha/dark-mc.css +0 -51
  256. package/docs/themes/mocha/dark.css +0 -51
  257. package/docs/themes/mocha/light-hc.css +0 -51
  258. package/docs/themes/mocha/light-mc.css +0 -51
  259. package/docs/themes/mocha/light.css +0 -51
  260. package/docs/themes/mocha/theme.css +0 -306
  261. package/docs/themes/olivegreen/dark-hc.css +0 -51
  262. package/docs/themes/olivegreen/dark-mc.css +0 -51
  263. package/docs/themes/olivegreen/dark.css +0 -51
  264. package/docs/themes/olivegreen/light-hc.css +0 -51
  265. package/docs/themes/olivegreen/light-mc.css +0 -51
  266. package/docs/themes/olivegreen/light.css +0 -51
  267. package/docs/themes/olivegreen/theme.css +0 -306
  268. package/docs/themes/peri/dark-hc.css +0 -51
  269. package/docs/themes/peri/dark-mc.css +0 -51
  270. package/docs/themes/peri/dark.css +0 -51
  271. package/docs/themes/peri/light-hc.css +0 -51
  272. package/docs/themes/peri/light-mc.css +0 -51
  273. package/docs/themes/peri/light.css +0 -51
  274. package/docs/themes/peri/theme.css +0 -306
  275. package/docs/timepicker.html +0 -160
  276. package/foundations/form/index.ts +0 -174
  277. package/foundations/layout/README.md +0 -127
  278. package/intl.d.ts +0 -9
  279. package/micl.ts +0 -221
  280. package/styles/README.md +0 -196
  281. package/tools/shapes/generate.mjs +0 -828
  282. package/tsconfig.json +0 -116
  283. package/webpack.config.js +0 -159
@@ -1,77 +0,0 @@
1
- //
2
- // Copyright © 2025 Hermana AS
3
- //
4
- // Permission is hereby granted, free of charge, to any person obtaining a copy
5
- // of this software and associated documentation files (the "Software"), to deal
6
- // in the Software without restriction, including without limitation the rights
7
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- // copies of the Software, and to permit persons to whom the Software is
9
- // furnished to do so, subject to the following conditions:
10
- //
11
- // The above copyright notice and this permission notice shall be included in all
12
- // copies or substantial portions of the Software.
13
- //
14
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- // SOFTWARE.
21
-
22
- export const buttonSelector = '.micl-button--toggle';
23
-
24
- const toggleIcon = (button: HTMLButtonElement): void =>
25
- {
26
- const selected = button.getAttribute('aria-pressed') === 'true';
27
- if (button.dataset.micliconselected) {
28
- button.classList.toggle(button.dataset.micliconselected, selected);
29
- }
30
- if (button.dataset.miclicon) {
31
- button.classList.toggle(button.dataset.miclicon, !selected);
32
- }
33
- };
34
-
35
- export default (() =>
36
- {
37
- return {
38
- command: (event: Event): void =>
39
- {
40
- const target = event.target as HTMLButtonElement;
41
-
42
- if (
43
- target.matches(buttonSelector)
44
- && !target.disabled
45
- && (event as any).command === '--micl-toggle'
46
- ) {
47
- target.classList.add('micl-button--toggled');
48
- target.setAttribute('aria-pressed', String(target.getAttribute('aria-pressed') !== 'true'));
49
-
50
- toggleIcon(target);
51
- }
52
- },
53
-
54
- initialize: function(element: HTMLButtonElement): void
55
- {
56
- if (
57
- !element.matches(buttonSelector)
58
- || element.dataset.miclinitialized
59
- ) {
60
- return;
61
- }
62
- element.dataset.miclinitialized = '1';
63
-
64
- toggleIcon(element);
65
-
66
- element.addEventListener('command', this.command);
67
- },
68
-
69
- cleanup: function(element: HTMLButtonElement): void
70
- {
71
- if (element.matches(buttonSelector)) {
72
- element.removeEventListener('command', this.command);
73
- delete element.dataset.miclinitialized;
74
- }
75
- }
76
- };
77
- })();
@@ -1,138 +0,0 @@
1
- //
2
- // Copyright © 2025 Hermana AS
3
- //
4
- // Permission is hereby granted, free of charge, to any person obtaining a copy
5
- // of this software and associated documentation files (the "Software"), to deal
6
- // in the Software without restriction, including without limitation the rights
7
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- // copies of the Software, and to permit persons to whom the Software is
9
- // furnished to do so, subject to the following conditions:
10
- //
11
- // The above copyright notice and this permission notice shall be included in all
12
- // copies or substantial portions of the Software.
13
- //
14
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- // SOFTWARE.
21
-
22
- export const listSelector = '.micl-list';
23
-
24
- const isDisabled = (item?: HTMLElement | null) => item?.classList.contains('micl-list-item--disabled');
25
- const isSelectable = (item?: HTMLElement | null) => item?.matches(':has(input[type=checkbox])');
26
- const isSelected = (item?: HTMLElement | null) => item?.matches(':has(input[type=checkbox]:checked)');
27
-
28
- export default
29
- {
30
- keydown(event: KeyboardEvent | Event): void
31
- {
32
- const target = event.target as HTMLElement;
33
-
34
- if (
35
- !(event instanceof KeyboardEvent)
36
- || !target?.matches('.micl-list-item-one,.micl-list-item-two,.micl-list-item-three')
37
- ) {
38
- return;
39
- }
40
-
41
- const parent = target.parentElement;
42
- if (!parent) return;
43
-
44
- const isAccordion = parent instanceof HTMLDetailsElement;
45
- let items: HTMLElement[] = [];
46
-
47
- if (isAccordion) {
48
- items = Array.from(parent.parentElement?.children || [])
49
- .map(details => details.querySelector(':scope > summary') as HTMLElement)
50
- .filter(Boolean);
51
- }
52
- else if (['UL', 'OL'].includes(parent.tagName)) {
53
- items = Array.from(parent.children).filter(child =>
54
- child instanceof HTMLLIElement && child.getAttribute('role') !== 'separator'
55
- ) as HTMLElement[];
56
- }
57
-
58
- items = items.filter(item => !isDisabled(item));
59
- if (!items.length) return;
60
-
61
- const currentIndex = items.indexOf(target);
62
- if (currentIndex === -1) return;
63
-
64
- let nextIndex = currentIndex;
65
-
66
- switch (event.key) {
67
- case 'ArrowDown':
68
- event.preventDefault(); // prevent page scrolling
69
- nextIndex = (currentIndex + 1) % items.length;
70
- break;
71
- case 'ArrowUp':
72
- event.preventDefault();
73
- nextIndex = (currentIndex - 1 + items.length) % items.length;
74
- break;
75
- case 'Tab':
76
- if (!isAccordion) {
77
- const selectedIndex = items.findIndex(isSelected);
78
- nextIndex = selectedIndex === -1 ? 0 : selectedIndex;
79
- }
80
- break;
81
- case ' ':
82
- case 'Enter':
83
- if (isAccordion) break;
84
- if (event.key === ' ') {
85
- event.preventDefault();
86
- }
87
- const el = target.querySelector<HTMLElement>(
88
- 'input[type=checkbox], a[href], button'
89
- );
90
- if (el instanceof HTMLInputElement) {
91
- el.checked = !el.checked;
92
- el.dispatchEvent(new Event('change', {
93
- bubbles : true,
94
- cancelable: true
95
- }));
96
- }
97
- else {
98
- el?.click();
99
- }
100
- break;
101
- default:
102
- }
103
-
104
- if (nextIndex !== currentIndex) {
105
- if (!isAccordion) {
106
- target.setAttribute('tabindex', '-1');
107
- items[nextIndex].setAttribute('tabindex', '0');
108
- }
109
- items[nextIndex].focus();
110
- }
111
- },
112
-
113
- initialize(element: HTMLElement): void
114
- {
115
- if (element.dataset.miclinitialized) return;
116
- element.dataset.miclinitialized = '1';
117
-
118
- element.querySelectorAll<HTMLElement>(
119
- ':scope > details > summary.micl-list-item--disabled'
120
- ).forEach(summary => summary.setAttribute('tabindex', '-1'));
121
-
122
- if (!element.querySelector('li[tabindex="0"]')) return;
123
-
124
- element.querySelectorAll<HTMLLIElement>('li:not([role="separator"])').forEach(item =>
125
- {
126
- if (item.getAttribute('tabindex') !== '0') {
127
- item.setAttribute('tabindex', '-1');
128
- }
129
-
130
- item.querySelectorAll('a, button, input').forEach(link => link.setAttribute('tabindex', '-1'));
131
-
132
- if (isSelectable(item)) {
133
- item.setAttribute('role', 'option');
134
- item.parentElement?.setAttribute('role', 'listbox');
135
- }
136
- });
137
- }
138
- };
@@ -1,145 +0,0 @@
1
- //
2
- // Copyright © 2025 Hermana AS
3
- //
4
- // Permission is hereby granted, free of charge, to any person obtaining a copy
5
- // of this software and associated documentation files (the "Software"), to deal
6
- // in the Software without restriction, including without limitation the rights
7
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- // copies of the Software, and to permit persons to whom the Software is
9
- // furnished to do so, subject to the following conditions:
10
- //
11
- // The above copyright notice and this permission notice shall be included in all
12
- // copies or substantial portions of the Software.
13
- //
14
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- // SOFTWARE.
21
-
22
- export const menuSelector = '.micl-menu[popover]';
23
-
24
- export default (() =>
25
- {
26
- const getOrigin = (invoker: Element, popover: Element): string =>
27
- {
28
- const invokerRect = invoker.getBoundingClientRect();
29
- const popoverRect = popover.getBoundingClientRect();
30
-
31
- return ((invokerRect.x > popoverRect.x) ? 'right ' : 'left ') +
32
- ((invokerRect.y > popoverRect.y) ? 'bottom' : 'top');
33
- };
34
-
35
- const navigableItems = (list: Element): HTMLElement[] =>
36
- Array.from(list.children).filter((child): child is HTMLElement =>
37
- child instanceof HTMLLIElement
38
- && child.getAttribute('role') !== 'separator'
39
- && !child.classList.contains('micl-list-item--disabled')
40
- && child.matches('.micl-list-item-one,.micl-list-item-two,.micl-list-item-three')
41
- );
42
-
43
- return {
44
- initialize: (element: HTMLElement): void =>
45
- {
46
- if (
47
- !element.matches('.micl-menu[popover]')
48
- || element.dataset.miclinitialized
49
- ) {
50
- return;
51
- }
52
- element.dataset.miclinitialized = '1';
53
-
54
- const invoker = document.querySelector(`[popovertarget="${element.id}"]`);
55
-
56
- invoker && element.addEventListener('beforetoggle', () =>
57
- {
58
- element.style.transformOrigin = getOrigin(invoker, element);
59
- });
60
-
61
- element.addEventListener('keydown', (event: KeyboardEvent) =>
62
- {
63
- if (event.key !== 'ArrowDown' && event.key !== 'ArrowUp') return;
64
-
65
- const target = event.target;
66
- if (
67
- !(target instanceof HTMLElement)
68
- || !target.matches('.micl-list-item-one,.micl-list-item-two,.micl-list-item-three')
69
- ) {
70
- return;
71
- }
72
-
73
- const currentList = target.parentElement;
74
- if (!currentList?.matches('ul.micl-list')) return;
75
- if (currentList.parentElement !== element) return;
76
-
77
- const lists = Array.from(element.querySelectorAll<HTMLElement>(':scope > ul.micl-list'));
78
- if (lists.length < 2) return;
79
-
80
- const listIndex = lists.indexOf(currentList as HTMLElement);
81
- const items = navigableItems(currentList);
82
- const itemIndex = items.indexOf(target);
83
- if (itemIndex === -1) return;
84
-
85
- let nextItem: HTMLElement | undefined;
86
-
87
- if (event.key === 'ArrowDown' && itemIndex === items.length - 1) {
88
- const nextListIndex = (listIndex + 1) % lists.length;
89
- nextItem = navigableItems(lists[nextListIndex])[0];
90
- }
91
- else if (event.key === 'ArrowUp' && itemIndex === 0) {
92
- const prevListIndex = (listIndex - 1 + lists.length) % lists.length;
93
- const prev = navigableItems(lists[prevListIndex]);
94
- nextItem = prev[prev.length - 1];
95
- }
96
-
97
- if (nextItem) {
98
- event.preventDefault();
99
- event.stopPropagation();
100
- target.setAttribute('tabindex', '-1');
101
- nextItem.setAttribute('tabindex', '0');
102
- nextItem.focus();
103
- }
104
- }, true);
105
-
106
- element.querySelectorAll<HTMLButtonElement>(
107
- ':scope > ul.micl-list > li > button[popovertarget]'
108
- ).forEach(submenuinvoker =>
109
- {
110
- if (submenuinvoker.popoverTargetElement?.matches('.micl-menu[popover]')) {
111
- const popover = submenuinvoker.popoverTargetElement as HTMLElement;
112
- const id = `--${popover.id}`;
113
- let hoverTimeout: ReturnType<typeof setTimeout>;
114
-
115
- submenuinvoker.style.setProperty('anchor-name', id);
116
- popover.style.insetBlockStart = `anchor(${id} start)`;
117
- popover.style.insetInlineStart = `anchor(${id} end)`;
118
-
119
- const scheduleClose = () =>
120
- {
121
- clearTimeout(hoverTimeout);
122
- hoverTimeout = setTimeout(() =>
123
- {
124
- if (!submenuinvoker.matches(':hover') && !popover.matches(':hover')) {
125
- popover.hidePopover();
126
- }
127
- }, 300);
128
- };
129
-
130
- submenuinvoker.addEventListener('mouseenter', () =>
131
- {
132
- clearTimeout(hoverTimeout);
133
- popover.showPopover();
134
- });
135
- submenuinvoker.addEventListener('mouseleave', scheduleClose);
136
- popover.addEventListener('mouseenter', () =>
137
- {
138
- clearTimeout(hoverTimeout);
139
- });
140
- popover.addEventListener('mouseleave', scheduleClose);
141
- }
142
- });
143
- }
144
- };
145
- })();
@@ -1,87 +0,0 @@
1
- //
2
- // Copyright © 2025 Hermana AS
3
- //
4
- // Permission is hereby granted, free of charge, to any person obtaining a copy
5
- // of this software and associated documentation files (the "Software"), to deal
6
- // in the Software without restriction, including without limitation the rights
7
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- // copies of the Software, and to permit persons to whom the Software is
9
- // furnished to do so, subject to the following conditions:
10
- //
11
- // The above copyright notice and this permission notice shall be included in all
12
- // copies or substantial portions of the Software.
13
- //
14
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- // SOFTWARE.
21
-
22
- export const navigationrailSelector = '.micl-navigationrail';
23
-
24
- interface NavigationRailState {
25
- boundHandleClick: (event: Event) => void;
26
- }
27
-
28
- const navigationrailStates = new WeakMap<HTMLElement, NavigationRailState>();
29
-
30
- export default
31
- {
32
- initialize: (element: HTMLElement): void =>
33
- {
34
- if (!element.matches(navigationrailSelector) || element.dataset.miclinitialized) {
35
- return;
36
- }
37
-
38
- element.dataset.miclinitialized = '1';
39
-
40
- const boundHandleClick = (event: Event): void =>
41
- {
42
- const clickedItem = (event.target as HTMLElement).closest<HTMLAnchorElement>(
43
- 'a.micl-navigationrail__item'
44
- );
45
-
46
- if (clickedItem) {
47
- const allItems = element.querySelectorAll<HTMLAnchorElement>(
48
- 'a.micl-navigationrail__item'
49
- );
50
- allItems.forEach(item => item.removeAttribute('aria-current'));
51
-
52
- clickedItem.setAttribute('aria-current', 'page');
53
- }
54
- };
55
-
56
- navigationrailStates.set(element, { boundHandleClick });
57
-
58
- element.addEventListener('click', boundHandleClick);
59
- },
60
-
61
- keydown: (event: Event): void =>
62
- {
63
- if (
64
- !(event instanceof KeyboardEvent)
65
- || !(event.target instanceof HTMLElement)
66
- || !event.target.matches('.micl-navigationrail__item')
67
- ) {
68
- return;
69
- }
70
-
71
- if (event.keyCode === 32 || event.key === ' ') {
72
- event.preventDefault();
73
- event.target.click();
74
- }
75
- },
76
-
77
- cleanup: (element: HTMLElement): void =>
78
- {
79
- const state = navigationrailStates.get(element);
80
-
81
- if (state) {
82
- element.removeEventListener('click', state.boundHandleClick);
83
- }
84
-
85
- delete element.dataset.miclinitialized;
86
- }
87
- };
@@ -1,77 +0,0 @@
1
- //
2
- // Copyright © 2025 Hermana AS
3
- //
4
- // Permission is hereby granted, free of charge, to any person obtaining a copy
5
- // of this software and associated documentation files (the "Software"), to deal
6
- // in the Software without restriction, including without limitation the rights
7
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- // copies of the Software, and to permit persons to whom the Software is
9
- // furnished to do so, subject to the following conditions:
10
- //
11
- // The above copyright notice and this permission notice shall be included in all
12
- // copies or substantial portions of the Software.
13
- //
14
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- // SOFTWARE.
21
-
22
- export const progressindicatorSelector = 'progress.micl-progress-linear,progress.micl-progress-circular';
23
-
24
- export default (() =>
25
- {
26
- // <progress> emits no input/change events when its value/max change, so a
27
- // per-instance MutationObserver mirrors the determinate attributes into the
28
- // CSS custom properties the SCSS reads. Indeterminate progress (no value
29
- // attribute) is handled entirely in CSS via the :indeterminate pseudo-class.
30
- const observers = new WeakMap<HTMLProgressElement, MutationObserver>();
31
-
32
- const setVars = (element: HTMLProgressElement): void =>
33
- {
34
- // position is value/max for determinate, or -1 when indeterminate.
35
- const fraction = element.position;
36
-
37
- if (fraction < 0) {
38
- element.style.removeProperty('--md-comp-progress-value');
39
- element.style.removeProperty('--md-comp-progress-max');
40
- element.style.removeProperty('--md-comp-progress-fraction');
41
- element.style.removeProperty('--md-comp-progress-amplitude-scale');
42
- return;
43
- }
44
-
45
- // The Expressive wave amplitude eases to zero over the final 10% so the
46
- // active indicator settles into a straight line as it completes.
47
- const scale = Math.max(0, Math.min(1, (1 - fraction) / 0.1));
48
-
49
- element.style.setProperty('--md-comp-progress-value', String(element.value));
50
- element.style.setProperty('--md-comp-progress-max', String(element.max || 1));
51
- element.style.setProperty('--md-comp-progress-fraction', String(fraction));
52
- element.style.setProperty('--md-comp-progress-amplitude-scale', String(scale));
53
- };
54
-
55
- return {
56
- initialize: (element: HTMLProgressElement): void =>
57
- {
58
- if (!element.matches(progressindicatorSelector)) {
59
- return;
60
- }
61
-
62
- setVars(element);
63
-
64
- const observer = new MutationObserver(() => setVars(element));
65
- observer.observe(element, { attributes: true, attributeFilter: ['value', 'max'] });
66
- observers.set(element, observer);
67
- },
68
- cleanup: (element: HTMLProgressElement): void =>
69
- {
70
- const observer = observers.get(element);
71
- if (observer) {
72
- observer.disconnect();
73
- observers.delete(element);
74
- }
75
- }
76
- };
77
- })();
@@ -1,149 +0,0 @@
1
- //
2
- // Copyright © 2025 Hermana AS
3
- //
4
- // Permission is hereby granted, free of charge, to any person obtaining a copy
5
- // of this software and associated documentation files (the "Software"), to deal
6
- // in the Software without restriction, including without limitation the rights
7
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- // copies of the Software, and to permit persons to whom the Software is
9
- // furnished to do so, subject to the following conditions:
10
- //
11
- // The above copyright notice and this permission notice shall be included in all
12
- // copies or substantial portions of the Software.
13
- //
14
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- // SOFTWARE.
21
-
22
- export const sliderSelector = 'input[type=range].micl-slider-xs,input[type=range].micl-slider-s,input[type=range].micl-slider-m,input[type=range].micl-slider-l,input[type=range].micl-slider-xl';
23
-
24
- export default (() =>
25
- {
26
- const
27
- tick = String.fromCharCode(8226),
28
- blank = String.fromCharCode(8201),
29
- getTickValues = (element: HTMLInputElement, max: number, min: number): number[] =>
30
- {
31
- const values: number[] = [];
32
-
33
- if (!!element.list && (max > min)) {
34
- element.list.querySelectorAll<HTMLOptionElement>('option[value]').forEach(option =>
35
- {
36
- let value = parseFloat(option.value);
37
- if (!isNaN(value) && (value >= min) && (value <= max)) {
38
- values.push(value);
39
- }
40
- });
41
- }
42
- return values;
43
- },
44
- getWrapper = (element: HTMLInputElement): null | HTMLElement =>
45
- {
46
- return element.parentElement?.classList.contains('micl-slider__container') ?
47
- element.parentElement : null;
48
- },
49
- setMax = (element: HTMLInputElement): void =>
50
- {
51
- let max = element.max || '100';
52
- getWrapper(element)?.style.setProperty('--md-sys-slider-max', max);
53
- element.style.setProperty('--md-sys-slider-max', max);
54
- },
55
- setMin = (element: HTMLInputElement): void =>
56
- {
57
- let min = element.min || '0';
58
- getWrapper(element)?.style.setProperty('--md-sys-slider-min', min);
59
- element.style.setProperty('--md-sys-slider-min', min);
60
- },
61
- setTickString = (element: HTMLInputElement, tickString: string): void =>
62
- {
63
- // getWrapper(element)?.dataset.miclsliderticks = tickString;
64
- element.dataset.miclsliderticks = tickString;
65
- },
66
- setValue = (element: HTMLInputElement): void =>
67
- {
68
- let tip = JSON.stringify(element.value + ''),
69
- wrapper = getWrapper(element);
70
- if (wrapper) {
71
- wrapper.style.setProperty('--md-sys-slider-value', element.value);
72
- wrapper.style.setProperty('--md-sys-slider-tip', tip);
73
- }
74
- element.style.setProperty('--md-sys-slider-value', element.value);
75
- element.style.setProperty('--md-sys-slider-tip', tip);
76
- },
77
- setVars = (element: HTMLInputElement): void =>
78
- {
79
- let wrapper = getWrapper(element);
80
- if (wrapper) {
81
- const computedStyles = window.getComputedStyle(element);
82
- ['--md-sys-slider-handle-height', '--md-sys-slider-track-height'].forEach(name => {
83
- wrapper.style.setProperty(name, computedStyles.getPropertyValue(name));
84
- });
85
- }
86
- };
87
-
88
- return {
89
- initialize: (element: HTMLInputElement): void =>
90
- {
91
- if (!element.matches(sliderSelector)) {
92
- return;
93
- }
94
-
95
- setMax(element);
96
- setMin(element);
97
- setValue(element);
98
- setVars(element);
99
-
100
- const max = parseFloat(element.max);
101
- const min = parseFloat(element.min);
102
- const rect = element.getBoundingClientRect();
103
- const percentages = getTickValues(element, max, min).sort((a, b) => a - b).map(value => {
104
- return Math.round(100 * (value - min) / (max - min));
105
- });
106
-
107
- if (percentages.length > 0) {
108
- const canvas = document.createElement('canvas');
109
- const ctx = canvas.getContext('2d');
110
-
111
- if (ctx) {
112
- ctx.font = window.getComputedStyle(element).getPropertyValue('font');
113
- let blankWidth = ctx.measureText(blank).width,
114
- tickWidth = ctx.measureText(tick).width,
115
- totalWidth = rect.width - 10,
116
- currentWidth = 0,
117
- tickString = '';
118
-
119
- percentages.forEach(percentage =>
120
- {
121
- let position = (totalWidth * percentage) / 100,
122
- nrBlanks = Math.round((position - currentWidth) / blankWidth) - 1;
123
- for (let i = 0; i < nrBlanks; i++) {
124
- tickString += blank;
125
- currentWidth += blankWidth;
126
- }
127
- tickString += tick;
128
- currentWidth += tickWidth;
129
- });
130
- setTickString(element, tickString);
131
- }
132
- canvas.remove();
133
- }
134
- else {
135
- setTickString(element, tick);
136
- }
137
- },
138
- input: (event: Event): void =>
139
- {
140
- if (
141
- (event.target as Element).matches(sliderSelector)
142
- && event.target instanceof HTMLInputElement
143
- && !event.target.disabled
144
- ) {
145
- setValue(event.target);
146
- }
147
- }
148
- };
149
- })();