@rws-framework/client 2.17.0 → 2.17.2

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 (50) hide show
  1. package/builder/webpack/rws.webpack.config.js +8 -10
  2. package/cfg/build_steps/webpack/_aliases.js +24 -6
  3. package/cfg/build_steps/webpack/_build_config.js +5 -3
  4. package/cfg/build_steps/webpack/_env_defines.js +0 -2
  5. package/cfg/build_steps/webpack/_hot_reload.js +14 -0
  6. package/cfg/build_steps/webpack/_loaders.js +0 -1
  7. package/cfg/build_steps/webpack/_plugins.js +0 -10
  8. package/cfg/build_steps/webpack/_webpack_config.js +10 -2
  9. package/package.json +1 -1
  10. package/src/client/config.ts +13 -1
  11. package/src/client/hotReload.ts +23 -0
  12. package/src/client.ts +4 -0
  13. package/src/components/index.ts +9 -5
  14. package/src/components/{loader → rws/loader}/component.ts +2 -2
  15. package/src/components/{progress → rws/progress}/component.ts +2 -2
  16. package/src/components/{reformer → rws/reformer}/component.ts +3 -3
  17. package/src/components/{reformer → rws/reformer}/fields/_field.ts +2 -2
  18. package/src/components/{reformer → rws/reformer}/fields/text/component.ts +1 -1
  19. package/src/components/rws/rws-api-resource/component.ts +55 -0
  20. package/src/components/rws/rws-api-resource/template.html +13 -0
  21. package/src/components/rws/rws-api-resource/variants/form/component.ts +11 -0
  22. package/src/components/rws/rws-api-resource/variants/list/component.ts +11 -0
  23. package/src/components/rws/rws-modal/component.ts +15 -0
  24. package/src/components/rws/rws-modal/styles/layout.scss +47 -0
  25. package/src/components/rws/rws-modal/template.html +11 -0
  26. package/src/components/rws/rws-table/component.ts +85 -0
  27. package/src/components/rws/rws-table/styles/layout.scss +73 -0
  28. package/src/components/rws/rws-table/template.html +27 -0
  29. package/src/components/{uploader → rws/uploader}/component.ts +2 -2
  30. package/src/index.ts +31 -37
  31. package/src/types/IRWSConfig.ts +2 -0
  32. package/src/components/rws-api-resource/component.ts +0 -20
  33. package/src/components/rws-api-resource/template.html +0 -3
  34. package/src/components/rws-api-resource/variants/form/component.ts +0 -11
  35. package/src/components/rws-api-resource/variants/list/component.ts +0 -11
  36. /package/src/components/{loader → rws/loader}/styles/layout.scss +0 -0
  37. /package/src/components/{loader → rws/loader}/template.html +0 -0
  38. /package/src/components/{progress → rws/progress}/styles/layout.scss +0 -0
  39. /package/src/components/{progress → rws/progress}/template.html +0 -0
  40. /package/src/components/{reformer → rws/reformer}/fields/text/styles/layout.scss +0 -0
  41. /package/src/components/{reformer → rws/reformer}/fields/text/template.html +0 -0
  42. /package/src/components/{reformer → rws/reformer}/styles/layout.scss +0 -0
  43. /package/src/components/{reformer → rws/reformer}/template.html +0 -0
  44. /package/src/components/{rws-api-resource → rws/rws-api-resource}/styles/layout.scss +0 -0
  45. /package/src/components/{rws-api-resource → rws/rws-api-resource}/variants/form/styles/layout.scss +0 -0
  46. /package/src/components/{rws-api-resource → rws/rws-api-resource}/variants/form/template.html +0 -0
  47. /package/src/components/{rws-api-resource → rws/rws-api-resource}/variants/list/styles/layout.scss +0 -0
  48. /package/src/components/{rws-api-resource → rws/rws-api-resource}/variants/list/template.html +0 -0
  49. /package/src/components/{uploader → rws/uploader}/styles/layout.scss +0 -0
  50. /package/src/components/{uploader → rws/uploader}/template.html +0 -0
