slackblock 0.4.0 → 1.0.0-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/CHANGELOG.md +33 -26
- package/LICENSE +21 -21
- package/README.md +95 -85
- package/dist/block.cjs +341 -0
- package/dist/block.cjs.map +1 -0
- package/dist/block.d.mts +412 -0
- package/dist/block.d.ts +412 -0
- package/dist/block.mjs +268 -0
- package/dist/block.mjs.map +1 -0
- package/dist/index.cjs +1202 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.mjs +1170 -0
- package/dist/index.mjs.map +1 -0
- package/dist/types.d-DgQXbJte.d.mts +296 -0
- package/dist/types.d-DgQXbJte.d.ts +296 -0
- package/package.json +85 -135
- package/blocks.js +0 -12
- package/index.js +0 -7
- package/lib/components/block/button.js +0 -27
- package/lib/components/block/confirmation.js +0 -27
- package/lib/components/block/image.js +0 -27
- package/lib/components/block/text.js +0 -27
- package/lib/components/index.js +0 -42
- package/lib/components/input/date-picker.js +0 -27
- package/lib/components/input/option-group.js +0 -27
- package/lib/components/input/option.js +0 -27
- package/lib/components/input/overflow.js +0 -27
- package/lib/components/input/radio-group.js +0 -27
- package/lib/components/input/select.js +0 -34
- package/lib/components/input/text.js +0 -27
- package/lib/components/layout/actions.js +0 -27
- package/lib/components/layout/container.js +0 -27
- package/lib/components/layout/context.js +0 -27
- package/lib/components/layout/divider.js +0 -27
- package/lib/components/layout/file.js +0 -27
- package/lib/components/layout/image.js +0 -27
- package/lib/components/layout/input.js +0 -27
- package/lib/components/layout/section.js +0 -27
- package/lib/components/message.js +0 -27
- package/lib/index.js +0 -7
- package/lib/parser/index.js +0 -32
- package/lib/renderer/index.js +0 -71
- package/lib/transformers/block/button.js +0 -29
- package/lib/transformers/block/confirmation.js +0 -18
- package/lib/transformers/block/image.js +0 -10
- package/lib/transformers/block/text.js +0 -16
- package/lib/transformers/index.js +0 -54
- package/lib/transformers/input/date-picker.js +0 -30
- package/lib/transformers/input/option-group.js +0 -19
- package/lib/transformers/input/option.js +0 -19
- package/lib/transformers/input/overflow.js +0 -19
- package/lib/transformers/input/radio-group.js +0 -22
- package/lib/transformers/input/select.js +0 -84
- package/lib/transformers/input/text.js +0 -31
- package/lib/transformers/layout/actions.js +0 -18
- package/lib/transformers/layout/container.js +0 -11
- package/lib/transformers/layout/context.js +0 -18
- package/lib/transformers/layout/divider.js +0 -10
- package/lib/transformers/layout/file.js +0 -14
- package/lib/transformers/layout/image.js +0 -23
- package/lib/transformers/layout/input.js +0 -26
- package/lib/transformers/layout/section.js +0 -31
- package/lib/utils/get-type.js +0 -16
- package/lib/utils/type-helpers.js +0 -2
- package/src/components/block/button.tsx +0 -20
- package/src/components/block/confirmation.tsx +0 -19
- package/src/components/block/image.tsx +0 -8
- package/src/components/block/text.tsx +0 -10
- package/src/components/index.ts +0 -23
- package/src/components/input/date-picker.tsx +0 -11
- package/src/components/input/option-group.tsx +0 -9
- package/src/components/input/option.tsx +0 -9
- package/src/components/input/overflow.tsx +0 -12
- package/src/components/input/radio-group.tsx +0 -13
- package/src/components/input/select.tsx +0 -36
- package/src/components/input/text.tsx +0 -12
- package/src/components/layout/actions.tsx +0 -9
- package/src/components/layout/container.tsx +0 -9
- package/src/components/layout/context.tsx +0 -12
- package/src/components/layout/divider.tsx +0 -7
- package/src/components/layout/file.tsx +0 -8
- package/src/components/layout/image.tsx +0 -10
- package/src/components/layout/input.tsx +0 -12
- package/src/components/layout/section.tsx +0 -15
- package/src/components/message.tsx +0 -20
- package/src/constants/types.d.ts +0 -93
- package/src/index.ts +0 -3
- package/src/parser/index.ts +0 -32
- package/src/renderer/index.ts +0 -75
- package/src/transformers/block/button.tsx +0 -47
- package/src/transformers/block/confirmation.tsx +0 -26
- package/src/transformers/block/image.ts +0 -18
- package/src/transformers/block/text.ts +0 -34
- package/src/transformers/index.ts +0 -65
- package/src/transformers/input/date-picker.tsx +0 -43
- package/src/transformers/input/option-group.tsx +0 -26
- package/src/transformers/input/option.tsx +0 -27
- package/src/transformers/input/overflow.ts +0 -33
- package/src/transformers/input/radio-group.ts +0 -38
- package/src/transformers/input/select.tsx +0 -136
- package/src/transformers/input/text.tsx +0 -47
- package/src/transformers/layout/actions.ts +0 -29
- package/src/transformers/layout/container.ts +0 -16
- package/src/transformers/layout/context.ts +0 -35
- package/src/transformers/layout/divider.ts +0 -20
- package/src/transformers/layout/file.ts +0 -24
- package/src/transformers/layout/image.tsx +0 -34
- package/src/transformers/layout/input.tsx +0 -39
- package/src/transformers/layout/section.ts +0 -53
- package/src/tsconfig.json +0 -11
- package/src/utils/get-type.ts +0 -20
- package/src/utils/type-helpers.ts +0 -1
- package/test/index.test.tsx +0 -11
- package/test/parser/parser.test.tsx +0 -67
- package/test/renderer/renderer.test.tsx +0 -138
- package/test/transformers/block/button.test.tsx +0 -63
- package/test/transformers/block/confirmation.test.tsx +0 -37
- package/test/transformers/block/image.test.tsx +0 -20
- package/test/transformers/block/text.test.tsx +0 -32
- package/test/transformers/input/date-picker.test.tsx +0 -66
- package/test/transformers/input/option-group.test.tsx +0 -26
- package/test/transformers/input/option.test.tsx +0 -36
- package/test/transformers/input/overflow.test.tsx +0 -57
- package/test/transformers/input/radio-group.test.tsx +0 -81
- package/test/transformers/input/select.test.tsx +0 -249
- package/test/transformers/input/text.test.tsx +0 -42
- package/test/transformers/layout/actions.test.tsx +0 -33
- package/test/transformers/layout/container.test.tsx +0 -34
- package/test/transformers/layout/context.test.tsx +0 -43
- package/test/transformers/layout/divider.test.tsx +0 -20
- package/test/transformers/layout/file.test.tsx +0 -26
- package/test/transformers/layout/image.test.tsx +0 -43
- package/test/transformers/layout/input.test.tsx +0 -59
- package/test/transformers/layout/section.test.tsx +0 -89
- package/test/tsconfig.json +0 -9
- package/test/utils/get-type.test.tsx +0 -21
- package/tsconfig.json +0 -14
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import test from 'ava';
|
|
3
|
-
|
|
4
|
-
import transformer from '../../../src/transformers/input/select';
|
|
5
|
-
import Select from '../../../src/components/input/select';
|
|
6
|
-
|
|
7
|
-
import optionTransformer from '../../../src/transformers/input/option';
|
|
8
|
-
import Option from '../../../src/components/input/option';
|
|
9
|
-
|
|
10
|
-
import optionGroupTransformer from '../../../src/transformers/input/option-group';
|
|
11
|
-
import OptionGroup from '../../../src/components/input/option-group';
|
|
12
|
-
|
|
13
|
-
import confirmationTransformer from '../../../src/transformers/block/confirmation';
|
|
14
|
-
import Confirmation from '../../../src/components/block/confirmation';
|
|
15
|
-
import Text from '../../../src/components/block/text';
|
|
16
|
-
|
|
17
|
-
test('transforms a select with options', t => {
|
|
18
|
-
const option = <Option value="v">O</Option>;
|
|
19
|
-
const options = [optionTransformer(option)];
|
|
20
|
-
|
|
21
|
-
const res = transformer(
|
|
22
|
-
<Select placeholder="placeholder" actionId="aid">
|
|
23
|
-
{option}
|
|
24
|
-
</Select>
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
t.deepEqual(res, {
|
|
28
|
-
type: 'static_select',
|
|
29
|
-
placeholder: {
|
|
30
|
-
type: 'plain_text',
|
|
31
|
-
text: 'placeholder'
|
|
32
|
-
},
|
|
33
|
-
action_id: 'aid',
|
|
34
|
-
options
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
test('transforms multi-select with options', t => {
|
|
39
|
-
const option = <Option value="v">O</Option>;
|
|
40
|
-
const options = [optionTransformer(option)];
|
|
41
|
-
|
|
42
|
-
const res = transformer(
|
|
43
|
-
<Select placeholder="placeholder" actionId="aid" multi>
|
|
44
|
-
{option}
|
|
45
|
-
</Select>
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
t.deepEqual(res, {
|
|
49
|
-
type: 'multi_static_select',
|
|
50
|
-
placeholder: {
|
|
51
|
-
type: 'plain_text',
|
|
52
|
-
text: 'placeholder'
|
|
53
|
-
},
|
|
54
|
-
action_id: 'aid',
|
|
55
|
-
options
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
test('transforms a select with OptionGroups', t => {
|
|
60
|
-
const option = <Option value="v">O</Option>;
|
|
61
|
-
const option2 = <Option value="O">V</Option>;
|
|
62
|
-
|
|
63
|
-
const optionGroup = <OptionGroup label="ogLabel">{option}{option2}</OptionGroup>;
|
|
64
|
-
const optionGroups = [optionGroupTransformer(optionGroup)];
|
|
65
|
-
|
|
66
|
-
const res = transformer(
|
|
67
|
-
<Select placeholder="placeholder" actionId="aid">
|
|
68
|
-
{optionGroup}
|
|
69
|
-
</Select>
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
t.deepEqual(res, {
|
|
73
|
-
type: 'static_select',
|
|
74
|
-
placeholder: {
|
|
75
|
-
type: 'plain_text',
|
|
76
|
-
text: 'placeholder'
|
|
77
|
-
},
|
|
78
|
-
action_id: 'aid',
|
|
79
|
-
option_groups: optionGroups
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
test('disallows options AND optionGroups in the same select block', t => {
|
|
84
|
-
const fn = () => transformer(
|
|
85
|
-
<Select placeholder="p" actionId="a">
|
|
86
|
-
<Option value="v">O</Option>
|
|
87
|
-
<OptionGroup label="l">
|
|
88
|
-
<Option value="o">V</Option>
|
|
89
|
-
</OptionGroup>
|
|
90
|
-
</Select>
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
t.throws(fn);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
test('it transforms additional options on the Select block', t => {
|
|
97
|
-
const option = <Option value="v">O</Option>;
|
|
98
|
-
const option2 = <Option value="c">C</Option>;
|
|
99
|
-
const options = [option, option2].map(optionTransformer);
|
|
100
|
-
|
|
101
|
-
const initialOptions = [option];
|
|
102
|
-
const transformedInitialOptions = initialOptions.map(optionTransformer);
|
|
103
|
-
|
|
104
|
-
const confirm = (
|
|
105
|
-
<Confirmation
|
|
106
|
-
title="cTitle"
|
|
107
|
-
confirm="confirm"
|
|
108
|
-
deny="deny"
|
|
109
|
-
>
|
|
110
|
-
<Text>cText</Text>
|
|
111
|
-
</Confirmation>
|
|
112
|
-
);
|
|
113
|
-
const transformedConfirm = confirmationTransformer(confirm);
|
|
114
|
-
|
|
115
|
-
const res = transformer(
|
|
116
|
-
<Select
|
|
117
|
-
placeholder="placeholder"
|
|
118
|
-
actionId="aid"
|
|
119
|
-
initialOptions={initialOptions}
|
|
120
|
-
confirm={confirm}
|
|
121
|
-
maxSelectedItems={2}
|
|
122
|
-
>
|
|
123
|
-
{option}
|
|
124
|
-
{option2}
|
|
125
|
-
</Select>
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
t.deepEqual(res, {
|
|
129
|
-
type: 'static_select',
|
|
130
|
-
placeholder: {
|
|
131
|
-
type: 'plain_text',
|
|
132
|
-
text: 'placeholder'
|
|
133
|
-
},
|
|
134
|
-
action_id: 'aid',
|
|
135
|
-
options,
|
|
136
|
-
confirm: transformedConfirm,
|
|
137
|
-
initial_options: transformedInitialOptions,
|
|
138
|
-
max_selected_items: 2
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
test('can transform a selcet with external options', t => {
|
|
143
|
-
const fn = () => transformer(
|
|
144
|
-
<Select
|
|
145
|
-
type="external"
|
|
146
|
-
placeholder="placeholder"
|
|
147
|
-
actionId="aid"
|
|
148
|
-
/>
|
|
149
|
-
);
|
|
150
|
-
|
|
151
|
-
t.notThrows(fn);
|
|
152
|
-
const res = fn();
|
|
153
|
-
|
|
154
|
-
t.deepEqual(res, {
|
|
155
|
-
type: 'external_select',
|
|
156
|
-
placeholder: {
|
|
157
|
-
type: 'plain_text',
|
|
158
|
-
text: 'placeholder'
|
|
159
|
-
},
|
|
160
|
-
action_id: 'aid'
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
test('does not transform child options when not static type', t => {
|
|
165
|
-
const res = transformer(
|
|
166
|
-
<Select
|
|
167
|
-
type="external"
|
|
168
|
-
placeholder="p"
|
|
169
|
-
actionId="aid"
|
|
170
|
-
>
|
|
171
|
-
<Option value="V">O</Option>
|
|
172
|
-
</Select>
|
|
173
|
-
);
|
|
174
|
-
|
|
175
|
-
t.deepEqual(res, {
|
|
176
|
-
type: 'external_select',
|
|
177
|
-
placeholder: {
|
|
178
|
-
type: 'plain_text',
|
|
179
|
-
text: 'p'
|
|
180
|
-
},
|
|
181
|
-
action_id: 'aid'
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
test('allows initialUsers prop if type is a user select', t => {
|
|
186
|
-
const users = ['A', 'B', 'C'];
|
|
187
|
-
const res = transformer(
|
|
188
|
-
<Select
|
|
189
|
-
type="user"
|
|
190
|
-
placeholder="p"
|
|
191
|
-
actionId="aid"
|
|
192
|
-
initialUsers={users}
|
|
193
|
-
/>
|
|
194
|
-
);
|
|
195
|
-
|
|
196
|
-
t.deepEqual(res, {
|
|
197
|
-
type: 'users_select',
|
|
198
|
-
placeholder: {
|
|
199
|
-
type: 'plain_text',
|
|
200
|
-
text: 'p'
|
|
201
|
-
},
|
|
202
|
-
action_id: 'aid',
|
|
203
|
-
initial_users: users
|
|
204
|
-
});
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
test('allows initialConversations prop if type is conversation', t => {
|
|
208
|
-
const conversations = ['A', 'B', 'C'];
|
|
209
|
-
const res = transformer(
|
|
210
|
-
<Select
|
|
211
|
-
type="conversation"
|
|
212
|
-
placeholder="p"
|
|
213
|
-
actionId="aid"
|
|
214
|
-
initialConversations={conversations}
|
|
215
|
-
/>
|
|
216
|
-
);
|
|
217
|
-
|
|
218
|
-
t.deepEqual(res, {
|
|
219
|
-
type: 'conversations_select',
|
|
220
|
-
placeholder: {
|
|
221
|
-
type: 'plain_text',
|
|
222
|
-
text: 'p'
|
|
223
|
-
},
|
|
224
|
-
action_id: 'aid',
|
|
225
|
-
initial_conversations: conversations
|
|
226
|
-
});
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
test('allows initialChannels prop if type is channel', t => {
|
|
230
|
-
const channels = ['A', 'B', 'C'];
|
|
231
|
-
const res = transformer(
|
|
232
|
-
<Select
|
|
233
|
-
type="channel"
|
|
234
|
-
placeholder="p"
|
|
235
|
-
actionId="aid"
|
|
236
|
-
initialChannels={channels}
|
|
237
|
-
/>
|
|
238
|
-
);
|
|
239
|
-
|
|
240
|
-
t.deepEqual(res, {
|
|
241
|
-
type: 'channels_select',
|
|
242
|
-
placeholder: {
|
|
243
|
-
type: 'plain_text',
|
|
244
|
-
text: 'p'
|
|
245
|
-
},
|
|
246
|
-
action_id: 'aid',
|
|
247
|
-
initial_channels: channels
|
|
248
|
-
});
|
|
249
|
-
});
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import test from 'ava';
|
|
3
|
-
|
|
4
|
-
import transformer from '../../../src/transformers/input/text';
|
|
5
|
-
import Text from '../../../src/components/input/text';
|
|
6
|
-
|
|
7
|
-
test('it transforms a basic text input', t => {
|
|
8
|
-
const res = transformer(
|
|
9
|
-
<Text actionId="actionId"/>
|
|
10
|
-
);
|
|
11
|
-
|
|
12
|
-
t.deepEqual(res, {
|
|
13
|
-
type: 'plain_text_input',
|
|
14
|
-
action_id: 'actionId'
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
test('it transforms an advanced text input', t => {
|
|
19
|
-
const res = transformer(
|
|
20
|
-
<Text
|
|
21
|
-
actionId="actionId"
|
|
22
|
-
placeholder="placeholder"
|
|
23
|
-
initial="initial"
|
|
24
|
-
minLength={10}
|
|
25
|
-
maxLength={20}
|
|
26
|
-
multiline
|
|
27
|
-
/>
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
t.deepEqual(res, {
|
|
31
|
-
type: 'plain_text_input',
|
|
32
|
-
action_id: 'actionId',
|
|
33
|
-
placeholder: {
|
|
34
|
-
type: 'plain_text',
|
|
35
|
-
text: 'placeholder'
|
|
36
|
-
},
|
|
37
|
-
initial_value: 'initial',
|
|
38
|
-
min_length: 10,
|
|
39
|
-
max_length: 20,
|
|
40
|
-
multiline: true
|
|
41
|
-
});
|
|
42
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import test from 'ava';
|
|
3
|
-
|
|
4
|
-
import transformer from '../../../src/transformers/layout/actions';
|
|
5
|
-
import buttonTransformer from '../../../src/transformers/block/button';
|
|
6
|
-
import Actions from '../../../src/components/layout/actions';
|
|
7
|
-
import Button from '../../../src/components/block/button';
|
|
8
|
-
|
|
9
|
-
test('transforms a basic actions block', t => {
|
|
10
|
-
const button = <Button actionId="aid">FooBar</Button>;
|
|
11
|
-
const transformedButton = buttonTransformer(button);
|
|
12
|
-
|
|
13
|
-
const res = transformer(
|
|
14
|
-
<Actions>
|
|
15
|
-
{button}
|
|
16
|
-
</Actions>
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
t.deepEqual(res, {
|
|
20
|
-
type: 'actions',
|
|
21
|
-
elements: [transformedButton]
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
test('it transforms action blocks with more data', t => {
|
|
26
|
-
const res = transformer(
|
|
27
|
-
<Actions blockId="blockId">
|
|
28
|
-
<Button actionId="aid">Foo</Button>
|
|
29
|
-
</Actions>
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
t.is(res.block_id, 'blockId');
|
|
33
|
-
});
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import test from 'ava';
|
|
3
|
-
|
|
4
|
-
import Container from '../../../src/components/layout/container';
|
|
5
|
-
import Text from '../../../src/components/block/text';
|
|
6
|
-
import transformer from '../../../src/transformers/layout/container';
|
|
7
|
-
import textTransformer from '../../../src/transformers/block/text';
|
|
8
|
-
import { Child } from '../../../src/constants/types';
|
|
9
|
-
|
|
10
|
-
test('passes elements through', t => {
|
|
11
|
-
const elem = <Text>Foo</Text>
|
|
12
|
-
|
|
13
|
-
const res = transformer(
|
|
14
|
-
<Container>
|
|
15
|
-
{elem}
|
|
16
|
-
</Container>
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
t.deepEqual(res, [textTransformer(elem)] as any[]);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
test('can pass multiple elements through', t => {
|
|
23
|
-
const elem = <Text>Foo</Text>;
|
|
24
|
-
const elem2 = <Text>Bar</Text>;
|
|
25
|
-
|
|
26
|
-
const res = transformer(
|
|
27
|
-
<Container>
|
|
28
|
-
{elem}
|
|
29
|
-
{elem2}
|
|
30
|
-
</Container>
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
t.deepEqual(res, [elem, elem2].map(textTransformer) as any[]);
|
|
34
|
-
});
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import test from 'ava';
|
|
3
|
-
|
|
4
|
-
import transformer from '../../../src/transformers/layout/context';
|
|
5
|
-
import textTransformer from '../../../src/transformers/block/text';
|
|
6
|
-
import imageTransformer from '../../../src/transformers/block/image';
|
|
7
|
-
|
|
8
|
-
import Context from '../../../src/components/layout/context';
|
|
9
|
-
import Text from '../../../src/components/block/text';
|
|
10
|
-
import Image from '../../../src/components/block/image';
|
|
11
|
-
|
|
12
|
-
test('transforms a basic context block', t => {
|
|
13
|
-
const text = <Text>FooBar</Text>
|
|
14
|
-
const image = <Image url="someUrl" alt="someAlt"/>;
|
|
15
|
-
|
|
16
|
-
const transformedText = textTransformer(text);
|
|
17
|
-
const transformedImage = imageTransformer(image);
|
|
18
|
-
|
|
19
|
-
const res = transformer(
|
|
20
|
-
<Context>
|
|
21
|
-
{text}
|
|
22
|
-
{image}
|
|
23
|
-
</Context>
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
t.deepEqual(res, {
|
|
27
|
-
type: 'context',
|
|
28
|
-
elements: [
|
|
29
|
-
transformedText,
|
|
30
|
-
transformedImage
|
|
31
|
-
]
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
test('transforms a more complex context block', t => {
|
|
36
|
-
const res = transformer(
|
|
37
|
-
<Context blockId="blockId">
|
|
38
|
-
<Text>FooBar</Text>
|
|
39
|
-
</Context>
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
t.is(res.block_id, "blockId");
|
|
43
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import test from 'ava';
|
|
3
|
-
|
|
4
|
-
import transformer from '../../../src/transformers/layout/divider';
|
|
5
|
-
import Divider from '../../../src/components/layout/divider';
|
|
6
|
-
|
|
7
|
-
test('transforms a basic divider', t => {
|
|
8
|
-
const res = transformer(<Divider/>);
|
|
9
|
-
|
|
10
|
-
t.deepEqual(res, {type: 'divider'});
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
test('transforms a divider with id', t => {
|
|
14
|
-
const res = transformer(<Divider blockId="blockId"/>);
|
|
15
|
-
|
|
16
|
-
t.deepEqual(res, {
|
|
17
|
-
type: 'divider',
|
|
18
|
-
block_id: 'blockId'
|
|
19
|
-
});
|
|
20
|
-
});
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import test from 'ava';
|
|
3
|
-
|
|
4
|
-
import transformer from '../../../src/transformers/layout/file';
|
|
5
|
-
import File from '../../../src/components/layout/file';
|
|
6
|
-
|
|
7
|
-
test('transforms a basic file', t => {
|
|
8
|
-
const res = transformer(<File externalId="externalId"/>);
|
|
9
|
-
|
|
10
|
-
t.deepEqual(res, {
|
|
11
|
-
type: 'file',
|
|
12
|
-
source: 'remote',
|
|
13
|
-
external_id: 'externalId'
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
test('transforms a file with block id', t => {
|
|
18
|
-
const res = transformer(<File externalId="ext" blockId="block"/>);
|
|
19
|
-
|
|
20
|
-
t.deepEqual(res, {
|
|
21
|
-
type: 'file',
|
|
22
|
-
source: 'remote',
|
|
23
|
-
external_id: 'ext',
|
|
24
|
-
block_id: 'block'
|
|
25
|
-
});
|
|
26
|
-
});
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import test from 'ava';
|
|
3
|
-
|
|
4
|
-
import transformer from '../../../src/transformers/layout/image';
|
|
5
|
-
import Image from '../../../src/components/layout/image';
|
|
6
|
-
import Text from '../../../src/components/block/text';
|
|
7
|
-
|
|
8
|
-
test('transforms a basic image layout', t => {
|
|
9
|
-
const res = transformer(
|
|
10
|
-
<Image
|
|
11
|
-
url="someUrl"
|
|
12
|
-
alt="someAlt"
|
|
13
|
-
/>
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
t.deepEqual(res, {
|
|
17
|
-
type: 'image',
|
|
18
|
-
image_url: 'someUrl',
|
|
19
|
-
alt_text: 'someAlt'
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
test('transforms a more advanced image layout', t => {
|
|
24
|
-
const res = transformer(
|
|
25
|
-
<Image
|
|
26
|
-
url="someUrl"
|
|
27
|
-
alt="someAlt"
|
|
28
|
-
title="someTitle"
|
|
29
|
-
blockId="blockId"
|
|
30
|
-
/>
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
t.deepEqual(res, {
|
|
34
|
-
type: 'image',
|
|
35
|
-
image_url: 'someUrl',
|
|
36
|
-
alt_text: 'someAlt',
|
|
37
|
-
title: {
|
|
38
|
-
type: 'plain_text',
|
|
39
|
-
text: 'someTitle'
|
|
40
|
-
},
|
|
41
|
-
block_id: 'blockId'
|
|
42
|
-
});
|
|
43
|
-
});
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import test from 'ava';
|
|
3
|
-
|
|
4
|
-
import transformer from '../../../src/transformers/layout/input';
|
|
5
|
-
import textTransformer from '../../../src/transformers/input/text';
|
|
6
|
-
|
|
7
|
-
import Input from '../../../src/components/layout/input';
|
|
8
|
-
import TextInput from '../../../src/components/input/text';
|
|
9
|
-
|
|
10
|
-
test('transforms a basic input layout block', t => {
|
|
11
|
-
const plainText = <TextInput actionId="action"/>;
|
|
12
|
-
const transformedText = textTransformer(plainText);
|
|
13
|
-
|
|
14
|
-
const res = transformer(
|
|
15
|
-
<Input
|
|
16
|
-
label="someLabel"
|
|
17
|
-
element={plainText}
|
|
18
|
-
/>
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
t.deepEqual(res, {
|
|
22
|
-
type: 'input',
|
|
23
|
-
label: {
|
|
24
|
-
type: 'plain_text',
|
|
25
|
-
text: 'someLabel'
|
|
26
|
-
},
|
|
27
|
-
element: transformedText
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
test('transforms an advanced input layout block', t => {
|
|
32
|
-
const plainText = <TextInput actionId="action"/>;
|
|
33
|
-
const transformedText = textTransformer(plainText);
|
|
34
|
-
|
|
35
|
-
const res = transformer(
|
|
36
|
-
<Input
|
|
37
|
-
label="someLabel"
|
|
38
|
-
element={plainText}
|
|
39
|
-
blockId="blockId"
|
|
40
|
-
hint="someHint"
|
|
41
|
-
optional
|
|
42
|
-
/>
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
t.deepEqual(res, {
|
|
46
|
-
type: 'input',
|
|
47
|
-
label: {
|
|
48
|
-
type: 'plain_text',
|
|
49
|
-
text: 'someLabel'
|
|
50
|
-
},
|
|
51
|
-
element: transformedText,
|
|
52
|
-
block_id: 'blockId',
|
|
53
|
-
hint: {
|
|
54
|
-
type: 'plain_text',
|
|
55
|
-
text: 'someHint'
|
|
56
|
-
},
|
|
57
|
-
optional: true
|
|
58
|
-
});
|
|
59
|
-
});
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import test from 'ava';
|
|
3
|
-
import Section from '../../../src/components/layout/section';
|
|
4
|
-
import Text from '../../../src/components/block/text';
|
|
5
|
-
import transformer from '../../../src/transformers/layout/section';
|
|
6
|
-
|
|
7
|
-
test('it transforms a basic Section component', t => {
|
|
8
|
-
const elem = (
|
|
9
|
-
<Section
|
|
10
|
-
text={ <Text>FooBar</Text> }
|
|
11
|
-
/>
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
const res = transformer(elem);
|
|
15
|
-
|
|
16
|
-
t.deepEqual(res, {
|
|
17
|
-
type: 'section',
|
|
18
|
-
text: {
|
|
19
|
-
type: 'mrkdwn',
|
|
20
|
-
text: 'FooBar'
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
test('it transforms a more complex Section', t => {
|
|
26
|
-
const fields = [
|
|
27
|
-
<Text>OtherText</Text>
|
|
28
|
-
];
|
|
29
|
-
|
|
30
|
-
const res = transformer(
|
|
31
|
-
<Section
|
|
32
|
-
text={<Text>FooBar</Text>}
|
|
33
|
-
blockId="abc123"
|
|
34
|
-
accessory={<Text>Accessory</Text>}
|
|
35
|
-
>
|
|
36
|
-
<Text>OtherText</Text>
|
|
37
|
-
</Section>
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
t.deepEqual(res, {
|
|
41
|
-
type: 'section',
|
|
42
|
-
text: {
|
|
43
|
-
type: 'mrkdwn',
|
|
44
|
-
text: 'FooBar'
|
|
45
|
-
},
|
|
46
|
-
block_id: 'abc123',
|
|
47
|
-
fields: [
|
|
48
|
-
{
|
|
49
|
-
type: 'mrkdwn',
|
|
50
|
-
text: 'OtherText'
|
|
51
|
-
}
|
|
52
|
-
],
|
|
53
|
-
accessory: {
|
|
54
|
-
type: 'mrkdwn',
|
|
55
|
-
text: 'Accessory'
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
test('it does not break if there is a null field', t => {
|
|
61
|
-
const fn = () => transformer(
|
|
62
|
-
<Section text={<Text>Foo</Text>}>
|
|
63
|
-
<Text>More text</Text>
|
|
64
|
-
{null}
|
|
65
|
-
<Text>Even more</Text>
|
|
66
|
-
</Section>
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
t.notThrows(fn);
|
|
70
|
-
const res = fn();
|
|
71
|
-
|
|
72
|
-
t.deepEqual(res, {
|
|
73
|
-
type: 'section',
|
|
74
|
-
text: {
|
|
75
|
-
type: 'mrkdwn',
|
|
76
|
-
text: 'Foo'
|
|
77
|
-
},
|
|
78
|
-
fields: [
|
|
79
|
-
{
|
|
80
|
-
type: 'mrkdwn',
|
|
81
|
-
text: 'More text'
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
type: 'mrkdwn',
|
|
85
|
-
text: 'Even more'
|
|
86
|
-
}
|
|
87
|
-
]
|
|
88
|
-
});
|
|
89
|
-
});
|
package/test/tsconfig.json
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import test from 'ava';
|
|
3
|
-
import getType from '../../src/utils/get-type';
|
|
4
|
-
|
|
5
|
-
class Foo extends React.Component {}
|
|
6
|
-
|
|
7
|
-
test('it recognizes strings', t => {
|
|
8
|
-
t.is(getType('Hello'), 'string');
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
test('it recognizes DOM elements', t => {
|
|
12
|
-
t.is(getType(<div/>), 'div');
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
test('it recognizes react elements', t => {
|
|
16
|
-
t.is(getType(<Foo/>), 'Foo');
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
test('it recognizes null', t => {
|
|
20
|
-
t.is(getType(null), 'null');
|
|
21
|
-
});
|
package/tsconfig.json
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"noImplicitAny": true,
|
|
4
|
-
"removeComments": true,
|
|
5
|
-
"outDir": "./lib" ,
|
|
6
|
-
"rootDir": "./src",
|
|
7
|
-
"target": "es5",
|
|
8
|
-
"jsx": "react",
|
|
9
|
-
"baseUrl": ".",
|
|
10
|
-
"esModuleInterop": true
|
|
11
|
-
},
|
|
12
|
-
"exclude": ["node_modules", "test/**/*"],
|
|
13
|
-
"include": ["src"]
|
|
14
|
-
}
|