@es-joy/jsoe 0.18.0 → 0.19.1
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,14 @@
|
|
|
1
1
|
# CHANGES TO `@es-joy/jsoe`
|
|
2
2
|
|
|
3
|
+
## 0.19.1
|
|
4
|
+
|
|
5
|
+
- fix: ensure `originalShape` passed to `dezerialize()` (`$ref`'s require)
|
|
6
|
+
|
|
7
|
+
## 0.19.0
|
|
8
|
+
|
|
9
|
+
- feat: change API for `$setFormat` to accept `schema` and change API to object with
|
|
10
|
+
`valueFormat`, `autoTrigger`, and `schema` properties.
|
|
11
|
+
|
|
3
12
|
## 0.18.0
|
|
4
13
|
|
|
5
14
|
- feat: give option to disable `autoTrigger` for building type choices, e.g.,
|
|
@@ -57,7 +57,11 @@ export function formatAndTypeChoices({ schemas, getSchemaContent, hasValue, sing
|
|
|
57
57
|
$buildTypeChoices: (this: HTMLSelectElement & {
|
|
58
58
|
$buildTypeChoices: any;
|
|
59
59
|
}, autoTrigger?: boolean | undefined) => Promise<void>;
|
|
60
|
-
},
|
|
60
|
+
}, cfg: {
|
|
61
|
+
valueFormat?: import("./formats.js").AvailableFormat;
|
|
62
|
+
autoTrigger: boolean;
|
|
63
|
+
schema?: string;
|
|
64
|
+
}) => Promise<void>;
|
|
61
65
|
$buildTypeChoices: (this: HTMLSelectElement & {
|
|
62
66
|
$buildTypeChoices: any;
|
|
63
67
|
}, autoTrigger?: boolean | undefined) => Promise<void>;
|
|
@@ -68,7 +72,11 @@ export function formatAndTypeChoices({ schemas, getSchemaContent, hasValue, sing
|
|
|
68
72
|
$buildTypeChoices: (this: HTMLSelectElement & {
|
|
69
73
|
$buildTypeChoices: any;
|
|
70
74
|
}, autoTrigger?: boolean | undefined) => Promise<void>;
|
|
71
|
-
},
|
|
75
|
+
}, cfg: {
|
|
76
|
+
valueFormat?: import("./formats.js").AvailableFormat;
|
|
77
|
+
autoTrigger: boolean;
|
|
78
|
+
schema?: string;
|
|
79
|
+
}) => Promise<void>;
|
|
72
80
|
$buildTypeChoices: (this: HTMLSelectElement & {
|
|
73
81
|
$buildTypeChoices: any;
|
|
74
82
|
}, autoTrigger?: boolean | undefined) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatAndTypeChoices.d.ts","sourceRoot":"","sources":["../src/formatAndTypeChoices.js"],"names":[],"mappings":"AAuDA;;;;;GAKG;AAEH;;GAEG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,sJA/BG;IAAuB,OAAO;IACyB,gBAAgB,aAAtD,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC;IAE1B,QAAQ;IAGR,WAAW;IACX,UAAU;IAKX,aAAa;IAEb,cAAc;IACU,OAAO;IACT,KAAK;CAChD,GAAU,OAAO,CAAC;IACpB,aAAiB;;;;
|
|
1
|
+
{"version":3,"file":"formatAndTypeChoices.d.ts","sourceRoot":"","sources":["../src/formatAndTypeChoices.js"],"names":[],"mappings":"AAuDA;;;;;GAKG;AAEH;;GAEG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,sJA/BG;IAAuB,OAAO;IACyB,gBAAgB,aAAtD,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC;IAE1B,QAAQ;IAGR,WAAW;IACX,UAAU;IAKX,aAAa;IAEb,cAAc;IACU,OAAO;IACT,KAAK;CAChD,GAAU,OAAO,CAAC;IACpB,aAAiB;;;;qDAmDC,OAAO,CAAC,IAAI,CAAC;gBAlBf;YACV,WAAe,CAAC,EAAE,OAAO,cAAc,EAAE,eAAe,CAAC;YACzD,WAAe,EAAE,OAAO,CAAC;YACzB,MAAU,CAAC,EAAE,MAAM,CAAA;SAChB,KAIS,OAAO,CAAC,IAAI,CAAC;;;iDAUb,OAAO,CAAC,IAAI,CAAC;MAnDE;IACjC,WAAe,iBAAc;IAC7B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AC7C,sBADW,OAAO,eAAe,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/formats/schema.js"],"names":[],"mappings":";0BA2Da,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"}
|
package/dist/index.js
CHANGED
|
@@ -9151,7 +9151,9 @@ const schema = {
|
|
|
9151
9151
|
// however, if the tested object has extra non-standard properties
|
|
9152
9152
|
schema.unknownKeys = 'strict';
|
|
9153
9153
|
}
|
|
9154
|
-
const dezSchema = dezerialize(schema
|
|
9154
|
+
const dezSchema = dezerialize(schema, {
|
|
9155
|
+
originalShape: stateObj.schemaContent
|
|
9156
|
+
});
|
|
9155
9157
|
const parsed = dezSchema.safeParse(v);
|
|
9156
9158
|
|
|
9157
9159
|
if (schema.type === 'object') {
|
|
@@ -21822,8 +21824,11 @@ async function formatAndTypeChoices ({
|
|
|
21822
21824
|
/**
|
|
21823
21825
|
* Sets the desired format and rebuilds the type choices.
|
|
21824
21826
|
* @callback SetFormat
|
|
21825
|
-
* @param {
|
|
21826
|
-
*
|
|
21827
|
+
* @param {{
|
|
21828
|
+
* valueFormat?: import('./formats.js').AvailableFormat,
|
|
21829
|
+
* autoTrigger: boolean,
|
|
21830
|
+
* schema?: string
|
|
21831
|
+
* }} cfg
|
|
21827
21832
|
* @this {HTMLSelectElement & {
|
|
21828
21833
|
* $buildTypeChoices: TypeChoiceBuilder
|
|
21829
21834
|
* }}
|
|
@@ -21850,8 +21855,15 @@ async function formatAndTypeChoices ({
|
|
|
21850
21855
|
/**
|
|
21851
21856
|
* @type {SetFormat}
|
|
21852
21857
|
*/
|
|
21853
|
-
async $setFormat (valueFormat, autoTrigger) {
|
|
21854
|
-
|
|
21858
|
+
async $setFormat ({valueFormat, autoTrigger, schema}) {
|
|
21859
|
+
if (schema) {
|
|
21860
|
+
const idx = [...this.options].findIndex((option) => {
|
|
21861
|
+
return option.dataset.schema === schema;
|
|
21862
|
+
});
|
|
21863
|
+
this.selectedIndex = idx === -1 ? 0 : idx;
|
|
21864
|
+
} else if (valueFormat) {
|
|
21865
|
+
this.value = valueFormat;
|
|
21866
|
+
}
|
|
21855
21867
|
await this.$buildTypeChoices(autoTrigger);
|
|
21856
21868
|
},
|
|
21857
21869
|
|
package/package.json
CHANGED
|
@@ -118,8 +118,11 @@ export async function formatAndTypeChoices ({
|
|
|
118
118
|
/**
|
|
119
119
|
* Sets the desired format and rebuilds the type choices.
|
|
120
120
|
* @callback SetFormat
|
|
121
|
-
* @param {
|
|
122
|
-
*
|
|
121
|
+
* @param {{
|
|
122
|
+
* valueFormat?: import('./formats.js').AvailableFormat,
|
|
123
|
+
* autoTrigger: boolean,
|
|
124
|
+
* schema?: string
|
|
125
|
+
* }} cfg
|
|
123
126
|
* @this {HTMLSelectElement & {
|
|
124
127
|
* $buildTypeChoices: TypeChoiceBuilder
|
|
125
128
|
* }}
|
|
@@ -146,8 +149,15 @@ export async function formatAndTypeChoices ({
|
|
|
146
149
|
/**
|
|
147
150
|
* @type {SetFormat}
|
|
148
151
|
*/
|
|
149
|
-
async $setFormat (valueFormat, autoTrigger) {
|
|
150
|
-
|
|
152
|
+
async $setFormat ({valueFormat, autoTrigger, schema}) {
|
|
153
|
+
if (schema) {
|
|
154
|
+
const idx = [...this.options].findIndex((option) => {
|
|
155
|
+
return option.dataset.schema === schema;
|
|
156
|
+
});
|
|
157
|
+
this.selectedIndex = idx === -1 ? 0 : idx;
|
|
158
|
+
} else if (valueFormat) {
|
|
159
|
+
this.value = valueFormat;
|
|
160
|
+
}
|
|
151
161
|
await this.$buildTypeChoices(autoTrigger);
|
|
152
162
|
},
|
|
153
163
|
|
package/src/formats/schema.js
CHANGED
|
@@ -667,7 +667,9 @@ const schema = {
|
|
|
667
667
|
// however, if the tested object has extra non-standard properties
|
|
668
668
|
schema.unknownKeys = 'strict';
|
|
669
669
|
}
|
|
670
|
-
const dezSchema = dezerialize(schema
|
|
670
|
+
const dezSchema = dezerialize(schema, {
|
|
671
|
+
originalShape: stateObj.schemaContent
|
|
672
|
+
});
|
|
671
673
|
const parsed = dezSchema.safeParse(v);
|
|
672
674
|
|
|
673
675
|
if (schema.type === 'object') {
|