@kep-platform/basic-component 0.2.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,64 @@
1
+ import { PaginationProps } from 'rc-pagination';
2
+ import { Key, ReactNode } from 'react';
3
+ export type SizeType = 'small' | 'large' | 'middle';
4
+ export type PaginationType = Pick<PaginationProps, 'current' | 'pageSize'>;
5
+ export type Direction = 'row' | 'column' | 'row-reverse' | 'column-reverse';
6
+ export type ListItemRender = (record: any, index: number) => ReactNode;
7
+ export type Align = 'left' | 'right' | 'center';
8
+ export type ColumnRender = (value: any, record: any, index: number) => ReactNode;
9
+ export type ColumnType = {
10
+ key: string;
11
+ dataIndex: string;
12
+ width?: number;
13
+ title?: ReactNode;
14
+ render?: ColumnRender;
15
+ align?: Align;
16
+ hideInTable?: boolean;
17
+ fixed?: 'left' | 'right';
18
+ left?: string;
19
+ right?: string;
20
+ bordered?: boolean;
21
+ sorter?: boolean | SorterFunc;
22
+ filter?: boolean;
23
+ };
24
+ export type SorterFunc = (a: any, b: any) => number;
25
+ export type Sorter = 'desc' | 'asc' | undefined;
26
+ export type TriggerType = 'click' | 'mouseover' | 'contextmenu' | 'doubleClick';
27
+ export type MenuItem = {
28
+ key: Key;
29
+ title?: string;
30
+ label: ReactNode;
31
+ };
32
+ export type RequiredTreeNodeKeys = 'key' | 'title' | 'children';
33
+ export type TreeFieldNames = {
34
+ [key in RequiredTreeNodeKeys]: string;
35
+ };
36
+ export type Condition = {
37
+ attribute: string;
38
+ condition?: (value: any) => boolean;
39
+ description: string;
40
+ };
41
+ export type TreeNodeType = {
42
+ [key: string]: any;
43
+ groupBy?: Condition[];
44
+ selectable?: boolean;
45
+ isLeaf?: boolean;
46
+ };
47
+ export type onExpandHandler = (keys: Key[], info: {
48
+ node: TreeNodeType;
49
+ expanded: boolean;
50
+ nativeEvent: React.MouseEvent;
51
+ }) => void;
52
+ export type onSelectHandler = (keys: Key[], info: {
53
+ node: TreeNodeType;
54
+ selected: boolean;
55
+ nativeEvent: React.MouseEvent;
56
+ }) => void;
57
+ export type RowSelection = {
58
+ selectedKeys?: Key[];
59
+ onSelect: (keys: Key[], info: {
60
+ type: 'row' | 'all';
61
+ selected: boolean;
62
+ nativeEvent: React.ChangeEvent;
63
+ }) => void;
64
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,5 @@
1
1
  import React, { HtmlHTMLAttributes, ReactNode } from 'react';
2
+ import { SizeType } from '../@types/type';
2
3
  export type ButtonProps = {
3
4
  type?: 'default' | 'primary' | 'danger';
4
5
  size?: SizeType;
@@ -1,5 +1,6 @@
1
1
  import React, { HtmlHTMLAttributes } from 'react';
2
2
  import { ListItemProps } from '../List/List';
3
+ import { ColumnType } from '../@types/type';
3
4
  export declare const DefaultColumnWidth = 200;
4
5
  export type ColumnsProps = {
5
6
  columns: ColumnType[];
@@ -13,12 +14,12 @@ export declare const Column: import("styled-components/dist/types").IStyledCompo
13
14
  key: React.Key;
14
15
  title?: React.ReactNode;
15
16
  index?: number | undefined;
16
- itemRender?: ListItemRender | undefined;
17
+ itemRender?: import("../@types/type").ListItemRender | undefined;
17
18
  } & Omit<React.HtmlHTMLAttributes<HTMLLIElement>, "title">, Omit<ColumnType, "render" | "dataIndex"> & {
18
19
  key: React.Key;
19
20
  title?: React.ReactNode;
20
21
  index?: number | undefined;
21
- itemRender?: ListItemRender | undefined;
22
+ itemRender?: import("../@types/type").ListItemRender | undefined;
22
23
  } & Omit<React.HtmlHTMLAttributes<HTMLLIElement>, "title"> & {
23
24
  isFlex: boolean;
24
25
  bordered?: boolean | undefined;
@@ -1,4 +1,5 @@
1
1
  import { HtmlHTMLAttributes } from 'react';
2
+ import { Align, Direction } from '../@types/type';
2
3
  export type FlexProps = {
3
4
  direction?: Direction;
4
5
  width?: number;
@@ -1,4 +1,5 @@
1
1
  import React, { HtmlHTMLAttributes, Key, ReactNode } from 'react';
2
+ import { Direction, ListItemRender } from '../@types/type';
2
3
  type ListItemType = {
3
4
  key: string;
4
5
  title?: ReactNode;
@@ -25,5 +26,9 @@ export declare const StyledLi: import("styled-components/dist/types").IStyledCom
25
26
  focused: boolean;
26
27
  }>> & string;
27
28
  export declare const ListItem: React.FC<ListItemProps>;
28
- declare const List: React.FC<ListProps>;
29
+ declare const List: React.ForwardRefExoticComponent<{
30
+ items?: ListItemType[] | undefined;
31
+ direction?: Direction | undefined;
32
+ itemRender?: ListItemRender | undefined;
33
+ } & React.HtmlHTMLAttributes<HTMLUListElement> & React.RefAttributes<HTMLUListElement>>;
29
34
  export default List;
package/dist/List/List.js CHANGED
@@ -53,7 +53,7 @@ export var ListItem = function ListItem(props) {
53
53
  };
54
54
 
55
55
  /* 理论上来说所有list相关的数据结构都应该交给List组件来完成,但是List组件只处理List结构不处理任何其他样式问题 */
56
- var List = function List(_ref) {
56
+ var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
57
57
  var items = _ref.items,
58
58
  _ref$direction = _ref.direction,
59
59
  direction = _ref$direction === void 0 ? 'row' : _ref$direction,
@@ -62,7 +62,9 @@ var List = function List(_ref) {
62
62
  rest = _objectWithoutProperties(_ref, _excluded2);
63
63
  return /*#__PURE__*/React.createElement(StyledUL, _extends({
64
64
  direction: direction
65
- }, rest), items && Array.isArray(items) ? items.map(function (item, index) {
65
+ }, rest, {
66
+ ref: ref
67
+ }), items && Array.isArray(items) ? items.map(function (item, index) {
66
68
  var key = item.key,
67
69
  title = item.title,
68
70
  rest = _objectWithoutProperties(item, _excluded3);
@@ -73,5 +75,5 @@ var List = function List(_ref) {
73
75
  title: typeof titleStr === 'string' ? titleStr : ''
74
76
  }), titleStr);
75
77
  }) : children);
76
- };
78
+ });
77
79
  export default List;
@@ -1,4 +1,5 @@
1
1
  import React, { ReactNode, type Key } from 'react';
2
+ import { Direction, MenuItem, TriggerType } from '../@types/type';
2
3
  export type MenuProps = {
3
4
  items: MenuItem[];
4
5
  direction?: Direction;
@@ -1,4 +1,5 @@
1
1
  import React, { HtmlHTMLAttributes, type ReactNode } from 'react';
2
+ import { TriggerType } from '../@types/type';
2
3
  export type PopupBoxProps = {
3
4
  children?: ReactNode;
4
5
  left?: number;
@@ -17,5 +18,5 @@ export declare function Popup(props: {
17
18
  trigger?: TriggerType;
18
19
  content?: ReactNode;
19
20
  onVisibleChange?: (visible: boolean) => void;
20
- }): string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
21
+ }): string | number | boolean | React.JSX.Element | Iterable<React.ReactNode> | null | undefined;
21
22
  export default PopupBox;
@@ -20,7 +20,7 @@ declare namespace Select {
20
20
  key: React.Key;
21
21
  title?: React.ReactNode;
22
22
  index?: number | undefined;
23
- itemRender?: ListItemRender | undefined;
23
+ itemRender?: import("..").ListItemRender | undefined;
24
24
  } & Omit<React.HtmlHTMLAttributes<HTMLLIElement>, "title">, SelectListItemProps>> & string & Omit<React.FC<ListItemProps>, keyof React.Component<any, {}, any>>;
25
25
  }
