@realtek/core-theme 0.0.297 → 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
  }
@@ -46808,38 +46928,17 @@ async function WP(e) {
46808
46928
  }).toString()}`);
46809
46929
  return t.data ?? t;
46810
46930
  }
46811
- async function GP(t) {
46812
- let n = p();
46813
- if (!n) {
46814
- let e = /* @__PURE__ */ Error("Authentication required");
46815
- throw e.status = 401, e;
46816
- }
46817
- let r = new FormData();
46818
- r.append("json", JSON.stringify(t));
46819
- let i = await fetch(`${e}/send-mail-client-doc`, {
46820
- method: "POST",
46821
- headers: { Authorization: `Bearer ${n}` },
46822
- body: r
46823
- });
46824
- i.status === 401 && m();
46825
- let a = await i.json().catch(() => ({}));
46826
- if (!i.ok || a?.status === !1) {
46827
- let e = Error(a?.message ?? a?.error ?? `API ${i.status}: ${i.statusText}`);
46828
- throw e.status = i.status, e;
46829
- }
46830
- return a.data ?? a;
46831
- }
46832
46931
  //#endregion
46833
46932
  //#region src/components/popups/definitions/manager-approve/ManagerApproveBody.jsx
46834
- function KP(...e) {
46933
+ function GP(...e) {
46835
46934
  return e.map((e) => e == null ? "" : String(e).trim()).find(Boolean) ?? "";
46836
46935
  }
46837
- var qP = (e, t) => !!e && e.toLowerCase() === KP(t).toLowerCase();
46838
- function JP(e, t, n) {
46839
- let r = KP(t.submittedBy);
46840
- return KP(qP(r, n) || qP(r, e.submitSource) || qP(r, e.supplierName) || qP(r, e.source) || qP(r, e.candidateSource) ? "" : r, e.signatureEmail);
46936
+ var KP = (e, t) => !!e && e.toLowerCase() === GP(t).toLowerCase();
46937
+ function qP(e, t, n) {
46938
+ let r = GP(t.submittedBy);
46939
+ return GP(KP(r, n) || KP(r, e.submitSource) || KP(r, e.supplierName) || KP(r, e.source) || KP(r, e.candidateSource) ? "" : r, e.signatureEmail);
46841
46940
  }
46842
- function YP(e, t = {}) {
46941
+ function JP(e, t = {}) {
46843
46942
  let n = t.employerName ?? e.supplierName ?? e.submitSource;
46844
46943
  return {
46845
46944
  client: t.clientName ?? e.clientName,
@@ -46848,15 +46947,46 @@ function YP(e, t = {}) {
46848
46947
  name: t.candidateName || [e.firstName, e.lastName].filter(Boolean).join(" ") || e.candidateFullName,
46849
46948
  location: t.jobLocation ?? e.city ?? e.currentLocation ?? e.jobLocation,
46850
46949
  vendor: n,
46851
- submittedBy: JP(e, t, n),
46950
+ submittedBy: qP(e, t, n),
46852
46951
  submittedAt: t.createdAt ?? e.createdAt,
46853
46952
  email: t.email ?? e.email,
46854
46953
  employerLocation: t.employerLocation,
46855
46954
  employerName: t.employerName
46856
46955
  };
46857
46956
  }
46858
- function XP(e) {
46859
- return xj(e).map((e) => ({ email: e }));
46957
+ function YP(e) {
46958
+ let t = e?.$oid ?? e?._id?.$oid ?? e?._id ?? e?.id?.$oid ?? e?.id ?? e;
46959
+ if (t == null || typeof t == "object") return "";
46960
+ let n = String(t).trim();
46961
+ return /^[a-f\d]{24}$/i.test(n) ? n : "";
46962
+ }
46963
+ function XP(...e) {
46964
+ for (let t of e) {
46965
+ let e = [
46966
+ t?.jobId,
46967
+ t?.JobId,
46968
+ t?.job_id,
46969
+ t?.jobDetails?._id,
46970
+ t?.jobDetails?.id,
46971
+ t?.job?._id,
46972
+ t?.job?.id,
46973
+ t?.submission?.jobId,
46974
+ t?.submission?.JobId,
46975
+ t?.submission?.job_id,
46976
+ t?.submission?.jobDetails?._id,
46977
+ t?.submission?.jobDetails?.id,
46978
+ t?.submission?.job?._id,
46979
+ t?.submission?.job?.id,
46980
+ t?.recordMeta?.jobId,
46981
+ t?.recordMeta?.JobId,
46982
+ t?.recordMeta?.job_id,
46983
+ t?.submission?.recordMeta?.jobId,
46984
+ t?.submission?.recordMeta?.JobId,
46985
+ t?.submission?.recordMeta?.job_id
46986
+ ].map(YP).find(Boolean);
46987
+ if (e) return e;
46988
+ }
46989
+ return "";
46860
46990
  }
46861
46991
  function ZP(e) {
46862
46992
  if (!e?.referralId) return {};
@@ -46972,21 +47102,26 @@ function $P({ context: e, selectedIds: t, selectedRecords: n, moduleName: r, onC
46972
47102
  candidateProposedRateUnit: _.rateUnit
46973
47103
  };
46974
47104
  try {
46975
- await GP({
46976
- submissionId: o,
46977
- to: XP(k.to),
46978
- cc: XP(k.cc),
46979
- bcc: XP(k.bcc),
46980
- subject: k.subject || null,
46981
- content: {
46982
- type: "text/html",
46983
- value: k.contents || null
46984
- }
46985
- }), await Qs(o, {
47105
+ await Qs(o, {
46986
47106
  ...e,
46987
47107
  submitVia: "VMS",
46988
47108
  ...ZP(y)
46989
- }), J.success("Approval mail sent and submission approved"), w(!1), v(null), b(null), i?.({ success: !0 });
47109
+ });
47110
+ let t = XP(s?.record, a);
47111
+ if (!t) J.warning("Submission approved, but job details were not available to send mail");
47112
+ else try {
47113
+ await Yl({
47114
+ jobId: t,
47115
+ toMail: xj(k.to),
47116
+ ccMail: xj(k.cc),
47117
+ bccMail: xj(k.bcc),
47118
+ subject: k.subject,
47119
+ contents: k.contents
47120
+ }), J.success("Approval mail sent and submission approved");
47121
+ } catch (e) {
47122
+ J.warning(e?.message ? `Submission approved, but mail was not sent: ${e.message}` : "Submission approved, but mail was not sent");
47123
+ }
47124
+ w(!1), v(null), b(null), i?.({ success: !0 });
46990
47125
  } catch (e) {
46991
47126
  J.error(e?.message ?? "Unable to send approval mail");
46992
47127
  } finally {
@@ -47025,7 +47160,7 @@ function $P({ context: e, selectedIds: t, selectedRecords: n, moduleName: r, onC
47025
47160
  type: HS,
47026
47161
  record: s.record,
47027
47162
  lookups: s.lookups,
47028
- identity: YP(a, s.display),
47163
+ identity: JP(a, s.display),
47029
47164
  referralOptions: d,
47030
47165
  currentUserId: typeof localStorage < "u" ? localStorage.getItem("userId") ?? void 0 : void 0,
47031
47166
  actions: te,