x4js 2.0.7 → 2.0.9

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 (150) hide show
  1. package/lib/cjs/x4.js +1 -1
  2. package/lib/esm/x4.mjs +1 -1
  3. package/lib/output.d.ts +1472 -0
  4. package/lib/src/components/boxes/boxes.ts +1 -1
  5. package/lib/src/components/btngroup/btngroup.ts +7 -11
  6. package/lib/src/components/button/button.ts +3 -3
  7. package/lib/src/components/calendar/calendar.ts +6 -6
  8. package/lib/src/components/checkbox/checkbox.ts +3 -3
  9. package/lib/src/components/colorinput/colorinput.ts +3 -3
  10. package/lib/src/components/colorpicker/colorpicker.ts +3 -3
  11. package/lib/src/components/combobox/combobox.ts +1 -1
  12. package/lib/src/components/dialog/dialog.ts +3 -2
  13. package/lib/src/components/header/header.ts +1 -1
  14. package/lib/src/components/icon/icon.ts +1 -1
  15. package/lib/src/components/image/image.ts +1 -1
  16. package/lib/src/components/input/input.ts +2 -2
  17. package/lib/src/components/label/label.ts +2 -2
  18. package/lib/src/components/listbox/listbox.ts +1 -1
  19. package/lib/src/components/menu/menu.ts +3 -3
  20. package/lib/src/components/messages/messages.ts +2 -2
  21. package/lib/src/components/notification/notification.ts +2 -2
  22. package/lib/src/components/panel/panel.ts +2 -2
  23. package/lib/src/components/popup/popup.ts +2 -2
  24. package/lib/src/components/progress/progress.ts +1 -1
  25. package/lib/src/components/rating/rating.ts +2 -2
  26. package/lib/src/components/sizers/sizer.ts +2 -2
  27. package/lib/src/components/slider/slider.ts +2 -2
  28. package/lib/src/components/switch/switch.ts +1 -1
  29. package/lib/src/components/tabs/tabs.ts +2 -2
  30. package/lib/src/components/textarea/textarea.ts +1 -1
  31. package/lib/src/components/textedit/textedit.ts +2 -2
  32. package/lib/src/components/tooltips/tooltips.ts +2 -2
  33. package/lib/src/components/treeview/treeview.ts +1 -1
  34. package/lib/src/components/viewport/viewport.ts +1 -1
  35. package/lib/src/core/component.ts +1 -1
  36. package/lib/src/core/core_styles.ts +0 -1
  37. package/lib/src/types/svg.d.ts +1 -0
  38. package/lib/src/types/x4react.d.ts +9 -0
  39. package/lib/types/x4.d.ts +6144 -178
  40. package/package.json +6 -1
  41. package/build/x4.css +0 -1
  42. package/build/x4.js +0 -1
  43. package/scripts/build.mjs +0 -362
  44. package/scripts/prepack.mjs +0 -51
  45. package/src/components/base.scss +0 -26
  46. package/src/components/boxes/boxes.module.scss +0 -37
  47. package/src/components/boxes/boxes.ts +0 -125
  48. package/src/components/btngroup/btngroup.module.scss +0 -29
  49. package/src/components/btngroup/btngroup.ts +0 -106
  50. package/src/components/button/button.module.scss +0 -154
  51. package/src/components/button/button.ts +0 -117
  52. package/src/components/calendar/calendar-check-sharp-light.svg +0 -1
  53. package/src/components/calendar/calendar.module.scss +0 -163
  54. package/src/components/calendar/calendar.ts +0 -326
  55. package/src/components/calendar/chevron-left-sharp-light.svg +0 -1
  56. package/src/components/calendar/chevron-right-sharp-light.svg +0 -1
  57. package/src/components/checkbox/check.svg +0 -4
  58. package/src/components/checkbox/checkbox.module.scss +0 -142
  59. package/src/components/checkbox/checkbox.ts +0 -125
  60. package/src/components/colorinput/colorinput.module.scss +0 -65
  61. package/src/components/colorinput/colorinput.ts +0 -88
  62. package/src/components/colorinput/crosshairs-simple-sharp-light.svg +0 -1
  63. package/src/components/colorpicker/colorpicker.module.scss +0 -133
  64. package/src/components/colorpicker/colorpicker.ts +0 -477
  65. package/src/components/combobox/combobox.module.scss +0 -121
  66. package/src/components/combobox/combobox.ts +0 -190
  67. package/src/components/combobox/updown.svg +0 -4
  68. package/src/components/dialog/dialog.module.scss +0 -71
  69. package/src/components/dialog/dialog.ts +0 -91
  70. package/src/components/dialog/xmark-sharp-light.svg +0 -1
  71. package/src/components/form/form.module.scss +0 -34
  72. package/src/components/form/form.ts +0 -36
  73. package/src/components/header/header.module.scss +0 -40
  74. package/src/components/header/header.ts +0 -124
  75. package/src/components/icon/icon.module.scss +0 -30
  76. package/src/components/icon/icon.ts +0 -134
  77. package/src/components/image/image.module.scss +0 -21
  78. package/src/components/image/image.ts +0 -67
  79. package/src/components/input/input.module.scss +0 -69
  80. package/src/components/input/input.ts +0 -274
  81. package/src/components/label/label.module.scss +0 -52
  82. package/src/components/label/label.ts +0 -55
  83. package/src/components/listbox/listbox.module.scss +0 -103
  84. package/src/components/listbox/listbox.ts +0 -427
  85. package/src/components/menu/caret-right-solid.svg +0 -1
  86. package/src/components/menu/menu.module.scss +0 -108
  87. package/src/components/menu/menu.ts +0 -168
  88. package/src/components/messages/circle-exclamation.svg +0 -1
  89. package/src/components/messages/messages.module.scss +0 -47
  90. package/src/components/messages/messages.ts +0 -64
  91. package/src/components/normalize.scss +0 -386
  92. package/src/components/notification/circle-check-solid.svg +0 -1
  93. package/src/components/notification/circle-exclamation-solid.svg +0 -1
  94. package/src/components/notification/circle-notch-light.svg +0 -1
  95. package/src/components/notification/notification.module.scss +0 -82
  96. package/src/components/notification/notification.ts +0 -108
  97. package/src/components/notification/xmark-sharp-light.svg +0 -1
  98. package/src/components/panel/panel.module.scss +0 -48
  99. package/src/components/panel/panel.ts +0 -57
  100. package/src/components/popup/popup.module.scss +0 -43
  101. package/src/components/popup/popup.ts +0 -395
  102. package/src/components/progress/progress.module.scss +0 -57
  103. package/src/components/progress/progress.ts +0 -43
  104. package/src/components/rating/rating.module.scss +0 -23
  105. package/src/components/rating/rating.ts +0 -125
  106. package/src/components/rating/star-sharp-light.svg +0 -1
  107. package/src/components/rating/star-sharp-solid.svg +0 -1
  108. package/src/components/shared.scss +0 -76
  109. package/src/components/sizers/sizer.module.scss +0 -90
  110. package/src/components/sizers/sizer.ts +0 -120
  111. package/src/components/slider/slider.module.scss +0 -71
  112. package/src/components/slider/slider.ts +0 -143
  113. package/src/components/switch/switch.module.scss +0 -127
  114. package/src/components/switch/switch.ts +0 -56
  115. package/src/components/tabs/tabs.module.scss +0 -46
  116. package/src/components/tabs/tabs.ts +0 -157
  117. package/src/components/textarea/textarea.module.scss +0 -59
  118. package/src/components/textarea/textarea.ts +0 -54
  119. package/src/components/textedit/textedit.module.scss +0 -114
  120. package/src/components/textedit/textedit.ts +0 -82
  121. package/src/components/themes.scss +0 -77
  122. package/src/components/tooltips/circle-info-sharp-light.svg +0 -1
  123. package/src/components/tooltips/tooltips.scss +0 -51
  124. package/src/components/tooltips/tooltips.ts +0 -103
  125. package/src/components/treeview/chevron-down-light.svg +0 -1
  126. package/src/components/treeview/treeview.module.scss +0 -116
  127. package/src/components/treeview/treeview.ts +0 -403
  128. package/src/components/viewport/viewport.module.scss +0 -25
  129. package/src/components/viewport/viewport.ts +0 -38
  130. package/src/core/component.ts +0 -979
  131. package/src/core/core_colors.ts +0 -250
  132. package/src/core/core_dom.ts +0 -471
  133. package/src/core/core_dragdrop.ts +0 -201
  134. package/src/core/core_element.ts +0 -98
  135. package/src/core/core_events.ts +0 -149
  136. package/src/core/core_i18n.ts +0 -377
  137. package/src/core/core_router.ts +0 -221
  138. package/src/core/core_styles.ts +0 -215
  139. package/src/core/core_svg.ts +0 -550
  140. package/src/core/core_tools.ts +0 -673
  141. package/src/demo/assets/house-light.svg +0 -1
  142. package/src/demo/assets/radio.svg +0 -4
  143. package/src/demo/index.html +0 -12
  144. package/src/demo/main.scss +0 -21
  145. package/src/demo/main.tsx +0 -323
  146. package/src/x4.scss +0 -19
  147. package/tsconfig.json +0 -14
  148. package/types/svg.d.ts +0 -4
  149. package/types/x4react.d.ts +0 -9
  150. /package/{types → lib/src/types}/scss.d.ts +0 -0
