@donotdev/ui 0.2.3 → 0.3.1
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/ChildRowsPicker-63M4EQUQ.js +1 -0
- package/dist/ChildRowsPicker-ISP365ON.js +1 -0
- package/dist/ChildRowsPicker-PQFE6NCR.js +1 -0
- package/dist/ChildRowsPicker-XXFFSMWY.js +1 -0
- package/dist/GoToDialog-XBK5EZF4.js +1 -0
- package/dist/chunk-3CIZFGST.js +1 -0
- package/dist/chunk-LHMKU342.js +1 -0
- package/dist/chunk-P2DHZWPY.js +1 -0
- package/dist/components/layout/components/Breadcrumbs.d.ts.map +1 -1
- package/dist/components/layout/components/Breadcrumbs.js +4 -3
- package/dist/components/layout/components/header/HeaderMenu.d.ts +17 -16
- package/dist/components/layout/components/header/HeaderMenu.d.ts.map +1 -1
- package/dist/components/layout/components/header/HeaderMenu.js +51 -23
- package/dist/components/layout/components/header/SettingsMenu.js +2 -2
- package/dist/crud/components/ChildRowsPicker.d.ts +21 -0
- package/dist/crud/components/ChildRowsPicker.d.ts.map +1 -0
- package/dist/crud/components/ChildRowsPicker.js +68 -0
- package/dist/crud/components/EntityCardList.d.ts.map +1 -1
- package/dist/crud/components/EntityCardList.js +9 -17
- package/dist/crud/components/EntityDisplayRenderer.js +2 -2
- package/dist/crud/components/EntityFormRenderer.d.ts +4 -2
- package/dist/crud/components/EntityFormRenderer.d.ts.map +1 -1
- package/dist/crud/components/EntityFormRenderer.js +137 -55
- package/dist/crud/components/EntityList.d.ts +3 -1
- package/dist/crud/components/EntityList.d.ts.map +1 -1
- package/dist/crud/components/EntityList.js +324 -56
- package/dist/crud/components/EntityRecommendations.js +1 -1
- package/dist/crud/components/EntityWorkflow.d.ts.map +1 -1
- package/dist/crud/components/EntityWorkflow.js +6 -4
- package/dist/crud/components/cellEditFor.d.ts +23 -8
- package/dist/crud/components/cellEditFor.d.ts.map +1 -1
- package/dist/crud/components/cellEditFor.js +40 -20
- package/dist/crud/components/entityParent.d.ts +8 -15
- package/dist/crud/components/entityParent.d.ts.map +1 -1
- package/dist/crud/components/entityParent.js +30 -8
- package/dist/crud/components/useRecordBreadcrumb.d.ts +1 -1
- package/dist/crud/components/useRecordBreadcrumb.d.ts.map +1 -1
- package/dist/crud/components/useRecordBreadcrumb.js +12 -3
- package/dist/crud/crudImports.d.ts +11 -2
- package/dist/crud/crudImports.d.ts.map +1 -1
- package/dist/crud/crudImports.js +10 -1
- package/dist/dndev-next.css +374 -57
- package/dist/dndev.css +376 -57
- package/dist/index.js +4 -4
- package/dist/internal/initializers/NextJsStoresInitializer.d.ts +3 -0
- package/dist/internal/initializers/NextJsStoresInitializer.d.ts.map +1 -1
- package/dist/internal/initializers/NextJsStoresInitializer.js +8 -1
- package/dist/internal/layout/components/AutoMetaTags.d.ts.map +1 -1
- package/dist/internal/layout/components/AutoMetaTags.js +3 -2
- package/dist/internal/layout/components/FontPreloadLinks.d.ts +7 -4
- package/dist/internal/layout/components/FontPreloadLinks.d.ts.map +1 -1
- package/dist/internal/layout/components/FontPreloadLinks.js +12 -25
- package/dist/internal/layout/components/footer/FooterCopyright.d.ts +2 -0
- package/dist/internal/layout/components/footer/FooterCopyright.d.ts.map +1 -1
- package/dist/internal/layout/components/footer/FooterCopyright.js +4 -0
- package/dist/internal/layout/components/footer/useLegalLinks.d.ts +2 -1
- package/dist/internal/layout/components/footer/useLegalLinks.d.ts.map +1 -1
- package/dist/internal/layout/components/footer/useLegalLinks.js +4 -3
- package/dist/internal/providers/UIProviders.d.ts +0 -8
- package/dist/internal/providers/UIProviders.d.ts.map +1 -1
- package/dist/internal/providers/UIProviders.js +39 -1
- package/dist/providers/NextJsAppProviders.d.ts.map +1 -1
- package/dist/providers/NextJsAppProviders.js +1 -2
- package/dist/providers/ViteAppProviders.d.ts.map +1 -1
- package/dist/providers/ViteAppProviders.js +1 -4
- package/dist/routing/404.d.ts +8 -1
- package/dist/routing/404.d.ts.map +1 -1
- package/dist/routing/404.js +6 -2
- package/dist/routing/hooks/hooks.next.js +1 -1
- package/dist/routing/hooks/useRedirectGuard.next.d.ts +3 -1
- package/dist/routing/hooks/useRedirectGuard.next.d.ts.map +1 -1
- package/dist/routing/hooks/useRedirectGuard.next.js +11 -9
- package/dist/routing/parentRoute.d.ts +27 -0
- package/dist/routing/parentRoute.d.ts.map +1 -0
- package/dist/routing/parentRoute.js +43 -0
- package/dist/routing/useNavigation.d.ts.map +1 -1
- package/dist/routing/useNavigation.js +5 -24
- package/dist/routing/useRouteDiscovery.d.ts +2 -2
- package/dist/routing/useRouteDiscovery.d.ts.map +1 -1
- package/dist/routing/useRouteDiscovery.js +6 -5
- package/dist/styles/index.css +373 -56
- package/dist/symbol-index.json +1 -1
- package/guidelines/COMPONENTS.md +1 -1
- package/guidelines/GOTCHAS.md +2 -0
- package/guidelines/LAYOUTS.md +4 -0
- package/guidelines/PAGES.md +23 -3
- package/guidelines/ROUTING.md +26 -1
- package/guidelines/SEO.md +1 -1
- package/package.json +8 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{g as p,n as u,t as g,v as m,w as f}from"./chunk-P2DHZWPY.js";import"./chunk-O2XFH626.js";import{useState as I}from"react";import{Button as k,DataTable as L,Dialog as D,Stack as P,Text as E}from"@donotdev/components";import{useTranslation as w}from"@donotdev/core";import{jsx as i,jsxs as R}from"react/jsx-runtime";function F({entity:t,excludedIds:h,onPick:b,onClose:l}){let{t:s}=w([t.namespace,"crud"]),{t:o}=w("crud"),a=p(t,{pagination:"client"}),y=u(t),[r,v]=I([]),c=a.processed.filter(e=>!h.has(e.id)),d=t.listFields||Object.keys(t.fields),C=d.flatMap(e=>{let n=t.fields[e];return n?[{key:e,title:m(e,n,s),dataIndex:e,sortable:!0,render:(x,S)=>f(x,n,s,{compact:!0,referenceData:y,item:S})}]:[]}),T=s("name",{defaultValue:t.name});return i(D,{open:!0,onOpenChange:e=>{e||l()},title:o("childRows.pickTitle",{entity:T}),footer:R(P,{direction:"row",gap:"tight",justify:"end",children:[i(k,{variant:"outline",onClick:l,children:o("actions.cancel")}),i(k,{intent:"add",disabled:r.length===0,onClick:()=>{b(r),l()},children:o("childRows.pickConfirm",{count:r.length})})]}),children:R(P,{children:[i(g,{entity:t,data:a.items,fieldsToFilter:d}),!a.loading&&c.length===0?i(E,{level:"body",children:o("childRows.pickEmpty")}):i(L,{data:c,columns:C,sortable:!0,searchable:!1,pagination:!0,loading:a.loading,selectable:!0,getRowId:e=>e.id,onSelect:e=>v(e.map(n=>n.id)),showingLabel:o("pagination.showing"),paginationPreviousLabel:o("pagination.previous"),paginationNextLabel:o("pagination.next"),paginationItemsPerPagePlaceholder:o("pagination.itemsPerPagePlaceholder")})]})})}export{F as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{A as b,g as m,k as f,n as h,t as k,v as w,w as P,z as R}from"./chunk-P2DHZWPY.js";import"./chunk-O2XFH626.js";import{Search as V}from"lucide-react";import{useState as v}from"react";import{Button as y,DataTable as j,Dialog as M,Input as U,Stack as C,Text as _}from"@donotdev/components";import{useTranslation as S}from"@donotdev/core";import{jsx as i,jsxs as T}from"react/jsx-runtime";var $="deleted";function q({entity:t,excludedIds:x,viewerRole:E,onPick:I,onClose:a}){let{t:l}=S([t.namespace,"crud"]),{t:o}=S("crud"),r=m(t,{pagination:"client"}),D=h(t),[s,F]=v([]),[c,L]=v(""),d=`${t.collection}#picker`,{filters:A}=f({collection:d}),p=r.items.filter(e=>e.status!==$&&!x.has(e.id)),u=b(R(p,A,t),c,t),g=t.listFields||Object.keys(t.fields),B=g.flatMap(e=>{let n=t.fields[e];return n?[{key:e,title:w(e,n,l),dataIndex:e,sortable:!0,render:(O,Q)=>P(O,n,l,{compact:!0,referenceData:D,item:Q})}]:[]}),K=l("name",{defaultValue:t.name});return i(M,{open:!0,onOpenChange:e=>{e||a()},title:o("childRows.pickTitle",{entity:K}),footer:T(C,{direction:"row",gap:"tight",justify:"end",children:[i(y,{variant:"outline",onClick:a,children:o("actions.cancel")}),i(y,{intent:"add",disabled:s.length===0,onClick:()=>{I(s),a()},children:o("childRows.pickConfirm",{count:s.length})})]}),children:T(C,{children:[i(k,{entity:t,data:p,fieldsToFilter:g,viewerRole:E,filterKey:d}),i(U,{placeholder:o("actions.searchPlaceholder"),value:c,onChange:e=>L(e.target.value),icon:V,className:"dndev-w-full"}),!r.loading&&u.length===0?i(_,{level:"body",children:o("childRows.pickEmpty")}):i(j,{data:u,columns:B,sortable:!0,searchable:!1,pagination:!0,loading:r.loading,selectable:!0,getRowId:e=>e.id,onSelect:e=>F(e.map(n=>n.id)),showingLabel:o("pagination.showing"),paginationPreviousLabel:o("pagination.previous"),paginationNextLabel:o("pagination.next"),paginationItemsPerPagePlaceholder:o("pagination.itemsPerPagePlaceholder")})]})})}export{q as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{g as m,k as f,n as h,t as k,v as P,w as R,y as w,z as v}from"./chunk-LHMKU342.js";import"./chunk-O2XFH626.js";import{Search as V}from"lucide-react";import{useState as b}from"react";import{Button as y,DataTable as j,Dialog as M,Input as $,Stack as C,Text as q}from"@donotdev/components";import{statusCan as z,useTranslation as S}from"@donotdev/core";import{jsx as i,jsxs as T}from"react/jsx-runtime";function G({entity:t,excludedIds:x,viewerRole:I,onPick:F,onClose:a}){let{t:l}=S([t.namespace,"crud"]),{t:o}=S("crud"),s=m(t,{pagination:"client"}),L=h(t),[r,D]=b([]),[c,E]=b(""),d=`${t.collection}#picker`,{filters:B}=f({collection:d}),u=s.items.filter(e=>!z(typeof e.status=="string"?e.status:null,"isRemoved")&&!x.has(e.id)),p=v(w(u,B,t),c,t),g=t.listFields||Object.keys(t.fields),A=g.flatMap(e=>{let n=t.fields[e];return n?[{key:e,title:P(e,n,l),dataIndex:e,sortable:!0,render:(O,Q)=>R(O,n,l,{compact:!0,referenceData:L,item:Q})}]:[]}),K=l("name",{defaultValue:t.name});return i(M,{open:!0,onOpenChange:e=>{e||a()},title:o("childRows.pickTitle",{entity:K}),footer:T(C,{direction:"row",gap:"tight",justify:"end",children:[i(y,{variant:"outline",onClick:a,children:o("actions.cancel")}),i(y,{intent:"add",disabled:r.length===0,onClick:()=>{F(r),a()},children:o("childRows.pickConfirm",{count:r.length})})]}),children:T(C,{children:[i(k,{entity:t,data:u,fieldsToFilter:g,viewerRole:I,filterKey:d}),i($,{placeholder:o("actions.searchPlaceholder"),value:c,onChange:e=>E(e.target.value),icon:V,className:"dndev-w-full"}),!s.loading&&p.length===0?i(q,{level:"body",children:o("childRows.pickEmpty")}):i(j,{data:p,columns:A,sortable:!0,searchable:!1,pagination:!0,loading:s.loading,selectable:!0,getRowId:e=>e.id,onSelect:e=>D(e.map(n=>n.id)),showingLabel:o("pagination.showing"),paginationPreviousLabel:o("pagination.previous"),paginationNextLabel:o("pagination.next"),paginationItemsPerPagePlaceholder:o("pagination.itemsPerPagePlaceholder")})]})})}export{G as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{g as m,k as f,n as h,t as k,v as w,w as P,y as R,z as b}from"./chunk-LHMKU342.js";import"./chunk-O2XFH626.js";import{Search as V}from"lucide-react";import{useState as v}from"react";import{Button as y,DataTable as j,Dialog as M,Input as U,Stack as C,Text as _}from"@donotdev/components";import{useTranslation as S}from"@donotdev/core";import{jsx as i,jsxs as T}from"react/jsx-runtime";var $="deleted";function q({entity:t,excludedIds:x,viewerRole:E,onPick:I,onClose:a}){let{t:l}=S([t.namespace,"crud"]),{t:o}=S("crud"),r=m(t,{pagination:"client"}),D=h(t),[s,F]=v([]),[c,L]=v(""),d=`${t.collection}#picker`,{filters:A}=f({collection:d}),p=r.items.filter(e=>e.status!==$&&!x.has(e.id)),u=b(R(p,A,t),c,t),g=t.listFields||Object.keys(t.fields),B=g.flatMap(e=>{let n=t.fields[e];return n?[{key:e,title:w(e,n,l),dataIndex:e,sortable:!0,render:(O,Q)=>P(O,n,l,{compact:!0,referenceData:D,item:Q})}]:[]}),K=l("name",{defaultValue:t.name});return i(M,{open:!0,onOpenChange:e=>{e||a()},title:o("childRows.pickTitle",{entity:K}),footer:T(C,{direction:"row",gap:"tight",justify:"end",children:[i(y,{variant:"outline",onClick:a,children:o("actions.cancel")}),i(y,{intent:"add",disabled:s.length===0,onClick:()=>{I(s),a()},children:o("childRows.pickConfirm",{count:s.length})})]}),children:T(C,{children:[i(k,{entity:t,data:p,fieldsToFilter:g,viewerRole:E,filterKey:d}),i(U,{placeholder:o("actions.searchPlaceholder"),value:c,onChange:e=>L(e.target.value),icon:V,className:"dndev-w-full"}),!r.loading&&u.length===0?i(_,{level:"body",children:o("childRows.pickEmpty")}):i(j,{data:u,columns:B,sortable:!0,searchable:!1,pagination:!0,loading:r.loading,selectable:!0,getRowId:e=>e.id,onSelect:e=>F(e.map(n=>n.id)),showingLabel:o("pagination.showing"),paginationPreviousLabel:o("pagination.previous"),paginationNextLabel:o("pagination.next"),paginationItemsPerPagePlaceholder:o("pagination.itemsPerPagePlaceholder")})]})})}export{q as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as u,i as T}from"./chunk-3CIZFGST.js";import"./chunk-O2XFH626.js";import{Link as G,Star as I}from"lucide-react";import{useCallback as k,useEffect as D,useRef as O}from"react";import{Badge as S,Command as R,CommandDialog as F}from"@donotdev/components";import{useOverlayStore as v,useTranslation as A}from"@donotdev/core";import{jsx as o,jsxs as t}from"react/jsx-runtime";var E=()=>{let{t:e}=A("dndev"),d=O(null),m=v(a=>a.isCommandDialogOpen),r=v(a=>a.closeCommandDialog),{navigationItems:f,favoriteItems:s,recentItems:i,toggleFavorite:b,isFavorite:c,navigateToItem:h}=T();D(()=>{m&&requestAnimationFrame(()=>{d.current?.focus()})},[m]);let C=k(a=>{h(a),r()},[h,r]),p=k((a,g=!0)=>a.map(n=>({label:n.label,value:n.path,description:n.path!==n.label?n.path:void 0,icon:o(u,{icon:n.icon,fallback:G}),badge:n.badge?o(S,{children:n.badge}):void 0,onSelect:()=>C(n.path),rightSlot:g?o("button",{type:"button",onClick:y=>{y.stopPropagation(),b(n.path)},className:"dndev-command-favorite-button","data-favorited":c(n.path),"aria-label":c(n.path)?e("globalGoTo.unfavorite","Remove from favorites"):e("globalGoTo.favorite","Add to favorites"),children:o(u,{icon:I,className:"dndev-size-sm"})}):void 0})),[C,b,c,e]),l=[];if(s.length>0&&l.push({heading:e("globalGoTo.favorites","Favorites"),items:p(s,!1)}),i.length>0){let a=i.flatMap(g=>p([g],!0));a.length>0&&l.push({heading:e("globalGoTo.recent","Recent"),separator:s.length>0,items:a})}l.push({heading:e("globalGoTo.allPages","All Pages"),separator:s.length>0||i.length>0,items:p(f)});let N=f.length>0;return t(F,{open:m,onOpenChange:a=>a?null:r(),children:[o(R,{placeholder:e("globalGoTo.placeholder","Search pages..."),emptyMessage:N?e("globalGoTo.noResults","No results found."):e("globalGoTo.empty","No pages available."),groups:l}),o("div",{className:"dndev-command-footer",children:t("div",{className:"dndev-command-footer-shortcuts",children:[t("div",{className:"dndev-command-footer-shortcut",children:[o("kbd",{className:"dndev-command-footer-key",children:"\u2318K"}),o("span",{children:e("globalGoTo.shortcutOpen","Open")})]}),t("div",{className:"dndev-command-footer-shortcut",children:[o("kbd",{className:"dndev-command-footer-key",children:"\u2191"}),o("kbd",{className:"dndev-command-footer-key",children:"\u2193"}),o("span",{children:e("globalGoTo.shortcutNavigate","Navigate")})]}),t("div",{className:"dndev-command-footer-shortcut",children:[o("kbd",{className:"dndev-command-footer-key",children:"\u21B5"}),o("span",{children:e("globalGoTo.shortcutSelect","Select")})]}),t("div",{className:"dndev-command-footer-shortcut",children:[o("kbd",{className:"dndev-command-footer-key",children:"Esc"}),o("span",{children:e("globalGoTo.shortcutClose","Close")})]})]})})]})},L=()=>v(d=>d.isCommandDialogOpen)?o(E,{}):null,K=L;export{K as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as p from"lucide-react";import{isValidElement as P}from"react";import{cn as f}from"@donotdev/components";import*as b from"lucide-react";var x=b;function C(e){return typeof e=="function"||typeof e=="object"&&e!==null&&"render"in e}function y(e){let t=x[e];return C(t)?t:void 0}import{jsx as c}from"react/jsx-runtime";function S(e){if(!e)return p.Palette;let t=e.replace(/['"]/g,"");return y(t)||p.Palette}var k=({icon:e,fallback:t,className:i,ariaHidden:s=!1})=>{let o=e||t;if(!o)return null;let a="dndev-size-md";if(typeof o=="function"||typeof o=="object"&&o!==null&&"render"in o)return c(o,{className:f(a,i),style:{flexShrink:0},"aria-hidden":s});if(typeof o=="string"){if(!/^[a-zA-Z0-9_-]+$/.test(o))return c("span",{className:f(a,i),style:{display:"inline-flex",alignItems:"center",justifyContent:"center"},"aria-hidden":s,children:o});let d=S(o);return c(d,{className:f(a,i),style:{flexShrink:0},"aria-hidden":s})}return P(o)?c("span",{className:i,style:{display:"inline-flex",alignItems:"center",justifyContent:"center"},"aria-hidden":s,children:o}):c("span",{className:i,style:{display:"inline-flex",alignItems:"center",justifyContent:"center"},"aria-hidden":s,children:o})},W=k;import*as h from"@donotdev/auth";import{DEGRADED_AUTH_API as T}from"@donotdev/core";var m=h?.useAuth;function E(e){return T[e]}function v(e){return m?m(e):E(e)}var B=typeof m=="function",J=h?.PasswordResetCallback??(()=>null);import{useMemo as A}from"react";import{filterNavigationRoutes as K,useNavigationStore as j,useTranslation as F}from"@donotdev/core";import{USER_ROLES as w}from"@donotdev/core";import{useRoutePath as U}from"@donotdev/ui/routing/hooks";function g(){let e=U(),t=v("user"),i=!!t,{t:s}=F(),o=t?.role||w.GUEST,a=j(r=>r.cache.allRoutes);return A(()=>K(a,{authenticated:i,role:o}).map(r=>({...r,label:_(r,s),isActive:D(r.path,e),hasChildren:!1,children:void 0})).sort((r,l)=>r.label.localeCompare(l.label,void 0,{sensitivity:"base"})),[a,i,o,e,s])}function oe(e){let t=g();return A(()=>t.find(i=>i.path===e),[t,e])}function _(e,t){let i=e.meta?.namespace;return typeof i!="string"||i===""?e.label:t(`${i}:title`,{defaultValue:e.label})}function D(e,t){return e==="/"?t==="/":t===e?!0:t.startsWith(e+"/")}import{useCallback as V}from"react";import{useNavigationStore as u}from"@donotdev/core";import{useNavigate as z}from"@donotdev/ui/routing/hooks";var ue=()=>{let e=z(),t=g()??[],i=u(n=>n.favorites),s=u(n=>n.recent),o=u(n=>n.toggleFavorite),a=u(n=>n.isFavorite),r=u(n=>n.addRecent),l=t.length?t.filter(n=>i.includes(n.path)):[],d=t.length?t.filter(n=>s.includes(n.path)).slice(0,5):[],R=n=>{o(n)},L=n=>a(n),I=n=>{r(n)},N=V(n=>{I(n),e(n)},[e,I]);return{navigationItems:t,favoriteItems:l,recentItems:d,toggleFavorite:R,isFavorite:L,navigateToItem:N}};export{y as a,k as b,W as c,v as d,B as e,J as f,g,oe as h,ue as i};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as e from"@donotdev/crud";var r=typeof e?.useCrud=="function",o=e?.useEntityForm,t=e?.useFormStore,s=e?.FormNavigationProvider,n=e?.useFormError,u=e?.useFieldConditions,i=e?.useCrud,d=e?.useCrudList,l=e?.useCrudDoc,a=e?.useCrudCardList,p=e?.useEntityFavorites,c=e?.useCrudFilters,F=e?.useCrudPageSize,x=e?.useEntityWorkflow,C=e?.useReferenceResolver,m=e?.useChildRows,y=e?.useJoinedForm,v=e?.DisplayFieldRenderer,E=e?.FormFieldRenderer,R=e?.UploadProvider,f=e?.EntityFilters,L=e?.CrudCard,P=e?.translateFieldLabel,S=e?.formatValue,b=e?.translateLabel,g=e?.applyFilters,h=e?.applySearch;export{r as a,o as b,t as c,n as d,u as e,i as f,d as g,l as h,a as i,p as j,c as k,F as l,x as m,C as n,m as o,y as p,v as q,E as r,R as s,f as t,L as u,P as v,S as w,b as x,g as y,h as z};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as e from"@donotdev/crud";var r=typeof e?.useCrud=="function",o=e?.useEntityForm,t=e?.useFormStore,s=e?.FormNavigationProvider,i=e?.useFormError,n=e?.useFieldConditions,u=e?.useCrud,d=e?.useCrudList,l=e?.useCrudDoc,a=e?.useCrudCardList,p=e?.useEntityFavorites,c=e?.useCrudFilters,F=e?.useCrudPageSize,x=e?.useEntityWorkflow,C=e?.useReferenceResolver,m=e?.useChildRows,y=e?.useJoinedForm,E=e?.DisplayFieldRenderer,v=e?.FormFieldRenderer,R=e?.UploadProvider,f=e?.EntityFilters,L=e?.CrudCard,b=e?.translateFieldLabel,P=e?.formatValue,S=e?.translateLabel,g=e?.isFieldEditable,h=e?.applyFilters,w=e?.applySearch;export{r as a,o as b,t as c,i as d,n as e,u as f,d as g,l as h,a as i,p as j,c as k,F as l,x as m,C as n,m as o,y as p,E as q,v as r,R as s,f as t,L as u,b as v,P as w,S as x,g as y,h as z,w as A};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Breadcrumbs.d.ts","sourceRoot":"","sources":["../../../../src/components/layout/components/Breadcrumbs.tsx"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Breadcrumbs.d.ts","sourceRoot":"","sources":["../../../../src/components/layout/components/Breadcrumbs.tsx"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAW3C,yCAAyC;AACzC,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,aAAa,CAAC;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC9C;AAED,2CAA2C;AAC3C,MAAM,WAAW,gBAAgB;IAC/B,+EAA+E;IAC/E,KAAK,CAAC,EAAE,cAAc,EAAE,CAAC;IACzB,iCAAiC;IACjC,SAAS,CAAC,EAAE,aAAa,CAAC;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClD,8BAA8B;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,uBAAuB;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iCAAiC;IACjC,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;GAQG;AACH,QAAA,MAAM,WAAW,EAAE,aAAa,CAAC,gBAAgB,CAqFhD,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -23,6 +23,7 @@ import { useLayout, useTranslation } from '@donotdev/core';
|
|
|
23
23
|
// Platform-specific hooks via conditional exports
|
|
24
24
|
import { useRoutePath } from '@donotdev/ui/routing/hooks';
|
|
25
25
|
import { Link } from '../../../routing/Link';
|
|
26
|
+
import { getPathPrefixes } from '../../../routing/parentRoute';
|
|
26
27
|
import { useAllRoutes } from '../../../routing/useRouteDiscovery';
|
|
27
28
|
/**
|
|
28
29
|
* Breadcrumbs component for navigation
|
|
@@ -48,10 +49,10 @@ const Breadcrumbs = ({ items, separator: Separator = ChevronRight, showHome = tr
|
|
|
48
49
|
? items
|
|
49
50
|
: (() => {
|
|
50
51
|
const pathSegments = pathname.split('/').filter(Boolean);
|
|
52
|
+
const prefixes = getPathPrefixes(pathname);
|
|
51
53
|
const breadcrumbs = [];
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
currentPath += `/${segment}`;
|
|
54
|
+
pathSegments.forEach((segment, index) => {
|
|
55
|
+
const currentPath = prefixes[index] ?? '';
|
|
55
56
|
// A record id segment shows the record's name, not the raw id
|
|
56
57
|
const label = recordLabel && decodeURIComponent(segment) === recordLabel.id
|
|
57
58
|
? recordLabel.label
|
|
@@ -1,37 +1,38 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
/** Props for the HeaderMenu component. */
|
|
3
3
|
export interface HeaderMenuProps {
|
|
4
|
-
/**
|
|
4
|
+
/** Header controls: inline from laptop up, in the burger panel below */
|
|
5
5
|
children: ReactNode;
|
|
6
6
|
/** Additional CSS classes for trigger button */
|
|
7
7
|
className?: string;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
-
* HeaderMenu -
|
|
10
|
+
* HeaderMenu - Header controls that collapse into a hamburger
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
12
|
+
* Renders `children` inline (`display: contents`, so they sit in the parent row with
|
|
13
|
+
* its gap) and a hamburger whose panel renders the same children while open. Both are
|
|
14
|
+
* in the server HTML; HeaderMenu.css shows the hamburger below the laptop breakpoint
|
|
15
|
+
* (1024px, the split of `useBreakpoint('isMobileOrTablet')`) and the inline controls
|
|
16
|
+
* from it up. No JS breakpoint, no hydration swap: usable at every width.
|
|
14
17
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
18
|
+
* The panel is a Popover, not a DropdownMenu: menu items swallow the clicks of the
|
|
19
|
+
* controls inside them and keep keyboard focus on the item wrapper, which broke
|
|
20
|
+
* nested popups (AuthHeader's provider menu or dialog, LanguageSelector, an account
|
|
21
|
+
* DropdownMenu). Labels are forced visible in the panel (.dndev-menu-content).
|
|
22
|
+
* The panel sits just above the header, so dialogs and menus opened from it show above it.
|
|
17
23
|
*
|
|
18
|
-
* @version 0.
|
|
24
|
+
* @version 0.2.0
|
|
19
25
|
* @since 0.0.1
|
|
20
26
|
* @author AMBROISE PARK Consulting
|
|
21
27
|
*
|
|
22
28
|
* @example
|
|
23
29
|
* ```tsx
|
|
24
|
-
* //
|
|
25
|
-
* const isMobileOrTablet = useBreakpoint('isMobileOrTablet');
|
|
26
|
-
* {isMobileOrTablet ? (
|
|
30
|
+
* // Inline on laptop and desktop, burger on mobile and tablet:
|
|
27
31
|
* <HeaderMenu>
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
32
|
+
* <AuthHeader />
|
|
33
|
+
* <LanguageSelector />
|
|
34
|
+
* <ThemeToggle />
|
|
31
35
|
* </HeaderMenu>
|
|
32
|
-
* ) : (
|
|
33
|
-
* <>{rightContent}</>
|
|
34
|
-
* )}
|
|
35
36
|
* ```
|
|
36
37
|
*/
|
|
37
38
|
export declare const HeaderMenu: ({ children, className }: HeaderMenuProps) => import("react").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HeaderMenu.d.ts","sourceRoot":"","sources":["../../../../../src/components/layout/components/header/HeaderMenu.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"HeaderMenu.d.ts","sourceRoot":"","sources":["../../../../../src/components/layout/components/header/HeaderMenu.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAc,SAAS,EAAE,MAAM,OAAO,CAAC;AAInD,0CAA0C;AAC1C,MAAM,WAAW,eAAe;IAC9B,wEAAwE;IACxE,QAAQ,EAAE,SAAS,CAAC;IACpB,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAsBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,UAAU,GAAI,yBAAyB,eAAe,gCAgClE,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -1,47 +1,75 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
3
|
// packages/ui/src/components/layout/components/header/HeaderMenu.tsx
|
|
3
4
|
/**
|
|
4
5
|
* @fileoverview HeaderMenu component
|
|
5
|
-
* @description
|
|
6
|
+
* @description Header controls inline on laptop and desktop, behind a hamburger below
|
|
6
7
|
*
|
|
7
8
|
* Features:
|
|
8
|
-
* -
|
|
9
|
-
* -
|
|
9
|
+
* - Children inline from the laptop breakpoint up, in a burger panel below
|
|
10
|
+
* - CSS-only switch (HeaderMenu.css): both are in the server HTML, no hydration swap
|
|
11
|
+
* - Nested popups (DropdownMenu, Dialog…) open and work from inside the panel
|
|
10
12
|
* - Reusable across all layout presets
|
|
11
13
|
*
|
|
12
|
-
* @version 0.
|
|
14
|
+
* @version 0.2.0
|
|
13
15
|
* @since 0.0.1
|
|
14
16
|
* @author AMBROISE PARK Consulting
|
|
15
17
|
*/
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
+
import { Menu } from 'lucide-react';
|
|
19
|
+
import { useState } from 'react';
|
|
20
|
+
import { Button, BUTTON_VARIANT, Popover, Stack } from '@donotdev/components';
|
|
18
21
|
/**
|
|
19
|
-
*
|
|
22
|
+
* Whether a click inside the burger panel ends the interaction.
|
|
20
23
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
24
|
+
* The panel renders its own copy of the children, so closing it unmounts any popup
|
|
25
|
+
* they opened. It stays open for a popup trigger (`aria-expanded`: DropdownMenu,
|
|
26
|
+
* Dialog, Popover, Select triggers) and for clicks inside a nested dialog, which is
|
|
27
|
+
* portaled outside the panel. Any other click (a plain control, a nested menu choice)
|
|
28
|
+
* closes it, as a menu item does.
|
|
29
|
+
*/
|
|
30
|
+
function endsInteraction({ target, currentTarget, }) {
|
|
31
|
+
if (!(target instanceof Element) || target.closest('[aria-expanded]')) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
if (currentTarget.contains(target))
|
|
35
|
+
return true;
|
|
36
|
+
return !target.closest('[role="dialog"], [role="alertdialog"]');
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* HeaderMenu - Header controls that collapse into a hamburger
|
|
40
|
+
*
|
|
41
|
+
* Renders `children` inline (`display: contents`, so they sit in the parent row with
|
|
42
|
+
* its gap) and a hamburger whose panel renders the same children while open. Both are
|
|
43
|
+
* in the server HTML; HeaderMenu.css shows the hamburger below the laptop breakpoint
|
|
44
|
+
* (1024px, the split of `useBreakpoint('isMobileOrTablet')`) and the inline controls
|
|
45
|
+
* from it up. No JS breakpoint, no hydration swap: usable at every width.
|
|
23
46
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
47
|
+
* The panel is a Popover, not a DropdownMenu: menu items swallow the clicks of the
|
|
48
|
+
* controls inside them and keep keyboard focus on the item wrapper, which broke
|
|
49
|
+
* nested popups (AuthHeader's provider menu or dialog, LanguageSelector, an account
|
|
50
|
+
* DropdownMenu). Labels are forced visible in the panel (.dndev-menu-content).
|
|
51
|
+
* The panel sits just above the header, so dialogs and menus opened from it show above it.
|
|
26
52
|
*
|
|
27
|
-
* @version 0.
|
|
53
|
+
* @version 0.2.0
|
|
28
54
|
* @since 0.0.1
|
|
29
55
|
* @author AMBROISE PARK Consulting
|
|
30
56
|
*
|
|
31
57
|
* @example
|
|
32
58
|
* ```tsx
|
|
33
|
-
* //
|
|
34
|
-
* const isMobileOrTablet = useBreakpoint('isMobileOrTablet');
|
|
35
|
-
* {isMobileOrTablet ? (
|
|
59
|
+
* // Inline on laptop and desktop, burger on mobile and tablet:
|
|
36
60
|
* <HeaderMenu>
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
61
|
+
* <AuthHeader />
|
|
62
|
+
* <LanguageSelector />
|
|
63
|
+
* <ThemeToggle />
|
|
40
64
|
* </HeaderMenu>
|
|
41
|
-
* ) : (
|
|
42
|
-
* <>{rightContent}</>
|
|
43
|
-
* )}
|
|
44
65
|
* ```
|
|
45
66
|
*/
|
|
46
|
-
export const HeaderMenu = ({ children, className }) =>
|
|
67
|
+
export const HeaderMenu = ({ children, className }) => {
|
|
68
|
+
const [open, setOpen] = useState(false);
|
|
69
|
+
const closeAfterAction = (event) => {
|
|
70
|
+
if (endsInteraction(event))
|
|
71
|
+
setOpen(false);
|
|
72
|
+
};
|
|
73
|
+
return (_jsxs(_Fragment, { children: [_jsx("div", { className: "dndev-header-menu-inline", children: children }), _jsx("div", { className: "dndev-header-menu-burger", children: _jsx(Popover, { open: open, onOpenChange: setOpen, align: "end", className: "dndev-menu-content dndev-header-menu-panel", trigger: _jsx(Button, { variant: BUTTON_VARIANT.GHOST, icon: Menu, "aria-label": "Menu", className: className }), children: _jsx(Stack, { gap: "none", onClick: closeAfterAction, children: children }) }) })] }));
|
|
74
|
+
};
|
|
47
75
|
export default HeaderMenu;
|
|
@@ -48,13 +48,13 @@ function SettingsMenu({ variant = BUTTON_VARIANT.OUTLINE, } = {}) {
|
|
|
48
48
|
const languageItems = languages.map((language) => {
|
|
49
49
|
const isActive = language.id === currentLanguage;
|
|
50
50
|
return {
|
|
51
|
-
label: language.
|
|
51
|
+
label: language.nativeName,
|
|
52
52
|
onClick: () => changeLanguage(language.id),
|
|
53
53
|
disabled: isLoading,
|
|
54
54
|
checked: isActive,
|
|
55
55
|
className: isActive ? 'bg-accent' : undefined,
|
|
56
56
|
iconEnd: isActive && !isLoading ? Check : undefined,
|
|
57
|
-
children: (_jsxs(Stack, { direction: "row", align: "center", gap: "tight", children: [_jsx(Flag, { code: language.flagCode || language.id, title:
|
|
57
|
+
children: (_jsxs(Stack, { direction: "row", align: "center", gap: "tight", children: [_jsx(Flag, { code: language.flagCode || language.id, title: language.nativeName }), _jsx("span", { children: language.nativeName }), isLoading && isActive && (_jsx("div", { style: { marginInlineStart: 'auto' }, children: _jsx("div", { style: {
|
|
58
58
|
width: '0.5rem',
|
|
59
59
|
height: '0.5rem',
|
|
60
60
|
borderRadius: '50%',
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { AnyEntity } from '@donotdev/core';
|
|
2
|
+
/** Props of {@link ChildRowsPicker}. */
|
|
3
|
+
export interface ChildRowsPickerProps {
|
|
4
|
+
/** Entity of the other side of the link table (the records to pick) */
|
|
5
|
+
entity: AnyEntity;
|
|
6
|
+
/** Records already linked (not offered) */
|
|
7
|
+
excludedIds: ReadonlySet<string>;
|
|
8
|
+
/** The viewer's role: which fields the filters offer (`visibility`) */
|
|
9
|
+
viewerRole: string;
|
|
10
|
+
/** Called with the picked record ids */
|
|
11
|
+
onPick: (ids: string[]) => void;
|
|
12
|
+
/** Closes the dialog */
|
|
13
|
+
onClose: () => void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Pick records of the other side of a link table: filters, text search,
|
|
17
|
+
* selectable list (deleted and already-linked records excluded), multi-select,
|
|
18
|
+
* "Add selected".
|
|
19
|
+
*/
|
|
20
|
+
export default function ChildRowsPicker({ entity, excludedIds, viewerRole, onPick, onClose, }: ChildRowsPickerProps): import("react").JSX.Element;
|
|
21
|
+
//# sourceMappingURL=ChildRowsPicker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChildRowsPicker.d.ts","sourceRoot":"","sources":["../../../src/crud/components/ChildRowsPicker.tsx"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAehD,wCAAwC;AACxC,MAAM,WAAW,oBAAoB;IACnC,uEAAuE;IACvE,MAAM,EAAE,SAAS,CAAC;IAClB,2CAA2C;IAC3C,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACjC,uEAAuE;IACvE,UAAU,EAAE,MAAM,CAAC;IACnB,wCAAwC;IACxC,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAChC,wBAAwB;IACxB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EACtC,MAAM,EACN,WAAW,EACX,UAAU,EACV,MAAM,EACN,OAAO,GACR,EAAE,oBAAoB,+BA6GtB"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
// packages/ui/src/crud/components/ChildRowsPicker.tsx
|
|
4
|
+
/**
|
|
5
|
+
* @fileoverview Link table picker
|
|
6
|
+
* @description Dialog of a joined `EntityList` on a link table (the child has
|
|
7
|
+
* one reference besides the parent's): the other side's records with
|
|
8
|
+
* `EntityFilters` (for the viewer's role, own filter state: the lists of that
|
|
9
|
+
* collection keep theirs) and a text search over a selectable list; deleted and
|
|
10
|
+
* already-linked records excluded; multi-select. Picked records become unsaved
|
|
11
|
+
* rows. Loaded lazily by EntityList.
|
|
12
|
+
*
|
|
13
|
+
* @version 0.1.0
|
|
14
|
+
* @since 0.2.5
|
|
15
|
+
* @author AMBROISE PARK Consulting
|
|
16
|
+
*/
|
|
17
|
+
import { Search } from 'lucide-react';
|
|
18
|
+
import { useState } from 'react';
|
|
19
|
+
import { Button, DataTable, Dialog, Input, Stack, Text, } from '@donotdev/components';
|
|
20
|
+
import { statusCan, useTranslation } from '@donotdev/core';
|
|
21
|
+
import { EntityFilters, applyFilters, applySearch, formatValue, translateFieldLabel, useCrudFilters, useCrudList, useReferenceResolver, } from '../crudImports';
|
|
22
|
+
/**
|
|
23
|
+
* Pick records of the other side of a link table: filters, text search,
|
|
24
|
+
* selectable list (deleted and already-linked records excluded), multi-select,
|
|
25
|
+
* "Add selected".
|
|
26
|
+
*/
|
|
27
|
+
export default function ChildRowsPicker({ entity, excludedIds, viewerRole, onPick, onClose, }) {
|
|
28
|
+
const { t } = useTranslation([entity.namespace, 'crud']);
|
|
29
|
+
const { t: tCrud } = useTranslation('crud');
|
|
30
|
+
const list = useCrudList(entity, { pagination: 'client' });
|
|
31
|
+
const referenceData = useReferenceResolver(entity);
|
|
32
|
+
const [selectedIds, setSelectedIds] = useState([]);
|
|
33
|
+
const [searchQuery, setSearchQuery] = useState('');
|
|
34
|
+
// Own filter state: picking must not filter the lists of this collection.
|
|
35
|
+
const filterKey = `${entity.collection}#picker`;
|
|
36
|
+
const { filters } = useCrudFilters({ collection: filterKey });
|
|
37
|
+
// Removed records (STATUS_MATRIX `isRemoved`) are never offered.
|
|
38
|
+
const candidates = list.items.filter((row) => !statusCan(typeof row.status === 'string' ? row.status : null, 'isRemoved') &&
|
|
39
|
+
!excludedIds.has(row.id));
|
|
40
|
+
const available = applySearch(applyFilters(candidates, filters, entity), searchQuery, entity);
|
|
41
|
+
const fields = entity.listFields || Object.keys(entity.fields);
|
|
42
|
+
const columns = fields.flatMap((fieldName) => {
|
|
43
|
+
const config = entity.fields[fieldName];
|
|
44
|
+
if (!config)
|
|
45
|
+
return [];
|
|
46
|
+
return [
|
|
47
|
+
{
|
|
48
|
+
key: fieldName,
|
|
49
|
+
title: translateFieldLabel(fieldName, config, t),
|
|
50
|
+
dataIndex: fieldName,
|
|
51
|
+
sortable: true,
|
|
52
|
+
render: (value, record) => formatValue(value, config, t, {
|
|
53
|
+
compact: true,
|
|
54
|
+
referenceData,
|
|
55
|
+
item: record,
|
|
56
|
+
}),
|
|
57
|
+
},
|
|
58
|
+
];
|
|
59
|
+
});
|
|
60
|
+
const entityName = t('name', { defaultValue: entity.name });
|
|
61
|
+
return (_jsx(Dialog, { open: true, onOpenChange: (open) => {
|
|
62
|
+
if (!open)
|
|
63
|
+
onClose();
|
|
64
|
+
}, title: tCrud('childRows.pickTitle', { entity: entityName }), footer: _jsxs(Stack, { direction: "row", gap: "tight", justify: "end", children: [_jsx(Button, { variant: "outline", onClick: onClose, children: tCrud('actions.cancel') }), _jsx(Button, { intent: "add", disabled: selectedIds.length === 0, onClick: () => {
|
|
65
|
+
onPick(selectedIds);
|
|
66
|
+
onClose();
|
|
67
|
+
}, children: tCrud('childRows.pickConfirm', { count: selectedIds.length }) })] }), children: _jsxs(Stack, { children: [_jsx(EntityFilters, { entity: entity, data: candidates, fieldsToFilter: fields, viewerRole: viewerRole, filterKey: filterKey }), _jsx(Input, { placeholder: tCrud('actions.searchPlaceholder'), value: searchQuery, onChange: (e) => setSearchQuery(e.target.value), icon: Search, className: "dndev-w-full" }), !list.loading && available.length === 0 ? (_jsx(Text, { level: "body", children: tCrud('childRows.pickEmpty') })) : (_jsx(DataTable, { data: available, columns: columns, sortable: true, searchable: false, pagination: true, loading: list.loading, selectable: true, getRowId: (row) => row.id, onSelect: (rows) => setSelectedIds(rows.map((row) => row.id)), showingLabel: tCrud('pagination.showing'), paginationPreviousLabel: tCrud('pagination.previous'), paginationNextLabel: tCrud('pagination.next'), paginationItemsPerPagePlaceholder: tCrud('pagination.itemsPerPagePlaceholder') }))] }) }));
|
|
68
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityCardList.d.ts","sourceRoot":"","sources":["../../../src/crud/components/EntityCardList.tsx"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EAAE,mBAAmB,EAAgB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"EntityCardList.d.ts","sourceRoot":"","sources":["../../../src/crud/components/EntityCardList.tsx"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EAAE,mBAAmB,EAAgB,MAAM,gBAAgB,CAAC;AAaxE,YAAY,EAAE,mBAAmB,EAAE,CAAC;AAwGpC;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,QAAQ,EACR,OAAO,EACP,IAAmB,EACnB,SAA0B,EAAE,2BAA2B;AACvD,YAAY,EACZ,MAAM,EACN,WAAmB,EACnB,WAAW,EACX,IAAI,EACJ,iBAAiB,EACjB,UAAU,EACV,WAAmB,EACnB,WAAW,EACX,OAAO,GACR,EAAE,mBAAmB,sCA6NrB"}
|
|
@@ -20,6 +20,7 @@ import { useTranslation, getListCardFieldNames, useBreakpoint, } from '@donotdev
|
|
|
20
20
|
import { isCrudModuleAvailable, useCrudCardList, EntityFilters, useEntityFavorites, useCrudFilters, } from '../crudImports';
|
|
21
21
|
import { CrudCard } from './CrudCardLink';
|
|
22
22
|
import { useNavigate } from '../../routing';
|
|
23
|
+
import { useAuthSafe } from '../../utils/useAuthSafe';
|
|
23
24
|
/**
|
|
24
25
|
* Resolve skeleton slots from entity shape — mirrors CrudCard's useResolvedSlots exactly.
|
|
25
26
|
* Returns the actual field names per slot so skeletons render the same structure as real cards.
|
|
@@ -91,6 +92,7 @@ queryOptions, filter, hideFilters = false, resultLabel, tone, renderCardOverlay,
|
|
|
91
92
|
return null;
|
|
92
93
|
const isPreview = !!preview;
|
|
93
94
|
const navigate = useNavigate();
|
|
95
|
+
const viewerRole = useAuthSafe('userRole');
|
|
94
96
|
const base = basePath ?? `/${entity.collection}`;
|
|
95
97
|
// useCrudCardList -> handles fetching + client-side filter/search/sort via `processed`
|
|
96
98
|
const { items: rawData, processed, loading: fetchLoading, error: fetchError, } = useCrudCardList(entity, {
|
|
@@ -147,23 +149,17 @@ queryOptions, filter, hideFilters = false, resultLabel, tone, renderCardOverlay,
|
|
|
147
149
|
const entityName = t('name', { defaultValue: entity.name });
|
|
148
150
|
return (_jsxs(_Fragment, { children: [!hideFilters && (_jsx(Section, { title: tCrud('filters.title', {
|
|
149
151
|
entity: entityName,
|
|
150
|
-
defaultValue: `Browse ${entityName} - Filters`,
|
|
151
152
|
}), collapsible: collapsible, defaultOpen: defaultOpen, tone: tone, children: _jsx(Card, { children: _jsxs(Stack, { direction: "column", children: [_jsx(Button, { variant: !isPreview && showFavoritesOnly ? 'primary' : 'outline', icon: _jsx(Heart, { size: 18 }), onClick: () => setShowFavoritesOnly(!showFavoritesOnly), disabled: isPreview, children: showFavoritesOnly
|
|
152
|
-
? tCrud('favorites.showAll'
|
|
153
|
-
: tCrud('favorites.showFavorites', {
|
|
154
|
-
|
|
155
|
-
}) }), !isPreview && (_jsx(EntityFilters, { entity: entity, data: rawData, fieldsToFilter: fieldsToFilter }))] }) }) })), _jsx(Section, { title: loading
|
|
156
|
-
? tCrud('results.title.fetching', { defaultValue: 'Fetching...' })
|
|
153
|
+
? tCrud('favorites.showAll')
|
|
154
|
+
: tCrud('favorites.showFavorites') }), !isPreview && (_jsx(EntityFilters, { entity: entity, data: rawData, fieldsToFilter: fieldsToFilter, viewerRole: viewerRole }))] }) }) })), _jsx(Section, { title: loading
|
|
155
|
+
? tCrud('results.title.fetching')
|
|
157
156
|
: resultLabel
|
|
158
157
|
? resultLabel(data.length)
|
|
159
158
|
: tCrud('results.title.count', {
|
|
160
159
|
count: data.length,
|
|
161
|
-
|
|
162
|
-
? 'Found 1 occurrence'
|
|
163
|
-
: `Found ${data.length} occurrences`,
|
|
164
|
-
}), collapsible: collapsible, defaultOpen: collapsible ? true : undefined, tone: tone, children: loading ? (_jsx(CardListSkeleton, { cols: cols, entity: entity })) : fetchError ? (_jsxs(Stack, { align: "center", justify: "center", style: { padding: 'var(--gap-3xl)', textAlign: 'center' }, children: [_jsx(Text, { level: "h3", style: { color: 'var(--destructive)' }, children: tCrud('errors.fetchFailed', { entity: entityName }) }), _jsx(Text, { level: "small", style: { color: 'var(--destructive)' }, children: fetchError instanceof Error
|
|
160
|
+
}), collapsible: collapsible, defaultOpen: collapsible ? true : undefined, tone: tone, children: loading ? (_jsx(CardListSkeleton, { cols: cols, entity: entity })) : fetchError ? (_jsxs(Stack, { align: "center", justify: "center", style: { padding: 'var(--gap-lg)', textAlign: 'center' }, children: [_jsx(Text, { level: "h3", style: { color: 'var(--destructive)' }, children: tCrud('errors.fetchFailed', { entity: entityName }) }), _jsx(Text, { level: "small", style: { color: 'var(--destructive)' }, children: fetchError instanceof Error
|
|
165
161
|
? fetchError.message
|
|
166
|
-
: String(fetchError) })] })) : data.length === 0 ? (_jsxs(Stack, { align: "center", justify: "center", style: { padding: 'var(--gap-
|
|
162
|
+
: String(fetchError) })] })) : data.length === 0 ? (_jsxs(Stack, { align: "center", justify: "center", style: { padding: 'var(--gap-lg)', textAlign: 'center' }, children: [_jsx(Text, { level: "h3", style: { color: 'var(--muted-foreground)' }, children: tCrud('emptyState.title') }), _jsx(Text, { style: { color: 'var(--muted-foreground)' }, children: tCrud('emptyState.description') })] })) : (_jsx(Grid, { cols: cols, children: data.map((item) => {
|
|
167
163
|
const itemIsFavorite = isFavorite(item.id);
|
|
168
164
|
const detailHref = isPreview || onClick ? undefined : `${base}/${item.id}`;
|
|
169
165
|
return (_jsx(CrudCard, { item: item, entity: entity, detailHref: detailHref, onClick: isPreview
|
|
@@ -182,11 +178,7 @@ queryOptions, filter, hideFilters = false, resultLabel, tone, renderCardOverlay,
|
|
|
182
178
|
transition: 'fill 0.2s, stroke 0.2s',
|
|
183
179
|
opacity: isPreview ? 0.5 : 1,
|
|
184
180
|
}, "aria-label": itemIsFavorite
|
|
185
|
-
? tCrud('favorites.remove'
|
|
186
|
-
|
|
187
|
-
})
|
|
188
|
-
: tCrud('favorites.add', {
|
|
189
|
-
defaultValue: 'Add to favorites',
|
|
190
|
-
}) }) }, item.id));
|
|
181
|
+
? tCrud('favorites.remove')
|
|
182
|
+
: tCrud('favorites.add') }) }, item.id));
|
|
191
183
|
}) })) })] }));
|
|
192
184
|
}
|
|
@@ -102,7 +102,7 @@ export function EntityDisplayRenderer({ entity, id, t, className = '', loadingMe
|
|
|
102
102
|
gridColumn: '1 / -1',
|
|
103
103
|
display: 'contents',
|
|
104
104
|
}, className: className, children: _jsx(Spinner, { overlay: true, "aria-label": loadingMessage ||
|
|
105
|
-
tCrud('form.loading'
|
|
105
|
+
tCrud('form.loading') }) }));
|
|
106
106
|
}
|
|
107
107
|
// CRUD unavailable (consent declined / feature absent): nothing will load
|
|
108
108
|
if (!displayData && !displayError && !notFound)
|
|
@@ -110,7 +110,7 @@ export function EntityDisplayRenderer({ entity, id, t, className = '', loadingMe
|
|
|
110
110
|
// Error or not found state
|
|
111
111
|
if (displayError || !displayData) {
|
|
112
112
|
return (_jsx(Stack, { align: "center", justify: "center", style: {
|
|
113
|
-
padding: 'var(--gap-
|
|
113
|
+
padding: 'var(--gap-lg)',
|
|
114
114
|
textAlign: 'center',
|
|
115
115
|
}, className: className, children: _jsxs(Stack, { direction: "column", gap: "tight", children: [_jsx("h3", { style: { color: 'var(--muted-foreground)' }, children: notFoundMessage ||
|
|
116
116
|
tCrud('errors.notFound', {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EntityFormRendererProps,
|
|
1
|
+
import type { AnyEntity, EntityFormRendererProps, FieldOperation } from '@donotdev/core';
|
|
2
2
|
export type { EntityFormRendererProps };
|
|
3
3
|
/**
|
|
4
4
|
* EntityFormRenderer - Dumb component that renders a form from entity definition.
|
|
@@ -8,6 +8,8 @@ export type { EntityFormRendererProps };
|
|
|
8
8
|
* - Generates formId
|
|
9
9
|
* - Renders fields
|
|
10
10
|
* - Renders submit button with status from useEntityForm
|
|
11
|
+
* - Submits through `onSubmit`, or, without it, useEntityForm's default writer
|
|
12
|
+
* (the record plus the child rows joined to the form, one `bulkAcross`)
|
|
11
13
|
*
|
|
12
14
|
* @version 0.1.0
|
|
13
15
|
* @since 0.0.1
|
|
@@ -18,6 +20,6 @@ export type { EntityFormRendererProps };
|
|
|
18
20
|
* Applies instanceKey as React key on the inner component for clean state isolation
|
|
19
21
|
* when navigating between entities on the same route (e.g. /cars/:id).
|
|
20
22
|
*/
|
|
21
|
-
export declare function EntityFormRenderer<
|
|
23
|
+
export declare function EntityFormRenderer<E extends AnyEntity, Op extends FieldOperation = FieldOperation>(props: EntityFormRendererProps<E, Op>): import("react").JSX.Element;
|
|
22
24
|
export default EntityFormRenderer;
|
|
23
25
|
//# sourceMappingURL=EntityFormRenderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityFormRenderer.d.ts","sourceRoot":"","sources":["../../../src/crud/components/EntityFormRenderer.tsx"],"names":[],"mappings":"AAiCA,OAAO,KAAK,EACV,uBAAuB,EACvB,
|
|
1
|
+
{"version":3,"file":"EntityFormRenderer.d.ts","sourceRoot":"","sources":["../../../src/crud/components/EntityFormRenderer.tsx"],"names":[],"mappings":"AAiCA,OAAO,KAAK,EACV,SAAS,EACT,uBAAuB,EACvB,cAAc,EAGf,MAAM,gBAAgB,CAAC;AAmBxB,YAAY,EAAE,uBAAuB,EAAE,CAAC;AA2DxC;;;;;;;;;;;;;;GAcG;AACH;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,CAAC,SAAS,SAAS,EACnB,EAAE,SAAS,cAAc,GAAG,cAAc,EAC1C,KAAK,EAAE,uBAAuB,CAAC,CAAC,EAAE,EAAE,CAAC,+BAGtC;AAqnBD,eAAe,kBAAkB,CAAC"}
|