@es-joy/jsoe 0.20.5 → 0.20.6
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 +8 -0
- package/badges/coverage-badge.svg +1 -1
- package/dist/formatAndTypeChoices.d.ts.map +1 -1
- package/dist/formats/schema.d.ts.map +1 -1
- package/dist/fundamentalTypes/arrayType.d.ts.map +1 -1
- package/dist/fundamentalTypes/nativeEnumType.d.ts.map +1 -1
- package/dist/fundamentalTypes/neverType.d.ts.map +1 -1
- package/dist/index.js +66 -36
- package/dist/superTypes/buffersourceType.d.ts.map +1 -1
- package/dist/superTypes/dommatrixType.d.ts.map +1 -1
- package/dist/superTypes/dompointType.d.ts.map +1 -1
- package/dist/superTypes/domrectType.d.ts.map +1 -1
- package/dist/superTypes/errorsSpecialType.d.ts.map +1 -1
- package/dist/typeChoices.d.ts.map +1 -1
- package/package.json +8 -7
- package/src/formatAndTypeChoices.js +5 -3
- package/src/formats/schema.js +20 -12
- package/src/fundamentalTypes/arrayType.js +22 -9
- package/src/fundamentalTypes/nativeEnumType.js +6 -4
- package/src/fundamentalTypes/neverType.js +0 -5
- package/src/superTypes/buffersourceType.js +1 -0
- package/src/superTypes/dommatrixType.js +1 -0
- package/src/superTypes/dompointType.js +1 -0
- package/src/superTypes/domrectType.js +1 -0
- package/src/superTypes/errorsSpecialType.js +2 -0
- package/src/typeChoices.js +6 -2
- package/src/types.js +1 -1
package/CHANGES.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# CHANGES TO `@es-joy/jsoe`
|
|
2
2
|
|
|
3
|
+
## 0.20.6
|
|
4
|
+
|
|
5
|
+
- fix(`recordType`): failing `toValue` conversion
|
|
6
|
+
- fix(`objectType`): resume reporting duplicate property names
|
|
7
|
+
- fix(schema demo): allow for non-schema choices
|
|
8
|
+
- fix: ensure tooltip exists for base property if just an array/set
|
|
9
|
+
element description
|
|
10
|
+
|
|
3
11
|
## 0.20.5
|
|
4
12
|
|
|
5
13
|
- fix: supply flattened schema for type choices
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="428" height="20"><defs><style>text{font-size:11px;font-family:Verdana,DejaVu Sans,Geneva,sans-serif}text.shadow{fill:#010101;fill-opacity:.3}text.high{fill:#fff}</style><linearGradient id="smooth" x2="0" y2="100%"><stop offset="0" stop-color="#aaa" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="round"><rect width="100%" height="100%" rx="3" fill="#fff"/></mask></defs><g id="bg" mask="url(#round)"><path fill="orange" stroke="#000" d="M0 0h120v20H0zM120 0h109v20H120zM229 0h87v20h-87zM316 0h112v20H316z"/><path fill="url(#smooth)" d="M0 0h428v20H0z"/></g><g id="fg"><text class="shadow" x="5.5" y="15">Statements
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="428" height="20"><defs><style>text{font-size:11px;font-family:Verdana,DejaVu Sans,Geneva,sans-serif}text.shadow{fill:#010101;fill-opacity:.3}text.high{fill:#fff}</style><linearGradient id="smooth" x2="0" y2="100%"><stop offset="0" stop-color="#aaa" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="round"><rect width="100%" height="100%" rx="3" fill="#fff"/></mask></defs><g id="bg" mask="url(#round)"><path fill="orange" stroke="#000" d="M0 0h120v20H0zM120 0h109v20H120zM229 0h87v20h-87zM316 0h112v20H316z"/><path fill="url(#smooth)" d="M0 0h428v20H0z"/></g><g id="fg"><text class="shadow" x="5.5" y="15">Statements 99.85%</text><text class="high" x="5" y="14">Statements 99.85%</text><text class="shadow" x="125.5" y="15">Branches 98.12%</text><text class="high" x="125" y="14">Branches 98.12%</text><text class="shadow" x="234.5" y="15">Lines 99.84%</text><text class="high" x="234" y="14">Lines 99.84%</text><text class="shadow" x="321.5" y="15">Functions 99.87%</text><text class="high" x="321" y="14">Functions 99.87%</text></g></svg>
|
|
@@ -1 +1 @@
|
|
|
1
|
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AE,OAAO,cAAc,EAAE,OAAO,CAAC;IAC5C,KAAS,EAAE,OAAO,YAAY,EAAE,OAAO,CAAA;CACpC,CAAC,CA6OJ;AAxTM,oFAPJ;IAAuB,OAAO;IACT,cAAc;IACb,UAAU;CAGhC,GAAU,gBAAgB,CAiC5B;+BAIU,OAAO,cAAc,EAAE,oBAAoB,YAC3C,OAAO,YAAY,EAAE,WAAW,KAC9B,OAAO,CAAC,IAAI,CAAC;0BAIb,OAAO,qBAAqB,EAAE,WAAW;mCAvDzC,cAAc,GAAC,IAAI;oBALZ,cAAc;kBADhB,YAAY"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/formats/schema.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/formats/schema.js"],"names":[],"mappings":"AAuMA;;;;GAIG;AACH,gDAJW,WAAW,gBACX,WAAW,GACT,GAAG,CAAC,WAAW,CAAC,CAiX5B;;0BAjgBY,OAAO,OAAO,EAAE,MAAM;2BAGtB,OAAO,qBAAqB,EAAE,YAAY;;;;oBAlD1C,CAAC,IADD,CAAC,CAAC,MAAM,CAAC,CAAC;iCAMV,OAAO,CAChB,IAAI,CAAC,OAAO,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CACrC;AA2iBH,6CAA6C;AAC7C,sBADW,OAAO,eAAe,EAAE,MAAM,CA8MvC"}
|
|
@@ -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;qCAKl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
1
|
-
{"version":3,"file":"nativeEnumType.d.ts","sourceRoot":"","sources":["../../src/fundamentalTypes/nativeEnumType.js"],"names":[],"mappings":";AAIA;;GAEG;AACH,8BAFU,OAAO,aAAa,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"nativeEnumType.d.ts","sourceRoot":"","sources":["../../src/fundamentalTypes/nativeEnumType.js"],"names":[],"mappings":";AAIA;;GAEG;AACH,8BAFU,OAAO,aAAa,EAAE,UAAU,CAqJxC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"neverType.d.ts","sourceRoot":"","sources":["../../src/fundamentalTypes/neverType.js"],"names":[],"mappings":";AAEA;;GAEG;AACH,yBAFU,OAAO,aAAa,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"neverType.d.ts","sourceRoot":"","sources":["../../src/fundamentalTypes/neverType.js"],"names":[],"mappings":";AAEA;;GAEG;AACH,yBAFU,OAAO,aAAa,EAAE,UAAU,CA2CxC"}
|
package/dist/index.js
CHANGED
|
@@ -2792,7 +2792,6 @@ const buildTypeChoices = ({
|
|
|
2792
2792
|
return JSON.stringify(obj);
|
|
2793
2793
|
}).indexOf(JSON.stringify(specificSchema));
|
|
2794
2794
|
if (idx === -1) {
|
|
2795
|
-
console.log('schemaObjs', schemaObjs, specificSchema);
|
|
2796
2795
|
this.value = type;
|
|
2797
2796
|
} else {
|
|
2798
2797
|
this.selectedIndex = idx + 1;
|
|
@@ -2847,8 +2846,9 @@ const buildTypeChoices = ({
|
|
|
2847
2846
|
},
|
|
2848
2847
|
|
|
2849
2848
|
/** @type {AddAndValidateEditUI} */
|
|
2850
|
-
$addAndValidateEditUI ({
|
|
2849
|
+
$addAndValidateEditUI (/* istanbul ignore next -- Backup */ {
|
|
2851
2850
|
baseValue, bringIntoFocus, schemaObject, avoidReport
|
|
2851
|
+
/* istanbul ignore next -- Backup */
|
|
2852
2852
|
} = {}) {
|
|
2853
2853
|
const {value: type} = this;
|
|
2854
2854
|
|
|
@@ -2885,8 +2885,12 @@ const buildTypeChoices = ({
|
|
|
2885
2885
|
// Avoid JSON references by using this by default (or only?)
|
|
2886
2886
|
(schemaObjs?.[sel.selectedIndex - 1]) ??
|
|
2887
2887
|
|
|
2888
|
+
// eslint-disable-next-line @stylistic/max-len -- Long
|
|
2889
|
+
/* istanbul ignore next -- Can probably remove as `schemaObjs` will be set */
|
|
2888
2890
|
(schemaContent?.type === 'union' && schemaIdx !== undefined
|
|
2891
|
+
/* istanbul ignore next -- Can probably remove */
|
|
2889
2892
|
? schemaContent.options[schemaIdx]
|
|
2893
|
+
// This is probably just `undefined` by here
|
|
2890
2894
|
: schemaContent),
|
|
2891
2895
|
schemaFallingBack: Boolean(!schemaObject && schemaContent)
|
|
2892
2896
|
});
|
|
@@ -8580,10 +8584,12 @@ const zodexToStructuredCloningTypeMap = new Map([
|
|
|
8580
8584
|
* @returns {ZodexSchema}
|
|
8581
8585
|
*/
|
|
8582
8586
|
function mergeSchema (leftItem, rightItem) {
|
|
8587
|
+
/* istanbul ignore if -- Guard */
|
|
8583
8588
|
if (leftItem.type !== 'object') {
|
|
8584
8589
|
console.log('leftItem', leftItem);
|
|
8585
8590
|
throw new Error('Unexpected leftItem of type ' + leftItem.type);
|
|
8586
8591
|
}
|
|
8592
|
+
/* istanbul ignore if -- Guard */
|
|
8587
8593
|
if (rightItem.type !== 'object') {
|
|
8588
8594
|
console.log('rightItem', rightItem);
|
|
8589
8595
|
throw new Error('Unexpected rightItem of type ' + rightItem.type);
|
|
@@ -8610,6 +8616,7 @@ function mergeSchema (leftItem, rightItem) {
|
|
|
8610
8616
|
|
|
8611
8617
|
newLeftObj[prop] = val && typeof val === 'object'
|
|
8612
8618
|
? copyObject(val)
|
|
8619
|
+
/* istanbul ignore next -- Guard */
|
|
8613
8620
|
: val;
|
|
8614
8621
|
}
|
|
8615
8622
|
}
|
|
@@ -8626,9 +8633,11 @@ function mergeSchema (leftItem, rightItem) {
|
|
|
8626
8633
|
}
|
|
8627
8634
|
/** @type {NestedObject} */ (
|
|
8628
8635
|
newLeftObj.properties
|
|
8629
|
-
)[prop] =
|
|
8630
|
-
|
|
8631
|
-
|
|
8636
|
+
)[prop] = /* istanbul ignore next -- Guard */
|
|
8637
|
+
val && typeof val === 'object'
|
|
8638
|
+
? copyObject(val)
|
|
8639
|
+
/* istanbul ignore next -- Guard */
|
|
8640
|
+
: val;
|
|
8632
8641
|
}
|
|
8633
8642
|
|
|
8634
8643
|
return newLeftObj;
|
|
@@ -9090,6 +9099,7 @@ const schema = {
|
|
|
9090
9099
|
) {
|
|
9091
9100
|
// eslint-disable-next-line prefer-const -- Convenient
|
|
9092
9101
|
let [parentSchema, parentSchemaIdx] = parentSchemaInfo ?? [];
|
|
9102
|
+
/* istanbul ignore if -- Guard */
|
|
9093
9103
|
if (!stateObj) {
|
|
9094
9104
|
throw new Error('State object expected for schema');
|
|
9095
9105
|
}
|
|
@@ -9136,12 +9146,13 @@ const schema = {
|
|
|
9136
9146
|
parentSchema
|
|
9137
9147
|
).inner;
|
|
9138
9148
|
break;
|
|
9139
|
-
//
|
|
9140
|
-
|
|
9141
|
-
|
|
9142
|
-
|
|
9143
|
-
|
|
9144
|
-
|
|
9149
|
+
// Todo: Reenable
|
|
9150
|
+
// // eslint-disable-next-line sonarjs/no-duplicated-branches -- Maintenance
|
|
9151
|
+
// case 'promise':
|
|
9152
|
+
// currentSchema = /** @type {import('zodex').SzPromise} */ (
|
|
9153
|
+
// parentSchema
|
|
9154
|
+
// ).value;
|
|
9155
|
+
// break;
|
|
9145
9156
|
case 'tuple':
|
|
9146
9157
|
currentSchema = /** @type {import('zodex').SzTuple} */ (
|
|
9147
9158
|
parentSchema
|
|
@@ -9151,6 +9162,8 @@ const schema = {
|
|
|
9151
9162
|
).rest;
|
|
9152
9163
|
break;
|
|
9153
9164
|
}
|
|
9165
|
+
|
|
9166
|
+
/* istanbul ignore if -- Guard */
|
|
9154
9167
|
if (!currentSchema) {
|
|
9155
9168
|
return {type: typesonType};
|
|
9156
9169
|
}
|
|
@@ -9182,9 +9195,6 @@ const schema = {
|
|
|
9182
9195
|
}
|
|
9183
9196
|
// console.log('parsed', parsed.success, v, schema);
|
|
9184
9197
|
if (parsed.success) {
|
|
9185
|
-
if (currentSchema.type === 'any' && schema.description) {
|
|
9186
|
-
schema.description += ' (any)';
|
|
9187
|
-
}
|
|
9188
9198
|
let type = zodexToStructuredCloningTypeMap.get(schema.type);
|
|
9189
9199
|
if (!type && schema.type === 'effect') {
|
|
9190
9200
|
type = /** @type {import('../types.js').AvailableType} */ (
|
|
@@ -9226,7 +9236,9 @@ const schema = {
|
|
|
9226
9236
|
return {type: typesonType};
|
|
9227
9237
|
},
|
|
9228
9238
|
|
|
9239
|
+
/* istanbul ignore next -- Not in use */
|
|
9229
9240
|
types () {
|
|
9241
|
+
/* istanbul ignore next -- Not in use */
|
|
9230
9242
|
return structuredCloning.types();
|
|
9231
9243
|
},
|
|
9232
9244
|
|
|
@@ -10749,9 +10761,10 @@ const arrayType = {
|
|
|
10749
10761
|
const state = sparse
|
|
10750
10762
|
? 'arrayNonindexKeys'
|
|
10751
10763
|
// ? 'sparseArrays'
|
|
10752
|
-
: (this.array ? 'array' : 'object');
|
|
10764
|
+
: (this.array && !this.record ? 'array' : 'object');
|
|
10753
10765
|
/** @type {{[key: (string|number)]: any}} */
|
|
10754
|
-
const retObj = this.array ? [] : {};
|
|
10766
|
+
const retObj = this.array && !this.record ? [] : {};
|
|
10767
|
+
/* istanbul ignore next -- Unreachable? */
|
|
10755
10768
|
let stringVal = innerContents !== undefined
|
|
10756
10769
|
? innerContents
|
|
10757
10770
|
/* istanbul ignore next -- Unreachable? */
|
|
@@ -10778,7 +10791,7 @@ const arrayType = {
|
|
|
10778
10791
|
}
|
|
10779
10792
|
return false;
|
|
10780
10793
|
};
|
|
10781
|
-
if (this.array) {
|
|
10794
|
+
if (this.array && !this.record) {
|
|
10782
10795
|
let idx = 0;
|
|
10783
10796
|
const parse = () => {
|
|
10784
10797
|
if (!stringVal) {
|
|
@@ -11473,7 +11486,11 @@ const arrayType = {
|
|
|
11473
11486
|
input.setCustomValidity(
|
|
11474
11487
|
invalidStr
|
|
11475
11488
|
);
|
|
11476
|
-
|
|
11489
|
+
if (invalidStr) {
|
|
11490
|
+
// Might not want this as changes focus; if ok, will hopefully be
|
|
11491
|
+
// marked as such elsewhere
|
|
11492
|
+
input.reportValidity();
|
|
11493
|
+
}
|
|
11477
11494
|
}
|
|
11478
11495
|
return invalidStr; // Don't give a chance to become valid
|
|
11479
11496
|
});
|
|
@@ -11690,8 +11707,11 @@ const arrayType = {
|
|
|
11690
11707
|
? elementDesc ?? 'Item'
|
|
11691
11708
|
: {'#': required
|
|
11692
11709
|
? [
|
|
11693
|
-
['b', {
|
|
11694
|
-
|
|
11710
|
+
['b', {
|
|
11711
|
+
className,
|
|
11712
|
+
title: (elementDesc ?? description) ? propName : undefined
|
|
11713
|
+
}, [
|
|
11714
|
+
elementDesc ?? description ?? propName
|
|
11695
11715
|
]]
|
|
11696
11716
|
]
|
|
11697
11717
|
: [
|
|
@@ -11712,6 +11732,7 @@ const arrayType = {
|
|
|
11712
11732
|
]?.description ?? propName
|
|
11713
11733
|
: /** @type {import('zodex').SzObject} */ (
|
|
11714
11734
|
specificSchemaObject
|
|
11735
|
+
/* istanbul ignore next -- Guard */
|
|
11715
11736
|
)?.catchall?.description ?? propName
|
|
11716
11737
|
]]
|
|
11717
11738
|
]
|
|
@@ -12634,6 +12655,7 @@ const arrayType = {
|
|
|
12634
12655
|
*/
|
|
12635
12656
|
async change () {
|
|
12636
12657
|
if (preventAdding()) {
|
|
12658
|
+
/* istanbul ignore next -- Just a guard */
|
|
12637
12659
|
this.value = this.$oldvalue ?? this.defaultValue;
|
|
12638
12660
|
return;
|
|
12639
12661
|
}
|
|
@@ -13060,6 +13082,7 @@ const arrayType = {
|
|
|
13060
13082
|
Object.entries(
|
|
13061
13083
|
/** @type {import('zodex').SzObject} */ (
|
|
13062
13084
|
specificSchemaObject
|
|
13085
|
+
/* istanbul ignore next -- Should always have `properties` */
|
|
13063
13086
|
).properties ?? {}
|
|
13064
13087
|
)
|
|
13065
13088
|
) {
|
|
@@ -13087,10 +13110,12 @@ const arrayType = {
|
|
|
13087
13110
|
}
|
|
13088
13111
|
}
|
|
13089
13112
|
break;
|
|
13090
|
-
}
|
|
13113
|
+
}
|
|
13114
|
+
// case 'array': // None with schemas?
|
|
13115
|
+
case 'arrayNonindexKeys': {
|
|
13091
13116
|
const {minLength = 0} = /** @type {import('zodex').SzArray} */ (
|
|
13092
13117
|
specificSchemaObject
|
|
13093
|
-
)
|
|
13118
|
+
);
|
|
13094
13119
|
const arrayLengthInput =
|
|
13095
13120
|
/** @type {HTMLInputElement & {$oldvalue: string}} */ (
|
|
13096
13121
|
$e(div, '.arrayLength')
|
|
@@ -13107,7 +13132,7 @@ const arrayType = {
|
|
|
13107
13132
|
if (!schemaFallingBack) {
|
|
13108
13133
|
const {minSize = 0} = /** @type {import('zodex').SzSet} */ (
|
|
13109
13134
|
specificSchemaObject
|
|
13110
|
-
)
|
|
13135
|
+
);
|
|
13111
13136
|
for (let i = 0; i < minSize; i++) {
|
|
13112
13137
|
div.$addArrayElement({required: true});
|
|
13113
13138
|
}
|
|
@@ -14639,6 +14664,7 @@ const errorsSpecialType = {
|
|
|
14639
14664
|
String.raw`)\((?<innerContent>.*)\)$`, 'u'
|
|
14640
14665
|
),
|
|
14641
14666
|
toValue (s, rootInfo) {
|
|
14667
|
+
/* istanbul ignore next -- Just a guard */
|
|
14642
14668
|
const {groups: {
|
|
14643
14669
|
errorClass
|
|
14644
14670
|
/* istanbul ignore next -- Should always be found */
|
|
@@ -14942,6 +14968,7 @@ const errorsSpecialType = {
|
|
|
14942
14968
|
).textContent = aggregateErrorsContents.hidden ? '+' : '-';
|
|
14943
14969
|
}}}, ['-']],
|
|
14944
14970
|
['div', {class: 'aggregateErrorsContents'}, [
|
|
14971
|
+
/* istanbul ignore next -- Just a guard */
|
|
14945
14972
|
(o.errors
|
|
14946
14973
|
? (() => {
|
|
14947
14974
|
const [div] = arrayType.viewUI({
|
|
@@ -17753,6 +17780,7 @@ const domrectType = {
|
|
|
17753
17780
|
return ['DOMRect', 'DOMRectReadOnly'].includes(toStringTag(x));
|
|
17754
17781
|
},
|
|
17755
17782
|
toValue (s, rootInfo) {
|
|
17783
|
+
/* istanbul ignore next -- Should always be found */
|
|
17756
17784
|
const {groups: {
|
|
17757
17785
|
domRectClass
|
|
17758
17786
|
/* istanbul ignore next -- Should always be found */
|
|
@@ -17932,6 +17960,7 @@ const dompointType = {
|
|
|
17932
17960
|
return ['DOMPoint', 'DOMPointReadOnly'].includes(toStringTag(x));
|
|
17933
17961
|
},
|
|
17934
17962
|
toValue (s, rootInfo) {
|
|
17963
|
+
/* istanbul ignore next -- Should always be found */
|
|
17935
17964
|
const {groups: {
|
|
17936
17965
|
domPointClass
|
|
17937
17966
|
/* istanbul ignore next -- Should always be found */
|
|
@@ -18106,6 +18135,7 @@ const dommatrixType = {
|
|
|
18106
18135
|
return ['DOMMatrix', 'DOMMatrixReadOnly'].includes(toStringTag(x));
|
|
18107
18136
|
},
|
|
18108
18137
|
toValue (s, rootInfo) {
|
|
18138
|
+
/* istanbul ignore next -- Should always be found */
|
|
18109
18139
|
const {groups: {
|
|
18110
18140
|
domMatrixClass
|
|
18111
18141
|
/* istanbul ignore next -- Should always be found */
|
|
@@ -18651,6 +18681,7 @@ const buffersourceType = {
|
|
|
18651
18681
|
return bufferSourceClasses.has(toStringTag(x));
|
|
18652
18682
|
},
|
|
18653
18683
|
toValue (s, rootInfo) {
|
|
18684
|
+
/* istanbul ignore next -- Should always be found */
|
|
18654
18685
|
const {groups: {
|
|
18655
18686
|
bufferSourceClass
|
|
18656
18687
|
/* istanbul ignore next -- Should always be found */
|
|
@@ -20131,16 +20162,11 @@ const neverType = {
|
|
|
20131
20162
|
/* istanbul ignore next -- Back-up in case shows */
|
|
20132
20163
|
return false;
|
|
20133
20164
|
},
|
|
20134
|
-
/* istanbul ignore next -- Back-up in case shows */
|
|
20135
20165
|
toValue (/* _s */) {
|
|
20136
|
-
/* istanbul ignore next -- Back-up in case shows */
|
|
20137
20166
|
throw new Error('Cannot convert to value');
|
|
20138
20167
|
},
|
|
20139
|
-
/* istanbul ignore next -- Back-up in case shows */
|
|
20140
20168
|
getValue () {
|
|
20141
|
-
/* istanbul ignore next -- Back-up in case shows */
|
|
20142
20169
|
return /** @type {import('../types.js').ToValue} */ (
|
|
20143
|
-
/* istanbul ignore next -- Back-up in case shows */
|
|
20144
20170
|
this.toValue
|
|
20145
20171
|
)('');
|
|
20146
20172
|
},
|
|
@@ -20338,7 +20364,7 @@ const nativeEnumType = {
|
|
|
20338
20364
|
return {value};
|
|
20339
20365
|
},
|
|
20340
20366
|
getInput ({root}) {
|
|
20341
|
-
return /** @type {HTMLTextAreaElement} */ ($e(root, 'input'));
|
|
20367
|
+
return /** @type {HTMLTextAreaElement} */ ($e(root, 'input.nativeEnumKey'));
|
|
20342
20368
|
},
|
|
20343
20369
|
setValue ({root, value}) {
|
|
20344
20370
|
const input = /**
|
|
@@ -20351,9 +20377,11 @@ const nativeEnumType = {
|
|
|
20351
20377
|
).find(([, val]) => {
|
|
20352
20378
|
return val === value;
|
|
20353
20379
|
})?.[0] ?? '';
|
|
20354
|
-
|
|
20355
|
-
|
|
20356
|
-
|
|
20380
|
+
if (input.value) { // If key was found, the value is ok
|
|
20381
|
+
/** @type {HTMLSpanElement} */ (
|
|
20382
|
+
$e(root, '.enumeratedValue')
|
|
20383
|
+
).textContent = value;
|
|
20384
|
+
}
|
|
20357
20385
|
},
|
|
20358
20386
|
getValue ({root}) {
|
|
20359
20387
|
const {value, $schemaNativeEnumValues} =
|
|
@@ -21230,7 +21258,7 @@ class Types {
|
|
|
21230
21258
|
valid
|
|
21231
21259
|
? ''
|
|
21232
21260
|
/* istanbul ignore next -- Should always have a message */
|
|
21233
|
-
: message || 'Invalid'
|
|
21261
|
+
: (message || 'Invalid')
|
|
21234
21262
|
);
|
|
21235
21263
|
|
|
21236
21264
|
// We don't want a focus as `reportValidity` does in at least
|
|
@@ -21658,9 +21686,11 @@ async function formatAndTypeChoices ({
|
|
|
21658
21686
|
requireObject: hasKeyPath,
|
|
21659
21687
|
objectHasValue: hasValue,
|
|
21660
21688
|
schema,
|
|
21661
|
-
schemaContent:
|
|
21662
|
-
|
|
21663
|
-
|
|
21689
|
+
schemaContent: schema
|
|
21690
|
+
? await getSchemaContent?.(
|
|
21691
|
+
/** @type {string} */ (schema)
|
|
21692
|
+
)
|
|
21693
|
+
: undefined
|
|
21664
21694
|
}).domArray}, typesHolder);
|
|
21665
21695
|
}
|
|
21666
21696
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffersourceType.d.ts","sourceRoot":"","sources":["../../src/superTypes/buffersourceType.js"],"names":[],"mappings":";yBA4Da,WAAW,GAAC,YAAY,GAAC,mBAAmB,GACxD,YAAgB,GAAC,aAAa,GAAC,YAAY,GAAC,aAAa,GACzD,cAAkB,GAAC,cAAc,GAAC,eAAe,GACjD,gBAAoB;iCAIR,SAAS,GAAC,UAAU,GAAC,iBAAiB,GAC9C,UAAU,GAAC,WAAW,GAAC,UAAU,GAAC,WAAW,GAC9C,YAAY,GAAC,YAAY,GAAC,aAAa,GACvC,cAAc;AAmDlB;;GAEG;AACH,gCAFU,OAAO,aAAa,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"buffersourceType.d.ts","sourceRoot":"","sources":["../../src/superTypes/buffersourceType.js"],"names":[],"mappings":";yBA4Da,WAAW,GAAC,YAAY,GAAC,mBAAmB,GACxD,YAAgB,GAAC,aAAa,GAAC,YAAY,GAAC,aAAa,GACzD,cAAkB,GAAC,cAAc,GAAC,eAAe,GACjD,gBAAoB;iCAIR,SAAS,GAAC,UAAU,GAAC,iBAAiB,GAC9C,UAAU,GAAC,WAAW,GAAC,UAAU,GAAC,WAAW,GAC9C,YAAY,GAAC,YAAY,GAAC,aAAa,GACvC,cAAc;AAmDlB;;GAEG;AACH,gCAFU,OAAO,aAAa,EAAE,eAAe,CA22C7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dommatrixType.d.ts","sourceRoot":"","sources":["../../src/superTypes/dommatrixType.js"],"names":[],"mappings":";AAKA;;GAEG;AACH,6BAFU,OAAO,aAAa,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"dommatrixType.d.ts","sourceRoot":"","sources":["../../src/superTypes/dommatrixType.js"],"names":[],"mappings":";AAKA;;GAEG;AACH,6BAFU,OAAO,aAAa,EAAE,eAAe,CAoa7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dompointType.d.ts","sourceRoot":"","sources":["../../src/superTypes/dompointType.js"],"names":[],"mappings":";AAKA;;GAEG;AACH,4BAFU,OAAO,aAAa,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"dompointType.d.ts","sourceRoot":"","sources":["../../src/superTypes/dompointType.js"],"names":[],"mappings":";AAKA;;GAEG;AACH,4BAFU,OAAO,aAAa,EAAE,eAAe,CA0K7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domrectType.d.ts","sourceRoot":"","sources":["../../src/superTypes/domrectType.js"],"names":[],"mappings":";AAKA;;GAEG;AACH,2BAFU,OAAO,aAAa,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"domrectType.d.ts","sourceRoot":"","sources":["../../src/superTypes/domrectType.js"],"names":[],"mappings":";AAKA;;GAEG;AACH,2BAFU,OAAO,aAAa,EAAE,eAAe,CA+K7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorsSpecialType.d.ts","sourceRoot":"","sources":["../../src/superTypes/errorsSpecialType.js"],"names":[],"mappings":";sBAOa,MAAM;+BAaN,gBAAgB,GAAC,yBAAyB;AAyBvD;;GAEG;AACH,iCAFU,OAAO,aAAa,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"errorsSpecialType.d.ts","sourceRoot":"","sources":["../../src/superTypes/errorsSpecialType.js"],"names":[],"mappings":";sBAOa,MAAM;+BAaN,gBAAgB,GAAC,yBAAyB;AAyBvD;;GAEG;AACH,iCAFU,OAAO,aAAa,EAAE,eAAe,CAwuB7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeChoices.d.ts","sourceRoot":"","sources":["../src/typeChoices.js"],"names":[],"mappings":"AASA;;;;;;;;GAQG;AAEH;;;;;;GAMG;AAEH;;;;;;;GAOG;AAEH;;GAEG;AAEH;;;;;GAKG;AAEH;;;;;;GAMG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;;;GAKG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH;;GAEG;AACH,+BAFU,gBAAgB,
|
|
1
|
+
{"version":3,"file":"typeChoices.d.ts","sourceRoot":"","sources":["../src/typeChoices.js"],"names":[],"mappings":"AASA;;;;;;;;GAQG;AAEH;;;;;;GAMG;AAEH;;;;;;;GAOG;AAEH;;GAEG;AAEH;;;;;GAKG;AAEH;;;;;;GAMG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;;;GAKG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH;;GAEG;AACH,+BAFU,gBAAgB,CAyVxB;sBAtbW,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,CAAC;IAC1B,cAAkB,CAAC,EAAE,OAAO,OAAO,EAAE,MAAM,CAAA;CACxC,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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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.
|
|
3
|
+
"version": "0.20.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -37,18 +37,19 @@
|
|
|
37
37
|
"@babel/plugin-transform-modules-commonjs": "^7.24.8",
|
|
38
38
|
"@babel/preset-env": "^7.25.3",
|
|
39
39
|
"@babel/register": "^7.24.6",
|
|
40
|
-
"@cypress/code-coverage": "^3.12.
|
|
40
|
+
"@cypress/code-coverage": "^3.12.45",
|
|
41
41
|
"@rollup/plugin-babel": "^6.0.4",
|
|
42
42
|
"@rollup/plugin-commonjs": "^26.0.1",
|
|
43
43
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
44
44
|
"@types/jsdom": "^21.1.7",
|
|
45
|
-
"@types/node": "^22.
|
|
45
|
+
"@types/node": "^22.4.2",
|
|
46
46
|
"axe-core": "^4.10.0",
|
|
47
47
|
"coveradge": "^0.8.2",
|
|
48
|
-
"cypress": "^13.13.
|
|
48
|
+
"cypress": "^13.13.3",
|
|
49
49
|
"cypress-axe": "^1.5.0",
|
|
50
|
-
"
|
|
51
|
-
"eslint
|
|
50
|
+
"cypress-terminal-report": "^6.1.2",
|
|
51
|
+
"eslint": "^9.9.0",
|
|
52
|
+
"eslint-config-ash-nazg": "^36.13.0",
|
|
52
53
|
"fast-deep-equal": "^3.1.3",
|
|
53
54
|
"jsdom": "^24.1.1",
|
|
54
55
|
"license-badger": "^0.21.1",
|
|
@@ -56,7 +57,7 @@
|
|
|
56
57
|
"nyc": "^17.0.0",
|
|
57
58
|
"open-cli": "^8.0.0",
|
|
58
59
|
"rimraf": "^6.0.1",
|
|
59
|
-
"rollup": "4.
|
|
60
|
+
"rollup": "4.21.0",
|
|
60
61
|
"rollup-plugin-istanbul": "^5.0.0",
|
|
61
62
|
"rollup-plugin-no-op": "^1.0.2",
|
|
62
63
|
"rollup-plugin-node-builtins": "^2.1.2",
|
|
@@ -182,9 +182,11 @@ export async function formatAndTypeChoices ({
|
|
|
182
182
|
requireObject: hasKeyPath,
|
|
183
183
|
objectHasValue: hasValue,
|
|
184
184
|
schema,
|
|
185
|
-
schemaContent:
|
|
186
|
-
|
|
187
|
-
|
|
185
|
+
schemaContent: schema
|
|
186
|
+
? await getSchemaContent?.(
|
|
187
|
+
/** @type {string} */ (schema)
|
|
188
|
+
)
|
|
189
|
+
: undefined
|
|
188
190
|
}).domArray}, typesHolder);
|
|
189
191
|
}
|
|
190
192
|
},
|
package/src/formats/schema.js
CHANGED
|
@@ -69,10 +69,12 @@ const zodexToStructuredCloningTypeMap = new Map([
|
|
|
69
69
|
* @returns {ZodexSchema}
|
|
70
70
|
*/
|
|
71
71
|
function mergeSchema (leftItem, rightItem) {
|
|
72
|
+
/* istanbul ignore if -- Guard */
|
|
72
73
|
if (leftItem.type !== 'object') {
|
|
73
74
|
console.log('leftItem', leftItem);
|
|
74
75
|
throw new Error('Unexpected leftItem of type ' + leftItem.type);
|
|
75
76
|
}
|
|
77
|
+
/* istanbul ignore if -- Guard */
|
|
76
78
|
if (rightItem.type !== 'object') {
|
|
77
79
|
console.log('rightItem', rightItem);
|
|
78
80
|
throw new Error('Unexpected rightItem of type ' + rightItem.type);
|
|
@@ -99,6 +101,7 @@ function mergeSchema (leftItem, rightItem) {
|
|
|
99
101
|
|
|
100
102
|
newLeftObj[prop] = val && typeof val === 'object'
|
|
101
103
|
? copyObject(val)
|
|
104
|
+
/* istanbul ignore next -- Guard */
|
|
102
105
|
: val;
|
|
103
106
|
}
|
|
104
107
|
}
|
|
@@ -115,9 +118,11 @@ function mergeSchema (leftItem, rightItem) {
|
|
|
115
118
|
}
|
|
116
119
|
/** @type {NestedObject} */ (
|
|
117
120
|
newLeftObj.properties
|
|
118
|
-
)[prop] =
|
|
119
|
-
|
|
120
|
-
|
|
121
|
+
)[prop] = /* istanbul ignore next -- Guard */
|
|
122
|
+
val && typeof val === 'object'
|
|
123
|
+
? copyObject(val)
|
|
124
|
+
/* istanbul ignore next -- Guard */
|
|
125
|
+
: val;
|
|
121
126
|
}
|
|
122
127
|
|
|
123
128
|
return newLeftObj;
|
|
@@ -579,6 +584,7 @@ const schema = {
|
|
|
579
584
|
) {
|
|
580
585
|
// eslint-disable-next-line prefer-const -- Convenient
|
|
581
586
|
let [parentSchema, parentSchemaIdx] = parentSchemaInfo ?? [];
|
|
587
|
+
/* istanbul ignore if -- Guard */
|
|
582
588
|
if (!stateObj) {
|
|
583
589
|
throw new Error('State object expected for schema');
|
|
584
590
|
}
|
|
@@ -625,12 +631,13 @@ const schema = {
|
|
|
625
631
|
parentSchema
|
|
626
632
|
).inner;
|
|
627
633
|
break;
|
|
628
|
-
//
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
+
// Todo: Reenable
|
|
635
|
+
// // eslint-disable-next-line sonarjs/no-duplicated-branches -- Maintenance
|
|
636
|
+
// case 'promise':
|
|
637
|
+
// currentSchema = /** @type {import('zodex').SzPromise} */ (
|
|
638
|
+
// parentSchema
|
|
639
|
+
// ).value;
|
|
640
|
+
// break;
|
|
634
641
|
case 'tuple':
|
|
635
642
|
currentSchema = /** @type {import('zodex').SzTuple} */ (
|
|
636
643
|
parentSchema
|
|
@@ -646,6 +653,8 @@ const schema = {
|
|
|
646
653
|
default:
|
|
647
654
|
break;
|
|
648
655
|
}
|
|
656
|
+
|
|
657
|
+
/* istanbul ignore if -- Guard */
|
|
649
658
|
if (!currentSchema) {
|
|
650
659
|
return {type: typesonType};
|
|
651
660
|
}
|
|
@@ -677,9 +686,6 @@ const schema = {
|
|
|
677
686
|
}
|
|
678
687
|
// console.log('parsed', parsed.success, v, schema);
|
|
679
688
|
if (parsed.success) {
|
|
680
|
-
if (currentSchema.type === 'any' && schema.description) {
|
|
681
|
-
schema.description += ' (any)';
|
|
682
|
-
}
|
|
683
689
|
let type = zodexToStructuredCloningTypeMap.get(schema.type);
|
|
684
690
|
if (!type && schema.type === 'effect') {
|
|
685
691
|
type = /** @type {import('../types.js').AvailableType} */ (
|
|
@@ -721,7 +727,9 @@ const schema = {
|
|
|
721
727
|
return {type: typesonType};
|
|
722
728
|
},
|
|
723
729
|
|
|
730
|
+
/* istanbul ignore next -- Not in use */
|
|
724
731
|
types () {
|
|
732
|
+
/* istanbul ignore next -- Not in use */
|
|
725
733
|
return structuredCloning.types();
|
|
726
734
|
},
|
|
727
735
|
|
|
@@ -111,9 +111,10 @@ const arrayType = {
|
|
|
111
111
|
const state = sparse
|
|
112
112
|
? 'arrayNonindexKeys'
|
|
113
113
|
// ? 'sparseArrays'
|
|
114
|
-
: (this.array ? 'array' : 'object');
|
|
114
|
+
: (this.array && !this.record ? 'array' : 'object');
|
|
115
115
|
/** @type {{[key: (string|number)]: any}} */
|
|
116
|
-
const retObj = this.array ? [] : {};
|
|
116
|
+
const retObj = this.array && !this.record ? [] : {};
|
|
117
|
+
/* istanbul ignore next -- Unreachable? */
|
|
117
118
|
let stringVal = innerContents !== undefined
|
|
118
119
|
? innerContents
|
|
119
120
|
/* istanbul ignore next -- Unreachable? */
|
|
@@ -140,7 +141,7 @@ const arrayType = {
|
|
|
140
141
|
}
|
|
141
142
|
return false;
|
|
142
143
|
};
|
|
143
|
-
if (this.array) {
|
|
144
|
+
if (this.array && !this.record) {
|
|
144
145
|
let idx = 0;
|
|
145
146
|
const parse = () => {
|
|
146
147
|
if (!stringVal) {
|
|
@@ -835,7 +836,11 @@ const arrayType = {
|
|
|
835
836
|
input.setCustomValidity(
|
|
836
837
|
invalidStr
|
|
837
838
|
);
|
|
838
|
-
|
|
839
|
+
if (invalidStr) {
|
|
840
|
+
// Might not want this as changes focus; if ok, will hopefully be
|
|
841
|
+
// marked as such elsewhere
|
|
842
|
+
input.reportValidity();
|
|
843
|
+
}
|
|
839
844
|
}
|
|
840
845
|
return invalidStr; // Don't give a chance to become valid
|
|
841
846
|
});
|
|
@@ -1052,8 +1057,11 @@ const arrayType = {
|
|
|
1052
1057
|
? elementDesc ?? 'Item'
|
|
1053
1058
|
: {'#': required
|
|
1054
1059
|
? [
|
|
1055
|
-
['b', {
|
|
1056
|
-
|
|
1060
|
+
['b', {
|
|
1061
|
+
className,
|
|
1062
|
+
title: (elementDesc ?? description) ? propName : undefined
|
|
1063
|
+
}, [
|
|
1064
|
+
elementDesc ?? description ?? propName
|
|
1057
1065
|
]]
|
|
1058
1066
|
]
|
|
1059
1067
|
: [
|
|
@@ -1074,6 +1082,7 @@ const arrayType = {
|
|
|
1074
1082
|
]?.description ?? propName
|
|
1075
1083
|
: /** @type {import('zodex').SzObject} */ (
|
|
1076
1084
|
specificSchemaObject
|
|
1085
|
+
/* istanbul ignore next -- Guard */
|
|
1077
1086
|
)?.catchall?.description ?? propName
|
|
1078
1087
|
]]
|
|
1079
1088
|
]
|
|
@@ -1998,6 +2007,7 @@ const arrayType = {
|
|
|
1998
2007
|
*/
|
|
1999
2008
|
async change () {
|
|
2000
2009
|
if (preventAdding()) {
|
|
2010
|
+
/* istanbul ignore next -- Just a guard */
|
|
2001
2011
|
this.value = this.$oldvalue ?? this.defaultValue;
|
|
2002
2012
|
return;
|
|
2003
2013
|
}
|
|
@@ -2424,6 +2434,7 @@ const arrayType = {
|
|
|
2424
2434
|
Object.entries(
|
|
2425
2435
|
/** @type {import('zodex').SzObject} */ (
|
|
2426
2436
|
specificSchemaObject
|
|
2437
|
+
/* istanbul ignore next -- Should always have `properties` */
|
|
2427
2438
|
).properties ?? {}
|
|
2428
2439
|
)
|
|
2429
2440
|
) {
|
|
@@ -2451,10 +2462,12 @@ const arrayType = {
|
|
|
2451
2462
|
}
|
|
2452
2463
|
}
|
|
2453
2464
|
break;
|
|
2454
|
-
}
|
|
2465
|
+
}
|
|
2466
|
+
// case 'array': // None with schemas?
|
|
2467
|
+
case 'arrayNonindexKeys': {
|
|
2455
2468
|
const {minLength = 0} = /** @type {import('zodex').SzArray} */ (
|
|
2456
2469
|
specificSchemaObject
|
|
2457
|
-
)
|
|
2470
|
+
);
|
|
2458
2471
|
const arrayLengthInput =
|
|
2459
2472
|
/** @type {HTMLInputElement & {$oldvalue: string}} */ (
|
|
2460
2473
|
$e(div, '.arrayLength')
|
|
@@ -2471,7 +2484,7 @@ const arrayType = {
|
|
|
2471
2484
|
if (!schemaFallingBack) {
|
|
2472
2485
|
const {minSize = 0} = /** @type {import('zodex').SzSet} */ (
|
|
2473
2486
|
specificSchemaObject
|
|
2474
|
-
)
|
|
2487
|
+
);
|
|
2475
2488
|
for (let i = 0; i < minSize; i++) {
|
|
2476
2489
|
div.$addArrayElement({required: true});
|
|
2477
2490
|
}
|
|
@@ -32,7 +32,7 @@ const nativeEnumType = {
|
|
|
32
32
|
return {value};
|
|
33
33
|
},
|
|
34
34
|
getInput ({root}) {
|
|
35
|
-
return /** @type {HTMLTextAreaElement} */ ($e(root, 'input'));
|
|
35
|
+
return /** @type {HTMLTextAreaElement} */ ($e(root, 'input.nativeEnumKey'));
|
|
36
36
|
},
|
|
37
37
|
setValue ({root, value}) {
|
|
38
38
|
const input = /**
|
|
@@ -45,9 +45,11 @@ const nativeEnumType = {
|
|
|
45
45
|
).find(([, val]) => {
|
|
46
46
|
return val === value;
|
|
47
47
|
})?.[0] ?? '';
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
if (input.value) { // If key was found, the value is ok
|
|
49
|
+
/** @type {HTMLSpanElement} */ (
|
|
50
|
+
$e(root, '.enumeratedValue')
|
|
51
|
+
).textContent = value;
|
|
52
|
+
}
|
|
51
53
|
},
|
|
52
54
|
getValue ({root}) {
|
|
53
55
|
const {value, $schemaNativeEnumValues} =
|
|
@@ -11,16 +11,11 @@ const neverType = {
|
|
|
11
11
|
/* istanbul ignore next -- Back-up in case shows */
|
|
12
12
|
return false;
|
|
13
13
|
},
|
|
14
|
-
/* istanbul ignore next -- Back-up in case shows */
|
|
15
14
|
toValue (/* _s */) {
|
|
16
|
-
/* istanbul ignore next -- Back-up in case shows */
|
|
17
15
|
throw new Error('Cannot convert to value');
|
|
18
16
|
},
|
|
19
|
-
/* istanbul ignore next -- Back-up in case shows */
|
|
20
17
|
getValue () {
|
|
21
|
-
/* istanbul ignore next -- Back-up in case shows */
|
|
22
18
|
return /** @type {import('../types.js').ToValue} */ (
|
|
23
|
-
/* istanbul ignore next -- Back-up in case shows */
|
|
24
19
|
this.toValue
|
|
25
20
|
)('');
|
|
26
21
|
},
|
|
@@ -136,6 +136,7 @@ const buffersourceType = {
|
|
|
136
136
|
return bufferSourceClasses.has(toStringTag(x));
|
|
137
137
|
},
|
|
138
138
|
toValue (s, rootInfo) {
|
|
139
|
+
/* istanbul ignore next -- Should always be found */
|
|
139
140
|
const {groups: {
|
|
140
141
|
bufferSourceClass
|
|
141
142
|
/* istanbul ignore next -- Should always be found */
|
|
@@ -14,6 +14,7 @@ const dommatrixType = {
|
|
|
14
14
|
return ['DOMMatrix', 'DOMMatrixReadOnly'].includes(toStringTag(x));
|
|
15
15
|
},
|
|
16
16
|
toValue (s, rootInfo) {
|
|
17
|
+
/* istanbul ignore next -- Should always be found */
|
|
17
18
|
const {groups: {
|
|
18
19
|
domMatrixClass
|
|
19
20
|
/* istanbul ignore next -- Should always be found */
|
|
@@ -14,6 +14,7 @@ const dompointType = {
|
|
|
14
14
|
return ['DOMPoint', 'DOMPointReadOnly'].includes(toStringTag(x));
|
|
15
15
|
},
|
|
16
16
|
toValue (s, rootInfo) {
|
|
17
|
+
/* istanbul ignore next -- Should always be found */
|
|
17
18
|
const {groups: {
|
|
18
19
|
domPointClass
|
|
19
20
|
/* istanbul ignore next -- Should always be found */
|
|
@@ -14,6 +14,7 @@ const domrectType = {
|
|
|
14
14
|
return ['DOMRect', 'DOMRectReadOnly'].includes(toStringTag(x));
|
|
15
15
|
},
|
|
16
16
|
toValue (s, rootInfo) {
|
|
17
|
+
/* istanbul ignore next -- Should always be found */
|
|
17
18
|
const {groups: {
|
|
18
19
|
domRectClass
|
|
19
20
|
/* istanbul ignore next -- Should always be found */
|
|
@@ -63,6 +63,7 @@ const errorsSpecialType = {
|
|
|
63
63
|
String.raw`)\((?<innerContent>.*)\)$`, 'u'
|
|
64
64
|
),
|
|
65
65
|
toValue (s, rootInfo) {
|
|
66
|
+
/* istanbul ignore next -- Just a guard */
|
|
66
67
|
const {groups: {
|
|
67
68
|
errorClass
|
|
68
69
|
/* istanbul ignore next -- Should always be found */
|
|
@@ -366,6 +367,7 @@ const errorsSpecialType = {
|
|
|
366
367
|
).textContent = aggregateErrorsContents.hidden ? '+' : '-';
|
|
367
368
|
}}}, ['-']],
|
|
368
369
|
['div', {class: 'aggregateErrorsContents'}, [
|
|
370
|
+
/* istanbul ignore next -- Just a guard */
|
|
369
371
|
(o.errors
|
|
370
372
|
? (() => {
|
|
371
373
|
const [div] = arrayType.viewUI({
|
package/src/typeChoices.js
CHANGED
|
@@ -170,7 +170,6 @@ export const buildTypeChoices = ({
|
|
|
170
170
|
return JSON.stringify(obj);
|
|
171
171
|
}).indexOf(JSON.stringify(specificSchema));
|
|
172
172
|
if (idx === -1) {
|
|
173
|
-
console.log('schemaObjs', schemaObjs, specificSchema);
|
|
174
173
|
this.value = type;
|
|
175
174
|
} else {
|
|
176
175
|
this.selectedIndex = idx + 1;
|
|
@@ -225,8 +224,9 @@ export const buildTypeChoices = ({
|
|
|
225
224
|
},
|
|
226
225
|
|
|
227
226
|
/** @type {AddAndValidateEditUI} */
|
|
228
|
-
$addAndValidateEditUI ({
|
|
227
|
+
$addAndValidateEditUI (/* istanbul ignore next -- Backup */ {
|
|
229
228
|
baseValue, bringIntoFocus, schemaObject, avoidReport
|
|
229
|
+
/* istanbul ignore next -- Backup */
|
|
230
230
|
} = {}) {
|
|
231
231
|
const {value: type} = this;
|
|
232
232
|
|
|
@@ -263,8 +263,12 @@ export const buildTypeChoices = ({
|
|
|
263
263
|
// Avoid JSON references by using this by default (or only?)
|
|
264
264
|
(schemaObjs?.[sel.selectedIndex - 1]) ??
|
|
265
265
|
|
|
266
|
+
// eslint-disable-next-line @stylistic/max-len -- Long
|
|
267
|
+
/* istanbul ignore next -- Can probably remove as `schemaObjs` will be set */
|
|
266
268
|
(schemaContent?.type === 'union' && schemaIdx !== undefined
|
|
269
|
+
/* istanbul ignore next -- Can probably remove */
|
|
267
270
|
? schemaContent.options[schemaIdx]
|
|
271
|
+
// This is probably just `undefined` by here
|
|
268
272
|
: schemaContent),
|
|
269
273
|
schemaFallingBack: Boolean(!schemaObject && schemaContent)
|
|
270
274
|
});
|
package/src/types.js
CHANGED