package/scripts/build.mjs DELETED
@@ -1,362 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * @file build.mjs
5
- * @author Etienne Cochard
6
- * @copyright (c) 2024 R-libre ingenierie, all rights reserved.
7
- * @version 1.2
8
- **/
9
-
10
- import * as fs from "node:fs"
11
- import * as path from "node:path"
12
- import * as url from "node:url"
13
- import * as http from "node:http"
14
-
15
- import chalk from "chalk"
16
- import esbuild from "esbuild"
17
- import { WebSocketServer } from 'ws';
18
- import Watcher from "watcher"
19
-
20
- import { sassPlugin } from "esbuild-sass-plugin";
21
- //import { hostname } from 'node:os'
22
-
23
- console.log( chalk.green("\n\n-- X4Build 1.2 -------------------") );
24
-
25
- const releaseMode = process.argv.some(a => a == "--release")
26
- const hmrMode = process.argv.some(a => a == "--hmr") // hot module replacement
27
- const watchMode = process.argv.some(a => a == "--watch" ) // watch modifications
28
- const serveMode = process.argv.some(a => a == "--serve") // watch modifications
29
- const cjsMode = process.argv.some(a => a == "--cjs") // output mode
30
- let outDir = process.argv.find( a => a.startsWith("--outdir=") );
31
- if( outDir ) {
32
- outDir = outDir.substring(9);
33
- }
34
-
35
- console.log( "outdir =", outDir );
36
-
37
-
38
- function readPackage() {
39
-
40
- let cpath = process.cwd();
41
-
42
- // check here
43
- let pth = path.join(cpath, "package.json");
44
- if (fs.existsSync(pth)) {
45
- const raw = fs.readFileSync(pth, "utf-8");
46
- return JSON.parse(raw);
47
- }
48
-
49
- throw new Error("cannot find package.json");
50
- }
51
-
52
- const def_settings = {
53
- "entryPoints": ["src/main.ts"],
54
- "outdir": "./bin",
55
- "copy": [],
56
- };
57
-
58
- const pkg_settings = readPackage();
59
- const settings = { ...def_settings, ...pkg_settings.x4build };
60
-
61
- if( outDir ) {
62
- settings.outdir = outDir;
63
- }
64
-
65
- console.log( chalk.green(" release mode ..", releaseMode ) );
66
- console.log( chalk.green(" hmr ...........", hmrMode ) );
67
- console.log( chalk.green(" watching ......", watchMode ) );
68
- console.log( chalk.green(" serve files ...", serveMode ) );
69
- console.log( chalk.green(" output dir ....", settings.outdir ) );
70
- console.log( chalk.green(" entry point ...", settings.entryPoints ) );
71
- console.log( chalk.green(" copying .......", settings.copy ) );
72
-
73
- console.log( chalk.green("----------------------------------") );
74
-
75
-
76
-
77
-
78
- const js_hmr = ` // X4 Hot Module Replacement v1.1
79
- {
80
- const ws = new WebSocket( "ws://127.0.0.1:9998", "hmr" );
81
-
82
- ws.onmessage = ( ev ) => {
83
- if( ev.data=="reload-css" ) {
84
- const gen_id = Date.now( );
85
- document.querySelectorAll( "link[rel=stylesheet]").forEach( link => {
86
- link.href = link.href.replace(/\\?.*|$/, "?" + gen_id)
87
- } );
88
- }
89
- else {
90
- location.reload();
91
- }
92
- }
93
- }`
94
-
95
- /** custom plugin to copy element after the build */
96
-
97
- const post_plugin = {
98
- name: 'post-cmd',
99
- setup(build) {
100
-
101
- build.onEnd(result => {
102
- if (result.errors.length) {
103
- console.error(`build ended with ${result.errors.length} errors`)
104
- }
105
- else {
106
- settings.copy?.forEach((desc) => {
107
- const { from, to } = desc;
108
-
109
- if (fs.existsSync(from)) {
110
- fs.cpSync(from, path.join(settings.outdir, to), { recursive: true });
111
- }
112
- });
113
- }
114
- })
115
- },
116
- }
117
-
118
- let buildcnt = 1;
119
-
120
- async function build() {
121
-
122
- console.log(chalk.cyan(`building (${buildcnt++})...`));
123
-
124
- try {
125
- /** @type {esbuild.BuildOptions} */
126
- const options = {
127
- target: "node12",
128
- logLevel: "error",
129
- entryPoints: settings.entryPoints,
130
- bundle: true,
131
- charset: "utf8",
132
- outdir: settings.outdir,
133
- keepNames: true,
134
- platform: "node",
135
- format: cjsMode ? "cjs" : "esm",
136
- minify: releaseMode,
137
- plugins: [
138
- sassPlugin( {
139
- type: "css",
140
- filter: /\.scss$/,
141
- }),
142
- post_plugin
143
- ],
144
- assetNames: "assets/[name]-[hash]",
145
- loader: {
146
- ".svg": "dataurl",
147
- ".jpg": "file",
148
- ".png": "file",
149
- ".woff": "file",
150
- ".woff2": "file",
151
- }
152
- }
153
-
154
- if (!releaseMode) {
155
- options.sourcemap = "inline";
156
- }
157
-
158
- if (hmrMode) {
159
- options.banner = { js: js_hmr }
160
- }
161
-
162
- await esbuild.build(options);
163
- }
164
- catch (e) {
165
- console.error(chalk.bgRed.white("build failure, waiting for correction"));
166
- console.log(e.message);
167
- }
168
- }
169
-
170
- // :: WEBSOCKET SERVER FOR HRM ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
171
-
172
- if (watchMode) {
173
-
174
- const wsServer = new WebSocketServer({
175
- port: 9998
176
- });
177
-
178
- // all connected clients (1)
179
- const clients = [];
180
-
181
- wsServer.on('connection', (ws) => {
182
- clients.push(ws);
183
-
184
- wsServer.on('error', (err) => {
185
- });
186
-
187
- wsServer.on('message', function message(data) {
188
- console.log('received: %s', data);
189
- });
190
- });
191
-
192
- const sendClientMessage = (msg) => {
193
- clients.forEach(ws => {
194
- ws.send(msg);
195
- });
196
- }
197
-
198
- // file watcher ------------------------------------------
199
- const selfPath = url.fileURLToPath(import.meta.url);
200
- const cPath = process.cwd();
201
-
202
- const watcher = new Watcher("./", {
203
- recursive: true,
204
- ignoreInitial: true,
205
- ignore: (targetPath) => {
206
- if (targetPath.startsWith(cPath)) {
207
- targetPath = path.join(".", targetPath.substring(cPath.length));
208
- targetPath = path.normalize(targetPath);
209
- }
210
-
211
- if (targetPath.startsWith("bin") || targetPath.startsWith("node_modules") ) {
212
- //console.log("skip watch", targetPath);
213
- return true;
214
- }
215
-
216
- return false;
217
- }
218
- });
219
-
220
-
221
- watcher.on('all', async (event, targetPath, targetPathNext) => {
222
-
223
- if (event == "change" || event == "add") {
224
- // one of our copy path ?
225
- if (targetPath.startsWith(cPath)) {
226
- let pth = "." + targetPath.substring(cPath.length);
227
- pth = path.normalize(pth);
228
-
229
- //console.log( targetPath );
230
- if (settings.copy?.some(desc => {
231
- const from = path.normalize(desc.from);
232
- if (pth == from || pth.startsWith(from)) {
233
- return true;
234
- }
235
- })) {
236
- await build();
237
- return;
238
- }
239
- }
240
- }
241
-
242
- if (event == "change") {
243
- // somebody changed this file, so leave
244
- if (targetPath == selfPath) {
245
- process.exit(0);
246
- }
247
-
248
- // depending of the extension, we send the correct type of refresh
249
- switch (path.extname(targetPath)) {
250
- case ".svg":
251
- case ".css":
252
- case ".scss": {
253
- await build();
254
- sendClientMessage("reload-css");
255
- break;
256
- }
257
-
258
- case ".html":
259
- case ".ts":
260
- case ".js":
261
- case ".jsx":
262
- case ".tsx": {
263
- await build();
264
- sendClientMessage("reload-js");
265
- break;
266
- }
267
-
268
- case ".json": {
269
- if (path.basename(targetPath) == 'package.json') {
270
- build();
271
- }
272
- break;
273
- }
274
- }
275
-
276
- //console.log ( event ); // => could be any target event: 'add', 'addDir', 'change', 'rename', 'renameDir', 'unlink' or 'unlinkDir'
277
- //console.log ( targetPath ); // => the file system path where the event took place, this is always provided
278
- }
279
- });
280
- }
281
-
282
- // :: WEB SERVER ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
283
-
284
- function serve() {
285
-
286
- // maps file extention to MIME types
287
- // full list can be found here: https://www.freeformatter.com/mime-types-list.html
288
- const mimeType = {
289
- '.ico': 'image/x-icon',
290
- '.html': 'text/html',
291
- '.js': 'text/javascript',
292
- '.json': 'application/json',
293
- '.css': 'text/css',
294
- '.png': 'image/png',
295
- '.jpg': 'image/jpeg',
296
- '.wav': 'audio/wav',
297
- '.mp3': 'audio/mpeg',
298
- '.svg': 'image/svg+xml',
299
- '.pdf': 'application/pdf',
300
- '.zip': 'application/zip',
301
- '.doc': 'application/msword',
302
- '.eot': 'application/vnd.ms-fontobject',
303
- '.ttf': 'application/x-font-ttf',
304
- };
305
-
306
- const server = http.createServer( {
307
- hostname: "127.0.0.1"
308
- });
309
-
310
- server.on('request', (req, res) => {
311
- //console.log(`${req.method} ${req.url}`);
312
-
313
- // parse URL
314
- const parsedUrl = url.parse(req.url);
315
-
316
- // extract URL path
317
- // Avoid https://en.wikipedia.org/wiki/Directory_traversal_attack
318
- // e.g curl --path-as-is http://localhost:9000/../fileInDanger.txt
319
- // by limiting the path to current directory only
320
- const sanitizePath = path.normalize(parsedUrl.pathname).replace(/^(\.\.[\/\\])+/, '');
321
- let pathname = path.join(settings.outdir, sanitizePath);
322
-
323
- if( fs.existsSync(pathname) ) {
324
- // if is a directory, then look for index.html
325
- if (fs.statSync(pathname).isDirectory()) {
326
- pathname = path.join( pathname, 'index.html' );
327
- }
328
-
329
- // read file from file system
330
- fs.readFile(pathname, function (err, data) {
331
- if (err) {
332
- res.statusCode = 500;
333
- res.end(`Error getting the file: ${err}.`);
334
- }
335
- else {
336
- // based on the URL path, extract the file extention. e.g. .js, .doc, ...
337
- const ext = path.parse(pathname).ext;
338
- // if the file is found, set Content-type and send data
339
- res.setHeader('Content-type', mimeType[ext] || 'text/plain');
340
- res.end(data);
341
- }
342
- });
343
- }
344
- else {
345
- // if the file is not found, return 404
346
- res.statusCode = 404;
347
- res.end(`File ${pathname} not found!`);
348
- return;
349
- }
350
- });
351
-
352
- server.listen(3000);
353
- console.log( chalk.yellow("listening on http://127.0.0.1:3000") );
354
- }
355
-
356
- build();
357
-
358
- if( serveMode ) {
359
- serve();
360
- }
361
-
362
-
@@ -1,51 +0,0 @@
1
- import * as fs from 'node:fs';
2
- import * as path from "node:path"
3
- import chalk from "chalk"
4
-
5
- import { execSync } from "node:child_process";
6
-
7
- function readPackage() {
8
-
9
- let cpath = process.cwd();
10
-
11
- // check here
12
- let pth = path.join(cpath, "package.json");
13
- if (fs.existsSync(pth)) {
14
- const raw = fs.readFileSync(pth, "utf-8");
15
- return JSON.parse(raw);
16
- }
17
-
18
- throw new Error("cannot find package.json");
19
- }
20
-
21
- async function main( ) {
22
-
23
- const pkg = readPackage( );
24
-
25
- console.log( chalk.yellow("-- prepack ------------------------"))
26
-
27
- fs.mkdirSync( 'lib/src', { recursive: true} );
28
- fs.mkdirSync( 'lib/styles', { recursive: true} );
29
- fs.mkdirSync( 'lib/types', { recursive: true} );
30
-
31
- console.log( chalk.green("building esm...") );
32
- execSync( "node scripts/build.mjs --release --outdir=lib/esm" );
33
-
34
- console.log( chalk.green("building cjs...") );
35
- execSync( "node scripts/build.mjs --release --cjs --outdir=lib/cjs" );
36
-
37
- console.log( chalk.green("creating .d.ts...") );
38
- execSync( `npx dts-generator --project . --out lib/types/x4.d.ts` );
39
-
40
- console.log( chalk.green("copying dependencies...") );
41
-
42
- fs.cpSync( 'lib/esm/x4.css', 'lib/styles/x4.css' );
43
- fs.renameSync( 'lib/esm/x4.js', 'lib/esm/x4.mjs' );
44
-
45
- fs.cpSync( 'src/', 'lib/src/', { recursive: true} );
46
- fs.cpSync( 'README.md', 'lib/README.txt' );
47
-
48
- console.log( chalk.yellow("-----------------------------------"))
49
- }
50
-
51
- main( );
@@ -1,26 +0,0 @@
1
- /**
2
- * ___ ___ __
3
- * \ \/ / / _
4
- * \ / /_| |_
5
- * / \____ _|
6
- * /__/\__\ |_|
7
- *
8
- * @file base.scss
9
- * @author Etienne Cochard
10
- *
11
- * @copyright (c) 2024 R-libre ingenierie
12
- *
13
- * Use of this source code is governed by an MIT-style license
14
- * that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
15
- **/
16
-
17
- @use "./shared.scss";
18
-
19
- .x4box {
20
- @extend .box;
21
- }
22
-
23
- .x4flex {
24
- @extend .flex;
25
- }
26
-
@@ -1,37 +0,0 @@
1
- /**
2
- * ___ ___ __
3
- * \ \/ / / _
4
- * \ / /_| |_
5
- * / \____ _|
6
- * /__/\__\ |_|
7
- *
8
- * @file boxes.module.scss
9
- * @author Etienne Cochard
10
- *
11
- * @copyright (c) 2024 R-libre ingenierie
12
- *
13
- * Use of this source code is governed by an MIT-style license
14
- * that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
15
- **/
16
-
17
- @use "../shared.scss";
18
-
19
- .x4hbox {
20
- @extend .hbox;
21
- }
22
-
23
- .x4vbox {
24
- @extend .vbox;
25
- }
26
-
27
- .x4stackbox {
28
- &>* {
29
- @extend .fit;
30
- position: relative !important;
31
- }
32
-
33
- &>*:not(.selected) {
34
- display: none;
35
- }
36
- }
37
-
@@ -1,125 +0,0 @@
1
- /**
2
- * ___ ___ __
3
- * \ \/ / / _
4
- * \ / /_| |_
5
- * / \____ _|
6
- * /__/\__\ |_|
7
- *
8
- * @file boxes.ts
9
- * @author Etienne Cochard
10
- *
11
- * @copyright (c) 2024 R-libre ingenierie
12
- *
13
- * Use of this source code is governed by an MIT-style license
14
- * that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
15
- **/
16
-
17
- import { Component, ComponentEvents, ComponentProps } from "@core/component"
18
-
19
- import "./boxes.module.scss";
20
-
21
- export interface BoxProps extends ComponentProps {
22
- }
23
-
24
- /**
25
- *
26
- */
27
-
28
- export class Box<P extends BoxProps=BoxProps,E extends ComponentEvents=ComponentEvents> extends Component<P,E> {
29
- }
30
-
31
-
32
- /**
33
- *
34
- */
35
-
36
- export class HBox<P extends BoxProps=BoxProps,E extends ComponentEvents=ComponentEvents> extends Box<P,E> {
37
- }
38
-
39
- /**
40
- *
41
- */
42
-
43
- export class VBox<P extends BoxProps=BoxProps,E extends ComponentEvents=ComponentEvents> extends Box<P,E> {
44
- constructor( p: P ) {
45
- super( p );
46
- }
47
- }
48
-
49
-
50
- /**
51
- * stack of widgets where only one widget is visible at a time
52
- */
53
-
54
- interface StackItem {
55
- name: string;
56
- content: Component;
57
- }
58
-
59
- interface StackedLayoutProps extends Omit<ComponentProps,"content"> {
60
- default: string;
61
- items: StackItem[];
62
- }
63
-
64
- interface _StackItem extends StackItem {
65
- page: Component;
66
- }
67
-
68
- export class StackBox extends Box<StackedLayoutProps> {
69
-
70
- private _items: _StackItem[];
71
-
72
- constructor( props: StackedLayoutProps ) {
73
- super( props );
74
-
75
- this._items = props.items?.map( itm => {
76
- return { ...itm, page: null };
77
- });
78
-
79
- if( props.default ) {
80
- this.select( props.default );
81
- }
82
- else if( this._items.length ) {
83
- this.select( this._items[0].name );
84
- }
85
- }
86
-
87
- select( name: string ) {
88
- let sel = this.query( `.selected` );
89
- if( sel ) {
90
- sel.setClass( "selected", false );
91
- }
92
-
93
- const pg = this._items.find( x => x.name==name );
94
- if( pg ) {
95
- if( !pg.page ) {
96
- pg.page = this._createPage( pg );
97
- this.appendContent( pg.page );
98
- }
99
-
100
- sel = pg.page;
101
- if( sel ) {
102
- sel.setClass( "selected", true );
103
- }
104
- }
105
- }
106
-
107
- /**
108
- *
109
- */
110
-
111
- private _createPage( page: _StackItem ) {
112
-
113
- let content: Component;
114
- //if( page.content instanceof ComponentBuilder ) {
115
- // content = page.content.create( );
116
- //}
117
- //else {
118
- content = page.content;
119
- //}
120
-
121
- content?.setData( "stackname", page.name );
122
- return content;
123
- }
124
- }
125
-
@@ -1,29 +0,0 @@
1
- /**
2
- * ___ ___ __
3
- * \ \/ / / _
4
- * \ / /_| |_
5
- * / \____ _|
6
- * /__/\__\ |_|
7
- *
8
- * @file btngroup.model.scss
9
- * @author Etienne Cochard
10
- *
11
- * @copyright (c) 2024 R-libre ingenierie
12
- *
13
- * Use of this source code is governed by an MIT-style license
14
- * that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
15
- **/
16
-
17
- .x4btngroup {
18
- align-content: start;
19
- margin: 5px;
20
- gap: 4px;
21
-
22
- &.align-right {
23
- justify-content: end;
24
- }
25
-
26
- &.align-center {
27
- justify-content: center;
28
- }
29
- }