@es-joy/jsoe 0.9.0 → 0.11.0
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/.eslintrc.cjs +9 -0
- package/.nyc_output/out.json +9131 -5880
- package/CHANGES.md +8 -0
- package/README.md +7 -2
- package/demo/index.js +12 -1
- package/dist/formats/structuredCloning.d.ts.map +1 -1
- package/dist/fundamentalTypes/arrayType.d.ts.map +1 -1
- package/dist/fundamentalTypes/blobType.d.ts +11 -0
- package/dist/fundamentalTypes/blobType.d.ts.map +1 -0
- package/dist/fundamentalTypes/errorType.d.ts.map +1 -1
- package/dist/fundamentalTypes/fileType.d.ts +13 -0
- package/dist/fundamentalTypes/fileType.d.ts.map +1 -0
- package/dist/fundamentalTypes/filelistType.d.ts +6 -0
- package/dist/fundamentalTypes/filelistType.d.ts.map +1 -0
- package/dist/types.d.ts +9 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/FileList.d.ts +26 -0
- package/dist/utils/FileList.d.ts.map +1 -0
- package/dist/utils/dialogs.d.ts +3 -1
- package/dist/utils/dialogs.d.ts.map +1 -1
- package/dist/utils/media.d.ts +18 -0
- package/dist/utils/media.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/formats/structuredCloning.js +16 -6
- package/src/fundamentalTypes/arrayType.js +57 -18
- package/src/fundamentalTypes/domexceptionType.js +124 -0
- package/src/fundamentalTypes/dommatrixType.js +357 -0
- package/src/fundamentalTypes/dompointType.js +103 -0
- package/src/fundamentalTypes/domrectType.js +103 -0
- package/src/fundamentalTypes/filelistType.js +35 -0
- package/src/jsoe.css +4 -0
- package/src/types.js +19 -19
- package/src/utils/FileList.js +32 -0
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
import {$e} from '../utils/templateUtils.js';
|
|
2
|
+
|
|
3
|
+
let idx = 0;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @type {import('../types.js').TypeObject}
|
|
7
|
+
*/
|
|
8
|
+
const dommatrixType = {
|
|
9
|
+
option: ['DOMMatrix'],
|
|
10
|
+
stringRegex: /^DOMMatrix\((.*)\)$/u,
|
|
11
|
+
toValue (s) {
|
|
12
|
+
const o = JSON.parse(s);
|
|
13
|
+
|
|
14
|
+
const dommatrix = Object.hasOwn(o, 'a')
|
|
15
|
+
? new DOMMatrix([o.a, o.b, o.c, o.d, o.e, o.f])
|
|
16
|
+
: new DOMMatrix([
|
|
17
|
+
o.m11, o.m12, o.m13, o.m14,
|
|
18
|
+
o.m21, o.m22, o.m23, o.m24,
|
|
19
|
+
o.m31, o.m32, o.m33, o.m34,
|
|
20
|
+
o.m41, o.m42, o.m43, o.m44
|
|
21
|
+
]);
|
|
22
|
+
|
|
23
|
+
return {value: dommatrix};
|
|
24
|
+
},
|
|
25
|
+
getInput ({root}) {
|
|
26
|
+
return /** @type {HTMLInputElement} */ ($e(root, 'input'));
|
|
27
|
+
},
|
|
28
|
+
setValue ({root, value: o}) {
|
|
29
|
+
const {is2D} = o;
|
|
30
|
+
/** @type {HTMLInputElement} */ ($e(root, '.d2')).checked = is2D;
|
|
31
|
+
/** @type {HTMLInputElement} */ ($e(root, '.d3')).checked = !is2D;
|
|
32
|
+
|
|
33
|
+
/** @type {HTMLDivElement} */ (
|
|
34
|
+
$e(root, '.holder2d')
|
|
35
|
+
).hidden = /** @type {HTMLInputElement} */ !is2D;
|
|
36
|
+
/** @type {HTMLDivElement} */ (
|
|
37
|
+
$e(root, '.holder3d')
|
|
38
|
+
).hidden = /** @type {HTMLInputElement} */ is2D;
|
|
39
|
+
|
|
40
|
+
if (is2D) {
|
|
41
|
+
/** @type {HTMLInputElement} */ (
|
|
42
|
+
$e(root, '.a')
|
|
43
|
+
).value = o.a;
|
|
44
|
+
/** @type {HTMLInputElement} */ (
|
|
45
|
+
$e(root, '.b')
|
|
46
|
+
).value = o.b;
|
|
47
|
+
/** @type {HTMLInputElement} */ (
|
|
48
|
+
$e(root, '.c')
|
|
49
|
+
).value = o.c;
|
|
50
|
+
/** @type {HTMLInputElement} */ (
|
|
51
|
+
$e(root, '.d')
|
|
52
|
+
).value = o.d;
|
|
53
|
+
/** @type {HTMLInputElement} */ (
|
|
54
|
+
$e(root, '.e')
|
|
55
|
+
).value = o.e;
|
|
56
|
+
/** @type {HTMLInputElement} */ (
|
|
57
|
+
$e(root, '.f')
|
|
58
|
+
).value = o.f;
|
|
59
|
+
} else {
|
|
60
|
+
/** @type {HTMLInputElement} */ (
|
|
61
|
+
$e(root, '.m11')
|
|
62
|
+
).value = o.m11;
|
|
63
|
+
/** @type {HTMLInputElement} */ (
|
|
64
|
+
$e(root, '.m12')
|
|
65
|
+
).value = o.m12;
|
|
66
|
+
/** @type {HTMLInputElement} */ (
|
|
67
|
+
$e(root, '.m13')
|
|
68
|
+
).value = o.m13;
|
|
69
|
+
/** @type {HTMLInputElement} */ (
|
|
70
|
+
$e(root, '.m14')
|
|
71
|
+
).value = o.m14;
|
|
72
|
+
|
|
73
|
+
/** @type {HTMLInputElement} */ (
|
|
74
|
+
$e(root, '.m21')
|
|
75
|
+
).value = o.m21;
|
|
76
|
+
/** @type {HTMLInputElement} */ (
|
|
77
|
+
$e(root, '.m22')
|
|
78
|
+
).value = o.m22;
|
|
79
|
+
/** @type {HTMLInputElement} */ (
|
|
80
|
+
$e(root, '.m23')
|
|
81
|
+
).value = o.m23;
|
|
82
|
+
/** @type {HTMLInputElement} */ (
|
|
83
|
+
$e(root, '.m24')
|
|
84
|
+
).value = o.m24;
|
|
85
|
+
|
|
86
|
+
/** @type {HTMLInputElement} */ (
|
|
87
|
+
$e(root, '.m31')
|
|
88
|
+
).value = o.m31;
|
|
89
|
+
/** @type {HTMLInputElement} */ (
|
|
90
|
+
$e(root, '.m32')
|
|
91
|
+
).value = o.m32;
|
|
92
|
+
/** @type {HTMLInputElement} */ (
|
|
93
|
+
$e(root, '.m33')
|
|
94
|
+
).value = o.m33;
|
|
95
|
+
/** @type {HTMLInputElement} */ (
|
|
96
|
+
$e(root, '.m34')
|
|
97
|
+
).value = o.m34;
|
|
98
|
+
|
|
99
|
+
/** @type {HTMLInputElement} */ (
|
|
100
|
+
$e(root, '.m41')
|
|
101
|
+
).value = o.m41;
|
|
102
|
+
/** @type {HTMLInputElement} */ (
|
|
103
|
+
$e(root, '.m42')
|
|
104
|
+
).value = o.m42;
|
|
105
|
+
/** @type {HTMLInputElement} */ (
|
|
106
|
+
$e(root, '.m43')
|
|
107
|
+
).value = o.m43;
|
|
108
|
+
/** @type {HTMLInputElement} */ (
|
|
109
|
+
$e(root, '.m44')
|
|
110
|
+
).value = o.m44;
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
getValue ({root}) {
|
|
114
|
+
const aType = /** @type {HTMLInputElement} */ (
|
|
115
|
+
$e(root, '.a')
|
|
116
|
+
).value;
|
|
117
|
+
|
|
118
|
+
if (aType) {
|
|
119
|
+
const a = Number(aType);
|
|
120
|
+
const b = Number(/** @type {HTMLInputElement} */ (
|
|
121
|
+
$e(root, '.b')
|
|
122
|
+
).value);
|
|
123
|
+
const c = Number(/** @type {HTMLInputElement} */ (
|
|
124
|
+
$e(root, '.c')
|
|
125
|
+
).value);
|
|
126
|
+
const d = Number(/** @type {HTMLInputElement} */ (
|
|
127
|
+
$e(root, '.d')
|
|
128
|
+
).value);
|
|
129
|
+
const e = Number(/** @type {HTMLInputElement} */ (
|
|
130
|
+
$e(root, '.e')
|
|
131
|
+
).value);
|
|
132
|
+
const f = Number(/** @type {HTMLInputElement} */ (
|
|
133
|
+
$e(root, '.f')
|
|
134
|
+
).value);
|
|
135
|
+
return new DOMMatrix([a, b, c, d, e, f]);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const m11 = Number(/** @type {HTMLInputElement} */ (
|
|
139
|
+
$e(root, '.m11')
|
|
140
|
+
).value);
|
|
141
|
+
const m12 = Number(/** @type {HTMLInputElement} */ (
|
|
142
|
+
$e(root, '.m12')
|
|
143
|
+
).value);
|
|
144
|
+
const m13 = Number(/** @type {HTMLInputElement} */ (
|
|
145
|
+
$e(root, '.m13')
|
|
146
|
+
).value);
|
|
147
|
+
const m14 = Number(/** @type {HTMLInputElement} */ (
|
|
148
|
+
$e(root, '.m14')
|
|
149
|
+
).value);
|
|
150
|
+
|
|
151
|
+
const m21 = Number(/** @type {HTMLInputElement} */ (
|
|
152
|
+
$e(root, '.m21')
|
|
153
|
+
).value);
|
|
154
|
+
const m22 = Number(/** @type {HTMLInputElement} */ (
|
|
155
|
+
$e(root, '.m22')
|
|
156
|
+
).value);
|
|
157
|
+
const m23 = Number(/** @type {HTMLInputElement} */ (
|
|
158
|
+
$e(root, '.m23')
|
|
159
|
+
).value);
|
|
160
|
+
const m24 = Number(/** @type {HTMLInputElement} */ (
|
|
161
|
+
$e(root, '.m24')
|
|
162
|
+
).value);
|
|
163
|
+
|
|
164
|
+
const m31 = Number(/** @type {HTMLInputElement} */ (
|
|
165
|
+
$e(root, '.m31')
|
|
166
|
+
).value);
|
|
167
|
+
const m32 = Number(/** @type {HTMLInputElement} */ (
|
|
168
|
+
$e(root, '.m32')
|
|
169
|
+
).value);
|
|
170
|
+
const m33 = Number(/** @type {HTMLInputElement} */ (
|
|
171
|
+
$e(root, '.m33')
|
|
172
|
+
).value);
|
|
173
|
+
const m34 = Number(/** @type {HTMLInputElement} */ (
|
|
174
|
+
$e(root, '.m34')
|
|
175
|
+
).value);
|
|
176
|
+
|
|
177
|
+
const m41 = Number(/** @type {HTMLInputElement} */ (
|
|
178
|
+
$e(root, '.m41')
|
|
179
|
+
).value);
|
|
180
|
+
const m42 = Number(/** @type {HTMLInputElement} */ (
|
|
181
|
+
$e(root, '.m42')
|
|
182
|
+
).value);
|
|
183
|
+
const m43 = Number(/** @type {HTMLInputElement} */ (
|
|
184
|
+
$e(root, '.m43')
|
|
185
|
+
).value);
|
|
186
|
+
const m44 = Number(/** @type {HTMLInputElement} */ (
|
|
187
|
+
$e(root, '.m44')
|
|
188
|
+
).value);
|
|
189
|
+
|
|
190
|
+
return new DOMMatrix([
|
|
191
|
+
m11, m12, m13, m14,
|
|
192
|
+
m21, m22, m23, m24,
|
|
193
|
+
m31, m32, m33, m34,
|
|
194
|
+
m41, m42, m43, m44
|
|
195
|
+
]);
|
|
196
|
+
},
|
|
197
|
+
viewUI ({value}) {
|
|
198
|
+
return ['div', {dataset: {type: 'dommatrix'}}, [
|
|
199
|
+
value.is2D
|
|
200
|
+
? ['div', [
|
|
201
|
+
['b', ['a ']],
|
|
202
|
+
value.a,
|
|
203
|
+
['br'],
|
|
204
|
+
['b', ['b ']],
|
|
205
|
+
value.b,
|
|
206
|
+
['br'],
|
|
207
|
+
['b', ['c ']],
|
|
208
|
+
value.c,
|
|
209
|
+
['br'],
|
|
210
|
+
['b', ['d ']],
|
|
211
|
+
value.d,
|
|
212
|
+
['br'],
|
|
213
|
+
['b', ['e ']],
|
|
214
|
+
value.e,
|
|
215
|
+
['br'],
|
|
216
|
+
['b', ['f ']],
|
|
217
|
+
value.f
|
|
218
|
+
]]
|
|
219
|
+
: ['div', [
|
|
220
|
+
['b', ['m11 ']],
|
|
221
|
+
value.m11,
|
|
222
|
+
['br'],
|
|
223
|
+
['b', ['m12 ']],
|
|
224
|
+
value.m12,
|
|
225
|
+
['br'],
|
|
226
|
+
['b', ['m13 ']],
|
|
227
|
+
value.m13,
|
|
228
|
+
['br'],
|
|
229
|
+
['b', ['m14 ']],
|
|
230
|
+
value.m14,
|
|
231
|
+
['br'],
|
|
232
|
+
|
|
233
|
+
['b', ['m21 ']],
|
|
234
|
+
value.m21,
|
|
235
|
+
['br'],
|
|
236
|
+
['b', ['m22 ']],
|
|
237
|
+
value.m22,
|
|
238
|
+
['br'],
|
|
239
|
+
['b', ['m23 ']],
|
|
240
|
+
value.m23,
|
|
241
|
+
['br'],
|
|
242
|
+
['b', ['m24 ']],
|
|
243
|
+
value.m24,
|
|
244
|
+
['br'],
|
|
245
|
+
|
|
246
|
+
['b', ['m31 ']],
|
|
247
|
+
value.m31,
|
|
248
|
+
['br'],
|
|
249
|
+
['b', ['m32 ']],
|
|
250
|
+
value.m32,
|
|
251
|
+
['br'],
|
|
252
|
+
['b', ['m33 ']],
|
|
253
|
+
value.m33,
|
|
254
|
+
['br'],
|
|
255
|
+
['b', ['m34 ']],
|
|
256
|
+
value.m34,
|
|
257
|
+
['br'],
|
|
258
|
+
|
|
259
|
+
['b', ['m41 ']],
|
|
260
|
+
value.m41,
|
|
261
|
+
['br'],
|
|
262
|
+
['b', ['m42 ']],
|
|
263
|
+
value.m42,
|
|
264
|
+
['br'],
|
|
265
|
+
['b', ['m43 ']],
|
|
266
|
+
value.m43,
|
|
267
|
+
['br'],
|
|
268
|
+
['b', ['m44 ']],
|
|
269
|
+
value.m44
|
|
270
|
+
]]
|
|
271
|
+
]];
|
|
272
|
+
},
|
|
273
|
+
editUI ({typeNamespace, value = {}}) {
|
|
274
|
+
idx++;
|
|
275
|
+
const {is2D} = value;
|
|
276
|
+
// eslint-disable-next-line @stylistic/max-len -- Long
|
|
277
|
+
return ['div', {dataset: {type: 'dommatrix'}}, /** @type {import('jamilih').JamilihChildren} */ ([
|
|
278
|
+
['div', {
|
|
279
|
+
$on: {
|
|
280
|
+
click (e) {
|
|
281
|
+
const {target} = e;
|
|
282
|
+
/* c8 ignore next 3 */
|
|
283
|
+
if (/** @type {HTMLInputElement} */ (target).type !== 'radio') {
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
const parent = /** @type {HTMLDivElement} */ (this.parentElement);
|
|
287
|
+
/** @type {HTMLDivElement} */ (
|
|
288
|
+
$e(parent, '.holder2d')
|
|
289
|
+
).hidden = /** @type {HTMLInputElement} */ (target).value === '3d';
|
|
290
|
+
/** @type {HTMLDivElement} */ (
|
|
291
|
+
$e(parent, '.holder3d')
|
|
292
|
+
).hidden = /** @type {HTMLInputElement} */ (target).value === '2d';
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}, [
|
|
296
|
+
['label', [
|
|
297
|
+
'2d',
|
|
298
|
+
['input', {
|
|
299
|
+
class: 'd2',
|
|
300
|
+
type: 'radio', name: `${typeNamespace}-dommatrix-dimension-${idx}`,
|
|
301
|
+
value: '2d',
|
|
302
|
+
checked: Boolean(is2D)
|
|
303
|
+
}]
|
|
304
|
+
]],
|
|
305
|
+
' ',
|
|
306
|
+
['label', [
|
|
307
|
+
'3d',
|
|
308
|
+
['input', {
|
|
309
|
+
class: 'd3',
|
|
310
|
+
type: 'radio', name: `${typeNamespace}-dommatrix-dimension-${idx}`,
|
|
311
|
+
value: '3d',
|
|
312
|
+
checked: !is2D
|
|
313
|
+
}]
|
|
314
|
+
]]
|
|
315
|
+
]],
|
|
316
|
+
['div', {
|
|
317
|
+
class: 'holder2d',
|
|
318
|
+
hidden: !is2D
|
|
319
|
+
}, (['a', 'b', 'c', 'd', 'e', 'f'].flatMap((label) => {
|
|
320
|
+
return [
|
|
321
|
+
['br'],
|
|
322
|
+
['label', [
|
|
323
|
+
label + ': ',
|
|
324
|
+
['input', {
|
|
325
|
+
class: label,
|
|
326
|
+
name: `${typeNamespace}-dommatrix-${label}`,
|
|
327
|
+
value: value[label] ?? ''
|
|
328
|
+
}]
|
|
329
|
+
]]
|
|
330
|
+
];
|
|
331
|
+
})).slice(1)],
|
|
332
|
+
['div', {
|
|
333
|
+
class: 'holder3d',
|
|
334
|
+
hidden: Boolean(is2D)
|
|
335
|
+
}, ([
|
|
336
|
+
'm11', 'm12', 'm13', 'm14',
|
|
337
|
+
'm21', 'm22', 'm23', 'm24',
|
|
338
|
+
'm31', 'm32', 'm33', 'm34',
|
|
339
|
+
'm41', 'm42', 'm43', 'm44'
|
|
340
|
+
].flatMap((label) => {
|
|
341
|
+
return [
|
|
342
|
+
['br'],
|
|
343
|
+
['label', [
|
|
344
|
+
label + ': ',
|
|
345
|
+
['input', {
|
|
346
|
+
class: label,
|
|
347
|
+
name: `${typeNamespace}-dommatrix-${label}`,
|
|
348
|
+
value: value[label] ?? ''
|
|
349
|
+
}]
|
|
350
|
+
]]
|
|
351
|
+
];
|
|
352
|
+
})).slice(1)]
|
|
353
|
+
])];
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
export default dommatrixType;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import {$e} from '../utils/templateUtils.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @type {import('../types.js').TypeObject}
|
|
5
|
+
*/
|
|
6
|
+
const dompointType = {
|
|
7
|
+
option: ['DOMPoint'],
|
|
8
|
+
stringRegex: /^DOMPoint\((.*)\)$/u,
|
|
9
|
+
toValue (s) {
|
|
10
|
+
const {x, y, z, w} = JSON.parse(s);
|
|
11
|
+
return {value: new DOMPoint(x, y, z, w)};
|
|
12
|
+
},
|
|
13
|
+
getInput ({root}) {
|
|
14
|
+
return /** @type {HTMLInputElement} */ ($e(root, 'input'));
|
|
15
|
+
},
|
|
16
|
+
setValue ({root, value}) {
|
|
17
|
+
/** @type {HTMLInputElement} */ (
|
|
18
|
+
$e(root, '.x')
|
|
19
|
+
).value = String(value.x);
|
|
20
|
+
/** @type {HTMLInputElement} */ (
|
|
21
|
+
$e(root, '.y')
|
|
22
|
+
).value = String(value.y);
|
|
23
|
+
/** @type {HTMLInputElement} */ (
|
|
24
|
+
$e(root, '.z')
|
|
25
|
+
).value = String(value.z);
|
|
26
|
+
/** @type {HTMLInputElement} */ (
|
|
27
|
+
$e(root, '.w')
|
|
28
|
+
).value = String(value.w);
|
|
29
|
+
},
|
|
30
|
+
getValue ({root}) {
|
|
31
|
+
const x = Number(/** @type {HTMLInputElement} */ (
|
|
32
|
+
$e(root, '.x')
|
|
33
|
+
).value);
|
|
34
|
+
const y = Number(/** @type {HTMLInputElement} */ (
|
|
35
|
+
$e(root, '.y')
|
|
36
|
+
).value);
|
|
37
|
+
const z = Number(/** @type {HTMLInputElement} */ (
|
|
38
|
+
$e(root, '.z')
|
|
39
|
+
).value);
|
|
40
|
+
const w = Number(/** @type {HTMLInputElement} */ (
|
|
41
|
+
$e(root, '.w')
|
|
42
|
+
).value);
|
|
43
|
+
return new DOMPoint(x, y, z, w);
|
|
44
|
+
},
|
|
45
|
+
viewUI ({value}) {
|
|
46
|
+
return ['div', {dataset: {type: 'dompoint'}}, [
|
|
47
|
+
['b', ['x ']],
|
|
48
|
+
value.x,
|
|
49
|
+
['br'],
|
|
50
|
+
['b', ['y ']],
|
|
51
|
+
value.y,
|
|
52
|
+
['br'],
|
|
53
|
+
['b', ['z ']],
|
|
54
|
+
value.z,
|
|
55
|
+
['br'],
|
|
56
|
+
['b', ['w ']],
|
|
57
|
+
value.w
|
|
58
|
+
]];
|
|
59
|
+
},
|
|
60
|
+
editUI ({typeNamespace, value = {
|
|
61
|
+
x: '',
|
|
62
|
+
y: '',
|
|
63
|
+
z: '',
|
|
64
|
+
w: ''
|
|
65
|
+
}}) {
|
|
66
|
+
// eslint-disable-next-line @stylistic/max-len -- Long
|
|
67
|
+
return ['div', {dataset: {type: 'dompoint'}}, /** @type {import('jamilih').JamilihChildren} */ ([
|
|
68
|
+
['label', [
|
|
69
|
+
'x: ',
|
|
70
|
+
['input', {
|
|
71
|
+
class: 'x',
|
|
72
|
+
name: `${typeNamespace}-dompoint-x`, value: value.x
|
|
73
|
+
}]
|
|
74
|
+
]],
|
|
75
|
+
['br'],
|
|
76
|
+
['label', [
|
|
77
|
+
'y: ',
|
|
78
|
+
['input', {
|
|
79
|
+
class: 'y',
|
|
80
|
+
name: `${typeNamespace}-dompoint-y`, value: value.y
|
|
81
|
+
}]
|
|
82
|
+
]],
|
|
83
|
+
['br'],
|
|
84
|
+
['label', [
|
|
85
|
+
'z: ',
|
|
86
|
+
['input', {
|
|
87
|
+
class: 'z',
|
|
88
|
+
name: `${typeNamespace}-dompoint-z`, value: value.z
|
|
89
|
+
}]
|
|
90
|
+
]],
|
|
91
|
+
['br'],
|
|
92
|
+
['label', [
|
|
93
|
+
'w: ',
|
|
94
|
+
['input', {
|
|
95
|
+
class: 'w',
|
|
96
|
+
name: `${typeNamespace}-dompoint-w`, value: value.w
|
|
97
|
+
}]
|
|
98
|
+
]]
|
|
99
|
+
])];
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export default dompointType;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import {$e} from '../utils/templateUtils.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @type {import('../types.js').TypeObject}
|
|
5
|
+
*/
|
|
6
|
+
const domrectType = {
|
|
7
|
+
option: ['DOMRect'],
|
|
8
|
+
stringRegex: /^DOMRect\((.*)\)$/u,
|
|
9
|
+
toValue (s) {
|
|
10
|
+
const {x, y, width, height} = JSON.parse(s);
|
|
11
|
+
return {value: new DOMRect(x, y, width, height)};
|
|
12
|
+
},
|
|
13
|
+
getInput ({root}) {
|
|
14
|
+
return /** @type {HTMLInputElement} */ ($e(root, 'input'));
|
|
15
|
+
},
|
|
16
|
+
setValue ({root, value}) {
|
|
17
|
+
/** @type {HTMLInputElement} */ (
|
|
18
|
+
$e(root, '.x')
|
|
19
|
+
).value = String(value.x);
|
|
20
|
+
/** @type {HTMLInputElement} */ (
|
|
21
|
+
$e(root, '.y')
|
|
22
|
+
).value = String(value.y);
|
|
23
|
+
/** @type {HTMLInputElement} */ (
|
|
24
|
+
$e(root, '.width')
|
|
25
|
+
).value = String(value.width);
|
|
26
|
+
/** @type {HTMLInputElement} */ (
|
|
27
|
+
$e(root, '.height')
|
|
28
|
+
).value = String(value.height);
|
|
29
|
+
},
|
|
30
|
+
getValue ({root}) {
|
|
31
|
+
const x = Number(/** @type {HTMLInputElement} */ (
|
|
32
|
+
$e(root, '.x')
|
|
33
|
+
).value);
|
|
34
|
+
const y = Number(/** @type {HTMLInputElement} */ (
|
|
35
|
+
$e(root, '.y')
|
|
36
|
+
).value);
|
|
37
|
+
const width = Number(/** @type {HTMLInputElement} */ (
|
|
38
|
+
$e(root, '.width')
|
|
39
|
+
).value);
|
|
40
|
+
const height = Number(/** @type {HTMLInputElement} */ (
|
|
41
|
+
$e(root, '.height')
|
|
42
|
+
).value);
|
|
43
|
+
return new DOMRect(x, y, width, height);
|
|
44
|
+
},
|
|
45
|
+
viewUI ({value}) {
|
|
46
|
+
return ['div', {dataset: {type: 'domrect'}}, [
|
|
47
|
+
['b', ['x ']],
|
|
48
|
+
value.x,
|
|
49
|
+
['br'],
|
|
50
|
+
['b', ['y ']],
|
|
51
|
+
value.y,
|
|
52
|
+
['br'],
|
|
53
|
+
['b', ['width ']],
|
|
54
|
+
value.width,
|
|
55
|
+
['br'],
|
|
56
|
+
['b', ['height ']],
|
|
57
|
+
value.height
|
|
58
|
+
]];
|
|
59
|
+
},
|
|
60
|
+
editUI ({typeNamespace, value = {
|
|
61
|
+
x: '',
|
|
62
|
+
y: '',
|
|
63
|
+
width: '',
|
|
64
|
+
height: ''
|
|
65
|
+
}}) {
|
|
66
|
+
// eslint-disable-next-line @stylistic/max-len -- Long
|
|
67
|
+
return ['div', {dataset: {type: 'domrect'}}, /** @type {import('jamilih').JamilihChildren} */ ([
|
|
68
|
+
['label', [
|
|
69
|
+
'x: ',
|
|
70
|
+
['input', {
|
|
71
|
+
class: 'x',
|
|
72
|
+
name: `${typeNamespace}-domrect-x`, value: value.x
|
|
73
|
+
}]
|
|
74
|
+
]],
|
|
75
|
+
['br'],
|
|
76
|
+
['label', [
|
|
77
|
+
'y: ',
|
|
78
|
+
['input', {
|
|
79
|
+
class: 'y',
|
|
80
|
+
name: `${typeNamespace}-domrect-y`, value: value.y
|
|
81
|
+
}]
|
|
82
|
+
]],
|
|
83
|
+
['br'],
|
|
84
|
+
['label', [
|
|
85
|
+
'width: ',
|
|
86
|
+
['input', {
|
|
87
|
+
class: 'width',
|
|
88
|
+
name: `${typeNamespace}-domrect-width`, value: value.width
|
|
89
|
+
}]
|
|
90
|
+
]],
|
|
91
|
+
['br'],
|
|
92
|
+
['label', [
|
|
93
|
+
'height: ',
|
|
94
|
+
['input', {
|
|
95
|
+
class: 'height',
|
|
96
|
+
name: `${typeNamespace}-domrect-height`, value: value.height
|
|
97
|
+
}]
|
|
98
|
+
]]
|
|
99
|
+
])];
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export default domrectType;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import arrayType from './arrayType.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @type {import('../types.js').TypeObject}
|
|
5
|
+
*/
|
|
6
|
+
const filelistType = {
|
|
7
|
+
option: ['FileList'],
|
|
8
|
+
array: true,
|
|
9
|
+
filelist: true,
|
|
10
|
+
regexEndings: [',', ')'],
|
|
11
|
+
stringRegexBegin: /^FileList\(/u,
|
|
12
|
+
stringRegexEnd: /^\)/u,
|
|
13
|
+
|
|
14
|
+
toValue (...args) {
|
|
15
|
+
return arrayType.toValue.apply(this, args);
|
|
16
|
+
},
|
|
17
|
+
getValue (...args) {
|
|
18
|
+
return arrayType.getValue.apply(this, args);
|
|
19
|
+
},
|
|
20
|
+
getInput (...args) {
|
|
21
|
+
return arrayType.getInput.apply(this, args);
|
|
22
|
+
},
|
|
23
|
+
viewUI ({...args}) {
|
|
24
|
+
return arrayType.viewUI.call(this, {
|
|
25
|
+
...args, type: 'filelist'
|
|
26
|
+
});
|
|
27
|
+
},
|
|
28
|
+
editUI ({...args}) {
|
|
29
|
+
return arrayType.editUI.call(this, {
|
|
30
|
+
...args, type: 'filelist'
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default filelistType;
|
package/src/jsoe.css
CHANGED
package/src/types.js
CHANGED
|
@@ -35,7 +35,12 @@ import SpecialNumberSuperType from './superTypes/SpecialNumberType.js';
|
|
|
35
35
|
import errorType from './fundamentalTypes/errorType.js';
|
|
36
36
|
import errorsSpecialType from './superTypes/errorsSpecialType.js';
|
|
37
37
|
import fileType from './fundamentalTypes/fileType.js';
|
|
38
|
+
import filelistType from './fundamentalTypes/filelistType.js';
|
|
38
39
|
import blobType from './fundamentalTypes/blobType.js';
|
|
40
|
+
import domexceptionType from './fundamentalTypes/domexceptionType.js';
|
|
41
|
+
import domrectType from './fundamentalTypes/domrectType.js';
|
|
42
|
+
import dompointType from './fundamentalTypes/dompointType.js';
|
|
43
|
+
import dommatrixType from './fundamentalTypes/dommatrixType.js';
|
|
39
44
|
|
|
40
45
|
/**
|
|
41
46
|
* Utility to retrieve the property value given a legend element.
|
|
@@ -270,9 +275,11 @@ const Types = {};
|
|
|
270
275
|
* @property {boolean} [array] Private context variable. Whether or not
|
|
271
276
|
* it is an array. Do not use in other types.
|
|
272
277
|
* @property {boolean} [map] Private context variable. Whether or not
|
|
273
|
-
* it is a Map
|
|
278
|
+
* it is a `Map`. Do not use in other types.
|
|
274
279
|
* @property {boolean} [set] Private context variable. Whether or not
|
|
275
|
-
* it is a
|
|
280
|
+
* it is a `Set`. Do not use in other types.
|
|
281
|
+
* @property {boolean} [filelist] Private context variable. Whether or not
|
|
282
|
+
* it is a `FileList` type. Do not use in other types.
|
|
276
283
|
* @property {boolean} [sparse] Private context variable. Whether or not
|
|
277
284
|
* it is a sparse array. Do not use in other types.
|
|
278
285
|
* @property {boolean} [valid] Private context variable. Whether or not
|
|
@@ -386,11 +393,15 @@ Types.availableTypes = {
|
|
|
386
393
|
set: setType,
|
|
387
394
|
|
|
388
395
|
file: fileType,
|
|
389
|
-
filelist:
|
|
390
|
-
option: ['FileList']
|
|
391
|
-
},
|
|
396
|
+
filelist: filelistType,
|
|
392
397
|
blob: blobType,
|
|
393
398
|
blobHTML: blobHTMLType,
|
|
399
|
+
|
|
400
|
+
domexception: domexceptionType,
|
|
401
|
+
domrect: domrectType,
|
|
402
|
+
dompoint: dompointType,
|
|
403
|
+
dommatrix: dommatrixType,
|
|
404
|
+
|
|
394
405
|
arraybuffer: {
|
|
395
406
|
option: ['ArrayBuffer']
|
|
396
407
|
},
|
|
@@ -436,17 +447,6 @@ Types.availableTypes = {
|
|
|
436
447
|
option: ['Float64Array']
|
|
437
448
|
},
|
|
438
449
|
|
|
439
|
-
// Intl (imperfect)
|
|
440
|
-
IntlCollator: {
|
|
441
|
-
option: ['Intl.Collator']
|
|
442
|
-
},
|
|
443
|
-
IntlDateTimeFormat: {
|
|
444
|
-
option: ['Intl.DateTimeFormat']
|
|
445
|
-
},
|
|
446
|
-
IntlNumberFormat: {
|
|
447
|
-
option: ['Intl.NumberFormat']
|
|
448
|
-
},
|
|
449
|
-
|
|
450
450
|
// We're catching this instead of using this
|
|
451
451
|
// sparseUndefined: sparseUndefinedType,
|
|
452
452
|
|
|
@@ -470,9 +470,9 @@ Types.availableTypes = {
|
|
|
470
470
|
* "NumberObject"|"StringObject"|"map"|"set"|"file"|"filelist"|"blobHTML"|
|
|
471
471
|
* "arraybuffer"|"arraybufferview"|"dataview"|"imagedata"|"imagebitmap"|
|
|
472
472
|
* "int8array"|"uint8array"|"uint8clampedarray"|"int16array"|"uint16array"|
|
|
473
|
-
* "int32array"|"uint32array"|"float32array"|"float64array"|"
|
|
474
|
-
* "
|
|
475
|
-
* "
|
|
473
|
+
* "int32array"|"uint32array"|"float32array"|"float64array"|"ValidDate"|
|
|
474
|
+
* "arrayNonindexKeys"|"error"|"errors"|"blob"|"domexception"|"domrect"|
|
|
475
|
+
* "dompoint"|"dommatrix"} AvailableType
|
|
476
476
|
*/
|
|
477
477
|
|
|
478
478
|
/**
|