@etsoo/react 1.4.72 → 1.4.76

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.
@@ -33,7 +33,7 @@ export interface ScrollerGridProps<T> extends GridLoader<T>, Omit<VariableSizeGr
33
33
  * Id field
34
34
  * @default id
35
35
  */
36
- idField?: keyof T;
36
+ idField?: string & keyof T;
37
37
  /**
38
38
  * Item renderer
39
39
  */
package/lib/index.d.ts CHANGED
@@ -64,6 +64,7 @@ export * from './mu/ScrollTopFab';
64
64
  export * from './mu/SearchBar';
65
65
  export * from './mu/SearchField';
66
66
  export * from './mu/SearchOptionGroup';
67
+ export * from './mu/SelectBool';
67
68
  export * from './mu/SelectEx';
68
69
  export * from './mu/Switch';
69
70
  export * from './mu/SwitchAnt';
package/lib/index.js CHANGED
@@ -67,6 +67,7 @@ export * from './mu/ScrollTopFab';
67
67
  export * from './mu/SearchBar';
68
68
  export * from './mu/SearchField';
69
69
  export * from './mu/SearchOptionGroup';
70
+ export * from './mu/SelectBool';
70
71
  export * from './mu/SelectEx';
71
72
  export * from './mu/Switch';
72
73
  export * from './mu/SwitchAnt';
@@ -8,7 +8,7 @@ export interface AutocompleteExtendedProps<T extends Record<string, unknown>> ex
8
8
  /**
9
9
  * Id field, default is id
10
10
  */
11
- idField?: keyof T;
11
+ idField?: string & keyof T;
12
12
  /**
13
13
  * Id value
14
14
  */
@@ -12,7 +12,7 @@ export interface ComboBoxProps<T extends {}> extends AutocompleteExtendedProps<T
12
12
  /**
13
13
  * Label field
14
14
  */
15
- labelField?: keyof T;
15
+ labelField?: string & keyof T;
16
16
  /**
17
17
  * Load data callback
18
18
  */
