@retailcrm/embed-ui 0.5.4 → 0.5.6
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/CHANGELOG.md +10 -0
- package/dist/index.cjs +13 -3
- package/dist/index.mjs +13 -3
- package/index.d.ts +17 -4
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
## [0.5.6](https://github.com/retailcrm/embed-ui/compare/v0.5.5...v0.5.6) (2025-01-03)
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* Updated vue-remote to v0.2.5 with fixes to host tree update mechanism ([72427e5](https://github.com/retailcrm/embed-ui/commit/72427e5883d51090a684b91d5e18ec508fa04389))
|
|
9
|
+
## [0.5.5](https://github.com/retailcrm/embed-ui/compare/v0.5.4...v0.5.5) (2024-12-28)
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* Added options to useCustomField so it is possible to narrow it's type & handle errors of interactions with host ([43a08fa](https://github.com/retailcrm/embed-ui/commit/43a08fa3c651775342d59d6eec56b97c3cc56a66))
|
|
4
14
|
## [0.5.4](https://github.com/retailcrm/embed-ui/compare/v0.5.3...v0.5.4) (2024-12-25)
|
|
5
15
|
|
|
6
16
|
### Bug Fixes
|
package/dist/index.cjs
CHANGED
|
@@ -22,10 +22,20 @@ const useField = (store, field, onReject = null) => {
|
|
|
22
22
|
set: (value) => set(field, value, onReject ?? _onReject)
|
|
23
23
|
});
|
|
24
24
|
};
|
|
25
|
-
const useCustomField = (store, code) => {
|
|
25
|
+
const useCustomField = (store, code, options = { readonly: false }) => {
|
|
26
|
+
const kind = options.kind ? Array.isArray(options.kind) ? options.kind : [options.kind] : [];
|
|
27
|
+
const suitable = (f) => f.code === code && (kind.includes(f.kind) || kind.length === 0);
|
|
28
|
+
const _onReject = (rejection) => console.error(rejection);
|
|
29
|
+
const get = () => {
|
|
30
|
+
var _a;
|
|
31
|
+
return ((_a = store.schema) == null ? void 0 : _a.fields.find(suitable)) ? store.values[code] ?? null : null;
|
|
32
|
+
};
|
|
33
|
+
if (options.readonly) {
|
|
34
|
+
return vue.computed(get);
|
|
35
|
+
}
|
|
26
36
|
return vue.computed({
|
|
27
|
-
get
|
|
28
|
-
set: (value) => store.set(code, value)
|
|
37
|
+
get,
|
|
38
|
+
set: (value) => store.set(code, value, options.onReject ?? _onReject)
|
|
29
39
|
});
|
|
30
40
|
};
|
|
31
41
|
const useInternal = pinia.defineStore("@retailcrm/embed-ui/_internal", {});
|
package/dist/index.mjs
CHANGED
|
@@ -20,10 +20,20 @@ const useField = (store, field, onReject = null) => {
|
|
|
20
20
|
set: (value) => set(field, value, onReject ?? _onReject)
|
|
21
21
|
});
|
|
22
22
|
};
|
|
23
|
-
const useCustomField = (store, code) => {
|
|
23
|
+
const useCustomField = (store, code, options = { readonly: false }) => {
|
|
24
|
+
const kind = options.kind ? Array.isArray(options.kind) ? options.kind : [options.kind] : [];
|
|
25
|
+
const suitable = (f) => f.code === code && (kind.includes(f.kind) || kind.length === 0);
|
|
26
|
+
const _onReject = (rejection) => console.error(rejection);
|
|
27
|
+
const get = () => {
|
|
28
|
+
var _a;
|
|
29
|
+
return ((_a = store.schema) == null ? void 0 : _a.fields.find(suitable)) ? store.values[code] ?? null : null;
|
|
30
|
+
};
|
|
31
|
+
if (options.readonly) {
|
|
32
|
+
return computed(get);
|
|
33
|
+
}
|
|
24
34
|
return computed({
|
|
25
|
-
get
|
|
26
|
-
set: (value) => store.set(code, value)
|
|
35
|
+
get,
|
|
36
|
+
set: (value) => store.set(code, value, options.onReject ?? _onReject)
|
|
27
37
|
});
|
|
28
38
|
};
|
|
29
39
|
const useInternal = defineStore("@retailcrm/embed-ui/_internal", {});
|
package/index.d.ts
CHANGED
|
@@ -9,12 +9,14 @@ import type {
|
|
|
9
9
|
RemoteCallable,
|
|
10
10
|
} from '@remote-ui/rpc'
|
|
11
11
|
|
|
12
|
-
import
|
|
12
|
+
import {
|
|
13
13
|
ContextAccessor,
|
|
14
14
|
ContextSchema,
|
|
15
|
+
CustomFieldKind,
|
|
15
16
|
IsReadonly,
|
|
16
17
|
RejectionHandler,
|
|
17
18
|
TypeOf,
|
|
19
|
+
TypeOfCustom,
|
|
18
20
|
} from '@retailcrm/embed-ui-v1-types/context'
|
|
19
21
|
|
|
20
22
|
import type {
|
|
@@ -49,10 +51,21 @@ export declare const useField: <S extends ContextSchema, F extends keyof S>(
|
|
|
49
51
|
? ComputedRef<TypeOf<S[F]>>
|
|
50
52
|
: WritableComputedRef<TypeOf<S[F]>>
|
|
51
53
|
|
|
52
|
-
export declare const useCustomField: <
|
|
54
|
+
export declare const useCustomField: <
|
|
55
|
+
T extends string,
|
|
56
|
+
K extends CustomFieldKind = CustomFieldKind,
|
|
57
|
+
R extends boolean = false
|
|
58
|
+
>(
|
|
53
59
|
store: CustomContextStore<T>,
|
|
54
|
-
code: string
|
|
55
|
-
|
|
60
|
+
code: string,
|
|
61
|
+
options?: {
|
|
62
|
+
kind?: K | K[],
|
|
63
|
+
readonly?: R,
|
|
64
|
+
onReject?: RejectionHandler,
|
|
65
|
+
}
|
|
66
|
+
) => R extends false
|
|
67
|
+
? WritableComputedRef<TypeOfCustom<K> | null, TypeOfCustom<K>>
|
|
68
|
+
: ComputedRef<TypeOfCustom<K> | null>
|
|
56
69
|
|
|
57
70
|
export declare const useHost = () => RemoteCallable<Callable>
|
|
58
71
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@retailcrm/embed-ui",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.6",
|
|
5
5
|
"description": "API and components for creating RetailCRM UI extensions",
|
|
6
6
|
"repository": "git@github.com:retailcrm/embed-ui.git",
|
|
7
7
|
"author": "RetailDriverLLC <integration@retailcrm.ru>",
|
|
@@ -30,20 +30,20 @@
|
|
|
30
30
|
"eslint": "eslint .",
|
|
31
31
|
"test": "vitest --run"
|
|
32
32
|
},
|
|
33
|
-
"dependencies": {
|
|
34
|
-
"@omnicajs/vue-remote": "^0.2.3",
|
|
35
|
-
"@remote-ui/rpc": "^1.4.5",
|
|
36
|
-
"@retailcrm/embed-ui-v1-contexts": "^0.5.4",
|
|
37
|
-
"@retailcrm/embed-ui-v1-types": "^0.5.4"
|
|
38
|
-
},
|
|
39
33
|
"peerDependencies": {
|
|
40
34
|
"pinia": "^2.2",
|
|
41
35
|
"vue": "^3.5"
|
|
42
36
|
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@omnicajs/vue-remote": "^0.2.5",
|
|
39
|
+
"@remote-ui/rpc": "^1.4.5",
|
|
40
|
+
"@retailcrm/embed-ui-v1-contexts": "^0.5.6",
|
|
41
|
+
"@retailcrm/embed-ui-v1-types": "^0.5.6"
|
|
42
|
+
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@eslint/eslintrc": "^3.0.2",
|
|
45
45
|
"@eslint/js": "^9.13.0",
|
|
46
|
-
"@retailcrm/embed-ui-v1-testing": "^0.5.
|
|
46
|
+
"@retailcrm/embed-ui-v1-testing": "^0.5.6",
|
|
47
47
|
"@types/git-semver-tags": "^7.0.0",
|
|
48
48
|
"@types/node": "^22.7.9",
|
|
49
49
|
"@types/semver": "^7.5.8",
|