roamjs-components 0.83.6 → 0.84.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.
@@ -5,9 +5,9 @@ const core_1 = require("@blueprintjs/core");
5
5
  const react_1 = tslib_1.__importStar(require("react"));
6
6
  const idToTitle_1 = tslib_1.__importDefault(require("../../util/idToTitle"));
7
7
  const Description_1 = tslib_1.__importDefault(require("../Description"));
8
- const FlagPanel = ({ title, uid: initialUid, parentUid, order, description, options = {}, }) => {
8
+ const FlagPanel = ({ title, uid: initialUid, parentUid, order, description, options = {}, disabled = false, }) => {
9
9
  const [uid, setUid] = (0, react_1.useState)(initialUid);
10
- return (react_1.default.createElement(core_1.Checkbox, { checked: !!uid, onChange: (e) => {
10
+ return (react_1.default.createElement(core_1.Checkbox, { checked: !!uid, disabled: disabled, onChange: (e) => {
11
11
  var _a;
12
12
  const { checked } = e.target;
13
13
  if (checked) {
@@ -1 +1 @@
1
- {"version":3,"file":"FlagPanel.js","sourceRoot":"","sources":["../../../src/components/ConfigPanels/FlagPanel.tsx"],"names":[],"mappings":";;;AAAA,4CAA6C;AAC7C,uDAAwC;AACxC,6EAA6C;AAC7C,yEAAyC;AAGzC,MAAM,SAAS,GAA0B,CAAC,EACxC,KAAK,EACL,GAAG,EAAE,UAAU,EACf,SAAS,EACT,KAAK,EACL,WAAW,EACX,OAAO,GAAG,EAAE,GACb,EAAE,EAAE;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,IAAA,gBAAQ,EAAC,UAAU,CAAC,CAAC;IAC3C,OAAO,CACL,8BAAC,eAAQ,IACP,OAAO,EAAE,CAAC,CAAC,GAAG,EACd,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE;;YACd,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,MAA0B,CAAC;YACjD,IAAI,OAAO,EAAE;gBACX,MAAM,MAAM,GAAG,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;gBACtD,MAAM,CAAC,YAAY,CAAC,WAAW,CAAC;oBAC9B,KAAK,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE;oBACrC,QAAQ,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE;iBAC7C,CAAC,CAAC;gBACH,UAAU,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;aACrC;iBAAM;gBACL,MAAM,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;gBACpD,MAAM,CAAC,EAAE,CAAC,CAAC;aACZ;YACD,MAAA,OAAO,CAAC,QAAQ,wDAAG,OAAO,EAAE,CAAC,CAAC,CAAC;QACjC,CAAC,EACD,YAAY,EACV;YACG,IAAA,mBAAS,EAAC,KAAK,CAAC;YACjB,8BAAC,qBAAW,IAAC,WAAW,EAAE,WAAW,GAAI,CACxC,GAEL,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,SAAS,CAAC,IAAI,GAAG,MAAM,CAAC;AAExB,kBAAe,SAAS,CAAC","sourcesContent":["import { Checkbox } from \"@blueprintjs/core\";\nimport React, { useState } from \"react\";\nimport idToTitle from \"../../util/idToTitle\";\nimport Description from \"../Description\";\nimport type { FieldPanel, FlagField } from \"./types\";\n\nconst FlagPanel: FieldPanel<FlagField> = ({\n title,\n uid: initialUid,\n parentUid,\n order,\n description,\n options = {},\n}) => {\n const [uid, setUid] = useState(initialUid);\n return (\n <Checkbox\n checked={!!uid}\n onChange={(e) => {\n const { checked } = e.target as HTMLInputElement;\n if (checked) {\n const newUid = window.roamAlphaAPI.util.generateUID();\n window.roamAlphaAPI.createBlock({\n block: { string: title, uid: newUid },\n location: { order, \"parent-uid\": parentUid },\n });\n setTimeout(() => setUid(newUid), 1);\n } else {\n window.roamAlphaAPI.deleteBlock({ block: { uid } });\n setUid(\"\");\n }\n options.onChange?.(checked, e);\n }}\n labelElement={\n <>\n {idToTitle(title)}\n <Description description={description} />\n </>\n }\n />\n );\n};\n\nFlagPanel.type = \"flag\";\n\nexport default FlagPanel;\n"]}
1
+ {"version":3,"file":"FlagPanel.js","sourceRoot":"","sources":["../../../src/components/ConfigPanels/FlagPanel.tsx"],"names":[],"mappings":";;;AAAA,4CAA6C;AAC7C,uDAAwC;AACxC,6EAA6C;AAC7C,yEAAyC;AAGzC,MAAM,SAAS,GAA0B,CAAC,EACxC,KAAK,EACL,GAAG,EAAE,UAAU,EACf,SAAS,EACT,KAAK,EACL,WAAW,EACX,OAAO,GAAG,EAAE,EACZ,QAAQ,GAAG,KAAK,GACjB,EAAE,EAAE;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,IAAA,gBAAQ,EAAC,UAAU,CAAC,CAAC;IAC3C,OAAO,CACL,8BAAC,eAAQ,IACP,OAAO,EAAE,CAAC,CAAC,GAAG,EACd,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE;;YACd,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,MAA0B,CAAC;YACjD,IAAI,OAAO,EAAE;gBACX,MAAM,MAAM,GAAG,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;gBACtD,MAAM,CAAC,YAAY,CAAC,WAAW,CAAC;oBAC9B,KAAK,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE;oBACrC,QAAQ,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE;iBAC7C,CAAC,CAAC;gBACH,UAAU,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;aACrC;iBAAM;gBACL,MAAM,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;gBACpD,MAAM,CAAC,EAAE,CAAC,CAAC;aACZ;YACD,MAAA,OAAO,CAAC,QAAQ,wDAAG,OAAO,EAAE,CAAC,CAAC,CAAC;QACjC,CAAC,EACD,YAAY,EACV;YACG,IAAA,mBAAS,EAAC,KAAK,CAAC;YACjB,8BAAC,qBAAW,IAAC,WAAW,EAAE,WAAW,GAAI,CACxC,GAEL,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,SAAS,CAAC,IAAI,GAAG,MAAM,CAAC;AAExB,kBAAe,SAAS,CAAC","sourcesContent":["import { Checkbox } from \"@blueprintjs/core\";\nimport React, { useState } from \"react\";\nimport idToTitle from \"../../util/idToTitle\";\nimport Description from \"../Description\";\nimport type { FieldPanel, FlagField } from \"./types\";\n\nconst FlagPanel: FieldPanel<FlagField> = ({\n title,\n uid: initialUid,\n parentUid,\n order,\n description,\n options = {},\n disabled = false,\n}) => {\n const [uid, setUid] = useState(initialUid);\n return (\n <Checkbox\n checked={!!uid}\n disabled={disabled}\n onChange={(e) => {\n const { checked } = e.target as HTMLInputElement;\n if (checked) {\n const newUid = window.roamAlphaAPI.util.generateUID();\n window.roamAlphaAPI.createBlock({\n block: { string: title, uid: newUid },\n location: { order, \"parent-uid\": parentUid },\n });\n setTimeout(() => setUid(newUid), 1);\n } else {\n window.roamAlphaAPI.deleteBlock({ block: { uid } });\n setUid(\"\");\n }\n options.onChange?.(checked, e);\n }}\n labelElement={\n <>\n {idToTitle(title)}\n <Description description={description} />\n </>\n }\n />\n );\n};\n\nFlagPanel.type = \"flag\";\n\nexport default FlagPanel;\n"]}
@@ -32,6 +32,7 @@ export declare type NumberField = {
32
32
  export declare type FlagField = {
33
33
  type: "flag";
34
34
  defaultValue?: boolean;
35
+ disabled?: boolean;
35
36
  options?: {
36
37
  onChange?: (f: boolean, e: React.FormEvent<HTMLInputElement>) => void;
37
38
  };
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/ConfigPanels/types.ts"],"names":[],"mappings":"","sourcesContent":["import React from \"react\";\nimport type { InputTextNode } from \"../../types/native\";\nimport type { ExternalLoginOptions } from \"../ExternalLogin\";\n\nexport type OauthField = {\n type: \"oauth\";\n defaultValue?: [];\n options: ExternalLoginOptions;\n};\n\nexport type FieldPanel<T extends UnionField, U = Record<string, unknown>> = ((\n props: {\n order: number;\n uid?: string;\n parentUid: string;\n } & Omit<Field<T>, \"Panel\"> &\n U\n) => React.ReactElement) & { type: T[\"type\"] };\n\nexport type TextField = {\n type: \"text\";\n defaultValue?: string;\n options?: {\n placeholder?: string;\n onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void\n };\n};\n\nexport type TimeField = {\n type: \"time\";\n defaultValue?: Date;\n};\n\nexport type NumberField = {\n type: \"number\";\n defaultValue?: number;\n};\n\nexport type FlagField = {\n type: \"flag\";\n defaultValue?: boolean;\n options?: {\n onChange?: (f: boolean, e: React.FormEvent<HTMLInputElement>) => void;\n };\n};\n\nexport type MultiTextField = {\n type: \"multitext\";\n defaultValue?: string[];\n options?: {\n placeholder?: string;\n };\n};\n\nexport type PagesField = {\n type: \"pages\";\n defaultValue?: string[];\n};\n\nexport type SelectField = {\n type: \"select\";\n defaultValue?: string;\n options: {\n items: string[] | (() => string[]);\n };\n};\n\nexport type BlockField = {\n type: \"block\";\n defaultValue?: InputTextNode;\n};\n\nexport type BlocksField = {\n type: \"blocks\";\n defaultValue?: InputTextNode[];\n};\n\nexport type CustomField = {\n type: \"custom\";\n defaultValue?: InputTextNode[];\n options: {\n component: React.FC<{\n parentUid: string;\n uid: string;\n defaultValue: InputTextNode[];\n title: string;\n }>;\n };\n};\n\nexport type ArrayField =\n | PagesField\n | MultiTextField\n | CustomField\n | BlocksField;\nexport type UnionField =\n | ArrayField\n | TextField\n | TimeField\n | NumberField\n | OauthField\n | FlagField\n | SelectField\n | BlockField;\n\nexport type Field<T extends UnionField> = Omit<T, \"type\"> & {\n title: string;\n description: string;\n Panel: FieldPanel<T>;\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/ConfigPanels/types.ts"],"names":[],"mappings":"","sourcesContent":["import React from \"react\";\nimport type { InputTextNode } from \"../../types/native\";\nimport type { ExternalLoginOptions } from \"../ExternalLogin\";\n\nexport type OauthField = {\n type: \"oauth\";\n defaultValue?: [];\n options: ExternalLoginOptions;\n};\n\nexport type FieldPanel<T extends UnionField, U = Record<string, unknown>> = ((\n props: {\n order: number;\n uid?: string;\n parentUid: string;\n } & Omit<Field<T>, \"Panel\"> &\n U\n) => React.ReactElement) & { type: T[\"type\"] };\n\nexport type TextField = {\n type: \"text\";\n defaultValue?: string;\n options?: {\n placeholder?: string;\n onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void\n };\n};\n\nexport type TimeField = {\n type: \"time\";\n defaultValue?: Date;\n};\n\nexport type NumberField = {\n type: \"number\";\n defaultValue?: number;\n};\n\nexport type FlagField = {\n type: \"flag\";\n defaultValue?: boolean;\n disabled?: boolean;\n options?: {\n onChange?: (f: boolean, e: React.FormEvent<HTMLInputElement>) => void;\n };\n};\n\nexport type MultiTextField = {\n type: \"multitext\";\n defaultValue?: string[];\n options?: {\n placeholder?: string;\n };\n};\n\nexport type PagesField = {\n type: \"pages\";\n defaultValue?: string[];\n};\n\nexport type SelectField = {\n type: \"select\";\n defaultValue?: string;\n options: {\n items: string[] | (() => string[]);\n };\n};\n\nexport type BlockField = {\n type: \"block\";\n defaultValue?: InputTextNode;\n};\n\nexport type BlocksField = {\n type: \"blocks\";\n defaultValue?: InputTextNode[];\n};\n\nexport type CustomField = {\n type: \"custom\";\n defaultValue?: InputTextNode[];\n options: {\n component: React.FC<{\n parentUid: string;\n uid: string;\n defaultValue: InputTextNode[];\n title: string;\n }>;\n };\n};\n\nexport type ArrayField =\n | PagesField\n | MultiTextField\n | CustomField\n | BlocksField;\nexport type UnionField =\n | ArrayField\n | TextField\n | TimeField\n | NumberField\n | OauthField\n | FlagField\n | SelectField\n | BlockField;\n\nexport type Field<T extends UnionField> = Omit<T, \"type\"> & {\n title: string;\n description: string;\n Panel: FieldPanel<T>;\n};\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.83.6",
4
+ "version": "0.84.0",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "scripts": {
@@ -1,2 +1,2 @@
1
- declare const createTagRegex: (tag: string) => RegExp;
1
+ declare const createTagRegex: (title: string) => RegExp;
2
2
  export default createTagRegex;
@@ -1,5 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const createTagRegex = (tag) => new RegExp(`#?\\[\\[${tag}\\]\\]|#${tag}`);
3
+ const createTagRegex = (title) => {
4
+ const escapedTitle = title.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
5
+ return new RegExp(`(?:#\\[\\[${escapedTitle}\\]\\]|#${escapedTitle}(?!\\w)|\\[\\[${escapedTitle}\\]\\])`);
6
+ };
4
7
  exports.default = createTagRegex;
5
8
  //# sourceMappingURL=createTagRegex.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createTagRegex.js","sourceRoot":"","sources":["../../src/util/createTagRegex.ts"],"names":[],"mappings":";;AAAA,MAAM,cAAc,GAAG,CAAC,GAAW,EAAU,EAAE,CAC7C,IAAI,MAAM,CAAC,WAAW,GAAG,WAAW,GAAG,EAAE,CAAC,CAAC;AAE7C,kBAAe,cAAc,CAAC","sourcesContent":["const createTagRegex = (tag: string): RegExp =>\n new RegExp(`#?\\\\[\\\\[${tag}\\\\]\\\\]|#${tag}`);\n\nexport default createTagRegex;\n"]}
1
+ {"version":3,"file":"createTagRegex.js","sourceRoot":"","sources":["../../src/util/createTagRegex.ts"],"names":[],"mappings":";;AAAA,MAAM,cAAc,GAAG,CAAC,KAAa,EAAU,EAAE;IAC/C,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;IAClE,OAAO,IAAI,MAAM,CACf,aAAa,YAAY,WAAW,YAAY,iBAAiB,YAAY,SAAS,CACvF,CAAC;AACJ,CAAC,CAAC;AACF,kBAAe,cAAc,CAAC","sourcesContent":["const createTagRegex = (title: string): RegExp => {\n const escapedTitle = title.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n return new RegExp(\n `(?:#\\\\[\\\\[${escapedTitle}\\\\]\\\\]|#${escapedTitle}(?!\\\\w)|\\\\[\\\\[${escapedTitle}\\\\]\\\\])`\n );\n};\nexport default createTagRegex;\n"]}