@rws-framework/client 2.16.2 → 2.17.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.
Files changed (27) hide show
  1. package/package.json +3 -5
  2. package/src/client.ts +2 -2
  3. package/src/components/_attrs/sanitize-html.ts +68 -68
  4. package/src/components/_component.ts +2 -0
  5. package/src/components/index.ts +5 -0
  6. package/src/components/loader/component.ts +2 -2
  7. package/src/components/progress/component.ts +3 -4
  8. package/src/components/reformer/component.ts +29 -0
  9. package/src/components/reformer/fields/_field.ts +14 -0
  10. package/src/components/reformer/fields/text/component.ts +9 -0
  11. package/src/components/reformer/fields/text/styles/layout.scss +5 -0
  12. package/src/components/reformer/fields/text/template.html +7 -0
  13. package/src/components/reformer/styles/layout.scss +5 -0
  14. package/src/components/reformer/template.html +7 -0
  15. package/src/components/rws-api-resource/component.ts +20 -0
  16. package/src/components/rws-api-resource/styles/layout.scss +5 -0
  17. package/src/components/rws-api-resource/template.html +3 -0
  18. package/src/components/rws-api-resource/variants/form/component.ts +11 -0
  19. package/src/components/rws-api-resource/variants/form/styles/layout.scss +0 -0
  20. package/src/components/rws-api-resource/variants/form/template.html +3 -0
  21. package/src/components/rws-api-resource/variants/list/component.ts +11 -0
  22. package/src/components/rws-api-resource/variants/list/styles/layout.scss +0 -0
  23. package/src/components/rws-api-resource/variants/list/template.html +3 -0
  24. package/src/components/uploader/component.ts +3 -1
  25. package/src/index.ts +2 -2
  26. package/src/services/DOMService.ts +2 -18
  27. package/src/types/IReFormerField.ts +5 -0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rws-framework/client",
3
3
  "private": false,
4
- "version": "2.16.2",
4
+ "version": "2.17.0",
5
5
  "main": "src/index.ts",
