@antscorp/antsomi-ui 1.3.3-beta.46 → 1.3.3-beta.47
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/es/components/common/ConfigProvider/GlobalStyle.js +167 -28
- package/es/components/molecules/DatePicker/components/AdvancedPicker/AdvancedPicker.d.ts +2 -2
- package/es/components/molecules/DatePicker/components/AdvancedPicker/AdvancedPicker.js +229 -80
- package/es/components/molecules/DatePicker/components/AdvancedPicker/constants.d.ts +35 -20
- package/es/components/molecules/DatePicker/components/AdvancedPicker/constants.js +66 -0
- package/es/components/molecules/DatePicker/components/AdvancedPicker/styled.js +48 -4
- package/es/components/molecules/DatePicker/components/AdvancedPicker/types.d.ts +22 -0
- package/es/components/molecules/DatePicker/components/AdvancedPicker/utils.d.ts +20 -0
- package/es/components/molecules/DatePicker/components/AdvancedPicker/utils.js +90 -1
- package/package.json +1 -1
|
@@ -11,7 +11,7 @@ import { fab } from '@fortawesome/free-brands-svg-icons';
|
|
|
11
11
|
library.add(fas, far, fab);
|
|
12
12
|
const { accent6, accent7, scrollBarSize } = THEME.token || {};
|
|
13
13
|
export const GlobalStyle = () => {
|
|
14
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33;
|
|
14
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35;
|
|
15
15
|
return (React.createElement(Global, { styles: css `
|
|
16
16
|
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@100;300;400;500;700;900&display=swap');
|
|
17
17
|
|
|
@@ -281,13 +281,143 @@ export const GlobalStyle = () => {
|
|
|
281
281
|
flex-direction: column-reverse;
|
|
282
282
|
padding-bottom: 60px;
|
|
283
283
|
|
|
284
|
-
.antsomi-picker-date-panel
|
|
284
|
+
.antsomi-picker-date-panel,
|
|
285
|
+
.antsomi-picker-quarter-panel {
|
|
285
286
|
width: 280px !important;
|
|
286
287
|
|
|
287
288
|
.antsomi-picker-cell {
|
|
288
289
|
pointer-events: none !important;
|
|
289
290
|
}
|
|
290
291
|
}
|
|
292
|
+
|
|
293
|
+
.antsomi-picker-date-panel {
|
|
294
|
+
position: relative;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
.antsomi-picker-date-panel::before {
|
|
298
|
+
content: 'Hours';
|
|
299
|
+
position: absolute;
|
|
300
|
+
top: 0;
|
|
301
|
+
right: 0;
|
|
302
|
+
transform: translateX(100%);
|
|
303
|
+
width: 61px;
|
|
304
|
+
/* width: 53.5px; */
|
|
305
|
+
font-weight: bold;
|
|
306
|
+
border-right: 1px solid rgba(5, 5, 5, 0.06);
|
|
307
|
+
height: 38px;
|
|
308
|
+
display: flex;
|
|
309
|
+
align-items: center;
|
|
310
|
+
justify-content: center;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
.antsomi-picker-time-panel {
|
|
314
|
+
.antsomi-picker-time-panel-cell-selected {
|
|
315
|
+
background-color: ${(_8 = THEME.token) === null || _8 === void 0 ? void 0 : _8.colorPrimary};
|
|
316
|
+
color: #fff;
|
|
317
|
+
}
|
|
318
|
+
.antsomi-picker-time-panel-cell-selected:hover {
|
|
319
|
+
background-color: ${(_9 = THEME.token) === null || _9 === void 0 ? void 0 : _9.colorPrimary};
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
.antsomi-picker-cell-inner {
|
|
323
|
+
text-align: center;
|
|
324
|
+
cursor: pointer;
|
|
325
|
+
}
|
|
326
|
+
.antsomi-picker-cell-inner:hover {
|
|
327
|
+
background: rgba(34, 34, 34, 0.04);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
.antsomi-picker-header {
|
|
331
|
+
display: none;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
.antsomi-picker-content {
|
|
335
|
+
position: relative;
|
|
336
|
+
|
|
337
|
+
.antsomi-picker-time-panel-column {
|
|
338
|
+
margin-top: 38px;
|
|
339
|
+
width: 60px;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
.antsomi-picker-content::after,
|
|
344
|
+
.antsomi-picker-content::before {
|
|
345
|
+
content: 'Minutes';
|
|
346
|
+
position: absolute;
|
|
347
|
+
top: 0;
|
|
348
|
+
left: 61px;
|
|
349
|
+
/* left: 53.5px; */
|
|
350
|
+
width: 60px;
|
|
351
|
+
/* width: 52.5px; */
|
|
352
|
+
height: 38px;
|
|
353
|
+
display: flex;
|
|
354
|
+
align-items: center;
|
|
355
|
+
justify-content: center;
|
|
356
|
+
font-weight: bold;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
.antsomi-picker-content::before {
|
|
360
|
+
border-right: 1px solid rgba(5, 5, 5, 0.06);
|
|
361
|
+
}
|
|
362
|
+
.antsomi-picker-content::after {
|
|
363
|
+
content: 'Seconds';
|
|
364
|
+
left: 120px;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/* Custom css scrollbar */
|
|
369
|
+
ul {
|
|
370
|
+
padding-left: 8px;
|
|
371
|
+
scrollbar-gutter: stable;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
&.hide-picker-header {
|
|
376
|
+
.antsomi-picker-month-panel,
|
|
377
|
+
.antsomi-picker-quarter-panel {
|
|
378
|
+
.antsomi-picker-header {
|
|
379
|
+
display: none;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
&.only-show-time-picker {
|
|
385
|
+
.antsomi-picker-date-panel {
|
|
386
|
+
display: none;
|
|
387
|
+
}
|
|
388
|
+
.antsomi-picker-time-panel {
|
|
389
|
+
border: none;
|
|
390
|
+
}
|
|
391
|
+
> .antsomi-picker-panel-container > .antsomi-picker-panel-layout > .antsomi-picker-panel {
|
|
392
|
+
width: 250px;
|
|
393
|
+
.antsomi-picker-datetime-panel {
|
|
394
|
+
justify-content: center;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
ul {
|
|
398
|
+
::-webkit-scrollbar {
|
|
399
|
+
width: 0;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
.antsomi-picker-content::after {
|
|
404
|
+
display: none;
|
|
405
|
+
}
|
|
406
|
+
.antsomi-picker-content::before {
|
|
407
|
+
content: 'Hours';
|
|
408
|
+
border: none;
|
|
409
|
+
left: 0;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
&.is-minutes-picker {
|
|
413
|
+
> .antsomi-picker-panel-container
|
|
414
|
+
> .antsomi-picker-panel-layout
|
|
415
|
+
> .antsomi-picker-panel {
|
|
416
|
+
.antsomi-picker-content::before {
|
|
417
|
+
content: 'Minutes';
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}
|
|
291
421
|
}
|
|
292
422
|
|
|
293
423
|
&.--error
|
|
@@ -301,6 +431,15 @@ export const GlobalStyle = () => {
|
|
|
301
431
|
.antsomi-picker-footer-extra {
|
|
302
432
|
padding: 0 !important;
|
|
303
433
|
}
|
|
434
|
+
|
|
435
|
+
/*
|
|
436
|
+
* NOTE: UI broken when add showTime props to <DatePicker />
|
|
437
|
+
* Unexpected header control (comment code below to see bug)
|
|
438
|
+
* Temporary solution: hide the verbose element
|
|
439
|
+
*/
|
|
440
|
+
.antsomi-picker-ranges {
|
|
441
|
+
display: none;
|
|
442
|
+
}
|
|
304
443
|
}
|
|
305
444
|
}
|
|
306
445
|
|
|
@@ -328,14 +467,14 @@ export const GlobalStyle = () => {
|
|
|
328
467
|
.antsomi-slider-rail {
|
|
329
468
|
border-radius: 2px !important;
|
|
330
469
|
transition: background-color 0.3s !important;
|
|
331
|
-
background-color: ${(
|
|
470
|
+
background-color: ${(_10 = THEME.token) === null || _10 === void 0 ? void 0 : _10.accent1} !important;
|
|
332
471
|
}
|
|
333
472
|
|
|
334
473
|
.antsomi-slider-track {
|
|
335
474
|
position: absolute !important;
|
|
336
475
|
border-radius: 2px !important;
|
|
337
476
|
transition: background-color 0.3s !important;
|
|
338
|
-
background-color: ${(
|
|
477
|
+
background-color: ${(_11 = THEME.token) === null || _11 === void 0 ? void 0 : _11.colorPrimary} !important;
|
|
339
478
|
}
|
|
340
479
|
|
|
341
480
|
.antsomi-slider-step {
|
|
@@ -369,16 +508,16 @@ export const GlobalStyle = () => {
|
|
|
369
508
|
}
|
|
370
509
|
|
|
371
510
|
.antsomi-slider-handle::after {
|
|
372
|
-
background-color: ${(
|
|
511
|
+
background-color: ${(_12 = THEME.token) === null || _12 === void 0 ? void 0 : _12.colorPrimary} !important;
|
|
373
512
|
}
|
|
374
513
|
|
|
375
514
|
&:hover {
|
|
376
515
|
.antsomi-slider-track {
|
|
377
|
-
background-color: ${(
|
|
516
|
+
background-color: ${(_13 = THEME.token) === null || _13 === void 0 ? void 0 : _13.colorPrimary} !important;
|
|
378
517
|
}
|
|
379
518
|
|
|
380
519
|
.antsomi-slider-rail {
|
|
381
|
-
background-color: ${(
|
|
520
|
+
background-color: ${(_14 = THEME.token) === null || _14 === void 0 ? void 0 : _14.accent1} !important;
|
|
382
521
|
}
|
|
383
522
|
|
|
384
523
|
.antsomi-slider-handle::after {
|
|
@@ -386,7 +525,7 @@ export const GlobalStyle = () => {
|
|
|
386
525
|
}
|
|
387
526
|
|
|
388
527
|
.antsomi-slider-handle {
|
|
389
|
-
border-color: ${(
|
|
528
|
+
border-color: ${(_15 = THEME.token) === null || _15 === void 0 ? void 0 : _15.colorPrimary} !important;
|
|
390
529
|
}
|
|
391
530
|
}
|
|
392
531
|
|
|
@@ -396,8 +535,8 @@ export const GlobalStyle = () => {
|
|
|
396
535
|
|
|
397
536
|
&.antsomi-slider-disabled {
|
|
398
537
|
.antsomi-slider-handle {
|
|
399
|
-
background-color: ${(
|
|
400
|
-
border-color: ${(
|
|
538
|
+
background-color: ${(_16 = THEME.token) === null || _16 === void 0 ? void 0 : _16.accent2} !important;
|
|
539
|
+
border-color: ${(_17 = THEME.token) === null || _17 === void 0 ? void 0 : _17.accent2} !important;
|
|
401
540
|
}
|
|
402
541
|
}
|
|
403
542
|
}
|
|
@@ -411,8 +550,8 @@ export const GlobalStyle = () => {
|
|
|
411
550
|
padding-left: 20px;
|
|
412
551
|
padding-right: 20px;
|
|
413
552
|
font-family: 'Roboto';
|
|
414
|
-
color: ${(
|
|
415
|
-
font-size: ${(
|
|
553
|
+
color: ${(_18 = THEME.token) === null || _18 === void 0 ? void 0 : _18.colorTextBase};
|
|
554
|
+
font-size: ${(_19 = THEME.token) === null || _19 === void 0 ? void 0 : _19.fontSize}px;
|
|
416
555
|
|
|
417
556
|
&:focus-within {
|
|
418
557
|
--tw-shadow: 0 0 #0000;
|
|
@@ -422,31 +561,31 @@ export const GlobalStyle = () => {
|
|
|
422
561
|
}
|
|
423
562
|
|
|
424
563
|
&:first-child {
|
|
425
|
-
border-top-left-radius: ${(
|
|
426
|
-
border-bottom-left-radius: ${(
|
|
564
|
+
border-top-left-radius: ${(_20 = THEME.token) === null || _20 === void 0 ? void 0 : _20.borderRadius}px;
|
|
565
|
+
border-bottom-left-radius: ${(_21 = THEME.token) === null || _21 === void 0 ? void 0 : _21.borderRadius}px;
|
|
427
566
|
}
|
|
428
567
|
|
|
429
568
|
&:last-child {
|
|
430
|
-
border-top-right-radius: ${(
|
|
431
|
-
border-bottom-right-radius: ${(
|
|
569
|
+
border-top-right-radius: ${(_22 = THEME.token) === null || _22 === void 0 ? void 0 : _22.borderRadius}px;
|
|
570
|
+
border-bottom-right-radius: ${(_23 = THEME.token) === null || _23 === void 0 ? void 0 : _23.borderRadius}px;
|
|
432
571
|
}
|
|
433
572
|
|
|
434
573
|
&.antsomi-radio-button-wrapper-checked {
|
|
435
|
-
border-color: ${(
|
|
436
|
-
background-color: ${(
|
|
437
|
-
color: ${(
|
|
574
|
+
border-color: ${(_24 = THEME.token) === null || _24 === void 0 ? void 0 : _24.accent1};
|
|
575
|
+
background-color: ${(_25 = THEME.token) === null || _25 === void 0 ? void 0 : _25.colorTextActive};
|
|
576
|
+
color: ${(_26 = THEME.token) === null || _26 === void 0 ? void 0 : _26.colorPrimary};
|
|
438
577
|
font-weight: 700;
|
|
439
578
|
|
|
440
579
|
&::before {
|
|
441
|
-
background-color: ${(
|
|
580
|
+
background-color: ${(_27 = THEME.token) === null || _27 === void 0 ? void 0 : _27.accent1};
|
|
442
581
|
}
|
|
443
582
|
}
|
|
444
583
|
}
|
|
445
584
|
|
|
446
585
|
.antsomi-radio-wrapper {
|
|
447
586
|
font-family: 'Roboto';
|
|
448
|
-
color: ${(
|
|
449
|
-
font-size: ${(
|
|
587
|
+
color: ${(_28 = THEME.token) === null || _28 === void 0 ? void 0 : _28.colorTextBase};
|
|
588
|
+
font-size: ${(_29 = THEME.token) === null || _29 === void 0 ? void 0 : _29.fontSize}px;
|
|
450
589
|
margin-right: 0;
|
|
451
590
|
|
|
452
591
|
.antsomi-radio-disabled {
|
|
@@ -477,12 +616,12 @@ export const GlobalStyle = () => {
|
|
|
477
616
|
.antsomi-radio-inner {
|
|
478
617
|
width: 16px;
|
|
479
618
|
height: 16px;
|
|
480
|
-
border-color: ${(
|
|
619
|
+
border-color: ${(_30 = THEME.token) === null || _30 === void 0 ? void 0 : _30.colorPrimary};
|
|
481
620
|
border-width: 2px;
|
|
482
|
-
background-color: ${(
|
|
621
|
+
background-color: ${(_31 = THEME.token) === null || _31 === void 0 ? void 0 : _31.bw0};
|
|
483
622
|
|
|
484
623
|
&::after {
|
|
485
|
-
background-color: ${(
|
|
624
|
+
background-color: ${(_32 = THEME.token) === null || _32 === void 0 ? void 0 : _32.colorPrimary};
|
|
486
625
|
}
|
|
487
626
|
}
|
|
488
627
|
}
|
|
@@ -540,7 +679,7 @@ export const GlobalStyle = () => {
|
|
|
540
679
|
|
|
541
680
|
.antsomi-collapse {
|
|
542
681
|
&.antsomi-collapse-borderless {
|
|
543
|
-
border-bottom: 1px solid ${(
|
|
682
|
+
border-bottom: 1px solid ${(_33 = THEME.token) === null || _33 === void 0 ? void 0 : _33.gray5};
|
|
544
683
|
}
|
|
545
684
|
|
|
546
685
|
> .antsomi-collapse-item > .antsomi-collapse-header .antsomi-collapse-arrow {
|
|
@@ -550,12 +689,12 @@ export const GlobalStyle = () => {
|
|
|
550
689
|
|
|
551
690
|
/* Switch */
|
|
552
691
|
.antsomi-switch {
|
|
553
|
-
border: 2px solid ${(
|
|
692
|
+
border: 2px solid ${(_34 = THEME.token) === null || _34 === void 0 ? void 0 : _34.colorPrimary} !important;
|
|
554
693
|
|
|
555
694
|
&.antsomi-switch-checked {
|
|
556
695
|
> .antsomi-switch-handle {
|
|
557
696
|
&::before {
|
|
558
|
-
background-color: ${(
|
|
697
|
+
background-color: ${(_35 = THEME.token) === null || _35 === void 0 ? void 0 : _35.bw0} !important;
|
|
559
698
|
}
|
|
560
699
|
}
|
|
561
700
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { TAdvancedType, TCalculationType, TOperatorKey, TOption, TShowCalculationTypeCondition } from './types';
|
|
2
|
+
import { TAdvancedType, TCalculationType, TOperatorKey, TOption, TShowCalculationTypeCondition, ValueTypes } from './types';
|
|
3
3
|
export interface AdvancedPickerProps {
|
|
4
4
|
label?: string;
|
|
5
5
|
disabled?: boolean;
|
|
@@ -7,7 +7,7 @@ export interface AdvancedPickerProps {
|
|
|
7
7
|
showCalculationTypeCondition?: TShowCalculationTypeCondition;
|
|
8
8
|
calculationTypeKeysShow?: TCalculationType[];
|
|
9
9
|
defaultDateTypeKey?: string;
|
|
10
|
-
valueType?:
|
|
10
|
+
valueType?: ValueTypes;
|
|
11
11
|
option?: TOption;
|
|
12
12
|
operatorKey?: TOperatorKey;
|
|
13
13
|
type?: TAdvancedType;
|
|
@@ -15,11 +15,11 @@ import { Input, InputNumber, Divider, Space, Button, Typography, } from '@antsco
|
|
|
15
15
|
import { Select, Dropdown, DatePicker } from '@antscorp/antsomi-ui/es/components';
|
|
16
16
|
// Utils
|
|
17
17
|
import { handleError, reorder } from '@antscorp/antsomi-ui/es/utils';
|
|
18
|
-
import { calculationDateAdvanced } from './utils';
|
|
18
|
+
import { calculationDateAdvanced, getCellRender, getLabelQuarterRange, getPickerRender, getTimePickerRender, } from './utils';
|
|
19
19
|
// Styled
|
|
20
20
|
import { DatePickerCustomInput, DatePickerHeader, DropdownContent, DropdownHeader, DatePickerFooter, DropdownFooter, CalendarIconWrapper, } from './styled';
|
|
21
21
|
// Constants
|
|
22
|
-
import { CALCULATION_DATES, CALCULATION_TYPES, DATE_TYPES, DEFAULT_DATE_FORMAT, VALUE_TYPES,
|
|
22
|
+
import { CALCULATION_DATES, CALCULATION_TYPES, DATE_TYPES, DEFAULT_DATE_FORMAT, VALUE_TYPES, ADVANCED_PICKER_TYPE, WEEK_ARR, QUARTER_PLACEHOLDER, WEEK_PLACEHOLDER, DAY_LABEL_SHORT, HIDE_TIME_LABEL_ARR, MONTH_LABEL_FULL, DAY_OF_MONTH, ANCHOR_LEAP_YEAR, } from './constants';
|
|
23
23
|
import { THEME } from '../../../../../constants';
|
|
24
24
|
// Instance
|
|
25
25
|
import i18nInstance from '@antscorp/antsomi-ui/es/locales/i18n';
|
|
@@ -62,24 +62,6 @@ export const AdvancedPicker = props => {
|
|
|
62
62
|
return CALCULATION_DATES;
|
|
63
63
|
}
|
|
64
64
|
}, [valueType]);
|
|
65
|
-
const pickerType = useMemo(() => {
|
|
66
|
-
switch (valueType) {
|
|
67
|
-
case VALUE_TYPES.YEAR_MONTH_DAY:
|
|
68
|
-
return TIME_PICKER_TYPE.DATE;
|
|
69
|
-
case VALUE_TYPES.YEAR_MONTH_DAY_HOUR:
|
|
70
|
-
return TIME_PICKER_TYPE.DATE_HOUR;
|
|
71
|
-
case VALUE_TYPES.YEAR_MONTH_DAY_MINUTE:
|
|
72
|
-
return TIME_PICKER_TYPE.DATE_HOUR_MINUTE;
|
|
73
|
-
case VALUE_TYPES.YEAR_MONTH_DAY_SECOND:
|
|
74
|
-
return TIME_PICKER_TYPE.DATE_TIME;
|
|
75
|
-
case VALUE_TYPES.YEAR:
|
|
76
|
-
return YEAR_PICKER_TYPE.YEAR;
|
|
77
|
-
case VALUE_TYPES.YEAR_MONTH:
|
|
78
|
-
return YEAR_PICKER_TYPE.MONTH;
|
|
79
|
-
default:
|
|
80
|
-
return TIME_PICKER_TYPE.DATE;
|
|
81
|
-
}
|
|
82
|
-
}, [valueType]);
|
|
83
65
|
const [formatDisplay, timeFormatDisplay] = useMemo(() => {
|
|
84
66
|
let formatDisplay = '';
|
|
85
67
|
let timeFormatDisplay = '';
|
|
@@ -91,24 +73,56 @@ export const AdvancedPicker = props => {
|
|
|
91
73
|
else {
|
|
92
74
|
isStartDate = operatorKey === 'after';
|
|
93
75
|
}
|
|
94
|
-
switch (
|
|
95
|
-
case
|
|
96
|
-
formatDisplay = '
|
|
97
|
-
|
|
76
|
+
switch (valueType) {
|
|
77
|
+
case 'YEAR':
|
|
78
|
+
formatDisplay = 'YYYY';
|
|
79
|
+
break;
|
|
80
|
+
case 'YEAR_QUARTER':
|
|
81
|
+
formatDisplay = `${QUARTER_PLACEHOLDER}Q, YYYY`;
|
|
82
|
+
break;
|
|
83
|
+
case 'YEAR_MONTH':
|
|
84
|
+
formatDisplay = 'MM/YYYY';
|
|
85
|
+
break;
|
|
86
|
+
case 'YEAR_WEEK':
|
|
87
|
+
formatDisplay = `${WEEK_PLACEHOLDER}W, YYYY`;
|
|
98
88
|
break;
|
|
99
|
-
case
|
|
89
|
+
case 'YEAR_MONTH_DAY_HOUR':
|
|
100
90
|
formatDisplay = `DD/MM/YYYY - ${isStartDate ? 'HH:00:00' : 'HH:59:59'}`;
|
|
101
|
-
timeFormatDisplay =
|
|
91
|
+
timeFormatDisplay = 'HH';
|
|
92
|
+
// timeFormatDisplay = isStartDate ? 'HH:00:00' : 'HH:59:59';
|
|
102
93
|
break;
|
|
103
|
-
case
|
|
94
|
+
case 'YEAR_MONTH_DAY_MINUTE':
|
|
104
95
|
formatDisplay = `DD/MM/YYYY - ${isStartDate ? 'HH:mm:00' : 'HH:mm:59'}`;
|
|
105
|
-
timeFormatDisplay = isStartDate ? 'HH:mm:00' : 'HH:mm:59';
|
|
96
|
+
// timeFormatDisplay = isStartDate ? 'HH:mm:00' : 'HH:mm:59';
|
|
97
|
+
timeFormatDisplay = 'HH:mm';
|
|
106
98
|
break;
|
|
107
|
-
case
|
|
108
|
-
formatDisplay = 'MM/YYYY';
|
|
99
|
+
case 'YEAR_MONTH_DAY_SECOND':
|
|
100
|
+
formatDisplay = 'DD/MM/YYYY - HH:mm:ss';
|
|
101
|
+
timeFormatDisplay = 'HH:mm:ss';
|
|
109
102
|
break;
|
|
110
|
-
case
|
|
111
|
-
formatDisplay =
|
|
103
|
+
case 'QUARTER':
|
|
104
|
+
formatDisplay = `${QUARTER_PLACEHOLDER}Q`;
|
|
105
|
+
break;
|
|
106
|
+
case 'MONTH':
|
|
107
|
+
formatDisplay = 'MMMM';
|
|
108
|
+
break;
|
|
109
|
+
case 'WEEK':
|
|
110
|
+
formatDisplay = `${WEEK_PLACEHOLDER}W`;
|
|
111
|
+
break;
|
|
112
|
+
case 'MONTH_DAY':
|
|
113
|
+
formatDisplay = 'MMMM DD';
|
|
114
|
+
break;
|
|
115
|
+
case 'DAY_OF_WEEK':
|
|
116
|
+
formatDisplay = 'dddd';
|
|
117
|
+
break;
|
|
118
|
+
case 'DAY':
|
|
119
|
+
formatDisplay = 'DD';
|
|
120
|
+
break;
|
|
121
|
+
case 'HOUR':
|
|
122
|
+
formatDisplay = 'HH';
|
|
123
|
+
break;
|
|
124
|
+
case 'MINUTE':
|
|
125
|
+
formatDisplay = 'mm';
|
|
112
126
|
break;
|
|
113
127
|
default:
|
|
114
128
|
formatDisplay = `DD/MM/YYYY - ${isStartDate ? '00:00:00' : '23:59:59'}`;
|
|
@@ -119,7 +133,7 @@ export const AdvancedPicker = props => {
|
|
|
119
133
|
formatDisplay = formatInputDisplay;
|
|
120
134
|
}
|
|
121
135
|
return [formatDisplay, timeFormatDisplay];
|
|
122
|
-
}, [
|
|
136
|
+
}, [valueType, operatorKey, type, formatInputDisplay]);
|
|
123
137
|
// State
|
|
124
138
|
const [state, setState] = useState({
|
|
125
139
|
isOpen: false,
|
|
@@ -139,6 +153,7 @@ export const AdvancedPicker = props => {
|
|
|
139
153
|
dateDisplay: dayjs().format(DEFAULT_DATE_FORMAT),
|
|
140
154
|
});
|
|
141
155
|
const { isOpen, option, date, dateDisplay } = state;
|
|
156
|
+
const [currMonthSelected, setCurrMonthSelected] = useState(dayjs(date, format).month());
|
|
142
157
|
const newCalculationTypes = useMemo(() => {
|
|
143
158
|
var _a;
|
|
144
159
|
if (calculationTypeKeysShow && calculationTypeKeysShow.length) {
|
|
@@ -159,7 +174,6 @@ export const AdvancedPicker = props => {
|
|
|
159
174
|
}, [calculationTypeKeysShow, showCalculationTypeCondition, option.dateType]);
|
|
160
175
|
// Hooks
|
|
161
176
|
const { token } = useToken();
|
|
162
|
-
// const { t } = useTranslation();
|
|
163
177
|
const { t } = i18nInstance;
|
|
164
178
|
// Variables
|
|
165
179
|
const contentStyle = {
|
|
@@ -244,23 +258,63 @@ export const AdvancedPicker = props => {
|
|
|
244
258
|
const disableDate = current => current > dayjs(disableAfterDate, format) || current < dayjs(disableBeforeDate, format);
|
|
245
259
|
const renderLabel = (date, locale = 'en') => {
|
|
246
260
|
let formatLabel = 'dddd, MMMM D, YYYY';
|
|
261
|
+
let subLabel = '';
|
|
247
262
|
switch (valueType) {
|
|
248
|
-
case
|
|
263
|
+
case 'YEAR':
|
|
249
264
|
formatLabel = 'YYYY';
|
|
250
265
|
break;
|
|
251
|
-
case
|
|
266
|
+
case 'YEAR_QUARTER':
|
|
267
|
+
formatLabel = `${QUARTER_PLACEHOLDER}Q, YYYY`;
|
|
268
|
+
subLabel = getLabelQuarterRange(date, format || DEFAULT_DATE_FORMAT, locale);
|
|
269
|
+
break;
|
|
270
|
+
case 'YEAR_MONTH':
|
|
252
271
|
formatLabel = 'MMMM, YYYY';
|
|
253
272
|
break;
|
|
273
|
+
case 'YEAR_WEEK': {
|
|
274
|
+
const dayObj = dayjs(date || new Date(), format).locale(locale || 'en');
|
|
275
|
+
formatLabel = `${WEEK_PLACEHOLDER}W, YYYY`;
|
|
276
|
+
subLabel = `${dayjs(dayObj).day(0).format('MMMM DD, YYYY')} - ${dayjs(dayObj)
|
|
277
|
+
.day(6)
|
|
278
|
+
.format('MMMM DD, YYYY')}`;
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
case 'QUARTER':
|
|
282
|
+
formatLabel = `${QUARTER_PLACEHOLDER}Q`;
|
|
283
|
+
break;
|
|
284
|
+
case 'MONTH':
|
|
285
|
+
formatLabel = 'MMMM';
|
|
286
|
+
break;
|
|
287
|
+
case 'WEEK':
|
|
288
|
+
formatLabel = `${WEEK_PLACEHOLDER}W`;
|
|
289
|
+
break;
|
|
290
|
+
case 'MONTH_DAY':
|
|
291
|
+
formatLabel = 'MMMM DD';
|
|
292
|
+
break;
|
|
293
|
+
case 'DAY_OF_WEEK':
|
|
294
|
+
formatLabel = 'dddd';
|
|
295
|
+
break;
|
|
296
|
+
case 'DAY':
|
|
297
|
+
formatLabel = 'DD';
|
|
298
|
+
break;
|
|
299
|
+
case 'HOUR':
|
|
300
|
+
formatLabel = 'HH';
|
|
301
|
+
break;
|
|
302
|
+
case 'MINUTE':
|
|
303
|
+
formatLabel = 'mm';
|
|
304
|
+
break;
|
|
254
305
|
default:
|
|
255
306
|
break;
|
|
256
307
|
}
|
|
257
308
|
return (React.createElement(React.Fragment, null,
|
|
258
|
-
React.createElement("div",
|
|
309
|
+
React.createElement("div", { style: { fontWeight: 'bold' } }, dayjs(date || new Date(), format)
|
|
259
310
|
.locale(locale || 'en')
|
|
260
|
-
.format(formatLabel)
|
|
261
|
-
|
|
311
|
+
.format(formatLabel)
|
|
312
|
+
.replace(QUARTER_PLACEHOLDER, 'Quarter ')
|
|
313
|
+
.replace(WEEK_PLACEHOLDER, 'Week ')),
|
|
314
|
+
subLabel ? React.createElement("div", null, subLabel) : null,
|
|
315
|
+
!HIDE_TIME_LABEL_ARR.includes(valueType || '') && showTime && !subLabel ? (React.createElement("div", { style: { fontWeight: 'bold' } }, dayjs(date || new Date(), format)
|
|
262
316
|
.locale(locale || 'en')
|
|
263
|
-
.format(timeFormatDisplay)))));
|
|
317
|
+
.format(timeFormatDisplay))) : null));
|
|
264
318
|
};
|
|
265
319
|
const toggleOpenDropdown = (isOpen) => {
|
|
266
320
|
try {
|
|
@@ -286,18 +340,6 @@ export const AdvancedPicker = props => {
|
|
|
286
340
|
});
|
|
287
341
|
}
|
|
288
342
|
};
|
|
289
|
-
const onChangeDatePicker = (value) => {
|
|
290
|
-
try {
|
|
291
|
-
setState(state => (Object.assign(Object.assign({}, state), { date: dayjs(value).format(format) })));
|
|
292
|
-
}
|
|
293
|
-
catch (error) {
|
|
294
|
-
handleError(error, {
|
|
295
|
-
path: PATH,
|
|
296
|
-
name: 'onChangeDatePicker',
|
|
297
|
-
args: { value },
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
};
|
|
301
343
|
const onClickApply = () => {
|
|
302
344
|
try {
|
|
303
345
|
const draftOption = {
|
|
@@ -365,30 +407,136 @@ export const AdvancedPicker = props => {
|
|
|
365
407
|
React.createElement(Icon, { type: "icon-ants-remove-circle", style: { color: (_a = THEME.token) === null || _a === void 0 ? void 0 : _a.colorError } }),
|
|
366
408
|
React.createElement(Text, { type: "danger" }, errorMessage))) : null;
|
|
367
409
|
};
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
410
|
+
// NOTE: valueType: 'WEEK'; 'DAY_OF_WEEK'; 'MONTH_DAY'; 'DAY'
|
|
411
|
+
const customPickerArr = useMemo(() => ({
|
|
412
|
+
WEEK: WEEK_ARR,
|
|
413
|
+
DAY_OF_WEEK: DAY_LABEL_SHORT,
|
|
414
|
+
MONTH_DAY: DAY_OF_MONTH[currMonthSelected],
|
|
415
|
+
DAY: DAY_OF_MONTH[0],
|
|
416
|
+
}), [currMonthSelected]);
|
|
417
|
+
const dropdownRender = () => {
|
|
418
|
+
// const customPickerArr = valueType === 'WEEK' ? WEEK_ARR : DAY_LABEL_SHORT;
|
|
419
|
+
const currWeek = dayjs(date, format).isoWeek();
|
|
420
|
+
const currDay = dayjs(date, format).day();
|
|
421
|
+
const currDayOfMonth = dayjs(date, format).date();
|
|
422
|
+
const currMonth = dayjs(date, format).month();
|
|
423
|
+
const getCellSelected = (item, index) => {
|
|
424
|
+
switch (valueType) {
|
|
425
|
+
case 'WEEK':
|
|
426
|
+
return currWeek === item;
|
|
427
|
+
case 'DAY_OF_WEEK':
|
|
428
|
+
return index === currDay;
|
|
429
|
+
case 'MONTH_DAY':
|
|
430
|
+
return item === currDayOfMonth && currMonth === currMonthSelected;
|
|
431
|
+
case 'DAY':
|
|
432
|
+
return item === currDayOfMonth;
|
|
433
|
+
default:
|
|
434
|
+
return false;
|
|
435
|
+
}
|
|
436
|
+
};
|
|
437
|
+
const getNewDate = (item, index) => {
|
|
438
|
+
switch (valueType) {
|
|
439
|
+
case 'WEEK':
|
|
440
|
+
return dayjs(date).isoWeek(item);
|
|
441
|
+
case 'DAY_OF_WEEK':
|
|
442
|
+
return dayjs(date).day(index);
|
|
443
|
+
case 'MONTH_DAY':
|
|
444
|
+
return dayjs(date).year(ANCHOR_LEAP_YEAR).month(currMonthSelected).date(item);
|
|
445
|
+
case 'DAY':
|
|
446
|
+
return dayjs(date).year(ANCHOR_LEAP_YEAR).month(0).date(item);
|
|
447
|
+
default:
|
|
448
|
+
return dayjs(date);
|
|
449
|
+
}
|
|
450
|
+
};
|
|
451
|
+
return (React.createElement("div", { style: contentStyle },
|
|
452
|
+
React.createElement(DropdownHeader, { className: "dropdown-header" }, renderDropdownLabel()),
|
|
453
|
+
React.createElement(DropdownContent, { className: "dropdown-content" },
|
|
454
|
+
renderDateTypeOptions(),
|
|
455
|
+
option.dateType.value === 'fixed' ? (React.createElement(React.Fragment, null,
|
|
456
|
+
valueType === 'MONTH_DAY' ? (React.createElement("div", { className: "month-controller" },
|
|
457
|
+
React.createElement(Icon, { type: "icon-ants-angle-left", style: { fontSize: '14px', color: '#D2D2D2' }, onClick: () => setCurrMonthSelected(prev => (prev === 0 ? 11 : prev - 1)) }),
|
|
458
|
+
MONTH_LABEL_FULL[currMonthSelected],
|
|
459
|
+
React.createElement(Icon, { type: "icon-ants-angle-right", style: { fontSize: '14px', color: '#D2D2D2' }, onClick: () => setCurrMonthSelected(prev => (prev === 11 ? 0 : prev + 1)) }))) : null,
|
|
460
|
+
React.createElement("div", { className: `custom-picker-content${['MONTH_DAY', 'DAY'].includes(valueType || '') ? ' day-of-month-container' : ''}` }, customPickerArr[valueType || ''].map((item, index) => (React.createElement("div", { key: `day_${item}`, className: clsx('custom-picker-item', {
|
|
461
|
+
'custom-picker-item-selected': getCellSelected(item, index),
|
|
462
|
+
}), onClick: () => {
|
|
463
|
+
const newDate = getNewDate(item, index);
|
|
464
|
+
setState(state => (Object.assign(Object.assign({}, state), { date: dayjs(newDate).format(format) })));
|
|
465
|
+
} }, item)))))) : (React.createElement(React.Fragment, null,
|
|
466
|
+
React.createElement(Select, { options: newCalculationTypes.map(({ label, value }) => ({
|
|
467
|
+
value,
|
|
468
|
+
label: t(label),
|
|
469
|
+
})), value: option.calculationType.value, onChange: value => {
|
|
470
|
+
const calculationType = CALCULATION_TYPES.find(calculationType => calculationType.value === value);
|
|
471
|
+
onChangeOption({ calculationType });
|
|
472
|
+
} }),
|
|
473
|
+
React.createElement(InputNumber, { value: option.value, style: { width: '100%' }, min: 0, showHandler: false, onChange: value => onChangeOption({ value }) }),
|
|
474
|
+
React.createElement(Select, { options: newCalculationDates.map(calculationDate => (Object.assign(Object.assign({}, calculationDate), { label: t(calculationDate.label) }))), value: option.calculationDate.value, onChange: value => {
|
|
475
|
+
const calculationDate = newCalculationDates.find(calculationDate => calculationDate.value === value);
|
|
476
|
+
onChangeOption({ calculationDate });
|
|
477
|
+
} }))),
|
|
478
|
+
renderErrorMessage()),
|
|
479
|
+
renderDropdownFooter()));
|
|
480
|
+
};
|
|
481
|
+
const cellRender = React.useCallback((current, info) => {
|
|
482
|
+
const onChangeDatePicker = (value) => {
|
|
483
|
+
try {
|
|
484
|
+
setState(state => (Object.assign(Object.assign({}, state), { date: dayjs(value).format(format) })));
|
|
485
|
+
}
|
|
486
|
+
catch (error) {
|
|
487
|
+
handleError(error, {
|
|
488
|
+
path: PATH,
|
|
489
|
+
name: 'onChangeDatePicker',
|
|
490
|
+
args: { value },
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
};
|
|
494
|
+
return (React.createElement("div", { className: "antsomi-picker-cell-inner", style: { pointerEvents: 'all', width: '100%' }, onClick: e => {
|
|
495
|
+
if (info.type === 'time' && typeof current === 'number') {
|
|
496
|
+
e.preventDefault();
|
|
497
|
+
e.stopPropagation();
|
|
498
|
+
let newDate;
|
|
499
|
+
switch (info.subType) {
|
|
500
|
+
case 'hour':
|
|
501
|
+
newDate = dayjs(date).hour(current);
|
|
502
|
+
break;
|
|
503
|
+
case 'minute':
|
|
504
|
+
newDate = dayjs(date).minute(current);
|
|
505
|
+
break;
|
|
506
|
+
case 'second':
|
|
507
|
+
newDate = dayjs(date).second(current);
|
|
508
|
+
break;
|
|
509
|
+
default:
|
|
510
|
+
break;
|
|
511
|
+
}
|
|
512
|
+
if (newDate)
|
|
513
|
+
onChangeDatePicker(newDate);
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
if (info.type === 'decade' ||
|
|
517
|
+
(info.type === 'year' && valueType !== 'YEAR') ||
|
|
518
|
+
(info.type === 'month' &&
|
|
519
|
+
!['MONTH', 'YEAR_MONTH'].includes(valueType || 'YEAR_MONTH_DAY')))
|
|
520
|
+
return;
|
|
521
|
+
e.preventDefault();
|
|
522
|
+
e.stopPropagation();
|
|
523
|
+
onChangeDatePicker(current);
|
|
524
|
+
} }, getCellRender(current, valueType || 'YEAR_MONTH_DAY', info)));
|
|
525
|
+
}, [valueType, format, date]);
|
|
386
526
|
return (React.createElement(Space, { direction: "vertical", size: 5 },
|
|
387
527
|
!!label && typeof label === 'string' ? (React.createElement(Text, { style: { color: '#666666' } }, label)) : (label),
|
|
388
|
-
option.dateType.value === 'fixed'
|
|
528
|
+
option.dateType.value === 'fixed' &&
|
|
529
|
+
!['WEEK', 'DAY_OF_WEEK', 'MONTH_DAY', 'DAY'].includes(valueType || 'YEAR_MONTH_DAY') ? (React.createElement(DatePicker, { disabled: disabled, open: !disabled && isOpen, allowClear: false, inputReadOnly: true, status: errorMessage ? 'error' : '', inputRender: () => (React.createElement(DatePickerCustomInput, { readOnly: true, placeholder: "Select Date", value: dayjs(dateDisplay, format)
|
|
530
|
+
.format(formatDisplay)
|
|
531
|
+
.replace(QUARTER_PLACEHOLDER, 'Quarter ')
|
|
532
|
+
.replace(WEEK_PLACEHOLDER, 'Week '), onClick: () => toggleOpenDropdown() })), value: dayjs(date, format), style: {
|
|
389
533
|
width: 120,
|
|
390
534
|
}, disabledDate: disableDate, format: formatDisplay, showToday: false, popupClassName: clsx('antsomi-picker-dropdown__advanced', {
|
|
391
535
|
'--error': errorMessage,
|
|
536
|
+
'hide-picker-header': ['QUARTER', 'MONTH'].includes(valueType || 'YEAR_MONTH_DAY'),
|
|
537
|
+
'only-show-time-picker': ['HOUR', 'MINUTE'].includes(valueType || 'YEAR_MONTH_DAY'),
|
|
538
|
+
'is-minutes-picker': valueType === 'MINUTE',
|
|
539
|
+
'is-hours-picker': valueType === 'HOUR',
|
|
392
540
|
}), renderExtraFooter: () => (React.createElement(React.Fragment, null,
|
|
393
541
|
React.createElement(DatePickerHeader, null,
|
|
394
542
|
renderDropdownLabel(),
|
|
@@ -396,20 +544,21 @@ export const AdvancedPicker = props => {
|
|
|
396
544
|
React.createElement(DatePickerFooter, null,
|
|
397
545
|
React.createElement("div", { style: { padding: '0 10px' } }, renderErrorMessage()),
|
|
398
546
|
renderDropdownFooter()),
|
|
399
|
-
React.createElement(Divider, null))),
|
|
547
|
+
React.createElement(Divider, null))), picker: getPickerRender(valueType || 'YEAR_MONTH_DAY'), showTime: getTimePickerRender(valueType || 'YEAR_MONTH_DAY')
|
|
548
|
+
? {
|
|
549
|
+
format: getTimePickerRender(valueType || 'YEAR_MONTH_DAY'),
|
|
550
|
+
}
|
|
551
|
+
: undefined, suffixIcon: React.createElement(CalendarIconWrapper, { style: {
|
|
400
552
|
pointerEvents: disabled ? 'none' : 'all',
|
|
401
553
|
}, onClick: () => toggleOpenDropdown() },
|
|
402
|
-
React.createElement(EventIcon, { width: 20, height: 20, fill: errorMessage ? (_a = THEME.token) === null || _a === void 0 ? void 0 : _a.colorError : (_b = THEME.token) === null || _b === void 0 ? void 0 : _b.bw10 })),
|
|
403
|
-
e.preventDefault();
|
|
404
|
-
e.stopPropagation();
|
|
405
|
-
onChangeDatePicker(current);
|
|
406
|
-
} }, current.date())),
|
|
407
|
-
// onChange={onChangeDatePicker}
|
|
408
|
-
onOpenChange: () => toggleOpenDropdown() })) : (React.createElement(Dropdown, { disabled: disabled, open: !disabled && isOpen, dropdownRender: dropdownRender, trigger: ['click'], onOpenChange: () => toggleOpenDropdown(), overlayStyle: { width: 'fit-content', minWidth: 'auto' } },
|
|
554
|
+
React.createElement(EventIcon, { width: 20, height: 20, fill: errorMessage ? (_a = THEME.token) === null || _a === void 0 ? void 0 : _a.colorError : (_b = THEME.token) === null || _b === void 0 ? void 0 : _b.bw10 })), cellRender: cellRender, onOpenChange: () => toggleOpenDropdown() })) : (React.createElement(Dropdown, { disabled: disabled, open: !disabled && isOpen, dropdownRender: dropdownRender, trigger: ['click'], onOpenChange: () => toggleOpenDropdown(), overlayStyle: { width: 'fit-content', minWidth: 'auto' } },
|
|
409
555
|
React.createElement(Input, { disabled: disabled, onClick: () => toggleOpenDropdown(), readOnly: true, suffix: React.createElement(CalendarIconWrapper, { style: {
|
|
410
556
|
pointerEvents: disabled ? 'none' : 'all',
|
|
411
557
|
}, onClick: () => toggleOpenDropdown() },
|
|
412
|
-
React.createElement(EventIcon, { width: 19, height: 19 })), style: inputStyle, value: dayjs(dateDisplay, format)
|
|
558
|
+
React.createElement(EventIcon, { width: 19, height: 19 })), style: inputStyle, value: dayjs(dateDisplay, format)
|
|
559
|
+
.format(formatDisplay)
|
|
560
|
+
.replace(QUARTER_PLACEHOLDER, 'Quarter ')
|
|
561
|
+
.replace(WEEK_PLACEHOLDER, 'Week '), status: errorMessage ? 'error' : '' })))));
|
|
413
562
|
};
|
|
414
563
|
AdvancedPicker.defaultProps = {
|
|
415
564
|
label: '',
|
|
@@ -12,26 +12,26 @@ export declare const CALCULATION_DATES: {
|
|
|
12
12
|
label: string;
|
|
13
13
|
}[];
|
|
14
14
|
export declare const VALUE_TYPES: {
|
|
15
|
-
INPUT_TEXT:
|
|
16
|
-
INPUT_NUMBER:
|
|
17
|
-
MATCHES_ANY:
|
|
18
|
-
YEAR:
|
|
19
|
-
YEAR_QUARTER:
|
|
20
|
-
YEAR_MONTH:
|
|
21
|
-
YEAR_WEEK:
|
|
22
|
-
YEAR_MONTH_DAY:
|
|
23
|
-
YEAR_MONTH_DAY_HOUR:
|
|
24
|
-
YEAR_MONTH_DAY_MINUTE:
|
|
25
|
-
YEAR_MONTH_DAY_SECOND:
|
|
26
|
-
QUARTER:
|
|
27
|
-
MONTH:
|
|
28
|
-
WEEK:
|
|
29
|
-
MONTH_DAY:
|
|
30
|
-
DAY_OF_WEEK:
|
|
31
|
-
DAY:
|
|
32
|
-
HOUR:
|
|
33
|
-
MINUTE:
|
|
34
|
-
INPUT_TEXT_NO_FIELD:
|
|
15
|
+
readonly INPUT_TEXT: "INPUT_TEXT";
|
|
16
|
+
readonly INPUT_NUMBER: "INPUT_NUMBER";
|
|
17
|
+
readonly MATCHES_ANY: "MATCHES_ANY";
|
|
18
|
+
readonly YEAR: "YEAR";
|
|
19
|
+
readonly YEAR_QUARTER: "YEAR_QUARTER";
|
|
20
|
+
readonly YEAR_MONTH: "YEAR_MONTH";
|
|
21
|
+
readonly YEAR_WEEK: "YEAR_WEEK";
|
|
22
|
+
readonly YEAR_MONTH_DAY: "YEAR_MONTH_DAY";
|
|
23
|
+
readonly YEAR_MONTH_DAY_HOUR: "YEAR_MONTH_DAY_HOUR";
|
|
24
|
+
readonly YEAR_MONTH_DAY_MINUTE: "YEAR_MONTH_DAY_MINUTE";
|
|
25
|
+
readonly YEAR_MONTH_DAY_SECOND: "YEAR_MONTH_DAY_SECOND";
|
|
26
|
+
readonly QUARTER: "QUARTER";
|
|
27
|
+
readonly MONTH: "MONTH";
|
|
28
|
+
readonly WEEK: "WEEK";
|
|
29
|
+
readonly MONTH_DAY: "MONTH_DAY";
|
|
30
|
+
readonly DAY_OF_WEEK: "DAY_OF_WEEK";
|
|
31
|
+
readonly DAY: "DAY";
|
|
32
|
+
readonly HOUR: "HOUR";
|
|
33
|
+
readonly MINUTE: "MINUTE";
|
|
34
|
+
readonly INPUT_TEXT_NO_FIELD: "INPUT_TEXT_NO_FIELD";
|
|
35
35
|
};
|
|
36
36
|
export declare const DEFAULT_DATE_FORMAT = "YYYYMMDDHHmmss";
|
|
37
37
|
export declare const DEFAULT_TIME_FORMAT = "HH:mm:ss";
|
|
@@ -51,3 +51,18 @@ export declare const ADVANCED_PICKER_TYPE: Record<string, {
|
|
|
51
51
|
value: TAdvancedType;
|
|
52
52
|
label: string;
|
|
53
53
|
}>;
|
|
54
|
+
export declare const MONTH_LABEL_SHORT: string[];
|
|
55
|
+
export declare const MONTH_LABEL_FULL: string[];
|
|
56
|
+
export declare const DAY_LABEL_SHORT: string[];
|
|
57
|
+
export declare const WEEK_ARR: number[];
|
|
58
|
+
export declare const MONTH_DAY_31: number[];
|
|
59
|
+
export declare const MONTH_DAY_30: number[];
|
|
60
|
+
export declare const MONTH_DAY_FEB: number[];
|
|
61
|
+
export declare const MONTH_31: number[];
|
|
62
|
+
export declare const MONTH_30: number[];
|
|
63
|
+
export declare const DAY_OF_MONTH: number[][];
|
|
64
|
+
/** The year with full 366 days of year, use for select day/day of month with include edge case (February 29th) */
|
|
65
|
+
export declare const ANCHOR_LEAP_YEAR = 2024;
|
|
66
|
+
export declare const QUARTER_PLACEHOLDER = "%q%";
|
|
67
|
+
export declare const WEEK_PLACEHOLDER = "%t%";
|
|
68
|
+
export declare const HIDE_TIME_LABEL_ARR: string[];
|
|
@@ -72,3 +72,69 @@ export const ADVANCED_PICKER_TYPE = {
|
|
|
72
72
|
label: 'datePicker.endDate',
|
|
73
73
|
},
|
|
74
74
|
};
|
|
75
|
+
export const MONTH_LABEL_SHORT = [
|
|
76
|
+
'Jan',
|
|
77
|
+
'Feb',
|
|
78
|
+
'Mar',
|
|
79
|
+
'Apr',
|
|
80
|
+
'May',
|
|
81
|
+
'Jun',
|
|
82
|
+
'Jul',
|
|
83
|
+
'Aug',
|
|
84
|
+
'Sep',
|
|
85
|
+
'Oct',
|
|
86
|
+
'Nov',
|
|
87
|
+
'Dec',
|
|
88
|
+
];
|
|
89
|
+
export const MONTH_LABEL_FULL = [
|
|
90
|
+
'January',
|
|
91
|
+
'February',
|
|
92
|
+
'March',
|
|
93
|
+
'April',
|
|
94
|
+
'May',
|
|
95
|
+
'June',
|
|
96
|
+
'July',
|
|
97
|
+
'August',
|
|
98
|
+
'September',
|
|
99
|
+
'October',
|
|
100
|
+
'November',
|
|
101
|
+
'December',
|
|
102
|
+
];
|
|
103
|
+
export const DAY_LABEL_SHORT = ['Sun', 'Mon', 'Tue', 'Wed', 'Thur', 'Fri', 'Sat'];
|
|
104
|
+
export const WEEK_ARR = Array.from({ length: 53 }, (_, i) => i + 1);
|
|
105
|
+
export const MONTH_DAY_31 = Array.from({ length: 31 }, (_, i) => i + 1);
|
|
106
|
+
export const MONTH_DAY_30 = Array.from({ length: 30 }, (_, i) => i + 1);
|
|
107
|
+
export const MONTH_DAY_FEB = Array.from({ length: 29 }, (_, i) => i + 1);
|
|
108
|
+
export const MONTH_31 = [0, 2, 4, 6, 7, 9, 11];
|
|
109
|
+
export const MONTH_30 = [3, 5, 8, 10];
|
|
110
|
+
export const DAY_OF_MONTH = [
|
|
111
|
+
MONTH_DAY_31,
|
|
112
|
+
MONTH_DAY_FEB,
|
|
113
|
+
MONTH_DAY_31,
|
|
114
|
+
MONTH_DAY_30,
|
|
115
|
+
MONTH_DAY_31,
|
|
116
|
+
MONTH_DAY_30,
|
|
117
|
+
MONTH_DAY_31,
|
|
118
|
+
MONTH_DAY_31,
|
|
119
|
+
MONTH_DAY_30,
|
|
120
|
+
MONTH_DAY_31,
|
|
121
|
+
MONTH_DAY_30,
|
|
122
|
+
MONTH_DAY_31,
|
|
123
|
+
];
|
|
124
|
+
/** The year with full 366 days of year, use for select day/day of month with include edge case (February 29th) */
|
|
125
|
+
export const ANCHOR_LEAP_YEAR = 2024;
|
|
126
|
+
export const QUARTER_PLACEHOLDER = '%q%';
|
|
127
|
+
export const WEEK_PLACEHOLDER = '%t%';
|
|
128
|
+
export const HIDE_TIME_LABEL_ARR = [
|
|
129
|
+
'YEAR',
|
|
130
|
+
'YEAR_MONTH',
|
|
131
|
+
'YEAR_MONTH_DAY',
|
|
132
|
+
'QUARTER',
|
|
133
|
+
'MONTH',
|
|
134
|
+
'WEEK',
|
|
135
|
+
'HOUR',
|
|
136
|
+
'MINUTE',
|
|
137
|
+
'MONTH_DAY',
|
|
138
|
+
'DAY_OF_WEEK',
|
|
139
|
+
'DAY',
|
|
140
|
+
];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _a, _b, _c;
|
|
1
|
+
var _a, _b, _c, _d, _e;
|
|
2
2
|
// Libraries
|
|
3
3
|
import { THEME } from '../../../../../constants';
|
|
4
4
|
import styled from 'styled-components';
|
|
@@ -8,6 +8,50 @@ export const DropdownContent = styled.div `
|
|
|
8
8
|
display: flex;
|
|
9
9
|
flex-direction: column;
|
|
10
10
|
gap: 10px;
|
|
11
|
+
|
|
12
|
+
.custom-picker-content {
|
|
13
|
+
display: grid;
|
|
14
|
+
grid-template-columns: repeat(3, 1fr);
|
|
15
|
+
row-gap: 12px;
|
|
16
|
+
height: 120px;
|
|
17
|
+
overflow-y: auto;
|
|
18
|
+
|
|
19
|
+
&.day-of-month-container {
|
|
20
|
+
grid-template-columns: repeat(7, 1fr);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
& > .custom-picker-item {
|
|
24
|
+
padding: 2px 8px;
|
|
25
|
+
cursor: pointer;
|
|
26
|
+
display: flex;
|
|
27
|
+
justify-content: center;
|
|
28
|
+
align-items: center;
|
|
29
|
+
|
|
30
|
+
&.custom-picker-item-selected {
|
|
31
|
+
background-color: ${(_a = THEME.token) === null || _a === void 0 ? void 0 : _a.colorPrimary};
|
|
32
|
+
color: #fff;
|
|
33
|
+
&:hover {
|
|
34
|
+
background-color: ${(_b = THEME.token) === null || _b === void 0 ? void 0 : _b.colorPrimary};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&:hover {
|
|
39
|
+
background-color: rgba(34, 34, 34, 0.04);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.month-controller {
|
|
45
|
+
display: flex;
|
|
46
|
+
justify-content: space-around;
|
|
47
|
+
user-select: none;
|
|
48
|
+
i {
|
|
49
|
+
cursor: pointer;
|
|
50
|
+
&:hover {
|
|
51
|
+
color: #000;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
11
55
|
`;
|
|
12
56
|
export const DropdownHeader = styled.div `
|
|
13
57
|
padding: 10px 10px 0px 10px;
|
|
@@ -17,7 +61,7 @@ export const DropdownHeader = styled.div `
|
|
|
17
61
|
text-align: center;
|
|
18
62
|
|
|
19
63
|
> .__title {
|
|
20
|
-
color: ${(
|
|
64
|
+
color: ${(_c = THEME.token) === null || _c === void 0 ? void 0 : _c.bw6};
|
|
21
65
|
}
|
|
22
66
|
`;
|
|
23
67
|
export const DropdownFooter = styled.div `
|
|
@@ -34,8 +78,8 @@ export const DatePickerHeader = styled.div `
|
|
|
34
78
|
line-height: 1.6 !important;
|
|
35
79
|
`;
|
|
36
80
|
export const DatePickerCustomInput = styled.input `
|
|
37
|
-
font-family: ${(
|
|
38
|
-
color: ${(
|
|
81
|
+
font-family: ${(_d = THEME.token) === null || _d === void 0 ? void 0 : _d.fontFamily};
|
|
82
|
+
color: ${(_e = THEME.token) === null || _e === void 0 ? void 0 : _e.bw10} !important;
|
|
39
83
|
`;
|
|
40
84
|
export const DatePickerFooter = styled.div `
|
|
41
85
|
position: absolute;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { VALUE_TYPES } from './constants';
|
|
1
2
|
export type TOption = {
|
|
2
3
|
dateType: TDateType;
|
|
3
4
|
calculationType: TCalculationType;
|
|
@@ -12,3 +13,24 @@ export type TCalculationType = 'minus' | 'plus' | '';
|
|
|
12
13
|
export type TCalculationDate = 'seconds' | 'minutes' | 'hours' | 'days' | 'weeks' | 'months' | 'quarters' | 'years' | '';
|
|
13
14
|
export type TOperatorKey = 'after' | 'between' | 'before';
|
|
14
15
|
export type TAdvancedType = 'startDate' | 'endDate';
|
|
16
|
+
/**
|
|
17
|
+
* @description Mapping ValueTypes to Semantic
|
|
18
|
+
* @example ```valueType -> semantic```
|
|
19
|
+
* @type YEAR -> 'YYYY'
|
|
20
|
+
* @type YEAR_QUARTER -> 'QQ YYYY'
|
|
21
|
+
* @type YEAR_MONTH -> 'MM YYYY'
|
|
22
|
+
* @type YEAR_WEEK -> 'WW YYYY'
|
|
23
|
+
* @type YEAR_MONTH_DAY -> 'MM DD YYYY'
|
|
24
|
+
* @type YEAR_MONTH_DAY_HOUR -> 'MM DD YYYY HH'
|
|
25
|
+
* @type YEAR_MONTH_DAY_MINUTE -> 'MM DD YYYY HH MM'
|
|
26
|
+
* @type YEAR_MONTH_DAY_SECOND -> 'MM DD YYYY HH MM SS'
|
|
27
|
+
* @type QUARTER -> 'QQ'
|
|
28
|
+
* @type MONTH -> 'MM'
|
|
29
|
+
* @type WEEK -> 'WW'
|
|
30
|
+
* @type MONTH_DAY -> 'MM DD'
|
|
31
|
+
* @type DAY_OF_WEEK -> 'D'
|
|
32
|
+
* @type DAY -> 'DD'
|
|
33
|
+
* @type HOUR -> 'HH'
|
|
34
|
+
* @type MINUTE -> 'MM'
|
|
35
|
+
*/
|
|
36
|
+
export type ValueTypes = (typeof VALUE_TYPES)[keyof typeof VALUE_TYPES];
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { Dayjs } from 'dayjs';
|
|
2
|
+
import type { CellRenderInfo } from 'rc-picker/es/interface';
|
|
3
|
+
import { ValueTypes } from './types';
|
|
1
4
|
/**
|
|
2
5
|
* Calculates a new date based on the given parameters.
|
|
3
6
|
* @param {string} [dateTypeKey='today'] - Key to determine the type of date to be used as the starting point.
|
|
@@ -13,3 +16,20 @@
|
|
|
13
16
|
* @returns {string} The new date in the specified format.
|
|
14
17
|
*/
|
|
15
18
|
export declare const calculationDateAdvanced: (dateTypeKey?: string, calculationTypeKey?: string, calculationDateKey?: any, value?: number, dateFormat?: string) => any;
|
|
19
|
+
/**
|
|
20
|
+
* Get text of calendar cell base on valueType (semantic/date format)
|
|
21
|
+
* @link https://ant.design/components/date-picker#components-date-picker-demo-cell-render
|
|
22
|
+
* @param {number | Dayjs} current params of cellRender function
|
|
23
|
+
* @param {CellRenderInfo<Dayjs>} info params of cellRender function
|
|
24
|
+
* @param {ValueTypes} valueType type of value (get from component props)
|
|
25
|
+
* @returns {number | string} label of cell according to valueType
|
|
26
|
+
*/
|
|
27
|
+
export declare const getCellRender: (current: number | Dayjs, valueType: ValueTypes, info: CellRenderInfo<Dayjs>) => number | string;
|
|
28
|
+
/**
|
|
29
|
+
* @param {ValueTypes} valueType type of value (get from component props)
|
|
30
|
+
* @returns {'date' | 'week' | 'month' | 'quarter' | 'year'} picker ant-design props to render type of calendar
|
|
31
|
+
*/
|
|
32
|
+
export declare const getPickerRender: (valueType: ValueTypes) => 'date' | 'week' | 'month' | 'quarter' | 'year';
|
|
33
|
+
export declare const getTimePickerRender: (valueType: ValueTypes) => "HH" | "HHmm" | "HHmmss" | "mm" | undefined;
|
|
34
|
+
export declare function getLabelQuarterRange(day: string, format: string, locale: string, showYear?: boolean): string;
|
|
35
|
+
export declare function getLabelQuarterRange(quarter: number, year?: number): string;
|
|
@@ -4,7 +4,7 @@ import dayjs from 'dayjs';
|
|
|
4
4
|
import isoWeek from 'dayjs/plugin/isoWeek';
|
|
5
5
|
import quarterOfYear from 'dayjs/plugin/quarterOfYear';
|
|
6
6
|
// Constants
|
|
7
|
-
import { DEFAULT_DATE_FORMAT } from './constants';
|
|
7
|
+
import { DEFAULT_DATE_FORMAT, MONTH_LABEL_SHORT } from './constants';
|
|
8
8
|
dayjs.extend(isoWeek);
|
|
9
9
|
dayjs.extend(quarterOfYear);
|
|
10
10
|
/**
|
|
@@ -82,3 +82,92 @@ export const calculationDateAdvanced = (dateTypeKey = 'today', calculationTypeKe
|
|
|
82
82
|
}
|
|
83
83
|
return newDate.format(dateFormat);
|
|
84
84
|
};
|
|
85
|
+
/**
|
|
86
|
+
* Get text of calendar cell base on valueType (semantic/date format)
|
|
87
|
+
* @link https://ant.design/components/date-picker#components-date-picker-demo-cell-render
|
|
88
|
+
* @param {number | Dayjs} current params of cellRender function
|
|
89
|
+
* @param {CellRenderInfo<Dayjs>} info params of cellRender function
|
|
90
|
+
* @param {ValueTypes} valueType type of value (get from component props)
|
|
91
|
+
* @returns {number | string} label of cell according to valueType
|
|
92
|
+
*/
|
|
93
|
+
export const getCellRender = (current, valueType, info) => {
|
|
94
|
+
if (typeof current === 'number')
|
|
95
|
+
return current;
|
|
96
|
+
if (info.type === 'decade')
|
|
97
|
+
return `${current.year()}-${current.year() + 10}`;
|
|
98
|
+
if (info.type === 'year')
|
|
99
|
+
return current.year();
|
|
100
|
+
if (info.type === 'month')
|
|
101
|
+
return MONTH_LABEL_SHORT[current.month()];
|
|
102
|
+
switch (valueType) {
|
|
103
|
+
case 'DAY':
|
|
104
|
+
return current.date();
|
|
105
|
+
case 'QUARTER':
|
|
106
|
+
case 'YEAR_QUARTER':
|
|
107
|
+
return `Quarter ${current.quarter()}`;
|
|
108
|
+
case 'MONTH':
|
|
109
|
+
case 'YEAR_MONTH':
|
|
110
|
+
return MONTH_LABEL_SHORT[current.month()];
|
|
111
|
+
case 'WEEK':
|
|
112
|
+
return current.isoWeek();
|
|
113
|
+
default:
|
|
114
|
+
return current.date();
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* @param {ValueTypes} valueType type of value (get from component props)
|
|
119
|
+
* @returns {'date' | 'week' | 'month' | 'quarter' | 'year'} picker ant-design props to render type of calendar
|
|
120
|
+
*/
|
|
121
|
+
export const getPickerRender = (valueType) => {
|
|
122
|
+
switch (valueType) {
|
|
123
|
+
case 'DAY':
|
|
124
|
+
return 'date';
|
|
125
|
+
case 'YEAR':
|
|
126
|
+
return 'year';
|
|
127
|
+
case 'QUARTER':
|
|
128
|
+
case 'YEAR_QUARTER':
|
|
129
|
+
return 'quarter';
|
|
130
|
+
case 'MONTH':
|
|
131
|
+
case 'YEAR_MONTH':
|
|
132
|
+
return 'month';
|
|
133
|
+
case 'WEEK':
|
|
134
|
+
case 'YEAR_WEEK':
|
|
135
|
+
return 'week';
|
|
136
|
+
default:
|
|
137
|
+
return 'date';
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
export const getTimePickerRender = (valueType) => {
|
|
141
|
+
switch (valueType) {
|
|
142
|
+
case 'HOUR':
|
|
143
|
+
case 'YEAR_MONTH_DAY_HOUR':
|
|
144
|
+
return 'HH';
|
|
145
|
+
case 'YEAR_MONTH_DAY_MINUTE':
|
|
146
|
+
return 'HHmm';
|
|
147
|
+
case 'YEAR_MONTH_DAY_SECOND':
|
|
148
|
+
return 'HHmmss';
|
|
149
|
+
case 'MINUTE':
|
|
150
|
+
return 'mm';
|
|
151
|
+
default:
|
|
152
|
+
return undefined;
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
export function getLabelQuarterRange(quarterOrDay, yearOrFormat, locale, showYear = true) {
|
|
156
|
+
const dayObj = typeof quarterOrDay === 'number'
|
|
157
|
+
? null
|
|
158
|
+
: dayjs(quarterOrDay || new Date(), yearOrFormat).locale(locale || 'en');
|
|
159
|
+
const currQuarter = dayObj ? dayObj.quarter() : quarterOrDay;
|
|
160
|
+
const currYear = dayObj
|
|
161
|
+
? showYear
|
|
162
|
+
? dayObj.year()
|
|
163
|
+
: null
|
|
164
|
+
: typeof yearOrFormat === 'number'
|
|
165
|
+
? yearOrFormat
|
|
166
|
+
: null;
|
|
167
|
+
const startMonthQuarter = [undefined, 'January', 'April', 'July', 'October'];
|
|
168
|
+
const endMonthQuarter = [undefined, 'March', 'June', 'September', 'December'];
|
|
169
|
+
const endDayQuarter = [undefined, 31, 30, 30, 31];
|
|
170
|
+
return currYear
|
|
171
|
+
? `${startMonthQuarter[currQuarter]} 01, ${currYear} - ${endMonthQuarter[currQuarter]} ${endDayQuarter[currQuarter]}, ${currYear}`
|
|
172
|
+
: `${startMonthQuarter[currQuarter]} 01 - ${endMonthQuarter[currQuarter]} ${endDayQuarter[currQuarter]}`;
|
|
173
|
+
}
|