@@ -31,7 +31,7 @@ export interface DnDListProps<D extends {}, E extends React.ElementType> {
31
31
  /**
32
32
  * Label field
33
33
  */
34
- labelField: keyof D;
34
+ labelField: string & keyof D;
35
35
  /**
36
36
  * Load data
37
37
  */
@@ -10,11 +10,11 @@ export interface ItemListProps<T extends Record<string, unknown>> {
10
10
  /**
11
11
  * Id field name
12
12
  */
13
- idField?: keyof T;
13
+ idField?: string & keyof T;
14
14
  /**
15
15
  * Label field name or callback
16
16
  */
17
- labelField?: keyof T | ((item: T) => string);
17
+ labelField?: (string & keyof T) | ((item: T) => string);
18
18
  /**
19
19
  * Button icon
20
20
  */
@@ -22,7 +22,6 @@ export function MobileListItemRenderer({ data, itemHeight, margins }, renderer)
22
22
  // Loading
23
23
  if (data == null)
24
24
  return React.createElement(LinearProgress, null);
25
- console.log('margins', margins);
26
25
  // Elements
27
26
  const [title, subheader, actions, children, cardActions] = renderer(data);
28
27
  return (React.createElement(Card, { sx: {
@@ -17,7 +17,7 @@ export interface OptionGroupProps<T extends Record<string, any> = IdLabelDto, D
17
17
  /**
18
18
  * Id field, default is id
19
19
  */
20
- idField?: keyof T;
20
+ idField?: string & keyof T;
21
21
  /**
22
22
  * Label
23
23
  */
@@ -25,7 +25,7 @@ export interface OptionGroupProps<T extends Record<string, any> = IdLabelDto, D
25
25
  /**
26
26
  * Label field, default is label
27
27
  */
28
- labelField?: keyof T;
28
+ labelField?: string & keyof T;
29
29
  /**
30
30
  * Multiple choose item
31
31
  */
@@ -40,7 +40,7 @@ export interface ScrollerListExProps<T> extends Omit<ScrollerListProps<T>, 'item
40
40
  /**
41
41
  * Id field
42
42
  */
43
- idField?: keyof T;
43
+ idField?: string & keyof T;
44
44
  /**
45
45
  * Inner item renderer
46
46
  */
@@ -0,0 +1,14 @@
1
+ /// <reference types="react" />
2
+ import { IdLabelDto } from '@etsoo/appscript';
3
+ import { SelectExProps } from './SelectEx';
4
+ /**
5
+ * SelectBool props
6
+ */
7
+ export interface SelectBoolProps extends Omit<SelectExProps<IdLabelDto<string>>, 'options' | 'loadData'> {
8
+ }
9
+ /**
10
+ * SelectBool (yes/no)
11
+ * @param props Props
12
+ * @returns Component
13
+ */
14
+ export declare function SelectBool(props: SelectBoolProps): JSX.Element;
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import { globalApp } from '..';
3
+ import { SelectEx } from './SelectEx';
4
+ /**
5
+ * SelectBool (yes/no)
6
+ * @param props Props
7
+ * @returns Component
8
+ */
9
+ export function SelectBool(props) {
10
+ // Destruct
11
+ const { search = true, ...rest } = props;
12
+ // Options
13
+ const options = [
14
+ { id: 'false', label: globalApp.get('no') },
15
+ { id: 'true', label: globalApp.get('yes') }
16
+ ];
17
+ if (search)
18
+ options.unshift({ id: '', label: '---' });
19
+ // Layout
20
+ return React.createElement(SelectEx, { options: options, search: search, ...rest });
21
+ }
@@ -8,7 +8,7 @@ export interface SelectExProps<T extends {}> extends Omit<SelectProps, 'labelId'
8
8
  /**
9
9
  * Id field, default is id
10
10
  */
11
- idField?: keyof T;
11
+ idField?: string & keyof T;
12
12
  /**
13
13
  * Item icon renderer
14
14
  */
@@ -16,7 +16,7 @@ export interface SelectExProps<T extends {}> extends Omit<SelectProps, 'labelId'
16
16
  /**
17
17
  * Label field, default is label
18
18
  */
19
- labelField?: ((option: T) => string) | keyof T;
19
+ labelField?: ((option: T) => string) | (string & keyof T);
20
20
  /**
21
21
  * Load data callback
22
22
  */
@@ -35,7 +35,7 @@ export interface TableExProps<T extends Record<string, any>> extends TableProps,
35
35
  /**
36
36
  * Id field
37
37
  */
38
- idField?: keyof T;
38
+ idField?: string & keyof T;
39
39
  /**
40
40
  * Max height
41
41
  */
package/lib/mu/Tiplist.js CHANGED
@@ -29,6 +29,8 @@ export function Tiplist(props) {
29
29
  options: [],
30
30
  value: null
31
31
  });
32
+ // Input value
33
+ const inputValue = React.useMemo(() => states.value && Reflect.get(states.value, idField), [states.value]);
32
34
  React.useEffect(() => {
33
35
  if (localValue != null)
34
36
  stateUpdate({ value: localValue });
@@ -133,7 +135,7 @@ export function Tiplist(props) {
133
135
  }, []);
134
136
  // Layout
135
137
  return (React.createElement("div", null,
136
- React.createElement("input", { ref: inputRef, "data-reset": "true", type: "text", style: { display: 'none' }, name: name, value: localIdValue !== null && localIdValue !== void 0 ? localIdValue : '', readOnly: true, onChange: inputOnChange }),
138
+ React.createElement("input", { ref: inputRef, "data-reset": "true", type: "text", style: { display: 'none' }, name: name, value: inputValue !== null && inputValue !== void 0 ? inputValue : '', readOnly: true, onChange: inputOnChange }),
137
139
  React.createElement(Autocomplete, { filterOptions: (options, _state) => options, value: states.value, options: states.options, onChange: (event, value, reason, details) => {
138
140
  // Set value
139
141
  setInputValue(value);
@@ -9,7 +9,7 @@ export interface ViewPageField<T extends {}> extends GridProps {
9
9
  /**
10
10
  * Data field
11
11
  */
12
- data: keyof T | ((item: T) => React.ReactNode);
12
+ data: (string & keyof T) | ((item: T) => React.ReactNode);
13
13
  /**
14
14
  * Data type
15
15
  */
@@ -86,6 +86,6 @@ export function ViewPage(props) {
86
86
  ":"),
87
87
  React.createElement(Typography, { variant: "subtitle2" }, itemData)));
88
88
  })),
89
- actions != null && (React.createElement(Stack, { className: "ET-ViewPage-Actions", direction: "row", width: "100%", flexWrap: "wrap", paddingTop: paddings, paddingBottom: paddings, gap: paddings }, Utils.getResult(actions, data))),
89
+ actions != null && (React.createElement(Stack, { className: "ET-ViewPage-Actions", direction: "row", width: "100%", flexWrap: "wrap", justifyContent: "flex-end", paddingTop: paddings, paddingBottom: paddings, gap: paddings }, Utils.getResult(actions, data))),
90
90
  Utils.getResult(children, data)))));
91
91
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/react",
3
- "version": "1.4.72",
3
+ "version": "1.4.76",
4
4
  "description": "TypeScript ReactJs framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -50,7 +50,7 @@
50
50
  "@emotion/react": "^11.7.1",
51
51
  "@emotion/style": "^0.8.0",
52
52
  "@emotion/styled": "^11.6.0",
53
- "@etsoo/appscript": "^1.2.27",
53
+ "@etsoo/appscript": "^1.2.28",
54
54
  "@etsoo/notificationbase": "^1.1.0",
55
55
  "@etsoo/shared": "^1.1.6",
56
56
  "@mui/icons-material": "^5.3.1",
@@ -54,7 +54,7 @@ export interface ScrollerGridProps<T>
54
54
  * Id field
55
55
  * @default id
56
56
  */
57
- idField?: keyof T;
57
+ idField?: string & keyof T;
58
58
 
59
59
  /**
60
60
  * Item renderer
package/src/index.ts CHANGED
@@ -71,6 +71,7 @@ export * from './mu/ScrollTopFab';
71
71
  export * from './mu/SearchBar';
72
72
  export * from './mu/SearchField';
73
73
  export * from './mu/SearchOptionGroup';
74
+ export * from './mu/SelectBool';
74
75
  export * from './mu/SelectEx';
75
76
  export * from './mu/Switch';
76
77
  export * from './mu/SwitchAnt';
@@ -13,7 +13,7 @@ export interface AutocompleteExtendedProps<T extends Record<string, unknown>>
13
13
  /**
14
14
  * Id field, default is id
15
15
  */
16
- idField?: keyof T;
16
+ idField?: string & keyof T;
17
17
 
18
18
  /**
19
19
  * Id value
@@ -20,7 +20,7 @@ export interface ComboBoxProps<T extends {}>
20
20
  /**
21
21
  * Label field
22
22
  */
23
- labelField?: keyof T;
23
+ labelField?: string & keyof T;
24
24
 
25
25
  /**
26
26
  * Load data callback
@@ -50,7 +50,7 @@ export interface DnDListProps<D extends {}, E extends React.ElementType> {
50
50
  /**
51
51
  * Label field
52
52
  */
53
- labelField: keyof D;
53
+ labelField: string & keyof D;
54
54
 
55
55
  /**
56
56
  * Load data
@@ -22,12 +22,12 @@ export interface ItemListProps<T extends Record<string, unknown>> {
22
22
  /**
23
23
  * Id field name
24
24
  */
25
- idField?: keyof T;
25
+ idField?: string & keyof T;
26
26
 
27
27
  /**
28
28
  * Label field name or callback
29
29
  */
30
- labelField?: keyof T | ((item: T) => string);
30
+ labelField?: (string & keyof T) | ((item: T) => string);
31
31
 
32
32
  /**
33
33
  * Button icon
@@ -36,8 +36,6 @@ export function MobileListItemRenderer<T>(
36
36
  // Loading
37
37
  if (data == null) return <LinearProgress />;
38
38
 
39
- console.log('margins', margins);
40
-
41
39
  // Elements
42
40
  const [title, subheader, actions, children, cardActions] = renderer(data);
43
41
 
@@ -32,7 +32,7 @@ export interface OptionGroupProps<
32
32
  /**
33
33
  * Id field, default is id
34
34
  */
35
- idField?: keyof T;
35
+ idField?: string & keyof T;
36
36
 
37
37
  /**
38
38
  * Label
@@ -42,7 +42,7 @@ export interface OptionGroupProps<
42
42
  /**
43
43
  * Label field, default is label
44
44
  */
45
- labelField?: keyof T;
45
+ labelField?: string & keyof T;
46
46
 
47
47
  /**
48
48
  * Multiple choose item
@@ -127,7 +127,7 @@ export interface ScrollerListExProps<T>
127
127
  /**
128
128
  * Id field
129
129
  */
130
- idField?: keyof T;
130
+ idField?: string & keyof T;
131
131
 
132
132
  /**
133
133
  * Inner item renderer
@@ -0,0 +1,31 @@
1
+ import { IdLabelDto } from '@etsoo/appscript';
2
+ import React from 'react';
3
+ import { globalApp } from '..';
4
+ import { SelectEx, SelectExProps } from './SelectEx';
5
+
6
+ /**
7
+ * SelectBool props
8
+ */
9
+ export interface SelectBoolProps
10
+ extends Omit<SelectExProps<IdLabelDto<string>>, 'options' | 'loadData'> {}
11
+
12
+ /**
13
+ * SelectBool (yes/no)
14
+ * @param props Props
15
+ * @returns Component
16
+ */
17
+ export function SelectBool(props: SelectBoolProps) {
18
+ // Destruct
19
+ const { search = true, ...rest } = props;
20
+
21
+ // Options
22
+ const options: IdLabelDto<string>[] = [
23
+ { id: 'false', label: globalApp.get('no')! },
24
+ { id: 'true', label: globalApp.get('yes')! }
25
+ ];
26
+
27
+ if (search) options.unshift({ id: '', label: '---' });
28
+
29
+ // Layout
30
+ return <SelectEx options={options} search={search} {...rest} />;
31
+ }
@@ -23,7 +23,7 @@ export interface SelectExProps<T extends {}>
23
23
  /**
24
24
  * Id field, default is id
25
25
  */
26
- idField?: keyof T;
26
+ idField?: string & keyof T;
27
27
 
28
28
  /**
29
29
  * Item icon renderer
@@ -33,7 +33,7 @@ export interface SelectExProps<T extends {}>
33
33
  /**
34
34
  * Label field, default is label
35
35
  */
36
- labelField?: ((option: T) => string) | keyof T;
36
+ labelField?: ((option: T) => string) | (string & keyof T);
37
37
 
38
38
  /**
39
39
  * Load data callback
@@ -68,7 +68,7 @@ export interface TableExProps<T extends Record<string, any>>
68
68
  /**
69
69
  * Id field
70
70
  */
71
- idField?: keyof T;
71
+ idField?: string & keyof T;
72
72
 
73
73
  /**
74
74
  * Max height
@@ -107,7 +107,7 @@ export function TableEx<T extends Record<string, unknown>>(
107
107
  // Theme
108
108
  const theme = useTheme();
109
109
 
110
- type keyType = keyof T;
110
+ type keyType = string & keyof T;
111
111
 
112
112
  // Destruct
113
113
  const {
@@ -83,6 +83,12 @@ export function Tiplist<T extends {} = IdLabelDto>(props: TiplistProps<T>) {
83
83
  }
84
84
  );
85
85
 
86
+ // Input value
87
+ const inputValue = React.useMemo(
88
+ () => states.value && Reflect.get(states.value, idField),
89
+ [states.value]
90
+ );
91
+
86
92
  React.useEffect(() => {
87
93
  if (localValue != null) stateUpdate({ value: localValue });
88
94
  }, [localValue]);
@@ -219,7 +225,7 @@ export function Tiplist<T extends {} = IdLabelDto>(props: TiplistProps<T>) {
219
225
  type="text"
220
226
  style={{ display: 'none' }}
221
227
  name={name}
222
- value={localIdValue ?? ''}
228
+ value={inputValue ?? ''}
223
229
  readOnly
224
230
  onChange={inputOnChange}
225
231
  />
@@ -24,7 +24,7 @@ export interface ViewPageField<T extends {}> extends GridProps {
24
24
  /**
25
25
  * Data field
26
26
  */
27
- data: keyof T | ((item: T) => React.ReactNode);
27
+ data: (string & keyof T) | ((item: T) => React.ReactNode);
28
28
 
29
29
  /**
30
30
  * Data type
@@ -222,6 +222,7 @@ export function ViewPage<T extends {}>(props: ViewPageProps<T>) {
222
222
  direction="row"
223
223
  width="100%"
224
224
  flexWrap="wrap"
225
+ justifyContent="flex-end"
225
226
  paddingTop={paddings}
226
227
  paddingBottom={paddings}
227
228
  gap={paddings}