@archbase/components 3.0.25 → 4.0.1
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/dist/buttons/ArchbaseSpeedDial.d.ts +59 -0
- package/dist/buttons/index.d.ts +2 -0
- package/dist/charts/ArchbaseArcGauge.d.ts +55 -0
- package/dist/charts/ArchbaseGantt.d.ts +70 -0
- package/dist/charts/ArchbaseLinearGauge.d.ts +55 -0
- package/dist/charts/ArchbaseResourceTimeline.d.ts +61 -0
- package/dist/charts/ArchbaseSparkline.d.ts +45 -0
- package/dist/charts/index.d.ts +10 -0
- package/dist/containers/ArchbaseExpansionPanel.d.ts +60 -0
- package/dist/containers/ArchbaseFloatingPanel.d.ts +91 -0
- package/dist/containers/index.d.ts +4 -0
- package/dist/datagrid/export/ArchbaseDataGridExcelExport.d.ts +67 -0
- package/dist/datagrid/export/index.d.ts +2 -0
- package/dist/datagrid/index.d.ts +1 -0
- package/dist/display/ArchbaseAnimationWrapper.d.ts +73 -0
- package/dist/display/ArchbaseBarcodeGenerator.d.ts +50 -0
- package/dist/display/ArchbaseCarousel.d.ts +100 -0
- package/dist/display/ArchbaseCodeViewer.d.ts +63 -0
- package/dist/display/ArchbaseDiffViewer.d.ts +41 -0
- package/dist/display/ArchbaseJsonTree.d.ts +34 -0
- package/dist/display/ArchbaseLightbox.d.ts +89 -0
- package/dist/display/ArchbaseMarquee.d.ts +46 -0
- package/dist/display/ArchbasePhotoAlbum.d.ts +58 -0
- package/dist/display/ArchbaseQRCode.d.ts +44 -0
- package/dist/display/ArchbaseTooltipRich.d.ts +82 -0
- package/dist/display/ArchbaseVirtualList.d.ts +116 -0
- package/dist/display/index.d.ts +24 -0
- package/dist/editors/ArchbaseAIPromptInput.d.ts +69 -0
- package/dist/editors/ArchbaseAsyncMultiSelect.d.ts +1 -1
- package/dist/editors/ArchbaseAsyncSelect.d.ts +1 -1
- package/dist/editors/ArchbaseBarcodeScanner.d.ts +63 -0
- package/dist/editors/ArchbaseCepInput.d.ts +26 -0
- package/dist/editors/ArchbaseColorGradientPicker.d.ts +80 -0
- package/dist/editors/ArchbaseCpfCnpjInput.d.ts +21 -0
- package/dist/editors/ArchbaseCurrencyInput.d.ts +25 -0
- package/dist/editors/ArchbaseDualListbox.d.ts +61 -0
- package/dist/editors/ArchbaseInPlaceEditor.d.ts +67 -0
- package/dist/editors/ArchbaseLightGrid.d.ts +56 -0
- package/dist/editors/ArchbaseMentionInput.d.ts +75 -0
- package/dist/editors/ArchbaseMultiEmail.d.ts +53 -0
- package/dist/editors/ArchbaseMultiViewCalendar.d.ts +47 -0
- package/dist/editors/ArchbaseNumberStepper.d.ts +66 -0
- package/dist/editors/ArchbaseOTPInput.d.ts +27 -0
- package/dist/editors/ArchbasePhoneInput.d.ts +52 -0
- package/dist/editors/ArchbaseRangeSlider.d.ts +22 -0
- package/dist/editors/ArchbaseSignaturePad.d.ts +60 -0
- package/dist/editors/ArchbaseSpeechToTextInput.d.ts +106 -0
- package/dist/editors/ArchbaseSpreadsheet.d.ts +56 -0
- package/dist/editors/ArchbaseTagInput.d.ts +55 -0
- package/dist/editors/index.d.ts +40 -0
- package/dist/feedback/ArchbaseChunkProgressBar.d.ts +35 -0
- package/dist/feedback/ArchbaseRipple.d.ts +43 -0
- package/dist/feedback/ArchbaseSkeleton.d.ts +115 -0
- package/dist/feedback/index.d.ts +6 -0
- package/dist/filters/ArchbaseColumnSelector.d.ts +38 -0
- package/dist/filters/index.d.ts +2 -0
- package/dist/forms/ArchbaseFieldArray.d.ts +80 -0
- package/dist/forms/ArchbaseFormWizard.d.ts +73 -0
- package/dist/forms/ArchbaseStepper.d.ts +51 -0
- package/dist/forms/index.d.ts +8 -0
- package/dist/forms/useArchbaseFormWizard.d.ts +74 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/useArchbaseConfirm.d.ts +59 -0
- package/dist/image/editor/index.d.ts +43 -4
- package/dist/image/index.d.ts +1 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +22510 -13820
- package/dist/list/ArchbaseTreeList.d.ts +76 -0
- package/dist/list/index.d.ts +2 -0
- package/dist/navigation/ArchbaseActionSheet.d.ts +70 -0
- package/dist/navigation/ArchbaseAppBar.d.ts +63 -0
- package/dist/navigation/ArchbaseBottomNavigation.d.ts +61 -0
- package/dist/navigation/ArchbaseContextMenu.d.ts +76 -0
- package/dist/navigation/ArchbaseKeyboardShortcuts.d.ts +85 -0
- package/dist/navigation/ArchbaseSpotlight.d.ts +69 -0
- package/dist/navigation/index.d.ts +12 -0
- package/dist/notification/ArchbaseNotificationCenter.d.ts +56 -0
- package/dist/notification/index.d.ts +2 -0
- package/dist/onboarding/ArchbaseOnboardingTour.d.ts +27 -76
- package/dist/viewers/ArchbaseDocViewer.d.ts +40 -0
- package/dist/viewers/ArchbasePdfBuilder.d.ts +53 -0
- package/dist/viewers/ArchbaseXmlViewer.d.ts +36 -0
- package/dist/viewers/index.d.ts +6 -0
- package/package.json +41 -18
- package/src/buttons/ArchbaseSpeedDial.tsx +282 -0
- package/src/buttons/index.ts +3 -0
- package/src/charts/ArchbaseArcGauge.tsx +325 -0
- package/src/charts/ArchbaseGantt.tsx +494 -0
- package/src/charts/ArchbaseLinearGauge.tsx +288 -0
- package/src/charts/ArchbaseResourceTimeline.tsx +433 -0
- package/src/charts/ArchbaseSparkline.tsx +193 -0
- package/src/charts/index.ts +20 -1
- package/src/containers/ArchbaseExpansionPanel.tsx +208 -0
- package/src/containers/ArchbaseFloatingPanel.tsx +448 -0
- package/src/containers/index.ts +17 -0
- package/src/datagrid/components/pagination/grid-pagination.tsx +2 -2
- package/src/datagrid/export/ArchbaseDataGridExcelExport.tsx +293 -0
- package/src/datagrid/export/index.ts +8 -0
- package/src/datagrid/index.tsx +2 -0
- package/src/display/ArchbaseAnimationWrapper.tsx +272 -0
- package/src/display/ArchbaseBarcodeGenerator.tsx +303 -0
- package/src/display/ArchbaseCarousel.tsx +679 -0
- package/src/display/ArchbaseCodeViewer.tsx +271 -0
- package/src/display/ArchbaseDiffViewer.tsx +108 -0
- package/src/display/ArchbaseJsonTree.tsx +150 -0
- package/src/display/ArchbaseLightbox.tsx +279 -0
- package/src/display/ArchbaseMarquee.tsx +268 -0
- package/src/display/ArchbasePhotoAlbum.tsx +415 -0
- package/src/display/ArchbaseQRCode.tsx +137 -0
- package/src/display/ArchbaseTooltipRich.tsx +317 -0
- package/src/display/ArchbaseVirtualList.tsx +618 -0
- package/src/display/index.ts +94 -1
- package/src/editors/ArchbaseAIPromptInput.tsx +432 -0
- package/src/editors/ArchbaseBarcodeScanner.tsx +570 -0
- package/src/editors/ArchbaseCepInput.tsx +173 -0
- package/src/editors/ArchbaseColorGradientPicker.tsx +460 -0
- package/src/editors/ArchbaseCpfCnpjInput.tsx +193 -0
- package/src/editors/ArchbaseCurrencyInput.tsx +100 -0
- package/src/editors/ArchbaseDualListbox.tsx +671 -0
- package/src/editors/ArchbaseInPlaceEditor.tsx +406 -0
- package/src/editors/ArchbaseLightGrid.tsx +538 -0
- package/src/editors/ArchbaseMentionInput.tsx +384 -0
- package/src/editors/ArchbaseMultiEmail.tsx +367 -0
- package/src/editors/ArchbaseMultiViewCalendar.tsx +439 -0
- package/src/editors/ArchbaseNumberStepper.tsx +219 -0
- package/src/editors/ArchbaseOTPInput.tsx +133 -0
- package/src/editors/ArchbaseOperationHoursEditor.tsx +1 -1
- package/src/editors/ArchbasePhoneInput.tsx +355 -0
- package/src/editors/ArchbaseRangeSlider.tsx +109 -0
- package/src/editors/ArchbaseSignaturePad.tsx +425 -0
- package/src/editors/ArchbaseSpeechToTextInput.tsx +444 -0
- package/src/editors/ArchbaseSpreadsheet.tsx +388 -0
- package/src/editors/ArchbaseTagInput.tsx +326 -0
- package/src/editors/index.tsx +92 -0
- package/src/feedback/ArchbaseChunkProgressBar.tsx +156 -0
- package/src/feedback/ArchbaseRipple.tsx +278 -0
- package/src/feedback/ArchbaseSkeleton.tsx +419 -0
- package/src/feedback/index.ts +22 -1
- package/src/filters/ArchbaseColumnSelector.tsx +268 -0
- package/src/filters/index.ts +2 -0
- package/src/forms/ArchbaseFieldArray.tsx +305 -0
- package/src/forms/ArchbaseFormWizard.tsx +284 -0
- package/src/forms/ArchbaseStepper.tsx +137 -0
- package/src/forms/index.ts +24 -2
- package/src/forms/useArchbaseFormWizard.ts +283 -0
- package/src/hooks/index.ts +12 -0
- package/src/hooks/useArchbaseConfirm.ts +293 -0
- package/src/image/editor/functions/image-processing.ts +5 -0
- package/src/image/editor/index.tsx +305 -391
- package/src/image/index.ts +1 -0
- package/src/index.ts +3 -0
- package/src/list/ArchbaseTreeList.tsx +422 -0
- package/src/list/index.ts +3 -0
- package/src/navigation/ArchbaseActionSheet.tsx +301 -0
- package/src/navigation/ArchbaseAppBar.tsx +233 -0
- package/src/navigation/ArchbaseBottomNavigation.tsx +243 -0
- package/src/navigation/ArchbaseContextMenu.tsx +298 -0
- package/src/navigation/ArchbaseKeyboardShortcuts.tsx +472 -0
- package/src/navigation/ArchbaseSpotlight.tsx +483 -0
- package/src/navigation/index.ts +48 -1
- package/src/notification/ArchbaseNotificationCenter.tsx +502 -0
- package/src/notification/index.ts +2 -0
- package/src/onboarding/ArchbaseOnboardingTour.tsx +229 -102
- package/src/viewers/ArchbaseDocViewer.tsx +584 -0
- package/src/viewers/ArchbasePdfBuilder.tsx +291 -0
- package/src/viewers/ArchbaseXmlViewer.tsx +142 -0
- package/src/viewers/index.ts +12 -0
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import React, { forwardRef, useCallback, ReactNode } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Drawer,
|
|
4
|
+
DrawerProps,
|
|
5
|
+
Menu,
|
|
6
|
+
Button,
|
|
7
|
+
Stack,
|
|
8
|
+
Group,
|
|
9
|
+
Text,
|
|
10
|
+
Divider,
|
|
11
|
+
Box,
|
|
12
|
+
MantineColor,
|
|
13
|
+
MantineSize,
|
|
14
|
+
} from '@mantine/core';
|
|
15
|
+
import { useMediaQuery } from '@mantine/hooks';
|
|
16
|
+
|
|
17
|
+
export interface ArchbaseActionSheetItem {
|
|
18
|
+
/** Chave única */
|
|
19
|
+
key: string;
|
|
20
|
+
/** Tipo do item */
|
|
21
|
+
type?: 'item' | 'divider';
|
|
22
|
+
/** Label do item */
|
|
23
|
+
label?: string;
|
|
24
|
+
/** Descrição */
|
|
25
|
+
description?: string;
|
|
26
|
+
/** Ícone */
|
|
27
|
+
icon?: ReactNode;
|
|
28
|
+
/** Cor */
|
|
29
|
+
color?: MantineColor;
|
|
30
|
+
/** Se está desabilitado */
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
/** Callback ao clicar */
|
|
33
|
+
onClick?: () => void;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface ArchbaseActionSheetProps {
|
|
37
|
+
/** Itens do action sheet */
|
|
38
|
+
items: ArchbaseActionSheetItem[];
|
|
39
|
+
/** Se está aberto */
|
|
40
|
+
opened: boolean;
|
|
41
|
+
/** Callback ao fechar */
|
|
42
|
+
onClose: () => void;
|
|
43
|
+
/** Título */
|
|
44
|
+
title?: string;
|
|
45
|
+
/** Descrição */
|
|
46
|
+
description?: string;
|
|
47
|
+
/** Label do botão cancelar */
|
|
48
|
+
cancelLabel?: string;
|
|
49
|
+
/** Se deve mostrar botão cancelar */
|
|
50
|
+
showCancel?: boolean;
|
|
51
|
+
/** Breakpoint para mudar de drawer para menu */
|
|
52
|
+
breakpoint?: string;
|
|
53
|
+
/** Posição do menu no desktop */
|
|
54
|
+
menuPosition?: 'bottom' | 'top' | 'left' | 'right';
|
|
55
|
+
/** Elemento alvo do menu (desktop) */
|
|
56
|
+
target?: ReactNode;
|
|
57
|
+
/** Tamanho */
|
|
58
|
+
size?: MantineSize;
|
|
59
|
+
/** Raio das bordas do drawer */
|
|
60
|
+
radius?: MantineSize;
|
|
61
|
+
/** Se deve ter overlay */
|
|
62
|
+
withOverlay?: boolean;
|
|
63
|
+
/** Classe CSS */
|
|
64
|
+
className?: string;
|
|
65
|
+
/** Estilo */
|
|
66
|
+
style?: React.CSSProperties;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export const ArchbaseActionSheet = forwardRef<HTMLDivElement, ArchbaseActionSheetProps>(
|
|
70
|
+
(
|
|
71
|
+
{
|
|
72
|
+
items,
|
|
73
|
+
opened,
|
|
74
|
+
onClose,
|
|
75
|
+
title,
|
|
76
|
+
description,
|
|
77
|
+
cancelLabel = 'Cancelar',
|
|
78
|
+
showCancel = true,
|
|
79
|
+
breakpoint = '48em',
|
|
80
|
+
menuPosition = 'bottom',
|
|
81
|
+
target,
|
|
82
|
+
size = 'md',
|
|
83
|
+
radius = 'lg',
|
|
84
|
+
withOverlay = true,
|
|
85
|
+
className,
|
|
86
|
+
style,
|
|
87
|
+
},
|
|
88
|
+
ref
|
|
89
|
+
) => {
|
|
90
|
+
const isMobile = useMediaQuery(`(max-width: ${breakpoint})`);
|
|
91
|
+
|
|
92
|
+
const handleItemClick = useCallback(
|
|
93
|
+
(item: ArchbaseActionSheetItem) => {
|
|
94
|
+
if (item.disabled) return;
|
|
95
|
+
item.onClick?.();
|
|
96
|
+
onClose();
|
|
97
|
+
},
|
|
98
|
+
[onClose]
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
const renderItem = (item: ArchbaseActionSheetItem) => {
|
|
102
|
+
if (item.type === 'divider') {
|
|
103
|
+
return <Divider key={item.key} my="xs" />;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return (
|
|
107
|
+
<Button
|
|
108
|
+
key={item.key}
|
|
109
|
+
variant="subtle"
|
|
110
|
+
color={item.color || 'dark'}
|
|
111
|
+
size={size}
|
|
112
|
+
fullWidth
|
|
113
|
+
justify="flex-start"
|
|
114
|
+
leftSection={item.icon}
|
|
115
|
+
disabled={item.disabled}
|
|
116
|
+
onClick={() => handleItemClick(item)}
|
|
117
|
+
styles={{
|
|
118
|
+
root: {
|
|
119
|
+
height: 'auto',
|
|
120
|
+
padding: '12px 16px',
|
|
121
|
+
},
|
|
122
|
+
inner: {
|
|
123
|
+
justifyContent: 'flex-start',
|
|
124
|
+
},
|
|
125
|
+
}}
|
|
126
|
+
>
|
|
127
|
+
<Stack gap={0} align="flex-start">
|
|
128
|
+
<Text size={size} fw={500}>
|
|
129
|
+
{item.label}
|
|
130
|
+
</Text>
|
|
131
|
+
{item.description && (
|
|
132
|
+
<Text size="xs" c="dimmed">
|
|
133
|
+
{item.description}
|
|
134
|
+
</Text>
|
|
135
|
+
)}
|
|
136
|
+
</Stack>
|
|
137
|
+
</Button>
|
|
138
|
+
);
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
// Mobile: Drawer from bottom
|
|
142
|
+
if (isMobile) {
|
|
143
|
+
return (
|
|
144
|
+
<Drawer
|
|
145
|
+
ref={ref}
|
|
146
|
+
opened={opened}
|
|
147
|
+
onClose={onClose}
|
|
148
|
+
position="bottom"
|
|
149
|
+
size="auto"
|
|
150
|
+
withOverlay={withOverlay}
|
|
151
|
+
radius={radius}
|
|
152
|
+
title={title}
|
|
153
|
+
className={className}
|
|
154
|
+
style={style}
|
|
155
|
+
styles={{
|
|
156
|
+
content: {
|
|
157
|
+
paddingBottom: 'env(safe-area-inset-bottom, 16px)',
|
|
158
|
+
},
|
|
159
|
+
header: {
|
|
160
|
+
paddingBottom: title ? 8 : 0,
|
|
161
|
+
},
|
|
162
|
+
}}
|
|
163
|
+
>
|
|
164
|
+
<Stack gap={0}>
|
|
165
|
+
{description && (
|
|
166
|
+
<Text size="sm" c="dimmed" mb="md">
|
|
167
|
+
{description}
|
|
168
|
+
</Text>
|
|
169
|
+
)}
|
|
170
|
+
|
|
171
|
+
{items.map(renderItem)}
|
|
172
|
+
|
|
173
|
+
{showCancel && (
|
|
174
|
+
<>
|
|
175
|
+
<Divider my="sm" />
|
|
176
|
+
<Button
|
|
177
|
+
variant="subtle"
|
|
178
|
+
color="gray"
|
|
179
|
+
size={size}
|
|
180
|
+
fullWidth
|
|
181
|
+
onClick={onClose}
|
|
182
|
+
>
|
|
183
|
+
{cancelLabel}
|
|
184
|
+
</Button>
|
|
185
|
+
</>
|
|
186
|
+
)}
|
|
187
|
+
</Stack>
|
|
188
|
+
</Drawer>
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Desktop: Menu dropdown
|
|
193
|
+
return (
|
|
194
|
+
<Menu
|
|
195
|
+
opened={opened}
|
|
196
|
+
onClose={onClose}
|
|
197
|
+
position={menuPosition}
|
|
198
|
+
shadow="md"
|
|
199
|
+
width={280}
|
|
200
|
+
>
|
|
201
|
+
<Menu.Target>{target || <Box />}</Menu.Target>
|
|
202
|
+
<Menu.Dropdown ref={ref} className={className} style={style}>
|
|
203
|
+
{title && <Menu.Label>{title}</Menu.Label>}
|
|
204
|
+
{description && (
|
|
205
|
+
<Text size="xs" c="dimmed" px="sm" pb="xs">
|
|
206
|
+
{description}
|
|
207
|
+
</Text>
|
|
208
|
+
)}
|
|
209
|
+
|
|
210
|
+
{items.map((item) => {
|
|
211
|
+
if (item.type === 'divider') {
|
|
212
|
+
return <Menu.Divider key={item.key} />;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return (
|
|
216
|
+
<Menu.Item
|
|
217
|
+
key={item.key}
|
|
218
|
+
leftSection={item.icon}
|
|
219
|
+
color={item.color}
|
|
220
|
+
disabled={item.disabled}
|
|
221
|
+
onClick={() => handleItemClick(item)}
|
|
222
|
+
>
|
|
223
|
+
<Stack gap={0}>
|
|
224
|
+
<Text size="sm">{item.label}</Text>
|
|
225
|
+
{item.description && (
|
|
226
|
+
<Text size="xs" c="dimmed">
|
|
227
|
+
{item.description}
|
|
228
|
+
</Text>
|
|
229
|
+
)}
|
|
230
|
+
</Stack>
|
|
231
|
+
</Menu.Item>
|
|
232
|
+
);
|
|
233
|
+
})}
|
|
234
|
+
|
|
235
|
+
{showCancel && (
|
|
236
|
+
<>
|
|
237
|
+
<Menu.Divider />
|
|
238
|
+
<Menu.Item color="gray" onClick={onClose}>
|
|
239
|
+
{cancelLabel}
|
|
240
|
+
</Menu.Item>
|
|
241
|
+
</>
|
|
242
|
+
)}
|
|
243
|
+
</Menu.Dropdown>
|
|
244
|
+
</Menu>
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
);
|
|
248
|
+
|
|
249
|
+
ArchbaseActionSheet.displayName = 'ArchbaseActionSheet';
|
|
250
|
+
|
|
251
|
+
// ================== Hook para uso programático ==================
|
|
252
|
+
|
|
253
|
+
export interface UseArchbaseActionSheetOptions {
|
|
254
|
+
items: ArchbaseActionSheetItem[];
|
|
255
|
+
title?: string;
|
|
256
|
+
description?: string;
|
|
257
|
+
cancelLabel?: string;
|
|
258
|
+
showCancel?: boolean;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export interface UseArchbaseActionSheetReturn {
|
|
262
|
+
opened: boolean;
|
|
263
|
+
open: () => void;
|
|
264
|
+
close: () => void;
|
|
265
|
+
toggle: () => void;
|
|
266
|
+
ActionSheet: React.FC<{ target?: ReactNode }>;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export function useArchbaseActionSheet(
|
|
270
|
+
options: UseArchbaseActionSheetOptions
|
|
271
|
+
): UseArchbaseActionSheetReturn {
|
|
272
|
+
const [opened, setOpened] = React.useState(false);
|
|
273
|
+
|
|
274
|
+
const open = useCallback(() => setOpened(true), []);
|
|
275
|
+
const close = useCallback(() => setOpened(false), []);
|
|
276
|
+
const toggle = useCallback(() => setOpened((prev) => !prev), []);
|
|
277
|
+
|
|
278
|
+
const ActionSheetComponent: React.FC<{ target?: ReactNode }> = useCallback(
|
|
279
|
+
({ target }) => (
|
|
280
|
+
<ArchbaseActionSheet
|
|
281
|
+
items={options.items}
|
|
282
|
+
opened={opened}
|
|
283
|
+
onClose={close}
|
|
284
|
+
title={options.title}
|
|
285
|
+
description={options.description}
|
|
286
|
+
cancelLabel={options.cancelLabel}
|
|
287
|
+
showCancel={options.showCancel}
|
|
288
|
+
target={target}
|
|
289
|
+
/>
|
|
290
|
+
),
|
|
291
|
+
[close, opened, options]
|
|
292
|
+
);
|
|
293
|
+
|
|
294
|
+
return {
|
|
295
|
+
opened,
|
|
296
|
+
open,
|
|
297
|
+
close,
|
|
298
|
+
toggle,
|
|
299
|
+
ActionSheet: ActionSheetComponent,
|
|
300
|
+
};
|
|
301
|
+
}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import React, { forwardRef, ReactNode } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Box,
|
|
4
|
+
Group,
|
|
5
|
+
ActionIcon,
|
|
6
|
+
Text,
|
|
7
|
+
Menu,
|
|
8
|
+
Burger,
|
|
9
|
+
MantineColor,
|
|
10
|
+
MantineSize,
|
|
11
|
+
} from '@mantine/core';
|
|
12
|
+
import { useMediaQuery, useDisclosure } from '@mantine/hooks';
|
|
13
|
+
import { IconDotsVertical } from '@tabler/icons-react';
|
|
14
|
+
|
|
15
|
+
export interface ArchbaseAppBarAction {
|
|
16
|
+
/** Chave única */
|
|
17
|
+
key: string;
|
|
18
|
+
/** Ícone */
|
|
19
|
+
icon: ReactNode;
|
|
20
|
+
/** Label (para menu mobile) */
|
|
21
|
+
label: string;
|
|
22
|
+
/** Callback ao clicar */
|
|
23
|
+
onClick: () => void;
|
|
24
|
+
/** Cor */
|
|
25
|
+
color?: MantineColor;
|
|
26
|
+
/** Se está desabilitado */
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
/** Se deve esconder no mobile */
|
|
29
|
+
hideOnMobile?: boolean;
|
|
30
|
+
/** Se deve mostrar sempre (não ir para menu) */
|
|
31
|
+
alwaysVisible?: boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface ArchbaseAppBarProps {
|
|
35
|
+
/** Seção esquerda (logo, back button, menu) */
|
|
36
|
+
leftSection?: ReactNode;
|
|
37
|
+
/** Seção central (título, busca) */
|
|
38
|
+
centerSection?: ReactNode;
|
|
39
|
+
/** Seção direita (ações, avatar) */
|
|
40
|
+
rightSection?: ReactNode;
|
|
41
|
+
/** Ações (alternativa ao rightSection) */
|
|
42
|
+
actions?: ArchbaseAppBarAction[];
|
|
43
|
+
/** Título */
|
|
44
|
+
title?: string;
|
|
45
|
+
/** Subtítulo */
|
|
46
|
+
subtitle?: string;
|
|
47
|
+
/** Altura */
|
|
48
|
+
height?: number;
|
|
49
|
+
/** Cor de fundo */
|
|
50
|
+
backgroundColor?: string;
|
|
51
|
+
/** Cor do texto */
|
|
52
|
+
textColor?: MantineColor;
|
|
53
|
+
/** Se deve ter sombra */
|
|
54
|
+
withShadow?: boolean;
|
|
55
|
+
/** Se deve ter borda inferior */
|
|
56
|
+
withBorder?: boolean;
|
|
57
|
+
/** Se está fixo no topo */
|
|
58
|
+
fixed?: boolean;
|
|
59
|
+
/** Z-index quando fixo */
|
|
60
|
+
zIndex?: number;
|
|
61
|
+
/** Breakpoint para modo mobile */
|
|
62
|
+
mobileBreakpoint?: string;
|
|
63
|
+
/** Callback do burger (para abrir drawer) */
|
|
64
|
+
onBurgerClick?: () => void;
|
|
65
|
+
/** Se o burger está aberto */
|
|
66
|
+
burgerOpened?: boolean;
|
|
67
|
+
/** Padding horizontal */
|
|
68
|
+
px?: MantineSize | number;
|
|
69
|
+
/** Tamanho das ações */
|
|
70
|
+
actionSize?: MantineSize;
|
|
71
|
+
/** Classe CSS */
|
|
72
|
+
className?: string;
|
|
73
|
+
/** Estilo */
|
|
74
|
+
style?: React.CSSProperties;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export const ArchbaseAppBar = forwardRef<HTMLElement, ArchbaseAppBarProps>(
|
|
78
|
+
(
|
|
79
|
+
{
|
|
80
|
+
leftSection,
|
|
81
|
+
centerSection,
|
|
82
|
+
rightSection,
|
|
83
|
+
actions,
|
|
84
|
+
title,
|
|
85
|
+
subtitle,
|
|
86
|
+
height = 60,
|
|
87
|
+
backgroundColor = 'var(--mantine-color-body)',
|
|
88
|
+
textColor,
|
|
89
|
+
withShadow = true,
|
|
90
|
+
withBorder = true,
|
|
91
|
+
fixed = true,
|
|
92
|
+
zIndex = 100,
|
|
93
|
+
mobileBreakpoint = '48em',
|
|
94
|
+
onBurgerClick,
|
|
95
|
+
burgerOpened = false,
|
|
96
|
+
px = 'md',
|
|
97
|
+
actionSize = 'md',
|
|
98
|
+
className,
|
|
99
|
+
style,
|
|
100
|
+
},
|
|
101
|
+
ref
|
|
102
|
+
) => {
|
|
103
|
+
const isMobile = useMediaQuery(`(max-width: ${mobileBreakpoint})`);
|
|
104
|
+
const [menuOpened, { toggle: toggleMenu, close: closeMenu }] = useDisclosure(false);
|
|
105
|
+
|
|
106
|
+
// Filtra ações visíveis
|
|
107
|
+
const visibleActions = actions?.filter((action) => {
|
|
108
|
+
if (isMobile && action.hideOnMobile) return false;
|
|
109
|
+
if (isMobile && !action.alwaysVisible) return false;
|
|
110
|
+
return true;
|
|
111
|
+
}) || [];
|
|
112
|
+
|
|
113
|
+
// Ações que vão para o menu no mobile
|
|
114
|
+
const menuActions = actions?.filter((action) => {
|
|
115
|
+
if (!isMobile) return false;
|
|
116
|
+
if (action.hideOnMobile) return false;
|
|
117
|
+
if (action.alwaysVisible) return false;
|
|
118
|
+
return true;
|
|
119
|
+
}) || [];
|
|
120
|
+
|
|
121
|
+
const renderActions = () => {
|
|
122
|
+
if (rightSection) return rightSection;
|
|
123
|
+
if (!actions || actions.length === 0) return null;
|
|
124
|
+
|
|
125
|
+
return (
|
|
126
|
+
<Group gap="xs">
|
|
127
|
+
{/* Ações visíveis */}
|
|
128
|
+
{visibleActions.map((action) => (
|
|
129
|
+
<ActionIcon
|
|
130
|
+
key={action.key}
|
|
131
|
+
variant="subtle"
|
|
132
|
+
color={action.color || 'gray'}
|
|
133
|
+
size={actionSize}
|
|
134
|
+
onClick={action.onClick}
|
|
135
|
+
disabled={action.disabled}
|
|
136
|
+
>
|
|
137
|
+
{action.icon}
|
|
138
|
+
</ActionIcon>
|
|
139
|
+
))}
|
|
140
|
+
|
|
141
|
+
{/* Menu para ações extras no mobile */}
|
|
142
|
+
{menuActions.length > 0 && (
|
|
143
|
+
<Menu opened={menuOpened} onClose={closeMenu} position="bottom-end">
|
|
144
|
+
<Menu.Target>
|
|
145
|
+
<ActionIcon variant="subtle" color="gray" size={actionSize} onClick={toggleMenu}>
|
|
146
|
+
<IconDotsVertical size={20} />
|
|
147
|
+
</ActionIcon>
|
|
148
|
+
</Menu.Target>
|
|
149
|
+
<Menu.Dropdown>
|
|
150
|
+
{menuActions.map((action) => (
|
|
151
|
+
<Menu.Item
|
|
152
|
+
key={action.key}
|
|
153
|
+
leftSection={action.icon}
|
|
154
|
+
color={action.color}
|
|
155
|
+
disabled={action.disabled}
|
|
156
|
+
onClick={() => {
|
|
157
|
+
action.onClick();
|
|
158
|
+
closeMenu();
|
|
159
|
+
}}
|
|
160
|
+
>
|
|
161
|
+
{action.label}
|
|
162
|
+
</Menu.Item>
|
|
163
|
+
))}
|
|
164
|
+
</Menu.Dropdown>
|
|
165
|
+
</Menu>
|
|
166
|
+
)}
|
|
167
|
+
</Group>
|
|
168
|
+
);
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
return (
|
|
172
|
+
<Box
|
|
173
|
+
ref={ref}
|
|
174
|
+
component="header"
|
|
175
|
+
className={className}
|
|
176
|
+
style={{
|
|
177
|
+
...style,
|
|
178
|
+
position: fixed ? 'fixed' : 'relative',
|
|
179
|
+
top: 0,
|
|
180
|
+
left: 0,
|
|
181
|
+
right: 0,
|
|
182
|
+
height,
|
|
183
|
+
backgroundColor,
|
|
184
|
+
borderBottom: withBorder ? '1px solid var(--mantine-color-gray-3)' : undefined,
|
|
185
|
+
boxShadow: withShadow ? '0 2px 4px rgba(0, 0, 0, 0.1)' : undefined,
|
|
186
|
+
zIndex: fixed ? zIndex : undefined,
|
|
187
|
+
display: 'flex',
|
|
188
|
+
alignItems: 'center',
|
|
189
|
+
paddingLeft: typeof px === 'number' ? px : `var(--mantine-spacing-${px})`,
|
|
190
|
+
paddingRight: typeof px === 'number' ? px : `var(--mantine-spacing-${px})`,
|
|
191
|
+
}}
|
|
192
|
+
>
|
|
193
|
+
{/* Left Section */}
|
|
194
|
+
<Group gap="sm" style={{ minWidth: 0 }}>
|
|
195
|
+
{/* Burger for mobile menu */}
|
|
196
|
+
{onBurgerClick && isMobile && (
|
|
197
|
+
<Burger opened={burgerOpened} onClick={onBurgerClick} size="sm" />
|
|
198
|
+
)}
|
|
199
|
+
{leftSection}
|
|
200
|
+
</Group>
|
|
201
|
+
|
|
202
|
+
{/* Center Section */}
|
|
203
|
+
<Box style={{ flex: 1, minWidth: 0, marginLeft: 16, marginRight: 16 }}>
|
|
204
|
+
{centerSection || (
|
|
205
|
+
<>
|
|
206
|
+
{title && (
|
|
207
|
+
<Text
|
|
208
|
+
size="md"
|
|
209
|
+
fw={600}
|
|
210
|
+
c={textColor}
|
|
211
|
+
truncate
|
|
212
|
+
style={{ lineHeight: 1.2 }}
|
|
213
|
+
>
|
|
214
|
+
{title}
|
|
215
|
+
</Text>
|
|
216
|
+
)}
|
|
217
|
+
{subtitle && (
|
|
218
|
+
<Text size="xs" c="dimmed" truncate>
|
|
219
|
+
{subtitle}
|
|
220
|
+
</Text>
|
|
221
|
+
)}
|
|
222
|
+
</>
|
|
223
|
+
)}
|
|
224
|
+
</Box>
|
|
225
|
+
|
|
226
|
+
{/* Right Section */}
|
|
227
|
+
{renderActions()}
|
|
228
|
+
</Box>
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
ArchbaseAppBar.displayName = 'ArchbaseAppBar';
|