@quandis/qbo4.ui 4.0.1-CI-20240403-131518

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 (94) hide show
  1. package/package.json +52 -0
  2. package/readme.md +456 -0
  3. package/src/qbo/Program.d.ts +18 -0
  4. package/src/qbo/Program.js +18 -0
  5. package/src/qbo/Program.ts +19 -0
  6. package/src/qbo/qbo-api.d.ts +27 -0
  7. package/src/qbo/qbo-api.js +96 -0
  8. package/src/qbo/qbo-api.ts +106 -0
  9. package/src/qbo/qbo-badge.d.ts +32 -0
  10. package/src/qbo/qbo-badge.js +93 -0
  11. package/src/qbo/qbo-badge.js.map +1 -0
  12. package/src/qbo/qbo-badge.ts +80 -0
  13. package/src/qbo/qbo-breadcrumb.d.ts +23 -0
  14. package/src/qbo/qbo-breadcrumb.js +132 -0
  15. package/src/qbo/qbo-breadcrumb.ts +96 -0
  16. package/src/qbo/qbo-datalist.d.ts +22 -0
  17. package/src/qbo/qbo-datalist.js +126 -0
  18. package/src/qbo/qbo-datalist.ts +104 -0
  19. package/src/qbo/qbo-docviewer.d.ts +15 -0
  20. package/src/qbo/qbo-docviewer.js +55 -0
  21. package/src/qbo/qbo-docviewer.ts +39 -0
  22. package/src/qbo/qbo-fetch.d.ts +29 -0
  23. package/src/qbo/qbo-fetch.js +134 -0
  24. package/src/qbo/qbo-fetch.ts +127 -0
  25. package/src/qbo/qbo-json.d.ts +8 -0
  26. package/src/qbo/qbo-json.js +85 -0
  27. package/src/qbo/qbo-json.ts +92 -0
  28. package/src/qbo/qbo-link.d.ts +15 -0
  29. package/src/qbo/qbo-link.js +48 -0
  30. package/src/qbo/qbo-link.js.map +1 -0
  31. package/src/qbo/qbo-link.ts +34 -0
  32. package/src/qbo/qbo-logging.d.ts +13 -0
  33. package/src/qbo/qbo-logging.js +92 -0
  34. package/src/qbo/qbo-logging.ts +72 -0
  35. package/src/qbo/qbo-mainmenu.d.ts +41 -0
  36. package/src/qbo/qbo-mainmenu.js +307 -0
  37. package/src/qbo/qbo-mainmenu.ts +263 -0
  38. package/src/qbo/qbo-markdown.d.ts +9 -0
  39. package/src/qbo/qbo-markdown.js +33 -0
  40. package/src/qbo/qbo-markdown.js.map +1 -0
  41. package/src/qbo/qbo-markdown.ts +22 -0
  42. package/src/qbo/qbo-microphone.d.ts +31 -0
  43. package/src/qbo/qbo-microphone.js +149 -0
  44. package/src/qbo/qbo-microphone.js.map +1 -0
  45. package/src/qbo/qbo-microphone.ts +137 -0
  46. package/src/qbo/qbo-popover.d.ts +8 -0
  47. package/src/qbo/qbo-popover.js +41 -0
  48. package/src/qbo/qbo-popover.ts +26 -0
  49. package/src/qbo/qbo-popup-listener.d.ts +25 -0
  50. package/src/qbo/qbo-popup-listener.js +145 -0
  51. package/src/qbo/qbo-popup-listener.ts +129 -0
  52. package/src/qbo/qbo-popup.d.ts +19 -0
  53. package/src/qbo/qbo-popup.js +95 -0
  54. package/src/qbo/qbo-popup.ts +84 -0
  55. package/src/qbo/qbo-select.d.ts +22 -0
  56. package/src/qbo/qbo-select.js +87 -0
  57. package/src/qbo/qbo-select.ts +65 -0
  58. package/src/qbo/qbo-sidebar.d.ts +10 -0
  59. package/src/qbo/qbo-sidebar.js +65 -0
  60. package/src/qbo/qbo-sidebar.ts +41 -0
  61. package/src/qbo/qbo-table.d.ts +23 -0
  62. package/src/qbo/qbo-table.js +94 -0
  63. package/src/qbo/qbo-table.js.map +1 -0
  64. package/src/qbo/qbo-table.ts +80 -0
  65. package/src/qbo/qbo-validate.d.ts +20 -0
  66. package/src/qbo/qbo-validate.js +92 -0
  67. package/src/qbo/qbo-validate.js.map +1 -0
  68. package/src/qbo/qbo-validate.ts +77 -0
  69. package/src/qbo/qbo-validators.d.ts +37 -0
  70. package/src/qbo/qbo-validators.js +72 -0
  71. package/src/qbo/qbo-validators.ts +66 -0
  72. package/src/qbo/styles.d.ts +3 -0
  73. package/src/qbo/styles.js +27 -0
  74. package/src/qbo/styles.ts +30 -0
  75. package/src/qbo-code/qbo-code.d.ts +12 -0
  76. package/src/qbo-code/qbo-code.js +54 -0
  77. package/src/qbo-code/qbo-code.ts +40 -0
  78. package/src/qbo-flowchart/qbo-flowchart.d.ts +45 -0
  79. package/src/qbo-flowchart/qbo-flowchart.js +309 -0
  80. package/src/qbo-flowchart/qbo-flowchart.js.map +1 -0
  81. package/src/qbo-flowchart/qbo-flowchart.ts +320 -0
  82. package/src/qbo-flowchart/readme.md +2 -0
  83. package/wwwroot/js/qbo4.ui-code.js +37965 -0
  84. package/wwwroot/js/qbo4.ui-code.min.js +3 -0
  85. package/wwwroot/js/qbo4.ui-code.min.js.LICENSE.txt +32 -0
  86. package/wwwroot/js/qbo4.ui-code.min.js.map +1 -0
  87. package/wwwroot/js/qbo4.ui-flowchart.js +44909 -0
  88. package/wwwroot/js/qbo4.ui-flowchart.min.js +9 -0
  89. package/wwwroot/js/qbo4.ui-flowchart.min.js.LICENSE.txt +43 -0
  90. package/wwwroot/js/qbo4.ui-flowchart.min.js.map +1 -0
  91. package/wwwroot/js/qbo4.ui.js +18840 -0
  92. package/wwwroot/js/qbo4.ui.min.js +108 -0
  93. package/wwwroot/js/qbo4.ui.min.js.LICENSE.txt +53 -0
  94. package/wwwroot/js/qbo4.ui.min.js.map +1 -0
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@quandis/qbo4.ui",
3
+ "author": "Quandis, Inc.",
4
+ "license": "MIT",
5
+ "type": "module",
6
+ "version": "4.0.1-CI-20240403-131518",
7
+ "workspaces": [
8
+ "code"
9
+ ],
10
+ "main": "src/qbo/Program.js",
11
+ "private": false,
12
+ "scripts": {
13
+ "build": "npm run sass && tsc && npm run packdev && npm run packprod && del *.tgz && npm pack && ren *.tgz qbo4.ui.tgz",
14
+ "packdev": "webpack --config webpack.dev.js --no-color",
15
+ "packprod": "webpack --config webpack.prod.js --no-color",
16
+ "sass": "sass scss/:wwwroot/css && node cssshake.js"
17
+ },
18
+ "keywords": [
19
+ "qbo"
20
+ ],
21
+ "files": [
22
+ "wwwroot/js/",
23
+ "src/"
24
+ ],
25
+ "dependencies": {
26
+ "@codemirror/lang-html": "^6.4.6",
27
+ "@joint/core": "^4.0.1",
28
+ "bootstrap": "^5.3.3",
29
+ "bootstrap-icons": "^1.10.5",
30
+ "codemirror": "^6.0.1",
31
+ "lit": "^2.8.0",
32
+ "reflect-metadata": "^0.2.2",
33
+ "tsyringe": "^4.8.0",
34
+ "zero-md": "^2.5.3"
35
+ },
36
+ "devDependencies": {
37
+ "@esm-bundle/chai": "^4.3.4",
38
+ "@fullhuman/postcss-purgecss": "^5.0.0",
39
+ "autoprefixer": "^10.4.19",
40
+ "clean-css": "^5.3.3",
41
+ "glob": "^10.3.10",
42
+ "html-webpack-plugin": "^5.5.3",
43
+ "mini-css-extract-plugin": "^2.7.6",
44
+ "postcss": "^8.4.38",
45
+ "postcss-loader": "^8.1.1",
46
+ "sass": "^1.72.0",
47
+ "typescript": "^5.4.3",
48
+ "webpack": "^5.88.2",
49
+ "webpack-cli": "^5.1.4",
50
+ "webpack-merge": "^5.10.0"
51
+ }
52
+ }
package/readme.md ADDED
@@ -0,0 +1,456 @@
1
+ # Overview
2
+
3
+ The `qbo4.UI.Web` project contains the web components to add sugar to any UI, including qbo3 and qbo4 UI.
4
+
5
+ This replace's the qbo3/Mootools `Behaviors` concept. Web components are reusable in any modern framework.
6
+
7
+ ## Background Reading
8
+
9
+ - [HTML Accessiblilty](https://developer.mozilla.org/en-US/docs/Learn/Accessibility/HTML)
10
+ - [Accessible Rich Internet Applications (ARIA)](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA)
11
+ - [Web components](https://developer.mozilla.org/en-US/docs/Web/Web_Components) ([examples](https://github.com/mdn/web-components-examples) on Github)
12
+ - [Form validation](https://www.w3.org/TR/2009/WD-html5-20090825/forms.html#attr-input-pattern)
13
+ - [Javascript Modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules)
14
+ - [TSDoc](https://tsdoc.org/) for Typescript comments
15
+
16
+ ## Custom Web components
17
+
18
+ There is a [debate](https://github.com/WebKit/standards-positions/issues/97) about customizing standard html elements.
19
+ Apple has refused to support customizing existing elements, and Quandis agrees with this approach.
20
+
21
+ This means that you can do:
22
+
23
+ ```html
24
+ <qbo-select></qbo-select>
25
+ ```
26
+
27
+ but you may not do:
28
+
29
+ ```html
30
+ <select is="qbo-select"></select>
31
+ ```
32
+
33
+ Components that customize `<select>` should do this:
34
+
35
+ ```javascript
36
+ @customElement('qbo-select')
37
+ export class QboSelect extends QboFetch
38
+ {
39
+ ...
40
+ render() {
41
+ ...
42
+ return html`
43
+ <select>
44
+ ${this.options.map(option => html`...`)}
45
+ </select>`;
46
+ }
47
+ }
48
+ ```
49
+
50
+ # Project Structure
51
+
52
+ While this project is a `Microsoft.NET.Sdk.Web` project, it does not include any meaningful server-side code.
53
+
54
+ ## Technology Components
55
+
56
+ | Technology | Config File | Purpose |
57
+ |-|-|-|
58
+ |Typescript|`tsconfig.json`|Type safe version of Javascript. `tsc --build` is used to compile (transpile) .ts files to .js file.|
59
+ |Node package manager (npm)|`package.json`|Javascript equivalent to Nuget package manager.|
60
+ |Webpack|`webpack.config.cjs`|Javascript equivalent to MSBuild. Webpack products a single `.js` and `.css` file for use by other projects.|
61
+ |Lit|--|Google's web component library. `LitElement` is the base class for most qbo4 web components.|
62
+ |web-test-runner|--|A test runner that runs tests in browser(s)' javascript/DOM engine.|
63
+
64
+ ## Folder Structure
65
+
66
+ |Folder|Purpose|
67
+ |-|-|
68
+ |`wwwroot`|Contains .html pages to enable testing of web components.|
69
+ |`wwwroot/scripts`|Contains `main.js` and `main.css` files to be linked to by `.html` pages.|
70
+ |`package`|Folder containing the files to be packaged by `npm` and pushed to an artifact feed. This is specified in `package.json`|
71
+ |`src`|Source `.ts` files that comprise qbo4.UI.Web's components and libaries.|
72
+ |`tests`|Test `*.test.ts` files for testing components and libraries.|
73
+
74
+ ## Typescript (tsconfig.json)
75
+
76
+ This project includes the `Microsoft.Typecript.MSBuild` Nuget package, which includes the `tsc` compiler.
77
+ When the project is built, MSBuild automatically calls `tsc` to compile `.ts` files to `.js` files.
78
+
79
+ It is convention to place `.ts` files in a `src` folder, and `.test.ts` files in a `tests` folder.
80
+ However, when we publish the package, we want to include only the `src` files.
81
+ To address this issue, we have three `tsconfig.json` files:
82
+
83
+ - `tsconfig.json`: in the root folder
84
+ - `src\tsconfig.json`: in the `src` folder, and instructs `tsc` where to output the files (`package` folder)
85
+ - `tests\tsconfig.json`: in the `tests` folder, and instructs `tsc` where to output the files (`tests` (same) folder)
86
+
87
+ The significant takeaway for our use of `tsconfig.json` is that we target `ESNext` for our output,
88
+ meaning that we produce javascript files that use the latest `ECMA` standards, including `import` and `export` of `modules`.
89
+ This means that these libraries will only work with modern browsers, which comprise 94+% of all browsers currently in use.
90
+ **IE is right out**.
91
+
92
+ ## Node (package.json)
93
+
94
+ The `package.json` is used instruct `npm` how to behave. While it has many options,
95
+ the most relevent are the defined `scripts` that allow you to execute node command with a shortcut:
96
+
97
+ ```console
98
+ // execute the tests using web-test-runner
99
+ npm run test
100
+ // package the files for deployment
101
+ npm run pack
102
+ ```
103
+
104
+ The following `npm` commands are not scripts, but you will use frequently:
105
+
106
+ ```console
107
+ // install all packages listed in package.json
108
+ npm install
109
+ // install a package and add it to package.json
110
+ npm install <package> --save
111
+ // install a package and add it to package.json as a dev dependency
112
+ npm install <package> --save-dev
113
+ // run any package installed globally
114
+ npx <package>
115
+ ```
116
+
117
+ ## Webpack (webpack.config.cjs)
118
+
119
+ Typescript projects must be transpiled into javascript, and will leverage modules via `import` and `export`.
120
+ Convention dictates that:
121
+
122
+ ```typescript
123
+ import `lit`; // This expects lit to be defined in the folder node_modules\lit
124
+ import `./qbo` // This expects qbo to be defined in the current folder
125
+ ```
126
+
127
+ Webpack's job is to look a one (or more) 'entry' javascript files, build a dependency graph of all the imports actually in use,
128
+ and create a single Javascript file containing all referenced code (a dependency graph).
129
+ The entry point for qbo modules is `qbo.js`.
130
+
131
+ Webpack uses the following configuration files:
132
+
133
+ - `webpack.config.cjs`: common configuration for both development and production, produces output in `package\dist`
134
+ - `webpack.config.dev.cjs`: does not minify, does copies `package\dist` to `wwwroot\scripts` for testing (merges with `webpack.config.cjs`)
135
+ - `webpack.config.prod.cjs`: minifies javascript and css (merges with `webpack.config.cjs`)
136
+
137
+ > Webpack looks for a `webpack.config.js` first, but expects the json to be `CommonJs`,
138
+ instead of a `module` as specified in `package.json` - as needed to tell node our modules use `import` instead of `require`.
139
+ Naming the file with `.cjs` tells `node` that file is `CommonJS`, regardless of what `package.json's` `target` says.
140
+
141
+ The `qbo.UI.Web.csproj` includes a build target for `webpack`, so that every time the project is built, new `qbo4.js` and `qbo4.css` are created.
142
+
143
+ ```xml
144
+ <Target Name="NpmRunPack" AfterTargets="Build">
145
+ <Exec Command="npm run packprod" />
146
+ </Target>
147
+ ```
148
+
149
+ paired with the `pack` script defined in `pacakge.json`:
150
+
151
+ ```json
152
+ { ...
153
+ "scripts": {
154
+ "packprod": "webpack --config webpack.prod.cjs --no-color"
155
+ },
156
+ ...
157
+ }
158
+ ```
159
+
160
+ # HTML Coding Guidelines
161
+
162
+ When creating web pages, features should be implemented with:
163
+
164
+ - HTML, first, if possible,
165
+ - CSS, second, if possible,
166
+ - Javascript, otherwise
167
+
168
+ ## Web Components
169
+
170
+ When designing reusable browser-based components, [web components](https://developer.mozilla.org/en-US/docs/Web/Web_Components) should be used.
171
+ Web components use Javascript, HTML and CSS to define new tags ~~or extend existing tags~~ , and scope all functionality to a [shadow DOM](https://developers.google.com/web/fundamentals/web-components/shadowdom).
172
+ This allows a given component to use javascript without worrying that it will interfere with other components.
173
+
174
+ The goal of creating web components is to strive to ensure QBO components can be **mixed into a variety of frameworks**,
175
+ including Angular and React.
176
+
177
+ In most cases, Quandis recommends use of Google's [Lit library](https://lit.dev/) to speed the development of pure web components.
178
+
179
+ A sampling custom components includes:
180
+
181
+ |Component|Purpose|
182
+ |-|-|
183
+ |`qbo-fetch`|Acts as a base class for elements that need to do API calls (via Javascript's `fetch` statement).|
184
+ |`qbo-select`|Renders a `<select>` element with options from the results of an API call.|
185
+ |`qbo-popup`|Renders a popup, with content optionally coming from an API call (via `qbo-fetch`).|
186
+ |`qbo-logging`|Provides UI around handling errors.|
187
+
188
+ ## Form validation
189
+
190
+ HTML5 supports [extensive form validation](https://www.w3.org/TR/2009/WD-html5-20090825/forms.html#attr-input-pattern); use it! Examples:
191
+
192
+ ```html
193
+ <input name="zipcode" type="text" pattern="\d{5}(-\d{4})?"/>
194
+ <input name="creditcard" type="text" pattern="[0-9]{13,16}"/>
195
+ ```
196
+
197
+ # Typescrpit / Javascript Coding Guidelines
198
+
199
+ - Use the [MDN Style Guide](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide) (which Microsoft also uses)
200
+ - Use `const` and `let` [instead of](https://stackoverflow.com/questions/40070631/v8-javascript-performance-implications-of-const-let-and-var/40070682#40070682) `var`
201
+ - Use camelcase for variables and function names
202
+
203
+ ``` javascript
204
+ const myLongVariableName = "foo";
205
+ ```
206
+
207
+ - Use template literals for code readability
208
+
209
+ ``` javascript
210
+ const firstName = "Bob";
211
+ const lastName = "Jones";
212
+ const result = `Hello ${firstName}, ${lastName}`;
213
+ ```
214
+
215
+ - Omit the protocol from links to other sites, if possible, to support `http` and `https`
216
+
217
+ ``` javascript
218
+ <style src="//maps.googleapis.com/maps/api/js"/>
219
+ ```
220
+
221
+ ## Namespacing
222
+
223
+ Use [`modules`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) via the `export` and `import` features to build javascript libraries.
224
+ Related classes and functions should be imported as a module. For example, qbo4-related modules:
225
+
226
+ - src
227
+ - qbo.ts
228
+ - qbo-fetch.ts
229
+ - qbo-json.ts
230
+ - qbo-select.ts
231
+
232
+ where `qbo.js` [aggregates](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#aggregating_modules) related classes an functions:
233
+
234
+ ```javascript
235
+ export * from './qbo-fetch.js'
236
+ export * from './qbo-json.js'
237
+ export * from './qbo-select.js'
238
+ ```
239
+ and the website's root includes a `qbo4.js` created by `webpack`:
240
+
241
+ ```javascript
242
+ import * as qbo4 from './qbo4.js';
243
+ ```
244
+ To use qbo4 from a browser debugger window:
245
+
246
+ ```javascript
247
+ const qbo = await import('/scirpts/qbo4.js');
248
+ // now you can access qbo.* functions
249
+ ```
250
+
251
+ ## Error handling in the browser
252
+
253
+ - Assume our code will fail
254
+ - Log errors to the server
255
+ - Our code, not the browser, should handle errors
256
+ - Identify errors that might occur (arguments, network)
257
+ - use [custom errors](https://medium.com/@iaincollins/error-handling-in-javascript-a6172ccdf9af)
258
+ - `throw` at a low level, `catch` at a high level
259
+ - Distinguish between fatal and non-fatal
260
+ - Global debug mode: help the developer figure out the problem
261
+
262
+ > Credit [Nicholas Zakas](https://www.slideshare.net/nzakas/enterprise-javascript-error-handling-presentation/48-E_tcetera_M_y_blog)
263
+
264
+ ## Comments
265
+
266
+ Quandis shall follow the [TSDoc](https://tsdoc.org/) to work with Visual Studio Intellisense.
267
+
268
+ ``` javascript
269
+ /* @description These are sample comments
270
+ * @param foo {string} Foo is used to ...
271
+ * @param bar {array} Each item in bar is used to ...
272
+ * @returns {object} An object representing ...
273
+ */
274
+ qbo4.someMethod = function (foo, bar) {...}
275
+ ```
276
+
277
+ ## Third Party Libraries
278
+
279
+ - Use native Javascript methods ahead of third party library methods
280
+ - e.g. `document.getElementById(id)` is preferrable to jQuery's `$('#id')[0]`.
281
+ - e.g. `{array}.forEach(...)` is preferable to Mootool's `{array}.each(...)`
282
+
283
+ |Library|qbo3|qbo4|Notes|
284
+ |-|-|-|-|
285
+ |[Mootools](https://mootools.net/)|yes|no|Deprecated; not under development.|
286
+ |[jQuery](https://jquery.com/)|yes|yes|For sugar **not supported by the DOM**. <br/>Use [noconflict](https://api.jquery.com/jQuery.noConflict/); $ shall be used for Mootools in qbo3.|
287
+ |[Google Visualizations](https://developers.google.com/chart/interactive/docs/gallery)|yes|yes|For charting.|
288
+ |[Bootstrap](https://getbootstrap.com/)|yes|yes|For styling and layout.|
289
+ |[Dropzone](https://www.dropzonejs.com/)|yes|yes|For file upload controls.|
290
+ |[Modernizr](https://modernizr.com/)|yes|yes|For older browsers (consumer-facing sites).|
291
+
292
+ ## Feature adoption
293
+
294
+ |Feature|qbo3|qbo4|Notes|
295
+ |-|-|-|-|
296
+ |Promises|yes|yes||
297
+ |async/await|yes|yes||
298
+
299
+ > Use new features [only if available](https://caniuse.com/) to 90% or more of global users.
300
+
301
+
302
+ # References
303
+
304
+ - [Web components](https://developers.google.com/web/fundamentals/web-components/customelements) *Read this!*
305
+ - [Composing events with the shadow DOM](https://stackoverflow.com/questions/43061417/how-to-listen-for-custom-events-defined-web-component)
306
+ - [Webpack](https://webpack.js.org/)
307
+ - [TypeScript with ASP.NET core](https://www.typescriptlang.org/docs/handbook/asp-net-core.html)
308
+
309
+
310
+ # Typescript in a Microsoft Stack
311
+
312
+ A basic Typescript project (`.esproj` file) looks something like this:
313
+
314
+ ```xml
315
+ <Project Sdk="Microsoft.VisualStudio.JavaScript.Sdk/0.5.74-alpha">
316
+ <PropertyGroup>
317
+ <!-- Command to run on project build -->
318
+ <BuildCommand>npm run build</BuildCommand>
319
+ <!-- Command to run on project clean -->
320
+ <CleanCommand>npm run clean</CleanCommand>
321
+ </PropertyGroup>
322
+ <ItemGroup>
323
+ <Folder Include="build\" />
324
+ </ItemGroup>
325
+ </Project>
326
+ ```
327
+
328
+ The following files are automatically added:
329
+
330
+ |File|Description|
331
+ |-|-|
332
+ |tsconfig.json|Typescript configuration file that provides tsc (a node package that is the Typescript compiler) with it's [build options](https://aka.ms/tsconfig).|
333
+ |package.json|Node.js configuration file that provides npm.exe (the [Node Package Manager](https://docs.npmjs.com/files/package.json)) with the Node packages to include.|
334
+ |nuget.config|Sources to use for Nuget packages.|
335
+
336
+ ## Building
337
+
338
+ - When a developer select Project > Build, the `BuildCommand` is executed, which in turn runs `npm run build`.
339
+ - `npm` looks for a `build` script defined in `package.json`, which is defined in by the `scrips` entry in `package.json`:
340
+
341
+ ```json
342
+ "scripts": {
343
+ "test": "echo \"Error: no test specified\" && exit 1",
344
+ "build": "tsc --build",
345
+ "clean": "tsc --build --clean"
346
+ },
347
+ ```
348
+
349
+ - `tsc` is the Typescript compiler, which is installed as a Node package.
350
+
351
+ By default, calling `tsc --build` will find any `.ts` files, and compile them to `.js` and `.js.map` files.
352
+
353
+ > The `.js.map` file is a mapping between the generated/transpiled/minified JavaScript file and one or more original source files.
354
+ The main purpose of Sourcemaps is to aid debugging.
355
+ If there is an error in the generated code file, the map can tell you the original source file location.
356
+ That's it.
357
+
358
+ This all happens in the root of the project.
359
+
360
+ # Quandis Customizations
361
+
362
+ ## `/src` and `/build` folders
363
+
364
+ A common convention is to store `.ts` files in a `/src` folder, and the generated `.js` files in a `/build` folder.
365
+ This is enabled by modifying the `tsconfig.json` file:
366
+ ```json
367
+ {
368
+ "compilerOptions": {
369
+ "experimentalDecorators": true, // for Lit compatibility
370
+ "outDir": "./js",
371
+ ...
372
+ },
373
+ "include": [ "src/**/*", "tests/**/*" ]
374
+ }
375
+ ```
376
+
377
+ ## Testing
378
+
379
+ [Lit recommends](https://lit.dev/docs/tools/testing/#web-test-runner) using [@web-test-runner](https://modern-web.dev/guides/test-runner/getting-started/) for testing Lit-based web components.
380
+ The `web-test-runner` tests javascript against actual browser javascript engines, rather than Node.js.
381
+ This is important because Node.js does not support the DOM, and Lit is a DOM-based library.
382
+ The `@web/test-runner-playwright` enables testing against Chrome, Safari and Edge.
383
+
384
+ To install `web-test-runner`:
385
+
386
+ ```
387
+ npm install --save-dev @web/test-runner
388
+ npm install --save-dev @web/test-runner-playwright
389
+ ```
390
+
391
+ To run tests, `packages.json` includes:
392
+ ```json
393
+ {
394
+ ...
395
+ "scripts": {
396
+ "test": "web-test-runner \"js/tests/**/*.test.js\" --node-resolve",
397
+ "test:watch": "web-test-runner \"js/tests/**/*.test.js\" --node-resolve --watch",
398
+ "test:all": "web-test-runner \"js/tests/**/*.test.js\" --node-resolve --playwright --browsers chromium firefox webkit --static-logging",
399
+ },
400
+ ...
401
+ }
402
+ ```
403
+
404
+ ## Publish Node Packages to Azure Devops
405
+
406
+ By default, `npm` will publish to the [npmjs.com](https://www.npmjs.com/) registry.
407
+ To publish to a private Azure Devops feed, you will create 2 .npmrc files:
408
+
409
+ - c:\users\your.username\\.npmrc: this will contain authentication info
410
+ - \{project folder}\\.npmrc: this will contain just the feed URL
411
+
412
+ The private `npmrc` file will look something like this:
413
+
414
+ ```ini
415
+ qbo4:registry=https://pkgs.dev.azure.com/quandis/_packaging/qbo4-Build/npm/registry/
416
+ always-auth=true
417
+ ; begin auth token
418
+ //pkgs.dev.azure.com/quandis/_packaging/qbo4-Build/npm/registry/:username=quandis
419
+ //pkgs.dev.azure.com/quandis/_packaging/qbo4-Build/npm/registry/:_password={your Devops PAT, base64 encoded}
420
+ //pkgs.dev.azure.com/quandis/_packaging/qbo4-Build/npm/registry/:email=npm requires email to be set but doesn't use the value
421
+ //pkgs.dev.azure.com/quandis/_packaging/qbo4-Build/npm/:username=quandis
422
+ //pkgs.dev.azure.com/quandis/_packaging/qbo4-Build/npm/:_password={your Devops PAT, base64 encoded}
423
+ //pkgs.dev.azure.com/quandis/_packaging/qbo4-Build/npm/:email=npm requires email to be set but doesn't use the value
424
+ ; end auth token
425
+ ```
426
+
427
+ > Yor PAT is an Azure Devops Personal Access Token, which you have configured for Visual Studio to pull Quandis Nuget packages
428
+ > You can use Fiddler's TextWizard to base64 encode your PAT.
429
+
430
+ The project `.npmrc` file will look something like this:
431
+
432
+ ```ini
433
+ registry=https://pkgs.dev.azure.com/quandis/_packaging/qbo4-Build/npm/registry/
434
+ ```
435
+
436
+ Some useful `npm` commands:
437
+
438
+ ```ini
439
+ // list all npm config settings, including registries defined in various .npmrc files
440
+ npm config list
441
+
442
+ // publish to a specific registry
443
+ npm publish --registry=https://pkgs.dev.azure.com/quandis/_packaging/qbo4-Build/npm/registry/
444
+
445
+ // publish to whatever registry is defined in the local .npmrc file
446
+ npm publish
447
+
448
+ // increment the version number in package.json
449
+ npm version patch
450
+ ```
451
+
452
+
453
+ # Notes
454
+
455
+ - [Debug client scripts with VS and Chrome](https://learn.microsoft.com/en-us/visualstudio/javascript/debug-nodejs?view=vs-2022#debug-client-side-script)
456
+
@@ -0,0 +1,18 @@
1
+ import 'reflect-metadata';
2
+ export * from './qbo-badge.js';
3
+ export * from './qbo-datalist.js';
4
+ export * from './qbo-docviewer.js';
5
+ export * from './qbo-json.js';
6
+ export * from './qbo-logging.js';
7
+ export * from './qbo-mainmenu.js';
8
+ export * from './qbo-markdown.js';
9
+ export * from './qbo-microphone.js';
10
+ export * from './qbo-popover.js';
11
+ export * from './qbo-popup.js';
12
+ export * from './qbo-popup-listener.js';
13
+ export * from './qbo-select.js';
14
+ export * from './qbo-sidebar.js';
15
+ export * from './qbo-table.js';
16
+ export * from './qbo-validate.js';
17
+ export * from './qbo-validators.js';
18
+ export * from './qbo-api.js';
@@ -0,0 +1,18 @@
1
+ import 'reflect-metadata';
2
+ export * from './qbo-badge.js';
3
+ export * from './qbo-datalist.js';
4
+ export * from './qbo-docviewer.js';
5
+ export * from './qbo-json.js';
6
+ export * from './qbo-logging.js';
7
+ export * from './qbo-mainmenu.js';
8
+ export * from './qbo-markdown.js';
9
+ export * from './qbo-microphone.js';
10
+ export * from './qbo-popover.js';
11
+ export * from './qbo-popup.js';
12
+ export * from './qbo-popup-listener.js';
13
+ export * from './qbo-select.js';
14
+ export * from './qbo-sidebar.js';
15
+ export * from './qbo-table.js';
16
+ export * from './qbo-validate.js';
17
+ export * from './qbo-validators.js';
18
+ export * from './qbo-api.js';
@@ -0,0 +1,19 @@
1
+ import 'reflect-metadata';
2
+
3
+ export * from './qbo-badge.js';
4
+ export * from './qbo-datalist.js'
5
+ export * from './qbo-docviewer.js'
6
+ export * from './qbo-json.js';
7
+ export * from './qbo-logging.js';
8
+ export * from './qbo-mainmenu.js';
9
+ export * from './qbo-markdown.js'
10
+ export * from './qbo-microphone.js'
11
+ export * from './qbo-popover.js'
12
+ export * from './qbo-popup.js';
13
+ export * from './qbo-popup-listener.js';
14
+ export * from './qbo-select.js';
15
+ export * from './qbo-sidebar.js'
16
+ export * from './qbo-table.js';
17
+ export * from './qbo-validate.js';
18
+ export * from './qbo-validators.js';
19
+ export * from './qbo-api.js';
@@ -0,0 +1,27 @@
1
+ import { LitElement } from 'lit';
2
+ /**
3
+ * Defines a contract for form field validation.
4
+ * @remarks
5
+ * External classes may define custom validators by implementing this interface.
6
+ * Register the custom validator with the tsyringe DI container using {@link ValidateToken}.
7
+ */
8
+ export interface IApiService {
9
+ fetch(relativePath: string | null, payload: Record<string, string> | null): Promise<any>;
10
+ }
11
+ export declare class RestApiService implements IApiService {
12
+ private headers;
13
+ private apiEndpoint;
14
+ private method;
15
+ constructor(apiEndpoint: string, headers?: HeadersInit, method?: string | null);
16
+ fetch(relativePath: string | null, payload?: Record<string, string> | null): Promise<any>;
17
+ }
18
+ export declare class ApiServiceComponent extends LitElement {
19
+ name: string | null;
20
+ apiEndpoint: string | null;
21
+ method: string;
22
+ firstUpdated(): void;
23
+ render(): import("lit").TemplateResult<1>;
24
+ }
25
+ declare function registerRestApi(name: string, apiEndpoint: string, headers?: HeadersInit, method?: string | null): void;
26
+ declare function getApiService(name: string): IApiService;
27
+ export { registerRestApi, getApiService };