@yuneta/gobj-ui 7.26.31 → 7.26.32

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.
@@ -199,8 +199,8 @@ function yui_wire_selection(tabulator, on_change)
199
199
  ***************************************************************/
200
200
  function yui_selection_bar(t, opts)
201
201
  {
202
- let o = opts || {};
203
- let actions = Array.isArray(o.actions) ? o.actions : [];
202
+ const o = opts || {};
203
+ const actions = Array.isArray(o.actions) ? o.actions : [];
204
204
  let name = o.name || "TABLE";
205
205
  let count = 0;
206
206
 
@@ -218,7 +218,6 @@ function yui_selection_bar(t, opts)
218
218
  click: action.on_click
219
219
  }]
220
220
  );
221
- $b._yui_label = action.label || "";
222
221
  $buttons.push($b);
223
222
  }
224
223
 
@@ -254,19 +253,27 @@ function yui_selection_bar(t, opts)
254
253
  return $b.querySelector("span.icon ~ span");
255
254
  }
256
255
 
256
+ /* A button's label and its name, in the current language */
257
+ function paint_label($b, key)
258
+ {
259
+ let $label = label_of($b);
260
+ if($label && key) {
261
+ $label.textContent = t(key);
262
+ }
263
+ $b.title = key ? t(key) : "";
264
+ $b.setAttribute("aria-label", $b.title);
265
+ }
266
+
257
267
  function refresh()
258
268
  {
259
269
  $count.textContent = t("{{n}} selected", {n: count});
260
- for(let $b of $buttons.concat([$clear])) {
261
- let $label = label_of($b);
262
- /* A literal, where validate-locales reads it; an action's key is the HOST's */
263
- const key = ($b === $clear)? "clear selection" : $b._yui_label;
264
- if($label && key) {
265
- $label.textContent = t(key);
266
- }
267
- $b.title = key ? t(key) : "";
268
- $b.setAttribute("aria-label", $b.title);
269
- }
270
+ /* An action's label is the HOST's key, read where the host calls
271
+ * yui_selection_bar() (I18N_KEY_FUNCTIONS); the clear button's, a
272
+ * literal read here */
273
+ actions.forEach((action, i) => {
274
+ paint_label($buttons[i], action.label || "");
275
+ });
276
+ paint_label($clear, "clear selection");
270
277
  /* Bulma's `is-hidden` carries `!important`: the class is what
271
278
  * toggles, an inline display would lose to it. */
272
279
  $el.classList.toggle("is-hidden", count <= 0);