@allxsmith/bestax-bulma 5.51.0 → 5.53.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 (133) hide show
  1. package/dist/bestax.css +1 -1
  2. package/dist/bestax.css.map +1 -1
  3. package/dist/esm/components/Command.js +637 -0
  4. package/dist/esm/components/Command.js.map +1 -0
  5. package/dist/esm/components/Modal.js +2 -1
  6. package/dist/esm/components/Modal.js.map +1 -1
  7. package/dist/esm/components/Sidebar.js +3 -1
  8. package/dist/esm/components/Sidebar.js.map +1 -1
  9. package/dist/esm/components/Toast.js +8 -5
  10. package/dist/esm/components/Toast.js.map +1 -1
  11. package/dist/esm/elements/Notification.js +4 -2
  12. package/dist/esm/elements/Notification.js.map +1 -1
  13. package/dist/esm/form/Autocomplete.js +5 -4
  14. package/dist/esm/form/Autocomplete.js.map +1 -1
  15. package/dist/esm/form/Checkbox.js +3 -2
  16. package/dist/esm/form/Checkbox.js.map +1 -1
  17. package/dist/esm/form/CheckboxCard.js +119 -0
  18. package/dist/esm/form/CheckboxCard.js.map +1 -0
  19. package/dist/esm/form/Checkboxes.js +14 -3
  20. package/dist/esm/form/Checkboxes.js.map +1 -1
  21. package/dist/esm/form/Combobox.js +3 -2
  22. package/dist/esm/form/Combobox.js.map +1 -1
  23. package/dist/esm/form/DateInputBase.js +15 -6
  24. package/dist/esm/form/DateInputBase.js.map +1 -1
  25. package/dist/esm/form/DateRangeInputBase.js +15 -5
  26. package/dist/esm/form/DateRangeInputBase.js.map +1 -1
  27. package/dist/esm/form/DateTimeInputBase.js +15 -6
  28. package/dist/esm/form/DateTimeInputBase.js.map +1 -1
  29. package/dist/esm/form/Fieldset.js +64 -0
  30. package/dist/esm/form/Fieldset.js.map +1 -0
  31. package/dist/esm/form/FormContext.js +17 -1
  32. package/dist/esm/form/FormContext.js.map +1 -1
  33. package/dist/esm/form/InputBase.js +3 -2
  34. package/dist/esm/form/InputBase.js.map +1 -1
  35. package/dist/esm/form/Numberinput.js +3 -2
  36. package/dist/esm/form/Numberinput.js.map +1 -1
  37. package/dist/esm/form/PinInput.js +3 -2
  38. package/dist/esm/form/PinInput.js.map +1 -1
  39. package/dist/esm/form/Radio.js +3 -2
  40. package/dist/esm/form/Radio.js.map +1 -1
  41. package/dist/esm/form/RadioCard.js +86 -0
  42. package/dist/esm/form/RadioCard.js.map +1 -0
  43. package/dist/esm/form/Radios.js +14 -3
  44. package/dist/esm/form/Radios.js.map +1 -1
  45. package/dist/esm/form/Rate.js +3 -2
  46. package/dist/esm/form/Rate.js.map +1 -1
  47. package/dist/esm/form/SelectBase.js +3 -2
  48. package/dist/esm/form/SelectBase.js.map +1 -1
  49. package/dist/esm/form/Slider.js +3 -2
  50. package/dist/esm/form/Slider.js.map +1 -1
  51. package/dist/esm/form/Switch.js +3 -1
  52. package/dist/esm/form/Switch.js.map +1 -1
  53. package/dist/esm/form/Taginput.js +3 -2
  54. package/dist/esm/form/Taginput.js.map +1 -1
  55. package/dist/esm/form/TextAreaBase.js +3 -2
  56. package/dist/esm/form/TextAreaBase.js.map +1 -1
  57. package/dist/esm/form/TimeInputBase.js +13 -6
  58. package/dist/esm/form/TimeInputBase.js.map +1 -1
  59. package/dist/esm/form/_pickerInternals/PickerPopover.js +4 -2
  60. package/dist/esm/form/_pickerInternals/PickerPopover.js.map +1 -1
  61. package/dist/esm/form/_pickerInternals/useLocaleDefaults.js +80 -0
  62. package/dist/esm/form/_pickerInternals/useLocaleDefaults.js.map +1 -0
  63. package/dist/esm/form/groupFieldset.js +38 -0
  64. package/dist/esm/form/groupFieldset.js.map +1 -0
  65. package/dist/esm/form/useAutoLabelId.js +1 -1
  66. package/dist/esm/helpers/LocaleProvider.js +153 -0
  67. package/dist/esm/helpers/LocaleProvider.js.map +1 -0
  68. package/dist/esm/helpers/localeInfo.js +109 -0
  69. package/dist/esm/helpers/localeInfo.js.map +1 -0
  70. package/dist/esm/helpers/portal.js +14 -1
  71. package/dist/esm/helpers/portal.js.map +1 -1
  72. package/dist/esm/helpers/useComboboxEngine.js +3 -3
  73. package/dist/esm/helpers/useFocusTrap.js +2 -2
  74. package/dist/esm/helpers/useFocusTrap.js.map +1 -1
  75. package/dist/extras.css +1 -1
  76. package/dist/extras.css.map +1 -1
  77. package/dist/index.cjs +4905 -3584
  78. package/dist/index.cjs.map +1 -1
  79. package/dist/index.esm.js +5 -0
  80. package/dist/index.esm.js.map +1 -1
  81. package/dist/types/components/Command.d.ts +318 -0
  82. package/dist/types/form/CheckboxCard.d.ts +94 -0
  83. package/dist/types/form/Checkboxes.d.ts +13 -0
  84. package/dist/types/form/DateInputBase.d.ts +25 -3
  85. package/dist/types/form/DateRangeInputBase.d.ts +25 -3
  86. package/dist/types/form/DateTimeInputBase.d.ts +25 -3
  87. package/dist/types/form/Fieldset.d.ts +86 -0
  88. package/dist/types/form/FormContext.d.ts +12 -0
  89. package/dist/types/form/RadioCard.d.ts +81 -0
  90. package/dist/types/form/Radios.d.ts +13 -0
  91. package/dist/types/form/TimeInputBase.d.ts +5 -1
  92. package/dist/types/form/_pickerInternals/PickerPopover.d.ts +6 -0
  93. package/dist/types/form/_pickerInternals/useLocaleDefaults.d.ts +49 -0
  94. package/dist/types/form/groupFieldset.d.ts +32 -0
  95. package/dist/types/helpers/LocaleProvider.d.ts +128 -0
  96. package/dist/types/helpers/localeInfo.d.ts +23 -0
  97. package/dist/types/helpers/portal.d.ts +11 -0
  98. package/dist/types/index.d.ts +6 -0
  99. package/dist/types-cjs/components/Command.d.ts +318 -0
  100. package/dist/types-cjs/form/CheckboxCard.d.ts +94 -0
  101. package/dist/types-cjs/form/Checkboxes.d.ts +13 -0
  102. package/dist/types-cjs/form/DateInputBase.d.ts +25 -3
  103. package/dist/types-cjs/form/DateRangeInputBase.d.ts +25 -3
  104. package/dist/types-cjs/form/DateTimeInputBase.d.ts +25 -3
  105. package/dist/types-cjs/form/Fieldset.d.ts +86 -0
  106. package/dist/types-cjs/form/FormContext.d.ts +12 -0
  107. package/dist/types-cjs/form/RadioCard.d.ts +81 -0
  108. package/dist/types-cjs/form/Radios.d.ts +13 -0
  109. package/dist/types-cjs/form/TimeInputBase.d.ts +5 -1
  110. package/dist/types-cjs/form/_pickerInternals/PickerPopover.d.ts +6 -0
  111. package/dist/types-cjs/form/_pickerInternals/useLocaleDefaults.d.ts +49 -0
  112. package/dist/types-cjs/form/groupFieldset.d.ts +32 -0
  113. package/dist/types-cjs/helpers/LocaleProvider.d.ts +128 -0
  114. package/dist/types-cjs/helpers/localeInfo.d.ts +23 -0
  115. package/dist/types-cjs/helpers/portal.d.ts +11 -0
  116. package/dist/types-cjs/index.d.ts +6 -0
  117. package/dist/versions/bestax-no-dark-mode.css +1 -1
  118. package/dist/versions/bestax-no-dark-mode.css.map +1 -1
  119. package/dist/versions/bestax-no-helpers-prefixed.css +1 -1
  120. package/dist/versions/bestax-no-helpers-prefixed.css.map +1 -1
  121. package/dist/versions/bestax-no-helpers.css +1 -1
  122. package/dist/versions/bestax-no-helpers.css.map +1 -1
  123. package/dist/versions/bestax-prefixed.css +1 -1
  124. package/dist/versions/bestax-prefixed.css.map +1 -1
  125. package/package.json +1 -1
  126. package/src/scss/components/_command.scss +259 -0
  127. package/src/scss/components/_index.scss +1 -0
  128. package/src/scss/form/_checkbox.scss +44 -0
  129. package/src/scss/form/_checkboxcard.scss +355 -0
  130. package/src/scss/form/_fieldset.scss +108 -0
  131. package/src/scss/form/_index.scss +3 -0
  132. package/src/scss/form/_radio.scss +44 -0
  133. package/src/scss/form/_radiocard.scss +291 -0
