es-grid-template 1.7.23 → 1.7.24

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.
Files changed (167) hide show
  1. package/es/index.d.ts +1 -0
  2. package/es/index.js +3 -1
  3. package/es/table-component/ColumnsChoose.d.ts +10 -0
  4. package/es/table-component/ColumnsChoose.js +557 -0
  5. package/es/table-component/ContextMenu.d.ts +20 -0
  6. package/es/table-component/ContextMenu.js +75 -0
  7. package/es/table-component/InternalTable.d.ts +9 -0
  8. package/es/table-component/InternalTable.js +295 -0
  9. package/es/table-component/TableContainer.d.ts +22 -0
  10. package/es/table-component/TableContainer.js +130 -0
  11. package/es/table-component/TableContainerEdit.d.ts +28 -0
  12. package/es/table-component/TableContainerEdit.js +1211 -0
  13. package/es/table-component/body/EditableCell.d.ts +16 -0
  14. package/es/table-component/body/EditableCell.js +1036 -0
  15. package/es/table-component/body/TableBody.d.ts +19 -0
  16. package/es/table-component/body/TableBody.js +64 -0
  17. package/es/table-component/body/TableBodyCell.d.ts +10 -0
  18. package/es/table-component/body/TableBodyCell.js +139 -0
  19. package/es/table-component/body/TableBodyCellEdit.d.ts +15 -0
  20. package/es/table-component/body/TableBodyCellEdit.js +814 -0
  21. package/es/table-component/body/TableBodyRow.d.ts +21 -0
  22. package/es/table-component/body/TableBodyRow.js +146 -0
  23. package/es/table-component/components/ControlCheckbox.d.ts +13 -0
  24. package/es/table-component/components/ControlCheckbox.js +87 -0
  25. package/es/table-component/components/EditForm/EditForm.d.ts +27 -0
  26. package/es/table-component/components/EditForm/EditForm.js +395 -0
  27. package/es/table-component/components/EditForm/index.d.ts +1 -0
  28. package/es/table-component/components/EditForm/index.js +1 -0
  29. package/es/table-component/components/InputControl/InputControl.d.ts +27 -0
  30. package/es/table-component/components/InputControl/InputControl.js +121 -0
  31. package/es/table-component/components/InputControl/index.d.ts +1 -0
  32. package/es/table-component/components/InputControl/index.js +1 -0
  33. package/es/table-component/components/async-select/index.d.ts +11 -0
  34. package/es/table-component/components/async-select/index.js +41 -0
  35. package/es/table-component/components/async-table-select/index.d.ts +11 -0
  36. package/es/table-component/components/async-table-select/index.js +43 -0
  37. package/es/table-component/components/checkbox-control/index.d.ts +13 -0
  38. package/es/table-component/components/checkbox-control/index.js +40 -0
  39. package/es/table-component/components/checkbox-filter/CheckboxFilter.d.ts +18 -0
  40. package/es/table-component/components/checkbox-filter/CheckboxFilter.js +240 -0
  41. package/es/table-component/components/checkbox-filter/FilterSearch.d.ts +12 -0
  42. package/es/table-component/components/checkbox-filter/FilterSearch.js +36 -0
  43. package/es/table-component/components/command/Command.d.ts +9 -0
  44. package/es/table-component/components/command/Command.js +28 -0
  45. package/es/table-component/components/number/index.d.ts +10 -0
  46. package/es/table-component/components/number/index.js +42 -0
  47. package/es/table-component/components/number-range/index.d.ts +11 -0
  48. package/es/table-component/components/number-range/index.js +66 -0
  49. package/es/table-component/features/operator.d.ts +24 -0
  50. package/es/table-component/features/operator.js +62 -0
  51. package/es/table-component/footer/TableFooter.d.ts +13 -0
  52. package/es/table-component/footer/TableFooter.js +33 -0
  53. package/es/table-component/footer/TableFooterCell.d.ts +10 -0
  54. package/es/table-component/footer/TableFooterCell.js +24 -0
  55. package/es/table-component/footer/TableFooterRow.d.ts +14 -0
  56. package/es/table-component/footer/TableFooterRow.js +71 -0
  57. package/es/table-component/header/TableHead.d.ts +14 -0
  58. package/es/table-component/header/TableHead.js +60 -0
  59. package/es/table-component/header/TableHeadCell.d.ts +14 -0
  60. package/es/table-component/header/TableHeadCell.js +324 -0
  61. package/es/table-component/header/TableHeadRow.d.ts +16 -0
  62. package/es/table-component/header/TableHeadRow.js +86 -0
  63. package/es/table-component/header/renderFilter.d.ts +20 -0
  64. package/es/table-component/header/renderFilter.js +281 -0
  65. package/es/table-component/hook/constant.d.ts +73 -0
  66. package/es/table-component/hook/constant.js +240 -0
  67. package/es/table-component/hook/useColumns.d.ts +11 -0
  68. package/es/table-component/hook/useColumns.js +209 -0
  69. package/es/table-component/hook/useFilterOperator.d.ts +7 -0
  70. package/es/table-component/hook/useFilterOperator.js +33 -0
  71. package/es/table-component/hook/utils.d.ts +121 -0
  72. package/es/table-component/hook/utils.js +1727 -0
  73. package/es/table-component/index.d.ts +5 -0
  74. package/es/table-component/index.js +2 -0
  75. package/es/table-component/style.scss +1083 -0
  76. package/es/table-component/table/Grid.d.ts +23 -0
  77. package/es/table-component/table/Grid.js +310 -0
  78. package/es/table-component/table/GridEdit.d.ts +23 -0
  79. package/es/table-component/table/GridEdit.js +282 -0
  80. package/es/table-component/type.d.ts +482 -0
  81. package/es/table-component/type.js +1 -0
  82. package/es/table-component/useContext.d.ts +119 -0
  83. package/es/table-component/useContext.js +61 -0
  84. package/lib/index.d.ts +1 -0
  85. package/lib/index.js +8 -1
  86. package/lib/table-component/ColumnsChoose.d.ts +10 -0
  87. package/lib/table-component/ColumnsChoose.js +568 -0
  88. package/lib/table-component/ContextMenu.d.ts +20 -0
  89. package/lib/table-component/ContextMenu.js +85 -0
  90. package/lib/table-component/InternalTable.d.ts +9 -0
  91. package/lib/table-component/InternalTable.js +299 -0
  92. package/lib/table-component/TableContainer.d.ts +22 -0
  93. package/lib/table-component/TableContainer.js +137 -0
  94. package/lib/table-component/TableContainerEdit.d.ts +28 -0
  95. package/lib/table-component/TableContainerEdit.js +1220 -0
  96. package/lib/table-component/body/EditableCell.d.ts +16 -0
  97. package/lib/table-component/body/EditableCell.js +1038 -0
  98. package/lib/table-component/body/TableBody.d.ts +19 -0
  99. package/lib/table-component/body/TableBody.js +72 -0
  100. package/lib/table-component/body/TableBodyCell.d.ts +10 -0
  101. package/lib/table-component/body/TableBodyCell.js +148 -0
  102. package/lib/table-component/body/TableBodyCellEdit.d.ts +15 -0
  103. package/lib/table-component/body/TableBodyCellEdit.js +821 -0
  104. package/lib/table-component/body/TableBodyRow.d.ts +21 -0
  105. package/lib/table-component/body/TableBodyRow.js +153 -0
  106. package/lib/table-component/components/ControlCheckbox.d.ts +13 -0
  107. package/lib/table-component/components/ControlCheckbox.js +95 -0
  108. package/lib/table-component/components/EditForm/EditForm.d.ts +27 -0
  109. package/lib/table-component/components/EditForm/EditForm.js +406 -0
  110. package/lib/table-component/components/EditForm/index.d.ts +1 -0
  111. package/lib/table-component/components/EditForm/index.js +16 -0
  112. package/lib/table-component/components/InputControl/InputControl.d.ts +27 -0
  113. package/lib/table-component/components/InputControl/InputControl.js +131 -0
  114. package/lib/table-component/components/InputControl/index.d.ts +1 -0
  115. package/lib/table-component/components/InputControl/index.js +16 -0
  116. package/lib/table-component/components/async-select/index.d.ts +11 -0
  117. package/lib/table-component/components/async-select/index.js +49 -0
  118. package/lib/table-component/components/async-table-select/index.d.ts +11 -0
  119. package/lib/table-component/components/async-table-select/index.js +51 -0
  120. package/lib/table-component/components/checkbox-control/index.d.ts +13 -0
  121. package/lib/table-component/components/checkbox-control/index.js +48 -0
  122. package/lib/table-component/components/checkbox-filter/CheckboxFilter.d.ts +18 -0
  123. package/lib/table-component/components/checkbox-filter/CheckboxFilter.js +249 -0
  124. package/lib/table-component/components/checkbox-filter/FilterSearch.d.ts +12 -0
  125. package/lib/table-component/components/checkbox-filter/FilterSearch.js +44 -0
  126. package/lib/table-component/components/command/Command.d.ts +9 -0
  127. package/lib/table-component/components/command/Command.js +37 -0
  128. package/lib/table-component/components/number/index.d.ts +10 -0
  129. package/lib/table-component/components/number/index.js +50 -0
  130. package/lib/table-component/components/number-range/index.d.ts +11 -0
  131. package/lib/table-component/components/number-range/index.js +74 -0
  132. package/lib/table-component/features/operator.d.ts +24 -0
  133. package/lib/table-component/features/operator.js +67 -0
  134. package/lib/table-component/footer/TableFooter.d.ts +13 -0
  135. package/lib/table-component/footer/TableFooter.js +42 -0
  136. package/lib/table-component/footer/TableFooterCell.d.ts +10 -0
  137. package/lib/table-component/footer/TableFooterCell.js +32 -0
  138. package/lib/table-component/footer/TableFooterRow.d.ts +14 -0
  139. package/lib/table-component/footer/TableFooterRow.js +79 -0
  140. package/lib/table-component/header/TableHead.d.ts +14 -0
  141. package/lib/table-component/header/TableHead.js +69 -0
  142. package/lib/table-component/header/TableHeadCell.d.ts +14 -0
  143. package/lib/table-component/header/TableHeadCell.js +333 -0
  144. package/lib/table-component/header/TableHeadRow.d.ts +16 -0
  145. package/lib/table-component/header/TableHeadRow.js +94 -0
  146. package/lib/table-component/header/renderFilter.d.ts +20 -0
  147. package/lib/table-component/header/renderFilter.js +291 -0
  148. package/lib/table-component/hook/constant.d.ts +73 -0
  149. package/lib/table-component/hook/constant.js +247 -0
  150. package/lib/table-component/hook/useColumns.d.ts +11 -0
  151. package/lib/table-component/hook/useColumns.js +220 -0
  152. package/lib/table-component/hook/useFilterOperator.d.ts +7 -0
  153. package/lib/table-component/hook/useFilterOperator.js +40 -0
  154. package/lib/table-component/hook/utils.d.ts +121 -0
  155. package/lib/table-component/hook/utils.js +1817 -0
  156. package/lib/table-component/index.d.ts +5 -0
  157. package/lib/table-component/index.js +9 -0
  158. package/lib/table-component/style.scss +1083 -0
  159. package/lib/table-component/table/Grid.d.ts +23 -0
  160. package/lib/table-component/table/Grid.js +313 -0
  161. package/lib/table-component/table/GridEdit.d.ts +23 -0
  162. package/lib/table-component/table/GridEdit.js +284 -0
  163. package/lib/table-component/type.d.ts +482 -0
  164. package/lib/table-component/type.js +5 -0
  165. package/lib/table-component/useContext.d.ts +119 -0
  166. package/lib/table-component/useContext.js +67 -0
  167. package/package.json +3 -1
