@yahoo/uds 3.115.0 → 3.116.0-beta.2
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/automated-config/dist/generated/autoVariants.cjs +10 -0
- package/dist/automated-config/dist/generated/autoVariants.d.cts +10 -0
- package/dist/automated-config/dist/generated/autoVariants.d.ts +10 -0
- package/dist/automated-config/dist/generated/autoVariants.js +10 -0
- package/dist/automated-config/dist/generated/generatedConfigs.cjs +1842 -0
- package/dist/automated-config/dist/generated/generatedConfigs.d.cts +194 -1
- package/dist/automated-config/dist/generated/generatedConfigs.d.ts +194 -1
- package/dist/automated-config/dist/generated/generatedConfigs.js +1842 -1
- package/dist/automated-config/dist/generated/universalTokensConfigAuto.cjs +78 -0
- package/dist/automated-config/dist/generated/universalTokensConfigAuto.d.cts +2 -1
- package/dist/automated-config/dist/generated/universalTokensConfigAuto.d.ts +2 -1
- package/dist/automated-config/dist/generated/universalTokensConfigAuto.js +78 -0
- package/dist/cli/commands/sync.cjs +6 -0
- package/dist/cli/commands/sync.js +6 -0
- package/dist/components/SvgFloatingOverlay.cjs +122 -0
- package/dist/components/SvgFloatingOverlay.d.cts +42 -0
- package/dist/components/SvgFloatingOverlay.d.ts +42 -0
- package/dist/components/SvgFloatingOverlay.js +120 -0
- package/dist/components/client/Menu/Menu.ItemCheckbox.d.cts +1 -1
- package/dist/components/client/Menu/Menu.ItemCheckbox.d.ts +1 -1
- package/dist/components/client/Popover/Popover.cjs +96 -0
- package/dist/components/client/Popover/Popover.d.cts +55 -0
- package/dist/components/client/Popover/Popover.d.ts +55 -0
- package/dist/components/client/Popover/Popover.js +94 -0
- package/dist/components/client/Popover/PopoverContent.cjs +171 -0
- package/dist/components/client/Popover/PopoverContent.d.cts +26 -0
- package/dist/components/client/Popover/PopoverContent.d.ts +26 -0
- package/dist/components/client/Popover/PopoverContent.js +169 -0
- package/dist/components/client/Popover/PopoverContext.cjs +11 -0
- package/dist/components/client/Popover/PopoverContext.d.cts +21 -0
- package/dist/components/client/Popover/PopoverContext.d.ts +21 -0
- package/dist/components/client/Popover/PopoverContext.js +9 -0
- package/dist/components/client/Popover/PopoverTrigger.cjs +26 -0
- package/dist/components/client/Popover/PopoverTrigger.d.cts +14 -0
- package/dist/components/client/Popover/PopoverTrigger.d.ts +14 -0
- package/dist/components/client/Popover/PopoverTrigger.js +24 -0
- package/dist/components/client/Popover/UDSPopoverConfigProvider.cjs +40 -0
- package/dist/components/client/Popover/UDSPopoverConfigProvider.d.cts +28 -0
- package/dist/components/client/Popover/UDSPopoverConfigProvider.d.ts +28 -0
- package/dist/components/client/Popover/UDSPopoverConfigProvider.js +37 -0
- package/dist/components/client/Popover/index.cjs +12 -0
- package/dist/components/client/Popover/index.d.cts +7 -0
- package/dist/components/client/Popover/index.d.ts +7 -0
- package/dist/components/client/Popover/index.js +8 -0
- package/dist/components/client/Toast/Toast.cjs +3 -3
- package/dist/components/client/Toast/Toast.d.cts +1 -1
- package/dist/components/client/Toast/Toast.d.ts +1 -1
- package/dist/components/client/Toast/Toast.js +3 -3
- package/dist/components/client/Toast/UDSToastConfigProvider.d.cts +5 -5
- package/dist/components/client/Toast/UDSToastConfigProvider.d.ts +5 -5
- package/dist/components/client/Toast/index.d.cts +1 -1
- package/dist/components/client/Toast/index.d.ts +1 -1
- package/dist/components/client/Tooltip/Tooltip.cjs +6 -6
- package/dist/components/client/Tooltip/Tooltip.d.cts +1 -1
- package/dist/components/client/Tooltip/Tooltip.d.ts +1 -1
- package/dist/components/client/Tooltip/Tooltip.js +6 -6
- package/dist/components/client/Tooltip/TooltipContent.cjs +55 -119
- package/dist/components/client/Tooltip/TooltipContent.js +56 -120
- package/dist/components/client/Tooltip/tooltipContext.cjs +0 -1
- package/dist/components/client/Tooltip/tooltipContext.d.cts +1 -2
- package/dist/components/client/Tooltip/tooltipContext.d.ts +1 -2
- package/dist/components/client/Tooltip/tooltipContext.js +0 -1
- package/dist/components/client/index.cjs +8 -0
- package/dist/components/client/index.d.cts +10 -5
- package/dist/components/client/index.d.ts +10 -5
- package/dist/components/client/index.js +5 -1
- package/dist/components/client/providers/UDSConfigProvider.cjs +6 -2
- package/dist/components/client/providers/UDSConfigProvider.d.cts +2 -1
- package/dist/components/client/providers/UDSConfigProvider.d.ts +2 -1
- package/dist/components/client/providers/UDSConfigProvider.js +6 -2
- package/dist/components/experimental/client/{Popover.cjs → ExperimentalPopover.cjs} +10 -1
- package/dist/components/experimental/client/ExperimentalPopover.d.cts +40 -0
- package/dist/components/experimental/client/ExperimentalPopover.d.ts +40 -0
- package/dist/components/experimental/client/{Popover.js → ExperimentalPopover.js} +10 -1
- package/dist/components/experimental/client/index.cjs +10 -10
- package/dist/components/experimental/client/index.d.cts +2 -2
- package/dist/components/experimental/client/index.d.ts +2 -2
- package/dist/components/experimental/client/index.js +1 -1
- package/dist/components/experimental/index.cjs +19 -19
- package/dist/components/experimental/index.d.cts +2 -2
- package/dist/components/experimental/index.d.ts +2 -2
- package/dist/components/experimental/index.js +1 -1
- package/dist/components/index.cjs +12 -0
- package/dist/components/index.d.cts +9 -5
- package/dist/components/index.d.ts +9 -5
- package/dist/components/index.js +9 -1
- package/dist/config/dist/index.cjs +79 -1
- package/dist/config/dist/index.js +79 -1
- package/dist/{components/client/Tooltip/useTooltipContent.cjs → hooks/useSvgFloatingContent.cjs} +81 -48
- package/dist/hooks/useSvgFloatingContent.d.cts +74 -0
- package/dist/hooks/useSvgFloatingContent.d.ts +74 -0
- package/dist/{components/client/Tooltip/useTooltipContent.js → hooks/useSvgFloatingContent.js} +76 -43
- package/dist/index.cjs +21 -10
- package/dist/index.d.cts +15 -10
- package/dist/index.d.ts +15 -10
- package/dist/index.js +16 -11
- package/dist/runtime/index.cjs +2 -0
- package/dist/runtime/index.d.cts +3 -2
- package/dist/runtime/index.d.ts +3 -2
- package/dist/runtime/index.js +2 -1
- package/dist/runtime/popoverConfig.cjs +41 -0
- package/dist/runtime/popoverConfig.d.cts +24 -0
- package/dist/runtime/popoverConfig.d.ts +24 -0
- package/dist/runtime/popoverConfig.js +40 -0
- package/dist/runtime/udsConfig.cjs +3 -1
- package/dist/runtime/udsConfig.d.cts +3 -1
- package/dist/runtime/udsConfig.d.ts +3 -1
- package/dist/runtime/udsConfig.js +3 -1
- package/dist/styles/styler.d.cts +90 -80
- package/dist/styles/styler.d.ts +90 -80
- package/dist/styles/variants.d.cts +30 -0
- package/dist/styles/variants.d.ts +30 -0
- package/dist/tailwind/dist/tailwind/plugins/components.cjs +1 -0
- package/dist/tailwind/dist/tailwind/plugins/components.js +2 -1
- package/dist/tokens/automation/configs/index.cjs +1 -0
- package/dist/tokens/automation/configs/index.d.cts +2 -2
- package/dist/tokens/automation/configs/index.d.ts +2 -2
- package/dist/tokens/automation/configs/index.js +2 -2
- package/dist/tokens/automation/index.cjs +1 -0
- package/dist/tokens/automation/index.d.cts +2 -2
- package/dist/tokens/automation/index.d.ts +2 -2
- package/dist/tokens/automation/index.js +2 -2
- package/dist/tokens/index.cjs +2 -1
- package/dist/tokens/index.d.cts +3 -3
- package/dist/tokens/index.d.ts +3 -3
- package/dist/tokens/index.js +3 -3
- package/dist/tokens/types.d.cts +2 -2
- package/dist/tokens/types.d.ts +2 -2
- package/dist/types/dist/index.d.cts +51 -1
- package/dist/types/dist/index.d.ts +51 -1
- package/dist/uds/generated/componentData.cjs +298 -139
- package/dist/uds/generated/componentData.js +263 -140
- package/dist/uds/generated/tailwindPurge.cjs +52 -26
- package/dist/uds/generated/tailwindPurge.js +52 -26
- package/dist/utils/parseShadow.cjs +120 -0
- package/dist/utils/parseShadow.d.cts +33 -0
- package/dist/utils/parseShadow.d.ts +33 -0
- package/dist/utils/parseShadow.js +118 -0
- package/dist/utils/svgFloatingContentUtils.cjs +121 -0
- package/dist/{components/client/Tooltip/util.d.cts → utils/svgFloatingContentUtils.d.cts} +25 -62
- package/dist/{components/client/Tooltip/util.d.ts → utils/svgFloatingContentUtils.d.ts} +25 -62
- package/dist/utils/svgFloatingContentUtils.js +117 -0
- package/generated/componentData.json +337 -185
- package/generated/tailwindPurge.ts +50 -27
- package/package.json +1 -1
- package/dist/components/client/Tooltip/useTooltipContent.d.cts +0 -66
- package/dist/components/client/Tooltip/useTooltipContent.d.ts +0 -66
- package/dist/components/client/Tooltip/util.cjs +0 -248
- package/dist/components/client/Tooltip/util.js +0 -240
- package/dist/components/experimental/client/Popover.d.cts +0 -29
- package/dist/components/experimental/client/Popover.d.ts +0 -29
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
//#region ../config/dist/index.js
|
|
4
4
|
/*! © 2026 Yahoo, Inc. UDS Default Config v0.0.0-development */
|
|
5
|
-
const LATEST_MIGRATION_VERSION = "v0.
|
|
5
|
+
const LATEST_MIGRATION_VERSION = "v0.86.0";
|
|
6
6
|
/**
|
|
7
7
|
* NOTE: If you're building a feature with a migration,
|
|
8
8
|
* this type will likely throw. You can regenerate yosConfig
|
|
@@ -16440,6 +16440,84 @@ const defaultTokensConfig = {
|
|
|
16440
16440
|
}
|
|
16441
16441
|
}
|
|
16442
16442
|
},
|
|
16443
|
+
popover: {
|
|
16444
|
+
defaults: {
|
|
16445
|
+
size: "default",
|
|
16446
|
+
variant: "default"
|
|
16447
|
+
},
|
|
16448
|
+
variables: {
|
|
16449
|
+
"size/default/closeIcon": { size: { rest: {
|
|
16450
|
+
type: "iconSizes",
|
|
16451
|
+
value: "sm",
|
|
16452
|
+
valueType: "alias"
|
|
16453
|
+
} } },
|
|
16454
|
+
"size/default/contentWrapper": {
|
|
16455
|
+
gap: { rest: {
|
|
16456
|
+
type: "spacingAliases",
|
|
16457
|
+
value: "3",
|
|
16458
|
+
valueType: "alias"
|
|
16459
|
+
} },
|
|
16460
|
+
spacingHorizontal: { rest: {
|
|
16461
|
+
type: "spacingAliases",
|
|
16462
|
+
value: "5",
|
|
16463
|
+
valueType: "alias"
|
|
16464
|
+
} },
|
|
16465
|
+
spacingVertical: { rest: {
|
|
16466
|
+
type: "spacingAliases",
|
|
16467
|
+
value: "5",
|
|
16468
|
+
valueType: "alias"
|
|
16469
|
+
} }
|
|
16470
|
+
},
|
|
16471
|
+
"size/default/root": { shadow: { rest: {
|
|
16472
|
+
type: "elevationAliases",
|
|
16473
|
+
value: "elevation-4",
|
|
16474
|
+
valueType: "alias"
|
|
16475
|
+
} } },
|
|
16476
|
+
"size/default/svgBase": { borderRadius: { rest: {
|
|
16477
|
+
type: "borderRadii",
|
|
16478
|
+
value: "lg",
|
|
16479
|
+
valueType: "alias"
|
|
16480
|
+
} } },
|
|
16481
|
+
"size/default/svgBorder": { strokeWidth: { rest: {
|
|
16482
|
+
type: "elevationAliases",
|
|
16483
|
+
value: "elevation-4",
|
|
16484
|
+
valueType: "alias"
|
|
16485
|
+
} } },
|
|
16486
|
+
"variant/default/blur": { backdropBlur: { rest: {
|
|
16487
|
+
type: "positiveIntegers",
|
|
16488
|
+
value: 0,
|
|
16489
|
+
valueType: "custom"
|
|
16490
|
+
} } },
|
|
16491
|
+
"variant/default/closeIcon": { color: { rest: {
|
|
16492
|
+
type: "foregroundPaletteColors",
|
|
16493
|
+
value: "primary",
|
|
16494
|
+
valueType: "alias"
|
|
16495
|
+
} } },
|
|
16496
|
+
"variant/default/root": {},
|
|
16497
|
+
"variant/default/svgBase": {
|
|
16498
|
+
backgroundColor: { rest: {
|
|
16499
|
+
type: "elevationAliases",
|
|
16500
|
+
value: "elevation-4",
|
|
16501
|
+
valueType: "alias"
|
|
16502
|
+
} },
|
|
16503
|
+
blurBackgroundColorFallback: { rest: {
|
|
16504
|
+
type: "elevationAliases",
|
|
16505
|
+
value: "elevation-4",
|
|
16506
|
+
valueType: "alias"
|
|
16507
|
+
} },
|
|
16508
|
+
fillOpacity: { rest: {
|
|
16509
|
+
type: "opacitySteps",
|
|
16510
|
+
value: "100",
|
|
16511
|
+
valueType: "alias"
|
|
16512
|
+
} }
|
|
16513
|
+
},
|
|
16514
|
+
"variant/default/svgBorder": { stroke: { rest: {
|
|
16515
|
+
type: "elevationAliases",
|
|
16516
|
+
value: "elevation-4",
|
|
16517
|
+
valueType: "alias"
|
|
16518
|
+
} } }
|
|
16519
|
+
}
|
|
16520
|
+
},
|
|
16443
16521
|
radio: {
|
|
16444
16522
|
defaults: {
|
|
16445
16523
|
size: "sm",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
2
|
//#region ../config/dist/index.js
|
|
3
3
|
/*! © 2026 Yahoo, Inc. UDS Default Config v0.0.0-development */
|
|
4
|
-
const LATEST_MIGRATION_VERSION = "v0.
|
|
4
|
+
const LATEST_MIGRATION_VERSION = "v0.86.0";
|
|
5
5
|
/**
|
|
6
6
|
* NOTE: If you're building a feature with a migration,
|
|
7
7
|
* this type will likely throw. You can regenerate yosConfig
|
|
@@ -16439,6 +16439,84 @@ const defaultTokensConfig = {
|
|
|
16439
16439
|
}
|
|
16440
16440
|
}
|
|
16441
16441
|
},
|
|
16442
|
+
popover: {
|
|
16443
|
+
defaults: {
|
|
16444
|
+
size: "default",
|
|
16445
|
+
variant: "default"
|
|
16446
|
+
},
|
|
16447
|
+
variables: {
|
|
16448
|
+
"size/default/closeIcon": { size: { rest: {
|
|
16449
|
+
type: "iconSizes",
|
|
16450
|
+
value: "sm",
|
|
16451
|
+
valueType: "alias"
|
|
16452
|
+
} } },
|
|
16453
|
+
"size/default/contentWrapper": {
|
|
16454
|
+
gap: { rest: {
|
|
16455
|
+
type: "spacingAliases",
|
|
16456
|
+
value: "3",
|
|
16457
|
+
valueType: "alias"
|
|
16458
|
+
} },
|
|
16459
|
+
spacingHorizontal: { rest: {
|
|
16460
|
+
type: "spacingAliases",
|
|
16461
|
+
value: "5",
|
|
16462
|
+
valueType: "alias"
|
|
16463
|
+
} },
|
|
16464
|
+
spacingVertical: { rest: {
|
|
16465
|
+
type: "spacingAliases",
|
|
16466
|
+
value: "5",
|
|
16467
|
+
valueType: "alias"
|
|
16468
|
+
} }
|
|
16469
|
+
},
|
|
16470
|
+
"size/default/root": { shadow: { rest: {
|
|
16471
|
+
type: "elevationAliases",
|
|
16472
|
+
value: "elevation-4",
|
|
16473
|
+
valueType: "alias"
|
|
16474
|
+
} } },
|
|
16475
|
+
"size/default/svgBase": { borderRadius: { rest: {
|
|
16476
|
+
type: "borderRadii",
|
|
16477
|
+
value: "lg",
|
|
16478
|
+
valueType: "alias"
|
|
16479
|
+
} } },
|
|
16480
|
+
"size/default/svgBorder": { strokeWidth: { rest: {
|
|
16481
|
+
type: "elevationAliases",
|
|
16482
|
+
value: "elevation-4",
|
|
16483
|
+
valueType: "alias"
|
|
16484
|
+
} } },
|
|
16485
|
+
"variant/default/blur": { backdropBlur: { rest: {
|
|
16486
|
+
type: "positiveIntegers",
|
|
16487
|
+
value: 0,
|
|
16488
|
+
valueType: "custom"
|
|
16489
|
+
} } },
|
|
16490
|
+
"variant/default/closeIcon": { color: { rest: {
|
|
16491
|
+
type: "foregroundPaletteColors",
|
|
16492
|
+
value: "primary",
|
|
16493
|
+
valueType: "alias"
|
|
16494
|
+
} } },
|
|
16495
|
+
"variant/default/root": {},
|
|
16496
|
+
"variant/default/svgBase": {
|
|
16497
|
+
backgroundColor: { rest: {
|
|
16498
|
+
type: "elevationAliases",
|
|
16499
|
+
value: "elevation-4",
|
|
16500
|
+
valueType: "alias"
|
|
16501
|
+
} },
|
|
16502
|
+
blurBackgroundColorFallback: { rest: {
|
|
16503
|
+
type: "elevationAliases",
|
|
16504
|
+
value: "elevation-4",
|
|
16505
|
+
valueType: "alias"
|
|
16506
|
+
} },
|
|
16507
|
+
fillOpacity: { rest: {
|
|
16508
|
+
type: "opacitySteps",
|
|
16509
|
+
value: "100",
|
|
16510
|
+
valueType: "alias"
|
|
16511
|
+
} }
|
|
16512
|
+
},
|
|
16513
|
+
"variant/default/svgBorder": { stroke: { rest: {
|
|
16514
|
+
type: "elevationAliases",
|
|
16515
|
+
value: "elevation-4",
|
|
16516
|
+
valueType: "alias"
|
|
16517
|
+
} } }
|
|
16518
|
+
}
|
|
16519
|
+
},
|
|
16442
16520
|
radio: {
|
|
16443
16521
|
defaults: {
|
|
16444
16522
|
size: "sm",
|
package/dist/{components/client/Tooltip/useTooltipContent.cjs → hooks/useSvgFloatingContent.cjs}
RENAMED
|
@@ -1,23 +1,19 @@
|
|
|
1
|
-
"use client";
|
|
2
1
|
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
3
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
const require_runtime = require('
|
|
5
|
-
const require_index = require('
|
|
6
|
-
const
|
|
3
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
4
|
+
const require_index = require('../css-tokens/dist/index.cjs');
|
|
5
|
+
const require_utils_parseShadow = require('../utils/parseShadow.cjs');
|
|
6
|
+
const require_utils_svgFloatingContentUtils = require('../utils/svgFloatingContentUtils.cjs');
|
|
7
7
|
let react = require("react");
|
|
8
8
|
|
|
9
|
-
//#region src/
|
|
10
|
-
function
|
|
9
|
+
//#region src/hooks/useSvgFloatingContent.ts
|
|
10
|
+
function useSvgFloatingContent({ open, effectivePlacement, borderRadius, arrowRef, animationDuration, hideArrow = false, arrowWidth, arrowHeight, arrowTipRadiusFraction }) {
|
|
11
11
|
const internalRef = (0, react.useRef)(null);
|
|
12
12
|
const shadowFilterId = (0, react.useId)();
|
|
13
13
|
const [dimensions, setDimensions] = (0, react.useState)({
|
|
14
14
|
width: 0,
|
|
15
15
|
height: 0
|
|
16
16
|
});
|
|
17
|
-
const maxWidthClass = (0, react.useMemo)(() => {
|
|
18
|
-
if (maxWidth !== void 0) return typeof maxWidth === "number" ? `max-w-[${maxWidth}px]` : `max-w-[${maxWidth}]`;
|
|
19
|
-
return "max-w-lg";
|
|
20
|
-
}, [maxWidth]);
|
|
21
17
|
(0, react.useEffect)(() => {
|
|
22
18
|
const el = internalRef.current;
|
|
23
19
|
if (!el) return;
|
|
@@ -37,7 +33,7 @@ function useTooltipContent({ open, effectivePlacement, maxWidth, borderRadius, a
|
|
|
37
33
|
const shadowValue = getComputedStyle(internalRef.current).getPropertyValue(`--${require_index.DROP_SHADOW_PREFIX}`);
|
|
38
34
|
if (shadowValue !== shadowValueRef.current) {
|
|
39
35
|
shadowValueRef.current = shadowValue;
|
|
40
|
-
setShadows(
|
|
36
|
+
setShadows(require_utils_parseShadow.parseShadow(shadowValue));
|
|
41
37
|
}
|
|
42
38
|
}, []);
|
|
43
39
|
const shadowPadding = (0, react.useMemo)(() => {
|
|
@@ -51,12 +47,12 @@ function useTooltipContent({ open, effectivePlacement, maxWidth, borderRadius, a
|
|
|
51
47
|
const [arrowCenter, setArrowCenter] = (0, react.useState)(void 0);
|
|
52
48
|
const computeArrowCenter = (0, react.useCallback)(() => {
|
|
53
49
|
const arrowEl = arrowRef.current;
|
|
54
|
-
const
|
|
55
|
-
if (!arrowEl || !
|
|
50
|
+
const el = internalRef.current;
|
|
51
|
+
if (!arrowEl || !el) return;
|
|
56
52
|
const arrowRect = arrowEl.getBoundingClientRect();
|
|
57
|
-
const
|
|
58
|
-
const side =
|
|
59
|
-
const raw = side === "top" || side === "bottom" ? arrowRect.left + arrowRect.width / 2 -
|
|
53
|
+
const rect = el.getBoundingClientRect();
|
|
54
|
+
const side = require_utils_svgFloatingContentUtils.getArrowSide(effectivePlacement);
|
|
55
|
+
const raw = side === "top" || side === "bottom" ? arrowRect.left + arrowRect.width / 2 - rect.left : arrowRect.top + arrowRect.height / 2 - rect.top;
|
|
60
56
|
return Math.round(raw);
|
|
61
57
|
}, [arrowRef, effectivePlacement]);
|
|
62
58
|
const onPositionUpdate = (0, react.useCallback)(async ({ updatePosition }) => {
|
|
@@ -73,81 +69,115 @@ function useTooltipContent({ open, effectivePlacement, maxWidth, borderRadius, a
|
|
|
73
69
|
});
|
|
74
70
|
readShadows();
|
|
75
71
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
72
|
+
if (!hideArrow) {
|
|
73
|
+
const next = computeArrowCenter();
|
|
74
|
+
if (next !== void 0) setArrowCenter((prev) => prev === next ? prev : next);
|
|
75
|
+
}
|
|
76
|
+
}, [
|
|
77
|
+
computeArrowCenter,
|
|
78
|
+
readShadows,
|
|
79
|
+
hideArrow
|
|
80
|
+
]);
|
|
79
81
|
const svgPath = (0, react.useMemo)(() => {
|
|
80
|
-
return dimensions.width > 0 && dimensions.height > 0 ?
|
|
82
|
+
return dimensions.width > 0 && dimensions.height > 0 ? require_utils_svgFloatingContentUtils.generateSvgFloatingContentPath({
|
|
81
83
|
width: dimensions.width,
|
|
82
84
|
height: dimensions.height,
|
|
83
85
|
placement: effectivePlacement,
|
|
84
86
|
borderRadius,
|
|
85
|
-
arrowCenter
|
|
87
|
+
arrowCenter: hideArrow ? void 0 : arrowCenter,
|
|
88
|
+
arrowWidth,
|
|
89
|
+
arrowHeight,
|
|
90
|
+
arrowTipRadiusFraction,
|
|
91
|
+
...hideArrow && {
|
|
92
|
+
arrowWidth: 0,
|
|
93
|
+
arrowHeight: 0
|
|
94
|
+
}
|
|
86
95
|
}) : null;
|
|
87
96
|
}, [
|
|
88
97
|
effectivePlacement,
|
|
89
98
|
dimensions.width,
|
|
90
99
|
dimensions.height,
|
|
91
100
|
borderRadius,
|
|
92
|
-
arrowCenter
|
|
101
|
+
arrowCenter,
|
|
102
|
+
hideArrow,
|
|
103
|
+
arrowWidth,
|
|
104
|
+
arrowHeight,
|
|
105
|
+
arrowTipRadiusFraction
|
|
93
106
|
]);
|
|
94
107
|
const blurClipPath = (0, react.useMemo)(() => {
|
|
95
108
|
if (dimensions.width <= 0 || dimensions.height <= 0) return null;
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
109
|
+
if (hideArrow) return require_utils_svgFloatingContentUtils.generateSvgFloatingContentPath({
|
|
110
|
+
width: dimensions.width,
|
|
111
|
+
height: dimensions.height,
|
|
112
|
+
placement: effectivePlacement,
|
|
113
|
+
borderRadius,
|
|
114
|
+
arrowWidth: 0,
|
|
115
|
+
arrowHeight: 0,
|
|
116
|
+
arrowTipRadiusFraction
|
|
117
|
+
});
|
|
118
|
+
const arrowSide = require_utils_svgFloatingContentUtils.getArrowSide(effectivePlacement);
|
|
119
|
+
const offsetX = arrowSide === "left" ? arrowHeight : 0;
|
|
120
|
+
const offsetY = arrowSide === "top" ? arrowHeight : 0;
|
|
121
|
+
return require_utils_svgFloatingContentUtils.generateSvgFloatingContentPath({
|
|
100
122
|
width: dimensions.width,
|
|
101
123
|
height: dimensions.height,
|
|
102
124
|
placement: effectivePlacement,
|
|
103
125
|
borderRadius,
|
|
104
126
|
arrowCenter,
|
|
105
127
|
offsetX,
|
|
106
|
-
offsetY
|
|
128
|
+
offsetY,
|
|
129
|
+
arrowWidth,
|
|
130
|
+
arrowHeight,
|
|
131
|
+
arrowTipRadiusFraction
|
|
107
132
|
});
|
|
108
133
|
}, [
|
|
109
134
|
effectivePlacement,
|
|
110
135
|
dimensions.width,
|
|
111
136
|
dimensions.height,
|
|
112
137
|
borderRadius,
|
|
113
|
-
arrowCenter
|
|
138
|
+
arrowCenter,
|
|
139
|
+
hideArrow,
|
|
140
|
+
arrowHeight,
|
|
141
|
+
arrowWidth,
|
|
142
|
+
arrowTipRadiusFraction
|
|
114
143
|
]);
|
|
115
144
|
const blurStyle = (0, react.useMemo)(() => {
|
|
116
145
|
const style = { clipPath: blurClipPath ? `path('${blurClipPath}')` : void 0 };
|
|
117
|
-
switch (
|
|
146
|
+
if (!hideArrow) switch (require_utils_svgFloatingContentUtils.getArrowSide(effectivePlacement)) {
|
|
118
147
|
case "top":
|
|
119
|
-
style.height = `calc(100% + ${
|
|
148
|
+
style.height = `calc(100% + ${arrowHeight}px)`;
|
|
120
149
|
style.top = "auto";
|
|
121
150
|
style.bottom = "0";
|
|
122
151
|
break;
|
|
123
152
|
case "bottom":
|
|
124
|
-
style.height = `calc(100% + ${
|
|
153
|
+
style.height = `calc(100% + ${arrowHeight}px)`;
|
|
125
154
|
break;
|
|
126
155
|
case "left":
|
|
127
|
-
style.width = `calc(100% + ${
|
|
156
|
+
style.width = `calc(100% + ${arrowHeight}px)`;
|
|
128
157
|
style.left = "auto";
|
|
129
158
|
style.right = "0";
|
|
130
159
|
break;
|
|
131
160
|
case "right":
|
|
132
|
-
style.width = `calc(100% + ${
|
|
161
|
+
style.width = `calc(100% + ${arrowHeight}px)`;
|
|
133
162
|
break;
|
|
134
163
|
}
|
|
135
164
|
return style;
|
|
136
|
-
}, [
|
|
165
|
+
}, [
|
|
166
|
+
blurClipPath,
|
|
167
|
+
effectivePlacement,
|
|
168
|
+
hideArrow,
|
|
169
|
+
arrowHeight
|
|
170
|
+
]);
|
|
137
171
|
const [visible, setVisible] = (0, react.useState)(false);
|
|
138
|
-
if ((!open || !svgPath) && visible) setVisible(false);
|
|
139
172
|
(0, react.useEffect)(() => {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
return () => cancelAnimationFrame(raf);
|
|
145
|
-
}
|
|
173
|
+
const raf = requestAnimationFrame(() => {
|
|
174
|
+
setVisible(open && !!svgPath);
|
|
175
|
+
});
|
|
176
|
+
return () => cancelAnimationFrame(raf);
|
|
146
177
|
}, [open, svgPath]);
|
|
147
178
|
return {
|
|
148
179
|
internalRef,
|
|
149
180
|
shadowFilterId,
|
|
150
|
-
maxWidthClass,
|
|
151
181
|
dimensions,
|
|
152
182
|
shadows,
|
|
153
183
|
shadowPadding,
|
|
@@ -159,28 +189,31 @@ function useTooltipContent({ open, effectivePlacement, maxWidth, borderRadius, a
|
|
|
159
189
|
opacity: visible ? 1 : 0,
|
|
160
190
|
transition: `opacity ${animationDuration}ms ease-in-out`
|
|
161
191
|
},
|
|
162
|
-
|
|
163
|
-
if (arrowCenter === void 0 || dimensions.width <= 0 || dimensions.height <= 0) return {
|
|
192
|
+
shift: (0, react.useMemo)(() => {
|
|
193
|
+
if (hideArrow || arrowCenter === void 0 || dimensions.width <= 0 || dimensions.height <= 0) return {
|
|
164
194
|
x: 0,
|
|
165
195
|
y: 0
|
|
166
196
|
};
|
|
167
|
-
return
|
|
197
|
+
return require_utils_svgFloatingContentUtils.getArrowClampDelta({
|
|
168
198
|
width: dimensions.width,
|
|
169
199
|
height: dimensions.height,
|
|
170
200
|
placement: effectivePlacement,
|
|
171
201
|
borderRadius,
|
|
172
|
-
arrowCenter
|
|
202
|
+
arrowCenter,
|
|
203
|
+
arrowWidth
|
|
173
204
|
});
|
|
174
205
|
}, [
|
|
206
|
+
hideArrow,
|
|
175
207
|
arrowCenter,
|
|
176
208
|
dimensions.width,
|
|
177
209
|
dimensions.height,
|
|
178
210
|
effectivePlacement,
|
|
179
|
-
borderRadius
|
|
211
|
+
borderRadius,
|
|
212
|
+
arrowWidth
|
|
180
213
|
]),
|
|
181
214
|
onPositionUpdate
|
|
182
215
|
};
|
|
183
216
|
}
|
|
184
217
|
|
|
185
218
|
//#endregion
|
|
186
|
-
exports.
|
|
219
|
+
exports.useSvgFloatingContent = useSvgFloatingContent;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
|
|
2
|
+
import { ParsedShadow } from "../utils/parseShadow.cjs";
|
|
3
|
+
import { CSSProperties, RefObject } from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/hooks/useSvgFloatingContent.d.ts
|
|
6
|
+
interface UseSvgFloatingContentOptions {
|
|
7
|
+
/** Whether the element is currently open. */
|
|
8
|
+
open: boolean;
|
|
9
|
+
/** Resolved placement after Ariakit positioning (e.g. `'top'`, `'bottom-start'`). */
|
|
10
|
+
effectivePlacement: string;
|
|
11
|
+
/** Border-radius from the component config (px). */
|
|
12
|
+
borderRadius: number;
|
|
13
|
+
/**
|
|
14
|
+
* Ref to the arrow element. Its position is read inside the `updatePosition`
|
|
15
|
+
* callback so the SVG arrow always mirrors where floating-ui places the
|
|
16
|
+
* native arrow.
|
|
17
|
+
*/
|
|
18
|
+
arrowRef: RefObject<HTMLDivElement | null>;
|
|
19
|
+
/** Animation duration from the component config (ms). */
|
|
20
|
+
animationDuration: number;
|
|
21
|
+
/** Whether to hide the arrow. */
|
|
22
|
+
hideArrow?: boolean;
|
|
23
|
+
/** Width of the arrow (px). */
|
|
24
|
+
arrowWidth: number;
|
|
25
|
+
/** Height of the arrow (px). */
|
|
26
|
+
arrowHeight: number;
|
|
27
|
+
/** Fraction of the container border-radius applied to round the arrow tip (0 = sharp point, 1 = same radius as the container corners). */
|
|
28
|
+
arrowTipRadiusFraction: number;
|
|
29
|
+
}
|
|
30
|
+
interface UseSvgFloatingContentReturn {
|
|
31
|
+
internalRef: RefObject<HTMLElement | null>;
|
|
32
|
+
shadowFilterId: string;
|
|
33
|
+
dimensions: {
|
|
34
|
+
width: number;
|
|
35
|
+
height: number;
|
|
36
|
+
};
|
|
37
|
+
shadows: ParsedShadow[];
|
|
38
|
+
shadowPadding: number;
|
|
39
|
+
svgPath: string | null;
|
|
40
|
+
blurClipPath: string | null;
|
|
41
|
+
blurStyle: CSSProperties;
|
|
42
|
+
visible: boolean;
|
|
43
|
+
childTransitionStyle: CSSProperties;
|
|
44
|
+
/**
|
|
45
|
+
* Pixel offset to apply as a CSS transform on the element so that
|
|
46
|
+
* the (clamped) SVG arrow aligns with the trigger center even when the
|
|
47
|
+
* trigger is too small / close to a rounded corner for the arrow to reach.
|
|
48
|
+
*/
|
|
49
|
+
shift: {
|
|
50
|
+
x: number;
|
|
51
|
+
y: number;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Pass as the `updatePosition` prop to the Ariakit component.
|
|
55
|
+
* This hooks into floating-ui's positioning lifecycle so the SVG arrow
|
|
56
|
+
* center is read after every `computePosition`
|
|
57
|
+
*/
|
|
58
|
+
onPositionUpdate: (props: {
|
|
59
|
+
updatePosition: () => Promise<void>;
|
|
60
|
+
}) => Promise<void>;
|
|
61
|
+
}
|
|
62
|
+
declare function useSvgFloatingContent({
|
|
63
|
+
open,
|
|
64
|
+
effectivePlacement,
|
|
65
|
+
borderRadius,
|
|
66
|
+
arrowRef,
|
|
67
|
+
animationDuration,
|
|
68
|
+
hideArrow,
|
|
69
|
+
arrowWidth,
|
|
70
|
+
arrowHeight,
|
|
71
|
+
arrowTipRadiusFraction
|
|
72
|
+
}: UseSvgFloatingContentOptions): UseSvgFloatingContentReturn;
|
|
73
|
+
//#endregion
|
|
74
|
+
export { type UseSvgFloatingContentOptions, type UseSvgFloatingContentReturn, useSvgFloatingContent };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
|
|
2
|
+
import { ParsedShadow } from "../utils/parseShadow.js";
|
|
3
|
+
import { CSSProperties, RefObject } from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/hooks/useSvgFloatingContent.d.ts
|
|
6
|
+
interface UseSvgFloatingContentOptions {
|
|
7
|
+
/** Whether the element is currently open. */
|
|
8
|
+
open: boolean;
|
|
9
|
+
/** Resolved placement after Ariakit positioning (e.g. `'top'`, `'bottom-start'`). */
|
|
10
|
+
effectivePlacement: string;
|
|
11
|
+
/** Border-radius from the component config (px). */
|
|
12
|
+
borderRadius: number;
|
|
13
|
+
/**
|
|
14
|
+
* Ref to the arrow element. Its position is read inside the `updatePosition`
|
|
15
|
+
* callback so the SVG arrow always mirrors where floating-ui places the
|
|
16
|
+
* native arrow.
|
|
17
|
+
*/
|
|
18
|
+
arrowRef: RefObject<HTMLDivElement | null>;
|
|
19
|
+
/** Animation duration from the component config (ms). */
|
|
20
|
+
animationDuration: number;
|
|
21
|
+
/** Whether to hide the arrow. */
|
|
22
|
+
hideArrow?: boolean;
|
|
23
|
+
/** Width of the arrow (px). */
|
|
24
|
+
arrowWidth: number;
|
|
25
|
+
/** Height of the arrow (px). */
|
|
26
|
+
arrowHeight: number;
|
|
27
|
+
/** Fraction of the container border-radius applied to round the arrow tip (0 = sharp point, 1 = same radius as the container corners). */
|
|
28
|
+
arrowTipRadiusFraction: number;
|
|
29
|
+
}
|
|
30
|
+
interface UseSvgFloatingContentReturn {
|
|
31
|
+
internalRef: RefObject<HTMLElement | null>;
|
|
32
|
+
shadowFilterId: string;
|
|
33
|
+
dimensions: {
|
|
34
|
+
width: number;
|
|
35
|
+
height: number;
|
|
36
|
+
};
|
|
37
|
+
shadows: ParsedShadow[];
|
|
38
|
+
shadowPadding: number;
|
|
39
|
+
svgPath: string | null;
|
|
40
|
+
blurClipPath: string | null;
|
|
41
|
+
blurStyle: CSSProperties;
|
|
42
|
+
visible: boolean;
|
|
43
|
+
childTransitionStyle: CSSProperties;
|
|
44
|
+
/**
|
|
45
|
+
* Pixel offset to apply as a CSS transform on the element so that
|
|
46
|
+
* the (clamped) SVG arrow aligns with the trigger center even when the
|
|
47
|
+
* trigger is too small / close to a rounded corner for the arrow to reach.
|
|
48
|
+
*/
|
|
49
|
+
shift: {
|
|
50
|
+
x: number;
|
|
51
|
+
y: number;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Pass as the `updatePosition` prop to the Ariakit component.
|
|
55
|
+
* This hooks into floating-ui's positioning lifecycle so the SVG arrow
|
|
56
|
+
* center is read after every `computePosition`
|
|
57
|
+
*/
|
|
58
|
+
onPositionUpdate: (props: {
|
|
59
|
+
updatePosition: () => Promise<void>;
|
|
60
|
+
}) => Promise<void>;
|
|
61
|
+
}
|
|
62
|
+
declare function useSvgFloatingContent({
|
|
63
|
+
open,
|
|
64
|
+
effectivePlacement,
|
|
65
|
+
borderRadius,
|
|
66
|
+
arrowRef,
|
|
67
|
+
animationDuration,
|
|
68
|
+
hideArrow,
|
|
69
|
+
arrowWidth,
|
|
70
|
+
arrowHeight,
|
|
71
|
+
arrowTipRadiusFraction
|
|
72
|
+
}: UseSvgFloatingContentOptions): UseSvgFloatingContentReturn;
|
|
73
|
+
//#endregion
|
|
74
|
+
export { type UseSvgFloatingContentOptions, type UseSvgFloatingContentReturn, useSvgFloatingContent };
|