26
26
  export default Select;
@@ -1,4 +1,5 @@
1
1
  import React, { CSSProperties, HtmlHTMLAttributes, ReactNode } from 'react';
2
+ import { Direction, SizeType } from '../@types/type';
2
3
  export type SpaceProps = {
3
4
  children?: ReactNode;
4
5
  className?: string;
@@ -1,4 +1,5 @@
1
1
  import React, { ReactNode } from 'react';
2
+ import { ColumnType, PaginationType, RowSelection, Sorter } from '../@types/type';
2
3
  type SorterDesc = Record<string, Sorter>;
3
4
  type FilterDesc = Record<string, string>;
4
5
  export type Scroll = {
@@ -12,14 +13,15 @@ export type TableProps = {
12
13
  actions?: ReactNode[];
13
14
  title?: ReactNode;
14
15
  scroll?: Scroll;
15
- onChange?: (pagination?: Pagination, sorter?: SorterDesc, fitler?: FilterDesc) => void;
16
+ onChange?: (pagination?: PaginationType, sorter?: SorterDesc, fitler?: FilterDesc) => void;
16
17
  headerRender?: (column: ColumnType) => ReactNode;
17
18
  groupBy?: string;
18
- pagination?: Pagination | false;
19
+ pagination?: PaginationType | false;
19
20
  empty?: ReactNode;
20
21
  rowSelection?: RowSelection;
21
22
  multiple?: boolean;
22
23
  tableContentRef?: React.RefObject<HTMLDivElement>;
24
+ virtual?: boolean;
23
25
  };
24
26
  export default function Table({ columns, dataSource, rowKey, scroll, onChange, headerRender, pagination: outerPagination, empty, rowSelection, multiple, tableContentRef, }: TableProps): React.JSX.Element;
25
27
  export {};
@@ -35,7 +35,7 @@ import { Popup } from "../PopupBox";
35
35
  import { Space } from "../Space";
36
36
  var TableContainer = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral([""])));
