jsgui3-server 0.0.122 → 0.0.124

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 (40) hide show
  1. package/examples/box/1) square box/server.js +2 -2
  2. package/examples/box/2) twenty square boxes/css flex wrap/client.js +2 -138
  3. package/examples/box/2) twenty square boxes/css flex wrap/server.js +1 -74
  4. package/examples/box/3) twenty selectable square boxes/css flex wrap/client.js +104 -0
  5. package/examples/box/3) twenty selectable square boxes/css flex wrap/server.js +39 -0
  6. package/examples/box/4) twenty composition selectable square boxes/css flex wrap/client.js +151 -0
  7. package/examples/box/4) twenty composition selectable square boxes/css flex wrap/server.js +39 -0
  8. package/examples/box/5) square box compositional dragable/client.js +204 -0
  9. package/examples/box/5) square box compositional dragable/server.js +113 -0
  10. package/examples/boxes/square_boxes.js +1 -1
  11. package/examples/color_palette.js +1 -1
  12. package/examples/controls/1) window/server.js +1 -1
  13. package/examples/controls/10) window, mirrored text inputs/client.js +0 -202
  14. package/examples/controls/10) window, mirrored text inputs/server.js +2 -82
  15. package/examples/controls/11) window, mirrored text fields/server.js +1 -1
  16. package/examples/controls/11b) window, shared Data_Object model mirrored text fields/server.js +1 -1
  17. package/examples/controls/11c) window, shared Data_Value model mirrored text fields/server.js +1 -1
  18. package/examples/controls/11d) window, shared model mirrored integer text fields/server.js +1 -1
  19. package/examples/controls/12) window, Select_Options control/client.js +1 -370
  20. package/examples/controls/12) window, Select_Options control/server.js +1 -99
  21. package/examples/controls/13) window, Dropdown_Menu control/client.js +66 -0
  22. package/examples/controls/13) window, Dropdown_Menu control/server.js +21 -0
  23. package/examples/controls/2) two windows/server.js +1 -1
  24. package/examples/controls/3) five windows/server.js +1 -1
  25. package/examples/controls/5) window, grid/server.js +1 -1
  26. package/examples/controls/6) window, color_palette/client.js +2 -138
  27. package/examples/controls/6) window, color_palette/server.js +1 -1
  28. package/examples/controls/7) window, month_view/client.js +19 -12
  29. package/examples/controls/8) window, checkbox/client.js +25 -239
  30. package/examples/controls/8) window, checkbox/server.js +1 -1
  31. package/examples/controls/9) window, date picker/client.js +2 -229
  32. package/examples/controls/9) window, date picker/server.js +1 -1
  33. package/examples/controls/9b) window, shared data.model mirrored date pickers/README.md +51 -0
  34. package/examples/controls/9b) window, shared data.model mirrored date pickers/client.js +64 -379
  35. package/examples/controls/9b) window, shared data.model mirrored date pickers/server.js +1 -1
  36. package/examples/grids/grid_1.js +1 -1
  37. package/examples/introducing jsgui3/server.js +1 -1
  38. package/examples/mx_display/mx_display_1.js +1 -1
  39. package/package.json +8 -8
  40. package/page-context.js +1 -0
@@ -4,82 +4,9 @@ const {Demo_UI} = jsgui.controls;
4
4
  const Server = require('../../../server');
5
5
 
6
6
 
7
- // what would be the (best?) way to include the whole thing in one JS file?
8
- // Maybe don't try that right now.
9
- // maybe standardise on the dir, then client.js and server.js inside.
10
-
11
-
12
-
13
- // Want to exclude this from the client bundle.
14
- // Some kind of marking to say that it's server-side only?
15
-
16
- // Need to include JSGUI3 js within the client document.
17
- // Seems like an earlier code simplification removed this functionality?
18
- // Just specifying a Ctrl for the server - and giving it the 'disk_path_client_js'.
19
- // May as well fix that....
20
-
21
-
22
- // The server code may be tiny, it seems best not to abstract it away totally though.
23
- // At least not for the moment.
24
-
25
-
26
-
27
-
28
7
 
