@helsenorge/designsystem-react 14.10.0 → 14.11.1

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 (152) hide show
  1. package/lib/BabyMobileMedium.js +1 -1
  2. package/lib/CHANGELOG.md +16 -0
  3. package/lib/Checkbox.js +25 -48
  4. package/lib/Checkbox.js.map +1 -1
  5. package/lib/CheckboxMarker.js +60 -0
  6. package/lib/CheckboxMarker.js.map +1 -0
  7. package/lib/ChildMedium.js +1 -1
  8. package/lib/EyeContactMedium.js +79 -0
  9. package/lib/EyeContactMedium.js.map +1 -0
  10. package/lib/FacialRecognitionFingerprintMedium.js +1 -1
  11. package/lib/Filter.js +12 -12
  12. package/lib/Filter.js.map +1 -1
  13. package/lib/FormGroup.js +5 -5
  14. package/lib/FormGroup.js.map +1 -1
  15. package/lib/GiveBabyFoodMedium.js +1 -1
  16. package/lib/Illustration.js +1 -1
  17. package/lib/IllustrationNames.js +4 -0
  18. package/lib/IllustrationNames.js.map +1 -1
  19. package/lib/LazyIllustration.js +5 -1
  20. package/lib/LazyIllustration.js.map +1 -1
  21. package/lib/Radio.js +73 -0
  22. package/lib/Radio.js.map +1 -0
  23. package/lib/RadioButton.js +81 -3
  24. package/lib/RadioButton.js.map +1 -1
  25. package/lib/RadioButton2.js +3 -73
  26. package/lib/RadioButton2.js.map +1 -1
  27. package/lib/RadioMarker.js +31 -0
  28. package/lib/RadioMarker.js.map +1 -0
  29. package/lib/ReadLettersMedium.js +1 -1
  30. package/lib/Search.js +4 -4
  31. package/lib/Search.js.map +1 -1
  32. package/lib/SkinToSkinMedium.js +106 -0
  33. package/lib/SkinToSkinMedium.js.map +1 -0
  34. package/lib/StorkMedium.js +1 -1
  35. package/lib/StrollerMedium.js +1 -1
  36. package/lib/Support2Medium.js +1 -1
  37. package/lib/TableBody.js +1 -1
  38. package/lib/TableHead.js +1 -1
  39. package/lib/TableRow.js +1 -1
  40. package/lib/ThinkingMedium.js +1 -1
  41. package/lib/VisualCheckbox.js +77 -0
  42. package/lib/VisualCheckbox.js.map +1 -0
  43. package/lib/VisualRadio.js +62 -0
  44. package/lib/VisualRadio.js.map +1 -0
  45. package/lib/__mocks__/matchMedia.js +3 -2
  46. package/lib/__mocks__/matchMedia.js.map +1 -1
  47. package/lib/components/Checkbox/CheckboxMarker/CheckboxMarker.d.ts +20 -0
  48. package/lib/components/Checkbox/CheckboxMarker/styles.module.scss +309 -0
  49. package/lib/components/Checkbox/CheckboxMarker/styles.module.scss.d.ts +25 -0
  50. package/lib/components/Checkbox/styles.module.scss +9 -269
  51. package/lib/components/Checkbox/styles.module.scss.d.ts +1 -17
  52. package/lib/components/Icons/Sort.js +12 -12
  53. package/lib/components/Icons/Sort.js.map +1 -1
  54. package/lib/components/Illustration/index.js +1 -1
  55. package/lib/components/Illustrations/BabyMobile.js +1 -1
  56. package/lib/components/Illustrations/Child.js +1 -1
  57. package/lib/components/Illustrations/Doctor.js +1 -1
  58. package/lib/components/Illustrations/EyeContact.d.ts +8 -0
  59. package/lib/components/Illustrations/EyeContact.js +16 -0
  60. package/lib/components/Illustrations/EyeContact.js.map +1 -0
  61. package/lib/components/Illustrations/EyeContactMedium.d.ts +3 -0
  62. package/lib/components/Illustrations/EyeContactMedium.js +2 -0
  63. package/lib/components/Illustrations/FacialRecognitionFingerprint.js +1 -1
  64. package/lib/components/Illustrations/GiveBabyFood.js +1 -1
  65. package/lib/components/Illustrations/HealthcarePersonnel.js +1 -1
  66. package/lib/components/Illustrations/IllustrationNames.d.ts +1 -1
  67. package/lib/components/Illustrations/ReadLetters.js +1 -1
  68. package/lib/components/Illustrations/SkinToSkin.d.ts +8 -0
  69. package/lib/components/Illustrations/SkinToSkin.js +16 -0
  70. package/lib/components/Illustrations/SkinToSkin.js.map +1 -0
  71. package/lib/components/Illustrations/SkinToSkinMedium.d.ts +3 -0
  72. package/lib/components/Illustrations/SkinToSkinMedium.js +2 -0
  73. package/lib/components/Illustrations/Stork.js +1 -1
  74. package/lib/components/Illustrations/Stroller.js +1 -1
  75. package/lib/components/Illustrations/Support2.js +1 -1
  76. package/lib/components/Illustrations/Thinking.js +1 -1
  77. package/lib/components/Panel/index.js +1 -1
  78. package/lib/components/PanelList/index.js +1 -1
  79. package/lib/components/RadioButton/RadioMarker/RadioMarker.d.ts +20 -0
  80. package/lib/components/RadioButton/RadioMarker/styles.module.scss +288 -0
  81. package/lib/components/RadioButton/RadioMarker/styles.module.scss.d.ts +20 -0
  82. package/lib/components/RadioButton/index.d.ts +0 -1
  83. package/lib/components/RadioButton/index.js +3 -3
  84. package/lib/components/RadioButton/styles.module.scss +13 -275
  85. package/lib/components/RadioButton/styles.module.scss.d.ts +2 -12
  86. package/lib/components/Table/index.js +1 -1
  87. package/lib/components/Validation/index.js +1 -1
  88. package/lib/components/VisualCheckboxCloud/Checkbox/styles.module.scss +5 -128
  89. package/lib/components/VisualCheckboxCloud/styles.module.scss +2 -9
  90. package/lib/components/VisualCheckboxGroup/VisualCheckbox/VisualCheckbox.d.ts +26 -0
  91. package/lib/components/VisualCheckboxGroup/VisualCheckbox/VisualContent.d.ts +10 -0
  92. package/lib/components/VisualCheckboxGroup/VisualCheckbox/index.d.ts +3 -0
  93. package/lib/components/VisualCheckboxGroup/VisualCheckbox/index.js +5 -0
  94. package/lib/components/VisualCheckboxGroup/VisualCheckbox/index.js.map +1 -0
  95. package/lib/components/VisualCheckboxGroup/VisualCheckbox/styles.module.scss +7 -0
  96. package/lib/components/VisualCheckboxGroup/VisualCheckbox/styles.module.scss.d.ts +18 -0
  97. package/lib/components/VisualCheckboxGroup/VisualCheckboxGroup.d.ts +33 -0
  98. package/lib/components/VisualCheckboxGroup/index.d.ts +3 -0
  99. package/lib/components/VisualCheckboxGroup/index.js +43 -0
  100. package/lib/components/VisualCheckboxGroup/index.js.map +1 -0
  101. package/lib/components/VisualCheckboxGroup/styles.module.scss +6 -0
  102. package/lib/components/VisualCheckboxGroup/styles.module.scss.d.ts +10 -0
  103. package/lib/components/{VisualRadioButtonCloud/RadioButton/RadioButton.d.ts → VisualRadioCloud/Radio/Radio.d.ts} +3 -3
  104. package/lib/components/VisualRadioCloud/Radio/index.d.ts +3 -0
  105. package/lib/components/VisualRadioCloud/Radio/index.js +5 -0
  106. package/lib/components/VisualRadioCloud/Radio/index.js.map +1 -0
  107. package/lib/components/VisualRadioCloud/Radio/styles.module.scss +7 -0
  108. package/lib/components/VisualRadioCloud/Radio/styles.module.scss.d.ts +15 -0
  109. package/lib/components/{VisualRadioButtonCloud/VisualRadioButtonCloud.d.ts → VisualRadioCloud/VisualRadioCloud.d.ts} +8 -8
  110. package/lib/components/VisualRadioCloud/index.d.ts +3 -0
  111. package/lib/components/{VisualRadioButtonCloud → VisualRadioCloud}/index.js +7 -7
  112. package/lib/components/VisualRadioCloud/index.js.map +1 -0
  113. package/lib/components/VisualRadioCloud/styles.module.scss +6 -0
  114. package/lib/components/{VisualRadioButtonCloud → VisualRadioCloud}/styles.module.scss.d.ts +1 -1
  115. package/lib/components/VisualRadioGroup/VisualRadio/VisualContent.d.ts +10 -0
  116. package/lib/components/VisualRadioGroup/VisualRadio/VisualRadio.d.ts +26 -0
  117. package/lib/components/VisualRadioGroup/VisualRadio/index.d.ts +3 -0
  118. package/lib/components/VisualRadioGroup/VisualRadio/index.js +5 -0
  119. package/lib/components/VisualRadioGroup/VisualRadio/index.js.map +1 -0
  120. package/lib/components/VisualRadioGroup/VisualRadio/styles.module.scss +7 -0
  121. package/lib/components/VisualRadioGroup/VisualRadio/styles.module.scss.d.ts +18 -0
  122. package/lib/components/VisualRadioGroup/VisualRadioGroup.d.ts +39 -0
  123. package/lib/components/VisualRadioGroup/index.d.ts +3 -0
  124. package/lib/components/VisualRadioGroup/index.js +63 -0
  125. package/lib/components/VisualRadioGroup/index.js.map +1 -0
  126. package/lib/components/VisualRadioGroup/styles.module.scss +6 -0
  127. package/lib/components/VisualRadioGroup/styles.module.scss.d.ts +10 -0
  128. package/lib/resourceHelper.js +10 -6
  129. package/lib/resourceHelper.js.map +1 -1
  130. package/lib/resources/HN.Designsystem.Filter.en-GB.json.d.ts +5 -3
  131. package/lib/resources/HN.Designsystem.Filter.nb-NO.json.d.ts +5 -3
  132. package/lib/resources/Resources.d.ts +10 -2
  133. package/lib/scss/_visual-form.scss +357 -0
  134. package/lib/utils3.js +10 -98
  135. package/lib/utils3.js.map +1 -1
  136. package/lib/utils4.js +28 -11
  137. package/lib/utils4.js.map +1 -1
  138. package/lib/utils5.js +58 -28
  139. package/lib/utils5.js.map +1 -1
  140. package/package.json +115 -1
  141. package/scss/_visual-form.scss +357 -0
  142. package/lib/components/RadioButton/utils.d.ts +0 -2
  143. package/lib/components/VisualRadioButtonCloud/RadioButton/index.d.ts +0 -3
  144. package/lib/components/VisualRadioButtonCloud/RadioButton/index.js +0 -5
  145. package/lib/components/VisualRadioButtonCloud/RadioButton/index.js.map +0 -1
  146. package/lib/components/VisualRadioButtonCloud/RadioButton/styles.module.scss +0 -133
  147. package/lib/components/VisualRadioButtonCloud/RadioButton/styles.module.scss.d.ts +0 -15
  148. package/lib/components/VisualRadioButtonCloud/index.d.ts +0 -3
  149. package/lib/components/VisualRadioButtonCloud/index.js.map +0 -1
  150. package/lib/components/VisualRadioButtonCloud/styles.module.scss +0 -13
  151. package/lib/utils6.js +0 -60
  152. package/lib/utils6.js.map +0 -1
