@antscorp/antsomi-ui 1.3.6-beta.3 → 1.3.6-beta.30

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 (91) hide show
  1. package/es/components/atoms/Input/Input.d.ts +11 -17
  2. package/es/components/atoms/Input/Input.js +7 -11
  3. package/es/components/atoms/Switch/Switch.js +2 -1
  4. package/es/components/icons/LazyIcon/LazyIcon.d.ts +2 -0
  5. package/es/components/icons/LazyIcon/LazyIcon.js +2 -0
  6. package/es/components/icons/TaskAltIcon.d.ts +3 -0
  7. package/es/components/icons/TaskAltIcon.js +7 -0
  8. package/es/components/icons/UnsubscribeIcon.d.ts +3 -0
  9. package/es/components/icons/UnsubscribeIcon.js +7 -0
  10. package/es/components/icons/index.d.ts +2 -0
  11. package/es/components/icons/index.js +2 -0
  12. package/es/components/molecules/AddDynamicContent/components/DisplayFormat/DisplayFormat.d.ts +1 -0
  13. package/es/components/molecules/CodeStructure/CodeStructure.d.ts +23 -2
  14. package/es/components/molecules/CodeStructure/CodeStructure.js +136 -26
  15. package/es/components/molecules/CodeStructure/constants.js +2 -2
  16. package/es/components/molecules/CodeStructure/styled.d.ts +3 -0
  17. package/es/components/molecules/CodeStructure/styled.js +6 -0
  18. package/es/components/molecules/CodeStructure/type.d.ts +2 -2
  19. package/es/components/molecules/CodeStructure/type.js +2 -2
  20. package/es/components/molecules/CodeStructure/utils.d.ts +12 -2
  21. package/es/components/molecules/CodeStructure/utils.js +5 -3
  22. package/es/components/molecules/DrawerDetail/DrawerDetail.js +10 -5
  23. package/es/components/molecules/DrawerDetail/types.d.ts +1 -0
  24. package/es/components/molecules/Dropdown/style.scss +6 -4
  25. package/es/components/molecules/EditingListV2/EditingList.d.ts +2 -0
  26. package/es/components/molecules/EditingListV2/EditingList.js +17 -0
  27. package/es/components/molecules/EditingListV2/components/List/List.d.ts +9 -0
  28. package/es/components/molecules/EditingListV2/components/List/List.js +42 -0
  29. package/es/components/molecules/EditingListV2/components/List/index.d.ts +1 -0
  30. package/es/components/molecules/EditingListV2/components/List/index.js +1 -0
  31. package/es/components/molecules/EditingListV2/components/Loadable.d.ts +8 -0
  32. package/es/components/molecules/EditingListV2/components/Loadable.js +2 -0
  33. package/es/components/molecules/EditingListV2/components/Popover/Popover.d.ts +11 -0
  34. package/es/components/molecules/EditingListV2/components/Popover/Popover.js +10 -0
  35. package/es/components/molecules/EditingListV2/components/Popover/index.d.ts +1 -0
  36. package/es/components/molecules/EditingListV2/components/Popover/index.js +1 -0
  37. package/es/components/molecules/EditingListV2/components/index.d.ts +3 -0
  38. package/es/components/molecules/EditingListV2/components/index.js +3 -0
  39. package/es/components/molecules/EditingListV2/index.d.ts +2 -0
  40. package/es/components/molecules/EditingListV2/index.js +1 -0
  41. package/es/components/molecules/EditingListV2/types.d.ts +19 -0
  42. package/es/components/molecules/EditingListV2/types.js +1 -0
  43. package/es/components/molecules/EditingListV2/utils.d.ts +27 -0
  44. package/es/components/molecules/EditingListV2/utils.js +28 -0
  45. package/es/components/molecules/InputSelectAttribute/index.js +5 -2
  46. package/es/components/molecules/SearchPopover/components/PopoverAddField/PopoverAddField.js +2 -2
  47. package/es/components/molecules/SearchPopover/components/PopoverSelect/PopoverSelect.js +4 -4
  48. package/es/components/molecules/SearchPopover/types.d.ts +1 -0
  49. package/es/components/molecules/TagifyInput/TagifyInput.js +5 -3
  50. package/es/components/molecules/index.d.ts +1 -0
  51. package/es/components/molecules/index.js +1 -0
  52. package/es/components/organism/TicketEditorV2/Content.d.ts +27 -0
  53. package/es/components/organism/TicketEditorV2/Content.js +296 -0
  54. package/es/components/organism/TicketEditorV2/Service.d.ts +49 -0
  55. package/es/components/organism/TicketEditorV2/Service.js +58 -0
  56. package/es/components/organism/TicketEditorV2/TicketEditorV2.d.ts +20 -0
  57. package/es/components/organism/TicketEditorV2/TicketEditorV2.js +124 -0
  58. package/es/components/organism/TicketEditorV2/components/DropdownComponent.d.ts +9 -0
  59. package/es/components/organism/TicketEditorV2/components/DropdownComponent.js +45 -0
  60. package/es/components/organism/TicketEditorV2/components/Message.d.ts +2 -0
  61. package/es/components/organism/TicketEditorV2/components/Message.js +31 -0
  62. package/es/components/organism/TicketEditorV2/components/MessageComponent.d.ts +10 -0
  63. package/es/components/organism/TicketEditorV2/components/MessageComponent.js +64 -0
  64. package/es/components/organism/TicketEditorV2/components/icons/AddTicketIcon.d.ts +2 -0
  65. package/es/components/organism/TicketEditorV2/components/icons/AddTicketIcon.js +5 -0
  66. package/es/components/organism/TicketEditorV2/components/icons/TicketIcon.d.ts +2 -0
  67. package/es/components/organism/TicketEditorV2/components/icons/TicketIcon.js +5 -0
  68. package/es/components/organism/TicketEditorV2/constant.d.ts +17 -0
  69. package/es/components/organism/TicketEditorV2/constant.js +17 -0
  70. package/es/components/organism/TicketEditorV2/constants/index.d.ts +1 -0
  71. package/es/components/organism/TicketEditorV2/constants/index.js +1 -0
  72. package/es/components/organism/TicketEditorV2/constants/queryKeys.d.ts +5 -0
  73. package/es/components/organism/TicketEditorV2/constants/queryKeys.js +5 -0
  74. package/es/components/organism/TicketEditorV2/index.d.ts +1 -0
  75. package/es/components/organism/TicketEditorV2/index.js +1 -0
  76. package/es/components/organism/TicketEditorV2/queries/index.d.ts +3 -0
  77. package/es/components/organism/TicketEditorV2/queries/index.js +3 -0
  78. package/es/components/organism/TicketEditorV2/queries/useGetDetailTicket.d.ts +12 -0
  79. package/es/components/organism/TicketEditorV2/queries/useGetDetailTicket.js +14 -0
  80. package/es/components/organism/TicketEditorV2/queries/useGetListComments.d.ts +13 -0
  81. package/es/components/organism/TicketEditorV2/queries/useGetListComments.js +18 -0
  82. package/es/components/organism/TicketEditorV2/queries/useGetListUser.d.ts +11 -0
  83. package/es/components/organism/TicketEditorV2/queries/useGetListUser.js +14 -0
  84. package/es/components/organism/TicketEditorV2/styled.d.ts +54 -0
  85. package/es/components/organism/TicketEditorV2/styled.js +871 -0
  86. package/es/components/organism/TicketEditorV2/util.d.ts +46 -0
  87. package/es/components/organism/TicketEditorV2/util.js +408 -0
  88. package/es/components/organism/index.d.ts +1 -0
  89. package/es/components/organism/index.js +1 -0
  90. package/es/components/template/TemplateListing/Loadable.d.ts +1 -0
  91. package/package.json +2 -2
