@opensite/ui 3.0.6 → 3.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -509,7 +509,7 @@ pnpm type-check
509
509
 
510
510
  ## License
511
511
 
512
- BSD 3-Claus
512
+ BSD 3-Clause
513
513
 
514
514
  ## Related Packages
515
515
 
@@ -0,0 +1,33 @@
1
+ 'use strict';
2
+
3
+ var AspectRatioPrimitive = require('@radix-ui/react-aspect-ratio');
4
+ var jsxRuntime = require('react/jsx-runtime');
5
+
6
+ function _interopNamespace(e) {
7
+ if (e && e.__esModule) return e;
8
+ var n = Object.create(null);
9
+ if (e) {
10
+ Object.keys(e).forEach(function (k) {
11
+ if (k !== 'default') {
12
+ var d = Object.getOwnPropertyDescriptor(e, k);
13
+ Object.defineProperty(n, k, d.get ? d : {
14
+ enumerable: true,
15
+ get: function () { return e[k]; }
16
+ });
17
+ }
18
+ });
19
+ }
20
+ n.default = e;
21
+ return Object.freeze(n);
22
+ }
23
+
24
+ var AspectRatioPrimitive__namespace = /*#__PURE__*/_interopNamespace(AspectRatioPrimitive);
25
+
26
+ // components/ui/aspect-ratio.tsx
27
+ function AspectRatio({
28
+ ...props
29
+ }) {
30
+ return /* @__PURE__ */ jsxRuntime.jsx(AspectRatioPrimitive__namespace.Root, { "data-slot": "aspect-ratio", ...props });
31
+ }
32
+
33
+ exports.AspectRatio = AspectRatio;
@@ -0,0 +1,6 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as AspectRatioPrimitive from '@radix-ui/react-aspect-ratio';
3
+
4
+ declare function AspectRatio({ ...props }: React.ComponentProps<typeof AspectRatioPrimitive.Root>): react_jsx_runtime.JSX.Element;
5
+
6
+ export { AspectRatio };
@@ -0,0 +1,6 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as AspectRatioPrimitive from '@radix-ui/react-aspect-ratio';
3
+
4
+ declare function AspectRatio({ ...props }: React.ComponentProps<typeof AspectRatioPrimitive.Root>): react_jsx_runtime.JSX.Element;
5
+
6
+ export { AspectRatio };
@@ -0,0 +1,11 @@
1
+ import * as AspectRatioPrimitive from '@radix-ui/react-aspect-ratio';
2
+ import { jsx } from 'react/jsx-runtime';
3
+
4
+ // components/ui/aspect-ratio.tsx
5
+ function AspectRatio({
6
+ ...props
7
+ }) {
8
+ return /* @__PURE__ */ jsx(AspectRatioPrimitive.Root, { "data-slot": "aspect-ratio", ...props });
9
+ }
10
+
11
+ export { AspectRatio };
@@ -9,6 +9,7 @@ var framerMotion = require('framer-motion');
9
9
  var useOnClickOutside = require('@opensite/hooks/useOnClickOutside');
10
10
  var react = require('motion/react');
11
11
  var img = require('@page-speed/img');
12
+ var AspectRatioPrimitive = require('@radix-ui/react-aspect-ratio');
12
13
  var reactSlot = require('@radix-ui/react-slot');
13
14
  var pressable = require('@page-speed/pressable');
14
15
  var classVarianceAuthority = require('class-variance-authority');
@@ -37,6 +38,7 @@ function _interopNamespace(e) {
37
38
  }
38
39
 
39
40
  var React4__namespace = /*#__PURE__*/_interopNamespace(React4);
41
+ var AspectRatioPrimitive__namespace = /*#__PURE__*/_interopNamespace(AspectRatioPrimitive);
40
42
  var PopoverPrimitive__namespace = /*#__PURE__*/_interopNamespace(PopoverPrimitive);
41
43
  var TabsPrimitive__namespace = /*#__PURE__*/_interopNamespace(TabsPrimitive);
42
44
 
@@ -917,6 +919,174 @@ var ImageSlider = ({
917
919
  }
918
920
  );
919
921
  };
