@plexui/ui 0.59.4 → 0.60.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"StatsCard.js","sourceRoot":"","sources":["../../../../src/components/StatsCard/StatsCard.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAA4B,MAAM,OAAO,CAAA;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAChC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,CAAC,MAAM,0DAA0D,CAAA;AAiExE,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,EACxB,KAAK,EACL,KAAK,EACL,WAAW,EACX,KAAK,EACL,WAAW,EACX,IAAI,EACJ,SAAS,EACT,QAAQ,EACR,aAAa,EACb,OAAO,EACP,aAAa,GAAG,OAAO,EACvB,YAAY,GAAG,MAAM,EACrB,IAAI,GAAG,SAAS,EAChB,OAAO,GAAG,SAAS,EACnB,WAAW,GAAG,SAAS,EACvB,SAAS,EACT,GAAG,EACH,GAAG,SAAS,EACG,EAAE,EAAE;IACnB,MAAM,UAAU,GAAG,KAAK,EAAE,KAAK,IAAI,CAAC,CAAA;IACpC,MAAM,cAAc,GAClB,UAAU,KAAK,CAAC;QACd,CAAC,CAAC,CAAC,CAAC,YAAY;QAChB,CAAC,CAAC,UAAU,GAAG,CAAC;YACd,CAAC,CAAC,WAAW;gBACX,CAAC,CAAC,CAAC,CAAC,aAAa;gBACjB,CAAC,CAAC,CAAC,CAAC,aAAa;YACnB,CAAC,CAAC,WAAW;gBACX,CAAC,CAAC,CAAC,CAAC,aAAa;gBACjB,CAAC,CAAC,CAAC,CAAC,aAAa,CAAA;IAEzB,MAAM,SAAS,GAAG,GAA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AA;IAE7F,MAAM,UAAU,GAAG,CAAC,aAAa,KAAK,SAAS,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC,CAClE,eAAK,SAAS,EAAE,CAAC,CAAC,QAAQ,aACxB,cAAK,SAAS,EAAE,CAAC,CAAC,aAAa,YAC7B,cACE,SAAS,EAAE,CAAC,CAAC,WAAW,EACxB,KAAK,EAAE,EAAE,KAAK,EAAE,GAAG,aAAa,IAAI,CAAC,GAAG,EAAE,wBAE1C,GACE,EACL,aAAa,IAAI,cAAK,SAAS,EAAE,CAAC,CAAC,aAAa,YAAG,aAAa,GAAO,IACpE,CACP,CAAC,CAAC,CAAC,IAAI,CAAA;IAER,MAAM,WAAW,GAAG,SAAS,CAAC,CAAC,CAAC,cAAK,SAAS,EAAE,CAAC,CAAC,SAAS,YAAG,SAAS,GAAO,CAAC,CAAC,CAAC,IAAI,CAAA;IAErF,OAAO,CACL,eACE,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,kBACzB,OAAO,eACV,IAAI,uBACI,WAAW,KAC1B,SAAS,aAEZ,QAAQ,EACR,UAAU,EACV,UAAU,EACV,aAAa,EACb,UAAU,EACV,WAAW,IACR,CACP,CAAA;AACH,CAAC,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { type ReactNode, type Ref } from \"react\"\nimport { Badge } from \"../Badge\"\nimport { InfoCircle, Trending } from \"../Icon\"\nimport { Tooltip } from \"../Tooltip\"\nimport s from \"@plexui/styles/components/StatsCard/StatsCard.module.css\"\n\nexport type StatsCardProps = {\n /** Label describing the metric */\n label: string\n /** The primary metric value (e.g. \"1,234\" or \"$50K\") */\n value: ReactNode\n /** Optional description or subtitle below the value */\n description?: string\n /** Trend indicator with percentage change */\n trend?: {\n /** The percentage change value (e.g. 12.5 for +12.5%) */\n value: number\n /** Optional label for the trend (e.g. \"vs last month\") */\n label?: string\n }\n /** When true, a positive trend is bad (red) and negative is good (green). Use for metrics like \"Error Rate\" or \"Avg Completion Time\". */\n invertTrend?: boolean\n /** Icon in a small tile with a soft background, at the end of the header */\n icon?: ReactNode\n /** Optional ReactNode for a sparkline/chart rendered at the bottom */\n sparkline?: ReactNode\n /** Progress value from 0 to 100. Shows a progress bar at the bottom. */\n progress?: number\n /** Label displayed after the progress bar */\n progressLabel?: string\n /** Tooltip text — renders an (i) icon next to the label with a tooltip on hover */\n tooltip?: string\n /**\n * Where the trend indicator is positioned\n * - `\"value\"` — under the value, with its label (default)\n * - `\"header\"` — right-aligned in the header row, its label under the value\n * @default \"value\"\n */\n trendPosition?: \"value\" | \"header\"\n /**\n * Visual style of the trend indicator\n * - `\"text\"` — plain colored text (default)\n * - `\"badge\"` — wrapped in a Badge component\n * @default \"text\"\n */\n trendVariant?: \"text\" | \"badge\"\n /**\n * Size of the card\n * - `\"default\"` — standard dashboard card\n * - `\"sm\"` — compact card for dense layouts\n * @default \"default\"\n */\n size?: \"default\" | \"sm\"\n /**\n * Visual variant of the card\n * @default \"default\"\n */\n variant?: \"default\" | \"accent\"\n /**\n * Color of the accent variant's bar\n * @default \"primary\"\n */\n accentColor?: \"primary\" | \"secondary\" | \"info\" | \"success\" | \"warning\" | \"danger\" | \"discovery\" | \"caution\"\n /** Class applied to the card container */\n className?: string\n /** Ref applied to the card container */\n ref?: Ref<HTMLDivElement>\n}\n\nexport const StatsCard = ({\n label,\n value,\n description,\n trend,\n invertTrend,\n icon,\n sparkline,\n progress,\n progressLabel,\n tooltip,\n trendPosition = \"value\",\n trendVariant = \"text\",\n size = \"default\",\n variant = \"default\",\n accentColor = \"primary\",\n className,\n ref,\n ...restProps\n}: StatsCardProps) => {\n const trendValue = trend?.value ?? 0\n const trendClassName =\n trendValue === 0\n ? s.TrendNeutral\n : trendValue > 0\n ? invertTrend\n ? s.TrendNegative\n : s.TrendPositive\n : invertTrend\n ? s.TrendPositive\n : s.TrendNegative\n\n const trendText = `${trendValue > 0 ? \"+\" : \"\"}${trendValue}%`\n const progressValue =\n progress === undefined ? undefined : Math.min(100, Math.max(0, progress))\n\n const trendBadgeColor =\n trendValue === 0\n ? \"secondary\"\n : trendValue > 0\n ? invertTrend\n ? \"danger\"\n : \"success\"\n : invertTrend\n ? \"success\"\n : \"danger\"\n\n // A trend line points the way the value moved, whichever colour that is (shadcn's metric cards draw lucide's\n // trending-up and trending-down); a fall is the rise mirrored\n const trendContent = (\n <>\n {trendValue !== 0 && <Trending className={trendValue < 0 ? s.TrendDown : undefined} />}\n {trendText}\n </>\n )\n\n const trendEl = trend != null && (\n trendVariant === \"badge\" ? (\n <Badge size=\"sm\" color={trendBadgeColor as \"secondary\" | \"success\" | \"danger\"}>\n {trendContent}\n </Badge>\n ) : (\n <div className={clsx(s.Trend, trendClassName)}>\n {trendContent}\n </div>\n )\n )\n\n // The icon's tile stands at the end of the header, as the trend may (shadcn's metric card with an icon)\n const iconEl = icon ? <div className={s.IconWrapper}>{icon}</div> : null\n const headerTrendEl = trendPosition === \"header\" ? trendEl : null\n\n const headerEl = (\n <div className={s.Header}>\n <div className={s.LabelRow}>\n <div className={s.Label}>{label}</div>\n {tooltip && (\n <Tooltip content={tooltip}>\n {/* Focusable and named so keyboard and screen-reader users reach the tooltip */}\n <span className={s.InfoIcon} tabIndex={0} role=\"img\" aria-label=\"More information\">\n <InfoCircle />\n </span>\n </Tooltip>\n )}\n </div>\n {(headerTrendEl || iconEl) && (\n <div className={s.HeaderEnd}>\n {headerTrendEl}\n {iconEl}\n </div>\n )}\n </div>\n )\n\n const valueRowEl = (\n <div className={s.ValueRow}>\n <div className={s.Value}>{value}</div>\n </div>\n )\n\n // Under the value, a trend and what it compares with, on one line (shadcn's metric card with a trend); a trend in\n // the header leaves its label there\n const trendRowEl = trend != null && (trendPosition === \"value\" || trend.label) ? (\n <div className={s.TrendRow}>\n {trendPosition === \"value\" && trendEl}\n {trend.label && <span className={s.TrendLabel}>{trend.label}</span>}\n </div>\n ) : null\n\n const descriptionEl = description ? <div className={s.Description}>{description}</div> : null\n\n const progressEl = (progressValue !== undefined || progressLabel) ? (\n <div className={s.Progress}>\n <div className={s.ProgressTrack}>\n <div\n className={s.ProgressBar}\n style={{ width: `${progressValue ?? 0}%` }}\n aria-hidden\n />\n </div>\n {progressLabel && <div className={s.ProgressLabel}>{progressLabel}</div>}\n </div>\n ) : null\n\n const sparklineEl = sparkline ? <div className={s.Sparkline}>{sparkline}</div> : null\n\n return (\n <div\n ref={ref}\n className={clsx(s.StatsCard, className)}\n data-variant={variant}\n data-size={size}\n data-accent-color={accentColor}\n {...restProps}\n >\n {headerEl}\n {valueRowEl}\n {trendRowEl}\n {descriptionEl}\n {progressEl}\n {sparklineEl}\n </div>\n )\n}\n"]}
1
+ {"version":3,"file":"StatsCard.js","sourceRoot":"","sources":["../../../../src/components/StatsCard/StatsCard.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAA4B,eAAe,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AACzE,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAChC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,CAAC,MAAM,0DAA0D,CAAA;AAiExE,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,EACxB,KAAK,EACL,KAAK,EACL,WAAW,EACX,KAAK,EACL,WAAW,EACX,IAAI,EACJ,SAAS,EACT,QAAQ,EACR,aAAa,EACb,OAAO,EACP,aAAa,GAAG,OAAO,EACvB,YAAY,GAAG,MAAM,EACrB,IAAI,GAAG,SAAS,EAChB,OAAO,GAAG,SAAS,EACnB,WAAW,GAAG,SAAS,EACvB,SAAS,EACT,GAAG,EACH,GAAG,SAAS,EACG,EAAE,EAAE;IAC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F,OAAO,CACL,eACE,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,kBACzB,OAAO,eACV,IAAI,uBACI,WAAW,KAC1B,SAAS,aAEZ,QAAQ,EACR,UAAU,EACV,UAAU,EACV,aAAa,EACb,UAAU,EACV,WAAW,IACR,CACP,CAAA;AACH,CAAC,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { type ReactNode, type Ref, useLayoutEffect, useRef } from \"react\"\nimport { Badge } from \"../Badge\"\nimport { InfoCircle, Trending } from \"../Icon\"\nimport { Tooltip } from \"../Tooltip\"\nimport { fitValueScale } from \"../../lib/fitValueScale\"\nimport s from \"@plexui/styles/components/StatsCard/StatsCard.module.css\"\n\nexport type StatsCardProps = {\n /** Label describing the metric */\n label: string\n /** The primary metric value (e.g. \"1,234\" or \"$50K\") */\n value: ReactNode\n /** Optional description or subtitle below the value */\n description?: string\n /** Trend indicator with percentage change */\n trend?: {\n /** The percentage change value (e.g. 12.5 for +12.5%) */\n value: number\n /** Optional label for the trend (e.g. \"vs last month\") */\n label?: string\n }\n /** When true, a positive trend is bad (red) and negative is good (green). Use for metrics like \"Error Rate\" or \"Avg Completion Time\". */\n invertTrend?: boolean\n /** Icon in a small tile with a soft background, at the end of the header */\n icon?: ReactNode\n /** Optional ReactNode for a sparkline/chart rendered at the bottom */\n sparkline?: ReactNode\n /** Progress value from 0 to 100. Shows a progress bar at the bottom. */\n progress?: number\n /** Label displayed after the progress bar */\n progressLabel?: string\n /** Tooltip text — renders an (i) icon next to the label with a tooltip on hover */\n tooltip?: string\n /**\n * Where the trend indicator is positioned\n * - `\"value\"` — under the value, with its label (default)\n * - `\"header\"` — right-aligned in the header row, its label under the value\n * @default \"value\"\n */\n trendPosition?: \"value\" | \"header\"\n /**\n * Visual style of the trend indicator\n * - `\"text\"` — plain colored text (default)\n * - `\"badge\"` — wrapped in a Badge component\n * @default \"text\"\n */\n trendVariant?: \"text\" | \"badge\"\n /**\n * Size of the card\n * - `\"default\"` — standard dashboard card\n * - `\"sm\"` — compact card for dense layouts\n * @default \"default\"\n */\n size?: \"default\" | \"sm\"\n /**\n * Visual variant of the card\n * @default \"default\"\n */\n variant?: \"default\" | \"accent\"\n /**\n * Color of the accent variant's bar\n * @default \"primary\"\n */\n accentColor?: \"primary\" | \"secondary\" | \"info\" | \"success\" | \"warning\" | \"danger\" | \"discovery\" | \"caution\"\n /** Class applied to the card container */\n className?: string\n /** Ref applied to the card container */\n ref?: Ref<HTMLDivElement>\n}\n\nexport const StatsCard = ({\n label,\n value,\n description,\n trend,\n invertTrend,\n icon,\n sparkline,\n progress,\n progressLabel,\n tooltip,\n trendPosition = \"value\",\n trendVariant = \"text\",\n size = \"default\",\n variant = \"default\",\n accentColor = \"primary\",\n className,\n ref,\n ...restProps\n}: StatsCardProps) => {\n // A value wider than the card (two cards a row on a phone) scales down to fit, as iOS's minimumScaleFactor\n const valueRef = useRef<HTMLDivElement>(null)\n useLayoutEffect(() => (valueRef.current ? fitValueScale(valueRef.current, \"--stats-card-value-scale\") : undefined), [])\n const trendValue = trend?.value ?? 0\n const trendClassName =\n trendValue === 0\n ? s.TrendNeutral\n : trendValue > 0\n ? invertTrend\n ? s.TrendNegative\n : s.TrendPositive\n : invertTrend\n ? s.TrendPositive\n : s.TrendNegative\n\n const trendText = `${trendValue > 0 ? \"+\" : \"\"}${trendValue}%`\n const progressValue =\n progress === undefined ? undefined : Math.min(100, Math.max(0, progress))\n\n const trendBadgeColor =\n trendValue === 0\n ? \"secondary\"\n : trendValue > 0\n ? invertTrend\n ? \"danger\"\n : \"success\"\n : invertTrend\n ? \"success\"\n : \"danger\"\n\n // A trend line points the way the value moved, whichever colour that is (shadcn's metric cards draw lucide's\n // trending-up and trending-down); a fall is the rise mirrored\n const trendContent = (\n <>\n {trendValue !== 0 && <Trending className={trendValue < 0 ? s.TrendDown : undefined} />}\n {trendText}\n </>\n )\n\n const trendEl = trend != null && (\n trendVariant === \"badge\" ? (\n <Badge size=\"sm\" color={trendBadgeColor as \"secondary\" | \"success\" | \"danger\"}>\n {trendContent}\n </Badge>\n ) : (\n <div className={clsx(s.Trend, trendClassName)}>\n {trendContent}\n </div>\n )\n )\n\n // The icon's tile stands at the end of the header, as the trend may (shadcn's metric card with an icon)\n const iconEl = icon ? <div className={s.IconWrapper}>{icon}</div> : null\n const headerTrendEl = trendPosition === \"header\" ? trendEl : null\n\n const headerEl = (\n <div className={s.Header}>\n <div className={s.LabelRow}>\n <div className={s.Label}>{label}</div>\n {tooltip && (\n <Tooltip content={tooltip}>\n {/* Focusable and named so keyboard and screen-reader users reach the tooltip */}\n <span className={s.InfoIcon} tabIndex={0} role=\"img\" aria-label=\"More information\">\n <InfoCircle />\n </span>\n </Tooltip>\n )}\n </div>\n {(headerTrendEl || iconEl) && (\n <div className={s.HeaderEnd}>\n {headerTrendEl}\n {iconEl}\n </div>\n )}\n </div>\n )\n\n const valueRowEl = (\n <div className={s.ValueRow}>\n <div ref={valueRef} className={s.Value}>{value}</div>\n </div>\n )\n\n // Under the value, a trend and what it compares with, on one line (shadcn's metric card with a trend); a trend in\n // the header leaves its label there\n const trendRowEl = trend != null && (trendPosition === \"value\" || trend.label) ? (\n <div className={s.TrendRow}>\n {trendPosition === \"value\" && trendEl}\n {trend.label && <span className={s.TrendLabel}>{trend.label}</span>}\n </div>\n ) : null\n\n const descriptionEl = description ? <div className={s.Description}>{description}</div> : null\n\n const progressEl = (progressValue !== undefined || progressLabel) ? (\n <div className={s.Progress}>\n <div className={s.ProgressTrack}>\n <div\n className={s.ProgressBar}\n style={{ width: `${progressValue ?? 0}%` }}\n aria-hidden\n />\n </div>\n {progressLabel && <div className={s.ProgressLabel}>{progressLabel}</div>}\n </div>\n ) : null\n\n const sparklineEl = sparkline ? <div className={s.Sparkline}>{sparkline}</div> : null\n\n return (\n <div\n ref={ref}\n className={clsx(s.StatsCard, className)}\n data-variant={variant}\n data-size={size}\n data-accent-color={accentColor}\n {...restProps}\n >\n {headerEl}\n {valueRowEl}\n {trendRowEl}\n {descriptionEl}\n {progressEl}\n {sparklineEl}\n </div>\n )\n}\n"]}
@@ -87,7 +87,7 @@ const TransitionGroupChildInner = ({ ref: forwardedRef, as: TagName, children, c
87
87
  enterTimeout = window.setTimeout(() => {
88
88
  dispatch({ type: "done" });
89
89
  triggerCallback("enter-complete");
90
- }, overlay && prefersReducedMotion() ? 0 : enterDurationRef.current);
90
+ }, enterDurationRef.current);
91
91
  });
