roamjs-components 0.74.14 → 0.74.15

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.
@@ -11,25 +11,7 @@ export declare const useExtensionAPI: () => {
11
11
  id: string;
12
12
  name: string;
13
13
  description: string;
14
- action: {
15
- type: "button";
16
- onClick?: ((e: MouseEvent) => void) | undefined;
17
- content: string;
18
- } | {
19
- type: "switch";
20
- onChange?: ((e: React.ChangeEvent<HTMLInputElement>) => void) | undefined;
21
- } | {
22
- type: "input";
23
- placeholder: string;
24
- onChange?: ((e: React.ChangeEvent<HTMLInputElement>) => void) | undefined;
25
- } | {
26
- type: "select";
27
- items: string[];
28
- onChange?: ((e: React.ChangeEvent<HTMLInputElement>) => void) | undefined;
29
- } | {
30
- type: "reactComponent";
31
- component: React.FC<{}>;
32
- };
14
+ action: import("../types").Action;
33
15
  }[];
34
16
  }) => void;
35
17
  };
@@ -28,7 +28,7 @@ declare type Props<T> = {
28
28
  }>;
29
29
  };
30
30
  declare const FormDialog: <T extends Record<string, unknown>>({ title, content, isOpen, onClose, onSubmit, fields, }: RoamOverlayProps<Props<T>>) => JSX.Element;
