@astral/ui 0.20.0 → 0.21.0

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.
Files changed (81) hide show
  1. package/Dialog/types.d.ts +1 -3
  2. package/DialogTitle/DialogTitle.js +4 -1
  3. package/DialogTitle/types.d.ts +2 -2
  4. package/Select/Select.d.ts +1 -1
  5. package/Select/Select.js +6 -3
  6. package/Select/types.d.ts +1 -0
  7. package/SideDialog/SideDialog.d.ts +3 -0
  8. package/SideDialog/SideDialog.js +33 -0
  9. package/SideDialog/index.d.ts +2 -0
  10. package/SideDialog/index.js +14 -0
  11. package/SideDialog/styled.d.ts +4 -0
  12. package/SideDialog/styled.js +11 -0
  13. package/SideDialog/types.d.ts +4 -0
  14. package/SideDialog/types.js +2 -0
  15. package/SideDialogActions/SideDialogActions.d.ts +1 -0
  16. package/SideDialogActions/SideDialogActions.js +5 -0
  17. package/SideDialogActions/index.d.ts +1 -0
  18. package/SideDialogActions/index.js +13 -0
  19. package/SideDialogActions/types.d.ts +1 -0
  20. package/SideDialogActions/types.js +2 -0
  21. package/SideDialogContent/SideDialogContent.d.ts +1 -0
  22. package/SideDialogContent/SideDialogContent.js +5 -0
  23. package/SideDialogContent/index.d.ts +1 -0
  24. package/SideDialogContent/index.js +13 -0
  25. package/SideDialogContent/types.d.ts +1 -0
  26. package/SideDialogContent/types.js +2 -0
  27. package/SideDialogContentText/SideDialogContentText.d.ts +1 -0
  28. package/SideDialogContentText/SideDialogContentText.js +5 -0
  29. package/SideDialogContentText/index.d.ts +1 -0
  30. package/SideDialogContentText/index.js +13 -0
  31. package/SideDialogContentText/types.d.ts +1 -0
  32. package/SideDialogContentText/types.js +2 -0
  33. package/SideDialogTitle/SideDialogTitle.d.ts +1 -0
  34. package/SideDialogTitle/SideDialogTitle.js +5 -0
  35. package/SideDialogTitle/index.d.ts +1 -0
  36. package/SideDialogTitle/index.js +13 -0
  37. package/SideDialogTitle/types.d.ts +1 -0
  38. package/SideDialogTitle/types.js +2 -0
  39. package/esm/Dialog/types.d.ts +1 -3
  40. package/esm/DialogTitle/DialogTitle.js +4 -1
  41. package/esm/DialogTitle/types.d.ts +2 -2
  42. package/esm/Select/Select.d.ts +1 -1
  43. package/esm/Select/Select.js +6 -3
  44. package/esm/Select/types.d.ts +1 -0
  45. package/esm/SideDialog/SideDialog.d.ts +3 -0
  46. package/esm/SideDialog/SideDialog.js +29 -0
  47. package/esm/SideDialog/index.d.ts +2 -0
  48. package/esm/SideDialog/index.js +2 -0
  49. package/esm/SideDialog/styled.d.ts +4 -0
  50. package/esm/SideDialog/styled.js +8 -0
  51. package/esm/SideDialog/types.d.ts +4 -0
  52. package/esm/SideDialog/types.js +1 -0
  53. package/esm/SideDialogActions/SideDialogActions.d.ts +1 -0
  54. package/esm/SideDialogActions/SideDialogActions.js +1 -0
  55. package/esm/SideDialogActions/index.d.ts +1 -0
  56. package/esm/SideDialogActions/index.js +1 -0
  57. package/esm/SideDialogActions/types.d.ts +1 -0
  58. package/esm/SideDialogActions/types.js +1 -0
  59. package/esm/SideDialogContent/SideDialogContent.d.ts +1 -0
  60. package/esm/SideDialogContent/SideDialogContent.js +1 -0
  61. package/esm/SideDialogContent/index.d.ts +1 -0
  62. package/esm/SideDialogContent/index.js +1 -0
  63. package/esm/SideDialogContent/types.d.ts +1 -0
  64. package/esm/SideDialogContent/types.js +1 -0
  65. package/esm/SideDialogContentText/SideDialogContentText.d.ts +1 -0
  66. package/esm/SideDialogContentText/SideDialogContentText.js +1 -0
  67. package/esm/SideDialogContentText/index.d.ts +1 -0
  68. package/esm/SideDialogContentText/index.js +1 -0
  69. package/esm/SideDialogContentText/types.d.ts +1 -0
  70. package/esm/SideDialogContentText/types.js +1 -0
  71. package/esm/SideDialogTitle/SideDialogTitle.d.ts +1 -0
  72. package/esm/SideDialogTitle/SideDialogTitle.js +1 -0
  73. package/esm/SideDialogTitle/index.d.ts +1 -0
  74. package/esm/SideDialogTitle/index.js +1 -0
  75. package/esm/SideDialogTitle/types.d.ts +1 -0
  76. package/esm/SideDialogTitle/types.js +1 -0
  77. package/esm/index.d.ts +5 -0
  78. package/esm/index.js +5 -0
  79. package/index.d.ts +5 -0
  80. package/index.js +5 -0
  81. package/package.json +2 -2
