@lemon-fe/kits 1.0.4 → 1.0.5-1

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.
@@ -52,7 +52,7 @@ export default class DataGrid<TData extends Record<string, any>> extends Compone
52
52
  Text: React.ForwardRefExoticComponent<import("@ag-grid-community/core").ICellEditorParams<any, any, any> & import("./typings").TextEditorParams<any> & React.RefAttributes<import("@ag-grid-community/react").ICellEditorReactComp>>;
53
53
  Date: React.ForwardRefExoticComponent<import("@ag-grid-community/core").ICellEditorParams<any, any, any> & import("./typings").DateEditorParams<any> & React.RefAttributes<import("@ag-grid-community/react").ICellEditorReactComp>>;
54
54
  Number: React.ForwardRefExoticComponent<import("@ag-grid-community/core").ICellEditorParams<any, any, any> & import("./typings").NumberEditorParams<any> & React.RefAttributes<import("@ag-grid-community/react").ICellEditorReactComp>>;
55
- Select: React.ForwardRefExoticComponent<import("@ag-grid-community/core").ICellEditorParams<any, any, any> & Pick<import("antd").SelectProps<any, import("antd/lib/select").BaseOptionType>, "disabled" | "allowClear" | "mode" | "options" | "virtual" | "showSearch" | "listHeight"> & {
55
+ Select: React.ForwardRefExoticComponent<import("@ag-grid-community/core").ICellEditorParams<any, any, any> & Pick<import("antd").SelectProps<any, import("antd/lib/select").BaseOptionType>, "disabled" | "mode" | "allowClear" | "options" | "virtual" | "showSearch" | "listHeight"> & {
56
56
  fieldNames?: {
57
57
  label: string;
58
58
  value: string;
@@ -1345,9 +1345,6 @@ var DataGrid = /*#__PURE__*/function (_Component) {
1345
1345
  lockVisible: true,
1346
1346
  initialWidth: 160,
1347
1347
  cellClass: prefix('operator-cell'),
1348
- cellRendererParams: {
1349
- actions: this.props.rowActions
1350
- },
1351
1348
  cellRenderer: ActionsRenderer
1352
1349
  }, this.props.rowActionsColDef));
1353
1350
  }
@@ -1,9 +1,10 @@
1
1
  /// <reference types="react" />
2
+ import type { ICellRendererParams } from '@ag-grid-community/core';
2
3
  import type { RowActionsType } from '../typings';
3
4
  interface Props<T> {
4
5
  actions: RowActionsType<T>;
5
6
  data: T;
6
- context?: any;
7
+ params: ICellRendererParams<T>;
7
8
  maxShowCount?: number;
8
9
  }
9
10
  export default function Actions<T>(props: Props<T>): JSX.Element;
@@ -38,10 +38,10 @@ function ActionItem(props) {
38
38
  export default function Actions(props) {
39
39
  var data = props.data,
40
40
  actionsProp = props.actions,
41
- context = props.context,
41
+ params = props.params,
42
42
  _props$maxShowCount = props.maxShowCount,
43
43
  maxShowCount = _props$maxShowCount === void 0 ? Infinity : _props$maxShowCount;
44
- var actions = typeof actionsProp === 'function' ? actionsProp(data, context) : actionsProp;
44
+ var actions = typeof actionsProp === 'function' ? actionsProp(data, params) : actionsProp;
45
45
 
46
46
  var traverse = function traverse(node, idx) {
47
47
  if (node === null) {
@@ -1,6 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import type { ICellRendererParams } from '@ag-grid-community/core';
3
- import type { RowActionsType } from '../typings';
4
- export default function ActionsRenderer<TData>(props: ICellRendererParams<TData> & {
5
- actions: RowActionsType<TData>;
6
- }): JSX.Element | null;
3
+ export default function ActionsRenderer<TData>(props: ICellRendererParams<TData>): JSX.Element | null;
@@ -1,3 +1,9 @@
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
+
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; }
6
+
1
7
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
8
 
3
9
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -11,17 +17,24 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
11
17
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
18
 
13
19
  import React, { useEffect, useState } from 'react';
20
+ import { useGridStore } from "../hooks";
14
21
  import DataGrid from "../index";
15
22
  import Actions from "./Actions";
16
23
  export default function ActionsRenderer(props) {
17
- var actions = props.actions,
18
- node = props.node;
24
+ var node = props.node;
19
25
 
20
26
  var _useState = useState(node.data),
21
27
  _useState2 = _slicedToArray(_useState, 2),
22
28
  data = _useState2[0],
23
29
  setData = _useState2[1];
24
30
 
31
+ var _useGridStore = useGridStore(function (state) {
32
+ return [state.context, state.grid.props.rowActions];
33
+ }),
34
+ _useGridStore2 = _slicedToArray(_useGridStore, 2),
35
+ ctx = _useGridStore2[0],
36
+ rowActions = _useGridStore2[1];
37
+
25
38
  useEffect(function () {
26
39
  var handler = function handler(evt) {
27
40
  setData(evt.newData);
@@ -33,7 +46,7 @@ export default function ActionsRenderer(props) {
33
46
  };
34
47
  }, []);
35
48
 
36
- if (DataGrid.isSummaryRow({
49
+ if (!rowActions || DataGrid.isSummaryRow({
37
50
  node: node
38
51
  }) || !data) {
39
52
  return null;
@@ -41,6 +54,9 @@ export default function ActionsRenderer(props) {
41
54
 
42
55
  return /*#__PURE__*/React.createElement(Actions, {
43
56
  data: data,
44
- actions: actions
57
+ actions: rowActions,
58
+ params: _objectSpread(_objectSpread({}, props), {}, {
59
+ context: ctx
60
+ })
45
61
  });
46
62
  }
@@ -108,9 +108,7 @@ export interface RowAction<T> {
108
108
  disabled?: boolean;
109
109
  dropDown?: (RowAction<T> | null)[];
110
110
  }
111
- export declare type RowActionsType<T> = (RowAction<T> | null)[] | ((record: T, params: {
112
- context?: any;
113
- }) => (RowAction<T> | null)[]);
111
+ export declare type RowActionsType<T> = (RowAction<T> | null)[] | ((record: T, params: ICellRendererParams<T>) => (RowAction<T> | null)[]);
114
112
  export declare type DetailCell<TData, Params = Record<string, never>> = {
115
113
  params?: Params;
116
114
  /** 这是一个render函数不是组件 */
@@ -333,3 +333,15 @@ span.@{ant-prefix}-radio + * {
333
333
  line-height: 20px;
334
334
  }
335
335
  }
336
+
337
+ /** alert **/
338
+ @alert-padding-vertical: @padding-xs - 2;
339
+
340
+ .@{ant-prefix}-alert {
341
+ align-items: flex-start;
342
+
343
+ &-icon {
344
+ padding: 2px 0;
345
+ font-size: 18px;
346
+ }
347
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lemon-fe/kits",
3
- "version": "1.0.4",
3
+ "version": "1.0.5-1",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",