@@ -0,0 +1,259 @@
1
+ // Bestax Extras - Command Styles
2
+ // A search field over a list of things to do. The field is Bulma's `Input`,
3
+ // in its Control, and the box, the list, its groups and its items are
4
+ // written here: the highlight that follows the keyboard is the pair Bulma's
5
+ // dropdown gives an `is-active` item, as Combobox's is. In a dialog the box
6
+ // sits in Bulma's `.modal`, near the top rather than in the middle, so it
7
+ // doesn't jump as the list grows and shrinks.
8
+ //
9
+ // Colors come from Bulma's tokens, so dark mode needs no rules of its own.
10
+
11
+ @use 'bulma/sass/utilities/initial-variables' as iv;
12
+ @use 'bulma/sass/utilities/css-variables' as cv;
13
+
14
+ $command-background: cv.getVar('scheme-main') !default;
15
+ // The edge keeps the box apart from the page, and from the background in a
16
+ // dialog, where the shadow all but vanishes on a dark page and is dropped in
17
+ // forced colors.
18
+ $command-border-color: cv.getVar('border-weak') !default;
19
+ $command-radius: cv.getVar('radius-large') !default;
20
+ $command-padding: 0.5rem !default;
21
+ // Between the field and the list.
22
+ $command-gap: 0.5rem !default;
23
+ // The list scrolls past this.
24
+ $command-list-max-height: 20rem !default;
25
+ $command-item-color: cv.getVar('text-strong') !default;
26
+ $command-item-size: 0.875rem !default;
27
+ $command-item-padding-y: 0.5rem !default;
28
+ $command-item-padding-x: 0.75rem !default;
29
+ $command-item-radius: cv.getVar('radius') !default;
30
+ // Between the icon, the label and the hint.
31
+ $command-item-gap: 0.75rem !default;
32
+ $command-item-hover-background: hsl(
33
+ #{cv.getVar('scheme-h')},
34
+ #{cv.getVar('scheme-s')},
35
+ calc(#{cv.getVar('scheme-main-l')} + #{cv.getVar('hover-background-l-delta')})
36
+ ) !default;
37
+ $command-highlight-background: cv.getVar('link') !default;
38
+ $command-highlight-color: cv.getVar('link-invert') !default;
39
+ $command-disabled-color: cv.getVar('text-weak') !default;
40
+ $command-icon-color: cv.getVar('text-weak') !default;
41
+ $command-description-color: cv.getVar('text-weak') !default;
42
+ $command-description-size: 0.875em !default;
43
+ $command-hint-color: cv.getVar('text-weak') !default;
44
+ $command-group-label-size: 0.85em !default;
45
+ $command-group-label-weight: cv.getVar('weight-semibold') !default;
46
+ $command-group-label-color: cv.getVar('text-weak') !default;
47
+ $command-divider-color: cv.getVar('border-weak') !default;
48
+ $command-empty-color: cv.getVar('text-weak') !default;
49
+ $command-empty-padding: 1.5rem !default;
50
+ // The dialog: how wide it gets, how far down it sits, and its shadow.
51
+ $command-dialog-width: 40rem !default;
52
+ $command-dialog-offset: 12vh !default;
53
+ $command-dialog-shadow: cv.getVar('shadow') !default;
54
+
55
+ .#{iv.$class-prefix}command {
56
+ @include cv.register-vars(
57
+ (
58
+ 'command-background': #{$command-background},
59
+ 'command-border-color': #{$command-border-color},
60
+ 'command-radius': #{$command-radius},
61
+ 'command-padding': #{$command-padding},
62
+ 'command-gap': #{$command-gap},
63
+ 'command-list-max-height': #{$command-list-max-height},
64
+ 'command-item-color': #{$command-item-color},
65
+ 'command-item-size': #{$command-item-size},
66
+ 'command-item-padding-y': #{$command-item-padding-y},
67
+ 'command-item-padding-x': #{$command-item-padding-x},
68
+ 'command-item-radius': #{$command-item-radius},
69
+ 'command-item-gap': #{$command-item-gap},
70
+ 'command-item-hover-background': #{$command-item-hover-background},
71
+ 'command-highlight-background': #{$command-highlight-background},
72
+ 'command-highlight-color': #{$command-highlight-color},
73
+ 'command-disabled-color': #{$command-disabled-color},
74
+ 'command-icon-color': #{$command-icon-color},
75
+ 'command-description-color': #{$command-description-color},
76
+ 'command-description-size': #{$command-description-size},
77
+ 'command-hint-color': #{$command-hint-color},
78
+ 'command-group-label-size': #{$command-group-label-size},
79
+ 'command-group-label-weight': #{$command-group-label-weight},
80
+ 'command-group-label-color': #{$command-group-label-color},
81
+ 'command-divider-color': #{$command-divider-color},
82
+ 'command-empty-color': #{$command-empty-color},
83
+ 'command-empty-padding': #{$command-empty-padding},
84
+ 'command-dialog-width': #{$command-dialog-width},
85
+ 'command-dialog-offset': #{$command-dialog-offset},
86
+ 'command-dialog-shadow': #{$command-dialog-shadow},
87
+ )
88
+ );
89
+ }
90
+
91
+ .#{iv.$class-prefix}command {
92
+ display: flex;
93
+ flex-direction: column;
94
+ gap: cv.getVar('command-gap');
95
+ padding: cv.getVar('command-padding');
96
+ background-color: cv.getVar('command-background');
97
+ border: 1px solid cv.getVar('command-border-color');
98
+ border-radius: cv.getVar('command-radius');
99
+ }
100
+
101
+ // The list's size, which its items, group headings and the empty message
102
+ // beside it take.
103
+ .#{iv.$class-prefix}command-list,
104
+ .#{iv.$class-prefix}command-empty {
105
+ font-size: cv.getVar('command-item-size');
106
+ }
107
+
108
+ .#{iv.$class-prefix}command-list {
109
+ max-height: cv.getVar('command-list-max-height');
110
+ overflow-y: auto;
111
+ overscroll-behavior: contain;
112
+ }
113
+
114
+ .#{iv.$class-prefix}command-item {
115
+ display: flex;
116
+ align-items: center;
117
+ gap: cv.getVar('command-item-gap');
118
+ padding: cv.getVar('command-item-padding-y')
119
+ cv.getVar('command-item-padding-x');
120
+ border-radius: cv.getVar('command-item-radius');
121
+ color: cv.getVar('command-item-color');
122
+ cursor: pointer;
123
+
124
+ // Where the pointer is while the highlight is somewhere else, as when the
125
+ // list scrolls under a pointer that hasn't moved.
126
+ &:hover:not(.#{iv.$class-prefix}is-active):not(
127
+ .#{iv.$class-prefix}is-disabled
128
+ ) {
129
+ background-color: cv.getVar('command-item-hover-background');
130
+ }
131
+
132
+ &.#{iv.$class-prefix}is-active {
133
+ background-color: cv.getVar('command-highlight-background');
134
+ color: cv.getVar('command-highlight-color');
135
+ }
136
+
137
+ &.#{iv.$class-prefix}is-disabled {
138
+ color: cv.getVar('command-disabled-color');
139
+ cursor: not-allowed;
140
+ }
141
+
142
+ // The arrows reach a disabled item, so it shows where they are, without
143
+ // the look of something Enter would run.
144
+ &.#{iv.$class-prefix}is-active.#{iv.$class-prefix}is-disabled {
145
+ background-color: cv.getVar('command-item-hover-background');
146
+ color: cv.getVar('command-disabled-color');
147
+ }
148
+ }
149
+
150
+ .#{iv.$class-prefix}command-item-icon {
151
+ display: inline-flex;
152
+ flex: none;
153
+ align-items: center;
154
+ justify-content: center;
155
+ color: cv.getVar('command-icon-color');
156
+ }
157
+
158
+ // The label over its description, taking the room the icon and hint leave.
159
+ .#{iv.$class-prefix}command-item-body {
160
+ display: flex;
161
+ flex: 1 1 auto;
162
+ flex-direction: column;
163
+ min-width: 0;
164
+ }
165
+
166
+ .#{iv.$class-prefix}command-item-description {
167
+ color: cv.getVar('command-description-color');
168
+ font-size: cv.getVar('command-description-size');
169
+ }
170
+
171
+ .#{iv.$class-prefix}command-item-hint {
172
+ display: inline-flex;
173
+ flex: none;
174
+ align-items: center;
175
+ margin-inline-start: auto;
176
+ color: cv.getVar('command-hint-color');
177
+ }
178
+
179
+ // On the highlight, and on a disabled item, the quieter parts take the item's
180
+ // own color, which is the one that reads against its background.
181
+ .#{iv.$class-prefix}command-item.#{iv.$class-prefix}is-active,
182
+ .#{iv.$class-prefix}command-item.#{iv.$class-prefix}is-disabled {
183
+ .#{iv.$class-prefix}command-item-icon,
184
+ .#{iv.$class-prefix}command-item-description,
185
+ .#{iv.$class-prefix}command-item-hint {
186
+ color: inherit;
187
+ }
188
+ }
189
+
190
+ // A line between a group and whatever comes before it, and between a group
191
+ // and items with no group after it, which would otherwise read as the group's
192
+ // last items. The line is the group's own edge rather than the item's, so it
193
+ // stays straight beside a rounded, highlighted item, and it's a border, which
194
+ // forced colors keeps.
195
+ .#{iv.$class-prefix}command-group:not(:first-child) {
196
+ border-top: 1px solid cv.getVar('command-divider-color');
197
+ margin-top: cv.getVar('command-item-padding-y');
198
+ padding-top: cv.getVar('command-item-padding-y');
199
+ }
200
+
201
+ .#{iv.$class-prefix}command-group:has(
202
+ + :not(.#{iv.$class-prefix}command-group)
203
+ ) {
204
+ border-bottom: 1px solid cv.getVar('command-divider-color');
205
+ margin-bottom: cv.getVar('command-item-padding-y');
206
+ padding-bottom: cv.getVar('command-item-padding-y');
207
+ }
208
+
209
+ .#{iv.$class-prefix}command-group-label {
210
+ padding: 0.25em cv.getVar('command-item-padding-x');
211
+ // In em of the list's size, so it follows the Command's.
212
+ font-size: cv.getVar('command-group-label-size');
213
+ color: cv.getVar('command-group-label-color');
214
+ font-weight: cv.getVar('command-group-label-weight');
215
+ }
216
+
217
+ .#{iv.$class-prefix}command-empty {
218
+ padding: cv.getVar('command-empty-padding')
219
+ cv.getVar('command-item-padding-x');
220
+ color: cv.getVar('command-empty-color');
221
+ text-align: center;
222
+ }
223
+
224
+ // In Bulma's `.modal`, a column that centers its content: the box keeps to
225
+ // the top, with the room under it left over, and above the background, which
226
+ // is positioned. Its list takes what height is left, so a short window
227
+ // scrolls the list rather than the page.
228
+ .#{iv.$class-prefix}command.#{iv.$class-prefix}command-dialog {
229
+ position: relative;
230
+ width: calc(100% - 2rem);
231
+ max-width: cv.getVar('command-dialog-width');
232
+ max-height: calc(100% - 2 * #{cv.getVar('command-dialog-offset')});
233
+ margin-top: cv.getVar('command-dialog-offset');
234
+ margin-bottom: auto;
235
+ box-shadow: cv.getVar('command-dialog-shadow');
236
+
237
+ > .#{iv.$class-prefix}command-list {
238
+ flex: 1 1 auto;
239
+ min-height: 0;
240
+ }
241
+ }
242
+
243
+ // Windows high contrast replaces the highlight's fill with the page's, so
244
+ // the highlight is drawn as an outline in the system's highlight color, and
245
+ // a disabled item takes the system's color for disabled text.
246
+ @media (forced-colors: active) {
247
+ .#{iv.$class-prefix}command-item {
248
+ &.#{iv.$class-prefix}is-active {
249
+ outline: 2px solid Highlight;
250
+ outline-offset: -2px;
251
+ }
252
+
253
+ // The highlighted one too, which the rule for it would otherwise outrank.
254
+ &.#{iv.$class-prefix}is-disabled,
255
+ &.#{iv.$class-prefix}is-active.#{iv.$class-prefix}is-disabled {
256
+ color: GrayText;
257
+ }
258
+ }
259
+ }
@@ -23,3 +23,4 @@
23
23
  @use 'timeline';
