@antscorp/antsomi-ui 1.3.6-beta.1 → 1.3.6-beta.2

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.
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { PayloadInfo } from '@antscorp/antsomi-ui/es/types';
3
2
  export type TDisplayFormat = 'number' | 'percentage' | 'currency' | 'datetime';
4
3
  type DisplayFormatProps = {
@@ -32,23 +32,23 @@ const InputSelectAttribute = (props) => {
32
32
  }
33
33
  return upperFirst(translate(translations._ITEM_NAME_ATTRIBUTE, 'attribute'));
34
34
  }, [sourceValue]);
35
- const mapCode = useMemo(() => {
35
+ const mapCodeBySource = useMemo(() => {
36
36
  if (typeof value === 'string')
37
37
  return {};
38
- return keyBy(get(mapCodeOptions, value?.code, []), 'value');
38
+ return keyBy(get(mapCodeOptions, value?.source, []), 'value');
39
39
  }, [mapCodeOptions, value]);
40
- const getCodeBySource = useCallback((source) => get(mapCodeOptions, [source, '0', 'value'], ''), [mapCodeOptions]);
40
+ const getCodeDefaultBySource = useCallback((source) => get(mapCodeOptions, [source, '0', 'value'], ''), [mapCodeOptions]);
41
41
  const onOpenModal = useCallback(() => {
42
42
  if (value && typeof value !== 'string') {
43
43
  form.setFieldsValue({ source: value?.source, code: value?.code });
44
44
  }
45
45
  else {
46
46
  const source = sourceOptions[0]?.value || '';
47
- const code = getCodeBySource(source);
47
+ const code = getCodeDefaultBySource(source);
48
48
  form.setFieldsValue({ source, code });
49
49
  }
50
50
  setOpenModal(true);
51
- }, [value, form, sourceOptions, getCodeBySource]);
51
+ }, [value, form, sourceOptions, getCodeDefaultBySource]);
52
52
  const onDeselect = useCallback(() => {
53
53
  onChange({ value: '', valueType: 'input' });
54
54
  }, [onChange]);
@@ -82,10 +82,10 @@ const InputSelectAttribute = (props) => {
82
82
  const onValuesChange = useCallback((changedValues) => {
83
83
  // If source changed -> set new code based on new source
84
84
  if (changedValues?.source) {
85
- const newCode = getCodeBySource(changedValues.source);
85
+ const newCode = getCodeDefaultBySource(changedValues.source);
86
86
  form.setFieldValue('code', newCode);
87
87
  }
88
- }, [form, getCodeBySource]);
88
+ }, [form, getCodeDefaultBySource]);
89
89
  const renderInput = () => {
90
90
  let element = null;
91
91
  const isObjValue = value && typeof value !== 'string';
@@ -97,7 +97,7 @@ const InputSelectAttribute = (props) => {
97
97
  height: 32,
98
98
  padding: '4px 12px 4px 4px',
99
99
  borderBottom: `1px solid ${errorMsg ? THEME.token?.colorError : THEME.token?.blue1}`,
100
- }, children: [_jsx("div", { style: { width: '100%', cursor: 'pointer' }, onClick: onOpenModal, children: isObjValue && (_jsx(Tag, { isError: isErrorTag, children: isErrorTag ? (_jsxs(Flex, { gap: 5, align: "center", children: ["Unknown", _jsx(Tooltip, { title: "The used dynamic content is removed", children: _jsx(ErrorIcon, { size: 16 }) })] })) : (get(mapCode, [value?.code, 'label'], value?.code)) })) }), _jsx(Icon, { type: "icon-ants-remove", style: { fontSize: 10, color: '#222', cursor: 'pointer' }, onClick: onDeselect })] }));
100
+ }, children: [_jsx("div", { style: { width: '100%', cursor: 'pointer' }, onClick: onOpenModal, children: isObjValue && (_jsx(Tag, { isError: isErrorTag, children: isErrorTag ? (_jsxs(Flex, { gap: 5, align: "center", children: ["Unknown", _jsx(Tooltip, { title: "The used dynamic content is removed", children: _jsx(ErrorIcon, { size: 16 }) })] })) : (get(mapCodeBySource, [value?.code, 'label'], value?.code)) })) }), _jsx(Icon, { type: "icon-ants-remove", style: { fontSize: 10, color: '#222', cursor: 'pointer' }, onClick: onDeselect })] }));
101
101
  }
102
102
  else {
103
103
  element = (_jsx(StyledSelect, { mode: "multiple", options: [{ value: '', label: 'Or select a field' }], notFoundContent: null, onSelect: onOpenModal, style: { width: '100%', borderTop: 'none', borderLeft: 'none', borderRight: 'none' }, onDeselect: onDeselect, autoClearSearchValue: false, searchValue: typeof value === 'string' ? value : '', onSearch: onChangeInput, status: errorMsg ? 'error' : undefined, placeholder: typeof value === 'string' ? value : translate(translations.inputYourValue.title), "$isPlaceholder": !value, "$isError": !!errorMsg, dropdownStyle: {
@@ -3,5 +3,4 @@
3
3
  * Asynchronously loads the component for TemplateListing
4
4
  *
5
5
  */
6
- /// <reference types="react" />
7
6
  export declare const TemplateListing: (props: import("./types").TemplateListingProps<{}>) => JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.6-beta.001",
3
+ "version": "1.3.6-beta.002",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",