proje-react-panel 1.2.0 → 1.3.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.
Files changed (37) hide show
  1. package/dist/__tests__/utils/PreloadCacheHelper.test.d.ts +1 -0
  2. package/dist/components/Login.d.ts +3 -12
  3. package/dist/components/Panel.d.ts +4 -1
  4. package/dist/components/form/Checkbox.d.ts +2 -1
  5. package/dist/components/form/FormPage.d.ts +2 -1
  6. package/dist/components/form/Uploader.d.ts +2 -1
  7. package/dist/decorators/form/Form.d.ts +9 -7
  8. package/dist/decorators/form/Input.d.ts +1 -1
  9. package/dist/decorators/form/inputs/SelectInput.d.ts +6 -8
  10. package/dist/index.cjs.js +1 -1
  11. package/dist/index.d.ts +2 -0
  12. package/dist/index.esm.js +1 -1
  13. package/dist/store/store.d.ts +2 -3
  14. package/dist/types/User.d.ts +3 -0
  15. package/dist/utils/PreloadCacheHelper.d.ts +15 -0
  16. package/dist/utils/login.d.ts +2 -0
  17. package/dist/utils/logout.d.ts +1 -0
  18. package/package.json +1 -1
  19. package/src/__tests__/utils/PreloadCacheHelper.test.ts +9 -20
  20. package/src/components/Login.tsx +4 -83
  21. package/src/components/Panel.tsx +13 -6
  22. package/src/components/form/Checkbox.tsx +6 -5
  23. package/src/components/form/FormField.tsx +16 -32
  24. package/src/components/form/FormPage.tsx +24 -5
  25. package/src/components/form/InnerForm.tsx +73 -72
  26. package/src/components/form/Select.tsx +4 -3
  27. package/src/components/form/Uploader.tsx +5 -4
  28. package/src/decorators/form/Form.ts +13 -10
  29. package/src/decorators/form/Input.ts +7 -3
  30. package/src/index.ts +2 -2
  31. package/src/store/store.ts +3 -4
  32. package/src/styles/form.scss +17 -6
  33. package/src/styles/login.scss +24 -93
  34. package/src/types/User.ts +3 -0
  35. package/src/utils/PreloadCacheHelper.ts +5 -12
  36. package/src/utils/login.ts +8 -0
  37. package/src/utils/logout.ts +7 -0
@@ -0,0 +1 @@
1
+ export {};
@@ -1,13 +1,4 @@
1
1
  import React from 'react';
2
- export interface OnLogin {
3
- login: (username: string, password: string) => Promise<LoginResponse>;
4
- }
5
- interface LoginResponse {
6
- user: any;
7
- token: string;
8
- }
9
- interface LoginProps {
10
- onLogin: OnLogin;
11
- }
12
- export declare function Login({ onLogin }: LoginProps): React.JSX.Element;
13
- export {};
2
+ import { FormPageProps } from './form/FormPage';
3
+ import { AnyClass } from '../types/AnyClass';
4
+ export declare function Login<T extends AnyClass>(props: FormPageProps<T>): React.JSX.Element;
@@ -1,6 +1,9 @@
1
1
  import React from 'react';
2
2
  interface AppProps {
3
+ onInit?: (appData: {
4
+ token?: string;
5
+ }) => void;
3
6
  children: React.ReactNode;
4
7
  }
5
- export declare function Panel({ children }: AppProps): React.JSX.Element;
8
+ export declare function Panel({ onInit, children }: AppProps): React.JSX.Element;
6
9
  export {};
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import { InputConfiguration } from '../../decorators/form/Input';
3
3
  interface CheckboxProps extends React.InputHTMLAttributes<HTMLInputElement> {
4
4
  input: InputConfiguration;
5
+ fieldName: string;
5
6
  }
6
- export declare function Checkbox({ input, ...props }: CheckboxProps): React.JSX.Element;
7
+ export declare function Checkbox({ input, fieldName, ...props }: CheckboxProps): React.JSX.Element;
7
8
  export {};
@@ -13,5 +13,6 @@ export interface FormPageProps<T extends AnyClass> {
13
13
  title?: string;
14
14
  documentTitle?: string;
15
15
  header?: (utils: FormUtils<T>) => React.ReactNode;
16
+ className?: string;
16
17
  }