31
- export declare const render: (props: Props<Record<string, unknown>>) => void | (() => void);
31
+ export declare const render: (props: Props<Record<string, unknown>>) => (() => void) | undefined;
32
32
  export declare const prompt: ({ defaultAnswer, question, title, }: {
33
33
  title: string;
34
34
  question: string;
@@ -7,5 +7,5 @@ export declare const ID = "roamjs-progress-dialog-root";
7
7
  declare const ProgressDialog: ({ onClose, ...props }: {
8
8
  onClose: () => void;
9
9
  } & Props) => JSX.Element;
10
- export declare const render: (props: Props) => void | (() => void);
10
+ export declare const render: (props: Props) => (() => void) | undefined;
11
11
  export default ProgressDialog;
@@ -11,5 +11,5 @@ declare type Props = {
11
11
  declare const SimpleAlert: (Markdown: typeof Marked) => ({ onClose, content, onConfirm, onCancel, externalLink, confirmText, dontShowAgain, }: Props & {
12
12
  onClose: () => void;
13
13
  }) => React.ReactElement;
14
- export declare const render: (props: Props) => Promise<void | (() => void)>;
14
+ export declare const render: (props: Props) => Promise<(() => void) | undefined>;
15
15
  export default SimpleAlert;
@@ -5,7 +5,7 @@ declare type Props = {
5
5
  declare const TokenDialog: ({ onClose, onEnter }: {
6
6
  onClose: () => void;
7
7
  } & Props) => JSX.Element;
8
- export declare const render: (props: Props) => void | (() => void);
8
+ export declare const render: (props: Props) => (() => void) | undefined;
9
9
  export declare const addTokenDialogCommand: (props?: Props) => void;
10
10
  export declare const checkRoamJSTokenWarning: () => Promise<string>;
11
11
  export default TokenDialog;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "roamjs-components",
3
3
  "description": "Expansive toolset, utilities, & components for developing RoamJS extensions.",
4
- "version": "0.74.14",
4
+ "version": "0.74.15",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "scripts": {
package/types/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { AddPullWatch, PullBlock, SidebarAction, SidebarWindow, SidebarWindowInput, WriteAction } from "./native";
2
2
  import { RegisterSelection, ParseQuery, FireQuery, ConditionToDatalog, RegisterDatalogTranslator, ResultsViewComponent, QueryEditorComponent, ExportDialogComponent, QueryPageComponent, RunQuery, ListActiveQueries } from "./query-builder";
3
- import { SamePageApi } from "./samepage";
4
3
  import { RegisterCommand, UnregisterCommand } from "./smartblocks";
5
4
  import type marked from "marked";
6
5
  import type Markdown from "marked-react";
@@ -179,8 +178,6 @@ declare global {
179
178
  roamjs: {
180
179
  loaded: Set<string>;
181
180
  extension: {
182
- multiplayer?: SamePageApi;
183
- samepage?: SamePageApi;
184
181
  queryBuilder?: {
185
182
  ExportDialog: ExportDialogComponent;
186
183
  QueryEditor: QueryEditorComponent;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;AA0BA,mDAAyB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;AAyBA,mDAAyB"}
package/types/native.d.ts CHANGED
@@ -346,13 +346,14 @@ declare type CustomAction = {
346
346
  type: "reactComponent";
347
347
  component: React.FC;
348
348
  };
349
+ export declare type Action = ButtonAction | SwitchAction | InputAction | SelectAction | CustomAction;
349
350
  declare type PanelConfig = {
350
351
  tabTitle: string;
351
352
  settings: {
352
353
  id: string;
353
354
  name: string;
354
355
  description: string;
355
- action: ButtonAction | SwitchAction | InputAction | SelectAction | CustomAction;
356
+ action: Action;
356
357
  }[];
357
358
  };
358
359
  export declare type OnloadArgs = {
@@ -1,4 +1,4 @@
1
1
  import React from "react";
2
2
  import { RoamOverlayProps } from "./renderOverlay";
3
- declare const createOverlayRender: <T extends Record<string, unknown>>(id: string, Overlay: (props: RoamOverlayProps<T>) => React.ReactElement) => (props: T) => void | (() => void);
3
+ declare const createOverlayRender: <T extends Record<string, unknown>>(id: string, Overlay: (props: RoamOverlayProps<T>) => React.ReactElement) => (props: T) => (() => void) | undefined;
4
4
  export default createOverlayRender;
@@ -3,11 +3,10 @@ export declare type RoamOverlayProps<T extends Record<string, unknown> = Record<
3
3
  onClose: () => void;
4
4
  isOpen: boolean;
5
5
  } & T;
6
- declare const renderOverlay: <T extends Record<string, unknown>>({ id, Overlay, props, path, before, }?: {
6
+ declare const renderOverlay: <T extends Record<string, unknown>>({ id, Overlay, props, path, }?: {
7
7
  id?: string | undefined;
8
8
  Overlay?: ((props: RoamOverlayProps<T>) => React.ReactElement) | undefined;
9
9
  props?: T | undefined;
10
10
  path?: string | HTMLElement | null | undefined;
11
- before?: number | HTMLElement | null | undefined;
12
- }) => (() => void) | void;
11
+ }) => (() => void) | undefined;
13
12
  export default renderOverlay;
@@ -6,19 +6,27 @@ const react_1 = tslib_1.__importDefault(require("react"));
6
6
  const react_dom_1 = tslib_1.__importDefault(require("react-dom"));
7
7
  const dispatchToRegistry_1 = tslib_1.__importDefault(require("./dispatchToRegistry"));
8
8
  const removeFromRegistry_1 = tslib_1.__importDefault(require("./removeFromRegistry"));
9
- const renderOverlay = ({ id = (0, nanoid_1.default)(), Overlay = (props) => react_1.default.createElement("div", props), props = {}, path = "body", before, } = {}) => {
9
+ const BEFORE_REGEX = /::before\([\w.]+\)$/;
10
+ const renderOverlay = ({ id = (0, nanoid_1.default)(), Overlay = (props) => react_1.default.createElement("div", props), props = {}, path = "body", } = {}) => {
11
+ var _a;
10
12
  const parent = document.createElement("div");
11
13
  parent.id = id.replace(/^\d*/, "");
12
- const pathElement = typeof path === "string" ? document.querySelector(path) : path;
14
+ const pathElement = typeof path === "string"
15
+ ? document.querySelector(path.replace(BEFORE_REGEX, ""))
16
+ : path;
13
17
  if (pathElement && !pathElement.querySelector(`#${parent.id}`)) {
14
- if (typeof before === "number") {
15
- pathElement.insertBefore(parent, pathElement.children[before]);
18
+ const before = typeof path === "string" ? (_a = BEFORE_REGEX.exec(path)) === null || _a === void 0 ? void 0 : _a[1] : undefined;
19
+ if (!before) {
20
+ pathElement.appendChild(parent);
21
+ }
22
+ else if (!Number.isNaN(Number(before))) {
23
+ pathElement.insertBefore(parent, pathElement.children[Number(before)]);
16
24
  }
17
- else if (typeof before === "object") {
18
- pathElement.insertBefore(parent, before);
25
+ else if (pathElement.querySelector(before)) {
26
+ pathElement.insertBefore(parent, pathElement.querySelector(before));
19
27
  }
20
28
  else {
21
- pathElement.appendChild(parent);
29
+ return undefined;
22
30
  }
23
31
  const onClose = () => {
24
32
  if (typeof props.onClose === "function")
@@ -35,6 +43,7 @@ const renderOverlay = ({ id = (0, nanoid_1.default)(), Overlay = (props) => reac
35
43
  });
36
44
  return onClose;
37
45
  }
46
+ return undefined;
38
47
  };
39
48
  exports.default = renderOverlay;
40
49
  //# sourceMappingURL=renderOverlay.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"renderOverlay.js","sourceRoot":"","sources":["../../src/util/renderOverlay.ts"],"names":[],"mappings":";;;AAAA,4DAA4B;AAC5B,0DAA0B;AAC1B,kEAAiC;A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| boolean | null | {
2
- toJSON: () => string;
3
- } | json[] | {
4
- [key: string]: json;
5
- };
6
- export declare type SamePageApi = {
7
- addGraphListener: (args: {
8
- operation: string;
9
- handler: (e: json, graph: string) => void;
10
- }) => void;
11
- removeGraphListener: (args: {
12
- operation: string;
13
- }) => void;
14
- sendToGraph: (args: {
15
- graph: string;
16
- operation: string;
17
- data?: {
18
- [k: string]: json;
19
- };
20
- }) => void;
21
- };
22
- export {};
package/types/samepage.js DELETED
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=samepage.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"samepage.js","sourceRoot":"","sources":["../../src/types/samepage.ts"],"names":[],"mappings":""}