@yuneta/gobj-ui 7.23.54 → 7.23.56
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/dist/gobj-ui.cjs.js +36 -0
- package/dist/gobj-ui.es.js +36 -0
- package/package.json +1 -1
- package/src/c_yui_form.css +22 -0
- package/src/c_yui_form.js +61 -0
package/dist/gobj-ui.cjs.js
CHANGED
|
@@ -7515,10 +7515,46 @@ function create_form_field(gobj, $form, prefix, field_desc, { tag, inputType, na
|
|
|
7515
7515
|
$extend.dataset.form_tag = tag;
|
|
7516
7516
|
$extend.dataset.form_input_type = inputType;
|
|
7517
7517
|
$extend.classList.add("yui-form-data-input");
|
|
7518
|
+
apply_readonly_to_control(readonly, tag, inputType, $extend);
|
|
7518
7519
|
}
|
|
7519
7520
|
return $element;
|
|
7520
7521
|
}
|
|
7521
7522
|
/******************************************************************
|
|
7523
|
+
* `readonly` is an attribute of a TEXT control and of nothing else.
|
|
7524
|
+
*
|
|
7525
|
+
* A `<select>` ignores it. So does a checkbox, and so does a radio:
|
|
7526
|
+
* the browser accepts the attribute, stores it, and lets the reader
|
|
7527
|
+
* change the value anyway. Only `disabled` stops them, and tom-select
|
|
7528
|
+
* is a widget of its own that has to be told through its API.
|
|
7529
|
+
*
|
|
7530
|
+
* Which is why a col that is not `writable` used to render an
|
|
7531
|
+
* EDITABLE select: the field was built read-only, correctly, and the
|
|
7532
|
+
* three controls that cannot be read-only said nothing about it.
|
|
7533
|
+
*
|
|
7534
|
+
* `disabled` is safe here: the record is collected by reading each
|
|
7535
|
+
* marked control's value, never by submitting the form, so a disabled
|
|
7536
|
+
* control is still read -- unlike in a native submit, where it would
|
|
7537
|
+
* be dropped.
|
|
7538
|
+
******************************************************************/
|
|
7539
|
+
function apply_readonly_to_control(readonly, tag, inputType, $extend) {
|
|
7540
|
+
if (!readonly) return;
|
|
7541
|
+
switch (tag) {
|
|
7542
|
+
case "select":
|
|
7543
|
+
case "checkbox":
|
|
7544
|
+
case "radio":
|
|
7545
|
+
$extend.setAttribute("disabled", "disabled");
|
|
7546
|
+
break;
|
|
7547
|
+
case "select2":
|
|
7548
|
+
$extend.setAttribute("disabled", "disabled");
|
|
7549
|
+
if ($extend.tom_select) $extend.tom_select.disable();
|
|
7550
|
+
break;
|
|
7551
|
+
case "jsoneditor":
|
|
7552
|
+
$extend.classList.add("yui-jse-readonly");
|
|
7553
|
+
break;
|
|
7554
|
+
case "input": if (inputType === "color") $extend.setAttribute("disabled", "disabled");
|
|
7555
|
+
}
|
|
7556
|
+
}
|
|
7557
|
+
/******************************************************************
|
|
7522
7558
|
* Create coordinates
|
|
7523
7559
|
******************************************************************/
|
|
7524
7560
|
function create_coordinates(gobj, attrs) {
|
package/dist/gobj-ui.es.js
CHANGED
|
@@ -7510,10 +7510,46 @@ function create_form_field(gobj, $form, prefix, field_desc, { tag, inputType, na
|
|
|
7510
7510
|
$extend.dataset.form_tag = tag;
|
|
7511
7511
|
$extend.dataset.form_input_type = inputType;
|
|
7512
7512
|
$extend.classList.add("yui-form-data-input");
|
|
7513
|
+
apply_readonly_to_control(readonly, tag, inputType, $extend);
|
|
7513
7514
|
}
|
|
7514
7515
|
return $element;
|
|
7515
7516
|
}
|
|
7516
7517
|
/******************************************************************
|
|
7518
|
+
* `readonly` is an attribute of a TEXT control and of nothing else.
|
|
7519
|
+
*
|
|
7520
|
+
* A `<select>` ignores it. So does a checkbox, and so does a radio:
|
|
7521
|
+
* the browser accepts the attribute, stores it, and lets the reader
|
|
7522
|
+
* change the value anyway. Only `disabled` stops them, and tom-select
|
|
7523
|
+
* is a widget of its own that has to be told through its API.
|
|
7524
|
+
*
|
|
7525
|
+
* Which is why a col that is not `writable` used to render an
|
|
7526
|
+
* EDITABLE select: the field was built read-only, correctly, and the
|
|
7527
|
+
* three controls that cannot be read-only said nothing about it.
|
|
7528
|
+
*
|
|
7529
|
+
* `disabled` is safe here: the record is collected by reading each
|
|
7530
|
+
* marked control's value, never by submitting the form, so a disabled
|
|
7531
|
+
* control is still read -- unlike in a native submit, where it would
|
|
7532
|
+
* be dropped.
|
|
7533
|
+
******************************************************************/
|
|
7534
|
+
function apply_readonly_to_control(readonly, tag, inputType, $extend) {
|
|
7535
|
+
if (!readonly) return;
|
|
7536
|
+
switch (tag) {
|
|
7537
|
+
case "select":
|
|
7538
|
+
case "checkbox":
|
|
7539
|
+
case "radio":
|
|
7540
|
+
$extend.setAttribute("disabled", "disabled");
|
|
7541
|
+
break;
|
|
7542
|
+
case "select2":
|
|
7543
|
+
$extend.setAttribute("disabled", "disabled");
|
|
7544
|
+
if ($extend.tom_select) $extend.tom_select.disable();
|
|
7545
|
+
break;
|
|
7546
|
+
case "jsoneditor":
|
|
7547
|
+
$extend.classList.add("yui-jse-readonly");
|
|
7548
|
+
break;
|
|
7549
|
+
case "input": if (inputType === "color") $extend.setAttribute("disabled", "disabled");
|
|
7550
|
+
}
|
|
7551
|
+
}
|
|
7552
|
+
/******************************************************************
|
|
7517
7553
|
* Create coordinates
|
|
7518
7554
|
******************************************************************/
|
|
7519
7555
|
function create_coordinates(gobj, attrs) {
|
package/package.json
CHANGED
package/src/c_yui_form.css
CHANGED
|
@@ -57,3 +57,25 @@
|
|
|
57
57
|
overscroll-behavior: contain;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
|
|
61
|
+
/* A colour that cannot be changed. `readonly` does not apply to a colour
|
|
62
|
+
* input (the spec lists the types it applies to and colour is not one),
|
|
63
|
+
* so it is `disabled` instead -- and a disabled swatch is drawn by the
|
|
64
|
+
* browser as a pale ghost of itself, which loses the one thing the field
|
|
65
|
+
* is for: seeing the colour. Keep the swatch, lose the affordance. */
|
|
66
|
+
.C_YUI_FORM input[type="color"][disabled] {
|
|
67
|
+
opacity: 1;
|
|
68
|
+
cursor: default;
|
|
69
|
+
border-color: var(--bulma-border, #dbdbdb);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/* A json document that cannot be edited. The editor is read-only for
|
|
73
|
+
* real (`readOnly` at build time); this is what makes it LOOK it --
|
|
74
|
+
* the menu bar is the whole invitation, and it offers nothing that
|
|
75
|
+
* reading needs. */
|
|
76
|
+
.C_YUI_FORM .yui-jse-readonly .jse-menu {
|
|
77
|
+
display: none !important;
|
|
78
|
+
}
|
|
79
|
+
.C_YUI_FORM .yui-jse-readonly {
|
|
80
|
+
background-color: var(--bulma-background, #f5f5f5);
|
|
81
|
+
}
|
package/src/c_yui_form.js
CHANGED
|
@@ -1449,11 +1449,72 @@ function create_form_field(
|
|
|
1449
1449
|
$extend.dataset.form_tag = tag;
|
|
1450
1450
|
$extend.dataset.form_input_type = inputType;
|
|
1451
1451
|
$extend.classList.add('yui-form-data-input');
|
|
1452
|
+
|
|
1453
|
+
apply_readonly_to_control(readonly, tag, inputType, $extend);
|
|
1452
1454
|
}
|
|
1453
1455
|
|
|
1454
1456
|
return $element;
|
|
1455
1457
|
}
|
|
1456
1458
|
|
|
1459
|
+
/******************************************************************
|
|
1460
|
+
* `readonly` is an attribute of a TEXT control and of nothing else.
|
|
1461
|
+
*
|
|
1462
|
+
* A `<select>` ignores it. So does a checkbox, and so does a radio:
|
|
1463
|
+
* the browser accepts the attribute, stores it, and lets the reader
|
|
1464
|
+
* change the value anyway. Only `disabled` stops them, and tom-select
|
|
1465
|
+
* is a widget of its own that has to be told through its API.
|
|
1466
|
+
*
|
|
1467
|
+
* Which is why a col that is not `writable` used to render an
|
|
1468
|
+
* EDITABLE select: the field was built read-only, correctly, and the
|
|
1469
|
+
* three controls that cannot be read-only said nothing about it.
|
|
1470
|
+
*
|
|
1471
|
+
* `disabled` is safe here: the record is collected by reading each
|
|
1472
|
+
* marked control's value, never by submitting the form, so a disabled
|
|
1473
|
+
* control is still read -- unlike in a native submit, where it would
|
|
1474
|
+
* be dropped.
|
|
1475
|
+
******************************************************************/
|
|
1476
|
+
function apply_readonly_to_control(readonly, tag, inputType, $extend)
|
|
1477
|
+
{
|
|
1478
|
+
if(!readonly) {
|
|
1479
|
+
return;
|
|
1480
|
+
}
|
|
1481
|
+
|
|
1482
|
+
switch(tag) {
|
|
1483
|
+
case 'select':
|
|
1484
|
+
case 'checkbox':
|
|
1485
|
+
case 'radio':
|
|
1486
|
+
$extend.setAttribute("disabled", "disabled");
|
|
1487
|
+
break;
|
|
1488
|
+
case 'select2':
|
|
1489
|
+
$extend.setAttribute("disabled", "disabled");
|
|
1490
|
+
if($extend.tom_select) {
|
|
1491
|
+
$extend.tom_select.disable();
|
|
1492
|
+
}
|
|
1493
|
+
break;
|
|
1494
|
+
case 'jsoneditor':
|
|
1495
|
+
/* It IS read-only -- `readOnly` went to the editor when it was
|
|
1496
|
+
* built -- and it did not LOOK it: a json editor with its menu
|
|
1497
|
+
* bar on top invites an edit it will discard. The class mutes
|
|
1498
|
+
* it (c_yui_form.css), which is the same thing a readonly
|
|
1499
|
+
* `input` has done since it existed. */
|
|
1500
|
+
$extend.classList.add('yui-jse-readonly');
|
|
1501
|
+
break;
|
|
1502
|
+
case 'input':
|
|
1503
|
+
/* `readonly` does not apply to a colour input -- the spec lists
|
|
1504
|
+
* the types it applies to and colour is not one of them -- so
|
|
1505
|
+
* the swatch opens its picker and the value changes, and in a
|
|
1506
|
+
* form that only sends writable cols the change is then
|
|
1507
|
+
* silently dropped. Date and time DO honour it, and keep it:
|
|
1508
|
+
* readonly stays selectable and copyable, disabled does not. */
|
|
1509
|
+
if(inputType === 'color') {
|
|
1510
|
+
$extend.setAttribute("disabled", "disabled");
|
|
1511
|
+
}
|
|
1512
|
+
break;
|
|
1513
|
+
default:
|
|
1514
|
+
break;
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1457
1518
|
|
|
1458
1519
|
/******************************************************************
|
|
1459
1520
|
* Create coordinates
|