@@ -28,7 +28,6 @@ const RWSWebpackWrapper = async (appRoot, rwsFrontendConfig, _packageDir) => {
28
28
  executionDir,
29
29
  isWatcher,
30
30
  isDev,
31
- isHotReload,
32
31
  isReport,
33
32
  isParted,
34
33
  partedPrefix,
@@ -45,7 +44,9 @@ const RWSWebpackWrapper = async (appRoot, rwsFrontendConfig, _packageDir) => {
45
44
  devRouteProxy,
46
45
  tsConfig,
47
46
  rwsPlugins,
48
- BuildConfigurator
47
+ BuildConfigurator,
48
+ hotReload,
49
+ hotReloadPort
49
50
  } = await getBuildConfig(rwsFrontendConfig, _packageDir);
50
51
 
51
52
  timeLog({ devDebug });
@@ -58,7 +59,7 @@ const RWSWebpackWrapper = async (appRoot, rwsFrontendConfig, _packageDir) => {
58
59
  buildInfo.start(executionDir, tsConfig, outputDir, isDev, publicDir, isParted, partedPrefix, partedDirUrlPrefix, devTools, rwsFrontendConfig.rwsPlugins);
59
60
 
60
61
  // #SECTION INIT PLUGINS && ENV VARS DEFINES
61
- addStartPlugins(rwsFrontendConfig, BuildConfigurator, devDebug, isHotReload, isReport);
62
+ addStartPlugins(rwsFrontendConfig, BuildConfigurator, devDebug, hotReload, isReport);
62
63
 
63
64
  const WEBPACK_AFTER_ACTIONS = rwsFrontendConfig.actions || [];
64
65
  const WEBPACK_AFTER_ERROR_ACTIONS = rwsFrontendConfig.error_actions || [];
@@ -66,7 +67,7 @@ const RWSWebpackWrapper = async (appRoot, rwsFrontendConfig, _packageDir) => {
66
67
  const modules_setup = [path.join(_packageDir, 'node_modules'), path.join(executionDir, 'node_modules'), path.join(tools.findRootWorkspacePath(appRoot), 'node_modules')];
67
68
  let optimConfig = null;
68
69
  let aliases = rwsFrontendConfig.aliases || {};
69
- aliases = { ...aliases, ...loadAliases(_packageDir, tsConfig,path.resolve(_MAIN_PACKAGE, 'node_modules'), executionDir) }
70
+ aliases = { ...aliases, ...(await loadAliases(_packageDir, tsConfig,path.resolve(_MAIN_PACKAGE, 'node_modules'), executionDir))}
70
71
 
71
72
  // #SECTION PLUGIN STARTING HOOKS
72
73
 
@@ -131,7 +132,9 @@ const RWSWebpackWrapper = async (appRoot, rwsFrontendConfig, _packageDir) => {
131
132
  rwsExternals,
132
133
  devExternalsVars,
133
134
  appRootDir: appRoot,
134
- entrypoint: rwsFrontendConfig.entrypoint
135
+ entrypoint: rwsFrontendConfig.entrypoint,
136
+ hotReload,
137
+ hotReloadPort
135
138
  });
136
139
 
137
140
  if (optimConfig) {
@@ -145,11 +148,6 @@ const RWSWebpackWrapper = async (appRoot, rwsFrontendConfig, _packageDir) => {
145
148
  await plugin.onBuild(cfgExport);
146
149
  }
147
150
 
148
- if (isDev) {
149
- // #SECTION RWS DEV SERVERS
150
- webpackDevServer(BuildConfigurator, rwsFrontendConfig, cfgExport);
151
- }
152
-
153
151
  return cfgExport;
154
152
  }
155
153
 
@@ -1,6 +1,12 @@
1
1
  const path = require('path');
2
+ const fs = require('fs');
2
3
 
3
- function loadAliases(packageDir, tsConfig, nodeModulesPath, executionDir){
4
+ const packageNames = [
5
+ 'client',
6
+ 'nest-interconnectors'
7
+ ];
8
+
9
+ async function loadAliases(packageDir, tsConfig, nodeModulesPath, executionDir){
4
10
 
5
11
  const tsPaths = {}
6
12
 
@@ -8,14 +14,26 @@ function loadAliases(packageDir, tsConfig, nodeModulesPath, executionDir){
8
14
  const alias = tsConfig.config.compilerOptions.paths[aliasKey];
9
15
  tsPaths[aliasKey] = path.resolve(executionDir, alias[0]);
10
16
  }
11
-
17
+
18
+ for(const pkgName of packageNames){
19
+ const symlinkPath = path.join(nodeModulesPath, '@rws-framework', pkgName);
20
+
21
+ if(fs.existsSync(symlinkPath)){
22
+ const pkgDirStat = fs.lstatSync(symlinkPath);
23
+
24
+ if(pkgDirStat.isSymbolicLink()){
25
+ const targetPath = await fs.promises.realpath(symlinkPath);
26
+
27
+ tsPaths['@rws-framework/' + pkgName + '/*'] = targetPath + '/*';
28
+ tsPaths['@rws-framework/' + pkgName] = targetPath + '/src/index.ts';
29
+ }
30
+ }
31
+ }
32
+
12
33
  return {
13
34
  ...tsPaths,
14
35
  '@rws-framework/foundation': path.resolve(packageDir, 'foundation', 'rws-foundation.js'),
15
- '@rws-framework/foundation/*': path.resolve(packageDir, 'foundation', '*'),
16
- // 'entities/lib/maps/entities.json': path.resolve(nodeModulesPath, 'entities/lib/maps/entities.json'),
17
- // 'entities/lib/maps/legacy.json': path.resolve(nodeModulesPath, 'entities/lib/maps/legacy.json'),
18
- // 'entities/lib/maps/xml.json': path.resolve(nodeModulesPath, 'entities/lib/maps/xml.json')
36
+ '@rws-framework/foundation/*': path.resolve(packageDir, 'foundation', '*'),
19
37
  }
20
38
  }
21
39
 
@@ -12,9 +12,10 @@ async function getBuildConfig(rwsFrontBuildConfig, _packageDir){
12
12
  const isWatcher = process.argv.includes('--watch') || false;
13
13
 
14
14
  const isDev = isWatcher ? true : (BuildConfigurator.get('dev', rwsFrontBuildConfig.dev) || false);
15
- const isHotReload = BuildConfigurator.get('hotReload', rwsFrontBuildConfig.hotReload);
16
15
  const isReport = BuildConfigurator.get('pkgReport', rwsFrontBuildConfig.pkgReport);
17
16
  const isParted = BuildConfigurator.get('parted', rwsFrontBuildConfig.parted || false);
17
+ const hotReload = BuildConfigurator.get('hotReload', rwsFrontBuildConfig.hotReload || false);
18
+ const hotReloadPort = BuildConfigurator.get('hotReloadtPort', rwsFrontBuildConfig.hotReloadPort || 1030);
18
19
 
19
20
  const partedPrefix = BuildConfigurator.get('partedPrefix', rwsFrontBuildConfig.partedPrefix);
20
21
  const partedDirUrlPrefix = BuildConfigurator.get('partedDirUrlPrefix', rwsFrontBuildConfig.partedDirUrlPrefix);
@@ -53,7 +54,6 @@ async function getBuildConfig(rwsFrontBuildConfig, _packageDir){
53
54
  executionDir,
54
55
  isWatcher,
55
56
  isDev,
56
- isHotReload,
57
57
  isReport,
58
58
  isParted,
59
59
  partedPrefix,
@@ -70,7 +70,9 @@ async function getBuildConfig(rwsFrontBuildConfig, _packageDir){
70
70
  devRouteProxy,
71
71
  tsConfig,
72
72
  rwsPlugins,
73
- BuildConfigurator
73
+ BuildConfigurator,
74
+ hotReload,
75
+ hotReloadPort
74
76
  }
75
77
  }
76
78
 
@@ -17,8 +17,6 @@ function processEnvDefines(BuildConfigurator, config, devDebug) {
17
17
  _rws_defines = { ..._rws_defines, ...stringifiedDefines }
18
18
  }
19
19
 
20
- console.log({_rws_defines});
21
-
22
20
  return _rws_defines;
23
21
  }
24
22
 
@@ -0,0 +1,14 @@
1
+ function getRWSHotReloadSetup(port, outputDir){
2
+ return {
3
+ hot: true,
4
+ port,
5
+ static: {
6
+ directory: outputDir,
7
+ },
8
+ devMiddleware: {
9
+ publicPath: '/'
10
+ }
11
+ }
12
+ }
13
+
14
+ module.exports = { getRWSHotReloadSetup };
@@ -89,7 +89,6 @@ function getRWSLoaders(packageDir, executionDir, tsConfigData, appRootDir, entry
89
89
  },
90
90
  ];
91
91
 
92
-
93
92
  return loaders;
94
93
  }
95
94
 
@@ -78,16 +78,6 @@ function addStartPlugins(rwsFrontendConfig, BuildConfigurator, devDebug, isHotRe
78
78
  ...getPackageModPlugins()
79
79
  ]);
