@es-joy/jsoe 0.20.0 → 0.20.2

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,15 @@
1
1
  # CHANGES TO `@es-joy/jsoe`
2
2
 
3
+ ## 0.20.2
4
+
5
+ - fix: setting of pull-downs with schemas
6
+
7
+ ## 0.20.1
8
+
9
+ - fix: allow detection of matching schema which are copies and not references
10
+ - fix: should pass original schema to editUI for `schemaContent`
11
+ - fix: refer to original JSON
12
+
3
13
  ## 0.20.0
4
14
 
5
15
  - feat: make `getTypesForSchema` public
@@ -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
 
@@ -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
  },
@@ -2796,7 +2811,9 @@ const buildTypeChoices = ({
2796
2811
  */
2797
2812
  $setTypeNoEditUI ({type, specificSchema}) {
2798
2813
  if (schemaObjs && specificSchema) {
2799
- const idx = schemaObjs.indexOf(specificSchema);
2814
+ const idx = schemaObjs.map((obj) => {
2815
+ return JSON.stringify(obj);
2816
+ }).indexOf(JSON.stringify(specificSchema));
2800
2817
  this.selectedIndex = idx + 1;
2801
2818
  } else {
2802
2819
  this.value = type;
@@ -3377,7 +3394,7 @@ const encapsulateObserver = (stateObj) => {
3377
3394
  buildTypeChoices,
3378
3395
  format,
3379
3396
  specificSchemaObject: schema,
3380
- schemaContent: schema ?? schemaContent,
3397
+ schemaContent,
3381
3398
  value: newValue,
3382
3399
  hasValue: true,
3383
3400
  // Not currently in use but may be convenient for a
@@ -9045,6 +9062,7 @@ function getTypesForSchema (schemaObject, originalJSON) {
9045
9062
  ]);
9046
9063
  default: {
9047
9064
  if ('$ref' in schemaObject) {
9065
+ // console.log('originalJSON', originalJSON, schemaObject.$ref);
9048
9066
  const refObj = resolveJSONPointer({
9049
9067
  obj: originalJSON,
9050
9068
  path: /** @type {import('zodex').SzRef} */ (schemaObject).$ref
@@ -9135,7 +9153,7 @@ const schema = {
9135
9153
  }
9136
9154
  const schemaObjects = [...getTypesForSchema(
9137
9155
  /** @type {import('zodex').SzType} */ (currentSchema),
9138
- /** @type {import('zodex').SzType} */ (currentSchema)
9156
+ /** @type {import('zodex').SzType} */ (stateObj.schemaContent)
9139
9157
  )];
9140
9158
  // console.log(
9141
9159
  // 'vvv', v, currentSchema,
@@ -12961,6 +12979,10 @@ const arrayType = {
12961
12979
  const typeChoices = this.$getTypeChoices();
12962
12980
  typeChoices.$setType({
12963
12981
  type, baseValue: value, bringIntoFocus,
12982
+ specificSchema:
12983
+ schema?.type === 'union' && schemaIdx !== undefined
12984
+ ? schema.options[schemaIdx]
12985
+ : schema,
12964
12986
  avoidReport: true
12965
12987
  });
12966
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;;GAEG;AACH,+BAFU,gBAAgB,CAiUxB;sBA7ZW,CAAC,GAAG,EAAE;IAClB,IAAQ,EAAE,MAAM,CAAC;IACjB,SAAa,CAAC,EAAE,OAAO,cAAc,EAAE,oBAAoB,CAAC;IAC5D,cAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,WAAe,CAAC,EAAE,OAAO,CAAA;CACtB,KAAK,IAAI;+BAIA,CAAC,IAAI,EAAE;IACnB,IAAQ,EAAE,MAAM,CAAC;IACjB,MAAU,EAAE,OAAO,CAAC;IACpB,cAAkB,CAAC,EAAE,OAAO,OAAO,EAAE,MAAM,CAAA;CACxC,KAAK,IAAI;mCAIA,CAAC,IAAI,CAAC,EAAE;IACpB,SAAa,CAAC,EAAE,OAAO,cAAc,EAAE,oBAAoB,CAAC;IAC5D,cAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,YAAgB,CAAC,EAAE,OAAO,2BAA2B,EAAE,WAAW,CAAC;IACnE,WAAe,CAAC,EAAE,OAAO,CAAA;CACtB,KAAK,IAAI;wBAIA,MAAM,IAAI;oCAIV,WAAW,G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CAKf;IACV,WAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,MAAU,EAAE,OAAO,cAAc,EAAE,eAAe,CAAC;IACnD,aAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,KAAS,CAAC,EAAE,OAAO,cAAc,EAAE,oBAAoB,CAAC;IACxD,QAAY,CAAC,EAAE,OAAO,CAAC;IACvB,KAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,aAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,cAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,OAAW,CAAC,EAAE,OAAO,YAAY,EAAE,WAAW,CAAC;IAC/C,OAAW,CAAC,EAAE,OAAO,cAAc,EAAE,OAAO,CAAA;IAC5C,KAAS,CAAC,EAAE,OAAO,YAAY,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.0",
3
+ "version": "0.20.2",
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
@@ -651,7 +652,7 @@ const schema = {
651
652
  }
652
653
  const schemaObjects = [...getTypesForSchema(
653
654
  /** @type {import('zodex').SzType} */ (currentSchema),
654
- /** @type {import('zodex').SzType} */ (currentSchema)
655
+ /** @type {import('zodex').SzType} */ (stateObj.schemaContent)
655
656
  )];
656
657
  // console.log(
657
658
  // 'vvv', v, currentSchema,
@@ -214,7 +214,7 @@ const encapsulateObserver = (stateObj) => {
214
214
  buildTypeChoices,
215
215
  format,
216
216
  specificSchemaObject: schema,
217
- schemaContent: schema ?? schemaContent,
217
+ schemaContent,
218
218
  value: newValue,
219
219
  hasValue: true,
220
220
  // Not currently in use but may be convenient for a
@@ -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
 
@@ -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
  },
@@ -174,7 +189,9 @@ export const buildTypeChoices = ({
174
189
  */
175
190
  $setTypeNoEditUI ({type, specificSchema}) {
176
191
  if (schemaObjs && specificSchema) {
177
- const idx = schemaObjs.indexOf(specificSchema);
192
+ const idx = schemaObjs.map((obj) => {
193
+ return JSON.stringify(obj);
194
+ }).indexOf(JSON.stringify(specificSchema));
178
195
  this.selectedIndex = idx + 1;
179
196
  } else {
180
197
  this.value = type;