@antscorp/antsomi-ui 1.3.5-beta.710 → 1.3.5-beta.711

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.
@@ -12,6 +12,11 @@ export interface AdvancedPickerProps {
12
12
  option?: TOption;
13
13
  operatorKey?: TOperatorKey;
14
14
  type?: TAdvancedType;
15
+ /**
16
+ * This is uncontrolled value (default value) and will not update if change outside
17
+ * only update when re-render component
18
+ * use ref.forceUpdate() to control value inside
19
+ */
15
20
  date?: string;
16
21
  format?: string;
17
22
  formatInputDisplay?: string;
@@ -58,4 +63,7 @@ export interface AdvancedPickerProps {
58
63
  option: TOption;
59
64
  }) => void;
60
65
  }
61
- export declare const AdvancedPicker: React.FC<AdvancedPickerProps>;
66
+ export interface AdvancedPickerHandle {
67
+ forceUpdate: (date: string) => void;
68
+ }
69
+ export declare const AdvancedPicker: React.ForwardRefExoticComponent<AdvancedPickerProps & React.RefAttributes<AdvancedPickerHandle>>;
@@ -1,7 +1,7 @@
1
1
  var _a, _b;
2
2
  /* eslint-disable react/no-unused-prop-types */
3
3
  // Libraries
4
- import React, { useEffect, useMemo, useCallback, useState } from 'react';
4
+ import React, { useEffect, useMemo, useCallback, useState, useImperativeHandle } from 'react';
5
5
  import { Tooltip, theme, DatePicker } from 'antd';
6
6
  import dayjs from 'dayjs';
7
7
  import clsx from 'clsx';
@@ -41,7 +41,7 @@ const isDisabledSpecificTime = (current, info, disabledTime, date) => {
41
41
  const PATH = '@antscorp/antsomi-ui/es/components/molecules/DatePicker/components/Advanced/DatePickerAdvanced.tsx';
42
42
  const { useToken } = theme;
43
43
  const { Text } = Typography;
44
- export const AdvancedPicker = props => {
44
+ export const AdvancedPicker = React.forwardRef((props, componentRef) => {
45
45
  var _a, _b;
46
46
  // Props
47
47
  const { label, inputStyle, popupStyle, dateTypeKeysShow, calculationTypeKeysShow, showCalculationTypeCondition, defaultDateTypeKey, valueType, option: propsOption, operatorKey, type, date: propsDate, format, formatInputDisplay, errorMessage, disableAfterDate, disableBeforeDate, showTime, disabled, timezone, isViewMode, onlyShowFixed, disabledTime, onUpdatedNewDate, onApply, } = props;
@@ -78,10 +78,16 @@ export const AdvancedPicker = props => {
78
78
  },
79
79
  date: dayjs().tz(timezone).format(format),
80
80
  dateDisplay: dayjs().tz(timezone).format(format),
81
- // date: dayjs(propsDate).tz(timezone).format(format),
82
- // dateDisplay: dayjs(propsDate).tz(timezone).format(format),
83
81
  });
84
82
  const { isOpen, option, date, dateDisplay } = state;
83
+ useImperativeHandle(componentRef, () => ({
84
+ forceUpdate(date) {
85
+ const newDate = dayjs(date, format, true).isValid()
86
+ ? dayjs(date, format).format(format)
87
+ : date;
88
+ setState(state => (Object.assign(Object.assign({}, state), { date: newDate, dateDisplay: newDate })));
89
+ },
90
+ }), [format]);
85
91
  const isShowFixed = option.dateType.value === 'fixed' || onlyShowFixed;
86
92
  const currDate = dayjs(date, format);
87
93
  const currWeek = currDate.isoWeek();
@@ -181,6 +187,9 @@ export const AdvancedPicker = props => {
181
187
  let newDate = '';
182
188
  if (newDateType) {
183
189
  if (newDateType.value === 'fixed') {
190
+ // newDate = dayjs(innerDate, format, true).isValid()
191
+ // ? dayjs(innerDate, format).format(format)
192
+ // : innerDate;
184
193
  newDate = dayjs(propsDate, format, true).isValid()
185
194
  ? dayjs(propsDate, format).format(format)
186
195
  : propsDate;
@@ -430,7 +439,7 @@ export const AdvancedPicker = props => {
430
439
  React.createElement(Divider, null),
431
440
  timeFormat && valueType !== 'HOUR' && valueType !== 'MINUTE' ? (React.createElement(TimeLabel, { "$width": timeFormat.length * 30, "$isRangePicker": operatorKey === 'between', "$onlyShowFixed": onlyShowFixed },
432
441
  ['HH', 'HHmm', 'HHmmss'].includes(timeFormat) ? React.createElement("span", null, "Hours") : null,
433
- ['HHmm', 'HHmmss', 'mm'].includes(timeFormat) ? React.createElement("span", null, "Minutes") : null,
442
+ ['HHmm', 'HHmmss', 'mm'].includes(timeFormat) ? (React.createElement("span", null, "Minutes")) : null,
434
443
  timeFormat === 'HHmmss' ? React.createElement("span", null, "Seconds") : null)) : null));
435
444
  }, picker: getPickerRender(valueType), showTime: getTimePickerRender(valueType)
436
445
  ? {
@@ -450,7 +459,7 @@ export const AdvancedPicker = props => {
450
459
  pointerEvents: disabled ? 'none' : 'all',
451
460
  }, onClick: () => toggleOpenDropdown() },
452
461
  React.createElement(EventIcon, { width: 19, height: 19 })), style: Object.assign({ textOverflow: 'ellipsis' }, inputStyle), value: selectedDateTitle, status: errorMessage ? 'error' : '' }))))));
453
- };
462
+ });
454
463
  AdvancedPicker.defaultProps = {
455
464
  label: '',
456
465
  type: ADVANCED_PICKER_TYPE.START_DATE.value,
@@ -1,3 +1,3 @@
1
1
  export { AdvancedPicker } from './AdvancedPicker';
2
- export type { AdvancedPickerProps } from './AdvancedPicker';
2
+ export type { AdvancedPickerProps, AdvancedPickerHandle } from './AdvancedPicker';
3
3
  export type { TOption as TAdvancedPickerOption } from './types';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.5-beta.710",
3
+ "version": "1.3.5-beta.711",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",
@@ -113,10 +113,8 @@
113
113
  "react-color": "2.19.3",
114
114
  "react-cookie": "^7.1.4",
115
115
  "react-custom-scrollbars": "^4.2.1",
116
- "react-device-detect": "^2.2.3",
117
116
  "react-draggable": "^4.4.5",
118
117
  "react-frame-component": "^5.2.6",
119
- "react-google-recaptcha": "^3.1.0",
120
118
  "react-helmet": "^6.1.0",
121
119
  "react-intersection-observer": "^9.10.3",
122
120
  "react-konva": "^18.2.10",