material-inspired-component-library 1.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 (174) hide show
  1. package/.editorconfig +12 -0
  2. package/.gitattributes +9 -0
  3. package/.github/ISSUE_TEMPLATE/bug_report.md +35 -0
  4. package/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  5. package/LICENSE +21 -0
  6. package/README.md +99 -0
  7. package/components/README.md +12 -0
  8. package/components/accordion/README.md +94 -0
  9. package/components/bottomsheet/README.md +77 -0
  10. package/components/bottomsheet/bottomsheet.scss +134 -0
  11. package/components/bottomsheet/index.ts +152 -0
  12. package/components/button/README.md +92 -0
  13. package/components/button/button.scss +515 -0
  14. package/components/button/index.ts +73 -0
  15. package/components/card/README.md +125 -0
  16. package/components/card/card.scss +261 -0
  17. package/components/checkbox/README.md +62 -0
  18. package/components/checkbox/checkbox.scss +275 -0
  19. package/components/checkbox/index.ts +48 -0
  20. package/components/dialog/README.md +133 -0
  21. package/components/dialog/dialog.scss +262 -0
  22. package/components/divider/README.md +52 -0
  23. package/components/divider/divider.scss +74 -0
  24. package/components/iconbutton/README.md +86 -0
  25. package/components/iconbutton/iconbutton.scss +461 -0
  26. package/components/iconbutton/index.ts +73 -0
  27. package/components/list/README.md +176 -0
  28. package/components/list/index.ts +108 -0
  29. package/components/list/list.scss +295 -0
  30. package/components/menu/README.md +96 -0
  31. package/components/menu/index.ts +77 -0
  32. package/components/menu/menu.scss +124 -0
  33. package/components/radio/README.md +53 -0
  34. package/components/radio/radio.scss +138 -0
  35. package/components/select/README.md +84 -0
  36. package/components/select/select.scss +122 -0
  37. package/components/sidesheet/README.md +99 -0
  38. package/components/sidesheet/sidesheet.scss +162 -0
  39. package/components/slider/README.md +69 -0
  40. package/components/slider/index.ts +114 -0
  41. package/components/slider/slider.scss +258 -0
  42. package/components/switch/README.md +49 -0
  43. package/components/switch/switch.scss +176 -0
  44. package/components/textfield/README.md +75 -0
  45. package/components/textfield/index.ts +81 -0
  46. package/components/textfield/textfield.scss +387 -0
  47. package/components.ts +169 -0
  48. package/dist/bottomsheet.css +1 -0
  49. package/dist/bottomsheet.js +0 -0
  50. package/dist/button.css +1 -0
  51. package/dist/button.js +0 -0
  52. package/dist/card.css +1 -0
  53. package/dist/card.js +0 -0
  54. package/dist/checkbox.css +1 -0
  55. package/dist/checkbox.js +0 -0
  56. package/dist/dialog.css +1 -0
  57. package/dist/dialog.js +0 -0
  58. package/dist/divider.css +1 -0
  59. package/dist/divider.js +0 -0
  60. package/dist/iconbutton.css +1 -0
  61. package/dist/iconbutton.js +0 -0
  62. package/dist/list.css +1 -0
  63. package/dist/list.js +0 -0
  64. package/dist/menu.css +1 -0
  65. package/dist/menu.js +0 -0
  66. package/dist/micl.css +1 -0
  67. package/dist/micl.js +1 -0
  68. package/dist/radio.css +1 -0
  69. package/dist/radio.js +0 -0
  70. package/dist/select.css +1 -0
  71. package/dist/select.js +0 -0
  72. package/dist/sidesheet.css +1 -0
  73. package/dist/sidesheet.js +0 -0
  74. package/dist/slider.css +1 -0
  75. package/dist/slider.js +0 -0
  76. package/dist/switch.css +1 -0
  77. package/dist/switch.js +0 -0
  78. package/dist/textfield.css +1 -0
  79. package/dist/textfield.js +0 -0
  80. package/docs/accordion.html +285 -0
  81. package/docs/bottomsheet.html +162 -0
  82. package/docs/button.html +206 -0
  83. package/docs/card-awards.webp +0 -0
  84. package/docs/card-cabinet.webp +0 -0
  85. package/docs/card-city.webp +0 -0
  86. package/docs/card-fingerprint.webp +0 -0
  87. package/docs/card-holiday.webp +0 -0
  88. package/docs/card-names.webp +0 -0
  89. package/docs/card.html +91 -0
  90. package/docs/checkbox.html +99 -0
  91. package/docs/dialog.html +153 -0
  92. package/docs/divider.html +103 -0
  93. package/docs/docs.css +34 -0
  94. package/docs/docs.js +69 -0
  95. package/docs/iconbutton.html +197 -0
  96. package/docs/index.html +319 -0
  97. package/docs/list.html +224 -0
  98. package/docs/menu.html +143 -0
  99. package/docs/micl.css +1 -0
  100. package/docs/micl.js +1 -0
  101. package/docs/radio.html +101 -0
  102. package/docs/select.html +205 -0
  103. package/docs/sidesheet.html +115 -0
  104. package/docs/slider.html +72 -0
  105. package/docs/switch.html +151 -0
  106. package/docs/textfield.html +151 -0
  107. package/docs/themes/airblue/dark-hc.css +51 -0
  108. package/docs/themes/airblue/dark-mc.css +51 -0
  109. package/docs/themes/airblue/dark.css +51 -0
  110. package/docs/themes/airblue/light-hc.css +51 -0
  111. package/docs/themes/airblue/light-mc.css +51 -0
  112. package/docs/themes/airblue/light.css +51 -0
  113. package/docs/themes/airblue/theme.css +306 -0
  114. package/docs/themes/barnred/dark-hc.css +51 -0
  115. package/docs/themes/barnred/dark-mc.css +51 -0
  116. package/docs/themes/barnred/dark.css +51 -0
  117. package/docs/themes/barnred/light-hc.css +51 -0
  118. package/docs/themes/barnred/light-mc.css +51 -0
  119. package/docs/themes/barnred/light.css +51 -0
  120. package/docs/themes/barnred/theme.css +306 -0
  121. package/docs/themes/citrine/dark-hc.css +51 -0
  122. package/docs/themes/citrine/dark-mc.css +51 -0
  123. package/docs/themes/citrine/dark.css +51 -0
  124. package/docs/themes/citrine/light-hc.css +51 -0
  125. package/docs/themes/citrine/light-mc.css +51 -0
  126. package/docs/themes/citrine/light.css +51 -0
  127. package/docs/themes/citrine/theme.css +306 -0
  128. package/docs/themes/olivegreen/dark-hc.css +51 -0
  129. package/docs/themes/olivegreen/dark-mc.css +51 -0
  130. package/docs/themes/olivegreen/dark.css +51 -0
  131. package/docs/themes/olivegreen/light-hc.css +51 -0
  132. package/docs/themes/olivegreen/light-mc.css +51 -0
  133. package/docs/themes/olivegreen/light.css +51 -0
  134. package/docs/themes/olivegreen/theme.css +306 -0
  135. package/package.json +62 -0
  136. package/styles/README.md +99 -0
  137. package/styles/elevation.scss +36 -0
  138. package/styles/motion.scss +124 -0
  139. package/styles/ripple.scss +50 -0
  140. package/styles/shapes.scss +46 -0
  141. package/styles/statelayer.scss +42 -0
  142. package/styles/typography.scss +568 -0
  143. package/styles.scss +43 -0
  144. package/themes/README.md +57 -0
  145. package/themes/airblue/dark-hc.css +51 -0
  146. package/themes/airblue/dark-mc.css +51 -0
  147. package/themes/airblue/dark.css +51 -0
  148. package/themes/airblue/light-hc.css +51 -0
  149. package/themes/airblue/light-mc.css +51 -0
  150. package/themes/airblue/light.css +51 -0
  151. package/themes/airblue/theme.css +306 -0
  152. package/themes/barnred/dark-hc.css +51 -0
  153. package/themes/barnred/dark-mc.css +51 -0
  154. package/themes/barnred/dark.css +51 -0
  155. package/themes/barnred/light-hc.css +51 -0
  156. package/themes/barnred/light-mc.css +51 -0
  157. package/themes/barnred/light.css +51 -0
  158. package/themes/barnred/theme.css +306 -0
  159. package/themes/citrine/dark-hc.css +51 -0
  160. package/themes/citrine/dark-mc.css +51 -0
  161. package/themes/citrine/dark.css +51 -0
  162. package/themes/citrine/light-hc.css +51 -0
  163. package/themes/citrine/light-mc.css +51 -0
  164. package/themes/citrine/light.css +51 -0
  165. package/themes/citrine/theme.css +306 -0
  166. package/themes/olivegreen/dark-hc.css +51 -0
  167. package/themes/olivegreen/dark-mc.css +51 -0
  168. package/themes/olivegreen/dark.css +51 -0
  169. package/themes/olivegreen/light-hc.css +51 -0
  170. package/themes/olivegreen/light-mc.css +51 -0
  171. package/themes/olivegreen/light.css +51 -0
  172. package/themes/olivegreen/theme.css +306 -0
  173. package/tsconfig.json +110 -0
  174. package/webpack.config.js +49 -0
