@monolith-forensics/monolith-ui 1.1.29 → 1.1.30

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.
Files changed (135) hide show
  1. package/dist/Button/Button.d.ts +19 -0
  2. package/dist/Button/Button.js +332 -0
  3. package/dist/Button/index.d.ts +2 -0
  4. package/dist/Button/index.js +8 -0
  5. package/dist/Calendar/Calendar.d.ts +15 -0
  6. package/dist/Calendar/Calendar.js +232 -0
  7. package/dist/Calendar/CalendarStyles.d.ts +36 -0
  8. package/dist/Calendar/CalendarStyles.js +170 -0
  9. package/dist/Calendar/calendarHelpers.d.ts +53 -0
  10. package/dist/Calendar/calendarHelpers.js +181 -0
  11. package/dist/Calendar/index.d.ts +1 -0
  12. package/dist/Calendar/index.js +8 -0
  13. package/dist/CheckBox/CheckBox.d.ts +13 -0
  14. package/dist/CheckBox/CheckBox.js +46 -0
  15. package/dist/CheckBox/index.d.ts +1 -0
  16. package/dist/CheckBox/index.js +8 -0
  17. package/dist/DateInput/DateInput.d.ts +24 -0
  18. package/dist/DateInput/DateInput.js +509 -0
  19. package/dist/DateInput/index.d.ts +1 -0
  20. package/dist/DateInput/index.js +8 -0
  21. package/dist/DropDownMenu/DropDownMenu.d.ts +36 -0
  22. package/dist/DropDownMenu/DropDownMenu.js +213 -0
  23. package/dist/DropDownMenu/index.d.ts +1 -0
  24. package/dist/DropDownMenu/index.js +8 -0
  25. package/dist/Error/Error.d.ts +4 -0
  26. package/dist/Error/Error.js +38 -0
  27. package/dist/Error/index.d.ts +1 -0
  28. package/dist/Error/index.js +8 -0
  29. package/dist/FieldLabel/FieldLabel.d.ts +19 -0
  30. package/dist/FieldLabel/FieldLabel.js +119 -0
  31. package/dist/FieldLabel/index.d.ts +1 -0
  32. package/dist/FieldLabel/index.js +8 -0
  33. package/dist/FileInputField/FileInputField.d.ts +19 -0
  34. package/dist/FileInputField/FileInputField.js +117 -0
  35. package/dist/FileInputField/index.d.ts +1 -0
  36. package/dist/FileInputField/index.js +8 -0
  37. package/dist/Flyout/Flyout.d.ts +11 -0
  38. package/dist/Flyout/Flyout.js +111 -0
  39. package/dist/Flyout/FlyoutHeader.d.ts +5 -0
  40. package/dist/Flyout/FlyoutHeader.js +12 -0
  41. package/dist/Flyout/FlyoutTitle.d.ts +2 -0
  42. package/dist/Flyout/FlyoutTitle.js +13 -0
  43. package/dist/Flyout/index.d.ts +3 -0
  44. package/dist/Flyout/index.js +12 -0
  45. package/dist/FormSection/FormSection.d.ts +9 -0
  46. package/dist/FormSection/FormSection.js +51 -0
  47. package/dist/FormSection/index.d.ts +1 -0
  48. package/dist/FormSection/index.js +8 -0
  49. package/dist/Grid/Grid.d.ts +8 -0
  50. package/dist/Grid/Grid.js +18 -0
  51. package/dist/Grid/index.d.ts +1 -0
  52. package/dist/Grid/index.js +8 -0
  53. package/dist/IconButton/IconButton.d.ts +5 -0
  54. package/dist/IconButton/IconButton.js +30 -0
  55. package/dist/IconButton/index.d.ts +1 -0
  56. package/dist/IconButton/index.js +8 -0
  57. package/dist/Input/Input.d.ts +21 -0
  58. package/dist/Input/Input.js +149 -0
  59. package/dist/Input/index.d.ts +1 -0
  60. package/dist/Input/index.js +8 -0
  61. package/dist/Modal/Modal.d.ts +14 -0
  62. package/dist/Modal/Modal.js +110 -0
  63. package/dist/Modal/index.d.ts +1 -0
  64. package/dist/Modal/index.js +8 -0
  65. package/dist/MonolithUIProvider/GlobalStyle.d.ts +4 -0
  66. package/dist/MonolithUIProvider/GlobalStyle.js +53 -0
  67. package/dist/MonolithUIProvider/MonolithUIProvider.d.ts +10 -0
  68. package/dist/MonolithUIProvider/MonolithUIProvider.js +29 -0
  69. package/dist/MonolithUIProvider/index.d.ts +3 -0
  70. package/dist/MonolithUIProvider/index.js +12 -0
  71. package/dist/MonolithUIProvider/useMonolithUITheme.d.ts +2 -0
  72. package/dist/MonolithUIProvider/useMonolithUITheme.js +12 -0
  73. package/dist/Pill/Pill.d.ts +11 -0
  74. package/dist/Pill/Pill.js +152 -0
  75. package/dist/Pill/index.d.ts +1 -0
  76. package/dist/Pill/index.js +8 -0
  77. package/dist/SelectBox/SelectBox.d.ts +45 -0
  78. package/dist/SelectBox/SelectBox.js +477 -0
  79. package/dist/SelectBox/index.d.ts +1 -0
  80. package/dist/SelectBox/index.js +8 -0
  81. package/dist/Switch/Switch.d.ts +18 -0
  82. package/dist/Switch/Switch.js +157 -0
  83. package/dist/Switch/index.d.ts +1 -0
  84. package/dist/Switch/index.js +8 -0
  85. package/dist/Table/Table.d.ts +91 -0
  86. package/dist/Table/Table.js +715 -0
  87. package/dist/Table/index.d.ts +2 -0
  88. package/dist/Table/index.js +10 -0
  89. package/dist/TagBox/TagBox.d.ts +39 -0
  90. package/dist/TagBox/TagBox.js +590 -0
  91. package/dist/TagBox/TagBoxStyles.d.ts +11 -0
  92. package/dist/TagBox/TagBoxStyles.js +113 -0
  93. package/dist/TagBox/index.d.ts +1 -0
  94. package/dist/TagBox/index.js +8 -0
  95. package/dist/TextArea/TextArea.d.ts +16 -0
  96. package/dist/TextArea/TextArea.js +81 -0
  97. package/dist/TextArea/index.d.ts +1 -0
  98. package/dist/TextArea/index.js +8 -0
  99. package/dist/TextAreaInput/TextAreaInput.d.ts +19 -0
  100. package/dist/TextAreaInput/TextAreaInput.js +11 -0
  101. package/dist/TextAreaInput/index.d.ts +1 -0
  102. package/dist/TextAreaInput/index.js +8 -0
  103. package/dist/TextInput/TextInput.d.ts +13 -0
  104. package/dist/TextInput/TextInput.js +31 -0
  105. package/dist/TextInput/index.d.ts +1 -0
  106. package/dist/TextInput/index.js +8 -0
  107. package/dist/Tooltip/Tooltip.d.ts +12 -0
  108. package/dist/Tooltip/Tooltip.js +53 -0
  109. package/dist/Tooltip/index.d.ts +1 -0
  110. package/dist/Tooltip/index.js +8 -0
  111. package/dist/core/ArrowButton.d.ts +6 -0
  112. package/dist/core/ArrowButton.js +48 -0
  113. package/dist/core/ClearButton.d.ts +6 -0
  114. package/dist/core/ClearButton.js +48 -0
  115. package/dist/core/MonolithThemeProvider.d.ts +4 -0
  116. package/dist/core/MonolithThemeProvider.js +20 -0
  117. package/dist/core/StyledContent.d.ts +7 -0
  118. package/dist/core/StyledContent.js +47 -0
  119. package/dist/core/StyledFloatContainer.d.ts +2 -0
  120. package/dist/core/StyledFloatContainer.js +10 -0
  121. package/dist/core/Types/Size.d.ts +2 -0
  122. package/dist/core/Types/Size.js +2 -0
  123. package/dist/core/Types/Variant.d.ts +2 -0
  124. package/dist/core/Types/Variant.js +2 -0
  125. package/dist/core/index.d.ts +6 -0
  126. package/dist/core/index.js +14 -0
  127. package/dist/index.d.ts +26 -0
  128. package/dist/index.js +59 -0
  129. package/dist/theme/index.d.ts +168 -0
  130. package/dist/theme/index.js +14 -0
  131. package/dist/theme/typography.d.ts +45 -0
  132. package/dist/theme/typography.js +59 -0
  133. package/dist/theme/variants.d.ts +172 -0
  134. package/dist/theme/variants.js +276 -0
  135. package/package.json +1 -1
