@mailstep/design-system 0.13.8 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mailstep/design-system",
3
- "version": "0.13.8",
3
+ "version": "0.13.9-beta.1",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "main": "./ui/index.js",
@@ -56,7 +56,7 @@
56
56
  "@tsdown/css": "^0.22.3",
57
57
  "@types/faker": "^4.1.11",
58
58
  "@types/lodash": "^4.17.13",
59
- "@types/luxon": "^3.4.2",
59
+ "@types/luxon": "^3.4.4",
60
60
  "@types/node": "^20.1.7",
61
61
  "@types/react": "^19.2.2",
62
62
  "@types/react-beautiful-dnd": "^13.1.2",
@@ -88,7 +88,6 @@
88
88
  "lint-staged": "^16.4.0",
89
89
  "lodash": "^4.18.0",
90
90
  "luxon": "^3.4.4",
91
- "moment": "^2.30.1",
92
91
  "prettier": "2.8.8",
93
92
  "react": "^19.2.0",
94
93
  "react-dom": "^19.2.0",
@@ -139,7 +138,6 @@
139
138
  "immer": "^9.0.19",
140
139
  "lodash": "^4.17.21",
141
140
  "luxon": "^3.4.4",
142
- "moment": "^2.30.1",
143
141
  "react": "^19.2.0",
144
142
  "react-dom": "^19.2.0",
145
143
  "react-grid-layout": "^1.2.5",
@@ -1,6 +1,6 @@
1
1
  import Icon from "../../Elements/Icon/Icon.js";
2
2
  import { Paragraph3, Paragraph5 } from "../../Elements/Typography/Typography.js";
3
- import { ItemCount, ItemDropdownArrow, ItemIcon, ItemLabel, ItemLinkWrap, ItemsSeparator, MenuItemContainer, OverflowWithEllipsis, SubItemsWrap } from "./styles.js";
3
+ import { ItemDropdownArrow, ItemIcon, ItemLabel, ItemLinkWrap, ItemsSeparator, MenuItemContainer, OverflowWithEllipsis, SubItemsWrap } from "./styles.js";
4
4
  import SubitemTooltip from "./components/SubitemTooltip.js";
5
5
  import { useLeftMenuContext } from "./context/useLeftMenuContext.js";
6
6
  import useOutSideHover from "./hooks/useOutsideHover.js";
@@ -9,7 +9,7 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
9
  import { matchPath } from "react-router";
10
10
  //#region packages/ui/Blocks/SideMenu/MenuItem.tsx
11
11
  const removeOptionalEnd = /\?$/;
