@esportsplus/ui 0.4.0 → 0.5.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.
|
@@ -2,12 +2,21 @@ import response from '@esportsplus/action';
|
|
|
2
2
|
import input from './input';
|
|
3
3
|
function parse(input) {
|
|
4
4
|
let data = {};
|
|
5
|
-
for (let path
|
|
5
|
+
for (let [path, value] of input) {
|
|
6
6
|
let bucket = data, keys = path.indexOf('.') !== -1 ? path.split('.') : [path];
|
|
7
7
|
for (let i = 0; i < keys.length - 1; i++) {
|
|
8
8
|
bucket = bucket[keys[i]] = bucket[keys[i]] || {};
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
if (path.endsWith('[]')) {
|
|
11
|
+
if (typeof value === 'string' && value.trim() === '') {
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
bucket = bucket[keys.at(-1)] ??= [];
|
|
15
|
+
bucket.push(value);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
bucket[keys[keys.length - 1]] = value;
|
|
19
|
+
}
|
|
11
20
|
}
|
|
12
21
|
return data;
|
|
13
22
|
}
|
|
@@ -27,7 +36,7 @@ export default function (action) {
|
|
|
27
36
|
event?.submitter?.classList.add('button--processing');
|
|
28
37
|
let { errors } = await action({
|
|
29
38
|
alert: null,
|
|
30
|
-
input: parse(
|
|
39
|
+
input: parse(new FormData(this).entries()),
|
|
31
40
|
response
|
|
32
41
|
});
|
|
33
42
|
for (let i = 0, n = errors.length; i < n; i++) {
|
package/normalize.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
/*! modern-normalize v3.0.
|
|
1
|
+
/*! modern-normalize v3.0.1 | MIT License | https://github.com/sindresorhus/modern-normalize */*,::before,::after{box-sizing:border-box}html{font-family:system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";line-height:1.15;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4}body{margin:0}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-0.25em}sup{top:-0.5em}table{border-color:currentcolor}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,[type=button],[type=reset],[type=submit]{-webkit-appearance:button}legend{padding:0}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}
|
package/package.json
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
"author": "ICJR",
|
|
3
3
|
"dependencies": {
|
|
4
4
|
"@esportsplus/action": "^0.0.50",
|
|
5
|
-
"@esportsplus/reactivity": "^0.2.
|
|
6
|
-
"@esportsplus/template": "^0.6.
|
|
5
|
+
"@esportsplus/reactivity": "^0.2.7",
|
|
6
|
+
"@esportsplus/template": "^0.6.5"
|
|
7
7
|
},
|
|
8
8
|
"devDependencies": {
|
|
9
|
-
"@esportsplus/webpack": "^0.4.
|
|
10
|
-
"modern-normalize": "^3.0.
|
|
9
|
+
"@esportsplus/webpack": "^0.4.13",
|
|
10
|
+
"modern-normalize": "^3.0.1"
|
|
11
11
|
},
|
|
12
12
|
"main": "build/index.js",
|
|
13
13
|
"name": "@esportsplus/ui",
|
|
@@ -21,5 +21,5 @@
|
|
|
21
21
|
},
|
|
22
22
|
"sideEffects": false,
|
|
23
23
|
"types": "build/index.d.ts",
|
|
24
|
-
"version": "0.
|
|
24
|
+
"version": "0.5.0"
|
|
25
25
|
}
|
|
@@ -4,18 +4,28 @@ import { Action } from './types';
|
|
|
4
4
|
import input from './input';
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
function parse(input:
|
|
7
|
+
function parse(input: ReturnType<FormData['entries']>) {
|
|
8
8
|
let data: Record<string, any> = {};
|
|
9
9
|
|
|
10
|
-
for (let path
|
|
10
|
+
for (let [path, value] of input) {
|
|
11
11
|
let bucket = data,
|
|
12
12
|
keys = path.indexOf('.') !== -1 ? path.split('.') : [path];
|
|
13
13
|
|
|
14
14
|
for (let i = 0; i < keys.length - 1; i++) {
|
|
15
|
-
bucket = bucket[keys[i]] = bucket[keys[i]] || {};
|
|
15
|
+
bucket = bucket[ keys[i] ] = bucket[ keys[i] ] || {};
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
if (path.endsWith('[]')) {
|
|
19
|
+
if (typeof value === 'string' && value.trim() === '') {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
bucket = bucket[ keys.at(-1)! ] ??= [];
|
|
24
|
+
bucket.push(value);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
bucket[keys[keys.length - 1]] = value;
|
|
28
|
+
}
|
|
19
29
|
}
|
|
20
30
|
|
|
21
31
|
return data;
|
|
@@ -39,7 +49,7 @@ export default function(action: Action) {
|
|
|
39
49
|
);
|
|
40
50
|
},
|
|
41
51
|
onsubmit: async function(this: HTMLFormElement, event: SubmitEvent) {
|
|
42
|
-
// TODO: Figure out processing
|
|
52
|
+
// TODO: Figure out button--processing
|
|
43
53
|
// - Could pass reactive value above and tie it to form layout handler
|
|
44
54
|
event.preventDefault();
|
|
45
55
|
event?.submitter?.classList.add('button--processing');
|
|
@@ -47,7 +57,7 @@ export default function(action: Action) {
|
|
|
47
57
|
let { errors } = await action({
|
|
48
58
|
// @ts-ignore
|
|
49
59
|
alert: null,
|
|
50
|
-
input: parse(
|
|
60
|
+
input: parse( new FormData( this ).entries() ),
|
|
51
61
|
response
|
|
52
62
|
});
|
|
53
63
|
|