@@ -0,0 +1,275 @@
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
+ @use '../../styles/motion';
23
+ @use '../../styles/ripple';
24
+
25
+ :root {
26
+ --md-sys-checkbox-container-size: 18px;
27
+ --md-sys-checkbox-border-width: 2px;
28
+ --md-sys-checkbox-selected-icon: "\2A3D";
29
+ --md-sys-checkbox-state-layer-radius: 20px;
30
+ }
31
+
32
+ @property --checkbox-outline-color {
33
+ syntax: '<color>';
34
+ initial-value: transparent;
35
+ inherits: false;
36
+ }
37
+ @property --checkbox-state-layer-color {
38
+ syntax: '<color>';
39
+ initial-value: transparent;
40
+ inherits: false;
41
+ }
42
+ @property --checkbox-container-color {
43
+ syntax: '<color>';
44
+ initial-value: transparent;
45
+ inherits: false;
46
+ }
47
+ @property --checkbox-container-border-color {
48
+ syntax: '<color>';
49
+ initial-value: transparent;
50
+ inherits: false;
51
+ }
52
+
53
+ input[type=checkbox].micl-checkbox {
54
+ --md-sys-ripple-background-color: var(--md-sys-color-primary);
55
+ --checkbox-container-color: transparent;
56
+ --checkbox-container-border-color: var(--md-sys-color-on-surface-variant);
57
+
58
+ appearance: none;
59
+ box-sizing: border-box;
60
+ position: relative;
61
+ width: var(--md-sys-target-size);
62
+ min-width: var(--md-sys-target-size);
63
+ height: var(--md-sys-target-size);
64
+ min-height: var(--md-sys-target-size);
65
+ margin: 0;
66
+ padding: calc((var(--md-sys-target-size) - var(--md-sys-checkbox-container-size)) / 2);
67
+ border-radius: calc(var(--md-sys-checkbox-border-width) + ((var(--md-sys-target-size) - var(--md-sys-checkbox-container-size)) / 2));
68
+ background-clip: border-box, border-box, content-box, content-box, content-box;
69
+ background-image:
70
+ radial-gradient(
71
+ circle var(--md-sys-checkbox-state-layer-radius),
72
+ transparent 0%,
73
+ transparent calc(var(--md-sys-checkbox-state-layer-radius) - var(--md-sys-state-focus-indicator-thickness)),
74
+ var(--checkbox-outline-color) calc(var(--md-sys-checkbox-state-layer-radius) - var(--md-sys-state-focus-indicator-thickness)),
75
+ var(--checkbox-outline-color) 100%,
76
+ transparent
77
+ ),
78
+ radial-gradient(
79
+ circle calc(var(--md-sys-checkbox-state-layer-radius) - var(--md-sys-state-focus-indicator-thickness)),
80
+ var(--checkbox-state-layer-color) 0%,
81
+ var(--checkbox-state-layer-color) 100%,
82
+ transparent
83
+ ),
84
+ linear-gradient(
85
+ to right,
86
+ var(--checkbox-container-color) 0%,
87
+ var(--checkbox-container-color) 100%,
88
+ transparent
89
+ ),
90
+ linear-gradient(
91
+ to bottom,
92
+ var(--checkbox-container-border-color) var(--md-sys-checkbox-border-width),
93
+ transparent var(--md-sys-checkbox-border-width),
94
+ transparent 16px,
95
+ var(--checkbox-container-border-color) 0px,
96
+ var(--checkbox-container-border-color) var(--md-sys-checkbox-container-size),
97
+ transparent var(--md-sys-checkbox-container-size)
98
+ ),
99
+ linear-gradient(
100
+ to right,
101
+ var(--checkbox-container-border-color) var(--md-sys-checkbox-border-width),
102
+ transparent var(--md-sys-checkbox-border-width),
103
+ transparent 16px,
104
+ var(--checkbox-container-border-color) 0px,
105
+ var(--checkbox-container-border-color) var(--md-sys-checkbox-container-size),
106
+ transparent var(--md-sys-checkbox-container-size)
107
+ );
108
+ background-origin: border-box;
109
+ background-position: center, center, center, center, center;
110
+ background-repeat: no-repeat;
111
+ background-size:
112
+ auto,
113
+ auto,
114
+ var(--md-sys-checkbox-container-size) var(--md-sys-checkbox-container-size),
115
+ var(--md-sys-checkbox-container-size) var(--md-sys-checkbox-container-size),
116
+ var(--md-sys-checkbox-container-size) var(--md-sys-checkbox-container-size),
117
+ var(--md-sys-checkbox-container-size) var(--md-sys-checkbox-container-size);
118
+ clip-path: circle(var(--md-sys-checkbox-state-layer-radius));
119
+ transition:
120
+ --checkbox-outline-color var(--md-sys-motion-duration-medium2),
121
+ --checkbox-state-layer-color var(--md-sys-motion-duration-medium2),
122
+ --checkbox-container-color var(--md-sys-motion-duration-medium2) var(--md-sys-motion-duration-short4),
123
+ --checkbox-container-border-color var(--md-sys-motion-duration-medium2);
124
+
125
+ &.micl-checkbox--error {
126
+ --md-sys-ripple-background-color: var(--md-sys-color-error);
127
+ --checkbox-container-border-color: var(--md-sys-color-error);
128
+ }
129
+ &::after {
130
+ content: var(--md-sys-checkbox-selected-icon);
131
+ box-sizing: border-box;
132
+ position: absolute;
133
+ width: calc(var(--md-sys-checkbox-container-size) + 2px);
134
+ height: 0;
135
+ inset: 0;
136
+ inset-block-start: 15px;
137
+ inset-inline-start: 8px;
138
+ margin: 4px;
139
+ font: 400 26px/2px var(--md-ref-typeface-plain);
140
+ color: var(--md-sys-color-on-primary);
141
+ text-align: center;
142
+ transform: rotate(-45deg);
143
+ transform-origin: top;
144
+ clip-path: rect(0px 4.5px 18px 0px);
145
+ overflow: hidden;
146
+ transition:
147
+ clip-path var(--md-sys-motion-duration-short3) motion.$md-sys-motion-easing-standard-accelerate,
148
+ height var(--md-sys-motion-duration-short3) var(--md-sys-motion-duration-short3) motion.$md-sys-motion-easing-standard-decelerate;
149
+ }
150
+ @supports (-moz-appearance:none) {
151
+ &::after {
152
+ inset-block-start: 16px;
153
+ inset-inline-start: 7px;
154
+ font: 400 27px/3px var(--md-ref-typeface-plain);
155
+ }
156
+ }
157
+ &:checked {
158
+ --checkbox-container-color: var(--md-sys-color-primary);
159
+ --checkbox-container-border-color: transparent;
160
+ transition:
161
+ --checkbox-container-color var(--md-sys-motion-duration-medium2),
162
+ --checkbox-container-border-color var(--md-sys-motion-duration-medium2);
163
+
164
+ &.micl-checkbox--error {
165
+ --checkbox-container-color: var(--md-sys-color-error);
166
+ }
167
+ &::after {
168
+ height: 8px;
169
+ clip-path: rect(0px 16px 18px 0px);
170
+ transition:
171
+ height var(--md-sys-motion-duration-short3) motion.$md-sys-motion-easing-standard-accelerate,
172
+ clip-path var(--md-sys-motion-duration-long4) var(--md-sys-motion-duration-short3) linear(motion.$md-sys-motion-spring-default-spatial);
173
+ }
174
+ }
175
+ &:not(:disabled) {
176
+ --miclripple: 1;
177
+
178
+ @include ripple.effect;
179
+
180
+ cursor: pointer;
181
+
182
+ &:hover {
183
+ &:checked {
184
+ --checkbox-outline-color: rgb(from var(--md-sys-color-primary) r g b / var(--md-sys-state-hover-state-layer-opacity));
185
+ --checkbox-state-layer-color: rgb(from var(--md-sys-color-primary) r g b / var(--md-sys-state-hover-state-layer-opacity));
186
+
187
+ &.micl-checkbox--error {
188
+ --checkbox-outline-color: rgb(from var(--md-sys-color-error) r g b / var(--md-sys-state-hover-state-layer-opacity));
189
+ --checkbox-state-layer-color: rgb(from var(--md-sys-color-error) r g b / var(--md-sys-state-hover-state-layer-opacity));
190
+ }
191
+ }
192
+ &:not(:checked) {
193
+ --checkbox-container-border-color: var(--md-sys-color-on-surface);
194
+ --checkbox-outline-color: rgb(from var(--md-sys-color-on-surface) r g b / var(--md-sys-state-hover-state-layer-opacity));
195
+ --checkbox-state-layer-color: rgb(from var(--md-sys-color-on-surface) r g b / var(--md-sys-state-hover-state-layer-opacity));
196
+
197
+ &.micl-checkbox--error {
198
+ --checkbox-container-border-color: var(--md-sys-color-error);
199
+ --checkbox-outline-color: rgb(from var(--md-sys-color-error) r g b / var(--md-sys-state-hover-state-layer-opacity));
200
+ --checkbox-state-layer-color: rgb(from var(--md-sys-color-error) r g b / var(--md-sys-state-hover-state-layer-opacity));
201
+ }
202
+ }
203
+ }
204
+ &:focus-visible {
205
+ --checkbox-outline-color: var(--md-sys-color-secondary);
206
+
207
+ &:checked {
208
+ --checkbox-state-layer-color: rgb(from var(--md-sys-color-primary) r g b / var(--md-sys-state-focus-state-layer-opacity));
209
+
210
+ &.micl-checkbox--error {
211
+ --checkbox-state-layer-color: rgb(from var(--md-sys-color-error) r g b / var(--md-sys-state-focus-state-layer-opacity));
212
+ }
213
+ }
214
+ &:not(:checked) {
215
+ --checkbox-container-border-color: var(--md-sys-color-on-surface);
216
+ --checkbox-state-layer-color: rgb(from var(--md-sys-color-on-surface) r g b / var(--md-sys-state-focus-state-layer-opacity));
217
+
218
+ &.micl-checkbox--error {
219
+ --checkbox-container-border-color: var(--md-sys-color-error);
220
+ --checkbox-state-layer-color: rgb(from var(--md-sys-color-error) r g b / var(--md-sys-state-focus-state-layer-opacity));
221
+ }
222
+ }
223
+ }
224
+ &:active {
225
+ &:checked {
226
+ --checkbox-outline-color: rgb(from var(--md-sys-color-on-surface) r g b / var(--md-sys-state-pressed-state-layer-opacity));
227
+ --checkbox-state-layer-color: rgb(from var(--md-sys-color-on-surface) r g b / var(--md-sys-state-pressed-state-layer-opacity));
228
+
229
+ &.micl-checkbox--error {
230
+ --checkbox-outline-color: rgb(from var(--md-sys-color-error) r g b / var(--md-sys-state-pressed-state-layer-opacity));
231
+ --checkbox-state-layer-color: rgb(from var(--md-sys-color-error) r g b / var(--md-sys-state-pressed-state-layer-opacity));
232
+ }
233
+ }
234
+ &:not(:checked) {
235
+ --checkbox-container-border-color: var(--md-sys-color-on-surface);
236
+ --checkbox-outline-color: rgb(from var(--md-sys-color-primary) r g b / var(--md-sys-state-pressed-state-layer-opacity));
237
+ --checkbox-state-layer-color: rgb(from var(--md-sys-color-primary) r g b / var(--md-sys-state-pressed-state-layer-opacity));
238
+
239
+ &.micl-checkbox--error {
240
+ --checkbox-container-border-color: var(--md-sys-color-error);
241
+ --checkbox-outline-color: rgb(from var(--md-sys-color-error) r g b / var(--md-sys-state-pressed-state-layer-opacity));
242
+ --checkbox-state-layer-color: rgb(from var(--md-sys-color-error) r g b / var(--md-sys-state-pressed-state-layer-opacity));
243
+ }
244
+ }
245
+ }
246
+ }
247
+ &:disabled {
248
+ --checkbox-container-border-color: var(--md-sys-color-on-surface);
249
+ opacity: 38%;
250
+
251
+ &:checked {
252
+ --checkbox-container-color: var(--md-sys-color-on-surface);
253
+
254
+ &::after {
255
+ color: var(--md-sys-color-surface);
256
+ }
257
+ }
258
+ }
259
+ }
260
+
261
+ input[type=checkbox].micl-checkbox:not(:disabled) + label,
262
+ label:has(+ input[type=checkbox].micl-checkbox:not(:disabled)) {
263
+ cursor: pointer;
264
+ }
265
+
266
+ [dir=rtl] input[type=checkbox].micl-checkbox {
267
+ &::after {
268
+ inset-inline-start: 9px;
269
+ transform: rotate(45deg);
270
+ clip-path: rect(0px 18px 7.5px 16px);
271
+ }
272
+ &:checked::after {
273
+ clip-path: rect(0px 18px 8px 6px);
274
+ }
275
+ }
@@ -0,0 +1,48 @@
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 checkboxSelector = '.micl-checkbox';
23
+
24
+ export default (() =>
25
+ {
26
+ return {
27
+ keydown: (event: Event) =>
28
+ {
29
+ if (
30
+ !(event.target as Element).matches(checkboxSelector)
31
+ || !(event instanceof KeyboardEvent)
32
+ || !(event.target instanceof HTMLInputElement)
33
+ || (event.target as HTMLInputElement).disabled
34
+ ) {
35
+ return;
36
+ }
37
+
38
+ switch (event.key) {
39
+ case 'Enter':
40
+ case ' ':
41
+ event.target.checked = !event.target.checked;
42
+ event.preventDefault() // prevent page scrolling
43
+ break;
44
+ default:
45
+ }
46
+ }
47
+ };
48
+ })();
@@ -0,0 +1,133 @@
1
+ # Dialog
2
+ This component implements the the [Material Design 3 Expressive Dialog](https://m3.material.io/components/dialogs/overview) design.
3
+
4
+ ## Basic Usage
5
+
6
+ ### HTML
7
+ To create a basic dialog, use the `<dialog>` element with the `micl-dialog` class. You can open and close the dialog using JavaScript, or you can use a control element, such as a button, to open and close the dialog.
8
+
9
+ ```HTML
10
+ <dialog id="mydialog" class="micl-dialog" closedby="any" popover>
11
+ <div class="micl-dialog__headline">
12
+ <h2>Basic dialog</h2>
13
+ <span class="micl-dialog__supporting-text">An example of a basic dialog</span>
14
+ </div>
15
+ </dialog>
16
+
17
+ <button type="button" popovertarget="mydialog">Open Basic Dialog</button>
18
+ ```
19
+
20
+ - The `popover` attribute makes the dialog a non-modal (light dismiss) popover.
21
+
22
+ - The `closedby="any"` attribute allows the dialog to be closed by clicking or tapping outside of it, or by pressing the <kbd>Esc</kbd> key.
23
+
24
+ ### CSS
25
+ Import the dialog styles into your project:
26
+
27
+ ```CSS
28
+ @use "micl/components/dialog";
29
+ ```
30
+
31
+ ### TypeScript
32
+ No custom TypeScript is required for the core functionality of this component, as the native popover attribute handles the open/close behavior.
33
+
34
+ ### Demo
35
+ A live example of the [Dialog component](https://henkpb.github.io/micl/dialog.html) is available for you to interact with.
36
+
37
+ ## Variants
38
+ When dialogs with the `popover` attribute are opened, they animate from the control element to the center of the screen. They can be easily dismissed by clicking outside or pressing <kbd>Esc</kbd>.
39
+
40
+ Removing the `popover` attribute creates a more intrusive **modal** dialog. This type of dialog requires the user to interact with its buttons or press the <kbd>Esc</kbd> key to close it.
41
+
42
+ ```HTML
43
+ <dialog id="mydialog" class="micl-dialog" closedby="closerequest">
44
+ <div class="micl-dialog__headline">
45
+ <span class="micl-dialog__icon material-symbols-outlined" aria-hidden="true">info</span>
46
+ <h2>Modal dialog</h2>
47
+ <span class="micl-dialog__supporting-text">An example of a modal dialog</span>
48
+ </div>
49
+ <div class="micl-dialog__actions">
50
+ <form method="dialog">
51
+ <button class="micl-button">Cancel</button>
52
+ <button class="micl-button">Save</button>
53
+ </form>
54
+ </div>
55
+ </dialog>
56
+
57
+ <button type="button" popovertarget="mydialog">Open Modal Dialog</button>
58
+ ```
59
+
60
+ - The `closedby="closerequest"` attribute restricts closing methods, typically requiring an explicit action within the dialog.
61
+
62
+ By default, modal dialogs open in the center of the screen. You can anchor a modal dialog to a control element, causing it to open relative to that element:
63
+
64
+ ```HTML
65
+ <dialog id="mydialog" class="micl-dialog" closedby="closerequest" style="position-anchor:--myanchor">
66
+ </dialog>
67
+
68
+ <button type="button" popovertarget="mydialog" style="anchor-name:--myanchor">Open Modal Dialog</button>
69
+ ```
70
+
71
+ ### Dialog Structure Sections
72
+
73
+ A dialog typically consists of three main sections to organize its content:
74
+
75
+ - `micl-dialog__headline`: The header of the dialog. It usually contains:
76
+
77
+ - A heading element (`<h1>`-`<h6>`).
78
+
79
+ - An optional icon (use `micl-dialog__icon`).
80
+
81
+ - An optional sub-header (e.g., `<span class="micl-dialog__subhead">`).
82
+
83
+ - An optional `micl-dialog__supporting-text` element, describing the dialog's purpose.
84
+
85
+ - `micl-dialog__content`: The optional main content area of the dialog, where additional information can be placed.
86
+
87
+ - `micl-dialog__actions`: A container for action buttons that allow the user to perform actions related to the dialog or close it. Actions are typically placed in a `<form method="dialog">` for native HTML dialog closing.
88
+
89
+ ### Full-screen dialog
90
+ A full-screen dialog covers the entire viewport, primarily on smaller screens. On screens wider than 560 pixels, a full-screen dialog behaves like a basic dialog. Use the `micl-dialog-fullscreen` class for this variant:
91
+
92
+ ```HTML
93
+ <dialog id="mydialog" class="micl-dialog-fullscreen" closedby="none" popover>
94
+ <form method="dialog" class="micl-dialog__headline">
95
+ <button type="button" class="micl-iconbutton-s material-symbols-outlined" popovertarget="mydialog" aria-label="Close">close</button>
96
+ <span class="micl-dialog__icon material-symbols-outlined" aria-hidden="true">person</span>
97
+ <h2>Full-screen dialog</h2>
98
+ <button class="micl-button" value="dosave">Save</button>
99
+ </form>
100
+ <div class="micl-dialog__content">
101
+ <span class="micl-dialog__supporting-text">This dialog covers the whole screen.</span>
102
+ </div>
103
+ <form method="dialog" class="micl-dialog__actions">
104
+ <button type="button" class="micl-button" popovertarget="mydialog">Cancel</button>
105
+ <button class="micl-button" value="dosave">Save</button>
106
+ </form>
107
+ </dialog>
108
+
109
+ <button type="button" popovertarget="mydialog">Open Full-Screen Dialog</button>
110
+ ```
111
+
112
+ - In full-screen mode, buttons placed directly within the `micl-dialog__headline` become visible, while the `micl-dialog__icon` and `micl-dialog__actions` at the bottom are hidden.
113
+
114
+ - When not in full-screen mode (e.g., on wider screens), the `micl-dialog__headline` buttons are hidden, and the standard dialog actions (`micl-dialog__actions`) are visible.
115
+
116
+ ## Customizations
117
+ You can customize the appearance of the Dialog component by overriding its global CSS variables. These variables are declared on the `:root` pseudo-class and can be changed on any appropriate parent element to affect its child dialogs.
118
+
119
+ | Variable name | Default Value | Description |
120
+ | ------------- | ----- | ----------- |
121
+ | --md-sys-dialog-padding | 24px | The inner padding between the dialog's edge and its content |
122
+
123
+ **Example: Changing the dialog padding**
124
+
125
+ ```HTML
126
+ <div style="--md-sys-dialog-padding:16px">
127
+ <dialog class="micl-dialog">
128
+ </dialog>
129
+ </div>
130
+ ```
131
+
132
+ ## Compatibility
133
+ This component uses **popover anchor positioning** to place the dialog in relation to its invoker. This is a modern CSS feature that may not be fully supported in all browsers. Please check [Browser compatibility](https://developer.mozilla.org/en-US/docs/Web/CSS/anchor#browser_compatibility) for details.