@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,415 @@
|
|
|
1
|
+
import React, { useCallback, useMemo, useState } from 'react';
|
|
2
|
+
import { RowsPhotoAlbum, ColumnsPhotoAlbum, MasonryPhotoAlbum, Photo, RenderPhotoProps } from 'react-photo-album';
|
|
3
|
+
import { Box, Overlay, Text, Badge, ActionIcon, Group, useMantineTheme } from '@mantine/core';
|
|
4
|
+
import { IconZoomIn, IconDownload, IconHeart } from '@tabler/icons-react';
|
|
5
|
+
import { ArchbaseLightbox, ArchbaseLightboxSlide, useArchbaseLightbox } from './ArchbaseLightbox';
|
|
6
|
+
|
|
7
|
+
// Import CSS
|
|
8
|
+
import 'react-photo-album/rows.css';
|
|
9
|
+
import 'react-photo-album/columns.css';
|
|
10
|
+
import 'react-photo-album/masonry.css';
|
|
11
|
+
|
|
12
|
+
// =============================================================================
|
|
13
|
+
// Types
|
|
14
|
+
// =============================================================================
|
|
15
|
+
|
|
16
|
+
export type ArchbasePhotoAlbumLayout = 'rows' | 'columns' | 'masonry';
|
|
17
|
+
|
|
18
|
+
export interface ArchbasePhotoAlbumPhoto extends Photo {
|
|
19
|
+
/** Título da foto */
|
|
20
|
+
title?: string;
|
|
21
|
+
/** Descrição da foto */
|
|
22
|
+
description?: string;
|
|
23
|
+
/** ID único (para tracking) */
|
|
24
|
+
id?: string | number;
|
|
25
|
+
/** Badge/tag para exibir */
|
|
26
|
+
badge?: string;
|
|
27
|
+
/** Cor do badge */
|
|
28
|
+
badgeColor?: string;
|
|
29
|
+
/** Se é favorito */
|
|
30
|
+
favorite?: boolean;
|
|
31
|
+
/** Dados extras */
|
|
32
|
+
data?: Record<string, unknown>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface ArchbasePhotoAlbumProps {
|
|
36
|
+
/** Array de fotos */
|
|
37
|
+
photos: ArchbasePhotoAlbumPhoto[];
|
|
38
|
+
/** Tipo de layout */
|
|
39
|
+
layout?: ArchbasePhotoAlbumLayout;
|
|
40
|
+
/** Espaçamento entre fotos (px) */
|
|
41
|
+
spacing?: number;
|
|
42
|
+
/** Padding interno (px) */
|
|
43
|
+
padding?: number;
|
|
44
|
+
/** Altura alvo das linhas (layout 'rows') */
|
|
45
|
+
targetRowHeight?: number;
|
|
46
|
+
/** Número de colunas (layout 'columns' ou 'masonry') */
|
|
47
|
+
columns?: number | ((containerWidth: number) => number);
|
|
48
|
+
/** Callback ao clicar em uma foto */
|
|
49
|
+
onClick?: (photo: ArchbasePhotoAlbumPhoto, index: number) => void;
|
|
50
|
+
/** Abre lightbox automaticamente ao clicar */
|
|
51
|
+
withLightbox?: boolean;
|
|
52
|
+
/** Mostra overlay com ações ao hover */
|
|
53
|
+
showOverlay?: boolean;
|
|
54
|
+
/** Mostra badge nas fotos */
|
|
55
|
+
showBadge?: boolean;
|
|
56
|
+
/** Mostra indicador de favorito */
|
|
57
|
+
showFavorite?: boolean;
|
|
58
|
+
/** Callback ao favoritar */
|
|
59
|
+
onFavorite?: (photo: ArchbasePhotoAlbumPhoto, index: number) => void;
|
|
60
|
+
/** Callback ao baixar */
|
|
61
|
+
onDownload?: (photo: ArchbasePhotoAlbumPhoto, index: number) => void;
|
|
62
|
+
/** Border radius das fotos */
|
|
63
|
+
borderRadius?: number;
|
|
64
|
+
/** Classe CSS */
|
|
65
|
+
className?: string;
|
|
66
|
+
/** Estilo */
|
|
67
|
+
style?: React.CSSProperties;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// =============================================================================
|
|
71
|
+
// Default Photo Renderer
|
|
72
|
+
// =============================================================================
|
|
73
|
+
|
|
74
|
+
interface DefaultPhotoRendererProps {
|
|
75
|
+
photo: ArchbasePhotoAlbumPhoto;
|
|
76
|
+
index: number;
|
|
77
|
+
width: number;
|
|
78
|
+
height: number;
|
|
79
|
+
showOverlay: boolean;
|
|
80
|
+
showBadge: boolean;
|
|
81
|
+
showFavorite: boolean;
|
|
82
|
+
borderRadius: number;
|
|
83
|
+
onClick?: (photo: ArchbasePhotoAlbumPhoto, index: number) => void;
|
|
84
|
+
onFavorite?: (photo: ArchbasePhotoAlbumPhoto, index: number) => void;
|
|
85
|
+
onDownload?: (photo: ArchbasePhotoAlbumPhoto, index: number) => void;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function DefaultPhotoRenderer({
|
|
89
|
+
photo,
|
|
90
|
+
index,
|
|
91
|
+
width,
|
|
92
|
+
height,
|
|
93
|
+
showOverlay,
|
|
94
|
+
showBadge,
|
|
95
|
+
showFavorite,
|
|
96
|
+
borderRadius,
|
|
97
|
+
onClick,
|
|
98
|
+
onFavorite,
|
|
99
|
+
onDownload,
|
|
100
|
+
}: DefaultPhotoRendererProps) {
|
|
101
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
102
|
+
const theme = useMantineTheme();
|
|
103
|
+
|
|
104
|
+
const handleClick = useCallback(
|
|
105
|
+
(e: React.MouseEvent) => {
|
|
106
|
+
e.stopPropagation();
|
|
107
|
+
onClick?.(photo, index);
|
|
108
|
+
},
|
|
109
|
+
[onClick, photo, index]
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
const handleFavorite = useCallback(
|
|
113
|
+
(e: React.MouseEvent) => {
|
|
114
|
+
e.stopPropagation();
|
|
115
|
+
onFavorite?.(photo, index);
|
|
116
|
+
},
|
|
117
|
+
[onFavorite, photo, index]
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
const handleDownload = useCallback(
|
|
121
|
+
(e: React.MouseEvent) => {
|
|
122
|
+
e.stopPropagation();
|
|
123
|
+
onDownload?.(photo, index);
|
|
124
|
+
},
|
|
125
|
+
[onDownload, photo, index]
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
return (
|
|
129
|
+
<Box
|
|
130
|
+
style={{
|
|
131
|
+
position: 'relative',
|
|
132
|
+
width,
|
|
133
|
+
height,
|
|
134
|
+
cursor: onClick ? 'pointer' : 'default',
|
|
135
|
+
overflow: 'hidden',
|
|
136
|
+
borderRadius,
|
|
137
|
+
}}
|
|
138
|
+
onMouseEnter={() => setIsHovered(true)}
|
|
139
|
+
onMouseLeave={() => setIsHovered(false)}
|
|
140
|
+
onClick={handleClick}
|
|
141
|
+
>
|
|
142
|
+
<img
|
|
143
|
+
src={photo.src}
|
|
144
|
+
alt={photo.alt || photo.title || ''}
|
|
145
|
+
style={{
|
|
146
|
+
width: '100%',
|
|
147
|
+
height: '100%',
|
|
148
|
+
objectFit: 'cover',
|
|
149
|
+
transition: 'transform 0.3s ease',
|
|
150
|
+
transform: isHovered ? 'scale(1.05)' : 'scale(1)',
|
|
151
|
+
}}
|
|
152
|
+
/>
|
|
153
|
+
|
|
154
|
+
{/* Badge */}
|
|
155
|
+
{showBadge && photo.badge && (
|
|
156
|
+
<Badge
|
|
157
|
+
color={photo.badgeColor || 'blue'}
|
|
158
|
+
variant="filled"
|
|
159
|
+
size="sm"
|
|
160
|
+
style={{
|
|
161
|
+
position: 'absolute',
|
|
162
|
+
top: 8,
|
|
163
|
+
left: 8,
|
|
164
|
+
zIndex: 2,
|
|
165
|
+
}}
|
|
166
|
+
>
|
|
167
|
+
{photo.badge}
|
|
168
|
+
</Badge>
|
|
169
|
+
)}
|
|
170
|
+
|
|
171
|
+
{/* Favorite indicator */}
|
|
172
|
+
{showFavorite && photo.favorite && (
|
|
173
|
+
<IconHeart
|
|
174
|
+
size={20}
|
|
175
|
+
style={{
|
|
176
|
+
position: 'absolute',
|
|
177
|
+
top: 8,
|
|
178
|
+
right: 8,
|
|
179
|
+
zIndex: 2,
|
|
180
|
+
fill: theme.colors.red[6],
|
|
181
|
+
color: theme.colors.red[6],
|
|
182
|
+
}}
|
|
183
|
+
/>
|
|
184
|
+
)}
|
|
185
|
+
|
|
186
|
+
{/* Overlay with actions */}
|
|
187
|
+
{showOverlay && isHovered && (
|
|
188
|
+
<>
|
|
189
|
+
<Overlay
|
|
190
|
+
gradient="linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.7) 100%)"
|
|
191
|
+
opacity={1}
|
|
192
|
+
zIndex={1}
|
|
193
|
+
style={{ borderRadius }}
|
|
194
|
+
/>
|
|
195
|
+
<Box
|
|
196
|
+
style={{
|
|
197
|
+
position: 'absolute',
|
|
198
|
+
bottom: 0,
|
|
199
|
+
left: 0,
|
|
200
|
+
right: 0,
|
|
201
|
+
padding: 12,
|
|
202
|
+
zIndex: 2,
|
|
203
|
+
}}
|
|
204
|
+
>
|
|
205
|
+
{photo.title && (
|
|
206
|
+
<Text c="white" fw={500} size="sm" lineClamp={1}>
|
|
207
|
+
{photo.title}
|
|
208
|
+
</Text>
|
|
209
|
+
)}
|
|
210
|
+
{photo.description && (
|
|
211
|
+
<Text c="gray.3" size="xs" lineClamp={2}>
|
|
212
|
+
{photo.description}
|
|
213
|
+
</Text>
|
|
214
|
+
)}
|
|
215
|
+
<Group gap={4} mt={8}>
|
|
216
|
+
{onClick && (
|
|
217
|
+
<ActionIcon
|
|
218
|
+
variant="filled"
|
|
219
|
+
color="dark"
|
|
220
|
+
size="sm"
|
|
221
|
+
onClick={handleClick}
|
|
222
|
+
title="Ampliar"
|
|
223
|
+
>
|
|
224
|
+
<IconZoomIn size={14} />
|
|
225
|
+
</ActionIcon>
|
|
226
|
+
)}
|
|
227
|
+
{onDownload && (
|
|
228
|
+
<ActionIcon
|
|
229
|
+
variant="filled"
|
|
230
|
+
color="dark"
|
|
231
|
+
size="sm"
|
|
232
|
+
onClick={handleDownload}
|
|
233
|
+
title="Baixar"
|
|
234
|
+
>
|
|
235
|
+
<IconDownload size={14} />
|
|
236
|
+
</ActionIcon>
|
|
237
|
+
)}
|
|
238
|
+
{onFavorite && (
|
|
239
|
+
<ActionIcon
|
|
240
|
+
variant="filled"
|
|
241
|
+
color={photo.favorite ? 'red' : 'dark'}
|
|
242
|
+
size="sm"
|
|
243
|
+
onClick={handleFavorite}
|
|
244
|
+
title={photo.favorite ? 'Remover favorito' : 'Favoritar'}
|
|
245
|
+
>
|
|
246
|
+
<IconHeart size={14} style={{ fill: photo.favorite ? 'currentColor' : 'none' }} />
|
|
247
|
+
</ActionIcon>
|
|
248
|
+
)}
|
|
249
|
+
</Group>
|
|
250
|
+
</Box>
|
|
251
|
+
</>
|
|
252
|
+
)}
|
|
253
|
+
</Box>
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// =============================================================================
|
|
258
|
+
// Component
|
|
259
|
+
// =============================================================================
|
|
260
|
+
|
|
261
|
+
export function ArchbasePhotoAlbum({
|
|
262
|
+
photos,
|
|
263
|
+
layout = 'rows',
|
|
264
|
+
spacing = 8,
|
|
265
|
+
padding = 0,
|
|
266
|
+
targetRowHeight = 200,
|
|
267
|
+
columns = 4,
|
|
268
|
+
onClick,
|
|
269
|
+
withLightbox = true,
|
|
270
|
+
showOverlay = true,
|
|
271
|
+
showBadge = true,
|
|
272
|
+
showFavorite = true,
|
|
273
|
+
onFavorite,
|
|
274
|
+
onDownload,
|
|
275
|
+
borderRadius = 4,
|
|
276
|
+
className,
|
|
277
|
+
style,
|
|
278
|
+
}: ArchbasePhotoAlbumProps) {
|
|
279
|
+
const lightbox = useArchbaseLightbox();
|
|
280
|
+
|
|
281
|
+
// Converte fotos para formato do Lightbox
|
|
282
|
+
const lightboxSlides: ArchbaseLightboxSlide[] = useMemo(
|
|
283
|
+
() =>
|
|
284
|
+
photos.map((photo) => ({
|
|
285
|
+
src: photo.src,
|
|
286
|
+
title: photo.title,
|
|
287
|
+
description: photo.description,
|
|
288
|
+
alt: photo.alt,
|
|
289
|
+
width: photo.width,
|
|
290
|
+
height: photo.height,
|
|
291
|
+
})),
|
|
292
|
+
[photos]
|
|
293
|
+
);
|
|
294
|
+
|
|
295
|
+
// Handler de clique
|
|
296
|
+
const handleClick = useCallback(
|
|
297
|
+
(photo: ArchbasePhotoAlbumPhoto, index: number) => {
|
|
298
|
+
if (withLightbox) {
|
|
299
|
+
lightbox.open(lightboxSlides, index);
|
|
300
|
+
}
|
|
301
|
+
onClick?.(photo, index);
|
|
302
|
+
},
|
|
303
|
+
[withLightbox, lightbox, lightboxSlides, onClick]
|
|
304
|
+
);
|
|
305
|
+
|
|
306
|
+
// Renderização customizada de foto
|
|
307
|
+
const renderPhoto = useCallback(
|
|
308
|
+
(renderProps: RenderPhotoProps) => {
|
|
309
|
+
const { photo: photoObj, width, height } = renderProps as unknown as {
|
|
310
|
+
photo: ArchbasePhotoAlbumPhoto;
|
|
311
|
+
width: number;
|
|
312
|
+
height: number;
|
|
313
|
+
};
|
|
314
|
+
const index = photos.findIndex((p) => p.src === photoObj.src);
|
|
315
|
+
|
|
316
|
+
return (
|
|
317
|
+
<DefaultPhotoRenderer
|
|
318
|
+
key={photoObj.src}
|
|
319
|
+
photo={photoObj}
|
|
320
|
+
index={index}
|
|
321
|
+
width={width}
|
|
322
|
+
height={height}
|
|
323
|
+
showOverlay={showOverlay}
|
|
324
|
+
showBadge={showBadge}
|
|
325
|
+
showFavorite={showFavorite}
|
|
326
|
+
borderRadius={borderRadius}
|
|
327
|
+
onClick={handleClick}
|
|
328
|
+
onFavorite={onFavorite}
|
|
329
|
+
onDownload={onDownload}
|
|
330
|
+
/>
|
|
331
|
+
);
|
|
332
|
+
},
|
|
333
|
+
[
|
|
334
|
+
photos,
|
|
335
|
+
showOverlay,
|
|
336
|
+
showBadge,
|
|
337
|
+
showFavorite,
|
|
338
|
+
borderRadius,
|
|
339
|
+
handleClick,
|
|
340
|
+
onFavorite,
|
|
341
|
+
onDownload,
|
|
342
|
+
]
|
|
343
|
+
);
|
|
344
|
+
|
|
345
|
+
// Renderiza o álbum baseado no layout
|
|
346
|
+
const renderAlbum = () => {
|
|
347
|
+
const commonProps = {
|
|
348
|
+
photos,
|
|
349
|
+
spacing,
|
|
350
|
+
padding,
|
|
351
|
+
render: { photo: renderPhoto },
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
switch (layout) {
|
|
355
|
+
case 'rows':
|
|
356
|
+
return (
|
|
357
|
+
<RowsPhotoAlbum
|
|
358
|
+
{...commonProps}
|
|
359
|
+
targetRowHeight={targetRowHeight}
|
|
360
|
+
/>
|
|
361
|
+
);
|
|
362
|
+
case 'columns':
|
|
363
|
+
return (
|
|
364
|
+
<ColumnsPhotoAlbum
|
|
365
|
+
{...commonProps}
|
|
366
|
+
columns={columns}
|
|
367
|
+
/>
|
|
368
|
+
);
|
|
369
|
+
case 'masonry':
|
|
370
|
+
return (
|
|
371
|
+
<MasonryPhotoAlbum
|
|
372
|
+
{...commonProps}
|
|
373
|
+
columns={columns}
|
|
374
|
+
/>
|
|
375
|
+
);
|
|
376
|
+
default:
|
|
377
|
+
return (
|
|
378
|
+
<RowsPhotoAlbum
|
|
379
|
+
{...commonProps}
|
|
380
|
+
targetRowHeight={targetRowHeight}
|
|
381
|
+
/>
|
|
382
|
+
);
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
return (
|
|
387
|
+
<Box className={className} style={style}>
|
|
388
|
+
{renderAlbum()}
|
|
389
|
+
|
|
390
|
+
{/* Lightbox */}
|
|
391
|
+
{withLightbox && (
|
|
392
|
+
<ArchbaseLightbox
|
|
393
|
+
slides={lightboxSlides}
|
|
394
|
+
open={lightbox.isOpen}
|
|
395
|
+
index={lightbox.currentIndex}
|
|
396
|
+
onClose={lightbox.close}
|
|
397
|
+
onSlideChange={lightbox.goTo}
|
|
398
|
+
enableZoom
|
|
399
|
+
enableThumbnails
|
|
400
|
+
enableFullscreen
|
|
401
|
+
showCounter
|
|
402
|
+
showCaptions
|
|
403
|
+
/>
|
|
404
|
+
)}
|
|
405
|
+
</Box>
|
|
406
|
+
);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
ArchbasePhotoAlbum.displayName = 'ArchbasePhotoAlbum';
|
|
410
|
+
|
|
411
|
+
// =============================================================================
|
|
412
|
+
// Exports
|
|
413
|
+
// =============================================================================
|
|
414
|
+
|
|
415
|
+
export default ArchbasePhotoAlbum;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { useCallback, useEffect } from 'react';
|
|
2
|
+
import { QRCodeSVG, QRCodeCanvas } from 'qrcode.react';
|
|
3
|
+
import { Box, Input, useMantineTheme, useComputedColorScheme } from '@mantine/core';
|
|
4
|
+
import {
|
|
5
|
+
useArchbaseV1V2Compatibility,
|
|
6
|
+
useArchbaseDataSourceListener,
|
|
7
|
+
} from '@archbase/data';
|
|
8
|
+
import type { IArchbaseDataSourceBase } from '@archbase/data';
|
|
9
|
+
|
|
10
|
+
export interface ArchbaseQRCodeImageSettings {
|
|
11
|
+
src: string;
|
|
12
|
+
height: number;
|
|
13
|
+
width: number;
|
|
14
|
+
excavate: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ArchbaseQRCodeProps<T> {
|
|
18
|
+
/** DataSource to read the string value from */
|
|
19
|
+
dataSource?: IArchbaseDataSourceBase<T>;
|
|
20
|
+
/** Field name within the DataSource */
|
|
21
|
+
dataField?: string;
|
|
22
|
+
/** Standalone string value to encode */
|
|
23
|
+
value?: string;
|
|
24
|
+
/** Render as SVG or Canvas */
|
|
25
|
+
renderAs?: 'svg' | 'canvas';
|
|
26
|
+
/** Size in pixels */
|
|
27
|
+
size?: number;
|
|
28
|
+
/** Error correction level */
|
|
29
|
+
level?: 'L' | 'M' | 'Q' | 'H';
|
|
30
|
+
/** Background color (dark mode aware) */
|
|
31
|
+
bgColor?: string;
|
|
32
|
+
/** Foreground color (dark mode aware) */
|
|
33
|
+
fgColor?: string;
|
|
34
|
+
/** Include margin around the QR code */
|
|
35
|
+
includeMargin?: boolean;
|
|
36
|
+
/** Optional logo/image in the center of the QR code */
|
|
37
|
+
imageSettings?: ArchbaseQRCodeImageSettings;
|
|
38
|
+
/** Label for Input.Wrapper */
|
|
39
|
+
label?: string;
|
|
40
|
+
/** Description for Input.Wrapper */
|
|
41
|
+
description?: string;
|
|
42
|
+
/** Error message for Input.Wrapper */
|
|
43
|
+
error?: string;
|
|
44
|
+
/** Custom style */
|
|
45
|
+
style?: React.CSSProperties;
|
|
46
|
+
/** Custom class name */
|
|
47
|
+
className?: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function ArchbaseQRCode<T>({
|
|
51
|
+
dataSource,
|
|
52
|
+
dataField,
|
|
53
|
+
value: valueProp,
|
|
54
|
+
renderAs = 'svg',
|
|
55
|
+
size = 128,
|
|
56
|
+
level = 'M',
|
|
57
|
+
bgColor,
|
|
58
|
+
fgColor,
|
|
59
|
+
includeMargin = true,
|
|
60
|
+
imageSettings,
|
|
61
|
+
label,
|
|
62
|
+
description,
|
|
63
|
+
error,
|
|
64
|
+
style,
|
|
65
|
+
className,
|
|
66
|
+
}: ArchbaseQRCodeProps<T>) {
|
|
67
|
+
const theme = useMantineTheme();
|
|
68
|
+
const colorScheme = useComputedColorScheme('light');
|
|
69
|
+
const isDark = colorScheme === 'dark';
|
|
70
|
+
|
|
71
|
+
const defaultBgColor = isDark ? theme.colors.dark[7] : '#FFFFFF';
|
|
72
|
+
const defaultFgColor = isDark ? '#FFFFFF' : '#000000';
|
|
73
|
+
|
|
74
|
+
const resolvedBgColor = bgColor ?? defaultBgColor;
|
|
75
|
+
const resolvedFgColor = fgColor ?? defaultFgColor;
|
|
76
|
+
|
|
77
|
+
const {
|
|
78
|
+
currentValue,
|
|
79
|
+
loadDataSourceFieldValue,
|
|
80
|
+
} = useArchbaseV1V2Compatibility<string>(
|
|
81
|
+
'ArchbaseQRCode',
|
|
82
|
+
dataSource,
|
|
83
|
+
dataField,
|
|
84
|
+
valueProp,
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
if (dataSource && dataField) {
|
|
89
|
+
loadDataSourceFieldValue();
|
|
90
|
+
}
|
|
91
|
+
}, [dataSource, dataField, loadDataSourceFieldValue]);
|
|
92
|
+
|
|
93
|
+
const dataSourceEvent = useCallback((_event: any) => {
|
|
94
|
+
loadDataSourceFieldValue();
|
|
95
|
+
}, [loadDataSourceFieldValue]);
|
|
96
|
+
|
|
97
|
+
useArchbaseDataSourceListener({
|
|
98
|
+
dataSource,
|
|
99
|
+
listener: dataSourceEvent,
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
const qrValue = currentValue ?? '';
|
|
103
|
+
|
|
104
|
+
const qrProps = {
|
|
105
|
+
value: qrValue,
|
|
106
|
+
size,
|
|
107
|
+
level,
|
|
108
|
+
bgColor: resolvedBgColor,
|
|
109
|
+
fgColor: resolvedFgColor,
|
|
110
|
+
includeMargin,
|
|
111
|
+
imageSettings,
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const qrElement = renderAs === 'canvas'
|
|
115
|
+
? <QRCodeCanvas {...qrProps} />
|
|
116
|
+
: <QRCodeSVG {...qrProps} />;
|
|
117
|
+
|
|
118
|
+
const content = (
|
|
119
|
+
<Box style={style} className={className}>
|
|
120
|
+
{qrElement}
|
|
121
|
+
</Box>
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
if (label || description || error) {
|
|
125
|
+
return (
|
|
126
|
+
<Input.Wrapper label={label} description={description} error={error}>
|
|
127
|
+
{content}
|
|
128
|
+
</Input.Wrapper>
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return content;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
ArchbaseQRCode.displayName = 'ArchbaseQRCode';
|
|
136
|
+
|
|
137
|
+
export { ArchbaseQRCode };
|