@xsolla/xui-date-picker 0.64.0-pr56.1768440195

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/web/index.js ADDED
@@ -0,0 +1,944 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.tsx
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ Calendar: () => Calendar,
34
+ DatePicker: () => DatePicker,
35
+ formatDate: () => formatDate,
36
+ getMonthInLocale: () => getMonthInLocale
37
+ });
38
+ module.exports = __toCommonJS(index_exports);
39
+
40
+ // src/DatePicker.tsx
41
+ var import_react6 = require("react");
42
+
43
+ // ../primitives-web/src/Box.tsx
44
+ var import_react = __toESM(require("react"));
45
+ var import_styled_components = __toESM(require("styled-components"));
46
+ var import_jsx_runtime = require("react/jsx-runtime");
47
+ var StyledBox = import_styled_components.default.div`
48
+ display: flex;
49
+ box-sizing: border-box;
50
+ background-color: ${(props) => props.backgroundColor || "transparent"};
51
+ border-color: ${(props) => props.borderColor || "transparent"};
52
+ border-width: ${(props) => typeof props.borderWidth === "number" ? `${props.borderWidth}px` : props.borderWidth || 0};
53
+
54
+ ${(props) => props.borderBottomWidth !== void 0 && `
55
+ border-bottom-width: ${typeof props.borderBottomWidth === "number" ? `${props.borderBottomWidth}px` : props.borderBottomWidth};
56
+ border-bottom-color: ${props.borderBottomColor || props.borderColor || "transparent"};
57
+ border-bottom-style: solid;
58
+ `}
59
+ ${(props) => props.borderTopWidth !== void 0 && `
60
+ border-top-width: ${typeof props.borderTopWidth === "number" ? `${props.borderTopWidth}px` : props.borderTopWidth};
61
+ border-top-color: ${props.borderTopColor || props.borderColor || "transparent"};
62
+ border-top-style: solid;
63
+ `}
64
+ ${(props) => props.borderLeftWidth !== void 0 && `
65
+ border-left-width: ${typeof props.borderLeftWidth === "number" ? `${props.borderLeftWidth}px` : props.borderLeftWidth};
66
+ border-left-color: ${props.borderLeftColor || props.borderColor || "transparent"};
67
+ border-left-style: solid;
68
+ `}
69
+ ${(props) => props.borderRightWidth !== void 0 && `
70
+ border-right-width: ${typeof props.borderRightWidth === "number" ? `${props.borderRightWidth}px` : props.borderRightWidth};
71
+ border-right-color: ${props.borderRightColor || props.borderColor || "transparent"};
72
+ border-right-style: solid;
73
+ `}
74
+
75
+ border-style: ${(props) => props.borderStyle || (props.borderWidth || props.borderBottomWidth || props.borderTopWidth || props.borderLeftWidth || props.borderRightWidth ? "solid" : "none")};
76
+ border-radius: ${(props) => typeof props.borderRadius === "number" ? `${props.borderRadius}px` : props.borderRadius || 0};
77
+ height: ${(props) => typeof props.height === "number" ? `${props.height}px` : props.height || "auto"};
78
+ width: ${(props) => typeof props.width === "number" ? `${props.width}px` : props.width || "auto"};
79
+ min-width: ${(props) => typeof props.minWidth === "number" ? `${props.minWidth}px` : props.minWidth || "auto"};
80
+ min-height: ${(props) => typeof props.minHeight === "number" ? `${props.minHeight}px` : props.minHeight || "auto"};
81
+
82
+ padding: ${(props) => typeof props.padding === "number" ? `${props.padding}px` : props.padding || 0};
83
+ ${(props) => props.paddingHorizontal && `
84
+ padding-left: ${typeof props.paddingHorizontal === "number" ? `${props.paddingHorizontal}px` : props.paddingHorizontal};
85
+ padding-right: ${typeof props.paddingHorizontal === "number" ? `${props.paddingHorizontal}px` : props.paddingHorizontal};
86
+ `}
87
+ ${(props) => props.paddingVertical && `
88
+ padding-top: ${typeof props.paddingVertical === "number" ? `${props.paddingVertical}px` : props.paddingVertical};
89
+ padding-bottom: ${typeof props.paddingVertical === "number" ? `${props.paddingVertical}px` : props.paddingVertical};
90
+ `}
91
+ ${(props) => props.paddingTop !== void 0 && `padding-top: ${typeof props.paddingTop === "number" ? `${props.paddingTop}px` : props.paddingTop};`}
92
+ ${(props) => props.paddingBottom !== void 0 && `padding-bottom: ${typeof props.paddingBottom === "number" ? `${props.paddingBottom}px` : props.paddingBottom};`}
93
+ ${(props) => props.paddingLeft !== void 0 && `padding-left: ${typeof props.paddingLeft === "number" ? `${props.paddingLeft}px` : props.paddingLeft};`}
94
+ ${(props) => props.paddingRight !== void 0 && `padding-right: ${typeof props.paddingRight === "number" ? `${props.paddingRight}px` : props.paddingRight};`}
95
+
96
+ margin: ${(props) => typeof props.margin === "number" ? `${props.margin}px` : props.margin || 0};
97
+ ${(props) => props.marginTop !== void 0 && `margin-top: ${typeof props.marginTop === "number" ? `${props.marginTop}px` : props.marginTop};`}
98
+ ${(props) => props.marginBottom !== void 0 && `margin-bottom: ${typeof props.marginBottom === "number" ? `${props.marginBottom}px` : props.marginBottom};`}
99
+ ${(props) => props.marginLeft !== void 0 && `margin-left: ${typeof props.marginLeft === "number" ? `${props.marginLeft}px` : props.marginLeft};`}
100
+ ${(props) => props.marginRight !== void 0 && `margin-right: ${typeof props.marginRight === "number" ? `${props.marginRight}px` : props.marginRight};`}
101
+
102
+ flex-direction: ${(props) => props.flexDirection || "column"};
103
+ flex-wrap: ${(props) => props.flexWrap || "nowrap"};
104
+ align-items: ${(props) => props.alignItems || "stretch"};
105
+ justify-content: ${(props) => props.justifyContent || "flex-start"};
106
+ cursor: ${(props) => props.cursor ? props.cursor : props.onClick || props.onPress ? "pointer" : "inherit"};
107
+ position: ${(props) => props.position || "static"};
108
+ top: ${(props) => typeof props.top === "number" ? `${props.top}px` : props.top};
109
+ bottom: ${(props) => typeof props.bottom === "number" ? `${props.bottom}px` : props.bottom};
110
+ left: ${(props) => typeof props.left === "number" ? `${props.left}px` : props.left};
111
+ right: ${(props) => typeof props.right === "number" ? `${props.right}px` : props.right};
112
+ flex: ${(props) => props.flex};
113
+ flex-shrink: ${(props) => props.flexShrink ?? 1};
114
+ gap: ${(props) => typeof props.gap === "number" ? `${props.gap}px` : props.gap || 0};
115
+ align-self: ${(props) => props.alignSelf || "auto"};
116
+ overflow: ${(props) => props.overflow || "visible"};
117
+ overflow-x: ${(props) => props.overflowX || "visible"};
118
+ overflow-y: ${(props) => props.overflowY || "visible"};
119
+ z-index: ${(props) => props.zIndex};
120
+ opacity: ${(props) => props.disabled ? 0.5 : 1};
121
+ pointer-events: ${(props) => props.disabled ? "none" : "auto"};
122
+
123
+ &:hover {
124
+ ${(props) => props.hoverStyle?.backgroundColor && `background-color: ${props.hoverStyle.backgroundColor};`}
125
+ ${(props) => props.hoverStyle?.borderColor && `border-color: ${props.hoverStyle.borderColor};`}
126
+ }
127
+
128
+ &:active {
129
+ ${(props) => props.pressStyle?.backgroundColor && `background-color: ${props.pressStyle.backgroundColor};`}
130
+ }
131
+ `;
132
+ var Box = import_react.default.forwardRef(
133
+ ({
134
+ children,
135
+ onPress,
136
+ onKeyDown,
137
+ onKeyUp,
138
+ role,
139
+ "aria-label": ariaLabel,
140
+ "aria-labelledby": ariaLabelledBy,
141
+ "aria-current": ariaCurrent,
142
+ "aria-disabled": ariaDisabled,
143
+ "aria-live": ariaLive,
144
+ "aria-busy": ariaBusy,
145
+ "aria-describedby": ariaDescribedBy,
146
+ "aria-expanded": ariaExpanded,
147
+ "aria-haspopup": ariaHasPopup,
148
+ "aria-pressed": ariaPressed,
149
+ "aria-controls": ariaControls,
150
+ tabIndex,
151
+ as,
152
+ src,
153
+ alt,
154
+ type,
155
+ disabled,
156
+ id,
157
+ ...props
158
+ }, ref) => {
159
+ if (as === "img" && src) {
160
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
161
+ "img",
162
+ {
163
+ src,
164
+ alt: alt || "",
165
+ style: {
166
+ display: "block",
167
+ objectFit: "cover",
168
+ width: typeof props.width === "number" ? `${props.width}px` : props.width,
169
+ height: typeof props.height === "number" ? `${props.height}px` : props.height,
170
+ borderRadius: typeof props.borderRadius === "number" ? `${props.borderRadius}px` : props.borderRadius,
171
+ position: props.position,
172
+ top: typeof props.top === "number" ? `${props.top}px` : props.top,
173
+ left: typeof props.left === "number" ? `${props.left}px` : props.left,
174
+ right: typeof props.right === "number" ? `${props.right}px` : props.right,
175
+ bottom: typeof props.bottom === "number" ? `${props.bottom}px` : props.bottom
176
+ }
177
+ }
178
+ );
179
+ }
180
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
181
+ StyledBox,
182
+ {
183
+ ref,
184
+ as,
185
+ id,
186
+ type: as === "button" ? type || "button" : void 0,
187
+ disabled: as === "button" ? disabled : void 0,
188
+ onClick: onPress,
189
+ onKeyDown,
190
+ onKeyUp,
191
+ role,
192
+ "aria-label": ariaLabel,
193
+ "aria-labelledby": ariaLabelledBy,
194
+ "aria-current": ariaCurrent,
195
+ "aria-disabled": ariaDisabled,
196
+ "aria-busy": ariaBusy,
197
+ "aria-describedby": ariaDescribedBy,
198
+ "aria-expanded": ariaExpanded,
199
+ "aria-haspopup": ariaHasPopup,
200
+ "aria-pressed": ariaPressed,
201
+ "aria-controls": ariaControls,
202
+ "aria-live": ariaLive,
203
+ tabIndex: tabIndex !== void 0 ? tabIndex : void 0,
204
+ ...props,
205
+ children
206
+ }
207
+ );
208
+ }
209
+ );
210
+ Box.displayName = "Box";
211
+
212
+ // ../primitives-web/src/Text.tsx
213
+ var import_styled_components2 = __toESM(require("styled-components"));
214
+ var import_jsx_runtime2 = require("react/jsx-runtime");
215
+ var StyledText = import_styled_components2.default.span`
216
+ color: ${(props) => props.color || "inherit"};
217
+ font-size: ${(props) => typeof props.fontSize === "number" ? `${props.fontSize}px` : props.fontSize || "inherit"};
218
+ font-weight: ${(props) => props.fontWeight || "normal"};
219
+ font-family: ${(props) => props.fontFamily || '"Pilat Wide Bold", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important'};
220
+ line-height: ${(props) => typeof props.lineHeight === "number" ? `${props.lineHeight}px` : props.lineHeight || "inherit"};
221
+ white-space: ${(props) => props.whiteSpace || "normal"};
222
+ text-align: ${(props) => props.textAlign || "inherit"};
223
+ text-decoration: ${(props) => props.textDecoration || "none"};
224
+ `;
225
+ var Text = ({
226
+ style,
227
+ className,
228
+ id,
229
+ role,
230
+ ...props
231
+ }) => {
232
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
233
+ StyledText,
234
+ {
235
+ ...props,
236
+ style,
237
+ className,
238
+ id,
239
+ role
240
+ }
241
+ );
242
+ };
243
+
244
+ // ../primitives-web/src/Spinner.tsx
245
+ var import_styled_components3 = __toESM(require("styled-components"));
246
+ var import_jsx_runtime3 = require("react/jsx-runtime");
247
+ var rotate = import_styled_components3.keyframes`
248
+ from {
249
+ transform: rotate(0deg);
250
+ }
251
+ to {
252
+ transform: rotate(360deg);
253
+ }
254
+ `;
255
+ var StyledSpinner = import_styled_components3.default.div`
256
+ width: ${(props) => typeof props.size === "number" ? `${props.size}px` : props.size || "24px"};
257
+ height: ${(props) => typeof props.size === "number" ? `${props.size}px` : props.size || "24px"};
258
+ border: ${(props) => props.strokeWidth || 2}px solid
259
+ ${(props) => props.color || "currentColor"};
260
+ border-bottom-color: transparent;
261
+ border-radius: 50%;
262
+ display: inline-block;
263
+ box-sizing: border-box;
264
+ animation: ${rotate} 1s linear infinite;
265
+ `;
266
+ var Spinner = ({
267
+ role = "status",
268
+ "aria-label": ariaLabel,
269
+ "aria-live": ariaLive = "polite",
270
+ "aria-describedby": ariaDescribedBy,
271
+ testID,
272
+ ...props
273
+ }) => {
274
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
275
+ StyledSpinner,
276
+ {
277
+ role,
278
+ "aria-label": ariaLabel,
279
+ "aria-live": ariaLive,
280
+ "aria-describedby": ariaDescribedBy,
281
+ "data-testid": testID,
282
+ ...props
283
+ }
284
+ );
285
+ };
286
+ Spinner.displayName = "Spinner";
287
+
288
+ // ../primitives-web/src/Icon.tsx
289
+ var import_styled_components4 = __toESM(require("styled-components"));
290
+ var import_jsx_runtime4 = require("react/jsx-runtime");
291
+ var StyledIcon = import_styled_components4.default.div`
292
+ display: flex;
293
+ align-items: center;
294
+ justify-content: center;
295
+ width: ${(props) => typeof props.size === "number" ? `${props.size}px` : props.size || "24px"};
296
+ height: ${(props) => typeof props.size === "number" ? `${props.size}px` : props.size || "24px"};
297
+ color: ${(props) => props.color || "currentColor"};
298
+
299
+ svg {
300
+ width: 100%;
301
+ height: 100%;
302
+ fill: none;
303
+ stroke: currentColor;
304
+ }
305
+ `;
306
+
307
+ // ../primitives-web/src/Divider.tsx
308
+ var import_styled_components5 = __toESM(require("styled-components"));
309
+ var import_jsx_runtime5 = require("react/jsx-runtime");
310
+ var StyledDivider = import_styled_components5.default.div`
311
+ background-color: ${(props) => props.dashStroke ? "transparent" : props.color || "rgba(255, 255, 255, 0.15)"};
312
+ width: ${(props) => props.vertical ? typeof props.width === "number" ? `${props.width}px` : props.width || "1px" : "100%"};
313
+ height: ${(props) => props.vertical ? "100%" : typeof props.height === "number" ? `${props.height}px` : props.height || "1px"};
314
+
315
+ ${(props) => props.dashStroke && `
316
+ border-style: dashed;
317
+ border-color: ${props.color || "rgba(255, 255, 255, 0.15)"};
318
+ border-width: 0;
319
+ ${props.vertical ? `
320
+ border-left-width: ${typeof props.width === "number" ? `${props.width}px` : props.width || "1px"};
321
+ height: 100%;
322
+ ` : `
323
+ border-top-width: ${typeof props.height === "number" ? `${props.height}px` : props.height || "1px"};
324
+ width: 100%;
325
+ `}
326
+ `}
327
+ `;
328
+
329
+ // ../primitives-web/src/Input.tsx
330
+ var import_react2 = require("react");
331
+ var import_styled_components6 = __toESM(require("styled-components"));
332
+ var import_jsx_runtime6 = require("react/jsx-runtime");
333
+ var StyledInput = import_styled_components6.default.input`
334
+ background: transparent;
335
+ border: none;
336
+ outline: none;
337
+ width: 100%;
338
+ height: 100%;
339
+ padding: 0;
340
+ margin: 0;
341
+ color: ${(props) => props.color || "inherit"};
342
+ font-size: ${(props) => typeof props.fontSize === "number" ? `${props.fontSize}px` : props.fontSize || "inherit"};
343
+ font-family: inherit;
344
+ text-align: inherit;
345
+
346
+ &::placeholder {
347
+ color: ${(props) => props.placeholderTextColor || "rgba(255, 255, 255, 0.5)"};
348
+ }
349
+
350
+ &:disabled {
351
+ cursor: not-allowed;
352
+ }
353
+ `;
354
+ var InputPrimitive = (0, import_react2.forwardRef)(
355
+ ({
356
+ value,
357
+ placeholder,
358
+ onChange,
359
+ onChangeText,
360
+ onFocus,
361
+ onBlur,
362
+ onKeyDown,
363
+ disabled,
364
+ secureTextEntry,
365
+ style,
366
+ color,
367
+ fontSize,
368
+ placeholderTextColor,
369
+ maxLength,
370
+ name,
371
+ type,
372
+ inputMode,
373
+ autoComplete,
374
+ id,
375
+ "aria-invalid": ariaInvalid,
376
+ "aria-describedby": ariaDescribedBy,
377
+ "aria-labelledby": ariaLabelledBy,
378
+ "aria-label": ariaLabel,
379
+ "aria-disabled": ariaDisabled,
380
+ "data-testid": dataTestId,
381
+ ...rest
382
+ }, ref) => {
383
+ const handleChange = (e) => {
384
+ if (onChange) {
385
+ onChange(e);
386
+ }
387
+ if (onChangeText) {
388
+ onChangeText(e.target.value);
389
+ }
390
+ };
391
+ const inputValue = value !== void 0 ? value : "";
392
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
393
+ StyledInput,
394
+ {
395
+ ref,
396
+ id,
397
+ value: inputValue,
398
+ name,
399
+ placeholder,
400
+ onChange: handleChange,
401
+ onFocus,
402
+ onBlur,
403
+ onKeyDown,
404
+ disabled,
405
+ type: secureTextEntry ? "password" : type || "text",
406
+ inputMode,
407
+ autoComplete,
408
+ style,
409
+ color,
410
+ fontSize,
411
+ placeholderTextColor,
412
+ maxLength,
413
+ "aria-invalid": ariaInvalid,
414
+ "aria-describedby": ariaDescribedBy,
415
+ "aria-labelledby": ariaLabelledBy,
416
+ "aria-label": ariaLabel,
417
+ "aria-disabled": ariaDisabled,
418
+ "data-testid": dataTestId,
419
+ ...rest
420
+ }
421
+ );
422
+ }
423
+ );
424
+ InputPrimitive.displayName = "InputPrimitive";
425
+
426
+ // ../primitives-web/src/TextArea.tsx
427
+ var import_react3 = require("react");
428
+ var import_styled_components7 = __toESM(require("styled-components"));
429
+ var import_jsx_runtime7 = require("react/jsx-runtime");
430
+ var StyledTextArea = import_styled_components7.default.textarea`
431
+ background: transparent;
432
+ border: none;
433
+ outline: none;
434
+ width: 100%;
435
+ height: 100%;
436
+ padding: 0;
437
+ margin: 0;
438
+ color: ${(props) => props.color || "inherit"};
439
+ font-size: ${(props) => typeof props.fontSize === "number" ? `${props.fontSize}px` : props.fontSize || "inherit"};
440
+ font-family: inherit;
441
+ text-align: inherit;
442
+ resize: none;
443
+
444
+ &::placeholder {
445
+ color: ${(props) => props.placeholderTextColor || "rgba(255, 255, 255, 0.5)"};
446
+ }
447
+
448
+ &:disabled {
449
+ cursor: not-allowed;
450
+ }
451
+ `;
452
+ var TextAreaPrimitive = (0, import_react3.forwardRef)(
453
+ ({
454
+ value,
455
+ placeholder,
456
+ onChangeText,
457
+ onFocus,
458
+ onBlur,
459
+ onKeyDown,
460
+ disabled,
461
+ style,
462
+ color,
463
+ fontSize,
464
+ placeholderTextColor,
465
+ maxLength,
466
+ rows
467
+ }, ref) => {
468
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
469
+ StyledTextArea,
470
+ {
471
+ ref,
472
+ value,
473
+ placeholder,
474
+ onChange: (e) => onChangeText?.(e.target.value),
475
+ onFocus,
476
+ onBlur,
477
+ onKeyDown,
478
+ disabled,
479
+ style,
480
+ color,
481
+ fontSize,
482
+ placeholderTextColor,
483
+ maxLength,
484
+ rows
485
+ }
486
+ );
487
+ }
488
+ );
489
+ TextAreaPrimitive.displayName = "TextAreaPrimitive";
490
+
491
+ // src/DatePicker.tsx
492
+ var import_xui_input = require("@xsolla/xui-input");
493
+ var import_xui_core2 = require("@xsolla/xui-core");
494
+ var import_date_fns3 = require("date-fns");
495
+
496
+ // src/Calendar.tsx
497
+ var import_react5 = require("react");
498
+ var import_xui_core = require("@xsolla/xui-core");
499
+ var import_date_fns2 = require("date-fns");
500
+ var locales2 = __toESM(require("date-fns/locale"));
501
+
502
+ // src/CalendarHeader.tsx
503
+ var import_react4 = require("react");
504
+ var import_xui_button = require("@xsolla/xui-button");
505
+ var import_xui_select = require("@xsolla/xui-select");
506
+
507
+ // src/utils.ts
508
+ var import_date_fns = require("date-fns");
509
+ var locales = __toESM(require("date-fns/locale"));
510
+ var defaultLocale = "enUS";
511
+ function formatDate(date, formatStr, locale = defaultLocale) {
512
+ const localeObj = locales[locale] || locales[defaultLocale];
513
+ return (0, import_date_fns.format)(date, formatStr, {
514
+ locale: localeObj
515
+ });
516
+ }
517
+ function getMonthInLocale(month, locale = defaultLocale) {
518
+ return formatDate((0, import_date_fns.setMonth)(/* @__PURE__ */ new Date(), month), "LLLL", locale);
519
+ }
520
+
521
+ // src/CalendarHeader.tsx
522
+ var import_jsx_runtime8 = require("react/jsx-runtime");
523
+ var ArrowLeft = () => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("svg", { viewBox: "0 0 24 24", width: 16, height: 16, fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("polyline", { points: "15 18 9 12 15 6" }) });
524
+ var ArrowRight = () => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("svg", { viewBox: "0 0 24 24", width: 16, height: 16, fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("polyline", { points: "9 18 15 12 9 6" }) });
525
+ var months = [
526
+ "january",
527
+ "february",
528
+ "march",
529
+ "april",
530
+ "may",
531
+ "june",
532
+ "july",
533
+ "august",
534
+ "september",
535
+ "october",
536
+ "november",
537
+ "december"
538
+ ];
539
+ var CalendarHeader = ({
540
+ monthDate,
541
+ decreaseMonth,
542
+ increaseMonth,
543
+ changeYear,
544
+ changeMonth,
545
+ prevMonthButtonDisabled,
546
+ nextMonthButtonDisabled,
547
+ locale,
548
+ minDate,
549
+ maxDate,
550
+ contextMenuMaxHeight = 240
551
+ }) => {
552
+ const handleChangeMonth = (0, import_react4.useCallback)(
553
+ (value) => {
554
+ changeMonth(months.indexOf(value));
555
+ },
556
+ [changeMonth]
557
+ );
558
+ const handleChangeYear = (0, import_react4.useCallback)(
559
+ (value) => {
560
+ changeYear(parseInt(value, 10));
561
+ },
562
+ [changeYear]
563
+ );
564
+ const monthOptions = (0, import_react4.useMemo)(() => {
565
+ return months.map((month, index) => ({
566
+ label: getMonthInLocale(index, locale),
567
+ value: month
568
+ }));
569
+ }, [locale]);
570
+ const yearOptions = (0, import_react4.useMemo)(() => {
571
+ const options = [];
572
+ const yearStart = minDate ? minDate.getFullYear() : 1900;
573
+ const yearEnd = maxDate ? maxDate.getFullYear() : (/* @__PURE__ */ new Date()).getFullYear() + 100;
574
+ for (let i = yearEnd; i >= yearStart; i--) {
575
+ options.push({ value: i.toString(), label: i.toString() });
576
+ }
577
+ return options;
578
+ }, [minDate, maxDate]);
579
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
580
+ Box,
581
+ {
582
+ width: "100%",
583
+ flexDirection: "row",
584
+ justifyContent: "space-between",
585
+ alignItems: "center",
586
+ marginBottom: 16,
587
+ gap: 8,
588
+ children: [
589
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
590
+ import_xui_button.IconButton,
591
+ {
592
+ size: "xs",
593
+ tone: "mono",
594
+ variant: "secondary",
595
+ onPress: decreaseMonth,
596
+ disabled: prevMonthButtonDisabled,
597
+ icon: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ArrowLeft, {}),
598
+ "aria-label": "Previous month"
599
+ }
600
+ ),
601
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Box, { flexDirection: "row", flex: 1, gap: 4, children: [
602
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Box, { flex: 1.5, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
603
+ import_xui_select.Select,
604
+ {
605
+ value: months[monthDate.getMonth()],
606
+ onValueChange: handleChangeMonth,
607
+ options: monthOptions,
608
+ size: "s"
609
+ }
610
+ ) }),
611
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Box, { flex: 1, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
612
+ import_xui_select.Select,
613
+ {
614
+ value: monthDate.getFullYear().toString(),
615
+ onValueChange: handleChangeYear,
616
+ options: yearOptions,
617
+ size: "s"
618
+ }
619
+ ) })
620
+ ] }),
621
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
622
+ import_xui_button.IconButton,
623
+ {
624
+ size: "xs",
625
+ tone: "mono",
626
+ variant: "secondary",
627
+ onPress: increaseMonth,
628
+ disabled: nextMonthButtonDisabled,
629
+ icon: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ArrowRight, {}),
630
+ "aria-label": "Next month"
631
+ }
632
+ )
633
+ ]
634
+ }
635
+ );
636
+ };
637
+
638
+ // src/Calendar.tsx
639
+ var import_jsx_runtime9 = require("react/jsx-runtime");
640
+ var Calendar = (0, import_react5.forwardRef)(
641
+ ({
642
+ locale = "enUS",
643
+ onChange,
644
+ startDate,
645
+ endDate,
646
+ selectedDate,
647
+ selectsRange = false,
648
+ contextMenuMaxHeight,
649
+ topContent,
650
+ bottomContent,
651
+ testID,
652
+ minDate,
653
+ maxDate,
654
+ firstDayOfWeek = 0,
655
+ month,
656
+ initialMonth
657
+ }, ref) => {
658
+ const { theme } = (0, import_xui_core.useDesignSystem)();
659
+ const localeObj = locales2[locale] || locales2.enUS;
660
+ const [currentMonth, setCurrentMonth] = (0, import_react5.useState)(
661
+ month || initialMonth || selectedDate || startDate || /* @__PURE__ */ new Date()
662
+ );
663
+ const [selectedStartDate, setSelectedStartDate] = (0, import_react5.useState)(startDate);
664
+ const [selectedEndDate, setSelectedEndDate] = (0, import_react5.useState)(endDate);
665
+ const [locSelectedDate, setLocSelectedDate] = (0, import_react5.useState)(selectedDate);
666
+ const [selectingRange, setSelectingRange] = (0, import_react5.useState)(null);
667
+ (0, import_react5.useEffect)(() => {
668
+ setSelectedStartDate(startDate);
669
+ setSelectedEndDate(endDate);
670
+ setLocSelectedDate(selectedDate);
671
+ if (month !== void 0) {
672
+ setCurrentMonth(month);
673
+ }
674
+ }, [startDate, endDate, selectedDate, month]);
675
+ const handleChange = (0, import_react5.useCallback)(
676
+ (date) => {
677
+ const newDate = new Date(
678
+ currentMonth.getFullYear(),
679
+ currentMonth.getMonth(),
680
+ date.getDate()
681
+ );
682
+ if (!selectsRange) {
683
+ setLocSelectedDate(newDate);
684
+ onChange?.(newDate);
685
+ } else {
686
+ if (!selectedStartDate || selectedStartDate && selectedEndDate) {
687
+ setSelectedStartDate(newDate);
688
+ setSelectedEndDate(null);
689
+ setSelectingRange(newDate);
690
+ onChange?.([newDate, null]);
691
+ } else {
692
+ const start = selectedStartDate < newDate ? selectedStartDate : newDate;
693
+ const end = selectedStartDate < newDate ? newDate : selectedStartDate;
694
+ setSelectedStartDate(start);
695
+ setSelectedEndDate(end);
696
+ setSelectingRange(null);
697
+ onChange?.([start, end]);
698
+ }
699
+ }
700
+ },
701
+ [onChange, selectsRange, selectedStartDate, selectedEndDate, currentMonth]
702
+ );
703
+ const decreaseMonth = (0, import_react5.useCallback)(() => setCurrentMonth((prev) => (0, import_date_fns2.subMonths)(prev, 1)), []);
704
+ const increaseMonth = (0, import_react5.useCallback)(() => setCurrentMonth((prev) => (0, import_date_fns2.addMonths)(prev, 1)), []);
705
+ const changeMonth = (0, import_react5.useCallback)((m) => setCurrentMonth((prev) => new Date(prev.getFullYear(), m, 1)), []);
706
+ const changeYear = (0, import_react5.useCallback)((y) => setCurrentMonth((prev) => new Date(y, prev.getMonth(), 1)), []);
707
+ const monthStart = (0, import_date_fns2.startOfMonth)(currentMonth);
708
+ const monthEnd = (0, import_date_fns2.endOfMonth)(currentMonth);
709
+ const weekStartsOn = firstDayOfWeek ?? 0;
710
+ const calendarStart = (0, import_date_fns2.startOfWeek)(monthStart, { weekStartsOn });
711
+ const calendarEnd = (0, import_date_fns2.endOfWeek)(monthEnd, { weekStartsOn });
712
+ const days = (0, import_date_fns2.eachDayOfInterval)({ start: calendarStart, end: calendarEnd });
713
+ const weekDays = (0, import_react5.useMemo)(() => {
714
+ return Array.from({ length: 7 }, (_, i) => {
715
+ const day = (0, import_date_fns2.addDays)(calendarStart, i);
716
+ return (0, import_date_fns2.format)(day, "EEEEEE", { locale: localeObj });
717
+ });
718
+ }, [calendarStart, localeObj]);
719
+ const weeks = (0, import_react5.useMemo)(() => {
720
+ const weekArray = [];
721
+ for (let i = 0; i < days.length; i += 7) {
722
+ weekArray.push(days.slice(i, i + 7));
723
+ }
724
+ return weekArray;
725
+ }, [days]);
726
+ const isDateDisabled = (0, import_react5.useCallback)(
727
+ (date) => {
728
+ if (minDate && (0, import_date_fns2.isBefore)(date, (0, import_date_fns2.startOfDay)(minDate))) return true;
729
+ if (maxDate && (0, import_date_fns2.isAfter)(date, (0, import_date_fns2.endOfDay)(maxDate))) return true;
730
+ return false;
731
+ },
732
+ [minDate, maxDate]
733
+ );
734
+ const isDateInRange = (0, import_react5.useCallback)(
735
+ (date) => {
736
+ if (!selectsRange || !selectedStartDate) return false;
737
+ const rangeEnd = selectedEndDate || selectingRange;
738
+ if (!rangeEnd) return false;
739
+ const start = selectedStartDate < rangeEnd ? selectedStartDate : rangeEnd;
740
+ const end = selectedStartDate < rangeEnd ? rangeEnd : selectedStartDate;
741
+ return (0, import_date_fns2.isWithinInterval)(date, { start: (0, import_date_fns2.startOfDay)(start), end: (0, import_date_fns2.endOfDay)(end) });
742
+ },
743
+ [selectsRange, selectedStartDate, selectedEndDate, selectingRange]
744
+ );
745
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
746
+ Box,
747
+ {
748
+ ref,
749
+ testID,
750
+ backgroundColor: theme.colors.background.secondary,
751
+ borderRadius: 8,
752
+ padding: 16,
753
+ overflow: "hidden",
754
+ style: {
755
+ boxShadow: "0px 4px 16px 0px rgba(7, 7, 8, 0.1)",
756
+ width: 312
757
+ },
758
+ children: [
759
+ topContent?.({ close: () => {
760
+ } }),
761
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
762
+ CalendarHeader,
763
+ {
764
+ monthDate: currentMonth,
765
+ decreaseMonth,
766
+ increaseMonth,
767
+ changeYear,
768
+ changeMonth,
769
+ locale,
770
+ minDate,
771
+ maxDate,
772
+ contextMenuMaxHeight
773
+ }
774
+ ),
775
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Box, { flexDirection: "row", justifyContent: "space-between", marginBottom: 8, children: weekDays.map((day, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Box, { width: 40, alignItems: "center", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Text, { fontSize: 12, fontWeight: "600", color: theme.colors.content.tertiary, children: day.toUpperCase() }) }, i)) }),
776
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Box, { gap: 2, children: weeks.map((week, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Box, { flexDirection: "row", justifyContent: "space-between", children: week.map((day, j) => {
777
+ const isOutsideMonth = !(0, import_date_fns2.isSameMonth)(day, currentMonth);
778
+ const isSelected = !selectsRange && locSelectedDate && (0, import_date_fns2.isSameDay)(day, locSelectedDate) || selectsRange && selectedStartDate && selectedEndDate && (0, import_date_fns2.isSameDay)(day, selectedStartDate) && (0, import_date_fns2.isSameDay)(day, selectedEndDate);
779
+ const isRangeStart = selectsRange && selectedStartDate && (0, import_date_fns2.isSameDay)(day, selectedStartDate);
780
+ const isRangeEnd = selectsRange && selectedEndDate && (0, import_date_fns2.isSameDay)(day, selectedEndDate);
781
+ const inRange = isDateInRange(day);
782
+ const today = (0, import_date_fns2.isToday)(day);
783
+ const disabled = isDateDisabled(day);
784
+ let bgColor = "transparent";
785
+ let textColor = theme.colors.content.primary;
786
+ if (isSelected || isRangeStart || isRangeEnd) {
787
+ bgColor = theme.colors.background.brand.primary;
788
+ textColor = theme.colors.content.on.brand;
789
+ } else if (inRange) {
790
+ bgColor = theme.colors.overlay.brand;
791
+ } else if (today) {
792
+ bgColor = theme.colors.overlay.mono;
793
+ }
794
+ if (isOutsideMonth || disabled) {
795
+ textColor = theme.colors.content.tertiary;
796
+ }
797
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
798
+ Box,
799
+ {
800
+ width: 40,
801
+ height: 32,
802
+ alignItems: "center",
803
+ justifyContent: "center",
804
+ borderRadius: isSelected || isRangeStart || isRangeEnd ? 4 : 0,
805
+ backgroundColor: bgColor,
806
+ cursor: disabled || isOutsideMonth ? "default" : "pointer",
807
+ onPress: () => !disabled && !isOutsideMonth && handleChange(day),
808
+ hoverStyle: !disabled && !isOutsideMonth && !isSelected ? { backgroundColor: theme.colors.overlay.mono } : void 0,
809
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Text, { color: textColor, fontSize: 14, fontWeight: isSelected || isRangeStart || isRangeEnd ? "600" : "400", children: (0, import_date_fns2.format)(day, "d") })
810
+ },
811
+ j
812
+ );
813
+ }) }, i)) }),
814
+ bottomContent?.({ close: () => {
815
+ } })
816
+ ]
817
+ }
818
+ );
819
+ }
820
+ );
821
+ Calendar.displayName = "Calendar";
822
+
823
+ // src/DatePicker.tsx
824
+ var import_jsx_runtime10 = require("react/jsx-runtime");
825
+ var DatePicker = (0, import_react6.forwardRef)(
826
+ ({
827
+ onChange,
828
+ size = "m",
829
+ locale = "enUS",
830
+ selectsRange = false,
831
+ startDate,
832
+ endDate,
833
+ selectedDate,
834
+ placeholder,
835
+ backgroundColor,
836
+ testID,
837
+ ...rest
838
+ }, ref) => {
839
+ const { theme } = (0, import_xui_core2.useDesignSystem)();
840
+ const [open, setOpen] = (0, import_react6.useState)(false);
841
+ const [inputValue, setInputValue] = (0, import_react6.useState)("");
842
+ const containerRef = (0, import_react6.useRef)(null);
843
+ const formatDateForDisplay = (date) => {
844
+ if (!date) return "";
845
+ try {
846
+ return (0, import_date_fns3.format)(date, "MM/dd/yyyy");
847
+ } catch {
848
+ return "";
849
+ }
850
+ };
851
+ const getDisplayValue = (0, import_react6.useCallback)(() => {
852
+ if (selectsRange) {
853
+ if (startDate && endDate) {
854
+ return `${formatDateForDisplay(startDate)} - ${formatDateForDisplay(endDate)}`;
855
+ } else if (startDate) {
856
+ return formatDateForDisplay(startDate);
857
+ }
858
+ return "";
859
+ } else {
860
+ return formatDateForDisplay(selectedDate);
861
+ }
862
+ }, [selectsRange, startDate, endDate, selectedDate]);
863
+ (0, import_react6.useEffect)(() => {
864
+ setInputValue(getDisplayValue());
865
+ }, [getDisplayValue]);
866
+ const handleInputChange = (text) => {
867
+ setInputValue(text);
868
+ };
869
+ const handleDateChange = (date) => {
870
+ if (!selectsRange) {
871
+ onChange?.(date);
872
+ setOpen(false);
873
+ } else {
874
+ const range = date;
875
+ onChange?.(range);
876
+ if (range[0] && range[1]) {
877
+ setOpen(false);
878
+ }
879
+ }
880
+ };
881
+ (0, import_react6.useEffect)(() => {
882
+ if (import_xui_core2.isNative) return;
883
+ const handleClickOutside = (event) => {
884
+ if (containerRef.current && !containerRef.current.contains(event.target)) {
885
+ setOpen(false);
886
+ }
887
+ };
888
+ document.addEventListener("mousedown", handleClickOutside);
889
+ return () => document.removeEventListener("mousedown", handleClickOutside);
890
+ }, []);
891
+ const renderCalendar = () => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
892
+ Calendar,
893
+ {
894
+ locale,
895
+ startDate,
896
+ endDate,
897
+ selectedDate,
898
+ onChange: handleDateChange,
899
+ selectsRange,
900
+ ...rest
901
+ }
902
+ );
903
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Box, { ref: containerRef, position: "relative", width: "100%", children: [
904
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
905
+ import_xui_input.Input,
906
+ {
907
+ ...rest,
908
+ size,
909
+ placeholder: placeholder || (selectsRange ? "MM/DD/YYYY - MM/DD/YYYY" : "MM/DD/YYYY"),
910
+ value: inputValue,
911
+ onChangeText: handleInputChange,
912
+ onFocus: () => setOpen(true),
913
+ backgroundColor,
914
+ testID
915
+ }
916
+ ),
917
+ open && (import_xui_core2.isWeb ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
918
+ Box,
919
+ {
920
+ position: "absolute",
921
+ top: "100%",
922
+ left: 0,
923
+ marginTop: 4,
924
+ zIndex: 1e3,
925
+ children: renderCalendar()
926
+ }
927
+ ) : (
928
+ // Native implementation could use a Modal here
929
+ // For now, we just show it below the input if needed,
930
+ // but usually a bottom sheet or centered modal is better.
931
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Box, { marginTop: 4, children: renderCalendar() })
932
+ ))
933
+ ] });
934
+ }
935
+ );
936
+ DatePicker.displayName = "DatePicker";
937
+ // Annotate the CommonJS export names for ESM import in node:
938
+ 0 && (module.exports = {
939
+ Calendar,
940
+ DatePicker,
941
+ formatDate,
942
+ getMonthInLocale
943
+ });
944
+ //# sourceMappingURL=index.js.map