@declarion/react 0.198.0 → 0.200.0

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.
@@ -350,42 +350,46 @@ function L({ layout: e, entityActions: t, globalActions: n, onRun: r, loading: a
350
350
  ]
351
351
  });
352
352
  }
353
- var R = "__overflow_trigger__", z = 90, ee = 4, B = 8;
353
+ var ee = "__overflow_trigger__", R = 90, z = 4, B = 8;
354
354
  function te(e) {
355
- return `icon:${J(e)}`;
355
+ return `icon:${q(e)}`;
356
356
  }
357
- function ne() {
357
+ function V() {
358
358
  return B;
359
359
  }
360
- function V(e, t, n) {
360
+ function H(e, t, n) {
361
361
  return [
362
362
  ...e,
363
363
  ...t,
364
364
  ...n
365
365
  ];
366
366
  }
367
- var H = () => {}, U = () => Promise.resolve();
368
- function W(e) {
367
+ var U = () => {}, ne = () => Promise.resolve();
368
+ function re(e) {
369
369
  return (t) => {
370
370
  t && (t.setAttribute("data-node-key", e), t.setAttribute("tabindex", "-1"));
371
371
  };
372
372
  }
373
- function re(e, t) {
373
+ function ie(e, t) {
374
374
  if (e.size !== t.size) return !1;
375
375
  for (let [n, r] of t) if (e.get(n) !== r) return !1;
376
376
  return !0;
377
377
  }
378
- function G(e, t) {
379
- return t.get(J(e)) ?? 0;
378
+ function W(e, t) {
379
+ return t.get(q(e)) ?? 0;
380
+ }
381
+ function ae(e, t, n) {
382
+ let r = e.map((e) => W(e, t)).filter((e) => e > 0);
383
+ if (r.length !== 0) return r.reduce((e, t) => e + t, 0) + z * (r.length - 1) + n;
380
384
  }
381
- function K(e, t) {
385
+ function G(e, t) {
382
386
  return t.get(te(e));
383
387
  }
384
- function q(e, t, n, r, i, a, o, s, c) {
385
- let { primary: l, regular: u, destructive: d } = E(e, i, a), f = ee, p = r.get(R) ?? z, m = t - n, h = V(l, u, d), g = /* @__PURE__ */ new Set(), _ = /* @__PURE__ */ new Set();
386
- if (o) for (let e of h) o(e) && g.add(J(e));
388
+ function K(e, t, n, r, i, a, o, s, c) {
389
+ let { primary: l, regular: u, destructive: d } = E(e, i, a), f = z, p = r.get(ee) ?? R, m = t - n, h = H(l, u, d), g = /* @__PURE__ */ new Set(), _ = /* @__PURE__ */ new Set();
390
+ if (o) for (let e of h) o(e) && g.add(q(e));
387
391
  else {
388
- let e = (e, t) => t ? K(e, r) ?? G(e, r) : G(e, r), t = (e) => s ? e.filter((e) => !s.has(J(e))).length * ne() : 0, n = (e, t) => c ? e.slice(0, t).filter((e) => c.has(J(e))).length * ne() : 0, i = (r, i) => {
392
+ let e = (e, t) => t ? G(e, r) ?? W(e, r) : W(e, r), t = (e) => s ? e.filter((e) => !s.has(q(e))).length * V() : 0, n = (e, t) => c ? e.slice(0, t).filter((e) => c.has(q(e))).length * V() : 0, i = (r, i) => {
389
393
  let a = r.length < h.length ? p + f : 0, o = r.length > 1 ? (r.length - 1) * f : 0;
390
394
  return r.reduce((t, n, r) => t + e(n, r >= i), 0) + o + a + t(r) + n(r, i) <= m;
391
395
  }, a = 0, o = !1;
@@ -393,11 +397,11 @@ function q(e, t, n, r, i, a, o, s, c) {
393
397
  let l = o ? 0 : Math.min(1, a), u = h.slice(0, a);
394
398
  for (; l < a && i(u, l + 1);) l++;
395
399
  u.forEach((e, t) => {
396
- let n = J(e);
400
+ let n = q(e);
397
401
  g.add(n), t >= l && _.add(n);
398
402
  });
399
403
  }
400
- let v = (e) => g.has(J(e)), y = [
404
+ let v = (e) => g.has(q(e)), y = [
401
405
  ...l,
402
406
  ...u,
403
407
  ...d
@@ -410,112 +414,112 @@ function q(e, t, n, r, i, a, o, s, c) {
410
414
  iconOnly: _
411
415
  };
412
416
  }
413
- function J(e) {
417
+ function q(e) {
414
418
  return e.kind === "action" ? `action:${e.code}` : `group:${JSON.stringify(e.name ?? {})}`;
415
419
  }
416
- function ie(e) {
420
+ function oe(e) {
417
421
  let t = e.parentElement;
418
422
  for (; t && getComputedStyle(t).display === "contents";) t = t.parentElement;
419
423
  if (!t) return !1;
420
424
  let n = getComputedStyle(t);
421
425
  return !(parseFloat(n.flexGrow) > 0 || n.display === "block" || n.display === "flow-root" || n.width !== "auto" || n.maxWidth !== "none");
422
426
  }
423
- function Y({ layout: r, entityActions: a, globalActions: o, onRun: s, reservedRightWidth: c = 0, measurementOverride: l, ariaLabel: x, align: S = "trailing", constrain: C = !0, row: E, widgetContext: D, onActionClick: O }) {
424
- let A = u(), F = g(null), I = g(null), [L, z] = _(0), [B, ne] = _(/* @__PURE__ */ new Map()), [V, G] = _(!1), [K, Y] = _(null), [X, ae] = _(() => typeof document < "u" && document.documentElement.dir === "rtl");
427
+ function J({ layout: r, entityActions: a, globalActions: o, onRun: s, reservedRightWidth: c = 0, measurementOverride: l, ariaLabel: x, align: S = "trailing", constrain: C = !0, row: E, widgetContext: D, onActionClick: O }) {
428
+ let A = u(), F = g(null), I = g(null), [L, R] = _(0), [B, V] = _(/* @__PURE__ */ new Map()), [H, W] = _(!1), [G, J] = _(null), [Y, se] = _(() => typeof document < "u" && document.documentElement.dir === "rtl");
425
429
  p(() => {
426
430
  if (typeof MutationObserver > "u") return;
427
431
  let e = new MutationObserver((e) => {
428
- for (let t of e) t.attributeName === "dir" && ae(document.documentElement.dir === "rtl"), t.attributeName === "lang" && G(!1);
432
+ for (let t of e) t.attributeName === "dir" && se(document.documentElement.dir === "rtl"), t.attributeName === "lang" && W(!1);
429
433
  });
430
434
  return e.observe(document.documentElement, {
431
435
  attributes: !0,
432
436
  attributeFilter: ["dir", "lang"]
433
437
  }), () => e.disconnect();
434
438
  }, []);
435
- let oe = g(null), [se, ce] = _(!1), le = f((e, t) => (ce(!1), s(e, t)), [s]), ue = w(r), Z = !!l, Q = f(() => {
436
- if (Z || !I.current) return;
439
+ let ce = g(null), [le, ue] = _(!1), de = f((e, t) => (ue(!1), s(e, t)), [s]), fe = w(r), X = !!l, Z = f(() => {
440
+ if (X || !I.current) return;
437
441
  let e = Array.from(I.current.children), t = /* @__PURE__ */ new Map();
438
442
  e.forEach((e) => {
439
443
  let n = e.dataset.nodeKey;
440
444
  n && t.set(n, e.getBoundingClientRect().width || e.offsetWidth);
441
- }), ne((e) => re(e, t) ? e : t), G(!0);
442
- }, [Z]), de = h(() => JSON.stringify(r.map((e) => J(e))), [r]);
445
+ }), V((e) => ie(e, t) ? e : t), W(!0);
446
+ }, [X]), pe = h(() => JSON.stringify(r.map((e) => q(e))), [r]);
443
447
  p(() => {
444
- if (Z) return;
448
+ if (X) return;
445
449
  let e = I.current;
446
450
  if (!e || typeof ResizeObserver > "u") return;
447
- let t = new ResizeObserver(() => Q());
451
+ let t = new ResizeObserver(() => Z());
448
452
  t.observe(e);
449
453
  for (let n of Array.from(e.children)) t.observe(n);
450
454
  return () => t.disconnect();
451
455
  }, [
452
- Q,
453
456
  Z,
454
- de
457
+ X,
458
+ pe
455
459
  ]), m(() => {
456
- if (Z) {
457
- G(!0);
460
+ if (X) {
461
+ W(!0);
458
462
  return;
459
463
  }
460
- G(!1);
464
+ W(!1);
461
465
  let e = requestAnimationFrame(() => {
462
- Q();
466
+ Z();
463
467
  });
464
468
  return () => cancelAnimationFrame(e);
465
469
  }, [
466
- de,
467
- Q,
468
- Z
470
+ pe,
471
+ Z,
472
+ X
469
473
  ]), p(() => {
470
- if (Z || V) return;
474
+ if (X || H) return;
471
475
  let e = setTimeout(() => {
472
- Q(), G(!0);
476
+ Z(), W(!0);
473
477
  }, 16);
474
478
  return () => clearTimeout(e);
475
479
  }, [
476
- V,
477
- Q,
478
- Z
480
+ H,
481
+ Z,
482
+ X
479
483
  ]), p(() => {
480
- if (Z || !C || !V || L === 0) return;
484
+ if (X || !C || !H || L === 0) return;
481
485
  let e = F.current;
482
- if (!e || !ie(e)) return;
486
+ if (!e || !oe(e)) return;
483
487
  let t = [...e.children].filter((e) => e.getAttribute("aria-hidden") !== "true"), n = t.length > 1 ? (t.length - 1) * 4 : 0, r = t.reduce((e, t) => e + t.getBoundingClientRect().width, 0) + n;
484
488
  r > 0 && Math.abs(L - r) < 1 && console.error(`[declarion] ResponsiveActionBar is measuring itself: its container is ${Math.round(L)}px, exactly the width of what it just rendered. The slot holding this bar is sized by its own content, so it cannot tell the bar how much room there is. Give that slot \`flex: 1 1 auto; min-width: 0\` (and justify its content to the edge the buttons sit on), or pass \`constrain={false}\` if it genuinely has no row to take space from.`);
485
489
  }, [
486
- Z,
490
+ X,
487
491
  C,
488
- V,
492
+ H,
489
493
  L,
490
494
  B
491
495
  ]), p(() => {
492
- if (Z) return;
496
+ if (X) return;
493
497
  let e = F.current;
494
498
  if (!e) return;
495
499
  if (typeof ResizeObserver > "u") {
496
- z(e.getBoundingClientRect().width);
500
+ R(e.getBoundingClientRect().width);
497
501
  return;
498
502
  }
499
503
  let t = new ResizeObserver((e) => {
500
504
  let t = e[0];
501
- t && z(t.contentRect.width);
505
+ t && R(t.contentRect.width);
502
506
  });
503
- return t.observe(e), z(e.getBoundingClientRect().width), () => t.disconnect();
504
- }, [Z]);
505
- let fe = g(void 0), pe = g(void 0);
507
+ return t.observe(e), R(e.getBoundingClientRect().width), () => t.disconnect();
508
+ }, [X]);
509
+ let me = g(void 0), Q = g(void 0);
506
510
  p(() => {
507
- fe.current = void 0, pe.current = void 0;
508
- }, [de]);
509
- let $ = h(() => Z || !C ? q(r, 2 ** 53 - 1, c, B, a, o, l) : V ? L === 0 ? q(r, 2 ** 53 - 1, c, B, a, o, l) : q(r, L, c, B, a, o, l, fe.current, pe.current) : {
511
+ me.current = void 0, Q.current = void 0;
512
+ }, [pe]);
513
+ let $ = h(() => X || !C ? K(r, 2 ** 53 - 1, c, B, a, o, l) : H ? L === 0 ? K(r, 2 ** 53 - 1, c, B, a, o, l) : K(r, L, c, B, a, o, l, me.current, Q.current) : {
510
514
  primaryInline: [],
511
515
  inline: [],
512
516
  overflow: [],
513
517
  destructiveInline: [],
514
518
  iconOnly: /* @__PURE__ */ new Set()
515
519
  }, [
516
- Z,
520
+ X,
517
521
  C,
518
- V,
522
+ H,
519
523
  L,
520
524
  r,
521
525
  c,
@@ -525,30 +529,31 @@ function Y({ layout: r, entityActions: a, globalActions: o, onRun: s, reservedRi
525
529
  l
526
530
  ]);
527
531
  if (p(() => {
528
- (V || Z) && (fe.current = new Set([
532
+ (H || X) && (me.current = new Set([
529
533
  ...$.primaryInline,
530
534
  ...$.inline,
531
535
  ...$.destructiveInline
532
- ].map(J)), pe.current = new Set($.iconOnly));
536
+ ].map(q)), Q.current = new Set($.iconOnly));
533
537
  }, [
534
538
  $,
535
- V,
536
- Z
537
- ]), ue === 0) return null;
538
- let me = $.overflow.length > 0, { normal: he, destructive: ge } = T($.overflow, a, o);
539
+ H,
540
+ X
541
+ ]), fe === 0) return null;
542
+ let he = $.overflow.length > 0, { normal: ge, destructive: _e } = T($.overflow, a, o);
539
543
  return /* @__PURE__ */ b("div", {
540
544
  ref: F,
541
545
  role: "toolbar",
542
546
  "aria-label": x ?? A("action.menu.title", "Actions"),
543
547
  style: {
544
548
  display: "flex",
545
- flexDirection: X ? "row-reverse" : "row",
549
+ flexDirection: Y ? "row-reverse" : "row",
546
550
  alignItems: "center",
547
- gap: ee,
551
+ gap: z,
548
552
  flexWrap: "wrap",
549
- visibility: V || Z ? "visible" : "hidden",
553
+ visibility: H || X ? "visible" : "hidden",
550
554
  position: "relative",
551
555
  flex: C ? "1 1 auto" : "0 1 auto",
556
+ width: C && H && !X ? ae(r, B, c) : void 0,
552
557
  justifyContent: S === "trailing" ? "flex-end" : "flex-start",
553
558
  minWidth: 0,
554
559
  boxSizing: "border-box"
@@ -570,44 +575,44 @@ function Y({ layout: r, entityActions: a, globalActions: o, onRun: s, reservedRi
570
575
  flexWrap: "nowrap"
571
576
  },
572
577
  children: [/* @__PURE__ */ y(e, {
573
- "data-node-key": R,
578
+ "data-node-key": ee,
574
579
  iconRight: /* @__PURE__ */ y(n.down, { size: 10 }),
575
580
  tabIndex: -1,
576
581
  children: A("action.menu.title", "Actions")
577
- }, R), r.map((e) => {
578
- let t = J(e);
582
+ }, ee), r.map((e) => {
583
+ let t = q(e);
579
584
  return e.kind === "action" ? /* @__PURE__ */ b(d, { children: [/* @__PURE__ */ y(j, {
580
585
  leaf: e,
581
586
  entityActions: a,
582
587
  globalActions: o,
583
- onRun: U,
588
+ onRun: ne,
584
589
  loading: !1,
585
- onLoadingChange: H,
590
+ onLoadingChange: U,
586
591
  row: E,
587
592
  widgetContext: D,
588
- measureRef: W(t)
593
+ measureRef: re(t)
589
594
  }), k(e.code, a, o) && /* @__PURE__ */ y(j, {
590
595
  leaf: e,
591
596
  entityActions: a,
592
597
  globalActions: o,
593
- onRun: U,
598
+ onRun: ne,
594
599
  loading: !1,
595
- onLoadingChange: H,
600
+ onLoadingChange: U,
596
601
  row: E,
597
602
  widgetContext: D,
598
603
  iconOnly: !0,
599
- measureRef: W(te(e))
604
+ measureRef: re(te(e))
600
605
  })] }, t) : /* @__PURE__ */ y(M, {
601
606
  group: e,
602
607
  entityActions: a,
603
608
  globalActions: o,
604
- onRun: U,
609
+ onRun: ne,
605
610
  loading: null,
606
- onLoadingChange: H,
611
+ onLoadingChange: U,
607
612
  row: E,
608
613
  widgetContext: D,
609
614
  onActionClick: O,
610
- measureRef: W(t)
615
+ measureRef: re(t)
611
616
  }, t);
612
617
  })]
613
618
  }),
@@ -616,22 +621,22 @@ function Y({ layout: r, entityActions: a, globalActions: o, onRun: s, reservedRi
616
621
  entityActions: a,
617
622
  globalActions: o,
618
623
  onRun: s,
619
- loading: K === e.code,
620
- onLoadingChange: (t) => Y(t ? e.code : null),
624
+ loading: G === e.code,
625
+ onLoadingChange: (t) => J(t ? e.code : null),
621
626
  row: E,
622
627
  widgetContext: D,
623
628
  onActionClick: O,
624
- iconOnly: $.iconOnly.has(J(e))
625
- }, J(e))),
629
+ iconOnly: $.iconOnly.has(q(e))
630
+ }, q(e))),
626
631
  $.inline.map((e) => {
627
- let t = J(e);
632
+ let t = q(e);
628
633
  return e.kind === "action" ? /* @__PURE__ */ y(j, {
629
634
  leaf: e,
630
635
  entityActions: a,
631
636
  globalActions: o,
632
637
  onRun: s,
633
- loading: K === e.code,
634
- onLoadingChange: (t) => Y(t ? e.code : null),
638
+ loading: G === e.code,
639
+ onLoadingChange: (t) => J(t ? e.code : null),
635
640
  row: E,
636
641
  widgetContext: D,
637
642
  onActionClick: O,
@@ -641,41 +646,41 @@ function Y({ layout: r, entityActions: a, globalActions: o, onRun: s, reservedRi
641
646
  entityActions: a,
642
647
  globalActions: o,
643
648
  onRun: s,
644
- loading: K,
645
- onLoadingChange: Y,
649
+ loading: G,
650
+ onLoadingChange: J,
646
651
  row: E,
647
652
  widgetContext: D,
648
653
  onActionClick: O
649
654
  }, t);
650
655
  }),
651
- me && /* @__PURE__ */ b(v, { children: [/* @__PURE__ */ y(e, {
652
- ref: oe,
656
+ he && /* @__PURE__ */ b(v, { children: [/* @__PURE__ */ y(e, {
657
+ ref: ce,
653
658
  kind: "default",
654
659
  iconRight: /* @__PURE__ */ y(n.down, { size: 10 }),
655
660
  "aria-haspopup": "menu",
656
- "aria-expanded": se ? "true" : "false",
657
- onClick: () => ce((e) => !e),
661
+ "aria-expanded": le ? "true" : "false",
662
+ onClick: () => ue((e) => !e),
658
663
  children: A("action.menu.title", "Actions")
659
664
  }), /* @__PURE__ */ y(t, {
660
- open: se,
661
- anchor: oe.current,
662
- onClose: () => ce(!1),
663
- align: X ? "start" : "end",
665
+ open: le,
666
+ anchor: ce.current,
667
+ onClose: () => ue(!1),
668
+ align: Y ? "start" : "end",
664
669
  width: 220,
665
670
  children: /* @__PURE__ */ y("div", {
666
671
  role: "menu",
667
672
  "aria-label": A("action.menu.more", "More actions"),
668
673
  children: [
669
- ...he,
670
- ...ge.length > 0 ? [null] : [],
671
- ...ge
674
+ ...ge,
675
+ ..._e.length > 0 ? [null] : [],
676
+ ..._e
672
677
  ].map((e, t) => e === null ? /* @__PURE__ */ y(i, { divider: !0 }, "destructive-divider") : e.kind === "action" ? /* @__PURE__ */ y(N, {
673
678
  leaf: e,
674
679
  entityActions: a,
675
680
  globalActions: o,
676
- onRun: le,
677
- loading: K === e.code,
678
- onLoadingChange: (t) => Y(t ? e.code : null),
681
+ onRun: de,
682
+ loading: G === e.code,
683
+ onLoadingChange: (t) => J(t ? e.code : null),
679
684
  row: E,
680
685
  widgetContext: D,
681
686
  onActionClick: O
@@ -683,13 +688,13 @@ function Y({ layout: r, entityActions: a, globalActions: o, onRun: s, reservedRi
683
688
  group: e,
684
689
  entityActions: a,
685
690
  globalActions: o,
686
- onRun: le,
687
- loading: K,
688
- onLoadingChange: Y,
691
+ onRun: de,
692
+ loading: G,
693
+ onLoadingChange: J,
689
694
  row: E,
690
695
  widgetContext: D,
691
696
  onActionClick: O
692
- }, `${J(e)}-${t}`))
697
+ }, `${q(e)}-${t}`))
693
698
  })
694
699
  })] }),
695
700
  $.destructiveInline.map((e) => /* @__PURE__ */ y(j, {
@@ -697,17 +702,17 @@ function Y({ layout: r, entityActions: a, globalActions: o, onRun: s, reservedRi
697
702
  entityActions: a,
698
703
  globalActions: o,
699
704
  onRun: s,
700
- loading: K === e.code,
701
- onLoadingChange: (t) => Y(t ? e.code : null),
705
+ loading: G === e.code,
706
+ onLoadingChange: (t) => J(t ? e.code : null),
702
707
  row: E,
703
708
  widgetContext: D,
704
709
  onActionClick: O,
705
- iconOnly: $.iconOnly.has(J(e))
706
- }, J(e)))
710
+ iconOnly: $.iconOnly.has(q(e))
711
+ }, q(e)))
707
712
  ]
708
713
  });
709
714
  }
710
- function X({ layout: e, rowSelection: t = [], ...n }) {
715
+ function Y({ layout: e, rowSelection: t = [], ...n }) {
711
716
  let r = t.length > 0;
712
717
  return /* @__PURE__ */ b("div", {
713
718
  style: {
@@ -723,7 +728,7 @@ function X({ layout: e, rowSelection: t = [], ...n }) {
723
728
  flex: "1 1 auto",
724
729
  minWidth: 0
725
730
  },
726
- children: /* @__PURE__ */ y(Y, {
731
+ children: /* @__PURE__ */ y(J, {
727
732
  layout: e,
728
733
  rowSelection: [],
729
734
  ...n
@@ -735,7 +740,7 @@ function X({ layout: e, rowSelection: t = [], ...n }) {
735
740
  flex: "1 1 auto",
736
741
  minWidth: 0
737
742
  },
738
- children: /* @__PURE__ */ y(Y, {
743
+ children: /* @__PURE__ */ y(J, {
739
744
  layout: e,
740
745
  rowSelection: t,
741
746
  ...n
@@ -743,7 +748,7 @@ function X({ layout: e, rowSelection: t = [], ...n }) {
743
748
  })]
744
749
  });
745
750
  }
746
- function ae({ layout: e, row: t, rowSelection: n, onRun: r, reservedRightWidth: i = 0, kind: a = "toolbar", align: o = "trailing", constrain: s = !0, measurementOverride: c, entityActions: l, globalActions: u, ariaLabel: d, widgetContext: f, onActionClick: p }) {
751
+ function se({ layout: e, row: t, rowSelection: n, onRun: r, reservedRightWidth: i = 0, kind: a = "toolbar", align: o = "trailing", constrain: s = !0, measurementOverride: c, entityActions: l, globalActions: u, ariaLabel: d, widgetContext: f, onActionClick: p }) {
747
752
  let m = w(e);
748
753
  return a === "row" ? /* @__PURE__ */ y(F, {
749
754
  layout: e,
@@ -753,7 +758,7 @@ function ae({ layout: e, row: t, rowSelection: n, onRun: r, reservedRightWidth:
753
758
  row: t,
754
759
  widgetContext: f,
755
760
  onActionClick: p
756
- }) : m === 0 ? null : y(a === "toolbar" ? X : Y, {
761
+ }) : m === 0 ? null : y(a === "toolbar" ? Y : J, {
757
762
  layout: e,
758
763
  row: t,
759
764
  rowSelection: n,
@@ -769,4 +774,4 @@ function ae({ layout: e, row: t, rowSelection: n, onRun: r, reservedRightWidth:
769
774
  onActionClick: p
770
775
  });
771
776
  }
772
- export { ae as ResponsiveActionBar, L as RowMenuContent, q as computeLayout, x as interpolate, ie as slotIsContentSized };
777
+ export { se as ResponsiveActionBar, L as RowMenuContent, K as computeLayout, x as interpolate, oe as slotIsContentSized };
@@ -80,6 +80,7 @@ function A(e) {
80
80
  type: e.type,
81
81
  value: e.value,
82
82
  values: e.values,
83
+ structure: e.structure,
83
84
  label: ce(e),
84
85
  maxWidth: "100%"
85
86
  }),
@@ -72,6 +72,7 @@ function b({ carrierEntityCode: b, carrierScope: x, rowId: S, title: C, icon: w,
72
72
  type: e.type,
73
73
  value: e.value,
74
74
  values: e.values,
75
+ structure: e.structure,
75
76
  label: H(e)
76
77
  }),
77
78
  o && /* @__PURE__ */ g(n, {
@@ -69,25 +69,28 @@ function S(e) {
69
69
  }] : []), { refs: i } = s(r, void 0, n?.entities);
70
70
  return (e) => e.ref?.entity ? o(t, i, e.ref, e.value, n?.entities) : void 0;
71
71
  }
72
- function C({ type: e, value: t, values: n, label: r, maxWidth: i = 180 }) {
73
- let a = d(), o = (e) => {
72
+ function C({ type: e, value: t, values: n, structure: r, label: i, maxWidth: a = 180 }) {
73
+ let o = d(), { data: s } = c(), l = (e) => {
74
74
  let t = n?.find((t) => t.code === e);
75
- return t && a(t.name) || u(e);
76
- }, s;
77
- return s = r === void 0 ? t == null ? "—" : n && n.length > 0 ? (Array.isArray(t) ? t.map(o).join(", ") : o(t)) || "—" : e === "bool" ? t ? a("params.value.on", "On") : a("params.value.off", "Off") : e === "multilang" || e === "multilang_text" ? a(t) || "—" : e === "multilang_array" && Array.isArray(t) ? t.map((e) => a(e)).join(", ") || "—" : e === "json" || e === "structure" ? Array.isArray(t) ? `[${t.map((e) => e && typeof e == "object" ? "{…}" : u(e)).join(", ")}]` : t && typeof t == "object" ? `{${Object.keys(t).join(", ")}}` : u(t) : u(t) : r, /* @__PURE__ */ h("span", {
75
+ return t && o(t.name) || u(e);
76
+ }, f = (e) => {
77
+ let t = r ? s?.structures?.[r]?.fields : void 0;
78
+ return t ? [...t].filter(([t]) => t in e).map(([e, t]) => t.display ? o(t.display.name) : e).join(", ") || "—" : `{${Object.keys(e).join(", ")}}`;
79
+ }, p;
80
+ return p = i === void 0 ? t == null || t === "" ? "—" : n && n.length > 0 ? (Array.isArray(t) ? t.map(l).join(", ") : l(t)) || "—" : e === "bool" ? t ? o("params.value.on", "On") : o("params.value.off", "Off") : e === "multilang" || e === "multilang_text" ? o(t) || "—" : e === "multilang_array" && Array.isArray(t) ? t.map((e) => o(e)).join(", ") || "—" : e === "json" || e === "structure" ? Array.isArray(t) ? `[${t.map((e) => e && typeof e == "object" ? "{…}" : u(e)).join(", ")}]` : t && typeof t == "object" ? f(t) : u(t) : u(t) : i, /* @__PURE__ */ h("span", {
78
81
  className: "mono",
79
- title: s,
82
+ title: p,
80
83
  style: {
81
84
  display: "inline-block",
82
85
  verticalAlign: "middle",
83
86
  fontSize: 11.5,
84
87
  color: "var(--text-2)",
85
- maxWidth: i,
88
+ maxWidth: a,
86
89
  overflow: "hidden",
87
90
  textOverflow: "ellipsis",
88
91
  whiteSpace: "nowrap"
89
92
  },
90
- children: s
93
+ children: p
91
94
  });
92
95
  }
93
96
  function w({ param: i, current: o, error: s, onCancel: c, onSave: l }) {
@@ -1,21 +1,22 @@
1
1
  import { Icon as e } from "./Icons.js";
2
2
  import { useText as t } from "../../hooks/useText.js";
3
- import { useCallback as n, useState as r } from "react";
4
- import { jsx as i, jsxs as a } from "react/jsx-runtime";
3
+ import { isUuid as n } from "../../lib/uuid.js";
4
+ import { useCallback as r, useState as i } from "react";
5
+ import { jsx as a, jsxs as o } from "react/jsx-runtime";
5
6
  // src/components/primitives/RecordIdBadge.tsx
6
- var o = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, s = 1200;
7
+ var s = 1200;
7
8
  function c({ value: c }) {
8
- let l = t(), [u, d] = r(!1), f = o.test(c) ? `${c.slice(0, 8)}…` : c, p = n(async () => {
9
+ let l = t(), [u, d] = i(!1), f = n(c) ? `${c.slice(0, 8)}…` : c, p = r(async () => {
9
10
  try {
10
11
  await navigator.clipboard.writeText(c), d(!0), window.setTimeout(() => d(!1), s);
11
12
  } catch {}
12
13
  }, [c]);
13
- return /* @__PURE__ */ a("button", {
14
+ return /* @__PURE__ */ o("button", {
14
15
  type: "button",
15
16
  onClick: p,
16
17
  title: u ? l("control.copied", "Copied") : l("control.copy_value", "Copy {value}", { value: c }),
17
18
  className: "mono inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[11px] text-text-4 hover:bg-surface-2 hover:text-text-3 transition-colors shrink-0 border border-transparent hover:border-border",
18
- children: [/* @__PURE__ */ i("span", { children: f }), u ? /* @__PURE__ */ i(e.check, { size: 10 }) : /* @__PURE__ */ i(e.copy, {
19
+ children: [/* @__PURE__ */ a("span", { children: f }), u ? /* @__PURE__ */ a(e.check, { size: 10 }) : /* @__PURE__ */ a(e.copy, {
19
20
  size: 10,
20
21
  style: { opacity: .6 }
21
22
  })]
@@ -2,9 +2,10 @@ import { useEntity as e } from "./useEntity.js";
2
2
  import { useEntityData as t } from "./useEntityData.js";
3
3
  import { useScreen as n } from "./useScreen.js";
4
4
  import { coerceDisplayString as r } from "../lib/display-value.js";
5
- import { useCallback as i, useMemo as a } from "react";
5
+ import { isUuid as i } from "../lib/uuid.js";
6
+ import { useCallback as a, useMemo as o } from "react";
6
7
  // src/hooks/useViews.ts
7
- function o(e, t) {
8
+ function s(e, t) {
8
9
  let n = t && String(e.user_id) === t;
9
10
  return {
10
11
  id: String(e.id),
@@ -17,27 +18,27 @@ function o(e, t) {
17
18
  sort: e.sort
18
19
  };
19
20
  }
20
- function s(e, n) {
21
- let r = t("view", {
21
+ function c(e, n) {
22
+ let r = e && i(e) ? e : null, a = t("view", {
22
23
  filters: [{
23
24
  field: "id",
24
25
  op: "eq",
25
- value: e ?? ""
26
+ value: r ?? ""
26
27
  }],
27
28
  per_page: 1
28
- }, !!e), i = r.data?.data?.[0], s = a(() => i ? o(i, n) : void 0, [i, n]);
29
- return e ? {
30
- view: s,
31
- isSettled: !r.isPending || r.fetchStatus === "paused"
29
+ }, !!r), c = a.data?.data?.[0], l = o(() => c ? s(c, n) : void 0, [c, n]);
30
+ return r ? {
31
+ view: l,
32
+ isSettled: !a.isPending || a.fetchStatus === "paused"
32
33
  } : {
33
34
  view: void 0,
34
35
  isSettled: !0
35
36
  };
36
37
  }
37
- function c(e, t) {
38
- return u(e, t).views;
39
- }
40
38
  function l(e, t) {
39
+ return d(e, t).views;
40
+ }
41
+ function u(e, t) {
41
42
  return {
42
43
  filters: [{
43
44
  field: "screen_code",
@@ -56,8 +57,8 @@ function l(e, t) {
56
57
  per_page: 100
57
58
  };
58
59
  }
59
- function u(r, s) {
60
- let c = n(r), u = e("view") !== void 0, d = t("view", l(r, s), u), f = d.data, p = a(() => {
60
+ function d(r, i) {
61
+ let c = n(r), l = e("view") !== void 0, d = t("view", u(r, i), l), f = d.data, p = o(() => {
61
62
  let e = [];
62
63
  if (c?.views) for (let t of c.views) e.push({
63
64
  id: t.code,
@@ -68,20 +69,20 @@ function u(r, s) {
68
69
  columns: t.columns,
69
70
  sort: t.sort
70
71
  });
71
- if (f?.data) for (let t of f.data) e.push(o(t, s));
72
+ if (f?.data) for (let t of f.data) e.push(s(t, i));
72
73
  return e;
73
74
  }, [
74
75
  c?.views,
75
76
  f?.data,
76
- s
77
+ i
77
78
  ]), { refetch: m } = d;
78
79
  return {
79
80
  views: p,
80
- isSettled: !u || !d.isPending || d.fetchStatus === "paused",
81
+ isSettled: !l || !d.isPending || d.fetchStatus === "paused",
81
82
  isFetching: d.isFetching,
82
- refetch: i(() => {
83
+ refetch: a(() => {
83
84
  m();
84
85
  }, [m])
85
86
  };
86
87
  }
87
- export { l as savedViewsParams, s as useViewById, c as useViews, u as useViewsQuery, o as viewItemFromRow };
88
+ export { u as savedViewsParams, c as useViewById, l as useViews, d as useViewsQuery, s as viewItemFromRow };
@@ -0,0 +1,6 @@
1
+ // src/lib/uuid.ts
2
+ var e = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
3
+ function t(t) {
4
+ return e.test(t);
5
+ }
6
+ export { t as isUuid };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@declarion/react",
3
- "version": "0.198.0",
3
+ "version": "0.200.0",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "description": "React SDK for Declarion, the schema-driven business apps platform.",