@okam/directus-flexible-content 1.2.23 → 1.2.24

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/CHANGELOG.md CHANGED
@@ -1,3 +1,30 @@
1
+ ## 1.2.24 (2026-01-13)
2
+
3
+ ### 🚀 Features
4
+
5
+ - React 19 + Next.js 15 support ([#369](https://github.com/OKAMca/stack/pull/369))
6
+ - bump ([ab924b9](https://github.com/OKAMca/stack/commit/ab924b9))
7
+
8
+ ### 🩹 Fixes
9
+
10
+ - **directus-flexible-content:** core-lib in external deps ([e44cb2b](https://github.com/OKAMca/stack/commit/e44cb2b))
11
+ - update vite-plugin-dts to version 3 ([5d33c77](https://github.com/OKAMca/stack/commit/5d33c77))
12
+ - package deps error ([b665a45](https://github.com/OKAMca/stack/commit/b665a45))
13
+ - search field type export ([5ab6070](https://github.com/OKAMca/stack/commit/5ab6070))
14
+ - search field icon ([0850fde](https://github.com/OKAMca/stack/commit/0850fde))
15
+ - select controlled ([#280](https://github.com/OKAMca/stack/pull/280))
16
+
17
+ ### 🧱 Updated Dependencies
18
+
19
+ - Updated stack-ui to 1.43.0
20
+ - Updated directus-block to 1.6.2
21
+
22
+ ### ❤️ Thank You
23
+
24
+ - Marie-Maxime Tanguay @marie-maxime
25
+ - Pierre-Olivier Clerson @poclerson
26
+ - poclerson
27
+
1
28
  ## 1.2.23 (2025-11-27)
2
29
 
3
30
  ### 🚀 Features
package/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react/jsx-runtime"),O=require("@tanstack/react-query"),_=require("radashi"),C=require("graphql-request"),E=require("@okam/stack-ui"),G=require("react"),B=require("@tiptap/core"),K=require("@tiptap/extension-blockquote"),V=require("@tiptap/extension-bold"),X=require("@tiptap/extension-bullet-list"),J=require("@tiptap/extension-code"),W=require("@tiptap/extension-code-block"),$=require("@tiptap/extension-document"),Y=require("@tiptap/extension-hard-break"),Z=require("@tiptap/extension-heading"),ee=require("@tiptap/extension-horizontal-rule"),te=require("@tiptap/extension-italic"),ne=require("@tiptap/extension-link"),re=require("@tiptap/extension-list-item"),oe=require("@tiptap/extension-ordered-list"),ie=require("@tiptap/extension-paragraph"),se=require("@tiptap/extension-strike"),ce=require("@tiptap/extension-subscript"),ae=require("@tiptap/extension-superscript"),le=require("@tiptap/extension-table"),ue=require("@tiptap/extension-table-cell"),de=require("@tiptap/extension-table-header"),me=require("@tiptap/extension-table-row"),fe=require("@tiptap/extension-text"),pe=require("@tiptap/extension-text-align");function H(e,n){return n}class q{constructor(n,r,t){this.nameSpace="[STACK]",this.suppressConsole=!1,this.env=process.env.NODE_ENV,this.nameSpace=n??this.nameSpace,this.suppressConsole=t??this.suppressConsole,this.logger=r??this.internalLogger}internalLogger(n,r,t){this.env!=="production"&&console[r||"log"](`${this.nameSpace} ${n}`.trimStart(),t??"")}setLogger(n){this.logger=(r,t,i)=>{this.suppressConsole&&this.internalLogger(r,t,i),n(r,t,i)}}static getInstance(){return q.instance||(q.instance=new q),q.instance}log(n,r,t){this.logger(n,r,t)}}q.getInstance();const ge=(e,n,r=!1)=>{const t=new q(e,n,r);return t.log("Logger initialized","info"),t},ke=ge("[DirectusQuery]"),ye=process.env.NEXT_PUBLIC_GRAPHQL_URL,be=process.env.NEXT_SERVER_GRAPHQL_URL,Ne=process.env.NEXT_GRAPHQL_URL_ADMIN,qe=process.env.NEXT_PUBLIC_API_TOKEN??"",Te=process.env.NEXT_PUBLIC_API_TOKEN,he=new C.GraphQLClient(be||ye,{credentials:"include",mode:"cors",fetch,headers:{Authorization:`Bearer ${qe}`}});new C.GraphQLClient(Ne,{credentials:"include",mode:"cors",fetch,headers:{Authorization:`Bearer ${Te}`}});new O.QueryClient({queryCache:new O.QueryCache({onError:e=>{ke.log("QueryClient Error","error",{error:e})}}),defaultOptions:{queries:{staleTime:5*1e3}}});function M(e,n,r=he){return r.request(e,{...n})}process.env.NEXT_PUBLIC_GRAPHQL_URL;process.env.NEXT_PUBLIC_API_TOKEN;function A(e){return!!e}function Be(e){const{id:n,settings:r,...t}=e??{};return _.isEmpty(t)}async function Se(e){const{document:n,blockKey:r,variables:t}=e;if(!n||!A(t))return null;const i=await M(n,t);return!i||typeof i!="object"||!r?null:i[r]}async function _e(e){const{document:n,item:r,blockKey:t,variables:i}=e;if(r){if(!Be(r))return r;const s={id:r.id,...i};return A(s)?Se({...e,variables:s}):null}if(!n||!A(i))return null;const o=await M(n,i);return!o||typeof o!="object"||!t?null:o[t]}function ve(e,...n){return n.reduce((t,i)=>i?{components:{...t.components,...i.components}}:t,e)}const z={kind:"Document",definitions:[{kind:"FragmentDefinition",name:{kind:"Name",value:"BlockSettings"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"block_settings"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"tokens"}},{kind:"Field",name:{kind:"Name",value:"variant"}}]}}]},Le=e=>{var N,k,h;const{item:n,collection:r,config:t,variables:i,defaultVariant:o,...c}=e;if(!r||!t)return null;const s=(N=t==null?void 0:t.components)==null?void 0:N[r];if(!s)return null;const{settings:l}=n??{},u=(n==null?void 0:n.id)??(i==null?void 0:i.id);if(!u)return null;const{variant:f}=H(z,l)??{},d=((k=s.getVariant)==null?void 0:k.call(s,e))??f??o,{default:g,document:m}=s,b=((h=s.variants)==null?void 0:h[d??""])??g;return b?p.jsx(b,{document:m,config:t,collection:r,item:n,...u?{variables:{...i,id:u}}:{variables:i},...c},u):null};async function xe(e,n,r){const t=_.get(e,"item"),i=_.get(e,"document"),o=_.get(e,"variables"),c=await _e({item:t,blockKey:n,document:i,variables:o}),{tokens:s}=H(z,c==null?void 0:c.settings)??{};return{...c,cmsTokens:s}}const Ee=async e=>{const n="block_wysiwyg_by_id",{themeName:r="wysiwyg",tokens:t}=e,{content:i,title:o,level:c,cmsTokens:s}=await xe(e,n);return!i&&!(o&&c)?null:p.jsxs(p.Fragment,{children:[o&&c&&p.jsx(E.Box,{as:"span",themeName:r,tokens:{...t,...s},children:G.createElement(c,{},o)}),i&&p.jsx(E.WysiwygBlock,{themeName:r,tokens:{...t,...s},content:i})]})},Ae={block_wysiwyg:{default:e=>p.jsx(Ee,{...e})}},Ie={components:{...Ae}},P=e=>{const{children:n,config:r,...t}=e,i=ve(Ie,r),o=s=>n?n({...t,...s,config:i}):p.jsx(Le,{...t,...s,config:i});if("blocks"in e){const{blocks:s}=e;return s.map(o)}const{block:c}=e;return o(c)},Re=(e,n,r="id",t="item")=>{const i=o=>{var c,s,l,u,f,d;if(!e&&o)return o;if(!o||!e)return null;if(o.type==="relation-mark"&&((c=o.attrs)!=null&&c.id)||o.type==="relation-block"&&((s=o.attrs)!=null&&s.id)||o.type==="relation-inline-block"&&((l=o.attrs)!=null&&l.id)){const g=(u=e.find(m=>{var y;return(m==null?void 0:m[r])===((y=o.attrs)==null?void 0:y.id)}))==null?void 0:u[t];o.attrs.data=g}return(f=o.content)==null||f.map(i),(d=o.marks)==null||d.map(i),o};return i(n)},we=(e,n)=>{const r=n.map(o=>(o.type==="mark"?B.Mark:B.Node).create({name:o.name,renderHTML({HTMLAttributes:s}){return o.render?[...o.render(s),0]:[o.component??(o.type==="mark"?"span":"div"),s,0]}})),t=r.map(({name:o})=>o);return[...e.filter(o=>t.indexOf(o.name)<0),...r]},D=(e,n,r)=>{const t=r.find(i=>i.type===n&&i.name===e);if(t)return{...t.config,options:t.options}},Oe=(e,n)=>{var t;const r=(t=n.addAttributes)==null?void 0:t.call(n);return!r||!e?e:Object.fromEntries(Object.entries(e).filter(([i])=>{var o;return((o=r[i])==null?void 0:o.rendered)!==!1}))},v=(e,n,r="node")=>{const t=D(e.type,r,n);if(!(t!=null&&t.renderHTML))return[];const i=Oe(e.attrs,t);return t.render?t.render(e):t.renderHTML({node:e,HTMLAttributes:i})},F=(e,n,r)=>{if(e!=null&&e.content&&(e.content=e.content.map(c=>F(c,n,r))),e.type==="text"){if(e.marks){let c;return e.marks.reverse().forEach(s=>{var u;const l=v({...s,attrs:{...s.attrs,data:{...(u=s==null?void 0:s.attrs)==null?void 0:u.data,markText:e.text}}},n,"mark");if(Array.isArray(l)){const[f="span",d=s.attrs]=l,g={...d,data:void 0};c=r(f,g,c||e.text)}else c={...l,text:e.text}}),c}return e.text??""}const t=D(e.type,"node",n);if(t!=null&&t.render)return v(e,n);const[i="div",o=e.attrs]=v(e,n);return r(i,o,e.content)},Pe=(e,n,r)=>F(e,n,r),L={colspan:"colSpan",rowspan:"rowSpan",textAlign:"textalign"},Ce=(e,n)=>({...Object.fromEntries(Object.entries(n).map(([r,t])=>[(e==null?void 0:e[r])??(L==null?void 0:L[r])??r,t]))}),x={},Q=e=>{const{content:n,serializers:r=[],componentSerializers:t=[],renderingNodes:i,remappedAttributes:o,themeName:c,tokens:s,customTheme:l}=e,u=JSON.parse(JSON.stringify(n)),f=we(r,t);return Pe(u,f,(d,g,m)=>{const y={...g,style:void 0},b=Ce(o,y),N=(i==null?void 0:i[d])??(x==null?void 0:x[d]);return N?N({children:m,attrs:b,themeName:c,tokens:s,customTheme:l}):p.jsx(E.Box,{as:d,...b,themeName:c,tokens:s,customTheme:l,children:m},JSON.stringify(m))})},He=[$,fe,ie,Y,Z,W,X,oe,re,K,ee,ne,V,te,se,J,le.Table,de.TableHeader,me.TableRow,ue.TableCell,pe,ce,ae],Me=e=>{const{jsonContent:n,editorNodes:r,serializers:t,nodes:i,config:o,relationMarksConfig:c,themeName:s,tokens:l,customTheme:u,remappedAttributes:f}=e,d=Re(r,n),g=t??[...He]??[],m=(k,h)=>{var I,R,w;const{attrs:a}=k,U=`${(I=a==null?void 0:a.collection)==null?void 0:I.replace("related_","")}_id`;if(a!=null&&a.data){if(!((R=a==null?void 0:a.data)!=null&&R.blocks)){const T={collection:a.collection,item:{...a==null?void 0:a.data}};return p.jsx(P,{block:T,config:h},JSON.stringify(T))}const S=(w=a==null?void 0:a.data)==null?void 0:w.blocks,j=S==null?void 0:S.map(T=>({item:T==null?void 0:T[U],collection:a==null?void 0:a.collection}));return p.jsx(P,{blocks:j,config:h},JSON.stringify(S))}return null},y=B.Node.create({name:"relation-block",renderHTML:()=>["relation-block"],render:k=>m(k,o)}),b=B.Node.create({name:"relation-inline-block",renderHTML:()=>["relation-inline-block"],render:k=>m(k,o)}),N=B.Mark.create({name:"relation-mark",type:"relation-mark",renderHTML:()=>["relation-mark"],render:k=>m(k,c)});return g.push(y,b,N),d?p.jsx(Q,{content:d,serializers:g,renderingNodes:i,themeName:s,tokens:l,customTheme:u,remappedAttributes:f}):null};exports.FlexibleEditorContent=Me;exports.RenderNodes=Q;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react/jsx-runtime"),O=require("@tanstack/react-query"),_=require("radashi"),C=require("graphql-request"),E=require("@okam/stack-ui"),G=require("react"),B=require("@tiptap/core"),K=require("@tiptap/extension-blockquote"),V=require("@tiptap/extension-bold"),X=require("@tiptap/extension-bullet-list"),J=require("@tiptap/extension-code"),W=require("@tiptap/extension-code-block"),$=require("@tiptap/extension-document"),Y=require("@tiptap/extension-hard-break"),Z=require("@tiptap/extension-heading"),ee=require("@tiptap/extension-horizontal-rule"),te=require("@tiptap/extension-italic"),ne=require("@tiptap/extension-link"),re=require("@tiptap/extension-list-item"),oe=require("@tiptap/extension-ordered-list"),ie=require("@tiptap/extension-paragraph"),se=require("@tiptap/extension-strike"),ce=require("@tiptap/extension-subscript"),ae=require("@tiptap/extension-superscript"),le=require("@tiptap/extension-table"),ue=require("@tiptap/extension-table-cell"),de=require("@tiptap/extension-table-header"),me=require("@tiptap/extension-table-row"),fe=require("@tiptap/extension-text"),ge=require("@tiptap/extension-text-align");function H(e,n){return n}class q{constructor(n,r,t){this.nameSpace="[STACK]",this.suppressConsole=!1,this.env=process.env.NODE_ENV,this.nameSpace=n??this.nameSpace,this.suppressConsole=t??this.suppressConsole,this.logger=r??this.internalLogger}internalLogger(n,r,t){this.env!=="production"&&console[r||"log"](`${this.nameSpace} ${n}`.trimStart(),t??"")}setLogger(n){this.logger=(r,t,i)=>{this.suppressConsole&&this.internalLogger(r,t,i),n(r,t,i)}}static getInstance(){return q.instance||(q.instance=new q),q.instance}log(n,r,t){this.logger(n,r,t)}}q.getInstance();const pe=(e,n,r=!1)=>{const t=new q(e,n,r);return t.log("Logger initialized","info"),t},ke=pe("[DirectusQuery]"),ye=process.env.NEXT_PUBLIC_GRAPHQL_URL,be=process.env.NEXT_SERVER_GRAPHQL_URL,Ne=process.env.NEXT_GRAPHQL_URL_ADMIN,qe=process.env.NEXT_PUBLIC_API_TOKEN??"",Te=process.env.NEXT_PUBLIC_API_TOKEN,he=new C.GraphQLClient(be||ye,{credentials:"include",mode:"cors",fetch,headers:{Authorization:`Bearer ${qe}`}});new C.GraphQLClient(Ne,{credentials:"include",mode:"cors",fetch,headers:{Authorization:`Bearer ${Te}`}});new O.QueryClient({queryCache:new O.QueryCache({onError:e=>{ke.log("QueryClient Error","error",{error:e})}}),defaultOptions:{queries:{staleTime:5*1e3}}});function M(e,n,r=he){return r.request(e,{...n})}process.env.NEXT_PUBLIC_GRAPHQL_URL;process.env.NEXT_PUBLIC_API_TOKEN;function A(e){return!!e}function Be(e){const{id:n,settings:r,...t}=e??{};return _.isEmpty(t)}async function Se(e){const{document:n,blockKey:r,variables:t}=e;if(!n||!A(t))return null;const i=await M(n,t);return!i||typeof i!="object"||!r?null:i[r]}async function _e(e){const{document:n,item:r,blockKey:t,variables:i}=e;if(r){if(!Be(r))return r;const s={id:r.id,...i};return A(s)?Se({...e,variables:s}):null}if(!n||!A(i))return null;const o=await M(n,i);return!o||typeof o!="object"||!t?null:o[t]}function ve(e,...n){return n.reduce((t,i)=>i?{components:{...t.components,...i.components}}:t,e)}const z={kind:"Document",definitions:[{kind:"FragmentDefinition",name:{kind:"Name",value:"BlockSettings"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"block_settings"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"tokens"}},{kind:"Field",name:{kind:"Name",value:"variant"}}]}}]},Le=e=>{var N,m,h;const{item:n,collection:r,config:t,variables:i,defaultVariant:o,...c}=e;if(!r||!t)return null;const s=(N=t==null?void 0:t.components)==null?void 0:N[r];if(!s)return null;const{settings:l}=n??{},u=(n==null?void 0:n.id)??(i==null?void 0:i.id);if(!u)return null;const{variant:g}=H(z,l)??{},f=((m=s.getVariant)==null?void 0:m.call(s,e))??g??o,{default:k,document:d}=s,b=((h=s.variants)==null?void 0:h[f??""])??k;return b?p.jsx(b,{document:d,config:t,collection:r,item:n,...u?{variables:{...i,id:u}}:{variables:i},...c},u):null};async function xe(e,n,r){const t=_.get(e,"item"),i=_.get(e,"document"),o=_.get(e,"variables"),c=await _e({item:t,blockKey:n,document:i,variables:o}),{tokens:s}=H(z,c==null?void 0:c.settings)??{};return{...c,cmsTokens:s}}const Ee=async e=>{const n="block_wysiwyg_by_id",{themeName:r="wysiwyg",tokens:t}=e,{content:i,title:o,level:c,cmsTokens:s}=await xe(e,n);return!i&&!(o&&c)?null:p.jsxs(p.Fragment,{children:[o&&c&&p.jsx(E.Box,{as:"span",themeName:r,tokens:{...t,...s},children:G.createElement(c,{},o)}),i&&p.jsx(E.WysiwygBlock,{themeName:r,tokens:{...t,...s},content:i})]})},Ae={block_wysiwyg:{default:e=>p.jsx(Ee,{...e})}},Ie={components:{...Ae}},P=e=>{const{children:n,config:r,...t}=e,i=ve(Ie,r),o=s=>n?n({...t,...s,config:i}):p.jsx(Le,{...t,...s,config:i});if("blocks"in e){const{blocks:s}=e;return s.map(o)}const{block:c}=e;return o(c)},Re=(e,n,r="id",t="item")=>{const i=o=>{var c,s,l,u,g,f;if(!e&&o)return o;if(!o||!e)return null;if(o.type==="relation-mark"&&((c=o.attrs)!=null&&c.id)||o.type==="relation-block"&&((s=o.attrs)!=null&&s.id)||o.type==="relation-inline-block"&&((l=o.attrs)!=null&&l.id)){const k=(u=e.find(d=>{var y;return(d==null?void 0:d[r])===((y=o.attrs)==null?void 0:y.id)}))==null?void 0:u[t];o.attrs.data=k}return(g=o.content)==null||g.map(i),(f=o.marks)==null||f.map(i),o};return i(n)},we=(e,n)=>{const r=n.map(o=>(o.type==="mark"?B.Mark:B.Node).create({name:o.name,renderHTML({HTMLAttributes:s}){return o.render?[...o.render(s),0]:[o.component??(o.type==="mark"?"span":"div"),s,0]}})),t=r.map(({name:o})=>o);return[...e.filter(o=>t.indexOf(o.name)<0),...r]},D=(e,n,r)=>{const t=r.find(i=>i.type===n&&i.name===e);if(t)return{...t.config,options:t.options}},Oe=(e,n)=>{var t;const r=(t=n.addAttributes)==null?void 0:t.call(n);return!r||!e?e:Object.fromEntries(Object.entries(e).filter(([i])=>{var o;return((o=r[i])==null?void 0:o.rendered)!==!1}))},v=(e,n,r="node")=>{const t=D(e.type,r,n);if(!(t!=null&&t.renderHTML))return[];const i=Oe(e.attrs,t);return t.render?t.render(e):t.renderHTML({node:e,HTMLAttributes:i})},F=(e,n,r)=>{if(e!=null&&e.content&&(e.content=e.content.map(c=>F(c,n,r))),e.type==="text"){if(e.marks){let c;return e.marks.reverse().forEach(s=>{var u;const l=v({...s,attrs:{...s.attrs,data:{...(u=s==null?void 0:s.attrs)==null?void 0:u.data,markText:e.text}}},n,"mark");if(Array.isArray(l)){const[g="span",f=s.attrs]=l,k={...f,data:void 0};c=r(g,k,c||e.text)}else c={...l,text:e.text}}),c}return e.text??""}const t=D(e.type,"node",n);if(t!=null&&t.render)return v(e,n);const[i="div",o=e.attrs]=v(e,n);return r(i,o,e.content)},Pe=(e,n,r)=>F(e,n,r),L={colspan:"colSpan",rowspan:"rowSpan",textAlign:"textalign"},Ce=(e,n)=>({...Object.fromEntries(Object.entries(n).map(([r,t])=>[(e==null?void 0:e[r])??(L==null?void 0:L[r])??r,t]))}),x={},Q=e=>{const{content:n,serializers:r=[],componentSerializers:t=[],renderingNodes:i,remappedAttributes:o,themeName:c,tokens:s,customTheme:l}=e,u=JSON.parse(JSON.stringify(n)),g=we(r,t);return Pe(u,g,(f,k,d)=>{const y={...k,style:void 0},b=Ce(o,y),N=f,m=(i==null?void 0:i[N])??(x==null?void 0:x[N]);return m?m({children:d,attrs:b,themeName:c,tokens:s,customTheme:l}):p.jsx(E.Box,{as:f,...b,themeName:c,tokens:s,customTheme:l,children:d},JSON.stringify(d))})},He=[$,fe,ie,Y,Z,W,X,oe,re,K,ee,ne,V,te,se,J,le.Table,de.TableHeader,me.TableRow,ue.TableCell,ge,ce,ae],Me=e=>{const{jsonContent:n,editorNodes:r,serializers:t,nodes:i,config:o,relationMarksConfig:c,themeName:s,tokens:l,customTheme:u,remappedAttributes:g}=e,f=Re(r,n),k=t??[...He]??[],d=(m,h)=>{var I,R,w;const{attrs:a}=m,U=`${(I=a==null?void 0:a.collection)==null?void 0:I.replace("related_","")}_id`;if(a!=null&&a.data){if(!((R=a==null?void 0:a.data)!=null&&R.blocks)){const T={collection:a.collection,item:{...a==null?void 0:a.data}};return p.jsx(P,{block:T,config:h},JSON.stringify(T))}const S=(w=a==null?void 0:a.data)==null?void 0:w.blocks,j=S==null?void 0:S.map(T=>({item:T==null?void 0:T[U],collection:a==null?void 0:a.collection}));return p.jsx(P,{blocks:j,config:h},JSON.stringify(S))}return null},y=B.Node.create({name:"relation-block",renderHTML:()=>["relation-block"],render:m=>d(m,o)}),b=B.Node.create({name:"relation-inline-block",renderHTML:()=>["relation-inline-block"],render:m=>d(m,o)}),N=B.Mark.create({name:"relation-mark",type:"relation-mark",renderHTML:()=>["relation-mark"],render:m=>d(m,c)});return k.push(y,b,N),f?p.jsx(Q,{content:f,serializers:k,renderingNodes:i,themeName:s,tokens:l,customTheme:u,remappedAttributes:g}):null};exports.FlexibleEditorContent=Me;exports.RenderNodes=Q;
package/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { jsx as g, jsxs as G, Fragment as K } from "react/jsx-runtime";
1
+ import { jsx as k, jsxs as K, Fragment as G } from "react/jsx-runtime";
2
2
  import { QueryClient as V, QueryCache as X } from "@tanstack/react-query";
3
3
  import { isEmpty as J, get as _ } from "radashi";
4
4
  import { GraphQLClient as H } from "graphql-request";
@@ -23,8 +23,8 @@ import ue from "@tiptap/extension-strike";
23
23
  import fe from "@tiptap/extension-subscript";
24
24
  import de from "@tiptap/extension-superscript";
25
25
  import { Table as pe } from "@tiptap/extension-table";
26
- import { TableCell as ke } from "@tiptap/extension-table-cell";
27
- import { TableHeader as ge } from "@tiptap/extension-table-header";
26
+ import { TableCell as ge } from "@tiptap/extension-table-cell";
27
+ import { TableHeader as ke } from "@tiptap/extension-table-header";
28
28
  import { TableRow as ye } from "@tiptap/extension-table-row";
29
29
  import Ne from "@tiptap/extension-text";
30
30
  import be from "@tiptap/extension-text-align";
@@ -121,18 +121,18 @@ function Oe(e, ...r) {
121
121
  return r.reduce((t, i) => i ? { components: { ...t.components, ...i.components } } : t, e);
122
122
  }
123
123
  const D = { kind: "Document", definitions: [{ kind: "FragmentDefinition", name: { kind: "Name", value: "BlockSettings" }, typeCondition: { kind: "NamedType", name: { kind: "Name", value: "block_settings" } }, selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "tokens" } }, { kind: "Field", name: { kind: "Name", value: "variant" } }] } }] }, Pe = (e) => {
124
- var b, k, B;
124
+ var b, f, B;
125
125
  const { item: r, collection: n, config: t, variables: i, defaultVariant: o, ...c } = e;
126
126
  if (!n || !t) return null;
127
127
  const s = (b = t == null ? void 0 : t.components) == null ? void 0 : b[n];
128
128
  if (!s) return null;
129
129
  const { settings: l } = r ?? {}, m = (r == null ? void 0 : r.id) ?? (i == null ? void 0 : i.id);
130
130
  if (!m) return null;
131
- const { variant: d } = q(D, l) ?? {}, u = ((k = s.getVariant) == null ? void 0 : k.call(s, e)) ?? d ?? o, { default: p, document: f } = s, N = ((B = s.variants) == null ? void 0 : B[u ?? ""]) ?? p;
132
- return N ? /* @__PURE__ */ g(
131
+ const { variant: p } = q(D, l) ?? {}, d = ((f = s.getVariant) == null ? void 0 : f.call(s, e)) ?? p ?? o, { default: g, document: u } = s, N = ((B = s.variants) == null ? void 0 : B[d ?? ""]) ?? g;
132
+ return N ? /* @__PURE__ */ k(
133
133
  N,
134
134
  {
135
- document: f,
135
+ document: u,
136
136
  config: t,
137
137
  collection: n,
138
138
  item: r,
@@ -153,20 +153,20 @@ async function Re(e, r, n) {
153
153
  }
154
154
  const He = async (e) => {
155
155
  const r = "block_wysiwyg_by_id", { themeName: n = "wysiwyg", tokens: t } = e, { content: i, title: o, level: c, cmsTokens: s } = await Re(e, r);
156
- return !i && !(o && c) ? null : /* @__PURE__ */ G(K, { children: [
157
- o && c && /* @__PURE__ */ g(C, { as: "span", themeName: n, tokens: { ...t, ...s }, children: $.createElement(c, {}, o) }),
158
- i && /* @__PURE__ */ g(W, { themeName: n, tokens: { ...t, ...s }, content: i })
156
+ return !i && !(o && c) ? null : /* @__PURE__ */ K(G, { children: [
157
+ o && c && /* @__PURE__ */ k(C, { as: "span", themeName: n, tokens: { ...t, ...s }, children: $.createElement(c, {}, o) }),
158
+ i && /* @__PURE__ */ k(W, { themeName: n, tokens: { ...t, ...s }, content: i })
159
159
  ] });
160
160
  }, Ce = {
161
161
  block_wysiwyg: {
162
- default: (e) => /* @__PURE__ */ g(He, { ...e })
162
+ default: (e) => /* @__PURE__ */ k(He, { ...e })
163
163
  }
164
164
  }, xe = {
165
165
  components: {
166
166
  ...Ce
167
167
  }
168
168
  }, R = (e) => {
169
- const { children: r, config: n, ...t } = e, i = Oe(xe, n), o = (s) => r ? r({ ...t, ...s, config: i }) : /* @__PURE__ */ g(Pe, { ...t, ...s, config: i });
169
+ const { children: r, config: n, ...t } = e, i = Oe(xe, n), o = (s) => r ? r({ ...t, ...s, config: i }) : /* @__PURE__ */ k(Pe, { ...t, ...s, config: i });
170
170
  if ("blocks" in e) {
171
171
  const { blocks: s } = e;
172
172
  return s.map(o);
@@ -175,17 +175,17 @@ const He = async (e) => {
175
175
  return o(c);
176
176
  }, qe = (e, r, n = "id", t = "item") => {
177
177
  const i = (o) => {
178
- var c, s, l, m, d, u;
178
+ var c, s, l, m, p, d;
179
179
  if (!e && o) return o;
180
180
  if (!o || !e) return null;
181
181
  if (o.type === "relation-mark" && ((c = o.attrs) != null && c.id) || o.type === "relation-block" && ((s = o.attrs) != null && s.id) || o.type === "relation-inline-block" && ((l = o.attrs) != null && l.id)) {
182
- const p = (m = e.find((f) => {
182
+ const g = (m = e.find((u) => {
183
183
  var y;
184
- return (f == null ? void 0 : f[n]) === ((y = o.attrs) == null ? void 0 : y.id);
184
+ return (u == null ? void 0 : u[n]) === ((y = o.attrs) == null ? void 0 : y.id);
185
185
  })) == null ? void 0 : m[t];
186
- o.attrs.data = p;
186
+ o.attrs.data = g;
187
187
  }
188
- return (d = o.content) == null || d.map(i), (u = o.marks) == null || u.map(i), o;
188
+ return (p = o.content) == null || p.map(i), (d = o.marks) == null || d.map(i), o;
189
189
  };
190
190
  return i(r);
191
191
  }, ze = (e, r) => {
@@ -231,8 +231,8 @@ const He = async (e) => {
231
231
  "mark"
232
232
  );
233
233
  if (Array.isArray(l)) {
234
- const [d = "span", u = s.attrs] = l, p = { ...u, data: void 0 };
235
- c = n(d, p, c || e.text);
234
+ const [p = "span", d = s.attrs] = l, g = { ...d, data: void 0 };
235
+ c = n(p, g, c || e.text);
236
236
  } else
237
237
  c = { ...l, text: e.text };
238
238
  }), c;
@@ -262,27 +262,27 @@ const He = async (e) => {
262
262
  themeName: c,
263
263
  tokens: s,
264
264
  customTheme: l
265
- } = e, m = JSON.parse(JSON.stringify(r)), d = ze(n, t);
265
+ } = e, m = JSON.parse(JSON.stringify(r)), p = ze(n, t);
266
266
  return Fe(
267
267
  m,
268
- d,
268
+ p,
269
269
  // @ts-expect-error Expects ReactNode
270
- (u, p, f) => {
270
+ (d, g, u) => {
271
271
  const y = {
272
- ...p,
272
+ ...g,
273
273
  style: void 0
274
- }, N = Me(o, y), b = (i == null ? void 0 : i[u]) ?? (E == null ? void 0 : E[u]);
275
- return b ? b({ children: f, attrs: N, themeName: c, tokens: s, customTheme: l }) : /* @__PURE__ */ g(
274
+ }, N = Me(o, y), b = d, f = (i == null ? void 0 : i[b]) ?? (E == null ? void 0 : E[b]);
275
+ return f ? f({ children: u, attrs: N, themeName: c, tokens: s, customTheme: l }) : /* @__PURE__ */ k(
276
276
  C,
277
277
  {
278
- as: u,
278
+ as: d,
279
279
  ...N,
280
280
  themeName: c,
281
281
  tokens: s,
282
282
  customTheme: l,
283
- children: f
283
+ children: u
284
284
  },
285
- JSON.stringify(f)
285
+ JSON.stringify(u)
286
286
  );
287
287
  }
288
288
  );
@@ -304,9 +304,9 @@ const He = async (e) => {
304
304
  ue,
305
305
  ee,
306
306
  pe,
307
- ge,
308
- ye,
309
307
  ke,
308
+ ye,
309
+ ge,
310
310
  be,
311
311
  fe,
312
312
  de
@@ -321,43 +321,43 @@ const He = async (e) => {
321
321
  themeName: s,
322
322
  tokens: l,
323
323
  customTheme: m,
324
- remappedAttributes: d
325
- } = e, u = qe(n, r), p = t ?? [...Ue] ?? [], f = (k, B) => {
324
+ remappedAttributes: p
325
+ } = e, d = qe(n, r), g = t ?? [...Ue] ?? [], u = (f, B) => {
326
326
  var w, O, P;
327
- const { attrs: a } = k, Q = `${(w = a == null ? void 0 : a.collection) == null ? void 0 : w.replace("related_", "")}_id`;
327
+ const { attrs: a } = f, Q = `${(w = a == null ? void 0 : a.collection) == null ? void 0 : w.replace("related_", "")}_id`;
328
328
  if (a != null && a.data) {
329
329
  if (!((O = a == null ? void 0 : a.data) != null && O.blocks)) {
330
330
  const h = { collection: a.collection, item: { ...a == null ? void 0 : a.data } };
331
- return /* @__PURE__ */ g(R, { block: h, config: B }, JSON.stringify(h));
331
+ return /* @__PURE__ */ k(R, { block: h, config: B }, JSON.stringify(h));
332
332
  }
333
333
  const S = (P = a == null ? void 0 : a.data) == null ? void 0 : P.blocks, U = S == null ? void 0 : S.map((h) => ({ item: h == null ? void 0 : h[Q], collection: a == null ? void 0 : a.collection }));
334
- return /* @__PURE__ */ g(R, { blocks: U, config: B }, JSON.stringify(S));
334
+ return /* @__PURE__ */ k(R, { blocks: U, config: B }, JSON.stringify(S));
335
335
  }
336
336
  return null;
337
337
  }, y = A.create({
338
338
  name: "relation-block",
339
339
  renderHTML: () => ["relation-block"],
340
- render: (k) => f(k, o)
340
+ render: (f) => u(f, o)
341
341
  }), N = A.create({
342
342
  name: "relation-inline-block",
343
343
  renderHTML: () => ["relation-inline-block"],
344
- render: (k) => f(k, o)
344
+ render: (f) => u(f, o)
345
345
  }), b = x.create({
346
346
  name: "relation-mark",
347
347
  type: "relation-mark",
348
348
  renderHTML: () => ["relation-mark"],
349
- render: (k) => f(k, c)
349
+ render: (f) => u(f, c)
350
350
  });
351
- return p.push(y, N, b), u ? /* @__PURE__ */ g(
351
+ return g.push(y, N, b), d ? /* @__PURE__ */ k(
352
352
  Qe,
353
353
  {
354
- content: u,
355
- serializers: p,
354
+ content: d,
355
+ serializers: g,
356
356
  renderingNodes: i,
357
357
  themeName: s,
358
358
  tokens: l,
359
359
  customTheme: m,
360
- remappedAttributes: d
360
+ remappedAttributes: p
361
361
  }
362
362
  ) : null;
363
363
  };
@@ -1,2 +1,2 @@
1
- declare const _default: (import("@tiptap/core").Node<any, any> | import("@tiptap/core").Extension<import("@tiptap/extension-text-align").TextAlignOptions, any> | import("@tiptap/core").Mark<import("@tiptap/extension-subscript").SubscriptExtensionOptions, any>)[];
1
+ declare const _default: (import('@tiptap/core').Node<any, any> | import('@tiptap/core').Extension<import('@tiptap/extension-text-align').TextAlignOptions, any> | import('@tiptap/core').Mark<import('@tiptap/extension-subscript').SubscriptExtensionOptions, any>)[];
2
2
  export default _default;
@@ -1,7 +1,8 @@
1
- import type { TBlockSerializerConfig } from '@okam/directus-block';
2
- import type { TDefaultComponent } from '@okam/stack-ui';
3
- import type { JSONContent, Extensions, EditorNodes } from '../../functions/types';
4
- import type { TRenderingNodes } from '../nodes/types';
1
+ import { TBlockSerializerConfig } from '../../../../../directus-block/src/index.ts';
2
+ import { TDefaultComponent } from '../../../../../../stack/stack-ui/src/index.ts';
3
+ import { JSONContent, Extensions, EditorNodes } from '../../functions/types';
4
+ import { TRenderingNodes } from '../nodes/types';
5
+
5
6
  interface FlexibleEditorContentProps extends TDefaultComponent {
6
7
  jsonContent: JSONContent;
7
8
  editorNodes?: EditorNodes[] | undefined | null;
@@ -1,7 +1,8 @@
1
- import type { TDefaultComponent } from '@okam/stack-ui';
2
- import type { FunctionComponent } from 'react';
3
- import type { JSONContent, Extensions, ReactComponentSerializers } from '../../functions/types';
4
- import type { TRenderingNodes } from '../nodes/types';
1
+ import { TDefaultComponent } from '../../../../../../stack/stack-ui/src/index.ts';
2
+ import { ReactNode } from 'react';
3
+ import { JSONContent, Extensions, ReactComponentSerializers } from '../../functions/types';
4
+ import { TRenderingNodes } from '../nodes/types';
5
+
5
6
  interface RenderNodesProps extends TDefaultComponent {
6
7
  content: JSONContent;
7
8
  serializers?: Extensions;
@@ -9,5 +10,5 @@ interface RenderNodesProps extends TDefaultComponent {
9
10
  renderingNodes?: TRenderingNodes;
10
11
  remappedAttributes?: Record<string, string>;
11
12
  }
12
- declare const RenderNodes: FunctionComponent<RenderNodesProps>;
13
+ declare const RenderNodes: (props: RenderNodesProps) => ReactNode;
13
14
  export default RenderNodes;
@@ -1,3 +1,4 @@
1
- import type { TRenderingNodes } from './types';
1
+ import { TRenderingNodes } from './types';
2
+
2
3
  declare const nodes: TRenderingNodes;
3
4
  export default nodes;
@@ -1,8 +1,10 @@
1
- import type { TDefaultComponent } from '@okam/stack-ui';
1
+ import { TDefaultComponent } from '../../../../../../stack/stack-ui/src/index.ts';
2
+ import { default as React } from 'react';
3
+
2
4
  export interface TBaseRenderingNode extends TDefaultComponent {
3
5
  children: React.ReactNode;
4
6
  attrs?: Record<string, number | string | boolean | undefined>;
5
7
  }
6
8
  export type TRenderingNodes = {
7
- [key in keyof JSX.IntrinsicElements]?: (props: TBaseRenderingNode) => JSX.Element;
9
+ [key in keyof React.JSX.IntrinsicElements]?: (props: TBaseRenderingNode) => React.JSX.Element;
8
10
  };
@@ -1,4 +1,5 @@
1
- import type { JSONContent } from '@tiptap/core';
2
- import type { EditorNodes } from './types';
1
+ import { JSONContent } from '@tiptap/core';
2
+ import { EditorNodes } from './types';
3
+
3
4
  declare const injectDataIntoContent: (data: EditorNodes[] | undefined | null, content: JSONContent, primaryKeyField?: string, itemField?: string) => JSONContent | null;
4
5
  export default injectDataIntoContent;
@@ -1,3 +1,4 @@
1
- import type { Extensions, ComponentSerializers } from './types';
1
+ import { Extensions, ComponentSerializers } from './types';
2
+
2
3
  declare const mergeSerializers: <T>(serializers: Extensions, componentSerializers: ComponentSerializers<T>) => Extensions;
3
4
  export default mergeSerializers;
@@ -1,4 +1,5 @@
1
- import type { ReactNode } from 'react';
2
- import type { JSONContent, Extensions, RenderedNode, RenderCallback } from './types';
1
+ import { ReactNode } from 'react';
2
+ import { JSONContent, Extensions, RenderedNode, RenderCallback } from './types';
3
+
3
4
  declare const renderView: <T>(node: JSONContent, serializers: Extensions, renderCallback: RenderCallback<ReactNode | JSONContent[]>) => RenderedNode<T>;
4
5
  export default renderView;
@@ -1,6 +1,7 @@
1
- import type { TBlock } from '@okam/directus-block';
2
- import type { JSONContent, Extensions, AnyExtension } from '@tiptap/core';
3
- import type { ElementType, FunctionComponent, ReactNode } from 'react';
1
+ import { TBlock } from '../../../../directus-block/src/index.ts';
2
+ import { JSONContent, Extensions, AnyExtension } from '@tiptap/core';
3
+ import { ElementType, FunctionComponent, ReactNode } from 'react';
4
+
4
5
  export type { JSONContent, Extensions };
5
6
  export type RenderedNode<T> = T | string | (T | string)[];
6
7
  export type Tag = ElementType;
package/lib/types.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import type { TCommonBlockFragment } from '@okam/directus-block';
1
+ import { TCommonBlockFragment } from '../../../directus-block/src/index.ts';
2
+
2
3
  export type RelationBlockSerializers<T> = {
3
4
  collection: string;
4
5
  component: T;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@okam/directus-flexible-content",
3
- "version": "1.2.23",
3
+ "version": "1.2.24",
4
4
  "main": "./index.js",
5
5
  "types": "./index.d.ts",
6
6
  "exports": {
@@ -23,8 +23,8 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@nx/vite": "20.2.2",
26
- "@okam/directus-block": "1.6.1",
27
- "@okam/stack-ui": "1.42.4",
26
+ "@okam/directus-block": "1.6.2",
27
+ "@okam/stack-ui": "1.43.0",
28
28
  "@vitejs/plugin-react": "4.3.4",
29
29
  "vite": "^5.0.13",
30
30
  "vite-plugin-dts": "~2.3.0",
@@ -51,7 +51,12 @@
51
51
  "@tiptap/extension-table-row": "^2.10.3",
52
52
  "@tiptap/extension-text": "^2.10.3",
53
53
  "@tiptap/extension-text-align": "^2.10.3",
54
- "@tiptap/core": "^2.10.3",
55
- "react": "18.3.1"
54
+ "@tiptap/core": "^2.10.3"
55
+ },
56
+ "peerDependencies": {
57
+ "react": "^18.0.0 || ^19.0.0"
58
+ },
59
+ "devDependencies": {
60
+ "react": "^19.0.0"
56
61
  }
57
62
  }