@divkitframework/jsonbuilder 29.8.0 → 29.10.0
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/README.md +2 -2
- package/dist/jsonbuilder.d.ts +1 -1
- package/package.json +1 -1
- package/README.ru.md +0 -114
package/README.md
CHANGED
|
@@ -105,8 +105,8 @@ While developing cards you need to make sure that:
|
|
|
105
105
|
- Urls of images, actions, etc are valid;
|
|
106
106
|
- Arrays are non-empty.
|
|
107
107
|
|
|
108
|
+
---
|
|
109
|
+
|
|
108
110
|
[Documentation](https://divkit.tech/doc). [Medium tutorial](https://medium.com/p/cad519252f0f). [Habr tutorial](https://habr.com/ru/company/yandex/blog/683886/).
|
|
109
111
|
|
|
110
112
|
Telegram: [News](https://t.me/divkit_news) | [English-speaking chat](https://t.me/divkit_community_en) | [Чат на русском](https://t.me/divkit_community_ru).
|
|
111
|
-
|
|
112
|
-
[Twitter](https://twitter.com/DivKitFramework)
|
package/dist/jsonbuilder.d.ts
CHANGED
|
@@ -4211,7 +4211,7 @@ interface DivInputProps {
|
|
|
4211
4211
|
*/
|
|
4212
4212
|
width?: Type<DivSize>;
|
|
4213
4213
|
}
|
|
4214
|
-
declare type DivInputKeyboardType = 'single_line_text' | 'multi_line_text' | 'phone' | 'number' | 'email' | 'uri';
|
|
4214
|
+
declare type DivInputKeyboardType = 'single_line_text' | 'multi_line_text' | 'phone' | 'number' | 'email' | 'uri' | 'password';
|
|
4215
4215
|
/**
|
|
4216
4216
|
* Text input line used in the native interface.
|
|
4217
4217
|
*/
|
package/package.json
CHANGED
package/README.ru.md
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
# DivKit TypeScript JSON Buidler
|
|
2
|
-
|
|
3
|
-
[Документация DivKit](https://divkit.tech/doc/)
|
|
4
|
-
|
|
5
|
-
## Что это и зачем
|
|
6
|
-
Библиотека `@divkitframework/jsonbuilder` предоставляет типобезопасные инструменты для генерации JSON-описаний высокоуровневой верстки для клиентов DivKit.
|
|
7
|
-
|
|
8
|
-
## Пример
|
|
9
|
-
|
|
10
|
-
```typescript
|
|
11
|
-
import { divCard, DivContainer, DivText, reference, rewritRefs, template, templateHelper } from '@divkitframework/jsonbuilder';
|
|
12
|
-
|
|
13
|
-
const templates = {
|
|
14
|
-
sampleBlock: new DivContainer({
|
|
15
|
-
items: [
|
|
16
|
-
template('header', {
|
|
17
|
-
text: reference('title')
|
|
18
|
-
}),
|
|
19
|
-
template('header', {
|
|
20
|
-
text: reference('subtitle')
|
|
21
|
-
}),
|
|
22
|
-
],
|
|
23
|
-
}),
|
|
24
|
-
header: new DivText({
|
|
25
|
-
font_size: 24,
|
|
26
|
-
}),
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const tHelper = templateHelper(templates);
|
|
30
|
-
|
|
31
|
-
console.log(JSON.stringify(
|
|
32
|
-
divCard(rewriteRefs(templates), {
|
|
33
|
-
log_id: 'sample_card',
|
|
34
|
-
states: [
|
|
35
|
-
{
|
|
36
|
-
state_id: 0,
|
|
37
|
-
div: tHelper.sampleBlock({
|
|
38
|
-
title: "Some Title",
|
|
39
|
-
subtitle: "Some Subtitle",
|
|
40
|
-
}),
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
}
|
|
44
|
-
)));
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
В результате `JSON.stringify(divCard(...))` вернет следующий JSON:
|
|
48
|
-
```json
|
|
49
|
-
{
|
|
50
|
-
"templates": {
|
|
51
|
-
"sampleBlock": {
|
|
52
|
-
"type": "container",
|
|
53
|
-
"items": [
|
|
54
|
-
{
|
|
55
|
-
"type": "header",
|
|
56
|
-
"$text": "title"
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
"type": "header",
|
|
60
|
-
"$text": "subtitle"
|
|
61
|
-
},
|
|
62
|
-
]
|
|
63
|
-
},
|
|
64
|
-
"header": {
|
|
65
|
-
"type": "text",
|
|
66
|
-
"font_size": 24
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
"card": {
|
|
70
|
-
"log_id": "sample_card",
|
|
71
|
-
"states": [
|
|
72
|
-
{
|
|
73
|
-
"state_id": 0,
|
|
74
|
-
"div": {
|
|
75
|
-
"type": "sampleBlock",
|
|
76
|
-
"title": "Some Title",
|
|
77
|
-
"subtitle": "Some Subtitle",
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
]
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
## Типизированные шаблоны (compile-time валидация)
|
|
86
|
-
Для проверки компилятором набора шаблонных свойств можно использовать вспомогательную функцию `templateHelper`. Типизация работает корректно только при включенном флаге [strictNullChecks](https://www.typescriptlang.org/docs/handbook/compiler-options.html) в tsconfig.json!
|
|
87
|
-
|
|
88
|
-
```typescript
|
|
89
|
-
const block = template('header', {
|
|
90
|
-
title: 'Some Title'
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
// вариант с templateHelper проверяет список параметров и их типы во время компиляции
|
|
94
|
-
const safeBlock = tHelper.header({
|
|
95
|
-
title: 'Some Title'
|
|
96
|
-
});
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
## Гарантии валидности
|
|
100
|
-
|
|
101
|
-
При разработке карточки нужно самостоятельно следить за тем, чтобы
|
|
102
|
-
|
|
103
|
-
- Текстовые строки не были пустыми;
|
|
104
|
-
- Урлы картинок, действий и др. были валидными;
|
|
105
|
-
- Массивы не был пустыми.
|
|
106
|
-
|
|
107
|
-
В сомнительных случаях сверяйтесь с [документацией DivKit](https://divkit.tech/doc/)
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
[Documentation](https://divkit.tech/doc). [Medium tutorial](https://medium.com/p/cad519252f0f). [Habr tutorial](https://habr.com/ru/company/yandex/blog/683886/).
|
|
111
|
-
|
|
112
|
-
Telegram: [News](https://t.me/divkit_news) | [English-speaking chat](https://t.me/divkit_community_en) | [Чат на русском](https://t.me/divkit_community_ru).
|
|
113
|
-
|
|
114
|
-
[Twitter](https://twitter.com/DivKitFramework)
|