@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
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { AutoUpdateTo, RangeInfo, RangeValue, ReducerState } from './types';
|
|
2
|
+
export declare const rangeInfoToStringType: (rangeInfo: RangeInfo) => string;
|
|
3
|
+
export declare const serializeWeekStartsOn: (rangeType: string) => number | undefined;
|
|
4
|
+
export declare const generateRangeInfo: (rangeType: string) => RangeInfo | null;
|
|
5
|
+
export declare const getDefaultDate: () => {
|
|
6
|
+
toDay: string;
|
|
7
|
+
yesterday: string;
|
|
8
|
+
startWeekSS: string;
|
|
9
|
+
startWeekMS: string;
|
|
10
|
+
last7Days: string;
|
|
11
|
+
startLastWeekSS: string;
|
|
12
|
+
startLastWeekMS: string;
|
|
13
|
+
endLastWeekSS: string;
|
|
14
|
+
endLastWeekMS: string;
|
|
15
|
+
last14Days: string;
|
|
16
|
+
startOfThisMonth: string;
|
|
17
|
+
endOfThisMonth: string;
|
|
18
|
+
last30Days: string;
|
|
19
|
+
lastMonthFirstDate: string;
|
|
20
|
+
lastMonthLastDate: string;
|
|
21
|
+
thisQuaterFirstDate: string;
|
|
22
|
+
thisQuaterLastDate: string;
|
|
23
|
+
lastQuaterFirstDate: string;
|
|
24
|
+
lastQuaterLastDate: string;
|
|
25
|
+
maxSub: number;
|
|
26
|
+
todayUptoCount: (val: number) => string;
|
|
27
|
+
yesterdayUptoCount: (val: number) => string;
|
|
28
|
+
};
|
|
29
|
+
export declare const getRangeValue: ({ rangeInfo, currentRangeValue, limitNumOfDays, }: {
|
|
30
|
+
rangeInfo: RangeInfo;
|
|
31
|
+
currentRangeValue: RangeValue[];
|
|
32
|
+
limitNumOfDays?: number | undefined;
|
|
33
|
+
}) => RangeValue[];
|
|
34
|
+
export declare const getRangeValueSelctedTitle: (rangeValue: RangeValue[], options?: {
|
|
35
|
+
formatStart?: string;
|
|
36
|
+
formatEnd?: string;
|
|
37
|
+
minimize?: boolean;
|
|
38
|
+
operator?: string;
|
|
39
|
+
}) => string[];
|
|
40
|
+
export declare const getRangeTypeSelectedTitle: (rangeInfo: RangeInfo) => string;
|
|
41
|
+
export declare const combineCurrentValue: (state: ReducerState) => {
|
|
42
|
+
rangeInfo: RangeInfo;
|
|
43
|
+
rangeValue: RangeValue[];
|
|
44
|
+
};
|
|
45
|
+
export declare const genTriggerOut: ({ mode, id, }: {
|
|
46
|
+
mode: ReducerState['triggerOut']['mode'];
|
|
47
|
+
id?: number | undefined;
|
|
48
|
+
}) => {
|
|
49
|
+
mode: "auto" | "manual";
|
|
50
|
+
id: number;
|
|
51
|
+
};
|
|
52
|
+
export declare const isAutoUpdateToOption: (value: unknown) => value is AutoUpdateTo;
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import utc from 'dayjs/plugin/utc';
|
|
3
|
+
import timezone from 'dayjs/plugin/timezone';
|
|
4
|
+
import isoWeek from 'dayjs/plugin/isoWeek';
|
|
5
|
+
import weekday from 'dayjs/plugin/weekday';
|
|
6
|
+
import quarterOfYear from 'dayjs/plugin/quarterOfYear';
|
|
7
|
+
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
|
|
8
|
+
import { AUTO_UPDATE_TO_KEY, DEFAULT_NUM_UP_TO, MAP_TITLE, RANGE_LIMIT, SELECTION_KEY, } from './constants';
|
|
9
|
+
import { last } from 'lodash';
|
|
10
|
+
import { asssertCannotReach } from '@antscorp/antsomi-ui/es/utils/common';
|
|
11
|
+
dayjs.extend(utc);
|
|
12
|
+
dayjs.extend(timezone);
|
|
13
|
+
dayjs.extend(isoWeek);
|
|
14
|
+
dayjs.extend(quarterOfYear);
|
|
15
|
+
dayjs.extend(weekday);
|
|
16
|
+
dayjs.extend(isSameOrBefore);
|
|
17
|
+
const dayZero = new Date(0);
|
|
18
|
+
export const rangeInfoToStringType = (rangeInfo) => {
|
|
19
|
+
switch (rangeInfo.type) {
|
|
20
|
+
case SELECTION_KEY.last_week:
|
|
21
|
+
case SELECTION_KEY.this_week: {
|
|
22
|
+
return `${rangeInfo.type}_${rangeInfo.weekStartsOn}`;
|
|
23
|
+
}
|
|
24
|
+
default:
|
|
25
|
+
return rangeInfo.type;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
export const serializeWeekStartsOn = (rangeType) => {
|
|
29
|
+
let startOn = last(rangeType.split('_'));
|
|
30
|
+
if (startOn) {
|
|
31
|
+
startOn = +startOn;
|
|
32
|
+
}
|
|
33
|
+
if (typeof startOn === 'number' && startOn >= 1 && startOn <= 7) {
|
|
34
|
+
return startOn;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
export const generateRangeInfo = (rangeType) => {
|
|
38
|
+
const startOn = serializeWeekStartsOn(rangeType);
|
|
39
|
+
let rangeInfo = null;
|
|
40
|
+
switch (true) {
|
|
41
|
+
case rangeType.startsWith(SELECTION_KEY.this_week): {
|
|
42
|
+
if (startOn) {
|
|
43
|
+
rangeInfo = {
|
|
44
|
+
type: SELECTION_KEY.this_week,
|
|
45
|
+
weekStartsOn: startOn,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
case rangeType.startsWith(SELECTION_KEY.last_week): {
|
|
51
|
+
if (startOn) {
|
|
52
|
+
rangeInfo = {
|
|
53
|
+
type: SELECTION_KEY.last_week,
|
|
54
|
+
weekStartsOn: startOn,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
default:
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
switch (rangeType) {
|
|
63
|
+
case SELECTION_KEY.custom: {
|
|
64
|
+
rangeInfo = {
|
|
65
|
+
type: rangeType,
|
|
66
|
+
autoUpdateTo: AUTO_UPDATE_TO_KEY.fixed,
|
|
67
|
+
};
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
case SELECTION_KEY.yesterday:
|
|
71
|
+
case SELECTION_KEY.today:
|
|
72
|
+
case SELECTION_KEY.last_7_days:
|
|
73
|
+
case SELECTION_KEY.last_14_days:
|
|
74
|
+
case SELECTION_KEY.last_30_days:
|
|
75
|
+
case SELECTION_KEY.this_month:
|
|
76
|
+
case SELECTION_KEY.last_month:
|
|
77
|
+
case SELECTION_KEY.this_quarter:
|
|
78
|
+
case SELECTION_KEY.last_quarter:
|
|
79
|
+
case SELECTION_KEY.all_time: {
|
|
80
|
+
rangeInfo = { type: rangeType };
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
case SELECTION_KEY.days_up_to_today:
|
|
84
|
+
case SELECTION_KEY.days_up_to_yesterday: {
|
|
85
|
+
rangeInfo = {
|
|
86
|
+
type: rangeType,
|
|
87
|
+
numOfDays: DEFAULT_NUM_UP_TO,
|
|
88
|
+
};
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
default:
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
return rangeInfo;
|
|
95
|
+
};
|
|
96
|
+
export const getDefaultDate = () => {
|
|
97
|
+
const toDayTz = dayjs(new Date());
|
|
98
|
+
return {
|
|
99
|
+
toDay: toDayTz.toISOString(),
|
|
100
|
+
yesterday: toDayTz.subtract(1, 'd').toISOString(),
|
|
101
|
+
startWeekSS: toDayTz.weekday(0).toISOString(),
|
|
102
|
+
startWeekMS: toDayTz.isoWeekday(1).toISOString(),
|
|
103
|
+
last7Days: toDayTz.subtract(1, 'w').toISOString(),
|
|
104
|
+
startLastWeekSS: toDayTz.subtract(1, 'w').weekday(0).toISOString(),
|
|
105
|
+
startLastWeekMS: toDayTz.subtract(1, 'w').isoWeekday(1).toISOString(),
|
|
106
|
+
endLastWeekSS: toDayTz.subtract(1, 'w').weekday(6).toISOString(),
|
|
107
|
+
endLastWeekMS: toDayTz.subtract(1, 'w').isoWeekday(7).toISOString(),
|
|
108
|
+
last14Days: toDayTz.subtract(14, 'd').toISOString(),
|
|
109
|
+
startOfThisMonth: toDayTz.startOf('M').toISOString(),
|
|
110
|
+
endOfThisMonth: toDayTz.endOf('M').toISOString(),
|
|
111
|
+
last30Days: toDayTz.subtract(30, 'd').toISOString(),
|
|
112
|
+
lastMonthFirstDate: toDayTz.subtract(1, 'M').startOf('M').toISOString(),
|
|
113
|
+
lastMonthLastDate: toDayTz.subtract(1, 'M').endOf('M').toISOString(),
|
|
114
|
+
thisQuaterFirstDate: toDayTz.startOf('Q').toISOString(),
|
|
115
|
+
thisQuaterLastDate: toDayTz.endOf('Q').toISOString(),
|
|
116
|
+
lastQuaterFirstDate: toDayTz.subtract(1, 'Q').startOf('Q').toISOString(),
|
|
117
|
+
lastQuaterLastDate: toDayTz.subtract(1, 'Q').endOf('Q').toISOString(),
|
|
118
|
+
maxSub: toDayTz.diff(dayZero, 'd'),
|
|
119
|
+
todayUptoCount: (val) => toDayTz.subtract(Math.round(val - 1), 'd').toISOString(),
|
|
120
|
+
yesterdayUptoCount: (val) => toDayTz.subtract(Math.round(val - 1) + 1, 'd').toISOString(),
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
export const getRangeValue = ({ rangeInfo, currentRangeValue, limitNumOfDays = RANGE_LIMIT, }) => {
|
|
124
|
+
const defaultDates = getDefaultDate();
|
|
125
|
+
const result = currentRangeValue.map(rangeValue => {
|
|
126
|
+
const temp = {
|
|
127
|
+
start: defaultDates.toDay,
|
|
128
|
+
end: defaultDates.toDay,
|
|
129
|
+
};
|
|
130
|
+
switch (rangeInfo.type) {
|
|
131
|
+
case SELECTION_KEY.custom: {
|
|
132
|
+
temp.start = rangeValue.start;
|
|
133
|
+
temp.end = rangeValue.end;
|
|
134
|
+
switch (rangeInfo.autoUpdateTo) {
|
|
135
|
+
case AUTO_UPDATE_TO_KEY.today: {
|
|
136
|
+
temp.end = defaultDates.toDay;
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
case AUTO_UPDATE_TO_KEY.yesterday: {
|
|
140
|
+
temp.end = defaultDates.yesterday;
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
default:
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
case SELECTION_KEY.today: {
|
|
149
|
+
temp.start = defaultDates.toDay;
|
|
150
|
+
temp.end = defaultDates.toDay;
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
case SELECTION_KEY.yesterday: {
|
|
154
|
+
temp.start = defaultDates.yesterday;
|
|
155
|
+
temp.end = defaultDates.yesterday;
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
case SELECTION_KEY.this_week: {
|
|
159
|
+
temp.start =
|
|
160
|
+
rangeInfo.weekStartsOn === 1 ? defaultDates.startWeekMS : defaultDates.startWeekSS;
|
|
161
|
+
temp.end = defaultDates.toDay;
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
case SELECTION_KEY.last_week: {
|
|
165
|
+
temp.start =
|
|
166
|
+
rangeInfo.weekStartsOn === 1
|
|
167
|
+
? defaultDates.startLastWeekMS
|
|
168
|
+
: defaultDates.startLastWeekSS;
|
|
169
|
+
temp.end =
|
|
170
|
+
rangeInfo.weekStartsOn === 1 ? defaultDates.endLastWeekMS : defaultDates.endLastWeekSS;
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
case SELECTION_KEY.last_7_days: {
|
|
174
|
+
temp.start = defaultDates.last7Days;
|
|
175
|
+
temp.end = defaultDates.yesterday;
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
case SELECTION_KEY.last_14_days: {
|
|
179
|
+
temp.start = defaultDates.last14Days;
|
|
180
|
+
temp.end = defaultDates.yesterday;
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
case SELECTION_KEY.last_30_days: {
|
|
184
|
+
temp.start = defaultDates.last30Days;
|
|
185
|
+
temp.end = defaultDates.yesterday;
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
case SELECTION_KEY.this_month: {
|
|
189
|
+
temp.start = defaultDates.startOfThisMonth;
|
|
190
|
+
temp.end = defaultDates.toDay;
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
case SELECTION_KEY.last_month: {
|
|
194
|
+
temp.start = defaultDates.lastMonthFirstDate;
|
|
195
|
+
temp.end = defaultDates.lastMonthLastDate;
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
case SELECTION_KEY.this_quarter: {
|
|
199
|
+
temp.start = defaultDates.thisQuaterFirstDate;
|
|
200
|
+
temp.end = defaultDates.toDay;
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
case SELECTION_KEY.last_quarter: {
|
|
204
|
+
temp.start = defaultDates.lastQuaterFirstDate;
|
|
205
|
+
temp.end = defaultDates.lastQuaterLastDate;
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
case SELECTION_KEY.all_time: {
|
|
209
|
+
temp.start = dayjs(defaultDates.toDay).subtract(limitNumOfDays, 'd').toISOString();
|
|
210
|
+
temp.end = defaultDates.toDay;
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
case SELECTION_KEY.days_up_to_today: {
|
|
214
|
+
temp.start = dayjs(defaultDates.toDay).subtract(rangeInfo.numOfDays, 'd').toISOString();
|
|
215
|
+
temp.end = defaultDates.toDay;
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
case SELECTION_KEY.days_up_to_yesterday: {
|
|
219
|
+
temp.start = dayjs(defaultDates.toDay).subtract(rangeInfo.numOfDays, 'd').toISOString();
|
|
220
|
+
temp.end = defaultDates.yesterday;
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
default:
|
|
224
|
+
asssertCannotReach(rangeInfo);
|
|
225
|
+
}
|
|
226
|
+
return Object.assign(Object.assign({}, rangeValue), temp);
|
|
227
|
+
});
|
|
228
|
+
return result;
|
|
229
|
+
};
|
|
230
|
+
export const getRangeValueSelctedTitle = (rangeValue, options) => {
|
|
231
|
+
const { formatStart, formatEnd, operator = '-' } = options || {};
|
|
232
|
+
const result = [];
|
|
233
|
+
rangeValue.forEach(range => {
|
|
234
|
+
var _a, _b, _c, _d, _e;
|
|
235
|
+
const { start, end } = range;
|
|
236
|
+
let startFormat = formatStart || 'MMM D';
|
|
237
|
+
const endFormat = formatEnd || 'MMM D YYYY';
|
|
238
|
+
if ((_a = dayjs(start)) === null || _a === void 0 ? void 0 : _a.isSame(dayjs(end), 'D')) {
|
|
239
|
+
return result.push((_b = dayjs(start)) === null || _b === void 0 ? void 0 : _b.format('MMM D YYYY'));
|
|
240
|
+
}
|
|
241
|
+
if (!((_c = dayjs(start)) === null || _c === void 0 ? void 0 : _c.isSame(dayjs(end), 'y')) && !formatStart) {
|
|
242
|
+
startFormat = `${startFormat} YYYY`;
|
|
243
|
+
}
|
|
244
|
+
result.push(`${(_d = dayjs(start)) === null || _d === void 0 ? void 0 : _d.format(startFormat)} ${operator} ${(_e = dayjs(end)) === null || _e === void 0 ? void 0 : _e.format(endFormat)}`);
|
|
245
|
+
});
|
|
246
|
+
return result;
|
|
247
|
+
};
|
|
248
|
+
export const getRangeTypeSelectedTitle = (rangeInfo) => {
|
|
249
|
+
let label = MAP_TITLE[rangeInfo.type];
|
|
250
|
+
switch (rangeInfo.type) {
|
|
251
|
+
case SELECTION_KEY.days_up_to_yesterday:
|
|
252
|
+
case SELECTION_KEY.days_up_to_today: {
|
|
253
|
+
label = `${rangeInfo.numOfDays} ${label}`;
|
|
254
|
+
break;
|
|
255
|
+
}
|
|
256
|
+
default:
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
return label;
|
|
260
|
+
};
|
|
261
|
+
export const combineCurrentValue = (state) => {
|
|
262
|
+
const { rangeValue, rangeInfo } = state.value.current;
|
|
263
|
+
return { rangeInfo, rangeValue };
|
|
264
|
+
};
|
|
265
|
+
export const genTriggerOut = (() => {
|
|
266
|
+
let catchedId = 0;
|
|
267
|
+
return function increaseTriggerOut({ mode, id, }) {
|
|
268
|
+
if (!id)
|
|
269
|
+
catchedId++;
|
|
270
|
+
return { mode, id: id || catchedId };
|
|
271
|
+
};
|
|
272
|
+
})();
|
|
273
|
+
// export const serializeRangeColors = (rangeValue: RangeValue[]) => {
|
|
274
|
+
// const listDate = rangeValue
|
|
275
|
+
// .flatMap(range => [range.start, range.end])
|
|
276
|
+
// .sort((a, b) => ascending(a.toDate(), b.toDate()));
|
|
277
|
+
// let rangeDates = listDate.reduce<RangeValue[]>((acc, current, idx) => {
|
|
278
|
+
// if (listDate[idx + 1]) {
|
|
279
|
+
// acc.push({ start: current, end: listDate[idx + 1] });
|
|
280
|
+
// }
|
|
281
|
+
// return acc;
|
|
282
|
+
// }, []);
|
|
283
|
+
// rangeDates = uniqWith(rangeDates, (a, b) => a.start.isSame(b.start) && a.end.isSame(b.end));
|
|
284
|
+
// rangeDates = rangeDates.map(rangeDate => {
|
|
285
|
+
// const colors: string[] = [];
|
|
286
|
+
// rangeValue.forEach(range => {
|
|
287
|
+
// if (
|
|
288
|
+
// range.color &&
|
|
289
|
+
// rangeDate.start.isBetween(range.start, range.end, 'd', '[]') &&
|
|
290
|
+
// rangeDate.end.isBetween(range.start, range.end, 'd', '[]')
|
|
291
|
+
// ) {
|
|
292
|
+
// colors.push(range.color);
|
|
293
|
+
// }
|
|
294
|
+
// });
|
|
295
|
+
// return { ...rangeDate, colors: uniq(colors) };
|
|
296
|
+
// });
|
|
297
|
+
// return rangeDates;
|
|
298
|
+
// };
|
|
299
|
+
export const isAutoUpdateToOption = (value) => {
|
|
300
|
+
if (typeof value === 'string' && Object.values(AUTO_UPDATE_TO_KEY).some(v => v === value)) {
|
|
301
|
+
return true;
|
|
302
|
+
}
|
|
303
|
+
return false;
|
|
304
|
+
};
|
|
@@ -53,7 +53,7 @@ const styleContainAlpha = {
|
|
|
53
53
|
const CustomPicker = props => {
|
|
54
54
|
var _a, _b, _c, _d;
|
|
55
55
|
// Props
|
|
56
|
-
const { className, style, children, onChange, onChangeComplete, presetColors } = props, restOf = __rest(props, ["className", "style", "children", "onChange", "onChangeComplete", "presetColors"]);
|
|
56
|
+
const { className, style, children, isHideAlpha, onChange, onChangeComplete, presetColors } = props, restOf = __rest(props, ["className", "style", "children", "isHideAlpha", "onChange", "onChangeComplete", "presetColors"]);
|
|
57
57
|
// State
|
|
58
58
|
const [isShowRgbaInput, setShowRgbaInput] = useState(true);
|
|
59
59
|
const onChangeRgbaColor = (key, value) => {
|
|
@@ -101,9 +101,9 @@ const CustomPicker = props => {
|
|
|
101
101
|
React.createElement("div", { style: rgbaStyling },
|
|
102
102
|
React.createElement(InputNumberWrapper, { value: (_c = props.rgb) === null || _c === void 0 ? void 0 : _c.b, controls: false, onChange: value => onChangeRgbaColor('b', value) }),
|
|
103
103
|
React.createElement(Text, { style: { position: 'absolute', bottom: '-20px' } }, "B")),
|
|
104
|
-
React.createElement("div", { style: rgbaStyling },
|
|
104
|
+
!isHideAlpha && (React.createElement("div", { style: rgbaStyling },
|
|
105
105
|
React.createElement(InputNumberWrapper, { value: (_d = props.rgb) === null || _d === void 0 ? void 0 : _d.a, controls: false, onChange: value => onChangeRgbaColor('a', value) }),
|
|
106
|
-
React.createElement(Text, { style: { position: 'absolute', bottom: '-20px' } }, "A")))) : (React.createElement(EditableInputWrapper, null,
|
|
106
|
+
React.createElement(Text, { style: { position: 'absolute', bottom: '-20px' } }, "A"))))) : (React.createElement(EditableInputWrapper, null,
|
|
107
107
|
React.createElement(EditableInput, { value: props.color, onChange: onChange }),
|
|
108
108
|
React.createElement(Text, { style: { position: 'absolute', bottom: '-20px' } }, "HEX"))),
|
|
109
109
|
React.createElement(Button, { onClick: () => {
|
|
@@ -21,7 +21,7 @@ const styleBtnColor = {
|
|
|
21
21
|
};
|
|
22
22
|
export const ColorPicker = props => {
|
|
23
23
|
// Props
|
|
24
|
-
const { className = '', defaultColor = '#000000', presetColors, positionInput = 'left', icon, showInput = true, style = {}, } = props;
|
|
24
|
+
const { className = '', defaultColor = '#000000', presetColors, positionInput = 'left', icon, showInput = true, style = {}, isHideAlpha, } = props;
|
|
25
25
|
const { onChange = () => { } } = props;
|
|
26
26
|
// States
|
|
27
27
|
const [color, setColor] = useState(defaultColor);
|
|
@@ -74,7 +74,7 @@ export const ColorPicker = props => {
|
|
|
74
74
|
};
|
|
75
75
|
return (React.createElement(ColorPickerWrapper, { className: `antsomi-color-picker ${className || ''}`, style: style },
|
|
76
76
|
showInput && positionInput === 'left' && (React.createElement(Input, { style: { textTransform: 'uppercase' }, value: color, onChange: onChangeColorInput })),
|
|
77
|
-
React.createElement(Popover, { arrow: true, content: React.createElement(CustomPicker, { color: color, presetColors: presetColors, onChange: onChangeColorPicker, onChangeComplete: onChangeComplete }), trigger: "click", open: popoverVisible, getPopupContainer: triggerNode => triggerNode, onOpenChange: onPopoverVisibleChange },
|
|
77
|
+
React.createElement(Popover, { arrow: true, content: React.createElement(CustomPicker, { color: color, presetColors: presetColors, isHideAlpha: isHideAlpha, onChange: onChangeColorPicker, onChangeComplete: onChangeComplete }), trigger: "click", open: popoverVisible, getPopupContainer: triggerNode => triggerNode, onOpenChange: onPopoverVisibleChange },
|
|
78
78
|
React.createElement("div", { className: "antsomi-popover-button", style: styleBtnColor }, iconNode || (React.createElement("span", { style: {
|
|
79
79
|
backgroundColor: color,
|
|
80
80
|
display: 'block',
|
|
@@ -88,6 +88,7 @@ ColorPicker.defaultProps = {
|
|
|
88
88
|
className: '',
|
|
89
89
|
color: '#000000',
|
|
90
90
|
defaultColor: '#000000',
|
|
91
|
+
isHideAlpha: false,
|
|
91
92
|
onChange: () => { },
|
|
92
93
|
showInput: true,
|
|
93
94
|
positionInput: 'left',
|
|
@@ -10,7 +10,7 @@ import { useDeepCompareEffect } from '../../../../../hooks';
|
|
|
10
10
|
import Icon from '@antscorp/icons';
|
|
11
11
|
import { EventIcon } from '../../../../icons';
|
|
12
12
|
// Components
|
|
13
|
-
import {
|
|
13
|
+
import { InputNumber, Divider, Space, Button, Typography, } from '@antscorp/antsomi-ui/es/components/atoms';
|
|
14
14
|
import { Select, Dropdown } from '@antscorp/antsomi-ui/es/components';
|
|
15
15
|
import { ErrorMessage } from '../ErrorMessage/ErrorMessage';
|
|
16
16
|
import { DropdownLabel } from '../DropdownLabel/DropdownLabel';
|
|
@@ -18,7 +18,7 @@ import { DropdownLabel } from '../DropdownLabel/DropdownLabel';
|
|
|
18
18
|
import { handleError, reorder } from '@antscorp/antsomi-ui/es/utils';
|
|
19
19
|
import { calculationDateAdvanced, getCellRender, getFormatDisplay, getPickerRender, getTimePickerRender, } from './utils';
|
|
20
20
|
// Styled
|
|
21
|
-
import { DatePickerCustomInput, DatePickerHeader, DropdownContent, DropdownHeader, DatePickerFooter, DropdownFooter, CalendarIconWrapper, } from './styled';
|
|
21
|
+
import { DatePickerCustomInput, DatePickerHeader, DropdownContent, DropdownHeader, DatePickerFooter, DropdownFooter, CalendarIconWrapper, InputStyled, TimeLabel, } from './styled';
|
|
22
22
|
// Constants
|
|
23
23
|
import { CALCULATION_DATES, CALCULATION_TYPES, DATE_TYPES, DEFAULT_DATE_FORMAT, VALUE_TYPES, ADVANCED_PICKER_TYPE, WEEK_ARR, QUARTER_PLACEHOLDER, WEEK_PLACEHOLDER, DAY_LABEL_SHORT, MONTH_LABEL_FULL, DAY_OF_MONTH, ANCHOR_LEAP_YEAR, GRANULARITY_MAPPING, } from './constants';
|
|
24
24
|
import { THEME } from '@antscorp/antsomi-ui/es/constants';
|
|
@@ -244,7 +244,8 @@ export const AdvancedPicker = props => {
|
|
|
244
244
|
};
|
|
245
245
|
const onClickNow = () => {
|
|
246
246
|
try {
|
|
247
|
-
|
|
247
|
+
const currentDate = dayjs();
|
|
248
|
+
setState(state => (Object.assign(Object.assign({}, state), { date: currentDate.format(format) })));
|
|
248
249
|
}
|
|
249
250
|
catch (error) {
|
|
250
251
|
handleError(error, {
|
|
@@ -381,7 +382,7 @@ export const AdvancedPicker = props => {
|
|
|
381
382
|
!!label && typeof label === 'string' ? (React.createElement(Text, { style: { color: '#666666' } }, label)) : (label),
|
|
382
383
|
option.dateType.value === 'fixed' &&
|
|
383
384
|
!['WEEK', 'DAY_OF_WEEK', 'MONTH_DAY', 'DAY'].includes(valueType) ? (React.createElement(Tooltip, { title: selectedDateTitle },
|
|
384
|
-
React.createElement(DatePicker, { disabled: disabled, open: !disabled && isOpen, allowClear: false, inputReadOnly: true, status: errorMessage ? 'error' : '', inputRender: () => (React.createElement(DatePickerCustomInput, { readOnly: true, placeholder: "Select Date", value: selectedDateTitle, onClick: () => toggleOpenDropdown() })), value: currDate,
|
|
385
|
+
React.createElement(DatePicker, { disabled: disabled, open: !disabled && isOpen, allowClear: false, inputReadOnly: true, style: Object.assign({ textOverflow: 'ellipsis' }, inputStyle), status: errorMessage ? 'error' : '', inputRender: () => (React.createElement(DatePickerCustomInput, { readOnly: true, placeholder: "Select Date", value: selectedDateTitle, onClick: () => toggleOpenDropdown() })), value: currDate,
|
|
385
386
|
// style={{
|
|
386
387
|
// width: 120,
|
|
387
388
|
// }}
|
|
@@ -391,32 +392,39 @@ export const AdvancedPicker = props => {
|
|
|
391
392
|
'only-show-time-picker': ['HOUR', 'MINUTE'].includes(valueType),
|
|
392
393
|
'is-minutes-picker': valueType === 'MINUTE',
|
|
393
394
|
'is-hours-picker': valueType === 'HOUR',
|
|
394
|
-
}), renderExtraFooter: () =>
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
395
|
+
}), renderExtraFooter: () => {
|
|
396
|
+
const timeFormat = getTimePickerRender(valueType);
|
|
397
|
+
return (React.createElement(React.Fragment, null,
|
|
398
|
+
React.createElement(DatePickerHeader, null,
|
|
399
|
+
React.createElement(DropdownLabel, { valueType: valueType, date: date, format: format, type: type, showTime: showTime, operatorKey: operatorKey, formatInputDisplay: formatInputDisplay }),
|
|
400
|
+
renderDateTypeOptions()),
|
|
401
|
+
React.createElement(DatePickerFooter, null,
|
|
402
|
+
React.createElement("div", { style: { padding: '0 10px' } },
|
|
403
|
+
React.createElement(ErrorMessage, { errorMessage: errorMessage })),
|
|
404
|
+
renderDropdownFooter()),
|
|
405
|
+
React.createElement(Divider, null),
|
|
406
|
+
timeFormat && valueType !== 'HOUR' && valueType !== 'MINUTE' ? (React.createElement(TimeLabel, { "$width": timeFormat.length * 30 },
|
|
407
|
+
['HH', 'HHmm', 'HHmmss'].includes(timeFormat) ? React.createElement("span", null, "Hours") : null,
|
|
408
|
+
['HHmm', 'HHmmss', 'mm'].includes(timeFormat) ? React.createElement("span", null, "Minutes") : null,
|
|
409
|
+
timeFormat === 'HHmmss' ? React.createElement("span", null, "Seconds") : null)) : null));
|
|
410
|
+
}, picker: getPickerRender(valueType), showTime: getTimePickerRender(valueType)
|
|
403
411
|
? {
|
|
404
412
|
format: getTimePickerRender(valueType),
|
|
405
413
|
}
|
|
406
414
|
: undefined, suffixIcon: React.createElement(CalendarIconWrapper, { style: {
|
|
407
415
|
pointerEvents: disabled ? 'none' : 'all',
|
|
408
416
|
}, onClick: () => toggleOpenDropdown() },
|
|
409
|
-
React.createElement(EventIcon, { width: 20, height: 20, fill: errorMessage ? (_a = THEME.token) === null || _a === void 0 ? void 0 : _a.colorError : (_b = THEME.token) === null || _b === void 0 ? void 0 : _b.bw10 })), cellRender: cellRender }))) : (React.createElement(Dropdown, { disabled: disabled, open: !disabled && isOpen, dropdownRender: dropdownRender, trigger: ['click'],
|
|
417
|
+
React.createElement(EventIcon, { width: 20, height: 20, fill: errorMessage ? (_a = THEME.token) === null || _a === void 0 ? void 0 : _a.colorError : (_b = THEME.token) === null || _b === void 0 ? void 0 : _b.bw10 })), cellRender: cellRender, onOpenChange: () => toggleOpenDropdown() }))) : (React.createElement(Dropdown, { disabled: disabled, open: !disabled && isOpen, dropdownRender: dropdownRender, trigger: ['click'],
|
|
410
418
|
// onOpenChange={(open, info) => {
|
|
411
419
|
// console.log('🚀🚀🚀 ', 4, { open, info });
|
|
412
420
|
// toggleOpenDropdown();
|
|
413
421
|
// }}
|
|
414
422
|
overlayStyle: { width: 'fit-content', minWidth: 'auto' } },
|
|
415
423
|
React.createElement(Tooltip, { title: selectedDateTitle },
|
|
416
|
-
React.createElement(
|
|
424
|
+
React.createElement(InputStyled, { disabled: disabled, onClick: () => toggleOpenDropdown(), readOnly: true, suffix: React.createElement(CalendarIconWrapper, { style: {
|
|
417
425
|
pointerEvents: disabled ? 'none' : 'all',
|
|
418
426
|
}, onClick: () => toggleOpenDropdown() },
|
|
419
|
-
React.createElement(EventIcon, { width: 19, height: 19 })), style: inputStyle, value: selectedDateTitle, status: errorMessage ? 'error' : '' }))))));
|
|
427
|
+
React.createElement(EventIcon, { width: 19, height: 19 })), style: Object.assign({ textOverflow: 'ellipsis' }, inputStyle), value: selectedDateTitle, status: errorMessage ? 'error' : '' }))))));
|
|
420
428
|
};
|
|
421
429
|
AdvancedPicker.defaultProps = {
|
|
422
430
|
label: '',
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
export declare const DropdownContent: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
2
3
|
export declare const DropdownHeader: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
3
4
|
export declare const DropdownFooter: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
4
5
|
export declare const DatePickerHeader: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
6
|
export declare const DatePickerCustomInput: import("styled-components").StyledComponent<"input", any, {}, never>;
|
|
7
|
+
export declare const InputStyled: import("styled-components").StyledComponent<import("react").ComponentType<any> | keyof import("react").JSX.IntrinsicElements, any, import("../../../../atoms/Input").InputProps, any>;
|
|
6
8
|
export declare const DatePickerFooter: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
7
9
|
export declare const CalendarIconWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
10
|
+
export declare const TimeLabel: import("styled-components").StyledComponent<"div", any, {
|
|
11
|
+
$width: number;
|
|
12
|
+
}, never>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
var _a, _b, _c, _d, _e;
|
|
2
2
|
// Libraries
|
|
3
|
-
import { THEME } from '../../../../../constants';
|
|
4
3
|
import styled from 'styled-components';
|
|
4
|
+
import { Input } from '@antscorp/antsomi-ui/es/components/atoms';
|
|
5
|
+
import { THEME } from '../../../../../constants';
|
|
5
6
|
export const DropdownContent = styled.div `
|
|
6
7
|
width: 250px;
|
|
7
8
|
padding: 10px 10px 0px 10px;
|
|
@@ -80,6 +81,12 @@ export const DatePickerHeader = styled.div `
|
|
|
80
81
|
export const DatePickerCustomInput = styled.input `
|
|
81
82
|
font-family: ${(_d = THEME.token) === null || _d === void 0 ? void 0 : _d.fontFamily};
|
|
82
83
|
color: ${(_e = THEME.token) === null || _e === void 0 ? void 0 : _e.bw10} !important;
|
|
84
|
+
text-overflow: ellipsis;
|
|
85
|
+
`;
|
|
86
|
+
export const InputStyled = styled(Input) `
|
|
87
|
+
input {
|
|
88
|
+
text-overflow: ellipsis;
|
|
89
|
+
}
|
|
83
90
|
`;
|
|
84
91
|
export const DatePickerFooter = styled.div `
|
|
85
92
|
position: absolute;
|
|
@@ -91,3 +98,26 @@ export const CalendarIconWrapper = styled.div `
|
|
|
91
98
|
cursor: pointer;
|
|
92
99
|
pointer-events: all;
|
|
93
100
|
`;
|
|
101
|
+
export const TimeLabel = styled.div `
|
|
102
|
+
position: absolute;
|
|
103
|
+
right: 0;
|
|
104
|
+
top: 120px;
|
|
105
|
+
height: 39.1px;
|
|
106
|
+
width: ${props => `${props.$width}px`};
|
|
107
|
+
/* width: 180px; */
|
|
108
|
+
display: flex;
|
|
109
|
+
align-items: stretch;
|
|
110
|
+
justify-content: space-around;
|
|
111
|
+
|
|
112
|
+
span {
|
|
113
|
+
width: 60px;
|
|
114
|
+
display: block;
|
|
115
|
+
text-align: center;
|
|
116
|
+
font-weight: bold;
|
|
117
|
+
border-left: 1px solid rgba(5, 5, 5, 0.06);
|
|
118
|
+
|
|
119
|
+
&:first-child {
|
|
120
|
+
border-left-color: transparent;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
`;
|
|
@@ -30,7 +30,7 @@ export declare const getCellRender: (current: number | Dayjs, valueType: ValueTy
|
|
|
30
30
|
* @returns {'date' | 'week' | 'month' | 'quarter' | 'year'} picker ant-design props to render type of calendar
|
|
31
31
|
*/
|
|
32
32
|
export declare const getPickerRender: (valueType: ValueTypes) => 'date' | 'week' | 'month' | 'quarter' | 'year';
|
|
33
|
-
export declare const getTimePickerRender: (valueType: ValueTypes) =>
|
|
33
|
+
export declare const getTimePickerRender: (valueType: ValueTypes) => 'HH' | 'HHmm' | 'HHmmss' | 'mm' | undefined;
|
|
34
34
|
export declare function getLabelQuarterRange(day: string, format: string, locale: string, showYear?: boolean): string;
|
|
35
35
|
export declare function getLabelQuarterRange(quarter: number, year?: number): string;
|
|
36
36
|
export declare const getFormatDisplay: (operatorKey?: TOperatorKey, type?: TAdvancedType, valueType?: ValueTypes, formatInputDisplay?: string) => {
|
package/es/components/molecules/DatePicker/components/AdvancedRangePicker/AdvancedRangePicker.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
2
|
import { TShowCalculationTypeCondition, ValueTypes } from '../AdvancedPicker/types';
|
|
3
3
|
import { TDateConfig, TOnChangePayload, TTimeRange } from './types';
|
|
4
4
|
export interface AdvancedRangePickerProps {
|
|
@@ -12,6 +12,8 @@ export interface AdvancedRangePickerProps {
|
|
|
12
12
|
showLabel?: boolean;
|
|
13
13
|
showTime?: boolean;
|
|
14
14
|
timezone?: string;
|
|
15
|
+
separator?: ReactNode;
|
|
16
|
+
inputStyle?: React.CSSProperties;
|
|
15
17
|
onChange?: ({ timeRange, mode }: TOnChangePayload) => void;
|
|
16
18
|
}
|
|
17
19
|
export declare const AdvancedRangePicker: React.FC<AdvancedRangePickerProps>;
|
package/es/components/molecules/DatePicker/components/AdvancedRangePicker/AdvancedRangePicker.js
CHANGED
|
@@ -19,7 +19,7 @@ const PATH = '@antscorp/antsomi-ui/es/components/molecules/DatePicker/components
|
|
|
19
19
|
export const AdvancedRangePicker = props => {
|
|
20
20
|
const { t } = i18nInstance;
|
|
21
21
|
// Props
|
|
22
|
-
const { valueType, timeRange, errorMessage, showLabel, startDateConfig, endDateConfig, showTime, showCalculationTypeCondition, disabled, timezone, onChange, } = props;
|
|
22
|
+
const { valueType, timeRange, errorMessage, showLabel, startDateConfig, endDateConfig, showTime, showCalculationTypeCondition, disabled, timezone, separator, inputStyle, onChange, } = props;
|
|
23
23
|
const [timeRangeState, setTimeRange] = useState(timeRange);
|
|
24
24
|
useDeepCompareEffect(() => {
|
|
25
25
|
if (typeof onChange === 'function') {
|
|
@@ -54,9 +54,10 @@ export const AdvancedRangePicker = props => {
|
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
|
-
return (React.createElement(Space, { size: 20 },
|
|
58
|
-
React.createElement(AdvancedPicker, { valueType: valueType, disabled: disabled, label: showLabel ? t(translations.datePicker.startDate) || '' : '', date: timeRange.startDate.date, option: omit(timeRange.startDate, 'date'), operatorKey: "between", type: "startDate", format: ADVANCED_RANGE_PICKER_FORMAT.startDate, errorMessage: errorMessage, disableAfterDate: timeRange.endDate.date, showTime: showTime, calculationTypeKeysShow: startDateConfig === null || startDateConfig === void 0 ? void 0 : startDateConfig.calculationTypeKeysShow, showCalculationTypeCondition: showCalculationTypeCondition, timezone: timezone, onUpdatedNewDate: ({ date }) => onUpdateTimeRange('startDate', { date }, 'system'), onApply: ({ date, option }) => onUpdateTimeRange('startDate', Object.assign({ date }, option), 'user') }),
|
|
59
|
-
|
|
57
|
+
return (React.createElement(Space, { size: 20, align: "end" },
|
|
58
|
+
React.createElement(AdvancedPicker, { valueType: valueType, disabled: disabled, label: showLabel ? t(translations.datePicker.startDate) || '' : '', date: timeRange.startDate.date, option: omit(timeRange.startDate, 'date'), operatorKey: "between", type: "startDate", format: ADVANCED_RANGE_PICKER_FORMAT.startDate, errorMessage: errorMessage, disableAfterDate: timeRange.endDate.date, showTime: showTime, calculationTypeKeysShow: startDateConfig === null || startDateConfig === void 0 ? void 0 : startDateConfig.calculationTypeKeysShow, showCalculationTypeCondition: showCalculationTypeCondition, timezone: timezone, onUpdatedNewDate: ({ date }) => onUpdateTimeRange('startDate', { date }, 'system'), onApply: ({ date, option }) => onUpdateTimeRange('startDate', Object.assign({ date }, option), 'user'), inputStyle: inputStyle }),
|
|
59
|
+
separator || null,
|
|
60
|
+
React.createElement(AdvancedPicker, { valueType: valueType, disabled: disabled, label: showLabel ? t(translations.datePicker.endDate) || '' : '', date: timeRange.endDate.date, option: omit(timeRange.endDate, 'date'), operatorKey: "between", type: "endDate", format: ADVANCED_RANGE_PICKER_FORMAT.endDate, errorMessage: errorMessage, showTime: showTime, calculationTypeKeysShow: endDateConfig === null || endDateConfig === void 0 ? void 0 : endDateConfig.calculationTypeKeysShow, showCalculationTypeCondition: showCalculationTypeCondition, timezone: timezone, onUpdatedNewDate: ({ date }) => onUpdateTimeRange('endDate', { date }, 'system'), onApply: ({ date, option }) => onUpdateTimeRange('endDate', Object.assign({ date }, option), 'user'), inputStyle: inputStyle })));
|
|
60
61
|
};
|
|
61
62
|
AdvancedRangePicker.defaultProps = {
|
|
62
63
|
timeRange: {
|