forlogic-core 2.0.4 → 2.0.6
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/.note/memory/features/crud-defaults-batteries-included.md +1 -1
- package/dist/auth/services/TokenManager.d.ts +0 -1
- package/dist/components/ui/dialog-wizard.d.ts +82 -0
- package/dist/components/ui/input-group.d.ts +1 -1
- package/dist/components/ui/input.d.ts +5 -23
- package/dist/components/ui/resizable.d.ts +1 -1
- package/dist/components/ui/sidebar.d.ts +1 -1
- package/dist/components/ui/step-selector.d.ts +11 -9
- package/dist/components/ui/textarea.d.ts +1 -0
- package/dist/crud/components/CrudTable.d.ts +3 -1
- package/dist/crud/createCrudPage.d.ts +2 -0
- package/dist/crud/hooks/useColumnManager.d.ts +3 -1
- package/dist/exports/ui.d.ts +1 -0
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/types.d.ts +3 -0
- package/docs/design-system/README.md +2 -2
- package/docs/design-system/buttons-actions.md +6 -0
- package/docs/design-system/domain.md +10 -0
- package/docs/design-system/inputs.md +20 -0
- package/docs/design-system/navigation.md +5 -0
- package/docs/design-system/notifications-feedback.md +2 -0
- package/package.json +1 -1
- package/dist/assets/AccordionDoc-CGNlubG3.js +0 -31
- package/dist/assets/ActionButtonDoc-CYtkXR0k.js +0 -47
- package/dist/assets/ActionPlanDoc-BSuPRftQ.js +0 -65
- package/dist/assets/AlertDoc-Cpvxneqg.js +0 -37
- package/dist/assets/AliasUrlDoc-DIpUWf4Y.js +0 -189
- package/dist/assets/AppHeaderDoc-DNQErj_t.js +0 -74
- package/dist/assets/AppSidebarDoc-DkeQarDu.js +0 -221
- package/dist/assets/ApprovalFlowDoc-8YgXbhKJ.js +0 -31
- package/dist/assets/AuditLogDoc-BBvNcHIo.js +0 -67
- package/dist/assets/AuditTrailDoc-DgFHO-uo.js +0 -17
- package/dist/assets/AuthDoc-WIA_Aetl.js +0 -200
- package/dist/assets/AvatarDoc-B6go1C1T.js +0 -11
- package/dist/assets/BadgeDoc-BONhfqB_.js +0 -36
- package/dist/assets/BaseFormDoc-CuyUArcj.js +0 -169
- package/dist/assets/BodyContentDoc-CterHC1E.js +0 -83
- package/dist/assets/BreadcrumbDoc-Dwn9nLeO.js +0 -75
- package/dist/assets/ButtonDoc-BOjRseZT.js +0 -41
- package/dist/assets/ButtonGroupDoc-8IS6PPh4.js +0 -7
- package/dist/assets/CalendarDoc-CMwIEqgT.js +0 -81
- package/dist/assets/CardDoc-BZz1CVg2.js +0 -49
- package/dist/assets/ChartDoc-B5vZVtqD.js +0 -76
- package/dist/assets/CheckboxDoc-lAbYO9I5.js +0 -55
- package/dist/assets/ColorPickerDoc-Dpsprp4N.js +0 -10
- package/dist/assets/ColorsFoundationDoc-CCHeSL3p.js +0 -13
- package/dist/assets/ComboTreeDoc-D4dTkIt-.js +0 -46
- package/dist/assets/ComboboxDoc-CqqZPvZq.js +0 -134
- package/dist/assets/ComponentDocTemplate-CQbBhfvZ.js +0 -1
- package/dist/assets/ContextMenuDoc-D3jC-MVA.js +0 -182
- package/dist/assets/ContextsDoc-XFH0-JdS.js +0 -211
- package/dist/assets/CreateCrudPageDoc-CpuiWI-g.js +0 -106
- package/dist/assets/CrudActionBarDoc-wuBGXD9Y.js +0 -112
- package/dist/assets/CrudGridDoc-BYWqSXBH.js +0 -85
- package/dist/assets/CrudOverviewDoc-B_bk2a2t.js +0 -14
- package/dist/assets/CrudPrimitivesDoc-CxaTB94A.js +0 -164
- package/dist/assets/CrudTableDoc-Dga1VgCu.js +0 -113
- package/dist/assets/CustomFormFieldsDoc-C1hwwSl3.js +0 -33
- package/dist/assets/DashboardFormDoc-BUDCmrMl.js +0 -49
- package/dist/assets/DashboardGeneralViewDoc-Cyg1SIiG.js +0 -71
- package/dist/assets/DashboardGridDoc-BavePiRF.js +0 -49
- package/dist/assets/DashboardListDoc-CLyMA6UK.js +0 -37
- package/dist/assets/DashboardOverviewDoc-DRVvNIF1.js +0 -35
- package/dist/assets/DashboardPanelRendererDoc--mfwb8Nc.js +0 -60
- package/dist/assets/DashboardPanelsBasicDoc-BQ2V_52D.js +0 -62
- package/dist/assets/DashboardPanelsCartesianDoc-sy-hcVQY.js +0 -75
- package/dist/assets/DashboardPanelsSpecialDoc-DsIUCRRP.js +0 -83
- package/dist/assets/DashboardViewDoc-CtlCNlEF.js +0 -45
- package/dist/assets/DataListDoc-DUy88lCQ.js +0 -13
- package/dist/assets/DesignSystemHome-DHl9YtbH.js +0 -1
- package/dist/assets/DialogDoc-CMQqnTV-.js +0 -981
- package/dist/assets/DropdownMenuDoc-S7X9csGt.js +0 -175
- package/dist/assets/ElectronicSignatureDialogDoc-BfithaL_.js +0 -57
- package/dist/assets/EmptyStateDoc-CHGCiGIk.js +0 -35
- package/dist/assets/EnvironmentsDoc-DZHJZ2nm.js +0 -96
- package/dist/assets/ErrorBoundaryDoc-DoaAg68p.js +0 -111
- package/dist/assets/ExampleActionPlanPage-C0fIMZCD.js +0 -1
- package/dist/assets/ExampleAppDoc-DzIU81Fn.js +0 -1
- package/dist/assets/ExampleCard-DuLrb3t-.js +0 -1
- package/dist/assets/ExampleCrudReportsPage-M0pz6tdM.js +0 -1
- package/dist/assets/ExampleDashboardPage-CRG5r3Vw.js +0 -1
- package/dist/assets/ExampleIdeasPage-I84ZMLY4.js +0 -1
- package/dist/assets/ExampleImportWizardPage-h4YqrrSe.js +0 -1
- package/dist/assets/ExampleSettingsPage-CwdWqoaP.js +0 -1
- package/dist/assets/FileUploadDoc-9-UujFNX.js +0 -34
- package/dist/assets/FilterBar-DDTqqUfZ.js +0 -1
- package/dist/assets/FormDoc-CVES6n3d.js +0 -81
- package/dist/assets/FoundationOverview-DT0u11Gz.js +0 -1
- package/dist/assets/GridDoc-CbHFSILF.js +0 -28
- package/dist/assets/HooksDoc-Ctxdk6Wq.js +0 -665
- package/dist/assets/HoverCardDoc-8Wkaafdj.js +0 -31
- package/dist/assets/I18nDoc-D3Q2m7ik.js +0 -167
- package/dist/assets/IconPickerDoc-DZ26Gdpg.js +0 -10
- package/dist/assets/IconsFoundationDoc-xOxtC7CW.js +0 -33
- package/dist/assets/InputDoc-BhztAiuJ.js +0 -211
- package/dist/assets/LabelDoc-A4hmTRRV.js +0 -42
- package/dist/assets/LeadershipDoc-CqOSfWsP.js +0 -452
- package/dist/assets/MediaDoc-C78gvC8p.js +0 -459
- package/dist/assets/MenubarDoc-DCnmd2tO.js +0 -165
- package/dist/assets/ModuleAccessDoc-CmD5nHDp.js +0 -153
- package/dist/assets/ModulesDialogDoc-DVit1CA-.js +0 -46
- package/dist/assets/MultiselectPermissionsDoc-tlJMs04L.js +0 -34
- package/dist/assets/NavigationMenuDoc-q1fbc89j.js +0 -116
- package/dist/assets/OnboardingDialogDoc-3A3eBYrq.js +0 -55
- package/dist/assets/PaginationDoc-B8-bMz5J.js +0 -27
- package/dist/assets/PaginationDoc-BkGdxHL3.js +0 -98
- package/dist/assets/PlacesDoc-CKPO6ATs.js +0 -226
- package/dist/assets/PopoverDoc-CJPU4Ags.js +0 -64
- package/dist/assets/ProgressDoc-CpjbTL4o.js +0 -29
- package/dist/assets/QualiexUserFieldDoc-DDwumlRw.js +0 -149
- package/dist/assets/RadioGroupDoc-D6tSZz8G.js +0 -57
- package/dist/assets/RadiusDoc-B4xSnajw.js +0 -7
- package/dist/assets/ReportRequestListDoc-C0LIaU8P.js +0 -15
- package/dist/assets/RequiredFieldsCounterDoc-COesoSdx.js +0 -58
- package/dist/assets/ResizableDoc-CW0-XQuB.js +0 -104
- package/dist/assets/RichTextEditorDoc-C8c_XA9P.js +0 -24
- package/dist/assets/ScrollAreaDoc-BxtoAPaZ.js +0 -28
- package/dist/assets/SecurityDoc-wOVqpg2F.js +0 -204
- package/dist/assets/SelectDoc-C75gtY9D.js +0 -80
- package/dist/assets/SeparatorDoc-BjQBPB1P.js +0 -4
- package/dist/assets/ServicesDoc-CXTctwBl.js +0 -308
- package/dist/assets/ShadowsDoc-C6Lw8_x2.js +0 -9
- package/dist/assets/SignDoc-Bh5ZUg5x.js +0 -66
- package/dist/assets/SkeletonDoc-rTLGK5VE.js +0 -54
- package/dist/assets/SliderDoc-JMAMDub7.js +0 -41
- package/dist/assets/SpacingDoc-RljOrpwA.js +0 -12
- package/dist/assets/SplitButtonDoc-CvShUW3w.js +0 -53
- package/dist/assets/StepSelectorDoc-C-nAap9H.js +0 -41
- package/dist/assets/SwitchDoc-DLnqmkPr.js +0 -56
- package/dist/assets/TableDoc-B8EpWLVg.js +0 -128
- package/dist/assets/TabsDoc-DIBtl_uC.js +0 -42
- package/dist/assets/TeamSelectorDoc-B7OnCbL7.js +0 -10
- package/dist/assets/TermsOfUseDoc-Bb-pw08s.js +0 -16
- package/dist/assets/TextareaDoc-DGnqMqEC.js +0 -46
- package/dist/assets/ToastDoc-DjYyc7ae.js +0 -157
- package/dist/assets/ToggleDoc-C9ZOVjkY.js +0 -51
- package/dist/assets/TooltipDoc-BEx4l9-i.js +0 -58
- package/dist/assets/TruncatedCellDoc-BbV1bRSY.js +0 -12
- package/dist/assets/TypographyFoundationDoc-CUDYjRo9.js +0 -7
- package/dist/assets/UpdatesNotificationDoc-7nyjzLMJ.js +0 -29
- package/dist/assets/UsersGroupsSelectorDoc-C0KlTAL5.js +0 -18
- package/dist/assets/UtilitiesDoc-DGxaHVV1.js +0 -145
- package/dist/assets/ViewerDialogsDoc-CnTPTEz0.js +0 -1
- package/dist/assets/blocks-B6LrJeAM.js +0 -1
- package/dist/assets/building-DeVappnD.js +0 -1
- package/dist/assets/calendar-days-BQ0na5kM.js +0 -1
- package/dist/assets/check-check-C_-PJCJa.js +0 -1
- package/dist/assets/circle-plus-CpIcep-O.js +0 -1
- package/dist/assets/circle-x-jPpBPew0.js +0 -1
- package/dist/assets/clipboard-list-CXNPdciZ.js +0 -1
- package/dist/assets/cloud-upload-BEjzumjl.js +0 -1
- package/dist/assets/crown-CqNsQIsm.js +0 -1
- package/dist/assets/date-picker-BW3eGOe_.js +0 -1
- package/dist/assets/disabled-menu-item-C2YaMvSt.js +0 -1
- package/dist/assets/drawer-D5rflIcD.js +0 -3
- package/dist/assets/file-braces-DFb5X9so.js +0 -1
- package/dist/assets/file-pen-line-CyUGKkEN.js +0 -1
- package/dist/assets/git-branch-BcXv9mpp.js +0 -1
- package/dist/assets/globe-CpMIWAcv.js +0 -1
- package/dist/assets/hash-cQWdKjya.js +0 -1
- package/dist/assets/hourglass-BahQ3eDv.js +0 -1
- package/dist/assets/hover-card-R66N85sZ.js +0 -1
- package/dist/assets/iframe-dialog-V0mW5aBb.js +0 -1
- package/dist/assets/index-DkiftrvI.js +0 -352
- package/dist/assets/index-nmBjO9Th.css +0 -1
- package/dist/assets/life-buoy-ByXiPddz.js +0 -1
- package/dist/assets/loading-state-Cb5_t5uE.js +0 -1
- package/dist/assets/lucide-react-Cp3Yw3Zm.js +0 -1
- package/dist/assets/package-B3-pVvPM.js +0 -1
- package/dist/assets/pen-Bi_lmmKT.js +0 -1
- package/dist/assets/pin-DVsSl8QA.js +0 -1
- package/dist/assets/printer-BnJ8B6m-.js +0 -1
- package/dist/assets/radio-group-BHAaNGsm.js +0 -1
- package/dist/assets/server-CtzFTfKR.js +0 -1
- package/dist/assets/share-2-Dv8Do445.js +0 -1
- package/dist/assets/shield-check-CFXjOV_w.js +0 -1
- package/dist/assets/shield-x-DJTRfVux.js +0 -1
- package/dist/assets/slider-v9tXBSnB.js +0 -1
- package/dist/assets/smartphone-BSNR60L7.js +0 -1
- package/dist/assets/step-selector-ATTh_9Wa.js +0 -1
- package/dist/assets/text-align-start-qE-MbYYw.js +0 -1
- package/dist/assets/thumbs-up-D_XIW_uX.js +0 -1
- package/dist/assets/trash-DTWQwpwA.js +0 -1
- package/dist/assets/trending-up-jip5-leJ.js +0 -1
- package/dist/assets/useMockCrud-CN4vjyOZ.js +0 -1
- package/dist/assets/user-check-BlH3EDWK.js +0 -1
- package/dist/assets/user-plus-BqwXwD-c.js +0 -1
- package/dist/index.html +0 -33
|
@@ -1,452 +0,0 @@
|
|
|
1
|
-
import{r as m,b7 as ie,j as e,ew as $,T as ve,i as Ne,k as oe,l as re,m as te,o as q,p as je,bk as X,aQ as W,q as be,ab as _,E as Le,fW as Ce,x as Q,G as ye,H as Se,I as De,ed as de,b0 as we,e3 as Te}from"./index-DkiftrvI.js";import{C as Ee}from"./ComponentDocTemplate-CQbBhfvZ.js";import{H as Ae,a as ke,b as Me}from"./hover-card-R66N85sZ.js";import{A as Oe,a as Re,B as Pe}from"./building-DeVappnD.js";import{U as Y}from"./user-plus-BqwXwD-c.js";import"./ExampleCard-DuLrb3t-.js";function ze(s,o){const c=new Set;function b(v){for(const j of v){if(j.id===o)return L(j.children),!0;if(j.children&&b(j.children))return!0}return!1}function L(v){if(v)for(const j of v)c.add(j.id),L(j.children)}return b(s),c}function Be(s,o){const c=new Set;for(const b of o)ze(s,b).forEach(v=>c.add(v));return c}function se({children:s,itemId:o,enableDrag:c,onDragStartCell:b,onDragEndCell:L,onDragOverCell:v,onDropCell:j,className:D}){return e.jsx(be,{draggable:c,onDragStart:c?l=>b(o,l):void 0,onDragEnd:c?L:void 0,onDragOver:l=>{l.preventDefault(),l.stopPropagation(),v(o,l)},onDragEnter:l=>{l.preventDefault(),l.stopPropagation(),v(o,l)},onDrop:l=>{l.preventDefault(),l.stopPropagation(),j(o,l)},className:D,children:s})}function le({item:s,level:o,columns:c,nameKey:b,iconComponent:L,expandedIds:v,onToggleExpand:j,onRowClick:D,renderActions:l,rowActionsVariant:E="default",enableSelection:M,selectedIds:O,onSelectItem:B,enableRowDrag:R,draggedId:T,dragOverId:P,onDragStartCell:d,onDragEndCell:p,onDragOverCell:i,onDropCell:f,dragCount:C}){const w=v.has(s.id),A=(s.children?.length??0)>0,I=o*24,J=E==="inline",U=T===s.id||O?.has(s.id)&&T&&O?.has(T),G=P===s.id&&T!==s.id,r=O?.has(s.id)??!1,t={itemId:s.id,enableDrag:R,onDragStartCell:d,onDragEndCell:p,onDragOverCell:i,onDropCell:f};return e.jsxs(e.Fragment,{children:[e.jsxs(oe,{className:q(D&&"cursor-pointer",J&&"group",U&&"opacity-40",G&&"ring-2 ring-primary ring-inset bg-primary/5"),onClick:D?()=>D(s):void 0,children:[e.jsx(se,{...t,children:e.jsxs("div",{className:"flex items-center gap-2",style:{paddingLeft:`${I}px`},children:[M&&e.jsx(te,{checked:r,onCheckedChange:()=>B?.(s.id),onClick:a=>a.stopPropagation(),className:"shrink-0"}),R&&e.jsx("span",{className:"cursor-grab text-muted-foreground shrink-0 select-none",title:"Arrastar",children:"⠿"}),A?e.jsx("button",{onClick:a=>{a.stopPropagation(),j(s.id)},className:"p-1 hover:bg-accent rounded shrink-0",children:w?e.jsx(X,{className:"h-4 w-4"}):e.jsx(W,{className:"h-4 w-4"})}):e.jsx("div",{className:"w-6 shrink-0"}),L??e.jsx($,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"truncate",children:String(s[b]??s.id)}),T===s.id&&C&&C>1&&e.jsx("span",{className:"ml-1 inline-flex items-center rounded-full bg-primary px-1.5 py-0 text-xs font-semibold text-primary-foreground",children:C})]})}),c.map(a=>{const u=s[a.key],x=a.render?a.render(s,o):u!=null?String(u):"—";return e.jsx(se,{...t,className:q("text-center",a.className),children:a.hoverContent?e.jsxs(Ae,{openDelay:200,children:[e.jsx(ke,{asChild:!0,children:e.jsx("span",{className:"cursor-default underline decoration-dotted underline-offset-4 text-foreground",children:x})}),e.jsx(Me,{side:"bottom",align:"center",className:"w-auto max-w-xs",children:a.hoverContent(s)})]}):x},String(a.key))}),l&&e.jsx(se,{...t,className:"text-right",children:e.jsx("div",{onClick:a=>a.stopPropagation(),className:q("flex items-center justify-end gap-1",J&&"opacity-0 group-hover:opacity-100 transition-opacity"),children:l(s)})})]}),A&&w&&s.children.map(a=>e.jsx(le,{item:a,level:o+1,columns:c,nameKey:b,iconComponent:L,expandedIds:v,onToggleExpand:j,onRowClick:D,renderActions:l,rowActionsVariant:E,enableSelection:M,selectedIds:O,onSelectItem:B,enableRowDrag:R,draggedId:T,dragOverId:P,onDragStartCell:d,onDragEndCell:p,onDragOverCell:i,onDropCell:f,dragCount:C},a.id))]})}function Ue({onDrop:s,isDragOver:o,onDragOver:c,onDragLeave:b,label:L}){return e.jsxs("div",{className:q("absolute top-0 left-0 right-0 z-10 flex items-center justify-center gap-2 py-2 px-4 border-2 border-dashed rounded-md text-sm transition-colors mx-2 mt-2",o?"border-primary bg-primary/10 text-primary":"border-muted-foreground/30 text-muted-foreground bg-background/95"),onDragOver:c,onDragEnter:c,onDragLeave:b,onDrop:s,children:[e.jsx(Oe,{className:"h-4 w-4"}),L??"Tornar Raiz"]})}function ce({data:s,columns:o,nameKey:c,nameHeader:b="Nome",iconComponent:L,expandedIds:v,onToggleExpand:j,onRowClick:D,renderActions:l,actionsHeader:E="",rowActionsVariant:M="default",isLoading:O,emptyMessage:B="Nenhum registro encontrado.",className:R,enableSelection:T,selectedIds:P,onSelectItem:d,onSelectAll:p,isAllSelected:i,enableRowDrag:f,onMoveNode:C,onMoveNodes:w,rootDropLabel:A,actionsWidth:I=20,nameMinWidth:J=200}){const[U,G]=m.useState(null),[r,t]=m.useState(null),[a,u]=m.useState(!1),[x,g]=m.useState(1),y=m.useRef(null),S=m.useRef([]),z=m.useRef(null),F=ie.useMemo(()=>new Set(P??[]),[P]),ne=ie.useMemo(()=>{if(!U||!s)return new Set;const n=S.current.length>0?S.current:[U],h=Be(s,n);return n.forEach(N=>h.add(N)),h},[U,s]),Z=m.useRef(ne);Z.current=ne;const H=m.useCallback(()=>{y.current=null,S.current=[],z.current=null,G(null),t(null),u(!1),g(1)},[]),K=m.useCallback((n,h)=>{n.length>1&&w?w(n,h):n.length===1&&C?.(n[0],h)},[C,w]),ue=m.useCallback((n,h)=>{const N=F.has(n)&&F.size>1?Array.from(F):[n];console.log("[TreeTable] dragStart",n,"batch:",N.length),y.current=n,S.current=N,z.current=null,G(n),g(N.length),h.dataTransfer.effectAllowed="move",h.dataTransfer.setData("text/plain",n),h.dataTransfer.setData("application/x-tree-ids",JSON.stringify(N))},[F]),me=m.useCallback((n,h)=>{if(h.preventDefault(),h.dataTransfer.dropEffect="move",Z.current.has(n)){t(null);return}z.current=n,t(n)},[]),ee=m.useCallback((n,h)=>{h.preventDefault(),h.stopPropagation(),console.log("[TreeTable] drop on cell targetId:",n);const N=Z.current.has(n)?z.current:n;if(!N){H();return}let k=S.current;if(k.length===0){try{const V=h.dataTransfer.getData("application/x-tree-ids");if(V){const ae=JSON.parse(V);Array.isArray(ae)&&ae.length>0&&(k=ae)}}catch{}if(k.length===0){const V=h.dataTransfer.getData("text/plain");V&&(k=[V])}}if(k.length===0||k.includes(N)){H();return}console.log("[TreeTable] dispatching move",k,"->",N),K(k,N),H()},[K,H]),pe=m.useCallback(n=>{n.preventDefault(),n.stopPropagation();let h=S.current;if(h.length===0){try{const N=n.dataTransfer.getData("application/x-tree-ids");if(N){const k=JSON.parse(N);Array.isArray(k)&&k.length>0&&(h=k)}}catch{}if(h.length===0){const N=n.dataTransfer.getData("text/plain");N&&(h=[N])}}if(h.length===0){H();return}console.log("[TreeTable] root drop",h),K(h,null),H()},[K,H]),he=m.useCallback(n=>{n.preventDefault(),n.dataTransfer.dropEffect="move",u(!0)},[]),xe=m.useCallback(n=>{f&&(n.preventDefault(),n.dataTransfer.dropEffect="move")},[f]),ge=m.useCallback(n=>{if(!f)return;const N=document.elementFromPoint(n.clientX,n.clientY)?.closest?.("[data-tree-row-id]")?.dataset?.treeRowId??z.current;N&&ee(N,n)},[f,ee]);if(O)return e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full mx-auto"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Carregando..."})]})});if(!s||s.length===0)return e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center space-y-2",children:[e.jsx($,{className:"h-10 w-10 text-muted-foreground/50"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:B})]});const fe=U!==null;return e.jsxs("div",{className:q("border rounded-lg overflow-hidden relative",R),onDragOver:xe,onDrop:ge,onDragLeave:f?n=>{const h=n.relatedTarget;(!h||!n.currentTarget.contains(h))&&(t(null),u(!1))}:void 0,children:[f&&fe&&e.jsx(Ue,{onDrop:pe,isDragOver:a,onDragOver:he,onDragLeave:()=>u(!1),label:A}),e.jsxs(ve,{children:[e.jsx(Ne,{children:e.jsxs(oe,{children:[e.jsx(re,{className:"text-left",style:{minWidth:J},children:e.jsxs("div",{className:"flex items-center gap-2",children:[T&&e.jsx(te,{checked:i??!1,onCheckedChange:()=>p?.()}),b]})}),o.map(n=>e.jsx(re,{className:q("text-center",n.className),style:n.width?{width:n.width}:void 0,children:n.header},String(n.key))),l&&e.jsx(re,{className:"text-right",style:{width:I},children:E})]})}),e.jsx(je,{children:s.map(n=>e.jsx(le,{item:n,level:0,columns:o,nameKey:c,iconComponent:L,expandedIds:v,onToggleExpand:j,onRowClick:D,renderActions:l,rowActionsVariant:M,enableSelection:T,selectedIds:F,onSelectItem:d,enableRowDrag:f,draggedId:U,dragOverId:r,onDragStartCell:ue,onDragEndCell:H,onDragOverCell:me,onDropCell:ee,dragCount:x},n.id))})]})]})}function ta(){return e.jsx(Ee,{title:"Leadership",description:"Módulo hierárquico de liderança para gerenciar relações de liderança entre usuários do Qualiex. Inclui componentes visuais, hooks de API e utilitários para construção de árvores hierárquicas.",installation:`import {
|
|
2
|
-
LeadershipPage,
|
|
3
|
-
LeadershipDialog,
|
|
4
|
-
LeadershipForm,
|
|
5
|
-
LeaderRow,
|
|
6
|
-
useLeadershipApi,
|
|
7
|
-
useLeadershipMutations,
|
|
8
|
-
buildHierarchy,
|
|
9
|
-
flattenTree
|
|
10
|
-
} from 'forlogic-core';`,component:e.jsx(Ie,{}),usage:`// Página completa de liderança
|
|
11
|
-
import { LeadershipPage } from 'forlogic-core';
|
|
12
|
-
|
|
13
|
-
function MyLeadershipPage() {
|
|
14
|
-
return <LeadershipPage />;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// Ou use componentes individuais
|
|
18
|
-
import {
|
|
19
|
-
LeadershipDialog,
|
|
20
|
-
useLeadershipApi
|
|
21
|
-
} from 'forlogic-core';
|
|
22
|
-
|
|
23
|
-
function CustomLeadershipView() {
|
|
24
|
-
const { data: leaders, isLoading } = useLeadershipApi();
|
|
25
|
-
const [dialogOpen, setDialogOpen] = useState(false);
|
|
26
|
-
|
|
27
|
-
if (isLoading) return <div>Carregando...</div>;
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<div>
|
|
31
|
-
<Button onClick={() => setDialogOpen(true)}>
|
|
32
|
-
Adicionar Líder
|
|
33
|
-
</Button>
|
|
34
|
-
|
|
35
|
-
<LeadershipDialog
|
|
36
|
-
open={dialogOpen}
|
|
37
|
-
onOpenChange={setDialogOpen}
|
|
38
|
-
title="Novo Líder"
|
|
39
|
-
/>
|
|
40
|
-
|
|
41
|
-
{/* Renderizar hierarquia */}
|
|
42
|
-
</div>
|
|
43
|
-
);
|
|
44
|
-
}`,examples:[{title:"Estrutura de Tipos",description:"Tipos principais usados no módulo de liderança.",preview:e.jsx(Fe,{}),code:`// Tipos principais
|
|
45
|
-
interface Leader {
|
|
46
|
-
id: string;
|
|
47
|
-
alias: string;
|
|
48
|
-
id_user: string; // ID do usuário no Qualiex
|
|
49
|
-
id_leader: string | null; // ID do líder superior (null = raiz)
|
|
50
|
-
is_removed: boolean;
|
|
51
|
-
is_active: boolean;
|
|
52
|
-
created_at: string;
|
|
53
|
-
updated_at: string;
|
|
54
|
-
|
|
55
|
-
// Campos enriquecidos do Qualiex (virtuais)
|
|
56
|
-
name?: string;
|
|
57
|
-
email?: string;
|
|
58
|
-
subordinatesCount?: number;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
interface LeaderNode extends Leader {
|
|
62
|
-
children: LeaderNode[]; // Subordinados diretos
|
|
63
|
-
level: number; // Nível na hierarquia (0 = raiz)
|
|
64
|
-
}`},{title:"Hook useLeadershipApi",description:"Hook para buscar a hierarquia de liderança com dados enriquecidos do Qualiex.",preview:e.jsx(He,{}),code:`import { useLeadershipApi, flattenTree } from 'forlogic-core';
|
|
65
|
-
|
|
66
|
-
function LeadersList() {
|
|
67
|
-
const {
|
|
68
|
-
data: leaders = [], // LeaderNode[] - árvore hierárquica
|
|
69
|
-
isLoading,
|
|
70
|
-
error
|
|
71
|
-
} = useLeadershipApi();
|
|
72
|
-
|
|
73
|
-
if (isLoading) return <div>Carregando...</div>;
|
|
74
|
-
if (error) return <div>Erro: {error.message}</div>;
|
|
75
|
-
|
|
76
|
-
// Achatar a árvore para iteração simples
|
|
77
|
-
const allLeaders = flattenTree(leaders);
|
|
78
|
-
|
|
79
|
-
return (
|
|
80
|
-
<ul>
|
|
81
|
-
{allLeaders.map(leader => (
|
|
82
|
-
<li key={leader.id} style={{ marginLeft: leader.level * 20 }}>
|
|
83
|
-
{leader.name} ({leader.subordinatesCount} subordinados)
|
|
84
|
-
</li>
|
|
85
|
-
))}
|
|
86
|
-
</ul>
|
|
87
|
-
);
|
|
88
|
-
}`},{title:"LeadershipDialog",description:"Dialog modal para adicionar ou editar um líder.",preview:e.jsx(qe,{}),code:`import { useState } from 'react';
|
|
89
|
-
import { LeadershipDialog, Button } from 'forlogic-core';
|
|
90
|
-
|
|
91
|
-
function AddLeaderButton() {
|
|
92
|
-
const [open, setOpen] = useState(false);
|
|
93
|
-
|
|
94
|
-
return (
|
|
95
|
-
<>
|
|
96
|
-
<Button onClick={() => setOpen(true)}>
|
|
97
|
-
Adicionar Líder
|
|
98
|
-
</Button>
|
|
99
|
-
|
|
100
|
-
<LeadershipDialog
|
|
101
|
-
open={open}
|
|
102
|
-
onOpenChange={setOpen}
|
|
103
|
-
title="Novo Líder"
|
|
104
|
-
// Opcional: pré-selecionar um líder superior
|
|
105
|
-
prefilledLeaderId="user-uuid-do-lider"
|
|
106
|
-
/>
|
|
107
|
-
</>
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Editando um líder existente
|
|
112
|
-
function EditLeaderButton({ leader }) {
|
|
113
|
-
const [open, setOpen] = useState(false);
|
|
114
|
-
|
|
115
|
-
return (
|
|
116
|
-
<>
|
|
117
|
-
<Button variant="outline" onClick={() => setOpen(true)}>
|
|
118
|
-
Editar
|
|
119
|
-
</Button>
|
|
120
|
-
|
|
121
|
-
<LeadershipDialog
|
|
122
|
-
open={open}
|
|
123
|
-
onOpenChange={setOpen}
|
|
124
|
-
leader={leader} // Passa o líder para edição
|
|
125
|
-
title="Editar Líder"
|
|
126
|
-
/>
|
|
127
|
-
</>
|
|
128
|
-
);
|
|
129
|
-
}`},{title:"Mutations (useLeadershipMutations)",description:"Hooks de mutação para criar, atualizar e remover líderes.",preview:e.jsx(_e,{}),code:`import {
|
|
130
|
-
useCreateMultipleLeadersMutation,
|
|
131
|
-
useUpdateLeaderMutation,
|
|
132
|
-
useRemoveLeaderMutation,
|
|
133
|
-
useSyncSubordinatesMutation
|
|
134
|
-
} from 'forlogic-core';
|
|
135
|
-
|
|
136
|
-
function LeaderActions() {
|
|
137
|
-
// Criar múltiplos liderados de uma vez
|
|
138
|
-
const createMultiple = useCreateMultipleLeadersMutation();
|
|
139
|
-
|
|
140
|
-
// Atualizar líder existente
|
|
141
|
-
const updateLeader = useUpdateLeaderMutation();
|
|
142
|
-
|
|
143
|
-
// Remover líder (soft delete)
|
|
144
|
-
const removeLeader = useRemoveLeaderMutation();
|
|
145
|
-
|
|
146
|
-
// Sincronizar subordinados de um líder
|
|
147
|
-
const syncSubordinates = useSyncSubordinatesMutation();
|
|
148
|
-
|
|
149
|
-
const handleCreateMultiple = async () => {
|
|
150
|
-
await createMultiple.mutateAsync({
|
|
151
|
-
id_leader: 'uuid-do-lider-superior', // null para raiz
|
|
152
|
-
users: [
|
|
153
|
-
{ id_user: 'uuid-usuario-1' },
|
|
154
|
-
{ id_user: 'uuid-usuario-2' }
|
|
155
|
-
]
|
|
156
|
-
});
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
const handleUpdate = async () => {
|
|
160
|
-
await updateLeader.mutateAsync({
|
|
161
|
-
id: 'uuid-do-registro-leader',
|
|
162
|
-
id_leader: 'novo-uuid-lider-superior'
|
|
163
|
-
});
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
const handleRemove = async () => {
|
|
167
|
-
await removeLeader.mutateAsync('uuid-do-registro-leader');
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
const handleSync = async () => {
|
|
171
|
-
await syncSubordinates.mutateAsync({
|
|
172
|
-
leaderUserId: 'uuid-do-lider',
|
|
173
|
-
selectedUsers: [
|
|
174
|
-
{ id_user: 'uuid-subordinado-1' },
|
|
175
|
-
{ id_user: 'uuid-subordinado-2' }
|
|
176
|
-
]
|
|
177
|
-
});
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
return (
|
|
181
|
-
<div className="space-x-2">
|
|
182
|
-
<Button onClick={handleCreateMultiple}>Criar Múltiplos</Button>
|
|
183
|
-
<Button onClick={handleUpdate}>Atualizar</Button>
|
|
184
|
-
<Button onClick={handleRemove} variant="destructive">Remover</Button>
|
|
185
|
-
<Button onClick={handleSync}>Sincronizar</Button>
|
|
186
|
-
</div>
|
|
187
|
-
);
|
|
188
|
-
}`},{title:"Utilitários (buildHierarchy, flattenTree)",description:"Funções utilitárias para manipular a estrutura hierárquica.",preview:e.jsx(Qe,{}),code:`import { buildHierarchy, flattenTree } from 'forlogic-core';
|
|
189
|
-
|
|
190
|
-
// buildHierarchy: Converte lista plana em árvore
|
|
191
|
-
const leaders = [
|
|
192
|
-
{ id: '1', id_user: 'user-a', id_leader: null, name: 'CEO' },
|
|
193
|
-
{ id: '2', id_user: 'user-b', id_leader: 'user-a', name: 'Diretor' },
|
|
194
|
-
{ id: '3', id_user: 'user-c', id_leader: 'user-b', name: 'Gerente' }
|
|
195
|
-
];
|
|
196
|
-
|
|
197
|
-
const tree = buildHierarchy(leaders);
|
|
198
|
-
// Resultado:
|
|
199
|
-
// [{
|
|
200
|
-
// id: '1', name: 'CEO', level: 0, children: [
|
|
201
|
-
// { id: '2', name: 'Diretor', level: 1, children: [
|
|
202
|
-
// { id: '3', name: 'Gerente', level: 2, children: [] }
|
|
203
|
-
// ]}
|
|
204
|
-
// ]
|
|
205
|
-
// }]
|
|
206
|
-
|
|
207
|
-
// flattenTree: Achata árvore para lista
|
|
208
|
-
const flatList = flattenTree(tree);
|
|
209
|
-
// Resultado: [CEO, Diretor, Gerente] com níveis preservados
|
|
210
|
-
|
|
211
|
-
// Uso comum: iterar mantendo indentação visual
|
|
212
|
-
flatList.forEach(node => {
|
|
213
|
-
const indent = ' '.repeat(node.level);
|
|
214
|
-
console.log(\`\${indent}\${node.name}\`);
|
|
215
|
-
});`},{title:"LeaderRow (Componente de Linha)",description:"Componente de linha expansível para tabelas de liderança.",preview:e.jsx(Je,{}),code:`import { useState } from 'react';
|
|
216
|
-
import { LeaderRow, useLeadershipApi } from 'forlogic-core';
|
|
217
|
-
|
|
218
|
-
function LeadersTable() {
|
|
219
|
-
const { data: leaders = [] } = useLeadershipApi();
|
|
220
|
-
const [expandedIds, setExpandedIds] = useState<Set<string>>(new Set());
|
|
221
|
-
|
|
222
|
-
const handleToggleExpand = (id: string) => {
|
|
223
|
-
setExpandedIds(prev => {
|
|
224
|
-
const next = new Set(prev);
|
|
225
|
-
if (next.has(id)) {
|
|
226
|
-
next.delete(id);
|
|
227
|
-
} else {
|
|
228
|
-
next.add(id);
|
|
229
|
-
}
|
|
230
|
-
return next;
|
|
231
|
-
});
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
const handleEdit = (leader) => {
|
|
235
|
-
console.log('Editar:', leader);
|
|
236
|
-
};
|
|
237
|
-
|
|
238
|
-
return (
|
|
239
|
-
<table className="w-full">
|
|
240
|
-
<thead>
|
|
241
|
-
<tr>
|
|
242
|
-
<th>Nome</th>
|
|
243
|
-
<th>Subordinados</th>
|
|
244
|
-
</tr>
|
|
245
|
-
</thead>
|
|
246
|
-
<tbody>
|
|
247
|
-
{leaders.map(leader => (
|
|
248
|
-
<LeaderRow
|
|
249
|
-
key={leader.id}
|
|
250
|
-
leader={leader}
|
|
251
|
-
expandedIds={expandedIds}
|
|
252
|
-
onToggleExpand={handleToggleExpand}
|
|
253
|
-
onEdit={handleEdit}
|
|
254
|
-
/>
|
|
255
|
-
))}
|
|
256
|
-
</tbody>
|
|
257
|
-
</table>
|
|
258
|
-
);
|
|
259
|
-
}`},{title:"Página Completa (LeadershipPage)",description:"Componente de página completa com todas as funcionalidades integradas.",preview:e.jsx(Ge,{}),code:`import { LeadershipPage } from 'forlogic-core';
|
|
260
|
-
|
|
261
|
-
// Uso simples - página completa pronta
|
|
262
|
-
function MyApp() {
|
|
263
|
-
return (
|
|
264
|
-
<Routes>
|
|
265
|
-
<Route path="/leadership" element={<LeadershipPage />} />
|
|
266
|
-
</Routes>
|
|
267
|
-
);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
// A LeadershipPage inclui:
|
|
271
|
-
// - Botão "Adicionar Líder"
|
|
272
|
-
// - Botões "Expandir/Colapsar Todos"
|
|
273
|
-
// - Tabela hierárquica com LeaderRow
|
|
274
|
-
// - LeadershipDialog para criar/editar
|
|
275
|
-
// - Contadores de usuários associados/não associados
|
|
276
|
-
// - Persistência do estado de expansão no localStorage`},{title:"Exemplo Completo Integrado",description:"Implementação customizada com todos os recursos do módulo de liderança.",preview:e.jsx(Ke,{}),code:`import { useState, useMemo } from 'react';
|
|
277
|
-
import {
|
|
278
|
-
useLeadershipApi,
|
|
279
|
-
useRemoveLeaderMutation,
|
|
280
|
-
LeadershipDialog,
|
|
281
|
-
LeaderRow,
|
|
282
|
-
flattenTree,
|
|
283
|
-
Button,
|
|
284
|
-
Card,
|
|
285
|
-
toast
|
|
286
|
-
} from 'forlogic-core';
|
|
287
|
-
import { Users, UserPlus, ChevronDown, ChevronUp, Trash2 } from 'lucide-react';
|
|
288
|
-
|
|
289
|
-
function CustomLeadershipPage() {
|
|
290
|
-
const { data: leaders = [], isLoading, error } = useLeadershipApi();
|
|
291
|
-
const removeLeader = useRemoveLeaderMutation();
|
|
292
|
-
|
|
293
|
-
const [dialogOpen, setDialogOpen] = useState(false);
|
|
294
|
-
const [editingLeader, setEditingLeader] = useState<Leader | null>(null);
|
|
295
|
-
const [expandedIds, setExpandedIds] = useState<Set<string>>(new Set());
|
|
296
|
-
|
|
297
|
-
// Achatar árvore para estatísticas
|
|
298
|
-
const flatList = useMemo(() => flattenTree(leaders), [leaders]);
|
|
299
|
-
const totalLeaders = flatList.length;
|
|
300
|
-
const rootLeaders = leaders.length;
|
|
301
|
-
|
|
302
|
-
// Handlers
|
|
303
|
-
const handleToggleExpand = (id: string) => {
|
|
304
|
-
setExpandedIds(prev => {
|
|
305
|
-
const next = new Set(prev);
|
|
306
|
-
next.has(id) ? next.delete(id) : next.add(id);
|
|
307
|
-
return next;
|
|
308
|
-
});
|
|
309
|
-
};
|
|
310
|
-
|
|
311
|
-
const handleExpandAll = () => {
|
|
312
|
-
setExpandedIds(new Set(flatList.map(l => l.id)));
|
|
313
|
-
};
|
|
314
|
-
|
|
315
|
-
const handleCollapseAll = () => {
|
|
316
|
-
setExpandedIds(new Set());
|
|
317
|
-
};
|
|
318
|
-
|
|
319
|
-
const handleEdit = (leader: Leader) => {
|
|
320
|
-
setEditingLeader(leader);
|
|
321
|
-
setDialogOpen(true);
|
|
322
|
-
};
|
|
323
|
-
|
|
324
|
-
const handleAdd = () => {
|
|
325
|
-
setEditingLeader(null);
|
|
326
|
-
setDialogOpen(true);
|
|
327
|
-
};
|
|
328
|
-
|
|
329
|
-
const handleRemove = async (leader: Leader) => {
|
|
330
|
-
try {
|
|
331
|
-
await removeLeader.mutateAsync(leader.id);
|
|
332
|
-
toast.success(\`\${leader.name} removido com sucesso\`);
|
|
333
|
-
} catch (error) {
|
|
334
|
-
toast.error('Erro ao remover líder');
|
|
335
|
-
}
|
|
336
|
-
};
|
|
337
|
-
|
|
338
|
-
const handleDialogClose = () => {
|
|
339
|
-
setDialogOpen(false);
|
|
340
|
-
setEditingLeader(null);
|
|
341
|
-
};
|
|
342
|
-
|
|
343
|
-
if (isLoading) return <div>Carregando hierarquia...</div>;
|
|
344
|
-
if (error) return <div>Erro: {error.message}</div>;
|
|
345
|
-
|
|
346
|
-
return (
|
|
347
|
-
<div className="space-y-6">
|
|
348
|
-
{/* Header com estatísticas e ações */}
|
|
349
|
-
<div className="flex items-center justify-between">
|
|
350
|
-
<div>
|
|
351
|
-
<h1 className="text-2xl font-bold">Hierarquia de Liderança</h1>
|
|
352
|
-
<p className="text-muted-foreground">
|
|
353
|
-
{totalLeaders} líderes • {rootLeaders} níveis raiz
|
|
354
|
-
</p>
|
|
355
|
-
</div>
|
|
356
|
-
|
|
357
|
-
<div className="flex gap-2">
|
|
358
|
-
<Button variant="outline" size="sm" onClick={handleExpandAll}>
|
|
359
|
-
<ChevronDown className="h-4 w-4 mr-1" />
|
|
360
|
-
Expandir
|
|
361
|
-
</Button>
|
|
362
|
-
<Button variant="outline" size="sm" onClick={handleCollapseAll}>
|
|
363
|
-
<ChevronUp className="h-4 w-4 mr-1" />
|
|
364
|
-
Colapsar
|
|
365
|
-
</Button>
|
|
366
|
-
<Button onClick={handleAdd}>
|
|
367
|
-
<UserPlus className="h-4 w-4 mr-1" />
|
|
368
|
-
Adicionar Líder
|
|
369
|
-
</Button>
|
|
370
|
-
</div>
|
|
371
|
-
</div>
|
|
372
|
-
|
|
373
|
-
{/* Tabela hierárquica */}
|
|
374
|
-
<Card>
|
|
375
|
-
<table className="w-full">
|
|
376
|
-
<thead className="bg-muted/50">
|
|
377
|
-
<tr>
|
|
378
|
-
<th className="text-left p-4">Líder</th>
|
|
379
|
-
<th className="text-center p-4">Subordinados</th>
|
|
380
|
-
<th className="text-right p-4">Ações</th>
|
|
381
|
-
</tr>
|
|
382
|
-
</thead>
|
|
383
|
-
<tbody>
|
|
384
|
-
{leaders.map(leader => (
|
|
385
|
-
<LeaderRow
|
|
386
|
-
key={leader.id}
|
|
387
|
-
leader={leader}
|
|
388
|
-
expandedIds={expandedIds}
|
|
389
|
-
onToggleExpand={handleToggleExpand}
|
|
390
|
-
onEdit={handleEdit}
|
|
391
|
-
// Ação extra de remoção
|
|
392
|
-
actions={
|
|
393
|
-
<Button
|
|
394
|
-
variant="ghost"
|
|
395
|
-
size="sm"
|
|
396
|
-
onClick={() => handleRemove(leader)}
|
|
397
|
-
>
|
|
398
|
-
<Trash2 className="h-4 w-4 text-destructive" />
|
|
399
|
-
</Button>
|
|
400
|
-
}
|
|
401
|
-
/>
|
|
402
|
-
))}
|
|
403
|
-
</tbody>
|
|
404
|
-
</table>
|
|
405
|
-
</Card>
|
|
406
|
-
|
|
407
|
-
{/* Dialog para criar/editar */}
|
|
408
|
-
<LeadershipDialog
|
|
409
|
-
open={dialogOpen}
|
|
410
|
-
onOpenChange={handleDialogClose}
|
|
411
|
-
leader={editingLeader}
|
|
412
|
-
title={editingLeader ? 'Editar Líder' : 'Novo Líder'}
|
|
413
|
-
/>
|
|
414
|
-
</div>
|
|
415
|
-
);
|
|
416
|
-
}`},{title:"Hierarquia de Locais (TreeTable reutilizado)",description:"Demonstra a reutilização do TreeTable para uma hierarquia de locais com colunas e ícones customizados.",preview:e.jsx(Xe,{}),code:`import { TreeTable, TreeTableColumn, TreeNode } from 'forlogic-core';
|
|
417
|
-
import { Building } from 'lucide-react';
|
|
418
|
-
|
|
419
|
-
interface PlaceNode extends TreeNode {
|
|
420
|
-
name: string;
|
|
421
|
-
type: string; // "Matriz", "Filial", "Departamento", "Setor"
|
|
422
|
-
usersCount: number;
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
const columns: TreeTableColumn<PlaceNode>[] = [
|
|
426
|
-
{
|
|
427
|
-
key: 'type',
|
|
428
|
-
header: 'Tipo de Local',
|
|
429
|
-
className: 'text-left',
|
|
430
|
-
render: (item) => (
|
|
431
|
-
<span className="text-sm px-2 py-0.5 rounded bg-muted">
|
|
432
|
-
{item.type}
|
|
433
|
-
</span>
|
|
434
|
-
),
|
|
435
|
-
},
|
|
436
|
-
{
|
|
437
|
-
key: 'usersCount',
|
|
438
|
-
header: 'Qtd. Usuários',
|
|
439
|
-
},
|
|
440
|
-
];
|
|
441
|
-
|
|
442
|
-
<TreeTable<PlaceNode>
|
|
443
|
-
data={places}
|
|
444
|
-
columns={columns}
|
|
445
|
-
nameKey="name"
|
|
446
|
-
nameHeader="Local"
|
|
447
|
-
rootDropLabel="Tornar Local Raiz"
|
|
448
|
-
iconComponent={<Building className="h-4 w-4 text-muted-foreground" />}
|
|
449
|
-
enableRowDrag
|
|
450
|
-
enableSelection
|
|
451
|
-
onMoveNode={handleMove}
|
|
452
|
-
/>`}],props:[{name:"LeadershipDialog.open",type:"boolean",description:"Controla a visibilidade do dialog."},{name:"LeadershipDialog.onOpenChange",type:"(open: boolean) => void",description:"Callback quando o estado de abertura muda."},{name:"LeadershipDialog.leader",type:"Leader",description:"Líder a ser editado (se não fornecido, cria novo)."},{name:"LeadershipDialog.prefilledLeaderId",type:"string | null",description:"ID do líder superior pré-selecionado (para criação)."},{name:"LeadershipDialog.title",type:"string",description:"Título do dialog."},{name:"LeaderRow.leader",type:"LeaderNode",description:"Nó do líder a ser renderizado."},{name:"LeaderRow.expandedIds",type:"Set<string>",description:"IDs dos nós atualmente expandidos."},{name:"LeaderRow.onToggleExpand",type:"(id: string) => void",description:"Callback para alternar expansão de um nó."},{name:"LeaderRow.onEdit",type:"(leader: Leader) => void",description:"Callback quando o nome do líder é clicado."},{name:"LeadershipForm.leader",type:"Leader",description:"Líder a ser editado (modo edição)."},{name:"LeadershipForm.prefilledLeaderId",type:"string | null",description:"ID do líder superior pré-selecionado."},{name:"LeadershipForm.onSuccess",type:"() => void",description:"Callback executado após salvar com sucesso."}],accessibility:["Os botões de expandir/colapsar são acessíveis via teclado.",'Os nomes clicáveis têm role="button" implícito.',"O dialog segue padrões WAI-ARIA para modais.","Checkboxes de seleção de usuários são navegáveis via Tab.","Estados de loading são anunciados para leitores de tela."],notes:["O módulo requer autenticação ativa (useAuth) e integração com Qualiex.","Os dados são enriquecidos automaticamente com nomes/emails do Qualiex.",'Líderes "virtuais" são criados automaticamente para referências não cadastradas.',"Validação de ciclos na hierarquia é feita automaticamente.","O estado de expansão é persistido no localStorage por alias.","Soft delete é usado para remoção (is_removed = true)."]})}function Ie(){return e.jsxs("div",{className:"p-6 border rounded-lg bg-card space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_,{className:"h-6 w-6 text-primary"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Módulo de Liderança"})]}),e.jsx("p",{className:"text-muted-foreground",children:"Sistema completo para gerenciar hierarquias de liderança, incluindo:"}),e.jsxs("ul",{className:"list-disc list-inside space-y-1 text-sm",children:[e.jsx("li",{children:"Visualização em árvore hierárquica"}),e.jsx("li",{children:"Criação e edição de líderes"}),e.jsx("li",{children:"Seleção múltipla de subordinados"}),e.jsx("li",{children:"Validação automática de ciclos"}),e.jsx("li",{children:"Integração com usuários do Qualiex"})]})]})}function Fe(){return e.jsxs("div",{className:"p-4 border rounded-lg bg-muted/30 font-mono text-xs space-y-2",children:[e.jsx("div",{className:"text-primary",children:"Leader"}),e.jsx("div",{className:"pl-4 text-muted-foreground",children:"id, alias, id_user, id_leader, is_removed, is_active"}),e.jsx("div",{className:"text-primary",children:"LeaderNode extends Leader"}),e.jsx("div",{className:"pl-4 text-muted-foreground",children:"children: LeaderNode[], level: number"})]})}function He(){const s=[{name:"CEO",level:0,subordinatesCount:2},{name:"Diretor A",level:1,subordinatesCount:3},{name:"Diretor B",level:1,subordinatesCount:1}];return e.jsxs("div",{className:"p-4 border rounded-lg space-y-2",children:[e.jsx("div",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Resultado do useLeadershipApi:"}),s.map((o,c)=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",style:{paddingLeft:o.level*16},children:[e.jsx(_,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:o.name}),e.jsxs("span",{className:"text-muted-foreground",children:["(",o.subordinatesCount," subordinados)"]})]},c))]})}function qe(){const[s,o]=m.useState(!1);return e.jsx("div",{className:"p-4 border rounded-lg",children:e.jsxs(Le,{open:s,onOpenChange:o,children:[e.jsx(Ce,{asChild:!0,children:e.jsxs(Q,{children:[e.jsx(Y,{className:"h-4 w-4 mr-2"}),"Adicionar Líder"]})}),e.jsxs(ye,{children:[e.jsx(Se,{children:e.jsx(De,{children:"Novo Líder"})}),e.jsx("div",{className:"py-4 text-center text-muted-foreground",children:"[LeadershipForm seria renderizado aqui]"})]})]})})}function _e(){return e.jsxs("div",{className:"p-4 border rounded-lg space-y-3",children:[e.jsx("div",{className:"text-sm font-medium",children:"Mutations disponíveis:"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[e.jsx("div",{className:"p-2 bg-muted/50 rounded",children:"useCreateMultipleLeadersMutation"}),e.jsx("div",{className:"p-2 bg-muted/50 rounded",children:"useUpdateLeaderMutation"}),e.jsx("div",{className:"p-2 bg-muted/50 rounded",children:"useRemoveLeaderMutation"}),e.jsx("div",{className:"p-2 bg-muted/50 rounded",children:"useSyncSubordinatesMutation"})]})]})}function Qe(){const s=[{name:"CEO",level:0},{name:"├── Diretor",level:1},{name:"│ └── Gerente",level:2}];return e.jsxs("div",{className:"p-4 border rounded-lg font-mono text-sm space-y-1",children:[e.jsx("div",{className:"text-muted-foreground mb-2",children:"buildHierarchy → flattenTree:"}),s.map((o,c)=>e.jsx("div",{children:o.name},c))]})}function Je(){const[s,o]=m.useState(!0);return e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-muted/50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left p-3",children:"Nome"}),e.jsx("th",{className:"text-center p-3",children:"Subordinados"})]})}),e.jsxs("tbody",{children:[e.jsxs("tr",{className:"border-t hover:bg-muted/30",children:[e.jsx("td",{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>o(!s),className:"p-1 hover:bg-accent rounded",children:s?e.jsx(X,{className:"h-4 w-4"}):e.jsx(W,{className:"h-4 w-4"})}),e.jsx(_,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium hover:text-primary cursor-pointer",children:"CEO"})]})}),e.jsx("td",{className:"text-center p-3",children:"2"})]}),s&&e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:"border-t hover:bg-muted/30",children:[e.jsx("td",{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-2",style:{paddingLeft:32},children:[e.jsx("button",{className:"p-1 hover:bg-accent rounded",children:e.jsx(W,{className:"h-4 w-4"})}),e.jsx(_,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium hover:text-primary cursor-pointer",children:"Diretor A"})]})}),e.jsx("td",{className:"text-center p-3",children:"3"})]}),e.jsxs("tr",{className:"border-t hover:bg-muted/30",children:[e.jsx("td",{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-2",style:{paddingLeft:32},children:[e.jsx("div",{className:"w-6"}),e.jsx(_,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium hover:text-primary cursor-pointer",children:"Diretor B"})]})}),e.jsx("td",{className:"text-center p-3",children:"0"})]})]})]})]})})}function Ge(){return e.jsxs("div",{className:"p-4 border rounded-lg space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"font-medium",children:"LeadershipPage"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Q,{size:"sm",variant:"outline",children:"Expandir Todos"}),e.jsxs(Q,{size:"sm",children:[e.jsx(Y,{className:"h-4 w-4 mr-1"}),"Adicionar"]})]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Inclui tabela hierárquica, dialog de edição, contadores e persistência"})]})}const Ve=[{id:"1",name:"Maria Silva (CEO)",email:"maria@empresa.com",role:"Diretora Executiva",place:"Sede SP",subordinatesCount:2,subordinateNames:["João Souza","Ana Costa"],children:[{id:"2",name:"João Souza",email:"joao@empresa.com",role:"Gerente de Operações",place:"Sede SP",subordinatesCount:3,subordinateNames:["Carlos Lima","Fernanda Dias ","Ricardo Alves"],children:[{id:"4",name:"Carlos Lima",email:"carlos@empresa.com",role:"Analista Sênior",place:"Filial RJ",subordinatesCount:0,subordinateNames:[],children:[]},{id:"5",name:"Fernanda Dias",email:"fernanda@empresa.com",role:"Coordenadora",place:"Filial BH",subordinatesCount:2,subordinateNames:["Paula Rocha","Bruno Santos"],children:[]}]},{id:"3",name:"Ana Costa",email:"ana@empresa.com",role:"Gerente de Qualidade",place:"Sede SP",subordinatesCount:1,subordinateNames:["Marcos Oliveira"],children:[]}]}],$e=[{id:"u1",name:"Paula Rocha",email:"paula@empresa.com",role:"Analista",place:"Filial RJ",subordinatesCount:0,subordinateNames:[],children:[]},{id:"u2",name:"Bruno Santos",email:"bruno@empresa.com",role:"Técnico",place:"Filial BH",subordinatesCount:0,subordinateNames:[],children:[]},{id:"u3",name:"Marcos Oliveira",email:"marcos@empresa.com",role:"Auditor",place:"Sede SP",subordinatesCount:0,subordinateNames:[],children:[]},{id:"u4",name:"Lucia Ferreira",email:"lucia@empresa.com",role:"Assistente",place:"Filial RJ",subordinatesCount:0,subordinateNames:[],children:[]},{id:"u5",name:"Pedro Almeida",email:"pedro@empresa.com",role:"Estagiário",place:"Sede SP",subordinatesCount:0,subordinateNames:[],children:[]}],We=[{id:"p1",name:"ForLogic Tecnologia",type:"Matriz",usersCount:5,userNames:["Ana Costa","Carlos Lima","Fernanda Dias","Maria Silva","Pedro Almeida"],children:[{id:"p2",name:"Filial São Paulo",type:"Filial",usersCount:4,userNames:["Bruno Santos","Julia Martins","Lucas Ferreira","Renata Souza"],children:[{id:"p4",name:"Engenharia",type:"Departamento",usersCount:3,userNames:["Diego Rocha","Isabela Nunes","Thiago Mendes"],children:[]},{id:"p5",name:"Comercial",type:"Departamento",usersCount:2,userNames:["Camila Oliveira","Rafael Gomes"],children:[]}]},{id:"p3",name:"Filial Rio de Janeiro",type:"Filial",usersCount:3,userNames:["Amanda Ribeiro","Felipe Cardoso","Marcos Oliveira"],children:[{id:"p6",name:"Suporte",type:"Setor",usersCount:2,userNames:["Lucia Ferreira","Paulo Henrique"],children:[]},{id:"p7",name:"Qualidade",type:"Setor",usersCount:2,userNames:["Gabriela Santos","Roberto Silva"],children:[]}]}]}];function Ke(){const[s,o]=m.useState(Ve),[c,b]=m.useState($e),[L,v]=m.useState(new Set(["1","2"])),[j,D]=m.useState([]),[l,E]=m.useState(new Set),[M,O]=m.useState(!0),B=r=>{v(t=>{const a=new Set(t);return a.has(r)?a.delete(r):a.add(r),a})},R=r=>{D(t=>t.includes(r)?t.filter(a=>a!==r):[...t,r])},T=r=>{E(t=>{const a=new Set(t);return a.has(r)?a.delete(r):a.add(r),a})},P=r=>r.reduce((t,a)=>(t.push(a.id),a.children&&t.push(...P(a.children)),t),[]),d=m.useMemo(()=>P(s),[s]),p=d.length>0&&j.length===d.length,i=L.size>=d.length,f=()=>{v(i?new Set:new Set(d))},C=()=>{D(p?[]:d)},w=(r,t)=>{let a=null;return[r.reduce((x,g)=>{if(g.id===t)return a=g,x;const y=g.children??[],[S,z]=w(y,t);return z&&(a=z),x.push({...g,children:S}),x},[]),a]},A=(r,t,a)=>t===null?[...r,{...a,children:a.children??[]}]:r.map(u=>{const x=u.children??[];return u.id===t?{...u,children:[...x,{...a,children:a.children??[]}]}:{...u,children:A(x,t,a)}}),I=(r,t)=>{console.log("[DnD] Moving node",r,"to",t);const a=c.find(u=>u.id===r);if(a){b(u=>u.filter(x=>x.id!==r)),o(u=>A(u,t,a)),E(u=>{const x=new Set(u);return x.delete(r),x});return}o(u=>{const[x,g]=w(u,r);return g?A(x,t,g):u})},J=(r,t)=>{console.log("[DnD] Moving nodes",r,"to",t);const a=r.filter(x=>c.some(g=>g.id===x)),u=r.filter(x=>!a.includes(x));if(a.length>0){const x=c.filter(g=>a.includes(g.id));b(g=>g.filter(y=>!a.includes(y.id))),o(g=>{let y=g;for(const S of x)y=A(y,t,S);return y}),E(g=>{const y=new Set(g);return a.forEach(S=>y.delete(S)),y})}u.length>0&&o(x=>{let g=x;const y=[];for(const S of u){const[z,F]=w(g,S);F&&(g=z,y.push(F))}for(const S of y)g=A(g,t,S);return g}),D([])},U=(r,t)=>{const a=l.has(r)&&l.size>1?Array.from(l):[r];t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",r),t.dataTransfer.setData("application/x-tree-ids",JSON.stringify(a));const u=t.currentTarget;u.style.opacity="0.4"},G=[{key:"subordinatesCount",header:"Subordinados",width:120,hoverContent:r=>r.subordinateNames.length>0?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Subordinados diretos:"}),[...r.subordinateNames].sort((t,a)=>t.localeCompare(a)).map(t=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx($,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("span",{children:t})]},t))]}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"Sem subordinados diretos"})},{key:"email",header:"Email",className:"text-left",width:180,render:r=>e.jsxs("span",{className:"flex items-center gap-1.5 text-muted-foreground text-sm",children:[e.jsx(we,{className:"h-3.5 w-3.5"}),r.email]})},{key:"role",header:"Papel",width:140,className:"text-left",render:r=>e.jsxs("span",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx(Pe,{className:"h-3.5 w-3.5 text-muted-foreground"}),r.role||"—"]})},{key:"place",header:"Local",width:140,className:"text-left",render:r=>e.jsxs("span",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx(Te,{className:"h-3.5 w-3.5 text-muted-foreground"}),r.place||"—"]})}];return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold",children:"Hierarquia de Liderança"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Arraste as linhas para reorganizar • Selecione múltiplos para mover em lote"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Q,{size:"sm",variant:"outline",onClick:f,children:i?e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"h-4 w-4 mr-1"}),"Colapsar"]}):e.jsxs(e.Fragment,{children:[e.jsx(W,{className:"h-4 w-4 mr-1"}),"Expandir"]})}),e.jsxs(Q,{size:"sm",children:[e.jsx(Y,{className:"h-4 w-4 mr-1"}),"Adicionar"]})]})]}),e.jsx(ce,{data:s,columns:G,nameKey:"name",nameHeader:"Líder",expandedIds:L,onToggleExpand:B,iconComponent:e.jsx(_,{className:"h-4 w-4 text-muted-foreground shrink-0"}),rowActionsVariant:"inline",enableRowDrag:!0,enableSelection:!0,selectedIds:j,onSelectItem:R,onSelectAll:C,isAllSelected:p,onMoveNode:I,onMoveNodes:J,rootDropLabel:"Tornar Líder Raiz",renderActions:r=>e.jsx(Q,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(de,{className:"h-4 w-4"})})}),c.length>0&&e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>O(r=>!r),className:"w-full px-4 py-2.5 bg-muted/50 border-b flex items-center gap-2 hover:bg-muted/70 transition-colors cursor-pointer",children:[M?e.jsx(X,{className:"h-4 w-4 text-muted-foreground shrink-0"}):e.jsx(W,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx(Y,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium",children:"Usuários não associados"}),e.jsxs("span",{className:"text-xs text-muted-foreground ml-1",children:["(",c.length,")"]}),l.size>0&&e.jsxs("span",{className:"text-xs text-primary ml-1",children:["(",l.size," selecionado",l.size>1?"s":"",")"]}),e.jsx("span",{className:"text-xs text-muted-foreground ml-auto",children:"Arraste para a hierarquia acima"})]}),M&&e.jsx("div",{className:"divide-y",children:c.map(r=>e.jsxs("div",{draggable:!0,onDragStart:t=>U(r.id,t),onDragEnd:t=>{const a=t.currentTarget;a.style.opacity="1"},className:q("flex items-center gap-3 px-4 py-2.5 hover:bg-accent/50 cursor-grab active:cursor-grabbing transition-colors",l.has(r.id)&&"bg-primary/5"),children:[e.jsx(te,{checked:l.has(r.id),onCheckedChange:()=>T(r.id),onClick:t=>t.stopPropagation(),className:"shrink-0"}),e.jsx("span",{className:"text-muted-foreground shrink-0 select-none",children:"⠿"}),e.jsx($,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsxs("div",{className:"flex flex-col min-w-0",children:[e.jsx("span",{className:"text-sm truncate",children:r.name}),e.jsx("span",{className:"text-xs text-muted-foreground truncate",children:r.email})]})]},r.id))})]}),e.jsxs("div",{className:"px-3 py-2 bg-muted/20 border rounded-lg text-xs text-muted-foreground flex justify-between",children:[e.jsxs("span",{children:["Usuários associados: ",(()=>{const r=t=>t.reduce((a,u)=>a+1+r(u.children??[]),0);return r(s)})()]}),e.jsxs("span",{children:["Usuários não associados: ",c.length]})]})]})}function Xe(){const[s,o]=m.useState(We),[c,b]=m.useState(new Set(["p1","p2","p3"])),[L,v]=m.useState([]),j=d=>{b(p=>{const i=new Set(p);return i.has(d)?i.delete(d):i.add(d),i})},D=d=>{v(p=>p.includes(d)?p.filter(i=>i!==d):[...p,d])},l=d=>d.reduce((p,i)=>(p.push(i.id),i.children&&p.push(...l(i.children)),p),[]),E=m.useMemo(()=>l(s),[s]),M=E.length>0&&L.length===E.length,O=()=>{v(M?[]:E)},B=(d,p)=>{let i=null;return[d.reduce((C,w)=>{if(w.id===p)return i=w,C;const[A,I]=B(w.children??[],p);return I&&(i=I),C.push({...w,children:A}),C},[]),i]},R=(d,p,i)=>p===null?[...d,{...i,children:i.children??[]}]:d.map(f=>f.id===p?{...f,children:[...f.children??[],{...i,children:i.children??[]}]}:{...f,children:R(f.children??[],p,i)}),T=(d,p)=>{o(i=>{const[f,C]=B(i,d);return C?R(f,p,C):i})},P=[{key:"type",header:"Tipo de Local",width:140,className:"text-left",render:d=>e.jsx("span",{className:"text-sm px-2 py-0.5 rounded bg-muted",children:d.type})},{key:"usersCount",header:"Qtd. Usuários",width:120,hoverContent:d=>{const p=d.userNames??[];return p.length>0?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Usuários no local:"}),[...p].sort((i,f)=>i.localeCompare(f)).map(i=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx($,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("span",{children:i})]},i))]}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"Nenhum usuário neste local"})},render:d=>e.jsxs("span",{className:"flex items-center justify-center gap-1.5 text-sm",children:[e.jsx(_,{className:"h-3.5 w-3.5 text-muted-foreground"}),d.usersCount]})}];return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold",children:"Hierarquia de Locais"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Mesmo componente TreeTable reutilizado com colunas e ícones diferentes"})]}),e.jsx(ce,{data:s,columns:P,nameKey:"name",nameHeader:"Local",expandedIds:c,onToggleExpand:j,iconComponent:e.jsx(Re,{className:"h-4 w-4 text-muted-foreground shrink-0"}),rowActionsVariant:"inline",enableRowDrag:!0,enableSelection:!0,selectedIds:L,onSelectItem:D,onSelectAll:O,isAllSelected:M,onMoveNode:T,rootDropLabel:"Tornar Local Raiz",emptyMessage:"Nenhum local encontrado.",renderActions:d=>e.jsx(Q,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(de,{className:"h-4 w-4"})})})]})}export{ta as LeadershipDoc};
|