@megha-ui/react 1.2.182 → 1.2.185
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.
|
@@ -37,9 +37,8 @@ interface DropdownProps {
|
|
|
37
37
|
border?: string;
|
|
38
38
|
selectedCharLength?: number;
|
|
39
39
|
menuFrom?: string;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
*/
|
|
40
|
+
compactDisplay?: boolean;
|
|
41
|
+
ultraCompactDisplay?: boolean;
|
|
43
42
|
autoPosition?: boolean;
|
|
44
43
|
Tooltip?: any;
|
|
45
44
|
DropDownIcon?: any;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
import { useDensity } from "../../context/DensityContext";
|
|
3
4
|
import Checkbox from "../checkbox";
|
|
4
5
|
import Loader from "../loader";
|
|
5
6
|
import Block from "../block";
|
|
6
7
|
import Text from "../text";
|
|
7
8
|
import Button from "../button";
|
|
8
9
|
import { HiChevronDown } from "react-icons/hi";
|
|
9
|
-
const Dropdown = ({ options, selectedValues, onChange, placeholder = "Select...", isMultiple = false, isSelectAll = false, className, style, labelFontSize, labelFontWeight, labelMarginBottom, asteriskColor, label, disabled = false, width, searchEnabled = true, dropdownListWidth, marginBottom, marginTop, marginRight, marginLeft, required, dropdownListBG, searchBorderColor = "#2377ba", maxDropdownHeight = "12rem", border = "1px solid #dbdfe9", selectedCharLength = 0, menuFrom = "left", Tooltip, DropDownIcon, onMenuClose, isClear, ClearIcon, clearId, selectedDisplay, checkboxWrapper, isSort = true, onSelectChange, isLoading = false, onApplyChange, withTooltip = false, isCreatable = false, onCreate = () => { }, autoPosition = false, }) => {
|
|
10
|
+
const Dropdown = ({ options, selectedValues, onChange, placeholder = "Select...", isMultiple = false, isSelectAll = false, className, style, labelFontSize, labelFontWeight, labelMarginBottom, asteriskColor, label, disabled = false, width, searchEnabled = true, dropdownListWidth, marginBottom, marginTop, marginRight, marginLeft, required, dropdownListBG, searchBorderColor = "#2377ba", maxDropdownHeight = "12rem", border = "1px solid #dbdfe9", selectedCharLength = 0, menuFrom = "left", Tooltip, DropDownIcon, onMenuClose, isClear, ClearIcon, clearId, selectedDisplay, checkboxWrapper, isSort = true, onSelectChange, isLoading = false, onApplyChange, withTooltip = false, isCreatable = false, onCreate = () => { }, autoPosition = false, compactDisplay = false, ultraCompactDisplay = false, }) => {
|
|
10
11
|
var _a, _b;
|
|
12
|
+
const { density } = useDensity();
|
|
11
13
|
const [isOpen, setIsOpen] = useState(false);
|
|
12
14
|
const [searchTerm, setSearchTerm] = useState("");
|
|
13
15
|
const [filteredOptions, setFilteredOptions] = useState(options);
|
|
@@ -289,7 +291,15 @@ const Dropdown = ({ options, selectedValues, onChange, placeholder = "Select..."
|
|
|
289
291
|
marginTop,
|
|
290
292
|
marginRight,
|
|
291
293
|
marginLeft,
|
|
292
|
-
}, children: [label && (_jsxs("p", { style: labelStyle, children: [label, required && _jsx("span", { style: asteriskStyle, children: " *" })] })), _jsxs("div", { ref: wrapperRef, className: `${className}`, style: Object.assign({ border, borderRadius: 4, padding: "0 0.5rem", alignItems: "center", display: "flex", minHeight:
|
|
294
|
+
}, children: [label && (_jsxs("p", { style: labelStyle, children: [label, required && _jsx("span", { style: asteriskStyle, children: " *" })] })), _jsxs("div", { ref: wrapperRef, className: `${className}`, style: Object.assign({ border, borderRadius: 4, padding: "0 0.5rem", alignItems: "center", display: "flex", minHeight: `var(--control-min-height, ${ultraCompactDisplay
|
|
295
|
+
? "1.5rem"
|
|
296
|
+
: compactDisplay
|
|
297
|
+
? "2rem"
|
|
298
|
+
: density === "ultra-compact"
|
|
299
|
+
? "1.5rem"
|
|
300
|
+
: density === "compact"
|
|
301
|
+
? "2rem"
|
|
302
|
+
: "2.5rem"})`, position: "relative" }, style), children: [_jsxs("div", { style: {
|
|
293
303
|
display: "flex",
|
|
294
304
|
alignItems: "center",
|
|
295
305
|
justifyContent: "space-between",
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export type DensityMode = "normal" | "compact" | "ultra-compact";
|
|
3
|
+
type DensityContextValue = {
|
|
4
|
+
density: DensityMode;
|
|
5
|
+
setDensity: (d: DensityMode) => void;
|
|
6
|
+
};
|
|
7
|
+
export declare const DensityProvider: React.FC<{
|
|
8
|
+
initialDensity?: DensityMode;
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
}>;
|
|
11
|
+
export declare const useDensity: () => DensityContextValue;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useMemo, useState } from "react";
|
|
3
|
+
const DensityContext = createContext({
|
|
4
|
+
density: "normal",
|
|
5
|
+
setDensity: () => { },
|
|
6
|
+
});
|
|
7
|
+
export const DensityProvider = ({ initialDensity = "normal", children }) => {
|
|
8
|
+
const [density, setDensity] = useState(initialDensity);
|
|
9
|
+
const value = useMemo(() => ({ density, setDensity }), [density]);
|
|
10
|
+
return _jsx(DensityContext.Provider, { value: value, children: children });
|
|
11
|
+
};
|
|
12
|
+
export const useDensity = () => useContext(DensityContext);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@megha-ui/react",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.185",
|
|
4
4
|
"description": "A collection of reusable UI components for React applications, built with TypeScript.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -8,7 +8,10 @@
|
|
|
8
8
|
"scripts": {
|
|
9
9
|
"build": "tsc",
|
|
10
10
|
"prepublishOnly": "npm run build",
|
|
11
|
-
"test": "jest"
|
|
11
|
+
"test": "jest",
|
|
12
|
+
"release:patch": "npm version patch && npm publish --access public",
|
|
13
|
+
"release:minor": "npm version minor && npm publish --access public",
|
|
14
|
+
"release:major": "npm version major && npm publish --access public"
|
|
12
15
|
},
|
|
13
16
|
"repository": {
|
|
14
17
|
"type": "git",
|