24
24
  @use 'treeview';
25
25
  @use 'scrollarea';
26
+ @use 'command';
@@ -4,6 +4,13 @@
4
4
 
5
5
  @use "bulma/sass/utilities/initial-variables" as iv;
6
6
  @use "bulma/sass/utilities/css-variables" as cv;
7
+ @use "bulma/sass/utilities/mixins" as mx;
8
+
9
+ // Bulma's horizontal field: `.field-label` takes one part of the row and
10
+ // `.field-body` five, after the label's `margin-inline-end`. Private, since
11
+ // they restate Bulma's layout rather than set a look of their own.
12
+ $-field-label-gap: 1.5rem;
13
+ $-field-label-parts: 6;
7
14
 
8
15
  // Checkbox-specific SCSS variables
9
16
  $checkbox-size: 1.25em !default;
@@ -249,3 +256,40 @@ $-check-mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'
249
256
  }
250
257
  }
251
258
  }
259
+
260
+ // `<Checkboxes as="fieldset">` renders a native fieldset: the group's own
261
+ // `.field`, with its label as the legend, or the `.checkboxes` box itself inside
262
+ // an outer `Field`. Bulma resets a fieldset's margin, border and padding but
263
+ // keeps the browser's `min-inline-size: min-content`, which lets a long row
264
+ // of choices push it out of its column.
265
+ fieldset.#{iv.$class-prefix}checkboxes,
266
+ fieldset.#{iv.$class-prefix}field:has(.#{iv.$class-prefix}checkboxes) {
267
+ min-inline-size: 0;
268
+ }
269
+
270
+ // Horizontal, the legend is the label column. The browser draws a
271
+ // fieldset's legend above the content rather than beside it. A floated
272
+ // legend escapes that, though not in a flex fieldset in every engine, so the
273
+ // fieldset is a block here and the legend floats, taking the share of the
274
+ // row Bulma's `.field-label` takes beside `.field-body` (one part in six of
275
+ // what's left after its margin), and growing as that does for a word too
276
+ // long to wrap. `.field-body`, a flex box, sits beside it. Below tablet the
277
+ // row stacks, and the legend sits on top as it is. It applies only where the
278
+ // fieldset's own legend is the label column and the body after it holds the
279
+ // group, so a fieldset you lay out with a `div.field-label` keeps Bulma's
280
+ // flex row whatever its body holds.
281
+ @include mx.tablet {
282
+ fieldset.#{iv.$class-prefix}field.#{iv.$class-prefix}is-horizontal:has(
283
+ > legend.#{iv.$class-prefix}field-label
284
+ + .#{iv.$class-prefix}field-body
285
+ .#{iv.$class-prefix}checkboxes
286
+ ) {
287
+ display: flow-root;
288
+
289
+ > legend.#{iv.$class-prefix}field-label {
290
+ float: inline-start;
291
+ inline-size: calc((100% - #{$-field-label-gap}) / #{$-field-label-parts});
292
+ min-inline-size: min-content;
293
+ }
294
+ }
295
+ }
@@ -0,0 +1,355 @@
1
+ // CheckboxCard styles
2
+ // A checkbox drawn as a card: a <label class="checkbox-card card"> holding the
3
+ // native input, then a .card-content span with the indicator and the text.
4
+ // Bulma's .card draws the surface. This partial adds the card's edge, which
5
+ // carries the checked state, the focus outline and the indicator.
6
+ //
7
+ // The edge is a pseudo-element of the content span, laid over the whole card,
8
+ // rather than a border on the label. The input comes before the content span,
9
+ // so `input:checked + …` reaches it without :has(), and a thicker edge when
10
+ // checked moves nothing inside the card. It's a real border, since Bulma's
11
+ // card draws its own edge with a box-shadow, which forced colors drops.
12
+
13
+ @use 'bulma/sass/utilities/initial-variables' as iv;
14
+ @use 'bulma/sass/utilities/css-variables' as cv;
15
+
16
+ $checkbox-card-border-width: 1px !default;
17
+ $checkbox-card-border-color: cv.getVar('border') !default;
18
+ $checkbox-card-hover-border-color: cv.getVar('border-hover') !default;
19
+ // Twice the edge, so a checked card differs from an unchecked one by more
20
+ // than its color (WCAG 1.4.1), with or without the indicator.
21
+ $checkbox-card-checked-border-width: 2px !default;
22
+ $checkbox-card-active-color: cv.getVar('primary') !default;
23
+ // Bulma's focus color and width, which every color of card shares, since
24
+ // some of the six fall short of 3:1 on a light page.
25
+ $checkbox-card-focus-color: hsl(
26
+ cv.getVar('focus-h'),
27
+ cv.getVar('focus-s'),
28
+ cv.getVar('focus-l')
29
+ ) !default;
30
+ $checkbox-card-focus-width: cv.getVar('focus-width') !default;
31
+ $checkbox-card-focus-offset: 2px !default;
32
+ $checkbox-card-gap: 0.75em !default;
33
+ $checkbox-card-min-width: 12rem !default;
34
+ $checkbox-card-title-weight: cv.getVar('weight-semibold') !default;
35
+ $checkbox-card-description-color: cv.getVar('text-weak') !default;
36
+ $checkbox-card-indicator-size: 1.25em !default;
37
+ $checkbox-card-indicator-border-width: 2px !default;
38
+ // The indicator's border is all that shows of an unchecked box, so it takes
39
+ // `text-weak`, as Checkbox's does, which holds 3:1 on the card's surface.
40
+ $checkbox-card-indicator-border-color: cv.getVar('text-weak') !default;
41
+ $checkbox-card-indicator-radius: cv.getVar('radius-small') !default;
42
+ $checkbox-card-check-color: cv.getVar('scheme-invert') !default;
43
+ $checkbox-card-disabled-opacity: 0.5 !default;
44
+ $checkbox-card-transition-duration: cv.getVar('duration') !default;
45
+
46
+ // The text's line height, which also places the indicator: it's centred on
47
+ // the title's first line while it's shorter than that line.
48
+ $-line-height: 1.5;
49
+
50
+ // The check mark's shape, used as a mask so it's painted with a background
51
+ // color: `checkbox-card-check-color`, or a system color in forced colors.
52
+ $-check-mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");
53
+
54
+ .#{iv.$class-prefix}checkbox-card {
55
+ @include cv.register-vars(
56
+ (
57
+ 'checkbox-card-border-width': #{$checkbox-card-border-width},
58
+ 'checkbox-card-border-color': #{$checkbox-card-border-color},
59
+ 'checkbox-card-hover-border-color': #{$checkbox-card-hover-border-color},
60
+ 'checkbox-card-checked-border-width':
61
+ #{$checkbox-card-checked-border-width},
62
+ 'checkbox-card-active-color': #{$checkbox-card-active-color},
63
+ 'checkbox-card-focus-color': #{$checkbox-card-focus-color},
64
+ 'checkbox-card-focus-width': #{$checkbox-card-focus-width},
65
+ 'checkbox-card-focus-offset': #{$checkbox-card-focus-offset},
66
+ 'checkbox-card-gap': #{$checkbox-card-gap},
67
+ 'checkbox-card-min-width': #{$checkbox-card-min-width},
68
+ 'checkbox-card-title-weight': #{$checkbox-card-title-weight},
69
+ 'checkbox-card-description-color': #{$checkbox-card-description-color},
70
+ 'checkbox-card-indicator-size': #{$checkbox-card-indicator-size},
71
+ 'checkbox-card-indicator-border-width':
72
+ #{$checkbox-card-indicator-border-width},
73
+ 'checkbox-card-indicator-border-color':
74
+ #{$checkbox-card-indicator-border-color},
75
+ 'checkbox-card-indicator-radius': #{$checkbox-card-indicator-radius},
76
+ 'checkbox-card-check-color': #{$checkbox-card-check-color},
77
+ 'checkbox-card-disabled-opacity': #{$checkbox-card-disabled-opacity},
78
+ 'checkbox-card-transition-duration': #{$checkbox-card-transition-duration},
79
+ )
80
+ );
81
+ }
82
+
83
+ .#{iv.$class-prefix}checkbox-card {
84
+ display: block;
85
+ position: relative;
86
+ cursor: pointer;
87
+
88
+ // The native input, hidden the way Checkbox hides it. It still takes focus
89
+ // and clicks through the label.
90
+ > input[type='checkbox'] {
91
+ position: absolute;
92
+ opacity: 0;
93
+ width: 0;
94
+ height: 0;
95
+ margin: 0;
96
+ }
97
+
98
+ // The edge, laid over the whole card.
99
+ > .#{iv.$class-prefix}checkbox-card-content::before {
100
+ content: '';
101
+ position: absolute;
102
+ inset: 0;
103
+ border: cv.getVar('checkbox-card-border-width') solid
104
+ cv.getVar('checkbox-card-border-color');
105
+ border-radius: cv.getVar('card-radius');
106
+ pointer-events: none;
107
+ transition-property: border-color, border-width;
108
+ transition-duration: cv.getVar('checkbox-card-transition-duration');
109
+ transition-timing-function: ease;
110
+ }
111
+
112
+ &:hover
113
+ > input[type='checkbox']:enabled:not(:checked, :indeterminate)
114
+ + .#{iv.$class-prefix}checkbox-card-content::before {
115
+ border-color: cv.getVar('checkbox-card-hover-border-color');
116
+ }
117
+
118
+ > input[type='checkbox']:checked
119
+ + .#{iv.$class-prefix}checkbox-card-content::before,
120
+ > input[type='checkbox']:indeterminate
121
+ + .#{iv.$class-prefix}checkbox-card-content::before {
122
+ border-color: cv.getVar('checkbox-card-active-color');
123
+ border-width: cv.getVar('checkbox-card-checked-border-width');
124
+ }
125
+
126
+ // Keyboard focus: an outline around the whole card.
127
+ > input[type='checkbox']:focus-visible
128
+ + .#{iv.$class-prefix}checkbox-card-content::before {
129
+ outline: cv.getVar('checkbox-card-focus-width') solid
130
+ cv.getVar('checkbox-card-focus-color');
131
+ outline-offset: cv.getVar('checkbox-card-focus-offset');
132
+ }
133
+
134
+ > input[type='checkbox']:disabled
135
+ + .#{iv.$class-prefix}checkbox-card-content {
136
+ opacity: cv.getVar('checkbox-card-disabled-opacity');
137
+ cursor: not-allowed;
138
+ }
139
+
140
+ // The indicator follows the input's state, as Checkbox's box does.
141
+ > input[type='checkbox']:checked
142
+ + .#{iv.$class-prefix}checkbox-card-content
143
+ > .#{iv.$class-prefix}checkbox-card-check {
144
+ background-color: cv.getVar('checkbox-card-active-color');
145
+ border-color: cv.getVar('checkbox-card-active-color');
146
+
147
+ &::after {
148
+ opacity: 1;
149
+ transform: scale(1);
150
+ }
151
+ }
152
+
153
+ > input[type='checkbox']:indeterminate
154
+ + .#{iv.$class-prefix}checkbox-card-content
155
+ > .#{iv.$class-prefix}checkbox-card-check {
156
+ background-color: cv.getVar('checkbox-card-active-color');
157
+ border-color: cv.getVar('checkbox-card-active-color');
158
+
159
+ &::after {
160
+ opacity: 0;
161
+ }
162
+
163
+ &::before {
164
+ content: '';
165
+ position: absolute;
166
+ top: 50%;
167
+ left: 50%;
168
+ transform: translate(-50%, -50%);
169
+ width: 60%;
170
+ height: cv.getVar('checkbox-card-indicator-border-width');
171
+ background-color: cv.getVar('checkbox-card-check-color');
172
+ border-radius: 1px;
173
+ }
174
+ }
175
+ }
176
+
177
+ // The content fills the card, the indicator beside the text. Bulma rounds a
178
+ // `.card-content` only as the card's first or last child, and the input comes
179
+ // first here, so the content takes the card's corners itself, or a themed
180
+ // `--bulma-card-content-background-color` would show square ones.
181
+ .#{iv.$class-prefix}checkbox-card-content {
182
+ display: flex;
183
+ align-items: flex-start;
184
+ gap: cv.getVar('checkbox-card-gap');
185
+ border-radius: inherit;
186
+ }
187
+
188
+ .#{iv.$class-prefix}checkbox-card-check {
189
+ display: inline-flex;
190
+ align-items: center;
191
+ justify-content: center;
192
+ flex-shrink: 0;
193
+ position: relative;
194
+ // Checkbox and Radio hold their box to 24px, the minimum target size. Here
195
+ // the whole card is the target, so the indicator has no floor and follows
196
+ // its size variable and the card's text size.
197
+ width: cv.getVar('checkbox-card-indicator-size');
198
+ height: cv.getVar('checkbox-card-indicator-size');
199
+ margin-top: max(
200
+ 0px,
201
+ calc(
202
+ (#{$-line-height}em - #{cv.getVar('checkbox-card-indicator-size')}) / 2
203
+ )
204
+ );
205
+ border: cv.getVar('checkbox-card-indicator-border-width') solid
206
+ cv.getVar('checkbox-card-indicator-border-color');
207
+ border-radius: cv.getVar('checkbox-card-indicator-radius');
208
+ transition-property: background-color, border-color;
209
+ transition-duration: cv.getVar('checkbox-card-transition-duration');
210
+ transition-timing-function: ease;
211
+
212
+ // The check mark: the mask cuts the shape, the background color paints it.
213
+ &::after {
214
+ content: '';
215
+ position: absolute;
216
+ width: 85%;
217
+ height: 85%;
218
+ opacity: 0;
219
+ transform: scale(0.5);
220
+ transition-property: opacity, transform;
221
+ transition-duration: cv.getVar('checkbox-card-transition-duration');
222
+ transition-timing-function: ease;
223
+ background-color: cv.getVar('checkbox-card-check-color');
224
+ -webkit-mask-image: $-check-mark;
225
+ -webkit-mask-size: contain;
226
+ -webkit-mask-repeat: no-repeat;
227
+ -webkit-mask-position: center;
228
+ mask-image: $-check-mark;
229
+ mask-size: contain;
230
+ mask-repeat: no-repeat;
231
+ mask-position: center;
232
+ }
233
+ }
234
+
235
+ // Block spans, since a label holds phrasing content only.
236
+ .#{iv.$class-prefix}checkbox-card-body {
237
+ display: block;
238
+ flex: 1 1 auto;
239
+ min-width: 0;
240
+ line-height: $-line-height;
241
+ }
242
+
243
+ // The title takes the card's own text color, so `textColor` reaches it too.
244
+ .#{iv.$class-prefix}checkbox-card-title {
245
+ display: block;
246
+ font-weight: cv.getVar('checkbox-card-title-weight');
247
+ }
248
+
249
+ .#{iv.$class-prefix}checkbox-card-description {
250
+ display: block;
251
+ color: cv.getVar('checkbox-card-description-color');
252
+ }
253
+
254
+ // Color variants
255
+ @each $name in 'primary', 'link', 'info', 'success', 'warning', 'danger' {
256
+ .#{iv.$class-prefix}checkbox-card.#{iv.$class-prefix}is-#{$name} {
257
+ @include cv.register-vars(
258
+ (
259
+ 'checkbox-card-active-color': #{cv.getVar($name)},
260
+ )
261
+ );
262
+ }
263
+ }
264
+
265
+ // In a Checkboxes group, a wrapping row: the cards share it equally and wrap
266
+ // before they get narrower than the minimum width.
267
+ .#{iv.$class-prefix}checkboxes
268
+ > .#{iv.$class-prefix}checkbox-card.#{iv.$class-prefix}card {
269
+ flex: 1 1 0;
270
+ min-width: min(100%, #{cv.getVar('checkbox-card-min-width')});
271
+ }
272
+
273
+ // The group's gap, or a Bulma grid's, spaces the cards, so Bulma's margin
274
+ // under a card goes, or the last card would stand taller than the rest.
275
+ .#{iv.$class-prefix}checkboxes,
276
+ .#{iv.$class-prefix}grid {
277
+ > .#{iv.$class-prefix}checkbox-card.#{iv.$class-prefix}card {
278
+ margin-bottom: 0;
279
+ }
280
+ }
281
+
282
+ // Forced colors repaints the edge in the text color and drops Bulma's
283
+ // shadow, so a checked card names Highlight on an edge that stays thicker.
284
+ @media (forced-colors: active) {
285
+ .#{iv.$class-prefix}checkbox-card {
286
+ > .#{iv.$class-prefix}checkbox-card-content::before {
287
+ border-color: CanvasText;
288
+ }
289
+
290
+ > input[type='checkbox']:checked
291
+ + .#{iv.$class-prefix}checkbox-card-content::before,
292
+ > input[type='checkbox']:indeterminate
293
+ + .#{iv.$class-prefix}checkbox-card-content::before {
294
+ border-color: Highlight;
295
+ }
296
+
297
+ > input[type='checkbox']:focus-visible
298
+ + .#{iv.$class-prefix}checkbox-card-content::before {
299
+ outline-color: Highlight;
300
+ }
301
+
302
+ > input[type='checkbox']:disabled
303
+ + .#{iv.$class-prefix}checkbox-card-content {
304
+ color: GrayText;
305
+
306
+ &::before {
307
+ border-color: GrayText;
308
+ }
309
+ }
310
+
311
+ .#{iv.$class-prefix}checkbox-card-check {
312
+ border-color: ButtonText;
313
+ }
314
+
315
+ > input[type='checkbox']:checked
316
+ + .#{iv.$class-prefix}checkbox-card-content
317
+ > .#{iv.$class-prefix}checkbox-card-check {
318
+ background-color: Highlight;
319
+ border-color: Highlight;
320
+
321
+ &::after {
322
+ background-color: HighlightText;
323
+ }
324
+ }
325
+
326
+ // A mixed fill and its dash would be repainted in one color, leaving an
327
+ // empty box, so the dash takes a color of its own.
328
+ > input[type='checkbox']:indeterminate
329
+ + .#{iv.$class-prefix}checkbox-card-content
330
+ > .#{iv.$class-prefix}checkbox-card-check {
331
+ background-color: Canvas;
332
+ border-color: Highlight;
333
+
334
+ &::before {
335
+ background-color: CanvasText;
336
+ }
337
+ }
338
+
339
+ > input[type='checkbox']:disabled
340
+ + .#{iv.$class-prefix}checkbox-card-content
341
+ > .#{iv.$class-prefix}checkbox-card-check {
342
+ border-color: GrayText;
343
+ }
344
+ }
345
+ }
346
+
347
+ @media (prefers-reduced-motion: reduce) {
348
+ .#{iv.$class-prefix}checkbox-card {
349
+ > .#{iv.$class-prefix}checkbox-card-content::before,
350
+ .#{iv.$class-prefix}checkbox-card-check,
351
+ .#{iv.$class-prefix}checkbox-card-check::after {
352
+ transition: none;
353
+ }
354
+ }
355
+ }