@preply/ds-web-lib 10.0.0 → 11.1.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/Accordion-B0hR-tcI.js +96 -0
- package/dist/AlertBannerProvider-Cf7w9AOq.js +76 -0
- package/dist/AlertDialog-BG-diKBi.js +475 -0
- package/dist/Avatar-B-JdqVyg.js +66 -0
- package/dist/AvatarWithStatus-CD9jEqEB.js +36 -0
- package/dist/Badge-Dd-CLBoW.js +50 -0
- package/dist/Box-BJBE9KNm.js +91 -0
- package/dist/BubbleCounter.module-BU2S0euA.js +16 -0
- package/dist/Button-C35BZJZT.js +91 -0
- package/dist/ButtonBase-8eUyTWxX.js +215 -0
- package/dist/Checkbox-CtolNbxI.js +108 -0
- package/dist/Chips-BRGw7Uup.js +99 -0
- package/dist/ChipsPrimitive-Bezq7ptE.js +1179 -0
- package/dist/CountryFlag-DVDKHmQH.js +43 -0
- package/dist/Dialog.module-Db2BJAn4.js +21 -0
- package/dist/DialogCloseButton-DjDd9Mid.js +98 -0
- package/dist/DialogDescription-8zw9t6pm.js +44 -0
- package/dist/DialogRoot-B67oJduC.js +335 -0
- package/dist/DialogRootContext-Bz8RW-Mq.js +12 -0
- package/dist/DialogTitle-C2Nn2ys-.js +43 -0
- package/dist/Divider-DvwDWB9_.js +17 -0
- package/dist/DropdownMenu.primitives-BrsTBvMk.js +4007 -0
- package/dist/FieldButton-B2slox8P.js +32 -0
- package/dist/FormControl-qnbQL1iF.js +128 -0
- package/dist/Heading-DA9gHfsx.js +71 -0
- package/dist/Icon-CixAeOSd.js +48 -0
- package/dist/IconButton-BPKpgfep.js +31 -0
- package/dist/InputContainer-CzzuOe_p.js +38 -0
- package/dist/LayoutFlex-e9auDvWD.js +86 -0
- package/dist/LayoutFlexItem-D9ziMmHe.js +48 -0
- package/dist/LayoutGridItem-Q8Lnvrri.js +34 -0
- package/dist/Link-CdoJVeER.js +66 -0
- package/dist/Loader-BMOxdJce.js +26 -0
- package/dist/OnboardingTooltip-B47_Yrsj.js +165 -0
- package/dist/OnboardingTour-DUUoI5WE.js +131 -0
- package/dist/PasswordField-Bx5YG62t.js +93 -0
- package/dist/PreplyLogo-abgOre30.js +112 -0
- package/dist/ProgressBar-CEU4GyHn.js +31 -0
- package/dist/ProgressSteps-BSqopxqv.js +45 -0
- package/dist/Select-Bo7PX_8V.js +124 -0
- package/dist/Slider-Crg4DEn_.js +64 -0
- package/dist/Spinner-Ck8KQA22.js +86 -0
- package/dist/Stars-D5QspUBE.js +72 -0
- package/dist/Steps-DbN5vFrP.js +173 -0
- package/dist/Switch-Ck_xB0ID.js +49 -0
- package/dist/Text-CaOF75Z-.js +121 -0
- package/dist/TextHighlighted-Dwq9Clgn.js +34 -0
- package/dist/TextInline-BcA4H2Tk.js +34 -0
- package/dist/Toast-wJAjSLfo.js +1019 -0
- package/dist/TokyoUIChevronDown-DGcVqR1z.js +14 -0
- package/dist/Tooltip-grvKQxTN.js +84 -0
- package/dist/VisuallyHidden-CtcHcZCK.js +29 -0
- package/dist/align-self-VrZUceie.js +42 -0
- package/dist/assets/Accordion.css +2 -2
- package/dist/assets/AlertBannerProvider.css +2 -2
- package/dist/assets/AlertDialog.css +2 -2
- package/dist/assets/Avatar.css +3 -3
- package/dist/assets/AvatarWithStatus.css +2 -2
- package/dist/assets/Badge.css +1 -1
- package/dist/assets/Box.css +3 -3
- package/dist/assets/BubbleCounter.css +1 -1
- package/dist/assets/Button.css +4 -4
- package/dist/assets/ButtonBase.css +40 -46
- package/dist/assets/Checkbox.css +1 -1
- package/dist/assets/Chips.css +2 -2
- package/dist/assets/ChipsPrimitive.css +2 -2
- package/dist/assets/CountryFlag.css +1 -1
- package/dist/assets/Dialog.css +13 -4
- package/dist/assets/Divider.css +1 -1
- package/dist/assets/DropdownMenu.css +2 -2
- package/dist/assets/FieldButton.css +3 -3
- package/dist/assets/FormControl.css +1 -1
- package/dist/assets/Heading.css +3 -3
- package/dist/assets/Icon.css +3 -3
- package/dist/assets/InputContainer.css +2 -2
- package/dist/assets/LayoutFlex.css +1 -1
- package/dist/assets/LayoutFlexItem.css +1 -1
- package/dist/assets/Link.css +3 -3
- package/dist/assets/Loader.css +1 -1
- package/dist/assets/OnboardingTooltip.css +6 -4
- package/dist/assets/OnboardingTour.css +3 -2
- package/dist/assets/PreplyLogo.css +1 -1
- package/dist/assets/ProgressBar.css +1 -1
- package/dist/assets/ProgressSteps.css +1 -1
- package/dist/assets/Select.css +2 -2
- package/dist/assets/Slider.css +1 -1
- package/dist/assets/Spinner.css +3 -3
- package/dist/assets/Stars.css +3 -3
- package/dist/assets/Steps.css +2 -2
- package/dist/assets/Switch.css +1 -1
- package/dist/assets/Text.css +3 -3
- package/dist/assets/TextHighlighted.css +3 -3
- package/dist/assets/TextInline.css +3 -3
- package/dist/assets/Toast.css +2 -2
- package/dist/assets/Tooltip.css +1 -1
- package/dist/assets/align-self.css +1 -1
- package/dist/assets/{IconTile.css → components.css} +9 -1
- package/dist/assets/exp-color.css +2 -2
- package/dist/assets/index.css +1 -1
- package/dist/assets/layout-gap.css +3 -3
- package/dist/assets/layout-grid.css +3 -3
- package/dist/assets/layout-hide.css +1 -1
- package/dist/assets/layout-padding.css +3 -3
- package/dist/assets/layout-relative.css +1 -1
- package/dist/assets/text-accent.css +2 -2
- package/dist/assets/text-centered.css +1 -1
- package/dist/assets/text-weight.css +2 -2
- package/dist/chunk-BVTlhY3a.js +24 -0
- package/dist/components/Accordion/Accordion.js +4 -60
- package/dist/components/Accordion/hooks/useOnOpenChange.js +19 -28
- package/dist/components/AlertBanner/AlertBanner.js +11 -26
- package/dist/components/AlertBanner/AlertBannerProvider.js +3 -8
- package/dist/components/AlertBanner/primitives/AlertBannerAction.js +11 -69
- package/dist/components/AlertBanner/primitives/AlertBannerIcon.js +77 -39
- package/dist/components/AlertBanner/primitives/AlertBannerRoot.js +26 -22
- package/dist/components/AlertBanner/primitives/AlertBannerText.js +11 -70
- package/dist/components/AlertDialog/AlertDialog.d.ts +3 -3
- package/dist/components/AlertDialog/AlertDialog.d.ts.map +1 -1
- package/dist/components/AlertDialog/AlertDialog.js +5 -94
- package/dist/components/Avatar/Avatar.js +3 -71
- package/dist/components/AvatarWithStatus/AvatarWithStatus.js +3 -43
- package/dist/components/Badge/Badge.js +4 -62
- package/dist/components/Box/Box.js +3 -95
- package/dist/components/BubbleCounter/BubbleCounter.js +23 -28
- package/dist/components/Button/Button.js +4 -80
- package/dist/components/CalloutBanner/CalloutBanner.js +61 -12
- package/dist/components/CalloutBanner/primitives/CalloutBannerDismissButton.js +50 -22
- package/dist/components/CalloutBanner/primitives/CalloutBannerIcon.js +86 -45
- package/dist/components/CalloutBanner/primitives/CalloutBannerRoot.js +50 -24
- package/dist/components/CalloutBanner/primitives/CalloutBannerText.js +41 -11
- package/dist/components/Checkbox/Checkbox.js +4 -78
- package/dist/components/Checkbox/hooks/useIndeterminate.js +24 -30
- package/dist/components/Chips/Chips.types.js +0 -1
- package/dist/components/Chips/DismissibleChips.js +117 -86
- package/dist/components/Chips/MultiSelectChips.js +98 -64
- package/dist/components/Chips/SingleSelectChips.js +94 -57
- package/dist/components/Chips/private/ChipsPrimitive.js +4 -17
- package/dist/components/CountryFlag/CountryFlag.js +3 -44
- package/dist/components/Dialog/Dialog.js +56 -31
- package/dist/components/Dialog/DialogSteps.js +40 -29
- package/dist/components/Dialog/primitives/DialogActions.js +26 -19
- package/dist/components/Dialog/primitives/DialogButtonStack.d.ts.map +1 -1
- package/dist/components/Dialog/primitives/DialogButtonStack.js +22 -15
- package/dist/components/Dialog/primitives/DialogCloseButton.d.ts +1 -1
- package/dist/components/Dialog/primitives/DialogCloseButton.d.ts.map +1 -1
- package/dist/components/Dialog/primitives/DialogCloseButton.js +4 -93
- package/dist/components/Dialog/primitives/DialogDescription.js +3 -43
- package/dist/components/Dialog/primitives/DialogFooter.js +37 -34
- package/dist/components/Dialog/primitives/DialogRoot.js +4 -1459
- package/dist/components/Dialog/primitives/DialogTitle.js +3 -42
- package/dist/components/Divider/Divider.js +3 -14
- package/dist/components/DropdownMenu/DropdownMenu.js +253 -188
- package/dist/components/DropdownMenu/primitives/DropdownMenu.primitives.js +5 -34
- package/dist/components/DropdownMenu/primitives/DropdownMenuSelectItem.primitives.js +121 -71
- package/dist/components/FieldButton/FieldButton.js +3 -37
- package/dist/components/FormControl/FormControl.js +3 -105
- package/dist/components/Heading/Heading.js +3 -78
- package/dist/components/Icon/Icon.js +4 -49
- package/dist/components/IconButton/IconButton.d.ts +5 -1
- package/dist/components/IconButton/IconButton.d.ts.map +1 -1
- package/dist/components/IconButton/IconButton.js +4 -28
- package/dist/components/IconTile/IconTile.js +11 -69
- package/dist/components/IntlFormatted/IntlFormattedAggregatedDateTime.js +16 -32
- package/dist/components/IntlFormatted/IntlFormattedCurrency.js +20 -42
- package/dist/components/IntlFormatted/IntlFormattedDate.js +73 -195
- package/dist/components/IntlFormatted/IntlFormattedTime.js +14 -24
- package/dist/components/IntlFormatted/Wrapper.js +14 -8
- package/dist/components/LayoutFlex/LayoutFlex.js +3 -100
- package/dist/components/LayoutFlex/style/getStyleAttrs.js +71 -143
- package/dist/components/LayoutFlex/tests/AlignItems.js +67 -97
- package/dist/components/LayoutFlex/tests/ColumnReverse.js +63 -100
- package/dist/components/LayoutFlex/tests/DataOverride.js +1498 -1093
- package/dist/components/LayoutFlex/tests/Default.js +19 -20
- package/dist/components/LayoutFlex/tests/Direction.js +65 -88
- package/dist/components/LayoutFlex/tests/Gap.js +115 -197
- package/dist/components/LayoutFlex/tests/HideInline.js +95 -136
- package/dist/components/LayoutFlex/tests/JustifyContent.js +75 -108
- package/dist/components/LayoutFlex/tests/Nowrap.js +35 -42
- package/dist/components/LayoutFlex/tests/Padding.js +207 -263
- package/dist/components/LayoutFlex/tests/Relative.js +49 -64
- package/dist/components/LayoutFlexItem/LayoutFlexItem.js +3 -54
- package/dist/components/LayoutGrid/LayoutGrid.js +26 -34
- package/dist/components/LayoutGridItem/LayoutGridItem.js +3 -41
- package/dist/components/Link/Link.js +3 -72
- package/dist/components/Loader/Loader.js +3 -32
- package/dist/components/NumberField/NumberField.js +33 -35
- package/dist/components/ObserveIntersection/ObserveIntersection.js +41 -42
- package/dist/components/OnboardingTooltip/OnboardingTooltip.js +4 -115
- package/dist/components/OnboardingTour/OnboardingTour.js +4 -114
- package/dist/components/PasswordField/PasswordField.js +3 -78
- package/dist/components/PreplyLogo/PreplyLogo.js +3 -81
- package/dist/components/ProgressBar/ProgressBar.js +3 -27
- package/dist/components/ProgressSteps/ProgressSteps.js +3 -48
- package/dist/components/Rating/Rating.js +29 -20
- package/dist/components/Rating/RatingInput.js +57 -59
- package/dist/components/Rating/Stars.js +4 -8
- package/dist/components/Rating/hooks/useHasError.js +11 -15
- package/dist/components/Rating/hooks/useHoverPercentage.js +37 -45
- package/dist/components/Rating/hooks/useInputState.js +18 -24
- package/dist/components/Rating/hooks/useLocalizations.js +12 -24
- package/dist/components/Rating/utils/roundToHalfDecimal.js +4 -4
- package/dist/components/SelectField/Select.js +5 -112
- package/dist/components/SelectField/SelectField.js +29 -24
- package/dist/components/SelectField/hooks/useBreakpointMatch.js +18 -19
- package/dist/components/ShowOnIntersection/ShowOnIntersection.js +32 -21
- package/dist/components/Slider/RangeSlider.js +62 -52
- package/dist/components/Slider/Slider.js +3 -10
- package/dist/components/Steps/Steps.js +4 -210
- package/dist/components/Switch/Switch.js +3 -51
- package/dist/components/Text/Text.js +3 -128
- package/dist/components/TextField/TextField.js +27 -29
- package/dist/components/TextHighlighted/TextHighlighted.js +3 -41
- package/dist/components/TextInline/TextInline.js +3 -40
- package/dist/components/TextareaField/TextareaField.js +26 -28
- package/dist/components/Toast/Toast.js +4 -1168
- package/dist/components/Tooltip/Tooltip.js +3 -66
- package/dist/components/deprecated/Chips/Chips.js +4 -76
- package/dist/components/deprecated/NativeSelectField/NativeSelect.js +40 -32
- package/dist/components/deprecated/NativeSelectField/NativeSelectField.js +34 -33
- package/dist/components/deprecated/index.js +5 -6
- package/dist/components/index.js +50 -150
- package/dist/components/private/ButtonBase/ButtonBase.d.ts +7 -11
- package/dist/components/private/ButtonBase/ButtonBase.d.ts.map +1 -1
- package/dist/components/private/ButtonBase/ButtonBase.js +3 -247
- package/dist/components/private/Input/Input.js +27 -19
- package/dist/components/private/Input/InputContainer.js +3 -5
- package/dist/components/private/Input/Textarea.js +24 -20
- package/dist/components/private/Input/index.js +2 -4
- package/dist/components/private/Spinner/Spinner.js +3 -52
- package/dist/components/private/VisuallyHidden/VisuallyHidden.js +3 -15
- package/dist/components-BIYP8wHJ.js +200 -0
- package/dist/exp-color-C5mKAN91.js +74 -0
- package/dist/floating-ui.utils.dom-CoeTbDZx.js +215 -0
- package/dist/index.js +50 -150
- package/dist/index.module-1c7ENvxc.js +7 -0
- package/dist/jsx-runtime-i4KUlhDu.js +743 -0
- package/dist/layout-gap.module-DLD8bcR4.js +95 -0
- package/dist/layout-grid.module-CZfhrKrB.js +101 -0
- package/dist/layout-hide.module-B1P0N4i3.js +53 -0
- package/dist/layout-padding-ugY-yd2q.js +389 -0
- package/dist/layout-relative.module-B5xrFD9j.js +6 -0
- package/dist/render-icon-Ch3b2dE0.js +290 -0
- package/dist/shared-styles/align-self/align-self.js +2 -36
- package/dist/shared-styles/exp-color/exp-color.js +2 -68
- package/dist/shared-styles/layout-gap/layout-gap.js +13 -7
- package/dist/shared-styles/layout-grid/layout-grid.js +28 -28
- package/dist/shared-styles/layout-grid-responsive-columns/layout-grid-responsive-columns.js +29 -43
- package/dist/shared-styles/layout-hide/layout-hide.js +8 -8
- package/dist/shared-styles/layout-padding/layout-padding.js +2 -5
- package/dist/shared-styles/layout-relative/layout-relative.js +14 -8
- package/dist/shared-styles/text-accent/text-accent.js +2 -25
- package/dist/shared-styles/text-centered/text-centered.js +2 -24
- package/dist/shared-styles/text-weight/text-weight.js +2 -15
- package/dist/store-sN_eYeZT.js +1064 -0
- package/dist/storybook-utils/consts.js +6 -8
- package/dist/storybook-utils/index.js +1 -5
- package/dist/text-accent-CfUFx-1K.js +30 -0
- package/dist/text-centered-Dwp2_-Yp.js +30 -0
- package/dist/text-weight-CwoqmM4o.js +21 -0
- package/dist/useBaseUiId-CWAD_PSs.js +13 -0
- package/dist/useBreakpointMatch-D9a3CTNK.js +338 -0
- package/dist/useButton-DHTh3Hm7.js +148 -0
- package/dist/useDialogClose-BzFIyWco.js +22 -0
- package/dist/useId-CJsH-2wV.js +34 -0
- package/dist/useOpenInteractionType-D8vA_ZKI.js +4104 -0
- package/dist/useRenderElement-ZBds6eRN.js +341 -0
- package/dist/utils/Orientation/OrientationProvider.js +54 -23
- package/dist/utils/Orientation/index.js +2 -4
- package/dist/utils/RovingTabIndex/RovingTabIndexProvider.js +70 -44
- package/dist/utils/RovingTabIndex/index.js +2 -4
- package/dist/utils/createRequiredContext.js +23 -13
- package/dist/utils/filterAttributesPassedByRadixUIAtRuntime.js +28 -25
- package/dist/utils/render-icon.js +3 -320
- package/dist/utils/shared-strings.js +24 -32
- package/dist/utils/useBreakpointMatch.d.ts.map +1 -1
- package/dist/utils/useBreakpointMatch.js +2 -183
- package/dist/utils/useControllableState/useControllableState.js +31 -25
- package/dist/utils/useMergeRefs.js +29 -14
- package/dist/utils/useStableCallback/useStableCallback.js +28 -13
- package/package.json +17 -22
- package/dist/AlertBannerProvider-DTx2Xp3V.js +0 -50
- package/dist/BubbleCounter.module-QMwXWFIS.js +0 -16
- package/dist/ChipsPrimitive-DzsaOWgY.js +0 -1244
- package/dist/Dialog.module-Ba1X7b3N.js +0 -29
- package/dist/DialogRootContext-BCXmmJAw.js +0 -15
- package/dist/DropdownMenu.primitives-CqJE9k4D.js +0 -5871
- package/dist/IconTile-D1G7MljH.js +0 -172
- package/dist/InputContainer-oHJlLWIi.js +0 -30
- package/dist/Slider-DB4Maswa.js +0 -55
- package/dist/Stars-C_mHop2H.js +0 -67
- package/dist/TokyoUIChevronDown-D_tD1yU8.js +0 -11
- package/dist/floating-ui.utils.dom-BvMNldxo.js +0 -234
- package/dist/index.module-Q9TzIR6B.js +0 -11
- package/dist/layout-gap.module-MKn_un_k.js +0 -97
- package/dist/layout-grid.module-P4B4WVUy.js +0 -103
- package/dist/layout-hide.module-Bpl3Pl-a.js +0 -55
- package/dist/layout-padding-D5I6rRlL.js +0 -373
- package/dist/layout-relative.module-1z75aSwo.js +0 -8
- package/dist/useBaseUiId-DavsGYu9.js +0 -8
- package/dist/useButton-fjQ0ak8m.js +0 -193
- package/dist/useId-BhIOp2JG.js +0 -28
- package/dist/useOpenInteractionType-DNYFqf-a.js +0 -2880
- package/dist/useRenderElement-BSthtPOr.js +0 -350
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { t as require_jsx_runtime } from "./jsx-runtime-i4KUlhDu.js";
|
|
3
|
+
import * as React$1 from "react";
|
|
4
|
+
//#region ../../node_modules/@base-ui-components/utils/esm/useRefWithInit.js
|
|
5
|
+
var UNINITIALIZED = {};
|
|
6
|
+
/**
|
|
7
|
+
* A React.useRef() that is initialized with a function. Note that it accepts an optional
|
|
8
|
+
* initialization argument, so the initialization function doesn't need to be an inline closure.
|
|
9
|
+
*
|
|
10
|
+
* @usage
|
|
11
|
+
* const ref = useRefWithInit(sortColumns, columns)
|
|
12
|
+
*/
|
|
13
|
+
function useRefWithInit(init, initArg) {
|
|
14
|
+
const ref = React$1.useRef(UNINITIALIZED);
|
|
15
|
+
if (ref.current === UNINITIALIZED) ref.current = init(initArg);
|
|
16
|
+
return ref;
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region ../../node_modules/@base-ui-components/utils/esm/empty.js
|
|
20
|
+
function NOOP() {}
|
|
21
|
+
var EMPTY_ARRAY = Object.freeze([]);
|
|
22
|
+
var EMPTY_OBJECT = Object.freeze({});
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region ../../node_modules/@base-ui-components/react/esm/utils/constants.js
|
|
25
|
+
var DISABLED_TRANSITIONS_STYLE = { style: { transition: "none" } };
|
|
26
|
+
var CLICK_TRIGGER_IDENTIFIER = "data-base-ui-click-trigger";
|
|
27
|
+
/**
|
|
28
|
+
* Used for dropdowns that usually strictly prefer top/bottom placements and
|
|
29
|
+
* use `var(--available-height)` to limit their height.
|
|
30
|
+
*/
|
|
31
|
+
var DROPDOWN_COLLISION_AVOIDANCE = { fallbackAxisSide: "none" };
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region ../../node_modules/@base-ui-components/utils/esm/useMergedRefs.js
|
|
34
|
+
/**
|
|
35
|
+
* Merges refs into a single memoized callback ref or `null`.
|
|
36
|
+
* This makes sure multiple refs are updated together and have the same value.
|
|
37
|
+
*
|
|
38
|
+
* This function accepts up to four refs. If you need to merge more, or have an unspecified number of refs to merge,
|
|
39
|
+
* use `useMergedRefsN` instead.
|
|
40
|
+
*/
|
|
41
|
+
function useMergedRefs(a, b, c, d) {
|
|
42
|
+
const forkRef = useRefWithInit(createForkRef).current;
|
|
43
|
+
if (didChange(forkRef, a, b, c, d)) update(forkRef, [
|
|
44
|
+
a,
|
|
45
|
+
b,
|
|
46
|
+
c,
|
|
47
|
+
d
|
|
48
|
+
]);
|
|
49
|
+
return forkRef.callback;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Merges an array of refs into a single memoized callback ref or `null`.
|
|
53
|
+
*
|
|
54
|
+
* If you need to merge a fixed number (up to four) of refs, use `useMergedRefs` instead for better performance.
|
|
55
|
+
*/
|
|
56
|
+
function useMergedRefsN(refs) {
|
|
57
|
+
const forkRef = useRefWithInit(createForkRef).current;
|
|
58
|
+
if (didChangeN(forkRef, refs)) update(forkRef, refs);
|
|
59
|
+
return forkRef.callback;
|
|
60
|
+
}
|
|
61
|
+
function createForkRef() {
|
|
62
|
+
return {
|
|
63
|
+
callback: null,
|
|
64
|
+
cleanup: null,
|
|
65
|
+
refs: []
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function didChange(forkRef, a, b, c, d) {
|
|
69
|
+
return forkRef.refs[0] !== a || forkRef.refs[1] !== b || forkRef.refs[2] !== c || forkRef.refs[3] !== d;
|
|
70
|
+
}
|
|
71
|
+
function didChangeN(forkRef, newRefs) {
|
|
72
|
+
return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index) => ref !== newRefs[index]);
|
|
73
|
+
}
|
|
74
|
+
function update(forkRef, refs) {
|
|
75
|
+
forkRef.refs = refs;
|
|
76
|
+
if (refs.every((ref) => ref == null)) {
|
|
77
|
+
forkRef.callback = null;
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
forkRef.callback = (instance) => {
|
|
81
|
+
if (forkRef.cleanup) {
|
|
82
|
+
forkRef.cleanup();
|
|
83
|
+
forkRef.cleanup = null;
|
|
84
|
+
}
|
|
85
|
+
if (instance != null) {
|
|
86
|
+
const cleanupCallbacks = Array(refs.length).fill(null);
|
|
87
|
+
for (let i = 0; i < refs.length; i += 1) {
|
|
88
|
+
const ref = refs[i];
|
|
89
|
+
if (ref == null) continue;
|
|
90
|
+
switch (typeof ref) {
|
|
91
|
+
case "function": {
|
|
92
|
+
const refCleanup = ref(instance);
|
|
93
|
+
if (typeof refCleanup === "function") cleanupCallbacks[i] = refCleanup;
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
case "object":
|
|
97
|
+
ref.current = instance;
|
|
98
|
+
break;
|
|
99
|
+
default:
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
forkRef.cleanup = () => {
|
|
103
|
+
for (let i = 0; i < refs.length; i += 1) {
|
|
104
|
+
const ref = refs[i];
|
|
105
|
+
if (ref == null) continue;
|
|
106
|
+
switch (typeof ref) {
|
|
107
|
+
case "function": {
|
|
108
|
+
const cleanupCallback = cleanupCallbacks[i];
|
|
109
|
+
if (typeof cleanupCallback === "function") cleanupCallback();
|
|
110
|
+
else ref(null);
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
case "object":
|
|
114
|
+
ref.current = null;
|
|
115
|
+
break;
|
|
116
|
+
default:
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region ../../node_modules/@base-ui-components/utils/esm/reactVersion.js
|
|
125
|
+
var majorVersion = parseInt(React$1.version, 10);
|
|
126
|
+
function isReactVersionAtLeast(reactVersionToCheck) {
|
|
127
|
+
return majorVersion >= reactVersionToCheck;
|
|
128
|
+
}
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region ../../node_modules/@base-ui-components/utils/esm/mergeObjects.js
|
|
131
|
+
function mergeObjects(a, b) {
|
|
132
|
+
if (a && !b) return a;
|
|
133
|
+
if (!a && b) return b;
|
|
134
|
+
if (a || b) return {
|
|
135
|
+
...a,
|
|
136
|
+
...b
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
//#endregion
|
|
140
|
+
//#region ../../node_modules/@base-ui-components/react/esm/utils/getStateAttributesProps.js
|
|
141
|
+
function getStateAttributesProps(state, customMapping) {
|
|
142
|
+
const props = {};
|
|
143
|
+
for (const key in state) {
|
|
144
|
+
const value = state[key];
|
|
145
|
+
if (customMapping === null || customMapping === void 0 ? void 0 : customMapping.hasOwnProperty(key)) {
|
|
146
|
+
const customProps = customMapping[key](value);
|
|
147
|
+
if (customProps != null) Object.assign(props, customProps);
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
if (value === true) props[`data-${key.toLowerCase()}`] = "";
|
|
151
|
+
else if (value) props[`data-${key.toLowerCase()}`] = value.toString();
|
|
152
|
+
}
|
|
153
|
+
return props;
|
|
154
|
+
}
|
|
155
|
+
//#endregion
|
|
156
|
+
//#region ../../node_modules/@base-ui-components/react/esm/utils/resolveClassName.js
|
|
157
|
+
/**
|
|
158
|
+
* If the provided className is a string, it will be returned as is.
|
|
159
|
+
* Otherwise, the function will call the className function with the state as the first argument.
|
|
160
|
+
*
|
|
161
|
+
* @param className
|
|
162
|
+
* @param state
|
|
163
|
+
*/
|
|
164
|
+
function resolveClassName(className, state) {
|
|
165
|
+
return typeof className === "function" ? className(state) : className;
|
|
166
|
+
}
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region ../../node_modules/@base-ui-components/react/esm/merge-props/mergeProps.js
|
|
169
|
+
var EMPTY_PROPS = {};
|
|
170
|
+
/**
|
|
171
|
+
* Merges multiple sets of React props. It follows the Object.assign pattern where the rightmost object's fields overwrite
|
|
172
|
+
* the conflicting ones from others. This doesn't apply to event handlers, `className` and `style` props.
|
|
173
|
+
* Event handlers are merged such that they are called in sequence (the rightmost one being called first),
|
|
174
|
+
* and allows the user to prevent the subsequent event handlers from being
|
|
175
|
+
* executed by attaching a `preventBaseUIHandler` method.
|
|
176
|
+
* It also merges the `className` and `style` props, whereby the classes are concatenated
|
|
177
|
+
* and the rightmost styles overwrite the subsequent ones.
|
|
178
|
+
*
|
|
179
|
+
* Props can either be provided as objects or as functions that take the previous props as an argument.
|
|
180
|
+
* The function will receive the merged props up to that point (going from left to right):
|
|
181
|
+
* so in the case of `(obj1, obj2, fn, obj3)`, `fn` will receive the merged props of `obj1` and `obj2`.
|
|
182
|
+
* The function is responsible for chaining event handlers if needed (i.e. we don't run the merge logic).
|
|
183
|
+
*
|
|
184
|
+
* Event handlers returned by the functions are not automatically prevented when `preventBaseUIHandler` is called.
|
|
185
|
+
* They must check `event.baseUIHandlerPrevented` themselves and bail out if it's true.
|
|
186
|
+
*
|
|
187
|
+
* @important **`ref` is not merged.**
|
|
188
|
+
* @param props props to merge.
|
|
189
|
+
* @returns the merged props.
|
|
190
|
+
*/
|
|
191
|
+
function mergeProps(a, b, c, d, e) {
|
|
192
|
+
let merged = { ...resolvePropsGetter(a, EMPTY_PROPS) };
|
|
193
|
+
if (b) merged = mergeOne(merged, b);
|
|
194
|
+
if (c) merged = mergeOne(merged, c);
|
|
195
|
+
if (d) merged = mergeOne(merged, d);
|
|
196
|
+
if (e) merged = mergeOne(merged, e);
|
|
197
|
+
return merged;
|
|
198
|
+
}
|
|
199
|
+
function mergePropsN(props) {
|
|
200
|
+
if (props.length === 0) return EMPTY_PROPS;
|
|
201
|
+
if (props.length === 1) return resolvePropsGetter(props[0], EMPTY_PROPS);
|
|
202
|
+
let merged = { ...resolvePropsGetter(props[0], EMPTY_PROPS) };
|
|
203
|
+
for (let i = 1; i < props.length; i += 1) merged = mergeOne(merged, props[i]);
|
|
204
|
+
return merged;
|
|
205
|
+
}
|
|
206
|
+
function mergeOne(merged, inputProps) {
|
|
207
|
+
if (isPropsGetter(inputProps)) return inputProps(merged);
|
|
208
|
+
return mutablyMergeInto(merged, inputProps);
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Merges two sets of props. In case of conflicts, the external props take precedence.
|
|
212
|
+
*/
|
|
213
|
+
function mutablyMergeInto(mergedProps, externalProps) {
|
|
214
|
+
if (!externalProps) return mergedProps;
|
|
215
|
+
for (const propName in externalProps) {
|
|
216
|
+
const externalPropValue = externalProps[propName];
|
|
217
|
+
switch (propName) {
|
|
218
|
+
case "style":
|
|
219
|
+
mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
|
|
220
|
+
break;
|
|
221
|
+
case "className":
|
|
222
|
+
mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
|
|
223
|
+
break;
|
|
224
|
+
default: if (isEventHandler(propName, externalPropValue)) mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
|
|
225
|
+
else mergedProps[propName] = externalPropValue;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return mergedProps;
|
|
229
|
+
}
|
|
230
|
+
function isEventHandler(key, value) {
|
|
231
|
+
const code0 = key.charCodeAt(0);
|
|
232
|
+
const code1 = key.charCodeAt(1);
|
|
233
|
+
const code2 = key.charCodeAt(2);
|
|
234
|
+
return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
|
|
235
|
+
}
|
|
236
|
+
function isPropsGetter(inputProps) {
|
|
237
|
+
return typeof inputProps === "function";
|
|
238
|
+
}
|
|
239
|
+
function resolvePropsGetter(inputProps, previousProps) {
|
|
240
|
+
if (isPropsGetter(inputProps)) return inputProps(previousProps);
|
|
241
|
+
return inputProps !== null && inputProps !== void 0 ? inputProps : EMPTY_PROPS;
|
|
242
|
+
}
|
|
243
|
+
function mergeEventHandlers(ourHandler, theirHandler) {
|
|
244
|
+
if (!theirHandler) return ourHandler;
|
|
245
|
+
if (!ourHandler) return theirHandler;
|
|
246
|
+
return (event) => {
|
|
247
|
+
if (isSyntheticEvent(event)) {
|
|
248
|
+
const baseUIEvent = event;
|
|
249
|
+
makeEventPreventable(baseUIEvent);
|
|
250
|
+
const result = theirHandler(baseUIEvent);
|
|
251
|
+
if (!baseUIEvent.baseUIHandlerPrevented) ourHandler === null || ourHandler === void 0 || ourHandler(baseUIEvent);
|
|
252
|
+
return result;
|
|
253
|
+
}
|
|
254
|
+
const result = theirHandler(event);
|
|
255
|
+
ourHandler === null || ourHandler === void 0 || ourHandler(event);
|
|
256
|
+
return result;
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
function makeEventPreventable(event) {
|
|
260
|
+
event.preventBaseUIHandler = () => {
|
|
261
|
+
event.baseUIHandlerPrevented = true;
|
|
262
|
+
};
|
|
263
|
+
return event;
|
|
264
|
+
}
|
|
265
|
+
function mergeClassNames(ourClassName, theirClassName) {
|
|
266
|
+
if (theirClassName) {
|
|
267
|
+
if (ourClassName) return theirClassName + " " + ourClassName;
|
|
268
|
+
return theirClassName;
|
|
269
|
+
}
|
|
270
|
+
return ourClassName;
|
|
271
|
+
}
|
|
272
|
+
function isSyntheticEvent(event) {
|
|
273
|
+
return event != null && typeof event === "object" && "nativeEvent" in event;
|
|
274
|
+
}
|
|
275
|
+
//#endregion
|
|
276
|
+
//#region ../../node_modules/@base-ui-components/react/esm/utils/useRenderElement.js
|
|
277
|
+
var import_jsx_runtime = require_jsx_runtime();
|
|
278
|
+
/**
|
|
279
|
+
* Renders a Base UI element.
|
|
280
|
+
*
|
|
281
|
+
* @param element The default HTML element to render. Can be overridden by the `render` prop.
|
|
282
|
+
* @param componentProps An object containing the `render` and `className` props to be used for element customization. Other props are ignored.
|
|
283
|
+
* @param params Additional parameters for rendering the element.
|
|
284
|
+
*/
|
|
285
|
+
function useRenderElement(element, componentProps, params = {}) {
|
|
286
|
+
var _params$state;
|
|
287
|
+
const renderProp = componentProps.render;
|
|
288
|
+
const outProps = useRenderElementProps(componentProps, params);
|
|
289
|
+
if (params.enabled === false) return null;
|
|
290
|
+
return evaluateRenderProp(element, renderProp, outProps, (_params$state = params.state) !== null && _params$state !== void 0 ? _params$state : EMPTY_OBJECT);
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Computes render element final props.
|
|
294
|
+
*/
|
|
295
|
+
function useRenderElementProps(componentProps, params = {}) {
|
|
296
|
+
var _mergeObjects;
|
|
297
|
+
const { className: classNameProp, render: renderProp } = componentProps;
|
|
298
|
+
const { state = EMPTY_OBJECT, ref, props, stateAttributesMapping, enabled = true } = params;
|
|
299
|
+
const className = enabled ? resolveClassName(classNameProp, state) : void 0;
|
|
300
|
+
const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping) : EMPTY_OBJECT;
|
|
301
|
+
const outProps = enabled ? (_mergeObjects = mergeObjects(stateProps, Array.isArray(props) ? mergePropsN(props) : props)) !== null && _mergeObjects !== void 0 ? _mergeObjects : EMPTY_OBJECT : EMPTY_OBJECT;
|
|
302
|
+
if (typeof document !== "undefined") if (!enabled) useMergedRefs(null, null);
|
|
303
|
+
else if (Array.isArray(ref)) outProps.ref = useMergedRefsN([
|
|
304
|
+
outProps.ref,
|
|
305
|
+
getChildRef(renderProp),
|
|
306
|
+
...ref
|
|
307
|
+
]);
|
|
308
|
+
else outProps.ref = useMergedRefs(outProps.ref, getChildRef(renderProp), ref);
|
|
309
|
+
if (!enabled) return EMPTY_OBJECT;
|
|
310
|
+
if (className !== void 0) outProps.className = mergeClassNames(outProps.className, className);
|
|
311
|
+
return outProps;
|
|
312
|
+
}
|
|
313
|
+
function evaluateRenderProp(element, render, props, state) {
|
|
314
|
+
if (render) {
|
|
315
|
+
if (typeof render === "function") return render(props, state);
|
|
316
|
+
const mergedProps = mergeProps(props, render.props);
|
|
317
|
+
mergedProps.ref = props.ref;
|
|
318
|
+
return /* @__PURE__ */ React$1.cloneElement(render, mergedProps);
|
|
319
|
+
}
|
|
320
|
+
if (element) {
|
|
321
|
+
if (typeof element === "string") return renderTag(element, props);
|
|
322
|
+
}
|
|
323
|
+
throw new Error("Base UI: Render element or function are not defined.");
|
|
324
|
+
}
|
|
325
|
+
function renderTag(Tag, props) {
|
|
326
|
+
if (Tag === "button") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
327
|
+
type: "button",
|
|
328
|
+
...props
|
|
329
|
+
});
|
|
330
|
+
if (Tag === "img") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", {
|
|
331
|
+
alt: "",
|
|
332
|
+
...props
|
|
333
|
+
});
|
|
334
|
+
return /* @__PURE__ */ React$1.createElement(Tag, props);
|
|
335
|
+
}
|
|
336
|
+
function getChildRef(render) {
|
|
337
|
+
if (render && typeof render !== "function") return isReactVersionAtLeast(19) ? render.props.ref : render.ref;
|
|
338
|
+
return null;
|
|
339
|
+
}
|
|
340
|
+
//#endregion
|
|
341
|
+
export { useMergedRefs as a, DROPDOWN_COLLISION_AVOIDANCE as c, NOOP as d, useRefWithInit as f, isReactVersionAtLeast as i, EMPTY_ARRAY as l, makeEventPreventable as n, CLICK_TRIGGER_IDENTIFIER as o, mergeProps as r, DISABLED_TRANSITIONS_STYLE as s, useRenderElement as t, EMPTY_OBJECT as u };
|
|
@@ -1,27 +1,58 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as require_jsx_runtime } from "../../jsx-runtime-i4KUlhDu.js";
|
|
2
2
|
import { createContext, useContext } from "react";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
//#region src/utils/Orientation/OrientationProvider.tsx
|
|
4
|
+
var import_jsx_runtime = require_jsx_runtime();
|
|
5
|
+
var ctx = createContext("horizontal");
|
|
6
|
+
/**
|
|
7
|
+
* Provider that supplies orientation context for keyboard navigation.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* function TabList({ orientation, children }) {
|
|
12
|
+
* return (
|
|
13
|
+
* <OrientationProvider orientation={orientation}>
|
|
14
|
+
* <div role="tablist">{children}</div>
|
|
15
|
+
* </OrientationProvider>
|
|
16
|
+
* );
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
function OrientationProvider({ orientation, children }) {
|
|
21
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ctx.Provider, {
|
|
22
|
+
value: orientation,
|
|
23
|
+
children
|
|
24
|
+
});
|
|
9
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Hook that provides orientation context and keyboard navigation keys.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```tsx
|
|
31
|
+
* function NavigableItem({ children }) {
|
|
32
|
+
* const { nextKey, previousKey } = useOrientation();
|
|
33
|
+
*
|
|
34
|
+
* const handleKeyDown = (e) => {
|
|
35
|
+
* if (e.key === nextKey) focusNext();
|
|
36
|
+
* if (e.key === previousKey) focusPrevious();
|
|
37
|
+
* };
|
|
38
|
+
*
|
|
39
|
+
* return <div role="tab" onKeyDown={handleKeyDown}>{children}</div>;
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
10
43
|
function useOrientation() {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
44
|
+
const orientation = useContext(ctx);
|
|
45
|
+
let nextKey = "ArrowRight";
|
|
46
|
+
let previousKey = "ArrowLeft";
|
|
47
|
+
if (orientation === "vertical") {
|
|
48
|
+
nextKey = "ArrowDown";
|
|
49
|
+
previousKey = "ArrowUp";
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
orientation,
|
|
53
|
+
nextKey,
|
|
54
|
+
previousKey
|
|
55
|
+
};
|
|
23
56
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
useOrientation
|
|
27
|
-
};
|
|
57
|
+
//#endregion
|
|
58
|
+
export { OrientationProvider, useOrientation };
|
|
@@ -1,48 +1,74 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import { createContext, useContext,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { t as require_jsx_runtime } from "../../jsx-runtime-i4KUlhDu.js";
|
|
3
|
+
import { createContext, useContext, useEffect, useRef, useState } from "react";
|
|
4
|
+
//#region src/utils/RovingTabIndex/RovingTabIndexProvider.tsx
|
|
5
|
+
var import_jsx_runtime = require_jsx_runtime();
|
|
6
|
+
var ctx = createContext({
|
|
7
|
+
lastFocused: null,
|
|
8
|
+
setLastFocused: () => {}
|
|
8
9
|
});
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Provider that manages tabIndex values for the roving tab index pattern.
|
|
12
|
+
* Only one element in the group has tabIndex={0}, others have tabIndex={-1}.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* function Toolbar() {
|
|
17
|
+
* return (
|
|
18
|
+
* <RovingTabIndexProvider>
|
|
19
|
+
* <ToolbarButton>Cut</ToolbarButton>
|
|
20
|
+
* <ToolbarButton>Copy</ToolbarButton>
|
|
21
|
+
* </RovingTabIndexProvider>
|
|
22
|
+
* );
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
function RovingTabIndexProvider({ children }) {
|
|
27
|
+
const [lastFocused, setLastFocused] = useState(null);
|
|
28
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ctx.Provider, {
|
|
29
|
+
value: {
|
|
30
|
+
lastFocused,
|
|
31
|
+
setLastFocused
|
|
32
|
+
},
|
|
33
|
+
children
|
|
34
|
+
});
|
|
17
35
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Hook that provides tabIndex management for individual elements in a roving tab index group.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```tsx
|
|
41
|
+
* function ToolbarButton({ children, onFocus }) {
|
|
42
|
+
* const { ref, onFocus, tabIndex } = useRovingTabIndex({ onFocus });
|
|
43
|
+
* return (
|
|
44
|
+
* <button ref={ref} onFocus={onFocus} tabIndex={tabIndex}>
|
|
45
|
+
* {children}
|
|
46
|
+
* </button>
|
|
47
|
+
* );
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
function useRovingTabIndex({ onFocus } = {}) {
|
|
52
|
+
const { lastFocused, setLastFocused } = useContext(ctx);
|
|
53
|
+
const ref = useRef(null);
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
const self = ref.current;
|
|
56
|
+
return () => {
|
|
57
|
+
setLastFocused((element) => {
|
|
58
|
+
if (element === self) return null;
|
|
59
|
+
return element;
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
}, [setLastFocused]);
|
|
63
|
+
const handleFocus = (e) => {
|
|
64
|
+
setLastFocused(e.target);
|
|
65
|
+
onFocus === null || onFocus === void 0 || onFocus(e);
|
|
66
|
+
};
|
|
67
|
+
return {
|
|
68
|
+
ref,
|
|
69
|
+
onFocus: handleFocus,
|
|
70
|
+
tabIndex: lastFocused && lastFocused !== ref.current ? -1 : 0
|
|
71
|
+
};
|
|
44
72
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
useRovingTabIndex
|
|
48
|
-
};
|
|
73
|
+
//#endregion
|
|
74
|
+
export { RovingTabIndexProvider, useRovingTabIndex };
|
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
import { createContext, useContext } from "react";
|
|
2
|
+
//#region src/utils/createRequiredContext.ts
|
|
3
|
+
/**
|
|
4
|
+
* Creates a required context and a hook to access it.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* const [Provider, useRequiredContext] = createRequiredContext<Ctx>('MyContext');
|
|
8
|
+
*
|
|
9
|
+
* <Provider value={value}>
|
|
10
|
+
* <Component />
|
|
11
|
+
* </Provider>
|
|
12
|
+
*
|
|
13
|
+
* const value = useRequiredContext();
|
|
14
|
+
*/
|
|
2
15
|
function createRequiredContext(name) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
return [context.Provider, useRequiredContext];
|
|
16
|
+
const context = createContext(null);
|
|
17
|
+
context.displayName = `${name}.Provider`;
|
|
18
|
+
const useRequiredContext = () => {
|
|
19
|
+
const value = useContext(context);
|
|
20
|
+
if (!value) throw new Error(`${name} context must be used within its Provider`);
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
return [context.Provider, useRequiredContext];
|
|
13
24
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
25
|
+
//#endregion
|
|
26
|
+
export { createRequiredContext };
|
|
@@ -1,26 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
//#region src/utils/filterAttributesPassedByRadixUIAtRuntime.ts
|
|
2
|
+
var ATTRIBUTES_SET = new Set([
|
|
3
|
+
"aria-describedby",
|
|
4
|
+
"data-state",
|
|
5
|
+
"onPointerMove",
|
|
6
|
+
"onPointerLeave",
|
|
7
|
+
"onPointerDown",
|
|
8
|
+
"onFocus",
|
|
9
|
+
"onBlur",
|
|
10
|
+
"onClick",
|
|
11
|
+
"onTouchStart",
|
|
12
|
+
"onTouchEnd",
|
|
13
|
+
"id",
|
|
14
|
+
"tabIndex"
|
|
15
|
+
]);
|
|
16
|
+
/**
|
|
17
|
+
* Filters an object to only include whitelisted HTML attributes.
|
|
18
|
+
* This is useful for safe props spreading to enable integration with third-party libs like radix-ui.
|
|
19
|
+
*
|
|
20
|
+
* Original need: to make radix-based Tooltip work when it wraps custom component, that custom
|
|
21
|
+
* component should forward ref AND spread props, that Radix passes down implicitly.
|
|
22
|
+
* With `filterHTMLAttributes`, we're allowing known props required for Tooltip/Popover, and avoiding
|
|
23
|
+
* spreading ALL the `{...rest}` props down, to prevent opening doors to all sorts of weird "hacks".
|
|
24
|
+
*/
|
|
25
|
+
var filterAttributesPassedByRadixUIAtRuntime = (attributes) => {
|
|
26
|
+
return Object.fromEntries(Object.entries(attributes).filter(([key]) => ATTRIBUTES_SET.has(key)));
|
|
26
27
|
};
|
|
28
|
+
//#endregion
|
|
29
|
+
export { filterAttributesPassedByRadixUIAtRuntime };
|