@antscorp/antsomi-ui 1.3.5-beta.2 → 1.3.5-beta.21
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/assets/css/main.scss +0 -2
- package/es/assets/images/background/skeleton-background.png +0 -0
- package/es/assets/images/skeleton_bg.png +0 -0
- package/es/assets/svg/mobile-frame.svg +3 -0
- package/es/components/atoms/Spin/Spin.js +2 -2
- package/es/components/common/ConfigProvider/ConfigProvider.js +8 -4
- package/es/components/common/ConfigProvider/GlobalStyle.js +85 -16
- package/es/components/molecules/CalendarSelection/CalendarSelection.d.ts +3 -0
- package/es/components/molecules/CalendarSelection/CalendarSelection.js +45 -0
- package/es/components/molecules/CalendarSelection/actions.d.ts +55 -0
- package/es/components/molecules/CalendarSelection/actions.js +39 -0
- package/es/components/molecules/CalendarSelection/components/AutoUpdateTo/AutoUpdateTo.d.ts +7 -0
- package/es/components/molecules/CalendarSelection/components/AutoUpdateTo/AutoUpdateTo.js +24 -0
- package/es/components/molecules/CalendarSelection/components/AutoUpdateTo/index.d.ts +1 -0
- package/es/components/molecules/CalendarSelection/components/AutoUpdateTo/index.js +1 -0
- package/es/components/molecules/CalendarSelection/components/AutoUpdateTo/styled.d.ts +1 -0
- package/es/components/molecules/CalendarSelection/components/AutoUpdateTo/styled.js +10 -0
- package/es/components/molecules/CalendarSelection/components/CustomPicker/CustomPicker.d.ts +3 -0
- package/es/components/molecules/CalendarSelection/components/CustomPicker/CustomPicker.js +96 -0
- package/es/components/molecules/CalendarSelection/components/CustomPicker/index.d.ts +1 -0
- package/es/components/molecules/CalendarSelection/components/CustomPicker/index.js +1 -0
- package/es/components/molecules/CalendarSelection/components/CustomPicker/styled.d.ts +6 -0
- package/es/components/molecules/CalendarSelection/components/CustomPicker/styled.js +152 -0
- package/es/components/molecules/CalendarSelection/components/CustomPicker/types.d.ts +1 -0
- package/es/components/molecules/CalendarSelection/components/Footer/Footer.d.ts +2 -0
- package/es/components/molecules/CalendarSelection/components/Footer/Footer.js +11 -0
- package/es/components/molecules/CalendarSelection/components/Footer/index.d.ts +1 -0
- package/es/components/molecules/CalendarSelection/components/Footer/index.js +1 -0
- package/es/components/molecules/CalendarSelection/components/Footer/styled.d.ts +1 -0
- package/es/components/molecules/CalendarSelection/components/Footer/styled.js +6 -0
- package/es/components/molecules/CalendarSelection/components/RangePicker/RangePicker.d.ts +5 -0
- package/es/components/molecules/CalendarSelection/components/RangePicker/RangePicker.js +4 -0
- package/es/components/molecules/CalendarSelection/components/RangePicker/index.d.ts +1 -0
- package/es/components/molecules/CalendarSelection/components/RangePicker/index.js +1 -0
- package/es/components/molecules/CalendarSelection/components/RangePicker/styled.d.ts +5 -0
- package/es/components/molecules/CalendarSelection/components/RangePicker/styled.js +13 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/RangeSelectOptions.d.ts +3 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/RangeSelectOptions.js +23 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/NumOfDaysRanges/NumOfDaysRanges.d.ts +2 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/NumOfDaysRanges/NumOfDaysRanges.js +41 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/NumOfDaysRanges/index.d.ts +1 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/NumOfDaysRanges/index.js +1 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/Option/Option.d.ts +11 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/Option/Option.js +40 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/Option/index.d.ts +1 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/Option/index.js +1 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/Option/styled.d.ts +1 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/Option/styled.js +29 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/index.d.ts +2 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/index.js +2 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/index.d.ts +1 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/index.js +1 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/styled.d.ts +3 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/styled.js +34 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/types.d.ts +1 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/types.js +1 -0
- package/es/components/molecules/CalendarSelection/components/TimeRangeDisplay/TimeRangeDisplay.d.ts +8 -0
- package/es/components/molecules/CalendarSelection/components/TimeRangeDisplay/TimeRangeDisplay.js +49 -0
- package/es/components/molecules/CalendarSelection/components/TimeRangeDisplay/index.d.ts +2 -0
- package/es/components/molecules/CalendarSelection/components/TimeRangeDisplay/index.js +2 -0
- package/es/components/molecules/CalendarSelection/components/TimeRangeDisplay/styled.d.ts +1 -0
- package/es/components/molecules/CalendarSelection/components/TimeRangeDisplay/styled.js +70 -0
- package/es/components/molecules/CalendarSelection/components/index.d.ts +5 -0
- package/es/components/molecules/CalendarSelection/components/index.js +5 -0
- package/es/components/molecules/CalendarSelection/constants.d.ts +97 -0
- package/es/components/molecules/CalendarSelection/constants.js +183 -0
- package/es/components/molecules/CalendarSelection/context.d.ts +4 -0
- package/es/components/molecules/CalendarSelection/context.js +6 -0
- package/es/components/molecules/CalendarSelection/hooks/index.d.ts +2 -0
- package/es/components/molecules/CalendarSelection/hooks/index.js +2 -0
- package/es/components/molecules/CalendarSelection/hooks/useStateContext.d.ts +4 -0
- package/es/components/molecules/CalendarSelection/hooks/useStateContext.js +13 -0
- package/es/components/molecules/CalendarSelection/hooks/useTriggerOut.d.ts +9 -0
- package/es/components/molecules/CalendarSelection/hooks/useTriggerOut.js +19 -0
- package/es/components/molecules/CalendarSelection/index.d.ts +25 -0
- package/es/components/molecules/CalendarSelection/index.js +6 -0
- package/es/components/molecules/CalendarSelection/reducer.d.ts +3 -0
- package/es/components/molecules/CalendarSelection/reducer.js +121 -0
- package/es/components/molecules/CalendarSelection/styled.d.ts +6 -0
- package/es/components/molecules/CalendarSelection/styled.js +13 -0
- package/es/components/molecules/CalendarSelection/types.d.ts +97 -0
- package/es/components/molecules/CalendarSelection/types.js +1 -0
- package/es/components/molecules/CalendarSelection/utils.d.ts +52 -0
- package/es/components/molecules/CalendarSelection/utils.js +304 -0
- package/es/components/molecules/ColorPicker/CustomPicker/index.js +3 -3
- package/es/components/molecules/ColorPicker/index.d.ts +1 -0
- package/es/components/molecules/ColorPicker/index.js +3 -2
- package/es/components/molecules/DatePicker/components/AdvancedPicker/AdvancedPicker.js +24 -16
- package/es/components/molecules/DatePicker/components/AdvancedPicker/styled.d.ts +5 -0
- package/es/components/molecules/DatePicker/components/AdvancedPicker/styled.js +31 -1
- package/es/components/molecules/DatePicker/components/AdvancedPicker/utils.d.ts +1 -1
- package/es/components/molecules/DatePicker/components/AdvancedRangePicker/AdvancedRangePicker.d.ts +3 -1
- package/es/components/molecules/DatePicker/components/AdvancedRangePicker/AdvancedRangePicker.js +5 -4
- package/es/components/molecules/ModalV2/styled.js +4 -0
- package/es/components/molecules/ResizeGrid/ResizeGrid.js +10 -2
- package/es/components/molecules/ResizeGrid/types.d.ts +1 -0
- package/es/components/molecules/RichMenu/RichMenuBlock/RichMenuBlock.d.ts +1 -0
- package/es/components/molecules/RichMenu/RichMenuBlock/RichMenuBlock.js +2 -2
- package/es/components/molecules/RichMenu/RichMenuMobileView/RichMenuMobileView.d.ts +1 -0
- package/es/components/molecules/RichMenu/RichMenuMobileView/RichMenuMobileView.js +2 -2
- package/es/components/molecules/ShareAccess/components/LayoutContent/LayoutContent.js +2 -2
- package/es/components/molecules/ShareAccess/index.d.ts +2 -3
- package/es/components/molecules/ShareAccess/index.js +2 -3
- package/es/components/molecules/ShareAccess/types.d.ts +1 -0
- package/es/components/molecules/TemplateSaveAs/TemplateSaveAs.d.ts +52 -0
- package/es/components/molecules/TemplateSaveAs/TemplateSaveAs.js +144 -0
- package/es/components/molecules/TemplateSaveAs/TemplateSaveAsModal.d.ts +10 -0
- package/es/components/molecules/TemplateSaveAs/TemplateSaveAsModal.js +38 -0
- package/es/components/molecules/TemplateSaveAs/components/ImageSlider/ImageSlider.d.ts +15 -0
- package/es/components/molecules/TemplateSaveAs/components/ImageSlider/ImageSlider.js +68 -0
- package/es/components/molecules/TemplateSaveAs/components/ImageSlider/index.d.ts +1 -0
- package/es/components/molecules/TemplateSaveAs/components/ImageSlider/index.js +1 -0
- package/es/components/molecules/TemplateSaveAs/components/ImageSlider/styled.d.ts +5 -0
- package/es/components/molecules/TemplateSaveAs/components/ImageSlider/styled.js +175 -0
- package/es/components/molecules/TemplateSaveAs/components/index.d.ts +1 -0
- package/es/components/molecules/TemplateSaveAs/components/index.js +1 -0
- package/es/components/molecules/TemplateSaveAs/index.d.ts +3 -0
- package/es/components/molecules/TemplateSaveAs/index.js +2 -0
- package/es/components/molecules/TemplateSaveAs/styled.d.ts +4 -0
- package/es/components/molecules/TemplateSaveAs/styled.js +70 -0
- package/es/components/molecules/ThumbnailCard/ThumbnailCard.d.ts +3 -0
- package/es/components/molecules/ThumbnailCard/ThumbnailCard.js +72 -0
- package/es/components/molecules/ThumbnailCard/constants.d.ts +3 -0
- package/es/components/molecules/ThumbnailCard/constants.js +3 -0
- package/es/components/molecules/ThumbnailCard/index.d.ts +2 -0
- package/es/components/molecules/ThumbnailCard/index.js +2 -0
- package/es/components/molecules/ThumbnailCard/styled.d.ts +1 -0
- package/es/components/{template/TemplateListing/components/TemplateItem → molecules/ThumbnailCard}/styled.js +14 -7
- package/es/components/molecules/ThumbnailCard/types.d.ts +21 -0
- package/es/components/molecules/ThumbnailCard/types.js +1 -0
- package/es/components/molecules/UploadImage/index.js +1 -1
- package/es/components/molecules/index.d.ts +5 -0
- package/es/components/molecules/index.js +3 -0
- package/es/components/organism/Help/Help.js +23 -1
- package/es/components/organism/Menu/Menu.d.ts +2 -0
- package/es/components/organism/Menu/Menu.js +3 -0
- package/es/components/organism/Menu/index.d.ts +1 -0
- package/es/components/organism/Menu/index.js +3 -0
- package/es/components/organism/PreviewTemplateModal/components/Banner/index.d.ts +3 -0
- package/es/components/organism/PreviewTemplateModal/components/Banner/index.js +12 -0
- package/es/components/organism/PreviewTemplateModal/components/Banner/styled.d.ts +4 -0
- package/es/components/organism/PreviewTemplateModal/components/Banner/styled.js +91 -0
- package/es/components/organism/PreviewTemplateModal/components/Information/index.d.ts +3 -0
- package/es/components/organism/PreviewTemplateModal/components/Information/index.js +29 -0
- package/es/components/organism/PreviewTemplateModal/components/Information/styled.d.ts +2 -0
- package/es/components/organism/PreviewTemplateModal/components/Information/styled.js +41 -0
- package/es/components/organism/PreviewTemplateModal/components/SimilarTemplate/index.d.ts +3 -0
- package/es/components/organism/PreviewTemplateModal/components/SimilarTemplate/index.js +29 -0
- package/es/components/organism/PreviewTemplateModal/components/SimilarTemplate/styled.d.ts +2 -0
- package/es/components/organism/PreviewTemplateModal/components/SimilarTemplate/styled.js +12 -0
- package/es/components/organism/PreviewTemplateModal/components/ThumbnailSlider/index.d.ts +6 -0
- package/es/components/organism/PreviewTemplateModal/components/ThumbnailSlider/index.js +77 -0
- package/es/components/organism/PreviewTemplateModal/components/ThumbnailSlider/styled.d.ts +3 -0
- package/es/components/organism/PreviewTemplateModal/components/ThumbnailSlider/styled.js +62 -0
- package/es/components/organism/PreviewTemplateModal/components/index.d.ts +4 -0
- package/es/components/organism/PreviewTemplateModal/components/index.js +4 -0
- package/es/components/organism/PreviewTemplateModal/constants/dataSample.d.ts +2 -0
- package/es/components/organism/PreviewTemplateModal/constants/dataSample.js +9 -0
- package/es/components/organism/PreviewTemplateModal/constants/defaultProps.d.ts +8 -0
- package/es/components/organism/PreviewTemplateModal/constants/defaultProps.js +11 -0
- package/es/components/organism/PreviewTemplateModal/constants/index.d.ts +3 -0
- package/es/components/organism/PreviewTemplateModal/constants/index.js +3 -0
- package/es/components/organism/PreviewTemplateModal/constants/variables.d.ts +12 -0
- package/es/components/organism/PreviewTemplateModal/constants/variables.js +12 -0
- package/es/components/organism/PreviewTemplateModal/index.d.ts +3 -0
- package/es/components/organism/PreviewTemplateModal/index.js +34 -0
- package/es/components/organism/PreviewTemplateModal/styled.d.ts +4 -0
- package/es/components/organism/PreviewTemplateModal/styled.js +26 -0
- package/es/components/organism/PreviewTemplateModal/types.d.ts +39 -0
- package/es/components/organism/PreviewTemplateModal/types.js +1 -0
- package/es/components/organism/index.d.ts +1 -0
- package/es/components/organism/index.js +1 -0
- package/es/components/template/TemplateListing/Loadable.d.ts +6 -0
- package/es/components/template/TemplateListing/Loadable.js +7 -0
- package/es/components/template/TemplateListing/components/BlankTemplate/index.js +9 -7
- package/es/components/template/TemplateListing/components/BlankTemplate/styled.js +2 -0
- package/es/components/template/TemplateListing/components/CategoryListing/index.js +19 -10
- package/es/components/template/TemplateListing/components/CategoryListing/styled.d.ts +2 -0
- package/es/components/template/TemplateListing/components/CategoryListing/styled.js +44 -7
- package/es/components/template/TemplateListing/components/CategoryListing/types.d.ts +2 -1
- package/es/components/template/TemplateListing/components/Empty/index.d.ts +3 -0
- package/es/components/template/TemplateListing/components/Empty/index.js +18 -0
- package/es/components/template/TemplateListing/components/Empty/styled.d.ts +3 -0
- package/es/components/template/TemplateListing/components/Empty/styled.js +35 -0
- package/es/components/template/TemplateListing/components/index.d.ts +1 -1
- package/es/components/template/TemplateListing/components/index.js +1 -1
- package/es/components/template/TemplateListing/constants/defaultProps.d.ts +8 -4
- package/es/components/template/TemplateListing/constants/defaultProps.js +9 -6
- package/es/components/template/TemplateListing/hooks/index.d.ts +1 -0
- package/es/components/template/TemplateListing/hooks/index.js +1 -0
- package/es/components/template/TemplateListing/hooks/useTemplateListing.d.ts +62 -0
- package/es/components/template/TemplateListing/hooks/useTemplateListing.js +206 -0
- package/es/components/template/TemplateListing/index.js +77 -13
- package/es/components/template/TemplateListing/styled/index.d.ts +2 -0
- package/es/components/template/TemplateListing/styled/index.js +29 -5
- package/es/components/template/TemplateListing/types/BlankTemplate.d.ts +3 -2
- package/es/components/template/TemplateListing/types/CategoryListing.d.ts +5 -2
- package/es/components/template/TemplateListing/types/Empty.d.ts +5 -0
- package/es/components/template/TemplateListing/types/Empty.js +1 -0
- package/es/components/template/TemplateListing/types/TemplateListing.d.ts +20 -9
- package/es/components/template/TemplateListing/types/index.d.ts +0 -1
- package/es/components/template/TemplateListing/types/index.js +0 -1
- package/es/components/template/index.d.ts +2 -1
- package/es/components/template/index.js +5 -1
- package/es/constants/datetime.d.ts +8 -0
- package/es/constants/datetime.js +1594 -0
- package/es/constants/index.d.ts +4 -1
- package/es/constants/index.js +4 -1
- package/es/constants/queries.d.ts +3 -0
- package/es/constants/queries.js +4 -0
- package/es/constants/templateListing.d.ts +58 -0
- package/es/constants/templateListing.js +58 -0
- package/es/hooks/index.d.ts +4 -0
- package/es/hooks/index.js +4 -0
- package/es/hooks/useEffectOnlyOnce.d.ts +2 -0
- package/es/hooks/useEffectOnlyOnce.js +12 -0
- package/es/hooks/useForceUpdate.d.ts +1 -0
- package/es/hooks/useForceUpdate.js +5 -0
- package/es/hooks/useIntersectionObserver.d.ts +57 -0
- package/es/hooks/useIntersectionObserver.js +97 -0
- package/es/hooks/useListingItemResize.d.ts +12 -0
- package/es/hooks/useListingItemResize.js +58 -0
- package/es/hooks/useScrollToEnd.d.ts +1 -0
- package/es/hooks/useScrollToEnd.js +30 -0
- package/es/index.d.ts +2 -0
- package/es/index.js +2 -0
- package/es/locales/en/translation.json +11 -3
- package/es/locales/i18n.d.ts +16 -0
- package/es/locales/translations.d.ts +8 -0
- package/es/locales/vi/translation.json +9 -1
- package/es/models/ObjectTemplate.d.ts +53 -0
- package/es/models/ObjectTemplate.js +80 -0
- package/es/models/TemplateCategory.d.ts +13 -0
- package/es/models/TemplateCategory.js +28 -0
- package/es/queries/TemplateListing/index.d.ts +47 -0
- package/es/queries/TemplateListing/index.js +93 -0
- package/es/queries/index.d.ts +1 -0
- package/es/queries/index.js +1 -0
- package/es/services/TemplateListing/index.d.ts +64 -0
- package/es/services/TemplateListing/index.js +149 -0
- package/es/test.js +62 -11
- package/es/types/index.d.ts +4 -0
- package/es/types/index.js +2 -0
- package/es/types/service.d.ts +22 -0
- package/es/types/service.js +1 -0
- package/es/types/templateListing.d.ts +11 -0
- package/es/types/templateListing.js +1 -0
- package/es/utils/common.d.ts +2 -0
- package/es/utils/common.js +12 -0
- package/package.json +6 -1
- package/es/components/template/TemplateListing/components/TemplateItem/index.d.ts +0 -3
- package/es/components/template/TemplateListing/components/TemplateItem/index.js +0 -53
- package/es/components/template/TemplateListing/components/TemplateItem/styled.d.ts +0 -1
- package/es/components/template/TemplateListing/types/TemplateItem.d.ts +0 -14
- /package/es/components/{template/TemplateListing/types/TemplateItem.js → molecules/CalendarSelection/components/CustomPicker/types.js} +0 -0
|
@@ -34,7 +34,7 @@ const defaultProps = {
|
|
|
34
34
|
selectColor: '#2f79bf80',
|
|
35
35
|
};
|
|
36
36
|
export const ResizeGrid = props => {
|
|
37
|
-
const { containerStyle, cellBorder, cellStyle, cellActiveStyle, isPreview, renderCell, grid: initGrid, image, imageSize, imagePosition, isCompact, onChange, delayUpdate, selectColor, } = props;
|
|
37
|
+
const { containerStyle, cellBorder, cellStyle, cellActiveStyle, isPreview, renderCell, grid: initGrid, image, imageSize, imagePosition, isCompact, onChange, delayUpdate, selectColor, reCalculateFlag, } = props;
|
|
38
38
|
const [grid, setGrid] = useState(buildGrid(initGrid || GRID_TEMPLATE.GRID_2_3));
|
|
39
39
|
const startRef = useRef(null);
|
|
40
40
|
const startCellRef = useRef(null);
|
|
@@ -106,7 +106,7 @@ export const ResizeGrid = props => {
|
|
|
106
106
|
useEffect(() => {
|
|
107
107
|
handleChangeGrid();
|
|
108
108
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
109
|
-
}, [grid]);
|
|
109
|
+
}, [grid, reCalculateFlag]);
|
|
110
110
|
useDeepCompareEffect(() => {
|
|
111
111
|
// console.log('changed grid', initGrid, acceptUpdateRef.current, initGrid?.rows, initGrid?.cols)
|
|
112
112
|
// console.log(initRef.current < 2,!initDoneRef.current, acceptUpdateRef.current)
|
|
@@ -560,11 +560,15 @@ export const ResizeGrid = props => {
|
|
|
560
560
|
};
|
|
561
561
|
const downSelect = (idx, cell) => {
|
|
562
562
|
// console.log('dow select', idx, cell);
|
|
563
|
+
if (isPreview)
|
|
564
|
+
return;
|
|
563
565
|
!cell.active && activeCell({ idx });
|
|
564
566
|
selectRef.current = { idx, cell };
|
|
565
567
|
gridRef.current = grid;
|
|
566
568
|
};
|
|
567
569
|
const unMerge = (cell, idx) => {
|
|
570
|
+
if (isPreview)
|
|
571
|
+
return;
|
|
568
572
|
const { colStart, colEnd, rowStart, rowEnd } = cell;
|
|
569
573
|
if (colStart + 1 === colEnd && rowStart + 1 === rowEnd) {
|
|
570
574
|
return;
|
|
@@ -604,6 +608,8 @@ export const ResizeGrid = props => {
|
|
|
604
608
|
});
|
|
605
609
|
}
|
|
606
610
|
const upSelect = (idx, cell) => {
|
|
611
|
+
if (isPreview)
|
|
612
|
+
return;
|
|
607
613
|
// console.log('up select', idx, cell);
|
|
608
614
|
if (selectRef.current &&
|
|
609
615
|
selectEndRef.current &&
|
|
@@ -634,6 +640,8 @@ export const ResizeGrid = props => {
|
|
|
634
640
|
selectEndRef.current = null;
|
|
635
641
|
};
|
|
636
642
|
const hoverSelect = (idx, cell) => {
|
|
643
|
+
if (isPreview)
|
|
644
|
+
return;
|
|
637
645
|
if (selectRef.current && gridRef.current) {
|
|
638
646
|
// console.log('hover select', idx, cell);
|
|
639
647
|
const { cell: cellStart, idx: idxStart } = selectRef.current;
|
|
@@ -9,5 +9,6 @@ export interface RichMenuBlockProps {
|
|
|
9
9
|
cellActiveIdx?: number;
|
|
10
10
|
onClickCell?: (cellIdx: number) => void;
|
|
11
11
|
onChange?: (richMenu: RichMenu, source?: 'user' | 'system') => void;
|
|
12
|
+
reCalculateFlag?: boolean | number;
|
|
12
13
|
}
|
|
13
14
|
export declare const RichMenuBlock: React.FC<RichMenuBlockProps>;
|
|
@@ -8,7 +8,7 @@ import { RichMenuCell } from './RichMenuCell';
|
|
|
8
8
|
import { tryCatchWrapper } from '@antscorp/antsomi-ui/es/utils';
|
|
9
9
|
const PATH = 'src/app/modules/Dashboard/containers/RichMenu/containers/Design/components/Workspace/components/RichMenuBlock/index.tsx';
|
|
10
10
|
export const RichMenuBlock = props => {
|
|
11
|
-
const { richMenu, layerActive, cellActiveIdx, isPreview, isActionLink = false, onClickCell, onChange, } = props;
|
|
11
|
+
const { richMenu, layerActive, cellActiveIdx, isPreview, isActionLink = false, onClickCell, onChange, reCalculateFlag, } = props;
|
|
12
12
|
const { gridTemplateCols = [], gridTemplateRows = [], cells = [], uploadMode, image, layoutType, rows, cols, } = richMenu || {};
|
|
13
13
|
const { imageUrl, imageStyles } = image || {};
|
|
14
14
|
const grid = {
|
|
@@ -45,7 +45,7 @@ export const RichMenuBlock = props => {
|
|
|
45
45
|
}
|
|
46
46
|
}, PATH);
|
|
47
47
|
const renderCell = (cellInfo, ctx) => (React.createElement(RichMenuCell, { context: ctx, isActionLink: isActionLink, isPreview: isPreview, layerActive: layerActive, cellActiveIdx: cellActiveIdx, cell: cellInfo, isSingleMode: isSingleUploadMode, onClick: handleClickCell }));
|
|
48
|
-
return (React.createElement(ResizeGrid, Object.assign({ grid: grid, isPreview: isPreview, containerStyle: imageStyles, isCompact: layoutType === 'compact', renderCell: renderCell, cellActiveStyle: { background: 'rgba(0, 95, 184, 0.5)' }, cellBorder: isSingleUploadMode ? '1px solid rgba(0, 95, 184, 1)' : '1px dotted #000000', onChange: handleGridChange }, Object.assign({}, (isSingleUploadMode && {
|
|
48
|
+
return (React.createElement(ResizeGrid, Object.assign({ grid: grid, isPreview: isPreview, containerStyle: imageStyles, isCompact: layoutType === 'compact', renderCell: renderCell, cellActiveStyle: { background: 'rgba(0, 95, 184, 0.5)' }, cellBorder: isSingleUploadMode ? '1px solid rgba(0, 95, 184, 1)' : '1px dotted #000000', onChange: handleGridChange, reCalculateFlag: reCalculateFlag }, Object.assign({}, (isSingleUploadMode && {
|
|
49
49
|
image: imageUrl,
|
|
50
50
|
imagePosition: imageStyles === null || imageStyles === void 0 ? void 0 : imageStyles.objectPosition,
|
|
51
51
|
imageSize: imageStyles === null || imageStyles === void 0 ? void 0 : imageStyles.objectFit,
|
|
@@ -5,6 +5,7 @@ interface RichMenuMobileViewProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
5
5
|
isPreview?: boolean;
|
|
6
6
|
onChangeRichMenu?: (richMenu: RichMenu, source?: 'user' | 'system') => void;
|
|
7
7
|
onClickCell?: (cellIndex: number) => void;
|
|
8
|
+
reCalculateFlag?: boolean | number;
|
|
8
9
|
}
|
|
9
10
|
export declare const RichMenuMobileView: React.FC<RichMenuMobileViewProps>;
|
|
10
11
|
export {};
|
|
@@ -20,7 +20,7 @@ import { RichMenuBlock } from '../RichMenuBlock';
|
|
|
20
20
|
// Styles
|
|
21
21
|
import { MobileContent, RichMenuWrapper, TopBar } from './styled';
|
|
22
22
|
export const RichMenuMobileView = props => {
|
|
23
|
-
const { richMenu, className, isPreview, onChangeRichMenu, onClickCell } = props, restOfProps = __rest(props, ["richMenu", "className", "isPreview", "onChangeRichMenu", "onClickCell"]);
|
|
23
|
+
const { richMenu, className, isPreview, onChangeRichMenu, onClickCell, reCalculateFlag } = props, restOfProps = __rest(props, ["richMenu", "className", "isPreview", "onChangeRichMenu", "onClickCell", "reCalculateFlag"]);
|
|
24
24
|
// State
|
|
25
25
|
const [state, setState] = useState({
|
|
26
26
|
showRichMenu: true,
|
|
@@ -32,6 +32,6 @@ export const RichMenuMobileView = props => {
|
|
|
32
32
|
return (React.createElement(MobileFrame, Object.assign({ className: `ants-mx-auto ${className}` }, restOfProps),
|
|
33
33
|
isPreview && React.createElement(TopBar, { src: IphoneTopBar, width: "100%", height: "auto" }),
|
|
34
34
|
React.createElement(MobileContent, null,
|
|
35
|
-
React.createElement(RichMenuWrapper, { "$showRichMenu": showRichMenu && !showTypingChat, "$isPreview": !!isPreview }, richMenu && (React.createElement(RichMenuBlock, { richMenu: richMenu, isPreview: isPreview, onChange: onChangeRichMenu, onClickCell: onClickCell }))),
|
|
35
|
+
React.createElement(RichMenuWrapper, { "$showRichMenu": showRichMenu && !showTypingChat, "$isPreview": !!isPreview }, richMenu && (React.createElement(RichMenuBlock, { richMenu: richMenu, isPreview: isPreview, onChange: onChangeRichMenu, onClickCell: onClickCell, reCalculateFlag: reCalculateFlag }))),
|
|
36
36
|
React.createElement(RichMenuChatBar, { disabled: !isPreview, label: richMenu === null || richMenu === void 0 ? void 0 : richMenu.chatBar.label, showRichMenu: showRichMenu, showTypingChat: showTypingChat, onToggleRichMenu: showRichMenu => setState(prevState => (Object.assign(Object.assign({}, prevState), { showRichMenu: !!showRichMenu }))), onToggleTypingChat: showTypingChat => setState(prevState => (Object.assign(Object.assign({}, prevState), { showTypingChat: !!showTypingChat }))) }))));
|
|
37
37
|
};
|
|
@@ -6,13 +6,13 @@ import { PeopleAccess } from '../PeopleAccess';
|
|
|
6
6
|
import { SearchUser } from '../SearchUser';
|
|
7
7
|
import { StyledLayoutContentRoot } from './styled';
|
|
8
8
|
export const LayoutContent = (props) => {
|
|
9
|
-
const { getUserInfo, allowChangeOnwership = true } = props;
|
|
9
|
+
const { getUserInfo, allowChangeOnwership = true, allowAddUser = true } = props;
|
|
10
10
|
const { state } = useShareAccess();
|
|
11
11
|
const { allowEdit, allowView } = state;
|
|
12
12
|
if (!allowEdit && !allowView)
|
|
13
13
|
return null;
|
|
14
14
|
return (React.createElement(StyledLayoutContentRoot, null,
|
|
15
|
-
React.createElement(SearchUser, { getUserInfo: getUserInfo }),
|
|
15
|
+
allowAddUser && React.createElement(SearchUser, { getUserInfo: getUserInfo }),
|
|
16
16
|
React.createElement(PeopleAccess, { allowChangeOnwership: allowChangeOnwership }),
|
|
17
17
|
React.createElement(GeneralAccess, null),
|
|
18
18
|
React.createElement(ModalTransferOwnership, null)));
|
|
@@ -33,6 +33,7 @@ export type ShareAccessProps = {
|
|
|
33
33
|
view: number;
|
|
34
34
|
};
|
|
35
35
|
accessInfo?: ObjectAccessInfo;
|
|
36
|
+
allowAddUser?: boolean;
|
|
36
37
|
allowChangeOnwership?: boolean;
|
|
37
38
|
getUserInfo?(search: string, signal: AbortSignal): Promise<UserInfo[]> | UserInfo[];
|
|
38
39
|
onChange?: (accessInfo: ObjectAccessInfo) => void;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ShareAccessProps } from '../ShareAccess/types';
|
|
3
|
+
type categoriesProps = Array<{
|
|
4
|
+
label: string;
|
|
5
|
+
key: string | number;
|
|
6
|
+
children: Array<{
|
|
7
|
+
label: string;
|
|
8
|
+
key: string | number;
|
|
9
|
+
}>;
|
|
10
|
+
}>;
|
|
11
|
+
export interface TemplateValueOptions {
|
|
12
|
+
saveOption?: string;
|
|
13
|
+
templateName?: {
|
|
14
|
+
id?: string | number;
|
|
15
|
+
label?: string;
|
|
16
|
+
};
|
|
17
|
+
templateDesc?: string;
|
|
18
|
+
defaultThumbnail?: number;
|
|
19
|
+
categories?: categoriesProps;
|
|
20
|
+
accessInfo?: ShareAccessProps['accessInfo'];
|
|
21
|
+
}
|
|
22
|
+
export interface ImagePreviewOptions {
|
|
23
|
+
thumbnails: (string | undefined)[];
|
|
24
|
+
skeleton?: boolean;
|
|
25
|
+
previewNavigation?: boolean;
|
|
26
|
+
slidesPerView?: number;
|
|
27
|
+
}
|
|
28
|
+
export interface TemplateSaveAsProps {
|
|
29
|
+
className?: string;
|
|
30
|
+
shareAccess: Omit<{
|
|
31
|
+
show: boolean;
|
|
32
|
+
} & ShareAccessProps, 'accessInfo' | 'onChange'>;
|
|
33
|
+
imageReview: ImagePreviewOptions;
|
|
34
|
+
saveOptions?: {
|
|
35
|
+
saveNewText?: string;
|
|
36
|
+
saveExistText?: string;
|
|
37
|
+
saveNewValue?: string;
|
|
38
|
+
saveExistValue?: string;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Default thumbnail - order of default thumbnail in thumbnails array
|
|
42
|
+
*/
|
|
43
|
+
categories?: categoriesProps;
|
|
44
|
+
templateNames: Array<{
|
|
45
|
+
label: string;
|
|
46
|
+
id: string | number;
|
|
47
|
+
}>;
|
|
48
|
+
value?: TemplateValueOptions;
|
|
49
|
+
onChange?: (value: Partial<TemplateValueOptions>) => void;
|
|
50
|
+
}
|
|
51
|
+
export declare const TemplateSaveAs: React.FC<TemplateSaveAsProps>;
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
// Libraries
|
|
13
|
+
import React, { useState } from 'react';
|
|
14
|
+
import { Dropdown } from 'antd';
|
|
15
|
+
import dayjs from 'dayjs';
|
|
16
|
+
// Components
|
|
17
|
+
import { Button, Flex, Input, Typography, Select, ShareAccess, RadioGroup, Radio, } from '@antscorp/antsomi-ui/es/components';
|
|
18
|
+
// Styles
|
|
19
|
+
import { TemplateSaveAsStyled } from './styled';
|
|
20
|
+
import { ImageSlider } from './components';
|
|
21
|
+
const { Text } = Typography;
|
|
22
|
+
export const TemplateSaveAs = props => {
|
|
23
|
+
const { className, shareAccess, saveOptions, imageReview, categories, templateNames, value, onChange, } = props;
|
|
24
|
+
const { show: isShowShareAccess } = shareAccess, shareAccessProps = __rest(shareAccess, ["show"]);
|
|
25
|
+
const { thumbnails, skeleton, previewNavigation, slidesPerView } = imageReview;
|
|
26
|
+
const { saveNewText = 'Save as a new media Template', saveExistText = 'Save as an existing media Template', saveNewValue = 'save-new', saveExistValue = 'save-exist', } = saveOptions || {};
|
|
27
|
+
const { saveOption = saveNewValue, templateName: defaultTemplateName, templateDesc: defaultTemplateDesc, defaultThumbnail = 0, categories: categoriesValue = [], accessInfo, } = value || {};
|
|
28
|
+
const [templateName, setTemplateName] = useState(`Untitled Media Template#${dayjs().format('YYYY-MM-DD HH:mm:ss')}`);
|
|
29
|
+
const [templateNameExist, setTemplateNameExist] = useState((defaultTemplateName === null || defaultTemplateName === void 0 ? void 0 : defaultTemplateName.id) ? defaultTemplateName : templateNames === null || templateNames === void 0 ? void 0 : templateNames[0]);
|
|
30
|
+
const handleChangeValue = (newValue) => {
|
|
31
|
+
if (onChange) {
|
|
32
|
+
onChange(Object.assign(Object.assign(Object.assign({}, value), newValue), {
|
|
33
|
+
// TODO: return saveOption and templateName generate default value if not pass as value props
|
|
34
|
+
saveOption: !(value === null || value === void 0 ? void 0 : value.saveOption) && !newValue.saveOption
|
|
35
|
+
? saveOption
|
|
36
|
+
: newValue.saveOption || (value === null || value === void 0 ? void 0 : value.saveOption), templateName: !defaultTemplateName && !newValue.templateName
|
|
37
|
+
? saveOption === saveNewValue
|
|
38
|
+
? { id: undefined, label: templateName }
|
|
39
|
+
: templateNameExist
|
|
40
|
+
: newValue.templateName || defaultTemplateName }));
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const handleAddCategory = ({ parent, parentKey, item, }) => {
|
|
44
|
+
const currCategory = categoriesValue.find(category => category.label === parent);
|
|
45
|
+
if (currCategory) {
|
|
46
|
+
currCategory.children.push(item);
|
|
47
|
+
const newCategoryList = categoriesValue.filter(item => item.label !== currCategory.label);
|
|
48
|
+
const newCategory = [...newCategoryList, currCategory];
|
|
49
|
+
handleChangeValue({ categories: newCategory });
|
|
50
|
+
}
|
|
51
|
+
const newCategory = [...categoriesValue, { label: parent, key: parentKey, children: [item] }];
|
|
52
|
+
handleChangeValue({ categories: newCategory });
|
|
53
|
+
};
|
|
54
|
+
const handleRemoveCategory = ({ parent, item }) => {
|
|
55
|
+
const currCategory = categoriesValue.find(category => category.label === parent);
|
|
56
|
+
if (!currCategory)
|
|
57
|
+
return;
|
|
58
|
+
const newChildren = currCategory.children.filter(child => child.label !== item.label);
|
|
59
|
+
const newCategoryList = categoriesValue.filter(child => child.label !== currCategory.label);
|
|
60
|
+
handleChangeValue({
|
|
61
|
+
categories: [...newCategoryList, Object.assign(Object.assign({}, currCategory), { children: newChildren })],
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
return (React.createElement(TemplateSaveAsStyled, { className: className || '', vertical: true },
|
|
65
|
+
React.createElement(Flex, { className: "save-options-container" },
|
|
66
|
+
React.createElement(RadioGroup, { value: saveOption, onChange: e => handleChangeValue({
|
|
67
|
+
saveOption: e.target.value,
|
|
68
|
+
templateName: e.target.value === saveNewValue
|
|
69
|
+
? { id: undefined, label: templateName }
|
|
70
|
+
: templateNameExist,
|
|
71
|
+
}) },
|
|
72
|
+
React.createElement(Radio, { value: saveNewValue }, saveNewText),
|
|
73
|
+
React.createElement(Radio, { value: saveExistValue }, saveExistText))),
|
|
74
|
+
React.createElement(Flex, null,
|
|
75
|
+
React.createElement(Flex, { vertical: true, gap: 20, className: "template-container" },
|
|
76
|
+
React.createElement(Flex, { className: "field-container" },
|
|
77
|
+
React.createElement(Text, { className: "field-title field-title--middle" },
|
|
78
|
+
"Template name ",
|
|
79
|
+
React.createElement("span", null, " *")),
|
|
80
|
+
saveOption === saveNewValue ? (React.createElement(Input, { debounce: 1000, className: "field-input", value: templateName, onAfterChange: value => {
|
|
81
|
+
handleChangeValue({ templateName: { id: undefined, label: value } });
|
|
82
|
+
setTemplateName(value);
|
|
83
|
+
}, required: true })) : (React.createElement(Select, { className: "field-input", value: templateNameExist === null || templateNameExist === void 0 ? void 0 : templateNameExist.id, options: (templateNames === null || templateNames === void 0 ? void 0 : templateNames.length) > 0
|
|
84
|
+
? templateNames.map(item => ({ value: item.id, label: item.label }))
|
|
85
|
+
: [], onChange: value => {
|
|
86
|
+
var _a, _b;
|
|
87
|
+
handleChangeValue({
|
|
88
|
+
templateName: {
|
|
89
|
+
id: value,
|
|
90
|
+
label: ((_a = templateNames.find(item => item.id === value)) === null || _a === void 0 ? void 0 : _a.label) || '',
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
setTemplateNameExist({
|
|
94
|
+
id: value,
|
|
95
|
+
label: ((_b = templateNames.find(item => item.id === value)) === null || _b === void 0 ? void 0 : _b.label) || '',
|
|
96
|
+
});
|
|
97
|
+
} }))),
|
|
98
|
+
React.createElement(Flex, { className: "field-container" },
|
|
99
|
+
React.createElement(Text, { className: "field-title field-title--middle" }, "Description"),
|
|
100
|
+
React.createElement(Input, { placeholder: "Describe your media template", className: "field-input", value: defaultTemplateDesc, debounce: 1000, onAfterChange: value => handleChangeValue({ templateDesc: value }) })),
|
|
101
|
+
React.createElement(Flex, { className: "field-container" },
|
|
102
|
+
React.createElement(Text, { className: "field-title" },
|
|
103
|
+
"Thumbnail template ",
|
|
104
|
+
React.createElement("span", null, "*")),
|
|
105
|
+
React.createElement(ImageSlider, { thumbnails: thumbnails, skeleton: skeleton, previewNavigation: previewNavigation, slidesPerView: slidesPerView, defaultThumbnail: defaultThumbnail, onSelectDefault: value => handleChangeValue({ defaultThumbnail: value }) })), categories === null || categories === void 0 ? void 0 :
|
|
106
|
+
categories.map(parentCategory => {
|
|
107
|
+
var _a, _b;
|
|
108
|
+
const selectedChildren = (_a = categoriesValue
|
|
109
|
+
.find(item => item.label === parentCategory.label)) === null || _a === void 0 ? void 0 : _a.children.map(item => item.label);
|
|
110
|
+
const remainChildren = parentCategory.children.filter(item => !(selectedChildren === null || selectedChildren === void 0 ? void 0 : selectedChildren.includes(item.label)));
|
|
111
|
+
const formatData = remainChildren.map((item, idx) => ({
|
|
112
|
+
label: item.label,
|
|
113
|
+
key: idx,
|
|
114
|
+
}));
|
|
115
|
+
return (React.createElement(Flex, { key: parentCategory.label, className: "field-container" },
|
|
116
|
+
React.createElement(Text, { className: "field-title" }, parentCategory.label),
|
|
117
|
+
React.createElement(Flex, { wrap: "wrap", gap: 10, className: "category-container" },
|
|
118
|
+
/* selectedCategory */
|
|
119
|
+
(_b = categoriesValue
|
|
120
|
+
.find(item => item.label === parentCategory.label)) === null || _b === void 0 ? void 0 :
|
|
121
|
+
_b.children.map(selectedItem => (React.createElement(Flex, { key: selectedItem.label, className: "selected-category", justify: "space-between", align: "center" },
|
|
122
|
+
React.createElement(Text, null, selectedItem.label),
|
|
123
|
+
' ',
|
|
124
|
+
React.createElement("span", { className: "remove-btn", onClick: () => handleRemoveCategory({
|
|
125
|
+
parent: parentCategory.label,
|
|
126
|
+
item: selectedItem,
|
|
127
|
+
}) }, "\u00D7")))),
|
|
128
|
+
React.createElement(Dropdown, { menu: {
|
|
129
|
+
items: formatData,
|
|
130
|
+
onClick: ({ key }) => {
|
|
131
|
+
handleAddCategory({
|
|
132
|
+
parent: parentCategory.label,
|
|
133
|
+
parentKey: parentCategory.key,
|
|
134
|
+
item: remainChildren[key],
|
|
135
|
+
});
|
|
136
|
+
},
|
|
137
|
+
}, getPopupContainer: triggerNode => triggerNode.parentElement, trigger: ['click'] },
|
|
138
|
+
React.createElement(Button, null,
|
|
139
|
+
"+ Add ",
|
|
140
|
+
parentCategory.label.toLowerCase())))));
|
|
141
|
+
})),
|
|
142
|
+
isShowShareAccess ? (React.createElement("div", { className: "share-access-container" },
|
|
143
|
+
React.createElement(ShareAccess, Object.assign({ accessInfo: accessInfo, onChange: value => handleChangeValue({ accessInfo: value }) }, shareAccessProps)))) : null)));
|
|
144
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ModalV2Props } from '../ModalV2';
|
|
3
|
+
import { TemplateSaveAsProps, TemplateValueOptions } from './TemplateSaveAs';
|
|
4
|
+
interface TemplateSaveAsModalProps extends ModalV2Props {
|
|
5
|
+
templateProps: TemplateSaveAsProps;
|
|
6
|
+
defaultValue?: TemplateValueOptions;
|
|
7
|
+
onOk?: (e: React.MouseEvent<HTMLButtonElement>, value?: TemplateValueOptions) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const TemplateSaveAsModal: React.FC<TemplateSaveAsModalProps>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import React, { useState } from 'react';
|
|
13
|
+
import { ModalV2 } from '../ModalV2';
|
|
14
|
+
import { TemplateSaveAs } from './TemplateSaveAs';
|
|
15
|
+
// NOTE: helper link (read more about controlled and uncontrolled component)
|
|
16
|
+
// Inspiration form input component https://react.dev/reference/react-dom/components/input
|
|
17
|
+
export const TemplateSaveAsModal = props => {
|
|
18
|
+
const { open, onCancel, okText, onOk, title, templateProps, defaultValue } = props, restProps = __rest(props, ["open", "onCancel", "okText", "onOk", "title", "templateProps", "defaultValue"]);
|
|
19
|
+
const { onChange: templateOnChange, value: templateValue } = templateProps, restTemplateProps = __rest(templateProps, ["onChange", "value"]);
|
|
20
|
+
const [internalValue, setInternalValue] = useState(defaultValue || templateValue);
|
|
21
|
+
const handleOnChange = (value) => {
|
|
22
|
+
if (templateOnChange) {
|
|
23
|
+
templateOnChange(value);
|
|
24
|
+
}
|
|
25
|
+
// NOTE: If there are no templateValue and templateOnChange => uncontrolled component => return templateValue
|
|
26
|
+
if (defaultValue && !templateValue && !templateOnChange) {
|
|
27
|
+
setInternalValue(value);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const handleOk = (event) => {
|
|
31
|
+
if (onOk) {
|
|
32
|
+
// NOTE: If there are templateValue and templateOnChange => controlled component => return templateValue
|
|
33
|
+
onOk(event, templateValue && templateOnChange ? templateValue : internalValue);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
return (React.createElement(ModalV2, Object.assign({ open: open, onCancel: onCancel, onOk: handleOk, okText: okText || 'Save', width: 1177, title: title || 'Save as my template' }, restProps),
|
|
37
|
+
React.createElement(TemplateSaveAs, Object.assign({ onChange: handleOnChange, value: templateValue || internalValue }, restTemplateProps))));
|
|
38
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface ImageSliderProps {
|
|
3
|
+
thumbnails: (string | undefined)[];
|
|
4
|
+
className?: string;
|
|
5
|
+
skeleton?: boolean;
|
|
6
|
+
previewNavigation?: boolean;
|
|
7
|
+
slidesPerView?: number;
|
|
8
|
+
/**
|
|
9
|
+
* Default thumbnail - order of default thumbnail in thumbnails array
|
|
10
|
+
*/
|
|
11
|
+
defaultThumbnail?: number;
|
|
12
|
+
onSelectDefault?: (imgIndex: number) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare const ImageSlider: React.FC<ImageSliderProps>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// Libraries
|
|
2
|
+
import React, { useState, useRef } from 'react';
|
|
3
|
+
import { Image } from 'antd';
|
|
4
|
+
import Icon from '@antscorp/icons';
|
|
5
|
+
// Components
|
|
6
|
+
import { Button, Flex } from '@antscorp/antsomi-ui/es/components';
|
|
7
|
+
// Styles
|
|
8
|
+
import { ImageSliderStyled } from './styled';
|
|
9
|
+
import clsx from 'clsx';
|
|
10
|
+
export const ImageSlider = props => {
|
|
11
|
+
var _a, _b;
|
|
12
|
+
const { thumbnails, className, skeleton, previewNavigation, slidesPerView = 3, defaultThumbnail, onSelectDefault, } = props;
|
|
13
|
+
console.log('🚀 ~ ImageSlider ~ thumbnails:', thumbnails);
|
|
14
|
+
const sliderContainerRef = useRef(null);
|
|
15
|
+
const thumbnailSelectedRef = useRef(null);
|
|
16
|
+
const [selectedThumbnail, setSelectedThumbnail] = useState(0);
|
|
17
|
+
console.log('🚀 ~ selectedThumbnail:', selectedThumbnail);
|
|
18
|
+
const [defaultThumbnailInternal, setDefaultThumbnailInternal] = useState(defaultThumbnail || 0);
|
|
19
|
+
console.log('🚀 ~ defaultThumbnailInternal:', defaultThumbnailInternal);
|
|
20
|
+
(_a = thumbnailSelectedRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo({
|
|
21
|
+
left: selectedThumbnail * 330,
|
|
22
|
+
behavior: 'smooth',
|
|
23
|
+
});
|
|
24
|
+
(_b = sliderContainerRef.current) === null || _b === void 0 ? void 0 : _b.scrollTo({
|
|
25
|
+
left: selectedThumbnail * (330 / slidesPerView),
|
|
26
|
+
behavior: 'smooth',
|
|
27
|
+
});
|
|
28
|
+
const handleNextThumbnail = () => {
|
|
29
|
+
setSelectedThumbnail(prev => (prev === thumbnails.length - 1 ? 0 : prev + 1));
|
|
30
|
+
};
|
|
31
|
+
const handlePrevThumbnail = () => {
|
|
32
|
+
setSelectedThumbnail(prev => (prev === 0 ? thumbnails.length - 1 : prev - 1));
|
|
33
|
+
};
|
|
34
|
+
// useEffect(() => {
|
|
35
|
+
// handleScrollToImage();
|
|
36
|
+
// // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
37
|
+
// }, [selectedThumbnail]);
|
|
38
|
+
return (React.createElement(ImageSliderStyled, { className: className || '', "$skeleton": skeleton, "$slidesPerView": slidesPerView, vertical: true, gap: 10 },
|
|
39
|
+
React.createElement(Flex, { className: "thumbnail-preview-container", ref: thumbnailSelectedRef }, thumbnails.map((url, index) => (React.createElement("div", { key: `image-big_${url}_${index * 2}`, className: clsx('image-container--big', {
|
|
40
|
+
'image-container--default': defaultThumbnailInternal === index,
|
|
41
|
+
// 'image-container--default': isSelectedDefault,
|
|
42
|
+
}) },
|
|
43
|
+
React.createElement(Image, { preview: false, width: "80%", height: "96%", src: thumbnails[index] }),
|
|
44
|
+
React.createElement(Button, { className: "set-default-button", onClick: () => {
|
|
45
|
+
setDefaultThumbnailInternal(selectedThumbnail);
|
|
46
|
+
if (onSelectDefault) {
|
|
47
|
+
onSelectDefault(selectedThumbnail);
|
|
48
|
+
}
|
|
49
|
+
} },
|
|
50
|
+
defaultThumbnailInternal === index ? (React.createElement(Icon, { type: "icon-ants-check", style: { fontSize: '12px' } })) : null,
|
|
51
|
+
defaultThumbnailInternal === index ? 'Default thumbnail' : 'Set as default'))))),
|
|
52
|
+
React.createElement(Flex, { gap: 10, className: "thumbnail-slider-container", ref: sliderContainerRef }, thumbnails.map((url, index) => {
|
|
53
|
+
console.log('🚀 ~ ImageSlider ~ render list ~ thumbnails:', { url, index });
|
|
54
|
+
return (React.createElement("div", { key: `${url}_${index * 2}`, className: clsx('image-container--small', {
|
|
55
|
+
'image-container--selected': index === selectedThumbnail,
|
|
56
|
+
}), onClick: () => setSelectedThumbnail(index) },
|
|
57
|
+
React.createElement(Image, { key: url, preview: false, width: "80%", height: "96%", src: url })));
|
|
58
|
+
})),
|
|
59
|
+
previewNavigation ? (React.createElement(React.Fragment, null,
|
|
60
|
+
React.createElement("div", { className: "change-preview-button change-preview-button--left", onClick: handlePrevThumbnail },
|
|
61
|
+
React.createElement(Icon, { type: "icon-ants-angle-left" })),
|
|
62
|
+
React.createElement("div", { className: "change-preview-button change-preview-button--right", onClick: handleNextThumbnail },
|
|
63
|
+
React.createElement(Icon, { type: "icon-ants-angle-right" })))) : null,
|
|
64
|
+
React.createElement("div", { className: "slider-button slider-button--left", onClick: handlePrevThumbnail },
|
|
65
|
+
React.createElement(Icon, { type: "icon-ants-angle-left" })),
|
|
66
|
+
React.createElement("div", { className: "slider-button slider-button--right", onClick: handleNextThumbnail },
|
|
67
|
+
React.createElement(Icon, { type: "icon-ants-angle-right" }))));
|
|
68
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ImageSlider } from './ImageSlider';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ImageSlider } from './ImageSlider';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const ImageSliderStyled: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd/es/flex/interface").FlexProps<import("antd/es/_util/type").AnyObject> & import("react").RefAttributes<HTMLElement>>, any, {
|
|
3
|
+
$skeleton?: boolean | undefined;
|
|
4
|
+
$slidesPerView?: number | undefined;
|
|
5
|
+
}, never>;
|