@es-joy/jsoe 0.20.1 → 0.20.3

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/CHANGES.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # CHANGES TO `@es-joy/jsoe`
2
2
 
3
+ ## 0.20.3
4
+
5
+ - fix: require object only if no schema
6
+
7
+ ## 0.20.2
8
+
9
+ - fix: setting of pull-downs with schemas
10
+
3
11
  ## 0.20.1
4
12
 
5
13
  - fix: allow detection of matching schema which are copies and not references
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/formats/schema.js"],"names":[],"mappings":"AAmMA;;;;GAIG;AACH,gDAJW,WAAW,gBACX,WAAW,GACT,GAAG,CAAC,WAAW,CAAC,CAgX5B;;0BA3fY,OAAO,OAAO,EAAE,MAAM;2BAGtB,OAAO,qBAAqB,EAAE,YAAY;;;;oBAnD1C,CAAC,IADD,CAAC,CAAC,MAAM,CAAC,CAAC;iCAMV,OAAO,CAChB,IAAI,CAAC,OAAO,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CACrC;AAsiBH,6CAA6C;AAC7C,sBADW,OAAO,eAAe,EAAE,MAAM,CA2MvC"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/formats/schema.js"],"names":[],"mappings":"AAmMA;;;;GAIG;AACH,gDAJW,WAAW,gBACX,WAAW,GACT,GAAG,CAAC,WAAW,CAAC,CAiX5B;;0BA5fY,OAAO,OAAO,EAAE,MAAM;2BAGtB,OAAO,qBAAqB,EAAE,YAAY;;;;oBAnD1C,CAAC,IADD,CAAC,CAAC,MAAM,CAAC,CAAC;iCAMV,OAAO,CAChB,IAAI,CAAC,OAAO,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CACrC;AAuiBH,6CAA6C;AAC7C,sBADW,OAAO,eAAe,EAAE,MAAM,CA2MvC"}
@@ -1 +1 @@
1
- {"version":3,"file":"arrayType.d.ts","sourceRoot":"","sources":["../../src/fundamentalTypes/arrayType.js"],"names":[],"mappings":";sBAaa,MAAM;mDAKN,KAAK,GAAC,OAAO;oCAGb,MAAM,gBAAgB,EAAE;+BAGxB,MAAM,CAAC,iBAAiB,GAAG;IACvC,SAAa,EAAE,OAAO,mBAAmB,EAAE,QAAQ,CAAA;CAChD,CAAC,EAAE;6BAGM,MAAM,IAAI;sCAIV,gBAAgB,EAAE;qCAKlB,IAAI;4BAGJ,MAAM,cAAc,GAAG;IACnC,sBAA0B,EAAE,qBAAqB,CAAC;IAClD,kBAAsB,EAAE,iBAAiB,CAAC;IAC1C,iBAAqB,EAAE,gBAAgB,CAAC;IACxC,iBAAqB,EAAE,gBAAgB,CAAA;CACpC;uBAGS,MAAM,OAAO,CAAC,IAAI,CAAC;2BAKrB;IAAC,WAAW,CAAC,EAAE,IAAI,CAAA;CAAC,KAClB,IAAI;+BAIJ,MAAM,gBAAgB,GAAC,SAAS;uBAIhC,GAAG;AAmBhB;;GAEG;AACH,yBAFU,OAAO,aAAa,EAAE,UAAU,GAAG;IAAC,MAAM,CAAC,EAAE,OAAO,GAAC,SAAS,CAAA;CAAC,CA+1EvE"}
1
+ {"version":3,"file":"arrayType.d.ts","sourceRoot":"","sources":["../../src/fundamentalTypes/arrayType.js"],"names":[],"mappings":";sBAaa,MAAM;mDAKN,KAAK,GAAC,OAAO;oCAGb,MAAM,gBAAgB,EAAE;+BAGxB,MAAM,CAAC,iBAAiB,GAAG;IACvC,SAAa,EAAE,OAAO,mBAAmB,EAAE,QAAQ,CAAA;CAChD,CAAC,EAAE;6BAGM,MAAM,IAAI;sCAIV,gBAAgB,EAAE;qCAKlB,IAAI;4BAGJ,MAAM,cAAc,GAAG;IACnC,sBAA0B,EAAE,qBAAqB,CAAC;IAClD,kBAAsB,EAAE,iBAAiB,CAAC;IAC1C,iBAAqB,EAAE,gBAAgB,CAAC;IACxC,iBAAqB,EAAE,gBAAgB,CAAA;CACpC;uBAGS,MAAM,OAAO,CAAC,IAAI,CAAC;2BAKrB;IAAC,WAAW,CAAC,EAAE,IAAI,CAAA;CAAC,KAClB,IAAI;+BAIJ,MAAM,gBAAgB,GAAC,SAAS;uBAIhC,GAAG;AAmBhB;;GAEG;AACH,yBAFU,OAAO,aAAa,EAAE,UAAU,GAAG;IAAC,MAAM,CAAC,EAAE,OAAO,GAAC,SAAS,CAAA;CAAC,CAm2EvE"}
package/dist/index.js CHANGED
@@ -2634,7 +2634,8 @@ dialogs.setLocale();
2634
2634
  * type: string,
