@retailcrm/embed-ui 0.4.1-alpha.2 → 0.4.1-alpha.21

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 CHANGED
@@ -1,6 +1,67 @@
1
1
  # Changelog
2
2
 
3
3
 
4
+ ## [0.4.1-alpha.21](https://github.com/retailcrm/embed-ui/compare/v0.4.1-alpha.20...v0.4.1-alpha.21) (2024-11-27)
5
+
6
+ ### Bug Fixes
7
+
8
+ * **v1-components:** Missing VueI18n export ([ed6ef3a](https://github.com/retailcrm/embed-ui/commit/ed6ef3ab50a5879c18b205d24db0c3c9c9da537a))
9
+ ## [0.4.1-alpha.20](https://github.com/retailcrm/embed-ui/compare/v0.4.1-alpha.19...v0.4.1-alpha.20) (2024-11-27)
10
+
11
+ ### Bug Fixes
12
+
13
+ * **v1-components:** Missing i18n plugin ([635b839](https://github.com/retailcrm/embed-ui/commit/635b839b0d533e00c04fba00e8293b4793bd0b42))
14
+ ## [0.4.1-alpha.19](https://github.com/retailcrm/embed-ui/compare/v0.4.1-alpha.18...v0.4.1-alpha.19) (2024-11-27)
15
+
16
+ ### Features
17
+
18
+ * Added field 'photo' to 'user/current' context ([4d6aece](https://github.com/retailcrm/embed-ui/commit/4d6aece931d23ad74d2afa54fcfc1cc821846ca2))
19
+ ## [0.4.1-alpha.18](https://github.com/retailcrm/embed-ui/compare/v0.4.1-alpha.17...v0.4.1-alpha.18) (2024-11-27)
20
+
21
+ ### Bug Fixes
22
+
23
+ * Missing components info for remote root ([ee0cf4a](https://github.com/retailcrm/embed-ui/commit/ee0cf4a33d5f9fe41462f66eb65b1715081cd8c8))
24
+ ## [0.4.1-alpha.17](https://github.com/retailcrm/embed-ui/compare/v0.4.1-alpha.16...v0.4.1-alpha.17) (2024-11-27)
25
+ ## [0.4.1-alpha.16](https://github.com/retailcrm/embed-ui/compare/v0.4.1-alpha.15...v0.4.1-alpha.16) (2024-11-27)
26
+
27
+ ### Bug Fixes
28
+
29
+ * **v1-components:** exports configuration ([4756f47](https://github.com/retailcrm/embed-ui/commit/4756f4723afb79238c4f543bc8ddabebd55411d1))
30
+ ## [0.4.1-alpha.15](https://github.com/retailcrm/embed-ui/compare/v0.4.1-alpha.14...v0.4.1-alpha.15) (2024-11-26)
31
+
32
+ ### Bug Fixes
33
+
34
+ * Types across schemas, removed artifacts from unsuccessful rebase ([d34514d](https://github.com/retailcrm/embed-ui/commit/d34514df0e6fcdd9b0e9a1a2e9c909e299138284))
35
+ ## [0.4.1-alpha.14](https://github.com/retailcrm/embed-ui/compare/v0.4.1-alpha.13...v0.4.1-alpha.14) (2024-11-26)
36
+ ## [0.4.1-alpha.13](https://github.com/retailcrm/embed-ui/compare/v0.4.1-alpha.12...v0.4.1-alpha.13) (2024-11-26)
37
+ ## [0.4.1-alpha.12](https://github.com/retailcrm/embed-ui/compare/v0.4.1-alpha.11...v0.4.1-alpha.12) (2024-11-26)
38
+ ## [0.4.1-alpha.11](https://github.com/retailcrm/embed-ui/compare/v0.4.1-alpha.10...v0.4.1-alpha.11) (2024-11-26)
39
+
40
+ ### Features
41
+
42
+ * **v1-components:** Added links validator for UiButton and UiLink ([94788df](https://github.com/retailcrm/embed-ui/commit/94788df863f1c25d80ec5ad537fe40b2b10d27ef))
43
+ * **v1-components:** Added UiToolbar, UiToolbarButton and UiToolbarLink ([2bba2b5](https://github.com/retailcrm/embed-ui/commit/2bba2b5ba422ced4649f4d634672b3fdf52c8b01))
44
+ ## [0.4.1-alpha.10](https://github.com/retailcrm/embed-ui/compare/v0.4.1-alpha.9...v0.4.1-alpha.10) (2024-11-26)
45
+
46
+ ### Bug Fixes
47
+
48
+ * Missing import of ReadonlyField ([5a068ce](https://github.com/retailcrm/embed-ui/commit/5a068cead28bb40ee5c2b66116c4ae615b9661ad))
49
+ ## [0.4.1-alpha.9](https://github.com/retailcrm/embed-ui/compare/v0.4.1-alpha.8...v0.4.1-alpha.9) (2024-11-26)
50
+
51
+ ### Bug Fixes
52
+
53
+ * Types declaration in index.d.ts ([2751630](https://github.com/retailcrm/embed-ui/commit/2751630db649592bc4e8f2b8e16aaf86a7971e0f))
54
+ * **v1-components:** Missing slot of remote UiModalWindow definition ([2bf97a3](https://github.com/retailcrm/embed-ui/commit/2bf97a33e2eee41090195038733bc89baf72bc3d))
55
+ ## [0.4.1-alpha.8](https://github.com/retailcrm/embed-ui/compare/v0.4.1-alpha.7...v0.4.1-alpha.8) (2024-11-25)
56
+
57
+ ### Bug Fixes
58
+
59
+ * Missing contexts in meta.json ([52d3529](https://github.com/retailcrm/embed-ui/commit/52d3529519c43580ef846a98881cec1dbd3265e8))
60
+ ## [0.4.1-alpha.7](https://github.com/retailcrm/embed-ui/compare/v0.4.1-alpha.6...v0.4.1-alpha.7) (2024-11-25)
61
+ ## [0.4.1-alpha.6](https://github.com/retailcrm/embed-ui/compare/v0.4.1-alpha.5...v0.4.1-alpha.6) (2024-11-25)
62
+ ## [0.4.1-alpha.5](https://github.com/retailcrm/embed-ui/compare/v0.4.1-alpha.4...v0.4.1-alpha.5) (2024-11-25)
63
+ ## [0.4.1-alpha.4](https://github.com/retailcrm/embed-ui/compare/v0.4.1-alpha.3...v0.4.1-alpha.4) (2024-11-25)
64
+ ## [0.4.1-alpha.3](https://github.com/retailcrm/embed-ui/compare/v0.4.1-alpha.2...v0.4.1-alpha.3) (2024-11-25)
4
65
  ## [0.4.1-alpha.2](https://github.com/retailcrm/embed-ui/compare/v0.4.1-alpha.1...v0.4.1-alpha.2) (2024-11-25)
5
66
 
6
67
  ### Bug Fixes
package/README.md CHANGED
@@ -7,47 +7,3 @@ API и компоненты для создания расширений инт
7
7
  Цели встраивания определяют места, где будет размещена разметка виджета, генерируемая расширением.
8
8
 
9
9
  https://docs.retailcrm.ru/Developers/modules/PublishingModuleMarketplace/JsModulesTargets
10
-
11
- ## Контексты
12
-
13
- Предоставляют данные из системы, реактивны.
14
-
15
- ### `customer/card`
16
-
17
- Данные карточки клиента
18
-
19
- ```typescript
20
- import { useCustomerCardContext } from '@retailcrm/embed-ui'
21
-
22
- const customer = useCustomerCardContext()
23
- ```
24
-
25
- ### `customer/card:phone`
26
-
27
- Данные телефона клиента
28
-
29
- ```typescript
30
- import { useCustomerCardPhoneContext } from '@retailcrm/embed-ui'
31
-
32
- const phone = useCustomerCardPhoneContext()
33
- ```
34
-
35
- ### `order/card`
36
-
37
- Данные карточки заказа
38
-
39
- ```typescript
40
- import { useOrderCardContext } from '@retailcrm/embed-ui'
41
-
42
- const order = useOrderCardContext()
43
- ```
44
-
45
- ### `settings`
46
-
47
- Настройки CRM
48
-
49
- ```typescript
50
- import { useSettingsContext } from '@retailcrm/embed-ui'
51
-
52
- const settings = useSettingsContext()
53
- ```
package/dist/index.cjs CHANGED
@@ -56,6 +56,9 @@ const defineContext = (id, schema2) => {
56
56
  const withMeta = (predicate, type) => {
57
57
  return Object.assign(predicate, { type });
58
58
  };
59
+ const isExactly = (expected) => {
60
+ return withMeta((value) => value === expected, JSON.stringify(expected));
61
+ };
59
62
  const isNull = withMeta((value) => value === null, "null");
60
63
  const isNumber = withMeta((value) => typeof value === "number", "number");
61
64
  const isString = withMeta((value) => typeof value === "string", "string");
@@ -72,31 +75,41 @@ const oneOf = (...predicates) => withMeta(
72
75
  predicates.map((p) => p.type).join(" | ")
73
76
  );
74
77
  const schema$4 = {
75
- "lastName": {
76
- accepts: oneOf(isString, isNull),
78
+ "id": {
79
+ accepts: oneOf(isNumber, isNull),
77
80
  defaults: () => null,
78
- readonly: false
81
+ readonly: true
82
+ },
83
+ "email": {
84
+ accepts: isString,
85
+ defaults: () => "",
86
+ readonly: true
79
87
  },
80
88
  "firstName": {
81
89
  accepts: oneOf(isString, isNull),
82
90
  defaults: () => null,
83
- readonly: false
91
+ readonly: true
84
92
  },
85
- "patronymic": {
93
+ "lastName": {
86
94
  accepts: oneOf(isString, isNull),
87
95
  defaults: () => null,
88
- readonly: false
96
+ readonly: true
89
97
  },
90
- "email": {
91
- accepts: isString,
92
- defaults: () => "",
98
+ "patronymic": {
99
+ accepts: oneOf(isString, isNull),
100
+ defaults: () => null,
93
101
  readonly: true
94
102
  },
95
- "id": {
96
- accepts: oneOf(isNumber, isNull),
103
+ "photo": {
104
+ accepts: oneOf(isString, isNull),
97
105
  defaults: () => null,
98
106
  readonly: true
99
107
  },
108
+ "groups": {
109
+ accepts: arrayOf(isString),
110
+ defaults: () => [],
111
+ readonly: true
112
+ },
100
113
  "permissions": {
101
114
  accepts: arrayOf(isString),
102
115
  defaults: () => [],
@@ -157,9 +170,12 @@ const schema$1 = {
157
170
  readonly: true
158
171
  },
159
172
  "customer.type": {
160
- accepts: oneOf(isNumber, isNull),
161
- defaults: () => null,
162
- readonly: false
173
+ accepts: oneOf(
174
+ isExactly("customer"),
175
+ isExactly("customer_corporate")
176
+ ),
177
+ defaults: () => "customer",
178
+ readonly: true
163
179
  },
164
180
  "customer.lastName": {
165
181
  accepts: oneOf(isString, isNull),
@@ -259,13 +275,9 @@ const schema$1 = {
259
275
  };
260
276
  const useContext$1 = defineContext("order/card", schema$1);
261
277
  const locales = ["en-GB", "es-ES", "ru-RU"];
262
- const isLocale = withMeta(
263
- (value) => locales.includes(value),
264
- locales.map((l) => `'${l}'`).join(" | ")
265
- );
266
278
  const schema = {
267
279
  "system.locale": {
268
- accepts: isLocale,
280
+ accepts: oneOf(...locales.map(isExactly)),
269
281
  defaults: () => "en-GB",
270
282
  readonly: true
271
283
  }
@@ -275,11 +287,10 @@ const useField = (store, field) => {
275
287
  if (store.schema[field].readonly) {
276
288
  return vue.computed(() => store[field]);
277
289
  }
290
+ const set = store.set;
278
291
  return vue.computed({
279
292
  get: () => store[field],
280
- set: (value) => {
281
- store.set(field, value);
282
- }
293
+ set: (value) => set(field, value)
283
294
  });
284
295
  };
285
296
  const useInternal = pinia.defineStore("@retailcrm/embed-ui/_internal", {});
@@ -298,13 +309,13 @@ const createRoot = async (channel) => {
298
309
  "UiError",
299
310
  "UiLink",
300
311
  "UiLoader",
301
- "UiMenuItem",
302
- "UiMenuItemGroup",
303
312
  "UiModalSidebar",
304
313
  "UiModalWindow",
305
314
  "UiModalWindowSurface",
306
315
  "UiScrollBox",
307
316
  "UiTag",
317
+ "UiToolbarButton",
318
+ "UiToolbarLink",
308
319
  "UiTransition",
309
320
  "CrmYandexMap"
310
321
  ]
package/dist/index.mjs CHANGED
@@ -54,6 +54,9 @@ const defineContext = (id, schema2) => {
54
54
  const withMeta = (predicate, type) => {
55
55
  return Object.assign(predicate, { type });
56
56
  };
57
+ const isExactly = (expected) => {
58
+ return withMeta((value) => value === expected, JSON.stringify(expected));
59
+ };
57
60
  const isNull = withMeta((value) => value === null, "null");
58
61
  const isNumber = withMeta((value) => typeof value === "number", "number");
59
62
  const isString = withMeta((value) => typeof value === "string", "string");
@@ -70,31 +73,41 @@ const oneOf = (...predicates) => withMeta(
70
73
  predicates.map((p) => p.type).join(" | ")
71
74
  );
72
75
  const schema$4 = {
73
- "lastName": {
74
- accepts: oneOf(isString, isNull),
76
+ "id": {
77
+ accepts: oneOf(isNumber, isNull),
75
78
  defaults: () => null,
76
- readonly: false
79
+ readonly: true
80
+ },
81
+ "email": {
82
+ accepts: isString,
83
+ defaults: () => "",
84
+ readonly: true
77
85
  },
78
86
  "firstName": {
79
87
  accepts: oneOf(isString, isNull),
80
88
  defaults: () => null,
81
- readonly: false
89
+ readonly: true
82
90
  },
83
- "patronymic": {
91
+ "lastName": {
84
92
  accepts: oneOf(isString, isNull),
85
93
  defaults: () => null,
86
- readonly: false
94
+ readonly: true
87
95
  },
88
- "email": {
89
- accepts: isString,
90
- defaults: () => "",
96
+ "patronymic": {
97
+ accepts: oneOf(isString, isNull),
98
+ defaults: () => null,
91
99
  readonly: true
92
100
  },
93
- "id": {
94
- accepts: oneOf(isNumber, isNull),
101
+ "photo": {
102
+ accepts: oneOf(isString, isNull),
95
103
  defaults: () => null,
96
104
  readonly: true
97
105
  },
106
+ "groups": {
107
+ accepts: arrayOf(isString),
108
+ defaults: () => [],
109
+ readonly: true
110
+ },
98
111
  "permissions": {
99
112
  accepts: arrayOf(isString),
100
113
  defaults: () => [],
@@ -155,9 +168,12 @@ const schema$1 = {
155
168
  readonly: true
156
169
  },
157
170
  "customer.type": {
158
- accepts: oneOf(isNumber, isNull),
159
- defaults: () => null,
160
- readonly: false
171
+ accepts: oneOf(
172
+ isExactly("customer"),
173
+ isExactly("customer_corporate")
174
+ ),
175
+ defaults: () => "customer",
176
+ readonly: true
161
177
  },
162
178
  "customer.lastName": {
163
179
  accepts: oneOf(isString, isNull),
@@ -257,13 +273,9 @@ const schema$1 = {
257
273
  };
258
274
  const useContext$1 = defineContext("order/card", schema$1);
259
275
  const locales = ["en-GB", "es-ES", "ru-RU"];
260
- const isLocale = withMeta(
261
- (value) => locales.includes(value),
262
- locales.map((l) => `'${l}'`).join(" | ")
263
- );
264
276
  const schema = {
265
277
  "system.locale": {
266
- accepts: isLocale,
278
+ accepts: oneOf(...locales.map(isExactly)),
267
279
  defaults: () => "en-GB",
268
280
  readonly: true
269
281
  }
@@ -273,11 +285,10 @@ const useField = (store, field) => {
273
285
  if (store.schema[field].readonly) {
274
286
  return computed(() => store[field]);
275
287
  }
288
+ const set = store.set;
276
289
  return computed({
277
290
  get: () => store[field],
278
- set: (value) => {
279
- store.set(field, value);
280
- }
291
+ set: (value) => set(field, value)
281
292
  });
282
293
  };
283
294
  const useInternal = defineStore("@retailcrm/embed-ui/_internal", {});
@@ -296,13 +307,13 @@ const createRoot = async (channel) => {
296
307
  "UiError",
297
308
  "UiLink",
298
309
  "UiLoader",
299
- "UiMenuItem",
300
- "UiMenuItemGroup",
301
310
  "UiModalSidebar",
302
311
  "UiModalWindow",
303
312
  "UiModalWindowSurface",
304
313
  "UiScrollBox",
305
314
  "UiTag",
315
+ "UiToolbarButton",
316
+ "UiToolbarLink",
306
317
  "UiTransition",
307
318
  "CrmYandexMap"
308
319
  ]
package/dist/meta.json CHANGED
@@ -1,67 +1,5 @@
1
1
  {
2
2
  "contexts": {
3
- "user/current": [
4
- {
5
- "name": "lastName",
6
- "type": "string | null",
7
- "description": {
8
- "en-GB": "User last name",
9
- "es-ES": "Apellido del usuario",
10
- "ru-RU": "Фамилия пользователя"
11
- },
12
- "readonly": false
13
- },
14
- {
15
- "name": "firstName",
16
- "type": "string | null",
17
- "description": {
18
- "en-GB": "User name",
19
- "es-ES": "Nombre del usuario",
20
- "ru-RU": "Имя пользователя"
21
- },
22
- "readonly": false
23
- },
24
- {
25
- "name": "patronymic",
26
- "type": "string | null",
27
- "description": {
28
- "en-GB": "Patronymic of the user",
29
- "es-ES": "Patronímico del usuario",
30
- "ru-RU": "Отчество пользователя"
31
- },
32
- "readonly": false
33
- },
34
- {
35
- "name": "email",
36
- "type": "string",
37
- "description": {
38
- "en-GB": "User email",
39
- "es-ES": "Correo electrónico del usuario",
40
- "ru-RU": "Email пользователя"
41
- },
42
- "readonly": true
43
- },
44
- {
45
- "name": "id",
46
- "type": "number | null",
47
- "description": {
48
- "en-GB": "User ID",
49
- "es-ES": "ID del usuario",
50
- "ru-RU": "ID пользователя"
51
- },
52
- "readonly": true
53
- },
54
- {
55
- "name": "permissions",
56
- "type": "Array<string>",
57
- "description": {
58
- "en-GB": "Character codes of available user permissions",
59
- "es-ES": "Códigos de caracteres de los permisos disponibles para el usuario",
60
- "ru-RU": "Символьные коды доступных пользователю разрешений"
61
- },
62
- "readonly": true
63
- }
64
- ],
65
3
  "customer/card": [
66
4
  {
67
5
  "name": "id",
@@ -159,13 +97,13 @@
159
97
  },
160
98
  {
161
99
  "name": "customer.type",
162
- "type": "number | null",
100
+ "type": "\"customer\" | \"customer_corporate\"",
163
101
  "description": {
164
102
  "en-GB": "Client type",
165
103
  "es-ES": "Tipo de cliente",
166
104
  "ru-RU": "Тип клиента"
167
105
  },
168
- "readonly": false
106
+ "readonly": true
169
107
  },
170
108
  {
171
109
  "name": "customer.lastName",
@@ -358,10 +296,92 @@
358
296
  "readonly": false
359
297
  }
360
298
  ],
299
+ "user/current": [
300
+ {
301
+ "name": "id",
302
+ "type": "number | null",
303
+ "description": {
304
+ "en-GB": "User ID",
305
+ "es-ES": "ID del usuario",
306
+ "ru-RU": "ID пользователя"
307
+ },
308
+ "readonly": true
309
+ },
310
+ {
311
+ "name": "email",
312
+ "type": "string",
313
+ "description": {
314
+ "en-GB": "User email",
315
+ "es-ES": "Correo electrónico del usuario",
316
+ "ru-RU": "Email пользователя"
317
+ },
318
+ "readonly": true
319
+ },
320
+ {
321
+ "name": "firstName",
322
+ "type": "string | null",
323
+ "description": {
324
+ "en-GB": "User name",
325
+ "es-ES": "Nombre del usuario",
326
+ "ru-RU": "Имя пользователя"
327
+ },
328
+ "readonly": true
329
+ },
330
+ {
331
+ "name": "lastName",
332
+ "type": "string | null",
333
+ "description": {
334
+ "en-GB": "User last name",
335
+ "es-ES": "Apellido del usuario",
336
+ "ru-RU": "Фамилия пользователя"
337
+ },
338
+ "readonly": true
339
+ },
340
+ {
341
+ "name": "patronymic",
342
+ "type": "string | null",
343
+ "description": {
344
+ "en-GB": "Patronymic of the user",
345
+ "es-ES": "Patronímico del usuario",
346
+ "ru-RU": "Отчество пользователя"
347
+ },
348
+ "readonly": true
349
+ },
350
+ {
351
+ "name": "photo",
352
+ "type": "string | null",
353
+ "description": {
354
+ "en-GB": "User photo",
355
+ "es-ES": "Foto del usuario",
356
+ "ru-RU": "Фото пользователя"
357
+ },
358
+ "readonly": true
359
+ },
360
+ {
361
+ "name": "groups",
362
+ "type": "Array<string>",
363
+ "description": {
364
+ "en-GB": "Symbolic codes of the groups the user belongs to",
365
+ "es-ES": "Códigos simbólicos de los grupos a los que pertenece el usuario",
366
+ "ru-RU": "Символьные коды групп, в которых состоит пользователь"
367
+ },
368
+ "readonly": true
369
+ },
370
+ {
371
+ "name": "permissions",
372
+ "type": "Array<string>",
373
+ "description": {
374
+ "en-GB": "Character codes of available user permissions",
375
+ "es-ES": "Códigos de caracteres de los permisos disponibles para el usuario",
376
+ "ru-RU": "Символьные коды доступных пользователю разрешений"
377
+ },
378
+ "readonly": true
379
+ }
380
+ ],
361
381
  "settings": [
362
382
  {
363
383
  "name": "system.locale",
364
- "type": "'en-GB' | 'es-ES' | 'ru-RU'",
384
+ "type": "\"en-GB\" | \"es-ES\" | \"ru-RU\"",
365
385
  "description": {
366
386
  "en-GB": "Current system's locale",
367
387
  "es-ES": "Configuración regional actual del sistema",
@@ -387,6 +407,7 @@
387
407
  "contexts": [
388
408
  "customer/card",
389
409
  "customer/card:phone",
410
+ "user/current",
390
411
  "settings"
391
412
  ]
392
413
  },
@@ -404,6 +425,7 @@
404
425
  },
405
426
  "contexts": [
406
427
  "order/card",
428
+ "user/current",
407
429
  "settings"
408
430
  ]
409
431
  },
@@ -421,6 +443,7 @@
421
443
  },
422
444
  "contexts": [
423
445
  "order/card",
446
+ "user/current",
424
447
  "settings"
425
448
  ]
426
449
  },
@@ -438,6 +461,7 @@
438
461
  },
439
462
  "contexts": [
440
463
  "order/card",
464
+ "user/current",
441
465
  "settings"
442
466
  ]
443
467
  },
@@ -455,6 +479,7 @@
455
479
  },
456
480
  "contexts": [
457
481
  "order/card",
482
+ "user/current",
458
483
  "settings"
459
484
  ]
460
485
  },
@@ -472,6 +497,7 @@
472
497
  },
473
498
  "contexts": [
474
499
  "order/card",
500
+ "user/current",
475
501
  "settings"
476
502
  ]
477
503
  },
@@ -489,6 +515,7 @@
489
515
  },
490
516
  "contexts": [
491
517
  "order/card",
518
+ "user/current",
492
519
  "settings"
493
520
  ]
494
521
  },
@@ -500,12 +527,13 @@
500
527
  "ru-RU": "Виджет для списка позиций заказа"
501
528
  },
502
529
  "location": {
503
- "en-GB": "[Temporary unavailable]",
504
- "es-ES": "[Temporalmente no disponible]",
505
- "ru-RU": "[Временно недоступен]"
530
+ "en-GB": "Section start, right above the input fields",
531
+ "es-ES": "Inicio de la sección, justo encima de los campos de entrada",
532
+ "ru-RU": "Начало секции, над полями ввода"
506
533
  },
507
534
  "contexts": [
508
535
  "order/card",
536
+ "user/current",
509
537
  "settings"
510
538
  ]
511
539
  },
@@ -523,6 +551,7 @@
523
551
  },
524
552
  "contexts": [
525
553
  "order/card",
554
+ "user/current",
526
555
  "settings"
527
556
  ]
528
557
  },
@@ -540,6 +569,7 @@
540
569
  },
541
570
  "contexts": [
542
571
  "order/card",
572
+ "user/current",
543
573
  "settings"
544
574
  ]
545
575
  },
@@ -557,6 +587,7 @@
557
587
  },
558
588
  "contexts": [
559
589
  "order/card",
590
+ "user/current",
560
591
  "settings"
561
592
  ]
562
593
  },
@@ -574,6 +605,7 @@
574
605
  },
575
606
  "contexts": [
576
607
  "order/card",
608
+ "user/current",
577
609
  "settings"
578
610
  ]
579
611
  },
@@ -591,6 +623,7 @@
591
623
  },
592
624
  "contexts": [
593
625
  "order/card",
626
+ "user/current",
594
627
  "settings"
595
628
  ]
596
629
  },
@@ -608,6 +641,7 @@
608
641
  },
609
642
  "contexts": [
610
643
  "order/card",
644
+ "user/current",
611
645
  "settings"
612
646
  ]
613
647
  },
@@ -625,6 +659,7 @@
625
659
  },
626
660
  "contexts": [
627
661
  "order/card",
662
+ "user/current",
628
663
  "settings"
629
664
  ]
630
665
  }
package/index.d.ts CHANGED
@@ -6,10 +6,11 @@ import type { ContextSchema } from './types/context/schema'
6
6
  import type { Endpoint, RemoteCallable } from '@remote-ui/rpc'
7
7
  import type { IsReadonly } from './types/context/schema'
8
8
  import type { MessageEndpoint } from '@remote-ui/rpc'
9
- import type { Schema } from './types/context/customer/card'
10
- import type { Schema as Schema_2 } from './types/context/customer/card-phone'
11
- import type { Schema as Schema_3 } from './types/context/order/card'
12
- import type { Schema as Schema_4 } from './types/context/settings'
9
+ import type { Schema as CustomerCardSchema } from './types/context/customer/card'
10
+ import type { Schema as CustomerCardPhoneSchema } from './types/context/customer/card-phone'
11
+ import type { Schema as OrderCardSchema } from './types/context/order/card'
12
+ import type { Schema as CurrentUserSchema } from './types/context/user/current'
13
+ import type { Schema as SettingsSchema } from './types/context/settings'
13
14
  import type { SchemaList } from './types/context'
14
15
  import type { Store } from 'pinia'
15
16
  import type { StoreDefinition } from 'pinia'
@@ -17,54 +18,51 @@ import type { TypeOf } from './types/context/schema'
17
18
  import type { WidgetRunner } from './types/widget'
18
19
  import type { WritableComputedRef } from 'vue'
19
20
 
20
- declare type Computed<S extends ContextSchema, F extends keyof S> = IsReadonly<S[F]> extends true ? ComputedRef<TypeOf<S[F]>> : WritableComputedRef<TypeOf<S[F]>>;
21
+ declare type Computed<
22
+ S extends ContextSchema,
23
+ F extends keyof S
24
+ > = IsReadonly<S[F]> extends true ? ComputedRef<TypeOf<S[F]>> : WritableComputedRef<TypeOf<S[F]>>;
21
25
 
22
- export declare const createWidgetEndpoint: (widget: WidgetRunner, messenger: MessageEndpoint) => Endpoint<ContextAccessor<SchemaList>>
26
+ export declare const createWidgetEndpoint: (
27
+ widget: WidgetRunner,
28
+ messenger: MessageEndpoint
29
+ ) => Endpoint<ContextAccessor<SchemaList>>
23
30
 
24
- export declare const customerCardPhoneSchema: Schema_2
31
+ export declare const customerCardPhoneSchema: CustomerCardPhoneSchema
32
+ export declare const customerCardSchema: CustomerCardSchema
33
+ export declare const orderCardSchema: OrderCardSchema
34
+ export declare const currentUserSchema: CurrentUserSchema
35
+ export declare const settingsSchema: SettingsSchema
25
36
 
26
- export declare const customerCardSchema: Schema
27
-
28
- export declare const orderCardSchema: Schema_3
29
-
30
- export declare const settingsSchema: Schema_4
31
-
32
- export declare const useCustomerCardContext: StoreDefinition<'customer/card', Context<Schema>, {
33
- schema: () => Schema;
37
+ export type ContextStore<S extends ContextSchema> = Store<string, Context<S>, {
38
+ schema(): S;
34
39
  }, {
35
40
  initialize(): Promise<void>;
36
- set<F extends keyof Schema>(field: F, value: TypeOf<Schema[F]>): void;
41
+ set<F extends keyof S>(field: F, value: TypeOf<S[F]>): void;
37
42
  }>
38
43
 
39
- export declare const useCustomerCardPhoneContext: StoreDefinition<'customer/card:phone', Context<Schema_2>, {
40
- schema: () => Schema_2;
44
+ export type ContextStoreDefinition<
45
+ Id extends string,
46
+ S extends ContextSchema
47
+ > = StoreDefinition<Id, Context<S>, {
48
+ schema(): S;
41
49
  }, {
42
50
  initialize(): Promise<void>;
43
- set<F extends keyof Schema_2>(field: F, value: TypeOf<Schema_2[F]>): void;
51
+ set<F extends keyof S>(field: F, value: TypeOf<S[F]>): void;
44
52
  }>
45
53
 
46
- export declare const useField: <S extends ContextSchema, F extends keyof S>(store: Store<string, Context<S>, {
47
- schema(): S;
48
- }, {
49
- initialize(): Promise<void>;
50
- set<F_1 extends keyof S>(field: F_1, value: TypeOf<S[F_1]>): void;
51
- }>, field: F) => Computed<S, F>
54
+ export declare const useCustomerCardContext: ContextStoreDefinition<'customer/card', CustomerCardSchema>
55
+ export declare const useCustomerCardPhoneContext: ContextStoreDefinition<'customer/card:phone', CustomerCardPhoneSchema>
56
+ export declare const useOrderCardContext: ContextStoreDefinition<'order/card', OrderCardSchema>
57
+ export declare const useCurrentUserContext: ContextStoreDefinition<'user/current', CurrentUserSchema>
58
+ export declare const useSettingsContext: ContextStoreDefinition<'settings', SettingsSchema>
52
59
 
53
- export declare const useHost = () => RemoteCallable<Callable>
60
+ export declare const useField: <S extends ContextSchema, F extends keyof S>(
61
+ store: ContextStore<S>,
62
+ field: F
63
+ ) => Computed<S, F>
54
64
 
55
- export declare const useOrderCardContext: StoreDefinition<'order/card', Context<Schema_3>, {
56
- schema: () => Schema_3;
57
- }, {
58
- initialize(): Promise<void>;
59
- set<F extends keyof Schema_3>(field: F, value: TypeOf<Schema_3[F]>): void;
60
- }>
61
-
62
- export declare const useSettingsContext: StoreDefinition<'settings', Context<Schema_4>, {
63
- schema: () => Schema_4;
64
- }, {
65
- initialize(): Promise<void>;
66
- set<F extends keyof Schema_4>(field: F, value: TypeOf<Schema_4[F]>): void;
67
- }>
65
+ export declare const useHost = () => RemoteCallable<Callable>
68
66
 
69
67
  declare module 'pinia' {
70
68
  interface PiniaCustomProperties {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@retailcrm/embed-ui",
3
3
  "type": "module",
4
- "version": "0.4.1-alpha.2",
4
+ "version": "0.4.1-alpha.21",
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>",
@@ -1,13 +1,13 @@
1
- import type { Schema as CurrentUserSchema } from './user/current'
2
1
  import type { Schema as CustomerCardSchema } from './customer/card'
3
2
  import type { Schema as CustomerCardPhoneSchema } from './customer/card-phone'
4
3
  import type { Schema as OrderCardSchema } from './order/card'
4
+ import type { Schema as CurrentUserSchema } from './user/current'
5
5
  import type { Schema as SettingsSchema } from './settings'
6
6
 
7
7
  export type SchemaList = {
8
- 'user/current': CurrentUserSchema;
9
8
  'customer/card': CustomerCardSchema;
10
9
  'customer/card:phone': CustomerCardPhoneSchema;
11
10
  'order/card': OrderCardSchema;
11
+ 'user/current': CurrentUserSchema;
12
12
  'settings': SettingsSchema;
13
13
  }
@@ -1,10 +1,10 @@
1
- import type { Field } from '../schema'
1
+ import type { Field, ReadonlyField } from '../schema'
2
2
 
3
3
  export type Schema = {
4
4
  'id': ReadonlyField<number | null>;
5
5
  'externalId': ReadonlyField<string | null>;
6
6
  'number': ReadonlyField<string | null>;
7
- 'customer.type': ReadonlyField<number | null>;
7
+ 'customer.type': ReadonlyField<'customer' | 'customer_corporate'>;
8
8
  'customer.lastName': Field<string | null>;
9
9
  'customer.firstName': Field<string | null>;
10
10
  'customer.patronymic': Field<string | null>;
@@ -1,9 +1,6 @@
1
1
  import type { ReadonlyField } from './schema'
2
2
 
3
3
  export type Locale = 'en-GB' | 'es-ES' | 'ru-RU'
4
-
5
4
  export type Schema = {
6
- 'order.templates.number.api': ReadonlyField<string>;
7
- 'order.templates.number.crm': ReadonlyField<string>;
8
5
  'system.locale': ReadonlyField<Locale>;
9
6
  }
@@ -1,10 +1,12 @@
1
1
  import type { ReadonlyField } from '../schema'
2
2
 
3
3
  export type Schema = {
4
- 'lastName': ReadonlyField<string>;
5
- 'firstName': ReadonlyField<number | null>;
6
- 'patronymic': ReadonlyField<number | null>;
7
- 'email': ReadonlyField<string>;
8
4
  'id': ReadonlyField<number | null>;
5
+ 'email': ReadonlyField<string>;
6
+ 'firstName': ReadonlyField<string | null>;
7
+ 'lastName': ReadonlyField<string | null>;
8
+ 'patronymic': ReadonlyField<string | null>;
9
+ 'photo': ReadonlyField<string | null>;
10
+ 'groups': ReadonlyField<string[]>;
9
11
  'permissions': ReadonlyField<string[]>;
10
12
  }