@@ -1,6 +1,5 @@
1
- /// <reference types="hoist-non-react-statics" />
2
1
  import React, { ReactNode } from 'react';
3
- import { InputProps as AntdInputProps, Input as AntdInput, InputRef } from 'antd';
2
+ import { InputProps as AntdInputProps, InputRef } from 'antd';
4
3
  export interface InputProps extends AntdInputProps {
5
4
  noborder?: 'true' | 'false' | boolean;
6
5
  debounce?: number;
@@ -16,20 +15,15 @@ export interface InputProps extends AntdInputProps {
16
15
  disableUndo?: boolean;
17
16
  withWrapper?: boolean;
18
17
  }
19
- export declare const Input: string & import("styled-components").StyledComponentBase<React.ForwardRefExoticComponent<AntdInputProps & React.RefAttributes<InputRef>> & {
20
- Group: React.FC<import("antd/es/input").GroupProps>;
21
- Search: React.ForwardRefExoticComponent<import("antd/es/input").SearchProps & React.RefAttributes<InputRef>>;
22
- TextArea: React.ForwardRefExoticComponent<import("antd/es/input").TextAreaProps & React.RefAttributes<import("antd/es/input/TextArea").TextAreaRef>>;
23
- Password: React.ForwardRefExoticComponent<import("antd/es/input").PasswordProps & React.RefAttributes<InputRef>>;
24
- }, any, InputProps, never> & import("hoist-non-react-statics").NonReactStatics<React.ForwardRefExoticComponent<AntdInputProps & React.RefAttributes<InputRef>> & {
25
- Group: React.FC<import("antd/es/input").GroupProps>;
26
- Search: React.ForwardRefExoticComponent<import("antd/es/input").SearchProps & React.RefAttributes<InputRef>>;
27
- TextArea: React.ForwardRefExoticComponent<import("antd/es/input").TextAreaProps & React.RefAttributes<import("antd/es/input/TextArea").TextAreaRef>>;
28
- Password: React.ForwardRefExoticComponent<import("antd/es/input").PasswordProps & React.RefAttributes<InputRef>>;
29
- }, {}> & {
30
- DefaultInput: typeof AntdInput;
31
- CustomSearch: typeof SearchInput;
18
+ export declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<InputRef>> & {
19
+ readonly DefaultInput: React.ForwardRefExoticComponent<AntdInputProps & React.RefAttributes<InputRef>> & {
20
+ Group: React.FC<import("antd/es/input").GroupProps>;
21
+ Search: React.ForwardRefExoticComponent<import("antd/es/input").SearchProps & React.RefAttributes<InputRef>>;
22
+ TextArea: React.ForwardRefExoticComponent<import("antd/es/input").TextAreaProps & React.RefAttributes<import("antd/es/input/TextArea").TextAreaRef>>;
23
+ Password: React.ForwardRefExoticComponent<import("antd/es/input").PasswordProps & React.RefAttributes<InputRef>>;
24
+ };
25
+ readonly CustomSearch: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<InputRef>>;
26
+ readonly TextArea: React.ForwardRefExoticComponent<import("antd/es/input").TextAreaProps & React.RefAttributes<import("antd/es/input/TextArea").TextAreaRef>>;
27
+ readonly Password: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<InputRef>>;
32
28
  };
33
- declare const SearchInput: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<InputRef>>;
34
29
  export declare const TextArea: React.ForwardRefExoticComponent<import("antd/es/input").TextAreaProps & React.RefAttributes<import("antd/es/input/TextArea").TextAreaRef>>;
35
- export {};
@@ -17,7 +17,7 @@ import { PreviewVisibilityEyeIcon, VisibilityOffEyeIcon } from '../../icons';
17
17
  const PATH = '@antscorp/antsomi-ui/es/components/atoms/Input/Input.tsx';
18
18
  const OriginInput = React.forwardRef((props, ref) => {
19
19
  // Props
20
- const { withWrapper, debounce, errorArchive, required, labelColor, isReverseMask, isHideErrMessage, focused, label, onAfterChange, onChange, errorMsg, ...restProps } = props;
20
+ const { debounce = 400, isHideErrMessage = false, withWrapper = true, errorArchive, required, labelColor, isReverseMask, focused, label, onAfterChange, onChange, errorMsg, ...restProps } = props;
21
21
  // State
22
22
  const [value, setValue] = useState(props.value);
23
23
  const [isFocused, setFocused] = useState(false);
@@ -79,16 +79,12 @@ const OriginInput = React.forwardRef((props, ref) => {
79
79
  return content;
80
80
  return _jsx("div", { className: "input__wrapper", children: content });
81
81
  });
82
- OriginInput.defaultProps = {
83
- debounce: 400,
84
- isHideErrMessage: false,
85
- withWrapper: true,
86
- };
87
- export const Input = OriginInput;
88
82
  const SearchInput = React.forwardRef((props, ref) => (_jsx(OriginInput, { bordered: false, autoFocus: true, suffix: _jsx(Icon, { type: "icon-ants-search-2", size: 24, color: globalToken?.bw8 }), ...props, ref: ref, className: `${props.className} antsomi-search-input` })));
89
83
  const PasswordInput = React.forwardRef((props, ref) => (_jsx(AntdInput.Password, { iconRender: visible => visible ? (_jsx(StyledIconWrapper, { type: "text", children: _jsx(PreviewVisibilityEyeIcon, {}) })) : (_jsx(StyledIconWrapper, { type: "text", children: _jsx(VisibilityOffEyeIcon, {}) })), ...props, ref: ref })));
90
- Input.CustomSearch = SearchInput;
91
- Input.TextArea = StyledInput.TextArea;
92
- Input.DefaultInput = AntdInput;
93
- Input.Password = PasswordInput;
84
+ export const Input = Object.assign(OriginInput, {
85
+ DefaultInput: AntdInput,
86
+ CustomSearch: SearchInput,
87
+ TextArea: StyledInput.TextArea,
88
+ Password: PasswordInput,
89
+ });
94
90
  export const { TextArea } = StyledInput;
@@ -3,6 +3,7 @@ import { THEME } from '@antscorp/antsomi-ui/es/constants';
3
3
  import { StyledSwitch } from './styled';
4
4
  const Switch = props => {
5
5
  const { color = THEME.token?.colorPrimary || '#005eb8', style, ...rest } = props;
6
- return _jsx(StyledSwitch, { style: { ...style, '--switch-color': color }, ...rest });
6
+ const validatedColor = CSS.supports('color', color) ? color : THEME.token?.colorPrimary;
7
+ return _jsx(StyledSwitch, { style: { ...style, '--switch-color': validatedColor }, ...rest });
7
8
  };
8
9
  export { Switch };
@@ -346,6 +346,7 @@ export declare const LazyIcon: {
346
346
  TabGroupIcon: import("react").LazyExoticComponent<import("react").ForwardRefExoticComponent<import("../types").IconProps & import("react").RefAttributes<SVGSVGElement>>>;
347
347
  TableIcon: import("react").LazyExoticComponent<import("react").ForwardRefExoticComponent<import("../types").IconProps & import("react").RefAttributes<SVGSVGElement>>>;
348
348
  TableVer2Icon: import("react").LazyExoticComponent<import("react").ForwardRefExoticComponent<import("../types").IconProps & import("react").RefAttributes<SVGSVGElement>>>;
349
+ TaskAltIcon: import("react").LazyExoticComponent<import("react").ForwardRefExoticComponent<import("../types").IconProps & import("react").RefAttributes<SVGSVGElement>>>;
349
350
  TextIcon: import("react").LazyExoticComponent<import("react").ForwardRefExoticComponent<import("../types").IconProps & import("react").RefAttributes<SVGSVGElement>>>;
350
351
  ThirdPartyPluginV130Icon: import("react").LazyExoticComponent<import("react").ForwardRefExoticComponent<import("../types").IconProps & import("react").RefAttributes<SVGSVGElement>>>;
351
352
  ThirdPartyPluginV230Icon: import("react").LazyExoticComponent<import("react").ForwardRefExoticComponent<import("../types").IconProps & import("react").RefAttributes<SVGSVGElement>>>;
@@ -360,6 +361,7 @@ export declare const LazyIcon: {
360
361
  UnblockIcon: import("react").LazyExoticComponent<import("react").ForwardRefExoticComponent<import("../types").IconProps & import("react").RefAttributes<SVGSVGElement>>>;
361
362
  UndoIcon: import("react").LazyExoticComponent<import("react").ForwardRefExoticComponent<import("../types").IconProps & import("react").RefAttributes<SVGSVGElement>>>;
362
363
  Unknown30Icon: import("react").LazyExoticComponent<import("react").ForwardRefExoticComponent<import("../types").IconProps & import("react").RefAttributes<SVGSVGElement>>>;
364
+ UnsubscribeIcon: import("react").LazyExoticComponent<import("react").ForwardRefExoticComponent<import("../types").IconProps & import("react").RefAttributes<SVGSVGElement>>>;
363
365
  UploadIcon: import("react").LazyExoticComponent<import("react").ForwardRefExoticComponent<import("../types").IconProps & import("react").RefAttributes<SVGSVGElement>>>;
364
366
  UploadMenuIcon: import("react").LazyExoticComponent<import("react").ForwardRefExoticComponent<import("../types").IconProps & import("react").RefAttributes<SVGSVGElement>>>;
365
367
  UserActivityIcon: import("react").LazyExoticComponent<import("react").ForwardRefExoticComponent<import("../types").IconProps & import("react").RefAttributes<SVGSVGElement>>>;
@@ -352,6 +352,7 @@ export const LazyIcon = {
352
352
  TabGroupIcon: lazy(() => import('../TabGroupIcon').then(m => ({ default: m.TabGroupIcon }))),
353
353
  TableIcon: lazy(() => import('../TableIcon').then(m => ({ default: m.TableIcon }))),
354
354
  TableVer2Icon: lazy(() => import('../TableVer2Icon').then(m => ({ default: m.TableVer2Icon }))),
355
+ TaskAltIcon: lazy(() => import('../TaskAltIcon').then(m => ({ default: m.TaskAltIcon }))),
355
356
  TextIcon: lazy(() => import('../TextIcon').then(m => ({ default: m.TextIcon }))),
356
357
  ThirdPartyPluginV130Icon: lazy(() => import('../ThirdPartyPluginV130Icon').then(m => ({ default: m.ThirdPartyPluginV130Icon }))),
357
358
  ThirdPartyPluginV230Icon: lazy(() => import('../ThirdPartyPluginV230Icon').then(m => ({ default: m.ThirdPartyPluginV230Icon }))),
@@ -366,6 +367,7 @@ export const LazyIcon = {
366
367
  UnblockIcon: lazy(() => import('../UnblockIcon').then(m => ({ default: m.UnblockIcon }))),
367
368
  UndoIcon: lazy(() => import('../UndoIcon').then(m => ({ default: m.UndoIcon }))),
368
369
  Unknown30Icon: lazy(() => import('../Unknown30Icon').then(m => ({ default: m.Unknown30Icon }))),
370
+ UnsubscribeIcon: lazy(() => import('../UnsubscribeIcon').then(m => ({ default: m.UnsubscribeIcon }))),
369
371
  UploadIcon: lazy(() => import('../UploadIcon').then(m => ({ default: m.UploadIcon }))),
370
372
  UploadMenuIcon: lazy(() => import('../UploadMenuIcon').then(m => ({ default: m.UploadMenuIcon }))),
371
373
  UserActivityIcon: lazy(() => import('../UserActivityIcon').then(m => ({ default: m.UserActivityIcon }))),
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import { IconProps } from './types';
3
+ export declare const TaskAltIcon: React.ForwardRefExoticComponent<IconProps & React.RefAttributes<SVGSVGElement>>;
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from 'react';
3
+ import { useIcon } from './hooks/useIcon';
4
+ export const TaskAltIcon = forwardRef((props, ref) => {
5
+ const { width, height } = useIcon(props);
6
+ return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 -960 960 960", fill: "currentColor", ...props, ref: ref, width: width, height: height, children: _jsx("path", { d: "M480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q65 0 123 19t107 53l-58 59q-38-24-81-37.5T480-800q-133 0-226.5 93.5T160-480q0 133 93.5 226.5T480-160q133 0 226.5-93.5T800-480q0-18-2-36t-6-35l65-65q11 32 17 66t6 70q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm-56-216L254-466l56-56 114 114 400-401 56 56-456 457Z" }) }));
7
+ });
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import { IconProps } from './types';
3
+ export declare const UnsubscribeIcon: React.ForwardRefExoticComponent<IconProps & React.RefAttributes<SVGSVGElement>>;
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from 'react';
3
+ import { useIcon } from './hooks/useIcon';
4
+ export const UnsubscribeIcon = forwardRef((props, ref) => {
5
+ const { width, height } = useIcon(props);
6
+ return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 -960 960 960", fill: "currentColor", ...props, ref: ref, width: width, height: height, children: _jsx("path", { d: "M480-440 160-640v400h320q0 21 3 40.5t9 39.5H160q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h640q33 0 56.5 23.5T880-720v228q-18-9-38.5-15t-41.5-9v-124L480-440Zm0-80 320-200H160l320 200ZM760-40q-83 0-141.5-58.5T560-240q0-83 58.5-141.5T760-440q83 0 141.5 58.5T960-240q0 83-58.5 141.5T760-40ZM640-220h240v-40H640v40Zm-480-20v-480 480Z" }) }));
7
+ });
@@ -342,6 +342,7 @@ export { SystemRunningIcon } from './SystemRunningIcon';
342
342
  export { TabGroupIcon } from './TabGroupIcon';
343
343
  export { TableIcon } from './TableIcon';
344
344
  export { TableVer2Icon } from './TableVer2Icon';
345
+ export { TaskAltIcon } from './TaskAltIcon';
345
346
  export { TextIcon } from './TextIcon';
346
347
  export { ThirdPartyPluginV130Icon } from './ThirdPartyPluginV130Icon';
347
348
  export { ThirdPartyPluginV230Icon } from './ThirdPartyPluginV230Icon';
@@ -356,6 +357,7 @@ export { TipsIdeaLight30Icon } from './TipsIdeaLight30Icon';
356
357
  export { UnblockIcon } from './UnblockIcon';
357
358
  export { UndoIcon } from './UndoIcon';
358
359
  export { Unknown30Icon } from './Unknown30Icon';
360
+ export { UnsubscribeIcon } from './UnsubscribeIcon';
359
361
  export { UploadIcon } from './UploadIcon';
360
362
  export { UploadMenuIcon } from './UploadMenuIcon';
361
363
  export { UserActivityIcon } from './UserActivityIcon';
@@ -342,6 +342,7 @@ export { SystemRunningIcon } from './SystemRunningIcon';
342
342
  export { TabGroupIcon } from './TabGroupIcon';
343
343
  export { TableIcon } from './TableIcon';
344
344
  export { TableVer2Icon } from './TableVer2Icon';
345
+ export { TaskAltIcon } from './TaskAltIcon';
345
346
  export { TextIcon } from './TextIcon';
346
347
  export { ThirdPartyPluginV130Icon } from './ThirdPartyPluginV130Icon';
347
348
  export { ThirdPartyPluginV230Icon } from './ThirdPartyPluginV230Icon';
@@ -356,6 +357,7 @@ export { TipsIdeaLight30Icon } from './TipsIdeaLight30Icon';
356
357
  export { UnblockIcon } from './UnblockIcon';
357
358
  export { UndoIcon } from './UndoIcon';
358
359
  export { Unknown30Icon } from './Unknown30Icon';
360
+ export { UnsubscribeIcon } from './UnsubscribeIcon';
359
361
  export { UploadIcon } from './UploadIcon';
360
362
  export { UploadMenuIcon } from './UploadMenuIcon';
361
363
  export { UserActivityIcon } from './UserActivityIcon';
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import type { PayloadInfo } from '@antscorp/antsomi-ui/es/types';
2
3
  export type TDisplayFormat = 'number' | 'percentage' | 'currency' | 'datetime';
3
4
  type DisplayFormatProps = {
@@ -1,11 +1,32 @@
1
1
  import React from 'react';
2
2
  import { CodeStructureData } from './type';
3
3
  interface CodeStructureProps {
4
- initialData: CodeStructureData;
4
+ initialData: Partial<CodeStructureData>;
5
5
  onChange: ({ data, isError }: {
6
- data: CodeStructureData;
6
+ data: Partial<CodeStructureData>;
7
7
  isError: boolean;
8
8
  }) => void;
9
9
  }
10
+ /**
11
+ * Component to configure the code structure for a pool rule.
12
+ *
13
+ * The component contains a form with fields for:
14
+ * - Prefix
15
+ * - Infix (character type, number of digits, number of letters, capitalization, character order)
16
+ * - Suffix
17
+ * - Separator
18
+ * - Quantity (number of codes per time)
19
+ * - Refill interval (manual or automatic)
20
+ * - Refill threshold (number of codes remaining)
21
+ * - Refill unit (codes or percent)
22
+ *
23
+ * The form also displays a preview of the generated code sample.
24
+ *
25
+ * The component calls the `onChange` callback with the updated form values and an `isError` flag
26
+ * indicating whether the form is valid or not.
27
+ *
28
+ * @param {CodeStructureProps} props The component props.
29
+ * @returns {React.ReactElement} The rendered component.
30
+ */
10
31
  export declare const CodeStructure: React.FC<CodeStructureProps>;
11
32
  export {};
@@ -1,20 +1,42 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  // Libraries
3
- import { useEffect } from 'react';
3
+ import { memo, useEffect } from 'react';
4
4
  import { Form, InputNumber, Radio, Select, Typography, Flex, Input, Row, Col } from 'antd';
5
5
  import { useImmer } from 'use-immer';
6
6
  import { translate, translations } from '@antscorp/antsomi-locales';
7
+ import { isEmpty } from 'lodash';
7
8
  // Utils
8
9
  import { calculateTotalCodes, generateCodeWithPrefixAndSuffix, generateRandomCodeWithConfig, } from './utils';
9
10
  // Types
10
11
  import { CapitalizationType, CharacterOrderType, CharacterType, RefillType, RefillUnitType, SeparatorType, } from './type';
11
12
  // Constants
12
13
  import { CAPITALIZATION_OPTIONS, CHARACTER_ORDER_OPTIONS, CHARACTER_TYPE_OPTIONS, REFILL_UNIT_OPTIONS, SEPARATOR_OPTIONS, } from './constants';
13
- import { CodeStructureWrapper } from './styled';
14
+ import { BlockAbsolute, CodeStructureWrapper } from './styled';
14
15
  import { useDebouncedCallbackV2 } from '@antscorp/antsomi-ui/es/hooks';
15
16
  const { Title } = Typography;
16
- export const CodeStructure = ({ initialData, onChange }) => {
17
- const { characterType = CharacterType.DIGIT_AND_LETTERS, digitalNumbers = 2, alphabetLetters = 3, capitalization = CapitalizationType.UPPERCASE, characterOrder = CharacterOrderType.RANDOM, separator = SeparatorType.UNDERSCORE, quantity = 1, suffix = '', refillInterval = RefillType.MANUAL, prefix = '', refillThreshold = 10, refillUnit = RefillUnitType.CODES, } = initialData;
17
+ /**
18
+ * Component to configure the code structure for a pool rule.
19
+ *
20
+ * The component contains a form with fields for:
21
+ * - Prefix
22
+ * - Infix (character type, number of digits, number of letters, capitalization, character order)
23
+ * - Suffix
24
+ * - Separator
25
+ * - Quantity (number of codes per time)
26
+ * - Refill interval (manual or automatic)
27
+ * - Refill threshold (number of codes remaining)
28
+ * - Refill unit (codes or percent)
29
+ *
30
+ * The form also displays a preview of the generated code sample.
31
+ *
32
+ * The component calls the `onChange` callback with the updated form values and an `isError` flag
33
+ * indicating whether the form is valid or not.
34
+ *
35
+ * @param {CodeStructureProps} props The component props.
36
+ * @returns {React.ReactElement} The rendered component.
37
+ */
38
+ export const CodeStructure = memo(({ initialData, onChange }) => {
39
+ const { characterType = CharacterType.DIGIT_AND_LETTERS, digitalNumbers = 2, alphabetLetters = 3, capitalization = CapitalizationType.UPPERCASE, characterOrder = CharacterOrderType.RANDOM, separator = SeparatorType.UNDERSCORE, quantity = 50, suffix = '', refillInterval = RefillType.MANUAL, prefix = '', refillThreshold = 10, refillUnit = RefillUnitType.CODES, } = initialData;
18
40
  const [form] = Form.useForm();
19
41
  const [state, setState] = useImmer({
20
42
  codeSample: '',
@@ -42,7 +64,7 @@ export const CodeStructure = ({ initialData, onChange }) => {
42
64
  draft.codeWithPrefixAndSuffix = value;
43
65
  });
44
66
  };
45
- const debouncedOnChange = useDebouncedCallbackV2(onChange, 350);
67
+ const debouncedOnChange = useDebouncedCallbackV2(onChange, 400);
46
68
  const updateFormValues = async (fieldKeyChange, isError) => {
47
69
  // Get all values from the form
48
70
  const allValues = form.getFieldsValue();
@@ -63,18 +85,52 @@ export const CodeStructure = ({ initialData, onChange }) => {
63
85
  fieldKeyChange !== 'separator';
64
86
  const isChangePrefix = fieldKeyChange === 'suffix' || fieldKeyChange === 'prefix' || fieldKeyChange === 'separator';
65
87
  if (isRelevantChangeMaxCode) {
66
- const total = calculateTotalCodes(numLetters, numDigits, type);
88
+ const total = calculateTotalCodes({
89
+ numberOfLetters: characterType === CharacterType.DIGIT_AND_LETTERS ||
90
+ characterType === CharacterType.LETTERS
91
+ ? numLetters
92
+ : 0,
93
+ numberOfDigits: characterType === CharacterType.DIGITS ||
94
+ characterType === CharacterType.DIGIT_AND_LETTERS
95
+ ? numDigits
96
+ : 0,
97
+ characterType: type,
98
+ });
67
99
  totalPredicted = total;
68
100
  setMaxCodes(total);
69
101
  }
102
+ let codeSampleTmp = codeSample;
70
103
  if (isRelevantChangeCodeKey) {
71
- setCodeSample(generateRandomCodeWithConfig(form.getFieldsValue()));
104
+ codeSampleTmp = generateRandomCodeWithConfig(form.getFieldsValue());
105
+ setCodeSample(codeSampleTmp);
72
106
  }
73
107
  if (isChangePrefix) {
74
- setCodeWithPrefixAndSuffix(generateCodeWithPrefixAndSuffix(codeSample, form.getFieldValue('prefix'), form.getFieldValue('suffix'), form.getFieldValue('separator')));
108
+ setCodeWithPrefixAndSuffix(generateCodeWithPrefixAndSuffix(codeSampleTmp, form.getFieldValue('prefix'), form.getFieldValue('suffix'), form.getFieldValue('separator')));
75
109
  }
76
110
  const dataOnChange = {
77
- ...allValues,
111
+ quantity: allValues.quantity,
112
+ refillInterval: allValues.refillInterval,
113
+ prefix: allValues.prefix,
114
+ suffix: allValues.suffix,
115
+ separator: allValues.separator,
116
+ ...(allValues.refillInterval === 'auto' && {
117
+ refillThreshold: allValues.refillThreshold,
118
+ refillUnit: allValues.refillUnit,
119
+ }),
120
+ characterType: allValues.characterType,
121
+ ...(allValues.characterType === CharacterType.DIGIT_AND_LETTERS && {
122
+ digitalNumbers: allValues.digitalNumbers,
123
+ alphabetLetters: allValues.alphabetLetters,
124
+ capitalization: allValues.capitalization,
125
+ characterOrder: allValues.characterOrder,
126
+ }),
127
+ ...(allValues.characterType === CharacterType.DIGITS && {
128
+ digitalNumbers: allValues.digitalNumbers,
129
+ }),
130
+ ...(allValues.characterType === CharacterType.LETTERS && {
131
+ alphabetLetters: allValues.alphabetLetters,
132
+ capitalization: allValues.capitalization,
133
+ }),
78
134
  totalPredicted,
79
135
  };
80
136
  debouncedOnChange({
@@ -83,14 +139,46 @@ export const CodeStructure = ({ initialData, onChange }) => {
83
139
  });
84
140
  };
85
141
  useEffect(() => {
86
- setMaxCodes(calculateTotalCodes(alphabetLetters, digitalNumbers, characterType));
142
+ setMaxCodes(calculateTotalCodes({
143
+ numberOfLetters: characterType === CharacterType.DIGIT_AND_LETTERS ||
144
+ characterType === CharacterType.LETTERS
145
+ ? alphabetLetters
146
+ : 0,
147
+ numberOfDigits: characterType === CharacterType.DIGITS ||
148
+ characterType === CharacterType.DIGIT_AND_LETTERS
149
+ ? digitalNumbers
150
+ : 0,
151
+ characterType,
152
+ }));
87
153
  }, [alphabetLetters, digitalNumbers, characterType]);
88
154
  useEffect(() => {
89
- setCodeSample(generateRandomCodeWithConfig(initialData));
155
+ setCodeSample(generateRandomCodeWithConfig({
156
+ characterType,
157
+ digitalNumbers,
158
+ alphabetLetters,
159
+ capitalization,
160
+ characterOrder,
161
+ }));
90
162
  }, [characterType, digitalNumbers, alphabetLetters, capitalization, characterOrder]);
91
163
  useEffect(() => {
92
- form.setFieldsValue(initialData);
93
- }, [initialData, form]);
164
+ setCodeWithPrefixAndSuffix(generateCodeWithPrefixAndSuffix(codeSample, prefix, suffix, separator));
165
+ }, [codeSample, prefix, suffix, separator]);
166
+ useEffect(() => {
167
+ form.setFieldsValue({
168
+ prefix,
169
+ suffix,
170
+ separator,
171
+ quantity,
172
+ refillInterval,
173
+ refillThreshold,
174
+ refillUnit,
175
+ characterType,
176
+ digitalNumbers,
177
+ alphabetLetters,
178
+ capitalization,
179
+ characterOrder,
180
+ });
181
+ }, [initialData]);
94
182
  return (_jsx(CodeStructureWrapper, { children: _jsxs(Form, { form: form, layout: "horizontal", labelCol: { span: 6 }, colon: false, wrapperCol: { span: 24 }, labelAlign: "left", initialValues: {
95
183
  characterType,
96
184
  digitalNumbers,
@@ -108,30 +196,52 @@ export const CodeStructure = ({ initialData, onChange }) => {
108
196
  const fieldKeyChange = changedFields[0].name[0];
109
197
  const isValidate = form.getFieldsError().some(field => field.errors.length > 0);
110
198
  updateFormValues(fieldKeyChange, isValidate);
111
- }, children: [_jsx(Title, { level: 5, children: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE, 'Code Structure') }), _jsx(Form.Item, { label: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_PREFIX, 'Prefix'), name: "prefix", children: _jsx(Input, { placeholder: "", style: {
199
+ }, children: [_jsx(Title, { style: { marginTop: 0 }, level: 5, children: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE, 'Coupon Code Structure') }), _jsx(Form.Item, { label: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_PREFIX, 'Prefix'), name: "prefix", rules: [
200
+ {
201
+ pattern: /^[a-zA-Z0-9]+$/i,
202
+ message: translate(translations._POOL_SHOPIFY_VALIDATE_PRE_SUFF, 'Invalid input. Use only letters and numbers.'),
203
+ },
204
+ ], children: _jsx(Input, { placeholder: "", style: {
112
205
  maxWidth: 465,
113
- } }) }), _jsxs(Row, { children: [_jsx(Col, { span: 6, offset: 0, children: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_INFIX, 'Infix') }), _jsx(Col, { span: 16, offset: 0, children: _jsxs(Flex, { vertical: true, gap: 10, children: [_jsx(Row, { children: _jsx(Col, { offset: 0, children: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_CHAC_TYPE, 'Character Type') }) }), _jsx(Form.Item, { name: "characterType", children: _jsx(Radio.Group, { options: CHARACTER_TYPE_OPTIONS }) })] }) })] }), _jsx(Row, { children: _jsx(Col, { offset: 6, children: _jsxs(Flex, { gap: 10, align: "center", children: [_jsx(Form.Item, { name: "digitalNumbers", children: _jsx(InputNumber, { min: 1, max: 50, style: { width: '40px' } }) }), _jsx("div", { style: { marginBottom: '15px' }, children: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_CHAC_TYPE_DIG_NO, 'digital numbers') })] }) }) }), _jsx(Row, { children: _jsx(Col, { offset: 6, children: _jsxs(Flex, { gap: 10, align: "center", children: [_jsx(Form.Item, { name: "alphabetLetters", children: _jsx(InputNumber, { min: 1, max: 50, style: { width: '40px' } }) }), _jsx("div", { style: { marginBottom: '15px' }, children: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_CHAC_TYPE_LET_NO, 'alphabet letters') })] }) }) }), _jsxs(Flex, { vertical: true, gap: 10, children: [_jsx(Row, { children: _jsx(Col, { offset: 6, children: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_CAP, 'Letters Capitalization') }) }), _jsx(Form.Item, { label: _jsx("span", { children: "\u00A0" }), name: "capitalization", children: _jsx(Radio.Group, { options: CAPITALIZATION_OPTIONS }) })] }), _jsxs(Flex, { vertical: true, gap: 10, children: [_jsx(Row, { children: _jsx(Col, { offset: 6, children: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_CHAC_ORDER, 'Character Order') }) }), _jsx(Form.Item, { label: _jsx("span", { children: "\u00A0" }), name: "characterOrder", children: _jsx(Radio.Group, { options: CHARACTER_ORDER_OPTIONS }) })] }), _jsx(Form.Item, { label: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_SUFFIX, 'Suffix'), name: "suffix", children: _jsx(Input, { placeholder: "", style: {
206
+ } }) }), _jsxs(Row, { children: [_jsx(Col, { span: 6, offset: 0, children: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_INFIX, 'Infix') }), _jsx(Col, { span: 16, offset: 0, children: _jsxs(Flex, { vertical: true, gap: 10, children: [_jsx(Row, { children: _jsx(Col, { offset: 0, children: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_CHAC_TYPE, 'Character Type') }) }), _jsx(Form.Item, { name: "characterType", children: _jsx(Radio.Group, { options: CHARACTER_TYPE_OPTIONS }) })] }) })] }), _jsx(Row, { children: _jsx(Col, { offset: 6, children: _jsxs(Flex, { gap: 10, align: "center", style: {
207
+ position: 'relative',
208
+ }, children: [_jsx(Form.Item, { hidden: form.getFieldValue('characterType') === CharacterType.LETTERS, shouldUpdate: true, name: "digitalNumbers", rules: [{ required: true, message: `This field can't be empty` }], children: _jsx(InputNumber, { min: 1, max: 50, style: { width: '65px' } }) }), (form.getFieldValue('characterType') === CharacterType.DIGITS ||
209
+ form.getFieldValue('characterType') === CharacterType.DIGIT_AND_LETTERS) && (_jsx(BlockAbsolute, { children: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_CHAC_TYPE_DIG_NO, 'digital numbers') }))] }) }) }), _jsx(Row, { children: _jsx(Col, { offset: 6, children: _jsxs(Flex, { gap: 10, align: "center", style: {
210
+ position: 'relative',
211
+ }, children: [_jsx(Form.Item, { hidden: form.getFieldValue('characterType') === CharacterType.DIGITS, name: "alphabetLetters", rules: [{ required: true, message: `This field can't be empty` }], children: _jsx(InputNumber, { min: 1, max: 50, style: { width: '65px' } }) }), (form.getFieldValue('characterType') === CharacterType.DIGIT_AND_LETTERS ||
212
+ form.getFieldValue('characterType') === CharacterType.LETTERS) && (_jsx(BlockAbsolute, { children: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_CHAC_TYPE_LET_NO, 'alphabet letters') }))] }) }) }), _jsxs(Flex, { vertical: true, gap: 10, children: [_jsx(Row, { children: form.getFieldValue('characterType') !== CharacterType.DIGITS && (_jsx(Col, { offset: 6, children: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_CAP, 'Letters Capitalization') })) }), _jsx(Form.Item, { hidden: form.getFieldValue('characterType') === CharacterType.DIGITS, label: _jsx("span", { children: "\u00A0" }), name: "capitalization", children: _jsx(Radio.Group, { options: CAPITALIZATION_OPTIONS }) })] }), _jsxs(Flex, { vertical: true, gap: 10, children: [_jsx(Row, { children: form.getFieldValue('characterType') === CharacterType.DIGIT_AND_LETTERS && (_jsx(Col, { offset: 6, children: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_CHAC_ORDER, 'Character Order') })) }), _jsx(Form.Item, { hidden: form.getFieldValue('characterType') !== CharacterType.DIGIT_AND_LETTERS, label: _jsx("span", { children: "\u00A0" }), name: "characterOrder", children: _jsx(Radio.Group, { options: CHARACTER_ORDER_OPTIONS }) })] }), _jsx(Form.Item, { label: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_SUFFIX, 'Suffix'), name: "suffix", rules: [
213
+ {
214
+ pattern: /^[a-zA-Z0-9]+$/i,
215
+ message: translate(translations._POOL_SHOPIFY_VALIDATE_PRE_SUFF, 'Invalid input. Use only letters and numbers.'),
216
+ },
217
+ ], children: _jsx(Input, { placeholder: "", style: {
114
218
  maxWidth: 465,
115
- } }) }), _jsx(Form.Item, { label: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_SEPARATOR, 'Separator'), name: "separator", children: _jsx(Select, { options: SEPARATOR_OPTIONS, style: { width: '180px' } }) }), _jsxs(Row, { children: [_jsx(Col, { span: 6, children: _jsxs(Flex, { justify: "start", align: "center", gap: 5, children: [translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_QUANTITY, 'Quantity'), ' ', _jsx("span", { style: { color: 'red' }, children: "*" })] }) }), _jsx(Col, { children: _jsxs(Flex, { gap: 10, align: "center", children: [_jsx(Form.Item, { required: true, name: "quantity", rules: [{ required: true }], children: _jsx(InputNumber, { min: 1, max: 10000 }) }), _jsx("div", { style: { marginBottom: '15px' }, children: "code(s) per time" })] }) })] }), _jsxs(Form.Item, { label: translate(translations._ACT_PREVIEW, 'Preview'), children: ["Maximum of ", _jsx("b", { children: maxCodes.toLocaleString() }), " codes (sample", ' ', generateCodeWithPrefixAndSuffix(codeSample, form.getFieldValue('prefix'), form.getFieldValue('suffix'), form.getFieldValue('separator')), ") to be generated"] }), _jsx(Title, { level: 5, children: "Code Refill" }), _jsx(Form.Item, { label: "Refill Interval", name: "refillInterval", children: _jsxs(Radio.Group, { style: { display: 'flex', flexDirection: 'column', gap: '10px' }, children: [_jsx(Radio, { value: "manual", children: "Manual refill only" }), _jsx(Radio, { value: "auto", children: _jsxs(Flex, { gap: 10, align: "center", children: [_jsx(Typography.Text, { style: { whiteSpace: 'nowrap' }, children: "Add codes when less than" }), _jsx(Form.Item, { noStyle: true, shouldUpdate: true, children: ({ getFieldValue }) => {
219
+ } }) }), _jsx(Form.Item, { label: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_SEPARATOR, 'Separator'), name: "separator", children: _jsx(Select, { options: SEPARATOR_OPTIONS, style: { width: '180px' } }) }), _jsxs(Row, { children: [_jsx(Col, { span: 6, children: _jsxs(Flex, { justify: "start", align: "center", gap: 5, children: [translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_QUANTITY, 'Quantity'), ' ', _jsx("span", { style: { color: 'red' }, children: "*" })] }) }), _jsx(Col, { children: _jsxs(Flex, { gap: 10, align: "center", style: { position: 'relative' }, children: [_jsx(Form.Item, { required: true, name: "quantity", rules: [{ required: true, message: `This field can't be empty` }], children: _jsx(InputNumber, { min: 0, max: 10000, style: { width: '65px' } }) }), _jsx(BlockAbsolute, { children: translate(translations._POOL_SHOPIFY_CODE_PREVIEW_TEXT_5, 'code(s) per time') })] }) })] }), _jsx(Form.Item, { label: translate(translations._ACT_PREVIEW, 'Preview'), children: _jsxs(Typography.Text, { children: [translate(translations._POOL_SHOPIFY_CODE_PREVIEW_TEXT_1, 'Maximum of'), ' ', _jsx("b", { children: maxCodes.toLocaleString() }), ' ', translate(translations._POOL_SHOPIFY_CODE_PREVIEW_TEXT_2, 'codes'), " (", translate(translations._POOL_SHOPIFY_CODE_PREVIEW_TEXT_3, 'sample'), ' ', state.codeWithPrefixAndSuffix, " )", ' ', translate(translations._POOL_SHOPIFY_CODE_PREVIEW_TEXT_4, 'to be generated')] }) }), _jsx(Title, { style: { marginTop: 0 }, level: 5, children: translate(translations._POOL_SHOPIFY_CODE_REFILL, 'Code Refill') }), _jsx(Form.Item, { label: translate(translations._POOL_SHOPIFY_CODE_REFILL_INTERVAL, 'Refill Interval'), name: "refillInterval", children: _jsxs(Radio.Group, { style: { display: 'flex', flexDirection: 'column', gap: '10px' }, onChange: e => {
220
+ if (e.target.value === 'manual' && isEmpty(form.getFieldValue('refillThreshold'))) {
221
+ form.setFieldsValue({ refillThreshold: 10 });
222
+ form.validateFields(['refillThreshold']);
223
+ }
224
+ }, children: [_jsx(Radio, { value: "manual", children: translate(translations._POOL_SHOPIFY_CODE_REFILL_MANUAL, 'Manual refill only') }), _jsx(Radio, { value: "auto", children: _jsxs(Flex, { gap: 10, align: "center", children: [_jsx(Typography.Text, { style: { whiteSpace: 'nowrap' }, children: translate(translations._POOL_SHOPIFY_CODE_REFILL_AUTO, 'Add codes when less than') }), _jsx(Form.Item, { noStyle: true, shouldUpdate: true, children: ({ getFieldValue }) => {
116
225
  const refillUnit = getFieldValue('refillUnit');
117
226
  return (_jsx(Form.Item, { name: "refillThreshold", noStyle: true, rules: [
118
227
  { required: true, message: '' },
119
228
  {
120
229
  validator: (_, value) => {
121
230
  if (refillUnit === RefillUnitType.PERCENT) {
122
- if (value < 1 || value > 100) {
123
- return Promise.reject(new Error(''));
124
- }
125
- }
126
- else if (refillUnit === RefillUnitType.CODES) {
127
- if (value < 0) {
128
- return Promise.reject(new Error(''));
231
+ if (value > 100) {
232
+ form.setFieldsValue({ refillThreshold: 100 });
129
233
  }
130
234
  }
131
235
  return Promise.resolve();
132
236
  },
133
237
  },
134
- ], children: _jsx(InputNumber, { min: refillUnit === RefillUnitType.CODES ? 0 : 1, max: refillUnit === RefillUnitType.PERCENT ? 100 : undefined, style: { width: '63px' } }) }));
238
+ ], children: _jsx(InputNumber, { onBlur: e => {
239
+ const { value } = e.target;
240
+ if (isEmpty(value)) {
241
+ form.setFieldsValue({ refillThreshold: 1 });
242
+ form.validateFields(['refillThreshold']);
243
+ }
244
+ }, min: 1, max: refillUnit === RefillUnitType.PERCENT ? 100 : undefined, style: { width: '63px' } }) }));
135
245
  } }), _jsx(Form.Item, { noStyle: true, shouldUpdate: true, children: () => (_jsx(Form.Item, { name: "refillUnit", noStyle: true, rules: [
136
246
  { required: true, message: '' },
137
247
  {
@@ -139,5 +249,5 @@ export const CodeStructure = ({ initialData, onChange }) => {
139
249
  form.validateFields(['refillThreshold']);
140
250
  },
141
251
  },
142
- ], children: _jsx(Select, { options: REFILL_UNIT_OPTIONS, style: { width: '63px' }, onClick: e => e.preventDefault() }) })) }), "remaining"] }) })] }) })] }) }));
143
- };
252
+ ], children: _jsx(Select, { defaultValue: RefillUnitType.CODES, options: REFILL_UNIT_OPTIONS, style: { width: '63px' }, onClick: e => e.preventDefault() }) })) }), translate(translations._POOL_SHOPIFY_CODE_REFILL_AUTO_TEXT, 'remaining')] }) })] }) })] }) }));
253
+ });
@@ -30,8 +30,8 @@ export const CAPITALIZATION_OPTIONS = [
30
30
  label: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_CAP_LOW, 'lowercase'),
