@inglorious/web 2.6.1 → 3.0.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/package.json +24 -4
- package/src/{form.test.js → form/form.test.js} +1 -1
- package/src/{form.js → form/index.js} +6 -6
- package/src/index.js +1 -6
- package/src/{list.js → list/index.js} +2 -2
- package/src/{list.test.js → list/list.test.js} +1 -1
- package/src/{router.js → router/index.js} +15 -3
- package/src/{router.test.js → router/router.test.js} +1 -1
- package/src/select/index.js +7 -0
- package/src/{select.test.js → select/select.test.js} +2 -2
- package/src/table/filters.js +5 -5
- package/src/table/index.js +7 -0
- package/src/table/rendering.js +2 -2
- package/src/{table.test.js → table/table.test.js} +2 -2
- package/src/table/theme.css +83 -83
- package/src/select.js +0 -7
- package/src/table.js +0 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inglorious/web",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "A new web framework that leverages the power of the Inglorious Store combined with the performance and simplicity of lit-html.",
|
|
5
5
|
"author": "IceOnFire <antony.mistretta@gmail.com> (https://ingloriouscoderz.it)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,6 +26,26 @@
|
|
|
26
26
|
"types": "./types/index.d.ts",
|
|
27
27
|
"import": "./src/index.js"
|
|
28
28
|
},
|
|
29
|
+
"./form": {
|
|
30
|
+
"types": "./types/form.d.ts",
|
|
31
|
+
"import": "./src/form/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./list": {
|
|
34
|
+
"types": "./types/list.d.ts",
|
|
35
|
+
"import": "./src/list/index.js"
|
|
36
|
+
},
|
|
37
|
+
"./router": {
|
|
38
|
+
"types": "./types/router.d.ts",
|
|
39
|
+
"import": "./src/router/index.js"
|
|
40
|
+
},
|
|
41
|
+
"./select": {
|
|
42
|
+
"types": "./types/select.d.ts",
|
|
43
|
+
"import": "./src/select/index.js"
|
|
44
|
+
},
|
|
45
|
+
"./table": {
|
|
46
|
+
"types": "./types/table.d.ts",
|
|
47
|
+
"import": "./src/table/index.js"
|
|
48
|
+
},
|
|
29
49
|
"./table/base.css": "./src/table/base.css",
|
|
30
50
|
"./table/theme.css": "./src/table/theme.css",
|
|
31
51
|
"./select/base.css": "./src/select/base.css",
|
|
@@ -38,14 +58,14 @@
|
|
|
38
58
|
"publishConfig": {
|
|
39
59
|
"access": "public"
|
|
40
60
|
},
|
|
61
|
+
"sideEffects": false,
|
|
41
62
|
"dependencies": {
|
|
42
63
|
"lit-html": "^3.3.1",
|
|
43
|
-
"@inglorious/
|
|
44
|
-
"@inglorious/
|
|
64
|
+
"@inglorious/utils": "3.7.0",
|
|
65
|
+
"@inglorious/store": "8.0.0"
|
|
45
66
|
},
|
|
46
67
|
"devDependencies": {
|
|
47
68
|
"prettier": "^3.6.2",
|
|
48
|
-
"vite": "^7.1.3",
|
|
49
69
|
"vitest": "^4.0.15",
|
|
50
70
|
"@inglorious/eslint-config": "1.1.1"
|
|
51
71
|
},
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { clone, get, set } from "@inglorious/utils/data-structures/object.js"
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @typedef {import('
|
|
5
|
-
* @typedef {import('
|
|
6
|
-
* @typedef {import('
|
|
4
|
+
* @typedef {import('../../types/form.js').FormEntity} FormEntity
|
|
5
|
+
* @typedef {import('../../types/form.js').FormFieldChangePayload} FormFieldChangePayload
|
|
6
|
+
* @typedef {import('../../types/form.js').FormFieldBlurPayload} FormFieldBlurPayload
|
|
7
7
|
*
|
|
8
8
|
* @typedef {object} FormValidatePayload
|
|
9
9
|
* @property {string|number} entityId - The ID of the target form entity.
|
|
10
|
-
* @property {(values: object) => import('
|
|
10
|
+
* @property {(values: object) => import('../../types/form.js').FormErrors<object>} validate - A function that validates the entire form's values and returns a complete error object.
|
|
11
11
|
*
|
|
12
12
|
* @typedef {object} FormValidateAsyncPayload
|
|
13
13
|
* @property {string|number} entityId - The ID of the target form entity.
|
|
14
|
-
* @property {(values: object) => Promise<import('
|
|
14
|
+
* @property {(values: object) => Promise<import('../../types/form.js').FormErrors<object>>} validate - An async function that validates the entire form's values.
|
|
15
15
|
*
|
|
16
16
|
* @typedef {object} FormValidationCompletePayload
|
|
17
17
|
* @property {string|number} entityId - The ID of the target form entity.
|
|
18
|
-
* @property {import('
|
|
18
|
+
* @property {import('../../types/form.js').FormErrors<object>} errors - The validation errors.
|
|
19
19
|
* @property {boolean} isValid - Whether the form is valid.
|
|
20
20
|
*
|
|
21
21
|
* @typedef {object} FormValidationErrorPayload
|
package/src/index.js
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
export { form, getFieldError, getFieldValue, isFieldTouched } from "./form.js"
|
|
2
|
-
export { list } from "./list.js"
|
|
3
1
|
export { mount } from "./mount.js"
|
|
4
|
-
export { router } from "./router.js"
|
|
5
|
-
export { select } from "./select.js"
|
|
6
|
-
export { table } from "./table.js"
|
|
7
2
|
export { createStore } from "@inglorious/store"
|
|
8
3
|
export { createDevtools } from "@inglorious/store/client/devtools.js"
|
|
9
4
|
export { createSelector } from "@inglorious/store/select.js"
|
|
10
|
-
export { trigger } from "@inglorious/store/test"
|
|
5
|
+
export { trigger } from "@inglorious/store/test.js"
|
|
11
6
|
export { html, render, svg } from "lit-html"
|
|
12
7
|
export { choose } from "lit-html/directives/choose.js"
|
|
13
8
|
export { classMap } from "lit-html/directives/class-map.js"
|
|
@@ -6,8 +6,8 @@ const LIST_START = 0
|
|
|
6
6
|
const PRETTY_INDEX = 1
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* @typedef {import('
|
|
10
|
-
* @typedef {import('
|
|
9
|
+
* @typedef {import('../../types/list').ListEntity} ListEntity
|
|
10
|
+
* @typedef {import('../../types/mount').Api} Api
|
|
11
11
|
* @typedef {import('lit-html').TemplateResult} TemplateResult
|
|
12
12
|
*/
|
|
13
13
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {import("
|
|
3
|
-
* @typedef {import("
|
|
4
|
-
* @typedef {import("
|
|
2
|
+
* @typedef {import("../../types/router").RouterType} RouterType
|
|
3
|
+
* @typedef {import("../../types/router").RouterEntity} RouterEntity
|
|
4
|
+
* @typedef {import("../../types/router").Api} Api
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
const SKIP_FULL_MATCH_GROUP = 1 // .match() result at index 0 is the full string
|
|
@@ -83,6 +83,18 @@ export const router = {
|
|
|
83
83
|
})
|
|
84
84
|
},
|
|
85
85
|
|
|
86
|
+
create(entity) {
|
|
87
|
+
entity.routes ??= {}
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
routeAdd(entity, route) {
|
|
91
|
+
entity.routes[route.path] = route.entityType
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
routeRemove(entity, path) {
|
|
95
|
+
delete [entity.routes[path]]
|
|
96
|
+
},
|
|
97
|
+
|
|
86
98
|
/**
|
|
87
99
|
* Handles navigation to a new route.
|
|
88
100
|
* @param {RouterEntity} entity - The router entity.
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { beforeEach, describe, expect, it } from "vitest"
|
|
5
5
|
|
|
6
|
-
import { select } from "
|
|
6
|
+
import { select } from "."
|
|
7
7
|
import {
|
|
8
8
|
filterOptions,
|
|
9
9
|
findOptionIndex,
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
getOptionValue,
|
|
13
13
|
groupOptions,
|
|
14
14
|
isOptionSelected,
|
|
15
|
-
} from "./
|
|
15
|
+
} from "./logic.js"
|
|
16
16
|
|
|
17
17
|
const sampleOptions = [
|
|
18
18
|
{ value: "br", label: "Brazil" },
|
package/src/table/filters.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { choose, html } from "@inglorious/web"
|
|
2
2
|
|
|
3
|
-
import { dateFilter } from "./filters/date"
|
|
4
|
-
import { numberFilter } from "./filters/number"
|
|
5
|
-
import { rangeFilter } from "./filters/range"
|
|
6
|
-
import { selectFilter } from "./filters/select"
|
|
7
|
-
import { textFilter } from "./filters/text"
|
|
3
|
+
import { dateFilter } from "./filters/date.js"
|
|
4
|
+
import { numberFilter } from "./filters/number.js"
|
|
5
|
+
import { rangeFilter } from "./filters/range.js"
|
|
6
|
+
import { selectFilter } from "./filters/select.js"
|
|
7
|
+
import { textFilter } from "./filters/text.js"
|
|
8
8
|
|
|
9
9
|
export const filters = {
|
|
10
10
|
render(entity, column, api) {
|
package/src/table/rendering.js
CHANGED
|
@@ -2,8 +2,8 @@ import { html } from "lit-html"
|
|
|
2
2
|
import { classMap } from "lit-html/directives/class-map.js"
|
|
3
3
|
import { ref } from "lit-html/directives/ref.js"
|
|
4
4
|
|
|
5
|
-
import { filters } from "./filters"
|
|
6
|
-
import { getPaginationInfo, getRows, getSortDirection } from "./logic"
|
|
5
|
+
import { filters } from "./filters.js"
|
|
6
|
+
import { getPaginationInfo, getRows, getSortDirection } from "./logic.js"
|
|
7
7
|
|
|
8
8
|
const DIVISOR = 2
|
|
9
9
|
const FIRST_PAGE = 0
|
|
@@ -9,7 +9,7 @@ vi.mock("./table/filters.js", () => ({
|
|
|
9
9
|
filters: { render: () => html`` },
|
|
10
10
|
}))
|
|
11
11
|
|
|
12
|
-
import { table } from "
|
|
12
|
+
import { table } from "."
|
|
13
13
|
import {
|
|
14
14
|
getPaginationInfo,
|
|
15
15
|
getRows,
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
getTotalRows,
|
|
18
18
|
isAllSelected,
|
|
19
19
|
isSomeSelected,
|
|
20
|
-
} from "./
|
|
20
|
+
} from "./logic.js"
|
|
21
21
|
|
|
22
22
|
const sampleData = [
|
|
23
23
|
{ id: 1, name: "Charlie", age: 35, active: true, role: "Admin" },
|
package/src/table/theme.css
CHANGED
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
.iw-table {
|
|
2
|
-
.iw-table-header {
|
|
3
|
-
border-bottom: 1px solid grey;
|
|
4
|
-
padding: 1em 0;
|
|
5
|
-
row-gap: 1em;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
.iw-table-header-row {
|
|
9
|
-
align-items: flex-start;
|
|
10
|
-
column-gap: 1em;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.iw-table-header-column {
|
|
14
|
-
row-gap: 0.5em;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.iw-table-header-title {
|
|
18
|
-
font-weight: bold;
|
|
19
|
-
white-space: nowrap;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.iw-table-body {
|
|
23
|
-
max-height: 35em;
|
|
24
|
-
overflow: auto;
|
|
25
|
-
border-bottom: 1px solid grey;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.iw-table-row {
|
|
29
|
-
align-items: center;
|
|
30
|
-
column-gap: 1em;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.iw-table-row-even {
|
|
34
|
-
background-color: aliceblue;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.iw-table-row-selected {
|
|
38
|
-
border-left: 1px solid cornflowerblue;
|
|
39
|
-
border-right: 1px solid cornflowerblue;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
:not(.iw-table-row-selected) + .iw-table-row-selected {
|
|
43
|
-
border-top: 1px solid cornflowerblue;
|
|
44
|
-
margin-top: -1px;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.iw-table-row-selected + :not(.iw-table-row-selected) {
|
|
48
|
-
border-top: 1px solid cornflowerblue;
|
|
49
|
-
margin-top: -1px;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.iw-table-cell {
|
|
53
|
-
padding: 1em;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.iw-table-cell-number,
|
|
57
|
-
.iw-table-cell-date {
|
|
58
|
-
text-align: right;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.iw-table-cell-boolean {
|
|
62
|
-
text-align: center;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.iw-table-footer {
|
|
66
|
-
padding: 1em 0;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.iw-table-footer-row {
|
|
70
|
-
justify-content: space-between;
|
|
71
|
-
align-items: center;
|
|
72
|
-
column-gap: 1em;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.iw-table-page-input {
|
|
76
|
-
min-width: 4em;
|
|
77
|
-
text-align: right;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.iw-table-pagination-button {
|
|
81
|
-
white-space: nowrap;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
1
|
+
.iw-table {
|
|
2
|
+
.iw-table-header {
|
|
3
|
+
border-bottom: 1px solid grey;
|
|
4
|
+
padding: 1em 0;
|
|
5
|
+
row-gap: 1em;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.iw-table-header-row {
|
|
9
|
+
align-items: flex-start;
|
|
10
|
+
column-gap: 1em;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.iw-table-header-column {
|
|
14
|
+
row-gap: 0.5em;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.iw-table-header-title {
|
|
18
|
+
font-weight: bold;
|
|
19
|
+
white-space: nowrap;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.iw-table-body {
|
|
23
|
+
max-height: 35em;
|
|
24
|
+
overflow: auto;
|
|
25
|
+
border-bottom: 1px solid grey;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.iw-table-row {
|
|
29
|
+
align-items: center;
|
|
30
|
+
column-gap: 1em;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.iw-table-row-even {
|
|
34
|
+
background-color: aliceblue;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.iw-table-row-selected {
|
|
38
|
+
border-left: 1px solid cornflowerblue;
|
|
39
|
+
border-right: 1px solid cornflowerblue;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
:not(.iw-table-row-selected) + .iw-table-row-selected {
|
|
43
|
+
border-top: 1px solid cornflowerblue;
|
|
44
|
+
margin-top: -1px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.iw-table-row-selected + :not(.iw-table-row-selected) {
|
|
48
|
+
border-top: 1px solid cornflowerblue;
|
|
49
|
+
margin-top: -1px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.iw-table-cell {
|
|
53
|
+
padding: 1em;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.iw-table-cell-number,
|
|
57
|
+
.iw-table-cell-date {
|
|
58
|
+
text-align: right;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.iw-table-cell-boolean {
|
|
62
|
+
text-align: center;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.iw-table-footer {
|
|
66
|
+
padding: 1em 0;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.iw-table-footer-row {
|
|
70
|
+
justify-content: space-between;
|
|
71
|
+
align-items: center;
|
|
72
|
+
column-gap: 1em;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.iw-table-page-input {
|
|
76
|
+
min-width: 4em;
|
|
77
|
+
text-align: right;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.iw-table-pagination-button {
|
|
81
|
+
white-space: nowrap;
|
|
82
|
+
}
|
|
83
|
+
}
|
package/src/select.js
DELETED