proje-react-panel 1.1.6 → 1.2.0
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/__tests__/utils/PreloadCacheHelper.test.ts +25 -0
- package/dist/decorators/form/Input.d.ts +2 -0
- package/dist/decorators/form/inputs/SelectInput.d.ts +3 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/jest.config.js +18 -0
- package/package.json +4 -2
- package/src/__tests__/utils/PreloadCacheHelper.test.ts +71 -0
- package/src/components/form/FormField.tsx +18 -2
- package/src/components/form/Select.tsx +1 -0
- package/src/decorators/form/Input.ts +2 -0
- package/src/decorators/form/inputs/SelectInput.ts +6 -2
- package/src/utils/PreloadCacheHelper.ts +54 -0
@@ -0,0 +1,25 @@
|
|
1
|
+
import { OnResult, preloadCacheHelper } from '../../utils/PreloadCacheHelper';
|
2
|
+
import { SelectPreloader } from '../../decorators/form/inputs/SelectInput';
|
3
|
+
import { describe, expect, it, beforeEach, jest } from '@jest/globals';
|
4
|
+
|
5
|
+
interface CacheMap {
|
6
|
+
cache: Map<SelectPreloader<unknown>, { label: string; value: unknown }[]>;
|
7
|
+
asyncQueue: Map<
|
8
|
+
SelectPreloader<unknown>,
|
9
|
+
((result: { label: string; value: unknown }[]) => Promise<void>)[]
|
10
|
+
>;
|
11
|
+
}
|
12
|
+
|
13
|
+
describe('PreloadCacheHelper', () => {
|
14
|
+
beforeEach(() => {
|
15
|
+
// Clear the cache before each test
|
16
|
+
(preloadCacheHelper as unknown as CacheMap).cache = new Map();
|
17
|
+
(preloadCacheHelper as unknown as CacheMap).asyncQueue = new Map();
|
18
|
+
});
|
19
|
+
|
20
|
+
it('should maintain singleton instance', () => {
|
21
|
+
const instance1 = preloadCacheHelper;
|
22
|
+
const instance2 = preloadCacheHelper;
|
23
|
+
expect(instance1).toBe(instance2);
|
24
|
+
});
|
25
|
+
});
|
@@ -9,6 +9,7 @@ export interface InputOptions {
|
|
9
9
|
label?: string;
|
10
10
|
placeholder?: string;
|
11
11
|
nestedFields?: InputConfiguration[];
|
12
|
+
defaultValue?: string;
|
12
13
|
includeInCSV?: boolean;
|
13
14
|
includeInJSON?: boolean;
|
14
15
|
}
|
@@ -22,6 +23,7 @@ export interface InputConfiguration {
|
|
22
23
|
label?: string;
|
23
24
|
placeholder?: string;
|
24
25
|
nestedFields?: InputConfiguration[];
|
26
|
+
defaultValue?: string;
|
25
27
|
includeInCSV: boolean;
|
26
28
|
includeInJSON: boolean;
|
27
29
|
}
|
@@ -9,6 +9,7 @@ export interface SelectInputOptions<T> extends InputOptions {
|
|
9
9
|
label: string;
|
10
10
|
}[];
|
11
11
|
csvExport?: never;
|
12
|
+
defaultValue?: never;
|
12
13
|
}
|
13
14
|
export interface SelectInputConfiguration<T> extends InputConfiguration {
|
14
15
|
type: 'select';
|
@@ -20,5 +21,7 @@ export interface SelectInputConfiguration<T> extends InputConfiguration {
|
|
20
21
|
value: T;
|
21
22
|
label: string;
|
22
23
|
}[];
|
24
|
+
csvExport?: never;
|
25
|
+
defaultValue?: never;
|
23
26
|
}
|
24
27
|
export declare function SelectInput<K>(options?: SelectInputOptions<K>): PropertyDecorator;
|