@donotdev/ui 0.0.22 → 0.0.23
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/CookieConsent-UVTR7CWW.js +1 -0
- package/dist/GoToDialog-CR4VOVXT.js +1 -0
- package/dist/chunk-O2XFH626.js +1 -0
- package/dist/chunk-XHGRMKOY.js +1 -0
- package/dist/dndev-next.css +10152 -0
- package/dist/index.js +4 -4
- package/package.json +26 -9
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk-O2XFH626.js";import{Cookie as T,Settings as _,Shield as G,BarChart3 as H,Target as K}from"lucide-react";import{useState as w,useEffect as v,useRef as V}from"react";import{Accordion as W,Button as p,BUTTON_VARIANT as h,Card as b,Switch as q,Text as f,cn as J,Stack as i}from"@donotdev/components";import{handleError as Q,useConsent as d,getCookieExamples as y,hasOptionalCookies as X}from"@donotdev/core";import{CONSENT_CATEGORY as l}from"@donotdev/core";import{useTranslation as Z}from"@donotdev/core";import{isClient as $}from"@donotdev/core";import{Fragment as te,jsx as n,jsxs as a}from"react/jsx-runtime";function ee({position:D="bottom",showBranding:ne=!0,brandingText:oe="Powered by DoNotDev Framework",className:O=""}){let r=d("hasConsented"),m=d("categories"),S=d("acceptAll"),B=d("declineAll"),I=d("updateCategory"),g=d("showBanner"),{t}=Z("cookies"),[u,x]=w(!1),[C,c]=w(!r||g),[N,A]=w(m),E=V(null);v(()=>{g&&c(!0)},[g]);let L=Object.keys(m),P=[{id:l.NECESSARY,icon:G,title:t("essentialCookies"),description:t("essentialDescription"),examples:y("necessary")||t("essentialExamples"),locked:!0},{id:l.FUNCTIONAL,icon:T,title:t("functionalCookies"),description:t("functionalDescription"),examples:y("functional")||t("functionalExamples"),legalNotice:t("functionalLegalNotice"),locked:!1},{id:l.ANALYTICS,icon:H,title:t("analyticsCookies"),description:t("analyticsDescription"),examples:y("analytics")||t("analyticsExamples"),locked:!1},{id:l.MARKETING,icon:K,title:t("marketingCookies"),description:t("marketingDescription"),examples:y("marketing")||t("marketingExamples"),locked:!1}].filter(e=>L.includes(e.id)),k=X();if(v(()=>{!r&&!k&&S()},[r,k,S]),v(()=>{let e={...m};if(u){let o=e;Object.keys(o).forEach(s=>{s!==l.NECESSARY&&o[s]===!1&&(o[s]=!0)})}A(e)},[m,u]),v(()=>{if(!$()||r||!C)return;let e=s=>{E.current&&!E.current.contains(s.target)&&c(!1)},o=setTimeout(()=>{document.addEventListener("mousedown",e)},100);return()=>{clearTimeout(o),document.removeEventListener("mousedown",e)}},[r,C]),r&&!g)return null;let R=()=>{try{Object.entries(N).forEach(([e,o])=>{if(e!==l.NECESSARY&&o!==void 0){let s=e;Object.values(l).includes(s)&&I(s,!!o)}}),x(!1),c(!1)}catch(e){Q(e,{userMessage:"Error saving preferences",context:{operation:"save_preferences"},severity:"warning",log:!0,reportToSentry:!1,showNotification:!1})}},U=()=>{S(),c(!1)},z=()=>{B(),c(!1)},F=a(i,{children:[n(f,{as:"p",variant:"muted",level:"small",children:t("cookieBannerDescription")}),k&&n(W,{type:"single",collapsible:!0,value:u?"preferences":"",onValueChange:e=>x(e==="preferences"),items:[{value:"preferences",trigger:a(i,{direction:"row",align:"center",gap:"tight",children:[n(_,{className:"dndev-size-md"}),t("customize")]}),content:n(i,{children:P.map(e=>{let o=e.icon,s=N[e.id]??!1;return n(b,{content:a(i,{direction:"row",align:"center",justify:"between",children:[a(i,{direction:"row",align:"start",gap:"tight",style:{flex:1},children:[n(o,{className:"dndev-size-md",style:{color:"var(--primary)",marginTop:"0.125rem"}}),a(i,{gap:"tight",children:[n(f,{as:"span",level:"body",style:{fontWeight:600},children:e.title}),n(f,{as:"span",variant:"muted",level:"small",children:e.description}),e.examples&&n(f,{as:"span",variant:"muted",level:"small",style:{fontStyle:"italic"},children:e.examples})]})]}),e.locked?n(f,{as:"span",variant:"muted",level:"small",children:t("alwaysOn")}):n(q,{checked:s,onCheckedChange:j=>A(M=>({...M,[e.id]:j}))})]})},e.id)})})}]})]}),Y=u?a(i,{direction:"row",gap:"tight",style:{width:"100%"},children:[n(p,{onClick:R,variant:h.DEFAULT,style:{flex:1},children:t("savePreferences","Save Preferences")}),n(p,{onClick:()=>x(!1),variant:h.OUTLINE,style:{flex:1},children:t("form.cancel","Cancel")})]}):a(i,{direction:"row",gap:"tight",style:{width:"100%"},children:[n(p,{onClick:U,variant:h.DEFAULT,style:{flex:1},children:t("acceptAll")}),k&&n(p,{onClick:z,variant:h.OUTLINE,style:{flex:1},children:t("declineOptional")})]});return a(te,{children:[C&&n(b,{ref:E,className:J("dndev-fixed dndev-z-modal",O),icon:T,title:t("cookiePreferences"),content:F,footer:Y,style:{[D==="top"?"top":"bottom"]:"var(--gap-md)",insetInlineStart:"var(--gap-md)",insetInlineEnd:"var(--gap-md)",maxWidth:"100%",width:"calc(100% - var(--gap-md) * 2)"}}),!C&&!r&&n(p,{onClick:()=>c(!0),className:"dndev-fixed dndev-z-toast",style:{bottom:"var(--gap-md)",insetInlineStart:"var(--gap-md)"},icon:T,title:t("cookiePreferences")})]})}var pe=ee;export{pe as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as u,g as T}from"./chunk-XHGRMKOY.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:N=>{N.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 y=f.length>0;return t(F,{open:m,onOpenChange:a=>a?null:r(),children:[o(R,{placeholder:e("globalGoTo.placeholder","Search pages..."),emptyMessage:y?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
|
+
var d=Object.defineProperty;var e=(b,a,c)=>a in b?d(b,a,{enumerable:!0,configurable:!0,writable:!0,value:c}):b[a]=c;var f=(b,a,c)=>e(b,typeof a!="symbol"?a+"":a,c);export{f as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as l from"lucide-react";import{isValidElement as P}from"react";import{cn as m}from"@donotdev/components";import{jsx as c}from"react/jsx-runtime";function S(e){if(!e)return l.Palette;let t=e.replace(/['"]/g,"");return l[t]||l.Palette}var b=({icon:e,fallback:t,className:r,ariaHidden:s=!1})=>{let o=e||t;if(!o)return null;let i="dndev-size-md";if(typeof o=="function"||typeof o=="object"&&o!==null&&"render"in o)return c(o,{className:m(i,r),style:{flexShrink:0},"aria-hidden":s});if(typeof o=="string"){if(!/^[a-zA-Z0-9_-]+$/.test(o))return c("span",{className:m(i,r),style:{display:"inline-flex",alignItems:"center",justifyContent:"center"},"aria-hidden":s,children:o});let p=S(o);return c(p,{className:m(i,r),style:{flexShrink:0},"aria-hidden":s})}return P(o)?c("span",{className:r,style:{display:"inline-flex",alignItems:"center",justifyContent:"center"},"aria-hidden":s,children:o}):c("span",{className:r,style:{display:"inline-flex",alignItems:"center",justifyContent:"center"},"aria-hidden":s,children:o})},z=b;import*as E from"@donotdev/auth";import{DEGRADED_AUTH_API as L}from"@donotdev/core";var d=E?.useAuth;function T(e){return L[e]}function y(e){return d?d(e):T(e)}var O=typeof d=="function";import{useMemo as h}from"react";import{useNavigationStore as K}from"@donotdev/core";import{USER_ROLES as F}from"@donotdev/core";import{useLocation as k}from"@donotdev/ui/routing/hooks";function g(){let e=k(),t=y("user"),r=!!t,s=t?.role||F.GUEST,o=K(i=>!i||typeof i.getFilteredRoutes!="function"?[]:i.getFilteredRoutes({authenticated:r,role:s}));return h(()=>Array.isArray(o)?o.map(i=>({...i,isActive:_(i.path,e.pathname),hasChildren:!1,children:void 0})).sort((i,a)=>i.label.localeCompare(a.label,void 0,{sensitivity:"base"})):[],[o,e.pathname])}function J(e){let t=g();return h(()=>t.find(r=>r.path===e),[t,e])}function _(e,t){return e==="/"?t==="/":t===e?!0:t.startsWith(e+"/")}import{useCallback as f,useMemo as A}from"react";import{useNavigationStore as u}from"@donotdev/core";import{useNavigate as j}from"@donotdev/ui/routing/hooks";var te=()=>{let e=j(),t=g()??[],r=u(n=>n.favorites),s=u(n=>n.recent),o=u(n=>n.toggleFavorite),i=u(n=>n.isFavorite),a=u(n=>n.addRecent),v=A(()=>t.length?t.filter(n=>r.includes(n.path)):[],[r,t]),p=A(()=>t.length?t.filter(C=>s.includes(C.path)).slice(0,5):[],[s,t]),N=f(n=>{o(n)},[o]),R=f(n=>i(n),[i]),I=f(n=>{a(n)},[a]),x=f(n=>{I(n),e(n)},[e,I]);return{navigationItems:t,favoriteItems:v,recentItems:p,toggleFavorite:N,isFavorite:R,navigateToItem:x}};export{b as a,z as b,y as c,O as d,g as e,J as f,te as g};
|