@yuneta/gobj-ui 7.23.115 → 7.23.116
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 +25 -0
- package/dist/gobj-ui.es.js +25 -0
- package/package.json +1 -1
- package/src/c_yui_form.js +33 -0
package/dist/gobj-ui.cjs.js
CHANGED
|
@@ -7219,6 +7219,30 @@ function destroy_ui$10(gobj) {
|
|
|
7219
7219
|
/******************************************************************
|
|
7220
7220
|
* Build form with bulma and createElement2
|
|
7221
7221
|
******************************************************************/
|
|
7222
|
+
/************************************************************
|
|
7223
|
+
* Put the field's NAME on its control.
|
|
7224
|
+
*
|
|
7225
|
+
* The label of a field is written `<label for={name}>` -- and
|
|
7226
|
+
* `for` matches an **id**, which no control here sets: they
|
|
7227
|
+
* carry `name`. So the association reads right in the source
|
|
7228
|
+
* and does not exist in the document, and every field of every
|
|
7229
|
+
* form of this library was unlabelled for anything that is not
|
|
7230
|
+
* an eye.
|
|
7231
|
+
*
|
|
7232
|
+
* `aria-label` and not an `id`: two forms can be open at once
|
|
7233
|
+
* (a record in a window and another in a modal), and duplicate
|
|
7234
|
+
* ids would break the association for both. The key is the
|
|
7235
|
+
* label's own, so a language change reaches it.
|
|
7236
|
+
************************************************************/
|
|
7237
|
+
function name_form_control($field, conf) {
|
|
7238
|
+
if (!$field || typeof $field.querySelector !== "function" || !conf) return;
|
|
7239
|
+
let key = conf.label_i18n || conf.label || "";
|
|
7240
|
+
if (!key) return;
|
|
7241
|
+
let $control = $field.querySelector("input, select, textarea");
|
|
7242
|
+
if (!$control || $control.getAttribute("aria-label")) return;
|
|
7243
|
+
$control.setAttribute("aria-label", (0, i18next.t)(key));
|
|
7244
|
+
$control.setAttribute("data-i18n-aria-label", key);
|
|
7245
|
+
}
|
|
7222
7246
|
function build_form(gobj) {
|
|
7223
7247
|
let form_id = (0, _yuneta_gobj_js.gobj_read_str_attr)(gobj, "form_id");
|
|
7224
7248
|
let $form = (0, _yuneta_gobj_js.createElement2)(["form", {
|
|
@@ -7255,6 +7279,7 @@ function build_html_form(gobj, $form, prefix, template) {
|
|
|
7255
7279
|
if (placeholders[key]) html_field_conf.placeholder = placeholders[key];
|
|
7256
7280
|
if (html_field_conf.tag) {
|
|
7257
7281
|
let $field = create_form_field(gobj, $form, prefix, field_desc, html_field_conf);
|
|
7282
|
+
name_form_control($field, html_field_conf);
|
|
7258
7283
|
$form.appendChild($field);
|
|
7259
7284
|
}
|
|
7260
7285
|
});
|
package/dist/gobj-ui.es.js
CHANGED
|
@@ -7214,6 +7214,30 @@ function destroy_ui$10(gobj) {
|
|
|
7214
7214
|
/******************************************************************
|
|
7215
7215
|
* Build form with bulma and createElement2
|
|
7216
7216
|
******************************************************************/
|
|
7217
|
+
/************************************************************
|
|
7218
|
+
* Put the field's NAME on its control.
|
|
7219
|
+
*
|
|
7220
|
+
* The label of a field is written `<label for={name}>` -- and
|
|
7221
|
+
* `for` matches an **id**, which no control here sets: they
|
|
7222
|
+
* carry `name`. So the association reads right in the source
|
|
7223
|
+
* and does not exist in the document, and every field of every
|
|
7224
|
+
* form of this library was unlabelled for anything that is not
|
|
7225
|
+
* an eye.
|
|
7226
|
+
*
|
|
7227
|
+
* `aria-label` and not an `id`: two forms can be open at once
|
|
7228
|
+
* (a record in a window and another in a modal), and duplicate
|
|
7229
|
+
* ids would break the association for both. The key is the
|
|
7230
|
+
* label's own, so a language change reaches it.
|
|
7231
|
+
************************************************************/
|
|
7232
|
+
function name_form_control($field, conf) {
|
|
7233
|
+
if (!$field || typeof $field.querySelector !== "function" || !conf) return;
|
|
7234
|
+
let key = conf.label_i18n || conf.label || "";
|
|
7235
|
+
if (!key) return;
|
|
7236
|
+
let $control = $field.querySelector("input, select, textarea");
|
|
7237
|
+
if (!$control || $control.getAttribute("aria-label")) return;
|
|
7238
|
+
$control.setAttribute("aria-label", t(key));
|
|
7239
|
+
$control.setAttribute("data-i18n-aria-label", key);
|
|
7240
|
+
}
|
|
7217
7241
|
function build_form(gobj) {
|
|
7218
7242
|
let form_id = gobj_read_str_attr(gobj, "form_id");
|
|
7219
7243
|
let $form = createElement2(["form", {
|
|
@@ -7250,6 +7274,7 @@ function build_html_form(gobj, $form, prefix, template) {
|
|
|
7250
7274
|
if (placeholders[key]) html_field_conf.placeholder = placeholders[key];
|
|
7251
7275
|
if (html_field_conf.tag) {
|
|
7252
7276
|
let $field = create_form_field(gobj, $form, prefix, field_desc, html_field_conf);
|
|
7277
|
+
name_form_control($field, html_field_conf);
|
|
7253
7278
|
$form.appendChild($field);
|
|
7254
7279
|
}
|
|
7255
7280
|
});
|
package/package.json
CHANGED
package/src/c_yui_form.js
CHANGED
|
@@ -490,6 +490,38 @@ function destroy_ui(gobj)
|
|
|
490
490
|
/******************************************************************
|
|
491
491
|
* Build form with bulma and createElement2
|
|
492
492
|
******************************************************************/
|
|
493
|
+
/************************************************************
|
|
494
|
+
* Put the field's NAME on its control.
|
|
495
|
+
*
|
|
496
|
+
* The label of a field is written `<label for={name}>` -- and
|
|
497
|
+
* `for` matches an **id**, which no control here sets: they
|
|
498
|
+
* carry `name`. So the association reads right in the source
|
|
499
|
+
* and does not exist in the document, and every field of every
|
|
500
|
+
* form of this library was unlabelled for anything that is not
|
|
501
|
+
* an eye.
|
|
502
|
+
*
|
|
503
|
+
* `aria-label` and not an `id`: two forms can be open at once
|
|
504
|
+
* (a record in a window and another in a modal), and duplicate
|
|
505
|
+
* ids would break the association for both. The key is the
|
|
506
|
+
* label's own, so a language change reaches it.
|
|
507
|
+
************************************************************/
|
|
508
|
+
function name_form_control($field, conf)
|
|
509
|
+
{
|
|
510
|
+
if(!$field || typeof $field.querySelector !== "function" || !conf) {
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
let key = conf.label_i18n || conf.label || "";
|
|
514
|
+
if(!key) {
|
|
515
|
+
return; /* a field with no label names nothing */
|
|
516
|
+
}
|
|
517
|
+
let $control = $field.querySelector("input, select, textarea");
|
|
518
|
+
if(!$control || $control.getAttribute("aria-label")) {
|
|
519
|
+
return;
|
|
520
|
+
}
|
|
521
|
+
$control.setAttribute("aria-label", t(key));
|
|
522
|
+
$control.setAttribute("data-i18n-aria-label", key);
|
|
523
|
+
}
|
|
524
|
+
|
|
493
525
|
function build_form(gobj)
|
|
494
526
|
{
|
|
495
527
|
let form_id = gobj_read_str_attr(gobj, "form_id");
|
|
@@ -566,6 +598,7 @@ function build_html_form(gobj, $form, prefix, template)
|
|
|
566
598
|
*/
|
|
567
599
|
if(html_field_conf.tag) {
|
|
568
600
|
let $field = create_form_field(gobj, $form, prefix, field_desc, html_field_conf);
|
|
601
|
+
name_form_control($field, html_field_conf);
|
|
569
602
|
$form.appendChild($field);
|
|
570
603
|
}
|
|
571
604
|
});
|