@mittwald/flow-react-components 1.6.0-next.68 → 1.6.0-next.69
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/assets/component-index.json +1 -1
- package/dist/assets/doc-properties.json +1 -1
- package/dist/css/all-layered.css +1 -1
- package/dist/css/all.css +1 -1
- package/dist/js/_virtual/_22.locale.mjs +6 -2
- package/dist/js/default.mjs +2 -1
- package/dist/js/packages/components/src/components/FileCard/components/FileSizeText/FileSizeText.mjs +25 -6
- package/dist/js/packages/components/src/components/FileCard/components/FileSizeText/FileSizeText.mjs.map +1 -1
- package/dist/js/packages/components/src/components/LightBox/LightBox.mjs +16 -8
- package/dist/js/packages/components/src/components/LightBox/LightBox.mjs.map +1 -1
- package/dist/js/packages/components/src/components/LightBox/LightBox.module.mjs +3 -1
- package/dist/js/packages/components/src/components/LightBox/LightBox.module.mjs.map +1 -1
- package/dist/js/packages/components/src/components/LightBox/components/LightBoxGallery/LightBoxGallery.mjs +15 -12
- package/dist/js/packages/components/src/components/LightBox/components/LightBoxGallery/LightBoxGallery.mjs.map +1 -1
- package/dist/js/packages/components/src/components/LightBox/components/LightBoxGallery/LightBoxGallery.module.mjs.map +1 -1
- package/dist/js/packages/components/src/components/LightBox/components/LightBoxGalleryItem/LightBoxGalleryItem.mjs +7 -6
- package/dist/js/packages/components/src/components/LightBox/components/LightBoxGalleryItem/LightBoxGalleryItem.mjs.map +1 -1
- package/dist/js/packages/components/src/components/LightBox/components/LightBoxZoom/LightBoxZoom.mjs +82 -0
- package/dist/js/packages/components/src/components/LightBox/components/LightBoxZoom/LightBoxZoom.mjs.map +1 -0
- package/dist/js/packages/components/src/components/LightBox/components/LightBoxZoom/LightBoxZoom.module.mjs +20 -0
- package/dist/js/packages/components/src/components/LightBox/components/LightBoxZoom/LightBoxZoom.module.mjs.map +1 -0
- package/dist/js/packages/components/src/components/LightBox/components/LightBoxZoom/hooks/useZoom.mjs +282 -0
- package/dist/js/packages/components/src/components/LightBox/components/LightBoxZoom/hooks/useZoom.mjs.map +1 -0
- package/dist/js/packages/components/src/components/LightBox/components/LightBoxZoom/lib/zoomTransform.mjs +58 -0
- package/dist/js/packages/components/src/components/LightBox/components/LightBoxZoom/lib/zoomTransform.mjs.map +1 -0
- package/dist/js/packages/components/src/views/LightBoxZoomView.mjs +15 -0
- package/dist/js/packages/components/src/views/LightBoxZoomView.mjs.map +1 -0
- package/dist/types/components/LightBox/LightBox.d.ts +6 -0
- package/dist/types/components/LightBox/components/LightBoxGalleryItem/LightBoxGalleryItem.d.ts +3 -4
- package/dist/types/components/LightBox/components/LightBoxZoom/LightBoxZoom.d.ts +12 -0
- package/dist/types/components/LightBox/components/LightBoxZoom/hooks/useZoom.d.ts +16 -0
- package/dist/types/components/LightBox/components/LightBoxZoom/index.d.ts +2 -0
- package/dist/types/components/LightBox/components/LightBoxZoom/lib/zoomTransform.d.ts +43 -0
- package/dist/types/components/LightBox/components/LightBoxZoom/view.d.ts +7 -0
- package/dist/types/components/LightBox/index.d.ts +1 -0
- package/dist/types/views/LightBoxZoomView.d.ts +4 -0
- package/package.json +10 -10
|
@@ -7,14 +7,18 @@ var __locale_default = {
|
|
|
7
7
|
"gallery": "Bildergalerie",
|
|
8
8
|
"indicator": "{current} von {count}",
|
|
9
9
|
"next": "Nächstes",
|
|
10
|
-
"previous": "Vorheriges"
|
|
10
|
+
"previous": "Vorheriges",
|
|
11
|
+
"zoom": "Zoombare Ansicht",
|
|
12
|
+
"zoomDescription": "Klick oder Eingabe vergrößert. Plus und Minus ändern die Vergrößerung, die Pfeiltasten verschieben das vergrößerte Bild."
|
|
11
13
|
},
|
|
12
14
|
"en-US": {
|
|
13
15
|
"close": "Close",
|
|
14
16
|
"gallery": "Image gallery",
|
|
15
17
|
"indicator": "{current} of {count}",
|
|
16
18
|
"next": "Next",
|
|
17
|
-
"previous": "Previous"
|
|
19
|
+
"previous": "Previous",
|
|
20
|
+
"zoom": "Zoomable view",
|
|
21
|
+
"zoomDescription": "Click or press Enter to zoom. Plus and minus change the zoom, the arrow keys move the zoomed image."
|
|
18
22
|
}
|
|
19
23
|
};
|
|
20
24
|
export { __locale_default as default };
|
package/dist/js/default.mjs
CHANGED
|
@@ -274,6 +274,7 @@ import { LabeledValue } from "./packages/components/src/components/LabeledValue/
|
|
|
274
274
|
import { LayoutCard } from "./packages/components/src/components/LayoutCard/LayoutCard.mjs";
|
|
275
275
|
import { LightBoxTrigger } from "./packages/components/src/components/LightBox/components/LightBoxTrigger/LightBoxTrigger.mjs";
|
|
276
276
|
import { LightBoxGallery } from "./packages/components/src/components/LightBox/components/LightBoxGallery/LightBoxGallery.mjs";
|
|
277
|
+
import { LightBoxZoom } from "./packages/components/src/components/LightBox/components/LightBoxZoom/LightBoxZoom.mjs";
|
|
277
278
|
import { LightBoxGalleryItem } from "./packages/components/src/components/LightBox/components/LightBoxGalleryItem/LightBoxGalleryItem.mjs";
|
|
278
279
|
import { OverlayContent } from "./packages/components/src/components/Overlay/components/OverlayContent.mjs";
|
|
279
280
|
import { Overlay } from "./packages/components/src/components/Overlay/Overlay.mjs";
|
|
@@ -341,4 +342,4 @@ import { Tab } from "./packages/components/src/components/Tabs/components/Tab/Ta
|
|
|
341
342
|
import { TextField } from "./packages/components/src/components/TextField/TextField.mjs";
|
|
342
343
|
import { Truncate } from "./packages/components/src/components/Truncate/Truncate.mjs";
|
|
343
344
|
import { TunnelEntry } from "./packages/components/src/components/TunnelEntry/TunnelEntry.mjs";
|
|
344
|
-
export { AbortActionError, AccentBox, Accordion, AccordionGroup, Action, ActionBatch, ActionGroup, Activity, Alert, AlertBadge, AlertIcon, AlertText, Align, Area, AreaDot, Autocomplete, Avatar, AvatarStack, Badge, Bar, BigNumber, Breadcrumb, BrowserOnly, Button, CartesianChart, CartesianGrid, ChartGrid, ChartLegend, ChartTooltip, Chat, Checkbox, CheckboxButton, CheckboxGroup, ClearPropsContext, CoachMark, CodeBlock, CodeEditor, Color, ColumnLayout, Combine, ComboBox, ComponentDefaultsContext, ComponentDefaultsProvider, ComponentPropsContextProvider, Content, ContextMenu, ContextMenuContent, ContextMenuSection, ContextMenuTrigger, ContextualHelp, ContextualHelpTrigger, CopyButton, CounterBadge, CountryOptions, DatePicker, DateRangePicker, DeprecationWarningContext, DeprecationWarningProvider, DialogTrigger, Div, DonutChart, EmptyView, EmptyViewContainer, FieldDescription, FieldError, FileCard, FileCardList, FileDropZone, FileField, Flex, GridList, GridListItem, Header, HeaderNavigation, Heading, Icon, IconAI, IconAIHosting, IconAnalytics, IconApp, IconAscending, IconAttachment, IconAutoresponder, IconBackLink, IconBackup, IconBold, IconCamera, IconCertificate, IconChangelog, IconCheck, IconCheckboxChecked, IconCheckboxEmpty, IconCheckboxIndeterminate, IconChevronDown, IconChevronLeft, IconChevronRight, IconChevronUp, IconClose, IconCode, IconContainer, IconContextMenu, IconContextMenuVertical, IconContract, IconContractPartner, IconContributor, IconCopy, IconCronjob, IconCustomer, IconDanger, IconDashboard, IconDatabase, IconDate, IconDelete, IconDeliveryBox, IconDescending, IconDesktop, IconDirectory, IconDnsSubZone, IconDnsZone, IconDomain, IconDownload, IconEdit, IconEmail, IconEmailArchive, IconExtension, IconExternalLink, IconFailed, IconFeedback, IconFile, IconFilter, IconForwardAddress, IconForwardLink, IconHide, IconHome, IconImage, IconInfo, IconInvite, IconInvoice, IconItalic, IconKnowledgeHint, IconLanguage, IconLeadFyndr, IconLink, IconLock, IconLockOpen, IconLogout, IconMainUser, IconMarketplace, IconMaximize, IconMember, IconMenu, IconMinimize, IconMinus, IconMittwald, IconMobile, IconMonitoring, IconMove, IconNewsletter, IconNotification, IconNumber, IconOrder, IconOrderedList, IconPassword, IconPath, IconPause, IconPayment, IconPending, IconPicture, IconPlus, IconProject, IconQuote, IconRadioOff, IconRadioOn, IconRedo, IconRefresh, IconRegistry, IconSave, IconSearch, IconSecurity, IconSend, IconServer, IconSetProvider, IconSettings, IconShare, IconShow, IconSorting, IconSsh, IconSshKey, IconSshSftp, IconStack, IconStar, IconStarFilled, IconStart, IconStrikeThrough, IconSubdomain, IconSucceeded, IconSuccess, IconSupport, IconTerminate, IconTicket, IconTime, IconUnavailable, IconUndo, IconUnorderedList, IconUpload, IconUser, IconVhost, IconView, IconVolume, IconWarning, IllustratedMessage, Image, ImageCropper, Initials, InlineCode, IntlProvider, Kbd, Label, LabeledValue, LayoutCard, Legend, LegendItem, LightBox, LightBoxGallery, LightBoxGalleryItem, LightBoxTrigger, Line, Link, List, ListFilter, ListItem, ListItemView, ListItemViewContent, ListLoaderAsync, ListSorting, ListStaticData, ListSummary, LoadingSpinner, Markdown, MarkdownEditor, MenuItem, MenuTrigger, Message, MessageSeparator, MessageThread, Modal, ModalTrigger, Navigation, NavigationGroup, Notification, NotificationController, NotificationProvider, NumberField, Option, Overlay, OverlayContent, OverlayController, OverlayTrigger, PasswordCreationField, Popover, PopoverContent, PopoverTrigger, ProgressBar, PropsContextProvider, Radio, RadioButton, RadioGroup, RangeCalendar, Rating, RatingSegment, Render, RouterProvider, SearchField, Section, Segment, SegmentedControl, Select, Separator, SettingsProvider, Skeleton, SkeletonMode, SkeletonText, Slider, SortingFunctions, SuspenseTrigger, Switch, Tab, TabNavigation, TabTitle, Table, TableBody, TableCell, TableColumn, TableFooterRow, TableHeader, TableRow, Tabs, Text, TextArea, TextField, ThemedHtml, TimeField, Tooltip, TooltipTrigger, TranslationProvider, Truncate, TunnelEntry, TypedArea, TypedBar, TypedChartGrid, TypedChartLegend, TypedChartTooltip, TypedLine, TypedList, TypedListFilter, TypedListItem, TypedListLoaderAsync, TypedListSorting, TypedListStaticData, TypedXAxis, TypedYAxis, Wrap, XAxis, YAxis, abortAction, builtInComponentDefaults, dynamic, eventHandlerContext, flags, getRemoteEvent, getResolvedTheme, getTheme, iconCategories, isDateRangeValue, overlayTriggersTunneledTo, propsContext, resolveDateRangeFilterValue, setTheme, sortByDachFirst, themeHtmlAttribute, typedCartesianChart, typedList, useAriaAnnounceSuspense, useComponentDefaults, useControlledRemoteValueProps, useDesignTokens, useIsMounted, useLanguage, useList, useListMetadata, useLocalizedStringFormatter, useModalController, useNotificationController, useOnChange, useOverlayController, useProps, useTheme as useStoredTheme, useResolvedTheme as useTheme, useTranslationProvider, useWarnDeprecation };
|
|
345
|
+
export { AbortActionError, AccentBox, Accordion, AccordionGroup, Action, ActionBatch, ActionGroup, Activity, Alert, AlertBadge, AlertIcon, AlertText, Align, Area, AreaDot, Autocomplete, Avatar, AvatarStack, Badge, Bar, BigNumber, Breadcrumb, BrowserOnly, Button, CartesianChart, CartesianGrid, ChartGrid, ChartLegend, ChartTooltip, Chat, Checkbox, CheckboxButton, CheckboxGroup, ClearPropsContext, CoachMark, CodeBlock, CodeEditor, Color, ColumnLayout, Combine, ComboBox, ComponentDefaultsContext, ComponentDefaultsProvider, ComponentPropsContextProvider, Content, ContextMenu, ContextMenuContent, ContextMenuSection, ContextMenuTrigger, ContextualHelp, ContextualHelpTrigger, CopyButton, CounterBadge, CountryOptions, DatePicker, DateRangePicker, DeprecationWarningContext, DeprecationWarningProvider, DialogTrigger, Div, DonutChart, EmptyView, EmptyViewContainer, FieldDescription, FieldError, FileCard, FileCardList, FileDropZone, FileField, Flex, GridList, GridListItem, Header, HeaderNavigation, Heading, Icon, IconAI, IconAIHosting, IconAnalytics, IconApp, IconAscending, IconAttachment, IconAutoresponder, IconBackLink, IconBackup, IconBold, IconCamera, IconCertificate, IconChangelog, IconCheck, IconCheckboxChecked, IconCheckboxEmpty, IconCheckboxIndeterminate, IconChevronDown, IconChevronLeft, IconChevronRight, IconChevronUp, IconClose, IconCode, IconContainer, IconContextMenu, IconContextMenuVertical, IconContract, IconContractPartner, IconContributor, IconCopy, IconCronjob, IconCustomer, IconDanger, IconDashboard, IconDatabase, IconDate, IconDelete, IconDeliveryBox, IconDescending, IconDesktop, IconDirectory, IconDnsSubZone, IconDnsZone, IconDomain, IconDownload, IconEdit, IconEmail, IconEmailArchive, IconExtension, IconExternalLink, IconFailed, IconFeedback, IconFile, IconFilter, IconForwardAddress, IconForwardLink, IconHide, IconHome, IconImage, IconInfo, IconInvite, IconInvoice, IconItalic, IconKnowledgeHint, IconLanguage, IconLeadFyndr, IconLink, IconLock, IconLockOpen, IconLogout, IconMainUser, IconMarketplace, IconMaximize, IconMember, IconMenu, IconMinimize, IconMinus, IconMittwald, IconMobile, IconMonitoring, IconMove, IconNewsletter, IconNotification, IconNumber, IconOrder, IconOrderedList, IconPassword, IconPath, IconPause, IconPayment, IconPending, IconPicture, IconPlus, IconProject, IconQuote, IconRadioOff, IconRadioOn, IconRedo, IconRefresh, IconRegistry, IconSave, IconSearch, IconSecurity, IconSend, IconServer, IconSetProvider, IconSettings, IconShare, IconShow, IconSorting, IconSsh, IconSshKey, IconSshSftp, IconStack, IconStar, IconStarFilled, IconStart, IconStrikeThrough, IconSubdomain, IconSucceeded, IconSuccess, IconSupport, IconTerminate, IconTicket, IconTime, IconUnavailable, IconUndo, IconUnorderedList, IconUpload, IconUser, IconVhost, IconView, IconVolume, IconWarning, IllustratedMessage, Image, ImageCropper, Initials, InlineCode, IntlProvider, Kbd, Label, LabeledValue, LayoutCard, Legend, LegendItem, LightBox, LightBoxGallery, LightBoxGalleryItem, LightBoxTrigger, LightBoxZoom, Line, Link, List, ListFilter, ListItem, ListItemView, ListItemViewContent, ListLoaderAsync, ListSorting, ListStaticData, ListSummary, LoadingSpinner, Markdown, MarkdownEditor, MenuItem, MenuTrigger, Message, MessageSeparator, MessageThread, Modal, ModalTrigger, Navigation, NavigationGroup, Notification, NotificationController, NotificationProvider, NumberField, Option, Overlay, OverlayContent, OverlayController, OverlayTrigger, PasswordCreationField, Popover, PopoverContent, PopoverTrigger, ProgressBar, PropsContextProvider, Radio, RadioButton, RadioGroup, RangeCalendar, Rating, RatingSegment, Render, RouterProvider, SearchField, Section, Segment, SegmentedControl, Select, Separator, SettingsProvider, Skeleton, SkeletonMode, SkeletonText, Slider, SortingFunctions, SuspenseTrigger, Switch, Tab, TabNavigation, TabTitle, Table, TableBody, TableCell, TableColumn, TableFooterRow, TableHeader, TableRow, Tabs, Text, TextArea, TextField, ThemedHtml, TimeField, Tooltip, TooltipTrigger, TranslationProvider, Truncate, TunnelEntry, TypedArea, TypedBar, TypedChartGrid, TypedChartLegend, TypedChartTooltip, TypedLine, TypedList, TypedListFilter, TypedListItem, TypedListLoaderAsync, TypedListSorting, TypedListStaticData, TypedXAxis, TypedYAxis, Wrap, XAxis, YAxis, abortAction, builtInComponentDefaults, dynamic, eventHandlerContext, flags, getRemoteEvent, getResolvedTheme, getTheme, iconCategories, isDateRangeValue, overlayTriggersTunneledTo, propsContext, resolveDateRangeFilterValue, setTheme, sortByDachFirst, themeHtmlAttribute, typedCartesianChart, typedList, useAriaAnnounceSuspense, useComponentDefaults, useControlledRemoteValueProps, useDesignTokens, useIsMounted, useLanguage, useList, useListMetadata, useLocalizedStringFormatter, useModalController, useNotificationController, useOnChange, useOverlayController, useProps, useTheme as useStoredTheme, useResolvedTheme as useTheme, useTranslationProvider, useWarnDeprecation };
|
package/dist/js/packages/components/src/components/FileCard/components/FileSizeText/FileSizeText.mjs
CHANGED
|
@@ -3,17 +3,36 @@
|
|
|
3
3
|
import { Text } from "../../../Text/Text.mjs";
|
|
4
4
|
import FileCard_module_default from "../../FileCard.module.mjs";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { useNumberFormatter } from "react-aria";
|
|
6
7
|
// src/components/FileCard/components/FileSizeText/FileSizeText.tsx
|
|
8
|
+
var units = [
|
|
9
|
+
"byte",
|
|
10
|
+
"kilobyte",
|
|
11
|
+
"megabyte",
|
|
12
|
+
"gigabyte",
|
|
13
|
+
"terabyte",
|
|
14
|
+
"petabyte"
|
|
15
|
+
];
|
|
16
|
+
var getUnit = (sizeInBytes) => {
|
|
17
|
+
let index = Math.min(Math.max(Math.floor(Math.log10(sizeInBytes) / 3), 0), units.length - 1);
|
|
18
|
+
if (index < units.length - 1 && Math.round(sizeInBytes / 1e3 ** index * 10) / 10 >= 1e3) index++;
|
|
19
|
+
return {
|
|
20
|
+
unit: units[index] ?? "byte",
|
|
21
|
+
value: sizeInBytes / 1e3 ** index
|
|
22
|
+
};
|
|
23
|
+
};
|
|
7
24
|
var FileSizeText = (props) => {
|
|
8
25
|
const { sizeInBytes } = props;
|
|
26
|
+
const { unit, value } = getUnit(sizeInBytes);
|
|
27
|
+
const formatter = useNumberFormatter({
|
|
28
|
+
style: "unit",
|
|
29
|
+
unit,
|
|
30
|
+
unitDisplay: unit === "byte" ? "long" : "short",
|
|
31
|
+
maximumFractionDigits: 1
|
|
32
|
+
});
|
|
9
33
|
return /* @__PURE__ */ jsx(Text, {
|
|
10
34
|
className: FileCard_module_default.subTitle,
|
|
11
|
-
children:
|
|
12
|
-
notation: "compact",
|
|
13
|
-
style: "unit",
|
|
14
|
-
unit: "byte",
|
|
15
|
-
unitDisplay: "narrow"
|
|
16
|
-
}).format(sizeInBytes)
|
|
35
|
+
children: formatter.format(value)
|
|
17
36
|
});
|
|
18
37
|
};
|
|
19
38
|
export { FileSizeText, FileSizeText as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileSizeText.mjs","names":["styles"],"sources":["../../../../../../../../../src/components/FileCard/components/FileSizeText/FileSizeText.tsx"],"sourcesContent":["import type { FC } from \"react\";\nimport { Text } from \"@/components/Text\";\nimport styles from \"@/components/FileCard/FileCard.module.scss\";\n\ninterface Props {\n sizeInBytes: number;\n}\n\
|
|
1
|
+
{"version":3,"file":"FileSizeText.mjs","names":["styles"],"sources":["../../../../../../../../../src/components/FileCard/components/FileSizeText/FileSizeText.tsx"],"sourcesContent":["import type { FC } from \"react\";\nimport { useNumberFormatter } from \"react-aria\";\nimport { Text } from \"@/components/Text\";\nimport styles from \"@/components/FileCard/FileCard.module.scss\";\n\ninterface Props {\n sizeInBytes: number;\n}\n\nconst units = [\n \"byte\",\n \"kilobyte\",\n \"megabyte\",\n \"gigabyte\",\n \"terabyte\",\n \"petabyte\",\n] as const;\n\nconst getUnit = (sizeInBytes: number) => {\n let index = Math.min(\n Math.max(Math.floor(Math.log10(sizeInBytes) / 3), 0),\n units.length - 1,\n );\n\n // 999,960 bytes would otherwise round to \"1,000 kB\"\n if (\n index < units.length - 1 &&\n Math.round((sizeInBytes / 1000 ** index) * 10) / 10 >= 1000\n ) {\n index++;\n }\n\n return { unit: units[index] ?? \"byte\", value: sizeInBytes / 1000 ** index };\n};\n\nexport const FileSizeText: FC<Props> = (props) => {\n const { sizeInBytes } = props;\n const { unit, value } = getUnit(sizeInBytes);\n\n const formatter = useNumberFormatter({\n style: \"unit\",\n unit,\n unitDisplay: unit === \"byte\" ? \"long\" : \"short\",\n maximumFractionDigits: 1,\n });\n\n return <Text className={styles.subTitle}>{formatter.format(value)}</Text>;\n};\n\nexport default FileSizeText;\n"],"mappings":";;;;;;;AASA,IAAM,QAAQ;CACZ;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,IAAM,WAAW,gBAAwB;CACvC,IAAI,QAAQ,KAAK,IACf,KAAK,IAAI,KAAK,MAAM,KAAK,MAAM,WAAW,IAAI,CAAC,GAAG,CAAC,GACnD,MAAM,SAAS,CACjB;CAGA,IACE,QAAQ,MAAM,SAAS,KACvB,KAAK,MAAO,cAAc,OAAQ,QAAS,EAAE,IAAI,MAAM,KAEvD;CAGF,OAAO;EAAE,MAAM,MAAM,UAAU;EAAQ,OAAO,cAAc,OAAQ;CAAM;AAC5E;AAEA,IAAa,gBAA2B,UAAU;CAChD,MAAM,EAAE,gBAAgB;CACxB,MAAM,EAAE,MAAM,UAAU,QAAQ,WAAW;CAE3C,MAAM,YAAY,mBAAmB;EACnC,OAAO;EACP;EACA,aAAa,SAAS,SAAS,SAAS;EACxC,uBAAuB;CACzB,CAAC;CAED,OAAO,oBAAC,MAAD;EAAM,WAAWA,wBAAO;EAAW,UAAA,UAAU,OAAO,KAAK;CAAQ,CAAA;AAC1E"}
|
|
@@ -10,13 +10,14 @@ import DivView from "../../views/DivView.mjs";
|
|
|
10
10
|
import __locale_default from "../../../../../_virtual/_22.locale.mjs";
|
|
11
11
|
import { Overlay } from "../Overlay/Overlay.mjs";
|
|
12
12
|
import LightBox_module_default from "./LightBox.module.mjs";
|
|
13
|
+
import LightBoxZoomView from "../../views/LightBoxZoomView.mjs";
|
|
13
14
|
import clsx from "clsx";
|
|
14
15
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
15
16
|
import { useLocalizedStringFormatter } from "react-aria";
|
|
16
17
|
// src/components/LightBox/LightBox.tsx
|
|
17
18
|
var LightBox = flowComponent("LightBox", (props) => {
|
|
18
|
-
const { controller: controllerFromProps, children, ref: ignoredRef, className, fitScreen = true, ...rest } = props;
|
|
19
|
-
const rootClassName = clsx(LightBox_module_default.lightBox, fitScreen && LightBox_module_default.fitScreen, className);
|
|
19
|
+
const { controller: controllerFromProps, children, ref: ignoredRef, className, fitScreen = true, withZoom, ...rest } = props;
|
|
20
|
+
const rootClassName = clsx(LightBox_module_default.lightBox, (fitScreen || withZoom) && LightBox_module_default.fitScreen, className);
|
|
20
21
|
const propsContext = {
|
|
21
22
|
ActionGroup: {
|
|
22
23
|
preserveOrder: true,
|
|
@@ -31,11 +32,18 @@ var LightBox = flowComponent("LightBox", (props) => {
|
|
|
31
32
|
component: "LightBox"
|
|
32
33
|
}
|
|
33
34
|
},
|
|
34
|
-
LightBoxGallery: {
|
|
35
|
+
LightBoxGallery: {
|
|
36
|
+
className: LightBox_module_default.gallery,
|
|
37
|
+
LightBoxGalleryItem: { withZoom }
|
|
38
|
+
}
|
|
35
39
|
};
|
|
36
40
|
const controllerFromContext = useOverlayController("LightBox", { reuseControllerFromContext: true });
|
|
37
41
|
const controller = controllerFromProps ?? controllerFromContext;
|
|
38
42
|
const stringFormatter = useLocalizedStringFormatter(__locale_default, "LightBox");
|
|
43
|
+
const zoomableContent = /* @__PURE__ */ jsx(LightBoxZoomView, {
|
|
44
|
+
className: LightBox_module_default.zoom,
|
|
45
|
+
children
|
|
46
|
+
});
|
|
39
47
|
return /* @__PURE__ */ jsx(Overlay, {
|
|
40
48
|
overlayType: "LightBox",
|
|
41
49
|
className: rootClassName,
|
|
@@ -45,18 +53,18 @@ var LightBox = flowComponent("LightBox", (props) => {
|
|
|
45
53
|
props: propsContext,
|
|
46
54
|
children: [/* @__PURE__ */ jsx(DivView, {
|
|
47
55
|
className: LightBox_module_default.content,
|
|
48
|
-
children
|
|
56
|
+
children: withZoom ? zoomableContent : children
|
|
49
57
|
}), /* @__PURE__ */ jsxs(DivView, {
|
|
50
58
|
className: LightBox_module_default.actions,
|
|
51
|
-
children: [/* @__PURE__ */ jsx(
|
|
59
|
+
children: [/* @__PURE__ */ jsx(UiComponentTunnelExit, {
|
|
60
|
+
id: "actionGroup",
|
|
61
|
+
component: "LightBox"
|
|
62
|
+
}), /* @__PURE__ */ jsx(ButtonView, {
|
|
52
63
|
color: "light-static",
|
|
53
64
|
variant: "solid",
|
|
54
65
|
onPress: () => controller.close(),
|
|
55
66
|
"aria-label": stringFormatter.format("close"),
|
|
56
67
|
children: /* @__PURE__ */ jsx(IconClose, {})
|
|
57
|
-
}), /* @__PURE__ */ jsx(UiComponentTunnelExit, {
|
|
58
|
-
id: "actionGroup",
|
|
59
|
-
component: "LightBox"
|
|
60
68
|
})]
|
|
61
69
|
})]
|
|
62
70
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LightBox.mjs","names":["styles","locales"],"sources":["../../../../../../../src/components/LightBox/LightBox.tsx"],"sourcesContent":["import {\n flowComponent,\n type FlowComponentProps,\n} from \"@/lib/componentFactory/flowComponent\";\nimport type { PropsWithChildren } from \"react\";\nimport type { PropsWithClassName } from \"@/lib/types/props\";\nimport { Overlay } from \"@/components/Overlay/Overlay\";\nimport clsx from \"clsx\";\nimport type { OverlayController } from \"@/lib/controller\";\nimport { useOverlayController } from \"@/lib/controller\";\nimport type { PropsContext } from \"@/lib/propsContext\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport { IconClose } from \"@/components/Icon/components/icons\";\nimport styles from \"./LightBox.module.scss\";\nimport DivView from \"@/views/DivView\";\nimport ButtonView from \"@/views/ButtonView\";\nimport { UiComponentTunnelExit } from \"@/components/UiComponentTunnel/UiComponentTunnelExit\";\nimport { useLocalizedStringFormatter } from \"react-aria\";\nimport locales from \"./locales/*.locale.json\";\n\nexport interface LightBoxProps\n extends PropsWithChildren, FlowComponentProps, PropsWithClassName {\n /** An overlay controller to control the light box state. */\n controller?: OverlayController;\n /**\n * Whether content can be displayed larger than the available space in the\n * screen. @default true\n */\n fitScreen?: boolean;\n}\n\nexport const LightBox = flowComponent(\"LightBox\", (props) => {\n const {\n controller: controllerFromProps,\n children,\n ref: ignoredRef,\n className,\n fitScreen = true,\n ...rest\n } = props;\n\n const rootClassName = clsx(\n styles.lightBox,\n fitScreen && styles.fitScreen,\n className,\n );\n\n const propsContext: PropsContext = {\n ActionGroup: {\n preserveOrder: true,\n spacing: \"m\",\n className: styles.actionGroup,\n Button: { variant: \"solid\", color: \"light-static\" },\n tunnel: {\n id: \"actionGroup\",\n component: \"LightBox\",\n },\n },\n LightBoxGallery: {\n className: styles.gallery,\n },\n };\n\n const controllerFromContext = useOverlayController(\"LightBox\", {\n reuseControllerFromContext: true,\n });\n\n const controller = controllerFromProps ?? controllerFromContext;\n\n const stringFormatter = useLocalizedStringFormatter(locales, \"LightBox\");\n\n return (\n <Overlay\n overlayType=\"LightBox\"\n className={rootClassName}\n controller={controller}\n {...rest}\n >\n <PropsContextProvider props={propsContext}>\n <DivView className={styles.content}
|
|
1
|
+
{"version":3,"file":"LightBox.mjs","names":["styles","locales"],"sources":["../../../../../../../src/components/LightBox/LightBox.tsx"],"sourcesContent":["import {\n flowComponent,\n type FlowComponentProps,\n} from \"@/lib/componentFactory/flowComponent\";\nimport type { PropsWithChildren } from \"react\";\nimport type { PropsWithClassName } from \"@/lib/types/props\";\nimport { Overlay } from \"@/components/Overlay/Overlay\";\nimport clsx from \"clsx\";\nimport type { OverlayController } from \"@/lib/controller\";\nimport { useOverlayController } from \"@/lib/controller\";\nimport type { PropsContext } from \"@/lib/propsContext\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport { IconClose } from \"@/components/Icon/components/icons\";\nimport styles from \"./LightBox.module.scss\";\nimport DivView from \"@/views/DivView\";\nimport ButtonView from \"@/views/ButtonView\";\nimport LightBoxZoomView from \"@/views/LightBoxZoomView\";\nimport { UiComponentTunnelExit } from \"@/components/UiComponentTunnel/UiComponentTunnelExit\";\nimport { useLocalizedStringFormatter } from \"react-aria\";\nimport locales from \"./locales/*.locale.json\";\n\nexport interface LightBoxProps\n extends PropsWithChildren, FlowComponentProps, PropsWithClassName {\n /** An overlay controller to control the light box state. */\n controller?: OverlayController;\n /**\n * Whether content can be displayed larger than the available space in the\n * screen. @default true\n */\n fitScreen?: boolean;\n /**\n * Whether the content can be zoomed. Applies to the items of a\n * `LightBoxGallery` as well. The content then always fits the screen,\n * whatever `fitScreen` says. @default false\n */\n withZoom?: boolean;\n}\n\nexport const LightBox = flowComponent(\"LightBox\", (props) => {\n const {\n controller: controllerFromProps,\n children,\n ref: ignoredRef,\n className,\n fitScreen = true,\n withZoom,\n ...rest\n } = props;\n\n const rootClassName = clsx(\n styles.lightBox,\n (fitScreen || withZoom) && styles.fitScreen,\n className,\n );\n\n const propsContext: PropsContext = {\n ActionGroup: {\n preserveOrder: true,\n spacing: \"m\",\n className: styles.actionGroup,\n Button: { variant: \"solid\", color: \"light-static\" },\n tunnel: {\n id: \"actionGroup\",\n component: \"LightBox\",\n },\n },\n LightBoxGallery: {\n className: styles.gallery,\n LightBoxGalleryItem: { withZoom },\n },\n };\n\n const controllerFromContext = useOverlayController(\"LightBox\", {\n reuseControllerFromContext: true,\n });\n\n const controller = controllerFromProps ?? controllerFromContext;\n\n const stringFormatter = useLocalizedStringFormatter(locales, \"LightBox\");\n\n const zoomableContent = (\n <LightBoxZoomView className={styles.zoom}>{children}</LightBoxZoomView>\n );\n\n return (\n <Overlay\n overlayType=\"LightBox\"\n className={rootClassName}\n controller={controller}\n {...rest}\n >\n <PropsContextProvider props={propsContext}>\n <DivView className={styles.content}>\n {withZoom ? zoomableContent : children}\n </DivView>\n <DivView className={styles.actions}>\n <UiComponentTunnelExit id=\"actionGroup\" component=\"LightBox\" />\n <ButtonView\n color=\"light-static\"\n variant=\"solid\"\n onPress={() => controller.close()}\n aria-label={stringFormatter.format(\"close\")}\n >\n <IconClose />\n </ButtonView>\n </DivView>\n </PropsContextProvider>\n </Overlay>\n );\n});\n\nexport default LightBox;\n"],"mappings":";;;;;;;;;;;;;;;;;AAsCA,IAAa,WAAW,cAAc,aAAa,UAAU;CAC3D,MAAM,EACJ,YAAY,qBACZ,UACA,KAAK,YACL,WACA,YAAY,MACZ,UACA,GAAG,SACD;CAEJ,MAAM,gBAAgB,KACpBA,wBAAO,WACN,aAAa,aAAaA,wBAAO,WAClC,SACF;CAEA,MAAM,eAA6B;EACjC,aAAa;GACX,eAAe;GACf,SAAS;GACT,WAAWA,wBAAO;GAClB,QAAQ;IAAE,SAAS;IAAS,OAAO;GAAe;GAClD,QAAQ;IACN,IAAI;IACJ,WAAW;GACb;EACF;EACA,iBAAiB;GACf,WAAWA,wBAAO;GAClB,qBAAqB,EAAE,SAAS;EAClC;CACF;CAEA,MAAM,wBAAwB,qBAAqB,YAAY,EAC7D,4BAA4B,KAC9B,CAAC;CAED,MAAM,aAAa,uBAAuB;CAE1C,MAAM,kBAAkB,4BAA4BC,kBAAS,UAAU;CAEvE,MAAM,kBACJ,oBAAC,kBAAD;EAAkB,WAAWD,wBAAO;EAAO;CAA2B,CAAA;CAGxE,OACE,oBAAC,SAAD;EACE,aAAY;EACZ,WAAW;EACC;EACZ,GAAI;EAEJ,UAAA,qBAAC,sBAAD;GAAsB,OAAO;GAA7B,UAAA,CACE,oBAAC,SAAD;IAAS,WAAWA,wBAAO;IACxB,UAAA,WAAW,kBAAkB;GACvB,CAAA,GACT,qBAAC,SAAD;IAAS,WAAWA,wBAAO;IAA3B,UAAA,CACE,oBAAC,uBAAD;KAAuB,IAAG;KAAc,WAAU;IAAY,CAAA,GAC9D,oBAAC,YAAD;KACE,OAAM;KACN,SAAQ;KACR,eAAe,WAAW,MAAM;KAChC,cAAY,gBAAgB,OAAO,OAAO;KAE1C,UAAA,oBAAC,WAAD,CAAY,CAAA;IACF,CAAA,CACL;GACW,CAAA,CAAA;;CACf,CAAA;AAEb,CAAC"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// src/components/LightBox/LightBox.module.scss
|
|
4
4
|
var lightBox = "flow--light-box";
|
|
5
5
|
var content = "flow--light-box--content";
|
|
6
|
+
var zoom = "flow--light-box--zoom";
|
|
6
7
|
var fitScreen = "flow--light-box--fit-screen";
|
|
7
8
|
var actions = "flow--light-box--actions";
|
|
8
9
|
var actionGroup = "flow--light-box--action-group";
|
|
@@ -10,11 +11,12 @@ var gallery = "flow--light-box--gallery";
|
|
|
10
11
|
var LightBox_module_default = {
|
|
11
12
|
lightBox,
|
|
12
13
|
content,
|
|
14
|
+
zoom,
|
|
13
15
|
fitScreen,
|
|
14
16
|
actions,
|
|
15
17
|
actionGroup,
|
|
16
18
|
gallery
|
|
17
19
|
};
|
|
18
|
-
export { actionGroup, actions, content, LightBox_module_default as default, fitScreen, gallery, lightBox };
|
|
20
|
+
export { actionGroup, actions, content, LightBox_module_default as default, fitScreen, gallery, lightBox, zoom };
|
|
19
21
|
|
|
20
22
|
//# sourceMappingURL=LightBox.module.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LightBox.module.mjs","names":[],"sources":["../../../../../../../src/components/LightBox/LightBox.module.scss"],"sourcesContent":[".lightBox {\n /* Overlay.module.scss lays the viewport out. */\n > :global(.flow--overlay--viewport) {\n /* react-aria's own modal wrapper — no className from Flow, so its\n default `react-aria-Modal` class is the handle. */\n > :global(.react-aria-Modal) {\n display: flex;\n justify-content: center;\n width: inherit;\n max-height: var(--visual-viewport-height);\n }\n }\n\n [role=\"dialog\"] {\n outline: none;\n display: flex;\n justify-content: center;\n max-width: var(--light-box--max-width);\n max-height: var(--light-box--max-height);\n }\n\n .content {\n overflow: auto;\n\n // The image is a consumer child — Flow `Image` or a bare `<img>`.\n // stylelint-disable
|
|
1
|
+
{"version":3,"file":"LightBox.module.mjs","names":[],"sources":["../../../../../../../src/components/LightBox/LightBox.module.scss"],"sourcesContent":[".lightBox {\n /* Overlay.module.scss lays the viewport out. */\n > :global(.flow--overlay--viewport) {\n /* react-aria's own modal wrapper — no className from Flow, so its\n default `react-aria-Modal` class is the handle. */\n > :global(.react-aria-Modal) {\n display: flex;\n justify-content: center;\n width: inherit;\n max-height: var(--visual-viewport-height);\n }\n }\n\n [role=\"dialog\"] {\n outline: none;\n display: flex;\n justify-content: center;\n max-width: var(--light-box--max-width);\n max-height: var(--light-box--max-height);\n }\n\n .content {\n overflow: auto;\n\n // The image is a consumer child — Flow `Image` or a bare `<img>`.\n // stylelint-disable selector-max-type -- bare `<img>` has no class\n > img,\n .zoom > * > img {\n width: 100%;\n }\n // stylelint-enable selector-max-type\n }\n\n /* The zoom wraps the content twice: the area it zooms and what it scales. */\n &.fitScreen {\n .content {\n > *,\n .zoom > *,\n .zoom > * > * {\n max-height: var(--light-box--max-height);\n }\n\n /* Zoomed content may cover the whole screen. */\n &:has(> .zoom) {\n overflow: visible;\n }\n }\n }\n\n /* In the screen's top right corner, over the content. */\n .actions {\n position: fixed;\n top: var(--light-box--spacing);\n inset-inline-end: var(--light-box--spacing);\n display: flex;\n column-gap: var(--light-box--spacing);\n }\n\n .actionGroup {\n flex-wrap: nowrap;\n }\n\n .gallery {\n width: var(--light-box--max-width);\n }\n\n &:has(.gallery) {\n .actions {\n display: none;\n }\n }\n}\n\n@media (max-width: 768px) {\n .lightBox {\n [role=\"dialog\"] {\n max-width: var(--light-box--max-width-mobile);\n max-height: var(--light-box--max-height-mobile);\n }\n\n &.fitScreen {\n .content {\n > *,\n .zoom > *,\n .zoom > * > * {\n max-height: var(--light-box--max-height-mobile);\n }\n }\n }\n\n .gallery {\n width: var(--light-box--max-width-mobile);\n }\n }\n}\n"],"mappings":""}
|
|
@@ -19,34 +19,36 @@ var LightBoxGallery = flowComponent("LightBoxGallery", (props) => {
|
|
|
19
19
|
const count = React.Children.count(children);
|
|
20
20
|
const isFirst = currentIndex === 0;
|
|
21
21
|
const isLast = currentIndex === count - 1;
|
|
22
|
-
const
|
|
22
|
+
const swipeStart = useRef(null);
|
|
23
23
|
const swipeThreshold = 50;
|
|
24
24
|
const containerRef = useRef(null);
|
|
25
|
+
const itemRef = useRef(null);
|
|
25
26
|
useEffect(() => {
|
|
26
27
|
const container = containerRef.current;
|
|
27
28
|
const focused = document.activeElement;
|
|
28
29
|
if (container && (!container.contains(focused) || focused?.matches(":disabled"))) container.focus();
|
|
29
30
|
}, [currentIndex]);
|
|
30
31
|
const paginate = (direction) => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return next;
|
|
36
|
-
});
|
|
32
|
+
const next = Math.min(Math.max(currentIndex + direction, 0), count - 1);
|
|
33
|
+
if (next === currentIndex) return;
|
|
34
|
+
if (itemRef.current?.contains(document.activeElement)) containerRef.current?.focus();
|
|
35
|
+
setIndex(next);
|
|
37
36
|
};
|
|
38
37
|
const handlePointerDown = (e) => {
|
|
39
38
|
if (!e.isPrimary) return;
|
|
40
|
-
|
|
39
|
+
swipeStart.current = {
|
|
40
|
+
pointerId: e.pointerId,
|
|
41
|
+
x: e.clientX
|
|
42
|
+
};
|
|
41
43
|
};
|
|
42
44
|
const handlePointerUp = (e) => {
|
|
43
|
-
if (
|
|
44
|
-
const distance =
|
|
45
|
+
if (swipeStart.current?.pointerId !== e.pointerId) return;
|
|
46
|
+
const distance = swipeStart.current.x - e.clientX;
|
|
45
47
|
if (Math.abs(distance) > swipeThreshold) paginate(distance > 0 ? 1 : -1);
|
|
46
|
-
|
|
48
|
+
swipeStart.current = null;
|
|
47
49
|
};
|
|
48
50
|
const handlePointerCancel = () => {
|
|
49
|
-
|
|
51
|
+
swipeStart.current = null;
|
|
50
52
|
};
|
|
51
53
|
const handleKeyDown = (e) => {
|
|
52
54
|
switch (e.key) {
|
|
@@ -73,6 +75,7 @@ var LightBoxGallery = flowComponent("LightBoxGallery", (props) => {
|
|
|
73
75
|
"aria-label": stringFormatter.format("gallery"),
|
|
74
76
|
children: [/* @__PURE__ */ jsx("div", {
|
|
75
77
|
className: LightBoxGallery_module_default.galleryItem,
|
|
78
|
+
ref: itemRef,
|
|
76
79
|
children: children[currentIndex]
|
|
77
80
|
}, currentIndex), /* @__PURE__ */ jsxs("div", {
|
|
78
81
|
className: LightBoxGallery_module_default.controls,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LightBoxGallery.mjs","names":["locales","styles"],"sources":["../../../../../../../../../src/components/LightBox/components/LightBoxGallery/LightBoxGallery.tsx"],"sourcesContent":["import {\n flowComponent,\n type FlowComponentProps,\n} from \"@/lib/componentFactory/flowComponent\";\nimport React, { type ReactNode, useEffect, useRef, useState } from \"react\";\nimport {\n IconChevronLeft,\n IconChevronRight,\n} from \"@/components/Icon/components/icons\";\nimport styles from \"./LightBoxGallery.module.scss\";\nimport type { PropsWithClassName } from \"@/lib/types/props\";\nimport clsx from \"clsx\";\nimport { useLocalizedStringFormatter } from \"react-aria\";\nimport locales from \"../../locales/*.locale.json\";\nimport Button from \"@/components/Button\";\nimport { Controls } from \"@/components/LightBox/components/LightBoxGallery/Controls\";\n\nexport interface LightBoxGalleryProps\n extends PropsWithClassName, FlowComponentProps {\n children: ReactNode[];\n defaultIndex?: number;\n}\n\n/** @flr-generate all */\nexport const LightBoxGallery = flowComponent(\"LightBoxGallery\", (props) => {\n const { children, className, defaultIndex = 0, ref } = props;\n\n const [currentIndex, setIndex] = useState(defaultIndex);\n\n const count = React.Children.count(children);\n\n const isFirst = currentIndex === 0;\n const isLast = currentIndex === count - 1;\n\n const
|
|
1
|
+
{"version":3,"file":"LightBoxGallery.mjs","names":["locales","styles"],"sources":["../../../../../../../../../src/components/LightBox/components/LightBoxGallery/LightBoxGallery.tsx"],"sourcesContent":["import {\n flowComponent,\n type FlowComponentProps,\n} from \"@/lib/componentFactory/flowComponent\";\nimport React, { type ReactNode, useEffect, useRef, useState } from \"react\";\nimport {\n IconChevronLeft,\n IconChevronRight,\n} from \"@/components/Icon/components/icons\";\nimport styles from \"./LightBoxGallery.module.scss\";\nimport type { PropsWithClassName } from \"@/lib/types/props\";\nimport clsx from \"clsx\";\nimport { useLocalizedStringFormatter } from \"react-aria\";\nimport locales from \"../../locales/*.locale.json\";\nimport Button from \"@/components/Button\";\nimport { Controls } from \"@/components/LightBox/components/LightBoxGallery/Controls\";\n\nexport interface LightBoxGalleryProps\n extends PropsWithClassName, FlowComponentProps {\n children: ReactNode[];\n defaultIndex?: number;\n}\n\n/** @flr-generate all */\nexport const LightBoxGallery = flowComponent(\"LightBoxGallery\", (props) => {\n const { children, className, defaultIndex = 0, ref } = props;\n\n const [currentIndex, setIndex] = useState(defaultIndex);\n\n const count = React.Children.count(children);\n\n const isFirst = currentIndex === 0;\n const isLast = currentIndex === count - 1;\n\n const swipeStart = useRef<{ pointerId: number; x: number } | null>(null);\n const swipeThreshold = 50;\n\n const containerRef = useRef<HTMLDivElement>(null);\n const itemRef = useRef<HTMLDivElement>(null);\n\n // A paging button that gets disabled keeps the focus but no longer receives\n // keys, so Escape would stop closing the light box.\n useEffect(() => {\n const container = containerRef.current;\n const focused = document.activeElement;\n if (\n container &&\n (!container.contains(focused) || focused?.matches(\":disabled\"))\n ) {\n container.focus();\n }\n }, [currentIndex]);\n\n const paginate = (direction: number) => {\n const next = Math.min(Math.max(currentIndex + direction, 0), count - 1);\n if (next === currentIndex) return;\n\n /* The item remounts, which would drop a focus inside it. */\n if (itemRef.current?.contains(document.activeElement)) {\n containerRef.current?.focus();\n }\n setIndex(next);\n };\n\n const handlePointerDown = (e: React.PointerEvent) => {\n if (!e.isPrimary) return;\n swipeStart.current = { pointerId: e.pointerId, x: e.clientX };\n };\n\n /* A pinch in the zoom keeps the release of its first finger, so a later\n press of another pointer must not read as a swipe. */\n const handlePointerUp = (e: React.PointerEvent) => {\n if (swipeStart.current?.pointerId !== e.pointerId) return;\n\n const distance = swipeStart.current.x - e.clientX;\n\n if (Math.abs(distance) > swipeThreshold) {\n paginate(distance > 0 ? 1 : -1);\n }\n\n swipeStart.current = null;\n };\n\n const handlePointerCancel = () => {\n swipeStart.current = null;\n };\n\n const handleKeyDown = (e: React.KeyboardEvent) => {\n switch (e.key) {\n case \"ArrowLeft\":\n if (!isFirst) paginate(-1);\n break;\n case \"ArrowRight\":\n if (!isLast) paginate(1);\n break;\n }\n };\n\n const stringFormatter = useLocalizedStringFormatter(locales, \"LightBox\");\n\n return (\n <div ref={ref} className={clsx(styles.lightBoxGallery, className)}>\n <div\n ref={containerRef}\n className={styles.content}\n onPointerDown={handlePointerDown}\n onPointerUp={handlePointerUp}\n onPointerCancel={handlePointerCancel}\n tabIndex={0}\n onKeyDown={handleKeyDown}\n role=\"region\"\n aria-roledescription=\"carousel\"\n aria-label={stringFormatter.format(\"gallery\")}\n >\n <div className={styles.galleryItem} key={currentIndex} ref={itemRef}>\n {children[currentIndex]}\n </div>\n\n <div className={styles.controls}>\n <Button\n aria-label={stringFormatter.format(\"previous\")}\n onPress={() => paginate(-1)}\n color=\"light-static\"\n className={styles.previousButton}\n isDisabled={isFirst}\n >\n <IconChevronLeft />\n </Button>\n\n <Controls count={count} currentIndex={currentIndex} />\n\n <Button\n aria-label={stringFormatter.format(\"next\")}\n onPress={() => paginate(1)}\n color=\"light-static\"\n className={styles.nextButton}\n isDisabled={isLast}\n >\n <IconChevronRight />\n </Button>\n </div>\n </div>\n </div>\n );\n});\n\nexport default LightBoxGallery;\n"],"mappings":";;;;;;;;;;;;;;;AAwBA,IAAa,kBAAkB,cAAc,oBAAoB,UAAU;CACzE,MAAM,EAAE,UAAU,WAAW,eAAe,GAAG,QAAQ;CAEvD,MAAM,CAAC,cAAc,YAAY,SAAS,YAAY;CAEtD,MAAM,QAAQ,MAAM,SAAS,MAAM,QAAQ;CAE3C,MAAM,UAAU,iBAAiB;CACjC,MAAM,SAAS,iBAAiB,QAAQ;CAExC,MAAM,aAAa,OAAgD,IAAI;CACvE,MAAM,iBAAiB;CAEvB,MAAM,eAAe,OAAuB,IAAI;CAChD,MAAM,UAAU,OAAuB,IAAI;CAI3C,gBAAgB;EACd,MAAM,YAAY,aAAa;EAC/B,MAAM,UAAU,SAAS;EACzB,IACE,cACC,CAAC,UAAU,SAAS,OAAO,KAAK,SAAS,QAAQ,WAAW,IAE7D,UAAU,MAAM;CAEpB,GAAG,CAAC,YAAY,CAAC;CAEjB,MAAM,YAAY,cAAsB;EACtC,MAAM,OAAO,KAAK,IAAI,KAAK,IAAI,eAAe,WAAW,CAAC,GAAG,QAAQ,CAAC;EACtE,IAAI,SAAS,cAAc;EAG3B,IAAI,QAAQ,SAAS,SAAS,SAAS,aAAa,GAClD,aAAa,SAAS,MAAM;EAE9B,SAAS,IAAI;CACf;CAEA,MAAM,qBAAqB,MAA0B;EACnD,IAAI,CAAC,EAAE,WAAW;EAClB,WAAW,UAAU;GAAE,WAAW,EAAE;GAAW,GAAG,EAAE;EAAQ;CAC9D;CAIA,MAAM,mBAAmB,MAA0B;EACjD,IAAI,WAAW,SAAS,cAAc,EAAE,WAAW;EAEnD,MAAM,WAAW,WAAW,QAAQ,IAAI,EAAE;EAE1C,IAAI,KAAK,IAAI,QAAQ,IAAI,gBACvB,SAAS,WAAW,IAAI,IAAI,EAAE;EAGhC,WAAW,UAAU;CACvB;CAEA,MAAM,4BAA4B;EAChC,WAAW,UAAU;CACvB;CAEA,MAAM,iBAAiB,MAA2B;EAChD,QAAQ,EAAE,KAAV;GACE,KAAK;IACH,IAAI,CAAC,SAAS,SAAS,EAAE;IACzB;GACF,KAAK,cACH,IAAI,CAAC,QAAQ,SAAS,CAAC;EAE3B;CACF;CAEA,MAAM,kBAAkB,4BAA4BA,kBAAS,UAAU;CAEvE,OACE,oBAAC,OAAD;EAAU;EAAK,WAAW,KAAKC,+BAAO,iBAAiB,SAAS;EAC9D,UAAA,qBAAC,OAAD;GACE,KAAK;GACL,WAAWA,+BAAO;GAClB,eAAe;GACf,aAAa;GACb,iBAAiB;GACjB,UAAU;GACV,WAAW;GACX,MAAK;GACL,wBAAqB;GACrB,cAAY,gBAAgB,OAAO,SAAS;GAV9C,UAAA,CAYE,oBAAC,OAAD;IAAK,WAAWA,+BAAO;IAAgC,KAAK;IACzD,UAAA,SAAS;GACP,GAFoC,YAEpC,GAEL,qBAAC,OAAD;IAAK,WAAWA,+BAAO;IAAvB,UAAA;KACE,oBAAC,QAAD;MACE,cAAY,gBAAgB,OAAO,UAAU;MAC7C,eAAe,SAAS,EAAE;MAC1B,OAAM;MACN,WAAWA,+BAAO;MAClB,YAAY;MAEZ,UAAA,oBAAC,iBAAD,CAAkB,CAAA;KACZ,CAAA;KAER,oBAAC,UAAD;MAAiB;MAAqB;KAAe,CAAA;KAErD,oBAAC,QAAD;MACE,cAAY,gBAAgB,OAAO,MAAM;MACzC,eAAe,SAAS,CAAC;MACzB,OAAM;MACN,WAAWA,+BAAO;MAClB,YAAY;MAEZ,UAAA,oBAAC,kBAAD,CAAmB,CAAA;KACb,CAAA;IACL;GACF,CAAA,CAAA;;CACF,CAAA;AAET,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LightBoxGallery.module.mjs","names":[],"sources":["../../../../../../../../../src/components/LightBox/components/LightBoxGallery/LightBoxGallery.module.scss"],"sourcesContent":[".lightBoxGallery {\n position: relative;\n display: flex;\n justify-content: space-between;\n align-items: center;\n\n --button-size: calc(\n var(--icon--size--m) + 2 * var(--button--padding-icon-only)\n );\n --button-size-plus-spacing: calc(\n var(--button-size) + var(--light-box--spacing)\n );\n --indicator-height: calc(var(--light-box--spacing) + var(--icon--size--m));\n\n .content {\n display: flex;\n flex-direction: column;\n width: 100%;\n justify-content: center;\n\n &:focus {\n outline: none;\n }\n }\n\n .galleryItem {\n position: relative;\n margin: 0 auto;\n user-select: none;\n max-height: var(--gallery-item-max-height);\n }\n\n .actions {\n position:
|
|
1
|
+
{"version":3,"file":"LightBoxGallery.module.mjs","names":[],"sources":["../../../../../../../../../src/components/LightBox/components/LightBoxGallery/LightBoxGallery.module.scss"],"sourcesContent":[".lightBoxGallery {\n position: relative;\n display: flex;\n justify-content: space-between;\n align-items: center;\n\n --button-size: calc(\n var(--icon--size--m) + 2 * var(--button--padding-icon-only)\n );\n --button-size-plus-spacing: calc(\n var(--button-size) + var(--light-box--spacing)\n );\n --indicator-height: calc(var(--light-box--spacing) + var(--icon--size--m));\n\n .content {\n display: flex;\n flex-direction: column;\n width: 100%;\n justify-content: center;\n\n &:focus {\n outline: none;\n }\n }\n\n .galleryItem {\n position: relative;\n margin: 0 auto;\n user-select: none;\n max-height: var(--gallery-item-max-height);\n }\n\n /* In the screen's top right corner, as the light box places its own. */\n .actions {\n position: fixed;\n top: var(--light-box--spacing);\n inset-inline-end: var(--light-box--spacing);\n display: flex;\n column-gap: var(--light-box--spacing);\n }\n\n .actionGroup {\n flex-wrap: nowrap;\n }\n\n /* The item's height is indefinite, so a percentage size here is cyclic and\n engines resolve it differently (WebKit stretched the image). An explicit\n cap scales the image down along its aspect ratio instead. */\n .image {\n animation: fade-in var(--transition--duration--default) ease-in forwards;\n max-height: var(--gallery-item-max-height);\n pointer-events: none;\n }\n\n @keyframes fade-in {\n from {\n opacity: 0;\n }\n\n to {\n opacity: 1;\n }\n }\n\n .indicators {\n display: flex;\n justify-content: center;\n column-gap: var(--light-box--indicator-spacing);\n color: var(--light-box--content-color);\n }\n\n .indicator {\n display: block;\n width: var(--light-box--indicator-size);\n height: var(--light-box--indicator-size);\n border: var(--light-box--indicator-border-width)\n var(--light-box--indicator-border-style) var(--light-box--content-color);\n border-radius: var(--light-box--indicator-corner-radius);\n\n &.current {\n background-color: var(--light-box--content-color);\n }\n }\n}\n\n@media (min-width: 768px) {\n .content {\n padding-inline: calc(\n var(--button-size-plus-spacing) + var(--light-box--spacing)\n );\n padding-bottom: var(--indicator-height);\n height: var(--light-box--max-height);\n }\n\n .galleryItem {\n --gallery-item-max-height: calc(\n var(--light-box--max-height) - var(--indicator-height)\n );\n }\n\n /* At the screen's edges, as far in as the light box's actions. */\n .indicators {\n position: fixed;\n bottom: var(--light-box--spacing);\n inset-inline: 0;\n }\n\n .previousButton,\n .nextButton {\n position: fixed;\n top: calc(50% - var(--button-size) / 2);\n }\n\n .previousButton {\n inset-inline-start: var(--light-box--spacing);\n }\n\n .nextButton {\n inset-inline-end: var(--light-box--spacing);\n }\n}\n\n@media (max-width: 768px) {\n .content {\n padding-inline: var(--button-size-plus-spacing);\n padding-bottom: var(--button-size-plus-spacing);\n height: var(--light-box--max-height-mobile);\n }\n\n .galleryItem {\n --gallery-item-max-height: calc(\n var(--light-box--max-height) - var(--button-size-plus-spacing)\n );\n }\n\n /* At the screen's bottom edge, as far in as the light box's actions. */\n .controls {\n display: flex;\n position: fixed;\n bottom: var(--light-box--spacing);\n inset-inline: var(--light-box--spacing);\n justify-content: space-between;\n align-items: center;\n }\n}\n"],"mappings":""}
|
|
@@ -8,12 +8,13 @@ import { UiComponentTunnelExit } from "../../../UiComponentTunnel/UiComponentTun
|
|
|
8
8
|
import { useOverlayController } from "../../../../lib/controller/overlay/useOverlayController.mjs";
|
|
9
9
|
import LightBoxGallery_module_default from "../LightBoxGallery/LightBoxGallery.module.mjs";
|
|
10
10
|
import __locale_default from "../../../../../../../_virtual/_22.locale.mjs";
|
|
11
|
+
import { LightBoxZoom } from "../LightBoxZoom/LightBoxZoom.mjs";
|
|
11
12
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
13
|
import { useLocalizedStringFormatter } from "react-aria";
|
|
13
14
|
// src/components/LightBox/components/LightBoxGalleryItem/LightBoxGalleryItem.tsx
|
|
14
15
|
/** @flr-generate all */
|
|
15
16
|
var LightBoxGalleryItem = flowComponent("LightBoxGalleryItem", (props) => {
|
|
16
|
-
const { children } = props;
|
|
17
|
+
const { children, withZoom } = props;
|
|
17
18
|
const controller = useOverlayController("Modal");
|
|
18
19
|
const propsContext = {
|
|
19
20
|
ActionGroup: {
|
|
@@ -30,16 +31,16 @@ var LightBoxGalleryItem = flowComponent("LightBoxGalleryItem", (props) => {
|
|
|
30
31
|
const stringFormatter = useLocalizedStringFormatter(__locale_default);
|
|
31
32
|
return /* @__PURE__ */ jsxs(PropsContextProvider, {
|
|
32
33
|
props: propsContext,
|
|
33
|
-
children: [children, /* @__PURE__ */ jsxs("div", {
|
|
34
|
+
children: [withZoom ? /* @__PURE__ */ jsx(LightBoxZoom, { children }) : children, /* @__PURE__ */ jsxs("div", {
|
|
34
35
|
className: LightBoxGallery_module_default.actions,
|
|
35
|
-
children: [/* @__PURE__ */ jsx(
|
|
36
|
+
children: [/* @__PURE__ */ jsx(UiComponentTunnelExit, {
|
|
37
|
+
id: "actionGroup",
|
|
38
|
+
component: "LightBoxGalleryItem"
|
|
39
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
36
40
|
"aria-label": stringFormatter.format("close"),
|
|
37
41
|
color: "light-static",
|
|
38
42
|
onPress: () => controller.close(),
|
|
39
43
|
children: /* @__PURE__ */ jsx(IconClose, {})
|
|
40
|
-
}), /* @__PURE__ */ jsx(UiComponentTunnelExit, {
|
|
41
|
-
id: "actionGroup",
|
|
42
|
-
component: "LightBoxGalleryItem"
|
|
43
44
|
})]
|
|
44
45
|
})]
|
|
45
46
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LightBoxGalleryItem.mjs","names":["styles","locales"],"sources":["../../../../../../../../../src/components/LightBox/components/LightBoxGalleryItem/LightBoxGalleryItem.tsx"],"sourcesContent":["import {\n flowComponent,\n type FlowComponentProps,\n} from \"@/lib/componentFactory/flowComponent\";\nimport styles from \"@/components/LightBox/components/LightBoxGallery/LightBoxGallery.module.scss\";\nimport { type PropsContext, PropsContextProvider } from \"@/lib/propsContext\";\nimport { IconClose } from \"@/components/Icon/components/icons\";\nimport { useOverlayController } from \"@/lib/hooks\";\nimport { useLocalizedStringFormatter } from \"react-aria\";\nimport locales from \"../../locales/*.locale.json\";\nimport { Button } from \"@/components/Button\";\nimport type { PropsWithChildren } from \"react\";\nimport { UiComponentTunnelExit } from \"@/components/UiComponentTunnel/UiComponentTunnelExit\";\n\n/* Renders no element of its own, so there is no ref to expose. */\nexport
|
|
1
|
+
{"version":3,"file":"LightBoxGalleryItem.mjs","names":["styles","locales","_jsx"],"sources":["../../../../../../../../../src/components/LightBox/components/LightBoxGalleryItem/LightBoxGalleryItem.tsx"],"sourcesContent":["import {\n flowComponent,\n type FlowComponentProps,\n} from \"@/lib/componentFactory/flowComponent\";\nimport styles from \"@/components/LightBox/components/LightBoxGallery/LightBoxGallery.module.scss\";\nimport { type PropsContext, PropsContextProvider } from \"@/lib/propsContext\";\nimport { IconClose } from \"@/components/Icon/components/icons\";\nimport { useOverlayController } from \"@/lib/hooks\";\nimport { useLocalizedStringFormatter } from \"react-aria\";\nimport locales from \"../../locales/*.locale.json\";\nimport { Button } from \"@/components/Button\";\nimport type { PropsWithChildren } from \"react\";\nimport { LightBoxZoom } from \"@/components/LightBox/components/LightBoxZoom\";\nimport { UiComponentTunnelExit } from \"@/components/UiComponentTunnel/UiComponentTunnelExit\";\n\n/* Renders no element of its own, so there is no ref to expose. */\nexport interface LightBoxGalleryItemProps\n extends PropsWithChildren, Omit<FlowComponentProps, \"ref\"> {\n /**\n * @internal Set by the `withZoom` of the surrounding `LightBox`: whether the\n * item's content can be zoomed.\n */\n withZoom?: boolean;\n}\n\n/** @flr-generate all */\nexport const LightBoxGalleryItem = flowComponent(\n \"LightBoxGalleryItem\",\n (props) => {\n const { children, withZoom } = props;\n\n const controller = useOverlayController(\"Modal\");\n\n const propsContext: PropsContext = {\n ActionGroup: {\n spacing: \"m\",\n className: styles.actionGroup,\n Button: { color: \"light-static\" },\n tunnel: { id: \"actionGroup\", component: \"LightBoxGalleryItem\" },\n },\n Image: { className: styles.image },\n };\n\n const stringFormatter = useLocalizedStringFormatter(locales);\n\n const zoomableContent = <LightBoxZoom>{children}</LightBoxZoom>;\n\n return (\n <PropsContextProvider props={propsContext}>\n {withZoom ? zoomableContent : children}\n <div className={styles.actions}>\n <UiComponentTunnelExit\n id=\"actionGroup\"\n component=\"LightBoxGalleryItem\"\n />\n <Button\n aria-label={stringFormatter.format(\"close\")}\n color=\"light-static\"\n onPress={() => controller.close()}\n >\n <IconClose />\n </Button>\n </div>\n </PropsContextProvider>\n );\n },\n);\n\nexport default LightBoxGalleryItem;\n"],"mappings":";;;;;;;;;;;;;;;AA0BA,IAAa,sBAAsB,cACjC,wBACC,UAAU;CACT,MAAM,EAAE,UAAU,aAAa;CAE/B,MAAM,aAAa,qBAAqB,OAAO;CAE/C,MAAM,eAA6B;EACjC,aAAa;GACX,SAAS;GACT,WAAWA,+BAAO;GAClB,QAAQ,EAAE,OAAO,eAAe;GAChC,QAAQ;IAAE,IAAI;IAAe,WAAW;GAAsB;EAChE;EACA,OAAO,EAAE,WAAWA,+BAAO,MAAM;CACnC;CAEA,MAAM,kBAAkB,4BAA4BC,gBAAO;CAI3D,OACE,qBAAC,sBAAD;EAAsB,OAAO;EAA7B,UAAA,CACG,WAJmBC,oBAAC,cAAD,EAAe,SAAuB,CAI9C,IAAkB,UAC9B,qBAAC,OAAD;GAAK,WAAWF,+BAAO;GAAvB,UAAA,CACE,oBAAC,uBAAD;IACE,IAAG;IACH,WAAU;GACX,CAAA,GACD,oBAAC,QAAD;IACE,cAAY,gBAAgB,OAAO,OAAO;IAC1C,OAAM;IACN,eAAe,WAAW,MAAM;IAEhC,UAAA,oBAAC,WAAD,CAAY,CAAA;GACN,CAAA,CACL;EACe,CAAA,CAAA;;AAE1B,CACF"}
|
package/dist/js/packages/components/src/components/LightBox/components/LightBoxZoom/LightBoxZoom.mjs
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
/* */
|
|
3
|
+
import { useLocalizedStringFormatter } from "../../../TranslationProvider/useLocalizedStringFormatter.mjs";
|
|
4
|
+
import __locale_default from "../../../../../../../_virtual/_22.locale.mjs";
|
|
5
|
+
import LightBoxZoom_module_default from "./LightBoxZoom.module.mjs";
|
|
6
|
+
import { visibleArea } from "./lib/zoomTransform.mjs";
|
|
7
|
+
import { useZoom } from "./hooks/useZoom.mjs";
|
|
8
|
+
import clsx from "clsx";
|
|
9
|
+
import { createContext, useCallback, useContext, useId, useLayoutEffect, useRef, useState } from "react";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
// src/components/LightBox/components/LightBoxZoom/LightBoxZoom.tsx
|
|
12
|
+
/**
|
|
13
|
+
* Lets a nested zoom switch the surrounding one off: a `LightBox` with
|
|
14
|
+
* `withZoom` wraps its content, and the items of a `LightBoxGallery` in it zoom
|
|
15
|
+
* on their own.
|
|
16
|
+
*/
|
|
17
|
+
var NestedZoomContext = createContext(void 0);
|
|
18
|
+
/**
|
|
19
|
+
* The zoomable area of a `LightBox` with `withZoom`. Not a `flowComponent`: it
|
|
20
|
+
* passes the light box's props context through to its children.
|
|
21
|
+
*
|
|
22
|
+
* @flr-generate all
|
|
23
|
+
*/
|
|
24
|
+
var LightBoxZoom = (props) => {
|
|
25
|
+
const { children, className } = props;
|
|
26
|
+
const registerWithSurroundingZoom = useContext(NestedZoomContext);
|
|
27
|
+
const [nestedZoomCount, setNestedZoomCount] = useState(0);
|
|
28
|
+
const isEnabled = nestedZoomCount === 0;
|
|
29
|
+
const registerNestedZoom = useCallback(() => {
|
|
30
|
+
setNestedZoomCount((count) => count + 1);
|
|
31
|
+
return () => setNestedZoomCount((count) => count - 1);
|
|
32
|
+
}, []);
|
|
33
|
+
useLayoutEffect(() => registerWithSurroundingZoom?.(), [registerWithSurroundingZoom]);
|
|
34
|
+
const ref = useRef(null);
|
|
35
|
+
const { transform, frame, isZoomed, isAnimated, isDragging, handlers } = useZoom(ref, isEnabled);
|
|
36
|
+
const descriptionId = useId();
|
|
37
|
+
const stringFormatter = useLocalizedStringFormatter(__locale_default, "LightBox");
|
|
38
|
+
const rootClassName = clsx(LightBoxZoom_module_default.lightBoxZoom, isZoomed && LightBoxZoom_module_default.zoomed, isDragging && LightBoxZoom_module_default.dragging, className);
|
|
39
|
+
const contentStyle = { transform: `translate(${transform.x}px, ${transform.y}px) scale(${transform.scale})` };
|
|
40
|
+
const focusRingStyle = isZoomed && frame ? {
|
|
41
|
+
...visibleArea(transform, frame),
|
|
42
|
+
right: "auto",
|
|
43
|
+
bottom: "auto"
|
|
44
|
+
} : void 0;
|
|
45
|
+
const passThrough = /* @__PURE__ */ jsx("div", {
|
|
46
|
+
className,
|
|
47
|
+
children: /* @__PURE__ */ jsx("div", { children })
|
|
48
|
+
});
|
|
49
|
+
const zoom = /* @__PURE__ */ jsxs("div", {
|
|
50
|
+
ref,
|
|
51
|
+
className: rootClassName,
|
|
52
|
+
role: "group",
|
|
53
|
+
"aria-label": stringFormatter.format("zoom"),
|
|
54
|
+
"aria-describedby": descriptionId,
|
|
55
|
+
tabIndex: 0,
|
|
56
|
+
onDragStart: (event) => event.preventDefault(),
|
|
57
|
+
...handlers,
|
|
58
|
+
children: [
|
|
59
|
+
/* @__PURE__ */ jsx("div", {
|
|
60
|
+
className: clsx(LightBoxZoom_module_default.content, isAnimated && LightBoxZoom_module_default.animated),
|
|
61
|
+
style: contentStyle,
|
|
62
|
+
children
|
|
63
|
+
}),
|
|
64
|
+
/* @__PURE__ */ jsx("span", {
|
|
65
|
+
className: LightBoxZoom_module_default.focusRing,
|
|
66
|
+
style: focusRingStyle
|
|
67
|
+
}),
|
|
68
|
+
/* @__PURE__ */ jsx("span", {
|
|
69
|
+
id: descriptionId,
|
|
70
|
+
hidden: true,
|
|
71
|
+
children: stringFormatter.format("zoomDescription")
|
|
72
|
+
})
|
|
73
|
+
]
|
|
74
|
+
});
|
|
75
|
+
return /* @__PURE__ */ jsx(NestedZoomContext, {
|
|
76
|
+
value: registerNestedZoom,
|
|
77
|
+
children: isEnabled ? zoom : passThrough
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
export { LightBoxZoom, LightBoxZoom as default };
|
|
81
|
+
|
|
82
|
+
//# sourceMappingURL=LightBoxZoom.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LightBoxZoom.mjs","names":["locales","styles"],"sources":["../../../../../../../../../src/components/LightBox/components/LightBoxZoom/LightBoxZoom.tsx"],"sourcesContent":["import {\n createContext,\n type FC,\n type PropsWithChildren,\n useCallback,\n useContext,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n} from \"react\";\nimport clsx from \"clsx\";\nimport type { PropsWithClassName } from \"@/lib/types/props\";\nimport { useLocalizedStringFormatter } from \"@/components/TranslationProvider\";\nimport locales from \"../../locales/*.locale.json\";\nimport styles from \"./LightBoxZoom.module.scss\";\nimport { useZoom } from \"./hooks/useZoom\";\nimport { visibleArea } from \"./lib/zoomTransform\";\n\nexport interface LightBoxZoomProps\n extends PropsWithChildren, PropsWithClassName {}\n\n/**\n * Lets a nested zoom switch the surrounding one off: a `LightBox` with\n * `withZoom` wraps its content, and the items of a `LightBoxGallery` in it zoom\n * on their own.\n */\nconst NestedZoomContext = createContext<(() => () => void) | undefined>(\n undefined,\n);\n\n/**\n * The zoomable area of a `LightBox` with `withZoom`. Not a `flowComponent`: it\n * passes the light box's props context through to its children.\n *\n * @flr-generate all\n */\nexport const LightBoxZoom: FC<LightBoxZoomProps> = (props) => {\n const { children, className } = props;\n\n const registerWithSurroundingZoom = useContext(NestedZoomContext);\n const [nestedZoomCount, setNestedZoomCount] = useState(0);\n const isEnabled = nestedZoomCount === 0;\n\n const registerNestedZoom = useCallback(() => {\n setNestedZoomCount((count) => count + 1);\n return () => setNestedZoomCount((count) => count - 1);\n }, []);\n\n /* Before paint, so the surrounding zoom never shows its own cursor. */\n useLayoutEffect(\n () => registerWithSurroundingZoom?.(),\n [registerWithSurroundingZoom],\n );\n\n const ref = useRef<HTMLDivElement>(null);\n const { transform, frame, isZoomed, isAnimated, isDragging, handlers } =\n useZoom(ref, isEnabled);\n const descriptionId = useId();\n\n const stringFormatter = useLocalizedStringFormatter(locales, \"LightBox\");\n\n const rootClassName = clsx(\n styles.lightBoxZoom,\n isZoomed && styles.zoomed,\n isDragging && styles.dragging,\n className,\n );\n\n const contentStyle = {\n transform: `translate(${transform.x}px, ${transform.y}px) scale(${transform.scale})`,\n };\n\n /* Zoomed, the ring outlines what is on screen, not the unscaled area. */\n const focusRingStyle =\n isZoomed && frame\n ? { ...visibleArea(transform, frame), right: \"auto\", bottom: \"auto\" }\n : undefined;\n\n /* The same elements as the zoom, so switching does not remount the\n children. */\n const passThrough = (\n <div className={className}>\n <div>{children}</div>\n </div>\n );\n\n const zoom = (\n <div\n ref={ref}\n className={rootClassName}\n role=\"group\"\n aria-label={stringFormatter.format(\"zoom\")}\n aria-describedby={descriptionId}\n tabIndex={0}\n onDragStart={(event) => event.preventDefault()}\n {...handlers}\n >\n <div\n className={clsx(styles.content, isAnimated && styles.animated)}\n style={contentStyle}\n >\n {children}\n </div>\n <span className={styles.focusRing} style={focusRingStyle} />\n <span id={descriptionId} hidden>\n {stringFormatter.format(\"zoomDescription\")}\n </span>\n </div>\n );\n\n return (\n <NestedZoomContext value={registerNestedZoom}>\n {isEnabled ? zoom : passThrough}\n </NestedZoomContext>\n );\n};\n\nexport default LightBoxZoom;\n"],"mappings":";;;;;;;;;;;;;;;;AA2BA,IAAM,oBAAoB,cACxB,KAAA,CACF;;;;;;;AAQA,IAAa,gBAAuC,UAAU;CAC5D,MAAM,EAAE,UAAU,cAAc;CAEhC,MAAM,8BAA8B,WAAW,iBAAiB;CAChE,MAAM,CAAC,iBAAiB,sBAAsB,SAAS,CAAC;CACxD,MAAM,YAAY,oBAAoB;CAEtC,MAAM,qBAAqB,kBAAkB;EAC3C,oBAAoB,UAAU,QAAQ,CAAC;EACvC,aAAa,oBAAoB,UAAU,QAAQ,CAAC;CACtD,GAAG,CAAC,CAAC;CAGL,sBACQ,8BAA8B,GACpC,CAAC,2BAA2B,CAC9B;CAEA,MAAM,MAAM,OAAuB,IAAI;CACvC,MAAM,EAAE,WAAW,OAAO,UAAU,YAAY,YAAY,aAC1D,QAAQ,KAAK,SAAS;CACxB,MAAM,gBAAgB,MAAM;CAE5B,MAAM,kBAAkB,4BAA4BA,kBAAS,UAAU;CAEvE,MAAM,gBAAgB,KACpBC,4BAAO,cACP,YAAYA,4BAAO,QACnB,cAAcA,4BAAO,UACrB,SACF;CAEA,MAAM,eAAe,EACnB,WAAW,aAAa,UAAU,EAAE,MAAM,UAAU,EAAE,YAAY,UAAU,MAAM,GACpF;CAGA,MAAM,iBACJ,YAAY,QACR;EAAE,GAAG,YAAY,WAAW,KAAK;EAAG,OAAO;EAAQ,QAAQ;CAAO,IAClE,KAAA;CAIN,MAAM,cACJ,oBAAC,OAAD;EAAgB;EACd,UAAA,oBAAC,OAAD,EAAM,SAAc,CAAA;CACjB,CAAA;CAGP,MAAM,OACJ,qBAAC,OAAD;EACO;EACL,WAAW;EACX,MAAK;EACL,cAAY,gBAAgB,OAAO,MAAM;EACzC,oBAAkB;EAClB,UAAU;EACV,cAAc,UAAU,MAAM,eAAe;EAC7C,GAAI;EARN,UAAA;GAUE,oBAAC,OAAD;IACE,WAAW,KAAKA,4BAAO,SAAS,cAAcA,4BAAO,QAAQ;IAC7D,OAAO;IAEN;GACE,CAAA;GACL,oBAAC,QAAD;IAAM,WAAWA,4BAAO;IAAW,OAAO;GAAiB,CAAA;GAC3D,oBAAC,QAAD;IAAM,IAAI;IAAe,QAAA;IACtB,UAAA,gBAAgB,OAAO,iBAAiB;GACrC,CAAA;EACH;;CAGP,OACE,oBAAC,mBAAD;EAAmB,OAAO;EACvB,UAAA,YAAY,OAAO;CACH,CAAA;AAEvB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
/* */
|
|
3
|
+
// src/components/LightBox/components/LightBoxZoom/LightBoxZoom.module.scss
|
|
4
|
+
var lightBoxZoom = "flow--light-box--light-box-zoom";
|
|
5
|
+
var content = "flow--light-box--light-box-zoom--content";
|
|
6
|
+
var animated = "flow--light-box--light-box-zoom--animated";
|
|
7
|
+
var focusRing = "flow--light-box--light-box-zoom--focus-ring";
|
|
8
|
+
var zoomed = "flow--light-box--light-box-zoom--zoomed";
|
|
9
|
+
var dragging = "flow--light-box--light-box-zoom--dragging";
|
|
10
|
+
var LightBoxZoom_module_default = {
|
|
11
|
+
lightBoxZoom,
|
|
12
|
+
content,
|
|
13
|
+
animated,
|
|
14
|
+
focusRing,
|
|
15
|
+
zoomed,
|
|
16
|
+
dragging
|
|
17
|
+
};
|
|
18
|
+
export { animated, content, LightBoxZoom_module_default as default, dragging, focusRing, lightBoxZoom, zoomed };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=LightBoxZoom.module.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LightBoxZoom.module.mjs","names":[],"sources":["../../../../../../../../../src/components/LightBox/components/LightBoxZoom/LightBoxZoom.module.scss"],"sourcesContent":[".lightBoxZoom {\n /* Pinch and pan are the zoom's own; the browser's would zoom the page. */\n touch-action: none;\n user-select: none;\n cursor: zoom-in;\n position: relative;\n isolation: isolate;\n outline: none;\n\n /* Elements */\n\n /* Below the focus ring: the transform makes it a stacking context, which\n would paint over the inset outline. */\n .content {\n position: relative;\n z-index: -1;\n transform-origin: center;\n\n &.animated {\n transition: transform var(--transition--duration--default) ease-out;\n }\n }\n\n /* The focus mixin's visible state, on an element of its own: it follows\n what is on screen while zoomed (positioned inline), and sits inside it,\n as the screen's edge would cut off a ring outside. */\n .focusRing {\n position: absolute;\n inset: 0;\n pointer-events: none;\n outline: var(--focus--outline-color) none var(--focus--outline-width);\n outline-offset: calc(var(--size-px--xs) * -1);\n }\n\n &:focus-visible .focusRing {\n outline-style: solid;\n box-shadow: 0 0 0 var(--focus--outline-width)\n var(--focus--secondary-outline-color);\n }\n\n /* States */\n\n &.zoomed {\n cursor: grab;\n }\n\n &.dragging {\n cursor: grabbing;\n }\n}\n"],"mappings":""}
|