@isi-ui7/bos7-shared 0.2.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 (108) hide show
  1. package/dist/api.d.ts +4 -0
  2. package/dist/auth7/client.d.ts +26 -0
  3. package/dist/auth7/delegated-proxy.d.ts +33 -0
  4. package/dist/auth7/hooks/useAuth.d.ts +10 -0
  5. package/dist/auth7/hooks/useSession.d.ts +12 -0
  6. package/dist/auth7/index.d.ts +12 -0
  7. package/dist/auth7/provider.d.ts +13 -0
  8. package/dist/auth7/scope-guard.d.ts +5 -0
  9. package/dist/auth7/service-account.d.ts +2 -0
  10. package/dist/auth7/token-exchange.d.ts +11 -0
  11. package/dist/auth7/types.d.ts +63 -0
  12. package/dist/backend.d.ts +20 -0
  13. package/dist/crud-components.d.ts +47 -0
  14. package/dist/crud-hooks.d.ts +15 -0
  15. package/dist/crud-types.d.ts +86 -0
  16. package/dist/data-table/cursor-adapter.d.ts +74 -0
  17. package/dist/event-bus/index.d.ts +20 -0
  18. package/dist/event-bus/useEventBus.d.ts +21 -0
  19. package/dist/event-bus.d.ts +1 -0
  20. package/dist/export.d.ts +7 -0
  21. package/dist/form-layout.d.ts +39 -0
  22. package/dist/form-numeric.d.ts +35 -0
  23. package/dist/form-renderer-utils.d.ts +10 -0
  24. package/dist/form-renderer.d.ts +18 -0
  25. package/dist/form-rules.d.ts +12 -0
  26. package/dist/form-types.d.ts +130 -0
  27. package/dist/html2canvas.esm-d2sM-0Wm.js +4870 -0
  28. package/dist/i18n.d.ts +35 -0
  29. package/dist/index.d.ts +18 -0
  30. package/dist/index.es-Bylk5fh-.js +5649 -0
  31. package/dist/index.js +20779 -0
  32. package/dist/jspdf.es.min-Dzm5j8wC.js +9977 -0
  33. package/dist/jspdf.plugin.autotable-DcntYaes.js +1078 -0
  34. package/dist/modal-layout.d.ts +45 -0
  35. package/dist/nats/client.d.ts +54 -0
  36. package/dist/notif7.d.ts +21 -0
  37. package/dist/notification/routing.d.ts +4 -0
  38. package/dist/notifications-bff.d.ts +22 -0
  39. package/dist/observability/otel-init.d.ts +1 -0
  40. package/dist/page-layout.d.ts +24 -0
  41. package/dist/purify.es-CiEWEeUM.js +605 -0
  42. package/dist/shell/app-shell-layout.d.ts +70 -0
  43. package/dist/shell/branch.d.ts +6 -0
  44. package/dist/shell/interaction.d.ts +2 -0
  45. package/dist/shell/provider.d.ts +15 -0
  46. package/dist/style-contract.d.ts +72 -0
  47. package/dist/types/core.d.ts +39 -0
  48. package/dist/types/notification.d.ts +30 -0
  49. package/dist/workflow/api-client.d.ts +2 -0
  50. package/dist/workflow/backend.d.ts +9 -0
  51. package/dist/workflow/crud-client.d.ts +3 -0
  52. package/dist/workflow/notif7.d.ts +6 -0
  53. package/dist/workflow/starter.d.ts +44 -0
  54. package/dist/workflow/use-crud-form.d.ts +27 -0
  55. package/dist/workflow/use-workflow-tracker.d.ts +40 -0
  56. package/package.json +92 -0
  57. package/src/api.ts +40 -0
  58. package/src/auth7/client.ts +248 -0
  59. package/src/auth7/delegated-proxy.ts +80 -0
  60. package/src/auth7/hooks/useAuth.ts +21 -0
  61. package/src/auth7/hooks/useSession.ts +75 -0
  62. package/src/auth7/index.ts +14 -0
  63. package/src/auth7/provider.tsx +256 -0
  64. package/src/auth7/scope-guard.ts +54 -0
  65. package/src/auth7/service-account.ts +71 -0
  66. package/src/auth7/token-exchange.ts +125 -0
  67. package/src/auth7/types.ts +72 -0
  68. package/src/backend.ts +96 -0
  69. package/src/crud-components.tsx +580 -0
  70. package/src/crud-hooks.test.ts +32 -0
  71. package/src/crud-hooks.ts +31 -0
  72. package/src/crud-types.ts +64 -0
  73. package/src/data-table/cursor-adapter.ts +239 -0
  74. package/src/event-bus/index.ts +90 -0
  75. package/src/event-bus/useEventBus.ts +93 -0
  76. package/src/event-bus.ts +1 -0
  77. package/src/export.ts +62 -0
  78. package/src/form-contract.css +52 -0
  79. package/src/form-layout.tsx +90 -0
  80. package/src/form-numeric.ts +173 -0
  81. package/src/form-renderer-utils.ts +139 -0
  82. package/src/form-renderer.tsx +624 -0
  83. package/src/form-rules.ts +54 -0
  84. package/src/form-types.ts +126 -0
  85. package/src/i18n.tsx +92 -0
  86. package/src/index.ts +20 -0
  87. package/src/modal-layout.tsx +60 -0
  88. package/src/nats/client.ts +130 -0
  89. package/src/notif7.ts +76 -0
  90. package/src/notification/routing.ts +64 -0
  91. package/src/notifications-bff.ts +273 -0
  92. package/src/observability/otel-init.ts +41 -0
  93. package/src/page-layout.tsx +69 -0
  94. package/src/shell/app-shell-layout.tsx +494 -0
  95. package/src/shell/branch.ts +48 -0
  96. package/src/shell/interaction.ts +17 -0
  97. package/src/shell/provider.tsx +34 -0
  98. package/src/style-contract.test.ts +59 -0
  99. package/src/style-contract.ts +132 -0
  100. package/src/types/core.ts +46 -0
  101. package/src/types/notification.ts +35 -0
  102. package/src/workflow/api-client.ts +7 -0
  103. package/src/workflow/backend.ts +53 -0
  104. package/src/workflow/crud-client.ts +43 -0
  105. package/src/workflow/notif7.ts +28 -0
  106. package/src/workflow/starter.ts +153 -0
  107. package/src/workflow/use-crud-form.ts +176 -0
  108. package/src/workflow/use-workflow-tracker.ts +109 -0
