material-inspired-component-library 5.0.1 → 6.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 +6 -2
- package/components/button/README.md +9 -1
- package/components/button/index.ts +21 -37
- package/components/datepicker/README.md +146 -0
- package/components/datepicker/index.scss +2 -1
- package/components/datepicker/index.ts +210 -109
- package/components/iconbutton/README.md +10 -1
- package/components/iconbutton/index.ts +21 -37
- package/components/textfield/index.ts +56 -0
- package/components/timepicker/README.md +8 -9
- package/components/timepicker/index.ts +5 -5
- package/dist/components/button/index.d.ts +2 -1
- package/dist/components/iconbutton/index.d.ts +2 -1
- package/dist/datepicker.css +1 -1
- package/dist/micl.css +1 -1
- package/dist/micl.js +1 -1
- package/docs/bottomsheet.html +3 -3
- package/docs/button.html +16 -16
- package/docs/datepicker.html +133 -9
- package/docs/dialog.html +5 -5
- package/docs/docs.js +22 -1
- package/docs/iconbutton.html +8 -8
- package/docs/index.html +3 -2
- package/docs/micl.css +1 -1
- package/docs/micl.js +1 -1
- package/docs/navigationrail.html +2 -2
- package/docs/sidesheet.html +3 -3
- package/docs/themes/gray/dark-hc.css +51 -0
- package/docs/themes/gray/dark-mc.css +51 -0
- package/docs/themes/gray/dark.css +51 -0
- package/docs/themes/gray/light-hc.css +51 -0
- package/docs/themes/gray/light-mc.css +51 -0
- package/docs/themes/gray/light.css +51 -0
- package/docs/themes/gray/theme.css +306 -0
- package/docs/themes/greenery/dark-hc.css +51 -0
- package/docs/themes/greenery/dark-mc.css +51 -0
- package/docs/themes/greenery/dark.css +51 -0
- package/docs/themes/greenery/light-hc.css +51 -0
- package/docs/themes/greenery/light-mc.css +51 -0
- package/docs/themes/greenery/light.css +51 -0
- package/docs/themes/greenery/theme.css +306 -0
- package/docs/themes/hermana/dark-hc.css +51 -0
- package/docs/themes/hermana/dark-mc.css +51 -0
- package/docs/themes/hermana/dark.css +51 -0
- package/docs/themes/hermana/light-hc.css +51 -0
- package/docs/themes/hermana/light-mc.css +51 -0
- package/docs/themes/hermana/light.css +51 -0
- package/docs/themes/hermana/theme.css +306 -0
- package/docs/themes/illuminating/dark-hc.css +51 -0
- package/docs/themes/illuminating/dark-mc.css +51 -0
- package/docs/themes/illuminating/dark.css +51 -0
- package/docs/themes/illuminating/light-hc.css +51 -0
- package/docs/themes/illuminating/light-mc.css +51 -0
- package/docs/themes/illuminating/light.css +51 -0
- package/docs/themes/illuminating/theme.css +306 -0
- package/docs/themes/magenta/dark-hc.css +51 -0
- package/docs/themes/magenta/dark-mc.css +51 -0
- package/docs/themes/magenta/dark.css +51 -0
- package/docs/themes/magenta/light-hc.css +51 -0
- package/docs/themes/magenta/light-mc.css +51 -0
- package/docs/themes/magenta/light.css +51 -0
- package/docs/themes/magenta/theme.css +306 -0
- package/docs/themes/mocha/dark-hc.css +51 -0
- package/docs/themes/mocha/dark-mc.css +51 -0
- package/docs/themes/mocha/dark.css +51 -0
- package/docs/themes/mocha/light-hc.css +51 -0
- package/docs/themes/mocha/light-mc.css +51 -0
- package/docs/themes/mocha/light.css +51 -0
- package/docs/themes/mocha/theme.css +306 -0
- package/docs/themes/peri/dark-hc.css +51 -0
- package/docs/themes/peri/dark-mc.css +51 -0
- package/docs/themes/peri/dark.css +51 -0
- package/docs/themes/peri/light-hc.css +51 -0
- package/docs/themes/peri/light-mc.css +51 -0
- package/docs/themes/peri/light.css +51 -0
- package/docs/themes/peri/theme.css +306 -0
- package/docs/timepicker.html +2 -2
- package/package.json +1 -1
- package/themes/gray/dark-hc.css +51 -0
- package/themes/gray/dark-mc.css +51 -0
- package/themes/gray/dark.css +51 -0
- package/themes/gray/light-hc.css +51 -0
- package/themes/gray/light-mc.css +51 -0
- package/themes/gray/light.css +51 -0
- package/themes/gray/theme.css +306 -0
- package/themes/greenery/dark-hc.css +51 -0
- package/themes/greenery/dark-mc.css +51 -0
- package/themes/greenery/dark.css +51 -0
- package/themes/greenery/light-hc.css +51 -0
- package/themes/greenery/light-mc.css +51 -0
- package/themes/greenery/light.css +51 -0
- package/themes/greenery/theme.css +306 -0
- package/themes/hermana/dark-hc.css +51 -0
- package/themes/hermana/dark-mc.css +51 -0
- package/themes/hermana/dark.css +51 -0
- package/themes/hermana/light-hc.css +51 -0
- package/themes/hermana/light-mc.css +51 -0
- package/themes/hermana/light.css +51 -0
- package/themes/hermana/theme.css +306 -0
- package/themes/illuminating/dark-hc.css +51 -0
- package/themes/illuminating/dark-mc.css +51 -0
- package/themes/illuminating/dark.css +51 -0
- package/themes/illuminating/light-hc.css +51 -0
- package/themes/illuminating/light-mc.css +51 -0
- package/themes/illuminating/light.css +51 -0
- package/themes/illuminating/theme.css +306 -0
- package/themes/magenta/dark-hc.css +51 -0
- package/themes/magenta/dark-mc.css +51 -0
- package/themes/magenta/dark.css +51 -0
- package/themes/magenta/light-hc.css +51 -0
- package/themes/magenta/light-mc.css +51 -0
- package/themes/magenta/light.css +51 -0
- package/themes/magenta/theme.css +306 -0
- package/themes/mocha/dark-hc.css +51 -0
- package/themes/mocha/dark-mc.css +51 -0
- package/themes/mocha/dark.css +51 -0
- package/themes/mocha/light-hc.css +51 -0
- package/themes/mocha/light-mc.css +51 -0
- package/themes/mocha/light.css +51 -0
- package/themes/mocha/theme.css +306 -0
- package/themes/peri/dark-hc.css +51 -0
- package/themes/peri/dark-mc.css +51 -0
- package/themes/peri/dark.css +51 -0
- package/themes/peri/light-hc.css +51 -0
- package/themes/peri/light-mc.css +51 -0
- package/themes/peri/light.css +51 -0
- package/themes/peri/theme.css +306 -0
package/README.md
CHANGED
|
@@ -102,7 +102,7 @@ The library currently consists of the following components:
|
|
|
102
102
|
- [x] [Button](components/button/README.md)
|
|
103
103
|
- [x] [Card](components/card/README.md)
|
|
104
104
|
- [x] [Checkbox](components/checkbox/README.md)
|
|
105
|
-
- [
|
|
105
|
+
- [x] [Date picker](components/datepicker/README.md)
|
|
106
106
|
- [x] [Dialog](components/dialog/README.md)
|
|
107
107
|
- [x] [Divider](components/divider/README.md)
|
|
108
108
|
- [x] [Icon button](components/iconbutton/README.md)
|
|
@@ -120,11 +120,15 @@ The library currently consists of the following components:
|
|
|
120
120
|
|
|
121
121
|
## Change Log ↪️
|
|
122
122
|
|
|
123
|
+
### 6.0.0 (23.12.2025)
|
|
124
|
+
- **BREAKING**: Use command-attribute to control toggle buttons.
|
|
125
|
+
- **Date picker**: New component.
|
|
126
|
+
|
|
123
127
|
### 5.0.0 (02.12.2025)
|
|
124
128
|
- **Time picker**: New component.
|
|
125
129
|
|
|
126
130
|
### 4.0.0 (27.10.2025)
|
|
127
|
-
- **BREAKING**: Moved layout.scss
|
|
131
|
+
- **BREAKING**: Moved layout.scss to sub-folder.
|
|
128
132
|
- **Alert**: New component.
|
|
129
133
|
- **Stepper**: New component.
|
|
130
134
|
|
|
@@ -63,9 +63,17 @@ A toggle button has two states: **on** (selected) and **off** (unselected). To c
|
|
|
63
63
|
**Example: A selected toggle button**
|
|
64
64
|
|
|
65
65
|
```HTML
|
|
66
|
-
<button
|
|
66
|
+
<button
|
|
67
|
+
type="button"
|
|
68
|
+
id="id0"
|
|
69
|
+
class="micl-button-tonal-s micl-button--toggle micl-button--selected"
|
|
70
|
+
commandfor="id0"
|
|
71
|
+
command="--micl-toggle"
|
|
72
|
+
>Selected</button>
|
|
67
73
|
```
|
|
68
74
|
|
|
75
|
+
The self-targeting `command` property (`--micl-toggle`) toggles the button state whenever the user interacts with the button.
|
|
76
|
+
|
|
69
77
|
## Icons
|
|
70
78
|
To add a leading icon to a button, include an element with the `micl-button__icon` class inside the `<button>`:
|
|
71
79
|
|
|
@@ -19,58 +19,42 @@
|
|
|
19
19
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
20
|
// SOFTWARE.
|
|
21
21
|
|
|
22
|
-
export const buttonSelector = 'button
|
|
22
|
+
export const buttonSelector = 'button.micl-button--toggle';
|
|
23
23
|
|
|
24
24
|
export default (() =>
|
|
25
25
|
{
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
if (event.target.classList.contains('micl-button--toggle')) {
|
|
40
|
-
event.target.classList.add('micl-button--toggled');
|
|
41
|
-
event.target.classList.toggle('micl-button--selected');
|
|
42
|
-
if (!!event.target.dataset.miclalt) {
|
|
43
|
-
[event.target.textContent, event.target.dataset.miclalt] =
|
|
44
|
-
[event.target.dataset.miclalt, event.target.textContent];
|
|
26
|
+
return {
|
|
27
|
+
command: (event: Event): void =>
|
|
28
|
+
{
|
|
29
|
+
const target = event.target as HTMLButtonElement;
|
|
30
|
+
|
|
31
|
+
if (
|
|
32
|
+
target.matches(buttonSelector)
|
|
33
|
+
&& !target.disabled
|
|
34
|
+
&& (event as any).command === '--micl-toggle'
|
|
35
|
+
) {
|
|
36
|
+
target.classList.add('micl-button--toggled');
|
|
37
|
+
target.classList.toggle('micl-button--selected');
|
|
45
38
|
}
|
|
46
|
-
}
|
|
47
|
-
};
|
|
39
|
+
},
|
|
48
40
|
|
|
49
|
-
|
|
50
|
-
initialize: (element: HTMLButtonElement) =>
|
|
41
|
+
initialize: function(element: HTMLButtonElement): void
|
|
51
42
|
{
|
|
52
43
|
if (
|
|
53
|
-
!element.matches(
|
|
44
|
+
!element.matches(buttonSelector)
|
|
54
45
|
|| element.dataset.miclinitialized
|
|
55
46
|
) {
|
|
56
47
|
return;
|
|
57
48
|
}
|
|
58
49
|
element.dataset.miclinitialized = '1';
|
|
59
50
|
|
|
60
|
-
|
|
61
|
-
(element.popoverTargetElement instanceof HTMLDialogElement)
|
|
62
|
-
&& !element.popoverTargetElement.hasAttribute('popover')
|
|
63
|
-
) {
|
|
64
|
-
element.addEventListener('click', onClick);
|
|
65
|
-
}
|
|
66
|
-
else if (element.classList.contains('micl-button--toggle')) {
|
|
67
|
-
element.addEventListener('click', onClick);
|
|
68
|
-
}
|
|
51
|
+
element.addEventListener('command', this.command);
|
|
69
52
|
},
|
|
70
|
-
|
|
53
|
+
|
|
54
|
+
cleanup: function(element: HTMLButtonElement): void
|
|
71
55
|
{
|
|
72
|
-
if (element.matches(
|
|
73
|
-
document.removeEventListener('
|
|
56
|
+
if (element.matches(buttonSelector)) {
|
|
57
|
+
document.removeEventListener('command', this.command);
|
|
74
58
|
delete element.dataset.miclinitialized;
|
|
75
59
|
}
|
|
76
60
|
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# Date picker
|
|
2
|
+
This component implements the [Material Design 3 Expressive Date picker](https://m3.material.io/components/date-pickers/overview) design. It allows users to select a date using either a text input or a calendar interface.
|
|
3
|
+
|
|
4
|
+
## Basic Usage
|
|
5
|
+
|
|
6
|
+
### HTML
|
|
7
|
+
The Date Picker component is an extension of the [**Dialog** component](../dialog/README.md). To create a basic date picker, use a `<dialog>` element with both `micl-dialog` and `micl-datepicker` classes.
|
|
8
|
+
|
|
9
|
+
```HTML
|
|
10
|
+
<dialog id="mydatepicker" class="micl-dialog micl-datepicker" closedby="closerequest" aria-labelledby="mytitle">
|
|
11
|
+
<form method="dialog">
|
|
12
|
+
<div class="micl-dialog__headline">
|
|
13
|
+
<h2 id="mytitle">Enter date</h2>
|
|
14
|
+
<span class="micl-dialog__supporting-text">Select date</span>
|
|
15
|
+
<button type="button" class="micl-datepicker__inputmode micl-iconbutton-standard-s material-symbols-outlined" data-miclalt="calendar_today">edit</button>
|
|
16
|
+
<hr class="micl-divider">
|
|
17
|
+
<div class="micl-datepicker__month-selector">
|
|
18
|
+
<button type="button" class="micl-datepicker__previous micl-iconbutton-standard-xs material-symbols-outlined" aria-label="Previous month">chevron_left</button>
|
|
19
|
+
<button type="button" class="micl-datepicker__month micl-button-text-xs">
|
|
20
|
+
<span class="micl-button__icon material-symbols-outlined" aria-hidden="true">arrow_drop_down</span>
|
|
21
|
+
</button>
|
|
22
|
+
<button type="button" class="micl-datepicker__next micl-iconbutton-standard-xs material-symbols-outlined" aria-label="Next month">chevron_right</button>
|
|
23
|
+
</div>
|
|
24
|
+
<div class="micl-datepicker__year-selector">
|
|
25
|
+
<button type="button" class="micl-datepicker__previous micl-iconbutton-standard-xs material-symbols-outlined" aria-label="Previous year">chevron_left</button>
|
|
26
|
+
<button type="button" class="micl-datepicker__year micl-button-text-xs">
|
|
27
|
+
<span class="micl-button__icon material-symbols-outlined" aria-hidden="true">arrow_drop_down</span>
|
|
28
|
+
</button>
|
|
29
|
+
<button type="button" class="micl-datepicker__next micl-iconbutton-standard-xs material-symbols-outlined" aria-label="Next year">chevron_right</button>
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
|
|
33
|
+
<div class="micl-dialog__content">
|
|
34
|
+
<div class="micl-datepicker__calendars"></div>
|
|
35
|
+
<div class="micl-datepicker__years"></div>
|
|
36
|
+
<div class="micl-datepicker__months"></div>
|
|
37
|
+
<div class="micl-datepicker__input micl-textfield-outlined">
|
|
38
|
+
<label for="mydate">Date</label>
|
|
39
|
+
<input type="text" id="mydate">
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
|
|
43
|
+
<div class="micl-dialog__actions">
|
|
44
|
+
<button class="micl-button-text-s" value="">Cancel</button>
|
|
45
|
+
<button class="micl-button-text-s" value="OK">OK</button>
|
|
46
|
+
</div>
|
|
47
|
+
</form>
|
|
48
|
+
</dialog>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### CSS
|
|
52
|
+
Import both the date picker and the dialog styles into your project:
|
|
53
|
+
|
|
54
|
+
```CSS
|
|
55
|
+
@use "material-inspired-component-library/dist/dialog";
|
|
56
|
+
@use "material-inspired-component-library/dist/datepicker";
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Or import all MICL styles:
|
|
60
|
+
```CSS
|
|
61
|
+
@use "material-inspired-component-library/styles";
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### JavaScript
|
|
65
|
+
This component requires JavaScript to function:
|
|
66
|
+
|
|
67
|
+
```JavaScript
|
|
68
|
+
import micl from "material-inspired-component-library/dist/micl";
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
This will initialize any Date picker component, including those that will be added to the DOM later on.
|
|
72
|
+
|
|
73
|
+
### Live Demo
|
|
74
|
+
A live example of the [Date picker component](https://henkpb.github.io/micl/datepicker.html) is available to interact with.
|
|
75
|
+
|
|
76
|
+
## Variants
|
|
77
|
+
Because the Date picker component relies on the Dialog component, it utilizes the same utility classes for content structure. Refer to the [Dialog component documentation](../dialog/README.md) for structural details.
|
|
78
|
+
|
|
79
|
+
### Date Picker Structure
|
|
80
|
+
For the picker to function, the `micl-dialog__content` area **must** contain the `<div class="micl-datepicker__calendars">` container. This holds the month-based calendars.
|
|
81
|
+
|
|
82
|
+
Additionally, the content area may contain:
|
|
83
|
+
|
|
84
|
+
- A container for selecting a year: `<div class="micl-datepicker__years">`
|
|
85
|
+
|
|
86
|
+
- A container for selecting a month: `<div class="micl-datepicker__months">`
|
|
87
|
+
|
|
88
|
+
- A [Text field component](../textfield/README.md) with the `micl-datepicker__input` class for manual date entry.
|
|
89
|
+
|
|
90
|
+
The `micl-dialog__headline` area may contain:
|
|
91
|
+
|
|
92
|
+
- **Title**: A heading element (e.g., `<h2>`) to display the selected date.
|
|
93
|
+
|
|
94
|
+
- **Supporting label**: A text element with the class `micl-dialog__supporting-text`.
|
|
95
|
+
|
|
96
|
+
- **Month selector**: A container with three [Icon button components](../iconbutton/README.md):
|
|
97
|
+
- `micl-datepicker__month`: Opens the month selection container.
|
|
98
|
+
- `micl-datepicker__previous`: Navigates to the previous month.
|
|
99
|
+
- `micl-datepicker__next`: Navigates to the next month.
|
|
100
|
+
|
|
101
|
+
- **Year selector**: A container with three [Icon button components](../iconbutton/README.md):
|
|
102
|
+
- `micl-datepicker__year`: Opens the year selection container.
|
|
103
|
+
- `micl-datepicker__previous`: Navigates to the previous year.
|
|
104
|
+
- `micl-datepicker__next`: Navigates to the next year.
|
|
105
|
+
|
|
106
|
+
Any item not required for your implementation may be omitted.
|
|
107
|
+
|
|
108
|
+
#### Input Mode Switching
|
|
109
|
+
To allow users to toggle between the calendar view and the manual date input, add an icon button to the `micl-dialog__headline` area:
|
|
110
|
+
|
|
111
|
+
- Class: `micl-datepicker__inputmode`
|
|
112
|
+
- Data Attribute: `data-miclalt="calendar_today"` (defines the icon to show when toggled).
|
|
113
|
+
|
|
114
|
+
### Integration
|
|
115
|
+
You can trigger the Date picker component from standard input fields or buttons.
|
|
116
|
+
|
|
117
|
+
#### Connecting to an Input Field
|
|
118
|
+
To replace the browser's native date picker, add the `data-datepicker` attribute to an `<input>` element. The value of this attribute must match the `id` of your Date picker dialog.
|
|
119
|
+
|
|
120
|
+
```HTML
|
|
121
|
+
<input type="date" data-datepicker="mydatepicker" value="2025-12-02">
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
- **Behavior**: Clicking the input opens the picker initialized with the input's current value.
|
|
125
|
+
- **Reusability**: Multiple input fields can target the same Date picker component ID. The picker will automatically update to reflect the date of the specific input field engaged by the user.
|
|
126
|
+
|
|
127
|
+
**Docked Positioning** By default, the Date picker opens in the center of the screen. To anchor it to the input field, use the `micl-dialog--docked` class and CSS Anchor positioning.
|
|
128
|
+
|
|
129
|
+
```HTML
|
|
130
|
+
<dialog id="mydatepicker" class="micl-dialog micl-dialog--docked micl-datepicker" style="position-anchor:--myanchor">
|
|
131
|
+
|
|
132
|
+
<div class="micl-textfield-outlined" style="anchor-name:--myanchor">
|
|
133
|
+
<label for="mytextfield">Start date</label>
|
|
134
|
+
<input type="date" id="mytextfield" data-datepicker="mydatepicker">
|
|
135
|
+
</div>
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
#### Connecting to a Button
|
|
139
|
+
You can trigger the picker from a button using the standard `popovertarget` attribute.
|
|
140
|
+
|
|
141
|
+
```HTML
|
|
142
|
+
<button type="button" class="micl-button-text-m" popovertarget="mydatepicker" value="2026-01-23">23.01.2026</button>
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
- **Behavior**: The Date picker reads from and writes to the button's value attribute.
|
|
146
|
+
- **Formatting**: The component automatically updates the button's text content with the selected date, formatted according to the user's locale.
|
|
@@ -385,7 +385,8 @@ dialog.micl-dialog.micl-datepicker {
|
|
|
385
385
|
margin-block-end: 16px;
|
|
386
386
|
|
|
387
387
|
&.micl-datepicker__view-hidden,
|
|
388
|
-
input[type=date]::-webkit-calendar-picker-indicator
|
|
388
|
+
input[type=date]::-webkit-calendar-picker-indicator,
|
|
389
|
+
input[type=date]::-webkit-inner-spin-button {
|
|
389
390
|
display: none;
|
|
390
391
|
}
|
|
391
392
|
}
|