@ram_28/kf-ai-sdk 1.0.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 (126) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +840 -0
  3. package/dist/api/client.d.ts +78 -0
  4. package/dist/api/client.d.ts.map +1 -0
  5. package/dist/api/datetime.d.ts +21 -0
  6. package/dist/api/datetime.d.ts.map +1 -0
  7. package/dist/api/index.d.ts +7 -0
  8. package/dist/api/index.d.ts.map +1 -0
  9. package/dist/api/metadata.d.ts +75 -0
  10. package/dist/api/metadata.d.ts.map +1 -0
  11. package/dist/components/hooks/index.d.ts +8 -0
  12. package/dist/components/hooks/index.d.ts.map +1 -0
  13. package/dist/components/hooks/useFilter/index.d.ts +5 -0
  14. package/dist/components/hooks/useFilter/index.d.ts.map +1 -0
  15. package/dist/components/hooks/useFilter/payloadBuilder.utils.d.ts +33 -0
  16. package/dist/components/hooks/useFilter/payloadBuilder.utils.d.ts.map +1 -0
  17. package/dist/components/hooks/useFilter/types.d.ts +137 -0
  18. package/dist/components/hooks/useFilter/types.d.ts.map +1 -0
  19. package/dist/components/hooks/useFilter/useFilter.d.ts +3 -0
  20. package/dist/components/hooks/useFilter/useFilter.d.ts.map +1 -0
  21. package/dist/components/hooks/useFilter/validation.utils.d.ts +38 -0
  22. package/dist/components/hooks/useFilter/validation.utils.d.ts.map +1 -0
  23. package/dist/components/hooks/useForm/apiClient.d.ts +71 -0
  24. package/dist/components/hooks/useForm/apiClient.d.ts.map +1 -0
  25. package/dist/components/hooks/useForm/expressionValidator.utils.d.ts +28 -0
  26. package/dist/components/hooks/useForm/expressionValidator.utils.d.ts.map +1 -0
  27. package/dist/components/hooks/useForm/index.d.ts +6 -0
  28. package/dist/components/hooks/useForm/index.d.ts.map +1 -0
  29. package/dist/components/hooks/useForm/optimizedExpressionValidator.utils.d.ts +88 -0
  30. package/dist/components/hooks/useForm/optimizedExpressionValidator.utils.d.ts.map +1 -0
  31. package/dist/components/hooks/useForm/ruleClassifier.utils.d.ts +28 -0
  32. package/dist/components/hooks/useForm/ruleClassifier.utils.d.ts.map +1 -0
  33. package/dist/components/hooks/useForm/schemaParser.utils.d.ts +29 -0
  34. package/dist/components/hooks/useForm/schemaParser.utils.d.ts.map +1 -0
  35. package/dist/components/hooks/useForm/types.d.ts +412 -0
  36. package/dist/components/hooks/useForm/types.d.ts.map +1 -0
  37. package/dist/components/hooks/useForm/useForm.d.ts +3 -0
  38. package/dist/components/hooks/useForm/useForm.d.ts.map +1 -0
  39. package/dist/components/hooks/useKanban/apiClient.d.ts +99 -0
  40. package/dist/components/hooks/useKanban/apiClient.d.ts.map +1 -0
  41. package/dist/components/hooks/useKanban/context.d.ts +4 -0
  42. package/dist/components/hooks/useKanban/context.d.ts.map +1 -0
  43. package/dist/components/hooks/useKanban/dragDropManager.d.ts +27 -0
  44. package/dist/components/hooks/useKanban/dragDropManager.d.ts.map +1 -0
  45. package/dist/components/hooks/useKanban/index.d.ts +6 -0
  46. package/dist/components/hooks/useKanban/index.d.ts.map +1 -0
  47. package/dist/components/hooks/useKanban/types.d.ts +438 -0
  48. package/dist/components/hooks/useKanban/types.d.ts.map +1 -0
  49. package/dist/components/hooks/useKanban/useKanban.d.ts +3 -0
  50. package/dist/components/hooks/useKanban/useKanban.d.ts.map +1 -0
  51. package/dist/components/hooks/useKanban/useKanbanSimple.d.ts +62 -0
  52. package/dist/components/hooks/useKanban/useKanbanSimple.d.ts.map +1 -0
  53. package/dist/components/hooks/useTable/index.d.ts +3 -0
  54. package/dist/components/hooks/useTable/index.d.ts.map +1 -0
  55. package/dist/components/hooks/useTable/types.d.ts +107 -0
  56. package/dist/components/hooks/useTable/types.d.ts.map +1 -0
  57. package/dist/components/hooks/useTable/useTable.d.ts +8 -0
  58. package/dist/components/hooks/useTable/useTable.d.ts.map +1 -0
  59. package/dist/components/index.d.ts +3 -0
  60. package/dist/components/index.d.ts.map +1 -0
  61. package/dist/components/ui/index.d.ts +2 -0
  62. package/dist/components/ui/index.d.ts.map +1 -0
  63. package/dist/components/ui/kanban/Kanban.d.ts +12 -0
  64. package/dist/components/ui/kanban/Kanban.d.ts.map +1 -0
  65. package/dist/components/ui/kanban/index.d.ts +2 -0
  66. package/dist/components/ui/kanban/index.d.ts.map +1 -0
  67. package/dist/index.cjs +45 -0
  68. package/dist/index.d.ts +5 -0
  69. package/dist/index.d.ts.map +1 -0
  70. package/dist/index.mjs +6522 -0
  71. package/dist/types/base-fields.d.ts +182 -0
  72. package/dist/types/base-fields.d.ts.map +1 -0
  73. package/dist/types/common.d.ts +238 -0
  74. package/dist/types/common.d.ts.map +1 -0
  75. package/dist/types/index.d.ts +3 -0
  76. package/dist/types/index.d.ts.map +1 -0
  77. package/dist/utils/cn.d.ts +7 -0
  78. package/dist/utils/cn.d.ts.map +1 -0
  79. package/dist/utils/formatting.d.ts +52 -0
  80. package/dist/utils/formatting.d.ts.map +1 -0
  81. package/dist/utils/index.d.ts +3 -0
  82. package/dist/utils/index.d.ts.map +1 -0
  83. package/package.json +98 -0
  84. package/sdk/api/client.ts +447 -0
  85. package/sdk/api/datetime.ts +33 -0
  86. package/sdk/api/index.ts +61 -0
  87. package/sdk/api/metadata.ts +148 -0
  88. package/sdk/components/hooks/index.ts +34 -0
  89. package/sdk/components/hooks/useFilter/index.ts +37 -0
  90. package/sdk/components/hooks/useFilter/payloadBuilder.utils.ts +298 -0
  91. package/sdk/components/hooks/useFilter/types.ts +158 -0
  92. package/sdk/components/hooks/useFilter/useFilter.llm.txt +497 -0
  93. package/sdk/components/hooks/useFilter/useFilter.ts +494 -0
  94. package/sdk/components/hooks/useFilter/validation.utils.ts +401 -0
  95. package/sdk/components/hooks/useForm/apiClient.ts +441 -0
  96. package/sdk/components/hooks/useForm/expressionValidator.utils.ts +444 -0
  97. package/sdk/components/hooks/useForm/index.ts +64 -0
  98. package/sdk/components/hooks/useForm/optimizedExpressionValidator.utils.ts +482 -0
  99. package/sdk/components/hooks/useForm/ruleClassifier.utils.ts +424 -0
  100. package/sdk/components/hooks/useForm/schemaParser.utils.ts +519 -0
  101. package/sdk/components/hooks/useForm/types.ts +630 -0
  102. package/sdk/components/hooks/useForm/useForm.llm.txt +340 -0
  103. package/sdk/components/hooks/useForm/useForm.ts +821 -0
  104. package/sdk/components/hooks/useKanban/apiClient.ts +494 -0
  105. package/sdk/components/hooks/useKanban/context.ts +14 -0
  106. package/sdk/components/hooks/useKanban/dragDropManager.ts +529 -0
  107. package/sdk/components/hooks/useKanban/index.ts +63 -0
  108. package/sdk/components/hooks/useKanban/types.ts +606 -0
  109. package/sdk/components/hooks/useKanban/useKanban.llm.txt +482 -0
  110. package/sdk/components/hooks/useKanban/useKanban.ts +725 -0
  111. package/sdk/components/hooks/useKanban/useKanbanSimple.ts +389 -0
  112. package/sdk/components/hooks/useTable/index.ts +5 -0
  113. package/sdk/components/hooks/useTable/types.ts +154 -0
  114. package/sdk/components/hooks/useTable/useTable.llm.txt +344 -0
  115. package/sdk/components/hooks/useTable/useTable.ts +413 -0
  116. package/sdk/components/index.ts +15 -0
  117. package/sdk/components/ui/index.ts +2 -0
  118. package/sdk/components/ui/kanban/Kanban.tsx +134 -0
  119. package/sdk/components/ui/kanban/index.ts +11 -0
  120. package/sdk/index.ts +13 -0
  121. package/sdk/types/base-fields.ts +221 -0
  122. package/sdk/types/common.ts +306 -0
  123. package/sdk/types/index.ts +5 -0
  124. package/sdk/utils/cn.ts +10 -0
  125. package/sdk/utils/formatting.ts +212 -0
  126. package/sdk/utils/index.ts +5 -0