@@ -0,0 +1,19 @@
1
+ import { ButtonHTMLAttributes, ReactNode } from "react";
2
+ import { Size, Variant } from "../core";
3
+ export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
4
+ children?: ReactNode | string;
5
+ className?: string;
6
+ loading?: boolean;
7
+ leftSection?: ReactNode;
8
+ rightSection?: ReactNode;
9
+ href?: string | null;
10
+ download?: string | null;
11
+ fullWidth?: boolean;
12
+ size?: Size;
13
+ variant?: Variant;
14
+ color?: string;
15
+ disabled?: boolean;
16
+ onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
17
+ }
18
+ declare const Button: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
19
+ export default Button;
@@ -0,0 +1,332 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ const jsx_runtime_1 = require("react/jsx-runtime");
18
+ const react_1 = require("react");
19
+ const styled_components_1 = __importDefault(require("styled-components"));
20
+ const lucide_react_1 = require("lucide-react");
21
+ const colors = {
22
+ gray: "#888888",
23
+ red: "#e03131",
24
+ pink: "#c2255c",
25
+ grape: "#9c36b5",
26
+ violet: "#6741d9",
27
+ indigo: "#3b5bdb",
28
+ cyan: "#0c8599",
29
+ teal: "#099268",
30
+ green: "#2f9e44",
31
+ lime: "#66a80f",
32
+ yellow: "#f08c00",
33
+ orange: "#e8590c",
34
+ };
35
+ const StyledButton = styled_components_1.default.button `
36
+ user-select: none;
37
+ display: flex;
38
+ outline: none;
39
+ white-space: nowrap;
40
+
41
+ width: ${({ fullWidth }) => (fullWidth ? "100%" : "fit-content")};
42
+ height: ${({ theme, size }) => {
43
+ switch (size) {
44
+ case "xxs":
45
+ return `24px`;
46
+ case "xs":
47
+ return `28px`;
48
+ case "sm":
49
+ return `34px`;
50
+ case "md":
51
+ return `40px`;
52
+ case "lg":
53
+ return `48px`;
54
+ case "xl":
55
+ return `58px`;
56
+ default:
57
+ return `34px`;
58
+ }
59
+ }};
60
+
61
+ font-weight: 525;
62
+ letter-spacing: 0.75px;
63
+ font-size: ${({ theme, size }) => {
64
+ switch (size) {
65
+ case "xxs":
66
+ return `11px`;
67
+ case "xs":
68
+ return `12px`;
69
+ case "sm":
70
+ return `14px`;
71
+ case "md":
72
+ return `16px`;
73
+ case "lg":
74
+ return `18px`;
75
+ case "xl":
76
+ return `20px`;
77
+ default:
78
+ return `14px`;
79
+ }
80
+ }};
81
+
82
+ padding: ${({ theme, size, variant }) => {
83
+ if (variant === "text")
84
+ return `0px 0px`;
85
+ switch (size) {
86
+ case "xxs":
87
+ return `0px 8px`;
88
+ case "xs":
89
+ return `0px 12px`;
90
+ case "sm":
91
+ return `0px 16px`;
92
+ case "md":
93
+ return `0px 20px`;
94
+ case "lg":
95
+ return `0px 24px`;
96
+ case "xl":
97
+ return `0px 30px`;
98
+ default:
99
+ return `0px 16px`;
100
+ }
101
+ }};
102
+
103
+ color: ${({ theme, variant, color }) => {
104
+ var _a, _b;
105
+ if (variant === "default")
106
+ return theme.palette.text.primary;
107
+ if (variant === "contained")
108
+ return "white";
109
+ if (variant === "filled")
110
+ return "white";
111
+ switch (color) {
112
+ case "primary":
113
+ return theme.palette.primary.main;
114
+ case undefined:
115
+ return theme.palette.text.primary;
116
+ default:
117
+ return color
118
+ ? ((_b = (_a = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _a === void 0 ? void 0 : _a[color]) === null || _b === void 0 ? void 0 : _b.main) ||
119
+ colors[color] ||
120
+ theme.palette.text.primary
121
+ : theme.palette.text.primary;
122
+ }
123
+ }};
124
+
125
+ background-color: ${({ theme, variant, color }) => {
126
+ var _a, _b, _c, _d, _e, _f;
127
+ if (variant === "default")
128
+ return "transparent";
129
+ switch (variant) {
130
+ case "contained":
131
+ return color
132
+ ? ((_b = (_a = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _a === void 0 ? void 0 : _a[color]) === null || _b === void 0 ? void 0 : _b.main) ||
133
+ colors[color] ||
134
+ theme.palette.background.secondary
135
+ : theme.palette.background.secondary;
136
+ case "filled":
137
+ return color
138
+ ? ((_d = (_c = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _c === void 0 ? void 0 : _c[color]) === null || _d === void 0 ? void 0 : _d.main) ||
139
+ colors[color] ||
140
+ theme.palette.background.secondary
141
+ : theme.palette.background.secondary;
142
+ case "light":
143
+ return ((color
144
+ ? ((_f = (_e = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _e === void 0 ? void 0 : _e[color]) === null || _f === void 0 ? void 0 : _f.main) ||
145
+ colors[color] ||
146
+ theme.palette.background.secondary
147
+ : theme.palette.background.secondary) + "30");
148
+ case "outlined":
149
+ return "transparent";
150
+ case "text":
151
+ return "transparent";
152
+ default:
153
+ return "transparent";
154
+ }
155
+ }};
156
+
157
+ border-radius: 4px;
158
+ border: 1px solid
159
+ ${({ theme, variant, color }) => {
160
+ var _a, _b, _c, _d;
161
+ switch (variant) {
162
+ case "contained":
163
+ return "transparent";
164
+ case "filled":
165
+ return "transparent";
166
+ case "light":
167
+ return "transparent";
168
+ case "outlined":
169
+ return color
170
+ ? ((_b = (_a = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _a === void 0 ? void 0 : _a[color]) === null || _b === void 0 ? void 0 : _b.main) ||
171
+ colors[color] ||
172
+ theme.palette.divider
173
+ : theme.palette.divider;
174
+ case "text":
175
+ return "transparent";
176
+ case "subtle":
177
+ return "transparent";
178
+ default:
179
+ return color
180
+ ? ((_d = (_c = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _c === void 0 ? void 0 : _c[color]) === null || _d === void 0 ? void 0 : _d.main) ||
181
+ colors[color] ||
182
+ theme.palette.divider
183
+ : theme.palette.divider;
184
+ }
185
+ }};
186
+
187
+ cursor: pointer;
188
+
189
+ transition: background-color 0.2s, border 0.2s;
190
+
191
+ .inner-span {
192
+ display: flex;
193
+ align-items: center;
194
+ }
195
+
196
+ .button-label {
197
+ display: flex;
198
+ align-items: center;
199
+ }
200
+
201
+ [data-position="left"] {
202
+ margin-inline-end: 6px;
203
+ display: flex;
204
+ align-items: center;
205
+ }
206
+
207
+ [data-position="right"] {
208
+ margin-inline-start: 6px;
209
+ display: flex;
210
+ align-items: center;
211
+ }
212
+
213
+ &:hover {
214
+ background-color: ${({ theme, variant, color }) => {
215
+ var _a, _b, _c, _d, _e, _f, _g, _h;
216
+ if (variant === "default")
217
+ return "transparent";
218
+ switch (variant) {
219
+ case "contained":
220
+ return ((color
221
+ ? ((_b = (_a = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _a === void 0 ? void 0 : _a[color]) === null || _b === void 0 ? void 0 : _b.main) ||
222
+ colors[color] ||
223
+ theme.palette.background.secondary
224
+ : theme.palette.background.secondary) + "90");
225
+ case "filled":
226
+ return ((color
227
+ ? ((_d = (_c = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _c === void 0 ? void 0 : _c[color]) === null || _d === void 0 ? void 0 : _d.main) ||
228
+ colors[color] ||
229
+ theme.palette.background.secondary
230
+ : theme.palette.background.secondary) + "90");
231
+ case "light":
232
+ return ((color
233
+ ? ((_f = (_e = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _e === void 0 ? void 0 : _e[color]) === null || _f === void 0 ? void 0 : _f.main) ||
234
+ colors[color] ||
235
+ theme.palette.background.secondary
236
+ : theme.palette.background.secondary) + "70");
237
+ case "outlined":
238
+ return theme.palette.action.hover;
239
+ case "text":
240
+ return "transparent";
241
+ case "subtle":
242
+ return color
243
+ ? (((_h = (_g = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _g === void 0 ? void 0 : _g[color]) === null || _h === void 0 ? void 0 : _h.main) ||
244
+ colors[color]) + "30" ||
245
+ theme.palette.action.hover
246
+ : theme.palette.action.hover;
247
+ default:
248
+ return theme.palette.action.hover;
249
+ }
250
+ }};
251
+
252
+ border: 1px solid
253
+ ${({ theme, variant, color }) => {
254
+ var _a, _b;
255
+ switch (variant) {
256
+ case "contained":
257
+ return "transparent";
258
+ case "filled":
259
+ return "transparent";
260
+ case "light":
261
+ return "transparent";
262
+ case "outlined":
263
+ return color
264
+ ? colors[color] || theme.palette.divider
265
+ : theme.palette.divider;
266
+ case "text":
267
+ return "transparent";
268
+ case "subtle":
269
+ return "transparent";
270
+ default:
271
+ return color
272
+ ? ((_b = (_a = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _a === void 0 ? void 0 : _a[color]) === null || _b === void 0 ? void 0 : _b.main) ||
273
+ colors[color] ||
274
+ theme.palette.divider
275
+ : theme.palette.divider;
276
+ }
277
+ }};
278
+ opacity: ${({ variant }) => (variant === "text" ? 0.8 : 1)};
279
+ }
280
+
281
+ opacity: ${({ disabled }) => (disabled ? 0.5 : 1)};
282
+ pointer-events: ${({ disabled }) => (disabled ? "none" : "auto")};
283
+
284
+ &:focus {
285
+ text-decoration: underline;
286
+ }
287
+
288
+ &:active {
289
+ // simulate physical button press
290
+ translate: 0px 1px;
291
+ text-decoration: none;
292
+ }
293
+
294
+ // disabled styles
295
+ ${({ disabled }) => disabled &&
296
+ `
297
+ cursor: not-allowed;
298
+ opacity: 0.5;
299
+ pointer-events: none;
300
+ `}
301
+ `;
302
+ const StyledAnchor = styled_components_1.default.a `
303
+ text-decoration: none;
304
+ height: 100%;
305
+
306
+ &:hover {
307
+ text-decoration: none !important;
308
+ }
309
+ `;
310
+ const StyledLoader = styled_components_1.default.span `
311
+ svg {
312
+ width: 16px;
313
+ height: 16px;
314
+ color: ${({ theme, color }) => color
315
+ ? theme.palette[color] || colors[color]
316
+ : theme.palette.primary};
317
+
318
+ animation: spin 0.75s linear infinite;
319
+
320
+ @keyframes spin {
321
+ 100% {
322
+ transform: rotate(360deg);
323
+ }
324
+ }
325
+ }
326
+ `;
327
+ const Button = (0, react_1.forwardRef)((props, ref) => {
328
+ const { children, loading = false, leftSection = null, rightSection = null, href = null, download = null } = props, other = __rest(props, ["children", "loading", "leftSection", "rightSection", "href", "download"]);
329
+ const buttonContent = ((0, jsx_runtime_1.jsx)("span", { className: "inner-span", style: { height: "100%" }, children: loading ? ((0, jsx_runtime_1.jsx)(StyledLoader, { children: (0, jsx_runtime_1.jsx)(lucide_react_1.Loader2Icon, {}) })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [leftSection && (0, jsx_runtime_1.jsx)("span", { "data-position": "left", children: leftSection }), (0, jsx_runtime_1.jsx)("span", { className: "button-label", children: children }), rightSection && (0, jsx_runtime_1.jsx)("span", { "data-position": "right", children: rightSection })] })) }));
330
+ return ((0, jsx_runtime_1.jsx)(StyledButton, Object.assign({ ref: ref }, other, { children: href ? ((0, jsx_runtime_1.jsx)(StyledAnchor, { href: href, download: download, children: buttonContent })) : (buttonContent) })));
331
+ });
332
+ exports.default = Button;
@@ -0,0 +1,2 @@
1
+ export { default } from "./Button";
2
+ export type { ButtonProps } from "./Button";
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.default = void 0;
7
+ var Button_1 = require("./Button");
8
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(Button_1).default; } });
@@ -0,0 +1,15 @@
1
+ interface CalendarProps {
2
+ defaultValue?: Date;
3
+ value?: Date | null;
4
+ onChange?: (date: Date | null) => void;
5
+ hourFormat?: "12" | "24";
6
+ includeTime?: boolean;
7
+ clearable?: boolean;
8
+ min?: Date;
9
+ max?: Date;
10
+ }
11
+ declare const Calendar: {
12
+ ({ defaultValue, value, onChange, hourFormat, includeTime, clearable, min, max, }: CalendarProps): import("react/jsx-runtime").JSX.Element;
13
+ displayName: string;
14
+ };
15
+ export default Calendar;
@@ -0,0 +1,232 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const jsx_runtime_1 = require("react/jsx-runtime");
30
+ const react_1 = require("react");
31
+ const lucide_react_1 = require("lucide-react");
32
+ const CalendarStyles_1 = require("./CalendarStyles");
33
+ const calendarHelpers_1 = __importStar(require("./calendarHelpers"));
34
+ const moment_1 = __importDefault(require("moment"));
35
+ const checkValidRange = (value, min, max) => {
36
+ if (min && (0, moment_1.default)(value).startOf("day").isBefore((0, moment_1.default)(min).startOf("day")))
37
+ return false;
38
+ if (max && (0, moment_1.default)(value).startOf("day").isAfter((0, moment_1.default)(max).startOf("day")))
39
+ return false;
40
+ return true;
41
+ };
42
+ const Calendar = ({ defaultValue = new Date(), value, onChange = () => { }, hourFormat = "24", includeTime = true, clearable = true, min, max, }) => {
43
+ const [dateState, setDateState] = (0, react_1.useState)({
44
+ current: defaultValue,
45
+ month: defaultValue.getMonth() + 1,
46
+ year: defaultValue.getFullYear(),
47
+ hours: 0,
48
+ minutes: 0,
49
+ });
50
+ const [today, setToday] = (0, react_1.useState)(new Date());
51
+ let pressureTimer;
52
+ let pressureTimeout;
53
+ let dayTimeout;
54
+ const addDateToState = (date) => {
55
+ const isDateObject = (0, calendarHelpers_1.isDate)(date);
56
+ const _date = isDateObject ? date : new Date();
57
+ setDateState({
58
+ current: isDateObject ? date : null,
59
+ month: +_date.getMonth() + 1,
60
+ year: _date.getFullYear(),
61
+ hours: _date.getHours(),
62
+ minutes: _date.getMinutes(),
63
+ });
64
+ };
65
+ const getCalendarDates = () => {
66
+ const { current, month, year } = dateState;
67
+ const calendarMonth = month || +((current === null || current === void 0 ? void 0 : current.getMonth()) || 0) + 1;
68
+ const calendarYear = year || (current === null || current === void 0 ? void 0 : current.getFullYear());
69
+ return (0, calendarHelpers_1.default)(calendarMonth, calendarYear);
70
+ };
71
+ //new start
72
+ const renderMonthAndYear = () => {
73
+ const { month, year } = dateState;
74
+ // Resolve the month name from the CALENDAR_MONTHS object map
75
+ const monthname = Object.keys(calendarHelpers_1.CALENDAR_MONTHS)[Math.max(0, Math.min(month - 1, 11))];
76
+ return ((0, jsx_runtime_1.jsxs)(CalendarStyles_1.CalendarHeader, { children: [(0, jsx_runtime_1.jsx)(lucide_react_1.ChevronLeftIcon, { onMouseDown: handlePrevious, onMouseUp: clearPressureTimer }), (0, jsx_runtime_1.jsxs)(CalendarStyles_1.CalendarMonth, { children: [monthname, " ", year] }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRightIcon, { onMouseDown: handleNext, onMouseUp: clearPressureTimer })] }));
77
+ };
78
+ // Render the label for day of the week
79
+ // This method is used as a map callback as seen in render()
80
+ const renderDayLabel = (day, index) => {
81
+ // Resolve the day of the week label from the WEEK_DAYS object map
82
+ const daylabel = calendarHelpers_1.WEEK_DAYS[day];
83
+ return ((0, jsx_runtime_1.jsx)(CalendarStyles_1.CalendarDay, { index: index, children: daylabel }, daylabel));
84
+ };
85
+ // Render a calendar date as returned from the calendar builder function
86
+ // This method is used as a map callback as seen in render()
87
+ const renderCalendarDate = (date, index) => {
88
+ const { current, month, year } = dateState;
89
+ const _date = new Date(date.join("-"));
90
+ // Check if calendar date is same day as today
91
+ const isToday = (0, calendarHelpers_1.isSameDay)(_date, today);
92
+ // Check if calendar date is same day as currently selected date
93
+ const isCurrent = current && (0, calendarHelpers_1.isSameDay)(_date, current);
94
+ // Check if calendar date is in the same month as the state month and year
95
+ const inMonth = month && year && (0, calendarHelpers_1.isSameMonth)(_date, new Date([year, month, 1].join("-")));
96
+ // The click handler
97
+ const props = {
98
+ "data-disabled": !checkValidRange((0, calendarHelpers_1.getDateISO)(_date), min || null, max || null),
99
+ index,
100
+ key: (0, calendarHelpers_1.getDateISO)(_date),
101
+ onClick: gotoDate(_date),
102
+ title: _date.toDateString(),
103
+ inMonth,
104
+ };
105
+ // Conditionally render a styled date component
106
+ return isCurrent ? ((0, jsx_runtime_1.jsx)(CalendarStyles_1.HighlightedCalendarDate, Object.assign({}, props, { children: _date.getDate() }))) : isToday ? ((0, jsx_runtime_1.jsx)(CalendarStyles_1.TodayCalendarDate, Object.assign({}, props, { children: _date.getDate() }))) : ((0, jsx_runtime_1.jsx)(CalendarStyles_1.CalendarDate, Object.assign({}, props, { children: _date.getDate() })));
107
+ };
108
+ const renderHours = () => {
109
+ const { hours } = dateState;
110
+ const hoursArray = hourFormat === "24" ? calendarHelpers_1.HOURS24 : calendarHelpers_1.HOURS12;
111
+ return hoursArray.map((hour, index) => {
112
+ const HourComponent = hour.value === hours ? CalendarStyles_1.TimeItemActive : CalendarStyles_1.TimeItem;
113
+ return ((0, jsx_runtime_1.jsx)(HourComponent, {
114
+ // value={hour.value}
115
+ onClick: (e) => {
116
+ const newTime = (0, moment_1.default)(dateState.current)
117
+ .hours(hour.value)
118
+ .toDate();
119
+ setDateState(Object.assign(Object.assign({}, dateState), { hours: hour.value, current: newTime }));
120
+ onChange(newTime);
121
+ }, children: hour.label }, hour.value));
122
+ });
123
+ };
124
+ const renderMinutes = () => {
125
+ const { minutes } = dateState;
126
+ return calendarHelpers_1.MINUTES.map((minute) => {
127
+ const MinuteComponent = minute === minutes ? CalendarStyles_1.TimeItemActive : CalendarStyles_1.TimeItem;
128
+ return ((0, jsx_runtime_1.jsx)(MinuteComponent, {
129
+ // value={minute}
130
+ onClick: (e) => {
131
+ const newTime = (0, moment_1.default)(dateState.current)
132
+ .minutes(Number(minute))
133
+ .toDate();
134
+ setDateState(Object.assign(Object.assign({}, dateState), { minutes: Number(minute), current: newTime }));
135
+ onChange(newTime);
136
+ }, children: minute }, minute));
137
+ });
138
+ };
139
+ // new 2
140
+ const gotoDate = (date) => (evt) => {
141
+ evt && evt.preventDefault();
142
+ const { current } = dateState;
143
+ // Set Hours and Minutes
144
+ const newTime = (0, moment_1.default)(date)
145
+ .hours(includeTime ? dateState.hours : 0)
146
+ .minutes(includeTime ? dateState.minutes : 0)
147
+ .toDate();
148
+ !(current && (0, calendarHelpers_1.isSameDay)(newTime, current)) && addDateToState(newTime);
149
+ onChange(newTime);
150
+ };
151
+ const gotoPreviousMonth = () => {
152
+ const { month, year } = dateState;
153
+ const previousMonth = (0, calendarHelpers_1.getPreviousMonth)(month, year);
154
+ setDateState({
155
+ month: previousMonth.month,
156
+ year: previousMonth.year,
157
+ current: dateState.current,
158
+ hours: dateState.hours,
159
+ minutes: dateState.minutes,
160
+ });
161
+ };
162
+ const gotoNextMonth = () => {
163
+ const { month, year } = dateState;
164
+ const nextMonth = (0, calendarHelpers_1.getNextMonth)(month, year);
165
+ setDateState({
166
+ month: nextMonth.month,
167
+ year: nextMonth.year,
168
+ current: dateState.current,
169
+ hours: dateState.hours,
170
+ minutes: dateState.minutes,
171
+ });
172
+ };
173
+ const gotoPreviousYear = () => {
174
+ const { year } = dateState;
175
+ setDateState({
176
+ month: dateState.month,
177
+ year: year - 1,
178
+ current: dateState.current,
179
+ hours: dateState.hours,
180
+ minutes: dateState.minutes,
181
+ });
182
+ };
183
+ const gotoNextYear = () => {
184
+ const { year } = dateState;
185
+ setDateState({
186
+ month: dateState.month,
187
+ year: year + 1,
188
+ current: dateState.current,
189
+ hours: dateState.hours,
190
+ minutes: dateState.minutes,
191
+ });
192
+ };
193
+ const clearPressureTimer = () => {
194
+ pressureTimer && clearInterval(pressureTimer);
195
+ pressureTimeout && clearTimeout(pressureTimeout);
196
+ };
197
+ const handlePrevious = (evt) => {
198
+ evt && evt.preventDefault();
199
+ const fn = evt.shiftKey ? gotoPreviousYear : gotoPreviousMonth;
200
+ fn();
201
+ };
202
+ const handleNext = (evt) => {
203
+ evt && evt.preventDefault();
204
+ const fn = evt.shiftKey ? gotoNextYear : gotoNextMonth;
205
+ fn();
206
+ };
207
+ (0, react_1.useEffect)(() => {
208
+ if (value) {
209
+ addDateToState(value);
210
+ }
211
+ }, [value]);
212
+ // lifecycle methods
213
+ (0, react_1.useEffect)(() => {
214
+ const now = new Date().valueOf();
215
+ const tomorrow = new Date().setHours(0, 0, 0, 0) + 24 * 60 * 60 * 1000;
216
+ const ms = tomorrow - now;
217
+ dayTimeout = setTimeout(() => {
218
+ setToday(new Date());
219
+ clearDayTimeout();
220
+ }, ms);
221
+ return () => {
222
+ clearPressureTimer();
223
+ clearDayTimeout();
224
+ };
225
+ }, []);
226
+ const clearDayTimeout = () => {
227
+ dayTimeout && clearTimeout(dayTimeout);
228
+ };
229
+ return ((0, jsx_runtime_1.jsxs)(CalendarStyles_1.MainContainer, { children: [(0, jsx_runtime_1.jsxs)(CalendarStyles_1.CalendarContainer, { children: [renderMonthAndYear(), (0, jsx_runtime_1.jsxs)(CalendarStyles_1.CalendarGrid, { children: [(0, jsx_runtime_1.jsx)(react_1.Fragment, { children: Object.keys(calendarHelpers_1.WEEK_DAYS).map(renderDayLabel) }), (0, jsx_runtime_1.jsx)(react_1.Fragment, { children: getCalendarDates().map(renderCalendarDate) })] }), clearable && ((0, jsx_runtime_1.jsx)("div", { style: { textAlign: "center", marginTop: 3 }, children: (0, jsx_runtime_1.jsx)(CalendarStyles_1.NoValueButton, { onClick: () => onChange(null), children: "Clear Date" }) }))] }), includeTime && ((0, jsx_runtime_1.jsxs)(CalendarStyles_1.TimeContainer, { children: [(0, jsx_runtime_1.jsx)(CalendarStyles_1.TimeHeader, { children: "Select Time" }), (0, jsx_runtime_1.jsxs)(CalendarStyles_1.TimePickerContainer, { children: [(0, jsx_runtime_1.jsx)(CalendarStyles_1.TimeHourSelect, { children: renderHours() }), (0, jsx_runtime_1.jsx)(CalendarStyles_1.TimeMinuteSelect, { children: renderMinutes() })] })] }))] }));
230
+ };
231
+ Calendar.displayName = "Calendar";
232
+ exports.default = Calendar;
@@ -0,0 +1,36 @@
1
+ export declare const MainContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
2
+ export declare const CalendarContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
3
+ export declare const CalendarHeader: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
4
+ export declare const CalendarGrid: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
5
+ export declare const CalendarMonth: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
6
+ interface CalendarCellProps {
7
+ index?: number;
8
+ inMonth?: boolean | 0;
9
+ "data-disabled"?: boolean | 0;
10
+ key: string | null;
11
+ title?: string;
12
+ }
13
+ export declare const CalendarCell: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, CalendarCellProps>> & string;
14
+ export declare const CalendarDay: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<Omit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof CalendarCellProps> & CalendarCellProps, "ref"> & {
15
+ ref?: ((instance: HTMLDivElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLDivElement> | null | undefined;
16
+ }, CalendarCellProps>> & string;
17
+ export declare const CalendarDate: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<Omit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof CalendarCellProps> & CalendarCellProps, "ref"> & {
18
+ ref?: ((instance: HTMLDivElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLDivElement> | null | undefined;
19
+ }, CalendarCellProps>> & string;
20
+ export declare const HighlightedCalendarDate: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("styled-components").FastOmit<Omit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof CalendarCellProps> & CalendarCellProps, "ref"> & {
21
+ ref?: ((instance: HTMLDivElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLDivElement> | null | undefined;
22
+ }, keyof CalendarCellProps> & CalendarCellProps, CalendarCellProps>> & string;
23
+ export declare const TodayCalendarDate: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("styled-components").FastOmit<import("styled-components").FastOmit<Omit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof CalendarCellProps> & CalendarCellProps, "ref"> & {
24
+ ref?: ((instance: HTMLDivElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLDivElement> | null | undefined;
25
+ }, keyof CalendarCellProps> & CalendarCellProps, keyof CalendarCellProps> & CalendarCellProps, CalendarCellProps>> & string;
26
+ export declare const TimeContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
27
+ export declare const TimePickerContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
28
+ export declare const TimeHeader: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
29
+ export declare const TimeHourSelect: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
30
+ export declare const TimeMinuteSelect: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
31
+ export declare const TimeItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
32
+ export declare const TimeItemActive: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>, "ref"> & {
33
+ ref?: ((instance: HTMLDivElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLDivElement> | null | undefined;
34
+ }, never>> & string;
35
+ export declare const NoValueButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, never>> & string;
36
+ export {};