922
+ function AspectRatio({
923
+ ...props
924
+ }) {
925
+ return /* @__PURE__ */ jsxRuntime.jsx(AspectRatioPrimitive__namespace.Root, { "data-slot": "aspect-ratio", ...props });
926
+ }
927
+ var DEFAULT_DEVICE_ASPECT_RATIOS = {
928
+ desktop: "square",
929
+ mobile: "square"
930
+ };
931
+ var DEFAULT_MEDIA_CLASS_NAME = "size-full object-cover";
932
+ var DEFAULT_FRAME_CLASS_NAME = "overflow-hidden";
933
+ var DEFAULT_BREAKPOINT = "lg";
934
+ var BREAKPOINT_VISIBILITY_CLASSES = {
935
+ sm: {
936
+ desktop: "hidden sm:block",
937
+ mobile: "sm:hidden"
938
+ },
939
+ md: {
940
+ desktop: "hidden md:block",
941
+ mobile: "md:hidden"
942
+ },
943
+ lg: {
944
+ desktop: "hidden lg:block",
945
+ mobile: "lg:hidden"
946
+ },
947
+ xl: {
948
+ desktop: "hidden xl:block",
949
+ mobile: "xl:hidden"
950
+ },
951
+ "2xl": {
952
+ desktop: "hidden 2xl:block",
953
+ mobile: "2xl:hidden"
954
+ }
955
+ };
956
+ var MEDIA_ASPECT_RATIOS = {
957
+ square: 1,
958
+ horizontal: 16 / 9,
959
+ vertical: 355 / 520
960
+ };
961
+ function resolveAspectRatio(ratio, fallback) {
962
+ const resolvedRatio = ratio ?? fallback;
963
+ if (typeof resolvedRatio === "number" && Number.isFinite(resolvedRatio) && resolvedRatio > 0) {
964
+ return resolvedRatio;
965
+ }
966
+ return MEDIA_ASPECT_RATIOS[resolvedRatio];
967
+ }
968
+ function hasRenderableMedia(mediaItem) {
969
+ return Boolean(mediaItem?.image?.src || mediaItem?.video?.src);
970
+ }
971
+ function renderMediaElement({
972
+ mediaItem,
973
+ optixFlowConfig,
974
+ mediaClassName,
975
+ imageClassName,
976
+ videoClassName
977
+ }) {
978
+ if (!hasRenderableMedia(mediaItem)) {
979
+ return null;
980
+ }
981
+ if (mediaItem.video?.src) {
982
+ const { className: inlineVideoClassName, poster, ...videoProps } = mediaItem.video;
983
+ const posterFallback = poster ?? (typeof mediaItem.image?.src === "string" ? mediaItem.image.src : void 0);
984
+ return /* @__PURE__ */ jsxRuntime.jsx(
985
+ "video",
986
+ {
987
+ ...videoProps,
988
+ poster: posterFallback,
989
+ className: cn(
990
+ DEFAULT_MEDIA_CLASS_NAME,
991
+ mediaClassName,
992
+ videoClassName,
993
+ inlineVideoClassName
994
+ )
995
+ }
996
+ );
997
+ }
998
+ if (mediaItem.image?.src) {
999
+ const { className: inlineImageClassName, alt, src, ...imageProps } = mediaItem.image;
1000
+ return /* @__PURE__ */ jsxRuntime.jsx(
1001
+ img.Img,
1002
+ {
1003
+ ...imageProps,
1004
+ src,
1005
+ alt: alt ?? "",
1006
+ className: cn(
1007
+ DEFAULT_MEDIA_CLASS_NAME,
1008
+ mediaClassName,
1009
+ imageClassName,
1010
+ inlineImageClassName
1011
+ ),
1012
+ optixFlowConfig
1013
+ }
1014
+ );
1015
+ }
1016
+ return null;
1017
+ }
1018
+ function MediaAspectRatio({
1019
+ containerClassName,
1020
+ mobileClassName,
1021
+ desktopClassName,
1022
+ frameClassName,
1023
+ mobileFrameClassName,
1024
+ desktopFrameClassName,
1025
+ mediaClassName,
1026
+ imageClassName,
1027
+ videoClassName,
1028
+ mediaItem,
1029
+ optixFlowConfig,
1030
+ deviceAspectRatios = DEFAULT_DEVICE_ASPECT_RATIOS,
1031
+ breakpoint = DEFAULT_BREAKPOINT
1032
+ }) {
1033
+ if (!hasRenderableMedia(mediaItem)) {
1034
+ return null;
1035
+ }
1036
+ const ratios = {
1037
+ desktop: resolveAspectRatio(
1038
+ deviceAspectRatios.desktop,
1039
+ DEFAULT_DEVICE_ASPECT_RATIOS.desktop
1040
+ ),
1041
+ mobile: resolveAspectRatio(
1042
+ deviceAspectRatios.mobile,
1043
+ DEFAULT_DEVICE_ASPECT_RATIOS.mobile
1044
+ )
1045
+ };
1046
+ const sharedFrameClassName = cn(
1047
+ DEFAULT_FRAME_CLASS_NAME,
1048
+ frameClassName,
1049
+ mediaItem.containerClassName
1050
+ );
1051
+ const visibilityClasses = BREAKPOINT_VISIBILITY_CLASSES[breakpoint];
1052
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: containerClassName, "data-slot": "media-aspect-ratio", children: [
1053
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("relative", visibilityClasses.mobile, mobileClassName), children: /* @__PURE__ */ jsxRuntime.jsx(
1054
+ AspectRatio,
1055
+ {
1056
+ ratio: ratios.mobile,
1057
+ className: cn(sharedFrameClassName, mobileFrameClassName),
1058
+ children: renderMediaElement({
1059
+ mediaItem,
1060
+ optixFlowConfig,
1061
+ mediaClassName,
1062
+ imageClassName,
1063
+ videoClassName
1064
+ })
1065
+ }
1066
+ ) }),
1067
+ /* @__PURE__ */ jsxRuntime.jsx(
1068
+ "div",
1069
+ {
1070
+ className: cn(visibilityClasses.desktop, desktopClassName),
1071
+ style: { aspectRatio: String(ratios.desktop) },
1072
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1073
+ "div",
1074
+ {
1075
+ className: cn("size-full", sharedFrameClassName, desktopFrameClassName),
1076
+ "data-slot": "media-aspect-ratio-frame",
1077
+ children: renderMediaElement({
1078
+ mediaItem,
1079
+ optixFlowConfig,
1080
+ mediaClassName,
1081
+ imageClassName,
1082
+ videoClassName
1083
+ })
1084
+ }
1085
+ )
1086
+ }
1087
+ )
1088
+ ] });
1089
+ }
920
1090
  function Button({
921
1091
  className,
922
1092
  variant = "default",
@@ -6649,6 +6819,7 @@ exports.FooterSimpleCentered = FooterSimpleCentered;
6649
6819
  exports.FooterSocialApps = FooterSocialApps;
6650
6820
  exports.FooterSocialNewsletter = FooterSocialNewsletter;
6651
6821
  exports.ImageSlider = ImageSlider;
6822
+ exports.MediaAspectRatio = MediaAspectRatio;
6652
6823
  exports.MediaHoverCtas = MediaHoverCtas;
6653
6824
  exports.PageHeroBanner = PageHeroBanner;
6654
6825
  exports.PaymentPlatformIcon = PaymentPlatformIcon;
@@ -3,6 +3,7 @@ export { Section } from './section.cjs';
3
3
  export { AnimatedDialog } from './animated-dialog.cjs';
4
4
  export { PageHeroBanner } from './page-hero-banner.cjs';
5
5
  export { ImageSlider } from './image-slider.cjs';
6
+ export { MediaAspectRatio, MediaAspectRatioBreakpoint, MediaAspectRatioProps, MediaAspectRatioVariant, ResponsiveMediaAspectRatioProps } from './media-aspect-ratio.cjs';
6
7
  export { Button } from './button.cjs';
7
8
  export { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from './card.cjs';
8
9
  export { Badge } from './badge.cjs';
@@ -3,6 +3,7 @@ export { Section } from './section.js';
3
3
  export { AnimatedDialog } from './animated-dialog.js';
4
4
  export { PageHeroBanner } from './page-hero-banner.js';
5
5
  export { ImageSlider } from './image-slider.js';
6
+ export { MediaAspectRatio, MediaAspectRatioBreakpoint, MediaAspectRatioProps, MediaAspectRatioVariant, ResponsiveMediaAspectRatioProps } from './media-aspect-ratio.js';
6
7
  export { Button } from './button.js';
7
8
  export { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from './card.js';
8
9
  export { Badge } from './badge.js';
@@ -8,6 +8,7 @@ import { AnimatePresence, motion } from 'framer-motion';
8
8
  import { useOnClickOutside } from '@opensite/hooks/useOnClickOutside';
9
9
  import { AnimatePresence as AnimatePresence$1, motion as motion$1 } from 'motion/react';
10
10
  import { Img } from '@page-speed/img';
11
+ import * as AspectRatioPrimitive from '@radix-ui/react-aspect-ratio';
11
12
  import { Slot } from '@radix-ui/react-slot';
12
13
  import { Pressable, buttonVariants } from '@page-speed/pressable';
13
14
  export { Pressable } from '@page-speed/pressable';
@@ -895,6 +896,174 @@ var ImageSlider = ({
895
896
  }
896
897
  );
897
898
  };
899
+ function AspectRatio({
900
+ ...props
901
+ }) {
902
+ return /* @__PURE__ */ jsx(AspectRatioPrimitive.Root, { "data-slot": "aspect-ratio", ...props });
903
+ }
904
+ var DEFAULT_DEVICE_ASPECT_RATIOS = {
905
+ desktop: "square",
906
+ mobile: "square"
907
+ };
908
+ var DEFAULT_MEDIA_CLASS_NAME = "size-full object-cover";
909
+ var DEFAULT_FRAME_CLASS_NAME = "overflow-hidden";
910
+ var DEFAULT_BREAKPOINT = "lg";
911
+ var BREAKPOINT_VISIBILITY_CLASSES = {
912
+ sm: {
913
+ desktop: "hidden sm:block",
914
+ mobile: "sm:hidden"
915
+ },
916
+ md: {
917
+ desktop: "hidden md:block",
918
+ mobile: "md:hidden"
919
+ },
920
+ lg: {
921
+ desktop: "hidden lg:block",
922
+ mobile: "lg:hidden"
923
+ },
924
+ xl: {
925
+ desktop: "hidden xl:block",
926
+ mobile: "xl:hidden"
927
+ },
928
+ "2xl": {
929
+ desktop: "hidden 2xl:block",
930
+ mobile: "2xl:hidden"
931
+ }
932
+ };
933
+ var MEDIA_ASPECT_RATIOS = {
934
+ square: 1,
935
+ horizontal: 16 / 9,
936
+ vertical: 355 / 520
937
+ };
938
+ function resolveAspectRatio(ratio, fallback) {
939
+ const resolvedRatio = ratio ?? fallback;
940
+ if (typeof resolvedRatio === "number" && Number.isFinite(resolvedRatio) && resolvedRatio > 0) {
941
+ return resolvedRatio;
942
+ }
943
+ return MEDIA_ASPECT_RATIOS[resolvedRatio];
944
+ }
945
+ function hasRenderableMedia(mediaItem) {
946
+ return Boolean(mediaItem?.image?.src || mediaItem?.video?.src);
947
+ }
948
+ function renderMediaElement({
949
+ mediaItem,
950
+ optixFlowConfig,
951
+ mediaClassName,
952
+ imageClassName,
953
+ videoClassName
954
+ }) {
955
+ if (!hasRenderableMedia(mediaItem)) {
956
+ return null;
957
+ }
958
+ if (mediaItem.video?.src) {
959
+ const { className: inlineVideoClassName, poster, ...videoProps } = mediaItem.video;
960
+ const posterFallback = poster ?? (typeof mediaItem.image?.src === "string" ? mediaItem.image.src : void 0);
961
+ return /* @__PURE__ */ jsx(
962
+ "video",
963
+ {
964
+ ...videoProps,
965
+ poster: posterFallback,
966
+ className: cn(
967
+ DEFAULT_MEDIA_CLASS_NAME,
968
+ mediaClassName,
969
+ videoClassName,
970
+ inlineVideoClassName
971
+ )
972
+ }
973
+ );
974
+ }
975
+ if (mediaItem.image?.src) {
976
+ const { className: inlineImageClassName, alt, src, ...imageProps } = mediaItem.image;
977
+ return /* @__PURE__ */ jsx(
978
+ Img,
979
+ {
980
+ ...imageProps,
981
+ src,
982
+ alt: alt ?? "",
983
+ className: cn(
984
+ DEFAULT_MEDIA_CLASS_NAME,
985
+ mediaClassName,
986
+ imageClassName,
987
+ inlineImageClassName
988
+ ),
989
+ optixFlowConfig
990
+ }
991
+ );
992
+ }
993
+ return null;
994
+ }
995
+ function MediaAspectRatio({
996
+ containerClassName,
997
+ mobileClassName,
998
+ desktopClassName,
999
+ frameClassName,
1000
+ mobileFrameClassName,
1001
+ desktopFrameClassName,
1002
+ mediaClassName,
1003
+ imageClassName,
1004
+ videoClassName,
1005
+ mediaItem,
1006
+ optixFlowConfig,
1007
+ deviceAspectRatios = DEFAULT_DEVICE_ASPECT_RATIOS,
1008
+ breakpoint = DEFAULT_BREAKPOINT
1009
+ }) {
1010
+ if (!hasRenderableMedia(mediaItem)) {
1011
+ return null;
1012
+ }
1013
+ const ratios = {
1014
+ desktop: resolveAspectRatio(
1015
+ deviceAspectRatios.desktop,
1016
+ DEFAULT_DEVICE_ASPECT_RATIOS.desktop
1017
+ ),
1018
+ mobile: resolveAspectRatio(
1019
+ deviceAspectRatios.mobile,
1020
+ DEFAULT_DEVICE_ASPECT_RATIOS.mobile
1021
+ )
1022
+ };
1023
+ const sharedFrameClassName = cn(
1024
+ DEFAULT_FRAME_CLASS_NAME,
1025
+ frameClassName,
1026
+ mediaItem.containerClassName
1027
+ );
1028
+ const visibilityClasses = BREAKPOINT_VISIBILITY_CLASSES[breakpoint];
1029
+ return /* @__PURE__ */ jsxs("div", { className: containerClassName, "data-slot": "media-aspect-ratio", children: [
1030
+ /* @__PURE__ */ jsx("div", { className: cn("relative", visibilityClasses.mobile, mobileClassName), children: /* @__PURE__ */ jsx(
1031
+ AspectRatio,
1032
+ {
1033
+ ratio: ratios.mobile,
1034
+ className: cn(sharedFrameClassName, mobileFrameClassName),
1035
+ children: renderMediaElement({
1036
+ mediaItem,
1037
+ optixFlowConfig,
1038
+ mediaClassName,
1039
+ imageClassName,
1040
+ videoClassName
1041
+ })
1042
+ }
1043
+ ) }),
1044
+ /* @__PURE__ */ jsx(
1045
+ "div",
1046
+ {
1047
+ className: cn(visibilityClasses.desktop, desktopClassName),
1048
+ style: { aspectRatio: String(ratios.desktop) },
1049
+ children: /* @__PURE__ */ jsx(
1050
+ "div",
1051
+ {
1052
+ className: cn("size-full", sharedFrameClassName, desktopFrameClassName),
1053
+ "data-slot": "media-aspect-ratio-frame",
1054
+ children: renderMediaElement({
1055
+ mediaItem,
1056
+ optixFlowConfig,
1057
+ mediaClassName,
1058
+ imageClassName,
1059
+ videoClassName
1060
+ })
1061
+ }
1062
+ )
1063
+ }
1064
+ )
1065
+ ] });
1066
+ }
898
1067
  function Button({
899
1068
  className,
900
1069
  variant = "default",
@@ -6581,4 +6750,4 @@ function FooterNavSocial({
6581
6750
  );
6582
6751
  }
6583
6752
 
6584
- export { AboutCultureTabs, AboutExpandableValues, AboutMissionPrinciples, AboutSplitHero, AlternatingBlocks, AnimatedDialog, Badge, BannerAnnouncementDismissible, BannerCountdownSale, BannerDeliveryCountdown, BannerEventPromo, BannerFloatingOffer, BannerGdprRights, BannerPrivacyNotice, BannerPromoCta, BannerSocialFollow, BannerSurveyIncentive, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, CarouselPagination, CommunityInitiatives, Container, DynamicIcon, FooterAnimatedSocial, FooterBackgroundCard, FooterBrandDescription, FooterContactCard, FooterCtaBanner, FooterCtaSocial, FooterLinksGrid, FooterNavSocial, FooterNewsletterGrid, FooterNewsletterMinimal, FooterSimpleCentered, FooterSocialApps, FooterSocialNewsletter, ImageSlider, MediaHoverCtas, PageHeroBanner, PaymentPlatformIcon, Popover, PopoverContent, PopoverTrigger, Section, SocialLinkIcon, StarRating };
6753
+ export { AboutCultureTabs, AboutExpandableValues, AboutMissionPrinciples, AboutSplitHero, AlternatingBlocks, AnimatedDialog, Badge, BannerAnnouncementDismissible, BannerCountdownSale, BannerDeliveryCountdown, BannerEventPromo, BannerFloatingOffer, BannerGdprRights, BannerPrivacyNotice, BannerPromoCta, BannerSocialFollow, BannerSurveyIncentive, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, CarouselPagination, CommunityInitiatives, Container, DynamicIcon, FooterAnimatedSocial, FooterBackgroundCard, FooterBrandDescription, FooterContactCard, FooterCtaBanner, FooterCtaSocial, FooterLinksGrid, FooterNavSocial, FooterNewsletterGrid, FooterNewsletterMinimal, FooterSimpleCentered, FooterSocialApps, FooterSocialNewsletter, ImageSlider, MediaAspectRatio, MediaHoverCtas, PageHeroBanner, PaymentPlatformIcon, Popover, PopoverContent, PopoverTrigger, Section, SocialLinkIcon, StarRating };