@lemon-fe/kits 1.0.0-15 → 1.0.0-19

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.
@@ -8,7 +8,7 @@ export declare type PathType = string | (string | number)[];
8
8
  export declare type ValidateRule<T> = Pick<RuleItem, 'required' | 'message' | 'pattern' | 'min' | 'max' | 'len' | 'type'> & {
9
9
  validator?: (rule: any, val: any, record: T) => void | Promise<void>;
10
10
  };
11
- export declare type EditableRender<T> = (val: any, record: T, index: number, params: {
11
+ export declare type EditableRender<T, K = any> = (val: K, record: T, index: number, params: {
12
12
  context: any;
13
13
  ref: RefObject<{
14
14
  select?: () => void;
@@ -16,7 +16,7 @@ export declare type EditableRender<T> = (val: any, record: T, index: number, par
16
16
  blur?: () => void;
17
17
  }>;
18
18
  onChange: (val: Partial<T>, action?: 'stop' | 'next') => void;
19
- } & ICellEditorParams) => ReactNode;
19
+ } & ICellEditorParams<T, K>) => ReactNode;
20
20
  export interface ColumnType<TData> extends Omit<ColDef<TData>, 'editable'> {
21
21
  title?: ReactNode | ((params: IHeaderParams) => ReactNode);
22
22
  dataIndex?: PathType;
@@ -18,6 +18,7 @@ interface Props {
18
18
  direction?: 'row' | 'column';
19
19
  style?: CSSProperties;
20
20
  className?: string;
21
+ labelWidth?: number;
21
22
  }
22
23
  declare function FormLayout(props: Props): JSX.Element;
23
24
  declare namespace FormLayout {
@@ -1,13 +1,18 @@
1
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
+
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
+
1
5
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
6
 
3
7
  import React from 'react';
4
8
  import classNames from 'classnames';
5
- import { PREFIX_CLS } from "../../constants";
9
+ import { prefixClassName } from "../utils";
10
+ var prefix = prefixClassName('form');
6
11
 
7
12
  var FormRow = function FormRow(props) {
8
13
  var children = props.children;
9
14
  return /*#__PURE__*/React.createElement("div", {
10
- className: classNames("".concat(PREFIX_CLS, "-form-row"))
15
+ className: prefix('row')
11
16
  }, children);
12
17
  };
13
18
 
@@ -15,7 +20,7 @@ var FormCol = function FormCol(props) {
15
20
  var span = props.span,
16
21
  children = props.children;
17
22
  return /*#__PURE__*/React.createElement("div", {
18
- className: classNames("".concat(PREFIX_CLS, "-form-col"), _defineProperty({}, "".concat(PREFIX_CLS, "-form-col-").concat(span), span !== undefined))
23
+ className: classNames(prefix('col'), _defineProperty({}, prefix("col-".concat(span)), span !== undefined))
19
24
  }, children);
20
25
  };
21
26
 
@@ -25,12 +30,19 @@ function FormLayout(props) {
25
30
  children = props.children,
26
31
  style = props.style,
27
32
  className = props.className,
28
- layout = props.layout;
33
+ layout = props.layout,
34
+ labelWidth = props.labelWidth;
35
+ var extraStyle;
36
+
37
+ if (labelWidth) {
38
+ extraStyle = _defineProperty({}, "--".concat(prefix('label-width')), "".concat(labelWidth, "px"));
39
+ }
40
+
29
41
  return /*#__PURE__*/React.createElement("div", {
30
- className: classNames("".concat(PREFIX_CLS, "-form-layout"), _defineProperty({}, "".concat(PREFIX_CLS, "-form-layout-flex"), layout === 'flex'), className),
31
- style: style
42
+ className: classNames(prefix('layout'), _defineProperty({}, prefix('layout-flex'), layout === 'flex'), className),
43
+ style: extraStyle !== undefined ? _objectSpread(_objectSpread({}, style), extraStyle) : style
32
44
  }, /*#__PURE__*/React.createElement("div", {
33
- className: "".concat(PREFIX_CLS, "-form-layout-").concat(direction)
45
+ className: prefix("layout-".concat(direction))
34
46
  }, children));
35
47
  }
36
48
 
@@ -1,7 +1,8 @@
1
1
  @spaceX: 16px;
2
2
  @spaceY: 8px;
3
+ @labelWidth: 94px;
3
4
  @minWidth: 350px;
4
- @maxWidth: 94px + 422px;
5
+ @maxWidth: @labelWidth + 422px;
5
6
 
6
7
  .wrapper() {
7
8
  margin-right: (-@spaceX / 2);
@@ -24,15 +25,17 @@
24
25
 
25
26
  .@{prefixCls}-form {
26
27
  &-layout {
28
+ --@{prefixCls}-form-label-width: @labelWidth;
29
+
27
30
  min-width: @minWidth - @spaceX;
28
- max-width: 4 * @maxWidth - @spaceX;
31
+ max-width: ~'calc(4 * (var(--@{prefixCls}-form-label-width) + 422px) - @{spaceX})';
29
32
 
30
33
  .@{ant-prefix}-form-item {
31
34
  flex-wrap: nowrap;
32
35
  margin-bottom: @spaceY;
33
36
 
34
37
  &-label {
35
- flex: 0 0 94px;
38
+ flex: 0 0 ~'var(--@{prefixCls}-form-label-width)';
36
39
  min-width: 0;
37
40
  overflow: visible;
38
41
  line-height: 1;
@@ -1,7 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import { TreeProps } from 'rc-tree';
3
- import type { DataNode, EventDataNode } from 'rc-tree/lib/interface';
4
- import { TabsProps } from 'antd';
2
+ import { type TabsProps, type TreeProps } from 'antd';
5
3
  import type { TreeData, OperationType } from './typings';
6
4
  interface Props<KeyType> extends Omit<TreeProps, 'onSelect' | 'selectedKeys' | 'defaultSelectedKeys' | 'defaultExpandAll' | 'defaultExpandedKeys' | 'prefixCls'> {
7
5
  data?: TreeData<KeyType>[];
@@ -10,13 +8,7 @@ interface Props<KeyType> extends Omit<TreeProps, 'onSelect' | 'selectedKeys' | '
10
8
  header?: ReactNode;
11
9
  footer?: ReactNode;
12
10
  operation?: OperationType<KeyType>;
13
- onSelect?: (node: TreeData<KeyType>, info: {
14
- event: 'select';
15
- selected: boolean;
16
- node: EventDataNode<DataNode>;
17
- selectedNodes: DataNode[];
18
- nativeEvent: MouseEvent;
19
- }) => void;
11
+ onSelect?: (node: TreeData<KeyType>, info: Parameters<Exclude<TreeProps['onSelect'], undefined>>[1]) => void;
20
12
  selectedKeys?: KeyType[];
21
13
  defaultSelectedKeys?: KeyType[];
22
14
  defaultExpandAll?: boolean;
@@ -29,8 +29,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
29
29
 
30
30
  import React, { useMemo, useState } from 'react';
31
31
  import { useDebounce } from '@lemon-fe/hooks';
32
- import Tree from 'rc-tree';
33
- import { Input, Tabs } from 'antd';
32
+ import { Input, Tabs, Tree } from 'antd';
34
33
  import { PREFIX_CLS } from "../../constants";
35
34
  import TreeNodeTitle from "./TreeNodeTitle";
36
35
  import Icons from "../Icons";
@@ -149,8 +148,7 @@ export default function SiderTree(props) {
149
148
  src: empty
150
149
  }), /*#__PURE__*/React.createElement("div", null, "\u6682\u65E0\u6570\u636E")) : /*#__PURE__*/React.createElement(Tree, _extends({
151
150
  treeData: tree,
152
- prefixCls: prefixCls,
153
- itemHeight: 40,
151
+ itemHeight: 28,
154
152
  showLine: true,
155
153
  onSelect: function onSelect(selectedKeys, info) {
156
154
  if (_onSelect) {
@@ -8,15 +8,6 @@
8
8
  box-sizing: border-box;
9
9
  height: 100%;
10
10
  padding: @space-v 0;
11
-
12
- .@{prefixCls}-tree-list-scrollbar {
13
- display: block !important;
14
- right: -16px !important;
15
- }
16
-
17
- .@{prefixCls}-tree-list-scrollbar-thumb {
18
- background: #ddd !important;
19
- }
20
11
  }
21
12
 
22
13
  &-menu-popover {
@@ -66,134 +57,126 @@
66
57
 
67
58
  &-body {
68
59
  min-height: 0;
69
- padding: 0 @space-h;
70
60
  overflow: auto;
71
-
72
61
  .scrollBar(8px);
73
- }
74
62
 
75
- &-header + &-body {
76
- margin-top: 12px;
77
- }
63
+ .@{ant-prefix}-tree {
64
+ &-list-holder-inner {
65
+ align-items: stretch;
66
+ }
78
67
 
79
- &-header + .@{ant-prefix}-tabs {
80
- margin-top: 8px;
81
- }
68
+ &-list {
69
+ padding: 0 @space-h;
70
+ }
82
71
 
83
- &-footer {
84
- margin-top: 12px;
85
- padding: 0 12px;
86
- }
72
+ &-list-scrollbar-thumb {
73
+ background: #ddd !important;
74
+ }
87
75
 
88
- &-treenode {
89
- display: flex;
90
- align-items: center;
91
- height: @treeNodeHeight;
92
- }
76
+ &-treenode {
77
+ display: flex;
78
+ align-items: center;
79
+ height: @treeNodeHeight;
80
+ padding-bottom: 0;
81
+ }
93
82
 
94
- &-indent {
95
- align-self: stretch;
96
- white-space: nowrap;
97
- user-select: none;
83
+ &-indent {
84
+ align-self: stretch;
85
+ white-space: nowrap;
86
+ user-select: none;
98
87
 
99
- &-unit {
100
- display: inline-block;
101
- width: @indentWidth;
102
- vertical-align: top;
103
- }
104
- }
88
+ &-unit {
89
+ display: inline-block;
90
+ width: @indentWidth;
91
+ vertical-align: top;
92
+ }
93
+ }
105
94
 
106
- &-show-line &-indent-unit {
107
- position: relative;
108
- height: 100%;
95
+ &-node-content-wrapper {
96
+ display: flex;
97
+ flex: 1;
98
+ align-items: center;
99
+ min-width: 0;
100
+ padding: 0;
101
+ }
109
102
 
110
- &::before {
111
- position: absolute;
112
- top: 0;
113
- right: @indentWidth / 2;
114
- bottom: 0;
115
- border-right: 1px solid #c4c4c4;
116
- content: '';
117
- }
118
- }
103
+ &-switcher {
104
+ position: relative;
105
+ display: flex;
106
+ flex: none;
107
+ justify-content: center;
108
+ align-items: center;
109
+ width: @indentWidth;
110
+ height: @treeNodeHeight;
111
+ margin: 0;
112
+ cursor: pointer;
113
+ user-select: none;
119
114
 
120
- &-switcher {
121
- position: relative;
122
- display: block;
123
- flex: none;
124
- align-self: stretch;
125
- width: @indentWidth;
126
- margin: 0;
127
- line-height: @treeNodeHeight;
128
- text-align: center;
129
- cursor: pointer;
130
- user-select: none;
115
+ & svg {
116
+ width: 13px;
117
+ height: 13px;
118
+ }
119
+ }
131
120
 
132
- & svg {
133
- width: 13px;
134
- height: 13px;
135
- }
121
+ &-title {
122
+ display: flex;
123
+ flex: 1;
124
+ align-items: center;
125
+ justify-content: space-between;
126
+ min-width: 56px;
127
+ padding: 0 8px;
128
+ border-radius: 4px;
129
+ cursor: pointer;
130
+ transition: background-color 0.2s;
131
+ }
136
132
 
137
- &-noop {
138
- display: none;
133
+ &-node-selected {
134
+ color: @primary-color;
135
+ background: .primary(0.1) [] !important;
136
+ }
139
137
  }
140
138
  }
141
139
 
142
- &-node-content-wrapper {
143
- display: flex;
144
- flex: 1;
145
- align-items: center;
146
- min-width: 0;
140
+ &-title-content {
141
+ display: block;
142
+ height: @treeNodeHeight;
143
+ overflow: hidden;
144
+ line-height: @treeNodeHeight;
145
+ white-space: nowrap;
146
+ text-overflow: ellipsis;
147
147
  }
148
148
 
149
- &-node-selected &-title {
150
- color: @primary-color;
151
- background: .primary(0.1) [] !important;
152
- }
149
+ &-title-operators {
150
+ &-item {
151
+ width: 20px;
152
+ height: 20px;
153
+ margin-left: 4px;
154
+ line-height: 1;
155
+ text-align: center;
156
+ border-radius: 4px;
153
157
 
154
- &-title {
155
- display: flex;
156
- flex: 1;
157
- align-items: center;
158
- justify-content: space-between;
159
- min-width: 56px;
160
- padding: 0 8px;
161
- border-radius: 4px;
162
- cursor: pointer;
163
- transition: background-color 0.2s;
164
-
165
- &:hover {
166
- background-color: #ededed;
167
- }
158
+ & svg {
159
+ vertical-align: middle;
160
+ }
168
161
 
169
- &-content {
170
- display: block;
171
- height: @treeNodeHeight;
172
- overflow: hidden;
173
- line-height: @treeNodeHeight;
174
- white-space: nowrap;
175
- text-overflow: ellipsis;
162
+ &-active,
163
+ &:hover {
164
+ background: #d7d7d7;
165
+ }
176
166
  }
167
+ }
177
168
 
178
- &-operators {
179
- &-item {
180
- width: 20px;
181
- height: 20px;
182
- margin-left: 4px;
183
- line-height: 1;
184
- text-align: center;
185
- border-radius: 4px;
169
+ &-header + &-body {
170
+ margin-top: 12px;
171
+ }
186
172
 
187
- & svg {
188
- vertical-align: middle;
189
- }
173
+ &-header + .@{ant-prefix}-tabs {
174
+ margin-top: 8px;
175
+ }
190
176
 
191
- &-active,
192
- &:hover {
193
- background: #d7d7d7;
194
- }
195
- }
196
- }
177
+ &-footer {
178
+ margin-top: 12px;
179
+ padding: 0 12px;
197
180
  }
198
181
 
199
182
  &-empty {
@@ -1,7 +1,7 @@
1
- import type { TreeNodeProps } from 'rc-tree';
1
+ import type { DataNode } from 'antd/es/tree';
2
2
  import type { ReactNode } from 'react';
3
3
 
4
- export interface TreeData<T> extends Pick<TreeNodeProps, 'icon'> {
4
+ export interface TreeData<T = string | number> extends Pick<DataNode, 'icon'> {
5
5
  key: T;
6
6
  title: string | number;
7
7
  parent?: T;
package/es/index.d.ts CHANGED
@@ -21,6 +21,7 @@ export { default as DurationPicker } from './components/DurationPicker';
21
21
  export { default as ColorPicker } from './components/ColorPicker';
22
22
  export { default as Popup } from './components/Popup';
23
23
  export { default as SiderTree } from './components/SiderTree';
24
+ export type { TreeData } from './components/SiderTree/typings';
24
25
  export { default as Icons } from './components/Icons';
25
26
  export { default as FormLayout } from './components/FormLayout';
26
27
  export { default as TabBar } from './components/TabBar';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lemon-fe/kits",
3
- "version": "1.0.0-15",
3
+ "version": "1.0.0-19",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -47,7 +47,6 @@
47
47
  "lodash": "^4.17.0",
48
48
  "moment": "^2.29.4",
49
49
  "rc-resize-observer": "^1.0.0",
50
- "rc-tree": "^5.7.0",
51
50
  "react-color": "^2.19.3",
52
51
  "react-gcolor-picker": "^1.2.4",
53
52
  "react-resizable": "^3.0.4",