kmaterialize 2.0.0 → 2.3.3-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 (150) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +55 -91
  3. package/components/appbar/_navbar.old.scss +223 -0
  4. package/components/appbar/appbar.css +235 -0
  5. package/components/appbar/appbar.mjs +54 -0
  6. package/components/appbar/appbar.test.mjs +9 -0
  7. package/components/atomic/atomic.mjs +19 -0
  8. package/components/atomic/component.mjs +67 -0
  9. package/components/badge/_badges.scss +75 -0
  10. package/components/badge/badge.mjs +11 -0
  11. package/components/breadcrumb/_breadcrumb.scss +27 -0
  12. package/components/button/_buttons.scss +352 -0
  13. package/components/button/button.mjs +11 -0
  14. package/components/button/buttons.stories.ts +150 -0
  15. package/components/button/buttons.ts +282 -0
  16. package/components/button/examples.iso.js +18 -0
  17. package/components/button/fabSpec.js +65 -0
  18. package/components/button/test-button.mjs +16 -0
  19. package/components/card/_cards.scss +229 -0
  20. package/components/card/card.mjs +10 -0
  21. package/components/card/cards.ts +185 -0
  22. package/components/card/cardsSpec.js +269 -0
  23. package/components/carousel/_carousel.scss +93 -0
  24. package/components/carousel/_slider.scss +119 -0
  25. package/components/carousel/carousel.ts +693 -0
  26. package/components/carousel/carouselSpec.js +61 -0
  27. package/components/carousel/slider.ts +431 -0
  28. package/components/carousel/sliderSpec.js +99 -0
  29. package/components/checkbox/_checkboxes.scss +281 -0
  30. package/components/checkbox/checkbox.mdx +24 -0
  31. package/components/checkbox/checkbox.stories.ts +120 -0
  32. package/components/chip/chip.mjs +37 -0
  33. package/components/chip/chip.test.mjs +10 -0
  34. package/components/chip/chips.css +126 -0
  35. package/components/chip/chips.mdx +33 -0
  36. package/components/chip/chips.ts +440 -0
  37. package/components/chip/chipsSpec.js +165 -0
  38. package/components/chip/readme.md +323 -0
  39. package/components/collapsible/_collapsible.scss +82 -0
  40. package/components/collapsible/collapsible.ts +230 -0
  41. package/components/collapsible/collapsibleSpec.js +240 -0
  42. package/components/datepicker/_datepicker.scss +268 -0
  43. package/components/datepicker/datepicker.ts +1450 -0
  44. package/components/datepicker/datepickerSpec.js +162 -0
  45. package/components/dialog/_materialbox.scss +42 -0
  46. package/components/dialog/_modal.scss +79 -0
  47. package/components/dialog/materialbox.ts +446 -0
  48. package/components/dialog/materialboxSpec.js +37 -0
  49. package/components/dialog/modal.ts +111 -0
  50. package/components/dialog/modalSpec.js +83 -0
  51. package/components/dialog/readme.md +5 -0
  52. package/components/divider/readme.md +15 -0
  53. package/components/dropdown/_dropdown.scss +83 -0
  54. package/components/dropdown/dropdown.ts +653 -0
  55. package/components/dropdown/dropdownSpec.js +108 -0
  56. package/components/list/_collection.scss +114 -0
  57. package/components/list/_list.scss +6 -0
  58. package/components/list/list.mjs +58 -0
  59. package/components/list/list.test.mjs +16 -0
  60. package/components/loading/loading.mjs +26 -0
  61. package/components/loading/loading.test.mjs +10 -0
  62. package/components/navigation-bar/_old +582 -0
  63. package/components/navigation-bar/navigation-bar.mdx +20 -0
  64. package/components/navigation-bar/navigation-bar.stories.ts +39 -0
  65. package/components/navigation-drawer/_sidenav.scss +247 -0
  66. package/components/navigation-drawer/sidenav.ts +546 -0
  67. package/components/navigation-drawer/sidenavSpec.js +124 -0
  68. package/components/pagination/_pagination.scss +47 -0
  69. package/components/progress/_preloader.scss +416 -0
  70. package/components/radio-button/_radio-buttons.scss +112 -0
  71. package/components/radio-button/radio-buttons.mdx +28 -0
  72. package/components/radio-button/radio-buttons.stories.ts +51 -0
  73. package/components/search/autocomplete.ts +620 -0
  74. package/components/search/autocompleteSpec.js +321 -0
  75. package/components/slider/_range.scss +157 -0
  76. package/components/slider/range.ts +216 -0
  77. package/components/snackbar/_toast.scss +68 -0
  78. package/components/snackbar/toastSpec.js +132 -0
  79. package/components/snackbar/toasts.ts +312 -0
  80. package/components/switch/_switches.scss +121 -0
  81. package/components/tabs/_tabs.scss +171 -0
  82. package/components/tabs/tabs.mjs +31 -0
  83. package/components/tabs/tabs.ts +358 -0
  84. package/components/tabs/tabsSpec.js +180 -0
  85. package/components/textfield/_file-input.scss +41 -0
  86. package/components/textfield/_input-fields.scss +368 -0
  87. package/components/textfield/_select.scss +104 -0
  88. package/components/textfield/formfields.css +311 -0
  89. package/components/textfield/forms.ts +182 -0
  90. package/components/textfield/formsSpec.js +142 -0
  91. package/components/textfield/select.ts +472 -0
  92. package/components/textfield/selectSpec.js +390 -0
  93. package/components/textfield/textfield.mjs +29 -0
  94. package/components/textfield/textfield.test.mjs +10 -0
  95. package/components/timepicker/_timepicker.scss +362 -0
  96. package/components/timepicker/timepicker.ts +905 -0
  97. package/components/tooltip/_tooltip.scss +40 -0
  98. package/components/tooltip/tooltip.ts +380 -0
  99. package/components/tooltip/tooltipSpec.js +145 -0
  100. package/dist/css/materialize.colors.min.css +6 -0
  101. package/dist/css/materialize.css +7578 -6326
  102. package/dist/css/materialize.min.css +6 -13
  103. package/dist/css/materialize.min.css.map +1 -0
  104. package/dist/js/materialize.cjs.js +8410 -0
  105. package/dist/js/materialize.d.ts +2625 -0
  106. package/dist/js/materialize.js +8415 -12374
  107. package/dist/js/materialize.min.js +6 -6
  108. package/dist/js/materialize.mjs +8382 -0
  109. package/package.json +82 -47
  110. package/sass/_colors.scss +417 -0
  111. package/sass/_global.scss +490 -0
  112. package/sass/_grid.scss +172 -0
  113. package/sass/_table_of_contents.scss +28 -0
  114. package/sass/_tapTarget.scss +102 -0
  115. package/sass/_typography.scss +58 -0
  116. package/sass/_variables.scss +56 -0
  117. package/sass/materialize.scss +51 -0
  118. package/sass/mixins.module.scss +168 -0
  119. package/extras/noUiSlider/nouislider.css +0 -406
  120. package/extras/noUiSlider/nouislider.js +0 -2147
  121. package/extras/noUiSlider/nouislider.min.js +0 -1
  122. package/js/anime.min.js +0 -34
  123. package/js/autocomplete.js +0 -448
  124. package/js/buttons.js +0 -354
  125. package/js/cards.js +0 -40
  126. package/js/carousel.js +0 -717
  127. package/js/cash.js +0 -960
  128. package/js/characterCounter.js +0 -136
  129. package/js/chips.js +0 -481
  130. package/js/collapsible.js +0 -275
  131. package/js/component.js +0 -44
  132. package/js/datepicker.js +0 -975
  133. package/js/dropdown.js +0 -635
  134. package/js/forms.js +0 -275
  135. package/js/global.js +0 -444
  136. package/js/materialbox.js +0 -453
  137. package/js/modal.js +0 -382
  138. package/js/parallax.js +0 -138
  139. package/js/pushpin.js +0 -148
  140. package/js/range.js +0 -263
  141. package/js/scrollspy.js +0 -295
  142. package/js/select.js +0 -450
  143. package/js/sidenav.js +0 -580
  144. package/js/slider.js +0 -359
  145. package/js/tabs.js +0 -402
  146. package/js/tapTarget.js +0 -314
  147. package/js/timepicker.js +0 -647
  148. package/js/toasts.js +0 -310
  149. package/js/tooltip.js +0 -303
  150. package/js/waves.js +0 -335
