@asd20/ui-next 2.33.3 → 2.34.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.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
# [2.34.0](https://github.com/academydistrict20/asd20-ui-next/compare/ui-next-v2.33.3...ui-next-v2.34.0) (2026-10-28)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* support checkbox groups for school transfer records ([9596d21](https://github.com/academydistrict20/asd20-ui-next/commit/9596d21fea018afec4c03de64471549cb77e9487))
|
|
9
|
+
|
|
3
10
|
## [2.33.3](https://github.com/academydistrict20/asd20-ui-next/compare/ui-next-v2.33.2...ui-next-v2.33.3) (2026-10-27)
|
|
4
11
|
|
|
5
12
|
|
package/package.json
CHANGED
|
@@ -149,6 +149,32 @@
|
|
|
149
149
|
</label>
|
|
150
150
|
</fieldset>
|
|
151
151
|
|
|
152
|
+
<fieldset
|
|
153
|
+
v-else-if="field.type === 'checkbox-group'"
|
|
154
|
+
:id="inputId"
|
|
155
|
+
class="asd20-public-form-field__choices"
|
|
156
|
+
tabindex="-1"
|
|
157
|
+
:aria-describedby="describedBy"
|
|
158
|
+
:aria-invalid="hasErrors ? 'true' : undefined"
|
|
159
|
+
>
|
|
160
|
+
<legend>{{ displayLabel }}</legend>
|
|
161
|
+
<label
|
|
162
|
+
v-for="option in field.options"
|
|
163
|
+
:key="option.value"
|
|
164
|
+
:for="`${inputId}-${option.value}`"
|
|
165
|
+
>
|
|
166
|
+
<input
|
|
167
|
+
:id="`${inputId}-${option.value}`"
|
|
168
|
+
:name="inputId"
|
|
169
|
+
type="checkbox"
|
|
170
|
+
:value="option.value"
|
|
171
|
+
:checked="Array.isArray(modelValue) && modelValue.includes(option.value)"
|
|
172
|
+
@change="toggleChoice(option.value, $event.target.checked)"
|
|
173
|
+
/>
|
|
174
|
+
<span>{{ option.label }}</span>
|
|
175
|
+
</label>
|
|
176
|
+
</fieldset>
|
|
177
|
+
|
|
152
178
|
<asd20-checkbox
|
|
153
179
|
v-else-if="field.type === 'checkbox'"
|
|
154
180
|
:id="inputId"
|
|
@@ -276,6 +302,12 @@ export default {
|
|
|
276
302
|
},
|
|
277
303
|
},
|
|
278
304
|
methods: {
|
|
305
|
+
toggleChoice(value, checked) {
|
|
306
|
+
const selected = Array.isArray(this.modelValue) ? this.modelValue : []
|
|
307
|
+
this.$emit('update:modelValue', checked
|
|
308
|
+
? [...selected.filter(choice => choice !== value), value]
|
|
309
|
+
: selected.filter(choice => choice !== value))
|
|
310
|
+
},
|
|
279
311
|
addFiles(event) {
|
|
280
312
|
const addedFiles = Array.from(event.target.files || [])
|
|
281
313
|
if (addedFiles.length) {
|
|
@@ -407,7 +439,8 @@ export default {
|
|
|
407
439
|
align-items: flex-start;
|
|
408
440
|
}
|
|
409
441
|
|
|
410
|
-
&__choices input[type='radio']
|
|
442
|
+
&__choices input[type='radio'],
|
|
443
|
+
&__choices input[type='checkbox'] {
|
|
411
444
|
flex: 0 0 auto;
|
|
412
445
|
margin: 0;
|
|
413
446
|
}
|
|
@@ -410,7 +410,7 @@ export default {
|
|
|
410
410
|
for (const field of this.formDefinition.fields) {
|
|
411
411
|
if (!isPublicFormFieldVisible(field, this.values)) {
|
|
412
412
|
this.values[field.name] =
|
|
413
|
-
field.type === 'checkbox' ? false : field.type
|
|
413
|
+
field.type === 'checkbox' ? false : ['file', 'checkbox-group'].includes(field.type) ? [] : ''
|
|
414
414
|
}
|
|
415
415
|
}
|
|
416
416
|
if (this.validationAttempted) this.validate(false)
|
|
@@ -7,6 +7,7 @@ export const SUPPORTED_PUBLIC_FORM_FIELD_TYPES = Object.freeze([
|
|
|
7
7
|
'select',
|
|
8
8
|
'radio',
|
|
9
9
|
'checkbox',
|
|
10
|
+
'checkbox-group',
|
|
10
11
|
'file',
|
|
11
12
|
])
|
|
12
13
|
|
|
@@ -48,7 +49,7 @@ function optionalBoolean(value, label) {
|
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
function normalizeOptions(field) {
|
|
51
|
-
if (!['select', 'radio'].includes(field.type)) return undefined
|
|
52
|
+
if (!['select', 'radio', 'checkbox-group'].includes(field.type)) return undefined
|
|
52
53
|
if (
|
|
53
54
|
!Array.isArray(field.options) ||
|
|
54
55
|
!field.options.length ||
|
|
@@ -184,17 +185,19 @@ function normalizeConditions(conditions) {
|
|
|
184
185
|
return conditions.map(normalizeCondition)
|
|
185
186
|
}
|
|
186
187
|
|
|
188
|
+
function matchesCondition(condition, values) {
|
|
189
|
+
const value = values[condition.fieldName]
|
|
190
|
+
return Array.isArray(value)
|
|
191
|
+
? value.some(choice => condition.values.includes(choice))
|
|
192
|
+
: condition.values.includes(String(value || '').trim())
|
|
193
|
+
}
|
|
194
|
+
|
|
187
195
|
export function isPublicFormFieldVisible(field, values) {
|
|
188
|
-
return (
|
|
189
|
-
!field.visibleWhen ||
|
|
190
|
-
field.visibleWhen.values.includes(String(values[field.visibleWhen.fieldName] || '').trim())
|
|
191
|
-
)
|
|
196
|
+
return !field.visibleWhen || matchesCondition(field.visibleWhen, values)
|
|
192
197
|
}
|
|
193
198
|
|
|
194
199
|
export function isPublicFormFieldRequired(field, values) {
|
|
195
|
-
const required = field.required || field.requiredWhen?.some(condition =>
|
|
196
|
-
condition.values.includes(String(values[condition.fieldName] || '').trim())
|
|
197
|
-
)
|
|
200
|
+
const required = field.required || field.requiredWhen?.some(condition => matchesCondition(condition, values))
|
|
198
201
|
const uploaded = field.requiredUnlessUploaded &&
|
|
199
202
|
Array.isArray(values[field.requiredUnlessUploaded]) &&
|
|
200
203
|
values[field.requiredUnlessUploaded].length > 0
|
|
@@ -268,8 +271,8 @@ export function normalizePublicFormDefinition(definition) {
|
|
|
268
271
|
)
|
|
269
272
|
if (
|
|
270
273
|
!dependency ||
|
|
271
|
-
dependency
|
|
272
|
-
!['radio', 'select'].includes(dependency.type) ||
|
|
274
|
+
fields.indexOf(dependency) >= fields.indexOf(field) ||
|
|
275
|
+
!['radio', 'select', 'checkbox-group'].includes(dependency.type) ||
|
|
273
276
|
condition.values.some(
|
|
274
277
|
value => !dependency.options.some(option => option.value === value)
|
|
275
278
|
)
|
|
@@ -369,7 +372,7 @@ export function createPublicFormValues(definition) {
|
|
|
369
372
|
return Object.fromEntries(
|
|
370
373
|
definition.fields.map(field => [
|
|
371
374
|
field.name,
|
|
372
|
-
field.type
|
|
375
|
+
['file', 'checkbox-group'].includes(field.type) ? [] : field.type === 'checkbox' ? false : '',
|
|
373
376
|
])
|
|
374
377
|
)
|
|
375
378
|
}
|
|
@@ -403,9 +406,9 @@ export function validatePublicFormValues(definition, sourceValues = {}) {
|
|
|
403
406
|
const values = {}
|
|
404
407
|
|
|
405
408
|
for (const field of definition.fields) {
|
|
406
|
-
if (!isPublicFormFieldVisible(field,
|
|
409
|
+
if (!isPublicFormFieldVisible(field, values)) {
|
|
407
410
|
values[field.name] =
|
|
408
|
-
field.type
|
|
411
|
+
['file', 'checkbox-group'].includes(field.type) ? [] : field.type === 'checkbox' ? false : ''
|
|
409
412
|
continue
|
|
410
413
|
}
|
|
411
414
|
const required = isPublicFormFieldRequired(field, sourceValues)
|
|
@@ -433,6 +436,21 @@ export function validatePublicFormValues(definition, sourceValues = {}) {
|
|
|
433
436
|
'Upload up to 5 PDF documents, 5 MB each and 10 MB total.'
|
|
434
437
|
)
|
|
435
438
|
}
|
|
439
|
+
} else if (field.type === 'checkbox-group') {
|
|
440
|
+
const selected = rawValue == null ? [] : rawValue
|
|
441
|
+
const allowed = new Set((field.options || []).map(option => option.value))
|
|
442
|
+
if (
|
|
443
|
+
!Array.isArray(selected) ||
|
|
444
|
+
selected.length > allowed.size ||
|
|
445
|
+
selected.some(choice => typeof choice !== 'string' || !allowed.has(choice)) ||
|
|
446
|
+
new Set(selected).size !== selected.length
|
|
447
|
+
) {
|
|
448
|
+
values[field.name] = []
|
|
449
|
+
fieldErrors.push(`Select valid choices for ${field.label.toLowerCase()}.`)
|
|
450
|
+
} else {
|
|
451
|
+
values[field.name] = [...selected]
|
|
452
|
+
if (required && !selected.length) fieldErrors.push(`${field.label} is required.`)
|
|
453
|
+
}
|
|
436
454
|
} else if (field.type === 'checkbox') {
|
|
437
455
|
const value = rawValue === true
|
|
438
456
|
values[field.name] = value
|