@jsb188/app 1.1.10 → 1.1.11

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 (63) hide show
  1. package/package.json +54 -45
  2. package/src/constants/agent.ts +58 -25
  3. package/src/constants/app.ts +18 -14
  4. package/src/constants/billing.ts +92 -92
  5. package/src/constants/emoji.ts +9144 -8936
  6. package/src/constants/other.ts +1 -5
  7. package/src/constants/user.ts +16 -25
  8. package/src/constants/wsActions.ts +35 -0
  9. package/src/i18n/account.ts +129 -107
  10. package/src/i18n/agent.ts +63 -43
  11. package/src/i18n/agentDoc.ts +110 -0
  12. package/src/i18n/app.ts +101 -91
  13. package/src/i18n/auth.ts +119 -102
  14. package/src/i18n/billing.ts +73 -78
  15. package/src/i18n/campaign.ts +217 -0
  16. package/src/i18n/country.ts +248 -248
  17. package/src/i18n/datetime.ts +26 -26
  18. package/src/i18n/error.ts +428 -182
  19. package/src/i18n/field_docs.ts +28 -0
  20. package/src/i18n/form.ts +464 -344
  21. package/src/i18n/index.ts +25 -18
  22. package/src/i18n/log.ts +53 -213
  23. package/src/i18n/memory.ts +39 -0
  24. package/src/i18n/message.ts +3 -4
  25. package/src/i18n/note.ts +17 -0
  26. package/src/i18n/org.ts +115 -109
  27. package/src/i18n/sheet.ts +376 -4
  28. package/src/i18n/workflow.ts +70 -23
  29. package/src/main.ts +66 -62
  30. package/src/platform.ts +25 -24
  31. package/src/types/ai.d.ts +33 -23
  32. package/src/types/app.d.ts +95 -37
  33. package/src/types/auth.d.ts +66 -40
  34. package/src/types/console.d.ts +3 -0
  35. package/src/types/form.d.ts +65 -61
  36. package/src/types/other.d.ts +6 -6
  37. package/src/types.d.ts +12 -14
  38. package/src/utils/account.ts +64 -58
  39. package/src/utils/api.ts +280 -77
  40. package/src/utils/authSession.ts +24 -0
  41. package/src/utils/billing.ts +110 -103
  42. package/src/utils/color.ts +202 -0
  43. package/src/utils/cron.ts +49 -18
  44. package/src/utils/datetime.ts +255 -103
  45. package/src/utils/emoji.ts +107 -84
  46. package/src/utils/expression.ts +867 -0
  47. package/src/utils/interval.ts +80 -0
  48. package/src/utils/logic.ts +209 -36
  49. package/src/utils/managedSession.ts +34 -0
  50. package/src/utils/managedSessionBff.test.ts +60 -0
  51. package/src/utils/managedSessionBff.ts +117 -0
  52. package/src/utils/number.ts +60 -32
  53. package/src/utils/object.ts +198 -30
  54. package/src/utils/promise.ts +27 -0
  55. package/src/utils/queryReset.ts +179 -0
  56. package/src/utils/recurringTask.ts +60 -0
  57. package/src/utils/schema.ts +293 -0
  58. package/src/utils/string.test.ts +220 -208
  59. package/src/utils/string.ts +471 -438
  60. package/src/utils/timeZone.ts +309 -851
  61. package/src/utils/url_client.ts +73 -69
  62. package/tsconfig.json +10 -10
  63. package/src/i18n/product.ts +0 -76
package/src/platform.ts CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  const PLATFORM_HANDLERS: Record<string, any> = {};
3
2
 
4
3
  /**
@@ -6,7 +5,7 @@ const PLATFORM_HANDLERS: Record<string, any> = {};
6
5
  */
7
6
 
8
7
  export function getPlatform(): 'WEB' | 'MOBILE' | 'UNKNOWN' {
9
- return PLATFORM_HANDLERS?.getPlatform?.() || 'UNKNOWN';
8
+ return PLATFORM_HANDLERS?.getPlatform?.() || 'UNKNOWN';
10
9
  }
