@blakesteve/roster 5.10.0 → 5.12.0
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/README.md +202 -11
- package/dist/components/atoms/Chip/chip-variants.cjs +1 -1
- package/dist/components/atoms/Chip/chip-variants.js +8 -2
- package/dist/components/atoms/Combobox/Combobox.cjs +1 -1
- package/dist/components/atoms/Combobox/Combobox.js +20 -18
- package/dist/components/atoms/MultiSelect/MultiSelect.cjs +1 -1
- package/dist/components/atoms/MultiSelect/MultiSelect.js +22 -20
- package/dist/components/atoms/PasswordInput/PasswordInput.cjs +1 -1
- package/dist/components/atoms/PasswordInput/PasswordInput.js +5 -5
- package/dist/components/atoms/Select/Select.cjs +1 -1
- package/dist/components/atoms/Select/Select.js +19 -17
- package/dist/components/atoms/Select/select-variants.cjs +1 -1
- package/dist/components/atoms/Select/select-variants.js +11 -2
- package/dist/components/molecules/Carousel/Carousel.cjs +1 -1
- package/dist/components/molecules/Carousel/Carousel.js +31 -29
- package/dist/components/molecules/FileUpload/FileUpload.cjs +1 -1
- package/dist/components/molecules/FileUpload/FileUpload.js +21 -19
- package/dist/components/molecules/LiquidTabs/LiquidTabs.cjs +1 -1
- package/dist/components/molecules/LiquidTabs/LiquidTabs.js +22 -20
- package/dist/components/molecules/Menu/Menu.cjs +1 -1
- package/dist/components/molecules/Menu/Menu.js +133 -124
- package/dist/components/molecules/RadioGroup/RadioGroup.cjs +1 -1
- package/dist/components/molecules/RadioGroup/RadioGroup.js +23 -21
- package/dist/components/molecules/RangeSlider/RangeSlider.cjs +1 -0
- package/dist/components/molecules/RangeSlider/RangeSlider.d.ts +79 -0
- package/dist/components/molecules/RangeSlider/RangeSlider.js +166 -0
- package/dist/components/molecules/Slider/Slider.cjs +1 -0
- package/dist/components/molecules/Slider/Slider.d.ts +91 -0
- package/dist/components/molecules/Slider/Slider.js +130 -0
- package/dist/components/molecules/Slider/track-parts.cjs +1 -0
- package/dist/components/molecules/Slider/track-parts.d.ts +65 -0
- package/dist/components/molecules/Slider/track-parts.js +121 -0
- package/dist/components/molecules/Slider/track.cjs +1 -0
- package/dist/components/molecules/Slider/track.d.ts +115 -0
- package/dist/components/molecules/Slider/track.js +152 -0
- package/dist/components/organisms/Dialog/Dialog.cjs +1 -1
- package/dist/components/organisms/Dialog/Dialog.js +19 -17
- package/dist/components/organisms/ModerationQueue/ModerationQueue.cjs +1 -1
- package/dist/components/organisms/ModerationQueue/ModerationQueue.js +45 -43
- package/dist/components/organisms/Navbar/Navbar.cjs +1 -1
- package/dist/components/organisms/Navbar/Navbar.js +24 -22
- package/dist/components/organisms/Sheet/Sheet.cjs +1 -1
- package/dist/components/organisms/Sheet/Sheet.js +25 -23
- package/dist/index.d.ts +2 -0
- package/dist/internal/key-focus.cjs +1 -0
- package/dist/internal/key-focus.d.ts +7 -0
- package/dist/internal/key-focus.js +60 -0
- package/dist/internal/popup.cjs +1 -1
- package/dist/internal/popup.d.ts +15 -1
- package/dist/internal/popup.js +17 -12
- package/dist/meta.json +3 -3
- package/dist/roster.cjs +1 -1
- package/dist/roster.css +1 -1
- package/dist/roster.js +67 -63
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),l=require("react"),D=require("../../../lib/utils.cjs"),Pe=require("../../../lib/labels.cjs"),he=require("../../atoms/Button/Button.cjs"),ze=require("../../atoms/Card/Card.cjs"),De=require("../../atoms/Spinner/Spinner.cjs"),He=require("../../atoms/Textarea/Textarea.cjs"),_=require("../../molecules/Alert/Alert.cjs"),Ke=require("../../molecules/EmptyState/EmptyState.cjs"),Qe=require("../../molecules/RadioGroup/RadioGroup.cjs"),Ge=require("./queue-actions.cjs"),We={loading:n=>`Loading ${n}`,loadFailed:"The queue couldn't load.",retry:"Retry",busy:"loading",cancel:"Cancel",decide:n=>`Decide: ${n}`,decided:(n,a)=>`${n}: ${a}.`,failed:(n,a,p)=>`${n} didn't go through for ${a}. ${p}`,unknownError:"Something went wrong.",decidedElsewhere:n=>`${n} was decided elsewhere.`,left:n=>n===0?"None left.":`${n} left.`,pickReason:"Pick a reason.",addNote:"Add a note.",reason:"Reason",reasonOptional:"Reason (optional)",note:"Note",noteOptional:"Note (optional)"},ge={primary:{colorScheme:"primary",variant:"solid"},success:{colorScheme:"success",variant:"solid"},danger:{colorScheme:"error",variant:"soft"},neutral:{colorScheme:"neutral",variant:"outline"}},Je={edit:Ge.editAction},N=n=>n.edit?n:null,Ue=n=>Math.min(6,Math.max(1,n)),Ve=(n,a)=>n instanceof Error&&n.message?n.message:a;function T(n,a){const p={...n};return delete p[a],p}function ee({busy:n=!1,blocked:a=!1,onClick:p,children:v,className:y,...S}){return s.jsx(he.Button,{size:"lg",...S,isLoading:n,"aria-disabled":a||void 0,className:D.cn(a&&!n&&"rst:cursor-not-allowed rst:opacity-50",y),onClick:h=>{if(a){h.preventDefault();return}p?.(h)},children:v})}function Xe({label:n,hideLabel:a=!1,headingLevel:p=2,itemHeadingLevel:v,items:y,getKey:S,itemLabel:h,renderMeta:w,renderContent:be,actions:H,status:te="ready",error:ve,onRetry:re,empty:ne={title:"Nothing waiting"},density:se="comfortable",footer:ye,labels:Se,className:je}){const g=Pe.withLabels(We,Se),qe=typeof H=="function"?H(Je):H,C=l.useId(),k=l.useRef(null),R=y.map(S),F=l.useRef(new Map);F.current=new Map(y.map((e,t)=>[R[t],e]));const[K,ke]=l.useState({}),$=l.useRef({}),oe=e=>{$.current=e($.current),ke($.current)},[ce,L]=l.useState({}),[ie,Re]=l.useState({}),x=l.useRef({}),b=(e,t)=>{x.current=t?{...x.current,[e]:t}:T(x.current,e),Re(x.current)},[Q,$e]=l.useState({text:"",n:0}),G=l.useRef([]),B=l.useRef(null),ae=l.useCallback(e=>{G.current.push(e),!B.current&&(B.current=setTimeout(()=>{B.current=null;const t=G.current.join(" ");G.current=[],$e(r=>({text:t,n:r.n+1}))},0))},[]);l.useLayoutEffect(()=>()=>{B.current&&clearTimeout(B.current)},[]);const[Ne,we]=l.useState(0),W=l.useRef(null),q=l.useCallback(e=>{W.current=e,we(t=>t+1)},[]),le=l.useCallback(e=>{const t=k.current;if(!t)return null;const r="key"in e?CSS.escape(e.key):"";switch(e.kind){case"item":return t.querySelector(`[data-queue-item="${r}"]`);case"empty":return t.querySelector("[data-queue-empty]");case"trigger":return t.querySelector(`[data-queue-item="${r}"] [data-queue-action="${CSS.escape(e.actionId)}"]`);case"step":return t.querySelector(`[data-queue-item="${r}"] [data-queue-step]`)}},[]);l.useLayoutEffect(()=>{const e=W.current;if(!e)return;W.current=null,(le(e)??k.current?.querySelector("[data-queue-item]")??k.current?.querySelector("[data-queue-empty]"))?.focus()},[Ne,le]);const J=l.useRef(null),Ce=e=>()=>{J.current=e},Be=e=>{e.relatedTarget&&!k.current?.contains(e.relatedTarget)&&(J.current=null)},A=e=>{if(J.current!==e)return!1;const t=document.activeElement;return!t||t===document.body?!0:k.current?.contains(t)?!!t.closest(`[data-queue-item="${CSS.escape(e)}"]`):!1},E=l.useRef(null),O=(e,t)=>{E.current=t,b(e.key,{...e,open:!1})},ue=l.useRef(R),U=l.useRef(new Map),[,Ee]=l.useState(0),V=l.useRef(new Set),de=(e,t,r)=>{const c=t.indexOf(e),f=t.slice(c+1).find(i=>r.has(i));if(f)return{kind:"item",key:f};const o=t.slice(0,c).reverse().find(i=>r.has(i));return o?{kind:"item",key:o}:{kind:"empty"}};l.useLayoutEffect(()=>{const e=ue.current;ue.current=R;const t=new Set(R),r=U.current;U.current=new Map;const c=[];let f=!1;for(const[o,i]of r){const u=t.has(o);c.push(i.announce??i.sentence),u||(f=!0),V.current.delete(o);const d=u?{kind:"trigger",key:o,actionId:i.actionId}:e.includes(o)?de(o,e,t):null,m=x.current[o];if(m?.surface)O(m,d??{kind:"empty"});else{const I=A(o);m&&b(o,null),d&&I&&q(d)}}for(const o of e.filter(i=>!t.has(i))){if(r.has(o))continue;L(m=>o in m?T(m,o):m);const i=de(o,e,t),u=E.current;if(u&&"key"in u&&u.key===o&&(E.current=i),$.current[o]){V.current.add(o),A(o)&&q(i);continue}const d=x.current[o];if(d&&!(d.surface&&!d.open))if(c.push(g.decidedElsewhere(d.label)),f=!0,d.surface)O(d,i);else{const m=A(o);b(o,null),m&&q(i)}else!d&&A(o)&&q(i)}c.length&&ae(`${c.join(" ")}${f?` ${g.left(R.length)}`:""}`)});const M=async(e,t,r,c)=>{const f=F.current.get(e)??t,o=h(f),i=r.edit?N(r).run:r.run;oe(u=>({...u,[e]:r.id})),L(u=>T(u,e));try{const u=await i(f,c);U.current.set(e,{actionId:r.id,sentence:g.decided(r.done??r.label,o),announce:u?u.announce:void 0}),Ee(d=>d+1)}catch(u){const d=Ve(u,g.unknownError);ae(g.failed(r.label,o,d));const m=x.current[e];V.current.delete(e)?m?.surface?O(m,{kind:"empty"}):m&&b(e,null):m?b(e,{...m,error:d}):L(I=>({...I,[e]:d}))}finally{oe(u=>T(u,e))}},Ie=(e,t)=>{const r=S(e),c=N(t);if(!t.confirm&&!t.reason&&!c){M(r,e,t,{});return}L(f=>T(f,r)),b(r,{key:r,label:h(e),item:e,action:t,draft:c?c.edit.initial(e):void 0,reason:{},surface:!!c?.edit.surface,open:!0}),c?.edit.surface||q({kind:"step",key:r})},X=e=>{const t=x.current[e];if(!t||$.current[e])return;const r={kind:"trigger",key:e,actionId:t.action.id};t.surface?O(t,r):(b(e,null),q(r))},Te=e=>{const t=x.current[e];!t||$.current[e]||xe(t,F.current.get(e)??t.item,g)||(t.action.edit?M(e,t.item,t.action,{draft:t.draft}):t.action.reason?M(e,t.item,t.action,{reason:Ye(t.reason)}):M(e,t.item,t.action,{}))},Fe=e=>{const t=E.current;E.current=null,b(e,null),t&&q(t)},Le=`h${p}`,fe=v??Ue(p+1),Ae=`h${fe}`,Y=`${C}-label`,pe=(e,t)=>{const{action:r}=e,c=N(r),f=F.current.get(e.key)??e.item,o=!!K[e.key],i=xe(e,f,g),u=`${C}-step-${t}-message`,d=s.jsx(ee,{...ge[r.tone??"neutral"],busy:o,loadingLabel:g.busy,blocked:!!i,"aria-describedby":i?u:void 0,onClick:()=>Te(e.key),"data-queue-submit":"",children:c?c.edit.submitLabel:r.label}),m=s.jsx(ee,{variant:"ghost",colorScheme:"neutral",blocked:o,onClick:()=>X(e.key),children:g.cancel}),I=s.jsxs(s.Fragment,{children:[r.reason&&s.jsx(Ze,{id:`${C}-step-${t}`,step:r.reason,labels:g,value:e.reason,disabled:o,onChange:Z=>b(e.key,{...x.current[e.key],reason:Z})}),c&&s.jsx(c.edit.Form,{item:f,value:e.draft,onChange:Z=>b(e.key,{...x.current[e.key],draft:Z})}),i&&s.jsx("p",{id:u,className:"rst:text-sm rst:text-error-600 rst:dark:text-error-400","data-queue-validation":"",children:i}),e.error&&s.jsx(_.Alert,{colorScheme:"error",role:"group","aria-live":"off",children:e.error})]});return{submitButton:d,cancelButton:m,fields:I}},Oe=(e,t)=>{const{submitButton:r,cancelButton:c,fields:f}=pe(e,t),o=`${C}-step-${t}-prompt`,i=N(e.action),u=e.action.reason?.prompt??e.action.confirm?.prompt??i?.edit.title;return s.jsxs("div",{role:"group","aria-labelledby":o,tabIndex:-1,"data-queue-step":"",onKeyDown:d=>{d.key==="Escape"&&(d.stopPropagation(),X(e.key))},className:"rst:flex rst:flex-col rst:gap-3 rst:rounded-lg rst:border rst:border-[var(--roster-card-border)] rst:p-4 rst:focus-visible:outline-hidden rst:focus-visible:ring-2 rst:focus-visible:ring-ring",children:[s.jsx("p",{id:o,className:"rst:text-sm rst:font-medium rst:text-[var(--roster-control-text)]",children:u}),i?.edit.description&&s.jsx("p",{className:"rst:text-sm rst:text-gray-600 rst:dark:text-gray-300",children:i.edit.description}),f,s.jsxs("div",{className:"rst:flex rst:flex-wrap rst:gap-2",children:[r,c]})]})},Me=(e,t)=>{const r=K[t];return s.jsx("div",{role:"group","aria-label":g.decide(h(e)),className:"rst:flex rst:flex-wrap rst:gap-2",children:qe.filter(c=>!c.hidden?.(e)).map(c=>s.jsx(ee,{...ge[c.tone??"neutral"],"data-queue-action":c.id,busy:r===c.id,loadingLabel:g.busy,blocked:!!r&&r!==c.id,onClick:()=>Ie(e,c),children:c.label},c.id))})},j=Object.values(ie).find(e=>e.surface)??null,P=j?N(j.action):null,me=P?.edit.surface,z=j?pe(j,-1):null;return s.jsxs("section",{ref:k,"aria-labelledby":Y,onBlur:Be,className:D.cn("rst:font-ui rst:flex rst:flex-col rst:gap-4",je),children:[s.jsx(Le,{id:Y,className:D.cn("rst:text-lg rst:font-semibold rst:text-[var(--roster-control-text)]",a&&"rst:sr-only"),children:n}),s.jsxs("div",{role:"status","aria-live":"polite","aria-atomic":"true",className:"rst:sr-only","data-queue-live":"","data-queue-live-n":Q.n,children:[Q.text,Q.n%2?" ":""]}),te==="loading"?s.jsx("div",{className:"rst:flex rst:justify-center rst:py-12","aria-busy":"true",children:s.jsx(De.Spinner,{size:"lg",label:g.loading(n)})}):te==="error"?s.jsx(_.Alert,{colorScheme:"error",children:s.jsxs("div",{className:"rst:flex rst:flex-col rst:items-start rst:gap-3",children:[s.jsx("div",{children:ve??g.loadFailed}),re&&s.jsx(he.Button,{size:"lg",variant:"outline",colorScheme:"neutral",onClick:re,children:g.retry})]})}):y.length===0?s.jsx(Ke.EmptyState,{title:ne.title,description:ne.description,headingLevel:fe,tabIndex:-1,"data-queue-empty":"",className:"rst:focus-visible:outline-hidden rst:focus-visible:ring-2 rst:focus-visible:ring-ring"}):s.jsx("ul",{role:"list","aria-labelledby":Y,className:"rst:m-0 rst:flex rst:list-none rst:flex-col rst:gap-3 rst:p-0",children:y.map((e,t)=>{const r=R[t],c=`${C}-item-${t}`,f=w?.(e),o=ie[r];return s.jsx("li",{children:s.jsx("article",{"data-queue-item":r,tabIndex:-1,"aria-labelledby":c,onFocus:Ce(r),className:"rst:rounded-xl rst:focus-visible:outline-hidden rst:focus-visible:ring-2 rst:focus-visible:ring-ring rst:focus-visible:ring-offset-2 rst:ring-offset-background",children:s.jsx(ze.Card,{padding:se==="compact"?"sm":"md",children:s.jsxs("div",{className:D.cn("rst:flex rst:flex-col",se==="compact"?"rst:gap-3":"rst:gap-4"),children:[s.jsxs("div",{className:"rst:flex rst:flex-wrap rst:items-baseline rst:gap-x-3 rst:gap-y-1",children:[s.jsx(Ae,{id:c,className:"rst:text-base rst:font-semibold",children:h(e)}),f&&s.jsx("div",{className:"rst:flex rst:flex-wrap rst:items-center rst:gap-2 rst:text-sm rst:text-gray-600 rst:dark:text-gray-300",children:f})]}),s.jsx("div",{className:"rst:min-w-0",children:be(e)}),ce[r]&&s.jsx(_.Alert,{colorScheme:"error",role:"group","aria-live":"off",children:ce[r]}),o&&!o.surface?Oe(o,t):Me(e,r)]})})})},r)})}),ye,me&&j&&P&&z&&s.jsx(me,{open:j.open,title:P.edit.title,description:P.edit.description,busy:!!K[j.key],onCancel:()=>X(j.key),onAfterClose:()=>Fe(j.key),submitButton:z.submitButton,cancelButton:z.cancelButton,closeLabel:g.close,children:s.jsx("div",{className:"rst:flex rst:flex-col rst:gap-4",children:z.fields})})]})}function xe(n,a,p){const v=N(n.action);if(v)return v.edit.validate?.(n.draft,a);if(n.action.reason){if(n.action.reason.required&&n.action.reason.options?.length&&!n.reason.value)return p.pickReason;if(n.action.reason.note==="required"&&!n.reason.note?.trim())return p.addNote}}function Ye(n){const a=n.note?.trim();return{...n.value?{value:n.value}:{},...a?{note:a}:{}}}function Ze({id:n,step:a,value:p,disabled:v,onChange:y,labels:S}){const h=a.note??"optional";return s.jsxs(s.Fragment,{children:[a.options&&a.options.length>0&&s.jsx(Qe.RadioGroup,{label:a.required?S.reason:S.reasonOptional,options:a.options,value:p.value??"",onChange:w=>y({...p,value:w}),disabled:v}),h!=="none"&&s.jsx(He.Textarea,{id:`${n}-note`,label:a.noteLabel??(h==="required"?S.note:S.noteOptional),rows:3,value:p.note??"",onChange:w=>y({...p,note:w.target.value}),disabled:v})]})}exports.ModerationQueue=Xe;
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),l=require("react"),z=require("../../../lib/utils.cjs"),Pe=require("../../../lib/labels.cjs"),he=require("../../atoms/Button/Button.cjs"),Ke=require("../../atoms/Card/Card.cjs"),ze=require("../../atoms/Spinner/Spinner.cjs"),De=require("../../atoms/Textarea/Textarea.cjs"),_=require("../../molecules/Alert/Alert.cjs"),He=require("../../molecules/EmptyState/EmptyState.cjs"),Qe=require("../../molecules/RadioGroup/RadioGroup.cjs"),Ge=require("./queue-actions.cjs"),We=require("../../../internal/key-focus.cjs"),Je={loading:n=>`Loading ${n}`,loadFailed:"The queue couldn't load.",retry:"Retry",busy:"loading",cancel:"Cancel",decide:n=>`Decide: ${n}`,decided:(n,a)=>`${n}: ${a}.`,failed:(n,a,p)=>`${n} didn't go through for ${a}. ${p}`,unknownError:"Something went wrong.",decidedElsewhere:n=>`${n} was decided elsewhere.`,left:n=>n===0?"None left.":`${n} left.`,pickReason:"Pick a reason.",addNote:"Add a note.",reason:"Reason",reasonOptional:"Reason (optional)",note:"Note",noteOptional:"Note (optional)"},ge={primary:{colorScheme:"primary",variant:"solid"},success:{colorScheme:"success",variant:"solid"},danger:{colorScheme:"error",variant:"soft"},neutral:{colorScheme:"neutral",variant:"outline"}},Ue={edit:Ge.editAction},N=n=>n.edit?n:null,Ve=n=>Math.min(6,Math.max(1,n)),Xe=(n,a)=>n instanceof Error&&n.message?n.message:a;function F(n,a){const p={...n};return delete p[a],p}function ee({busy:n=!1,blocked:a=!1,onClick:p,children:v,className:y,...S}){return s.jsx(he.Button,{size:"lg",...S,isLoading:n,"aria-disabled":a||void 0,className:z.cn(a&&!n&&"rst:cursor-not-allowed rst:opacity-50",y),onClick:h=>{if(a){h.preventDefault();return}p?.(h)},children:v})}function Ye({label:n,hideLabel:a=!1,headingLevel:p=2,itemHeadingLevel:v,items:y,getKey:S,itemLabel:h,renderMeta:w,renderContent:be,actions:D,status:te="ready",error:ve,onRetry:re,empty:ne={title:"Nothing waiting"},density:se="comfortable",footer:ye,labels:Se,className:je}){We.useKeyFocus();const g=Pe.withLabels(Je,Se),qe=typeof D=="function"?D(Ue):D,C=l.useId(),k=l.useRef(null),R=y.map(S),T=l.useRef(new Map);T.current=new Map(y.map((e,t)=>[R[t],e]));const[H,ke]=l.useState({}),$=l.useRef({}),oe=e=>{$.current=e($.current),ke($.current)},[ce,L]=l.useState({}),[ie,Re]=l.useState({}),x=l.useRef({}),b=(e,t)=>{x.current=t?{...x.current,[e]:t}:F(x.current,e),Re(x.current)},[Q,$e]=l.useState({text:"",n:0}),G=l.useRef([]),B=l.useRef(null),ae=l.useCallback(e=>{G.current.push(e),!B.current&&(B.current=setTimeout(()=>{B.current=null;const t=G.current.join(" ");G.current=[],$e(r=>({text:t,n:r.n+1}))},0))},[]);l.useLayoutEffect(()=>()=>{B.current&&clearTimeout(B.current)},[]);const[Ne,we]=l.useState(0),W=l.useRef(null),q=l.useCallback(e=>{W.current=e,we(t=>t+1)},[]),le=l.useCallback(e=>{const t=k.current;if(!t)return null;const r="key"in e?CSS.escape(e.key):"";switch(e.kind){case"item":return t.querySelector(`[data-queue-item="${r}"]`);case"empty":return t.querySelector("[data-queue-empty]");case"trigger":return t.querySelector(`[data-queue-item="${r}"] [data-queue-action="${CSS.escape(e.actionId)}"]`);case"step":return t.querySelector(`[data-queue-item="${r}"] [data-queue-step]`)}},[]);l.useLayoutEffect(()=>{const e=W.current;if(!e)return;W.current=null,(le(e)??k.current?.querySelector("[data-queue-item]")??k.current?.querySelector("[data-queue-empty]"))?.focus()},[Ne,le]);const J=l.useRef(null),Ce=e=>()=>{J.current=e},Be=e=>{e.relatedTarget&&!k.current?.contains(e.relatedTarget)&&(J.current=null)},A=e=>{if(J.current!==e)return!1;const t=document.activeElement;return!t||t===document.body?!0:k.current?.contains(t)?!!t.closest(`[data-queue-item="${CSS.escape(e)}"]`):!1},E=l.useRef(null),O=(e,t)=>{E.current=t,b(e.key,{...e,open:!1})},ue=l.useRef(R),U=l.useRef(new Map),[,Ee]=l.useState(0),V=l.useRef(new Set),de=(e,t,r)=>{const c=t.indexOf(e),f=t.slice(c+1).find(i=>r.has(i));if(f)return{kind:"item",key:f};const o=t.slice(0,c).reverse().find(i=>r.has(i));return o?{kind:"item",key:o}:{kind:"empty"}};l.useLayoutEffect(()=>{const e=ue.current;ue.current=R;const t=new Set(R),r=U.current;U.current=new Map;const c=[];let f=!1;for(const[o,i]of r){const u=t.has(o);c.push(i.announce??i.sentence),u||(f=!0),V.current.delete(o);const d=u?{kind:"trigger",key:o,actionId:i.actionId}:e.includes(o)?de(o,e,t):null,m=x.current[o];if(m?.surface)O(m,d??{kind:"empty"});else{const I=A(o);m&&b(o,null),d&&I&&q(d)}}for(const o of e.filter(i=>!t.has(i))){if(r.has(o))continue;L(m=>o in m?F(m,o):m);const i=de(o,e,t),u=E.current;if(u&&"key"in u&&u.key===o&&(E.current=i),$.current[o]){V.current.add(o),A(o)&&q(i);continue}const d=x.current[o];if(d&&!(d.surface&&!d.open))if(c.push(g.decidedElsewhere(d.label)),f=!0,d.surface)O(d,i);else{const m=A(o);b(o,null),m&&q(i)}else!d&&A(o)&&q(i)}c.length&&ae(`${c.join(" ")}${f?` ${g.left(R.length)}`:""}`)});const M=async(e,t,r,c)=>{const f=T.current.get(e)??t,o=h(f),i=r.edit?N(r).run:r.run;oe(u=>({...u,[e]:r.id})),L(u=>F(u,e));try{const u=await i(f,c);U.current.set(e,{actionId:r.id,sentence:g.decided(r.done??r.label,o),announce:u?u.announce:void 0}),Ee(d=>d+1)}catch(u){const d=Xe(u,g.unknownError);ae(g.failed(r.label,o,d));const m=x.current[e];V.current.delete(e)?m?.surface?O(m,{kind:"empty"}):m&&b(e,null):m?b(e,{...m,error:d}):L(I=>({...I,[e]:d}))}finally{oe(u=>F(u,e))}},Ie=(e,t)=>{const r=S(e),c=N(t);if(!t.confirm&&!t.reason&&!c){M(r,e,t,{});return}L(f=>F(f,r)),b(r,{key:r,label:h(e),item:e,action:t,draft:c?c.edit.initial(e):void 0,reason:{},surface:!!c?.edit.surface,open:!0}),c?.edit.surface||q({kind:"step",key:r})},X=e=>{const t=x.current[e];if(!t||$.current[e])return;const r={kind:"trigger",key:e,actionId:t.action.id};t.surface?O(t,r):(b(e,null),q(r))},Fe=e=>{const t=x.current[e];!t||$.current[e]||xe(t,T.current.get(e)??t.item,g)||(t.action.edit?M(e,t.item,t.action,{draft:t.draft}):t.action.reason?M(e,t.item,t.action,{reason:Ze(t.reason)}):M(e,t.item,t.action,{}))},Te=e=>{const t=E.current;E.current=null,b(e,null),t&&q(t)},Le=`h${p}`,fe=v??Ve(p+1),Ae=`h${fe}`,Y=`${C}-label`,pe=(e,t)=>{const{action:r}=e,c=N(r),f=T.current.get(e.key)??e.item,o=!!H[e.key],i=xe(e,f,g),u=`${C}-step-${t}-message`,d=s.jsx(ee,{...ge[r.tone??"neutral"],busy:o,loadingLabel:g.busy,blocked:!!i,"aria-describedby":i?u:void 0,onClick:()=>Fe(e.key),"data-queue-submit":"",children:c?c.edit.submitLabel:r.label}),m=s.jsx(ee,{variant:"ghost",colorScheme:"neutral",blocked:o,onClick:()=>X(e.key),children:g.cancel}),I=s.jsxs(s.Fragment,{children:[r.reason&&s.jsx(_e,{id:`${C}-step-${t}`,step:r.reason,labels:g,value:e.reason,disabled:o,onChange:Z=>b(e.key,{...x.current[e.key],reason:Z})}),c&&s.jsx(c.edit.Form,{item:f,value:e.draft,onChange:Z=>b(e.key,{...x.current[e.key],draft:Z})}),i&&s.jsx("p",{id:u,className:"rst:text-sm rst:text-error-600 rst:dark:text-error-400","data-queue-validation":"",children:i}),e.error&&s.jsx(_.Alert,{colorScheme:"error",role:"group","aria-live":"off",children:e.error})]});return{submitButton:d,cancelButton:m,fields:I}},Oe=(e,t)=>{const{submitButton:r,cancelButton:c,fields:f}=pe(e,t),o=`${C}-step-${t}-prompt`,i=N(e.action),u=e.action.reason?.prompt??e.action.confirm?.prompt??i?.edit.title;return s.jsxs("div",{role:"group","aria-labelledby":o,tabIndex:-1,"data-queue-step":"",onKeyDown:d=>{d.key==="Escape"&&(d.stopPropagation(),X(e.key))},className:"rst:flex rst:flex-col rst:gap-3 rst:rounded-lg rst:border rst:border-[var(--roster-card-border)] rst:p-4 rst:focus-visible:outline-hidden rst:focus-visible:ring-2 rst:focus-visible:ring-ring",children:[s.jsx("p",{id:o,className:"rst:text-sm rst:font-medium rst:text-[var(--roster-control-text)]",children:u}),i?.edit.description&&s.jsx("p",{className:"rst:text-sm rst:text-gray-600 rst:dark:text-gray-300",children:i.edit.description}),f,s.jsxs("div",{className:"rst:flex rst:flex-wrap rst:gap-2",children:[r,c]})]})},Me=(e,t)=>{const r=H[t];return s.jsx("div",{role:"group","aria-label":g.decide(h(e)),className:"rst:flex rst:flex-wrap rst:gap-2",children:qe.filter(c=>!c.hidden?.(e)).map(c=>s.jsx(ee,{...ge[c.tone??"neutral"],"data-queue-action":c.id,busy:r===c.id,loadingLabel:g.busy,blocked:!!r&&r!==c.id,onClick:()=>Ie(e,c),children:c.label},c.id))})},j=Object.values(ie).find(e=>e.surface)??null,P=j?N(j.action):null,me=P?.edit.surface,K=j?pe(j,-1):null;return s.jsxs("section",{ref:k,"aria-labelledby":Y,onBlur:Be,className:z.cn("rst:font-ui rst:flex rst:flex-col rst:gap-4",je),children:[s.jsx(Le,{id:Y,className:z.cn("rst:text-lg rst:font-semibold rst:text-[var(--roster-control-text)]",a&&"rst:sr-only"),children:n}),s.jsxs("div",{role:"status","aria-live":"polite","aria-atomic":"true",className:"rst:sr-only","data-queue-live":"","data-queue-live-n":Q.n,children:[Q.text,Q.n%2?" ":""]}),te==="loading"?s.jsx("div",{className:"rst:flex rst:justify-center rst:py-12","aria-busy":"true",children:s.jsx(ze.Spinner,{size:"lg",label:g.loading(n)})}):te==="error"?s.jsx(_.Alert,{colorScheme:"error",children:s.jsxs("div",{className:"rst:flex rst:flex-col rst:items-start rst:gap-3",children:[s.jsx("div",{children:ve??g.loadFailed}),re&&s.jsx(he.Button,{size:"lg",variant:"outline",colorScheme:"neutral",onClick:re,children:g.retry})]})}):y.length===0?s.jsx(He.EmptyState,{title:ne.title,description:ne.description,headingLevel:fe,tabIndex:-1,"data-queue-empty":"",className:"rst:focus-visible:outline-hidden rst:focus-visible:ring-2 rst:focus-visible:ring-ring"}):s.jsx("ul",{role:"list","aria-labelledby":Y,className:"rst:m-0 rst:flex rst:list-none rst:flex-col rst:gap-3 rst:p-0",children:y.map((e,t)=>{const r=R[t],c=`${C}-item-${t}`,f=w?.(e),o=ie[r];return s.jsx("li",{children:s.jsx("article",{"data-queue-item":r,tabIndex:-1,"aria-labelledby":c,onFocus:Ce(r),className:"rst:rounded-xl rst:focus-visible:outline-hidden rst:focus-visible:ring-2 rst:focus-visible:ring-ring rst:focus-visible:ring-offset-2 rst:ring-offset-background",children:s.jsx(Ke.Card,{padding:se==="compact"?"sm":"md",children:s.jsxs("div",{className:z.cn("rst:flex rst:flex-col",se==="compact"?"rst:gap-3":"rst:gap-4"),children:[s.jsxs("div",{className:"rst:flex rst:flex-wrap rst:items-baseline rst:gap-x-3 rst:gap-y-1",children:[s.jsx(Ae,{id:c,className:"rst:text-base rst:font-semibold",children:h(e)}),f&&s.jsx("div",{className:"rst:flex rst:flex-wrap rst:items-center rst:gap-2 rst:text-sm rst:text-gray-600 rst:dark:text-gray-300",children:f})]}),s.jsx("div",{className:"rst:min-w-0",children:be(e)}),ce[r]&&s.jsx(_.Alert,{colorScheme:"error",role:"group","aria-live":"off",children:ce[r]}),o&&!o.surface?Oe(o,t):Me(e,r)]})})})},r)})}),ye,me&&j&&P&&K&&s.jsx(me,{open:j.open,title:P.edit.title,description:P.edit.description,busy:!!H[j.key],onCancel:()=>X(j.key),onAfterClose:()=>Te(j.key),submitButton:K.submitButton,cancelButton:K.cancelButton,closeLabel:g.close,children:s.jsx("div",{className:"rst:flex rst:flex-col rst:gap-4",children:K.fields})})]})}function xe(n,a,p){const v=N(n.action);if(v)return v.edit.validate?.(n.draft,a);if(n.action.reason){if(n.action.reason.required&&n.action.reason.options?.length&&!n.reason.value)return p.pickReason;if(n.action.reason.note==="required"&&!n.reason.note?.trim())return p.addNote}}function Ze(n){const a=n.note?.trim();return{...n.value?{value:n.value}:{},...a?{note:a}:{}}}function _e({id:n,step:a,value:p,disabled:v,onChange:y,labels:S}){const h=a.note??"optional";return s.jsxs(s.Fragment,{children:[a.options&&a.options.length>0&&s.jsx(Qe.RadioGroup,{label:a.required?S.reason:S.reasonOptional,options:a.options,value:p.value??"",onChange:w=>y({...p,value:w}),disabled:v}),h!=="none"&&s.jsx(De.Textarea,{id:`${n}-note`,label:a.noteLabel??(h==="required"?S.note:S.noteOptional),rows:3,value:p.note??"",onChange:w=>y({...p,note:w.target.value}),disabled:v})]})}exports.ModerationQueue=Ye;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs as q, jsx as c, Fragment as Se } from "react/jsx-runtime";
|
|
3
3
|
import { useId as Qe, useRef as g, useState as I, useCallback as te, useLayoutEffect as re } from "react";
|
|
4
|
-
import { cn as
|
|
4
|
+
import { cn as H } from "../../../lib/utils.js";
|
|
5
5
|
import { withLabels as Ge } from "../../../lib/labels.js";
|
|
6
6
|
import { Button as ke } from "../../atoms/Button/Button.js";
|
|
7
7
|
import { Card as We } from "../../atoms/Card/Card.js";
|
|
@@ -11,7 +11,8 @@ import { Alert as ne } from "../../molecules/Alert/Alert.js";
|
|
|
11
11
|
import { EmptyState as Ve } from "../../molecules/EmptyState/EmptyState.js";
|
|
12
12
|
import { RadioGroup as Xe } from "../../molecules/RadioGroup/RadioGroup.js";
|
|
13
13
|
import { editAction as Ye } from "./queue-actions.js";
|
|
14
|
-
|
|
14
|
+
import { useKeyFocus as Ze } from "../../../internal/key-focus.js";
|
|
15
|
+
const _e = {
|
|
15
16
|
loading: (n) => `Loading ${n}`,
|
|
16
17
|
loadFailed: "The queue couldn't load.",
|
|
17
18
|
retry: "Retry",
|
|
@@ -34,7 +35,7 @@ const Ze = {
|
|
|
34
35
|
success: { colorScheme: "success", variant: "solid" },
|
|
35
36
|
danger: { colorScheme: "error", variant: "soft" },
|
|
36
37
|
neutral: { colorScheme: "neutral", variant: "outline" }
|
|
37
|
-
},
|
|
38
|
+
}, et = { edit: Ye }, R = (n) => n.edit ? n : null, tt = (n) => Math.min(6, Math.max(1, n)), rt = (n, a) => n instanceof Error && n.message ? n.message : a;
|
|
38
39
|
function O(n, a) {
|
|
39
40
|
const f = { ...n };
|
|
40
41
|
return delete f[a], f;
|
|
@@ -54,7 +55,7 @@ function oe({
|
|
|
54
55
|
...S,
|
|
55
56
|
isLoading: n,
|
|
56
57
|
"aria-disabled": a || void 0,
|
|
57
|
-
className:
|
|
58
|
+
className: H(a && !n && "rst:cursor-not-allowed rst:opacity-50", x),
|
|
58
59
|
onClick: (b) => {
|
|
59
60
|
if (a) {
|
|
60
61
|
b.preventDefault();
|
|
@@ -66,7 +67,7 @@ function oe({
|
|
|
66
67
|
}
|
|
67
68
|
);
|
|
68
69
|
}
|
|
69
|
-
function
|
|
70
|
+
function vt({
|
|
70
71
|
label: n,
|
|
71
72
|
hideLabel: a = !1,
|
|
72
73
|
headingLevel: f = 2,
|
|
@@ -86,27 +87,28 @@ function ht({
|
|
|
86
87
|
labels: we,
|
|
87
88
|
className: Ce
|
|
88
89
|
}) {
|
|
89
|
-
|
|
90
|
+
Ze();
|
|
91
|
+
const p = Ge(_e, we), Ie = typeof Q == "function" ? Q(et) : Q, E = Qe(), N = g(null), w = x.map(S), j = g(/* @__PURE__ */ new Map());
|
|
90
92
|
j.current = new Map(x.map((e, t) => [w[t], e]));
|
|
91
93
|
const [G, Re] = I({}), C = g({}), le = (e) => {
|
|
92
94
|
C.current = e(C.current), Re(C.current);
|
|
93
95
|
}, [ue, M] = I({}), [de, Be] = I({}), h = g({}), v = (e, t) => {
|
|
94
96
|
h.current = t ? { ...h.current, [e]: t } : O(h.current, e), Be(h.current);
|
|
95
|
-
}, [W, Ee] = I({ text: "", n: 0 }), J = g([]),
|
|
96
|
-
J.current.push(e), !
|
|
97
|
-
|
|
97
|
+
}, [W, Ee] = I({ text: "", n: 0 }), J = g([]), F = g(null), fe = te((e) => {
|
|
98
|
+
J.current.push(e), !F.current && (F.current = setTimeout(() => {
|
|
99
|
+
F.current = null;
|
|
98
100
|
const t = J.current.join(" ");
|
|
99
101
|
J.current = [], Ee((r) => ({ text: t, n: r.n + 1 }));
|
|
100
102
|
}, 0));
|
|
101
103
|
}, []);
|
|
102
104
|
re(
|
|
103
105
|
() => () => {
|
|
104
|
-
|
|
106
|
+
F.current && clearTimeout(F.current);
|
|
105
107
|
},
|
|
106
108
|
[]
|
|
107
109
|
);
|
|
108
|
-
const [
|
|
109
|
-
U.current = e,
|
|
110
|
+
const [Fe, Te] = I(0), U = g(null), $ = te((e) => {
|
|
111
|
+
U.current = e, Te((t) => t + 1);
|
|
110
112
|
}, []), me = te((e) => {
|
|
111
113
|
const t = N.current;
|
|
112
114
|
if (!t) return null;
|
|
@@ -126,7 +128,7 @@ function ht({
|
|
|
126
128
|
const e = U.current;
|
|
127
129
|
if (!e) return;
|
|
128
130
|
U.current = null, (me(e) ?? N.current?.querySelector("[data-queue-item]") ?? N.current?.querySelector("[data-queue-empty]"))?.focus();
|
|
129
|
-
}, [
|
|
131
|
+
}, [Fe, me]);
|
|
130
132
|
const V = g(null), Le = (e) => () => {
|
|
131
133
|
V.current = e;
|
|
132
134
|
}, Oe = (e) => {
|
|
@@ -135,8 +137,8 @@ function ht({
|
|
|
135
137
|
if (V.current !== e) return !1;
|
|
136
138
|
const t = document.activeElement;
|
|
137
139
|
return !t || t === document.body ? !0 : N.current?.contains(t) ? !!t.closest(`[data-queue-item="${CSS.escape(e)}"]`) : !1;
|
|
138
|
-
},
|
|
139
|
-
|
|
140
|
+
}, T = g(null), P = (e, t) => {
|
|
141
|
+
T.current = t, v(e.key, { ...e, open: !1 });
|
|
140
142
|
}, pe = g(w), X = g(/* @__PURE__ */ new Map()), [, je] = I(0), Y = g(/* @__PURE__ */ new Set()), ge = (e, t, r) => {
|
|
141
143
|
const s = t.indexOf(e), d = t.slice(s + 1).find((i) => r.has(i));
|
|
142
144
|
if (d) return { kind: "item", key: d };
|
|
@@ -164,8 +166,8 @@ function ht({
|
|
|
164
166
|
for (const o of e.filter((i) => !t.has(i))) {
|
|
165
167
|
if (r.has(o)) continue;
|
|
166
168
|
M((m) => o in m ? O(m, o) : m);
|
|
167
|
-
const i = ge(o, e, t), l =
|
|
168
|
-
if (l && "key" in l && l.key === o && (
|
|
169
|
+
const i = ge(o, e, t), l = T.current;
|
|
170
|
+
if (l && "key" in l && l.key === o && (T.current = i), C.current[o]) {
|
|
169
171
|
Y.current.add(o), A(o) && $(i);
|
|
170
172
|
continue;
|
|
171
173
|
}
|
|
@@ -180,7 +182,7 @@ function ht({
|
|
|
180
182
|
}
|
|
181
183
|
s.length && fe(`${s.join(" ")}${d ? ` ${p.left(w.length)}` : ""}`);
|
|
182
184
|
});
|
|
183
|
-
const
|
|
185
|
+
const K = async (e, t, r, s) => {
|
|
184
186
|
const d = j.current.get(e) ?? t, o = b(d), i = r.edit ? R(r).run : r.run;
|
|
185
187
|
le((l) => ({ ...l, [e]: r.id })), M((l) => O(l, e));
|
|
186
188
|
try {
|
|
@@ -191,7 +193,7 @@ function ht({
|
|
|
191
193
|
announce: l ? l.announce : void 0
|
|
192
194
|
}), je((u) => u + 1);
|
|
193
195
|
} catch (l) {
|
|
194
|
-
const u =
|
|
196
|
+
const u = rt(l, p.unknownError);
|
|
195
197
|
fe(p.failed(r.label, o, u));
|
|
196
198
|
const m = h.current[e];
|
|
197
199
|
Y.current.delete(e) ? m?.surface ? P(m, { kind: "empty" }) : m && v(e, null) : m ? v(e, { ...m, error: u }) : M((L) => ({ ...L, [e]: u }));
|
|
@@ -201,7 +203,7 @@ function ht({
|
|
|
201
203
|
}, Me = (e, t) => {
|
|
202
204
|
const r = S(e), s = R(t);
|
|
203
205
|
if (!t.confirm && !t.reason && !s) {
|
|
204
|
-
|
|
206
|
+
K(r, e, t, {});
|
|
205
207
|
return;
|
|
206
208
|
}
|
|
207
209
|
M((d) => O(d, r)), v(r, {
|
|
@@ -221,11 +223,11 @@ function ht({
|
|
|
221
223
|
t.surface ? P(t, r) : (v(e, null), $(r));
|
|
222
224
|
}, Ae = (e) => {
|
|
223
225
|
const t = h.current[e];
|
|
224
|
-
!t || C.current[e] || xe(t, j.current.get(e) ?? t.item, p) || (t.action.edit ?
|
|
226
|
+
!t || C.current[e] || xe(t, j.current.get(e) ?? t.item, p) || (t.action.edit ? K(e, t.item, t.action, { draft: t.draft }) : t.action.reason ? K(e, t.item, t.action, { reason: nt(t.reason) }) : K(e, t.item, t.action, {}));
|
|
225
227
|
}, Pe = (e) => {
|
|
226
|
-
const t =
|
|
227
|
-
|
|
228
|
-
},
|
|
228
|
+
const t = T.current;
|
|
229
|
+
T.current = null, v(e, null), t && $(t);
|
|
230
|
+
}, Ke = `h${f}`, he = y ?? tt(f + 1), ze = `h${he}`, _ = `${E}-label`, be = (e, t) => {
|
|
229
231
|
const { action: r } = e, s = R(r), d = j.current.get(e.key) ?? e.item, o = !!G[e.key], i = xe(e, d, p), l = `${E}-step-${t}-message`, u = /* @__PURE__ */ c(
|
|
230
232
|
oe,
|
|
231
233
|
{
|
|
@@ -240,7 +242,7 @@ function ht({
|
|
|
240
242
|
}
|
|
241
243
|
), m = /* @__PURE__ */ c(oe, { variant: "ghost", colorScheme: "neutral", blocked: o, onClick: () => Z(e.key), children: p.cancel }), L = /* @__PURE__ */ q(Se, { children: [
|
|
242
244
|
r.reason && /* @__PURE__ */ c(
|
|
243
|
-
|
|
245
|
+
ot,
|
|
244
246
|
{
|
|
245
247
|
id: `${E}-step-${t}`,
|
|
246
248
|
step: r.reason,
|
|
@@ -262,7 +264,7 @@ function ht({
|
|
|
262
264
|
e.error && /* @__PURE__ */ c(ne, { colorScheme: "error", role: "group", "aria-live": "off", children: e.error })
|
|
263
265
|
] });
|
|
264
266
|
return { submitButton: u, cancelButton: m, fields: L };
|
|
265
|
-
},
|
|
267
|
+
}, De = (e, t) => {
|
|
266
268
|
const { submitButton: r, cancelButton: s, fields: d } = be(e, t), o = `${E}-step-${t}-prompt`, i = R(e.action), l = e.action.reason?.prompt ?? e.action.confirm?.prompt ?? i?.edit.title;
|
|
267
269
|
return /* @__PURE__ */ q(
|
|
268
270
|
"div",
|
|
@@ -286,7 +288,7 @@ function ht({
|
|
|
286
288
|
]
|
|
287
289
|
}
|
|
288
290
|
);
|
|
289
|
-
},
|
|
291
|
+
}, He = (e, t) => {
|
|
290
292
|
const r = G[t];
|
|
291
293
|
return /* @__PURE__ */ c("div", { role: "group", "aria-label": p.decide(b(e)), className: "rst:flex rst:flex-wrap rst:gap-2", children: Ie.filter((s) => !s.hidden?.(e)).map((s) => /* @__PURE__ */ c(
|
|
292
294
|
oe,
|
|
@@ -301,20 +303,20 @@ function ht({
|
|
|
301
303
|
},
|
|
302
304
|
s.id
|
|
303
305
|
)) });
|
|
304
|
-
}, k = Object.values(de).find((e) => e.surface) ?? null,
|
|
306
|
+
}, k = Object.values(de).find((e) => e.surface) ?? null, z = k ? R(k.action) : null, ve = z?.edit.surface, D = k ? be(k, -1) : null;
|
|
305
307
|
return /* @__PURE__ */ q(
|
|
306
308
|
"section",
|
|
307
309
|
{
|
|
308
310
|
ref: N,
|
|
309
311
|
"aria-labelledby": _,
|
|
310
312
|
onBlur: Oe,
|
|
311
|
-
className:
|
|
313
|
+
className: H("rst:font-ui rst:flex rst:flex-col rst:gap-4", Ce),
|
|
312
314
|
children: [
|
|
313
315
|
/* @__PURE__ */ c(
|
|
314
|
-
|
|
316
|
+
Ke,
|
|
315
317
|
{
|
|
316
318
|
id: _,
|
|
317
|
-
className:
|
|
319
|
+
className: H(
|
|
318
320
|
"rst:text-lg rst:font-semibold rst:text-[var(--roster-control-text)]",
|
|
319
321
|
a && "rst:sr-only"
|
|
320
322
|
),
|
|
@@ -368,14 +370,14 @@ function ht({
|
|
|
368
370
|
"aria-labelledby": s,
|
|
369
371
|
onFocus: Le(r),
|
|
370
372
|
className: "rst:rounded-xl rst:focus-visible:outline-hidden rst:focus-visible:ring-2 rst:focus-visible:ring-ring rst:focus-visible:ring-offset-2 rst:ring-offset-background",
|
|
371
|
-
children: /* @__PURE__ */ c(We, { padding: ae === "compact" ? "sm" : "md", children: /* @__PURE__ */ q("div", { className:
|
|
373
|
+
children: /* @__PURE__ */ c(We, { padding: ae === "compact" ? "sm" : "md", children: /* @__PURE__ */ q("div", { className: H("rst:flex rst:flex-col", ae === "compact" ? "rst:gap-3" : "rst:gap-4"), children: [
|
|
372
374
|
/* @__PURE__ */ q("div", { className: "rst:flex rst:flex-wrap rst:items-baseline rst:gap-x-3 rst:gap-y-1", children: [
|
|
373
|
-
/* @__PURE__ */ c(
|
|
375
|
+
/* @__PURE__ */ c(ze, { id: s, className: "rst:text-base rst:font-semibold", children: b(e) }),
|
|
374
376
|
d && /* @__PURE__ */ c("div", { className: "rst:flex rst:flex-wrap rst:items-center rst:gap-2 rst:text-sm rst:text-gray-600 rst:dark:text-gray-300", children: d })
|
|
375
377
|
] }),
|
|
376
378
|
/* @__PURE__ */ c("div", { className: "rst:min-w-0", children: qe(e) }),
|
|
377
379
|
ue[r] && /* @__PURE__ */ c(ne, { colorScheme: "error", role: "group", "aria-live": "off", children: ue[r] }),
|
|
378
|
-
o && !o.surface ?
|
|
380
|
+
o && !o.surface ? De(o, t) : He(e, r)
|
|
379
381
|
] }) })
|
|
380
382
|
}
|
|
381
383
|
) }, r);
|
|
@@ -384,19 +386,19 @@ function ht({
|
|
|
384
386
|
)
|
|
385
387
|
),
|
|
386
388
|
Ne,
|
|
387
|
-
ve && k &&
|
|
389
|
+
ve && k && z && D && /* @__PURE__ */ c(
|
|
388
390
|
ve,
|
|
389
391
|
{
|
|
390
392
|
open: k.open,
|
|
391
|
-
title:
|
|
392
|
-
description:
|
|
393
|
+
title: z.edit.title,
|
|
394
|
+
description: z.edit.description,
|
|
393
395
|
busy: !!G[k.key],
|
|
394
396
|
onCancel: () => Z(k.key),
|
|
395
397
|
onAfterClose: () => Pe(k.key),
|
|
396
|
-
submitButton:
|
|
397
|
-
cancelButton:
|
|
398
|
+
submitButton: D.submitButton,
|
|
399
|
+
cancelButton: D.cancelButton,
|
|
398
400
|
closeLabel: p.close,
|
|
399
|
-
children: /* @__PURE__ */ c("div", { className: "rst:flex rst:flex-col rst:gap-4", children:
|
|
401
|
+
children: /* @__PURE__ */ c("div", { className: "rst:flex rst:flex-col rst:gap-4", children: D.fields })
|
|
400
402
|
}
|
|
401
403
|
)
|
|
402
404
|
]
|
|
@@ -411,11 +413,11 @@ function xe(n, a, f) {
|
|
|
411
413
|
if (n.action.reason.note === "required" && !n.reason.note?.trim()) return f.addNote;
|
|
412
414
|
}
|
|
413
415
|
}
|
|
414
|
-
function
|
|
416
|
+
function nt(n) {
|
|
415
417
|
const a = n.note?.trim();
|
|
416
418
|
return { ...n.value ? { value: n.value } : {}, ...a ? { note: a } : {} };
|
|
417
419
|
}
|
|
418
|
-
function
|
|
420
|
+
function ot({
|
|
419
421
|
id: n,
|
|
420
422
|
step: a,
|
|
421
423
|
value: f,
|
|
@@ -449,5 +451,5 @@ function nt({
|
|
|
449
451
|
] });
|
|
450
452
|
}
|
|
451
453
|
export {
|
|
452
|
-
|
|
454
|
+
vt as ModerationQueue
|
|
453
455
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),m=require("react"),f=require("../../../node_modules/@fortawesome/react-fontawesome/dist/index.cjs"),p=require("../../../node_modules/@fortawesome/free-solid-svg-icons/index.cjs"),n=require("../../../lib/utils.cjs"),cr=require("../../../lib/labels.cjs"),q=require("../../atoms/Button/Button.cjs"),E=require("../../atoms/Link/Link.cjs"),J=require("../../atoms/Badge/Badge.cjs"),dr=require("../../atoms/Avatar/Avatar.cjs"),Q=require("../../atoms/Switch/switch-variants.cjs"),d=require("../../molecules/Menu/Menu.cjs"),lr=require("./navbar-variants.cjs"),L=require("../../../node_modules/@headlessui/react/dist/components/popover/popover.cjs"),ur=require("../../../node_modules/@headlessui/react/dist/components/transition/transition.cjs");function T({on:s,size:e}){return r.jsx("span",{"aria-hidden":"true","data-testid":"navbar-theme-track","data-checked":s?"":void 0,className:n.cn(Q.switchTrackVariants({size:e,variant:"neutral"}),"rst:pointer-events-none"),children:r.jsx("span",{className:n.cn(Q.switchThumbVariants({size:e}))})})}const D="rst:gap-2 rst:px-4 rst:[&>[data-menu-lead]]:w-auto rst:text-gray-700 rst:dark:text-gray-200 rst:focus:bg-gray-50 rst:focus:text-gray-700 rst:dark:focus:bg-gray-700 rst:dark:focus:text-gray-200",xr=n.cn(D,"rst:font-semibold rst:rounded-sm rst:hover:text-gray-900 rst:dark:hover:text-gray-100 rst:hover:focus:text-gray-900 rst:dark:hover:focus:text-gray-100"),W=new WeakMap;function hr(s){if(!s||typeof s=="string")return;let e=W.get(s);return e||(e=a=>r.jsx(s,{...a}),W.set(s,e)),e}const Y=n.cn(D,"rst:border rst:border-transparent rst:font-medium rst:text-gray-600 rst:dark:text-gray-400 rst:focus:text-gray-600 rst:dark:focus:text-gray-400 rst:hover:bg-gray-500/10 rst:dark:hover:bg-gray-400/15 rst:hover:focus:bg-gray-500/10 rst:dark:hover:focus:bg-gray-400/15"),Z=(s,e)=>typeof s=="function"?s({close:e}):s,mr={openMainMenu:"Open main menu",closeMainMenu:"Close menu",openUserMenu:"Open user menu",logIn:"Log In",logOut:"Log Out",darkMode:"Dark Mode",pendingInvitations:"Pending Invitations",inbox:s=>`Inbox (${s})`};function gr(s){return m.useSyncExternalStore(e=>{if(!s||typeof document>"u")return()=>{};const a=new MutationObserver(e);return a.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>a.disconnect()},()=>s&&document.documentElement.classList.contains("dark"),()=>!1)}function H(s,e){if(!e||!s)return!1;if(s.contains(e))return!0;const a=e.closest?.("[data-menu-panel]")?.getAttribute("data-menu-tree");return!!a&&!!s.querySelector(`[data-menu-tree="${CSS.escape(a)}"]`)}const yr='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function fr({close:s,panel:e,hamburger:a}){return m.useEffect(()=>{const x=g=>{const b=g.target;!H(e.current,b)&&!a.current?.contains(b)&&s()};return document.addEventListener("pointerdown",x,{capture:!0}),()=>document.removeEventListener("pointerdown",x,{capture:!0})},[s,e,a]),null}function pr({close:s,panel:e}){return m.useEffect(()=>{const a=g=>{g.target!==e.current?.parentElement&&(H(e.current,g.target)||s())},x=requestAnimationFrame(()=>{e.current?.querySelector(yr)?.focus(),document.addEventListener("focusin",a)});return()=>{cancelAnimationFrame(x),document.removeEventListener("focusin",a)}},[s,e]),null}function vr({activePath:s,close:e}){const a=m.useRef(s);return m.useEffect(()=>{a.current!==s&&(a.current=s,e())},[s,e]),null}const br=({logoSrc:s,logoSize:e="2rem",logoHeight:a,logoWidth:x,logoClassName:g,brandName:b,items:_,activePath:w,routerElement:k,user:i,onLogin:M,onLogout:S,onInboxClick:j,onThemeToggle:v,actions:rr,brandElement:z,navActions:tr,userMenuItems:F=[],className:sr,variant:l="default",position:er="sticky",themeMode:O,labels:ar,notificationVariant:P="error",notificationFill:V="solid",...nr})=>{const o=cr.withLabels(mr,ar),ir=hr(k),N=(i?.notificationCount||0)>0,I=h=>typeof h=="number"?`${h}px`:h,$=a!==void 0||x!==void 0,G=$?{width:x===void 0?"auto":I(x),height:a===void 0?"auto":I(a)}:{width:I(e),height:I(e)},K=$&&"rst:object-contain rst:object-left rst:rtl:object-right",or=gr(O==="auto"),u=(O==="auto"?or?"dark":"light":O??(l==="white"||l==="default"?"light":"dark"))==="dark",A=l==="slate"||l==="primary"||l==="default"&&u||l==="white"&&u||l==="transparent"&&u,B=l==="primary"?{brand:"rst:text-primary-700-ink rst:hover:text-primary-700-ink/80 rst:dark:text-white rst:dark:hover:text-gray-200",linkBase:"rst:text-primary-700-ink/80 rst:hover:text-primary-700-ink rst:dark:text-gray-300 rst:dark:hover:text-white",linkActive:"rst:text-primary-700-ink rst:font-semibold rst:hover:text-primary-700-ink/80 rst:dark:text-primary-400 rst:dark:hover:text-primary-300",hamburger:"rst:text-primary-700-ink/80 rst:hover:bg-primary-700-ink/10 rst:hover:text-primary-700-ink rst:dark:text-gray-300 rst:dark:hover:bg-white/10 rst:dark:hover:text-white"}:{brand:A?"rst:text-white rst:dark:text-white rst:hover:text-gray-200 rst:dark:hover:text-gray-200":"rst:text-gray-900 rst:dark:text-gray-900 rst:hover:text-gray-600 rst:dark:hover:text-gray-600",linkBase:A?"rst:text-gray-300 rst:dark:text-gray-300 rst:hover:text-white rst:dark:hover:text-white":"rst:text-gray-600 rst:dark:text-gray-600 rst:hover:text-gray-900 rst:dark:hover:text-gray-900",linkActive:A?"rst:text-primary-400 rst:dark:text-primary-400 rst:font-semibold rst:hover:text-primary-300 rst:dark:hover:text-primary-300":"rst:text-primary-600 rst:dark:text-primary-600 rst:font-semibold rst:hover:text-primary-700 rst:dark:hover:text-primary-700",hamburger:A?"rst:text-gray-300 rst:dark:text-gray-300 rst:hover:bg-white/10 rst:dark:hover:bg-white/10 rst:hover:text-white rst:dark:hover:text-white":"rst:text-gray-500 rst:dark:text-gray-500 rst:hover:bg-gray-100 rst:dark:hover:bg-gray-100 rst:hover:text-gray-700 rst:dark:hover:text-gray-700"},R=m.useRef(null),X=m.useRef(null);return r.jsx(L.Popover,{as:"nav",className:n.cn("rst:z-50",lr.navbarVariants({variant:l,position:er}),sr),...nr,children:({open:h,close:c})=>{const C=Z(rr,c),U=Z(tr,c);return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"rst:container rst:mx-auto rst:flex rst:items-center rst:justify-between rst:px-4 rst:h-16",children:[r.jsxs(E.Link,{as:k,href:"/",to:"/",variant:"neutral",underline:"none",className:n.cn("rst:flex rst:items-center rst:gap-3 rst:transition-opacity",B.brand),children:[r.jsx("img",{src:s,alt:"",style:G,className:n.cn("rst:shrink-0",K,g??"rst:rounded-md")}),z??r.jsx("span",{className:"rst:text-xl rst:font-bold rst:tracking-tight",children:b})]}),r.jsxs("div",{className:"rst:hidden rst:md:flex rst:items-center rst:gap-8",children:[r.jsx("div",{className:"rst:flex rst:items-center rst:gap-6",children:_.map(t=>{const y=w===t.path;return r.jsxs(E.Link,{as:k,href:t.path,to:t.path,variant:"neutral",underline:"none",className:n.cn("rst:inline-flex rst:items-center rst:gap-1.5 rst:text-sm rst:transition-colors rst:duration-200",y?B.linkActive:B.linkBase),children:[t.label,t.badge&&r.jsx("span",{className:"rst:inline-flex",children:t.badge})]},t.path)})}),U,C??(i?r.jsx("div",{className:"rst:relative rst:ml-2",children:r.jsxs(d.Menu,{linkComponent:ir,children:[r.jsxs(d.MenuButton,{plain:!0,className:"rst:relative rst:flex rst:rounded-full rst:text-sm rst:focus-visible:outline-hidden rst:focus-visible:ring-2 rst:focus-visible:ring-ring rst:focus-visible:ring-offset-2 rst:ring-offset-background rst:before:absolute rst:before:-inset-1.5 rst:before:content-['']",children:[r.jsx("span",{className:"rst:sr-only",children:o.openUserMenu}),r.jsx(dr.Avatar,{"aria-hidden":"true",alt:"",initials:i.initials,src:i.avatarSrc,size:"sm",shape:"circle",colorScheme:i.avatarColor??"primary"}),N&&r.jsx("div",{className:"rst:absolute rst:-top-1 rst:-right-2",children:r.jsx(J.Badge,{fill:V,size:"xs",statusBadge:!0,variant:P,children:i.notificationCount})})]}),r.jsxs(d.MenuItems,{align:"end",offset:8,className:"rst:w-48 rst:min-w-0 rst:bg-white rst:dark:bg-gray-800 rst:ring-black/5 rst:dark:ring-white/10 rst:divide-y rst:divide-gray-100 rst:dark:divide-gray-700",children:[(N&&j||v)&&r.jsxs(d.MenuGroup,{className:"rst:py-1",children:[N&&j&&r.jsx(d.MenuItem,{onSelect:j,className:Y,icon:r.jsx(f.FontAwesomeIcon,{icon:p.faInbox,className:"rst:text-primary-500 rst:w-4"}),children:o.inbox(i.notificationCount??0)}),v&&r.jsx(d.MenuCheckboxItem,{checked:u,onCheckedChange:()=>v(),closeOnSelect:!1,className:D,icon:r.jsx(f.FontAwesomeIcon,{icon:p.faMoon,className:n.cn("rst:w-4 rst:transition-colors",u?"rst:text-amber-500":"rst:text-gray-400")}),indicator:r.jsx(T,{on:u,size:"xs"}),children:r.jsx("span",{className:"rst:font-medium",children:o.darkMode})})]}),F.length>0&&r.jsx(d.MenuGroup,{className:"rst:py-1",children:F.map(t=>r.jsx(d.MenuItem,{href:t.path,badge:t.badge,className:xr,children:t.label},t.path))}),S&&r.jsx(d.MenuGroup,{className:"rst:py-1",children:r.jsx(d.MenuItem,{onSelect:S,className:Y,icon:r.jsx(f.FontAwesomeIcon,{icon:p.faRightFromBracket,className:"rst:text-gray-400 rst:dark:text-gray-500 rst:w-4"}),children:o.logOut})})]})]})}):r.jsx(q.Button,{size:"sm",variant:"solid",colorScheme:"primary",onClick:M,children:o.logIn}))]}),r.jsx("div",{ref:X,"data-roster-hamburger":!0,className:"rst:flex rst:md:hidden",children:r.jsxs(L.PopoverButton,{className:n.cn("rst:inline-flex rst:items-center rst:justify-center rst:rounded-md rst:p-2 rst:focus-visible:outline-hidden rst:focus-visible:ring-2 rst:focus-visible:ring-ring rst:focus-visible:ring-offset-2 rst:ring-offset-background",B.hamburger),children:[r.jsx("span",{className:"rst:sr-only",children:o.openMainMenu}),h?r.jsx(f.FontAwesomeIcon,{icon:p.faXmark,className:"rst:block rst:h-6 rst:w-6","aria-hidden":"true"}):r.jsxs("div",{className:"rst:relative",children:[r.jsx(f.FontAwesomeIcon,{icon:p.faBars,className:"rst:block rst:h-6 rst:w-6","aria-hidden":"true"}),N&&r.jsx("span",{className:"rst:absolute rst:top-0 rst:right-0 rst:block rst:h-2.5 rst:w-2.5 rst:rounded-full rst:bg-error-500 rst:ring-2 rst:ring-transparent rst:transform rst:translate-x-1/4 rst:-translate-y-1/4"})]})]})})]}),h&&r.jsx(fr,{close:c,panel:R,hamburger:X}),h&&r.jsx(pr,{close:c,panel:R}),h&&r.jsx(vr,{activePath:w,close:c}),r.jsx(ur.Transition,{as:m.Fragment,enter:"rst:duration-200 rst:ease-out",enterFrom:"rst:opacity-0 rst:scale-95",enterTo:"rst:opacity-100 rst:scale-100",leave:"rst:duration-100 rst:ease-in",leaveFrom:"rst:opacity-100 rst:scale-100",leaveTo:"rst:opacity-0 rst:scale-95",children:r.jsx(L.PopoverPanel,{className:"rst:absolute rst:top-0 rst:inset-x-0 rst:z-50 rst:origin-top-right rst:transform rst:p-2 rst:transition rst:md:hidden",children:r.jsxs("div",{ref:R,"data-roster-mobile-panel":!0,className:"rst:rounded-lg rst:elevation-anchored rst:ring rst:ring-black/5 rst:dark:ring-white/10 rst:divide-y rst:divide-gray-100 rst:dark:divide-gray-700 rst:bg-white rst:dark:bg-gray-800",children:[r.jsxs("div",{className:"rst:px-5 rst:pt-5 rst:pb-6",children:[r.jsxs("div",{className:"rst:flex rst:items-center rst:justify-between",children:[r.jsxs("div",{className:"rst:flex rst:items-center rst:gap-3",children:[r.jsx("img",{src:s,alt:"",style:G,className:n.cn("rst:shrink-0",K,g??"rst:rounded-md")}),z??r.jsx("span",{className:"rst:font-bold rst:text-gray-900 rst:dark:text-white",children:b})]}),r.jsx("div",{className:"rst:-mr-2",children:r.jsxs(L.PopoverButton,{className:"rst:inline-flex rst:items-center rst:justify-center rst:rounded-md rst:p-2 rst:text-gray-400 rst:hover:bg-gray-100 rst:dark:hover:bg-gray-700 rst:hover:text-gray-500 rst:dark:hover:text-white rst:focus:outline-hidden",children:[r.jsx("span",{className:"rst:sr-only",children:o.closeMainMenu}),r.jsx(f.FontAwesomeIcon,{icon:p.faXmark,className:"rst:h-6 rst:w-6","aria-hidden":"true"})]})})]}),r.jsxs("div",{className:"rst:mt-6",children:[U&&r.jsx("div",{className:"rst:mb-4",children:U}),r.jsxs("nav",{className:"rst:grid rst:gap-y-4",children:[_.map(t=>{const y=w===t.path;return r.jsx(E.Link,{as:k,href:t.path,to:t.path,onClick:()=>c(),variant:"neutral",underline:"none",className:n.cn("rst:-m-3 rst:flex rst:items-center rst:rounded-md rst:p-3 rst:transition-colors","rst:hover:bg-gray-50 rst:dark:hover:bg-gray-700",y?"rst:bg-gray-50 rst:dark:bg-gray-700":"rst:text-gray-900 rst:dark:text-gray-100"),children:r.jsxs("span",{className:n.cn("rst:ml-3 rst:inline-flex rst:items-center rst:gap-1.5 rst:text-base rst:font-medium",y?"rst:text-primary-600 rst:dark:text-primary-400 rst:font-bold":"rst:text-gray-900 rst:dark:text-gray-100"),children:[t.label,t.badge&&r.jsx("span",{className:"rst:inline-flex",children:t.badge})]})},t.path)}),i&&F.length>0&&r.jsxs(r.Fragment,{children:[r.jsx("hr",{className:"rst:border-gray-100 rst:dark:border-gray-700"}),F.map(t=>{const y=w===t.path;return r.jsxs(E.Link,{as:k,href:t.path,to:t.path,onClick:()=>c(),variant:"neutral",underline:"none",className:n.cn("rst:-m-3 rst:flex rst:items-center rst:rounded-md rst:p-3 rst:transition-colors","rst:hover:bg-gray-50 rst:dark:hover:bg-gray-700",y?"rst:bg-gray-50 rst:dark:bg-gray-700":"rst:text-gray-900 rst:dark:text-gray-100"),children:[r.jsx("span",{className:n.cn("rst:ml-3 rst:text-base rst:font-medium",y?"rst:text-primary-600 rst:dark:text-primary-400 rst:font-bold":"rst:text-gray-900 rst:dark:text-gray-100"),children:t.label}),t.badge&&r.jsx("span",{className:"rst:ml-2 rst:inline-flex",children:t.badge})]},t.path)})]})]})]})]}),(i||C||M)&&r.jsx("div",{className:"rst:py-6 rst:px-5 rst:space-y-4",children:C||(!i&&M?r.jsx(q.Button,{variant:"solid",colorScheme:"primary",className:"rst:w-full rst:justify-center",onClick:()=>{M(),c()},children:o.logIn}):r.jsxs(r.Fragment,{children:[N&&j&&r.jsx(q.Button,{variant:"ghost",colorScheme:"neutral",onClick:()=>{j?.(),c()},className:"rst:w-full rst:justify-between rst:px-4 rst:text-base rst:font-medium rst:hover:bg-gray-50 rst:dark:hover:bg-gray-700 rst:text-gray-900 rst:dark:text-gray-100",endIcon:r.jsx(J.Badge,{fill:V,size:"xs",statusBadge:!0,variant:P,children:i?.notificationCount}),children:o.pendingInvitations}),v&&r.jsxs("div",{onClick:t=>{t.preventDefault(),v()},role:"switch","aria-checked":u,tabIndex:0,onKeyDown:t=>{t.repeat||(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),v())},className:"rst:flex rst:w-full rst:items-center rst:justify-between rst:rounded-md rst:px-4 rst:py-2 rst:text-base rst:transition-colors rst:cursor-pointer rst:hover:bg-gray-50 rst:dark:hover:bg-gray-700 rst:text-gray-900 rst:dark:text-gray-100",children:[r.jsxs("div",{className:"rst:flex rst:items-center rst:gap-3 rst:font-medium",children:[r.jsx(f.FontAwesomeIcon,{icon:p.faMoon,className:n.cn("rst:w-5 rst:transition-colors",u?"rst:text-amber-500":"rst:text-gray-400")}),r.jsx("span",{children:o.darkMode})]}),r.jsx(T,{on:u,size:"sm"})]}),S&&r.jsx(q.Button,{variant:"outline",colorScheme:"error",className:"rst:w-full rst:justify-center",onClick:()=>{S?.(),c()},children:o.logOut})]}))})]})})})]})}})};exports.Navbar=br;
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),m=require("react"),f=require("../../../node_modules/@fortawesome/react-fontawesome/dist/index.cjs"),p=require("../../../node_modules/@fortawesome/free-solid-svg-icons/index.cjs"),n=require("../../../lib/utils.cjs"),cr=require("../../../lib/labels.cjs"),C=require("../../atoms/Button/Button.cjs"),E=require("../../atoms/Link/Link.cjs"),J=require("../../atoms/Badge/Badge.cjs"),dr=require("../../atoms/Avatar/Avatar.cjs"),Q=require("../../atoms/Switch/switch-variants.cjs"),d=require("../../molecules/Menu/Menu.cjs"),lr=require("./navbar-variants.cjs"),ur=require("../../../internal/key-focus.cjs"),L=require("../../../node_modules/@headlessui/react/dist/components/popover/popover.cjs"),xr=require("../../../node_modules/@headlessui/react/dist/components/transition/transition.cjs");function T({on:s,size:e}){return r.jsx("span",{"aria-hidden":"true","data-testid":"navbar-theme-track","data-checked":s?"":void 0,className:n.cn(Q.switchTrackVariants({size:e,variant:"neutral"}),"rst:pointer-events-none"),children:r.jsx("span",{className:n.cn(Q.switchThumbVariants({size:e}))})})}const D="rst:gap-2 rst:px-4 rst:[&>[data-menu-lead]]:w-auto rst:text-gray-700 rst:dark:text-gray-200 rst:focus:bg-gray-50 rst:focus:text-gray-700 rst:dark:focus:bg-gray-700 rst:dark:focus:text-gray-200",hr=n.cn(D,"rst:font-semibold rst:rounded-sm rst:hover:text-gray-900 rst:dark:hover:text-gray-100 rst:hover:focus:text-gray-900 rst:dark:hover:focus:text-gray-100"),W=new WeakMap;function mr(s){if(!s||typeof s=="string")return;let e=W.get(s);return e||(e=a=>r.jsx(s,{...a}),W.set(s,e)),e}const Y=n.cn(D,"rst:border rst:border-transparent rst:font-medium rst:text-gray-600 rst:dark:text-gray-400 rst:focus:text-gray-600 rst:dark:focus:text-gray-400 rst:hover:bg-gray-500/10 rst:dark:hover:bg-gray-400/15 rst:hover:focus:bg-gray-500/10 rst:dark:hover:focus:bg-gray-400/15"),Z=(s,e)=>typeof s=="function"?s({close:e}):s,gr={openMainMenu:"Open main menu",closeMainMenu:"Close menu",openUserMenu:"Open user menu",logIn:"Log In",logOut:"Log Out",darkMode:"Dark Mode",pendingInvitations:"Pending Invitations",inbox:s=>`Inbox (${s})`};function yr(s){return m.useSyncExternalStore(e=>{if(!s||typeof document>"u")return()=>{};const a=new MutationObserver(e);return a.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>a.disconnect()},()=>s&&document.documentElement.classList.contains("dark"),()=>!1)}function H(s,e){if(!e||!s)return!1;if(s.contains(e))return!0;const a=e.closest?.("[data-menu-panel]")?.getAttribute("data-menu-tree");return!!a&&!!s.querySelector(`[data-menu-tree="${CSS.escape(a)}"]`)}const fr='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function pr({close:s,panel:e,hamburger:a}){return m.useEffect(()=>{const x=g=>{const b=g.target;!H(e.current,b)&&!a.current?.contains(b)&&s()};return document.addEventListener("pointerdown",x,{capture:!0}),()=>document.removeEventListener("pointerdown",x,{capture:!0})},[s,e,a]),null}function vr({close:s,panel:e}){return m.useEffect(()=>{const a=g=>{g.target!==e.current?.parentElement&&(H(e.current,g.target)||s())},x=requestAnimationFrame(()=>{e.current?.querySelector(fr)?.focus(),document.addEventListener("focusin",a)});return()=>{cancelAnimationFrame(x),document.removeEventListener("focusin",a)}},[s,e]),null}function br({activePath:s,close:e}){const a=m.useRef(s);return m.useEffect(()=>{a.current!==s&&(a.current=s,e())},[s,e]),null}const kr=({logoSrc:s,logoSize:e="2rem",logoHeight:a,logoWidth:x,logoClassName:g,brandName:b,items:_,activePath:w,routerElement:k,user:i,onLogin:M,onLogout:S,onInboxClick:j,onThemeToggle:v,actions:rr,brandElement:z,navActions:tr,userMenuItems:F=[],className:sr,variant:l="default",position:er="sticky",themeMode:O,labels:ar,notificationVariant:P="error",notificationFill:K="solid",...nr})=>{ur.useKeyFocus();const o=cr.withLabels(gr,ar),ir=mr(k),N=(i?.notificationCount||0)>0,I=h=>typeof h=="number"?`${h}px`:h,V=a!==void 0||x!==void 0,$=V?{width:x===void 0?"auto":I(x),height:a===void 0?"auto":I(a)}:{width:I(e),height:I(e)},G=V&&"rst:object-contain rst:object-left rst:rtl:object-right",or=yr(O==="auto"),u=(O==="auto"?or?"dark":"light":O??(l==="white"||l==="default"?"light":"dark"))==="dark",A=l==="slate"||l==="primary"||l==="default"&&u||l==="white"&&u||l==="transparent"&&u,B=l==="primary"?{brand:"rst:text-primary-700-ink rst:hover:text-primary-700-ink/80 rst:dark:text-white rst:dark:hover:text-gray-200",linkBase:"rst:text-primary-700-ink/80 rst:hover:text-primary-700-ink rst:dark:text-gray-300 rst:dark:hover:text-white",linkActive:"rst:text-primary-700-ink rst:font-semibold rst:hover:text-primary-700-ink/80 rst:dark:text-primary-400 rst:dark:hover:text-primary-300",hamburger:"rst:text-primary-700-ink/80 rst:hover:bg-primary-700-ink/10 rst:hover:text-primary-700-ink rst:dark:text-gray-300 rst:dark:hover:bg-white/10 rst:dark:hover:text-white"}:{brand:A?"rst:text-white rst:dark:text-white rst:hover:text-gray-200 rst:dark:hover:text-gray-200":"rst:text-gray-900 rst:dark:text-gray-900 rst:hover:text-gray-600 rst:dark:hover:text-gray-600",linkBase:A?"rst:text-gray-300 rst:dark:text-gray-300 rst:hover:text-white rst:dark:hover:text-white":"rst:text-gray-600 rst:dark:text-gray-600 rst:hover:text-gray-900 rst:dark:hover:text-gray-900",linkActive:A?"rst:text-primary-400 rst:dark:text-primary-400 rst:font-semibold rst:hover:text-primary-300 rst:dark:hover:text-primary-300":"rst:text-primary-600 rst:dark:text-primary-600 rst:font-semibold rst:hover:text-primary-700 rst:dark:hover:text-primary-700",hamburger:A?"rst:text-gray-300 rst:dark:text-gray-300 rst:hover:bg-white/10 rst:dark:hover:bg-white/10 rst:hover:text-white rst:dark:hover:text-white":"rst:text-gray-500 rst:dark:text-gray-500 rst:hover:bg-gray-100 rst:dark:hover:bg-gray-100 rst:hover:text-gray-700 rst:dark:hover:text-gray-700"},R=m.useRef(null),X=m.useRef(null);return r.jsx(L.Popover,{as:"nav",className:n.cn("rst:z-50",lr.navbarVariants({variant:l,position:er}),sr),...nr,children:({open:h,close:c})=>{const q=Z(rr,c),U=Z(tr,c);return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"rst:container rst:mx-auto rst:flex rst:items-center rst:justify-between rst:px-4 rst:h-16",children:[r.jsxs(E.Link,{as:k,href:"/",to:"/",variant:"neutral",underline:"none",className:n.cn("rst:flex rst:items-center rst:gap-3 rst:transition-opacity",B.brand),children:[r.jsx("img",{src:s,alt:"",style:$,className:n.cn("rst:shrink-0",G,g??"rst:rounded-md")}),z??r.jsx("span",{className:"rst:text-xl rst:font-bold rst:tracking-tight",children:b})]}),r.jsxs("div",{className:"rst:hidden rst:md:flex rst:items-center rst:gap-8",children:[r.jsx("div",{className:"rst:flex rst:items-center rst:gap-6",children:_.map(t=>{const y=w===t.path;return r.jsxs(E.Link,{as:k,href:t.path,to:t.path,variant:"neutral",underline:"none",className:n.cn("rst:inline-flex rst:items-center rst:gap-1.5 rst:text-sm rst:transition-colors rst:duration-200",y?B.linkActive:B.linkBase),children:[t.label,t.badge&&r.jsx("span",{className:"rst:inline-flex",children:t.badge})]},t.path)})}),U,q??(i?r.jsx("div",{className:"rst:relative rst:ml-2",children:r.jsxs(d.Menu,{linkComponent:ir,children:[r.jsxs(d.MenuButton,{plain:!0,className:"rst:relative rst:flex rst:rounded-full rst:text-sm rst:focus-visible:outline-hidden rst:focus-visible:ring-2 rst:focus-visible:ring-ring rst:focus-visible:ring-offset-2 rst:ring-offset-background rst:before:absolute rst:before:-inset-1.5 rst:before:content-['']",children:[r.jsx("span",{className:"rst:sr-only",children:o.openUserMenu}),r.jsx(dr.Avatar,{"aria-hidden":"true",alt:"",initials:i.initials,src:i.avatarSrc,size:"sm",shape:"circle",colorScheme:i.avatarColor??"primary"}),N&&r.jsx("div",{className:"rst:absolute rst:-top-1 rst:-right-2",children:r.jsx(J.Badge,{fill:K,size:"xs",statusBadge:!0,variant:P,children:i.notificationCount})})]}),r.jsxs(d.MenuItems,{align:"end",offset:8,className:"rst:w-48 rst:min-w-0 rst:bg-white rst:dark:bg-gray-800 rst:ring-black/5 rst:dark:ring-white/10 rst:divide-y rst:divide-gray-100 rst:dark:divide-gray-700",children:[(N&&j||v)&&r.jsxs(d.MenuGroup,{className:"rst:py-1",children:[N&&j&&r.jsx(d.MenuItem,{onSelect:j,className:Y,icon:r.jsx(f.FontAwesomeIcon,{icon:p.faInbox,className:"rst:text-primary-500 rst:w-4"}),children:o.inbox(i.notificationCount??0)}),v&&r.jsx(d.MenuCheckboxItem,{checked:u,onCheckedChange:()=>v(),closeOnSelect:!1,className:D,icon:r.jsx(f.FontAwesomeIcon,{icon:p.faMoon,className:n.cn("rst:w-4 rst:transition-colors",u?"rst:text-amber-500":"rst:text-gray-400")}),indicator:r.jsx(T,{on:u,size:"xs"}),children:r.jsx("span",{className:"rst:font-medium",children:o.darkMode})})]}),F.length>0&&r.jsx(d.MenuGroup,{className:"rst:py-1",children:F.map(t=>r.jsx(d.MenuItem,{href:t.path,badge:t.badge,className:hr,children:t.label},t.path))}),S&&r.jsx(d.MenuGroup,{className:"rst:py-1",children:r.jsx(d.MenuItem,{onSelect:S,className:Y,icon:r.jsx(f.FontAwesomeIcon,{icon:p.faRightFromBracket,className:"rst:text-gray-400 rst:dark:text-gray-500 rst:w-4"}),children:o.logOut})})]})]})}):r.jsx(C.Button,{size:"sm",variant:"solid",colorScheme:"primary",onClick:M,children:o.logIn}))]}),r.jsx("div",{ref:X,"data-roster-hamburger":!0,className:"rst:flex rst:md:hidden",children:r.jsxs(L.PopoverButton,{className:n.cn("rst:inline-flex rst:items-center rst:justify-center rst:rounded-md rst:p-2 rst:focus-visible:outline-hidden rst:focus-visible:ring-2 rst:focus-visible:ring-ring rst:focus-visible:ring-offset-2 rst:ring-offset-background",B.hamburger),children:[r.jsx("span",{className:"rst:sr-only",children:o.openMainMenu}),h?r.jsx(f.FontAwesomeIcon,{icon:p.faXmark,className:"rst:block rst:h-6 rst:w-6","aria-hidden":"true"}):r.jsxs("div",{className:"rst:relative",children:[r.jsx(f.FontAwesomeIcon,{icon:p.faBars,className:"rst:block rst:h-6 rst:w-6","aria-hidden":"true"}),N&&r.jsx("span",{className:"rst:absolute rst:top-0 rst:right-0 rst:block rst:h-2.5 rst:w-2.5 rst:rounded-full rst:bg-error-500 rst:ring-2 rst:ring-transparent rst:transform rst:translate-x-1/4 rst:-translate-y-1/4"})]})]})})]}),h&&r.jsx(pr,{close:c,panel:R,hamburger:X}),h&&r.jsx(vr,{close:c,panel:R}),h&&r.jsx(br,{activePath:w,close:c}),r.jsx(xr.Transition,{as:m.Fragment,enter:"rst:duration-200 rst:ease-out",enterFrom:"rst:opacity-0 rst:scale-95",enterTo:"rst:opacity-100 rst:scale-100",leave:"rst:duration-100 rst:ease-in",leaveFrom:"rst:opacity-100 rst:scale-100",leaveTo:"rst:opacity-0 rst:scale-95",children:r.jsx(L.PopoverPanel,{className:"rst:absolute rst:top-0 rst:inset-x-0 rst:z-50 rst:origin-top-right rst:transform rst:p-2 rst:transition rst:md:hidden",children:r.jsxs("div",{ref:R,"data-roster-mobile-panel":!0,className:"rst:rounded-lg rst:elevation-anchored rst:ring rst:ring-black/5 rst:dark:ring-white/10 rst:divide-y rst:divide-gray-100 rst:dark:divide-gray-700 rst:bg-white rst:dark:bg-gray-800",children:[r.jsxs("div",{className:"rst:px-5 rst:pt-5 rst:pb-6",children:[r.jsxs("div",{className:"rst:flex rst:items-center rst:justify-between",children:[r.jsxs("div",{className:"rst:flex rst:items-center rst:gap-3",children:[r.jsx("img",{src:s,alt:"",style:$,className:n.cn("rst:shrink-0",G,g??"rst:rounded-md")}),z??r.jsx("span",{className:"rst:font-bold rst:text-gray-900 rst:dark:text-white",children:b})]}),r.jsx("div",{className:"rst:-mr-2",children:r.jsxs(L.PopoverButton,{className:"rst:inline-flex rst:items-center rst:justify-center rst:rounded-md rst:p-2 rst:text-gray-400 rst:hover:bg-gray-100 rst:dark:hover:bg-gray-700 rst:hover:text-gray-500 rst:dark:hover:text-white rst:focus:outline-hidden",children:[r.jsx("span",{className:"rst:sr-only",children:o.closeMainMenu}),r.jsx(f.FontAwesomeIcon,{icon:p.faXmark,className:"rst:h-6 rst:w-6","aria-hidden":"true"})]})})]}),r.jsxs("div",{className:"rst:mt-6",children:[U&&r.jsx("div",{className:"rst:mb-4",children:U}),r.jsxs("nav",{className:"rst:grid rst:gap-y-4",children:[_.map(t=>{const y=w===t.path;return r.jsx(E.Link,{as:k,href:t.path,to:t.path,onClick:()=>c(),variant:"neutral",underline:"none",className:n.cn("rst:-m-3 rst:flex rst:items-center rst:rounded-md rst:p-3 rst:transition-colors","rst:hover:bg-gray-50 rst:dark:hover:bg-gray-700",y?"rst:bg-gray-50 rst:dark:bg-gray-700":"rst:text-gray-900 rst:dark:text-gray-100"),children:r.jsxs("span",{className:n.cn("rst:ml-3 rst:inline-flex rst:items-center rst:gap-1.5 rst:text-base rst:font-medium",y?"rst:text-primary-600 rst:dark:text-primary-400 rst:font-bold":"rst:text-gray-900 rst:dark:text-gray-100"),children:[t.label,t.badge&&r.jsx("span",{className:"rst:inline-flex",children:t.badge})]})},t.path)}),i&&F.length>0&&r.jsxs(r.Fragment,{children:[r.jsx("hr",{className:"rst:border-gray-100 rst:dark:border-gray-700"}),F.map(t=>{const y=w===t.path;return r.jsxs(E.Link,{as:k,href:t.path,to:t.path,onClick:()=>c(),variant:"neutral",underline:"none",className:n.cn("rst:-m-3 rst:flex rst:items-center rst:rounded-md rst:p-3 rst:transition-colors","rst:hover:bg-gray-50 rst:dark:hover:bg-gray-700",y?"rst:bg-gray-50 rst:dark:bg-gray-700":"rst:text-gray-900 rst:dark:text-gray-100"),children:[r.jsx("span",{className:n.cn("rst:ml-3 rst:text-base rst:font-medium",y?"rst:text-primary-600 rst:dark:text-primary-400 rst:font-bold":"rst:text-gray-900 rst:dark:text-gray-100"),children:t.label}),t.badge&&r.jsx("span",{className:"rst:ml-2 rst:inline-flex",children:t.badge})]},t.path)})]})]})]})]}),(i||q||M)&&r.jsx("div",{className:"rst:py-6 rst:px-5 rst:space-y-4",children:q||(!i&&M?r.jsx(C.Button,{variant:"solid",colorScheme:"primary",className:"rst:w-full rst:justify-center",onClick:()=>{M(),c()},children:o.logIn}):r.jsxs(r.Fragment,{children:[N&&j&&r.jsx(C.Button,{variant:"ghost",colorScheme:"neutral",onClick:()=>{j?.(),c()},className:"rst:w-full rst:justify-between rst:px-4 rst:text-base rst:font-medium rst:hover:bg-gray-50 rst:dark:hover:bg-gray-700 rst:text-gray-900 rst:dark:text-gray-100",endIcon:r.jsx(J.Badge,{fill:K,size:"xs",statusBadge:!0,variant:P,children:i?.notificationCount}),children:o.pendingInvitations}),v&&r.jsxs("div",{onClick:t=>{t.preventDefault(),v()},role:"switch","aria-checked":u,tabIndex:0,onKeyDown:t=>{t.repeat||(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),v())},className:"rst:flex rst:w-full rst:items-center rst:justify-between rst:rounded-md rst:px-4 rst:py-2 rst:text-base rst:transition-colors rst:cursor-pointer rst:hover:bg-gray-50 rst:dark:hover:bg-gray-700 rst:text-gray-900 rst:dark:text-gray-100",children:[r.jsxs("div",{className:"rst:flex rst:items-center rst:gap-3 rst:font-medium",children:[r.jsx(f.FontAwesomeIcon,{icon:p.faMoon,className:n.cn("rst:w-5 rst:transition-colors",u?"rst:text-amber-500":"rst:text-gray-400")}),r.jsx("span",{children:o.darkMode})]}),r.jsx(T,{on:u,size:"sm"})]}),S&&r.jsx(C.Button,{variant:"outline",colorScheme:"error",className:"rst:w-full rst:justify-center",onClick:()=>{S?.(),c()},children:o.logOut})]}))})]})})})]})}})};exports.Navbar=kr;
|
|
@@ -12,8 +12,9 @@ import { Avatar as xr } from "../../atoms/Avatar/Avatar.js";
|
|
|
12
12
|
import { switchThumbVariants as vr, switchTrackVariants as br } from "../../atoms/Switch/switch-variants.js";
|
|
13
13
|
import { Menu as kr, MenuButton as Nr, MenuItems as wr, MenuGroup as D, MenuItem as _, MenuCheckboxItem as Mr } from "../../molecules/Menu/Menu.js";
|
|
14
14
|
import { navbarVariants as Sr } from "./navbar-variants.js";
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
15
|
+
import { useKeyFocus as Cr } from "../../../internal/key-focus.js";
|
|
16
|
+
import { Popover as Er, PopoverButton as T, PopoverPanel as Fr } from "../../../node_modules/@headlessui/react/dist/components/popover/popover.js";
|
|
17
|
+
import { Transition as Or } from "../../../node_modules/@headlessui/react/dist/components/transition/transition.js";
|
|
17
18
|
function H({ on: e, size: s }) {
|
|
18
19
|
return /* @__PURE__ */ r(
|
|
19
20
|
"span",
|
|
@@ -26,11 +27,11 @@ function H({ on: e, size: s }) {
|
|
|
26
27
|
}
|
|
27
28
|
);
|
|
28
29
|
}
|
|
29
|
-
const K = "rst:gap-2 rst:px-4 rst:[&>[data-menu-lead]]:w-auto rst:text-gray-700 rst:dark:text-gray-200 rst:focus:bg-gray-50 rst:focus:text-gray-700 rst:dark:focus:bg-gray-700 rst:dark:focus:text-gray-200",
|
|
30
|
+
const K = "rst:gap-2 rst:px-4 rst:[&>[data-menu-lead]]:w-auto rst:text-gray-700 rst:dark:text-gray-200 rst:focus:bg-gray-50 rst:focus:text-gray-700 rst:dark:focus:bg-gray-700 rst:dark:focus:text-gray-200", jr = /* @__PURE__ */ i(
|
|
30
31
|
K,
|
|
31
32
|
"rst:font-semibold rst:rounded-sm rst:hover:text-gray-900 rst:dark:hover:text-gray-100 rst:hover:focus:text-gray-900 rst:dark:hover:focus:text-gray-100"
|
|
32
33
|
), rr = /* @__PURE__ */ new WeakMap();
|
|
33
|
-
function
|
|
34
|
+
function Ar(e) {
|
|
34
35
|
if (!e || typeof e == "string") return;
|
|
35
36
|
let s = rr.get(e);
|
|
36
37
|
return s || (s = (n) => /* @__PURE__ */ r(e, { ...n }), rr.set(e, s)), s;
|
|
@@ -38,7 +39,7 @@ function jr(e) {
|
|
|
38
39
|
const tr = /* @__PURE__ */ i(
|
|
39
40
|
K,
|
|
40
41
|
"rst:border rst:border-transparent rst:font-medium rst:text-gray-600 rst:dark:text-gray-400 rst:focus:text-gray-600 rst:dark:focus:text-gray-400 rst:hover:bg-gray-500/10 rst:dark:hover:bg-gray-400/15 rst:hover:focus:bg-gray-500/10 rst:dark:hover:focus:bg-gray-400/15"
|
|
41
|
-
), er = (e, s) => typeof e == "function" ? e({ close: s }) : e,
|
|
42
|
+
), er = (e, s) => typeof e == "function" ? e({ close: s }) : e, Br = {
|
|
42
43
|
openMainMenu: "Open main menu",
|
|
43
44
|
closeMainMenu: "Close menu",
|
|
44
45
|
openUserMenu: "Open user menu",
|
|
@@ -48,7 +49,7 @@ const tr = /* @__PURE__ */ i(
|
|
|
48
49
|
pendingInvitations: "Pending Invitations",
|
|
49
50
|
inbox: (e) => `Inbox (${e})`
|
|
50
51
|
};
|
|
51
|
-
function
|
|
52
|
+
function Ir(e) {
|
|
52
53
|
return ur.useSyncExternalStore(
|
|
53
54
|
(s) => {
|
|
54
55
|
if (!e || typeof document > "u") return () => {
|
|
@@ -69,8 +70,8 @@ function sr(e, s) {
|
|
|
69
70
|
const n = s.closest?.("[data-menu-panel]")?.getAttribute("data-menu-tree");
|
|
70
71
|
return !!n && !!e.querySelector(`[data-menu-tree="${CSS.escape(n)}"]`);
|
|
71
72
|
}
|
|
72
|
-
const
|
|
73
|
-
function
|
|
73
|
+
const Lr = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
74
|
+
function Ur({ close: e, panel: s, hamburger: n }) {
|
|
74
75
|
return z(() => {
|
|
75
76
|
const u = (g) => {
|
|
76
77
|
const x = g.target;
|
|
@@ -79,19 +80,19 @@ function Lr({ close: e, panel: s, hamburger: n }) {
|
|
|
79
80
|
return document.addEventListener("pointerdown", u, { capture: !0 }), () => document.removeEventListener("pointerdown", u, { capture: !0 });
|
|
80
81
|
}, [e, s, n]), null;
|
|
81
82
|
}
|
|
82
|
-
function
|
|
83
|
+
function Dr({ close: e, panel: s }) {
|
|
83
84
|
return z(() => {
|
|
84
85
|
const n = (g) => {
|
|
85
86
|
g.target !== s.current?.parentElement && (sr(s.current, g.target) || e());
|
|
86
87
|
}, u = requestAnimationFrame(() => {
|
|
87
|
-
s.current?.querySelector(
|
|
88
|
+
s.current?.querySelector(Lr)?.focus(), document.addEventListener("focusin", n);
|
|
88
89
|
});
|
|
89
90
|
return () => {
|
|
90
91
|
cancelAnimationFrame(u), document.removeEventListener("focusin", n);
|
|
91
92
|
};
|
|
92
93
|
}, [e, s]), null;
|
|
93
94
|
}
|
|
94
|
-
function
|
|
95
|
+
function _r({
|
|
95
96
|
activePath: e,
|
|
96
97
|
close: s
|
|
97
98
|
}) {
|
|
@@ -100,7 +101,7 @@ function Dr({
|
|
|
100
101
|
n.current !== e && (n.current = e, s());
|
|
101
102
|
}, [e, s]), null;
|
|
102
103
|
}
|
|
103
|
-
const
|
|
104
|
+
const tt = ({
|
|
104
105
|
logoSrc: e,
|
|
105
106
|
logoSize: s = "2rem",
|
|
106
107
|
logoHeight: n,
|
|
@@ -128,10 +129,11 @@ const Hr = ({
|
|
|
128
129
|
notificationFill: V = "solid",
|
|
129
130
|
...dr
|
|
130
131
|
}) => {
|
|
131
|
-
|
|
132
|
+
Cr();
|
|
133
|
+
const c = pr(Br, cr), lr = Ar(v), k = (o?.notificationCount || 0) > 0, C = (h) => typeof h == "number" ? `${h}px` : h, G = n !== void 0 || u !== void 0, X = G ? {
|
|
132
134
|
width: u === void 0 ? "auto" : C(u),
|
|
133
135
|
height: n === void 0 ? "auto" : C(n)
|
|
134
|
-
} : { width: C(s), height: C(s) }, J = G && "rst:object-contain rst:object-left rst:rtl:object-right", mr =
|
|
136
|
+
} : { width: C(s), height: C(s) }, J = G && "rst:object-contain rst:object-left rst:rtl:object-right", mr = Ir(B === "auto"), m = (B === "auto" ? mr ? "dark" : "light" : B ?? (l === "white" || l === "default" ? "light" : "dark")) === "dark", E = l === "slate" || l === "primary" || l === "default" && m || l === "white" && m || l === "transparent" && m, F = l === "primary" ? {
|
|
135
137
|
// On primary-700, text is that fill's ink (the dimmer links at 80%),
|
|
136
138
|
// so a light primary gets dark text. The dark fill is primary-950,
|
|
137
139
|
// which the ink doesn't describe: there it stays the dark surface's
|
|
@@ -147,7 +149,7 @@ const Hr = ({
|
|
|
147
149
|
hamburger: E ? "rst:text-gray-300 rst:dark:text-gray-300 rst:hover:bg-white/10 rst:dark:hover:bg-white/10 rst:hover:text-white rst:dark:hover:text-white" : "rst:text-gray-500 rst:dark:text-gray-500 rst:hover:bg-gray-100 rst:dark:hover:bg-gray-100 rst:hover:text-gray-700 rst:dark:hover:text-gray-700"
|
|
148
150
|
}, I = R(null), Q = R(null);
|
|
149
151
|
return /* @__PURE__ */ r(
|
|
150
|
-
|
|
152
|
+
Er,
|
|
151
153
|
{
|
|
152
154
|
as: "nav",
|
|
153
155
|
className: i("rst:z-50", Sr({ variant: l, position: or }), ir),
|
|
@@ -275,7 +277,7 @@ const Hr = ({
|
|
|
275
277
|
}
|
|
276
278
|
)
|
|
277
279
|
] }),
|
|
278
|
-
S.length > 0 && /* @__PURE__ */ r(D, { className: "rst:py-1", children: S.map((t) => /* @__PURE__ */ r(_, { href: t.path, badge: t.badge, className:
|
|
280
|
+
S.length > 0 && /* @__PURE__ */ r(D, { className: "rst:py-1", children: S.map((t) => /* @__PURE__ */ r(_, { href: t.path, badge: t.badge, className: jr, children: t.label }, t.path)) }),
|
|
279
281
|
M && /* @__PURE__ */ r(D, { className: "rst:py-1", children: /* @__PURE__ */ r(
|
|
280
282
|
_,
|
|
281
283
|
{
|
|
@@ -321,11 +323,11 @@ const Hr = ({
|
|
|
321
323
|
}
|
|
322
324
|
) })
|
|
323
325
|
] }),
|
|
324
|
-
h && /* @__PURE__ */ r(
|
|
325
|
-
h && /* @__PURE__ */ r(
|
|
326
|
-
h && /* @__PURE__ */ r(
|
|
326
|
+
h && /* @__PURE__ */ r(Ur, { close: d, panel: I, hamburger: Q }),
|
|
327
|
+
h && /* @__PURE__ */ r(Dr, { close: d, panel: I }),
|
|
328
|
+
h && /* @__PURE__ */ r(_r, { activePath: N, close: d }),
|
|
327
329
|
/* @__PURE__ */ r(
|
|
328
|
-
|
|
330
|
+
Or,
|
|
329
331
|
{
|
|
330
332
|
as: hr,
|
|
331
333
|
enter: "rst:duration-200 rst:ease-out",
|
|
@@ -335,7 +337,7 @@ const Hr = ({
|
|
|
335
337
|
leaveFrom: "rst:opacity-100 rst:scale-100",
|
|
336
338
|
leaveTo: "rst:opacity-0 rst:scale-95",
|
|
337
339
|
children: /* @__PURE__ */ r(
|
|
338
|
-
|
|
340
|
+
Fr,
|
|
339
341
|
{
|
|
340
342
|
className: "rst:absolute rst:top-0 rst:inset-x-0 rst:z-50 rst:origin-top-right rst:transform rst:p-2 rst:transition rst:md:hidden",
|
|
341
343
|
children: /* @__PURE__ */ a("div", { ref: I, "data-roster-mobile-panel": !0, className: "rst:rounded-lg rst:elevation-anchored rst:ring rst:ring-black/5 rst:dark:ring-white/10 rst:divide-y rst:divide-gray-100 rst:dark:divide-gray-700 rst:bg-white rst:dark:bg-gray-800", children: [
|
|
@@ -531,5 +533,5 @@ const Hr = ({
|
|
|
531
533
|
);
|
|
532
534
|
};
|
|
533
535
|
export {
|
|
534
|
-
|
|
536
|
+
tt as Navbar
|
|
535
537
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),Q=require("react"),Z=require("../../../node_modules/@headlessui/react/dist/components/description/description.cjs"),
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),Q=require("react"),Z=require("../../../node_modules/@headlessui/react/dist/components/description/description.cjs"),b=require("../../../node_modules/@headlessui/react/dist/components/dialog/dialog.cjs"),W=require("../../../node_modules/@headlessui/react/dist/components/transition/transition.cjs"),f=require("../../../lib/utils.cjs"),O=require("../../../lib/labels.cjs"),tt=require("../../../internal/popup.cjs"),et=require("../../../internal/motion.cjs"),rt=require("../../../internal/page-inert.cjs"),S=require("./sheet-drag.cjs"),st=require("./sheet-title.cjs"),nt=require("../../../internal/key-focus.cjs");function ot(r){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const c in r)if(c!=="default"){const l=Object.getOwnPropertyDescriptor(r,c);Object.defineProperty(i,c,l.get?l:{enumerable:!0,get:()=>r[c]})}}return i.default=r,Object.freeze(i)}const n=ot(Q),at={close:"Close"},it="rst:transition-transform rst:duration-(--roster-sheet-enter-duration) rst:ease-(--roster-sheet-enter-easing) rst:data-leave:duration-(--roster-sheet-leave-duration) rst:data-leave:ease-(--roster-sheet-leave-easing) rst:data-closed:translate-y-full",ct="rst:transition-opacity rst:duration-(--roster-sheet-fade-duration) rst:ease-out rst:data-closed:opacity-0",ut="rst:transition-opacity rst:duration-(--roster-sheet-enter-duration) rst:ease-out rst:data-leave:duration-(--roster-sheet-leave-duration) rst:data-closed:opacity-0",lt="rst:transition-opacity rst:duration-(--roster-sheet-fade-duration) rst:ease-out rst:data-closed:opacity-0",dt=["input:not([type=checkbox]):not([type=radio]):not([type=button]):not([type=submit]):not([type=reset]):not([type=range]):not([type=color]):not([type=file]):not([type=image])","textarea","select","[contenteditable]:not([contenteditable=false])"].join(",");function ft(r){return r?"current"in r?r.current:r:null}function pt({target:r}){const i=n.useRef(r),c=n.useRef(!1);return n.useEffect(()=>{i.current=r}),n.useEffect(()=>(c.current=!1,()=>{c.current=!0,queueMicrotask(()=>{if(!c.current)return;const l=ft(i.current);l?.isConnected&&l.focus()})}),[]),null}function ht(){return s.jsx("svg",{"aria-hidden":"true",focusable:"false",viewBox:"0 0 20 20",className:"rst:h-5 rst:w-5",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:s.jsx("path",{d:"M5 5l10 10M15 5L5 15"})})}const gt=({isOpen:r,onClose:i,onAfterClose:c,title:l,hideTitle:T=!1,description:D,actions:L,maxWidth:x=560,initialFocus:v,returnFocus:_,busy:p=!1,dragToDismiss:j=!0,contentKey:h,labels:z,className:B,children:Y})=>{nt.useKeyFocus();const K=O.withLabels(at,z),{ref:R,inDarkScope:U}=tt.useDarkScope(),N=et.useReducedMotion();n.useLayoutEffect(()=>{if(r)return rt.lockPage(R.current)},[r,R]);const u=n.useRef(null),C=n.useRef(null),I=n.useRef(null),E=n.useRef(null),k=n.useRef(null),q=n.useId(),g=st.titleSignature(l),w=n.useRef({signature:g,contentKey:h,open:r,busy:p});n.useEffect(()=>{const t=w.current;if(w.current={signature:g,contentKey:h,open:r,busy:p},!t.open||!r)return;const e=t.contentKey!==h,o=t.signature!==g&&!t.busy;!e&&!o||(I.current?.focus(),k.current&&(k.current.scrollTop=0))},[g,h,r,p]),n.useEffect(()=>{if(!r)return;const t=requestAnimationFrame(()=>{const e=u.current,o=document.activeElement;!e||o&&e.contains(o)||(v?.current??E.current)?.focus()});return()=>cancelAnimationFrame(t)},[r,v]);const[P,M]=n.useState(null);n.useEffect(()=>{if(!r)return;const t=window.visualViewport;if(!t)return;const e=()=>{const o=document.activeElement,d=!!o&&!!u.current?.contains(o)&&o.matches(dt);M(d?Math.round(t.height):null)};return t.addEventListener("resize",e),document.addEventListener("focusin",e),document.addEventListener("focusout",e),()=>{t.removeEventListener("resize",e),document.removeEventListener("focusin",e),document.removeEventListener("focusout",e),M(null)}},[r]);const a=n.useRef(null),m=n.useRef(!1),A=n.useRef(r);n.useEffect(()=>{A.current=r},[r]);const y=t=>{u.current?.style.setProperty("--rst-sheet-drag",`${t}px`)},F=t=>{const e=u.current;a.current=null,e&&(delete e.dataset.dragging,t==="close"?(i(),requestAnimationFrame(()=>{A.current&&!a.current&&y(0)})):y(0))};n.useEffect(()=>{!r&&a.current&&(a.current=null,u.current&&delete u.current.dataset.dragging),r&&!a.current&&y(0)},[r]);const V=t=>{a.current||(m.current=!1,!(!j||!r)&&(t.pointerType==="mouse"&&(t.button!==0||!C.current?.contains(t.target))||(a.current={pointerId:t.pointerId,x0:t.clientX,y0:t.clientY,dy:0,phase:"pending",samples:[{t:t.timeStamp,y:t.clientY}]})))},X=t=>{const e=a.current;if(!e||t.pointerId!==e.pointerId)return;const o=t.clientX-e.x0,d=t.clientY-e.y0;if(e.phase==="pending"){if(!S.exceedsSheetTapSlop(o,d))return;if(Math.abs(o)>Math.abs(d)){e.phase="ignored";return}e.phase="dragging",m.current=!0;try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}u.current&&(u.current.dataset.dragging="")}e.phase==="dragging"&&(e.dy=d,e.samples.push({t:t.timeStamp,y:t.clientY}),e.samples.length>32&&e.samples.shift(),y(Math.max(0,d)))},$=t=>{const e=a.current;if(!e||t.pointerId!==e.pointerId)return;if(e.phase!=="dragging"){a.current=null;return}e.samples.push({t:t.timeStamp,y:t.clientY});const o=t.clientY-e.y0,d=u.current?.getBoundingClientRect().height??0;F(S.sheetDragOutcome(o,d,S.sheetReleaseVelocity(e.samples)))},G=t=>{const e=a.current;!e||t.pointerId!==e.pointerId||(e.phase==="dragging"?F("stay"):a.current=null)},H=t=>{!m.current||t.detail===0||(m.current=!1,t.preventDefault(),t.stopPropagation())},J={"--rst-sheet-max-width":typeof x=="number"?`${x}px`:x,...P!==null&&{"--rst-sheet-keyboard-cap":`${P}px`}};return s.jsxs(s.Fragment,{children:[s.jsx("span",{ref:R,hidden:!0}),s.jsxs(b.Dialog,{open:r,as:"div",onClose:i,initialFocus:v??E,className:f.cn("rst:font-ui rst:relative rst:z-50 rst:focus:outline-hidden",U&&"dark"),children:[s.jsx(b.DialogBackdrop,{transition:!0,"data-testid":"sheet-backdrop",className:f.cn("rst:fixed rst:inset-0 rst:bg-[var(--roster-backdrop,var(--roster-sheet-backdrop))]",N?lt:ut)}),s.jsx("div",{className:"rst:fixed rst:inset-0 rst:flex rst:items-end rst:justify-center",children:s.jsx(W.TransitionChild,{afterLeave:c,children:s.jsxs(b.DialogPanel,{ref:u,style:J,"data-testid":"sheet-panel",className:f.cn("rst:relative rst:flex rst:max-h-[min(92dvh,var(--rst-sheet-keyboard-cap,92dvh))] rst:w-full rst:flex-col","rst:md:max-w-(--rst-sheet-max-width)","rst:rounded-t-2xl rst:border rst:border-b-0 rst:elevation-overlay","rst:bg-[var(--roster-popover-bg)] rst:border-[var(--roster-popover-border)] rst:text-[var(--roster-popover-text)]","rst:[--roster-ring-offset:var(--roster-popover-bg)]","rst:pb-[env(safe-area-inset-bottom)]","rst:translate-y-[var(--rst-sheet-drag,0px)]",N?ct:it,"rst:data-dragging:transition-none",B),children:[s.jsxs("div",{"data-testid":"sheet-drag-zone",className:f.cn("rst:shrink-0",j&&"rst:touch-none"),onPointerDown:V,onPointerMove:X,onPointerUp:$,onPointerCancel:G,onClickCapture:H,children:[s.jsx("div",{ref:C,"aria-hidden":"true","data-testid":"sheet-handle",className:f.cn("rst:flex rst:h-11 rst:items-start rst:justify-center rst:pt-2",j&&"rst:cursor-grab rst:active:cursor-grabbing"),children:s.jsx("span",{className:"rst:h-1 rst:w-10 rst:rounded-full rst:bg-current rst:opacity-30"})}),s.jsxs("div",{className:"rst:-mt-3 rst:flex rst:items-start rst:gap-2 rst:px-5 rst:pb-4",children:[s.jsxs("div",{className:"rst:min-w-0 rst:flex-1 rst:pt-2",children:[s.jsx(b.DialogTitle,{as:"h2",id:q,ref:I,tabIndex:-1,className:f.cn("rst:text-lg rst:font-semibold rst:text-inherit rst:focus:outline-hidden",T&&"rst:sr-only"),children:l}),D&&s.jsx(Z.Description,{as:"p",className:"rst:mt-1 rst:text-sm rst:text-inherit rst:opacity-75",children:D})]}),L&&s.jsx("div",{className:"rst:flex rst:h-11 rst:shrink-0 rst:items-center rst:gap-1",children:L}),s.jsx("button",{ref:E,type:"button",onClick:i,"aria-label":K.close,className:"rst:inline-flex rst:size-11 rst:shrink-0 rst:-mr-2 rst:cursor-pointer rst:items-center rst:justify-center rst:rounded-md rst:bg-transparent rst:text-inherit rst:opacity-60 rst:transition-opacity rst:hover:opacity-100 rst:focus:outline-hidden rst:focus-visible:opacity-100 rst:focus-visible:ring-2 rst:focus-visible:ring-ring rst:focus-visible:ring-offset-2 rst:ring-offset-background",children:s.jsx(ht,{})})]})]}),s.jsx("div",{ref:k,role:"region","aria-labelledby":q,tabIndex:0,"data-testid":"sheet-content","aria-busy":p||void 0,className:"rst:min-h-0 rst:flex-1 rst:overflow-y-auto rst:overscroll-contain rst:px-5 rst:pb-4 rst:focus:outline-hidden rst:ring-inset rst:focus-visible:ring-2 rst:focus-visible:ring-ring",children:Y}),s.jsx(pt,{target:_})]})})})]})]})};exports.Sheet=gt;
|