@etsoo/materialui 1.3.11 → 1.3.13
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/lib/CultureDataTable.d.ts +18 -0
- package/lib/CultureDataTable.js +30 -0
- package/lib/SelectEx.d.ts +4 -0
- package/lib/SelectEx.js +2 -2
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/package.json +8 -8
- package/src/CultureDataTable.tsx +60 -0
- package/src/SelectEx.tsx +14 -1
- package/src/index.ts +1 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DataTableProps } from "./DataTable";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { ListType1 } from "@etsoo/shared";
|
|
4
|
+
/**
|
|
5
|
+
* Culture table props
|
|
6
|
+
*/
|
|
7
|
+
export type CultureDataTableProps = Omit<DataTableProps, "columns"> & {
|
|
8
|
+
cultures: ListType1[];
|
|
9
|
+
cultureLabel?: string;
|
|
10
|
+
editable?: boolean;
|
|
11
|
+
titleLabel?: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Culture DataTable
|
|
15
|
+
* @param props Props
|
|
16
|
+
* @returns Component
|
|
17
|
+
*/
|
|
18
|
+
export declare function CultureDataTable(props: CultureDataTableProps): React.JSX.Element;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { DataTable } from "./DataTable";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { globalApp } from "./app/ReactApp";
|
|
4
|
+
/**
|
|
5
|
+
* Culture DataTable
|
|
6
|
+
* @param props Props
|
|
7
|
+
* @returns Component
|
|
8
|
+
*/
|
|
9
|
+
export function CultureDataTable(props) {
|
|
10
|
+
// Destruct
|
|
11
|
+
const { cultures, cultureLabel = globalApp === null || globalApp === void 0 ? void 0 : globalApp.get("culture"), editable = true, titleLabel, ...rest } = props;
|
|
12
|
+
const getCultureLabel = React.useCallback((value) => { var _a, _b; return (_b = (_a = cultures.find((c) => c.id == value.id)) === null || _a === void 0 ? void 0 : _a.label) !== null && _b !== void 0 ? _b : `${value.value}`; }, [cultures]);
|
|
13
|
+
return (React.createElement(DataTable, { columns: [
|
|
14
|
+
{
|
|
15
|
+
field: "id",
|
|
16
|
+
headerName: cultureLabel,
|
|
17
|
+
valueFormatter: getCultureLabel,
|
|
18
|
+
width: 150,
|
|
19
|
+
editable: false,
|
|
20
|
+
sortable: false
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
field: "title",
|
|
24
|
+
headerName: titleLabel,
|
|
25
|
+
flex: 1,
|
|
26
|
+
editable,
|
|
27
|
+
sortable: false
|
|
28
|
+
}
|
|
29
|
+
], ...rest }));
|
|
30
|
+
}
|
package/lib/SelectEx.d.ts
CHANGED
package/lib/SelectEx.js
CHANGED
|
@@ -12,7 +12,7 @@ import { ReactUtils } from "@etsoo/react";
|
|
|
12
12
|
*/
|
|
13
13
|
export function SelectEx(props) {
|
|
14
14
|
// Destruct
|
|
15
|
-
const { defaultValue, idField = "id", error, helperText, itemIconRenderer, itemStyle, label, labelField = "label", loadData, onItemChange, onItemClick, onLoadData, multiple = false, name, options, refresh, search = false, autoAddBlankItem = search, value, onChange, fullWidth, required, variant = "outlined", ...rest } = props;
|
|
15
|
+
const { defaultValue, idField = "id", error, helperText, inputReset, itemIconRenderer, itemStyle, label, labelField = "label", loadData, onItemChange, onItemClick, onLoadData, multiple = false, name, options, refresh, search = false, autoAddBlankItem = search, value, onChange, fullWidth, required, variant = "outlined", ...rest } = props;
|
|
16
16
|
// Options state
|
|
17
17
|
const [localOptions, setOptions] = React.useState([]);
|
|
18
18
|
const isMounted = React.useRef(false);
|
|
@@ -133,7 +133,7 @@ export function SelectEx(props) {
|
|
|
133
133
|
? valueState
|
|
134
134
|
: localOptions.some((o) => o[idField] === valueState)
|
|
135
135
|
? valueState
|
|
136
|
-
: "", input: React.createElement(OutlinedInput, { notched: true, label: label, required: required }), labelId: labelId, name: name, multiple: multiple, onChange: (event, child) => {
|
|
136
|
+
: "", input: React.createElement(OutlinedInput, { notched: true, label: label, required: required, "data-reset": inputReset }), labelId: labelId, name: name, multiple: multiple, onChange: (event, child) => {
|
|
137
137
|
if (onChange) {
|
|
138
138
|
onChange(event, child);
|
|
139
139
|
// event.preventDefault() will block executing
|
package/lib/index.d.ts
CHANGED
|
@@ -44,6 +44,7 @@ export * from "./ComboBoxMultiple";
|
|
|
44
44
|
export * from "./ComboBoxPro";
|
|
45
45
|
export * from "./CountdownButton";
|
|
46
46
|
export * from "./CountryList";
|
|
47
|
+
export * from "./CultureDataTable";
|
|
47
48
|
export * from "./CustomFabProps";
|
|
48
49
|
export * from "./DataGridEx";
|
|
49
50
|
export * from "./DataGridRenderers";
|
package/lib/index.js
CHANGED
|
@@ -44,6 +44,7 @@ export * from "./ComboBoxMultiple";
|
|
|
44
44
|
export * from "./ComboBoxPro";
|
|
45
45
|
export * from "./CountdownButton";
|
|
46
46
|
export * from "./CountryList";
|
|
47
|
+
export * from "./CultureDataTable";
|
|
47
48
|
export * from "./CustomFabProps";
|
|
48
49
|
export * from "./DataGridEx";
|
|
49
50
|
export * from "./DataGridRenderers";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/materialui",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.13",
|
|
4
4
|
"description": "TypeScript Material-UI Implementation",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -50,12 +50,12 @@
|
|
|
50
50
|
"@emotion/css": "^11.11.2",
|
|
51
51
|
"@emotion/react": "^11.11.1",
|
|
52
52
|
"@emotion/styled": "^11.11.0",
|
|
53
|
-
"@etsoo/appscript": "^1.4.
|
|
53
|
+
"@etsoo/appscript": "^1.4.52",
|
|
54
54
|
"@etsoo/notificationbase": "^1.1.28",
|
|
55
55
|
"@etsoo/react": "^1.7.8",
|
|
56
56
|
"@etsoo/shared": "^1.2.12",
|
|
57
|
-
"@mui/icons-material": "^5.14.
|
|
58
|
-
"@mui/material": "^5.14.
|
|
57
|
+
"@mui/icons-material": "^5.14.9",
|
|
58
|
+
"@mui/material": "^5.14.9",
|
|
59
59
|
"@mui/x-data-grid": "^6.13.0",
|
|
60
60
|
"@types/pica": "^9.0.1",
|
|
61
61
|
"@types/pulltorefreshjs": "^0.1.5",
|
|
@@ -85,10 +85,10 @@
|
|
|
85
85
|
"@testing-library/jest-dom": "^6.1.3",
|
|
86
86
|
"@testing-library/react": "^14.0.0",
|
|
87
87
|
"@types/jest": "^29.5.4",
|
|
88
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
89
|
-
"@typescript-eslint/parser": "^6.
|
|
90
|
-
"jest": "^29.
|
|
91
|
-
"jest-environment-jsdom": "^29.
|
|
88
|
+
"@typescript-eslint/eslint-plugin": "^6.7.0",
|
|
89
|
+
"@typescript-eslint/parser": "^6.7.0",
|
|
90
|
+
"jest": "^29.7.0",
|
|
91
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
92
92
|
"typescript": "^5.2.2"
|
|
93
93
|
}
|
|
94
94
|
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { DataTable, DataTableProps } from "./DataTable";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { globalApp } from "./app/ReactApp";
|
|
4
|
+
import { ListType1 } from "@etsoo/shared";
|
|
5
|
+
import { GridValueFormatterParams } from "@mui/x-data-grid";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Culture table props
|
|
9
|
+
*/
|
|
10
|
+
export type CultureDataTableProps = Omit<DataTableProps, "columns"> & {
|
|
11
|
+
cultures: ListType1[];
|
|
12
|
+
cultureLabel?: string;
|
|
13
|
+
editable?: boolean;
|
|
14
|
+
titleLabel?: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Culture DataTable
|
|
19
|
+
* @param props Props
|
|
20
|
+
* @returns Component
|
|
21
|
+
*/
|
|
22
|
+
export function CultureDataTable(props: CultureDataTableProps) {
|
|
23
|
+
// Destruct
|
|
24
|
+
const {
|
|
25
|
+
cultures,
|
|
26
|
+
cultureLabel = globalApp?.get("culture"),
|
|
27
|
+
editable = true,
|
|
28
|
+
titleLabel,
|
|
29
|
+
...rest
|
|
30
|
+
} = props;
|
|
31
|
+
|
|
32
|
+
const getCultureLabel = React.useCallback(
|
|
33
|
+
(value: GridValueFormatterParams) =>
|
|
34
|
+
cultures.find((c) => c.id == value.id)?.label ?? `${value.value}`,
|
|
35
|
+
[cultures]
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<DataTable
|
|
40
|
+
columns={[
|
|
41
|
+
{
|
|
42
|
+
field: "id",
|
|
43
|
+
headerName: cultureLabel,
|
|
44
|
+
valueFormatter: getCultureLabel,
|
|
45
|
+
width: 150,
|
|
46
|
+
editable: false,
|
|
47
|
+
sortable: false
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
field: "title",
|
|
51
|
+
headerName: titleLabel,
|
|
52
|
+
flex: 1,
|
|
53
|
+
editable,
|
|
54
|
+
sortable: false
|
|
55
|
+
}
|
|
56
|
+
]}
|
|
57
|
+
{...rest}
|
|
58
|
+
/>
|
|
59
|
+
);
|
|
60
|
+
}
|
package/src/SelectEx.tsx
CHANGED
|
@@ -48,6 +48,11 @@ export type SelectExProps<
|
|
|
48
48
|
*/
|
|
49
49
|
idField?: D;
|
|
50
50
|
|
|
51
|
+
/**
|
|
52
|
+
* Set 'data-reset'
|
|
53
|
+
*/
|
|
54
|
+
inputReset?: boolean;
|
|
55
|
+
|
|
51
56
|
/**
|
|
52
57
|
* Item icon renderer
|
|
53
58
|
*/
|
|
@@ -115,6 +120,7 @@ export function SelectEx<
|
|
|
115
120
|
idField = "id" as D,
|
|
116
121
|
error,
|
|
117
122
|
helperText,
|
|
123
|
+
inputReset,
|
|
118
124
|
itemIconRenderer,
|
|
119
125
|
itemStyle,
|
|
120
126
|
label,
|
|
@@ -291,7 +297,14 @@ export function SelectEx<
|
|
|
291
297
|
? valueState
|
|
292
298
|
: ""
|
|
293
299
|
}
|
|
294
|
-
input={
|
|
300
|
+
input={
|
|
301
|
+
<OutlinedInput
|
|
302
|
+
notched
|
|
303
|
+
label={label}
|
|
304
|
+
required={required}
|
|
305
|
+
data-reset={inputReset}
|
|
306
|
+
/>
|
|
307
|
+
}
|
|
295
308
|
labelId={labelId}
|
|
296
309
|
name={name}
|
|
297
310
|
multiple={multiple}
|
package/src/index.ts
CHANGED
|
@@ -48,6 +48,7 @@ export * from "./ComboBoxMultiple";
|
|
|
48
48
|
export * from "./ComboBoxPro";
|
|
49
49
|
export * from "./CountdownButton";
|
|
50
50
|
export * from "./CountryList";
|
|
51
|
+
export * from "./CultureDataTable";
|
|
51
52
|
export * from "./CustomFabProps";
|
|
52
53
|
export * from "./DataGridEx";
|
|
53
54
|
export * from "./DataGridRenderers";
|