@etsoo/materialui 1.0.79 → 1.0.80

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.
@@ -0,0 +1,30 @@
1
+ /// <reference types="react" />
2
+ import { AddressRegionDb, RegionsRQ } from '@etsoo/appscript';
3
+ import { DataTypes } from '@etsoo/shared';
4
+ import { TiplistProps } from './Tiplist';
5
+ /**
6
+ * Country list props
7
+ */
8
+ export type CountryListProps = Omit<DataTypes.Optional<TiplistProps<AddressRegionDb, 'id'>, 'name'>, 'loadData'> & {
9
+ /**
10
+ * Load data
11
+ * @param rq Request data
12
+ * @returns Result
13
+ */
14
+ loadData: (rq: RegionsRQ) => Promise<AddressRegionDb[] | undefined>;
15
+ /**
16
+ * Load favored country ids
17
+ * @returns Result
18
+ */
19
+ loadFavoredIds?: () => Promise<string[]>;
20
+ /**
21
+ * Max items to display
22
+ */
23
+ items?: number;
24
+ };
25
+ /**
26
+ * Country list
27
+ * @param props Props
28
+ * @returns Component
29
+ */
30
+ export declare function CountryList(props: CountryListProps): JSX.Element;
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import { Tiplist } from './Tiplist';
3
+ /**
4
+ * Country list
5
+ * @param props Props
6
+ * @returns Component
7
+ */
8
+ export function CountryList(props) {
9
+ // Destruct
10
+ const { items = 16, loadData, loadFavoredIds, name = 'countryId', ...rest } = props;
11
+ // Ref
12
+ const favoredIds = React.useRef([]);
13
+ // Ready
14
+ React.useEffect(() => {
15
+ if (loadFavoredIds)
16
+ loadFavoredIds().then((ids) => {
17
+ favoredIds.current = ids;
18
+ });
19
+ }, [loadFavoredIds]);
20
+ // Layout
21
+ return (React.createElement(Tiplist, { name: name, loadData: (keyword, id) => loadData({ id, keyword, favoredIds: favoredIds.current, items }), ...rest }));
22
+ }
package/lib/Tiplist.js CHANGED
@@ -153,5 +153,5 @@ export function Tiplist(props) {
153
153
  open: false,
154
154
  ...(!states.value && { options: [] })
155
155
  });
156
- }, loading: states.loading, sx: sx, renderInput: (params) => search ? (React.createElement(SearchField, { onChange: changeHandle, ...params, readOnly: readOnly, label: label, name: name + 'Input', margin: inputMargin, variant: inputVariant, required: inputRequired, autoComplete: inputAutoComplete, error: inputError, helperText: inputHelperText })) : (React.createElement(InputField, { onChange: changeHandle, ...addReadOnly(params), label: label, name: name + 'Input', margin: inputMargin, variant: inputVariant, required: inputRequired, autoComplete: inputAutoComplete, error: inputError, helperText: inputHelperText })), isOptionEqualToValue: (option, value) => option[idField] === value[idField], ...rest })));
156
+ }, loading: states.loading, sx: sx, renderInput: (params) => search ? (React.createElement(SearchField, { onChange: changeHandle, ...addReadOnly(params), readOnly: readOnly, label: label, name: name + 'Input', margin: inputMargin, variant: inputVariant, required: inputRequired, autoComplete: inputAutoComplete, error: inputError, helperText: inputHelperText })) : (React.createElement(InputField, { onChange: changeHandle, ...addReadOnly(params), label: label, name: name + 'Input', margin: inputMargin, variant: inputVariant, required: inputRequired, autoComplete: inputAutoComplete, error: inputError, helperText: inputHelperText })), isOptionEqualToValue: (option, value) => option[idField] === value[idField], ...rest })));
157
157
  }
package/lib/index.d.ts CHANGED
@@ -29,6 +29,7 @@ export * from './BridgeCloseButton';
29
29
  export * from './ButtonLink';
30
30
  export * from './ComboBox';
31
31
  export * from './CountdownButton';
32
+ export * from './CountryList';
32
33
  export * from './CustomFabProps';
33
34
  export * from './DataGridEx';
34
35
  export * from './DataGridRenderers';
package/lib/index.js CHANGED
@@ -29,6 +29,7 @@ export * from './BridgeCloseButton';
29
29
  export * from './ButtonLink';
30
30
  export * from './ComboBox';
31
31
  export * from './CountdownButton';
32
+ export * from './CountryList';
32
33
  export * from './CustomFabProps';
33
34
  export * from './DataGridEx';
34
35
  export * from './DataGridRenderers';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.0.79",
3
+ "version": "1.0.80",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -0,0 +1,68 @@
1
+ import { AddressRegionDb, RegionsRQ } from '@etsoo/appscript';
2
+ import { DataTypes } from '@etsoo/shared';
3
+ import React from 'react';
4
+ import { Tiplist, TiplistProps } from './Tiplist';
5
+
6
+ /**
7
+ * Country list props
8
+ */
9
+ export type CountryListProps = Omit<
10
+ DataTypes.Optional<TiplistProps<AddressRegionDb, 'id'>, 'name'>,
11
+ 'loadData'
12
+ > & {
13
+ /**
14
+ * Load data
15
+ * @param rq Request data
16
+ * @returns Result
17
+ */
18
+ loadData: (rq: RegionsRQ) => Promise<AddressRegionDb[] | undefined>;
19
+
20
+ /**
21
+ * Load favored country ids
22
+ * @returns Result
23
+ */
24
+ loadFavoredIds?: () => Promise<string[]>;
25
+
26
+ /**
27
+ * Max items to display
28
+ */
29
+ items?: number;
30
+ };
31
+
32
+ /**
33
+ * Country list
34
+ * @param props Props
35
+ * @returns Component
36
+ */
37
+ export function CountryList(props: CountryListProps) {
38
+ // Destruct
39
+ const {
40
+ items = 16,
41
+ loadData,
42
+ loadFavoredIds,
43
+ name = 'countryId',
44
+ ...rest
45
+ } = props;
46
+
47
+ // Ref
48
+ const favoredIds = React.useRef<string[]>([]);
49
+
50
+ // Ready
51
+ React.useEffect(() => {
52
+ if (loadFavoredIds)
53
+ loadFavoredIds().then((ids) => {
54
+ favoredIds.current = ids;
55
+ });
56
+ }, [loadFavoredIds]);
57
+
58
+ // Layout
59
+ return (
60
+ <Tiplist<AddressRegionDb, 'id'>
61
+ name={name}
62
+ loadData={(keyword, id) =>
63
+ loadData({ id, keyword, favoredIds: favoredIds.current, items })
64
+ }
65
+ {...rest}
66
+ />
67
+ );
68
+ }
package/src/Tiplist.tsx CHANGED
@@ -267,7 +267,7 @@ export function Tiplist<
267
267
  search ? (
268
268
  <SearchField
269
269
  onChange={changeHandle}
270
- {...params}
270
+ {...addReadOnly(params)}
271
271
  readOnly={readOnly}
272
272
  label={label}
273
273
  name={name + 'Input'}
package/src/index.ts CHANGED
@@ -32,6 +32,7 @@ export * from './BridgeCloseButton';
32
32
  export * from './ButtonLink';
33
33
  export * from './ComboBox';
34
34
  export * from './CountdownButton';
35
+ export * from './CountryList';
35
36
  export * from './CustomFabProps';
36
37
  export * from './DataGridEx';
37
38
  export * from './DataGridRenderers';