@vendorflow/components 2.0.41 → 2.0.45

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 (35) hide show
  1. package/lib/components/index.d.ts +0 -1
  2. package/lib/components/index.js +1 -3
  3. package/lib/components/material-ui/ChatInterface/ChatInterface.d.ts +2 -0
  4. package/lib/components/material-ui/ChatInterface/ChatInterface.js +1 -1
  5. package/lib/components/material-ui/ChatInterface/ChatInterface.story.js +15 -4
  6. package/lib/components/material-ui/ChatInterface/MessageItem.js +2 -3
  7. package/lib/components/material-ui/ChatInterface/MessageThread.d.ts +2 -2
  8. package/lib/components/material-ui/ChatInterface/MessageThread.js +100 -4
  9. package/package.json +1 -1
  10. package/lib/TempHooks.d.ts +0 -9
  11. package/lib/TempHooks.js +0 -25
  12. package/lib/components/InfiniteScroll/InfiniteScroll.d.ts +0 -16
  13. package/lib/components/InfiniteScroll/InfiniteScroll.js +0 -135
  14. package/lib/components/InfiniteScroll/index.d.ts +0 -1
  15. package/lib/components/InfiniteScroll/index.js +0 -8
  16. package/lib/components/blueprint/InputGroup/InputGroup.d.ts +0 -20
  17. package/lib/components/blueprint/InputGroup/InputGroup.js +0 -13
  18. package/lib/components/blueprint/InputGroup/InputGroup.story.d.ts +0 -2
  19. package/lib/components/blueprint/InputGroup/InputGroup.story.js +0 -11
  20. package/lib/components/blueprint/InputGroup/index.d.ts +0 -1
  21. package/lib/components/blueprint/InputGroup/index.js +0 -4
  22. package/lib/components/blueprint/InputSelect/InputSelect.d.ts +0 -51
  23. package/lib/components/blueprint/InputSelect/InputSelect.js +0 -98
  24. package/lib/components/blueprint/InputSelect/InputSelect.story.d.ts +0 -3
  25. package/lib/components/blueprint/InputSelect/InputSelect.story.js +0 -19
  26. package/lib/components/blueprint/InputSelect/index.d.ts +0 -1
  27. package/lib/components/blueprint/InputSelect/index.js +0 -4
  28. package/lib/components/blueprint/InputTime/InputTime.d.ts +0 -24
  29. package/lib/components/blueprint/InputTime/InputTime.js +0 -28
  30. package/lib/components/blueprint/InputTime/InputTime.story.d.ts +0 -2
  31. package/lib/components/blueprint/InputTime/InputTime.story.js +0 -11
  32. package/lib/components/blueprint/InputTime/index.d.ts +0 -1
  33. package/lib/components/blueprint/InputTime/index.js +0 -4
  34. package/lib/services/Select.service.d.ts +0 -5
  35. package/lib/services/Select.service.js +0 -67
@@ -10,5 +10,4 @@ export { default as InputCheckboxGroup } from './material-ui/InputCheckboxGroup'
10
10
  export { default as InputRadioGroup } from './material-ui/InputRadioGroup';
11
11
  export { default as InputSearchDropdown } from './material-ui/InputSearchDropdown';
12
12
  export { default as InputTime } from './material-ui/InputTime';
13
- export { default as InfiniteScroll } from './InfiniteScroll';
14
13
  export { default as Modal } from './material-ui/Modal';
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Modal = exports.InfiniteScroll = exports.InputTime = exports.InputSearchDropdown = exports.InputRadioGroup = exports.InputCheckboxGroup = exports.InputGroup = exports.InputDateTime = exports.InputDate = exports.DataTable = exports.ColorPicker = exports.ChatInterface = exports.ButtonMenu = exports.Button = void 0;
6
+ exports.Modal = exports.InputTime = exports.InputSearchDropdown = exports.InputRadioGroup = exports.InputCheckboxGroup = exports.InputGroup = exports.InputDateTime = exports.InputDate = exports.DataTable = exports.ColorPicker = exports.ChatInterface = exports.ButtonMenu = exports.Button = void 0;
7
7
  var Button_1 = require("./material-ui/Button");
8
8
  Object.defineProperty(exports, "Button", { enumerable: true, get: function () { return __importDefault(Button_1).default; } });
9
9
  var ButtonMenu_1 = require("./material-ui/ButtonMenu");
@@ -28,7 +28,5 @@ var InputSearchDropdown_1 = require("./material-ui/InputSearchDropdown");
28
28
  Object.defineProperty(exports, "InputSearchDropdown", { enumerable: true, get: function () { return __importDefault(InputSearchDropdown_1).default; } });
29
29
  var InputTime_1 = require("./material-ui/InputTime");
30
30
  Object.defineProperty(exports, "InputTime", { enumerable: true, get: function () { return __importDefault(InputTime_1).default; } });
31
- var InfiniteScroll_1 = require("./InfiniteScroll");
32
- Object.defineProperty(exports, "InfiniteScroll", { enumerable: true, get: function () { return __importDefault(InfiniteScroll_1).default; } });
33
31
  var Modal_1 = require("./material-ui/Modal");
34
32
  Object.defineProperty(exports, "Modal", { enumerable: true, get: function () { return __importDefault(Modal_1).default; } });
@@ -3,6 +3,8 @@ export interface Message {
3
3
  id: string;
4
4
  userId: string;
5
5
  username: string;
6
+ /** use for building chat icon */
7
+ initials: string;
6
8
  timestamp: string;
7
9
  content: string;
8
10
  }
@@ -101,7 +101,7 @@ function ChatInterface(_a) {
101
101
  } }, function (_a) {
102
102
  var measureRef = _a.measureRef;
103
103
  return ((0, react_1.jsx)(react_2.Fragment, null,
104
- (0, react_1.jsx)(MessageThread_1.default, { userId: userId, messages: messages, inputHeight: inputHeight, hasNextPage: hasNextPage, fetchNextPage: fetchNextPage, isLoading: isLoading, isFetching: isFetching, colors: colors }),
104
+ (0, react_1.jsx)(MessageThread_1.default, { userId: userId, messages: messages, inputHeight: inputHeight, hasNextPage: hasNextPage, fetchNextPage: fetchNextPage, isLoading: isLoading, isFetching: isFetching, isSubmitting: isSubmitting, colors: colors }),
105
105
  renderInputComponent ? (renderInputComponent(measureRef)) : ((0, react_1.jsx)(MessageInput_1.default, { ref: measureRef, handleClickSend: handleClickSend, message: message, setMessage: setMessage, isSubmitting: isSubmitting, placeholder: placeholder }))));
106
106
  })));
