@servicetitan/table 24.3.2 → 25.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/demo/overview/table.d.ts +3 -4
- package/dist/demo/overview/table.d.ts.map +1 -1
- package/dist/demo/overview/table.js +17 -5
- package/dist/demo/overview/table.js.map +1 -1
- package/dist/editable-cell/index.d.ts +0 -2
- package/dist/editable-cell/index.d.ts.map +1 -1
- package/dist/editable-cell/index.js +0 -2
- package/dist/editable-cell/index.js.map +1 -1
- package/package.json +7 -7
- package/src/demo/overview/table.tsx +46 -16
- package/src/editable-cell/index.ts +0 -2
- package/dist/editable-cell/date-editable-cell.d.ts +0 -3
- package/dist/editable-cell/date-editable-cell.d.ts.map +0 -1
- package/dist/editable-cell/date-editable-cell.js +0 -14
- package/dist/editable-cell/date-editable-cell.js.map +0 -1
- package/dist/editable-cell/numeric-editable-cell.d.ts +0 -3
- package/dist/editable-cell/numeric-editable-cell.d.ts.map +0 -1
- package/dist/editable-cell/numeric-editable-cell.js +0 -15
- package/dist/editable-cell/numeric-editable-cell.js.map +0 -1
- package/src/editable-cell/date-editable-cell.tsx +0 -29
- package/src/editable-cell/numeric-editable-cell.tsx +0 -30
@@ -1,6 +1,5 @@
|
|
1
1
|
import { FC } from 'react';
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
export declare const TableExample: FC<TableExampleProps>;
|
2
|
+
import { TableCellProps } from '../..';
|
3
|
+
export declare const DateEditableCell: (props: TableCellProps<any, any, never, never>) => JSX.Element;
|
4
|
+
export declare const TableExample: FC;
|
6
5
|
//# sourceMappingURL=table.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../src/demo/overview/table.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAmC,EAAE,EAAgB,MAAM,OAAO,CAAC;
|
1
|
+
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../src/demo/overview/table.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAmC,EAAE,EAAgB,MAAM,OAAO,CAAC;AAQ1E,OAAO,EAIH,cAAc,EAWjB,MAAM,OAAO,CAAC;AA6Cf,eAAO,MAAM,gBAAgB,gEAE3B,CAAC;AA0BH,eAAO,MAAM,YAAY,EAAE,EA2H1B,CAAC"}
|
@@ -2,12 +2,12 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo, cloneElement, Fragment } from 'react';
|
3
3
|
import { provide, useDependencies } from '@servicetitan/react-ioc';
|
4
4
|
import { observer } from 'mobx-react';
|
5
|
-
import { Stack, ButtonGroup, Button, Tag } from '@servicetitan/design-system';
|
6
|
-
import { Table, TableColumn, TableCell, TextEditableCell,
|
5
|
+
import { Stack, ButtonGroup, Button, Tag, DatePicker } from '@servicetitan/design-system';
|
6
|
+
import { Table, TableColumn, TableCell, TextEditableCell, BooleanEditableCell, getSelectEditableCell, DateRangeColumnMenuFilter, StandardColumnMenuFilter, standardFilterWithMultiselect, multiSelectColumnMenuFilter, CurrencyRangeColumnMenuFilter, getEditableCell, } from '../..';
|
7
7
|
import { Export } from '../../export';
|
8
8
|
import { TableStore } from './table.store';
|
9
9
|
import { ActionsCell } from './actions-cell';
|
10
|
-
import { enumToOptions, getEnumKeys } from '@servicetitan/form';
|
10
|
+
import { NumberInput, enumToOptions, getEnumKeys } from '@servicetitan/form';
|
11
11
|
import { UserRole, Supplier } from './product';
|
12
12
|
const UserRoleColumnMenuFilter = multiSelectColumnMenuFilter(getEnumKeys(UserRole), userRole => (_jsx(Tag, Object.assign({ compact: true, color: UserRole[userRole] === UserRole.Owner ? 'success' : 'default' }, { children: userRole }))));
|
13
13
|
const AvailableForEditableCell = getSelectEditableCell({
|
@@ -24,9 +24,21 @@ const SupplierCell = props => {
|
|
24
24
|
}
|
25
25
|
return _jsx("td", { children: Supplier[dataItem[field]] });
|
26
26
|
};
|
27
|
+
// Implementation of a date editable cell utilizing getEditableCell
|
28
|
+
const DateEditor = observer(({ fieldState: { value, onChange, hasError }, className }) => {
|
29
|
+
return (_jsx("td", Object.assign({ className: className }, { children: _jsx(DatePicker, { value: value, onChange: onChange, error: hasError }) })));
|
30
|
+
});
|
31
|
+
export const DateEditableCell = getEditableCell({
|
32
|
+
editor: DateEditor,
|
33
|
+
});
|
34
|
+
// Implementation of a numeric editable cell utilizing getEditableCell
|
35
|
+
const NumberCellEditor = observer(({ fieldState: { value, hasError, onChange } }) => (_jsx("td", { children: _jsx(NumberInput, { onChange: onChange, type: "number", error: hasError, value: value, emptyValue: 0, min: 0, max: 1000, useEmptyThousandsSeparator: true, fluid: true, decimalPlaces: 2, useKeyboardNavigation: true }) })));
|
36
|
+
const NumericEditableCell = getEditableCell({
|
37
|
+
editor: getEditableCell({ editor: NumberCellEditor }),
|
38
|
+
});
|
27
39
|
export const TableExample = provide({
|
28
40
|
singletons: [TableStore],
|
29
|
-
})(observer((
|
41
|
+
})(observer(() => {
|
30
42
|
const [{ tableState, inEdit, editAll, cancelAll, saveAll }] = useDependencies(TableStore);
|
31
43
|
const madeInColumnMenu = useMemo(() => standardFilterWithMultiselect({ tableState }), [tableState]);
|
32
44
|
const cellRender = (td, { dataItem, field }) => {
|
@@ -39,6 +51,6 @@ export const TableExample = provide({
|
|
39
51
|
},
|
40
52
|
});
|
41
53
|
};
|
42
|
-
return (_jsxs(Fragment, { children: [_jsxs(Stack, Object.assign({ justifyContent: "space-between", alignContent: "center", className: "m-b-2" }, { children: [_jsx(Export, { totalCount: tableState.totalCount, exportPdf: tableState.exportPdf, exportExcel: tableState.exportExcel }), inEdit ? (_jsxs(ButtonGroup, { children: [_jsx(Button, Object.assign({ small: true, onClick: cancelAll, className: "m-r-2" }, { children: "Cancel All" })), _jsx(Button, Object.assign({ small: true, primary: true, onClick: saveAll }, { children: "Save All" }))] })) : (_jsx(Button, Object.assign({ small: true, primary: true, onClick: editAll }, { children: "Edit All" })))] })), _jsxs(Table, Object.assign({ tableState: tableState, striped: false, selectable: true, groupable: true, sortable: true, exportable: true, exportFileName: "Table.Export.Test...File.Name.01.01.2020..~!@#$%^(*_+';", cellRender: cellRender }, { children: [_jsx(TableColumn, { field: "ProductID", title: "ID", editable: false, width: "100px" }), _jsx(TableColumn, { field: "ProductName", title: "Product Name", cell: TextEditableCell, columnMenu: StandardColumnMenuFilter, width: "240px" }), _jsx(TableColumn, { field: "Supplier", title: "Supplier", cell: SupplierCell, columnMenu: StandardColumnMenuFilter, width: "150px" }), _jsx(TableColumn, { field: "MadeIn", title: "Made In", cell: TextEditableCell, columnMenu: madeInColumnMenu, width: "175px" }), _jsx(TableColumn, { field: "UnitsOnOrder", title: "First Ordered On", cell: DateEditableCell, columnMenu: DateRangeColumnMenuFilter, format: "{0:
|
54
|
+
return (_jsxs(Fragment, { children: [_jsxs(Stack, Object.assign({ justifyContent: "space-between", alignContent: "center", className: "m-b-2" }, { children: [_jsx(Export, { totalCount: tableState.totalCount, exportPdf: tableState.exportPdf, exportExcel: tableState.exportExcel }), inEdit ? (_jsxs(ButtonGroup, { children: [_jsx(Button, Object.assign({ small: true, onClick: cancelAll, className: "m-r-2" }, { children: "Cancel All" })), _jsx(Button, Object.assign({ small: true, primary: true, onClick: saveAll }, { children: "Save All" }))] })) : (_jsx(Button, Object.assign({ small: true, primary: true, onClick: editAll }, { children: "Edit All" })))] })), _jsxs(Table, Object.assign({ tableState: tableState, striped: false, selectable: true, groupable: true, sortable: true, exportable: true, exportFileName: "Table.Export.Test...File.Name.01.01.2020..~!@#$%^(*_+';", cellRender: cellRender }, { children: [_jsx(TableColumn, { field: "ProductID", title: "ID", editable: false, width: "100px" }), _jsx(TableColumn, { field: "ProductName", title: "Product Name", cell: TextEditableCell, columnMenu: StandardColumnMenuFilter, width: "240px" }), _jsx(TableColumn, { field: "Supplier", title: "Supplier", cell: SupplierCell, columnMenu: StandardColumnMenuFilter, width: "150px" }), _jsx(TableColumn, { field: "MadeIn", title: "Made In", cell: TextEditableCell, columnMenu: madeInColumnMenu, width: "175px" }), _jsx(TableColumn, { field: "UnitsOnOrder", title: "First Ordered On", cell: DateEditableCell, columnMenu: DateRangeColumnMenuFilter, format: "{0:MM/dd/yyyy}", width: "240px" }), _jsx(TableColumn, { field: "UnitPrice", title: "Unit Price", cell: NumericEditableCell, columnMenu: CurrencyRangeColumnMenuFilter, format: "{0:c}", width: "125px" }), _jsx(TableColumn, { field: "Discontinued", title: "Discontinued", cell: BooleanEditableCell, sortable: false, width: "125px" }), _jsx(TableColumn, { field: "AvailableFor", title: "Available For", cell: AvailableForEditableCell, columnMenu: UserRoleColumnMenuFilter, width: "240px" }), _jsx(TableColumn, { cell: ActionsCell, sortable: false, width: "125px" })] }))] }));
|
43
55
|
}));
|
44
56
|
//# sourceMappingURL=table.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"table.js","sourceRoot":"","sources":["../../../src/demo/overview/table.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAoB,MAAM,OAAO,CAAC;AAE1E,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAEnE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,6BAA6B,CAAC;
|
1
|
+
{"version":3,"file":"table.js","sourceRoot":"","sources":["../../../src/demo/overview/table.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAoB,MAAM,OAAO,CAAC;AAE1E,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAEnE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAE1F,OAAO,EACH,KAAK,EACL,WAAW,EACX,SAAS,EAET,gBAAgB,EA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,EAAC,OAAO,GACf,EAEF,KAAC,WAAW,IAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAC,OAAO,GAAG,KAC7D,IACD,CACd,CAAC;AACN,CAAC,CAAC,CACL,CAAC"}
|
@@ -1,8 +1,6 @@
|
|
1
1
|
export * from './get-action-cell';
|
2
2
|
export * from './get-editable-cell';
|
3
3
|
export * from './text-editable-cell';
|
4
|
-
export * from './numeric-editable-cell';
|
5
4
|
export * from './boolean-editable-cell';
|
6
|
-
export * from './date-editable-cell';
|
7
5
|
export * from './get-select-editable-cell';
|
8
6
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/editable-cell/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/editable-cell/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC"}
|
@@ -1,8 +1,6 @@
|
|
1
1
|
export * from './get-action-cell';
|
2
2
|
export * from './get-editable-cell';
|
3
3
|
export * from './text-editable-cell';
|
4
|
-
export * from './numeric-editable-cell';
|
5
4
|
export * from './boolean-editable-cell';
|
6
|
-
export * from './date-editable-cell';
|
7
5
|
export * from './get-select-editable-cell';
|
8
6
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/editable-cell/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/editable-cell/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@servicetitan/table",
|
3
|
-
"version": "
|
3
|
+
"version": "25.0.1",
|
4
4
|
"description": "",
|
5
5
|
"homepage": "https://docs.st.dev/docs/frontend/table",
|
6
6
|
"repository": {
|
@@ -32,14 +32,14 @@
|
|
32
32
|
"@progress/kendo-react-pdf": "^5.5.0",
|
33
33
|
"@progress/kendo-react-popup": "^5.5.0",
|
34
34
|
"@progress/kendo-react-treeview": "^5.5.0",
|
35
|
-
"@servicetitan/react-hooks": "^
|
35
|
+
"@servicetitan/react-hooks": "^3.0.0",
|
36
36
|
"classnames": "~2.3.1",
|
37
37
|
"memoize-one": "~6.0.0"
|
38
38
|
},
|
39
39
|
"devDependencies": {
|
40
|
-
"@servicetitan/data-query": "^
|
40
|
+
"@servicetitan/data-query": "^25.0.1",
|
41
41
|
"@servicetitan/design-system": ">=12.4.1",
|
42
|
-
"@servicetitan/form": "^
|
42
|
+
"@servicetitan/form": "^25.0.1",
|
43
43
|
"@servicetitan/react-ioc": "^21.6.0",
|
44
44
|
"@servicetitan/suppress-warnings": "^21.6.0",
|
45
45
|
"@types/accounting": "~0.4.2",
|
@@ -53,9 +53,9 @@
|
|
53
53
|
"react": "~17.0.2"
|
54
54
|
},
|
55
55
|
"peerDependencies": {
|
56
|
-
"@servicetitan/data-query": "^
|
56
|
+
"@servicetitan/data-query": "^25.0.1",
|
57
57
|
"@servicetitan/design-system": ">=12.4.1",
|
58
|
-
"@servicetitan/form": "^
|
58
|
+
"@servicetitan/form": "^25.0.1",
|
59
59
|
"@servicetitan/react-ioc": ">21.0.0",
|
60
60
|
"@servicetitan/suppress-warnings": ">21.0.0",
|
61
61
|
"accounting": "~0.4.1",
|
@@ -72,5 +72,5 @@
|
|
72
72
|
"cli": {
|
73
73
|
"webpack": false
|
74
74
|
},
|
75
|
-
"gitHead": "
|
75
|
+
"gitHead": "81ba2d8ecce891162d8d4de743c6b3fff9cf1982"
|
76
76
|
}
|
@@ -4,7 +4,7 @@ import { provide, useDependencies } from '@servicetitan/react-ioc';
|
|
4
4
|
|
5
5
|
import { observer } from 'mobx-react';
|
6
6
|
|
7
|
-
import { Stack, ButtonGroup, Button, Tag } from '@servicetitan/design-system';
|
7
|
+
import { Stack, ButtonGroup, Button, Tag, DatePicker } from '@servicetitan/design-system';
|
8
8
|
|
9
9
|
import {
|
10
10
|
Table,
|
@@ -12,15 +12,15 @@ import {
|
|
12
12
|
TableCell,
|
13
13
|
TableCellProps,
|
14
14
|
TextEditableCell,
|
15
|
-
NumericEditableCell,
|
16
15
|
BooleanEditableCell,
|
17
|
-
DateEditableCell,
|
18
16
|
getSelectEditableCell,
|
19
|
-
CurrencyRangeColumnMenuFilter,
|
20
17
|
DateRangeColumnMenuFilter,
|
21
18
|
StandardColumnMenuFilter,
|
22
19
|
standardFilterWithMultiselect,
|
23
20
|
multiSelectColumnMenuFilter,
|
21
|
+
CurrencyRangeColumnMenuFilter,
|
22
|
+
getEditableCell,
|
23
|
+
EditorProps,
|
24
24
|
} from '../..';
|
25
25
|
import { Export } from '../../export';
|
26
26
|
|
@@ -28,7 +28,7 @@ import { TableStore } from './table.store';
|
|
28
28
|
|
29
29
|
import { ActionsCell } from './actions-cell';
|
30
30
|
|
31
|
-
import { enumToOptions, getEnumKeys } from '@servicetitan/form';
|
31
|
+
import { NumberInput, enumToOptions, getEnumKeys } from '@servicetitan/form';
|
32
32
|
import { Product, UserRole, Supplier } from './product';
|
33
33
|
|
34
34
|
const UserRoleColumnMenuFilter = multiSelectColumnMenuFilter(getEnumKeys(UserRole), userRole => (
|
@@ -56,14 +56,48 @@ const SupplierCell: FC<TableCellProps> = props => {
|
|
56
56
|
return <td>{Supplier[dataItem[field!]]}</td>;
|
57
57
|
};
|
58
58
|
|
59
|
-
|
60
|
-
|
61
|
-
}
|
59
|
+
// Implementation of a date editable cell utilizing getEditableCell
|
60
|
+
const DateEditor = observer<FC<EditorProps<Date | string | undefined>>>(
|
61
|
+
({ fieldState: { value, onChange, hasError }, className }) => {
|
62
|
+
return (
|
63
|
+
<td className={className}>
|
64
|
+
<DatePicker value={value} onChange={onChange} error={hasError} />
|
65
|
+
</td>
|
66
|
+
);
|
67
|
+
}
|
68
|
+
);
|
69
|
+
export const DateEditableCell = getEditableCell({
|
70
|
+
editor: DateEditor,
|
71
|
+
});
|
62
72
|
|
63
|
-
|
73
|
+
// Implementation of a numeric editable cell utilizing getEditableCell
|
74
|
+
const NumberCellEditor: FC<EditorProps<number>> = observer(
|
75
|
+
({ fieldState: { value, hasError, onChange } }) => (
|
76
|
+
<td>
|
77
|
+
<NumberInput
|
78
|
+
onChange={onChange}
|
79
|
+
type="number"
|
80
|
+
error={hasError}
|
81
|
+
value={value}
|
82
|
+
emptyValue={0}
|
83
|
+
min={0}
|
84
|
+
max={1000}
|
85
|
+
useEmptyThousandsSeparator
|
86
|
+
fluid
|
87
|
+
decimalPlaces={2}
|
88
|
+
useKeyboardNavigation
|
89
|
+
/>
|
90
|
+
</td>
|
91
|
+
)
|
92
|
+
);
|
93
|
+
const NumericEditableCell = getEditableCell({
|
94
|
+
editor: getEditableCell({ editor: NumberCellEditor }),
|
95
|
+
});
|
96
|
+
|
97
|
+
export const TableExample: FC = provide({
|
64
98
|
singletons: [TableStore],
|
65
99
|
})(
|
66
|
-
observer((
|
100
|
+
observer(() => {
|
67
101
|
const [{ tableState, inEdit, editAll, cancelAll, saveAll }] = useDependencies(TableStore);
|
68
102
|
|
69
103
|
const madeInColumnMenu = useMemo(
|
@@ -149,7 +183,7 @@ export const TableExample: FC<TableExampleProps> = provide({
|
|
149
183
|
title="First Ordered On"
|
150
184
|
cell={DateEditableCell}
|
151
185
|
columnMenu={DateRangeColumnMenuFilter}
|
152
|
-
format="{0:
|
186
|
+
format="{0:MM/dd/yyyy}"
|
153
187
|
width="240px"
|
154
188
|
/>
|
155
189
|
|
@@ -178,11 +212,7 @@ export const TableExample: FC<TableExampleProps> = provide({
|
|
178
212
|
width="240px"
|
179
213
|
/>
|
180
214
|
|
181
|
-
<TableColumn
|
182
|
-
cell={ActionsCell}
|
183
|
-
sortable={false}
|
184
|
-
{...(props.fixedWidthColumns ? { width: '125px' } : {})}
|
185
|
-
/>
|
215
|
+
<TableColumn cell={ActionsCell} sortable={false} width="125px" />
|
186
216
|
</Table>
|
187
217
|
</Fragment>
|
188
218
|
);
|
@@ -1,7 +1,5 @@
|
|
1
1
|
export * from './get-action-cell';
|
2
2
|
export * from './get-editable-cell';
|
3
3
|
export * from './text-editable-cell';
|
4
|
-
export * from './numeric-editable-cell';
|
5
4
|
export * from './boolean-editable-cell';
|
6
|
-
export * from './date-editable-cell';
|
7
5
|
export * from './get-select-editable-cell';
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"date-editable-cell.d.ts","sourceRoot":"","sources":["../../src/editable-cell/date-editable-cell.tsx"],"names":[],"mappings":";AA0BA,eAAO,MAAM,gBAAgB,6EAE3B,CAAC"}
|
@@ -1,14 +0,0 @@
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
-
import { observer } from 'mobx-react';
|
3
|
-
import { DatePicker } from '@progress/kendo-react-dateinputs';
|
4
|
-
import { getEditableCell } from './get-editable-cell';
|
5
|
-
const Editor = observer(({ fieldState: { value, onChange, hasError, error }, className }) => {
|
6
|
-
const handleChange = (event) => {
|
7
|
-
onChange(event.value);
|
8
|
-
};
|
9
|
-
return (_jsx("td", Object.assign({ className: className }, { children: _jsx(DatePicker, { value: value, onChange: handleChange, valid: !hasError, validationMessage: error }) })));
|
10
|
-
});
|
11
|
-
export const DateEditableCell = getEditableCell({
|
12
|
-
editor: Editor,
|
13
|
-
});
|
14
|
-
//# sourceMappingURL=date-editable-cell.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"date-editable-cell.js","sourceRoot":"","sources":["../../src/editable-cell/date-editable-cell.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,UAAU,EAAyB,MAAM,kCAAkC,CAAC;AAErF,OAAO,EAAE,eAAe,EAAe,MAAM,qBAAqB,CAAC;AAEnE,MAAM,MAAM,GAAG,QAAQ,CACnB,CAAC,EAAE,UAAU,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE;IAChE,MAAM,YAAY,GAAG,CAAC,KAA4B,EAAE,EAAE;QAClD,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC,CAAC;IAEF,OAAO,CACH,2BAAI,SAAS,EAAE,SAAS,gBACpB,KAAC,UAAU,IACP,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,YAAY,EACtB,KAAK,EAAE,CAAC,QAAQ,EAChB,iBAAiB,EAAE,KAAK,GAC1B,IACD,CACR,CAAC;AACN,CAAC,CACJ,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,eAAe,CAAC;IAC5C,MAAM,EAAE,MAAM;CACjB,CAAC,CAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"numeric-editable-cell.d.ts","sourceRoot":"","sources":["../../src/editable-cell/numeric-editable-cell.tsx"],"names":[],"mappings":";AA2BA,eAAO,MAAM,mBAAmB,6EAE9B,CAAC"}
|
@@ -1,15 +0,0 @@
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
-
import { observer } from 'mobx-react';
|
3
|
-
import { NumericTextBox } from '@progress/kendo-react-inputs';
|
4
|
-
import { getEditableCell } from './get-editable-cell';
|
5
|
-
const Editor = observer(({ fieldState: { value, onChange, hasError, error }, className }) => {
|
6
|
-
const handleChange = (event) => {
|
7
|
-
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
8
|
-
onChange(event.value || undefined);
|
9
|
-
};
|
10
|
-
return (_jsx("td", Object.assign({ className: className }, { children: _jsx(NumericTextBox, { value: value, onChange: handleChange, valid: !hasError, validationMessage: error }) })));
|
11
|
-
});
|
12
|
-
export const NumericEditableCell = getEditableCell({
|
13
|
-
editor: Editor,
|
14
|
-
});
|
15
|
-
//# sourceMappingURL=numeric-editable-cell.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"numeric-editable-cell.js","sourceRoot":"","sources":["../../src/editable-cell/numeric-editable-cell.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,cAAc,EAA6B,MAAM,8BAA8B,CAAC;AAEzF,OAAO,EAAE,eAAe,EAAe,MAAM,qBAAqB,CAAC;AAEnE,MAAM,MAAM,GAAG,QAAQ,CACnB,CAAC,EAAE,UAAU,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE;IAChE,MAAM,YAAY,GAAG,CAAC,KAAgC,EAAE,EAAE;QACtD,wEAAwE;QACxE,QAAQ,CAAC,KAAK,CAAC,KAAK,IAAI,SAAS,CAAC,CAAC;IACvC,CAAC,CAAC;IAEF,OAAO,CACH,2BAAI,SAAS,EAAE,SAAS,gBACpB,KAAC,cAAc,IACX,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,YAAY,EACtB,KAAK,EAAE,CAAC,QAAQ,EAChB,iBAAiB,EAAE,KAAK,GAC1B,IACD,CACR,CAAC;AACN,CAAC,CACJ,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,eAAe,CAAC;IAC/C,MAAM,EAAE,MAAM;CACjB,CAAC,CAAC"}
|
@@ -1,29 +0,0 @@
|
|
1
|
-
import { FC } from 'react';
|
2
|
-
import { observer } from 'mobx-react';
|
3
|
-
|
4
|
-
import { DatePicker, DatePickerChangeEvent } from '@progress/kendo-react-dateinputs';
|
5
|
-
|
6
|
-
import { getEditableCell, EditorProps } from './get-editable-cell';
|
7
|
-
|
8
|
-
const Editor = observer<FC<EditorProps<Date | null>>>(
|
9
|
-
({ fieldState: { value, onChange, hasError, error }, className }) => {
|
10
|
-
const handleChange = (event: DatePickerChangeEvent) => {
|
11
|
-
onChange(event.value);
|
12
|
-
};
|
13
|
-
|
14
|
-
return (
|
15
|
-
<td className={className}>
|
16
|
-
<DatePicker
|
17
|
-
value={value}
|
18
|
-
onChange={handleChange}
|
19
|
-
valid={!hasError}
|
20
|
-
validationMessage={error}
|
21
|
-
/>
|
22
|
-
</td>
|
23
|
-
);
|
24
|
-
}
|
25
|
-
);
|
26
|
-
|
27
|
-
export const DateEditableCell = getEditableCell({
|
28
|
-
editor: Editor,
|
29
|
-
});
|
@@ -1,30 +0,0 @@
|
|
1
|
-
import { FC } from 'react';
|
2
|
-
import { observer } from 'mobx-react';
|
3
|
-
|
4
|
-
import { NumericTextBox, NumericTextBoxChangeEvent } from '@progress/kendo-react-inputs';
|
5
|
-
|
6
|
-
import { getEditableCell, EditorProps } from './get-editable-cell';
|
7
|
-
|
8
|
-
const Editor = observer<FC<EditorProps<number | undefined>>>(
|
9
|
-
({ fieldState: { value, onChange, hasError, error }, className }) => {
|
10
|
-
const handleChange = (event: NumericTextBoxChangeEvent) => {
|
11
|
-
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
12
|
-
onChange(event.value || undefined);
|
13
|
-
};
|
14
|
-
|
15
|
-
return (
|
16
|
-
<td className={className}>
|
17
|
-
<NumericTextBox
|
18
|
-
value={value}
|
19
|
-
onChange={handleChange}
|
20
|
-
valid={!hasError}
|
21
|
-
validationMessage={error}
|
22
|
-
/>
|
23
|
-
</td>
|
24
|
-
);
|
25
|
-
}
|
26
|
-
);
|
27
|
-
|
28
|
-
export const NumericEditableCell = getEditableCell({
|
29
|
-
editor: Editor,
|
30
|
-
});
|