@drax/crud-vue 3.48.0 → 3.48.2
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
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "3.48.
|
|
6
|
+
"version": "3.48.2",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "./src/index.ts",
|
|
9
9
|
"module": "./src/index.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@drax/common-front": "^3.29.0",
|
|
28
28
|
"@drax/crud-front": "^3.21.0",
|
|
29
29
|
"@drax/crud-share": "^3.48.0",
|
|
30
|
-
"@drax/media-vue": "^3.48.
|
|
30
|
+
"@drax/media-vue": "^3.48.2"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"pinia": "^3.0.4",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"vue-tsc": "^3.2.4",
|
|
51
51
|
"vuetify": "^3.11.8"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "f5bb4bb2e3c724572043e56a65be9c6aa6876717"
|
|
54
54
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {describe, expect, it} from "vitest";
|
|
2
|
+
|
|
3
|
+
describe("CrudButtonConfig", () => {
|
|
4
|
+
it("shares config between duplicated module instances", async () => {
|
|
5
|
+
const first = await import("./CrudButtonConfig");
|
|
6
|
+
const duplicatedModulePath = "./CrudButtonConfig?duplicated";
|
|
7
|
+
const second = await import(duplicatedModulePath) as typeof import("./CrudButtonConfig");
|
|
8
|
+
|
|
9
|
+
first.resetCrudButtonsConfig();
|
|
10
|
+
first.configureCrudButtons({
|
|
11
|
+
defaults: {
|
|
12
|
+
variant: "elevated",
|
|
13
|
+
rounded: 0,
|
|
14
|
+
color: "deep-purple-accent-4",
|
|
15
|
+
},
|
|
16
|
+
buttons: {
|
|
17
|
+
create: {
|
|
18
|
+
icon: "md:add_circle",
|
|
19
|
+
color: "green-accent-4",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
expect(second.getCrudButtonConfig("create")).toMatchObject({
|
|
25
|
+
icon: "md:add_circle",
|
|
26
|
+
variant: "elevated",
|
|
27
|
+
rounded: 0,
|
|
28
|
+
color: "green-accent-4",
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
first.resetCrudButtonsConfig();
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -55,10 +55,22 @@ const crudButtonDefaultStyles: Record<CrudButtonName, CrudButtonStyle> = {
|
|
|
55
55
|
view: {icon: "mdi-magnify", variant: "text", color: "teal"},
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
const crudButtonsConfigGlobalKey = "__draxCrudVueCrudButtonsConfig";
|
|
59
|
+
|
|
60
|
+
type CrudButtonsConfigGlobal = typeof globalThis & {
|
|
61
|
+
[crudButtonsConfigGlobalKey]?: Required<CrudButtonsConfig>;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
function createCrudButtonsConfig(): Required<CrudButtonsConfig> {
|
|
65
|
+
return reactive<Required<CrudButtonsConfig>>({
|
|
66
|
+
defaults: {},
|
|
67
|
+
buttons: {},
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const crudButtonsConfigGlobal = globalThis as CrudButtonsConfigGlobal;
|
|
72
|
+
const crudButtonsConfig = crudButtonsConfigGlobal[crudButtonsConfigGlobalKey]
|
|
73
|
+
|| (crudButtonsConfigGlobal[crudButtonsConfigGlobalKey] = createCrudButtonsConfig());
|
|
62
74
|
|
|
63
75
|
export function configureCrudButtons(config: CrudButtonsConfig) {
|
|
64
76
|
if (config.defaults) {
|