@monolith-forensics/monolith-ui 1.1.48 → 1.1.50

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.
@@ -203,6 +203,8 @@ const StyledButton = styled.button `
203
203
 
204
204
  [data-position="right"] {
205
205
  margin-inline-start: 6px;
206
+ padding-inline-start: 6px;
207
+ margin-left: auto;
206
208
  display: flex;
207
209
  align-items: center;
208
210
  }
@@ -323,7 +325,7 @@ const StyledLoader = styled.span `
323
325
  `;
324
326
  const Button = forwardRef((props, ref) => {
325
327
  const { children, loading = false, leftSection = null, rightSection = null, href = null, download = null } = props, other = __rest(props, ["children", "loading", "leftSection", "rightSection", "href", "download"]);
326
- const buttonContent = (_jsx("span", { className: "inner-span", style: { height: "100%" }, children: loading ? (_jsx(StyledLoader, { children: _jsx(Loader2Icon, {}) })) : (_jsxs(_Fragment, { children: [leftSection && _jsx("span", { "data-position": "left", children: leftSection }), _jsx("span", { className: "button-label", children: children }), rightSection && _jsx("span", { "data-position": "right", children: rightSection })] })) }));
328
+ const buttonContent = (_jsx("span", { className: "inner-span", style: { height: "100%", width: "100%" }, children: loading ? (_jsx(StyledLoader, { children: _jsx(Loader2Icon, {}) })) : (_jsxs(_Fragment, { children: [leftSection && _jsx("span", { "data-position": "left", children: leftSection }), _jsx("span", { className: "button-label", children: children }), rightSection && _jsx("span", { "data-position": "right", children: rightSection })] })) }));
327
329
  return (_jsx(StyledButton, Object.assign({ ref: ref }, other, { children: href ? (_jsx(StyledAnchor, { href: href, download: download, children: buttonContent })) : (buttonContent) })));
328
330
  });
329
331
  export default Button;
@@ -1,4 +1,4 @@
1
- import { ComponentPropsWithoutRef, ComponentType, ReactElement, ReactNode, UIEvent } from "react";
1
+ import React, { ComponentPropsWithoutRef, ComponentType, ReactElement, ReactNode, UIEvent } from "react";
2
2
  import { ButtonProps } from "../Button";
3
3
  import { Size, Variant } from "../core";
4
4
  import { DropDownItem } from "./types";
@@ -6,11 +6,12 @@ interface StyledContentProps {
6
6
  maxDropdownHeight?: number | string;
7
7
  variant?: Variant;
8
8
  }
9
- declare const StyledContent: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledContentProps>> & string;
9
+ declare const StyledContent: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledContentProps>> & string;
10
10
  export interface DropDownMenuProps {
11
11
  className?: string;
12
12
  children?: ReactNode | string;
13
- data?: DropDownItem[];
13
+ label?: string;
14
+ data: DropDownItem[];
14
15
  variant?: Variant;
15
16
  defaultValue?: DropDownItem[];
16
17
  multiselect?: boolean;
@@ -28,5 +29,18 @@ export interface DropDownMenuProps {
28
29
  buttonRender?: (props: any) => ReactElement;
29
30
  buttonProps?: ButtonProps;
30
31
  }
31
- declare const DropDownMenu: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<DropDownMenuProps, never>> & string & Omit<({ className, children, data, variant, defaultValue, multiselect, size, TooltipContent, renderOption, onChange, onItemSelect, onScroll, loading, arrow, searchable, dropDownProps, buttonRender, buttonProps, }: DropDownMenuProps) => import("react/jsx-runtime").JSX.Element, keyof import("react").Component<any, {}, any>>;
32
+ interface MenuProps {
33
+ label?: any;
34
+ nested?: boolean;
35
+ children?: React.ReactNode;
36
+ buttonRender?: (props: any) => ReactElement;
37
+ arrow?: boolean;
38
+ variant?: Variant;
39
+ buttonProps?: ButtonProps;
40
+ size?: Size;
41
+ buttonSize?: Size;
42
+ multiselect?: boolean;
43
+ }
44
+ export declare const Menu: React.ForwardRefExoticComponent<Omit<React.HTMLProps<HTMLButtonElement> & MenuProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
45
+ declare const DropDownMenu: ({ data, children, defaultValue, variant, arrow, size, searchable, loading, onScroll, multiselect, renderOption, onItemSelect, onChange, buttonProps, TooltipContent, }: DropDownMenuProps) => import("react/jsx-runtime").JSX.Element;
32
46
  export default DropDownMenu;
@@ -1,12 +1,24 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { FloatingFocusManager, FloatingPortal, flip, offset, useFloating, } from "@floating-ui/react";
3
- import { forwardRef, useEffect, useRef, useState, } from "react";
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
13
+ import { FloatingFocusManager, FloatingList, FloatingNode, FloatingPortal, FloatingTree, autoUpdate, flip, offset, safePolygon, shift, useClick, useDismiss, useFloating, useFloatingNodeId, useFloatingParentNodeId, useFloatingTree, useHover, useInteractions, useListItem, useListNavigation, useMergeRefs, useRole, useTypeahead, } from "@floating-ui/react";
14
+ import React, { forwardRef, useRef, useState, } from "react";
4
15
  import styled from "styled-components";
5
16
  import { Button, Tooltip, CheckBox, Input } from "..";
6
17
  import { useDebouncedCallback } from "use-debounce";
7
- import { ChevronDownIcon } from "lucide-react";
18
+ import { ChevronDownIcon, ChevronRightIcon } from "lucide-react";
8
19
  const StyledFloatContainer = styled.div `
9
20
  z-index: 1500;
21
+ outline: none;
10
22
  `;
11
23
  const StyledInnerItemContainer = styled.div `
12
24
  overflow-y: auto;
@@ -16,28 +28,53 @@ const StyledInnerItemContainer = styled.div `
16
28
  }
17
29
  `;
18
30
  const SearchInput = forwardRef((props, ref) => _jsx(Input, Object.assign({ ref: ref, style: { marginBottom: 8 } }, props)));