12
- const MenuItem = ({ icon, title, link = "", items, id, count, isSubitem, isCompact, lightMode = false, separator = false, isLeftMenuOpen, onCloseLeftMenu, onClick }) => {
12
+ const MenuItem = ({ icon, title, link = "", items, id, isSubitem, isCompact, lightMode = false, separator = false, isLeftMenuOpen, onCloseLeftMenu, onClick }) => {
13
13
  const hasChildren = items && items?.length > 0;
14
14
  const { expandedItem, expandItem } = useLeftMenuContext();
15
15
  const isExpanded = expandedItem === id;
@@ -61,8 +61,6 @@ const MenuItem = ({ icon, title, link = "", items, id, count, isSubitem, isCompa
61
61
  $isCompact: isCompact,
62
62
  className: itemLinkWrapClassName,
63
63
  $lightMode: lightMode,
64
- $isHovering: isHovering,
65
- "data-testid": id ? `menu-item-${id}` : void 0,
66
64
  as: link ? void 0 : "a",
67
65
  ...link ? {
68
66
  exact: true,
@@ -72,27 +70,20 @@ const MenuItem = ({ icon, title, link = "", items, id, count, isSubitem, isCompa
72
70
  children: [/* @__PURE__ */ jsxs(ItemLabel, {
73
71
  $isCompact: isCompact,
74
72
  isSubitem,
75
- children: [
76
- !isSubitem && icon && /* @__PURE__ */ jsx(ItemIcon, {
77
- className: "mainIcon",
78
- $isCompact: isCompact,
79
- children: typeof icon === "string" ? /* @__PURE__ */ jsx(Icon, {
80
- icon,
81
- fill: "none"
82
- }) : icon
83
- }),
84
- /* @__PURE__ */ jsx(Title, {
85
- variant: "semiBold",
86
- mt: 0,
87
- mb: 0,
88
- textAlign: isCompact ? "center" : "left",
89
- children: /* @__PURE__ */ jsx(OverflowWithEllipsis, { children: title })
90
- }),
91
- !!count && /* @__PURE__ */ jsx(ItemCount, {
92
- $isCompact: isCompact,
93
- children: count
94
- })
95
- ]
73
+ children: [!isSubitem && icon && /* @__PURE__ */ jsx(ItemIcon, {
74
+ className: "mainIcon",
75
+ $isCompact: isCompact,
76
+ children: typeof icon === "string" ? /* @__PURE__ */ jsx(Icon, {
77
+ icon,
78
+ fill: "none"
79
+ }) : icon
80
+ }), /* @__PURE__ */ jsx(Title, {
81
+ variant: "semiBold",
82
+ mt: 0,
83
+ mb: 0,
84
+ textAlign: isCompact ? "center" : "left",
85
+ children: /* @__PURE__ */ jsx(OverflowWithEllipsis, { children: title })
86
+ })]
96
87
  }), !isCompact && hasChildren && /* @__PURE__ */ jsx(ItemDropdownArrow, {
97
88
  icon: "goDown",
98
89
  $lightMode: lightMode
@@ -1,5 +1,4 @@
1
1
  import { useClickOutside } from "../Modal/hooks/useClickOutside.js";
2
- import { HamburgerMenuButton } from "./components/HamburgerMenu.js";
3
2
  import MenuFooter from "./components/Footer.js";
4
3
  import { LeftMenuProvider } from "./context/LeftMenuContext.js";
5
4
  import { BodyWrap, Container, Overlay, ScrollWrap, TopLevelWrap } from "./styles.js";
@@ -7,7 +6,7 @@ import MenuItem_default from "./MenuItem.js";
7
6
  import "react";
8
7
  import { jsx, jsxs } from "react/jsx-runtime";
9
8
  //#region packages/ui/Blocks/SideMenu/SideMenu.tsx
10
- const SideMenu = ({ menuItems, isCompact, setIsCompact, isLeftMenuOpen, isAlwaysVisible, onCloseLeftMenu, showHamburgerMenu = false, variant = "dark", children }) => {
9
+ const SideMenu = ({ menuItems, isCompact, setIsCompact, isLeftMenuOpen, isAlwaysVisible, onCloseLeftMenu, variant = "dark", children }) => {
11
10
  const lightMode = variant === "light";
12
11
  return /* @__PURE__ */ jsx(LeftMenuProvider, { children: /* @__PURE__ */ jsxs(Container, {
13
12
  isLeftMenuOpen,
@@ -17,28 +16,21 @@ const SideMenu = ({ menuItems, isCompact, setIsCompact, isLeftMenuOpen, isAlways
17
16
  isLeftMenuOpen,
18
17
  ref: useClickOutside({ onClose: onCloseLeftMenu }),
19
18
  lightMode,
20
- children: [
21
- showHamburgerMenu && /* @__PURE__ */ jsx(HamburgerMenuButton, {
22
- isLeftMenuOpen,
23
- onClick: onCloseLeftMenu
24
- }),
25
- /* @__PURE__ */ jsx(ScrollWrap, { children: /* @__PURE__ */ jsxs(BodyWrap, {
26
- isCompact,
27
- children: [menuItems.map((item, index) => /* @__PURE__ */ jsx(MenuItem_default, {
28
- isCompact,
29
- isLeftMenuOpen,
30
- onCloseLeftMenu,
31
- lightMode,
32
- separator: !!item.separator,
33
- ...item
34
- }, `${item.id ?? item.title}-${index}`)), children]
35
- }) }),
36
- /* @__PURE__ */ jsx(MenuFooter, {
19
+ children: [/* @__PURE__ */ jsx(ScrollWrap, { children: /* @__PURE__ */ jsxs(BodyWrap, {
20
+ isCompact,
21
+ children: [menuItems.map((item, index) => /* @__PURE__ */ jsx(MenuItem_default, {
37
22
  isCompact,
38
- setIsCompact,
39
- lightMode
40
- })
41
- ]
23
+ isLeftMenuOpen,
24
+ onCloseLeftMenu,
25
+ lightMode,
26
+ separator: !!item.separator,
27
+ ...item
28
+ }, `${item.id ?? item.title}-${index}`)), children]
29
+ }) }), /* @__PURE__ */ jsx(MenuFooter, {
30
+ isCompact,
31
+ setIsCompact,
32
+ lightMode
33
+ })]
42
34
  }), /* @__PURE__ */ jsx(Overlay, {})]
43
35
  }) });
44
36
  };
@@ -1,8 +1,6 @@
1
- import React from 'react';
2
1
  type Props = {
3
2
  isLeftMenuOpen?: boolean;
4
3
  onClick?: () => void;
5
- mr?: string;
6
4
  };
7
- export declare const HamburgerMenuButton: ({ isLeftMenuOpen, onClick, mr }: Props) => React.ReactElement;
5
+ export declare const HamburgerMenuButton: ({ isLeftMenuOpen, onClick }: Props) => import("react/jsx-runtime").JSX.Element;
8
6
  export {};
@@ -35,11 +35,11 @@ const HamburgerMenuWrapper = styled$2(x.div)`
35
35
  display: none;
36
36
  }
37
37
  `;
38
- const HamburgerMenuButton = ({ isLeftMenuOpen, onClick, mr = "8px" }) => {
38
+ const HamburgerMenuButton = ({ isLeftMenuOpen, onClick }) => {
39
39
  const theme = useTheme();
40
- const neutralColor = th$1.color("bgLightGray2")({ theme });
40
+ const neutralColor = th$1.color("neutral20")({ theme });
41
41
  return /* @__PURE__ */ jsx(HamburgerMenuWrapper, {
42
- mr,
42
+ mr: "8px",
43
43
  onClick,
44
44
  isLeftMenuOpen: !!isLeftMenuOpen,
45
45
  children: isLeftMenuOpen ? /* @__PURE__ */ jsx(MobileCancel, { fill: neutralColor }) : /* @__PURE__ */ jsx(HamburgerMenu, {
@@ -1,12 +1,12 @@
1
1
  import { H6 } from "../../../Elements/Typography/Typography.js";
2
2
  import { Portal } from "../../../Elements/Portal/index.js";
3
- import { ItemCount, ItemLinkWrap, TooltipItemLabel, TooltipWrap } from "../styles.js";
3
+ import { ItemLinkWrap, TooltipItemLabel, TooltipWrap } from "../styles.js";
4
4
  import { useMemo } from "react";
5
- import { jsx, jsxs } from "react/jsx-runtime";
5
+ import { jsx } from "react/jsx-runtime";
6
6
  import styled from "styled-components";
7
7
  import { Popper } from "react-popper";
8
8
  //#region packages/ui/Blocks/SideMenu/components/SubitemTooltip.tsx
9
- const TooltipItem = ({ title, link = "", lightMode, count }) => {
9
+ const TooltipItem = ({ title, link = "", lightMode }) => {
10
10
  return /* @__PURE__ */ jsx(ItemLinkWrap, {
11
11
  ...useMemo(() => {
12
12
  return link.startsWith("https://") ? {
@@ -16,14 +16,14 @@ const TooltipItem = ({ title, link = "", lightMode, count }) => {
16
16
  }, [link]),
17
17
  exact: true,
18
18
  $lightMode: lightMode,
19
- children: /* @__PURE__ */ jsxs(TooltipItemLabel, { children: [/* @__PURE__ */ jsx(H6, {
19
+ children: /* @__PURE__ */ jsx(TooltipItemLabel, { children: /* @__PURE__ */ jsx(H6, {
20
20
  variant: "medium",
21
21
  children: title
22
- }), !!count && /* @__PURE__ */ jsx(ItemCount, { children: count })] })
22
+ }) })
23
23
  });
24
24
  };
25
25
  const PopoverWrapper = styled.div`
26
- z-index: 31;
26
+ z-index: 5;
27
27
  display: ${({ isLeftMenuOpen }) => isLeftMenuOpen ? "block" : "none"};
28
28
  @media (min-width: 1024px) {
29
29
  display: block;
@@ -4,7 +4,6 @@ export declare const menuItems: ({
4
4
  link: string;
5
5
  id: string;
6
6
  items?: undefined;
7
- count?: undefined;
8
7
  } | {
9
8
  title: string;
10
9
  icon: import("react/jsx-runtime").JSX.Element;
@@ -15,22 +14,4 @@ export declare const menuItems: ({
15
14
  link: string;
16
15
  id: string;
17
16
  }[];
18
- count?: undefined;
19
- } | {
20
- title: string;
21
- icon: import("react/jsx-runtime").JSX.Element;
22
- link: string;
23
- id: string;
24
- count: number;
25
- items: ({
26
- title: string;
27
- link: string;
28
- id: string;
29
- count?: undefined;
30
- } | {
31
- title: string;
32
- link: string;
33
- id: string;
34
- count: number;
35
- })[];
36
17
  })[];
@@ -53,7 +53,6 @@ const menuItems = [
53
53
  icon: /* @__PURE__ */ jsx(Expeditions, {}),
54
54
  link: "/expeditions",
55
55
  id: "expeditions",
56
- count: 3,
57
56
  items: [
58
57
  {
59
58
  title: "Expeditions",
@@ -63,8 +62,7 @@ const menuItems = [
63
62
  {
64
63
  title: "Outbound receipts",
65
64
  link: "/expeditions/outbound-receipts",
66
- id: "outboundReceipts",
67
- count: 3
65
+ id: "outboundReceipts"
68
66
  },
69
67
  {
70
68
  title: "Missing goods",
@@ -16,7 +16,6 @@ export declare const TooltipItemLabel: import("styled-components").StyledCompone
16
16
  export declare const ItemLinkWrap: import("styled-components").StyledComponent<typeof NavLink, import("@xstyled/styled-components").Theme, {
17
17
  $isCompact?: boolean;
18
18
  $lightMode?: boolean;
19
- $isHovering?: boolean;
20
19
  appearance?: "gray" | "default";
21
20
  }, never>;
22
21
  export declare const MenuItemContainer: import("styled-components").StyledComponent<"div", import("@xstyled/styled-components").Theme, {
@@ -42,6 +41,3 @@ export declare const BodyWrap: import("styled-components").StyledComponent<"div"
42
41
  isCompact: boolean;
43
42
  }, never>;
44
43
  export declare const Overlay: import("styled-components").StyledComponent<"div", import("@xstyled/styled-components").Theme, {}, never>;
45
- export declare const ItemCount: import("styled-components").StyledComponent<"span", import("@xstyled/styled-components").Theme, {
46
- $isCompact?: boolean;
47
- }, never>;
@@ -67,8 +67,6 @@ const ItemDropdownArrow = styled$1(Icon)`
67
67
  const TooltipItemLabel = styled$1.div`
68
68
  line-height: 1.5;
69
69
  letter-spacing: 0.4px;
70
- display: flex;
71
- align-items: center;
72
70
  `;
73
71
  const ItemLinkWrap = styled$1(NavLink)`
74
72
  display: flex;
@@ -80,17 +78,14 @@ const ItemLinkWrap = styled$1(NavLink)`
80
78
  font-weight: 600;
81
79
  letter-spacing: 0.4px;
82
80
  position: relative;
83
- color: ${({ $lightMode, $isHovering }) => {
84
- if ($lightMode) return th$1.color("typoPrimary");
85
- if ($isHovering) return "white";
86
- return th$1.color("lightGray5");
87
- }};
81
+ color: ${({ $lightMode }) => $lightMode ? th$1.color("typoPrimary") : th$1.color("lightGray5")};
88
82
  transition: moving 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
89
83
  transition-property: transform;
90
84
 
91
85
  &.toplevel {
92
86
  margin: ${({ $isCompact }) => $isCompact ? "0 0 12px 0" : "16px 0"};
93
87
  padding: ${({ $isCompact }) => $isCompact ? "10px 14px 6px 13px" : "9px 10px"};
88
+ gap: ${({ $isCompact }) => $isCompact ? "none" : "30px"};
94
89
  justify-content: ${({ $isCompact }) => $isCompact ? "center" : "space-between"};
95
90
  &.active {
96
91
  color: ${({ $lightMode }) => $lightMode ? th$1("colors.red1") : "white"};
@@ -135,7 +130,7 @@ const MenuItemContainer = styled$1.div`
135
130
  z-index: 1;
136
131
  stroke: ${({ $lightMode }) => $lightMode ? th$1.color("blue2") : void 0};
137
132
  .selected > ${ItemLabel}, .active > ${ItemLabel} {
138
- color: ${({ $lightMode }) => $lightMode ? th$1.color("red1") : th$1.color("sideMenuSelectedText")};
133
+ color: ${({ $lightMode }) => $lightMode ? th$1.color("red1") : th$1.color("white")};
139
134
  stroke: ${({ $lightMode }) => $lightMode ? th$1.color("red1") : th$1.color("blue2")};
140
135
  }
141
136
 
@@ -264,10 +259,9 @@ const OverflowWithEllipsis = styled$1.span`
264
259
  max-width: 140px;
265
260
  overflow: hidden;
266
261
  text-overflow: ellipsis;
267
- white-space: nowrap;
268
262
  `;
269
263
  const TopLevelWrap = styled$1.div`
270
- background-color: ${({ lightMode }) => lightMode ? "white" : th$1("colors.sideMenuBackground")};
264
+ background-color: ${({ lightMode }) => lightMode ? "white" : th$1("colors.blue3")};
271
265
  border-right: 1px solid ${th$1("colors.lightGray6")};
272
266
  height: -webkit-fill-available;
273
267
  transition: width 0.5s ease;
@@ -312,28 +306,5 @@ const Overlay = styled$1.div`
312
306
  display: none;
313
307
  }
314
308
  `;
315
- const ItemCount = styled$1.span`
316
- display: flex;
317
- align-items: center;
318
- justify-content: center;
319
- flex-shrink: 0;
320
- min-width: 20px;
321
- height: 18px;
322
- padding: 0 5px;
323
- border-radius: 9px;
324
- background-color: #ffffff;
325
- color: ${th$1.color("red1")};
326
- font-size: 12px;
327
- line-height: 18px;
328
- font-weight: 600;
329
- margin-left: 8px;
330
-
331
- ${({ $isCompact }) => $isCompact && css`
332
- position: absolute;
333
- top: 0;
334
- right: 2px;
335
- margin-left: 0;
336
- `}
337
- `;
338
309
  //#endregion
339
- export { BodyWrap, Container, ItemCount, ItemDropdownArrow, ItemIcon, ItemLabel, ItemLinkWrap, ItemsSeparator, MenuItemContainer, OverflowWithEllipsis, Overlay, ScrollWrap, SubItemsWrap, TooltipItemLabel, TooltipWrap, TopLevelWrap };
310
+ export { BodyWrap, Container, ItemDropdownArrow, ItemIcon, ItemLabel, ItemLinkWrap, ItemsSeparator, MenuItemContainer, OverflowWithEllipsis, Overlay, ScrollWrap, SubItemsWrap, TooltipItemLabel, TooltipWrap, TopLevelWrap };
@@ -10,7 +10,6 @@ export type MenuItemType = {
10
10
  lightMode?: boolean;
11
11
  separator?: boolean;
12
12
  appearance?: 'gray' | 'default';
13
- count?: number;
14
13
  };
15
14
  export type SideMenuProps = {
16
15
  menuItems: MenuItemType[];
@@ -19,7 +18,6 @@ export type SideMenuProps = {
19
18
  isLeftMenuOpen?: boolean;
20
19
  isAlwaysVisible?: boolean;
21
20
  onCloseLeftMenu?: () => void;
22
- showHamburgerMenu?: boolean;
23
21
  variant?: 'dark' | 'light';
24
22
  children?: ReactNode;
25
23
  };
@@ -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?.toDate?.();
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?.toDate?.(), selected?.toDate?.()];
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
- getLocaleData(): any;
50
- getDateFormat(): any;
51
- getTimeFormat(): any;
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
- updateTime(op: any, amount: any, type: any, toSelected: any): void;
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
- localMoment(date: any, format: any, props: any): any;
73
- checkTZ(): void;
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.clone(),
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 = (date || this.state.viewDate).clone();
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.viewToMethod = {
101
- days: "date",
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
- let viewDate = this.state.viewDate.clone();
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
- viewDate.month(parseInt(e.target.getAttribute("data-month"), 10));
117
- viewDate.year(parseInt(e.target.getAttribute("data-year"), 10));
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.clone();
122
- update.inputValue = viewDate.format(this.getFormat("datetime"));
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.clone());
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
- let viewDate = this.state.viewDate.clone();
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
- let date = (this.getSelectedDate() || this.state.viewDate).clone();
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.clone(),
141
- inputValue: date.format(this.getFormat("datetime"))
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 localMoment = this.localMoment(value, this.getFormat("datetime"));
164
+ const parsedDate = this.localDate(value, this.getFormat("datetime"));
170
165
  let update = { inputValue: value };
171
- if (localMoment.isValid()) {
172
- update.selectedDate = localMoment;
173
- update.viewDate = localMoment.clone().startOf("month");
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(localMoment.isValid() ? localMoment : this.state.inputValue);
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() ? selectedDate : void 0,
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()) return viewDate;
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()) return selectedDate.clone();
231
+ } else if (selectedDate && selectedDate.isValid) return selectedDate;
238
232
  return this.getInitialDate();
239
233
  }
240
234
  getInitialDate() {
241
- let m = this.localMoment();
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.localMoment(date, dateFormat);
252
- else if (date) parsedDate = this.localMoment(date);
253
- if (parsedDate && !parsedDate.isValid()) parsedDate = null;
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
- if (dateFormat.match(/[lLD]/)) return viewModes.DAYS;
272
- if (dateFormat.indexOf("M") !== -1) return viewModes.MONTHS;
273
- if (dateFormat.indexOf("Y") !== -1) return viewModes.YEARS;
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 locale.longDateFormat("L");
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 locale.longDateFormat("LT");
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
- updateTime(op, amount, type, toSelected) {
301
- let update = {};
302
- const date = toSelected ? "selectedDate" : "viewDate";
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
- localMoment(date, format, props) {
307
- props = props || this.props;
308
- let m = null;
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
- checkTZ() {
316
- const { displayTimeZone } = this.props;
317
- if (displayTimeZone && !this.tzWarning && !moment.tz) this.tzWarning = true;
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
- "displayZone",
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 props = this.props;
338
- let viewDate = this.state.viewDate.clone();
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()) update.inputValue = selectedDate.format(this.getFormat("datetime"));
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() ? selectedDate : false;
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()) return selectedDate.format(this.getFormat("datetime"));
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.format(this.getFormat("datetime")) : this.state.inputValue;
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
- let viewDate;
390
- if (typeof date === "string") viewDate = this.localMoment(date, this.getFormat("datetime"));
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 { Moment } from 'moment';
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 | Moment | string) => void;
15
+ type EventOrValueHandler<Event> = (event: Event | DateTime | string) => void;
16
16
  export interface DatetimepickerProps {
17
- value?: Date | string | Moment;
18
- initialValue?: Date | string | Moment;
19
- initialViewDate?: Date | string | Moment;
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: Moment | string) => void;
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: Moment) => string;
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: Moment;
56
- selectedDate: Moment;
54
+ viewDate: DateTime;
55
+ selectedDate: DateTime;
57
56
  inputValue: string;
58
57
  open: boolean;
59
58
  secondValue?: Date | null;
@@ -0,0 +1,4 @@
1
+ export declare const MOMENT_TOKEN_PATTERN: RegExp;
2
+ export declare const LUXON_TOKENS: Record<string, string>;
3
+ export declare const LOCALE_DATE_FORMAT = "D";
4
+ export declare const LOCALE_TIME_FORMAT = "t";
@@ -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,3 @@
1
+ type ToLuxonFormatType = (format: string) => string;
2
+ export declare const toLuxonFormat: ToLuxonFormatType;
3
+ export {};
@@ -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.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: locale.months(date, "DD[]MMMM") + " " + date.year(),
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.localeData()).map((day, index) => /* @__PURE__ */ jsx("th", {
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.clone().startOf("month");
57
- const endOfMonth = date.clone().endOf("month");
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.clone().subtract(1, "months");
67
- startDate.date(startDate.daysInMonth()).startOf("week");
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.isBefore(endDate)) {
69
+ while (startDate < endDate) {
71
70
  getRow(rows, i++).push(this.renderDay(startDate, startOfMonth, endOfMonth));
72
- startDate.add(1, "d");
71
+ startDate = startDate.plus({ days: 1 });
73
72
  }
74
- return rows.map((r, i) => /* @__PURE__ */ jsx("tr", { children: r }, `${endDate.month()}_${i}`));
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.format("M_D"),
81
- "data-value": date.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.isBefore(startOfMonth)) className += " rdtOld";
87
- else if (date.isAfter(endOfMonth)) className += " rdtNew";
88
- if (secondValue && date.isBefore(secondValue) && date.isAfter(selectedDate)) className += " rdtActiveRange";
89
- if (secondValue && date.isAfter(secondValue) && date.isBefore(selectedDate)) className += " rdtActiveRange";
90
- if (selectedDate && date.isSame(selectedDate, "day")) className += " rdtActive";
91
- if (secondValue && date.isSame(secondValue, "day")) className += " rdtActiveSecond";
92
- if (date.isSame(this.props.moment(), "day")) className += " rdtToday";
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.clone(), selectedDate && selectedDate.clone());
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 first = locale.firstDayOfWeek();
133
- let dow = [];
134
- let i = 0;
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: this.props.viewDate.year(),
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() === this.props.viewDate.year() && selectedDate.month() === month) className += " rdtActive";
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(), this.props.selectedDate && this.props.selectedDate.clone());
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.clone().set({ month });
59
- let day = date.endOf("month").date() + 1;
60
- while (day-- > 1) if (isValidDate(date.date(day))) return false;
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 localMoment = this.props.viewDate;
65
- return capitalize(localMoment.localeData().monthsShort(localMoment.month(month)).substring(0, 3));
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 && this.props.selectedDate.clone());
57
+ return this.props.renderYear(props, year, this.props.selectedDate);
58
58
  }
59
59
  getViewYear() {
60
- return parseInt(this.props.viewDate.year() / 10, 10) * 10;
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.clone().set({ year });
71
- let day = date.endOf("year").dayOfYear() + 1;
72
- while (day-- > 1) if (isValidDate(date.dayOfYear(day))) {
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
  }
@@ -1,5 +1,4 @@
1
- import type { Moment } from 'moment';
2
1
  export declare const useOnChange: () => {
3
2
  value: string | Date;
4
- handleChange: (next: string | Date | Moment) => void;
3
+ handleChange: (next: string | Date) => void;
5
4
  };