37
37
  var TableHeaderRow = styled(Columns)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n border-bottom: var(--kep-platform-line-width) solid var(--kep-platform-color-table-border);\n position: sticky;\n top: 0;\n left: 0;\n z-index: calc(var(--kep-platform-z-index-fixed) + 5);\n & ", " {\n background-color: var(--kep-platform-header-bg);\n font-weight: 600;\n position: sticky;\n &:not(:last-child):after {\n content: '';\n width: 1px;\n height: calc(100% - 2 * var(--kep-platform-padding-xs));\n position: absolute;\n top: var(--kep-platform-padding-xs);\n right: 0;\n background-color: var(--kep-platform-color-border-secondary);\n }\n }\n"])), Column);
38
- var TableBody = styled(List)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral([""])));
38
+ var TableBody = styled(List)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n flex-direction: column;\n"])));
39
39
  var TableBodyRow = styled(ListItem).withConfig({
40
40
  shouldForwardProp: function shouldForwardProp(prop) {
41
41
  return !['isActive'].includes(prop);
@@ -1,4 +1,5 @@
1
1
  import React, { Key, ReactNode } from 'react';
2
+ import { ColumnType, MenuItem, onExpandHandler, onSelectHandler, TreeFieldNames, TreeNodeType } from '../@types/type';
2
3
  export type TreeProps = {
3
4
  treeData: TreeNodeType[];
4
5
  expandedKeys?: Key[];
@@ -1,4 +1,5 @@
1
1
  import React, { Key, ReactNode } from 'react';
2
+ import { ColumnType, MenuItem, onExpandHandler, onSelectHandler, TreeFieldNames, TreeNodeType } from '../@types/type';
2
3
  export type TreeNodeControllerProps = {
3
4
  node: TreeNodeType;
4
5
  selectedKeys: Key[];
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ export * from './@types/type';
2
+ export * from './__styles';
1
3
  export * from './Button';
2
4
  export * from './Columns';
3
5
  export * from './Flex';
@@ -14,4 +16,3 @@ export * from './Table';
14
16
  export * from './Tree';
15
17
  export * from './ViewPort';
16
18
  export * from './Window';
17
- export * from './__styles';
package/dist/index.js CHANGED
@@ -1,3 +1,5 @@
1
+ export * from "./@types/type";
2
+ export * from "./__styles";
1
3
  export * from "./Button";
2
4
  export * from "./Columns";
3
5
  export * from "./Flex";
@@ -13,5 +15,4 @@ export * from "./Spin";
13
15
  export * from "./Table";
14
16
  export * from "./Tree";
15
17
  export * from "./ViewPort";
16
- export * from "./Window";
17
- export * from "./__styles";
18
+ export * from "./Window";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kep-platform/basic-component",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "description": "A react library developed with dumi",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",
@@ -47,7 +47,7 @@
47
47
  },
48
48
  "dependencies": {
49
49
  "@ant-design/icons": "^5.3.7",
50
- "@kep-platform/hooks": "^0.2.0",
50
+ "@kep-platform/hooks": "^0.3.1",
51
51
  "color": "^4.2.3",
52
52
  "rc-pagination": "^4.1.0"
53
53
  },
@@ -87,5 +87,5 @@
87
87
  "authors": [
88
88
  "less-step-jss 1599925910@qq.com"
89
89
  ],
90
- "gitHead": "54a6f029d61a1bd43f18e5d9021193c18307cb4b"
90
+ "gitHead": "63be39dfc99f519d873b7da30a3d4ee291122f48"
91
91
  }
@@ -1,81 +0,0 @@
1
- import { keyframes } from 'styled-components';
2
- import { PaginationProps } from '../Pagination';
3
- declare global {
4
- type SizeType = 'small' | 'large' | 'middle';
5
- type Keyframes = ReturnType<typeof keyframes>;
6
- type Direction = 'row' | 'column' | 'row-reverse' | 'column-reverse';
7
- type ListItemRender = (record: any, index: number) => ReactNode;
8
- type Align = 'left' | 'right' | 'center';
9
- type Pagination = PaginationProps;
10
- type ColumnRender = (value: any, record: Record<string, any>, index: number) => ReactNode;
11
- type ColumnType = {
12
- key: string;
13
- dataIndex: string;
14
- width?: number;
15
- title?: ReactNode;
16
- render?: ColumnRender;
17
- align?: Align;
18
- hideInTable?: boolean;
19
- fixed?: 'left' | 'right';
20
- left?: string;
21
- right?: string;
22
- bordered?: boolean;
23
- sorter?: boolean | SorterFunc;
24
- filter?: boolean;
25
- };
26
- type SorterFunc = (a: any, b: any) => number;
27
- type Sorter = 'desc' | 'asc' | undefined;
28
- type TriggerType = 'click' | 'mouseover' | 'contextmenu' | 'doubleClick';
29
- type MenuItem = {
30
- key: Key;
31
- title?: string;
32
- label: ReactNode;
33
- };
34
- type RequiredTreeNodeKeys = 'key' | 'title' | 'children';
35
-
36
- type TreeFieldNames = {
37
- [key in RequiredTreeNodeKeys]: string;
38
- };
39
-
40
- type Condition = {
41
- attribute: string;
42
- condition?: (value: any) => boolean;
43
- description: string;
44
- };
45
-
46
- type TreeNodeType = {
47
- [key: string]: any;
48
- groupBy?: Condition[];
49
- selectable?: boolean;
50
- isLeaf?: boolean;
51
- };
52
-
53
- type onExpandHandler = (
54
- keys: Key[],
55
- info: {
56
- node: TreeNodeType;
57
- expanded: boolean;
58
- nativeEvent: React.MouseEvent;
59
- },
60
- ) => void;
61
-
62
- type onSelectHandler = (
63
- keys: Key[],
64
- info: {
65
- node: TreeNodeType;
66
- selected: boolean;
67
- nativeEvent: React.MouseEvent;
68
- },
69
- ) => void;
70
- type RowSelection = {
71
- selectedKeys?: Key[];
72
- onSelect: (
73
- keys: Key[],
74
- info: {
75
- type: 'row' | 'all';
76
- selected: boolean;
77
- nativeEvent: React.ChangeEvent;
78
- },
79
- ) => void;
80
- };
81
- }