@@ -0,0 +1,212 @@
1
+ import type { CurrencyValue, JSONValue } from '../types/base-fields';
2
+
3
+ /**
4
+ * Data formatting utilities for display and conversion
5
+ */
6
+
7
+ /**
8
+ * Format currency value for display
9
+ */
10
+ export function formatCurrency(value: CurrencyValue): string {
11
+ if (typeof value === 'string') {
12
+ return value; // Already formatted
13
+ }
14
+
15
+ if (typeof value === 'object' && value !== null) {
16
+ const formatter = new Intl.NumberFormat('en-US', {
17
+ style: 'currency',
18
+ currency: value.currency,
19
+ });
20
+ return formatter.format(value.value);
21
+ }
22
+
23
+ return 'Invalid Currency';
24
+ }
25
+
26
+ /**
27
+ * Parse currency string to currency object
28
+ */
29
+ export function parseCurrency(value: string): CurrencyValue | null {
30
+ // Try to parse "USD 100.50" or "100.50 USD" format
31
+ const match = value.match(/^(?:([A-Z]{3})\s+(\d+\.?\d*))|(?:(\d+\.?\d*)\s+([A-Z]{3}))$/);
32
+
33
+ if (match) {
34
+ const currency = match[1] || match[4];
35
+ const amount = parseFloat(match[2] || match[3]);
36
+
37
+ if (!isNaN(amount)) {
38
+ return { value: amount, currency };
39
+ }
40
+ }
41
+
42
+ return null;
43
+ }
44
+
45
+ /**
46
+ * Format date for display
47
+ */
48
+ export function formatDate(date: Date, format: 'short' | 'medium' | 'long' = 'medium'): string {
49
+ if (!(date instanceof Date) || isNaN(date.getTime())) {
50
+ return 'Invalid Date';
51
+ }
52
+
53
+ const options: Intl.DateTimeFormatOptions = {
54
+ short: { dateStyle: 'short' as const },
55
+ medium: { dateStyle: 'medium' as const },
56
+ long: { dateStyle: 'long' as const },
57
+ }[format];
58
+
59
+ return new Intl.DateTimeFormat('en-US', options).format(date);
60
+ }
61
+
62
+ /**
63
+ * Format datetime for display
64
+ */
65
+ export function formatDateTime(date: Date, format: 'short' | 'medium' | 'long' = 'medium'): string {
66
+ if (!(date instanceof Date) || isNaN(date.getTime())) {
67
+ return 'Invalid Date';
68
+ }
69
+
70
+ const options: Intl.DateTimeFormatOptions = {
71
+ short: { dateStyle: 'short' as const, timeStyle: 'short' as const },
72
+ medium: { dateStyle: 'medium' as const, timeStyle: 'medium' as const },
73
+ long: { dateStyle: 'long' as const, timeStyle: 'long' as const },
74
+ }[format];
75
+
76
+ return new Intl.DateTimeFormat('en-US', options).format(date);
77
+ }
78
+
79
+ /**
80
+ * Format number with precision
81
+ */
82
+ export function formatNumber(value: number, precision: number = 2): string {
83
+ if (typeof value !== 'number' || isNaN(value)) {
84
+ return 'Invalid Number';
85
+ }
86
+
87
+ return value.toFixed(precision);
88
+ }
89
+
90
+ /**
91
+ * Format JSON value for display
92
+ */
93
+ export function formatJSON(value: JSONValue, indent: number = 2): string {
94
+ try {
95
+ return JSON.stringify(value, null, indent);
96
+ } catch {
97
+ return 'Invalid JSON';
98
+ }
99
+ }
100
+
101
+ /**
102
+ * Format array values for display
103
+ */
104
+ export function formatArray<T>(
105
+ array: T[],
106
+ formatter?: (item: T) => string,
107
+ separator: string = ', '
108
+ ): string {
109
+ if (!Array.isArray(array)) {
110
+ return 'Invalid Array';
111
+ }
112
+
113
+ if (formatter) {
114
+ return array.map(formatter).join(separator);
115
+ }
116
+
117
+ return array.map(item => String(item)).join(separator);
118
+ }
119
+
120
+ /**
121
+ * Format boolean for display
122
+ */
123
+ export function formatBoolean(value: boolean, options?: {
124
+ trueLabel?: string;
125
+ falseLabel?: string;
126
+ }): string {
127
+ if (typeof value !== 'boolean') {
128
+ return 'Invalid Boolean';
129
+ }
130
+
131
+ return value
132
+ ? (options?.trueLabel || 'Yes')
133
+ : (options?.falseLabel || 'No');
134
+ }
135
+
136
+ /**
137
+ * Truncate string with ellipsis
138
+ */
139
+ export function truncateString(value: string, maxLength: number = 50): string {
140
+ if (typeof value !== 'string') {
141
+ return 'Invalid String';
142
+ }
143
+
144
+ if (value.length <= maxLength) {
145
+ return value;
146
+ }
147
+
148
+ return value.slice(0, maxLength - 3) + '...';
149
+ }
150
+
151
+ /**
152
+ * Format text area content for display (handle line breaks)
153
+ */
154
+ export function formatTextArea(value: string, maxLines?: number): string {
155
+ if (typeof value !== 'string') {
156
+ return 'Invalid Text';
157
+ }
158
+
159
+ const lines = value.split('\n');
160
+
161
+ if (maxLines && lines.length > maxLines) {
162
+ return lines.slice(0, maxLines).join('\n') + '\n...';
163
+ }
164
+
165
+ return value;
166
+ }
167
+
168
+ /**
169
+ * Generic formatter that automatically detects field type and formats accordingly
170
+ */
171
+ export function formatFieldValue(
172
+ value: any,
173
+ fieldType?: 'id' | 'string' | 'textarea' | 'number' | 'boolean' | 'date' | 'datetime' | 'currency' | 'json' | 'array'
174
+ ): string {
175
+ if (value === null || value === undefined) {
176
+ return '';
177
+ }
178
+
179
+ // Auto-detect type if not provided
180
+ if (!fieldType) {
181
+ if (typeof value === 'boolean') fieldType = 'boolean';
182
+ else if (typeof value === 'number') fieldType = 'number';
183
+ else if (value instanceof Date) fieldType = 'datetime';
184
+ else if (Array.isArray(value)) fieldType = 'array';
185
+ else if (typeof value === 'object') fieldType = 'json';
186
+ else fieldType = 'string';
187
+ }
188
+
189
+ switch (fieldType) {
190
+ case 'id':
191
+ case 'string':
192
+ return String(value);
193
+ case 'textarea':
194
+ return formatTextArea(String(value));
195
+ case 'number':
196
+ return formatNumber(value);
197
+ case 'boolean':
198
+ return formatBoolean(value);
199
+ case 'date':
200
+ return formatDate(value);
201
+ case 'datetime':
202
+ return formatDateTime(value);
203
+ case 'currency':
204
+ return formatCurrency(value);
205
+ case 'json':
206
+ return formatJSON(value);
207
+ case 'array':
208
+ return formatArray(value);
209
+ default:
210
+ return String(value);
211
+ }
212
+ }
@@ -0,0 +1,5 @@
1
+ // Formatting utilities
2
+ export * from "./formatting";
3
+
4
+ // Class name utilities
5
+ export * from "./cn";