@nu-art/live-docs-frontend 0.400.7
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/core/module-pack.d.ts +2 -0
- package/core/module-pack.js +22 -0
- package/index.d.ts +3 -0
- package/index.js +21 -0
- package/modules/ModuleFE_LiveDocs.d.ts +17 -0
- package/modules/ModuleFE_LiveDocs.js +50 -0
- package/package.json +77 -0
- package/ui/LiveDoc.d.ts +17 -0
- package/ui/LiveDoc.js +37 -0
- package/utils.d.ts +3 -0
- package/utils.js +51 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Live-Docs will allow you to add and edit tool-tips from within your app...
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2020 Adam van der Kruk aka TacB0sS
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
import { ModuleFE_LiveDocs } from '../modules/ModuleFE_LiveDocs.js';
|
|
19
|
+
export const ModulePack_Frontend_LiveDocs = [
|
|
20
|
+
ModuleFE_LiveDocs
|
|
21
|
+
];
|
|
22
|
+
export * from '../modules/ModuleFE_LiveDocs.js';
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Permissions management system, define access level for each of
|
|
3
|
+
* your server apis, and restrict users by giving them access levels
|
|
4
|
+
*
|
|
5
|
+
* Copyright (C) 2020 Adam van der Kruk aka TacB0sS
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
export * from "./core/module-pack.js";
|
|
20
|
+
export * from "./ui/LiveDoc.js";
|
|
21
|
+
export * from "./utils.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Module } from '@nu-art/ts-common';
|
|
2
|
+
import { ToastBuilder } from '@nu-art/thunderstorm-frontend/index';
|
|
3
|
+
import { DB_Document, LiveDocReqParams } from '@nu-art/live-docs-shared';
|
|
4
|
+
import { ApiStruct_LiveDoc } from '@nu-art/live-docs-shared/api';
|
|
5
|
+
import { ApiDefCaller } from '@nu-art/thunderstorm-shared';
|
|
6
|
+
export type LiveDocActionResolver = (doc: DB_Document) => ToastBuilder;
|
|
7
|
+
export declare class ModuleFE_LiveDocs_Class extends Module implements ApiDefCaller<ApiStruct_LiveDoc> {
|
|
8
|
+
private docs;
|
|
9
|
+
private toasterResolver;
|
|
10
|
+
readonly v1: ApiDefCaller<ApiStruct_LiveDoc>['v1'];
|
|
11
|
+
constructor();
|
|
12
|
+
protected init(): void;
|
|
13
|
+
onGotDoc: (response: DB_Document, params: LiveDocReqParams) => Promise<void>;
|
|
14
|
+
get(key: string): DB_Document;
|
|
15
|
+
setActionsResolver(resolver: LiveDocActionResolver): void;
|
|
16
|
+
}
|
|
17
|
+
export declare const ModuleFE_LiveDocs: ModuleFE_LiveDocs_Class;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Live-Docs will allow you to add and edit tool-tips from within your app...
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2020 Adam van der Kruk aka TacB0sS
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
import { Module } from '@nu-art/ts-common';
|
|
19
|
+
import { apiWithBody, apiWithQuery } from '@nu-art/thunderstorm-frontend/index';
|
|
20
|
+
import { ApiDef_LiveDoc } from '@nu-art/live-docs-shared/api';
|
|
21
|
+
import { DefaultLiveDocEditor } from '../utils.js';
|
|
22
|
+
export class ModuleFE_LiveDocs_Class extends Module {
|
|
23
|
+
docs = {};
|
|
24
|
+
toasterResolver = DefaultLiveDocEditor;
|
|
25
|
+
v1;
|
|
26
|
+
constructor() {
|
|
27
|
+
super();
|
|
28
|
+
this.v1 = {
|
|
29
|
+
get: apiWithQuery(ApiDef_LiveDoc.v1.get, this.onGotDoc),
|
|
30
|
+
upsert: apiWithBody(ApiDef_LiveDoc.v1.upsert, this.onGotDoc),
|
|
31
|
+
history: apiWithQuery(ApiDef_LiveDoc.v1.history, this.onGotDoc),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
init() {
|
|
35
|
+
}
|
|
36
|
+
onGotDoc = async (response, params) => {
|
|
37
|
+
const _doc = this.docs[params.key];
|
|
38
|
+
if (_doc && response.document === _doc.document)
|
|
39
|
+
return;
|
|
40
|
+
this.docs[params.key] = response;
|
|
41
|
+
this.toasterResolver(response).show();
|
|
42
|
+
};
|
|
43
|
+
get(key) {
|
|
44
|
+
return this.docs[key];
|
|
45
|
+
}
|
|
46
|
+
setActionsResolver(resolver) {
|
|
47
|
+
this.toasterResolver = resolver;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export const ModuleFE_LiveDocs = new ModuleFE_LiveDocs_Class();
|
package/package.json
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nu-art/live-docs-frontend",
|
|
3
|
+
"version": "0.400.7",
|
|
4
|
+
"description": "Live docs Frontend",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"TacB0sS",
|
|
7
|
+
"express",
|
|
8
|
+
"infra",
|
|
9
|
+
"live-docs",
|
|
10
|
+
"nu-art",
|
|
11
|
+
"thunderstorm",
|
|
12
|
+
"typescript"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://github.com/nu-art-js/thunderstorm",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/nu-art-js/thunderstorm/issues"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+ssh://git@github.com:nu-art-js/live-docs.git"
|
|
21
|
+
},
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"directory": "dist",
|
|
24
|
+
"linkDirectory": true
|
|
25
|
+
},
|
|
26
|
+
"license": "Apache-2.0",
|
|
27
|
+
"author": "TacB0sS",
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsc"
|
|
30
|
+
},
|
|
31
|
+
"contributors": [
|
|
32
|
+
{
|
|
33
|
+
"name": "TacB0sS"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"name": "Cipher",
|
|
37
|
+
"url": "https://www.linkedin.com/in/itay-leybovich-470b87229/"
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@nu-art/live-docs-shared": "0.400.7",
|
|
42
|
+
"@nu-art/firebase-frontend": "0.400.7",
|
|
43
|
+
"@nu-art/firebase-shared": "0.400.7",
|
|
44
|
+
"@nu-art/thunderstorm-frontend": "0.400.7",
|
|
45
|
+
"@nu-art/thunderstorm-shared": "0.400.7",
|
|
46
|
+
"@nu-art/ts-common": "0.400.7",
|
|
47
|
+
"express": "^4.18.2",
|
|
48
|
+
"firebase": "^11.9.0",
|
|
49
|
+
"firebase-admin": "13.4.0",
|
|
50
|
+
"firebase-functions": "6.3.2",
|
|
51
|
+
"moment": "^2.29.4",
|
|
52
|
+
"react": "^18.0.0",
|
|
53
|
+
"react-dom": "^18.0.0",
|
|
54
|
+
"react-router-dom": "^6.9.0",
|
|
55
|
+
"request": "^2.88.0"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@types/react": "^18.0.0",
|
|
59
|
+
"@types/express": "^4.17.17",
|
|
60
|
+
"@types/history": "^4.7.2",
|
|
61
|
+
"@types/request": "^2.48.1"
|
|
62
|
+
},
|
|
63
|
+
"unitConfig": {
|
|
64
|
+
"type": "typescript-lib"
|
|
65
|
+
},
|
|
66
|
+
"type": "module",
|
|
67
|
+
"exports": {
|
|
68
|
+
".": {
|
|
69
|
+
"types": "./index.d.ts",
|
|
70
|
+
"import": "./index.js"
|
|
71
|
+
},
|
|
72
|
+
"./*": {
|
|
73
|
+
"types": "./*.d.ts",
|
|
74
|
+
"import": "./*.js"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
package/ui/LiveDoc.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
type State = {
|
|
3
|
+
edit?: boolean;
|
|
4
|
+
};
|
|
5
|
+
type Props = {
|
|
6
|
+
docKey: string;
|
|
7
|
+
component?: React.ReactNode;
|
|
8
|
+
duration?: number;
|
|
9
|
+
};
|
|
10
|
+
export declare class LiveDoc extends React.Component<Props, State> {
|
|
11
|
+
static defaultProps: {
|
|
12
|
+
component: string;
|
|
13
|
+
};
|
|
14
|
+
constructor(props: Props);
|
|
15
|
+
render(): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
package/ui/LiveDoc.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Live-Docs will allow you to add and edit tool-tips from within your app...
|
|
4
|
+
*
|
|
5
|
+
* Copyright (C) 2020 Adam van der Kruk aka TacB0sS
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
import * as React from 'react';
|
|
20
|
+
import { ModuleFE_LiveDocs } from '../modules/ModuleFE_LiveDocs.js';
|
|
21
|
+
const showLiveDoc = (e) => {
|
|
22
|
+
const key = e.currentTarget.id;
|
|
23
|
+
ModuleFE_LiveDocs.v1.get({ key }).execute();
|
|
24
|
+
};
|
|
25
|
+
export class LiveDoc extends React.Component {
|
|
26
|
+
static defaultProps = {
|
|
27
|
+
component: '?'
|
|
28
|
+
};
|
|
29
|
+
constructor(props) {
|
|
30
|
+
super(props);
|
|
31
|
+
this.state = {};
|
|
32
|
+
}
|
|
33
|
+
render() {
|
|
34
|
+
const Component = this.props.component;
|
|
35
|
+
return (_jsx("div", { className: `clickable`, id: this.props.docKey, style: { display: 'inline-block' }, onClick: showLiveDoc, children: Component || 'Click Here' }));
|
|
36
|
+
}
|
|
37
|
+
}
|
package/utils.d.ts
ADDED
package/utils.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Live-Docs will allow you to add and edit tool-tips from within your app...
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2020 Adam van der Kruk aka TacB0sS
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
// import * as React from 'react';
|
|
19
|
+
import { ToastBuilder } from '@nu-art/thunderstorm-frontend/index';
|
|
20
|
+
export const DefaultLiveDocEditor = (doc) => {
|
|
21
|
+
return new ToastBuilder().setContent(doc.document.length === 0 ? `No Content for document with key: ${doc.document}` : doc.document);
|
|
22
|
+
// .setActions(
|
|
23
|
+
// [<button style={{marginRight: 8}} onClick={() => showEditModalExample(docKey)}>Edit</button>]);
|
|
24
|
+
};
|
|
25
|
+
export const showEditModalExample = (docKey) => {
|
|
26
|
+
// const title = "Default Edit modal";
|
|
27
|
+
//
|
|
28
|
+
// const doc = LiveDocsModule.get(docKey);
|
|
29
|
+
//
|
|
30
|
+
// const originalDoc = doc.document;
|
|
31
|
+
// const content = <TS_TextArea id={`livedoc-${docKey}`} type="text" style={{height: "110px", margin: "8px", width: "100%", outline: "none"}}
|
|
32
|
+
// value={doc.document}
|
|
33
|
+
// onChange={(value: string) => {
|
|
34
|
+
// doc.document = value;
|
|
35
|
+
// ModuleFE_Toaster.toastInfo(doc.document);
|
|
36
|
+
// }}/>;
|
|
37
|
+
// new Dialog_Builder(content)
|
|
38
|
+
// .setTitle(title)
|
|
39
|
+
// .setStyle({maxWidth: "400px", width: "350px", height: "220px"})
|
|
40
|
+
// .addButton(DialogButton_Cancel(() => {
|
|
41
|
+
// doc.document = originalDoc;
|
|
42
|
+
// ModuleFE_Dialog.close();
|
|
43
|
+
// }))
|
|
44
|
+
// .addButton(DialogButton_Save(() => {
|
|
45
|
+
// const liveDoc: Request_UpdateDocument = {key: docKey, document: doc.document};
|
|
46
|
+
// LiveDocsModule.update(liveDoc);
|
|
47
|
+
// ModuleFE_Dialog.close();
|
|
48
|
+
// }))
|
|
49
|
+
// .setOverlayColor("rgba(102, 255, 255, 0.4)")
|
|
50
|
+
// .show();
|
|
51
|
+
};
|