@marimo-team/islands 0.21.1-dev15 → 0.21.1-dev18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/{Combination-Dk6JxauT.js → Combination-BBPQRrDo.js} +1 -1
  2. package/dist/{ConnectedDataExplorerComponent-Bgr96_Mw.js → ConnectedDataExplorerComponent-D0GoOd_c.js} +10 -10
  3. package/dist/{any-language-editor-BIj11a2e.js → any-language-editor-DIUWKyeN.js} +4 -4
  4. package/dist/{button-DQpBib29.js → button-BKkuUpZh.js} +8 -0
  5. package/dist/{check-DpqPQmzz.js → check-Diwc5emq.js} +1 -1
  6. package/dist/{copy-BkBF0Xgk.js → copy-DIK6DiIA.js} +2 -2
  7. package/dist/{dist-WIWVvdBh.js → dist-C0Rnbr-_.js} +2 -2
  8. package/dist/{error-banner-BctofTCP.js → error-banner-Dmi5ujan.js} +2 -2
  9. package/dist/{esm-BBkPJL8N.js → esm-BxfaUFPY.js} +4 -4
  10. package/dist/{glide-data-editor-DqxJOnJk.js → glide-data-editor-pZyd9UJ_.js} +6 -6
  11. package/dist/{label-BLDcDYdI.js → label-BbpGrh4j.js} +4 -4
  12. package/dist/{loader-V1UqqlAy.js → loader-CABJs6GU.js} +1 -1
  13. package/dist/main.js +24 -24
  14. package/dist/{mermaid-DkdSmFY8.js → mermaid-CrKqsE2j.js} +5 -5
  15. package/dist/{slides-component-DwvL_HJi.js → slides-component-GkilRW21.js} +2 -2
  16. package/dist/{spec-CbYkiXG3.js → spec-Bfvf9Hre.js} +4 -4
  17. package/dist/style.css +1 -1
  18. package/dist/{tooltip-SPkubVH3.js → tooltip-CKG75XQa.js} +3 -3
  19. package/dist/{types-0FB-N7AA.js → types-CGc7peZV.js} +6 -6
  20. package/dist/{useAsyncData-D7-oahg5.js → useAsyncData-CEjJxwFB.js} +1 -1
  21. package/dist/{useDeepCompareMemoize-CJr2MRe6.js → useDeepCompareMemoize-BWUwfh37.js} +4 -4
  22. package/dist/{useIframeCapabilities-DFGZKWkO.js → useIframeCapabilities-OQaMKgZl.js} +1 -1
  23. package/dist/{useTheme-D0rdoMBF.js → useTheme-CPybHVFN.js} +2 -2
  24. package/dist/{vega-component-Cq-KtS_2.js → vega-component-CuPTCRp5.js} +8 -8
  25. package/package.json +1 -1
  26. package/src/components/editor/actions/useCellActionButton.tsx +38 -29
  27. package/src/components/editor/cell/code/cell-editor.tsx +9 -0
  28. package/src/core/codemirror/__tests__/setup.test.ts +1 -0
  29. package/src/core/codemirror/cells/state.ts +1 -0
  30. package/src/core/codemirror/extensions.ts +20 -0
  31. package/src/core/hotkeys/hotkeys.ts +8 -0
  32. package/src/css/md.css +4 -0
@@ -1,9 +1,9 @@
1
1
  import { s as __toESM } from "./chunk-BNovOVIE.js";
2
2
  import { t as require_react } from "./react-Bs6Z0kvn.js";
3
3
  import { t as require_compiler_runtime } from "./compiler-runtime-B_OLMU9S.js";
