@antscorp/antsomi-ui 2.0.103 → 2.0.104

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 (168) hide show
  1. package/es/__mocks__/sql-query.json +56 -0
  2. package/es/assets/css/main.scss +2 -2
  3. package/es/components/atoms/App/App.d.ts +7 -0
  4. package/es/components/atoms/App/App.js +5 -0
  5. package/es/components/atoms/App/index.d.ts +1 -0
  6. package/es/components/atoms/App/index.js +1 -0
  7. package/es/components/atoms/Input/Input.d.ts +11 -17
  8. package/es/components/atoms/Input/Input.js +11 -12
  9. package/es/components/atoms/List/List.d.ts +1 -0
  10. package/es/components/atoms/List/List.js +1 -0
  11. package/es/components/atoms/List/index.d.ts +1 -0
  12. package/es/components/atoms/List/index.js +1 -0
  13. package/es/components/atoms/Scrollbars/Scrollbars.d.ts +3 -4
  14. package/es/components/atoms/Scrollbars/Scrollbars.js +2 -1
  15. package/es/components/atoms/SlideBar/SlideBar.js +1 -1
  16. package/es/components/atoms/Tag/Tag.js +1 -1
  17. package/es/components/atoms/index.d.ts +3 -0
  18. package/es/components/atoms/index.js +2 -0
  19. package/es/components/icons/FeedbackOutlinedIcon.d.ts +3 -0
  20. package/es/components/icons/FeedbackOutlinedIcon.js +7 -0
  21. package/es/components/icons/LazyIcon/LazyIcon.d.ts +5 -0
  22. package/es/components/icons/LazyIcon/LazyIcon.js +5 -0
  23. package/es/components/icons/NavigateBeforeIcon.d.ts +3 -0
  24. package/es/components/icons/NavigateBeforeIcon.js +7 -0
  25. package/es/components/icons/NavigateNextIcon.d.ts +3 -0
  26. package/es/components/icons/NavigateNextIcon.js +7 -0
  27. package/es/components/icons/PenSparkIcon.d.ts +3 -0
  28. package/es/components/icons/PenSparkIcon.js +7 -0
  29. package/es/components/icons/StatusSuccessIcon.d.ts +3 -0
  30. package/es/components/icons/StatusSuccessIcon.js +7 -0
  31. package/es/components/icons/SummarizeIconIcon.d.ts +3 -0
  32. package/es/components/icons/SummarizeIconIcon.js +7 -0
  33. package/es/components/icons/index.d.ts +5 -0
  34. package/es/components/icons/index.js +5 -0
  35. package/es/components/index.scss +1 -0
  36. package/es/components/molecules/AddDynamicContent/AddDynamicContent.d.ts +1 -2
  37. package/es/components/molecules/CalendarSelection/constants.d.ts +1 -1
  38. package/es/components/molecules/CalendarSelection/constants.js +1 -1
  39. package/es/components/molecules/CaptureScreen/CaptureScreen.d.ts +8 -2
  40. package/es/components/molecules/CaptureScreen/CaptureScreen.js +2 -2
  41. package/es/components/molecules/DrawerDetail/DrawerDetail.js +19 -7
  42. package/es/components/molecules/DrawerDetail/types.d.ts +5 -0
  43. package/es/components/molecules/EditingListV2/components/Loadable.d.ts +1 -1
  44. package/es/components/molecules/EditorScript/EditorScript.d.ts +1 -2
  45. package/es/components/molecules/EditorScript/EditorScript.js +5 -1
  46. package/es/components/molecules/FontSizeInput/index.scss +15 -0
  47. package/es/components/molecules/Select/styled.js +1 -1
  48. package/es/components/molecules/SelectAccount/type.d.ts +1 -1
  49. package/es/components/molecules/TagifyInput/utils.style.js +1 -0
  50. package/es/components/molecules/TemplateSaveAs/hooks/useTemplateSave.d.ts +1 -1
  51. package/es/components/organism/AccountProfile/components/AccountSetting/AccountSetting.js +2 -1
  52. package/es/components/organism/AccountProfile/components/AccountSetting/components/LanguageSelector/styles.d.ts +1 -1
  53. package/es/components/organism/AccountProfile/components/AccountSetting/components/LanguageSelector/styles.js +1 -1
  54. package/es/components/organism/ActivityTimeline/__mocks__/event_tracking.json +1290 -0
  55. package/es/components/organism/ActivityTimeline/__mocks__/timeline.json +3059 -0
  56. package/es/components/organism/DataTable/hooks/useDataTableListing/useDataTableListing.js +5 -4
  57. package/es/components/organism/Login/components/LoginWithEmail/styled.js +1 -1
  58. package/es/components/organism/Login/components/SetupGGAuthenticator/styled.js +1 -1
  59. package/es/components/organism/Login/components/SignIn/styled.js +1 -1
  60. package/es/components/organism/Login/components/WidgetLayout/styled.js +1 -1
  61. package/es/components/organism/Login/styled.d.ts +3 -3
  62. package/es/components/organism/Login/styled.js +11 -11
  63. package/es/components/organism/ModifyColumnModal/styled.d.ts +2 -2
  64. package/es/components/organism/PreviewTemplateModal/components/ThumbnailSlider/styled.d.ts +1 -2
  65. package/es/components/organism/PreviewTemplateModal/components/ThumbnailSlider/styled.js +3 -1
  66. package/es/components/organism/SQLGeneration/SQLGeneration.d.ts +3 -0
  67. package/es/components/organism/SQLGeneration/SQLGeneration.js +26 -0
  68. package/es/components/organism/SQLGeneration/components/CheckboxShowDiff.d.ts +2 -0
  69. package/es/components/organism/SQLGeneration/components/CheckboxShowDiff.js +16 -0
  70. package/es/components/organism/SQLGeneration/components/EditTableSourcesDrawer.d.ts +2 -0
  71. package/es/components/organism/SQLGeneration/components/EditTableSourcesDrawer.js +56 -0
  72. package/es/components/organism/SQLGeneration/components/ErrorDisplay.d.ts +21 -0
  73. package/es/components/organism/SQLGeneration/components/ErrorDisplay.js +69 -0
  74. package/es/components/organism/SQLGeneration/components/SQLGenerationActions.d.ts +4 -0
  75. package/es/components/organism/SQLGeneration/components/SQLGenerationActions.js +23 -0
  76. package/es/components/organism/SQLGeneration/components/SQLGenerationCodeBlock.d.ts +2 -0
  77. package/es/components/organism/SQLGeneration/components/SQLGenerationCodeBlock.js +22 -0
  78. package/es/components/organism/SQLGeneration/components/SQLGenerationEditPrompt.d.ts +2 -0
  79. package/es/components/organism/SQLGeneration/components/SQLGenerationEditPrompt.js +66 -0
  80. package/es/components/organism/SQLGeneration/components/SQLGenerationHeader.d.ts +2 -0
  81. package/es/components/organism/SQLGeneration/components/SQLGenerationHeader.js +10 -0
  82. package/es/components/organism/SQLGeneration/components/SQLGenerationModal.d.ts +2 -0
  83. package/es/components/organism/SQLGeneration/components/SQLGenerationModal.js +35 -0
  84. package/es/components/organism/SQLGeneration/components/SQLGenerationPagination.d.ts +4 -0
  85. package/es/components/organism/SQLGeneration/components/SQLGenerationPagination.js +13 -0
  86. package/es/components/organism/SQLGeneration/components/SQLGenerationPrompt.d.ts +2 -0
  87. package/es/components/organism/SQLGeneration/components/SQLGenerationPrompt.js +31 -0
  88. package/es/components/organism/SQLGeneration/components/SQLGenerationPromptDisplay.d.ts +2 -0
  89. package/es/components/organism/SQLGeneration/components/SQLGenerationPromptDisplay.js +15 -0
  90. package/es/components/organism/SQLGeneration/components/SQLGenerationQuerySummary.d.ts +2 -0
  91. package/es/components/organism/SQLGeneration/components/SQLGenerationQuerySummary.js +17 -0
  92. package/es/components/organism/SQLGeneration/components/SQLGenerationRefine.d.ts +1 -0
  93. package/es/components/organism/SQLGeneration/components/SQLGenerationRefine.js +55 -0
  94. package/es/components/organism/SQLGeneration/components/SQLGenerationResult.d.ts +5 -0
  95. package/es/components/organism/SQLGeneration/components/SQLGenerationResult.js +29 -0
  96. package/es/components/organism/SQLGeneration/components/index.d.ts +9 -0
  97. package/es/components/organism/SQLGeneration/components/index.js +9 -0
  98. package/es/components/organism/SQLGeneration/components/styled.d.ts +52 -0
  99. package/es/components/organism/SQLGeneration/components/styled.js +382 -0
  100. package/es/components/organism/SQLGeneration/constants.d.ts +48 -0
  101. package/es/components/organism/SQLGeneration/constants.js +48 -0
  102. package/es/components/organism/SQLGeneration/hooks/index.d.ts +1 -0
  103. package/es/components/organism/SQLGeneration/hooks/index.js +1 -0
  104. package/es/components/organism/SQLGeneration/hooks/useKeyboardNavigation.d.ts +14 -0
  105. package/es/components/organism/SQLGeneration/hooks/useKeyboardNavigation.js +123 -0
  106. package/es/components/organism/SQLGeneration/index.d.ts +10 -0
  107. package/es/components/organism/SQLGeneration/index.js +6 -0
  108. package/es/components/organism/SQLGeneration/index.scss +1 -0
  109. package/es/components/organism/SQLGeneration/integrations/AceEditor/index.d.ts +1 -0
  110. package/es/components/organism/SQLGeneration/integrations/AceEditor/index.js +1 -0
  111. package/es/components/organism/SQLGeneration/integrations/AceEditor/index.scss +4 -0
  112. package/es/components/organism/SQLGeneration/integrations/AceEditor/useAceEditor.d.ts +9 -0
  113. package/es/components/organism/SQLGeneration/integrations/AceEditor/useAceEditor.js +24 -0
  114. package/es/components/organism/SQLGeneration/integrations/AceEditor/useEnhancePlaceholder.d.ts +10 -0
  115. package/es/components/organism/SQLGeneration/integrations/AceEditor/useEnhancePlaceholder.js +172 -0
  116. package/es/components/organism/SQLGeneration/integrations/AceEditor/useInsertQuery.d.ts +8 -0
  117. package/es/components/organism/SQLGeneration/integrations/AceEditor/useInsertQuery.js +21 -0
  118. package/es/components/organism/SQLGeneration/integrations/AntsomiAI/index.d.ts +1 -0
  119. package/es/components/organism/SQLGeneration/integrations/AntsomiAI/index.js +1 -0
  120. package/es/components/organism/SQLGeneration/integrations/AntsomiAI/useAntsomiAI.d.ts +1 -0
  121. package/es/components/organism/SQLGeneration/integrations/AntsomiAI/useAntsomiAI.js +35 -0
  122. package/es/components/organism/SQLGeneration/integrations/AntsomiSqlWS/index.d.ts +1 -0
  123. package/es/components/organism/SQLGeneration/integrations/AntsomiSqlWS/index.js +1 -0
  124. package/es/components/organism/SQLGeneration/integrations/AntsomiSqlWS/useAntsomiSqlWS.d.ts +7 -0
  125. package/es/components/organism/SQLGeneration/integrations/AntsomiSqlWS/useAntsomiSqlWS.js +10 -0
  126. package/es/components/organism/SQLGeneration/selectors.d.ts +857 -0
  127. package/es/components/organism/SQLGeneration/selectors.js +61 -0
  128. package/es/components/organism/SQLGeneration/store/index.d.ts +2 -0
  129. package/es/components/organism/SQLGeneration/store/index.js +1 -0
  130. package/es/components/organism/SQLGeneration/store/provider.d.ts +7 -0
  131. package/es/components/organism/SQLGeneration/store/provider.js +40 -0
  132. package/es/components/organism/SQLGeneration/store/store.d.ts +383 -0
  133. package/es/components/organism/SQLGeneration/store/store.js +309 -0
  134. package/es/components/organism/SQLGeneration/store/types.d.ts +97 -0
  135. package/es/components/organism/SQLGeneration/store/types.js +1 -0
  136. package/es/components/organism/SQLGeneration/types.d.ts +29 -0
  137. package/es/components/organism/SQLGeneration/types.js +1 -0
  138. package/es/components/organism/index.d.ts +1 -0
  139. package/es/components/organism/index.js +1 -0
  140. package/es/components/organism/index.scss +1 -0
  141. package/es/components/template/TemplateListing/hooks/useTemplateListing.d.ts +3 -4
  142. package/es/hooks/index.d.ts +1 -0
  143. package/es/hooks/index.js +1 -0
  144. package/es/hooks/useFocusManagement.d.ts +14 -0
  145. package/es/hooks/useFocusManagement.js +124 -0
  146. package/es/locales/ja/google-sheet.json +2 -2
  147. package/es/providers/ConfigProvider/ConfigProvider.js +4 -1
  148. package/es/providers/ConfigProvider/GlobalStyle.js +153 -46
  149. package/es/queries/AI/index.d.ts +23 -0
  150. package/es/queries/AI/index.js +4 -0
  151. package/es/queries/AI/useSqlGeneration.d.ts +25 -0
  152. package/es/queries/AI/useSqlGeneration.js +13 -0
  153. package/es/queries/TemplateListing/index.d.ts +2 -2
  154. package/es/queries/index.d.ts +1 -0
  155. package/es/queries/index.js +1 -0
  156. package/es/services/AI/index.d.ts +15 -0
  157. package/es/services/AI/index.js +15 -0
  158. package/es/types/auth.d.ts +25 -0
  159. package/es/types/auth.js +1 -0
  160. package/es/types/index.d.ts +1 -0
  161. package/es/types/index.js +1 -0
  162. package/es/utils/common.d.ts +1 -0
  163. package/es/utils/common.js +16 -1
  164. package/es/utils/web.d.ts +16 -3
  165. package/es/utils/web.js +36 -3
  166. package/es/utils/zustand.d.ts +10 -0
  167. package/es/utils/zustand.js +8 -0
  168. package/package.json +15 -10
