@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.0",
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.0"
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": "455427fd48fc742af2e301ab85af2d48e5b2da16"
53
+ "gitHead": "f5bb4bb2e3c724572043e56a65be9c6aa6876717"
54
54
  }
@@ -28,7 +28,7 @@ const {
28
28
  <v-btn
29
29
  v-bind="props"
30
30
  id="crud-columns-button"
31
- class="crud-columns-button"
31
+ class="crud-columns-button mr-1"
32
32
  icon
33
33
  :variant="buttonConfig.variant"
34
34
  :rounded="buttonConfig.rounded"
@@ -16,7 +16,6 @@ const buttonConfig = useCrudButtonConfig("view")
16
16
  :variant="buttonConfig.variant"
17
17
  :rounded="buttonConfig.rounded"
18
18
  :color="buttonConfig.color"
19
- slim
20
19
  >
21
20
  </v-btn>
22
21
  </template>
@@ -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 crudButtonsConfig = reactive<Required<CrudButtonsConfig>>({
59
- defaults: {},
60
- buttons: {},
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) {