4
- import { a as Content, i as Arrow, o as Root2, r as Anchor, s as createPopperScope, t as Root } from "./dist-WIWVvdBh.js";
5
- import { m as useComposedRefs, y as cn } from "./button-DQpBib29.js";
6
- import { _t as createContextScope, at as useControllableState, ct as useId, ft as Primitive, ht as createSlottable, it as StyleNamespace, nt as withSmartCollisionBoundary, ot as Presence, st as Portal, tt as withFullScreenAsRoot, ut as DismissableLayer, vt as composeEventHandlers } from "./Combination-Dk6JxauT.js";
4
+ import { a as Content, i as Arrow, o as Root2, r as Anchor, s as createPopperScope, t as Root } from "./dist-C0Rnbr-_.js";
5
+ import { m as useComposedRefs, y as cn } from "./button-BKkuUpZh.js";
6
+ import { _t as createContextScope, at as useControllableState, ct as useId, ft as Primitive, ht as createSlottable, it as StyleNamespace, nt as withSmartCollisionBoundary, ot as Presence, st as Portal, tt as withFullScreenAsRoot, ut as DismissableLayer, vt as composeEventHandlers } from "./Combination-BBPQRrDo.js";
7
7
  import { t as require_jsx_runtime } from "./jsx-runtime-CTBg5pdT.js";
