@monolith-forensics/monolith-ui 1.3.28 → 1.3.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useTheme } from "styled-components";
2
+ import styled, { useTheme } from "styled-components";
3
3
  import { useFloating, flip, offset, FloatingPortal, autoUpdate, } from "@floating-ui/react";
4
4
  import { useCallback, useEffect, useRef, useState } from "react";
5
5
  import { Input, FieldLabel, Tooltip, Loader } from "..";
@@ -9,6 +9,12 @@ import { DEFAULT_DROPDOWN_HEIGHT, DROPDOWN_OFFSET, getEmptyMessage, KEYBOARD_KEY
9
9
  import { StyledInputContainer, StyledInnerItemContainer, EmptyComponent, GroupTitle, ActionMenu, StyledItem, StyledContainer, } from "./select-box.styled-components";
10
10
  // Re-export for backward compatibility
11
11
  export { StyledInputContainer };
12
+ const StyledInput = styled(Input) `
13
+ &[disabled] {
14
+ opacity: 1;
15
+ pointer-events: none;
16
+ }
17
+ `;
12
18
  export const SelectBox = ({ className, data = [], placeholder = "Select...", arrow = true, onChange, onSearch, searchFn, onScroll, loading, defaultValue, value, 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
13
19
  DropDownProps = {}, debounceTime = 175, sort = false, disabled = false, }) => {
14
20
  var _a, _b, _c, _d, _e, _f;
@@ -193,6 +199,8 @@ DropDownProps = {}, debounceTime = 175, sort = false, disabled = false, }) => {
193
199
  }, [onChange]);
194
200
  const handleKeyDown = (e) => {
195
201
  var _a;
202
+ if (disabled)
203
+ return;
196
204
  // Escape key
197
205
  if (e.key === KEYBOARD_KEYS.ESCAPE) {
198
206
  const reference = (_a = refs === null || refs === void 0 ? void 0 : refs.reference) === null || _a === void 0 ? void 0 : _a.current;
@@ -353,7 +361,7 @@ DropDownProps = {}, debounceTime = 175, sort = false, disabled = false, }) => {
353
361
  // ============================================================================
354
362
  // Render
355
363
  // ============================================================================
356
- return (_jsxs(StyledContainer, { 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, "data-disabled": disabled, children: [_jsx(Input, { ref: inputRef, value: inputValue, onChange: handleInputChange, onFocus: handleFocus, autoFocus: focused, placeholder: placeholder, size: size, readOnly: !searchable && !allowCustomValue, "data-button-right": arrow || clearable, style: isOpen ? { borderColor: theme.palette.primary.main } : {} }), renderActionButton()] }), isOpen && (_jsx(FloatingPortal, { preserveTabOrder: true, children: _jsx(StyledFloatContainer, { ref: (ref) => {
364
+ return (_jsxs(StyledContainer, { 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, "data-disabled": disabled, tabIndex: disabled ? -1 : 0, children: [_jsx(StyledInput, { ref: inputRef, value: inputValue, onChange: handleInputChange, onFocus: handleFocus, autoFocus: focused, disabled: disabled, tabIndex: disabled ? -1 : 0, placeholder: placeholder, size: size, readOnly: !searchable && !allowCustomValue, "data-button-right": arrow || clearable, style: isOpen ? { borderColor: theme.palette.primary.main } : {} }), renderActionButton()] }), isOpen && (_jsx(FloatingPortal, { preserveTabOrder: true, children: _jsx(StyledFloatContainer, { ref: (ref) => {
357
365
  containerRef.current = ref;
358
366
  refs.setFloating(ref);
359
367
  }, style: floatingStyles, className: "mfFloating", children: _jsxs(StyledContent, Object.assign({ className: "mfFloatingContent", style: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monolith-forensics/monolith-ui",
3
- "version": "1.3.28",
3
+ "version": "1.3.30",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "author": "Matt Danner (Monolith Forensics LLC)",