92
92
  return () => {
93
93
  cancelAnimationFrame();
@@ -122,7 +122,7 @@ const TransitionGroupChild = (props) => {
122
122
  return mounted ? _jsx(TransitionGroupChildInner, { ...props }) : null;
123
123
  };
124
124
  export const TransitionGroup = (props) => {
125
- const { ref: forwardedRef, as: TagName = "span", children, className, transitionId, style, enterDuration = 0, exitDuration = 0, preventInitialTransition = true, enterMountDelay, insertMethod = "append", disableAnimations = getDisableAnimations(), overlay, } = props;
125
+ const { ref: forwardedRef, as: TagName = "span", children, className, transitionId, style, enterDuration = 0, reducedMotionEnterDuration, exitDuration = 0, preventInitialTransition = true, enterMountDelay, insertMethod = "append", disableAnimations = getDisableAnimations(), overlay, } = props;
126
126
  // Create stable, mutable references for all callbacks
127
127
  const onEnter = useChildCallback(props.onEnter ?? noop);
128
128
  const onEnterActive = useChildCallback(props.onEnterActive ?? noop);
@@ -174,6 +174,6 @@ export const TransitionGroup = (props) => {
174
174
  // @ts-expect-error -- TS is not happy about this forwardedRef, but it's fine.
175
175
  ref: forwardedRef, className: className, style: style, "data-transition-id": transitionId, children: child }))) }));