11
10
 
12
11
  /**
@@ -14,7 +13,7 @@ export function getPlatform(): 'WEB' | 'MOBILE' | 'UNKNOWN' {
14
13
  */
15
14
 
16
15
  export const fetchAuthToken = (cb: (token: string | null) => void): void => {
17
- return PLATFORM_HANDLERS?.fetchAuthToken?.(cb) || cb(null);
16
+ return PLATFORM_HANDLERS?.fetchAuthToken?.(cb) || cb(null);
18
17
  };
19
18
 
20
19
  /**
@@ -22,7 +21,7 @@ export const fetchAuthToken = (cb: (token: string | null) => void): void => {
22
21
  */
23
22
 
24
23
  export const deleteAuthToken = (): void => {
25
- return PLATFORM_HANDLERS?.deleteAuthToken?.();
24
+ return PLATFORM_HANDLERS?.deleteAuthToken?.();
26
25
  };
27
26
 
28
27
  /**
@@ -30,7 +29,7 @@ export const deleteAuthToken = (): void => {
30
29
  */
31
30
 
32
31
  export function saveAuthTokenToPlatform(token: string, cb: () => void) {
33
- return PLATFORM_HANDLERS?.saveAuthTokenToPlatform?.(token, cb) || cb();
32
+ return PLATFORM_HANDLERS?.saveAuthTokenToPlatform?.(token, cb) || cb();
34
33
  }
35
34
 
36
35
  /**
@@ -39,7 +38,7 @@ export function saveAuthTokenToPlatform(token: string, cb: () => void) {
39
38
  */
40
39
 
41
40
  export function clearAppCache() {
42
- return PLATFORM_HANDLERS?.clearAppCache?.();
41
+ return PLATFORM_HANDLERS?.clearAppCache?.();
43
42
  }
44
43
 
45
44
  /**
@@ -47,10 +46,12 @@ export function clearAppCache() {
47
46
  */
48
47
 
49
48
  export const fetchLightModeSetting = (
50
- accountId: number | null,
51
- cb: (lightMode: string) => void,
49
+ accountId: number | null,
50
+ cb: (lightMode: string) => void,
52
51
  ): void => {
53
- return PLATFORM_HANDLERS?.fetchLightModeSetting?.(accountId, cb) || cb('SYSTEM');
52
+ return (
53
+ PLATFORM_HANDLERS?.fetchLightModeSetting?.(accountId, cb) || cb('SYSTEM')
54
+ );
54
55
  };
55
56
 
56
57
  /**
@@ -58,7 +59,7 @@ export const fetchLightModeSetting = (
58
59
  */
59
60
 
60
61
  export function getOS() {
61
- return PLATFORM_HANDLERS?.getOS?.();
62
+ return PLATFORM_HANDLERS?.getOS?.();
62
63
  }
63
64
 
64
65
  /**
@@ -66,7 +67,7 @@ export function getOS() {
66
67
  */
67
68
 
68
69
  export function updateAppTheme(lightMode: string, theme: string) {
69
- return PLATFORM_HANDLERS?.updateAppTheme?.(lightMode, theme);
70
+ return PLATFORM_HANDLERS?.updateAppTheme?.(lightMode, theme);
70
71
  }
71
72
 
72
73
  /**
@@ -74,7 +75,7 @@ export function updateAppTheme(lightMode: string, theme: string) {
74
75
  */
75
76
 
76
77
  export function getLocalLastVersion(accountId: string) {
77
- return PLATFORM_HANDLERS?.getLocalLastVersion?.(accountId);
78
+ return PLATFORM_HANDLERS?.getLocalLastVersion?.(accountId);
78
79
  }
79
80
 
80
81
  /**
@@ -82,7 +83,7 @@ export function getLocalLastVersion(accountId: string) {
82
83
  */
83
84
 