19
- const StyledItem = styled.div `
20
- color: ${(props) => props.theme.palette.text.primary};
21
- border-radius: 3px;
22
- display: flex;
23
- flex-direction: row;
24
- gap: 5px;
25
- align-items: center;
26
- min-height: 25px;
27
- padding: 7px 10px;
28
- position: relative;
29
- user-select: none;
30
- outline: none;
31
+ const MenuItem = styled(React.forwardRef((_a, forwardedRef) => {
32
+ var { label, children, disabled, multiselect } = _a, props = __rest(_a, ["label", "children", "disabled", "multiselect"]);
33
+ const menu = React.useContext(MenuContext);
34
+ const item = useListItem({ label: disabled ? null : label });
35
+ const tree = useFloatingTree();
36
+ const isActive = item.index === menu.activeIndex;
37
+ return (_jsx(Button, Object.assign({}, props, { ref: useMergeRefs([item.ref, forwardedRef]), type: "button", role: "menuitem", tabIndex: isActive ? 0 : -1, disabled: disabled }, menu.getItemProps({
38
+ onClick(event) {
39
+ var _a;
40
+ (_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, event);
41
+ tree === null || tree === void 0 ? void 0 : tree.events.emit("click");
42
+ },
43
+ onFocus(event) {
44
+ var _a;
45
+ (_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props, event);
46
+ menu.setHasFocusInside(true);
47
+ },
48
+ }), { children: label || children })));
49
+ })) `
50
+ &.MenuItem {
51
+ color: ${(props) => props.theme.palette.text.primary};
52
+ border-radius: 3px;
53
+ display: flex;
54
+ flex-direction: row;
55
+ gap: 5px;
56
+ align-items: center;
57
+ min-height: 25px;
58
+ width: 100%;
59
+ min-width: fit-content;
60
+ height: auto;
61
+ position: relative;
62
+ user-select: none;
63
+ outline: none;
31
64
 
32
- white-space: nowrap;
33
- overflow: hidden;
34
- text-overflow: ellipsis;
65
+ border: none;
35
66
 
36
- cursor: pointer;
67
+ white-space: nowrap;
68
+ overflow: hidden;
69
+ text-overflow: ellipsis;
37
70
 
38
- font-family: ${({ theme }) => theme.typography.fontFamily};
71
+ cursor: pointer;
72
+ text-decoration: none;
39
73
 
40
- font-size: ${({ size }) => size === "xs"
74
+ font-weight: normal;
75
+ letter-spacing: normal;
76
+
77
+ font-size: ${({ size }) => size === "xs"
41
78
  ? "11px"
42
79
  : size === "sm"
43
80
  ? "13px"
@@ -49,7 +86,7 @@ const StyledItem = styled.div `
49
86
  ? "19px"
50
87
  : "11px"};
51
88
 
52
- padding: ${({ size }) => size === "xs"
89
+ padding: ${({ size }) => size === "xs"
53
90
  ? "2px 8px"
54
91
  : size === "sm"
55
92
  ? "4px 10px"
@@ -61,14 +98,26 @@ const StyledItem = styled.div `
61
98
  ? "6px 16px"
62
99
  : "2px 8px"};
63
100
 
64
- &[data-disabled] {
65
- color: ${(props) => props.theme.palette.text.secondary};
66
- pointer-events: "none";
67
- }
101
+ &[data-disabled] {
102
+ color: ${(props) => props.theme.palette.text.secondary};
103
+ pointer-events: "none";
104
+ }
68
105
 
69
- &:hover {
70
- background-color: ${(props) => props.theme.palette.action.hover};
71
- color: ${(props) => props.theme.palette.text.primary};
106
+ &:hover {
107
+ background-color: ${(props) => props.theme.palette.action.hover};
108
+ color: ${(props) => props.theme.palette.text.primary};
109
+ }
110
+
111
+ &:active {
112
+ translate: none;
113
+ }
114
+
115
+ .button-label {
116
+ display: flex;
117
+ flex-direction: row;
118
+ gap: 5px;
119
+ align-items: center;
120
+ }
72
121
  }
73
122
  `;
74
123
  const StyledContent = styled.div `
@@ -79,6 +128,8 @@ const StyledContent = styled.div `
79
128
  overflow-y: hidden;
80
129
  overflow-x: hidden;
81
130
 
131
+ min-width: 150px;
132
+ max-width: 400px;
82
133
  max-height: ${({ maxDropdownHeight }) => Number.isInteger(maxDropdownHeight)
83
134
  ? `${maxDropdownHeight}px`
84
135
  : maxDropdownHeight || "250px"};
@@ -99,6 +150,7 @@ const StyledContent = styled.div `
99
150
 
100
151
  border-radius: 5px;
101
152
  border: 1px solid ${(props) => props.theme.palette.divider};
153
+ outline: none;
102
154
  padding: 5px;
103
155
  animation-duration: 400ms;
104
156
  animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
@@ -108,22 +160,123 @@ const StyledContent = styled.div `
108
160
  display: none;
109
161
  }
110
162
  `;
111
- const DropDownMenu = styled(({ className, children, data = [], variant = "outlined", defaultValue, multiselect = false, size = "xs", TooltipContent, renderOption, onChange, onItemSelect, onScroll, loading, arrow, searchable, dropDownProps, buttonRender, buttonProps, }) => {
163
+ const MenuContext = React.createContext({
164
+ getItemProps: () => ({}),
165
+ activeIndex: null,
166
+ setActiveIndex: () => { },
167
+ setHasFocusInside: () => { },
168
+ isOpen: false,
169
+ });
170
+ const MenuComponent = React.forwardRef((_a, forwardedRef) => {
171
+ var { children, label, arrow, size, buttonSize, variant, buttonProps, buttonRender, multiselect } = _a, props = __rest(_a, ["children", "label", "arrow", "size", "buttonSize", "variant", "buttonProps", "buttonRender", "multiselect"]);
172
+ const [isOpen, setIsOpen] = React.useState(false);
173
+ const [hasFocusInside, setHasFocusInside] = React.useState(false);
174
+ const [activeIndex, setActiveIndex] = React.useState(null);
175
+ const elementsRef = React.useRef([]);
176
+ const labelsRef = React.useRef([]);
177
+ const parent = React.useContext(MenuContext);
178
+ const tree = useFloatingTree();
179
+ const nodeId = useFloatingNodeId();
180
+ const parentId = useFloatingParentNodeId();
181
+ const item = useListItem();
182
+ const isNested = parentId != null;
183
+ const { floatingStyles, refs, context } = useFloating({
184
+ nodeId,
185
+ open: isOpen,
186
+ onOpenChange: setIsOpen,
187
+ placement: isNested ? "right-start" : "bottom-start",
188
+ middleware: [
189
+ offset({
190
+ mainAxis: isNested ? 0 : 2,
191
+ alignmentAxis: isNested ? -4 : 0,
192
+ }),
193
+ flip(),
194
+ shift(),
195
+ ],
196
+ whileElementsMounted: autoUpdate,
197
+ });
198
+ const hover = useHover(context, {
199
+ enabled: isNested,
200
+ delay: { open: 75 },
201
+ handleClose: safePolygon({ blockPointerEvents: true }),
202
+ });
203
+ const click = useClick(context, {
204
+ event: "click",
205
+ toggle: !isNested,
206
+ ignoreMouse: isNested,
207
+ });
208
+ const role = useRole(context, { role: "menu" });
209
+ const dismiss = useDismiss(context, { bubbles: true });
210
+ const listNavigation = useListNavigation(context, {
211
+ listRef: elementsRef,
212
+ activeIndex,
213
+ nested: isNested,
214
+ onNavigate: setActiveIndex,
215
+ });
216
+ const typeahead = useTypeahead(context, {
217
+ listRef: labelsRef,
218
+ onMatch: isOpen ? setActiveIndex : undefined,
219
+ activeIndex,
220
+ });
221
+ const { getReferenceProps, getFloatingProps, getItemProps } = useInteractions([hover, click, role, dismiss]);
222
+ // Event emitter allows you to communicate across tree components.
223
+ // This effect closes all menus when an item gets clicked anywhere
224
+ // in the tree.
225
+ React.useEffect(() => {
226
+ if (!tree)
227
+ return;
228
+ function handleTreeClick() {
229
+ if (!multiselect) {
230
+ setIsOpen(false);
231
+ }
232
+ }
233
+ function onSubMenuOpen(event) {
234
+ if (event.nodeId !== nodeId && event.parentId === parentId) {
235
+ setIsOpen(false);
236
+ }
237
+ }
238
+ tree.events.on("click", handleTreeClick);
239
+ tree.events.on("menuopen", onSubMenuOpen);
240
+ return () => {
241
+ tree.events.off("click", handleTreeClick);
242
+ tree.events.off("menuopen", onSubMenuOpen);
243
+ };
244
+ }, [tree, nodeId, parentId]);
245
+ React.useEffect(() => {
246
+ if (isOpen && tree) {
247
+ tree.events.emit("menuopen", { parentId, nodeId });
248
+ }
249
+ }, [tree, isOpen, nodeId, parentId]);
250
+ return (_jsxs(FloatingNode, { id: nodeId, children: [_jsx(MenuItem, Object.assign({ ref: useMergeRefs([refs.setReference, item.ref, forwardedRef]), tabIndex: !isNested ? undefined : parent.activeIndex === item.index ? 0 : -1, role: isNested ? "menuitem" : undefined, className: isNested ? "MenuItem" : "RootMenu", "data-open": isOpen ? "" : undefined, "data-nested": isNested ? "" : undefined, "data-focus-inside": hasFocusInside ? "" : undefined }, getReferenceProps(parent.getItemProps(Object.assign(Object.assign({}, props), { onFocus(event) {
251
+ var _a;
252
+ (_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props, event);
253
+ setHasFocusInside(false);
254
+ parent.setHasFocusInside(true);
255
+ } }))), { rightSection: arrow ? (_jsx(ChevronDownIcon, { size: 12 })) : isNested ? (_jsx(ChevronRightIcon, { size: 12 })) : null, size: buttonSize, variant: variant, selected: isOpen }, buttonProps, { children: label })), _jsx(MenuContext.Provider, { value: {
256
+ activeIndex,
257
+ setActiveIndex,
258
+ getItemProps,
259
+ setHasFocusInside,
260
+ isOpen,
261
+ }, children: _jsx(FloatingList, { elementsRef: elementsRef, labelsRef: labelsRef, children: isOpen && (_jsx(FloatingPortal, { children: _jsx(FloatingFocusManager, { context: context, modal: false, initialFocus: isNested ? -1 : 0, returnFocus: !isNested, children: _jsx(StyledFloatContainer, Object.assign({ ref: refs.setFloating, className: "Menu", style: floatingStyles }, getFloatingProps(), { children: _jsx(StyledContent, { className: "mfFloatingContent", children: children }) })) }) })) }) })] }));
262
+ });
263
+ export const Menu = React.forwardRef((props, ref) => {
264
+ const parentId = useFloatingParentNodeId();
265
+ if (parentId === null) {
266
+ return (_jsx(FloatingTree, { children: _jsx(MenuComponent, Object.assign({}, props, { ref: ref })) }));
267
+ }
268
+ return _jsx(MenuComponent, Object.assign({}, props, { ref: ref }));
269
+ });
270
+ const DropDownMenu = ({ data, children, defaultValue, variant, arrow, size, searchable, loading, onScroll, multiselect, renderOption, onItemSelect, onChange, buttonProps, TooltipContent, }) => {
112
271
  var _a, _b, _c;
113
272
  const isObjectArray = (_a = Object.keys((data === null || data === void 0 ? void 0 : data[0]) || {})) === null || _a === void 0 ? void 0 : _a.includes("label");
114
- const [isOpen, setIsOpen] = useState(false);
115
273
  const [selected, setSelected] = useState(defaultValue || []);
116
274
  const [searchValue, setSearchValue] = useState("");
117
275
  const scrollContainerRef = useRef(null);
118
276
  const searchInputRef = useRef(null);
119
- const { refs, floatingStyles, context } = useFloating({
120
- open: isOpen,
121
- onOpenChange: setIsOpen,
122
- placement: "bottom-start",
123
- strategy: "absolute",
124
- // Handle collisions with the viewport
125
- middleware: [flip(), offset(3)],
126
- });
277
+ const handleSearch = useDebouncedCallback((e) => {
278
+ setSearchValue(e.target.value);
279
+ }, 150);
127
280
  const handleAddItem = (item) => {
128
281
  setSelected((prev) => {
129
282
  let newSelected = [...prev, item];
@@ -140,76 +293,37 @@ const DropDownMenu = styled(({ className, children, data = [], variant = "outlin
140
293
  return newSelected;
141
294
  });
142
295
  };
143
- const handleSearch = useDebouncedCallback((e) => {
144
- setSearchValue(e.target.value);
145
- }, 150);
146
- // Close on outside click
147
- useEffect(() => {
148
- const close = (e) => {
149
- var _a, _b, _c, _d;
150
- const target = e.target;
151
- const referenceElement = (_a = refs === null || refs === void 0 ? void 0 : refs.reference) === null || _a === void 0 ? void 0 : _a.current;
152
- const floatingElement = (_b = refs === null || refs === void 0 ? void 0 : refs.floating) === null || _b === void 0 ? void 0 : _b.current;
153
- if (floatingElement && // Check if the floating element exists
154
- e.target !== referenceElement && // Check if the target is not the reference (input)
155
- !((_c = referenceElement === null || referenceElement === void 0 ? void 0 : referenceElement.contains) === null || _c === void 0 ? void 0 : _c.call(referenceElement, target)) && // Check if the target is not inside the reference (input)
156
- !((_d = floatingElement === null || floatingElement === void 0 ? void 0 : floatingElement.contains) === null || _d === void 0 ? void 0 : _d.call(floatingElement, target)) // Check if the target is not inside the floating element (content)
157
- ) {
158
- setIsOpen(false);
159
- }
160
- };
161
- document.addEventListener("mousedown", close);
162
- return () => document.removeEventListener("mousdown", close);
163
- }, [refs.floating, refs.reference]);
164
- useEffect(() => {
165
- var _a, _b;
166
- if (isOpen && searchable) {
167
- (_b = (_a = searchInputRef === null || searchInputRef === void 0 ? void 0 : searchInputRef.current) === null || _a === void 0 ? void 0 : _a.focus) === null || _b === void 0 ? void 0 : _b.call(_a);
168
- }
169
- if (!isOpen) {
170
- setSearchValue("");
171
- }
172
- }, [isOpen, searchable]);
173
296
  const scrollActive = (((_b = scrollContainerRef === null || scrollContainerRef === void 0 ? void 0 : scrollContainerRef.current) === null || _b === void 0 ? void 0 : _b.scrollHeight) || 0) >
174
297
  (((_c = scrollContainerRef === null || scrollContainerRef === void 0 ? void 0 : scrollContainerRef.current) === null || _c === void 0 ? void 0 : _c.clientHeight) || 0);
175
- return (_jsxs("div", { className: className + " mfDropDownMenu", children: [buttonRender ? (buttonRender({
176
- onClick: () => setIsOpen(!isOpen),
177
- buttonRef: refs.setReference,
178
- isOpen,
179
- })) : (_jsx(Button, Object.assign({ ref: (ref) => {
180
- refs.setReference(ref);
181
- }, onClick: () => setIsOpen(!isOpen), rightSection: arrow ? _jsx(ChevronDownIcon, { size: 12 }) : null, size: size, variant: variant, selected: isOpen }, buttonProps, { children: children }))), isOpen && (_jsx(FloatingPortal, { preserveTabOrder: true, children: _jsx(FloatingFocusManager, { context: context, modal: false, children: _jsx(StyledFloatContainer, { ref: refs.setFloating, style: floatingStyles, className: "mfFloating", children: _jsx(StyledContent, Object.assign({ className: "mfFloatingContent", style: { width: 150, maxWidth: 400 } }, dropDownProps, { children: _jsxs(StyledInnerItemContainer, { ref: scrollContainerRef, "data-scroll-active": scrollActive, onScroll: onScroll, children: [loading && _jsx("div", { children: "Loading..." }), searchable && (_jsx(SearchInput, { ref: searchInputRef, variant: "outlined", size: size, placeholder: "Search", onChange: handleSearch })), !loading &&
182
- data
183
- .filter((item) => {
184
- var _a, _b, _c;
185
- if (!searchable)
186
- return true;
187
- if (isObjectArray) {
188
- return (((_a = item === null || item === void 0 ? void 0 : item.label) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(searchValue.toLowerCase())) ||
189
- ((_b = item === null || item === void 0 ? void 0 : item.value) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes(searchValue.toLowerCase())));
190
- }
191
- return (_c = item
192
- .toLowerCase) === null || _c === void 0 ? void 0 : _c.call(item).includes(searchValue.toLowerCase());
193
- })
194
- .map((item, index) => {
195
- const isSelected = !!(selected === null || selected === void 0 ? void 0 : selected.find((s) => isObjectArray
196
- ? (s === null || s === void 0 ? void 0 : s.value) === (item === null || item === void 0 ? void 0 : item.value)
197
- : s === item));
198
- return (_jsx(Tooltip, { content: TooltipContent ? (_jsx(TooltipContent, { data: item.data })) : null, side: "left", children: _jsxs(StyledItem, { className: "mfFloatingItem", onClick: (e) => {
199
- var _a;
200
- e.preventDefault();
201
- e.stopPropagation();
202
- if (multiselect) {
203
- isSelected
204
- ? handleRemoveItem(item)
205
- : handleAddItem(item);
206
- }
207
- else {
208
- setIsOpen(false);
209
- }
210
- onItemSelect === null || onItemSelect === void 0 ? void 0 : onItemSelect(item);
211
- (_a = item === null || item === void 0 ? void 0 : item.onClick) === null || _a === void 0 ? void 0 : _a.call(item, item);
212
- }, "data-selected": isSelected, size: size, children: [multiselect && _jsx(CheckBox, { value: isSelected }), (item === null || item === void 0 ? void 0 : item.leftSection) || null, _jsx(_Fragment, { children: (renderOption === null || renderOption === void 0 ? void 0 : renderOption(item)) || (item === null || item === void 0 ? void 0 : item.label) || item }), (item === null || item === void 0 ? void 0 : item.rightSection) || null] }) }, index));
213
- })] }) })) }) }) }))] }));
214
- }) ``;
298
+ return (_jsx(Menu, { label: children, arrow: arrow, buttonSize: size, variant: variant, multiselect: multiselect, buttonProps: buttonProps, children: _jsxs(StyledInnerItemContainer, { ref: scrollContainerRef, "data-scroll-active": scrollActive, onScroll: onScroll, children: [loading && _jsx("div", { children: "Loading..." }), searchable && (_jsx(SearchInput, { ref: searchInputRef, variant: "outlined", size: size, placeholder: "Search", onChange: handleSearch })), !loading &&
299
+ data
300
+ .filter((item) => {
301
+ var _a, _b, _c;
302
+ if (!searchable)
303
+ return true;
304
+ if (isObjectArray) {
305
+ return (((_a = item === null || item === void 0 ? void 0 : item.label) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(searchValue.toLowerCase())) ||
306
+ ((_b = item === null || item === void 0 ? void 0 : item.value) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes(searchValue.toLowerCase())));
307
+ }
308
+ return (_c = item.toLowerCase) === null || _c === void 0 ? void 0 : _c.call(item).includes(searchValue.toLowerCase());
309
+ })
310
+ .map((item, index) => {
311
+ const isSelected = !!(selected === null || selected === void 0 ? void 0 : selected.find((s) => isObjectArray ? (s === null || s === void 0 ? void 0 : s.value) === (item === null || item === void 0 ? void 0 : item.value) : s === item));
312
+ if (item.items) {
313
+ return (_jsx(DropDownMenu, { data: item.items, children: item.label }));
314
+ }
315
+ return (_jsx(Tooltip, { content: TooltipContent ? _jsx(TooltipContent, { data: item.data }) : null, side: "left", children: _jsxs(MenuItem, { className: "MenuItem", "data-selected": isSelected, leftSection: multiselect && _jsx(CheckBox, { value: isSelected, size: size }), multiselect: multiselect, size: size, onClick: (e) => {
316
+ var _a;
317
+ e.preventDefault();
318
+ e.stopPropagation();
319
+ if (multiselect) {
320
+ isSelected
321
+ ? handleRemoveItem(item)
322
+ : handleAddItem(item);
323
+ }
324
+ onItemSelect === null || onItemSelect === void 0 ? void 0 : onItemSelect(item);
325
+ (_a = item === null || item === void 0 ? void 0 : item.onClick) === null || _a === void 0 ? void 0 : _a.call(item, item);
326
+ }, children: [(item === null || item === void 0 ? void 0 : item.leftSection) || null, _jsx(_Fragment, { children: (renderOption === null || renderOption === void 0 ? void 0 : renderOption(item)) || (item === null || item === void 0 ? void 0 : item.label) || item }), (item === null || item === void 0 ? void 0 : item.rightSection) || null] }, index) }, index));
327
+ })] }) }));
328
+ };
215
329
  export default DropDownMenu;
@@ -4,6 +4,7 @@ export type DropDownItem = {
4
4
  value: string;
5
5
  onClick?: (args: any) => void;
6
6
  data?: any;
7
+ items?: DropDownItem[];
7
8
  leftSection?: React.ReactNode;
8
9
  rightSection?: React.ReactNode;
9
10
  };
package/dist/Grid/Grid.js CHANGED
@@ -5,7 +5,8 @@ const Grid = styled(({ className, children }) => {
5
5
  }) `
6
6
  display: grid;
7
7
  grid-template-columns: repeat(${({ col }) => col || 1}, minmax(0, 1fr));
8
- gap: 20px;
8
+ column-gap: 20px;
9
+ row-gap: 15px;
9
10
 
10
11
  width: ${({ width }) => Number.isInteger(width) ? `${width}px` : width || "100%"};
11
12
  height: auto;
@@ -10,5 +10,6 @@ declare const Modal: {
10
10
  ({ children, open, onClose, style, showCloseButton, FocusProps, }: ModalProps): import("react/jsx-runtime").JSX.Element;
11
11
  Title: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, never>> & string;
12
12
  SubTitle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, never>> & string;
13
+ Content: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
13
14
  };
14
15
  export default Modal;
@@ -70,11 +70,20 @@ const StyledClose = styled.div `
70
70
  color: ${(props) => props.theme.palette.text.secondary};
71
71
  `;
72
72
  const StyledButton = styled.button `
73
+ display: flex;
74
+ align-items: center;
75
+ justify-content: center;
76
+ color: ${(props) => props.theme.palette.text.secondary};
73
77
  background-color: transparent;
78
+ border-radius: 4px;
74
79
  border: none;
75
80
  outline: none;
76
81
  cursor: pointer;
77
- padding: 0;
82
+ padding: 2px;
83
+
84
+ &:hover {
85
+ background-color: ${(props) => props.theme.palette.action.hover};
86
+ }
78
87
  `;
79
88
  const Title = styled.h1 `
80
89
  font-size: 20px;
@@ -87,6 +96,11 @@ const SubTitle = styled.h2 `
87
96
  margin: 0px;
88
97
  color: ${(props) => props.theme.palette.text.secondary};
89
98
  `;
99
+ const ModalContent = styled.div `
100
+ display: flex;
101
+ flex-direction: column;
102
+ gap: 1rem;
103
+ `;
90
104
  const Modal = ({ children, open = false, onClose, style = {}, showCloseButton = false, FocusProps = {}, }) => {
91
105
  const { refs, floatingStyles, context } = useFloating({
92
106
  open,
@@ -103,4 +117,5 @@ const Modal = ({ children, open = false, onClose, style = {}, showCloseButton =
103
117
  };
104
118
  Modal.Title = Title;
105
119
  Modal.SubTitle = SubTitle;
120
+ Modal.Content = ModalContent;
106
121
  export default Modal;
@@ -1,7 +1,9 @@
1
1
  import { createGlobalStyle } from "styled-components";
2
2
  const GlobalStyle = createGlobalStyle `
3
+
3
4
  * {
4
5
  box-sizing: border-box;
6
+ -webkit-font-smoothing: antialiased;
5
7
  }
6
8
 
7
9
  body {
@@ -20,15 +20,25 @@ interface BubbleMenuDropDownItem extends DropDownItem {
20
20
  export type BubbleItem = {
21
21
  name: Extensions | string;
22
22
  icon?: React.FC<any>;
23
- type?: "button" | "menu";
23
+ type: "menu";
24
24
  label?: string | Element;
25
- items?: BubbleMenuDropDownItem[];
25
+ items: BubbleMenuDropDownItem[];
26
26
  arrow?: boolean;
27
27
  isActive?: (editor: Editor) => boolean;
28
28
  buttonRender?: (props: any) => ReactElement;
29
29
  buttonProps?: ButtonProps;
30
30
  dropDownProps?: DropDownMenuProps;
31
31
  onClick?: (editor: Editor) => void;
32
+ } | {
33
+ name: Extensions | string;
34
+ icon?: React.FC<any>;
35
+ type: "button";
36
+ label?: string | Element;
37
+ arrow?: boolean;
38
+ isActive?: (editor: Editor) => boolean;
39
+ buttonRender?: (props: any) => ReactElement;
40
+ buttonProps?: ButtonProps;
41
+ onClick?: (editor: Editor) => void;
32
42
  };
33
43
  declare const BubbleMenu: React.FC<BubbleMenuProps>;
34
44
  export default BubbleMenu;
@@ -0,0 +1,5 @@
1
+ declare const RichTextEditorContext: import("react").Context<{
2
+ font: string;
3
+ setFont: (font: string) => void;
4
+ }>;
5
+ export default RichTextEditorContext;
@@ -0,0 +1,7 @@
1
+ import { createContext } from "react";
2
+ import Fonts from "../Enums/Fonts";
3
+ const RichTextEditorContext = createContext({
4
+ font: Fonts.DEFAULT,
5
+ setFont: (font) => { },
6
+ });
7
+ export default RichTextEditorContext;
@@ -0,0 +1,20 @@
1
+ declare enum Controls {
2
+ UNDO = "undo",
3
+ REDO = "redo",
4
+ BOLD = "bold",
5
+ ITALIC = "italic",
6
+ UNDERLINE = "underline",
7
+ STRIKE = "strike",
8
+ HEADING_1 = "heading_1",
9
+ HEADING_2 = "heading_2",
10
+ HEADING_3 = "heading_3",
11
+ HEADING_4 = "heading_4",
12
+ BULLET_LIST = "bulletList",
13
+ ORDERED_LIST = "orderedList",
14
+ TEXT_ALIGN_LEFT = "textAlignLeft",
15
+ TEXT_ALIGN_CENTER = "textAlignCenter",
16
+ TEXT_ALIGN_RIGHT = "textAlignRight",
17
+ TEXT_ALIGN_JUSTIFIED = "textAlignJustified",
18
+ FONT = "font"
19
+ }
20
+ export default Controls;
@@ -0,0 +1,21 @@
1
+ var Controls;
2
+ (function (Controls) {
3
+ Controls["UNDO"] = "undo";
4
+ Controls["REDO"] = "redo";
5
+ Controls["BOLD"] = "bold";
6
+ Controls["ITALIC"] = "italic";
7
+ Controls["UNDERLINE"] = "underline";
8
+ Controls["STRIKE"] = "strike";
9
+ Controls["HEADING_1"] = "heading_1";
10
+ Controls["HEADING_2"] = "heading_2";
11
+ Controls["HEADING_3"] = "heading_3";
12
+ Controls["HEADING_4"] = "heading_4";
13
+ Controls["BULLET_LIST"] = "bulletList";
14
+ Controls["ORDERED_LIST"] = "orderedList";
15
+ Controls["TEXT_ALIGN_LEFT"] = "textAlignLeft";
16
+ Controls["TEXT_ALIGN_CENTER"] = "textAlignCenter";
17
+ Controls["TEXT_ALIGN_RIGHT"] = "textAlignRight";
18
+ Controls["TEXT_ALIGN_JUSTIFIED"] = "textAlignJustified";
19
+ Controls["FONT"] = "font";
20
+ })(Controls || (Controls = {}));
21
+ export default Controls;
@@ -0,0 +1,10 @@
1
+ declare enum Fonts {
2
+ DEFAULT = "Default",
3
+ ARIAL = "Arial",
4
+ COURIER_NEW = "Courier New",
5
+ TIMES_NEW_ROMAN = "Times New Roman",
6
+ SEGOE_UI = "Segoe UI",
7
+ ROBOTO = "Roboto",
8
+ VERANDA = "Veranda"
9
+ }
10
+ export default Fonts;
@@ -0,0 +1,11 @@
1
+ var Fonts;
2
+ (function (Fonts) {
3
+ Fonts["DEFAULT"] = "Default";
4
+ Fonts["ARIAL"] = "Arial";
5
+ Fonts["COURIER_NEW"] = "Courier New";
6
+ Fonts["TIMES_NEW_ROMAN"] = "Times New Roman";
7
+ Fonts["SEGOE_UI"] = "Segoe UI";
8
+ Fonts["ROBOTO"] = "Roboto";
9
+ Fonts["VERANDA"] = "Veranda";
10
+ })(Fonts || (Fonts = {}));
11
+ export default Fonts;
@@ -2,6 +2,7 @@ import { Editor } from "@tiptap/react";
2
2
  import { ExtensionType } from "./Extensions/getTiptapExtensions";
3
3
  import { HandleImageUpload } from "./Plugins/UploadImagesPlugin";
4
4
  import { BubbleMenuOptions } from "./Extensions/BubbleMenuExtension";
5
+ import { ToolbarOptions } from "./Toolbar/Toolbar";
5
6
  interface RichTextEditorProps {
6
7
  className?: string;
7
8
  editorInstanceRef?: React.RefObject<Editor>;
@@ -16,6 +17,7 @@ interface RichTextEditorProps {
16
17
  onChange?: (value: string) => void;
17
18
  handleImageUpload?: HandleImageUpload;
18
19
  bubbleMenuOptions?: BubbleMenuOptions;
20
+ toolbarOptions?: ToolbarOptions;
19
21
  style?: React.CSSProperties;
20
22
  }
21
23
  declare const RichTextEditor: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<RichTextEditorProps & import("react").RefAttributes<unknown>, "ref"> & {
@@ -1,12 +1,15 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { forwardRef, useEffect } from "react";
2
+ import { forwardRef, useEffect, useState } from "react";
3
3
  import styled from "styled-components";
4
4
  import { EditorContent, useEditor } from "@tiptap/react";
5
5
  import Toolbar from "./Toolbar";
6
6
  import getTipTapExtensions from "./Extensions/getTiptapExtensions";
7
7
  import Extensions from "./Enums/Extensions";
8
8
  import SaveBadge from "./Components/SaveBadge";
9
- const RichTextEditor = styled(forwardRef(({ className, editorInstanceRef, defaultValue = "", readOnly = false, font, showToolbar = true, saving = false, extensions = [], slashCommands = [], bubbleMenuOptions, onChange, handleImageUpload, style, }, ref) => {
9
+ import Fonts from "./Enums/Fonts";
10
+ import RichTextEditorContext from "./Contexts/RichTextEditorContext";
11
+ const RichTextEditor = styled(forwardRef(({ className, editorInstanceRef, defaultValue = "", readOnly = false, font, showToolbar = true, saving = false, extensions = [], slashCommands = [], bubbleMenuOptions, toolbarOptions, onChange, handleImageUpload, style, }, ref) => {
12
+ const [fontState, setFontState] = useState(font || Fonts.DEFAULT);
10
13
  // check if image extension is included
11
14
  if (extensions === null || extensions === void 0 ? void 0 : extensions.includes(Extensions.Image)) {
12
15
  // Ensure that handleImageUpload is provided
@@ -33,7 +36,10 @@ const RichTextEditor = styled(forwardRef(({ className, editorInstanceRef, defaul
33
36
  _ref.current = editor;
34
37
  }
35
38
  }, [editor]);
36
- return (_jsxs("div", { className: className, children: [showToolbar && _jsx(Toolbar, { editor: editor }), saving && _jsx(SaveBadge, {}), _jsx(EditorContent, { className: "editor-content", editor: editor, "data-font": font || null, style: style })] }));
39
+ return (_jsx("div", { className: className, children: _jsxs(RichTextEditorContext.Provider, { value: {
40
+ font: fontState,
41
+ setFont: setFontState,
42
+ }, children: [showToolbar && (_jsx(Toolbar, { editor: editor, toolbarOptions: toolbarOptions })), saving && _jsx(SaveBadge, {}), _jsx(EditorContent, { className: "editor-content", editor: editor, "data-font": fontState || null, style: style })] }) }));
37
43
  })) `
38
44
  position: relative;
39
45
  display: flex;
@@ -136,9 +142,11 @@ const RichTextEditor = styled(forwardRef(({ className, editorInstanceRef, defaul
136
142
  }
137
143
  ul {
138
144
  margin: 0;
145
+ font-size: 0.8rem;
139
146
  }
140
147
  ol {
141
148
  margin: 0;
149
+ font-size: 0.8rem;
142
150
  }
143
151
  .editor-link {
144
152
  color: ${({ theme }) => theme.palette.primary.main};
@@ -2,6 +2,9 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from "react";
3
3
  import styled from "styled-components";
4
4
  const ControlsGroup = styled(forwardRef(({ className, children }, ref) => {
5
+ if (!children) {
6
+ return null;
7
+ }
5
8
  return (_jsx("div", { className: className + " controls-group", ref: ref, children: children }));
6
9
  })) `
7
10
  & {
@@ -1,7 +1,25 @@
1
1
  import { Editor } from "@tiptap/react";
2
+ import Controls from "../Enums/Controls";
3
+ import { ReactNode } from "react";
4
+ import { DropDownMenuProps } from "../../DropDownMenu/DropDownMenu";
5
+ import { ButtonProps } from "../../Button";
6
+ export type CustomItem = {
7
+ type: "button";
8
+ options: ButtonProps & {
9
+ label: ReactNode;
10
+ };
11
+ } | {
12
+ type: "menu";
13
+ options: DropDownMenuProps;
14
+ };
15
+ export interface ToolbarOptions {
16
+ controls?: Array<Controls | CustomItem>;
17
+ customItems?: CustomItem[];
18
+ }
2
19
  interface ToolbarProps {
3
20
  className?: string;
4
21
  editor: Editor | null;
22
+ toolbarOptions?: ToolbarOptions;
5
23
  }
6
- declare const Toolbar: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<ToolbarProps, never>> & string & Omit<({ className, editor }: ToolbarProps) => import("react/jsx-runtime").JSX.Element, keyof import("react").Component<any, {}, any>>;
24
+ declare const Toolbar: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<ToolbarProps, never>> & string & Omit<({ className, editor, toolbarOptions }: ToolbarProps) => import("react/jsx-runtime").JSX.Element, keyof import("react").Component<any, {}, any>>;
7
25
  export default Toolbar;
@@ -2,8 +2,37 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import styled from "styled-components";
3
3
  import ControlsGroup from "./ControlsGroup";
4
4
  import { UndoControl, RedoControl, BoldControl, ItalicControl, UnderlineControl, StrikeThroughControl, Heading1Control, Heading2Control, Heading3Control, Heading4Control, BulletListControl, OrderedListControl, AlignLeftControl, AlignCenterControl, AlignRightControl, AlignJustifiedControl, } from "./Controls";
5
- const Toolbar = styled(({ className, editor }) => {
6
- return (_jsxs("div", { className: className, children: [_jsxs(ControlsGroup, { children: [_jsx(UndoControl, { editor: editor }), _jsx(RedoControl, { editor: editor })] }), _jsxs(ControlsGroup, { children: [_jsx(BoldControl, { editor: editor }), _jsx(ItalicControl, { editor: editor }), _jsx(UnderlineControl, { editor: editor }), _jsx(StrikeThroughControl, { editor: editor })] }), _jsxs(ControlsGroup, { children: [_jsx(Heading1Control, { editor: editor }), _jsx(Heading2Control, { editor: editor }), _jsx(Heading3Control, { editor: editor }), _jsx(Heading4Control, { editor: editor })] }), _jsxs(ControlsGroup, { children: [_jsx(BulletListControl, { editor: editor }), _jsx(OrderedListControl, { editor: editor })] }), _jsxs(ControlsGroup, { children: [_jsx(AlignLeftControl, { editor: editor }), _jsx(AlignCenterControl, { editor: editor }), _jsx(AlignRightControl, { editor: editor }), _jsx(AlignJustifiedControl, { editor: editor })] })] }));
5
+ import Controls from "../Enums/Controls";
6
+ import DropDownMenu from "../../DropDownMenu";
7
+ import Fonts from "../Enums/Fonts";
8
+ import { useContext } from "react";
9
+ import RichTextEditorContext from "../Contexts/RichTextEditorContext";
10
+ import Button from "../../Button";
11
+ const Toolbar = styled(({ className, editor, toolbarOptions }) => {
12
+ var _a;
13
+ const { controls } = toolbarOptions || {};
14
+ const customItems = controls === null || controls === void 0 ? void 0 : controls.filter((control) => typeof control !== "string" && control.type === ("menu" || "button"));
15
+ const { font, setFont } = useContext(RichTextEditorContext);
16
+ return (_jsxs("div", { className: className, children: [(_a = customItems === null || customItems === void 0 ? void 0 : customItems.map) === null || _a === void 0 ? void 0 : _a.call(customItems, (item, index) => {
17
+ var _a, _b;
18
+ if (item.type === "button") {
19
+ return (_jsx(Button, Object.assign({}, item.options, { children: (_a = item === null || item === void 0 ? void 0 : item.options) === null || _a === void 0 ? void 0 : _a.label }), index));
20
+ }
21
+ else if (item.type === "menu") {
22
+ return (_jsx(DropDownMenu, Object.assign({}, item.options, { children: (_b = item === null || item === void 0 ? void 0 : item.options) === null || _b === void 0 ? void 0 : _b.label }), index));
23
+ }
24
+ }), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.FONT)) && (_jsx(DropDownMenu, { data: Object.values(Fonts).map((font) => ({
25
+ label: font,
26
+ value: font,
27
+ onClick: () => {
28
+ setFont(font);
29
+ },
30
+ })), size: "xxs", variant: "outlined", arrow: true, buttonProps: {
31
+ style: {
32
+ fontWeight: "normal",
33
+ },
34
+ title: "Select Font",
35
+ }, children: (font || Fonts.DEFAULT) })), _jsxs(ControlsGroup, { children: [(controls === null || controls === void 0 ? void 0 : controls.includes(Controls.UNDO)) && _jsx(UndoControl, { editor: editor }), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.REDO)) && _jsx(RedoControl, { editor: editor })] }), _jsxs(ControlsGroup, { children: [(controls === null || controls === void 0 ? void 0 : controls.includes(Controls.BOLD)) && _jsx(BoldControl, { editor: editor }), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.ITALIC)) && (_jsx(ItalicControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.UNDERLINE)) && (_jsx(UnderlineControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.STRIKE)) && (_jsx(StrikeThroughControl, { editor: editor }))] }), _jsxs(ControlsGroup, { children: [(controls === null || controls === void 0 ? void 0 : controls.includes(Controls.HEADING_1)) && (_jsx(Heading1Control, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.HEADING_2)) && (_jsx(Heading2Control, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.HEADING_3)) && (_jsx(Heading3Control, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.HEADING_4)) && (_jsx(Heading4Control, { editor: editor }))] }), _jsxs(ControlsGroup, { children: [(controls === null || controls === void 0 ? void 0 : controls.includes(Controls.BULLET_LIST)) && (_jsx(BulletListControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.ORDERED_LIST)) && (_jsx(OrderedListControl, { editor: editor }))] }), _jsxs(ControlsGroup, { children: [(controls === null || controls === void 0 ? void 0 : controls.includes(Controls.TEXT_ALIGN_LEFT)) && (_jsx(AlignLeftControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.TEXT_ALIGN_CENTER)) && (_jsx(AlignCenterControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.TEXT_ALIGN_RIGHT)) && (_jsx(AlignRightControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.TEXT_ALIGN_JUSTIFIED)) && (_jsx(AlignJustifiedControl, { editor: editor }))] })] }));
7
36
  }) `
8
37
  display: flex;
9
38
  flex-direction: row;
@@ -1,3 +1,6 @@
1
1
  export { default } from "./RichTextEditor";
2
2
  export { default as Extensions } from "./Enums/Extensions";
3
3
  export { default as SlashCommands } from "./Enums/SlashCommands";
4
+ export { default as Controls } from "./Enums/Controls";
5
+ export type { CustomItem } from "./Toolbar/Toolbar";
6
+ export type { ToolbarOptions } from "./Toolbar/Toolbar";
@@ -1,3 +1,4 @@
1
1
  export { default } from "./RichTextEditor";
2
2
  export { default as Extensions } from "./Enums/Extensions";
3
3
  export { default as SlashCommands } from "./Enums/SlashCommands";
4
+ export { default as Controls } from "./Enums/Controls";
@@ -166,7 +166,7 @@ const SelectBox = styled(({ className, data = [], placeholder = "Select...", arr
166
166
  .concat(customItems) // Add custom items to the list
167
167
  .filter((item) => {
168
168
  const itemValue = (isObjectArray ? item.label : item);
169
- return itemValue.toLowerCase().includes(searchValue.toLowerCase());
169
+ return itemValue === null || itemValue === void 0 ? void 0 : itemValue.toLowerCase().includes(searchValue.toLowerCase());
170
170
  })
171
171
  .sort((a, b) => {
172
172
  if (grouped) {
@@ -219,9 +219,9 @@ const SelectBox = styled(({ className, data = [], placeholder = "Select...", arr
219
219
  };
220
220
  const handleClear = (e) => {
221
221
  e.preventDefault();
222
- e.stopPropagation();
223
222
  if (inputRef.current)
224
223
  inputRef.current.value = "";
224
+ setIsOpen(false);
225
225
  handleChangeSelection(null);
226
226
  setSelected(null);
227
227
  setSearchValue("");
@@ -434,7 +434,10 @@ const SelectBox = styled(({ className, data = [], placeholder = "Select...", arr
434
434
  setDropDownHeight(bottomHeight);
435
435
  };
436
436
  }, [topHeight, bottomHeight, isOpen]);
437
- 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: debouncedHandleOnChange, 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 })) : arrow ? (_jsx(ArrowButton, { onClick: (e) => {
437
+ 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: debouncedHandleOnChange, 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) => {
438
+ e.preventDefault();
439
+ e.stopPropagation();
440
+ } })) : arrow ? (_jsx(ArrowButton, { onClick: (e) => {
438
441
  e.preventDefault();
439
442
  // e.stopPropagation();
440
443
  }, onMouseDown: (e) => {
@@ -359,7 +359,6 @@ const TagBox = styled(({ className, data = [], placeholder = "Select tags", arro
359
359
  };
360
360
  const handleClear = (e) => {
361
361
  e.preventDefault();
362
- e.stopPropagation();
363
362
  if (inputRef === null || inputRef === void 0 ? void 0 : inputRef.current)
364
363
  inputRef.current.value = "";
365
364
  onChange === null || onChange === void 0 ? void 0 : onChange([]);
@@ -551,7 +550,10 @@ const TagBox = styled(({ className, data = [], placeholder = "Select tags", arro
551
550
  }
552
551
  update();
553
552
  }, placeholder: placeholder, size: size, readOnly: !(searchable || allowCustomValue) }))] }) }), clearable &&
554
- (selectedItems.length > 0 || !!((_f = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _f === void 0 ? void 0 : _f.value)) ? (_jsx(ClearButton, { onClick: handleClear })) : arrow ? (_jsx(ArrowButton, { onClick: (e) => {
553
+ (selectedItems.length > 0 || !!((_f = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _f === void 0 ? void 0 : _f.value)) ? (_jsx(ClearButton, { onClick: handleClear, onMouseDown: (e) => {
554
+ e.preventDefault();
555
+ e.stopPropagation();
556
+ } })) : arrow ? (_jsx(ArrowButton, { onClick: (e) => {
555
557
  e.preventDefault();
556
558
  }, onMouseDown: (e) => {
557
559
  e.preventDefault();
package/dist/index.d.ts CHANGED
@@ -26,4 +26,5 @@ export { default as Table } from "./Table";
26
26
  export { Column } from "./Table";
27
27
  export { default as MonolithUIProvider } from "./MonolithUIProvider";
28
28
  export { useMonolithUITheme } from "./MonolithUIProvider";
29
- export { default as RichTextEditor, Extensions, SlashCommands, } from "./RichTextEditor";
29
+ export { default as RichTextEditor, Extensions, SlashCommands, Controls, } from "./RichTextEditor";
30
+ export type { CustomItem, ToolbarOptions } from "./RichTextEditor";
package/dist/index.js CHANGED
@@ -24,4 +24,4 @@ export { default as Table } from "./Table";
24
24
  export { Column } from "./Table";
25
25
  export { default as MonolithUIProvider } from "./MonolithUIProvider";
26
26
  export { useMonolithUITheme } from "./MonolithUIProvider";
27
- export { default as RichTextEditor, Extensions, SlashCommands, } from "./RichTextEditor";
27
+ export { default as RichTextEditor, Extensions, SlashCommands, Controls, } from "./RichTextEditor";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monolith-forensics/monolith-ui",
3
- "version": "1.1.48",
3
+ "version": "1.1.50",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "author": "Matt Danner (Monolith Forensics LLC)",