@iebh/tera-fy 1.13.0 → 1.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/api.md +10 -5
- package/lib/terafy.client.js +11 -5
- package/lib/terafy.server.js +54 -18
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.13.2](https://github.com/IEBH/TERA-fy/compare/v1.13.1...v1.13.2) (2024-07-11)
|
|
4
|
+
|
|
5
|
+
## [1.13.1](https://github.com/IEBH/TERA-fy/compare/v1.13.0...v1.13.1) (2024-07-10)
|
|
6
|
+
|
|
3
7
|
# [1.13.0](https://github.com/IEBH/TERA-fy/compare/v1.12.0...v1.13.0) (2024-07-09)
|
|
4
8
|
|
|
5
9
|
|
package/api.md
CHANGED
|
@@ -997,11 +997,13 @@ Display simple text within TERA
|
|
|
997
997
|
|
|
998
998
|
### Parameters
|
|
999
999
|
|
|
1000
|
-
* `text` **[String][150]
|
|
1000
|
+
* `text` **[String][150]?** Text to display, if specified this populates `options.body`
|
|
1001
1001
|
* `options` **[Object][151]?** Additional options to mutate behaviour
|
|
1002
1002
|
|
|
1003
|
-
* `options.
|
|
1003
|
+
* `options.body` **[String][150]** The body text to display (optional, default `"Alert!"`)
|
|
1004
1004
|
* `options.isHtml` **[Boolean][159]** If falsy the text is rendered as plain-text otherwise it will be assumed as HTML content (optional, default `false`)
|
|
1005
|
+
* `options.title` **[String][150]** The title of the alert box (optional, default `'TERA'`)
|
|
1006
|
+
* `options.buttons` **(`"ok"` | `false`)** Button set to use or falsy to disable (optional, default `'ok'`)
|
|
1005
1007
|
|
|
1006
1008
|
Returns **[Promise][157]** A promise which resolves when the alert has been dismissed
|
|
1007
1009
|
|
|
@@ -1011,11 +1013,12 @@ Present a simple ok/cancel dialog to the user
|
|
|
1011
1013
|
|
|
1012
1014
|
### Parameters
|
|
1013
1015
|
|
|
1014
|
-
* `text` **[String][150]
|
|
1016
|
+
* `text` **[String][150]?** Text to display, if specified this populates `options.body`
|
|
1015
1017
|
* `options` **[Object][151]?** Additional options to mutate behaviour
|
|
1016
1018
|
|
|
1017
|
-
* `options.
|
|
1019
|
+
* `options.body` **[String][150]** The body text to display (optional, default `"Confirm?"`)
|
|
1018
1020
|
* `options.isHtml` **[Boolean][159]** If falsy the text is rendered as plain-text otherwise it will be assumed as HTML content (optional, default `false`)
|
|
1021
|
+
* `options.title` **[String][150]** The title of the confirmation box (optional, default `'TERA'`)
|
|
1019
1022
|
|
|
1020
1023
|
Returns **[Promise][157]** A promise which resolves with `Promise.resolve('OK')` or rejects with `Promise.reject('CANCEL')`
|
|
1021
1024
|
|
|
@@ -1044,13 +1047,15 @@ Prompt the user for an input, responding with a Promisable value
|
|
|
1044
1047
|
|
|
1045
1048
|
### Parameters
|
|
1046
1049
|
|
|
1050
|
+
* `text` **[String][150]?** Text to display, if specified this populates `options.body`
|
|
1047
1051
|
* `options` **[Object][151]?** Additional options to mutate behaviour
|
|
1048
1052
|
|
|
1053
|
+
* `options.body` **[String][150]?** Optional additional body text
|
|
1049
1054
|
* `options.value` **[String][150]?** Current or default value to display pre-filled
|
|
1050
1055
|
* `options.title` **[String][150]** The dialog title to display (optional, default `'Input required'`)
|
|
1051
|
-
* `options.body` **[String][150]?** Optional additional body text
|
|
1052
1056
|
* `options.bodyHtml` **[Boolean][159]** If truthy, treat the body as HTML (optional, default `false`)
|
|
1053
1057
|
* `options.placeholder` **[String][150]?** Optional placeholder text
|
|
1058
|
+
* `options.required` **[Boolean][159]** Treat nullish or empty inputs as a cancel operation (optional, default `true`)
|
|
1054
1059
|
|
|
1055
1060
|
Returns **[Promise][157]\<any>** Either the eventual user value or a throw with `Promise.reject('CANCEL')`
|
|
1056
1061
|
|
package/lib/terafy.client.js
CHANGED
|
@@ -1297,11 +1297,13 @@ export default class TeraFy {
|
|
|
1297
1297
|
* Display simple text within TERA
|
|
1298
1298
|
*
|
|
1299
1299
|
* @function uiAlert
|
|
1300
|
-
* @param {String} text
|
|
1300
|
+
* @param {String} [text] Text to display, if specified this populates `options.body`
|
|
1301
1301
|
*
|
|
1302
1302
|
* @param {Object} [options] Additional options to mutate behaviour
|
|
1303
|
-
* @param {String} [options.
|
|
1303
|
+
* @param {String} [options.body="Alert!"] The body text to display
|
|
1304
1304
|
* @param {Boolean} [options.isHtml=false] If falsy the text is rendered as plain-text otherwise it will be assumed as HTML content
|
|
1305
|
+
* @param {String} [options.title='TERA'] The title of the alert box
|
|
1306
|
+
* @param {'ok'|false} [options.buttons='ok'] Button set to use or falsy to disable
|
|
1305
1307
|
*
|
|
1306
1308
|
* @returns {Promise} A promise which resolves when the alert has been dismissed
|
|
1307
1309
|
*/
|
|
@@ -1311,11 +1313,12 @@ export default class TeraFy {
|
|
|
1311
1313
|
* Present a simple ok/cancel dialog to the user
|
|
1312
1314
|
*
|
|
1313
1315
|
* @function uiConfirm
|
|
1314
|
-
* @param {String} text
|
|
1316
|
+
* @param {String} [text] Text to display, if specified this populates `options.body`
|
|
1315
1317
|
*
|
|
1316
1318
|
* @param {Object} [options] Additional options to mutate behaviour
|
|
1317
|
-
* @param {String} [options.
|
|
1319
|
+
* @param {String} [options.body="Confirm?"] The body text to display
|
|
1318
1320
|
* @param {Boolean} [options.isHtml=false] If falsy the text is rendered as plain-text otherwise it will be assumed as HTML content
|
|
1321
|
+
* @param {String} [options.title='TERA'] The title of the confirmation box
|
|
1319
1322
|
*
|
|
1320
1323
|
* @returns {Promise} A promise which resolves with `Promise.resolve('OK')` or rejects with `Promise.reject('CANCEL')`
|
|
1321
1324
|
*/
|
|
@@ -1343,12 +1346,15 @@ export default class TeraFy {
|
|
|
1343
1346
|
* Prompt the user for an input, responding with a Promisable value
|
|
1344
1347
|
*
|
|
1345
1348
|
* @function uiPrompt
|
|
1349
|
+
* @param {String} [text] Text to display, if specified this populates `options.body`
|
|
1350
|
+
*
|
|
1346
1351
|
* @param {Object} [options] Additional options to mutate behaviour
|
|
1352
|
+
* @param {String} [options.body] Optional additional body text
|
|
1347
1353
|
* @param {String} [options.value] Current or default value to display pre-filled
|
|
1348
1354
|
* @param {String} [options.title='Input required'] The dialog title to display
|
|
1349
|
-
* @param {String} [options.body] Optional additional body text
|
|
1350
1355
|
* @param {Boolean} [options.bodyHtml=false] If truthy, treat the body as HTML
|
|
1351
1356
|
* @param {String} [options.placeholder] Optional placeholder text
|
|
1357
|
+
* @param {Boolean} [options.required=true] Treat nullish or empty inputs as a cancel operation
|
|
1352
1358
|
*
|
|
1353
1359
|
* @returns {Promise<*>} Either the eventual user value or a throw with `Promise.reject('CANCEL')`
|
|
1354
1360
|
*/
|
package/lib/terafy.server.js
CHANGED
|
@@ -108,7 +108,14 @@ export default class TeraFyServer {
|
|
|
108
108
|
case TeraFyServer.SERVERMODE_FRAME: {
|
|
109
109
|
// Server is the top-level window so we need to send messages to an embedded iFrame
|
|
110
110
|
let iFrame = document.querySelector('iframe#external');
|
|
111
|
-
if (!iFrame)
|
|
111
|
+
if (!iFrame) {
|
|
112
|
+
this.debug('INFO', 2, 'Cannot locate TERA-FY top-level->iFrame#external - maybe there is none');
|
|
113
|
+
return mixin(this, {
|
|
114
|
+
sendRaw(message) {
|
|
115
|
+
this.debug('INFO', 2, 'Sending broadcast to zero listening clients');
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
}
|
|
112
119
|
|
|
113
120
|
return mixin(this, {
|
|
114
121
|
sendRaw(message) {
|
|
@@ -1431,27 +1438,33 @@ export default class TeraFyServer {
|
|
|
1431
1438
|
/**
|
|
1432
1439
|
* Display simple text within TERA
|
|
1433
1440
|
*
|
|
1434
|
-
* @param {String} text
|
|
1441
|
+
* @param {String} [text] Text to display, if specified this populates `options.body`
|
|
1435
1442
|
*
|
|
1436
1443
|
* @param {Object} [options] Additional options to mutate behaviour
|
|
1437
|
-
* @param {String} [options.
|
|
1444
|
+
* @param {String} [options.body="Alert!"] The body text to display
|
|
1438
1445
|
* @param {Boolean} [options.isHtml=false] If falsy the text is rendered as plain-text otherwise it will be assumed as HTML content
|
|
1446
|
+
* @param {String} [options.title='TERA'] The title of the alert box
|
|
1439
1447
|
* @param {'ok'|false} [options.buttons='ok'] Button set to use or falsy to disable
|
|
1440
1448
|
*
|
|
1441
1449
|
* @returns {Promise} A promise which resolves when the alert has been dismissed
|
|
1442
1450
|
*/
|
|
1443
1451
|
uiAlert(text, options) {
|
|
1444
1452
|
let settings = {
|
|
1445
|
-
|
|
1453
|
+
body: 'Alert!',
|
|
1446
1454
|
isHtml: false,
|
|
1455
|
+
title: 'TERA',
|
|
1447
1456
|
buttons: 'ok',
|
|
1448
|
-
...
|
|
1457
|
+
...(
|
|
1458
|
+
typeof text == 'string' ? {body: text, ...options}
|
|
1459
|
+
: typeof text == 'object' ? text
|
|
1460
|
+
: options
|
|
1461
|
+
),
|
|
1449
1462
|
};
|
|
1450
1463
|
|
|
1451
1464
|
return this.requestFocus(()=>
|
|
1452
1465
|
app.service('$prompt').dialog({
|
|
1453
1466
|
title: settings.title,
|
|
1454
|
-
body:
|
|
1467
|
+
body: settings.body,
|
|
1455
1468
|
buttons:
|
|
1456
1469
|
settings.buttons == 'ok' ? ['ok']
|
|
1457
1470
|
: false,
|
|
@@ -1465,19 +1478,25 @@ export default class TeraFyServer {
|
|
|
1465
1478
|
/**
|
|
1466
1479
|
* Present a simple ok/cancel dialog to the user
|
|
1467
1480
|
*
|
|
1468
|
-
* @param {String} text
|
|
1481
|
+
* @param {String} [text] Text to display, if specified this populates `options.body`
|
|
1469
1482
|
*
|
|
1470
1483
|
* @param {Object} [options] Additional options to mutate behaviour
|
|
1471
|
-
* @param {String} [options.
|
|
1484
|
+
* @param {String} [options.body="Confirm?"] The body text to display
|
|
1472
1485
|
* @param {Boolean} [options.isHtml=false] If falsy the text is rendered as plain-text otherwise it will be assumed as HTML content
|
|
1486
|
+
* @param {String} [options.title='TERA'] The title of the confirmation box
|
|
1473
1487
|
*
|
|
1474
1488
|
* @returns {Promise} A promise which resolves with `Promise.resolve('OK')` or rejects with `Promise.reject('CANCEL')`
|
|
1475
1489
|
*/
|
|
1476
1490
|
uiConfirm(text, options) {
|
|
1477
1491
|
let settings = {
|
|
1478
|
-
|
|
1492
|
+
body: 'Confirm?',
|
|
1479
1493
|
isHtml: false,
|
|
1480
|
-
|
|
1494
|
+
title: 'TERA',
|
|
1495
|
+
...(
|
|
1496
|
+
typeof text == 'string' ? {body: text, ...options}
|
|
1497
|
+
: typeof text == 'object' ? text
|
|
1498
|
+
: options
|
|
1499
|
+
),
|
|
1481
1500
|
};
|
|
1482
1501
|
|
|
1483
1502
|
return this.requestFocus(()=>
|
|
@@ -1509,9 +1528,9 @@ export default class TeraFyServer {
|
|
|
1509
1528
|
* All options are cumulative - i.e. they are merged with other options previously provided
|
|
1510
1529
|
*
|
|
1511
1530
|
* @param {Object|Boolean} [options] Additional options to mutate behaviour, if boolean false `{close: true}` is assumed
|
|
1512
|
-
* @param {String} [options.title='TERA'] Window title, can only be set on the initial call
|
|
1513
1531
|
* @param {String} [options.body=''] Window body text
|
|
1514
1532
|
* @param {Boolean} [options.bodyHtml=false] If truthy, treat the body as HTML
|
|
1533
|
+
* @param {String} [options.title='TERA'] Window title, can only be set on the initial call
|
|
1515
1534
|
* @param {Boolean} [options.close=false] Close the existing dialog, if true the dialog is disposed and options reset
|
|
1516
1535
|
* @param {Number} [options.progress] The current progress of the task being conducted, this is assumed to be a value less than `progressMax`
|
|
1517
1536
|
* @param {Number} [options.progressMax] The maximum value that the progress can be
|
|
@@ -1523,9 +1542,9 @@ export default class TeraFyServer {
|
|
|
1523
1542
|
|
|
1524
1543
|
if (this.uiProgressOptions === null) { // New uiProgress window
|
|
1525
1544
|
this.uiProgressOptions = reactive({
|
|
1526
|
-
title: 'TERA',
|
|
1527
1545
|
body: '',
|
|
1528
1546
|
bodyHtml: false,
|
|
1547
|
+
title: 'TERA',
|
|
1529
1548
|
close: false,
|
|
1530
1549
|
progress: 0,
|
|
1531
1550
|
progressMax: 0,
|
|
@@ -1562,23 +1581,31 @@ export default class TeraFyServer {
|
|
|
1562
1581
|
/**
|
|
1563
1582
|
* Prompt the user for an input, responding with a Promisable value
|
|
1564
1583
|
*
|
|
1584
|
+
* @param {String} [text] Text to display, if specified this populates `options.body`
|
|
1585
|
+
*
|
|
1565
1586
|
* @param {Object} [options] Additional options to mutate behaviour
|
|
1587
|
+
* @param {String} [options.body] Optional additional body text
|
|
1566
1588
|
* @param {String} [options.value] Current or default value to display pre-filled
|
|
1567
1589
|
* @param {String} [options.title='Input required'] The dialog title to display
|
|
1568
|
-
* @param {String} [options.body] Optional additional body text
|
|
1569
1590
|
* @param {Boolean} [options.bodyHtml=false] If truthy, treat the body as HTML
|
|
1570
1591
|
* @param {String} [options.placeholder] Optional placeholder text
|
|
1592
|
+
* @param {Boolean} [options.required=true] Treat nullish or empty inputs as a cancel operation
|
|
1571
1593
|
*
|
|
1572
1594
|
* @returns {Promise<*>} Either the eventual user value or a throw with `Promise.reject('CANCEL')`
|
|
1573
1595
|
*/
|
|
1574
|
-
uiPrompt(options) {
|
|
1596
|
+
uiPrompt(text, options) {
|
|
1575
1597
|
let settings = {
|
|
1576
|
-
title: 'Input required',
|
|
1577
|
-
value: '',
|
|
1578
1598
|
body: '',
|
|
1579
1599
|
bodyHtml: false,
|
|
1600
|
+
title: 'Input required',
|
|
1601
|
+
value: '',
|
|
1580
1602
|
placeholder: '',
|
|
1581
|
-
|
|
1603
|
+
required: true,
|
|
1604
|
+
...(
|
|
1605
|
+
typeof text == 'string' ? {body: text, ...options}
|
|
1606
|
+
: typeof text == 'object' ? text
|
|
1607
|
+
: options
|
|
1608
|
+
),
|
|
1582
1609
|
};
|
|
1583
1610
|
|
|
1584
1611
|
return this.requestFocus(()=>
|
|
@@ -1595,7 +1622,16 @@ export default class TeraFyServer {
|
|
|
1595
1622
|
buttons: ['ok', 'cancel'],
|
|
1596
1623
|
})
|
|
1597
1624
|
)
|
|
1598
|
-
.then(answer =>
|
|
1625
|
+
.then(answer => {
|
|
1626
|
+
if (answer) {
|
|
1627
|
+
return answer;
|
|
1628
|
+
} else if (settings.required) {
|
|
1629
|
+
return Promise.reject('CANCEL');
|
|
1630
|
+
} else {
|
|
1631
|
+
return answer;
|
|
1632
|
+
}
|
|
1633
|
+
})
|
|
1634
|
+
.catch(()=> Promise.reject('CANCEL'))
|
|
1599
1635
|
}
|
|
1600
1636
|
|
|
1601
1637
|
|
package/package.json
CHANGED