84
85
  export function saveLocalLastVersion(accountId: string, version: string) {
85
- return PLATFORM_HANDLERS?.saveLocalLastVersion?.(accountId, version);
86
+ return PLATFORM_HANDLERS?.saveLocalLastVersion?.(accountId, version);
86
87
  }
87
88
 
88
89
  /**
@@ -90,7 +91,7 @@ export function saveLocalLastVersion(accountId: string, version: string) {
90
91
  */
91
92
 
92
93
  export function getFileInputObject(fileInput: File) {
93
- return PLATFORM_HANDLERS?.getFileInputObject?.(fileInput) || fileInput;
94
+ return PLATFORM_HANDLERS?.getFileInputObject?.(fileInput) || fileInput;
94
95
  }
95
96
 
96
97
  /**
@@ -98,7 +99,7 @@ export function getFileInputObject(fileInput: File) {
98
99
  */
99
100
 
100
101
  export function getBufferDataFromFile(file: any) {
101
- return PLATFORM_HANDLERS?.getBufferDataFromFile?.(file) || file;
102
+ return PLATFORM_HANDLERS?.getBufferDataFromFile?.(file) || file;
102
103
  }
103
104
 
104
105
  /**
@@ -106,7 +107,7 @@ export function getBufferDataFromFile(file: any) {
106
107
  */
107
108
 
108
109
  export function isSystemDarkMode() {
109
- return PLATFORM_HANDLERS?.isSystemDarkMode?.();
110
+ return PLATFORM_HANDLERS?.isSystemDarkMode?.();
110
111
  }
111
112
 
112
113
  /**
@@ -114,12 +115,12 @@ export function isSystemDarkMode() {
114
115
  */
115
116
 
116
117
  export function registerPlatformHandlers(handlers: Record<string, any>) {
117
- for (const key in handlers) {
118
- if (
119
- Object.prototype.hasOwnProperty.call(handlers, key) &&
120
- typeof handlers[key] === 'function'
121
- ) {
122
- PLATFORM_HANDLERS[key] = handlers[key];
123
- }
124
- }
118
+ for (const key in handlers) {
119
+ if (
120
+ Object.prototype.hasOwnProperty.call(handlers, key) &&
121
+ typeof handlers[key] === 'function'
122
+ ) {
123
+ PLATFORM_HANDLERS[key] = handlers[key];
124
+ }
125
+ }
125
126
  }
package/src/types/ai.d.ts CHANGED
@@ -1,34 +1,44 @@
1
-
2
1
  // AI chat types
3
2
 
4
- export type AIChatMessageType = 'MESSAGE' | 'SMS' | 'FUNCTION_CALL'| 'FUNCTION_CALL_OUTPUT';
3
+ export type AIChatMessageType =
4
+ | 'MESSAGE'
5
+ | 'SMS'
6
+ | 'IMAGE'
7
+ | 'FILE'
8
+ | 'SMS_IMAGE'
9
+ | 'SMS_FILE'
10
+ | 'TRANSCRIBED_MESSAGE'
11
+ | 'FUNCTION_CALL'
12
+ | 'FUNCTION_CALL_OUTPUT';
5
13
 
6
14
  // AI events
7
15
 
8
16
  export type AIEventErrorName =