176
176
  }
177
- return (_jsx(_Fragment, { children: renderChildren.map(({ component, ...restProps }) => (_jsx(TransitionGroupChild, { ...restProps, as: TagName, className: className, transitionId: transitionId, enterDuration: enterDuration, exitDuration: exitDuration, enterMountDelay: enterMountDelay, overlay: overlay, style: style, ref: forwardedRef, children: component }, component.key))) }));
177
+ return (_jsx(_Fragment, { children: renderChildren.map(({ component, ...restProps }) => (_jsx(TransitionGroupChild, { ...restProps, as: TagName, className: className, transitionId: transitionId, enterDuration: reducedMotionEnterDuration !== undefined && prefersReducedMotion() ? reducedMotionEnterDuration : enterDuration, exitDuration: exitDuration, enterMountDelay: enterMountDelay, overlay: overlay, style: style, ref: forwardedRef, children: component }, component.key))) }));
178
178
  };
179
179
  //# sourceMappingURL=TransitionGroup.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TransitionGroup.js","sourceRoot":"","sources":["../../../../src/components/Transition/TransitionGroup.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,KAAK,EAAE,EACZ,QAAQ,EACR,WAAW,EACX,SAAS,EACT,eAAe,EACf,UAAU,EACV,MAAM,EACN,QAAQ,GAET,MAAM,OAAO,CAAA;AACd,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAE5C,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAE/E,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,oBAAoB,MAAM,wBAAwB,CAAA;AACzD,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,yBAAyB,EACzB,IAAI,EACJ,gBAAgB,GAIjB,MAAM,UAAU,CAAA;AACjB,OAAO,CAAC,MAAM,iEAAiE,CAAA;AAC/E,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAkBlF,MAAM,yBAAyB,GAAG,CAAC,EACjC,GAAG,EAAE,YAAY,EACjB,EAAE,EAAE,OAAO,EACX,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,KAAK,EACL,sBAAsB,EACtB,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,OAAO,EACP,WAAW,EACX,OAAO,EACP,aAAa,EACb,eAAe,EACf,MAAM,EACN,YAAY,EACZ,cAAc,GACY,EAAE,EAAE;IAC9B,MAA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AAc,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,EAAE,EAAE,CAAC,CACnD,KAAC,oBAAoB,OAEf,SAAS,EACb,EAAE,EAAE,OAAO,EACX,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,YAAY,EAC1B,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,YAAY,EAC1B,eAAe,EAAE,eAAe,EAChC,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,YAAY,YAEhB,SAAS,IAZL,SAAS,CAAC,GAAG,CAaG,CACxB,CAAC,GACD,CACJ,CAAA;AACH,CAAC,CAAA","sourcesContent":["\"use client\"\n\nimport React, {\n Children,\n useCallback,\n useEffect,\n useLayoutEffect,\n useReducer,\n useRef,\n useState,\n type CSSProperties,\n} from \"react\"\nimport { mergeRefs } from \"react-merge-refs\"\n\nimport { prefersReducedMotion, waitForAnimationFrame } from \"../../lib/helpers\"\n\nimport clsx from \"clsx\"\nimport { useTimeout } from \"usehooks-ts\"\nimport getDisableAnimations from \"./getDisableAnimations\"\nimport {\n assertSingleChildWhenRef,\n ChildrenWithKeys,\n computeNextRenderChildren,\n noop,\n useChildCallback,\n type CallbackType,\n type ReactElementWithKey,\n type TransitionGroupChildCallbacks,\n} from \"./shared\"\nimport s from \"@plexui/styles/components/Transition/TransitionGroup.module.css\"\nimport { getInitialTransitionState, transitionReducer } from \"./transitionReducer\"\n\ntype TransitionGroupChildProps = {\n as: \"div\" | \"span\"\n children: React.ReactNode\n className?: string\n transitionId?: string\n style?: CSSProperties\n preventMountTransition?: boolean\n shouldRender: boolean\n enterDuration: number\n exitDuration: number\n enterMountDelay?: number\n overlay?: boolean\n removeChild: () => void\n ref?: React.Ref<unknown>\n} & TransitionGroupChildCallbacks\n\nconst TransitionGroupChildInner = ({\n ref: forwardedRef,\n as: TagName,\n children,\n className,\n transitionId,\n style,\n preventMountTransition,\n shouldRender,\n enterDuration,\n exitDuration,\n overlay,\n removeChild,\n onEnter,\n onEnterActive,\n onEnterComplete,\n onExit,\n onExitActive,\n onExitComplete,\n}: TransitionGroupChildProps) => {\n const [state, dispatch] = useReducer(\n transitionReducer,\n getInitialTransitionState(preventMountTransition || false),\n )\n // Allow a child to prevent mount transition, but still experience\n // future enter transition events, when applicable.\n const preventedMountTransition = useRef<boolean>(false)\n const elementRef = useRef<HTMLDivElement | null>(null)\n // Duration values should not affect hook re-renders, so we create refs for them\n const enterDurationRef = useRef<number>(enterDuration)\n enterDurationRef.current = enterDuration\n const exitDurationRef = useRef<number>(exitDuration)\n exitDurationRef.current = exitDuration\n\n const lastCallbackRef = useRef<CallbackType>(null)\n const triggerCallback = useCallback(\n (callbackType: CallbackType) => {\n const element = elementRef.current\n\n if (!element || callbackType === lastCallbackRef.current) {\n return\n }\n\n lastCallbackRef.current = callbackType\n\n switch (callbackType) {\n case \"enter\":\n onEnter(element)\n break\n case \"enter-active\":\n onEnterActive(element)\n break\n case \"enter-complete\":\n onEnterComplete(element)\n break\n case \"exit\":\n onExit(element)\n break\n case \"exit-active\":\n onExitActive(element)\n break\n case \"exit-complete\":\n onExitComplete(element)\n break\n default:\n callbackType satisfies never\n break\n }\n },\n [onEnter, onEnterActive, onEnterComplete, onExit, onExitActive, onExitComplete],\n )\n\n React.useLayoutEffect(() => {\n // Exit transition\n if (!shouldRender) {\n let exitTimeout: number | undefined\n\n dispatch({ type: \"exit-before\" })\n triggerCallback(\"exit\")\n\n const cancelAnimationFrame = waitForAnimationFrame(() => {\n dispatch({ type: \"exit-active\" })\n triggerCallback(\"exit-active\")\n\n exitTimeout = window.setTimeout(\n () => {\n triggerCallback(\"exit-complete\")\n removeChild()\n },\n overlay && prefersReducedMotion() ? 0 : exitDurationRef.current,\n )\n })\n\n return () => {\n cancelAnimationFrame()\n if (exitTimeout !== undefined) clearTimeout(exitTimeout)\n }\n }\n\n // Enter transition\n\n // Check if we need to prevent this specific entering cycle\n if (preventMountTransition && !preventedMountTransition.current) {\n // Mark initial transition as prevented and short-circuit.\n preventedMountTransition.current = true\n return\n }\n\n let enterTimeout: number | undefined\n\n dispatch({ type: \"enter-before\" })\n triggerCallback(\"enter\")\n\n const cancelAnimationFrame = waitForAnimationFrame(() => {\n dispatch({ type: \"enter-active\" })\n triggerCallback(\"enter-active\")\n\n enterTimeout = window.setTimeout(() => {\n dispatch({ type: \"done\" })\n triggerCallback(\"enter-complete\")\n }, overlay && prefersReducedMotion() ? 0 : enterDurationRef.current)\n })\n\n return () => {\n cancelAnimationFrame()\n if (enterTimeout !== undefined) clearTimeout(enterTimeout)\n }\n }, [\n shouldRender,\n // This value is immutable after <TransitionGroup> is created, and does not change on re-renders.\n preventMountTransition,\n overlay,\n removeChild,\n triggerCallback,\n ])\n\n useEffect(() => {\n // Required for <StrictMode>, because we need to unset this token\n // when the hooks are re-run. It's an imperative effect that we need to manage.\n return () => {\n preventedMountTransition.current = false\n }\n }, [])\n\n return (\n <TagName\n ref={mergeRefs([elementRef, forwardedRef])}\n className={clsx(className, s.TransitionGroupChild)}\n data-transition-id={transitionId}\n style={style}\n data-entering={state.enter ? \"\" : undefined}\n data-entering-active={state.enterActive ? \"\" : undefined}\n data-exiting={state.exit ? \"\" : undefined}\n data-exiting-active={state.exitActive ? \"\" : undefined}\n data-interrupted={state.interrupted ? \"\" : undefined}\n inert={overlay && state.exit ? true : undefined}\n >\n {children}\n </TagName>\n )\n}\n\nconst TransitionGroupChild = (props: TransitionGroupChildProps) => {\n // Don't spread these out of props - pass all props to inner child\n const { enterMountDelay, preventMountTransition } = props\n // Mount gating occurs when enterMountDelay exists, and isn't initial mount\n // Otherwise, this flag is a no-op and the TransitionChild mounts normally.\n const mountDelay = !preventMountTransition && enterMountDelay != null ? enterMountDelay : null\n const [mounted, setMounted] = useState(mountDelay == null)\n useTimeout(() => setMounted(true), mounted ? null : mountDelay)\n\n return mounted ? <TransitionGroupChildInner {...props} /> : null\n}\n\nexport type TransitionGroupProps = {\n /** Components controlled by TransitionGroup rendering */\n children: React.ReactNode\n /** Determines the tag used by wrapping elements */\n as?: \"div\" | \"span\"\n /** Class passed to wrapping elements */\n className?: string\n /** Identifier passed to wrapping elements as `[data-transition-id]` */\n transitionId?: string\n /** Determines the amount of time that the enter state is applied during mounting */\n enterDuration?: number\n /** Determines the amount of time that the exit state is applied before unmounting */\n exitDuration?: number\n /**\n * Determines if children should have an enter transition applied during mounting of the TransitionGroup.\n * @default true\n */\n preventInitialTransition?: boolean\n /** Delay in MS to wait before mounting a child. `null` for no delay (default). */\n enterMountDelay?: number\n /** Render children changes immediately, bypassing transition timings */\n disableAnimations?: boolean\n /**\n * For overlays: an exiting child is `inert`, out of the tab order and of hit\n * testing, and with reduced motion it settles and leaves without waiting for\n * `enterDuration` or `exitDuration` (nothing moves, so nothing is held).\n */\n overlay?: boolean\n /** Determines how new children are added to the children array */\n insertMethod?: \"append\" | \"prepend\"\n /** Styles applied to wrapping elements */\n style?: CSSProperties\n /** Ref for the TransitionGroup */\n ref?: React.Ref<unknown>\n} & Partial<TransitionGroupChildCallbacks>\n\ntype RenderChild = {\n component: ReactElementWithKey\n shouldRender: boolean\n preventMountTransition?: boolean\n removeChild: () => void\n} & TransitionGroupChildCallbacks\n\nexport const TransitionGroup = (props: TransitionGroupProps) => {\n const {\n ref: forwardedRef,\n as: TagName = \"span\",\n children,\n className,\n transitionId,\n style,\n enterDuration = 0,\n exitDuration = 0,\n preventInitialTransition = true,\n enterMountDelay,\n insertMethod = \"append\",\n disableAnimations = getDisableAnimations(),\n overlay,\n } = props\n // Create stable, mutable references for all callbacks\n const onEnter = useChildCallback(props.onEnter ?? noop)\n const onEnterActive = useChildCallback(props.onEnterActive ?? noop)\n const onEnterComplete = useChildCallback(props.onEnterComplete ?? noop)\n const onExit = useChildCallback(props.onExit ?? noop)\n const onExitActive = useChildCallback(props.onExitActive ?? noop)\n const onExitComplete = useChildCallback(props.onExitComplete ?? noop)\n\n // Ensure all children are provided with keys.\n // Cannot reliably use Children.toArray() because `key` is processed: https://reactjs.org/docs/react-api.html#reactchildrentoarray\n Children.forEach(children, (child) => {\n // @ts-expect-error - We know `key` might not exist on certain types, that's why we're checking\n if (child && !child.key) {\n throw new Error(\"Child elements of <TransitionGroup /> must include a `key`\")\n }\n })\n\n const createDefaultRenderChildProps = useCallback(\n (child: ReactElementWithKey): RenderChild => ({\n component: child,\n shouldRender: true,\n removeChild: () => {\n setRenderChildren((currentRenderChildren) =>\n currentRenderChildren.filter((c) => child.key !== c.component.key),\n )\n },\n onEnter,\n onEnterActive,\n onEnterComplete,\n onExit,\n onExitActive,\n onExitComplete,\n }),\n [onEnter, onEnterActive, onEnterComplete, onExit, onExitActive, onExitComplete],\n )\n\n const [renderChildren, setRenderChildren] = useState<RenderChild[]>((): RenderChild[] => {\n return ChildrenWithKeys(children).map((child) => ({\n ...createDefaultRenderChildProps(child),\n // Lock this value to whatever the value was on initial render of the TransitionGroup.\n // It doesn't make sense to change this once it is mounted.\n preventMountTransition: preventInitialTransition,\n }))\n })\n\n useLayoutEffect(() => {\n setRenderChildren((currentRenderChildren): RenderChild[] => {\n const propChildrenArray = ChildrenWithKeys(children)\n return computeNextRenderChildren(\n propChildrenArray,\n currentRenderChildren,\n createDefaultRenderChildProps,\n insertMethod,\n )\n })\n }, [children, insertMethod, createDefaultRenderChildProps])\n\n // Prevent mistakes with forwardRef() by ensuring single child usage within the group.\n assertSingleChildWhenRef(\"TransitionGroup\", forwardedRef, Children.count(children))\n\n if (disableAnimations) {\n return (\n <>\n {Children.map(children, (child) => (\n <TagName\n // @ts-expect-error -- TS is not happy about this forwardedRef, but it's fine.\n ref={forwardedRef}\n className={className}\n style={style}\n data-transition-id={transitionId}\n >\n {child}\n </TagName>\n ))}\n </>\n )\n }\n\n return (\n <>\n {renderChildren.map(({ component, ...restProps }) => (\n <TransitionGroupChild\n key={component.key}\n {...restProps}\n as={TagName}\n className={className}\n transitionId={transitionId}\n enterDuration={enterDuration}\n exitDuration={exitDuration}\n enterMountDelay={enterMountDelay}\n overlay={overlay}\n style={style}\n ref={forwardedRef}\n >\n {component}\n </TransitionGroupChild>\n ))}\n </>\n )\n}\n"]}