80
80
 
81
- if (isHotReload) {
82
- if (!publicDir) {
83
- throw new Error('No public dir set')
84
- }
85
-
86
- RWS_WEBPACK_PLUGINS_BAG.add(new HtmlWebpackPlugin({
87
- template: path.join(publicDir, '/', publicIndex),
88
- }));
89
- }
90
-
91
81
  const overridePlugins = rwsFrontendConfig.plugins || []
92
82
 
93
83
  RWS_WEBPACK_PLUGINS_BAG.add(overridePlugins);
@@ -1,5 +1,6 @@
1
+ const { getRWSHotReloadSetup } = require('./_hot_reload');
1
2
  const { getRWSLoaders } = require('./_loaders');
2
- const path = require('path');
3
+ const webpack = require('webpack');
3
4
 
4
5
 
5
6
  async function createWebpackConfig({
@@ -20,9 +21,15 @@ async function createWebpackConfig({
20
21
  rwsExternals,
21
22
  devExternalsVars,
22
23
  appRootDir,
23
- entrypoint
24
+ entrypoint,
25
+ hotReload,
26
+ hotReloadPort
24
27
  }) {
25
28
 
29
+ if(hotReload){
30
+ WEBPACK_PLUGINS.push(new webpack.HotModuleReplacementPlugin());
31
+ }
32
+
26
33
  return {
27
34
  context: executionDir,
28
35
  entry: {
@@ -47,6 +54,7 @@ async function createWebpackConfig({
47
54
  path: false
48
55
  }
49
56
  },
57
+ devServer: hotReload ? getRWSHotReloadSetup(hotReloadPort, outputDir) : null,
50
58
  module: {
51
59
  rules: getRWSLoaders(_packageDir, executionDir, tsConfig, appRootDir, entrypoint),
52
60
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rws-framework/client",
3
3
  "private": false,
4
- "version": "2.17.0",
4
+ "version": "2.17.2",
5
5
  "main": "src/index.ts",
6
6
  "scripts": {
7
7
  "docs": "typedoc --tsconfig ./tsconfig.json"
@@ -6,7 +6,7 @@ import RWSWindow, {loadRWSRichWindow } from '../types/RWSWindow';
6
6
  import deepmerge from 'deepmerge';
7
7
  import { IPluginSpawnOption } from "../types/IRWSPlugin";
8
8
 
9
- type RWSInfoType = { components: string[] };
9
+ import { _DEFAULT_HR_PORT } from './hotReload';
10
10
 
11
11
  function getUser(this: RWSClientInstance): IRWSUser {
12
12
 
@@ -96,6 +96,12 @@ async function setup(this: RWSClientInstance, config: IRWSConfig = {}): Promise<
96
96
 
97
97
  this.appConfig.mergeConfig(this.config);
98
98
 
99
+ if (this.appConfig.get('hotReload') === true) {
100
+ if(!this.appConfig.get('hotReloadPort')){
101
+ this.appConfig.set('hotReloadPort', _DEFAULT_HR_PORT)
102
+ }
103
+ }
104
+
99
105
  if(this.config.plugins){
100
106
  for (const pluginEntry of this.config.plugins){
101
107
  addPlugin.bind(this)(pluginEntry);
@@ -146,6 +152,12 @@ async function start(this: RWSClientInstance, config: IRWSConfig = {}): Promise<
146
152
  await plugin.onClientStart();
147
153
  }
148
154
 
155
+ if(this.appConfig.get('hotReload')){
156
+ if (module.hot) {
157
+ module.hot.accept();
158
+ }
159
+ }
160
+
149
161
  return this;
150
162
  }
151
163
 
@@ -0,0 +1,23 @@
1
+ import { RWSClientInstance } from "../client";
2
+ import IRWSConfig from "../types/IRWSConfig";
3
+
4
+ export const _DEFAULT_HR_PORT = 1030;
5
+
6
+ export interface IHotReloadCfg {
7
+ enabled: boolean,
8
+ port: number
9
+ }
10
+
11
+ async function hotReloadSetup(this: RWSClientInstance, config: IRWSConfig = {}): Promise<RWSClientInstance>
12
+ {
13
+
14
+ return this;
15
+ }
16
+
17
+ function getBinds(this: RWSClientInstance) {
18
+ return {
19
+ hotReloadSetup: hotReloadSetup.bind(this)
20
+ };
21
+ }
22
+
23
+ export default getBinds;
package/src/client.ts CHANGED
@@ -22,6 +22,7 @@ import TheRWSService from './services/_service';
22
22
  import ComponentHelper, { ComponentHelperStatic, RWSInfoType } from './client/components';
23
23
  import ServicesHelper from './client/services';
24
24
  import ConfigHelper from './client/config';
25
+ import HotReloadHelper, { IHotReloadCfg, _DEFAULT_HR_PORT } from './client/hotReload';
25
26
  import { DefaultRWSPluginOptionsType, RWSPlugin } from './plugins/_plugin';
26
27
  import { IStaticRWSPlugin } from './types/IRWSPlugin'
27
28
 
@@ -38,10 +39,13 @@ class RWSClient {
38
39
  protected devStorage: { [key: string]: any } = {};
39
40
  protected customServices: { [serviceName: string]: TheRWSService} = {};
40
41
  protected defaultServices: { [serviceName: string]: TheRWSService} = {};
42
+ protected hrSetup: IHotReloadCfg = { enabled: false, port: _DEFAULT_HR_PORT }
41
43
 
42
44
  private componentHelper = ComponentHelper.bind(this)();
43
45
  private servicesHelper = ServicesHelper.bind(this)();
44
46
  private configHelper = ConfigHelper.bind(this)();
47
+ private hotReloadHelper = HotReloadHelper.bind(this)();
48
+
45
49
 
46
50
  protected initCallback: () => Promise<void> = async () => { };
47
51
 
@@ -1,8 +1,10 @@
1
- import { RWSUploader } from './uploader/component';
2
- import { RWSProgress } from './progress/component';
3
- import { RWSLoader } from './loader/component';
4
- import { RWSApiResource } from './rws-api-resource/component';
5
- import { ReFormer } from './reformer/component';
1
+ import { RWSUploader } from './rws/uploader/component';
2
+ import { RWSProgress } from './rws/progress/component';
3
+ import { RWSLoader } from './rws/loader/component';
4
+ import { RWSApiResource } from './rws/rws-api-resource/component';
5
+ import { ReFormer } from './rws/reformer/component';
6
+ import { RWSTable } from './rws/rws-table/component';
7
+ import { RWSModal } from './rws/rws-modal/component';
6
8
 
7
9
 
8
10
  function declareRWSComponents(parted: boolean = false): void
@@ -11,6 +13,8 @@ function declareRWSComponents(parted: boolean = false): void
11
13
  RWSUploader;
12
14
  RWSProgress;
13
15
  RWSLoader;
16
+ RWSTable;
17
+ RWSModal;
14
18
 
15
19
  RWSApiResource;
16
20
  ReFormer;
@@ -1,5 +1,5 @@
1
- import { RWSView } from '../_decorator';
2
- import { RWSViewComponent } from '../_component';
1
+ import { RWSView } from '../../_decorator';
2
+ import { RWSViewComponent } from '../../_component';
3
3
 
4
4
  @RWSView('the-loader')
5
5
  class RWSLoader extends RWSViewComponent {
@@ -1,6 +1,6 @@
1
1
  import { observable, attr, nullableNumberConverter } from '@microsoft/fast-element';
2
- import { RWSView } from '../_decorator';
3
- import { RWSViewComponent } from '../_component';
2
+ import { RWSView } from '../../_decorator';
3
+ import { RWSViewComponent } from '../../_component';
4
4
 
5
5
  @RWSView('rws-progress', { debugPackaging: false })
6
6
  class RWSProgress extends RWSViewComponent {
@@ -1,7 +1,7 @@
1
1
  import { observable, attr } from '@microsoft/fast-element';
2
- import { IKDBTypesResponse } from '../../types/IBackendCore';
3
- import { RWSViewComponent} from '../_component';
4
- import { RWSView} from '../_decorator';
2
+ import { IKDBTypesResponse } from '../../../types/IBackendCore';
3
+ import { RWSViewComponent} from '../../_component';
4
+ import { RWSView} from '../../_decorator';
5
5
  import { ReFormerText } from './fields/text/component';
6
6
 
7
7
  ReFormerText;
@@ -1,6 +1,6 @@
1
1
  import { observable, attr } from "@microsoft/fast-element";
2
- import RWSViewComponent from "../../_component";
3
- import { IReFormerField } from "../../../types/IReFormerField";
2
+ import RWSViewComponent from "../../../_component";
3
+ import { IReFormerField } from "../../../../types/IReFormerField";
4
4
 
5
5
  export abstract class ReFormerFieldComponent extends RWSViewComponent implements IReFormerField {
6
6
  @attr name: string;
@@ -1,4 +1,4 @@
1
- import { RWSView} from '../../../_decorator';
1
+ import { RWSView} from '../../../../_decorator';
2
2
  import { ReFormerFieldComponent } from '../_field';
3
3
 
4
4
  @RWSView('reformer-text')
@@ -0,0 +1,55 @@
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
+ import { ActionType, IExtraColumnFormatter, IFlexTableColumn } from '../rws-table/component';
9
+
10
+
11
+ RWSResourceListComponent;
12
+ RWSResourceFormComponent;
13
+
14
+ @RWSView('rws-resource')
15
+ class RWSApiResource extends RWSViewComponent {
16
+ @attr resource: string;
17
+ @attr resourceLabel: string = null;
18
+
19
+ @attr emptyLabel: string = 'No records';
20
+
21
+ @observable dbModelData: IKDBTypesResponse = null;
22
+ @observable resourceList: any[] = [];
23
+ @observable columns: IFlexTableColumn[] = [];
24
+
25
+ @observable fields: string[] = [];
26
+ @observable extraFormatters: {[header_key: string] : IExtraColumnFormatter} = {};
27
+ @observable headerTranslations: {[header_key: string] : string} = {};
28
+
29
+ @observable actions: ActionType[] = [];
30
+
31
+ async connectedCallback(): Promise<void>
32
+ {
33
+ super.connectedCallback();
34
+
35
+ this.dbModelData = await this.apiService.getResource(this.resource);
36
+ this.resourceList = await this.apiService.back.get(`${this.resource}:list`);
37
+
38
+ const makeColumns: IFlexTableColumn[] = [];
39
+
40
+ for(const key in Object.keys(this.dbModelData.data.types)){
41
+ const responseObject: IKDBTypeInfo = this.dbModelData.data.types[key];
42
+
43
+ makeColumns.push({
44
+ key: responseObject.fieldName,
45
+ header: responseObject.fieldName,
46
+ });
47
+ }
48
+
49
+ this.columns = makeColumns;
50
+ }
51
+ }
52
+
53
+ RWSApiResource.defineComponent();
54
+
55
+ export { RWSApiResource };
@@ -0,0 +1,13 @@
1
+ <div class="rws-api-container">
2
+ ${T.when(x => x.resourceLabel, T.html`<h3>${x => x.resourceLabel}</h3>`)}
3
+ ${x => console.log(x.columns)}
4
+ ${T.when(x => x.columns.length, T.html`<rws-table
5
+ emptyLabel="${x => x.emptyLabel}"
6
+ :columns="${x => x.columns}"
7
+ :data="${x => x.resourceList}"
8
+ :fields="${x => x.fields}"
9
+ :actions="${x => x.actions}"
10
+ :extraFormatters="${x => x.extraFormatters}"
11
+ :headerTranslations="${x => x.headerTranslations}">
12
+ </rws-table>`)}
13
+ </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,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,15 @@
1
+ import { observable } from '@microsoft/fast-element';
2
+ import { RWSViewComponent} from '../../_component';
3
+ import { RWSView} from '../../_decorator';
4
+
5
+ @RWSView('rws-modal')
6
+ class RWSModal extends RWSViewComponent {
7
+ @observable closeModal: () => void
8
+ connectedCallback(): void {
9
+ super.connectedCallback();
10
+ }
11
+ }
12
+
13
+ RWSModal.defineComponent();
14
+
15
+ export { RWSModal };
@@ -0,0 +1,47 @@
1
+ @import "@rws-mixins";
2
+
3
+ .backdrop {
4
+ position: fixed;
5
+ width: 100vw;
6
+ height: 100vh;
7
+ top: 0;
8
+ left: 0;
9
+ background-color: rgba(0,0,0,0.8);
10
+ cursor: pointer;
11
+ z-index: 1001;
12
+ }
13
+
14
+ .rws-modal {
15
+ position: fixed;
16
+ width: 100vw;
17
+ height: 100vh;
18
+ top: 0;
19
+ left: 0;
20
+ z-index: 1000;
21
+
22
+ .rws-modal-wrapper{
23
+ background: #FFF;
24
+ border-radius: 20px;
25
+ padding: 20px;
26
+ max-width: 70vw;
27
+ max-height: 80vh;
28
+ min-height: 40vh;
29
+ transform: translate(50%, 50%);
30
+ left: -15%;
31
+ margin-left: 30px;
32
+ color: #000;
33
+ position: relative;
34
+ z-index: 1002;
35
+ overflow-y: auto;
36
+
37
+ @include customScrollbars();
38
+
39
+ .rws-modal-header{
40
+ display: flex;
41
+
42
+ justify-content: end;
43
+ }
44
+
45
+ .rws-modal-body{}
46
+ }
47
+ }
@@ -0,0 +1,11 @@
1
+ <div class="rws-modal">
2
+ <div @click="${ (x, c) => x.closeModal() }" class="backdrop"></div>
3
+ <div class="rws-modal-wrapper">
4
+ <div class="rws-modal-header">
5
+ <sl-button @click="${ (x, c) => x.closeModal() }" variant="secondary" >Close</sl-button>
6
+ </div>
7
+ <div class="rws-modal-body">
8
+ <slot></slot>
9
+ </div>
10
+ </div>
11
+ </div>
@@ -0,0 +1,85 @@
1
+ import { observable, attr } from '@microsoft/fast-element';
2
+ import { RWSViewComponent} from '../../_component';
3
+ import { RWSView} from '../../_decorator';
4
+
5
+ export interface IFlexTableColumn {
6
+ key: string;
7
+ header: string;
8
+ formatter?: (value: any) => string;
9
+ }
10
+
11
+ export type IExtraColumnFormatter<T = unknown> = (inputType: T) => string;
12
+
13
+ export type ActionType = {
14
+ key: string,
15
+ label: string,
16
+ variant: string,
17
+ handler: (id: string) => Promise<void>
18
+ }
19
+
20
+ @RWSView('rws-table')
21
+ class RWSTable extends RWSViewComponent {
22
+ @attr emptyLabel: string = 'No records';
23
+ @observable columns: IFlexTableColumn[] = [];
24
+
25
+ @observable dataColumns: IFlexTableColumn[] = [];
26
+ @observable data: any[] = [];
27
+ @observable fields: string[] = [];
28
+
29
+ @observable actions: ActionType[] = [];
30
+
31
+ @observable extraFormatters: {[header_key: string] : IExtraColumnFormatter} = {};
32
+ @observable headerTranslations: { [sourceKey: string]: string } = {};
33
+
34
+ connectedCallback(): void {
35
+ super.connectedCallback();
36
+
37
+ this.orderFields();
38
+ }
39
+
40
+ headerTranslationsChanged(oldValue: { [sourceKey: string]: string }, newValue: { [sourceKey: string]: string })
41
+ {
42
+ this.orderFields();
43
+ }
44
+
45
+ fieldsChanged(oldValue: string[], newValue: string[])
46
+ {
47
+ this.orderFields();
48
+ }
49
+
50
+ columnsChanged(oldValue: IFlexTableColumn[], newValue: IFlexTableColumn[])
51
+ {
52
+ this.orderFields();
53
+ }
54
+
55
+ orderFields(): void
56
+ {
57
+ if(this.columns && this.fields && this.fields.length && this.columns.length){
58
+ const orderedColumns: IFlexTableColumn[] = [];
59
+
60
+ for(const fieldKey of this.fields){
61
+ const found = this.columns.find(item => item.key === fieldKey);
62
+
63
+ if(found){
64
+ if(Object.keys(this.extraFormatters).includes(fieldKey)){
65
+ found.formatter = this.extraFormatters[fieldKey];
66
+ }
67
+
68
+ if(this.headerTranslations && Object.keys(this.headerTranslations).includes(fieldKey)){
69
+ found.header = this.headerTranslations[fieldKey];
70
+ }
71
+
72
+ orderedColumns.push(found);
73
+ }
74
+ }
75
+
76
+ this.dataColumns = orderedColumns;
77
+ }else{
78
+ this.dataColumns = this.columns;
79
+ }
80
+ }
81
+ }
82
+
83
+ RWSTable.defineComponent();
84
+
85
+ export { RWSTable };
@@ -0,0 +1,73 @@
1
+ .flex-table {
2
+ width: 100%;
3
+ border: 1px solid #e2e8f0;
4
+ border-radius: 8px;
5
+ overflow: hidden;
6
+ background: white;
7
+ box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
8
+
9
+ .flex-table-row {
10
+ display: flex;
11
+ align-items: center;
12
+ border-bottom: 1px solid #e2e8f0;
13
+
14
+ &:last-child {
15
+ border-bottom: none;
16
+ }
17
+
18
+ &.table-header {
19
+ background-color: #f8fafc;
20
+ font-weight: 600;
21
+ color: #475569;
22
+ text-transform: capitalize;
23
+ }
24
+
25
+ &.table-body {
26
+ &:hover {
27
+ background-color: #f1f5f9;
28
+ }
29
+ }
30
+
31
+ &.flex-table-empty {
32
+ display: flex;
33
+ justify-content: center;
34
+ align-items: center;
35
+ min-height: 100px;
36
+ background-color: #f8fafc;
37
+ }
38
+ }
39
+
40
+ .flex-table-cell {
41
+ flex: 1;
42
+ padding: 12px 16px;
43
+ overflow: hidden;
44
+ text-overflow: ellipsis;
45
+ white-space: nowrap;
46
+ min-width: 0;
47
+
48
+ sl-button {
49
+ margin: 0 4px;
50
+
51
+ &:first-child {
52
+ margin-left: 0;
53
+ }
54
+
55
+ &:last-child {
56
+ margin-right: 0;
57
+ }
58
+ }
59
+
60
+ // Add styles for the full-row cell
61
+ &.full-row {
62
+ flex: 1 1 100%;
63
+ text-align: center;
64
+ color: #64748b; // Slate-500 color
65
+ padding: 24px 16px;
66
+
67
+ strong {
68
+ font-weight: 600;
69
+ }
70
+ }
71
+ }
72
+ }
73
+
@@ -0,0 +1,27 @@
1
+ <div class="flex-table">
2
+ <div class="flex-table-row table-header">
3
+ ${T.repeat(x => x.dataColumns, T.html`<div class="flex-table-cell">${x => x.header}</div>`)}
4
+ ${T.when(x => x.actions.length, T.html`<div class="flex-table-cell" data-field="_actions">Actions</div>`)}
5
+ </div>
6
+
7
+ ${T.repeat((x, dataContext) => x.data, T.html`<div class="flex-table-row table-body">
8
+ ${T.repeat((x, columnContext) => columnContext.parent.dataColumns, T.html`<div class="flex-table-cell" data-field="${x => x.key}">
9
+ ${(column, ctx) => {
10
+ const value = ctx.parent[column.key];
11
+ return column.formatter ? column.formatter(value) : value;
12
+ }}
13
+ </div>
14
+ `)}
15
+ ${T.when((x,c) => c.parent.actions && c.parent.actions.length, T.html`<div class="flex-table-cell" data-field="_actions">
16
+ ${T.repeat((x, c) => c.parent.actions, T.html`
17
+ <sl-button @click="${ (x, c) => x.handler(c.parent.id) }" variant="${x => x.variant}" >${x => x.label}</sl-button>
18
+ `)}
19
+ </div>`)}
20
+ </div>
21
+ `)}
22
+
23
+ ${T.when(x => !x.data.length, T.html`<div class="flex-table-row flex-table-empty table-body">
24
+ <div class="flex-table-cell full-row"><strong>${ x => x.emptyLabel }</strong></div>
25
+ </div>`)}
26
+
27
+ </div>
@@ -1,6 +1,6 @@
1
1
  import { observable, attr } from '@microsoft/fast-element';
2
- import { RWSView } from '../_decorator';
3
- import { RWSViewComponent } from '../_component';
2
+ import { RWSView } from '../../_decorator';
3
+ import { RWSViewComponent } from '../../_component';
4
4
 
5
5
  @RWSView('rws-uploader')
6
6
  class RWSUploader extends RWSViewComponent {
package/src/index.ts CHANGED
@@ -1,60 +1,38 @@
1
1
  import { Transformer as HTMLTagTransformerType, Tag as HTMLTag, Attributes as HTMLAttributes } from 'sanitize-html';
2
2
  import { observable, attr } from '@microsoft/fast-element';
3
- import type IRWSConfig from './types/IRWSConfig';
4
- import type RWSNotify from './types/RWSNotify';
5
- import type { NotifyUiType, NotifyLogType } from './types/RWSNotify';
3
+
6
4
  import RWSService from './services/_service';
7
5
  import ConfigService, { ConfigServiceInstance } from './services/ConfigService';
8
6
  import NotifyService, {NotifyServiceInstance} from './services/NotifyService';
9
7
  import DOMService, { DOMServiceInstance } from './services/DOMService';
10
- import type { DOMOutputType, TagsProcessorType } from './services/DOMService';
11
8
  import ApiService, { ApiServiceInstance } from './services/ApiService';
12
- import type { IBackendRoute, IHTTProute, IPrefixedHTTProutes } from './services/ApiService';
13
-
14
9
  import UtilsService, {UtilsServiceInstance} from './services/UtilsService';
15
10
  import ServiceWorkerService, { ServiceWorkerServiceInstance } from './services/ServiceWorkerService';
16
- // import { sanitizedAttr } from './components/_attrs/sanitize-html';
17
11
  import { ngAttr } from './components/_attrs/angular-attr';
18
12
  import { externalObservable } from './components/_attrs/external-observable';
19
13
  import { externalAttr } from './components/_attrs/external-attr';
20
14
  import { RWSPlugin } from './plugins/_plugin';
15
+ import RWSClient, { RWSClientInstance } from './client';
16
+ import RWSViewComponent from './components/_component';
17
+ import RWSContainer from './components/_container';
21
18
 
22
- import type { DefaultRWSPluginOptionsType } from './plugins/_plugin';
19
+ import { RWSIgnore, RWSInject, RWSView } from './components/_decorator';
20
+ import { declareRWSComponents } from './components';
23
21
 
22
+ import type { DefaultRWSPluginOptionsType } from './plugins/_plugin';
24
23
  import type { IRWSPlugin, IStaticRWSPlugin, IPluginSpawnOption } from './types/IRWSPlugin';
25
- import RWSClient, { RWSClientInstance } from './client';
26
24
  import type IRWSUser from './types/IRWSUser';
27
- import RWSViewComponent from './components/_component';
28
25
  import type { IAssetShowOptions } from './components/_component';
29
-
30
- import RWSContainer from './components/_container';
31
-
32
26
  import type { RWSDecoratorOptions } from './components/_decorator';
33
27
  import type { IKDBTypeInfo, IKDBTypesResponse } from './types/IBackendCore';
34
-
35
- import { RWSIgnore, RWSInject, RWSView } from './components/_decorator';
36
-
37
- import { declareRWSComponents } from './components';
28
+ import type { DOMOutputType, TagsProcessorType } from './services/DOMService';
29
+ import type { IBackendRoute, IHTTProute, IPrefixedHTTProutes } from './services/ApiService';
30
+ import type IRWSConfig from './types/IRWSConfig';
31
+ import type RWSNotify from './types/RWSNotify';
32
+ import type { NotifyUiType, NotifyLogType } from './types/RWSNotify';
38
33
 
39
34
  export default RWSClient;
40
35
 
41
- export type {
42
- IKDBTypeInfo, IKDBTypesResponse,
43
- NotifyUiType,
44
- NotifyLogType,
45
- IBackendRoute as IRWSBackendRoute,
46
- RWSDecoratorOptions as IRWSDecoratorOptions,
47
- IHTTProute as IRWSHttpRoute,
48
- IPrefixedHTTProutes as IRWSPrefixedHTTProutes,
49
- IAssetShowOptions as IRWSAssetShowOptions,
50
- IRWSConfig,
51
- IRWSUser,
52
- TagsProcessorType,
53
- HTMLTagTransformerType,
54
- HTMLTag,
55
- HTMLAttributes
56
- }
57
-
58
36
  export {
59
37
  RWSClient,
60
38
  RWSClientInstance,
@@ -79,8 +57,7 @@ export {
79
57
 
80
58
  RWSNotify,
81
59
 
82
- RWSView,
83
- // sanitizedAttr,
60
+ RWSView,
84
61
  RWSIgnore,
85
62
  RWSInject,
86
63
  observable,
@@ -94,4 +71,21 @@ export {
94
71
  declareRWSComponents,
95
72
 
96
73
  RWSContainer
97
- };
74
+ };
75
+
76
+ export type {
77
+ IKDBTypeInfo, IKDBTypesResponse,
78
+ NotifyUiType,
79
+ NotifyLogType,
80
+ IBackendRoute as IRWSBackendRoute,
81
+ RWSDecoratorOptions as IRWSDecoratorOptions,
82
+ IHTTProute as IRWSHttpRoute,
83
+ IPrefixedHTTProutes as IRWSPrefixedHTTProutes,
84
+ IAssetShowOptions as IRWSAssetShowOptions,
85
+ IRWSConfig,
86
+ IRWSUser,
87
+ TagsProcessorType,
88
+ HTMLTagTransformerType,
89
+ HTMLTag,
90
+ HTMLAttributes
91
+ }
@@ -22,6 +22,8 @@ export default interface IRWSConfig {
22
22
  rwsDefines?: {[key: string]: any}
23
23
  partedFileDir?: string
24
24
  partedPrefix?: string
25
+ hotReload?: boolean,
26
+ hotReloadPort?: number,
25
27
  plugins?: IPluginSpawnOption<any>[]
26
28
  routing_enabled?: boolean
27
29
  _noLoad?: boolean
@@ -1,20 +0,0 @@
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 };
@@ -1,3 +0,0 @@
1
- <div class="rws-api-container">
2
-
3
- </div>
@@ -1,11 +0,0 @@
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 };
@@ -1,11 +0,0 @@
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 };