roamjs-components 0.84.1 → 0.85.1

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,10 +1,17 @@
1
- import { IButtonProps } from "@blueprintjs/core";
2
- import { SelectProps } from "@blueprintjs/select";
3
- import React from "react";
4
- declare const MenuItemSelect: <T extends React.ReactText>(props: Omit<SelectProps<T>, "itemRenderer"> & {
5
- ButtonProps?: (IButtonProps<HTMLButtonElement> & React.ButtonHTMLAttributes<HTMLButtonElement>) | undefined;
6
- } & {
7
- emptyValueText?: string | undefined;
8
- transformItem?: ((s: T) => React.ReactNode) | undefined;
9
- }) => JSX.Element;
1
+ import { ButtonProps } from "@blueprintjs/core";
2
+ import { SelectProps, ICreateNewItem } from "@blueprintjs/select";
3
+ import React, { ReactText, ButtonHTMLAttributes, ReactNode } from "react";
4
+ declare type ActiveItem<T> = T | ICreateNewItem | null | undefined;
5
+ declare type TransformItem<T> = (s: T) => ReactNode;
6
+ declare type MenuItemSelectProps<T extends ReactText> = Omit<SelectProps<T>, "itemRenderer"> & {
7
+ ButtonProps?: ButtonProps & ButtonHTMLAttributes<HTMLButtonElement>;
8
+ emptyValueText?: string;
9
+ transformItem?: TransformItem<T>;
10
+ children?: (props: {
11
+ activeItem: ActiveItem<T>;
12
+ emptyValueText?: string;
13
+ transformItem?: TransformItem<T>;
14
+ }) => ReactNode;
15
+ };
16
+ declare const MenuItemSelect: <T extends React.ReactText>(props: MenuItemSelectProps<T>) => JSX.Element;
10
17
  export default MenuItemSelect;
@@ -10,9 +10,15 @@ const MenuItemSelect = (props) => {
10
10
  const text = props.transformItem ? props.transformItem(item) : item;
11
11
  return String(text).toLowerCase().includes(query.toLowerCase());
12
12
  };
13
- const { activeItem, filterable = false } = props, selectProps = tslib_1.__rest(props, ["activeItem", "filterable"]);
14
- return (react_1.default.createElement(TypeSelect, Object.assign({}, selectProps, { itemRenderer: (item, { modifiers, handleClick }) => (react_1.default.createElement(core_1.MenuItem, { key: item, text: props.transformItem ? props.transformItem(item) : item, active: modifiers.active, onClick: handleClick })), filterable: filterable, itemPredicate: props.filterable ? itemPredicate : undefined, popoverProps: Object.assign({ minimal: true, captureDismiss: true }, props.popoverProps) }),
15
- react_1.default.createElement(core_1.Button, Object.assign({ text: activeItem ? (props.transformItem ? (props.transformItem(activeItem)) : (activeItem)) : (react_1.default.createElement("i", { style: { opacity: 0.5 } }, props.emptyValueText || "Choose...")), rightIcon: "double-caret-vertical" }, props.ButtonProps))));
13
+ const { activeItem, filterable = false, children, transformItem, emptyValueText } = props, selectProps = tslib_1.__rest(props, ["activeItem", "filterable", "children", "transformItem", "emptyValueText"]);
14
+ const defaultButton = (react_1.default.createElement(core_1.Button, Object.assign({ text: activeItem ? (transformItem ? (transformItem(activeItem)) : (activeItem)) : (react_1.default.createElement("span", { className: "opacity-50 italic" }, emptyValueText || "Choose...")), rightIcon: "double-caret-vertical" }, props.ButtonProps)));
15
+ return (react_1.default.createElement(TypeSelect, Object.assign({}, selectProps, { itemRenderer: (item, { modifiers, handleClick }) => (react_1.default.createElement(core_1.MenuItem, { key: item, text: transformItem ? transformItem(item) : item, active: modifiers.active, onClick: handleClick })), filterable: filterable, itemPredicate: filterable ? itemPredicate : undefined, popoverProps: Object.assign({ minimal: true, captureDismiss: true }, props.popoverProps) }), children
16
+ ? children({
17
+ activeItem,
18
+ emptyValueText,
19
+ transformItem,
20
+ })
21
+ : defaultButton));
16
22
  };
17
23
  exports.default = MenuItemSelect;
