@frontify/guideline-blocks-settings 0.34.6 → 0.34.8

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.
@@ -1,60 +1,65 @@
1
- import { jsx as i, Fragment as k } from "react/jsx-runtime";
2
- import { useState as r, useEffect as m } from "react";
3
- import { DocumentLink as x } from "./DocumentLink.es.js";
4
- import { LoadingIndicator as A } from "./LoadingIndicator.es.js";
5
- const q = ({
6
- selectedUrl: t,
1
+ import { jsx as s, Fragment as x } from "react/jsx-runtime";
2
+ import { useState as d, useEffect as m } from "react";
3
+ import { filterDocumentSectionsWithUnreadableTitles as v } from "../helpers/filterDocumentSectionsWithUnreadableTitles.es.js";
4
+ import { LoadingIndicator as E } from "./LoadingIndicator.es.js";
5
+ import { DocumentLink as S } from "./DocumentLink.es.js";
6
+ const O = ({
7
+ selectedUrl: n,
7
8
  onSelectUrl: f,
8
9
  getAllDocuments: l,
9
- getDocumentPagesByDocumentId: a,
10
- getDocumentSectionsByDocumentPageId: c
10
+ getDocumentPagesByDocumentId: r,
11
+ getDocumentSectionsByDocumentPageId: a
11
12
  }) => {
12
- const [p, u] = r(!0), [I, g] = r([]), [L, v] = r({
13
+ const [p, u] = d(!0), [e, I] = d([]), [g, L] = d({
13
14
  documentId: void 0,
14
15
  pageId: void 0
15
- }), e = [...I.values()];
16
+ });
16
17
  m(() => {
17
- t && e.length > 0 && y().then((n) => {
18
- v(n);
18
+ n && e.length > 0 && h().then((t) => {
19
+ L(t);
19
20
  });
20
21
  }, [e.length]), m(() => {
21
- l().then((n) => {
22
- g(n);
22
+ l().then((t) => {
23
+ I(t);
23
24
  }).finally(() => {
24
25
  u(!1);
25
26
  });
26
27
  }, []);
27
- const y = async () => {
28
- const n = {
28
+ const h = async () => {
29
+ const t = {
29
30
  documentId: void 0,
30
31
  pageId: void 0
31
32
  };
32
- if (e.find((o) => o.permanentLink === t))
33
- return n;
34
- for (const o of e) {
35
- const d = [...(await a(o.id)).values()];
36
- if (!!d.find((s) => s.permanentLink === t))
37
- return n.documentId = o.id, n;
38
- for (const s of d)
39
- if (!![...(await c(s.id)).values()].find((h) => h.permanentLink === t))
40
- return n.documentId = o.id, n.pageId = s.id, n;
33
+ if (e.find((i) => i.permanentLink === n))
34
+ return t;
35
+ for (const i of e) {
36
+ const c = await r(i.id);
37
+ if (!!c.find((o) => o.permanentLink === n))
38
+ return t.documentId = i.id, t;
39
+ for (const o of c) {
40
+ const T = await a(o.id);
41
+ if (!!v(T).find(
42
+ (k) => k.permanentLink === n
43
+ ))
44
+ return t.documentId = i.id, t.pageId = o.id, t;
45
+ }
41
46
  }
42
- return n;
47
+ return t;
43
48
  };
44
- return p ? /* @__PURE__ */ i(A, {}) : /* @__PURE__ */ i(k, { children: e.map((n) => /* @__PURE__ */ i(
45
- x,
49
+ return p ? /* @__PURE__ */ s(E, {}) : /* @__PURE__ */ s(x, { children: e.map((t) => /* @__PURE__ */ s(
50
+ S,
46
51
  {
47
- document: n,
48
- selectedUrl: t,
52
+ document: t,
53
+ selectedUrl: n,
49
54
  onSelectUrl: f,
50
- itemsToExpandInitially: L,
51
- getDocumentSectionsByDocumentPageId: c,
52
- getDocumentPagesByDocumentId: a
55
+ itemsToExpandInitially: g,
56
+ getDocumentSectionsByDocumentPageId: a,
57
+ getDocumentPagesByDocumentId: r
53
58
  },
54
- n.id
59
+ t.id
55
60
  )) });
56
61
  };
57
62
  export {
58
- q as DocumentLinks
63
+ O as DocumentLinks
59
64
  };
60
65
  //# sourceMappingURL=DocumentLinks.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DocumentLinks.es.js","sources":["../../../../src/components/Link/LinkSelector/DocumentLinks.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport type { Document, DocumentPage, DocumentSection } from '@frontify/app-bridge';\nimport { ReactElement, useEffect, useState } from 'react';\nimport { DocumentLink } from './DocumentLink';\nimport { LoadingIndicator } from './LoadingIndicator';\nimport { InitiallyExpandedItems } from '../';\n\ntype DocumentLinksProps = {\n selectedUrl: string;\n onSelectUrl: (url: string) => void;\n getAllDocuments: () => Promise<Document[]>;\n getDocumentSectionsByDocumentPageId: (documentPageId: number) => Promise<DocumentSection[]>;\n getDocumentPagesByDocumentId: (documentId: number) => Promise<DocumentPage[]>;\n};\n\nexport const DocumentLinks = ({\n selectedUrl,\n onSelectUrl,\n getAllDocuments,\n getDocumentPagesByDocumentId,\n getDocumentSectionsByDocumentPageId,\n}: DocumentLinksProps): ReactElement => {\n const [isLoading, setIsLoading] = useState(true);\n const [documents, setDocuments] = useState<Document[]>([]);\n const [itemsToExpandInitially, setItemsToExpandInitially] = useState<InitiallyExpandedItems>({\n documentId: undefined,\n pageId: undefined,\n });\n\n const documentArray = [...documents.values()];\n\n useEffect(() => {\n if (selectedUrl && documentArray.length > 0) {\n findLocationOfSelectedUrl().then((items) => {\n setItemsToExpandInitially(items);\n });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [documentArray.length]);\n\n useEffect(() => {\n getAllDocuments()\n .then((_documents) => {\n setDocuments(_documents);\n })\n .finally(() => {\n setIsLoading(false);\n });\n }, []);\n\n const findLocationOfSelectedUrl = async () => {\n const itemsToExpand: InitiallyExpandedItems = {\n documentId: undefined,\n pageId: undefined,\n };\n const selectedUrlIsDocument = documentArray.find((document) => document.permanentLink === selectedUrl);\n if (selectedUrlIsDocument) {\n return itemsToExpand;\n }\n for (const document of documentArray) {\n const pages = await getDocumentPagesByDocumentId(document.id);\n const pagesArray = [...pages.values()];\n const selectedUrlIsPage = !!pagesArray.find((page) => page.permanentLink === selectedUrl);\n if (selectedUrlIsPage) {\n itemsToExpand.documentId = document.id;\n return itemsToExpand;\n }\n for (const page of pagesArray) {\n const sections = await getDocumentSectionsByDocumentPageId(page.id);\n const sectionsArray = [...sections.values()];\n const selectedUrlIsSection = !!sectionsArray.find((section) => section.permanentLink === selectedUrl);\n if (selectedUrlIsSection) {\n itemsToExpand.documentId = document.id;\n itemsToExpand.pageId = page.id;\n return itemsToExpand;\n }\n }\n }\n return itemsToExpand;\n };\n\n return isLoading ? (\n <LoadingIndicator />\n ) : (\n <>\n {documentArray.map((document) => {\n return (\n <DocumentLink\n key={document.id}\n document={document}\n selectedUrl={selectedUrl}\n onSelectUrl={onSelectUrl}\n itemsToExpandInitially={itemsToExpandInitially}\n getDocumentSectionsByDocumentPageId={getDocumentSectionsByDocumentPageId}\n getDocumentPagesByDocumentId={getDocumentPagesByDocumentId}\n />\n );\n })}\n </>\n );\n};\n"],"names":["DocumentLinks","selectedUrl","onSelectUrl","getAllDocuments","getDocumentPagesByDocumentId","getDocumentSectionsByDocumentPageId","isLoading","setIsLoading","useState","documents","setDocuments","itemsToExpandInitially","setItemsToExpandInitially","documentArray","useEffect","findLocationOfSelectedUrl","items","_documents","itemsToExpand","document","pagesArray","page","section","LoadingIndicator","jsx","DocumentLink"],"mappings":";;;;AAgBO,MAAMA,IAAgB,CAAC;AAAA,EAC1B,aAAAC;AAAA,EACA,aAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,8BAAAC;AAAA,EACA,qCAAAC;AACJ,MAAwC;AACpC,QAAM,CAACC,GAAWC,CAAY,IAAIC,EAAS,EAAI,GACzC,CAACC,GAAWC,CAAY,IAAIF,EAAqB,CAAE,CAAA,GACnD,CAACG,GAAwBC,CAAyB,IAAIJ,EAAiC;AAAA,IACzF,YAAY;AAAA,IACZ,QAAQ;AAAA,EAAA,CACX,GAEKK,IAAgB,CAAC,GAAGJ,EAAU,OAAQ,CAAA;AAE5C,EAAAK,EAAU,MAAM;AACR,IAAAb,KAAeY,EAAc,SAAS,KACZE,EAAA,EAAE,KAAK,CAACC,MAAU;AACxC,MAAAJ,EAA0BI,CAAK;AAAA,IAAA,CAClC;AAAA,EACL,GAED,CAACH,EAAc,MAAM,CAAC,GAEzBC,EAAU,MAAM;AACI,IAAAX,EAAA,EACX,KAAK,CAACc,MAAe;AAClB,MAAAP,EAAaO,CAAU;AAAA,IAAA,CAC1B,EACA,QAAQ,MAAM;AACX,MAAAV,EAAa,EAAK;AAAA,IAAA,CACrB;AAAA,EACT,GAAG,CAAE,CAAA;AAEL,QAAMQ,IAA4B,YAAY;AAC1C,UAAMG,IAAwC;AAAA,MAC1C,YAAY;AAAA,MACZ,QAAQ;AAAA,IAAA;AAGZ,QAD8BL,EAAc,KAAK,CAACM,MAAaA,EAAS,kBAAkBlB,CAAW;AAE1F,aAAAiB;AAEX,eAAWC,KAAYN,GAAe;AAElC,YAAMO,IAAa,CAAC,IADN,MAAMhB,EAA6Be,EAAS,EAAE,GAC/B,OAAQ,CAAA;AAErC,UAD0B,CAAC,CAACC,EAAW,KAAK,CAACC,MAASA,EAAK,kBAAkBpB,CAAW;AAEpF,eAAAiB,EAAc,aAAaC,EAAS,IAC7BD;AAEX,iBAAWG,KAAQD;AAIf,YAD6B,CAAC,CADR,CAAC,IADN,MAAMf,EAAoCgB,EAAK,EAAE,GAC/B,OAAQ,CAAA,EACE,KAAK,CAACC,MAAYA,EAAQ,kBAAkBrB,CAAW;AAEhG,iBAAAiB,EAAc,aAAaC,EAAS,IACpCD,EAAc,SAASG,EAAK,IACrBH;AAAA,IAGnB;AACO,WAAAA;AAAA,EAAA;AAGJ,SAAAZ,sBACFiB,GAAiB,CAAA,CAAA,2BAGb,UAAcV,EAAA,IAAI,CAACM,MAEZ,gBAAAK;AAAA,IAACC;AAAA,IAAA;AAAA,MAEG,UAAAN;AAAA,MACA,aAAAlB;AAAA,MACA,aAAAC;AAAA,MACA,wBAAAS;AAAA,MACA,qCAAAN;AAAA,MACA,8BAAAD;AAAA,IAAA;AAAA,IANKe,EAAS;AAAA,EAAA,CASzB,EACL,CAAA;AAER;"}
1
+ {"version":3,"file":"DocumentLinks.es.js","sources":["../../../../src/components/Link/LinkSelector/DocumentLinks.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { type Document, type DocumentPage, type DocumentSection } from '@frontify/app-bridge';\nimport { ReactElement, useEffect, useState } from 'react';\n\nimport { filterDocumentSectionsWithUnreadableTitles } from '../helpers/filterDocumentSectionsWithUnreadableTitles';\nimport { InitiallyExpandedItems } from '../';\n\nimport { LoadingIndicator } from './LoadingIndicator';\nimport { DocumentLink } from './DocumentLink';\n\ntype DocumentLinksProps = {\n selectedUrl: string;\n onSelectUrl: (url: string) => void;\n getAllDocuments: () => Promise<Document[]>;\n getDocumentSectionsByDocumentPageId: (documentPageId: number) => Promise<DocumentSection[]>;\n getDocumentPagesByDocumentId: (documentId: number) => Promise<DocumentPage[]>;\n};\n\nexport const DocumentLinks = ({\n selectedUrl,\n onSelectUrl,\n getAllDocuments,\n getDocumentPagesByDocumentId,\n getDocumentSectionsByDocumentPageId,\n}: DocumentLinksProps): ReactElement => {\n const [isLoading, setIsLoading] = useState(true);\n const [documents, setDocuments] = useState<Document[]>([]);\n const [itemsToExpandInitially, setItemsToExpandInitially] = useState<InitiallyExpandedItems>({\n documentId: undefined,\n pageId: undefined,\n });\n\n useEffect(() => {\n if (selectedUrl && documents.length > 0) {\n findLocationOfSelectedUrl().then((items) => {\n setItemsToExpandInitially(items);\n });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [documents.length]);\n\n useEffect(() => {\n getAllDocuments()\n .then((_documents) => {\n setDocuments(_documents);\n })\n .finally(() => {\n setIsLoading(false);\n });\n }, []);\n\n const findLocationOfSelectedUrl = async () => {\n const itemsToExpand: InitiallyExpandedItems = {\n documentId: undefined,\n pageId: undefined,\n };\n const selectedUrlIsDocument = documents.find((document) => document.permanentLink === selectedUrl);\n if (selectedUrlIsDocument) {\n return itemsToExpand;\n }\n for (const document of documents) {\n const pages = await getDocumentPagesByDocumentId(document.id);\n const selectedUrlIsPage = !!pages.find((page) => page.permanentLink === selectedUrl);\n if (selectedUrlIsPage) {\n itemsToExpand.documentId = document.id;\n return itemsToExpand;\n }\n for (const page of pages) {\n const sections = await getDocumentSectionsByDocumentPageId(page.id);\n const sectionsWithReadableTitles = filterDocumentSectionsWithUnreadableTitles(sections);\n const selectedUrlIsSection = !!sectionsWithReadableTitles.find(\n (section) => section.permanentLink === selectedUrl,\n );\n if (selectedUrlIsSection) {\n itemsToExpand.documentId = document.id;\n itemsToExpand.pageId = page.id;\n return itemsToExpand;\n }\n }\n }\n return itemsToExpand;\n };\n\n return isLoading ? (\n <LoadingIndicator />\n ) : (\n <>\n {documents.map((document) => {\n return (\n <DocumentLink\n key={document.id}\n document={document}\n selectedUrl={selectedUrl}\n onSelectUrl={onSelectUrl}\n itemsToExpandInitially={itemsToExpandInitially}\n getDocumentSectionsByDocumentPageId={getDocumentSectionsByDocumentPageId}\n getDocumentPagesByDocumentId={getDocumentPagesByDocumentId}\n />\n );\n })}\n </>\n );\n};\n"],"names":["DocumentLinks","selectedUrl","onSelectUrl","getAllDocuments","getDocumentPagesByDocumentId","getDocumentSectionsByDocumentPageId","isLoading","setIsLoading","useState","documents","setDocuments","itemsToExpandInitially","setItemsToExpandInitially","useEffect","findLocationOfSelectedUrl","items","_documents","itemsToExpand","document","pages","page","sections","filterDocumentSectionsWithUnreadableTitles","section","LoadingIndicator","jsx","DocumentLink"],"mappings":";;;;;AAmBO,MAAMA,IAAgB,CAAC;AAAA,EAC1B,aAAAC;AAAA,EACA,aAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,8BAAAC;AAAA,EACA,qCAAAC;AACJ,MAAwC;AACpC,QAAM,CAACC,GAAWC,CAAY,IAAIC,EAAS,EAAI,GACzC,CAACC,GAAWC,CAAY,IAAIF,EAAqB,CAAE,CAAA,GACnD,CAACG,GAAwBC,CAAyB,IAAIJ,EAAiC;AAAA,IACzF,YAAY;AAAA,IACZ,QAAQ;AAAA,EAAA,CACX;AAED,EAAAK,EAAU,MAAM;AACR,IAAAZ,KAAeQ,EAAU,SAAS,KACRK,EAAA,EAAE,KAAK,CAACC,MAAU;AACxC,MAAAH,EAA0BG,CAAK;AAAA,IAAA,CAClC;AAAA,EACL,GAED,CAACN,EAAU,MAAM,CAAC,GAErBI,EAAU,MAAM;AACI,IAAAV,EAAA,EACX,KAAK,CAACa,MAAe;AAClB,MAAAN,EAAaM,CAAU;AAAA,IAAA,CAC1B,EACA,QAAQ,MAAM;AACX,MAAAT,EAAa,EAAK;AAAA,IAAA,CACrB;AAAA,EACT,GAAG,CAAE,CAAA;AAEL,QAAMO,IAA4B,YAAY;AAC1C,UAAMG,IAAwC;AAAA,MAC1C,YAAY;AAAA,MACZ,QAAQ;AAAA,IAAA;AAGZ,QAD8BR,EAAU,KAAK,CAACS,MAAaA,EAAS,kBAAkBjB,CAAW;AAEtF,aAAAgB;AAEX,eAAWC,KAAYT,GAAW;AAC9B,YAAMU,IAAQ,MAAMf,EAA6Bc,EAAS,EAAE;AAE5D,UAD0B,CAAC,CAACC,EAAM,KAAK,CAACC,MAASA,EAAK,kBAAkBnB,CAAW;AAE/E,eAAAgB,EAAc,aAAaC,EAAS,IAC7BD;AAEX,iBAAWG,KAAQD,GAAO;AACtB,cAAME,IAAW,MAAMhB,EAAoCe,EAAK,EAAE;AAKlE,YAH6B,CAAC,CADKE,EAA2CD,CAAQ,EAC5B;AAAA,UACtD,CAACE,MAAYA,EAAQ,kBAAkBtB;AAAA,QAAA;AAGvC,iBAAAgB,EAAc,aAAaC,EAAS,IACpCD,EAAc,SAASG,EAAK,IACrBH;AAAA,MAEf;AAAA,IACJ;AACO,WAAAA;AAAA,EAAA;AAGJ,SAAAX,sBACFkB,GAAiB,CAAA,CAAA,2BAGb,UAAUf,EAAA,IAAI,CAACS,MAER,gBAAAO;AAAA,IAACC;AAAA,IAAA;AAAA,MAEG,UAAAR;AAAA,MACA,aAAAjB;AAAA,MACA,aAAAC;AAAA,MACA,wBAAAS;AAAA,MACA,qCAAAN;AAAA,MACA,8BAAAD;AAAA,IAAA;AAAA,IANKc,EAAS;AAAA,EAAA,CASzB,EACL,CAAA;AAER;"}
@@ -2,23 +2,24 @@ import { jsxs as d, Fragment as v, jsx as e } from "react/jsx-runtime";
2
2
  import { merge as m } from "@frontify/fondue";
3
3
  import { useState as h, useEffect as x } from "react";
4
4
  import { SectionLink as g } from "./SectionLink.es.js";
5
- const j = ({
5
+ import { filterDocumentSectionsWithUnreadableTitles as k } from "../helpers/filterDocumentSectionsWithUnreadableTitles.es.js";
6
+ const D = ({
6
7
  page: t,
7
8
  selectedUrl: i,
8
- onSelectUrl: w,
9
+ onSelectUrl: c,
9
10
  itemsToExpandInitially: r,
10
- getDocumentSectionsByDocumentPageId: c
11
+ getDocumentSectionsByDocumentPageId: w
11
12
  }) => {
12
- const [n, a] = h(t.id === r.documentId), [b, f] = h([]), u = t.permanentLink === i;
13
+ const [n, a] = h(t.id === r.documentId), [o, b] = h([]), f = t.permanentLink === i;
13
14
  x(() => {
14
15
  (async () => {
15
- const p = await c(t.id);
16
- f(p);
16
+ const p = await w(t.id), u = k(p);
17
+ b(u);
17
18
  })();
18
- }, [t.id, c]), x(() => {
19
+ }, [t.id, w]), x(() => {
19
20
  t.id === r.pageId && a(!0);
20
21
  }, [r, t.id]);
21
- const s = [...b.values()], l = s.length > 0;
22
+ const l = o.length > 0;
22
23
  return /* @__PURE__ */ d(v, { children: [
23
24
  /* @__PURE__ */ e(
24
25
  "button",
@@ -27,9 +28,9 @@ const j = ({
27
28
  className: m([
28
29
  "tw-py-2 tw-pr-2.5 tw-leading-5 tw-cursor-pointer tw-flex tw-w-full",
29
30
  l ? "tw-pl-7" : "tw-pl-12",
30
- u ? "tw-bg-box-selected-strong tw-text-box-selected-strong-inverse hover:tw-bg-box-selected-strong-hover:hover hover:tw-text-box-selected-strong-inverse-hover:hover" : "hover:tw-bg-box-neutral-hover hover:tw-text-box-neutral-inverse-hover"
31
+ f ? "tw-bg-box-selected-strong tw-text-box-selected-strong-inverse hover:tw-bg-box-selected-strong-hover:hover hover:tw-text-box-selected-strong-inverse-hover:hover" : "hover:tw-bg-box-neutral-hover hover:tw-text-box-neutral-inverse-hover"
31
32
  ]),
32
- onClick: () => w(t.permanentLink),
33
+ onClick: () => c(t.permanentLink),
33
34
  children: /* @__PURE__ */ d("div", { className: "tw-flex tw-flex-1 tw-space-x-1 tw-items-center tw-h-6", children: [
34
35
  l && /* @__PURE__ */ e(
35
36
  "button",
@@ -53,18 +54,18 @@ const j = ({
53
54
  ] }, t.id)
54
55
  }
55
56
  ),
56
- n && s.length > 0 && s.map((o) => /* @__PURE__ */ e(
57
+ n && o.length > 0 && o.map((s) => /* @__PURE__ */ e(
57
58
  g,
58
59
  {
59
- section: o,
60
+ section: s,
60
61
  selectedUrl: i,
61
- onSelectUrl: w
62
+ onSelectUrl: c
62
63
  },
63
- o.id
64
+ s.id
64
65
  ))
65
66
  ] });
66
67
  };
67
68
  export {
68
- j as PageLink
69
+ D as PageLink
69
70
  };
70
71
  //# sourceMappingURL=PageLink.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PageLink.es.js","sources":["../../../../src/components/Link/LinkSelector/PageLink.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { type DocumentSection } from '@frontify/app-bridge';\nimport { merge } from '@frontify/fondue';\nimport { useEffect, useState } from 'react';\nimport { InitiallyExpandedItems } from '../';\nimport { SectionLink } from './SectionLink';\n\ntype PageLinkProps = {\n page: {\n id: number;\n title: string;\n permanentLink: string;\n };\n selectedUrl: string;\n onSelectUrl: (url: string) => void;\n itemsToExpandInitially: InitiallyExpandedItems;\n getDocumentSectionsByDocumentPageId: (documentPageId: number) => Promise<DocumentSection[]>;\n};\n\nexport const PageLink = ({\n page,\n selectedUrl,\n onSelectUrl,\n itemsToExpandInitially,\n getDocumentSectionsByDocumentPageId,\n}: PageLinkProps) => {\n const [isExpanded, setIsExpanded] = useState(page.id === itemsToExpandInitially.documentId);\n const [documentSections, setDocumentSections] = useState<DocumentSection[]>([]);\n const isActive = page.permanentLink === selectedUrl;\n\n useEffect(() => {\n const fetchDocumentSections = async () => {\n const sections = await getDocumentSectionsByDocumentPageId(page.id);\n setDocumentSections(sections);\n };\n\n fetchDocumentSections();\n }, [page.id, getDocumentSectionsByDocumentPageId]);\n\n useEffect(() => {\n if (page.id === itemsToExpandInitially.pageId) {\n setIsExpanded(true);\n }\n }, [itemsToExpandInitially, page.id]);\n\n const sectionsArray = [...documentSections.values()];\n const hasSections = sectionsArray.length > 0;\n\n return (\n <>\n <button\n data-test-id=\"internal-link-selector-page-link\"\n className={merge([\n 'tw-py-2 tw-pr-2.5 tw-leading-5 tw-cursor-pointer tw-flex tw-w-full',\n hasSections ? 'tw-pl-7' : 'tw-pl-12',\n isActive\n ? 'tw-bg-box-selected-strong tw-text-box-selected-strong-inverse hover:tw-bg-box-selected-strong-hover:hover hover:tw-text-box-selected-strong-inverse-hover:hover'\n : 'hover:tw-bg-box-neutral-hover hover:tw-text-box-neutral-inverse-hover',\n ])}\n onClick={() => onSelectUrl(page.permanentLink)}\n >\n <div key={page.id} className=\"tw-flex tw-flex-1 tw-space-x-1 tw-items-center tw-h-6\">\n {hasSections && (\n <button\n data-test-id=\"tree-item-toggle\"\n className=\"tw-flex tw-items-center tw-justify-center -tw-mr-2 tw-pr-3.5 tw-pt-1.5 tw-pb-1.5 tw-pl-3.5 tw-cursor-pointer\"\n onClick={() => setIsExpanded(!isExpanded)}\n >\n <div\n className={merge([\n 'tw-transition-transform tw-w-0 tw-h-0 tw-font-normal tw-border-t-4 tw-border-t-transparent tw-border-b-4 tw-border-b-transparent tw-border-l-4 tw-border-l-x-strong',\n isExpanded ? 'tw-rotate-90' : '',\n ])}\n ></div>\n </button>\n )}\n <span className=\"tw-text-s\">{page.title}</span>\n <span className=\"tw-flex-auto tw-font-sans tw-text-xs tw-text-right\">Page</span>\n </div>\n </button>\n {isExpanded &&\n sectionsArray.length > 0 &&\n sectionsArray.map((section) => {\n return (\n <SectionLink\n key={section.id}\n section={section}\n selectedUrl={selectedUrl}\n onSelectUrl={onSelectUrl}\n />\n );\n })}\n </>\n );\n};\n"],"names":["PageLink","page","selectedUrl","onSelectUrl","itemsToExpandInitially","getDocumentSectionsByDocumentPageId","isExpanded","setIsExpanded","useState","documentSections","setDocumentSections","isActive","useEffect","sections","sectionsArray","hasSections","jsxs","Fragment","jsx","merge","section","SectionLink"],"mappings":";;;;AAoBO,MAAMA,IAAW,CAAC;AAAA,EACrB,MAAAC;AAAA,EACA,aAAAC;AAAA,EACA,aAAAC;AAAA,EACA,wBAAAC;AAAA,EACA,qCAAAC;AACJ,MAAqB;AACX,QAAA,CAACC,GAAYC,CAAa,IAAIC,EAASP,EAAK,OAAOG,EAAuB,UAAU,GACpF,CAACK,GAAkBC,CAAmB,IAAIF,EAA4B,CAAE,CAAA,GACxEG,IAAWV,EAAK,kBAAkBC;AAExC,EAAAU,EAAU,MAAM;AAMU,KALQ,YAAY;AACtC,YAAMC,IAAW,MAAMR,EAAoCJ,EAAK,EAAE;AAClE,MAAAS,EAAoBG,CAAQ;AAAA,IAAA;EAIjC,GAAA,CAACZ,EAAK,IAAII,CAAmC,CAAC,GAEjDO,EAAU,MAAM;AACR,IAAAX,EAAK,OAAOG,EAAuB,UACnCG,EAAc,EAAI;AAAA,EAEvB,GAAA,CAACH,GAAwBH,EAAK,EAAE,CAAC;AAEpC,QAAMa,IAAgB,CAAC,GAAGL,EAAiB,OAAQ,CAAA,GAC7CM,IAAcD,EAAc,SAAS;AAE3C,SAEQ,gBAAAE,EAAAC,GAAA,EAAA,UAAA;AAAA,IAAA,gBAAAC;AAAA,MAAC;AAAA,MAAA;AAAA,QACG,gBAAa;AAAA,QACb,WAAWC,EAAM;AAAA,UACb;AAAA,UACAJ,IAAc,YAAY;AAAA,UAC1BJ,IACM,oKACA;AAAA,QAAA,CACT;AAAA,QACD,SAAS,MAAMR,EAAYF,EAAK,aAAa;AAAA,QAE7C,UAAA,gBAAAe,EAAC,OAAkB,EAAA,WAAU,yDACxB,UAAA;AAAA,UACGD,KAAA,gBAAAG;AAAA,YAAC;AAAA,YAAA;AAAA,cACG,gBAAa;AAAA,cACb,WAAU;AAAA,cACV,SAAS,MAAMX,EAAc,CAACD,CAAU;AAAA,cAExC,UAAA,gBAAAY;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBACG,WAAWC,EAAM;AAAA,oBACb;AAAA,oBACAb,IAAa,iBAAiB;AAAA,kBAAA,CACjC;AAAA,gBAAA;AAAA,cACJ;AAAA,YAAA;AAAA,UACL;AAAA,UAEH,gBAAAY,EAAA,QAAA,EAAK,WAAU,aAAa,YAAK,OAAM;AAAA,UACvC,gBAAAA,EAAA,QAAA,EAAK,WAAU,sDAAqD,UAAI,QAAA;AAAA,QAAA,EAAA,GAhBnEjB,EAAK,EAiBf;AAAA,MAAA;AAAA,IACJ;AAAA,IACCK,KACGQ,EAAc,SAAS,KACvBA,EAAc,IAAI,CAACM,MAEX,gBAAAF;AAAA,MAACG;AAAA,MAAA;AAAA,QAEG,SAAAD;AAAA,QACA,aAAAlB;AAAA,QACA,aAAAC;AAAA,MAAA;AAAA,MAHKiB,EAAQ;AAAA,IAAA,CAMxB;AAAA,EACT,EAAA,CAAA;AAER;"}
1
+ {"version":3,"file":"PageLink.es.js","sources":["../../../../src/components/Link/LinkSelector/PageLink.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { type DocumentSection } from '@frontify/app-bridge';\nimport { merge } from '@frontify/fondue';\nimport { useEffect, useState } from 'react';\nimport { DocumentSectionWithTitle, InitiallyExpandedItems } from '../';\nimport { SectionLink } from './SectionLink';\nimport { filterDocumentSectionsWithUnreadableTitles } from '../helpers/filterDocumentSectionsWithUnreadableTitles';\n\ntype PageLinkProps = {\n page: {\n id: number;\n title: string;\n permanentLink: string;\n };\n selectedUrl: string;\n onSelectUrl: (url: string) => void;\n itemsToExpandInitially: InitiallyExpandedItems;\n getDocumentSectionsByDocumentPageId: (documentPageId: number) => Promise<DocumentSection[]>;\n};\n\nexport const PageLink = ({\n page,\n selectedUrl,\n onSelectUrl,\n itemsToExpandInitially,\n getDocumentSectionsByDocumentPageId,\n}: PageLinkProps) => {\n const [isExpanded, setIsExpanded] = useState(page.id === itemsToExpandInitially.documentId);\n const [documentSections, setDocumentSections] = useState<DocumentSectionWithTitle[]>([]);\n const isActive = page.permanentLink === selectedUrl;\n\n useEffect(() => {\n const fetchDocumentSections = async () => {\n const sections = await getDocumentSectionsByDocumentPageId(page.id);\n const sectionsWithReadableTitles = filterDocumentSectionsWithUnreadableTitles(sections);\n setDocumentSections(sectionsWithReadableTitles);\n };\n\n fetchDocumentSections();\n }, [page.id, getDocumentSectionsByDocumentPageId]);\n\n useEffect(() => {\n if (page.id === itemsToExpandInitially.pageId) {\n setIsExpanded(true);\n }\n }, [itemsToExpandInitially, page.id]);\n\n const hasSections = documentSections.length > 0;\n\n return (\n <>\n <button\n data-test-id=\"internal-link-selector-page-link\"\n className={merge([\n 'tw-py-2 tw-pr-2.5 tw-leading-5 tw-cursor-pointer tw-flex tw-w-full',\n hasSections ? 'tw-pl-7' : 'tw-pl-12',\n isActive\n ? 'tw-bg-box-selected-strong tw-text-box-selected-strong-inverse hover:tw-bg-box-selected-strong-hover:hover hover:tw-text-box-selected-strong-inverse-hover:hover'\n : 'hover:tw-bg-box-neutral-hover hover:tw-text-box-neutral-inverse-hover',\n ])}\n onClick={() => onSelectUrl(page.permanentLink)}\n >\n <div key={page.id} className=\"tw-flex tw-flex-1 tw-space-x-1 tw-items-center tw-h-6\">\n {hasSections && (\n <button\n data-test-id=\"tree-item-toggle\"\n className=\"tw-flex tw-items-center tw-justify-center -tw-mr-2 tw-pr-3.5 tw-pt-1.5 tw-pb-1.5 tw-pl-3.5 tw-cursor-pointer\"\n onClick={() => setIsExpanded(!isExpanded)}\n >\n <div\n className={merge([\n 'tw-transition-transform tw-w-0 tw-h-0 tw-font-normal tw-border-t-4 tw-border-t-transparent tw-border-b-4 tw-border-b-transparent tw-border-l-4 tw-border-l-x-strong',\n isExpanded ? 'tw-rotate-90' : '',\n ])}\n ></div>\n </button>\n )}\n <span className=\"tw-text-s\">{page.title}</span>\n <span className=\"tw-flex-auto tw-font-sans tw-text-xs tw-text-right\">Page</span>\n </div>\n </button>\n {isExpanded &&\n documentSections.length > 0 &&\n documentSections.map((section) => {\n return (\n <SectionLink\n key={section.id}\n section={section}\n selectedUrl={selectedUrl}\n onSelectUrl={onSelectUrl}\n />\n );\n })}\n </>\n );\n};\n"],"names":["PageLink","page","selectedUrl","onSelectUrl","itemsToExpandInitially","getDocumentSectionsByDocumentPageId","isExpanded","setIsExpanded","useState","documentSections","setDocumentSections","isActive","useEffect","sections","sectionsWithReadableTitles","filterDocumentSectionsWithUnreadableTitles","hasSections","jsxs","Fragment","jsx","merge","section","SectionLink"],"mappings":";;;;;AAqBO,MAAMA,IAAW,CAAC;AAAA,EACrB,MAAAC;AAAA,EACA,aAAAC;AAAA,EACA,aAAAC;AAAA,EACA,wBAAAC;AAAA,EACA,qCAAAC;AACJ,MAAqB;AACX,QAAA,CAACC,GAAYC,CAAa,IAAIC,EAASP,EAAK,OAAOG,EAAuB,UAAU,GACpF,CAACK,GAAkBC,CAAmB,IAAIF,EAAqC,CAAE,CAAA,GACjFG,IAAWV,EAAK,kBAAkBC;AAExC,EAAAU,EAAU,MAAM;AAOU,KANQ,YAAY;AACtC,YAAMC,IAAW,MAAMR,EAAoCJ,EAAK,EAAE,GAC5Da,IAA6BC,EAA2CF,CAAQ;AACtF,MAAAH,EAAoBI,CAA0B;AAAA,IAAA;EAInD,GAAA,CAACb,EAAK,IAAII,CAAmC,CAAC,GAEjDO,EAAU,MAAM;AACR,IAAAX,EAAK,OAAOG,EAAuB,UACnCG,EAAc,EAAI;AAAA,EAEvB,GAAA,CAACH,GAAwBH,EAAK,EAAE,CAAC;AAE9B,QAAAe,IAAcP,EAAiB,SAAS;AAE9C,SAEQ,gBAAAQ,EAAAC,GAAA,EAAA,UAAA;AAAA,IAAA,gBAAAC;AAAA,MAAC;AAAA,MAAA;AAAA,QACG,gBAAa;AAAA,QACb,WAAWC,EAAM;AAAA,UACb;AAAA,UACAJ,IAAc,YAAY;AAAA,UAC1BL,IACM,oKACA;AAAA,QAAA,CACT;AAAA,QACD,SAAS,MAAMR,EAAYF,EAAK,aAAa;AAAA,QAE7C,UAAA,gBAAAgB,EAAC,OAAkB,EAAA,WAAU,yDACxB,UAAA;AAAA,UACGD,KAAA,gBAAAG;AAAA,YAAC;AAAA,YAAA;AAAA,cACG,gBAAa;AAAA,cACb,WAAU;AAAA,cACV,SAAS,MAAMZ,EAAc,CAACD,CAAU;AAAA,cAExC,UAAA,gBAAAa;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBACG,WAAWC,EAAM;AAAA,oBACb;AAAA,oBACAd,IAAa,iBAAiB;AAAA,kBAAA,CACjC;AAAA,gBAAA;AAAA,cACJ;AAAA,YAAA;AAAA,UACL;AAAA,UAEH,gBAAAa,EAAA,QAAA,EAAK,WAAU,aAAa,YAAK,OAAM;AAAA,UACvC,gBAAAA,EAAA,QAAA,EAAK,WAAU,sDAAqD,UAAI,QAAA;AAAA,QAAA,EAAA,GAhBnElB,EAAK,EAiBf;AAAA,MAAA;AAAA,IACJ;AAAA,IACCK,KACGG,EAAiB,SAAS,KAC1BA,EAAiB,IAAI,CAACY,MAEd,gBAAAF;AAAA,MAACG;AAAA,MAAA;AAAA,QAEG,SAAAD;AAAA,QACA,aAAAnB;AAAA,QACA,aAAAC;AAAA,MAAA;AAAA,MAHKkB,EAAQ;AAAA,IAAA,CAMxB;AAAA,EACT,EAAA,CAAA;AAER;"}
@@ -0,0 +1,8 @@
1
+ const l = (e) => e.filter((i) => {
2
+ var t;
3
+ return !!((t = i.title) != null && t.trim());
4
+ });
5
+ export {
6
+ l as filterDocumentSectionsWithUnreadableTitles
7
+ };
8
+ //# sourceMappingURL=filterDocumentSectionsWithUnreadableTitles.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filterDocumentSectionsWithUnreadableTitles.es.js","sources":["../../../../src/components/Link/helpers/filterDocumentSectionsWithUnreadableTitles.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { type DocumentSection } from '@frontify/app-bridge';\nimport { type DocumentSectionWithTitle } from '../types';\n\nexport const filterDocumentSectionsWithUnreadableTitles = (sections: DocumentSection[]) =>\n sections.filter((section) => !!section.title?.trim()) as DocumentSectionWithTitle[];\n"],"names":["filterDocumentSectionsWithUnreadableTitles","sections","section","_a"],"mappings":"AAKO,MAAMA,IAA6C,CAACC,MACvDA,EAAS,OAAO,CAACC,MAAY;AAD1B,MAAAC;AAC0B,UAAC,GAACA,IAAAD,EAAQ,UAAR,QAAAC,EAAe;AAAA,CAAM;"}