1
+ {"version":3,"file":"TransitionGroup.js","sourceRoot":"","sources":["../../../../src/components/Transition/TransitionGroup.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,KAAK,EAAE,EACZ,QAAQ,EACR,WAAW,EACX,SAAS,EACT,eAAe,EACf,UAAU,EACV,MAAM,EACN,QAAQ,GAET,MAAM,OAAO,CAAA;AACd,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAE5C,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAE/E,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,oBAAoB,MAAM,wBAAwB,CAAA;AACzD,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,yBAAyB,EACzB,IAAI,EACJ,gBAAgB,GAIjB,MAAM,UAAU,CAAA;AACjB,OAAO,CAAC,MAAM,iEAAiE,CAAA;AAC/E,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAkBlF,MAAM,yBAAyB,GAAG,CAAC,EACjC,GAAG,EAAE,YAAY,EACjB,EAAE,EAAE,OAAO,EACX,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,KAAK,EACL,sBAAsB,EACtB,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,OAAO,EACP,WAAW,EACX,OAAO,EACP,aAAa,EACb,eAAe,EACf,MAAM,EACN,YAAY,EACZ,cAAc,GACY,EAAE,EAAE;IAC9B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,UAAU,CAClC,iBAAiB,EACjB,yBAAyB,CAAC,sBAAsB,IAAI,KAAK,CAAC,CAC3D,CAAA;IACD,kEAAkE;IAClE,mDAAmD;IACnD,MAAM,w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AAK,SAAS,IAAI,oBAAoB,EAAE,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC,CAAC,aAAa,EAEjH,YAAY,EAAE,YAAY,EAC1B,eAAe,EAAE,eAAe,EAChC,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,YAAY,YAEhB,SAAS,IAdL,SAAS,CAAC,GAAG,CAeG,CACxB,CAAC,GACD,CACJ,CAAA;AACH,CAAC,CAAA","sourcesContent":["\"use client\"\n\nimport React, {\n Children,\n useCallback,\n useEffect,\n useLayoutEffect,\n useReducer,\n useRef,\n useState,\n type CSSProperties,\n} from \"react\"\nimport { mergeRefs } from \"react-merge-refs\"\n\nimport { prefersReducedMotion, waitForAnimationFrame } from \"../../lib/helpers\"\n\nimport clsx from \"clsx\"\nimport { useTimeout } from \"usehooks-ts\"\nimport getDisableAnimations from \"./getDisableAnimations\"\nimport {\n assertSingleChildWhenRef,\n ChildrenWithKeys,\n computeNextRenderChildren,\n noop,\n useChildCallback,\n type CallbackType,\n type ReactElementWithKey,\n type TransitionGroupChildCallbacks,\n} from \"./shared\"\nimport s from \"@plexui/styles/components/Transition/TransitionGroup.module.css\"\nimport { getInitialTransitionState, transitionReducer } from \"./transitionReducer\"\n\ntype TransitionGroupChildProps = {\n as: \"div\" | \"span\"\n children: React.ReactNode\n className?: string\n transitionId?: string\n style?: CSSProperties\n preventMountTransition?: boolean\n shouldRender: boolean\n enterDuration: number\n exitDuration: number\n enterMountDelay?: number\n overlay?: boolean\n removeChild: () => void\n ref?: React.Ref<unknown>\n} & TransitionGroupChildCallbacks\n\nconst TransitionGroupChildInner = ({\n ref: forwardedRef,\n as: TagName,\n children,\n className,\n transitionId,\n style,\n preventMountTransition,\n shouldRender,\n enterDuration,\n exitDuration,\n overlay,\n removeChild,\n onEnter,\n onEnterActive,\n onEnterComplete,\n onExit,\n onExitActive,\n onExitComplete,\n}: TransitionGroupChildProps) => {\n const [state, dispatch] = useReducer(\n transitionReducer,\n getInitialTransitionState(preventMountTransition || false),\n )\n // Allow a child to prevent mount transition, but still experience\n // future enter transition events, when applicable.\n const preventedMountTransition = useRef<boolean>(false)\n const elementRef = useRef<HTMLDivElement | null>(null)\n // Duration values should not affect hook re-renders, so we create refs for them\n const enterDurationRef = useRef<number>(enterDuration)\n enterDurationRef.current = enterDuration\n const exitDurationRef = useRef<number>(exitDuration)\n exitDurationRef.current = exitDuration\n\n const lastCallbackRef = useRef<CallbackType>(null)\n const triggerCallback = useCallback(\n (callbackType: CallbackType) => {\n const element = elementRef.current\n\n if (!element || callbackType === lastCallbackRef.current) {\n return\n }\n\n lastCallbackRef.current = callbackType\n\n switch (callbackType) {\n case \"enter\":\n onEnter(element)\n break\n case \"enter-active\":\n onEnterActive(element)\n break\n case \"enter-complete\":\n onEnterComplete(element)\n break\n case \"exit\":\n onExit(element)\n break\n case \"exit-active\":\n onExitActive(element)\n break\n case \"exit-complete\":\n onExitComplete(element)\n break\n default:\n callbackType satisfies never\n break\n }\n },\n [onEnter, onEnterActive, onEnterComplete, onExit, onExitActive, onExitComplete],\n )\n\n React.useLayoutEffect(() => {\n // Exit transition\n if (!shouldRender) {\n let exitTimeout: number | undefined\n\n dispatch({ type: \"exit-before\" })\n triggerCallback(\"exit\")\n\n const cancelAnimationFrame = waitForAnimationFrame(() => {\n dispatch({ type: \"exit-active\" })\n triggerCallback(\"exit-active\")\n\n exitTimeout = window.setTimeout(\n () => {\n triggerCallback(\"exit-complete\")\n removeChild()\n },\n overlay && prefersReducedMotion() ? 0 : exitDurationRef.current,\n )\n })\n\n return () => {\n cancelAnimationFrame()\n if (exitTimeout !== undefined) clearTimeout(exitTimeout)\n }\n }\n\n // Enter transition\n\n // Check if we need to prevent this specific entering cycle\n if (preventMountTransition && !preventedMountTransition.current) {\n // Mark initial transition as prevented and short-circuit.\n preventedMountTransition.current = true\n return\n }\n\n let enterTimeout: number | undefined\n\n dispatch({ type: \"enter-before\" })\n triggerCallback(\"enter\")\n\n const cancelAnimationFrame = waitForAnimationFrame(() => {\n dispatch({ type: \"enter-active\" })\n triggerCallback(\"enter-active\")\n\n enterTimeout = window.setTimeout(() => {\n dispatch({ type: \"done\" })\n triggerCallback(\"enter-complete\")\n }, enterDurationRef.current)\n })\n\n return () => {\n cancelAnimationFrame()\n if (enterTimeout !== undefined) clearTimeout(enterTimeout)\n }\n }, [\n shouldRender,\n // This value is immutable after <TransitionGroup> is created, and does not change on re-renders.\n preventMountTransition,\n overlay,\n removeChild,\n triggerCallback,\n ])\n\n useEffect(() => {\n // Required for <StrictMode>, because we need to unset this token\n // when the hooks are re-run. It's an imperative effect that we need to manage.\n return () => {\n preventedMountTransition.current = false\n }\n }, [])\n\n return (\n <TagName\n ref={mergeRefs([elementRef, forwardedRef])}\n className={clsx(className, s.TransitionGroupChild)}\n data-transition-id={transitionId}\n style={style}\n data-entering={state.enter ? \"\" : undefined}\n data-entering-active={state.enterActive ? \"\" : undefined}\n data-exiting={state.exit ? \"\" : undefined}\n data-exiting-active={state.exitActive ? \"\" : undefined}\n data-interrupted={state.interrupted ? \"\" : undefined}\n inert={overlay && state.exit ? true : undefined}\n >\n {children}\n </TagName>\n )\n}\n\nconst TransitionGroupChild = (props: TransitionGroupChildProps) => {\n // Don't spread these out of props - pass all props to inner child\n const { enterMountDelay, preventMountTransition } = props\n // Mount gating occurs when enterMountDelay exists, and isn't initial mount\n // Otherwise, this flag is a no-op and the TransitionChild mounts normally.\n const mountDelay = !preventMountTransition && enterMountDelay != null ? enterMountDelay : null\n const [mounted, setMounted] = useState(mountDelay == null)\n useTimeout(() => setMounted(true), mounted ? null : mountDelay)\n\n return mounted ? <TransitionGroupChildInner {...props} /> : null\n}\n\nexport type TransitionGroupProps = {\n /** Components controlled by TransitionGroup rendering */\n children: React.ReactNode\n /** Determines the tag used by wrapping elements */\n as?: \"div\" | \"span\"\n /** Class passed to wrapping elements */\n className?: string\n /** Identifier passed to wrapping elements as `[data-transition-id]` */\n transitionId?: string\n /** Determines the amount of time that the enter state is applied during mounting */\n enterDuration?: number\n /**\n * The enter time with reduced motion, in place of `enterDuration`: for an overlay\n * whose styles fade it in over a time of its own then (a Dialog, a Menu).\n */\n reducedMotionEnterDuration?: number\n /** Determines the amount of time that the exit state is applied before unmounting */\n exitDuration?: number\n /**\n * Determines if children should have an enter transition applied during mounting of the TransitionGroup.\n * @default true\n */\n preventInitialTransition?: boolean\n /** Delay in MS to wait before mounting a child. `null` for no delay (default). */\n enterMountDelay?: number\n /** Render children changes immediately, bypassing transition timings */\n disableAnimations?: boolean\n /**\n * For overlays: an exiting child is `inert`, out of the tab order and of hit\n * testing, and with reduced motion it leaves without waiting for `exitDuration`. It\n * still waits out `enterDuration`: with reduced motion an overlay fades in over it.\n */\n overlay?: boolean\n /** Determines how new children are added to the children array */\n insertMethod?: \"append\" | \"prepend\"\n /** Styles applied to wrapping elements */\n style?: CSSProperties\n /** Ref for the TransitionGroup */\n ref?: React.Ref<unknown>\n} & Partial<TransitionGroupChildCallbacks>\n\ntype RenderChild = {\n component: ReactElementWithKey\n shouldRender: boolean\n preventMountTransition?: boolean\n removeChild: () => void\n} & TransitionGroupChildCallbacks\n\nexport const TransitionGroup = (props: TransitionGroupProps) => {\n const {\n ref: forwardedRef,\n as: TagName = \"span\",\n children,\n className,\n transitionId,\n style,\n enterDuration = 0,\n reducedMotionEnterDuration,\n exitDuration = 0,\n preventInitialTransition = true,\n enterMountDelay,\n insertMethod = \"append\",\n disableAnimations = getDisableAnimations(),\n overlay,\n } = props\n // Create stable, mutable references for all callbacks\n const onEnter = useChildCallback(props.onEnter ?? noop)\n const onEnterActive = useChildCallback(props.onEnterActive ?? noop)\n const onEnterComplete = useChildCallback(props.onEnterComplete ?? noop)\n const onExit = useChildCallback(props.onExit ?? noop)\n const onExitActive = useChildCallback(props.onExitActive ?? noop)\n const onExitComplete = useChildCallback(props.onExitComplete ?? noop)\n\n // Ensure all children are provided with keys.\n // Cannot reliably use Children.toArray() because `key` is processed: https://reactjs.org/docs/react-api.html#reactchildrentoarray\n Children.forEach(children, (child) => {\n // @ts-expect-error - We know `key` might not exist on certain types, that's why we're checking\n if (child && !child.key) {\n throw new Error(\"Child elements of <TransitionGroup /> must include a `key`\")\n }\n })\n\n const createDefaultRenderChildProps = useCallback(\n (child: ReactElementWithKey): RenderChild => ({\n component: child,\n shouldRender: true,\n removeChild: () => {\n setRenderChildren((currentRenderChildren) =>\n currentRenderChildren.filter((c) => child.key !== c.component.key),\n )\n },\n onEnter,\n onEnterActive,\n onEnterComplete,\n onExit,\n onExitActive,\n onExitComplete,\n }),\n [onEnter, onEnterActive, onEnterComplete, onExit, onExitActive, onExitComplete],\n )\n\n const [renderChildren, setRenderChildren] = useState<RenderChild[]>((): RenderChild[] => {\n return ChildrenWithKeys(children).map((child) => ({\n ...createDefaultRenderChildProps(child),\n // Lock this value to whatever the value was on initial render of the TransitionGroup.\n // It doesn't make sense to change this once it is mounted.\n preventMountTransition: preventInitialTransition,\n }))\n })\n\n useLayoutEffect(() => {\n setRenderChildren((currentRenderChildren): RenderChild[] => {\n const propChildrenArray = ChildrenWithKeys(children)\n return computeNextRenderChildren(\n propChildrenArray,\n currentRenderChildren,\n createDefaultRenderChildProps,\n insertMethod,\n )\n })\n }, [children, insertMethod, createDefaultRenderChildProps])\n\n // Prevent mistakes with forwardRef() by ensuring single child usage within the group.\n assertSingleChildWhenRef(\"TransitionGroup\", forwardedRef, Children.count(children))\n\n if (disableAnimations) {\n return (\n <>\n {Children.map(children, (child) => (\n <TagName\n // @ts-expect-error -- TS is not happy about this forwardedRef, but it's fine.\n ref={forwardedRef}\n className={className}\n style={style}\n data-transition-id={transitionId}\n >\n {child}\n </TagName>\n ))}\n </>\n )\n }\n\n return (\n <>\n {renderChildren.map(({ component, ...restProps }) => (\n <TransitionGroupChild\n key={component.key}\n {...restProps}\n as={TagName}\n className={className}\n transitionId={transitionId}\n enterDuration={\n reducedMotionEnterDuration !== undefined && prefersReducedMotion() ? reducedMotionEnterDuration : enterDuration\n }\n exitDuration={exitDuration}\n enterMountDelay={enterMountDelay}\n overlay={overlay}\n style={style}\n ref={forwardedRef}\n >\n {component}\n </TransitionGroupChild>\n ))}\n </>\n )\n}\n"]}
@@ -21,6 +21,12 @@ export const overlayTiming = { enterDuration: 250, exitDuration: 150 };
21
21
  export const overlayTimingLarge = { enterDuration: 300, exitDuration: 200 };
22
22
  /** A submenu: it opens after a hover delay of its own, so it shows at once */
23
23
  export const overlayTimingQuick = { enterDuration: 100, exitDuration: 100 };
24
+ /**
25
+ * With reduced motion a Dialog and a Menu fade in place, as on iOS with Reduce Motion (measured on the iOS 27.2
26
+ * simulator: a sheet about 350 ms, a menu about 500 ms), and stay entering, holding touches, for the whole fade. These
27
+ * match --motion-reduced-enter-dialog and --motion-reduced-enter-menu.
28
+ */
29
+ export const reducedMotionEnter = { dialog: 350, menu: 500 };
24
30
  /**
25
31
  * An overlay stays a dismissable layer through its exit. A press on its trigger
26
32
  * turns it around, and the layer must not count that press as outside and
@@ -1 +1 @@
1
- {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../src/components/Transition/shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAwDnD,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,QAAyB,EAAE,EAAE,CAC3D,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC,CAAA;AAOrF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,QAAyB,EACzB,cAAuB,KAAK,EAC5B,gBAAwB,iBAAiB,EAClB,EAAE;IACzB,MAAM,aAAa,GAA0B,EAAE,CAAA;IAC/C,QAAQ,CAAC,OAAO,CAAC,QAAQ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a,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,GAAG,CAAC;KAC1D,CAAC,CAAC,CAAA;IAEH,OAAO,YAAY,KAAK,QAAQ;QAC9B,CAAC,CAAC,sBAAsB,CAAC,MAAM,CAAC,iBAAiB,CAAC;QAClD,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAA;AACtD,CAAC;AAED,MAAM,UAAU,wBAAwB,CACtC,aAAqB,EACrB,GAAmC,EACnC,aAAqB;IAErB,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,IAAI,GAAG,IAAI,aAAa,GAAG,CAAC,EAAE,CAAC;QAClD,MAAM,IAAI,KAAK,CAAC,oDAAoD,aAAa,KAAK,CAAC,CAAA;IACzF,CAAC;AACH,CAAC","sourcesContent":["import React, { Children, useCallback, useRef } from \"react\"\nimport { isDev, isTest } from \"../../lib/constants\"\n\nexport type TransitionDefinition = {\n opacity?: number\n /** The horizontal translation value in pixels */\n x?: number\n /** The horizontal vertical value in pixels */\n y?: number\n /** The opacity value ranging from 0 to 1. */\n scale?: number\n rotate?: number | string\n skewX?: number | string\n skewY?: number | string\n blur?: number\n duration?: number\n delay?: number\n timingFunction?: string\n}\n\nexport type InitialTransitionDefinition = Omit<\n TransitionDefinition,\n \"duration\" | \"delay\" | \"timingFunction\"\n>\n\nexport type LayoutTransitionDefinition = {\n duration?: number\n delay?: number\n timingFunction?: string\n}\n\nexport type CallbackType =\n | \"enter\"\n | \"enter-active\"\n | \"enter-complete\"\n | \"exit\"\n | \"exit-active\"\n | \"exit-complete\"\n\n// Transition callbacks and types shared across implementations\nexport type TransitionGroupChildCallback = (element: HTMLDivElement) => void\n\nexport type TransitionGroupChildCallbacks = {\n /** Callback fired when an enter animation is staged (e.g., component mounted to the DOM) */\n onEnter: TransitionGroupChildCallback\n /** Callback fired when an enter animation starts */\n onEnterActive: TransitionGroupChildCallback\n /** Callback fired when an enter animation completes */\n onEnterComplete: TransitionGroupChildCallback\n /** Callback fired when an exit animation is staged */\n onExit: TransitionGroupChildCallback\n /** Callback fired when an exit animation starts */\n onExitActive: TransitionGroupChildCallback\n /** Callback fired when an exit animation completes (e.g., component unmounted from the DOM) */\n onExitComplete: TransitionGroupChildCallback\n}\n\nexport const NonNullChildren = (children: React.ReactNode) =>\n Children.toArray(children).filter((child) => child !== null && child !== undefined)\n\n// Shared keyed-children and transition helpers\nexport interface ReactElementWithKey extends React.ReactElement {\n key: string\n}\n\nexport const ChildrenWithKeys = (\n children: React.ReactNode,\n shouldThrow: boolean = false,\n componentName: string = \"TransitionGroup\",\n): ReactElementWithKey[] => {\n const validChildren: ReactElementWithKey[] = []\n Children.forEach(children, (child) => {\n if (child && typeof child === \"object\" && \"key\" in child && !!child.key) {\n // @ts-expect-error -- The above conditional is enough coercion that the component is valid\n validChildren.push(child)\n } else if (shouldThrow) {\n throw new Error(`Child elements of <${componentName} /> must include a \\`key\\``)\n }\n })\n return validChildren\n}\n\nexport const noop = () => {}\n\n// Overlay timers, in step with the `--motion-*` tokens\nexport const overlayTiming = { enterDuration: 250, exitDuration: 150 }\n/** A panel that crosses the screen: a sheet or a side panel */\nexport const overlayTimingLarge = { enterDuration: 300, exitDuration: 200 }\n/** A submenu: it opens after a hover delay of its own, so it shows at once */\nexport const overlayTimingQuick = { enterDuration: 100, exitDuration: 100 }\n\n/**\n * An overlay stays a dismissable layer through its exit. A press on its trigger\n * turns it around, and the layer must not count that press as outside and\n * close it again: pass `transition` to the TransitionGroup and\n * `onInteractOutside` to the layer.\n */\nexport const createExitGuard = () => {\n let exiting = false\n return {\n transition: {\n onExit: () => {\n exiting = true\n },\n onEnterActive: () => {\n exiting = false\n },\n onExitComplete: () => {\n exiting = false\n },\n },\n onInteractOutside: (event: Event) => {\n if (exiting) event.preventDefault()\n },\n }\n}\n\nexport const useChildCallback = (cb: (el: HTMLDivElement) => void) => {\n const ref = useRef(cb)\n ref.current = cb\n return useCallback<(el: HTMLDivElement) => void>((element) => ref.current(element), [])\n}\n\nexport type InsertMethod = \"append\" | \"prepend\"\n\nexport function computeNextRenderChildren<\n RenderChild extends { component: ReactElementWithKey; shouldRender: boolean },\n>(\n propChildrenArray: ReactElementWithKey[],\n currentRenderChildren: RenderChild[],\n createDefaultRenderChildProps: (child: ReactElementWithKey) => RenderChild,\n insertMethod: InsertMethod,\n): RenderChild[] {\n // Sets, not plain objects: a key such as \"constructor\" must not match an\n // inherited Object property\n const propChildKeys = new Set(propChildrenArray.map((child) => child.key))\n const currentRenderChildKeys = new Set(currentRenderChildren.map((child) => child.component.key))\n\n const newRenderChildren: RenderChild[] = propChildrenArray\n .filter((propChild) => !currentRenderChildKeys.has(propChild.key))\n .map(createDefaultRenderChildProps)\n\n const updatedCurrentChildren: RenderChild[] = currentRenderChildren.map((childProps) => ({\n ...childProps,\n component:\n propChildrenArray.find(({ key }) => key === childProps.component.key) || childProps.component,\n shouldRender: propChildKeys.has(childProps.component.key),\n }))\n\n return insertMethod === \"append\"\n ? updatedCurrentChildren.concat(newRenderChildren)\n : newRenderChildren.concat(updatedCurrentChildren)\n}\n\nexport function assertSingleChildWhenRef(\n componentName: string,\n ref: React.Ref<unknown> | undefined,\n childrenCount: number,\n): void {\n if ((isTest || isDev) && ref && childrenCount > 1) {\n throw new Error(`Cannot use forwardRef with multiple children in <${componentName} />`)\n }\n}\n"]}
1
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../src/components/Transition/shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAwDnD,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,QAAyB,EAAE,EAAE,CAC3D,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,IAAI,IAA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AAC;SACjE,GAAG,CAAC,6BAA6B,CAAC,CAAA;IAErC,MAAM,sBAAsB,GAAkB,qBAAqB,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QACvF,GAAG,UAAU;QACb,SAAS,EACP,iBAAiB,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,KAAK,UAAU,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,UAAU,CAAC,SAAS;QAC/F,YAAY,EAAE,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,GAAG,CAAC;KAC1D,CAAC,CAAC,CAAA;IAEH,OAAO,YAAY,KAAK,QAAQ;QAC9B,CAAC,CAAC,sBAAsB,CAAC,MAAM,CAAC,iBAAiB,CAAC;QAClD,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAA;AACtD,CAAC;AAED,MAAM,UAAU,wBAAwB,CACtC,aAAqB,EACrB,GAAmC,EACnC,aAAqB;IAErB,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,IAAI,GAAG,IAAI,aAAa,GAAG,CAAC,EAAE,CAAC;QAClD,MAAM,IAAI,KAAK,CAAC,oDAAoD,aAAa,KAAK,CAAC,CAAA;IACzF,CAAC;AACH,CAAC","sourcesContent":["import React, { Children, useCallback, useRef } from \"react\"\nimport { isDev, isTest } from \"../../lib/constants\"\n\nexport type TransitionDefinition = {\n opacity?: number\n /** The horizontal translation value in pixels */\n x?: number\n /** The horizontal vertical value in pixels */\n y?: number\n /** The opacity value ranging from 0 to 1. */\n scale?: number\n rotate?: number | string\n skewX?: number | string\n skewY?: number | string\n blur?: number\n duration?: number\n delay?: number\n timingFunction?: string\n}\n\nexport type InitialTransitionDefinition = Omit<\n TransitionDefinition,\n \"duration\" | \"delay\" | \"timingFunction\"\n>\n\nexport type LayoutTransitionDefinition = {\n duration?: number\n delay?: number\n timingFunction?: string\n}\n\nexport type CallbackType =\n | \"enter\"\n | \"enter-active\"\n | \"enter-complete\"\n | \"exit\"\n | \"exit-active\"\n | \"exit-complete\"\n\n// Transition callbacks and types shared across implementations\nexport type TransitionGroupChildCallback = (element: HTMLDivElement) => void\n\nexport type TransitionGroupChildCallbacks = {\n /** Callback fired when an enter animation is staged (e.g., component mounted to the DOM) */\n onEnter: TransitionGroupChildCallback\n /** Callback fired when an enter animation starts */\n onEnterActive: TransitionGroupChildCallback\n /** Callback fired when an enter animation completes */\n onEnterComplete: TransitionGroupChildCallback\n /** Callback fired when an exit animation is staged */\n onExit: TransitionGroupChildCallback\n /** Callback fired when an exit animation starts */\n onExitActive: TransitionGroupChildCallback\n /** Callback fired when an exit animation completes (e.g., component unmounted from the DOM) */\n onExitComplete: TransitionGroupChildCallback\n}\n\nexport const NonNullChildren = (children: React.ReactNode) =>\n Children.toArray(children).filter((child) => child !== null && child !== undefined)\n\n// Shared keyed-children and transition helpers\nexport interface ReactElementWithKey extends React.ReactElement {\n key: string\n}\n\nexport const ChildrenWithKeys = (\n children: React.ReactNode,\n shouldThrow: boolean = false,\n componentName: string = \"TransitionGroup\",\n): ReactElementWithKey[] => {\n const validChildren: ReactElementWithKey[] = []\n Children.forEach(children, (child) => {\n if (child && typeof child === \"object\" && \"key\" in child && !!child.key) {\n // @ts-expect-error -- The above conditional is enough coercion that the component is valid\n validChildren.push(child)\n } else if (shouldThrow) {\n throw new Error(`Child elements of <${componentName} /> must include a \\`key\\``)\n }\n })\n return validChildren\n}\n\nexport const noop = () => {}\n\n// Overlay timers, in step with the `--motion-*` tokens\nexport const overlayTiming = { enterDuration: 250, exitDuration: 150 }\n/** A panel that crosses the screen: a sheet or a side panel */\nexport const overlayTimingLarge = { enterDuration: 300, exitDuration: 200 }\n/** A submenu: it opens after a hover delay of its own, so it shows at once */\nexport const overlayTimingQuick = { enterDuration: 100, exitDuration: 100 }\n/**\n * With reduced motion a Dialog and a Menu fade in place, as on iOS with Reduce Motion (measured on the iOS 27.2\n * simulator: a sheet about 350 ms, a menu about 500 ms), and stay entering, holding touches, for the whole fade. These\n * match --motion-reduced-enter-dialog and --motion-reduced-enter-menu.\n */\nexport const reducedMotionEnter = { dialog: 350, menu: 500 }\n\n/**\n * An overlay stays a dismissable layer through its exit. A press on its trigger\n * turns it around, and the layer must not count that press as outside and\n * close it again: pass `transition` to the TransitionGroup and\n * `onInteractOutside` to the layer.\n */\nexport const createExitGuard = () => {\n let exiting = false\n return {\n transition: {\n onExit: () => {\n exiting = true\n },\n onEnterActive: () => {\n exiting = false\n },\n onExitComplete: () => {\n exiting = false\n },\n },\n onInteractOutside: (event: Event) => {\n if (exiting) event.preventDefault()\n },\n }\n}\n\nexport const useChildCallback = (cb: (el: HTMLDivElement) => void) => {\n const ref = useRef(cb)\n ref.current = cb\n return useCallback<(el: HTMLDivElement) => void>((element) => ref.current(element), [])\n}\n\nexport type InsertMethod = \"append\" | \"prepend\"\n\nexport function computeNextRenderChildren<\n RenderChild extends { component: ReactElementWithKey; shouldRender: boolean },\n>(\n propChildrenArray: ReactElementWithKey[],\n currentRenderChildren: RenderChild[],\n createDefaultRenderChildProps: (child: ReactElementWithKey) => RenderChild,\n insertMethod: InsertMethod,\n): RenderChild[] {\n // Sets, not plain objects: a key such as \"constructor\" must not match an\n // inherited Object property\n const propChildKeys = new Set(propChildrenArray.map((child) => child.key))\n const currentRenderChildKeys = new Set(currentRenderChildren.map((child) => child.component.key))\n\n const newRenderChildren: RenderChild[] = propChildrenArray\n .filter((propChild) => !currentRenderChildKeys.has(propChild.key))\n .map(createDefaultRenderChildProps)\n\n const updatedCurrentChildren: RenderChild[] = currentRenderChildren.map((childProps) => ({\n ...childProps,\n component:\n propChildrenArray.find(({ key }) => key === childProps.component.key) || childProps.component,\n shouldRender: propChildKeys.has(childProps.component.key),\n }))\n\n return insertMethod === \"append\"\n ? updatedCurrentChildren.concat(newRenderChildren)\n : newRenderChildren.concat(updatedCurrentChildren)\n}\n\nexport function assertSingleChildWhenRef(\n componentName: string,\n ref: React.Ref<unknown> | undefined,\n childrenCount: number,\n): void {\n if ((isTest || isDev) && ref && childrenCount > 1) {\n throw new Error(`Cannot use forwardRef with multiple children in <${componentName} />`)\n }\n}\n"]}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Scales a one-line value down until it fits the width of its parent, as iOS's `minimumScaleFactor` does: writes
3
+ * `property` on the value as a factor from `min` to 1 (removed at 1), for its CSS to multiply its font size by. It is
4
+ * measured again when the parent or the value resizes, the value's text changes, or the fonts load. Under `min` the
5
+ * value's own CSS cuts it (an ellipsis). Returns the cleanup.
6
+ */
7
+ export function fitValueScale(value, property, min = 0.5) {
8
+ let frame = 0;
9
+ const measure = () => {
10
+ frame = 0;
11
+ const row = value.parentElement;
12
+ if (!row)
13
+ return;
14
+ const current = value.style.getPropertyValue(property);
15
+ // The width the text takes at full size, measured at full size: a width read at a scaled size comes in whole
16
+ // pixels, and a factor from it can step back and forth with each resize it causes
17
+ value.style.removeProperty(property);
18
+ const natural = value.scrollWidth;
19
+ const available = row.clientWidth;
20
+ if (!natural || !available) {
21
+ if (current)
22
+ value.style.setProperty(property, current);
23
+ return;
24
+ }
25
+ // Two decimals, rounded down (1e-9 keeps a float like 98.99999 on its step)
26
+ const next = Math.max(min, Math.min(1, Math.floor((available / natural) * 100 + 1e-9) / 100));
27
+ if (next < 1)
28
+ value.style.setProperty(property, String(next));
29
+ };
30
+ const schedule = () => {
31
+ if (!frame)
32
+ frame = requestAnimationFrame(measure);
33
+ };
34
+ measure();
35
+ const resize = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(schedule);
36
+ if (value.parentElement)
37
+ resize?.observe(value.parentElement);
38
+ resize?.observe(value);
39
+ const mutation = typeof MutationObserver === "undefined" ? null : new MutationObserver(schedule);
40
+ mutation?.observe(value, { childList: true, characterData: true, subtree: true });
41
+ let live = true;
42
+ document.fonts?.ready.then(() => {
43
+ if (live)
44
+ schedule();
45
+ });
46
+ return () => {
47
+ live = false;
48
+ if (frame)
49
+ cancelAnimationFrame(frame);
50
+ resize?.disconnect();
51
+ mutation?.disconnect();
52
+ };
53
+ }
54
+ //# sourceMappingURL=fitValueScale.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fitValueScale.js","sourceRoot":"","sources":["../../../src/lib/fitValueScale.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,KAAkB,EAAE,QAAgB,EAAE,GAAG,GAAG,GAAG;IAC3E,IAAI,KAAK,GAAG,CAAC,CAAA;IACb,MAAM,OAAO,GAAG,GAAG,EAAE;QACnB,KAAK,GAAG,CAAC,CAAA;QACT,MAAM,GAAG,GAAG,KAAK,CAAC,aAAa,CAAA;QAC/B,IAAI,CAAC,GAAG;YAAE,OAAM;QAChB,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAA;QACtD,6GAA6G;QAC7G,kFAAkF;QAClF,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAA;QACpC,MAAM,OAAO,GAAG,KAAK,CAAC,WAAW,CAAA;QACjC,MAAM,SAAS,GAAG,GAAG,CAAC,WAAW,CAAA;QACjC,IAAI,CAAC,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC;YAC3B,IAAI,OAAO;gBAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;YACvD,OAAM;QACR,CAAC;QACD,4EAA4E;QAC5E,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,GAAG,OAAO,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,CAAA;QAC7F,IAAI,IAAI,GAAG,CAAC;YAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;IAC/D,CAAC,CAAA;IACD,MAAM,QAAQ,GAAG,GAAG,EAAE;QACpB,IAAI,CAAC,KAAK;YAAE,KAAK,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAA;IACpD,CAAC,CAAA;IACD,OAAO,EAAE,CAAA;IACT,MAAM,MAAM,GAAG,OAAO,cAAc,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,cAAc,CAAC,QAAQ,CAAC,CAAA;IAC1F,IAAI,KAAK,CAAC,aAAa;QAAE,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;IAC7D,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,CAAA;IACtB,MAAM,QAAQ,GAAG,OAAO,gBAAgB,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,gBAAgB,CAAC,QAAQ,CAAC,CAAA;IAChG,QAAQ,EAAE,OAAO,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAA;IACjF,IAAI,IAAI,GAAG,IAAI,CAAA;IACf,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE;QAC9B,IAAI,IAAI;YAAE,QAAQ,EAAE,CAAA;IACtB,CAAC,CAAC,CAAA;IACF,OAAO,GAAG,EAAE;QACV,IAAI,GAAG,KAAK,CAAA;QACZ,IAAI,KAAK;YAAE,oBAAoB,CAAC,KAAK,CAAC,CAAA;QACtC,MAAM,EAAE,UAAU,EAAE,CAAA;QACpB,QAAQ,EAAE,UAAU,EAAE,CAAA;IACxB,CAAC,CAAA;AACH,CAAC","sourcesContent":["/**\n * Scales a one-line value down until it fits the width of its parent, as iOS's `minimumScaleFactor` does: writes\n * `property` on the value as a factor from `min` to 1 (removed at 1), for its CSS to multiply its font size by. It is\n * measured again when the parent or the value resizes, the value's text changes, or the fonts load. Under `min` the\n * value's own CSS cuts it (an ellipsis). Returns the cleanup.\n */\nexport function fitValueScale(value: HTMLElement, property: string, min = 0.5): () => void {\n let frame = 0\n const measure = () => {\n frame = 0\n const row = value.parentElement\n if (!row) return\n const current = value.style.getPropertyValue(property)\n // The width the text takes at full size, measured at full size: a width read at a scaled size comes in whole\n // pixels, and a factor from it can step back and forth with each resize it causes\n value.style.removeProperty(property)\n const natural = value.scrollWidth\n const available = row.clientWidth\n if (!natural || !available) {\n if (current) value.style.setProperty(property, current)\n return\n }\n // Two decimals, rounded down (1e-9 keeps a float like 98.99999 on its step)\n const next = Math.max(min, Math.min(1, Math.floor((available / natural) * 100 + 1e-9) / 100))\n if (next < 1) value.style.setProperty(property, String(next))\n }\n const schedule = () => {\n if (!frame) frame = requestAnimationFrame(measure)\n }\n measure()\n const resize = typeof ResizeObserver === \"undefined\" ? null : new ResizeObserver(schedule)\n if (value.parentElement) resize?.observe(value.parentElement)\n resize?.observe(value)\n const mutation = typeof MutationObserver === \"undefined\" ? null : new MutationObserver(schedule)\n mutation?.observe(value, { childList: true, characterData: true, subtree: true })\n let live = true\n document.fonts?.ready.then(() => {\n if (live) schedule()\n })\n return () => {\n live = false\n if (frame) cancelAnimationFrame(frame)\n resize?.disconnect()\n mutation?.disconnect()\n }\n}\n"]}
@@ -5,8 +5,19 @@ export type NavigationRowProps = Omit<ButtonHTMLAttributes<HTMLButtonElement | H
5
5
  label: ReactNode;
