@antscorp/antsomi-ui 1.3.5-beta.86 → 1.3.5-beta.88

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.
@@ -41,8 +41,8 @@ export interface TemplateSaveAsProps {
41
41
  saveOptions?: {
42
42
  saveNewText?: string;
43
43
  saveExistText?: string;
44
- saveNewValue?: string;
45
- saveExistValue?: string;
44
+ readonly saveNewValue?: string;
45
+ readonly saveExistValue?: string;
46
46
  };
47
47
  categories?: Array<{
48
48
  label: string | React.ReactNode;
@@ -27,7 +27,7 @@ export const TemplateSaveAs = props => {
27
27
  } = props;
28
28
  const { show: isShowShareAccess } = shareAccess, shareAccessProps = __rest(shareAccess, ["show"]);
29
29
  const { thumbnails, isLoading: isLoadingThumbnail, skeleton, previewNavigation, slidesPerView, hideThumbnailsList, hideDefaultButton, imageHeight, imageWidth, label: imageReviewLabel, } = imageReview;
30
- const { isLoading, label: templateLabel, defaultNewTemplateName, onSearch, onNamePopupScroll, } = templateNamesOptions || {};
30
+ const { isLoading, label: templateLabel, defaultNewTemplateName = `Untitled Media Template#${dayjs().format('YYYY-MM-DD HH:mm:ss')}`, onSearch, onNamePopupScroll, } = templateNamesOptions || {};
31
31
  const { label: descriptionLabel, placeholder: descriptionPlaceholder } = descriptionOptions || {};
32
32
  const { saveNewText = 'Save as a new media Template', saveExistText = 'Save as an existing media Template', saveNewValue = 'save-new', saveExistValue = 'save-exist', } = saveOptions || {};
33
33
  const { saveOption = saveNewValue, templateName, description: defaultTemplateDesc, defaultThumbnail = 0, categories: categoriesValue = {}, accessInfo, } = value || {};
@@ -37,7 +37,7 @@ export const TemplateSaveAs = props => {
37
37
  if (searchValueDebounce && onSearch)
38
38
  onSearch(searchValueDebounce);
39
39
  }, [searchValueDebounce, onSearch]);
40
- const [templateNameNew, setTemplateNameNew] = useState(defaultNewTemplateName || `Untitled Media Template#${dayjs().format('YYYY-MM-DD HH:mm:ss')}`);
40
+ const [templateNameNew, setTemplateNameNew] = useState(defaultNewTemplateName);
41
41
  const [templateNameExist, setTemplateNameExist] = useState((templateName === null || templateName === void 0 ? void 0 : templateName.id) ? templateName : templateNameList === null || templateNameList === void 0 ? void 0 : templateNameList[0]);
42
42
  // NOTE: HOTFIX templateNameExist not update when value outside changed
43
43
  useEffect(() => {
@@ -51,13 +51,7 @@ export const TemplateSaveAs = props => {
51
51
  onEvent(newValue);
52
52
  }
53
53
  if (onChange) {
54
- onChange(Object.assign(Object.assign(Object.assign({}, value), newValue), {
55
- // TODO: return saveOption and templateName generate default value if not pass as value props
56
- defaultThumbnail: newValue.defaultThumbnail || defaultThumbnail,
57
- // NOTE: if have no saveOption set saveOption value follow this priority => newValue >> value
58
- saveOption: !(value === null || value === void 0 ? void 0 : value.saveOption) && !newValue.saveOption
59
- ? saveOption
60
- : newValue.saveOption || (value === null || value === void 0 ? void 0 : value.saveOption) }), (_b = (_a = form === null || form === void 0 ? void 0 : form.getFieldsError()) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.errors);
54
+ onChange(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, value), (!(value === null || value === void 0 ? void 0 : value.saveOption) && { saveOption: saveNewValue })), (!(value === null || value === void 0 ? void 0 : value.templateName) && { templateName: { id: undefined, label: templateNameNew } })), (!(value === null || value === void 0 ? void 0 : value.defaultThumbnail) && { defaultThumbnail })), newValue), (_b = (_a = form === null || form === void 0 ? void 0 : form.getFieldsError()) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.errors);
61
55
  }
62
56
  };
63
57
  const handleAddCategory = ({ parentKey, item, }) => {
@@ -118,7 +118,9 @@ export const useTemplateListing = (options) => {
118
118
  // Memo
119
119
  const templateDetail = useDeepCompareMemo(() => {
120
120
  if (infiniteObjectTemplate && selectedTemplateId) {
121
- return infiniteObjectTemplate.pages[0].entities.find(template => template.id === selectedTemplateId);
121
+ return infiniteObjectTemplate.pages
122
+ .flatMap(({ entities }) => entities.flat())
123
+ .find(objectTemplate => +objectTemplate.id === +selectedTemplateId);
122
124
  }
123
125
  return undefined;
124
126
  }, [infiniteObjectTemplate, selectedTemplateId]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.5-beta.86",
3
+ "version": "1.3.5-beta.88",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",