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