@astral/ui 4.104.0 → 4.104.2

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.
@@ -83,6 +83,9 @@ export const notify = {
83
83
  });
84
84
  },
85
85
  stop: () => {
86
+ if (!toastId) {
87
+ return;
88
+ }
86
89
  if (initialOptions?.containerId) {
87
90
  toast.dismiss({
88
91
  id: toastId,
@@ -1,9 +1,14 @@
1
- import { NOTIFY_CONTAINER_ID, NOTIFY_STATIC_CONTAINER_ID, } from '../../constants';
1
+ import { NOTIFY_CONTAINER_ID, NOTIFY_STATIC_CONTAINER_ID, notifyClassnames, } from '../../constants';
2
+ const checkHasStackContainer = () => typeof document !== 'undefined' &&
3
+ Boolean(document.querySelector(`.${notifyClassnames.stackHost}`));
2
4
  const getContainerId = ({ containerId, isStatic, }) => {
3
5
  if (containerId) {
4
6
  return containerId;
5
7
  }
6
- return isStatic ? NOTIFY_STATIC_CONTAINER_ID : NOTIFY_CONTAINER_ID;
8
+ if (isStatic && checkHasStackContainer()) {
9
+ return NOTIFY_STATIC_CONTAINER_ID;
10
+ }
11
+ return NOTIFY_CONTAINER_ID;
7
12
  };
8
13
  export const getNotifyOptions = ({ isStatic, containerId, hideProgressBar, autoClose, ...options }) => ({
9
14
  containerId: getContainerId({ containerId, isStatic }),
@@ -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
+ };
@@ -86,6 +86,9 @@ exports.notify = {
86
86
  });
87
87
  },
88
88
  stop: () => {
89
+ if (!toastId) {
90
+ return;
91
+ }
89
92
  if (initialOptions?.containerId) {
90
93
  react_toastify_next_1.toast.dismiss({
91
94
  id: toastId,
@@ -2,11 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getNotifyOptions = void 0;
4
4
  const constants_1 = require("../../constants");
5
+ const checkHasStackContainer = () => typeof document !== 'undefined' &&
6
+ Boolean(document.querySelector(`.${constants_1.notifyClassnames.stackHost}`));
5
7
  const getContainerId = ({ containerId, isStatic, }) => {
6
8
  if (containerId) {
7
9
  return containerId;
8
10
  }
9
- return isStatic ? constants_1.NOTIFY_STATIC_CONTAINER_ID : constants_1.NOTIFY_CONTAINER_ID;
11
+ if (isStatic && checkHasStackContainer()) {
12
+ return constants_1.NOTIFY_STATIC_CONTAINER_ID;
13
+ }
14
+ return constants_1.NOTIFY_CONTAINER_ID;
10
15
  };
11
16
  const getNotifyOptions = ({ isStatic, containerId, hideProgressBar, autoClose, ...options }) => ({
12
17
  containerId: getContainerId({ containerId, isStatic }),
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astral/ui",
3
- "version": "4.104.0",
3
+ "version": "4.104.2",
4
4
  "browser": "./index.js",
5
5
  "main": "./node/index.js",
6
6
  "dependencies": {