@lemon-fe/kits 1.0.0-34 → 1.0.0-36
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/components/DataGrid/cell-editors/{Custom.d.ts → Row.d.ts} +8 -2
- package/es/components/DataGrid/cell-editors/{Custom.js → Row.js} +41 -9
- package/es/components/DataGrid/index.js +17 -8
- package/es/components/DataGrid/typings.d.ts +3 -4
- package/package.json +1 -1
- package/es/components/DataGrid/cell-editors/Combination.d.ts +0 -8
- package/es/components/DataGrid/cell-editors/Combination.js +0 -25
|
@@ -2,8 +2,14 @@ import type { MutableRefObject, ReactElement } from 'react';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import type { ICellEditorReactComp } from '@ag-grid-community/react';
|
|
4
4
|
import type { ICellEditorParams } from '@ag-grid-community/core';
|
|
5
|
-
export
|
|
5
|
+
export declare class RowEditorData<T> {
|
|
6
|
+
private data;
|
|
7
|
+
constructor(data: T);
|
|
8
|
+
getValue(): T;
|
|
9
|
+
}
|
|
10
|
+
export interface RowEditorParams<T = any, K = any> {
|
|
6
11
|
suppressEnterEvent?: boolean;
|
|
12
|
+
isCancelAfterEnd?: (prevValue: T, nextValue: T) => boolean;
|
|
7
13
|
render: (val: K, data: T, params: ICellEditorParams<T, K> & {
|
|
8
14
|
ref: MutableRefObject<{
|
|
9
15
|
select?: () => void;
|
|
@@ -12,5 +18,5 @@ export interface CustomEditorParams<T = any, K = any> {
|
|
|
12
18
|
onChange: (val: Partial<T>, action?: 'stop' | 'next') => void;
|
|
13
19
|
}) => ReactElement | null;
|
|
14
20
|
}
|
|
15
|
-
declare const _default: React.ForwardRefExoticComponent<ICellEditorParams<any, any> &
|
|
21
|
+
declare const _default: React.ForwardRefExoticComponent<ICellEditorParams<any, any> & RowEditorParams<any, any> & React.RefAttributes<ICellEditorReactComp>>;
|
|
16
22
|
export default _default;
|
|
@@ -2,8 +2,6 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
2
2
|
|
|
3
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
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
|
-
|
|
7
5
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
6
|
|
|
9
7
|
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."); }
|
|
@@ -16,18 +14,44 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
16
14
|
|
|
17
15
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
18
16
|
|
|
17
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
18
|
+
|
|
19
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
20
|
+
|
|
21
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
22
|
+
|
|
23
|
+
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; }
|
|
24
|
+
|
|
19
25
|
import React, { useEffect, useRef } from 'react';
|
|
20
26
|
import { get } from 'lodash';
|
|
21
27
|
import { forwardRef, useImperativeHandle, useState } from 'react';
|
|
22
28
|
import EditorWrapper from "./Wrapper";
|
|
23
29
|
import { useGridStore } from "../hooks";
|
|
24
|
-
export
|
|
30
|
+
export var RowEditorData = /*#__PURE__*/function () {
|
|
31
|
+
function RowEditorData(data) {
|
|
32
|
+
_classCallCheck(this, RowEditorData);
|
|
33
|
+
|
|
34
|
+
_defineProperty(this, "data", void 0);
|
|
35
|
+
|
|
36
|
+
this.data = data;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
_createClass(RowEditorData, [{
|
|
40
|
+
key: "getValue",
|
|
41
|
+
value: function getValue() {
|
|
42
|
+
return this.data;
|
|
43
|
+
}
|
|
44
|
+
}]);
|
|
45
|
+
|
|
46
|
+
return RowEditorData;
|
|
47
|
+
}();
|
|
48
|
+
export default /*#__PURE__*/forwardRef(function RowEditor(props, ref) {
|
|
25
49
|
var api = props.api,
|
|
26
50
|
suppressEnterEvent = props.suppressEnterEvent,
|
|
27
51
|
stopEditing = props.stopEditing,
|
|
28
52
|
data = props.data,
|
|
29
53
|
render = props.render,
|
|
30
|
-
|
|
54
|
+
isCancelAfterEnd = props.isCancelAfterEnd,
|
|
31
55
|
field = props.colDef.field;
|
|
32
56
|
|
|
33
57
|
var _useState = useState(data),
|
|
@@ -51,12 +75,20 @@ export default /*#__PURE__*/forwardRef(function CustomEditor(props, ref) {
|
|
|
51
75
|
useImperativeHandle(ref, function () {
|
|
52
76
|
return {
|
|
53
77
|
getValue: function getValue() {
|
|
54
|
-
var
|
|
78
|
+
var prevValue = props.value;
|
|
79
|
+
var nextValue = prevValue;
|
|
80
|
+
|
|
81
|
+
if (field === undefined) {
|
|
82
|
+
return prevValue;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
nextValue = get(value, field);
|
|
86
|
+
|
|
87
|
+
if (nextValue == prevValue || isCancelAfterEnd !== undefined && isCancelAfterEnd(data, _objectSpread(_objectSpread({}, data), value))) {
|
|
88
|
+
return prevValue;
|
|
89
|
+
}
|
|
55
90
|
|
|
56
|
-
|
|
57
|
-
node.setData(newData);
|
|
58
|
-
});
|
|
59
|
-
return field ? get(newData, field) : props.value;
|
|
91
|
+
return new RowEditorData(value);
|
|
60
92
|
}
|
|
61
93
|
};
|
|
62
94
|
});
|
|
@@ -87,7 +87,7 @@ import DateEditor from "./cell-editors/Date";
|
|
|
87
87
|
import TextEditor from "./cell-editors/Text";
|
|
88
88
|
import NumberEditor from "./cell-editors/Number";
|
|
89
89
|
import SelectEditor from "./cell-editors/Select";
|
|
90
|
-
import
|
|
90
|
+
import RowEditor, { RowEditorData } from "./cell-editors/Row";
|
|
91
91
|
import EditorWrapper from "./cell-editors/Wrapper";
|
|
92
92
|
export { AgGridReact } from '@ag-grid-community/react';
|
|
93
93
|
ModuleRegistry.registerModules([ClientSideRowModelModule, RowGroupingModule, InfiniteRowModelModule, ClipboardModule, MenuModule, SideBarModule, ColumnsToolPanelModule, ServerSideRowModelModule], false);
|
|
@@ -102,7 +102,7 @@ var defaultComponents = {
|
|
|
102
102
|
'number-editor': NumberEditor,
|
|
103
103
|
'date-editor': DateEditor,
|
|
104
104
|
'select-editor': SelectEditor,
|
|
105
|
-
'row-editor':
|
|
105
|
+
'row-editor': RowEditor
|
|
106
106
|
};
|
|
107
107
|
|
|
108
108
|
var DataGrid = /*#__PURE__*/function (_Component) {
|
|
@@ -581,18 +581,27 @@ var DataGrid = /*#__PURE__*/function (_Component) {
|
|
|
581
581
|
_opts.cellRenderer = CellRenderer;
|
|
582
582
|
}
|
|
583
583
|
|
|
584
|
-
if (_opts.valueSetter === undefined
|
|
584
|
+
if (_opts.valueSetter === undefined) {
|
|
585
585
|
_opts.valueSetter = function (mParams) {
|
|
586
586
|
var colField = mParams.colDef.field,
|
|
587
587
|
data = mParams.data,
|
|
588
|
-
newValue = mParams.newValue
|
|
588
|
+
newValue = mParams.newValue,
|
|
589
|
+
oldValue = mParams.oldValue;
|
|
589
590
|
|
|
590
|
-
if (colField) {
|
|
591
|
-
|
|
591
|
+
if (!colField || newValue === oldValue) {
|
|
592
|
+
return false;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
set(data, colField, newValue);
|
|
596
|
+
|
|
597
|
+
if (valueSetter !== undefined) {
|
|
598
|
+
var _result = valueSetter(newValue, data);
|
|
599
|
+
|
|
600
|
+
Object.assign(data, _result);
|
|
601
|
+
} else if (newValue instanceof RowEditorData) {
|
|
602
|
+
Object.assign(data, newValue.getValue());
|
|
592
603
|
}
|
|
593
604
|
|
|
594
|
-
var result = valueSetter(mParams.newValue, mParams.data);
|
|
595
|
-
Object.assign(data, result);
|
|
596
605
|
return true;
|
|
597
606
|
};
|
|
598
607
|
}
|
|
@@ -6,13 +6,12 @@ import type { TextEditorParams } from './cell-editors/Text';
|
|
|
6
6
|
import type { NumberEditorParams } from './cell-editors/Number';
|
|
7
7
|
import type { DateEditorParams } from './cell-editors/Date';
|
|
8
8
|
import type { SelectEditorParams } from './cell-editors/Select';
|
|
9
|
-
import type {
|
|
9
|
+
import type { RowEditorParams } from './cell-editors/Row';
|
|
10
10
|
export type { TextEditorParams } from './cell-editors/Text';
|
|
11
11
|
export type { NumberEditorParams } from './cell-editors/Number';
|
|
12
12
|
export type { DateEditorParams } from './cell-editors/Date';
|
|
13
13
|
export type { SelectEditorParams } from './cell-editors/Select';
|
|
14
|
-
export type {
|
|
15
|
-
export type { CustomEditorParams } from './cell-editors/Custom';
|
|
14
|
+
export type { RowEditorParams } from './cell-editors/Row';
|
|
16
15
|
export declare type GetRowId<T> = string | ((data: T) => string);
|
|
17
16
|
export declare type PathType = string | (string | number)[];
|
|
18
17
|
export declare type ValidateRule<T> = Pick<RuleItem, 'required' | 'message' | 'pattern' | 'min' | 'max' | 'len' | 'type'> & {
|
|
@@ -23,7 +22,7 @@ interface EditorParamsType<T extends string, K extends Record<string, any>> {
|
|
|
23
22
|
params?: K;
|
|
24
23
|
component?: string;
|
|
25
24
|
}
|
|
26
|
-
declare type EditorType<TData> = EditorParamsType<'text-editor', TextEditorParams> | EditorParamsType<'number-editor', NumberEditorParams> | EditorParamsType<'date-editor', DateEditorParams> | EditorParamsType<'select-editor', SelectEditorParams> | EditorParamsType<'row-editor',
|
|
25
|
+
declare type EditorType<TData> = EditorParamsType<'text-editor', TextEditorParams> | EditorParamsType<'number-editor', NumberEditorParams> | EditorParamsType<'date-editor', DateEditorParams> | EditorParamsType<'select-editor', SelectEditorParams> | EditorParamsType<'row-editor', RowEditorParams<TData>>;
|
|
27
26
|
export interface ColType<TData> extends Omit<ColDef<TData>, 'editable'> {
|
|
28
27
|
title?: ReactNode | ((params: IHeaderParams) => ReactNode);
|
|
29
28
|
dataIndex?: PathType;
|
package/package.json
CHANGED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { ICellEditorReactComp } from '@ag-grid-community/react';
|
|
2
|
-
import type { ICellEditorParams } from '@ag-grid-community/core';
|
|
3
|
-
import { type ForwardedRef, type ReactElement } from 'react';
|
|
4
|
-
export interface CombinationEditorParams<T = any> {
|
|
5
|
-
render: (props: ICellEditorParams<T>, ref: ForwardedRef<ICellEditorReactComp>) => ReactElement | null;
|
|
6
|
-
}
|
|
7
|
-
declare const _default: import("react").ForwardRefExoticComponent<ICellEditorParams<any, any> & CombinationEditorParams<any> & import("react").RefAttributes<ICellEditorReactComp>>;
|
|
8
|
-
export default _default;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
var _excluded = ["render"];
|
|
2
|
-
|
|
3
|
-
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; }
|
|
4
|
-
|
|
5
|
-
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; }
|
|
6
|
-
|
|
7
|
-
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; }
|
|
8
|
-
|
|
9
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
10
|
-
|
|
11
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
12
|
-
|
|
13
|
-
import { forwardRef } from 'react';
|
|
14
|
-
import { useGridStore } from "../hooks";
|
|
15
|
-
export default /*#__PURE__*/forwardRef(function CombinationEditor(props, ref) {
|
|
16
|
-
var render = props.render,
|
|
17
|
-
restProps = _objectWithoutProperties(props, _excluded);
|
|
18
|
-
|
|
19
|
-
var context = useGridStore(function (state) {
|
|
20
|
-
return state.context;
|
|
21
|
-
});
|
|
22
|
-
return render(_objectSpread(_objectSpread({}, restProps), {}, {
|
|
23
|
-
context: context
|
|
24
|
-
}), ref);
|
|
25
|
-
});
|