@platforma-sdk/ui-vue 1.4.8 → 1.4.9

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": "@platforma-sdk/ui-vue",
3
- "version": "1.4.8",
3
+ "version": "1.4.9",
4
4
  "type": "module",
5
5
  "main": "dist/lib.umd.cjs",
6
6
  "module": "dist/lib.js",
@@ -25,14 +25,14 @@
25
25
  "@platforma-sdk/model": "^1.2.32"
26
26
  },
27
27
  "devDependencies": {
28
- "@ag-grid-community/client-side-row-model": "^32.2.1",
29
- "@ag-grid-community/core": "^32.2.1",
30
- "@ag-grid-community/infinite-row-model": "^32.2.1",
31
- "@ag-grid-community/styles": "^32.2.1",
32
- "@ag-grid-community/vue3": "^32.2.1",
33
- "@ag-grid-enterprise/core": "^32.2.1",
34
- "@ag-grid-enterprise/clipboard": "^32.2.1",
35
- "@ag-grid-enterprise/range-selection": "^32.2.1",
28
+ "@ag-grid-community/client-side-row-model": "^32.2.2",
29
+ "@ag-grid-community/core": "^32.2.2",
30
+ "@ag-grid-community/infinite-row-model": "^32.2.2",
31
+ "@ag-grid-community/styles": "^32.2.2",
32
+ "@ag-grid-community/vue3": "^32.2.2",
33
+ "@ag-grid-enterprise/core": "^32.2.2",
34
+ "@ag-grid-enterprise/clipboard": "^32.2.2",
35
+ "@ag-grid-enterprise/range-selection": "^32.2.2",
36
36
  "@faker-js/faker": "^8.4.0",
37
37
  "@types/lodash": "^4.17.7",
38
38
  "@types/node": "~20.16.5",
package/src/aggrid.ts CHANGED
@@ -1,7 +1,10 @@
1
1
  import { getEnvironmentValue } from '@platforma-sdk/model';
2
2
  import { LicenseManager } from '@ag-grid-enterprise/core';
3
3
 
4
- export function setAgGridLicense() {
4
+ export function activateAgGrid() {
5
5
  const agGridLicense = getEnvironmentValue('AGGRID_LICENSE');
6
- if (agGridLicense) LicenseManager.setLicenseKey(agGridLicense);
6
+ if (agGridLicense) {
7
+ LicenseManager.setLicenseKey(agGridLicense);
8
+ console.log('AGGrid Activated');
9
+ }
7
10
  }
@@ -1,7 +1,7 @@
1
1
  import { reactive, computed, ref, watch, unref } from 'vue';
2
2
  import type { ZodError } from 'zod';
3
3
  import type { ModelOptions, Model } from './types';
4
- import { deepEqual, deepClone } from '@milaboratories/helpers';
4
+ import { deepClone } from '@milaboratories/helpers';
5
5
  import { isJsonEqual } from './utils';
6
6
 
7
7
  const identity = <T, V = T>(v: T): V => v as unknown as V;
@@ -33,22 +33,26 @@ export function createModel<M, V = unknown>(options: ModelOptions<M, V>): Model<
33
33
 
34
34
  const error = ref<Error | undefined>();
35
35
 
36
- const local = ref<M>();
36
+ const local = ref<{ model: M }>();
37
+
38
+ const setSource = (v: M) => {
39
+ local.value = {
40
+ model: deepClone(v),
41
+ };
42
+ };
37
43
 
38
44
  watch(
39
45
  () => options.get(),
40
- (v) => {
41
- local.value = deepClone(v);
42
- },
46
+ (v) => setSource(v),
43
47
  { immediate: true },
44
48
  );
45
49
 
46
50
  const save = () => {
47
- options.onSave(validate(deepClone(local.value)));
51
+ options.onSave(validate(deepClone(local.value?.model)));
48
52
  };
49
53
 
50
54
  const revert = () => {
51
- local.value = deepClone(options.get());
55
+ setSource(options.get());
52
56
  error.value = undefined;
53
57
  };
54
58
 
@@ -75,19 +79,19 @@ export function createModel<M, V = unknown>(options: ModelOptions<M, V>): Model<
75
79
 
76
80
  const model = computed<M>({
77
81
  get: () => {
78
- return local.value as M;
82
+ return local.value?.model as M;
79
83
  },
80
84
  set(v) {
81
- local.value = v;
85
+ setSource(v);
82
86
  setValue(v);
83
87
  },
84
88
  });
85
89
 
86
90
  watch(
87
91
  local,
88
- (v) => {
89
- if (!isJsonEqual(options.get(), v)) {
90
- setValue(v as M);
92
+ (v, old) => {
93
+ if (v && v === old) {
94
+ setValue(v.model);
91
95
  }
92
96
  },
93
97
  { deep: true },
@@ -96,13 +100,13 @@ export function createModel<M, V = unknown>(options: ModelOptions<M, V>): Model<
96
100
  const valid = computed(() => !error.value);
97
101
 
98
102
  const isChanged = computed(() => {
99
- return !deepEqual(options.get(), unref(local));
103
+ return !isJsonEqual(options.get(), unref(local)); // @TODO, can be slow
100
104
  });
101
105
 
102
106
  const errorString = computed(() => (error.value ? error.value.message : ''));
103
107
 
104
108
  return reactive({
105
- model: model,
109
+ model,
106
110
  valid,
107
111
  isChanged,
108
112
  error,
package/src/defineApp.ts CHANGED
@@ -4,7 +4,7 @@ import type { Component, Reactive } from 'vue';
4
4
  import { inject, markRaw, reactive } from 'vue';
5
5
  import { createApp, type BaseApp } from './internal/createApp';
6
6
  import type { LocalState, Routes } from './types';
7
- import { setAgGridLicense } from './aggrid';
7
+ import { activateAgGrid } from './aggrid';
8
8
 
9
9
  const pluginKey = Symbol('sdk-vue');
10
10
 
@@ -22,7 +22,7 @@ export function defineApp<
22
22
  >(platforma: Platforma<Args, Outputs, UiState, Href>, extendApp: (app: BaseApp<Args, Outputs, UiState, Href>) => Local) {
23
23
  let app: undefined | App<Args, Outputs, UiState, Href, Local> = undefined;
24
24
 
25
- setAgGridLicense();
25
+ activateAgGrid();
26
26
 
27
27
  const loadApp = () => {
28
28
  platforma
package/src/lib.ts CHANGED
@@ -15,6 +15,8 @@ export * from './types';
15
15
 
16
16
  export * from './defineStore';
17
17
 
18
+ export * from './aggrid';
19
+
18
20
  export * from './utils';
19
21
 
20
22
  export * from './computedResult';