9
- | 'AI_EVENT_UNKNOWN_ERR'
10
- | 'AI_EVENT_DEVELOPER_ERR'
11
- | 'AI_EVENT_NO_ACCESS'
12
- | 'AI_COULD_NOT_RESOLVE'
13
- | 'AI_CONTEXT_ERR'
14
- | 'AI_ORG_ACL_FAILED'
15
- | 'SETUP_INCOMPLETE_ORG'
16
- | 'MISSING_API_KEY'
17
- | 'LLM_PROVIDER_NOT_FOUND'
18
- | 'LLM_SERVICE_ERR'
19
- | 'MODERATION_MISSING'
20
- | 'MODERATION_SERVICE_ERR'
21
- | 'UNKNOWN_LLM_ERR'
22
- | 'TWILIO_API_ERR'
23
- | 'UNFINISHED_LOGIC';
17
+ | 'AI_EVENT_UNKNOWN_ERR'
18
+ | 'AI_EVENT_DEVELOPER_ERR'
19
+ | 'AI_EVENT_NO_ACCESS'
20
+ | 'AI_COULD_NOT_RESOLVE'
21
+ | 'AI_CONTEXT_ERR'
22
+ | 'AI_ORG_ACL_FAILED'
23
+ | 'SETUP_INCOMPLETE_ORG'
24
+ | 'MISSING_API_KEY'
25
+ | 'LLM_PROVIDER_NOT_FOUND'
26
+ | 'LLM_SERVICE_ERR'
27
+ | 'MODERATION_MISSING'
28
+ | 'MODERATION_SERVICE_ERR'
29
+ | 'UNKNOWN_LLM_ERR'
30
+ | 'TWILIO_API_ERR'
31
+ | 'UNFINISHED_LOGIC';
24
32
 
25
33
  // AI chat
26
34
 
27
35
  export interface AIChatData {
28
- id: string;
29
- calDate: string;
30
- summary: string;
31
- archivedAt: string | null;
32
- createdAt: string;
33
- updatedAt: string;
36
+ id: string;
37
+ organizationId: string | null;
38
+ calDate: string | null;
39
+ summary: string;
40
+ userManagedSummary: boolean;
41
+ archivedAt: string | null;
42
+ createdAt: string;
43
+ updatedAt: string;
34
44
  }
@@ -1,31 +1,32 @@
1
1
  import { COLORS } from '../constants/app.ts';
2
+ import type { QueryResetTarget } from '../utils/queryReset.ts';
2
3
 
3
4
  // Modal; App settings
4
5
 
5
6
  export interface EditIfaceModalProps {
6
- containerClassName: string;
7
- saveCounter: number;
8
- saving: boolean;
9
- hasChanges: boolean;
10
- openModalPopUp: (opts: any) => void;
11
- onChangeDiff: (diff: boolean) => void;
7
+ containerClassName: string;
8
+ saveCounter: number;
9
+ saving: boolean;
10
+ hasChanges: boolean;
11
+ openModalPopUp: (opts: any) => void;
12
+ onChangeDiff: (diff: boolean) => void;
12
13
  }
13
14
 
14
15
  export interface EditUserModalProps extends EditIfaceModalProps {
15
- user: any;
16
- editUser: (obj: object) => void;
16
+ user: any;
17
+ editUser: (obj: object) => void;
17
18
  }
18
19
 
19
20
  export interface EditUserPlusModalProps extends EditIfaceModalProps {
20
- user: any;
21
- editUserPlus: (obj: object) => void;
21
+ user: any;
22
+ editUserPlus: (obj: object) => void;
22
23
  }
23
24
 
24
25
  // App types
25
26
 
26
27
  export type DarkOrLightEnum = 'light' | 'dark';
27
28
 
28
- export type ColorEnum = typeof COLORS[number];
29
+ export type ColorEnum = (typeof COLORS)[number];
29
30
 
30
31
  // Stripe types
31
32
 
@@ -34,43 +35,100 @@ export type PlatformProductGroupEnum = 'PERKS' | 'PLUS' | 'PRO' | 'COINS';
34
35
  // Server/API related types
35
36
 
36
37
  export interface ServerErrorObj {
37
- statusCode: number;
38
- errorCode: string;
39
- errorValue?: string;
40
- iconName?: string;
41
- title: string;
42
- message: string;
38
+ statusCode: number;
39
+ errorCode: string;
40
+ errorValue?: string;
41
+ iconName?: string;
42
+ title: string;
43
+ message: string;
43
44
  }
44
45
 
45
46
  export interface SimpleErrorType {
46
- iconName?: string;
47
- title?: string;
48
- message: string;
47
+ iconName?: string;
48
+ title?: string;
49
+ message: string;
49
50
  }
