@monolith-forensics/monolith-ui 1.1.78 → 1.1.80

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.
package/dist/Pill/Pill.js CHANGED
@@ -23,7 +23,7 @@ const Pill = styled(({ className, children, size = "md", showRemoveIcon = true,
23
23
  return (_jsxs("div", { className: className, onClick: (e) => {
24
24
  e.preventDefault();
25
25
  e.stopPropagation();
26
- }, children: [_jsx("span", { className: "pill-content", children: children }), showRemoveIcon && (_jsx(StyledButton, { onClick: handleRemove, onMouseDown: (e) => {
26
+ }, children: [_jsx("span", { className: "pill-content", children: children }), showRemoveIcon && (_jsx(StyledButton, { tabIndex: -1, onClick: handleRemove, onMouseDown: (e) => {
27
27
  e.preventDefault();
28
28
  e.stopPropagation();
29
29
  }, children: _jsx(X, {}) }))] }));
@@ -18,6 +18,7 @@ interface RichTextEditorProps {
18
18
  handleImageUpload?: HandleImageUpload;
19
19
  bubbleMenuOptions?: BubbleMenuOptions;
20
20
  toolbarOptions?: ToolbarOptions;
21
+ autoFocus?: boolean;
21
22
  style?: React.CSSProperties;
22
23
  }
23
24
  declare const RichTextEditor: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<RichTextEditorProps & import("react").RefAttributes<unknown>, "ref"> & {
@@ -9,7 +9,7 @@ import { startImageUpload, } from "./Plugins/UploadImagesPlugin";
9
9
  import SaveBadge from "./Components/SaveBadge";
10
10
  import Fonts from "./Enums/Fonts";
11
11
  import RichTextEditorContext from "./Contexts/RichTextEditorContext";
12
- const RichTextEditor = styled(forwardRef(({ className, editorInstanceRef, defaultValue = "", readOnly = false, font, showToolbar = true, saving = false, extensions = [], slashCommands = [], bubbleMenuOptions, toolbarOptions, onChange, handleImageUpload, style, }, ref) => {
12
+ const RichTextEditor = styled(forwardRef(({ className, editorInstanceRef, defaultValue = "", readOnly = false, font, showToolbar = true, saving = false, extensions = [], slashCommands = [], bubbleMenuOptions, toolbarOptions, autoFocus, onChange, handleImageUpload, style, }, ref) => {
13
13
  const [fontState, setFontState] = useState(font || Fonts.DEFAULT);
14
14
  // check if image extension is included
15
15
  if (extensions === null || extensions === void 0 ? void 0 : extensions.includes(Extensions.Image)) {
@@ -80,6 +80,12 @@ const RichTextEditor = styled(forwardRef(({ className, editorInstanceRef, defaul
80
80
  _ref.current = editor;
81
81
  }
82
82
  }, [editor]);
83
+ // AutoFocus on the editor
84
+ useEffect(() => {
85
+ if (autoFocus && editor) {
86
+ editor.view.focus();
87
+ }
88
+ }, [autoFocus, editor]);
83
89
  return (_jsx("div", { className: className, children: _jsxs(RichTextEditorContext.Provider, { value: {
84
90
  font: fontState,
85
91
  setFont: setFontState,
@@ -10,7 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
13
- import styled from "styled-components";
13
+ import styled, { useTheme } from "styled-components";
14
14
  import { useFloating, flip, offset, FloatingPortal, autoUpdate, } from "@floating-ui/react";
15
15
  import { useCallback, useEffect, useRef, useState, } from "react";
16
16
  import { Input, FieldLabel, Tooltip, Loader } from "..";
@@ -161,8 +161,9 @@ const StyledItem = styled.div `
161
161
  }
162
162
  `;
163
163
  const SelectBox = styled(({ className, data = [], placeholder = "Select...", arrow = true, onChange, onSearch, searchFn, onScroll, loading, defaultValue, value, onItemAdded, size = "sm", variant = "outlined", width = "100%", allowCustomValue = false, searchable = false, clearable = false, label, description, required = false, error, openOnFocus = true, renderOption, actionComponent, focused, grouped, OptionTooltip, // Custom tooltip component for search menu items
164
- DropDownProps = {}, debounceTime = 300, sort = false, }) => {
164
+ DropDownProps = {}, debounceTime = 150, sort = false, }) => {
165
165
  var _a, _b, _c, _d, _e, _f, _g, _h;
166
+ const theme = useTheme();
166
167
  const isObjectArray = (_a = Object.keys((data === null || data === void 0 ? void 0 : data[0]) || {})) === null || _a === void 0 ? void 0 : _a.includes("label");
167
168
  const [inputValue, setInputValue] = useState("");
168
169
  const [isOpen, setIsOpen] = useState(false);
@@ -241,6 +242,7 @@ DropDownProps = {}, debounceTime = 300, sort = false, }) => {
241
242
  };
242
243
  const handleInputChange = (e) => {
243
244
  const value = e.target.value;
245
+ debouncedHandleChange(value);
244
246
  setInputValue(value);
245
247
  setIsOpen(true);
246
248
  };
@@ -257,6 +259,8 @@ DropDownProps = {}, debounceTime = 300, sort = false, }) => {
257
259
  : item.toLowerCase() === value.toLowerCase());
258
260
  if (existingItem)
259
261
  handleChangeSelection(existingItem);
262
+ else
263
+ handleChangeSelection(null);
260
264
  }
261
265
  update();
262
266
  }, debounceTime);
@@ -283,8 +287,10 @@ DropDownProps = {}, debounceTime = 300, sort = false, }) => {
283
287
  update();
284
288
  };
285
289
  const handleItemClick = (event, item) => {
286
- event.preventDefault();
287
- event.stopPropagation();
290
+ var _a;
291
+ // Prevent input from losing focus on item selection
292
+ // Allows user to tab to next item in form
293
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
288
294
  handleChangeSelection(item);
289
295
  setIsOpen(false);
290
296
  };
@@ -365,7 +371,7 @@ DropDownProps = {}, debounceTime = 300, sort = false, }) => {
365
371
  setIsOpen(false);
366
372
  return;
367
373
  }
368
- setSelected(null); // Reset selected value when input value changes
374
+ // setSelected(null); // Reset selected value when input value changes
369
375
  };
370
376
  const handleFocus = () => {
371
377
  if (openOnFocus) {
@@ -415,15 +421,10 @@ DropDownProps = {}, debounceTime = 300, sort = false, }) => {
415
421
  }, [data, defaultValue, isObjectArray]);
416
422
  // handle input value change
417
423
  useEffect(() => {
418
- if (inputRef.current) {
419
- if (!selected) {
420
- inputRef.current.value = "";
421
- }
422
- else {
423
- inputRef.current.value = isObjectArray
424
- ? selected.label
425
- : selected;
426
- }
424
+ if (inputRef.current && selected) {
425
+ inputRef.current.value = isObjectArray
426
+ ? selected.label
427
+ : selected;
427
428
  }
428
429
  }, [selected]);
429
430
  // handle scroll item into view
@@ -455,10 +456,7 @@ DropDownProps = {}, debounceTime = 300, sort = false, }) => {
455
456
  setDropDownHeight(bottomHeight);
456
457
  };
457
458
  }, [topHeight, bottomHeight, isOpen]);
458
- useEffect(() => {
459
- debouncedHandleChange(inputValue);
460
- }, [inputValue, debouncedHandleChange]);
461
- return (_jsxs("div", { className: className, children: [label && (_jsx(FieldLabel, { error: error, asterisk: required, size: size, description: description, children: label })), _jsxs(StyledInputContainer, { ref: refs.setReference, onMouseDown: () => setIsOpen(true), width: width, onKeyDown: handleKeyDown, "data-open": isOpen, children: [_jsx(Input, { ref: inputRef, onChange: handleInputChange, onFocus: handleFocus, autoFocus: focused, placeholder: placeholder, size: size, readOnly: !searchable, "data-button-right": arrow || clearable }), clearable && (selected || !!((_h = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _h === void 0 ? void 0 : _h.value)) ? (_jsx(ClearButton, { className: "input-btn", onClick: handleClear, onMouseDown: (e) => {
459
+ return (_jsxs("div", { className: className, children: [label && (_jsx(FieldLabel, { error: error, asterisk: required, size: size, description: description, children: label })), _jsxs(StyledInputContainer, { ref: refs.setReference, onMouseDown: () => setIsOpen(true), width: width, onKeyDown: handleKeyDown, "data-open": isOpen, children: [_jsx(Input, { ref: inputRef, onChange: handleInputChange, onFocus: handleFocus, autoFocus: focused, placeholder: placeholder, size: size, readOnly: !searchable, "data-button-right": arrow || clearable, style: isOpen ? { borderColor: theme.palette.primary.main } : {} }), clearable && (selected || !!((_h = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _h === void 0 ? void 0 : _h.value)) ? (_jsx(ClearButton, { className: "input-btn", onClick: handleClear, onMouseDown: (e) => {
462
460
  e.preventDefault();
463
461
  e.stopPropagation();
464
462
  } })) : arrow ? (_jsx(ArrowButton, { onClick: (e) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monolith-forensics/monolith-ui",
3
- "version": "1.1.78",
3
+ "version": "1.1.80",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "author": "Matt Danner (Monolith Forensics LLC)",