@antscorp/antsomi-ui 1.3.5-beta.57 → 1.3.5-beta.59
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/images/profile.png +0 -0
- package/es/assets/images/stars_slider.png +0 -0
- package/es/assets/images/tail.png +0 -0
- package/es/components/atoms/MobileFrame/MobileFrame.d.ts +2 -0
- package/es/components/atoms/MobileFrame/MobileFrame.js +1 -1
- package/es/components/atoms/MobileFrame/styled.d.ts +2 -1
- package/es/components/atoms/MobileFrame/styled.js +11 -6
- package/es/components/atoms/Popover/styled.d.ts +4 -0
- package/es/components/atoms/Popover/styled.js +5 -0
- package/es/components/atoms/RateV2/RateV2.d.ts +18 -0
- package/es/components/atoms/RateV2/RateV2.js +73 -0
- package/es/components/atoms/RateV2/index.d.ts +1 -0
- package/es/components/atoms/RateV2/index.js +1 -0
- package/es/components/atoms/Slider/index.js +8 -3
- package/es/components/atoms/SliderV2/index.d.ts +3 -2
- package/es/components/atoms/SliderV2/index.js +9 -11
- package/es/components/atoms/index.d.ts +1 -0
- package/es/components/atoms/index.js +1 -0
- package/es/components/common/ConfigProvider/GlobalStyle.js +75 -15
- 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 +108 -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/CustomPicker/types.js +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 +98 -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 +20 -16
- package/es/components/molecules/DatePicker/components/AdvancedPicker/styled.d.ts +3 -0
- package/es/components/molecules/DatePicker/components/AdvancedPicker/styled.js +23 -0
- package/es/components/molecules/DatePicker/components/AdvancedPicker/utils.d.ts +1 -1
- package/es/components/molecules/DatePicker/components/AdvancedRangePicker/AdvancedRangePicker.d.ts +1 -0
- package/es/components/molecules/DatePicker/components/AdvancedRangePicker/AdvancedRangePicker.js +3 -3
- package/es/components/molecules/FontSetting/index.js +1 -1
- package/es/components/molecules/RichMenu/RichMenuBlock/constants.js +1 -1
- package/es/components/molecules/RichMenu/RichMenuChatBar/RichMenuChatBar.d.ts +1 -0
- package/es/components/molecules/RichMenu/RichMenuChatBar/RichMenuChatBar.js +4 -3
- package/es/components/molecules/RichMenu/RichMenuChatBar/styled.d.ts +1 -0
- package/es/components/molecules/RichMenu/RichMenuChatBar/styled.js +1 -1
- package/es/components/molecules/RichMenu/RichMenuMobileView/RichMenuMobileView.d.ts +6 -0
- package/es/components/molecules/RichMenu/RichMenuMobileView/RichMenuMobileView.js +24 -5
- package/es/components/molecules/RichMenu/RichMenuMobileView/styled.d.ts +5 -0
- package/es/components/molecules/RichMenu/RichMenuMobileView/styled.js +31 -0
- package/es/components/molecules/TemplateSaveAs/hooks/useTemplateSave.js +1 -0
- package/es/components/molecules/UploadImage/MediaThumb.d.ts +8 -0
- package/es/components/molecules/UploadImage/MediaThumb.js +15 -0
- package/es/components/molecules/UploadImage/VideoThumbnail.d.ts +4 -0
- package/es/components/molecules/UploadImage/VideoThumbnail.js +43 -0
- package/es/components/molecules/UploadImage/index.js +2 -1
- package/es/components/molecules/index.d.ts +2 -1
- package/es/components/molecules/index.js +2 -1
- package/es/components/organism/GenerativeInsights/constants.d.ts +1 -0
- package/es/components/organism/GenerativeInsights/constants.js +1 -0
- package/es/components/organism/GenerativeInsights/index.d.ts +11 -0
- package/es/components/organism/GenerativeInsights/index.js +57 -0
- package/es/components/organism/GenerativeInsights/styled.d.ts +12 -0
- package/es/components/organism/GenerativeInsights/styled.js +66 -0
- package/es/components/organism/GenerativeInsights/utils.d.ts +13 -0
- package/es/components/organism/GenerativeInsights/utils.js +50 -0
- package/es/components/organism/Help/Help.js +30 -1
- package/es/components/organism/index.d.ts +1 -0
- package/es/components/organism/index.js +1 -0
- package/es/components/template/TemplateListing/hooks/useTemplateListing.js +1 -0
- package/es/services/TemplateListing/index.d.ts +1 -0
- package/es/test.js +168 -116
- package/es/utils/common.d.ts +1 -0
- package/es/utils/common.js +3 -0
- package/package.json +1 -2
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -16,7 +16,7 @@ import { MobileWrapper, MobileInner, MobileBottomLine } from './styled';
|
|
|
16
16
|
export const MobileFrame = (_a) => {
|
|
17
17
|
var { children } = _a, restOfProps = __rest(_a, ["children"]);
|
|
18
18
|
return (React.createElement(MobileWrapper, Object.assign({}, restOfProps),
|
|
19
|
-
React.createElement(MobileInner,
|
|
19
|
+
React.createElement(MobileInner, { backgroundColor: restOfProps.backgroundColor, size: restOfProps.size },
|
|
20
20
|
children,
|
|
21
21
|
React.createElement(MobileBottomLine, null))));
|
|
22
22
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { MobileFrameProps } from './MobileFrame';
|
|
1
2
|
export declare const MobileWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
2
|
-
export declare const MobileInner: import("styled-components").StyledComponent<"div", any,
|
|
3
|
+
export declare const MobileInner: import("styled-components").StyledComponent<"div", any, MobileFrameProps, never>;
|
|
3
4
|
export declare const MobileBottomLine: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Libraries
|
|
2
|
-
import styled from 'styled-components';
|
|
2
|
+
import styled, { css } from 'styled-components';
|
|
3
3
|
// Assets
|
|
4
4
|
import MobileFrame from '@antscorp/antsomi-ui/es/assets/images/iphone.png';
|
|
5
5
|
export const MobileWrapper = styled.div `
|
|
@@ -12,12 +12,17 @@ export const MobileWrapper = styled.div `
|
|
|
12
12
|
export const MobileInner = styled.div `
|
|
13
13
|
position: relative;
|
|
14
14
|
width: 100%;
|
|
15
|
-
max-width:
|
|
16
|
-
height:
|
|
17
|
-
margin: 61px 23px 20px 24px;
|
|
18
|
-
border-bottom-left-radius:
|
|
19
|
-
border-bottom-right-radius:
|
|
15
|
+
max-width: ${props => (props.size === 'medium' ? 290 : 336)}px;
|
|
16
|
+
height: ${props => (props.size === 'medium' ? 600 : 695)}px;
|
|
17
|
+
margin: ${props => (props.size === 'medium' ? '52px 23px 18px 24px' : '61px 23px 20px 24px')};
|
|
18
|
+
border-bottom-left-radius: ${props => (props.size === 'medium' ? 37 : 50)}px;
|
|
19
|
+
border-bottom-right-radius: ${props => (props.size === 'medium' ? 37 : 50)}px;
|
|
20
20
|
overflow: hidden;
|
|
21
|
+
|
|
22
|
+
${props => props.backgroundColor &&
|
|
23
|
+
css `
|
|
24
|
+
background-color: ${props.backgroundColor};
|
|
25
|
+
`}
|
|
21
26
|
`;
|
|
22
27
|
export const MobileBottomLine = styled.div `
|
|
23
28
|
width: 145px;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const PopoverWrapper: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd").PopoverProps & import("react").RefAttributes<unknown>> & {
|
|
3
|
+
_InternalPanelDoNotUseOrYouWillBeFired: import("react").FC<import("antd/es/popover/PurePanel").PurePanelProps>;
|
|
4
|
+
}, any, {}, never>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface RateContinuousProps {
|
|
3
|
+
count?: number;
|
|
4
|
+
className?: string;
|
|
5
|
+
defaultValue?: number;
|
|
6
|
+
/**
|
|
7
|
+
* @description number of star
|
|
8
|
+
*/
|
|
9
|
+
value?: number;
|
|
10
|
+
type?: 'full' | 'half' | 'continuous';
|
|
11
|
+
/**
|
|
12
|
+
* @param value current number of stars are selected
|
|
13
|
+
* @description number of stars = fillWidth / STAR_WIDTH
|
|
14
|
+
*/
|
|
15
|
+
onChange?: (value: number) => void;
|
|
16
|
+
}
|
|
17
|
+
export declare const RateV2: React.FC<RateContinuousProps>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import StarImage from '@antscorp/antsomi-ui/es/assets/images/stars_slider.png';
|
|
3
|
+
const STAR_WIDTH = 30;
|
|
4
|
+
const parseNumDecimals = (input, decimals) => +Number.parseFloat(input === null || input === void 0 ? void 0 : input.toString()).toFixed(decimals);
|
|
5
|
+
const roundHalf = (num) => {
|
|
6
|
+
const multiplier = 1 / 0.5;
|
|
7
|
+
return Math.round(num * multiplier) / multiplier;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @param width width measure from the left edge of star container
|
|
12
|
+
* @param type type of star - 'full' | 'half' | 'continuous'
|
|
13
|
+
* @default type 'full'
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
const getWidth = (width, type = 'full') => {
|
|
17
|
+
const numberOfStar = width / STAR_WIDTH;
|
|
18
|
+
return type === 'full'
|
|
19
|
+
? Math.ceil(numberOfStar) * STAR_WIDTH
|
|
20
|
+
: type === 'half'
|
|
21
|
+
? roundHalf(numberOfStar) * STAR_WIDTH
|
|
22
|
+
: width;
|
|
23
|
+
};
|
|
24
|
+
export const RateV2 = ({ count = 5, className, defaultValue = 0, value, type = 'full', onChange, }) => {
|
|
25
|
+
const fullWidth = count * STAR_WIDTH;
|
|
26
|
+
// The width is calculated when move mouse => change the UI, not change the real value
|
|
27
|
+
const [fillWidth, setFillWidth] = useState(() => defaultValue ? getWidth(defaultValue * STAR_WIDTH, type) : 0);
|
|
28
|
+
// The real current value that will be return to parent component by onChange function
|
|
29
|
+
// currWidth = value * STAR_WIDTH
|
|
30
|
+
const [currWidth, setCurrWidth] = useState(0);
|
|
31
|
+
const handleMouseMove = e => {
|
|
32
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
33
|
+
const x = e.clientX - rect.left;
|
|
34
|
+
const hoverWidth = Math.round(x);
|
|
35
|
+
setFillWidth(getWidth(hoverWidth, type));
|
|
36
|
+
};
|
|
37
|
+
const handleClick = () => {
|
|
38
|
+
// If have no value => auto set current value; if have value => must control value with onChange props
|
|
39
|
+
if (!value)
|
|
40
|
+
setCurrWidth(fillWidth);
|
|
41
|
+
if (onChange)
|
|
42
|
+
onChange(parseNumDecimals(fillWidth / STAR_WIDTH, 2));
|
|
43
|
+
};
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (typeof value === 'number') {
|
|
46
|
+
const width = getWidth(value * STAR_WIDTH, type);
|
|
47
|
+
setCurrWidth(width);
|
|
48
|
+
setFillWidth(width);
|
|
49
|
+
}
|
|
50
|
+
}, [value]);
|
|
51
|
+
return (React.createElement("div", { className: `antsomi-rate-continuous${className ? ` ${className}` : ''}`, style: {
|
|
52
|
+
position: 'relative',
|
|
53
|
+
width: `${fullWidth}px`,
|
|
54
|
+
backgroundPosition: '-27px',
|
|
55
|
+
height: '28px',
|
|
56
|
+
}, onMouseMove: handleMouseMove, onMouseLeave: () => setFillWidth(currWidth || 0), onClick: handleClick },
|
|
57
|
+
React.createElement("div", { className: "custom-rate custom-rate--fill", style: {
|
|
58
|
+
position: 'absolute',
|
|
59
|
+
background: `url(${StarImage}) 0px 0px`,
|
|
60
|
+
width: `${fillWidth}px`,
|
|
61
|
+
height: '26px',
|
|
62
|
+
zIndex: 1,
|
|
63
|
+
} }),
|
|
64
|
+
React.createElement("div", { className: "custom-rate custom-rate--empty", style: {
|
|
65
|
+
position: 'absolute',
|
|
66
|
+
top: '0px',
|
|
67
|
+
left: '0px',
|
|
68
|
+
backgroundImage: 'none',
|
|
69
|
+
background: `transparent url(${StarImage}) 0px -26px`,
|
|
70
|
+
width: `${fullWidth}px`,
|
|
71
|
+
height: '26px',
|
|
72
|
+
} })));
|
|
73
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { RateV2 } from './RateV2';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { RateV2 } from './RateV2';
|
|
@@ -9,15 +9,20 @@ export const Slider = memo(props => {
|
|
|
9
9
|
const { range, value, min = 0, max = 0, className, tooltipVisible } = props;
|
|
10
10
|
const isNegative = useMemo(() => !!(!range && min < 0), [range, min]);
|
|
11
11
|
const calculateWidth = useMemo(() => ((value || 0) * 100) / (Math.abs(max) + Math.abs(min) || 1), [min, max, value]);
|
|
12
|
-
const restProps = tooltipVisible === 'default' ? omit(props, ['tooltipVisible']) : props;
|
|
12
|
+
// const restProps = tooltipVisible === 'default' ? omit(props, ['tooltipVisible']) : props;
|
|
13
|
+
const restProps = omit(props, ['tooltipVisible']);
|
|
13
14
|
if (isNegative) {
|
|
14
15
|
return (React.createElement(SliderWrapper, { isNegative: true, width: calculateWidth, className: className },
|
|
15
|
-
React.createElement(AntdSlider, Object.assign({}, omit(restProps, ['marks', 'className']), {
|
|
16
|
+
React.createElement(AntdSlider, Object.assign({}, omit(restProps, ['marks', 'className']), { tooltip: tooltipVisible !== 'default' && {
|
|
17
|
+
open: tooltipVisible,
|
|
18
|
+
}, marks: {
|
|
16
19
|
0: ' ',
|
|
17
20
|
} }))));
|
|
18
21
|
}
|
|
19
22
|
return (React.createElement(SliderWrapper, { className: className },
|
|
20
|
-
React.createElement(AntdSlider, Object.assign({}, restProps
|
|
23
|
+
React.createElement(AntdSlider, Object.assign({}, restProps, { tooltip: tooltipVisible !== 'default' && {
|
|
24
|
+
open: tooltipVisible,
|
|
25
|
+
} }))));
|
|
21
26
|
});
|
|
22
27
|
Slider.defaultProps = {
|
|
23
28
|
tooltipVisible: false,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { SliderRangeProps, SliderSingleProps } from 'antd/es/slider';
|
|
3
|
-
export interface SliderProps
|
|
3
|
+
export interface SliderProps {
|
|
4
|
+
defaultSliderTrack?: boolean;
|
|
4
5
|
}
|
|
5
|
-
export declare const SliderV2: React.FC<SliderProps | SliderRangeProps>;
|
|
6
|
+
export declare const SliderV2: React.FC<(SliderSingleProps & SliderProps) | (SliderRangeProps & SliderProps)>;
|
|
@@ -4,20 +4,18 @@ import React, { useState } from 'react';
|
|
|
4
4
|
import { Slider as AntdSlider } from 'antd';
|
|
5
5
|
// React.FC<SliderProps>
|
|
6
6
|
export const SliderV2 = props => {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
// const max = props.max || 100;
|
|
11
|
-
const { min, max, onChange, styles, range } = props;
|
|
12
|
-
if (min && max && min < 0 && max > 0 && !range) {
|
|
7
|
+
const { min, max, onChange, styles, range, value, defaultValue, marks, defaultSliderTrack } = props;
|
|
8
|
+
const [valueInternal, setValueInternal] = useState(defaultValue || min || 0);
|
|
9
|
+
if (min && max && min < 0 && max > 0 && !range && !defaultSliderTrack) {
|
|
13
10
|
const sliderWidth = max - min;
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
const calcValue = value || valueInternal;
|
|
12
|
+
const leftTrackPosition = `${(Math.abs(calcValue > 0 ? min : min - calcValue) / sliderWidth) * 100}%`;
|
|
13
|
+
const sliderTrackWidth = `${(Math.abs(calcValue) / sliderWidth) * 100}%`;
|
|
14
|
+
return (React.createElement(AntdSlider, Object.assign({ value: value || valueInternal, onChange: value => {
|
|
15
|
+
setValueInternal(value);
|
|
18
16
|
if (onChange)
|
|
19
17
|
onChange(value);
|
|
20
|
-
}, styles: Object.assign({ track: Object.assign({ left: leftTrackPosition, width: sliderTrackWidth }, styles === null || styles === void 0 ? void 0 : styles.track) }, styles), marks: { 0: ' ' } }, props)));
|
|
18
|
+
}, styles: Object.assign({ track: Object.assign({ left: leftTrackPosition, width: sliderTrackWidth }, styles === null || styles === void 0 ? void 0 : styles.track) }, styles), marks: marks || { 0: ' ' } }, props)));
|
|
21
19
|
}
|
|
22
20
|
return React.createElement(AntdSlider, Object.assign({}, props));
|
|
23
21
|
};
|
|
@@ -33,6 +33,7 @@ export { Rate } from './Rate';
|
|
|
33
33
|
export { SliderV2 } from './SliderV2';
|
|
34
34
|
export { InputDynamic } from './InputDynamic';
|
|
35
35
|
export * from './Flex';
|
|
36
|
+
export * from './RateV2';
|
|
36
37
|
export * from './PreviewTabs';
|
|
37
38
|
export * from './MobileFrame';
|
|
38
39
|
export * from './SlideBar';
|
|
@@ -33,6 +33,7 @@ export { Rate } from './Rate';
|
|
|
33
33
|
export { SliderV2 } from './SliderV2';
|
|
34
34
|
export { InputDynamic } from './InputDynamic';
|
|
35
35
|
export * from './Flex';
|
|
36
|
+
export * from './RateV2';
|
|
36
37
|
export * from './PreviewTabs';
|
|
37
38
|
export * from './MobileFrame';
|
|
38
39
|
export * from './SlideBar';
|
|
@@ -291,25 +291,24 @@ export const GlobalStyle = () => {
|
|
|
291
291
|
}
|
|
292
292
|
}
|
|
293
293
|
|
|
294
|
-
.antsomi-picker-date-panel {
|
|
294
|
+
/* .antsomi-picker-date-panel {
|
|
295
295
|
position: relative;
|
|
296
|
-
}
|
|
296
|
+
} */
|
|
297
297
|
|
|
298
|
-
.antsomi-picker-date-panel::before {
|
|
298
|
+
/* .antsomi-picker-date-panel::before {
|
|
299
299
|
content: 'Hours';
|
|
300
300
|
position: absolute;
|
|
301
301
|
top: 0;
|
|
302
302
|
right: 0;
|
|
303
303
|
transform: translateX(100%);
|
|
304
304
|
width: 61px;
|
|
305
|
-
/* width: 53.5px; */
|
|
306
305
|
font-weight: bold;
|
|
307
306
|
border-right: 1px solid rgba(5, 5, 5, 0.06);
|
|
308
307
|
height: 38px;
|
|
309
308
|
display: flex;
|
|
310
309
|
align-items: center;
|
|
311
310
|
justify-content: center;
|
|
312
|
-
}
|
|
311
|
+
} */
|
|
313
312
|
|
|
314
313
|
.antsomi-picker-time-panel {
|
|
315
314
|
.antsomi-picker-time-panel-column:after {
|
|
@@ -336,43 +335,94 @@ export const GlobalStyle = () => {
|
|
|
336
335
|
display: none;
|
|
337
336
|
}
|
|
338
337
|
|
|
339
|
-
.antsomi-picker-
|
|
338
|
+
.antsomi-picker-time-panel-column {
|
|
339
|
+
width: 60px;
|
|
340
|
+
margin-top: 38px;
|
|
341
|
+
/* margin-top: 0; */
|
|
342
|
+
scrollbar-width: unset;
|
|
343
|
+
scrollbar-color: unset;
|
|
344
|
+
|
|
345
|
+
&::-webkit-scrollbar {
|
|
346
|
+
width: 6px;
|
|
347
|
+
background: transparent;
|
|
348
|
+
}
|
|
349
|
+
&::-webkit-scrollbar-track {
|
|
350
|
+
/* margin-top: 38px; */
|
|
351
|
+
border-radius: 10px;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/* ul.antsomi-picker-time-panel-column::before {
|
|
356
|
+
content: '';
|
|
357
|
+
position: absolute;
|
|
358
|
+
background: red;
|
|
359
|
+
top: 0;
|
|
360
|
+
right: 0;
|
|
361
|
+
width: 1px;
|
|
362
|
+
bottom: 0;
|
|
363
|
+
} */
|
|
364
|
+
|
|
365
|
+
/* .antsomi-picker-time-panel-column::before {
|
|
366
|
+
content: 'Hours';
|
|
367
|
+
position: sticky;
|
|
368
|
+
display: block;
|
|
369
|
+
top: 0;
|
|
370
|
+
height: 38px;
|
|
371
|
+
line-height: 38px;
|
|
372
|
+
text-align: center;
|
|
373
|
+
font-weight: bold;
|
|
374
|
+
background-color: #fff;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
.antsomi-picker-time-panel-column:nth-child(1)::before {
|
|
378
|
+
content: 'Hours';
|
|
379
|
+
}
|
|
380
|
+
.antsomi-picker-time-panel-column:nth-child(2)::before {
|
|
381
|
+
content: 'Minutes';
|
|
382
|
+
}
|
|
383
|
+
.antsomi-picker-time-panel-column:nth-child(3)::before {
|
|
384
|
+
content: 'Seconds';
|
|
385
|
+
} */
|
|
386
|
+
|
|
387
|
+
/* .antsomi-picker-content {
|
|
340
388
|
position: relative;
|
|
341
389
|
|
|
342
390
|
.antsomi-picker-time-panel-column {
|
|
343
391
|
margin-top: 38px;
|
|
344
392
|
width: 60px;
|
|
345
393
|
}
|
|
394
|
+
} */
|
|
395
|
+
|
|
396
|
+
.antsomi-picker-content {
|
|
397
|
+
position: relative;
|
|
346
398
|
}
|
|
347
399
|
|
|
348
|
-
.antsomi-picker-content::after,
|
|
400
|
+
/* .antsomi-picker-content::after,
|
|
349
401
|
.antsomi-picker-content::before {
|
|
350
402
|
content: 'Minutes';
|
|
351
403
|
position: absolute;
|
|
352
404
|
top: 0;
|
|
353
405
|
left: 61px;
|
|
354
|
-
/* left: 53.5px; */
|
|
355
406
|
width: 60px;
|
|
356
|
-
/* width: 52.5px; */
|
|
357
407
|
height: 38px;
|
|
358
408
|
display: flex;
|
|
359
409
|
align-items: center;
|
|
360
410
|
justify-content: center;
|
|
361
411
|
font-weight: bold;
|
|
362
|
-
}
|
|
412
|
+
} */
|
|
363
413
|
|
|
364
|
-
.antsomi-picker-content::before {
|
|
414
|
+
/* .antsomi-picker-content::before {
|
|
365
415
|
border-right: 1px solid rgba(5, 5, 5, 0.06);
|
|
366
|
-
}
|
|
367
|
-
.antsomi-picker-content::after {
|
|
416
|
+
} */
|
|
417
|
+
/* .antsomi-picker-content::after {
|
|
368
418
|
content: 'Seconds';
|
|
369
419
|
left: 120px;
|
|
370
|
-
}
|
|
420
|
+
} */
|
|
371
421
|
}
|
|
372
422
|
|
|
373
423
|
/* Custom css scrollbar */
|
|
374
424
|
ul {
|
|
375
|
-
padding-left:
|
|
425
|
+
padding-left: 6px;
|
|
376
426
|
scrollbar-gutter: stable;
|
|
377
427
|
}
|
|
378
428
|
}
|
|
@@ -415,6 +465,16 @@ export const GlobalStyle = () => {
|
|
|
415
465
|
content: 'Hours';
|
|
416
466
|
border: none;
|
|
417
467
|
left: 0;
|
|
468
|
+
|
|
469
|
+
position: absolute;
|
|
470
|
+
top: 0;
|
|
471
|
+
/* left: 61px; */
|
|
472
|
+
width: 60px;
|
|
473
|
+
height: 38px;
|
|
474
|
+
display: flex;
|
|
475
|
+
align-items: center;
|
|
476
|
+
justify-content: center;
|
|
477
|
+
font-weight: bold;
|
|
418
478
|
}
|
|
419
479
|
}
|
|
420
480
|
&.is-minutes-picker {
|
|
@@ -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, StyledPopoverContainer } from './styled';
|
|
7
|
+
import { CustomPicker, Footer, RangeSelectOptions, TimeRangeDisplay } from './components';
|
|
8
|
+
import { LOCAL_TIMEZONE, RANGE_LIMIT } from './constants';
|
|
9
|
+
import { initState, resetValue } from './actions';
|
|
10
|
+
import { useTriggerOut } from './hooks/useTriggerOut';
|
|
11
|
+
export const CalendarSelection = props => {
|
|
12
|
+
const initialed = useRef(false);
|
|
13
|
+
const { value, rangeLimit = RANGE_LIMIT, timezone = LOCAL_TIMEZONE, timeDisplayProps, popoverProps, rangePickerProps, 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(StyledPopoverContainer, 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, Object.assign({}, rangePickerProps))),
|
|
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, Object.assign({}, timeDisplayProps))))));
|
|
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>;
|