@yuntijs/ui 1.0.0-beta.15 → 1.0.0-beta.17
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/es/App/index.d.ts +7 -0
- package/es/App/index.js +19 -0
- package/es/Radio/index.d.ts +36 -0
- package/es/Radio/index.js +26 -0
- package/es/Radio/style.d.ts +4 -0
- package/es/Radio/style.js +66 -0
- package/es/Table/index.d.ts +17 -0
- package/es/Table/index.js +51 -0
- package/es/index.d.ts +6 -2
- package/es/index.js +8 -3
- package/es/notification/index.d.ts +24 -0
- package/es/notification/index.js +237 -0
- package/es/notification/style.d.ts +2 -0
- package/es/notification/style.js +28 -0
- package/package.json +2 -2
- package/umd/index.min.js +1 -1
- package/umd/index.min.js.map +1 -1
package/es/App/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["children"];
|
|
4
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
|
+
import { App as AntdApp } from 'antd';
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { NotificationGlobalStyle } from "../notification";
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
export var App = function App(props) {
|
|
12
|
+
var children = props.children,
|
|
13
|
+
otherProps = _objectWithoutProperties(props, _excluded);
|
|
14
|
+
return /*#__PURE__*/_jsxs(AntdApp, _objectSpread(_objectSpread({}, otherProps), {}, {
|
|
15
|
+
children: [/*#__PURE__*/_jsx(NotificationGlobalStyle, {}), children]
|
|
16
|
+
}));
|
|
17
|
+
};
|
|
18
|
+
App.useApp = AntdApp.useApp;
|
|
19
|
+
export default App;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Radio as AntdRadio, type RadioGroupProps as AntdRadioGroupProps, RadioProps } from 'antd';
|
|
2
|
+
import type { RadioRef } from 'antd/es/radio/interface';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
export interface CustomRadioProps {
|
|
5
|
+
/**
|
|
6
|
+
* @description Set the button style is similar to the Segmented component
|
|
7
|
+
* @default 'false'
|
|
8
|
+
*/
|
|
9
|
+
segmented?: {
|
|
10
|
+
/**
|
|
11
|
+
* @description Set the spacing between buttons
|
|
12
|
+
* @default 'true'
|
|
13
|
+
*/
|
|
14
|
+
gap?: 'small' | 'middle' | 'large' | number | boolean;
|
|
15
|
+
/**
|
|
16
|
+
* @description Set border-radius of buttons
|
|
17
|
+
* @default 'true'
|
|
18
|
+
*/
|
|
19
|
+
borderRadius?: number | boolean;
|
|
20
|
+
/**
|
|
21
|
+
* @description Sets whether the button's border is displayed
|
|
22
|
+
* @default 'false'
|
|
23
|
+
*/
|
|
24
|
+
bordered?: boolean;
|
|
25
|
+
} | boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface RadioGroupProps extends AntdRadioGroupProps, CustomRadioProps {
|
|
28
|
+
}
|
|
29
|
+
type RadioType = React.ForwardRefExoticComponent<RadioProps & React.RefAttributes<RadioRef>> & {
|
|
30
|
+
Group: typeof Group;
|
|
31
|
+
Button: typeof AntdRadio.Button;
|
|
32
|
+
};
|
|
33
|
+
export declare const Radio: RadioType;
|
|
34
|
+
declare const Group: React.FC<RadioGroupProps>;
|
|
35
|
+
export default Radio;
|
|
36
|
+
export { type RadioChangeEvent, type RadioProps } from 'antd';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["className"];
|
|
4
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
|
+
import { Radio as AntdRadio } from 'antd';
|
|
7
|
+
import AntdGroup from 'antd/es/radio/group';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import { useStyles } from "./style";
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
export var Radio = AntdRadio;
|
|
12
|
+
var Group = function Group(props) {
|
|
13
|
+
var className = props.className,
|
|
14
|
+
otherProps = _objectWithoutProperties(props, _excluded);
|
|
15
|
+
if (otherProps.segmented) {
|
|
16
|
+
otherProps.optionType = 'button';
|
|
17
|
+
}
|
|
18
|
+
var _useStyles = useStyles(otherProps),
|
|
19
|
+
styles = _useStyles.styles,
|
|
20
|
+
cx = _useStyles.cx;
|
|
21
|
+
return /*#__PURE__*/_jsx(AntdGroup, _objectSpread(_objectSpread({}, otherProps), {}, {
|
|
22
|
+
className: cx(styles.custom, className)
|
|
23
|
+
}));
|
|
24
|
+
};
|
|
25
|
+
Radio.Group = Group;
|
|
26
|
+
export default Radio;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
2
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
3
|
+
import { createStyles } from 'antd-style';
|
|
4
|
+
export var useStyles = createStyles(function (_ref, _ref2) {
|
|
5
|
+
var css = _ref.css,
|
|
6
|
+
token = _ref.token,
|
|
7
|
+
prefixCls = _ref.prefixCls;
|
|
8
|
+
var size = _ref2.size,
|
|
9
|
+
segmented = _ref2.segmented;
|
|
10
|
+
var gap = function () {
|
|
11
|
+
if (!segmented) {
|
|
12
|
+
return 0;
|
|
13
|
+
}
|
|
14
|
+
if (segmented !== true) {
|
|
15
|
+
return segmented.gap;
|
|
16
|
+
}
|
|
17
|
+
return true;
|
|
18
|
+
}();
|
|
19
|
+
var borderRadius = function () {
|
|
20
|
+
if (!segmented) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (segmented !== true) {
|
|
24
|
+
return segmented.borderRadius;
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
}();
|
|
28
|
+
var getGapSize = function getGapSize() {
|
|
29
|
+
var gapSizeMap = {
|
|
30
|
+
small: token.sizeSM,
|
|
31
|
+
middle: token.size,
|
|
32
|
+
large: token.sizeLG
|
|
33
|
+
};
|
|
34
|
+
if (typeof gap === 'string') {
|
|
35
|
+
return gapSizeMap[gap];
|
|
36
|
+
}
|
|
37
|
+
if (gap === true) {
|
|
38
|
+
return size ? gapSizeMap[size] : gapSizeMap['middle'];
|
|
39
|
+
}
|
|
40
|
+
if (!gap) {
|
|
41
|
+
return 0;
|
|
42
|
+
}
|
|
43
|
+
return gap;
|
|
44
|
+
};
|
|
45
|
+
var getBorderRadius = function getBorderRadius() {
|
|
46
|
+
var borderRadiusSizeMap = {
|
|
47
|
+
small: token.controlHeightSM,
|
|
48
|
+
middle: token.controlHeight,
|
|
49
|
+
large: token.controlHeightLG
|
|
50
|
+
};
|
|
51
|
+
if (borderRadius === true) {
|
|
52
|
+
return size ? borderRadiusSizeMap[size] : borderRadiusSizeMap['middle'];
|
|
53
|
+
}
|
|
54
|
+
if (borderRadius || borderRadius === 0) {
|
|
55
|
+
return borderRadius;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
var borderRadiusStyle = getBorderRadius() && css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n label {\n border-inline-start-width: 1px !important;\n border-radius: ", "px !important;\n }\n label::before {\n display: none !important;\n }\n "])), getBorderRadius());
|
|
59
|
+
var gapStyle = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n label {\n margin-right: ", "px !important;\n }\n label:last-child {\n margin-right: 0 !important;\n }\n "])), getGapSize());
|
|
60
|
+
var noBorderd = segmented === true || segmented && !segmented.bordered;
|
|
61
|
+
return {
|
|
62
|
+
custom: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n ", "\n ", "\n ", "\n "])), borderRadiusStyle, gapStyle, noBorderd && css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n .", "-radio-button-wrapper {\n border: none !important;\n }\n .", "-radio-button-wrapper-checked {\n border: 1px solid ", " !important;\n }\n "])), prefixCls, prefixCls, token.colorPrimary))
|
|
63
|
+
};
|
|
64
|
+
}, {
|
|
65
|
+
hashPriority: 'low'
|
|
66
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Table as AntdTable, TableProps } from 'antd';
|
|
2
|
+
import { AnyObject } from 'antd/es/_util/type';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
export { type TableColumnGroupType, type TableColumnProps, type TableColumnsType, type TableColumnType, type TablePaginationConfig, type TableProps, } from 'antd';
|
|
5
|
+
type YuntiTable = <RecordType extends AnyObject = AnyObject>(props: TableProps<RecordType>) => React.ReactElement;
|
|
6
|
+
export declare const Table: YuntiTable & {
|
|
7
|
+
displayName?: typeof AntdTable.displayName;
|
|
8
|
+
SELECTION_COLUMN: typeof AntdTable.SELECTION_COLUMN;
|
|
9
|
+
EXPAND_COLUMN: typeof AntdTable.EXPAND_COLUMN;
|
|
10
|
+
SELECTION_ALL: typeof AntdTable.SELECTION_ALL;
|
|
11
|
+
SELECTION_INVERT: typeof AntdTable.SELECTION_INVERT;
|
|
12
|
+
SELECTION_NONE: typeof AntdTable.SELECTION_NONE;
|
|
13
|
+
Column: typeof AntdTable.Column;
|
|
14
|
+
ColumnGroup: typeof AntdTable.ColumnGroup;
|
|
15
|
+
Summary: typeof AntdTable.Summary;
|
|
16
|
+
};
|
|
17
|
+
export default Table;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["columns"];
|
|
4
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
|
+
import { Table as AntdTable, Tooltip } from 'antd';
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
export var Table = function Table(props) {
|
|
10
|
+
var columns = props.columns,
|
|
11
|
+
otherProps = _objectWithoutProperties(props, _excluded);
|
|
12
|
+
var formatColumns;
|
|
13
|
+
if (columns) {
|
|
14
|
+
formatColumns = columns.map(function (item) {
|
|
15
|
+
if (!item.render) {
|
|
16
|
+
item.render = function (text) {
|
|
17
|
+
return text !== null && text !== void 0 ? text : '-';
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
if (item.ellipsis && item.ellipsis !== true && item.ellipsis.showTitle || item.ellipsis === true) {
|
|
21
|
+
var tooltipProps = item.ellipsis === true ? {} : item.ellipsis;
|
|
22
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
23
|
+
ellipsis: {
|
|
24
|
+
showTitle: false
|
|
25
|
+
},
|
|
26
|
+
render: function render(text) {
|
|
27
|
+
return text || text === 0 ? /*#__PURE__*/_jsx(Tooltip, _objectSpread(_objectSpread({}, tooltipProps), {}, {
|
|
28
|
+
placement: "topLeft",
|
|
29
|
+
title: text,
|
|
30
|
+
children: text
|
|
31
|
+
})) : '-';
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return item;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return /*#__PURE__*/_jsx(AntdTable, _objectSpread(_objectSpread({}, otherProps), {}, {
|
|
39
|
+
columns: formatColumns
|
|
40
|
+
}));
|
|
41
|
+
};
|
|
42
|
+
Table.displayName = 'Table';
|
|
43
|
+
Table.SELECTION_COLUMN = AntdTable.SELECTION_COLUMN;
|
|
44
|
+
Table.EXPAND_COLUMN = AntdTable.EXPAND_COLUMN;
|
|
45
|
+
Table.SELECTION_ALL = AntdTable.SELECTION_ALL;
|
|
46
|
+
Table.SELECTION_INVERT = AntdTable.SELECTION_INVERT;
|
|
47
|
+
Table.SELECTION_NONE = AntdTable.SELECTION_NONE;
|
|
48
|
+
Table.Column = AntdTable.Column;
|
|
49
|
+
Table.ColumnGroup = AntdTable.ColumnGroup;
|
|
50
|
+
Table.Summary = AntdTable.Summary;
|
|
51
|
+
export default Table;
|
package/es/index.d.ts
CHANGED
|
@@ -5,15 +5,19 @@ export * from './MonacoEditor';
|
|
|
5
5
|
export * from './SliderInput';
|
|
6
6
|
export * from './Tree';
|
|
7
7
|
export * from './Alert';
|
|
8
|
+
export * from './App';
|
|
8
9
|
export * from './Card';
|
|
9
10
|
export * from './Descriptions';
|
|
10
11
|
export * from './Divider';
|
|
11
12
|
export * from './Drawer';
|
|
12
13
|
export * from './FormHelper';
|
|
13
14
|
export * from './Modal';
|
|
14
|
-
export
|
|
15
|
+
export * from './notification';
|
|
16
|
+
export * from './Radio';
|
|
17
|
+
export * from './Table';
|
|
18
|
+
export { Affix, type AffixProps, Anchor, type AnchorProps, AutoComplete, type AutoCompleteProps, Avatar, type AvatarProps, BackTop, type BackTopProps, Badge, // @todo composed type
|
|
15
19
|
type BadgeProps, Button, // @todo dependence unifiedLink. link type, hover primary color, back button
|
|
16
20
|
type ButtonProps, Calendar, type CalendarProps, Carousel, type CarouselProps, Cascader, type CascaderProps, Checkbox, type CheckboxProps, Col, Collapse, type CollapseProps, ColorPicker, type ColorPickerProps, type ColProps, // @todo center style
|
|
17
|
-
DatePicker, type DatePickerProps, Dropdown, type DropDownProps, Empty, type EmptyProps, Flex, type FlexProps, FloatButton, type FloatButtonProps, Form, type FormInstance, type FormItemProps, type FormListFieldData, type FormListOperation, type FormProps, type FormRule, Grid, Image, type ImageProps, Input, InputNumber, type InputNumberProps, type InputProps, type InputRef, Layout, type LayoutProps, List, type ListProps, type MentionProps, Mentions, Menu, type MenuItemProps, type MenuProps, type MenuRef, type MenuTheme, message, type MessageArgsProps, Space, type SpaceProps, type SubMenuProps, } from 'antd';
|
|
21
|
+
type CountdownProps, DatePicker, type DatePickerProps, Dropdown, type DropDownProps, Empty, type EmptyProps, Flex, type FlexProps, FloatButton, type FloatButtonProps, Form, type FormInstance, type FormItemProps, type FormListFieldData, type FormListOperation, type FormProps, type FormRule, type GlobalToken, Grid, Image, type ImageProps, Input, InputNumber, type InputNumberProps, type InputProps, type InputRef, Layout, type LayoutProps, List, type ListProps, type MappingAlgorithm, type MentionProps, Mentions, Menu, type MenuItemProps, type MenuProps, type MenuRef, type MenuTheme, message, type MessageArgsProps, Pagination, type PaginationProps, Popconfirm, type PopconfirmProps, Popover, type PopoverProps, Progress, type ProgressProps, QRCode, type QRCodeProps, type QRPropsCanvas, type QRPropsSvg, Rate, type RateProps, type RefSelectProps, Result, type ResultProps, Row, type RowProps, Segmented, type SegmentedProps, Select, type SelectProps, Skeleton, type SkeletonProps, Slider, type SliderSingleProps, Space, type SpaceProps, Spin, type SpinProps, Statistic, type StatisticProps, type StepProps, Steps, type StepsProps, type SubMenuProps, Switch, type SwitchProps, type TabPaneProps, Tabs, type TabsProps, Tag, type TagProps, type TagType, theme, Timeline, type TimelineItemProps, type TimelineProps, TimePicker, type TimePickerProps, type TimeRangePickerProps, Tooltip, type TooltipProps, Tour, type TourProps, type TourStepProps, Transfer, type TransferProps, Tree, type TreeDataNode, type TreeNodeProps, type TreeProps, TreeSelect, type TreeSelectProps, Typography, type TypographyProps, Upload, type UploadFile, type UploadProps, version, Watermark, type WatermarkProps, } from 'antd';
|
|
18
22
|
export { Highlighter, type HighlighterProps, Markdown, type MarkdownProps, SyntaxHighlighter, type SyntaxHighlighterProps, } from '@lobehub/ui';
|
|
19
23
|
export { useResponsive, useTheme, useThemeMode } from 'antd-style';
|
package/es/index.js
CHANGED
|
@@ -7,19 +7,24 @@ export * from "./Tree";
|
|
|
7
7
|
|
|
8
8
|
// ~ custom antd
|
|
9
9
|
export * from "./Alert";
|
|
10
|
+
export * from "./App";
|
|
10
11
|
export * from "./Card";
|
|
11
12
|
export * from "./Descriptions";
|
|
12
13
|
export * from "./Divider";
|
|
13
14
|
export * from "./Drawer";
|
|
14
15
|
export * from "./FormHelper";
|
|
15
16
|
export * from "./Modal";
|
|
17
|
+
export * from "./notification";
|
|
18
|
+
export * from "./Radio";
|
|
19
|
+
export * from "./Table";
|
|
16
20
|
|
|
17
21
|
// ~ antd
|
|
18
|
-
export { Affix, Anchor,
|
|
22
|
+
export { Affix, Anchor, AutoComplete, Avatar, BackTop, Badge // @todo composed type
|
|
19
23
|
, Button // @todo dependence unifiedLink. link type, hover primary color, back button
|
|
20
|
-
, Calendar, Carousel, Cascader, Checkbox, Col, Collapse, ColorPicker
|
|
24
|
+
, Calendar, Carousel, Cascader, Checkbox, Col, Collapse, ColorPicker
|
|
25
|
+
|
|
21
26
|
// @todo center style
|
|
22
|
-
DatePicker, Dropdown, Empty, Flex, FloatButton, Form, Grid, Image, Input, InputNumber, Layout, List, Mentions, Menu, message, Space } from 'antd';
|
|
27
|
+
, DatePicker, Dropdown, Empty, Flex, FloatButton, Form, Grid, Image, Input, InputNumber, Layout, List, Mentions, Menu, message, Pagination, Popconfirm, Popover, Progress, QRCode, Rate, Result, Row, Segmented, Select, Skeleton, Slider, Space, Spin, Statistic, Steps, Switch, Tabs, Tag, theme, Timeline, TimePicker, Tooltip, Tour, Transfer, Tree, TreeSelect, Typography, Upload, version, Watermark } from 'antd';
|
|
23
28
|
|
|
24
29
|
// ~ @lobehub/ui
|
|
25
30
|
export { Highlighter, Markdown, SyntaxHighlighter } from '@lobehub/ui';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type NotificationArgsProps as AntdNotificationArgsProps } from 'antd';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export interface NotificationArgsProps extends AntdNotificationArgsProps {
|
|
4
|
+
/** 如果不为空,则会以折叠面板的形式展示描述,展开后展示报错内容,可用来展示报错详情 */
|
|
5
|
+
detail?: Record<string, any>;
|
|
6
|
+
descKey?: string;
|
|
7
|
+
errors?: Error[];
|
|
8
|
+
}
|
|
9
|
+
export declare const notification: {
|
|
10
|
+
success: (args: NotificationArgsProps) => void;
|
|
11
|
+
info: (args: NotificationArgsProps) => void;
|
|
12
|
+
warning: (args: NotificationArgsProps) => void;
|
|
13
|
+
warn: (args: NotificationArgsProps) => void;
|
|
14
|
+
error: (args: NotificationArgsProps) => void;
|
|
15
|
+
warnings: (args: NotificationArgsProps) => void;
|
|
16
|
+
warns: (args: NotificationArgsProps) => void;
|
|
17
|
+
open: (config: AntdNotificationArgsProps) => void;
|
|
18
|
+
destroy: (key?: React.Key | undefined) => void;
|
|
19
|
+
config: (config: import("antd/es/notification/interface").GlobalConfigProps) => void;
|
|
20
|
+
useNotification: typeof import("antd/es/notification/useNotification").default;
|
|
21
|
+
_InternalPanelDoNotUseOrYouWillBeFired: React.FC<import("antd/es/notification/PurePanel").PurePanelProps>;
|
|
22
|
+
};
|
|
23
|
+
export default notification;
|
|
24
|
+
export { NotificationGlobalStyle } from './style';
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
|
+
var _excluded = ["detail", "message", "description", "onClose", "className"];
|
|
5
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
8
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
9
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
10
|
+
import { MinusSquareOutlined, PlusSquareOutlined, WarningFilled } from '@ant-design/icons';
|
|
11
|
+
import { notification as AntdNotification, Collapse, Typography } from 'antd';
|
|
12
|
+
import React, { isValidElement, useState } from 'react';
|
|
13
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
+
var Panel = Collapse.Panel;
|
|
17
|
+
var Link = Typography.Link,
|
|
18
|
+
Paragraph = Typography.Paragraph,
|
|
19
|
+
Text = Typography.Text;
|
|
20
|
+
var NOTICE_MAP = {};
|
|
21
|
+
var setNoticeMap = function setNoticeMap(key, noticeProps) {
|
|
22
|
+
if (!NOTICE_MAP[key]) {
|
|
23
|
+
NOTICE_MAP[key] = [];
|
|
24
|
+
}
|
|
25
|
+
NOTICE_MAP[key].push(noticeProps);
|
|
26
|
+
};
|
|
27
|
+
var removeNoticeMap = function removeNoticeMap(key) {
|
|
28
|
+
delete NOTICE_MAP[key];
|
|
29
|
+
};
|
|
30
|
+
var reactNodeToString = function reactNodeToString(reactNode) {
|
|
31
|
+
var string = '';
|
|
32
|
+
if (typeof reactNode === 'string') {
|
|
33
|
+
string = reactNode;
|
|
34
|
+
} else if (typeof reactNode === 'number') {
|
|
35
|
+
string = reactNode.toString();
|
|
36
|
+
} else if (Array.isArray(reactNode)) {
|
|
37
|
+
var _iterator = _createForOfIteratorHelper(reactNode),
|
|
38
|
+
_step;
|
|
39
|
+
try {
|
|
40
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
41
|
+
var child = _step.value;
|
|
42
|
+
string += reactNodeToString(child);
|
|
43
|
+
}
|
|
44
|
+
} catch (err) {
|
|
45
|
+
_iterator.e(err);
|
|
46
|
+
} finally {
|
|
47
|
+
_iterator.f();
|
|
48
|
+
}
|
|
49
|
+
} else if ( /*#__PURE__*/isValidElement(reactNode)) {
|
|
50
|
+
string += reactNodeToString(reactNode.props.children);
|
|
51
|
+
}
|
|
52
|
+
return string;
|
|
53
|
+
};
|
|
54
|
+
var Message = function Message(props) {
|
|
55
|
+
var _NOTICE_MAP$key;
|
|
56
|
+
var key = props.noticeKey,
|
|
57
|
+
message = props.message;
|
|
58
|
+
var count = ((_NOTICE_MAP$key = NOTICE_MAP[key]) === null || _NOTICE_MAP$key === void 0 ? void 0 : _NOTICE_MAP$key.length) || 0;
|
|
59
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
60
|
+
children: [message, count > 1 && " (".concat(count, ")")]
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
var Description = function Description(props) {
|
|
64
|
+
var key = props.noticeKey;
|
|
65
|
+
var _useState = useState(),
|
|
66
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
67
|
+
activePanels = _useState2[0],
|
|
68
|
+
setActivePanels = _useState2[1];
|
|
69
|
+
var descMap = {};
|
|
70
|
+
var _iterator2 = _createForOfIteratorHelper(NOTICE_MAP[key]),
|
|
71
|
+
_step2;
|
|
72
|
+
try {
|
|
73
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
74
|
+
var noticeProps = _step2.value;
|
|
75
|
+
var descKey = reactNodeToString(noticeProps.description);
|
|
76
|
+
noticeProps.descKey = descKey;
|
|
77
|
+
descMap[descKey] = noticeProps;
|
|
78
|
+
}
|
|
79
|
+
} catch (err) {
|
|
80
|
+
_iterator2.e(err);
|
|
81
|
+
} finally {
|
|
82
|
+
_iterator2.f();
|
|
83
|
+
}
|
|
84
|
+
return /*#__PURE__*/_jsx(Collapse, {
|
|
85
|
+
accordion: true,
|
|
86
|
+
activeKey: activePanels,
|
|
87
|
+
className: "yunti-notification-collapse",
|
|
88
|
+
expandIcon: function expandIcon(_ref) {
|
|
89
|
+
var isActive = _ref.isActive;
|
|
90
|
+
return /*#__PURE__*/_jsx("span", {
|
|
91
|
+
className: "yunti-notification-collapse-expand-icon",
|
|
92
|
+
children: isActive ? /*#__PURE__*/_jsx(Link, {
|
|
93
|
+
className: "yunti-notification-link",
|
|
94
|
+
children: /*#__PURE__*/_jsx(MinusSquareOutlined, {
|
|
95
|
+
title: "\u70B9\u51FB\u5173\u95ED\u9519\u8BEF\u8BE6\u60C5"
|
|
96
|
+
})
|
|
97
|
+
}) : /*#__PURE__*/_jsx(PlusSquareOutlined, {
|
|
98
|
+
title: "\u70B9\u51FB\u67E5\u770B\u9519\u8BEF\u8BE6\u60C5"
|
|
99
|
+
})
|
|
100
|
+
});
|
|
101
|
+
},
|
|
102
|
+
ghost: true,
|
|
103
|
+
onChange: function onChange(keys) {
|
|
104
|
+
setActivePanels(keys);
|
|
105
|
+
},
|
|
106
|
+
children: Object.values(descMap).map(function (_ref2) {
|
|
107
|
+
var descKey = _ref2.descKey,
|
|
108
|
+
description = _ref2.description,
|
|
109
|
+
detail = _ref2.detail;
|
|
110
|
+
return /*#__PURE__*/_jsx(Panel, {
|
|
111
|
+
header: /*#__PURE__*/_jsx(Text, {
|
|
112
|
+
ellipsis: {
|
|
113
|
+
tooltip: false
|
|
114
|
+
},
|
|
115
|
+
style: {
|
|
116
|
+
width: 250
|
|
117
|
+
},
|
|
118
|
+
children: description
|
|
119
|
+
}),
|
|
120
|
+
children: /*#__PURE__*/_jsx(Paragraph, {
|
|
121
|
+
className: "yunti-notification-collapse-content-p",
|
|
122
|
+
copyable: {
|
|
123
|
+
text: JSON.stringify(detail, null, 2)
|
|
124
|
+
},
|
|
125
|
+
type: "secondary",
|
|
126
|
+
children: /*#__PURE__*/_jsx("pre", {
|
|
127
|
+
children: JSON.stringify(detail, null, 2)
|
|
128
|
+
})
|
|
129
|
+
})
|
|
130
|
+
}, descKey);
|
|
131
|
+
})
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
var notice = function notice(args) {
|
|
135
|
+
var detail = args.detail,
|
|
136
|
+
message = args.message,
|
|
137
|
+
description = args.description,
|
|
138
|
+
onCloseFromProps = args.onClose,
|
|
139
|
+
className = args.className,
|
|
140
|
+
restArgs = _objectWithoutProperties(args, _excluded);
|
|
141
|
+
var key = reactNodeToString(message);
|
|
142
|
+
setNoticeMap(key, args);
|
|
143
|
+
var onClose = function onClose() {
|
|
144
|
+
onCloseFromProps === null || onCloseFromProps === void 0 || onCloseFromProps();
|
|
145
|
+
removeNoticeMap(key);
|
|
146
|
+
};
|
|
147
|
+
if (args.type === 'warning' && !args.icon) {
|
|
148
|
+
restArgs.icon = /*#__PURE__*/_jsx(WarningFilled, {
|
|
149
|
+
style: {
|
|
150
|
+
color: '#ff7d00'
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
if (!detail) {
|
|
155
|
+
return AntdNotification.open(_objectSpread({
|
|
156
|
+
key: key,
|
|
157
|
+
message: /*#__PURE__*/_jsx(Message, {
|
|
158
|
+
message: message,
|
|
159
|
+
noticeKey: key
|
|
160
|
+
}),
|
|
161
|
+
description: description,
|
|
162
|
+
onClose: onClose,
|
|
163
|
+
className: "yunti-notification ".concat(className)
|
|
164
|
+
}, restArgs));
|
|
165
|
+
}
|
|
166
|
+
return AntdNotification.open(_objectSpread({
|
|
167
|
+
key: key,
|
|
168
|
+
message: /*#__PURE__*/_jsx(Message, {
|
|
169
|
+
message: message,
|
|
170
|
+
noticeKey: key
|
|
171
|
+
}),
|
|
172
|
+
description: /*#__PURE__*/_jsx(Description, {
|
|
173
|
+
noticeKey: key
|
|
174
|
+
}),
|
|
175
|
+
onClose: onClose,
|
|
176
|
+
className: "yunti-notification ".concat(className)
|
|
177
|
+
}, restArgs));
|
|
178
|
+
};
|
|
179
|
+
var warnsFun = function warnsFun(args) {
|
|
180
|
+
var _args$errors;
|
|
181
|
+
if (((args === null || args === void 0 || (_args$errors = args.errors) === null || _args$errors === void 0 ? void 0 : _args$errors.length) || 0) > 0) {
|
|
182
|
+
if (args !== null && args !== void 0 && args.errors || []) {
|
|
183
|
+
var _iterator3 = _createForOfIteratorHelper((args === null || args === void 0 ? void 0 : args.errors) || []),
|
|
184
|
+
_step3;
|
|
185
|
+
try {
|
|
186
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
187
|
+
var item = _step3.value;
|
|
188
|
+
notice(_objectSpread(_objectSpread({
|
|
189
|
+
detail: item,
|
|
190
|
+
description: item.message
|
|
191
|
+
}, args), {}, {
|
|
192
|
+
type: 'warning'
|
|
193
|
+
}));
|
|
194
|
+
}
|
|
195
|
+
} catch (err) {
|
|
196
|
+
_iterator3.e(err);
|
|
197
|
+
} finally {
|
|
198
|
+
_iterator3.f();
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
} else {
|
|
202
|
+
notice(_objectSpread(_objectSpread({}, args), {}, {
|
|
203
|
+
type: 'warning'
|
|
204
|
+
}));
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
export var notification = _objectSpread(_objectSpread({}, AntdNotification), {}, {
|
|
208
|
+
success: function success(args) {
|
|
209
|
+
return notice(_objectSpread(_objectSpread({}, args), {}, {
|
|
210
|
+
type: 'success'
|
|
211
|
+
}));
|
|
212
|
+
},
|
|
213
|
+
info: function info(args) {
|
|
214
|
+
return notice(_objectSpread(_objectSpread({}, args), {}, {
|
|
215
|
+
type: 'info'
|
|
216
|
+
}));
|
|
217
|
+
},
|
|
218
|
+
warning: function warning(args) {
|
|
219
|
+
return notice(_objectSpread(_objectSpread({}, args), {}, {
|
|
220
|
+
type: 'warning'
|
|
221
|
+
}));
|
|
222
|
+
},
|
|
223
|
+
warn: function warn(args) {
|
|
224
|
+
return notice(_objectSpread(_objectSpread({}, args), {}, {
|
|
225
|
+
type: 'warning'
|
|
226
|
+
}));
|
|
227
|
+
},
|
|
228
|
+
error: function error(args) {
|
|
229
|
+
return notice(_objectSpread(_objectSpread({}, args), {}, {
|
|
230
|
+
type: 'error'
|
|
231
|
+
}));
|
|
232
|
+
},
|
|
233
|
+
warnings: warnsFun,
|
|
234
|
+
warns: warnsFun
|
|
235
|
+
});
|
|
236
|
+
export default notification;
|
|
237
|
+
export { NotificationGlobalStyle } from "./style";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
2
|
+
var _templateObject;
|
|
3
|
+
import { notification } from 'antd';
|
|
4
|
+
import { createGlobalStyle } from 'antd-style';
|
|
5
|
+
export var NotificationGlobalStyle = createGlobalStyle(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n.yunti-notification {\n width: auto;\n min-width: 360px;\n max-width: 520px;\n &-link {\n color: ", ";\n }\n &-link:hover {\n color: ", ";\n }\n &-collapse {\n &-expand-icon {\n font-size: 14px !important;\n }\n &.ant-collapse > .ant-collapse-item {\n & > .ant-collapse-header {\n padding: 6px 16px 6px 24px;\n & > span {\n color: rgba(0, 0, 0, 0.7);\n }\n &:hover {\n .yunti-notification-collapse-expand-icon {\n color: ", ";\n }\n }\n .ant-collapse-expand-icon {\n position: absolute;\n top: 3.429px;\n left: 0%;\n }\n\n .ant-collapse-arrow {\n position: relative;\n top: 3.429px;\n\n display: inline-block;\n\n padding: 6px 0;\n\n line-height: 0;\n text-align: center;\n text-transform: none;\n text-rendering: optimizelegibility;\n vertical-align: -0.125em;\n }\n & > .ant-collapse-header-text {\n width: 100%;\n }\n }\n & > .ant-collapse-content > .ant-collapse-content-box {\n padding: 0;\n }\n }\n &-content-p {\n position: relative;\n & > pre {\n overflow: auto;\n height: 166px;\n margin: 0;\n padding-right: 24px;\n }\n & > .ant-typography-copy {\n position: absolute;\n right: 16px;\n bottom: 8px;\n\n font-size: 14px;\n color:", ";\n }\n\n & > .ant-typography-copy:hover {\n color:", ";\n }\n }\n }\n ", "\n}\n"])), function (_ref) {
|
|
6
|
+
var theme = _ref.theme;
|
|
7
|
+
return "".concat(theme === null || theme === void 0 ? void 0 : theme.colorPrimary, " !important");
|
|
8
|
+
}, function (_ref2) {
|
|
9
|
+
var theme = _ref2.theme;
|
|
10
|
+
return "".concat(theme === null || theme === void 0 ? void 0 : theme.colorPrimaryHover, " !important");
|
|
11
|
+
}, function (_ref3) {
|
|
12
|
+
var theme = _ref3.theme;
|
|
13
|
+
return theme === null || theme === void 0 ? void 0 : theme.colorPrimary;
|
|
14
|
+
}, function (_ref4) {
|
|
15
|
+
var theme = _ref4.theme;
|
|
16
|
+
return "".concat(theme === null || theme === void 0 ? void 0 : theme.colorPrimary, " !important");
|
|
17
|
+
}, function (_ref5) {
|
|
18
|
+
var theme = _ref5.theme;
|
|
19
|
+
return "".concat(theme === null || theme === void 0 ? void 0 : theme.colorPrimaryHover, " !important");
|
|
20
|
+
}, function (_ref6) {
|
|
21
|
+
var theme = _ref6.theme;
|
|
22
|
+
var _ref7 = theme || {},
|
|
23
|
+
prefixCls = _ref7.prefixCls;
|
|
24
|
+
notification.config({
|
|
25
|
+
prefixCls: prefixCls
|
|
26
|
+
});
|
|
27
|
+
return "\n .".concat(prefixCls, "-notice-message {\n font-weight: 500 !important;\n }\n .").concat(prefixCls, "-notice-description {\n max-height: ~'calc(100vh - 160px)';\n overflow: auto;\n }\n ");
|
|
28
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yuntijs/ui",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.17",
|
|
4
4
|
"description": "☁️ Yunti UI - an open-source UI component library for building Cloud Native web apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"yuntijs",
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"@types/react-dom": "^18",
|
|
99
99
|
"@vitest/coverage-v8": "latest",
|
|
100
100
|
"@yuntijs/lint": "^1.4.0",
|
|
101
|
-
"antd": "^5.
|
|
101
|
+
"antd": "^5.16.1",
|
|
102
102
|
"antd-style": "^3",
|
|
103
103
|
"babel-plugin-antd-style": "latest",
|
|
104
104
|
"commitlint": "^18",
|