50
51
 
51
52
  // Web Socket events
52
53
 
53
- export type ResetQueryRuleEnum = 'ALWAYS' | 'IF_FRAGMENT_NOT_FOUND' | 'IF_FRAGMENT_FOUND' | 'NEVER' | 'RESET_ONLY';
54
+ export type ResetQueryRuleEnum =
55
+ | 'ALWAYS'
56
+ | 'IF_FRAGMENT_NOT_FOUND'
57
+ | 'IF_FRAGMENT_FOUND'
58
+ | 'NEVER'
59
+ | 'RESET_ONLY';
54
60
  export type AppendRuleEnum = 'APPEND_NEW' | 'APPEND_AT_END' | 'APPEND_AT_FRONT';
55
61
 
62
+ export interface DataTableChangeWSMeta {
63
+ batchId: string;
64
+ organizationId: string;
65
+ dataTableId: string;
66
+ fromSeq: string;
67
+ toSeq: string;
68
+ chunkIndex: number;
69
+ chunkCount: number;
70
+ }
71
+
72
+ export type DataTableWriteOrderWS =
73
+ | {
74
+ kind: 'CELL';
75
+ dataTableRowId: string;
76
+ cellKey: string;
77
+ serverSeq: string;
78
+ tombstone: boolean;
79
+ }
80
+ | {
81
+ kind: 'DESIGN';
82
+ property:
83
+ | 'CELLS_ORDER'
84
+ | 'FORMAT'
85
+ | 'HUMAN_LABEL'
86
+ | 'ROW_IDENTIFIER'
87
+ | 'WIDTH';
88
+ targetKey: string;
89
+ targetType: 'CELL' | 'TABLE';
90
+ serverSeq: string;
91
+ tombstone: boolean;
92
+ }
93
+ | {
94
+ kind: 'ROW';
95
+ dataTableRowId: string;
96
+ serverSeq: string;
97
+ tombstone: boolean;
98
+ };
99
+
56
100
  export interface WSDataUpdateObj {
57
- id: string;
58
- route: string[]; // First items in the array have priority (Different org operations may not allow the actions handled by other org operations)
59
- message?: string | null; // If null, nothing will be visible to the client.
60
- messageType: 'NORMAL' | 'SUCCESS' | 'ERROR';
61
- resetQueryKeys?: string[]; // List of query keys including {variablesKey}
62
- resetQueryRule?: ResetQueryRuleEnum; // Defaults to "IF_FRAGMENT_FOUND"
63
- reactiveFragmentKeys?: string[]; // Fragment keys that are used to trigger reactivity
64
- fragments?: null | ({
65
- name: string;
66
- dataId: string;
67
- replaceId?: string; // Use this where client has a temporary ID that will be replaced by the server-side ID later
68
- appendRule?: AppendRuleEnum | null;
69
- data: any;
70
- } | null)[];
101
+ id: string;
102
+ route: string[]; // First items in the array have priority (Different org operations may not allow the actions handled by other org operations)
103
+ message?: string | null; // If null, nothing will be visible to the client.
104
+ messageType: 'NORMAL' | 'SUCCESS' | 'ERROR';
105
+ resetQueries?: QueryResetTarget[]; // Structured query reset targets
106
+ resetQueryRule?: ResetQueryRuleEnum; // Defaults to "IF_FRAGMENT_FOUND"
107
+ reactiveFragmentKeys?: string[]; // Fragment keys that are used to trigger reactivity
108
+ dataTableChange?: DataTableChangeWSMeta; // Exact journal range/chunk contract
109
+ dataTableSnapshotRequired?: boolean; // Full snapshot must be awaited before this range is considered converged
110
+ dataTableWriteOrders?: DataTableWriteOrderWS[]; // Committed per-target realtime authority
111
+ // Committed DataTable authority delivered to a Sheet data room so bridged
112
+ // region previews settle without the client joining the DataTable's room
113
+ sheetDataTableWriteOrders?: {
114
+ dataTableId: string;
115
+ organizationId: string;
116
+ orders: DataTableWriteOrderWS[];
117
+ };
118
+ authorizationContextChanged?: boolean; // Private memory/disk cache must be discarded and auth reloaded
119
+ fragments?:
120
+ | null
121
+ | ({
122
+ name: string;
123
+ dataId: string;
124
+ sequence?: string;
125
+ replaceId?: string; // Use this where client has a temporary ID that will be replaced by the server-side ID later
126
+ appendRule?: AppendRuleEnum | null;
127
+ data: any;
128
+ } | null)[];
71
129
  }
