zavadil-react-common 1.1.57 → 1.1.58
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,10 @@
|
|
|
1
|
+
import { LookupTableEntity } from "zavadil-ts-common/dist/type/Entity";
|
|
2
|
+
export type LookupSelectProps = {
|
|
3
|
+
id?: number | null;
|
|
4
|
+
onChange: (n: number | null) => any;
|
|
5
|
+
options?: Array<LookupTableEntity> | null;
|
|
6
|
+
showEmptyOption?: boolean;
|
|
7
|
+
emptyOptionLabel?: string;
|
|
8
|
+
sort?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export default function LookupSelect({ id, sort, onChange, options, showEmptyOption, emptyOptionLabel }: LookupSelectProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
3
3
|
import { PagingRequest, UserAlertType, UserAlerts, UserAlert, JavaHeapStats, CacheStats, QueueStats } from 'zavadil-ts-common';
|
|
4
4
|
import * as react from 'react';
|
|
5
5
|
import { PropsWithChildren, ReactNode } from 'react';
|
|
6
|
+
import { LookupTableEntity } from 'zavadil-ts-common/dist/type/Entity';
|
|
6
7
|
|
|
7
8
|
type HeaderCol = {
|
|
8
9
|
name: string;
|
|
@@ -42,6 +43,15 @@ type ActiveButtonProps = IconButtonProps & {
|
|
|
42
43
|
};
|
|
43
44
|
declare function LoadingButton({ disabled, icon, loading, children, size, onClick }: PropsWithChildren<ActiveButtonProps>): react_jsx_runtime.JSX.Element;
|
|
44
45
|
|
|
46
|
+
type LookupSelectProps = {
|
|
47
|
+
id?: number | null;
|
|
48
|
+
onChange: (n: number | null) => any;
|
|
49
|
+
options?: Array<LookupTableEntity> | null;
|
|
50
|
+
showEmptyOption?: boolean;
|
|
51
|
+
emptyOptionLabel?: string;
|
|
52
|
+
sort?: boolean;
|
|
53
|
+
};
|
|
54
|
+
|
|
45
55
|
type GenericSelectOption<T> = {
|
|
46
56
|
id?: T | null;
|
|
47
57
|
label: string;
|
|
@@ -114,4 +124,4 @@ type QueueStatsControlProps = {
|
|
|
114
124
|
};
|
|
115
125
|
declare function QueueStatsControl({ name, stats }: QueueStatsControlProps): react_jsx_runtime.JSX.Element;
|
|
116
126
|
|
|
117
|
-
export { type ActiveButtonProps, AdvancedTable, type AdvancedTableProps, type BasicDialogProps, CacheStatsControl, type CacheStatsControlProps, ConfirmDialog, ConfirmDialogContext, ConfirmDialogContextData, type ConfirmDialogProps, type GenericSelectOption, type GenericSelectProps, type HeaderCol, IconButton, type IconButtonProps, JavaHeapControl, LoadingButton, NumberSelect, type NumberSelectProps, QueueStateControl, type QueueStateControlProps, QueueStatsControl, type QueueStatsControlProps, StringSelect, type StringSelectProps, type TableHeader, TextInputWithReset, type TextInputWithResetProps, UserAlertTypeIcon, type UserAlertTypeIconProps, UserAlertWidget, type UserAlertWidgetProps, UserAlertsWidget, type UserAlertsWidgetProps, type WorkerJavaHeapControlProps };
|
|
127
|
+
export { type ActiveButtonProps, AdvancedTable, type AdvancedTableProps, type BasicDialogProps, CacheStatsControl, type CacheStatsControlProps, ConfirmDialog, ConfirmDialogContext, ConfirmDialogContextData, type ConfirmDialogProps, type GenericSelectOption, type GenericSelectProps, type HeaderCol, IconButton, type IconButtonProps, JavaHeapControl, LoadingButton, type LookupSelectProps, NumberSelect, type NumberSelectProps, QueueStateControl, type QueueStateControlProps, QueueStatsControl, type QueueStatsControlProps, StringSelect, type StringSelectProps, type TableHeader, TextInputWithReset, type TextInputWithResetProps, UserAlertTypeIcon, type UserAlertTypeIconProps, UserAlertWidget, type UserAlertWidgetProps, UserAlertsWidget, type UserAlertsWidgetProps, type WorkerJavaHeapControlProps };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zavadil-react-common",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.58",
|
|
4
4
|
"description": "Common types for React Typescript UI apps.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"react": "^18.3.1",
|
|
31
|
-
"zavadil-ts-common": "^1.1.
|
|
31
|
+
"zavadil-ts-common": "^1.1.39",
|
|
32
32
|
"bootstrap": "^5.3.0",
|
|
33
33
|
"react-bootstrap": "^2.10.5",
|
|
34
34
|
"react-dom": "^18.2.0",
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {useMemo} from "react";
|
|
2
|
+
import {GenericSelectOption, NumberSelect} from "./Select";
|
|
3
|
+
import {LookupTableEntity} from "zavadil-ts-common/dist/type/Entity";
|
|
4
|
+
|
|
5
|
+
export type LookupSelectProps = {
|
|
6
|
+
id?: number | null;
|
|
7
|
+
onChange: (n: number | null) => any;
|
|
8
|
+
options?: Array<LookupTableEntity> | null;
|
|
9
|
+
showEmptyOption?: boolean;
|
|
10
|
+
emptyOptionLabel?: string;
|
|
11
|
+
sort?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default function LookupSelect({id, sort, onChange, options, showEmptyOption, emptyOptionLabel}: LookupSelectProps) {
|
|
15
|
+
const lOptions: GenericSelectOption<number>[] = useMemo(
|
|
16
|
+
() => {
|
|
17
|
+
let result: Array<LookupTableEntity> = []
|
|
18
|
+
if (options) {
|
|
19
|
+
result = sort ? options.sort((a, b) => a.name > b.name ? 1 : -1) : options;
|
|
20
|
+
}
|
|
21
|
+
return result
|
|
22
|
+
.map(
|
|
23
|
+
(o) => {
|
|
24
|
+
return {
|
|
25
|
+
id: o.id,
|
|
26
|
+
label: o.name
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
},
|
|
31
|
+
[options]
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<NumberSelect
|
|
36
|
+
value={id}
|
|
37
|
+
options={lOptions}
|
|
38
|
+
onChange={onChange}
|
|
39
|
+
showEmptyOption={showEmptyOption}
|
|
40
|
+
emptyOptionLabel={emptyOptionLabel}
|
|
41
|
+
/>
|
|
42
|
+
);
|
|
43
|
+
}
|