@@ -0,0 +1,130 @@
1
+ import { ReactNode } from 'react';
2
+ import { Ui7FormDensity } from './style-contract';
3
+ import { T_LookupTblStruct } from '@isi-ui7/lookup-input';
4
+
5
+ export type FormMode = "create" | "edit" | "view";
6
+ export type ApiPath = string | ((params: Record<string, string>) => string);
7
+ /** Per-field validator function — same signature used by Rules.* and FieldValidation.validators[]. */
8
+ export type FieldValidatorFn<TData = Record<string, unknown>> = (value: unknown, data: TData) => string | undefined;
9
+ export type FieldValidation<TData extends Record<string, unknown>> = {
10
+ required?: true | string;
11
+ minLength?: number | [number, string];
12
+ maxLength?: number | [number, string];
13
+ min?: number | [number, string];
14
+ max?: number | [number, string];
15
+ pattern?: RegExp | [RegExp, string];
16
+ /** Single custom validator (kept for backward compatibility). */
17
+ custom?: FieldValidatorFn<TData>;
18
+ /** Array of validators — compose Rules.* or custom functions. Runs after built-in rules. */
19
+ validators?: FieldValidatorFn<TData>[];
20
+ };
21
+ export type FormFieldType = "text" | "textarea" | "number" | "date" | "select" | "lookup" | "checkbox" | "toggle";
22
+ export type FormFieldOption = {
23
+ value: string;
24
+ label: string;
25
+ };
26
+ export type FormFieldLookupConfig<TData extends Record<string, unknown>> = {
27
+ lookupAPI: string;
28
+ lookupDataStructure: Record<string, T_LookupTblStruct>;
29
+ lookupFieldTitles: Record<string, string>;
30
+ displayFieldNames: string[];
31
+ popupWidthPx?: number;
32
+ placeholder?: string;
33
+ dataSource?: "api" | "direct";
34
+ /** Return a patch to merge into the form when a lookup row is selected. */
35
+ onDataPatch?: (row: Record<string, unknown>, data: TData) => Partial<TData>;
36
+ };
37
+ export type FormFieldNumericConfig<TData extends Record<string, unknown>> = {
38
+ kind: "currency";
39
+ currencyField: keyof TData;
40
+ precisionByCurrency: Record<string, number>;
41
+ defaultPrecision?: number;
42
+ } | {
43
+ kind: "percent";
44
+ maxFractionDigits: number;
45
+ } | {
46
+ kind: "integer";
47
+ } | {
48
+ kind: "phone";
49
+ minDigits: number;
50
+ maxDigits: number;
51
+ allowedPrefixes?: string[];
52
+ };
53
+ export type FormField<TData extends Record<string, unknown>> = {
54
+ key: keyof TData;
55
+ label: ReactNode;
56
+ type: FormFieldType;
57
+ span?: number;
58
+ /** Static or dynamic readonly. Function receives current mode + form data. */
59
+ readonly?: boolean | ((mode: FormMode, data: TData) => boolean);
60
+ /** Static or dynamic visibility. Hidden fields are skipped in validation. */
61
+ hidden?: boolean | ((mode: FormMode, data: TData) => boolean);
62
+ /** Restrict to specific modes (undefined = all modes). */
63
+ mode?: FormMode | FormMode[];
64
+ helperText?: ReactNode;
65
+ placeholder?: string;
66
+ maxLength?: number;
67
+ rows?: number;
68
+ inputMode?: "text" | "numeric" | "decimal" | "email" | "tel" | "url";
69
+ options?: FormFieldOption[];
70
+ lookup?: FormFieldLookupConfig<TData>;
71
+ numeric?: FormFieldNumericConfig<TData>;
72
+ format?: (value: TData[keyof TData], data: TData) => ReactNode;
73
+ validation?: FieldValidation<TData>;
74
+ };
75
+ export type FormSection<TData extends Record<string, unknown>> = {
76
+ title?: ReactNode;
77
+ description?: ReactNode;
78
+ /** Number of equal columns in the section grid. Default 1. */
79
+ columns?: 1 | 2 | 3;
80
+ fields: FormField<TData>[];
81
+ };
82
+ export type FormPageDef<TData extends Record<string, unknown>> = {
83
+ label: string;
84
+ sections: FormSection<TData>[];
85
+ /** Optional: save draft on Next. Returns {ok,error?} (no 202 required). */
86
+ stepSaveApiPath?: ApiPath;
87
+ };
88
+ export type FormLayout<TData extends Record<string, unknown>> = {
89
+ type: "single-page";
90
+ sections: FormSection<TData>[];
91
+ } | {
92
+ type: "tabs";
93
+ pages: FormPageDef<TData>[];
94
+ } | {
95
+ type: "wizard";
96
+ pages: FormPageDef<TData>[];
97
+ validateOnNext?: boolean;
98
+ };
99
+ export type CrudForm<TData extends Record<string, unknown>> = {
100
+ title: {
101
+ create: string;
102
+ edit: string;
103
+ view: string;
104
+ };
105
+ subtitle?: string | {
106
+ create: string;
107
+ edit: string;
108
+ view: string;
109
+ };
110
+ /** Omit entirely to use i18n defaults ("Simpan" / "Update"). Per-key also optional. */
111
+ submitLabel?: {
112
+ create?: string;
113
+ edit?: string;
114
+ };
115
+ /** Omit to use i18n default ("Batal"). */
116
+ backLabel?: {
117
+ view?: string;
118
+ others?: string;
119
+ };
120
+ /** Form layout density. Defaults to "compact". */
121
+ density?: Ui7FormDensity;
122
+ emptyData: TData;
123
+ createApiPath: ApiPath;
124
+ updateApiPath?: ApiPath;
125
+ /** Required for edit + view modes. */
126
+ loadApiPath?: ApiPath;
127
+ /** Cross-field validation run after per-field rules. */
128
+ validate?: (data: TData) => Partial<Record<keyof TData, string>>;
129
+ layout: FormLayout<TData>;
130
+ };