@@ -1,12 +1,13 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  // Libraries
3
3
  import { StyleProvider } from '@ant-design/cssinjs';
4
- import { ConfigProvider as AntdConfigProvider, App } from 'antd';
4
+ import { ConfigProvider as AntdConfigProvider } from 'antd';
5
5
  import dayjs from 'dayjs';
6
6
  import localeData from 'dayjs/plugin/localeData';
7
7
  import relativeTime from 'dayjs/plugin/relativeTime';
8
8
  import weekday from 'dayjs/plugin/weekday';
9
9
  import { useEffect, useRef } from 'react';
10
+ import { App } from '../../components';
10
11
  /** dayjs plugins for timezone */
11
12
  import timezone from 'dayjs/plugin/timezone';
12
13
  import utc from 'dayjs/plugin/utc';
@@ -15,6 +16,8 @@ import { ANTSOMI_COMPONENT_PREFIX_CLS, THEME } from '@antscorp/antsomi-ui/es/con
15
16
  // Style
16
17
  import '@antscorp/antsomi-ui/es/assets/css/main.scss';
17
18
  import { GlobalStyle } from './GlobalStyle';
19
+ // Initialize languages
20
+ // import '@antscorp/antsomi-ui/es/locales/i18n';
18
21
  import 'animate.css';
