@antscorp/antsomi-ui 1.3.5-beta.144 → 1.3.5-beta.145

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.
@@ -178,7 +178,7 @@ export const TemplateSaveAs = props => {
178
178
  })
179
179
  : null),
180
180
  isShowShareAccess ? (React.createElement("div", { className: "share-access-container" },
181
- React.createElement(ShareAccess, Object.assign({ accessInfo: accessInfo, excludeUserAccess: ['to_editor'], generalAccessSettings: {
181
+ React.createElement(ShareAccess, Object.assign({ accessInfo: accessInfo, excludeUserAccess: ['to_editor', 'to_owner'], generalAccessSettings: {
182
182
  publicOnlyWith: true,
183
183
  }, onChange: value => handleChangeValue({ accessInfo: value }) }, shareAccessProps)))) : null))));
184
184
  };
@@ -34,7 +34,10 @@ export const TemplateSaveAsModal = props => {
34
34
  }
35
35
  };
36
36
  const handleOk = (event) => {
37
- if (onOk && (!errors || errors.length === 0)) {
37
+ var _a;
38
+ // Check form errors
39
+ const isError = ((_a = restTemplateProps.form) === null || _a === void 0 ? void 0 : _a.getFieldsError().some(field => field.errors.length)) || false;
40
+ if (onOk && (!errors || errors.length === 0) && !isError) {
38
41
  // NOTE: If there are templateValue and onChange => controlled component => return templateValue
39
42
  onOk(event, templateValue && onChange ? templateValue : internalValue);
40
43
  }
@@ -61,7 +61,7 @@ export declare const useTemplateSave: (options: TemplateListingOptions) => {
61
61
  onSearch: import("react").Dispatch<import("react").SetStateAction<string>>;
62
62
  onScrollToBottom: () => void;
63
63
  isLoading: boolean;
64
- validateName: (rule: RuleObject, value: any) => Promise<void>;
64
+ validateName: (rule: RuleObject, value: any, callback?: any) => Promise<void>;
65
65
  };
66
66
  form: import("antd").FormInstance<any>;
67
67
  errors: any[] | undefined;
@@ -96,7 +96,7 @@ export const useTemplateSave = (options) => {
96
96
  setValue(valueArg || {});
97
97
  };
98
98
  /* Validate Template Name */
99
- const validateName = (rule, value) => __awaiter(void 0, void 0, void 0, function* () {
99
+ const validateName = (rule, value, callback) => __awaiter(void 0, void 0, void 0, function* () {
100
100
  if (!value)
101
101
  return;
102
102
  const response = yield validateTemplateName({
@@ -140,7 +140,8 @@ export const useTemplateListing = (options) => {
140
140
  return undefined;
141
141
  }, [infiniteObjectTemplate, selectedTemplateId]);
142
142
  const categoryItems = useDeepCompareMemo(() => {
143
- const recursiveCategory = (categories = [], parentCategoryCode = '') => categories.map(category => {
143
+ const recursiveCategory = (categories = [], parentCategoryCode = '') => categories
144
+ .map(category => {
144
145
  const { categoryCode, categoryId, categoryName, children, total } = category;
145
146
  const key = Array.isArray(children) && children.length
146
147
  ? categoryCode
@@ -151,6 +152,13 @@ export const useTemplateListing = (options) => {
151
152
  total,
152
153
  children: recursiveCategory(children || [], categoryCode),
153
154
  };
155
+ })
156
+ .filter(category => {
157
+ // Filter category has no children and total template is 0
158
+ if (isEmpty(category.children) && !category.total) {
159
+ return false;
160
+ }
161
+ return true;
154
162
  });
155
163
  return recursiveCategory(categoryList || []);
156
164
  }, [categoryList]);
package/es/test.js CHANGED
@@ -8,10 +8,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  /* eslint-disable @typescript-eslint/no-unused-vars */
11
- import React from 'react';
11
+ import React, { useState } from 'react';
12
12
  import { createRoot } from 'react-dom/client';
13
13
  import '@antscorp/icons/main.css';
14
- import { ConfigProvider, TemplateSaveAs, useTemplateSave } from './components';
14
+ import { Button, ConfigProvider, TemplateSaveAsModal, useTemplateSave, } from './components';
15
15
  // Constants
16
16
  import { GET_LIST_TYPE, OBJECT_TYPES, PUBLIC_LEVEL } from './constants';
17
17
  // import { Slider } from 'antd';
@@ -71,7 +71,7 @@ const getUserInfos = (email) => __awaiter(void 0, void 0, void 0, function* () {
71
71
  return data;
72
72
  });
73
73
  export const App = () => {
74
- const { categoryItems, templateItems, value: templateValue, onChange: onChangeValue, searchNameProps, form, } = useTemplateSave({
74
+ const { categoryItems, templateItems, value: templateValue, onChange: onChangeTemplateValue, searchNameProps, form, } = useTemplateSave({
75
75
  service: {
76
76
  url: 'https://sandbox-media-template.antsomi.com/cdp/api/v1',
77
77
  token: '5474r2x214z254a4u2a4y444m4j5p27444c4h4h4n5t5',
@@ -89,20 +89,72 @@ export const App = () => {
89
89
  saveOption: 'save-new',
90
90
  },
91
91
  });
92
- return (React.createElement(TemplateSaveAs, { form: form, imageReview: {
93
- thumbnails,
94
- skeleton: true,
95
- }, categories: categoryItems, templateNames: templateItems, shareAccess: {
96
- show: true,
97
- userId: 1600085510,
98
- userPermission: {
99
- edit: MENU_PERMISSION.CREATED_BY_USER,
100
- view: MENU_PERMISSION.NONE,
101
- },
102
- getUserInfo: getUserInfos,
103
- }, templateNamesOptions: Object.assign({}, searchNameProps), value: templateValue, onChange: value => {
104
- onChangeValue(value);
105
- } }));
92
+ const [isOpenSaveTemplate, setIsOpenSaveTemplate] = useState(false);
93
+ return (
94
+ // <TemplateSaveAs
95
+ // form={form}
96
+ // imageReview={{
97
+ // thumbnails,
98
+ // skeleton: true,
99
+ // }}
100
+ // categories={categoryItems}
101
+ // templateNames={templateItems}
102
+ // shareAccess={{
103
+ // show: true,
104
+ // userId: 1600085510,
105
+ // userPermission: {
106
+ // edit: MENU_PERMISSION.CREATED_BY_USER,
107
+ // view: MENU_PERMISSION.NONE,
108
+ // },
109
+ // getUserInfo: getUserInfos,
110
+ // }}
111
+ // templateNamesOptions={{
112
+ // ...searchNameProps,
113
+ // }}
114
+ // value={templateValue}
115
+ // onChange={value => {
116
+ // onChangeValue(value);
117
+ // }}
118
+ // />
119
+ React.createElement(React.Fragment, null,
120
+ React.createElement(Button, { onClick: () => setIsOpenSaveTemplate(true) }, "Open Modal"),
121
+ React.createElement(TemplateSaveAsModal, { open: isOpenSaveTemplate, okButtonProps: { loading: false }, cancelButtonProps: { disabled: false },
122
+ // onCancel={() => {
123
+ // !loadingPersistTemplate && handleCancel();
124
+ // }}
125
+ onOk: (e, value) => {
126
+ console.log('e');
127
+ }, templateProps: {
128
+ form,
129
+ value: templateValue,
130
+ onChange: onChangeTemplateValue,
131
+ // onEvent: event => {
132
+ // if (event.templateName && event.templateName.id)
133
+ // setSelectedTemplate(event.templateName.id.toString());
134
+ // },
135
+ imageReview: {
136
+ thumbnails: [],
137
+ skeleton: true,
138
+ },
139
+ templateNames: templateItems,
140
+ categories: categoryItems,
141
+ omitCategories: ['device_type', 'template_type'],
142
+ shareAccess: {
143
+ // getUserInfo: email => permissionServices.getUserInfo(email, userInfo?.user_id!) as any,
144
+ show: true,
145
+ // userId: +userInfo?.user_id!,
146
+ userPermission: {
147
+ edit: MENU_PERMISSION.CREATED_BY_USER,
148
+ view: MENU_PERMISSION.CREATED_BY_USER,
149
+ },
150
+ placeholder: 'Add people',
151
+ generalAccessSettings: {
152
+ publicOnlyWith: true,
153
+ },
154
+ allowAddUser: true,
155
+ },
156
+ templateNamesOptions: Object.assign({}, searchNameProps),
157
+ } })));
106
158
  };
107
159
  const container = document.getElementById('root');
108
160
  const root = createRoot(container);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.5-beta.144",
3
+ "version": "1.3.5-beta.145",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",