@elliemae/pui-app-sdk 5.18.2 → 5.20.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/dist/cjs/utils/decorators/functionDecorators.js +20 -0
- package/dist/esm/utils/decorators/functionDecorators.js +20 -0
- package/dist/types/lib/utils/decorators/functionDecorators.d.ts +32 -0
- package/dist/types/lib/view/fields/date-time-picker/index.stories.d.ts +37 -12
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +49 -50
|
@@ -18,6 +18,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var functionDecorators_exports = {};
|
|
20
20
|
__export(functionDecorators_exports, {
|
|
21
|
+
AsyncSingleExecution: () => AsyncSingleExecution,
|
|
21
22
|
CacheUntilResolved: () => CacheUntilResolved,
|
|
22
23
|
Debounce: () => Debounce,
|
|
23
24
|
ImmutableArgs: () => ImmutableArgs,
|
|
@@ -156,3 +157,22 @@ function Throttle(delay = 300) {
|
|
|
156
157
|
return descriptor;
|
|
157
158
|
};
|
|
158
159
|
}
|
|
160
|
+
function AsyncSingleExecution(_target, _propertyKey, descriptor) {
|
|
161
|
+
const originalMethod = descriptor.value;
|
|
162
|
+
const promiseMap = /* @__PURE__ */ new Map();
|
|
163
|
+
descriptor.value = function(...args) {
|
|
164
|
+
const key = JSON.stringify(args);
|
|
165
|
+
if (promiseMap.has(key)) {
|
|
166
|
+
return promiseMap.get(key);
|
|
167
|
+
}
|
|
168
|
+
const promise = originalMethod.apply(this, args);
|
|
169
|
+
if (promise instanceof Promise) {
|
|
170
|
+
promiseMap.set(key, promise);
|
|
171
|
+
promise.finally(() => {
|
|
172
|
+
promiseMap.delete(key);
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
return promise;
|
|
176
|
+
};
|
|
177
|
+
return descriptor;
|
|
178
|
+
}
|
|
@@ -127,7 +127,27 @@ function Throttle(delay = 300) {
|
|
|
127
127
|
return descriptor;
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
|
+
function AsyncSingleExecution(_target, _propertyKey, descriptor) {
|
|
131
|
+
const originalMethod = descriptor.value;
|
|
132
|
+
const promiseMap = /* @__PURE__ */ new Map();
|
|
133
|
+
descriptor.value = function(...args) {
|
|
134
|
+
const key = JSON.stringify(args);
|
|
135
|
+
if (promiseMap.has(key)) {
|
|
136
|
+
return promiseMap.get(key);
|
|
137
|
+
}
|
|
138
|
+
const promise = originalMethod.apply(this, args);
|
|
139
|
+
if (promise instanceof Promise) {
|
|
140
|
+
promiseMap.set(key, promise);
|
|
141
|
+
promise.finally(() => {
|
|
142
|
+
promiseMap.delete(key);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
return promise;
|
|
146
|
+
};
|
|
147
|
+
return descriptor;
|
|
148
|
+
}
|
|
130
149
|
export {
|
|
150
|
+
AsyncSingleExecution,
|
|
131
151
|
CacheUntilResolved,
|
|
132
152
|
Debounce,
|
|
133
153
|
ImmutableArgs,
|
|
@@ -99,3 +99,35 @@ export declare function QueueTask(_target: unknown, _key: string, descriptor: Pr
|
|
|
99
99
|
* }
|
|
100
100
|
*/
|
|
101
101
|
export declare function Throttle(delay?: number): (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
102
|
+
/**
|
|
103
|
+
* AsyncSingleExecution decorator ensures that multiple concurrent calls to an async function
|
|
104
|
+
* with the same arguments will return the same promise instance until it resolves.
|
|
105
|
+
* Once resolved, subsequent calls will trigger a new execution.
|
|
106
|
+
* @param _target
|
|
107
|
+
* @param _propertyKey
|
|
108
|
+
* @param descriptor
|
|
109
|
+
* @returns {Function} A function that modifies the property descriptor.
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* import { AsyncSingleExecution } from './functionDecorators';
|
|
113
|
+
*
|
|
114
|
+
* class Example {
|
|
115
|
+
* @AsyncSingleExecution
|
|
116
|
+
* async fetchData(id: number) {
|
|
117
|
+
* console.log('Fetching data for', id);
|
|
118
|
+
* return new Promise(resolve => setTimeout(() => resolve(id), 1000));
|
|
119
|
+
* }
|
|
120
|
+
* }
|
|
121
|
+
*
|
|
122
|
+
* const instance = new Example();
|
|
123
|
+
* const promise1 = instance.fetchData(1);
|
|
124
|
+
* const promise2 = instance.fetchData(1);
|
|
125
|
+
*
|
|
126
|
+
* console.log(promise1 === promise2); // true
|
|
127
|
+
* ```
|
|
128
|
+
*
|
|
129
|
+
* // Output:
|
|
130
|
+
* // Fetching data for 1 (only logged once)
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
export declare function AsyncSingleExecution(_target: any, _propertyKey: string, descriptor: PropertyDescriptor): PropertyDescriptor;
|
|
@@ -1,15 +1,40 @@
|
|
|
1
1
|
import { Story, Meta } from '@storybook/react';
|
|
2
|
+
import { DateTimePickerProps } from './index.js';
|
|
2
3
|
declare const _default: Meta;
|
|
3
4
|
export default _default;
|
|
4
|
-
export declare const DateTimeInputs: Story<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export declare const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export declare const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export declare const
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
export declare const DateTimeInputs: Story<DateTimePickerProps & {
|
|
6
|
+
labelText: string;
|
|
7
|
+
}>;
|
|
8
|
+
export declare const FullDateTime: Story<DateTimePickerProps & {
|
|
9
|
+
labelText: string;
|
|
10
|
+
}>;
|
|
11
|
+
export declare const DateTimePickerExample: Story<DateTimePickerProps & {
|
|
12
|
+
labelText: string;
|
|
13
|
+
}>;
|
|
14
|
+
export declare const DateTimePickerControllerOnly: Story<DateTimePickerProps & {
|
|
15
|
+
labelText: string;
|
|
16
|
+
}>;
|
|
17
|
+
export declare const DateInputs: Story<DateTimePickerProps & {
|
|
18
|
+
labelText: string;
|
|
19
|
+
}>;
|
|
20
|
+
export declare const DatePicker: Story<DateTimePickerProps & {
|
|
21
|
+
labelText: string;
|
|
22
|
+
}>;
|
|
23
|
+
export declare const DatePickerControllerOnly: Story<DateTimePickerProps & {
|
|
24
|
+
labelText: string;
|
|
25
|
+
}>;
|
|
26
|
+
export declare const FullDate: Story<DateTimePickerProps & {
|
|
27
|
+
labelText: string;
|
|
28
|
+
}>;
|
|
29
|
+
export declare const FullTime: Story<DateTimePickerProps & {
|
|
30
|
+
labelText: string;
|
|
31
|
+
}>;
|
|
32
|
+
export declare const TimeInputs: Story<DateTimePickerProps & {
|
|
33
|
+
labelText: string;
|
|
34
|
+
}>;
|
|
35
|
+
export declare const TimePickerControllerOnly: Story<DateTimePickerProps & {
|
|
36
|
+
labelText: string;
|
|
37
|
+
}>;
|
|
38
|
+
export declare const TimePicker: Story<DateTimePickerProps & {
|
|
39
|
+
labelText: string;
|
|
40
|
+
}>;
|