@antscorp/antsomi-ui 2.0.4 → 2.0.6

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';
@@ -18,6 +18,7 @@ import { Button, Typography, Dropdown, ContentEditable, Modal, } from '@antscorp
18
18
  import { EditorTabStyled } from './styled';
19
19
  // Utils
20
20
  import { handleError } from '@antscorp/antsomi-ui/es/utils';
21
+ import { CloseIcon, MoreIcon } from '../../icons';
21
22
  const PATH = 'src/components/EditorTab/index.jsx';
22
23
  export const EditorTab = props => {
23
24
  var _a;
@@ -195,7 +196,7 @@ export const EditorTab = props => {
195
196
  }
196
197
  }),
197
198
  }, placement: "bottomLeft", trigger: ['click'], destroyPopupOnHide: true },
198
- React.createElement(Button, { icon: React.createElement(Icon, { type: "icon-ants-three-dot-vertical", overlayStyle: { fontSize: 12 } }), size: "small" }))) : closable ? (React.createElement(Button, { onClick: e => handleCloseTab(e, tab, idx), icon: React.createElement(Icon, { type: "icon-ants-remove-slim", overlayStyle: { fontSize: 12 } }), size: "small" })) : null));
199
+ React.createElement(Button, { icon: React.createElement(MoreIcon, { size: 20 }), size: "small" }))) : closable ? (React.createElement(Button, { onClick: e => handleCloseTab(e, tab, idx), icon: React.createElement(CloseIcon, { size: 20 }), size: "small" })) : null));
199
200
  })
200
201
  : null,
201
202
  React.createElement("div", { ref: anchorRightElRef })),
