@ahrowe/ui 0.1.4 → 0.1.6
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/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1850 -1164
- package/dist/index.mjs.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types/package/common/iconPicker/iconPicker.d.ts +2 -21
- package/dist/types/package/common/iconPicker/iconPicker.types.d.ts +23 -0
- package/dist/types/package/common/iconPicker/index.d.ts +1 -2
- package/dist/types/package/common/inputDropdown/index.d.ts +1 -0
- package/dist/types/package/common/inputDropdown/inputDropdown.d.ts +2 -0
- package/dist/types/package/common/inputDropdown/inputDropdown.types.d.ts +21 -0
- package/dist/types/package/common/stepper/index.d.ts +1 -2
- package/dist/types/package/common/stepper/stepper.d.ts +2 -25
- package/dist/types/package/common/stepper/stepper.types.d.ts +21 -0
- package/dist/types/package/common/virtualList/index.d.ts +2 -0
- package/dist/types/package/common/virtualList/virtualList.d.ts +14 -0
- package/dist/types/package/common/virtualList/virtualList.types.d.ts +71 -0
- package/dist/types/package/common/wizard/index.d.ts +1 -2
- package/dist/types/package/common/wizard/wizard.d.ts +2 -27
- package/dist/types/package/common/wizard/wizard.types.d.ts +12 -0
- package/dist/types/package/index.d.ts +53 -37
- package/dist/types/package/services/formValidation/FormValidatorGroupWithForm.d.ts +3 -0
- package/dist/types/package/services/formValidation/formValidatorGroup.d.ts +8 -2
- package/dist/types/package/services/formValidation/useFormValidatorGroup.d.ts +5 -2
- package/package.json +11 -3
- package/dist/types/package/common/icon/Icon.d.ts +0 -10
- package/dist/types/package/common/icon/index.d.ts +0 -2
- package/dist/types/package/common/icon/svg/can.d.ts +0 -2
- package/dist/types/package/common/inputDropdownModern/index.d.ts +0 -2
- package/dist/types/package/common/inputDropdownModern/inputDropdownModern.d.ts +0 -35
- package/dist/types/package/common/roleManager/index.d.ts +0 -2
- package/dist/types/package/common/roleManager/roleManager.container.d.ts +0 -2
- package/dist/types/package/common/roleManager/roleManager.d.ts +0 -22
- /package/dist/{mcp → mcp.js} +0 -0
|
@@ -6,6 +6,9 @@ import { default as React } from 'react';
|
|
|
6
6
|
*
|
|
7
7
|
* This is the class you should use everywhere — it is a drop-in replacement
|
|
8
8
|
* for FormValidatorGroup with one extra property: `this.Form`.
|
|
9
|
+
*
|
|
10
|
+
* Also injects the default toast-based onSubmitError so both hook and class-component
|
|
11
|
+
* consumers surface errors out of the box; pass options.onSubmitError to override.
|
|
9
12
|
*/
|
|
10
13
|
export default class FormValidatorGroupWithForm<TGroup extends FormGroup = FormGroup, TInitial = InferGroupValues<TGroup>> extends FormValidatorGroup<TGroup, TInitial> {
|
|
11
14
|
Form: React.FC<React.FormHTMLAttributes<HTMLFormElement>>;
|
|
@@ -16,6 +16,7 @@ export interface FormValidatorGroupOptions<TGroup extends FormGroup = FormGroup,
|
|
|
16
16
|
onSubmit?: (values: MergedValues<TInitial, TGroup>, group: FormValidatorGroup<TGroup, TInitial>) => Promise<void> | void;
|
|
17
17
|
onValidate?: (group: FormValidatorGroup<TGroup, TInitial>) => ValidationError | null | void;
|
|
18
18
|
errorParser?: ErrorParser;
|
|
19
|
+
onSubmitError?: (errors: ValidationError[]) => void;
|
|
19
20
|
}
|
|
20
21
|
interface ComponentLike {
|
|
21
22
|
forceUpdate: () => void;
|
|
@@ -27,6 +28,7 @@ export default class FormValidatorGroup<TGroup extends FormGroup = FormGroup, TI
|
|
|
27
28
|
onSubmitCallback: (values: MergedValues<TInitial, TGroup>, group: FormValidatorGroup<TGroup, TInitial>) => Promise<void> | void;
|
|
28
29
|
onValidateCallback: (group: FormValidatorGroup<TGroup, TInitial>) => ValidationError | null | void;
|
|
29
30
|
errorParser: ErrorParser;
|
|
31
|
+
onSubmitError: (errors: ValidationError[]) => void;
|
|
30
32
|
submitCount: number;
|
|
31
33
|
onDebounce: (values: MergedValues<TInitial, TGroup>) => void;
|
|
32
34
|
onReset: (group: FormValidatorGroup<TGroup, TInitial>, valuesAfterCreation: FormValues, initialValues: TInitial) => void;
|
|
@@ -35,7 +37,7 @@ export default class FormValidatorGroup<TGroup extends FormGroup = FormGroup, TI
|
|
|
35
37
|
* @param component - Class component instance for forceUpdate (pass null when using hooks)
|
|
36
38
|
* @param options - initialValues, onSubmit, onValidate, errorParser
|
|
37
39
|
*/
|
|
38
|
-
constructor(formValidatorGroup: TGroup, component?: ComponentLike | null, { initialValues, onSubmit, onValidate, errorParser, }?: FormValidatorGroupOptions<TGroup, TInitial>);
|
|
40
|
+
constructor(formValidatorGroup: TGroup, component?: ComponentLike | null, { initialValues, onSubmit, onValidate, errorParser, onSubmitError, }?: FormValidatorGroupOptions<TGroup, TInitial>);
|
|
39
41
|
get isSubmitting(): boolean;
|
|
40
42
|
get wasTouched(): boolean;
|
|
41
43
|
get isDirty(): boolean;
|
|
@@ -45,7 +47,11 @@ export default class FormValidatorGroup<TGroup extends FormGroup = FormGroup, TI
|
|
|
45
47
|
set: (validatorName: keyof TGroup & string, value: unknown) => this;
|
|
46
48
|
reset: (toOverride?: FormValues) => void;
|
|
47
49
|
resetDirtyAndTouched: () => void;
|
|
48
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* Parses an API error and pushes field-level errors into the matching validators.
|
|
52
|
+
* When field errors are found and isInternal is set, surfaces the first field message.
|
|
53
|
+
* When the error shape isn't recognised (no field errors), always surfaces a generic message.
|
|
54
|
+
*/
|
|
49
55
|
parseError: (err: unknown, isInternal?: boolean) => void;
|
|
50
56
|
registerOnUpdateListener: (callback: UpdateListener) => void;
|
|
51
57
|
removeOnUpdateListener: (callback: UpdateListener) => void;
|
|
@@ -8,8 +8,11 @@ import { FormGroup, FormValidatorGroupOptions, InferGroupValues } from './formVa
|
|
|
8
8
|
* onSubmit / onValidate are kept fresh via refs — they always reflect the latest
|
|
9
9
|
* closure without needing to be listed in effect dependencies.
|
|
10
10
|
*
|
|
11
|
+
* onSubmitError defaults to showing the message as an error toast (provided by FormValidatorGroupWithForm);
|
|
12
|
+
* pass options.onSubmitError to override.
|
|
13
|
+
*
|
|
11
14
|
* @param groupDef - Map of field name → FormValidator instance
|
|
12
|
-
* @param options - initialValues, onSubmit, onValidate, errorParser
|
|
15
|
+
* @param options - initialValues, onSubmit, onValidate, errorParser, onSubmitError
|
|
13
16
|
*
|
|
14
17
|
* @example
|
|
15
18
|
* const form = useFormValidatorGroup(
|
|
@@ -20,4 +23,4 @@ import { FormGroup, FormValidatorGroupOptions, InferGroupValues } from './formVa
|
|
|
20
23
|
* },
|
|
21
24
|
* );
|
|
22
25
|
*/
|
|
23
|
-
export declare function useFormValidatorGroup<TGroup extends FormGroup = FormGroup, TInitial = InferGroupValues<TGroup>>(groupDef: TGroup, { initialValues, onSubmit, onValidate, errorParser }?: FormValidatorGroupOptions<TGroup, TInitial>): FormValidatorGroup<TGroup, TInitial>;
|
|
26
|
+
export declare function useFormValidatorGroup<TGroup extends FormGroup = FormGroup, TInitial = InferGroupValues<TGroup>>(groupDef: TGroup, { initialValues, onSubmit, onValidate, errorParser, onSubmitError }?: FormValidatorGroupOptions<TGroup, TInitial>): FormValidatorGroup<TGroup, TInitial>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ahrowe/ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -37,18 +37,22 @@
|
|
|
37
37
|
},
|
|
38
38
|
"style": "./dist/style.css",
|
|
39
39
|
"bin": {
|
|
40
|
-
"ahrowe-ui-mcp": "./dist/mcp"
|
|
40
|
+
"ahrowe-ui-mcp": "./dist/mcp.js"
|
|
41
41
|
},
|
|
42
42
|
"files": [
|
|
43
43
|
"dist",
|
|
44
44
|
"docs"
|
|
45
45
|
],
|
|
46
|
+
"lint-staged": {
|
|
47
|
+
"*.{ts,tsx}": "vitest related --run"
|
|
48
|
+
},
|
|
46
49
|
"scripts": {
|
|
47
50
|
"dev": "vite",
|
|
48
51
|
"build": "vite build",
|
|
49
52
|
"build:lib": "vite build --config vite.lib.config.ts",
|
|
50
53
|
"build:mcp": "vite build --config vite.mcp.config.ts",
|
|
51
54
|
"preview": "vite preview",
|
|
55
|
+
"gen-barrel": "tsx scripts/gen-barrel.ts",
|
|
52
56
|
"gc": "bash src/scripts/generateComponent.sh $INIT_CWD process.argv",
|
|
53
57
|
"lint": "eslint .",
|
|
54
58
|
"lint:fix": "eslint . --fix",
|
|
@@ -58,7 +62,8 @@
|
|
|
58
62
|
"verify-package": "bash src/scripts/verify-package.sh",
|
|
59
63
|
"test": "vitest run",
|
|
60
64
|
"test:watch": "vitest",
|
|
61
|
-
"test:ui": "vitest --ui"
|
|
65
|
+
"test:ui": "vitest --ui",
|
|
66
|
+
"prepare": "husky"
|
|
62
67
|
},
|
|
63
68
|
"peerDependencies": {
|
|
64
69
|
"@fortawesome/fontawesome-svg-core": ">=6.0.0",
|
|
@@ -99,8 +104,10 @@
|
|
|
99
104
|
"eslint-config-prettier": "^10.1.8",
|
|
100
105
|
"eslint-plugin-react": "^7.37.5",
|
|
101
106
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
107
|
+
"husky": "^9.1.7",
|
|
102
108
|
"jiti": "^2.7.0",
|
|
103
109
|
"jsdom": "^29.1.1",
|
|
110
|
+
"lint-staged": "^17.0.5",
|
|
104
111
|
"postcss": "^8.5.15",
|
|
105
112
|
"postcss-nested": "^7.0.2",
|
|
106
113
|
"prettier": "^3.8.3",
|
|
@@ -108,6 +115,7 @@
|
|
|
108
115
|
"react-dom": "^19.2.6",
|
|
109
116
|
"react-element-to-jsx-string": "^17.0.1",
|
|
110
117
|
"react-syntax-highlighter": "^16.1.1",
|
|
118
|
+
"tsx": "^4.22.3",
|
|
111
119
|
"typescript": "^6.0.3",
|
|
112
120
|
"typescript-eslint": "^8.60.0",
|
|
113
121
|
"vite": "^8.0.14",
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { ValidatableComponent } from '../../services/formValidation';
|
|
2
|
-
export default InputDropdownModern;
|
|
3
|
-
declare class InputDropdownModern extends ValidatableComponent<import('../../services/formValidation/validatableComponent').ValidatableComponentProps, import('../../services/formValidation/validatableComponent').ValidatableComponentState> {
|
|
4
|
-
static propTypes: {
|
|
5
|
-
label: any;
|
|
6
|
-
value: any;
|
|
7
|
-
formValidator: any;
|
|
8
|
-
items: any;
|
|
9
|
-
className: any;
|
|
10
|
-
onSelect: any;
|
|
11
|
-
placeholder: any;
|
|
12
|
-
};
|
|
13
|
-
static defaultProps: {
|
|
14
|
-
label: string;
|
|
15
|
-
value: string;
|
|
16
|
-
formValidator: null;
|
|
17
|
-
items: never[];
|
|
18
|
-
className: string;
|
|
19
|
-
onSelect: () => null;
|
|
20
|
-
placeholder: string;
|
|
21
|
-
};
|
|
22
|
-
constructor(props: any);
|
|
23
|
-
state: {
|
|
24
|
-
isMenuShown: boolean;
|
|
25
|
-
highlightedIndex: null;
|
|
26
|
-
currItems: any;
|
|
27
|
-
lastVal: string;
|
|
28
|
-
};
|
|
29
|
-
getItemsForValue: (value: any) => any;
|
|
30
|
-
getValueFromProps: (props: any) => any;
|
|
31
|
-
componentDidUpdate(prevProps: any, prevState: any): void;
|
|
32
|
-
hideMenuTimeout: any;
|
|
33
|
-
onKeyDown: (event: any) => void;
|
|
34
|
-
render(): import("react/jsx-runtime").JSX.Element;
|
|
35
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
2
|
-
export default RoleManager;
|
|
3
|
-
declare class RoleManager extends React.Component<any, any, any> {
|
|
4
|
-
static propTypes: {
|
|
5
|
-
children: any;
|
|
6
|
-
anyRequiredRoles: any;
|
|
7
|
-
allRequiredRoles: any;
|
|
8
|
-
invalidRoleContent: any;
|
|
9
|
-
user: any;
|
|
10
|
-
household: any;
|
|
11
|
-
};
|
|
12
|
-
static defaultProps: {
|
|
13
|
-
children: null;
|
|
14
|
-
anyRequiredRoles: never[];
|
|
15
|
-
allRequiredRoles: never[];
|
|
16
|
-
invalidRoleContent: null;
|
|
17
|
-
};
|
|
18
|
-
constructor(props: any);
|
|
19
|
-
state: {};
|
|
20
|
-
checkIsRoleSufficient: () => any;
|
|
21
|
-
render(): import("react/jsx-runtime").JSX.Element;
|
|
22
|
-
}
|
/package/dist/{mcp → mcp.js}
RENAMED
|
File without changes
|