@nu-art/thunderstorm-frontend 0.400.12 → 0.400.14
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/component-modules/mouse-interactivity/types.d.ts +1 -0
- package/components/TS_MouseInteractivity/TS_PopUp/TS_PopUp.js +1 -0
- package/components/TS_Radio/TS_Radio.js +3 -4
- package/components/TS_V2_TextArea/TS_TextAreaV2.d.ts +1 -1
- package/components/TS_V2_TextArea/TS_TextAreaV2.js +4 -4
- package/modules/ModuleFE_LocalStorage.js +9 -9
- package/modules/ModuleFE_Thunderstorm.d.ts +2 -0
- package/modules/ModuleFE_Thunderstorm.js +14 -1
- package/package.json +6 -6
- package/utils/EditableItem.js +1 -1
- package/utils/tools.d.ts +5 -0
- package/utils/tools.js +4 -0
|
@@ -25,6 +25,7 @@ export type Model_Menu = Omit<MouseInteractivity_Model, 'content'> & {
|
|
|
25
25
|
};
|
|
26
26
|
export type Model_PopUp = MouseInteractivity_Model & {
|
|
27
27
|
ignoreOverlayClick?: ResolvableContent<boolean>;
|
|
28
|
+
onOverlayClick?: (e: React.MouseEvent<HTMLDivElement>) => void;
|
|
28
29
|
};
|
|
29
30
|
export type Model_ToolTip = MouseInteractivity_Model & {
|
|
30
31
|
contentHoverDelay?: number;
|
|
@@ -23,6 +23,7 @@ export class TS_PopUp extends TS_MouseInteractivity {
|
|
|
23
23
|
if (!model.ignoreOverlayClick || !resolveContent(model?.ignoreOverlayClick))
|
|
24
24
|
this.setState({ open: false });
|
|
25
25
|
ModuleFE_MouseInteractivity.hide(mouseInteractivity_PopUp);
|
|
26
|
+
model?.onOverlayClick?.(e);
|
|
26
27
|
}, children: _jsx("div", { className: "ts-popup__content", id: model.id, ref: this.ref, onClick: stopPropagation, onContextMenu: stopPropagation, children: resolveContent(model.content, () => this.forceUpdate()) }) });
|
|
27
28
|
}
|
|
28
29
|
}
|
|
@@ -22,10 +22,9 @@ export class TS_Radio extends ComponentSync {
|
|
|
22
22
|
const nextValue = (this.props.canUnselect && value === prevValue)
|
|
23
23
|
? undefined
|
|
24
24
|
: value;
|
|
25
|
-
this.
|
|
26
|
-
this.props.onCheck
|
|
27
|
-
|
|
28
|
-
});
|
|
25
|
+
if (this.props.onCheck)
|
|
26
|
+
return this.props.onCheck(nextValue, prevValue);
|
|
27
|
+
this.setState({ checked: nextValue });
|
|
29
28
|
};
|
|
30
29
|
// ######################### Render #########################
|
|
31
30
|
renderRadioOption = (value) => {
|
|
@@ -68,11 +68,11 @@ export declare class TS_TextAreaV2 extends React.Component<Props_TS_TextAreaV2,
|
|
|
68
68
|
value: string | undefined;
|
|
69
69
|
};
|
|
70
70
|
private static getInitialState;
|
|
71
|
+
componentDidUpdate(prevProps: Readonly<Props_TS_TextAreaV2>, prevState: Readonly<InputState>): void;
|
|
71
72
|
changeValue: (event: ChangeEvent<HTMLTextAreaElement>) => void;
|
|
72
73
|
onKeyDown: (ev: KeyboardEvent<HTMLTextAreaElement>) => void;
|
|
73
74
|
resizeWithText: () => void;
|
|
74
75
|
componentDidMount(): void;
|
|
75
|
-
componentDidUpdate(): void;
|
|
76
76
|
render(): import("react/jsx-runtime").JSX.Element;
|
|
77
77
|
}
|
|
78
78
|
export {};
|
|
@@ -80,6 +80,10 @@ export class TS_TextAreaV2 extends React.Component {
|
|
|
80
80
|
value: props.value || ''
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
+
componentDidUpdate(prevProps, prevState) {
|
|
84
|
+
if (this.props.resizeWithText && prevState.value !== this.state.value)
|
|
85
|
+
this.resizeWithText();
|
|
86
|
+
}
|
|
83
87
|
changeValue = (event) => {
|
|
84
88
|
const value = event.target.value;
|
|
85
89
|
this.setState({ value });
|
|
@@ -152,10 +156,6 @@ export class TS_TextAreaV2 extends React.Component {
|
|
|
152
156
|
if (this.props.resizeWithText)
|
|
153
157
|
this.resizeWithText();
|
|
154
158
|
}
|
|
155
|
-
componentDidUpdate() {
|
|
156
|
-
if (this.props.resizeWithText)
|
|
157
|
-
this.resizeWithText();
|
|
158
|
-
}
|
|
159
159
|
render() {
|
|
160
160
|
const { onAccept, error, trim, saveEvent, forceAcceptKeys, resizeWithText, focus, innerRef, ...props } = this.props;
|
|
161
161
|
return _jsx("textarea", { ...props, ...convertToHTMLDataAttributes(this.props.error, 'error'), ref: input => {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
/**
|
|
22
22
|
* Created by tacb0ss on 27/07/2018.
|
|
23
23
|
*/
|
|
24
|
-
import { _keys, exists, merge, Module, resolveContent } from '@nu-art/ts-common';
|
|
24
|
+
import { _keys, deepClone, exists, merge, Module, resolveContent } from '@nu-art/ts-common';
|
|
25
25
|
import { ThunderDispatcher } from '../core/thunder-dispatcher.js';
|
|
26
26
|
export class StorageModule_Class extends Module {
|
|
27
27
|
cache = {};
|
|
@@ -65,6 +65,8 @@ export class StorageModule_Class extends Module {
|
|
|
65
65
|
set(key, value, persist = true) {
|
|
66
66
|
if (value === undefined)
|
|
67
67
|
return this.delete(key);
|
|
68
|
+
if (this.cache[key] === value)
|
|
69
|
+
return;
|
|
68
70
|
this.cache[key] = value;
|
|
69
71
|
this.getStorage(persist).setItem(key, JSON.stringify(value));
|
|
70
72
|
// @ts-ignore
|
|
@@ -80,15 +82,13 @@ export class StorageModule_Class extends Module {
|
|
|
80
82
|
delete this.cache[key];
|
|
81
83
|
}
|
|
82
84
|
get(key, fallbackValue, persist = true) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
// this.logDebug(`get: ${key} = ${value}`)
|
|
88
|
-
if (!exists(value) || value === 'null' || value === 'undefined')
|
|
85
|
+
if (this.cache[key])
|
|
86
|
+
return deepClone(this.cache[key]);
|
|
87
|
+
const value = this.getStorage(persist).getItem(key);
|
|
88
|
+
if (!exists(value))
|
|
89
89
|
return resolveContent(fallbackValue);
|
|
90
|
-
|
|
91
|
-
return this.cache[key]
|
|
90
|
+
this.cache[key] = JSON.parse(value);
|
|
91
|
+
return deepClone(this.cache[key]);
|
|
92
92
|
}
|
|
93
93
|
query(query) {
|
|
94
94
|
const toRet = [];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Module, TypedMap } from '@nu-art/ts-common';
|
|
2
|
+
import { GenericUpdate } from '@nu-art/thunderstorm-shared';
|
|
2
3
|
type Config = {
|
|
3
4
|
appName: string;
|
|
4
5
|
themeColor: string;
|
|
@@ -26,6 +27,7 @@ declare class ModuleFE_Thunderstorm_Class extends Module<Config> {
|
|
|
26
27
|
params?: TypedMap<(() => string) | string | undefined>;
|
|
27
28
|
}, target?: UrlTarget): void;
|
|
28
29
|
downloadFile(props: FileDownloadProps): void;
|
|
30
|
+
performGenericUpdate: (updateData: GenericUpdate[]) => Promise<void>;
|
|
29
31
|
}
|
|
30
32
|
export declare const ModuleFE_Thunderstorm: ModuleFE_Thunderstorm_Class;
|
|
31
33
|
export {};
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* See the License for the specific language governing permissions and
|
|
19
19
|
* limitations under the License.
|
|
20
20
|
*/
|
|
21
|
-
import { _keys, BadImplementationException, Module } from '@nu-art/ts-common';
|
|
21
|
+
import { _keys, BadImplementationException, Module, MUSTNeverHappenException, Promise_all_sequentially, RuntimeModules } from '@nu-art/ts-common';
|
|
22
22
|
import { ModuleFE_Toaster } from '../component-modules/ModuleFE_Toaster.js';
|
|
23
23
|
import { composeURL } from './routing/ModuleFE_RoutingV2.js';
|
|
24
24
|
import { HttpMethod } from '@nu-art/thunderstorm-shared';
|
|
@@ -118,5 +118,18 @@ class ModuleFE_Thunderstorm_Class extends Module {
|
|
|
118
118
|
element.setAttribute('download', `${props.fileName}`);
|
|
119
119
|
element.click();
|
|
120
120
|
}
|
|
121
|
+
performGenericUpdate = async (updateData) => {
|
|
122
|
+
const promises = [];
|
|
123
|
+
updateData.forEach(update => {
|
|
124
|
+
const module = RuntimeModules().find(module => module.dbDef?.dbKey === update.dbKey);
|
|
125
|
+
if (!module)
|
|
126
|
+
throw new MUSTNeverHappenException(`Trying to perform a generic update without an existing module for dbKey ${update.dbKey}`);
|
|
127
|
+
if (update.data.toUpdate?.length)
|
|
128
|
+
promises.push(() => module.onEntriesUpdated(update.data.toUpdate));
|
|
129
|
+
if (update.data.toDelete?.length)
|
|
130
|
+
promises.push(() => module.onEntriesDeleted(update.data.toDelete));
|
|
131
|
+
});
|
|
132
|
+
await Promise_all_sequentially(promises);
|
|
133
|
+
};
|
|
121
134
|
}
|
|
122
135
|
export const ModuleFE_Thunderstorm = new ModuleFE_Thunderstorm_Class();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nu-art/thunderstorm-frontend",
|
|
3
|
-
"version": "0.400.
|
|
3
|
+
"version": "0.400.14",
|
|
4
4
|
"description": "Thunderstorm Frontend",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"TacB0sS",
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
"linkDirectory": true
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@nu-art/thunderstorm-shared": "0.400.
|
|
41
|
-
"@nu-art/firebase-frontend": "0.400.
|
|
42
|
-
"@nu-art/firebase-shared": "0.400.
|
|
43
|
-
"@nu-art/ts-common": "0.400.
|
|
44
|
-
"@nu-art/ts-styles": "0.400.
|
|
40
|
+
"@nu-art/thunderstorm-shared": "0.400.14",
|
|
41
|
+
"@nu-art/firebase-frontend": "0.400.14",
|
|
42
|
+
"@nu-art/firebase-shared": "0.400.14",
|
|
43
|
+
"@nu-art/ts-common": "0.400.14",
|
|
44
|
+
"@nu-art/ts-styles": "0.400.14",
|
|
45
45
|
"abort-controller": "^3.0.0",
|
|
46
46
|
"axios": "^1.13.1",
|
|
47
47
|
"body-parser": "^1.19.0",
|
package/utils/EditableItem.js
CHANGED
|
@@ -501,7 +501,7 @@ export class EditableDBItemV3 extends EditableItem {
|
|
|
501
501
|
if (this.hasValidationError())
|
|
502
502
|
return this.setStatus(EditableItemStatus_FailedValidation);
|
|
503
503
|
if (this.saveError)
|
|
504
|
-
return this.setStatus(
|
|
504
|
+
return this.setStatus(EditableItemStatus_ErrorSaving);
|
|
505
505
|
if (this.hasChanges()) {
|
|
506
506
|
return this.setStatus(EditableItemStatus_UnsavedChanges);
|
|
507
507
|
}
|
package/utils/tools.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Browser } from '@nu-art/thunderstorm-shared/consts';
|
|
2
|
+
import { DBProto } from '@nu-art/ts-common';
|
|
2
3
|
import * as React from 'react';
|
|
3
4
|
import { DependencyList, Dispatch, EffectCallback, SetStateAction } from 'react';
|
|
5
|
+
import { ModuleFE_BaseDB } from '../modules/db-api-gen/ModuleFE_BaseDB.js';
|
|
4
6
|
export declare function browserType(): Browser;
|
|
5
7
|
export declare function base64ToBlob(imageAsBase64: string): Promise<Blob>;
|
|
6
8
|
export declare function stringToArrayBuffer(stringToConvert: string): ArrayBuffer;
|
|
@@ -28,4 +30,7 @@ type MouseClickActions = {
|
|
|
28
30
|
};
|
|
29
31
|
export declare const mouseEventHandler: (e: React.MouseEvent | MouseEvent, actions: MouseClickActions) => void | undefined;
|
|
30
32
|
export declare const stringReplacer: (_content: string, _toReplace: string, replacer: (match: string, i: number) => JSX.Element) => React.ReactNode[];
|
|
33
|
+
export type EntityToResolve<P extends DBProto<any> = DBProto<any>> = string | P['dbType'] | undefined;
|
|
34
|
+
export declare const resolveId: (entity: EntityToResolve) => any;
|
|
35
|
+
export declare const resolveEntity: <P extends DBProto<any>>(module: ModuleFE_BaseDB<P>) => (entity: EntityToResolve<P>) => Readonly<P["dbType"]> | undefined;
|
|
31
36
|
export {};
|
package/utils/tools.js
CHANGED
|
@@ -136,3 +136,7 @@ export const stringReplacer = (_content, _toReplace, replacer) => {
|
|
|
136
136
|
i++;
|
|
137
137
|
}
|
|
138
138
|
};
|
|
139
|
+
export const resolveId = (entity) => typeof entity === 'string' ? entity : entity?._id;
|
|
140
|
+
export const resolveEntity = (module) => (entity) => typeof entity === 'string'
|
|
141
|
+
? module.cache.unique(entity)
|
|
142
|
+
: entity;
|