31
31
  },
32
32
  {
33
- value: CapitalizationType.TITLE_CASE,
34
- label: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_CAP_TITL, 'Title case'),
33
+ value: CapitalizationType.RANDOM,
34
+ label: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_CHAC_ORDER_RANDOM, 'Random'),
35
35
  },
36
36
  ];
37
37
  export const CHARACTER_ORDER_OPTIONS = [
@@ -1 +1,4 @@
1
1
  export declare const CodeStructureWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
2
+ export declare const BlockAbsolute: import("styled-components").StyledComponent<"div", any, {
3
+ left?: number | undefined;
4
+ }, never>;
@@ -1,2 +1,8 @@
1
1
  import styled from 'styled-components';
2
2
  export const CodeStructureWrapper = styled.div ``;
3
+ export const BlockAbsolute = styled.div `
4
+ position: absolute;
5
+ left: ${p => p.left || 75}px;
6
+ white-space: nowrap;
7
+ margin-bottom: 15px;
8
+ `;
@@ -11,7 +11,7 @@ export declare enum CharacterOrderType {
11
11
  export declare enum CapitalizationType {
12
12
  UPPERCASE = "upper",
13
13
  LOWERCASE = "lower",
14
- TITLE_CASE = "title"
14
+ RANDOM = "random"
15
15
  }
16
16
  export declare enum SeparatorType {
17
17
  HYPHEN = "hyphen",
@@ -24,7 +24,7 @@ export declare enum RefillType {
24
24
  MANUAL = "manual"
25
25
  }
26
26
  export declare enum RefillUnitType {
27
- CODES = "code",
27
+ CODES = "codes",
28
28
  PERCENT = "percent"
29
29
  }
30
30
  export interface CodeStructureData {
@@ -14,7 +14,7 @@ export var CapitalizationType;
14
14
  (function (CapitalizationType) {
15
15
  CapitalizationType["UPPERCASE"] = "upper";
16
16
  CapitalizationType["LOWERCASE"] = "lower";
17
- CapitalizationType["TITLE_CASE"] = "title";
17
+ CapitalizationType["RANDOM"] = "random";
18
18
  })(CapitalizationType || (CapitalizationType = {}));
19
19
  export var SeparatorType;
20
20
  (function (SeparatorType) {
@@ -30,6 +30,6 @@ export var RefillType;
30
30
  })(RefillType || (RefillType = {}));
31
31
  export var RefillUnitType;
32
32
  (function (RefillUnitType) {
33
- RefillUnitType["CODES"] = "code";
33
+ RefillUnitType["CODES"] = "codes";
34
34
  RefillUnitType["PERCENT"] = "percent";
35
35
  })(RefillUnitType || (RefillUnitType = {}));
@@ -1,4 +1,14 @@
1
1
  import { CharacterType, CodeStructureData, SeparatorType } from './type';
2
- export declare const generateRandomCodeWithConfig: ({ characterType, digitalNumbers, alphabetLetters, capitalization, characterOrder, }: CodeStructureData) => string;
2
+ export declare const generateRandomCodeWithConfig: ({ characterType, digitalNumbers, alphabetLetters, capitalization, characterOrder, }: {
3
+ characterType: CodeStructureData['characterType'];
4
+ digitalNumbers: CodeStructureData['digitalNumbers'];
5
+ alphabetLetters: CodeStructureData['alphabetLetters'];
6
+ capitalization: CodeStructureData['capitalization'];
7
+ characterOrder: CodeStructureData['characterOrder'];
8
+ }) => string;
3
9
  export declare const generateCodeWithPrefixAndSuffix: (code: string, prefix: string, suffix: string, separator: SeparatorType) => string;
4
- export declare const calculateTotalCodes: (numberOfLetters: number, numberOfDigits: number, characterType: CharacterType) => number;
10
+ export declare const calculateTotalCodes: ({ numberOfLetters, numberOfDigits, characterType, }: {
11
+ numberOfLetters: number;
12
+ numberOfDigits: number;
13
+ characterType: CharacterType;
14
+ }) => number;
@@ -18,8 +18,10 @@ export const generateRandomCodeWithConfig = ({ characterType, digitalNumbers, al
18
18
  else if (capitalization === CapitalizationType.LOWERCASE) {
19
19
  letterPart = letterPart.toLowerCase();
20
20
  }
21
- else if (capitalization === CapitalizationType.TITLE_CASE && letterPart.length > 0) {
22
- letterPart = letterPart.charAt(0).toUpperCase() + letterPart.slice(1).toLowerCase();
21
+ else if (capitalization === CapitalizationType.RANDOM) {
22
+ letterPart = Array.from(letterPart)
23
+ .map(char => (Math.random() < 0.5 ? char.toUpperCase() : char.toLowerCase()))
24
+ .join('');
23
25
  }
24
26
  // Order characters
25
27
  let finalCode = '';
@@ -46,7 +48,7 @@ export const generateCodeWithPrefixAndSuffix = (code, prefix, suffix, separator)
46
48
  finalCode = `${finalCode}${separator !== SeparatorType.NONE ? (separator === SeparatorType.HYPHEN ? '-' : separator === SeparatorType.DOT ? '.' : '_') : ''}${suffix}`;
47
49
  return finalCode;
48
50
  };
49
- export const calculateTotalCodes = (numberOfLetters, numberOfDigits, characterType) => {
51
+ export const calculateTotalCodes = ({ numberOfLetters, numberOfDigits, characterType, }) => {
50
52
  let totalCodes = 0;
51
53
  switch (characterType) {
52
54
  case CharacterType.LETTERS: