@bagelink/vue 1.15.333 → 1.15.337

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/vue",
3
3
  "type": "module",
4
- "version": "1.15.333",
4
+ "version": "1.15.337",
5
5
  "description": "Bagel core sdk packages",
6
6
  "author": {
7
7
  "name": "Bagel Studio",
@@ -389,6 +389,13 @@ function getFieldProps(field: FieldBuilder, key: string) {
389
389
  return baseProps
390
390
  }
391
391
 
392
+ function getCustomFieldProps(field: FieldBuilder, key: string) {
393
+ return {
394
+ ...(field._component?.props ?? {}),
395
+ ...getFieldProps(field, key),
396
+ }
397
+ }
398
+
392
399
  function resolveComponent(componentRef: any): any {
393
400
  if (typeof componentRef === 'string') {
394
401
  if (props.components?.[componentRef] != null) {
@@ -556,9 +563,7 @@ defineExpose({
556
563
  <template v-else-if="usesCustomComponent(field)">
557
564
  <component
558
565
  :is="resolveComponent(field._component!.component)"
559
- :model-value="getFieldValue(key)"
560
- v-bind="field._component!.props"
561
- @update:model-value="(val: any) => updateField(key, val, field)"
566
+ v-bind="getCustomFieldProps(field, key)"
562
567
  />
563
568
  </template>
564
569
 
@@ -759,6 +759,7 @@ interface JSONSchemaProperty {
759
759
  'title'?: string
760
760
  'description'?: string
761
761
  'default'?: any
762
+ 'const'?: any
762
763
  'enum'?: any[]
763
764
  'format'?: string
764
765
  'minimum'?: number
@@ -1065,6 +1066,27 @@ function createFieldFromProperty(
1065
1066
  field = $.text(config)
1066
1067
  }
1067
1068
 
1069
+ // Rendering is orthogonal to semantics: a checkbox may use a branded
1070
+ // component while remaining a checkbox for validation and serialization.
1071
+ if (
1072
+ xUi.component
1073
+ && fieldType !== 'component'
1074
+ && fieldType !== 'display'
1075
+ ) {
1076
+ field._component = {
1077
+ component: xUi.component,
1078
+ props: xUi.componentProps || {},
1079
+ }
1080
+ }
1081
+
1082
+ if (resolvedProp.const !== undefined) {
1083
+ field.validate(value =>
1084
+ value === resolvedProp.const
1085
+ ? true
1086
+ : config.requiredMessage || 'form.required'
1087
+ )
1088
+ }
1089
+
1068
1090
  // Apply class
1069
1091
  if (xUi.class) {
1070
1092
  field.class(xUi.class)
@@ -101,6 +101,7 @@ export interface FormField {
101
101
  export interface JSONSchemaProperty {
102
102
  type?: string | string[]
103
103
  items?: JSONSchemaProperty
104
+ const?: any
104
105
  title?: string
105
106
  description?: string
106
107
  format?: string
@@ -354,7 +355,12 @@ export function fieldsToSchema(fields: FormField[]): JSONSchemaObject {
354
355
  if (field.validation?.pattern !== undefined) prop.pattern = field.validation.pattern
355
356
 
356
357
  // Required
357
- if (field.required) required.push(field.key)
358
+ if (field.required) {
359
+ required.push(field.key)
360
+ // Required checkboxes represent explicit acceptance, not merely
361
+ // presence of a boolean key.
362
+ if (field.type === 'checkbox') prop.const = true
363
+ }
358
364
  }
359
365
 
360
366
  // Placeholder