6
6
  "scripts": {
7
7
  "docs": "typedoc --tsconfig ./tsconfig.json"
@@ -39,8 +39,7 @@
39
39
  "moment": "^2.29.4",
40
40
  "partial-json-parser": "^1.0.0",
41
41
  "reflect-metadata": "^0.2.2",
42
- "resolve-url-loader": "^5.0.0",
43
- "sanitize-html": "^2.14.0",
42
+ "resolve-url-loader": "^5.0.0",
44
43
  "socket.io-client": "^4.7.2",
45
44
  "upload": "^1.3.2",
46
45
  "url-router": "^13.0.0",
@@ -52,8 +51,7 @@
52
51
  "@types/eslint": "^6.0.0",
53
52
  "@types/express-fileupload": "^1.4.4",
54
53
  "@types/glob": "^8.1.0",
55
- "@types/he": "^1.2.3",
56
- "@types/sanitize-html": "^2.11.0",
54
+ "@types/he": "^1.2.3",
57
55
  "@types/uuid": "^9.0.7",
58
56
  "@typescript-eslint/parser": "^5.0.0",
59
57
  "browser-sync": "^2.29.3",
package/src/client.ts CHANGED
@@ -15,7 +15,7 @@ import RWSWindow, { RWSWindowComponentRegister, loadRWSRichWindow } from './type
15
15
 
16
16
  import { DI, Container, Registration } from './components/_container';
17
17
 
18
- import RWSViewComponent, { IWithCompose } from './components/_component';
18
+ import { declareRWSComponents } from './components/index';
19
19
  import RWSContainer from './components/_container';
20
20
  import TheRWSService from './services/_service';
21
21
 
@@ -202,4 +202,4 @@ class RWSClient {
202
202
  }
203
203
 
204
204
  export default DI.createInterface<RWSClient>(x => x.singleton(RWSClient));
205
- export { RWSClient as RWSClientInstance };
205
+ export { RWSClient as RWSClientInstance, declareRWSComponents };
@@ -1,81 +1,81 @@
1
- import { Observable } from '@microsoft/fast-element';
2
- import RWSViewComponent from '../_component';
3
- import DOMService from '../../services/DOMService';
4
- import RWSContainer from '../_container';
5
- import { IOptions } from 'sanitize-html';
1
+ // import { Observable } from '@microsoft/fast-element';
2
+ // import RWSViewComponent from '../_component';
3
+ // import DOMService from '../../services/DOMService';
4
+ // import RWSContainer from '../_container';
5
+ // // import { IOptions } from 'sanitize-html';
6
6
 
7
- import * as he from 'he';
7
+ // import * as he from 'he';
8
8
 
9
- type SanitizeOptions = IOptions & { fullEncode?: boolean };
9
+ // // type SanitizeOptions = IOptions & { fullEncode?: boolean };
10
10
 
11
- const heOpt: he.EncodeOptions = {
12
- useNamedReferences: false,
13
- encodeEverything: true,
14
- };
11
+ // const heOpt: he.EncodeOptions = {
12
+ // useNamedReferences: false,
13
+ // encodeEverything: true,
14
+ // };
15
15
 
16
- function enc(html: string): string
17
- {
18
- return he.encode(html, heOpt);
19
- }
16
+ // function enc(html: string): string
17
+ // {
18
+ // return he.encode(html, heOpt);
19
+ // }
20
20
 
21
21
 
22
- const transformAnyTag = (tagName: string, attribs: { [key: string]: string }) => {
23
- // Example: Wrap the original tag with `span` and indicate the original tag name in a data attribute
24
- return {
25
- tagName: 'span', // Change this to any tag you want to transform to
26
- attribs: {
27
- ...attribs,
28
- 'data-original-tag': tagName
29
- }
30
- };
31
- };
22
+ // const transformAnyTag = (tagName: string, attribs: { [key: string]: string }) => {
23
+ // // Example: Wrap the original tag with `span` and indicate the original tag name in a data attribute
24
+ // return {
25
+ // tagName: 'span', // Change this to any tag you want to transform to
26
+ // attribs: {
27
+ // ...attribs,
28
+ // 'data-original-tag': tagName
29
+ // }
30
+ // };
31
+ // };
32
32
 
33
- function sanitizedAttr(configOrTarget?: SanitizeOptions | RWSViewComponent, prop?: string): void | any
34
- {
35
- if (arguments.length > 1) {
36
- // Decorator used directly without factory invocation
37
- // Apply the decorator immediately without returning anything
38
- applyDecorator(configOrTarget as RWSViewComponent, prop!);
39
- } else {
40
- // Decorator factory invocation
41
- const config = configOrTarget as SanitizeOptions;
42
- // Return a function that applies the decorator, conforming to TypeScript's expectations for decorator factories
43
- return (target: RWSViewComponent, property: string) => applyDecorator(target, property, config);
44
- }
45
- }
33
+ // function sanitizedAttr(configOrTarget?: SanitizeOptions | RWSViewComponent, prop?: string): void | any
34
+ // {
35
+ // if (arguments.length > 1) {
36
+ // // Decorator used directly without factory invocation
37
+ // // Apply the decorator immediately without returning anything
38
+ // applyDecorator(configOrTarget as RWSViewComponent, prop!);
39
+ // } else {
40
+ // // Decorator factory invocation
41
+ // const config = configOrTarget as SanitizeOptions;
42
+ // // Return a function that applies the decorator, conforming to TypeScript's expectations for decorator factories
43
+ // return (target: RWSViewComponent, property: string) => applyDecorator(target, property, config);
44
+ // }
45
+ // }
46
46
 
47
- function applyDecorator(target: RWSViewComponent, prop: string, config: SanitizeOptions = null): void
48
- {
49
- if(config.fullEncode){
50
- const encAllOpts = {transformTags: { '*' : transformAnyTag }, textFilter: function(text: string, tagName?: string) { return tagName ? `${enc('<')}${tagName}${enc('>')}${text}${enc('</')}${tagName}${enc('>')}` : text; }};
51
- config = {...config, ...encAllOpts};
52
- delete config.fullEncode;
53
- }
47
+ // function applyDecorator(target: RWSViewComponent, prop: string, config: SanitizeOptions = null): void
48
+ // {
49
+ // if(config.fullEncode){
50
+ // const encAllOpts = {transformTags: { '*' : transformAnyTag }, textFilter: function(text: string, tagName?: string) { return tagName ? `${enc('<')}${tagName}${enc('>')}${text}${enc('</')}${tagName}${enc('>')}` : text; }};
51
+ // config = {...config, ...encAllOpts};
52
+ // delete config.fullEncode;
53
+ // }
54
54
 
55
- modifyPropertyDescriptor(target, prop, config as IOptions);
56
- }
55
+ // modifyPropertyDescriptor(target, prop, config as IOptions);
56
+ // }
57
57
 
58
- function modifyPropertyDescriptor(target: any, propertyKey: string, config: IOptions = null): void {
59
- const privatePropName = `_${String(propertyKey)}`;
60
- Object.defineProperty(target, privatePropName, {
61
- writable: true,
62
- value: target[propertyKey],
63
- });
58
+ // function modifyPropertyDescriptor(target: any, propertyKey: string, config: IOptions = null): void {
59
+ // const privatePropName = `_${String(propertyKey)}`;
60
+ // Object.defineProperty(target, privatePropName, {
61
+ // writable: true,
62
+ // value: target[propertyKey],
63
+ // });
64
64
 
65
- Object.defineProperty(target, propertyKey, {
66
- get() {
67
- return this[privatePropName];
68
- },
69
- set(value: any) {
70
- if (typeof value === 'string') {
71
- this[privatePropName] = RWSContainer().get(DOMService).sanitizeHTML(value, null, config);
72
- } else {
73
- this[privatePropName] = null;
74
- }
75
- Observable.notify(this, propertyKey);
76
- },
77
- });
78
- }
65
+ // Object.defineProperty(target, propertyKey, {
66
+ // get() {
67
+ // return this[privatePropName];
68
+ // },
69
+ // set(value: any) {
70
+ // if (typeof value === 'string') {
71
+ // this[privatePropName] = RWSContainer().get(DOMService).sanitizeHTML(value, null, config);
72
+ // } else {
73
+ // this[privatePropName] = null;
74
+ // }
75
+ // Observable.notify(this, propertyKey);
76
+ // },
77
+ // });
78
+ // }
79
79
 
80
80
 
81
- export { sanitizedAttr };
81
+ // export { sanitizedAttr };
@@ -240,6 +240,8 @@ abstract class RWSViewComponent extends FoundationElement implements IRWSViewCom
240
240
 
241
241
  export default RWSViewComponent;
242
242
 
243
+ export { RWSViewComponent };
244
+
243
245
  export type {
244
246
  IAssetShowOptions,
245
247
  IRWSViewComponent
@@ -1,6 +1,8 @@
1
1
  import { RWSUploader } from './uploader/component';
2
2
  import { RWSProgress } from './progress/component';
3
3
  import { RWSLoader } from './loader/component';
4
+ import { RWSApiResource } from './rws-api-resource/component';
5
+ import { ReFormer } from './reformer/component';
4
6
 
5
7
 
6
8
  function declareRWSComponents(parted: boolean = false): void
@@ -9,6 +11,9 @@ function declareRWSComponents(parted: boolean = false): void
9
11
  RWSUploader;
10
12
  RWSProgress;
11
13
  RWSLoader;
14
+
15
+ RWSApiResource;
16
+ ReFormer;
12
17
  }
13
18
  }
