@antscorp/antsomi-ui 2.0.103 → 2.0.105
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.
- package/es/__mocks__/sql-query.json +56 -0
- package/es/assets/css/main.scss +2 -2
- package/es/components/atoms/App/App.d.ts +7 -0
- package/es/components/atoms/App/App.js +5 -0
- package/es/components/atoms/App/index.d.ts +1 -0
- package/es/components/atoms/App/index.js +1 -0
- package/es/components/atoms/Input/Input.d.ts +11 -17
- package/es/components/atoms/Input/Input.js +11 -12
- package/es/components/atoms/List/List.d.ts +1 -0
- package/es/components/atoms/List/List.js +1 -0
- package/es/components/atoms/List/index.d.ts +1 -0
- package/es/components/atoms/List/index.js +1 -0
- package/es/components/atoms/Scrollbars/Scrollbars.d.ts +3 -4
- package/es/components/atoms/Scrollbars/Scrollbars.js +2 -1
- package/es/components/atoms/SlideBar/SlideBar.js +1 -1
- package/es/components/atoms/Tag/Tag.js +1 -1
- package/es/components/atoms/index.d.ts +3 -0
- package/es/components/atoms/index.js +2 -0
- package/es/components/icons/FeedbackOutlinedIcon.d.ts +3 -0
- package/es/components/icons/FeedbackOutlinedIcon.js +7 -0
- package/es/components/icons/LazyIcon/LazyIcon.d.ts +5 -0
- package/es/components/icons/LazyIcon/LazyIcon.js +5 -0
- package/es/components/icons/NavigateBeforeIcon.d.ts +3 -0
- package/es/components/icons/NavigateBeforeIcon.js +7 -0
- package/es/components/icons/NavigateNextIcon.d.ts +3 -0
- package/es/components/icons/NavigateNextIcon.js +7 -0
- package/es/components/icons/PenSparkIcon.d.ts +3 -0
- package/es/components/icons/PenSparkIcon.js +7 -0
- package/es/components/icons/StatusSuccessIcon.d.ts +3 -0
- package/es/components/icons/StatusSuccessIcon.js +7 -0
- package/es/components/icons/SummarizeIconIcon.d.ts +3 -0
- package/es/components/icons/SummarizeIconIcon.js +7 -0
- package/es/components/icons/index.d.ts +5 -0
- package/es/components/icons/index.js +5 -0
- package/es/components/index.scss +1 -0
- package/es/components/molecules/AddDynamicContent/AddDynamicContent.d.ts +1 -2
- package/es/components/molecules/CalendarSelection/constants.d.ts +1 -1
- package/es/components/molecules/CalendarSelection/constants.js +1 -1
- package/es/components/molecules/CaptureScreen/CaptureScreen.d.ts +8 -2
- package/es/components/molecules/CaptureScreen/CaptureScreen.js +2 -2
- package/es/components/molecules/DrawerDetail/DrawerDetail.js +19 -7
- package/es/components/molecules/DrawerDetail/types.d.ts +5 -0
- package/es/components/molecules/EditingListV2/components/Loadable.d.ts +1 -1
- package/es/components/molecules/EditorScript/EditorScript.d.ts +1 -2
- package/es/components/molecules/EditorScript/EditorScript.js +5 -1
- package/es/components/molecules/FontSizeInput/index.scss +15 -0
- package/es/components/molecules/Select/styled.js +1 -1
- package/es/components/molecules/SelectAccount/type.d.ts +1 -1
- package/es/components/molecules/TagifyInput/utils.style.js +1 -0
- package/es/components/molecules/TemplateSaveAs/hooks/useTemplateSave.d.ts +1 -1
- package/es/components/organism/AccountProfile/components/AccountSetting/AccountSetting.js +2 -1
- package/es/components/organism/AccountProfile/components/AccountSetting/components/LanguageSelector/styles.d.ts +1 -1
- package/es/components/organism/AccountProfile/components/AccountSetting/components/LanguageSelector/styles.js +1 -1
- package/es/components/organism/ActivityTimeline/__mocks__/event_tracking.json +1290 -0
- package/es/components/organism/ActivityTimeline/__mocks__/timeline.json +3059 -0
- package/es/components/organism/DataTable/hooks/useDataTableListing/useDataTableListing.js +5 -4
- package/es/components/organism/Login/components/LoginWithEmail/styled.js +1 -1
- package/es/components/organism/Login/components/SetupGGAuthenticator/styled.js +1 -1
- package/es/components/organism/Login/components/SignIn/styled.js +1 -1
- package/es/components/organism/Login/components/WidgetLayout/styled.js +1 -1
- package/es/components/organism/Login/styled.d.ts +3 -3
- package/es/components/organism/Login/styled.js +11 -11
- package/es/components/organism/ModifyColumnModal/styled.d.ts +2 -2
- package/es/components/organism/PreviewTemplateModal/components/ThumbnailSlider/styled.d.ts +1 -2
- package/es/components/organism/PreviewTemplateModal/components/ThumbnailSlider/styled.js +3 -1
- package/es/components/organism/SQLGeneration/SQLGeneration.d.ts +3 -0
- package/es/components/organism/SQLGeneration/SQLGeneration.js +26 -0
- package/es/components/organism/SQLGeneration/components/CheckboxShowDiff.d.ts +2 -0
- package/es/components/organism/SQLGeneration/components/CheckboxShowDiff.js +16 -0
- package/es/components/organism/SQLGeneration/components/EditTableSourcesDrawer.d.ts +2 -0
- package/es/components/organism/SQLGeneration/components/EditTableSourcesDrawer.js +56 -0
- package/es/components/organism/SQLGeneration/components/ErrorDisplay.d.ts +21 -0
- package/es/components/organism/SQLGeneration/components/ErrorDisplay.js +69 -0
- package/es/components/organism/SQLGeneration/components/SQLGenerationActions.d.ts +4 -0
- package/es/components/organism/SQLGeneration/components/SQLGenerationActions.js +23 -0
- package/es/components/organism/SQLGeneration/components/SQLGenerationCodeBlock.d.ts +2 -0
- package/es/components/organism/SQLGeneration/components/SQLGenerationCodeBlock.js +22 -0
- package/es/components/organism/SQLGeneration/components/SQLGenerationEditPrompt.d.ts +2 -0
- package/es/components/organism/SQLGeneration/components/SQLGenerationEditPrompt.js +66 -0
- package/es/components/organism/SQLGeneration/components/SQLGenerationHeader.d.ts +2 -0
- package/es/components/organism/SQLGeneration/components/SQLGenerationHeader.js +10 -0
- package/es/components/organism/SQLGeneration/components/SQLGenerationModal.d.ts +2 -0
- package/es/components/organism/SQLGeneration/components/SQLGenerationModal.js +35 -0
- package/es/components/organism/SQLGeneration/components/SQLGenerationPagination.d.ts +4 -0
- package/es/components/organism/SQLGeneration/components/SQLGenerationPagination.js +13 -0
- package/es/components/organism/SQLGeneration/components/SQLGenerationPrompt.d.ts +2 -0
- package/es/components/organism/SQLGeneration/components/SQLGenerationPrompt.js +31 -0
- package/es/components/organism/SQLGeneration/components/SQLGenerationPromptDisplay.d.ts +2 -0
- package/es/components/organism/SQLGeneration/components/SQLGenerationPromptDisplay.js +15 -0
- package/es/components/organism/SQLGeneration/components/SQLGenerationQuerySummary.d.ts +2 -0
- package/es/components/organism/SQLGeneration/components/SQLGenerationQuerySummary.js +17 -0
- package/es/components/organism/SQLGeneration/components/SQLGenerationRefine.d.ts +1 -0
- package/es/components/organism/SQLGeneration/components/SQLGenerationRefine.js +55 -0
- package/es/components/organism/SQLGeneration/components/SQLGenerationResult.d.ts +5 -0
- package/es/components/organism/SQLGeneration/components/SQLGenerationResult.js +29 -0
- package/es/components/organism/SQLGeneration/components/index.d.ts +9 -0
- package/es/components/organism/SQLGeneration/components/index.js +9 -0
- package/es/components/organism/SQLGeneration/components/styled.d.ts +52 -0
- package/es/components/organism/SQLGeneration/components/styled.js +382 -0
- package/es/components/organism/SQLGeneration/constants.d.ts +48 -0
- package/es/components/organism/SQLGeneration/constants.js +48 -0
- package/es/components/organism/SQLGeneration/hooks/index.d.ts +1 -0
- package/es/components/organism/SQLGeneration/hooks/index.js +1 -0
- package/es/components/organism/SQLGeneration/hooks/useKeyboardNavigation.d.ts +14 -0
- package/es/components/organism/SQLGeneration/hooks/useKeyboardNavigation.js +123 -0
- package/es/components/organism/SQLGeneration/index.d.ts +10 -0
- package/es/components/organism/SQLGeneration/index.js +6 -0
- package/es/components/organism/SQLGeneration/index.scss +1 -0
- package/es/components/organism/SQLGeneration/integrations/AceEditor/index.d.ts +1 -0
- package/es/components/organism/SQLGeneration/integrations/AceEditor/index.js +1 -0
- package/es/components/organism/SQLGeneration/integrations/AceEditor/index.scss +4 -0
- package/es/components/organism/SQLGeneration/integrations/AceEditor/useAceEditor.d.ts +9 -0
- package/es/components/organism/SQLGeneration/integrations/AceEditor/useAceEditor.js +24 -0
- package/es/components/organism/SQLGeneration/integrations/AceEditor/useEnhancePlaceholder.d.ts +10 -0
- package/es/components/organism/SQLGeneration/integrations/AceEditor/useEnhancePlaceholder.js +172 -0
- package/es/components/organism/SQLGeneration/integrations/AceEditor/useInsertQuery.d.ts +8 -0
- package/es/components/organism/SQLGeneration/integrations/AceEditor/useInsertQuery.js +21 -0
- package/es/components/organism/SQLGeneration/integrations/AntsomiAI/index.d.ts +1 -0
- package/es/components/organism/SQLGeneration/integrations/AntsomiAI/index.js +1 -0
- package/es/components/organism/SQLGeneration/integrations/AntsomiAI/useAntsomiAI.d.ts +1 -0
- package/es/components/organism/SQLGeneration/integrations/AntsomiAI/useAntsomiAI.js +35 -0
- package/es/components/organism/SQLGeneration/integrations/AntsomiSqlWS/index.d.ts +1 -0
- package/es/components/organism/SQLGeneration/integrations/AntsomiSqlWS/index.js +1 -0
- package/es/components/organism/SQLGeneration/integrations/AntsomiSqlWS/useAntsomiSqlWS.d.ts +7 -0
- package/es/components/organism/SQLGeneration/integrations/AntsomiSqlWS/useAntsomiSqlWS.js +10 -0
- package/es/components/organism/SQLGeneration/selectors.d.ts +857 -0
- package/es/components/organism/SQLGeneration/selectors.js +61 -0
- package/es/components/organism/SQLGeneration/store/index.d.ts +2 -0
- package/es/components/organism/SQLGeneration/store/index.js +1 -0
- package/es/components/organism/SQLGeneration/store/provider.d.ts +7 -0
- package/es/components/organism/SQLGeneration/store/provider.js +40 -0
- package/es/components/organism/SQLGeneration/store/store.d.ts +383 -0
- package/es/components/organism/SQLGeneration/store/store.js +309 -0
- package/es/components/organism/SQLGeneration/store/types.d.ts +97 -0
- package/es/components/organism/SQLGeneration/store/types.js +1 -0
- package/es/components/organism/SQLGeneration/types.d.ts +29 -0
- package/es/components/organism/SQLGeneration/types.js +1 -0
- package/es/components/organism/index.d.ts +1 -0
- package/es/components/organism/index.js +1 -0
- package/es/components/organism/index.scss +1 -0
- package/es/components/template/TemplateListing/hooks/useTemplateListing.d.ts +3 -4
- package/es/hooks/index.d.ts +1 -0
- package/es/hooks/index.js +1 -0
- package/es/hooks/useFocusManagement.d.ts +14 -0
- package/es/hooks/useFocusManagement.js +124 -0
- package/es/locales/ja/google-sheet.json +2 -2
- package/es/providers/ConfigProvider/ConfigProvider.js +4 -1
- package/es/providers/ConfigProvider/GlobalStyle.js +153 -46
- package/es/queries/AI/index.d.ts +23 -0
- package/es/queries/AI/index.js +4 -0
- package/es/queries/AI/useSqlGeneration.d.ts +25 -0
- package/es/queries/AI/useSqlGeneration.js +13 -0
- package/es/queries/TemplateListing/index.d.ts +2 -2
- package/es/queries/index.d.ts +1 -0
- package/es/queries/index.js +1 -0
- package/es/services/AI/index.d.ts +15 -0
- package/es/services/AI/index.js +15 -0
- package/es/types/auth.d.ts +25 -0
- package/es/types/auth.js +1 -0
- package/es/types/index.d.ts +1 -0
- package/es/types/index.js +1 -0
- package/es/utils/common.d.ts +1 -0
- package/es/utils/common.js +16 -1
- package/es/utils/web.d.ts +16 -3
- package/es/utils/web.js +36 -3
- package/es/utils/zustand.d.ts +10 -0
- package/es/utils/zustand.js +8 -0
- package/package.json +16 -11
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/* eslint-disable no-extra-boolean-cast */
|
|
2
3
|
// Libraries
|
|
3
4
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
4
5
|
import { Link } from 'react-router-dom';
|
|
@@ -383,11 +384,11 @@ export function useDataTableListing(props) {
|
|
|
383
384
|
if (columns?.toggle) {
|
|
384
385
|
const { key, dataIndex, valueKey, title, value, disabled, onChange } = columns.toggle || {};
|
|
385
386
|
data.push({
|
|
386
|
-
key: 'toggle'
|
|
387
|
+
key: key || 'toggle',
|
|
387
388
|
fixed: 'left',
|
|
388
389
|
align: 'center',
|
|
389
|
-
dataIndex: 'toggle'
|
|
390
|
-
title: 'Toggle'
|
|
390
|
+
dataIndex: dataIndex || 'toggle',
|
|
391
|
+
title: title || 'Toggle',
|
|
391
392
|
width: DEFAULT_TOGGLE_WIDTH,
|
|
392
393
|
...columns.toggle,
|
|
393
394
|
render: (_, record) => {
|
|
@@ -590,7 +591,7 @@ export function useDataTableListing(props) {
|
|
|
590
591
|
if (!!modeView) {
|
|
591
592
|
setState(prev => ({ ...prev, modeView }));
|
|
592
593
|
}
|
|
593
|
-
}, [localStorageValues]);
|
|
594
|
+
}, [localStorageValues, disabledCache]);
|
|
594
595
|
/**
|
|
595
596
|
* Set default groupBy column
|
|
596
597
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
2
|
export const LabelStep = styled.span `
|
|
3
3
|
color: #005eb8;
|
|
4
|
-
font-size: ${
|
|
4
|
+
font-size: ${props => (props.isMobile ? '16px' : '14px')};
|
|
5
5
|
font-weight: 500;
|
|
6
6
|
`;
|
|
7
7
|
export const Link = styled.a `
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Flex } from 'antd';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
export const Title = styled.div `
|
|
4
|
-
font-size: ${
|
|
4
|
+
font-size: ${props => (props.isMobile ? '20px' : '18px')};
|
|
5
5
|
font-weight: 700;
|
|
6
6
|
color: #005eb8;
|
|
7
7
|
text-align: center;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export declare const LoginMain: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd").FlexProps<import("antd/es/_util/type").AnyObject> & import("react").RefAttributes<HTMLElement>>, any, {}, never>;
|
|
3
3
|
export declare const LoginBannerZone: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
4
4
|
export declare const WrapperLogin: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd").FlexProps<import("antd/es/_util/type").AnyObject> & import("react").RefAttributes<HTMLElement>>, any, {
|
|
5
|
-
isMobile
|
|
5
|
+
isMobile?: boolean | undefined;
|
|
6
6
|
}, never>;
|
|
7
7
|
export declare const WrapperImage: import("styled-components").StyledComponent<"img", any, {}, never>;
|
|
8
8
|
export declare const Label: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
@@ -44,8 +44,8 @@ export declare const StyleButton: import("styled-components").StyledComponent<im
|
|
|
44
44
|
}, any, {
|
|
45
45
|
isMobile: boolean;
|
|
46
46
|
}, never>;
|
|
47
|
-
export declare const Text: import("styled-components").StyledComponent<"
|
|
47
|
+
export declare const Text: import("styled-components").StyledComponent<"div", any, {
|
|
48
48
|
color?: string | undefined;
|
|
49
|
-
isMobile: boolean;
|
|
50
49
|
isBold?: boolean | undefined;
|
|
50
|
+
isMobile?: boolean | undefined;
|
|
51
51
|
}, never>;
|
|
@@ -28,7 +28,7 @@ export const WrapperLogin = styled(Flex) `
|
|
|
28
28
|
min-width: ${props => (props.isMobile ? '100%' : '300px')};
|
|
29
29
|
max-width: ${props => (props.isMobile ? '100%' : '404px')};
|
|
30
30
|
|
|
31
|
-
${
|
|
31
|
+
${props => (!props.isMobile ? 'box-shadow: 3px 0px 9px 0px #002e5926' : '')}
|
|
32
32
|
`;
|
|
33
33
|
export const WrapperImage = styled.img `
|
|
34
34
|
width: 180px;
|
|
@@ -73,8 +73,8 @@ export const AvatarImage = styled.img `
|
|
|
73
73
|
`;
|
|
74
74
|
export const StyledForm = styled(Form) `
|
|
75
75
|
input {
|
|
76
|
-
height: ${
|
|
77
|
-
font-size: ${
|
|
76
|
+
height: ${props => (props.isMobile ? ' 44px' : '36px')};
|
|
77
|
+
font-size: ${props => (props.isMobile ? ' 16px !important' : '14px !important')};
|
|
78
78
|
|
|
79
79
|
&::placeholder {
|
|
80
80
|
font-size: ${(props) => props.isMobile ? ' 16px !important' : '14px !important'};
|
|
@@ -111,19 +111,19 @@ export const StyledForm = styled(Form) `
|
|
|
111
111
|
}
|
|
112
112
|
`;
|
|
113
113
|
export const StyleInput = styled(Input) `
|
|
114
|
-
height: ${
|
|
115
|
-
font-size: ${
|
|
114
|
+
height: ${props => (props.isMobile ? ' 44px !important' : '36px !important')};
|
|
115
|
+
font-size: ${props => (props.isMobile ? ' 16px !important' : '14px !important')};
|
|
116
116
|
|
|
117
117
|
&::placeholder {
|
|
118
118
|
font-size: ${(props) => props.isMobile ? ' 16px !important' : '14px !important'};
|
|
119
119
|
}
|
|
120
120
|
`;
|
|
121
121
|
export const StyleButton = styled(Button) `
|
|
122
|
-
height: ${
|
|
123
|
-
font-size: ${
|
|
122
|
+
height: ${props => (props.isMobile ? ' 44px !important' : '40px !important')};
|
|
123
|
+
font-size: ${props => (props.isMobile ? ' 16px !important' : '14px !important')};
|
|
124
124
|
`;
|
|
125
|
-
export const Text = styled.
|
|
126
|
-
color: ${
|
|
127
|
-
font-size: ${
|
|
128
|
-
font-weight: ${
|
|
125
|
+
export const Text = styled.div `
|
|
126
|
+
color: ${props => (props.color ? props.color : ' #000000')};
|
|
127
|
+
font-size: ${props => (props.isMobile ? ' 14px !important' : '12px')};
|
|
128
|
+
font-weight: ${props => (props.isBold ? 'bold' : 'normal')};
|
|
129
129
|
`;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ModalV2Props } from '../../molecules/ModalV2';
|
|
3
3
|
export declare const StyledModal: import("styled-components").StyledComponent<(props: ModalV2Props) => import("react/jsx-runtime").JSX.Element, any, {}, never>;
|
|
4
|
-
export declare const ParentMetricWrapper: import("styled-components").StyledComponent<import("react").FC<import("
|
|
5
|
-
export declare const ChildrenMetricWrapper: import("styled-components").StyledComponent<import("react").FC<import("
|
|
4
|
+
export declare const ParentMetricWrapper: import("styled-components").StyledComponent<import("react").FC<import("react-custom-scrollbars").ScrollbarProps>, any, {}, never>;
|
|
5
|
+
export declare const ChildrenMetricWrapper: import("styled-components").StyledComponent<import("react").FC<import("react-custom-scrollbars").ScrollbarProps>, any, {}, never>;
|
|
6
6
|
export declare const SelectedMetricsWrapper: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd/es/flex/interface").FlexProps<import("antd/es/_util/type").AnyObject> & import("react").RefAttributes<HTMLElement>>, any, {}, never>;
|
|
7
7
|
export declare const SelectedMetricItem: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd/es/flex/interface").FlexProps<import("antd/es/_util/type").AnyObject> & import("react").RefAttributes<HTMLElement>>, any, {
|
|
8
8
|
disabled?: boolean | undefined;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
export declare const ThumbnailSliderWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
3
|
-
export declare const SwiperSlideWrapper: import("styled-components").StyledComponent<
|
|
2
|
+
export declare const SwiperSlideWrapper: import("styled-components").StyledComponent<any, any, object, string | number | symbol>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import { SQLGenerationModal } from './components';
|
|
4
|
+
import { useSQLGenerationStore } from './store';
|
|
5
|
+
import { isBoolean } from 'lodash';
|
|
6
|
+
import { useDeepCompareEffect } from '@antscorp/antsomi-ui/es/hooks';
|
|
7
|
+
export const SQLGeneration = props => {
|
|
8
|
+
const { isOpen, onOpenChange, tableSources } = props;
|
|
9
|
+
const setState = useSQLGenerationStore(s => s.setState);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (isBoolean(isOpen)) {
|
|
12
|
+
setState({ isOpen });
|
|
13
|
+
}
|
|
14
|
+
}, [isOpen, setState]);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (onOpenChange) {
|
|
17
|
+
setState({ onOpenChange });
|
|
18
|
+
}
|
|
19
|
+
}, [setState, onOpenChange]);
|
|
20
|
+
useDeepCompareEffect(() => {
|
|
21
|
+
if (tableSources !== undefined) {
|
|
22
|
+
setState({ tableSources });
|
|
23
|
+
}
|
|
24
|
+
}, [setState, tableSources]);
|
|
25
|
+
return _jsx(SQLGenerationModal, {});
|
|
26
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Checkbox } from '../../../atoms';
|
|
3
|
+
import { selectCurrentResultIndex, selectCurrentResultShowDiff } from '../selectors';
|
|
4
|
+
import { useSQLGenerationStore } from '../store/provider';
|
|
5
|
+
export const CheckboxShowDiff = () => {
|
|
6
|
+
const currentResultShowDiff = useSQLGenerationStore(selectCurrentResultShowDiff);
|
|
7
|
+
const setCurrentResultSettings = useSQLGenerationStore(s => s.setCurrentResultSettings);
|
|
8
|
+
const currentResultIndex = useSQLGenerationStore(selectCurrentResultIndex);
|
|
9
|
+
if (currentResultIndex === 0)
|
|
10
|
+
return null;
|
|
11
|
+
return (_jsx(Checkbox, { title: "Show diff", checked: currentResultShowDiff, onChange: () => {
|
|
12
|
+
setCurrentResultSettings(draft => {
|
|
13
|
+
draft.showDiff = !draft.showDiff;
|
|
14
|
+
});
|
|
15
|
+
}, children: "Show diff" }));
|
|
16
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo, useCallback, useState } from 'react';
|
|
3
|
+
import { Input, Button, Checkbox, Space, Typography, Icon } from '../../../atoms';
|
|
4
|
+
import { SQL_GENERATION_CONSTANTS } from '../constants';
|
|
5
|
+
import { ModalDescription, SearchSection, LanguageSelector, SearchInput, SearchActions, GeneratedSearchInfo, TableListHeader, TableListHeaderLeft, TableListHeaderRight, TableListContainer, TableItem, TableItemContent, TableName, EmptyState, PaginationControls, PaginationText, } from './styled';
|
|
6
|
+
import { useSQLGenerationStore } from '../store/provider';
|
|
7
|
+
import { searchStringQuery } from '@antscorp/antsomi-ui/es/utils';
|
|
8
|
+
import { selectIsEditTableSourcesOpen, selectTableSources } from '../selectors';
|
|
9
|
+
import { Drawer } from 'antd';
|
|
10
|
+
const { Text } = Typography;
|
|
11
|
+
export const EditTableSourcesDrawer = () => {
|
|
12
|
+
const tableSources = useSQLGenerationStore(selectTableSources);
|
|
13
|
+
const isEditTableSourcesOpen = useSQLGenerationStore(selectIsEditTableSourcesOpen);
|
|
14
|
+
const setTableSources = useSQLGenerationStore(s => s.setTableSources);
|
|
15
|
+
const setIsEditTableSourcesOpen = useSQLGenerationStore(s => s.setIsEditTableSourcesOpen);
|
|
16
|
+
const [searchTerm, setSearchTerm] = useState('');
|
|
17
|
+
const selectedTables = useMemo(() => tableSources.filter(t => t.selected), [tableSources]);
|
|
18
|
+
// Filter tables based on search term
|
|
19
|
+
const filteredTables = useMemo(() => {
|
|
20
|
+
if (!searchTerm.trim())
|
|
21
|
+
return tableSources;
|
|
22
|
+
return tableSources.filter(table => searchStringQuery(table.name, searchTerm) ||
|
|
23
|
+
searchStringQuery(table.dataset, searchTerm) ||
|
|
24
|
+
searchStringQuery(table.project, searchTerm));
|
|
25
|
+
}, [tableSources, searchTerm]);
|
|
26
|
+
// Check selection states
|
|
27
|
+
const isAllSelected = useMemo(() => filteredTables.every(table => selectedTables.some(selected => selected.id === table.id)), [filteredTables, selectedTables]);
|
|
28
|
+
const isIndeterminate = useMemo(() => {
|
|
29
|
+
const selectedCount = filteredTables.filter(table => selectedTables.some(selected => selected.id === table.id)).length;
|
|
30
|
+
return selectedCount > 0 && selectedCount < filteredTables.length;
|
|
31
|
+
}, [filteredTables, selectedTables]);
|
|
32
|
+
// Handle select all
|
|
33
|
+
const handleSelectAll = useCallback((checked) => {
|
|
34
|
+
const newTableSources = tableSources.map(ts => {
|
|
35
|
+
if (filteredTables.some(ft => ft.id === ts.id)) {
|
|
36
|
+
return { ...ts, selected: checked };
|
|
37
|
+
}
|
|
38
|
+
return ts;
|
|
39
|
+
});
|
|
40
|
+
setTableSources(newTableSources);
|
|
41
|
+
}, [filteredTables, tableSources, setTableSources]);
|
|
42
|
+
// Handle individual table selection
|
|
43
|
+
const handleTableSelect = useCallback((table, checked) => {
|
|
44
|
+
const newTableSources = tableSources.map(ts => ts.id === table.id ? { ...ts, selected: checked } : ts);
|
|
45
|
+
setTableSources(newTableSources);
|
|
46
|
+
}, [tableSources, setTableSources]);
|
|
47
|
+
// Handle apply
|
|
48
|
+
const handleApply = useCallback(() => {
|
|
49
|
+
setIsEditTableSourcesOpen(false);
|
|
50
|
+
}, [setIsEditTableSourcesOpen]);
|
|
51
|
+
const handleClose = () => setIsEditTableSourcesOpen(false);
|
|
52
|
+
return (_jsx(Drawer, { title: SQL_GENERATION_CONSTANTS.TITLES.EDIT_TABLE_SOURCES, open: isEditTableSourcesOpen, onClose: handleClose, width: SQL_GENERATION_CONSTANTS.MODAL_WIDTH, footer: [
|
|
53
|
+
_jsx(Button, { onClick: handleClose, children: SQL_GENERATION_CONSTANTS.BUTTON_TEXTS.CLOSE }, "close"),
|
|
54
|
+
_jsx(Button, { type: "primary", onClick: handleApply, children: SQL_GENERATION_CONSTANTS.BUTTON_TEXTS.APPLY }, "apply"),
|
|
55
|
+
], children: _jsxs(Space, { direction: "vertical", size: 16, style: { width: '100%' }, children: [_jsx(ModalDescription, { children: SQL_GENERATION_CONSTANTS.MESSAGES.TABLE_SOURCES_INFO }), _jsxs(SearchSection, { children: [_jsxs(LanguageSelector, { children: [_jsx(Icon, { type: "icon-ants-translate", size: 16 }), _jsx(Text, { style: { fontSize: '14px', fontWeight: 500 }, children: "Natural language" }), _jsx(Icon, { type: "icon-ants-chevron-down", size: 14 })] }), _jsx(SearchInput, { children: _jsx(Input, { placeholder: SQL_GENERATION_CONSTANTS.PLACEHOLDER_TEXTS.SEARCH_TABLES, value: searchTerm, onChange: e => setSearchTerm(e.target.value), style: { width: '100%' }, suffix: _jsx(Icon, { type: "icon-ants-search", size: 16 }) }) }), _jsxs(SearchActions, { children: [_jsx(Icon, { type: "icon-ants-filter", size: 16 }), _jsx(Icon, { type: "icon-ants-more-horizontal", size: 16 })] })] }), _jsxs(GeneratedSearchInfo, { children: [_jsxs(Text, { type: "secondary", children: ["Generated search for ", `"${searchTerm || 'all tables'}"`] }), _jsx(Button, { type: "link", size: "small", style: { fontSize: '13px', padding: 0, marginLeft: '8px' }, children: "Edit Search" })] }), _jsxs(TableListHeader, { children: [_jsxs(TableListHeaderLeft, { children: [_jsx(Checkbox, { checked: isAllSelected, indeterminate: isIndeterminate, onChange: e => handleSelectAll(e.target.checked) }), _jsx(Text, { style: { fontWeight: 500 }, children: SQL_GENERATION_CONSTANTS.TITLES.TABLE_ASSET })] }), _jsxs(TableListHeaderRight, { children: [_jsxs(PaginationText, { children: [selectedTables.length, " of ", filteredTables.length, " selected"] }), _jsxs(PaginationControls, { children: [_jsx(Button, { type: "text", size: "small", disabled: true, children: _jsx(Icon, { type: "icon-ants-chevron-left", size: 12 }) }), _jsxs(PaginationText, { children: ["1-", Math.min(10, filteredTables.length), " of ", filteredTables.length] }), _jsx(Button, { type: "text", size: "small", disabled: true, children: _jsx(Icon, { type: "icon-ants-chevron-right", size: 12 }) })] })] })] }), _jsx(TableListContainer, { children: filteredTables.length === 0 ? (_jsxs(EmptyState, { children: ["No tables found matching ", `"${searchTerm}"`] })) : (filteredTables.slice(0, 10).map(table => (_jsxs(TableItem, { children: [_jsx(Checkbox, { checked: table.selected, onChange: e => handleTableSelect(table, e.target.checked) }), _jsxs(TableItemContent, { children: [_jsx(Icon, { type: "icon-ants-table", size: 16, style: { color: '#4285f4' } }), _jsx(TableName, { children: table.project ? `${table.project}.${table.dataset}.${table.name}` : table.name })] })] }, table.id)))) })] }) }));
|
|
56
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SQLGenerationError } from '../store/types';
|
|
3
|
+
export interface ErrorDisplayProps {
|
|
4
|
+
error?: SQLGenerationError | null;
|
|
5
|
+
onRetry?: () => void;
|
|
6
|
+
onDismiss?: () => void;
|
|
7
|
+
showRetry?: boolean;
|
|
8
|
+
className?: string;
|
|
9
|
+
style?: React.CSSProperties;
|
|
10
|
+
}
|
|
11
|
+
export declare const ErrorDisplay: React.FC<ErrorDisplayProps>;
|
|
12
|
+
export declare const CurrentOperationError: React.FC;
|
|
13
|
+
export declare const GenerateSQLError: React.FC<{
|
|
14
|
+
style?: React.CSSProperties;
|
|
15
|
+
}>;
|
|
16
|
+
export declare const RefineSQLError: React.FC<{
|
|
17
|
+
style?: React.CSSProperties;
|
|
18
|
+
}>;
|
|
19
|
+
export declare const QuerySummaryError: React.FC<{
|
|
20
|
+
style?: React.CSSProperties;
|
|
21
|
+
}>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Alert, Button, Space } from '@antscorp/antsomi-ui/es/components/atoms';
|
|
3
|
+
import { useSQLGenerationStore } from '../store/provider';
|
|
4
|
+
import { selectGenerateSQLError, selectRefineSQLError, selectQuerySummaryError, selectCurrentOperationError, } from '../selectors';
|
|
5
|
+
export const ErrorDisplay = ({ error, onRetry, onDismiss, showRetry = true, className, style, }) => {
|
|
6
|
+
if (!error)
|
|
7
|
+
return null;
|
|
8
|
+
const getErrorTitle = (operation) => {
|
|
9
|
+
switch (operation) {
|
|
10
|
+
case 'generateSQL':
|
|
11
|
+
return 'Failed to Generate SQL';
|
|
12
|
+
case 'refineSQL':
|
|
13
|
+
return 'Failed to Refine SQL';
|
|
14
|
+
case 'querySummary':
|
|
15
|
+
return 'Failed to Generate Summary';
|
|
16
|
+
default:
|
|
17
|
+
return 'An Error Occurred';
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const action = (_jsxs(Space, { children: [showRetry && onRetry && (_jsx(Button, { onClick: onRetry, type: "primary", children: "Retry" })), onDismiss && _jsx(Button, { onClick: onDismiss, children: "Dismiss" })] }));
|
|
21
|
+
return (_jsx(Alert, { style: style, message: getErrorTitle(error.operation), description: error.message, type: "error", showIcon: false, action: action, className: className, role: "alert", "aria-live": "assertive" }));
|
|
22
|
+
};
|
|
23
|
+
// Component for displaying current operation error
|
|
24
|
+
export const CurrentOperationError = () => {
|
|
25
|
+
const currentError = useSQLGenerationStore(selectCurrentOperationError);
|
|
26
|
+
const retryGenerateSQL = useSQLGenerationStore(s => s.retryGenerateSQL);
|
|
27
|
+
const retryRefineSQL = useSQLGenerationStore(s => s.retryRefineSQL);
|
|
28
|
+
const retryQuerySummary = useSQLGenerationStore(s => s.retryQuerySummary);
|
|
29
|
+
const clearError = useSQLGenerationStore(s => s.clearError);
|
|
30
|
+
if (!currentError)
|
|
31
|
+
return null;
|
|
32
|
+
const handleRetry = () => {
|
|
33
|
+
switch (currentError.operation) {
|
|
34
|
+
case 'generateSQL':
|
|
35
|
+
retryGenerateSQL();
|
|
36
|
+
break;
|
|
37
|
+
case 'refineSQL':
|
|
38
|
+
retryRefineSQL();
|
|
39
|
+
break;
|
|
40
|
+
case 'querySummary':
|
|
41
|
+
retryQuerySummary();
|
|
42
|
+
break;
|
|
43
|
+
default:
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const handleDismiss = () => {
|
|
48
|
+
clearError(currentError.operation);
|
|
49
|
+
};
|
|
50
|
+
return (_jsx(ErrorDisplay, { error: currentError, onRetry: handleRetry, onDismiss: handleDismiss, className: "sql-generation-error" }));
|
|
51
|
+
};
|
|
52
|
+
export const GenerateSQLError = ({ style }) => {
|
|
53
|
+
const error = useSQLGenerationStore(selectGenerateSQLError);
|
|
54
|
+
const retryGenerateSQL = useSQLGenerationStore(s => s.retryGenerateSQL);
|
|
55
|
+
const setGenerateSQLError = useSQLGenerationStore(s => s.setGenerateSQLError);
|
|
56
|
+
return (_jsx(ErrorDisplay, { style: style, error: error, onRetry: retryGenerateSQL, onDismiss: () => setGenerateSQLError(null) }));
|
|
57
|
+
};
|
|
58
|
+
export const RefineSQLError = ({ style }) => {
|
|
59
|
+
const error = useSQLGenerationStore(selectRefineSQLError);
|
|
60
|
+
const retryRefineSQL = useSQLGenerationStore(s => s.retryRefineSQL);
|
|
61
|
+
const setRefineSQLError = useSQLGenerationStore(s => s.setRefineSQLError);
|
|
62
|
+
return (_jsx(ErrorDisplay, { style: style, error: error, onRetry: retryRefineSQL, onDismiss: () => setRefineSQLError(null) }));
|
|
63
|
+
};
|
|
64
|
+
export const QuerySummaryError = ({ style }) => {
|
|
65
|
+
const error = useSQLGenerationStore(selectQuerySummaryError);
|
|
66
|
+
const retryQuerySummary = useSQLGenerationStore(s => s.retryQuerySummary);
|
|
67
|
+
const setQuerySummaryError = useSQLGenerationStore(s => s.setQuerySummaryError);
|
|
68
|
+
return (_jsx(ErrorDisplay, { error: error, onRetry: retryQuerySummary, onDismiss: () => setQuerySummaryError(null), style: style }));
|
|
69
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Space } from '../../../atoms';
|
|
3
|
+
import { SQL_GENERATION_CONSTANTS } from '../constants';
|
|
4
|
+
import { ActionsSection, ActionButton, CautionLink, RatingSection, RatingText, RatingButton, } from './styled';
|
|
5
|
+
import { FeedbackOutlinedIcon, SummarizeIcon, TableIcon, ThumbDownHandIcon, ThumbUpHandIcon, } from '../../../icons';
|
|
6
|
+
import { Flex, Tooltip } from 'antd';
|
|
7
|
+
import { globalToken } from '@antscorp/antsomi-ui/es/constants';
|
|
8
|
+
import { useSQLGenerationStore } from '../store/provider';
|
|
9
|
+
import { selectHasResult, selectIsLoading, selectQuerySummaryError } from '../selectors';
|
|
10
|
+
import { QuerySummaryError } from './ErrorDisplay';
|
|
11
|
+
export const SQLGenerationActions = ({ children }) => {
|
|
12
|
+
const isLoading = useSQLGenerationStore(selectIsLoading);
|
|
13
|
+
const hasResult = useSQLGenerationStore(selectHasResult);
|
|
14
|
+
const summaryError = useSQLGenerationStore(selectQuerySummaryError);
|
|
15
|
+
const insertSQL = useSQLGenerationStore(s => s.insertSQL);
|
|
16
|
+
const querySummary = useSQLGenerationStore(s => s.querySummary);
|
|
17
|
+
const setIsEditTableSourcesOpen = useSQLGenerationStore(s => s.setIsEditTableSourcesOpen);
|
|
18
|
+
// Get current result
|
|
19
|
+
const isDisabled = isLoading || !hasResult;
|
|
20
|
+
return (_jsxs(ActionsSection, { children: [_jsxs(Flex, { gap: 8, children: [_jsx(ActionButton, { type: "text", size: "small", onClick: () => setIsEditTableSourcesOpen(true), className: "with-icon", icon: _jsx(TableIcon, { size: 18 }),
|
|
21
|
+
// Temporary not support
|
|
22
|
+
disabled: true, children: SQL_GENERATION_CONSTANTS.BUTTON_TEXTS.EDIT_TABLE_SOURCES }), _jsx(ActionButton, { type: "text", size: "small", onClick: querySummary, disabled: isDisabled, className: "with-icon", icon: _jsx(SummarizeIcon, { size: 18 }), children: SQL_GENERATION_CONSTANTS.BUTTON_TEXTS.QUERY_SUMMARY }), hasResult && (_jsx(CautionLink, { type: "link", size: "small", children: "Use query with caution" }))] }), children, hasResult && (_jsxs(_Fragment, { children: [_jsxs(RatingSection, { children: [_jsx(RatingText, { children: "Rate this suggestion" }), _jsxs(Space, { size: 2, children: [_jsx(RatingButton, { type: "text", size: "small", disabled: isDisabled, children: _jsx(Tooltip, { title: SQL_GENERATION_CONSTANTS.TITLES.RATING.THUMBS_UP, children: _jsx(ThumbUpHandIcon, { size: 14, color: globalToken?.bw8 }) }) }), _jsx(RatingButton, { type: "text", size: "small", disabled: isDisabled, children: _jsx(Tooltip, { title: SQL_GENERATION_CONSTANTS.TITLES.RATING.THUMBS_DOWN, children: _jsx(ThumbDownHandIcon, { size: 14, color: globalToken?.bw8 }) }) }), _jsx(RatingButton, { type: "text", size: "small", disabled: isDisabled, children: _jsx(Tooltip, { title: SQL_GENERATION_CONSTANTS.TITLES.RATING.MORE_FEEDBACK, children: _jsx(FeedbackOutlinedIcon, { size: 14, color: globalToken?.bw8 }) }) })] })] }), _jsx(Flex, { justify: "end", children: _jsx(ActionButton, { type: "primary", onClick: insertSQL, disabled: isDisabled, className: "primary", children: SQL_GENERATION_CONSTANTS.BUTTON_TEXTS.INSERT }) })] })), summaryError && _jsx(QuerySummaryError, { style: { marginTop: 12 } })] }));
|
|
23
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useSQLGenerationStore } from '../store/provider';
|
|
3
|
+
import { SQLCodeBlock } from './styled';
|
|
4
|
+
import { selectCurrentResult, selectCurrentResultSettings, selectPreviousCurrentResult, } from '../selectors';
|
|
5
|
+
import DiffViewer, { DiffMethod } from 'react-diff-viewer';
|
|
6
|
+
export const SQLGenerationCodeBlock = () => {
|
|
7
|
+
const currentResult = useSQLGenerationStore(selectCurrentResult);
|
|
8
|
+
const currentResultSettings = useSQLGenerationStore(selectCurrentResultSettings);
|
|
9
|
+
const previousCurrentResult = useSQLGenerationStore(selectPreviousCurrentResult);
|
|
10
|
+
const showDiff = currentResultSettings?.showDiff || false;
|
|
11
|
+
if (!currentResult)
|
|
12
|
+
return null;
|
|
13
|
+
if (showDiff && previousCurrentResult) {
|
|
14
|
+
return (_jsx("div", { style: { height: '300px', overflow: 'auto' }, children: _jsx(DiffViewer, { oldValue: previousCurrentResult.sqlSuggestion, newValue: currentResult.sqlSuggestion, compareMethod: DiffMethod.LINES, hideLineNumbers: true, splitView: false, styles: {
|
|
15
|
+
contentText: {
|
|
16
|
+
fontFamily: 'Monoca',
|
|
17
|
+
fontSize: '14px',
|
|
18
|
+
},
|
|
19
|
+
} }) }));
|
|
20
|
+
}
|
|
21
|
+
return (_jsx(SQLCodeBlock, { readOnly: true, hideExpand: true, height: "300px", mode: "mysql", theme: "textmate", fontSize: 14, showGutter: false, showPrintMargin: false, value: currentResult.sqlSuggestion, style: { background: 'transparent' }, scrollMargin: [10, 10] }));
|
|
22
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect, useRef } from 'react';
|
|
3
|
+
import { Input, Button, Space } from '../../../atoms';
|
|
4
|
+
import { SQL_GENERATION_CONSTANTS } from '../constants';
|
|
5
|
+
import { EditPromptSection, EditPromptInput, EditPromptActions } from './styled';
|
|
6
|
+
import { useSQLGenerationStore } from '../store/provider';
|
|
7
|
+
import { selectCurrentResult, selectIsLoading } from '../selectors';
|
|
8
|
+
export const SQLGenerationEditPrompt = () => {
|
|
9
|
+
const currentResult = useSQLGenerationStore(selectCurrentResult);
|
|
10
|
+
const isLoading = useSQLGenerationStore(selectIsLoading);
|
|
11
|
+
const setPrompt = useSQLGenerationStore(s => s.setPrompt);
|
|
12
|
+
const generateSQL = useSQLGenerationStore(s => s.generateSQL);
|
|
13
|
+
const onGenerateSQL = useSQLGenerationStore(s => s.onGenerateSQL);
|
|
14
|
+
const setIsEditingPrompt = useSQLGenerationStore(s => s.setIsEditingPrompt);
|
|
15
|
+
const originalPrompt = currentResult?.prompt || '';
|
|
16
|
+
const isClickingUpdate = useRef(false);
|
|
17
|
+
const [currentPrompt, setCurrentPrompt] = useState(originalPrompt);
|
|
18
|
+
const [hasChanges, setHasChanges] = useState(false);
|
|
19
|
+
const disabled = !onGenerateSQL;
|
|
20
|
+
// Reset prompt when originalPrompt changes
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
setCurrentPrompt(originalPrompt);
|
|
23
|
+
setHasChanges(false);
|
|
24
|
+
}, [originalPrompt]);
|
|
25
|
+
// Update hasChanges when prompt changes
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
setHasChanges(currentPrompt.trim() !== originalPrompt.trim());
|
|
28
|
+
}, [currentPrompt, originalPrompt]);
|
|
29
|
+
// Handle prompt change
|
|
30
|
+
const handlePromptChange = (e) => {
|
|
31
|
+
setCurrentPrompt(e.target.value);
|
|
32
|
+
};
|
|
33
|
+
// Handle update
|
|
34
|
+
const handleUpdate = async () => {
|
|
35
|
+
if (hasChanges && currentPrompt.trim()) {
|
|
36
|
+
setPrompt(currentPrompt.trim());
|
|
37
|
+
setIsEditingPrompt(false);
|
|
38
|
+
await generateSQL();
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
// Handle cancel
|
|
42
|
+
const handleCancel = () => {
|
|
43
|
+
setCurrentPrompt(originalPrompt);
|
|
44
|
+
setHasChanges(false);
|
|
45
|
+
setIsEditingPrompt(false);
|
|
46
|
+
};
|
|
47
|
+
// Handle key press
|
|
48
|
+
const handleKeyPress = (e) => {
|
|
49
|
+
if (e.key === 'Enter' && hasChanges && !isLoading) {
|
|
50
|
+
handleUpdate();
|
|
51
|
+
}
|
|
52
|
+
if (e.key === 'Escape') {
|
|
53
|
+
handleCancel();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const handleBlur = () => {
|
|
57
|
+
if (isClickingUpdate.current) {
|
|
58
|
+
isClickingUpdate.current = false;
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
handleCancel();
|
|
62
|
+
};
|
|
63
|
+
return (_jsxs(EditPromptSection, { children: [_jsx(EditPromptInput, { children: _jsx(Input, { onBlur: handleBlur, value: currentPrompt, onChange: handlePromptChange, onKeyDown: handleKeyPress, placeholder: SQL_GENERATION_CONSTANTS.PLACEHOLDER_TEXTS.PROMPT, disabled: disabled || isLoading, autoFocus: true }) }), _jsx(EditPromptActions, { children: _jsxs(Space, { size: 8, children: [_jsx(Button, { type: "default", onClick: handleCancel, disabled: isLoading, children: "Cancel" }), _jsx(Button, { type: "primary", onClick: handleUpdate, onMouseDown: () => {
|
|
64
|
+
isClickingUpdate.current = true;
|
|
65
|
+
}, disabled: !hasChanges || isLoading || !currentPrompt.trim(), loading: isLoading, children: "Update" })] }) })] }));
|
|
66
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { SQL_GENERATION_CONSTANTS } from '../constants';
|
|
3
|
+
import { HeaderContainer, HeaderContent, HeaderTitle, CloseButton } from './styled';
|
|
4
|
+
import { CloseIcon, PenSparkIcon } from '../../../icons';
|
|
5
|
+
import { globalToken } from '@antscorp/antsomi-ui/es/constants';
|
|
6
|
+
import { useSQLGenerationStore } from '../store/provider';
|
|
7
|
+
export const SQLGenerationHeader = () => {
|
|
8
|
+
const setIsOpen = useSQLGenerationStore(state => state.setIsOpen);
|
|
9
|
+
return (_jsxs(HeaderContainer, { children: [_jsxs(HeaderContent, { children: [_jsx(PenSparkIcon, { size: 22, "aria-hidden": "true" }), _jsx(HeaderTitle, { id: "sql-generation-title", role: "heading", "aria-level": 1, children: SQL_GENERATION_CONSTANTS.TITLES.MAIN })] }), _jsx(CloseButton, { type: "text", size: "small", icon: _jsx(CloseIcon, { size: 20, color: globalToken?.colorText }), onClick: () => setIsOpen(false), "aria-label": "Close SQL Generation dialog", title: "Close SQL Generation dialog (Escape)" })] }));
|
|
10
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Modal } from 'antd';
|
|
3
|
+
import { SQL_GENERATION_CONSTANTS } from '../constants';
|
|
4
|
+
import { PopoverContent, PopoverBody, AccessibilityStyles } from './styled';
|
|
5
|
+
import { useSQLGenerationStore } from '../store/provider';
|
|
6
|
+
import { selectHasResult, selectIsEditingPrompt, selectIsOpen } from '../selectors';
|
|
7
|
+
import { SQLGenerationHeader } from './SQLGenerationHeader';
|
|
8
|
+
import { SQLGenerationEditPrompt } from './SQLGenerationEditPrompt';
|
|
9
|
+
import { SQLGenerationPromptDisplay } from './SQLGenerationPromptDisplay';
|
|
10
|
+
import { SQLGenerationResult } from './SQLGenerationResult';
|
|
11
|
+
import { SQLGenerationRefine } from './SQLGenerationRefine';
|
|
12
|
+
import { SQLGenerationActions } from './SQLGenerationActions';
|
|
13
|
+
import { SQLGenerationQuerySummary } from './SQLGenerationQuerySummary';
|
|
14
|
+
import { SQLGenerationPrompt } from './SQLGenerationPrompt';
|
|
15
|
+
import { EditTableSourcesDrawer } from './EditTableSourcesDrawer';
|
|
16
|
+
import { useSQLGenerationKeyboard } from '../hooks';
|
|
17
|
+
import { useFocusManagement } from '@antscorp/antsomi-ui/es/hooks';
|
|
18
|
+
export const SQLGenerationModal = () => {
|
|
19
|
+
const isOpen = useSQLGenerationStore(selectIsOpen);
|
|
20
|
+
const hasResults = useSQLGenerationStore(selectHasResult);
|
|
21
|
+
const isEditingPrompt = useSQLGenerationStore(selectIsEditingPrompt);
|
|
22
|
+
const setIsOpen = useSQLGenerationStore(s => s.setIsOpen);
|
|
23
|
+
// Enable keyboard navigation
|
|
24
|
+
useSQLGenerationKeyboard();
|
|
25
|
+
// Enable focus management
|
|
26
|
+
const { containerRef } = useFocusManagement(isOpen, {
|
|
27
|
+
autoFocus: true,
|
|
28
|
+
restoreFocus: true,
|
|
29
|
+
trapFocus: true,
|
|
30
|
+
});
|
|
31
|
+
const popoverContent = (_jsxs(PopoverContent, { ref: containerRef, children: [_jsx(SQLGenerationHeader, {}), _jsx(PopoverBody, { children: hasResults ? (_jsxs(_Fragment, { children: [isEditingPrompt ? _jsx(SQLGenerationEditPrompt, {}) : _jsx(SQLGenerationPromptDisplay, {}), _jsx(SQLGenerationResult, {}), _jsx(SQLGenerationRefine, {}), _jsx(SQLGenerationActions, { children: _jsx(SQLGenerationQuerySummary, {}) })] })) : (_jsx(SQLGenerationPrompt, {})) })] }));
|
|
32
|
+
return (_jsx(AccessibilityStyles, { children: _jsxs(Modal, { open: isOpen, footer: null, closeIcon: null, width: SQL_GENERATION_CONSTANTS.MODAL_WIDTH, onCancel: () => setIsOpen(false), destroyOnClose: true, maskClosable: false,
|
|
33
|
+
// Accessibility improvements - Antd Modal already has role="dialog" and aria-modal="true"
|
|
34
|
+
title: null, className: "sql-generation-modal", children: [popoverContent, _jsx(EditTableSourcesDrawer, {})] }) }));
|
|
35
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useSQLGenerationStore } from '../store/provider';
|
|
3
|
+
import { selectCurrentResultIndex, selectResultsAllKeys, selectTotalResults } from '../selectors';
|
|
4
|
+
import { PaginationIndicator } from './styled';
|
|
5
|
+
import { Button, Space, Text } from '../../../atoms';
|
|
6
|
+
import { NavigateBeforeIcon, NavigateNextIcon } from '../../../icons';
|
|
7
|
+
export const SQLGenerationPagination = ({ style }) => {
|
|
8
|
+
const totalResults = useSQLGenerationStore(selectTotalResults);
|
|
9
|
+
const currentResultIndex = useSQLGenerationStore(selectCurrentResultIndex);
|
|
10
|
+
const resultAllKeys = useSQLGenerationStore(selectResultsAllKeys);
|
|
11
|
+
const setCurrentResultKey = useSQLGenerationStore(s => s.setCurrentResultKey);
|
|
12
|
+
return (_jsxs(_Fragment, { children: [totalResults > 1 && (_jsx(PaginationIndicator, { style: style, role: "navigation", "aria-label": "SQL results pagination", children: _jsxs(Space, { size: 8, align: "center", children: [_jsx(Button, { type: "text", size: "small", disabled: currentResultIndex === 0, onClick: () => setCurrentResultKey(resultAllKeys[currentResultIndex - 1]), icon: _jsx(NavigateBeforeIcon, { size: 14 }), "aria-label": "Go to previous SQL result", title: "Previous result (Arrow Left)" }), _jsxs(Text, { style: { fontSize: '13px', color: '#999' }, role: "status", "aria-label": `Result ${currentResultIndex + 1} of ${totalResults}`, children: [currentResultIndex + 1, " / ", totalResults] }), _jsx(Button, { type: "text", size: "small", disabled: currentResultIndex === totalResults - 1, onClick: () => setCurrentResultKey(resultAllKeys[currentResultIndex + 1]), icon: _jsx(NavigateNextIcon, { size: 14 }), "aria-label": "Go to next SQL result", title: "Next result (Arrow Right)" })] }) })), totalResults === 1 && (_jsx(PaginationIndicator, { style: style, role: "status", "aria-label": "Single result", children: _jsx(Text, { style: { fontSize: '13px', color: '#5f6368' }, children: "1/1" }) }))] }));
|
|
13
|
+
};
|