@antscorp/antsomi-ui 1.3.8 → 1.3.10

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 (25) hide show
  1. package/es/components/common/ConfigProvider/ConfigProvider.js +11 -0
  2. package/es/components/common/ConfigProvider/GlobalStyle.js +178 -28
  3. package/es/components/molecules/DatePicker/components/AdvancedPicker/AdvancedPicker.d.ts +7 -3
  4. package/es/components/molecules/DatePicker/components/AdvancedPicker/AdvancedPicker.js +218 -207
  5. package/es/components/molecules/DatePicker/components/AdvancedPicker/constants.d.ts +78 -25
  6. package/es/components/molecules/DatePicker/components/AdvancedPicker/constants.js +145 -22
  7. package/es/components/molecules/DatePicker/components/AdvancedPicker/styled.d.ts +2 -0
  8. package/es/components/molecules/DatePicker/components/AdvancedPicker/styled.js +57 -6
  9. package/es/components/molecules/DatePicker/components/AdvancedPicker/types.d.ts +22 -0
  10. package/es/components/molecules/DatePicker/components/AdvancedPicker/utils.d.ts +25 -1
  11. package/es/components/molecules/DatePicker/components/AdvancedPicker/utils.js +167 -40
  12. package/es/components/molecules/DatePicker/components/AdvancedRangePicker/AdvancedRangePicker.d.ts +5 -2
  13. package/es/components/molecules/DatePicker/components/AdvancedRangePicker/AdvancedRangePicker.js +23 -10
  14. package/es/components/molecules/DatePicker/components/AdvancedRangePicker/constants.d.ts +1 -0
  15. package/es/components/molecules/DatePicker/components/AdvancedRangePicker/constants.js +1 -0
  16. package/es/components/molecules/DatePicker/components/AdvancedRangePicker/types.d.ts +1 -0
  17. package/es/components/molecules/DatePicker/components/DropdownLabel/DropdownLabel.d.ts +13 -0
  18. package/es/components/molecules/DatePicker/components/DropdownLabel/DropdownLabel.js +87 -0
  19. package/es/components/molecules/DatePicker/components/ErrorMessage/ErrorMessage.d.ts +6 -0
  20. package/es/components/molecules/DatePicker/components/ErrorMessage/ErrorMessage.js +12 -0
  21. package/es/components/molecules/UploadImage/index.js +1 -1
  22. package/es/hooks/useOutsideClick.d.ts +4 -0
  23. package/es/hooks/useOutsideClick.js +18 -0
  24. package/es/locales/en/translation.json +2 -2
  25. package/package.json +1 -1
@@ -12,7 +12,13 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  // Libraries
13
13
  import { StyleProvider } from '@ant-design/cssinjs';
14
14
  import { ConfigProvider as AntdConfigProvider } from 'antd';
15
+ import dayjs from 'dayjs';
15
16
  import React, { useEffect } from 'react';
17
+ import weekday from 'dayjs/plugin/weekday';
18
+ import localeData from 'dayjs/plugin/localeData';
19
+ /** dayjs plugins for timezone */
20
+ import utc from 'dayjs/plugin/utc';
21
+ import timezone from 'dayjs/plugin/timezone';
16
22
  // Constants
17
23
  import { THEME } from '@antscorp/antsomi-ui/es/constants';
18
24
  // Style
@@ -21,6 +27,11 @@ import '@antscorp/antsomi-ui/es/assets/css/main.scss';
21
27
  // Initialize languages
22
28
  // import '@antscorp/antsomi-ui/es/locales/i18n';
23
29
  import i18next from '@antscorp/antsomi-ui/es/locales/i18n';