6
6
  /** The current value, at the end of the row in the secondary label. `0` shows; `null`, `undefined` and `""` do not. */
7
7
  value?: ReactNode;
8
- /** A line under the label; the row grows from 52 to hold it */
8
+ /** A line under the label; the row grows from 52 to hold it. A `<br />` starts a second line. */
9
9
  description?: ReactNode;
10
+ /**
11
+ * What leads the row, such as an `Avatar` or a symbol, in a column before the label (`--navigation-row-leading-size`,
12
+ * its own size), on the label's first line: a shorter text is centred beside it, a longer one starts level with it.
13
+ * The line above the row starts after it, where the text starts (iOS Find My's People list).
14
+ */
15
+ leading?: ReactNode;
16
+ /**
17
+ * The chevron at the end. `false` drops it, for a row that opens a record rather than a page of choices (as the
18
+ * Contacts list of iOS); the row is still one press. @default true
19
+ */
20
+ disclosure?: boolean;
10
21
  /** Where the row goes. With it the row is a link (through `PlexUIProvider`'s `linkComponent`, or `as`). */
11
22
  href?: string;
12
23
  /** Force external-link behavior for `href` */
@@ -1,5 +1,6 @@
1
1
  import { type ComponentProps } from "react";
2
2
  import { Progress as RadixProgress } from "radix-ui";