@@ -113,15 +113,15 @@ export const HeaderV2 = memo(props => {
113
113
  showLogo && (React.createElement(LogoWrapper, { className: "logo-wrapper", onClick: onCLickLogo },
114
114
  React.createElement("img", { src: SubLogoAntsomi, alt: "Antsomi sub logo" }))),
115
115
  React.createElement(AccountSelection, Object.assign({}, accountSelectionProps, { currentAccount: selectedAccount, apiConfig: accountSelectionApiConfig, onChange: handleChangeAccount, inputStyle: inputStyle, refreshOnSelect: true })),
116
- React.createElement("div", { className: "title-container" },
117
- breadcrumbs ? (React.createElement("div", { className: "header-breadcrumbs" }, breadcrumbs.map((item, index) => (React.createElement(React.Fragment, { key: `${item.title}_${item.link}` },
116
+ React.createElement("div", { className: "title-container", "data-test": "page-title" },
117
+ breadcrumbs ? (React.createElement("div", { className: "header-breadcrumbs", "data-test": "breadcrumbs" }, breadcrumbs.map((item, index) => (React.createElement(React.Fragment, { key: `${item.title}_${item.link}` },
118
118
  isNil(item.useExternalLink) && !item.useExternalLink ? (React.createElement(Link, { to: item.link || '', className: "header-breadcrumbs__item" }, item.title)) : (React.createElement("a", { href: item.link, className: "header-breadcrumbs__item" }, item.title)),
119
119
  breadcrumbs.length === index + 1 ? null : React.createElement(React.Fragment, null,
120
120
  "\u2002",
121
121
  QUOTE_ENTITY,
122
122
  "\u2002")))))) : null,
123
123
  typeof pageTitle === 'string' ? (React.createElement("div", { className: "page-title" }, pageTitle)) : (pageTitle))),
124
- React.createElement("div", { className: "right-side" },
124
+ React.createElement("div", { "data-test": "header-menu", className: "right-side" },
125
125
  React.createElement(Flex, { gap: 10 },
126
126
  rightContent,
127
127
  showHelp ? React.createElement(Help, Object.assign({ configs: helpConfigProps }, helpProps)) : null,
@@ -245,7 +245,7 @@ export function MatchesAny(props) {
245
245
  React.createElement(Flex, { align: "center", gap: 10 },
246
246
  renderExtraValueLabels(),
247
247
  React.createElement(TextButton, { disabled: isDisableSelectAll, onClick: onSelectAll }, t(translations.global.selectAll).toString()))),
248
- React.createElement(Spin, { spinning: loading }, (treeData === null || treeData === void 0 ? void 0 : treeData.length) ? (React.createElement(React.Fragment, null,
248
+ React.createElement(Spin, { spinning: loading }, (treeData === null || treeData === void 0 ? void 0 : treeData.length) > 1 ? (React.createElement(React.Fragment, null,
249
249
  React.createElement(StyledTree, { key: searchValue, defaultExpandedKeys: (matchedParents === null || matchedParents === void 0 ? void 0 : matchedParents.length)
250
250
  ? matchedParents.map(item => item.key)
251
251
  : items === null || items === void 0 ? void 0 : items.map(item => item.key), selectable: false, treeData: treeData, switcherIcon: props => (React.createElement(Icon, { type: "icon-ants-caret-down", style: {
@@ -137,7 +137,7 @@ const Help = props => {
137
137
  type: 'divider',
138
138
  },
139
139
  {
140
- label: (React.createElement("a", { href: `${domainTicket}/${portalId}/#/${userId}/tickets`, target: "_blank", rel: "noreferrer" },
140
+ label: (React.createElement("a", { href: `${domainTicket}/${portalId}/#/${userId}/tickets`, target: "_blank", rel: "noreferrer", style: { textDecoration: 'none' } },
141
141
  React.createElement(Label, { className: "verify-support" }, "Verify support request"))),
142
142
  key: MENU_KEYS.SUPPORT,
143
143
  },
@@ -81,9 +81,9 @@ export const TemplateListing = memo(props => {
81
81
  previewBtnProps: Object.assign(Object.assign({}, previewBtnProps), { onClick: handleClickThumbnailPreview }) }, restOfTemplateItemProps))));
82
82
  }))),
83
83
  !loading && !blankTemplateProps.show && !isHasData && (React.createElement(EmptyData, { icon: emptyProps === null || emptyProps === void 0 ? void 0 : emptyProps.icon, title: emptyProps === null || emptyProps === void 0 ? void 0 : emptyProps.description })))));
84
- return (React.createElement(TemplateListingWrapper, null,
85
- React.createElement(CategoryListing, Object.assign({}, categoryListingProps, { emptyProps: emptyProps })),
86
- React.createElement(TemplateWrapper, { className: wrapperClassName, style: wrapperStyle },
84
+ return (React.createElement(TemplateListingWrapper, { "data-test": "template-listing-component" },
85
+ React.createElement(CategoryListing, Object.assign({}, categoryListingProps, { emptyProps: emptyProps, "data-test": "template-listing-categories" })),
86
+ React.createElement(TemplateWrapper, { className: wrapperClassName, style: wrapperStyle, "data-test": "template-listing-container" },
87
87
  header,
88
88
  content
89
89
  ? typeof content === 'function'
@@ -9,6 +9,13 @@ export declare const CDP_API: {
9
9
  staging: string;
10
10
  production: string;
11
11
  };
12
+ export declare const ANTALYSER_API: {
13
+ development: string;
14
+ sandbox: string;
15
+ "sandbox-cdp": string;
16
+ staging: string;
17
+ production: string;
18
+ };
12
19
  export declare const CDP_ROUTE: {
13
20
  sandbox: string;
14
21
  "sandbox-cdp": string;
@@ -13,6 +13,13 @@ export const CDP_API = {
13
13
  [ENV.STAGING]: 'https://staging-cdp.antsomi.com',
14
14
  [ENV.PROD]: 'https://cdp.antsomi.com',
15
15
  };
16
+ export const ANTALYSER_API = {
17
+ [ENV.DEV]: 'https://sandbox-antalyser.ants.vn',
18
+ [ENV.SANDBOX]: 'https://sandbox-antalyser.ants.vn',
19
+ [ENV.SANDBOX_CDP]: 'https://sandbox-antalyser.ants.vn',
20
+ [ENV.STAGING]: 'https://sandbox-antalyser.ants.vn',
21
+ [ENV.PROD]: 'https://sandbox-antalyser.ants.vn',
22
+ };
16
23
  export const CDP_ROUTE = {
17
24
  [ENV.SANDBOX]: 'https://sandbox-cdp.antsomi.com',
18
25
  [ENV.SANDBOX_CDP]: 'https://sandbox-cdp.antsomi.com',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "2.0.4",
3
+ "version": "2.0.6",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",