package/Dialog/types.d.ts CHANGED
@@ -1,7 +1,5 @@
1
- import React from 'react';
2
1
  import { DialogProps as MuiDialogProps } from '@mui/material';
3
- export declare type DialogProps = Omit<MuiDialogProps, 'onClose'> & {
2
+ export declare type DialogProps = MuiDialogProps & {
4
3
  title?: string;
5
4
  disableBackdropClick?: boolean;
6
- onClose?: (event?: React.MouseEvent<HTMLButtonElement>, reason?: 'backdropClick' | 'escapeKeyDown') => void;
7
5
  };
@@ -26,9 +26,12 @@ exports.DialogTitle = void 0;
26
26
  var jsx_runtime_1 = require("react/jsx-runtime");
27
27
  var material_1 = require("@mui/material");
28
28
  var icons_1 = require("@astral/icons");
29
+ var react_1 = require("react");
29
30
  var IconButton_1 = require("../IconButton");
30
31
  var DialogTitle = function (_a) {
32
+ // 'escapeKeyDown' в документашке написано что это опциональный тип, и можно стрингу любую туда закидывать, а по факту либо escapeKeyDown либо backdropClick
31
33
  var children = _a.children, onClose = _a.onClose, props = __rest(_a, ["children", "onClose"]);
32
- return ((0, jsx_runtime_1.jsxs)(material_1.DialogTitle, __assign({}, props, { children: [children, onClose && ((0, jsx_runtime_1.jsx)(IconButton_1.IconButton, __assign({ variant: "text", onClick: onClose }, { children: (0, jsx_runtime_1.jsx)(icons_1.CrossOutlineMd, {}, void 0) }), void 0))] }), void 0));
34
+ var onClickTitle = (0, react_1.useCallback)(function (e) { return onClose && onClose(e, 'escapeKeyDown'); }, [onClose]);
35
+ return ((0, jsx_runtime_1.jsxs)(material_1.DialogTitle, __assign({}, props, { children: [children, onClose && ((0, jsx_runtime_1.jsx)(IconButton_1.IconButton, __assign({ variant: "text", onClick: onClickTitle }, { children: (0, jsx_runtime_1.jsx)(icons_1.CrossOutlineMd, {}, void 0) }), void 0))] }), void 0));
33
36
  };
34
37
  exports.DialogTitle = DialogTitle;
@@ -1,4 +1,4 @@
1
- import { DialogTitleProps as MuiDialogTitleProps } from '@mui/material';
1
+ import { ModalProps, DialogTitleProps as MuiDialogTitleProps } from '@mui/material';
2
2
  export declare type DialogTitleProps = MuiDialogTitleProps & {
3
- onClose?: () => void;
3
+ onClose?: ModalProps['onClose'];
4
4
  };
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import { SelectProps } from './types';
3
- export declare const Select: ({ multiple, loading, placeholder, helperText, success, children, label, error, ...props }: SelectProps) => JSX.Element;
3
+ export declare const Select: ({ multiple, loading, placeholder, getOptionLabel, helperText, success, children, label, error, ...props }: SelectProps) => JSX.Element;
package/Select/Select.js CHANGED
@@ -35,17 +35,20 @@ var CircularProgress_1 = require("../CircularProgress");
35
35
  var MenuItem_1 = require("../MenuItem");
36
36
  var styled_1 = require("./styled");
37
37
  var Select = function (_a) {
38
- var multiple = _a.multiple, loading = _a.loading, placeholder = _a.placeholder, helperText = _a.helperText, success = _a.success, children = _a.children, label = _a.label, error = _a.error, props = __rest(_a, ["multiple", "loading", "placeholder", "helperText", "success", "children", "label", "error"]);
38
+ var multiple = _a.multiple, loading = _a.loading, placeholder = _a.placeholder, _b = _a.getOptionLabel, getOptionLabel = _b === void 0 ? function (value) { return value; } : _b, helperText = _a.helperText, success = _a.success, children = _a.children, label = _a.label, error = _a.error, props = __rest(_a, ["multiple", "loading", "placeholder", "getOptionLabel", "helperText", "success", "children", "label", "error"]);
39
39
  // unknown, т.к. ts ругается на несоответствие типов. По-умолчанию в selectedOptions string или string[].
40
40
  var renderValue = function (selectedOptions) {
41
41
  if (Array.isArray(selectedOptions) && selectedOptions.length) {
42
- return ((0, jsx_runtime_1.jsx)(styled_1.TagsWrapper, { children: selectedOptions.map(function (option) { return ((0, jsx_runtime_1.jsx)(Tag_1.Tag, { color: "grey", label: option }, option)); }) }, void 0));
42
+ return ((0, jsx_runtime_1.jsx)(styled_1.TagsWrapper, { children: selectedOptions.map(function (option) {
43
+ var optionLabel = getOptionLabel(option);
44
+ return (0, jsx_runtime_1.jsx)(Tag_1.Tag, { color: "grey", label: optionLabel }, option);
45
+ }) }, void 0));
43
46
  }
44
47
  if ((Array.isArray(selectedOptions) || typeof selectedOptions === 'string') &&
45
48
  !selectedOptions.length) {
46
49
  return placeholder;
47
50
  }
48
- return selectedOptions;
51
+ return getOptionLabel(selectedOptions);
49
52
  };
50
53
  var isNoData = !Boolean(react_1.default.Children.count(children));
51
54
  return ((0, jsx_runtime_1.jsxs)(TextField_1.TextField, __assign({ select: true, label: label, helperText: helperText, error: error, success: success, SelectProps: __assign(__assign({}, props), { multiple: multiple, renderValue: renderValue, displayEmpty: true, IconComponent: icons_1.ChevronDOutlineMd }) }, { children: [(0, jsx_runtime_1.jsx)(styled_1.Placeholder, __assign({ value: "" }, { children: "placeholder" }), void 0), loading && ((0, jsx_runtime_1.jsx)(styled_1.ProgressWrapper, { children: (0, jsx_runtime_1.jsx)(CircularProgress_1.CircularProgress, { color: "primary" }, void 0) }, void 0)), !loading && children, !loading && isNoData && (0, jsx_runtime_1.jsx)(MenuItem_1.MenuItem, __assign({ disabled: true }, { children: "\u041D\u0435\u0442 \u0434\u0430\u043D\u043D\u044B\u0445" }), void 0)] }), void 0));
package/Select/types.d.ts CHANGED
@@ -3,4 +3,5 @@ import { TextFieldProps } from '../TextField';
3
3
  export declare type SelectProps = MuiSelectProps & Pick<TextFieldProps, 'error' | 'success' | 'SelectProps' | 'helperText' | 'label'> & {
4
4
  loading?: boolean;
5
5
  placeholder?: string;
6
+ getOptionLabel?: (value: string | number) => string | number;
6
7
  };
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { SideDialogProps } from './types';
3
+ export declare const SideDialog: ({ children, title, onClose, open, ...props }: SideDialogProps) => JSX.Element;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __rest = (this && this.__rest) || function (s, e) {
14
+ var t = {};
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
+ t[p] = s[p];
17
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
+ t[p[i]] = s[p[i]];
21
+ }
22
+ return t;
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.SideDialog = void 0;
26
+ var jsx_runtime_1 = require("react/jsx-runtime");
27
+ var SideDialogTitle_1 = require("../SideDialogTitle");
28
+ var styled_1 = require("./styled");
29
+ var SideDialog = function (_a) {
30
+ var children = _a.children, title = _a.title, onClose = _a.onClose, open = _a.open, props = __rest(_a, ["children", "title", "onClose", "open"]);
31
+ return ((0, jsx_runtime_1.jsxs)(styled_1.StyledDrawer, __assign({ anchor: "right", open: open, onClose: onClose }, props, { children: [(0, jsx_runtime_1.jsx)(SideDialogTitle_1.SideDialogTitle, __assign({ onClose: onClose }, { children: title }), void 0), children] }), void 0));
32
+ };
33
+ exports.SideDialog = SideDialog;
@@ -0,0 +1,2 @@
1
+ export * from './SideDialog';
2
+ export * from './types';
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./SideDialog"), exports);
14
+ __exportStar(require("./types"), exports);
@@ -0,0 +1,4 @@
1
+ import { DrawerProps } from '@mui/material';
2
+ export declare const StyledDrawer: import("@emotion/styled").StyledComponent<DrawerProps & {
3
+ theme?: import("@emotion/react").Theme | undefined;
4
+ }, {}, {}>;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
+ return cooked;
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.StyledDrawer = void 0;
8
+ var material_1 = require("@mui/material");
9
+ var styles_1 = require("../styles");
10
+ exports.StyledDrawer = (0, styles_1.styled)(material_1.Drawer)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n .MuiPaper-root {\n width: 30%;\n }\n height: 100vh;\n"], ["\n .MuiPaper-root {\n width: 30%;\n }\n height: 100vh;\n"])));
11
+ var templateObject_1;
@@ -0,0 +1,4 @@
1
+ import { DrawerProps as MuiDrawerProps } from '@mui/material';
2
+ export declare type SideDialogProps = MuiDrawerProps & {
3
+ title: string;
4
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export { DialogActions as SideDialogActions } from '../DialogActions';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SideDialogActions = void 0;
4
+ var DialogActions_1 = require("../DialogActions");
5
+ Object.defineProperty(exports, "SideDialogActions", { enumerable: true, get: function () { return DialogActions_1.DialogActions; } });
@@ -0,0 +1 @@
1
+ export * from './SideDialogActions';
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./SideDialogActions"), exports);
@@ -0,0 +1 @@
1
+ export type { DialogActionsProps as SideDialogActionsProps } from '@mui/material';
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export { DialogContent as SideDialogContent } from '../DialogContent';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SideDialogContent = void 0;
4
+ var DialogContent_1 = require("../DialogContent");
5
+ Object.defineProperty(exports, "SideDialogContent", { enumerable: true, get: function () { return DialogContent_1.DialogContent; } });
@@ -0,0 +1 @@
1
+ export * from './SideDialogContent';
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./SideDialogContent"), exports);
@@ -0,0 +1 @@
1
+ export type { DialogContentProps as SideDialogContentProps } from '@mui/material';
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export { DialogContentText as SideDialogContentText } from '../DialogContentText';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SideDialogContentText = void 0;
4
+ var DialogContentText_1 = require("../DialogContentText");
5
+ Object.defineProperty(exports, "SideDialogContentText", { enumerable: true, get: function () { return DialogContentText_1.DialogContentText; } });
@@ -0,0 +1 @@
1
+ export * from './SideDialogContentText';
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./SideDialogContentText"), exports);
@@ -0,0 +1 @@
1
+ export type { DialogContentTextProps as SideDialogContentTextProps } from '@mui/material';
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export { DialogTitle as SideDialogTitle } from '../DialogTitle';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SideDialogTitle = void 0;
4
+ var DialogTitle_1 = require("../DialogTitle");
5
+ Object.defineProperty(exports, "SideDialogTitle", { enumerable: true, get: function () { return DialogTitle_1.DialogTitle; } });
@@ -0,0 +1 @@
1
+ export * from './SideDialogTitle';
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./SideDialogTitle"), exports);
@@ -0,0 +1 @@
1
+ export type { DialogTitleProps as SideDialogTitleProps } from '../DialogTitle';
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,7 +1,5 @@
1
- import React from 'react';
2
1
  import { DialogProps as MuiDialogProps } from '@mui/material';
3
- export declare type DialogProps = Omit<MuiDialogProps, 'onClose'> & {
2
+ export declare type DialogProps = MuiDialogProps & {
4
3
  title?: string;
5
4
  disableBackdropClick?: boolean;
6
- onClose?: (event?: React.MouseEvent<HTMLButtonElement>, reason?: 'backdropClick' | 'escapeKeyDown') => void;
7
5
  };
@@ -23,8 +23,11 @@ var __rest = (this && this.__rest) || function (s, e) {
23
23
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
24
24
  import { DialogTitle as MuiDialogTitle } from '@mui/material';
25
25
  import { CrossOutlineMd } from '@astral/icons';
26
+ import { useCallback } from 'react';
26
27
  import { IconButton } from '../IconButton';
27
28
  export var DialogTitle = function (_a) {
29
+ // 'escapeKeyDown' в документашке написано что это опциональный тип, и можно стрингу любую туда закидывать, а по факту либо escapeKeyDown либо backdropClick
28
30
  var children = _a.children, onClose = _a.onClose, props = __rest(_a, ["children", "onClose"]);
29
- return (_jsxs(MuiDialogTitle, __assign({}, props, { children: [children, onClose && (_jsx(IconButton, __assign({ variant: "text", onClick: onClose }, { children: _jsx(CrossOutlineMd, {}, void 0) }), void 0))] }), void 0));
31
+ var onClickTitle = useCallback(function (e) { return onClose && onClose(e, 'escapeKeyDown'); }, [onClose]);
32
+ return (_jsxs(MuiDialogTitle, __assign({}, props, { children: [children, onClose && (_jsx(IconButton, __assign({ variant: "text", onClick: onClickTitle }, { children: _jsx(CrossOutlineMd, {}, void 0) }), void 0))] }), void 0));
30
33
  };
@@ -1,4 +1,4 @@
1
- import { DialogTitleProps as MuiDialogTitleProps } from '@mui/material';
1
+ import { ModalProps, DialogTitleProps as MuiDialogTitleProps } from '@mui/material';
2
2
  export declare type DialogTitleProps = MuiDialogTitleProps & {
3
- onClose?: () => void;
3
+ onClose?: ModalProps['onClose'];
4
4
  };
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import { SelectProps } from './types';
3
- export declare const Select: ({ multiple, loading, placeholder, helperText, success, children, label, error, ...props }: SelectProps) => JSX.Element;
3
+ export declare const Select: ({ multiple, loading, placeholder, getOptionLabel, helperText, success, children, label, error, ...props }: SelectProps) => JSX.Element;
@@ -29,17 +29,20 @@ import { CircularProgress } from '../CircularProgress';
29
29
  import { MenuItem } from '../MenuItem';
30
30
  import { Placeholder, ProgressWrapper, TagsWrapper } from './styled';
31
31
  export var Select = function (_a) {
32
- var multiple = _a.multiple, loading = _a.loading, placeholder = _a.placeholder, helperText = _a.helperText, success = _a.success, children = _a.children, label = _a.label, error = _a.error, props = __rest(_a, ["multiple", "loading", "placeholder", "helperText", "success", "children", "label", "error"]);
32
+ var multiple = _a.multiple, loading = _a.loading, placeholder = _a.placeholder, _b = _a.getOptionLabel, getOptionLabel = _b === void 0 ? function (value) { return value; } : _b, helperText = _a.helperText, success = _a.success, children = _a.children, label = _a.label, error = _a.error, props = __rest(_a, ["multiple", "loading", "placeholder", "getOptionLabel", "helperText", "success", "children", "label", "error"]);
33
33
  // unknown, т.к. ts ругается на несоответствие типов. По-умолчанию в selectedOptions string или string[].
34
34
  var renderValue = function (selectedOptions) {
35
35
  if (Array.isArray(selectedOptions) && selectedOptions.length) {
36
- return (_jsx(TagsWrapper, { children: selectedOptions.map(function (option) { return (_jsx(Tag, { color: "grey", label: option }, option)); }) }, void 0));
36
+ return (_jsx(TagsWrapper, { children: selectedOptions.map(function (option) {
37
+ var optionLabel = getOptionLabel(option);
38
+ return _jsx(Tag, { color: "grey", label: optionLabel }, option);
39
+ }) }, void 0));
37
40
  }
38
41
  if ((Array.isArray(selectedOptions) || typeof selectedOptions === 'string') &&
39
42
  !selectedOptions.length) {
40
43
  return placeholder;
41
44
  }
42
- return selectedOptions;
45
+ return getOptionLabel(selectedOptions);
43
46
  };
44
47
  var isNoData = !Boolean(React.Children.count(children));
45
48
  return (_jsxs(TextField, __assign({ select: true, label: label, helperText: helperText, error: error, success: success, SelectProps: __assign(__assign({}, props), { multiple: multiple, renderValue: renderValue, displayEmpty: true, IconComponent: ChevronDOutlineMd }) }, { children: [_jsx(Placeholder, __assign({ value: "" }, { children: "placeholder" }), void 0), loading && (_jsx(ProgressWrapper, { children: _jsx(CircularProgress, { color: "primary" }, void 0) }, void 0)), !loading && children, !loading && isNoData && _jsx(MenuItem, __assign({ disabled: true }, { children: "\u041D\u0435\u0442 \u0434\u0430\u043D\u043D\u044B\u0445" }), void 0)] }), void 0));
@@ -3,4 +3,5 @@ import { TextFieldProps } from '../TextField';
3
3
  export declare type SelectProps = MuiSelectProps & Pick<TextFieldProps, 'error' | 'success' | 'SelectProps' | 'helperText' | 'label'> & {
4
4
  loading?: boolean;
5
5
  placeholder?: string;
6
+ getOptionLabel?: (value: string | number) => string | number;
6
7
  };
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { SideDialogProps } from './types';
3
+ export declare const SideDialog: ({ children, title, onClose, open, ...props }: SideDialogProps) => JSX.Element;
@@ -0,0 +1,29 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
24
+ import { SideDialogTitle } from '../SideDialogTitle';
25
+ import { StyledDrawer } from './styled';
26
+ export var SideDialog = function (_a) {
27
+ var children = _a.children, title = _a.title, onClose = _a.onClose, open = _a.open, props = __rest(_a, ["children", "title", "onClose", "open"]);
28
+ return (_jsxs(StyledDrawer, __assign({ anchor: "right", open: open, onClose: onClose }, props, { children: [_jsx(SideDialogTitle, __assign({ onClose: onClose }, { children: title }), void 0), children] }), void 0));
29
+ };
@@ -0,0 +1,2 @@
1
+ export * from './SideDialog';
2
+ export * from './types';
@@ -0,0 +1,2 @@
1
+ export * from './SideDialog';
2
+ export * from './types';
@@ -0,0 +1,4 @@
1
+ import { DrawerProps } from '@mui/material';
2
+ export declare const StyledDrawer: import("@emotion/styled").StyledComponent<DrawerProps & {
3
+ theme?: import("@emotion/react").Theme | undefined;
4
+ }, {}, {}>;
@@ -0,0 +1,8 @@
1
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
2
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
3
+ return cooked;
4
+ };
5
+ import { Drawer } from '@mui/material';
6
+ import { styled } from '../styles';
7
+ export var StyledDrawer = styled(Drawer)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n .MuiPaper-root {\n width: 30%;\n }\n height: 100vh;\n"], ["\n .MuiPaper-root {\n width: 30%;\n }\n height: 100vh;\n"])));
8
+ var templateObject_1;
@@ -0,0 +1,4 @@
1
+ import { DrawerProps as MuiDrawerProps } from '@mui/material';
2
+ export declare type SideDialogProps = MuiDrawerProps & {
3
+ title: string;
4
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export { DialogActions as SideDialogActions } from '../DialogActions';
@@ -0,0 +1 @@
1
+ export { DialogActions as SideDialogActions } from '../DialogActions';
@@ -0,0 +1 @@
1
+ export * from './SideDialogActions';
@@ -0,0 +1 @@
1
+ export * from './SideDialogActions';
@@ -0,0 +1 @@
1
+ export type { DialogActionsProps as SideDialogActionsProps } from '@mui/material';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export { DialogContent as SideDialogContent } from '../DialogContent';
@@ -0,0 +1 @@
1
+ export { DialogContent as SideDialogContent } from '../DialogContent';
@@ -0,0 +1 @@
1
+ export * from './SideDialogContent';
@@ -0,0 +1 @@
1
+ export * from './SideDialogContent';
@@ -0,0 +1 @@
1
+ export type { DialogContentProps as SideDialogContentProps } from '@mui/material';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export { DialogContentText as SideDialogContentText } from '../DialogContentText';
@@ -0,0 +1 @@
1
+ export { DialogContentText as SideDialogContentText } from '../DialogContentText';
@@ -0,0 +1 @@
1
+ export * from './SideDialogContentText';
@@ -0,0 +1 @@
1
+ export * from './SideDialogContentText';
@@ -0,0 +1 @@
1
+ export type { DialogContentTextProps as SideDialogContentTextProps } from '@mui/material';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export { DialogTitle as SideDialogTitle } from '../DialogTitle';
@@ -0,0 +1 @@
1
+ export { DialogTitle as SideDialogTitle } from '../DialogTitle';
@@ -0,0 +1 @@
1
+ export * from './SideDialogTitle';
@@ -0,0 +1 @@
1
+ export * from './SideDialogTitle';
@@ -0,0 +1 @@
1
+ export type { DialogTitleProps as SideDialogTitleProps } from '../DialogTitle';
@@ -0,0 +1 @@
1
+ export {};
package/esm/index.d.ts CHANGED
@@ -38,5 +38,10 @@ export * from './ThemeProvider';
38
38
  export * from './TextField';
39
39
  export * from './Typography';
40
40
  export * from './Tooltip';
41
+ export * from './SideDialog';
42
+ export * from './SideDialogTitle';
43
+ export * from './SideDialogActions';
44
+ export * from './SideDialogContent';
45
+ export * from './SideDialogContentText';
41
46
  export * from './DatePicker';
42
47
  export * from './LocalizationProvider';
package/esm/index.js CHANGED
@@ -38,5 +38,10 @@ export * from './ThemeProvider';
38
38
  export * from './TextField';
39
39
  export * from './Typography';
40
40
  export * from './Tooltip';
41
+ export * from './SideDialog';
42
+ export * from './SideDialogTitle';
43
+ export * from './SideDialogActions';
44
+ export * from './SideDialogContent';
45
+ export * from './SideDialogContentText';
41
46
  export * from './DatePicker';
42
47
  export * from './LocalizationProvider';
package/index.d.ts CHANGED
@@ -38,5 +38,10 @@ export * from './ThemeProvider';
38
38
  export * from './TextField';
39
39
  export * from './Typography';
40
40
  export * from './Tooltip';
41
+ export * from './SideDialog';
42
+ export * from './SideDialogTitle';
43
+ export * from './SideDialogActions';
44
+ export * from './SideDialogContent';
45
+ export * from './SideDialogContentText';
41
46
  export * from './DatePicker';
42
47
  export * from './LocalizationProvider';
package/index.js CHANGED
@@ -50,5 +50,10 @@ __exportStar(require("./ThemeProvider"), exports);
50
50
  __exportStar(require("./TextField"), exports);
51
51
  __exportStar(require("./Typography"), exports);
52
52
  __exportStar(require("./Tooltip"), exports);
53
+ __exportStar(require("./SideDialog"), exports);
54
+ __exportStar(require("./SideDialogTitle"), exports);
55
+ __exportStar(require("./SideDialogActions"), exports);
56
+ __exportStar(require("./SideDialogContent"), exports);
57
+ __exportStar(require("./SideDialogContentText"), exports);
53
58
  __exportStar(require("./DatePicker"), exports);
54
59
  __exportStar(require("./LocalizationProvider"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astral/ui",
3
- "version": "0.20.0",
3
+ "version": "0.21.0",
4
4
  "browser": "./src/index.ts",
5
5
  "jest": {
6
6
  "moduleNameMapper": {
@@ -8,7 +8,7 @@
8
8
  }
9
9
  },
10
10
  "dependencies": {
11
- "@astral/icons": "^0.20.0",
11
+ "@astral/icons": "^0.21.0",
12
12
  "@emotion/cache": "11.7.1",
13
13
  "@emotion/react": "11.8.1",
14
14
  "@emotion/server": "11.4.0",