29
8
  if (require.main === module) {
30
-
31
- // By default should include the JS and the CSS.
32
- // By reference, serving them from their respective paths.
33
-
34
-
35
- // This API is not working right now.
36
-
37
- // A very simple syntax for running a single control would be great.
38
-
39
- // Need to in the default (server) configuration build and serve the client-side app.
40
- // Want to be able to make interactive apps quickly with minimal server side code that needs to be written as boilerplate to
41
- // get the app running.
42
-
43
- // Though maybe defining a webpage, that serves the client js, and renders the control on the server, and activates it on the client,
44
- // would be the right approach.
45
-
46
- // Want to make the code really explicit, in a simple way.
47
-
48
-
49
- // eg { '/': Demo_UI }
50
- // eg { '*': Demo_UI }
51
- // as at least it explicitly assigns it to the '/' route
52
-
53
-
54
- // But worth keeping the '/' Ctrl property?
55
- // Could change it to explicitly setting the route(s).
56
-
57
- // Do want it to build the client js on start.
58
-
59
- // Could extract the CSS from the file itself, or maybe better reading it from the classes and objects that are loaded / referenced.
60
- // All kinds of complex server program structures exist already, so could use Publishers if needed for some things.
61
- // But need to keep the surface-level API really simple.
62
-
63
- // Maybe define a Webpage and maybe use / define an HTML_Webpage_Publisher for example too.
64
- // The clearest code would be really explicit about what it does, but in terms of almost English idioms
65
- // and on the surface-level not spelling out in great detail what it's doing, but referencing objects and
66
- // instructions with clear purposes, though details could be obscure at the top level. Eg it's the publisher's responsibility
67
- // to include the CSS and JS that's needed to get it to run. A publisher is referenced and used, and it does its thing.
68
-
69
- // The Server could automatically involk the use of a Publisher.
70
- // May be better to either require or recommend more explicit code, have them in the examples,
71
- // but also to document some shortcuts, defaults, and abbreviations (though they may omit some essential info, so not recommended for beginners)
72
-
73
- // Could have a tabbed view for examples for 'explicit' and 'short' notations when there are multiple.
74
-
75
- // jsgui3-html-suite may be of use, for some more extended controls that are built on top of jsgui3-html, but not specifically
76
- // client or server.
77
-
78
-
79
-
80
-
81
-
82
-
9
+
83
10
  const server = new Server({
84
11
  Ctrl: Demo_UI,
85
12
  //debug: true,
@@ -91,18 +18,14 @@ if (require.main === module) {
91
18
  //debug: true // should not minify the js, should include the symbols.
92
19
  //js_client: require.resolve('./square_box.js')
93
20
  });
94
- // A callback or event for when the bundling has been completed
95
- // a 'ready' event.
96
21
 
97
- // then start the server....
98
- // be able to choose the port / ports?
99
22
  console.log('waiting for server ready event');
100
23
  server.one('ready', () => {
101
24
  console.log('server ready');
102
25
 
103
26
  // server start will change to observable?
104
27
 
105
- server.start(8080, function (err, cb_start) {
28
+ server.start(52000, function (err, cb_start) {
106
29
  if (err) {
107
30
  throw err;
108
31
  } else {
@@ -112,7 +35,4 @@ if (require.main === module) {
112
35
  }
113
36
  });
114
37
  })
115
-
116
-
117
-
118
38
  }
@@ -102,7 +102,7 @@ if (require.main === module) {
102
102
 
103
103
  // server start will change to observable?
104
104
 
105
- server.start(8080, function (err, cb_start) {
105
+ server.start(52000, function (err, cb_start) {
106
106
  if (err) {
107
107
  throw err;
108
108
  } else {
@@ -102,7 +102,7 @@ if (require.main === module) {
102
102
 
103
103
  // server start will change to observable?
104
104
 
105
- server.start(8080, function (err, cb_start) {
105
+ server.start(52000, function (err, cb_start) {
106
106
  if (err) {
107
107
  throw err;
108
108
  } else {
@@ -102,7 +102,7 @@ if (require.main === module) {
102
102
 
103
103
  // server start will change to observable?
104
104
 
105
- server.start(8080, function (err, cb_start) {
105
+ server.start(52000, function (err, cb_start) {
106
106
  if (err) {
107
107
  throw err;
108
108
  } else {
@@ -119,7 +119,7 @@ if (require.main === module) {
119
119
 
120
120
  // server start will change to observable?
121
121
 
122
- server.start(8080, function (err, cb_start) {
122
+ server.start(52000, function (err, cb_start) {
123
123
  if (err) {
124
124
  throw err;
125
125
  } else {
@@ -1,435 +1,66 @@
1
1
  const jsgui = require('jsgui3-client');
2
2
  const {controls, Control, mixins} = jsgui;
3
3
  const {dragable} = mixins;
4
-
5
-
6
4
  const {Checkbox, Date_Picker, Text_Input, Text_Field, Select_Options} = controls;
7
-
8
5
  const Active_HTML_Document = require('../../../controls/Active_HTML_Document');
9
-
10
- // Will make Date_Picker use progressive enhancement.
11
- // On activation would create a new element? Create a new sibling?
12
- // May want code that checks for .el being changed.
13
-
14
-
15
- /*
16
- Though this works through simple principles, it may be much better to do data binding with a shared ctrl.data.model.
17
- Want the top-level code to be really simple and intuitive when specifying data flows, and when not specifying them
18
- using sensible defaults.
19
-
20
- The granularity between data.model and view.model should help a lot.
21
-
22
- // Also data.model.value being a possible default.
23
- // Data models will become more advanced and capable of holding multiple values.
24
- // For the moment, although the Control_Data and Control_View classes exist, will continue with a POJO.
25
- // Then could later work on getter / setters for when a data.model or a view.model gets changed.
26
-
27
-
28
-
29
- Also should work on functional constraints or / and class based constraints for fields / text fields.
30
- // Both for data in the system, as well as in the UI.
31
- // Could integrate a bit more with data types / class data types.
32
-
33
- // Typed_Data_Value perhaps.
34
-
35
- // Anyway, want to set things up better with the .view.model and .data.model system.
36
-
37
- // Then later support more complex (and / or app-defined) data and view models.
38
-
39
- // Defining what the underlying data of the app is could help (a lot).
40
- // Some data may be for editing, some not.
41
-
42
- // A data model could have a bunch of news articles, and be set up so that they can be viewed nicely.
43
- // Would not be so important to edit the articles themselves, though maybe the user may want to tag them
44
- // and comment on them.
45
-
46
- // Mid-level complexity handling a fair bit of what needs to happen with multiple models, how updates get sequenced
47
- // but then at a high level code must be really simple.
48
- // Could distinguish between view and data models at high level - may help a lot in some cases.
49
- // However, will generally assume a shared data model between controls, not a shared view model, and the data model
50
- // will be updated with at least some small / sensible hesitation.
51
- // Maybe even define the update hesitations / update hesitation mode.
52
- // Data Model Update Hesitation Mode???
53
-
54
- // View Model To Data Model Syncing Update Hesitation Mode???
55
- // really explicit names on the more complex mid level will help the code and system to make sense.
56
-
57
- // syncing.view_to_data.hesitation = 'leave-control' ????
58
- // And could have that one as the default.
59
- // Or could hesitate / debounce 250ms for example.
60
- // Very very explicit on the more complex mid / lower level, so that it's really simple on the higher level,
61
- // and can (quickly?) get into more explicit details when needed.
62
-
63
- // Data model syncing seems best in general.
64
- // Then sync data model changes immediately to view models.
65
- // Then only sync view model changes to data model after necessary hesitation / event / confirmation.
66
- // Also be able to cancel view model changes (load values back from data model possibly, some contexts makes a lot more sense)
67
-
68
-
69
- // The view model is essentially internal to the control - though maybe it would integrate with a whole Page_Context view
70
- // model that's for all the controls...?
71
-
72
- // Internal and separate view models for the controls seems best for the moment.
73
- // Could always use refs to some place else.
74
-
75
- // Have the controls automatically create their view model.
76
-
77
- // Some controls should not determine the data model at application (or larger control) start.
78
- // Maybe some should?
79
-
80
- // Or better to change it so that the Data_Model gets set first, then all the controls given access to it at start (on server)
81
- // and get rendered on the server with the correct data, then on the client it only sets the view_model at the start.
82
- // Or does it???
83
- // Want different sensible options for getting that Data_Model to the client. Maybe getting the View_Model to the client????
84
-
85
- // Make it simple and easy to code on the top level API.
86
-
87
-
88
-
89
-
90
-
91
-
92
-
93
-
94
-
95
-
96
-
97
-
98
-
99
-
100
-
101
-
102
-
103
-
104
-
105
-
106
-
107
-
108
-
109
-
110
-
111
-
112
- */
113
-
114
-
115
-
116
-
117
-
118
6
  class Demo_UI extends Active_HTML_Document {
119
7
  constructor(spec = {}) {
120
8
  spec.__type_name = spec.__type_name || 'demo_ui';
121
9
  super(spec);
122
10
  const {context} = this;
123
-
124
- // Make sure it requires the correct CSS.
125
- // Though making that 'effortless' on the server may help more.
126
-
127
-
128
- // Maybe can't do this here???
129
-
130
- // Does not have .body (yet) on the client.
131
- // simple way to get the client to attach the body of the Active_HTML_Document?
132
- // maybe with jsgui-data-controls?
133
- // Though automatically having the .body property available on the client without sending extra HTTP
134
- // plumbing will help.
135
-
136
- // .body will not be available before activation.
137
-
138
-
139
- // .body should not be a normal function....?
140
- // a getter function would be better.
141
-
142
-
143
11
  if (typeof this.body.add_class === 'function') {
144
12
  this.body.add_class('demo-ui');
145
13
  }
146
-
147
- //console.log('this.body', this.body);
148
- //console.log('this.body.add_class', this.body.add_class);
149
-
150
-
151
14
  const compose = () => {
152
- // put 20 of them in place.
153
-
154
- // Then how to arrange them...?
155
-
156
-
157
-
158
-
159
15
  const window = new controls.Window({
160
16
  context: context,
161
17
  title: 'jsgui3-html Select_Options',
162
18
  pos: [5, 5]
163
19
  });
164
-
165
20
  window.size = [480, 160];
166
-
167
- // Without specifying the data model.
168
- // Should be able to use and refer to data and view models even when not specified.
169
- // Want this complexity on the lower level to enable simple (but not overly simple/simplstic) higher level programming.
170
-
171
-
172
-
173
- // Should set up its data model automatically if not specified here.
174
- // An independent data model, specifically for that text field.
175
-
176
- // Or in the data.model.label_text perhaps?
177
-
178
- // Want to make it easy to make and use somewhat more complex and expressive structures.
179
-
180
- // The text label makes more sense being in the view.data.model???
181
-
182
- // Should set up the ctrl.data.model.value and ctrl.data.model.options automatically.
183
- // Needs to be a somewhat complex and multi-stage process.
184
-
185
- // Maybe support some shared values, ie .value shared with one place, and .options shared with another.
186
-
187
- // Definitely want it to be simple to make with the high-level API.
188
- // Can operate by default in a sophisticated way under that, though make it simple and
189
- // easy to define what is and is not shared where.
190
-
191
- // Will soon approach it from the higher level app code that needs to specify which models / values are shared where and how.
192
-
193
-
194
- // Assign the data.model.options from the options in the spec.
195
- // don't need to give them as data.model or data.model.options.
196
-
197
- // .selected.index??
198
- // .selected.value???
199
-
200
- // Could also work with the 'selectable' mixin?
201
- // Some core selectable support built into that...?
202
-
203
-
204
-
205
-
206
- // .options.selected even????
207
-
208
- //.selectedIndex
209
-
210
-
211
-
212
-
213
-
214
21
  const select_options = new Select_Options({
215
22
  context,
216
23
  options: ['zero', 'one', 'two', 'three', 'four', 'five']
217
24
  });
218
-
219
-
220
25
  window.inner.add(select_options);
221
-
222
-
223
26
  this.body.add(window);
224
-
225
27
  this._ctrl_fields = this._ctrl_fields || {};
226
28
  this._ctrl_fields.select_options = this.select_options = select_options;
227
-
228
-
229
29
  }
230
30
  if (!spec.el) {
231
31
  compose();
232
32
  this.add_change_listeners();
233
33
  }
234
-
235
-
236
- // Can respond to / deal with changes to the data models here, not only when activated.
237
- // The data.model and view.model system seems to offer some higher level improved programming by putting
238
- // more in the constructor. Maybe the activated code ('.activate') would not be needed on higher level controls,
239
- // because the lower level ones will connect it all up the the dom <> view <> data models / system.
240
-
241
- // It even has a 'dom model' too, of sorts ????
242
- // Though currently it's not named that or considered that throughout the code there.
243
- // Could be worth moding to dom.model
244
- // then view.model
245
- // then data.model
246
-
247
- // Could be a structure that better supports non-dom models.
248
- // Though in this case, it would no yet have the refs to all the child things????
249
-
250
- // Getting that back in the 'compose' or 'recompose' stage could help.
251
- // Though it's currently auto-recompose pre activate.
252
-
253
- // Maybe want code to run either when activated, or post-compose.
254
- // add_change_listeners.
255
-
256
- // Would be run server-side after compose (or when composing it like that on the client)
257
- // but when it gets recomosed on the client-side would need to run then instead.
258
-
259
-
260
-
261
-
262
-
263
-
264
-
265
-
266
-
267
-
268
34
  }
269
-
270
35
  add_change_listeners() {
271
36
  const {select_options} = this;
272
-
273
- // Need to fix the text_field data model and view model system.
274
-
275
- //console.log('add_change_listeners');
276
-
277
- // Maybe it should always have a .data.model???
278
- // Makes sense in terms of plenty of controls.
279
-
280
-
281
-
282
-
283
37
  select_options.data.model.on('change', e => {
284
38
  console.log('select_options.data.model change e', e);
285
-
286
- /*
287
- if (e.name === 'value') {
288
- if (e.value !== e.old) {
289
- ti2.data.model.value = e.value;
290
- }
291
- }
292
- */
293
39
  });
294
-
295
-
296
40
  }
297
-
298
-
299
41
  activate() {
300
42
  if (!this.__active) {
301
43
  super.activate();
302
44
  const {context, ti1, ti2} = this;
303
-
304
45
  this.add_change_listeners();
305
-
306
-
307
46
  console.log('activate Demo_UI');
308
-
309
- // listen for change events.
310
- // would be nice to know which change events originated from the user interacting with that specific HTML element (or ctrl???)
311
-
312
- // e.from_user === true test.
313
-
314
- // e.user_initiated_on_this ????
315
-
316
-
317
-
318
-
319
- //console.log('activate Demo_UI');
320
- // listen for the context events regarding frames, changes, resizing.
321
-
322
47
  context.on('window-resize', e_resize => {
323
-
324
- // Could see about having some window contents bound through CSS to the size of the window.
325
- // Though having a framework of adjusting CSS from the JS on-the-fly could work too.
326
-
327
- // May be done with the 'bind' mixin, or will make more specific mixins to do things like bind
328
- // a control to the space within another control, space within a specific part of that control.
329
-
330
- // Or bind to parent size. That should be possible with CSS though.
331
- // May make some controls make more use of CSS by default
332
- // Or having an absolutely positioned box model used extensively could avoid some ambiguity, though
333
- // making use of and supporting generally respected CSS features will help too.
334
-
335
- //console.log('window-resize', e_resize);
336
-
337
- // Make all internal controls go absolute in terms of position
338
- // Remove them from their containers too?
339
- // Ie their containing divs?
340
-
341
- // Would be nice to do this really simple with a fn call or very simple piece of code.
342
- // Like get absolute position, set position to be absolute, move to that position.
343
- // Maybe something within jsgui3-client helps with this, this is more about what needs to be done on the client.
344
- // Though recognising perf implications, it's (more) OK to include client-side functionality in jsgui3-html.
345
-
346
-
347
-
348
-
349
-
350
-
351
48
  });
352
-
353
49
  }
354
50
  }
355
51
  }
356
-
357
- // Include this in bundling.
358
- // Want CSS bundling so that styles are read out from the JS document and compiled to a stylesheet.
359
-
360
- //controls.Demo_UI = Demo_UI;
361
-
362
- // A css file may be an easier way to get started...?
363
- // Want to support but not require css in js.
364
-
365
- // But need to set up the serving of the CSS both on the server, and on the client.
366
- // Ofc setting it up on the server first is important - then can that stage set it up in the doc sent to the client?
367
-
368
- // Including the CSS from the JS like before.
369
- // Needs to extract the CSS and serve it as a separate CSS file.
370
- // Should also have end-to-end regression tests so this does not break again in the future.
371
- // The code was kind of clunky and got refactored away.
372
- //
373
-
374
- // Would need to parse the JS files to extract the CSS.
375
- // Maybe could do it an easier way??? Now that it's easy, want a faster way.
376
-
377
-
378
52
  Demo_UI.css = `
379
-
380
53
  * {
381
54
  margin: 0;
382
55
  padding: 0;
383
56
  }
384
-
385
57
  body {
386
58
  overflow-x: hidden;
387
59
  overflow-y: hidden;
388
60
  background-color: #E0E0E0;
389
61
  }
390
-
391
62
  .demo-ui {
392
-
393
- /*
394
-
395
- display: flex;
396
- flex-wrap: wrap;
397
-
398
- flex-direction: column;
399
- justify-content: center;
400
- align-items: center;
401
- text-align: center;
402
- min-height: 100vh;
403
- */
404
-
405
63
  }
406
64
  `;
407
-
408
- // But may want to remove them from that flex upon picking up / dropping them.
409
- // Maybe best upon drop.
410
-
411
- // Maybe want other examples that use absolute positioning to position the items at the start?
412
- //
413
-
414
-
415
-
416
- //controls.Square_Box = Square_Box;
417
- // could export jsgui with the updated controls....
418
- // so that they are in the correct Page Context.?
419
-
420
-
421
65
  controls.Demo_UI = Demo_UI;
422
-
423
- module.exports = jsgui;
424
-
425
- /*
426
- module.exports = {
427
- Square_Box: Square_Box,
428
- Demo_UI: Demo_UI
429
- }
430
- */
431
-
432
- // Then if window...?
433
-
434
- // Need to add the Square_Box control to the context or original map of controls...
435
-
66
+ module.exports = jsgui;