@mailstep/design-system 0.13.7 → 0.13.9-beta.1
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/README.md +1 -0
- package/package.json +4 -5
- package/ui/Blocks/Modal/Modal.js +0 -5
- package/ui/Elements/DropdownMenu/components/MenuItem.js +1 -2
- package/ui/Elements/DropdownSelect/DropdownSelect.js +0 -1
- package/ui/Elements/HighlightBox/HighlightBox.d.ts +0 -1
- package/ui/Elements/HighlightBox/HighlightBox.js +1 -2
- package/ui/Elements/Select/components/ChevronOption.js +1 -2
- package/ui/Elements/Select/components/DropdownIndicator.js +1 -2
- package/ui/Elements/Select/themes/index.js +0 -2
- package/ui/Elements/Toggle/Toggle.js +0 -1
- package/ui/Forms/Checkbox/Checkbox.js +0 -1
- package/ui/Forms/DatePicker/DatePicker.d.ts +0 -5
- package/ui/Forms/DatePicker/DatePicker.js +2 -7
- package/ui/Forms/DatePicker/Datetime/DateTime.d.ts +7 -11
- package/ui/Forms/DatePicker/Datetime/DateTime.js +62 -94
- package/ui/Forms/DatePicker/Datetime/types.d.ts +9 -10
- package/ui/Forms/DatePicker/Datetime/utils/constants.d.ts +4 -0
- package/ui/Forms/DatePicker/Datetime/utils/constants.js +26 -0
- package/ui/Forms/DatePicker/Datetime/utils/toLuxonFormat.d.ts +3 -0
- package/ui/Forms/DatePicker/Datetime/utils/toLuxonFormat.js +8 -0
- package/ui/Forms/DatePicker/Datetime/views/DaysView.js +28 -37
- package/ui/Forms/DatePicker/Datetime/views/MonthsView.js +11 -9
- package/ui/Forms/DatePicker/Datetime/views/YearsView.js +6 -6
- package/ui/Forms/DatePicker/stories/hooks/useOnChange.d.ts +1 -2
- package/ui/Forms/Input/Input.js +0 -1
- package/ui/Modules/CommonGrid/components/ActionHead/ActionHead.js +0 -2
- package/ui/Modules/CommonGrid/components/ButtonMore/ButtonMore.js +0 -1
- package/ui/Modules/CommonGrid/components/ControlButtons/ControlButtons.js +1 -5
- package/ui/Modules/CommonGrid/components/Filters/NumberRange/NumberRange.js +0 -1
- package/ui/Modules/CommonGrid/components/Filters/TextRange/TextRange.js +0 -1
- package/ui/Modules/CommonGrid/components/gridCells/EnumInCell.js +0 -1
- package/ui/Modules/CommonGrid/components/gridCells/IconButtonInCell.js +0 -2
- package/ui/Elements/Select/components/CustomInput.d.ts +0 -2
- package/ui/Elements/Select/components/CustomInput.js +0 -13
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mailstep/design-system",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.9-beta.1",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./ui/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"deploy:win": "npm run build:win && npm publish ./build",
|
|
21
21
|
"dev": "yarn storybook",
|
|
22
22
|
"test": "echo \"The tests are still waiting to be written, but it seems like they're really good at procrastinating!\"",
|
|
23
|
-
"lint": "eslint ./packages/ui/**/*.{ts,tsx}",
|
|
23
|
+
"lint": "eslint './packages/ui/**/*.{ts,tsx}'",
|
|
24
24
|
"prepare": "husky"
|
|
25
25
|
},
|
|
26
26
|
"lint-staged": {
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"@nivo/legends": "^0.73.0",
|
|
46
46
|
"@nivo/pie": "^0.73.0",
|
|
47
47
|
"@popperjs/core": "^2.11.8",
|
|
48
|
+
"@storybook-community/storybook-dark-mode": "7.1.4",
|
|
48
49
|
"@storybook/addon-designs": "^11.1.4",
|
|
49
50
|
"@storybook/addon-docs": "10.6.0",
|
|
50
51
|
"@storybook/addon-links": "10.6.0",
|
|
@@ -55,7 +56,7 @@
|
|
|
55
56
|
"@tsdown/css": "^0.22.3",
|
|
56
57
|
"@types/faker": "^4.1.11",
|
|
57
58
|
"@types/lodash": "^4.17.13",
|
|
58
|
-
"@types/luxon": "^3.4.
|
|
59
|
+
"@types/luxon": "^3.4.4",
|
|
59
60
|
"@types/node": "^20.1.7",
|
|
60
61
|
"@types/react": "^19.2.2",
|
|
61
62
|
"@types/react-beautiful-dnd": "^13.1.2",
|
|
@@ -87,7 +88,6 @@
|
|
|
87
88
|
"lint-staged": "^16.4.0",
|
|
88
89
|
"lodash": "^4.18.0",
|
|
89
90
|
"luxon": "^3.4.4",
|
|
90
|
-
"moment": "^2.30.1",
|
|
91
91
|
"prettier": "2.8.8",
|
|
92
92
|
"react": "^19.2.0",
|
|
93
93
|
"react-dom": "^19.2.0",
|
|
@@ -138,7 +138,6 @@
|
|
|
138
138
|
"immer": "^9.0.19",
|
|
139
139
|
"lodash": "^4.17.21",
|
|
140
140
|
"luxon": "^3.4.4",
|
|
141
|
-
"moment": "^2.30.1",
|
|
142
141
|
"react": "^19.2.0",
|
|
143
142
|
"react-dom": "^19.2.0",
|
|
144
143
|
"react-grid-layout": "^1.2.5",
|
package/ui/Blocks/Modal/Modal.js
CHANGED
|
@@ -41,7 +41,6 @@ const Modal = memo(({ children, isShown = true, onExtraAction, onCancel, title,
|
|
|
41
41
|
style: dialogStyle,
|
|
42
42
|
$backgroundColor: background,
|
|
43
43
|
top,
|
|
44
|
-
"data-cy": "dialogWindow",
|
|
45
44
|
onClick: closeEverywhere ? closeDialog : void 0,
|
|
46
45
|
$minWidth: minWidth,
|
|
47
46
|
$minHeight: minHeight,
|
|
@@ -72,7 +71,6 @@ const Modal = memo(({ children, isShown = true, onExtraAction, onCancel, title,
|
|
|
72
71
|
}),
|
|
73
72
|
withCloseIcon && /* @__PURE__ */ jsx(CloseButton, {
|
|
74
73
|
onClick: closeDialog,
|
|
75
|
-
"data-cy": "dialogCloseBtn",
|
|
76
74
|
children: /* @__PURE__ */ jsx(Cancel, {
|
|
77
75
|
width: "11px",
|
|
78
76
|
height: "11px"
|
|
@@ -88,7 +86,6 @@ const Modal = memo(({ children, isShown = true, onExtraAction, onCancel, title,
|
|
|
88
86
|
type: "button",
|
|
89
87
|
onClick: onExtraAction,
|
|
90
88
|
isLoading,
|
|
91
|
-
"data-cy": "extraActionBtn",
|
|
92
89
|
appearance: "secondary",
|
|
93
90
|
variant: "ghost",
|
|
94
91
|
children: extraActionLabel
|
|
@@ -99,7 +96,6 @@ const Modal = memo(({ children, isShown = true, onExtraAction, onCancel, title,
|
|
|
99
96
|
type: "button",
|
|
100
97
|
onClick: onCancel,
|
|
101
98
|
isLoading,
|
|
102
|
-
"data-cy": "cancelBtn",
|
|
103
99
|
appearance: "secondary",
|
|
104
100
|
variant: "default",
|
|
105
101
|
"data-testid": name ? `button-${name}-cancel` : void 0,
|
|
@@ -109,7 +105,6 @@ const Modal = memo(({ children, isShown = true, onExtraAction, onCancel, title,
|
|
|
109
105
|
onClick: onDialogConfirmClick,
|
|
110
106
|
isLoading,
|
|
111
107
|
disabled: isConfirmDisabled,
|
|
112
|
-
"data-cy": "submitBtn",
|
|
113
108
|
appearance: "primary",
|
|
114
109
|
variant: "default",
|
|
115
110
|
"data-testid": name ? `button-${name}-confirm` : void 0,
|
|
@@ -37,7 +37,7 @@ const StyledLink = styled$1(Link)`
|
|
|
37
37
|
`}
|
|
38
38
|
`;
|
|
39
39
|
const MenuItem = ({ item, ItemComponent, onClose }) => {
|
|
40
|
-
const { onClick, link, hasSeparator,
|
|
40
|
+
const { onClick, link, hasSeparator, autoClose, disabled } = item;
|
|
41
41
|
const isActive = link === useLocation().pathname;
|
|
42
42
|
const onClickCallback = useCallback((e) => {
|
|
43
43
|
if (disabled) {
|
|
@@ -63,7 +63,6 @@ const MenuItem = ({ item, ItemComponent, onClose }) => {
|
|
|
63
63
|
$disabled: !!disabled,
|
|
64
64
|
onClick: onClickCallback,
|
|
65
65
|
$hasSeparator: !!hasSeparator,
|
|
66
|
-
"data-cy": name,
|
|
67
66
|
size: "inherit",
|
|
68
67
|
children: /* @__PURE__ */ jsx(ItemComponent, { ...item })
|
|
69
68
|
});
|
|
@@ -99,7 +99,6 @@ const DropdownSelect = ({ label, appearance, variant, options, showChevron, onSe
|
|
|
99
99
|
variant: variant || "default",
|
|
100
100
|
onClick: toggleDropdownMenu,
|
|
101
101
|
disabled,
|
|
102
|
-
"data-cy": "createProductDropdownMenuBtn",
|
|
103
102
|
children: /* @__PURE__ */ jsxs(ContentWrapper, { children: [
|
|
104
103
|
icon && /* @__PURE__ */ jsx(CustomIconWrap, { children: icon }),
|
|
105
104
|
/* @__PURE__ */ jsx("span", { children: label }),
|
|
@@ -88,12 +88,11 @@ const flagAppearanceToFontColorMap = {
|
|
|
88
88
|
redBold: "#ffffff",
|
|
89
89
|
redSubtle: "red80"
|
|
90
90
|
};
|
|
91
|
-
const HighlightBox = ({ children, appearance, size = "default", cursor, className
|
|
91
|
+
const HighlightBox = ({ children, appearance, size = "default", cursor, className }) => {
|
|
92
92
|
const theme = useTheme();
|
|
93
93
|
return /* @__PURE__ */ jsx(StyledHighlightBox, {
|
|
94
94
|
$bgcolor: th$1.color(appearance ? flagAppearanceToColorMap[appearance] : "transparent")({ theme }),
|
|
95
95
|
$fontColor: th$1.color(appearance ? flagAppearanceToFontColorMap[appearance] : "typoPrimary")({ theme }),
|
|
96
|
-
"data-cy": prefix ? `${prefix}Label` : "label",
|
|
97
96
|
$cursor: cursor,
|
|
98
97
|
children: /* @__PURE__ */ jsx(OverflowWrap, {
|
|
99
98
|
className: size + " " + (className || ""),
|
|
@@ -5,7 +5,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
5
5
|
import { components } from "react-select";
|
|
6
6
|
//#region packages/ui/Elements/Select/components/ChevronOption.tsx
|
|
7
7
|
const ChevronOption = (props) => {
|
|
8
|
-
const { theme, isSelected, selectOption, children
|
|
8
|
+
const { theme, isSelected, selectOption, children } = props;
|
|
9
9
|
const showCheckbox = !!(theme.optionVariant == "checkbox");
|
|
10
10
|
const showToggle = !!(theme.optionVariant == "toggle");
|
|
11
11
|
return /* @__PURE__ */ jsxs(components.Option, {
|
|
@@ -22,7 +22,6 @@ const ChevronOption = (props) => {
|
|
|
22
22
|
variant: "grid"
|
|
23
23
|
})] }), /* @__PURE__ */ jsx("span", {
|
|
24
24
|
className: "label",
|
|
25
|
-
"data-cy": `dropdownModalOption${data.index}`,
|
|
26
25
|
children
|
|
27
26
|
})]
|
|
28
27
|
});
|
|
@@ -9,13 +9,12 @@ const ChevronDiv = styled$1.div`
|
|
|
9
9
|
display: flex;
|
|
10
10
|
`;
|
|
11
11
|
const DropdownIndicator = (props) => {
|
|
12
|
-
const { menuIsOpen
|
|
12
|
+
const { menuIsOpen } = props.selectProps;
|
|
13
13
|
const iconColor = props.theme.colors.placeholderTextColor;
|
|
14
14
|
return /* @__PURE__ */ jsx(components.DropdownIndicator, {
|
|
15
15
|
...props,
|
|
16
16
|
children: /* @__PURE__ */ jsx(ChevronDiv, {
|
|
17
17
|
className: "chevron",
|
|
18
|
-
"data-cy": `${name || ""}ChevronBtn`,
|
|
19
18
|
children: menuIsOpen ? /* @__PURE__ */ jsx(ArrowUp, {
|
|
20
19
|
width: "16px",
|
|
21
20
|
stroke: iconColor
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ChevronOption } from "../components/ChevronOption.js";
|
|
2
2
|
import ConnectedMenu from "../components/ConnectedMenu.js";
|
|
3
3
|
import CountMultiValue from "../components/CountMultiValue.js";
|
|
4
|
-
import { CustomInput } from "../components/CustomInput.js";
|
|
5
4
|
import { DropdownIndicator } from "../components/DropdownIndicator.js";
|
|
6
5
|
import IconValueContainer from "../components/IconValueContainer.js";
|
|
7
6
|
import SimplifiedOption from "../components/SimplifiedOption.js";
|
|
@@ -17,7 +16,6 @@ const useStylesAndComponents = (style = "form", optionVariant = "default", multi
|
|
|
17
16
|
if (multiLabelVariant === "count") components.MultiValue = CountMultiValue;
|
|
18
17
|
if (containerVariant === "search") components.DropdownIndicator = null;
|
|
19
18
|
if (showSelectAllButton) components.MenuList = ConnectedMenu;
|
|
20
|
-
components.Input = CustomInput;
|
|
21
19
|
const themes = getCustomTheme(systemTheme, optionVariant, style === "gridFilter");
|
|
22
20
|
const styles = CustomStyles;
|
|
23
21
|
components.Option = ChevronOption;
|
|
@@ -108,7 +108,6 @@ const Toggle = ({ onChange, label, name, checked, defaultChecked, spaceAround =
|
|
|
108
108
|
defaultChecked,
|
|
109
109
|
onChange: !disabled ? onChange : void 0,
|
|
110
110
|
disabled,
|
|
111
|
-
"data-cy": name ? `${name}Switch` : void 0,
|
|
112
111
|
"data-testid": name ? `toggle-${name}` : void 0,
|
|
113
112
|
readOnly
|
|
114
113
|
}), /* @__PURE__ */ jsx(StyledToggle, {
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { SpaceAround } from '../../Elements/SpaceAround';
|
|
3
3
|
import type { DateTimeOthers, DatetimepickerProps } from './Datetime/types';
|
|
4
|
-
import 'moment/dist/locale/cs';
|
|
5
|
-
import 'moment/dist/locale/el';
|
|
6
|
-
import 'moment/dist/locale/it';
|
|
7
|
-
import 'moment/dist/locale/ru';
|
|
8
|
-
import 'moment/dist/locale/sk';
|
|
9
4
|
export type DatePickerType = DatetimepickerProps & {
|
|
10
5
|
onChange: (value: string | Date) => void;
|
|
11
6
|
disabled?: boolean;
|
|
@@ -8,11 +8,6 @@ import { DatePickerBase } from "./styles.js";
|
|
|
8
8
|
import React, { useCallback, useContext } from "react";
|
|
9
9
|
import { x } from "@xstyled/styled-components";
|
|
10
10
|
import { jsx } from "react/jsx-runtime";
|
|
11
|
-
import "moment/dist/locale/cs";
|
|
12
|
-
import "moment/dist/locale/el";
|
|
13
|
-
import "moment/dist/locale/it";
|
|
14
|
-
import "moment/dist/locale/ru";
|
|
15
|
-
import "moment/dist/locale/sk";
|
|
16
11
|
//#region packages/ui/Forms/DatePicker/DatePicker.tsx
|
|
17
12
|
const defaultDateFormat = "DD.MM.YYYY";
|
|
18
13
|
const DatePicker = ({ name, value, initialViewDate, error, label, disabled, isValidDate, onChange, dateFormat = defaultDateFormat, timeFormat = false, open, secondValue = null, input, icon = true, showInputLabel = false, showCalendarLabel = true, spaceAround = false, className, onClear, onInputChange, ...passProps }) => {
|
|
@@ -50,11 +45,11 @@ const DatePicker = ({ name, value, initialViewDate, error, label, disabled, isVa
|
|
|
50
45
|
return renderCalendar();
|
|
51
46
|
}, [label, showInputLabel]);
|
|
52
47
|
const handleChange = useCallback((value) => {
|
|
53
|
-
const parsed = typeof value === "string" ? value : value?.
|
|
48
|
+
const parsed = typeof value === "string" ? value : value?.toJSDate?.();
|
|
54
49
|
onChange?.(parsed);
|
|
55
50
|
}, [onChange]);
|
|
56
51
|
const handleIsValid = useCallback((current, selected) => {
|
|
57
|
-
const parsed = [current?.
|
|
52
|
+
const parsed = [current?.toJSDate?.(), selected?.toJSDate?.()];
|
|
58
53
|
return isValidDate ? isValidDate(...parsed) : true;
|
|
59
54
|
}, [isValidDate]);
|
|
60
55
|
return /* @__PURE__ */ jsx(SpaceAround_default, {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import moment from 'moment';
|
|
3
2
|
import type { DatetimepickerProps } from './types';
|
|
4
3
|
export default class Datetime extends React.Component<DatetimepickerProps> {
|
|
5
4
|
static defaultProps: {
|
|
@@ -20,13 +19,11 @@ export default class Datetime extends React.Component<DatetimepickerProps> {
|
|
|
20
19
|
inputProps: {};
|
|
21
20
|
timeConstraints: {};
|
|
22
21
|
isValidDate: () => boolean;
|
|
23
|
-
strictParsing: boolean;
|
|
24
22
|
closeOnSelect: boolean;
|
|
25
23
|
closeOnTab: boolean;
|
|
26
24
|
closeOnClickOutside: boolean;
|
|
27
25
|
renderView: (_: any, renderFunc: any) => any;
|
|
28
26
|
};
|
|
29
|
-
static moment: typeof moment;
|
|
30
27
|
constructor(props: any);
|
|
31
28
|
render(): import("react/jsx-runtime").JSX.Element;
|
|
32
29
|
renderInput(): import("react/jsx-runtime").JSX.Element | undefined;
|
|
@@ -46,13 +43,11 @@ export default class Datetime extends React.Component<DatetimepickerProps> {
|
|
|
46
43
|
getClassName(): string;
|
|
47
44
|
isOpen(): any;
|
|
48
45
|
getUpdateOn(dateFormat: any): string;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
getFormat(type: any): any;
|
|
46
|
+
getDateFormat(): string;
|
|
47
|
+
getTimeFormat(): string;
|
|
48
|
+
getFormat(type: any): string;
|
|
53
49
|
_showView: (view: any, date: any) => void;
|
|
54
|
-
|
|
55
|
-
viewToMethod: {
|
|
50
|
+
viewToUnit: {
|
|
56
51
|
days: string;
|
|
57
52
|
months: string;
|
|
58
53
|
years: string;
|
|
@@ -69,8 +64,9 @@ export default class Datetime extends React.Component<DatetimepickerProps> {
|
|
|
69
64
|
_openCalendar: () => void;
|
|
70
65
|
_closeCalendar: () => void;
|
|
71
66
|
_handleClickOutside: () => void;
|
|
72
|
-
|
|
73
|
-
|
|
67
|
+
getZone(): string;
|
|
68
|
+
localize(date: any): any;
|
|
69
|
+
localDate(date: any, format: any): any;
|
|
74
70
|
componentDidUpdate(prevProps: any): void;
|
|
75
71
|
regenerateDates(): void;
|
|
76
72
|
getSelectedDate(): any;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import "./utils/constants.js";
|
|
2
|
+
import { toLuxonFormat } from "./utils/toLuxonFormat.js";
|
|
1
3
|
import DaysView from "./views/DaysView.js";
|
|
2
4
|
import MonthsView from "./views/MonthsView.js";
|
|
3
5
|
import YearsView from "./views/YearsView.js";
|
|
4
6
|
import React from "react";
|
|
7
|
+
import { DateTime } from "luxon";
|
|
5
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
import moment from "moment";
|
|
7
9
|
import onClickOutside from "react-onclickoutside";
|
|
8
10
|
//#region packages/ui/Forms/DatePicker/Datetime/DateTime.tsx
|
|
9
11
|
const viewModes = {
|
|
@@ -37,23 +39,19 @@ var Datetime = class extends React.Component {
|
|
|
37
39
|
isValidDate: function() {
|
|
38
40
|
return true;
|
|
39
41
|
},
|
|
40
|
-
strictParsing: true,
|
|
41
42
|
closeOnSelect: false,
|
|
42
43
|
closeOnTab: true,
|
|
43
44
|
closeOnClickOutside: true,
|
|
44
45
|
renderView: (_, renderFunc) => renderFunc()
|
|
45
46
|
};
|
|
46
47
|
}
|
|
47
|
-
static {
|
|
48
|
-
this.moment = moment;
|
|
49
|
-
}
|
|
50
48
|
constructor(props) {
|
|
51
49
|
super(props);
|
|
52
50
|
this._renderCalendar = () => {
|
|
53
51
|
const props = this.props;
|
|
54
52
|
const state = this.state;
|
|
55
53
|
let viewProps = {
|
|
56
|
-
viewDate: state.viewDate
|
|
54
|
+
viewDate: state.viewDate,
|
|
57
55
|
label: props.label,
|
|
58
56
|
isSecondDatePicker: props.isSecondDatePicker,
|
|
59
57
|
secondValue: props.secondValue,
|
|
@@ -64,7 +62,6 @@ var Datetime = class extends React.Component {
|
|
|
64
62
|
onChangeOthers: props.onChangeOthers,
|
|
65
63
|
reset: this._reset,
|
|
66
64
|
navigate: this._viewNavigate,
|
|
67
|
-
moment,
|
|
68
65
|
showView: this._showView
|
|
69
66
|
};
|
|
70
67
|
switch (state.currentView) {
|
|
@@ -90,15 +87,15 @@ var Datetime = class extends React.Component {
|
|
|
90
87
|
}
|
|
91
88
|
};
|
|
92
89
|
this._showView = (view, date) => {
|
|
93
|
-
const d =
|
|
90
|
+
const d = date || this.state.viewDate;
|
|
94
91
|
const nextView = this.props.onBeforeNavigate(view, this.state.currentView, d);
|
|
95
92
|
if (nextView && this.state.currentView !== nextView) {
|
|
96
93
|
this.props.onNavigate(nextView);
|
|
97
94
|
this.setState({ currentView: nextView });
|
|
98
95
|
}
|
|
99
96
|
};
|
|
100
|
-
this.
|
|
101
|
-
days: "
|
|
97
|
+
this.viewToUnit = {
|
|
98
|
+
days: "day",
|
|
102
99
|
months: "month",
|
|
103
100
|
years: "year"
|
|
104
101
|
};
|
|
@@ -110,35 +107,33 @@ var Datetime = class extends React.Component {
|
|
|
110
107
|
this._updateDate = (e) => {
|
|
111
108
|
let currentView = this.state.currentView;
|
|
112
109
|
let updateOnView = this.getUpdateOn(this.getFormat("date"));
|
|
113
|
-
|
|
114
|
-
viewDate[this.viewToMethod[currentView]](parseInt(e.target.getAttribute("data-value"), 10));
|
|
110
|
+
const values = { [this.viewToUnit[currentView]]: parseInt(e.target.getAttribute("data-value"), 10) };
|
|
115
111
|
if (currentView === "days") {
|
|
116
|
-
|
|
117
|
-
|
|
112
|
+
values.month = parseInt(e.target.getAttribute("data-month"), 10);
|
|
113
|
+
values.year = parseInt(e.target.getAttribute("data-year"), 10);
|
|
118
114
|
}
|
|
115
|
+
const viewDate = this.state.viewDate.set(values);
|
|
119
116
|
let update = { viewDate };
|
|
120
117
|
if (currentView === updateOnView) {
|
|
121
|
-
update.selectedDate = viewDate
|
|
122
|
-
update.inputValue = viewDate.
|
|
118
|
+
update.selectedDate = viewDate;
|
|
119
|
+
update.inputValue = viewDate.toFormat(this.getFormat("datetime"));
|
|
123
120
|
if (this.props.open === void 0 && this.props.input && this.props.closeOnSelect) this._closeCalendar();
|
|
124
|
-
this.props.onChange(viewDate
|
|
121
|
+
this.props.onChange(viewDate);
|
|
125
122
|
} else this._showView(this.nextView[currentView], viewDate);
|
|
126
123
|
this.setState(update);
|
|
127
124
|
};
|
|
128
125
|
this._viewNavigate = (modifier, unit) => {
|
|
129
|
-
|
|
130
|
-
viewDate.add(modifier, unit);
|
|
126
|
+
const viewDate = this.state.viewDate.plus({ [unit]: modifier });
|
|
131
127
|
if (modifier > 0) this.props.onNavigateForward(modifier, unit);
|
|
132
128
|
else this.props.onNavigateBack(-modifier, unit);
|
|
133
129
|
this.setState({ viewDate });
|
|
134
130
|
};
|
|
135
131
|
this._setTime = (type, value) => {
|
|
136
|
-
|
|
137
|
-
date[type](value);
|
|
132
|
+
const date = (this.getSelectedDate() || this.state.viewDate).set({ [type]: value });
|
|
138
133
|
if (!this.props.value) this.setState({
|
|
139
134
|
selectedDate: date,
|
|
140
|
-
viewDate: date
|
|
141
|
-
inputValue: date.
|
|
135
|
+
viewDate: date,
|
|
136
|
+
inputValue: date.toFormat(this.getFormat("datetime"))
|
|
142
137
|
});
|
|
143
138
|
this.props.onChange(date);
|
|
144
139
|
};
|
|
@@ -166,14 +161,14 @@ var Datetime = class extends React.Component {
|
|
|
166
161
|
this._onInputChange = (e) => {
|
|
167
162
|
if (!this.callHandler(this.props.inputProps.onChange, e)) return;
|
|
168
163
|
const value = e.target ? e.target.value : e;
|
|
169
|
-
const
|
|
164
|
+
const parsedDate = this.localDate(value, this.getFormat("datetime"));
|
|
170
165
|
let update = { inputValue: value };
|
|
171
|
-
if (
|
|
172
|
-
update.selectedDate =
|
|
173
|
-
update.viewDate =
|
|
166
|
+
if (parsedDate.isValid) {
|
|
167
|
+
update.selectedDate = parsedDate;
|
|
168
|
+
update.viewDate = parsedDate.startOf("month");
|
|
174
169
|
} else update.selectedDate = null;
|
|
175
170
|
this.setState(update, () => {
|
|
176
|
-
this.props.onChange(
|
|
171
|
+
this.props.onChange(parsedDate.isValid ? parsedDate : this.state.inputValue);
|
|
177
172
|
});
|
|
178
173
|
};
|
|
179
174
|
this._onInputKeyDown = (e) => {
|
|
@@ -218,12 +213,11 @@ var Datetime = class extends React.Component {
|
|
|
218
213
|
let props = this.props;
|
|
219
214
|
let inputFormat = this.getFormat("datetime");
|
|
220
215
|
let selectedDate = this.parseDate(props.value || props.initialValue, inputFormat);
|
|
221
|
-
this.checkTZ();
|
|
222
216
|
return {
|
|
223
217
|
open: !props.input,
|
|
224
218
|
currentView: props.initialViewMode || this.getInitialView(),
|
|
225
219
|
viewDate: this.getInitialViewDate(selectedDate),
|
|
226
|
-
selectedDate: selectedDate && selectedDate.isValid
|
|
220
|
+
selectedDate: selectedDate && selectedDate.isValid ? selectedDate : void 0,
|
|
227
221
|
inputValue: this.getInitialInputValue(selectedDate)
|
|
228
222
|
};
|
|
229
223
|
}
|
|
@@ -232,15 +226,13 @@ var Datetime = class extends React.Component {
|
|
|
232
226
|
let viewDate;
|
|
233
227
|
if (propDate) {
|
|
234
228
|
viewDate = this.parseDate(propDate, this.getFormat("datetime"));
|
|
235
|
-
if (viewDate && viewDate.isValid
|
|
229
|
+
if (viewDate && viewDate.isValid) return viewDate;
|
|
236
230
|
else console.log("The initialViewDated given \"" + propDate + "\" is not valid. Using current date instead.");
|
|
237
|
-
} else if (selectedDate && selectedDate.isValid
|
|
231
|
+
} else if (selectedDate && selectedDate.isValid) return selectedDate;
|
|
238
232
|
return this.getInitialDate();
|
|
239
233
|
}
|
|
240
234
|
getInitialDate() {
|
|
241
|
-
|
|
242
|
-
m.hour(0).minute(0).second(0).millisecond(0);
|
|
243
|
-
return m;
|
|
235
|
+
return this.localDate().startOf("day");
|
|
244
236
|
}
|
|
245
237
|
getInitialView() {
|
|
246
238
|
const dateFormat = this.getFormat("date");
|
|
@@ -248,9 +240,9 @@ var Datetime = class extends React.Component {
|
|
|
248
240
|
}
|
|
249
241
|
parseDate(date, dateFormat) {
|
|
250
242
|
let parsedDate;
|
|
251
|
-
if (date && typeof date === "string") parsedDate = this.
|
|
252
|
-
else if (date) parsedDate = this.
|
|
253
|
-
if (parsedDate && !parsedDate.isValid
|
|
243
|
+
if (date && typeof date === "string") parsedDate = this.localDate(date, dateFormat);
|
|
244
|
+
else if (date) parsedDate = this.localDate(date);
|
|
245
|
+
if (parsedDate && !parsedDate.isValid) parsedDate = null;
|
|
254
246
|
return parsedDate;
|
|
255
247
|
}
|
|
256
248
|
getClassName() {
|
|
@@ -268,27 +260,22 @@ var Datetime = class extends React.Component {
|
|
|
268
260
|
}
|
|
269
261
|
getUpdateOn(dateFormat) {
|
|
270
262
|
if (this.props.updateOnView) return this.props.updateOnView;
|
|
271
|
-
|
|
272
|
-
if (
|
|
273
|
-
if (
|
|
263
|
+
const tokens = dateFormat.replace(/'[^']*'/g, "");
|
|
264
|
+
if (tokens.match(/[dD]/)) return viewModes.DAYS;
|
|
265
|
+
if (tokens.match(/[ML]/)) return viewModes.MONTHS;
|
|
266
|
+
if (tokens.indexOf("y") !== -1) return viewModes.YEARS;
|
|
274
267
|
return viewModes.DAYS;
|
|
275
268
|
}
|
|
276
|
-
getLocaleData() {
|
|
277
|
-
let p = this.props;
|
|
278
|
-
return this.localMoment(p.value || p.defaultValue || /* @__PURE__ */ new Date()).localeData();
|
|
279
|
-
}
|
|
280
269
|
getDateFormat() {
|
|
281
|
-
const locale = this.getLocaleData();
|
|
282
270
|
let format = this.props.dateFormat;
|
|
283
|
-
if (format === true) return
|
|
284
|
-
if (format) return format;
|
|
271
|
+
if (format === true) return "D";
|
|
272
|
+
if (format) return toLuxonFormat(format);
|
|
285
273
|
return "";
|
|
286
274
|
}
|
|
287
275
|
getTimeFormat() {
|
|
288
|
-
const locale = this.getLocaleData();
|
|
289
276
|
let format = this.props.timeFormat;
|
|
290
|
-
if (format === true) return
|
|
291
|
-
return format
|
|
277
|
+
if (format === true) return "t";
|
|
278
|
+
return format ? toLuxonFormat(format) : "";
|
|
292
279
|
}
|
|
293
280
|
getFormat(type) {
|
|
294
281
|
if (type === "date") return this.getDateFormat();
|
|
@@ -297,24 +284,23 @@ var Datetime = class extends React.Component {
|
|
|
297
284
|
let timeFormat = this.getTimeFormat();
|
|
298
285
|
return dateFormat && timeFormat ? dateFormat + " " + timeFormat : dateFormat || timeFormat;
|
|
299
286
|
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
update[date] = this.state[date].clone()[op](amount, type);
|
|
304
|
-
this.setState(update);
|
|
287
|
+
getZone() {
|
|
288
|
+
if (this.props.utc) return "utc";
|
|
289
|
+
return this.props.displayTimeZone || "local";
|
|
305
290
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
if (props.utc) m = moment.utc(date, format, props.strictParsing);
|
|
310
|
-
else if (props.displayTimeZone) m = moment.tz(date, format, props.displayTimeZone);
|
|
311
|
-
else m = moment(date, format, props.strictParsing);
|
|
312
|
-
if (props.locale) m.locale(props.locale);
|
|
313
|
-
return m;
|
|
291
|
+
localize(date) {
|
|
292
|
+
const zoned = date.setZone(this.getZone());
|
|
293
|
+
return this.props.locale ? zoned.setLocale(this.props.locale) : zoned;
|
|
314
294
|
}
|
|
315
|
-
|
|
316
|
-
const
|
|
317
|
-
if (
|
|
295
|
+
localDate(date, format) {
|
|
296
|
+
const zone = this.getZone();
|
|
297
|
+
if (date === void 0) return this.localize(DateTime.now());
|
|
298
|
+
if (typeof date === "string") return this.localize(DateTime.fromFormat(date, format, {
|
|
299
|
+
zone,
|
|
300
|
+
locale: this.props.locale
|
|
301
|
+
}));
|
|
302
|
+
if (DateTime.isDateTime(date)) return this.localize(date);
|
|
303
|
+
return this.localize(DateTime.fromJSDate(date instanceof Date ? date : new Date(date)));
|
|
318
304
|
}
|
|
319
305
|
componentDidUpdate(prevProps) {
|
|
320
306
|
if (prevProps === this.props) return;
|
|
@@ -323,7 +309,7 @@ var Datetime = class extends React.Component {
|
|
|
323
309
|
[
|
|
324
310
|
"locale",
|
|
325
311
|
"utc",
|
|
326
|
-
"
|
|
312
|
+
"displayTimeZone",
|
|
327
313
|
"dateFormat",
|
|
328
314
|
"timeFormat"
|
|
329
315
|
].forEach(function(p) {
|
|
@@ -331,49 +317,33 @@ var Datetime = class extends React.Component {
|
|
|
331
317
|
});
|
|
332
318
|
if (needsUpdate) this.regenerateDates();
|
|
333
319
|
if (thisProps.value && thisProps.value !== prevProps.value) this.setViewDate(thisProps.value);
|
|
334
|
-
this.checkTZ();
|
|
335
320
|
}
|
|
336
321
|
regenerateDates() {
|
|
337
|
-
const
|
|
338
|
-
|
|
339
|
-
let selectedDate = this.state.selectedDate && this.state.selectedDate.clone();
|
|
340
|
-
if (props.locale) {
|
|
341
|
-
viewDate.locale(props.locale);
|
|
342
|
-
selectedDate && selectedDate.locale(props.locale);
|
|
343
|
-
}
|
|
344
|
-
if (props.utc) {
|
|
345
|
-
viewDate.utc();
|
|
346
|
-
selectedDate && selectedDate.utc();
|
|
347
|
-
} else if (props.displayTimeZone) {
|
|
348
|
-
viewDate.tz(props.displayTimeZone);
|
|
349
|
-
selectedDate && selectedDate.tz(props.displayTimeZone);
|
|
350
|
-
} else {
|
|
351
|
-
viewDate.locale();
|
|
352
|
-
selectedDate && selectedDate.locale();
|
|
353
|
-
}
|
|
322
|
+
const viewDate = this.localize(this.state.viewDate);
|
|
323
|
+
const selectedDate = this.state.selectedDate && this.localize(this.state.selectedDate);
|
|
354
324
|
let update = {
|
|
355
325
|
viewDate,
|
|
356
326
|
selectedDate
|
|
357
327
|
};
|
|
358
|
-
if (selectedDate && selectedDate.isValid
|
|
328
|
+
if (selectedDate && selectedDate.isValid) update.inputValue = selectedDate.toFormat(this.getFormat("datetime"));
|
|
359
329
|
this.setState(update);
|
|
360
330
|
}
|
|
361
331
|
getSelectedDate() {
|
|
362
332
|
if (this.props.value === void 0) return this.state.selectedDate;
|
|
363
333
|
let selectedDate = this.parseDate(this.props.value, this.getFormat("datetime"));
|
|
364
|
-
return selectedDate && selectedDate.isValid
|
|
334
|
+
return selectedDate && selectedDate.isValid ? selectedDate : false;
|
|
365
335
|
}
|
|
366
336
|
getInitialInputValue(selectedDate) {
|
|
367
337
|
const props = this.props;
|
|
368
338
|
if (props.inputProps.value) return props.inputProps.value;
|
|
369
|
-
if (selectedDate && selectedDate.isValid
|
|
339
|
+
if (selectedDate && selectedDate.isValid) return selectedDate.toFormat(this.getFormat("datetime"));
|
|
370
340
|
if (props.value && typeof props.value === "string") return props.value;
|
|
371
341
|
if (props.initialValue && typeof props.initialValue === "string") return props.initialValue;
|
|
372
342
|
return "";
|
|
373
343
|
}
|
|
374
344
|
getInputValue() {
|
|
375
345
|
let selectedDate = this.getSelectedDate();
|
|
376
|
-
return selectedDate ? selectedDate.
|
|
346
|
+
return selectedDate ? selectedDate.toFormat(this.getFormat("datetime")) : this.state.inputValue;
|
|
377
347
|
}
|
|
378
348
|
/**
|
|
379
349
|
* Set the date that is currently shown in the calendar.
|
|
@@ -386,10 +356,8 @@ var Datetime = class extends React.Component {
|
|
|
386
356
|
return console.log("Invalid date passed to the `setViewDate` method: " + date);
|
|
387
357
|
};
|
|
388
358
|
if (!date) return logError();
|
|
389
|
-
|
|
390
|
-
if (
|
|
391
|
-
else viewDate = this.localMoment(date);
|
|
392
|
-
if (!viewDate || !viewDate.isValid()) return logError();
|
|
359
|
+
const viewDate = this.localDate(date, this.getFormat("datetime"));
|
|
360
|
+
if (!viewDate || !viewDate.isValid) return logError();
|
|
393
361
|
this.setState({ viewDate });
|
|
394
362
|
}
|
|
395
363
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FocusEvent, FocusEventHandler, ReactNode } from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { DateTime } from 'luxon';
|
|
3
3
|
export type ViewMode = 'years' | 'months' | 'days' | 'time';
|
|
4
4
|
export interface TimeConstraint {
|
|
5
5
|
min: number;
|
|
@@ -12,11 +12,11 @@ export interface TimeConstraints {
|
|
|
12
12
|
seconds?: TimeConstraint;
|
|
13
13
|
milliseconds?: TimeConstraint;
|
|
14
14
|
}
|
|
15
|
-
type EventOrValueHandler<Event> = (event: Event |
|
|
15
|
+
type EventOrValueHandler<Event> = (event: Event | DateTime | string) => void;
|
|
16
16
|
export interface DatetimepickerProps {
|
|
17
|
-
value?: Date | string |
|
|
18
|
-
initialValue?: Date | string |
|
|
19
|
-
initialViewDate?: Date | string |
|
|
17
|
+
value?: Date | string | DateTime;
|
|
18
|
+
initialValue?: Date | string | DateTime;
|
|
19
|
+
initialViewDate?: Date | string | DateTime;
|
|
20
20
|
initialViewMode?: ViewMode;
|
|
21
21
|
updateOnView?: string;
|
|
22
22
|
dateFormat?: boolean | string;
|
|
@@ -26,11 +26,11 @@ export interface DatetimepickerProps {
|
|
|
26
26
|
locale?: string;
|
|
27
27
|
utc?: boolean;
|
|
28
28
|
displayTimeZone?: string;
|
|
29
|
-
onChange?: (value:
|
|
29
|
+
onChange?: (value: DateTime | string) => void;
|
|
30
30
|
onOpen?: FocusEventHandler<any>;
|
|
31
31
|
onClose?: EventOrValueHandler<FocusEvent<any>>;
|
|
32
32
|
onNavigate?: (viewMode: string) => void;
|
|
33
|
-
onBeforeNavigate?: (nextView: string, currentView: string, viewDate:
|
|
33
|
+
onBeforeNavigate?: (nextView: string, currentView: string, viewDate: DateTime) => string;
|
|
34
34
|
onNavigateBack?: (amount: number, type: string) => void;
|
|
35
35
|
onNavigateForward?: (amount: number, type: string) => void;
|
|
36
36
|
className?: string;
|
|
@@ -41,7 +41,6 @@ export interface DatetimepickerProps {
|
|
|
41
41
|
renderMonth?: (props: any, month: number, year: number, selectedDate: any) => ReactNode;
|
|
42
42
|
renderYear?: (props: any, year: number, selectedDate: any) => ReactNode;
|
|
43
43
|
renderInput?: (props: any, openCalendar: Function, closeCalendar: Function) => ReactNode;
|
|
44
|
-
strictParsing?: boolean;
|
|
45
44
|
closeOnSelect?: boolean;
|
|
46
45
|
timeConstraints?: TimeConstraints;
|
|
47
46
|
closeOnClickOutside?: boolean;
|
|
@@ -52,8 +51,8 @@ export interface DatetimepickerProps {
|
|
|
52
51
|
export interface DatetimepickerState {
|
|
53
52
|
updateOn: string;
|
|
54
53
|
inputFormat: string;
|
|
55
|
-
viewDate:
|
|
56
|
-
selectedDate:
|
|
54
|
+
viewDate: DateTime;
|
|
55
|
+
selectedDate: DateTime;
|
|
57
56
|
inputValue: string;
|
|
58
57
|
open: boolean;
|
|
59
58
|
secondValue?: Date | null;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region packages/ui/Forms/DatePicker/Datetime/utils/constants.ts
|
|
2
|
+
const MOMENT_TOKEN_PATTERN = /\[([^\]]*)]|YYYY|YY|MMMM|MMM|MM|M|DD|D|HH|H|hh|h|mm|m|ss|s|A|a/g;
|
|
3
|
+
const LUXON_TOKENS = {
|
|
4
|
+
YYYY: "yyyy",
|
|
5
|
+
YY: "yy",
|
|
6
|
+
MMMM: "MMMM",
|
|
7
|
+
MMM: "MMM",
|
|
8
|
+
MM: "MM",
|
|
9
|
+
M: "M",
|
|
10
|
+
DD: "dd",
|
|
11
|
+
D: "d",
|
|
12
|
+
HH: "HH",
|
|
13
|
+
H: "H",
|
|
14
|
+
hh: "hh",
|
|
15
|
+
h: "h",
|
|
16
|
+
mm: "mm",
|
|
17
|
+
m: "m",
|
|
18
|
+
ss: "ss",
|
|
19
|
+
s: "s",
|
|
20
|
+
A: "a",
|
|
21
|
+
a: "a"
|
|
22
|
+
};
|
|
23
|
+
const LOCALE_DATE_FORMAT = "D";
|
|
24
|
+
const LOCALE_TIME_FORMAT = "t";
|
|
25
|
+
//#endregion
|
|
26
|
+
export { LOCALE_DATE_FORMAT, LOCALE_TIME_FORMAT, LUXON_TOKENS, MOMENT_TOKEN_PATTERN };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { LUXON_TOKENS, MOMENT_TOKEN_PATTERN } from "./constants.js";
|
|
2
|
+
//#region packages/ui/Forms/DatePicker/Datetime/utils/toLuxonFormat.ts
|
|
3
|
+
const toLuxonFormat = (format) => format.replace(MOMENT_TOKEN_PATTERN, (token, escaped) => {
|
|
4
|
+
if (escaped === void 0) return LUXON_TOKENS[token];
|
|
5
|
+
return escaped ? `'${escaped}'` : "";
|
|
6
|
+
});
|
|
7
|
+
//#endregion
|
|
8
|
+
export { toLuxonFormat };
|
|
@@ -3,6 +3,7 @@ import { Timepicker } from "../components/Timepicker/Timepicker.js";
|
|
|
3
3
|
import "../components/Timepicker/index.js";
|
|
4
4
|
import ViewNavigation from "../components/ViewNavigation.js";
|
|
5
5
|
import React from "react";
|
|
6
|
+
import { DateTime, Info } from "luxon";
|
|
6
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
8
|
//#region packages/ui/Forms/DatePicker/Datetime/views/DaysView.tsx
|
|
8
9
|
var DaysView = class extends React.Component {
|
|
@@ -17,7 +18,7 @@ var DaysView = class extends React.Component {
|
|
|
17
18
|
isValidDate: () => true,
|
|
18
19
|
renderDay: (props, date) => /* @__PURE__ */ jsx("td", {
|
|
19
20
|
...props,
|
|
20
|
-
children: date.
|
|
21
|
+
children: date.day
|
|
21
22
|
})
|
|
22
23
|
};
|
|
23
24
|
}
|
|
@@ -33,28 +34,27 @@ var DaysView = class extends React.Component {
|
|
|
33
34
|
}
|
|
34
35
|
renderNavigation() {
|
|
35
36
|
const date = this.props.viewDate;
|
|
36
|
-
const locale = date.localeData();
|
|
37
37
|
const label = this.props.label;
|
|
38
38
|
return /* @__PURE__ */ jsx(ViewNavigation, {
|
|
39
39
|
onClickPrev: () => this.props.navigate(-1, "months"),
|
|
40
40
|
onClickSwitch: () => this.props.showView("months"),
|
|
41
41
|
onClickNext: () => this.props.navigate(1, "months"),
|
|
42
|
-
switchContent:
|
|
42
|
+
switchContent: date.toFormat("LLLL yyyy"),
|
|
43
43
|
switchColSpan: 3,
|
|
44
44
|
label,
|
|
45
|
-
switchProps: { "data-value": this.props.viewDate.month
|
|
45
|
+
switchProps: { "data-value": this.props.viewDate.month - 1 }
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
renderDayHeaders() {
|
|
49
|
-
return /* @__PURE__ */ jsx("tr", { children: getDaysOfWeek(this.props.viewDate.
|
|
49
|
+
return /* @__PURE__ */ jsx("tr", { children: getDaysOfWeek(this.props.viewDate.locale).map((day, index) => /* @__PURE__ */ jsx("th", {
|
|
50
50
|
className: "dow",
|
|
51
51
|
children: day
|
|
52
52
|
}, day + index)) });
|
|
53
53
|
}
|
|
54
54
|
renderDays() {
|
|
55
55
|
const date = this.props.viewDate;
|
|
56
|
-
const startOfMonth = date.
|
|
57
|
-
const endOfMonth = date.
|
|
56
|
+
const startOfMonth = date.startOf("month");
|
|
57
|
+
const endOfMonth = date.endOf("month");
|
|
58
58
|
let rows = [
|
|
59
59
|
[],
|
|
60
60
|
[],
|
|
@@ -63,38 +63,38 @@ var DaysView = class extends React.Component {
|
|
|
63
63
|
[],
|
|
64
64
|
[]
|
|
65
65
|
];
|
|
66
|
-
let startDate = date.
|
|
67
|
-
startDate.
|
|
68
|
-
let endDate = startDate.clone().add(42, "d");
|
|
66
|
+
let startDate = date.minus({ months: 1 }).endOf("month").startOf("week", { useLocaleWeeks: true });
|
|
67
|
+
let endDate = startDate.plus({ days: 42 });
|
|
69
68
|
let i = 0;
|
|
70
|
-
while (startDate
|
|
69
|
+
while (startDate < endDate) {
|
|
71
70
|
getRow(rows, i++).push(this.renderDay(startDate, startOfMonth, endOfMonth));
|
|
72
|
-
startDate.
|
|
71
|
+
startDate = startDate.plus({ days: 1 });
|
|
73
72
|
}
|
|
74
|
-
return rows.map((r, i) => /* @__PURE__ */ jsx("tr", { children: r }, `${endDate.month
|
|
73
|
+
return rows.map((r, i) => /* @__PURE__ */ jsx("tr", { children: r }, `${endDate.month}_${i}`));
|
|
75
74
|
}
|
|
76
75
|
renderDay(date, startOfMonth, endOfMonth) {
|
|
77
76
|
let selectedDate = this.props.selectedDate;
|
|
78
77
|
let secondValue = this.props.secondValue;
|
|
79
78
|
let dayProps = {
|
|
80
|
-
key: date.
|
|
81
|
-
"data-value": date.
|
|
82
|
-
"data-month": date.month
|
|
83
|
-
"data-year": date.year
|
|
79
|
+
key: date.toFormat("M_d"),
|
|
80
|
+
"data-value": date.day,
|
|
81
|
+
"data-month": date.month,
|
|
82
|
+
"data-year": date.year
|
|
84
83
|
};
|
|
84
|
+
const second = secondValue && DateTime.fromJSDate(secondValue).setZone(date.zone);
|
|
85
85
|
let className = "rdtDay";
|
|
86
|
-
if (date
|
|
87
|
-
else if (date
|
|
88
|
-
if (
|
|
89
|
-
if (
|
|
90
|
-
if (selectedDate && date.
|
|
91
|
-
if (
|
|
92
|
-
if (date.
|
|
86
|
+
if (date < startOfMonth) className += " rdtOld";
|
|
87
|
+
else if (date > endOfMonth) className += " rdtNew";
|
|
88
|
+
if (second && selectedDate && date < second && date > selectedDate) className += " rdtActiveRange";
|
|
89
|
+
if (second && selectedDate && date > second && date < selectedDate) className += " rdtActiveRange";
|
|
90
|
+
if (selectedDate && date.hasSame(selectedDate, "day")) className += " rdtActive";
|
|
91
|
+
if (second && date.hasSame(second, "day")) className += " rdtActiveSecond";
|
|
92
|
+
if (date.hasSame(DateTime.now().setZone(date.zone), "day")) className += " rdtToday";
|
|
93
93
|
if (this.props.isValidDate(date) && !this.props.others?.dateTypeRepeater && !this.props.disabled) dayProps.onClick = this._setDate;
|
|
94
94
|
else className += " rdtDisabled";
|
|
95
95
|
if (this.props.others?.dateTypeRepeater || this.props.disabled) className += " rdtDisabled";
|
|
96
96
|
dayProps.className = className;
|
|
97
|
-
return this.props.renderDay(dayProps, date
|
|
97
|
+
return this.props.renderDay(dayProps, date, selectedDate);
|
|
98
98
|
}
|
|
99
99
|
renderFooter() {
|
|
100
100
|
const setTime = this.props.setTime;
|
|
@@ -123,19 +123,10 @@ var DaysView = class extends React.Component {
|
|
|
123
123
|
function getRow(rows, day) {
|
|
124
124
|
return rows[Math.floor(day / 7)];
|
|
125
125
|
}
|
|
126
|
-
/**
|
|
127
|
-
* Get a list of the days of the week
|
|
128
|
-
* depending on the current locale
|
|
129
|
-
* @return {array} A list with the shortname of the days
|
|
130
|
-
*/
|
|
131
126
|
function getDaysOfWeek(locale) {
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
locale._weekdaysMin.forEach(function(day) {
|
|
136
|
-
dow[(7 + i++ - first) % 7] = day;
|
|
137
|
-
});
|
|
138
|
-
return dow;
|
|
127
|
+
const weekdays = Info.weekdays("short", { locale }).map((day) => day.slice(0, 2));
|
|
128
|
+
const firstDayIndex = Info.getStartOfWeek({ locale }) - 1;
|
|
129
|
+
return [...weekdays.slice(firstDayIndex), ...weekdays.slice(0, firstDayIndex)];
|
|
139
130
|
}
|
|
140
131
|
//#endregion
|
|
141
132
|
export { DaysView as default };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import ViewNavigation from "../components/ViewNavigation.js";
|
|
2
2
|
import React from "react";
|
|
3
|
+
import { Info } from "luxon";
|
|
3
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
5
|
//#region packages/ui/Forms/DatePicker/Datetime/views/MonthsView.tsx
|
|
5
6
|
var MonthsView = class extends React.Component {
|
|
@@ -16,11 +17,12 @@ var MonthsView = class extends React.Component {
|
|
|
16
17
|
});
|
|
17
18
|
}
|
|
18
19
|
renderNavigation() {
|
|
20
|
+
let year = this.props.viewDate.year;
|
|
19
21
|
return /* @__PURE__ */ jsx(ViewNavigation, {
|
|
20
22
|
onClickPrev: () => this.props.navigate(-1, "years"),
|
|
21
23
|
onClickSwitch: () => this.props.showView("years"),
|
|
22
24
|
onClickNext: () => this.props.navigate(1, "years"),
|
|
23
|
-
switchContent:
|
|
25
|
+
switchContent: year,
|
|
24
26
|
switchColSpan: "2"
|
|
25
27
|
});
|
|
26
28
|
}
|
|
@@ -39,14 +41,14 @@ var MonthsView = class extends React.Component {
|
|
|
39
41
|
let onClick;
|
|
40
42
|
if (this.isDisabledMonth(month)) className += " rdtDisabled";
|
|
41
43
|
else onClick = this._updateSelectedMonth;
|
|
42
|
-
if (selectedDate && selectedDate.year
|
|
44
|
+
if (selectedDate && selectedDate.year === this.props.viewDate.year && selectedDate.month === month + 1) className += " rdtActive";
|
|
43
45
|
let props = {
|
|
44
46
|
key: month,
|
|
45
47
|
className,
|
|
46
|
-
"data-value": month,
|
|
48
|
+
"data-value": month + 1,
|
|
47
49
|
onClick
|
|
48
50
|
};
|
|
49
|
-
if (this.props.renderMonth) return this.props.renderMonth(props, month, this.props.viewDate.year
|
|
51
|
+
if (this.props.renderMonth) return this.props.renderMonth(props, month, this.props.viewDate.year, this.props.selectedDate);
|
|
50
52
|
return /* @__PURE__ */ jsx("td", {
|
|
51
53
|
...props,
|
|
52
54
|
children: this.getMonthText(month)
|
|
@@ -55,14 +57,14 @@ var MonthsView = class extends React.Component {
|
|
|
55
57
|
isDisabledMonth(month) {
|
|
56
58
|
let isValidDate = this.props.isValidDate;
|
|
57
59
|
if (!isValidDate) return false;
|
|
58
|
-
let date = this.props.viewDate.
|
|
59
|
-
let day = date.
|
|
60
|
-
while (day-- > 1) if (isValidDate(date.
|
|
60
|
+
let date = this.props.viewDate.set({ month: month + 1 });
|
|
61
|
+
let day = date.daysInMonth + 1;
|
|
62
|
+
while (day-- > 1) if (isValidDate(date.set({ day }))) return false;
|
|
61
63
|
return true;
|
|
62
64
|
}
|
|
63
65
|
getMonthText(month) {
|
|
64
|
-
const
|
|
65
|
-
return capitalize(
|
|
66
|
+
const monthStr = Info.months("short", { locale: this.props.viewDate.locale })[month];
|
|
67
|
+
return capitalize(monthStr.substring(0, 3));
|
|
66
68
|
}
|
|
67
69
|
};
|
|
68
70
|
function getRow(rows, year) {
|
|
@@ -54,22 +54,22 @@ var YearsView = class extends React.Component {
|
|
|
54
54
|
"data-value": year,
|
|
55
55
|
onClick
|
|
56
56
|
};
|
|
57
|
-
return this.props.renderYear(props, year, this.props.selectedDate
|
|
57
|
+
return this.props.renderYear(props, year, this.props.selectedDate);
|
|
58
58
|
}
|
|
59
59
|
getViewYear() {
|
|
60
|
-
return parseInt(this.props.viewDate.year
|
|
60
|
+
return parseInt(this.props.viewDate.year / 10, 10) * 10;
|
|
61
61
|
}
|
|
62
62
|
getSelectedYear() {
|
|
63
|
-
return this.props.selectedDate && this.props.selectedDate.year
|
|
63
|
+
return this.props.selectedDate && this.props.selectedDate.year;
|
|
64
64
|
}
|
|
65
65
|
isDisabledYear(year) {
|
|
66
66
|
let cache = this.disabledYearsCache;
|
|
67
67
|
if (cache[year] !== void 0) return cache[year];
|
|
68
68
|
let isValidDate = this.props.isValidDate;
|
|
69
69
|
if (!isValidDate) return false;
|
|
70
|
-
let date = this.props.viewDate.
|
|
71
|
-
let day = date.
|
|
72
|
-
while (day-- > 1) if (isValidDate(date.
|
|
70
|
+
let date = this.props.viewDate.set({ year });
|
|
71
|
+
let day = date.daysInYear + 1;
|
|
72
|
+
while (day-- > 1) if (isValidDate(date.set({ ordinal: day }))) {
|
|
73
73
|
cache[year] = false;
|
|
74
74
|
return false;
|
|
75
75
|
}
|
package/ui/Forms/Input/Input.js
CHANGED
|
@@ -66,7 +66,6 @@ const Input = ({ appearance = "primary", type, name, label, value, icon, variant
|
|
|
66
66
|
className: `${appearance} ${checkIconPlacement}`,
|
|
67
67
|
type,
|
|
68
68
|
name,
|
|
69
|
-
"data-cy": name ? `${name}Inp` : void 0,
|
|
70
69
|
"data-testid": name ? `input-${name}` : void 0,
|
|
71
70
|
value,
|
|
72
71
|
$isInvalid,
|
|
@@ -93,7 +93,6 @@ const ActionHead = ({ gridActions, gridSelectors, actionOptions, onBatchAction,
|
|
|
93
93
|
onClick: checkAll,
|
|
94
94
|
appearance: "secondary",
|
|
95
95
|
variant: "default",
|
|
96
|
-
"data-cy": "checkAllBtn",
|
|
97
96
|
disabled: checked,
|
|
98
97
|
children: /* @__PURE__ */ jsx(Trans, {
|
|
99
98
|
id: "dataGrid.checkAll",
|
|
@@ -105,7 +104,6 @@ const ActionHead = ({ gridActions, gridSelectors, actionOptions, onBatchAction,
|
|
|
105
104
|
onClick: processCheckedValues,
|
|
106
105
|
appearance: "primary",
|
|
107
106
|
variant: "default",
|
|
108
|
-
"data-cy": "exportBtn",
|
|
109
107
|
disabled: !rowsData.length,
|
|
110
108
|
children: processCheckedValuesTitle || /* @__PURE__ */ jsx(Trans, {
|
|
111
109
|
id: "dataGrid.actionOptions.export",
|
|
@@ -67,7 +67,6 @@ const ControlButtons = ({ extraControlButtons, gridActions, gridSelectors, quick
|
|
|
67
67
|
onClick: onClearSettings,
|
|
68
68
|
variant: "default",
|
|
69
69
|
appearance: "secondary",
|
|
70
|
-
"data-cy": "resetFiltersBtn",
|
|
71
70
|
children: /* @__PURE__ */ jsx(Trans, {
|
|
72
71
|
id: "dataGrid.buttonClearSettings",
|
|
73
72
|
message: "Reset"
|
|
@@ -78,7 +77,6 @@ const ControlButtons = ({ extraControlButtons, gridActions, gridSelectors, quick
|
|
|
78
77
|
type: "button",
|
|
79
78
|
appearance: filtersCount ? "primary" : "tertiary",
|
|
80
79
|
onClick: onOpenMobileFilters,
|
|
81
|
-
"data-cy": "mobileFilterBtn",
|
|
82
80
|
children: [/* @__PURE__ */ jsx(Filter, { fill: filtersCount ? "white" : red }), /* @__PURE__ */ jsxs(H6, {
|
|
83
81
|
variant: "semiBold",
|
|
84
82
|
mt: 0,
|
|
@@ -101,7 +99,6 @@ const ControlButtons = ({ extraControlButtons, gridActions, gridSelectors, quick
|
|
|
101
99
|
appearance: sortCount ? "primary" : "tertiary",
|
|
102
100
|
onClick: onOpenMobileSorting,
|
|
103
101
|
disabled: isSortTerminated,
|
|
104
|
-
"data-cy": "mobileSortBtn",
|
|
105
102
|
children: [/* @__PURE__ */ jsx(Sort, { stroke: sortCount ? "white" : red }), /* @__PURE__ */ jsxs(H6, {
|
|
106
103
|
variant: "semiBold",
|
|
107
104
|
mt: 0,
|
|
@@ -158,8 +155,7 @@ const ControlButtons = ({ extraControlButtons, gridActions, gridSelectors, quick
|
|
|
158
155
|
title: i18n._({
|
|
159
156
|
id: "dataGrid.share.title",
|
|
160
157
|
message: "Share"
|
|
161
|
-
})
|
|
162
|
-
"data-cy": "shareGridBtn"
|
|
158
|
+
})
|
|
163
159
|
})] }),
|
|
164
160
|
displayManageColumnButton && !isMobile && /* @__PURE__ */ jsx(StyledColumnButton, {
|
|
165
161
|
type: "button",
|
|
@@ -8,7 +8,6 @@ import { Link } from "react-router-dom";
|
|
|
8
8
|
const IconButtonInCell = ({ icon, isLoading, onClick, linkTo }) => {
|
|
9
9
|
return /* @__PURE__ */ jsx(Fragment, { children: isLoading ? /* @__PURE__ */ jsx(Spinner, { variant: "sm" }) : linkTo ? /* @__PURE__ */ jsx(Link, {
|
|
10
10
|
to: linkTo,
|
|
11
|
-
"data-cy": `${icon ?? ""}IconBtn`,
|
|
12
11
|
children: /* @__PURE__ */ jsx(Icon, {
|
|
13
12
|
icon: icon || "warning",
|
|
14
13
|
size: "16px",
|
|
@@ -16,7 +15,6 @@ const IconButtonInCell = ({ icon, isLoading, onClick, linkTo }) => {
|
|
|
16
15
|
})
|
|
17
16
|
}) : /* @__PURE__ */ jsx(x.span, {
|
|
18
17
|
onClick,
|
|
19
|
-
"data-cy": `${icon ?? ""}IconBtn`,
|
|
20
18
|
cursor: "pointer",
|
|
21
19
|
h: "100%",
|
|
22
20
|
display: "flex",
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { components } from "react-select";
|
|
3
|
-
//#region packages/ui/Elements/Select/components/CustomInput.tsx
|
|
4
|
-
const CustomInput = (props) => {
|
|
5
|
-
const { name } = props.selectProps;
|
|
6
|
-
const value = !!name ? `${name}Inp` : props.id;
|
|
7
|
-
return /* @__PURE__ */ jsx(components.Input, {
|
|
8
|
-
...props,
|
|
9
|
-
"data-cy": value
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
|
-
//#endregion
|
|
13
|
-
export { CustomInput, CustomInput as default };
|