@@ -0,0 +1,357 @@
1
+ @use 'sass:map';
2
+ @use 'breakpoints' as breakpoints;
3
+ @use 'font-mixins' as fonts;
4
+
5
+ // Wrapper layout shared by VisualCheckboxCloud and VisualRadioCloud
6
+ @mixin visual-form-cloud {
7
+ display: flex;
8
+ flex-flow: row wrap;
9
+ gap: var(--core-space-4xs) var(--core-space-xs);
10
+
11
+ @media (min-width: map.get(breakpoints.$grid-breakpoints, md)) {
12
+ gap: var(--core-space-m) var(--core-space-s);
13
+ }
14
+ }
15
+
16
+ // Pill-style input shared by VisualCheckboxCloud/Checkbox and VisualRadioCloud/Radio
17
+ @mixin visual-form-pill(
18
+ $pill-padding-mobile: var(--core-space-3xs) var(--core-space-m),
19
+ $checked-pill-padding-md: var(--core-space-3xs) var(--core-space-m) var(--core-space-3xs) 1.25rem
20
+ ) {
21
+ position: relative;
22
+ display: inline-flex;
23
+ align-items: stretch;
24
+ min-height: 2.75rem;
25
+ padding: 0.313rem 0;
26
+ cursor: pointer;
27
+
28
+ @media (min-width: map.get(breakpoints.$grid-breakpoints, md)) {
29
+ padding: 0;
30
+ }
31
+
32
+ &__input {
33
+ // Hides input while making sure screen reader outline wraps the entire component
34
+ cursor: pointer;
35
+ position: absolute;
36
+ z-index: 0;
37
+ inset: 0;
38
+ width: 100%;
39
+ height: 100%;
40
+ outline: none;
41
+ appearance: none;
42
+ }
43
+
44
+ &__pill {
45
+ position: relative;
46
+ z-index: 1;
47
+ display: inline-flex;
48
+ align-items: center;
49
+ gap: var(--core-space-2xs);
50
+ box-sizing: border-box;
51
+ min-height: var(--core-space-l);
52
+ padding: $pill-padding-mobile;
53
+ border-radius: 100px;
54
+ background-color: var(--color-action-background-ondark);
55
+ border: 1px solid var(--color-action-border-onlight);
56
+ color: var(--color-base-text-onlight);
57
+
58
+ @include fonts.title6;
59
+
60
+ @media (min-width: map.get(breakpoints.$grid-breakpoints, md)) {
61
+ min-height: var(--core-space-xl);
62
+ padding: var(--core-space-3xs) var(--core-space-l);
63
+ }
64
+ }
65
+
66
+ &:hover &__pill {
67
+ background-color: var(--color-action-background-ondark-hover);
68
+ border-color: var(--color-action-border-onlight-hover);
69
+ }
70
+
71
+ &:active &__pill {
72
+ background-color: var(--color-action-background-ondark-selected);
73
+ border-color: var(--color-action-border-onlight-hover);
74
+ }
75
+
76
+ &--checked &__pill,
77
+ &:has(input:checked) &__pill {
78
+ background-color: var(--color-action-background-onlight);
79
+ color: var(--color-action-text-ondark);
80
+ border-color: var(--color-action-background-onlight);
81
+ padding: var(--core-space-3xs) var(--core-space-s);
82
+
83
+ @media (min-width: map.get(breakpoints.$grid-breakpoints, md)) {
84
+ padding: $checked-pill-padding-md;
85
+ }
86
+ }
87
+
88
+ &--checked:hover &__pill,
89
+ &:has(input:checked):hover &__pill {
90
+ background-color: var(--color-action-graphics-onlight-hover);
91
+ border-color: var(--color-action-graphics-onlight-hover);
92
+ }
93
+
94
+ &--checked:active &__pill,
95
+ &:has(input:checked):active &__pill {
96
+ background-color: var(--color-action-background-onlight-active);
97
+ border-color: var(--color-action-background-onlight-active);
98
+ }
99
+
100
+ &--invalid &__pill {
101
+ background-color: var(--color-action-background-ondark);
102
+ border-color: var(--color-destructive-border-normal);
103
+ }
104
+
105
+ &--invalid:hover &__pill {
106
+ background-color: var(--color-destructive-background-normal);
107
+ border-color: var(--color-destructive-border-normal);
108
+ }
109
+
110
+ &--invalid:active &__pill {
111
+ background-color: var(--color-destructive-background-emphasized);
112
+ border-color: var(--color-destructive-border-normal);
113
+ }
114
+
115
+ &--invalid#{&}--checked &__pill,
116
+ &--invalid:has(input:checked) &__pill {
117
+ background-color: var(--color-destructive-graphics-normal);
118
+ border-color: var(--color-destructive-graphics-normal);
119
+ }
120
+
121
+ &--invalid#{&}--checked:hover &__pill,
122
+ &--invalid:has(input:checked):hover &__pill {
123
+ background-color: var(--color-destructive-graphics-hover);
124
+ border-color: var(--color-destructive-graphics-hover);
125
+ }
126
+
127
+ &--invalid#{&}--checked:active &__pill,
128
+ &--invalid:has(input:checked):active &__pill {
129
+ background-color: var(--color-destructive-graphics-emphasized-onlight);
130
+ border-color: var(--color-destructive-graphics-emphasized-onlight);
131
+ }
132
+
133
+ &__input:focus-visible + &__pill {
134
+ outline: 3px solid var(--color-action-border-onlight-focus);
135
+ border-color: var(--color-action-border-ondark);
136
+ }
137
+
138
+ &__icon {
139
+ display: inline-flex;
140
+ align-items: center;
141
+ justify-content: center;
142
+
143
+ svg {
144
+ fill: var(--color-action-graphics-ondark);
145
+ }
146
+ }
147
+
148
+ &__label {
149
+ text-box: trim-both cap alphabetic;
150
+ }
151
+ }
152
+
153
+ // Grid layout shared by VisualCheckboxGroup and VisualRadioGroup.
154
+ @mixin visual-form-group {
155
+ display: grid;
156
+ grid-template-columns: repeat(auto-fit, minmax(8.75rem, 1fr));
157
+ gap: var(--core-space-xs);
158
+
159
+ @media (min-width: map.get(breakpoints.$grid-breakpoints, md)) {
160
+ gap: 0.75rem var(--core-space-xs, 0.75rem);
161
+ }
162
+
163
+ &--variant-line {
164
+ grid-template-columns: 1fr;
165
+ }
166
+ }
167
+
168
+ // Styling shared by VisualCheckbox and VisualRadio
169
+ @mixin visual-form-card {
170
+ display: flex;
171
+ position: relative;
172
+ cursor: pointer;
173
+ width: 100%;
174
+
175
+ &--variant-line {
176
+ flex-direction: row;
177
+ justify-content: flex-start;
178
+ align-items: center;
179
+ min-height: 6rem;
180
+ min-width: 15.125rem;
181
+ }
182
+
183
+ &--variant-rectangle {
184
+ flex-direction: column;
185
+ align-items: center;
186
+ min-height: 12.625rem;
187
+ min-width: 8.75rem;
188
+ height: 100%;
189
+ }
190
+
191
+ &__input {
192
+ // Hides input while making sure screen reader outline wraps the entire component
193
+ cursor: pointer;
194
+ position: absolute;
195
+ z-index: 0;
196
+ inset: 0;
197
+ width: 100%;
198
+ height: 100%;
199
+ outline: none;
200
+ appearance: none;
201
+ }
202
+
203
+ &__frame {
204
+ position: relative;
205
+ width: 100%;
206
+ z-index: 1;
207
+ display: inline-flex;
208
+ border-radius: 4px;
209
+ background: var(--color-action-background-ondark);
210
+ border: 2px solid var(--color-action-border-onlight);
211
+ color: var(--color-base-text-onlight);
212
+ }
213
+
214
+ &--variant-line &__frame {
215
+ margin-left: -2.87rem;
216
+ gap: var(--core-space-2xs);
217
+ flex-direction: row;
218
+ justify-content: flex-end;
219
+ align-items: center;
220
+ min-height: 4.63rem;
221
+ min-width: 12.25rem;
222
+ padding: var(--core-space-s) var(--core-space-m) var(--core-space-s) var(--core-space-2xl);
223
+ }
224
+
225
+ &--variant-rectangle &__frame {
226
+ margin-top: -4.37rem;
227
+ flex: 1;
228
+ gap: var(--core-space-xs);
229
+ flex-direction: column;
230
+ align-items: center;
231
+ justify-content: flex-end;
232
+ text-align: center;
233
+ min-width: 8.75rem;
234
+ min-height: 10.25rem;
235
+ padding: var(--core-space-3xl) var(--core-space-xs) var(--core-space-m) var(--core-space-xs);
236
+ }
237
+
238
+ &__visual-content {
239
+ position: relative;
240
+ z-index: 2;
241
+ display: inline-flex;
242
+ align-items: center;
243
+ justify-content: center;
244
+ overflow: hidden;
245
+ border-radius: 100%;
246
+ background: var(--color-action-background-ondark);
247
+ border: 2px solid var(--color-action-border-ondark);
248
+
249
+ > * {
250
+ width: 100%;
251
+ height: 100%;
252
+ object-fit: cover;
253
+ }
254
+ }
255
+
256
+ &--variant-line &__visual-content {
257
+ min-width: var(--core-space-4xl);
258
+ min-height: var(--core-space-4xl);
259
+
260
+ @media (min-width: map.get(breakpoints.$grid-breakpoints, md)) {
261
+ min-width: var(--core-space-5xl);
262
+ min-height: var(--core-space-5xl);
263
+ }
264
+ }
265
+
266
+ &--variant-rectangle &__visual-content {
267
+ flex-shrink: 0;
268
+ width: calc(100% - 2rem);
269
+ min-width: 6.75rem;
270
+ max-width: 13rem;
271
+ }
272
+
273
+ &--checked &__frame,
274
+ &:has(input:checked) &__frame {
275
+ background: var(--color-action-background-onlight);
276
+ color: var(--color-action-text-ondark);
277
+ border-color: var(--color-action-background-onlight);
278
+ }
279
+
280
+ &--invalid &__frame {
281
+ background: var(--color-action-background-ondark);
282
+ border-color: var(--core-color-cherry-500);
283
+ }
284
+
285
+ &:hover &__frame {
286
+ background: var(--core-color-neutral-50);
287
+ border-color: var(--color-action-border-onlight-hover);
288
+ }
289
+
290
+ &:active &__frame {
291
+ background: var(--core-color-neutral-100);
292
+ border-color: var(--color-action-border-onlight-hover);
293
+ }
294
+
295
+ &--checked:hover &__frame,
296
+ &:has(input:checked):hover &__frame {
297
+ background: var(--color-action-background-onlight-hover);
298
+ }
299
+
300
+ &--checked:active &__frame,
301
+ &:has(input:checked):active &__frame {
302
+ background: var(--color-action-background-onlight-active);
303
+ border-color: var(--color-action-background-onlight-active);
304
+ }
305
+
306
+ &--invalid:hover &__frame {
307
+ background: var(--core-color-cherry-50);
308
+ border-color: var(--core-color-cherry-500);
309
+ }
310
+
311
+ &--invalid:active &__frame {
312
+ background: var(--core-color-cherry-100);
313
+ border-color: var(--core-color-cherry-500);
314
+ }
315
+
316
+ &--invalid#{&}--checked &__frame,
317
+ &--invalid:has(input:checked) &__frame {
318
+ background: var(--core-color-cherry-50);
319
+ color: var(--color-base-text-onlight);
320
+ border-color: var(--core-color-cherry-500);
321
+ }
322
+
323
+ &--invalid#{&}--checked:hover &__frame,
324
+ &--invalid:has(input:checked):hover &__frame {
325
+ background: var(--core-color-cherry-100);
326
+ border-color: var(--core-color-cherry-500);
327
+ }
328
+
329
+ &--invalid#{&}--checked:active &__frame,
330
+ &--invalid:has(input:checked):active &__frame {
331
+ background: var(--core-color-cherry-200);
332
+ border-color: var(--core-color-cherry-500);
333
+ }
334
+
335
+ &__input:focus-visible + &__frame {
336
+ outline: 4px solid var(--color-action-border-onlight-focus);
337
+ border-color: var(--color-action-border-ondark);
338
+ }
339
+
340
+ &__icon {
341
+ display: inline-flex;
342
+ align-items: center;
343
+ justify-content: center;
344
+
345
+ svg {
346
+ fill: var(--color-action-graphics-ondark);
347
+ }
348
+ }
349
+
350
+ &__label {
351
+ flex: 1;
352
+ min-width: 0;
353
+ overflow-wrap: anywhere;
354
+
355
+ @include fonts.label-subdued;
356
+ }
357
+ }
package/lib/utils3.js CHANGED
@@ -1,101 +1,13 @@
1
- import { t as uuid } from "./uuid.js";
2
- import { i as FormSize, n as AnalyticsId, r as FormOnColor } from "./constants2.js";
3
- import { t as usePseudoClasses } from "./usePseudoClasses.js";
4
- import { n as mergeRefs, t as isMutableRefObject } from "./refs.js";
5
- import { t as useIdWithFallback } from "./useIdWithFallback.js";
6
- import { t as getAriaDescribedBy } from "./accessibility.js";
7
- import { t as ErrorWrapper_default } from "./ErrorWrapper.js";
8
- import { r as renderLabelAsParent, t as getLabelText } from "./utils2.js";
9
- import classNames from "classnames";
10
- import { useState } from "react";
11
- import { jsx } from "react/jsx-runtime";
12
- import radioButtonStyles from "./components/RadioButton/styles.module.scss";
13
- const RadioButton = (props) => {
14
- const { className, defaultChecked, onChange, disabled, label, inputId = uuid(), onColor = FormOnColor.onwhite, name = inputId, size, errorText, errorTextId: errorTextIdProp, error = !!errorText, errorWrapperClassName, value = getLabelText(label), testId, required, labelClassNames, ref, ...rest } = props;
15
- const invalid = error || onColor === FormOnColor.oninvalid;
16
- const onDark = onColor === FormOnColor.ondark;
17
- const onBlueberry = onColor === FormOnColor.onblueberry;
18
- const onCherry = onColor === FormOnColor.oninvalid;
19
- const isLarge = size === FormSize.large;
20
- const [checked, changeChecked] = useState();
21
- const { refObject, isFocused } = usePseudoClasses(isMutableRefObject(ref) ? ref : null);
22
- const mergedRefs = mergeRefs([ref, refObject]);
23
- const errorTextId = useIdWithFallback(errorTextIdProp);
24
- const radioButtonWrapperClasses = classNames(radioButtonStyles["radio-button-wrapper"], {
25
- [radioButtonStyles["radio-button-wrapper__large"]]: isLarge,
26
- [radioButtonStyles["radio-button-wrapper__large--focused"]]: isLarge && isFocused,
27
- [radioButtonStyles["radio-button-wrapper__large--selected"]]: isLarge && checked && isFocused,
28
- [radioButtonStyles["radio-button-wrapper__large--invalid"]]: isLarge && onCherry && isFocused,
29
- [radioButtonStyles["radio-button-wrapper__large--on-blueberry"]]: isLarge && onBlueberry && isFocused
30
- });
31
- const radioButtonLabelClasses = classNames(radioButtonStyles["radio-button-label"], {
32
- [radioButtonStyles["radio-button-label--disabled"]]: disabled,
33
- [radioButtonStyles["radio-button-label--on-dark"]]: onDark,
34
- [radioButtonStyles["radio-button-label--invalid"]]: invalid,
35
- [radioButtonStyles["radio-button-label__large"]]: isLarge,
36
- [radioButtonStyles["radio-button-label__large--focused"]]: isFocused && isLarge,
37
- [radioButtonStyles["radio-button-label__large--disabled"]]: isLarge && disabled
38
- }, labelClassNames);
39
- const radioButtonClasses = classNames(radioButtonStyles["radio-button"], {
40
- [radioButtonStyles["radio-button--on-dark"]]: onDark,
41
- [radioButtonStyles["radio-button--disabled"]]: disabled,
42
- [radioButtonStyles["radio-button--on-blueberry"]]: onBlueberry,
43
- [radioButtonStyles["radio-button--invalid"]]: invalid,
44
- [radioButtonStyles["radio-button__large"]]: isLarge,
45
- [radioButtonStyles["radio-button__large--disabled"]]: isLarge && disabled,
46
- [radioButtonStyles["radio-button__large--invalid"]]: isLarge && invalid
47
- }, className);
48
- const change = (e) => {
49
- changeChecked(e.target.checked);
50
- if (onChange) onChange(e);
51
- };
52
- const getLabelContent = () => /* @__PURE__ */ jsx("input", {
53
- ...rest,
54
- id: inputId,
55
- name,
56
- className: radioButtonClasses,
57
- type: "radio",
58
- disabled,
59
- value,
60
- ref: mergedRefs,
61
- defaultChecked,
62
- "aria-describedby": getAriaDescribedBy(props, errorTextId),
63
- required,
64
- onChange: (e) => change(e)
65
- });
66
- return /* @__PURE__ */ jsx(ErrorWrapper_default, {
67
- className: errorWrapperClassName,
68
- errorText,
69
- errorTextId,
70
- children: /* @__PURE__ */ jsx("div", {
71
- "data-testid": testId,
72
- "data-analyticsid": AnalyticsId.RadioButton,
73
- className: radioButtonWrapperClasses,
74
- children: renderLabelAsParent({
75
- label,
76
- children: getLabelContent(),
77
- inputId,
78
- onColor,
79
- labelClassName: radioButtonLabelClasses,
80
- sublabelWrapperClassName: radioButtonStyles["radiobutton-sublabel-wrapper"],
81
- large: isLarge,
82
- afterLabelChildrenClassName: radioButtonStyles["radiobutton-afterlabelchildren-wrapper"]
83
- })
84
- })
85
- });
1
+ let ViewBoxSize = /* @__PURE__ */ function(ViewBoxSize$1) {
2
+ ViewBoxSize$1["Medium"] = "0 0 512 512";
3
+ ViewBoxSize$1["Small"] = "0 0 200 200";
4
+ return ViewBoxSize$1;
5
+ }({});
6
+ const getIllustration = ({ size, large, medium, small }) => {
7
+ if (large && (size >= 512 || !medium && !small)) return large;
8
+ if (medium && (size >= 201 || !small)) return medium;
9
+ return small;
86
10
  };
87
- RadioButton.displayName = "RadioButton";
88
- var RadioButton_default = RadioButton;
89
- const getRadioLabelClasses = (radioId, onColor, large, checkedRadioId) => {
90
- const onCherry = onColor === "oninvalid";
91
- const checked = radioId === checkedRadioId;
92
- return classNames({
93
- [radioButtonStyles["radio-button-label__large--on-grey"]]: large && onColor === "ongrey" && !checked,
94
- [radioButtonStyles["radio-button-label__large--on-blueberry"]]: onColor === "onblueberry" && !checked && large,
95
- [radioButtonStyles["radio-button-label__large--selected"]]: large && checked && !onCherry,
96
- [radioButtonStyles["radio-button-label__large--selected-invalid"]]: large && checked && onCherry
97
- });
98
- };
99
- export { RadioButton as n, RadioButton_default as r, getRadioLabelClasses as t };
11
+ export { getIllustration as n, ViewBoxSize as t };
100
12
 
101
13
  //# sourceMappingURL=utils3.js.map
package/lib/utils3.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils3.js","names":["RadioButton: React.FC<RadioButtonProps>"],"sources":["../src/components/RadioButton/RadioButton.tsx","../src/components/RadioButton/utils.ts"],"sourcesContent":["import { useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport type { ErrorWrapperClassNameProps } from '../ErrorWrapper';\n\nimport { AnalyticsId, FormOnColor, FormSize } from '../../constants';\nimport { useIdWithFallback } from '../../hooks/useIdWithFallback';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { getAriaDescribedBy } from '../../utils/accessibility';\nimport { isMutableRefObject, mergeRefs } from '../../utils/refs';\nimport { uuid } from '../../utils/uuid';\nimport ErrorWrapper from '../ErrorWrapper';\nimport { getLabelText, renderLabelAsParent } from '../Label/utils';\n\nimport radioButtonStyles from './styles.module.scss';\n\nexport interface RadioButtonProps\n extends\n ErrorWrapperClassNameProps,\n Pick<\n React.InputHTMLAttributes<HTMLInputElement>,\n 'aria-describedby' | 'name' | 'value' | 'disabled' | 'checked' | 'defaultChecked' | 'required' | 'onChange'\n > {\n /** Adds custom classes to the element. */\n className?: string;\n /** The <Label/> next to the radioButton - sublabels kan ikke kombineres med large variant */\n label: React.ReactNode;\n /** Adds custom classes to the label element. */\n labelClassNames?: string;\n /** input id of the radioButton */\n inputId?: string;\n /** Changes the visuals of the radioButton */\n onColor?: keyof typeof FormOnColor;\n /** Changes the visuals of the radioButton. Large version only works when used inside a FormGroup wrapper. */\n size?: keyof typeof FormSize;\n /** Activates Error style for the radioButton - This is can be true while errorText is empty, when in a FormGroup */\n error?: boolean;\n /** Error text to show above the component */\n errorText?: string;\n /** Error text id */\n errorTextId?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Ref passed to the input element */\n ref?: React.Ref<HTMLInputElement | null>;\n}\n\nexport const RadioButton: React.FC<RadioButtonProps> = props => {\n const {\n className,\n defaultChecked,\n onChange,\n disabled,\n label,\n inputId = uuid(),\n onColor = FormOnColor.onwhite,\n name = inputId,\n size,\n errorText,\n errorTextId: errorTextIdProp,\n error = !!errorText,\n errorWrapperClassName,\n value = getLabelText(label),\n testId,\n required,\n labelClassNames,\n ref,\n ...rest\n } = props;\n const invalid = error || onColor === FormOnColor.oninvalid;\n const onDark = onColor === FormOnColor.ondark;\n const onBlueberry = onColor === FormOnColor.onblueberry;\n const onCherry = onColor === FormOnColor.oninvalid;\n const isLarge = size === FormSize.large;\n const [checked, changeChecked] = useState<boolean>();\n const { refObject, isFocused } = usePseudoClasses<HTMLInputElement>(isMutableRefObject(ref) ? ref : null);\n const mergedRefs = mergeRefs([ref, refObject]);\n const errorTextId = useIdWithFallback(errorTextIdProp);\n\n const radioButtonWrapperClasses = classNames(radioButtonStyles['radio-button-wrapper'], {\n [radioButtonStyles['radio-button-wrapper__large']]: isLarge,\n [radioButtonStyles['radio-button-wrapper__large--focused']]: isLarge && isFocused,\n [radioButtonStyles['radio-button-wrapper__large--selected']]: isLarge && checked && isFocused,\n [radioButtonStyles['radio-button-wrapper__large--invalid']]: isLarge && onCherry && isFocused,\n [radioButtonStyles['radio-button-wrapper__large--on-blueberry']]: isLarge && onBlueberry && isFocused,\n });\n const radioButtonLabelClasses = classNames(\n radioButtonStyles['radio-button-label'],\n {\n [radioButtonStyles['radio-button-label--disabled']]: disabled,\n [radioButtonStyles['radio-button-label--on-dark']]: onDark,\n [radioButtonStyles['radio-button-label--invalid']]: invalid,\n [radioButtonStyles['radio-button-label__large']]: isLarge,\n [radioButtonStyles['radio-button-label__large--focused']]: isFocused && isLarge,\n [radioButtonStyles['radio-button-label__large--disabled']]: isLarge && disabled,\n },\n labelClassNames\n );\n const radioButtonClasses = classNames(\n radioButtonStyles['radio-button'],\n {\n [radioButtonStyles['radio-button--on-dark']]: onDark,\n [radioButtonStyles['radio-button--disabled']]: disabled,\n [radioButtonStyles['radio-button--on-blueberry']]: onBlueberry,\n [radioButtonStyles['radio-button--invalid']]: invalid,\n [radioButtonStyles['radio-button__large']]: isLarge,\n [radioButtonStyles['radio-button__large--disabled']]: isLarge && disabled,\n [radioButtonStyles['radio-button__large--invalid']]: isLarge && invalid,\n },\n className\n );\n\n const change = (e: React.ChangeEvent<HTMLInputElement>): void => {\n changeChecked(e.target.checked);\n if (onChange) onChange(e);\n };\n\n const getLabelContent = (): React.ReactNode => (\n <input\n {...rest}\n id={inputId}\n name={name}\n className={radioButtonClasses}\n type=\"radio\"\n disabled={disabled}\n value={value}\n ref={mergedRefs}\n defaultChecked={defaultChecked}\n aria-describedby={getAriaDescribedBy(props, errorTextId)}\n required={required}\n onChange={(e): void => change(e)}\n />\n );\n\n return (\n <ErrorWrapper className={errorWrapperClassName} errorText={errorText} errorTextId={errorTextId}>\n <div data-testid={testId} data-analyticsid={AnalyticsId.RadioButton} className={radioButtonWrapperClasses}>\n {renderLabelAsParent({\n label: label,\n children: getLabelContent(),\n inputId: inputId,\n onColor: onColor as FormOnColor,\n labelClassName: radioButtonLabelClasses,\n sublabelWrapperClassName: radioButtonStyles['radiobutton-sublabel-wrapper'],\n large: isLarge,\n afterLabelChildrenClassName: radioButtonStyles['radiobutton-afterlabelchildren-wrapper'],\n })}\n </div>\n </ErrorWrapper>\n );\n};\n\nRadioButton.displayName = 'RadioButton';\n\nexport default RadioButton;\n","import classNames from 'classnames';\n\nimport type { FormOnColor } from '../../constants';\n\nimport radioButtonStyles from './styles.module.scss';\n\nexport const getRadioLabelClasses = (\n radioId: string,\n onColor: FormOnColor,\n large: boolean,\n checkedRadioId?: string\n): string | undefined => {\n const onCherry = onColor === 'oninvalid';\n const checked = radioId === checkedRadioId;\n\n return classNames({\n [radioButtonStyles['radio-button-label__large--on-grey']]: large && onColor === 'ongrey' && !checked,\n [radioButtonStyles['radio-button-label__large--on-blueberry']]: onColor === 'onblueberry' && !checked && large,\n [radioButtonStyles['radio-button-label__large--selected']]: large && checked && !onCherry,\n [radioButtonStyles['radio-button-label__large--selected-invalid']]: large && checked && onCherry,\n });\n};\n"],"mappings":";;;;;;;;;;;;AAgDA,MAAaA,eAA0C,UAAS;CAC9D,MAAM,EACJ,WACA,gBACA,UACA,UACA,OACA,UAAU,MAAM,EAChB,UAAU,YAAY,SACtB,OAAO,SACP,MACA,WACA,aAAa,iBACb,QAAQ,CAAC,CAAC,WACV,uBACA,QAAQ,aAAa,MAAM,EAC3B,QACA,UACA,iBACA,KACA,GAAG,SACD;CACJ,MAAM,UAAU,SAAS,YAAY,YAAY;CACjD,MAAM,SAAS,YAAY,YAAY;CACvC,MAAM,cAAc,YAAY,YAAY;CAC5C,MAAM,WAAW,YAAY,YAAY;CACzC,MAAM,UAAU,SAAS,SAAS;CAClC,MAAM,CAAC,SAAS,iBAAiB,UAAmB;CACpD,MAAM,EAAE,WAAW,cAAc,iBAAmC,mBAAmB,IAAI,GAAG,MAAM,KAAK;CACzG,MAAM,aAAa,UAAU,CAAC,KAAK,UAAU,CAAC;CAC9C,MAAM,cAAc,kBAAkB,gBAAgB;CAEtD,MAAM,4BAA4B,WAAW,kBAAkB,yBAAyB;GACrF,kBAAkB,iCAAiC;GACnD,kBAAkB,0CAA0C,WAAW;GACvE,kBAAkB,2CAA2C,WAAW,WAAW;GACnF,kBAAkB,0CAA0C,WAAW,YAAY;GACnF,kBAAkB,+CAA+C,WAAW,eAAe;EAC7F,CAAC;CACF,MAAM,0BAA0B,WAC9B,kBAAkB,uBAClB;GACG,kBAAkB,kCAAkC;GACpD,kBAAkB,iCAAiC;GACnD,kBAAkB,iCAAiC;GACnD,kBAAkB,+BAA+B;GACjD,kBAAkB,wCAAwC,aAAa;GACvE,kBAAkB,yCAAyC,WAAW;EACxE,EACD,gBACD;CACD,MAAM,qBAAqB,WACzB,kBAAkB,iBAClB;GACG,kBAAkB,2BAA2B;GAC7C,kBAAkB,4BAA4B;GAC9C,kBAAkB,gCAAgC;GAClD,kBAAkB,2BAA2B;GAC7C,kBAAkB,yBAAyB;GAC3C,kBAAkB,mCAAmC,WAAW;GAChE,kBAAkB,kCAAkC,WAAW;EACjE,EACD,UACD;CAED,MAAM,UAAU,MAAiD;AAC/D,gBAAc,EAAE,OAAO,QAAQ;AAC/B,MAAI,SAAU,UAAS,EAAE;;CAG3B,MAAM,wBACJ,oBAAC,SAAA;EACC,GAAI;EACJ,IAAI;EACE;EACN,WAAW;EACX,MAAK;EACK;EACH;EACP,KAAK;EACW;EAChB,oBAAkB,mBAAmB,OAAO,YAAY;EAC9C;EACV,WAAW,MAAY,OAAO,EAAE;GAChC;AAGJ,QACE,oBAAC,sBAAA;EAAa,WAAW;EAAkC;EAAwB;YACjF,oBAAC,OAAA;GAAI,eAAa;GAAQ,oBAAkB,YAAY;GAAa,WAAW;aAC7E,oBAAoB;IACZ;IACP,UAAU,iBAAiB;IAClB;IACA;IACT,gBAAgB;IAChB,0BAA0B,kBAAkB;IAC5C,OAAO;IACP,6BAA6B,kBAAkB;IAChD,CAAC;IACE;GACO;;AAInB,YAAY,cAAc;AAE1B,IAAA,sBAAe;ACrJf,MAAa,wBACX,SACA,SACA,OACA,mBACuB;CACvB,MAAM,WAAW,YAAY;CAC7B,MAAM,UAAU,YAAY;AAE5B,QAAO,WAAW;GACf,kBAAkB,wCAAwC,SAAS,YAAY,YAAY,CAAC;GAC5F,kBAAkB,6CAA6C,YAAY,iBAAiB,CAAC,WAAW;GACxG,kBAAkB,yCAAyC,SAAS,WAAW,CAAC;GAChF,kBAAkB,iDAAiD,SAAS,WAAW;EACzF,CAAC"}
1
+ {"version":3,"file":"utils3.js","names":[],"sources":["../src/components/Illustration/utils.ts"],"sourcesContent":["export enum ViewBoxSize {\n Medium = '0 0 512 512',\n Small = '0 0 200 200',\n}\ninterface IllustrationConfig<T> {\n size: number;\n large?: T;\n medium?: T;\n small?: T;\n}\n\nexport const getIllustration = <T>({ size, large, medium, small }: IllustrationConfig<T>): T => {\n if (large && (size >= 512 || (!medium && !small))) {\n return large;\n }\n\n if (medium && (size >= 201 || !small)) {\n return medium;\n }\n\n return small as T;\n};\n"],"mappings":"AAAA,IAAY,cAAA,yBAAA,eAAL;AACL,eAAA,YAAA;AACA,eAAA,WAAA;;;AASF,MAAa,mBAAsB,EAAE,MAAM,OAAO,QAAQ,YAAsC;AAC9F,KAAI,UAAU,QAAQ,OAAQ,CAAC,UAAU,CAAC,OACxC,QAAO;AAGT,KAAI,WAAW,QAAQ,OAAO,CAAC,OAC7B,QAAO;AAGT,QAAO"}
package/lib/utils4.js CHANGED
@@ -1,13 +1,30 @@
1
- let ViewBoxSize = /* @__PURE__ */ function(ViewBoxSize$1) {
2
- ViewBoxSize$1["Medium"] = "0 0 512 512";
3
- ViewBoxSize$1["Small"] = "0 0 200 200";
4
- return ViewBoxSize$1;
5
- }({});
6
- const getIllustration = ({ size, large, medium, small }) => {
7
- if (large && (size >= 512 || !medium && !small)) return large;
8
- if (medium && (size >= 201 || !small)) return medium;
9
- return small;
10
- };
11
- export { getIllustration as n, ViewBoxSize as t };
1
+ import { createContext } from "react";
2
+ let PanelLayout = /* @__PURE__ */ function(PanelLayout$1) {
3
+ PanelLayout$1["vertical"] = "vertical";
4
+ PanelLayout$1["horizontal"] = "horizontal";
5
+ PanelLayout$1["combined"] = "combined";
6
+ PanelLayout$1["bAsRightCol"] = "bAsRightCol";
7
+ return PanelLayout$1;
8
+ }({});
9
+ let PanelVariant = /* @__PURE__ */ function(PanelVariant$1) {
10
+ PanelVariant$1["fill"] = "fill";
11
+ PanelVariant$1["line"] = "line";
12
+ PanelVariant$1["outline"] = "outline";
13
+ return PanelVariant$1;
14
+ }({});
15
+ let PanelStacking = /* @__PURE__ */ function(PanelStacking$1) {
16
+ PanelStacking$1["default"] = "default";
17
+ PanelStacking$1["bFirst"] = "bFirst";
18
+ return PanelStacking$1;
19
+ }({});
20
+ let PanelStatus = /* @__PURE__ */ function(PanelStatus$1) {
21
+ PanelStatus$1["none"] = "none";
22
+ PanelStatus$1["new"] = "new";
23
+ PanelStatus$1["error"] = "error";
24
+ PanelStatus$1["draft"] = "draft";
25
+ return PanelStatus$1;
26
+ }({});
27
+ const PanelListContext = createContext(null);
28
+ export { PanelVariant as a, PanelStatus as i, PanelLayout as n, PanelStacking as r, PanelListContext as t };
12
29
 
13
30
  //# sourceMappingURL=utils4.js.map
package/lib/utils4.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils4.js","names":[],"sources":["../src/components/Illustration/utils.ts"],"sourcesContent":["export enum ViewBoxSize {\n Medium = '0 0 512 512',\n Small = '0 0 200 200',\n}\ninterface IllustrationConfig<T> {\n size: number;\n large?: T;\n medium?: T;\n small?: T;\n}\n\nexport const getIllustration = <T>({ size, large, medium, small }: IllustrationConfig<T>): T => {\n if (large && (size >= 512 || (!medium && !small))) {\n return large;\n }\n\n if (medium && (size >= 201 || !small)) {\n return medium;\n }\n\n return small as T;\n};\n"],"mappings":"AAAA,IAAY,cAAA,yBAAA,eAAL;AACL,eAAA,YAAA;AACA,eAAA,WAAA;;;AASF,MAAa,mBAAsB,EAAE,MAAM,OAAO,QAAQ,YAAsC;AAC9F,KAAI,UAAU,QAAQ,OAAQ,CAAC,UAAU,CAAC,OACxC,QAAO;AAGT,KAAI,WAAW,QAAQ,OAAO,CAAC,OAC7B,QAAO;AAGT,QAAO"}
1
+ {"version":3,"file":"utils4.js","names":[],"sources":["../src/components/Panel/constants.ts","../src/components/PanelList/utils.tsx"],"sourcesContent":["export enum PanelLayout {\n vertical = 'vertical',\n horizontal = 'horizontal',\n combined = 'combined',\n bAsRightCol = 'bAsRightCol',\n}\n\nexport enum PanelVariant {\n fill = 'fill',\n line = 'line',\n outline = 'outline',\n}\n\nexport enum PanelStacking {\n default = 'default',\n bFirst = 'bFirst',\n}\n\nexport enum PanelStatus {\n none = 'none',\n new = 'new',\n error = 'error',\n draft = 'draft',\n}\n","import { createContext } from 'react';\n\nimport type { PanelVariant } from '../Panel/constants';\n\nexport interface PanelListContextValue {\n variant: PanelVariant;\n highlightText?: string;\n applyPanelClassName: (existingClassName?: string) => string;\n}\n\nexport const PanelListContext = createContext<PanelListContextValue | null>(null);\n"],"mappings":";AAAA,IAAY,cAAA,yBAAA,eAAL;AACL,eAAA,cAAA;AACA,eAAA,gBAAA;AACA,eAAA,cAAA;AACA,eAAA,iBAAA;;;AAGF,IAAY,eAAA,yBAAA,gBAAL;AACL,gBAAA,UAAA;AACA,gBAAA,UAAA;AACA,gBAAA,aAAA;;;AAGF,IAAY,gBAAA,yBAAA,iBAAL;AACL,iBAAA,aAAA;AACA,iBAAA,YAAA;;;AAGF,IAAY,cAAA,yBAAA,eAAL;AACL,eAAA,UAAA;AACA,eAAA,SAAA;AACA,eAAA,WAAA;AACA,eAAA,WAAA;;;ACZF,MAAa,mBAAmB,cAA4C,KAAK"}
package/lib/utils5.js CHANGED
@@ -1,30 +1,60 @@
1
- import { createContext } from "react";
2
- let PanelLayout = /* @__PURE__ */ function(PanelLayout$1) {
3
- PanelLayout$1["vertical"] = "vertical";
4
- PanelLayout$1["horizontal"] = "horizontal";
5
- PanelLayout$1["combined"] = "combined";
6
- PanelLayout$1["bAsRightCol"] = "bAsRightCol";
7
- return PanelLayout$1;
8
- }({});
9
- let PanelVariant = /* @__PURE__ */ function(PanelVariant$1) {
10
- PanelVariant$1["fill"] = "fill";
11
- PanelVariant$1["line"] = "line";
12
- PanelVariant$1["outline"] = "outline";
13
- return PanelVariant$1;
14
- }({});
15
- let PanelStacking = /* @__PURE__ */ function(PanelStacking$1) {
16
- PanelStacking$1["default"] = "default";
17
- PanelStacking$1["bFirst"] = "bFirst";
18
- return PanelStacking$1;
19
- }({});
20
- let PanelStatus = /* @__PURE__ */ function(PanelStatus$1) {
21
- PanelStatus$1["none"] = "none";
22
- PanelStatus$1["new"] = "new";
23
- PanelStatus$1["error"] = "error";
24
- PanelStatus$1["draft"] = "draft";
25
- return PanelStatus$1;
26
- }({});
27
- const PanelListContext = createContext(null);
28
- export { PanelVariant as a, PanelStatus as i, PanelLayout as n, PanelStacking as r, PanelListContext as t };
1
+ import { t as Breakpoint } from "./useBreakpoint.js";
2
+ import { r as ResponsiveTableVariant } from "./constants3.js";
3
+ import { t as isTouchDevice } from "./device.js";
4
+ import React from "react";
5
+ import tableStyles from "./components/Table/styles.module.scss";
6
+ var configUsesCss = (config) => config.variant === ResponsiveTableVariant.centeredoverflow || config.variant === ResponsiveTableVariant.block;
7
+ var mapConfigToClass = (config) => config.variant === "centeredoverflow" || config.variant === "block" ? tableStyles[`table--${config.variant}-${config.breakpoint}`] : "";
8
+ var sortByBreakpointsDescending = (a, b) => Breakpoint[a.breakpoint] - Breakpoint[b.breakpoint];
9
+ var isValidForCurrentBreakpoint = (config, breakpoint) => Breakpoint[config.breakpoint] >= breakpoint;
10
+ var getConfigForBreakpoint = (config, breakpoint) => {
11
+ if (Array.isArray(config)) {
12
+ config.sort(sortByBreakpointsDescending);
13
+ return config.find((x) => isValidForCurrentBreakpoint(x, breakpoint));
14
+ } else if (config && isValidForCurrentBreakpoint(config, breakpoint)) return config;
15
+ };
16
+ const getCurrentConfig = (config, breakpoint, tableWidth, windowWidth) => {
17
+ const breakpointConfig = getConfigForBreakpoint(config, breakpoint);
18
+ const canUseHorizontalScroll = isTouchDevice();
19
+ const canUseCenteredOverflow = tableWidth <= windowWidth;
20
+ if (!breakpointConfig) return;
21
+ if (breakpointConfig.variant === ResponsiveTableVariant.centeredoverflow && !canUseCenteredOverflow && breakpointConfig.fallbackVariant === ResponsiveTableVariant.horizontalscroll) return {
22
+ variant: canUseHorizontalScroll ? ResponsiveTableVariant.horizontalscroll : ResponsiveTableVariant.none,
23
+ breakpoint: breakpointConfig.breakpoint
24
+ };
25
+ if (breakpointConfig.variant === ResponsiveTableVariant.centeredoverflow && !canUseCenteredOverflow && breakpointConfig.fallbackVariant !== ResponsiveTableVariant.centeredoverflow) return {
26
+ variant: breakpointConfig.fallbackVariant ?? ResponsiveTableVariant.none,
27
+ breakpoint: breakpointConfig.breakpoint
28
+ };
29
+ if (breakpointConfig.variant === ResponsiveTableVariant.horizontalscroll && !canUseHorizontalScroll && breakpointConfig.fallbackVariant === ResponsiveTableVariant.centeredoverflow) return {
30
+ variant: canUseCenteredOverflow ? ResponsiveTableVariant.centeredoverflow : ResponsiveTableVariant.none,
31
+ breakpoint: breakpointConfig.breakpoint
32
+ };
33
+ if (breakpointConfig.variant === ResponsiveTableVariant.horizontalscroll && !canUseHorizontalScroll && breakpointConfig.fallbackVariant !== ResponsiveTableVariant.horizontalscroll) return {
34
+ variant: breakpointConfig.fallbackVariant ?? ResponsiveTableVariant.none,
35
+ breakpoint: breakpointConfig.breakpoint
36
+ };
37
+ return breakpointConfig;
38
+ };
39
+ const getBreakpointClass = (config) => config && configUsesCss(config) ? mapConfigToClass(config) : void 0;
40
+ const getCenteredOverflowTableStyle = (parentWidth, tableWidth) => {
41
+ if (parentWidth >= tableWidth) return;
42
+ return { left: `${(parentWidth - tableWidth) / 2 - 8}px` };
43
+ };
44
+ const mapChildrenWithMode = (children, mode) => React.Children.map(children, (child) => {
45
+ if (!React.isValidElement(child)) return child;
46
+ if (child.type === React.Fragment) {
47
+ const fragmentChildren = child.props.children;
48
+ const mapped = React.Children.map(fragmentChildren, (gc) => React.isValidElement(gc) ? React.cloneElement(gc, { mode }) : gc);
49
+ return React.cloneElement(child, void 0, mapped);
50
+ }
51
+ return React.cloneElement(child, { mode });
52
+ });
53
+ const omitProps = (obj, keys) => {
54
+ const clone = { ...obj };
55
+ for (const k of keys) delete clone[k];
56
+ return clone;
57
+ };
58
+ export { omitProps as a, mapChildrenWithMode as i, getCenteredOverflowTableStyle as n, getCurrentConfig as r, getBreakpointClass as t };
29
59
 
30
60
  //# sourceMappingURL=utils5.js.map