material-inspired-component-library 8.1.0 → 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 (284) 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 +70 -10
  13. package/components/button/_shared.scss +210 -0
  14. package/components/button/index.scss +75 -389
  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 +63 -12
  29. package/components/iconbutton/index.scss +142 -303
  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 +62 -37
  37. package/components/navigationrail/_navitem.scss +96 -0
  38. package/components/navigationrail/index.scss +78 -132
  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/button/index.d.ts +1 -1
  80. package/dist/components/iconbutton/index.d.ts +2 -7
  81. package/dist/components/slider/index.d.ts +1 -1
  82. package/dist/components/textfield/index.d.ts +2 -2
  83. package/dist/datepicker.css +1 -1
  84. package/dist/datepicker.js +1 -1
  85. package/dist/dialog.css +1 -1
  86. package/dist/dialog.js +1 -1
  87. package/dist/divider.css +1 -1
  88. package/dist/divider.js +1 -1
  89. package/dist/field.css +1 -0
  90. package/dist/field.js +1 -0
  91. package/dist/foundations/form/index.js +1 -1
  92. package/dist/foundations/runtime.d.ts +15 -0
  93. package/dist/foundations/runtime.js +1 -0
  94. package/dist/iconbutton.css +1 -1
  95. package/dist/iconbutton.js +1 -1
  96. package/dist/layout.css +1 -1
  97. package/dist/layout.js +1 -1
  98. package/dist/list.css +1 -1
  99. package/dist/list.js +1 -1
  100. package/dist/menu.css +1 -1
  101. package/dist/menu.js +1 -1
  102. package/dist/micl.css +1 -1
  103. package/dist/micl.d.ts +14 -5
  104. package/dist/micl.js +1 -1
  105. package/dist/navigationbar.css +1 -0
  106. package/dist/navigationbar.js +1 -0
  107. package/dist/navigationrail.css +1 -1
  108. package/dist/navigationrail.js +1 -1
  109. package/dist/progressindicator.css +1 -1
  110. package/dist/progressindicator.js +1 -1
  111. package/dist/radio.css +1 -1
  112. package/dist/radio.js +1 -1
  113. package/dist/scrollbar.js +1 -1
  114. package/dist/select.css +1 -1
  115. package/dist/select.js +1 -1
  116. package/dist/shapes.css +1 -1
  117. package/dist/shapes.js +1 -1
  118. package/dist/sidesheet.css +1 -1
  119. package/dist/sidesheet.js +1 -1
  120. package/dist/slider.css +1 -1
  121. package/dist/slider.js +1 -1
  122. package/dist/snackbar.css +1 -1
  123. package/dist/snackbar.js +1 -1
  124. package/dist/stepper.css +1 -1
  125. package/dist/stepper.js +1 -1
  126. package/dist/switch.css +1 -1
  127. package/dist/switch.js +1 -1
  128. package/dist/textfield.css +1 -1
  129. package/dist/textfield.js +1 -1
  130. package/dist/timepicker.css +1 -1
  131. package/dist/timepicker.js +1 -1
  132. package/foundations/_index.scss +35 -0
  133. package/foundations/{index.scss → base/index.scss} +21 -56
  134. package/foundations/field/index.scss +37 -0
  135. package/foundations/layout/index.scss +64 -65
  136. package/package.json +23 -9
  137. package/styles/statelayer.scss +20 -5
  138. package/styles.scss +5 -2
  139. package/.claude/settings.local.json +0 -14
  140. package/.editorconfig +0 -12
  141. package/.gitattributes +0 -9
  142. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -35
  143. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  144. package/CLAUDE.md +0 -53
  145. package/CODE_OF_CONDUCT.md +0 -128
  146. package/components/bottomsheet/index.ts +0 -153
  147. package/components/button/index.ts +0 -79
  148. package/components/checkbox/index.ts +0 -148
  149. package/components/datepicker/index.ts +0 -693
  150. package/components/iconbutton/index.ts +0 -77
  151. package/components/list/index.ts +0 -138
  152. package/components/menu/index.ts +0 -145
  153. package/components/navigationrail/index.ts +0 -87
  154. package/components/progressindicator/index.ts +0 -77
  155. package/components/slider/index.ts +0 -149
  156. package/components/snackbar/index.ts +0 -118
  157. package/components/stepper/index.ts +0 -248
  158. package/components/textfield/index.ts +0 -188
  159. package/components/timepicker/index.ts +0 -413
  160. package/dist/components/progressindicator/index.d.ts +0 -6
  161. package/dist/foundations.css +0 -1
  162. package/dist/foundations.js +0 -1
  163. package/docs/accordion.html +0 -344
  164. package/docs/alert.html +0 -177
  165. package/docs/bottomsheet.html +0 -240
  166. package/docs/button.html +0 -290
  167. package/docs/card-awards.webp +0 -0
  168. package/docs/card-cabinet.webp +0 -0
  169. package/docs/card-city.webp +0 -0
  170. package/docs/card-fingerprint.webp +0 -0
  171. package/docs/card-holiday.webp +0 -0
  172. package/docs/card-names.webp +0 -0
  173. package/docs/card.html +0 -159
  174. package/docs/checkbox.html +0 -147
  175. package/docs/datepicker.html +0 -274
  176. package/docs/dialog.html +0 -195
  177. package/docs/divider.html +0 -139
  178. package/docs/docs.css +0 -26
  179. package/docs/docs.js +0 -139
  180. package/docs/iconbutton.html +0 -329
  181. package/docs/index.html +0 -431
  182. package/docs/list.html +0 -310
  183. package/docs/menu.html +0 -574
  184. package/docs/micl.css +0 -1
  185. package/docs/micl.js +0 -1
  186. package/docs/navigationrail.html +0 -138
  187. package/docs/progressindicator.html +0 -288
  188. package/docs/radio.html +0 -123
  189. package/docs/select.html +0 -337
  190. package/docs/shapes.css +0 -1
  191. package/docs/shapes.html +0 -159
  192. package/docs/shapes.js +0 -1
  193. package/docs/sidesheet.html +0 -149
  194. package/docs/slider.html +0 -141
  195. package/docs/snackbar.html +0 -102
  196. package/docs/stepper.html +0 -319
  197. package/docs/switch.html +0 -196
  198. package/docs/textfield.html +0 -208
  199. package/docs/themes/airblue/dark-hc.css +0 -51
  200. package/docs/themes/airblue/dark-mc.css +0 -51
  201. package/docs/themes/airblue/dark.css +0 -51
  202. package/docs/themes/airblue/light-hc.css +0 -51
  203. package/docs/themes/airblue/light-mc.css +0 -51
  204. package/docs/themes/airblue/light.css +0 -51
  205. package/docs/themes/airblue/theme.css +0 -306
  206. package/docs/themes/barnred/dark-hc.css +0 -51
  207. package/docs/themes/barnred/dark-mc.css +0 -51
  208. package/docs/themes/barnred/dark.css +0 -51
  209. package/docs/themes/barnred/light-hc.css +0 -51
  210. package/docs/themes/barnred/light-mc.css +0 -51
  211. package/docs/themes/barnred/light.css +0 -51
  212. package/docs/themes/barnred/theme.css +0 -306
  213. package/docs/themes/citrine/dark-hc.css +0 -51
  214. package/docs/themes/citrine/dark-mc.css +0 -51
  215. package/docs/themes/citrine/dark.css +0 -51
  216. package/docs/themes/citrine/light-hc.css +0 -51
  217. package/docs/themes/citrine/light-mc.css +0 -51
  218. package/docs/themes/citrine/light.css +0 -51
  219. package/docs/themes/citrine/theme.css +0 -306
  220. package/docs/themes/gray/dark-hc.css +0 -51
  221. package/docs/themes/gray/dark-mc.css +0 -51
  222. package/docs/themes/gray/dark.css +0 -51
  223. package/docs/themes/gray/light-hc.css +0 -51
  224. package/docs/themes/gray/light-mc.css +0 -51
  225. package/docs/themes/gray/light.css +0 -51
  226. package/docs/themes/gray/theme.css +0 -306
  227. package/docs/themes/greenery/dark-hc.css +0 -51
  228. package/docs/themes/greenery/dark-mc.css +0 -51
  229. package/docs/themes/greenery/dark.css +0 -51
  230. package/docs/themes/greenery/light-hc.css +0 -51
  231. package/docs/themes/greenery/light-mc.css +0 -51
  232. package/docs/themes/greenery/light.css +0 -51
  233. package/docs/themes/greenery/theme.css +0 -306
  234. package/docs/themes/hermana/dark-hc.css +0 -51
  235. package/docs/themes/hermana/dark-mc.css +0 -51
  236. package/docs/themes/hermana/dark.css +0 -51
  237. package/docs/themes/hermana/light-hc.css +0 -51
  238. package/docs/themes/hermana/light-mc.css +0 -51
  239. package/docs/themes/hermana/light.css +0 -51
  240. package/docs/themes/hermana/theme.css +0 -306
  241. package/docs/themes/illuminating/dark-hc.css +0 -51
  242. package/docs/themes/illuminating/dark-mc.css +0 -51
  243. package/docs/themes/illuminating/dark.css +0 -51
  244. package/docs/themes/illuminating/light-hc.css +0 -51
  245. package/docs/themes/illuminating/light-mc.css +0 -51
  246. package/docs/themes/illuminating/light.css +0 -51
  247. package/docs/themes/illuminating/theme.css +0 -306
  248. package/docs/themes/magenta/dark-hc.css +0 -51
  249. package/docs/themes/magenta/dark-mc.css +0 -51
  250. package/docs/themes/magenta/dark.css +0 -51
  251. package/docs/themes/magenta/light-hc.css +0 -51
  252. package/docs/themes/magenta/light-mc.css +0 -51
  253. package/docs/themes/magenta/light.css +0 -51
  254. package/docs/themes/magenta/theme.css +0 -306
  255. package/docs/themes/mocha/dark-hc.css +0 -51
  256. package/docs/themes/mocha/dark-mc.css +0 -51
  257. package/docs/themes/mocha/dark.css +0 -51
  258. package/docs/themes/mocha/light-hc.css +0 -51
  259. package/docs/themes/mocha/light-mc.css +0 -51
  260. package/docs/themes/mocha/light.css +0 -51
  261. package/docs/themes/mocha/theme.css +0 -306
  262. package/docs/themes/olivegreen/dark-hc.css +0 -51
  263. package/docs/themes/olivegreen/dark-mc.css +0 -51
  264. package/docs/themes/olivegreen/dark.css +0 -51
  265. package/docs/themes/olivegreen/light-hc.css +0 -51
  266. package/docs/themes/olivegreen/light-mc.css +0 -51
  267. package/docs/themes/olivegreen/light.css +0 -51
  268. package/docs/themes/olivegreen/theme.css +0 -306
  269. package/docs/themes/peri/dark-hc.css +0 -51
  270. package/docs/themes/peri/dark-mc.css +0 -51
  271. package/docs/themes/peri/dark.css +0 -51
  272. package/docs/themes/peri/light-hc.css +0 -51
  273. package/docs/themes/peri/light-mc.css +0 -51
  274. package/docs/themes/peri/light.css +0 -51
  275. package/docs/themes/peri/theme.css +0 -306
  276. package/docs/timepicker.html +0 -160
  277. package/foundations/form/index.ts +0 -174
  278. package/foundations/layout/README.md +0 -127
  279. package/intl.d.ts +0 -9
  280. package/micl.ts +0 -221
  281. package/styles/README.md +0 -196
  282. package/tools/shapes/generate.mjs +0 -828
  283. package/tsconfig.json +0 -116
  284. package/webpack.config.js +0 -104