19
22
  import { AppConfigProvider } from '../AppConfigProvider';
20
23
  // Hooks
@@ -24,6 +24,58 @@ export const GlobalStyle = () => (_jsx(Global, { styles: css `
24
24
  -webkit-box-sizing: border-box;
25
25
  -moz-box-sizing: border-box;
26
26
  box-sizing: border-box;
27
+ border-width: 0;
28
+ border-style: solid;
29
+ }
30
+
31
+ blockquote,
32
+ dl,
33
+ dd,
34
+ h1,
35
+ h2,
36
+ h3,
37
+ h4,
38
+ h5,
39
+ h6,
40
+ hr,
41
+ figure,
42
+ p,
43
+ pre {
44
+ margin: 0;
45
+ }
46
+
47
+ h1,
48
+ h2,
49
+ h3,
50
+ h4,
51
+ h5,
52
+ h6 {
53
+ font-size: inherit;
54
+ font-weight: inherit;
55
+ }
56
+
57
+ ol,
58
+ ul {
59
+ list-style: none;
60
+ margin: 0;
61
+ padding: 0;
62
+ }
63
+
64
+ img,
65
+ svg,
66
+ video,
67
+ canvas,
68
+ audio,
69
+ iframe,
70
+ embed,
71
+ object {
72
+ vertical-align: middle;
73
+ }
74
+
75
+ img,
76
+ video {
77
+ max-width: 100%;
78
+ height: auto;
27
79
  }
28
80
 
29
81
  hr {
@@ -146,65 +198,120 @@ export const GlobalStyle = () => (_jsx(Global, { styles: css `
146
198
  i {
147
199
  font-size: 20px;
148
200
  }
149
- }
150
-
151
- .antsomi-btn-default {
152
- &:not(:disabled):hover {
153
- border-color: ${THEME.token?.blue3} !important;
154
- background-color: ${THEME.token?.blue} !important;
155
- }
156
- &:not(:disabled).antsomi-btn-default-active {
157
- border-color: ${THEME.token?.colorPrimary} !important;
158
- background-color: ${THEME.token?.blue1_1} !important;
159
- }
160
-
161
- &.antsomi-btn-dangerous {
162
- border-color: ${THEME.token?.red2} !important;
163
201
 
202
+ &.antsomi-btn-default {
164
203
  &:not(:disabled):hover {
165
- border-color: ${THEME.token?.red3} !important;
166
- background-color: ${THEME.token?.red} !important;
204
+ border-color: ${THEME.token?.blue3};
205
+ background-color: ${THEME.token?.blue};
206
+ }
207
+ &:not(:disabled).antsomi-btn-default-active {
208
+ border-color: ${THEME.token?.colorPrimary};
209
+ background-color: ${THEME.token?.blue1_1};
167
210
  }
168
- }
169
211
 
170
- &.antsomi-btn-icon-only {
171
- width: 36px !important;
172
- height: 36px !important;
173
- }
212
+ &.antsomi-btn-dangerous {
213
+ border-color: ${THEME.token?.red2};
174
214
 
175
- &.antsomi-btn-icon-only.antsomi-btn-sm {
176
- /* Important to override the above code before */
177
- width: 24px !important;
178
- height: 24px !important;
179
- }
180
- }
215
+ &:not(:disabled):hover {
216
+ border-color: ${THEME.token?.red3};
217
+ background-color: ${THEME.token?.red};
218
+ }
219
+ }
181
220
 
182
- .antsomi-btn-text:disabled,
183
- .antsomi-btn-link:disabled {
184
- color: ${THEME.token?.bw6} !important;
185
- }
221
+ &.antsomi-btn-icon-only {
222
+ width: 36px;
223
+ height: 36px;
224
+ }
186
225
 
187
- /* .antsomi-btn-primary:disabled, */
188
- .antsomi-btn-default:disabled,
189
- .antsomi-btn-dashed:disabled,
190
- .antsomi-btn-disabled,
191
- .antsomi-btn-default.antsomi-btn-dangerous:disabled,
192
- .antsomi-btn-primary.antsomi-btn-dangerous:disabled {
193
- border-color: ${THEME.token?.bw4} !important;
194
- }
226
+ &.antsomi-btn-icon-only.antsomi-btn-sm {
227
+ /* Important to override the above code before */
228
+ width: 24px;
229
+ height: 24px;
230
+ }
231
+ }
195
232
 
196
- .antsomi-btn-default:disabled,
197
- .antsomi-btn-dashed:disabled,
198
- .antsomi-btn-disabled,
199
- .antsomi-btn-default.antsomi-btn-dangerous:disabled {
200
- color: ${THEME.token?.bw6} !important;
201
- background-color: ${THEME.token?.bw2} !important;
202
- }
233
+ &.antsomi-btn-text:disabled,
234
+ &.antsomi-btn-link:disabled {
235
+ color: ${THEME.token?.bw6};
236
+ }
237
+
238
+ /* .antsomi-btn-primary:disabled, */
239
+ &.antsomi-btn-default:disabled,
240
+ &.antsomi-btn-dashed:disabled,
241
+ &.antsomi-btn-disabled,
242
+ &.antsomi-btn-default.antsomi-btn-dangerous:disabled,
243
+ &.antsomi-btn-primary.antsomi-btn-dangerous:disabled {
244
+ border-color: ${THEME.token?.bw4};
245
+ }
246
+
247
+ &.antsomi-btn-default:disabled,
248
+ &.antsomi-btn-dashed:disabled,
249
+ &.antsomi-btn-disabled,
250
+ &.antsomi-btn-default.antsomi-btn-dangerous:disabled {
251
+ color: ${THEME.token?.bw6};
252
+ background-color: ${THEME.token?.bw2};
253
+ }
254
+ }
255
+
256
+ /* .antsomi-btn-default { */
257
+ /* &:not(:disabled):hover { */
258
+ /* border-color: ${THEME.token?.blue3} !important; */
259
+ /* background-color: ${THEME.token?.blue} !important; */
260
+ /* } */
261
+ /* &:not(:disabled).antsomi-btn-default-active { */
262
+ /* border-color: ${THEME.token?.colorPrimary} !important; */
263
+ /* background-color: ${THEME.token?.blue1_1} !important; */
264
+ /* } */
265
+ /**/
266
+ /* &.antsomi-btn-dangerous { */
267
+ /* border-color: ${THEME.token?.red2} !important; */
268
+ /**/
269
+ /* &:not(:disabled):hover { */
270
+ /* border-color: ${THEME.token?.red3} !important; */
271
+ /* background-color: ${THEME.token?.red} !important; */
272
+ /* } */
273
+ /* } */
274
+ /**/
275
+ /* &.antsomi-btn-icon-only { */
276
+ /* width: 36px !important; */
277
+ /* height: 36px !important; */
278
+ /* } */
279
+ /**/
280
+ /* &.antsomi-btn-icon-only.antsomi-btn-sm { */
281
+ /* /* Important to override the above code before */
282
+ */
283
+ /* width: 24px !important; */
284
+ /* height: 24px !important; */
285
+ /* } */
286
+ /* } */
287
+
288
+ /* .antsomi-btn-text:disabled, */
289
+ /* .antsomi-btn-link:disabled { */
290
+ /* color: ${THEME.token?.bw6} !important; */
291
+ /* } */
292
+ /**/
293
+ /* /* .antsomi-btn-primary:disabled, */ */
294
+ /* .antsomi-btn-default:disabled, */
295
+ /* .antsomi-btn-dashed:disabled, */
296
+ /* .antsomi-btn-disabled, */
297
+ /* .antsomi-btn-default.antsomi-btn-dangerous:disabled, */
298
+ /* .antsomi-btn-primary.antsomi-btn-dangerous:disabled { */
299
+ /* border-color: ${THEME.token?.bw4} !important; */
300
+ /* } */
301
+ /**/
302
+ /* .antsomi-btn-default:disabled, */
303
+ /* .antsomi-btn-dashed:disabled, */
304
+ /* .antsomi-btn-disabled, */
305
+ /* .antsomi-btn-default.antsomi-btn-dangerous:disabled { */
306
+ /* color: ${THEME.token?.bw6} !important; */
307
+ /* background-color: ${THEME.token?.bw2} !important; */
308
+ /* } */
203
309
 
204
310
  // NOTE: Just hot fix for easy looking
205
311
  .antsomi-btn-primary.antsomi-btn-compact-item.antsomi-btn-compact-first-item {
206
312
  padding-right: 6px !important;
207
313
  }
314
+
208
315
  .antsomi-btn-compact-item.antsomi-btn-primary.antsomi-btn-compact-last-item {
209
316
  width: fit-content;
210
317
  //padding: 0px !important;
@@ -0,0 +1,23 @@
1
+ export declare const AntsomiAIQueries: {
2
+ readonly useSqlGeneration: (params: {
3
+ auth: import("../..").Auth;
4
+ env: import("@antscorp/antsomi-constants").Env;
5
+ }) => {
6
+ generateSQL: import("@tanstack/react-query").UseMutateFunction<{
7
+ key: string;
8
+ prompt: string;
9
+ refine_prompt: string;
10
+ sql_suggestion: string;
11
+ summary: string;
12
+ }, unknown, Record<string, unknown>, unknown>;
13
+ generateSQLAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
14
+ key: string;
15
+ prompt: string;
16
+ refine_prompt: string;
17
+ sql_suggestion: string;
18
+ summary: string;
19
+ }, unknown, Record<string, unknown>, unknown>;
20
+ isLoading: boolean;
21
+ isError: boolean;
22
+ };
23
+ };
@@ -0,0 +1,4 @@
1
+ import { useSqlGeneration } from './useSqlGeneration';
2
+ export const AntsomiAIQueries = {
3
+ useSqlGeneration,
4
+ };
@@ -0,0 +1,25 @@
1
+ import { Auth } from '../../types';
2
+ import { Env } from '@antscorp/antsomi-constants';
3
+ type UseSqlGenerationParams = {
4
+ auth: Auth;
5
+ env: Env;
6
+ };
7
+ export declare const useSqlGeneration: (params: UseSqlGenerationParams) => {
8
+ generateSQL: import("@tanstack/react-query").UseMutateFunction<{
9
+ key: string;
10
+ prompt: string;
11
+ refine_prompt: string;
12
+ sql_suggestion: string;
13
+ summary: string;
14
+ }, unknown, Record<string, unknown>, unknown>;
15
+ generateSQLAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
16
+ key: string;
17
+ prompt: string;
18
+ refine_prompt: string;
19
+ sql_suggestion: string;
20
+ summary: string;
21
+ }, unknown, Record<string, unknown>, unknown>;
22
+ isLoading: boolean;
23
+ isError: boolean;
24
+ };
25
+ export {};
@@ -0,0 +1,13 @@
1
+ import { useMutation } from '@tanstack/react-query';
2
+ import { AIServices } from '../../services/AI';
3
+ export const useSqlGeneration = (params) => {
4
+ const { auth, env } = params;
5
+ const { mutate: generateSQL, mutateAsync: generateSQLAsync, isLoading, isError, } = useMutation({
6
+ mutationFn: async (data) => AIServices.generateSQL({
7
+ auth,
8
+ data,
9
+ env,
10
+ }),
11
+ });
12
+ return { generateSQL, generateSQLAsync, isLoading, isError };
13
+ };
@@ -14,7 +14,7 @@ export type TGetSaveAsGalleryPermissionEmails = {
14
14
  };
