@astral/ui 4.104.0 → 4.104.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.
- package/components/Select/Select.js +1 -1
- package/components/Select/useLogic/useLogic.js +2 -2
- package/components/Select/useLogic/utils/isShowingPlaceholder/index.d.ts +1 -0
- package/components/Select/useLogic/utils/isShowingPlaceholder/index.js +1 -0
- package/components/Select/useLogic/utils/isShowingPlaceholder/isShowingPlaceholder.d.ts +1 -0
- package/components/Select/useLogic/utils/isShowingPlaceholder/isShowingPlaceholder.js +12 -0
- package/node/components/Select/Select.js +1 -1
- package/node/components/Select/useLogic/useLogic.js +2 -2
- package/node/components/Select/useLogic/utils/isShowingPlaceholder/index.d.ts +1 -0
- package/node/components/Select/useLogic/utils/isShowingPlaceholder/index.js +17 -0
- package/node/components/Select/useLogic/utils/isShowingPlaceholder/isShowingPlaceholder.d.ts +1 -0
- package/node/components/Select/useLogic/utils/isShowingPlaceholder/isShowingPlaceholder.js +16 -0
- package/package.json +1 -1
|
@@ -47,6 +47,6 @@ const SelectInner = ({ required, getOptionLabel, placeholder, helperText, hideHe
|
|
|
47
47
|
}
|
|
48
48
|
return findMenuItemsLabel(children, selectedOptions);
|
|
49
49
|
};
|
|
50
|
-
return (_jsxs(FormControl, { error: error, fullWidth: fullWidth, children: [label && (_jsx(InputLabel, { htmlFor: "grouped-select", required: required, disabled: disabled, children: label })), _jsxs(StyledSelect, { ...props, value: value === null ? '' : value, open: isOpened, disabled: disabled, onOpen: openSelect, onClose: closeSelect, renderValue: renderValue, IconComponent: () => null, displayEmpty: true, ref: ref, fullWidth: fullWidth, onChange: handleChangeOption, "$isShowingPlaceholder": isShowingPlaceholder, endAdornment: _jsxs(EndAdornmentWrapper, { children: [loading && _jsx(Loader, { color: "primary", size: "small" }), !loading && isShowingClearButton && (_jsx(ClearButton, { disabled: disabled, ref: resetButtonRef, onClick: onClearAll })), !loading && (_jsx(IconButton, { variant: "text", disabled: disabled, onClick: openSelect, children: !isOpened ? _jsx(DownOutlineMd, {}) : _jsx(UpOutlineMd, {}) }))] }), children: [_jsx(Placeholder, { value: "", children: placeholder }), !loading && isShowingSelectAll && (_jsxs(MenuItem, { className: selectAllClassName, selected: isSelectedAll, value: SELECT_ALL_VALUE, children: [_jsx(ListItemIcon, { children: _jsx(Checkbox, { checked: isSelectedAll, indeterminate: isIndeterminate }) }), "\u0412\u044B\u0431\u0440\u0430\u0442\u044C \u0432\u0441\u0435"] })), !loading && children, !loading && isNoData && _jsx(StateWrapper, { children: "\u041D\u0435\u0442 \u0434\u0430\u043D\u043D\u044B\u0445" })] }), _jsx(FormHelperText, { error: error, success: success, hideHelperText: hideHelperText, children: helperText })] }));
|
|
50
|
+
return (_jsxs(FormControl, { error: error, fullWidth: fullWidth, children: [label && (_jsx(InputLabel, { htmlFor: "grouped-select", required: required, disabled: disabled, children: label })), _jsxs(StyledSelect, { ...props, value: value === null || value === undefined ? '' : value, open: isOpened, disabled: disabled, onOpen: openSelect, onClose: closeSelect, renderValue: renderValue, IconComponent: () => null, displayEmpty: true, ref: ref, fullWidth: fullWidth, onChange: handleChangeOption, "$isShowingPlaceholder": isShowingPlaceholder, endAdornment: _jsxs(EndAdornmentWrapper, { children: [loading && _jsx(Loader, { color: "primary", size: "small" }), !loading && isShowingClearButton && (_jsx(ClearButton, { disabled: disabled, ref: resetButtonRef, onClick: onClearAll })), !loading && (_jsx(IconButton, { variant: "text", disabled: disabled, onClick: openSelect, children: !isOpened ? _jsx(DownOutlineMd, {}) : _jsx(UpOutlineMd, {}) }))] }), children: [_jsx(Placeholder, { value: "", children: placeholder }), !loading && isShowingSelectAll && (_jsxs(MenuItem, { className: selectAllClassName, selected: isSelectedAll, value: SELECT_ALL_VALUE, children: [_jsx(ListItemIcon, { children: _jsx(Checkbox, { checked: isSelectedAll, indeterminate: isIndeterminate }) }), "\u0412\u044B\u0431\u0440\u0430\u0442\u044C \u0432\u0441\u0435"] })), !loading && children, !loading && isNoData && _jsx(StateWrapper, { children: "\u041D\u0435\u0442 \u0434\u0430\u043D\u043D\u044B\u0445" })] }), _jsx(FormHelperText, { error: error, success: success, hideHelperText: hideHelperText, children: helperText })] }));
|
|
51
51
|
};
|
|
52
52
|
export const Select = forwardRefWithGeneric(SelectInner);
|
|
@@ -4,6 +4,7 @@ import { MenuItem } from '../../MenuItem';
|
|
|
4
4
|
import { getNodeText } from '../../utils/getNodeText';
|
|
5
5
|
import { isSyncReactElement } from '../../utils/isSyncReactElement';
|
|
6
6
|
import { SELECT_ALL_VALUE } from '../constants';
|
|
7
|
+
import { isShowingPlaceholder } from './utils/isShowingPlaceholder';
|
|
7
8
|
export const useLogic = ({ value, onChange, children, open: externalIsOpened, defaultOpen, multiple, isEnableAllSelection, isShowClearButton = true, valueOptions, onSelectAll, onUnselectAll, name, placeholder, onClose, onOpen, loading, }) => {
|
|
8
9
|
const [isOpened, setOpened] = useState(!loading && (defaultOpen || externalIsOpened || false));
|
|
9
10
|
const resetButtonRef = useRef(null);
|
|
@@ -111,7 +112,6 @@ export const useLogic = ({ value, onChange, children, open: externalIsOpened, de
|
|
|
111
112
|
}
|
|
112
113
|
return null;
|
|
113
114
|
};
|
|
114
|
-
const isShowingPlaceholder = Boolean((value === '' || Array.isArray(value)) && !!placeholder);
|
|
115
115
|
return {
|
|
116
116
|
isOpened,
|
|
117
117
|
isNoData,
|
|
@@ -128,6 +128,6 @@ export const useLogic = ({ value, onChange, children, open: externalIsOpened, de
|
|
|
128
128
|
handleChangeArrayValue,
|
|
129
129
|
selectAllClassName,
|
|
130
130
|
findMenuItemsLabel,
|
|
131
|
-
isShowingPlaceholder,
|
|
131
|
+
isShowingPlaceholder: isShowingPlaceholder(value, placeholder),
|
|
132
132
|
};
|
|
133
133
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './isShowingPlaceholder';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './isShowingPlaceholder';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isShowingPlaceholder: (value: unknown, placeholder?: string) => boolean;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const isShowingPlaceholder = (value, placeholder) => {
|
|
2
|
+
if (!placeholder) {
|
|
3
|
+
return false;
|
|
4
|
+
}
|
|
5
|
+
if (value === null || value === undefined || value === '') {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
if (Array.isArray(value) && value.length === 0) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
return false;
|
|
12
|
+
};
|
|
@@ -53,6 +53,6 @@ const SelectInner = ({ required, getOptionLabel, placeholder, helperText, hideHe
|
|
|
53
53
|
}
|
|
54
54
|
return findMenuItemsLabel(children, selectedOptions);
|
|
55
55
|
};
|
|
56
|
-
return ((0, jsx_runtime_1.jsxs)(FormControl_1.default, { error: error, fullWidth: fullWidth, children: [label && ((0, jsx_runtime_1.jsx)(InputLabel_1.default, { htmlFor: "grouped-select", required: required, disabled: disabled, children: label })), (0, jsx_runtime_1.jsxs)(styles_1.StyledSelect, { ...props, value: value === null ? '' : value, open: isOpened, disabled: disabled, onOpen: openSelect, onClose: closeSelect, renderValue: renderValue, IconComponent: () => null, displayEmpty: true, ref: ref, fullWidth: fullWidth, onChange: handleChangeOption, "$isShowingPlaceholder": isShowingPlaceholder, endAdornment: (0, jsx_runtime_1.jsxs)(styles_1.EndAdornmentWrapper, { children: [loading && (0, jsx_runtime_1.jsx)(Loader_1.Loader, { color: "primary", size: "small" }), !loading && isShowingClearButton && ((0, jsx_runtime_1.jsx)(ClearButton, { disabled: disabled, ref: resetButtonRef, onClick: onClearAll })), !loading && ((0, jsx_runtime_1.jsx)(IconButton_1.IconButton, { variant: "text", disabled: disabled, onClick: openSelect, children: !isOpened ? (0, jsx_runtime_1.jsx)(DownOutlineMd_1.DownOutlineMd, {}) : (0, jsx_runtime_1.jsx)(UpOutlineMd_1.UpOutlineMd, {}) }))] }), children: [(0, jsx_runtime_1.jsx)(styles_1.Placeholder, { value: "", children: placeholder }), !loading && isShowingSelectAll && ((0, jsx_runtime_1.jsxs)(MenuItem_1.MenuItem, { className: selectAllClassName, selected: isSelectedAll, value: constants_1.SELECT_ALL_VALUE, children: [(0, jsx_runtime_1.jsx)(ListItemIcon_1.default, { children: (0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, { checked: isSelectedAll, indeterminate: isIndeterminate }) }), "\u0412\u044B\u0431\u0440\u0430\u0442\u044C \u0432\u0441\u0435"] })), !loading && children, !loading && isNoData && (0, jsx_runtime_1.jsx)(styles_1.StateWrapper, { children: "\u041D\u0435\u0442 \u0434\u0430\u043D\u043D\u044B\u0445" })] }), (0, jsx_runtime_1.jsx)(FormHelperText_1.FormHelperText, { error: error, success: success, hideHelperText: hideHelperText, children: helperText })] }));
|
|
56
|
+
return ((0, jsx_runtime_1.jsxs)(FormControl_1.default, { error: error, fullWidth: fullWidth, children: [label && ((0, jsx_runtime_1.jsx)(InputLabel_1.default, { htmlFor: "grouped-select", required: required, disabled: disabled, children: label })), (0, jsx_runtime_1.jsxs)(styles_1.StyledSelect, { ...props, value: value === null || value === undefined ? '' : value, open: isOpened, disabled: disabled, onOpen: openSelect, onClose: closeSelect, renderValue: renderValue, IconComponent: () => null, displayEmpty: true, ref: ref, fullWidth: fullWidth, onChange: handleChangeOption, "$isShowingPlaceholder": isShowingPlaceholder, endAdornment: (0, jsx_runtime_1.jsxs)(styles_1.EndAdornmentWrapper, { children: [loading && (0, jsx_runtime_1.jsx)(Loader_1.Loader, { color: "primary", size: "small" }), !loading && isShowingClearButton && ((0, jsx_runtime_1.jsx)(ClearButton, { disabled: disabled, ref: resetButtonRef, onClick: onClearAll })), !loading && ((0, jsx_runtime_1.jsx)(IconButton_1.IconButton, { variant: "text", disabled: disabled, onClick: openSelect, children: !isOpened ? (0, jsx_runtime_1.jsx)(DownOutlineMd_1.DownOutlineMd, {}) : (0, jsx_runtime_1.jsx)(UpOutlineMd_1.UpOutlineMd, {}) }))] }), children: [(0, jsx_runtime_1.jsx)(styles_1.Placeholder, { value: "", children: placeholder }), !loading && isShowingSelectAll && ((0, jsx_runtime_1.jsxs)(MenuItem_1.MenuItem, { className: selectAllClassName, selected: isSelectedAll, value: constants_1.SELECT_ALL_VALUE, children: [(0, jsx_runtime_1.jsx)(ListItemIcon_1.default, { children: (0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, { checked: isSelectedAll, indeterminate: isIndeterminate }) }), "\u0412\u044B\u0431\u0440\u0430\u0442\u044C \u0432\u0441\u0435"] })), !loading && children, !loading && isNoData && (0, jsx_runtime_1.jsx)(styles_1.StateWrapper, { children: "\u041D\u0435\u0442 \u0434\u0430\u043D\u043D\u044B\u0445" })] }), (0, jsx_runtime_1.jsx)(FormHelperText_1.FormHelperText, { error: error, success: success, hideHelperText: hideHelperText, children: helperText })] }));
|
|
57
57
|
};
|
|
58
58
|
exports.Select = (0, forwardRefWithGeneric_1.forwardRefWithGeneric)(SelectInner);
|
|
@@ -7,6 +7,7 @@ const MenuItem_2 = require("../../MenuItem");
|
|
|
7
7
|
const getNodeText_1 = require("../../utils/getNodeText");
|
|
8
8
|
const isSyncReactElement_1 = require("../../utils/isSyncReactElement");
|
|
9
9
|
const constants_1 = require("../constants");
|
|
10
|
+
const isShowingPlaceholder_1 = require("./utils/isShowingPlaceholder");
|
|
10
11
|
const useLogic = ({ value, onChange, children, open: externalIsOpened, defaultOpen, multiple, isEnableAllSelection, isShowClearButton = true, valueOptions, onSelectAll, onUnselectAll, name, placeholder, onClose, onOpen, loading, }) => {
|
|
11
12
|
const [isOpened, setOpened] = (0, react_1.useState)(!loading && (defaultOpen || externalIsOpened || false));
|
|
12
13
|
const resetButtonRef = (0, react_1.useRef)(null);
|
|
@@ -114,7 +115,6 @@ const useLogic = ({ value, onChange, children, open: externalIsOpened, defaultOp
|
|
|
114
115
|
}
|
|
115
116
|
return null;
|
|
116
117
|
};
|
|
117
|
-
const isShowingPlaceholder = Boolean((value === '' || Array.isArray(value)) && !!placeholder);
|
|
118
118
|
return {
|
|
119
119
|
isOpened,
|
|
120
120
|
isNoData,
|
|
@@ -131,7 +131,7 @@ const useLogic = ({ value, onChange, children, open: externalIsOpened, defaultOp
|
|
|
131
131
|
handleChangeArrayValue,
|
|
132
132
|
selectAllClassName,
|
|
133
133
|
findMenuItemsLabel,
|
|
134
|
-
isShowingPlaceholder,
|
|
134
|
+
isShowingPlaceholder: (0, isShowingPlaceholder_1.isShowingPlaceholder)(value, placeholder),
|
|
135
135
|
};
|
|
136
136
|
};
|
|
137
137
|
exports.useLogic = useLogic;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './isShowingPlaceholder';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./isShowingPlaceholder"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isShowingPlaceholder: (value: unknown, placeholder?: string) => boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isShowingPlaceholder = void 0;
|
|
4
|
+
const isShowingPlaceholder = (value, placeholder) => {
|
|
5
|
+
if (!placeholder) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
if (value === null || value === undefined || value === '') {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
if (Array.isArray(value) && value.length === 0) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
};
|
|
16
|
+
exports.isShowingPlaceholder = isShowingPlaceholder;
|