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.
- package/README.md +106 -18
- package/components/README.md +1 -1
- package/components/accordion/README.md +6 -6
- package/components/alert/README.md +10 -10
- package/components/alert/index.scss +27 -52
- package/components/appbar/README.md +19 -6
- package/components/appbar/index.scss +40 -44
- package/components/badge/README.md +12 -10
- package/components/badge/index.scss +21 -25
- package/components/bottomsheet/README.md +26 -1
- package/components/bottomsheet/index.scss +58 -44
- package/components/button/README.md +70 -10
- package/components/button/_shared.scss +210 -0
- package/components/button/index.scss +75 -389
- package/components/card/README.md +97 -85
- package/components/card/index.scss +46 -65
- package/components/checkbox/README.md +25 -14
- package/{tools/shapes/check.mjs → components/checkbox/_label.scss} +37 -42
- package/components/checkbox/index.scss +66 -66
- package/components/chip/README.md +186 -0
- package/components/chip/index.scss +285 -0
- package/components/datepicker/README.md +79 -0
- package/components/datepicker/index.scss +346 -315
- package/components/dialog/README.md +20 -10
- package/components/dialog/index.scss +55 -66
- package/components/divider/README.md +16 -15
- package/components/divider/index.scss +9 -25
- package/components/iconbutton/README.md +63 -12
- package/components/iconbutton/index.scss +142 -303
- package/components/list/README.md +89 -156
- package/components/list/index.scss +34 -36
- package/components/menu/README.md +81 -155
- package/components/menu/index.scss +52 -58
- package/components/navigationbar/README.md +108 -0
- package/components/navigationbar/index.scss +185 -0
- package/components/navigationrail/README.md +62 -37
- package/components/navigationrail/_navitem.scss +96 -0
- package/components/navigationrail/index.scss +78 -132
- package/components/progressindicator/README.md +83 -47
- package/components/progressindicator/index.scss +622 -172
- package/components/radio/README.md +11 -9
- package/components/radio/index.scss +36 -33
- package/components/select/README.md +12 -7
- package/components/select/index.scss +26 -34
- package/components/shapes/README.md +3 -3
- package/components/shapes/index.scss +0 -1
- package/components/sidesheet/README.md +21 -9
- package/components/sidesheet/index.scss +38 -46
- package/components/slider/README.md +21 -0
- package/components/slider/index.scss +108 -139
- package/components/snackbar/README.md +32 -35
- package/components/snackbar/index.scss +10 -22
- package/components/stepper/README.md +14 -7
- package/components/stepper/index.scss +58 -39
- package/components/switch/README.md +22 -15
- package/components/switch/index.scss +68 -60
- package/components/textfield/README.md +48 -5
- package/components/textfield/index.scss +192 -248
- package/components/timepicker/README.md +53 -23
- package/components/timepicker/index.scss +110 -128
- package/dist/alert.css +1 -1
- package/dist/alert.js +1 -1
- package/dist/appbar.css +1 -1
- package/dist/appbar.js +1 -1
- package/dist/badge.css +1 -1
- package/dist/badge.js +1 -1
- package/dist/base.css +1 -0
- package/dist/base.js +1 -0
- package/dist/bottomsheet.css +1 -1
- package/dist/bottomsheet.js +1 -1
- package/dist/button.css +1 -1
- package/dist/button.js +1 -1
- package/dist/card.css +1 -1
- package/dist/card.js +1 -1
- package/dist/checkbox.css +1 -1
- package/dist/checkbox.js +1 -1
- package/dist/chip.css +1 -0
- package/dist/chip.js +1 -0
- package/dist/components/button/index.d.ts +1 -1
- package/dist/components/iconbutton/index.d.ts +2 -7
- package/dist/components/slider/index.d.ts +1 -1
- package/dist/components/textfield/index.d.ts +2 -2
- package/dist/datepicker.css +1 -1
- package/dist/datepicker.js +1 -1
- package/dist/dialog.css +1 -1
- package/dist/dialog.js +1 -1
- package/dist/divider.css +1 -1
- package/dist/divider.js +1 -1
- package/dist/field.css +1 -0
- package/dist/field.js +1 -0
- package/dist/foundations/form/index.js +1 -1
- package/dist/foundations/runtime.d.ts +15 -0
- package/dist/foundations/runtime.js +1 -0
- package/dist/iconbutton.css +1 -1
- package/dist/iconbutton.js +1 -1
- package/dist/layout.css +1 -1
- package/dist/layout.js +1 -1
- package/dist/list.css +1 -1
- package/dist/list.js +1 -1
- package/dist/menu.css +1 -1
- package/dist/menu.js +1 -1
- package/dist/micl.css +1 -1
- package/dist/micl.d.ts +14 -5
- package/dist/micl.js +1 -1
- package/dist/navigationbar.css +1 -0
- package/dist/navigationbar.js +1 -0
- package/dist/navigationrail.css +1 -1
- package/dist/navigationrail.js +1 -1
- package/dist/progressindicator.css +1 -1
- package/dist/progressindicator.js +1 -1
- package/dist/radio.css +1 -1
- package/dist/radio.js +1 -1
- package/dist/scrollbar.js +1 -1
- package/dist/select.css +1 -1
- package/dist/select.js +1 -1
- package/dist/shapes.css +1 -1
- package/dist/shapes.js +1 -1
- package/dist/sidesheet.css +1 -1
- package/dist/sidesheet.js +1 -1
- package/dist/slider.css +1 -1
- package/dist/slider.js +1 -1
- package/dist/snackbar.css +1 -1
- package/dist/snackbar.js +1 -1
- package/dist/stepper.css +1 -1
- package/dist/stepper.js +1 -1
- package/dist/switch.css +1 -1
- package/dist/switch.js +1 -1
- package/dist/textfield.css +1 -1
- package/dist/textfield.js +1 -1
- package/dist/timepicker.css +1 -1
- package/dist/timepicker.js +1 -1
- package/foundations/_index.scss +35 -0
- package/foundations/{index.scss → base/index.scss} +21 -56
- package/foundations/field/index.scss +37 -0
- package/foundations/layout/index.scss +64 -65
- package/package.json +23 -9
- package/styles/statelayer.scss +20 -5
- package/styles.scss +5 -2
- package/.claude/settings.local.json +0 -14
- package/.editorconfig +0 -12
- package/.gitattributes +0 -9
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -35
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- package/CLAUDE.md +0 -53
- package/CODE_OF_CONDUCT.md +0 -128
- package/components/bottomsheet/index.ts +0 -153
- package/components/button/index.ts +0 -79
- package/components/checkbox/index.ts +0 -148
- package/components/datepicker/index.ts +0 -693
- package/components/iconbutton/index.ts +0 -77
- package/components/list/index.ts +0 -138
- package/components/menu/index.ts +0 -145
- package/components/navigationrail/index.ts +0 -87
- package/components/progressindicator/index.ts +0 -77
- package/components/slider/index.ts +0 -149
- package/components/snackbar/index.ts +0 -118
- package/components/stepper/index.ts +0 -248
- package/components/textfield/index.ts +0 -188
- package/components/timepicker/index.ts +0 -413
- package/dist/components/progressindicator/index.d.ts +0 -6
- package/dist/foundations.css +0 -1
- package/dist/foundations.js +0 -1
- package/docs/accordion.html +0 -344
- package/docs/alert.html +0 -177
- package/docs/bottomsheet.html +0 -240
- package/docs/button.html +0 -290
- package/docs/card-awards.webp +0 -0
- package/docs/card-cabinet.webp +0 -0
- package/docs/card-city.webp +0 -0
- package/docs/card-fingerprint.webp +0 -0
- package/docs/card-holiday.webp +0 -0
- package/docs/card-names.webp +0 -0
- package/docs/card.html +0 -159
- package/docs/checkbox.html +0 -147
- package/docs/datepicker.html +0 -274
- package/docs/dialog.html +0 -195
- package/docs/divider.html +0 -139
- package/docs/docs.css +0 -26
- package/docs/docs.js +0 -139
- package/docs/iconbutton.html +0 -329
- package/docs/index.html +0 -431
- package/docs/list.html +0 -310
- package/docs/menu.html +0 -574
- package/docs/micl.css +0 -1
- package/docs/micl.js +0 -1
- package/docs/navigationrail.html +0 -138
- package/docs/progressindicator.html +0 -288
- package/docs/radio.html +0 -123
- package/docs/select.html +0 -337
- package/docs/shapes.css +0 -1
- package/docs/shapes.html +0 -159
- package/docs/shapes.js +0 -1
- package/docs/sidesheet.html +0 -149
- package/docs/slider.html +0 -141
- package/docs/snackbar.html +0 -102
- package/docs/stepper.html +0 -319
- package/docs/switch.html +0 -196
- package/docs/textfield.html +0 -208
- package/docs/themes/airblue/dark-hc.css +0 -51
- package/docs/themes/airblue/dark-mc.css +0 -51
- package/docs/themes/airblue/dark.css +0 -51
- package/docs/themes/airblue/light-hc.css +0 -51
- package/docs/themes/airblue/light-mc.css +0 -51
- package/docs/themes/airblue/light.css +0 -51
- package/docs/themes/airblue/theme.css +0 -306
- package/docs/themes/barnred/dark-hc.css +0 -51
- package/docs/themes/barnred/dark-mc.css +0 -51
- package/docs/themes/barnred/dark.css +0 -51
- package/docs/themes/barnred/light-hc.css +0 -51
- package/docs/themes/barnred/light-mc.css +0 -51
- package/docs/themes/barnred/light.css +0 -51
- package/docs/themes/barnred/theme.css +0 -306
- package/docs/themes/citrine/dark-hc.css +0 -51
- package/docs/themes/citrine/dark-mc.css +0 -51
- package/docs/themes/citrine/dark.css +0 -51
- package/docs/themes/citrine/light-hc.css +0 -51
- package/docs/themes/citrine/light-mc.css +0 -51
- package/docs/themes/citrine/light.css +0 -51
- package/docs/themes/citrine/theme.css +0 -306
- package/docs/themes/gray/dark-hc.css +0 -51
- package/docs/themes/gray/dark-mc.css +0 -51
- package/docs/themes/gray/dark.css +0 -51
- package/docs/themes/gray/light-hc.css +0 -51
- package/docs/themes/gray/light-mc.css +0 -51
- package/docs/themes/gray/light.css +0 -51
- package/docs/themes/gray/theme.css +0 -306
- package/docs/themes/greenery/dark-hc.css +0 -51
- package/docs/themes/greenery/dark-mc.css +0 -51
- package/docs/themes/greenery/dark.css +0 -51
- package/docs/themes/greenery/light-hc.css +0 -51
- package/docs/themes/greenery/light-mc.css +0 -51
- package/docs/themes/greenery/light.css +0 -51
- package/docs/themes/greenery/theme.css +0 -306
- package/docs/themes/hermana/dark-hc.css +0 -51
- package/docs/themes/hermana/dark-mc.css +0 -51
- package/docs/themes/hermana/dark.css +0 -51
- package/docs/themes/hermana/light-hc.css +0 -51
- package/docs/themes/hermana/light-mc.css +0 -51
- package/docs/themes/hermana/light.css +0 -51
- package/docs/themes/hermana/theme.css +0 -306
- package/docs/themes/illuminating/dark-hc.css +0 -51
- package/docs/themes/illuminating/dark-mc.css +0 -51
- package/docs/themes/illuminating/dark.css +0 -51
- package/docs/themes/illuminating/light-hc.css +0 -51
- package/docs/themes/illuminating/light-mc.css +0 -51
- package/docs/themes/illuminating/light.css +0 -51
- package/docs/themes/illuminating/theme.css +0 -306
- package/docs/themes/magenta/dark-hc.css +0 -51
- package/docs/themes/magenta/dark-mc.css +0 -51
- package/docs/themes/magenta/dark.css +0 -51
- package/docs/themes/magenta/light-hc.css +0 -51
- package/docs/themes/magenta/light-mc.css +0 -51
- package/docs/themes/magenta/light.css +0 -51
- package/docs/themes/magenta/theme.css +0 -306
- package/docs/themes/mocha/dark-hc.css +0 -51
- package/docs/themes/mocha/dark-mc.css +0 -51
- package/docs/themes/mocha/dark.css +0 -51
- package/docs/themes/mocha/light-hc.css +0 -51
- package/docs/themes/mocha/light-mc.css +0 -51
- package/docs/themes/mocha/light.css +0 -51
- package/docs/themes/mocha/theme.css +0 -306
- package/docs/themes/olivegreen/dark-hc.css +0 -51
- package/docs/themes/olivegreen/dark-mc.css +0 -51
- package/docs/themes/olivegreen/dark.css +0 -51
- package/docs/themes/olivegreen/light-hc.css +0 -51
- package/docs/themes/olivegreen/light-mc.css +0 -51
- package/docs/themes/olivegreen/light.css +0 -51
- package/docs/themes/olivegreen/theme.css +0 -306
- package/docs/themes/peri/dark-hc.css +0 -51
- package/docs/themes/peri/dark-mc.css +0 -51
- package/docs/themes/peri/dark.css +0 -51
- package/docs/themes/peri/light-hc.css +0 -51
- package/docs/themes/peri/light-mc.css +0 -51
- package/docs/themes/peri/light.css +0 -51
- package/docs/themes/peri/theme.css +0 -306
- package/docs/timepicker.html +0 -160
- package/foundations/form/index.ts +0 -174
- package/foundations/layout/README.md +0 -127
- package/intl.d.ts +0 -9
- package/micl.ts +0 -221
- package/styles/README.md +0 -196
- package/tools/shapes/generate.mjs +0 -828
- package/tsconfig.json +0 -116
- 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
|
-
})();
|