72
130
 
73
131
  export interface WSAppContextUpdateObj {
74
- accountId: string;
75
- updates: [any, any][];
132
+ accountId: string;
133
+ updates: [any, any][];
76
134
  }
@@ -1,5 +1,3 @@
1
- import type { OrganizationShortData } from './organization.d.ts';
2
-
3
1
  /**
4
2
  * Auth enums
5
3
  */
@@ -12,42 +10,68 @@ export type LightModeEnum = 'LIGHT' | 'DARK' | 'SYSTEM';
12
10
  */
13
11
 
14
12
  export interface AccountData {
15
- id: string;
16
- deleted: boolean;
13
+ id: string;
14
+ deleted: boolean;
17
15
 
18
- plus: any; // placeholder for later
16
+ plus: any; // placeholder for later
19
17
 
20
- settings: AccountSettings;
18
+ settings: AccountSettings;
21
19
 
22
- profile: {
23
- id: string;
24
- firstName: string;
25
- lastName: string;
26
- photoId: string;
27
- photoUri: string;
28
- };
20
+ profile: {
21
+ id: string;
22
+ firstName: string;
23
+ lastName: string;
24
+ photoId: string;
25
+ photoUri: string;
26
+ };
29
27
 
30
- email: {
31
- id: string;
32
- address: string;
33
- verified: boolean;
34
- };
28
+ email: {
29
+ id: string;
30
+ address: string;
31
+ verified: boolean;
32
+ };
35
33
 
36
- phone: {
37
- id: string;
38
- number: string;
39
- verified: boolean;
40
- };
34
+ phone: {
35
+ id: string;
36
+ number: string;
37
+ verified: boolean;
38
+ };
41
39
  }
42
40
 
43
41
  export interface AccountSettings {
44
- theme: string | null;
45
- language: string;
46
- lightMode: LightModeEnum;
47
- timeZone: string | null;
48
- showSelfAvatar: boolean;
49
- isBubbleOther: boolean;
50
- showOtherAvatar: boolean;
42
+ theme: string | null;
43
+ language: string;
44
+ lightMode: LightModeEnum;
45
+ timeZone: string | null;
46
+ }
47
+
48
+ export interface AccountSessionOrganizationAuthorizationData {
49
+ id: string;
50
+ organizationId: string;
51
+ ssoConnectionId?: string | null;
52
+ authorizationMethod: string;
53
+ authorizedAt: string;
54
+ lastActivityAt?: string | null;
55
+ revokedAt?: string | null;
56
+ revokeReason?: string | null;
57
+ }
58
+
59
+ export interface AccountSessionData {
60
+ id: string;
61
+ accountId: string;
62
+ authMethod: string;
63
+ deviceName?: string | null;
64
+ userAgent?: string | null;
65
+ createdIpAddress?: string | null;
66
+ lastIpAddress?: string | null;
67
+ createdAt: string;
68
+ lastActivityAt: string;
69
+ idleExpiresAt: string;
70
+ absoluteExpiresAt: string;
71
+ revokedAt?: string | null;
72
+ revokeReason?: string | null;
73
+ current: boolean;
74
+ organizationAuthorizations: AccountSessionOrganizationAuthorizationData[];
51
75
  }
52
76
 
53
77
  /**
@@ -55,14 +79,16 @@ export interface AccountSettings {
55
79
  */
