@realtek/core-theme 0.0.298 → 0.0.299

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-lib/index.js CHANGED
@@ -44383,28 +44383,79 @@ function mM({ record: e }) {
44383
44383
  })]
44384
44384
  });
44385
44385
  }
44386
- function hM({ fields: e, moduleName: t }) {
44387
- return e?.length ? /* @__PURE__ */ X("div", {
44386
+ function hM({ fields: e, moduleName: t, centralDocuments: n = [] }) {
44387
+ let [r, i] = R([]), [a, o] = R(0), [s, c] = R(!1);
44388
+ if (!e?.length) return null;
44389
+ function l(e) {
44390
+ let t = String(e?.type ?? "").trim().toLowerCase(), n = `${e?.field ?? ""} ${e?.label ?? ""}`;
44391
+ return [
44392
+ "file",
44393
+ "document",
44394
+ "upload"
44395
+ ].includes(t) || /resume|cv|document|attachment/i.test(n);
44396
+ }
44397
+ function u(e, t) {
44398
+ i(e), o(t), c(!0);
44399
+ }
44400
+ return /* @__PURE__ */ Z(Y, { children: [/* @__PURE__ */ X("div", {
44388
44401
  className: "preview-field-grid",
44389
44402
  children: e.map((e) => {
44390
- let n = e.value, r = Array.isArray(n) && n.length > 0, i = fM(t) && pM(e) && typeof n == "string" && n.trim();
44391
- return r ? n.map((t, r) => /* @__PURE__ */ Z("div", {
44403
+ let r = e.value, i = Array.isArray(r) && r.length > 0, a = fM(t) && pM(e) && typeof r == "string" && r.trim(), o = l(e) ? n.filter((t) => {
44404
+ let n = String(t?.fieldName ?? t?.field ?? t?.formField ?? t?.key ?? "").trim().toLowerCase(), r = String(e?.field ?? "").trim().toLowerCase();
44405
+ if (n && r && n === r) return !0;
44406
+ let i = `${e?.field ?? ""} ${e?.label ?? ""}`;
44407
+ return /resume|cv/i.test(i) ? /resume|cv/i.test(`${n} ${t?.fileName ?? ""} ${t?.name ?? ""}`) : !1;
44408
+ }).map((t) => ({
44409
+ name: t?.fileName || t?.name || t?.uploadedFileName || t?.originalName || e?.label || "Document",
44410
+ url: t?.fileUrl || t?.downloadUrl || t?.signedUrl || t?.url || "",
44411
+ type: t?.mimeType || t?.contentType || t?.type
44412
+ })).filter((e) => e.url) : [], s = l(e) ? o.length ? o : Ye(r).filter((e) => e.url) : [];
44413
+ return s.length ? /* @__PURE__ */ Z("div", {
44414
+ className: "preview-field-card preview-field-card--documents",
44415
+ children: [/* @__PURE__ */ X("span", {
44416
+ className: "preview-field-card__label",
44417
+ children: e.label
44418
+ }), /* @__PURE__ */ X("div", {
44419
+ className: "preview-document-list",
44420
+ children: s.map((e, t) => /* @__PURE__ */ Z("button", {
44421
+ type: "button",
44422
+ className: "preview-document-link",
44423
+ onClick: () => u(s, t),
44424
+ title: `Preview ${e.name || "document"}`,
44425
+ children: [
44426
+ /* @__PURE__ */ X("span", {
44427
+ className: "preview-document-link__icon",
44428
+ "aria-hidden": "true",
44429
+ children: "▣"
44430
+ }),
44431
+ /* @__PURE__ */ X("span", {
44432
+ className: "preview-document-link__name",
44433
+ children: e.name || `Document ${t + 1}`
44434
+ }),
44435
+ /* @__PURE__ */ X("span", {
44436
+ className: "preview-document-link__action",
44437
+ children: "Preview"
44438
+ })
44439
+ ]
44440
+ }, `${e.url}-${t}`))
44441
+ })]
44442
+ }, e.field ?? e.label) : i ? r.map((t, n) => /* @__PURE__ */ Z("div", {
44392
44443
  className: "preview-field-card",
44393
44444
  children: [/* @__PURE__ */ Z("span", {
44394
44445
  className: "preview-field-card__label",
44395
- children: [e.label, n.length > 1 ? ` (${r + 1})` : ""]
44446
+ children: [e.label, r.length > 1 ? ` (${n + 1})` : ""]
44396
44447
  }), /* @__PURE__ */ X("span", {
44397
44448
  className: "preview-field-card__value",
44398
44449
  children: uM(t)
44399
44450
  })]
44400
- }, `${e.field ?? e.label}-${r}`)) : i ? /* @__PURE__ */ Z("div", {
44451
+ }, `${e.field ?? e.label}-${n}`)) : a ? /* @__PURE__ */ Z("div", {
44401
44452
  className: "preview-field-card preview-field-card--description",
44402
44453
  children: [/* @__PURE__ */ X("span", {
44403
44454
  className: "preview-field-card__label",
44404
44455
  children: e.label
44405
44456
  }), /* @__PURE__ */ X("div", {
44406
44457
  className: "preview-field-card__description",
44407
- children: /* @__PURE__ */ X(iM, { raw: n })
44458
+ children: /* @__PURE__ */ X(iM, { raw: r })
44408
44459
  })]
44409
44460
  }, e.field ?? e.label) : /* @__PURE__ */ Z("div", {
44410
44461
  className: "preview-field-card",
@@ -44413,32 +44464,90 @@ function hM({ fields: e, moduleName: t }) {
44413
44464
  children: e.label
44414
44465
  }), /* @__PURE__ */ X("span", {
44415
44466
  className: "preview-field-card__value",
44416
- children: uM(n)
44467
+ children: uM(r)
44417
44468
  })]
44418
44469
  }, e.field ?? e.label);
44419
44470
  })
44420
- }) : null;
44471
+ }), /* @__PURE__ */ X(Lr, {
44472
+ documents: r,
44473
+ open: s,
44474
+ onClose: () => c(!1),
44475
+ initialIndex: a
44476
+ })] });
44421
44477
  }
44422
44478
  function gM() {
44423
- let e = Zo(), { moduleName: t = "", record: n = null } = Xo().state ?? {}, r = n?.id ?? n?._id, [i, a] = R([]), [o, s] = R(!!(t && r)), [c, l] = R(null);
44479
+ let e = Zo(), { moduleName: t = "", record: n = null } = Xo().state ?? {}, r = n?.id ?? n?._id, [i, a] = R([]), [o, s] = R(!!(t && r)), [c, l] = R(null), [u, d] = R([]), [f, p] = R(0), m = ui(null), h = ui([]);
44424
44480
  I(() => {
44425
44481
  if (!t || !r) return;
44426
44482
  let e = !1;
44427
- return yn({
44483
+ return Promise.all([yn({
44428
44484
  module: t,
44429
44485
  id: r
44430
- }).then((t) => {
44431
- e || (a(Array.isArray(t) ? t : []), s(!1));
44486
+ }), Gn(t, r).catch(() => ({ data: [] }))]).then(([t, n]) => {
44487
+ e || (a(Array.isArray(t) ? t : []), d(Array.isArray(n) ? n : n?.data ?? []), s(!1));
44432
44488
  }).catch((t) => {
44433
- e || (l(t.message || "Failed to load preview"), s(!1));
44489
+ e || (l(t.message || "Failed to load preview"), d([]), s(!1));
44434
44490
  }), () => {
44435
44491
  e = !0;
44436
44492
  };
44437
44493
  }, [t, r]);
44438
- function u() {
44494
+ function g() {
44439
44495
  e(-1);
44440
44496
  }
44441
- let d = /* @__PURE__ */ Z("div", {
44497
+ function _(e, t) {
44498
+ return e?.label ?? e?.name ?? `Section ${t + 1}`;
44499
+ }
44500
+ function v(e) {
44501
+ let t = m.current, n = h.current[e];
44502
+ if (!t || !n) return;
44503
+ let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a = (t.querySelector(".preview-stepper-wrap")?.offsetHeight ?? 0) + 12, o = t.scrollTop + i.top - r.top - a;
44504
+ p(e), t.scrollTo({
44505
+ top: Math.max(0, o),
44506
+ behavior: "smooth"
44507
+ });
44508
+ }
44509
+ function y() {
44510
+ let e = m.current;
44511
+ if (!e || !h.current.length) return;
44512
+ let t = e.getBoundingClientRect().top + (e.querySelector(".preview-stepper-wrap")?.offsetHeight ?? 0) + 24, n = 0;
44513
+ h.current.forEach((e, r) => {
44514
+ e && e.getBoundingClientRect().top <= t && (n = r);
44515
+ }), p((e) => e === n ? e : n);
44516
+ }
44517
+ function b() {
44518
+ return i.length ? /* @__PURE__ */ X("div", {
44519
+ className: "preview-stepper-wrap",
44520
+ "aria-label": "Preview sections",
44521
+ children: /* @__PURE__ */ X("div", {
44522
+ className: "preview-stepper",
44523
+ children: i.map((e, t) => /* @__PURE__ */ Z("div", {
44524
+ className: "preview-stepper__segment",
44525
+ children: [/* @__PURE__ */ Z("button", {
44526
+ type: "button",
44527
+ className: "preview-stepper__item",
44528
+ onClick: () => v(t),
44529
+ "aria-current": f === t ? "step" : void 0,
44530
+ title: `Go to ${_(e, t)}`,
44531
+ children: [/* @__PURE__ */ X("span", {
44532
+ className: [
44533
+ "preview-stepper__circle",
44534
+ t < f ? "preview-stepper__circle--done" : "",
44535
+ t === f ? "preview-stepper__circle--active" : ""
44536
+ ].filter(Boolean).join(" "),
44537
+ children: t + 1
44538
+ }), /* @__PURE__ */ X("span", {
44539
+ className: ["preview-stepper__label", t === f ? "preview-stepper__label--active" : ""].filter(Boolean).join(" "),
44540
+ children: _(e, t)
44541
+ })]
44542
+ }), t < i.length - 1 && /* @__PURE__ */ X("span", {
44543
+ className: ["preview-stepper__line", t < f ? "preview-stepper__line--done" : ""].filter(Boolean).join(" "),
44544
+ "aria-hidden": "true"
44545
+ })]
44546
+ }, e.name ?? e.id ?? t))
44547
+ })
44548
+ }) : null;
44549
+ }
44550
+ let x = /* @__PURE__ */ Z("div", {
44442
44551
  className: "preview-modal-header",
44443
44552
  children: [/* @__PURE__ */ X("span", {
44444
44553
  className: "preview-modal-module",
@@ -44447,17 +44556,17 @@ function gM() {
44447
44556
  className: "preview-modal-title",
44448
44557
  children: t ? " Details" : "Preview"
44449
44558
  })]
44450
- }), f = /* @__PURE__ */ X("div", {
44559
+ }), S = /* @__PURE__ */ X("div", {
44451
44560
  className: "wizard-footer preview-scroll-footer",
44452
44561
  children: /* @__PURE__ */ X("div", {
44453
44562
  className: "wizard-footer-nav",
44454
44563
  children: /* @__PURE__ */ X(z, {
44455
- onClick: u,
44564
+ onClick: g,
44456
44565
  children: "Close"
44457
44566
  })
44458
44567
  })
44459
44568
  });
44460
- function p() {
44569
+ function C() {
44461
44570
  return !t || !r ? /* @__PURE__ */ X("div", {
44462
44571
  className: "job-preview-content job-preview-status",
44463
44572
  children: "Preview id is missing."
@@ -44470,7 +44579,11 @@ function gM() {
44470
44579
  }) : i.length ? /* @__PURE__ */ X("div", {
44471
44580
  className: "preview-section-list",
44472
44581
  children: i.map((e, n) => /* @__PURE__ */ Z("section", {
44582
+ ref: (e) => {
44583
+ h.current[n] = e;
44584
+ },
44473
44585
  className: "preview-section-card",
44586
+ "data-section-index": n,
44474
44587
  children: [/* @__PURE__ */ Z("div", {
44475
44588
  className: "preview-section-card__header",
44476
44589
  children: [/* @__PURE__ */ X("span", {
@@ -44478,13 +44591,14 @@ function gM() {
44478
44591
  children: n + 1
44479
44592
  }), /* @__PURE__ */ X("span", {
44480
44593
  className: "preview-section-card__title",
44481
- children: e.label ?? e.name ?? `Section ${n + 1}`
44594
+ children: _(e, n)
44482
44595
  })]
44483
44596
  }), /* @__PURE__ */ X("div", {
44484
44597
  className: "preview-section-card__body",
44485
44598
  children: e.fields?.length > 0 ? /* @__PURE__ */ X(hM, {
44486
44599
  fields: e.fields,
44487
- moduleName: t
44600
+ moduleName: t,
44601
+ centralDocuments: u
44488
44602
  }) : /* @__PURE__ */ X(aM, {
44489
44603
  type: "secondary",
44490
44604
  children: "No fields in this group."
@@ -44499,15 +44613,21 @@ function gM() {
44499
44613
  return /* @__PURE__ */ X(ki, {
44500
44614
  centered: !0,
44501
44615
  className: "wizard-modal preview-modal preview-scroll-modal",
44502
- footer: f,
44616
+ footer: S,
44503
44617
  open: !0,
44504
- title: d,
44618
+ title: x,
44505
44619
  width: "min(900px, calc(100vw - 32px))",
44506
- onCancel: u,
44620
+ onCancel: g,
44507
44621
  maskClosable: !1,
44508
44622
  children: /* @__PURE__ */ Z("div", {
44623
+ ref: m,
44509
44624
  className: "wizard-body preview-scroll-body",
44510
- children: [n && /* @__PURE__ */ X(mM, { record: n }), p()]
44625
+ onScroll: y,
44626
+ children: [
44627
+ !o && !c && i.length > 0 && b(),
44628
+ n && /* @__PURE__ */ X(mM, { record: n }),
44629
+ C()
44630
+ ]
44511
44631
  })
44512
44632
  });
44513
44633
  }