2635
2635
  * baseValue?: import('./formats.js').StructuredCloneValue,
2636
2636
  * bringIntoFocus?: boolean,
2637
- * avoidReport?: boolean
2637
+ * avoidReport?: boolean,
2638
+ * specificSchema?: import('zodex').SzType
2638
2639
  * }) => void} SetType
2639
2640
  */
2640
2641
 
@@ -2744,7 +2745,7 @@ const buildTypeChoices = ({
2744
2745
  schemaContent
2745
2746
  }) => {
2746
2747
  // console.log('format', format, 'state', state, 'path', typeNamespace);
2747
- const typeAndSchemaInfo = requireObject
2748
+ const typeAndSchemaInfo = requireObject && !schemaContent
2748
2749
  ? {
2749
2750
  typeOptions: [types.getOptionForType('object')], schemaObjects: undefined
2750
2751
  }
@@ -2783,8 +2784,22 @@ const buildTypeChoices = ({
2783
2784
  $custom: {
2784
2785
  $getValue,
2785
2786
  /** @type {SetType} */
2786
- $setType ({type, baseValue, bringIntoFocus, avoidReport}) {
2787
- this.value = type;
2787
+ $setType ({
2788
+ type, baseValue, bringIntoFocus, avoidReport, specificSchema
2789
+ }) {
2790
+ if (schemaObjs && specificSchema) {
2791
+ const idx = schemaObjs.map((obj) => {
2792
+ return JSON.stringify(obj);
2793
+ }).indexOf(JSON.stringify(specificSchema));
2794
+ if (idx === -1) {
2795
+ console.log('schemaObjs', schemaObjs, specificSchema);
2796
+ this.value = type;
2797
+ } else {
2798
+ this.selectedIndex = idx + 1;
2799
+ }
2800
+ } else {
2801
+ this.value = type;
2802
+ }
2788
2803
  this.$setStyles();
2789
2804
  this.$addAndValidateEditUI({baseValue, bringIntoFocus, avoidReport});
2790
2805
  },
@@ -9047,6 +9062,7 @@ function getTypesForSchema (schemaObject, originalJSON) {
9047
9062
  ]);
9048
9063
  default: {
9049
9064
  if ('$ref' in schemaObject) {
9065
+ // console.log('originalJSON', originalJSON, schemaObject.$ref);
9050
9066
  const refObj = resolveJSONPointer({
9051
9067
  obj: originalJSON,
9052
9068
  path: /** @type {import('zodex').SzRef} */ (schemaObject).$ref
@@ -12963,6 +12979,10 @@ const arrayType = {
12963
12979
  const typeChoices = this.$getTypeChoices();
12964
12980
  typeChoices.$setType({
12965
12981
  type, baseValue: value, bringIntoFocus,
12982
+ specificSchema:
12983
+ schema?.type === 'union' && schemaIdx !== undefined
12984
+ ? schema.options[schemaIdx]
12985
+ : schema,
12966
12986
  avoidReport: true
12967
12987
  });
12968
12988
  const root = typeChoices.$getTypeRoot();
@@ -3,7 +3,8 @@
3
3
  * type: string,
4
4
  * baseValue?: import('./formats.js').StructuredCloneValue,
5
5
  * bringIntoFocus?: boolean,
6
- * avoidReport?: boolean
6
+ * avoidReport?: boolean,
7
+ * specificSchema?: import('zodex').SzType
7
8
  * }) => void} SetType
8
9
  */
9
10
  /**
@@ -89,6 +90,7 @@ export type SetType = (cfg: {
89
90
  baseValue?: import("./formats.js").StructuredCloneValue;
90
91
  bringIntoFocus?: boolean;
91
92
  avoidReport?: boolean;
93
+ specificSchema?: import("zodex").SzType;
92
94
  }) => void;
93
95
  export type AddTypeAndEditUI = (info: {
94
96
  type: string;
@@ -1 +1 @@
1
- {"version":3,"file":"typeChoices.d.ts","sourceRoot":"","sources":["../src/typeChoices.js"],"names":[],"mappings":"AASA;;;;;;;GAOG;AAEH;;;;;;GAMG;AAEH;;;;;;;GAOG;AAEH;;GAEG;AAEH;;;;;GAKG;AAEH;;;;;;GAMG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;;;GAKG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH;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Y,EAAE,OAAO,CAAA;IACxC,MAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAkB,CAAC,EAAE,OAAO,2BAA2B,EAAE,WAAW,CAAC;IACrE,aAAiB,CAAC,EAAE,OAAO,2BAA2B,EAAE,WAAW,CAAC;CACjE,KACS;IACZ,QAAY,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC;IAChE,QAAY,EAAE,QAAQ,CAAC;IACvB,OAAW,EAAE,OAAO,CAAC;IACrB,cAAkB,EAAE,cAAc,CAAC;IACnC,QAAY,EAAE,QAAQ,CAAA;CACnB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@es-joy/jsoe",
3
- "version": "0.20.1",
3
+ "version": "0.20.3",
4
4
  "type": "module",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./src/index.js",
@@ -555,6 +555,7 @@ export function getTypesForSchema (schemaObject, originalJSON) {
555
555
  ]);
556
556
  default: {
557
557
  if ('$ref' in schemaObject) {
558
+ // console.log('originalJSON', originalJSON, schemaObject.$ref);
558
559
  const refObj = resolveJSONPointer({
559
560
  obj: originalJSON,
560
561
  path: /** @type {import('zodex').SzRef} */ (schemaObject).$ref
@@ -2271,6 +2271,10 @@ const arrayType = {
2271
2271
  const typeChoices = this.$getTypeChoices();
2272
2272
  typeChoices.$setType({
2273
2273
  type, baseValue: value, bringIntoFocus,
2274
+ specificSchema:
2275
+ schema?.type === 'union' && schemaIdx !== undefined
2276
+ ? schema.options[schemaIdx]
2277
+ : schema,
2274
2278
  avoidReport: true
2275
2279
  });
2276
2280
  const root = typeChoices.$getTypeRoot();
@@ -12,7 +12,8 @@ import dialogs from './utils/dialogs.js';
12
12
  * type: string,
13
13
  * baseValue?: import('./formats.js').StructuredCloneValue,
14
14
  * bringIntoFocus?: boolean,
15
- * avoidReport?: boolean
15
+ * avoidReport?: boolean,
16
+ * specificSchema?: import('zodex').SzType
16
17
  * }) => void} SetType
17
18
  */
18
19
 
@@ -122,7 +123,7 @@ export const buildTypeChoices = ({
122
123
  schemaContent
123
124
  }) => {
124
125
  // console.log('format', format, 'state', state, 'path', typeNamespace);
125
- const typeAndSchemaInfo = requireObject
126
+ const typeAndSchemaInfo = requireObject && !schemaContent
126
127
  ? {
127
128
  typeOptions: [types.getOptionForType('object')], schemaObjects: undefined
128
129
  }
@@ -161,8 +162,22 @@ export const buildTypeChoices = ({
161
162
  $custom: {
162
163
  $getValue,
163
164
  /** @type {SetType} */
164
- $setType ({type, baseValue, bringIntoFocus, avoidReport}) {
165
- this.value = type;
165
+ $setType ({
166
+ type, baseValue, bringIntoFocus, avoidReport, specificSchema
167
+ }) {
168
+ if (schemaObjs && specificSchema) {
169
+ const idx = schemaObjs.map((obj) => {
170
+ return JSON.stringify(obj);
171
+ }).indexOf(JSON.stringify(specificSchema));
172
+ if (idx === -1) {
173
+ console.log('schemaObjs', schemaObjs, specificSchema);
174
+ this.value = type;
175
+ } else {
176
+ this.selectedIndex = idx + 1;
177
+ }
178
+ } else {
179
+ this.value = type;
180
+ }
166
181
  this.$setStyles();
167
182
  this.$addAndValidateEditUI({baseValue, bringIntoFocus, avoidReport});
168
183
  },