107
107
  }
@@ -63,16 +63,24 @@ function ChatInterface() {
63
63
  {
64
64
  id: 'user1',
65
65
  name: 'Socorro Aguilar',
66
+ initials: 'SA',
66
67
  },
67
68
  {
68
69
  id: 'user2',
69
70
  name: 'Greg Bujak',
71
+ initials: 'GB',
72
+ },
73
+ {
74
+ id: 'user3',
75
+ name: 'xinyi@vendorflow.co',
76
+ initials: 'X',
70
77
  },
71
78
  ]);
72
79
  return {
73
80
  id: generateId(),
74
81
  userId: user.id,
75
82
  username: user.name,
83
+ initials: user.initials,
76
84
  timestamp: generateTimestamp(),
77
85
  content: faker_1.default.lorem.sentence(5, 2),
78
86
  };
@@ -80,15 +88,16 @@ function ChatInterface() {
80
88
  function generateMessagePage() {
81
89
  return new Array(10).fill(null).map(generateMessage);
82
90
  }
83
- function loadMore() {
91
+ var fetchNextPage = (0, react_2.useCallback)(function () {
84
92
  setFetching(true);
85
93
  setTimeout(function () {
86
94
  setMessages(__spreadArray(__spreadArray([], __read(messages), false), __read(generateMessagePage()), false));
87
95
  setFetching(false);
88
96
  }, 100);
89
- }
97
+ }, [messages, generateMessagePage, setMessages]);
90
98
  function handleSend(message) {
91
99
  setSubmitting(true);
100
+ setFetching(true);
92
101
  return new Promise(function (resolve) {
93
102
  setTimeout(function () {
94
103
  setMessages(__spreadArray([
@@ -96,17 +105,19 @@ function ChatInterface() {
96
105
  id: generateId(),
97
106
  userId: 'user1',
98
107
  username: 'Socorro Aguilar',
108
+ initials: 'SA',
99
109
  timestamp: generateTimestamp(),
100
110
  content: message,
101
111
  }
102
112
  ], __read(messages), false));
103
113
  setSubmitting(false);
114
+ setFetching(false);
104
115
  resolve(true);
105
116
  }, 500);
106
117
  });
107
118
  }
108
- return ((0, react_1.jsx)("div", { css: (0, react_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n border: 1px solid #ededed;\n height: 50rem;\n "], ["\n border: 1px solid #ededed;\n height: 50rem;\n "]))) },
109
- (0, react_1.jsx)(ChatInterface_1.default, { userId: "user1", messages: messages, handleSend: handleSend, fetchNextPage: loadMore, hasNextPage: hasMore, isLoading: isLoading, isFetching: isFetching, isSubmitting: isSubmitting })));
119
+ return ((0, react_1.jsx)("div", { css: (0, react_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n border: 1px solid #ededed;\n height: 30rem;\n "], ["\n border: 1px solid #ededed;\n height: 30rem;\n "]))) },
120
+ (0, react_1.jsx)(ChatInterface_1.default, { userId: "user1", messages: messages, handleSend: handleSend, fetchNextPage: fetchNextPage, hasNextPage: hasMore, isLoading: isLoading, isFetching: isFetching, isSubmitting: isSubmitting })));
110
121
  }
111
122
  exports.ChatInterface = ChatInterface;
112
123
  var templateObject_1;
@@ -56,11 +56,10 @@ function MessageItem(_a) {
56
56
  return ((0, react_1.jsx)("div", { css: (0, react_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: 100%;\n background: white;\n margin-top: 0.5rem;\n border-radius: 4px;\n display: flex;\n flex-direction: row;\n "], ["\n width: 100%;\n background: white;\n margin-top: 0.5rem;\n border-radius: 4px;\n display: flex;\n flex-direction: row;\n "]))) },
57
57
  (0, react_1.jsx)(material_1.Avatar, { css: function (theme) {
58
58
  var _a, _b, _c, _d, _e;
59
- return (0, react_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n && {\n height: 2rem;\n width: 2rem;\n margin-right: 0.5rem;\n background-color: ", ";\n }\n "], ["\n && {\n height: 2rem;\n width: 2rem;\n margin-right: 0.5rem;\n background-color: ", ";\n }\n "])), userId === message.userId
59
+ return (0, react_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n && {\n font-size: 1rem;\n height: 2rem;\n width: 2rem;\n margin-right: 0.5rem;\n background-color: ", ";\n }\n "], ["\n && {\n font-size: 1rem;\n height: 2rem;\n width: 2rem;\n margin-right: 0.5rem;\n background-color: ", ";\n }\n "])), userId === message.userId
60
60
  ? (colors === null || colors === void 0 ? void 0 : colors.user) || ((_c = (_b = (_a = theme === null || theme === void 0 ? void 0 : theme.custom) === null || _a === void 0 ? void 0 : _a.palette) === null || _b === void 0 ? void 0 : _b.tertiary) === null || _c === void 0 ? void 0 : _c.main) || 'hsl(0, 0%, 89%)'
61
61
  : (colors === null || colors === void 0 ? void 0 : colors.others) || ((_e = (_d = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _d === void 0 ? void 0 : _d.primary) === null || _e === void 0 ? void 0 : _e.main) || 'hsl(0, 0%, 47%)');
62
- } },
63
- (0, react_1.jsx)(icons_material_1.Person, null)),
62
+ } }, message.initials === '' ? (0, react_1.jsx)(icons_material_1.Person, null) : message.initials),
64
63
  (0, react_1.jsx)("div", null,
65
64
  (0, react_1.jsx)("div", { css: (0, react_1.css)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n display: flex;\n flex-direction: row;\n justify-content: flex-start;\n align-items: flex-start;\n "], ["\n display: flex;\n flex-direction: row;\n justify-content: flex-start;\n align-items: flex-start;\n "]))) },
66
65
  (0, react_1.jsx)("div", { css: (0, react_1.css)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n font-weight: 700;\n font-size: 0.75rem;\n display: inline-block;\n margin-right: 0.25rem;\n "], ["\n font-weight: 700;\n font-size: 0.75rem;\n display: inline-block;\n margin-right: 0.25rem;\n "]))) }, message.username),
@@ -1,6 +1,6 @@
1
1
  import { ChatInterfaceProps } from './ChatInterface';
2
- interface Props extends Pick<ChatInterfaceProps, 'userId' | 'messages' | 'hasNextPage' | 'fetchNextPage' | 'isLoading' | 'isFetching' | 'colors'> {
2
+ interface Props extends Pick<ChatInterfaceProps, 'userId' | 'messages' | 'hasNextPage' | 'fetchNextPage' | 'isLoading' | 'isFetching' | 'isSubmitting' | 'colors'> {
3
3
  inputHeight: number;
4
4
  }
5
- export default function MessageThread({ userId, messages, inputHeight, hasNextPage, fetchNextPage, isLoading, isFetching, colors, }: Props): JSX.Element;
5
+ export default function MessageThread({ userId, messages, inputHeight, hasNextPage, fetchNextPage, isLoading, isFetching, isSubmitting, colors, }: Props): JSX.Element;
6
6
  export {};
@@ -12,12 +12,108 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  var react_1 = require("@emotion/react");
13
13
  var react_2 = require("react");
14
14
  var MessageItem_1 = __importDefault(require("./MessageItem"));
15
- var InfiniteScroll_1 = __importDefault(require("../../InfiniteScroll/InfiniteScroll"));
15
+ var lodash_1 = require("lodash");
16
+ var material_1 = require("@mui/material");
16
17
  function MessageThread(_a) {
17
- var userId = _a.userId, messages = _a.messages, inputHeight = _a.inputHeight, hasNextPage = _a.hasNextPage, fetchNextPage = _a.fetchNextPage, isLoading = _a.isLoading, isFetching = _a.isFetching, colors = _a.colors;
18
+ var _b;
19
+ var userId = _a.userId, messages = _a.messages, inputHeight = _a.inputHeight, hasNextPage = _a.hasNextPage, fetchNextPage = _a.fetchNextPage, isLoading = _a.isLoading, isFetching = _a.isFetching, isSubmitting = _a.isSubmitting, colors = _a.colors;
20
+ var isInitialized = (0, react_2.useRef)(false);
21
+ var isScrollLoad = (0, react_2.useRef)(false);
22
+ var hasSubmitted = (0, react_2.useRef)(false);
23
+ var prevScrollTop = (0, react_2.useRef)(null);
24
+ var prevScrollHeight = (0, react_2.useRef)(null);
25
+ var shouldScrollToPrevPosition = (0, react_2.useRef)(false);
18
26
  var scrollParent = (0, react_2.useRef)(null);
27
+ var handleScrollEvent = (0, react_2.useCallback)((0, lodash_1.debounce)(function (evt) {
28
+ var parent = evt.target;
29
+ if (parent.scrollTop === 0 && hasNextPage && fetchNextPage && !isLoading && !isFetching) {
30
+ isScrollLoad.current = true;
31
+ prevScrollHeight.current = parent.scrollHeight;
32
+ fetchNextPage();
33
+ }
34
+ }, 300), [hasNextPage, fetchNextPage, isLoading, isFetching]);
35
+ (0, react_2.useEffect)(function () {
36
+ if (isSubmitting) {
37
+ hasSubmitted.current = true;
38
+ }
39
+ }, [isSubmitting]);
40
+ // This will handle the initial loading of messages, then scroll to bottom
41
+ (0, react_2.useEffect)(function () {
42
+ if (!isInitialized.current && !isFetching && scrollParent.current) {
43
+ var _a = scrollParent.current, clientHeight = _a.clientHeight, scrollHeight = _a.scrollHeight;
44
+ if (clientHeight >= scrollHeight && hasNextPage && fetchNextPage) {
45
+ fetchNextPage();
46
+ return;
47
+ }
48
+ isInitialized.current = true;
49
+ scrollParent.current.scrollTo(0, scrollHeight - clientHeight);
50
+ }
51
+ }, [isFetching, isInitialized.current, hasNextPage, fetchNextPage]);
52
+ // Sets up the scroll event listener
53
+ (0, react_2.useEffect)(function () {
54
+ if (scrollParent.current) {
55
+ scrollParent.current.addEventListener('scroll', handleScrollEvent);
56
+ }
57
+ return function () {
58
+ if (scrollParent.current) {
59
+ scrollParent.current.removeEventListener('scroll', handleScrollEvent);
60
+ }
61
+ };
62
+ }, [scrollParent.current, hasNextPage, fetchNextPage, isLoading, isFetching]);
63
+ // Handles the scroll position adjustment after fetching the next page
64
+ (0, react_2.useEffect)(function () {
65
+ if (!isFetching &&
66
+ isInitialized.current &&
67
+ scrollParent.current &&
68
+ isScrollLoad.current &&
69
+ prevScrollHeight.current &&
70
+ scrollParent.current.scrollHeight !== prevScrollHeight.current) {
71
+ var delta = scrollParent.current.scrollHeight - prevScrollHeight.current;
72
+ scrollParent.current.scrollTo(0, delta);
73
+ isScrollLoad.current = false;
74
+ prevScrollHeight.current = 0;
75
+ }
76
+ }, [isFetching, prevScrollHeight.current]);
77
+ // Manages scroll position for data changes that are triggered from anything other than the scroll event
78
+ (0, react_2.useEffect)(function () {
79
+ var _a;
80
+ if (scrollParent.current && !isScrollLoad.current && isInitialized.current) {
81
+ var _b = scrollParent.current, scrollHeight = _b.scrollHeight, scrollTop = _b.scrollTop, clientHeight = _b.clientHeight;
82
+ if (isFetching) {
83
+ // track the current position
84
+ prevScrollHeight.current = scrollHeight;
85
+ prevScrollTop.current = scrollTop;
86
+ var distanceFromBottom = scrollHeight - scrollTop - clientHeight;
87
+ if (!isSubmitting && distanceFromBottom > 200) {
88
+ shouldScrollToPrevPosition.current = true;
89
+ }
90
+ }
91
+ else {
92
+ // init to scroll to bottom delta
93
+ var delta = scrollHeight - clientHeight;
94
+ if (hasSubmitted.current) {
95
+ // scroll to bottom if this was triggered by the current user's sent message
96
+ (_a = scrollParent.current) === null || _a === void 0 ? void 0 : _a.scrollTo(0, delta);
97
+ }
98
+ else if (!isFetching && prevScrollHeight.current !== null && prevScrollTop.current !== null) {
99
+ if (shouldScrollToPrevPosition.current) {
100
+ delta = prevScrollTop.current;
101
+ }
102
+ scrollParent.current.scrollTo(0, delta);
103
+ }
104
+ // clean up
105
+ prevScrollHeight.current = null;
106
+ prevScrollTop.current = null;
107
+ hasSubmitted.current = false;
108
+ shouldScrollToPrevPosition.current = false;
109
+ }
110
+ }
111
+ }, [isFetching, (_b = scrollParent.current) === null || _b === void 0 ? void 0 : _b.scrollHeight]);
19
112
  return ((0, react_1.jsx)("div", { ref: scrollParent, css: (0, react_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n box-sizing: border-box;\n height: calc(100% - ", "px);\n width: 100%;\n padding: 0.5rem 1rem;\n overflow-y: auto;\n "], ["\n box-sizing: border-box;\n height: calc(100% - ", "px);\n width: 100%;\n padding: 0.5rem 1rem;\n overflow-y: auto;\n "])), inputHeight) },
20
- (0, react_1.jsx)(InfiniteScroll_1.default, { scrollParent: scrollParent, isReverse: true, isLoading: isLoading, isFetching: isFetching, hasNextPage: hasNextPage, fetchNextPage: fetchNextPage }, messages.map(function (message) { return ((0, react_1.jsx)(MessageItem_1.default, { key: "" + message.id, message: message, userId: userId, colors: colors })); }))));
113
+ (0, react_1.jsx)("div", { css: (0, react_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n flex-direction: column-reverse;\n justify-content: flex-start;\n align-items: flex-start;\n "], ["\n display: flex;\n flex-direction: column-reverse;\n justify-content: flex-start;\n align-items: flex-start;\n "]))) },
114
+ messages.map(function (message) { return ((0, react_1.jsx)(MessageItem_1.default, { key: "" + message.id, message: message, userId: userId, colors: colors })); }),
115
+ hasNextPage && ((0, react_1.jsx)("div", { key: "loader", css: (0, react_1.css)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n width: 100%;\n margin: 0.5rem 0;\n height: auto;\n display: flex;\n justify-content: center;\n align-items: center;\n\n && {\n visibility: ", ";\n }\n "], ["\n width: 100%;\n margin: 0.5rem 0;\n height: auto;\n display: flex;\n justify-content: center;\n align-items: center;\n\n && {\n visibility: ", ";\n }\n "])), isFetching && isScrollLoad ? 'visible' : 'hidden') },
116
+ (0, react_1.jsx)(material_1.CircularProgress, { size: "1.5rem", disableShrink: true }))))));
21
117
  }
22
118
  exports.default = MessageThread;
23
- var templateObject_1;
119
+ var templateObject_1, templateObject_2, templateObject_3;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vendorflow/components",
3
- "version": "2.0.41",
3
+ "version": "2.0.45",
4
4
  "description": "React components for vendorflow",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -1,9 +0,0 @@
1
- import { RefObject } from 'react';
2
- interface UseInfiniteScrollProps {
3
- parentEl?: RefObject<HTMLDivElement>;
4
- isLoading?: boolean;
5
- hasMore?: boolean;
6
- loadMore?: () => Promise<void> | void;
7
- }
8
- export declare function useInfiniteScroll({ parentEl, isLoading, hasMore, loadMore }: UseInfiniteScrollProps): (node: any) => void;
9
- export {};
package/lib/TempHooks.js DELETED
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useInfiniteScroll = void 0;
4
- var react_1 = require("react");
5
- function useInfiniteScroll(_a) {
6
- var parentEl = _a.parentEl, isLoading = _a.isLoading, hasMore = _a.hasMore, loadMore = _a.loadMore;
7
- var observer = (0, react_1.useRef)();
8
- return (0, react_1.useCallback)(function (node) {
9
- if (isLoading)
10
- return;
11
- if (observer.current)
12
- observer.current.disconnect();
13
- observer.current = new IntersectionObserver(function (entries) {
14
- if (entries[0].isIntersecting && hasMore && loadMore) {
15
- loadMore();
16
- }
17
- }, {
18
- root: (parentEl === null || parentEl === void 0 ? void 0 : parentEl.current) || null,
19
- threshold: 1.0,
20
- });
21
- if (node)
22
- observer.current.observe(node);
23
- }, [isLoading, hasMore, loadMore, parentEl]);
24
- }
25
- exports.useInfiniteScroll = useInfiniteScroll;
@@ -1,16 +0,0 @@
1
- /** @jsxRuntime classic */
2
- /** @jsx jsx */
3
- import { jsx } from '@emotion/react';
4
- import { MutableRefObject, ReactElement } from 'react';
5
- interface Props {
6
- children: ReactElement[];
7
- scrollParent: MutableRefObject<HTMLDivElement | null>;
8
- isLoading?: boolean;
9
- isFetching?: boolean;
10
- isReverse?: boolean;
11
- hasNextPage?: boolean;
12
- fetchNextPage?: () => Promise<any> | any;
13
- Loader?: ReactElement;
14
- }
15
- export default function InfiniteScroll({ children, scrollParent, isLoading, isFetching, isReverse, hasNextPage, fetchNextPage, Loader, }: Props): jsx.JSX.Element;
16
- export {};
@@ -1,135 +0,0 @@
1
- "use strict";
2
- var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
- if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
- return cooked;
5
- };
6
- var __read = (this && this.__read) || function (o, n) {
7
- var m = typeof Symbol === "function" && o[Symbol.iterator];
8
- if (!m) return o;
9
- var i = m.call(o), r, ar = [], e;
10
- try {
11
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
12
- }
13
- catch (error) { e = { error: error }; }
14
- finally {
15
- try {
16
- if (r && !r.done && (m = i["return"])) m.call(i);
17
- }
18
- finally { if (e) throw e.error; }
19
- }
20
- return ar;
21
- };
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- /** @jsxRuntime classic */
24
- /** @jsx jsx */
25
- var react_1 = require("@emotion/react");
26
- var react_2 = require("react");
27
- var material_1 = require("@mui/material");
28
- function InfiniteScroll(_a) {
29
- var children = _a.children, scrollParent = _a.scrollParent, isLoading = _a.isLoading, isFetching = _a.isFetching, isReverse = _a.isReverse, hasNextPage = _a.hasNextPage, fetchNextPage = _a.fetchNextPage, Loader = _a.Loader;
30
- var _b = __read((0, react_2.useState)(false), 2), isLoadMoreFetch = _b[0], setLoadMoreFetch = _b[1];
31
- var scrollBody = (0, react_2.useRef)(null);
32
- var loadMoreRef = useInfiniteScroll({
33
- scrollParent: scrollParent,
34
- scrollBody: scrollBody,
35
- isReverse: isReverse,
36
- isLoading: isLoading,
37
- isFetching: isFetching,
38
- hasNextPage: hasNextPage,
39
- fetchNextPage: fetchNextPageAndSetFlag,
40
- });
41
- (0, react_2.useEffect)(function () {
42
- if (!isFetching) {
43
- setLoadMoreFetch(false);
44
- }
45
- }, [isFetching]);
46
- function fetchNextPageAndSetFlag() {
47
- if (fetchNextPage) {
48
- fetchNextPage();
49
- setLoadMoreFetch(true);
50
- }
51
- }
52
- function renderLoader() {
53
- if (!hasNextPage) {
54
- return null;
55
- }
56
- if (Loader) {
57
- return ((0, react_1.jsx)(react_1.ClassNames, null, function (_a) {
58
- var css = _a.css;
59
- return (0, react_2.cloneElement)(Loader, {
60
- ref: loadMoreRef,
61
- className: css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n && {\n visibility: ", ";\n }\n "], ["\n && {\n visibility: ", ";\n }\n "])), isFetching && isLoadMoreFetch ? 'visible' : 'hidden'),
62
- });
63
- }));
64
- }
65
- else {
66
- return ((0, react_1.jsx)(DefaultLoader, { css: (0, react_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n && {\n visibility: ", ";\n }\n "], ["\n && {\n visibility: ", ";\n }\n "])), isFetching && isLoadMoreFetch ? 'visible' : 'hidden'), ref: loadMoreRef }));
67
- }
68
- }
69
- return ((0, react_1.jsx)("div", { css: (0, react_1.css)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n display: flex;\n flex-direction: ", ";\n justify-content: flex-start;\n align-items: flex-start;\n "], ["\n display: flex;\n flex-direction: ", ";\n justify-content: flex-start;\n align-items: flex-start;\n "])), isReverse ? 'column-reverse' : 'column'), ref: scrollBody },
70
- children,
71
- renderLoader()));
72
- }
73
- exports.default = InfiniteScroll;
74
- var DefaultLoader = (0, react_2.forwardRef)(function (_a, ref) {
75
- var className = _a.className, style = _a.style;
76
- return ((0, react_1.jsx)("div", { key: "loader", className: className, style: style, ref: ref, css: (0, react_1.css)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n width: 100%;\n margin: 0.5rem 0;\n height: auto;\n display: flex;\n justify-content: center;\n align-items: center;\n "], ["\n width: 100%;\n margin: 0.5rem 0;\n height: auto;\n display: flex;\n justify-content: center;\n align-items: center;\n "]))) },
77
- (0, react_1.jsx)(material_1.CircularProgress, { size: "1.5rem", disableShrink: true })));
78
- });
79
- function useInfiniteScroll(_a) {
80
- var _b, _c;
81
- var scrollParent = _a.scrollParent, scrollBody = _a.scrollBody, isLoading = _a.isLoading, isFetching = _a.isFetching, isReverse = _a.isReverse, hasNextPage = _a.hasNextPage, fetchNextPage = _a.fetchNextPage;
82
- var prevPosition = (0, react_2.useRef)();
83
- var observer = (0, react_2.useRef)();
84
- var _d = __read((0, react_2.useState)(false), 2), isScrollInit = _d[0], setScrollInit = _d[1];
85
- var hasScrollbar = (0, react_2.useMemo)(function () {
86
- if (scrollParent.current && scrollBody.current) {
87
- return scrollBody.current.clientHeight > scrollParent.current.clientHeight;
88
- }
89
- return false;
90
- }, [(_b = scrollParent.current) === null || _b === void 0 ? void 0 : _b.clientHeight, (_c = scrollBody.current) === null || _c === void 0 ? void 0 : _c.clientHeight]);
91
- (0, react_2.useEffect)(function () {
92
- if (!isLoading && hasScrollbar) {
93
- prevPosition.current = null;
94
- scrollToStart();
95
- }
96
- }, [isLoading, hasScrollbar]);
97
- function scrollToStart() {
98
- var _a;
99
- var scrollHeight = (scrollBody.current || { scrollHeight: 0 }).scrollHeight;
100
- var scrollToValue = isReverse ? scrollHeight : 0;
101
- (_a = scrollParent.current) === null || _a === void 0 ? void 0 : _a.scrollTo(0, scrollToValue);
102
- setScrollInit(true);
103
- }
104
- // this callback is used and fired based on the state of the element it is attached to
105
- return (0, react_2.useCallback)(function (node) {
106
- if (isLoading || isFetching) {
107
- return;
108
- }
109
- if (observer.current) {
110
- observer.current.disconnect();
111
- }
112
- observer.current = new IntersectionObserver(function (entries) {
113
- if (entries[0].isIntersecting && hasNextPage && fetchNextPage) {
114
- if (scrollBody.current && isReverse && isScrollInit) {
115
- // save the last element, so that we can scroll to it after the new data loads in
116
- prevPosition.current = scrollBody.current.clientHeight;
117
- }
118
- // load the next page
119
- fetchNextPage();
120
- }
121
- }, {
122
- root: (scrollParent === null || scrollParent === void 0 ? void 0 : scrollParent.current) || null,
123
- threshold: 1.0,
124
- });
125
- if (node) {
126
- if (isReverse && scrollParent.current && prevPosition.current != null) {
127
- // If we had a prev position, then we want to scroll to it
128
- scrollParent.current.scrollTo(0, scrollBody.current.clientHeight - prevPosition.current);
129
- prevPosition.current = null;
130
- }
131
- observer.current.observe(node);
132
- }
133
- }, [isLoading, isFetching, isReverse, hasNextPage, fetchNextPage, scrollParent, scrollBody, isScrollInit]);
134
- }
135
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
@@ -1 +0,0 @@
1
- export { default } from './InfiniteScroll';
@@ -1,8 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.default = void 0;
7
- var InfiniteScroll_1 = require("./InfiniteScroll");
8
- Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(InfiniteScroll_1).default; } });
@@ -1,20 +0,0 @@
1
- import { ChangeEvent } from 'react';
2
- import { IIntentProps, IInputGroupProps } from '@blueprintjs/core';
3
- interface Props {
4
- id?: string;
5
- className?: string;
6
- disabled?: boolean;
7
- fill?: boolean;
8
- helperText?: string;
9
- intent?: IIntentProps['intent'];
10
- label?: string;
11
- labelInfo?: string;
12
- name?: string;
13
- onChange: (evt: ChangeEvent<HTMLInputElement>) => void;
14
- placeholder?: string;
15
- type?: string;
16
- value: IInputGroupProps['value'];
17
- hideCharCount?: boolean;
18
- }
19
- export default function InputGroup(props: Props): JSX.Element;
20
- export {};
@@ -1,13 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var react_1 = __importDefault(require("react"));
7
- var core_1 = require("@blueprintjs/core");
8
- function InputGroup(props) {
9
- var id = props.id, className = props.className, disabled = props.disabled, fill = props.fill, helperText = props.helperText, intent = props.intent, label = props.label, labelInfo = props.labelInfo, name = props.name, onChange = props.onChange, placeholder = props.placeholder, _a = props.type, type = _a === void 0 ? 'text' : _a, value = props.value;
10
- return (react_1.default.createElement(core_1.FormGroup, { className: className, helperText: helperText, intent: intent, label: label, labelFor: id, labelInfo: labelInfo, disabled: disabled },
11
- react_1.default.createElement(core_1.InputGroup, { fill: fill, id: id, intent: intent, name: name, onChange: onChange, placeholder: placeholder, type: type, value: value })));
12
- }
13
- exports.default = InputGroup;
@@ -1,2 +0,0 @@
1
- /// <reference types="react" />
2
- export declare const InputGroup: () => JSX.Element;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var react_1 = __importDefault(require("react"));
7
- var addon_actions_1 = require("@storybook/addon-actions");
8
- var InputGroup_1 = __importDefault(require("./InputGroup"));
9
- exports.InputGroup = function () {
10
- return (react_1.default.createElement(InputGroup_1.default, { name: "name", label: "First Name", labelInfo: "(required)", value: "", intent: "danger", onChange: addon_actions_1.action('changed') }));
11
- };
@@ -1 +0,0 @@
1
- export { default } from './InputGroup';
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var InputGroup_1 = require("./InputGroup");
4
- exports.default = InputGroup_1.default;
@@ -1,51 +0,0 @@
1
- /// <reference types="react" />
2
- import { IIntentProps } from '@blueprintjs/core';
3
- import { ItemRenderer } from '@blueprintjs/select';
4
- import { SimpleEvent, InputValueRender, TagRender } from '../../../types/Component.types';
5
- declare type Props<T> = InputSuggestProps<T> | InputMultiSelectProps<T>;
6
- declare type InputSuggestProps<T> = {
7
- type: 'suggest';
8
- className?: string;
9
- disabled?: boolean;
10
- fill?: boolean;
11
- helperText?: string;
12
- id?: string;
13
- inputValueRenderer: InputValueRender<T>;
14
- intent?: IIntentProps['intent'];
15
- itemRenderer?: ItemRenderer<T>;
16
- items: T[];
17
- uniqueKey: string | ((item: T) => string | number);
18
- label?: string;
19
- labelInfo?: string;
20
- multi?: boolean;
21
- name?: string;
22
- onChange: (evt: SimpleEvent<T | T[]>) => void;
23
- placeholder?: string;
24
- selectedItem: T | null;
25
- selectedItems?: undefined;
26
- tagRenderer?: undefined;
27
- };
28
- declare type InputMultiSelectProps<T> = {
29
- type: 'multiselect';
30
- className?: string;
31
- disabled?: boolean;
32
- fill?: boolean;
33
- helperText?: string;
34
- id?: string;
35
- inputValueRenderer: InputValueRender<T>;
36
- intent?: IIntentProps['intent'];
37
- itemRenderer?: ItemRenderer<T>;
38
- items: T[];
39
- uniqueKey: string | ((item: T) => string | number);
40
- label?: string;
41
- labelInfo?: string;
42
- multi?: boolean;
43
- name?: string;
44
- onChange: (evt: SimpleEvent<T | T[]>) => void;
45
- placeholder?: string;
46
- selectedItem?: undefined;
47
- selectedItems: T[];
48
- tagRenderer?: TagRender<T>;
49
- };
50
- export default function InputSelect<T>(props: Props<T>): JSX.Element;
51
- export {};
@@ -1,98 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __importStar = (this && this.__importStar) || function (mod) {
14
- if (mod && mod.__esModule) return mod;
15
- var result = {};
16
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
17
- result["default"] = mod;
18
- return result;
19
- };
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- var react_1 = __importStar(require("react"));
22
- var core_1 = require("@blueprintjs/core");
23
- var select_1 = require("@blueprintjs/select");
24
- var Select_service_1 = require("../../../services/Select.service");
25
- function InputSelect(props) {
26
- var className = props.className, disabled = props.disabled, fill = props.fill, helperText = props.helperText, id = props.id, inputValueRenderer = props.inputValueRenderer, intent = props.intent, items = props.items, itemRenderer = props.itemRenderer, uniqueKey = props.uniqueKey, label = props.label, labelInfo = props.labelInfo, name = props.name, onChange = props.onChange, placeholder = props.placeholder, _a = props.selectedItem, selectedItem = _a === void 0 ? null : _a, tagRenderer = props.tagRenderer, type = props.type;
27
- var _b = react_1.useState(''), query = _b[0], setQuery = _b[1];
28
- var _c = react_1.useState(null), value = _c[0], setValue = _c[1];
29
- var _d = react_1.useState([]), values = _d[0], setValues = _d[1];
30
- react_1.useEffect(function () {
31
- if (value !== selectedItem) {
32
- setValue(selectedItem);
33
- }
34
- // eslint-disable-next-line react-hooks/exhaustive-deps
35
- }, [selectedItem]);
36
- function handleOnChange(value, _) {
37
- var newValue = null;
38
- if (type === 'multiselect') {
39
- if (isItemSelected(value)) {
40
- newValue = values.filter(function (item) { return value !== item; });
41
- }
42
- else {
43
- newValue = values.concat(value);
44
- }
45
- setValues(newValue);
46
- }
47
- else {
48
- newValue = value;
49
- setValue(newValue);
50
- }
51
- onChange({ target: { value: newValue, name: name } });
52
- }
53
- function handleOnTagRemove(_, index) {
54
- var newValues = values.filter(function (_, valueIndex) { return index !== valueIndex; });
55
- setValues(newValues);
56
- onChange({ target: { value: newValues, name: name } });
57
- }
58
- function handleOnClear() {
59
- setValues([]);
60
- onChange({ target: { value: [], name: name } });
61
- }
62
- function isItemSelected(item) {
63
- return values.indexOf(item) !== -1;
64
- }
65
- function getCommonProps() {
66
- return {
67
- disabled: disabled,
68
- fill: fill,
69
- itemPredicate: Select_service_1.getFilter(inputValueRenderer),
70
- itemRenderer: itemRenderer ||
71
- Select_service_1.getItemRenderer(uniqueKey, inputValueRenderer, type === 'multiselect' ? isItemSelected : undefined),
72
- items: items,
73
- noResults: react_1.default.createElement(core_1.MenuItem, { disabled: true, text: "No results." }),
74
- onItemSelect: handleOnChange,
75
- onQueryChange: setQuery,
76
- query: query,
77
- popoverProps: { minimal: true },
78
- };
79
- }
80
- function renderClearButton() {
81
- return values.length > 0 ? (react_1.default.createElement(core_1.Button, { icon: "cross", minimal: true, onClick: handleOnClear })) : undefined;
82
- }
83
- function renderSelectComponent() {
84
- switch (type) {
85
- case 'multiselect': {
86
- return (react_1.default.createElement(select_1.MultiSelect, __assign({}, getCommonProps(), { resetOnSelect: true, selectedItems: values, tagRenderer: tagRenderer || inputValueRenderer, tagInputProps: {
87
- onRemove: handleOnTagRemove,
88
- rightElement: renderClearButton(),
89
- tagProps: {},
90
- } })));
91
- }
92
- default:
93
- return (react_1.default.createElement(select_1.Suggest, __assign({}, getCommonProps(), { inputProps: { intent: intent, placeholder: placeholder }, inputValueRenderer: inputValueRenderer, resetOnSelect: false, selectedItem: value })));
94
- }
95
- }
96
- return (react_1.default.createElement(core_1.FormGroup, { className: className, helperText: helperText, intent: intent, label: label, labelFor: id, labelInfo: labelInfo, disabled: disabled }, renderSelectComponent()));
97
- }
98
- exports.default = InputSelect;
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- export declare const InputSuggest: () => JSX.Element;
3
- export declare const InputMultiselect: () => JSX.Element;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var react_1 = __importDefault(require("react"));
7
- var InputSelect_1 = __importDefault(require("./InputSelect"));
8
- var addon_actions_1 = require("@storybook/addon-actions");
9
- var items = [
10
- { firstName: 'Alvin', lastName: 'Kamara' },
11
- { firstName: 'Michael', lastName: 'Thomas' },
12
- { firstName: 'Todd', lastName: 'Gurley' },
13
- { firstName: 'Raheem', lastName: 'Mostert' },
14
- { firstName: 'Tyeke', lastName: 'Hill' },
15
- { firstName: 'Frank', lastName: 'Gore' },
16
- { firstName: 'Patrick', lastName: 'Willis' },
17
- ];
18
- exports.InputSuggest = function () { return (react_1.default.createElement(InputSelect_1.default, { type: "suggest", label: "Football Players", name: "player", inputValueRenderer: function (item) { return item.firstName + " " + item.lastName; }, uniqueKey: "lastName", labelInfo: "(required)", helperText: "Please select a player.", intent: "danger", items: items, onChange: addon_actions_1.action('onChange'), placeholder: "Select football player", selectedItem: null })); };
19
- exports.InputMultiselect = function () { return (react_1.default.createElement(InputSelect_1.default, { type: "multiselect", label: "Football Players", name: "player", inputValueRenderer: function (item) { return item.firstName + " " + item.lastName; }, uniqueKey: "lastName", labelInfo: "(required)", helperText: "Please select a player.", intent: "danger", items: items, onChange: addon_actions_1.action('onChange'), placeholder: "Select football player", selectedItems: [] })); };
@@ -1 +0,0 @@
1
- export { default } from './InputSelect';
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var InputSelect_1 = require("./InputSelect");
4
- exports.default = InputSelect_1.default;
@@ -1,24 +0,0 @@
1
- /// <reference types="react" />
2
- import { IIntentProps } from '@blueprintjs/core';
3
- import { TimePrecision } from '@blueprintjs/datetime';
4
- import { SimpleEvent } from '../../../types/Component.types';
5
- interface Props {
6
- className?: string;
7
- disabled?: boolean;
8
- fill?: boolean;
9
- helperText?: string;
10
- intent?: IIntentProps['intent'];
11
- label?: string;
12
- labelInfo?: string;
13
- maxTime?: Date;
14
- minTime?: Date;
15
- name?: string;
16
- onChange: (evt: SimpleEvent<Date>) => void;
17
- precision?: TimePrecision;
18
- selectAllOnFocus?: boolean;
19
- showArrowButtons?: boolean;
20
- value: Date | null;
21
- useAmPm?: boolean;
22
- }
23
- export default function InputTime(props: Props): JSX.Element;
24
- export {};
@@ -1,28 +0,0 @@
1
- "use strict";
2
- var __importStar = (this && this.__importStar) || function (mod) {
3
- if (mod && mod.__esModule) return mod;
4
- var result = {};
5
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
6
- result["default"] = mod;
7
- return result;
8
- };
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- var react_1 = __importStar(require("react"));
11
- var core_1 = require("@blueprintjs/core");
12
- var datetime_1 = require("@blueprintjs/datetime");
13
- function InputTime(props) {
14
- var className = props.className, disabled = props.disabled, helperText = props.helperText, intent = props.intent, label = props.label, labelInfo = props.labelInfo, maxTime = props.maxTime, minTime = props.minTime, name = props.name, onChange = props.onChange, precision = props.precision, selectAllOnFocus = props.selectAllOnFocus, showArrowButtons = props.showArrowButtons, useAmPm = props.useAmPm;
15
- var _a = react_1.useState(undefined), value = _a[0], setValue = _a[1];
16
- react_1.useEffect(function () {
17
- if (props.value) {
18
- setValue(props.value);
19
- }
20
- }, []);
21
- function handleOnChange(time) {
22
- setValue(time);
23
- onChange({ target: { name: name, value: time } });
24
- }
25
- return (react_1.default.createElement(core_1.FormGroup, { className: className, helperText: helperText, intent: intent, label: label, labelInfo: labelInfo, disabled: disabled },
26
- react_1.default.createElement(datetime_1.TimePicker, { disabled: disabled, onChange: handleOnChange, maxTime: maxTime, minTime: minTime, precision: precision, selectAllOnFocus: selectAllOnFocus, showArrowButtons: showArrowButtons, value: value, useAmPm: useAmPm })));
27
- }
28
- exports.default = InputTime;
@@ -1,2 +0,0 @@
1
- /// <reference types="react" />
2
- export declare const InputTime: () => JSX.Element;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var react_1 = __importDefault(require("react"));
7
- var addon_actions_1 = require("@storybook/addon-actions");
8
- var InputTime_1 = __importDefault(require("./InputTime"));
9
- exports.InputTime = function () {
10
- return (react_1.default.createElement(InputTime_1.default, { name: "time", label: "Bedtime", labelInfo: "(required)", value: null, onChange: addon_actions_1.action('changed') }));
11
- };
@@ -1 +0,0 @@
1
- export { default } from './InputTime';
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var InputTime_1 = require("./InputTime");
4
- exports.default = InputTime_1.default;
@@ -1,5 +0,0 @@
1
- /// <reference types="react" />
2
- import { IItemRendererProps } from '@blueprintjs/select';
3
- import { UniqueKey, InputValueRender } from 'types/Component.types';
4
- export declare function getFilter<T>(inputValueRenderer: InputValueRender<T>): (query: string, item: T, index?: number | undefined, exactMatch?: boolean | undefined) => boolean;
5
- export declare function getItemRenderer<T>(uniqueKey: UniqueKey<T>, inputValueRenderer: InputValueRender<T>, isItemSelected?: (item: T) => boolean): (item: T, { handleClick, modifiers, query }: IItemRendererProps) => JSX.Element | null;
@@ -1,67 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var react_1 = __importDefault(require("react"));
7
- var core_1 = require("@blueprintjs/core");
8
- function escapeRegExpChars(text) {
9
- return text.replace(/([.*+?^=!:${}()|[\]/\\])/g, '\\$1');
10
- }
11
- function highlightText(text, query) {
12
- var lastIndex = 0;
13
- var words = query
14
- .split(/\s+/)
15
- .filter(function (word) { return word.length > 0; })
16
- .map(escapeRegExpChars);
17
- if (words.length === 0) {
18
- return [text];
19
- }
20
- var regexp = new RegExp(words.join('|'), 'gi');
21
- var tokens = [];
22
- while (true) {
23
- var match = regexp.exec(text);
24
- if (!match) {
25
- break;
26
- }
27
- var length_1 = match[0].length;
28
- var before = text.slice(lastIndex, regexp.lastIndex - length_1);
29
- if (before.length > 0) {
30
- tokens.push(before);
31
- }
32
- lastIndex = regexp.lastIndex;
33
- tokens.push(react_1.default.createElement("strong", { key: lastIndex }, match[0]));
34
- }
35
- var rest = text.slice(lastIndex);
36
- if (rest.length > 0) {
37
- tokens.push(rest);
38
- }
39
- return tokens;
40
- }
41
- function getFilter(inputValueRenderer) {
42
- return function filterItems(query, item, index, exactMatch) {
43
- return exactMatch
44
- ? inputValueRenderer(item).toLowerCase() === query.toLowerCase()
45
- : inputValueRenderer(item).toLowerCase().includes(query.toLowerCase());
46
- };
47
- }
48
- exports.getFilter = getFilter;
49
- function getItemRenderer(uniqueKey, inputValueRenderer, isItemSelected) {
50
- return function renderItem(item, _a) {
51
- var handleClick = _a.handleClick, modifiers = _a.modifiers, query = _a.query;
52
- if (!modifiers.matchesPredicate) {
53
- return null;
54
- }
55
- var text = inputValueRenderer(item);
56
- var key = null;
57
- if (typeof uniqueKey === 'string') {
58
- // @ts-ignore
59
- key = item[uniqueKey];
60
- }
61
- else if (typeof uniqueKey === 'function') {
62
- key = uniqueKey(item);
63
- }
64
- return (react_1.default.createElement(core_1.MenuItem, { active: modifiers.active, icon: isItemSelected && isItemSelected(item) ? 'tick' : 'blank', disabled: modifiers.disabled, label: undefined, key: key, onClick: handleClick, text: highlightText(text, query) }));
65
- };
66
- }
67
- exports.getItemRenderer = getItemRenderer;