jsgui3-server 0.0.126 → 0.0.128
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.
- package/README.md +18 -69
- package/examples/controls/11b) window, shared Data_Object model mirrored text fields/client.js +2 -2
- package/examples/controls/11c) window, shared Data_Value model mirrored text fields/client.js +2 -2
- package/examples/controls/11d) window, shared model mirrored integer text fields/client.js +31 -288
- package/examples/controls/2) two windows/client.js +23 -0
- package/examples/controls/2) two windows/server.js +0 -69
- package/examples/controls/8) window, checkbox/{client.js → a)/client.js } +1 -1
- package/examples/controls/8) window, checkbox/{server.js → a)/server.js } +1 -1
- package/examples/controls/8) window, checkbox/b)/client.js +36 -0
- package/examples/controls/8) window, checkbox/b)/server.js +36 -0
- package/examples/controls/9b) window, shared data.model mirrored date pickers/client.js +2 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -196,7 +196,6 @@ The framework includes several consistency verification patterns:
|
|
|
196
196
|
|
|
197
197
|
- **Console Logging:** Extensive logging during server startup and events
|
|
198
198
|
- **Port Configuration:** Standardized on port 52000 for examples
|
|
199
|
-
- **Hot Reloading:** Server can be restarted to pick up client.js changes
|
|
200
199
|
- **Activation Lifecycle:** `activate()` method provides hook for post-initialization logic
|
|
201
200
|
|
|
202
201
|
## Dependencies and Integration
|
|
@@ -301,8 +300,8 @@ if (date_picker_1.data.model !== date_picker_2.data.model) {
|
|
|
301
300
|
field(dm, 'value');
|
|
302
301
|
date_picker_1.data.model = dm;
|
|
303
302
|
date_picker_2.data.model = dm;
|
|
304
|
-
date_picker_1.assign_data_model_value_change_handler();
|
|
305
|
-
date_picker_2.assign_data_model_value_change_handler();
|
|
303
|
+
//date_picker_1.assign_data_model_value_change_handler();
|
|
304
|
+
//date_picker_2.assign_data_model_value_change_handler();
|
|
306
305
|
}
|
|
307
306
|
```
|
|
308
307
|
|
|
@@ -383,8 +382,7 @@ context.on('window-resize', e_resize => { });
|
|
|
383
382
|
### Event Naming Conventions
|
|
384
383
|
|
|
385
384
|
- `window-resize` - Browser window size changes
|
|
386
|
-
-
|
|
387
|
-
- Control-specific events follow `control-event` pattern
|
|
385
|
+
- Control-specific events follow framework patterns
|
|
388
386
|
|
|
389
387
|
## Control Composition Hierarchy
|
|
390
388
|
|
|
@@ -602,10 +600,8 @@ window.pos // Current position
|
|
|
602
600
|
```
|
|
603
601
|
|
|
604
602
|
**Window Features:**
|
|
605
|
-
- Draggable by title bar
|
|
606
|
-
-
|
|
607
|
-
- Close button functionality
|
|
608
|
-
- Z-index management for overlapping windows
|
|
603
|
+
- Draggable by title bar
|
|
604
|
+
- Window positioning and management
|
|
609
605
|
- Child control containment via `inner` property
|
|
610
606
|
|
|
611
607
|
### Data_Object Reactive System
|
|
@@ -665,9 +661,6 @@ context.on('event-name', handler);
|
|
|
665
661
|
|
|
666
662
|
// Common event types:
|
|
667
663
|
'window-resize' // Browser window size changes
|
|
668
|
-
'data-model-value-change' // Data model property updates
|
|
669
|
-
'control-activated' // Control becomes active
|
|
670
|
-
'control-deactivated' // Control becomes inactive
|
|
671
664
|
|
|
672
665
|
// Event handler patterns
|
|
673
666
|
context.on('window-resize', e_resize => {
|
|
@@ -700,8 +693,8 @@ activate() {
|
|
|
700
693
|
picker2.data.model = dm;
|
|
701
694
|
|
|
702
695
|
// Re-establish change handlers
|
|
703
|
-
picker1.assign_data_model_value_change_handler();
|
|
704
|
-
picker2.assign_data_model_value_change_handler();
|
|
696
|
+
//picker1.assign_data_model_value_change_handler();
|
|
697
|
+
//picker2.assign_data_model_value_change_handler();
|
|
705
698
|
}
|
|
706
699
|
}
|
|
707
700
|
}
|
|
@@ -714,11 +707,8 @@ activate() {
|
|
|
714
707
|
const sharedModel = new Data_Object({ context });
|
|
715
708
|
field(sharedModel, 'value');
|
|
716
709
|
|
|
717
|
-
const
|
|
718
|
-
|
|
719
|
-
new Text_Input({ context, data: { model: sharedModel } }),
|
|
720
|
-
new Display_Label({ context, data: { model: sharedModel } })
|
|
721
|
-
];
|
|
710
|
+
const date_picker_1 = new Date_Picker({ context, data: { model: sharedModel } });
|
|
711
|
+
const date_picker_2 = new Date_Picker({ context, data: { model: sharedModel } });
|
|
722
712
|
|
|
723
713
|
// Any control's changes propagate to all others
|
|
724
714
|
```
|
|
@@ -769,20 +759,14 @@ const server = new Server({
|
|
|
769
759
|
// 1. Browser requests application
|
|
770
760
|
// 2. Server serves bundled JavaScript
|
|
771
761
|
// 3. Client executes and creates UI
|
|
772
|
-
// 4.
|
|
773
|
-
// 5. UI events
|
|
774
|
-
// 6.
|
|
775
|
-
// 7. Model changes propagate back to client
|
|
762
|
+
// 4. Real-time updates handled through framework
|
|
763
|
+
// 5. UI events processed by client-side framework
|
|
764
|
+
// 6. Data model changes handled by shared state system
|
|
776
765
|
```
|
|
777
766
|
|
|
778
767
|
### Multi-Client Synchronization
|
|
779
768
|
|
|
780
|
-
|
|
781
|
-
// Server maintains shared state across multiple clients
|
|
782
|
-
// Changes from one client propagate to all connected clients
|
|
783
|
-
// Data models are server-authoritative
|
|
784
|
-
// Client UI updates reflect server state changes
|
|
785
|
-
```
|
|
769
|
+
Data models can be shared within a single client instance, enabling synchronized UI controls.
|
|
786
770
|
|
|
787
771
|
## CSS Architecture and Styling
|
|
788
772
|
|
|
@@ -855,14 +839,7 @@ context.on('window-resize', e_resize => {
|
|
|
855
839
|
```javascript
|
|
856
840
|
const checkbox = new Checkbox({
|
|
857
841
|
context,
|
|
858
|
-
label: { text: '
|
|
859
|
-
// Optional data binding
|
|
860
|
-
data: { model: booleanModel } // Binds to boolean field
|
|
861
|
-
});
|
|
862
|
-
|
|
863
|
-
// Checkbox events
|
|
864
|
-
checkbox.on('change', (checked) => {
|
|
865
|
-
// Handle checkbox state changes
|
|
842
|
+
label: { text: 'A checkbox' }
|
|
866
843
|
});
|
|
867
844
|
```
|
|
868
845
|
|
|
@@ -872,20 +849,10 @@ checkbox.on('change', (checked) => {
|
|
|
872
849
|
const tabbed_panel = new controls.Tabbed_Panel({
|
|
873
850
|
context,
|
|
874
851
|
tabs: [
|
|
875
|
-
|
|
876
|
-
'
|
|
877
|
-
|
|
878
|
-
// OR control-embedded tabs
|
|
879
|
-
['Tab 1', controlInstance1],
|
|
880
|
-
['Tab 2', controlInstance2],
|
|
881
|
-
['Tab 3', controlInstance3]
|
|
852
|
+
['tab 1', new Control({context, size: [250, 250], background: {color: '#553311'}})],
|
|
853
|
+
['tab 2', new Control({context, size: [250, 250], background: {color: '#1177AA'}})]
|
|
882
854
|
]
|
|
883
855
|
});
|
|
884
|
-
|
|
885
|
-
// Tab switching events
|
|
886
|
-
tabbed_panel.on('tab-changed', (tabIndex) => {
|
|
887
|
-
// Handle tab selection
|
|
888
|
-
});
|
|
889
856
|
```
|
|
890
857
|
|
|
891
858
|
### Date_Picker Control
|
|
@@ -893,16 +860,7 @@ tabbed_panel.on('tab-changed', (tabIndex) => {
|
|
|
893
860
|
```javascript
|
|
894
861
|
const date_picker = new Date_Picker({
|
|
895
862
|
context,
|
|
896
|
-
data: { model:
|
|
897
|
-
// Optional configuration
|
|
898
|
-
format: 'YYYY-MM-DD', // Date display format
|
|
899
|
-
minDate: new Date('2020-01-01'), // Minimum selectable date
|
|
900
|
-
maxDate: new Date('2030-12-31') // Maximum selectable date
|
|
901
|
-
});
|
|
902
|
-
|
|
903
|
-
// Date selection events
|
|
904
|
-
date_picker.on('date-selected', (date) => {
|
|
905
|
-
// Handle date selection
|
|
863
|
+
data: { model: sharedDataModel }
|
|
906
864
|
});
|
|
907
865
|
```
|
|
908
866
|
|
|
@@ -910,16 +868,7 @@ date_picker.on('date-selected', (date) => {
|
|
|
910
868
|
|
|
911
869
|
```javascript
|
|
912
870
|
const month_view = new Month_View({
|
|
913
|
-
context
|
|
914
|
-
// Optional configuration
|
|
915
|
-
showToday: true, // Highlight today's date
|
|
916
|
-
showWeekNumbers: false, // Show week numbers
|
|
917
|
-
firstDayOfWeek: 0 // 0=Sunday, 1=Monday, etc.
|
|
918
|
-
});
|
|
919
|
-
|
|
920
|
-
// Month navigation events
|
|
921
|
-
month_view.on('month-changed', (year, month) => {
|
|
922
|
-
// Handle month navigation
|
|
871
|
+
context
|
|
923
872
|
});
|
|
924
873
|
```
|
|
925
874
|
|
package/examples/controls/11b) window, shared Data_Object model mirrored text fields/client.js
CHANGED
|
@@ -418,8 +418,8 @@ class Demo_UI extends Active_HTML_Document {
|
|
|
418
418
|
// But then need to get them to reassign their data model change listeners....?
|
|
419
419
|
// value change even....
|
|
420
420
|
|
|
421
|
-
ti1.assign_data_model_value_change_handler();
|
|
422
|
-
ti2.assign_data_model_value_change_handler();
|
|
421
|
+
//ti1.assign_data_model_value_change_handler();
|
|
422
|
+
//ti2.assign_data_model_value_change_handler();
|
|
423
423
|
|
|
424
424
|
|
|
425
425
|
}
|
package/examples/controls/11c) window, shared Data_Value model mirrored text fields/client.js
CHANGED
|
@@ -422,8 +422,8 @@ class Demo_UI extends Active_HTML_Document {
|
|
|
422
422
|
// But then need to get them to reassign their data model change listeners....?
|
|
423
423
|
// value change even....
|
|
424
424
|
|
|
425
|
-
ti1.assign_data_model_value_change_handler();
|
|
426
|
-
ti2.assign_data_model_value_change_handler();
|
|
425
|
+
//ti1.assign_data_model_value_change_handler();
|
|
426
|
+
//ti2.assign_data_model_value_change_handler();
|
|
427
427
|
|
|
428
428
|
|
|
429
429
|
}
|
|
@@ -186,42 +186,7 @@ class Demo_UI extends Active_HTML_Document {
|
|
|
186
186
|
|
|
187
187
|
|
|
188
188
|
const compose = () => {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
// Then how to arrange them...?
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
// Setting up the shared model in composition would be best....
|
|
195
|
-
// Or maybe during init, pre-activate?
|
|
196
|
-
|
|
197
|
-
// This seems like it will need some lower level integration for ease of use.
|
|
198
|
-
// Would like this to work server-side when setting properties, so should not rely on having this
|
|
199
|
-
// in the 'activate' code.
|
|
200
|
-
|
|
201
|
-
// a 'model' property.
|
|
202
|
-
// maybe two model properties: view.model, data.model.
|
|
203
|
-
|
|
204
|
-
// There could be a 'confirm / cancel' dialog when the view.model has been changed, and the view model can be updated
|
|
205
|
-
|
|
206
|
-
// Also, a single model could enable an undo history.
|
|
207
|
-
|
|
208
|
-
// app.data.model?
|
|
209
|
-
// context.data.model?
|
|
210
|
-
|
|
211
|
-
// context.view.model could make sense too, for representing the state of the app view (ie windows maximised, minimised, positions)
|
|
212
|
-
// Could help when resuming the app at a later point, or transmitting the view of the app.
|
|
213
|
-
// Maybe for collaborative editing, could operate like shared screen, or each user has control over their own windows.
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
// context.model?
|
|
218
|
-
|
|
219
|
-
// ctrl.view.model perhaps???
|
|
220
|
-
// ctrl.data.model = context.model perhaps?
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
189
|
+
|
|
225
190
|
|
|
226
191
|
|
|
227
192
|
const window = new controls.Window({
|
|
@@ -232,51 +197,6 @@ class Demo_UI extends Active_HTML_Document {
|
|
|
232
197
|
|
|
233
198
|
window.size = [480, 160];
|
|
234
199
|
|
|
235
|
-
// Label text better propbably?
|
|
236
|
-
|
|
237
|
-
// .value
|
|
238
|
-
|
|
239
|
-
// .data.model = context.data.model
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
// set that 'value' to a data model ??? No.
|
|
243
|
-
// set it's 'model' or 'data.model'.
|
|
244
|
-
|
|
245
|
-
// data.model for the moment will be best.
|
|
246
|
-
// That is what we want to bind.
|
|
247
|
-
// View model and data model pair could allow for 'cancel | OK' options to confirm changes.
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
// 'data_model' property.
|
|
251
|
-
// 'dmodel', 'dm' too...?
|
|
252
|
-
// 'vm' possibly?
|
|
253
|
-
|
|
254
|
-
// .v.m shorthand??
|
|
255
|
-
// .d.m too?
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
// or data: {model: obj_data_model}
|
|
260
|
-
|
|
261
|
-
// The data model persistance must not be tricky here.
|
|
262
|
-
// Maybe setting it up at compose is not best???
|
|
263
|
-
// Makes for the nicest syntax here, the 'magic' about jsgui is handing things over to the client
|
|
264
|
-
// in a working way, auto-reconstructing things client-side.
|
|
265
|
-
// Would need to send over info on which Data_Model would be used...
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
// The shared data model should mean that these fields automatically stay in sync (somewhat)
|
|
269
|
-
// A shared view model would mean a more immediate sync.
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
// So Text_Field would need to look at data, data.model from the spec.
|
|
273
|
-
|
|
274
|
-
// Write the code in a few controls first, see what is in common and can be abstracted into a mixin
|
|
275
|
-
// such as control-data-model-sync
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
// Would change the 'value' property by default.
|
|
279
|
-
|
|
280
200
|
const ti1 = new Text_Field({
|
|
281
201
|
context,
|
|
282
202
|
|
|
@@ -296,23 +216,6 @@ class Demo_UI extends Active_HTML_Document {
|
|
|
296
216
|
|
|
297
217
|
window.inner.add(ti1);
|
|
298
218
|
|
|
299
|
-
// Though not sure they get reconstructed with that data model?
|
|
300
|
-
|
|
301
|
-
// Want to make this easy for the app programmer to get right in particular.
|
|
302
|
-
|
|
303
|
-
// May need (much) more work on persisting the data model to the client.
|
|
304
|
-
// Or defining it in a way / place so it can be started isomorphically.
|
|
305
|
-
// Though it may make sense to do more to transfer models from the server to the client, with their data.
|
|
306
|
-
// However, reconstructing models from the (values in) the DOM could make a lot of sense.
|
|
307
|
-
// Having it read the DOM to create its DOM model, then from that its view.data model, then its data model.
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
219
|
const ti2 = new Text_Field({
|
|
317
220
|
context,
|
|
318
221
|
|
|
@@ -330,21 +233,6 @@ class Demo_UI extends Active_HTML_Document {
|
|
|
330
233
|
window.inner.add(ti2);
|
|
331
234
|
|
|
332
235
|
this.body.add(window);
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
// ._ctrl_fields should automatically be set up.
|
|
337
|
-
// Also make it so when there are 0 entries in there it won't render the DOM attribute.
|
|
338
|
-
|
|
339
|
-
// First get the MVC properly and explicitly working accross some more controls.
|
|
340
|
-
// If any abstractions come really easily then do that.
|
|
341
|
-
// Maybe a DMVM_Control could be very effective soon.
|
|
342
|
-
|
|
343
|
-
// An 'adjuster' control could possibly have no 'data model' of its own.
|
|
344
|
-
// It could be set up to adjust either a data model, or a view model.
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
236
|
|
|
349
237
|
this._ctrl_fields = this._ctrl_fields || {};
|
|
350
238
|
this._ctrl_fields.ti1 = ti1;
|
|
@@ -363,33 +251,6 @@ class Demo_UI extends Active_HTML_Document {
|
|
|
363
251
|
|
|
364
252
|
console.log('activate Demo_UI');
|
|
365
253
|
|
|
366
|
-
//field(this.data.model, 'value');
|
|
367
|
-
// and events dealing with changes to those tis.
|
|
368
|
-
|
|
369
|
-
// ti1, ti2.
|
|
370
|
-
|
|
371
|
-
// Some kind of tracking of what the event initiator could help?
|
|
372
|
-
// Automatically avoiding feedback somehow???
|
|
373
|
-
// If it gets changed to its current value it does not push the change...?
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
// a non-dom change???
|
|
377
|
-
// or basically .view.model.change even????
|
|
378
|
-
|
|
379
|
-
// ti1.view.model.on('change') could be much clearer, disambiguating it from a dom change event.
|
|
380
|
-
// assign .view.model events ....?
|
|
381
|
-
// doing this on a lower level would help.
|
|
382
|
-
|
|
383
|
-
// Just creating .view and .view.model objects (getters and setters specified) in jsgui3-html will help
|
|
384
|
-
// when referring to them.
|
|
385
|
-
|
|
386
|
-
// Maybe see about better reconstruction....
|
|
387
|
-
|
|
388
|
-
//console.log('ti1.data.model', ti1.data.model);
|
|
389
|
-
//console.log('ti2.data.model', ti2.data.model);
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
254
|
const activate_demo_ui_data_model = () => {
|
|
394
255
|
console.log('ti1.data.model === ti2.data.model', ti1.data.model === ti2.data.model);
|
|
395
256
|
|
|
@@ -416,8 +277,8 @@ class Demo_UI extends Active_HTML_Document {
|
|
|
416
277
|
// But then need to get them to reassign their data model change listeners....?
|
|
417
278
|
// value change even....
|
|
418
279
|
|
|
419
|
-
ti1.assign_data_model_value_change_handler();
|
|
420
|
-
ti2.assign_data_model_value_change_handler();
|
|
280
|
+
//ti1.assign_data_model_value_change_handler();
|
|
281
|
+
//ti2.assign_data_model_value_change_handler();
|
|
421
282
|
|
|
422
283
|
|
|
423
284
|
}
|
|
@@ -425,131 +286,10 @@ class Demo_UI extends Active_HTML_Document {
|
|
|
425
286
|
|
|
426
287
|
activate_demo_ui_data_model();
|
|
427
288
|
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
// Create a new data_model (and view_model?) for both of them?
|
|
431
|
-
// The view_model gets created by default and does not need to be shared (and should not be)
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
// ti1.value.on('change') ????
|
|
438
|
-
// where the value is an Evented_Class or even Data_Object????
|
|
439
|
-
// and where we can also get the value out of it easily / do so automatically, maybe within other useful functions.
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
// ti1.model.on('change') ????
|
|
443
|
-
// or .view.model to be most specific for the moment...?
|
|
444
|
-
// and raise those events within the controls on those .view.model objects.
|
|
445
|
-
|
|
446
|
-
// Maybe just try it on Text_Field for the moment.
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
// Need to work on having it update the dom with value changes....
|
|
451
|
-
|
|
452
|
-
const old_activate_changes = () => {
|
|
453
|
-
|
|
454
|
-
ti1.model.on('change', e => {
|
|
455
|
-
//console.log('ti1 change e', e);
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
if (e.property_name === 'value') {
|
|
459
|
-
if (e.value !== e.old) {
|
|
460
|
-
ti2.value = e.value;
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
// setting ti2.view.model.value even????
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
})
|
|
470
|
-
ti2.model.on('change', e => {
|
|
471
|
-
//console.log('ti2 change e', e);
|
|
472
|
-
|
|
473
|
-
//
|
|
474
|
-
|
|
475
|
-
if (e.value !== e.old) {
|
|
476
|
-
ti1.value = e.value;
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
})
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
// listen for change events.
|
|
486
|
-
// would be nice to know which change events originated from the user interacting with that specific HTML element (or ctrl???)
|
|
487
|
-
|
|
488
|
-
// e.from_user === true test.
|
|
489
|
-
|
|
490
|
-
// e.user_initiated_on_this ????
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
//console.log('activate Demo_UI');
|
|
496
|
-
// listen for the context events regarding frames, changes, resizing.
|
|
497
|
-
|
|
498
|
-
context.on('window-resize', e_resize => {
|
|
499
|
-
|
|
500
|
-
// Could see about having some window contents bound through CSS to the size of the window.
|
|
501
|
-
// Though having a framework of adjusting CSS from the JS on-the-fly could work too.
|
|
502
|
-
|
|
503
|
-
// May be done with the 'bind' mixin, or will make more specific mixins to do things like bind
|
|
504
|
-
// a control to the space within another control, space within a specific part of that control.
|
|
505
|
-
|
|
506
|
-
// Or bind to parent size. That should be possible with CSS though.
|
|
507
|
-
// May make some controls make more use of CSS by default
|
|
508
|
-
// Or having an absolutely positioned box model used extensively could avoid some ambiguity, though
|
|
509
|
-
// making use of and supporting generally respected CSS features will help too.
|
|
510
|
-
|
|
511
|
-
//console.log('window-resize', e_resize);
|
|
512
|
-
|
|
513
|
-
// Make all internal controls go absolute in terms of position
|
|
514
|
-
// Remove them from their containers too?
|
|
515
|
-
// Ie their containing divs?
|
|
516
|
-
|
|
517
|
-
// Would be nice to do this really simple with a fn call or very simple piece of code.
|
|
518
|
-
// Like get absolute position, set position to be absolute, move to that position.
|
|
519
|
-
// Maybe something within jsgui3-client helps with this, this is more about what needs to be done on the client.
|
|
520
|
-
// Though recognising perf implications, it's (more) OK to include client-side functionality in jsgui3-html.
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
});
|
|
528
|
-
|
|
529
289
|
}
|
|
530
290
|
}
|
|
531
291
|
}
|
|
532
292
|
|
|
533
|
-
// Include this in bundling.
|
|
534
|
-
// Want CSS bundling so that styles are read out from the JS document and compiled to a stylesheet.
|
|
535
|
-
|
|
536
|
-
//controls.Demo_UI = Demo_UI;
|
|
537
|
-
|
|
538
|
-
// A css file may be an easier way to get started...?
|
|
539
|
-
// Want to support but not require css in js.
|
|
540
|
-
|
|
541
|
-
// But need to set up the serving of the CSS both on the server, and on the client.
|
|
542
|
-
// Ofc setting it up on the server first is important - then can that stage set it up in the doc sent to the client?
|
|
543
|
-
|
|
544
|
-
// Including the CSS from the JS like before.
|
|
545
|
-
// Needs to extract the CSS and serve it as a separate CSS file.
|
|
546
|
-
// Should also have end-to-end regression tests so this does not break again in the future.
|
|
547
|
-
// The code was kind of clunky and got refactored away.
|
|
548
|
-
//
|
|
549
|
-
|
|
550
|
-
// Would need to parse the JS files to extract the CSS.
|
|
551
|
-
// Maybe could do it an easier way??? Now that it's easy, want a faster way.
|
|
552
|
-
|
|
553
293
|
|
|
554
294
|
Demo_UI.css = `
|
|
555
295
|
|
|
@@ -564,6 +304,34 @@ body {
|
|
|
564
304
|
background-color: #E0E0E0;
|
|
565
305
|
}
|
|
566
306
|
|
|
307
|
+
|
|
308
|
+
.window .relative .inner {
|
|
309
|
+
padding: 0.38em;}
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
.window .relative .inner .text-field {
|
|
313
|
+
margin-top: 0.125em;
|
|
314
|
+
margin-bottom: 0.125em;
|
|
315
|
+
display: flex;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
.window .relative .inner .text-field label{
|
|
319
|
+
display: block;
|
|
320
|
+
width: 1.085em;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
.window .relative .inner .text-field .left {
|
|
327
|
+
margin-right: 0.125em;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
.window .relative .inner .text-field .right {
|
|
331
|
+
margin-left: 0.125em;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
|
|
567
335
|
.demo-ui {
|
|
568
336
|
|
|
569
337
|
/*
|
|
@@ -581,31 +349,6 @@ body {
|
|
|
581
349
|
}
|
|
582
350
|
`;
|
|
583
351
|
|
|
584
|
-
// But may want to remove them from that flex upon picking up / dropping them.
|
|
585
|
-
// Maybe best upon drop.
|
|
586
|
-
|
|
587
|
-
// Maybe want other examples that use absolute positioning to position the items at the start?
|
|
588
|
-
//
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
//controls.Square_Box = Square_Box;
|
|
593
|
-
// could export jsgui with the updated controls....
|
|
594
|
-
// so that they are in the correct Page Context.?
|
|
595
|
-
|
|
596
352
|
|
|
597
353
|
controls.Demo_UI = Demo_UI;
|
|
598
|
-
|
|
599
354
|
module.exports = jsgui;
|
|
600
|
-
|
|
601
|
-
/*
|
|
602
|
-
module.exports = {
|
|
603
|
-
Square_Box: Square_Box,
|
|
604
|
-
Demo_UI: Demo_UI
|
|
605
|
-
}
|
|
606
|
-
*/
|
|
607
|
-
|
|
608
|
-
// Then if window...?
|
|
609
|
-
|
|
610
|
-
// Need to add the Square_Box control to the context or original map of controls...
|
|
611
|
-
|
|
@@ -63,6 +63,28 @@ class Demo_UI extends Active_HTML_Document {
|
|
|
63
63
|
|
|
64
64
|
// Then how to arrange them...?
|
|
65
65
|
|
|
66
|
+
const num_windows = 2
|
|
67
|
+
let [x, y] = [40, 40];
|
|
68
|
+
|
|
69
|
+
// pos property?
|
|
70
|
+
//. consider a pos_info or pos_details property, or use another class to help with it.
|
|
71
|
+
|
|
72
|
+
// the .pos property would be a nice shortcut.
|
|
73
|
+
//. seems more like it's for enhanced controls? Not sure.
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
for (let c = 1; c <= num_windows; c++) {
|
|
77
|
+
const window = new controls.Window({
|
|
78
|
+
context: context,
|
|
79
|
+
title: c + ') jsgui3-html Window Control',
|
|
80
|
+
pos: [x, y]
|
|
81
|
+
})
|
|
82
|
+
this.body.add(window);
|
|
83
|
+
|
|
84
|
+
x += 0; y += 80;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/*
|
|
66
88
|
const window_1 = new controls.Window({
|
|
67
89
|
context: context,
|
|
68
90
|
title: '1) jsgui3-html Window Control'
|
|
@@ -74,6 +96,7 @@ class Demo_UI extends Active_HTML_Document {
|
|
|
74
96
|
title: '2) jsgui3-html Window Control'
|
|
75
97
|
})
|
|
76
98
|
this.body.add(window_2);
|
|
99
|
+
*/
|
|
77
100
|
|
|
78
101
|
|
|
79
102
|
}
|
|
@@ -4,78 +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
|
-
|
|
23
|
-
|
|
24
7
|
|
|
25
8
|
if (require.main === module) {
|
|
26
9
|
|
|
27
|
-
// By default should include the JS and the CSS.
|
|
28
|
-
// By reference, serving them from their respective paths.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
// This API is not working right now.
|
|
32
|
-
|
|
33
|
-
// A very simple syntax for running a single control would be great.
|
|
34
|
-
|
|
35
|
-
// Need to in the default (server) configuration build and serve the client-side app.
|
|
36
|
-
// Want to be able to make interactive apps quickly with minimal server side code that needs to be written as boilerplate to
|
|
37
|
-
// get the app running.
|
|
38
|
-
|
|
39
|
-
// Though maybe defining a webpage, that serves the client js, and renders the control on the server, and activates it on the client,
|
|
40
|
-
// would be the right approach.
|
|
41
|
-
|
|
42
|
-
// Want to make the code really explicit, in a simple way.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
// eg { '/': Demo_UI }
|
|
46
|
-
// eg { '*': Demo_UI }
|
|
47
|
-
// as at least it explicitly assigns it to the '/' route
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
// But worth keeping the '/' Ctrl property?
|
|
51
|
-
// Could change it to explicitly setting the route(s).
|
|
52
|
-
|
|
53
|
-
// Do want it to build the client js on start.
|
|
54
|
-
|
|
55
|
-
// Could extract the CSS from the file itself, or maybe better reading it from the classes and objects that are loaded / referenced.
|
|
56
|
-
// All kinds of complex server program structures exist already, so could use Publishers if needed for some things.
|
|
57
|
-
// But need to keep the surface-level API really simple.
|
|
58
|
-
|
|
59
|
-
// Maybe define a Webpage and maybe use / define an HTML_Webpage_Publisher for example too.
|
|
60
|
-
// The clearest code would be really explicit about what it does, but in terms of almost English idioms
|
|
61
|
-
// and on the surface-level not spelling out in great detail what it's doing, but referencing objects and
|
|
62
|
-
// instructions with clear purposes, though details could be obscure at the top level. Eg it's the publisher's responsibility
|
|
63
|
-
// 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.
|
|
64
|
-
|
|
65
|
-
// The Server could automatically involk the use of a Publisher.
|
|
66
|
-
// May be better to either require or recommend more explicit code, have them in the examples,
|
|
67
|
-
// but also to document some shortcuts, defaults, and abbreviations (though they may omit some essential info, so not recommended for beginners)
|
|
68
|
-
|
|
69
|
-
// Could have a tabbed view for examples for 'explicit' and 'short' notations when there are multiple.
|
|
70
|
-
|
|
71
|
-
// jsgui3-html-suite may be of use, for some more extended controls that are built on top of jsgui3-html, but not specifically
|
|
72
|
-
// client or server.
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
10
|
const server = new Server({
|
|
80
11
|
Ctrl: Demo_UI,
|
|
81
12
|
// Giving it the Ctrl and disk path client js should enable to server to get the JS-bundled CSS from the file(s).
|
|
@@ -2,7 +2,7 @@ const jsgui = require('jsgui3-client');
|
|
|
2
2
|
const { controls, Control, mixins } = jsgui;
|
|
3
3
|
const { dragable } = mixins;
|
|
4
4
|
const { Checkbox } = controls;
|
|
5
|
-
const Active_HTML_Document = require('
|
|
5
|
+
const Active_HTML_Document = require('../../../../controls/Active_HTML_Document');
|
|
6
6
|
class Demo_UI extends Active_HTML_Document {
|
|
7
7
|
constructor(spec = {}) {
|
|
8
8
|
spec.__type_name = spec.__type_name || 'demo_ui';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const jsgui = require('jsgui3-client');
|
|
2
|
+
const { controls, Control, mixins } = jsgui;
|
|
3
|
+
const { dragable } = mixins;
|
|
4
|
+
const { Checkbox } = controls;
|
|
5
|
+
const Active_HTML_Document = require('../../../../controls/Active_HTML_Document');
|
|
6
|
+
class Demo_UI extends Active_HTML_Document {
|
|
7
|
+
constructor(spec = {}) {
|
|
8
|
+
spec.__type_name = spec.__type_name || 'demo_ui';
|
|
9
|
+
super(spec); const { context } = this;
|
|
10
|
+
if (typeof this.body.add_class === 'function') { this.body.add_class('demo-ui'); }
|
|
11
|
+
const compose = () => {
|
|
12
|
+
// Compose window with a checkbox control
|
|
13
|
+
const window = new controls.Window({ context, title: 'jsgui3-html Checkbox Control', pos: [10,10] });
|
|
14
|
+
const checkbox = new Checkbox({ context, label: { text: 'A checkbox' } });
|
|
15
|
+
const st_ind = new controls.Status_Indicator({ context });
|
|
16
|
+
st_ind.data.model = (checkbox.data.model);
|
|
17
|
+
// Special handling code for setting a data model?
|
|
18
|
+
window.inner.add(checkbox); window.inner.add(st_ind); this.body.add(window);
|
|
19
|
+
};
|
|
20
|
+
if (!spec.el) { compose(); }
|
|
21
|
+
}
|
|
22
|
+
activate() {
|
|
23
|
+
if (!this.__active) {
|
|
24
|
+
super.activate(); const { context } = this;
|
|
25
|
+
// Handle window resize events
|
|
26
|
+
context.on('window-resize', e_resize => { });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
Demo_UI.css = `
|
|
31
|
+
* { margin: 0; padding: 0; }
|
|
32
|
+
body { overflow-x: hidden; overflow-y: hidden; background-color: #E0E0E0; }
|
|
33
|
+
.demo-ui { /* display: flex; flex-wrap: wrap; flex-direction: column; justify-content: center; align-items: center; text-align: center; min-height: 100vh; */ }
|
|
34
|
+
`;
|
|
35
|
+
controls.Demo_UI = Demo_UI; module.exports = jsgui;
|
|
36
|
+
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const jsgui = require('./client');
|
|
2
|
+
|
|
3
|
+
const {Demo_UI} = jsgui.controls;
|
|
4
|
+
const Server = require('../../../../server');
|
|
5
|
+
|
|
6
|
+
if (require.main === module) {
|
|
7
|
+
|
|
8
|
+
const server = new Server({
|
|
9
|
+
Ctrl: Demo_UI,
|
|
10
|
+
//debug: true,
|
|
11
|
+
// Giving it the Ctrl and disk path client js should enable to server to get the JS-bundled CSS from the file(s).
|
|
12
|
+
// Putting the JS files through proper parsing and into a syntax tree would be best.
|
|
13
|
+
|
|
14
|
+
//'js_mode': 'debug',
|
|
15
|
+
'src_path_client_js': require.resolve('./client.js'),
|
|
16
|
+
//debug: true // should not minify the js, should include the symbols.
|
|
17
|
+
//js_client: require.resolve('./square_box.js')
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
console.log('waiting for server ready event');
|
|
21
|
+
server.on('ready', () => {
|
|
22
|
+
console.log('server ready');
|
|
23
|
+
|
|
24
|
+
// server start will change to observable?
|
|
25
|
+
|
|
26
|
+
server.start(52000, function (err, cb_start) {
|
|
27
|
+
if (err) {
|
|
28
|
+
throw err;
|
|
29
|
+
} else {
|
|
30
|
+
// Should have build it by now...
|
|
31
|
+
|
|
32
|
+
console.log('server started');
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
})
|
|
36
|
+
}
|
|
@@ -49,8 +49,8 @@ class Demo_UI extends Active_HTML_Document {
|
|
|
49
49
|
field(dm, 'value');
|
|
50
50
|
date_picker_1.data.model = dm;
|
|
51
51
|
date_picker_2.data.model = dm;
|
|
52
|
-
date_picker_1.assign_data_model_value_change_handler();
|
|
53
|
-
date_picker_2.assign_data_model_value_change_handler();
|
|
52
|
+
//date_picker_1.assign_data_model_value_change_handler();
|
|
53
|
+
//date_picker_2.assign_data_model_value_change_handler();
|
|
54
54
|
}
|
|
55
55
|
context.on('window-resize', e_resize => { });
|
|
56
56
|
}
|
package/package.json
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"esbuild": "^0.25.5",
|
|
11
11
|
"fnl": "^0.0.36",
|
|
12
12
|
"fnlfs": "^0.0.33",
|
|
13
|
-
"jsgui3-client": "^0.0.
|
|
14
|
-
"jsgui3-html": "^0.0.
|
|
13
|
+
"jsgui3-client": "^0.0.117",
|
|
14
|
+
"jsgui3-html": "^0.0.163",
|
|
15
15
|
"jsgui3-webpage": "^0.0.8",
|
|
16
16
|
"jsgui3-website": "^0.0.8",
|
|
17
17
|
"lang-tools": "^0.0.36",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"type": "git",
|
|
39
39
|
"url": "https://github.com/metabench/jsgui3-server.git"
|
|
40
40
|
},
|
|
41
|
-
"version": "0.0.
|
|
41
|
+
"version": "0.0.128"
|
|
42
42
|
}
|