56
80
 
57
81
  export interface AuthenticationData {
58
- token: string | null;
59
- timeZone: string | null;
60
- account: AccountData | null;
61
- settings: AccountSettings | null;
62
- primaryOrganizationId: string | null;
63
- activated: boolean;
64
- hasPassword: boolean;
65
- webVersion: string;
66
- mobileVersion: string;
67
- alertUpdatesOnMount: boolean;
82
+ token: string | null;
83
+ sessionBootstrapToken?: string | null;
84
+ cacheAuthorizationEpoch?: string | null;
85
+ timeZone: string | null;
86
+ account: AccountData | null;
87
+ settings: AccountSettings | null;
88
+ primaryOrganizationId: string | null;
89
+ activated: boolean;
90
+ hasPassword: boolean;
91
+ webVersion: string;
92
+ mobileVersion: string;
93
+ alertUpdatesOnMount: boolean;
68
94
  }
@@ -0,0 +1,3 @@
1
+ interface Console {
2
+ dev: (...args: any[]) => void;
3
+ }
@@ -1,63 +1,64 @@
1
+ import type { ChangeEvent, FormEvent, KeyboardEvent, MouseEvent } from 'react';
1
2
 
2
3
  /**
3
4
  * Types; form schema
4
5
  */
5
6
 
6
7
  export type FormValuesObj = {
7
- [key: string]: any;
8
- __errorFields?: string[];
8
+ [key: string]: any;
9
+ __errorFields?: string[];
9
10
  };
10
11
 
11
12
  export type FormValueSetter<TFormValues extends FormValuesObj = any> = (
12
- values: TFormValues | ((prev: TFormValues) => TFormValues)
13
+ values: TFormValues | ((prev: TFormValues) => TFormValues),
13
14
  ) => void;
14
15
 
15
16
  export type FormItemType =
16
- | 'subtitle'
17
- | 'break'
18
- | 'group'
19
- | 'input'
20
- | 'section_title'
21
- | 'input_click'
22
- | 'input_w_button'
23
- | 'input_time_from_date'
24
- | 'password'
25
- | 'textarea'
26
- | 'none'
27
- | (string & {});
17
+ | 'subtitle'
18
+ | 'break'
19
+ | 'group'
20
+ | 'input'
21
+ | 'section_title'
22
+ | 'input_click'
23
+ | 'input_w_button'
24
+ | 'input_time_from_date'
25
+ | 'password'
26
+ | 'textarea'
27
+ | 'none'
28
+ | (string & {});
28
29
 
29
30
  interface SchemaItemAny<TCurrentData = any, TDataForSchema = any> {
30
- [key: string]: any;
31
- __typename?: string;
32
- setter?: (currentData?: TCurrentData, dataForSchema?: TDataForSchema) => any;
31
+ [key: string]: any;
32
+ __typename?: string;
33
+ setter?: (currentData?: TCurrentData, dataForSchema?: TDataForSchema) => any;
33
34
  }
34
35
 
35
36
  export interface FormItemSchemaObj<TCurrentData = any, TDataForSchema = any> {
36
- __type: FormItemType;
37
- autoFocus?: boolean;
38
- disabled?: boolean;
39
- hidden?: boolean | ((dataForSchema: TDataForSchema) => boolean);
40
- locked?: boolean | ((dataForSchema: TDataForSchema) => boolean);
41
- labelClassName?: string;
42
- listenToInput?: boolean;
43
- value?: any;
44
- item: SchemaItemAny<TCurrentData, TDataForSchema>;
37
+ __type: FormItemType;
38
+ autoFocus?: boolean;
39
+ disabled?: boolean;
40
+ hidden?: boolean | ((dataForSchema: TDataForSchema) => boolean);
41
+ locked?: boolean | ((dataForSchema: TDataForSchema) => boolean);
42
+ labelClassName?: string;
43
+ listenToInput?: boolean;
44
+ value?: any;
45
+ item: SchemaItemAny<TCurrentData, TDataForSchema>;
45
46
  }
