@bagelink/vue 1.12.13 → 1.12.16

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.12.13",
4
+ "version": "1.12.16",
5
5
  "description": "Bagel core sdk packages",
6
6
  "author": {
7
7
  "name": "Bagel Studio",
@@ -60,7 +60,7 @@
60
60
  "@types/leaflet": "^1.9.18",
61
61
  "@types/signature_pad": "^4.0.0",
62
62
  "swiper": "^12.0.3",
63
- "vue": "^3.5.16",
63
+ "vue": "^3.5.32",
64
64
  "vue-component-type-helpers": "^2.2.10"
65
65
  },
66
66
  "peerDependencies": {
@@ -90,7 +90,7 @@
90
90
  "signature_pad": "^5.0.9",
91
91
  "vue-i18n": "^11.2.8",
92
92
  "vue-toastification": "^2.0.0-rc.5",
93
- "@bagelink/utils": "1.12.13"
93
+ "@bagelink/utils": "1.12.16"
94
94
  },
95
95
  "scripts": {
96
96
  "dev": "tsx watch src/index.ts",
@@ -131,6 +131,10 @@ export interface SchemaDefinition<T extends Record<string, any> = Record<string,
131
131
 
132
132
  if: (condition: string) => SchemaDefinition<T>
133
133
  class: (className: string) => SchemaDefinition<T>
134
+ /** Set default values for multiple fields at once. Field-level defaults take precedence. */
135
+ defaults: (values: Partial<T>) => SchemaDefinition<T>
136
+ /** Returns the default values extracted from field configs. */
137
+ getDefaults: () => Partial<T>
134
138
  toJSONSchema: () => any
135
139
  }
136
140
 
@@ -479,6 +483,25 @@ class Schema<T extends Record<string, any> = Record<string, any>> implements Sch
479
483
  return this
480
484
  }
481
485
 
486
+ defaults(values: Partial<T>): this {
487
+ for (const [key, value] of Object.entries(values)) {
488
+ if (this._fields[key] && this._fields[key]._config.default === undefined) {
489
+ this._fields[key]._config.default = value
490
+ }
491
+ }
492
+ return this
493
+ }
494
+
495
+ getDefaults(): Partial<T> {
496
+ const result: Record<string, unknown> = {}
497
+ for (const [key, field] of Object.entries(this._fields)) {
498
+ if (field._config.default !== undefined) {
499
+ result[key] = field._config.default
500
+ }
501
+ }
502
+ return result as Partial<T>
503
+ }
504
+
482
505
  toJSONSchema(): any {
483
506
  const properties: Record<string, any> = {}
484
507
  const requiredFields: string[] = []