@spscommerce/ds-react 5.12.1 → 5.13.0
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/lib/autocomplete/SpsAutocomplete.d.ts +3 -2
- package/lib/dropdown/SpsDropdown.d.ts +2 -1
- package/lib/form/SpsForm.examples.d.ts +9 -0
- package/lib/form/hooks/useCustomValidator.d.ts +7 -0
- package/lib/form/hooks/useSpsForm.d.ts +5 -1
- package/lib/form/index.d.ts +1 -0
- package/lib/form/validation/types.d.ts +3 -0
- package/lib/index.cjs.js +143 -90
- package/lib/index.es.js +185 -33
- package/lib/multi-select/SpsMultiSelect.d.ts +3 -2
- package/lib/option-list/SpsOptionListProps.d.ts +6 -3
- package/lib/select/SpsSelect.d.ts +3 -2
- package/package.json +9 -9
|
@@ -17,12 +17,13 @@ declare const propTypes: {
|
|
|
17
17
|
value: PropTypes.Requireable<string>;
|
|
18
18
|
zeroState: PropTypes.Requireable<string>;
|
|
19
19
|
loading: PropTypes.Requireable<boolean>;
|
|
20
|
-
|
|
20
|
+
maxHeightOptionListPx: PropTypes.Requireable<number>;
|
|
21
|
+
maxHeightOptionListRem: PropTypes.Requireable<number>;
|
|
21
22
|
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
22
23
|
className: PropTypes.Requireable<string>;
|
|
23
24
|
"data-testid": PropTypes.Requireable<string>;
|
|
24
25
|
unsafelyReplaceClassName: PropTypes.Requireable<string>;
|
|
25
26
|
};
|
|
26
27
|
export declare type SpsAutocompleteProps = PropTypes.InferTS<typeof propTypes, HTMLInputElement>;
|
|
27
|
-
export declare function SpsAutocomplete({ className, debounce, disabled, formControl, formMeta, onChange, icon, id, placeholder, suggestions, unsafelyReplaceClassName, tallOptionList, value, zeroState, loading,
|
|
28
|
+
export declare function SpsAutocomplete({ className, debounce, disabled, formControl, formMeta, onChange, icon, id, placeholder, suggestions, unsafelyReplaceClassName, tallOptionList, value, zeroState, loading, maxHeightOptionListPx, maxHeightOptionListRem, ...rest }: SpsAutocompleteProps): JSX.Element;
|
|
28
29
|
export {};
|
|
@@ -14,7 +14,8 @@ declare const propTypes: {
|
|
|
14
14
|
onOpen: PropTypes.Requireable<() => void>;
|
|
15
15
|
onClose: PropTypes.Requireable<() => void>;
|
|
16
16
|
loading: PropTypes.Requireable<boolean>;
|
|
17
|
-
|
|
17
|
+
maxHeightOptionListPx: PropTypes.Requireable<number>;
|
|
18
|
+
maxHeightOptionListRem: PropTypes.Requireable<number>;
|
|
18
19
|
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
19
20
|
className: PropTypes.Requireable<string>;
|
|
20
21
|
"data-testid": PropTypes.Requireable<string>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SpsValidator } from "../validation/types";
|
|
2
|
+
export declare enum ValidationMode {
|
|
3
|
+
ON_CHANGE = 0,
|
|
4
|
+
ON_BLUR = 1,
|
|
5
|
+
ON_SUBMIT = 2
|
|
6
|
+
}
|
|
7
|
+
export declare function useCustomValidator<T>(validator: SpsValidator<T>, validatorConfig?: Record<string, ValidationMode>, dependencies?: any[]): SpsValidator<T>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SpsValidator, SpsValidationErrors } from "../validation/types";
|
|
2
2
|
declare type PathComponent = string | number;
|
|
3
3
|
declare type Path = PathComponent[];
|
|
4
|
-
declare type UpdateFn = (path?: Path, newValue?: any, markAsBlurred?: boolean) => void;
|
|
4
|
+
declare type UpdateFn = (path?: Path, newValue?: any, markAsBlurred?: boolean, newValidators?: Array<SpsValidator<any>>) => void;
|
|
5
5
|
export declare abstract class SpsFormMetaBase<T> {
|
|
6
6
|
path: Path;
|
|
7
7
|
update: UpdateFn;
|
|
@@ -9,6 +9,7 @@ export declare abstract class SpsFormMetaBase<T> {
|
|
|
9
9
|
errors: SpsValidationErrors | null;
|
|
10
10
|
revealAllErrors: boolean;
|
|
11
11
|
preventativeErrors: any[];
|
|
12
|
+
submitted: boolean;
|
|
12
13
|
constructor(path: Path, update: UpdateFn);
|
|
13
14
|
abstract isPristine(): boolean;
|
|
14
15
|
abstract markAsPristine(): SpsFormMetaBase<T>;
|
|
@@ -23,6 +24,7 @@ export declare abstract class SpsFormMetaBase<T> {
|
|
|
23
24
|
hasPreventativeError(errorKey: string): boolean;
|
|
24
25
|
hasPreventativeErrors(): boolean;
|
|
25
26
|
isRequired(): boolean;
|
|
27
|
+
isSubmitted(): boolean;
|
|
26
28
|
onFocus(): void;
|
|
27
29
|
onBlur(): void;
|
|
28
30
|
}
|
|
@@ -37,6 +39,7 @@ export declare class SpsFormFieldMeta<T> extends SpsFormMetaBase<T> {
|
|
|
37
39
|
isFocused(): boolean;
|
|
38
40
|
markAsFocused(): SpsFormFieldMeta<T>;
|
|
39
41
|
markAsBlurred(): SpsFormFieldMeta<T>;
|
|
42
|
+
markAsSubmitted(): SpsFormFieldMeta<T>;
|
|
40
43
|
}
|
|
41
44
|
export declare type InferredSpsFormMeta<T> = SpsFormMetaBase<T> & (T extends any[] ? SpsFormArrayMeta<T> : T extends (Array<infer U> | undefined) ? SpsFormArrayMeta<U[]> | undefined : T extends object ? SpsFormGroupMeta<T> : T extends (object | undefined) ? SpsFormGroupMeta<object & T> | undefined : T extends boolean ? SpsFormFieldMeta<boolean> : T extends (infer V | undefined) ? SpsFormFieldMeta<V> | undefined : SpsFormFieldMeta<T>);
|
|
42
45
|
export declare type SpsFormSetMembers<T> = {
|
|
@@ -61,6 +64,7 @@ export declare abstract class SpsFormSetMeta<T extends SpsFormSetValue, U extend
|
|
|
61
64
|
markAsPristine(): this;
|
|
62
65
|
markAsDirty(): this;
|
|
63
66
|
markAsBlurred(): this;
|
|
67
|
+
markAsSubmitted(): this;
|
|
64
68
|
}
|
|
65
69
|
export declare class SpsFormGroupMeta<T extends object> extends SpsFormSetMeta<T> {
|
|
66
70
|
protected inferMembers(inferFromValue: T): void;
|
package/lib/form/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * from "./hooks/SpsAbstractControl.interface";
|
|
|
6
6
|
export * from "./hooks/SpsControlSet.interface";
|
|
7
7
|
export * from "./hooks/useForm";
|
|
8
8
|
export * from "./hooks/useServerSideValidation";
|
|
9
|
+
export * from "./hooks/useCustomValidator";
|
|
9
10
|
export * from "./validation/SpsValidators";
|
|
10
11
|
export * from "./validation/types";
|
|
11
12
|
export * from "./validation/validate";
|
|
@@ -5,3 +5,6 @@ export declare type SpsValidatorFactory<T> = (...args: any[]) => SpsValidator<T>
|
|
|
5
5
|
export declare const OnBlurErrorKeys: Set<string>;
|
|
6
6
|
export declare const AsTypingErrorKeys: Set<string>;
|
|
7
7
|
export declare const PreventativeErrorKeys: Set<string>;
|
|
8
|
+
export declare const OnSubmitErrorKeys: Set<string>;
|
|
9
|
+
export declare function addOnChangeErrorKey(errorKey: string): void;
|
|
10
|
+
export declare function addOnSubmitErrorKey(errorKey: string): void;
|