18
24
  //# sourceMappingURL=MenuItemSelect.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MenuItemSelect.js","sourceRoot":"","sources":["../../src/components/MenuItemSelect.tsx"],"names":[],"mappings":";;;AAAA,4CAAmE;AACnE,gDAA0D;AAC1D,0DAAyC;AAEzC,MAAM,cAAc,GAAG,CACrB,KAE0E,EAC7D,EAAE;IACf,MAAM,UAAU,GAAG,eAAM,CAAC,MAAM,EAAK,CAAC;IACtC,MAAM,aAAa,GAA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cAAc,IAAI,WAAW,CAClC,CACL,EAEH,SAAS,EAAC,uBAAuB,IAC7B,KAAK,CAAC,WAAW,EACrB,CACS,CACd,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,cAAc,CAAC","sourcesContent":["import { Button, IButtonProps, MenuItem } from \"@blueprintjs/core\";\nimport { SelectProps, Select } from \"@blueprintjs/select\";\nimport React, { ReactText } from \"react\";\n\nconst MenuItemSelect = <T extends ReactText>(\n props: Omit<SelectProps<T>, \"itemRenderer\"> & {\n ButtonProps?: IButtonProps & React.ButtonHTMLAttributes<HTMLButtonElement>;\n } & { emptyValueText?: string; transformItem?: (s: T) => React.ReactNode }\n): JSX.Element => {\n const TypeSelect = Select.ofType<T>();\n const itemPredicate = (query: string, item: T) => {\n const text = props.transformItem ? props.transformItem(item) : item;\n return String(text).toLowerCase().includes(query.toLowerCase());\n };\n const { activeItem, filterable = false, ...selectProps } = props;\n return (\n <TypeSelect\n {...selectProps}\n itemRenderer={(item, { modifiers, handleClick }) => (\n <MenuItem\n key={item}\n text={props.transformItem ? props.transformItem(item) : item}\n active={modifiers.active}\n onClick={handleClick}\n />\n )}\n filterable={filterable}\n itemPredicate={props.filterable ? itemPredicate : undefined}\n popoverProps={{\n minimal: true,\n captureDismiss: true,\n ...props.popoverProps,\n }}\n >\n <Button\n text={\n activeItem ? (\n props.transformItem ? (\n props.transformItem(activeItem as T)\n ) : (\n activeItem\n )\n ) : (\n <i style={{ opacity: 0.5 }}>\n {props.emptyValueText || \"Choose...\"}\n </i>\n )\n }\n rightIcon=\"double-caret-vertical\"\n {...props.ButtonProps}\n />\n </TypeSelect>\n );\n};\n\nexport default MenuItemSelect;\n"]}