15
15
  export type TGetObjectTEmplateList = {
16
16
  args: TGetObjectTemplateListArgs;
17
- options?: UseInfiniteQueryOptions<any, any, ResponseListing<ObjectTemplate>, (string | number)[]>;
17
+ options?: UseInfiniteQueryOptions<any, any, any, ResponseListing<ObjectTemplate>, (string | Record<string, any>)[]>;
18
18
  };
19
19
  export type TGetObjectTemplateDetail = {
20
20
  args: TGetObjectTemplateDetailArgs;
@@ -40,7 +40,7 @@ export type TUsePersistTemplate = {
40
40
  };
41
41
  export declare const useGetTemplateCategoryList: (params: TGetTemplateCategoryList) => import("@tanstack/react-query").UseQueryResult<TemplateCategory[], any>;
42
42
  export declare const useGetSaveAsGalleryPermissionEmails: (params: TGetSaveAsGalleryPermissionEmails) => import("@tanstack/react-query").UseQueryResult<string[], any>;
43
- export declare const useGetObjectTemplateList: (params: TGetObjectTEmplateList) => import("@tanstack/react-query").UseInfiniteQueryResult<ResponseListing<ObjectTemplate>, any>;
43
+ export declare const useGetObjectTemplateList: (params: TGetObjectTEmplateList) => import("@tanstack/react-query").UseInfiniteQueryResult<any, any>;
44
44
  export declare const useGetObjectTemplateDetail: (params: TGetObjectTemplateDetail) => import("@tanstack/react-query").UseQueryResult<ObjectTemplate, any>;
45
45
  export declare const useValidateTemplateName: (params: TUseValidateTemplateName) => import("@tanstack/react-query").UseMutationResult<ResponseCheckNameExist, any, TValidateObjectTemplateNameArgs, unknown>;
46
46
  export declare const useBulkUpdateTemplate: (params: TBulkUpdateTemplate) => import("@tanstack/react-query").UseMutationResult<any, any, TBulkUpdateObjectTemplateArgs, unknown>;
@@ -9,3 +9,4 @@ export * from './TemplateListing';
9
9
  export * from './Permission';
10
10
  export * from './DataTable';
11
11
  export * from './User';
12
+ export * from './AI';
@@ -9,3 +9,4 @@ export * from './TemplateListing';
9
9
  export * from './Permission';
10
10
  export * from './DataTable';
11
11
  export * from './User';
12
+ export * from './AI';
@@ -0,0 +1,15 @@
1
+ import { Env } from '@antscorp/antsomi-constants';
2
+ import { Auth } from '../../types';
3
+ export declare const AIServices: {
4
+ readonly generateSQL: (params: {
5
+ env: Env;
6
+ data: Record<string, unknown>;
7
+ auth: Auth;
8
+ }) => Promise<{
9
+ key: string;
10
+ prompt: string;
11
+ refine_prompt: string;
12
+ sql_suggestion: string;
13
+ summary: string;
14
+ }>;
15
+ };
@@ -0,0 +1,15 @@
1
+ import axios from 'axios';
2
+ import { CDP_AI } from '@antscorp/antsomi-constants';
3
+ export const AIServices = {
4
+ generateSQL: async (params) => {
5
+ const { data, auth, env } = params;
6
+ const response = await axios.post(`${CDP_AI[env]}/api/v1/sql_generation/generate`, data, {
7
+ params: {
8
+ _token: auth.token,
9
+ _user_id: auth.userId,
10
+ _account_id: auth.accountId,
11
+ },
12
+ });
13
+ return response.data.data;
14
+ },
15
+ };
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Represents an authentication info with associated user and portal information.
3
+ */
4
+ export interface Auth {
5
+ /**
6
+ * The authentication token.
7
+ */
8
+ token: string;
9
+ /**
10
+ * The ID of the authenticated user.
11
+ */
12
+ userId: number;
13
+ /**
14
+ * The ID of the portal associated with the authentication token.
15
+ */
16
+ portalId?: number;
17
+ /**
18
+ * The ID of the account associated with the authentication token.
19
+ */
20
+ accountId?: number;
21
+ /**
22
+ * The user's preferred language.
23
+ */
24
+ language?: string;
25
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -25,6 +25,7 @@ export * from './actionsButton';
25
25
  export * from './condition';
26
26
  export * from './api';
27
27
  export * from './date';
28
+ export * from './auth';
28
29
  export type PayloadInfo = {
29
30
  url?: string;
30
31
  userId?: string;
package/es/types/index.js CHANGED
@@ -9,3 +9,4 @@ export * from './actionsButton';
9
9
  export * from './condition';
10
10
  export * from './api';
11
11
  export * from './date';
12
+ export * from './auth';
@@ -165,3 +165,4 @@ export declare const convertNumberByDisplayFormat: (value: number | string, grou
165
165
  export declare function numberWithCommas(n: number): string;
166
166
  export declare const multiPercentageValue: (value?: string) => string;
167
167
  export declare const antsomiClsx: (componentName: string) => (className: string) => string;
168
+ export declare function arrayToMapByProperty<T extends object, K extends keyof T>(array: T[], propertyName: K): Map<T[K], T>;
@@ -6,7 +6,7 @@ import uniqid from 'uniqid';
6
6
  import { MESSAGES, PORTAL_KEYS } from '@antscorp/antsomi-ui/es/services/constants';
7
7
  // Utils
8
8
  import { handleError } from './handleError';
9
- import { sortBy } from 'lodash';
9
+ import { keyBy, sortBy } from 'lodash';
10
10
  import clsx from 'clsx';
11
11
  import { ANTSOMI_COMPONENT_PREFIX_CLS } from '../constants';
12
12
  const PATH = 'src/utils/common.ts';
@@ -742,3 +742,18 @@ export const antsomiClsx = (componentName) => (className) => {
742
742
  });
743
743
  return clsx(classNames);
744
744
  };
745
+ export function arrayToMapByProperty(array, propertyName) {
746
+ // Đảm bảo đầu vào là một mảng và không rỗng
747
+ if (!Array.isArray(array) || array.length === 0) {
748
+ // eslint-disable-next-line no-console
749
+ console.warn('Đầu vào không phải là một mảng hợp lệ hoặc là mảng rỗng. Trả về Map rỗng.');
750
+ return new Map();
751
+ }
752
+ // Sử dụng _.keyBy để nhóm các đối tượng theo propertyName
753
+ // Lưu ý: _.keyBy trả về một plain object.
754
+ const keyedObject = keyBy(array, propertyName);
755
+ // Chuyển đổi plain object thành một Map
756
+ // Object.entries() tạo ra một mảng các cặp [khóa, giá trị]
757
+ // new Map() có thể nhận mảng này để khởi tạo Map
758
+ return new Map(Object.entries(keyedObject));
759
+ }
package/es/utils/web.d.ts CHANGED
@@ -1,10 +1,23 @@
1
+ /// <reference types="react" />
1
2
  /**
2
3
  * Function to parse search params string to object
3
4
  * @param {string} searchParams - search params
4
5
  * @returns {Record<string, unknown>}
5
6
  */
6
7
  export declare const searchPramsToObject: (searchParams?: string) => Record<string, unknown>;
7
- export declare const getPreventKeyboardAction: (actions?: Array<'undo' | 'copy' | 'paste'>) => {
8
- onKeyDown: (e: React.KeyboardEvent | KeyboardEvent) => false | undefined;
9
- onKeyUp: (e: React.KeyboardEvent | KeyboardEvent) => void;
8
+ export declare const getPreventKeyboardAction: <T extends import("react").KeyboardEvent<Element> | KeyboardEvent>(actions?: Array<'undo' | 'copy' | 'paste' | 'cut'>, options?: {
9
+ onKeydown?: (e: T) => void;
10
+ onKeyup?: (e: T) => void;
11
+ }) => {
12
+ onKeyDown: (e: T) => false | undefined;
13
+ onKeyUp: (e: T) => void;
10
14
  };
15
+ export declare const getPlatform: () => "mac" | "window" | "linux" | "unknown";
16
+ export declare const isMacOS: () => boolean;
17
+ export declare const isWindows: () => boolean;
18
+ export declare const isLinux: () => boolean;
19
+ /**
20
+ * Gets the modifier key based on the platform
21
+ * @returns Platform-appropriate modifier key
22
+ */
23
+ export declare const getModifierKey: () => "⌘" | "Ctrl";
package/es/utils/web.js CHANGED
@@ -1,4 +1,4 @@
1
- import { VALUE_C, VALUE_CONTROL, VALUE_LEFT_WINDOW, VALUE_V, VALUE_Z, } from '@antscorp/antsomi-ui/es/constants/keyCode';
1
+ import { VALUE_C, VALUE_CONTROL, VALUE_LEFT_WINDOW, VALUE_V, VALUE_X, VALUE_Z, } from '@antscorp/antsomi-ui/es/constants/keyCode';
2
2
  /**
3
3
  * Function to parse search params string to object
4
4
  * @param {string} searchParams - search params
@@ -6,21 +6,54 @@ import { VALUE_C, VALUE_CONTROL, VALUE_LEFT_WINDOW, VALUE_V, VALUE_Z, } from '@a
6
6
  */
7
7
  export const searchPramsToObject = (searchParams = '') => Object.fromEntries(new URLSearchParams(searchParams));
8
8
  let ctrlDown = false;
9
- export const getPreventKeyboardAction = (actions = []) => ({
9
+ export const getPreventKeyboardAction = (actions = [], options) => ({
10
10
  onKeyDown: (e) => {
11
11
  if (e.key === VALUE_CONTROL || e.key === VALUE_LEFT_WINDOW) {
12
12
  ctrlDown = true;
13
13
  }
14
14
  if ((actions.includes('undo') && ctrlDown && e.key === VALUE_Z) ||
15
15
  (actions.includes('copy') && ctrlDown && e.key === VALUE_V) ||
16
- (actions.includes('paste') && ctrlDown && e.key === VALUE_C)) {
16
+ (actions.includes('paste') && ctrlDown && e.key === VALUE_C) ||
17
+ (actions.includes('cut') && ctrlDown && e.key === VALUE_X)) {
17
18
  e.preventDefault();
18
19
  return false;
19
20
  }
21
+ options?.onKeydown?.(e);
20
22
  },
21
23
  onKeyUp: (e) => {
22
24
  if (e.key === VALUE_CONTROL || e.key === VALUE_LEFT_WINDOW) {
23
25
  ctrlDown = false;
24
26
  }
27
+ options?.onKeyup?.(e);
25
28
  },
26
29
  });
30
+ export const getPlatform = () => {
31
+ // Modern API (userAgentData)
32
+ const navAny = navigator;
33
+ if (navAny.userAgentData && typeof navAny.userAgentData.platform === 'string') {
34
+ const platform = navAny.userAgentData.platform.toLowerCase();
35
+ if (platform.includes('mac'))
36
+ return 'mac';
37
+ if (platform.includes('win'))
38
+ return 'window';
39
+ if (platform.includes('linux') || platform.includes('x11'))
40
+ return 'linux';
41
+ }
42
+ // Fallback for older browsers
43
+ const ua = navigator.userAgent.toLowerCase();
44
+ if (ua.includes('mac'))
45
+ return 'mac';
46
+ if (ua.includes('win'))
47
+ return 'window';
48
+ if (ua.includes('linux') || ua.includes('x11'))
49
+ return 'linux';
50
+ return 'unknown';
51
+ };
52
+ export const isMacOS = () => getPlatform() === 'mac';
53
+ export const isWindows = () => getPlatform() === 'window';
54
+ export const isLinux = () => getPlatform() === 'linux';
55
+ /**
56
+ * Gets the modifier key based on the platform
57
+ * @returns Platform-appropriate modifier key
58
+ */
59
+ export const getModifierKey = () => (isMacOS() ? '⌘' : 'Ctrl');
@@ -0,0 +1,10 @@
1
+ import { StoreApi, UseBoundStore } from 'zustand';
2
+ type WithSelectors<S> = S extends {
3
+ getState: () => infer T;
4
+ } ? S & {
5
+ use: {
6
+ [K in keyof T]: () => T[K];
7
+ };
8
+ } : never;
9
+ export declare const createSelectors: <S extends UseBoundStore<StoreApi<object>>>(_store: S) => WithSelectors<S>;
10
+ export {};
@@ -0,0 +1,8 @@
1
+ export const createSelectors = (_store) => {
2
+ const store = _store;
3
+ store.use = {};
4
+ for (const k of Object.keys(store.getState())) {
5
+ store.use[k] = () => store(s => s[k]);
6
+ }
7
+ return store;
8
+ };