@yahoo/uds 3.114.0-beta.2 → 3.114.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 +3 -0
- package/dist/automated-config/dist/generated/autoVariants.d.cts +3 -0
- package/dist/automated-config/dist/generated/autoVariants.d.ts +3 -0
- package/dist/automated-config/dist/generated/autoVariants.js +3 -0
- package/dist/automated-config/dist/generated/generatedConfigs.cjs +1883 -0
- package/dist/automated-config/dist/generated/generatedConfigs.d.cts +175 -1
- package/dist/automated-config/dist/generated/generatedConfigs.d.ts +175 -1
- package/dist/automated-config/dist/generated/generatedConfigs.js +1882 -1
- package/dist/automated-config/dist/generated/universalTokensConfigAuto.cjs +84 -0
- package/dist/automated-config/dist/generated/universalTokensConfigAuto.d.cts +3 -1
- package/dist/automated-config/dist/generated/universalTokensConfigAuto.d.ts +3 -1
- package/dist/automated-config/dist/generated/universalTokensConfigAuto.js +84 -0
- package/dist/automated-config/dist/mapTextVariantFixtureToValue.cjs +1 -12
- package/dist/automated-config/dist/mapTextVariantFixtureToValue.js +1 -12
- package/dist/automated-config/dist/properties.cjs +58 -12
- package/dist/automated-config/dist/properties.d.cts +8 -0
- package/dist/automated-config/dist/properties.d.ts +8 -0
- package/dist/automated-config/dist/properties.js +58 -12
- package/dist/automated-config/dist/utils/getConfigVariantProperties.d.cts +2 -2
- package/dist/automated-config/dist/utils/getConfigVariantProperties.d.ts +2 -2
- package/dist/cli/commands/sync.cjs +7 -1
- package/dist/cli/commands/sync.d.cts +1 -1
- package/dist/cli/commands/sync.d.ts +1 -1
- package/dist/cli/commands/sync.js +7 -1
- package/dist/cli/commands/version.cjs +2 -0
- package/dist/cli/commands/version.d.cts +1 -1
- package/dist/cli/commands/version.d.ts +1 -1
- package/dist/cli/commands/version.js +2 -0
- package/dist/cli/dist/cli.cjs +1 -1
- package/dist/cli/dist/cli.js +1 -1
- package/dist/cli/dist/commands/editor-rules.cjs +2 -2
- package/dist/cli/dist/commands/editor-rules.js +2 -2
- package/dist/cli/dist/utils/rules/config.cjs +1 -1
- package/dist/cli/dist/utils/rules/config.js +1 -1
- package/dist/cli/runner.cjs +2 -11
- package/dist/cli/runner.js +2 -11
- package/dist/components/Scrim.cjs +28 -0
- package/dist/components/Scrim.d.cts +14 -0
- package/dist/components/Scrim.d.ts +14 -0
- package/dist/components/Scrim.js +26 -0
- package/dist/components/client/BottomSheet/BottomSheet.cjs +209 -0
- package/dist/components/client/BottomSheet/BottomSheet.d.cts +77 -0
- package/dist/components/client/BottomSheet/BottomSheet.d.ts +77 -0
- package/dist/components/client/BottomSheet/BottomSheet.js +207 -0
- package/dist/components/client/BottomSheet/BottomSheetContent.cjs +26 -0
- package/dist/components/client/BottomSheet/BottomSheetContent.d.cts +15 -0
- package/dist/components/client/BottomSheet/BottomSheetContent.d.ts +15 -0
- package/dist/components/client/BottomSheet/BottomSheetContent.js +24 -0
- package/dist/components/client/BottomSheet/BottomSheetDismiss.cjs +15 -0
- package/dist/components/client/BottomSheet/BottomSheetDismiss.d.cts +12 -0
- package/dist/components/client/BottomSheet/BottomSheetDismiss.d.ts +12 -0
- package/dist/components/client/BottomSheet/BottomSheetDismiss.js +13 -0
- package/dist/components/client/BottomSheet/BottomSheetHandle.cjs +30 -0
- package/dist/components/client/BottomSheet/BottomSheetHandle.d.cts +19 -0
- package/dist/components/client/BottomSheet/BottomSheetHandle.d.ts +19 -0
- package/dist/components/client/BottomSheet/BottomSheetHandle.js +28 -0
- package/dist/components/client/BottomSheet/BottomSheetHeader.cjs +42 -0
- package/dist/components/client/BottomSheet/BottomSheetHeader.d.cts +18 -0
- package/dist/components/client/BottomSheet/BottomSheetHeader.d.ts +18 -0
- package/dist/components/client/BottomSheet/BottomSheetHeader.js +40 -0
- package/dist/components/client/BottomSheet/BottomSheetProvider.cjs +21 -0
- package/dist/components/client/BottomSheet/BottomSheetProvider.d.cts +19 -0
- package/dist/components/client/BottomSheet/BottomSheetProvider.d.ts +19 -0
- package/dist/components/client/BottomSheet/BottomSheetProvider.js +19 -0
- package/dist/components/client/BottomSheet/BottomSheetTrigger.cjs +15 -0
- package/dist/components/client/BottomSheet/BottomSheetTrigger.d.cts +12 -0
- package/dist/components/client/BottomSheet/BottomSheetTrigger.d.ts +12 -0
- package/dist/components/client/BottomSheet/BottomSheetTrigger.js +13 -0
- package/dist/components/client/BottomSheet/UDSBottomSheetConfigProvider.cjs +32 -0
- package/dist/components/client/BottomSheet/UDSBottomSheetConfigProvider.d.cts +22 -0
- package/dist/components/client/BottomSheet/UDSBottomSheetConfigProvider.d.ts +22 -0
- package/dist/components/client/BottomSheet/UDSBottomSheetConfigProvider.js +29 -0
- package/dist/components/client/BottomSheet/index.cjs +22 -0
- package/dist/components/client/BottomSheet/index.d.cts +10 -0
- package/dist/components/client/BottomSheet/index.d.ts +10 -0
- package/dist/components/client/BottomSheet/index.js +12 -0
- package/dist/components/client/BottomSheet/useBottomSheetDrag.cjs +188 -0
- package/dist/components/client/BottomSheet/useBottomSheetDrag.d.cts +44 -0
- package/dist/components/client/BottomSheet/useBottomSheetDrag.d.ts +44 -0
- package/dist/components/client/BottomSheet/useBottomSheetDrag.js +185 -0
- package/dist/components/client/BottomSheet/useBottomSheetSnapModel.cjs +138 -0
- package/dist/components/client/BottomSheet/useBottomSheetSnapModel.d.cts +46 -0
- package/dist/components/client/BottomSheet/useBottomSheetSnapModel.d.ts +46 -0
- package/dist/components/client/BottomSheet/useBottomSheetSnapModel.js +135 -0
- package/dist/components/client/BottomSheet/useBottomSheetStore.cjs +34 -0
- package/dist/components/client/BottomSheet/useBottomSheetStore.d.cts +38 -0
- package/dist/components/client/BottomSheet/useBottomSheetStore.d.ts +38 -0
- package/dist/components/client/BottomSheet/useBottomSheetStore.js +31 -0
- package/dist/components/client/BottomSheet/useBottomSheetStoreInternal.cjs +17 -0
- package/dist/components/client/BottomSheet/useBottomSheetStoreInternal.d.cts +13 -0
- package/dist/components/client/BottomSheet/useBottomSheetStoreInternal.d.ts +13 -0
- package/dist/components/client/BottomSheet/useBottomSheetStoreInternal.js +15 -0
- package/dist/components/client/BottomSheet/useExpansionMargins.cjs +89 -0
- package/dist/components/client/BottomSheet/useExpansionMargins.d.cts +34 -0
- package/dist/components/client/BottomSheet/useExpansionMargins.d.ts +34 -0
- package/dist/components/client/BottomSheet/useExpansionMargins.js +87 -0
- package/dist/components/client/BottomSheet/useViewportHeight.cjs +32 -0
- package/dist/components/client/BottomSheet/useViewportHeight.d.cts +9 -0
- package/dist/components/client/BottomSheet/useViewportHeight.d.ts +9 -0
- package/dist/components/client/BottomSheet/useViewportHeight.js +30 -0
- package/dist/components/client/BottomSheet/useVirtualKeyboard.cjs +48 -0
- package/dist/components/client/BottomSheet/useVirtualKeyboard.d.cts +10 -0
- package/dist/components/client/BottomSheet/useVirtualKeyboard.d.ts +10 -0
- package/dist/components/client/BottomSheet/useVirtualKeyboard.js +46 -0
- package/dist/components/client/BottomSheet/utils.cjs +128 -0
- package/dist/components/client/BottomSheet/utils.d.cts +61 -0
- package/dist/components/client/BottomSheet/utils.d.ts +61 -0
- package/dist/components/client/BottomSheet/utils.js +118 -0
- package/dist/components/client/Menu/Menu.Content.cjs +1 -1
- package/dist/components/client/Menu/Menu.Content.js +1 -1
- 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/Menu/Menu.index.d.cts +1 -1
- package/dist/components/client/index.cjs +16 -0
- package/dist/components/client/index.d.cts +10 -1
- package/dist/components/client/index.d.ts +10 -1
- package/dist/components/client/index.js +9 -1
- package/dist/components/client/providers/UDSConfigProvider.cjs +10 -6
- package/dist/components/client/providers/UDSConfigProvider.d.cts +1 -0
- package/dist/components/client/providers/UDSConfigProvider.d.ts +1 -0
- package/dist/components/client/providers/UDSConfigProvider.js +10 -6
- package/dist/components/index.cjs +24 -0
- package/dist/components/index.d.cts +9 -1
- package/dist/components/index.d.ts +9 -1
- package/dist/components/index.js +17 -1
- package/dist/config/dist/index.cjs +110 -2
- package/dist/config/dist/index.js +110 -2
- package/dist/fixtures/dist/index.cjs +103 -0
- package/dist/fixtures/dist/index.d.cts +3 -2
- package/dist/fixtures/dist/index.d.ts +3 -2
- package/dist/fixtures/dist/index.js +103 -1
- package/dist/fixtures/index.cjs +1 -0
- package/dist/fixtures/index.d.cts +2 -2
- package/dist/fixtures/index.d.ts +2 -2
- package/dist/fixtures/index.js +2 -2
- package/dist/index.cjs +20 -2
- package/dist/index.d.cts +12 -5
- package/dist/index.d.ts +12 -5
- package/dist/index.js +11 -3
- package/dist/runtime/bottomSheetConfig.cjs +11 -0
- package/dist/runtime/bottomSheetConfig.d.cts +15 -0
- package/dist/runtime/bottomSheetConfig.d.ts +15 -0
- package/dist/runtime/bottomSheetConfig.js +9 -0
- package/dist/runtime/index.cjs +2 -0
- package/dist/runtime/index.d.cts +2 -1
- package/dist/runtime/index.d.ts +2 -1
- package/dist/runtime/index.js +2 -1
- package/dist/runtime/udsConfig.cjs +2 -0
- package/dist/runtime/udsConfig.d.cts +2 -0
- package/dist/runtime/udsConfig.d.ts +2 -0
- package/dist/runtime/udsConfig.js +2 -0
- package/dist/styles/styler.d.cts +33 -30
- package/dist/styles/styler.d.ts +33 -30
- package/dist/styles/variants.cjs +278 -278
- package/dist/styles/variants.d.cts +9 -0
- package/dist/styles/variants.d.ts +9 -0
- package/dist/styles/variants.js +278 -278
- package/dist/tailwind/dist/commands/generateComponentData.cjs +31 -33
- package/dist/tailwind/dist/commands/generateComponentData.d.ts +1 -1
- package/dist/tailwind/dist/commands/generateComponentData.js +31 -33
- package/dist/tailwind/dist/commands/generatePurgeCSSData.d.ts +1 -1
- package/dist/tailwind/dist/commands/purge.cjs +4 -3
- package/dist/tailwind/dist/commands/purge.d.ts +1 -1
- package/dist/tailwind/dist/commands/purge.js +4 -3
- package/dist/tailwind/dist/index.d.cts +0 -1
- package/dist/tailwind/dist/index.d.ts +3 -5
- package/dist/tailwind/dist/purger/legacy/purgeCSS.cjs +3 -4
- package/dist/tailwind/dist/purger/legacy/purgeCSS.js +3 -4
- package/dist/tailwind/dist/purger/optimized/ast/expressions.cjs +125 -122
- package/dist/tailwind/dist/purger/optimized/ast/expressions.js +125 -122
- package/dist/tailwind/dist/purger/optimized/ast/jsx.cjs +8 -1
- package/dist/tailwind/dist/purger/optimized/ast/jsx.js +8 -1
- package/dist/tailwind/dist/purger/optimized/purge.cjs +10 -11
- package/dist/tailwind/dist/purger/optimized/purge.js +9 -10
- package/dist/tailwind/dist/purger/optimized/purgeFromCode.cjs +127 -232
- package/dist/tailwind/dist/purger/optimized/purgeFromCode.js +127 -232
- package/dist/tailwind/dist/purger/optimized/utils/componentAnalyzer.cjs +262 -330
- package/dist/tailwind/dist/purger/optimized/utils/componentAnalyzer.js +262 -329
- package/dist/tailwind/dist/purger/optimized/utils/files.cjs +3 -4
- package/dist/tailwind/dist/purger/optimized/utils/files.js +3 -4
- package/dist/tailwind/dist/purger/optimized/utils/safelist.cjs +21 -13
- package/dist/tailwind/dist/purger/optimized/utils/safelist.js +21 -13
- package/dist/tailwind/dist/tailwind/plugins/components.cjs +2 -0
- package/dist/tailwind/dist/tailwind/plugins/components.js +3 -1
- package/dist/tailwind/dist/tailwind/plugins/typography.cjs +13 -41
- package/dist/tailwind/dist/tailwind/plugins/typography.js +13 -41
- package/dist/tailwind/dist/tailwind/utils/composeTailwindPlugins.cjs +2 -4
- package/dist/tailwind/dist/tailwind/utils/composeTailwindPlugins.d.cts +1 -10
- package/dist/tailwind/dist/tailwind/utils/composeTailwindPlugins.d.ts +1 -10
- package/dist/tailwind/dist/tailwind/utils/composeTailwindPlugins.js +2 -4
- package/dist/tailwind/dist/utils/tsMorph.cjs +1 -1
- package/dist/tokens/automation/configs/index.cjs +2 -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 +2 -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 -0
- package/dist/tokens/index.d.cts +3 -3
- package/dist/tokens/index.d.ts +3 -3
- package/dist/tokens/index.js +2 -2
- package/dist/tokens/types.d.cts +2 -2
- package/dist/tokens/types.d.ts +2 -2
- package/dist/types/dist/index.d.cts +76 -1
- package/dist/types/dist/index.d.ts +76 -1
- package/dist/uds/generated/componentData.cjs +1187 -961
- package/dist/uds/generated/componentData.js +1111 -939
- package/dist/uds/generated/tailwindPurge.cjs +57 -29
- package/dist/uds/generated/tailwindPurge.js +57 -29
- package/dist/uds/package.cjs +4 -10
- package/dist/uds/package.js +4 -10
- package/package.json +4 -7
- package/dist/cli/dist/lib/logger.cjs +0 -66
- package/dist/cli/dist/lib/logger.js +0 -66
- package/dist/tailwind/dist/commands/css.cjs +0 -79
- package/dist/tailwind/dist/commands/css.d.ts +0 -3
- package/dist/tailwind/dist/commands/css.helpers.cjs +0 -32
- package/dist/tailwind/dist/commands/css.helpers.js +0 -28
- package/dist/tailwind/dist/commands/css.js +0 -79
- package/dist/tailwind/dist/css/generate.cjs +0 -120
- package/dist/tailwind/dist/css/generate.d.cts +0 -30
- package/dist/tailwind/dist/css/generate.d.ts +0 -31
- package/dist/tailwind/dist/css/generate.helpers.cjs +0 -112
- package/dist/tailwind/dist/css/generate.helpers.js +0 -100
- package/dist/tailwind/dist/css/generate.js +0 -115
- package/dist/tailwind/dist/css/postcss.cjs +0 -35
- package/dist/tailwind/dist/css/postcss.helpers.cjs +0 -27
- package/dist/tailwind/dist/css/postcss.helpers.js +0 -26
- package/dist/tailwind/dist/css/postcss.js +0 -35
- package/dist/tailwind/dist/css/runner.cjs +0 -278
- package/dist/tailwind/dist/css/runner.helpers.cjs +0 -26
- package/dist/tailwind/dist/css/runner.helpers.js +0 -23
- package/dist/tailwind/dist/css/runner.js +0 -275
- package/dist/tailwind/dist/css/theme.cjs +0 -12
- package/dist/tailwind/dist/css/theme.d.cts +0 -66
- package/dist/tailwind/dist/css/theme.d.ts +0 -66
- package/dist/tailwind/dist/css/theme.js +0 -11
- package/dist/tailwind/dist/css/utils.cjs +0 -234
- package/dist/tailwind/dist/css/utils.js +0 -223
- package/dist/tailwind/dist/utils/optimizeCSS.cjs +0 -405
- package/dist/tailwind/dist/utils/optimizeCSS.js +0 -403
- package/dist/tailwind/dist/utils/postcssPreserveVars.cjs +0 -67
- package/dist/tailwind/dist/utils/postcssPreserveVars.js +0 -65
- package/generated/componentData.json +0 -2397
- package/generated/tailwindPurge.ts +0 -4560
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
3
|
+
import { useBottomSheetStoreInternal } from "./useBottomSheetStoreInternal.js";
|
|
4
|
+
import { useStoreState } from "@ariakit/react";
|
|
5
|
+
|
|
6
|
+
//#region src/components/client/BottomSheet/useBottomSheetStore.ts
|
|
7
|
+
/** @internal */
|
|
8
|
+
const BOTTOM_SHEET_INTERNAL_STORE_KEY = "__bottomSheetInternal";
|
|
9
|
+
/** @internal */
|
|
10
|
+
function getBottomSheetInternal(controller) {
|
|
11
|
+
const internal = controller[BOTTOM_SHEET_INTERNAL_STORE_KEY];
|
|
12
|
+
if (!internal) throw new Error("Invalid BottomSheet controller. Use `useBottomSheetStore()` to create one.");
|
|
13
|
+
return internal;
|
|
14
|
+
}
|
|
15
|
+
const useBottomSheetStore = ({ animated = true, defaultOpen = false, open: openProp } = {}) => {
|
|
16
|
+
const bottomSheetInternal = useBottomSheetStoreInternal({
|
|
17
|
+
animated,
|
|
18
|
+
open: openProp,
|
|
19
|
+
defaultOpen
|
|
20
|
+
});
|
|
21
|
+
const isOpen = useStoreState(bottomSheetInternal, (state) => state.open);
|
|
22
|
+
return {
|
|
23
|
+
open: bottomSheetInternal.show,
|
|
24
|
+
close: bottomSheetInternal.hide,
|
|
25
|
+
isOpen,
|
|
26
|
+
[BOTTOM_SHEET_INTERNAL_STORE_KEY]: bottomSheetInternal
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { getBottomSheetInternal, useBottomSheetStore };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
|
|
5
|
+
let _ariakit_react = require("@ariakit/react");
|
|
6
|
+
|
|
7
|
+
//#region src/components/client/BottomSheet/useBottomSheetStoreInternal.ts
|
|
8
|
+
const useBottomSheetStoreInternal = ({ animated = true, defaultOpen = false, open } = {}) => {
|
|
9
|
+
return (0, _ariakit_react.useDialogStore)({
|
|
10
|
+
animated,
|
|
11
|
+
open,
|
|
12
|
+
defaultOpen
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
exports.useBottomSheetStoreInternal = useBottomSheetStoreInternal;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
|
|
2
|
+
import * as _ariakit_react0 from "@ariakit/react";
|
|
3
|
+
import { DialogStoreProps } from "@ariakit/react";
|
|
4
|
+
|
|
5
|
+
//#region src/components/client/BottomSheet/useBottomSheetStoreInternal.d.ts
|
|
6
|
+
type UseBottomSheetStoreInternalProps = Pick<DialogStoreProps, 'animated' | 'open' | 'defaultOpen'>;
|
|
7
|
+
declare const useBottomSheetStoreInternal: ({
|
|
8
|
+
animated,
|
|
9
|
+
defaultOpen,
|
|
10
|
+
open
|
|
11
|
+
}?: UseBottomSheetStoreInternalProps) => _ariakit_react0.DialogStore;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { useBottomSheetStoreInternal };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
|
|
2
|
+
import * as _ariakit_react0 from "@ariakit/react";
|
|
3
|
+
import { DialogStoreProps } from "@ariakit/react";
|
|
4
|
+
|
|
5
|
+
//#region src/components/client/BottomSheet/useBottomSheetStoreInternal.d.ts
|
|
6
|
+
type UseBottomSheetStoreInternalProps = Pick<DialogStoreProps, 'animated' | 'open' | 'defaultOpen'>;
|
|
7
|
+
declare const useBottomSheetStoreInternal: ({
|
|
8
|
+
animated,
|
|
9
|
+
defaultOpen,
|
|
10
|
+
open
|
|
11
|
+
}?: UseBottomSheetStoreInternalProps) => _ariakit_react0.DialogStore;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { useBottomSheetStoreInternal };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
3
|
+
import { useDialogStore } from "@ariakit/react";
|
|
4
|
+
|
|
5
|
+
//#region src/components/client/BottomSheet/useBottomSheetStoreInternal.ts
|
|
6
|
+
const useBottomSheetStoreInternal = ({ animated = true, defaultOpen = false, open } = {}) => {
|
|
7
|
+
return useDialogStore({
|
|
8
|
+
animated,
|
|
9
|
+
open,
|
|
10
|
+
defaultOpen
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { useBottomSheetStoreInternal };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
|
|
5
|
+
let react = require("react");
|
|
6
|
+
|
|
7
|
+
//#region src/components/client/BottomSheet/useExpansionMargins.ts
|
|
8
|
+
/**
|
|
9
|
+
* Manages the `fullWidthAtMaxSnap` feature: animates configured CSS margins to 0
|
|
10
|
+
* as the sheet expands from the second-to-last snap point to the max snap point.
|
|
11
|
+
*
|
|
12
|
+
* Returns a stable `applyExpansionMargins` callback (safe for `useCallback([], [])`)
|
|
13
|
+
* and a `thresholdRef` that the caller must set during render after the snap model
|
|
14
|
+
* resolves pixel snap points
|
|
15
|
+
*/
|
|
16
|
+
function useExpansionMargins({ sheetRef, maxSnapPxRef, fullWidthAtMaxSnap, snapPointsLength, isOpen, forceZeroRef }) {
|
|
17
|
+
const thresholdRef = (0, react.useRef)(null);
|
|
18
|
+
const marginsRef = (0, react.useRef)(null);
|
|
19
|
+
const applyExpansionMargins = (0, react.useCallback)((el, currentTranslatePx) => {
|
|
20
|
+
if (forceZeroRef.current) {
|
|
21
|
+
el.style.marginLeft = "0px";
|
|
22
|
+
el.style.marginRight = "0px";
|
|
23
|
+
el.style.marginBottom = "0px";
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const threshold = thresholdRef.current;
|
|
27
|
+
if (threshold == null) return;
|
|
28
|
+
let margins = marginsRef.current;
|
|
29
|
+
if (!margins) {
|
|
30
|
+
el.style.removeProperty("margin-left");
|
|
31
|
+
el.style.removeProperty("margin-right");
|
|
32
|
+
el.style.removeProperty("margin-bottom");
|
|
33
|
+
const computed = getComputedStyle(el);
|
|
34
|
+
const left = parseFloat(computed.marginLeft) || 0;
|
|
35
|
+
const right = parseFloat(computed.marginRight) || 0;
|
|
36
|
+
const bottom = parseFloat(computed.marginBottom) || 0;
|
|
37
|
+
if (left === 0 && right === 0 && bottom === 0) return;
|
|
38
|
+
margins = {
|
|
39
|
+
left,
|
|
40
|
+
right,
|
|
41
|
+
bottom
|
|
42
|
+
};
|
|
43
|
+
marginsRef.current = margins;
|
|
44
|
+
}
|
|
45
|
+
const maxSnap = maxSnapPxRef.current;
|
|
46
|
+
const range = maxSnap - threshold;
|
|
47
|
+
if (range <= 0) return;
|
|
48
|
+
const rawProgress = (maxSnap - currentTranslatePx - threshold) / range;
|
|
49
|
+
const progress = Math.max(0, Math.min(1, rawProgress));
|
|
50
|
+
if (progress <= 0) {
|
|
51
|
+
marginsRef.current = null;
|
|
52
|
+
el.style.removeProperty("margin-left");
|
|
53
|
+
el.style.removeProperty("margin-right");
|
|
54
|
+
el.style.removeProperty("margin-bottom");
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
el.style.marginLeft = `${margins.left * (1 - progress)}px`;
|
|
58
|
+
el.style.marginRight = `${margins.right * (1 - progress)}px`;
|
|
59
|
+
el.style.marginBottom = `${margins.bottom * (1 - progress)}px`;
|
|
60
|
+
}, [
|
|
61
|
+
forceZeroRef,
|
|
62
|
+
maxSnapPxRef,
|
|
63
|
+
thresholdRef,
|
|
64
|
+
marginsRef
|
|
65
|
+
]);
|
|
66
|
+
(0, react.useEffect)(() => {
|
|
67
|
+
if (isOpen && fullWidthAtMaxSnap && snapPointsLength >= 2) return;
|
|
68
|
+
marginsRef.current = null;
|
|
69
|
+
const el = sheetRef.current;
|
|
70
|
+
if (el) {
|
|
71
|
+
el.style.removeProperty("margin-left");
|
|
72
|
+
el.style.removeProperty("margin-right");
|
|
73
|
+
el.style.removeProperty("margin-bottom");
|
|
74
|
+
if (!isOpen) el.style.removeProperty("height");
|
|
75
|
+
}
|
|
76
|
+
}, [
|
|
77
|
+
isOpen,
|
|
78
|
+
fullWidthAtMaxSnap,
|
|
79
|
+
snapPointsLength,
|
|
80
|
+
sheetRef
|
|
81
|
+
]);
|
|
82
|
+
return {
|
|
83
|
+
applyExpansionMargins,
|
|
84
|
+
thresholdRef
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
//#endregion
|
|
89
|
+
exports.useExpansionMargins = useExpansionMargins;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/client/BottomSheet/useExpansionMargins.d.ts
|
|
5
|
+
interface UseExpansionMarginsParams {
|
|
6
|
+
sheetRef: React.RefObject<HTMLElement | null>;
|
|
7
|
+
maxSnapPxRef: React.RefObject<number>;
|
|
8
|
+
fullWidthAtMaxSnap: boolean;
|
|
9
|
+
snapPointsLength: number;
|
|
10
|
+
isOpen: boolean;
|
|
11
|
+
/** When true, forces all margins to 0 (e.g. virtual keyboard visible). */
|
|
12
|
+
forceZeroRef: React.RefObject<boolean>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Manages the `fullWidthAtMaxSnap` feature: animates configured CSS margins to 0
|
|
16
|
+
* as the sheet expands from the second-to-last snap point to the max snap point.
|
|
17
|
+
*
|
|
18
|
+
* Returns a stable `applyExpansionMargins` callback (safe for `useCallback([], [])`)
|
|
19
|
+
* and a `thresholdRef` that the caller must set during render after the snap model
|
|
20
|
+
* resolves pixel snap points
|
|
21
|
+
*/
|
|
22
|
+
declare function useExpansionMargins({
|
|
23
|
+
sheetRef,
|
|
24
|
+
maxSnapPxRef,
|
|
25
|
+
fullWidthAtMaxSnap,
|
|
26
|
+
snapPointsLength,
|
|
27
|
+
isOpen,
|
|
28
|
+
forceZeroRef
|
|
29
|
+
}: UseExpansionMarginsParams): {
|
|
30
|
+
applyExpansionMargins: (el: HTMLElement, currentTranslatePx: number) => void;
|
|
31
|
+
thresholdRef: React.RefObject<number | null>;
|
|
32
|
+
};
|
|
33
|
+
//#endregion
|
|
34
|
+
export { useExpansionMargins };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/client/BottomSheet/useExpansionMargins.d.ts
|
|
5
|
+
interface UseExpansionMarginsParams {
|
|
6
|
+
sheetRef: React.RefObject<HTMLElement | null>;
|
|
7
|
+
maxSnapPxRef: React.RefObject<number>;
|
|
8
|
+
fullWidthAtMaxSnap: boolean;
|
|
9
|
+
snapPointsLength: number;
|
|
10
|
+
isOpen: boolean;
|
|
11
|
+
/** When true, forces all margins to 0 (e.g. virtual keyboard visible). */
|
|
12
|
+
forceZeroRef: React.RefObject<boolean>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Manages the `fullWidthAtMaxSnap` feature: animates configured CSS margins to 0
|
|
16
|
+
* as the sheet expands from the second-to-last snap point to the max snap point.
|
|
17
|
+
*
|
|
18
|
+
* Returns a stable `applyExpansionMargins` callback (safe for `useCallback([], [])`)
|
|
19
|
+
* and a `thresholdRef` that the caller must set during render after the snap model
|
|
20
|
+
* resolves pixel snap points
|
|
21
|
+
*/
|
|
22
|
+
declare function useExpansionMargins({
|
|
23
|
+
sheetRef,
|
|
24
|
+
maxSnapPxRef,
|
|
25
|
+
fullWidthAtMaxSnap,
|
|
26
|
+
snapPointsLength,
|
|
27
|
+
isOpen,
|
|
28
|
+
forceZeroRef
|
|
29
|
+
}: UseExpansionMarginsParams): {
|
|
30
|
+
applyExpansionMargins: (el: HTMLElement, currentTranslatePx: number) => void;
|
|
31
|
+
thresholdRef: React.RefObject<number | null>;
|
|
32
|
+
};
|
|
33
|
+
//#endregion
|
|
34
|
+
export { useExpansionMargins };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
3
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/components/client/BottomSheet/useExpansionMargins.ts
|
|
6
|
+
/**
|
|
7
|
+
* Manages the `fullWidthAtMaxSnap` feature: animates configured CSS margins to 0
|
|
8
|
+
* as the sheet expands from the second-to-last snap point to the max snap point.
|
|
9
|
+
*
|
|
10
|
+
* Returns a stable `applyExpansionMargins` callback (safe for `useCallback([], [])`)
|
|
11
|
+
* and a `thresholdRef` that the caller must set during render after the snap model
|
|
12
|
+
* resolves pixel snap points
|
|
13
|
+
*/
|
|
14
|
+
function useExpansionMargins({ sheetRef, maxSnapPxRef, fullWidthAtMaxSnap, snapPointsLength, isOpen, forceZeroRef }) {
|
|
15
|
+
const thresholdRef = useRef(null);
|
|
16
|
+
const marginsRef = useRef(null);
|
|
17
|
+
const applyExpansionMargins = useCallback((el, currentTranslatePx) => {
|
|
18
|
+
if (forceZeroRef.current) {
|
|
19
|
+
el.style.marginLeft = "0px";
|
|
20
|
+
el.style.marginRight = "0px";
|
|
21
|
+
el.style.marginBottom = "0px";
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const threshold = thresholdRef.current;
|
|
25
|
+
if (threshold == null) return;
|
|
26
|
+
let margins = marginsRef.current;
|
|
27
|
+
if (!margins) {
|
|
28
|
+
el.style.removeProperty("margin-left");
|
|
29
|
+
el.style.removeProperty("margin-right");
|
|
30
|
+
el.style.removeProperty("margin-bottom");
|
|
31
|
+
const computed = getComputedStyle(el);
|
|
32
|
+
const left = parseFloat(computed.marginLeft) || 0;
|
|
33
|
+
const right = parseFloat(computed.marginRight) || 0;
|
|
34
|
+
const bottom = parseFloat(computed.marginBottom) || 0;
|
|
35
|
+
if (left === 0 && right === 0 && bottom === 0) return;
|
|
36
|
+
margins = {
|
|
37
|
+
left,
|
|
38
|
+
right,
|
|
39
|
+
bottom
|
|
40
|
+
};
|
|
41
|
+
marginsRef.current = margins;
|
|
42
|
+
}
|
|
43
|
+
const maxSnap = maxSnapPxRef.current;
|
|
44
|
+
const range = maxSnap - threshold;
|
|
45
|
+
if (range <= 0) return;
|
|
46
|
+
const rawProgress = (maxSnap - currentTranslatePx - threshold) / range;
|
|
47
|
+
const progress = Math.max(0, Math.min(1, rawProgress));
|
|
48
|
+
if (progress <= 0) {
|
|
49
|
+
marginsRef.current = null;
|
|
50
|
+
el.style.removeProperty("margin-left");
|
|
51
|
+
el.style.removeProperty("margin-right");
|
|
52
|
+
el.style.removeProperty("margin-bottom");
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
el.style.marginLeft = `${margins.left * (1 - progress)}px`;
|
|
56
|
+
el.style.marginRight = `${margins.right * (1 - progress)}px`;
|
|
57
|
+
el.style.marginBottom = `${margins.bottom * (1 - progress)}px`;
|
|
58
|
+
}, [
|
|
59
|
+
forceZeroRef,
|
|
60
|
+
maxSnapPxRef,
|
|
61
|
+
thresholdRef,
|
|
62
|
+
marginsRef
|
|
63
|
+
]);
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
if (isOpen && fullWidthAtMaxSnap && snapPointsLength >= 2) return;
|
|
66
|
+
marginsRef.current = null;
|
|
67
|
+
const el = sheetRef.current;
|
|
68
|
+
if (el) {
|
|
69
|
+
el.style.removeProperty("margin-left");
|
|
70
|
+
el.style.removeProperty("margin-right");
|
|
71
|
+
el.style.removeProperty("margin-bottom");
|
|
72
|
+
if (!isOpen) el.style.removeProperty("height");
|
|
73
|
+
}
|
|
74
|
+
}, [
|
|
75
|
+
isOpen,
|
|
76
|
+
fullWidthAtMaxSnap,
|
|
77
|
+
snapPointsLength,
|
|
78
|
+
sheetRef
|
|
79
|
+
]);
|
|
80
|
+
return {
|
|
81
|
+
applyExpansionMargins,
|
|
82
|
+
thresholdRef
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
//#endregion
|
|
87
|
+
export { useExpansionMargins };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
|
|
5
|
+
const require_components_client_BottomSheet_utils = require('./utils.cjs');
|
|
6
|
+
let react = require("react");
|
|
7
|
+
|
|
8
|
+
//#region src/components/client/BottomSheet/useViewportHeight.ts
|
|
9
|
+
/**
|
|
10
|
+
* Hook to get the viewport height in pixels.
|
|
11
|
+
* @returns The viewport height in pixels.
|
|
12
|
+
*/
|
|
13
|
+
function useViewportHeight() {
|
|
14
|
+
const [viewportHeightPx, setViewportHeightPx] = (0, react.useState)(require_components_client_BottomSheet_utils.getViewportHeightPx);
|
|
15
|
+
(0, react.useEffect)(() => {
|
|
16
|
+
if (typeof window === "undefined") return;
|
|
17
|
+
function onResize() {
|
|
18
|
+
setViewportHeightPx(require_components_client_BottomSheet_utils.getViewportHeightPx());
|
|
19
|
+
}
|
|
20
|
+
onResize();
|
|
21
|
+
window.addEventListener("resize", onResize);
|
|
22
|
+
window.visualViewport?.addEventListener("resize", onResize);
|
|
23
|
+
return () => {
|
|
24
|
+
window.removeEventListener("resize", onResize);
|
|
25
|
+
window.visualViewport?.removeEventListener("resize", onResize);
|
|
26
|
+
};
|
|
27
|
+
}, []);
|
|
28
|
+
return viewportHeightPx;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
exports.useViewportHeight = useViewportHeight;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/components/client/BottomSheet/useViewportHeight.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Hook to get the viewport height in pixels.
|
|
5
|
+
* @returns The viewport height in pixels.
|
|
6
|
+
*/
|
|
7
|
+
declare function useViewportHeight(): number;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { useViewportHeight };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/components/client/BottomSheet/useViewportHeight.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Hook to get the viewport height in pixels.
|
|
5
|
+
* @returns The viewport height in pixels.
|
|
6
|
+
*/
|
|
7
|
+
declare function useViewportHeight(): number;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { useViewportHeight };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
3
|
+
import { getViewportHeightPx } from "./utils.js";
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
5
|
+
|
|
6
|
+
//#region src/components/client/BottomSheet/useViewportHeight.ts
|
|
7
|
+
/**
|
|
8
|
+
* Hook to get the viewport height in pixels.
|
|
9
|
+
* @returns The viewport height in pixels.
|
|
10
|
+
*/
|
|
11
|
+
function useViewportHeight() {
|
|
12
|
+
const [viewportHeightPx, setViewportHeightPx] = useState(getViewportHeightPx);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (typeof window === "undefined") return;
|
|
15
|
+
function onResize() {
|
|
16
|
+
setViewportHeightPx(getViewportHeightPx());
|
|
17
|
+
}
|
|
18
|
+
onResize();
|
|
19
|
+
window.addEventListener("resize", onResize);
|
|
20
|
+
window.visualViewport?.addEventListener("resize", onResize);
|
|
21
|
+
return () => {
|
|
22
|
+
window.removeEventListener("resize", onResize);
|
|
23
|
+
window.visualViewport?.removeEventListener("resize", onResize);
|
|
24
|
+
};
|
|
25
|
+
}, []);
|
|
26
|
+
return viewportHeightPx;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
export { useViewportHeight };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
|
|
5
|
+
const require_components_client_BottomSheet_utils = require('./utils.cjs');
|
|
6
|
+
let react = require("react");
|
|
7
|
+
|
|
8
|
+
//#region src/components/client/BottomSheet/useVirtualKeyboard.ts
|
|
9
|
+
/**
|
|
10
|
+
* Minimum keyboard height (px) to treat as a real virtual keyboard.
|
|
11
|
+
* Filters out small residual values (e.g. iOS safe area insets) that
|
|
12
|
+
* don't represent an actual keyboard.
|
|
13
|
+
*/
|
|
14
|
+
const MIN_VIRTUAL_KEYBOARD_HEIGHT_PX = 100;
|
|
15
|
+
/**
|
|
16
|
+
* Hook to get the height of the virtual keyboard.
|
|
17
|
+
* @param isEnabled - Whether the virtual keyboard is enabled.
|
|
18
|
+
* @returns The height of the virtual keyboard in pixels, or 0 if below the minimum threshold.
|
|
19
|
+
*/
|
|
20
|
+
function useVirtualKeyboard(isEnabled) {
|
|
21
|
+
const [keyboardHeightPx, setKeyboardHeightPx] = (0, react.useState)(0);
|
|
22
|
+
const keyboardIsOpenRef = (0, react.useRef)(false);
|
|
23
|
+
(0, react.useEffect)(() => {
|
|
24
|
+
if (!isEnabled) {
|
|
25
|
+
keyboardIsOpenRef.current = false;
|
|
26
|
+
setKeyboardHeightPx(0);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const vv = window.visualViewport;
|
|
30
|
+
if (!vv) return;
|
|
31
|
+
const viewport = vv;
|
|
32
|
+
function onVisualViewportResize() {
|
|
33
|
+
const nextKeyboardHeight = Math.max(window.innerHeight - viewport.height, 0);
|
|
34
|
+
const focused = document.activeElement;
|
|
35
|
+
const keyboardIsOpen = nextKeyboardHeight > 0 && (require_components_client_BottomSheet_utils.isInputLike(focused) || keyboardIsOpenRef.current);
|
|
36
|
+
keyboardIsOpenRef.current = keyboardIsOpen;
|
|
37
|
+
setKeyboardHeightPx(keyboardIsOpen ? nextKeyboardHeight : 0);
|
|
38
|
+
}
|
|
39
|
+
onVisualViewportResize();
|
|
40
|
+
viewport.addEventListener("resize", onVisualViewportResize);
|
|
41
|
+
return () => viewport.removeEventListener("resize", onVisualViewportResize);
|
|
42
|
+
}, [isEnabled]);
|
|
43
|
+
const height = isEnabled ? keyboardHeightPx : 0;
|
|
44
|
+
return height >= MIN_VIRTUAL_KEYBOARD_HEIGHT_PX ? height : 0;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
exports.useVirtualKeyboard = useVirtualKeyboard;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/components/client/BottomSheet/useVirtualKeyboard.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Hook to get the height of the virtual keyboard.
|
|
5
|
+
* @param isEnabled - Whether the virtual keyboard is enabled.
|
|
6
|
+
* @returns The height of the virtual keyboard in pixels, or 0 if below the minimum threshold.
|
|
7
|
+
*/
|
|
8
|
+
declare function useVirtualKeyboard(isEnabled: boolean): number;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { useVirtualKeyboard };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/components/client/BottomSheet/useVirtualKeyboard.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Hook to get the height of the virtual keyboard.
|
|
5
|
+
* @param isEnabled - Whether the virtual keyboard is enabled.
|
|
6
|
+
* @returns The height of the virtual keyboard in pixels, or 0 if below the minimum threshold.
|
|
7
|
+
*/
|
|
8
|
+
declare function useVirtualKeyboard(isEnabled: boolean): number;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { useVirtualKeyboard };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
3
|
+
import { isInputLike } from "./utils.js";
|
|
4
|
+
import { useEffect, useRef, useState } from "react";
|
|
5
|
+
|
|
6
|
+
//#region src/components/client/BottomSheet/useVirtualKeyboard.ts
|
|
7
|
+
/**
|
|
8
|
+
* Minimum keyboard height (px) to treat as a real virtual keyboard.
|
|
9
|
+
* Filters out small residual values (e.g. iOS safe area insets) that
|
|
10
|
+
* don't represent an actual keyboard.
|
|
11
|
+
*/
|
|
12
|
+
const MIN_VIRTUAL_KEYBOARD_HEIGHT_PX = 100;
|
|
13
|
+
/**
|
|
14
|
+
* Hook to get the height of the virtual keyboard.
|
|
15
|
+
* @param isEnabled - Whether the virtual keyboard is enabled.
|
|
16
|
+
* @returns The height of the virtual keyboard in pixels, or 0 if below the minimum threshold.
|
|
17
|
+
*/
|
|
18
|
+
function useVirtualKeyboard(isEnabled) {
|
|
19
|
+
const [keyboardHeightPx, setKeyboardHeightPx] = useState(0);
|
|
20
|
+
const keyboardIsOpenRef = useRef(false);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (!isEnabled) {
|
|
23
|
+
keyboardIsOpenRef.current = false;
|
|
24
|
+
setKeyboardHeightPx(0);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const vv = window.visualViewport;
|
|
28
|
+
if (!vv) return;
|
|
29
|
+
const viewport = vv;
|
|
30
|
+
function onVisualViewportResize() {
|
|
31
|
+
const nextKeyboardHeight = Math.max(window.innerHeight - viewport.height, 0);
|
|
32
|
+
const focused = document.activeElement;
|
|
33
|
+
const keyboardIsOpen = nextKeyboardHeight > 0 && (isInputLike(focused) || keyboardIsOpenRef.current);
|
|
34
|
+
keyboardIsOpenRef.current = keyboardIsOpen;
|
|
35
|
+
setKeyboardHeightPx(keyboardIsOpen ? nextKeyboardHeight : 0);
|
|
36
|
+
}
|
|
37
|
+
onVisualViewportResize();
|
|
38
|
+
viewport.addEventListener("resize", onVisualViewportResize);
|
|
39
|
+
return () => viewport.removeEventListener("resize", onVisualViewportResize);
|
|
40
|
+
}, [isEnabled]);
|
|
41
|
+
const height = isEnabled ? keyboardHeightPx : 0;
|
|
42
|
+
return height >= MIN_VIRTUAL_KEYBOARD_HEIGHT_PX ? height : 0;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
export { useVirtualKeyboard };
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
|
|
5
|
+
let lodash_clamp_js = require("lodash/clamp.js");
|
|
6
|
+
lodash_clamp_js = require_runtime.__toESM(lodash_clamp_js);
|
|
7
|
+
|
|
8
|
+
//#region src/components/client/BottomSheet/utils.ts
|
|
9
|
+
/**
|
|
10
|
+
* Check if an element is an input-like element.
|
|
11
|
+
* @param el - The element to check.
|
|
12
|
+
* @returns True if the element is an input-like element, false otherwise.
|
|
13
|
+
*/
|
|
14
|
+
function isInputLike(el) {
|
|
15
|
+
if (!el) return false;
|
|
16
|
+
const tagName = el.tagName.toLowerCase();
|
|
17
|
+
if (tagName === "input" || tagName === "textarea" || tagName === "select") return true;
|
|
18
|
+
if (el instanceof HTMLElement && el.isContentEditable) return true;
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get the viewport height in pixels.
|
|
23
|
+
* @returns The viewport height in pixels.
|
|
24
|
+
*/
|
|
25
|
+
function getViewportHeightPx() {
|
|
26
|
+
if (typeof window === "undefined") return 0;
|
|
27
|
+
return window.visualViewport?.height ?? window.innerHeight;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Clamp an index into the valid range for an array-like collection.
|
|
31
|
+
*
|
|
32
|
+
* @param index - The candidate index (may be negative or out of bounds).
|
|
33
|
+
* @param length - The collection length.
|
|
34
|
+
* @returns A valid index in the range [0, length - 1]. Returns 0 if length <= 0.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* clampIndex(12, 10) // 9
|
|
38
|
+
* clampIndex(-3, 10) // 0
|
|
39
|
+
* clampIndex(5, 0) // 0
|
|
40
|
+
*/
|
|
41
|
+
function clampIndex(index, length) {
|
|
42
|
+
if (length <= 0) return 0;
|
|
43
|
+
return (0, lodash_clamp_js.default)(index, 0, length - 1);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Resolve a height value to a pixel value.
|
|
47
|
+
* @param height - The height value to resolve.
|
|
48
|
+
* @param viewportHeightPx - The viewport height in pixels.
|
|
49
|
+
* @returns The resolved height in pixels.
|
|
50
|
+
*/
|
|
51
|
+
function resolveHeightToPx(height, viewportHeightPx) {
|
|
52
|
+
if (typeof height === "number") return height;
|
|
53
|
+
const trimmed = height.trim();
|
|
54
|
+
if (trimmed.endsWith("%")) {
|
|
55
|
+
const pct = Number.parseFloat(trimmed.slice(0, -1));
|
|
56
|
+
if (Number.isFinite(pct)) return pct / 100 * viewportHeightPx;
|
|
57
|
+
}
|
|
58
|
+
if (trimmed.endsWith("px")) {
|
|
59
|
+
const px = Number.parseFloat(trimmed.slice(0, -2));
|
|
60
|
+
if (Number.isFinite(px)) return px;
|
|
61
|
+
}
|
|
62
|
+
const fallback = Number.parseFloat(trimmed);
|
|
63
|
+
return Number.isFinite(fallback) ? fallback : 0;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Check if an element is scrollable.
|
|
67
|
+
* @param el - The element to check.
|
|
68
|
+
* @returns True if the element is scrollable, false otherwise.
|
|
69
|
+
*/
|
|
70
|
+
function isScrollable(el) {
|
|
71
|
+
return el.scrollHeight > el.clientHeight;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Check if a drag event should be prevented from the target element.
|
|
75
|
+
* @param target - The target element.
|
|
76
|
+
* @returns True if the drag event should be prevented, false otherwise.
|
|
77
|
+
*/
|
|
78
|
+
function shouldPreventDragFromTarget(target) {
|
|
79
|
+
const element = target instanceof Element ? target : null;
|
|
80
|
+
if (!element) return false;
|
|
81
|
+
if (element.tagName.toUpperCase() === "SELECT") return true;
|
|
82
|
+
return !!element.closest("[data-bottomsheet-no-drag]");
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Get the translateY value of an element's transform.
|
|
86
|
+
* @param el - The element to get the translateY value of.
|
|
87
|
+
* @returns The translateY value in pixels.
|
|
88
|
+
*/
|
|
89
|
+
function getTranslateY(el) {
|
|
90
|
+
if (!el) return 0;
|
|
91
|
+
const style = window.getComputedStyle(el);
|
|
92
|
+
const transform = style.getPropertyValue("transform") || style.getPropertyValue("-webkit-transform") || style.getPropertyValue("-moz-transform");
|
|
93
|
+
if (!transform || transform === "none") return 0;
|
|
94
|
+
const mat3d = transform.match(/^matrix3d\((.+)\)$/);
|
|
95
|
+
if (mat3d) {
|
|
96
|
+
const parts = mat3d[1].split(",").map((p) => p.trim());
|
|
97
|
+
return Number.parseFloat(parts[13] ?? "0") || 0;
|
|
98
|
+
}
|
|
99
|
+
const mat2d = transform.match(/^matrix\((.+)\)$/);
|
|
100
|
+
if (mat2d) {
|
|
101
|
+
const parts = mat2d[1].split(",").map((p) => p.trim());
|
|
102
|
+
return Number.parseFloat(parts[5] ?? "0") || 0;
|
|
103
|
+
}
|
|
104
|
+
return 0;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Parse a max snap point ratio from a string.
|
|
108
|
+
* @param rawValue - The raw value to parse.
|
|
109
|
+
* @returns The parsed max snap point ratio.
|
|
110
|
+
*/
|
|
111
|
+
function parseMaxSnapPointRatio(rawValue) {
|
|
112
|
+
const trimmed = rawValue.trim();
|
|
113
|
+
if (!trimmed) return 1;
|
|
114
|
+
const value = trimmed.endsWith("%") ? trimmed.slice(0, -1) : trimmed;
|
|
115
|
+
const parsed = Number.parseFloat(value);
|
|
116
|
+
if (!Number.isFinite(parsed)) return 1;
|
|
117
|
+
return Math.min(Math.max(parsed / 100, 0), 1);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
//#endregion
|
|
121
|
+
exports.clampIndex = clampIndex;
|
|
122
|
+
exports.getTranslateY = getTranslateY;
|
|
123
|
+
exports.getViewportHeightPx = getViewportHeightPx;
|
|
124
|
+
exports.isInputLike = isInputLike;
|
|
125
|
+
exports.isScrollable = isScrollable;
|
|
126
|
+
exports.parseMaxSnapPointRatio = parseMaxSnapPointRatio;
|
|
127
|
+
exports.resolveHeightToPx = resolveHeightToPx;
|
|
128
|
+
exports.shouldPreventDragFromTarget = shouldPreventDragFromTarget;
|