@@ -0,0 +1,281 @@
1
+ /* Checkboxes */
2
+
3
+ @at-root {
4
+ :root {
5
+ --checkbox-size: 18px; // 18px
6
+ --checkbox-shape: 2px;
7
+ }
8
+ }
9
+
10
+ input[type="checkbox"] {
11
+ /* Add if not using autoprefixer */
12
+ -webkit-appearance: none;
13
+ appearance: none;
14
+ /* For iOS < 15 to remove gradient background */
15
+ // background-color: #fff;
16
+ margin: 0;
17
+ position: relative;
18
+ cursor: pointer;
19
+ }
20
+
21
+ input[type="checkbox"]:focus {
22
+ outline: 3px solid var(--md-sys-color-secondary);
23
+ border-radius: 50%;
24
+ outline-offset: 0.5rem;
25
+ }
26
+
27
+ input[type="checkbox"]:before {
28
+ opacity: 1;
29
+ position: absolute;
30
+ display: block;
31
+ width: var(--checkbox-size);
32
+ height: var(--checkbox-size);
33
+ border: 2px solid var(--md-sys-color-on-surface-variant);
34
+ border-radius: var(--checkbox-shape);
35
+ content: "";
36
+ // background: #fff;
37
+ }
38
+
39
+ input[type="checkbox"]:after {
40
+ position: relative;
41
+ display: block;
42
+ // left: 2px;
43
+ // top: -11px;
44
+ width: var(--checkbox-size);
45
+ height: var(--checkbox-size);
46
+ // border-width: 2px;
47
+ // border-style: solid;
48
+ // border-color: var(--md-sys-color-on-surface-variant);
49
+ content: "";
50
+ // background-image: linear-gradient(135deg, #B1B6BE 0%, #FFF 100%);
51
+ border-radius: var(--checkbox-shape);
52
+ background-repeat: no-repeat;
53
+ background-position: center;
54
+ }
55
+
56
+ input[type="checkbox"]:checked:after {
57
+ background-color: var(--md-sys-color-primary);
58
+ clip-path: polygon(0 48%, 0 0, 56% 0, 74% 17%, 40% 64%, 23% 50%, 14% 61%, 42% 82%, 81% 31%, 32% 0, 100% 0, 100% 100%, 0 100%, 0 49%);
59
+ }
60
+
61
+ [type="checkbox"]:indeterminate:after {
62
+ background-color: var(--md-sys-color-primary);
63
+ clip-path: polygon(0% 0%, 0% 100%, 18% 100%, 16% 43%, 83% 42%, 83% 63%, 16% 63%, 16% 100%, 100% 100%, 100% 0%);
64
+ }
65
+
66
+ // Disabled
67
+ input[type="checkbox"]:disabled:before {
68
+ filter: opacity(0.2);
69
+ }
70
+ input[type="checkbox"]:disabled:after {
71
+ filter: opacity(0.2);
72
+ }
73
+
74
+ // Hover
75
+ input[type="checkbox"]:not(:disabled):checked:hover:after{
76
+ // background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAQAAABuW59YAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAAB2SURBVHjaAGkAlv8A3QDyAP0A/QD+Dam3W+kCAAD8APYAAgTVZaZCGwwA5wr0AvcA+Dh+7UX/x24AqK3Wg/8nt6w4/5q71wAAVP9g/7rTXf9n/+9N+AAAtpJa/zf/S//DhP8H/wAA4gzWj2P4lsf0JP0A/wADAHB0Ngka6UmKAAAAAElFTkSuQmCC'), linear-gradient(135deg, #8BB0C2 0%,#FFF 100%);
77
+ background-color: var(--md-sys-color-primary);
78
+ }
79
+
80
+ input[type="checkbox"]:not(:disabled):hover:after{
81
+ // background-image: linear-gradient(135deg, #8BB0C2 0%,#FFF 100%);
82
+ border-color: #85A9BB #92C2DA #92C2DA #85A9BB;
83
+ }
84
+
85
+ input[type="checkbox"]:not(:disabled):hover:before{
86
+ border-color: #3D7591;
87
+ }
88
+
89
+ /*
90
+ // Checkbox Styles
91
+ [type="checkbox"] {
92
+ // Text Label Style
93
+ + span:not(.lever) {
94
+ position: relative;
95
+ cursor: pointer;
96
+ display: inline-block;
97
+ height: var(--checkbox-size);
98
+ line-height: var(--checkbox-size);
99
+ padding-left: var(--checkbox-size);
100
+ // background-color: red;
101
+ font-size: 1rem;
102
+ user-select: none;
103
+ }
104
+
105
+ // checkbox aspect
106
+ + span:not(.lever):before,
107
+ &:not(.filled-in) + span:not(.lever):after {
108
+ content: '';
109
+ position: absolute;
110
+ top: 0;
111
+ left: 0;
112
+ width: var(--checkbox-size);
113
+ height: var(--checkbox-size);
114
+ z-index: 0;
115
+ border: 2px solid var(--md-sys-color-on-surface-variant);
116
+ border-radius: 1px;
117
+ transition: .2s;
118
+ }
119
+
120
+ &:not(.filled-in) + span:not(.lever):after {
121
+ border: 0;
122
+ transform: scale(0);
123
+ }
124
+
125
+ &:not(:checked):disabled + span:not(.lever):before {
126
+ border-color: color-mix(in srgb, transparent, var(--md-sys-color-on-surface) 38%);
127
+ }
128
+
129
+ &:disabled + span:not(.lever) {
130
+ color: color-mix(in srgb, transparent, var(--md-sys-color-on-surface) 38%);
131
+ }
132
+
133
+ // Focused styles
134
+ &.tabbed:focus + span:not(.lever):after {
135
+ transform: scale(1);
136
+ border: 0;
137
+ border-radius: 50%;
138
+ box-shadow: 0 0 0 10px rgba(0, 0, 0, 0.12);
139
+ background-color: rgba(0, 0, 0, 0.12);
140
+ }
141
+ }
142
+
143
+ [type="checkbox"]:checked {
144
+ + span:not(.lever):before {
145
+ top: -4px;
146
+ left: -5px;
147
+ width: 12px;
148
+ height: 22px;
149
+ border-top: 2px solid transparent;
150
+ border-left: 2px solid transparent;
151
+ border-right: 2px solid var(--md-sys-color-primary);
152
+ border-bottom: 2px solid var(--md-sys-color-primary);
153
+ transform: rotate(40deg);
154
+ backface-visibility: hidden;
155
+ transform-origin: 100% 100%;
156
+ }
157
+
158
+ &:disabled + span:before {
159
+ border-right: 2px solid color-mix(in srgb, transparent, var(--md-sys-color-on-surface) 38%);
160
+ border-bottom: 2px solid color-mix(in srgb, transparent, var(--md-sys-color-on-surface) 38%);
161
+ }
162
+ }
163
+
164
+ // Indeterminate checkbox
165
+ [type="checkbox"]:indeterminate {
166
+ + span:not(.lever):before {
167
+ top: -11px;
168
+ left: -12px;
169
+ width: 10px;
170
+ height: 22px;
171
+ border-top: none;
172
+ border-left: none;
173
+ border-right: 2px solid var(--md-sys-color-primary);
174
+ border-bottom: none;
175
+ transform: rotate(90deg);
176
+ backface-visibility: hidden;
177
+ transform-origin: 100% 100%;
178
+ }
179
+
180
+ // Disabled indeterminate
181
+ &:disabled + span:not(.lever):before {
182
+ border-right: 2px solid color-mix(in srgb, transparent, var(--md-sys-color-on-surface) 38%);
183
+ background-color: transparent;
184
+ }
185
+ }
186
+
187
+ // Filled in Style
188
+ [type="checkbox"].filled-in {
189
+ // General
190
+ + span:not(.lever):after {
191
+ border-radius: 2px;
192
+ }
193
+
194
+ + span:not(.lever):before,
195
+ + span:not(.lever):after {
196
+ content: '';
197
+ left: 0;
198
+ position: absolute;
199
+ // .1s delay is for check animation
200
+ transition: border .25s, background-color .25s, width .20s .1s, height .20s .1s, top .20s .1s, left .20s .1s;
201
+ z-index: 1;
202
+ }
203
+
204
+ // Unchecked style
205
+ &:not(:checked) + span:not(.lever):before {
206
+ width: 0;
207
+ height: 0;
208
+ border: 3px solid transparent;
209
+ left: 6px;
210
+ top: 10px;
211
+ transform: rotateZ(37deg);
212
+ transform-origin: 100% 100%;
213
+ }
214
+
215
+ &:not(:checked) + span:not(.lever):after {
216
+ height: 20px;
217
+ width: 20px;
218
+ background-color: transparent;
219
+ border: 2px solid var(--md-sys-color-on-surface-variant);
220
+ top: 0px;
221
+ z-index: 0;
222
+ }
223
+
224
+ // Checked style
225
+ &:checked {
226
+ + span:not(.lever):before {
227
+ top: 0;
228
+ left: 1px;
229
+ width: 8px;
230
+ height: 13px;
231
+ border-top: 2px solid transparent;
232
+ border-left: 2px solid transparent;
233
+ border-right: 2px solid var(--md-sys-color-on-primary);
234
+ border-bottom: 2px solid var(--md-sys-color-on-primary);
235
+ transform: rotateZ(37deg);
236
+ transform-origin: 100% 100%;
237
+ }
238
+
239
+ + span:not(.lever):after {
240
+ top: 0;
241
+ width: 20px;
242
+ height: 20px;
243
+ border: 2px solid var(--md-sys-color-primary);
244
+ background-color: var(--md-sys-color-primary);
245
+ z-index: 0;
246
+ }
247
+ }
248
+
249
+ // Focused styles
250
+ &.tabbed:focus + span:not(.lever):after {
251
+ border-radius: 2px;
252
+ border-color: var(--md-sys-color-on-surface-variant)r;
253
+ background-color: rgba(0, 0, 0, 0.12);
254
+ }
255
+
256
+ &.tabbed:checked:focus + span:not(.lever):after {
257
+ border-radius: 2px;
258
+ background-color: var(--md-sys-color-primary);
259
+ border-color: var(--md-sys-color-primary);
260
+ }
261
+
262
+ // Disabled style
263
+ &:disabled:not(:checked) + span:not(.lever):before {
264
+ background-color: transparent;
265
+ border: 2px solid transparent;
266
+ }
267
+
268
+ &:disabled:not(:checked) + span:not(.lever):after {
269
+ border-color: color-mix(in srgb, transparent, var(--md-sys-color-on-surface) 38%);
270
+ }
271
+
272
+ &:disabled:checked + span:not(.lever):before {
273
+ background-color: transparent;
274
+ }
275
+
276
+ &:disabled:checked + span:not(.lever):after {
277
+ background-color: color-mix(in srgb, transparent, var(--md-sys-color-on-surface) 38%);
278
+ border: none;
279
+ }
280
+ }
281
+ */
@@ -0,0 +1,24 @@
1
+ import {Story, Meta, Source, Controls, Markdown, Primary} from '@storybook/addon-docs/blocks';
2
+ import * as stories from './checkbox.stories';
3
+
4
+ <Meta of={stories}/>
5
+
6
+ # Checkboxes
7
+
8
+ Use checkboxes when looking for yes or no answers. The `for` attribute is necessary to bind our custom checkbox with the input.
9
+ Add the input's `id` as the value of the `for` attribute of the label.
10
+
11
+ ## Default
12
+
13
+ <Story of={stories.Default} />
14
+ <Source of={stories.Default} format="dedent"/>
15
+
16
+ ## Filled-in Checkbox
17
+
18
+ <Story of={stories.FilledIn} />
19
+ <Source of={stories.FilledIn} format="dedent"/>
20
+
21
+ ## Indeterminate Checkbox
22
+
23
+ <Story of={stories.Indeterminate} />
24
+ <Source of={stories.Indeterminate} format="dedent"/>
@@ -0,0 +1,120 @@
1
+ import type { Meta, StoryObj } from '@storybook/html-vite';
2
+
3
+ export default {
4
+ title: 'Components/Checkbox'
5
+ } satisfies Meta;
6
+
7
+ export const Default: StoryObj = {
8
+ render() {
9
+ return `
10
+ <form action="#">
11
+
12
+ <p>Normal basic checkbox input</p>
13
+
14
+ <input type="checkbox" />
15
+ <input type="checkbox" checked="checked" />
16
+ <input type="checkbox" disabled />
17
+ <input type="checkbox" disabled checked="checked" />
18
+
19
+ <p>Compound Checkbox Elements</p>
20
+
21
+ <p>
22
+ <label>
23
+ <input type="checkbox" />
24
+ <span>Unchecked</span>
25
+ </label>
26
+ </p>
27
+
28
+ <p>
29
+ <label>
30
+ <input type="checkbox" checked="checked" />
31
+ <span>Checked</span>
32
+ </label>
33
+ </p>
34
+
35
+ <p>
36
+ <label>
37
+ <input type="checkbox" />
38
+ <span></span>
39
+ </label>
40
+ </p>
41
+
42
+ <p>
43
+ <label>
44
+ <input type="checkbox" disabled="disabled" />
45
+ <span>Disabled</span>
46
+ </label>
47
+ </p>
48
+
49
+ <p>
50
+ <label>
51
+ <input type="checkbox" checked="checked" disabled="disabled" />
52
+ <span>Checked & Disabled</span>
53
+ </label>
54
+ </p>
55
+ </form>
56
+ `;
57
+ }
58
+ };
59
+
60
+ export const FilledIn: StoryObj = {
61
+ render() {
62
+ return `
63
+ <form action="#">
64
+ <p>
65
+ <label>
66
+ <input type="checkbox" class="filled-in"/>
67
+ <span>Filled in unchecked</span>
68
+ </label>
69
+ </p>
70
+ <p>
71
+ <label>
72
+ <input type="checkbox" class="filled-in" checked="checked"/>
73
+ <span>Filled in checked</span>
74
+ </label>
75
+ </p>
76
+ <p>
77
+ <label>
78
+ <input type="checkbox" class="filled-in" disabled="disabled"/>
79
+ <span>Filled in disabled</span>
80
+ </label>
81
+ </p>
82
+ <p>
83
+ <label>
84
+ <input type="checkbox" class="filled-in" checked="checked" disabled="disabled"/>
85
+ <span>Filled in checked & disabled</span>
86
+ </label>
87
+ </p>
88
+ </form>
89
+ `;
90
+ }
91
+ };
92
+
93
+ export const Indeterminate: StoryObj = {
94
+ render() {
95
+ return `
96
+ <form action="#">
97
+ <p>
98
+ <label>
99
+ <input class="indeterminate-checkbox" type="checkbox" />
100
+ <span>Indeterminate Style</span>
101
+ </label>
102
+ </p>
103
+ <p>
104
+ <label>
105
+ <input class="indeterminate-checkbox" type="checkbox" disabled="disabled"/>
106
+ <span>Indeterminate Disabled</span>
107
+ </label>
108
+ </p>
109
+ </form>
110
+
111
+ <script>
112
+ // Set the indeterminate property on the checkbox elements
113
+ const elements = document.querySelectorAll('.indeterminate-checkbox');
114
+ elements.forEach((element) => {
115
+ element.indeterminate = true;
116
+ });
117
+ </script>
118
+ `;
119
+ }
120
+ };
@@ -0,0 +1,37 @@
1
+ import { Component } from '../atomic/component.mjs';
2
+
3
+ class Chip extends Component {
4
+ #id;
5
+ #text;
6
+ #image;
7
+
8
+ constructor(options) {
9
+ super(options);
10
+ this.addClassname('chip');
11
+ }
12
+
13
+ setId(id) {
14
+ this.#id = id;
15
+ return this;
16
+ }
17
+
18
+ setText(text) {
19
+ this.#text = text;
20
+ return this;
21
+ }
22
+
23
+ setImage(image) {
24
+ this.#image = image;
25
+ return this;
26
+ }
27
+
28
+ toHTML() {
29
+ let html = '';
30
+ if (this.#image) html += `<img src="${this.#image}" alt=""/>`;
31
+ html += this.#text;
32
+ this.setChildren(html);
33
+ return super.toHTML();
34
+ }
35
+ }
36
+
37
+ export { Chip };
@@ -0,0 +1,10 @@
1
+ import { describe, expect, test } from 'vitest';
2
+ import { Chip } from './chip.mjs';
3
+
4
+ describe('chip', () => {
5
+ test('create html', () => {
6
+ const chip = new Chip().setText('John Doe');
7
+ //console.log(list.toHTML());
8
+ expect(chip.toHTML()).toContain('John');
9
+ });
10
+ });
@@ -0,0 +1,126 @@
1
+ .chip {
2
+ --font-size: 14px;
3
+ --font-size-icon: 18px;
4
+ --padding: 8px;
5
+
6
+ color: var(--md-sys-color-on-surface-variant);
7
+ background-color: rgba(0, 0, 0, 0.09);
8
+ display: inline-flex;
9
+ white-space: nowrap;
10
+ gap: 8px;
11
+ margin: 0;
12
+ height: 32px;
13
+ padding-left: var(--padding);
14
+ padding-right: var(--padding);
15
+ font-size: var(--font-size);
16
+ font-weight: 500;
17
+ border-radius: 8px;
18
+ align-items: center;
19
+ user-select: none;
20
+ vertical-align: top;
21
+ }
22
+ .chip:focus {
23
+ outline: none;
24
+ background-color: var(--md-sys-color-primary);
25
+ color: var(--md-sys-color-on-primary);
26
+ }
27
+
28
+ .chip.outlined {
29
+ background-color: transparent;
30
+ border-color: var(--md-sys-color-outline);
31
+ border-width: 1px;
32
+ border-style: solid;
33
+ }
34
+
35
+ .chip > img {
36
+ margin: 0;
37
+ width: 24px;
38
+ height: 24px;
39
+ object-fit: cover;
40
+ border-radius: 12px;
41
+ }
42
+
43
+ .chip > .material-icons {
44
+ font-size: var(--font-size-icon);
45
+ color: var(--md-sys-color-on-surface-variant);
46
+ }
47
+
48
+ .chip .close {
49
+ border: none;
50
+ border-radius: 50%;
51
+ height: 24px;
52
+ width: 24px;
53
+ padding: 0;
54
+ display: grid;
55
+ justify-content: center;
56
+ align-content: center;
57
+ cursor: pointer;
58
+ }
59
+
60
+ .chip .close:hover {
61
+ background-color: #8888;
62
+ }
63
+
64
+ .chips {
65
+ display: flex;
66
+ gap: 4px;
67
+ flex-wrap: wrap;
68
+ border: none;
69
+ box-shadow: none;
70
+ margin: 0 0 8px 0;
71
+ padding: 4px;
72
+ /* min-height: 45px; */
73
+ outline: none;
74
+ transition: all 0.3s;
75
+ }
76
+ .chips.focus {
77
+ border-bottom: 1px solid var(--md-sys-color-primary);
78
+ box-shadow: 0 1px 0 0 var(--md-sys-color-primary);
79
+ }
80
+ .chips.input-field {
81
+ border-bottom: 1px solid var(--md-sys-color-on-surface-variant);
82
+ }
83
+ .chis input:not([type]):not(.browser-default).input {
84
+ background: none;
85
+ border: 0;
86
+ color: var(--md-sys-color-on-background);
87
+ display: inline-block;
88
+ font-size: 16px;
89
+ /* height: 32px;
90
+ line-height: 32px; */
91
+ height: 32px;
92
+ outline: 0;
93
+ margin: 0;
94
+ padding: 0;
95
+ width: 120px;
96
+ width: fit-content;
97
+ min-width: 100px;
98
+ max-width: 200px;
99
+ }
100
+
101
+ .chis input:not([type]):not(.browser-default).input:focus {
102
+ border: 0;
103
+ box-shadow: none;
104
+ }
105
+ .chips.input-field:hover {
106
+ cursor: text;
107
+ }
108
+ .chips .autocomplete-content {
109
+ margin-top: 0;
110
+ margin-bottom: 0;
111
+ }
112
+
113
+ .prefix ~ .chips {
114
+ margin-left: 3rem;
115
+ width: 92%;
116
+ width: calc(100% - 3rem);
117
+ }
118
+ .suffix ~ .chips {
119
+ margin-right: 3rem;
120
+ width: 92%;
121
+ width: calc(100% - 3rem);
122
+ }
123
+ .chips:empty ~ label {
124
+ font-size: 0.8rem;
125
+ transform: translateY(-140%);
126
+ }
@@ -0,0 +1,33 @@
1
+ # Chips
2
+
3
+ To add tags, just enter your tag text and press enter. You can delete them by clicking on the close icon or by using your delete button.
4
+
5
+
6
+ ATTENTION: Data-Format has changed from version 1.X.X to 2.0.0! Please update option 'data'.
7
+
8
+ Normal:
9
+
10
+ <div class="chips"></div>
11
+
12
+ Set initial tags:
13
+
14
+ <div class="chips chips-initial"></div>
15
+
16
+ Use placeholders and override hint texts:
17
+
18
+ <div class="chips chips-placeholder"></div>
19
+
20
+ Use autocomplete with chips:
21
+
22
+ <div class="chips chips-autocomplete"></div>
23
+
24
+ ```html
25
+ <!-- Default with no input (automatically generated) -->
26
+ <div class="chips"></div>
27
+ <div class="chips chips-initial"></div>
28
+ <div class="chips chips-placeholder"></div>
29
+ <div class="chips chips-autocomplete"></div>
30
+ <!-- Customizable input -->
31
+ <div class="chips">
32
+ <input class="custom-class">
33
+ </div>