@yahoo/uds 3.116.3 → 3.117.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.
- package/dist/automated-config/dist/generated/autoVariants.cjs +11 -0
- package/dist/automated-config/dist/generated/autoVariants.d.cts +11 -0
- package/dist/automated-config/dist/generated/autoVariants.d.ts +11 -0
- package/dist/automated-config/dist/generated/autoVariants.js +11 -0
- package/dist/automated-config/dist/generated/generatedConfigs.cjs +1890 -0
- package/dist/automated-config/dist/generated/generatedConfigs.d.cts +208 -1
- package/dist/automated-config/dist/generated/generatedConfigs.d.ts +208 -1
- package/dist/automated-config/dist/generated/generatedConfigs.js +1890 -1
- package/dist/automated-config/dist/generated/universalTokensConfigAuto.cjs +83 -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 +83 -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 +175 -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 +173 -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/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 +33 -96
- package/dist/components/client/Tooltip/TooltipContent.js +34 -97
- 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 +84 -1
- package/dist/config/dist/index.js +84 -1
- package/dist/hooks/useSvgFloatingContent.cjs +236 -0
- 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} +94 -44
- 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 +36 -0
- package/dist/runtime/popoverConfig.d.cts +25 -0
- package/dist/runtime/popoverConfig.d.ts +25 -0
- package/dist/runtime/popoverConfig.js +35 -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 +114 -103
- package/dist/styles/styler.d.ts +114 -103
- package/dist/styles/variants.d.cts +33 -0
- package/dist/styles/variants.d.ts +33 -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 +1296 -1134
- package/dist/uds/generated/componentData.js +1262 -1136
- package/dist/uds/generated/tailwindPurge.cjs +55 -27
- package/dist/uds/generated/tailwindPurge.js +55 -27
- 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 +1628 -1469
- package/generated/tailwindPurge.ts +4 -4
- package/package.json +1 -1
- package/dist/components/client/Tooltip/useTooltipContent.cjs +0 -186
- 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,89 @@ 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/closeIconContainer": { spacing: { rest: {
|
|
16455
|
+
type: "spacingAliases",
|
|
16456
|
+
value: "2",
|
|
16457
|
+
valueType: "alias"
|
|
16458
|
+
} } },
|
|
16459
|
+
"size/default/contentWrapper": {
|
|
16460
|
+
gap: { rest: {
|
|
16461
|
+
type: "spacingAliases",
|
|
16462
|
+
value: "3",
|
|
16463
|
+
valueType: "alias"
|
|
16464
|
+
} },
|
|
16465
|
+
spacingHorizontal: { rest: {
|
|
16466
|
+
type: "spacingAliases",
|
|
16467
|
+
value: "5",
|
|
16468
|
+
valueType: "alias"
|
|
16469
|
+
} },
|
|
16470
|
+
spacingVertical: { rest: {
|
|
16471
|
+
type: "spacingAliases",
|
|
16472
|
+
value: "5",
|
|
16473
|
+
valueType: "alias"
|
|
16474
|
+
} }
|
|
16475
|
+
},
|
|
16476
|
+
"size/default/root": { shadow: { rest: {
|
|
16477
|
+
type: "elevationAliases",
|
|
16478
|
+
value: "elevation-4",
|
|
16479
|
+
valueType: "alias"
|
|
16480
|
+
} } },
|
|
16481
|
+
"size/default/svgBase": { borderRadius: { rest: {
|
|
16482
|
+
type: "borderRadii",
|
|
16483
|
+
value: "lg",
|
|
16484
|
+
valueType: "alias"
|
|
16485
|
+
} } },
|
|
16486
|
+
"size/default/svgBorder": { strokeWidth: { rest: {
|
|
16487
|
+
type: "elevationAliases",
|
|
16488
|
+
value: "elevation-4",
|
|
16489
|
+
valueType: "alias"
|
|
16490
|
+
} } },
|
|
16491
|
+
"variant/default/blur": { backdropBlur: { rest: {
|
|
16492
|
+
type: "positiveIntegers",
|
|
16493
|
+
value: 0,
|
|
16494
|
+
valueType: "custom"
|
|
16495
|
+
} } },
|
|
16496
|
+
"variant/default/closeIcon": { color: { rest: {
|
|
16497
|
+
type: "foregroundPaletteColors",
|
|
16498
|
+
value: "primary",
|
|
16499
|
+
valueType: "alias"
|
|
16500
|
+
} } },
|
|
16501
|
+
"variant/default/root": {},
|
|
16502
|
+
"variant/default/svgBase": {
|
|
16503
|
+
backgroundColor: { rest: {
|
|
16504
|
+
type: "elevationAliases",
|
|
16505
|
+
value: "elevation-4",
|
|
16506
|
+
valueType: "alias"
|
|
16507
|
+
} },
|
|
16508
|
+
blurBackgroundColorFallback: { rest: {
|
|
16509
|
+
type: "elevationAliases",
|
|
16510
|
+
value: "elevation-4",
|
|
16511
|
+
valueType: "alias"
|
|
16512
|
+
} },
|
|
16513
|
+
fillOpacity: { rest: {
|
|
16514
|
+
type: "opacitySteps",
|
|
16515
|
+
value: "100",
|
|
16516
|
+
valueType: "alias"
|
|
16517
|
+
} }
|
|
16518
|
+
},
|
|
16519
|
+
"variant/default/svgBorder": { stroke: { rest: {
|
|
16520
|
+
type: "elevationAliases",
|
|
16521
|
+
value: "elevation-4",
|
|
16522
|
+
valueType: "alias"
|
|
16523
|
+
} } }
|
|
16524
|
+
}
|
|
16525
|
+
},
|
|
16443
16526
|
radio: {
|
|
16444
16527
|
defaults: {
|
|
16445
16528
|
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,89 @@ 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/closeIconContainer": { spacing: { rest: {
|
|
16454
|
+
type: "spacingAliases",
|
|
16455
|
+
value: "2",
|
|
16456
|
+
valueType: "alias"
|
|
16457
|
+
} } },
|
|
16458
|
+
"size/default/contentWrapper": {
|
|
16459
|
+
gap: { rest: {
|
|
16460
|
+
type: "spacingAliases",
|
|
16461
|
+
value: "3",
|
|
16462
|
+
valueType: "alias"
|
|
16463
|
+
} },
|
|
16464
|
+
spacingHorizontal: { rest: {
|
|
16465
|
+
type: "spacingAliases",
|
|
16466
|
+
value: "5",
|
|
16467
|
+
valueType: "alias"
|
|
16468
|
+
} },
|
|
16469
|
+
spacingVertical: { rest: {
|
|
16470
|
+
type: "spacingAliases",
|
|
16471
|
+
value: "5",
|
|
16472
|
+
valueType: "alias"
|
|
16473
|
+
} }
|
|
16474
|
+
},
|
|
16475
|
+
"size/default/root": { shadow: { rest: {
|
|
16476
|
+
type: "elevationAliases",
|
|
16477
|
+
value: "elevation-4",
|
|
16478
|
+
valueType: "alias"
|
|
16479
|
+
} } },
|
|
16480
|
+
"size/default/svgBase": { borderRadius: { rest: {
|
|
16481
|
+
type: "borderRadii",
|
|
16482
|
+
value: "lg",
|
|
16483
|
+
valueType: "alias"
|
|
16484
|
+
} } },
|
|
16485
|
+
"size/default/svgBorder": { strokeWidth: { rest: {
|
|
16486
|
+
type: "elevationAliases",
|
|
16487
|
+
value: "elevation-4",
|
|
16488
|
+
valueType: "alias"
|
|
16489
|
+
} } },
|
|
16490
|
+
"variant/default/blur": { backdropBlur: { rest: {
|
|
16491
|
+
type: "positiveIntegers",
|
|
16492
|
+
value: 0,
|
|
16493
|
+
valueType: "custom"
|
|
16494
|
+
} } },
|
|
16495
|
+
"variant/default/closeIcon": { color: { rest: {
|
|
16496
|
+
type: "foregroundPaletteColors",
|
|
16497
|
+
value: "primary",
|
|
16498
|
+
valueType: "alias"
|
|
16499
|
+
} } },
|
|
16500
|
+
"variant/default/root": {},
|
|
16501
|
+
"variant/default/svgBase": {
|
|
16502
|
+
backgroundColor: { rest: {
|
|
16503
|
+
type: "elevationAliases",
|
|
16504
|
+
value: "elevation-4",
|
|
16505
|
+
valueType: "alias"
|
|
16506
|
+
} },
|
|
16507
|
+
blurBackgroundColorFallback: { rest: {
|
|
16508
|
+
type: "elevationAliases",
|
|
16509
|
+
value: "elevation-4",
|
|
16510
|
+
valueType: "alias"
|
|
16511
|
+
} },
|
|
16512
|
+
fillOpacity: { rest: {
|
|
16513
|
+
type: "opacitySteps",
|
|
16514
|
+
value: "100",
|
|
16515
|
+
valueType: "alias"
|
|
16516
|
+
} }
|
|
16517
|
+
},
|
|
16518
|
+
"variant/default/svgBorder": { stroke: { rest: {
|
|
16519
|
+
type: "elevationAliases",
|
|
16520
|
+
value: "elevation-4",
|
|
16521
|
+
valueType: "alias"
|
|
16522
|
+
} } }
|
|
16523
|
+
}
|
|
16524
|
+
},
|
|
16442
16525
|
radio: {
|
|
16443
16526
|
defaults: {
|
|
16444
16527
|
size: "sm",
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
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
|
+
let react = require("react");
|
|
8
|
+
|
|
9
|
+
//#region src/hooks/useSvgFloatingContent.ts
|
|
10
|
+
function useSvgFloatingContent({ open, effectivePlacement, borderRadius, arrowRef, animationDuration, hideArrow = false, arrowWidth, arrowHeight, arrowTipRadiusFraction }) {
|
|
11
|
+
const internalRef = (0, react.useRef)(null);
|
|
12
|
+
const shadowFilterId = (0, react.useId)();
|
|
13
|
+
const [dimensions, setDimensions] = (0, react.useState)({
|
|
14
|
+
width: 0,
|
|
15
|
+
height: 0
|
|
16
|
+
});
|
|
17
|
+
(0, react.useEffect)(() => {
|
|
18
|
+
const el = internalRef.current;
|
|
19
|
+
if (!el) return;
|
|
20
|
+
const observer = new ResizeObserver(() => {
|
|
21
|
+
setDimensions({
|
|
22
|
+
width: el.offsetWidth,
|
|
23
|
+
height: el.offsetHeight
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
observer.observe(el);
|
|
27
|
+
return () => observer.disconnect();
|
|
28
|
+
}, [open]);
|
|
29
|
+
const [shadows, setShadows] = (0, react.useState)([]);
|
|
30
|
+
const shadowValueRef = (0, react.useRef)("");
|
|
31
|
+
const readShadows = (0, react.useCallback)(() => {
|
|
32
|
+
if (!internalRef.current) return;
|
|
33
|
+
const shadowValue = getComputedStyle(internalRef.current).getPropertyValue(`--${require_index.DROP_SHADOW_PREFIX}`);
|
|
34
|
+
if (shadowValue !== shadowValueRef.current) {
|
|
35
|
+
shadowValueRef.current = shadowValue;
|
|
36
|
+
setShadows(require_utils_parseShadow.parseShadow(shadowValue));
|
|
37
|
+
}
|
|
38
|
+
}, []);
|
|
39
|
+
const shadowPadding = (0, react.useMemo)(() => {
|
|
40
|
+
if (shadows.length === 0) return 0;
|
|
41
|
+
return shadows.reduce((max, s) => {
|
|
42
|
+
const extentX = Math.abs(s.x) + s.blur + Math.abs(s.spread);
|
|
43
|
+
const extentY = Math.abs(s.y) + s.blur + Math.abs(s.spread);
|
|
44
|
+
return Math.max(max, extentX, extentY);
|
|
45
|
+
}, 0);
|
|
46
|
+
}, [shadows]);
|
|
47
|
+
const [arrowCenter, setArrowCenter] = (0, react.useState)(void 0);
|
|
48
|
+
const computeArrowCenter = (0, react.useCallback)(() => {
|
|
49
|
+
const arrowEl = arrowRef.current;
|
|
50
|
+
const el = internalRef.current;
|
|
51
|
+
if (!arrowEl || !el) return;
|
|
52
|
+
const arrowRect = arrowEl.getBoundingClientRect();
|
|
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;
|
|
56
|
+
return Math.round(raw);
|
|
57
|
+
}, [arrowRef, effectivePlacement]);
|
|
58
|
+
const onPositionUpdate = (0, react.useCallback)(async ({ updatePosition }) => {
|
|
59
|
+
await updatePosition();
|
|
60
|
+
const el = internalRef.current;
|
|
61
|
+
if (el) {
|
|
62
|
+
const { offsetWidth, offsetHeight } = el;
|
|
63
|
+
if (offsetWidth > 0 && offsetHeight > 0) setDimensions((prev) => {
|
|
64
|
+
if (prev.width === offsetWidth && prev.height === offsetHeight) return prev;
|
|
65
|
+
return {
|
|
66
|
+
width: offsetWidth,
|
|
67
|
+
height: offsetHeight
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
readShadows();
|
|
71
|
+
}
|
|
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
|
+
]);
|
|
81
|
+
const svgPath = (0, react.useMemo)(() => {
|
|
82
|
+
return dimensions.width > 0 && dimensions.height > 0 ? require_utils_svgFloatingContentUtils.generateSvgFloatingContentPath({
|
|
83
|
+
width: dimensions.width,
|
|
84
|
+
height: dimensions.height,
|
|
85
|
+
placement: effectivePlacement,
|
|
86
|
+
borderRadius,
|
|
87
|
+
arrowCenter: hideArrow ? void 0 : arrowCenter,
|
|
88
|
+
arrowWidth,
|
|
89
|
+
arrowHeight,
|
|
90
|
+
arrowTipRadiusFraction,
|
|
91
|
+
...hideArrow && {
|
|
92
|
+
arrowWidth: 0,
|
|
93
|
+
arrowHeight: 0
|
|
94
|
+
}
|
|
95
|
+
}) : null;
|
|
96
|
+
}, [
|
|
97
|
+
effectivePlacement,
|
|
98
|
+
dimensions.width,
|
|
99
|
+
dimensions.height,
|
|
100
|
+
borderRadius,
|
|
101
|
+
arrowCenter,
|
|
102
|
+
hideArrow,
|
|
103
|
+
arrowWidth,
|
|
104
|
+
arrowHeight,
|
|
105
|
+
arrowTipRadiusFraction
|
|
106
|
+
]);
|
|
107
|
+
const blurClipPath = (0, react.useMemo)(() => {
|
|
108
|
+
if (dimensions.width <= 0 || dimensions.height <= 0) return null;
|
|
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({
|
|
122
|
+
width: dimensions.width,
|
|
123
|
+
height: dimensions.height,
|
|
124
|
+
placement: effectivePlacement,
|
|
125
|
+
borderRadius,
|
|
126
|
+
arrowCenter,
|
|
127
|
+
offsetX,
|
|
128
|
+
offsetY,
|
|
129
|
+
arrowWidth,
|
|
130
|
+
arrowHeight,
|
|
131
|
+
arrowTipRadiusFraction
|
|
132
|
+
});
|
|
133
|
+
}, [
|
|
134
|
+
effectivePlacement,
|
|
135
|
+
dimensions.width,
|
|
136
|
+
dimensions.height,
|
|
137
|
+
borderRadius,
|
|
138
|
+
arrowCenter,
|
|
139
|
+
hideArrow,
|
|
140
|
+
arrowHeight,
|
|
141
|
+
arrowWidth,
|
|
142
|
+
arrowTipRadiusFraction
|
|
143
|
+
]);
|
|
144
|
+
const blurStyle = (0, react.useMemo)(() => {
|
|
145
|
+
const style = {};
|
|
146
|
+
if (blurClipPath && dimensions.width > 0 && dimensions.height > 0) {
|
|
147
|
+
let maskWidth = dimensions.width;
|
|
148
|
+
let maskHeight = dimensions.height;
|
|
149
|
+
if (!hideArrow) {
|
|
150
|
+
const arrowSide = require_utils_svgFloatingContentUtils.getArrowSide(effectivePlacement);
|
|
151
|
+
if (arrowSide === "top" || arrowSide === "bottom") maskHeight += arrowHeight;
|
|
152
|
+
else maskWidth += arrowHeight;
|
|
153
|
+
}
|
|
154
|
+
const svgMask = `<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 ${maskWidth} ${maskHeight}'><path d='${blurClipPath}' fill='white'/></svg>`;
|
|
155
|
+
const maskUrl = `url("data:image/svg+xml,${encodeURIComponent(svgMask)}")`;
|
|
156
|
+
style.WebkitMaskImage = maskUrl;
|
|
157
|
+
style.maskImage = maskUrl;
|
|
158
|
+
style.WebkitMaskSize = "100% 100%";
|
|
159
|
+
style.maskSize = "100% 100%";
|
|
160
|
+
}
|
|
161
|
+
if (!hideArrow) switch (require_utils_svgFloatingContentUtils.getArrowSide(effectivePlacement)) {
|
|
162
|
+
case "top":
|
|
163
|
+
style.height = `calc(100% + ${arrowHeight}px)`;
|
|
164
|
+
style.top = "auto";
|
|
165
|
+
style.bottom = "0";
|
|
166
|
+
break;
|
|
167
|
+
case "bottom":
|
|
168
|
+
style.height = `calc(100% + ${arrowHeight}px)`;
|
|
169
|
+
break;
|
|
170
|
+
case "left":
|
|
171
|
+
style.width = `calc(100% + ${arrowHeight}px)`;
|
|
172
|
+
style.left = "auto";
|
|
173
|
+
style.right = "0";
|
|
174
|
+
break;
|
|
175
|
+
case "right":
|
|
176
|
+
style.width = `calc(100% + ${arrowHeight}px)`;
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
return style;
|
|
180
|
+
}, [
|
|
181
|
+
blurClipPath,
|
|
182
|
+
dimensions.width,
|
|
183
|
+
dimensions.height,
|
|
184
|
+
effectivePlacement,
|
|
185
|
+
hideArrow,
|
|
186
|
+
arrowHeight
|
|
187
|
+
]);
|
|
188
|
+
const [visible, setVisible] = (0, react.useState)(false);
|
|
189
|
+
(0, react.useEffect)(() => {
|
|
190
|
+
const raf = requestAnimationFrame(() => {
|
|
191
|
+
setVisible(open && !!svgPath);
|
|
192
|
+
});
|
|
193
|
+
return () => cancelAnimationFrame(raf);
|
|
194
|
+
}, [open, svgPath]);
|
|
195
|
+
return {
|
|
196
|
+
internalRef,
|
|
197
|
+
shadowFilterId,
|
|
198
|
+
dimensions,
|
|
199
|
+
shadows,
|
|
200
|
+
shadowPadding,
|
|
201
|
+
svgPath,
|
|
202
|
+
blurClipPath,
|
|
203
|
+
blurStyle,
|
|
204
|
+
visible,
|
|
205
|
+
childTransitionStyle: {
|
|
206
|
+
opacity: visible ? 1 : 0,
|
|
207
|
+
transition: `opacity ${animationDuration}ms ease-in-out`
|
|
208
|
+
},
|
|
209
|
+
shift: (0, react.useMemo)(() => {
|
|
210
|
+
if (hideArrow || arrowCenter === void 0 || dimensions.width <= 0 || dimensions.height <= 0) return {
|
|
211
|
+
x: 0,
|
|
212
|
+
y: 0
|
|
213
|
+
};
|
|
214
|
+
return require_utils_svgFloatingContentUtils.getArrowClampDelta({
|
|
215
|
+
width: dimensions.width,
|
|
216
|
+
height: dimensions.height,
|
|
217
|
+
placement: effectivePlacement,
|
|
218
|
+
borderRadius,
|
|
219
|
+
arrowCenter,
|
|
220
|
+
arrowWidth
|
|
221
|
+
});
|
|
222
|
+
}, [
|
|
223
|
+
hideArrow,
|
|
224
|
+
arrowCenter,
|
|
225
|
+
dimensions.width,
|
|
226
|
+
dimensions.height,
|
|
227
|
+
effectivePlacement,
|
|
228
|
+
borderRadius,
|
|
229
|
+
arrowWidth
|
|
230
|
+
]),
|
|
231
|
+
onPositionUpdate
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
//#endregion
|
|
236
|
+
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 };
|