forlogic-core 1.20.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.note/memory/patterns/alias-url-resolution.md +5 -2
- package/.note/memory/patterns/single-scroll-pattern.md +30 -12
- package/dist/action-plans/components/ActionPlanAttachmentsTab.d.ts +18 -0
- package/dist/action-plans/components/ActionPlanCommentsTab.d.ts +18 -0
- package/dist/action-plans/components/ActionPlanCostTab.d.ts +10 -0
- package/dist/action-plans/components/ActionPlanGeneralTab.d.ts +18 -0
- package/dist/action-plans/components/ActionPlanHistoryTab.d.ts +13 -0
- package/dist/action-plans/components/ActionPlanPage.d.ts +25 -0
- package/dist/action-plans/components/ActionPlanPredecessorsTab.d.ts +10 -0
- package/dist/action-plans/components/ActionPlanProgressDialog.d.ts +13 -0
- package/dist/action-plans/components/ActionPlanProgressTab.d.ts +5 -0
- package/dist/action-plans/components/ActionPlanStatusBadge.d.ts +11 -0
- package/dist/action-plans/constants.d.ts +42 -0
- package/dist/action-plans/hooks/useActionPlan.d.ts +14 -0
- package/dist/action-plans/hooks/useActionPlanProgress.d.ts +15 -0
- package/dist/action-plans/index.d.ts +15 -0
- package/dist/action-plans/types.d.ts +353 -0
- package/dist/action-plans/utils/formatTime.d.ts +15 -0
- package/dist/approval-flow/components/ApprovalSidenav.d.ts +16 -0
- package/dist/approval-flow/components/ApproveDialog.d.ts +13 -0
- package/dist/approval-flow/components/SelectApproverDialog.d.ts +11 -0
- package/dist/approval-flow/index.d.ts +4 -0
- package/dist/approval-flow/types.d.ts +76 -0
- package/dist/assets/index.d.ts +1 -0
- package/dist/audit-trail/components/AuditTrailDetails.d.ts +17 -0
- package/dist/audit-trail/components/AuditTrailFilter.d.ts +19 -0
- package/dist/audit-trail/components/AuditTrailPage.d.ts +30 -0
- package/dist/audit-trail/index.d.ts +9 -0
- package/dist/audit-trail/types.d.ts +151 -0
- package/dist/audit-trail/utils.d.ts +38 -0
- package/dist/components/dashboards/dashboard-form.d.ts +50 -0
- package/dist/components/dashboards/dashboard-general-view.d.ts +109 -0
- package/dist/components/dashboards/dashboard-grid.d.ts +41 -0
- package/dist/components/dashboards/dashboard-list.d.ts +31 -0
- package/dist/components/dashboards/dashboard-panel-renderer.d.ts +21 -0
- package/dist/components/dashboards/dashboard-view.d.ts +38 -0
- package/dist/components/dashboards/helpers.d.ts +47 -0
- package/dist/components/dashboards/index.d.ts +9 -0
- package/dist/components/dashboards/panels/burndown-panel.d.ts +26 -0
- package/dist/components/dashboards/panels/cartesian-panel.d.ts +46 -0
- package/dist/components/dashboards/panels/index.d.ts +14 -0
- package/dist/components/dashboards/panels/list-panel.d.ts +30 -0
- package/dist/components/dashboards/panels/matrix-risk-panel.d.ts +49 -0
- package/dist/components/dashboards/panels/numeric-panel.d.ts +22 -0
- package/dist/components/dashboards/panels/panel-error.d.ts +8 -0
- package/dist/components/dashboards/panels/panel-header.d.ts +17 -0
- package/dist/components/dashboards/panels/panel-loader.d.ts +7 -0
- package/dist/components/dashboards/panels/panel-no-data.d.ts +6 -0
- package/dist/components/dashboards/panels/panel-unavailable.d.ts +6 -0
- package/dist/components/dashboards/panels/pareto-panel.d.ts +20 -0
- package/dist/components/dashboards/panels/performance-panel.d.ts +24 -0
- package/dist/components/dashboards/panels/pie-panel.d.ts +19 -0
- package/dist/components/dashboards/panels/text-panel.d.ts +18 -0
- package/dist/components/dashboards/types.d.ts +525 -0
- package/dist/components/ui/electronic-signature-dialog.d.ts +21 -0
- package/dist/components/ui/export-dialog.d.ts +28 -0
- package/dist/components/ui/iframe-dialog.d.ts +14 -0
- package/dist/components/ui/multiselect-permissions.d.ts +59 -0
- package/dist/components/ui/online-editor-dialog.d.ts +18 -0
- package/dist/components/ui/report-request-list.d.ts +44 -0
- package/dist/components/ui/stimulsoft-viewer.d.ts +20 -0
- package/dist/components/ui/terms-of-use-dialog.d.ts +56 -0
- package/dist/components/ui/timepicker.d.ts +11 -0
- package/dist/components/ui/users-groups-selector.d.ts +44 -0
- package/dist/components/ui/viewer-dialog.d.ts +77 -0
- package/dist/custom-form-fields/components/CustomFormFields.d.ts +8 -0
- package/dist/custom-form-fields/fields/FormDateField.d.ts +6 -0
- package/dist/custom-form-fields/fields/FormMultiSelectionField.d.ts +6 -0
- package/dist/custom-form-fields/fields/FormNumericField.d.ts +6 -0
- package/dist/custom-form-fields/fields/FormQuestionsField.d.ts +6 -0
- package/dist/custom-form-fields/fields/FormSingleSelectionField.d.ts +6 -0
- package/dist/custom-form-fields/fields/FormTextField.d.ts +6 -0
- package/dist/custom-form-fields/fields/FormTimeField.d.ts +6 -0
- package/dist/custom-form-fields/fields/FormUrlField.d.ts +6 -0
- package/dist/custom-form-fields/fields/ReadOnlyTextField.d.ts +6 -0
- package/dist/custom-form-fields/index.d.ts +13 -0
- package/dist/custom-form-fields/types.d.ts +143 -0
- package/dist/exports/action-plans.d.ts +16 -0
- package/dist/exports/audit-trail.d.ts +1 -0
- package/dist/exports/custom-form-fields.d.ts +1 -0
- package/dist/exports/file-upload.d.ts +1 -0
- package/dist/exports/ui.d.ts +12 -0
- package/dist/file-upload/components/SingleFileUpload.d.ts +43 -0
- package/dist/file-upload/index.d.ts +6 -0
- package/dist/file-upload/types.d.ts +11 -0
- package/dist/file-upload/utils/formatBytes.d.ts +1 -0
- package/dist/file-upload/utils/getFileExtension.d.ts +1 -0
- package/dist/hooks/useSidebarResize.d.ts +1 -1
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/team-selector/components/TeamSelector.d.ts +24 -0
- package/dist/team-selector/index.d.ts +2 -0
- package/dist/team-selector/types.d.ts +10 -0
- package/docs/ICON_MIGRATION_GUIDE.md +177 -0
- package/package.json +1 -1
- package/dist/assets/AccordionDoc-BVPUJk8G.js +0 -31
- package/dist/assets/ActionButtonDoc-DLJ_K9ib.js +0 -47
- package/dist/assets/AlertDoc-CY1ybZeG.js +0 -37
- package/dist/assets/AppHeaderDoc-Crkw4dA9.js +0 -67
- package/dist/assets/AppSidebarDoc-ET-4j6wV.js +0 -204
- package/dist/assets/AuthDoc-B4v4Nci5.js +0 -192
- package/dist/assets/AvatarDoc-BLdMoyJd.js +0 -11
- package/dist/assets/BadgeDoc-CSNM1b6b.js +0 -36
- package/dist/assets/BaseFormDoc-DXiYuN6-.js +0 -169
- package/dist/assets/BodyContentDoc-Bp6YmUWX.js +0 -83
- package/dist/assets/BreadcrumbDoc-D7tqqTvo.js +0 -75
- package/dist/assets/ButtonDoc-C4JwIvU3.js +0 -41
- package/dist/assets/ButtonGroupDoc-QFfjC7Pm.js +0 -7
- package/dist/assets/CalendarDoc-COlEKqmv.js +0 -81
- package/dist/assets/CardDoc-BVhMoC2w.js +0 -49
- package/dist/assets/ChartDoc-BJ14EjI2.js +0 -111
- package/dist/assets/CheckboxDoc-Bcqpln9_.js +0 -55
- package/dist/assets/ColorPickerDoc-CcfmSwyC.js +0 -10
- package/dist/assets/ColorsFoundationDoc-uO6IiJbS.js +0 -13
- package/dist/assets/ComboTreeDoc-R4qE6XwB.js +0 -46
- package/dist/assets/ComboboxDoc-JIo_-gSN.js +0 -134
- package/dist/assets/ComponentDocTemplate-CRbRY-v5.js +0 -1
- package/dist/assets/ContextMenuDoc-C4-_0NLp.js +0 -182
- package/dist/assets/ContextsDoc-Cj9Aaoyo.js +0 -184
- package/dist/assets/CreateCrudPageDoc-D_SnMRJ2.js +0 -106
- package/dist/assets/CrudActionBarDoc-BYqtIabp.js +0 -112
- package/dist/assets/CrudGridDoc-DspxQrq5.js +0 -85
- package/dist/assets/CrudOverviewDoc-DLcOL_HZ.js +0 -14
- package/dist/assets/CrudPrimitivesDoc-BRS86nWg.js +0 -164
- package/dist/assets/CrudTableDoc-Daw8u2G_.js +0 -113
- package/dist/assets/DataListDoc-BrgVNhhR.js +0 -13
- package/dist/assets/DesignSystemHome-BFBNqq1J.js +0 -1
- package/dist/assets/DialogDoc-DCpRy4rg.js +0 -981
- package/dist/assets/DropdownMenuDoc-DT6LBa8Z.js +0 -175
- package/dist/assets/EmptyStateDoc-wydc09gG.js +0 -35
- package/dist/assets/EnvironmentsDoc-amIriwDD.js +0 -96
- package/dist/assets/ErrorBoundaryDoc-BEixy_Gl.js +0 -111
- package/dist/assets/FormDoc-DxoRt6p7.js +0 -81
- package/dist/assets/FoundationOverview-CxSbumIt.js +0 -1
- package/dist/assets/GridDoc-BpQqCMUE.js +0 -28
- package/dist/assets/HooksDoc-JNODhbaF.js +0 -665
- package/dist/assets/HoverCardDoc-CdqiYrIb.js +0 -31
- package/dist/assets/I18nDoc-B6LMXnE3.js +0 -232
- package/dist/assets/IconPickerDoc-BRdy58IC.js +0 -10
- package/dist/assets/IconsFoundationDoc-CrymfxTI.js +0 -33
- package/dist/assets/InputDoc-BK-SdpJ7.js +0 -211
- package/dist/assets/LabelDoc-DHvgzhaJ.js +0 -42
- package/dist/assets/LeadershipDoc-DRiB0spL.js +0 -416
- package/dist/assets/MediaDoc-B_vqnf72.js +0 -459
- package/dist/assets/MenubarDoc-Zvgczxe2.js +0 -165
- package/dist/assets/ModuleAccessDoc-Nuxb4S27.js +0 -153
- package/dist/assets/ModulesDialogDoc-iJWLkOZo.js +0 -46
- package/dist/assets/NavigationMenuDoc-CeWun1VF.js +0 -116
- package/dist/assets/OnboardingDialogDoc-xBL-rXeZ.js +0 -55
- package/dist/assets/PaginationDoc-CfvwxCMe.js +0 -98
- package/dist/assets/PaginationDoc-DqtRgXnF.js +0 -27
- package/dist/assets/PlacesDoc-nckioEzg.js +0 -226
- package/dist/assets/PopoverDoc-C3o2CZCT.js +0 -64
- package/dist/assets/ProgressDoc-BmWBNMPA.js +0 -29
- package/dist/assets/QualiexUserFieldDoc-CE1e4mx6.js +0 -149
- package/dist/assets/RadioGroupDoc-DMZH6NmR.js +0 -57
- package/dist/assets/RadiusDoc-BOZD3gPV.js +0 -7
- package/dist/assets/RequiredFieldsCounterDoc-CG-lmSSy.js +0 -58
- package/dist/assets/ResizableDoc-CqGkv6Cd.js +0 -104
- package/dist/assets/RichTextEditorDoc-m50ll-Od.js +0 -24
- package/dist/assets/ScrollAreaDoc-BzJ-APXo.js +0 -28
- package/dist/assets/SecurityDoc-B34gVeiV.js +0 -204
- package/dist/assets/SelectDoc-DXRv7QHK.js +0 -80
- package/dist/assets/SeparatorDoc-DcNh8k0P.js +0 -4
- package/dist/assets/ServicesDoc-8aXBd6yg.js +0 -308
- package/dist/assets/ShadowsDoc-Brl4hIDI.js +0 -9
- package/dist/assets/SignDoc-BdwerR-2.js +0 -66
- package/dist/assets/SkeletonDoc-BWgqgbDY.js +0 -54
- package/dist/assets/SliderDoc-E-NjbYVk.js +0 -41
- package/dist/assets/SpacingDoc-BzburM-r.js +0 -12
- package/dist/assets/SplitButtonDoc-BYUysmJp.js +0 -53
- package/dist/assets/StepSelectorDoc-PB1k4v7F.js +0 -41
- package/dist/assets/SwitchDoc-BLOG6kfj.js +0 -56
- package/dist/assets/TableDoc-Dwcs-lop.js +0 -128
- package/dist/assets/TabsDoc-Ovkh8ArV.js +0 -42
- package/dist/assets/TextareaDoc-DsBYxmbr.js +0 -46
- package/dist/assets/ToastDoc-BbZaFE_A.js +0 -157
- package/dist/assets/ToggleDoc-C28vbvhp.js +0 -51
- package/dist/assets/TooltipDoc-DL5cnLak.js +0 -58
- package/dist/assets/TruncatedCellDoc-BuDA8QcY.js +0 -12
- package/dist/assets/TypographyFoundationDoc-CPdH4PHa.js +0 -7
- package/dist/assets/UtilitiesDoc-CrQhyEfz.js +0 -145
- package/dist/assets/blocks-DO93nPjs.js +0 -1
- package/dist/assets/calendar-days-cMfwBSZx.js +0 -1
- package/dist/assets/circle-plus-D3NftMzS.js +0 -1
- package/dist/assets/circle-x-BVAVJ_oz.js +0 -1
- package/dist/assets/crown-B2MTZDnM.js +0 -1
- package/dist/assets/date-picker-zhJU-_kM.js +0 -1
- package/dist/assets/disabled-menu-item-C16xsaVs.js +0 -1
- package/dist/assets/drawer-oTqCOtsC.js +0 -3
- package/dist/assets/file-pen-line-CXv-Eye-.js +0 -1
- package/dist/assets/git-branch-V6-h6P9K.js +0 -1
- package/dist/assets/globe-CaUBIJU8.js +0 -1
- package/dist/assets/hash-B4MTXppl.js +0 -1
- package/dist/assets/hover-card-DEuucfxP.js +0 -1
- package/dist/assets/index-CE0k7Rdh.js +0 -312
- package/dist/assets/index-Cx3adT_u.css +0 -1
- package/dist/assets/life-buoy-BRndExxh.js +0 -1
- package/dist/assets/lucide-react-t7dCa4lv.js +0 -1
- package/dist/assets/monitor-Dg3HKTSE.js +0 -1
- package/dist/assets/package-3G45ARQh.js +0 -1
- package/dist/assets/pen-BYSSwjK4.js +0 -1
- package/dist/assets/pin-CMYagNhs.js +0 -1
- package/dist/assets/radio-group-BVun_Tmt.js +0 -1
- package/dist/assets/server-p0Sb0mKI.js +0 -1
- package/dist/assets/share-2-D-ZhCCq2.js +0 -1
- package/dist/assets/shield-x-Q7hAXWsG.js +0 -1
- package/dist/assets/step-selector-DHxgT2FL.js +0 -1
- package/dist/assets/text-align-start-6aYQqbX4.js +0 -1
- package/dist/assets/trash-DveAOiLF.js +0 -1
- package/dist/assets/useMockCrud-GY0KxHXr.js +0 -1
- package/dist/assets/user-check-CoGNBfIk.js +0 -1
- package/dist/assets/user-plus-Bad2xWIT.js +0 -1
- package/dist/index.html +0 -35
- package/dist/leadership/components/LeaderRow.d.ts +0 -9
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./index-CE0k7Rdh.js";import{C as n}from"./ComponentDocTemplate-CRbRY-v5.js";const r=`import {
|
|
2
|
-
// Contexts e Hooks
|
|
3
|
-
useLocale,
|
|
4
|
-
useNavigation,
|
|
5
|
-
usePageMetadata,
|
|
6
|
-
useModalState,
|
|
7
|
-
useHasOpenModal,
|
|
8
|
-
|
|
9
|
-
// Providers
|
|
10
|
-
LocaleProvider,
|
|
11
|
-
NavigationProvider,
|
|
12
|
-
PageMetadataProvider,
|
|
13
|
-
ModalStateProvider,
|
|
14
|
-
} from 'forlogic-core';`,s=`import { useLocale } from 'forlogic-core';
|
|
15
|
-
|
|
16
|
-
function UserSettings() {
|
|
17
|
-
const {
|
|
18
|
-
locale,
|
|
19
|
-
timezone,
|
|
20
|
-
datetimeFormat,
|
|
21
|
-
setLocale,
|
|
22
|
-
setTimezone,
|
|
23
|
-
setDatetimeFormat,
|
|
24
|
-
isLoading
|
|
25
|
-
} = useLocale();
|
|
26
|
-
|
|
27
|
-
if (isLoading) return <Spinner />;
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<div className="space-y-4">
|
|
31
|
-
<Select
|
|
32
|
-
value={locale}
|
|
33
|
-
onValueChange={setLocale}
|
|
34
|
-
>
|
|
35
|
-
<SelectItem value="pt-BR">Português</SelectItem>
|
|
36
|
-
<SelectItem value="en-US">English</SelectItem>
|
|
37
|
-
<SelectItem value="es-ES">Español</SelectItem>
|
|
38
|
-
</Select>
|
|
39
|
-
|
|
40
|
-
<Select
|
|
41
|
-
value={timezone}
|
|
42
|
-
onValueChange={setTimezone}
|
|
43
|
-
>
|
|
44
|
-
<SelectItem value="America/Sao_Paulo">São Paulo (-3)</SelectItem>
|
|
45
|
-
<SelectItem value="America/New_York">New York (-5)</SelectItem>
|
|
46
|
-
</Select>
|
|
47
|
-
|
|
48
|
-
<Select
|
|
49
|
-
value={datetimeFormat}
|
|
50
|
-
onValueChange={setDatetimeFormat}
|
|
51
|
-
>
|
|
52
|
-
<SelectItem value="dd/MM/yyyy HH:mm">DD/MM/YYYY HH:mm</SelectItem>
|
|
53
|
-
<SelectItem value="yyyy-MM-dd HH:mm">YYYY-MM-DD HH:mm</SelectItem>
|
|
54
|
-
</Select>
|
|
55
|
-
</div>
|
|
56
|
-
);
|
|
57
|
-
}`,d=`import { NavigationProvider, useNavigation } from 'forlogic-core';
|
|
58
|
-
|
|
59
|
-
// Configuração de navegação
|
|
60
|
-
const sidebarConfig = {
|
|
61
|
-
appName: 'Minha Aplicação',
|
|
62
|
-
navigation: [
|
|
63
|
-
{ path: '/', label: 'Início', icon: Home },
|
|
64
|
-
{ path: '/users', label: 'Usuários', icon: Users },
|
|
65
|
-
{ path: '/settings', label: 'Configurações', icon: Settings },
|
|
66
|
-
]
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
// Provider no root da aplicação
|
|
70
|
-
function App() {
|
|
71
|
-
return (
|
|
72
|
-
<NavigationProvider config={sidebarConfig}>
|
|
73
|
-
<AppLayout />
|
|
74
|
-
</NavigationProvider>
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Uso em componentes
|
|
79
|
-
function PageHeader() {
|
|
80
|
-
const { navigation, appName } = useNavigation();
|
|
81
|
-
|
|
82
|
-
return (
|
|
83
|
-
<header>
|
|
84
|
-
<h1>{appName}</h1>
|
|
85
|
-
<nav>
|
|
86
|
-
{navigation?.map(item => (
|
|
87
|
-
<Link key={item.path} to={item.path}>
|
|
88
|
-
{item.label}
|
|
89
|
-
</Link>
|
|
90
|
-
))}
|
|
91
|
-
</nav>
|
|
92
|
-
</header>
|
|
93
|
-
);
|
|
94
|
-
}`,l=`import { PageMetadataProvider, usePageMetadata } from 'forlogic-core';
|
|
95
|
-
|
|
96
|
-
// Provider com ações customizadas no header
|
|
97
|
-
function App() {
|
|
98
|
-
return (
|
|
99
|
-
<PageMetadataProvider
|
|
100
|
-
defaultHeaderActions={<Button>Ação Global</Button>}
|
|
101
|
-
>
|
|
102
|
-
<AppLayout />
|
|
103
|
-
</PageMetadataProvider>
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// Hook para definir metadados da página
|
|
108
|
-
function UsersPage() {
|
|
109
|
-
usePageMetadata({
|
|
110
|
-
title: 'Gerenciamento de Usuários',
|
|
111
|
-
subtitle: 'Adicione, edite e remova usuários do sistema'
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
return <UserList />;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// Consumindo metadados no header
|
|
118
|
-
function AppHeader() {
|
|
119
|
-
const { metadata, headerActions } = usePageMetadataContext();
|
|
120
|
-
|
|
121
|
-
return (
|
|
122
|
-
<header className="flex justify-between">
|
|
123
|
-
<div>
|
|
124
|
-
<h1>{metadata?.title}</h1>
|
|
125
|
-
{metadata?.subtitle && (
|
|
126
|
-
<p className="text-muted-foreground">{metadata.subtitle}</p>
|
|
127
|
-
)}
|
|
128
|
-
</div>
|
|
129
|
-
<div>{headerActions}</div>
|
|
130
|
-
</header>
|
|
131
|
-
);
|
|
132
|
-
}`,c=`import { ModalStateProvider, useModalState, useHasOpenModal } from 'forlogic-core';
|
|
133
|
-
|
|
134
|
-
// Provider no root da aplicação
|
|
135
|
-
function App() {
|
|
136
|
-
return (
|
|
137
|
-
<ModalStateProvider>
|
|
138
|
-
<AppLayout />
|
|
139
|
-
</ModalStateProvider>
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// Registrar modal aberto
|
|
144
|
-
function MyDialog({ open, onOpenChange }) {
|
|
145
|
-
const { registerModal, unregisterModal } = useModalState();
|
|
146
|
-
|
|
147
|
-
useEffect(() => {
|
|
148
|
-
if (open) {
|
|
149
|
-
registerModal('my-dialog');
|
|
150
|
-
} else {
|
|
151
|
-
unregisterModal('my-dialog');
|
|
152
|
-
}
|
|
153
|
-
}, [open, registerModal, unregisterModal]);
|
|
154
|
-
|
|
155
|
-
return (
|
|
156
|
-
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
157
|
-
<DialogContent>...</DialogContent>
|
|
158
|
-
</Dialog>
|
|
159
|
-
);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// Hook simplificado para verificar se há modal aberto
|
|
163
|
-
function SidebarTrigger() {
|
|
164
|
-
const hasOpenModal = useHasOpenModal();
|
|
165
|
-
|
|
166
|
-
return (
|
|
167
|
-
<Button
|
|
168
|
-
disabled={hasOpenModal}
|
|
169
|
-
onClick={openSidebar}
|
|
170
|
-
>
|
|
171
|
-
Menu
|
|
172
|
-
</Button>
|
|
173
|
-
);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// Uso com setHasOpenModal (modo simplificado)
|
|
177
|
-
function SimpleModal() {
|
|
178
|
-
const { setHasOpenModal } = useModalState();
|
|
179
|
-
|
|
180
|
-
const handleOpen = () => setHasOpenModal(true);
|
|
181
|
-
const handleClose = () => setHasOpenModal(false);
|
|
182
|
-
|
|
183
|
-
return <Dialog onOpenChange={(open) => setHasOpenModal(open)}>...</Dialog>;
|
|
184
|
-
}`,m=[{name:"useLocale()",type:"LocaleContextType",default:"-",description:"Retorna locale, timezone, datetimeFormat, funções setters e isLoading."},{name:"LocaleProvider",type:"React.FC<{ children }>",default:"-",description:"Provider que gerencia preferências de locale do usuário com persistência no banco."},{name:"useNavigation()",type:"{ navigation, appName }",default:"-",description:"Retorna configuração de navegação e nome da aplicação."},{name:"NavigationProvider",type:"React.FC<{ config, children }>",default:"-",description:"Provider que fornece configuração de sidebar/navegação para toda a aplicação."},{name:"usePageMetadata(options)",type:"void",default:"-",description:"Define title e subtitle da página atual. Limpa automaticamente no unmount."},{name:"usePageMetadataContext()",type:"{ metadata, headerActions, setMetadata, clearMetadata }",default:"-",description:"Acessa metadados da página atual para uso em headers."},{name:"PageMetadataProvider",type:"React.FC<{ defaultHeaderActions, children }>",default:"-",description:"Provider que gerencia metadados de página e ações do header."},{name:"useModalState()",type:"ModalStateContextValue",default:"-",description:"Retorna openModals, hasOpenModal, registerModal, unregisterModal, setHasOpenModal."},{name:"useHasOpenModal()",type:"boolean",default:"-",description:"Hook simplificado que retorna apenas se há modal aberto."},{name:"ModalStateProvider",type:"React.FC<{ children }>",default:"-",description:"Provider que rastreia modais abertos globalmente."}];function a({title:t,description:o,code:i}){return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold",children:t}),e.jsx("p",{className:"text-sm text-muted-foreground",children:o})]}),e.jsx("pre",{className:"rounded-lg border bg-muted/50 p-4 overflow-x-auto",children:e.jsx("code",{className:"text-sm font-mono",children:i})})]})}function g(){const t=[{id:"exemplos",label:"Exemplos"},{id:"localecontext",label:"LocaleContext"},{id:"navigationcontext",label:"NavigationContext"},{id:"pagemetadatacontext",label:"PageMetadataContext"},{id:"modalstatecontext",label:"ModalStateContext"}];return e.jsx(n,{title:"Contexts",description:"Contexts globais da biblioteca forlogic-core para gerenciamento de estado da aplicação. Incluem LocaleContext para i18n, NavigationContext para navegação, PageMetadataContext para metadados de página e ModalStateContext para rastreamento de modais.",usage:r,props:m,tocItems:t,notes:["LocaleContext fornece locale fixo em pt-BR (preferências do usuário serão implementadas futuramente via API externa).","NavigationContext é memoizado para evitar re-renders durante navegação.","PageMetadataContext limpa automaticamente os metadados quando a página é desmontada.","ModalStateContext permite uso opcional - retorna fallback silencioso se não houver provider.","useHasOpenModal é útil para desabilitar ações de sidebar quando há modais abertos.","Todos os contexts devem ser configurados via CoreProviders no root da aplicação."],children:e.jsxs("div",{id:"exemplos",className:"space-y-8 scroll-mt-4",children:[e.jsx("h2",{className:"text-2xl font-semibold tracking-tight border-b pb-2",children:"Exemplos"}),e.jsx("div",{id:"localecontext",className:"scroll-mt-4",children:e.jsx(a,{title:"LocaleContext",description:"Gerencia preferências de locale, timezone e formato de data/hora do usuário. Persiste automaticamente no banco de dados.",code:s})}),e.jsx("div",{id:"navigationcontext",className:"scroll-mt-4",children:e.jsx(a,{title:"NavigationContext",description:"Fornece configuração de navegação e nome da aplicação. Usado pelo AppSidebar e hooks como usePageTitle.",code:d})}),e.jsx("div",{id:"pagemetadatacontext",className:"scroll-mt-4",children:e.jsx(a,{title:"PageMetadataContext",description:"Permite que páginas definam título e subtítulo que serão exibidos no AppHeader. Suporta ações customizadas no header.",code:l})}),e.jsx("div",{id:"modalstatecontext",className:"scroll-mt-4",children:e.jsx(a,{title:"ModalStateContext",description:"Rastreia modais abertos globalmente. Permite que componentes como SidebarActionTrigger se desabilitem quando há modais abertos.",code:c})})]})})}export{g as ContextsDoc};
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import{j as e,C as m,a as x,b as h,d as u,b9 as a,aq as l,cl as i,cm as d,cn as r,t as T,bc as o,co as c,h as t,aD as z,dg as j,E as p,r as f,f as v,P as k,c0 as R,I as B,ar as E,at as F,au as y,av as g,aw as q,ax as N,B as I,n as _,o as H,A as U,p as L,q as b,s as V,bW as O,T as M,d_ as W,d$ as G,e1 as Q,e2 as $,e3 as J,e5 as K}from"./index-CE0k7Rdh.js";import{C as X}from"./ComponentDocTemplate-CRbRY-v5.js";const Y=[{id:"1",title:"Reunião de planejamento",category:"Trabalho",is_actived:!0},{id:"2",title:"Lista de compras",category:"Pessoal",is_actived:!0},{id:"3",title:"Ideias para o projeto",category:"Trabalho",is_actived:!1},{id:"4",title:"Anotações da aula",category:"Estudos",is_actived:!0},{id:"5",title:"Receita de bolo",category:"Pessoal",is_actived:!0}];function Z(){const[C,P]=f.useState(""),[A,n]=f.useState(!1),[D,S]=f.useState(1),w=Y.filter(s=>s.title.toLowerCase().includes(C.toLowerCase()));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(v,{size:"sm",onClick:()=>n(!0),children:[e.jsx(k,{className:"h-4 w-4 mr-2"}),"Nova Nota"]}),e.jsx("div",{className:"flex-1 max-w-xs",children:e.jsxs("div",{className:"relative",children:[e.jsx(R,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(B,{placeholder:"Buscar notas...",value:C,onChange:s=>P(s.target.value),className:"pl-9 h-9"})]})})]}),e.jsxs(E,{children:[e.jsx(F,{children:e.jsxs(y,{children:[e.jsx(g,{children:"Título"}),e.jsx(g,{children:"Categoria"}),e.jsx(g,{children:"Status"}),e.jsx(g,{className:"w-16",children:"Ações"})]})}),e.jsx(q,{children:w.map(s=>e.jsxs(y,{children:[e.jsx(N,{className:"font-medium",children:s.title}),e.jsx(N,{children:s.category}),e.jsx(N,{children:e.jsx(I,{variant:s.is_actived?"default":"secondary",children:s.is_actived?"Ativo":"Inativo"})}),e.jsx(N,{children:e.jsxs(_,{children:[e.jsx(H,{asChild:!0,children:e.jsx(U,{})}),e.jsxs(L,{align:"end",children:[e.jsxs(b,{children:[e.jsx(V,{className:"h-4 w-4 mr-2"}),"Editar"]}),e.jsxs(b,{children:[e.jsx(O,{className:"h-4 w-4 mr-2"}),"Desativar"]}),e.jsxs(b,{className:"text-destructive",children:[e.jsx(M,{className:"h-4 w-4 mr-2"}),"Excluir"]})]})]})})]},s.id))})]}),e.jsx("div",{className:"border-t",children:e.jsx(W,{currentPage:D,totalPages:1,totalItems:w.length,itemsPerPage:10,onPageChange:S,onItemsPerPageChange:()=>{},variant:"full"})}),e.jsx(G,{open:A,onOpenChange:n,children:e.jsxs(Q,{children:[e.jsx($,{children:e.jsx(J,{children:"Nova Nota"})}),e.jsx("div",{className:"py-4 text-center text-muted-foreground",children:"Formulário gerado automaticamente pelo BaseForm"}),e.jsxs(K,{children:[e.jsx(v,{variant:"outline",onClick:()=>n(!1),children:"Cancelar"}),e.jsx(v,{onClick:()=>n(!1),children:"Salvar"})]})]})})]})}const ee=`// 1. Defina o serviço
|
|
2
|
-
const notesService = createSimpleService<Note>({
|
|
3
|
-
tableName: 'notes',
|
|
4
|
-
schema: 'common',
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
// 2. Crie a página com ~15 linhas de configuração
|
|
8
|
-
const NotesPage = createCrudPage({
|
|
9
|
-
entityName: 'Nota',
|
|
10
|
-
entityNamePlural: 'Notas',
|
|
11
|
-
service: notesService,
|
|
12
|
-
columns: [
|
|
13
|
-
{ key: 'title', header: 'Título', sortable: true },
|
|
14
|
-
{ key: 'category', header: 'Categoria' },
|
|
15
|
-
{ key: 'is_actived', header: 'Status' },
|
|
16
|
-
],
|
|
17
|
-
formSections: [{
|
|
18
|
-
id: 'main',
|
|
19
|
-
fields: [
|
|
20
|
-
{ name: 'title', label: 'Título', type: 'text', required: true },
|
|
21
|
-
{ name: 'category', label: 'Categoria', type: 'select', options: [...] },
|
|
22
|
-
{ name: 'content', label: 'Conteúdo', type: 'textarea' },
|
|
23
|
-
],
|
|
24
|
-
}],
|
|
25
|
-
});`,se=`const ProductsPage = createCrudPage({
|
|
26
|
-
// ... config básica
|
|
27
|
-
filters: [
|
|
28
|
-
{
|
|
29
|
-
key: 'category',
|
|
30
|
-
label: 'Categoria',
|
|
31
|
-
options: [
|
|
32
|
-
{ value: 'electronics', label: 'Eletrônicos' },
|
|
33
|
-
{ value: 'clothing', label: 'Vestuário' },
|
|
34
|
-
]
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
key: 'status',
|
|
38
|
-
label: 'Status',
|
|
39
|
-
options: [
|
|
40
|
-
{ value: 'active', label: 'Ativo' },
|
|
41
|
-
{ value: 'inactive', label: 'Inativo' },
|
|
42
|
-
]
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
defaultSort: { column: 'name', direction: 'asc' },
|
|
46
|
-
});`,ae=`const ReportsPage = createCrudPage({
|
|
47
|
-
// ... config básica
|
|
48
|
-
|
|
49
|
-
// Ações na toolbar
|
|
50
|
-
customActions: [
|
|
51
|
-
{
|
|
52
|
-
icon: Download,
|
|
53
|
-
label: 'Exportar',
|
|
54
|
-
onClick: () => handleExport()
|
|
55
|
-
},
|
|
56
|
-
],
|
|
57
|
-
|
|
58
|
-
// Ações por linha
|
|
59
|
-
customRowActions: (item) => [
|
|
60
|
-
{ icon: Copy, label: 'Duplicar', onClick: () => handleDuplicate(item) },
|
|
61
|
-
{ icon: History, label: 'Histórico', onClick: () => handleHistory(item) },
|
|
62
|
-
],
|
|
63
|
-
|
|
64
|
-
// Ações em massa (dropdown "Ações em lote")
|
|
65
|
-
enableBulkActions: true,
|
|
66
|
-
bulkActions: [
|
|
67
|
-
{
|
|
68
|
-
icon: Archive,
|
|
69
|
-
label: 'Arquivar',
|
|
70
|
-
action: (ids) => handleBulkArchive(ids)
|
|
71
|
-
},
|
|
72
|
-
],
|
|
73
|
-
});`,le=`const ProcessesPage = createCrudPage({
|
|
74
|
-
// ... config básica
|
|
75
|
-
|
|
76
|
-
// Desabilita o formulário padrão
|
|
77
|
-
useCustomRouting: true,
|
|
78
|
-
hideNewButton: true,
|
|
79
|
-
|
|
80
|
-
// Handler customizado para "Novo"
|
|
81
|
-
onNew: () => navigate('/processes/new'),
|
|
82
|
-
|
|
83
|
-
// Ou usa handler direto (abre modal/wizard externo)
|
|
84
|
-
onEdit: (item) => navigate(\`/processes/\${item.id}/edit\`),
|
|
85
|
-
});`,te=`// Render customizado de colunas
|
|
86
|
-
columns: [
|
|
87
|
-
{
|
|
88
|
-
key: 'status',
|
|
89
|
-
header: 'Status',
|
|
90
|
-
render: (item) => (
|
|
91
|
-
<Badge variant={item.is_actived ? 'default' : 'secondary'}>
|
|
92
|
-
{item.is_actived ? 'Ativo' : 'Inativo'}
|
|
93
|
-
</Badge>
|
|
94
|
-
)
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
key: 'user',
|
|
98
|
-
header: 'Responsável',
|
|
99
|
-
render: (item) => (
|
|
100
|
-
<div className="flex items-center gap-2">
|
|
101
|
-
<Avatar src={item.user.avatar} />
|
|
102
|
-
<span>{item.user.name}</span>
|
|
103
|
-
</div>
|
|
104
|
-
)
|
|
105
|
-
},
|
|
106
|
-
]`;function ie(){return e.jsxs(X,{title:"createCrudPage",description:"Factory de alto nível que gera uma página CRUD completa com ~15 linhas de configuração declarativa.",tocItems:[{id:"geracao-automatica",label:"Geração Automática"},{id:"uso-basico",label:"Uso Básico"},{id:"com-filtros",label:"Com Filtros"},{id:"com-acoes",label:"Com Ações Customizadas"},{id:"com-wizard",label:"Com Wizard"},{id:"render-customizado",label:"Render Customizado"},{id:"referencia-props",label:"Referência de Props"},{id:"quando-usar",label:"Quando Usar"},{id:"docs-detalhadas",label:"Documentação Detalhada"}],children:[e.jsxs(m,{id:"geracao-automatica",className:"scroll-mt-4",children:[e.jsx(x,{children:e.jsx(h,{children:"O que o createCrudPage gera automaticamente?"})}),e.jsx(u,{children:e.jsxs("ul",{className:"grid grid-cols-1 md:grid-cols-2 gap-2 text-sm",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(a,{className:"h-4 w-4 text-green-500"}),"Tabela com paginação e ordenação"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(a,{className:"h-4 w-4 text-green-500"}),"Formulário modal para criar/editar"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(a,{className:"h-4 w-4 text-green-500"}),"Barra de busca integrada"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(a,{className:"h-4 w-4 text-green-500"}),"Filtros customizáveis"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(a,{className:"h-4 w-4 text-green-500"}),"Ações de editar/excluir/toggle"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(a,{className:"h-4 w-4 text-green-500"}),"Dropdown de ações em lote"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(a,{className:"h-4 w-4 text-green-500"}),"Estados de loading/empty"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(a,{className:"h-4 w-4 text-green-500"}),"Integração automática com service"]})]})})]}),e.jsx(l,{}),e.jsxs("section",{id:"uso-basico",className:"space-y-4 scroll-mt-4",children:[e.jsx("h2",{className:"text-2xl font-semibold",children:"Uso Básico"}),e.jsxs(i,{defaultValue:"preview",className:"w-full",children:[e.jsxs(d,{className:"mb-4",children:[e.jsxs(r,{value:"preview",className:"gap-2",children:[e.jsx(T,{size:16}),"Preview"]}),e.jsxs(r,{value:"code",className:"gap-2",children:[e.jsx(o,{size:16}),"Código"]})]}),e.jsxs(c,{value:"preview",className:"mt-0",children:[e.jsx(Z,{}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Este é um preview interativo do que o createCrudPage gera automaticamente."})]}),e.jsx(c,{value:"code",className:"mt-0",children:e.jsx("pre",{className:"bg-muted p-4 rounded-lg overflow-x-auto text-xs",children:e.jsx("code",{children:ee})})})]})]}),e.jsx(l,{}),e.jsxs("section",{id:"com-filtros",className:"space-y-4 scroll-mt-4",children:[e.jsx("h2",{className:"text-2xl font-semibold",children:"Com Filtros"}),e.jsxs(i,{defaultValue:"code",className:"w-full",children:[e.jsx(d,{className:"mb-4",children:e.jsxs(r,{value:"code",className:"gap-2",children:[e.jsx(o,{size:16}),"Código"]})}),e.jsx(c,{value:"code",className:"mt-0",children:e.jsx("pre",{className:"bg-muted p-4 rounded-lg overflow-x-auto text-xs",children:e.jsx("code",{children:se})})})]})]}),e.jsx(l,{}),e.jsxs("section",{id:"com-acoes",className:"space-y-4 scroll-mt-4",children:[e.jsx("h2",{className:"text-2xl font-semibold",children:"Com Ações Customizadas"}),e.jsxs(i,{defaultValue:"code",className:"w-full",children:[e.jsx(d,{className:"mb-4",children:e.jsxs(r,{value:"code",className:"gap-2",children:[e.jsx(o,{size:16}),"Código"]})}),e.jsx(c,{value:"code",className:"mt-0",children:e.jsx("pre",{className:"bg-muted p-4 rounded-lg overflow-x-auto text-xs",children:e.jsx("code",{children:ae})})})]})]}),e.jsx(l,{}),e.jsxs("section",{id:"com-wizard",className:"space-y-4 scroll-mt-4",children:[e.jsx("h2",{className:"text-2xl font-semibold",children:"Com Wizard ou Roteamento Customizado"}),e.jsxs(i,{defaultValue:"code",className:"w-full",children:[e.jsx(d,{className:"mb-4",children:e.jsxs(r,{value:"code",className:"gap-2",children:[e.jsx(o,{size:16}),"Código"]})}),e.jsx(c,{value:"code",className:"mt-0",children:e.jsx("pre",{className:"bg-muted p-4 rounded-lg overflow-x-auto text-xs",children:e.jsx("code",{children:le})})})]})]}),e.jsx(l,{}),e.jsxs("section",{id:"render-customizado",className:"space-y-4 scroll-mt-4",children:[e.jsx("h2",{className:"text-2xl font-semibold",children:"Render Customizado de Colunas"}),e.jsxs(i,{defaultValue:"code",className:"w-full",children:[e.jsx(d,{className:"mb-4",children:e.jsxs(r,{value:"code",className:"gap-2",children:[e.jsx(o,{size:16}),"Código"]})}),e.jsx(c,{value:"code",className:"mt-0",children:e.jsx("pre",{className:"bg-muted p-4 rounded-lg overflow-x-auto text-xs",children:e.jsx("code",{children:te})})})]})]}),e.jsx(l,{}),e.jsxs("section",{id:"referencia-props",className:"space-y-4 scroll-mt-4",children:[e.jsx("h2",{className:"text-2xl font-semibold",children:"Referência de Props"}),e.jsxs(m,{children:[e.jsx(x,{children:e.jsx(h,{children:"SimpleCrudPageConfig"})}),e.jsx(u,{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",{className:"divide-y",children:[e.jsxs("tr",{children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"entityName"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"string"}),e.jsx("td",{className:"p-2",children:'Nome singular (ex: "Nota")'})]}),e.jsxs("tr",{children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"entityNamePlural"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"string"}),e.jsx("td",{className:"p-2",children:'Nome plural (ex: "Notas")'})]}),e.jsxs("tr",{children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"service"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"SimpleService"}),e.jsx("td",{className:"p-2",children:"Serviço criado com createSimpleService"})]}),e.jsxs("tr",{children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"columns"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"CrudColumn[]"}),e.jsx("td",{className:"p-2",children:"Definição das colunas da tabela"})]}),e.jsxs("tr",{children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"formSections"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"FormSection[]"}),e.jsx("td",{className:"p-2",children:"Seções do formulário"})]}),e.jsxs("tr",{children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"filters"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"CrudFilter[]"}),e.jsx("td",{className:"p-2",children:"Filtros customizados"})]}),e.jsxs("tr",{children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"defaultSort"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"{column, direction}"}),e.jsx("td",{className:"p-2",children:"Ordenação inicial"})]}),e.jsxs("tr",{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 múltipla e dropdown de ações"})]}),e.jsxs("tr",{children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"bulkActions"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"BulkAction[]"}),e.jsx("td",{className:"p-2",children:"Ações em massa no dropdown"})]}),e.jsxs("tr",{children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"customActions"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"Action[]"}),e.jsx("td",{className:"p-2",children:"Ações na toolbar"})]}),e.jsxs("tr",{children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"customRowActions"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"(item) => Action[]"}),e.jsx("td",{className:"p-2",children:"Ações por linha"})]}),e.jsxs("tr",{className:"bg-muted/50",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"onNew"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"() => void"}),e.jsx("td",{className:"p-2",children:'Handler customizado para "Novo"'})]}),e.jsxs("tr",{className:"bg-muted/50",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"hideNewButton"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"boolean"}),e.jsx("td",{className:"p-2",children:'Esconde o botão "Novo"'})]}),e.jsxs("tr",{className:"bg-muted/50",children:[e.jsx("td",{className:"p-2",children:e.jsx("code",{children:"useCustomRouting"})}),e.jsx("td",{className:"p-2 text-muted-foreground",children:"boolean"}),e.jsx("td",{className:"p-2",children:"Desabilita BaseForm padrão"})]})]})]})})})]})]}),e.jsx(l,{}),e.jsxs("section",{id:"quando-usar",className:"space-y-4 scroll-mt-4",children:[e.jsx("h2",{className:"text-2xl font-semibold",children:"Quando usar?"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(m,{className:"border-green-500/20 bg-green-500/5",children:[e.jsx(x,{children:e.jsxs(h,{className:"text-green-600 flex items-center gap-2",children:[e.jsx(a,{className:"h-5 w-5"}),"Use createCrudPage quando:"]})}),e.jsx(u,{children:e.jsxs("ul",{className:"space-y-2 text-sm",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(t,{className:"h-4 w-4"}),"Precisa de um CRUD padrão rapidamente"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(t,{className:"h-4 w-4"}),"Layout tabela + formulário atende"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(t,{className:"h-4 w-4"}),"Quer consistência com outros CRUDs"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(t,{className:"h-4 w-4"}),"Produtividade é prioridade"]})]})})]}),e.jsxs(m,{className:"border-orange-500/20 bg-orange-500/5",children:[e.jsx(x,{children:e.jsxs(h,{className:"text-orange-600 flex items-center gap-2",children:[e.jsx(z,{className:"h-5 w-5"}),"Use CrudTable/CrudGrid quando:"]})}),e.jsx(u,{children:e.jsxs("ul",{className:"space-y-2 text-sm",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(t,{className:"h-4 w-4"}),"Precisa de layout muito customizado"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(t,{className:"h-4 w-4"}),"Múltiplas tabelas na mesma página"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(t,{className:"h-4 w-4"}),"Lógica de negócio complexa"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(t,{className:"h-4 w-4"}),"Controle total sobre a UI"]})]})})]})]})]}),e.jsx(l,{}),e.jsxs("section",{id:"docs-detalhadas",className:"space-y-4 scroll-mt-4",children:[e.jsx("h2",{className:"text-2xl font-semibold",children:"Documentação Detalhada"}),e.jsx("p",{className:"text-muted-foreground",children:"Para customizações avançadas e composição manual, consulte:"}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs(j,{to:"/ds/crud-table",className:"flex items-center gap-2 p-4 border rounded-lg hover:bg-muted transition-colors",children:[e.jsx(p,{className:"h-4 w-4"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:"CrudTable"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Composição manual com controle total"})]})]}),e.jsxs(j,{to:"/ds/crud-baseform",className:"flex items-center gap-2 p-4 border rounded-lg hover:bg-muted transition-colors",children:[e.jsx(p,{className:"h-4 w-4"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:"BaseForm"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Tipos de campo e grupos"})]})]}),e.jsxs(j,{to:"/ds/crud-pagination",className:"flex items-center gap-2 p-4 border rounded-lg hover:bg-muted transition-colors",children:[e.jsx(p,{className:"h-4 w-4"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:"CrudPagination"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Controles de paginação"})]})]}),e.jsxs(j,{to:"/ds/crud",className:"flex items-center gap-2 p-4 border rounded-lg hover:bg-muted transition-colors",children:[e.jsx(p,{className:"h-4 w-4"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:"Visão Geral do CRUD"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Arquitetura e níveis de abstração"})]})]})]})]})]})}export{ie as CreateCrudPageDoc};
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import{r as s,j as e,B as o,C as r,a as l,b as n,d,ey as a,d4 as c,d5 as i,d6 as x,d7 as u,d8 as t,cl as E,cm as V,cn as m,co as h}from"./index-CE0k7Rdh.js";import{C as k,E as p}from"./ComponentDocTemplate-CRbRY-v5.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 R(){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(E,{defaultValue:"createCrudPage",className:"w-full",children:[e.jsxs(V,{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{R as CrudActionBarDoc};
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import{ep as Ce,r as o,j as e,ey as be,aH as ye,ao as we,dk as ke,dl as Se,C as g,d as v,eB as le,l as E,eC as de,dm as Me,eD as Ie,cl as Pe,cm as Te,cn as te,co as ie,a as se,b as ae,f as b,P as Ee,c0 as De,I as O,Q as Re,R as ce,bE as ze,bB as ne,d4 as D,d5 as R,d6 as z,d7 as A,d8 as t,n as Ae,o as Fe,p as Ve,q as H,x as Be,u as j,ce as Ge,T as oe,cs as Le,ct as $e,bn as qe,B as W,cu as Ue,ci as Oe,eA as He,d$ as me,e1 as xe,e2 as ue,e3 as he,L as F,e5 as je}from"./index-CE0k7Rdh.js";import{D as pe}from"./disabled-menu-item-C16xsaVs.js";import{u as We,c as _e}from"./useMockCrud-GY0KxHXr.js";import{C as Qe}from"./ComponentDocTemplate-CRbRY-v5.js";import{P as ge}from"./pen-BYSSwjK4.js";const Xe=({manager:r,columns:N,onEdit:d,onView:f,onToggleStatus:n,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:X,bulkActions:k=[],onBulkDelete:M,filters:I,gridColumns:c=3,renderCard:h,viewMode:J,onViewModeChange:K,listCardRenderer:L,gridCardRenderer:$,showViewToggle:q=!1})=>{const{setSearchVisible:P}=Ce(),Y=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||q,U=Y&&Z,s=M||(()=>{r.bulkDelete?.(r.selectedIds)}),T=J||"grid",y=T==="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:c],Ne=a=>y&&L?L(a):!y&&$?$(a):h?h(a):null,ee=U?e.jsx(be,{onNew:V,newButtonLabel:_,showNewButton:i,showSearch:u,searchValue:S,onSearchChange:G,searchPlaceholder:X,showBulkActions:x,selectedCount:r.selectedIds.length,bulkActions:k,onBulkDelete:s,onClearSelection:r.clearSelection,customActions:w,filters:I,viewMode:T,onViewModeChange:K,showViewToggle:q,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:E("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):d?.(a)},children:re}):e.jsx(g,{className:E("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):d?.(a)},children:e.jsxs(v,{className:E("p-4",y&&"flex items-center gap-4 w-full"),children:[x&&e.jsx("div",{className:E(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)))}),(d||f||p)&&e.jsx("div",{onClick:l=>l.stopPropagation(),children:p?p(a):e.jsx(de,{onEdit:d?()=>d(a):void 0,onDelete:m?()=>m(a):void 0,onToggleStatus:n?()=>n(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:E("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))),(d||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(de,{onEdit:d?()=>d(a):void 0,onDelete:m?()=>m(a):void 0,onToggleStatus:n?()=>n(a):void 0,isActive:a.is_actived,customActions:C?C(a):[]})})]})]})]})})}),e.jsx(Me,{className:"w-[160px]",children:e.jsx(Ie,{onEdit:d?()=>d(a):void 0,onDelete:m?()=>m(a):void 0,onToggleStatus:n?()=>n(a):void 0,isActive:a.is_actived,canDelete:!!m,customActions:C?C(a):[],renderAs:"context"})})]},a.id)})})})]})},Je=Array.from({length:50},(r,N)=>{const d=N+1,f=["Eletrônicos","Móveis","Vestuário","Alimentos"],n=f[d%f.length],m=d%5===0?"Inativo":"Ativo";return _e({id:String(d),name:`Produto ${String(d).padStart(3,"0")}`,category:n,price:Math.floor(Math.random()*1e3)+50,stock:Math.floor(Math.random()*100),status:m})}),Ke=[{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 Ye(){const[r,N]=o.useState(""),[d,f]=o.useState(""),[n,m]=o.useState(""),[p,C]=o.useState(3),[x,V]=o.useState("grid"),_=o.useCallback(s=>{if(r&&s.category!==r||d&&s.status!==d)return!1;if(n){const T=n.toLowerCase();return s.name.toLowerCase().includes(T)||s.category.toLowerCase().includes(T)}return!0},[r,d,n]),i=We(Je,{searchFields:["name","category"],pageSize:9,filterFn:_}),w=[r,d].filter(Boolean).length,B=()=>{N(""),f("")},[Q,u]=o.useState(!1),[S,G]=o.useState(null),[X,k]=o.useState(!1),[M,I]=o.useState(null),[c,h]=o.useState({name:"",category:"",price:0,stock:0,status:"Ativo"}),J=()=>{G(null),h({name:"",category:"",price:0,stock:0,status:"Ativo"}),u(!0)},K=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]})]})]})}),q=async()=>{if(!c.name){j.error("Nome é obrigatório");return}S?(await i.updateEntity(S.id,c),j.success("Produto atualizado!")):(await i.createEntity(c),j.success("Produto criado!")),u(!1)},P=async s=>{await i.updateEntity(s.id,{status:s.status==="Ativo"?"Inativo":"Ativo"}),j.success("Status alterado!")},Y=s=>{I(s),k(!0)},Z=()=>{M&&(i.deleteEntity(M.id),j.success("Produto excluído!")),k(!1),I(null)},U=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:J,children:[e.jsx(Ee,{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:n,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(ce,{value:"list","aria-label":"Visualização em lista",children:e.jsx(ze,{className:"h-4 w-4"})}),e.jsx(ce,{value:"grid","aria-label":"Visualização em grade",children:e.jsx(ne,{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(ne,{className:"h-4 w-4 mr-2"}),e.jsx(z,{})]}),e.jsxs(A,{children:[e.jsx(t,{value:"1",children:"1 col"}),e.jsx(t,{value:"2",children:"2 cols"}),e.jsx(t,{value:"3",children:"3 cols"}),e.jsx(t,{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:()=>U("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:()=>U("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(qe,{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(Ue,{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(t,{value:"all",children:"Todas"}),e.jsx(t,{value:"Eletrônicos",children:"Eletrônicos"}),e.jsx(t,{value:"Móveis",children:"Móveis"}),e.jsx(t,{value:"Vestuário",children:"Vestuário"}),e.jsx(t,{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:d||"all",onValueChange:s=>f(s==="all"?"":s),children:[e.jsx(R,{children:e.jsx(z,{placeholder:"Todos"})}),e.jsxs(A,{children:[e.jsx(t,{value:"all",children:"Todos"}),e.jsx(t,{value:"Ativo",children:"Ativo"}),e.jsx(t,{value:"Inativo",children:"Inativo"})]})]})]})]})]})})]})]})]}),e.jsx(Xe,{manager:i,columns:Ke,onEdit:K,onToggleStatus:P,onDelete:Y,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:c.name,onChange:s=>h({...c,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:c.category,onValueChange:s=>h({...c,category:s}),children:[e.jsx(R,{children:e.jsx(z,{placeholder:"Selecione"})}),e.jsxs(A,{children:[e.jsx(t,{value:"Eletrônicos",children:"Eletrônicos"}),e.jsx(t,{value:"Móveis",children:"Móveis"}),e.jsx(t,{value:"Vestuário",children:"Vestuário"}),e.jsx(t,{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:c.price,onChange:s=>h({...c,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:c.stock,onChange:s=>h({...c,stock:Number(s.target.value)})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(F,{htmlFor:"status",children:"Status"}),e.jsxs(D,{value:c.status,onValueChange:s=>h({...c,status:s}),children:[e.jsx(R,{children:e.jsx(z,{})}),e.jsxs(A,{children:[e.jsx(t,{value:"Ativo",children:"Ativo"}),e.jsx(t,{value:"Inativo",children:"Inativo"})]})]})]})]})]}),e.jsxs(je,{children:[e.jsx(b,{variant:"outline",onClick:()=>u(!1),children:"Cancelar"}),e.jsx(b,{onClick:q,children:"Salvar"})]})]})}),e.jsx(me,{open:X,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(Te,{children:[e.jsx(te,{value:"preview",children:"Preview"}),e.jsx(te,{value:"code",children:"Código"})]}),e.jsx(ie,{value:"preview",children:e.jsx(Ye,{})}),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};
|