30
+ // NOTE: HOT fix DatePicker Advanced
31
+ dayjs.extend(weekday);
32
+ dayjs.extend(localeData);
33
+ dayjs.extend(utc);
34
+ dayjs.extend(timezone);
24
35
  const ConfigProvider = props => {
25
36
  // Props
26
37
  const { children, locale } = props, restOfProps = __rest(props, ["children", "locale"]);
@@ -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
 
@@ -282,13 +282,150 @@ export const GlobalStyle = () => {
282
282
  flex-direction: column-reverse;
283
283
  padding-bottom: 60px;
284
284
 
285
- .antsomi-picker-date-panel {
285
+ .antsomi-picker-date-panel,
286
+ .antsomi-picker-quarter-panel {
286
287
  width: 280px !important;
287
288
 
288
289
  .antsomi-picker-cell {
289
290
  pointer-events: none !important;
290
291
  }
291
292
  }
293
+
294
+ .antsomi-picker-date-panel {
295
+ position: relative;
296
+ }
297
+
298
+ .antsomi-picker-date-panel::before {
299
+ content: 'Hours';
300
+ position: absolute;
301
+ top: 0;
302
+ right: 0;
303
+ transform: translateX(100%);
304
+ width: 61px;
305
+ /* width: 53.5px; */
306
+ font-weight: bold;
307
+ border-right: 1px solid rgba(5, 5, 5, 0.06);
308
+ height: 38px;
309
+ display: flex;
310
+ align-items: center;
311
+ justify-content: center;
312
+ }
313
+
314
+ .antsomi-picker-time-panel {
315
+ .antsomi-picker-time-panel-column:after {
316
+ height: 8px;
317
+ }
318
+
319
+ .antsomi-picker-time-panel-cell-selected {
320
+ background-color: ${(_8 = THEME.token) === null || _8 === void 0 ? void 0 : _8.colorPrimary};
321
+ color: #fff;
322
+ }
323
+ .antsomi-picker-time-panel-cell-selected:hover {
324
+ background-color: ${(_9 = THEME.token) === null || _9 === void 0 ? void 0 : _9.colorPrimary};
325
+ }
326
+
327
+ .antsomi-picker-cell-inner {
328
+ text-align: center;
329
+ cursor: pointer;
330
+ }
331
+ .antsomi-picker-cell-inner:hover {
332
+ background: rgba(34, 34, 34, 0.04);
333
+ }
334
+
335
+ .antsomi-picker-header {
336
+ display: none;
337
+ }
338
+
339
+ .antsomi-picker-content {
340
+ position: relative;
341
+
342
+ .antsomi-picker-time-panel-column {
343
+ margin-top: 38px;
344
+ width: 60px;
345
+ }
346
+ }
347
+
348
+ .antsomi-picker-content::after,
349
+ .antsomi-picker-content::before {
350
+ content: 'Minutes';
351
+ position: absolute;
352
+ top: 0;
353
+ left: 61px;
354
+ /* left: 53.5px; */
355
+ width: 60px;
356
+ /* width: 52.5px; */
357
+ height: 38px;
358
+ display: flex;
359
+ align-items: center;
360
+ justify-content: center;
361
+ font-weight: bold;
362
+ }
363
+
364
+ .antsomi-picker-content::before {
365
+ border-right: 1px solid rgba(5, 5, 5, 0.06);
366
+ }
367
+ .antsomi-picker-content::after {
368
+ content: 'Seconds';
369
+ left: 120px;
370
+ }
371
+ }
372
+
373
+ /* Custom css scrollbar */
374
+ ul {
375
+ padding-left: 8px;
376
+ scrollbar-gutter: stable;
377
+ }
378
+ }
379
+
380
+ &.hide-picker-header {
381
+ .antsomi-picker-month-panel,
382
+ .antsomi-picker-quarter-panel {
383
+ .antsomi-picker-header {
384
+ display: none;
385
+ }
386
+ }
387
+ }
388
+
389
+ &.only-show-time-picker {
390
+ .antsomi-picker-date-panel {
391
+ display: none;
392
+ }
393
+ .antsomi-picker-time-panel {
394
+ border: none;
395
+ /* NOTE: production prod show unexpected border */
396
+ border-inline-start: none !important;
397
+ }
398
+ > .antsomi-picker-panel-container > .antsomi-picker-panel-layout > .antsomi-picker-panel {
399
+ width: 250px;
400
+ .antsomi-picker-datetime-panel {
401
+ justify-content: center;
402
+ }
403
+
404
+ ul {
405
+ ::-webkit-scrollbar {
406
+ width: 0;
407
+ }
408
+ padding: 0;
409
+ }
410
+
411
+ .antsomi-picker-content::after {
412
+ display: none;
413
+ }
414
+ .antsomi-picker-content::before {
415
+ content: 'Hours';
416
+ border: none;
417
+ left: 0;
418
+ }
419
+ }
420
+ &.is-minutes-picker {
421
+ > .antsomi-picker-panel-container
422
+ > .antsomi-picker-panel-layout
423
+ > .antsomi-picker-panel {
424
+ .antsomi-picker-content::before {
425
+ content: 'Minutes';
426
+ }
427
+ }
428
+ }
292
429
  }
293
430
 
294
431
  &.--error
@@ -302,9 +439,22 @@ export const GlobalStyle = () => {
302
439
  .antsomi-picker-footer-extra {
303
440
  padding: 0 !important;
304
441
  }
442
+
443
+ /*
444
+ * NOTE: UI broken when add showTime props to <DatePicker />
445
+ * Unexpected header control (comment code below to see bug)
446
+ * Temporary solution: hide the verbose element
447
+ */
448
+ .antsomi-picker-ranges {
449
+ display: none;
450
+ }
305
451
  }
306
452
  }
307
453
 
454
+ .antsomi-advanced-picker-container .input__wrapper {
455
+ display: inline-block;
456
+ }
457
+
308
458
  // Slider
309
459
  .antsomi-slider {
310
460
  margin: 0 !important;
@@ -329,14 +479,14 @@ export const GlobalStyle = () => {
329
479
  .antsomi-slider-rail {
330
480
  border-radius: 2px !important;
331
481
  transition: background-color 0.3s !important;
332
- background-color: ${(_8 = THEME.token) === null || _8 === void 0 ? void 0 : _8.accent1} !important;
482
+ background-color: ${(_10 = THEME.token) === null || _10 === void 0 ? void 0 : _10.accent1} !important;
333
483
  }
334
484
 
335
485
  .antsomi-slider-track {
336
486
  position: absolute !important;
337
487
  border-radius: 2px !important;
338
488
  transition: background-color 0.3s !important;
339
- background-color: ${(_9 = THEME.token) === null || _9 === void 0 ? void 0 : _9.colorPrimary} !important;
489
+ background-color: ${(_11 = THEME.token) === null || _11 === void 0 ? void 0 : _11.colorPrimary} !important;
340
490
  }
341
491
 
342
492
  .antsomi-slider-step {
@@ -370,16 +520,16 @@ export const GlobalStyle = () => {
370
520
  }
371
521
 
372
522
  .antsomi-slider-handle::after {
373
- background-color: ${(_10 = THEME.token) === null || _10 === void 0 ? void 0 : _10.colorPrimary} !important;
523
+ background-color: ${(_12 = THEME.token) === null || _12 === void 0 ? void 0 : _12.colorPrimary} !important;
374
524
  }
375
525
 
376
526
  &:hover {
377
527
  .antsomi-slider-track {
378
- background-color: ${(_11 = THEME.token) === null || _11 === void 0 ? void 0 : _11.colorPrimary} !important;
528
+ background-color: ${(_13 = THEME.token) === null || _13 === void 0 ? void 0 : _13.colorPrimary} !important;
379
529
  }
380
530
 
381
531
  .antsomi-slider-rail {
382
- background-color: ${(_12 = THEME.token) === null || _12 === void 0 ? void 0 : _12.accent1} !important;
532
+ background-color: ${(_14 = THEME.token) === null || _14 === void 0 ? void 0 : _14.accent1} !important;
383
533
  }
384
534
 
385
535
  .antsomi-slider-handle::after {
@@ -387,7 +537,7 @@ export const GlobalStyle = () => {
387
537
  }
388
538
 
389
539
  .antsomi-slider-handle {
390
- border-color: ${(_13 = THEME.token) === null || _13 === void 0 ? void 0 : _13.colorPrimary} !important;
540
+ border-color: ${(_15 = THEME.token) === null || _15 === void 0 ? void 0 : _15.colorPrimary} !important;
391
541
  }
392
542
  }
393
543
 
@@ -397,8 +547,8 @@ export const GlobalStyle = () => {
397
547
 
398
548
  &.antsomi-slider-disabled {
399
549
  .antsomi-slider-handle {
400
- background-color: ${(_14 = THEME.token) === null || _14 === void 0 ? void 0 : _14.accent2} !important;
401
- border-color: ${(_15 = THEME.token) === null || _15 === void 0 ? void 0 : _15.accent2} !important;
550
+ background-color: ${(_16 = THEME.token) === null || _16 === void 0 ? void 0 : _16.accent2} !important;
551
+ border-color: ${(_17 = THEME.token) === null || _17 === void 0 ? void 0 : _17.accent2} !important;
402
552
  }
403
553
  }
404
554
  }
@@ -412,8 +562,8 @@ export const GlobalStyle = () => {
412
562
  padding-left: 20px;
413
563
  padding-right: 20px;
414
564
  font-family: 'Roboto';
415
- color: ${(_16 = THEME.token) === null || _16 === void 0 ? void 0 : _16.colorTextBase};
416
- font-size: ${(_17 = THEME.token) === null || _17 === void 0 ? void 0 : _17.fontSize}px;
565
+ color: ${(_18 = THEME.token) === null || _18 === void 0 ? void 0 : _18.colorTextBase};
566
+ font-size: ${(_19 = THEME.token) === null || _19 === void 0 ? void 0 : _19.fontSize}px;
417
567
 
418
568
  &:focus-within {
419
569
  --tw-shadow: 0 0 #0000;
@@ -423,31 +573,31 @@ export const GlobalStyle = () => {
423
573
  }
424
574
 
425
575
  &:first-child {
426
- border-top-left-radius: ${(_18 = THEME.token) === null || _18 === void 0 ? void 0 : _18.borderRadius}px;
427
- border-bottom-left-radius: ${(_19 = THEME.token) === null || _19 === void 0 ? void 0 : _19.borderRadius}px;
576
+ border-top-left-radius: ${(_20 = THEME.token) === null || _20 === void 0 ? void 0 : _20.borderRadius}px;
577
+ border-bottom-left-radius: ${(_21 = THEME.token) === null || _21 === void 0 ? void 0 : _21.borderRadius}px;
428
578
  }
429
579
 
430
580
  &:last-child {
431
- border-top-right-radius: ${(_20 = THEME.token) === null || _20 === void 0 ? void 0 : _20.borderRadius}px;
432
- border-bottom-right-radius: ${(_21 = THEME.token) === null || _21 === void 0 ? void 0 : _21.borderRadius}px;
581
+ border-top-right-radius: ${(_22 = THEME.token) === null || _22 === void 0 ? void 0 : _22.borderRadius}px;
582
+ border-bottom-right-radius: ${(_23 = THEME.token) === null || _23 === void 0 ? void 0 : _23.borderRadius}px;
433
583
  }
434
584
 
435
585
  &.antsomi-radio-button-wrapper-checked {
436
- border-color: ${(_22 = THEME.token) === null || _22 === void 0 ? void 0 : _22.accent1};
437
- background-color: ${(_23 = THEME.token) === null || _23 === void 0 ? void 0 : _23.colorTextActive};
438
- color: ${(_24 = THEME.token) === null || _24 === void 0 ? void 0 : _24.colorPrimary};
586
+ border-color: ${(_24 = THEME.token) === null || _24 === void 0 ? void 0 : _24.accent1};
587
+ background-color: ${(_25 = THEME.token) === null || _25 === void 0 ? void 0 : _25.colorTextActive};
588
+ color: ${(_26 = THEME.token) === null || _26 === void 0 ? void 0 : _26.colorPrimary};
439
589
  font-weight: 700;
440
590
 
441
591
  &::before {
442
- background-color: ${(_25 = THEME.token) === null || _25 === void 0 ? void 0 : _25.accent1};
592
+ background-color: ${(_27 = THEME.token) === null || _27 === void 0 ? void 0 : _27.accent1};
443
593
  }
444
594
  }
445
595
  }
446
596
 
447
597
  .antsomi-radio-wrapper {
448
598
  font-family: 'Roboto';
449
- color: ${(_26 = THEME.token) === null || _26 === void 0 ? void 0 : _26.colorTextBase};
450
- font-size: ${(_27 = THEME.token) === null || _27 === void 0 ? void 0 : _27.fontSize}px;
599
+ color: ${(_28 = THEME.token) === null || _28 === void 0 ? void 0 : _28.colorTextBase};
600
+ font-size: ${(_29 = THEME.token) === null || _29 === void 0 ? void 0 : _29.fontSize}px;
451
601
  margin-right: 0;
452
602
 
453
603
  .antsomi-radio-disabled {
@@ -478,12 +628,12 @@ export const GlobalStyle = () => {
478
628
  .antsomi-radio-inner {
479
629
  width: 16px;
480
630
  height: 16px;
481
- border-color: ${(_28 = THEME.token) === null || _28 === void 0 ? void 0 : _28.colorPrimary};
631
+ border-color: ${(_30 = THEME.token) === null || _30 === void 0 ? void 0 : _30.colorPrimary};
482
632
  border-width: 2px;
483
- background-color: ${(_29 = THEME.token) === null || _29 === void 0 ? void 0 : _29.bw0};
633
+ background-color: ${(_31 = THEME.token) === null || _31 === void 0 ? void 0 : _31.bw0};
484
634
 
485
635
  &::after {
486
- background-color: ${(_30 = THEME.token) === null || _30 === void 0 ? void 0 : _30.colorPrimary};
636
+ background-color: ${(_32 = THEME.token) === null || _32 === void 0 ? void 0 : _32.colorPrimary};
487
637
  }
488
638
  }
489
639
  }
@@ -541,7 +691,7 @@ export const GlobalStyle = () => {
541
691
 
542
692
  .antsomi-collapse {
543
693
  &.antsomi-collapse-borderless {
544
- border-bottom: 1px solid ${(_31 = THEME.token) === null || _31 === void 0 ? void 0 : _31.gray5};
694
+ border-bottom: 1px solid ${(_33 = THEME.token) === null || _33 === void 0 ? void 0 : _33.gray5};
545
695
  }
546
696
 
547
697
  > .antsomi-collapse-item > .antsomi-collapse-header .antsomi-collapse-arrow {
@@ -551,12 +701,12 @@ export const GlobalStyle = () => {
551
701
 
552
702
  /* Switch */
553
703
  .antsomi-switch {
554
- border: 2px solid ${(_32 = THEME.token) === null || _32 === void 0 ? void 0 : _32.colorPrimary} !important;
704
+ border: 2px solid ${(_34 = THEME.token) === null || _34 === void 0 ? void 0 : _34.colorPrimary} !important;
555
705
 
556
706
  &.antsomi-switch-checked {
557
707
  > .antsomi-switch-handle {
558
708
  &::before {
559
- background-color: ${(_33 = THEME.token) === null || _33 === void 0 ? void 0 : _33.bw0} !important;
709
+ background-color: ${(_35 = THEME.token) === null || _35 === void 0 ? void 0 : _35.bw0} !important;
560
710
  }
561
711
  }
562
712
  }
@@ -1,13 +1,13 @@
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
+ valueType?: ValueTypes;
5
6
  disabled?: boolean;
6
7
  dateTypeKeysShow?: string[];
7
8
  showCalculationTypeCondition?: TShowCalculationTypeCondition;
8
9
  calculationTypeKeysShow?: TCalculationType[];
9
10
  defaultDateTypeKey?: string;
10
- valueType?: string;
11
11
  option?: TOption;
12
12
  operatorKey?: TOperatorKey;
13
13
  type?: TAdvancedType;
@@ -19,7 +19,11 @@ export interface AdvancedPickerProps {
19
19
  disableBeforeDate?: string;
20
20
  errorMessage?: string;
21
21
  showTime?: boolean;
22
- onUpdatedNewDate?: (newDate: any) => void;
22
+ timezone?: string;
23
+ onUpdatedNewDate?: ({ date, option }: {
24
+ date: string;
25
+ option: TOption;
26
+ }) => void;
23
27
  onApply?: ({ date, option }: {
24
28
  date: string;
25
29
  option: TOption;