@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.
- package/es/components/atoms/Input/Input.d.ts +11 -17
- package/es/components/atoms/Input/Input.js +7 -11
- package/es/components/atoms/Switch/Switch.js +2 -1
- package/es/components/icons/LazyIcon/LazyIcon.d.ts +2 -0
- package/es/components/icons/LazyIcon/LazyIcon.js +2 -0
- package/es/components/icons/TaskAltIcon.d.ts +3 -0
- package/es/components/icons/TaskAltIcon.js +7 -0
- package/es/components/icons/UnsubscribeIcon.d.ts +3 -0
- package/es/components/icons/UnsubscribeIcon.js +7 -0
- package/es/components/icons/index.d.ts +2 -0
- package/es/components/icons/index.js +2 -0
- package/es/components/molecules/AddDynamicContent/components/DisplayFormat/DisplayFormat.d.ts +1 -0
- package/es/components/molecules/CodeStructure/CodeStructure.d.ts +23 -2
- package/es/components/molecules/CodeStructure/CodeStructure.js +136 -26
- package/es/components/molecules/CodeStructure/constants.js +2 -2
- package/es/components/molecules/CodeStructure/styled.d.ts +3 -0
- package/es/components/molecules/CodeStructure/styled.js +6 -0
- package/es/components/molecules/CodeStructure/type.d.ts +2 -2
- package/es/components/molecules/CodeStructure/type.js +2 -2
- package/es/components/molecules/CodeStructure/utils.d.ts +12 -2
- package/es/components/molecules/CodeStructure/utils.js +5 -3
- package/es/components/molecules/DrawerDetail/DrawerDetail.js +10 -5
- package/es/components/molecules/DrawerDetail/types.d.ts +1 -0
- package/es/components/molecules/Dropdown/style.scss +6 -4
- package/es/components/molecules/EditingListV2/EditingList.d.ts +2 -0
- package/es/components/molecules/EditingListV2/EditingList.js +17 -0
- package/es/components/molecules/EditingListV2/components/List/List.d.ts +9 -0
- package/es/components/molecules/EditingListV2/components/List/List.js +42 -0
- package/es/components/molecules/EditingListV2/components/List/index.d.ts +1 -0
- package/es/components/molecules/EditingListV2/components/List/index.js +1 -0
- package/es/components/molecules/EditingListV2/components/Loadable.d.ts +8 -0
- package/es/components/molecules/EditingListV2/components/Loadable.js +2 -0
- package/es/components/molecules/EditingListV2/components/Popover/Popover.d.ts +11 -0
- package/es/components/molecules/EditingListV2/components/Popover/Popover.js +10 -0
- package/es/components/molecules/EditingListV2/components/Popover/index.d.ts +1 -0
- package/es/components/molecules/EditingListV2/components/Popover/index.js +1 -0
- package/es/components/molecules/EditingListV2/components/index.d.ts +3 -0
- package/es/components/molecules/EditingListV2/components/index.js +3 -0
- package/es/components/molecules/EditingListV2/index.d.ts +2 -0
- package/es/components/molecules/EditingListV2/index.js +1 -0
- package/es/components/molecules/EditingListV2/types.d.ts +19 -0
- package/es/components/molecules/EditingListV2/types.js +1 -0
- package/es/components/molecules/EditingListV2/utils.d.ts +27 -0
- package/es/components/molecules/EditingListV2/utils.js +28 -0
- package/es/components/molecules/InputSelectAttribute/index.js +5 -2
- package/es/components/molecules/SearchPopover/components/PopoverAddField/PopoverAddField.js +2 -2
- package/es/components/molecules/SearchPopover/components/PopoverSelect/PopoverSelect.js +4 -4
- package/es/components/molecules/SearchPopover/types.d.ts +1 -0
- package/es/components/molecules/TagifyInput/TagifyInput.js +5 -3
- package/es/components/molecules/index.d.ts +1 -0
- package/es/components/molecules/index.js +1 -0
- package/es/components/organism/TicketEditorV2/Content.d.ts +27 -0
- package/es/components/organism/TicketEditorV2/Content.js +296 -0
- package/es/components/organism/TicketEditorV2/Service.d.ts +49 -0
- package/es/components/organism/TicketEditorV2/Service.js +58 -0
- package/es/components/organism/TicketEditorV2/TicketEditorV2.d.ts +20 -0
- package/es/components/organism/TicketEditorV2/TicketEditorV2.js +124 -0
- package/es/components/organism/TicketEditorV2/components/DropdownComponent.d.ts +9 -0
- package/es/components/organism/TicketEditorV2/components/DropdownComponent.js +45 -0
- package/es/components/organism/TicketEditorV2/components/Message.d.ts +2 -0
- package/es/components/organism/TicketEditorV2/components/Message.js +31 -0
- package/es/components/organism/TicketEditorV2/components/MessageComponent.d.ts +10 -0
- package/es/components/organism/TicketEditorV2/components/MessageComponent.js +64 -0
- package/es/components/organism/TicketEditorV2/components/icons/AddTicketIcon.d.ts +2 -0
- package/es/components/organism/TicketEditorV2/components/icons/AddTicketIcon.js +5 -0
- package/es/components/organism/TicketEditorV2/components/icons/TicketIcon.d.ts +2 -0
- package/es/components/organism/TicketEditorV2/components/icons/TicketIcon.js +5 -0
- package/es/components/organism/TicketEditorV2/constant.d.ts +17 -0
- package/es/components/organism/TicketEditorV2/constant.js +17 -0
- package/es/components/organism/TicketEditorV2/constants/index.d.ts +1 -0
- package/es/components/organism/TicketEditorV2/constants/index.js +1 -0
- package/es/components/organism/TicketEditorV2/constants/queryKeys.d.ts +5 -0
- package/es/components/organism/TicketEditorV2/constants/queryKeys.js +5 -0
- package/es/components/organism/TicketEditorV2/index.d.ts +1 -0
- package/es/components/organism/TicketEditorV2/index.js +1 -0
- package/es/components/organism/TicketEditorV2/queries/index.d.ts +3 -0
- package/es/components/organism/TicketEditorV2/queries/index.js +3 -0
- package/es/components/organism/TicketEditorV2/queries/useGetDetailTicket.d.ts +12 -0
- package/es/components/organism/TicketEditorV2/queries/useGetDetailTicket.js +14 -0
- package/es/components/organism/TicketEditorV2/queries/useGetListComments.d.ts +13 -0
- package/es/components/organism/TicketEditorV2/queries/useGetListComments.js +18 -0
- package/es/components/organism/TicketEditorV2/queries/useGetListUser.d.ts +11 -0
- package/es/components/organism/TicketEditorV2/queries/useGetListUser.js +14 -0
- package/es/components/organism/TicketEditorV2/styled.d.ts +54 -0
- package/es/components/organism/TicketEditorV2/styled.js +871 -0
- package/es/components/organism/TicketEditorV2/util.d.ts +46 -0
- package/es/components/organism/TicketEditorV2/util.js +408 -0
- package/es/components/organism/index.d.ts +1 -0
- package/es/components/organism/index.js +1 -0
- package/es/components/template/TemplateListing/Loadable.d.ts +1 -0
- 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,
|
|
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:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
TextArea: React.ForwardRefExoticComponent<import("antd/es/input").TextAreaProps & React.RefAttributes<import("antd/es/input/TextArea").TextAreaRef>>;
|
|
28
|
-
Password: React.ForwardRefExoticComponent<
|
|
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 {
|
|
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
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
|
|
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,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,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,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
|
-
|
|
17
|
-
|
|
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,
|
|
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(
|
|
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
|
-
|
|
104
|
+
codeSampleTmp = generateRandomCodeWithConfig(form.getFieldsValue());
|
|
105
|
+
setCodeSample(codeSampleTmp);
|
|
72
106
|
}
|
|
73
107
|
if (isChangePrefix) {
|
|
74
|
-
setCodeWithPrefixAndSuffix(generateCodeWithPrefixAndSuffix(
|
|
108
|
+
setCodeWithPrefixAndSuffix(generateCodeWithPrefixAndSuffix(codeSampleTmp, form.getFieldValue('prefix'), form.getFieldValue('suffix'), form.getFieldValue('separator')));
|
|
75
109
|
}
|
|
76
110
|
const dataOnChange = {
|
|
77
|
-
|
|
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(
|
|
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(
|
|
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
|
-
|
|
93
|
-
}, [
|
|
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",
|
|
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",
|
|
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:
|
|
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
|
|
123
|
-
|
|
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, {
|
|
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() }) })) }),
|
|
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.
|
|
34
|
-
label: translate(translations.
|
|
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 = [
|
|
@@ -11,7 +11,7 @@ export declare enum CharacterOrderType {
|
|
|
11
11
|
export declare enum CapitalizationType {
|
|
12
12
|
UPPERCASE = "upper",
|
|
13
13
|
LOWERCASE = "lower",
|
|
14
|
-
|
|
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 = "
|
|
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["
|
|
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"] = "
|
|
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, }:
|
|
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
|
|
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.
|
|
22
|
-
letterPart =
|
|
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:
|