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
package/CLAUDE.md DELETED
@@ -1,53 +0,0 @@
1
- # CLAUDE.md
2
-
3
- This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
-
5
- ## Project Overview
6
-
7
- MICL is a Material Design 3 (M3 Expressive) UI component library written in Sass and TypeScript.
8
-
9
- ## Commands
10
-
11
- ```bash
12
- npm run build # Compiles TypeScript + Sass via webpack, outputs to /dist/ and /docs/
13
- ```
14
-
15
- There is no test suite, linter script, or dev server configured.
16
-
17
- ## Architecture
18
-
19
- ### Entry Points
20
-
21
- - **`micl.ts`** — Main orchestrator. Initializes components lazily via a `MutationObserver` that watches for DOM insertions/removals. Handles event delegation for `input`, `change`, and `keydown` events, applies the ripple effect, and sets scrollbar CSS custom properties.
22
- - **`styles.scss`** — Master stylesheet that imports all component and foundation Sass partials.
23
-
24
- ### Component Structure
25
-
26
- Each component lives in `components/<name>/` and exports:
27
- - A CSS selector string (e.g., `buttonSelector = 'button.micl-button--toggle'`)
28
- - A handler object with `initialize(element)` / `cleanup(element)` methods and optional event handlers (`input`, `change`, `keydown`, `command`)
29
-
30
- `micl.ts` imports every component handler, maps selectors to handlers, and drives the lifecycle using the MutationObserver + event delegation pattern.
31
-
32
- ### Styling System
33
-
34
- - Sass uses `@use` (not `@import`); partials are namespaced.
35
- - Theming is done entirely via CSS custom properties with `--md-comp-*` prefixes.
36
- - `themes/` contains 11 colour themes, each with light, dark, and high-contrast variants.
37
- - `styles/` contains Material Design tokens: typography, shapes, elevation, motion, state layers.
38
- - `foundations/` contains the responsive layout system (breakpoints: compact ≤599 px, medium 600–839 px, expanded 840–1199 px, large 1200–1599 px, extra-large ≥1600 px).
39
-
40
- ### Coding
41
-
42
- - The amount of TypeScript code should be minimized. Necessary functionality should be solved using SCSS only.
43
- – The SCSS code can be verbose, but the compiled CSS code must be as small as possible.
44
-
45
- ### Documentation
46
-
47
- - Component documentation is stored with the SCSS and JavaScript files. Always check if the documentation is up to date with regards to the implementation.
48
-
49
- ### Build
50
-
51
- `webpack.config.js` produces two identical outputs: one to `/dist/` (npm distribution) and one to `/docs/` (live demo). TypeScript target is ES2022 with strict mode and declaration-file generation enabled.
52
-
53
- The library compiles to a UMD bundle (`dist/micl.js`) and a CSS file (`dist/micl.css`) with zero runtime dependencies. In addition, a CSS and JavaScript pair of compiled files is created, so that a consumer may load only a subset of components.
@@ -1,128 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- We as members, contributors, and leaders pledge to make participation in our
6
- community a harassment-free experience for everyone, regardless of age, body
7
- size, visible or invisible disability, ethnicity, sex characteristics, gender
8
- identity and expression, level of experience, education, socio-economic status,
9
- nationality, personal appearance, race, religion, or sexual identity
10
- and orientation.
11
-
12
- We pledge to act and interact in ways that contribute to an open, welcoming,
13
- diverse, inclusive, and healthy community.
14
-
15
- ## Our Standards
16
-
17
- Examples of behavior that contributes to a positive environment for our
18
- community include:
19
-
20
- * Demonstrating empathy and kindness toward other people
21
- * Being respectful of differing opinions, viewpoints, and experiences
22
- * Giving and gracefully accepting constructive feedback
23
- * Accepting responsibility and apologizing to those affected by our mistakes,
24
- and learning from the experience
25
- * Focusing on what is best not just for us as individuals, but for the
26
- overall community
27
-
28
- Examples of unacceptable behavior include:
29
-
30
- * The use of sexualized language or imagery, and sexual attention or
31
- advances of any kind
32
- * Trolling, insulting or derogatory comments, and personal or political attacks
33
- * Public or private harassment
34
- * Publishing others' private information, such as a physical or email
35
- address, without their explicit permission
36
- * Other conduct which could reasonably be considered inappropriate in a
37
- professional setting
38
-
39
- ## Enforcement Responsibilities
40
-
41
- Community leaders are responsible for clarifying and enforcing our standards of
42
- acceptable behavior and will take appropriate and fair corrective action in
43
- response to any behavior that they deem inappropriate, threatening, offensive,
44
- or harmful.
45
-
46
- Community leaders have the right and responsibility to remove, edit, or reject
47
- comments, commits, code, wiki edits, issues, and other contributions that are
48
- not aligned to this Code of Conduct, and will communicate reasons for moderation
49
- decisions when appropriate.
50
-
51
- ## Scope
52
-
53
- This Code of Conduct applies within all community spaces, and also applies when
54
- an individual is officially representing the community in public spaces.
55
- Examples of representing our community include using an official e-mail address,
56
- posting via an official social media account, or acting as an appointed
57
- representative at an online or offline event.
58
-
59
- ## Enforcement
60
-
61
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
- reported to the community leaders responsible for enforcement at
63
- micl.hermana@proton.me.
64
- All complaints will be reviewed and investigated promptly and fairly.
65
-
66
- All community leaders are obligated to respect the privacy and security of the
67
- reporter of any incident.
68
-
69
- ## Enforcement Guidelines
70
-
71
- Community leaders will follow these Community Impact Guidelines in determining
72
- the consequences for any action they deem in violation of this Code of Conduct:
73
-
74
- ### 1. Correction
75
-
76
- **Community Impact**: Use of inappropriate language or other behavior deemed
77
- unprofessional or unwelcome in the community.
78
-
79
- **Consequence**: A private, written warning from community leaders, providing
80
- clarity around the nature of the violation and an explanation of why the
81
- behavior was inappropriate. A public apology may be requested.
82
-
83
- ### 2. Warning
84
-
85
- **Community Impact**: A violation through a single incident or series
86
- of actions.
87
-
88
- **Consequence**: A warning with consequences for continued behavior. No
89
- interaction with the people involved, including unsolicited interaction with
90
- those enforcing the Code of Conduct, for a specified period of time. This
91
- includes avoiding interactions in community spaces as well as external channels
92
- like social media. Violating these terms may lead to a temporary or
93
- permanent ban.
94
-
95
- ### 3. Temporary Ban
96
-
97
- **Community Impact**: A serious violation of community standards, including
98
- sustained inappropriate behavior.
99
-
100
- **Consequence**: A temporary ban from any sort of interaction or public
101
- communication with the community for a specified period of time. No public or
102
- private interaction with the people involved, including unsolicited interaction
103
- with those enforcing the Code of Conduct, is allowed during this period.
104
- Violating these terms may lead to a permanent ban.
105
-
106
- ### 4. Permanent Ban
107
-
108
- **Community Impact**: Demonstrating a pattern of violation of community
109
- standards, including sustained inappropriate behavior, harassment of an
110
- individual, or aggression toward or disparagement of classes of individuals.
111
-
112
- **Consequence**: A permanent ban from any sort of public interaction within
113
- the community.
114
-
115
- ## Attribution
116
-
117
- This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
- version 2.0, available at
119
- https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120
-
121
- Community Impact Guidelines were inspired by [Mozilla's code of conduct
122
- enforcement ladder](https://github.com/mozilla/diversity).
123
-
124
- [homepage]: https://www.contributor-covenant.org
125
-
126
- For answers to common questions about this code of conduct, see the FAQ at
127
- https://www.contributor-covenant.org/faq. Translations are available at
128
- https://www.contributor-covenant.org/translations.
@@ -1,153 +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 bottomsheetSelector = 'dialog.micl-bottomsheet';
23
-
24
- export default (() =>
25
- {
26
- const getSnapHeights = (dialog: HTMLDialogElement): number[] =>
27
- {
28
- let fitHeight = parseInt(dialog.dataset.miclfitheight || '0', 10),
29
- maxHeight = parseInt(window.getComputedStyle(dialog).getPropertyValue('max-block-size'), 10),
30
- snapHeights = (dialog.dataset.miclsnapheights || '').split(',').map(Number).filter(
31
- n => !isNaN(n) && (n >= 0) && (n <= maxHeight)
32
- );
33
-
34
- if (fitHeight < 1) {
35
- fitHeight = Math.min(dialog.getBoundingClientRect().height, maxHeight);
36
- dialog.dataset.miclfitheight = `${fitHeight}`;
37
- }
38
- return [...new Set(snapHeights.concat([fitHeight]).sort())];
39
- };
40
-
41
- const getNextSnapHeight = (dialog: HTMLDialogElement, isResizing: boolean): number =>
42
- {
43
- let currentHeight = dialog.getBoundingClientRect().height,
44
- snapHeights = getSnapHeights(dialog),
45
- largerSnaps = snapHeights.filter(height => height > currentHeight + 4);
46
-
47
- return largerSnaps[0] || snapHeights[isResizing ? snapHeights.length - 1 : 0];
48
- };
49
-
50
- const getPreviousSnapHeight = (dialog: HTMLDialogElement): number =>
51
- {
52
- let currentHeight = dialog.getBoundingClientRect().height,
53
- snapHeights = getSnapHeights(dialog),
54
- smallerSnaps = snapHeights.filter(height => height < currentHeight - 4);
55
-
56
- return smallerSnaps[smallerSnaps.length - 1] || snapHeights[0];
57
- };
58
-
59
- const setHeight = (dialog: HTMLDialogElement, value: number): void =>
60
- {
61
- if (value < 1) {
62
- delete dialog.dataset.miclfitheight;
63
- dialog.style.removeProperty('--md-sys-bottomsheet-height');
64
- dialog[!dialog.popover ? 'close' : 'hidePopover']();
65
- }
66
- else {
67
- dialog.style.setProperty('--md-sys-bottomsheet-height', `${value}px`);
68
- }
69
- }
70
-
71
- return {
72
- initialize: (element: HTMLDialogElement) =>
73
- {
74
- if (
75
- !element.matches(bottomsheetSelector)
76
- || element.dataset.miclinitialized
77
- ) {
78
- return;
79
- }
80
- element.dataset.miclinitialized = '1';
81
-
82
- const headline = element.querySelector('.micl-bottomsheet__headline') as HTMLElement;
83
- if (!headline) {
84
- return;
85
- }
86
- const draghandle = headline.querySelector('.micl-bottomsheet__draghandle') as HTMLElement;
87
-
88
- draghandle?.addEventListener('click', () =>
89
- {
90
- setHeight(element, getNextSnapHeight(element, false));
91
- });
92
-
93
- let isPreparing = false,
94
- isResizing = false,
95
- initialMouseY: number,
96
- initialHeight: number;
97
-
98
- headline.addEventListener('mousedown', (event: Event) =>
99
- {
100
- if (event.eventPhase === Event.AT_TARGET) {
101
- isPreparing = true;
102
- event.preventDefault();
103
- initialMouseY = (event as MouseEvent).clientY;
104
- initialHeight = element.getBoundingClientRect().height;
105
- document.addEventListener('mousemove', onMouseMove);
106
- document.addEventListener('mouseup', onMouseUp);
107
- }
108
- });
109
-
110
- function onMouseMove(event: Event)
111
- {
112
- const currentMouseY = (event as MouseEvent).clientY;
113
- if (isPreparing && (Math.abs(initialMouseY - currentMouseY) > 4)) {
114
- isPreparing = false;
115
- isResizing = true;
116
- element.classList.add('micl-bottomsheet--resizing');
117
- }
118
- if (isResizing) {
119
- setHeight(element, initialHeight + initialMouseY - currentMouseY);
120
- }
121
- }
122
- function onMouseUp(event: Event)
123
- {
124
- isPreparing = false;
125
- element.classList.remove('micl-bottomsheet--resizing');
126
- if (isResizing) {
127
- isResizing = false;
128
-
129
- const currentMouseY = (event as MouseEvent).clientY;
130
- if (currentMouseY < initialMouseY) {
131
- setHeight(element, getNextSnapHeight(element, true));
132
- }
133
- else if (element.getBoundingClientRect().height < 48) {
134
- setHeight(element, 0);
135
- }
136
- else {
137
- setHeight(element, getPreviousSnapHeight(element));
138
- }
139
- document.removeEventListener('mousemove', onMouseMove);
140
- document.removeEventListener('mouseup', onMouseUp);
141
- }
142
- }
143
- },
144
- cleanup: (element: HTMLDialogElement) =>
145
- {
146
- if (element.matches(bottomsheetSelector)) {
147
- element.classList.remove('micl-bottomsheet--resizing');
148
- delete element.dataset.miclinitialized;
149
- delete element.dataset.miclfitheight;
150
- }
151
- }
152
- };
153
- })();
@@ -1,79 +0,0 @@
1
- //
2
- // Copyright © 2025 Hermana AS
3
- //
4
- // Permission is hereby granted, free of charge, to any person obtaining a copy
5
- // of this software and associated documentation files (the "Software"), to deal
6
- // in the Software without restriction, including without limitation the rights
7
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- // copies of the Software, and to permit persons to whom the Software is
9
- // furnished to do so, subject to the following conditions:
10
- //
11
- // The above copyright notice and this permission notice shall be included in all
12
- // copies or substantial portions of the Software.
13
- //
14
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- // SOFTWARE.
21
-
22
- export const buttonSelector = 'button.micl-button--toggle';
23
-
24
- const toggleIcon = (button: HTMLButtonElement): void =>
25
- {
26
- const element = button.querySelector<HTMLElement>('.micl-button__icon') ?? button;
27
-
28
- const selected = button.classList.contains('micl-button--selected');
29
- if (element.dataset.micliconselected) {
30
- element.classList.toggle(element.dataset.micliconselected, selected);
31
- }
32
- if (element.dataset.miclicon) {
33
- element.classList.toggle(element.dataset.miclicon, !selected);
34
- }
35
- };
36
-
37
- export default (() =>
38
- {
39
- return {
40
- command: (event: Event): void =>
41
- {
42
- const target = event.target as HTMLButtonElement;
43
-
44
- if (
45
- target.matches(buttonSelector)
46
- && !target.disabled
47
- && (event as any).command === '--micl-toggle'
48
- ) {
49
- target.classList.add('micl-button--toggled');
50
- target.classList.toggle('micl-button--selected');
51
-
52
- toggleIcon(target);
53
- }
54
- },
55
-
56
- initialize: function(element: HTMLButtonElement): void
57
- {
58
- if (
59
- !element.matches(buttonSelector)
60
- || element.dataset.miclinitialized
61
- ) {
62
- return;
63
- }
64
- element.dataset.miclinitialized = '1';
65
-
66
- toggleIcon(element);
67
-
68
- element.addEventListener('command', this.command);
69
- },
70
-
71
- cleanup: function(element: HTMLButtonElement): void
72
- {
73
- if (element.matches(buttonSelector)) {
74
- document.removeEventListener('command', this.command);
75
- delete element.dataset.miclinitialized;
76
- }
77
- }
78
- };
79
- })();
@@ -1,148 +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 checkboxGroupSelector = '.micl-checkbox-group';
23
-
24
- export default (() =>
25
- {
26
- const getParentCheckbox = (checkboxGroup: HTMLElement): HTMLInputElement | null =>
27
- {
28
- const parentCheckbox = checkboxGroup.querySelector<HTMLInputElement>('.micl-checkbox__parent');
29
- return (parentCheckbox?.closest(checkboxGroupSelector) === checkboxGroup) ? parentCheckbox : null;
30
- };
31
-
32
- const refreshParentCheckbox = (checkboxGroup: HTMLElement): boolean =>
33
- {
34
- const parentCheckbox = getParentCheckbox(checkboxGroup);
35
- if (!parentCheckbox) {
36
- return false;
37
- }
38
- let nrCheckboxes = 0,
39
- nrCheckedCheckboxes = 0;
40
-
41
- checkboxGroup.querySelectorAll<HTMLInputElement>(
42
- 'input[type="checkbox"].micl-checkbox'
43
- ).forEach(cb =>
44
- {
45
- if (cb !== parentCheckbox) {
46
- const group = cb.closest(checkboxGroupSelector) as HTMLElement;
47
- if (group === checkboxGroup) {
48
- nrCheckboxes++;
49
- if (cb.checked && !cb.indeterminate) {
50
- nrCheckedCheckboxes++;
51
- }
52
- }
53
- else if (
54
- cb.classList.contains('micl-checkbox__parent')
55
- && (group?.parentElement?.closest(checkboxGroupSelector) === checkboxGroup)
56
- ) {
57
- nrCheckboxes++;
58
- if (refreshParentCheckbox(group)) {
59
- nrCheckedCheckboxes++;
60
- }
61
- }
62
- }
63
- });
64
-
65
- if (nrCheckedCheckboxes === 0) {
66
- parentCheckbox.checked = false;
67
- parentCheckbox.indeterminate = false;
68
- }
69
- else if (nrCheckedCheckboxes === nrCheckboxes) {
70
- parentCheckbox.checked = true;
71
- parentCheckbox.indeterminate = false;
72
- }
73
- else {
74
- parentCheckbox.checked = true;
75
- parentCheckbox.indeterminate = true;
76
- }
77
-
78
- return nrCheckedCheckboxes === nrCheckboxes;
79
- };
80
-
81
- const updateCheckboxGroup = (checkboxGroup: HTMLElement, checked: boolean): void =>
82
- {
83
- checkboxGroup.querySelectorAll<HTMLInputElement>(
84
- 'input[type="checkbox"].micl-checkbox'
85
- ).forEach(cb =>
86
- {
87
- const group = cb.closest(checkboxGroupSelector) as HTMLElement;
88
- if (group === checkboxGroup) {
89
- cb.checked = checked;
90
- }
91
- else if (
92
- cb.classList.contains('micl-checkbox__parent')
93
- && (group?.parentElement?.closest(checkboxGroupSelector) === checkboxGroup)
94
- ) {
95
- cb.checked = checked;
96
- updateCheckboxGroup(group, checked);
97
- }
98
- });
99
- };
100
-
101
- const refreshCheckboxGroup = (checkboxGroup: HTMLElement, input: HTMLInputElement | null): void =>
102
- {
103
- const parentCheckbox = getParentCheckbox(checkboxGroup);
104
- if (!parentCheckbox) {
105
- return;
106
- }
107
-
108
- if (input === parentCheckbox) {
109
- updateCheckboxGroup(checkboxGroup, input.checked);
110
- }
111
-
112
- let parentCheckboxGroup,
113
- cbg = checkboxGroup;
114
- do {
115
- parentCheckboxGroup = cbg;
116
- cbg = cbg.parentElement?.closest(checkboxGroupSelector) as HTMLElement;
117
- }
118
- while (cbg);
119
-
120
- refreshParentCheckbox(parentCheckboxGroup);
121
- };
122
-
123
- return {
124
- initialize: (element: HTMLElement): void =>
125
- {
126
- if (
127
- !element.matches(checkboxGroupSelector)
128
- || element.dataset.miclinitialized
129
- ) {
130
- return;
131
- }
132
- element.dataset.miclinitialized = '1';
133
-
134
- element.addEventListener('change', event =>
135
- {
136
- const input = event.target as HTMLInputElement;
137
- if (!input.classList.contains('micl-checkbox')) {
138
- return;
139
- }
140
- event.stopPropagation();
141
-
142
- refreshCheckboxGroup(element, input);
143
- });
144
-
145
- refreshCheckboxGroup(element, null);
146
- }
147
- };
148
- })();