@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.
package/dist/index.mjs CHANGED
@@ -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
  */
@@ -5164,6 +5209,7 @@ function flattenStateStyles(stateStyles) {
5164
5209
  return Object.keys(result).length > 0 ? result : void 0;
5165
5210
  }
5166
5211
  var warnedDeadButtonIds = /* @__PURE__ */ new Set();
5212
+ var warnedRedundantUpdateLabelIds = /* @__PURE__ */ new Set();
5167
5213
  function scheduleDeadButtonWarning(bridge, id, type) {
5168
5214
  if (type !== "button" && type !== "pressable") return;
5169
5215
  if (warnedDeadButtonIds.has(id)) return;
@@ -5392,6 +5438,23 @@ function useUIElement(options) {
5392
5438
  },
5393
5439
  [bridge, id]
5394
5440
  );
5441
+ const updateLabel = useCallback(
5442
+ (newLabel) => {
5443
+ if (!bridge || !registered) return;
5444
+ const changed = bridge.registry.updateElementMeta(id, {
5445
+ label: newLabel,
5446
+ accessibilityLabel: newLabel,
5447
+ testId: id
5448
+ });
5449
+ if (!changed && !warnedRedundantUpdateLabelIds.has(id)) {
5450
+ warnedRedundantUpdateLabelIds.add(id);
5451
+ console.warn(
5452
+ `[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.`
5453
+ );
5454
+ }
5455
+ },
5456
+ [bridge, registered, id]
5457
+ );
5395
5458
  const updateStyle = useCallback(
5396
5459
  (newStyle, newStateStyles) => {
5397
5460
  if (!bridge || !registered) return;
@@ -5417,7 +5480,8 @@ function useUIElement(options) {
5417
5480
  register,
5418
5481
  unregister,
5419
5482
  registeredElement,
5420
- updateStyle
5483
+ updateStyle,
5484
+ updateLabel
5421
5485
  };
5422
5486
  }
5423
5487
  function useUIElementWithProps(options) {