@antscorp/antsomi-ui 1.3.5-beta.140 → 1.3.5-beta.142
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/es/components/molecules/TemplateSaveAs/TemplateSaveAs.d.ts +2 -0
- package/es/components/molecules/TemplateSaveAs/TemplateSaveAs.js +5 -2
- package/es/components/molecules/TemplateSaveAs/TemplateSaveAsModal.js +1 -1
- package/es/components/molecules/TemplateSaveAs/components/Category/Category.js +4 -1
- package/es/components/molecules/TemplateSaveAs/hooks/useTemplateSave.d.ts +2 -0
- package/es/components/molecules/TemplateSaveAs/hooks/useTemplateSave.js +30 -1
- package/es/components/molecules/TemplateSaveAs/styled.js +4 -0
- package/es/constants/theme.js +16 -14
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import type { FormInstance, SelectProps } from 'antd';
|
|
3
3
|
import { ImageSliderProps } from './components';
|
|
4
4
|
import { ShareAccessProps } from '../ShareAccess/types';
|
|
5
|
+
import { RuleObject } from 'antd/es/form';
|
|
5
6
|
export type categoriesProps = {
|
|
6
7
|
[key: string]: (string | number)[];
|
|
7
8
|
};
|
|
@@ -61,6 +62,7 @@ export interface TemplateSaveAsProps {
|
|
|
61
62
|
onSearch?: (searchValue: string) => void;
|
|
62
63
|
onNamePopupScroll?: SelectProps['onPopupScroll'];
|
|
63
64
|
onScrollToBottom?: () => void;
|
|
65
|
+
validateName?: (rule: RuleObject, value: any) => void;
|
|
64
66
|
};
|
|
65
67
|
descriptionOptions?: {
|
|
66
68
|
label?: string;
|
|
@@ -90,7 +90,7 @@ export const TemplateSaveAs = props => {
|
|
|
90
90
|
React.createElement(Text, { className: "field-title field-title--start" },
|
|
91
91
|
templateLabel || 'Template name',
|
|
92
92
|
React.createElement("span", null, "\u2009*")),
|
|
93
|
-
saveOption === saveNewValue ? (React.createElement(Form.Item, { name: "template-name", validateTrigger: "onChange", rules: [{ required: true, message: "This field can't be empty" }] },
|
|
93
|
+
saveOption === saveNewValue ? (React.createElement(Form.Item, { label: "Template name", name: "template-name", validateTrigger: "onChange", noStyle: true, rules: [{ required: true, message: "This field can't be empty" }] },
|
|
94
94
|
React.createElement(Input, { className: "field-input", value: templateNameNew, placeholder: placeholder, debounce: 100, maxLength: 255, onAfterChange: value => {
|
|
95
95
|
handleChangeValue({ templateName: { id: undefined, label: value } });
|
|
96
96
|
setTemplateNameNew(value);
|
|
@@ -118,7 +118,10 @@ export const TemplateSaveAs = props => {
|
|
|
118
118
|
...(templateNameList.find(item => item.id === (templateNameExist === null || templateNameExist === void 0 ? void 0 : templateNameExist.id))
|
|
119
119
|
? []
|
|
120
120
|
: [{ value: templateNameExist === null || templateNameExist === void 0 ? void 0 : templateNameExist.id, label: templateNameExist === null || templateNameExist === void 0 ? void 0 : templateNameExist.label }]),
|
|
121
|
-
...templateNameList.map(item => ({
|
|
121
|
+
...templateNameList.map(item => ({
|
|
122
|
+
value: item.id,
|
|
123
|
+
label: item.label,
|
|
124
|
+
})),
|
|
122
125
|
]
|
|
123
126
|
: [], onChange: value => {
|
|
124
127
|
var _a, _b;
|
|
@@ -45,6 +45,6 @@ export const TemplateSaveAsModal = props => {
|
|
|
45
45
|
onCancel(event);
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
-
return (React.createElement(ModalV2, Object.assign({ open: open, onCancel: handleCancel, onOk: handleOk, okText: okText || 'Save', width: 1177, title: title || 'Save as my template', styles: { body: { borderTop: '1px solid #e5e5e5', paddingTop: 0 } } }, restProps),
|
|
48
|
+
return (React.createElement(ModalV2, Object.assign({ open: open, onCancel: handleCancel, onOk: handleOk, okText: okText || 'Save', width: 1177, title: title || 'Save as my template', styles: { body: { borderTop: '1px solid #e5e5e5', paddingTop: 0 } }, centered: true }, restProps),
|
|
49
49
|
React.createElement(TemplateSaveAs, Object.assign({ onChange: onChange ? (newValue, errors) => handleOnChange(newValue, errors) : undefined, value: templateValue || internalValue }, restTemplateProps))));
|
|
50
50
|
};
|
|
@@ -5,7 +5,7 @@ const { Text } = Typography;
|
|
|
5
5
|
export const Category = props => {
|
|
6
6
|
const { categoryKey, categoryChildren, label, selected, onRemoveCategory, onAddCategory } = props;
|
|
7
7
|
const remainChildren = categoryChildren.filter(item => !(selected === null || selected === void 0 ? void 0 : selected.includes(item.key)));
|
|
8
|
-
return (React.createElement(Flex, { className: "field-container" },
|
|
8
|
+
return (React.createElement(Flex, { className: "field-container categories-container" },
|
|
9
9
|
React.createElement(Text, { className: "field-title" }, label),
|
|
10
10
|
React.createElement(Flex, { wrap: "wrap", gap: 10, className: "category-container" }, selected === null || selected === void 0 ? void 0 :
|
|
11
11
|
selected.map(selectedKey => {
|
|
@@ -21,6 +21,9 @@ export const Category = props => {
|
|
|
21
21
|
label.toLowerCase())) : (label)) : (React.createElement(Dropdown, { menu: {
|
|
22
22
|
items: remainChildren,
|
|
23
23
|
onClick: ({ key }) => onAddCategory({ parentKey: categoryKey, childKey: key }),
|
|
24
|
+
}, overlayStyle: {
|
|
25
|
+
maxHeight: 400,
|
|
26
|
+
overflow: 'auto',
|
|
24
27
|
}, getPopupContainer: triggerNode => triggerNode.parentElement, trigger: ['click'] }, typeof label === 'string' ? (React.createElement(Button, { disabled: true },
|
|
25
28
|
"+ Add ", label === null || label === void 0 ? void 0 :
|
|
26
29
|
label.toLowerCase())) : (label))))));
|
|
@@ -4,6 +4,7 @@ import { TGetTemplateCategoryList, TGetObjectTEmplateList } from '@antscorp/ants
|
|
|
4
4
|
import { TTemplateListingConfig } from '@antscorp/antsomi-ui/es/types/templateListing';
|
|
5
5
|
import { TemplateCategory } from '@antscorp/antsomi-ui/es/models/TemplateCategory';
|
|
6
6
|
import { TemplateValueOptions, categoriesProps } from '../TemplateSaveAs';
|
|
7
|
+
import { RuleObject } from 'antd/es/form';
|
|
7
8
|
interface TemplateListingOptions {
|
|
8
9
|
service: PayloadInfo;
|
|
9
10
|
config: TTemplateListingConfig;
|
|
@@ -60,6 +61,7 @@ export declare const useTemplateSave: (options: TemplateListingOptions) => {
|
|
|
60
61
|
onSearch: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
61
62
|
onScrollToBottom: () => void;
|
|
62
63
|
isLoading: boolean;
|
|
64
|
+
validateName: (rule: RuleObject, value: any) => Promise<void>;
|
|
63
65
|
};
|
|
64
66
|
form: import("antd").FormInstance<any>;
|
|
65
67
|
errors: any[] | undefined;
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
// Libraries
|
|
2
11
|
import { useCallback, useMemo, useState } from 'react';
|
|
3
|
-
import { useGetTemplateCategoryList, useGetObjectTemplateList, } from '@antscorp/antsomi-ui/es/queries/TemplateListing';
|
|
12
|
+
import { useGetTemplateCategoryList, useGetObjectTemplateList, useValidateTemplateName, } from '@antscorp/antsomi-ui/es/queries/TemplateListing';
|
|
4
13
|
// Hooks
|
|
5
14
|
import { useDeepCompareMemo } from '@antscorp/antsomi-ui/es/hooks';
|
|
6
15
|
import { Form } from 'antd';
|
|
@@ -54,6 +63,7 @@ export const useTemplateSave = (options) => {
|
|
|
54
63
|
},
|
|
55
64
|
options: templateListOptions,
|
|
56
65
|
});
|
|
66
|
+
const { mutateAsync: validateTemplateName } = useValidateTemplateName({});
|
|
57
67
|
// Variables
|
|
58
68
|
const isLoadingTemplateList = isFetching || isFetchingNextPage;
|
|
59
69
|
// Memo
|
|
@@ -85,6 +95,24 @@ export const useTemplateSave = (options) => {
|
|
|
85
95
|
const reset = () => {
|
|
86
96
|
setValue(valueArg || {});
|
|
87
97
|
};
|
|
98
|
+
/* Validate Template Name */
|
|
99
|
+
const validateName = (rule, value) => __awaiter(void 0, void 0, void 0, function* () {
|
|
100
|
+
if (!value) {
|
|
101
|
+
return Promise.reject(new Error('This field is required'));
|
|
102
|
+
}
|
|
103
|
+
const response = yield validateTemplateName({
|
|
104
|
+
auth: service,
|
|
105
|
+
params: {
|
|
106
|
+
object_type: objectType,
|
|
107
|
+
public_level: publicLevel,
|
|
108
|
+
template_name: value,
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
if (response.existed) {
|
|
112
|
+
return Promise.reject(new Error('Template name already exists'));
|
|
113
|
+
}
|
|
114
|
+
return Promise.resolve();
|
|
115
|
+
});
|
|
88
116
|
return {
|
|
89
117
|
// MapKeys
|
|
90
118
|
categoryItems,
|
|
@@ -108,6 +136,7 @@ export const useTemplateSave = (options) => {
|
|
|
108
136
|
onSearch: setSearchName,
|
|
109
137
|
onScrollToBottom: onLoadMore,
|
|
110
138
|
isLoading: isLoadingTemplateList,
|
|
139
|
+
validateName,
|
|
111
140
|
},
|
|
112
141
|
// Form handler
|
|
113
142
|
form,
|
package/es/constants/theme.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
1
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
2
2
|
// Types
|
|
3
3
|
import { theme } from 'antd';
|
|
4
4
|
// Variables
|
|
@@ -99,9 +99,11 @@ THEME.components = {
|
|
|
99
99
|
borderRadiusSM: 0,
|
|
100
100
|
borderRadiusOuter: 0,
|
|
101
101
|
borderRadiusXS: 0,
|
|
102
|
-
|
|
102
|
+
optionActiveBg: '#F2F9FF',
|
|
103
|
+
optionSelectedBg: (_k = THEME.token) === null || _k === void 0 ? void 0 : _k.blue1_1,
|
|
104
|
+
colorBorder: (_l = THEME.token) === null || _l === void 0 ? void 0 : _l.blue1,
|
|
103
105
|
controlItemBgActive: '#E0EBF7',
|
|
104
|
-
colorBgContainerDisabled: (
|
|
106
|
+
colorBgContainerDisabled: (_m = THEME.token) === null || _m === void 0 ? void 0 : _m.bw2,
|
|
105
107
|
fontSizeIcon: 14,
|
|
106
108
|
},
|
|
107
109
|
Tag: {
|
|
@@ -114,9 +116,9 @@ THEME.components = {
|
|
|
114
116
|
borderRadiusOuter: 0,
|
|
115
117
|
controlHeight: 30,
|
|
116
118
|
borderRadiusXS: 0,
|
|
117
|
-
colorBorder: (
|
|
119
|
+
colorBorder: (_o = THEME.token) === null || _o === void 0 ? void 0 : _o.blue1,
|
|
118
120
|
controlItemBgActive: '#E0EBF7',
|
|
119
|
-
colorBgContainerDisabled: (
|
|
121
|
+
colorBgContainerDisabled: (_p = THEME.token) === null || _p === void 0 ? void 0 : _p.bw2,
|
|
120
122
|
// fontSizeIcon: 14,
|
|
121
123
|
},
|
|
122
124
|
DatePicker: {
|
|
@@ -125,20 +127,20 @@ THEME.components = {
|
|
|
125
127
|
borderRadiusSM: 0,
|
|
126
128
|
borderRadiusOuter: 0,
|
|
127
129
|
borderRadiusXS: 0,
|
|
128
|
-
colorBorder: (
|
|
130
|
+
colorBorder: (_q = THEME.token) === null || _q === void 0 ? void 0 : _q.blue1,
|
|
129
131
|
controlItemBgActive: '#E0EBF7',
|
|
130
|
-
colorBgContainerDisabled: (
|
|
132
|
+
colorBgContainerDisabled: (_r = THEME.token) === null || _r === void 0 ? void 0 : _r.bw2,
|
|
131
133
|
fontSizeIcon: 14,
|
|
132
134
|
controlHeight: 31,
|
|
133
135
|
},
|
|
134
136
|
Divider: {
|
|
135
137
|
marginLG: 15,
|
|
136
138
|
marginXL: 15,
|
|
137
|
-
colorSplit: (
|
|
139
|
+
colorSplit: (_s = THEME.token) === null || _s === void 0 ? void 0 : _s.accent3,
|
|
138
140
|
},
|
|
139
141
|
Checkbox: {
|
|
140
142
|
controlInteractiveSize: 18,
|
|
141
|
-
colorBorder: (
|
|
143
|
+
colorBorder: (_t = THEME.token) === null || _t === void 0 ? void 0 : _t.colorPrimary,
|
|
142
144
|
lineWidth: 2,
|
|
143
145
|
},
|
|
144
146
|
Modal: {
|
|
@@ -150,7 +152,7 @@ THEME.components = {
|
|
|
150
152
|
paddingMD: 0,
|
|
151
153
|
},
|
|
152
154
|
Tabs: {
|
|
153
|
-
itemColor: (
|
|
155
|
+
itemColor: (_u = THEME.token) === null || _u === void 0 ? void 0 : _u.bw8,
|
|
154
156
|
horizontalItemPadding: '17px 30px',
|
|
155
157
|
horizontalItemGutter: 0,
|
|
156
158
|
lineWidthBold: 3,
|
|
@@ -165,18 +167,18 @@ THEME.components = {
|
|
|
165
167
|
headerPadding: '15px 10px',
|
|
166
168
|
},
|
|
167
169
|
Switch: {
|
|
168
|
-
colorTextQuaternary: (
|
|
169
|
-
colorTextTertiary: (
|
|
170
|
+
colorTextQuaternary: (_v = THEME.token) === null || _v === void 0 ? void 0 : _v.bw0,
|
|
171
|
+
colorTextTertiary: (_w = THEME.token) === null || _w === void 0 ? void 0 : _w.bw0,
|
|
170
172
|
handleSize: 12,
|
|
171
173
|
handleSizeSM: 7,
|
|
172
174
|
trackMinWidth: 30,
|
|
173
|
-
handleBg: (
|
|
175
|
+
handleBg: (_x = THEME.token) === null || _x === void 0 ? void 0 : _x.colorPrimary,
|
|
174
176
|
},
|
|
175
177
|
Menu: {
|
|
176
178
|
itemHoverBg: '#F2F9FF',
|
|
177
179
|
activeBarBorderWidth: 0,
|
|
178
180
|
},
|
|
179
181
|
Tooltip: {
|
|
180
|
-
colorBgSpotlight: (
|
|
182
|
+
colorBgSpotlight: (_y = THEME.token) === null || _y === void 0 ? void 0 : _y.bw8,
|
|
181
183
|
},
|
|
182
184
|
};
|