46
47
 
47
48
  interface SchemaRule<TFormValues extends FormValuesObj = any> {
48
- for: string;
49
- rule: (value: any, formValues: TFormValues) => boolean;
50
- error: any;
51
- };
49
+ for: string;
50
+ rule: (value: any, formValues: TFormValues) => boolean;
51
+ error: any;
52
+ }
52
53
 
53
54
  export interface FormSchemaObj<
54
- TFormValues extends FormValuesObj = any,
55
- TCurrentData = any,
56
- TDataForSchema = any,
55
+ TFormValues extends FormValuesObj = any,
56
+ TCurrentData = any,
57
+ TDataForSchema = any,
57
58
  > {
58
- listData: FormItemSchemaObj<TCurrentData, TDataForSchema>[];
59
- rules?: SchemaRule<TFormValues>[];
60
- isButtonDisabled?: (formValues: TFormValues) => boolean;
59
+ listData: FormItemSchemaObj<TCurrentData, TDataForSchema>[];
60
+ rules?: SchemaRule<TFormValues>[];
61
+ isButtonDisabled?: (formValues: TFormValues) => boolean;
61
62
  }
62
63
 
63
64
  /**
@@ -65,33 +66,36 @@ export interface FormSchemaObj<
65
66
  */
66
67
 
67
68
  interface FormGroupType<
68
- TFormValues extends FormValuesObj = any,
69
- TCurrentData = any,
70
- TDataForSchema = any,
69
+ TFormValues extends FormValuesObj = any,
70
+ TCurrentData = any,
71
+ TDataForSchema = any,
71
72
  > {
72
- id?: string;
73
- name: string;
74
- label?: string;
75
- value: string | number | null;
76
- items: Array<FormItemIfaceObj<TFormValues, TCurrentData, TDataForSchema>>;
73
+ id?: string;
74
+ name: string;
75
+ label?: string;
76
+ value: string | number | null;
77
+ items: Array<FormItemIfaceObj<TFormValues, TCurrentData, TDataForSchema>>;
77
78
  }
78
79
 
79
80
  export interface FormItemIfaceObj<
80
- TFormValues extends FormValuesObj = any,
81
- TCurrentData = any,
82
- TDataForSchema = any,
81
+ TFormValues extends FormValuesObj = any,
82
+ TCurrentData = any,
83
+ TDataForSchema = any,
83
84
  > extends FormItemSchemaObj<TCurrentData, TDataForSchema> {
84
- name: string;
85
- preset?: string;
86
- className?: string;
87
- inputClassName?: string;
88
- focusStyle?: string;
89
- hidden?: boolean | ((dataForSchema: TDataForSchema) => boolean);
90
- locked?: boolean | ((dataForSchema: TDataForSchema) => boolean);
91
- formValues: TFormValues;
92
- setFormValues: FormValueSetter<TFormValues>;
93
- onInput?: (e: React.FormEvent, name: string) => void;
94
- onKeyDown?: (e: React.KeyboardEvent, name: string) => void;
95
- onSubmit?: (e: React.MouseEvent, name: string) => void;
96
- onChange?: (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>, name: string) => void;
85
+ name: string;
86
+ preset?: string;
87
+ className?: string;
88
+ inputClassName?: string;
89
+ focusStyle?: string;
90
+ hidden?: boolean | ((dataForSchema: TDataForSchema) => boolean);
91
+ locked?: boolean | ((dataForSchema: TDataForSchema) => boolean);
92
+ formValues: TFormValues;
93
+ setFormValues: FormValueSetter<TFormValues>;
94
+ onInput?: (e: FormEvent, name: string) => void;
95
+ onKeyDown?: (e: KeyboardEvent, name: string) => void;
96
+ onSubmit?: (e: MouseEvent, name: string) => void;
97
+ onChange?: (
98
+ e: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>,
99
+ name: string,
100
+ ) => void;
97
101
  }