|
13 | 13 |
|
14 | 14 | import type { FieldProps } from "./model.js"; |
15 | 15 |
|
16 | | - let { |
17 | | - config, |
18 | | - value = $bindable(), |
19 | | - multiple = false, |
20 | | - }: FieldProps<"enum"> = $props(); |
| 16 | + let { config, value = $bindable(), multiple }: FieldProps<"enum"> = $props(); |
21 | 17 |
|
22 | 18 | const ctx = getFormContext(); |
23 | 19 |
|
24 | 20 | const Template = $derived(getTemplate(ctx, "field", config)); |
25 | 21 | const Widget = $derived(getWidget(ctx, "select", config)); |
26 | 22 |
|
27 | | - const handlers = makeEventHandlers(ctx, () => |
28 | | - validateField(ctx, config, value) |
29 | | - ); |
| 23 | + const handlers = makeEventHandlers(ctx, () => validateField(ctx, config, value)); |
30 | 24 | const attributes = $derived(selectAttributes(ctx, config, handlers)); |
31 | 25 | const options = $derived( |
32 | | - createOptions2(config.schema, config.idSchema, config.uiOptions, (i) => |
33 | | - makePseudoId(ctx, config.idSchema.$id, i) |
| 26 | + createOptions2( |
| 27 | + multiple ?? config.schema, |
| 28 | + config.idSchema, |
| 29 | + config.uiOptions, |
| 30 | + (i) => makePseudoId(ctx, config.idSchema.$id, i) |
34 | 31 | ) ?? [] |
35 | 32 | ); |
36 | 33 | const errors = $derived(getErrors(ctx, config.idSchema)); |
37 | 34 | </script> |
38 | 35 |
|
39 | 36 | <Template showTitle {value} {config} {errors}> |
40 | | - <Widget {attributes} {config} {errors} bind:value {options} {multiple} /> |
| 37 | + <Widget |
| 38 | + {attributes} |
| 39 | + {config} |
| 40 | + {errors} |
| 41 | + bind:value |
| 42 | + {options} |
| 43 | + multiple={multiple !== undefined} |
| 44 | + /> |
41 | 45 | </Template> |
0 commit comments