forlogic-core 2.0.3 → 2.0.5
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/README.md +187 -917
- 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/sidebar.d.ts +2 -1
- package/dist/types.d.ts +3 -0
- package/docs/AUDIT_PROMPT.md +74 -0
- package/docs/PROJECT_KNOWLEDGE_TEMPLATE.md +117 -0
- package/docs/PROMPT_TEMPLATE.md +77 -0
- package/docs/STARTER_TEMPLATE.md +114 -0
- package/docs/design-system/README.md +45 -0
- package/docs/design-system/buttons-actions.md +433 -0
- package/docs/design-system/charts-dashboards.md +547 -0
- package/docs/design-system/crud.md +243 -0
- package/docs/design-system/data-display.md +360 -0
- package/docs/design-system/dialogs.md +588 -0
- package/docs/design-system/domain.md +661 -0
- package/docs/design-system/examples.md +275 -0
- package/docs/design-system/foundation.md +82 -0
- package/docs/design-system/infra-utils.md +36 -0
- package/docs/design-system/inputs.md +556 -0
- package/docs/design-system/layout.md +351 -0
- package/docs/design-system/navigation.md +604 -0
- package/docs/design-system/notifications-feedback.md +139 -0
- package/docs/design-system/platform.md +95 -0
- package/docs/design-system/selectors.md +424 -0
- package/docs/design-system/tables-grids.md +114 -0
- package/package.json +2 -2
- 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,113 +0,0 @@
|
|
|
1
|
-
import{j as e,a5 as re,a6 as te,a7 as I,aX as ie,dy as ne,aa as A,a as y,d as F,b as W,c as M,r as d,gr as ce,y as oe,gs as me,E as $,G as O,H as L,I as U,J as x,K as E,N as j,O as p,Q as g,R as v,V as t,M as Ee,X as J,x as u,Y as n,P as Ie,d7 as Ae,ak as je,al as pe,an as ge,ao as D,aJ as ve,U as fe,Z as Ne,_ as Ce,$ as be,B as q,a0 as Se,a1 as ye}from"./index-DkiftrvI.js";import{D as xe}from"./disabled-menu-item-C2YaMvSt.js";import{u as he,c as Fe}from"./useMockCrud-CN4vjyOZ.js";import{C as De}from"./ComponentDocTemplate-CQbBhfvZ.js";import{P as de}from"./pen-Bi_lmmKT.js";import"./ExampleCard-DuLrb3t-.js";const we=Array.from({length:200},(o,h)=>{const r=h+1,C=`Tipo ${r%3+1}`,m=`Fornecedor ${["A","B","C"][r%3]}`,b=r%4===0?"Inativo":"Ativo";return Fe({id:String(r),item:`Item ${String(r).padStart(3,"0")}`,tipo:C,fornecedor:m,detalhes:`Detalhes do item ${r} (exemplo para demonstrar paginação)`,status:b})}),ke=[{key:"item",header:"Item",sortable:!0,minWidth:120,hideable:!1},{key:"tipo",header:"Tipo",sortable:!0,minWidth:100,groupable:!0},{key:"fornecedor",header:"Fornecedor",sortable:!0,minWidth:120,groupable:!0},{key:"detalhes",header:"Detalhes",minWidth:200},{key:"status",header:"Status",sortable:!0,minWidth:80,groupable:!0,render:o=>e.jsx(q,{variant:o.status==="Ativo"?"default":"secondary",children:o.status})}],H=["SP","RJ","MG","RS","PR","SC","BA","PE"],Te={SP:["São Paulo","Campinas","Santos","Ribeirão Preto"],RJ:["Rio de Janeiro","Niterói","Petrópolis"],MG:["Belo Horizonte","Uberlândia","Juiz de Fora"],RS:["Porto Alegre","Caxias do Sul","Pelotas"],PR:["Curitiba","Londrina","Maringá"],SC:["Florianópolis","Joinville","Blumenau"],BA:["Salvador","Feira de Santana"],PE:["Recife","Olinda"]},K=["Matéria Prima","Serviços","Logística","Equipamentos","Tecnologia"],ze=Array.from({length:150},(o,h)=>{const r=h+1,C=H[r%H.length],m=Te[C],b=m[r%m.length],f=K[r%K.length],z=r%5===0?"Inativo":"Ativo";return Fe({id:String(r),cnpj:`${String(r).padStart(2,"0")}.${String(r*3).padStart(3,"0")}.${String(r*7).padStart(3,"0")}/0001-${String(r%100).padStart(2,"0")}`,razaoSocial:`Empresa ${String(r).padStart(3,"0")} LTDA`,nomeFantasia:`Fornecedor ${String(r).padStart(3,"0")}`,email:`contato@fornecedor${r}.com.br`,telefone:`(${String(11+r%89).padStart(2,"0")}) ${String(9e4+r).slice(0,5)}-${String(1e3+r).slice(0,4)}`,cidade:b,estado:C,categoria:f,status:z})}),Pe=[{key:"cnpj",header:"CNPJ",minWidth:160},{key:"razaoSocial",header:"Razão Social",sortable:!0,minWidth:200},{key:"nomeFantasia",header:"Nome Fantasia",sortable:!0,minWidth:150},{key:"email",header:"Email",minWidth:180},{key:"cidade",header:"Cidade",sortable:!0,minWidth:120},{key:"estado",header:"UF",sortable:!0,minWidth:60},{key:"categoria",header:"Categoria",sortable:!0,minWidth:120},{key:"status",header:"Status",sortable:!0,minWidth:80,render:o=>e.jsx(q,{variant:o.status==="Ativo"?"default":"secondary",children:o.status})}];function Be(){const[o,h]=d.useState(""),[r,C]=d.useState(""),[m,b]=d.useState(""),[f,z]=d.useState(""),G=d.useCallback(a=>{if(o&&a.tipo!==o||r&&a.fornecedor!==r||m&&a.status!==m)return!1;if(f){const ue=f.toLowerCase();return a.item.toLowerCase().includes(ue)||a.detalhes.toLowerCase().includes(ue)}return!0},[o,r,m,f]),i=he(we,{searchFields:["item","tipo","fornecedor","detalhes"],pageSize:10,filterFn:G}),w=[o,r,m].filter(Boolean).length,Q=()=>{h(""),C(""),b("")},[X,N]=d.useState(!1),[k,P]=d.useState(null),[_,S]=d.useState(!1),[T,B]=d.useState(null),[l,c]=d.useState({item:"",tipo:"",fornecedor:"",detalhes:"",status:"Ativo"}),Y=()=>{P(null),c({item:"",tipo:"",fornecedor:"",detalhes:"",status:"Ativo"}),N(!0)},Z=a=>{P(a),c({item:a.item,tipo:a.tipo,fornecedor:a.fornecedor,detalhes:a.detalhes,status:a.status}),N(!0)},ee=async()=>{if(!l.item){n.error("Nome do item é obrigatório");return}k?(await i.updateEntity(k.id,l),n.success("Item atualizado!")):(await i.createEntity(l),n.success("Item criado!")),N(!1)},se=async a=>{await i.updateEntity(a.id,{status:a.status==="Ativo"?"Inativo":"Ativo"}),n.success("Status alterado!")},ae=a=>{B(a),S(!0)},le=()=>{T&&(i.deleteEntity(T.id),n.success("Item excluído!")),S(!1),B(null)},V=a=>{if(i.selectedIds.length<2){n.info("Selecione dois ou mais itens");return}a==="edit"?n.info(`Editando ${i.selectedIds.length} itens em massa...`):(i.bulkDelete(i.selectedIds),n.success(`${i.selectedIds.length} itens excluídos!`))},s=e.jsxs(e.Fragment,{children:[e.jsxs(je,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(u,{variant:"outline",className:"shrink-0",children:"Ações"})}),e.jsxs(ge,{children:[e.jsxs(D,{onClick:()=>n.info("Exportando..."),children:[e.jsx(ve,{className:"h-4 w-4 mr-2"}),"Exportar"]}),e.jsxs(D,{onClick:()=>n.info("Importando..."),children:[e.jsx(fe,{className:"h-4 w-4 mr-2"}),"Importar"]})]})]}),e.jsxs(Ne,{children:[e.jsx(Ce,{asChild:!0,children:e.jsxs(u,{variant:"outline",className:"shrink-0",children:[e.jsx(be,{className:"h-4 w-4 mr-2"}),"Filtrar",w>0&&e.jsx(q,{variant:"secondary",className:"ml-2 h-5 w-5 p-0 flex items-center justify-center",children:w})]})}),e.jsx(Se,{className:"w-80",align:"end",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"font-medium",children:"Filtros"}),w>0&&e.jsxs(u,{variant:"ghost",size:"sm",onClick:Q,className:"h-8 px-2 text-muted-foreground",children:[e.jsx(ye,{className:"h-4 w-4 mr-1"}),"Limpar"]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium",children:"Tipo"}),e.jsxs(j,{value:o||"all",onValueChange:a=>h(a==="all"?"":a),children:[e.jsx(p,{children:e.jsx(g,{placeholder:"Todos"})}),e.jsxs(v,{children:[e.jsx(t,{value:"all",children:"Todos"}),e.jsx(t,{value:"Tipo 1",children:"Tipo 1"}),e.jsx(t,{value:"Tipo 2",children:"Tipo 2"}),e.jsx(t,{value:"Tipo 3",children:"Tipo 3"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium",children:"Fornecedor"}),e.jsxs(j,{value:r||"all",onValueChange:a=>C(a==="all"?"":a),children:[e.jsx(p,{children:e.jsx(g,{placeholder:"Todos"})}),e.jsxs(v,{children:[e.jsx(t,{value:"all",children:"Todos"}),e.jsx(t,{value:"Fornecedor A",children:"Fornecedor A"}),e.jsx(t,{value:"Fornecedor B",children:"Fornecedor B"}),e.jsx(t,{value:"Fornecedor C",children:"Fornecedor C"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium",children:"Status"}),e.jsxs(j,{value:m||"all",onValueChange:a=>b(a==="all"?"":a),children:[e.jsx(p,{children:e.jsx(g,{placeholder:"Todos"})}),e.jsxs(v,{children:[e.jsx(t,{value:"all",children:"Todos"}),e.jsx(t,{value:"Ativo",children:"Ativo"}),e.jsx(t,{value:"Inativo",children:"Inativo"})]})]})]})]})]})})]})]}),R=[{label:"Editar em massa",icon:de,action:()=>V("edit")},{label:"Excluir em massa",icon:oe,variant:"destructive",action:()=>V("delete")}];return e.jsxs("div",{className:"border rounded-lg overflow-hidden bg-background",children:[e.jsx(ce,{manager:i,columns:ke,onNew:Y,newButtonLabel:"Adicionar item",onEdit:Z,onToggleStatus:se,onDelete:ae,enableBulkActions:!0,bulkActions:R,showSearch:!0,searchValue:f,onSearchChange:z,searchPlaceholder:"Buscar itens...",filters:s,resizeStorageKey:"crud-table-doc",enableColumnManager:!0,columnManagerStorageKey:"ds-crud-table-demo"}),e.jsx("div",{className:"border-t p-2",children:e.jsx(me,{manager:i})}),e.jsx($,{open:X,onOpenChange:N,children:e.jsxs(O,{children:[e.jsx(L,{children:e.jsx(U,{children:k?"Editar Item":"Novo Item"})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"item",children:"Nome"}),e.jsx(E,{id:"item",value:l.item,onChange:a=>c({...l,item:a.target.value}),placeholder:"Nome do item"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"tipo",children:"Tipo"}),e.jsxs(j,{value:l.tipo,onValueChange:a=>c({...l,tipo:a}),children:[e.jsx(p,{children:e.jsx(g,{placeholder:"Selecione"})}),e.jsxs(v,{children:[e.jsx(t,{value:"Tipo 1",children:"Tipo 1"}),e.jsx(t,{value:"Tipo 2",children:"Tipo 2"}),e.jsx(t,{value:"Tipo 3",children:"Tipo 3"})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"fornecedor",children:"Fornecedor"}),e.jsxs(j,{value:l.fornecedor,onValueChange:a=>c({...l,fornecedor:a}),children:[e.jsx(p,{children:e.jsx(g,{placeholder:"Selecione"})}),e.jsxs(v,{children:[e.jsx(t,{value:"Fornecedor A",children:"Fornecedor A"}),e.jsx(t,{value:"Fornecedor B",children:"Fornecedor B"}),e.jsx(t,{value:"Fornecedor C",children:"Fornecedor C"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"status",children:"Status"}),e.jsxs(j,{value:l.status,onValueChange:a=>c({...l,status:a}),children:[e.jsx(p,{children:e.jsx(g,{})}),e.jsxs(v,{children:[e.jsx(t,{value:"Ativo",children:"Ativo"}),e.jsx(t,{value:"Inativo",children:"Inativo"})]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"detalhes",children:"Detalhes"}),e.jsx(Ee,{id:"detalhes",value:l.detalhes,onChange:a=>c({...l,detalhes:a.target.value}),placeholder:"Detalhes adicionais..."})]})]}),e.jsxs(J,{children:[e.jsx(u,{variant:"outline",onClick:()=>N(!1),children:"Cancelar"}),e.jsx(u,{onClick:ee,children:"Salvar"})]})]})}),e.jsx($,{open:_,onOpenChange:S,children:e.jsxs(O,{size:"sm",children:[e.jsx(L,{showSeparator:!0,children:e.jsx(U,{className:"text-center",children:"Confirmar exclusão"})}),e.jsxs("div",{className:"space-y-2 text-center",children:[e.jsxs("p",{children:['Você está prestes a excluir o item "',T?.item,'".']}),e.jsx("p",{className:"text-muted-foreground",children:"Esta ação não pode ser desfeita."})]}),e.jsxs(J,{className:"justify-center gap-2",children:[e.jsx(u,{variant:"outline",onClick:()=>S(!1),children:"Cancelar"}),e.jsx(u,{variant:"destructive",onClick:le,children:"Sim, excluir"})]})]})})]})}const Ve=`import { CrudTable, CrudPagination, useCrud } from 'forlogic-core';
|
|
2
|
-
import type { CrudColumn, BaseEntity } from 'forlogic-core';
|
|
3
|
-
|
|
4
|
-
interface Item extends BaseEntity {
|
|
5
|
-
item: string;
|
|
6
|
-
tipo: string;
|
|
7
|
-
fornecedor: string;
|
|
8
|
-
detalhes: string;
|
|
9
|
-
status: 'Ativo' | 'Inativo';
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const columns: CrudColumn<Item>[] = [
|
|
13
|
-
{ key: 'item', header: 'Item', sortable: true, minWidth: 120 },
|
|
14
|
-
{ key: 'tipo', header: 'Tipo', sortable: true, minWidth: 100 },
|
|
15
|
-
{ key: 'fornecedor', header: 'Fornecedor', sortable: true },
|
|
16
|
-
{ key: 'detalhes', header: 'Detalhes', minWidth: 200 },
|
|
17
|
-
{
|
|
18
|
-
key: 'status',
|
|
19
|
-
header: 'Status',
|
|
20
|
-
render: (item) => (
|
|
21
|
-
<Badge variant={item.status === 'Ativo' ? 'default' : 'secondary'}>
|
|
22
|
-
{item.status}
|
|
23
|
-
</Badge>
|
|
24
|
-
),
|
|
25
|
-
},
|
|
26
|
-
];
|
|
27
|
-
|
|
28
|
-
function ItemsPage() {
|
|
29
|
-
const manager = useCrud<Item>({
|
|
30
|
-
tableName: 'items',
|
|
31
|
-
searchFields: ['item', 'tipo', 'fornecedor']
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
<div>
|
|
36
|
-
<CrudTable
|
|
37
|
-
manager={manager}
|
|
38
|
-
columns={columns}
|
|
39
|
-
onNew={() => openForm()}
|
|
40
|
-
onEdit={(item) => openForm(item)}
|
|
41
|
-
onToggleStatus={(item) => toggleStatus(item)}
|
|
42
|
-
onDelete={(item) => deleteItem(item)}
|
|
43
|
-
enableBulkActions
|
|
44
|
-
/>
|
|
45
|
-
<CrudPagination manager={manager} />
|
|
46
|
-
</div>
|
|
47
|
-
);
|
|
48
|
-
}`;function Re(){const[o,h]=d.useState(""),[r,C]=d.useState(""),[m,b]=d.useState(""),[f,z]=d.useState(""),G=d.useCallback(s=>{if(o&&s.categoria!==o||r&&s.estado!==r||m&&s.status!==m)return!1;if(f){const R=f.toLowerCase();return s.razaoSocial.toLowerCase().includes(R)||s.nomeFantasia.toLowerCase().includes(R)||s.cnpj.includes(f)||s.email.toLowerCase().includes(R)}return!0},[o,r,m,f]),i=he(ze,{searchFields:["razaoSocial","nomeFantasia","cnpj","email","cidade"],pageSize:10,filterFn:G}),w=[o,r,m].filter(Boolean).length,Q=()=>{h(""),C(""),b("")},[X,N]=d.useState(!1),[k,P]=d.useState(null),[_,S]=d.useState(!1),[T,B]=d.useState(null),[l,c]=d.useState({cnpj:"",razaoSocial:"",nomeFantasia:"",email:"",telefone:"",cidade:"",estado:"",categoria:"",status:"Ativo"}),Y=()=>{P(null),c({cnpj:"",razaoSocial:"",nomeFantasia:"",email:"",telefone:"",cidade:"",estado:"",categoria:"",status:"Ativo"}),N(!0)},Z=s=>{P(s),c({cnpj:s.cnpj,razaoSocial:s.razaoSocial,nomeFantasia:s.nomeFantasia,email:s.email,telefone:s.telefone,cidade:s.cidade,estado:s.estado,categoria:s.categoria,status:s.status}),N(!0)},ee=async()=>{if(!l.razaoSocial){n.error("Razão Social é obrigatório");return}k?(await i.updateEntity(k.id,l),n.success("Fornecedor atualizado!")):(await i.createEntity(l),n.success("Fornecedor criado!")),N(!1)},se=async s=>{await i.updateEntity(s.id,{status:s.status==="Ativo"?"Inativo":"Ativo"}),n.success("Status alterado!")},ae=s=>{B(s),S(!0)},le=()=>{T&&(i.deleteEntity(T.id),n.success("Fornecedor excluído!")),S(!1),B(null)},V=s=>{if(i.selectedIds.length<2){n.info("Selecione dois ou mais itens");return}s==="edit"?n.info(`Editando ${i.selectedIds.length} fornecedores em massa...`):(i.bulkDelete(i.selectedIds),n.success(`${i.selectedIds.length} fornecedores excluídos!`))};return e.jsxs("div",{className:"border rounded-lg overflow-hidden bg-background",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4 border-b",children:[e.jsxs(u,{className:"shrink-0",onClick:Y,children:[e.jsx(Ie,{className:"h-4 w-4 mr-2"}),"Novo Fornecedor"]}),e.jsx("div",{className:"flex-1 max-w-md",children:e.jsxs("div",{className:"relative",children:[e.jsx(Ae,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(E,{placeholder:"Buscar por razão social, CNPJ, email...",value:f,onChange:s=>z(s.target.value),className:"pl-9"})]})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(je,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(u,{variant:"outline",className:"shrink-0",children:"Ações"})}),e.jsxs(ge,{children:[e.jsxs(D,{onClick:()=>n.info("Exportando..."),children:[e.jsx(ve,{className:"h-4 w-4 mr-2"}),"Exportar"]}),e.jsxs(D,{onClick:()=>n.info("Importando..."),children:[e.jsx(fe,{className:"h-4 w-4 mr-2"}),"Importar"]}),i.selectedIds.length<2?e.jsxs(xe,{disabledReason:"Selecione ao menos 2 itens",children:[e.jsx(de,{className:"h-4 w-4 mr-2"}),"Edição em massa"]}):e.jsxs(D,{onClick:()=>V("edit"),children:[e.jsx(de,{className:"h-4 w-4 mr-2"}),"Edição em massa"]}),i.selectedIds.length<2?e.jsxs(xe,{disabledReason:"Selecione ao menos 2 itens",className:"text-destructive",children:[e.jsx(oe,{className:"h-4 w-4 mr-2"}),"Exclusão em massa"]}):e.jsxs(D,{onClick:()=>V("delete"),className:"text-destructive",children:[e.jsx(oe,{className:"h-4 w-4 mr-2"}),"Exclusão em massa"]})]})]}),e.jsxs(Ne,{children:[e.jsx(Ce,{asChild:!0,children:e.jsxs(u,{variant:"outline",className:"shrink-0",children:[e.jsx(be,{className:"h-4 w-4 mr-2"}),"Filtrar",w>0&&e.jsx(q,{variant:"secondary",className:"ml-2 h-5 w-5 p-0 flex items-center justify-center",children:w})]})}),e.jsx(Se,{className:"w-80",align:"end",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"font-medium",children:"Filtros"}),w>0&&e.jsxs(u,{variant:"ghost",size:"sm",onClick:Q,className:"h-8 px-2 text-muted-foreground",children:[e.jsx(ye,{className:"h-4 w-4 mr-1"}),"Limpar"]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium",children:"Categoria"}),e.jsxs(j,{value:o||"all",onValueChange:s=>h(s==="all"?"":s),children:[e.jsx(p,{children:e.jsx(g,{placeholder:"Todas"})}),e.jsxs(v,{children:[e.jsx(t,{value:"all",children:"Todas"}),K.map(s=>e.jsx(t,{value:s,children:s},s))]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium",children:"Estado"}),e.jsxs(j,{value:r||"all",onValueChange:s=>C(s==="all"?"":s),children:[e.jsx(p,{children:e.jsx(g,{placeholder:"Todos"})}),e.jsxs(v,{children:[e.jsx(t,{value:"all",children:"Todos"}),H.map(s=>e.jsx(t,{value:s,children:s},s))]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium",children:"Status"}),e.jsxs(j,{value:m||"all",onValueChange:s=>b(s==="all"?"":s),children:[e.jsx(p,{children:e.jsx(g,{placeholder:"Todos"})}),e.jsxs(v,{children:[e.jsx(t,{value:"all",children:"Todos"}),e.jsx(t,{value:"Ativo",children:"Ativo"}),e.jsx(t,{value:"Inativo",children:"Inativo"})]})]})]})]})]})})]})]})]}),e.jsx(ce,{manager:i,columns:Pe,onEdit:Z,onToggleStatus:se,onDelete:ae,enableBulkActions:!0,hideActionBar:!0,resizeStorageKey:"crud-table-doc-fornecedores"}),e.jsx("div",{className:"border-t p-2",children:e.jsx(me,{manager:i})}),e.jsx($,{open:X,onOpenChange:N,children:e.jsxs(O,{className:"max-w-2xl",children:[e.jsx(L,{children:e.jsx(U,{children:k?"Editar Fornecedor":"Novo Fornecedor"})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"text-sm font-medium text-muted-foreground",children:"Dados da Empresa"}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"cnpj",children:"CNPJ"}),e.jsx(E,{id:"cnpj",value:l.cnpj,onChange:s=>c({...l,cnpj:s.target.value}),placeholder:"00.000.000/0001-00"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"razaoSocial",children:"Razão Social *"}),e.jsx(E,{id:"razaoSocial",value:l.razaoSocial,onChange:s=>c({...l,razaoSocial:s.target.value}),placeholder:"Nome da empresa"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"nomeFantasia",children:"Nome Fantasia"}),e.jsx(E,{id:"nomeFantasia",value:l.nomeFantasia,onChange:s=>c({...l,nomeFantasia:s.target.value}),placeholder:"Nome fantasia"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"text-sm font-medium text-muted-foreground",children:"Contato"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"email",children:"Email"}),e.jsx(E,{id:"email",type:"email",value:l.email,onChange:s=>c({...l,email:s.target.value}),placeholder:"contato@empresa.com"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"telefone",children:"Telefone"}),e.jsx(E,{id:"telefone",value:l.telefone,onChange:s=>c({...l,telefone:s.target.value}),placeholder:"(00) 00000-0000"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"text-sm font-medium text-muted-foreground",children:"Localização e Classificação"}),e.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"estado",children:"Estado"}),e.jsxs(j,{value:l.estado,onValueChange:s=>c({...l,estado:s,cidade:""}),children:[e.jsx(p,{children:e.jsx(g,{placeholder:"UF"})}),e.jsx(v,{children:H.map(s=>e.jsx(t,{value:s,children:s},s))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"cidade",children:"Cidade"}),e.jsxs(j,{value:l.cidade,onValueChange:s=>c({...l,cidade:s}),disabled:!l.estado,children:[e.jsx(p,{children:e.jsx(g,{placeholder:"Selecione"})}),e.jsx(v,{children:(Te[l.estado]||[]).map(s=>e.jsx(t,{value:s,children:s},s))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"categoria",children:"Categoria"}),e.jsxs(j,{value:l.categoria,onValueChange:s=>c({...l,categoria:s}),children:[e.jsx(p,{children:e.jsx(g,{placeholder:"Selecione"})}),e.jsx(v,{children:K.map(s=>e.jsx(t,{value:s,children:s},s))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"status",children:"Status"}),e.jsxs(j,{value:l.status,onValueChange:s=>c({...l,status:s}),children:[e.jsx(p,{children:e.jsx(g,{})}),e.jsxs(v,{children:[e.jsx(t,{value:"Ativo",children:"Ativo"}),e.jsx(t,{value:"Inativo",children:"Inativo"})]})]})]})]})]})]}),e.jsxs(J,{children:[e.jsx(u,{variant:"outline",onClick:()=>N(!1),children:"Cancelar"}),e.jsx(u,{onClick:ee,children:"Salvar"})]})]})}),e.jsx($,{open:_,onOpenChange:S,children:e.jsxs(O,{size:"sm",children:[e.jsx(L,{showSeparator:!0,children:e.jsx(U,{className:"text-center",children:"Confirmar exclusão"})}),e.jsxs("div",{className:"space-y-2 text-center",children:[e.jsxs("p",{children:['Você está prestes a excluir "',T?.nomeFantasia,'".']}),e.jsx("p",{className:"text-muted-foreground",children:"Esta ação não pode ser desfeita."})]}),e.jsxs(J,{className:"justify-center gap-2",children:[e.jsx(u,{variant:"outline",onClick:()=>S(!1),children:"Cancelar"}),e.jsx(u,{variant:"destructive",onClick:le,children:"Sim, excluir"})]})]})})]})}const We=`interface Fornecedor extends BaseEntity {
|
|
49
|
-
cnpj: string;
|
|
50
|
-
razaoSocial: string;
|
|
51
|
-
nomeFantasia: string;
|
|
52
|
-
email: string;
|
|
53
|
-
telefone: string;
|
|
54
|
-
cidade: string;
|
|
55
|
-
estado: string;
|
|
56
|
-
categoria: string;
|
|
57
|
-
status: 'Ativo' | 'Inativo';
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const fornecedorColumns: CrudColumn<Fornecedor>[] = [
|
|
61
|
-
{ key: 'cnpj', header: 'CNPJ', minWidth: 160 },
|
|
62
|
-
{ key: 'razaoSocial', header: 'Razão Social', sortable: true, minWidth: 200 },
|
|
63
|
-
{ key: 'nomeFantasia', header: 'Nome Fantasia', sortable: true, minWidth: 150 },
|
|
64
|
-
{ key: 'email', header: 'Email', minWidth: 180 },
|
|
65
|
-
{ key: 'cidade', header: 'Cidade', sortable: true, minWidth: 120 },
|
|
66
|
-
{ key: 'estado', header: 'UF', sortable: true, minWidth: 60 },
|
|
67
|
-
{ key: 'categoria', header: 'Categoria', sortable: true, minWidth: 120 },
|
|
68
|
-
{
|
|
69
|
-
key: 'status',
|
|
70
|
-
header: 'Status',
|
|
71
|
-
render: (item) => <Badge variant={item.status === 'Ativo' ? 'default' : 'secondary'}>{item.status}</Badge>,
|
|
72
|
-
},
|
|
73
|
-
];
|
|
74
|
-
|
|
75
|
-
function FornecedoresPage() {
|
|
76
|
-
const manager = useCrud<Fornecedor>({
|
|
77
|
-
tableName: 'fornecedores',
|
|
78
|
-
searchFields: ['razaoSocial', 'nomeFantasia', 'cnpj', 'email']
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
return (
|
|
82
|
-
<div>
|
|
83
|
-
<CrudTable
|
|
84
|
-
manager={manager}
|
|
85
|
-
columns={fornecedorColumns}
|
|
86
|
-
onEdit={(item) => openForm(item)}
|
|
87
|
-
onToggleStatus={(item) => toggleStatus(item)}
|
|
88
|
-
onDelete={(item) => confirmDelete(item)}
|
|
89
|
-
enableBulkActions
|
|
90
|
-
hideActionBar // Usa toolbar customizada
|
|
91
|
-
/>
|
|
92
|
-
<CrudPagination manager={manager} />
|
|
93
|
-
</div>
|
|
94
|
-
);
|
|
95
|
-
}`;function Me(){const o=he(we.slice(0,20),{searchFields:["item","tipo","fornecedor","detalhes"],pageSize:5});return e.jsxs("div",{className:"border rounded-lg overflow-hidden bg-background",children:[e.jsx(ce,{manager:o,columns:ke,onEdit:h=>n.info(`Editando: ${h.item}`),onToggleStatus:h=>n.info(`Toggle: ${h.item}`),onDelete:h=>n.info(`Excluindo: ${h.item}`),rowActionsVariant:"inline",hideActionBar:!0,resizeStorageKey:"crud-table-inline-doc"}),e.jsx("div",{className:"border-t p-2",children:e.jsx(me,{manager:o})})]})}const $e=`<CrudTable
|
|
96
|
-
manager={manager}
|
|
97
|
-
columns={columns}
|
|
98
|
-
onEdit={(item) => handleEdit(item)}
|
|
99
|
-
onToggleStatus={(item) => handleToggle(item)}
|
|
100
|
-
onDelete={(item) => handleDelete(item)}
|
|
101
|
-
rowActionsVariant="inline" // Ações aparecem on-hover
|
|
102
|
-
/>`;function qe(){return e.jsxs(De,{title:"CrudTable",description:"Componente de tabela CRUD completo com ordenação, seleção, resize de colunas, ações em massa e paginação integrada com useCrud.",tocItems:[{id:"exemplo-interativo",label:"Exemplo Interativo"},{id:"exemplo-inline-actions",label:"Ações Inline (Hover)"},{id:"exemplo-avancado",label:"Exemplo Avançado"},{id:"funcionalidades",label:"Funcionalidades"},{id:"props-principais",label:"Props Principais"},{id:"quando-usar",label:"Quando Usar"},{id:"notas",label:"Notas"}],children:[e.jsxs("section",{id:"exemplo-interativo",className:"space-y-4 scroll-mt-4",children:[e.jsx("h2",{className:"text-2xl font-semibold",children:"Exemplo Interativo"}),e.jsxs(re,{defaultValue:"preview",className:"w-full",children:[e.jsxs(te,{className:"mb-4",children:[e.jsxs(I,{value:"preview",className:"gap-2",children:[e.jsx(ie,{size:16}),"Preview"]}),e.jsxs(I,{value:"code",className:"gap-2",children:[e.jsx(ne,{size:16}),"Código"]})]}),e.jsx(A,{value:"preview",className:"mt-0",children:e.jsx(Be,{})}),e.jsx(A,{value:"code",className:"mt-0",children:e.jsx(y,{children:e.jsx(F,{className:"p-0",children:e.jsx("pre",{className:"bg-muted p-4 rounded-lg overflow-x-auto text-sm max-h-[500px]",children:e.jsx("code",{children:Ve})})})})})]})]}),e.jsxs("section",{id:"exemplo-inline-actions",className:"space-y-4 scroll-mt-4",children:[e.jsx("h2",{className:"text-2xl font-semibold",children:"Ações Inline (Hover)"}),e.jsxs("p",{className:"text-muted-foreground",children:["Com ",e.jsx("code",{children:'rowActionsVariant="inline"'}),", as ações aparecem como ícones diretamente na linha ao passar o mouse, similar ao Google Drive. O menu de contexto (clique-direito) continua disponível como fallback."]}),e.jsxs(re,{defaultValue:"preview",className:"w-full",children:[e.jsxs(te,{className:"mb-4",children:[e.jsxs(I,{value:"preview",className:"gap-2",children:[e.jsx(ie,{size:16}),"Preview"]}),e.jsxs(I,{value:"code",className:"gap-2",children:[e.jsx(ne,{size:16}),"Código"]})]}),e.jsx(A,{value:"preview",className:"mt-0",children:e.jsx(Me,{})}),e.jsx(A,{value:"code",className:"mt-0",children:e.jsx(y,{children:e.jsx(F,{className:"p-0",children:e.jsx("pre",{className:"bg-muted p-4 rounded-lg overflow-x-auto text-sm max-h-[500px]",children:e.jsx("code",{children:$e})})})})})]})]}),e.jsxs("section",{id:"exemplo-avancado",className:"space-y-4 scroll-mt-4",children:[e.jsx("h2",{className:"text-2xl font-semibold",children:"Exemplo Avançado: Fornecedores"}),e.jsx("p",{className:"text-muted-foreground",children:"Exemplo de CRUD com muitos campos (CNPJ, Razão Social, Email, Telefone, Cidade, Estado, Categoria), demonstrando tabelas complexas com múltiplos filtros e formulários extensos."}),e.jsxs(re,{defaultValue:"preview",className:"w-full",children:[e.jsxs(te,{className:"mb-4",children:[e.jsxs(I,{value:"preview",className:"gap-2",children:[e.jsx(ie,{size:16}),"Preview"]}),e.jsxs(I,{value:"code",className:"gap-2",children:[e.jsx(ne,{size:16}),"Código"]})]}),e.jsx(A,{value:"preview",className:"mt-0",children:e.jsx(Re,{})}),e.jsx(A,{value:"code",className:"mt-0",children:e.jsx(y,{children:e.jsx(F,{className:"p-0",children:e.jsx("pre",{className:"bg-muted p-4 rounded-lg overflow-x-auto text-sm max-h-[500px]",children:e.jsx("code",{children:We})})})})})]})]}),e.jsxs(y,{id:"gerenciamento-colunas",className:"scroll-mt-4",children:[e.jsx(W,{children:e.jsx(M,{children:"Gerenciamento de Colunas"})}),e.jsxs(F,{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Ative ",e.jsx("code",{children:"enableColumnManager"})," para permitir ocultar, reordenar e agrupar colunas. O ícone de colunas aparece na zona direita do action bar."]}),e.jsxs("ul",{className:"list-disc list-inside space-y-2 text-sm text-muted-foreground",children:[e.jsxs("li",{children:[e.jsx("strong",{children:"Ocultar/exibir:"})," Checkbox no popover para cada coluna. Colunas com ",e.jsx("code",{children:"hideable: false"})," ficam sempre visíveis."]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Reordenar:"})," Drag-and-drop no popover (arrastar pelo ícone ☰)."]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Agrupar:"})," Clique no ícone de grupo em colunas com ",e.jsx("code",{children:"groupable: true"}),". Os dados são agrupados com linhas colapsáveis."]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Persistência:"})," Use ",e.jsx("code",{children:"columnManagerStorageKey"})," para salvar estado em localStorage."]})]}),e.jsx("pre",{className:"bg-muted p-4 rounded-lg overflow-x-auto text-sm",children:e.jsx("code",{children:`const columns: CrudColumn<Item>[] = [
|
|
103
|
-
{ key: 'nome', header: 'Nome', hideable: false }, // sempre visível
|
|
104
|
-
{ key: 'tipo', header: 'Tipo', groupable: true }, // pode agrupar
|
|
105
|
-
{ key: 'status', header: 'Status', groupable: true },
|
|
106
|
-
];
|
|
107
|
-
|
|
108
|
-
<CrudTable
|
|
109
|
-
manager={manager}
|
|
110
|
-
columns={columns}
|
|
111
|
-
enableColumnManager
|
|
112
|
-
columnManagerStorageKey="minha-tabela"
|
|
113
|
-
/>`})})]})]}),e.jsxs(y,{id:"funcionalidades",className:"scroll-mt-4",children:[e.jsx(W,{children:e.jsx(M,{children:"Funcionalidades Incluídas"})}),e.jsx(F,{children:e.jsxs("ul",{className:"list-disc list-inside space-y-2 text-sm text-muted-foreground",children:[e.jsxs("li",{children:[e.jsx("strong",{children:"Ordenação:"})," Clique nos headers das colunas para ordenar"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Resize:"})," Arraste as bordas das colunas para redimensionar"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Seleção em massa:"})," Checkbox para selecionar múltiplos itens"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"CRUD completo:"})," Criar, editar, visualizar e excluir"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Paginação:"})," Navegação entre páginas e controle de itens por página"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Ações por linha:"})," Menu de contexto com ações rápidas"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Gerenciamento de colunas:"})," Ocultar, reordenar e agrupar via popover"]})]})})]}),e.jsxs(y,{id:"props-principais",className:"scroll-mt-4",children:[e.jsx(W,{children:e.jsx(M,{children:"Props Principais"})}),e.jsx(F,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",children:[e.jsx("th",{className:"text-left p-2 font-medium",children:"Prop"}),e.jsx("th",{className:"text-left p-2 font-medium",children:"Tipo"}),e.jsx("th",{className:"text-left p-2 font-medium",children:"Descrição"})]})}),e.jsxs("tbody",{children:[e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"manager"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"CrudManager<T>"}),e.jsx("td",{className:"p-2",children:"Hook useCrud com estado e operações"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"columns"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"CrudColumn<T>[]"}),e.jsx("td",{className:"p-2",children:"Definição das colunas da tabela"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"onEdit"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"(item: T) => void"}),e.jsx("td",{className:"p-2",children:"Callback ao clicar em editar"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"onDelete"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"(item: T) => void"}),e.jsx("td",{className:"p-2",children:"Callback ao clicar em excluir"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"onToggleStatus"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"(item: T) => void"}),e.jsx("td",{className:"p-2",children:"Callback para alternar status ativo/inativo"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"enableColumnResize"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"boolean"}),e.jsx("td",{className:"p-2",children:"Habilita redimensionamento de colunas (padrão: true)"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"enableBulkActions"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"boolean"}),e.jsx("td",{className:"p-2",children:"Habilita seleção e ações em massa"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"rowActionsVariant"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"'dropdown' | 'inline'"}),e.jsx("td",{className:"p-2",children:"Variante de ações por linha: dropdown (padrão) ou inline on-hover (estilo Google Drive)"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"hideActionBar"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"boolean"}),e.jsx("td",{className:"p-2",children:"Oculta a barra de ações interna (para usar toolbar customizada)"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"enableColumnManager"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"boolean"}),e.jsx("td",{className:"p-2",children:"Habilita popover de gerenciamento de colunas (ocultar, reordenar, agrupar)"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"columnManagerStorageKey"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"string"}),e.jsx("td",{className:"p-2",children:"Chave para persistir configuração de colunas em localStorage"})]})]})]})})})]}),e.jsxs(y,{id:"quando-usar",className:"scroll-mt-4",children:[e.jsx(W,{children:e.jsx(M,{children:"Quando Usar"})}),e.jsxs(F,{children:[e.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:["Use o ",e.jsx("code",{children:"CrudTable"})," quando precisar de uma tabela completa com todas as funcionalidades padrão. Para casos mais específicos, considere:"]}),e.jsxs("ul",{className:"list-disc list-inside space-y-1 text-sm text-muted-foreground",children:[e.jsxs("li",{children:[e.jsx("code",{children:"createCrudPage"})," - Para gerar página completa automaticamente"]}),e.jsxs("li",{children:[e.jsx("code",{children:"Primitives"})," - Para UI totalmente customizada"]})]})]})]}),e.jsxs(y,{id:"notas",className:"scroll-mt-4",children:[e.jsx(W,{children:e.jsx(M,{children:"Notas"})}),e.jsx(F,{children:e.jsxs("ul",{className:"list-disc list-inside space-y-2 text-sm text-muted-foreground",children:[e.jsxs("li",{children:["Use junto com ",e.jsx("code",{children:"useCrud"})," ou ",e.jsx("code",{children:"createSimpleService"})]}),e.jsxs("li",{children:["Colunas com ",e.jsx("code",{children:"sortable: true"})," permitem ordenação"]}),e.jsxs("li",{children:["Use ",e.jsx("code",{children:"render: (item) => ..."})," para formatação customizada"]}),e.jsxs("li",{children:["Combine com ",e.jsx("code",{children:"CrudPagination"})," para paginação"]})]})})]})]})}export{qe as CrudTableDoc};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import{j as t,J as h,o as g,M as D,K as y,r as F,x as A,aU as M,P as $,y as I,N as L,O as R,Q as U,R as P,V as z,B as Q,a1 as _,m as B,Y as w}from"./index-DkiftrvI.js";import{C as K}from"./ComponentDocTemplate-CQbBhfvZ.js";import{R as S,a as q}from"./radio-group-BHAaNGsm.js";import"./ExampleCard-DuLrb3t-.js";var d=(e=>(e[e.readOnlyText=1]="readOnlyText",e[e.text=2]="text",e[e.date=3]="date",e[e.time=4]="time",e[e.url=5]="url",e[e.number=6]="number",e[e.singleSelection=7]="singleSelection",e[e.multiSelection=8]="multiSelection",e[e.questions=9]="questions",e))(d||{}),v=(e=>(e[e.dropdown=1]="dropdown",e[e.buttons=2]="buttons",e[e.radio=3]="radio",e[e.checkbox=4]="checkbox",e))(v||{}),b=(e=>(e[e.custom=1]="custom",e[e.users=2]="users",e[e.usersLists=3]="usersLists",e))(b||{});function N(e){switch(e.type){case 2:return e.textValue;case 6:return e.numberValue;case 3:return e.dateValue;case 4:return e.timeValue;case 5:case 7:case 8:return e.itemsValue;case 9:return e.questionsValue;case 1:return e.textValue;default:return null}}function T(e,r){if(!r)return!0;const n=N(e)!=null&&N(e)!==""&&!(Array.isArray(N(e))&&N(e).length===0);return e.isActive!==!1||n}function H(e){return e.filter(r=>r.type!==1).map(r=>({formFieldAssociationId:r.id,textValue:r.type===2?r.textValue:void 0,numberValue:r.type===6?r.numberValue:void 0,dateValue:r.type===3?r.dateValue:void 0,timeValue:r.type===4?r.timeValue:void 0,itemsValue:[5,7,8].includes(r.type)?r.itemsValue:void 0,questionsValue:r.type===9?r.questionsValue:void 0}))}function G(e){const r=[];return e.forEach(n=>{if(!n.required||n.readOnly||n.type===1)return;const a=N(n);if((a==null||a===""||Array.isArray(a)&&a.length===0)&&r.push(n.id),n.type===6&&a!=null){const c=n.config;c?.min!=null&&a<c.min&&r.push(n.id),c?.max!=null&&a>c.max&&r.push(n.id)}}),{valid:r.length===0,invalidFields:[...new Set(r)]}}function J({field:e}){return t.jsxs("div",{className:"space-y-1",children:[e.name&&t.jsx("p",{className:"text-sm font-medium text-foreground",children:e.name}),e.description&&t.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:e.description}),e.textValue&&t.jsx("p",{className:"text-sm text-muted-foreground italic",children:e.textValue})]})}function W({field:e,readOnly:r,onChange:n}){const u=e.config?.multiline??!1,c=r||e.readOnly,i=o=>{n?.({...e,textValue:o})};return t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(h,{className:g(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&t.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),u?t.jsx(D,{value:e.textValue||"",onChange:o=>i(o.target.value),placeholder:e.placeholder,disabled:c,rows:4}):t.jsx(y,{value:e.textValue||"",onChange:o=>i(o.target.value),placeholder:e.placeholder,disabled:c})]})}function X({field:e,readOnly:r,onChange:n}){const a=r||e.readOnly,u=e.dateValue?typeof e.dateValue=="string"?e.dateValue.substring(0,10):new Date(e.dateValue).toISOString().substring(0,10):"",c=i=>{n?.({...e,dateValue:i||void 0})};return t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(h,{className:g(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&t.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),t.jsx(y,{type:"date",value:u,onChange:i=>c(i.target.value),placeholder:e.placeholder,disabled:a})]})}function Y({field:e,readOnly:r,onChange:n}){const a=r||e.readOnly,u=i=>{if(i==null)return"";const o=Math.floor(i/60),x=i%60;return`${o.toString().padStart(2,"0")}:${x.toString().padStart(2,"0")}`},c=i=>{if(!i)return;const[o,x]=i.split(":").map(Number);return o*60+x};return t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(h,{className:g(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&t.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),t.jsx(y,{type:"time",value:u(e.timeValue),onChange:i=>n?.({...e,timeValue:c(i.target.value)}),placeholder:e.placeholder,disabled:a})]})}function Z({field:e,readOnly:r,onChange:n}){const u=e.config?.multiple??!1,c=r||e.readOnly,[i,o]=F.useState(""),x=e.itemsValue||[],j=l=>{n?.({...e,itemsValue:l?[{value:l,text:l}]:[]})},s=()=>{if(!i.trim())return;const l={value:crypto.randomUUID(),text:i.trim()};n?.({...e,itemsValue:[...x,l]}),o("")},m=l=>{const p=x.filter((f,V)=>V!==l);n?.({...e,itemsValue:p})};if(!u){const l=x[0]?.text||"";return t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(h,{className:g(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&t.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(y,{type:"url",value:l,onChange:p=>j(p.target.value),placeholder:e.placeholder||"https://",disabled:c}),l&&t.jsx(A,{variant:"outline",size:"icon",asChild:!0,className:"flex-shrink-0",children:t.jsx("a",{href:l,target:"_blank",rel:"noopener noreferrer",children:t.jsx(M,{className:"h-4 w-4"})})})]})]})}return t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(h,{className:g(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&t.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),!c&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(y,{type:"url",value:i,onChange:l=>o(l.target.value),placeholder:e.placeholder||"https://",onKeyDown:l=>l.key==="Enter"&&(l.preventDefault(),s())}),t.jsx(A,{variant:"outline",size:"icon",onClick:s,disabled:!i.trim(),className:"flex-shrink-0",children:t.jsx($,{className:"h-4 w-4"})})]}),x.length>0&&t.jsx("div",{className:"space-y-1",children:x.map((l,p)=>t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx("a",{href:l.text,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline truncate flex-1",children:l.text}),!c&&t.jsx(A,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>m(p),children:t.jsx(I,{className:"h-3 w-3"})})]},l.value))})]})}function E({field:e,readOnly:r,onChange:n}){const a=e.config,u=r||e.readOnly,c=o=>{if(o===""){n?.({...e,numberValue:void 0});return}const x=parseFloat(o);isNaN(x)||n?.({...e,numberValue:x})},i=a?.decimals!=null&&a.decimals>0?(1/Math.pow(10,a.decimals)).toString():"1";return t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(h,{className:g(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&t.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),t.jsx(y,{type:"number",value:e.numberValue??"",onChange:o=>c(o.target.value),placeholder:e.placeholder,disabled:u,min:a?.min,max:a?.max,step:i}),a?.min!=null&&a?.max!=null&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Min: ",a.min," | Max: ",a.max]})]})}function ee({field:e,readOnly:r,onChange:n}){const a=e.config,u=r||e.readOnly,c=a?.viewMode??v.dropdown,i=a?.data?.filter(s=>s.isActive!==!1||e.itemsValue?.some(m=>m.value===s.value))||[],o=e.itemsValue?.[0]?.value||"",x=s=>{const m=i.find(p=>p.value===s);if(!m)return;const l={value:m.value,text:m.text,isActive:m.isActive};n?.({...e,itemsValue:[l]})},j=()=>{n?.({...e,itemsValue:[]})};return t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(h,{className:g(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&t.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),c===v.dropdown&&t.jsxs(L,{value:o,onValueChange:x,disabled:u,children:[t.jsx(R,{children:t.jsx(U,{placeholder:e.placeholder||"Selecione..."})}),t.jsx(P,{children:i.map(s=>t.jsxs(z,{value:s.value,children:[s.text,s.isActive===!1&&t.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(inativo)"})]},s.value))})]}),(c===v.radio||c===v.buttons)&&t.jsx(S,{value:o,onValueChange:x,disabled:u,className:g(c===v.buttons?"flex flex-wrap gap-2":"space-y-2"),children:i.map(s=>t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(q,{value:s.value,id:`${e.id}-${s.value}`}),t.jsxs(h,{htmlFor:`${e.id}-${s.value}`,className:"text-sm font-normal cursor-pointer",children:[s.text,s.isActive===!1&&t.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(inativo)"})]})]},s.value))}),!u&&o&&!e.required&&t.jsx("button",{type:"button",onClick:j,className:"text-xs text-muted-foreground hover:text-foreground underline",children:"Limpar seleção"})]})}function te({field:e,readOnly:r,onChange:n}){const a=e.config,u=r||e.readOnly,c=a?.viewMode??v.dropdown,i=a?.data?.filter(s=>s.isActive!==!1||e.itemsValue?.some(m=>m.value===s.value))||[],o=new Set(e.itemsValue?.map(s=>s.value)||[]),x=s=>{const m=e.itemsValue||[],p=m.some(f=>f.value===s.value)?m.filter(f=>f.value!==s.value):[...m,{value:s.value,text:s.text,isActive:s.isActive}];n?.({...e,itemsValue:p})},j=s=>{const m=(e.itemsValue||[]).filter(l=>l.value!==s);n?.({...e,itemsValue:m})};return t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(h,{className:g(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&t.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),(e.itemsValue?.length??0)>0&&t.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.itemsValue.map(s=>t.jsxs(Q,{variant:"secondary",className:"gap-1 pr-1",children:[t.jsx("span",{className:"text-xs",children:s.text}),!u&&t.jsx("button",{type:"button",onClick:()=>j(s.value),className:"rounded-full p-0.5 hover:bg-muted-foreground/20",children:t.jsx(_,{className:"h-3 w-3"})})]},s.value))}),!u&&t.jsx("div",{className:g(c===v.checkbox?"space-y-2":"grid grid-cols-2 gap-2 border rounded-md p-3 max-h-48 overflow-y-auto"),children:i.map(s=>t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(B,{id:`${e.id}-${s.value}`,checked:o.has(s.value),onCheckedChange:()=>x(s),disabled:u}),t.jsxs(h,{htmlFor:`${e.id}-${s.value}`,className:"text-sm font-normal cursor-pointer",children:[s.text,s.isActive===!1&&t.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(inativo)"})]})]},s.value))})]})}function se({field:e,readOnly:r,onChange:n}){const a=e.config,u=r||e.readOnly,c=a?.questions||[],i=a?.options||[],o=e.questionsValue||[],x=s=>o.find(m=>m.questionValue===s)?.optionValue,j=(s,m,l,p)=>{const f={questionValue:s,questionText:m,optionValue:l,optionText:p},V=o.filter(k=>k.questionValue!==s);V.push(f),n?.({...e,questionsValue:V})};return c.length===0||i.length===0?t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(h,{children:e.name}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Nenhuma questão configurada"})]}):t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(h,{className:g(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&t.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),t.jsx("div",{className:"border rounded-md overflow-x-auto",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b bg-muted/50",children:[t.jsx("th",{className:"text-left p-2 font-medium min-w-[150px]",children:"Pergunta"}),i.map(s=>t.jsx("th",{className:"text-center p-2 font-medium min-w-[80px]",children:s.text},s.value))]})}),t.jsx("tbody",{children:c.map((s,m)=>t.jsxs("tr",{className:g(m<c.length-1&&"border-b"),children:[t.jsx("td",{className:"p-2 text-muted-foreground",children:s.text}),i.map(l=>t.jsx("td",{className:"text-center p-2",children:t.jsx(S,{value:x(s.value)||"",onValueChange:p=>j(s.value,s.text,p,l.text),disabled:u,className:"flex justify-center",children:t.jsx(q,{value:l.value,id:`${e.id}-${s.value}-${l.value}`})})},l.value))]},s.value))})]})})]})}function O({fields:e,readOnly:r=!1,hideInactiveWithoutValue:n=!1,onChange:a,onFieldChange:u}){const c=F.useCallback(o=>{if(u?.(o),a){const x=e.map(j=>j.id===o.id?o:j);a(x)}},[e,a,u]),i=e.filter(o=>T(o,n));return i.length===0?null:t.jsx("div",{className:"space-y-4",children:i.map(o=>t.jsx(ae,{field:o,readOnly:r,onChange:c},o.id))})}function ae({field:e,readOnly:r,onChange:n}){const a={field:e,readOnly:r,onChange:n};switch(e.type){case d.readOnlyText:return t.jsx(J,{...a});case d.text:return t.jsx(W,{...a});case d.date:return t.jsx(X,{...a});case d.time:return t.jsx(Y,{...a});case d.url:return t.jsx(Z,{...a});case d.number:return t.jsx(E,{...a});case d.singleSelection:return t.jsx(ee,{...a});case d.multiSelection:return t.jsx(te,{...a});case d.questions:return t.jsx(se,{...a});default:return null}}const re=[{id:"f-readonly",type:d.readOnlyText,name:"Instruções",description:"Preencha os campos abaixo com as informações do formulário customizado.",textValue:"Este é um campo somente leitura para orientações.",isActive:!0},{id:"f-text",type:d.text,name:"Nome do Responsável",required:!0,placeholder:"Digite o nome completo",config:{multiline:!1},isActive:!0},{id:"f-textarea",type:d.text,name:"Observações",placeholder:"Descreva as observações necessárias...",config:{multiline:!0},isActive:!0},{id:"f-date",type:d.date,name:"Data de Vencimento",required:!0,isActive:!0},{id:"f-time",type:d.time,name:"Horário da Inspeção",isActive:!0},{id:"f-url",type:d.url,name:"Link do Documento",placeholder:"https://exemplo.com/doc",config:{multiple:!1},isActive:!0},{id:"f-number",type:d.number,name:"Quantidade",required:!0,config:{decimals:2,min:0,max:1e3},isActive:!0},{id:"f-single",type:d.singleSelection,name:"Prioridade",required:!0,config:{viewMode:v.dropdown,dataSource:b.custom,data:[{value:"low",text:"Baixa",isActive:!0},{value:"medium",text:"Média",isActive:!0},{value:"high",text:"Alta",isActive:!0},{value:"critical",text:"Crítica",isActive:!0}]},isActive:!0},{id:"f-single-radio",type:d.singleSelection,name:"Tipo de Avaliação",config:{viewMode:v.radio,dataSource:b.custom,data:[{value:"internal",text:"Auditoria Interna",isActive:!0},{value:"external",text:"Auditoria Externa",isActive:!0},{value:"supplier",text:"Auditoria de Fornecedor",isActive:!0}]},isActive:!0},{id:"f-multi",type:d.multiSelection,name:"Áreas Envolvidas",config:{viewMode:v.checkbox,dataSource:b.custom,data:[{value:"quality",text:"Qualidade",isActive:!0},{value:"production",text:"Produção",isActive:!0},{value:"engineering",text:"Engenharia",isActive:!0},{value:"logistics",text:"Logística",isActive:!0},{value:"rh",text:"Recursos Humanos",isActive:!0}]},isActive:!0},{id:"f-questions",type:d.questions,name:"Avaliação de Conformidade",config:{viewMode:v.buttons,questions:[{value:"q1",text:"O processo segue o procedimento padrão?"},{value:"q2",text:"Os registros estão atualizados?"},{value:"q3",text:"Os indicadores estão dentro da meta?"}],options:[{value:"ok",text:"Conforme"},{value:"nok",text:"Não Conforme"},{value:"na",text:"N/A"}]},isActive:!0}];function C(){const[e,r]=F.useState(re),n=()=>{const a=G(e);if(a.valid){const u=H(e);w.success(`Formulário válido! ${u.length} campos com valores.`)}else w.error(`${a.invalidFields.length} campo(s) inválido(s)`)};return t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"border rounded-lg p-4 max-h-[600px] overflow-y-auto",children:t.jsx(O,{fields:e,onChange:r,onFieldChange:a=>console.log("Campo alterado:",a.name,a)})}),t.jsx("div",{className:"flex gap-2",children:t.jsx("button",{type:"button",onClick:n,className:"px-4 py-2 text-sm bg-primary text-primary-foreground rounded-md hover:bg-primary/90",children:"Validar Formulário"})})]})}function ne(){const e=[{id:"ro-1",type:d.text,name:"Responsável",textValue:"Maria Silva",isActive:!0},{id:"ro-2",type:d.date,name:"Data",dateValue:"2026-03-15",isActive:!0},{id:"ro-3",type:d.singleSelection,name:"Status",itemsValue:[{value:"done",text:"Concluído"}],config:{viewMode:v.dropdown,dataSource:b.custom,data:[{value:"done",text:"Concluído",isActive:!0}]},isActive:!0}];return t.jsx("div",{className:"border rounded-lg p-4",children:t.jsx(O,{fields:e,readOnly:!0})})}function ue(){return t.jsx(K,{title:"Custom Form Fields",description:"Componente container que renderiza campos de formulário dinâmicos baseados em configuração. Suporta 9 tipos de campo: Texto Somente Leitura, Texto, Data, Hora, URL, Numérico, Seleção Única, Seleção Múltipla e Questões. Portado de FlcCustomFormFieldsComponent (flc-custom-form-fields).",component:t.jsx(C,{}),usage:`import { CustomFormFields, ECustomFormFieldType, validateFields } from "forlogic-core"
|
|
2
|
-
import type { FieldAssociation } from "forlogic-core"
|
|
3
|
-
|
|
4
|
-
const fields: FieldAssociation[] = [
|
|
5
|
-
{
|
|
6
|
-
id: 'f1',
|
|
7
|
-
type: ECustomFormFieldType.text,
|
|
8
|
-
name: 'Nome',
|
|
9
|
-
required: true,
|
|
10
|
-
config: { multiline: false },
|
|
11
|
-
isActive: true,
|
|
12
|
-
},
|
|
13
|
-
// ...mais campos
|
|
14
|
-
];
|
|
15
|
-
|
|
16
|
-
const [formFields, setFormFields] = useState(fields);
|
|
17
|
-
|
|
18
|
-
<CustomFormFields
|
|
19
|
-
fields={formFields}
|
|
20
|
-
onChange={setFormFields}
|
|
21
|
-
onFieldChange={(field) => console.log('Changed:', field)}
|
|
22
|
-
/>`,examples:[{title:"Formulário Completo (todos os tipos)",description:"Exemplo com todos os 9 tipos de campo, incluindo validação.",preview:t.jsx(C,{}),code:`const [fields, setFields] = useState(MOCK_FIELDS);
|
|
23
|
-
|
|
24
|
-
<CustomFormFields
|
|
25
|
-
fields={fields}
|
|
26
|
-
onChange={setFields}
|
|
27
|
-
/>
|
|
28
|
-
|
|
29
|
-
// Validar
|
|
30
|
-
const { valid, invalidFields } = validateFields(fields);
|
|
31
|
-
|
|
32
|
-
// Extrair valores para salvar
|
|
33
|
-
const values = getFormFieldValues(fields);`},{title:"Modo Somente Leitura",description:"Campos exibidos sem edição, com valores pré-preenchidos.",preview:t.jsx(ne,{}),code:"<CustomFormFields fields={prefilledFields} readOnly />"}],props:[{name:"fields",type:"FieldAssociation[]",description:"Array de definições de campo com tipo, config e valores."},{name:"readOnly",type:"boolean",default:"false",description:"Desabilita edição em todos os campos."},{name:"hideInactiveWithoutValue",type:"boolean",default:"false",description:"Oculta campos inativos que não possuem valor preenchido."},{name:"onChange",type:"(fields) => void",description:"Callback quando qualquer campo muda. Recebe o array completo atualizado."},{name:"onFieldChange",type:"(field) => void",description:"Callback quando um campo individual muda."},{name:"users",type:"Array<{id, name, ...}>",description:"Lista de usuários para campos com dataSource = users."}],notes:["Portado de FlcCustomFormFieldsComponent (flc-custom-form-fields) Angular.","Tipos de campo: readOnlyText (1), text (2), date (3), time (4), url (5), number (6), singleSelection (7), multiSelection (8), questions (9).","Use validateFields() para validar campos obrigatórios e restrições numéricas.","Use getFormFieldValues() para extrair valores no formato de envio ao backend.","Use setFormFieldValues() para aplicar valores salvos a uma lista de campos.","Campos de seleção suportam dataSource custom (dados estáticos) e users (lista de usuários do sistema)."]})}export{ue as CustomFormFieldsDoc};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./index-DkiftrvI.js";import{C as s}from"./ComponentDocTemplate-CQbBhfvZ.js";import"./ExampleCard-DuLrb3t-.js";function r(){return e.jsxs("div",{className:"border border-border rounded-lg overflow-hidden bg-card max-w-lg w-full",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-border",children:[e.jsx("span",{className:"text-sm font-semibold text-foreground",children:"Novo Dashboard"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"px-3 py-1.5 text-xs border border-input rounded-md cursor-pointer hover:bg-accent",children:"Cancelar"}),e.jsx("span",{className:"px-3 py-1.5 text-xs bg-primary text-primary-foreground rounded-md font-medium",children:"✓ Salvar"})]})]}),e.jsxs("div",{className:"flex border-b border-border",children:[e.jsx("span",{className:"px-4 py-2 text-xs font-medium border-b-2 border-primary text-foreground",children:"Geral"}),e.jsx("span",{className:"px-4 py-2 text-xs text-muted-foreground",children:"Compartilhamento"})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-foreground",children:"Título *"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("span",{className:"px-2 py-0.5 text-[10px] rounded-md bg-primary text-primary-foreground",children:"PT-BR"}),e.jsx("span",{className:"px-2 py-0.5 text-[10px] rounded-md border border-input text-muted-foreground",children:"EN-US"}),e.jsx("span",{className:"px-2 py-0.5 text-[10px] rounded-md border border-input text-muted-foreground",children:"ES-ES"})]})]}),e.jsx("div",{className:"h-9 rounded-md border border-input bg-background flex items-center px-3 text-xs text-muted-foreground",children:"Indicadores de Qualidade"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Intervalo de atualização"}),e.jsx("div",{className:"h-9 rounded-md border border-input bg-background flex items-center px-3 text-xs text-foreground",children:"5 minutos ▾"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Situação"}),e.jsxs("div",{className:"flex items-center gap-2 h-9",children:[e.jsx("div",{className:"relative inline-flex h-5 w-9 items-center rounded-full bg-primary",children:e.jsx("span",{className:"inline-block h-3.5 w-3.5 rounded-full bg-white translate-x-4"})}),e.jsx("span",{className:"text-xs text-foreground",children:"Ativo"})]})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Tipo de visualização"}),e.jsx("div",{className:"h-9 rounded-md border border-input bg-background flex items-center px-3 text-xs text-foreground",children:"Página normal ▾"})]})})]})]})}function o(){return e.jsxs("div",{className:"border border-border rounded-lg overflow-hidden bg-card max-w-lg w-full",children:[e.jsxs("div",{className:"flex border-b border-border",children:[e.jsx("span",{className:"px-4 py-2 text-xs text-muted-foreground",children:"Geral"}),e.jsx("span",{className:"px-4 py-2 text-xs font-medium border-b-2 border-primary text-foreground",children:"Compartilhamento"})]}),e.jsx("div",{className:"p-4 space-y-3",children:[{label:"Não compartilhado",desc:"Somente o responsável terá acesso",active:!1},{label:"Todos os colaboradores",desc:"Todos os colaboradores terão acesso",active:!0},{label:"Grupos, locais e colaboradores",desc:"Selecione específicos",active:!1}].map(a=>e.jsxs("div",{className:`flex items-start gap-2 p-2.5 rounded-lg border ${a.active?"border-primary bg-primary/5":"border-border"}`,children:[e.jsx("div",{className:`mt-0.5 h-4 w-4 rounded-full border-2 flex items-center justify-center ${a.active?"border-primary":"border-muted-foreground"}`,children:a.active&&e.jsx("div",{className:"h-2 w-2 rounded-full bg-primary"})}),e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-medium text-foreground",children:a.label}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a.desc})]})]},a.label))})]})}function t(){return e.jsx(s,{title:"DashboardForm",description:"Formulário de criação/edição de dashboards com títulos multilíngue (PT-BR, EN-US, ES-ES), intervalo de atualização, tipo de visualização (Normal/Carousel), switch de situação e aba de compartilhamento com três modos.",component:e.jsx(r,{}),usage:`import { DashboardForm, type DashboardFormValues } from 'forlogic-core';
|
|
2
|
-
|
|
3
|
-
// Criação
|
|
4
|
-
<DashboardForm
|
|
5
|
-
onSave={(values: DashboardFormValues) => {
|
|
6
|
-
// values: { titlePtBr, titleEnUs, titleEsEs, isActive,
|
|
7
|
-
// idUpdateTime, idViewType, idPageTime,
|
|
8
|
-
// idShare, groups?, places?, collaborators? }
|
|
9
|
-
createDashboard(values);
|
|
10
|
-
}}
|
|
11
|
-
onCancel={() => navigate('/dashboards')}
|
|
12
|
-
/>
|
|
13
|
-
|
|
14
|
-
// Edição
|
|
15
|
-
<DashboardForm
|
|
16
|
-
dashboard={existingDashboard}
|
|
17
|
-
users={usersList}
|
|
18
|
-
groups={groupsList}
|
|
19
|
-
places={placesList}
|
|
20
|
-
collaborators={collaboratorsList}
|
|
21
|
-
isSaving={mutation.isPending}
|
|
22
|
-
onSave={(values) => updateDashboard(dashboard.id, values)}
|
|
23
|
-
onCancel={() => goBack()}
|
|
24
|
-
/>`,examples:[{title:"Aba Geral",description:"Contém toggles de idioma, inputs de título com contagem de caracteres (máx 200), seletor de responsável, intervalo de atualização, tipo de visualização (Normal/Carousel), tempo de página (quando Carousel) e switch de situação.",preview:e.jsx(r,{}),code:`<DashboardForm
|
|
25
|
-
dashboard={null} // null = criação
|
|
26
|
-
users={[
|
|
27
|
-
{ id: 'u1', name: 'João Silva' },
|
|
28
|
-
{ id: 'u2', name: 'Maria Santos' },
|
|
29
|
-
]}
|
|
30
|
-
onSave={(values) => {
|
|
31
|
-
console.log(values);
|
|
32
|
-
// { titlePtBr: '...', titleEnUs: '', titleEsEs: '',
|
|
33
|
-
// isActive: true, idUpdateTime: 2, idViewType: 1,
|
|
34
|
-
// idPageTime: null, idShare: 1 }
|
|
35
|
-
}}
|
|
36
|
-
/>`},{title:"Aba Compartilhamento",description:"Três modos de compartilhamento: Não compartilhado, Todos os colaboradores, ou Grupos/Locais/Colaboradores específicos. No terceiro modo, listas de seleção aparecem.",preview:e.jsx(o,{}),code:`<DashboardForm
|
|
37
|
-
dashboard={existingDashboard}
|
|
38
|
-
initialTab={DashboardFormTab.Share}
|
|
39
|
-
groups={groupsList}
|
|
40
|
-
places={placesList}
|
|
41
|
-
collaborators={collaboratorsList}
|
|
42
|
-
onSave={(values) => {
|
|
43
|
-
// values.idShare = DashboardShareType.SharedWithUsersGroupsPlacesCollaborators
|
|
44
|
-
// values.groups = ['g1', 'g2']
|
|
45
|
-
// values.places = ['p1']
|
|
46
|
-
// values.collaborators = ['c1', 'c2', 'c3']
|
|
47
|
-
updateDashboard(dashboard.id, values);
|
|
48
|
-
}}
|
|
49
|
-
/>`}],props:[{name:"dashboard",type:"Dashboard | null",description:"Dashboard existente para edição. null para criação."},{name:"initialTab",type:"DashboardFormTab",description:"Aba inicial (General ou Share). Default: General."},{name:"isSaving",type:"boolean",description:"Desabilita o botão salvar e mostra spinner."},{name:"isQualitfy",type:"boolean",description:"Dashboard padrão Qualitfy — bloqueia campos de configuração."},{name:"users",type:"Array<{ id, name }>",description:"Lista para seletor de responsável."},{name:"groups / places / collaborators",type:"Array<{ id, name }>",description:"Listas para aba de compartilhamento."},{name:"onSave",type:"(values: DashboardFormValues) => void",description:"Chamado ao clicar Salvar com valores válidos."},{name:"onCancel",type:"() => void",description:"Chamado ao clicar Cancelar."}]})}export{t as DashboardFormDoc};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import{j as e,gy as d,gz as t,gA as n}from"./index-DkiftrvI.js";import{C as l}from"./ComponentDocTemplate-CQbBhfvZ.js";import"./ExampleCard-DuLrb3t-.js";n.SharedWithAllCollaborators,t.FiveMinutes,d.NormalPage,t.NotUpdate,d.NormalPage;function i(){const o=[{name:"list",desc:"Lista de dashboards",active:!0},{name:"view",desc:"Visualização do dashboard"},{name:"create",desc:"Criação de novo dashboard"},{name:"edit",desc:"Edição do dashboard"},{name:"share",desc:"Configuração de compartilhamento"}],s=[{from:"list",to:"view",label:"onOpen"},{from:"list",to:"create",label:"onAdd"},{from:"view",to:"edit",label:"onEdit"},{from:"view",to:"share",label:"onShare"},{from:"view",to:"list",label:"onBackToList"},{from:"edit",to:"view",label:"onCancel/onSave"},{from:"share",to:"view",label:"onCancel/onSave"},{from:"create",to:"list",label:"onCancel/onSave"}];return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:o.map(a=>e.jsxs("div",{className:`px-3 py-2 rounded-lg border text-center ${a.active?"border-primary bg-primary/10 text-primary":"border-border bg-card text-foreground"}`,children:[e.jsx("span",{className:"text-sm font-semibold",children:a.name}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-0.5",children:a.desc})]},a.name))}),e.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:s.map((a,r)=>e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-mono bg-muted px-1.5 py-0.5 rounded",children:a.from}),e.jsx("span",{children:"→"}),e.jsx("span",{className:"font-mono bg-muted px-1.5 py-0.5 rounded",children:a.to}),e.jsx("span",{className:"text-primary",children:a.label})]},r))})]})}function h(){return e.jsx(l,{title:"DashboardGeneralView",description:"Componente orquestrador que gerencia todo o ciclo de vida do módulo de Dashboards. Integra DashboardList, DashboardView e DashboardForm através de uma máquina de estados, com suporte a carousel auto-advance e General View.",component:e.jsx(i,{}),usage:`import { DashboardGeneralView } from 'forlogic-core';
|
|
2
|
-
|
|
3
|
-
// Uso básico (uncontrolled — gerencia estado internamente)
|
|
4
|
-
<DashboardGeneralView
|
|
5
|
-
dashboards={dashboards}
|
|
6
|
-
limit={{ maxDashboards: 50, countDashboards: 12 }}
|
|
7
|
-
canAdd canEdit canRemove
|
|
8
|
-
activePanels={panels}
|
|
9
|
-
activePages={pages}
|
|
10
|
-
getPanelData={(panelId) => ({
|
|
11
|
-
state: PanelState.Loaded,
|
|
12
|
-
data: panelData[panelId],
|
|
13
|
-
})}
|
|
14
|
-
onOpen={(d) => loadPanels(d.id)}
|
|
15
|
-
onSave={(values) => createDashboard(values)}
|
|
16
|
-
onUpdate={(id, values) => updateDashboard(id, values)}
|
|
17
|
-
onRemove={(d) => removeDashboard(d.id)}
|
|
18
|
-
onToggleFavorite={(d) => toggleFav(d.id)}
|
|
19
|
-
/>
|
|
20
|
-
|
|
21
|
-
// Uso controlado (com react-router)
|
|
22
|
-
const [viewState, setViewState] = useState({ mode: 'list' });
|
|
23
|
-
|
|
24
|
-
<DashboardGeneralView
|
|
25
|
-
dashboards={dashboards}
|
|
26
|
-
viewState={viewState}
|
|
27
|
-
onViewStateChange={(state) => {
|
|
28
|
-
setViewState(state);
|
|
29
|
-
if (state.mode === 'view') navigate(\`/dashboards/\${state.dashboardId}\`);
|
|
30
|
-
if (state.mode === 'list') navigate('/dashboards');
|
|
31
|
-
}}
|
|
32
|
-
// ... demais props
|
|
33
|
-
/>`,examples:[{title:"Máquina de Estados",description:"O componente gerencia 5 modos: list, view, create, edit e share. Transições são feitas automaticamente via callbacks ou controladas externamente via viewState/onViewStateChange.",preview:e.jsx(i,{}),code:`// DashboardViewState
|
|
34
|
-
type DashboardViewState =
|
|
35
|
-
| { mode: 'list' }
|
|
36
|
-
| { mode: 'view'; dashboardId: string }
|
|
37
|
-
| { mode: 'create' }
|
|
38
|
-
| { mode: 'edit'; dashboardId: string }
|
|
39
|
-
| { mode: 'share'; dashboardId: string };
|
|
40
|
-
|
|
41
|
-
// Transições automáticas:
|
|
42
|
-
// list → view: quando onOpen é chamado
|
|
43
|
-
// list → create: quando onAdd é chamado
|
|
44
|
-
// view → edit: quando onEdit é chamado no viewer
|
|
45
|
-
// view → share: quando onShare é chamado no viewer
|
|
46
|
-
// edit → view: quando form salva/cancela
|
|
47
|
-
// create → list: quando form salva/cancela`},{title:"Carousel Auto-Advance",description:"Quando o dashboard usa DashboardViewType.Carousel, as páginas avançam automaticamente com base no DashboardPageTime configurado.",preview:e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-semibold text-foreground",children:"Modo:"}),e.jsx("span",{className:"px-2 py-0.5 bg-primary/10 text-primary rounded text-xs",children:"Carousel"})]}),e.jsx("div",{className:"grid grid-cols-4 gap-1",children:["5s","10s","15s","30s","1min","3min","5min","10min"].map((o,s)=>e.jsx("span",{className:`px-2 py-1 rounded text-xs text-center ${s===2?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"}`,children:o},o))})]}),code:`// O carousel avança automaticamente
|
|
48
|
-
<DashboardGeneralView
|
|
49
|
-
dashboards={[{
|
|
50
|
-
...dashboard,
|
|
51
|
-
idViewType: DashboardViewType.Carousel,
|
|
52
|
-
idPageTime: DashboardPageTime.FifteenSeconds,
|
|
53
|
-
}]}
|
|
54
|
-
activePages={[
|
|
55
|
-
{ id: 'p1', position: 1, name: 'Página 1' },
|
|
56
|
-
{ id: 'p2', position: 2, name: 'Página 2' },
|
|
57
|
-
{ id: 'p3', position: 3, name: 'Página 3' },
|
|
58
|
-
]}
|
|
59
|
-
/>`},{title:"General View",description:'Um dashboard pode ser definido como "Visão Geral" — o dashboard padrão exibido ao entrar no módulo. O ícone de casa indica o dashboard ativo como General View.',preview:e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg border border-border bg-card",children:[e.jsx("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-primary/10 text-primary",children:"🏠 Visão geral"}),e.jsx("span",{className:"text-sm text-foreground",children:"Indicadores de Qualidade"}),e.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:"DASH-001"})]}),code:`<DashboardGeneralView
|
|
60
|
-
dashboards={dashboards}
|
|
61
|
-
generalView={{
|
|
62
|
-
id: 'gv1',
|
|
63
|
-
dashboardId: 'dash-1',
|
|
64
|
-
titlePtBr: 'Indicadores de Qualidade',
|
|
65
|
-
titleEnUs: 'Quality Indicators',
|
|
66
|
-
titleEsEs: 'Indicadores de Calidad',
|
|
67
|
-
idViewType: 1,
|
|
68
|
-
softwareId: 2,
|
|
69
|
-
}}
|
|
70
|
-
onSetGeneralView={(dashboardId) => setGeneralView(dashboardId)}
|
|
71
|
-
/>`}],props:[{name:"dashboards",type:"Dashboard[]",description:"Lista completa de dashboards para exibir na lista."},{name:"limit",type:"DashboardLimit",description:"Limites de uso ({ maxDashboards, countDashboards })."},{name:"generalView",type:"GeneralViewDashboard | null",description:"Dashboard definido como visão geral padrão."},{name:"language",type:"DashboardLanguage",description:"Idioma para resolução de títulos (default: pt-br)."},{name:"activePanels",type:"DashboardPanel[]",description:"Painéis do dashboard atualmente aberto."},{name:"activePages",type:"DashboardPage[]",description:"Páginas do dashboard (modo carousel)."},{name:"getPanelData",type:"(panelId) => PanelRendererProps",description:"Provedor de dados por painel (state, data, series, etc.)."},{name:"viewState",type:"DashboardViewState",description:"Estado controlado (opcional). Sem ele, o componente gerencia internamente."},{name:"onViewStateChange",type:"(state) => void",description:"Callback para modo controlado — útil para sincronizar com react-router."},{name:"canAdd / canEdit / canRemove",type:"boolean",description:"Permissões que controlam botões e ações disponíveis."},{name:"onSave / onUpdate / onRemove",type:"callbacks",description:"CRUD de dashboards."},{name:"onSetGeneralView",type:"(dashboardId) => void",description:"Define um dashboard como visão geral."}]})}export{h as DashboardGeneralViewDoc};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./index-DkiftrvI.js";import{C as i}from"./ComponentDocTemplate-CQbBhfvZ.js";import"./ExampleCard-DuLrb3t-.js";function r(){const o=[{id:"num-1",col:0,row:0,sizeX:1,sizeY:1},{id:"num-2",col:1,row:0,sizeX:1,sizeY:1},{id:"num-3",col:2,row:0,sizeX:1,sizeY:1},{id:"num-4",col:3,row:0,sizeX:1,sizeY:1},{id:"chart-1",col:4,row:0,sizeX:4,sizeY:2},{id:"chart-2",col:0,row:1,sizeX:4,sizeY:2},{id:"wide",col:0,row:3,sizeX:8,sizeY:2}];return e.jsx("div",{className:"w-full border border-border rounded-lg bg-muted/30 p-2",style:{display:"grid",gridTemplateColumns:"repeat(8, 1fr)",gridTemplateRows:"repeat(5, 50px)",gap:"6px"},children:o.map(a=>e.jsxs("div",{className:"rounded-md border border-border bg-card flex flex-col items-center justify-center text-center",style:{gridColumn:`${a.col+1} / span ${a.sizeX}`,gridRow:`${a.row+1} / span ${a.sizeY}`},children:[e.jsx("span",{className:"text-[10px] font-mono text-muted-foreground",children:a.id}),e.jsxs("span",{className:"text-[9px] text-muted-foreground",children:[a.sizeX,"×",a.sizeY]})]},a.id))})}function n(){const o=[{type:"Numeric",x:1,y:1},{type:"Text / Bar / Column / Pie / Line / Area / StackedColumn",x:4,y:2},{type:"Pareto / RiskMatrix / Burndown / Performance",x:8,y:2}];return e.jsx("div",{className:"space-y-2",children:o.map(a=>e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded border border-border bg-card",children:[e.jsxs("span",{className:"px-2 py-0.5 bg-primary/10 text-primary rounded text-xs font-mono",children:[a.x,"×",a.y]}),e.jsx("span",{className:"text-xs text-foreground",children:a.type})]},a.type))})}function l(){return e.jsx(i,{title:"DashboardGrid",description:"Grid de 8 colunas com posicionamento por col/row e dimensão por sizeX/sizeY. Suporta drag-and-drop via @dnd-kit quando allowDragging é true. Cada painel é renderizado como um card com header arrastável.",component:e.jsx(r,{}),usage:`import { DashboardGrid, getDefaultPanelSize, getMinPanelSize } from 'forlogic-core';
|
|
2
|
-
|
|
3
|
-
<DashboardGrid
|
|
4
|
-
panels={[
|
|
5
|
-
{ id: 'p1', col: 0, row: 0, sizeX: 4, sizeY: 2 },
|
|
6
|
-
{ id: 'p2', col: 4, row: 0, sizeX: 4, sizeY: 2 },
|
|
7
|
-
{ id: 'p3', col: 0, row: 2, sizeX: 8, sizeY: 2 },
|
|
8
|
-
]}
|
|
9
|
-
columns={8} // padrão: 8
|
|
10
|
-
cellHeight={160} // padrão: 160px
|
|
11
|
-
cellGap={10} // padrão: 10px
|
|
12
|
-
allowDragging={canEdit}
|
|
13
|
-
showGridLines={canEdit}
|
|
14
|
-
renderPanel={(panelId) => <MyPanelComponent id={panelId} />}
|
|
15
|
-
onLayoutChange={(updatedPanels) => saveLayout(updatedPanels)}
|
|
16
|
-
/>`,examples:[{title:"Layout com 8 Colunas",description:"O grid suporta layouts flexíveis: painéis numéricos de 1×1, gráficos de 4×2, e painéis panorâmicos de 8×2. O posicionamento é feito por col/row absolutos.",preview:e.jsx(r,{}),code:`<DashboardGrid
|
|
17
|
-
panels={[
|
|
18
|
-
{ id: 'num-1', col: 0, row: 0, sizeX: 1, sizeY: 1 },
|
|
19
|
-
{ id: 'num-2', col: 1, row: 0, sizeX: 1, sizeY: 1 },
|
|
20
|
-
{ id: 'chart-1', col: 4, row: 0, sizeX: 4, sizeY: 2 },
|
|
21
|
-
{ id: 'chart-2', col: 0, row: 1, sizeX: 4, sizeY: 2 },
|
|
22
|
-
{ id: 'wide', col: 0, row: 3, sizeX: 8, sizeY: 2 },
|
|
23
|
-
]}
|
|
24
|
-
renderPanel={(id) => <MyPanel id={id} />}
|
|
25
|
-
/>`},{title:"Tamanhos Padrão por Tipo",description:"As funções getDefaultPanelSize e getMinPanelSize retornam dimensões ideais baseadas no tipo de painel.",preview:e.jsx(n,{}),code:`import { getDefaultPanelSize, getMinPanelSize, DashboardPanelType } from 'forlogic-core';
|
|
26
|
-
|
|
27
|
-
const defaultSize = getDefaultPanelSize(DashboardPanelType.Column);
|
|
28
|
-
// → { x: 4, y: 2 }
|
|
29
|
-
|
|
30
|
-
const minSize = getMinPanelSize(DashboardPanelType.Numeric);
|
|
31
|
-
// → { x: 1, y: 1 }
|
|
32
|
-
|
|
33
|
-
// Usar ao criar um novo painel:
|
|
34
|
-
const newPanel = {
|
|
35
|
-
id: generateId(),
|
|
36
|
-
col: nextAvailableCol,
|
|
37
|
-
row: nextAvailableRow,
|
|
38
|
-
sizeX: defaultSize.x,
|
|
39
|
-
sizeY: defaultSize.y,
|
|
40
|
-
};`},{title:"Drag-and-Drop",description:"Com allowDragging=true, os painéis podem ser reordenados via drag. O handler de header serve como drag handle. Após o drop, as posições são trocadas e onLayoutChange é chamado.",preview:e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border border-border bg-card",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"⠿"}),e.jsx("span",{className:"text-sm font-medium text-foreground",children:"Título do Painel"}),e.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:"Arraste para reordenar"})]}),code:`<DashboardGrid
|
|
41
|
-
panels={panels}
|
|
42
|
-
allowDragging={true}
|
|
43
|
-
showGridLines={true}
|
|
44
|
-
renderPanel={(id) => <PanelRenderer panelId={id} />}
|
|
45
|
-
onLayoutChange={(updatedPanels) => {
|
|
46
|
-
// updatedPanels contém as posições trocadas
|
|
47
|
-
savePanelPositions(updatedPanels);
|
|
48
|
-
}}
|
|
49
|
-
/>`}],props:[{name:"panels",type:"GridPanelLayout[]",description:"Definições de layout: id, col, row, sizeX, sizeY."},{name:"columns",type:"number",description:"Número de colunas do grid. Default: 8."},{name:"cellHeight",type:"number",description:"Altura de cada célula em pixels. Default: 160."},{name:"cellGap",type:"number",description:"Gap entre células em pixels. Default: 10."},{name:"allowDragging",type:"boolean",description:"Habilita drag-and-drop via @dnd-kit."},{name:"showGridLines",type:"boolean",description:"Mostra background do grid para orientação visual."},{name:"renderPanel",type:"(panelId: string) => ReactNode",description:"Função que renderiza o conteúdo de cada painel."},{name:"onLayoutChange",type:"(panels: GridPanelLayout[]) => void",description:"Chamado após drag com posições atualizadas."}]})}export{l as DashboardGridDoc};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import{j as e,gy as t,gz as r,gA as d}from"./index-DkiftrvI.js";import{C as i}from"./ComponentDocTemplate-CQbBhfvZ.js";import"./ExampleCard-DuLrb3t-.js";const n=[{id:"1",code:"DASH-001",title:"Indicadores de Qualidade",titlePtBr:"Indicadores de Qualidade",titleEnUs:"Quality Indicators",titleEsEs:"Indicadores de Calidad",responsibleId:"u1",responsibleName:"João Silva",creationDate:"2025-01-15",lastModified:"2025-03-20",isActive:!0,isFavorite:!0,isGeneralViewUse:!1,isSystemChart:!1,hasSharedIcon:!0,idShare:d.SharedWithAllCollaborators,idUpdateTime:r.FiveMinutes,idViewType:t.NormalPage},{id:"2",code:"DASH-002",title:"Ocorrências por Mês",titlePtBr:"Ocorrências por Mês",titleEnUs:"Occurrences by Month",titleEsEs:"Ocurrencias por Mes",responsibleId:"u2",responsibleName:"Maria Santos",creationDate:"2025-02-10",lastModified:"2025-03-28",isActive:!0,isFavorite:!1,isGeneralViewUse:!1,isSystemChart:!1,idUpdateTime:r.NotUpdate,idViewType:t.NormalPage},{id:"3",code:"DASH-003",title:"Plano de Ação — Burndown",titlePtBr:"Plano de Ação — Burndown",titleEnUs:"Action Plan — Burndown",titleEsEs:"Plan de Acción — Burndown",responsibleId:"u1",responsibleName:"João Silva",creationDate:"2024-11-01",lastModified:"2025-01-10",isActive:!1,isFavorite:!1,isGeneralViewUse:!1,isSystemChart:!1,idUpdateTime:r.ThirtyMinutes,idViewType:t.Carousel}];function o(){return e.jsxs("div",{className:"border border-border rounded-lg overflow-hidden bg-card",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-border",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-foreground",children:"Dashboards"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"(3/50)"})]}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground",children:"🔍"}),e.jsx("div",{className:"h-8 w-40 rounded-md border border-input bg-background pl-8 pr-3 text-xs flex items-center text-muted-foreground",children:"Buscar..."})]}),e.jsx("span",{className:"px-3 py-1.5 text-xs bg-primary text-primary-foreground rounded-md font-medium",children:"+ Novo"})]})]}),e.jsx("div",{className:"flex items-center gap-1 px-4 py-1.5 border-b border-border",children:["Todos","Meus dashboards","Favoritos"].map((a,s)=>e.jsx("span",{className:`px-2.5 py-1 text-xs rounded-md ${s===0?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent"}`,children:a},a))}),e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"bg-muted/50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2 text-left text-muted-foreground font-medium w-10",children:"★"}),e.jsx("th",{className:"px-3 py-2 text-left text-muted-foreground font-medium",children:"Código"}),e.jsx("th",{className:"px-3 py-2 text-left text-muted-foreground font-medium",children:"Título"}),e.jsx("th",{className:"px-3 py-2 text-left text-muted-foreground font-medium",children:"Responsável"}),e.jsx("th",{className:"px-3 py-2 text-left text-muted-foreground font-medium",children:"Situação"}),e.jsx("th",{className:"px-3 py-2 w-8"})]})}),e.jsx("tbody",{children:n.map(a=>e.jsxs("tr",{className:"border-t border-border hover:bg-accent/50 cursor-pointer",children:[e.jsx("td",{className:"px-3 py-2",children:a.isFavorite?"★":"☆"}),e.jsx("td",{className:"px-3 py-2 font-mono",children:a.code}),e.jsx("td",{className:"px-3 py-2 font-medium text-foreground",children:a.titlePtBr}),e.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:a.responsibleName}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("span",{className:`px-1.5 py-0.5 rounded-full text-[10px] font-medium ${a.isActive?"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400":"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"}`,children:a.isActive?"Ativo":"Inativo"})}),e.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:"⋮"})]},a.id))})]})]})}function p(){return e.jsx(i,{title:"DashboardList",description:"Lista/tabela de dashboards com busca integrada, filtros rápidos (Todos / Meus / Favoritos), toggle de favorito, status ativo/inativo, ícone de compartilhamento e menu de contexto por linha.",component:e.jsx(o,{}),usage:`import { DashboardList, QuickFilterDashboard } from 'forlogic-core';
|
|
2
|
-
|
|
3
|
-
<DashboardList
|
|
4
|
-
dashboards={dashboards}
|
|
5
|
-
limit={{ maxDashboards: 50, countDashboards: 12 }}
|
|
6
|
-
language={DashboardLanguage.PtBr}
|
|
7
|
-
canAdd canEdit canRemove
|
|
8
|
-
onOpen={(d) => navigate(\`/dashboards/\${d.id}\`)}
|
|
9
|
-
onEdit={(d) => navigate(\`/dashboards/\${d.id}/edit\`)}
|
|
10
|
-
onShare={(d) => openShareDialog(d)}
|
|
11
|
-
onDuplicate={(d) => duplicateDashboard(d.id)}
|
|
12
|
-
onRemove={(d) => removeDashboard(d.id)}
|
|
13
|
-
onAdd={() => navigate('/dashboards/new')}
|
|
14
|
-
onToggleFavorite={(d) => toggleFavorite(d.id)}
|
|
15
|
-
onSearch={(q) => setSearch(q)}
|
|
16
|
-
onQuickFilterChange={(f) => setFilter(f)}
|
|
17
|
-
/>`,examples:[{title:"Lista Completa com Filtros",description:'A lista inclui header com contagem de limites, barra de busca, botão "Novo", filtros rápidos e tabela com colunas de favorito, código, título, responsável, compartilhamento, data e situação.',preview:e.jsx(o,{}),code:`<DashboardList
|
|
18
|
-
dashboards={dashboards}
|
|
19
|
-
limit={{ maxDashboards: 50, countDashboards: 12 }}
|
|
20
|
-
canAdd canEdit canRemove
|
|
21
|
-
onOpen={(d) => openDashboard(d)}
|
|
22
|
-
onToggleFavorite={(d) => toggleFav(d.id)}
|
|
23
|
-
onSearch={(q) => fetchFiltered(q)}
|
|
24
|
-
onQuickFilterChange={(filter) => {
|
|
25
|
-
// QuickFilterDashboard.All | OnlyMine | Favorites
|
|
26
|
-
refetch(filter);
|
|
27
|
-
}}
|
|
28
|
-
/>`},{title:"Menu de Contexto",description:"Cada linha tem um menu de contexto (⋮) com ações: Abrir, Editar, Compartilhar, Duplicar e Remover. As opções respeitam as permissões canEdit e canRemove.",preview:e.jsxs("div",{className:"border border-border rounded-md bg-popover shadow-md py-1 w-40",children:[e.jsx("div",{className:"px-3 py-1.5 text-sm hover:bg-accent cursor-pointer",children:"Abrir"}),e.jsx("div",{className:"px-3 py-1.5 text-sm hover:bg-accent cursor-pointer",children:"Editar"}),e.jsx("div",{className:"px-3 py-1.5 text-sm hover:bg-accent cursor-pointer",children:"Compartilhar"}),e.jsx("div",{className:"px-3 py-1.5 text-sm hover:bg-accent cursor-pointer",children:"Duplicar"}),e.jsx("div",{className:"my-1 border-t border-border"}),e.jsx("div",{className:"px-3 py-1.5 text-sm text-destructive hover:bg-destructive/10 cursor-pointer",children:"Remover"})]}),code:`// As ações são controladas por callbacks
|
|
29
|
-
<DashboardList
|
|
30
|
-
canEdit={true}
|
|
31
|
-
canRemove={true}
|
|
32
|
-
onOpen={(d) => navigate(\`/view/\${d.id}\`)}
|
|
33
|
-
onEdit={(d) => navigate(\`/edit/\${d.id}\`)}
|
|
34
|
-
onShare={(d) => openShareDialog(d)}
|
|
35
|
-
onDuplicate={(d) => duplicateDashboard(d.id)}
|
|
36
|
-
onRemove={(d) => confirmAndRemove(d.id)}
|
|
37
|
-
/>`}],props:[{name:"dashboards",type:"Dashboard[]",description:"Lista de dashboards a exibir."},{name:"limit",type:"DashboardLimit",description:"Limites de uso (maxDashboards, countDashboards)."},{name:"language",type:"DashboardLanguage",description:"Idioma para resolução de títulos. Default: pt-br."},{name:"isLoading",type:"boolean",description:"Mostra spinner central quando true."},{name:"canAdd / canEdit / canRemove",type:"boolean",description:'Permissões que controlam o botão "Novo" e opções do menu de contexto.'},{name:"onOpen",type:"(d: Dashboard) => void",description:'Chamado ao clicar na linha ou "Abrir" no menu.'},{name:"onToggleFavorite",type:"(d: Dashboard) => void",description:"Toggle de favorito por dashboard."},{name:"onSearch",type:"(search: string) => void",description:"Chamado a cada digitação na busca."},{name:"onQuickFilterChange",type:"(filter: QuickFilterDashboard) => void",description:"Chamado ao trocar de filtro rápido."},{name:"toolbarExtra",type:"ReactNode",description:"Slot para ações extras no header (ex: botão de exportar)."}]})}export{p as DashboardListDoc};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import{j as e,gw as r,gx as t}from"./index-DkiftrvI.js";import{C as s}from"./ComponentDocTemplate-CQbBhfvZ.js";import"./ExampleCard-DuLrb3t-.js";function i(){const o=[{type:r.Numeric,label:"Numeric",desc:"Valor numérico agregado"},{type:r.Text,label:"Text",desc:"HTML rico"},{type:r.Bar,label:"Bar",desc:"Barras horizontais"},{type:r.Column,label:"Column",desc:"Colunas verticais"},{type:r.Line,label:"Line",desc:"Gráfico de linha"},{type:r.Area,label:"Area",desc:"Gráfico de área"},{type:r.Pie,label:"Pie",desc:"Gráfico de pizza"},{type:r.Pareto,label:"Pareto",desc:"Barras + linha cumulativa"},{type:r.StackedColumn,label:"Stacked Column",desc:"Colunas empilhadas"},{type:r.EvolutionLine,label:"Evolution Line",desc:"Linha com evolução temporal"},{type:r.List,label:"List",desc:"Tabela de dados"},{type:r.Burndown,label:"Burndown",desc:"Execução vs Planejamento"},{type:r.PerformanceColumns,label:"Performance",desc:"Barras de desempenho"},{type:r.RiskMatrix,label:"Risk Matrix",desc:"Matriz de criticidade"}];return e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3",children:o.map(a=>e.jsxs("div",{className:"flex flex-col items-center gap-1 p-3 rounded-lg border border-border bg-card text-center",children:[e.jsx("span",{className:"text-2xl font-bold text-primary",children:a.type}),e.jsx("span",{className:"text-sm font-medium text-foreground",children:a.label}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:a.desc})]},a.type))})}function d(){const o=[{state:t.Loading,label:"Loading",color:"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400"},{state:t.Loaded,label:"Loaded",color:"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400"},{state:t.NoData,label:"No Data",color:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400"},{state:t.Error,label:"Error",color:"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"},{state:t.Unavailable,label:"Unavailable",color:"bg-gray-100 text-gray-700 dark:bg-gray-900/30 dark:text-gray-400"}];return e.jsx("div",{className:"flex flex-wrap gap-2",children:o.map(a=>e.jsxs("span",{className:`px-3 py-1.5 rounded-full text-xs font-medium ${a.color}`,children:[a.label," (",a.state,")"]},a.state))})}function l(){const o=[{name:"DashboardGeneralView",desc:"Orquestrador — máquina de estados (list/view/create/edit/share)",color:"bg-primary/10 border-primary/30"},{name:"DashboardList",desc:"Lista com busca, filtros e menu de contexto",color:"bg-chart-2/10 border-chart-2/30"},{name:"DashboardView",desc:"Visualizador com toolbar, pages e grid",color:"bg-chart-3/10 border-chart-3/30"},{name:"DashboardForm",desc:"Formulário de criação/edição multilíngue",color:"bg-chart-4/10 border-chart-4/30"},{name:"DashboardGrid",desc:"Grid de 8 colunas com @dnd-kit",color:"bg-chart-5/10 border-chart-5/30"},{name:"DashboardPanelRenderer",desc:"Mapeia DashboardPanelType → componente",color:"bg-accent border-accent/30"},{name:"14 Panel Components",desc:"Numeric, Text, List, Cartesian (6 variantes), Pie, Pareto, Burndown, Performance, MatrixRisk",color:"bg-muted border-border"}];return e.jsx("div",{className:"space-y-2",children:o.map((a,n)=>e.jsxs("div",{className:`flex items-center gap-3 p-3 rounded-lg border ${a.color}`,style:{marginLeft:`${n*16}px`},children:[e.jsx("span",{className:"text-sm font-semibold text-foreground whitespace-nowrap",children:a.name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:a.desc})]},a.name))})}function b(){return e.jsx(s,{title:"Dashboards — Visão Geral",description:"Módulo completo de dashboards portado do qex-dashboards Angular. Inclui 14 tipos de painéis com Recharts, grid responsivo com drag-and-drop via @dnd-kit, lista com filtros, formulário multilíngue e visualizador com toolbar.",component:e.jsx(l,{}),usage:`import {
|
|
2
|
-
// Orquestrador principal
|
|
3
|
-
DashboardGeneralView,
|
|
4
|
-
|
|
5
|
-
// Componentes de página
|
|
6
|
-
DashboardView,
|
|
7
|
-
DashboardList,
|
|
8
|
-
DashboardForm,
|
|
9
|
-
DashboardGrid,
|
|
10
|
-
DashboardPanelRenderer,
|
|
11
|
-
|
|
12
|
-
// Painéis individuais
|
|
13
|
-
NumericPanel, TextPanel, ListPanel,
|
|
14
|
-
CartesianPanel, PiePanel, ParetoPanel,
|
|
15
|
-
BurndownPanel, PerformancePanel, MatrixRiskPanel,
|
|
16
|
-
|
|
17
|
-
// Shared de painel
|
|
18
|
-
PanelHeader, PanelError, PanelLoader, PanelNoData, PanelUnavailable,
|
|
19
|
-
|
|
20
|
-
// Types & Helpers
|
|
21
|
-
DashboardPanelType, PanelState, AggregationType,
|
|
22
|
-
type PanelConfig, type Dashboard, type DashboardPanel,
|
|
23
|
-
getDefaultPanelSize, getMinPanelSize,
|
|
24
|
-
currencyFormatter, processUrl, getLinkFromRow,
|
|
25
|
-
} from 'forlogic-core';`,examples:[{title:"14 Tipos de Painel",description:"Cada tipo é representado pelo enum DashboardPanelType. O DashboardPanelRenderer resolve automaticamente qual componente renderizar.",preview:e.jsx(i,{}),code:`// O renderer mapeia typeId → componente automaticamente
|
|
26
|
-
<DashboardPanelRenderer
|
|
27
|
-
config={{ ...panelConfig, typeId: DashboardPanelType.Column }}
|
|
28
|
-
state={PanelState.Loaded}
|
|
29
|
-
cartesianData={chartData}
|
|
30
|
-
cartesianSeries={[{ dataKey: 'value', name: 'Total' }]}
|
|
31
|
-
/>`},{title:"5 Estados de Painel",description:"Todos os painéis suportam os mesmos 5 estados. Componentes shared (PanelLoader, PanelError, etc.) são renderizados automaticamente dentro de cada painel.",preview:e.jsx(d,{}),code:`// Os painéis verificam o estado antes de renderizar
|
|
32
|
-
<NumericPanel config={config} state={PanelState.Loading} /> // → PanelLoader
|
|
33
|
-
<NumericPanel config={config} state={PanelState.NoData} /> // → PanelNoData
|
|
34
|
-
<NumericPanel config={config} state={PanelState.Error} /> // → PanelError
|
|
35
|
-
<NumericPanel config={config} state={PanelState.Loaded} value={42} />`}],props:[{name:"DashboardGeneralView",type:"Component",description:"Página orquestradora — integra List → View → Form com máquina de estados, carousel auto-advance e suporte a General View."},{name:"DashboardView",type:"Component",description:"Viewer com toolbar (refresh, fullscreen, favorito, share), tabs de páginas e grid de painéis."},{name:"DashboardList",type:"Component",description:"Lista/tabela com busca, filtros rápidos, favoritos e menu de contexto."},{name:"DashboardForm",type:"Component",description:"Formulário com títulos multilíngue, configurações e aba de compartilhamento."},{name:"DashboardGrid",type:"Component",description:"Grid de 8 colunas com @dnd-kit para posicionamento via drag-and-drop."},{name:"DashboardPanelRenderer",type:"Component",description:"Mapeia DashboardPanelType → componente React (14 tipos)."},{name:"PanelConfig",type:"Interface",description:"Configuração base compartilhada por todos os painéis (título, tipo, query, cores, etc.)."},{name:"PanelState",type:"Enum",description:"Loading (0), Loaded (1), Error (3), NoData (4), Unavailable (5)."}]})}export{b as DashboardOverviewDoc};
|