14
19
 
@@ -1,8 +1,8 @@
1
- import { RWSView, RWSViewComponent } from '../../index';
1
+ import { RWSView } from '../_decorator';
2
+ import { RWSViewComponent } from '../_component';
2
3
 
3
4
  @RWSView('the-loader')
4
5
  class RWSLoader extends RWSViewComponent {
5
-
6
6
  connectedCallback(): void {
7
7
  super.connectedCallback();
8
8
  }
@@ -1,7 +1,6 @@
1
- import { RWSView, RWSViewComponent, observable, attr } from '../../index';
2
- import {
3
- nullableNumberConverter,
4
- } from '@microsoft/fast-element';
1
+ import { observable, attr, nullableNumberConverter } from '@microsoft/fast-element';
2
+ import { RWSView } from '../_decorator';
3
+ import { RWSViewComponent } from '../_component';
5
4
 
6
5
  @RWSView('rws-progress', { debugPackaging: false })
7
6
  class RWSProgress extends RWSViewComponent {
@@ -0,0 +1,29 @@
1
+ import { observable, attr } from '@microsoft/fast-element';
2
+ import { IKDBTypesResponse } from '../../types/IBackendCore';
3
+ import { RWSViewComponent} from '../_component';
4
+ import { RWSView} from '../_decorator';
5
+ import { ReFormerText } from './fields/text/component';
6
+
7
+ ReFormerText;
8
+
9
+ @RWSView('rws-reformer')
10
+ class ReFormer extends RWSViewComponent {
11
+ @attr resourceName: string;
12
+
13
+ @observable fields: string[] | null = null;
14
+ @observable modelTypes: IKDBTypesResponse;
15
+
16
+ async connectedCallback(): Promise<void>
17
+ {
18
+ this.modelTypes = await this.apiService.getResource(this.resourceName);
19
+ }
20
+
21
+ setForm(key: string, val: any)
22
+ {
23
+ console.log('set reformer form', {key, val});
24
+ }
25
+ }
26
+
27
+ ReFormer.defineComponent();
28
+
29
+ export { ReFormer };
@@ -0,0 +1,14 @@
1
+ import { observable, attr } from "@microsoft/fast-element";
2
+ import RWSViewComponent from "../../_component";
3
+ import { IReFormerField } from "../../../types/IReFormerField";
4
+
5
+ export abstract class ReFormerFieldComponent extends RWSViewComponent implements IReFormerField {
6
+ @attr name: string;
7
+ @observable defaultValue: any;
8
+ @observable setForm: (field: string, value: any) => Promise<void>;
9
+
10
+ changeField(key: string, value: any)
11
+ {
12
+ this.setForm(key, value);
13
+ }
14
+ }
@@ -0,0 +1,9 @@
1
+ import { RWSView} from '../../../_decorator';
2
+ import { ReFormerFieldComponent } from '../_field';
3
+
4
+ @RWSView('reformer-text')
5
+ class ReFormerText extends ReFormerFieldComponent {}
6
+
7
+ ReFormerText.defineComponent();
8
+
9
+ export { ReFormerText };
@@ -0,0 +1,5 @@
1
+ @import "@rws-mixins";
2
+
3
+ .re-former-text-input {
4
+ display: flex;
5
+ }
@@ -0,0 +1,7 @@
1
+ <sl-input
2
+ type="text"
3
+ name="${ x => x.name}"
4
+ id="re-former-field-${x.name}"
5
+ value="${x => x.defaultValue}"
6
+ @change="${(x,c) => x.changeField(x.name, c.event.target)}"
7
+ ></sl-input>
@@ -0,0 +1,5 @@
1
+ @import "@rws-mixins";
2
+
3
+ .re-former-container {
4
+ display: flex;
5
+ }
@@ -0,0 +1,7 @@
1
+ <div class="re-former-container">
2
+ ${T.repeat(x => x.modelTypes.data.types, T.html`<div class="form-field">
3
+ ${T.when(x => x.type === 'String', T.html`
4
+ <re-former-text :setForm="${x => x.setForm.bind(x)}" name="${x => x.fieldName}"></re-former-text>
5
+ `)}
6
+ </div>`)}
7
+ </div>
@@ -0,0 +1,20 @@
1
+ import { IKDBTypeInfo, IKDBTypesResponse } from '../../types/IBackendCore';
2
+ import { observable, attr } from '@microsoft/fast-element';
3
+ import { RWSView } from '../_decorator';
4
+ import { RWSViewComponent } from '../_component';
5
+ import { RWSResourceListComponent } from './variants/list/component';
6
+ import { RWSResourceFormComponent } from './variants/form/component';
7
+ import { IRWSResourceQuery } from '../../types/IRWSResource';
8
+
9
+
10
+ RWSResourceListComponent;
11
+ RWSResourceFormComponent;
12
+
13
+ @RWSView('rws-resource')
14
+ class RWSApiResource extends RWSViewComponent {
15
+ @observable dbModelData: IKDBTypesResponse;
16
+ }
17
+
18
+ RWSApiResource.defineComponent();
19
+
20
+ export { RWSApiResource };
@@ -0,0 +1,5 @@
1
+ @import "@rws-mixins";
2
+
3
+ .rws-api-container {
4
+
5
+ }
@@ -0,0 +1,3 @@
1
+ <div class="rws-api-container">
2
+
3
+ </div>
@@ -0,0 +1,11 @@
1
+ import { RWSViewComponent} from '../../../_component';
2
+ import { RWSView} from '../../../_decorator';
3
+
4
+
5
+ @RWSView('rws-resource-form')
6
+ class RWSResourceFormComponent extends RWSViewComponent {
7
+ }
8
+
9
+ RWSResourceFormComponent.defineComponent();
10
+
11
+ export { RWSResourceFormComponent };
@@ -0,0 +1,3 @@
1
+ <div id="resource-form">
2
+
3
+ </div>
@@ -0,0 +1,11 @@
1
+ import { RWSViewComponent} from '../../../_component';
2
+ import { RWSView} from '../../../_decorator';
3
+
4
+
5
+ @RWSView('rws-resource-list')
6
+ class RWSResourceListComponent extends RWSViewComponent {
7
+ }
8
+
9
+ RWSResourceListComponent.defineComponent();
10
+
11
+ export { RWSResourceListComponent };
@@ -0,0 +1,3 @@
1
+ <div id="resource-list">
2
+
3
+ </div>
@@ -1,4 +1,6 @@
1
- import { RWSView, RWSViewComponent, observable, attr } from '../../index';
1
+ import { observable, attr } from '@microsoft/fast-element';
2
+ import { RWSView } from '../_decorator';
3
+ import { RWSViewComponent } from '../_component';
2
4
 
3
5
  @RWSView('rws-uploader')
4
6
  class RWSUploader extends RWSViewComponent {
package/src/index.ts CHANGED
@@ -13,7 +13,7 @@ import type { IBackendRoute, IHTTProute, IPrefixedHTTProutes } from './services/
13
13
 
14
14
  import UtilsService, {UtilsServiceInstance} from './services/UtilsService';
15
15
  import ServiceWorkerService, { ServiceWorkerServiceInstance } from './services/ServiceWorkerService';
16
- import { sanitizedAttr } from './components/_attrs/sanitize-html';
16
+ // import { sanitizedAttr } from './components/_attrs/sanitize-html';
17
17
  import { ngAttr } from './components/_attrs/angular-attr';
18
18
  import { externalObservable } from './components/_attrs/external-observable';
19
19
  import { externalAttr } from './components/_attrs/external-attr';
@@ -80,7 +80,7 @@ export {
80
80
  RWSNotify,
81
81
 
82
82
  RWSView,
83
- sanitizedAttr,
83
+ // sanitizedAttr,
84
84
  RWSIgnore,
85
85
  RWSInject,
86
86
  observable,
@@ -1,6 +1,6 @@
1
1
  import RWSService from './_service';
2
2
  import { DOM } from '@microsoft/fast-element';
3
- import htmlSanitizer, { Transformer, IOptions } from 'sanitize-html';
3
+ // import htmlSanitizer, { Transformer, IOptions } from 'sanitize-html';
4
4
 
5
5
  type TagsProcessorType = { [tagName: string]: string | Transformer };
6
6
  type DOMOutputType<T extends Element> = NodeListOf<T> | T | null;
@@ -67,23 +67,7 @@ class DOMService extends RWSService {
67
67
  });
68
68
 
69
69
  return sanitizedText;
70
- }
71
-
72
- sanitizeHTML(
73
- line: string,
74
- allowedHTMLTags: string[] = null,
75
- sanitizeOptions: IOptions = {})
76
- {
77
- const output: string = line.trim();
78
-
79
- if(allowedHTMLTags){
80
- sanitizeOptions.allowedTags = allowedHTMLTags;
81
- }
82
-
83
- const sanitized = htmlSanitizer(output, sanitizeOptions);
84
-
85
- return sanitized;
86
- }
70
+ }
87
71
 
88
72
  async onDOMLoad(): Promise<void>
89
73
  {
@@ -0,0 +1,5 @@
1
+ export interface IReFormerField {
2
+ name: string,
3
+ defaultValue?: any,
4
+ setForm: (field: string, value: any) => Promise<void>
5
+ }