@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inglorious/web",
3
- "version": "2.6.1",
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/store": "8.0.0",
44
- "@inglorious/utils": "3.7.0"
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
  },
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import { beforeEach, describe, expect, it, vi } from "vitest"
5
5
 
6
- import { form, getFieldError, getFieldValue, isFieldTouched } from "./form.js"
6
+ import { form, getFieldError, getFieldValue, isFieldTouched } from "."
7
7
 
8
8
  describe("form", () => {
9
9
  let entity
@@ -1,21 +1,21 @@
1
1
  import { clone, get, set } from "@inglorious/utils/data-structures/object.js"
2
2
 
3
3
  /**
4
- * @typedef {import('../types/form.js').FormEntity} FormEntity
5
- * @typedef {import('../types/form.js').FormFieldChangePayload} FormFieldChangePayload
6
- * @typedef {import('../types/form.js').FormFieldBlurPayload} FormFieldBlurPayload
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('../types/form.js').FormErrors<object>} validate - A function that validates the entire form's values and returns a complete error object.
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('../types/form.js').FormErrors<object>>} validate - An async function that validates the entire form's values.
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('../types/form.js').FormErrors<object>} errors - The validation errors.
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('../types/list').ListEntity} ListEntity
10
- * @typedef {import('../types/mount').Api} Api
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
 
@@ -4,7 +4,7 @@
4
4
  import { html } from "lit-html"
5
5
  import { beforeEach, describe, expect, it, vi } from "vitest"
6
6
 
7
- import { list } from "./list.js"
7
+ import { list } from "."
8
8
 
9
9
  describe("list", () => {
10
10
  let entity
@@ -1,7 +1,7 @@
1
1
  /**
2
- * @typedef {import("../types/router").RouterType} RouterType
3
- * @typedef {import("../types/router").RouterEntity} RouterEntity
4
- * @typedef {import("../types/router").Api} Api
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 { afterEach, beforeEach, describe, expect, it, vi } from "vitest"
5
5
 
6
- import { router } from "./router.js"
6
+ import { router } from "."
7
7
 
8
8
  describe("router", () => {
9
9
  let entity
@@ -0,0 +1,7 @@
1
+ import { logic } from "./logic.js"
2
+ import { rendering } from "./rendering.js"
3
+
4
+ export const select = {
5
+ ...logic,
6
+ ...rendering,
7
+ }
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import { beforeEach, describe, expect, it } from "vitest"
5
5
 
6
- import { select } from "./select.js"
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 "./select/logic.js"
15
+ } from "./logic.js"
16
16
 
17
17
  const sampleOptions = [
18
18
  { value: "br", label: "Brazil" },
@@ -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) {
@@ -0,0 +1,7 @@
1
+ import { logic } from "./logic.js"
2
+ import { rendering } from "./rendering.js"
3
+
4
+ export const table = {
5
+ ...logic,
6
+ ...rendering,
7
+ }
@@ -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 "./table.js"
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 "./table/logic.js"
20
+ } from "./logic.js"
21
21
 
22
22
  const sampleData = [
23
23
  { id: 1, name: "Charlie", age: 35, active: true, role: "Admin" },
@@ -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
@@ -1,7 +0,0 @@
1
- import { logic } from "./select/logic.js"
2
- import { rendering } from "./select/rendering.js"
3
-
4
- export const select = {
5
- ...logic,
6
- ...rendering,
7
- }
package/src/table.js DELETED
@@ -1,7 +0,0 @@
1
- import { logic } from "./table/logic"
2
- import { rendering } from "./table/rendering"
3
-
4
- export const table = {
5
- ...logic,
6
- ...rendering,
7
- }