@antscorp/antsomi-ui 1.3.3-beta.71 → 1.3.3-beta.73

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.
@@ -15,6 +15,8 @@ import { getObjectPropSafely, random, safeParse } from '@antscorp/antsomi-ui/es/
15
15
  import { convertBreakTag, convertDivToBreakTag, convertHtmlText, genShortLinkValue, getInsertLinkPatternWithAppendSpaceEnd, getInsertPatternWithAppendSpaceEnd, handleUpdateInputPersonalization, initialValue, mapLabelPersonalization, pasteHtmlAtCaret, removeHtmlTag, spacingNonTracking, validateHTMLTags, createElement, getBgColorByContentSourceType, } from './utils';
16
16
  // Hooks
17
17
  import { useDebounce } from '@antscorp/antsomi-ui/es/hooks/useDebounce';
18
+ // Constants
19
+ import { THEME } from '@antscorp/antsomi-ui/es/constants';
18
20
  const PATH = 'src/components/atoms/InputDynamic/InputDynamic.tsx';
19
21
  export const AllowDynamicType = {
20
22
  SHORTLINK: 'shortlink',
@@ -32,6 +34,7 @@ const defaultProps = {
32
34
  accountId: '1600085679',
33
35
  userId: '1600085679',
34
36
  },
37
+ disabled: false,
35
38
  showIndex: true,
36
39
  showDisplayFormat: true,
37
40
  isShowCustomFunction: true,
@@ -40,7 +43,7 @@ const defaultProps = {
40
43
  addMessageToQueue: () => { },
41
44
  };
42
45
  export const InputDynamic = (props) => {
43
- const { value, isViewMode, errors, disabledOpts, canMultipleLine, allowDynamicOptions, showIndex, showDisplayFormat, isShowCustomFunction, apiConfig, onError, onChange, addMessageToQueue, } = props;
46
+ const { value, isViewMode, errors, disabledOpts, disabled, canMultipleLine, allowDynamicOptions, showIndex, showDisplayFormat, isShowCustomFunction, apiConfig, onError, onChange, addMessageToQueue, } = props;
44
47
  // States
45
48
  const [textValue, setTextValue] = useState(initialValue(value));
46
49
  const [initSelectedProperties, setInitSelectedProperties] = useState({
@@ -125,6 +128,8 @@ export const InputDynamic = (props) => {
125
128
  setDynamicContent(prev => (Object.assign(Object.assign({}, prev), { visible: newChange })));
126
129
  }, []);
127
130
  const handleOpenChange = (newOpen) => {
131
+ if (disabled)
132
+ return;
128
133
  setDynamicContent(prev => (Object.assign(Object.assign({}, prev), { activeTagId: '' })));
129
134
  setIsShowPopover(newOpen);
130
135
  };
@@ -433,6 +438,7 @@ export const InputDynamic = (props) => {
433
438
  return allowDynamicOptions.map((dynamicKey) => (React.createElement(DynamicItem, { key: dynamicKey, onClick: e => handleClickDynamicItem(e, dynamicKey) }, mapLabelPersonalization(dynamicKey))));
434
439
  };
435
440
  const renderAddPersonalizationView = () => {
441
+ var _a, _b;
436
442
  if (isViewMode) {
437
443
  return null;
438
444
  }
@@ -442,15 +448,25 @@ export const InputDynamic = (props) => {
442
448
  const hasOnlyShortlink = isOnlyOneOpt && (allowDynamicOptions === null || allowDynamicOptions === void 0 ? void 0 : allowDynamicOptions.includes(AllowDynamicType.SHORTLINK));
443
449
  const iconPersonalization = (React.createElement(Icon, { type: "icon-ants-person-alt", onClick: e => {
444
450
  e.stopPropagation();
451
+ if (disabled || isRenderPopover)
452
+ return;
445
453
  // Open short link modal
446
454
  if (hasOnlyShortlink) {
447
455
  toggleShortLinkModal();
448
456
  }
449
- // Open Personalization modal
450
- if (hasOnlyPersonalization) {
457
+ else if (hasOnlyPersonalization) {
458
+ // Open Personalization modal
451
459
  setDynamicContent(prev => (Object.assign(Object.assign({}, prev), { activeTagId: '', visible: true })));
452
460
  }
453
- }, className: "customize-antsomi-profile", style: { width: 24, height: 24 } }));
461
+ else {
462
+ toggleShortLinkModal();
463
+ }
464
+ }, className: "customize-antsomi-profile", style: {
465
+ width: 24,
466
+ height: 24,
467
+ color: disabled ? (_a = THEME.token) === null || _a === void 0 ? void 0 : _a.colorTextDisabled : (_b = THEME.token) === null || _b === void 0 ? void 0 : _b.colorPrimary,
468
+ cursor: disabled ? 'not-allowed' : 'pointer',
469
+ } }));
454
470
  if (!isRenderPopover) {
455
471
  return iconPersonalization;
456
472
  }
@@ -12,6 +12,7 @@ export type InputDynamicProps = {
12
12
  value: string;
13
13
  isViewMode?: boolean;
14
14
  errors?: string[];
15
+ disabled?: boolean;
15
16
  disabledOpts?: DisableShortLinkTypeProps;
16
17
  allowDynamicOptions?: Array<AllowDynamicOptions>;
17
18
  showIndex?: boolean;
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable react/no-unused-prop-types */
2
2
  // Libraries
3
- import React, { useEffect, useMemo, useState } from 'react';
3
+ import React, { useMemo, useState } from 'react';
4
4
  import { Tooltip, theme } from 'antd';
5
5
  import dayjs from 'dayjs';
6
6
  import clsx from 'clsx';
@@ -183,7 +183,7 @@ export const AdvancedPicker = props => {
183
183
  });
184
184
  }
185
185
  }, [isOpen]);
186
- useEffect(() => {
186
+ useDeepCompareEffect(() => {
187
187
  try {
188
188
  if (option.dateType.value !== 'fixed') {
189
189
  const newDate = calculationDateAdvanced(option.dateType.value, option.calculationType.value, option.calculationDate.value, option.value, format);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.3-beta.71",
3
+ "version": "1.3.3-beta.73",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",
@@ -88,6 +88,7 @@
88
88
  "lodash": "^4.17.21",
89
89
  "moment": "2.29.2",
90
90
  "qs": "6.10.3",
91
+ "rc-picker": "^4.1.1",
91
92
  "react-color": "2.19.3",
92
93
  "react-draggable": "^4.4.5",
93
94
  "react-markdown": "^8.0.7",