3
+ export type ProgressSize = "sm" | "md" | "lg";
3
4
  export type ProgressColor = "primary" | "secondary" | "success" | "warning" | "caution" | "danger" | "info" | "discovery";
4
5
  /** A part of a segmented bar: its share of `max`, its color, and the name it is read with. */
5
6
  export type ProgressSegment = {
@@ -25,6 +26,17 @@ export type ProgressProps = Omit<ComponentProps<typeof RadixProgress.Root>, "chi
25
26
  * take `value`'s place. A part's share is clamped so the bar never passes `max`.
26
27
  */
27
28
  segments?: ProgressSegment[];
29
+ /**
30
+ * The bar's thickness: `sm` 4px (iOS's progress view), `md` 6px, `lg` 8px (a bar in a stats card, as Apple Fitness).
31
+ * @default "sm"
32
+ */
33
+ size?: ProgressSize;
34
+ /**
35
+ * The color of the filled part, such as `secondary` (grey) for a second series beside a `primary` one. A segmented
36
+ * bar's parts take their own colors.
37
+ * @default "primary"
38
+ */
39
+ color?: ProgressColor;
28
40
  className?: string;
29
41
  };
30
42
  /** The parts of a segmented bar, each clamped so their sum stays within `max`, and their sum. */
@@ -38,4 +50,4 @@ export declare const progressSegments: (segments: ProgressSegment[], max: number
38
50
  }[];