8
8
  var import_react = /* @__PURE__ */ __toESM(require_react(), 1), import_jsx_runtime = /* @__PURE__ */ __toESM(require_jsx_runtime(), 1), [createTooltipContext, createTooltipScope] = createContextScope("Tooltip", [createPopperScope]), usePopperScope = createPopperScope(), PROVIDER_NAME = "TooltipProvider", DEFAULT_DELAY_DURATION = 700, TOOLTIP_OPEN = "tooltip.open", [TooltipProviderContextProvider, useTooltipProviderContext] = createTooltipContext(PROVIDER_NAME), TooltipProvider$1 = (t) => {
9
9
  let { __scopeTooltip: k, delayDuration: A = DEFAULT_DELAY_DURATION, skipDelayDuration: j = 300, disableHoverableContent: M = false, children: N } = t, P = import_react.useRef(true), F = import_react.useRef(false), I = import_react.useRef(0);
@@ -5,17 +5,17 @@ var _a;
5
5
  import { s as __toESM, t as __commonJSMin } from "./chunk-BNovOVIE.js";
6
6
  import { t as require_react } from "./react-Bs6Z0kvn.js";
7
7
  import { t as require_compiler_runtime } from "./compiler-runtime-B_OLMU9S.js";
8
- import { a as Content, i as Arrow, l as createLucideIcon, o as Root2$1, r as Anchor, s as createPopperScope } from "./dist-WIWVvdBh.js";
9
- import { t as Check } from "./check-DpqPQmzz.js";
10
- import { A as $a916eb452884faea$export$b7a616150fdb9f44, C as useDirection, F as $b5e257d569688ac6$export$619500959fc48b26, I as X, L as ChevronUp, M as $18f2051aff69b9bf$export$43bb16f9c6d9e3f7, R as ChevronDown, _ as menuItemVariants, b as menuSubTriggerVariants, g as menuControlVariants, h as menuControlCheckVariants, j as $488c6ddbf4ef74c2$export$cc77c4ff7e8673c5, k as upperFirst_default, m as menuContentCommon, v as menuLabelVariants, w as createCollection, y as menuSeparatorVariants } from "./label-BLDcDYdI.js";
8
+ import { a as Content, i as Arrow, l as createLucideIcon, o as Root2$1, r as Anchor, s as createPopperScope } from "./dist-C0Rnbr-_.js";
9
+ import { t as Check } from "./check-Diwc5emq.js";
10
+ import { A as $a916eb452884faea$export$b7a616150fdb9f44, C as useDirection, F as $b5e257d569688ac6$export$619500959fc48b26, I as X, L as ChevronUp, M as $18f2051aff69b9bf$export$43bb16f9c6d9e3f7, R as ChevronDown, _ as menuItemVariants, b as menuSubTriggerVariants, g as menuControlVariants, h as menuControlCheckVariants, j as $488c6ddbf4ef74c2$export$cc77c4ff7e8673c5, k as upperFirst_default, m as menuContentCommon, v as menuLabelVariants, w as createCollection, y as menuSeparatorVariants } from "./label-BbpGrh4j.js";
11
11
  import { n as clsx_default } from "./clsx-D2KVTYnW.js";
12
- import { g as Logger, h as Events, m as useComposedRefs, p as composeRefs, t as Button, y as cn } from "./button-DQpBib29.js";
13
- import { _t as createContextScope, at as useControllableState, ct as useId, dt as useCallbackRef, et as MAX_HEIGHT_OFFSET, ft as Primitive, i as useFocusGuards, it as StyleNamespace, mt as createSlot, n as hideOthers, nt as withSmartCollisionBoundary, ot as Presence, pt as dispatchDiscreteCustomEvent, r as FocusScope, st as Portal, t as Combination_default, tt as withFullScreenAsRoot, ut as DismissableLayer, vt as composeEventHandlers } from "./Combination-Dk6JxauT.js";
12
+ import { g as Logger, h as Events, m as useComposedRefs, p as composeRefs, t as Button, y as cn } from "./button-BKkuUpZh.js";
13
+ import { _t as createContextScope, at as useControllableState, ct as useId, dt as useCallbackRef, et as MAX_HEIGHT_OFFSET, ft as Primitive, i as useFocusGuards, it as StyleNamespace, mt as createSlot, n as hideOthers, nt as withSmartCollisionBoundary, ot as Presence, pt as dispatchDiscreteCustomEvent, r as FocusScope, st as Portal, t as Combination_default, tt as withFullScreenAsRoot, ut as DismissableLayer, vt as composeEventHandlers } from "./Combination-BBPQRrDo.js";
14
14
  import { t as require_jsx_runtime } from "./jsx-runtime-CTBg5pdT.js";
15
15
  import { t as require_react_dom } from "./react-dom-CqtLRVZP.js";
16
16
  import { t as toString_default } from "./toString-DbIAWQpF.js";
17
17
  import { i as debounce_default, n as Constants } from "./constants-CytQ_3LM.js";
18
- import { C as useEvent_default } from "./useTheme-D0rdoMBF.js";
18
+ import { C as useEvent_default } from "./useTheme-CPybHVFN.js";
19
19
  import { t as memoizeLastValue } from "./once-BqS42WgZ.js";
20
20
  var ChevronRight = createLucideIcon("chevron-right", [["path", {
21
21
  d: "m9 18 6-6-6-6",
@@ -1,7 +1,7 @@
1
1
  import { s as __toESM } from "./chunk-BNovOVIE.js";
2
2
  import { t as require_react } from "./react-Bs6Z0kvn.js";
3
3
  import { t as require_compiler_runtime } from "./compiler-runtime-B_OLMU9S.js";
4
- import { C as useEvent_default } from "./useTheme-D0rdoMBF.js";
4
+ import { C as useEvent_default } from "./useTheme-CPybHVFN.js";
5
5
  import { t as invariant } from "./invariant-D9QLJ4SZ.js";
6
6
  var import_compiler_runtime = require_compiler_runtime(), import_react = /* @__PURE__ */ __toESM(require_react(), 1), Result = {
7
7
  error(e, s) {
@@ -4,12 +4,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
4
4
  import { s as __toESM, t as __commonJSMin } from "./chunk-BNovOVIE.js";
5
5
  import { t as require_react } from "./react-Bs6Z0kvn.js";
6
6
  import { t as require_compiler_runtime } from "./compiler-runtime-B_OLMU9S.js";
7
- import { l as createLucideIcon } from "./dist-WIWVvdBh.js";
8
- import { a as cva, g as Logger, y as cn } from "./button-DQpBib29.js";
7
+ import { l as createLucideIcon } from "./dist-C0Rnbr-_.js";
8
+ import { a as cva, g as Logger, y as cn } from "./button-BKkuUpZh.js";
9
9
  import { t as require_jsx_runtime } from "./jsx-runtime-CTBg5pdT.js";
10
10
  import { r as KnownQueryParams } from "./constants-CytQ_3LM.js";
11
- import { f as waitFor, p as isIslands, u as store, y as atom } from "./useTheme-D0rdoMBF.js";
12
- import { i as tableFromIPC } from "./loader-V1UqqlAy.js";
11
+ import { f as waitFor, p as isIslands, u as store, y as atom } from "./useTheme-CPybHVFN.js";
12
+ import { i as tableFromIPC } from "./loader-CABJs6GU.js";
13
13
  var CircleQuestionMark = createLucideIcon("circle-question-mark", [
14
14
  ["circle", {
15
15
  cx: "12",
@@ -1,7 +1,7 @@
1
1
  import { s as __toESM } from "./chunk-BNovOVIE.js";
2
2
  import { t as require_react } from "./react-Bs6Z0kvn.js";
3
3
  import { t as require_compiler_runtime } from "./compiler-runtime-B_OLMU9S.js";
4
- import { g as Logger } from "./button-DQpBib29.js";
4
+ import { g as Logger } from "./button-BKkuUpZh.js";
5
5
  import { n as once } from "./once-BqS42WgZ.js";
6
6
  function testStorage(e) {
7
7
  try {
@@ -1,8 +1,8 @@
1
1
  import { s as __toESM } from "./chunk-BNovOVIE.js";
2
2
  import { t as require_react } from "./react-Bs6Z0kvn.js";
3
3
  import { t as require_compiler_runtime } from "./compiler-runtime-B_OLMU9S.js";
4
- import { g as Logger, s as OverridingHotkeyProvider, u as resolvePlatform } from "./button-DQpBib29.js";
5
- import { B as record, H as string, L as number, O as array, P as looseObject, R as object, W as union, k as boolean, w as _enum } from "./Combination-Dk6JxauT.js";
4
+ import { g as Logger, s as OverridingHotkeyProvider, u as resolvePlatform } from "./button-BKkuUpZh.js";
5
+ import { B as record, H as string, L as number, O as array, P as looseObject, R as object, W as union, k as boolean, w as _enum } from "./Combination-BBPQRrDo.js";
6
6
  import { t as _baseIsEqual_default } from "./_baseIsEqual-CvgsjYoW.js";
7
7
  import { t as merge_default } from "./merge-NuyC7LN7.js";
8
8
  function isEqual(e, A) {
@@ -1,19 +1,19 @@
1
1
  import { s as __toESM } from "./chunk-BNovOVIE.js";
2
2
  import { t as require_react } from "./react-Bs6Z0kvn.js";
3
3
  import { t as require_compiler_runtime } from "./compiler-runtime-B_OLMU9S.js";
4
- import { S as CircleQuestionMark, a as AlertTitle, m as asRemoteURL, n as arrow, o as isValid, r as Alert, t as useDeepCompareMemoize } from "./useDeepCompareMemoize-CJr2MRe6.js";
5
- import { d as Objects, g as Logger, h as Events, y as cn } from "./button-DQpBib29.js";
6
- import "./Combination-Dk6JxauT.js";
4
+ import { S as CircleQuestionMark, a as AlertTitle, m as asRemoteURL, n as arrow, o as isValid, r as Alert, t as useDeepCompareMemoize } from "./useDeepCompareMemoize-BWUwfh37.js";
5
+ import { d as Objects, g as Logger, h as Events, y as cn } from "./button-BKkuUpZh.js";
6
+ import "./Combination-BBPQRrDo.js";
7
7
  import { t as require_jsx_runtime } from "./jsx-runtime-CTBg5pdT.js";
8
8
  import "./react-dom-CqtLRVZP.js";
9
- import { t as Tooltip } from "./tooltip-SPkubVH3.js";
9
+ import { t as Tooltip } from "./tooltip-CKG75XQa.js";
10
10
  import { i as debounce_default } from "./constants-CytQ_3LM.js";
11
- import { C as useEvent_default, n as useTheme } from "./useTheme-D0rdoMBF.js";
12
- import { a as getContainerWidth, n as vegaLoadData, s as tooltipHandler } from "./loader-V1UqqlAy.js";
11
+ import { C as useEvent_default, n as useTheme } from "./useTheme-CPybHVFN.js";
12
+ import { a as getContainerWidth, n as vegaLoadData, s as tooltipHandler } from "./loader-CABJs6GU.js";
13
13
  import { t as uniq_default } from "./uniq-H2E5nMLq.js";
14
- import { n as ErrorBanner } from "./error-banner-BctofTCP.js";
14
+ import { n as ErrorBanner } from "./error-banner-Dmi5ujan.js";
15
15
  import { n as formats } from "./vega-loader.browser-CQ-lnUkI.js";
16
- import { t as useAsyncData } from "./useAsyncData-D7-oahg5.js";
16
+ import { t as useAsyncData } from "./useAsyncData-CEjJxwFB.js";
17
17
  import { t as j } from "./react-vega-C6kwcd86.js";
18
18
  import "./defaultLocale-Bklbu-Tp.js";
19
19
  import "./defaultLocale-CfQ4kBaV.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marimo-team/islands",
3
- "version": "0.21.1-dev15",
3
+ "version": "0.21.1-dev18",
4
4
  "main": "dist/main.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -41,7 +41,10 @@ import { hasOnlyOneCellAtom, useCellActions } from "@/core/cells/cells";
41
41
  import { type CellId, SETUP_CELL_ID } from "@/core/cells/ids";
42
42
  import type { CellData } from "@/core/cells/types";
43
43
  import { formatEditorViews } from "@/core/codemirror/format";
44
- import { toggleToLanguage } from "@/core/codemirror/language/commands";
44
+ import {
45
+ getCurrentLanguageAdapter,
46
+ toggleToLanguage,
47
+ } from "@/core/codemirror/language/commands";
45
48
  import { switchLanguage } from "@/core/codemirror/language/extension";
46
49
  import { MARKDOWN_INITIAL_HIDE_CODE } from "@/core/codemirror/language/languages/markdown";
47
50
  import {
@@ -235,35 +238,41 @@ export function useCellActionButtons({ cell, closePopover }: Props) {
235
238
  },
236
239
  hidden: isSetupCell,
237
240
  },
238
- {
239
- icon: <DatabaseIcon size={13} strokeWidth={1.5} />,
240
- label: "Convert to SQL",
241
- handle: () => {
242
- const editorView = getEditorView();
243
- if (!editorView) {
244
- return;
241
+ // We need to check this here because the user may have toggled the language
242
+ getCurrentLanguageAdapter(getEditorView()) === "sql"
243
+ ? {
244
+ icon: <PythonIcon />,
245
+ label: "View as Python",
246
+ hotkey: "cell.viewAsSQL",
247
+ handle: () => {
248
+ const editorView = getEditorView();
249
+ if (!editorView) {
250
+ return;
251
+ }
252
+ toggleToLanguage(editorView, "python", { force: true });
253
+ },
254
+ hidden: isSetupCell,
245
255
  }
246
- maybeAddMarimoImport({ autoInstantiate, createNewCell: createCell });
247
- switchLanguage(editorView, {
248
- language: "sql",
249
- keepCodeAsIs: false,
250
- });
251
- },
252
- hidden: isSetupCell,
253
- },
254
- {
255
- icon: <PythonIcon />,
256
- label: "Toggle as Python",
257
- handle: () => {
258
- const editorView = getEditorView();
259
- if (!editorView) {
260
- return;
261
- }
262
- maybeAddMarimoImport({ autoInstantiate, createNewCell: createCell });
263
- toggleToLanguage(editorView, "python", { force: true });
264
- },
265
- hidden: isSetupCell,
266
- },
256
+ : {
257
+ icon: <DatabaseIcon size={13} strokeWidth={1.5} />,
258
+ label: "Convert to SQL",
259
+ hotkey: "cell.viewAsSQL",
260
+ handle: () => {
261
+ const editorView = getEditorView();
262
+ if (!editorView) {
263
+ return;
264
+ }
265
+ maybeAddMarimoImport({
266
+ autoInstantiate,
267
+ createNewCell: createCell,
268
+ });
269
+ switchLanguage(editorView, {
270
+ language: "sql",
271
+ keepCodeAsIs: false,
272
+ });
273
+ },
274
+ hidden: isSetupCell,
275
+ },
267
276
  ],
268
277
 
269
278
  // Movement
@@ -163,6 +163,13 @@ const CellEditorInternal = ({
163
163
  }
164
164
  });
165
165
 
166
+ const afterToggleSQL = useEvent(() => {
167
+ maybeAddMarimoImport({
168
+ autoInstantiate,
169
+ createNewCell: cellActions.createNewCell,
170
+ });
171
+ });
172
+
166
173
  const aiEnabled = isAiEnabled(userConfig);
167
174
 
168
175
  const extensions = useMemo(() => {
@@ -173,6 +180,7 @@ const CellEditorInternal = ({
173
180
  cellActions: {
174
181
  ...cellActions,
175
182
  afterToggleMarkdown,
183
+ afterToggleSQL,
176
184
  onRun: handleRunCell,
177
185
  deleteCell: handleDelete,
178
186
  saveNotebook: saveOrNameNotebook,
@@ -267,6 +275,7 @@ const CellEditorInternal = ({
267
275
  handleRunCell,
268
276
  setAiCompletionCell,
269
277
  afterToggleMarkdown,
278
+ afterToggleSQL,
270
279
  setLanguageAdapter,
271
280
  showHiddenCode,
272
281
  saveOrNameNotebook,
@@ -45,6 +45,7 @@ function getOpts() {
45
45
  onRun: namedFunction("onRun"),
46
46
  deleteCell: namedFunction("deleteCell"),
47
47
  afterToggleMarkdown: namedFunction("afterToggleMarkdown"),
48
+ afterToggleSQL: namedFunction("afterToggleSQL"),
48
49
  } as unknown as CodemirrorCellActions,
49
50
  completionConfig: {
50
51
  activate_on_typing: false,
@@ -11,6 +11,7 @@ export interface CodemirrorCellActions extends CellActions {
11
11
  onRun: () => void;
12
12
  deleteCell: () => void;
13
13
  afterToggleMarkdown: () => void;
14
+ afterToggleSQL: () => void;
14
15
  saveNotebook: () => void;
15
16
  }
16
17
 
@@ -42,6 +42,26 @@ export function formatKeymapExtension(hotkeys: HotkeyProvider) {
42
42
  actions.afterToggleMarkdown();
43
43
  }
44
44
 
45
+ return response !== false;
46
+ },
47
+ },
48
+ {
49
+ key: hotkeys.getHotkey("cell.viewAsSQL").key,
50
+ preventDefault: true,
51
+ run: (ev) => {
52
+ const currentLanguage = getCurrentLanguageAdapter(ev);
53
+ const destinationLanguage =
54
+ currentLanguage === "sql" ? "python" : "sql";
55
+
56
+ const response = toggleToLanguage(ev, destinationLanguage, {
57
+ force: true,
58
+ });
59
+
60
+ if (response === "sql") {
61
+ const actions = ev.state.facet(cellActionsState);
62
+ actions.afterToggleSQL();
63
+ }
64
+
45
65
  return response !== false;
46
66
  },
47
67
  },
@@ -142,6 +142,14 @@ const DEFAULT_HOT_KEY = {
142
142
  group: "Editing",
143
143
  key: "Mod-Shift-m",
144
144
  },
145
+ "cell.viewAsSQL": {
146
+ name: "Toggle SQL",
147
+ group: "Editing",
148
+ key: {
149
+ windows: "Alt-Shift-l",
150
+ main: "Mod-Shift-l",
151
+ },
152
+ },
145
153
  "cell.complete": {
146
154
  name: "Code completion",
147
155
  group: "Editing",
package/src/css/md.css CHANGED
@@ -41,6 +41,10 @@
41
41
  font-family: var(--heading-font);
42
42
  }
43
43
 
44
+ .markdown hr {
45
+ margin-block: 0.5rem;
46
+ }
47
+
44
48
  .markdown a {
45
49
  cursor: pointer;
46
50
  text-decoration: inherit;