@yoka-ui/ui 1.0.5 → 1.0.7
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/@Docs-yoka/exports.generated.md +6 -9
- package/README.md +39 -12
- package/dist/es/assets/image/skills.zip +0 -0
- package/dist/es/business/Empty/index.js.map +1 -1
- package/dist/es/business/YkCharts/Area.d.ts +18 -0
- package/dist/es/business/YkCharts/Area.js +336 -0
- package/dist/es/business/YkCharts/Area.js.map +7 -0
- package/dist/es/business/YkCharts/Bar.d.ts +21 -0
- package/dist/es/business/YkCharts/Bar.js +316 -0
- package/dist/es/business/YkCharts/Bar.js.map +7 -0
- package/dist/es/business/YkCharts/BarProperty.d.ts +21 -0
- package/dist/es/business/YkCharts/BarProperty.js +357 -0
- package/dist/es/business/YkCharts/BarProperty.js.map +7 -0
- package/dist/es/business/YkCharts/BarTotal.d.ts +21 -0
- package/dist/es/business/YkCharts/BarTotal.js +288 -0
- package/dist/es/business/YkCharts/BarTotal.js.map +7 -0
- package/dist/es/business/YkCharts/Line.d.ts +21 -0
- package/dist/es/business/YkCharts/Line.js +342 -0
- package/dist/es/business/YkCharts/Line.js.map +7 -0
- package/dist/es/business/YkCharts/Pie.d.ts +19 -0
- package/dist/es/business/YkCharts/Pie.js +107 -0
- package/dist/es/business/YkCharts/Pie.js.map +7 -0
- package/dist/es/business/YkCharts/PieProperty.d.ts +18 -0
- package/dist/es/business/YkCharts/PieProperty.js +180 -0
- package/dist/es/business/YkCharts/PieProperty.js.map +7 -0
- package/dist/es/business/YkCharts/Pies.d.ts +26 -0
- package/dist/es/business/YkCharts/Pies.js +348 -0
- package/dist/es/business/YkCharts/Pies.js.map +7 -0
- package/dist/es/business/YkCharts/constants.d.ts +1 -0
- package/dist/es/business/YkCharts/constants.js +47 -0
- package/dist/es/business/YkCharts/constants.js.map +7 -0
- package/dist/es/business/YkCharts/hooks.d.ts +4 -0
- package/dist/es/business/YkCharts/hooks.js +37 -0
- package/dist/es/business/YkCharts/hooks.js.map +7 -0
- package/dist/es/business/YkCharts/index.d.ts +9 -0
- package/dist/es/business/YkCharts/index.js +20 -0
- package/dist/es/business/YkCharts/index.js.map +7 -0
- package/dist/es/business/YkCharts/index.module.less +164 -0
- package/dist/es/business/YkCharts/tooltip.less +92 -0
- package/dist/es/business/YkCharts/transformData.js +16 -0
- package/dist/es/business/YkCharts/transformData.js.map +7 -0
- package/dist/es/business/YkCharts/typing.d.ts +74 -0
- package/dist/es/business/YkCharts/typing.js +1 -0
- package/dist/es/business/YkCharts/typing.js.map +7 -0
- package/dist/es/business/YkCharts/utils.d.ts +4 -0
- package/dist/es/business/YkCharts/utils.js +109 -0
- package/dist/es/business/YkCharts/utils.js.map +7 -0
- package/dist/es/business/YkCharts/variables.less +13 -0
- package/dist/es/business/YkLoginModule/SmsLoginForm.d.ts +25 -0
- package/dist/es/business/YkLoginModule/SmsLoginForm.js +178 -0
- package/dist/es/business/YkLoginModule/SmsLoginForm.js.map +7 -0
- package/dist/es/business/YkLoginModule/index.d.ts +48 -0
- package/dist/es/business/YkLoginModule/index.js +198 -0
- package/dist/es/business/YkLoginModule/index.js.map +7 -0
- package/dist/es/business/YkLoginModule/styles.module.less +169 -0
- package/dist/es/business/YkSqlEdit/code-mirror-custom.module.less +154 -0
- package/dist/es/business/YkSqlEdit/index.d.ts +20 -0
- package/dist/es/business/YkSqlEdit/index.js +180 -0
- package/dist/es/business/YkSqlEdit/index.js.map +7 -0
- package/dist/es/business/YkSqlEdit/sql-language.d.ts +11 -0
- package/dist/es/business/YkSqlEdit/sql-language.js +1460 -0
- package/dist/es/business/YkSqlEdit/sql-language.js.map +7 -0
- package/dist/es/components/YKMarkdown/index.d.ts +11 -0
- package/dist/es/components/YKMarkdown/index.js +236 -0
- package/dist/es/components/YKMarkdown/index.js.map +7 -0
- package/dist/es/components/YKMarkdown/index.module.less +83 -0
- package/dist/es/components/YkDateRangePicker/YkDateRangePicker.mdx +3 -3
- package/dist/es/creative/GlassSegmentedRadio/index.d.ts +1 -1
- package/dist/es/creative/SkillsWriter/index.d.ts +3 -0
- package/dist/es/creative/SkillsWriter/index.js +191 -0
- package/dist/es/creative/SkillsWriter/index.js.map +7 -0
- package/dist/es/creative/SkillsWriter/index.module.less +21 -0
- package/dist/es/index.d.ts +4 -2
- package/dist/es/index.js +80 -76
- package/dist/es/index.js.map +2 -2
- package/dist/es/index.less +8 -1
- package/dist/es/utils/ykStorybookDoc.d.ts +15 -0
- package/dist/es/utils/ykStorybookDoc.js +24 -2
- package/dist/es/utils/ykStorybookDoc.js.map +2 -2
- package/dist/lib/assets/image/skills.zip +0 -0
- package/dist/lib/business/Empty/index.js.map +1 -1
- package/dist/lib/business/YkCharts/Area.d.ts +18 -0
- package/dist/lib/business/YkCharts/Area.js +346 -0
- package/dist/lib/business/YkCharts/Area.js.map +7 -0
- package/dist/lib/business/YkCharts/Bar.d.ts +21 -0
- package/dist/lib/business/YkCharts/Bar.js +323 -0
- package/dist/lib/business/YkCharts/Bar.js.map +7 -0
- package/dist/lib/business/YkCharts/BarProperty.d.ts +21 -0
- package/dist/lib/business/YkCharts/BarProperty.js +370 -0
- package/dist/lib/business/YkCharts/BarProperty.js.map +7 -0
- package/dist/lib/business/YkCharts/BarTotal.d.ts +21 -0
- package/dist/lib/business/YkCharts/BarTotal.js +295 -0
- package/dist/lib/business/YkCharts/BarTotal.js.map +7 -0
- package/dist/lib/business/YkCharts/Line.d.ts +21 -0
- package/dist/lib/business/YkCharts/Line.js +349 -0
- package/dist/lib/business/YkCharts/Line.js.map +7 -0
- package/dist/lib/business/YkCharts/Pie.d.ts +19 -0
- package/dist/lib/business/YkCharts/Pie.js +117 -0
- package/dist/lib/business/YkCharts/Pie.js.map +7 -0
- package/dist/lib/business/YkCharts/PieProperty.d.ts +18 -0
- package/dist/lib/business/YkCharts/PieProperty.js +193 -0
- package/dist/lib/business/YkCharts/PieProperty.js.map +7 -0
- package/dist/lib/business/YkCharts/Pies.d.ts +26 -0
- package/dist/lib/business/YkCharts/Pies.js +337 -0
- package/dist/lib/business/YkCharts/Pies.js.map +7 -0
- package/dist/lib/business/YkCharts/constants.d.ts +1 -0
- package/dist/lib/business/YkCharts/constants.js +71 -0
- package/dist/lib/business/YkCharts/constants.js.map +7 -0
- package/dist/lib/business/YkCharts/hooks.d.ts +4 -0
- package/dist/lib/business/YkCharts/hooks.js +62 -0
- package/dist/lib/business/YkCharts/hooks.js.map +7 -0
- package/dist/lib/business/YkCharts/index.d.ts +9 -0
- package/dist/lib/business/YkCharts/index.js +61 -0
- package/dist/lib/business/YkCharts/index.js.map +7 -0
- package/dist/lib/business/YkCharts/index.module.less +164 -0
- package/dist/lib/business/YkCharts/tooltip.less +92 -0
- package/dist/lib/business/YkCharts/transformData.js +40 -0
- package/dist/lib/business/YkCharts/transformData.js.map +7 -0
- package/dist/lib/business/YkCharts/typing.d.ts +74 -0
- package/dist/lib/business/YkCharts/typing.js +18 -0
- package/dist/lib/business/YkCharts/typing.js.map +7 -0
- package/dist/lib/business/YkCharts/utils.d.ts +4 -0
- package/dist/lib/business/YkCharts/utils.js +143 -0
- package/dist/lib/business/YkCharts/utils.js.map +7 -0
- package/dist/lib/business/YkCharts/variables.less +13 -0
- package/dist/lib/business/YkLoginModule/SmsLoginForm.d.ts +25 -0
- package/dist/lib/business/YkLoginModule/SmsLoginForm.js +171 -0
- package/dist/lib/business/YkLoginModule/SmsLoginForm.js.map +7 -0
- package/dist/lib/business/YkLoginModule/index.d.ts +48 -0
- package/dist/lib/business/YkLoginModule/index.js +206 -0
- package/dist/lib/business/YkLoginModule/index.js.map +7 -0
- package/dist/lib/business/YkLoginModule/styles.module.less +169 -0
- package/dist/lib/business/YkSqlEdit/code-mirror-custom.module.less +154 -0
- package/dist/lib/business/YkSqlEdit/index.d.ts +20 -0
- package/dist/lib/business/YkSqlEdit/index.js +202 -0
- package/dist/lib/business/YkSqlEdit/index.js.map +7 -0
- package/dist/lib/business/YkSqlEdit/sql-language.d.ts +11 -0
- package/dist/lib/business/YkSqlEdit/sql-language.js +1493 -0
- package/dist/lib/business/YkSqlEdit/sql-language.js.map +7 -0
- package/dist/lib/components/YKMarkdown/index.d.ts +11 -0
- package/dist/lib/components/YKMarkdown/index.js +188 -0
- package/dist/lib/components/YKMarkdown/index.js.map +7 -0
- package/dist/lib/components/YKMarkdown/index.module.less +83 -0
- package/dist/lib/components/YkDateRangePicker/YkDateRangePicker.mdx +3 -3
- package/dist/lib/creative/GlassSegmentedRadio/index.d.ts +1 -1
- package/dist/lib/creative/SkillsWriter/index.d.ts +3 -0
- package/dist/lib/creative/SkillsWriter/index.js +200 -0
- package/dist/lib/creative/SkillsWriter/index.js.map +7 -0
- package/dist/lib/creative/SkillsWriter/index.module.less +21 -0
- package/dist/lib/index.d.ts +4 -2
- package/dist/lib/index.js +6 -0
- package/dist/lib/index.js.map +2 -2
- package/dist/lib/index.less +8 -1
- package/dist/lib/utils/ykStorybookDoc.d.ts +15 -0
- package/dist/lib/utils/ykStorybookDoc.js +23 -1
- package/dist/lib/utils/ykStorybookDoc.js.map +2 -2
- package/package.json +16 -2
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/business/YkLoginModule/index.tsx"],
|
|
4
|
+
"sourcesContent": ["import { LoginForm } from '@ant-design/pro-form';\nimport { Flex, message, QRCode, Tabs } from 'antd';\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport SmsLoginForm, { type SmsLoginFormApi } from './SmsLoginForm';\nimport styles from './styles.module.less';\n\nexport type LoginType = 'qrcode' | 'sms';\n\nexport type LoginTabItem = {\n key: LoginType;\n label: React.ReactNode;\n};\n\nexport type QrcodeApi = {\n getQrcode: () => Promise<{ qrcode: string; url: string }>;\n scanLogin: (qrcode: string) => Promise<{\n code: number;\n data?: {\n status?: number;\n msg?: string;\n };\n }>;\n};\n\nexport type LoginModuleProps = {\n title: React.ReactNode;\n tabs: LoginTabItem[];\n defaultLoginType: LoginType;\n containerStyle?: React.CSSProperties;\n actions?: React.ReactNode | ((loginType: LoginType) => React.ReactNode);\n className?: string;\n formClassName?: string;\n tabsClassName?: string;\n inputClassName?: string;\n qrcodeClassName?: string;\n qrcodeBoxClassName?: string;\n\n onFinish: (values: Record<string, unknown>) => Promise<void>;\n\n qrcode?: {\n api: QrcodeApi;\n icon: string;\n iconSize?: number;\n size?: number;\n wrapStyle?: React.CSSProperties;\n onSuccess: () => void | Promise<void>;\n };\n\n sms?: {\n api: SmsLoginFormApi;\n appKey: string;\n };\n};\n\nconst DEFAULT_QRCODE_WRAP_STYLE: React.CSSProperties = {\n padding: 10,\n display: 'flex',\n justifyContent: 'center',\n};\n\nconst LoginModule: React.FC<LoginModuleProps> = (props) => {\n const {\n title,\n tabs,\n defaultLoginType,\n containerStyle,\n actions,\n onFinish,\n qrcode,\n className = styles.root,\n formClassName = styles.form,\n tabsClassName = styles.tabs,\n inputClassName,\n qrcodeClassName = styles.qrcode,\n qrcodeBoxClassName = styles.qrcodeBox,\n sms,\n } = props;\n\n const [loginType, setLoginType] = useState<LoginType>(defaultLoginType);\n\n const [qrcodeStatus, setQrcodeStatus] = useState<'active' | 'expired' | 'loading'>('active');\n const [qrcodeUrl, setQrcodeUrl] = useState<string>('-');\n const [qrcodeValue, setQrcodeValue] = useState<string>('');\n const pollIntervalRef = useRef<ReturnType<typeof setInterval> | null>(null);\n const pollTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const shouldShowSubmitter = loginType !== 'qrcode';\n\n const resolvedActions = useMemo(() => {\n if (!actions) return undefined;\n return typeof actions === 'function' ? actions(loginType) : actions;\n }, [actions, loginType]);\n\n const safeClearTimers = useCallback(() => {\n if (pollIntervalRef.current) clearInterval(pollIntervalRef.current);\n if (pollTimeoutRef.current) clearTimeout(pollTimeoutRef.current);\n pollIntervalRef.current = null;\n pollTimeoutRef.current = null;\n }, []);\n\n const handleQrcodeRefresh = useCallback(async () => {\n if (!qrcode) return;\n setQrcodeStatus('loading');\n try {\n const res = await qrcode.api.getQrcode();\n setQrcodeUrl(res.url);\n setQrcodeValue(res.qrcode);\n setQrcodeStatus('active');\n } catch {\n setQrcodeStatus('expired');\n message.error('获取二维码失败,请稍后重试');\n }\n }, [qrcode]);\n\n const enabledTabKeys = useMemo(() => new Set(tabs.map((t) => t.key)), [tabs]);\n\n useEffect(() => {\n if (enabledTabKeys.has(defaultLoginType)) {\n setLoginType(defaultLoginType);\n return;\n }\n const fallback = tabs[0]?.key;\n if (fallback) setLoginType(fallback);\n }, [defaultLoginType, enabledTabKeys, tabs]);\n\n useEffect(() => {\n if (enabledTabKeys.has(loginType)) return;\n const fallback = tabs[0]?.key;\n if (fallback) setLoginType(fallback);\n }, [enabledTabKeys, loginType, tabs]);\n\n // 切到扫码登录时刷新二维码;离开扫码登录时停止轮询并标记过期\n useEffect(() => {\n safeClearTimers();\n if (loginType !== 'qrcode') {\n setQrcodeStatus('expired');\n return;\n }\n if (!qrcode) {\n setQrcodeStatus('expired');\n return;\n }\n void handleQrcodeRefresh();\n return safeClearTimers;\n }, [handleQrcodeRefresh, loginType, qrcode, safeClearTimers]);\n\n // 扫码轮询:仅在二维码“激活 + 有值 + 在扫码 Tab”时启动\n useEffect(() => {\n safeClearTimers();\n if (!qrcode) return;\n if (loginType !== 'qrcode') return;\n if (qrcodeStatus !== 'active') return;\n if (!qrcodeValue) return;\n\n pollIntervalRef.current = setInterval(() => {\n void qrcode.api\n .scanLogin(qrcodeValue)\n .then((res) => {\n if (res.code !== 200) return;\n\n const status = res.data?.status;\n const msg = res.data?.msg ?? '扫码遇到问题,稍后重试';\n\n if (status === -1) return;\n if (status !== 1) {\n safeClearTimers();\n setQrcodeStatus('expired');\n message.error(msg, 3);\n return;\n }\n safeClearTimers();\n void qrcode.onSuccess();\n })\n .catch(() => {\n // 忽略轮询中的偶发网络错误,保持继续轮询直到超时/成功\n });\n }, 1000);\n\n pollTimeoutRef.current = setTimeout(() => {\n setQrcodeStatus('expired');\n safeClearTimers();\n }, 30000);\n\n return safeClearTimers;\n }, [loginType, qrcode, qrcodeStatus, qrcodeValue, safeClearTimers]);\n\n const tabItems = useMemo(() => tabs.map((t) => ({ key: t.key, label: t.label })), [tabs]);\n\n return (\n <div className={className} style={{ maxWidth: '500px' }}>\n <LoginForm\n className={formClassName}\n onFinish={async (values) => {\n await onFinish(values);\n }}\n title={typeof title === 'string' ? <div className={styles.title}>{title}</div> : title}\n containerStyle={containerStyle}\n submitter={shouldShowSubmitter ? undefined : (false as const)}\n actions={resolvedActions}\n >\n <Tabs\n className={tabsClassName}\n centered\n activeKey={loginType}\n onChange={(activeKey) => {\n const next = activeKey as LoginType;\n setLoginType(next);\n }}\n items={tabItems}\n />\n\n {enabledTabKeys.has('qrcode') && loginType === 'qrcode' && qrcode && (\n <div style={qrcode.wrapStyle ?? DEFAULT_QRCODE_WRAP_STYLE}>\n <div className={qrcodeBoxClassName}>\n <Flex justify='center' align='center'>\n <i className='iconfont icon-saoyisao' style={{ color: '#999999', marginRight: 10, fontSize: 14 }}></i>\n 请使用<span style={{ color: '#0A6BFD' }}>小闪扫码</span>登录\n </Flex>\n <QRCode\n icon={qrcode.icon}\n iconSize={qrcode.iconSize ?? 50}\n className={qrcodeClassName}\n size={qrcode.size ?? 240}\n value={qrcodeUrl}\n status={qrcodeStatus}\n onRefresh={handleQrcodeRefresh}\n />\n </div>\n </div>\n )}\n\n {enabledTabKeys.has('sms') && loginType === 'sms' && sms && (\n <SmsLoginForm inputClassName={inputClassName ?? ''} api={sms.api} appKey={sms.appKey} />\n )}\n </LoginForm>\n </div>\n );\n};\n\nexport default LoginModule;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA0B;AAC1B,kBAA4C;AAC5C,mBAAyE;AACzE,0BAAmD;AACnD,2BAAmB;AAkDnB,IAAM,4BAAiD;AAAA,EACrD,SAAS;AAAA,EACT,SAAS;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AAA,QAAA,cAAC,SAAI,WAAW,sBACd,6BAAAA,QAAA,cAAC,oBAAK,SAAQ,UAAS,OAAM,YAC3B,6BAAAA,QAAA,cAAC,OAAE,WAAU,0BAAyB,OAAO,EAAE,OAAO,WAAW,aAAa,IAAI,UAAU,GAAG,GAAG,GAAI,OACnG,6BAAAA,QAAA,cAAC,UAAK,OAAO,EAAE,OAAO,UAAU,KAAG,MAAI,GAAO,IACnD,GACA,6BAAAA,QAAA;AAAA,MAAC;AAAA;AAAA,QACC,MAAM,OAAO;AAAA,QACb,UAAU,OAAO,YAAY;AAAA,QAC7B,WAAW;AAAA,QACX,MAAM,OAAO,QAAQ;AAAA,QACrB,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,WAAW;AAAA;AAAA,IACb,CACF,CACF;AAAA,IAGD,eAAe,IAAI,KAAK,KAAK,cAAc,SAAS,OACnD,6BAAAA,QAAA,cAAC,oBAAAC,SAAA,EAAa,gBAAgB,kBAAkB,IAAI,KAAK,IAAI,KAAK,QAAQ,IAAI,QAAQ;AAAA,EAE1F,CACF;AAEJ;AAEA,IAAO,wBAAQ;",
|
|
6
|
+
"names": ["styles", "React", "SmsLoginForm"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex: 1;
|
|
4
|
+
align-items: center;
|
|
5
|
+
justify-content: center;
|
|
6
|
+
|
|
7
|
+
:global {
|
|
8
|
+
@media (max-width: 768px) {
|
|
9
|
+
.ant-pro-form-login-container {
|
|
10
|
+
padding: 20px !important;
|
|
11
|
+
padding-inline: 0;
|
|
12
|
+
padding-block: 0;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.ant-pro-form-login-container {
|
|
17
|
+
border: 1px solid #ececec;
|
|
18
|
+
border-radius: 12px;
|
|
19
|
+
background: #ffffff;
|
|
20
|
+
|
|
21
|
+
.ant-pro-form-login-top {
|
|
22
|
+
margin-bottom: 54px;
|
|
23
|
+
|
|
24
|
+
.ant-pro-form-login-header {
|
|
25
|
+
justify-content: flex-start;
|
|
26
|
+
height: 33px;
|
|
27
|
+
line-height: 33px;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.ant-pro-form-login-main {
|
|
32
|
+
width: 100% !important;
|
|
33
|
+
max-width: 500px !important;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@media (max-width: 768px) {
|
|
37
|
+
.ant-pro-form-login-main {
|
|
38
|
+
width: 100% !important;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.ant-form-item-control-input {
|
|
42
|
+
.ant-input-affix-wrapper {
|
|
43
|
+
width: 100% !important;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.ant-pro-form-login-main-other {
|
|
49
|
+
margin-top: 0;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.title {
|
|
56
|
+
height: 33px;
|
|
57
|
+
color: #333333;
|
|
58
|
+
font-weight: 600;
|
|
59
|
+
font-size: 24px;
|
|
60
|
+
line-height: 33px;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.tabs {
|
|
64
|
+
:global {
|
|
65
|
+
.ant-tabs-nav {
|
|
66
|
+
margin: 0 0 30px 0;
|
|
67
|
+
|
|
68
|
+
.ant-tabs-nav-wrap {
|
|
69
|
+
justify-content: left;
|
|
70
|
+
border-bottom: 1px solid #eeeeee;
|
|
71
|
+
|
|
72
|
+
.ant-tabs-nav-list {
|
|
73
|
+
.ant-tabs-tab {
|
|
74
|
+
padding: 0 0 15px 0;
|
|
75
|
+
|
|
76
|
+
.ant-tabs-tab-btn {
|
|
77
|
+
color: #666666;
|
|
78
|
+
font-weight: 400;
|
|
79
|
+
font-size: 18px;
|
|
80
|
+
line-height: 25px;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
&.ant-tabs-tab-active {
|
|
84
|
+
.ant-tabs-tab-btn {
|
|
85
|
+
color: #333333;
|
|
86
|
+
font-weight: 600;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.form {
|
|
97
|
+
:global {
|
|
98
|
+
width: 100%;
|
|
99
|
+
|
|
100
|
+
.ant-form-item {
|
|
101
|
+
margin-bottom: 20px;
|
|
102
|
+
|
|
103
|
+
.ant-form-item-row {
|
|
104
|
+
.ant-form-item-explain-error {
|
|
105
|
+
font-size: 12px;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.ant-form-item-control-input {
|
|
109
|
+
.ant-input-affix-wrapper {
|
|
110
|
+
width: 100%;
|
|
111
|
+
height: 50px;
|
|
112
|
+
background: #fcfcfc;
|
|
113
|
+
border: 1px solid #ececec;
|
|
114
|
+
border-radius: 4px;
|
|
115
|
+
|
|
116
|
+
.ant-input-prefix {
|
|
117
|
+
margin-right: 15px;
|
|
118
|
+
color: #666;
|
|
119
|
+
font-size: 20px;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
input {
|
|
123
|
+
background: #fcfcfc;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.ant-btn-primary {
|
|
131
|
+
width: 100%;
|
|
132
|
+
height: 50px;
|
|
133
|
+
margin-top: 37px;
|
|
134
|
+
margin-bottom: 46px;
|
|
135
|
+
padding: 0;
|
|
136
|
+
color: #ffffff;
|
|
137
|
+
font-weight: 600;
|
|
138
|
+
font-size: 18px;
|
|
139
|
+
line-height: 50px;
|
|
140
|
+
background: linear-gradient(131deg, #1d93ff 0%, #0a6bfd 100%);
|
|
141
|
+
border-radius: 4px;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.actions {
|
|
147
|
+
color: #666666;
|
|
148
|
+
font-weight: 400;
|
|
149
|
+
font-size: 14px;
|
|
150
|
+
line-height: 25px;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.qrcodeBox {
|
|
154
|
+
padding: 20px 24px;
|
|
155
|
+
border: 1px solid #ececec;
|
|
156
|
+
border-radius: 12px;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.qrcode {
|
|
160
|
+
:global {
|
|
161
|
+
border: none !important;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.captchaBtn {
|
|
166
|
+
padding: 0;
|
|
167
|
+
color: #0a6bfd;
|
|
168
|
+
}
|
|
169
|
+
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
.codeMirrorCustom {
|
|
2
|
+
width: 100%;
|
|
3
|
+
height: 100%;
|
|
4
|
+
border: 0.5px solid #ecedf1;
|
|
5
|
+
|
|
6
|
+
&.disabled {
|
|
7
|
+
:global {
|
|
8
|
+
.cm-activeLine,
|
|
9
|
+
.cm-activeLineGutter {
|
|
10
|
+
background-color: transparent !important;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// CodeMirror 语法高亮样式覆盖
|
|
16
|
+
:global {
|
|
17
|
+
color: #888d9d;
|
|
18
|
+
// 关键字 - 蓝色
|
|
19
|
+
.ͼb {
|
|
20
|
+
color: #997bbf !important;
|
|
21
|
+
font-weight: 400;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// 类型名 - 紫色
|
|
25
|
+
.ͼi {
|
|
26
|
+
color: #997bbf !important;
|
|
27
|
+
font-weight: 400;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// 字符串 - 绿色
|
|
31
|
+
.ͼc,
|
|
32
|
+
.ͼf,
|
|
33
|
+
.ͼe {
|
|
34
|
+
color: #9dbd93 !important;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// 数字 - 橙色
|
|
38
|
+
.ͼd {
|
|
39
|
+
color: #e57271 !important;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// 注释 - 灰色
|
|
43
|
+
.ͼm {
|
|
44
|
+
color: #999999 !important;
|
|
45
|
+
font-style: italic;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// 变量名 - 黑色
|
|
49
|
+
.ͼg {
|
|
50
|
+
color: #000000 !important;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// 表名、列名 - 深绿色
|
|
54
|
+
.ͼh {
|
|
55
|
+
color: #006633 !important;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.cm-dynamic-param {
|
|
59
|
+
color: #4484d2 !important;
|
|
60
|
+
|
|
61
|
+
.ͼi,
|
|
62
|
+
.ͼb,
|
|
63
|
+
.ͼc,
|
|
64
|
+
.ͼd,
|
|
65
|
+
.ͼe,
|
|
66
|
+
.ͼf,
|
|
67
|
+
.ͼg,
|
|
68
|
+
.ͼh {
|
|
69
|
+
color: #4484d2 !important;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// 自定义关键词高亮样式
|
|
76
|
+
:global {
|
|
77
|
+
.cm-custom-keyword {
|
|
78
|
+
color: #997bbf !important;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.cm-editor {
|
|
82
|
+
outline: none !important;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.cm-activeLine {
|
|
86
|
+
background-color: rgb(204 238 255 / 60%) !important;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// 确保自定义关键词在语法高亮之上
|
|
90
|
+
.cm-editor .cm-line .cm-custom-keyword {
|
|
91
|
+
position: relative;
|
|
92
|
+
z-index: 10;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
:global {
|
|
97
|
+
.cm-scroller {
|
|
98
|
+
font-size: 12px;
|
|
99
|
+
background-color: #f9fbfc;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.cm-gutters {
|
|
103
|
+
background-color: #f6f6f9 !important;
|
|
104
|
+
border: none !important;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.cm-gutterElement {
|
|
108
|
+
color: #999 !important;
|
|
109
|
+
|
|
110
|
+
span[title='Fold line'] {
|
|
111
|
+
display: inline-block;
|
|
112
|
+
transform: translateY(-5px);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.cm-tooltip {
|
|
117
|
+
padding: 10px !important;
|
|
118
|
+
background-color: #fff !important;
|
|
119
|
+
border: none !important;
|
|
120
|
+
border-radius: 4px !important;
|
|
121
|
+
box-shadow: 0 0 10px 0 rgba(154, 153, 153, 0.2);
|
|
122
|
+
|
|
123
|
+
.cm-completionLabel {
|
|
124
|
+
color: #666 !important;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.cm-completionMatchedText {
|
|
128
|
+
color: #ff9600 !important;
|
|
129
|
+
text-decoration: none !important;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.cm-tooltip-autocomplete ul li {
|
|
134
|
+
display: flex !important;
|
|
135
|
+
margin-bottom: 5px !important;
|
|
136
|
+
line-height: 30px !important;
|
|
137
|
+
border-radius: 4px !important;
|
|
138
|
+
|
|
139
|
+
.cm-completionDetail {
|
|
140
|
+
margin-left: auto !important;
|
|
141
|
+
padding-right: 10px !important;
|
|
142
|
+
color: #999 !important;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.cm-tooltip.cm-tooltip-autocomplete > ul {
|
|
147
|
+
max-height: 220px !important;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.cm-tooltip-autocomplete ul li[aria-selected] {
|
|
151
|
+
background-color: #f1f8ff !important;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type ReactCodeMirrorRef } from '@uiw/react-codemirror';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { type SqlDialectType } from './sql-language';
|
|
4
|
+
export type YkSqlEditProps = {
|
|
5
|
+
value: string;
|
|
6
|
+
previewValue?: string;
|
|
7
|
+
preview?: boolean;
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
height?: string;
|
|
10
|
+
width?: string;
|
|
11
|
+
onChange: (value: string) => void;
|
|
12
|
+
datasourceType?: SqlDialectType;
|
|
13
|
+
keywordOptions?: {
|
|
14
|
+
keywords: string[];
|
|
15
|
+
functions: string[];
|
|
16
|
+
};
|
|
17
|
+
dataTestId?: string;
|
|
18
|
+
};
|
|
19
|
+
declare const YkSqlEdit: React.ForwardRefExoticComponent<YkSqlEditProps & React.RefAttributes<ReactCodeMirrorRef>>;
|
|
20
|
+
export default YkSqlEdit;
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/business/YkSqlEdit/index.tsx
|
|
30
|
+
var YkSqlEdit_exports = {};
|
|
31
|
+
__export(YkSqlEdit_exports, {
|
|
32
|
+
default: () => YkSqlEdit_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(YkSqlEdit_exports);
|
|
35
|
+
var import_autocomplete = require("@codemirror/autocomplete");
|
|
36
|
+
var import_lang_sql = require("@codemirror/lang-sql");
|
|
37
|
+
var import_view = require("@codemirror/view");
|
|
38
|
+
var import_react_codemirror = __toESM(require("@uiw/react-codemirror"));
|
|
39
|
+
var import_react = __toESM(require("react"));
|
|
40
|
+
var import_code_mirror_custom_module = __toESM(require("./code-mirror-custom.module.less"));
|
|
41
|
+
var import_sql_language = require("./sql-language");
|
|
42
|
+
function dynamicParamHighlighter() {
|
|
43
|
+
return import_view.ViewPlugin.fromClass(
|
|
44
|
+
class {
|
|
45
|
+
constructor(view) {
|
|
46
|
+
this.decorations = this.buildDecorations(view);
|
|
47
|
+
}
|
|
48
|
+
update(update) {
|
|
49
|
+
if (update.docChanged || update.viewportChanged) {
|
|
50
|
+
this.decorations = this.buildDecorations(update.view);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
buildDecorations(view) {
|
|
54
|
+
const widgets = [];
|
|
55
|
+
const regex = /\{\{.*?\}\}/g;
|
|
56
|
+
for (const { from, to } of view.visibleRanges) {
|
|
57
|
+
const text = view.state.doc.sliceString(from, to);
|
|
58
|
+
let match;
|
|
59
|
+
while ((match = regex.exec(text)) !== null) {
|
|
60
|
+
const start = from + match.index;
|
|
61
|
+
const end = start + match[0].length;
|
|
62
|
+
widgets.push(import_view.Decoration.mark({ class: "cm-dynamic-param" }).range(start, end));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return import_view.Decoration.set(widgets, true);
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
decorations: (v) => v.decorations
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
function customKeywordHighlighter(allKeywords) {
|
|
74
|
+
return import_view.ViewPlugin.fromClass(
|
|
75
|
+
class {
|
|
76
|
+
constructor(view) {
|
|
77
|
+
this.decorations = this.buildDecorations(view);
|
|
78
|
+
}
|
|
79
|
+
update(update) {
|
|
80
|
+
if (update.docChanged || update.viewportChanged) {
|
|
81
|
+
this.decorations = this.buildDecorations(update.view);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
buildDecorations(view) {
|
|
85
|
+
if (!allKeywords.length)
|
|
86
|
+
return import_view.Decoration.none;
|
|
87
|
+
const widgets = [];
|
|
88
|
+
const regex = new RegExp(`\\b(${allKeywords.join("|")})\\b`, "gi");
|
|
89
|
+
for (const { from, to } of view.visibleRanges) {
|
|
90
|
+
const text = view.state.doc.sliceString(from, to);
|
|
91
|
+
let match;
|
|
92
|
+
while ((match = regex.exec(text)) !== null) {
|
|
93
|
+
const start = from + match.index;
|
|
94
|
+
const end = start + match[0].length;
|
|
95
|
+
widgets.push(
|
|
96
|
+
import_view.Decoration.mark({
|
|
97
|
+
class: "cm-custom-keyword",
|
|
98
|
+
attributes: { "data-keyword": match[0] }
|
|
99
|
+
}).range(start, end)
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return import_view.Decoration.set(widgets, true);
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
decorations: (v) => v.decorations
|
|
108
|
+
}
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
function buildCompletions(keywordOptions) {
|
|
112
|
+
const keywords = (keywordOptions == null ? void 0 : keywordOptions.keywords) ?? [];
|
|
113
|
+
const functions = (keywordOptions == null ? void 0 : keywordOptions.functions) ?? [];
|
|
114
|
+
const allKeywords = [.../* @__PURE__ */ new Set([...keywords, ...functions])];
|
|
115
|
+
return (context) => {
|
|
116
|
+
const word = context.matchBefore(/\w*/);
|
|
117
|
+
if ((word == null ? void 0 : word.from) === (word == null ? void 0 : word.to) && !context.explicit)
|
|
118
|
+
return null;
|
|
119
|
+
const search = ((word == null ? void 0 : word.text) ?? "").toLowerCase();
|
|
120
|
+
const options = allKeywords.filter((kw) => kw.toLowerCase().includes(search)).map((kw) => ({
|
|
121
|
+
label: kw,
|
|
122
|
+
detail: keywords.includes(kw) ? "关键字" : functions.includes(kw) ? "函数" : "",
|
|
123
|
+
boost: kw.toLowerCase().startsWith(search) ? 10 : 1
|
|
124
|
+
})).sort((a, b) => (b.boost ?? 0) - (a.boost ?? 0));
|
|
125
|
+
return {
|
|
126
|
+
from: (word == null ? void 0 : word.from) ?? 0,
|
|
127
|
+
options: options.slice(0, 50)
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
var YkSqlEdit = import_react.default.forwardRef((props, ref) => {
|
|
132
|
+
const {
|
|
133
|
+
value,
|
|
134
|
+
previewValue,
|
|
135
|
+
preview,
|
|
136
|
+
placeholder = "请输入查询语句",
|
|
137
|
+
height = "100%",
|
|
138
|
+
width = "100%",
|
|
139
|
+
onChange,
|
|
140
|
+
datasourceType,
|
|
141
|
+
keywordOptions,
|
|
142
|
+
dataTestId = "native-query-editor"
|
|
143
|
+
} = props;
|
|
144
|
+
const resolvedKeywordOptions = import_react.default.useMemo(() => {
|
|
145
|
+
if (keywordOptions)
|
|
146
|
+
return keywordOptions;
|
|
147
|
+
if (!datasourceType)
|
|
148
|
+
return { keywords: [], functions: [] };
|
|
149
|
+
return {
|
|
150
|
+
keywords: (0, import_sql_language.sqlKeywords)(datasourceType),
|
|
151
|
+
functions: (0, import_sql_language.sqlFunctions)(datasourceType)
|
|
152
|
+
};
|
|
153
|
+
}, [datasourceType, keywordOptions]);
|
|
154
|
+
const allKeywords = import_react.default.useMemo(() => {
|
|
155
|
+
const keywords = resolvedKeywordOptions.keywords ?? [];
|
|
156
|
+
const functions = resolvedKeywordOptions.functions ?? [];
|
|
157
|
+
return [.../* @__PURE__ */ new Set([...keywords, ...functions])];
|
|
158
|
+
}, [resolvedKeywordOptions]);
|
|
159
|
+
const customCompletions = import_react.default.useMemo(() => buildCompletions(resolvedKeywordOptions), [resolvedKeywordOptions]);
|
|
160
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
161
|
+
import_react_codemirror.default,
|
|
162
|
+
{
|
|
163
|
+
ref,
|
|
164
|
+
value: preview ? previewValue ?? value : value,
|
|
165
|
+
className: `${import_code_mirror_custom_module.default.codeMirrorCustom} ${preview ? import_code_mirror_custom_module.default.disabled : ""}`,
|
|
166
|
+
"data-testid": dataTestId,
|
|
167
|
+
placeholder,
|
|
168
|
+
height,
|
|
169
|
+
width,
|
|
170
|
+
editable: !preview,
|
|
171
|
+
autoCorrect: "off",
|
|
172
|
+
extensions: [
|
|
173
|
+
(0, import_lang_sql.sql)({ dialect: import_lang_sql.MySQL }),
|
|
174
|
+
dynamicParamHighlighter(),
|
|
175
|
+
customKeywordHighlighter(allKeywords),
|
|
176
|
+
(0, import_autocomplete.autocompletion)({
|
|
177
|
+
override: [customCompletions]
|
|
178
|
+
})
|
|
179
|
+
],
|
|
180
|
+
onChange: (next) => onChange(next),
|
|
181
|
+
basicSetup: {
|
|
182
|
+
closeBrackets: true,
|
|
183
|
+
autocompletion: true,
|
|
184
|
+
bracketMatching: true,
|
|
185
|
+
highlightSpecialChars: true,
|
|
186
|
+
searchKeymap: true,
|
|
187
|
+
history: true,
|
|
188
|
+
historyKeymap: true,
|
|
189
|
+
drawSelection: true,
|
|
190
|
+
syntaxHighlighting: true,
|
|
191
|
+
defaultKeymap: true,
|
|
192
|
+
dropCursor: true,
|
|
193
|
+
highlightSelectionMatches: true,
|
|
194
|
+
completionKeymap: true,
|
|
195
|
+
highlightActiveLineGutter: true
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
);
|
|
199
|
+
});
|
|
200
|
+
YkSqlEdit.displayName = "YkSqlEdit";
|
|
201
|
+
var YkSqlEdit_default = YkSqlEdit;
|
|
202
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/business/YkSqlEdit/index.tsx"],
|
|
4
|
+
"sourcesContent": ["import {\n autocompletion,\n type Completion,\n type CompletionContext,\n type CompletionResult,\n} from '@codemirror/autocomplete';\nimport { MySQL, sql } from '@codemirror/lang-sql';\nimport { Decoration, type EditorView, ViewPlugin, type ViewUpdate } from '@codemirror/view';\nimport CodeMirror, { type ReactCodeMirrorRef } from '@uiw/react-codemirror';\nimport React from 'react';\nimport customStyles from './code-mirror-custom.module.less';\nimport { type SqlDialectType, sqlFunctions, sqlKeywords } from './sql-language';\n\nexport type YkSqlEditProps = {\n value: string;\n previewValue?: string;\n preview?: boolean;\n placeholder?: string;\n height?: string;\n width?: string;\n onChange: (value: string) => void;\n\n datasourceType?: SqlDialectType;\n keywordOptions?: {\n keywords: string[];\n functions: string[];\n };\n dataTestId?: string;\n};\n\n// 动态参数高亮插件\nfunction dynamicParamHighlighter() {\n return ViewPlugin.fromClass(\n class {\n decorations;\n constructor(view: EditorView) {\n this.decorations = this.buildDecorations(view);\n }\n update(update: ViewUpdate) {\n if (update.docChanged || update.viewportChanged) {\n this.decorations = this.buildDecorations(update.view);\n }\n }\n buildDecorations(view: EditorView) {\n const widgets = [];\n const regex = /\\{\\{.*?\\}\\}/g;\n for (const { from, to } of view.visibleRanges) {\n const text = view.state.doc.sliceString(from, to);\n let match;\n while ((match = regex.exec(text)) !== null) {\n const start = from + match.index;\n const end = start + match[0].length;\n widgets.push(Decoration.mark({ class: 'cm-dynamic-param' }).range(start, end));\n }\n }\n return Decoration.set(widgets, true);\n }\n },\n {\n decorations: (v) => v.decorations,\n },\n );\n}\n\nfunction customKeywordHighlighter(allKeywords: string[]) {\n return ViewPlugin.fromClass(\n class {\n decorations;\n constructor(view: EditorView) {\n this.decorations = this.buildDecorations(view);\n }\n update(update: ViewUpdate) {\n if (update.docChanged || update.viewportChanged) {\n this.decorations = this.buildDecorations(update.view);\n }\n }\n buildDecorations(view: EditorView) {\n if (!allKeywords.length) return Decoration.none;\n\n const widgets = [];\n const regex = new RegExp(`\\\\b(${allKeywords.join('|')})\\\\b`, 'gi');\n\n for (const { from, to } of view.visibleRanges) {\n const text = view.state.doc.sliceString(from, to);\n let match;\n while ((match = regex.exec(text)) !== null) {\n const start = from + match.index;\n const end = start + match[0].length;\n widgets.push(\n Decoration.mark({\n class: 'cm-custom-keyword',\n attributes: { 'data-keyword': match[0] },\n }).range(start, end),\n );\n }\n }\n return Decoration.set(widgets, true);\n }\n },\n {\n decorations: (v) => v.decorations,\n },\n );\n}\n\nfunction buildCompletions(keywordOptions?: YkSqlEditProps['keywordOptions']) {\n const keywords = keywordOptions?.keywords ?? [];\n const functions = keywordOptions?.functions ?? [];\n const allKeywords = [...new Set([...keywords, ...functions])];\n\n return (context: CompletionContext): CompletionResult | null => {\n const word = context.matchBefore(/\\w*/);\n if (word?.from === word?.to && !context.explicit) return null;\n\n const search = (word?.text ?? '').toLowerCase();\n const options: Completion[] = allKeywords\n .filter((kw) => kw.toLowerCase().includes(search))\n .map((kw) => ({\n label: kw,\n detail: keywords.includes(kw) ? '关键字' : functions.includes(kw) ? '函数' : '',\n boost: kw.toLowerCase().startsWith(search) ? 10 : 1,\n }))\n .sort((a, b) => (b.boost ?? 0) - (a.boost ?? 0));\n\n return {\n from: word?.from ?? 0,\n options: options.slice(0, 50),\n };\n };\n}\n\nconst YkSqlEdit = React.forwardRef<ReactCodeMirrorRef, YkSqlEditProps>((props, ref) => {\n const {\n value,\n previewValue,\n preview,\n placeholder = '请输入查询语句',\n height = '100%',\n width = '100%',\n onChange,\n datasourceType,\n keywordOptions,\n dataTestId = 'native-query-editor',\n } = props;\n\n const resolvedKeywordOptions = React.useMemo(() => {\n if (keywordOptions) return keywordOptions;\n if (!datasourceType) return { keywords: [], functions: [] };\n return {\n keywords: sqlKeywords(datasourceType),\n functions: sqlFunctions(datasourceType),\n };\n }, [datasourceType, keywordOptions]);\n\n const allKeywords = React.useMemo(() => {\n const keywords = resolvedKeywordOptions.keywords ?? [];\n const functions = resolvedKeywordOptions.functions ?? [];\n return [...new Set([...keywords, ...functions])];\n }, [resolvedKeywordOptions]);\n\n const customCompletions = React.useMemo(() => buildCompletions(resolvedKeywordOptions), [resolvedKeywordOptions]);\n\n return (\n <CodeMirror\n ref={ref}\n value={preview ? (previewValue ?? value) : value}\n className={`${customStyles.codeMirrorCustom} ${preview ? customStyles.disabled : ''}`}\n data-testid={dataTestId}\n placeholder={placeholder}\n height={height}\n width={width}\n editable={!preview}\n autoCorrect='off'\n extensions={[\n sql({ dialect: MySQL }),\n dynamicParamHighlighter(),\n customKeywordHighlighter(allKeywords),\n autocompletion({\n override: [customCompletions],\n }),\n ]}\n onChange={(next) => onChange(next)}\n basicSetup={{\n closeBrackets: true,\n autocompletion: true,\n bracketMatching: true,\n highlightSpecialChars: true,\n searchKeymap: true,\n history: true,\n historyKeymap: true,\n drawSelection: true,\n syntaxHighlighting: true,\n defaultKeymap: true,\n dropCursor: true,\n highlightSelectionMatches: true,\n completionKeymap: true,\n highlightActiveLineGutter: true,\n }}\n />\n );\n});\n\nYkSqlEdit.displayName = 'YkSqlEdit';\n\nexport default YkSqlEdit;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;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AAAA,IAAA;AAAA,MACC;AAAA,MACA,OAAO,UAAW,gBAAgB,QAAS;AAAA,MAC3C,WAAW,GAAG,iCAAAC,QAAa,oBAAoB,UAAU,iCAAAA,QAAa,WAAW;AAAA,MACjF,eAAa;AAAA,MACb;AAAA,MACA;AAAA,MACA;AAAA,MACA,UAAU,CAAC;AAAA,MACX,aAAY;AAAA,MACZ,YAAY;AAAA,YACV,qBAAI,EAAE,SAAS,sBAAM,CAAC;AAAA,QACtB,wBAAwB;AAAA,QACxB,yBAAyB,WAAW;AAAA,YACpC,oCAAe;AAAA,UACb,UAAU,CAAC,iBAAiB;AAAA,QAC9B,CAAC;AAAA,MACH;AAAA,MACA,UAAU,CAAC,SAAS,SAAS,IAAI;AAAA,MACjC,YAAY;AAAA,QACV,eAAe;AAAA,QACf,gBAAgB;AAAA,QAChB,iBAAiB;AAAA,QACjB,uBAAuB;AAAA,QACvB,cAAc;AAAA,QACd,SAAS;AAAA,QACT,eAAe;AAAA,QACf,eAAe;AAAA,QACf,oBAAoB;AAAA,QACpB,eAAe;AAAA,QACf,YAAY;AAAA,QACZ,2BAA2B;AAAA,QAC3B,kBAAkB;AAAA,QAClB,2BAA2B;AAAA,MAC7B;AAAA;AAAA,EACF;AAEJ,CAAC;AAED,UAAU,cAAc;AAExB,IAAO,oBAAQ;",
|
|
6
|
+
"names": ["React", "CodeMirror", "customStyles"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type SqlDialectType = 'starrocks' | 'impala' | 'hive' | string;
|
|
2
|
+
export declare const defaultKeywords: string[];
|
|
3
|
+
export declare const defaultFunctions: string[];
|
|
4
|
+
export declare const srKeywords: string[];
|
|
5
|
+
export declare const srFunctions: string[];
|
|
6
|
+
export declare const impalaKeywords: string[];
|
|
7
|
+
export declare const impalaFunctions: string[];
|
|
8
|
+
export declare const hiveKeywords: string[];
|
|
9
|
+
export declare const hiveFunctions: string[];
|
|
10
|
+
export declare const sqlKeywords: (type: SqlDialectType) => string[];
|
|
11
|
+
export declare const sqlFunctions: (type: SqlDialectType) => string[];
|