39
51
  total: number;
40
52
  };
41
- export declare const Progress: ({ value, max, segments, className, ...restProps }: ProgressProps) => import("react/jsx-runtime").JSX.Element;
53
+ export declare const Progress: ({ value, max, segments, size, color, className, ...restProps }: ProgressProps) => import("react/jsx-runtime").JSX.Element;
@@ -1 +1 @@
1
- export { Progress, progressSegments, type ProgressColor, type ProgressProps, type ProgressSegment } from "./Progress.js";
1
+ export { Progress, progressSegments, type ProgressColor, type ProgressProps, type ProgressSegment, type ProgressSize } from "./Progress.js";
@@ -11,6 +11,11 @@ export type TransitionGroupProps = {
11
11
  transitionId?: string;
12
12
  /** Determines the amount of time that the enter state is applied during mounting */
13
13
  enterDuration?: number;
14
+ /**
15
+ * The enter time with reduced motion, in place of `enterDuration`: for an overlay
16
+ * whose styles fade it in over a time of its own then (a Dialog, a Menu).
17
+ */
18
+ reducedMotionEnterDuration?: number;
14
19
  /** Determines the amount of time that the exit state is applied before unmounting */
15
20
  exitDuration?: number;
16
21
  /**
@@ -24,8 +29,8 @@ export type TransitionGroupProps = {
24
29
  disableAnimations?: boolean;
25
30
  /**
26
31
  * For overlays: an exiting child is `inert`, out of the tab order and of hit
27
- * testing, and with reduced motion it settles and leaves without waiting for
28
- * `enterDuration` or `exitDuration` (nothing moves, so nothing is held).
32
+ * testing, and with reduced motion it leaves without waiting for `exitDuration`. It
33
+ * still waits out `enterDuration`: with reduced motion an overlay fades in over it.
29
34
  */
30
35
  overlay?: boolean;
31
36
  /** Determines how new children are added to the children array */
@@ -57,6 +57,15 @@ export declare const overlayTimingQuick: {
57
57
  enterDuration: number;
58
58
  exitDuration: number;
59
59
  };
60
+ /**
61
+ * With reduced motion a Dialog and a Menu fade in place, as on iOS with Reduce Motion (measured on the iOS 27.2
62
+ * simulator: a sheet about 350 ms, a menu about 500 ms), and stay entering, holding touches, for the whole fade. These
63
+ * match --motion-reduced-enter-dialog and --motion-reduced-enter-menu.
64
+ */
65
+ export declare const reducedMotionEnter: {
66
+ dialog: number;
67
+ menu: number;
68
+ };
60
69
  /**
61
70
  * An overlay stays a dismissable layer through its exit. A press on its trigger
62
71
  * turns it around, and the layer must not count that press as outside and
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Scales a one-line value down until it fits the width of its parent, as iOS's `minimumScaleFactor` does: writes
3
+ * `property` on the value as a factor from `min` to 1 (removed at 1), for its CSS to multiply its font size by. It is
4
+ * measured again when the parent or the value resizes, the value's text changes, or the fonts load. Under `min` the
5
+ * value's own CSS cuts it (an ellipsis). Returns the cleanup.
6
+ */
7
+ export declare function fitValueScale(value: HTMLElement, property: string, min?: number): () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plexui/ui",
3
- "version": "0.59.4",
3
+ "version": "0.60.0",
4
4
  "description": "Modern design system for building high-quality applications",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -99,7 +99,7 @@
99
99
  "@maskito/core": "^5.2.2",
100
100
  "@maskito/kit": "^5.2.2",
101
101
  "@maskito/react": "^5.2.2",
102
- "@plexui/styles": "^0.16.2",
102
+ "@plexui/styles": "^0.16.4",
103
103
  "@radix-ui/react-dismissable-layer": "1.2.1",
104
104
  "@radix-ui/react-focus-guards": "1.2.0",
105
105
  "@radix-ui/react-focus-scope": "1.3.1",