roamjs-components 0.82.14 → 0.83.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.
@@ -1,6 +1,7 @@
1
+ import React from "react";
1
2
  import { Intent, IToastProps, ToasterPosition } from "@blueprintjs/core";
2
3
  declare type ToastBaseProps = {
3
- content?: string;
4
+ content?: React.ReactNode;
4
5
  timeout?: number;
5
6
  intent?: Intent;
6
7
  onDismiss?: IToastProps["onDismiss"];
@@ -22,10 +22,11 @@ const render = (_a) => {
22
22
  ? window.RoamLazy.MarkedReact()
23
23
  : Promise.resolve().then(() => tslib_1.__importStar(require("marked-react"))).then((r) => r.default)).then((Markdown) => {
24
24
  const Toast = ({ content = "RoamJS Notification", intent = core_1.Intent.PRIMARY, timeout = 5000, onDismiss, action, }) => {
25
+ const isStringContent = typeof content === "string";
25
26
  return {
26
27
  message: (react_1.default.createElement(react_1.default.Fragment, null,
27
28
  react_1.default.createElement("style", null, `.${className} p { margin-bottom: 0; }`),
28
- react_1.default.createElement(Markdown, null, content))),
29
+ isStringContent ? react_1.default.createElement(Markdown, null, content) : content)),
29
30
  intent,
30
31
  timeout,
31
32
  onDismiss,
@@ -1 +1 @@
1
- {"version":3,"file":"Toast.js","sourceRoot":"","sources":["../../src/components/Toast.tsx"],"names":[],"mappings":";;;;AAAA,0DAA0B;AAC1B,4CAK2B;AAepB,MAAM,MAAM,GAAG,CAAC,EAGV,EAAgB,EAAE;QAHR,EACrB,QAAQ,GAAG,KAAK,OAEL,EADR,KAAK,sBAFa,YAGtB,CADS;IAER,MAAM,SAAS,GAAG,gBAAgB,QAAQ,EAAE,CAAC;IAC7C,MAAM,WAAW,GAAG,QAAQ,CAAC,aAAa,CACxC,wBAAwB,SAAS,EAAE,CACpC,CAAC;IACF,IAAI,WAAW,EAAE;QACf,WAAW,CAAC,aAAa,CACvB,IAAI,WAAW,CAAC,cAAc,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CACnD,C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AE,CAAC,CAAC;oBACjC,CAAC,CAAkB,CAAC,CAAC;YACzB,CAAC,EAAE,CAAC,CAAC,CAAC;QACR,CAAC,CAAC,CAAC;QACH,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;KACxC;AACH,CAAC,CAAC;AA5DW,QAAA,MAAM,UA4DjB;AAEF,kBAAe,cAAM,CAAC","sourcesContent":["import React from \"react\";\nimport {\n Intent,\n IToastProps,\n Toaster,\n ToasterPosition,\n} from \"@blueprintjs/core\";\n\ntype ToastBaseProps = {\n content?: string;\n timeout?: number;\n intent?: Intent;\n onDismiss?: IToastProps[\"onDismiss\"];\n action?: IToastProps[\"action\"];\n};\n\ntype ToastProps = {\n id: string;\n position?: ToasterPosition;\n} & ToastBaseProps;\n\nexport const render = ({\n position = \"top\",\n ...props\n}: ToastProps): (() => void) => {\n const className = `roamjs-toast-${position}`;\n const toasterRoot = document.querySelector(\n `.bp3-toast-container.${className}`\n );\n if (toasterRoot) {\n toasterRoot.dispatchEvent(\n new CustomEvent(\"roamjs-toast\", { detail: props })\n );\n return () => toasterRoot.remove();\n } else {\n const toaster = Toaster.create({\n position,\n className,\n });\n\n // `import(marked-react)` is returning `window.RoamLazy.MarkedReact` instead of the module itself\n (window.RoamLazy\n ? window.RoamLazy.MarkedReact()\n : import(\"marked-react\").then((r) => r.default)\n ).then((Markdown) => {\n const Toast = ({\n content = \"RoamJS Notification\",\n intent = Intent.PRIMARY,\n timeout = 5000,\n onDismiss,\n action,\n }: ToastBaseProps) => {\n return {\n message: (\n <>\n <style>{`.${className} p { margin-bottom: 0; }`}</style>\n <Markdown>{content}</Markdown>\n </>\n ),\n intent,\n timeout,\n onDismiss,\n action,\n };\n };\n toaster.show(Toast(props), props.id);\n setTimeout(() => {\n const toasterRoot = document.querySelector<HTMLDivElement>(\n `.bp3-toast-container.${className}`\n );\n if (toasterRoot)\n toasterRoot.addEventListener(\"roamjs-toast\", ((e: CustomEvent) => {\n const {\n detail: { id, ...props },\n } = e;\n toaster.show(Toast(props), id);\n }) as EventListener);\n }, 1);\n });\n return () => toaster.dismiss(props.id);\n }\n};\n\nexport default render;\n"]}
1
+ {"version":3,"file":"Toast.js","sourceRoot":"","sources":["../../src/components/Toast.tsx"],"names":[],"mappings":";;;;AAAA,0DAA0B;AAC1B,4CAK2B;AAepB,MAAM,MAAM,GAAG,CAAC,EAGV,EAAgB,EAAE;QAHR,EACrB,QAAQ,GAAG,KAAK,OAEL,EADR,KAAK,sBAFa,YAGtB,CADS;IAER,MAAM,SAAS,GAAG,gBAAgB,QAAQ,EAAE,CAAC;IAC7C,MAAM,WAAW,GAAG,QAAQ,CAAC,aAAa,CACxC,wBAAwB,SAAS,EAAE,CACpC,CAAC;IACF,IAAI,WAAW,EAAE;QACf,WAAW,CAAC,aAAa,CACvB,IAAI,WAAW,CAAC,cAAc,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CACnD,CAAC;QACF,OAAO,GAAG,EAAE,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;KACnC;SAAM;QACL,MAAM,OAAO,GAAG,cAAO,CAAC,MAAM,CAAC;YAC7B,QAAQ;YACR,SAAS;SACV,CAAC,CAAC;QAEH,iGAAiG;QACjG,CAAC,MAAM,CAAC,QAAQ;YACd,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,EAAE;YAC/B,CAAC,CAAC,0DAAO,cAAc,IAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAChD,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;YAClB,MAAM,KAAK,GAAG,CAAC,EACb,OAAO,GAAG,qBAAqB,EAC/B,MAAM,GAAG,aAAM,CAAC,OAAO,EACvB,OAAO,GAAG,IAAI,EACd,SAAS,EACT,MAAM,GACS,EAAE,EAAE;gBACnB,MAAM,eAAe,GAAG,OAAO,OAAO,KAAK,QAAQ,CAAC;gBACpD,OAAO;oBACL,OAAO,EAAE,CACP;wBACE,6CAAQ,IAAI,SAAS,0BAA0B,CAAS;wBACvD,eAAe,CAAC,CAAC,CAAC,8BAAC,QAAQ,QAAE,OAAO,CAAY,CAAC,CAAC,CAAC,OAAO,CAC1D,CACJ;oBACD,MAAM;oBACN,OAAO;oBACP,SAAS;oBACT,MAAM;iBACP,CAAC;YACJ,CAAC,CAAC;YACF,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;YACrC,UAAU,CAAC,GAAG,EAAE;gBACd,MAAM,WAAW,GAAG,QAAQ,CAAC,aAAa,CACxC,wBAAwB,SAAS,EAAE,CACpC,CAAC;gBACF,IAAI,WAAW;oBACb,WAAW,CAAC,gBAAgB,CAAC,cAAc,EAAE,CAAC,CAAC,CAAc,EAAE,EAAE;wBAC/D,MACE,KACE,CAAC,OADqB,EAAxB,EAAU,EAAE,OAAY,EAAP,KAAK,sBAAd,MAAgB,CACrB,CAAC;wBACN,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;oBACjC,CAAC,CAAkB,CAAC,CAAC;YACzB,CAAC,EAAE,CAAC,CAAC,CAAC;QACR,CAAC,CAAC,CAAC;QACH,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;KACxC;AACH,CAAC,CAAC;AA7DW,QAAA,MAAM,UA6DjB;AAEF,kBAAe,cAAM,CAAC","sourcesContent":["import React from \"react\";\nimport {\n Intent,\n IToastProps,\n Toaster,\n ToasterPosition,\n} from \"@blueprintjs/core\";\n\ntype ToastBaseProps = {\n content?: React.ReactNode;\n timeout?: number;\n intent?: Intent;\n onDismiss?: IToastProps[\"onDismiss\"];\n action?: IToastProps[\"action\"];\n};\n\ntype ToastProps = {\n id: string;\n position?: ToasterPosition;\n} & ToastBaseProps;\n\nexport const render = ({\n position = \"top\",\n ...props\n}: ToastProps): (() => void) => {\n const className = `roamjs-toast-${position}`;\n const toasterRoot = document.querySelector(\n `.bp3-toast-container.${className}`\n );\n if (toasterRoot) {\n toasterRoot.dispatchEvent(\n new CustomEvent(\"roamjs-toast\", { detail: props })\n );\n return () => toasterRoot.remove();\n } else {\n const toaster = Toaster.create({\n position,\n className,\n });\n\n // `import(marked-react)` is returning `window.RoamLazy.MarkedReact` instead of the module itself\n (window.RoamLazy\n ? window.RoamLazy.MarkedReact()\n : import(\"marked-react\").then((r) => r.default)\n ).then((Markdown) => {\n const Toast = ({\n content = \"RoamJS Notification\",\n intent = Intent.PRIMARY,\n timeout = 5000,\n onDismiss,\n action,\n }: ToastBaseProps) => {\n const isStringContent = typeof content === \"string\";\n return {\n message: (\n <>\n <style>{`.${className} p { margin-bottom: 0; }`}</style>\n {isStringContent ? <Markdown>{content}</Markdown> : content}\n </>\n ),\n intent,\n timeout,\n onDismiss,\n action,\n };\n };\n toaster.show(Toast(props), props.id);\n setTimeout(() => {\n const toasterRoot = document.querySelector<HTMLDivElement>(\n `.bp3-toast-container.${className}`\n );\n if (toasterRoot)\n toasterRoot.addEventListener(\"roamjs-toast\", ((e: CustomEvent) => {\n const {\n detail: { id, ...props },\n } = e;\n toaster.show(Toast(props), id);\n }) as EventListener);\n }, 1);\n });\n return () => toaster.dismiss(props.id);\n }\n};\n\nexport default render;\n"]}
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.82.14",
4
+ "version": "0.83.0",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "scripts": {