17
- export declare function FormPage<T extends AnyClass>({ model, title, documentTitle, header, }: FormPageProps<T>): React.JSX.Element;
18
+ export declare function FormPage<T extends AnyClass>({ model, title, documentTitle, header, className, }: FormPageProps<T>): React.JSX.Element;
@@ -3,6 +3,7 @@ import { InputConfiguration } from '../../decorators/form/Input';
3
3
  interface UploaderProps {
4
4
  input: InputConfiguration;
5
5
  maxLength?: number;
6
+ fieldName: string;
6
7
  }
7
- export declare function Uploader({ input, maxLength }: UploaderProps): React.JSX.Element;
8
+ export declare function Uploader({ input, maxLength, fieldName }: UploaderProps): React.JSX.Element;
8
9
  export {};
@@ -1,19 +1,21 @@
1
1
  import 'reflect-metadata';
2
2
  import { AnyClass, AnyClassConstructor } from '../../types/AnyClass';
3
3
  import { GetDetailsDataFN } from '../details/Details';
4
- export type OnSubmitFN<T> = (data: T | FormData) => Promise<T>;
5
- interface FormOptions<T extends AnyClass> {
6
- onSubmit: OnSubmitFN<T>;
4
+ export type OnSubmitFN<T, L = T> = (data: T | FormData) => Promise<L>;
5
+ interface FormOptions<T extends AnyClass, L = T> {
6
+ onSubmit: OnSubmitFN<T, L>;
7
+ onSubmitSuccess?: (data: L) => void;
7
8
  getDetailsData?: GetDetailsDataFN<T>;
8
9
  type?: 'json' | 'formData';
9
10
  redirectSuccessUrl?: string;
10
11
  }
11
- export interface FormConfiguration<T extends AnyClass> {
12
- onSubmit: OnSubmitFN<T>;
12
+ export interface FormConfiguration<T extends AnyClass, L = T> {
13
+ onSubmit: OnSubmitFN<T, L>;
14
+ onSubmitSuccess?: (data: L) => void;
13
15
  getDetailsData?: GetDetailsDataFN<T>;
14
16
  type: 'json' | 'formData';
15
17
  redirectSuccessUrl?: string;
16
18
  }
17
- export declare function Form<T extends AnyClass>(options?: FormOptions<T>): ClassDecorator;
18
- export declare function getFormConfiguration<T extends AnyClass, K extends AnyClassConstructor<T>>(entityClass: K): FormConfiguration<T>;
19
+ export declare function Form<T extends AnyClass, L = T>(options?: FormOptions<T, L>): ClassDecorator;
20
+ export declare function getFormConfiguration<T extends AnyClass, K extends AnyClassConstructor<T>, L = T>(entityClass: K): FormConfiguration<T, L>;
19
21
  export {};
@@ -3,7 +3,6 @@ import { AnyClass, AnyClassConstructor } from '../../types/AnyClass';
3
3
  export type InputTypes = 'input' | 'textarea' | 'file-upload' | 'checkbox' | 'hidden' | 'nested';
4
4
  export type ExtendedInputTypes = InputTypes | 'select';
5
5
  export interface InputOptions {
6
- name?: string;
7
6
  type?: InputTypes;
8
7
  inputType?: 'text' | 'email' | 'tel' | 'password' | 'number' | 'date';
9
8
  label?: string;
@@ -18,6 +17,7 @@ export interface ExtendedInputOptions extends Omit<InputOptions, 'type'> {
18
17
  }
19
18
  export interface InputConfiguration {
20
19
  name: string;
20
+ isNested: boolean;
21
21
  type: ExtendedInputTypes;
22
22
  inputType: 'text' | 'email' | 'tel' | 'password' | 'number' | 'date';
23
23
  label?: string;
@@ -1,9 +1,10 @@
1
1
  import { InputConfiguration, InputOptions } from '../Input';
2
+ export type SelectPreloader<T> = () => Promise<{
3
+ label: string;
4
+ value: T;
5
+ }[]>;
2
6
  export interface SelectInputOptions<T> extends InputOptions {
3
- onSelectPreloader?: () => Promise<{
4
- label: string;
5
- value: T;
6
- }[]>;
7
+ onSelectPreloader?: SelectPreloader<T>;
7
8
  defaultOptions?: {
8
9
  value: T;
9
10
  label: string;
@@ -13,10 +14,7 @@ export interface SelectInputOptions<T> extends InputOptions {
13
14
  }
14
15
  export interface SelectInputConfiguration<T> extends InputConfiguration {
15
16
  type: 'select';
16
- onSelectPreloader?: () => Promise<{
17
- label: string;
18
- value: T;
19
- }[]>;
17
+ onSelectPreloader?: SelectPreloader<T>;
20
18
  defaultOptions?: {
21
19
  value: T;
22
20
  label: string;