chop-logic-components 0.11.0 → 0.12.1
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/dist/components/containers/form/FormContext.d.ts +2 -0
- package/dist/components/containers/form/controller.d.ts +15 -0
- package/dist/components/containers/form/helpers.d.ts +4 -13
- package/dist/components/{misc → inputs/_common}/error-message/ErrorMessage.d.ts +1 -1
- package/dist/components/inputs/_common/input-inner-button/InputInnerButton.d.ts +10 -0
- package/dist/components/inputs/_common/input-inner-button/InputInnerButton.styled.d.ts +2 -0
- package/dist/components/{misc → inputs/_common}/label/Label.d.ts +1 -1
- package/dist/components/inputs/numeric/NumericInput.d.ts +5 -1
- package/dist/components/inputs/numeric/NumericInput.styled.d.ts +2 -0
- package/dist/components/inputs/numeric/helpers.d.ts +17 -2
- package/dist/components/inputs/text/TextInput.d.ts +8 -1
- package/dist/components/inputs/text/TextInput.styled.d.ts +2 -0
- package/dist/components/inputs/text/__docs__/TextInput.stories.d.ts +3 -1
- package/dist/components/inputs/text/helpers.d.ts +13 -1
- package/dist/components/misc/icon/Icon.d.ts +4 -0
- package/dist/components/misc/icon/elements/Down.d.ts +4 -0
- package/dist/components/misc/icon/elements/Hide.d.ts +4 -0
- package/dist/components/misc/icon/elements/Show.d.ts +4 -0
- package/dist/components/misc/icon/elements/Up.d.ts +4 -0
- package/dist/constants/style-variables.d.ts +1 -1
- package/dist/hooks/use-element-ids/__tests__/use-element-ids.test.d.ts +1 -0
- package/dist/index.cjs.js +333 -291
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +7640 -7465
- package/dist/index.es.js.map +1 -1
- package/package.json +10 -10
- package/dist/components/misc/clear-input-button/ClearInputButton.d.ts +0 -8
- package/dist/components/misc/clear-input-button/ClearInputButton.styled.d.ts +0 -2
- /package/dist/components/{misc/clear-input-button/__tests__/ClearInputButton.test.d.ts → containers/form/__tests__/helpers.test.d.ts} +0 -0
- /package/dist/components/{misc → inputs/_common}/error-message/ErrorMessage.styled.d.ts +0 -0
- /package/dist/components/{misc → inputs/_common}/error-message/__tests__/ErrorMessage.test.d.ts +0 -0
- /package/dist/components/{misc/label/__tests__/Label.test.d.ts → inputs/_common/input-inner-button/__tests__/InputInnerButton.test.d.ts} +0 -0
- /package/dist/components/{misc → inputs/_common}/label/Label.styled.d.ts +0 -0
- /package/dist/{hooks/use-element-id/__tests__/use-element-ids.test.d.ts → components/inputs/_common/label/__tests__/Label.test.d.ts} +0 -0
- /package/dist/hooks/{use-element-id → use-element-ids}/index.d.ts +0 -0
|
@@ -3,10 +3,12 @@ import { default as React } from 'react';
|
|
|
3
3
|
export type ChopLogicFormData = {
|
|
4
4
|
[key: string]: unknown;
|
|
5
5
|
};
|
|
6
|
+
export type ChopLogicFormValidationState = [string, boolean][];
|
|
6
7
|
export type ChopLogicFormInput = HTMLInputElement | HTMLSelectElement;
|
|
7
8
|
export type ChopLogicFormInputParams = {
|
|
8
9
|
name: string;
|
|
9
10
|
value: unknown;
|
|
11
|
+
valid?: boolean;
|
|
10
12
|
};
|
|
11
13
|
export type ChopLogicFormContextProps = {
|
|
12
14
|
onChangeFormInput?: (params: ChopLogicFormInputParams) => void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FormEvent } from 'react';
|
|
2
|
+
import { ChopLogicFormData, ChopLogicFormInputParams } from './FormContext';
|
|
3
|
+
|
|
4
|
+
export declare function useChopLogicFormController({ initialValues, onReset, onSubmit, onClickSubmit, }: {
|
|
5
|
+
initialValues?: ChopLogicFormData;
|
|
6
|
+
onReset?: React.FormEventHandler<HTMLFormElement>;
|
|
7
|
+
onSubmit?: React.FormEventHandler<HTMLFormElement>;
|
|
8
|
+
onClickSubmit?: (data: ChopLogicFormData) => void;
|
|
9
|
+
}): {
|
|
10
|
+
handleInputChange: (params: ChopLogicFormInputParams) => void;
|
|
11
|
+
handleSubmit: (event: FormEvent<HTMLFormElement>) => void;
|
|
12
|
+
handleReset: (event: FormEvent<HTMLFormElement>) => void;
|
|
13
|
+
resetSignal: number;
|
|
14
|
+
valid: boolean;
|
|
15
|
+
};
|
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ChopLogicFormData, ChopLogicFormInputParams } from './FormContext';
|
|
1
|
+
import { ChopLogicFormData, ChopLogicFormInputParams, ChopLogicFormValidationState } from './FormContext';
|
|
3
2
|
|
|
4
|
-
export declare function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
onSubmit?: React.FormEventHandler<HTMLFormElement>;
|
|
8
|
-
onClickSubmit?: (data: ChopLogicFormData) => void;
|
|
9
|
-
}): {
|
|
10
|
-
handleInputChange: (params: ChopLogicFormInputParams) => void;
|
|
11
|
-
handleSubmit: (event: FormEvent<HTMLFormElement>) => void;
|
|
12
|
-
handleReset: (event: FormEvent<HTMLFormElement>) => void;
|
|
13
|
-
resetSignal: number;
|
|
14
|
-
};
|
|
3
|
+
export declare function getInitialValidationState(data?: ChopLogicFormData): ChopLogicFormValidationState;
|
|
4
|
+
export declare function updateValidationState(state: ChopLogicFormValidationState, params: ChopLogicFormInputParams): ChopLogicFormValidationState;
|
|
5
|
+
export declare function isFormDataValid(state: ChopLogicFormValidationState): boolean;
|
|
@@ -4,8 +4,8 @@ type ChopLogicErrorMessageProps = {
|
|
|
4
4
|
errorId: string;
|
|
5
5
|
visible?: boolean;
|
|
6
6
|
message?: string;
|
|
7
|
-
className?: string;
|
|
8
7
|
testId?: string;
|
|
8
|
+
style?: React.CSSProperties;
|
|
9
9
|
};
|
|
10
10
|
declare const ChopLogicErrorMessage: React.FC<ChopLogicErrorMessageProps>;
|
|
11
11
|
export default ChopLogicErrorMessage;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { CLIcon } from '../../../../../../../../../../src/components/misc/icon/Icon';
|
|
3
|
+
|
|
4
|
+
type ClearInputButtonProps = {
|
|
5
|
+
onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
6
|
+
label: string;
|
|
7
|
+
icon: CLIcon;
|
|
8
|
+
};
|
|
9
|
+
declare const InputInnerButton: React.FC<ClearInputButtonProps>;
|
|
10
|
+
export default InputInnerButton;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const StyledInputInnerButton: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, never>> & string;
|
|
@@ -4,10 +4,10 @@ type ChopLogicLabelProps = {
|
|
|
4
4
|
label: string;
|
|
5
5
|
required: boolean;
|
|
6
6
|
inputId: string;
|
|
7
|
-
className?: string;
|
|
8
7
|
isTextHidden?: boolean;
|
|
9
8
|
icon?: React.ReactElement;
|
|
10
9
|
iconPosition?: 'left' | 'right';
|
|
10
|
+
style?: React.CSSProperties;
|
|
11
11
|
};
|
|
12
12
|
declare const ChopLogicLabel: React.FC<PropsWithChildren<ChopLogicLabelProps>>;
|
|
13
13
|
export default ChopLogicLabel;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
|
|
3
|
+
export type NumericValidationFunction = (input?: number) => boolean;
|
|
3
4
|
export type ChopLogicNumericInputProps = React.InputHTMLAttributes<HTMLInputElement> & {
|
|
4
5
|
name: string;
|
|
5
6
|
label: string;
|
|
6
|
-
valid?: boolean;
|
|
7
7
|
errorMessage?: string;
|
|
8
|
+
validator?: NumericValidationFunction;
|
|
9
|
+
onClear?: () => void;
|
|
10
|
+
hasSpinButtons?: boolean;
|
|
11
|
+
onSpinButtonClick?: (value?: number) => void;
|
|
8
12
|
};
|
|
9
13
|
declare const ChopLogicNumericInput: React.FC<ChopLogicNumericInputProps>;
|
|
10
14
|
export default ChopLogicNumericInput;
|
|
@@ -5,3 +5,5 @@ export declare const StyledNumericInputWrapper: import('styled-components/dist/t
|
|
|
5
5
|
$invalid: boolean;
|
|
6
6
|
}>> & string;
|
|
7
7
|
export declare const StyledNumericInput: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, never>> & string;
|
|
8
|
+
export declare const StyledFieldWrapper: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
|
|
9
|
+
export declare const StyledButtonsWrapper: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
|
|
@@ -1,20 +1,35 @@
|
|
|
1
1
|
import { ChangeEventHandler } from 'react';
|
|
2
2
|
import { ChopLogicFormData } from '../../../../../../../../../src/components/containers/form/FormContext';
|
|
3
|
+
import { NumericValidationFunction } from './NumericInput';
|
|
3
4
|
|
|
4
5
|
export declare function getNumericInputInitialValue({ name, initialValues, defaultValue, }: {
|
|
5
6
|
name: string;
|
|
6
7
|
initialValues?: ChopLogicFormData;
|
|
7
8
|
defaultValue?: string | number | readonly string[];
|
|
8
9
|
}): number;
|
|
9
|
-
export declare function
|
|
10
|
+
export declare function validateNumericInputValue({ value, required, validator, maxValue, minValue, }: {
|
|
11
|
+
value?: number;
|
|
12
|
+
required?: boolean;
|
|
13
|
+
validator?: NumericValidationFunction;
|
|
14
|
+
maxValue?: number;
|
|
15
|
+
minValue?: number;
|
|
16
|
+
}): boolean;
|
|
17
|
+
export declare function useChopLogicNumericInputController({ name, defaultValue, onChange, onSpinButtonClick, min, max, step, required, validator, }: {
|
|
10
18
|
name: string;
|
|
11
19
|
defaultValue?: string | number | readonly string[];
|
|
12
20
|
onChange?: ChangeEventHandler<HTMLInputElement>;
|
|
21
|
+
onSpinButtonClick?: (value?: number) => void;
|
|
13
22
|
min?: string | number;
|
|
14
23
|
max?: string | number;
|
|
24
|
+
step: number;
|
|
25
|
+
required: boolean;
|
|
26
|
+
validator?: NumericValidationFunction;
|
|
15
27
|
}): {
|
|
16
28
|
handleChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
17
|
-
value:
|
|
29
|
+
value: number;
|
|
30
|
+
valid: boolean;
|
|
18
31
|
minValue: number;
|
|
19
32
|
maxValue: number;
|
|
33
|
+
increment: () => void;
|
|
34
|
+
decrement: () => void;
|
|
20
35
|
};
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
|
|
3
|
+
export type RegExpWithFlags = {
|
|
4
|
+
regexp: string;
|
|
5
|
+
flags?: string;
|
|
6
|
+
};
|
|
7
|
+
export type TextValidationFunction = (input: string) => boolean;
|
|
3
8
|
export type ChopLogicTextInputProps = React.InputHTMLAttributes<HTMLInputElement> & {
|
|
4
9
|
name: string;
|
|
5
10
|
label: string;
|
|
6
11
|
valid?: boolean;
|
|
7
12
|
errorMessage?: string;
|
|
8
|
-
|
|
13
|
+
clearable?: boolean;
|
|
9
14
|
onClear?: () => void;
|
|
15
|
+
type?: 'text' | 'email' | 'password';
|
|
16
|
+
validator?: RegExpWithFlags | TextValidationFunction;
|
|
10
17
|
};
|
|
11
18
|
declare const ChopLogicTextInput: React.FC<ChopLogicTextInputProps>;
|
|
12
19
|
export default ChopLogicTextInput;
|
|
@@ -5,3 +5,5 @@ export declare const StyledTextInputWrapper: import('styled-components/dist/type
|
|
|
5
5
|
$invalid: boolean;
|
|
6
6
|
}>> & string;
|
|
7
7
|
export declare const StyledTextInput: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, never>> & string;
|
|
8
|
+
export declare const StyledFieldWrapper: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
|
|
9
|
+
export declare const StyledButtonsWrapper: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
|
|
@@ -4,4 +4,6 @@ import { default as TextInputExample } from './TextInputExample';
|
|
|
4
4
|
declare const meta: Meta<typeof TextInputExample>;
|
|
5
5
|
export default meta;
|
|
6
6
|
type Story = StoryObj<typeof TextInputExample>;
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const DefaultTextInput: Story;
|
|
8
|
+
export declare const PasswordInput: Story;
|
|
9
|
+
export declare const EmailInput: Story;
|
|
@@ -1,17 +1,29 @@
|
|
|
1
1
|
import { ChangeEventHandler } from 'react';
|
|
2
2
|
import { ChopLogicFormData } from '../../../../../../../../../src/components/containers/form/FormContext';
|
|
3
|
+
import { RegExpWithFlags, TextValidationFunction } from './TextInput';
|
|
3
4
|
|
|
5
|
+
export declare function validateTextInputValue({ value, required, validator, }: {
|
|
6
|
+
value: string;
|
|
7
|
+
required: boolean;
|
|
8
|
+
validator?: RegExpWithFlags | TextValidationFunction;
|
|
9
|
+
}): boolean;
|
|
4
10
|
export declare function getTextInputInitialValue({ name, initialValues, defaultValue, }: {
|
|
5
11
|
name: string;
|
|
6
12
|
initialValues?: ChopLogicFormData;
|
|
7
13
|
defaultValue?: string | number | readonly string[];
|
|
8
14
|
}): string;
|
|
9
|
-
export declare function useChopLogicTextInputController({ name, defaultValue, onChange, }: {
|
|
15
|
+
export declare function useChopLogicTextInputController({ name, defaultValue, onChange, onClear, required, validator, }: {
|
|
10
16
|
name: string;
|
|
17
|
+
required: boolean;
|
|
18
|
+
validator?: RegExpWithFlags | TextValidationFunction;
|
|
11
19
|
defaultValue?: string | number | readonly string[];
|
|
12
20
|
onChange?: ChangeEventHandler<HTMLInputElement>;
|
|
21
|
+
onClear?: () => void;
|
|
13
22
|
}): {
|
|
14
23
|
value: string;
|
|
24
|
+
valid: boolean;
|
|
25
|
+
passwordShown: boolean;
|
|
15
26
|
handleChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
16
27
|
handleClear: () => void;
|
|
28
|
+
togglePassword: () => void;
|
|
17
29
|
};
|
|
@@ -12,14 +12,18 @@ export declare enum CLIcon {
|
|
|
12
12
|
Copy = "copy",
|
|
13
13
|
Cut = "cut",
|
|
14
14
|
Delete = "delete",
|
|
15
|
+
Down = "down",
|
|
15
16
|
Download = "download",
|
|
16
17
|
Error = "error",
|
|
17
18
|
Forward = "forward",
|
|
18
19
|
Help = "help",
|
|
20
|
+
Hide = "hide",
|
|
19
21
|
Info = "info",
|
|
20
22
|
Paste = "paste",
|
|
21
23
|
Question = "question",
|
|
22
24
|
Save = "save",
|
|
25
|
+
Show = "show",
|
|
26
|
+
Up = "up",
|
|
23
27
|
Upload = "upload",
|
|
24
28
|
Warning = "warning",
|
|
25
29
|
Remove = "remove"
|
|
@@ -19,7 +19,7 @@ export declare const UNITS: Readonly<{
|
|
|
19
19
|
minElementSize: "2.75rem";
|
|
20
20
|
smallIconSize: "1.6rem";
|
|
21
21
|
blockBorderRadius: "0.375rem";
|
|
22
|
-
inputWrapperHeight: "
|
|
22
|
+
inputWrapperHeight: "3.5rem";
|
|
23
23
|
}>;
|
|
24
24
|
export declare const SHADOWS: Readonly<{
|
|
25
25
|
box: "rgba(0, 0, 0, 0.15) 2.4px 2.4px 3.2px";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|