forlogic-core 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -46
- package/dist/assets/AccordionDoc-CGNlubG3.js +31 -0
- package/dist/assets/ActionButtonDoc-CYtkXR0k.js +47 -0
- package/dist/assets/ActionPlanDoc-BSuPRftQ.js +65 -0
- package/dist/assets/AlertDoc-Cpvxneqg.js +37 -0
- package/dist/assets/AliasUrlDoc-DIpUWf4Y.js +189 -0
- package/dist/assets/AppHeaderDoc-DNQErj_t.js +74 -0
- package/dist/assets/AppSidebarDoc-DkeQarDu.js +221 -0
- package/dist/assets/ApprovalFlowDoc-8YgXbhKJ.js +31 -0
- package/dist/assets/AuditLogDoc-BBvNcHIo.js +67 -0
- package/dist/assets/AuditTrailDoc-DgFHO-uo.js +17 -0
- package/dist/assets/AuthDoc-WIA_Aetl.js +200 -0
- package/dist/assets/AvatarDoc-B6go1C1T.js +11 -0
- package/dist/assets/BadgeDoc-BONhfqB_.js +36 -0
- package/dist/assets/BaseFormDoc-CuyUArcj.js +169 -0
- package/dist/assets/BodyContentDoc-CterHC1E.js +83 -0
- package/dist/assets/BreadcrumbDoc-Dwn9nLeO.js +75 -0
- package/dist/assets/ButtonDoc-BOjRseZT.js +41 -0
- package/dist/assets/ButtonGroupDoc-8IS6PPh4.js +7 -0
- package/dist/assets/CalendarDoc-CMwIEqgT.js +81 -0
- package/dist/assets/CardDoc-BZz1CVg2.js +49 -0
- package/dist/assets/ChartDoc-B5vZVtqD.js +76 -0
- package/dist/assets/CheckboxDoc-lAbYO9I5.js +55 -0
- package/dist/assets/ColorPickerDoc-Dpsprp4N.js +10 -0
- package/dist/assets/ColorsFoundationDoc-CCHeSL3p.js +13 -0
- package/dist/assets/ComboTreeDoc-D4dTkIt-.js +46 -0
- package/dist/assets/ComboboxDoc-CqqZPvZq.js +134 -0
- package/dist/assets/ComponentDocTemplate-CQbBhfvZ.js +1 -0
- package/dist/assets/ContextMenuDoc-D3jC-MVA.js +182 -0
- package/dist/assets/ContextsDoc-XFH0-JdS.js +211 -0
- package/dist/assets/CreateCrudPageDoc-CpuiWI-g.js +106 -0
- package/dist/assets/CrudActionBarDoc-wuBGXD9Y.js +112 -0
- package/dist/assets/CrudGridDoc-BYWqSXBH.js +85 -0
- package/dist/assets/CrudOverviewDoc-B_bk2a2t.js +14 -0
- package/dist/assets/CrudPrimitivesDoc-CxaTB94A.js +164 -0
- package/dist/assets/CrudTableDoc-Dga1VgCu.js +113 -0
- package/dist/assets/CustomFormFieldsDoc-C1hwwSl3.js +33 -0
- package/dist/assets/DashboardFormDoc-BUDCmrMl.js +49 -0
- package/dist/assets/DashboardGeneralViewDoc-Cyg1SIiG.js +71 -0
- package/dist/assets/DashboardGridDoc-BavePiRF.js +49 -0
- package/dist/assets/DashboardListDoc-CLyMA6UK.js +37 -0
- package/dist/assets/DashboardOverviewDoc-DRVvNIF1.js +35 -0
- package/dist/assets/DashboardPanelRendererDoc--mfwb8Nc.js +60 -0
- package/dist/assets/DashboardPanelsBasicDoc-BQ2V_52D.js +62 -0
- package/dist/assets/DashboardPanelsCartesianDoc-sy-hcVQY.js +75 -0
- package/dist/assets/DashboardPanelsSpecialDoc-DsIUCRRP.js +83 -0
- package/dist/assets/DashboardViewDoc-CtlCNlEF.js +45 -0
- package/dist/assets/DataListDoc-DUy88lCQ.js +13 -0
- package/dist/assets/DesignSystemHome-DHl9YtbH.js +1 -0
- package/dist/assets/DialogDoc-CMQqnTV-.js +981 -0
- package/dist/assets/DropdownMenuDoc-S7X9csGt.js +175 -0
- package/dist/assets/ElectronicSignatureDialogDoc-BfithaL_.js +57 -0
- package/dist/assets/EmptyStateDoc-CHGCiGIk.js +35 -0
- package/dist/assets/EnvironmentsDoc-DZHJZ2nm.js +96 -0
- package/dist/assets/ErrorBoundaryDoc-DoaAg68p.js +111 -0
- package/dist/assets/ExampleActionPlanPage-C0fIMZCD.js +1 -0
- package/dist/assets/ExampleAppDoc-DzIU81Fn.js +1 -0
- package/dist/assets/ExampleCard-DuLrb3t-.js +1 -0
- package/dist/assets/ExampleCrudReportsPage-M0pz6tdM.js +1 -0
- package/dist/assets/ExampleDashboardPage-CRG5r3Vw.js +1 -0
- package/dist/assets/ExampleIdeasPage-I84ZMLY4.js +1 -0
- package/dist/assets/ExampleImportWizardPage-h4YqrrSe.js +1 -0
- package/dist/assets/ExampleSettingsPage-CwdWqoaP.js +1 -0
- package/dist/assets/FileUploadDoc-9-UujFNX.js +34 -0
- package/dist/assets/FilterBar-DDTqqUfZ.js +1 -0
- package/dist/assets/FormDoc-CVES6n3d.js +81 -0
- package/dist/assets/FoundationOverview-DT0u11Gz.js +1 -0
- package/dist/assets/GridDoc-CbHFSILF.js +28 -0
- package/dist/assets/HooksDoc-Ctxdk6Wq.js +665 -0
- package/dist/assets/HoverCardDoc-8Wkaafdj.js +31 -0
- package/dist/assets/I18nDoc-D3Q2m7ik.js +167 -0
- package/dist/assets/IconPickerDoc-DZ26Gdpg.js +10 -0
- package/dist/assets/IconsFoundationDoc-xOxtC7CW.js +33 -0
- package/dist/assets/InputDoc-BhztAiuJ.js +211 -0
- package/dist/assets/LabelDoc-A4hmTRRV.js +42 -0
- package/dist/assets/LeadershipDoc-CqOSfWsP.js +452 -0
- package/dist/assets/MediaDoc-C78gvC8p.js +459 -0
- package/dist/assets/MenubarDoc-DCnmd2tO.js +165 -0
- package/dist/assets/ModuleAccessDoc-CmD5nHDp.js +153 -0
- package/dist/assets/ModulesDialogDoc-DVit1CA-.js +46 -0
- package/dist/assets/MultiselectPermissionsDoc-tlJMs04L.js +34 -0
- package/dist/assets/NavigationMenuDoc-q1fbc89j.js +116 -0
- package/dist/assets/OnboardingDialogDoc-3A3eBYrq.js +55 -0
- package/dist/assets/PaginationDoc-B8-bMz5J.js +27 -0
- package/dist/assets/PaginationDoc-BkGdxHL3.js +98 -0
- package/dist/assets/PlacesDoc-CKPO6ATs.js +226 -0
- package/dist/assets/PopoverDoc-CJPU4Ags.js +64 -0
- package/dist/assets/ProgressDoc-CpjbTL4o.js +29 -0
- package/dist/assets/QualiexUserFieldDoc-DDwumlRw.js +149 -0
- package/dist/assets/RadioGroupDoc-D6tSZz8G.js +57 -0
- package/dist/assets/RadiusDoc-B4xSnajw.js +7 -0
- package/dist/assets/ReportRequestListDoc-C0LIaU8P.js +15 -0
- package/dist/assets/RequiredFieldsCounterDoc-COesoSdx.js +58 -0
- package/dist/assets/ResizableDoc-CW0-XQuB.js +104 -0
- package/dist/assets/RichTextEditorDoc-C8c_XA9P.js +24 -0
- package/dist/assets/ScrollAreaDoc-BxtoAPaZ.js +28 -0
- package/dist/assets/SecurityDoc-wOVqpg2F.js +204 -0
- package/dist/assets/SelectDoc-C75gtY9D.js +80 -0
- package/dist/assets/SeparatorDoc-BjQBPB1P.js +4 -0
- package/dist/assets/ServicesDoc-CXTctwBl.js +308 -0
- package/dist/assets/ShadowsDoc-C6Lw8_x2.js +9 -0
- package/dist/assets/SignDoc-Bh5ZUg5x.js +66 -0
- package/dist/assets/SkeletonDoc-rTLGK5VE.js +54 -0
- package/dist/assets/SliderDoc-JMAMDub7.js +41 -0
- package/dist/assets/SpacingDoc-RljOrpwA.js +12 -0
- package/dist/assets/SplitButtonDoc-CvShUW3w.js +53 -0
- package/dist/assets/StepSelectorDoc-C-nAap9H.js +41 -0
- package/dist/assets/SwitchDoc-DLnqmkPr.js +56 -0
- package/dist/assets/TableDoc-B8EpWLVg.js +128 -0
- package/dist/assets/TabsDoc-DIBtl_uC.js +42 -0
- package/dist/assets/TeamSelectorDoc-B7OnCbL7.js +10 -0
- package/dist/assets/TermsOfUseDoc-Bb-pw08s.js +16 -0
- package/dist/assets/TextareaDoc-DGnqMqEC.js +46 -0
- package/dist/assets/ToastDoc-DjYyc7ae.js +157 -0
- package/dist/assets/ToggleDoc-C9ZOVjkY.js +51 -0
- package/dist/assets/TooltipDoc-BEx4l9-i.js +58 -0
- package/dist/assets/TruncatedCellDoc-BbV1bRSY.js +12 -0
- package/dist/assets/TypographyFoundationDoc-CUDYjRo9.js +7 -0
- package/dist/assets/UpdatesNotificationDoc-7nyjzLMJ.js +29 -0
- package/dist/assets/UsersGroupsSelectorDoc-C0KlTAL5.js +18 -0
- package/dist/assets/UtilitiesDoc-DGxaHVV1.js +145 -0
- package/dist/assets/ViewerDialogsDoc-CnTPTEz0.js +1 -0
- package/dist/assets/blocks-B6LrJeAM.js +1 -0
- package/dist/assets/building-DeVappnD.js +1 -0
- package/dist/assets/calendar-days-BQ0na5kM.js +1 -0
- package/dist/assets/check-check-C_-PJCJa.js +1 -0
- package/dist/assets/circle-plus-CpIcep-O.js +1 -0
- package/dist/assets/circle-x-jPpBPew0.js +1 -0
- package/dist/assets/clipboard-list-CXNPdciZ.js +1 -0
- package/dist/assets/cloud-upload-BEjzumjl.js +1 -0
- package/dist/assets/crown-CqNsQIsm.js +1 -0
- package/dist/assets/date-picker-BW3eGOe_.js +1 -0
- package/dist/assets/disabled-menu-item-C2YaMvSt.js +1 -0
- package/dist/assets/drawer-D5rflIcD.js +3 -0
- package/dist/assets/file-braces-DFb5X9so.js +1 -0
- package/dist/assets/file-pen-line-CyUGKkEN.js +1 -0
- package/dist/assets/git-branch-BcXv9mpp.js +1 -0
- package/dist/assets/globe-CpMIWAcv.js +1 -0
- package/dist/assets/hash-cQWdKjya.js +1 -0
- package/dist/assets/hourglass-BahQ3eDv.js +1 -0
- package/dist/assets/hover-card-R66N85sZ.js +1 -0
- package/dist/assets/iframe-dialog-V0mW5aBb.js +1 -0
- package/dist/assets/index-DkiftrvI.js +352 -0
- package/dist/assets/index-nmBjO9Th.css +1 -0
- package/dist/assets/life-buoy-ByXiPddz.js +1 -0
- package/dist/assets/loading-state-Cb5_t5uE.js +1 -0
- package/dist/assets/lucide-react-Cp3Yw3Zm.js +1 -0
- package/dist/assets/package-B3-pVvPM.js +1 -0
- package/dist/assets/pen-Bi_lmmKT.js +1 -0
- package/dist/assets/pin-DVsSl8QA.js +1 -0
- package/dist/assets/printer-BnJ8B6m-.js +1 -0
- package/dist/assets/radio-group-BHAaNGsm.js +1 -0
- package/dist/assets/server-CtzFTfKR.js +1 -0
- package/dist/assets/share-2-Dv8Do445.js +1 -0
- package/dist/assets/shield-check-CFXjOV_w.js +1 -0
- package/dist/assets/shield-x-DJTRfVux.js +1 -0
- package/dist/assets/slider-v9tXBSnB.js +1 -0
- package/dist/assets/smartphone-BSNR60L7.js +1 -0
- package/dist/assets/step-selector-ATTh_9Wa.js +1 -0
- package/dist/assets/text-align-start-qE-MbYYw.js +1 -0
- package/dist/assets/thumbs-up-D_XIW_uX.js +1 -0
- package/dist/assets/trash-DTWQwpwA.js +1 -0
- package/dist/assets/trending-up-jip5-leJ.js +1 -0
- package/dist/assets/useMockCrud-CN4vjyOZ.js +1 -0
- package/dist/assets/user-check-BlH3EDWK.js +1 -0
- package/dist/assets/user-plus-BqwXwD-c.js +1 -0
- package/dist/components/modules/ModulesContent.d.ts +7 -3
- package/dist/components/modules/ModulesFooterCards.d.ts +3 -1
- package/dist/components/modules/types.d.ts +3 -1
- package/dist/components/ui/button.d.ts +1 -1
- package/dist/components/ui/resizable.d.ts +1 -1
- package/dist/exports/crud.d.ts +5 -1
- package/dist/exports/ui.d.ts +8 -1
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +1 -1
- package/dist/index.html +33 -0
- package/dist/index.js +1 -1
- package/dist/setup/favicon.d.ts +1 -0
- package/docs/PUBLISH.md +3 -3
- package/package.json +1 -5
- package/dist/README.md +0 -1079
- package/dist/bin/bootstrap.js +0 -40
- package/dist/bin/pull-docs.js +0 -186
- package/dist/docs/KNOWLEDGE.md +0 -109
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import{r as s,j as e,B as o,a as r,b as l,c as n,d,gq as a,N as c,O as i,Q as x,R as u,V as t,a5 as V,a6 as E,a7 as m,aa as h}from"./index-DkiftrvI.js";import{E as p}from"./ExampleCard-DuLrb3t-.js";import{C as k}from"./ComponentDocTemplate-CQbBhfvZ.js";const I=[{id:"visao-geral",label:"Visão Geral"},{id:"layout-3-zonas",label:"Layout de 3 Zonas"},{id:"exemplos",label:"Exemplos"},{id:"propriedades",label:"Propriedades"}],P=`import { CrudActionBar } from 'forlogic-core';
|
|
2
|
+
|
|
3
|
+
function MyPage() {
|
|
4
|
+
const [search, setSearch] = useState('');
|
|
5
|
+
|
|
6
|
+
return (
|
|
7
|
+
<CrudActionBar
|
|
8
|
+
onNew={() => console.log('Novo')}
|
|
9
|
+
showSearch
|
|
10
|
+
searchValue={search}
|
|
11
|
+
onSearchChange={setSearch}
|
|
12
|
+
/>
|
|
13
|
+
);
|
|
14
|
+
}`,D=`import { CrudActionBar, Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from 'forlogic-core';
|
|
15
|
+
|
|
16
|
+
function MyPage() {
|
|
17
|
+
const [search, setSearch] = useState('');
|
|
18
|
+
const [status, setStatus] = useState('all');
|
|
19
|
+
const [selectedIds, setSelectedIds] = useState<string[]>([]);
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<CrudActionBar
|
|
23
|
+
// Botão Novo (Zona Esquerda)
|
|
24
|
+
onNew={() => openModal()}
|
|
25
|
+
newButtonLabel="Novo Treinamento"
|
|
26
|
+
showNewButton={true}
|
|
27
|
+
|
|
28
|
+
// Busca Centralizada (Zona Central)
|
|
29
|
+
showSearch={true}
|
|
30
|
+
searchValue={search}
|
|
31
|
+
onSearchChange={setSearch}
|
|
32
|
+
searchPlaceholder="Buscar treinamentos..."
|
|
33
|
+
|
|
34
|
+
// Ações em Lote (Zona Esquerda, ao lado do Novo)
|
|
35
|
+
enableBulkActions={true}
|
|
36
|
+
selectedCount={selectedIds.length}
|
|
37
|
+
bulkActions={[
|
|
38
|
+
{ label: 'Exportar', onClick: handleExport, icon: Download },
|
|
39
|
+
{ label: 'Arquivar', onClick: handleArchive, icon: Archive },
|
|
40
|
+
]}
|
|
41
|
+
onClearSelection={() => setSelectedIds([])}
|
|
42
|
+
|
|
43
|
+
// Filtros Customizados (Zona Direita)
|
|
44
|
+
filters={
|
|
45
|
+
<Select value={status} onValueChange={setStatus}>
|
|
46
|
+
<SelectTrigger className="w-[140px] h-9">
|
|
47
|
+
<SelectValue placeholder="Status" />
|
|
48
|
+
</SelectTrigger>
|
|
49
|
+
<SelectContent>
|
|
50
|
+
<SelectItem value="all">Todos</SelectItem>
|
|
51
|
+
<SelectItem value="active">Ativo</SelectItem>
|
|
52
|
+
<SelectItem value="inactive">Inativo</SelectItem>
|
|
53
|
+
</SelectContent>
|
|
54
|
+
</Select>
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Toggle de Visualização (Zona Direita)
|
|
58
|
+
viewMode="table"
|
|
59
|
+
onViewModeChange={setViewMode}
|
|
60
|
+
showViewToggle={true}
|
|
61
|
+
/>
|
|
62
|
+
);
|
|
63
|
+
}`,z=`// Ocultar elementos específicos
|
|
64
|
+
<CrudActionBar
|
|
65
|
+
showNewButton={false} // Oculta botão Novo
|
|
66
|
+
showSearch={false} // Oculta campo de busca
|
|
67
|
+
enableBulkActions={false} // Desabilita ações em lote
|
|
68
|
+
showViewToggle={false} // Oculta toggle de visualização
|
|
69
|
+
/>
|
|
70
|
+
|
|
71
|
+
// Ocultar a Action Bar completamente
|
|
72
|
+
<CrudTable
|
|
73
|
+
showActionBar={false}
|
|
74
|
+
// ... outras props
|
|
75
|
+
/>`;function F(){const[C,w]=s.useState(""),[j,b]=s.useState(""),[g,y]=s.useState("all"),[f,S]=s.useState("all"),[N,B]=s.useState(3),[v,A]=s.useState("list");return e.jsxs(k,{title:"CrudActionBar",description:"Barra de ações unificada usada por todos os componentes CRUD (CrudTable, CrudGrid, createCrudPage) para garantir UX consistente.",tocItems:I,children:[e.jsxs("div",{className:"flex items-center gap-2 -mt-6",children:[e.jsx(o,{variant:"secondary",children:"CRUD"}),e.jsx(o,{variant:"outline",children:"Componente Compartilhado"})]}),e.jsxs(r,{id:"layout-3-zonas",className:"scroll-mt-4",children:[e.jsx(l,{children:e.jsx(n,{children:"Layout de 3 Zonas"})}),e.jsxs(d,{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"O CrudActionBar implementa um layout rígido de 3 zonas para garantir consistência visual em todos os CRUDs:"}),e.jsx("div",{className:"border rounded-lg p-4 bg-muted/30 font-mono text-sm",children:e.jsx("pre",{className:"overflow-x-auto",children:`┌─────────────────────────────────────────────────────────────────┐
|
|
76
|
+
│ [+ Novo] [Ações em lote ▼] │ 🔍 Buscar... │ [Filtros] [👁] │
|
|
77
|
+
│ ESQUERDA │ CENTRO │ DIREITA │
|
|
78
|
+
└─────────────────────────────────────────────────────────────────┘`})}),e.jsxs("div",{className:"grid gap-3 text-sm",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx(o,{variant:"outline",className:"shrink-0",children:"Esquerda"}),e.jsx("span",{className:"text-muted-foreground",children:'Botão "Novo" + Dropdown de Ações em Lote (com badge de contagem)'})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(o,{variant:"outline",className:"shrink-0",children:"Centro"}),e.jsx("span",{className:"text-muted-foreground",children:"Campo de busca centralizado com placeholder customizável"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(o,{variant:"outline",className:"shrink-0",children:"Direita"}),e.jsx("span",{className:"text-muted-foreground",children:"Filtros customizados + Toggle de visualização (list/grid/table)"})]})]})]})]}),e.jsxs("div",{id:"exemplos",className:"space-y-6 scroll-mt-4",children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Exemplos"}),e.jsx(p,{title:"Uso Básico",code:P,preview:e.jsx(a,{onNew:()=>console.log("Novo"),showSearch:!0,searchValue:C,onSearchChange:w,searchPlaceholder:"Buscar..."})}),e.jsx(p,{title:"Exemplo Completo",code:D,preview:e.jsxs(e.Fragment,{children:[e.jsx(a,{onNew:()=>console.log("Novo"),newButtonLabel:"Novo Treinamento",showNewButton:!0,showSearch:!0,searchValue:j,onSearchChange:b,searchPlaceholder:"Buscar treinamentos...",showBulkActions:!0,selectedCount:N,bulkActions:[{label:"Exportar",action:()=>console.log("Exportar")},{label:"Arquivar",action:()=>console.log("Arquivar")},{label:"Enviar E-mail",action:()=>console.log("E-mail")}],onClearSelection:()=>B(0),filters:e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(c,{value:g,onValueChange:y,children:[e.jsx(i,{className:"w-[120px] h-9",children:e.jsx(x,{placeholder:"Status"})}),e.jsxs(u,{children:[e.jsx(t,{value:"all",children:"Todos"}),e.jsx(t,{value:"active",children:"Ativo"}),e.jsx(t,{value:"inactive",children:"Inativo"})]})]}),e.jsxs(c,{value:f,onValueChange:S,children:[e.jsx(i,{className:"w-[130px] h-9",children:e.jsx(x,{placeholder:"Categoria"})}),e.jsxs(u,{children:[e.jsx(t,{value:"all",children:"Todas"}),e.jsx(t,{value:"a",children:"Categoria A"}),e.jsx(t,{value:"b",children:"Categoria B"})]})]})]}),viewMode:v,onViewModeChange:T=>A(T),showViewToggle:!0}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-3 pt-3 border-t",children:["Selecionados: ",N,' | Busca: "',j,'" | Status: ',g," | Categoria: ",f," | View: ",v]})]})}),e.jsx(p,{title:"Ocultando Elementos",code:z,preview:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Sem botão Novo:"}),e.jsx(a,{showNewButton:!1,showSearch:!0,searchValue:"",onSearchChange:()=>{}})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Sem busca:"}),e.jsx(a,{onNew:()=>{},showSearch:!1})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Apenas filtros:"}),e.jsx(a,{showNewButton:!1,showSearch:!1,filters:e.jsxs(c,{value:"all",onValueChange:()=>{},children:[e.jsx(i,{className:"w-[140px] h-9",children:e.jsx(x,{placeholder:"Status"})}),e.jsx(u,{children:e.jsx(t,{value:"all",children:"Todos"})})]})})]})]})})]}),e.jsxs(r,{id:"propriedades",className:"scroll-mt-4",children:[e.jsx(l,{children:e.jsx(n,{children:"Propriedades"})}),e.jsx(d,{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 py-2 pr-4 font-medium",children:"Prop"}),e.jsx("th",{className:"text-left py-2 pr-4 font-medium",children:"Tipo"}),e.jsx("th",{className:"text-left py-2 pr-4 font-medium",children:"Default"}),e.jsx("th",{className:"text-left py-2 font-medium",children:"Descrição"})]})}),e.jsxs("tbody",{className:"divide-y",children:[e.jsxs("tr",{children:[e.jsx("td",{className:"py-2 pr-4 font-mono text-xs",children:"onNew"}),e.jsx("td",{className:"py-2 pr-4 font-mono text-xs text-muted-foreground",children:"() => void"}),e.jsx("td",{className:"py-2 pr-4 font-mono text-xs text-muted-foreground",children:"-"}),e.jsx("td",{className:"py-2 text-muted-foreground",children:"Callback ao clicar no botão Novo"})]}),e.jsxs("tr",{children:[e.jsx("td",{className:"py-2 pr-4 font-mono text-xs",children:"newButtonLabel"}),e.jsx("td",{className:"py-2 pr-4 font-mono text-xs text-muted-foreground",children:"string"}),e.jsx("td",{className:"py-2 pr-4 font-mono text-xs text-muted-foreground",children:'"Novo"'}),e.jsx("td",{className:"py-2 text-muted-foreground",children:"Texto do botão de criação"})]}),e.jsxs("tr",{children:[e.jsx("td",{className:"py-2 pr-4 font-mono text-xs",children:"showNewButton"}),e.jsx("td",{className:"py-2 pr-4 font-mono text-xs text-muted-foreground",children:"boolean"}),e.jsx("td",{className:"py-2 pr-4 font-mono text-xs text-muted-foreground",children:"true"}),e.jsx("td",{className:"py-2 text-muted-foreground",children:"Exibir botão Novo"})]}),e.jsxs("tr",{children:[e.jsx("td",{className:"py-2 pr-4 font-mono text-xs",children:"showSearch"}),e.jsx("td",{className:"py-2 pr-4 font-mono text-xs text-muted-foreground",children:"boolean"}),e.jsx("td",{className:"py-2 pr-4 font-mono text-xs text-muted-foreground",children:"true"}),e.jsx("td",{className:"py-2 text-muted-foreground",children:"Exibir campo de busca"})]}),e.jsxs("tr",{children:[e.jsx("td",{className:"py-2 pr-4 font-mono text-xs",children:"searchValue"}),e.jsx("td",{className:"py-2 pr-4 font-mono text-xs text-muted-foreground",children:"string"}),e.jsx("td",{className:"py-2 pr-4 font-mono text-xs text-muted-foreground",children:'""'}),e.jsx("td",{className:"py-2 text-muted-foreground",children:"Valor do campo de busca"})]}),e.jsxs("tr",{children:[e.jsx("td",{className:"py-2 pr-4 font-mono text-xs",children:"onSearchChange"}),e.jsx("td",{className:"py-2 pr-4 font-mono text-xs text-muted-foreground",children:"(value: string) => void"}),e.jsx("td",{className:"py-2 pr-4 font-mono text-xs text-muted-foreground",children:"-"}),e.jsx("td",{className:"py-2 text-muted-foreground",children:"Callback ao alterar busca"})]}),e.jsxs("tr",{children:[e.jsx("td",{className:"py-2 pr-4 font-mono text-xs",children:"searchPlaceholder"}),e.jsx("td",{className:"py-2 pr-4 font-mono text-xs text-muted-foreground",children:"string"}),e.jsx("td",{className:"py-2 pr-4 font-mono text-xs text-muted-foreground",children:'"Buscar..."'}),e.jsx("td",{className:"py-2 text-muted-foreground",children:"Placeholder do campo de busca"})]}),e.jsxs("tr",{children:[e.jsx("td",{className:"py-2 pr-4 font-mono text-xs",children:"enableBulkActions"}),e.jsx("td",{className:"py-2 pr-4 font-mono text-xs text-muted-foreground",children:"boolean"}),e.jsx("td",{className:"py-2 pr-4 font-mono text-xs text-muted-foreground",children:"false"}),e.jsx("td",{className:"py-2 text-muted-foreground",children:"Habilitar dropdown de ações em lote"})]}),e.jsxs("tr",{children:[e.jsx("td",{className:"py-2 pr-4 font-mono text-xs",children:"selectedCount"}),e.jsx("td",{className:"py-2 pr-4 font-mono text-xs text-muted-foreground",children:"number"}),e.jsx("td",{className:"py-2 pr-4 font-mono text-xs text-muted-foreground",children:"0"}),e.jsx("td",{className:"py-2 text-muted-foreground",children:"Quantidade de itens selecionados"})]}),e.jsxs("tr",{children:[e.jsx("td",{className:"py-2 pr-4 font-mono text-xs",children:"bulkActions"}),e.jsx("td",{className:"py-2 pr-4 font-mono text-xs text-muted-foreground",children:"BulkAction[]"}),e.jsx("td",{className:"py-2 pr-4 font-mono text-xs text-muted-foreground",children:"[]"}),e.jsx("td",{className:"py-2 text-muted-foreground",children:"Lista de ações em lote"})]}),e.jsxs("tr",{children:[e.jsx("td",{className:"py-2 pr-4 font-mono text-xs",children:"onClearSelection"}),e.jsx("td",{className:"py-2 pr-4 font-mono text-xs text-muted-foreground",children:"() => void"}),e.jsx("td",{className:"py-2 pr-4 font-mono text-xs text-muted-foreground",children:"-"}),e.jsx("td",{className:"py-2 text-muted-foreground",children:"Limpar seleção"})]}),e.jsxs("tr",{children:[e.jsx("td",{className:"py-2 pr-4 font-mono text-xs",children:"filters"}),e.jsx("td",{className:"py-2 pr-4 font-mono text-xs text-muted-foreground",children:"React.ReactNode"}),e.jsx("td",{className:"py-2 pr-4 font-mono text-xs text-muted-foreground",children:"-"}),e.jsx("td",{className:"py-2 text-muted-foreground",children:"Filtros customizados (zona direita)"})]}),e.jsxs("tr",{children:[e.jsx("td",{className:"py-2 pr-4 font-mono text-xs",children:"viewMode"}),e.jsx("td",{className:"py-2 pr-4 font-mono text-xs text-muted-foreground",children:"'list' | 'grid' | 'table'"}),e.jsx("td",{className:"py-2 pr-4 font-mono text-xs text-muted-foreground",children:"-"}),e.jsx("td",{className:"py-2 text-muted-foreground",children:"Modo de visualização atual"})]}),e.jsxs("tr",{children:[e.jsx("td",{className:"py-2 pr-4 font-mono text-xs",children:"onViewModeChange"}),e.jsx("td",{className:"py-2 pr-4 font-mono text-xs text-muted-foreground",children:"(mode) => void"}),e.jsx("td",{className:"py-2 pr-4 font-mono text-xs text-muted-foreground",children:"-"}),e.jsx("td",{className:"py-2 text-muted-foreground",children:"Callback ao trocar modo de visualização"})]}),e.jsxs("tr",{children:[e.jsx("td",{className:"py-2 pr-4 font-mono text-xs",children:"showViewToggle"}),e.jsx("td",{className:"py-2 pr-4 font-mono text-xs text-muted-foreground",children:"boolean"}),e.jsx("td",{className:"py-2 pr-4 font-mono text-xs text-muted-foreground",children:"false"}),e.jsx("td",{className:"py-2 text-muted-foreground",children:"Exibir toggle de visualização"})]})]})]})})})]}),e.jsxs(r,{children:[e.jsx(l,{children:e.jsx(n,{children:"Uso nos Componentes CRUD"})}),e.jsxs(d,{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"O CrudActionBar é usado internamente por todos os componentes CRUD de alto nível. Você pode configurá-lo através das props padrão:"}),e.jsxs(V,{defaultValue:"createCrudPage",className:"w-full",children:[e.jsxs(E,{children:[e.jsx(m,{value:"createCrudPage",children:"createCrudPage"}),e.jsx(m,{value:"CrudTable",children:"CrudTable"}),e.jsx(m,{value:"CrudGrid",children:"CrudGrid"})]}),e.jsx(h,{value:"createCrudPage",className:"mt-4",children:e.jsx("pre",{className:"bg-muted p-4 rounded-lg text-sm overflow-x-auto",children:`createCrudPage({
|
|
79
|
+
// ... outras configs
|
|
80
|
+
showNewButton: true,
|
|
81
|
+
newButtonLabel: 'Novo Treinamento',
|
|
82
|
+
showSearch: true,
|
|
83
|
+
searchPlaceholder: 'Buscar treinamentos...',
|
|
84
|
+
showActionBar: true,
|
|
85
|
+
enableBulkActions: true,
|
|
86
|
+
bulkActions: [
|
|
87
|
+
{ label: 'Exportar', onClick: handleExport },
|
|
88
|
+
],
|
|
89
|
+
})`})}),e.jsx(h,{value:"CrudTable",className:"mt-4",children:e.jsx("pre",{className:"bg-muted p-4 rounded-lg text-sm overflow-x-auto",children:`<CrudTable
|
|
90
|
+
manager={manager}
|
|
91
|
+
columns={columns}
|
|
92
|
+
// Action Bar props
|
|
93
|
+
showNewButton={true}
|
|
94
|
+
newButtonLabel="Novo Item"
|
|
95
|
+
showSearch={true}
|
|
96
|
+
searchPlaceholder="Buscar itens..."
|
|
97
|
+
showActionBar={true}
|
|
98
|
+
enableBulkActions={true}
|
|
99
|
+
bulkActions={bulkActions}
|
|
100
|
+
filters={<MyFilters />}
|
|
101
|
+
/>`})}),e.jsx(h,{value:"CrudGrid",className:"mt-4",children:e.jsx("pre",{className:"bg-muted p-4 rounded-lg text-sm overflow-x-auto",children:`<CrudGrid
|
|
102
|
+
manager={manager}
|
|
103
|
+
cardRenderer={renderCard}
|
|
104
|
+
// Action Bar props
|
|
105
|
+
showNewButton={true}
|
|
106
|
+
newButtonLabel="Novo Card"
|
|
107
|
+
showSearch={true}
|
|
108
|
+
showActionBar={true}
|
|
109
|
+
showViewToggle={true}
|
|
110
|
+
viewMode="grid"
|
|
111
|
+
onViewModeChange={setViewMode}
|
|
112
|
+
/>`})})]})]})]})]})}export{F as CrudActionBarDoc};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import{gf as Ce,r as o,j as e,gq as be,eD as ye,a2 as we,fh as ke,fi as Se,a as g,d as v,gt as le,o as T,gu as te,fj as Me,gv as Ie,a5 as Pe,a6 as Ee,a7 as de,aa as ie,b as se,c as ae,x as b,P as Te,d7 as De,K as O,b3 as Re,b4 as ne,a9 as ze,dY as ce,N as D,O as R,Q as z,R as A,V as d,ak as Ae,al as Fe,an as Ve,ao as H,aJ as Be,Y as j,U as Ge,y as oe,Z as Le,_ as $e,$ as Ue,B as W,a0 as qe,a1 as Oe,gs as He,E as me,G as xe,H as ue,I as he,J as F,X as je}from"./index-DkiftrvI.js";import{D as pe}from"./disabled-menu-item-C2YaMvSt.js";import{u as We,c as _e}from"./useMockCrud-CN4vjyOZ.js";import{C as Qe}from"./ComponentDocTemplate-CQbBhfvZ.js";import{P as ge}from"./pen-Bi_lmmKT.js";import"./ExampleCard-DuLrb3t-.js";const Je=({manager:r,columns:N,onEdit:t,onView:f,onToggleStatus:c,onDelete:m,renderActions:p,customRowActions:C,enableBulkActions:x=!1,onNew:V,newButtonLabel:_,showNewButton:i=!0,customActions:w=[],hideActionBar:B,showActionBar:Q=!0,showSearch:u=!1,searchValue:S,onSearchChange:G,searchPlaceholder:J,bulkActions:k=[],onBulkDelete:M,filters:I,gridColumns:n=3,renderCard:h,viewMode:X,onViewModeChange:Y,listCardRenderer:L,gridCardRenderer:$,showViewToggle:U=!1})=>{const{setSearchVisible:P}=Ce(),K=B!==void 0?!B:Q;o.useEffect(()=>{if(!u)return P(!0),()=>P(!1)},[P,u]);const Z=V||w.length>0||u||x||I||U,q=K&&Z,s=M||(()=>{r.bulkDelete?.(r.selectedIds)}),E=X||"grid",y=E==="list",ve={1:"grid-cols-1",2:"grid-cols-1 md:grid-cols-2",3:"grid-cols-1 md:grid-cols-2 lg:grid-cols-3",4:"grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4"}[y?1:n],Ne=a=>y&&L?L(a):!y&&$?$(a):h?h(a):null,ee=q?e.jsx(be,{onNew:V,newButtonLabel:_,showNewButton:i,showSearch:u,searchValue:S,onSearchChange:G,searchPlaceholder:J,showBulkActions:x,selectedCount:r.selectedIds.length,bulkActions:k,onBulkDelete:s,onClearSelection:r.clearSelection,customActions:w,filters:I,viewMode:E,onViewModeChange:Y,showViewToggle:U,availableViewModes:["list","grid"]}):null;return r.isLoading?e.jsxs("div",{className:"flex flex-col h-full",children:[ee,e.jsx("div",{className:"flex-1 overflow-auto p-4",children:e.jsx(ye,{count:6})})]}):r.entities.length===0?e.jsxs("div",{className:"flex flex-col h-full",children:[ee,e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(we,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"})})]}):e.jsxs("div",{className:"flex flex-col h-full",children:[ee,e.jsx("div",{className:"flex-1 overflow-auto p-4",children:e.jsx("div",{className:T("grid gap-4",ve),children:r.entities.map(a=>{const re=Ne(a);return e.jsxs(ke,{children:[e.jsx(Se,{asChild:!0,children:re?e.jsx("div",{className:"cursor-pointer",onClick:l=>{l.stopPropagation(),x?r.selectItem(a.id):t?.(a)},children:re}):e.jsx(g,{className:T("overflow-hidden cursor-pointer hover:bg-muted/50 transition-colors",x&&r.selectedIds.includes(a.id)&&"bg-muted ring-2 ring-primary",y&&"flex-row"),onClick:l=>{l.stopPropagation(),x?r.selectItem(a.id):t?.(a)},children:e.jsxs(v,{className:T("p-4",y&&"flex items-center gap-4 w-full"),children:[x&&e.jsx("div",{className:T(y?"":"pt-0.5"),onClick:l=>l.stopPropagation(),children:e.jsx(le,{checked:r.selectedIds.includes(a.id),onCheckedChange:()=>r.selectItem(a.id)})}),y?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex-1 flex items-center gap-6 min-w-0",children:N.map(l=>e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground shrink-0",children:[l.header,":"]}),e.jsx("div",{className:"text-sm text-foreground truncate",children:l.render?l.render(a):String(a[l.key]??"")})]},String(l.key)))}),(t||f||p)&&e.jsx("div",{onClick:l=>l.stopPropagation(),children:p?p(a):e.jsx(te,{onEdit:t?()=>t(a):void 0,onDelete:m?()=>m(a):void 0,onToggleStatus:c?()=>c(a):void 0,isActive:a.is_actived,customActions:C?C(a):[]})})]}):e.jsxs("div",{className:"flex items-start gap-3",children:[x&&e.jsx("div",{className:"pt-0.5",onClick:l=>l.stopPropagation(),children:e.jsx(le,{checked:r.selectedIds.includes(a.id),onCheckedChange:()=>r.selectItem(a.id)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[N.map((l,fe)=>e.jsxs("div",{className:T("flex justify-between items-start gap-2",fe!==N.length-1&&"mb-2"),children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground shrink-0",children:[l.header,":"]}),e.jsx("div",{className:"text-sm text-foreground text-right truncate",children:l.render?l.render(a):String(a[l.key]??"")})]},String(l.key))),(t||f||p)&&e.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:l=>l.stopPropagation(),children:p?p(a):e.jsx(te,{onEdit:t?()=>t(a):void 0,onDelete:m?()=>m(a):void 0,onToggleStatus:c?()=>c(a):void 0,isActive:a.is_actived,customActions:C?C(a):[]})})]})]})]})})}),e.jsx(Me,{className:"w-[160px]",children:e.jsx(Ie,{onEdit:t?()=>t(a):void 0,onDelete:m?()=>m(a):void 0,onToggleStatus:c?()=>c(a):void 0,isActive:a.is_actived,canDelete:!!m,customActions:C?C(a):[],renderAs:"context"})})]},a.id)})})})]})},Xe=Array.from({length:50},(r,N)=>{const t=N+1,f=["Eletrônicos","Móveis","Vestuário","Alimentos"],c=f[t%f.length],m=t%5===0?"Inativo":"Ativo";return _e({id:String(t),name:`Produto ${String(t).padStart(3,"0")}`,category:c,price:Math.floor(Math.random()*1e3)+50,stock:Math.floor(Math.random()*100),status:m})}),Ye=[{key:"name",header:"Nome",sortable:!0,minWidth:150},{key:"category",header:"Categoria",sortable:!0,minWidth:120},{key:"price",header:"Preço",sortable:!0,minWidth:100,render:r=>`R$ ${r.price.toFixed(2)}`},{key:"stock",header:"Estoque",sortable:!0,minWidth:80},{key:"status",header:"Status",sortable:!0,minWidth:80,render:r=>e.jsx(W,{variant:r.status==="Ativo"?"default":"secondary",children:r.status})}];function Ke(){const[r,N]=o.useState(""),[t,f]=o.useState(""),[c,m]=o.useState(""),[p,C]=o.useState(3),[x,V]=o.useState("grid"),_=o.useCallback(s=>{if(r&&s.category!==r||t&&s.status!==t)return!1;if(c){const E=c.toLowerCase();return s.name.toLowerCase().includes(E)||s.category.toLowerCase().includes(E)}return!0},[r,t,c]),i=We(Xe,{searchFields:["name","category"],pageSize:9,filterFn:_}),w=[r,t].filter(Boolean).length,B=()=>{N(""),f("")},[Q,u]=o.useState(!1),[S,G]=o.useState(null),[J,k]=o.useState(!1),[M,I]=o.useState(null),[n,h]=o.useState({name:"",category:"",price:0,stock:0,status:"Ativo"}),X=()=>{G(null),h({name:"",category:"",price:0,stock:0,status:"Ativo"}),u(!0)},Y=s=>{G(s),h({name:s.name,category:s.category,price:s.price,stock:s.stock,status:s.status}),u(!0)},L=s=>e.jsx(g,{className:"hover:bg-muted/50 transition-colors",children:e.jsx(v,{className:"p-4 flex items-center justify-between gap-4",children:e.jsxs("div",{className:"flex items-center gap-6 flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium truncate min-w-[120px]",children:s.name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s.category}),e.jsxs("div",{className:"text-sm font-medium",children:["R$ ",s.price.toFixed(2)]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Estoque: ",s.stock]}),e.jsx(W,{variant:s.status==="Ativo"?"default":"secondary",children:s.status})]})})}),$=s=>e.jsx(g,{className:"hover:bg-muted/50 transition-colors h-full",children:e.jsxs(v,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsx("h3",{className:"font-semibold truncate",children:s.name}),e.jsx(W,{variant:s.status==="Ativo"?"default":"secondary",className:"shrink-0 ml-2",children:s.status})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s.category}),e.jsxs("div",{className:"flex justify-between items-center pt-2 border-t",children:[e.jsxs("span",{className:"text-lg font-bold",children:["R$ ",s.price.toFixed(2)]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Estoque: ",s.stock]})]})]})}),U=async()=>{if(!n.name){j.error("Nome é obrigatório");return}S?(await i.updateEntity(S.id,n),j.success("Produto atualizado!")):(await i.createEntity(n),j.success("Produto criado!")),u(!1)},P=async s=>{await i.updateEntity(s.id,{status:s.status==="Ativo"?"Inativo":"Ativo"}),j.success("Status alterado!")},K=s=>{I(s),k(!0)},Z=()=>{M&&(i.deleteEntity(M.id),j.success("Produto excluído!")),k(!1),I(null)},q=s=>{if(i.selectedIds.length<2){j.info("Selecione dois ou mais itens");return}s==="edit"?j.info(`Editando ${i.selectedIds.length} itens em massa...`):(i.bulkDelete(i.selectedIds),j.success(`${i.selectedIds.length} itens 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(b,{className:"shrink-0",onClick:X,children:[e.jsx(Te,{className:"h-4 w-4 mr-2"}),"Adicionar produto"]}),e.jsx("div",{className:"flex-1 max-w-md",children:e.jsxs("div",{className:"relative",children:[e.jsx(De,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(O,{placeholder:"Buscar produtos...",value:c,onChange:s=>m(s.target.value),className:"pl-9"})]})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(Re,{type:"single",value:x,onValueChange:s=>s&&V(s),size:"sm",children:[e.jsx(ne,{value:"list","aria-label":"Visualização em lista",children:e.jsx(ze,{className:"h-4 w-4"})}),e.jsx(ne,{value:"grid","aria-label":"Visualização em grade",children:e.jsx(ce,{className:"h-4 w-4"})})]}),x==="grid"&&e.jsxs(D,{value:String(p),onValueChange:s=>C(Number(s)),children:[e.jsxs(R,{className:"w-[100px]",children:[e.jsx(ce,{className:"h-4 w-4 mr-2"}),e.jsx(z,{})]}),e.jsxs(A,{children:[e.jsx(d,{value:"1",children:"1 col"}),e.jsx(d,{value:"2",children:"2 cols"}),e.jsx(d,{value:"3",children:"3 cols"}),e.jsx(d,{value:"4",children:"4 cols"})]})]}),e.jsxs(Ae,{children:[e.jsx(Fe,{asChild:!0,children:e.jsx(b,{variant:"outline",className:"shrink-0",children:"Ações"})}),e.jsxs(Ve,{children:[e.jsxs(H,{onClick:()=>j.info("Exportando..."),children:[e.jsx(Be,{className:"h-4 w-4 mr-2"}),"Exportar"]}),e.jsxs(H,{onClick:()=>j.info("Importando..."),children:[e.jsx(Ge,{className:"h-4 w-4 mr-2"}),"Importar"]}),i.selectedIds.length<2?e.jsxs(pe,{disabledReason:"Selecione ao menos 2 itens",children:[e.jsx(ge,{className:"h-4 w-4 mr-2"}),"Edição em massa"]}):e.jsxs(H,{onClick:()=>q("edit"),children:[e.jsx(ge,{className:"h-4 w-4 mr-2"}),"Edição em massa"]}),i.selectedIds.length<2?e.jsxs(pe,{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(H,{onClick:()=>q("delete"),className:"text-destructive",children:[e.jsx(oe,{className:"h-4 w-4 mr-2"}),"Exclusão em massa"]})]})]}),e.jsxs(Le,{children:[e.jsx($e,{asChild:!0,children:e.jsxs(b,{variant:"outline",className:"shrink-0",children:[e.jsx(Ue,{className:"h-4 w-4 mr-2"}),"Filtrar",w>0&&e.jsx(W,{variant:"secondary",className:"ml-2 h-5 w-5 p-0 flex items-center justify-center",children:w})]})}),e.jsx(qe,{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(b,{variant:"ghost",size:"sm",onClick:B,className:"h-8 px-2 text-muted-foreground",children:[e.jsx(Oe,{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(D,{value:r||"all",onValueChange:s=>N(s==="all"?"":s),children:[e.jsx(R,{children:e.jsx(z,{placeholder:"Todas"})}),e.jsxs(A,{children:[e.jsx(d,{value:"all",children:"Todas"}),e.jsx(d,{value:"Eletrônicos",children:"Eletrônicos"}),e.jsx(d,{value:"Móveis",children:"Móveis"}),e.jsx(d,{value:"Vestuário",children:"Vestuário"}),e.jsx(d,{value:"Alimentos",children:"Alimentos"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium",children:"Status"}),e.jsxs(D,{value:t||"all",onValueChange:s=>f(s==="all"?"":s),children:[e.jsx(R,{children:e.jsx(z,{placeholder:"Todos"})}),e.jsxs(A,{children:[e.jsx(d,{value:"all",children:"Todos"}),e.jsx(d,{value:"Ativo",children:"Ativo"}),e.jsx(d,{value:"Inativo",children:"Inativo"})]})]})]})]})]})})]})]})]}),e.jsx(Je,{manager:i,columns:Ye,onEdit:Y,onToggleStatus:P,onDelete:K,enableBulkActions:!0,hideActionBar:!0,gridColumns:p,viewMode:x,listCardRenderer:L,gridCardRenderer:$}),e.jsx("div",{className:"border-t p-2",children:e.jsx(He,{manager:i})}),e.jsx(me,{open:Q,onOpenChange:u,children:e.jsxs(xe,{children:[e.jsx(ue,{children:e.jsx(he,{children:S?"Editar Produto":"Novo Produto"})}),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(F,{htmlFor:"name",children:"Nome"}),e.jsx(O,{id:"name",value:n.name,onChange:s=>h({...n,name:s.target.value}),placeholder:"Nome do produto"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(F,{htmlFor:"category",children:"Categoria"}),e.jsxs(D,{value:n.category,onValueChange:s=>h({...n,category:s}),children:[e.jsx(R,{children:e.jsx(z,{placeholder:"Selecione"})}),e.jsxs(A,{children:[e.jsx(d,{value:"Eletrônicos",children:"Eletrônicos"}),e.jsx(d,{value:"Móveis",children:"Móveis"}),e.jsx(d,{value:"Vestuário",children:"Vestuário"}),e.jsx(d,{value:"Alimentos",children:"Alimentos"})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(F,{htmlFor:"price",children:"Preço"}),e.jsx(O,{id:"price",type:"number",value:n.price,onChange:s=>h({...n,price:Number(s.target.value)})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(F,{htmlFor:"stock",children:"Estoque"}),e.jsx(O,{id:"stock",type:"number",value:n.stock,onChange:s=>h({...n,stock:Number(s.target.value)})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(F,{htmlFor:"status",children:"Status"}),e.jsxs(D,{value:n.status,onValueChange:s=>h({...n,status:s}),children:[e.jsx(R,{children:e.jsx(z,{})}),e.jsxs(A,{children:[e.jsx(d,{value:"Ativo",children:"Ativo"}),e.jsx(d,{value:"Inativo",children:"Inativo"})]})]})]})]})]}),e.jsxs(je,{children:[e.jsx(b,{variant:"outline",onClick:()=>u(!1),children:"Cancelar"}),e.jsx(b,{onClick:U,children:"Salvar"})]})]})}),e.jsx(me,{open:J,onOpenChange:k,children:e.jsxs(xe,{size:"sm",children:[e.jsx(ue,{children:e.jsx(he,{children:"Confirmar Exclusão"})}),e.jsxs("p",{className:"py-4",children:["Deseja realmente excluir o produto ",e.jsx("strong",{children:M?.name}),"?"]}),e.jsxs(je,{children:[e.jsx(b,{variant:"outline",onClick:()=>k(!1),children:"Cancelar"}),e.jsx(b,{variant:"destructive",onClick:Z,children:"Excluir"})]})]})})]})}const Ze=`import { CrudGrid, CrudPagination, useCrud } from 'forlogic-core';
|
|
2
|
+
|
|
3
|
+
const columns = [
|
|
4
|
+
{ key: 'name', header: 'Nome', sortable: true },
|
|
5
|
+
{ key: 'category', header: 'Categoria', sortable: true },
|
|
6
|
+
{ key: 'price', header: 'Preço', render: (item) => \`R$ \${item.price.toFixed(2)}\` },
|
|
7
|
+
{ key: 'status', header: 'Status', render: (item) => <Badge>{item.status}</Badge> },
|
|
8
|
+
];
|
|
9
|
+
|
|
10
|
+
function ProductsGrid() {
|
|
11
|
+
const manager = useCrud(productService);
|
|
12
|
+
const [viewMode, setViewMode] = useState<'list' | 'grid'>('grid');
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<>
|
|
16
|
+
<CrudGrid
|
|
17
|
+
manager={manager}
|
|
18
|
+
columns={columns}
|
|
19
|
+
onNew={handleNew}
|
|
20
|
+
onEdit={handleEdit}
|
|
21
|
+
onDelete={handleDelete}
|
|
22
|
+
gridColumns={3}
|
|
23
|
+
enableBulkActions
|
|
24
|
+
viewMode={viewMode}
|
|
25
|
+
onViewModeChange={setViewMode}
|
|
26
|
+
showViewToggle
|
|
27
|
+
/>
|
|
28
|
+
<CrudPagination manager={manager} />
|
|
29
|
+
</>
|
|
30
|
+
);
|
|
31
|
+
}`,es=`// Exemplo com toggle List/Grid e renderizadores distintos
|
|
32
|
+
const [viewMode, setViewMode] = useState<'list' | 'grid'>('grid');
|
|
33
|
+
|
|
34
|
+
// Renderizador para modo lista (horizontal)
|
|
35
|
+
const listCardRenderer = (item) => (
|
|
36
|
+
<Card className="hover:bg-muted/50">
|
|
37
|
+
<CardContent className="p-4 flex items-center justify-between gap-4">
|
|
38
|
+
<div className="font-medium">{item.name}</div>
|
|
39
|
+
<div className="text-muted-foreground">{item.category}</div>
|
|
40
|
+
<span className="font-bold">R$ {item.price}</span>
|
|
41
|
+
<Badge>{item.status}</Badge>
|
|
42
|
+
</CardContent>
|
|
43
|
+
</Card>
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
// Renderizador para modo grade (vertical)
|
|
47
|
+
const gridCardRenderer = (item) => (
|
|
48
|
+
<Card className="hover:bg-muted/50 h-full">
|
|
49
|
+
<CardContent className="p-4 space-y-3">
|
|
50
|
+
<h3 className="font-semibold">{item.name}</h3>
|
|
51
|
+
<div className="text-muted-foreground">{item.category}</div>
|
|
52
|
+
<div className="flex justify-between items-center pt-2 border-t">
|
|
53
|
+
<span className="font-bold">R$ {item.price}</span>
|
|
54
|
+
<Badge>{item.status}</Badge>
|
|
55
|
+
</div>
|
|
56
|
+
</CardContent>
|
|
57
|
+
</Card>
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
<CrudGrid
|
|
61
|
+
manager={manager}
|
|
62
|
+
columns={columns}
|
|
63
|
+
viewMode={viewMode}
|
|
64
|
+
onViewModeChange={setViewMode}
|
|
65
|
+
listCardRenderer={listCardRenderer}
|
|
66
|
+
gridCardRenderer={gridCardRenderer}
|
|
67
|
+
gridColumns={3}
|
|
68
|
+
/>`,ss=`<CrudGrid
|
|
69
|
+
manager={manager}
|
|
70
|
+
columns={columns}
|
|
71
|
+
gridColumns={4}
|
|
72
|
+
renderCard={(item) => (
|
|
73
|
+
<Card className="hover:shadow-lg transition-shadow">
|
|
74
|
+
<CardContent className="p-4">
|
|
75
|
+
<img src={item.image} className="w-full h-32 object-cover rounded" />
|
|
76
|
+
<h3 className="font-semibold mt-2">{item.name}</h3>
|
|
77
|
+
<p className="text-muted-foreground">{item.category}</p>
|
|
78
|
+
<div className="flex justify-between items-center mt-2">
|
|
79
|
+
<span className="font-bold">R$ {item.price}</span>
|
|
80
|
+
<Badge>{item.status}</Badge>
|
|
81
|
+
</div>
|
|
82
|
+
</CardContent>
|
|
83
|
+
</Card>
|
|
84
|
+
)}
|
|
85
|
+
/>`;function cs(){return e.jsxs(Qe,{title:"CrudGrid",description:"Componente para exibir dados em formato de grade (cards) com todas as funcionalidades CRUD. Alternativa visual ao CrudTable para listagens com layout mais visual.",tocItems:[{id:"exemplo-interativo",label:"Exemplo Interativo"},{id:"alternancia-list-grid",label:"Alternância List/Grid"},{id:"card-customizado",label:"Card Customizado"},{id:"funcionalidades",label:"Funcionalidades"},{id:"props-principais",label:"Props Principais"},{id:"quando-usar",label:"Quando Usar"}],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(Pe,{defaultValue:"preview",className:"w-full",children:[e.jsxs(Ee,{children:[e.jsx(de,{value:"preview",children:"Preview"}),e.jsx(de,{value:"code",children:"Código"})]}),e.jsx(ie,{value:"preview",children:e.jsx(Ke,{})}),e.jsx(ie,{value:"code",children:e.jsx(g,{children:e.jsx(v,{className:"p-4",children:e.jsx("pre",{className:"text-sm overflow-auto max-h-96",children:e.jsx("code",{children:Ze})})})})})]})]}),e.jsxs("section",{id:"alternancia-list-grid",className:"space-y-4 scroll-mt-4",children:[e.jsx("h2",{className:"text-2xl font-semibold",children:"Alternância List/Grid"}),e.jsxs("p",{className:"text-muted-foreground",children:["Use as props ",e.jsx("code",{children:"viewMode"}),", ",e.jsx("code",{children:"listCardRenderer"})," e ",e.jsx("code",{children:"gridCardRenderer"})," para criar dois layouts visuais distintos que o usuário pode alternar."]}),e.jsx(g,{children:e.jsx(v,{className:"p-4",children:e.jsx("pre",{className:"text-sm overflow-auto max-h-96",children:e.jsx("code",{children:es})})})})]}),e.jsxs("section",{id:"card-customizado",className:"space-y-4 scroll-mt-4",children:[e.jsx("h2",{className:"text-2xl font-semibold",children:"Card Customizado (Simples)"}),e.jsxs("p",{className:"text-muted-foreground",children:["Para um único layout customizado, use ",e.jsx("code",{children:"renderCard"})," como fallback."]}),e.jsx(g,{children:e.jsx(v,{className:"p-4",children:e.jsx("pre",{className:"text-sm overflow-auto",children:e.jsx("code",{children:ss})})})})]}),e.jsxs(g,{id:"funcionalidades",className:"scroll-mt-4",children:[e.jsx(se,{children:e.jsx(ae,{children:"Funcionalidades"})}),e.jsx(v,{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:"Toggle List/Grid:"})," Alterne entre visualização em lista e grade com ",e.jsx("code",{children:"viewMode"})]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Renderizadores distintos:"})," Use ",e.jsx("code",{children:"listCardRenderer"})," e ",e.jsx("code",{children:"gridCardRenderer"})," para layouts específicos"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Grid Responsivo:"})," 1 a 4 colunas configuráveis via prop ",e.jsx("code",{children:"gridColumns"})]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Cards Customizados:"})," Use ",e.jsx("code",{children:"renderCard"})," para layout personalizado único"]}),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:"Context Menu:"})," Clique direito para ações rápidas"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Action Bar:"})," Barra de ações integrada (botão novo, toggle de visualização)"]})]})})]}),e.jsxs(g,{id:"props-principais",className:"scroll-mt-4",children:[e.jsx(se,{children:e.jsx(ae,{children:"Props Principais"})}),e.jsx(v,{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/campos do card padrão"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"gridColumns"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"1 | 2 | 3 | 4"}),e.jsx("td",{className:"p-2",children:"Número de colunas do grid (padrão: 3)"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"viewMode"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"'list' | 'grid'"}),e.jsx("td",{className:"p-2",children:"Modo de visualização atual"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"onViewModeChange"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"(mode) => void"}),e.jsx("td",{className:"p-2",children:"Callback ao mudar visualização"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"listCardRenderer"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"(item: T) => ReactNode"}),e.jsx("td",{className:"p-2",children:"Renderiza card em modo lista (horizontal)"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"gridCardRenderer"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"(item: T) => ReactNode"}),e.jsx("td",{className:"p-2",children:"Renderiza card em modo grade (vertical)"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"showViewToggle"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"boolean"}),e.jsx("td",{className:"p-2",children:"Exibe botões de alternância List/Grid na toolbar"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"renderCard"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"(item: T) => ReactNode"}),e.jsx("td",{className:"p-2",children:"Fallback para card customizado único"})]}),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:"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:"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"})]})]})]})})})]}),e.jsxs(g,{id:"quando-usar",className:"scroll-mt-4",children:[e.jsx(se,{children:e.jsx(ae,{children:"Quando Usar"})}),e.jsxs(v,{children:[e.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:["Use o ",e.jsx("code",{children:"CrudGrid"})," quando precisar de uma visualização mais visual dos dados, como catálogos de produtos, galerias ou listagens onde o layout de card é mais apropriado."]}),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:"CrudTable"})," - Para dados tabulares com muitas colunas"]}),e.jsxs("li",{children:[e.jsx("code",{children:"CrudGrid"})," - Para visualização em cards/galeria"]}),e.jsxs("li",{children:[e.jsx("code",{children:"createCrudPage"})," - Para gerar página completa automaticamente"]})]})]})]})]})}export{cs as CrudGridDoc};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import{j as e,a as s,b as a,dW as m,B as n,c as r,e as i,d,dw as t,eo as x,A as l,dK as u,F as p}from"./index-DkiftrvI.js";import{B as h}from"./blocks-B6LrJeAM.js";function b({onNavigate:o}){const c=j=>{o&&o(j)};return e.jsxs("div",{className:"space-y-12",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:"Sistema CRUD"}),e.jsx("p",{className:"text-lg text-muted-foreground mt-2",children:"Componentes padronizados para operações Create, Read, Update e Delete com arquitetura em 3 níveis de abstração."})]}),e.jsxs("section",{className:"space-y-6",children:[e.jsx("h2",{className:"text-2xl font-semibold",children:"Arquitetura em 3 Níveis"}),e.jsxs("p",{className:"text-muted-foreground",children:["O sistema CRUD da ",e.jsx("code",{children:"forlogic-core"})," é organizado em 3 níveis de abstração, permitindo desde implementações rápidas até personalizações completas."]}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-3",children:[e.jsxs(s,{className:"border-primary/50 cursor-pointer hover:bg-accent/50 transition-colors",onClick:()=>c("crud-create-page"),children:[e.jsxs(a,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-2 rounded-lg bg-primary/10",children:e.jsx(m,{className:"h-5 w-5 text-primary"})}),e.jsx(n,{variant:"default",children:"Alto Nível"})]}),e.jsx(r,{className:"mt-4",children:"createCrudPage"}),e.jsx(i,{children:"Página CRUD completa gerada automaticamente"})]}),e.jsxs(d,{className:"space-y-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:[e.jsx("p",{className:"font-medium text-foreground mb-2",children:"Inclui automaticamente:"}),e.jsxs("ul",{className:"space-y-1",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(t,{className:"h-3.5 w-3.5 text-green-500"}),"Tabela com ordenação"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(t,{className:"h-3.5 w-3.5 text-green-500"}),"Formulário em dialog"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(t,{className:"h-3.5 w-3.5 text-green-500"}),"Filtros e busca"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(t,{className:"h-3.5 w-3.5 text-green-500"}),"Paginação"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(t,{className:"h-3.5 w-3.5 text-green-500"}),"Ações em massa"]})]})]}),e.jsx("div",{className:"pt-2 border-t",children:e.jsxs("p",{className:"text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"Esforço:"})," ~10 linhas de configuração"]})})]})]}),e.jsxs(s,{className:"border-blue-500/50 cursor-pointer hover:bg-accent/50 transition-colors",onClick:()=>c("crud-table"),children:[e.jsxs(a,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-2 rounded-lg bg-blue-500/10",children:e.jsx(x,{className:"h-5 w-5 text-blue-500"})}),e.jsx(n,{variant:"secondary",className:"bg-blue-500/10 text-blue-500",children:"Médio Nível"})]}),e.jsx(r,{className:"mt-4",children:"Componentes CRUD"}),e.jsx(i,{children:"Componentes individuais para composição"})]}),e.jsxs(d,{className:"space-y-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:[e.jsx("p",{className:"font-medium text-foreground mb-2",children:"Componentes disponíveis:"}),e.jsxs("ul",{className:"space-y-1",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(l,{className:"h-3.5 w-3.5"}),"CrudTable"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(l,{className:"h-3.5 w-3.5"}),"CrudGrid"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(l,{className:"h-3.5 w-3.5"}),"BaseForm"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(l,{className:"h-3.5 w-3.5"}),"CrudPagination"]})]})]}),e.jsx("div",{className:"pt-2 border-t",children:e.jsxs("p",{className:"text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"Esforço:"})," ~50-100 linhas de código"]})})]})]}),e.jsxs(s,{className:"border-orange-500/50 cursor-pointer hover:bg-accent/50 transition-colors",onClick:()=>c("crud-primitives"),children:[e.jsxs(a,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-2 rounded-lg bg-orange-500/10",children:e.jsx(h,{className:"h-5 w-5 text-orange-500"})}),e.jsx(n,{variant:"outline",className:"border-orange-500/50 text-orange-500",children:"Baixo Nível"})]}),e.jsx(r,{className:"mt-4",children:"Primitives"}),e.jsx(i,{children:"Blocos básicos para UIs totalmente customizadas"})]}),e.jsxs(d,{className:"space-y-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:[e.jsx("p",{className:"font-medium text-foreground mb-2",children:"Primitives disponíveis:"}),e.jsxs("ul",{className:"space-y-1",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(l,{className:"h-3.5 w-3.5"}),"Table + ActionButton"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(l,{className:"h-3.5 w-3.5"}),"CrudPrimitivePagination"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(l,{className:"h-3.5 w-3.5"}),"CrudPrimitiveFilterBar"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(l,{className:"h-3.5 w-3.5"}),"CrudPrimitiveFilterPopover"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(l,{className:"h-3.5 w-3.5"}),"TableResizeHandle + useColumnResize"]})]})]}),e.jsx("div",{className:"pt-2 border-t",children:e.jsxs("p",{className:"text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"Esforço:"})," 200+ linhas de código"]})})]})]})]})]}),e.jsxs("section",{className:"space-y-6",children:[e.jsx("h2",{className:"text-2xl font-semibold",children:"Quando Usar Qual Componente?"}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b bg-muted/50",children:[e.jsx("th",{className:"text-left p-4 font-medium",children:"Cenário"}),e.jsx("th",{className:"text-left p-4 font-medium",children:"Componente"}),e.jsx("th",{className:"text-left p-4 font-medium",children:"Esforço"})]})}),e.jsxs("tbody",{children:[e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-4",children:"CRUD padrão (lista + formulário + filtros)"}),e.jsx("td",{className:"p-4",children:e.jsx("code",{className:"text-sm bg-primary/10 text-primary px-2 py-1 rounded",children:"createCrudPage"})}),e.jsx("td",{className:"p-4 text-muted-foreground",children:"~10 linhas"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-4",children:"Tabela com layout customizado"}),e.jsx("td",{className:"p-4",children:e.jsx("code",{className:"text-sm bg-blue-500/10 text-blue-500 px-2 py-1 rounded",children:"CrudTable + useCrud"})}),e.jsx("td",{className:"p-4 text-muted-foreground",children:"~50 linhas"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-4",children:"Visualização em grid/cards"}),e.jsx("td",{className:"p-4",children:e.jsx("code",{className:"text-sm bg-blue-500/10 text-blue-500 px-2 py-1 rounded",children:"CrudGrid"})}),e.jsx("td",{className:"p-4 text-muted-foreground",children:"~50 linhas"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-4",children:"Formulário multi-step"}),e.jsx("td",{className:"p-4",children:e.jsx("code",{className:"text-sm bg-blue-500/10 text-blue-500 px-2 py-1 rounded",children:"WizardForm"})}),e.jsx("td",{className:"p-4 text-muted-foreground",children:"~30 linhas"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-4",children:"UI totalmente customizada"}),e.jsx("td",{className:"p-4",children:e.jsx("code",{className:"text-sm bg-orange-500/10 text-orange-500 px-2 py-1 rounded",children:"Primitives"})}),e.jsx("td",{className:"p-4 text-muted-foreground",children:"200+ linhas"})]})]})]})})]}),e.jsxs("section",{className:"space-y-6",children:[e.jsx("h2",{className:"text-2xl font-semibold",children:"Boas Práticas"}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsxs(s,{className:"border-green-500/20 bg-green-500/5",children:[e.jsx(a,{children:e.jsxs(r,{className:"text-green-600 flex items-center gap-2",children:[e.jsx(t,{className:"h-5 w-5"}),"Faça"]})}),e.jsx(d,{children:e.jsxs("ul",{className:"space-y-2 text-sm",children:[e.jsxs("li",{children:["✅ Use ",e.jsx("code",{children:"createCrudPage"})," para CRUDs padrão"]}),e.jsxs("li",{children:["✅ Use ",e.jsx("code",{children:"CrudTable"})," para customizações de layout"]}),e.jsxs("li",{children:["✅ Use ",e.jsx("code",{children:"CrudGrid"})," para visualização em cards"]}),e.jsxs("li",{children:["✅ Use ",e.jsx("code",{children:"BaseForm"})," para formulários com validação Zod"]}),e.jsxs("li",{children:["✅ Use ",e.jsx("code",{children:"useCrud"})," para gerenciamento de estado"]}),e.jsx("li",{children:"✅ Reutilize os hooks existentes"})]})})]}),e.jsxs(s,{className:"border-red-500/20 bg-red-500/5",children:[e.jsx(a,{children:e.jsxs(r,{className:"text-red-600 flex items-center gap-2",children:[e.jsx("span",{className:"h-5 w-5 flex items-center justify-center",children:"✕"}),"Evite"]})}),e.jsx(d,{children:e.jsxs("ul",{className:"space-y-2 text-sm",children:[e.jsxs("li",{children:["❌ Recriar tabelas do zero com ",e.jsx("code",{children:"<Table>"})," base"]}),e.jsx("li",{children:"❌ Implementar paginação manual"}),e.jsxs("li",{children:["❌ Criar formulários sem ",e.jsx("code",{children:"BaseForm"})]}),e.jsx("li",{children:"❌ Duplicar lógica CRUD em cada página"}),e.jsx("li",{children:"❌ Usar Primitives quando componentes de alto nível servem"})]})})]})]})]}),e.jsxs("section",{className:"space-y-6",children:[e.jsx("h2",{className:"text-2xl font-semibold",children:"Integração com useCrud"}),e.jsxs("p",{className:"text-muted-foreground",children:["O hook ",e.jsx("code",{children:"useCrud"})," gerencia todo o estado do CRUD: busca, ordenação, paginação, seleção e operações de create/update/delete. Ele é usado internamente pelo ",e.jsx("code",{children:"createCrudPage"}),"e pode ser usado diretamente com os componentes de nível médio."]}),e.jsxs(s,{children:[e.jsx(a,{children:e.jsx(r,{children:"Exemplo de uso com createSimpleService"})}),e.jsx(d,{children:e.jsx("pre",{className:"bg-muted p-4 rounded-lg overflow-x-auto text-sm",children:`// 1. Criar o serviço
|
|
2
|
+
const notesService = createSimpleService<Note>({
|
|
3
|
+
tableName: 'notes',
|
|
4
|
+
entityName: 'nota',
|
|
5
|
+
searchFields: ['title', 'content'],
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
// 2. Usar o hook em um componente
|
|
9
|
+
function NotesPage() {
|
|
10
|
+
const manager = notesService.useCrudHook();
|
|
11
|
+
|
|
12
|
+
// 3. Usar createCrudPage ou componentes individuais
|
|
13
|
+
return <CrudTable manager={manager} columns={columns} />;
|
|
14
|
+
}`})})]})]}),e.jsxs("section",{className:"space-y-6",children:[e.jsx("h2",{className:"text-2xl font-semibold",children:"Documentação Detalhada"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[e.jsx(s,{className:"hover:border-primary/50 transition-colors cursor-pointer",onClick:()=>c("crud-create-page"),children:e.jsxs(a,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(m,{className:"h-5 w-5 text-primary"}),e.jsx(r,{className:"text-base",children:"createCrudPage"})]}),e.jsx(i,{children:"Gerador de página CRUD completa"})]})}),e.jsx(s,{className:"hover:border-primary/50 transition-colors cursor-pointer",onClick:()=>c("crud-table"),children:e.jsxs(a,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(x,{className:"h-5 w-5 text-blue-500"}),e.jsx(r,{className:"text-base",children:"CrudTable"})]}),e.jsx(i,{children:"Tabela CRUD com ordenação, seleção e ações"})]})}),e.jsx(s,{className:"hover:border-primary/50 transition-colors cursor-pointer",onClick:()=>c("crud-grid"),children:e.jsxs(a,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(u,{className:"h-5 w-5 text-blue-500"}),e.jsx(r,{className:"text-base",children:"CrudGrid"})]}),e.jsx(i,{children:"Visualização em cards com lista/grid toggle"})]})}),e.jsx(s,{className:"hover:border-primary/50 transition-colors cursor-pointer",onClick:()=>c("crud-primitives"),children:e.jsxs(a,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(h,{className:"h-5 w-5 text-orange-500"}),e.jsx(r,{className:"text-base",children:"Primitives"})]}),e.jsx(i,{children:"Blocos de baixo nível para UIs customizadas"})]})}),e.jsx(s,{className:"hover:border-primary/50 transition-colors cursor-pointer",onClick:()=>c("crud-baseform"),children:e.jsxs(a,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{className:"h-5 w-5 text-blue-500"}),e.jsx(r,{className:"text-base",children:"BaseForm"})]}),e.jsx(i,{children:"Formulário com validação Zod e tipos de campo"})]})})]})]})]})}export{b as CrudOverviewDoc};
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import{f as $,r as l,j as e,a as t,b as r,c as d,d as i,a5 as w,a6 as y,a7 as c,aX as N,dy as T,aa as n,T as Z,i as _,k as H,l as E,n as J,p as Y,q as g,B as q,ak as ee,al as se,aV as ae,an as le,ao as b,aW as te,a$ as re,y as de,N as m,O as x,Q as h,R as u,V as a,Z as ie,_ as ce,x as o,$ as ne,a0 as oe,a1 as me,w as xe}from"./index-DkiftrvI.js";import{C as he}from"./ComponentDocTemplate-CQbBhfvZ.js";import{F as U}from"./FilterBar-DDTqqUfZ.js";import"./ExampleCard-DuLrb3t-.js";function ge(){const L=[{id:"1",name:"Item Alpha",category:"Categoria A",status:"active"},{id:"2",name:"Item Beta",category:"Categoria B",status:"active"},{id:"3",name:"Item Gamma",category:"Categoria A",status:"inactive"},{id:"4",name:"Item Delta",category:"Categoria C",status:"active"},{id:"5",name:"Item Epsilon",category:"Categoria B",status:"inactive"}],P=[{key:"name",header:"Nome",minWidth:150},{key:"category",header:"Categoria",minWidth:120},{key:"status",header:"Status",minWidth:100}],{columnWidths:O,isDragging:X,handleMouseDown:K}=$({columns:P.map(s=>({key:s.key,minWidth:s.minWidth,defaultWidth:s.minWidth})),storageKey:"crud-primitives-table"}),[D,F]=l.useState(""),[z,B]=l.useState("all"),[k,I]=l.useState("all"),[M,V]=l.useState(""),[v,R]=l.useState("all"),[f,A]=l.useState("all"),[C,W]=l.useState("all"),j=(s,S)=>O[s]||S,Q=()=>{F(""),B("all"),I("all")},G=()=>{V(""),R("all"),A("all"),W("all")},p=[v,f,C].filter(s=>s!=="all").length+(M?1:0);return e.jsxs(he,{title:"CRUD Primitives",description:"Componentes de baixo nível para interfaces CRUD totalmente customizadas com controle total sobre layout e comportamento.",tocItems:[{id:"table-actionbutton",label:"Table + ActionButton"},{id:"filterbar",label:"CrudPrimitiveFilterBar"},{id:"filterpopover",label:"CrudPrimitiveFilterPopover"},{id:"props",label:"Props"},{id:"acessibilidade",label:"Acessibilidade"},{id:"quando-usar",label:"Quando Usar"}],children:[e.jsxs(t,{id:"table-actionbutton",className:"scroll-mt-4",children:[e.jsx(r,{children:e.jsx(d,{children:"Table + ActionButton"})}),e.jsx(i,{children:e.jsxs(w,{defaultValue:"preview",className:"w-full",children:[e.jsxs(y,{className:"mb-4",children:[e.jsxs(c,{value:"preview",className:"gap-2",children:[e.jsx(N,{size:16}),"Preview"]}),e.jsxs(c,{value:"code",className:"gap-2",children:[e.jsx(T,{size:16}),"Código"]})]}),e.jsx(n,{value:"preview",className:"mt-0",children:e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsxs(Z,{children:[e.jsx(_,{children:e.jsxs(H,{children:[P.map(s=>e.jsxs(E,{className:"relative",style:{width:j(s.key,s.minWidth),minWidth:s.minWidth},children:[s.header,e.jsx(J,{direction:"horizontal",onMouseDown:S=>K(s.key,S),isDragging:X})]},s.key)),e.jsx(E,{className:"w-16",children:"Ações"})]})}),e.jsx(Y,{children:L.map(s=>e.jsxs(H,{children:[e.jsx(g,{style:{width:j("name",150)},children:s.name}),e.jsx(g,{style:{width:j("category",120)},children:s.category}),e.jsx(g,{style:{width:j("status",100)},children:e.jsx(q,{variant:s.status==="active"?"default":"secondary",children:s.status==="active"?"Ativo":"Inativo"})}),e.jsx(g,{children:e.jsxs(ee,{children:[e.jsx(se,{asChild:!0,children:e.jsx(ae,{})}),e.jsxs(le,{align:"end",children:[e.jsxs(b,{children:[e.jsx(N,{className:"h-4 w-4 mr-2"}),"Visualizar"]}),e.jsxs(b,{children:[e.jsx(te,{className:"h-4 w-4 mr-2"}),"Editar"]}),e.jsxs(b,{children:[e.jsx(re,{className:"h-4 w-4 mr-2"}),"Duplicar"]}),e.jsxs(b,{className:"text-destructive",children:[e.jsx(de,{className:"h-4 w-4 mr-2"}),"Excluir"]})]})]})})]},s.id))})]})})}),e.jsx(n,{value:"code",className:"mt-0",children:e.jsx("pre",{className:"bg-muted p-4 rounded-lg text-sm overflow-x-auto",children:`import {
|
|
2
|
+
Table, TableHeader, TableBody, TableRow, TableHead, TableCell,
|
|
3
|
+
DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem,
|
|
4
|
+
ActionButton, Badge, TableResizeHandle, useColumnResize
|
|
5
|
+
} from 'forlogic-core';
|
|
6
|
+
|
|
7
|
+
function MyTable({ data }) {
|
|
8
|
+
const columns = [
|
|
9
|
+
{ key: 'name', minWidth: 150 },
|
|
10
|
+
{ key: 'category', minWidth: 120 },
|
|
11
|
+
{ key: 'status', minWidth: 100 },
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
const { columnWidths, isDragging, handleMouseDown } = useColumnResize({
|
|
15
|
+
columns: columns.map(c => ({ key: c.key, minWidth: c.minWidth })),
|
|
16
|
+
storageKey: 'my-table-columns',
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<Table>
|
|
21
|
+
<TableHeader>
|
|
22
|
+
<TableRow>
|
|
23
|
+
<TableHead className="relative" style={{ width: columnWidths['name'] || 150 }}>
|
|
24
|
+
Nome
|
|
25
|
+
<TableResizeHandle
|
|
26
|
+
direction="horizontal"
|
|
27
|
+
onMouseDown={(e) => handleMouseDown('name', e)}
|
|
28
|
+
isDragging={isDragging}
|
|
29
|
+
/>
|
|
30
|
+
</TableHead>
|
|
31
|
+
{/* ... outras colunas */}
|
|
32
|
+
<TableHead className="w-12"></TableHead>
|
|
33
|
+
</TableRow>
|
|
34
|
+
</TableHeader>
|
|
35
|
+
<TableBody>
|
|
36
|
+
{data.map((item) => (
|
|
37
|
+
<TableRow key={item.id}>
|
|
38
|
+
<TableCell>{item.name}</TableCell>
|
|
39
|
+
{/* ... outras células */}
|
|
40
|
+
<TableCell>
|
|
41
|
+
<DropdownMenu>
|
|
42
|
+
<DropdownMenuTrigger asChild>
|
|
43
|
+
<ActionButton />
|
|
44
|
+
</DropdownMenuTrigger>
|
|
45
|
+
<DropdownMenuContent align="end">
|
|
46
|
+
<DropdownMenuItem>Editar</DropdownMenuItem>
|
|
47
|
+
<DropdownMenuItem className="text-destructive">Excluir</DropdownMenuItem>
|
|
48
|
+
</DropdownMenuContent>
|
|
49
|
+
</DropdownMenu>
|
|
50
|
+
</TableCell>
|
|
51
|
+
</TableRow>
|
|
52
|
+
))}
|
|
53
|
+
</TableBody>
|
|
54
|
+
</Table>
|
|
55
|
+
);
|
|
56
|
+
}`})})]})})]}),e.jsxs(t,{id:"filterbar",className:"scroll-mt-4",children:[e.jsx(r,{children:e.jsx(d,{children:"CrudPrimitiveFilterBar"})}),e.jsxs(i,{children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"Barra de filtros reutilizável com campo de busca e slots para filtros customizados."}),e.jsxs(w,{defaultValue:"preview",className:"w-full",children:[e.jsxs(y,{className:"mb-4",children:[e.jsxs(c,{value:"preview",className:"gap-2",children:[e.jsx(N,{size:16}),"Preview"]}),e.jsxs(c,{value:"code",className:"gap-2",children:[e.jsx(T,{size:16}),"Código"]})]}),e.jsxs(n,{value:"preview",className:"mt-0",children:[e.jsx("div",{className:"border rounded-lg p-4 bg-muted/30",children:e.jsx(U,{searchValue:D,onSearchChange:F,customFilters:[e.jsxs(m,{value:z,onValueChange:B,children:[e.jsx(x,{className:"w-[140px] h-9",children:e.jsx(h,{placeholder:"Status"})}),e.jsxs(u,{children:[e.jsx(a,{value:"all",children:"Todos"}),e.jsx(a,{value:"active",children:"Ativo"}),e.jsx(a,{value:"inactive",children:"Inativo"})]})]},"status"),e.jsxs(m,{value:k,onValueChange:I,children:[e.jsx(x,{className:"w-[160px] h-9",children:e.jsx(h,{placeholder:"Categoria"})}),e.jsxs(u,{children:[e.jsx(a,{value:"all",children:"Todas"}),e.jsx(a,{value:"a",children:"Categoria A"}),e.jsx(a,{value:"b",children:"Categoria B"}),e.jsx(a,{value:"c",children:"Categoria C"})]})]},"category")],onClearFilters:Q,showClearButton:!0,layout:"horizontal"})}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:['Busca: "',D,'" | Status: ',z," | Categoria: ",k]})]}),e.jsx(n,{value:"code",className:"mt-0",children:e.jsx("pre",{className:"bg-muted p-4 rounded-lg text-sm overflow-x-auto",children:`import { CrudPrimitiveFilterBar, Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from 'forlogic-core';
|
|
57
|
+
|
|
58
|
+
function MyFilters() {
|
|
59
|
+
const [searchValue, setSearchValue] = useState('');
|
|
60
|
+
const [statusFilter, setStatusFilter] = useState('all');
|
|
61
|
+
const [categoryFilter, setCategoryFilter] = useState('all');
|
|
62
|
+
|
|
63
|
+
const handleClearFilters = () => {
|
|
64
|
+
setSearchValue('');
|
|
65
|
+
setStatusFilter('all');
|
|
66
|
+
setCategoryFilter('all');
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<CrudPrimitiveFilterBar
|
|
71
|
+
searchValue={searchValue}
|
|
72
|
+
onSearchChange={setSearchValue}
|
|
73
|
+
customFilters={[
|
|
74
|
+
<Select key="status" value={statusFilter} onValueChange={setStatusFilter}>
|
|
75
|
+
<SelectTrigger className="w-[140px] h-9">
|
|
76
|
+
<SelectValue placeholder="Status" />
|
|
77
|
+
</SelectTrigger>
|
|
78
|
+
<SelectContent>
|
|
79
|
+
<SelectItem value="all">Todos</SelectItem>
|
|
80
|
+
<SelectItem value="active">Ativo</SelectItem>
|
|
81
|
+
<SelectItem value="inactive">Inativo</SelectItem>
|
|
82
|
+
</SelectContent>
|
|
83
|
+
</Select>,
|
|
84
|
+
<Select key="category" value={categoryFilter} onValueChange={setCategoryFilter}>
|
|
85
|
+
<SelectTrigger className="w-[160px] h-9">
|
|
86
|
+
<SelectValue placeholder="Categoria" />
|
|
87
|
+
</SelectTrigger>
|
|
88
|
+
<SelectContent>
|
|
89
|
+
<SelectItem value="all">Todas</SelectItem>
|
|
90
|
+
<SelectItem value="a">Categoria A</SelectItem>
|
|
91
|
+
<SelectItem value="b">Categoria B</SelectItem>
|
|
92
|
+
</SelectContent>
|
|
93
|
+
</Select>
|
|
94
|
+
]}
|
|
95
|
+
onClearFilters={handleClearFilters}
|
|
96
|
+
showClearButton={true}
|
|
97
|
+
layout="horizontal"
|
|
98
|
+
/>
|
|
99
|
+
);
|
|
100
|
+
}`})})]})]})]}),e.jsxs(t,{id:"filterpopover",className:"scroll-mt-4",children:[e.jsx(r,{children:e.jsx(d,{children:"CrudPrimitiveFilterPopover"})}),e.jsxs(i,{children:[e.jsxs("p",{className:"text-muted-foreground mb-4",children:["Para interfaces com muitos filtros, agrupe-os em um Popover para manter a toolbar limpa. Este padrão é usado no ",e.jsx("code",{children:"CrudTable"})," quando há múltiplos filtros configurados."]}),e.jsxs(w,{defaultValue:"preview",className:"w-full",children:[e.jsxs(y,{className:"mb-4",children:[e.jsxs(c,{value:"preview",className:"gap-2",children:[e.jsx(N,{size:16}),"Preview"]}),e.jsxs(c,{value:"code",className:"gap-2",children:[e.jsx(T,{size:16}),"Código"]})]}),e.jsxs(n,{value:"preview",className:"mt-0",children:[e.jsx("div",{className:"border rounded-lg p-4 bg-muted/30",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(U,{searchValue:M,onSearchChange:V,showClearButton:!1}),e.jsxs(ie,{children:[e.jsx(ce,{asChild:!0,children:e.jsxs(o,{variant:"outline",size:"sm",className:"h-9 gap-2",children:[e.jsx(ne,{size:16}),"Filtrar",p>0&&e.jsx(q,{variant:"secondary",className:"ml-1 h-5 px-1.5 text-xs",children:p})]})}),e.jsx(oe,{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"}),p>0&&e.jsxs(o,{variant:"ghost",size:"sm",onClick:G,className:"h-7 text-xs",children:[e.jsx(me,{size:12,className:"mr-1"}),"Limpar"]})]}),e.jsx(xe,{}),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:"Status"}),e.jsxs(m,{value:v,onValueChange:R,children:[e.jsx(x,{className:"h-9",children:e.jsx(h,{placeholder:"Todos"})}),e.jsxs(u,{children:[e.jsx(a,{value:"all",children:"Todos"}),e.jsx(a,{value:"active",children:"Ativo"}),e.jsx(a,{value:"inactive",children:"Inativo"}),e.jsx(a,{value:"pending",children:"Pendente"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium",children:"Categoria"}),e.jsxs(m,{value:f,onValueChange:A,children:[e.jsx(x,{className:"h-9",children:e.jsx(h,{placeholder:"Todas"})}),e.jsxs(u,{children:[e.jsx(a,{value:"all",children:"Todas"}),e.jsx(a,{value:"a",children:"Categoria A"}),e.jsx(a,{value:"b",children:"Categoria B"}),e.jsx(a,{value:"c",children:"Categoria C"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium",children:"Prioridade"}),e.jsxs(m,{value:C,onValueChange:W,children:[e.jsx(x,{className:"h-9",children:e.jsx(h,{placeholder:"Todas"})}),e.jsxs(u,{children:[e.jsx(a,{value:"all",children:"Todas"}),e.jsx(a,{value:"high",children:"Alta"}),e.jsx(a,{value:"medium",children:"Média"}),e.jsx(a,{value:"low",children:"Baixa"})]})]})]})]})]})})]})]})}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["Filtros ativos: ",p," | Status: ",v," | Categoria: ",f," | Prioridade: ",C]})]}),e.jsx(n,{value:"code",className:"mt-0",children:e.jsx("pre",{className:"bg-muted p-4 rounded-lg text-sm overflow-x-auto",children:`import {
|
|
101
|
+
Button, Badge, Popover, PopoverContent, PopoverTrigger,
|
|
102
|
+
Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Separator
|
|
103
|
+
} from 'forlogic-core';
|
|
104
|
+
import { Filter, X } from 'lucide-react';
|
|
105
|
+
|
|
106
|
+
function FiltersInPopover() {
|
|
107
|
+
const [status, setStatus] = useState('all');
|
|
108
|
+
const [category, setCategory] = useState('all');
|
|
109
|
+
const [priority, setPriority] = useState('all');
|
|
110
|
+
|
|
111
|
+
const activeFiltersCount = [status, category, priority]
|
|
112
|
+
.filter(v => v !== 'all').length;
|
|
113
|
+
|
|
114
|
+
const handleClear = () => {
|
|
115
|
+
setStatus('all');
|
|
116
|
+
setCategory('all');
|
|
117
|
+
setPriority('all');
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
return (
|
|
121
|
+
<Popover>
|
|
122
|
+
<PopoverTrigger asChild>
|
|
123
|
+
<Button variant="outline" size="sm" className="h-9 gap-2">
|
|
124
|
+
<Filter size={16} />
|
|
125
|
+
Filtrar
|
|
126
|
+
{activeFiltersCount > 0 && (
|
|
127
|
+
<Badge variant="secondary" className="ml-1 h-5 px-1.5 text-xs">
|
|
128
|
+
{activeFiltersCount}
|
|
129
|
+
</Badge>
|
|
130
|
+
)}
|
|
131
|
+
</Button>
|
|
132
|
+
</PopoverTrigger>
|
|
133
|
+
<PopoverContent className="w-80" align="end">
|
|
134
|
+
<div className="space-y-4">
|
|
135
|
+
<div className="flex items-center justify-between">
|
|
136
|
+
<h4 className="font-medium">Filtros</h4>
|
|
137
|
+
{activeFiltersCount > 0 && (
|
|
138
|
+
<Button variant="ghost" size="sm" onClick={handleClear}>
|
|
139
|
+
<X size={12} className="mr-1" />
|
|
140
|
+
Limpar
|
|
141
|
+
</Button>
|
|
142
|
+
)}
|
|
143
|
+
</div>
|
|
144
|
+
<Separator />
|
|
145
|
+
|
|
146
|
+
<div className="space-y-3">
|
|
147
|
+
<div className="space-y-1.5">
|
|
148
|
+
<label className="text-sm font-medium">Status</label>
|
|
149
|
+
<Select value={status} onValueChange={setStatus}>
|
|
150
|
+
<SelectTrigger><SelectValue /></SelectTrigger>
|
|
151
|
+
<SelectContent>
|
|
152
|
+
<SelectItem value="all">Todos</SelectItem>
|
|
153
|
+
<SelectItem value="active">Ativo</SelectItem>
|
|
154
|
+
<SelectItem value="inactive">Inativo</SelectItem>
|
|
155
|
+
</SelectContent>
|
|
156
|
+
</Select>
|
|
157
|
+
</div>
|
|
158
|
+
{/* Repita para outros filtros... */}
|
|
159
|
+
</div>
|
|
160
|
+
</div>
|
|
161
|
+
</PopoverContent>
|
|
162
|
+
</Popover>
|
|
163
|
+
);
|
|
164
|
+
}`})})]})]})]}),e.jsxs(t,{id:"props",className:"scroll-mt-4",children:[e.jsx(r,{children:e.jsx(d,{children:"Props"})}),e.jsxs(i,{className:"space-y-8",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-3",children:"CrudPrimitiveFilterBar"}),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:"Default"}),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:"searchValue"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"string"}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"''"}),e.jsx("td",{className:"p-2",children:"Valor atual do campo de busca"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"onSearchChange"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"(value: string) => void"}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"-"}),e.jsx("td",{className:"p-2",children:"Callback ao digitar na busca"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"customFilters"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"ReactNode[]"}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"[]"}),e.jsx("td",{className:"p-2",children:"Array de componentes de filtro customizados (Select, Combobox, etc.)"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"onClearFilters"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"() => void"}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"-"}),e.jsx("td",{className:"p-2",children:'Callback ao clicar em "Limpar filtros"'})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"showClearButton"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"boolean"}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"true"}),e.jsx("td",{className:"p-2",children:"Exibir botão de limpar quando há filtros ativos"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"layout"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"'horizontal' | 'vertical'"}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"'horizontal'"}),e.jsx("td",{className:"p-2",children:"Orientação dos filtros"})]})]})]})})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-3",children:"CrudPrimitivePagination"}),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:"Default"}),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:"currentPage"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"number"}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"-"}),e.jsx("td",{className:"p-2",children:"Página atual (1-indexed)"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"totalPages"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"number"}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"-"}),e.jsx("td",{className:"p-2",children:"Total de páginas"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"totalItems"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"number"}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"-"}),e.jsx("td",{className:"p-2",children:"Total de itens"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"itemsPerPage"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"number"}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"-"}),e.jsx("td",{className:"p-2",children:"Itens por página"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"onPageChange"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"(page: number) => void"}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"-"}),e.jsx("td",{className:"p-2",children:"Callback ao mudar página"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"onItemsPerPageChange"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"(value: number) => void"}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"-"}),e.jsx("td",{className:"p-2",children:"Callback ao mudar itens por página"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"variant"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"'full' | 'compact'"}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"'full'"}),e.jsx("td",{className:"p-2",children:"Variante de exibição. 'full' inclui seletor de itens por página"})]})]})]})})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-3",children:"BulkActionBar"}),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:"Default"}),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:"selectedCount"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"number"}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"-"}),e.jsx("td",{className:"p-2",children:"Quantidade de itens selecionados"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"onClearSelection"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"() => void"}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"-"}),e.jsx("td",{className:"p-2",children:"Callback para limpar seleção"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"onBulkDelete"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"() => void"}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"-"}),e.jsx("td",{className:"p-2",children:'Callback para exclusão em massa (exibe botão "Excluir")'})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"customActions"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"BulkAction[]"}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"[]"}),e.jsx("td",{className:"p-2",children:"Ações customizadas (exportar, enviar email, etc.)"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"isLoading"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"boolean"}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"false"}),e.jsx("td",{className:"p-2",children:"Desabilita ações durante loading"})]})]})]})})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-3",children:"BulkAction (tipo)"}),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:"label"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"string"}),e.jsx("td",{className:"p-2",children:"Texto do botão"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"icon"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"ComponentType"}),e.jsx("td",{className:"p-2",children:"Ícone Lucide (opcional)"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"variant"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"'default' | 'destructive' | 'outline'"}),e.jsx("td",{className:"p-2",children:"Estilo do botão"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"action"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"(items: T[]) => void | Promise"}),e.jsx("td",{className:"p-2",children:"Callback executado ao clicar"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"disabled"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"boolean"}),e.jsx("td",{className:"p-2",children:"Se a ação está desabilitada"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"disabledReason"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"string"}),e.jsx("td",{className:"p-2",children:"Tooltip exibido quando disabled=true"})]})]})]})})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-3",children:"useColumnResize (Opções)"}),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:"Opção"}),e.jsx("th",{className:"text-left p-2 font-medium",children:"Tipo"}),e.jsx("th",{className:"text-left p-2 font-medium",children:"Default"}),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:"columns"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"ColumnConfig[]"}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"-"}),e.jsx("td",{className:"p-2",children:"Configuração das colunas (key, minWidth, maxWidth, defaultWidth)"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"storageKey"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"string?"}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"-"}),e.jsx("td",{className:"p-2",children:"Chave para persistência no localStorage"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"onResize"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"(widths: Record<string, number>) => void"}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"-"}),e.jsx("td",{className:"p-2",children:"Callback executado ao redimensionar"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"enabled"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"boolean"}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"true"}),e.jsx("td",{className:"p-2",children:"Habilitar/desabilitar redimensionamento"})]})]})]})})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-3",children:"useColumnResize (Retornos)"}),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:"Retorno"}),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:"columnWidths"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"Record<string, number>"}),e.jsx("td",{className:"p-2",children:"Larguras atuais das colunas (mapa key → width)"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"isDragging"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"boolean"}),e.jsx("td",{className:"p-2",children:"Se está arrastando no momento"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"activeColumn"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"string | null"}),e.jsx("td",{className:"p-2",children:"Key da coluna sendo redimensionada"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"handleMouseDown"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"(key: string, e: MouseEvent) => void"}),e.jsx("td",{className:"p-2",children:"Handler para iniciar o resize (passar para TableResizeHandle)"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"resetWidths"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"() => void"}),e.jsx("td",{className:"p-2",children:"Restaurar larguras padrão e limpar localStorage"})]})]})]})})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-3",children:"TableResizeHandle"}),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:"direction"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"'horizontal' | 'vertical'"}),e.jsx("td",{className:"p-2",children:"Direção do resize (colunas = horizontal, linhas = vertical)"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"onMouseDown"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"(e: MouseEvent) => void"}),e.jsx("td",{className:"p-2",children:"Handler para iniciar o arraste (usar handleMouseDown do useColumnResize)"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"isDragging"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"boolean?"}),e.jsx("td",{className:"p-2",children:"Se está em modo de arraste (muda aparência visual)"})]}),e.jsxs("tr",{className:"border-b",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"className"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"string?"}),e.jsx("td",{className:"p-2",children:"Classes CSS adicionais"})]})]})]})})]})]})]}),e.jsxs(t,{id:"acessibilidade",className:"scroll-mt-4",children:[e.jsx(r,{children:e.jsx(d,{children:"Acessibilidade"})}),e.jsx(i,{children:e.jsxs("ul",{className:"list-disc list-inside space-y-2 text-sm text-muted-foreground",children:[e.jsx("li",{children:'Tabela com role="table" e estrutura semântica (thead, tbody)'}),e.jsx("li",{children:'Cabeçalhos de coluna com scope="col" para leitores de tela'}),e.jsx("li",{children:"Menu de ações acessível via teclado (Enter/Space para abrir)"}),e.jsx("li",{children:"Navegação por teclado entre itens do menu (Arrow Up/Down)"}),e.jsx("li",{children:"Paginação com botões focáveis e aria-labels descritivos"}),e.jsx("li",{children:"Handles de redimensionamento com cursor visual e feedback"}),e.jsx("li",{children:"Contraste adequado para badges de status (WCAG AA)"}),e.jsx("li",{children:"Campo de busca com placeholder descritivo e ícone de contexto"}),e.jsx("li",{children:"Popover de filtros acessível via teclado (Escape para fechar)"}),e.jsx("li",{children:"Badge de contagem de filtros com contraste adequado"})]})})]}),e.jsxs(t,{id:"quando-usar",className:"scroll-mt-4",children:[e.jsx(r,{children:e.jsx(d,{children:"Quando Usar Primitives?"})}),e.jsxs(i,{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"Os primitives são ideais quando você precisa de controle total sobre a UI, mas quer aproveitar os blocos básicos já estilizados e funcionais."}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"p-4 border rounded-lg bg-green-500/5 border-green-500/30",children:[e.jsx("h4",{className:"font-medium text-green-700 dark:text-green-400 mb-2",children:"✓ Use Primitives quando:"}),e.jsxs("ul",{className:"text-sm space-y-1 text-muted-foreground",children:[e.jsx("li",{children:"• Layout completamente customizado"}),e.jsx("li",{children:"• Integração com sistemas externos"}),e.jsx("li",{children:"• UX muito específica do projeto"}),e.jsx("li",{children:"• Múltiplas tabelas na mesma página"}),e.jsx("li",{children:"• Filtros em locais não convencionais"})]})]}),e.jsxs("div",{className:"p-4 border rounded-lg bg-orange-500/5 border-orange-500/30",children:[e.jsx("h4",{className:"font-medium text-orange-700 dark:text-orange-400 mb-2",children:"✗ Use CrudTable/createCrudPage quando:"}),e.jsxs("ul",{className:"text-sm space-y-1 text-muted-foreground",children:[e.jsx("li",{children:"• CRUD padrão com lista + form"}),e.jsx("li",{children:"• Produtividade é prioridade"}),e.jsx("li",{children:"• Consistência com outras páginas"}),e.jsx("li",{children:"• Menos código para manter"}),e.jsx("li",{children:"• Filtros padrão são suficientes"})]})]})]})]})]}),e.jsxs(t,{children:[e.jsx(r,{children:e.jsx(d,{children:"Ver Também"})}),e.jsxs(i,{children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"Componentes relacionados com documentação detalhada:"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(o,{variant:"outline",size:"sm",onClick:()=>window.location.href="/ds/crud-pagination",children:"Pagination →"}),e.jsx(o,{variant:"outline",size:"sm",onClick:()=>window.location.href="/ds/crud-bulk-action-bar",children:"BulkActionBar →"}),e.jsx(o,{variant:"outline",size:"sm",onClick:()=>window.location.href="/ds/crud-table",children:"CrudTable →"}),e.jsx(o,{variant:"outline",size:"sm",onClick:()=>window.location.href="/ds/crud-overview",children:"CRUD Overview →"})]})]})]})]})}export{ge as CrudPrimitivesDoc};
|