@mezzanine-ui/react 1.4.0 → 1.4.1
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.
|
@@ -24,9 +24,6 @@ const NavigationOption = forwardRef((props, ref) => {
|
|
|
24
24
|
const currentKey = id || title || href || uuid;
|
|
25
25
|
const currentPath = useMemo(() => [...parentPath, currentKey], [parentPath, currentKey]);
|
|
26
26
|
const currentPathKey = currentPath.join('::');
|
|
27
|
-
const Component = href && !children
|
|
28
|
-
? ((_a = anchorComponent !== null && anchorComponent !== void 0 ? anchorComponent : optionsAnchorComponent) !== null && _a !== void 0 ? _a : 'a')
|
|
29
|
-
: 'div';
|
|
30
27
|
const flattenedChildren = useMemo(() => flattenChildren(children), [children]);
|
|
31
28
|
const { badge, items } = useMemo(() => {
|
|
32
29
|
let badgeComponent = null;
|
|
@@ -49,6 +46,12 @@ const NavigationOption = forwardRef((props, ref) => {
|
|
|
49
46
|
});
|
|
50
47
|
return { badge: badgeComponent, items };
|
|
51
48
|
}, [flattenedChildren]);
|
|
49
|
+
// Group vs leaf is decided by the presence of real sub-options, not by
|
|
50
|
+
// raw `children` — a lone `Badge` child is rendered inline on a leaf.
|
|
51
|
+
const hasSubOptions = items.length > 0;
|
|
52
|
+
const Component = href && !hasSubOptions
|
|
53
|
+
? ((_a = anchorComponent !== null && anchorComponent !== void 0 ? anchorComponent : optionsAnchorComponent) !== null && _a !== void 0 ? _a : 'a')
|
|
54
|
+
: 'div';
|
|
52
55
|
// Default open if current path is activated
|
|
53
56
|
useEffect(() => {
|
|
54
57
|
if (activatedPathKey === currentPathKey ||
|
|
@@ -83,7 +86,7 @@ const NavigationOption = forwardRef((props, ref) => {
|
|
|
83
86
|
resizeObserver.disconnect();
|
|
84
87
|
};
|
|
85
88
|
}, [title]);
|
|
86
|
-
return (jsxs("li", { ...rest, ref: ref, className: cx(navigationOptionClasses.host, open && navigationOptionClasses.open, !
|
|
89
|
+
return (jsxs("li", { ...rest, ref: ref, className: cx(navigationOptionClasses.host, open && navigationOptionClasses.open, !hasSubOptions && navigationOptionClasses.basic, (active !== null && active !== void 0 ? active : (activatedPath === null || activatedPath === void 0 ? void 0 : activatedPath[currentLevel - 1]) === currentKey) &&
|
|
87
90
|
navigationOptionClasses.active, collapsed && navigationOptionClasses.collapsed, (collapsed && collapsedHiddenKeys.has(currentKey)) ||
|
|
88
91
|
(!collapsed && !filter)
|
|
89
92
|
? navigationOptionClasses.hidden
|
|
@@ -95,16 +98,18 @@ const NavigationOption = forwardRef((props, ref) => {
|
|
|
95
98
|
if (collapsed) {
|
|
96
99
|
handleCollapseChange(false);
|
|
97
100
|
}
|
|
98
|
-
if (!
|
|
101
|
+
if (!hasSubOptions)
|
|
99
102
|
setActivatedPath(currentPath);
|
|
100
103
|
}, onKeyDown: (e) => {
|
|
101
104
|
if (e.key === 'Enter' || e.key === ' ') {
|
|
102
105
|
e.preventDefault();
|
|
103
106
|
setOpen(!open);
|
|
104
|
-
if (!
|
|
107
|
+
if (!hasSubOptions)
|
|
105
108
|
setActivatedPath(currentPath);
|
|
106
109
|
}
|
|
107
|
-
}, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, ref: tooltipChildRef, role: "menuitem", tabIndex: 0, children: [icon && jsx(Icon, { className: navigationOptionClasses.icon, icon: icon }), jsx("span", { className: navigationOptionClasses.titleWrapper, children: jsx(Fade, { ref: titleRef, in: collapsed === false || !icon, children: jsx("span", { className: navigationOptionClasses.title, children: collapsed && !icon
|
|
110
|
+
}, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, ref: tooltipChildRef, role: "menuitem", tabIndex: 0, children: [icon && jsx(Icon, { className: navigationOptionClasses.icon, icon: icon }), jsx("span", { className: navigationOptionClasses.titleWrapper, children: jsx(Fade, { ref: titleRef, in: collapsed === false || !icon, children: jsx("span", { className: navigationOptionClasses.title, children: collapsed && !icon
|
|
111
|
+
? Array.from(title).slice(0, 2).join('')
|
|
112
|
+
: title }) }) }), badge, hasSubOptions && (jsx(Icon, { className: navigationOptionClasses.toggleIcon, icon: GroupToggleIcon }))] })) }), hasSubOptions && !collapsed && (jsx(Collapse, { lazyMount: true, className: cx(navigationOptionClasses.childrenWrapper), in: open, children: jsx(NavigationOptionLevelContext.Provider, { value: {
|
|
108
113
|
level: currentLevel,
|
|
109
114
|
path: currentPath,
|
|
110
115
|
}, children: jsx("ul", { className: navigationOptionClasses.group, children: items }) }) }))] }));
|
package/Select/SelectTrigger.js
CHANGED
|
@@ -11,7 +11,7 @@ import cx from 'clsx';
|
|
|
11
11
|
const isMultipleSelection = (props) => props.mode === 'multiple';
|
|
12
12
|
function SelectTriggerComponent(props) {
|
|
13
13
|
var _a, _b, _c;
|
|
14
|
-
const { active, className, clearable: clearableProp = false, disabled, forceHideSuffixActionIcon, inputProps, innerRef, inputRef, isForceClearable = false, mode = 'single', onTagClose, overflowStrategy = 'counter', placeholder, readOnly, required, searchText, size = 'main', showTextInputAfterTags = false, suffixAction, suffixActionIcon: suffixActionIconProp, type = 'default', onClick, ...restTextFieldProps } = props;
|
|
14
|
+
const { active, className, clearable: clearableProp = false, disabled, error, forceHideSuffixActionIcon, inputProps, innerRef, inputRef, isForceClearable = false, mode = 'single', onTagClose, overflowStrategy = 'counter', placeholder, readOnly, required, searchText, size = 'main', showTextInputAfterTags = false, suffixAction, suffixActionIcon: suffixActionIconProp, type = 'default', onClick, ...restTextFieldProps } = props;
|
|
15
15
|
const renderValueProp = 'renderValue' in props ? props.renderValue : undefined;
|
|
16
16
|
// Exclude renderValue to avoid leaking unknown props to DOM.
|
|
17
17
|
const sanitizedTextFieldProps = (() => {
|
|
@@ -60,9 +60,7 @@ function SelectTriggerComponent(props) {
|
|
|
60
60
|
return (jsxs(TextField, { ref: innerRef, ...interactiveProps, ...sanitizedTextFieldProps, onClick: onClick, active: active, className: cx(selectClasses.trigger, selectClasses.triggerMode(mode), selectClasses.triggerSelected(Array.isArray(props.value) ? (_a = props.value) === null || _a === void 0 ? void 0 : _a.length : props.value), {
|
|
61
61
|
[selectClasses.triggerReadOnly]: readOnly,
|
|
62
62
|
[selectClasses.triggerDisabled]: disabled,
|
|
63
|
-
}, className), error: type === 'error', clearable: shouldEnableClearable, forceShowClearable: shouldEnableClearable, size: size, suffix: forceHideSuffixActionIcon ? undefined : suffixActionIcon, children: [jsx("input", { ...inputProps, ref: inputRef, "aria-autocomplete": "list", "aria-haspopup": "listbox", autoComplete: "off", className: cx(selectClasses.triggerInput, inputProps === null || inputProps === void 0 ? void 0 : inputProps.className), disabled: disabled, placeholder: placeholder, readOnly: (_b = inputProps === null || inputProps === void 0 ? void 0 : inputProps.readOnly) !== null && _b !== void 0 ? _b : true, required: required, type: "text", value: renderValue() }), isMultipleSelection(props) && ((_c = props.value) === null || _c === void 0 ? void 0 : _c.length)
|
|
64
|
-
? (jsx(SelectTriggerTags, { disabled: disabled, overflowStrategy: overflowStrategy, inputProps: inputProps, inputRef: inputRef, onTagClose: onTagClose, readOnly: readOnly, required: required, searchText: searchText, size: size, showTextInputAfterTags: showTextInputAfterTags, value: props.value }))
|
|
65
|
-
: null] }));
|
|
63
|
+
}, className), error: error || type === 'error', clearable: shouldEnableClearable, forceShowClearable: shouldEnableClearable, size: size, suffix: forceHideSuffixActionIcon ? undefined : suffixActionIcon, children: [jsx("input", { ...inputProps, ref: inputRef, "aria-autocomplete": "list", "aria-haspopup": "listbox", autoComplete: "off", className: cx(selectClasses.triggerInput, inputProps === null || inputProps === void 0 ? void 0 : inputProps.className), disabled: disabled, placeholder: placeholder, readOnly: (_b = inputProps === null || inputProps === void 0 ? void 0 : inputProps.readOnly) !== null && _b !== void 0 ? _b : true, required: required, type: "text", value: renderValue() }), isMultipleSelection(props) && ((_c = props.value) === null || _c === void 0 ? void 0 : _c.length) ? (jsx(SelectTriggerTags, { disabled: disabled, overflowStrategy: overflowStrategy, inputProps: inputProps, inputRef: inputRef, onTagClose: onTagClose, readOnly: readOnly, required: required, searchText: searchText, size: size, showTextInputAfterTags: showTextInputAfterTags, value: props.value })) : null] }));
|
|
66
64
|
}
|
|
67
65
|
const SelectTrigger = forwardRef((props, ref) => {
|
|
68
66
|
if (props.mode === 'multiple') {
|