@antscorp/antsomi-ui 1.3.5-beta.1 → 1.3.5-beta.11
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/components/common/ConfigProvider/ConfigProvider.d.ts +1 -0
- package/es/components/common/ConfigProvider/ConfigProvider.js +1 -0
- package/es/components/common/ConfigProvider/GlobalStyle.js +10 -1
- 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 +89 -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 +141 -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 +5 -0
- package/es/components/molecules/CalendarSelection/components/TimeRangeDisplay/TimeRangeDisplay.js +45 -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 +5 -0
- package/es/components/molecules/CalendarSelection/styled.js +10 -0
- package/es/components/molecules/CalendarSelection/types.d.ts +98 -0
- package/es/components/molecules/CalendarSelection/types.js +1 -0
- package/es/components/molecules/CalendarSelection/utils.d.ts +48 -0
- package/es/components/molecules/CalendarSelection/utils.js +300 -0
- package/es/components/molecules/DatePicker/components/AdvancedPicker/AdvancedPicker.js +10 -6
- package/es/components/molecules/DatePicker/components/AdvancedPicker/styled.d.ts +2 -0
- package/es/components/molecules/DatePicker/components/AdvancedPicker/styled.js +8 -1
- package/es/components/molecules/DatePicker/components/AdvancedRangePicker/AdvancedRangePicker.d.ts +2 -1
- package/es/components/molecules/DatePicker/components/AdvancedRangePicker/AdvancedRangePicker.js +3 -2
- 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/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 +20 -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 +3 -0
- package/es/components/molecules/index.js +2 -0
- package/es/components/organism/Menu/Menu.d.ts +1 -0
- package/es/components/organism/Menu/Menu.js +1 -0
- package/es/components/organism/Menu/index.d.ts +1 -0
- package/es/components/organism/Menu/index.js +3 -0
- package/es/components/organism/index.d.ts +1 -0
- package/es/components/organism/index.js +1 -0
- package/es/components/template/TemplateListing/components/BlankTemplate/index.js +7 -7
- package/es/components/template/TemplateListing/components/BlankTemplate/styled.js +2 -0
- package/es/components/template/TemplateListing/components/CategoryListing/index.js +15 -10
- package/es/components/template/TemplateListing/components/CategoryListing/styled.d.ts +2 -0
- package/es/components/template/TemplateListing/components/CategoryListing/styled.js +27 -5
- package/es/components/template/TemplateListing/components/CategoryListing/types.d.ts +2 -1
- package/es/components/template/TemplateListing/components/index.d.ts +0 -1
- package/es/components/template/TemplateListing/components/index.js +0 -1
- package/es/components/template/TemplateListing/constants/defaultProps.d.ts +4 -2
- package/es/components/template/TemplateListing/constants/defaultProps.js +2 -0
- package/es/components/template/TemplateListing/index.js +5 -6
- package/es/components/template/TemplateListing/types/BlankTemplate.d.ts +3 -2
- package/es/components/template/TemplateListing/types/CategoryListing.d.ts +3 -1
- package/es/components/template/TemplateListing/types/TemplateListing.d.ts +8 -7
- package/es/components/template/TemplateListing/types/index.d.ts +0 -1
- package/es/components/template/TemplateListing/types/index.js +0 -1
- package/es/locales/en/translation.json +2 -2
- package/es/test.js +30 -0
- package/es/utils/common.d.ts +1 -0
- package/es/utils/common.js +3 -0
- package/package.json +4 -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
package/es/assets/css/main.scss
CHANGED
|
Binary file
|
|
@@ -2,6 +2,7 @@ import { ConfigProviderProps as AntdConfigProviderProps } from 'antd/es/config-p
|
|
|
2
2
|
import React, { ReactNode } from 'react';
|
|
3
3
|
import '@antscorp/antsomi-ui/es/assets/css/main.scss';
|
|
4
4
|
import { TLocale } from '@antscorp/antsomi-ui/es/types';
|
|
5
|
+
import 'animate.css';
|
|
5
6
|
interface ConfigProviderProps extends Omit<AntdConfigProviderProps, 'locale'> {
|
|
6
7
|
children?: ReactNode;
|
|
7
8
|
locale?: TLocale;
|
|
@@ -27,6 +27,7 @@ import '@antscorp/antsomi-ui/es/assets/css/main.scss';
|
|
|
27
27
|
// Initialize languages
|
|
28
28
|
// import '@antscorp/antsomi-ui/es/locales/i18n';
|
|
29
29
|
import i18next from '@antscorp/antsomi-ui/es/locales/i18n';
|
|
30
|
+
import 'animate.css';
|
|
30
31
|
// NOTE: HOT fix DatePicker Advanced
|
|
31
32
|
dayjs.extend(weekday);
|
|
32
33
|
dayjs.extend(localeData);
|
|
@@ -11,7 +11,7 @@ import { fab } from '@fortawesome/free-brands-svg-icons';
|
|
|
11
11
|
library.add(fas, far, fab);
|
|
12
12
|
const { accent6, accent7, scrollBarSize } = THEME.token || {};
|
|
13
13
|
export const GlobalStyle = () => {
|
|
14
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36;
|
|
14
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37;
|
|
15
15
|
return (React.createElement(Global, { styles: css `
|
|
16
16
|
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@100;300;400;500;700;900&display=swap');
|
|
17
17
|
|
|
@@ -769,5 +769,14 @@ export const GlobalStyle = () => {
|
|
|
769
769
|
}
|
|
770
770
|
}
|
|
771
771
|
}
|
|
772
|
+
|
|
773
|
+
/* Menu */
|
|
774
|
+
.antsomi-menu {
|
|
775
|
+
.antsomi-menu-submenu.antsomi-menu-submenu-selected {
|
|
776
|
+
.antsomi-menu-item.antsomi-menu-item-selected {
|
|
777
|
+
background-color: ${(_37 = THEME.token) === null || _37 === void 0 ? void 0 : _37.blue};
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
}
|
|
772
781
|
` }));
|
|
773
782
|
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/* eslint-disable react/jsx-no-constructed-context-values */
|
|
2
|
+
import React, { useLayoutEffect, useReducer, useRef } from 'react';
|
|
3
|
+
import { Divider } from 'antd';
|
|
4
|
+
import { ActionContext, StateContext } from './context';
|
|
5
|
+
import { reducer, INITIAL_STATE } from './reducer';
|
|
6
|
+
import { StyledPopover, StyledPopoverBody } from './styled';
|
|
7
|
+
import { CustomPicker, Footer, RangeSelectOptions, TimeRangeDisplay } from './components';
|
|
8
|
+
import { LOCAL_TIMEZONE, RANGE_LIMIT } from './constants';
|
|
9
|
+
import { initState } from './actions';
|
|
10
|
+
import { useTriggerOut } from './hooks/useTriggerOut';
|
|
11
|
+
export const CalendarSelection = props => {
|
|
12
|
+
const initialed = useRef(false);
|
|
13
|
+
const { value, popoverProps, rangeLimit = RANGE_LIMIT, timezone = LOCAL_TIMEZONE, timeDisplayProps, onChange, } = props;
|
|
14
|
+
const [state, dispatch] = useReducer(reducer, INITIAL_STATE);
|
|
15
|
+
useLayoutEffect(() => {
|
|
16
|
+
if (!value)
|
|
17
|
+
return;
|
|
18
|
+
dispatch(initState(value, !initialed.current));
|
|
19
|
+
initialed.current = true;
|
|
20
|
+
}, [value]);
|
|
21
|
+
// useLayoutEffect(() => {
|
|
22
|
+
// if (!state.open) {
|
|
23
|
+
// return () => {
|
|
24
|
+
// dispatch(resetValue());
|
|
25
|
+
// };
|
|
26
|
+
// }
|
|
27
|
+
// }, [state.open]);
|
|
28
|
+
useTriggerOut({ state, dispatch, onChange });
|
|
29
|
+
const popoverContent = (React.createElement(React.Fragment, null,
|
|
30
|
+
React.createElement(StyledPopoverBody, null,
|
|
31
|
+
React.createElement(RangeSelectOptions, null),
|
|
32
|
+
React.createElement(Divider, { type: "vertical", style: { margin: 0, height: 'auto' } }),
|
|
33
|
+
React.createElement(CustomPicker, null)),
|
|
34
|
+
React.createElement(Divider, { style: { margin: 0 } }),
|
|
35
|
+
React.createElement(Footer, null)));
|
|
36
|
+
// console.log(state.value.current.rangeValue);
|
|
37
|
+
return (React.createElement(StateContext.Provider, { value: Object.assign(Object.assign({}, state), { rangeLimit,
|
|
38
|
+
timezone }) },
|
|
39
|
+
React.createElement(ActionContext.Provider, { value: { dispatch } },
|
|
40
|
+
React.createElement(StyledPopover, Object.assign({}, popoverProps, { open: state.open, arrow: false, trigger: ['click'], content: popoverContent, destroyTooltipOnHide: true, overlayInnerStyle: { padding: 0 }, onOpenChange: isOpen => {
|
|
41
|
+
if (!isOpen)
|
|
42
|
+
dispatch({ type: 'toggle_popover' });
|
|
43
|
+
} }),
|
|
44
|
+
React.createElement(TimeRangeDisplay, { showType: timeDisplayProps === null || timeDisplayProps === void 0 ? void 0 : timeDisplayProps.showType })))));
|
|
45
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Custom, RangeInfo, CalendarSelectionValue, RangeValue } from './types';
|
|
2
|
+
export declare const ACTION_TYPES: {
|
|
3
|
+
readonly initState: "init_state";
|
|
4
|
+
readonly changeRangeType: "change_range_type";
|
|
5
|
+
readonly updateRangeInfo: "update_range_info";
|
|
6
|
+
readonly updateRangeValue: "update_range_value";
|
|
7
|
+
readonly changeAutoUpdateTo: "change_auto_update_to";
|
|
8
|
+
readonly togglePopover: "toggle_popover";
|
|
9
|
+
readonly apply: "apply";
|
|
10
|
+
readonly resetValue: "reset_value";
|
|
11
|
+
};
|
|
12
|
+
export declare const changeRangeType: (rangeType: string, callback?: ((rangeInfo: RangeInfo) => void) | undefined) => {
|
|
13
|
+
type: "change_range_type";
|
|
14
|
+
payload: {
|
|
15
|
+
rangeType: string;
|
|
16
|
+
callback: ((rangeInfo: RangeInfo) => void) | undefined;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export declare const updateRangeInfo: (updateValue: Partial<RangeInfo>) => {
|
|
20
|
+
type: "update_range_info";
|
|
21
|
+
payload: {
|
|
22
|
+
updateValue: Partial<RangeInfo>;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export declare const updateRangeValue: (rangeValue: RangeValue[], options?: {
|
|
26
|
+
isManual: boolean;
|
|
27
|
+
}) => {
|
|
28
|
+
type: "update_range_value";
|
|
29
|
+
payload: {
|
|
30
|
+
rangeValue: RangeValue[];
|
|
31
|
+
options: {
|
|
32
|
+
isManual: boolean;
|
|
33
|
+
} | undefined;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
export declare const changeAutoUpdateTo: (value: Custom['autoUpdateTo']) => {
|
|
37
|
+
type: "change_auto_update_to";
|
|
38
|
+
payload: import("./types").AutoUpdateTo;
|
|
39
|
+
};
|
|
40
|
+
export declare const initState: (initData: CalendarSelectionValue, needTriggerOut?: boolean) => {
|
|
41
|
+
type: "init_state";
|
|
42
|
+
payload: {
|
|
43
|
+
initData: CalendarSelectionValue;
|
|
44
|
+
needTriggerOut: boolean;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export declare const togglePopover: () => {
|
|
48
|
+
type: "toggle_popover";
|
|
49
|
+
};
|
|
50
|
+
export declare const apply: () => {
|
|
51
|
+
type: "apply";
|
|
52
|
+
};
|
|
53
|
+
export declare const resetValue: () => {
|
|
54
|
+
type: "reset_value";
|
|
55
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export const ACTION_TYPES = {
|
|
2
|
+
initState: 'init_state',
|
|
3
|
+
changeRangeType: 'change_range_type',
|
|
4
|
+
updateRangeInfo: 'update_range_info',
|
|
5
|
+
updateRangeValue: 'update_range_value',
|
|
6
|
+
changeAutoUpdateTo: 'change_auto_update_to',
|
|
7
|
+
togglePopover: 'toggle_popover',
|
|
8
|
+
apply: 'apply',
|
|
9
|
+
resetValue: 'reset_value',
|
|
10
|
+
};
|
|
11
|
+
export const changeRangeType = (rangeType, callback) => ({
|
|
12
|
+
type: ACTION_TYPES.changeRangeType,
|
|
13
|
+
payload: { rangeType, callback },
|
|
14
|
+
});
|
|
15
|
+
export const updateRangeInfo = (updateValue) => ({
|
|
16
|
+
type: ACTION_TYPES.updateRangeInfo,
|
|
17
|
+
payload: { updateValue },
|
|
18
|
+
});
|
|
19
|
+
export const updateRangeValue = (rangeValue, options) => ({
|
|
20
|
+
type: ACTION_TYPES.updateRangeValue,
|
|
21
|
+
payload: { rangeValue, options },
|
|
22
|
+
});
|
|
23
|
+
export const changeAutoUpdateTo = (value) => ({
|
|
24
|
+
type: ACTION_TYPES.changeAutoUpdateTo,
|
|
25
|
+
payload: value,
|
|
26
|
+
});
|
|
27
|
+
export const initState = (initData, needTriggerOut = false) => ({
|
|
28
|
+
type: ACTION_TYPES.initState,
|
|
29
|
+
payload: { initData, needTriggerOut },
|
|
30
|
+
});
|
|
31
|
+
export const togglePopover = () => ({
|
|
32
|
+
type: ACTION_TYPES.togglePopover,
|
|
33
|
+
});
|
|
34
|
+
export const apply = () => ({
|
|
35
|
+
type: ACTION_TYPES.apply,
|
|
36
|
+
});
|
|
37
|
+
export const resetValue = () => ({
|
|
38
|
+
type: ACTION_TYPES.resetValue,
|
|
39
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Select } from '@antscorp/antsomi-ui/es/components/molecules/Select';
|
|
3
|
+
import { updateRangeInfo } from '../../actions';
|
|
4
|
+
import { AUTO_UPDATE_TO_KEY, AUTO_UPDATE_TO_OPTIONS, SELECTION_KEY } from '../../constants';
|
|
5
|
+
import { useCalendarSelectionContext } from '../../hooks';
|
|
6
|
+
import { isAutoUpdateToOption } from '../../utils';
|
|
7
|
+
import { StyledAutoUpdateToRoot } from './styled';
|
|
8
|
+
export const AutoUpdateTo = props => {
|
|
9
|
+
const { className, id } = props;
|
|
10
|
+
const { state, action } = useCalendarSelectionContext();
|
|
11
|
+
const { rangeInfo } = state.value.current;
|
|
12
|
+
const value = AUTO_UPDATE_TO_OPTIONS[rangeInfo.type === 'custom' ? rangeInfo.autoUpdateTo : AUTO_UPDATE_TO_KEY.fixed].label;
|
|
13
|
+
const handleChangeUpdateTo = (value) => {
|
|
14
|
+
if (!isAutoUpdateToOption(value))
|
|
15
|
+
return;
|
|
16
|
+
action.dispatch(updateRangeInfo({
|
|
17
|
+
type: SELECTION_KEY.custom,
|
|
18
|
+
autoUpdateTo: value,
|
|
19
|
+
}));
|
|
20
|
+
};
|
|
21
|
+
return (React.createElement(StyledAutoUpdateToRoot, { className: className },
|
|
22
|
+
React.createElement("div", { className: "label" }, "Auto update to"),
|
|
23
|
+
React.createElement(Select, { id: id, options: Object.values(AUTO_UPDATE_TO_OPTIONS).map(i => (Object.assign(Object.assign({}, i), { value: i.key }))), value: value, onChange: handleChangeUpdateTo })));
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AutoUpdateTo';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AutoUpdateTo';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const StyledAutoUpdateToRoot: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/* eslint-disable react/no-array-index-key */
|
|
2
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { TinyColor } from '@ctrl/tinycolor';
|
|
4
|
+
import { RangePicker } from '../RangePicker';
|
|
5
|
+
import { useCalendarSelectionContext } from '../../hooks';
|
|
6
|
+
import dayjs from 'dayjs';
|
|
7
|
+
import isBetween from 'dayjs/plugin/isBetween';
|
|
8
|
+
import { AutoUpdateTo } from '../AutoUpdateTo';
|
|
9
|
+
import { updateRangeValue } from '../../actions';
|
|
10
|
+
import { CalendarContainerStyled, StyledCellDate, StyledCustomPickerRoot } from './styled';
|
|
11
|
+
import { ConfigProvider } from 'antd';
|
|
12
|
+
import { interpolateHsl } from 'd3-interpolate';
|
|
13
|
+
import { isEmpty } from 'lodash';
|
|
14
|
+
dayjs.extend(isBetween);
|
|
15
|
+
const generateRangeInputLabel = (idx, label) => {
|
|
16
|
+
if (label)
|
|
17
|
+
return label;
|
|
18
|
+
if (idx === 0)
|
|
19
|
+
return 'custom';
|
|
20
|
+
return `custom compare${idx > 1 ? ` ${idx}}` : ''}`;
|
|
21
|
+
};
|
|
22
|
+
export const CustomPicker = () => {
|
|
23
|
+
const popupContainer = useRef(null);
|
|
24
|
+
const { state, action } = useCalendarSelectionContext();
|
|
25
|
+
const { rangeValue } = state.value.current;
|
|
26
|
+
const [activeRangeIdx, setActiveRangeIdx] = useState(null);
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (rangeValue.length > 0) {
|
|
29
|
+
setActiveRangeIdx(0);
|
|
30
|
+
}
|
|
31
|
+
}, [rangeValue.length]);
|
|
32
|
+
const handleCalendarChange = (start, end) => {
|
|
33
|
+
var _a, _b;
|
|
34
|
+
if (!start || !end || activeRangeIdx === null)
|
|
35
|
+
return;
|
|
36
|
+
const replacedRange = rangeValue[activeRangeIdx];
|
|
37
|
+
if (((_a = replacedRange.start) === null || _a === void 0 ? void 0 : _a.isSame(start)) && ((_b = replacedRange.end) === null || _b === void 0 ? void 0 : _b.isSame(end)))
|
|
38
|
+
return;
|
|
39
|
+
const updatedRangeValue = [...rangeValue];
|
|
40
|
+
updatedRangeValue.splice(activeRangeIdx, 1, Object.assign(Object.assign({}, replacedRange), { start,
|
|
41
|
+
end }));
|
|
42
|
+
action.dispatch(updateRangeValue(updatedRangeValue, { isManual: true }));
|
|
43
|
+
};
|
|
44
|
+
const renderCellDate = useCallback((date, originNode) => {
|
|
45
|
+
const colors = rangeValue.reduce((acc, cur) => {
|
|
46
|
+
if (date.isBetween(cur.start, cur.end, 'd', '[]') && cur.color) {
|
|
47
|
+
acc.push(cur.color);
|
|
48
|
+
}
|
|
49
|
+
return acc;
|
|
50
|
+
}, []);
|
|
51
|
+
if (isEmpty(colors))
|
|
52
|
+
return originNode;
|
|
53
|
+
const cellBgColor = new TinyColor(colors.length > 1
|
|
54
|
+
? colors.reduce((acc, color) => interpolateHsl(acc, color)(0.5), colors[0])
|
|
55
|
+
: colors[0]);
|
|
56
|
+
return React.createElement(StyledCellDate, { rangeColor: cellBgColor }, originNode);
|
|
57
|
+
}, [rangeValue]);
|
|
58
|
+
return (React.createElement(StyledCustomPickerRoot, null,
|
|
59
|
+
React.createElement("div", { className: "range-inputs" }, rangeValue.map((range, rangeIdx) => (React.createElement(ConfigProvider, { key: rangeIdx, theme: {
|
|
60
|
+
components: {
|
|
61
|
+
DatePicker: Object.assign({ cellHeight: 20 }, (range.color && {
|
|
62
|
+
hoverBorderColor: range.color,
|
|
63
|
+
colorBorder: range.color,
|
|
64
|
+
colorPrimary: range.color,
|
|
65
|
+
colorPrimaryActive: range.color,
|
|
66
|
+
cellActiveWithRangeBg: new TinyColor(range.color).lighten(40).toHexString(),
|
|
67
|
+
})),
|
|
68
|
+
},
|
|
69
|
+
} },
|
|
70
|
+
React.createElement("div", { className: "range-input" },
|
|
71
|
+
React.createElement("div", { className: "range-input-label" }, generateRangeInputLabel(rangeIdx, range.label)),
|
|
72
|
+
React.createElement(RangePicker, { open: true, value: [range.start, range.end], onClick: () => setActiveRangeIdx(rangeIdx), getPopupContainer: () => popupContainer.current || document.body, panelRender: originalPanel => {
|
|
73
|
+
if (activeRangeIdx !== rangeIdx)
|
|
74
|
+
return null;
|
|
75
|
+
return originalPanel;
|
|
76
|
+
}, cellRender: (current, info) => {
|
|
77
|
+
if (typeof current === 'number' || info.type !== 'date') {
|
|
78
|
+
return info.originNode;
|
|
79
|
+
}
|
|
80
|
+
return renderCellDate(current, info.originNode);
|
|
81
|
+
}, onCalendarChange: value => {
|
|
82
|
+
var _a, _b;
|
|
83
|
+
const start = dayjs((_a = value === null || value === void 0 ? void 0 : value.at(0)) === null || _a === void 0 ? void 0 : _a.toDate());
|
|
84
|
+
const end = dayjs((_b = value === null || value === void 0 ? void 0 : value.at(1)) === null || _b === void 0 ? void 0 : _b.toDate());
|
|
85
|
+
handleCalendarChange(start, end);
|
|
86
|
+
} })))))),
|
|
87
|
+
React.createElement(AutoUpdateTo, null),
|
|
88
|
+
React.createElement(CalendarContainerStyled, { className: "calendar-container", ref: popupContainer })));
|
|
89
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CustomPicker';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CustomPicker';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { TinyColor } from '@ctrl/tinycolor';
|
|
2
|
+
export declare const StyledCellDate: import("styled-components").StyledComponent<"div", any, {
|
|
3
|
+
rangeColor: TinyColor;
|
|
4
|
+
}, never>;
|
|
5
|
+
export declare const StyledCustomPickerRoot: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
6
|
+
export declare const CalendarContainerStyled: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
export const StyledCellDate = styled.div `
|
|
3
|
+
--cellTextColor: ${p => (p.rangeColor.isLight() ? '#000' : '#fff')};
|
|
4
|
+
--cellBgColor: ${p => p.rangeColor.lighten(40).toHexString()};
|
|
5
|
+
--cellHoverBgColor: ${p => p.rangeColor.lighten(30).toHexString()};
|
|
6
|
+
--rangeColor: ${p => p.rangeColor.toHexString()};
|
|
7
|
+
|
|
8
|
+
position: relative;
|
|
9
|
+
|
|
10
|
+
&:before {
|
|
11
|
+
position: absolute;
|
|
12
|
+
top: 0;
|
|
13
|
+
left: 0;
|
|
14
|
+
height: 100%;
|
|
15
|
+
width: 100%;
|
|
16
|
+
content: '';
|
|
17
|
+
}
|
|
18
|
+
`;
|
|
19
|
+
export const StyledCustomPickerRoot = styled.div `
|
|
20
|
+
display: flex;
|
|
21
|
+
flex-direction: column;
|
|
22
|
+
gap: 8px;
|
|
23
|
+
padding: 8px 12px;
|
|
24
|
+
|
|
25
|
+
.range-inputs {
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-direction: column;
|
|
28
|
+
gap: 8px;
|
|
29
|
+
|
|
30
|
+
.range-input {
|
|
31
|
+
display: flex;
|
|
32
|
+
flex-direction: column;
|
|
33
|
+
gap: 4px;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.custom-label,
|
|
38
|
+
.range-inputs .range-input-label {
|
|
39
|
+
font-weight: bold;
|
|
40
|
+
text-transform: uppercase;
|
|
41
|
+
color: #838383;
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
44
|
+
export const CalendarContainerStyled = styled.div `
|
|
45
|
+
/* Variables */
|
|
46
|
+
--cellHeight: 28px;
|
|
47
|
+
--cellWidth: 28px;
|
|
48
|
+
--colorToDay: rgb(211, 211, 211);
|
|
49
|
+
--colorSelected: rgb(0, 94, 184);
|
|
50
|
+
--colorInRange: rgb(216, 234, 252);
|
|
51
|
+
|
|
52
|
+
position: relative;
|
|
53
|
+
|
|
54
|
+
.antsomi-picker-dropdown {
|
|
55
|
+
position: relative;
|
|
56
|
+
top: 0 !important;
|
|
57
|
+
left: 0 !important;
|
|
58
|
+
box-shadow: none;
|
|
59
|
+
padding: 0;
|
|
60
|
+
|
|
61
|
+
.antsomi-picker-panel-container {
|
|
62
|
+
box-shadow: none;
|
|
63
|
+
}
|
|
64
|
+
.antsomi-picker-panels {
|
|
65
|
+
display: inline-flex;
|
|
66
|
+
flex-direction: column;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/* Content */
|
|
70
|
+
.antsomi-picker-content {
|
|
71
|
+
/* Rectangle */
|
|
72
|
+
& td,
|
|
73
|
+
& th,
|
|
74
|
+
& .antsomi-picker-cell-inner,
|
|
75
|
+
& td::before {
|
|
76
|
+
/* width: var(--cellWidth);
|
|
77
|
+
height: var(--cellHeight); */
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/* Date node */
|
|
81
|
+
.antsomi-picker-cell-inner {
|
|
82
|
+
height: 21.5px;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* Today node */
|
|
86
|
+
.antsomi-picker-cell-today {
|
|
87
|
+
.antsomi-picker-cell-inner {
|
|
88
|
+
&::before {
|
|
89
|
+
border-radius: 18px;
|
|
90
|
+
border: 0.0001rem solid var(--colorToDay);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/* Selected node */
|
|
96
|
+
.antsomi-picker-cell-in-view {
|
|
97
|
+
&.antsomi-picker-cell-selected,
|
|
98
|
+
&.antsomi-picker-cell-range-start,
|
|
99
|
+
&.antsomi-picker-cell-range-end {
|
|
100
|
+
.antsomi-picker-cell-inner {
|
|
101
|
+
background: var(--colorSelected) !important;
|
|
102
|
+
border-radius: 18px !important;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/* In Range */
|
|
108
|
+
.antsomi-picker-cell-in-range.antsomi-picker-cell-in-view {
|
|
109
|
+
&::before {
|
|
110
|
+
background: var(--colorInRange) !important;
|
|
111
|
+
}
|
|
112
|
+
.antsomi-picker-cell-inner {
|
|
113
|
+
background: var(--colorInRange) !important;
|
|
114
|
+
&::after {
|
|
115
|
+
content: none;
|
|
116
|
+
background: var(--colorInRange) !important;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/* In Range Start End */
|
|
122
|
+
.antsomi-picker-cell-in-view.antsomi-picker-cell-range-start:not(
|
|
123
|
+
.antsomi-picker-cell-range-start-single
|
|
124
|
+
) {
|
|
125
|
+
&::before {
|
|
126
|
+
background: var(--colorInRange) !important;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
.antsomi-picker-cell-in-view.antsomi-picker-cell-range-end:not(
|
|
130
|
+
.antsomi-picker-cell-range-end-single
|
|
131
|
+
) {
|
|
132
|
+
&::before {
|
|
133
|
+
background: var(--colorInRange) !important;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
.antsomi-picker-range-arrow {
|
|
138
|
+
display: none !important;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type CustomPickerProps = {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Button } from '@antscorp/antsomi-ui/es/components/atoms/Button';
|
|
3
|
+
import { useCalendarSelectionContext } from '../../hooks';
|
|
4
|
+
import { apply, togglePopover } from '../../actions';
|
|
5
|
+
import { StyledFooterRoot } from './styled';
|
|
6
|
+
export const Footer = () => {
|
|
7
|
+
const { action } = useCalendarSelectionContext();
|
|
8
|
+
return (React.createElement(StyledFooterRoot, null,
|
|
9
|
+
React.createElement(Button, { onClick: () => action.dispatch(apply()), type: "primary" }, "Apply"),
|
|
10
|
+
React.createElement(Button, { onClick: () => action.dispatch(togglePopover()) }, "Cancel")));
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Footer';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Footer';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const StyledFooterRoot: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyledRangePicker } from './styled';
|
|
3
|
+
const DATE_FORMAT = 'DD/MM/YYYY';
|
|
4
|
+
export const RangePicker = props => (React.createElement(StyledRangePicker, Object.assign({}, props, { allowEmpty: [true, true], allowClear: false, autoFocus: false, size: "large", suffixIcon: false, format: DATE_FORMAT })));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './RangePicker';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './RangePicker';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const StyledRangePicker: import("styled-components").StyledComponent<import("antd/es/date-picker/generatePicker/interface").PickerComponentClass<import("antd/es/date-picker/generatePicker").RangePickerProps<import("dayjs").Dayjs> & {
|
|
2
|
+
dropdownClassName?: string | undefined;
|
|
3
|
+
popupClassName?: string | undefined;
|
|
4
|
+
rootClassName?: string | undefined;
|
|
5
|
+
}, unknown>, any, {}, never>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DatePicker } from '@antscorp/antsomi-ui/es/components/molecules';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
const { RangePicker } = DatePicker;
|
|
4
|
+
export const StyledRangePicker = styled(RangePicker) `
|
|
5
|
+
font-size: 12px;
|
|
6
|
+
padding-right: 8px;
|
|
7
|
+
|
|
8
|
+
.ant-picker-input {
|
|
9
|
+
input {
|
|
10
|
+
width: 80px;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
`;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { RANGE_SELECTION_OPTIONS, RANGE_TIME, SELECTION_KEY } from '../../constants';
|
|
3
|
+
import { Divider } from '@antscorp/antsomi-ui/es/components/atoms';
|
|
4
|
+
import { List } from 'antd';
|
|
5
|
+
import { NumOfDaysRanges, Option } from './components';
|
|
6
|
+
import { RangeSelectOptionsRoot } from './styled';
|
|
7
|
+
const customOption = RANGE_SELECTION_OPTIONS[SELECTION_KEY.custom];
|
|
8
|
+
const baseOptions = RANGE_TIME.map(key => {
|
|
9
|
+
var _a;
|
|
10
|
+
const option = RANGE_SELECTION_OPTIONS[key];
|
|
11
|
+
return {
|
|
12
|
+
key,
|
|
13
|
+
type: key,
|
|
14
|
+
label: option.label.trim(),
|
|
15
|
+
options: ((_a = option.options) === null || _a === void 0 ? void 0 : _a.map(i => (Object.assign(Object.assign({}, i), { type: i.key })))) || [],
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
export const RangeSelectOptions = () => (React.createElement(RangeSelectOptionsRoot, null,
|
|
19
|
+
React.createElement(List, { dataSource: [customOption], renderItem: item => React.createElement(Option, { type: item.key, label: item.label }) }),
|
|
20
|
+
React.createElement(Divider, { style: { marginTop: 4, marginBottom: 4 } }),
|
|
21
|
+
React.createElement(List, { dataSource: baseOptions, renderItem: item => React.createElement(Option, { type: item.key, label: item.label, options: item.options }) }),
|
|
22
|
+
React.createElement(Divider, { style: { marginTop: 4, marginBottom: 4 } }),
|
|
23
|
+
React.createElement(NumOfDaysRanges, null)));
|