@keboola/design 11.0.1 → 11.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +41 -15
- package/CHANGELOG.md +2392 -0
- package/COMPONENT-API.md +41 -2
- package/dist/{AIKit-Dre37SJr.js → AIKit-DaFT7p92.js} +23 -22
- package/dist/AIKit-DaFT7p92.js.map +1 -0
- package/dist/{Alert-DfZq9kGe.js → Alert-CseY3yAj.js} +3 -3
- package/dist/{Alert-DfZq9kGe.js.map → Alert-CseY3yAj.js.map} +1 -1
- package/dist/{AlertModal-BUC4Es8o.js → AlertModal-DQAGpsEy.js} +4 -7
- package/dist/{AlertModal-BUC4Es8o.js.map → AlertModal-DQAGpsEy.js.map} +1 -1
- package/dist/{AppShell-B5GQN6Zs.js → AppShell-BUoxM3fv.js} +29 -10
- package/dist/AppShell-BUoxM3fv.js.map +1 -0
- package/dist/{BrandEditor-B8o9zdZO.js → BrandEditor-BnTLMRMp.js} +6 -6
- package/dist/{BrandEditor-B8o9zdZO.js.map → BrandEditor-BnTLMRMp.js.map} +1 -1
- package/dist/{BrandLogo-CJkRd0F8.js → BrandLogo-V2pRUAeO.js} +2 -2
- package/dist/{BrandLogo-CJkRd0F8.js.map → BrandLogo-V2pRUAeO.js.map} +1 -1
- package/dist/{Breadcrumb-DJp7WwSv.js → Breadcrumb-CQTPn_KB.js} +3 -3
- package/dist/{Breadcrumb-DJp7WwSv.js.map → Breadcrumb-CQTPn_KB.js.map} +1 -1
- package/dist/{Button-nzmDNS2q.js → Button-CPsEQuTN.js} +16 -16
- package/dist/Button-CPsEQuTN.js.map +1 -0
- package/dist/{Card-BAoZ35CV.js → Card-Cd5HSBmv.js} +2 -2
- package/dist/{Card-BAoZ35CV.js.map → Card-Cd5HSBmv.js.map} +1 -1
- package/dist/{Checkbox-GJ8-srt4.js → Checkbox-5VNCcV7E.js} +3 -3
- package/dist/{Checkbox-GJ8-srt4.js.map → Checkbox-5VNCcV7E.js.map} +1 -1
- package/dist/{Clipboard-CBJZiviP.js → Clipboard-B7rckqV_.js} +2 -2
- package/dist/{Clipboard-CBJZiviP.js.map → Clipboard-B7rckqV_.js.map} +1 -1
- package/dist/{ClipboardButton-ez5V3fkk.js → ClipboardButton-CQ6Aewpg.js} +3 -3
- package/dist/{ClipboardButton-ez5V3fkk.js.map → ClipboardButton-CQ6Aewpg.js.map} +1 -1
- package/dist/{CodeEditor-BfQJfbhL.js → CodeEditor-CUse8znx.js} +290 -100
- package/dist/CodeEditor-CUse8znx.js.map +1 -0
- package/dist/{ColorInput-Dx8Dsv7Y.js → ColorInput-Q1D9Vcc_.js} +3 -3
- package/dist/{ColorInput-Dx8Dsv7Y.js.map → ColorInput-Q1D9Vcc_.js.map} +1 -1
- package/dist/{ColorModeSwitch-CCqj7tjE.js → ColorModeSwitch-B5PXCVqB.js} +3 -3
- package/dist/{ColorModeSwitch-CCqj7tjE.js.map → ColorModeSwitch-B5PXCVqB.js.map} +1 -1
- package/dist/{Combobox-c_xBjf0P.js → Combobox-CyoRA7oY.js} +12 -8
- package/dist/Combobox-CyoRA7oY.js.map +1 -0
- package/dist/{Command-CQ_bQsJp.js → Command-Ds68v2rX.js} +3 -3
- package/dist/{Command-CQ_bQsJp.js.map → Command-Ds68v2rX.js.map} +1 -1
- package/dist/{CopyField-BJ96zvXs.js → CopyField-DI66uY_g.js} +2 -2
- package/dist/{CopyField-BJ96zvXs.js.map → CopyField-DI66uY_g.js.map} +1 -1
- package/dist/{DateInput-CMD3dY-T.js → DateInput-BPj2pzsn.js} +4 -4
- package/dist/{DateInput-CMD3dY-T.js.map → DateInput-BPj2pzsn.js.map} +1 -1
- package/dist/{DatePicker-BbFbmsGl.js → DatePicker-DyEGuW9m.js} +2 -2
- package/dist/{DatePicker-BbFbmsGl.js.map → DatePicker-DyEGuW9m.js.map} +1 -1
- package/dist/{DateRangeInput-D3BhiKyk.js → DateRangeInput-u9DxNbHW.js} +4 -4
- package/dist/{DateRangeInput-D3BhiKyk.js.map → DateRangeInput-u9DxNbHW.js.map} +1 -1
- package/dist/{DateRangePicker-BiUgtt_M.js → DateRangePicker-CYYhX6S7.js} +6 -6
- package/dist/{DateRangePicker-BiUgtt_M.js.map → DateRangePicker-CYYhX6S7.js.map} +1 -1
- package/dist/{DropdownMenu-B6ZbYvaM.js → DropdownMenu-DpMEcyCq.js} +9 -9
- package/dist/DropdownMenu-DpMEcyCq.js.map +1 -0
- package/dist/FieldItem-qQKGU9lF.js +108 -0
- package/dist/FieldItem-qQKGU9lF.js.map +1 -0
- package/dist/FieldItem-vhIJW4pj.d.ts +103 -0
- package/dist/{FileUpload-sXRv7JiY.js → FileUpload-C336MVnU.js} +2 -2
- package/dist/{FileUpload-sXRv7JiY.js.map → FileUpload-C336MVnU.js.map} +1 -1
- package/dist/{Form-BDCef6O9.js → Form-CTygENDc.js} +21 -81
- package/dist/{Form-BDCef6O9.js.map → Form-CTygENDc.js.map} +1 -1
- package/dist/{FormGroup-S9mPNHKH.js → FormGroup-BnwP0jNu.js} +7 -7
- package/dist/FormGroup-BnwP0jNu.js.map +1 -0
- package/dist/{FullScreenModal-CJa2VkJ2.js → FullScreenModal-j-M4aPFd.js} +3 -3
- package/dist/{FullScreenModal-CJa2VkJ2.js.map → FullScreenModal-j-M4aPFd.js.map} +1 -1
- package/dist/{HoverCard-WfDkLK1s.js → HoverCard-yQq-O49c.js} +2 -2
- package/dist/{HoverCard-WfDkLK1s.js.map → HoverCard-yQq-O49c.js.map} +1 -1
- package/dist/{InputGroup-BJWsI35s.js → InputGroup-D7zlmqPB.js} +3 -3
- package/dist/{InputGroup-BJWsI35s.js.map → InputGroup-D7zlmqPB.js.map} +1 -1
- package/dist/{Kbd-CxHAo1oo.js → Kbd-D6LpR7G2.js} +2 -2
- package/dist/{Kbd-CxHAo1oo.js.map → Kbd-D6LpR7G2.js.map} +1 -1
- package/dist/{MermaidDiagram-BB06gymm.js → MermaidDiagram-JlvuGcY-.js} +6 -87
- package/dist/MermaidDiagram-JlvuGcY-.js.map +1 -0
- package/dist/{Modal-BA5Wc3sx.js → Modal-o4ATIexE.js} +3 -3
- package/dist/{Modal-BA5Wc3sx.js.map → Modal-o4ATIexE.js.map} +1 -1
- package/dist/{MultiActionButtonGroup-CiBHxsSk.js → MultiActionButtonGroup-GTeFk-L8.js} +3 -3
- package/dist/{MultiActionButtonGroup-CiBHxsSk.js.map → MultiActionButtonGroup-GTeFk-L8.js.map} +1 -1
- package/dist/{Navbar-t16usFZQ.js → Navbar-CAQs4BZz.js} +6 -3
- package/dist/Navbar-CAQs4BZz.js.map +1 -0
- package/dist/{PageToolbar-0_1OBzaZ.js → PageToolbar-bG2YtSa3.js} +4 -4
- package/dist/PageToolbar-bG2YtSa3.js.map +1 -0
- package/dist/{Pagination-CM_Rszz-.js → Pagination-BB3X7ooY.js} +2 -2
- package/dist/{Pagination-CM_Rszz-.js.map → Pagination-BB3X7ooY.js.map} +1 -1
- package/dist/{Popconfirm-BGe1jLov.js → Popconfirm-C2Ky5hJO.js} +4 -7
- package/dist/{Popconfirm-BGe1jLov.js.map → Popconfirm-C2Ky5hJO.js.map} +1 -1
- package/dist/{Popover-Ca0V6AD1.js → Popover-DsbI2HKu.js} +7 -14
- package/dist/Popover-DsbI2HKu.js.map +1 -0
- package/dist/{RadioGroup-sIveSsNa.js → RadioGroup-BMxuZEbT.js} +3 -3
- package/dist/{RadioGroup-sIveSsNa.js.map → RadioGroup-BMxuZEbT.js.map} +1 -1
- package/dist/{Search-3UiqNZRj.js → Search-DFeECt5D.js} +2 -2
- package/dist/{Search-3UiqNZRj.js.map → Search-DFeECt5D.js.map} +1 -1
- package/dist/{SearchInput-D2fcOv7E.js → SearchInput-CCpdUego.js} +3 -3
- package/dist/{SearchInput-D2fcOv7E.js.map → SearchInput-CCpdUego.js.map} +1 -1
- package/dist/{SectionNav--7bw2b6u.js → SectionNav-Bw_MVL0_.js} +4 -4
- package/dist/{SectionNav--7bw2b6u.js.map → SectionNav-Bw_MVL0_.js.map} +1 -1
- package/dist/{Select-4YX38G5h.js → Select-D6IZVvwL.js} +5 -5
- package/dist/Select-D6IZVvwL.js.map +1 -0
- package/dist/{Sheet-BQrX8-h5.js → Sheet-BIzs2K2H.js} +3 -3
- package/dist/{Sheet-BQrX8-h5.js.map → Sheet-BIzs2K2H.js.map} +1 -1
- package/dist/{Sidebar-ROaR_AqC.js → Sidebar-r1TW4g_b.js} +5 -5
- package/dist/{Sidebar-ROaR_AqC.js.map → Sidebar-r1TW4g_b.js.map} +1 -1
- package/dist/{Slider-Da_3mS5v.js → Slider-CjxyfEty.js} +3 -3
- package/dist/{Slider-Da_3mS5v.js.map → Slider-CjxyfEty.js.map} +1 -1
- package/dist/{Switch-CX2A0v50.js → Switch-BueTV03C.js} +2 -2
- package/dist/{Switch-CX2A0v50.js.map → Switch-BueTV03C.js.map} +1 -1
- package/dist/{Tabs-EAihyqCt.js → Tabs-l72-WuhK.js} +2 -2
- package/dist/{Tabs-EAihyqCt.js.map → Tabs-l72-WuhK.js.map} +1 -1
- package/dist/{TextInput-BGed-V13.js → TextInput-DhdRk8qm.js} +3 -3
- package/dist/{TextInput-BGed-V13.js.map → TextInput-DhdRk8qm.js.map} +1 -1
- package/dist/{ThemeProvider-QncUrfJn.js → ThemeProvider-DZfGdf1v.js} +5 -4
- package/dist/{ThemeProvider-QncUrfJn.js.map → ThemeProvider-DZfGdf1v.js.map} +1 -1
- package/dist/{TimePicker-B_NegL-7.js → TimePicker-B6d2rAbX.js} +2 -2
- package/dist/{TimePicker-B_NegL-7.js.map → TimePicker-B6d2rAbX.js.map} +1 -1
- package/dist/{Toast-DQSbs3oA.js → Toast-CxXUulYN.js} +2 -2
- package/dist/{Toast-DQSbs3oA.js.map → Toast-CxXUulYN.js.map} +1 -1
- package/dist/{ZoomableSvg-DG9PnAm8.js → ZoomableSvg-CNIzRHKH.js} +4 -4
- package/dist/{ZoomableSvg-DG9PnAm8.js.map → ZoomableSvg-CNIzRHKH.js.map} +1 -1
- package/dist/{context-KxxeMHbR.js → context-BrNtMc1H.js} +3 -33
- package/dist/context-BrNtMc1H.js.map +1 -0
- package/dist/defaults-CTfvj2KB.js +34 -0
- package/dist/defaults-CTfvj2KB.js.map +1 -0
- package/dist/editors.d.ts +81 -9
- package/dist/editors.js +75 -12
- package/dist/editors.js.map +1 -1
- package/dist/flint.d.ts +15 -0
- package/dist/flint.js +212 -0
- package/dist/flint.js.map +1 -0
- package/dist/index.d.ts +361 -317
- package/dist/index.js +60 -57
- package/dist/internal/blocks/AIKit.js +1 -1
- package/dist/internal/blocks/AppShell.js +2 -2
- package/dist/internal/blocks/BrandEditor.js +1 -1
- package/dist/internal/blocks/ChartPanel.js +1 -1
- package/dist/internal/blocks/ClipboardButton.js +1 -1
- package/dist/internal/blocks/ColorInput.js +1 -1
- package/dist/internal/blocks/ColorModeSwitch.js +1 -1
- package/dist/internal/blocks/Command.js +1 -1
- package/dist/internal/blocks/CopyField.js +1 -1
- package/dist/internal/blocks/DateInput.js +1 -1
- package/dist/internal/blocks/DateRangeInput.js +1 -1
- package/dist/{DiagramSkeleton-lwBS2YBa.js → internal/blocks/DiagramShared/DiagramSkeleton.js} +3 -3
- package/dist/internal/blocks/DiagramShared/DiagramSkeleton.js.map +1 -0
- package/dist/internal/blocks/EmptyConfigurationActionCard.js +1 -1
- package/dist/internal/blocks/ErrorState.js +1 -1
- package/dist/internal/blocks/ExportMenu.js +3 -3
- package/dist/internal/blocks/Form/connectors/MultiComboboxField.js +56 -0
- package/dist/internal/blocks/Form/connectors/MultiComboboxField.js.map +1 -0
- package/dist/internal/blocks/Form.js +1 -1
- package/dist/internal/blocks/FormGroup.js +1 -1
- package/dist/internal/blocks/MultiActionButtonGroup.js +1 -1
- package/dist/internal/blocks/MultiCombobox.js +10 -4
- package/dist/internal/blocks/MultiCombobox.js.map +1 -1
- package/dist/internal/blocks/NumberInput.js +1 -1
- package/dist/internal/blocks/PageToolbar.js +1 -1
- package/dist/internal/blocks/PasswordInput.js +2 -2
- package/dist/internal/blocks/SearchInput.js +1 -1
- package/dist/internal/blocks/SearchInputWithNavigation.js +3 -3
- package/dist/internal/blocks/SectionNav.js +1 -1
- package/dist/internal/blocks/SplitButton.js +2 -2
- package/dist/internal/blocks/StatCard.js +1 -1
- package/dist/internal/blocks/TextInput.js +1 -1
- package/dist/internal/blocks/Textarea.js +1 -1
- package/dist/internal/blocks/TimeInput.js +3 -3
- package/dist/internal/components/Alert.js +1 -1
- package/dist/internal/components/AlertModal.js +1 -1
- package/dist/internal/components/Avatar.js +1 -1
- package/dist/internal/components/BrandLogo.js +1 -1
- package/dist/internal/components/Breadcrumb.js +1 -1
- package/dist/internal/components/Button.js +1 -1
- package/dist/internal/components/Card.js +1 -1
- package/dist/internal/components/Checkbox.js +1 -1
- package/dist/internal/components/Clipboard.js +1 -1
- package/dist/internal/components/CollapsiblePanel.js +1 -1
- package/dist/internal/components/Combobox.js +1 -1
- package/dist/internal/components/DatePicker.js +1 -1
- package/dist/internal/components/DateRangePicker.js +1 -1
- package/dist/internal/components/DropdownMenu.js +1 -1
- package/dist/internal/components/FileUpload.js +1 -1
- package/dist/internal/components/FullScreenModal.js +1 -1
- package/dist/internal/components/HoverCard.js +1 -1
- package/dist/internal/components/InputGroup.js +1 -1
- package/dist/internal/components/Kbd.js +1 -1
- package/dist/internal/components/Modal.js +1 -1
- package/dist/internal/components/Navbar.js +1 -1
- package/dist/internal/components/Pagination.js +1 -1
- package/dist/internal/components/Popconfirm.js +1 -1
- package/dist/internal/components/Popover.js +1 -1
- package/dist/internal/components/RadioGroup.js +1 -1
- package/dist/internal/components/Search.js +1 -1
- package/dist/internal/components/Select.js +1 -1
- package/dist/internal/components/Sheet.js +1 -1
- package/dist/internal/components/Sidebar.js +1 -1
- package/dist/internal/components/Slider.js +1 -1
- package/dist/internal/components/Switch.js +1 -1
- package/dist/internal/components/Tabs.js +1 -1
- package/dist/internal/components/ThemeProvider.js +3 -2
- package/dist/internal/components/TimePicker.js +1 -1
- package/dist/internal/components/Toast.js +2 -2
- package/dist/internal/components/Tooltip.js +1 -1
- package/dist/internal/components/Truncated.js +16 -8
- package/dist/internal/components/Truncated.js.map +1 -1
- package/dist/internal/components/ZoomableSvg.js +1 -1
- package/dist/internal/utils.js +1 -1
- package/dist/markdown-editor.js +7 -7
- package/dist/mermaid.js +1 -1
- package/dist/rjsf.d.ts +13 -1
- package/dist/rjsf.js +237 -177
- package/dist/rjsf.js.map +1 -1
- package/dist/{styles-DSUP_-9Z.js → styles-BAFscjSV.js} +4 -3
- package/dist/styles-BAFscjSV.js.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/svgTransforms-C9njt92h.js +89 -0
- package/dist/svgTransforms-C9njt92h.js.map +1 -0
- package/dist/testing.js +3 -2
- package/dist/testing.js.map +1 -1
- package/dist/{themeTokens-BNg98Mu9.js → themeTokens-7T1AFLhq.js} +13 -6
- package/dist/{themeTokens-BNg98Mu9.js.map → themeTokens-7T1AFLhq.js.map} +1 -1
- package/dist/{toast-CjkURw0M.js → toast-BweSoKn3.js} +3 -3
- package/dist/toast-BweSoKn3.js.map +1 -0
- package/dist/types-BPcAjMG0.d.ts +10 -0
- package/dist/{useColorSchemeState-CYqcUfSH.js → useColorSchemeState-BJEk6esG.js} +2 -2
- package/dist/{useColorSchemeState-CYqcUfSH.js.map → useColorSchemeState-BJEk6esG.js.map} +1 -1
- package/dist/{utils-D0c5VAyF.js → utils-B-g7d_Jb.js} +2 -2
- package/dist/{utils-D0c5VAyF.js.map → utils-B-g7d_Jb.js.map} +1 -1
- package/dist/vega.d.ts +46 -0
- package/dist/vega.js +26 -0
- package/dist/vega.js.map +1 -0
- package/dist/vegaTheme-FBXgAdHK.js +146 -0
- package/dist/vegaTheme-FBXgAdHK.js.map +1 -0
- package/package.json +29 -9
- package/src/styles.css +27 -4
- package/dist/AIKit-Dre37SJr.js.map +0 -1
- package/dist/AppShell-B5GQN6Zs.js.map +0 -1
- package/dist/Button-nzmDNS2q.js.map +0 -1
- package/dist/CodeEditor-BfQJfbhL.js.map +0 -1
- package/dist/Combobox-c_xBjf0P.js.map +0 -1
- package/dist/DiagramSkeleton-lwBS2YBa.js.map +0 -1
- package/dist/DropdownMenu-B6ZbYvaM.js.map +0 -1
- package/dist/FormGroup-S9mPNHKH.js.map +0 -1
- package/dist/MermaidDiagram-BB06gymm.js.map +0 -1
- package/dist/Navbar-t16usFZQ.js.map +0 -1
- package/dist/PageToolbar-0_1OBzaZ.js.map +0 -1
- package/dist/Popover-Ca0V6AD1.js.map +0 -1
- package/dist/Select-4YX38G5h.js.map +0 -1
- package/dist/constants-D6JcsD4_.d.ts +0 -41
- package/dist/context-KxxeMHbR.js.map +0 -1
- package/dist/styles-DSUP_-9Z.js.map +0 -1
- package/dist/toast-CjkURw0M.js.map +0 -1
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import { cn } from "./classNames-BzrkDnOD.js";
|
|
2
|
-
import { isMac, keyCodes } from "./utils-
|
|
3
|
-
import { useArgoDesign } from "./context-
|
|
2
|
+
import { isMac, keyCodes } from "./utils-B-g7d_Jb.js";
|
|
3
|
+
import { useArgoDesign } from "./context-BrNtMc1H.js";
|
|
4
4
|
import { escapeStringRegexp } from "./escapeStringRegexp-8MxP2knR.js";
|
|
5
|
-
import { ClipboardButton } from "./ClipboardButton-
|
|
5
|
+
import { ClipboardButton } from "./ClipboardButton-CQ6Aewpg.js";
|
|
6
6
|
import { HelpBlock } from "./internal/components/HelpBlock.js";
|
|
7
|
-
import { Kbd } from "./Kbd-
|
|
7
|
+
import { Kbd } from "./Kbd-D6LpR7G2.js";
|
|
8
8
|
import { useStableCallback } from "./internal/hooks/useStableCallback.js";
|
|
9
|
-
import { resolveToken, useThemeAttributes } from "./themeTokens-
|
|
9
|
+
import { resolveToken, useThemeAttributes } from "./themeTokens-7T1AFLhq.js";
|
|
10
10
|
import { useEffect, useLayoutEffect, useMemo, useRef } from "react";
|
|
11
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
12
|
import { autocompletion, completeAnyWord } from "@codemirror/autocomplete";
|
|
13
|
-
import { json, jsonParseLinter } from "@codemirror/lang-json";
|
|
14
|
-
import { linter } from "@codemirror/lint";
|
|
15
13
|
import { unifiedMergeView } from "@codemirror/merge";
|
|
16
14
|
import { Decoration, EditorView, ViewPlugin, keymap, placeholder, tooltips } from "@codemirror/view";
|
|
17
15
|
import CodeMirror, { EditorState } from "@uiw/react-codemirror";
|
|
18
16
|
import colors from "@keboola/tailwind-config/colors";
|
|
19
17
|
import { javascript } from "@codemirror/lang-javascript";
|
|
18
|
+
import { json, jsonParseLinter } from "@codemirror/lang-json";
|
|
20
19
|
import { python } from "@codemirror/lang-python";
|
|
21
20
|
import { MSSQL, MySQL, PLSQL, PostgreSQL, StandardSQL } from "@codemirror/lang-sql";
|
|
22
21
|
import { StreamLanguage } from "@codemirror/language";
|
|
23
22
|
import { r } from "@codemirror/legacy-modes/mode/r";
|
|
24
23
|
import { shell } from "@codemirror/legacy-modes/mode/shell";
|
|
25
24
|
import { toml } from "@codemirror/legacy-modes/mode/toml";
|
|
26
|
-
import {
|
|
27
|
-
import { githubLightInit } from "@uiw/codemirror-theme-github";
|
|
25
|
+
import { linter } from "@codemirror/lint";
|
|
26
|
+
import { githubDarkInit, githubLightInit } from "@uiw/codemirror-theme-github";
|
|
28
27
|
import { getSqlLanguageSupport } from "@keboola/codemirror-lang-sql";
|
|
29
28
|
import { simpleMode } from "@codemirror/legacy-modes/mode/simple-mode";
|
|
29
|
+
import { tags } from "@lezer/highlight";
|
|
30
30
|
import { Compartment, StateEffect, StateField } from "@codemirror/state";
|
|
31
31
|
//#region src/components/CodeEditor/ButtonToolbar.tsx
|
|
32
32
|
const ButtonToolbar = ({ value, children }) => {
|
|
@@ -344,6 +344,95 @@ const jsonnet = {
|
|
|
344
344
|
return null;
|
|
345
345
|
}
|
|
346
346
|
};
|
|
347
|
+
const DARK_GUTTER_ALPHA = "47";
|
|
348
|
+
/**
|
|
349
|
+
* The two diff fills, per scheme: light keeps the opaque pastel, dark tints the same `500` hue at
|
|
350
|
+
* low alpha over whatever token surface is behind it.
|
|
351
|
+
*
|
|
352
|
+
* - Its own module, importing nothing, so `MergeEditor` can share it without reaching into
|
|
353
|
+
* `CodeEditor/helpers.ts` and pulling the language modes and the CodeMirror runtime with it.
|
|
354
|
+
* - Shared by the unified merge wash in `helpers.ts` and `buildDiffHighlightTheme` in
|
|
355
|
+
* `MergeEditor/decorations.ts`, so the two views cannot drift apart on the alphas.
|
|
356
|
+
* - Callers pass the hue and the pastel; which one is used is this function's business.
|
|
357
|
+
*/
|
|
358
|
+
const buildDiffWash = (scheme) => {
|
|
359
|
+
const dark = scheme === "dark";
|
|
360
|
+
return {
|
|
361
|
+
line: (hue, pastel) => dark ? `${hue}29` : pastel,
|
|
362
|
+
gutter: (hue, pastel) => dark ? `${hue}${DARK_GUTTER_ALPHA}` : pastel
|
|
363
|
+
};
|
|
364
|
+
};
|
|
365
|
+
//#endregion
|
|
366
|
+
//#region src/components/CodeEditor/syntaxPalette.ts
|
|
367
|
+
/**
|
|
368
|
+
* The tag colours layered over the stock github palette, per colour scheme.
|
|
369
|
+
*
|
|
370
|
+
* - Its own module, importing nothing but the tag vocabulary and the ramps, so
|
|
371
|
+
* `scripts/contrast-audit.ts` can measure the palette without pulling the language modes and the
|
|
372
|
+
* CodeMirror runtime into a build script.
|
|
373
|
+
* - Later entries win over the stock rule for the same tag — both `githubLightInit` and
|
|
374
|
+
* `githubDarkInit` concatenate these after their own.
|
|
375
|
+
* - `foreground` is the caller's, because it is a live `--*` token rather than a ramp step: the
|
|
376
|
+
* theme passes `resolveToken('foreground')`, the audit passes the scheme's channel value.
|
|
377
|
+
* - Every ramp step here is a light/dark pair, and each pair is chosen against **two** surfaces —
|
|
378
|
+
* the theme's `background` setting is the page, but `variant="field"` paints on `muted`, which
|
|
379
|
+
* the theme never sees. Ratios in the comments are quoted `background` / `muted`.
|
|
380
|
+
*/
|
|
381
|
+
const buildSyntaxPalette = (scheme, foreground) => {
|
|
382
|
+
const dark = scheme === "dark";
|
|
383
|
+
return [
|
|
384
|
+
{
|
|
385
|
+
tag: [
|
|
386
|
+
tags.name,
|
|
387
|
+
tags.special(tags.string),
|
|
388
|
+
tags.bracket
|
|
389
|
+
],
|
|
390
|
+
color: foreground
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
tag: tags.standard(tags.name),
|
|
394
|
+
color: dark ? colors.purple[300] : colors.purple[600]
|
|
395
|
+
},
|
|
396
|
+
{
|
|
397
|
+
tag: tags.special(tags.name),
|
|
398
|
+
color: dark ? colors.cyan[300] : colors.cyan[800]
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
tag: tags.string,
|
|
402
|
+
color: dark ? colors.warning[300] : colors.warning[800]
|
|
403
|
+
},
|
|
404
|
+
...dark ? [] : [
|
|
405
|
+
{
|
|
406
|
+
tag: [
|
|
407
|
+
tags.keyword,
|
|
408
|
+
tags.typeName,
|
|
409
|
+
tags.typeOperator
|
|
410
|
+
],
|
|
411
|
+
color: colors.error[550]
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
tag: tags.comment,
|
|
415
|
+
color: colors.neutral[500]
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
tag: tags.quote,
|
|
419
|
+
color: colors.green[900]
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
tag: tags.invalid,
|
|
423
|
+
color: colors.error[700]
|
|
424
|
+
}
|
|
425
|
+
],
|
|
426
|
+
...dark ? [{
|
|
427
|
+
tag: [
|
|
428
|
+
tags.escape,
|
|
429
|
+
tags.url,
|
|
430
|
+
tags.link
|
|
431
|
+
],
|
|
432
|
+
color: colors.blue[300]
|
|
433
|
+
}] : []
|
|
434
|
+
];
|
|
435
|
+
};
|
|
347
436
|
//#endregion
|
|
348
437
|
//#region src/components/CodeEditor/helpers.ts
|
|
349
438
|
const LANGUAGE_MODES = [
|
|
@@ -368,44 +457,61 @@ const LANGUAGE_MODES = [
|
|
|
368
457
|
const isLanguageMode = (mode) => LANGUAGE_MODES.includes(mode);
|
|
369
458
|
const READ_ONLY_EDITOR = "&.cm-editor:has(.cm-content[contenteditable=\"false\"])";
|
|
370
459
|
const EDITABLE_EDITOR = "&.cm-editor:has(.cm-content[contenteditable=\"true\"])";
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
}
|
|
460
|
+
/**
|
|
461
|
+
* Editor chrome and the unified merge (diff) wash.
|
|
462
|
+
*
|
|
463
|
+
* - Chrome surfaces (selection, read-only wash) resolve from live `--*` tokens, so they re-skin
|
|
464
|
+
* with brand and colour scheme. Fallback channels mirror the light-mode token values for SSR /
|
|
465
|
+
* no-provider parity.
|
|
466
|
+
* - Diff colours stay categorical — fixed across brands, because added/removed is meaning, not
|
|
467
|
+
* chrome — but each is a light/dark pair from `buildDiffWash`, shared with
|
|
468
|
+
* `buildDiffHighlightTheme` in `MergeEditor/decorations.ts`.
|
|
469
|
+
* - This wash reaches only `CodeEditor`'s *unified* merge view — the one a `previousValue` turns on.
|
|
470
|
+
* `MergePane` builds its own theme from scratch.
|
|
471
|
+
*/
|
|
472
|
+
const buildBaseThemeStyles = (scheme) => {
|
|
473
|
+
const { line, gutter } = buildDiffWash(scheme);
|
|
474
|
+
const dark = scheme === "dark";
|
|
475
|
+
return {
|
|
476
|
+
"*": { lineHeight: "20px" },
|
|
477
|
+
"*::selection": {
|
|
478
|
+
backgroundColor: resolveToken("primary", "31 143 255"),
|
|
479
|
+
color: `${resolveToken("primary-foreground", "255 255 255")} !important`
|
|
480
|
+
},
|
|
481
|
+
[READ_ONLY_EDITOR]: { backgroundColor: dark ? resolveToken("muted", "38 38 45") : resolveToken("secondary", "226 232 240") },
|
|
482
|
+
[`${READ_ONLY_EDITOR} .cm-gutters`]: { backgroundColor: resolveToken("border", "229 231 235") },
|
|
483
|
+
"&.cm-editor .cm-scroller": { overflowAnchor: "none" },
|
|
484
|
+
"&.cm-editor, &.cm-editor .cm-scroller": {
|
|
485
|
+
minHeight: "100%",
|
|
486
|
+
flexGrow: 1,
|
|
487
|
+
alignItems: "stretch !important",
|
|
488
|
+
outline: "none"
|
|
489
|
+
},
|
|
490
|
+
".cm-gutter.cm-foldGutter": { display: "none !important" },
|
|
491
|
+
".cm-gutter.cm-lineNumbers": {
|
|
492
|
+
paddingLeft: "20px",
|
|
493
|
+
paddingRight: "6px"
|
|
494
|
+
},
|
|
495
|
+
".cm-gutters": { height: "auto" },
|
|
496
|
+
"&[class*=\"cm-merge-\"] .cm-deletedLine": { backgroundColor: line(colors.error[500], colors.error[100]) },
|
|
497
|
+
"&[class*=\"cm-merge-\"] .cm-changedLine": { backgroundColor: line(colors.green[500], colors.green[100]) },
|
|
498
|
+
"&[class*=\"cm-merge-\"] .cm-deletedLineGutter": { backgroundColor: gutter(colors.error[500], colors.error[200]) },
|
|
499
|
+
"&[class*=\"cm-merge-\"] .cm-changedLineGutter": { backgroundColor: gutter(colors.green[500], colors.green[200]) },
|
|
500
|
+
"&[class*=\"cm-merge-\"] .cm-deletedText": { background: gutter(colors.error[500], colors.error[200]) },
|
|
501
|
+
"&[class*=\"cm-merge-\"] .cm-changedText": { background: gutter(colors.green[500], colors.green[200]) },
|
|
502
|
+
"&[class*=\"cm-merge-\"]": { backgroundColor: `${resolveToken("background", "249 250 251")} !important` },
|
|
503
|
+
"&[class*=\"cm-merge-\"] .cm-gutters": { backgroundColor: `${resolveToken("muted", "241 245 249")} !important` },
|
|
504
|
+
".cm-changeGutter": {
|
|
505
|
+
position: "absolute",
|
|
506
|
+
zIndex: -1,
|
|
507
|
+
width: "100%",
|
|
508
|
+
paddingLeft: 0
|
|
509
|
+
},
|
|
510
|
+
"&[class*=\"cm-merge-\"] .cm-changedLine,&[class*=\"cm-merge-\"] .cm-line, &[class*=\"cm-merge-\"] .cm-deletedChunk": { paddingLeft: 0 }
|
|
511
|
+
};
|
|
512
|
+
};
|
|
408
513
|
const ALWAYS_OFF = {
|
|
514
|
+
autocompletion: false,
|
|
409
515
|
drawSelection: false,
|
|
410
516
|
foldGutter: false,
|
|
411
517
|
foldKeymap: false,
|
|
@@ -424,41 +530,50 @@ const buildBasicSetup = (readOnly) => ({
|
|
|
424
530
|
highlightSelectionMatches: false
|
|
425
531
|
} : null
|
|
426
532
|
});
|
|
427
|
-
|
|
533
|
+
/**
|
|
534
|
+
* The syntax theme, per colour scheme.
|
|
535
|
+
*
|
|
536
|
+
* - The stock github palette is picked by scheme: `githubDarkInit` under dark, `githubLightInit`
|
|
537
|
+
* otherwise. One palette cannot serve both — the light set scores 1.14:1 to 4.31:1 on the two
|
|
538
|
+
* dark surfaces, so 10 of its 11 colours failed AA there (UT-5194).
|
|
539
|
+
* - `githubDarkInit` also passes `dark: true` to `EditorView.theme`, which sets the
|
|
540
|
+
* `EditorView.darkTheme` facet. That is what makes the `&dark` rules apply — CodeMirror's own
|
|
541
|
+
* base theme (cursor, selection layer, panels, buttons) and ours (`search.ts`,
|
|
542
|
+
* `highlighting.ts`) both key off it, so they follow the scheme without a second signal.
|
|
543
|
+
* - Chrome (surface, gutter, selection, caret) resolves from live `--*` tokens, so it re-skins with
|
|
544
|
+
* the brand too. Fallback channels mirror the light-mode token values, for SSR and jsdom.
|
|
545
|
+
* - `caret` and `selectionMatch` are pinned because the two initialisers disagree on them, and the
|
|
546
|
+
* branch would otherwise change values nothing here chose. The caret follows `foreground`; before
|
|
547
|
+
* the facet was set, CodeMirror's own default painted it black on the dark page, so it was
|
|
548
|
+
* invisible. `selectionMatch` is a 10% `primary` tint, which beats each initialiser's own value
|
|
549
|
+
* on the token it hurts most: 3.82:1 against the light default's 3.29, 5.40:1 against the dark
|
|
550
|
+
* default's 3.57. Any occurrence wash costs contrast — this is the cheapest one, and it is the
|
|
551
|
+
* same in both schemes.
|
|
552
|
+
* - `styles` comes from `buildSyntaxPalette`, which lives apart so the audit script can measure it.
|
|
553
|
+
*
|
|
554
|
+
* Those overrides exist because the github theme paints every `name`-family tag one colour, and in
|
|
555
|
+
* SQL nearly every token is a name — identifiers, function calls and `$variables` all drowned
|
|
556
|
+
* together, and a keyword that doubles as a function (`create or REPLACE`) read as a value
|
|
557
|
+
* (UT-5024). Instead: identifiers and brackets carry no colour, functions and special vars get
|
|
558
|
+
* their own hues, and amber is unique to string literals — in JSON that shifts string values from
|
|
559
|
+
* navy to amber, the one visible non-SQL change.
|
|
560
|
+
*/
|
|
561
|
+
const buildCustomTheme = (scheme) => {
|
|
428
562
|
const foreground = resolveToken("foreground", "30 41 59");
|
|
429
|
-
return githubLightInit({
|
|
563
|
+
return (scheme === "dark" ? githubDarkInit : githubLightInit)({
|
|
430
564
|
settings: {
|
|
431
565
|
fontFamily: `'SFMono-Regular', 'Menlo', 'Monaco', 'Consolas', 'Liberation Mono', 'Courier New'`,
|
|
432
566
|
background: resolveToken("background", "249 250 251"),
|
|
433
567
|
foreground,
|
|
568
|
+
caret: foreground,
|
|
434
569
|
gutterBackground: resolveToken("muted", "241 245 249"),
|
|
435
570
|
gutterForeground: resolveToken("muted-foreground", "100 116 139"),
|
|
436
571
|
gutterBorder: "transparent",
|
|
437
572
|
lineHighlight: "transparent",
|
|
438
|
-
selection: resolveToken("primary", "31 143 255")
|
|
573
|
+
selection: resolveToken("primary", "31 143 255"),
|
|
574
|
+
selectionMatch: resolveToken("primary", "31 143 255", .1)
|
|
439
575
|
},
|
|
440
|
-
styles:
|
|
441
|
-
{
|
|
442
|
-
tag: [
|
|
443
|
-
tags.name,
|
|
444
|
-
tags.special(tags.string),
|
|
445
|
-
tags.bracket
|
|
446
|
-
],
|
|
447
|
-
color: foreground
|
|
448
|
-
},
|
|
449
|
-
{
|
|
450
|
-
tag: tags.standard(tags.name),
|
|
451
|
-
color: colors.purple[600]
|
|
452
|
-
},
|
|
453
|
-
{
|
|
454
|
-
tag: tags.special(tags.name),
|
|
455
|
-
color: colors.cyan[700]
|
|
456
|
-
},
|
|
457
|
-
{
|
|
458
|
-
tag: tags.string,
|
|
459
|
-
color: colors.warning[700]
|
|
460
|
-
}
|
|
461
|
-
]
|
|
576
|
+
styles: buildSyntaxPalette(scheme, foreground)
|
|
462
577
|
});
|
|
463
578
|
};
|
|
464
579
|
const getLanguageMode = (mode) => {
|
|
@@ -487,6 +602,32 @@ const getLanguageMode = (mode) => {
|
|
|
487
602
|
}
|
|
488
603
|
};
|
|
489
604
|
const shouldLintJson = (mode, readOnly) => mode === "application/json" && !readOnly;
|
|
605
|
+
/**
|
|
606
|
+
* Wraps a lint source so a blank document produces no diagnostics.
|
|
607
|
+
*
|
|
608
|
+
* `jsonParseLinter` reports "Unexpected end of input" for empty content, which is right for a file and
|
|
609
|
+
* wrong for an *optional* form field: it starts empty, and clearing it is how its value is removed.
|
|
610
|
+
* Left unwrapped, every such field opens with a red gutter marker contradicting its own validation —
|
|
611
|
+
* `CodeEditorField` puts six of them on one screen.
|
|
612
|
+
*
|
|
613
|
+
* Exported for its test: the wrapper is the behaviour worth pinning, and it needs no editor to exercise.
|
|
614
|
+
*/
|
|
615
|
+
const skipBlankDocument = (source) => (view) => view.state.doc.toString().trim() === "" ? [] : source(view);
|
|
616
|
+
/**
|
|
617
|
+
* The JSON linter, optionally blind to a blank document.
|
|
618
|
+
*
|
|
619
|
+
* - `allowBlankDocument` is opt-in, and only `CodeEditorField` opts in (from `!required`). Suppressing
|
|
620
|
+
* the marker by default would break callers that treat empty as invalid *and* say so nowhere else:
|
|
621
|
+
* `ex-generic/JsonConfiguration.tsx`, `flows/TaskParamsModalContent.tsx` and
|
|
622
|
+
* `stream/PayloadTest.tsx` all gate their button on `isValidJsonConfig`, which is `false` for `''`,
|
|
623
|
+
* with no `disabledReason` — so the gutter marker is the only thing explaining a dead button.
|
|
624
|
+
* - Not derivable from `variant`: `ex-generic/FunctionControl.tsx` is `variant="field"` and empty is
|
|
625
|
+
* an error there too. Whether blank is valid is the *field's* contract, not the control's shape.
|
|
626
|
+
*/
|
|
627
|
+
const buildJsonLinter = (allowBlankDocument) => {
|
|
628
|
+
const source = jsonParseLinter();
|
|
629
|
+
return linter(allowBlankDocument ? skipBlankDocument(source) : source);
|
|
630
|
+
};
|
|
490
631
|
//#endregion
|
|
491
632
|
//#region src/components/CodeEditor/editorChrome.ts
|
|
492
633
|
/**
|
|
@@ -497,22 +638,32 @@ const shouldLintJson = (mode, readOnly) => mode === "application/json" && !readO
|
|
|
497
638
|
* variant does. No semantic token holds that grey, and the nearest one
|
|
498
639
|
* (`--muted`) is a few points off — which is the "almost, but not quite, the
|
|
499
640
|
* input next to it" mismatch this preset exists to remove.
|
|
641
|
+
*
|
|
642
|
+
* That ramp is fixed, so the legacy preset needs its own scheme pair — a legacy brand and the dark
|
|
643
|
+
* scheme are independent choices, and `neutral[100]` under dark is a light slab: `foreground` on it
|
|
644
|
+
* is 1.09:1 and the darkest syntax colour 2.69:1. Dark mirrors the same two steps from the other
|
|
645
|
+
* end of the ramp (`800` / `900`, 5.00:1 and 6.14:1 for that colour).
|
|
500
646
|
*/
|
|
501
|
-
const buildInputChrome = (isArgo) =>
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
647
|
+
const buildInputChrome = (isArgo, scheme) => {
|
|
648
|
+
const dark = scheme === "dark";
|
|
649
|
+
const legacySurface = dark ? colors.neutral[800] : colors.neutral[100];
|
|
650
|
+
const legacyReadOnly = dark ? colors.neutral[900] : colors.neutral[150];
|
|
651
|
+
return {
|
|
652
|
+
surface: isArgo ? resolveToken("muted", "241 245 249") : legacySurface,
|
|
653
|
+
borderColor: isArgo ? resolveToken("input", "203 213 225") : legacySurface,
|
|
654
|
+
readOnlySurface: isArgo ? resolveToken("muted", "241 245 249") : legacyReadOnly,
|
|
655
|
+
readOnlyBorderColor: isArgo ? resolveToken("input", "203 213 225") : legacyReadOnly,
|
|
656
|
+
hoverBorderColor: null,
|
|
657
|
+
focusBorderColor: isArgo ? resolveToken("primary", "37 99 235") : resolveToken("ring", "31 143 255"),
|
|
658
|
+
focusRing: `0 0 0 4px ${resolveToken("ring", "31 143 255", isArgo ? .5 : .3)}`,
|
|
659
|
+
radius: isArgo ? "var(--radius-lg, 0.25rem)" : "0.25rem",
|
|
660
|
+
paddingY: isArgo ? "3px" : "5px",
|
|
661
|
+
paddingX: {
|
|
662
|
+
left: "10px",
|
|
663
|
+
right: "14px"
|
|
664
|
+
}
|
|
665
|
+
};
|
|
666
|
+
};
|
|
516
667
|
/** The SQL workspace's notebook cell: a white canvas, not a form control. */
|
|
517
668
|
const buildCanvasChrome = () => ({
|
|
518
669
|
surface: resolveToken("card", "255 255 255"),
|
|
@@ -633,11 +784,28 @@ const searchViewPlugin = ViewPlugin.fromClass(class {
|
|
|
633
784
|
if (state.selectedMatchIndex === void 0) this.lastSelectedIndex = void 0;
|
|
634
785
|
}
|
|
635
786
|
});
|
|
787
|
+
/**
|
|
788
|
+
* Match and current-match fills, per colour scheme.
|
|
789
|
+
*
|
|
790
|
+
* - `&dark` is how a *static* base theme follows the scheme, without becoming a
|
|
791
|
+
* `useThemedExtension` builder and a second entry in its never-evicting cache. It applies
|
|
792
|
+
* whenever the `EditorView.darkTheme` facet is set — see `buildBaseThemeStyles`' callers, which
|
|
793
|
+
* set it explicitly.
|
|
794
|
+
* - Light text is `blue[700]`: 5.42:1 on the fill, and 6.29:1 for white on the current match.
|
|
795
|
+
* - Dark tints `blue[500]` for the plain match, with `blue[200]` text: 11.10:1 on the page surface,
|
|
796
|
+
* 8.86:1 on the `variant="field"` one. The current match keeps a solid `blue[500]` and takes
|
|
797
|
+
* `neutral[900]` as its text (5.78:1) — white on it is 2.55:1, since the token that reads as
|
|
798
|
+
* "strong" in light is a light colour.
|
|
799
|
+
*/
|
|
636
800
|
const searchTheme = EditorView.baseTheme({
|
|
637
801
|
".cm-searchMatch": { backgroundColor: colors.blue[100] },
|
|
638
|
-
".cm-searchMatch > span": { color: `${colors.blue[
|
|
639
|
-
".cm-searchMatch-selected": { backgroundColor: colors.blue[
|
|
640
|
-
".cm-searchMatch-selected > span": { color: `${colors.white} !important` }
|
|
802
|
+
".cm-searchMatch > span": { color: `${colors.blue[700]} !important` },
|
|
803
|
+
".cm-searchMatch-selected": { backgroundColor: colors.blue[700] },
|
|
804
|
+
".cm-searchMatch-selected > span": { color: `${colors.white} !important` },
|
|
805
|
+
"&dark .cm-searchMatch": { backgroundColor: `${colors.blue[500]}29` },
|
|
806
|
+
"&dark .cm-searchMatch > span": { color: `${colors.blue[200]} !important` },
|
|
807
|
+
"&dark .cm-searchMatch-selected": { backgroundColor: colors.blue[500] },
|
|
808
|
+
"&dark .cm-searchMatch-selected > span": { color: `${colors.neutral[900]} !important` }
|
|
641
809
|
});
|
|
642
810
|
function searchExtension() {
|
|
643
811
|
return [
|
|
@@ -817,10 +985,27 @@ const useVariableCompletion = (variables = []) => useStableCallback(completeVari
|
|
|
817
985
|
//#endregion
|
|
818
986
|
//#region src/components/CodeEditor/CodeEditor.tsx
|
|
819
987
|
const emptyObject = {};
|
|
820
|
-
const CodeEditor = ({ value, previousValue, onChange, variant = "plain", mode = "application/json", placeholder: placeholder$1 = "", ariaLabel, searchQuery, searchMatchIndex, readOnly = false, inputLocked = false, autocompletions, completionSource, variables, extraKeys = emptyObject, withToggleCommentHint = false, withAutofocus = false, withLineNumbers = true, withLineWrapping = true, withCollapseUnchanged = false, withCopyButton = false, completeAny = false, help = null, helpPostfix = null, renderAdditionalButtons, className }) => {
|
|
988
|
+
const CodeEditor = ({ value, previousValue, onChange, variant = "plain", mode = "application/json", placeholder: placeholder$1 = "", ariaLabel, ariaLabelledBy, ariaDescribedBy, ariaInvalid, ariaRequired, allowBlankDocument = false, onBlur, searchQuery, searchMatchIndex, readOnly = false, inputLocked = false, autocompletions, completionSource, variables, withCompletions = true, extraKeys = emptyObject, withToggleCommentHint = false, withAutofocus = false, withLineNumbers = true, withLineWrapping = true, withCollapseUnchanged = false, withCopyButton = false, completeAny = false, help = null, helpPostfix = null, renderAdditionalButtons, className }) => {
|
|
821
989
|
const handleChange = useStableCallback((next) => onChange?.(next));
|
|
990
|
+
const handleBlur = useStableCallback(() => onBlur?.());
|
|
822
991
|
const withSearch = searchQuery !== void 0;
|
|
992
|
+
const withBlur = onBlur !== void 0;
|
|
823
993
|
const editorRef = useRef(null);
|
|
994
|
+
const contentAria = useMemo(() => {
|
|
995
|
+
const attributes = {};
|
|
996
|
+
if (ariaLabel !== void 0) attributes["aria-label"] = ariaLabel;
|
|
997
|
+
if (ariaLabelledBy !== void 0) attributes["aria-labelledby"] = ariaLabelledBy;
|
|
998
|
+
if (ariaDescribedBy !== void 0) attributes["aria-describedby"] = ariaDescribedBy;
|
|
999
|
+
if (ariaInvalid !== void 0) attributes["aria-invalid"] = String(ariaInvalid);
|
|
1000
|
+
if (ariaRequired !== void 0) attributes["aria-required"] = String(ariaRequired);
|
|
1001
|
+
return Object.keys(attributes).length > 0 ? attributes : null;
|
|
1002
|
+
}, [
|
|
1003
|
+
ariaLabel,
|
|
1004
|
+
ariaLabelledBy,
|
|
1005
|
+
ariaDescribedBy,
|
|
1006
|
+
ariaInvalid,
|
|
1007
|
+
ariaRequired
|
|
1008
|
+
]);
|
|
824
1009
|
useEffect(() => {
|
|
825
1010
|
const view = editorRef.current?.view;
|
|
826
1011
|
if (view && withSearch) updateSearch(view, searchQuery, searchMatchIndex);
|
|
@@ -843,16 +1028,16 @@ const CodeEditor = ({ value, previousValue, onChange, variant = "plain", mode =
|
|
|
843
1028
|
const customTheme = useThemedExtension("editor:syntax", buildCustomTheme);
|
|
844
1029
|
const isArgo = useArgoDesign();
|
|
845
1030
|
const isField = variant === "field";
|
|
846
|
-
const baseTheme = useThemedExtension(isField ? `code-editor:field:${isArgo ? "argo" : "legacy"}` : "code-editor:chrome", () => EditorView.theme({
|
|
847
|
-
...buildBaseThemeStyles(),
|
|
848
|
-
...isField ? buildChromeStyles(buildInputChrome(isArgo)) : null
|
|
849
|
-
}));
|
|
1031
|
+
const baseTheme = useThemedExtension(isField ? `code-editor:field:${isArgo ? "argo" : "legacy"}` : "code-editor:chrome", (scheme) => EditorView.theme({
|
|
1032
|
+
...buildBaseThemeStyles(scheme),
|
|
1033
|
+
...isField ? buildChromeStyles(buildInputChrome(isArgo, scheme)) : null
|
|
1034
|
+
}, { dark: scheme === "dark" }));
|
|
850
1035
|
const commonExtensions = useMemo(() => {
|
|
851
1036
|
const callerCompletions = completionSource ?? (completeAny ? completeAnyWord : autocompletions?.length ? autocompletions : null);
|
|
852
1037
|
const completionEntries = [...callerCompletions ? [{ autocomplete: callerCompletions }] : [], { autocomplete: variableCompletion }];
|
|
853
1038
|
return [
|
|
854
1039
|
getLanguageMode(mode),
|
|
855
|
-
shouldLintJson(mode, readOnly) ?
|
|
1040
|
+
shouldLintJson(mode, readOnly) ? buildJsonLinter(allowBlankDocument) : [],
|
|
856
1041
|
withLineWrapping ? EditorView.lineWrapping : [],
|
|
857
1042
|
EditorState.languageData.of(() => completionEntries),
|
|
858
1043
|
keymap.of(boundKeys.map((key) => ({
|
|
@@ -862,8 +1047,9 @@ const CodeEditor = ({ value, previousValue, onChange, variant = "plain", mode =
|
|
|
862
1047
|
return true;
|
|
863
1048
|
}
|
|
864
1049
|
}))),
|
|
865
|
-
readOnly ? [] : [autocompletion()],
|
|
866
|
-
|
|
1050
|
+
readOnly || !withCompletions ? [] : [autocompletion()],
|
|
1051
|
+
contentAria ? EditorView.contentAttributes.of(contentAria) : [],
|
|
1052
|
+
withBlur ? EditorView.domEventHandlers({ blur: handleBlur }) : [],
|
|
867
1053
|
withSearch ? searchExtension() : [],
|
|
868
1054
|
tooltipLayer,
|
|
869
1055
|
baseTheme
|
|
@@ -873,12 +1059,16 @@ const CodeEditor = ({ value, previousValue, onChange, variant = "plain", mode =
|
|
|
873
1059
|
completionSource,
|
|
874
1060
|
variableCompletion,
|
|
875
1061
|
completeAny,
|
|
1062
|
+
withCompletions,
|
|
876
1063
|
boundKeys,
|
|
877
1064
|
mode,
|
|
878
1065
|
readOnly,
|
|
1066
|
+
allowBlankDocument,
|
|
879
1067
|
withLineWrapping,
|
|
880
1068
|
baseTheme,
|
|
881
|
-
|
|
1069
|
+
contentAria,
|
|
1070
|
+
withBlur,
|
|
1071
|
+
handleBlur,
|
|
882
1072
|
withSearch,
|
|
883
1073
|
tooltipLayer
|
|
884
1074
|
]);
|
|
@@ -947,6 +1137,6 @@ const CodeEditor = ({ value, previousValue, onChange, variant = "plain", mode =
|
|
|
947
1137
|
});
|
|
948
1138
|
};
|
|
949
1139
|
//#endregion
|
|
950
|
-
export { CodeEditor, LANGUAGE_MODES, buildBaseThemeStyles, buildBasicSetup, buildCanvasChrome, buildChromeStyles, buildCustomTheme, isLanguageMode, searchExtension, updateSearch, useThemedExtension, useTooltipsExtension, useVariableCompletion };
|
|
1140
|
+
export { CodeEditor, LANGUAGE_MODES, buildBaseThemeStyles, buildBasicSetup, buildCanvasChrome, buildChromeStyles, buildCustomTheme, buildDiffWash, isLanguageMode, searchExtension, updateSearch, useThemedExtension, useTooltipsExtension, useVariableCompletion };
|
|
951
1141
|
|
|
952
|
-
//# sourceMappingURL=CodeEditor-
|
|
1142
|
+
//# sourceMappingURL=CodeEditor-CUse8znx.js.map
|