@@ -0,0 +1,27 @@
1
+ import type { HTMLInputTypeAttribute } from "react";
2
+ import React from "react";
3
+ interface IFFormInput {
4
+ id?: any;
5
+ control: any;
6
+ name: string;
7
+ type?: HTMLInputTypeAttribute;
8
+ label: string;
9
+ labelSize?: string;
10
+ required?: boolean;
11
+ errors?: any;
12
+ height?: number | string;
13
+ disabled?: boolean;
14
+ row?: number;
15
+ isLabel?: boolean;
16
+ inLine?: boolean;
17
+ autoFocus?: boolean;
18
+ placeholder?: string;
19
+ classes?: string;
20
+ callback?: any;
21
+ readOnly?: boolean;
22
+ isView?: boolean;
23
+ t?: any;
24
+ onKeyDown?: (event: any) => void;
25
+ }
26
+ declare const InputControl: (props: IFFormInput) => React.JSX.Element;
27
+ export default InputControl;
@@ -0,0 +1,121 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import { Controller } from "react-hook-form";
3
+ import { Input } from "rc-master-ui";
4
+ import { Typography } from "antd";
5
+ import classnames from "classnames";
6
+ import React, { Fragment } from "react";
7
+ // import {isNullOrUndefined} from "../../hooks";
8
+ import { Col, Row } from "rc-master-ui/es/grid";
9
+ import { isNullOrUndefined } from "../../hook/utils";
10
+ // import {isNullOrUndefined} from "../../../hooks"
11
+
12
+ const {
13
+ Text
14
+ } = Typography;
15
+ const InputControl = props => {
16
+ const {
17
+ id,
18
+ control,
19
+ name,
20
+ type,
21
+ label,
22
+ labelSize,
23
+ required,
24
+ errors,
25
+ height,
26
+ disabled,
27
+ row,
28
+ isLabel,
29
+ placeholder,
30
+ autoFocus,
31
+ inLine,
32
+ callback,
33
+ readOnly,
34
+ classes,
35
+ isView,
36
+ t,
37
+ onKeyDown,
38
+ ...rest
39
+ } = props;
40
+ const renderLabel = () => {
41
+ return /*#__PURE__*/React.createElement(Col, {
42
+ span: 6
43
+ }, isLabel === false ? '' : /*#__PURE__*/React.createElement("label", {
44
+ className: "form-label"
45
+ }, t ? t(label ? label : '') : label ? label : '', " ", required ? /*#__PURE__*/React.createElement("span", {
46
+ className: "text-danger"
47
+ }, "*") : '', " "));
48
+ };
49
+
50
+ // const renderText = () => {
51
+ // return (
52
+ // <Fragment>
53
+ // <Controller
54
+ // name={name}
55
+ // control={control}
56
+ // render={({ field: { value } }) => (
57
+ // <span>{value}</span>
58
+ // )}
59
+ // />
60
+ // </Fragment>
61
+ // )
62
+ // }
63
+
64
+ const renderInput = () => {
65
+ return /*#__PURE__*/React.createElement("div", {
66
+ style: {
67
+ display: 'flex',
68
+ flexDirection: 'column'
69
+ }
70
+ }, /*#__PURE__*/React.createElement(Controller, {
71
+ name: name,
72
+ control: control,
73
+ render: ({
74
+ field: {
75
+ value,
76
+ onChange
77
+ }
78
+ }) => /*#__PURE__*/React.createElement(Input, _extends({}, rest, {
79
+ id: id,
80
+ value: !isNullOrUndefined(value) ? value : '',
81
+ onChange: val => {
82
+ onChange(val.target.value);
83
+ if (callback) {
84
+ callback(val);
85
+ }
86
+ },
87
+ style: {
88
+ height: `${height}px`
89
+ },
90
+ autoFocus: autoFocus,
91
+ disabled: disabled,
92
+ placeholder: placeholder,
93
+ type: type ? type : 'text'
94
+ // invalid={errors && true}
95
+ ,
96
+ status: errors && true ? 'error' : undefined
97
+ // rows={row}
98
+ ,
99
+ readOnly: readOnly,
100
+ onKeyDown: onKeyDown
101
+ }))
102
+ }), errors && /*#__PURE__*/React.createElement(Text, {
103
+ type: "danger"
104
+ }, errors?.message));
105
+ };
106
+ return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Row, {
107
+ gutter: [4, 4]
108
+ // className={classnames(' align', {
109
+ // [labelSize ? labelSize : '']: labelSize,
110
+ // [classes ? classes : '']: classes,
111
+ // 'form-row-inline-error': errors
112
+ // }, inLine === false ? 'form-group ' : 'form-row-inline d-flex'
113
+ // )}
114
+ }, renderLabel(), /*#__PURE__*/React.createElement(Col, {
115
+ span: 18,
116
+ className: classnames('', {
117
+ 'hidden-label': isLabel === false
118
+ })
119
+ }, renderInput())));
120
+ };
121
+ export default InputControl;
@@ -0,0 +1 @@
1
+ export * from './InputControl';
@@ -0,0 +1 @@
1
+ export * from "./InputControl";
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import type { BaseOptionType, DefaultOptionType } from "rc-select/lib/Select";
3
+ import type { SelectProps } from "rc-master-ui/es/select";
4
+ import type { LoadOptionsArgs } from '../../type';
5
+ export interface DebounceSelectProps<OptionType extends BaseOptionType = DefaultOptionType> extends SelectProps {
6
+ loadOptions?: (search: string, callback: (newOptions: OptionType[]) => void, args?: LoadOptionsArgs) => void;
7
+ debounceTimeout?: number;
8
+ defaultOptions?: OptionType[];
9
+ rowData?: any;
10
+ }
11
+ export declare function AsyncSelect<OptionType extends BaseOptionType>({ loadOptions, debounceTimeout, defaultOptions, rowData, ...props }: DebounceSelectProps<OptionType>): React.JSX.Element;
@@ -0,0 +1,41 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import React, { useEffect, useMemo, useState } from 'react';
3
+ import debounce from 'lodash/debounce';
4
+ import { Select } from "rc-master-ui";
5
+
6
+ // import type {LoadOptionsArgs} from "../type";
7
+
8
+ export function AsyncSelect({
9
+ loadOptions,
10
+ debounceTimeout = 500,
11
+ defaultOptions,
12
+ rowData,
13
+ ...props
14
+ }) {
15
+ const [options, setOptions] = useState(defaultOptions ?? []);
16
+ const debounceFetcher = useMemo(() => {
17
+ const fetchOptions = value => {
18
+ if (value.trim().length === 0) {
19
+ setOptions(defaultOptions ?? []);
20
+ return;
21
+ }
22
+ if (loadOptions) {
23
+ loadOptions(value, newOptions => {
24
+ setOptions(newOptions);
25
+ }, {
26
+ rowData
27
+ });
28
+ }
29
+ };
30
+ return debounce(fetchOptions, debounceTimeout);
31
+ }, [loadOptions, debounceTimeout]);
32
+ useEffect(() => {
33
+ setOptions(defaultOptions ?? []);
34
+ }, [defaultOptions]);
35
+ return /*#__PURE__*/React.createElement(Select, _extends({}, props, {
36
+ filterOption: loadOptions ? false : props?.filterOption,
37
+ onSearch: debounceFetcher,
38
+ onSelect: () => setOptions(defaultOptions ?? []),
39
+ options: options
40
+ }));
41
+ }
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import type { BaseOptionType, DefaultOptionType } from "rc-select/lib/Select";
3
+ import type { TableSelectProps } from "rc-master-ui/es/table-select";
4
+ import type { LoadOptionsArgs } from '../../type';
5
+ export interface DebounceSelectProps<OptionType extends BaseOptionType = DefaultOptionType> extends TableSelectProps {
6
+ loadOptions?: (search: string, callback: (newOptions: OptionType[]) => void, args?: LoadOptionsArgs) => void;
7
+ debounceTimeout?: number;
8
+ defaultOptions?: OptionType[];
9
+ rowData?: any;
10
+ }
11
+ export declare function AsyncTableSelect<OptionType extends BaseOptionType>({ loadOptions, debounceTimeout, defaultOptions, columns, rowData, ...props }: DebounceSelectProps<OptionType>): React.JSX.Element;
@@ -0,0 +1,43 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import React, { useEffect, useMemo, useState } from 'react';
3
+ import debounce from 'lodash/debounce';
4
+ import { TableSelect } from "rc-master-ui";
5
+
6
+ // import type {LoadOptionsArgs} from "../type";
7
+
8
+ export function AsyncTableSelect({
9
+ loadOptions,
10
+ debounceTimeout = 500,
11
+ defaultOptions,
12
+ columns,
13
+ rowData,
14
+ ...props
15
+ }) {
16
+ const [options, setOptions] = useState(defaultOptions ?? []);
17
+ const debounceFetcher = useMemo(() => {
18
+ const fetchOptions = value => {
19
+ if (value.trim().length === 0) {
20
+ setOptions(defaultOptions ?? []);
21
+ return;
22
+ }
23
+ if (loadOptions) {
24
+ loadOptions(value, newOptions => {
25
+ setOptions(newOptions);
26
+ }, {
27
+ rowData
28
+ });
29
+ }
30
+ };
31
+ return debounce(fetchOptions, debounceTimeout);
32
+ }, [debounceTimeout, loadOptions, defaultOptions, rowData]);
33
+ useEffect(() => {
34
+ setOptions(defaultOptions ?? []);
35
+ }, [defaultOptions]);
36
+ return /*#__PURE__*/React.createElement(TableSelect, _extends({}, props, {
37
+ filterOption: loadOptions ? false : props?.filterOption,
38
+ onSearch: debounceFetcher,
39
+ onSelect: () => setOptions(defaultOptions ?? []),
40
+ options: options,
41
+ columns: columns
42
+ }));
43
+ }
@@ -0,0 +1,13 @@
1
+ import React from "react";
2
+ type OptionType = {
3
+ value: any;
4
+ label: string;
5
+ [key: string]: any;
6
+ };
7
+ type Props<T> = {
8
+ options: T[];
9
+ value: any[];
10
+ onChange?: (value: any[]) => void;
11
+ };
12
+ declare const CheckboxControl: <T extends OptionType>(props: Props<T>) => React.JSX.Element;
13
+ export default CheckboxControl;
@@ -0,0 +1,40 @@
1
+ import React, { useMemo } from "react";
2
+ import { Checkbox } from "rc-master-ui";
3
+ const CheckboxControl = props => {
4
+ const {
5
+ options,
6
+ value,
7
+ onChange
8
+ } = props;
9
+ const selected = useMemo(() => {
10
+ return value ? value : [];
11
+ }, [value]);
12
+ const list = useMemo(() => {
13
+ return options ? options : [];
14
+ }, [options]);
15
+ const onChangeValue = val => {
16
+ const findIndex = selected.findIndex(it => it === val);
17
+ if (findIndex > -1) {
18
+ const newVal = selected.filter(it => it !== val);
19
+ onChange?.(newVal);
20
+ } else {
21
+ const newVal = [...selected, val];
22
+ onChange?.(newVal);
23
+ }
24
+ };
25
+ return /*#__PURE__*/React.createElement("div", {
26
+ className: "d-flex flex-column gap-50",
27
+ style: {}
28
+ }, list.map((it, index) => {
29
+ return /*#__PURE__*/React.createElement("div", {
30
+ key: index,
31
+ className: "d-flex align-items-center"
32
+ }, /*#__PURE__*/React.createElement(Checkbox, {
33
+ checked: selected.includes(it.value),
34
+ type: "checkbox",
35
+ className: "cursor-pointer me-50",
36
+ onChange: () => onChangeValue(it.value)
37
+ }), /*#__PURE__*/React.createElement("span", null, it.label));
38
+ }));
39
+ };
40
+ export default CheckboxControl;
@@ -0,0 +1,18 @@
1
+ import * as React from "react";
2
+ import type { TableLocale } from "rc-master-ui/es/table/interface";
3
+ type Props = {
4
+ options: any[];
5
+ filterSearch?: boolean;
6
+ open?: boolean;
7
+ tablePrefixCls?: string;
8
+ prefixCls?: string;
9
+ dropdownPrefixCls?: string;
10
+ filterMultiple: boolean;
11
+ showFilter?: boolean;
12
+ onSelect?: (value: any) => void;
13
+ selectedKeys: string[];
14
+ locale?: TableLocale;
15
+ filterMode?: 'menu' | 'tree';
16
+ };
17
+ declare const CheckboxFilter: (props: Props) => React.JSX.Element;
18
+ export default CheckboxFilter;
@@ -0,0 +1,240 @@
1
+ import * as React from "react";
2
+ import classNames from "classnames";
3
+ import { Checkbox, Menu, Radio, Empty } from "rc-master-ui";
4
+ import { Tree } from "antd";
5
+ import { flattenKeys } from "rc-master-ui/es/table/hooks/useFilter";
6
+ import FilterSearch from "./FilterSearch";
7
+ function searchValueMatched(searchValue, text) {
8
+ if (typeof text === 'string' || typeof text === 'number') {
9
+ return text?.toString().toLowerCase().includes(searchValue.trim().toLowerCase());
10
+ }
11
+ return false;
12
+ }
13
+ function renderFilterItems({
14
+ filters,
15
+ prefixCls,
16
+ filteredKeys,
17
+ filterMultiple,
18
+ searchValue,
19
+ filterSearch
20
+ }) {
21
+ return filters.map((filter, index) => {
22
+ const key = String(filter.value);
23
+ if (filter.children) {
24
+ return {
25
+ key: key || index,
26
+ label: filter.text,
27
+ popupClassName: `${prefixCls}-dropdown-submenu`,
28
+ children: renderFilterItems({
29
+ filters: filter.children,
30
+ prefixCls,
31
+ filteredKeys,
32
+ filterMultiple,
33
+ searchValue,
34
+ filterSearch
35
+ })
36
+ };
37
+ }
38
+ const Component = filterMultiple ? Checkbox : Radio;
39
+ const item = {
40
+ key: filter.value !== undefined ? key : index,
41
+ label: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Component, {
42
+ checked: filteredKeys.includes(key)
43
+ }), /*#__PURE__*/React.createElement("span", null, filter.text))
44
+ };
45
+ if (searchValue.trim()) {
46
+ if (typeof filterSearch === 'function') {
47
+ return filterSearch(searchValue, filter) ? item : null;
48
+ }
49
+ return searchValueMatched(searchValue, filter.text) ? item : null;
50
+ }
51
+ return item;
52
+ });
53
+ }
54
+ function hasSubMenu(filters) {
55
+ return filters.some(({
56
+ children
57
+ }) => children);
58
+ }
59
+ const CheckboxFilter = props => {
60
+ const {
61
+ // column,
62
+ filterSearch = true,
63
+ tablePrefixCls = 'ui-rc-table',
64
+ prefixCls = 'ui-rc-table-filter',
65
+ dropdownPrefixCls = 'ui-rc-dropdown',
66
+ filterMultiple,
67
+ selectedKeys,
68
+ locale,
69
+ options,
70
+ filterMode = 'tree',
71
+ // open,
72
+ // searchValue,
73
+ showFilter,
74
+ // setSearchValue,
75
+ onSelect
76
+ } = props;
77
+ const [searchValue, setSearchValue] = React.useState('');
78
+ const [openKeys, setOpenKeys] = React.useState([]);
79
+
80
+ // clear search value after close filter dropdown
81
+ // React.useEffect(() => {
82
+ // // if (visible) {
83
+ // setSearchValue('');
84
+ // // }
85
+ // }, [open]);
86
+
87
+ const onOpenChange = keys => {
88
+ setOpenKeys(keys);
89
+ };
90
+ const items = renderFilterItems({
91
+ // filters: column.filters || [],
92
+ filters: options || [],
93
+ filterSearch,
94
+ prefixCls,
95
+ filteredKeys: selectedKeys ?? [],
96
+ filterMultiple,
97
+ searchValue
98
+ });
99
+ const dropdownMenuClass = classNames({
100
+ // [`${dropdownPrefixCls}-menu-without-submenu`]: !hasSubMenu(column.filters || []),
101
+ [`${dropdownPrefixCls}-menu-without-submenu`]: !hasSubMenu(options || [])
102
+ });
103
+ const empty = /*#__PURE__*/React.createElement(Empty, {
104
+ image: Empty.PRESENTED_IMAGE_SIMPLE,
105
+ description: locale?.filterEmptyText,
106
+ imageStyle: {
107
+ height: 24
108
+ },
109
+ style: {
110
+ margin: 0,
111
+ padding: '16px 0'
112
+ }
113
+ });
114
+ const isEmpty = items.every(item => item === null);
115
+ const onSearch = e => {
116
+ const {
117
+ value
118
+ } = e.target;
119
+ setSearchValue(value);
120
+ };
121
+
122
+ // if ((column.filters || []).length === 0) {
123
+ // return empty;
124
+ // }
125
+
126
+ const getTreeData = ({
127
+ filters
128
+ }) => (filters || []).map((filter, index) => {
129
+ const key = String(filter.value);
130
+ const item = {
131
+ title: filter.text,
132
+ key: filter.value !== undefined ? key : String(index)
133
+ };
134
+ if (filter.children) {
135
+ item.children = getTreeData({
136
+ filters: filter.children
137
+ });
138
+ }
139
+ return item;
140
+ });
141
+ const getFilterData = node => ({
142
+ ...node,
143
+ text: node.title,
144
+ value: node.key,
145
+ children: node.children?.map(item => getFilterData(item)) || []
146
+ });
147
+ const onCheckAll = e => {
148
+ if (e.target.checked) {
149
+ const allFilterKeys = flattenKeys(options).map(key => String(key));
150
+
151
+ // setFilteredKeysSync(allFilterKeys);
152
+ onSelect?.(allFilterKeys);
153
+ } else {
154
+ onSelect?.([]);
155
+ // setFilteredKeysSync([]);
156
+ }
157
+ };
158
+ const onCheck = (keys, {
159
+ node,
160
+ checked
161
+ }) => {
162
+ if (!filterMultiple) {
163
+ // onSelectKeys({ selectedKeys: checked && node.key ? [node.key] : [] });
164
+ onSelect?.(checked && node.key ? [node.key] : []);
165
+ } else {
166
+ // onSelectKeys({ selectedKeys: keys });
167
+ onSelect?.(keys);
168
+ }
169
+ };
170
+ if (filterMode === 'tree') {
171
+ return /*#__PURE__*/React.createElement(React.Fragment, null, showFilter && /*#__PURE__*/React.createElement(FilterSearch, {
172
+ filterSearch: filterSearch,
173
+ value: searchValue,
174
+ onChange: onSearch,
175
+ tablePrefixCls: tablePrefixCls,
176
+ locale: locale
177
+ }), /*#__PURE__*/React.createElement("div", {
178
+ className: `${tablePrefixCls}-filter-dropdown-tree`
179
+ }, filterMultiple && options.length > 0 ? /*#__PURE__*/React.createElement(Checkbox
180
+ // checked={selectedKeys.length === flattenKeys(column.filters).length}
181
+ , {
182
+ checked: selectedKeys.length === flattenKeys(options).length
183
+ // indeterminate={
184
+ // selectedKeys.length > 0 &&
185
+ // selectedKeys.length < flattenKeys(column.filters).length
186
+ // }
187
+ ,
188
+
189
+ indeterminate: selectedKeys.length > 0 && selectedKeys.length < flattenKeys(options).length,
190
+ className: `${tablePrefixCls}-filter-dropdown-checkall`,
191
+ onChange: onCheckAll
192
+ }, locale?.filterCheckall) : /*#__PURE__*/React.createElement(Empty, null), /*#__PURE__*/React.createElement(Tree, {
193
+ checkable: true,
194
+ selectable: false,
195
+ blockNode: true,
196
+ multiple: filterMultiple,
197
+ checkStrictly: !filterMultiple,
198
+ className: `${dropdownPrefixCls}-menu`,
199
+ onCheck: onCheck,
200
+ checkedKeys: selectedKeys,
201
+ selectedKeys: selectedKeys,
202
+ showIcon: false
203
+ // treeData={getTreeData({ filters: column.filters })}
204
+ ,
205
+ treeData: getTreeData({
206
+ filters: options
207
+ }),
208
+ autoExpandParent: true,
209
+ defaultExpandAll: true,
210
+ filterTreeNode: searchValue.trim() ? node => {
211
+ if (typeof filterSearch === 'function') {
212
+ // @ts-ignore
213
+ return filterSearch(searchValue, getFilterData(node));
214
+ }
215
+ return searchValueMatched(searchValue, node.title);
216
+ } : undefined
217
+ })));
218
+ }
219
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FilterSearch, {
220
+ filterSearch: filterSearch,
221
+ value: searchValue,
222
+ onChange: onSearch,
223
+ tablePrefixCls: tablePrefixCls,
224
+ locale: locale
225
+ }), isEmpty ? empty : /*#__PURE__*/React.createElement(Menu, {
226
+ selectable: true,
227
+ multiple: filterMultiple,
228
+ prefixCls: `${dropdownPrefixCls}-menu`,
229
+ className: dropdownMenuClass,
230
+ onSelect: onSelect,
231
+ onDeselect: onSelect,
232
+ selectedKeys: selectedKeys
233
+ // getPopupContainer={getPopupContainer}
234
+ ,
235
+ openKeys: openKeys,
236
+ onOpenChange: onOpenChange,
237
+ items: items
238
+ }));
239
+ };
240
+ export default CheckboxFilter;
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+ import type { FilterSearchType, TableLocale } from "antd/es/table/interface";
3
+ import type { AnyObject } from '../../type';
4
+ interface FilterSearchProps<RecordType = AnyObject> {
5
+ value: string;
6
+ onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
7
+ filterSearch: FilterSearchType<RecordType>;
8
+ tablePrefixCls: string;
9
+ locale?: TableLocale;
10
+ }
11
+ declare const FilterSearch: <RecordType extends AnyObject = AnyObject>(props: FilterSearchProps<RecordType>) => React.JSX.Element;
12
+ export default FilterSearch;
@@ -0,0 +1,36 @@
1
+ import * as React from 'react';
2
+ import SearchOutlined from '@ant-design/icons/SearchOutlined';
3
+ import { Input } from 'rc-master-ui';
4
+
5
+ // import type {AnyObject} from "./type"
6
+
7
+ const FilterSearch = props => {
8
+ const {
9
+ value,
10
+ filterSearch,
11
+ tablePrefixCls,
12
+ locale,
13
+ onChange
14
+ } = props;
15
+ if (!filterSearch) {
16
+ return null;
17
+ }
18
+ return /*#__PURE__*/React.createElement("div", {
19
+ className: `${tablePrefixCls}-filter-dropdown-search`,
20
+ style: {
21
+ paddingLeft: 0,
22
+ paddingRight: 0
23
+ }
24
+ }, /*#__PURE__*/React.createElement(Input, {
25
+ suffix: /*#__PURE__*/React.createElement(SearchOutlined, null),
26
+ placeholder: locale?.filterSearchPlaceholder,
27
+ onChange: onChange,
28
+ value: value,
29
+ autoFocus: true
30
+ // for skip min-width of input
31
+ ,
32
+ htmlSize: 1,
33
+ className: `${tablePrefixCls}-filter-dropdown-search-input`
34
+ }));
35
+ };
36
+ export default FilterSearch;
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ import type { CommandItem } from "../../type";
3
+ type Props<T> = {
4
+ record: T;
5
+ item: CommandItem;
6
+ onClick: (e: any) => void;
7
+ };
8
+ declare const Command: <T extends object>(props: Props<T>) => React.JSX.Element;
9
+ export default Command;
@@ -0,0 +1,28 @@
1
+ import React, { Fragment } from "react";
2
+ import classnames from "classnames";
3
+ const Command = props => {
4
+ const {
5
+ item,
6
+ onClick,
7
+ record
8
+ } = props;
9
+ return /*#__PURE__*/React.createElement(Fragment, null, item.template ? /*#__PURE__*/React.createElement("div", {
10
+ id: item.id,
11
+ onClick: onClick
12
+ }, typeof item.template === 'function' ? item.template(record) : item.template) : /*#__PURE__*/React.createElement("div", {
13
+ tabIndex: -1,
14
+ style: {
15
+ padding: '3px',
16
+ maxWidth: 45,
17
+ height: '100%',
18
+ display: 'flex',
19
+ cursor: 'pointer'
20
+ },
21
+ className: classnames('command-item', {
22
+ 'btn-icon': item.title === ''
23
+ }),
24
+ color: item.color ? item.color : 'primary',
25
+ onClick: onClick
26
+ }, typeof item.icon === 'function' ? item.icon() : item.icon));
27
+ };
28
+ export default Command;
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import type { IFormat } from "../../type";
3
+ type Props = {
4
+ t?: any;
5
+ format?: IFormat;
6
+ value: number | string | undefined;
7
+ onChange?: (values: any[]) => void;
8
+ };
9
+ declare const NumberInput: (props: Props) => React.JSX.Element;
10
+ export default NumberInput;