1
+ {"version":3,"file":"MenuItemSelect.js","sourceRoot":"","sources":["../../src/components/MenuItemSelect.tsx"],"names":[],"mappings":";;;AAAA,4CAAkE;AAClE,gDAA0E;AAC1E,0DAA0E;AAkB1E,MAAM,cAAc,GAAG,CACrB,KAA6B,EAChB,EAAE;IACf,MAAM,UA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AC,aAAa,CAAC,CAAC,CAAC,SAAS,EACrD,YAAY,kBACV,OAAO,EAAE,IAAI,EACb,cAAc,EAAE,IAAI,IACjB,KAAK,CAAC,YAAY,MAGtB,QAAQ;QACP,CAAC,CAAC,QAAQ,CAAC;YACP,UAAU;YACV,cAAc;YACd,aAAa;SACd,CAAC;QACJ,CAAC,CAAC,aAAa,CACN,CACd,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,cAAc,CAAC","sourcesContent":["import { Button, ButtonProps, MenuItem } from \"@blueprintjs/core\";\nimport { SelectProps, Select, ICreateNewItem } from \"@blueprintjs/select\";\nimport React, { ReactText, ButtonHTMLAttributes, ReactNode } from \"react\";\n\ntype ActiveItem<T> = T | ICreateNewItem | null | undefined;\ntype TransformItem<T> = (s: T) => ReactNode;\ntype MenuItemSelectProps<T extends ReactText> = Omit<\n SelectProps<T>,\n \"itemRenderer\"\n> & {\n ButtonProps?: ButtonProps & ButtonHTMLAttributes<HTMLButtonElement>;\n emptyValueText?: string;\n transformItem?: TransformItem<T>;\n children?: (props: {\n activeItem: ActiveItem<T>;\n emptyValueText?: string;\n transformItem?: TransformItem<T>;\n }) => ReactNode;\n};\n\nconst MenuItemSelect = <T extends ReactText>(\n props: MenuItemSelectProps<T>\n): JSX.Element => {\n const TypeSelect = Select.ofType<T>();\n const itemPredicate = (query: string, item: T) => {\n const text = props.transformItem ? props.transformItem(item) : item;\n return String(text).toLowerCase().includes(query.toLowerCase());\n };\n const {\n activeItem,\n filterable = false,\n children,\n transformItem,\n emptyValueText,\n ...selectProps\n } = props;\n\n const defaultButton = (\n <Button\n text={\n activeItem ? (\n transformItem ? (\n transformItem(activeItem as T)\n ) : (\n activeItem\n )\n ) : (\n <span className=\"opacity-50 italic\">\n {emptyValueText || \"Choose...\"}\n </span>\n )\n }\n rightIcon=\"double-caret-vertical\"\n {...props.ButtonProps}\n />\n );\n\n return (\n <TypeSelect\n {...selectProps}\n itemRenderer={(item, { modifiers, handleClick }) => (\n <MenuItem\n key={item}\n text={transformItem ? transformItem(item) : item}\n active={modifiers.active}\n onClick={handleClick}\n />\n )}\n filterable={filterable}\n itemPredicate={filterable ? itemPredicate : undefined}\n popoverProps={{\n minimal: true,\n captureDismiss: true,\n ...props.popoverProps,\n }}\n >\n {children\n ? children({\n activeItem,\n emptyValueText,\n transformItem,\n })\n : defaultButton}\n </TypeSelect>\n );\n};\n\nexport default MenuItemSelect;\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.84.1",
4
+ "version": "0.85.1",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "scripts": {
@@ -1,14 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const getCurrentUser_1 = tslib_1.__importDefault(require("./getCurrentUser"));
4
+ const getCurrentUserUid_1 = tslib_1.__importDefault(require("./getCurrentUserUid"));
5
+ const getDisplayNameByUid_1 = tslib_1.__importDefault(require("./getDisplayNameByUid"));
5
6
  const getCurrentUserDisplayName = () => {
6
- const userArray = (0, getCurrentUser_1.default)();
7
- const uidIndex = userArray.findIndex((s) => s === "~:display-name");
8
- if (uidIndex > 0) {
9
- return userArray[uidIndex + 1] || "";
10
- }
11
- return "";
7
+ const uid = (0, getCurrentUserUid_1.default)();
8
+ return (0, getDisplayNameByUid_1.default)(uid);
12
9
  };
13
10
  exports.default = getCurrentUserDisplayName;
14
11
  //# sourceMappingURL=getCurrentUserDisplayName.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getCurrentUserDisplayName.js","sourceRoot":"","sources":["../../src/queries/getCurrentUserDisplayName.ts"],"names":[],"mappings":";;;AAAA,8EAA8C;AAE9C,MAAM,yBAAyB,GAAG,GAAW,EAAE;IAC7C,MAAM,SAAS,GAAG,IAAA,wBAAc,GAAE,CAAC;IACnC,MAAM,QAAQ,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,gBAAgB,CAAC,CAAC;IACpE,IAAI,QAAQ,GAAG,CAAC,EAAE;QAChB,OAAO,SAAS,CAAC,QAAQ,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;KACtC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAEF,kBAAe,yBAAyB,CAAC","sourcesContent":["import getCurrentUser from \"./getCurrentUser\";\n\nconst getCurrentUserDisplayName = (): string => {\n const userArray = getCurrentUser();\n const uidIndex = userArray.findIndex((s) => s === \"~:display-name\");\n if (uidIndex > 0) {\n return userArray[uidIndex + 1] || \"\";\n }\n return \"\";\n};\n\nexport default getCurrentUserDisplayName;\n"]}
1
+ {"version":3,"file":"getCurrentUserDisplayName.js","sourceRoot":"","sources":["../../src/queries/getCurrentUserDisplayName.ts"],"names":[],"mappings":";;;AAAA,oFAAoD;AACpD,wFAAwD;AAExD,MAAM,yBAAyB,GAAG,GAAW,EAAE;IAC7C,MAAM,GAAG,GAAG,IAAA,2BAAiB,GAAE,CAAC;IAChC,OAAO,IAAA,6BAAmB,EAAC,GAAG,CAAC,CAAC;AAClC,CAAC,CAAC;AAEF,kBAAe,yBAAyB,CAAC","sourcesContent":["import getCurrentUserUid from \"./getCurrentUserUid\";\nimport getDisplayNameByUid from \"./getDisplayNameByUid\";\n\nconst getCurrentUserDisplayName = (): string => {\n const uid = getCurrentUserUid();\n return getDisplayNameByUid(uid);\n};\n\nexport default getCurrentUserDisplayName;\n"]}