d2coreui 21.0.11 → 21.0.12
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/components/color/colorPicker.d.ts +20 -0
- package/components/color/colorPicker.js +54 -0
- package/components/color/colorPicker.js.map +1 -0
- package/components/color/colorUtils.d.ts +2 -0
- package/components/color/colorUtils.js +29 -0
- package/components/color/colorUtils.js.map +1 -1
- package/components/date/dateRangeInput.d.ts +13 -1
- package/components/date/dateRangeInput.js +100 -9
- package/components/date/dateRangeInput.js.map +1 -1
- package/components/date/dateRangeInputAdvancedPanel.d.ts +26 -0
- package/components/date/dateRangeInputAdvancedPanel.js +116 -0
- package/components/date/dateRangeInputAdvancedPanel.js.map +1 -0
- package/components/date/dateRangeInputConfirm.d.ts +11 -1
- package/components/date/dateRangeInputConfirm.js +67 -27
- package/components/date/dateRangeInputConfirm.js.map +1 -1
- package/components/date/dateTimeInput.d.ts +2 -0
- package/components/date/dateTimeInput.js +5 -5
- package/components/date/dateTimeInput.js.map +1 -1
- package/components/grid/cell/simpleStatusTextCellEditor.d.ts +1 -0
- package/components/grid/cell/simpleStatusTextCellEditor.js +17 -10
- package/components/grid/cell/simpleStatusTextCellEditor.js.map +1 -1
- package/components/grid/config/rowStylePicker.d.ts +1 -5
- package/components/grid/config/rowStylePicker.js +14 -70
- package/components/grid/config/rowStylePicker.js.map +1 -1
- package/components/grid/dataGrid.d.ts +1 -1
- package/components/grid/dataGrid.js +101 -122
- package/components/grid/dataGrid.js.map +1 -1
- package/components/grid/extendedDataGrid.d.ts +2 -0
- package/components/grid/extendedDataGrid.js +6 -1
- package/components/grid/extendedDataGrid.js.map +1 -1
- package/components/input/maskedInput.d.ts +3 -3
- package/components/scrollTo/scrollTo.d.ts +1 -0
- package/components/scrollTo/scrollTo.js +13 -0
- package/components/scrollTo/scrollTo.js.map +1 -1
- package/i18n/components.sk.json +17 -0
- package/package.json +2 -2
- package/style/index.less +5 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { SketchPickerProps } from "react-color/lib/components/sketch/Sketch";
|
|
3
|
+
import { TooltipPlacement } from "antd/lib/tooltip";
|
|
4
|
+
interface ColorPickerProps extends SketchPickerProps {
|
|
5
|
+
badgeIcon?: React.ReactNode;
|
|
6
|
+
title: string;
|
|
7
|
+
placement?: TooltipPlacement;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
transparentColorAllowed?: boolean;
|
|
10
|
+
onResetColor(): void;
|
|
11
|
+
}
|
|
12
|
+
interface ColorPickerState {
|
|
13
|
+
popupVisible: boolean;
|
|
14
|
+
}
|
|
15
|
+
export default class ColorPicker extends React.Component<ColorPickerProps, ColorPickerState> {
|
|
16
|
+
constructor(props: Readonly<ColorPickerProps>);
|
|
17
|
+
private getColorString;
|
|
18
|
+
render(): JSX.Element;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import i18n from "d2core/i18n/i18n";
|
|
3
|
+
import { Badge, Button, Popover } from "antd";
|
|
4
|
+
import { CloseOutlined, StopOutlined } from "@ant-design/icons";
|
|
5
|
+
import { SketchPicker } from "react-color";
|
|
6
|
+
const transparentBackgroundStyle = "url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAMUlEQVQ4T2NkYGAQYcAP3uCTZhw1gGGYhAGBZIA/nYDCgBDAm9BGDWAAJyRCgLaBCAAgXwixzAS0pgAAAABJRU5ErkJggg==\") left center";
|
|
7
|
+
const presetColors = [
|
|
8
|
+
"#fff1f0", "#ffccc7", "#ffa39e", "#ff7875", "#ff4d4f", "#f5222d", "#cf1322", "#a8071a", "#820014", "#5c0011",
|
|
9
|
+
"#fff2e8", "#ffd8bf", "#ffbb96", "#ff9c6e", "#ff7a45", "#fa541c", "#d4380d", "#ad2102", "#871400", "#610b00",
|
|
10
|
+
"#fff7e6", "#ffe7ba", "#ffd591", "#ffc069", "#ffa940", "#fa8c16", "#d46b08", "#ad4e00", "#873800", "#612500",
|
|
11
|
+
"#feffe6", "#ffffb8", "#fffb8f", "#fff566", "#ffec3d", "#fadb14", "#d4b106", "#ad8b00", "#876800", "#614700",
|
|
12
|
+
"#f6ffed", "#d9f7be", "#b7eb8f", "#95de64", "#73d13d", "#52c41a", "#389e0d", "#237804", "#135200", "#092b00",
|
|
13
|
+
"#e6fffb", "#b5f5ec", "#87e8de", "#5cdbd3", "#36cfc9", "#13c2c2", "#08979c", "#006d75", "#00474f", "#002329",
|
|
14
|
+
"#e6f7ff", "#bae7ff", "#91d5ff", "#69c0ff", "#40a9ff", "#1890ff", "#096dd9", "#0050b3", "#003a8c", "#002766",
|
|
15
|
+
"#ffffff", "#fafafa", "#f5f5f5", "#e8e8e8", "#d9d9d9", "#bfbfbf", "#8c8c8c", "#595959", "#262626", "#000000",
|
|
16
|
+
];
|
|
17
|
+
export default class ColorPicker extends React.Component {
|
|
18
|
+
constructor(props) {
|
|
19
|
+
super(props);
|
|
20
|
+
this.state = {
|
|
21
|
+
popupVisible: false,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
getColorString(color) {
|
|
25
|
+
if (typeof color === "object") {
|
|
26
|
+
return `rgba(${color.r},${color.g},${color.b},${color.a})`;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
return color;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
render() {
|
|
33
|
+
var _a;
|
|
34
|
+
return (React.createElement(Popover, { placement: this.props.placement, trigger: this.props.disabled ? "" : "click", visible: this.state.popupVisible, onVisibleChange: (visible) => {
|
|
35
|
+
this.setState({ popupVisible: visible });
|
|
36
|
+
}, title: React.createElement("div", null,
|
|
37
|
+
this.props.title,
|
|
38
|
+
React.createElement(Button, { style: { float: "right", paddingLeft: 8, border: "none" }, size: "small", title: i18n("Close"), onClick: () => {
|
|
39
|
+
this.setState({ popupVisible: false });
|
|
40
|
+
} },
|
|
41
|
+
React.createElement(CloseOutlined, null)),
|
|
42
|
+
React.createElement(Button, { style: { background: transparentBackgroundStyle, float: "right" }, size: "small", title: i18n("Set No Color"), onClick: () => {
|
|
43
|
+
this.props.onResetColor();
|
|
44
|
+
this.setState({ popupVisible: false });
|
|
45
|
+
} },
|
|
46
|
+
React.createElement(StopOutlined, { style: { color: "rgba(0,0,0,0.85)" } }))), content: React.createElement(SketchPicker, { color: this.props.color, width: "250px", presetColors: this.props.transparentColorAllowed ? [...presetColors, "transparent"] : presetColors, onChange: this.props.onChange, onChangeComplete: this.props.onChangeComplete }) },
|
|
47
|
+
React.createElement(Badge, { count: this.props.badgeIcon ?
|
|
48
|
+
React.createElement("span", { className: "ant-badge-count", style: { color: "#1890ff", background: "#e6f7ff", borderColor: "#91d5ff" } }, this.props.badgeIcon)
|
|
49
|
+
: undefined },
|
|
50
|
+
React.createElement(Button, { style: { background: (_a = this.getColorString(this.props.color)) !== null && _a !== void 0 ? _a : transparentBackgroundStyle }, disabled: this.props.disabled, title: this.props.title },
|
|
51
|
+
React.createElement("span", { role: "img", className: "anticon" })))));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=colorPicker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colorPicker.js","sourceRoot":"","sources":["../../../../components/color/colorPicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,kBAAkB,CAAC;AACpC,OAAO,EAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAC,MAAM,MAAM,CAAC;AAC5C,OAAO,EAAC,aAAa,EAAE,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAW,YAAY,EAAC,MAAM,aAAa,CAAC;AAInD,MAAM,0BAA0B,GAAG,6LAA6L,CAAA;AAChO,MAAM,YAAY,GAAG;IACjB,SAAS,EAAE,SAAS,EAAE,SAAS,E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AED,oBAAC,YAAY,IAAC,KAAK,EAAE,EAAC,KAAK,EAAE,kBAAkB,EAAC,GAAG,CAC9C,CACP,EAEV,OAAO,EACH,oBAAC,YAAY,IACT,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,KAAK,EAAE,OAAO,EACd,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,GAAG,YAAY,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,YAAY,EAClG,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAC7B,gBAAgB,EAAE,IAAI,CAAC,KAAK,CAAC,gBAAgB,GAC/C;YAGN,oBAAC,KAAK,IACF,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;oBACzB,8BACI,SAAS,EAAC,iBAAiB,EAC3B,KAAK,EAAE,EAAC,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAC,IAEnE,IAAI,CAAC,KAAK,CAAC,SAAS,CAClB;oBACX,CAAC,CAAC,SAAS;gBAGf,oBAAC,MAAM,IACH,KAAK,EAAE,EAAC,UAAU,EAAE,MAAA,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,KAAsC,CAAC,mCAAI,0BAA0B,EAAC,EACzH,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAC7B,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK;oBAEvB,8BAAM,IAAI,EAAC,KAAK,EAAC,SAAS,EAAC,SAAS,GAAE,CACjC,CACL,CACF,CACb,CAAC;IACN,CAAC;CAEJ","sourcesContent":["import React from \"react\";\r\nimport i18n from \"d2core/i18n/i18n\";\r\nimport {Badge, Button, Popover} from \"antd\";\r\nimport {CloseOutlined, StopOutlined} from \"@ant-design/icons\";\r\nimport {RGBColor, SketchPicker} from \"react-color\";\r\nimport {SketchPickerProps} from \"react-color/lib/components/sketch/Sketch\";\r\nimport {TooltipPlacement} from \"antd/lib/tooltip\";\r\n\r\nconst transparentBackgroundStyle = \"url(\\\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAMUlEQVQ4T2NkYGAQYcAP3uCTZhw1gGGYhAGBZIA/nYDCgBDAm9BGDWAAJyRCgLaBCAAgXwixzAS0pgAAAABJRU5ErkJggg==\\\") left center\"\r\nconst presetColors = [\r\n \"#fff1f0\", \"#ffccc7\", \"#ffa39e\", \"#ff7875\", \"#ff4d4f\", \"#f5222d\", \"#cf1322\", \"#a8071a\", \"#820014\", \"#5c0011\",\r\n \"#fff2e8\", \"#ffd8bf\", \"#ffbb96\", \"#ff9c6e\", \"#ff7a45\", \"#fa541c\", \"#d4380d\", \"#ad2102\", \"#871400\", \"#610b00\",\r\n \"#fff7e6\", \"#ffe7ba\", \"#ffd591\", \"#ffc069\", \"#ffa940\", \"#fa8c16\", \"#d46b08\", \"#ad4e00\", \"#873800\", \"#612500\",\r\n \"#feffe6\", \"#ffffb8\", \"#fffb8f\", \"#fff566\", \"#ffec3d\", \"#fadb14\", \"#d4b106\", \"#ad8b00\", \"#876800\", \"#614700\",\r\n \"#f6ffed\", \"#d9f7be\", \"#b7eb8f\", \"#95de64\", \"#73d13d\", \"#52c41a\", \"#389e0d\", \"#237804\", \"#135200\", \"#092b00\",\r\n \"#e6fffb\", \"#b5f5ec\", \"#87e8de\", \"#5cdbd3\", \"#36cfc9\", \"#13c2c2\", \"#08979c\", \"#006d75\", \"#00474f\", \"#002329\",\r\n \"#e6f7ff\", \"#bae7ff\", \"#91d5ff\", \"#69c0ff\", \"#40a9ff\", \"#1890ff\", \"#096dd9\", \"#0050b3\", \"#003a8c\", \"#002766\",\r\n \"#ffffff\", \"#fafafa\", \"#f5f5f5\", \"#e8e8e8\", \"#d9d9d9\", \"#bfbfbf\", \"#8c8c8c\", \"#595959\", \"#262626\", \"#000000\",\r\n];\r\n\r\ninterface ColorPickerProps extends SketchPickerProps {\r\n badgeIcon?: React.ReactNode\r\n title: string\r\n placement?: TooltipPlacement\r\n disabled?: boolean\r\n transparentColorAllowed?: boolean\r\n\r\n onResetColor(): void\r\n}\r\n\r\ninterface ColorPickerState {\r\n popupVisible: boolean\r\n}\r\n\r\nexport default class ColorPicker extends React.Component<ColorPickerProps, ColorPickerState> {\r\n constructor(props: Readonly<ColorPickerProps>) {\r\n super(props);\r\n\r\n this.state = {\r\n popupVisible: false,\r\n }\r\n }\r\n\r\n private getColorString(color: RGBColor | string | undefined): string | undefined {\r\n if (typeof color === \"object\") {\r\n return `rgba(${color.r},${color.g},${color.b},${color.a})`;\r\n } else {\r\n return color;\r\n }\r\n }\r\n\r\n render() {\r\n return (\r\n <Popover\r\n placement={this.props.placement}\r\n trigger={this.props.disabled ? \"\" : \"click\"}\r\n visible={this.state.popupVisible}\r\n onVisibleChange={(visible) => {\r\n this.setState({popupVisible: visible});\r\n }}\r\n title={\r\n <div>\r\n {this.props.title}\r\n <Button\r\n style={{float: \"right\", paddingLeft: 8, border: \"none\"}}\r\n size=\"small\"\r\n title={i18n(\"Close\")}\r\n onClick={() => {\r\n this.setState({popupVisible: false});\r\n }}\r\n >\r\n <CloseOutlined/>\r\n </Button>\r\n <Button\r\n style={{background: transparentBackgroundStyle, float: \"right\"}}\r\n size=\"small\"\r\n title={i18n(\"Set No Color\")}\r\n onClick={() => {\r\n this.props.onResetColor();\r\n this.setState({popupVisible: false});\r\n }}\r\n >\r\n <StopOutlined style={{color: \"rgba(0,0,0,0.85)\"}}/>\r\n </Button>\r\n </div>\r\n }\r\n content={\r\n <SketchPicker\r\n color={this.props.color}\r\n width={\"250px\"}\r\n presetColors={this.props.transparentColorAllowed ? [...presetColors, \"transparent\"] : presetColors}\r\n onChange={this.props.onChange}\r\n onChangeComplete={this.props.onChangeComplete}\r\n />\r\n }\r\n >\r\n <Badge\r\n count={this.props.badgeIcon ?\r\n <span\r\n className=\"ant-badge-count\"\r\n style={{color: \"#1890ff\", background: \"#e6f7ff\", borderColor: \"#91d5ff\"}}\r\n >\r\n {this.props.badgeIcon}\r\n </span>\r\n : undefined\r\n }\r\n >\r\n <Button\r\n style={{background: this.getColorString(this.props.color as RGBColor | string | undefined) ?? transparentBackgroundStyle}}\r\n disabled={this.props.disabled}\r\n title={this.props.title}\r\n >\r\n <span role=\"img\" className=\"anticon\"/>\r\n </Button>\r\n </Badge>\r\n </Popover>\r\n );\r\n }\r\n\r\n}"]}
|
|
@@ -11,5 +11,34 @@ export default class ColorUtils {
|
|
|
11
11
|
const r = parseInt(hex.substr(1, 2), 16), g = (parseInt(hex.substr(3, 2), 16) << 8), b = (parseInt(hex.substr(5, 2), 16) << 16);
|
|
12
12
|
return r + g + b;
|
|
13
13
|
}
|
|
14
|
+
static padZero(s, length = 2) {
|
|
15
|
+
while (s.length < length) {
|
|
16
|
+
s = '0' + s;
|
|
17
|
+
}
|
|
18
|
+
return s;
|
|
19
|
+
}
|
|
20
|
+
static invertColor(hex, bw) {
|
|
21
|
+
if (hex.indexOf('#') === 0) {
|
|
22
|
+
hex = hex.slice(1);
|
|
23
|
+
}
|
|
24
|
+
if (hex.length === 3) {
|
|
25
|
+
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
|
|
26
|
+
}
|
|
27
|
+
if (hex.length !== 6) {
|
|
28
|
+
throw new Error('Invalid HEX color.');
|
|
29
|
+
}
|
|
30
|
+
const r = parseInt(hex.slice(0, 2), 16);
|
|
31
|
+
const g = parseInt(hex.slice(2, 4), 16);
|
|
32
|
+
const b = parseInt(hex.slice(4, 6), 16);
|
|
33
|
+
if (bw) {
|
|
34
|
+
return (r * 0.299 + g * 0.587 + b * 0.114) > 186
|
|
35
|
+
? '#000000'
|
|
36
|
+
: '#FFFFFF';
|
|
37
|
+
}
|
|
38
|
+
const rString = (255 - r).toString(16);
|
|
39
|
+
const gString = (255 - g).toString(16);
|
|
40
|
+
const bString = (255 - b).toString(16);
|
|
41
|
+
return "#" + this.padZero(rString) + this.padZero(gString) + this.padZero(bString);
|
|
42
|
+
}
|
|
14
43
|
}
|
|
15
44
|
//# sourceMappingURL=colorUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colorUtils.js","sourceRoot":"","sources":["../../../../components/color/colorUtils.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,UAAU;IAC3B,MAAM,CAAC,UAAU,CAAC,GAAW;QAEzB,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,QAAQ,CAAC,KAAK,EAAE,EAC7B,CAAC,GAAG,CAAC,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,EACxB,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC;QACnB,OAAO,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;IAC9C,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,GAAW;QAEzB,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,QAAQ,CAAC,KAAK,EAAE,EAC7B,CAAC,GAAG,CAAC,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,EACxB,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC;QACnB,OAAO,GAAG,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACrH,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,GAAW;QACzB,MAAM,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,EACpC,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,EACzC,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;QAE/C,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;CACJ","sourcesContent":["export default class ColorUtils {\r\n static d2IntToRGB(num: number): string {\r\n // d2000 posiela farbu vo formate bgr\r\n const b = (num & 0xFF0000) >>> 16,\r\n g = (num & 0xFF00) >>> 8,\r\n r = num & 0xFF;\r\n return \"rgb(\" + [r, g, b].join(\",\") + \")\";\r\n }\r\n\r\n static d2IntToHex(num: number): string {\r\n // d2000 posiela farbu vo formate bgr\r\n const b = (num & 0xFF0000) >>> 16,\r\n g = (num & 0xFF00) >>> 8,\r\n r = num & 0xFF;\r\n return \"#\" + r.toString(16).padStart(2, '0') + g.toString(16).padStart(2, '0') + b.toString(16).padStart(2, '0');\r\n }\r\n\r\n static hexToD2Int(hex: string): number {\r\n const r = parseInt(hex.substr(1, 2), 16),\r\n g = (parseInt(hex.substr(3, 2), 16) << 8),\r\n b = (parseInt(hex.substr(5, 2), 16) << 16);\r\n\r\n return r + g + b;\r\n }\r\n}"]}
|
|
1
|
+
{"version":3,"file":"colorUtils.js","sourceRoot":"","sources":["../../../../components/color/colorUtils.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,UAAU;IAC3B,MAAM,CAAC,UAAU,CAAC,GAAW;QAEzB,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,QAAQ,CAAC,KAAK,EAAE,EAC7B,CAAC,GAAG,CAAC,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,EACxB,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC;QACnB,OAAO,MAAM,GA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,CAAC,CAAC;QACvC,MAAM,OAAO,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAEvC,OAAO,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACvF,CAAC;CACJ","sourcesContent":["export default class ColorUtils {\r\n static d2IntToRGB(num: number): string {\r\n // d2000 posiela farbu vo formate bgr\r\n const b = (num & 0xFF0000) >>> 16,\r\n g = (num & 0xFF00) >>> 8,\r\n r = num & 0xFF;\r\n return \"rgb(\" + [r, g, b].join(\",\") + \")\";\r\n }\r\n\r\n static d2IntToHex(num: number): string {\r\n // d2000 posiela farbu vo formate bgr\r\n const b = (num & 0xFF0000) >>> 16,\r\n g = (num & 0xFF00) >>> 8,\r\n r = num & 0xFF;\r\n return \"#\" + r.toString(16).padStart(2, '0') + g.toString(16).padStart(2, '0') + b.toString(16).padStart(2, '0');\r\n }\r\n\r\n static hexToD2Int(hex: string): number {\r\n const r = parseInt(hex.substr(1, 2), 16),\r\n g = (parseInt(hex.substr(3, 2), 16) << 8),\r\n b = (parseInt(hex.substr(5, 2), 16) << 16);\r\n\r\n return r + g + b;\r\n }\r\n\r\n private static padZero(s: string, length: number = 2) {\r\n while (s.length < length) {\r\n s = '0' + s;\r\n }\r\n return s;\r\n }\r\n\r\n static invertColor(hex: string, bw: boolean) {\r\n if (hex.indexOf('#') === 0) {\r\n hex = hex.slice(1);\r\n }\r\n // convert 3-digit hex to 6-digits.\r\n if (hex.length === 3) {\r\n hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];\r\n }\r\n if (hex.length !== 6) {\r\n throw new Error('Invalid HEX color.');\r\n }\r\n const r = parseInt(hex.slice(0, 2), 16);\r\n const g = parseInt(hex.slice(2, 4), 16);\r\n const b = parseInt(hex.slice(4, 6), 16);\r\n if (bw) {\r\n // http://stackoverflow.com/a/3943023/112731\r\n return (r * 0.299 + g * 0.587 + b * 0.114) > 186\r\n ? '#000000'\r\n : '#FFFFFF';\r\n }\r\n // invert color components\r\n const rString = (255 - r).toString(16);\r\n const gString = (255 - g).toString(16);\r\n const bString = (255 - b).toString(16);\r\n // pad each with zeros and return\r\n return \"#\" + this.padZero(rString) + this.padZero(gString) + this.padZero(bString);\r\n }\r\n}"]}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import React, { HTMLAttributes } from "react";
|
|
2
2
|
import { Moment } from "moment";
|
|
3
3
|
import { TooltipPlacement } from "antd/es/tooltip";
|
|
4
|
+
export declare enum DateRangeInputMode {
|
|
5
|
+
SIMPLE = 0,
|
|
6
|
+
ADVANCED = 1
|
|
7
|
+
}
|
|
4
8
|
export interface DateRangeInputProps extends Omit<HTMLAttributes<HTMLDivElement>, "onChange"> {
|
|
5
9
|
mask: string;
|
|
6
10
|
fromValue: Moment | null;
|
|
@@ -29,21 +33,29 @@ export interface DateRangeInputProps extends Omit<HTMLAttributes<HTMLDivElement>
|
|
|
29
33
|
useCssBottom?: boolean;
|
|
30
34
|
useCssTransform?: boolean;
|
|
31
35
|
};
|
|
36
|
+
defaultMode?: DateRangeInputMode;
|
|
37
|
+
onModeChange?(mode: DateRangeInputMode): void;
|
|
32
38
|
onFocus?(): void;
|
|
33
39
|
onBlur?(): void;
|
|
40
|
+
confirmButtonsRenderer?(): React.ReactNode;
|
|
41
|
+
onPopupVisibleChange?(visible: boolean): void;
|
|
34
42
|
}
|
|
35
43
|
interface DateRangeInputState {
|
|
36
44
|
valid: boolean;
|
|
37
45
|
selectionStartDate: Moment | null;
|
|
38
46
|
popupKeyIndex: number;
|
|
39
47
|
popupVisible: boolean;
|
|
48
|
+
mode: DateRangeInputMode;
|
|
40
49
|
}
|
|
41
50
|
export default class DateRangeInput extends React.Component<DateRangeInputProps, DateRangeInputState> {
|
|
42
51
|
constructor(props: Readonly<DateRangeInputProps>);
|
|
52
|
+
componentDidUpdate(_prevProps: Readonly<DateRangeInputProps>, prevState: Readonly<DateRangeInputState>): void;
|
|
43
53
|
getDefaultSelectedDateForFromPanel(fromDate: Moment | null, toDate: Moment | null): Moment;
|
|
44
54
|
private getFromValue;
|
|
45
55
|
private getToValue;
|
|
46
|
-
|
|
56
|
+
closePopup(): void;
|
|
57
|
+
private renderSimplePart;
|
|
58
|
+
private renderAdvancedPart;
|
|
47
59
|
renderPopup(): React.ReactElement;
|
|
48
60
|
renderInput(): JSX.Element;
|
|
49
61
|
render(): any;
|
|
@@ -12,21 +12,35 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import React from "react";
|
|
13
13
|
import moment from "moment";
|
|
14
14
|
import { CalendarOutlined } from "@ant-design/icons";
|
|
15
|
-
import { Divider, Tooltip } from "antd";
|
|
15
|
+
import { Divider, Switch, Tooltip } from "antd";
|
|
16
16
|
import DateTimeInput from "./dateTimeInput";
|
|
17
17
|
import memoizeOne from "memoize-one";
|
|
18
18
|
import KeyboardUtils from "../keyboard/keyboardUtils";
|
|
19
|
+
import i18n from "d2core/i18n/i18n";
|
|
20
|
+
import DateRangeInputAdvancedPanel, { TimeShiftDirection } from "./dateRangeInputAdvancedPanel";
|
|
21
|
+
export var DateRangeInputMode;
|
|
22
|
+
(function (DateRangeInputMode) {
|
|
23
|
+
DateRangeInputMode[DateRangeInputMode["SIMPLE"] = 0] = "SIMPLE";
|
|
24
|
+
DateRangeInputMode[DateRangeInputMode["ADVANCED"] = 1] = "ADVANCED";
|
|
25
|
+
})(DateRangeInputMode || (DateRangeInputMode = {}));
|
|
19
26
|
export default class DateRangeInput extends React.Component {
|
|
20
27
|
constructor(props) {
|
|
28
|
+
var _a;
|
|
21
29
|
super(props);
|
|
22
30
|
this.state = {
|
|
23
31
|
valid: !!props.fromValue && props.fromValue.isValid() && !!props.toValue && props.toValue.isValid(),
|
|
24
32
|
selectionStartDate: null,
|
|
25
33
|
popupKeyIndex: 0,
|
|
26
|
-
popupVisible: false
|
|
34
|
+
popupVisible: false,
|
|
35
|
+
mode: (_a = props.defaultMode) !== null && _a !== void 0 ? _a : DateRangeInputMode.SIMPLE,
|
|
27
36
|
};
|
|
28
37
|
this.getDefaultSelectedDateForFromPanel = memoizeOne(this.getDefaultSelectedDateForFromPanel.bind(this));
|
|
29
38
|
}
|
|
39
|
+
componentDidUpdate(_prevProps, prevState) {
|
|
40
|
+
if (prevState.popupVisible !== this.state.popupVisible && this.props.onPopupVisibleChange) {
|
|
41
|
+
this.props.onPopupVisibleChange(this.state.popupVisible);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
30
44
|
getDefaultSelectedDateForFromPanel(fromDate, toDate) {
|
|
31
45
|
if (!!fromDate && !!toDate && fromDate.isSame(toDate, "date")) {
|
|
32
46
|
return fromDate.clone().subtract(1, "month");
|
|
@@ -46,10 +60,10 @@ export default class DateRangeInput extends React.Component {
|
|
|
46
60
|
closePopup() {
|
|
47
61
|
this.setState({ popupKeyIndex: this.state.popupKeyIndex + 1, popupVisible: false });
|
|
48
62
|
}
|
|
49
|
-
|
|
63
|
+
renderSimplePart() {
|
|
50
64
|
const _a = this.props, { fromValue, toValue, onChange, style, allowClear, renderAsCalendar, hidePopup, align } = _a, props = __rest(_a, ["fromValue", "toValue", "onChange", "style", "allowClear", "renderAsCalendar", "hidePopup", "align"]);
|
|
51
65
|
const markedDateInterval = this.props.fromValue && this.props.toValue ? [this.props.fromValue, this.props.toValue] : undefined;
|
|
52
|
-
return (React.createElement("div",
|
|
66
|
+
return (React.createElement("div", null,
|
|
53
67
|
React.createElement("div", { style: { display: "flex" } },
|
|
54
68
|
React.createElement(DateTimeInput, Object.assign({ value: fromValue }, props, { allowClear: allowClear, renderAsCalendar: true, style: { width: "100%" }, onChange: (date) => {
|
|
55
69
|
var _a, _b;
|
|
@@ -83,7 +97,7 @@ export default class DateRangeInput extends React.Component {
|
|
|
83
97
|
}
|
|
84
98
|
}, onDateItemMouseUp: (_date) => {
|
|
85
99
|
this.setState({ selectionStartDate: null });
|
|
86
|
-
} })),
|
|
100
|
+
}, ignoreKeyStrokes: true })),
|
|
87
101
|
React.createElement(Divider, { type: "vertical", style: { height: "auto" } }),
|
|
88
102
|
React.createElement(DateTimeInput, Object.assign({ value: toValue }, props, { renderAsCalendar: true, allowClear: allowClear, style: { width: "100%" }, onChange: (date) => {
|
|
89
103
|
var _a, _b;
|
|
@@ -117,7 +131,7 @@ export default class DateRangeInput extends React.Component {
|
|
|
117
131
|
}
|
|
118
132
|
}, onDateItemMouseUp: (_date) => {
|
|
119
133
|
this.setState({ selectionStartDate: null });
|
|
120
|
-
} }))),
|
|
134
|
+
}, ignoreKeyStrokes: true }))),
|
|
121
135
|
React.createElement("div", { className: "ant-picker-footer" },
|
|
122
136
|
React.createElement("ul", { className: "ant-picker-ranges", style: { padding: 0, borderTop: "1px solid #ddd" } }, this.props.ranges && Object.keys(this.props.ranges).map((rangeName, index) => {
|
|
123
137
|
return (React.createElement("li", { className: "ant-picker-preset", key: `range-${index}`, onClick: () => {
|
|
@@ -131,17 +145,94 @@ export default class DateRangeInput extends React.Component {
|
|
|
131
145
|
React.createElement("span", { className: "ant-tag ant-tag-blue", style: { userSelect: "none" } }, rangeName)));
|
|
132
146
|
})))));
|
|
133
147
|
}
|
|
148
|
+
renderAdvancedPart() {
|
|
149
|
+
return (React.createElement("div", null,
|
|
150
|
+
React.createElement("div", { style: { display: "flex" } },
|
|
151
|
+
React.createElement(DateTimeInput, { style: { width: "47%" }, mask: this.props.mask, value: this.props.fromValue, onChange: (value) => {
|
|
152
|
+
var _a, _b;
|
|
153
|
+
(_b = (_a = this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, value, this.props.toValue);
|
|
154
|
+
} }),
|
|
155
|
+
React.createElement("span", { style: { width: "6%", paddingTop: 4, color: "rgba(0, 0, 0, 0.65)", textAlign: "center" } }, "\u27F7"),
|
|
156
|
+
React.createElement(DateTimeInput, { style: { width: "47%" }, mask: this.props.mask, value: this.props.toValue, onChange: (value) => {
|
|
157
|
+
var _a, _b;
|
|
158
|
+
(_b = (_a = this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, this.props.fromValue, value);
|
|
159
|
+
} })),
|
|
160
|
+
React.createElement(DateRangeInputAdvancedPanel, { onBeginIntervalChange: unit => {
|
|
161
|
+
var _a, _b, _c, _d;
|
|
162
|
+
if (unit === "15minutes") {
|
|
163
|
+
const roundedMinutes = Math.floor(moment().minute() / 15) * 15;
|
|
164
|
+
(_b = (_a = this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, moment().startOf("hour").minute(roundedMinutes), this.props.toValue);
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
(_d = (_c = this.props).onChange) === null || _d === void 0 ? void 0 : _d.call(_c, moment().startOf(unit), this.props.toValue);
|
|
168
|
+
}
|
|
169
|
+
}, onIntervalDurationChange: unitOfTime => {
|
|
170
|
+
var _a, _b, _c, _d;
|
|
171
|
+
if (this.props.fromValue) {
|
|
172
|
+
if (unitOfTime === "4years") {
|
|
173
|
+
(_b = (_a = this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, this.props.fromValue, this.props.fromValue.clone().add(4, "year").subtract(1, "minute"));
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
(_d = (_c = this.props).onChange) === null || _d === void 0 ? void 0 : _d.call(_c, this.props.fromValue, this.props.fromValue.clone().add(1, unitOfTime).subtract(1, "minute"));
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}, onTimeShift: (shiftBegin, shiftEnd, unitOfTime, type) => {
|
|
180
|
+
var _a, _b, _c, _d;
|
|
181
|
+
let fromValue = (_a = this.props.fromValue) === null || _a === void 0 ? void 0 : _a.clone();
|
|
182
|
+
let toValue = (_b = this.props.toValue) === null || _b === void 0 ? void 0 : _b.clone();
|
|
183
|
+
if (shiftBegin && fromValue) {
|
|
184
|
+
if (type === TimeShiftDirection.INCREMENT) {
|
|
185
|
+
fromValue.add(1, unitOfTime);
|
|
186
|
+
}
|
|
187
|
+
else if (type === TimeShiftDirection.DECREMENT) {
|
|
188
|
+
fromValue.subtract(1, unitOfTime);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
if (shiftEnd && toValue) {
|
|
192
|
+
if (type === TimeShiftDirection.INCREMENT) {
|
|
193
|
+
toValue.add(1, unitOfTime);
|
|
194
|
+
}
|
|
195
|
+
else if (type === TimeShiftDirection.DECREMENT) {
|
|
196
|
+
toValue.subtract(1, unitOfTime);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
(_d = (_c = this.props).onChange) === null || _d === void 0 ? void 0 : _d.call(_c, fromValue !== null && fromValue !== void 0 ? fromValue : null, toValue !== null && toValue !== void 0 ? toValue : null);
|
|
200
|
+
}, onEndIntervalChange: unit => {
|
|
201
|
+
var _a, _b, _c, _d;
|
|
202
|
+
if (unit === "15minutes") {
|
|
203
|
+
const roundedMinutes = Math.floor(moment().minute() / 15) * 15;
|
|
204
|
+
(_b = (_a = this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, this.props.fromValue, moment().startOf("hour").minute(roundedMinutes).subtract(1, "minute"));
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
(_d = (_c = this.props).onChange) === null || _d === void 0 ? void 0 : _d.call(_c, this.props.fromValue, moment().startOf(unit).subtract(1, "minute"));
|
|
208
|
+
}
|
|
209
|
+
} })));
|
|
210
|
+
}
|
|
211
|
+
renderPopup() {
|
|
212
|
+
var _a, _b;
|
|
213
|
+
return (React.createElement("div", { onFocus: this.props.onFocus, onBlur: this.props.onBlur },
|
|
214
|
+
this.state.mode === DateRangeInputMode.SIMPLE && this.renderSimplePart(),
|
|
215
|
+
this.state.mode === DateRangeInputMode.ADVANCED && this.renderAdvancedPart(),
|
|
216
|
+
React.createElement("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "flex-end" } },
|
|
217
|
+
React.createElement(Switch, { style: { float: "right", marginTop: 8 }, checked: this.state.mode === DateRangeInputMode.ADVANCED, onChange: checked => {
|
|
218
|
+
var _a, _b;
|
|
219
|
+
const mode = checked ? DateRangeInputMode.ADVANCED : DateRangeInputMode.SIMPLE;
|
|
220
|
+
this.setState({ mode: mode });
|
|
221
|
+
(_b = (_a = this.props).onModeChange) === null || _b === void 0 ? void 0 : _b.call(_a, mode);
|
|
222
|
+
}, checkedChildren: i18n("Advanced Mode"), unCheckedChildren: i18n("Simple Mode") }), (_b = (_a = this.props).confirmButtonsRenderer) === null || _b === void 0 ? void 0 :
|
|
223
|
+
_b.call(_a))));
|
|
224
|
+
}
|
|
134
225
|
renderInput() {
|
|
135
226
|
const _a = this.props, { fromValue, toValue, onChange, style, allowClear, renderAsCalendar, hidePopup, align, disabled } = _a, props = __rest(_a, ["fromValue", "toValue", "onChange", "style", "allowClear", "renderAsCalendar", "hidePopup", "align", "disabled"]);
|
|
136
|
-
const className = disabled ? "readonly" : undefined;
|
|
227
|
+
const className = (disabled || this.state.popupVisible) ? "readonly" : undefined;
|
|
137
228
|
return (React.createElement("div", { style: Object.assign(Object.assign({}, style), { padding: 0 }), className: "ant-input", onFocus: this.props.onFocus, onBlur: this.props.onBlur },
|
|
138
229
|
React.createElement("div", { style: { display: "flex", width: "calc(100% - 27px)" } },
|
|
139
|
-
React.createElement(DateTimeInput, Object.assign({ value: fromValue }, props, { disabled: disabled, allowClear: allowClear, bordered: false, hidePopup: true, style: { width: "auto" }, inputStyle: { paddingRight: 2 }, onChange: (value) => {
|
|
230
|
+
React.createElement(DateTimeInput, Object.assign({ value: fromValue }, props, { disabled: disabled, inputDisabled: this.state.popupVisible, allowClear: allowClear, bordered: false, hidePopup: true, style: { width: "auto" }, inputStyle: { paddingRight: 2 }, onChange: (value) => {
|
|
140
231
|
var _a, _b;
|
|
141
232
|
(_b = (_a = this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, value, this.props.toValue);
|
|
142
233
|
} })),
|
|
143
234
|
React.createElement("span", { style: { paddingTop: 4 }, className: className }, "\u27F7"),
|
|
144
|
-
React.createElement(DateTimeInput, Object.assign({ value: toValue }, props, { disabled: disabled, allowClear: allowClear, bordered: false, hidePopup: true, style: { width: "auto" }, inputStyle: { paddingLeft: 2 }, onChange: (value) => {
|
|
235
|
+
React.createElement(DateTimeInput, Object.assign({ value: toValue }, props, { disabled: disabled, inputDisabled: this.state.popupVisible, allowClear: allowClear, bordered: false, hidePopup: true, style: { width: "auto" }, inputStyle: { paddingLeft: 2 }, onChange: (value) => {
|
|
145
236
|
var _a, _b;
|
|
146
237
|
(_b = (_a = this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, this.props.fromValue, value);
|
|
147
238
|
} }))),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dateRangeInput.js","sourceRoot":"","sources":["../../../../components/date/dateRangeInput.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAuB,MAAM,OAAO,CAAC;AAC5C,OAAO,MAAgB,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAC,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAC,OAAO,EAAE,OAAO,EAAC,MAAM,MAAM,CAAC;AACtC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,UAAU,MAAM,aAAa,CAAC;AAErC,OAAO,aAAa,MAAM,2BAA2B,CAAC;AA2CtD,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,KAAK,CAAC,SAAmD;IACjG,YAAY,KAAoC;QAC5C,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,KAAK,GAAG;YACT,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE;YACnG,kBAAkB,EAAE,IAAI;YACxB,aAAa,EAAE,CAAC;YACh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AAC,WAAW,EAAE,CACb,CACb,CAAC;SACL;IACL,CAAC;CACJ","sourcesContent":["import React, {HTMLAttributes} from \"react\";\r\nimport moment, {Moment} from \"moment\";\r\nimport {CalendarOutlined} from \"@ant-design/icons\";\r\nimport {Divider, Tooltip} from \"antd\";\r\nimport DateTimeInput from \"./dateTimeInput\";\r\nimport memoizeOne from \"memoize-one\";\r\nimport {TooltipPlacement} from \"antd/es/tooltip\";\r\nimport KeyboardUtils from \"../keyboard/keyboardUtils\";\r\n\r\nexport interface DateRangeInputProps extends Omit<HTMLAttributes<HTMLDivElement>, \"onChange\"> {\r\n mask: string\r\n fromValue: Moment | null\r\n toValue: Moment | null\r\n onChange?: (fromValue: Moment | null, toValue: Moment | null) => void\r\n onInvalidValue?: (input: string) => void\r\n disabled?: boolean\r\n minDate?: Moment\r\n maxDate?: Moment\r\n // allows to set no (null) date by datepicker\r\n allowClear?: boolean\r\n ranges?: { [rangeName: string]: () => [Moment, Moment] }\r\n\r\n hidePopup?: boolean\r\n renderAsCalendar?: boolean\r\n placement?: TooltipPlacement\r\n align?: {\r\n points?: [string, string];\r\n offset?: [number, number];\r\n targetOffset?: [number, number];\r\n overflow?: {\r\n adjustX?: boolean;\r\n adjustY?: boolean;\r\n };\r\n useCssRight?: boolean;\r\n useCssBottom?: boolean;\r\n useCssTransform?: boolean;\r\n }\r\n\r\n onFocus?(): void\r\n\r\n onBlur?(): void\r\n}\r\n\r\ninterface DateRangeInputState {\r\n valid: boolean\r\n selectionStartDate: Moment | null\r\n popupKeyIndex: number\r\n popupVisible: boolean\r\n}\r\n\r\nexport default class DateRangeInput extends React.Component<DateRangeInputProps, DateRangeInputState> {\r\n constructor(props: Readonly<DateRangeInputProps>) {\r\n super(props);\r\n this.state = {\r\n valid: !!props.fromValue && props.fromValue.isValid() && !!props.toValue && props.toValue.isValid(),\r\n selectionStartDate: null,\r\n popupKeyIndex: 0,\r\n popupVisible: false\r\n };\r\n this.getDefaultSelectedDateForFromPanel = memoizeOne(this.getDefaultSelectedDateForFromPanel.bind(this));\r\n }\r\n\r\n getDefaultSelectedDateForFromPanel(fromDate: Moment | null, toDate: Moment | null): Moment {\r\n if (!!fromDate && !!toDate && fromDate.isSame(toDate, \"date\")) {\r\n return fromDate.clone().subtract(1, \"month\");\r\n } else {\r\n return fromDate ?? moment().startOf(\"day\").subtract(1, \"month\");\r\n }\r\n }\r\n\r\n private getFromValue(date: moment.Moment) {\r\n return (this.props.fromValue?.clone() ?? moment().startOf(\"day\")).year(date.year()).month(date.month()).date(date.date());\r\n }\r\n\r\n private getToValue(date: moment.Moment) {\r\n return (this.props.toValue?.clone() ?? moment().endOf(\"day\")).year(date.year()).month(date.month()).date(date.date());\r\n }\r\n\r\n private closePopup() {\r\n // close tooltip\r\n this.setState({popupKeyIndex: this.state.popupKeyIndex + 1, popupVisible: false});\r\n }\r\n\r\n renderPopup(): React.ReactElement {\r\n const {\r\n fromValue,\r\n toValue,\r\n onChange,\r\n style,\r\n allowClear,\r\n renderAsCalendar,\r\n hidePopup,\r\n align,\r\n ...props\r\n } = this.props;\r\n const markedDateInterval: [Moment, Moment] | undefined = this.props.fromValue && this.props.toValue ? [this.props.fromValue, this.props.toValue] : undefined;\r\n\r\n return (\r\n <div onFocus={this.props.onFocus} onBlur={this.props.onBlur}>\r\n <div style={{display: \"flex\"}}>\r\n <DateTimeInput value={fromValue} {...props}\r\n allowClear={allowClear}\r\n renderAsCalendar\r\n style={{width: \"100%\"}}\r\n onChange={(date) => {\r\n if (date) {\r\n const fromValue = this.getFromValue(date);\r\n const toValue = this.getToValue(date);\r\n this.props.onChange?.(fromValue, toValue);\r\n }\r\n }}\r\n defaultSelectedDate={this.getDefaultSelectedDateForFromPanel(fromValue, toValue)}\r\n markedDateInterval={markedDateInterval}\r\n onDateItemMouseDown={(date) => {\r\n this.setState({selectionStartDate: date});\r\n const dateFrom = this.getFromValue(date);\r\n const dateTo = this.getToValue(date);\r\n this.props.onChange?.(dateFrom, dateTo);\r\n }}\r\n onDateItemMouseOver={(date) => {\r\n if (KeyboardUtils.isMouseDown() && !!this.state.selectionStartDate) {\r\n let dateFrom: Moment;\r\n let dateTo: Moment;\r\n if (this.state.selectionStartDate.isBefore(date)) {\r\n dateFrom = this.state.selectionStartDate;\r\n dateTo = date;\r\n } else {\r\n dateFrom = date;\r\n dateTo = this.state.selectionStartDate;\r\n }\r\n dateFrom = this.getFromValue(dateFrom);\r\n dateTo = this.getToValue(dateTo);\r\n this.props.onChange?.(dateFrom, dateTo);\r\n }\r\n }}\r\n onDateItemMouseUp={(_date) => {\r\n this.setState({selectionStartDate: null});\r\n }}\r\n\r\n />\r\n <Divider type=\"vertical\" style={{height: \"auto\"}}/>\r\n <DateTimeInput value={toValue} {...props}\r\n renderAsCalendar\r\n allowClear={allowClear}\r\n style={{width: \"100%\"}}\r\n onChange={(date) => {\r\n if (date) {\r\n const fromValue = this.getFromValue(date);\r\n const toValue = this.getToValue(date);\r\n this.props.onChange?.(fromValue, toValue);\r\n }\r\n }}\r\n markedDateInterval={markedDateInterval}\r\n onDateItemMouseDown={(date) => {\r\n this.setState({selectionStartDate: date});\r\n const dateFrom = this.getFromValue(date);\r\n const dateTo = this.getToValue(date);\r\n this.props.onChange?.(dateFrom, dateTo);\r\n }}\r\n onDateItemMouseOver={(date) => {\r\n if (KeyboardUtils.isMouseDown() && !!this.state.selectionStartDate) {\r\n let dateFrom: Moment;\r\n let dateTo: Moment;\r\n if (this.state.selectionStartDate.isBefore(date)) {\r\n dateFrom = this.state.selectionStartDate;\r\n dateTo = date;\r\n } else {\r\n dateFrom = date;\r\n dateTo = this.state.selectionStartDate;\r\n }\r\n dateFrom = this.getFromValue(dateFrom);\r\n dateTo = this.getToValue(dateTo);\r\n this.props.onChange?.(dateFrom, dateTo);\r\n }\r\n }}\r\n onDateItemMouseUp={(_date) => {\r\n this.setState({selectionStartDate: null});\r\n }}\r\n />\r\n </div>\r\n <div className=\"ant-picker-footer\">\r\n <ul className=\"ant-picker-ranges\" style={{padding: 0, borderTop: \"1px solid #ddd\"}}>\r\n {\r\n this.props.ranges && Object.keys(this.props.ranges).map((rangeName, index) => {\r\n return (<li className=\"ant-picker-preset\"\r\n key={`range-${index}`}\r\n onClick={() => {\r\n const rangeFunction = this.props.ranges?.[rangeName];\r\n if (rangeFunction) {\r\n const range = rangeFunction();\r\n this.props.onChange?.(range[0], range[1]);\r\n }\r\n }}>\r\n <span className=\"ant-tag ant-tag-blue\"\r\n style={{userSelect: \"none\"}}>{rangeName}</span>\r\n </li>);\r\n })\r\n }\r\n </ul>\r\n </div>\r\n </div>);\r\n }\r\n\r\n renderInput() {\r\n const {\r\n fromValue,\r\n toValue,\r\n onChange,\r\n style,\r\n allowClear,\r\n renderAsCalendar,\r\n hidePopup,\r\n align,\r\n disabled,\r\n ...props\r\n } = this.props;\r\n const className = disabled ? \"readonly\" : undefined;\r\n return (\r\n <div style={{...style, padding: 0}} className={\"ant-input\"} onFocus={this.props.onFocus}\r\n onBlur={this.props.onBlur}>\r\n <div style={{display: \"flex\", width: \"calc(100% - 27px)\"}}>\r\n <DateTimeInput value={fromValue} {...props}\r\n disabled={disabled}\r\n allowClear={allowClear}\r\n bordered={false}\r\n hidePopup={true}\r\n style={{width: \"auto\"}}\r\n inputStyle={{paddingRight: 2}}\r\n onChange={(value) => {\r\n this.props.onChange?.(value, this.props.toValue);\r\n }}\r\n />\r\n <span style={{paddingTop: 4}} className={className}>{\"\\u27F7\"}</span>\r\n <DateTimeInput value={toValue} {...props}\r\n disabled={disabled}\r\n allowClear={allowClear}\r\n bordered={false}\r\n hidePopup={true}\r\n style={{width: \"auto\"}}\r\n inputStyle={{paddingLeft: 2}}\r\n onChange={(value) => {\r\n this.props.onChange?.(this.props.fromValue, value);\r\n }}/>\r\n </div>\r\n <div className={\"ant-input-number-handler-wrap \" + className}\r\n style={{\r\n width: 28,\r\n opacity: 1,\r\n height: \"100%\",\r\n textAlign: \"center\",\r\n cursor: disabled ? \"not-allowed\" : \"pointer\"\r\n }}\r\n onClick={(event) => {\r\n if (!disabled && document.createEvent) {\r\n if (this.state.popupVisible) {\r\n this.closePopup();\r\n } else {\r\n var ev = document.createEvent('HTMLEvents');\r\n ev.initEvent('contextmenu', true, false);\r\n event.target.dispatchEvent(ev);\r\n this.props.onFocus?.();\r\n }\r\n }\r\n }}\r\n >\r\n <CalendarOutlined style={{color: \"rgba(0,0,0,0.65)\", verticalAlign: \"middle\", marginTop: 2}}/>\r\n </div>\r\n </div>\r\n );\r\n }\r\n\r\n render(): any {\r\n if (this.props.renderAsCalendar) {\r\n return this.renderPopup();\r\n } else if (this.props.hidePopup) {\r\n return this.renderInput();\r\n } else {\r\n return (\r\n <Tooltip color={\"white\"}\r\n key={\"date-range-popup-\" + this.state.popupKeyIndex}\r\n trigger={this.props.disabled ? [] : [\"contextMenu\"]}\r\n align={this.props.align}\r\n placement={this.props.placement}\r\n overlayInnerStyle={{maxHeight: \"100vh\", overflowY: \"auto\", overflowX: \"hidden\"}}\r\n onVisibleChange={(visible) => {\r\n if (visible) {\r\n this.props.onFocus?.();\r\n } else {\r\n this.props.onBlur?.();\r\n }\r\n this.setState({popupVisible: visible});\r\n }}\r\n overlayClassName={\"date-range-picker-popup\"}\r\n title={this.renderPopup()}>\r\n {this.renderInput()}\r\n </Tooltip>\r\n );\r\n }\r\n }\r\n}"]}
|
|
1
|
+
{"version":3,"file":"dateRangeInput.js","sourceRoot":"","sources":["../../../../components/date/dateRangeInput.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAuB,MAAM,OAAO,CAAC;AAC5C,OAAO,MAAgB,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAC,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAC,MAAM,MAAM,CAAC;AAC9C,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,UAAU,MAAM,aAAa,CAAC;AAErC,OAAO,aAAa,MAAM,2BAA2B,CA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AAI,CAAC,KAAK,CAAC,gBAAgB,EAAE;YAC7B,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;SAC7B;aAAM,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE;YAC7B,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;SAC7B;aAAM;YACH,OAAO,CACH,oBAAC,OAAO,IAAC,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,mBAAmB,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,EACnD,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,EACnD,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,EAC/B,iBAAiB,EAAE,EAAC,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAC,EAC/E,eAAe,EAAE,CAAC,OAAO,EAAE,EAAE;;oBACzB,IAAI,OAAO,EAAE;wBACT,MAAA,MAAA,IAAI,CAAC,KAAK,EAAC,OAAO,kDAAI,CAAC;qBAC1B;yBAAM;wBACH,MAAA,MAAA,IAAI,CAAC,KAAK,EAAC,MAAM,kDAAI,CAAC;qBACzB;oBACD,IAAI,CAAC,QAAQ,CAAC,EAAC,YAAY,EAAE,OAAO,EAAC,CAAC,CAAC;gBAC3C,CAAC,EACD,gBAAgB,EAAE,yBAAyB,EAC3C,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,IAC7B,IAAI,CAAC,WAAW,EAAE,CACb,CACb,CAAC;SACL;IACL,CAAC;CACJ","sourcesContent":["import React, {HTMLAttributes} from \"react\";\r\nimport moment, {Moment} from \"moment\";\r\nimport {CalendarOutlined} from \"@ant-design/icons\";\r\nimport {Divider, Switch, Tooltip} from \"antd\";\r\nimport DateTimeInput from \"./dateTimeInput\";\r\nimport memoizeOne from \"memoize-one\";\r\nimport {TooltipPlacement} from \"antd/es/tooltip\";\r\nimport KeyboardUtils from \"../keyboard/keyboardUtils\";\r\nimport i18n from \"d2core/i18n/i18n\";\r\nimport DateRangeInputAdvancedPanel, {TimeShiftDirection} from \"./dateRangeInputAdvancedPanel\";\r\n\r\nexport enum DateRangeInputMode {\r\n SIMPLE,\r\n ADVANCED,\r\n}\r\n\r\nexport interface DateRangeInputProps extends Omit<HTMLAttributes<HTMLDivElement>, \"onChange\"> {\r\n mask: string\r\n fromValue: Moment | null\r\n toValue: Moment | null\r\n onChange?: (fromValue: Moment | null, toValue: Moment | null) => void\r\n onInvalidValue?: (input: string) => void\r\n disabled?: boolean\r\n minDate?: Moment\r\n maxDate?: Moment\r\n // allows to set no (null) date by datepicker\r\n allowClear?: boolean\r\n ranges?: { [rangeName: string]: () => [Moment, Moment] }\r\n\r\n hidePopup?: boolean\r\n renderAsCalendar?: boolean\r\n placement?: TooltipPlacement\r\n align?: {\r\n points?: [string, string];\r\n offset?: [number, number];\r\n targetOffset?: [number, number];\r\n overflow?: {\r\n adjustX?: boolean;\r\n adjustY?: boolean;\r\n };\r\n useCssRight?: boolean;\r\n useCssBottom?: boolean;\r\n useCssTransform?: boolean;\r\n }\r\n\r\n defaultMode?: DateRangeInputMode\r\n\r\n onModeChange?(mode: DateRangeInputMode): void\r\n\r\n onFocus?(): void\r\n\r\n onBlur?(): void\r\n\r\n confirmButtonsRenderer?(): React.ReactNode\r\n\r\n onPopupVisibleChange?(visible: boolean): void\r\n}\r\n\r\ninterface DateRangeInputState {\r\n valid: boolean\r\n selectionStartDate: Moment | null\r\n popupKeyIndex: number\r\n popupVisible: boolean\r\n\r\n mode: DateRangeInputMode\r\n}\r\n\r\nexport default class DateRangeInput extends React.Component<DateRangeInputProps, DateRangeInputState> {\r\n constructor(props: Readonly<DateRangeInputProps>) {\r\n super(props);\r\n this.state = {\r\n valid: !!props.fromValue && props.fromValue.isValid() && !!props.toValue && props.toValue.isValid(),\r\n selectionStartDate: null,\r\n popupKeyIndex: 0,\r\n popupVisible: false,\r\n\r\n mode: props.defaultMode ?? DateRangeInputMode.SIMPLE,\r\n };\r\n this.getDefaultSelectedDateForFromPanel = memoizeOne(this.getDefaultSelectedDateForFromPanel.bind(this));\r\n }\r\n\r\n componentDidUpdate(_prevProps: Readonly<DateRangeInputProps>, prevState: Readonly<DateRangeInputState>) {\r\n if (prevState.popupVisible !== this.state.popupVisible && this.props.onPopupVisibleChange) {\r\n this.props.onPopupVisibleChange(this.state.popupVisible);\r\n }\r\n }\r\n\r\n getDefaultSelectedDateForFromPanel(fromDate: Moment | null, toDate: Moment | null): Moment {\r\n if (!!fromDate && !!toDate && fromDate.isSame(toDate, \"date\")) {\r\n return fromDate.clone().subtract(1, \"month\");\r\n } else {\r\n return fromDate ?? moment().startOf(\"day\").subtract(1, \"month\");\r\n }\r\n }\r\n\r\n private getFromValue(date: moment.Moment) {\r\n return (this.props.fromValue?.clone() ?? moment().startOf(\"day\")).year(date.year()).month(date.month()).date(date.date());\r\n }\r\n\r\n private getToValue(date: moment.Moment) {\r\n return (this.props.toValue?.clone() ?? moment().endOf(\"day\")).year(date.year()).month(date.month()).date(date.date());\r\n }\r\n\r\n closePopup() {\r\n // close tooltip\r\n this.setState({popupKeyIndex: this.state.popupKeyIndex + 1, popupVisible: false});\r\n }\r\n\r\n private renderSimplePart() {\r\n const {\r\n fromValue,\r\n toValue,\r\n onChange,\r\n style,\r\n allowClear,\r\n renderAsCalendar,\r\n hidePopup,\r\n align,\r\n ...props\r\n } = this.props;\r\n const markedDateInterval: [Moment, Moment] | undefined = this.props.fromValue && this.props.toValue ? [this.props.fromValue, this.props.toValue] : undefined;\r\n\r\n return (\r\n <div>\r\n <div style={{display: \"flex\"}}>\r\n <DateTimeInput value={fromValue} {...props}\r\n allowClear={allowClear}\r\n renderAsCalendar\r\n style={{width: \"100%\"}}\r\n onChange={(date) => {\r\n if (date) {\r\n const fromValue = this.getFromValue(date);\r\n const toValue = this.getToValue(date);\r\n this.props.onChange?.(fromValue, toValue);\r\n }\r\n }}\r\n defaultSelectedDate={this.getDefaultSelectedDateForFromPanel(fromValue, toValue)}\r\n markedDateInterval={markedDateInterval}\r\n onDateItemMouseDown={(date) => {\r\n this.setState({selectionStartDate: date});\r\n const dateFrom = this.getFromValue(date);\r\n const dateTo = this.getToValue(date);\r\n this.props.onChange?.(dateFrom, dateTo);\r\n }}\r\n onDateItemMouseOver={(date) => {\r\n if (KeyboardUtils.isMouseDown() && !!this.state.selectionStartDate) {\r\n let dateFrom: Moment;\r\n let dateTo: Moment;\r\n if (this.state.selectionStartDate.isBefore(date)) {\r\n dateFrom = this.state.selectionStartDate;\r\n dateTo = date;\r\n } else {\r\n dateFrom = date;\r\n dateTo = this.state.selectionStartDate;\r\n }\r\n dateFrom = this.getFromValue(dateFrom);\r\n dateTo = this.getToValue(dateTo);\r\n this.props.onChange?.(dateFrom, dateTo);\r\n }\r\n }}\r\n onDateItemMouseUp={(_date) => {\r\n this.setState({selectionStartDate: null});\r\n }}\r\n ignoreKeyStrokes\r\n />\r\n <Divider type=\"vertical\" style={{height: \"auto\"}}/>\r\n <DateTimeInput value={toValue} {...props}\r\n renderAsCalendar\r\n allowClear={allowClear}\r\n style={{width: \"100%\"}}\r\n onChange={(date) => {\r\n if (date) {\r\n const fromValue = this.getFromValue(date);\r\n const toValue = this.getToValue(date);\r\n this.props.onChange?.(fromValue, toValue);\r\n }\r\n }}\r\n markedDateInterval={markedDateInterval}\r\n onDateItemMouseDown={(date) => {\r\n this.setState({selectionStartDate: date});\r\n const dateFrom = this.getFromValue(date);\r\n const dateTo = this.getToValue(date);\r\n this.props.onChange?.(dateFrom, dateTo);\r\n }}\r\n onDateItemMouseOver={(date) => {\r\n if (KeyboardUtils.isMouseDown() && !!this.state.selectionStartDate) {\r\n let dateFrom: Moment;\r\n let dateTo: Moment;\r\n if (this.state.selectionStartDate.isBefore(date)) {\r\n dateFrom = this.state.selectionStartDate;\r\n dateTo = date;\r\n } else {\r\n dateFrom = date;\r\n dateTo = this.state.selectionStartDate;\r\n }\r\n dateFrom = this.getFromValue(dateFrom);\r\n dateTo = this.getToValue(dateTo);\r\n this.props.onChange?.(dateFrom, dateTo);\r\n }\r\n }}\r\n onDateItemMouseUp={(_date) => {\r\n this.setState({selectionStartDate: null});\r\n }}\r\n ignoreKeyStrokes\r\n />\r\n </div>\r\n <div className=\"ant-picker-footer\">\r\n <ul className=\"ant-picker-ranges\" style={{padding: 0, borderTop: \"1px solid #ddd\"}}>\r\n {\r\n this.props.ranges && Object.keys(this.props.ranges).map((rangeName, index) => {\r\n return (<li className=\"ant-picker-preset\"\r\n key={`range-${index}`}\r\n onClick={() => {\r\n const rangeFunction = this.props.ranges?.[rangeName];\r\n if (rangeFunction) {\r\n const range = rangeFunction();\r\n this.props.onChange?.(range[0], range[1]);\r\n }\r\n }}>\r\n <span className=\"ant-tag ant-tag-blue\"\r\n style={{userSelect: \"none\"}}>{rangeName}</span>\r\n </li>);\r\n })\r\n }\r\n </ul>\r\n </div>\r\n </div>\r\n )\r\n }\r\n\r\n private renderAdvancedPart() {\r\n return (\r\n <div>\r\n <div style={{display: \"flex\"}}>\r\n <DateTimeInput\r\n style={{width: \"47%\"}}\r\n mask={this.props.mask}\r\n value={this.props.fromValue}\r\n onChange={(value) => {\r\n this.props.onChange?.(value, this.props.toValue);\r\n }}\r\n />\r\n <span style={{width: \"6%\", paddingTop: 4, color: \"rgba(0, 0, 0, 0.65)\", textAlign: \"center\"}}>\r\n {\"\\u27F7\"}\r\n </span>\r\n <DateTimeInput\r\n style={{width: \"47%\"}}\r\n mask={this.props.mask}\r\n value={this.props.toValue}\r\n onChange={(value) => {\r\n this.props.onChange?.(this.props.fromValue, value);\r\n }}\r\n />\r\n </div>\r\n <DateRangeInputAdvancedPanel\r\n onBeginIntervalChange={unit => {\r\n if (unit === \"15minutes\") {\r\n const roundedMinutes = Math.floor(moment().minute() / 15) * 15;\r\n this.props.onChange?.(moment().startOf(\"hour\").minute(roundedMinutes), this.props.toValue);\r\n } else {\r\n this.props.onChange?.(moment().startOf(unit), this.props.toValue);\r\n }\r\n }}\r\n onIntervalDurationChange={unitOfTime => {\r\n if (this.props.fromValue) {\r\n if (unitOfTime === \"4years\") {\r\n this.props.onChange?.(this.props.fromValue, this.props.fromValue.clone().add(4, \"year\").subtract(1, \"minute\"));\r\n } else {\r\n this.props.onChange?.(this.props.fromValue, this.props.fromValue.clone().add(1, unitOfTime).subtract(1, \"minute\"));\r\n }\r\n }\r\n }}\r\n onTimeShift={(shiftBegin, shiftEnd, unitOfTime, type) => {\r\n let fromValue = this.props.fromValue?.clone();\r\n let toValue = this.props.toValue?.clone();\r\n\r\n if (shiftBegin && fromValue) {\r\n if (type === TimeShiftDirection.INCREMENT) {\r\n fromValue.add(1, unitOfTime);\r\n } else if (type === TimeShiftDirection.DECREMENT) {\r\n fromValue.subtract(1, unitOfTime);\r\n }\r\n }\r\n\r\n if (shiftEnd && toValue) {\r\n if (type === TimeShiftDirection.INCREMENT) {\r\n toValue.add(1, unitOfTime);\r\n } else if (type === TimeShiftDirection.DECREMENT) {\r\n toValue.subtract(1, unitOfTime);\r\n }\r\n }\r\n\r\n this.props.onChange?.(fromValue ?? null, toValue ?? null);\r\n }}\r\n onEndIntervalChange={unit => {\r\n if (unit === \"15minutes\") {\r\n const roundedMinutes = Math.floor(moment().minute() / 15) * 15;\r\n this.props.onChange?.(this.props.fromValue, moment().startOf(\"hour\").minute(roundedMinutes).subtract(1, \"minute\"));\r\n } else {\r\n this.props.onChange?.(this.props.fromValue, moment().startOf(unit).subtract(1, \"minute\"));\r\n }\r\n }}\r\n />\r\n </div>\r\n )\r\n }\r\n\r\n renderPopup(): React.ReactElement {\r\n return (\r\n <div onFocus={this.props.onFocus} onBlur={this.props.onBlur}>\r\n {this.state.mode === DateRangeInputMode.SIMPLE && this.renderSimplePart()}\r\n {this.state.mode === DateRangeInputMode.ADVANCED && this.renderAdvancedPart()}\r\n <div style={{display: \"flex\", justifyContent: \"space-between\", alignItems: \"flex-end\"}}>\r\n <Switch\r\n style={{float: \"right\", marginTop: 8}}\r\n checked={this.state.mode === DateRangeInputMode.ADVANCED}\r\n onChange={checked => {\r\n const mode = checked ? DateRangeInputMode.ADVANCED : DateRangeInputMode.SIMPLE;\r\n this.setState({mode: mode});\r\n this.props.onModeChange?.(mode);\r\n }}\r\n checkedChildren={i18n(\"Advanced Mode\")}\r\n unCheckedChildren={i18n(\"Simple Mode\")}\r\n />\r\n {this.props.confirmButtonsRenderer?.()}\r\n </div>\r\n </div>\r\n );\r\n }\r\n\r\n renderInput() {\r\n const {\r\n fromValue,\r\n toValue,\r\n onChange,\r\n style,\r\n allowClear,\r\n renderAsCalendar,\r\n hidePopup,\r\n align,\r\n disabled,\r\n ...props\r\n } = this.props;\r\n const className = (disabled || this.state.popupVisible) ? \"readonly\" : undefined;\r\n return (\r\n <div style={{...style, padding: 0}} className={\"ant-input\"} onFocus={this.props.onFocus}\r\n onBlur={this.props.onBlur}>\r\n <div style={{display: \"flex\", width: \"calc(100% - 27px)\"}}>\r\n <DateTimeInput value={fromValue} {...props}\r\n disabled={disabled}\r\n inputDisabled={this.state.popupVisible}\r\n allowClear={allowClear}\r\n bordered={false}\r\n hidePopup={true}\r\n style={{width: \"auto\"}}\r\n inputStyle={{paddingRight: 2}}\r\n onChange={(value) => {\r\n this.props.onChange?.(value, this.props.toValue);\r\n }}\r\n />\r\n <span style={{paddingTop: 4}} className={className}>{\"\\u27F7\"}</span>\r\n <DateTimeInput value={toValue} {...props}\r\n disabled={disabled}\r\n inputDisabled={this.state.popupVisible}\r\n allowClear={allowClear}\r\n bordered={false}\r\n hidePopup={true}\r\n style={{width: \"auto\"}}\r\n inputStyle={{paddingLeft: 2}}\r\n onChange={(value) => {\r\n this.props.onChange?.(this.props.fromValue, value);\r\n }}/>\r\n </div>\r\n <div className={\"ant-input-number-handler-wrap \" + className}\r\n style={{\r\n width: 28,\r\n opacity: 1,\r\n height: \"100%\",\r\n textAlign: \"center\",\r\n cursor: disabled ? \"not-allowed\" : \"pointer\"\r\n }}\r\n onClick={(event) => {\r\n if (!disabled && document.createEvent) {\r\n if (this.state.popupVisible) {\r\n this.closePopup();\r\n } else {\r\n var ev = document.createEvent('HTMLEvents');\r\n ev.initEvent('contextmenu', true, false);\r\n event.target.dispatchEvent(ev);\r\n this.props.onFocus?.();\r\n }\r\n }\r\n }}\r\n >\r\n <CalendarOutlined style={{color: \"rgba(0,0,0,0.65)\", verticalAlign: \"middle\", marginTop: 2}}/>\r\n </div>\r\n </div>\r\n );\r\n }\r\n\r\n render(): any {\r\n if (this.props.renderAsCalendar) {\r\n return this.renderPopup();\r\n } else if (this.props.hidePopup) {\r\n return this.renderInput();\r\n } else {\r\n return (\r\n <Tooltip color={\"white\"}\r\n key={\"date-range-popup-\" + this.state.popupKeyIndex}\r\n trigger={this.props.disabled ? [] : [\"contextMenu\"]}\r\n align={this.props.align}\r\n placement={this.props.placement}\r\n overlayInnerStyle={{maxHeight: \"100vh\", overflowY: \"auto\", overflowX: \"hidden\"}}\r\n onVisibleChange={(visible) => {\r\n if (visible) {\r\n this.props.onFocus?.();\r\n } else {\r\n this.props.onBlur?.();\r\n }\r\n this.setState({popupVisible: visible});\r\n }}\r\n overlayClassName={\"date-range-picker-popup\"}\r\n title={this.renderPopup()}>\r\n {this.renderInput()}\r\n </Tooltip>\r\n );\r\n }\r\n }\r\n}"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { unitOfTime } from "moment";
|
|
3
|
+
export declare enum TimeShiftDirection {
|
|
4
|
+
INCREMENT = 0,
|
|
5
|
+
DECREMENT = 1
|
|
6
|
+
}
|
|
7
|
+
interface DateRangeInputAdvancedPanelProps {
|
|
8
|
+
onBeginIntervalChange(unit: unitOfTime.StartOf | "15minutes"): void;
|
|
9
|
+
onIntervalDurationChange(unitOfTime: unitOfTime.DurationConstructor | "4years"): void;
|
|
10
|
+
onTimeShift(shiftBegin: boolean, shiftEnd: boolean, unitOfTime: unitOfTime.DurationConstructor, direction: TimeShiftDirection): void;
|
|
11
|
+
onEndIntervalChange(unit: unitOfTime.StartOf | "15minutes"): void;
|
|
12
|
+
}
|
|
13
|
+
interface DateRangeInputAdvancedPanelState {
|
|
14
|
+
timeShiftBegin: boolean;
|
|
15
|
+
timeShiftBoth: boolean;
|
|
16
|
+
timeShiftEnd: boolean;
|
|
17
|
+
}
|
|
18
|
+
export default class DateRangeInputAdvancedPanel extends React.Component<DateRangeInputAdvancedPanelProps, DateRangeInputAdvancedPanelState> {
|
|
19
|
+
constructor(props: Readonly<DateRangeInputAdvancedPanelProps>);
|
|
20
|
+
private renderSectionTitle;
|
|
21
|
+
private renderButton;
|
|
22
|
+
private renderTimeShiftItem;
|
|
23
|
+
private renderTimeShiftIcon;
|
|
24
|
+
render(): JSX.Element;
|
|
25
|
+
}
|
|
26
|
+
export {};
|