@qontinui/ui-bridge-native 0.6.1 → 0.6.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.
@@ -351,6 +351,51 @@ var NativeUIBridgeRegistry = class {
351
351
  this.emit("element:stateChanged", { id, state: newState });
352
352
  }
353
353
  }
354
+ /**
355
+ * Update an element's descriptive metadata (label / accessibilityLabel /
356
+ * testId). Sister to {@link updateElementState} (which carries layout +
357
+ * visibility) and {@link updateElementProps} (which carries event handlers).
358
+ *
359
+ * Idempotent — if every passed field equals the existing value, the call
360
+ * returns without mutating the entry or emitting an event. This keeps
361
+ * `useUIElement().updateLabel(...)` cheap when consumers re-publish from a
362
+ * render path that produces the same string on every tick.
363
+ *
364
+ * Returns `true` when the entry was mutated, `false` otherwise. Callers
365
+ * that want to gate a `console.warn` on no-op invocations can use the
366
+ * return value instead of recomputing equality.
367
+ */
368
+ updateElementMeta(id, meta) {
369
+ const element = this.elements.get(id);
370
+ if (!element) return false;
371
+ const currentIdentifier = element.getIdentifier();
372
+ const nextLabel = meta.label !== void 0 ? meta.label : element.label;
373
+ const nextAccessibilityLabel = meta.accessibilityLabel !== void 0 ? meta.accessibilityLabel : currentIdentifier.accessibilityLabel;
374
+ const nextTestId = meta.testId !== void 0 ? meta.testId : currentIdentifier.testId;
375
+ const labelChanged = nextLabel !== element.label;
376
+ const accessibilityLabelChanged = nextAccessibilityLabel !== currentIdentifier.accessibilityLabel;
377
+ const testIdChanged = nextTestId !== currentIdentifier.testId;
378
+ if (!labelChanged && !accessibilityLabelChanged && !testIdChanged) {
379
+ return false;
380
+ }
381
+ const updated = {
382
+ ...element,
383
+ label: nextLabel,
384
+ getIdentifier: () => ({
385
+ uiId: id,
386
+ testId: nextTestId,
387
+ accessibilityLabel: nextAccessibilityLabel,
388
+ treePath: currentIdentifier.treePath
389
+ })
390
+ };
391
+ this.elements.set(id, updated);
392
+ this.emit("element:registered", {
393
+ id,
394
+ type: element.type,
395
+ label: nextLabel
396
+ });
397
+ return true;
398
+ }
354
399
  /**
355
400
  * Update element props (for action execution)
356
401
  */
@@ -5114,6 +5159,7 @@ function flattenStateStyles(stateStyles) {
5114
5159
  return Object.keys(result).length > 0 ? result : void 0;
5115
5160
  }
5116
5161
  var warnedDeadButtonIds = /* @__PURE__ */ new Set();
5162
+ var warnedRedundantUpdateLabelIds = /* @__PURE__ */ new Set();
5117
5163
  function scheduleDeadButtonWarning(bridge, id, type) {
5118
5164
  if (type !== "button" && type !== "pressable") return;
5119
5165
  if (warnedDeadButtonIds.has(id)) return;
@@ -5342,6 +5388,23 @@ function useUIElement(options) {
5342
5388
  },
5343
5389
  [bridge, id]
5344
5390
  );
5391
+ const updateLabel = react.useCallback(
5392
+ (newLabel) => {
5393
+ if (!bridge || !registered) return;
5394
+ const changed = bridge.registry.updateElementMeta(id, {
5395
+ label: newLabel,
5396
+ accessibilityLabel: newLabel,
5397
+ testId: id
5398
+ });
5399
+ if (!changed && !warnedRedundantUpdateLabelIds.has(id)) {
5400
+ warnedRedundantUpdateLabelIds.add(id);
5401
+ console.warn(
5402
+ `[UI Bridge] updateLabel("${newLabel}") on element "${id}" was a no-op (label unchanged). Gate the call behind a useEffect with [label] deps to avoid redundant publishes.`
5403
+ );
5404
+ }
5405
+ },
5406
+ [bridge, registered, id]
5407
+ );
5345
5408
  const updateStyle = react.useCallback(
5346
5409
  (newStyle, newStateStyles) => {
5347
5410
  if (!bridge || !registered) return;
@@ -5367,7 +5430,8 @@ function useUIElement(options) {
5367
5430
  register,
5368
5431
  unregister,
5369
5432
  registeredElement,
5370
- updateStyle
5433
+ updateStyle,
5434
+ updateLabel
5371
5435
  };
5372
5436
  }
5373
5437
  function useUIElementWithProps(options) {