1 | import * as React from 'react';
|
2 |
|
3 | export * from './theme/types';
|
4 | import { IPropsTheme } from './theme/types';
|
5 |
|
6 | export type PropsData = Record<string, unknown> | PropArray;
|
7 | export type PropScalar = string | boolean | number | null | undefined;
|
8 | export type PropArray = Array<PropScalar | Record<string, unknown>>;
|
9 | export type PropValue = PropScalar | PropArray | Record<string, unknown> | Function;
|
10 |
|
11 | export type PropDataObjectType = 'object' | 'array';
|
12 | export type PropObjectType = PropDataObjectType | 'function';
|
13 | export type PropTypeScalar = 'string' | 'boolean' | 'number';
|
14 | export type PropEmptyType = 'null' | 'undefined';
|
15 | export type PropType = PropTypeScalar | PropEmptyType | PropObjectType;
|
16 |
|
17 | export type PropValueFactory = (
|
18 | e: PropValueFactoryArgs,
|
19 | ) => PropValueFactoryResponse | undefined | void;
|
20 |
|
21 | export type PropValueFactoryResponse = {
|
22 | el?: React.ReactNode;
|
23 | underline?: {
|
24 | color: string | number;
|
25 | style: 'solid' | 'dashed';
|
26 | };
|
27 | };
|
28 |
|
29 | export type PropValueFactoryArgs = {
|
30 | path: string;
|
31 | key: string | number;
|
32 | value: PropValue;
|
33 | type: PropType;
|
34 | theme: IPropsTheme;
|
35 | change(args: { to: string }): void;
|
36 | onFocus(isFocused: boolean): void;
|
37 | };
|
38 |
|
39 | export type PropFilter = (e: PropFilterArgs) => boolean;
|
40 | export type PropFilterArgs = {
|
41 | path: string;
|
42 | key: string | number;
|
43 | value: PropValue;
|
44 | type: PropType;
|
45 | };
|
46 |
|
47 |
|
48 |
|
49 |
|
50 | export type PropsEvent = IPropsChangedEvent | IPropsFocusEvent;
|
51 |
|
52 | export type IPropsChangedEvent<D extends PropsData = any> = {
|
53 | type: 'PROPS/changed';
|
54 | payload: IPropsChange<D>;
|
55 | };
|
56 | export type IPropsChange<D extends PropsData = any> = {
|
57 | action: PropChangeAction;
|
58 | path: string;
|
59 | key: string | number;
|
60 | value: { from: PropValue; to: PropValue };
|
61 | data: { from: D; to: D };
|
62 | };
|
63 | export type PropChangeAction = 'CHANGE' | 'INSERT' | 'DELETE';
|
64 |
|
65 | export type IPropsFocusEvent = {
|
66 | type: 'PROPS/focus';
|
67 | payload: IPropsFocus;
|
68 | };
|
69 | export type IPropsFocus = {
|
70 | isFocused: boolean;
|
71 | path: string;
|
72 | };
|