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,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = (function (elem) {
|
|
4
|
-
var _a = elem.props, plainText = _a.plainText, children = _a.children, emoji = _a.emoji, verbatim = _a.verbatim;
|
|
5
|
-
var res = {
|
|
6
|
-
type: plainText ? 'plain_text' : 'mrkdwn',
|
|
7
|
-
text: children
|
|
8
|
-
};
|
|
9
|
-
if (emoji) {
|
|
10
|
-
res.emoji = true;
|
|
11
|
-
}
|
|
12
|
-
if (verbatim) {
|
|
13
|
-
res.verbatim = true;
|
|
14
|
-
}
|
|
15
|
-
return res;
|
|
16
|
-
});
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
var get_type_1 = __importDefault(require("../utils/get-type"));
|
|
7
|
-
var text_1 = __importDefault(require("./block/text"));
|
|
8
|
-
var confirmation_1 = __importDefault(require("./block/confirmation"));
|
|
9
|
-
var button_1 = __importDefault(require("./block/button"));
|
|
10
|
-
var image_1 = __importDefault(require("./block/image"));
|
|
11
|
-
var container_1 = __importDefault(require("./layout/container"));
|
|
12
|
-
var section_1 = __importDefault(require("./layout/section"));
|
|
13
|
-
var actions_1 = __importDefault(require("./layout/actions"));
|
|
14
|
-
var context_1 = __importDefault(require("./layout/context"));
|
|
15
|
-
var divider_1 = __importDefault(require("./layout/divider"));
|
|
16
|
-
var file_1 = __importDefault(require("./layout/file"));
|
|
17
|
-
var image_2 = __importDefault(require("./layout/image"));
|
|
18
|
-
var input_1 = __importDefault(require("./layout/input"));
|
|
19
|
-
var text_2 = __importDefault(require("./input/text"));
|
|
20
|
-
var date_picker_1 = __importDefault(require("./input/date-picker"));
|
|
21
|
-
var select_1 = __importDefault(require("./input/select"));
|
|
22
|
-
var option_1 = __importDefault(require("./input/option"));
|
|
23
|
-
var option_group_1 = __importDefault(require("./input/option-group"));
|
|
24
|
-
var overflow_1 = __importDefault(require("./input/overflow"));
|
|
25
|
-
var radio_group_1 = __importDefault(require("./input/radio-group"));
|
|
26
|
-
var Transformers = {
|
|
27
|
-
Container: container_1.default,
|
|
28
|
-
Section: section_1.default,
|
|
29
|
-
Actions: actions_1.default,
|
|
30
|
-
Context: context_1.default,
|
|
31
|
-
Divider: divider_1.default,
|
|
32
|
-
File: file_1.default,
|
|
33
|
-
ImageLayout: image_2.default,
|
|
34
|
-
Input: input_1.default,
|
|
35
|
-
Text: text_1.default,
|
|
36
|
-
Confirmation: confirmation_1.default,
|
|
37
|
-
Button: button_1.default,
|
|
38
|
-
Image: image_1.default,
|
|
39
|
-
TextInput: text_2.default,
|
|
40
|
-
DatePicker: date_picker_1.default,
|
|
41
|
-
Select: select_1.default,
|
|
42
|
-
Overflow: overflow_1.default,
|
|
43
|
-
RadioGroup: radio_group_1.default,
|
|
44
|
-
Option: option_1.default,
|
|
45
|
-
OptionGroup: option_group_1.default
|
|
46
|
-
};
|
|
47
|
-
exports.default = Transformers;
|
|
48
|
-
exports.transform = function (elem) {
|
|
49
|
-
var type = get_type_1.default(elem);
|
|
50
|
-
if (!Transformers[type]) {
|
|
51
|
-
throw new Error("No transformer exists for type '" + type + "'");
|
|
52
|
-
}
|
|
53
|
-
return Transformers[type](elem);
|
|
54
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
var react_1 = __importDefault(require("react"));
|
|
7
|
-
var __1 = require("..");
|
|
8
|
-
var text_1 = __importDefault(require("../../components/block/text"));
|
|
9
|
-
exports.default = (function (child) {
|
|
10
|
-
var _a = child.props, actionId = _a.actionId, placeholder = _a.placeholder, initialDate = _a.initialDate, confirm = _a.confirm;
|
|
11
|
-
var res = {
|
|
12
|
-
type: 'datepicker',
|
|
13
|
-
action_id: actionId
|
|
14
|
-
};
|
|
15
|
-
if (placeholder) {
|
|
16
|
-
res.placeholder = __1.transform(react_1.default.createElement(text_1.default, { plainText: true }, placeholder));
|
|
17
|
-
}
|
|
18
|
-
if (initialDate) {
|
|
19
|
-
var dateRegex = /^(\d{4})-(\d{2})-(\d{2})$/g;
|
|
20
|
-
var date = new Date(initialDate);
|
|
21
|
-
if (Number.isNaN(date.getTime()) || !dateRegex.test(initialDate)) {
|
|
22
|
-
throw new Error('Date must be valid and in format YYY-MM-DD.');
|
|
23
|
-
}
|
|
24
|
-
res.initial_date = initialDate;
|
|
25
|
-
}
|
|
26
|
-
if (confirm) {
|
|
27
|
-
res.confirm = __1.transform(confirm);
|
|
28
|
-
}
|
|
29
|
-
return res;
|
|
30
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
var react_1 = __importDefault(require("react"));
|
|
7
|
-
var text_1 = __importDefault(require("../../components/block/text"));
|
|
8
|
-
var __1 = require("..");
|
|
9
|
-
exports.default = (function (child) {
|
|
10
|
-
var _a = child.props, label = _a.label, children = _a.children;
|
|
11
|
-
var options = children;
|
|
12
|
-
if (!Array.isArray(options)) {
|
|
13
|
-
options = [options];
|
|
14
|
-
}
|
|
15
|
-
return {
|
|
16
|
-
label: __1.transform(react_1.default.createElement(text_1.default, { plainText: true }, label)),
|
|
17
|
-
options: options.map(function (option) { return __1.transform(option); })
|
|
18
|
-
};
|
|
19
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
var react_1 = __importDefault(require("react"));
|
|
7
|
-
var text_1 = __importDefault(require("../../components/block/text"));
|
|
8
|
-
var __1 = require("..");
|
|
9
|
-
exports.default = (function (child) {
|
|
10
|
-
var _a = child.props, text = _a.children, value = _a.value, url = _a.url;
|
|
11
|
-
var res = {
|
|
12
|
-
text: __1.transform(react_1.default.createElement(text_1.default, { plainText: true }, text)),
|
|
13
|
-
value: value
|
|
14
|
-
};
|
|
15
|
-
if (url) {
|
|
16
|
-
res.url = url;
|
|
17
|
-
}
|
|
18
|
-
return res;
|
|
19
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var __1 = require("..");
|
|
4
|
-
exports.default = (function (child) {
|
|
5
|
-
var _a = child.props, actionId = _a.actionId, children = _a.children, confirm = _a.confirm;
|
|
6
|
-
var elements = children;
|
|
7
|
-
if (!Array.isArray(elements)) {
|
|
8
|
-
elements = [elements];
|
|
9
|
-
}
|
|
10
|
-
var res = {
|
|
11
|
-
type: 'overflow',
|
|
12
|
-
action_id: actionId,
|
|
13
|
-
options: elements.map(function (element) { return __1.transform(element); })
|
|
14
|
-
};
|
|
15
|
-
if (confirm) {
|
|
16
|
-
res.confirm = __1.transform(confirm);
|
|
17
|
-
}
|
|
18
|
-
return res;
|
|
19
|
-
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var __1 = require("..");
|
|
4
|
-
exports.default = (function (child) {
|
|
5
|
-
var _a = child.props, actionId = _a.actionId, children = _a.children, initialOption = _a.initialOption, confirm = _a.confirm;
|
|
6
|
-
var elements = children;
|
|
7
|
-
if (!Array.isArray(elements)) {
|
|
8
|
-
elements = [elements];
|
|
9
|
-
}
|
|
10
|
-
var res = {
|
|
11
|
-
type: 'radio_buttons',
|
|
12
|
-
action_id: actionId,
|
|
13
|
-
options: elements.map(function (element) { return __1.transform(element); })
|
|
14
|
-
};
|
|
15
|
-
if (initialOption) {
|
|
16
|
-
res.initial_option = __1.transform(initialOption);
|
|
17
|
-
}
|
|
18
|
-
if (confirm) {
|
|
19
|
-
res.confirm = __1.transform(confirm);
|
|
20
|
-
}
|
|
21
|
-
return res;
|
|
22
|
-
});
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
var _a;
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
var react_1 = __importDefault(require("react"));
|
|
8
|
-
var select_1 = require("../../components/input/select");
|
|
9
|
-
var text_1 = __importDefault(require("../../components/block/text"));
|
|
10
|
-
var __1 = require("..");
|
|
11
|
-
var get_type_1 = __importDefault(require("../../utils/get-type"));
|
|
12
|
-
var OPTION = 'Option';
|
|
13
|
-
var OPTION_GROUP = 'OptionGroup';
|
|
14
|
-
var types = (_a = {},
|
|
15
|
-
_a[select_1.selectTypes.STATIC] = 'static_select',
|
|
16
|
-
_a[select_1.selectTypes.EXTERNAL] = 'external_select',
|
|
17
|
-
_a[select_1.selectTypes.USER] = 'users_select',
|
|
18
|
-
_a[select_1.selectTypes.CONVERSATION] = 'conversations_select',
|
|
19
|
-
_a[select_1.selectTypes.CHANNEL] = 'channels_select',
|
|
20
|
-
_a);
|
|
21
|
-
var MULTI_PREFIX = 'multi_';
|
|
22
|
-
exports.default = (function (child) {
|
|
23
|
-
var _a = child.props, placeholder = _a.placeholder, actionId = _a.actionId, multi = _a.multi, children = _a.children, initialOptions = _a.initialOptions, confirm = _a.confirm, maxSelectedItems = _a.maxSelectedItems, typeProp = _a.type, initialUsers = _a.initialUsers, initialConversations = _a.initialConversations, initialChannels = _a.initialChannels;
|
|
24
|
-
var type = typeProp || select_1.selectTypes.STATIC;
|
|
25
|
-
var typeString = "" + (multi ? MULTI_PREFIX : '') + types[type];
|
|
26
|
-
var res = {
|
|
27
|
-
type: typeString,
|
|
28
|
-
placeholder: __1.transform(react_1.default.createElement(text_1.default, { plainText: true }, placeholder)),
|
|
29
|
-
action_id: actionId
|
|
30
|
-
};
|
|
31
|
-
var elements = children;
|
|
32
|
-
if (!Array.isArray(elements)) {
|
|
33
|
-
elements = [elements];
|
|
34
|
-
}
|
|
35
|
-
if (type === select_1.selectTypes.STATIC) {
|
|
36
|
-
var type_1 = get_type_1.default(elements[0]);
|
|
37
|
-
if (elements.some(function (element) { return get_type_1.default(element) !== type_1; })) {
|
|
38
|
-
if (type_1 === OPTION && elements.some(function (element) { return get_type_1.default(element) !== OPTION_GROUP; })) {
|
|
39
|
-
throw new TypeError('You cannot mix OptionGroup types with Option types in a Select block.');
|
|
40
|
-
}
|
|
41
|
-
else if (type_1 === OPTION_GROUP && elements.some(function (element) { return get_type_1.default(element) !== OPTION; })) {
|
|
42
|
-
throw new TypeError('You cannot mix OptionGroup types with Option types in a Select block.');
|
|
43
|
-
}
|
|
44
|
-
throw new TypeError('Only allowed types are Option OR OptionGroup');
|
|
45
|
-
}
|
|
46
|
-
if (type_1 === OPTION) {
|
|
47
|
-
elements = elements;
|
|
48
|
-
res.options = elements.map(function (element) { return __1.transform(element); });
|
|
49
|
-
}
|
|
50
|
-
else if (type_1 === OPTION_GROUP) {
|
|
51
|
-
elements = elements;
|
|
52
|
-
res.option_groups = elements.map(function (element) { return __1.transform(element); });
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
if (confirm) {
|
|
56
|
-
res.confirm = __1.transform(confirm);
|
|
57
|
-
}
|
|
58
|
-
if (type !== select_1.selectTypes.USER && initialOptions) {
|
|
59
|
-
}
|
|
60
|
-
switch (type) {
|
|
61
|
-
case select_1.selectTypes.USER:
|
|
62
|
-
if (initialUsers) {
|
|
63
|
-
res.initial_users = initialUsers;
|
|
64
|
-
}
|
|
65
|
-
break;
|
|
66
|
-
case select_1.selectTypes.CONVERSATION:
|
|
67
|
-
if (initialConversations) {
|
|
68
|
-
res.initial_conversations = initialConversations;
|
|
69
|
-
}
|
|
70
|
-
break;
|
|
71
|
-
case select_1.selectTypes.CHANNEL:
|
|
72
|
-
if (initialChannels) {
|
|
73
|
-
res.initial_channels = initialChannels;
|
|
74
|
-
}
|
|
75
|
-
default:
|
|
76
|
-
if (initialOptions) {
|
|
77
|
-
res.initial_options = initialOptions.map(function (element) { return __1.transform(element); });
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
if (maxSelectedItems) {
|
|
81
|
-
res.max_selected_items = maxSelectedItems;
|
|
82
|
-
}
|
|
83
|
-
return res;
|
|
84
|
-
});
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
var react_1 = __importDefault(require("react"));
|
|
7
|
-
var text_1 = __importDefault(require("../../components/block/text"));
|
|
8
|
-
var __1 = require("..");
|
|
9
|
-
exports.default = (function (child) {
|
|
10
|
-
var _a = child.props, actionId = _a.actionId, placeholder = _a.placeholder, initial = _a.initial, multiline = _a.multiline, minLength = _a.minLength, maxLength = _a.maxLength;
|
|
11
|
-
var res = {
|
|
12
|
-
type: 'plain_text_input',
|
|
13
|
-
action_id: actionId
|
|
14
|
-
};
|
|
15
|
-
if (placeholder) {
|
|
16
|
-
res.placeholder = __1.transform(react_1.default.createElement(text_1.default, { plainText: true }, placeholder));
|
|
17
|
-
}
|
|
18
|
-
if (initial) {
|
|
19
|
-
res.initial_value = initial;
|
|
20
|
-
}
|
|
21
|
-
if (multiline) {
|
|
22
|
-
res.multiline = true;
|
|
23
|
-
}
|
|
24
|
-
if (minLength) {
|
|
25
|
-
res.min_length = minLength;
|
|
26
|
-
}
|
|
27
|
-
if (maxLength) {
|
|
28
|
-
res.max_length = maxLength;
|
|
29
|
-
}
|
|
30
|
-
return res;
|
|
31
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var __1 = require("..");
|
|
4
|
-
exports.default = (function (child) {
|
|
5
|
-
var _a = child.props, children = _a.children, blockId = _a.blockId;
|
|
6
|
-
var elements = children;
|
|
7
|
-
if (!Array.isArray(elements)) {
|
|
8
|
-
elements = [elements];
|
|
9
|
-
}
|
|
10
|
-
var res = {
|
|
11
|
-
type: 'actions',
|
|
12
|
-
elements: elements.map(function (element) { return __1.transform(element); })
|
|
13
|
-
};
|
|
14
|
-
if (blockId) {
|
|
15
|
-
res.block_id = blockId;
|
|
16
|
-
}
|
|
17
|
-
return res;
|
|
18
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var __1 = require("..");
|
|
4
|
-
exports.default = (function (child) {
|
|
5
|
-
var children = child.props.children;
|
|
6
|
-
var elements = children;
|
|
7
|
-
if (!Array.isArray(elements)) {
|
|
8
|
-
elements = [elements];
|
|
9
|
-
}
|
|
10
|
-
return elements.map(function (element) { return __1.transform(element); });
|
|
11
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var __1 = require("..");
|
|
4
|
-
exports.default = (function (child) {
|
|
5
|
-
var _a = child.props, children = _a.children, blockId = _a.blockId;
|
|
6
|
-
var elements = children;
|
|
7
|
-
if (!Array.isArray(elements)) {
|
|
8
|
-
elements = [elements];
|
|
9
|
-
}
|
|
10
|
-
var res = {
|
|
11
|
-
type: 'context',
|
|
12
|
-
elements: elements.map(function (element) { return __1.transform(element); })
|
|
13
|
-
};
|
|
14
|
-
if (blockId) {
|
|
15
|
-
res.block_id = blockId;
|
|
16
|
-
}
|
|
17
|
-
return res;
|
|
18
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = (function (child) {
|
|
4
|
-
var _a = child.props, externalId = _a.externalId, blockId = _a.blockId;
|
|
5
|
-
var res = {
|
|
6
|
-
type: 'file',
|
|
7
|
-
source: 'remote',
|
|
8
|
-
external_id: externalId
|
|
9
|
-
};
|
|
10
|
-
if (blockId) {
|
|
11
|
-
res.block_id = blockId;
|
|
12
|
-
}
|
|
13
|
-
return res;
|
|
14
|
-
});
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
var react_1 = __importDefault(require("react"));
|
|
7
|
-
var __1 = require("..");
|
|
8
|
-
var text_1 = __importDefault(require("../../components/block/text"));
|
|
9
|
-
exports.default = (function (child) {
|
|
10
|
-
var _a = child.props, url = _a.url, alt = _a.alt, title = _a.title, blockId = _a.blockId;
|
|
11
|
-
var res = {
|
|
12
|
-
type: 'image',
|
|
13
|
-
image_url: url,
|
|
14
|
-
alt_text: alt
|
|
15
|
-
};
|
|
16
|
-
if (title) {
|
|
17
|
-
res.title = __1.transform(react_1.default.createElement(text_1.default, { plainText: true }, title));
|
|
18
|
-
}
|
|
19
|
-
if (blockId) {
|
|
20
|
-
res.block_id = blockId;
|
|
21
|
-
}
|
|
22
|
-
return res;
|
|
23
|
-
});
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
var react_1 = __importDefault(require("react"));
|
|
7
|
-
var __1 = require("..");
|
|
8
|
-
var text_1 = __importDefault(require("../../components/block/text"));
|
|
9
|
-
exports.default = (function (child) {
|
|
10
|
-
var _a = child.props, label = _a.label, element = _a.element, hint = _a.hint, optional = _a.optional, blockId = _a.blockId;
|
|
11
|
-
var res = {
|
|
12
|
-
type: 'input',
|
|
13
|
-
label: __1.transform(react_1.default.createElement(text_1.default, { plainText: true }, label)),
|
|
14
|
-
element: __1.transform(element)
|
|
15
|
-
};
|
|
16
|
-
if (hint) {
|
|
17
|
-
res.hint = __1.transform(react_1.default.createElement(text_1.default, { plainText: true }, hint));
|
|
18
|
-
}
|
|
19
|
-
if (optional) {
|
|
20
|
-
res.optional = true;
|
|
21
|
-
}
|
|
22
|
-
if (blockId) {
|
|
23
|
-
res.block_id = blockId;
|
|
24
|
-
}
|
|
25
|
-
return res;
|
|
26
|
-
});
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var __1 = require("..");
|
|
4
|
-
exports.default = (function (elem) {
|
|
5
|
-
var _a = elem.props, text = _a.text, blockId = _a.blockId, children = _a.children, accessory = _a.accessory;
|
|
6
|
-
var res = {
|
|
7
|
-
type: 'section',
|
|
8
|
-
text: __1.transform(text)
|
|
9
|
-
};
|
|
10
|
-
if (blockId) {
|
|
11
|
-
res.block_id = blockId;
|
|
12
|
-
}
|
|
13
|
-
if (accessory) {
|
|
14
|
-
res.accessory = __1.transform(accessory);
|
|
15
|
-
}
|
|
16
|
-
if (children) {
|
|
17
|
-
res.fields = [];
|
|
18
|
-
var fields = children;
|
|
19
|
-
if (!Array.isArray(fields)) {
|
|
20
|
-
fields = [fields];
|
|
21
|
-
}
|
|
22
|
-
for (var _i = 0, fields_1 = fields; _i < fields_1.length; _i++) {
|
|
23
|
-
var field = fields_1[_i];
|
|
24
|
-
if (field) {
|
|
25
|
-
var t = __1.transform(field);
|
|
26
|
-
res.fields.push(t);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return res;
|
|
31
|
-
});
|
package/lib/utils/get-type.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = (function (element) {
|
|
4
|
-
if (typeof element === 'string') {
|
|
5
|
-
return 'string';
|
|
6
|
-
}
|
|
7
|
-
if (element === null) {
|
|
8
|
-
return 'null';
|
|
9
|
-
}
|
|
10
|
-
if (Array.isArray(element)) {
|
|
11
|
-
throw new TypeError('Cannot type arrays');
|
|
12
|
-
}
|
|
13
|
-
var type = element.type;
|
|
14
|
-
var fn = type;
|
|
15
|
-
return fn.name || type;
|
|
16
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import Confirmation from './confirmation';
|
|
3
|
-
|
|
4
|
-
type TopProps = {
|
|
5
|
-
children: string;
|
|
6
|
-
actionId: string;
|
|
7
|
-
url?: string;
|
|
8
|
-
value?: string;
|
|
9
|
-
style?: 'primary' | 'danger';
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export type ButtonProps = TopProps & {
|
|
13
|
-
confirm?: Confirmation;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
type Props = TopProps & {
|
|
17
|
-
confirm?: React.ReactElement<Confirmation>;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export default class Button extends React.Component<Props> {}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import Text from './text';
|
|
3
|
-
|
|
4
|
-
type TopProps = {
|
|
5
|
-
title: string;
|
|
6
|
-
confirm: string;
|
|
7
|
-
deny: string;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
/* This is a dumb workaround to merging props */
|
|
11
|
-
export type ConfirmationProps = TopProps & {
|
|
12
|
-
children: Text;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
type Props = TopProps & {
|
|
16
|
-
children: React.ReactElement<Text>;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export default class Confirmation extends React.Component<Props> {}
|
package/src/components/index.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export {default as Message} from './message';
|
|
2
|
-
|
|
3
|
-
export {default as Button} from './block/button';
|
|
4
|
-
export {default as Confirmation} from './block/confirmation';
|
|
5
|
-
export {default as Image} from './block/image';
|
|
6
|
-
export {default as Text} from './block/text';
|
|
7
|
-
|
|
8
|
-
export {default as DatePicker} from './input/date-picker';
|
|
9
|
-
export {default as OptionGroup} from './input/option-group';
|
|
10
|
-
export {default as Option} from './input/option';
|
|
11
|
-
export {default as Overflow} from './input/overflow';
|
|
12
|
-
export {default as RadioGroup} from './input/radio-group';
|
|
13
|
-
export {default as Select} from './input/select';
|
|
14
|
-
export {default as TextInput} from './input/text';
|
|
15
|
-
|
|
16
|
-
export {default as Actions} from './layout/actions';
|
|
17
|
-
export {default as Context} from './layout/context';
|
|
18
|
-
export {default as Divider} from './layout/divider';
|
|
19
|
-
export {default as File} from './layout/file';
|
|
20
|
-
export {default as ImageLayout} from './layout/image';
|
|
21
|
-
export {default as Input} from './layout/input';
|
|
22
|
-
export {default as Section} from './layout/section';
|
|
23
|
-
export {default as Container} from './layout/container';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import Confirmation from '../block/confirmation';
|
|
3
|
-
|
|
4
|
-
export type Props = {
|
|
5
|
-
actionId: string;
|
|
6
|
-
placeholder?: string;
|
|
7
|
-
initialDate?: string;
|
|
8
|
-
confirm?: React.ReactElement<Confirmation>;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export default class DatePicker extends React.Component<Props> {}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import Confirmation from '../block/confirmation';
|
|
3
|
-
import Option from './option';
|
|
4
|
-
import {SingleOrArray} from '../../utils/type-helpers';
|
|
5
|
-
|
|
6
|
-
export type Props = {
|
|
7
|
-
actionId: string;
|
|
8
|
-
children: SingleOrArray<React.ReactElement<Option>>;
|
|
9
|
-
confirm?: React.ReactElement<Confirmation>;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export default class Overflow extends React.Component<Props> {}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import Option from './option';
|
|
3
|
-
import Confirmation from '../block/confirmation';
|
|
4
|
-
import {SingleOrArray} from '../../utils/type-helpers';
|
|
5
|
-
|
|
6
|
-
export type Props = {
|
|
7
|
-
actionId: string;
|
|
8
|
-
children: SingleOrArray<React.ReactElement<Option>>;
|
|
9
|
-
initialOption?: React.ReactElement<Option>;
|
|
10
|
-
confirm?: React.ReactElement<Confirmation>;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export default class RadioGroup extends React.Component<Props> {}
|