@@ -1,118 +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 snackbarSelector = '.micl-snackbar';
23
-
24
- interface SnackbarState {
25
- timeoutid?: number;
26
- delay: number;
27
- boundHandleToggle: (event: Event) => void;
28
- boundClearTimer: () => void;
29
- boundHandleMouseLeave: () => void;
30
- }
31
-
32
- const snackbarStates = new WeakMap<HTMLElement, SnackbarState>();
33
-
34
- const clearTimer = (element: HTMLElement): void =>
35
- {
36
- const state = snackbarStates.get(element);
37
- if (state && state.timeoutid) {
38
- clearTimeout(state.timeoutid);
39
- state.timeoutid = undefined;
40
- }
41
- };
42
-
43
- const startTimer = (element: HTMLElement): void =>
44
- {
45
- clearTimer(element);
46
- const state = snackbarStates.get(element);
47
- if (!state) return;
48
-
49
- state.timeoutid = window.setTimeout(() => {
50
- if (element.isConnected && element.matches(':popover-open')) {
51
- element.hidePopover();
52
- }
53
- }, state.delay);
54
- };
55
-
56
- export default
57
- {
58
- initialize: (element: HTMLElement): void =>
59
- {
60
- if (!element.matches(snackbarSelector) || element.dataset.miclinitialized) {
61
- return;
62
- }
63
-
64
- const delayAttr = element.dataset.micldelay;
65
- const delay = delayAttr ? parseInt(delayAttr, 10) : 0;
66
-
67
- if (isNaN(delay) || delay <= 0) return;
68
-
69
- element.dataset.miclinitialized = '1';
70
-
71
- // Create bound handlers specifically for THIS snackbar.
72
- const boundClearTimer = () => clearTimer(element);
73
-
74
- const boundHandleToggle = (event: Event): void =>
75
- {
76
- const toggleEvent = event as ToggleEvent;
77
- if (toggleEvent.newState === 'open') {
78
- startTimer(element);
79
- }
80
- else {
81
- clearTimer(element);
82
- }
83
- };
84
-
85
- const boundHandleMouseLeave = (): void =>
86
- {
87
- if (element.matches(':popover-open')) {
88
- startTimer(element);
89
- }
90
- };
91
-
92
- // Save these references in the WeakMap.
93
- snackbarStates.set(element, {
94
- delay,
95
- boundHandleToggle,
96
- boundClearTimer,
97
- boundHandleMouseLeave
98
- });
99
-
100
- element.addEventListener('toggle', boundHandleToggle);
101
- element.addEventListener('mouseenter', boundClearTimer);
102
- element.addEventListener('mouseleave', boundHandleMouseLeave);
103
- },
104
-
105
- cleanup: (element: HTMLElement): void =>
106
- {
107
- const state = snackbarStates.get(element);
108
-
109
- if (state) {
110
- clearTimer(element);
111
- element.removeEventListener('toggle', state.boundHandleToggle);
112
- element.removeEventListener('mouseenter', state.boundClearTimer);
113
- element.removeEventListener('mouseleave', state.boundHandleMouseLeave);
114
- snackbarStates.delete(element);
115
- }
116
- delete element.dataset.miclinitialized;
117
- }
118
- };
@@ -1,248 +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
- import form from '../../foundations/form';
23
-
24
- export const stepperSelector = '.micl-stepper';
25
-
26
- const ACTIONS_SELECTOR = '.micl-stepper__action-back,.micl-stepper__action-next';
27
- const BUTTON_SELECTOR = '.micl-stepper__header button[role=tab][aria-controls]';
28
- const STEP_CLASS = 'micl-stepper__step';
29
- const STEP_SELECTOR = '.' + STEP_CLASS;
30
-
31
- export default (() =>
32
- {
33
- const getSelectedStep = (stepper: HTMLElement): HTMLElement | null =>
34
- {
35
- let step = stepper.querySelector(`${STEP_SELECTOR}[aria-current=step]`);
36
- if (step) {
37
- return step as HTMLElement;
38
- }
39
- return setSelectedStep(stepper, stepper.querySelector(STEP_SELECTOR));
40
- };
41
-
42
- const getStepNumber = (stepper: HTMLElement, step: HTMLElement): number =>
43
- {
44
- const allSteps = Array.from(stepper.querySelectorAll(STEP_SELECTOR));
45
- const index = allSteps.indexOf(step);
46
-
47
- return index + 1;
48
- };
49
-
50
- const setSelectedStep = (stepper: HTMLElement, step: HTMLElement | null): HTMLElement | null =>
51
- {
52
- if (!step) {
53
- return null;
54
- }
55
- let index = 0;
56
- stepper.querySelectorAll(STEP_SELECTOR).forEach((e, i) =>
57
- {
58
- e.setAttribute('aria-current', e === step ? 'step' : 'false');
59
- if (e === step) {
60
- index = i;
61
- }
62
- });
63
- const button = stepper.querySelectorAll(BUTTON_SELECTOR).item(index);
64
- stepper.querySelectorAll(BUTTON_SELECTOR).forEach(e =>
65
- {
66
- e.setAttribute('aria-selected', e === button ? 'true' : 'false');
67
- });
68
- refresh(stepper, step);
69
-
70
- return step;
71
- };
72
-
73
- const endTransitionSelected = (event: Event): void =>
74
- {
75
- const target = event.currentTarget as Element;
76
- if ((event as TransitionEvent).propertyName !== 'transform' || !target) {
77
- return;
78
- }
79
- target.classList.remove(
80
- 'micl-stepper__step--fromselected',
81
- 'micl-stepper__step--toselected'
82
- );
83
- target.removeEventListener('transitionend', endTransitionSelected);
84
- };
85
-
86
- const goToSibling = (stepper: HTMLElement, selectedStep: HTMLElement, sibling: HTMLElement): void =>
87
- {
88
- selectedStep.addEventListener('transitionend', endTransitionSelected);
89
- selectedStep.classList.add('micl-stepper__step--fromselected');
90
- selectedStep.offsetHeight;
91
-
92
- sibling.addEventListener('transitionend', endTransitionSelected);
93
- sibling.classList.add('micl-stepper__step--toselected');
94
- sibling.offsetHeight;
95
-
96
- setSelectedStep(stepper, sibling);
97
- };
98
-
99
- const isBackAction = (action: HTMLElement): boolean =>
100
- action.classList.contains('micl-stepper__action-back');
101
-
102
- const showHideActions = (stepper: HTMLElement, step: HTMLElement): void =>
103
- {
104
- Array.from(stepper.querySelectorAll<HTMLElement>(ACTIONS_SELECTOR)).forEach(action =>
105
- {
106
- const siblingKey = isBackAction(action) ? 'previousElementSibling' : 'nextElementSibling';
107
- const hasSibling = (step[siblingKey] as Element)?.classList.contains(STEP_CLASS);
108
-
109
- action.classList.toggle('micl-hidden', !hasSibling);
110
- });
111
- };
112
-
113
- const showHideElements = (stepper: HTMLElement, step: HTMLElement): void =>
114
- {
115
- const nrsteps = stepper.querySelectorAll(STEP_SELECTOR).length;
116
- const selectedStep = getStepNumber(stepper, step);
117
-
118
- stepper.querySelectorAll<HTMLElement>('[data-step]').forEach(element =>
119
- {
120
- const stepnr = parseInt(element.dataset.step || '0', 10);
121
- element.classList.toggle(
122
- 'micl-hidden',
123
- stepnr > 0 ? stepnr != selectedStep : nrsteps + stepnr + 1 != selectedStep
124
- );
125
- });
126
- };
127
-
128
- const updateProgress = (stepper: HTMLElement, step: HTMLElement): void =>
129
- {
130
- const index = getStepNumber(stepper, step);
131
- const totalSteps = stepper.querySelectorAll(STEP_SELECTOR).length;
132
- const linear = !stepper.classList.contains('micl-stepper--nonlinear');
133
- const setText = (selector: string, content: string): void => {
134
- stepper.querySelectorAll(selector).forEach(e => { e.textContent = content; });
135
- };
136
-
137
- setText('.micl-stepper__progress-current', `${index}`);
138
- setText('.micl-stepper__progress-total', `${totalSteps}`);
139
-
140
- stepper.querySelectorAll('.micl-stepper__progress-dots').forEach(dots =>
141
- {
142
- const fragment = document.createDocumentFragment();
143
-
144
- dots.innerHTML = '';
145
- for (let i = 1; i <= totalSteps; i++) {
146
- let dot = document.createElement('span');
147
- dot.classList.add('micl-stepper__progress-dot');
148
- if ((linear && (i <= index)) || (!linear && (i === index))) {
149
- dot.classList.add('micl-stepper__progress--done');
150
- }
151
- fragment.appendChild(dot);
152
- }
153
- dots.appendChild(fragment);
154
- });
155
- stepper.querySelectorAll(BUTTON_SELECTOR).forEach((button, i) =>
156
- {
157
- button.classList.toggle(
158
- 'micl-stepper__progress--done',
159
- linear ? i + 1 <= index : i + 1 === index
160
- );
161
- });
162
- };
163
-
164
- const refresh = (stepper: HTMLElement, step: HTMLElement): void =>
165
- {
166
- showHideActions(stepper, step);
167
- showHideElements(stepper, step);
168
- updateProgress(stepper, step);
169
- };
170
-
171
- return {
172
- initialize: (stepper: HTMLElement): void =>
173
- {
174
- if (!stepper.matches(stepperSelector) || stepper.dataset.miclinitialized) {
175
- return;
176
- }
177
- stepper.dataset.miclinitialized = '1';
178
-
179
- const step = getSelectedStep(stepper);
180
- const header = stepper.querySelector('.micl-stepper__header');
181
-
182
- if (step) {
183
- refresh(stepper, step);
184
-
185
- header?.querySelectorAll<HTMLButtonElement>(
186
- 'button[role=tab][aria-controls]'
187
- ).forEach(button =>
188
- {
189
- button.addEventListener('click', () =>
190
- {
191
- if (
192
- ('ariaControlsElements' in Element.prototype)
193
- && button.ariaControlsElements
194
- ) {
195
- setSelectedStep(stepper, button.ariaControlsElements[0] as HTMLElement);
196
- }
197
- else {
198
- const id = button.getAttribute('aria-controls');
199
- if (id) {
200
- setSelectedStep(stepper, document.getElementById(id));
201
- }
202
- }
203
- });
204
- });
205
- }
206
-
207
- Array.from(stepper.querySelectorAll<HTMLElement>(ACTIONS_SELECTOR)).forEach(action =>
208
- {
209
- action.addEventListener('click', function(event: Event)
210
- {
211
- const back = isBackAction(this);
212
- const selectedStep = getSelectedStep(stepper);
213
-
214
- if (
215
- !selectedStep
216
- || (!back
217
- && selectedStep instanceof HTMLFieldSetElement
218
- && !form.validateFieldSet(selectedStep, true))
219
- ) {
220
- if (!back) {
221
- event.stopImmediatePropagation();
222
- }
223
- return;
224
- }
225
- const sibling = selectedStep[
226
- back ? 'previousElementSibling' : 'nextElementSibling'
227
- ] as HTMLElement;
228
-
229
- if (sibling?.classList.contains(STEP_CLASS)) {
230
- goToSibling(stepper, selectedStep, sibling);
231
- }
232
- }, true);
233
- });
234
-
235
- if (stepper instanceof HTMLFormElement) {
236
- stepper.addEventListener('submit', (event: SubmitEvent) =>
237
- {
238
- if (!event.submitter?.classList.contains('micl-form--dosubmit')) {
239
- event.preventDefault();
240
- }
241
- if (!form.validateForm(stepper, true)) {
242
- event.stopImmediatePropagation();
243
- }
244
- }, true);
245
- }
246
- }
247
- };
248
- })();
@@ -1,188 +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 textfieldSelector = '.micl-textfield-outlined > input,.micl-textfield-filled > input';
23
- export const textareaSelector = '.micl-textfield-outlined > textarea,.micl-textfield-filled > textarea';
24
- export const selectSelector = '.micl-textfield-filled > select,.micl-textfield-outlined > select';
25
-
26
- export default (() =>
27
- {
28
- const isTextFieldElement = (target: EventTarget | null): target is
29
- HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement =>
30
- (target as Element).matches(`${textfieldSelector},${selectSelector},${textareaSelector}`);
31
-
32
- const setCounter = (input: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement): void =>
33
- {
34
- if (
35
- !input.parentElement
36
- || input instanceof HTMLSelectElement
37
- || !input.maxLength
38
- ) {
39
- return;
40
- }
41
- const counter = input.parentElement.querySelector('.micl-textfield__character-counter');
42
- if (counter) {
43
- counter.textContent = `${input.value.length}/${input.maxLength}`;
44
- }
45
- };
46
-
47
- const formatAsDate = (input: HTMLInputElement, inputType: string): void =>
48
- {
49
- const partsRegex = /([DMY]{2,4})([^DMY])?([DMY]{2,4})([^DMY])?([DMY]{2,4})/;
50
- const match = (input.dataset.micldateformat || '').match(partsRegex);
51
- if (!match) {
52
- return;
53
- }
54
-
55
- const components = [
56
- { type: match[1], length: match[1].length, separator: match[2] || '' },
57
- { type: match[3], length: match[3].length, separator: match[4] || '' },
58
- { type: match[5], length: match[5].length, separator: '' }
59
- ];
60
-
61
- input.maxLength = components.reduce((sum, c) => sum + c.length + (c.separator ? 1 : 0), 0);
62
-
63
- let value = input.value.replace(/\D/g, ''); // remove all non-digits
64
- let formattedValue = '';
65
- let valueIndex = 0;
66
- let cursorPosition = input.selectionStart || 0;
67
-
68
- for (let i = 0; i < components.length; i++) {
69
- const comp = components[i];
70
- if (value.length < valueIndex) break;
71
-
72
- const segment = value.substring(valueIndex, valueIndex + comp.length);
73
- formattedValue += segment;
74
- valueIndex += segment.length;
75
-
76
- if (segment.length === comp.length && comp.separator) {
77
- formattedValue += comp.separator;
78
- }
79
- }
80
-
81
- const prevLength = input.value.length;
82
- input.value = formattedValue.substring(0, input.maxLength);
83
- const newLength = input.value.length;
84
-
85
- if (inputType.startsWith('deleteContent')) {
86
- if (cursorPosition > 0) {
87
- input.setSelectionRange(cursorPosition, cursorPosition);
88
- }
89
- }
90
- else {
91
- if (newLength > prevLength && newLength > cursorPosition) {
92
- input.setSelectionRange(newLength, newLength);
93
- }
94
- else {
95
- input.setSelectionRange(cursorPosition, cursorPosition);
96
- }
97
- }
98
- };
99
-
100
- const refreshTextField = (event: Event): void =>
101
- {
102
- if (
103
- !isTextFieldElement(event.target)
104
- || !event.target.dataset.miclinitialized
105
- || event.target.disabled
106
- ) {
107
- return;
108
- }
109
-
110
- if (event.target instanceof HTMLInputElement && event.target.dataset.micldateformat) {
111
- formatAsDate(event.target, (event as InputEvent).inputType);
112
- }
113
- if (event.target.value) {
114
- event.target.dataset.miclvalue = '1';
115
- }
116
- else {
117
- delete event.target.dataset.miclvalue;
118
- }
119
-
120
- setCounter(event.target);
121
- };
122
-
123
- return {
124
- initialize: (input: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement): void =>
125
- {
126
- if (input.dataset.miclinitialized) {
127
- return;
128
- }
129
- input.dataset.miclinitialized = '1';
130
-
131
- if (input.value) {
132
- input.dataset.miclvalue = '1';
133
- }
134
-
135
- if (input instanceof HTMLSelectElement) {
136
- input.addEventListener('mousedown', () =>
137
- {
138
- const rect = input.getBoundingClientRect();
139
- const spaceAbove = rect.top;
140
- const spaceBelow = window.innerHeight - rect.bottom;
141
-
142
- !input.matches(':open') && input.style.setProperty(
143
- '--md-comp-select-picker-origin',
144
- spaceAbove > spaceBelow ? 'left bottom' : 'left top'
145
- );
146
- });
147
- }
148
-
149
- if (input.matches('input[type=time][data-timepicker],input[type=date][data-datepicker]')) {
150
- const picker = !input.dataset.timepicker ? (!input.dataset.datepicker ? null :
151
- document.getElementById(input.dataset.datepicker)) :
152
- document.getElementById(input.dataset.timepicker);
153
- if (picker instanceof HTMLDialogElement) {
154
- input.addEventListener('click', (event: Event) =>
155
- {
156
- event.preventDefault();
157
- picker.showModal();
158
- });
159
- input.addEventListener('keydown', (event: Event) =>
160
- {
161
- if (!(event instanceof KeyboardEvent)) {
162
- return;
163
- }
164
- switch (event.key) {
165
- case 'Enter':
166
- case ' ':
167
- event.preventDefault();
168
- picker.showModal();
169
- break;
170
- default:
171
- }
172
- });
173
- }
174
- }
175
-
176
- setCounter(input);
177
- },
178
-
179
- change: (event: Event): void =>
180
- {
181
- refreshTextField(event);
182
- },
183
- input: (event: Event): void =>
184
- {
185
- refreshTextField(event);
186
- }
187
- };
188
- })();