@autoguru/overdrive 4.43.9-next.0 → 4.43.10-next.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/components/Actions/Actions.d.ts +3 -3
- package/dist/components/Actions/Actions.d.ts.map +1 -1
- package/dist/components/Actions/Actions.js +4 -3
- package/dist/components/Alert/Alert.d.ts +3 -3
- package/dist/components/Alert/Alert.d.ts.map +1 -1
- package/dist/components/Alert/Alert.js +11 -11
- package/dist/components/Anchor/Anchor.d.ts +4 -3
- package/dist/components/Anchor/Anchor.d.ts.map +1 -1
- package/dist/components/Anchor/Anchor.js +21 -19
- package/dist/components/AutoSuggest/AutoSuggest.js +52 -34
- package/dist/components/AutoSuggest/useLayoutSuggestionVisible.js +1 -0
- package/dist/components/Badge/Badge.d.ts +13 -2
- package/dist/components/Badge/Badge.d.ts.map +1 -1
- package/dist/components/Badge/Badge.js +7 -1
- package/dist/components/Box/Box.d.ts +7 -0
- package/dist/components/Box/Box.d.ts.map +1 -1
- package/dist/components/Box/Box.js +11 -2
- package/dist/components/Box/newBox/NewBox.d.ts +23 -0
- package/dist/components/Box/newBox/NewBox.d.ts.map +1 -1
- package/dist/components/Box/newBox/NewBox.js +25 -2
- package/dist/components/Box/newBox/useBox.d.ts +24 -0
- package/dist/components/Box/newBox/useBox.d.ts.map +1 -1
- package/dist/components/Box/newBox/useBox.js +38 -1
- package/dist/components/BulletList/Bullet.js +2 -2
- package/dist/components/BulletList/BulletList.js +2 -2
- package/dist/components/BulletList/context.js +1 -1
- package/dist/components/BulletText/BulletText.d.ts.map +1 -1
- package/dist/components/BulletText/BulletText.js +13 -12
- package/dist/components/Button/Button.css.d.ts +9 -0
- package/dist/components/Button/Button.css.d.ts.map +1 -1
- package/dist/components/Button/Button.css.js +12 -2
- package/dist/components/Button/Button.d.ts +11 -2
- package/dist/components/Button/Button.d.ts.map +1 -1
- package/dist/components/Button/Button.js +23 -11
- package/dist/components/CheckBox/CheckBox.d.ts +4 -0
- package/dist/components/CheckBox/CheckBox.d.ts.map +1 -1
- package/dist/components/CheckBox/CheckBox.js +4 -4
- package/dist/components/ColourInput/ColourInput.d.ts.map +1 -1
- package/dist/components/ColourInput/ColourInput.js +10 -9
- package/dist/components/Columns/Column.css.js +1 -0
- package/dist/components/Columns/Column.js +3 -3
- package/dist/components/Columns/ColumnGrid.css.js +1 -1
- package/dist/components/Columns/Columns.d.ts +3 -3
- package/dist/components/Columns/Columns.d.ts.map +1 -1
- package/dist/components/Columns/Columns.js +4 -4
- package/dist/components/DateInput/DateInput.js +1 -1
- package/dist/components/DatePicker/DatePicker.js +6 -6
- package/dist/components/DateTimePicker/CalendarButton.js +1 -1
- package/dist/components/DateTimePicker/CalendarGrid.js +10 -10
- package/dist/components/DateTimePicker/DateTimePicker.css.js +9 -1
- package/dist/components/DateTimePicker/DateTimePicker.d.ts +39 -0
- package/dist/components/DateTimePicker/DateTimePicker.d.ts.map +1 -1
- package/dist/components/DateTimePicker/DateTimePicker.js +50 -17
- package/dist/components/DividerLine/DividerLine.js +1 -1
- package/dist/components/DropDown/DropDown.js +5 -5
- package/dist/components/DropDown/DropDownOption.js +4 -4
- package/dist/components/DropDown/DropDownOptionsList.js +4 -4
- package/dist/components/EditableText/EditableText.d.ts +2 -2
- package/dist/components/EditableText/EditableText.d.ts.map +1 -1
- package/dist/components/EditableText/EditableText.js +10 -10
- package/dist/components/FillHeightBox/FillHeightBox.js +2 -1
- package/dist/components/Flyout/Flyout.d.ts +2 -2
- package/dist/components/Flyout/Flyout.d.ts.map +1 -1
- package/dist/components/Flyout/Flyout.js +3 -3
- package/dist/components/Heading/Heading.d.ts +6 -1
- package/dist/components/Heading/Heading.d.ts.map +1 -1
- package/dist/components/Heading/Heading.js +10 -3
- package/dist/components/HorizontalAutoScroller/HorizontalAutoScroller.d.ts +2 -2
- package/dist/components/HorizontalAutoScroller/HorizontalAutoScroller.d.ts.map +1 -1
- package/dist/components/HorizontalAutoScroller/HorizontalAutoScroller.js +19 -18
- package/dist/components/Icon/Icon.js +2 -2
- package/dist/components/Image/Image.d.ts +3 -0
- package/dist/components/Image/Image.d.ts.map +1 -1
- package/dist/components/Image/Image.js +2 -2
- package/dist/components/Image/ImageServerProvider.js +7 -2
- package/dist/components/Image/ResponsiveImage.d.ts +22 -0
- package/dist/components/Image/ResponsiveImage.d.ts.map +1 -1
- package/dist/components/Image/ResponsiveImage.js +2 -1
- package/dist/components/Image/SimpleImage.d.ts +18 -0
- package/dist/components/Image/SimpleImage.d.ts.map +1 -1
- package/dist/components/Image/SimpleImage.js +6 -2
- package/dist/components/Inline/Inline.d.ts +9 -6
- package/dist/components/Inline/Inline.d.ts.map +1 -1
- package/dist/components/Inline/Inline.js +53 -46
- package/dist/components/IntentStripe/IntentStripe.js +1 -1
- package/dist/components/LinearProgressIndicator/LinearProgressIndicator.js +4 -4
- package/dist/components/LoadingBox/LoadingBox.js +1 -1
- package/dist/components/Meta/Meta.js +3 -3
- package/dist/components/MinimalModal/MinimalModal.js +4 -4
- package/dist/components/Modal/Modal.js +7 -6
- package/dist/components/NumberBubble/NumberBubble.js +2 -2
- package/dist/components/NumberInput/NumberInput.js +1 -1
- package/dist/components/NumberInput/useNumberInputBehaviours.js +9 -3
- package/dist/components/OptionGrid/OptionGrid.css.js +7 -1
- package/dist/components/OptionGrid/OptionGrid.d.ts +32 -0
- package/dist/components/OptionGrid/OptionGrid.d.ts.map +1 -1
- package/dist/components/OptionGrid/OptionGrid.js +26 -12
- package/dist/components/OptionList/OptionList.css.js +5 -1
- package/dist/components/OptionList/OptionList.d.ts +25 -0
- package/dist/components/OptionList/OptionList.d.ts.map +1 -1
- package/dist/components/OptionList/OptionList.js +19 -6
- package/dist/components/OptionList/OptionListItem.d.ts +10 -0
- package/dist/components/OptionList/OptionListItem.d.ts.map +1 -1
- package/dist/components/OptionList/OptionListItem.js +16 -9
- package/dist/components/OrderedList/OrderedList.css.d.ts +0 -1
- package/dist/components/OrderedList/OrderedList.css.d.ts.map +1 -1
- package/dist/components/OrderedList/OrderedList.css.js +1 -8
- package/dist/components/OrderedList/OrderedList.d.ts +4 -4
- package/dist/components/OrderedList/OrderedList.d.ts.map +1 -1
- package/dist/components/OrderedList/OrderedList.js +11 -9
- package/dist/components/OutsideClick/OutsideClick.js +4 -1
- package/dist/components/OverdriveProvider/FallbackProvider.d.ts +3 -0
- package/dist/components/OverdriveProvider/FallbackProvider.d.ts.map +1 -1
- package/dist/components/OverdriveProvider/FallbackProvider.js +5 -1
- package/dist/components/OverdriveProvider/OverdriveProvider.d.ts +5 -0
- package/dist/components/OverdriveProvider/OverdriveProvider.d.ts.map +1 -1
- package/dist/components/OverdriveProvider/OverdriveProvider.js +10 -6
- package/dist/components/OverdriveProvider/ThemeOverrideDebugger.js +7 -7
- package/dist/components/OverdriveProvider/index.d.ts +2 -1
- package/dist/components/OverdriveProvider/index.d.ts.map +1 -1
- package/dist/components/OverdriveProvider/index.js +3 -1
- package/dist/components/OverdriveProvider/useColorOverrides.d.ts +1 -0
- package/dist/components/OverdriveProvider/useColorOverrides.d.ts.map +1 -1
- package/dist/components/OverdriveProvider/useColorOverrides.js +9 -0
- package/dist/components/Pagination/Bubble.js +1 -1
- package/dist/components/Pagination/Pagination.js +11 -11
- package/dist/components/Portal/Portal.js +5 -2
- package/dist/components/Positioner/Positioner.js +18 -2
- package/dist/components/Positioner/alignment.js +1 -1
- package/dist/components/ProgressBar/ProgressBar.js +3 -3
- package/dist/components/ProgressBarGroup/ProgressBarGroup.js +5 -5
- package/dist/components/ProgressSpinner/ProgressSpinner.js +3 -3
- package/dist/components/Radio/Radio.js +4 -4
- package/dist/components/Radio/RadioGroup.js +4 -4
- package/dist/components/ScrollPane/ScrollPane.js +2 -2
- package/dist/components/SearchBar/SearchBar.d.ts +17 -0
- package/dist/components/SearchBar/SearchBar.d.ts.map +1 -1
- package/dist/components/SearchBar/SearchBar.js +21 -9
- package/dist/components/Section/Section.d.ts +3 -3
- package/dist/components/Section/Section.d.ts.map +1 -1
- package/dist/components/Section/Section.js +4 -3
- package/dist/components/SelectInput/SelectInput.js +6 -6
- package/dist/components/SimplePagination/SimplePagination.js +6 -6
- package/dist/components/SliderProgress/ProgressStep.js +4 -4
- package/dist/components/SliderProgress/SliderProgress.js +3 -3
- package/dist/components/Stack/Divider.d.ts +3 -0
- package/dist/components/Stack/Divider.d.ts.map +1 -0
- package/dist/components/Stack/Divider.js +13 -0
- package/dist/components/Stack/Stack.d.ts +6 -10
- package/dist/components/Stack/Stack.d.ts.map +1 -1
- package/dist/components/Stack/Stack.js +28 -28
- package/dist/components/StandardModal/StandardModal.d.ts +2 -2
- package/dist/components/StandardModal/StandardModal.d.ts.map +1 -1
- package/dist/components/StandardModal/StandardModal.js +13 -11
- package/dist/components/StarRating/StarRating.js +11 -9
- package/dist/components/Stepper/Stepper.js +10 -10
- package/dist/components/StickyBox/StickyBox.js +4 -3
- package/dist/components/Switch/Switch.d.ts +11 -0
- package/dist/components/Switch/Switch.d.ts.map +1 -1
- package/dist/components/Switch/Switch.js +10 -5
- package/dist/components/Table/Table.css.js +4 -0
- package/dist/components/Table/Table.js +9 -3
- package/dist/components/Table/TableCell.css.js +5 -0
- package/dist/components/Table/TableCell.js +7 -4
- package/dist/components/Table/TableHeadCell.js +7 -7
- package/dist/components/Table/TableRow.js +2 -2
- package/dist/components/Table/TableRowGroup.js +2 -2
- package/dist/components/Table/context.js +2 -2
- package/dist/components/Tabs/Tab.d.ts +3 -3
- package/dist/components/Tabs/Tab.d.ts.map +1 -1
- package/dist/components/Tabs/Tab.js +6 -6
- package/dist/components/Tabs/TabList.js +10 -10
- package/dist/components/Tabs/TabPane.js +1 -1
- package/dist/components/Tabs/TabPanes.d.ts +1 -0
- package/dist/components/Tabs/TabPanes.d.ts.map +1 -1
- package/dist/components/Tabs/TabPanes.js +3 -3
- package/dist/components/Tabs/Tabs.js +2 -2
- package/dist/components/Text/Text.d.ts +3 -5
- package/dist/components/Text/Text.d.ts.map +1 -1
- package/dist/components/Text/Text.js +5 -2
- package/dist/components/Text/textStyles.d.ts +3 -0
- package/dist/components/Text/textStyles.d.ts.map +1 -1
- package/dist/components/Text/textStyles.js +5 -0
- package/dist/components/TextAreaInput/TextAreaInput.js +1 -1
- package/dist/components/TextBubble/TextBubble.d.ts +5 -5
- package/dist/components/TextBubble/TextBubble.d.ts.map +1 -1
- package/dist/components/TextBubble/TextBubble.js +4 -3
- package/dist/components/TextContainer/TextContainer.js +4 -4
- package/dist/components/TextInput/TextInput.js +1 -1
- package/dist/components/TextLink/TextLink.css.d.ts +0 -1
- package/dist/components/TextLink/TextLink.css.d.ts.map +1 -1
- package/dist/components/TextLink/TextLink.css.js +0 -5
- package/dist/components/TextLink/TextLink.d.ts +7 -8
- package/dist/components/TextLink/TextLink.d.ts.map +1 -1
- package/dist/components/TextLink/TextLink.js +19 -19
- package/dist/components/Toaster/Toast.js +20 -10
- package/dist/components/Tooltip/Tooltip.d.ts +25 -5
- package/dist/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/components/Tooltip/Tooltip.js +61 -82
- package/dist/components/Tooltip/index.d.ts +1 -1
- package/dist/components/Tooltip/index.d.ts.map +1 -1
- package/dist/components/VisuallyHidden/VisuallyHidden.d.ts +5 -0
- package/dist/components/VisuallyHidden/VisuallyHidden.d.ts.map +1 -1
- package/dist/components/VisuallyHidden/VisuallyHidden.js +6 -1
- package/dist/components/private/CheckableBase/CheckableBase.css.js +2 -0
- package/dist/components/private/CheckableBase/CheckableBase.js +6 -6
- package/dist/components/private/CheckableBase/useCheckableStyles.d.ts +3 -0
- package/dist/components/private/CheckableBase/useCheckableStyles.d.ts.map +1 -1
- package/dist/components/private/CheckableBase/useCheckableStyles.js +3 -0
- package/dist/components/private/InputBase/HintText.js +1 -1
- package/dist/components/private/InputBase/NotchedBase.js +7 -7
- package/dist/components/private/InputBase/withEnhancedInput.css.js +1 -0
- package/dist/components/private/InputBase/withEnhancedInput.d.ts +1 -1
- package/dist/components/private/InputBase/withEnhancedInput.d.ts.map +1 -1
- package/dist/components/private/InputBase/withEnhancedInput.js +32 -10
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useAttachedBoxes/useAttachedBoxes.js +2 -1
- package/dist/hooks/useDeepCompareMemo/index.d.ts +4 -0
- package/dist/hooks/useDeepCompareMemo/index.d.ts.map +1 -1
- package/dist/hooks/useDeepCompareMemo/index.js +12 -0
- package/dist/hooks/useMedia/useMedia.js +1 -0
- package/dist/hooks/useResponsiveValue/useResponsiveValue.js +3 -1
- package/dist/hooks/useTooltip/index.d.ts +2 -0
- package/dist/hooks/useTooltip/index.d.ts.map +1 -0
- package/dist/hooks/useTooltip/index.js +3 -0
- package/dist/hooks/useTooltip/useTooltip.d.ts +38 -0
- package/dist/hooks/useTooltip/useTooltip.d.ts.map +1 -0
- package/dist/hooks/useTooltip/useTooltip.js +125 -0
- package/dist/hooks/useWindowHeightFill/useWindowHeightFill.js +1 -0
- package/dist/hooks/useWindowScrollLock/index.js +2 -0
- package/dist/styles/componentStyles.d.ts +14 -1
- package/dist/styles/componentStyles.d.ts.map +1 -1
- package/dist/styles/componentStyles.js +17 -3
- package/dist/styles/componentStyles.spec.d.ts +2 -0
- package/dist/styles/componentStyles.spec.d.ts.map +1 -0
- package/dist/styles/componentStyles.spec.js +251 -0
- package/dist/styles/elementReset.css.d.ts +1 -0
- package/dist/styles/elementReset.css.d.ts.map +1 -1
- package/dist/styles/elementReset.css.js +4 -0
- package/dist/styles/global/reset.css.js +2 -0
- package/dist/styles/layers.css.d.ts +3 -2
- package/dist/styles/layers.css.d.ts.map +1 -1
- package/dist/styles/layers.css.js +6 -2
- package/dist/styles/sprinkles.css.d.ts +11 -11
- package/dist/styles/sprinkles.css.d.ts.map +1 -1
- package/dist/styles/sprinkles.css.js +39 -14
- package/dist/styles/typography.css.d.ts +14 -0
- package/dist/styles/typography.css.d.ts.map +1 -1
- package/dist/styles/typography.css.js +5 -0
- package/dist/styles/vars.css.js +2 -0
- package/dist/themes/base/theme.css.js +3 -1
- package/dist/themes/base/tokens.d.ts +3 -0
- package/dist/themes/base/tokens.d.ts.map +1 -1
- package/dist/themes/base/tokens.js +3 -0
- package/dist/themes/helpers.d.ts +22 -0
- package/dist/themes/helpers.d.ts.map +1 -1
- package/dist/themes/helpers.js +24 -0
- package/dist/themes/makeTheme.d.ts +3 -0
- package/dist/themes/makeTheme.d.ts.map +1 -1
- package/dist/themes/makeTheme.js +7 -1
- package/dist/themes/theme.css.d.ts +4 -0
- package/dist/themes/theme.css.d.ts.map +1 -1
- package/dist/themes/theme.css.js +16 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/css.d.ts +15 -0
- package/dist/utils/css.d.ts.map +1 -1
- package/dist/utils/css.js +18 -0
- package/dist/utils/dataAttrs.d.ts +3 -0
- package/dist/utils/dataAttrs.d.ts.map +1 -1
- package/dist/utils/dataAttrs.js +3 -0
- package/dist/utils/estimateTextWidth.js +3 -2
- package/dist/utils/index.d.ts +21 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +39 -0
- package/dist/utils/number.js +7 -2
- package/dist/utils/propGuards.d.ts +14 -0
- package/dist/utils/propGuards.d.ts.map +1 -1
- package/dist/utils/propGuards.js +14 -0
- package/dist/utils/responsiveProps.css.js +1 -1
- package/dist/utils/sprinkles.d.ts +18 -0
- package/dist/utils/sprinkles.d.ts.map +1 -1
- package/dist/utils/sprinkles.js +21 -1
- package/package.json +19 -19
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { EAlignment } from '../../components/Positioner/alignment';
|
|
3
|
+
export type ToolTipSize = 'medium' | 'large';
|
|
4
|
+
export interface UseTooltipProps {
|
|
5
|
+
/**
|
|
6
|
+
* Whether the tooltip should be controlled externally
|
|
7
|
+
*/
|
|
8
|
+
isOpen?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Auto-close the tooltip after this many milliseconds
|
|
11
|
+
*/
|
|
12
|
+
closeAfter?: number | null;
|
|
13
|
+
/**
|
|
14
|
+
* Called when the tooltip open state changes
|
|
15
|
+
*/
|
|
16
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Hook for managing tooltip state and interactions
|
|
20
|
+
*/
|
|
21
|
+
export declare const useTooltip: ({ isOpen: controlledIsOpen, closeAfter, onOpenChange, }: UseTooltipProps) => {
|
|
22
|
+
isOpen: boolean;
|
|
23
|
+
triggerRef: React.RefObject<HTMLElement | null>;
|
|
24
|
+
triggerProps: {
|
|
25
|
+
onMouseEnter: () => void;
|
|
26
|
+
onMouseLeave: () => void;
|
|
27
|
+
onFocus: () => void;
|
|
28
|
+
onBlur: () => void;
|
|
29
|
+
'aria-describedby': string | undefined;
|
|
30
|
+
};
|
|
31
|
+
PositionedTooltip: ({ alignment, className, label, size, }: {
|
|
32
|
+
alignment?: EAlignment;
|
|
33
|
+
className?: string;
|
|
34
|
+
label: string;
|
|
35
|
+
size?: ToolTipSize;
|
|
36
|
+
}) => React.JSX.Element;
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=useTooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTooltip.d.ts","sourceRoot":"","sources":["../../../lib/hooks/useTooltip/useTooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA0D,MAAM,OAAO,CAAC;AAI/E,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AAGnE,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE7C,MAAM,WAAW,eAAe;IAC/B;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;CACzC;AAOD;;GAEG;AACH,eAAO,MAAM,UAAU,GAAI,yDAIxB,eAAe;;;;;;;;;;gEAmFb;QACF,SAAS,CAAC,EAAE,UAAU,CAAC;QACvB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,WAAW,CAAC;KACnB;CAwCF,CAAC"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React, { useCallback, useEffect, useRef, useState, useId } from 'react';
|
|
4
|
+
import { Box } from "../../components/Box/Box.js";
|
|
5
|
+
import { Positioner } from "../../components/Positioner/Positioner.js";
|
|
6
|
+
import { EAlignment } from "../../components/Positioner/alignment.js";
|
|
7
|
+
import { Text } from "../../components/Text/Text.js";
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
const sizeMap = {
|
|
10
|
+
medium: '2',
|
|
11
|
+
large: '3'
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Hook for managing tooltip state and interactions
|
|
16
|
+
*/
|
|
17
|
+
export const useTooltip = _ref => {
|
|
18
|
+
let {
|
|
19
|
+
isOpen: controlledIsOpen,
|
|
20
|
+
closeAfter = null,
|
|
21
|
+
onOpenChange
|
|
22
|
+
} = _ref;
|
|
23
|
+
const tooltipId = useId();
|
|
24
|
+
const [internalIsOpen, setInternalIsOpen] = useState(false);
|
|
25
|
+
const triggerRef = useRef(null);
|
|
26
|
+
const tooltipRef = useRef(null);
|
|
27
|
+
const leaveTimer = useRef(null);
|
|
28
|
+
|
|
29
|
+
// Use controlled state if provided, otherwise use internal state
|
|
30
|
+
const isOpen = typeof controlledIsOpen === 'boolean' ? controlledIsOpen : internalIsOpen;
|
|
31
|
+
const setIsOpen = useCallback(newIsOpen => {
|
|
32
|
+
if (typeof controlledIsOpen !== 'boolean') {
|
|
33
|
+
setInternalIsOpen(newIsOpen);
|
|
34
|
+
}
|
|
35
|
+
onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(newIsOpen);
|
|
36
|
+
}, [controlledIsOpen, onOpenChange]);
|
|
37
|
+
const enterHandler = useCallback(() => {
|
|
38
|
+
if (leaveTimer.current) {
|
|
39
|
+
clearTimeout(leaveTimer.current);
|
|
40
|
+
leaveTimer.current = null;
|
|
41
|
+
}
|
|
42
|
+
setIsOpen(true);
|
|
43
|
+
}, [setIsOpen]);
|
|
44
|
+
const leaveHandler = useCallback(() => {
|
|
45
|
+
if (leaveTimer.current) {
|
|
46
|
+
clearTimeout(leaveTimer.current);
|
|
47
|
+
}
|
|
48
|
+
leaveTimer.current = setTimeout(() => {
|
|
49
|
+
setIsOpen(false);
|
|
50
|
+
}, 500); // 500ms delay
|
|
51
|
+
}, [setIsOpen]);
|
|
52
|
+
const focusHandler = useCallback(() => {
|
|
53
|
+
setIsOpen(true);
|
|
54
|
+
}, [setIsOpen]);
|
|
55
|
+
const blurHandler = useCallback(() => {
|
|
56
|
+
setIsOpen(false);
|
|
57
|
+
}, [setIsOpen]);
|
|
58
|
+
|
|
59
|
+
// Handle the closeAfter prop
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
let timeout;
|
|
62
|
+
if (isOpen && typeof closeAfter === 'number') {
|
|
63
|
+
timeout = setTimeout(() => setIsOpen(false), closeAfter);
|
|
64
|
+
}
|
|
65
|
+
return () => {
|
|
66
|
+
if (timeout) clearTimeout(timeout);
|
|
67
|
+
};
|
|
68
|
+
}, [closeAfter, isOpen, setIsOpen]);
|
|
69
|
+
|
|
70
|
+
// Cleanup timer on unmount
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
return () => {
|
|
73
|
+
if (leaveTimer.current) {
|
|
74
|
+
clearTimeout(leaveTimer.current);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}, []);
|
|
78
|
+
const triggerProps = {
|
|
79
|
+
onMouseEnter: enterHandler,
|
|
80
|
+
onMouseLeave: leaveHandler,
|
|
81
|
+
onFocus: focusHandler,
|
|
82
|
+
onBlur: blurHandler,
|
|
83
|
+
'aria-describedby': isOpen ? tooltipId : undefined
|
|
84
|
+
};
|
|
85
|
+
const PositionedTooltip = useCallback(_ref2 => {
|
|
86
|
+
let {
|
|
87
|
+
alignment = EAlignment.RIGHT,
|
|
88
|
+
className,
|
|
89
|
+
label,
|
|
90
|
+
size = 'medium'
|
|
91
|
+
} = _ref2;
|
|
92
|
+
const textSize = sizeMap[size];
|
|
93
|
+
return /*#__PURE__*/_jsx(Positioner, {
|
|
94
|
+
triggerRef: triggerRef,
|
|
95
|
+
alignment: alignment,
|
|
96
|
+
isOpen: isOpen,
|
|
97
|
+
children: /*#__PURE__*/_jsx(Box, {
|
|
98
|
+
className: className,
|
|
99
|
+
id: tooltipId,
|
|
100
|
+
ref: tooltipRef,
|
|
101
|
+
width: "full",
|
|
102
|
+
pointerEvents: "none",
|
|
103
|
+
userSelect: "none",
|
|
104
|
+
overflow: "hidden",
|
|
105
|
+
borderRadius: "1",
|
|
106
|
+
boxShadow: "4",
|
|
107
|
+
backgroundColour: "gray900",
|
|
108
|
+
paddingY: "2",
|
|
109
|
+
paddingX: "3",
|
|
110
|
+
role: "tooltip",
|
|
111
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
112
|
+
size: textSize,
|
|
113
|
+
colour: "white",
|
|
114
|
+
children: label
|
|
115
|
+
})
|
|
116
|
+
})
|
|
117
|
+
});
|
|
118
|
+
}, [isOpen, tooltipId]);
|
|
119
|
+
return {
|
|
120
|
+
isOpen,
|
|
121
|
+
triggerRef,
|
|
122
|
+
triggerProps,
|
|
123
|
+
PositionedTooltip
|
|
124
|
+
};
|
|
125
|
+
};
|
|
@@ -3,11 +3,24 @@ import type { ElementType, ReactElement } from 'react';
|
|
|
3
3
|
import { type ResetVariantProps } from './elementReset.css';
|
|
4
4
|
import { type Sprinkles } from './sprinkles.css';
|
|
5
5
|
type ResetPropsWithoutAs = Omit<ResetVariantProps, 'as'>;
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Returns the reset styles based on the `as` prop tag name passed in.
|
|
8
|
+
* A wrapper around `resetVariants` recipe to allow any string to be passed in
|
|
9
|
+
*/
|
|
10
|
+
export declare const resetStyles: (element: unknown, options?: ResetPropsWithoutAs) => string;
|
|
7
11
|
export interface ComponentStylesProps extends Sprinkles {
|
|
8
12
|
as?: string | ElementType | ReactElement;
|
|
9
13
|
className?: ClassName;
|
|
10
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Convenience function that combines element reset styles via `as` props and sprinkles utility styles.
|
|
17
|
+
* Allows `as` prop that is JSX or other React element to safely be passed in so it does not have to be filtered out.
|
|
18
|
+
* Includes logic for adding border reset styles when any border props are used.
|
|
19
|
+
*
|
|
20
|
+
* @example <svg className={componentStyles({ as: 'svg', padding: '1', size: '4' })} ... />
|
|
21
|
+
* @example <div className={componentStyles({ borderTopWidth: '1', borderTopColor: 'soft' })}
|
|
22
|
+
* // ^ this will trigger the border reset ^
|
|
23
|
+
*/
|
|
11
24
|
export declare const componentStyles: ({ as, className, ...styleProps }: ComponentStylesProps) => string;
|
|
12
25
|
export {};
|
|
13
26
|
//# sourceMappingURL=componentStyles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"componentStyles.d.ts","sourceRoot":"","sources":["../../lib/styles/componentStyles.ts"],"names":[],"mappings":"AAAA,OAAa,EAAE,KAAK,UAAU,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAEvD,OAAO,EAGN,KAAK,iBAAiB,EACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5D,KAAK,mBAAmB,GAAG,IAAI,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"componentStyles.d.ts","sourceRoot":"","sources":["../../lib/styles/componentStyles.ts"],"names":[],"mappings":"AAAA,OAAa,EAAE,KAAK,UAAU,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAEvD,OAAO,EAGN,KAAK,iBAAiB,EACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5D,KAAK,mBAAmB,GAAG,IAAI,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;AAmCzD;;;GAGG;AACH,eAAO,MAAM,WAAW,GACvB,SAAS,OAAO,EAChB,UAAU,mBAAmB,WAW7B,CAAC;AAEF,MAAM,WAAW,oBAAqB,SAAQ,SAAS;IACtD,EAAE,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,YAAY,CAAC;IACzC,SAAS,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,GAAI,kCAI7B,oBAAoB,WAKrB,CAAC"}
|
|
@@ -5,23 +5,37 @@ const _excluded = ["as", "className"];
|
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import { elementReset, resetVariants } from "./elementReset.css.js";
|
|
7
7
|
import { sprinkles } from "./sprinkles.css.js";
|
|
8
|
+
/** Will check for any border-related prop out of any style props */
|
|
8
9
|
const hasBorderRelatedProp = props => Boolean(props.borderColor || props.borderStyle || props.borderWidth || props.borderWidthX || props.borderWidthY || props.borderBottomColor || props.borderBottomStyle || props.borderBottomWidth || props.borderLeftColor || props.borderLeftStyle || props.borderLeftWidth || props.borderRightColor || props.borderRightStyle || props.borderRightWidth || props.borderTopColor || props.borderTopStyle || props.borderTopWidth || props.borderWidthTop || props.borderWidthRight || props.borderWidthBottom || props.borderWidthLeft || props.borderColour || props.borderColourX || props.borderColourY || props.borderBottomColour || props.borderLeftColour || props.borderRightColour || props.borderTopColour);
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Returns the reset styles based on the `as` prop tag name passed in.
|
|
13
|
+
* A wrapper around `resetVariants` recipe to allow any string to be passed in
|
|
14
|
+
*/
|
|
9
15
|
export const resetStyles = (element, options) => {
|
|
16
|
+
if (typeof element !== 'string') return '';
|
|
10
17
|
const as = element in elementReset ? element : undefined;
|
|
11
18
|
return resetVariants({
|
|
12
19
|
as,
|
|
13
20
|
hasBorder: options === null || options === void 0 ? void 0 : options.hasBorder
|
|
14
21
|
});
|
|
15
22
|
};
|
|
23
|
+
/**
|
|
24
|
+
* Convenience function that combines element reset styles via `as` props and sprinkles utility styles.
|
|
25
|
+
* Allows `as` prop that is JSX or other React element to safely be passed in so it does not have to be filtered out.
|
|
26
|
+
* Includes logic for adding border reset styles when any border props are used.
|
|
27
|
+
*
|
|
28
|
+
* @example <svg className={componentStyles({ as: 'svg', padding: '1', size: '4' })} ... />
|
|
29
|
+
* @example <div className={componentStyles({ borderTopWidth: '1', borderTopColor: 'soft' })}
|
|
30
|
+
* // ^ this will trigger the border reset ^
|
|
31
|
+
*/
|
|
16
32
|
export const componentStyles = _ref => {
|
|
17
33
|
let {
|
|
18
34
|
as,
|
|
19
35
|
className
|
|
20
36
|
} = _ref,
|
|
21
37
|
styleProps = _objectWithoutProperties(_ref, _excluded);
|
|
22
|
-
if (typeof as !== 'string') return clsx(className);
|
|
23
|
-
const hasBorder = hasBorderRelatedProp(styleProps);
|
|
24
38
|
return clsx(resetStyles(as, {
|
|
25
|
-
hasBorder
|
|
39
|
+
hasBorder: hasBorderRelatedProp(styleProps)
|
|
26
40
|
}), sprinkles(styleProps), className);
|
|
27
41
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"componentStyles.spec.d.ts","sourceRoot":"","sources":["../../lib/styles/componentStyles.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
4
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
|
+
import { describe, expect, it } from 'vitest';
|
|
7
|
+
import { componentStyles } from "./componentStyles.js";
|
|
8
|
+
// Test constants
|
|
9
|
+
const MOCK_CLASS_NAME = 'custom-class';
|
|
10
|
+
const MockComponent = () => null;
|
|
11
|
+
|
|
12
|
+
// Type-safe mock sprinkles properties for testing
|
|
13
|
+
const createMockSprinklesProps = props => props;
|
|
14
|
+
describe('componentStyles', () => {
|
|
15
|
+
describe('with no props', () => {
|
|
16
|
+
it('should return empty string when no props are provided', () => {
|
|
17
|
+
const result = componentStyles({});
|
|
18
|
+
expect(result).toBe('');
|
|
19
|
+
});
|
|
20
|
+
it('should return empty string when only non-string as prop is provided', () => {
|
|
21
|
+
const result = componentStyles({
|
|
22
|
+
as: MockComponent
|
|
23
|
+
});
|
|
24
|
+
expect(result).toBe('');
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
describe('with className only', () => {
|
|
28
|
+
it('should return the className when only className is provided', () => {
|
|
29
|
+
const result = componentStyles({
|
|
30
|
+
className: MOCK_CLASS_NAME
|
|
31
|
+
});
|
|
32
|
+
expect(result).toBe(MOCK_CLASS_NAME);
|
|
33
|
+
});
|
|
34
|
+
it('should return the className when className and non-string as prop are provided', () => {
|
|
35
|
+
const result = componentStyles({
|
|
36
|
+
className: MOCK_CLASS_NAME,
|
|
37
|
+
as: MockComponent
|
|
38
|
+
});
|
|
39
|
+
expect(result).toBe(MOCK_CLASS_NAME);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
describe('with as prop', () => {
|
|
43
|
+
it('should return styles with length when as prop is a valid HTML element', () => {
|
|
44
|
+
const result = componentStyles({
|
|
45
|
+
as: 'div'
|
|
46
|
+
});
|
|
47
|
+
expect(typeof result).toBe('string');
|
|
48
|
+
expect(result.length).toBeGreaterThan(0);
|
|
49
|
+
});
|
|
50
|
+
it('should return styles with length when as prop is a known element with reset styles', () => {
|
|
51
|
+
const result = componentStyles({
|
|
52
|
+
as: 'button'
|
|
53
|
+
});
|
|
54
|
+
expect(typeof result).toBe('string');
|
|
55
|
+
expect(result.length).toBeGreaterThan(0);
|
|
56
|
+
});
|
|
57
|
+
it('should return styles with length when as prop is an unknown element', () => {
|
|
58
|
+
const result = componentStyles({
|
|
59
|
+
as: 'custom-element'
|
|
60
|
+
});
|
|
61
|
+
expect(typeof result).toBe('string');
|
|
62
|
+
expect(result.length).toBeGreaterThan(0);
|
|
63
|
+
});
|
|
64
|
+
it('should return only className when as prop is not a string', () => {
|
|
65
|
+
const result = componentStyles({
|
|
66
|
+
as: MockComponent,
|
|
67
|
+
className: 'test-class'
|
|
68
|
+
});
|
|
69
|
+
expect(result).toBe('test-class');
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
describe('with style props', () => {
|
|
73
|
+
it('should return styles with length when padding prop is provided', () => {
|
|
74
|
+
const result = componentStyles(_objectSpread({}, createMockSprinklesProps({
|
|
75
|
+
padding: '4'
|
|
76
|
+
})));
|
|
77
|
+
expect(typeof result).toBe('string');
|
|
78
|
+
expect(result.length).toBeGreaterThan(0);
|
|
79
|
+
});
|
|
80
|
+
it('should return styles with length when margin prop is provided', () => {
|
|
81
|
+
const result = componentStyles(_objectSpread({}, createMockSprinklesProps({
|
|
82
|
+
margin: '2'
|
|
83
|
+
})));
|
|
84
|
+
expect(typeof result).toBe('string');
|
|
85
|
+
expect(result.length).toBeGreaterThan(0);
|
|
86
|
+
});
|
|
87
|
+
it('should return styles with length when multiple style props are provided', () => {
|
|
88
|
+
const result = componentStyles(_objectSpread({}, createMockSprinklesProps({
|
|
89
|
+
padding: '4',
|
|
90
|
+
margin: '2',
|
|
91
|
+
backgroundColor: 'transparent'
|
|
92
|
+
})));
|
|
93
|
+
expect(typeof result).toBe('string');
|
|
94
|
+
expect(result.length).toBeGreaterThan(0);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
describe('with border props', () => {
|
|
98
|
+
it('should return styles with length when borderColor is provided', () => {
|
|
99
|
+
const result = componentStyles(_objectSpread({
|
|
100
|
+
as: 'div'
|
|
101
|
+
}, createMockSprinklesProps({
|
|
102
|
+
borderColor: 'default'
|
|
103
|
+
})));
|
|
104
|
+
expect(typeof result).toBe('string');
|
|
105
|
+
expect(result.length).toBeGreaterThan(0);
|
|
106
|
+
});
|
|
107
|
+
it('should return styles with length when borderWidth is provided', () => {
|
|
108
|
+
const result = componentStyles(_objectSpread({
|
|
109
|
+
as: 'div'
|
|
110
|
+
}, createMockSprinklesProps({
|
|
111
|
+
borderWidth: '1'
|
|
112
|
+
})));
|
|
113
|
+
expect(typeof result).toBe('string');
|
|
114
|
+
expect(result.length).toBeGreaterThan(0);
|
|
115
|
+
});
|
|
116
|
+
it('should return styles with length when borderStyle is provided', () => {
|
|
117
|
+
const result = componentStyles(_objectSpread({
|
|
118
|
+
as: 'div'
|
|
119
|
+
}, createMockSprinklesProps({
|
|
120
|
+
borderStyle: 'solid'
|
|
121
|
+
})));
|
|
122
|
+
expect(typeof result).toBe('string');
|
|
123
|
+
expect(result.length).toBeGreaterThan(0);
|
|
124
|
+
});
|
|
125
|
+
it('should return styles with length when specific border side props are provided', () => {
|
|
126
|
+
const result = componentStyles(_objectSpread({
|
|
127
|
+
as: 'div'
|
|
128
|
+
}, createMockSprinklesProps({
|
|
129
|
+
borderTopColor: 'default',
|
|
130
|
+
borderBottomWidth: '2'
|
|
131
|
+
})));
|
|
132
|
+
expect(typeof result).toBe('string');
|
|
133
|
+
expect(result.length).toBeGreaterThan(0);
|
|
134
|
+
});
|
|
135
|
+
it('should return styles with length when legacy border colour props are provided', () => {
|
|
136
|
+
const result = componentStyles(_objectSpread({
|
|
137
|
+
as: 'div'
|
|
138
|
+
}, createMockSprinklesProps({
|
|
139
|
+
borderColour: 'gray'
|
|
140
|
+
})));
|
|
141
|
+
expect(typeof result).toBe('string');
|
|
142
|
+
expect(result.length).toBeGreaterThan(0);
|
|
143
|
+
});
|
|
144
|
+
it('should return styles with length when borderColourX is provided', () => {
|
|
145
|
+
const result = componentStyles(_objectSpread({
|
|
146
|
+
as: 'div'
|
|
147
|
+
}, createMockSprinklesProps({
|
|
148
|
+
borderColourX: 'light'
|
|
149
|
+
})));
|
|
150
|
+
expect(typeof result).toBe('string');
|
|
151
|
+
expect(result.length).toBeGreaterThan(0);
|
|
152
|
+
});
|
|
153
|
+
it('should return styles with length when borderColourY is provided', () => {
|
|
154
|
+
const result = componentStyles(_objectSpread({
|
|
155
|
+
as: 'div'
|
|
156
|
+
}, createMockSprinklesProps({
|
|
157
|
+
borderColourY: 'dark'
|
|
158
|
+
})));
|
|
159
|
+
expect(typeof result).toBe('string');
|
|
160
|
+
expect(result.length).toBeGreaterThan(0);
|
|
161
|
+
});
|
|
162
|
+
it('should return styles with length when specific side borderColour props are provided', () => {
|
|
163
|
+
const result = componentStyles(_objectSpread({
|
|
164
|
+
as: 'div'
|
|
165
|
+
}, createMockSprinklesProps({
|
|
166
|
+
borderTopColour: 'primary',
|
|
167
|
+
borderLeftColour: 'secondary'
|
|
168
|
+
})));
|
|
169
|
+
expect(typeof result).toBe('string');
|
|
170
|
+
expect(result.length).toBeGreaterThan(0);
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
describe('with combined props', () => {
|
|
174
|
+
it('should return styles with length when as, className, and style props are provided', () => {
|
|
175
|
+
const result = componentStyles(_objectSpread({
|
|
176
|
+
as: 'div',
|
|
177
|
+
className: MOCK_CLASS_NAME
|
|
178
|
+
}, createMockSprinklesProps({
|
|
179
|
+
padding: '4',
|
|
180
|
+
borderColor: 'default'
|
|
181
|
+
})));
|
|
182
|
+
expect(typeof result).toBe('string');
|
|
183
|
+
expect(result.length).toBeGreaterThan(0);
|
|
184
|
+
});
|
|
185
|
+
it('should return styles with length when complex combination of props is provided', () => {
|
|
186
|
+
const result = componentStyles(_objectSpread({
|
|
187
|
+
as: 'section',
|
|
188
|
+
className: 'complex-component'
|
|
189
|
+
}, createMockSprinklesProps({
|
|
190
|
+
padding: '8',
|
|
191
|
+
margin: '4',
|
|
192
|
+
backgroundColor: 'transparent',
|
|
193
|
+
borderTopWidth: '1',
|
|
194
|
+
borderTopColor: 'default',
|
|
195
|
+
borderBottomColour: 'primary'
|
|
196
|
+
})));
|
|
197
|
+
expect(typeof result).toBe('string');
|
|
198
|
+
expect(result.length).toBeGreaterThan(0);
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
describe('edge cases', () => {
|
|
202
|
+
it('should handle undefined className', () => {
|
|
203
|
+
const result = componentStyles({
|
|
204
|
+
as: 'span',
|
|
205
|
+
className: undefined
|
|
206
|
+
});
|
|
207
|
+
expect(typeof result).toBe('string');
|
|
208
|
+
expect(result.length).toBeGreaterThan(0);
|
|
209
|
+
});
|
|
210
|
+
it('should handle null className', () => {
|
|
211
|
+
const result = componentStyles({
|
|
212
|
+
as: 'section',
|
|
213
|
+
className: null
|
|
214
|
+
});
|
|
215
|
+
expect(typeof result).toBe('string');
|
|
216
|
+
expect(result.length).toBeGreaterThan(0);
|
|
217
|
+
});
|
|
218
|
+
it('should handle array className', () => {
|
|
219
|
+
const result = componentStyles({
|
|
220
|
+
as: 'ul',
|
|
221
|
+
className: ['class1', 'class2']
|
|
222
|
+
});
|
|
223
|
+
expect(typeof result).toBe('string');
|
|
224
|
+
expect(result.length).toBeGreaterThan(0);
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
describe('type safety', () => {
|
|
228
|
+
it('should accept all optional props', () => {
|
|
229
|
+
// This test verifies that all props are optional by not causing TypeScript errors
|
|
230
|
+
expect(() => {
|
|
231
|
+
componentStyles({});
|
|
232
|
+
componentStyles({
|
|
233
|
+
as: 'div'
|
|
234
|
+
});
|
|
235
|
+
componentStyles({
|
|
236
|
+
className: 'test'
|
|
237
|
+
});
|
|
238
|
+
componentStyles(createMockSprinklesProps({
|
|
239
|
+
padding: '4'
|
|
240
|
+
}));
|
|
241
|
+
componentStyles(_objectSpread({
|
|
242
|
+
as: 'div',
|
|
243
|
+
className: 'test'
|
|
244
|
+
}, createMockSprinklesProps({
|
|
245
|
+
padding: '4',
|
|
246
|
+
borderColor: 'default'
|
|
247
|
+
})));
|
|
248
|
+
}).not.toThrow();
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
});
|
|
@@ -5,6 +5,7 @@ export declare const trimmed: {
|
|
|
5
5
|
};
|
|
6
6
|
export declare const borderReset: string;
|
|
7
7
|
export declare const container: string;
|
|
8
|
+
/** controls the list html tag names to reset and maps them to the reset style */
|
|
8
9
|
export declare const elementReset: {
|
|
9
10
|
div: string;
|
|
10
11
|
p: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elementReset.css.d.ts","sourceRoot":"","sources":["../../lib/styles/elementReset.css.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAQlE,eAAO,MAAM,OAAO;;;CAGnB,CAAC;AAUF,eAAO,MAAM,WAAW,QAOtB,CAAC;AAEH,eAAO,MAAM,SAAS,QASpB,CAAC;
|
|
1
|
+
{"version":3,"file":"elementReset.css.d.ts","sourceRoot":"","sources":["../../lib/styles/elementReset.css.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAQlE,eAAO,MAAM,OAAO;;;CAGnB,CAAC;AAUF,eAAO,MAAM,WAAW,QAOtB,CAAC;AAEH,eAAO,MAAM,SAAS,QASpB,CAAC;AAsHH,iFAAiF;AACjF,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsCxB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,YAAY,CAAC;AAEtD,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAcxB,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,WAAW,CAC1C,cAAc,CAAC,OAAO,aAAa,CAAC,CACpC,CAAC"}
|
|
@@ -129,6 +129,8 @@ const vAlignMiddle = [trimmedElement, style({
|
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
}, "vAlignMiddle")];
|
|
132
|
+
|
|
133
|
+
/** controls the list html tag names to reset and maps them to the reset style */
|
|
132
134
|
export const elementReset = {
|
|
133
135
|
div: block,
|
|
134
136
|
p: trimmedElement,
|
|
@@ -172,6 +174,8 @@ export const resetVariants = recipe({
|
|
|
172
174
|
base: {},
|
|
173
175
|
variants: {
|
|
174
176
|
as: elementReset,
|
|
177
|
+
// When any border color or width is specified, automatically set borderWidth to 'none'
|
|
178
|
+
// and borderStyle to 'solid'. This handles properties with old naming and css-aligned
|
|
175
179
|
hasBorder: {
|
|
176
180
|
true: borderReset
|
|
177
181
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export declare const cssLayerReset: string;
|
|
2
2
|
export declare const cssLayerTheme: string;
|
|
3
|
-
export declare const cssLayerTypography: string;
|
|
4
|
-
export declare const cssLayerUtil: string;
|
|
5
3
|
export declare const cssColorSet: string;
|
|
4
|
+
export declare const cssLayerTypography: string;
|
|
5
|
+
export declare const cssLayerStyleprops: string;
|
|
6
6
|
export declare const cssLayerComponent: string;
|
|
7
|
+
export declare const cssLayerUtil: string;
|
|
7
8
|
//# sourceMappingURL=layers.css.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layers.css.d.ts","sourceRoot":"","sources":["../../lib/styles/layers.css.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"layers.css.d.ts","sourceRoot":"","sources":["../../lib/styles/layers.css.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,aAAa,QAAuB,CAAC;AAClD,eAAO,MAAM,aAAa,QAAuB,CAAC;AAClD,eAAO,MAAM,WAAW,QAAqD,CAAC;AAC9E,eAAO,MAAM,kBAAkB,QAG9B,CAAC;AACF,eAAO,MAAM,kBAAkB,QAA4B,CAAC;AAC5D,eAAO,MAAM,iBAAiB,QAA2B,CAAC;AAC1D,eAAO,MAAM,YAAY,QAAsB,CAAC"}
|
|
@@ -3,12 +3,16 @@
|
|
|
3
3
|
import * as __vanilla_filescope__ from '@vanilla-extract/css/fileScope';
|
|
4
4
|
__vanilla_filescope__.setFileScope("lib/styles/layers.css.ts", "@autoguru/overdrive");
|
|
5
5
|
import { globalLayer } from '@vanilla-extract/css';
|
|
6
|
+
globalLayer('ag, reset, theme, styleprops, component, util');
|
|
6
7
|
export const cssLayerReset = globalLayer('reset');
|
|
7
8
|
export const cssLayerTheme = globalLayer('theme');
|
|
9
|
+
export const cssColorSet = globalLayer({
|
|
10
|
+
parent: cssLayerTheme
|
|
11
|
+
}, 'colorset');
|
|
8
12
|
export const cssLayerTypography = globalLayer({
|
|
9
13
|
parent: cssLayerTheme
|
|
10
14
|
}, 'typography');
|
|
11
|
-
export const
|
|
12
|
-
export const cssColorSet = globalLayer('colorset');
|
|
15
|
+
export const cssLayerStyleprops = globalLayer('styleprops');
|
|
13
16
|
export const cssLayerComponent = globalLayer('component');
|
|
17
|
+
export const cssLayerUtil = globalLayer('util');
|
|
14
18
|
__vanilla_filescope__.endFileScope();
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
export declare const valueArrays: {
|
|
2
|
+
borderColors: ("page" | "hard" | "soft" | "accent" | "success" | "info" | "danger" | "warning" | "muted" | "default" | "disabled")[];
|
|
3
|
+
gapSizesWithVar: ("1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "none")[];
|
|
4
|
+
intentBackgroundColoursStandard: ("success" | "danger" | "warning" | "neutral" | "primary" | "brand" | "secondary" | "shine" | "information")[];
|
|
5
|
+
intentBorderColours: ("success" | "danger" | "warning" | "neutral" | "primary" | "brand" | "secondary" | "shine" | "information")[];
|
|
6
|
+
intentForegroundColours: ("success" | "danger" | "warning" | "neutral" | "primary" | "brand" | "secondary" | "shine" | "information")[];
|
|
7
|
+
};
|
|
1
8
|
export declare const responsiveConditions: {
|
|
2
9
|
mobile: {};
|
|
3
10
|
tablet: {
|
|
@@ -465,16 +472,9 @@ export declare const sprinkles: ((props: {
|
|
|
465
472
|
properties: Set<"colour" | "backgroundColour" | "color" | "width" | "size" | "fontSize" | "lineHeight" | "fontWeight" | "opacity" | "alignContent" | "alignItems" | "alignSelf" | "backgroundColor" | "borderBottomColor" | "borderBottomStyle" | "borderBottomWidth" | "borderLeftColor" | "borderLeftStyle" | "borderLeftWidth" | "borderRightColor" | "borderRightStyle" | "borderRightWidth" | "borderTopColor" | "borderTopStyle" | "borderTopWidth" | "boxShadow" | "columnGap" | "display" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "height" | "justifyContent" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxWidth" | "minWidth" | "order" | "overflowX" | "overflowY" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "pointerEvents" | "position" | "rowGap" | "textAlign" | "textTransform" | "textWrap" | "userSelect" | "wordBreak" | "borderColor" | "borderRadius" | "borderStyle" | "borderWidth" | "gap" | "margin" | "overflow" | "padding" | "placeItems" | "text" | "borderBottomColour" | "borderLeftColour" | "borderRightColour" | "borderTopColour" | "useVar" | "bg" | "fg" | "borderColorX" | "borderColorY" | "borderColour" | "borderColourX" | "borderColourY" | "borderStyleBottom" | "borderStyleLeft" | "borderStyleRight" | "borderStyleTop" | "gridColumns" | "borderWidthX" | "borderWidthY" | "borderWidthBottom" | "borderWidthLeft" | "borderWidthRight" | "borderWidthTop" | "p" | "paddingX" | "px" | "paddingY" | "py" | "pt" | "pr" | "pb" | "pl" | "m" | "marginX" | "mx" | "marginY" | "my" | "mt" | "mr" | "mb" | "ml">;
|
|
466
473
|
};
|
|
467
474
|
export type Sprinkles = Parameters<typeof sprinkles>[0];
|
|
475
|
+
/**
|
|
476
|
+
* Legacy colours are not a discreet combination of all colours as many typeography colour
|
|
477
|
+
* tokens are overwritten by the intentional colour sets
|
|
478
|
+
*/
|
|
468
479
|
export type SprinklesLegacyColours = Pick<Sprinkles, 'backgroundColour' | 'borderColour' | 'borderBottomColour' | 'borderLeftColour' | 'borderRightColour' | 'borderTopColour' | 'colour'>;
|
|
469
|
-
export declare const valueArrays: {
|
|
470
|
-
alignItems: ("stretch" | "center" | "end" | "start" | "baseline" | "centre" | "flexEnd" | "flexStart")[];
|
|
471
|
-
borderColors: ("page" | "hard" | "soft" | "accent" | "success" | "info" | "danger" | "warning" | "muted" | "default" | "disabled")[];
|
|
472
|
-
gapSizesWithVar: ("1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "none")[];
|
|
473
|
-
intentBackgroundColoursStandard: ("success" | "danger" | "warning" | "neutral" | "primary" | "brand" | "secondary" | "shine" | "information")[];
|
|
474
|
-
intentBorderColours: ("success" | "danger" | "warning" | "neutral" | "primary" | "brand" | "secondary" | "shine" | "information")[];
|
|
475
|
-
intentForegroundColours: ("success" | "danger" | "warning" | "neutral" | "primary" | "brand" | "secondary" | "shine" | "information")[];
|
|
476
|
-
justifyContent: ("space-around" | "space-between" | "space-evenly" | "stretch" | "center" | "end" | "start" | "centre" | "spaceAround" | "spaceBetween" | "flexEnd" | "flexStart")[];
|
|
477
|
-
spaceWithNone: ("1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "none")[];
|
|
478
|
-
width: ("1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "full" | "auto" | "fit-content" | "max-content" | "min-content")[];
|
|
479
|
-
};
|
|
480
480
|
//# sourceMappingURL=sprinkles.css.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sprinkles.css.d.ts","sourceRoot":"","sources":["../../lib/styles/sprinkles.css.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sprinkles.css.d.ts","sourceRoot":"","sources":["../../lib/styles/sprinkles.css.ts"],"names":[],"mappings":"AA4GA,eAAO,MAAM,WAAW;;;;;;CAQvB,CAAC;AAmFF,eAAO,MAAM,oBAAoB;;;;;;;;;;;CAOhC,CAAC;AAoIF,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAwD,CAAC;AAC/E,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AAExD;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG,IAAI,CACxC,SAAS,EACP,kBAAkB,GAClB,cAAc,GACd,oBAAoB,GACpB,kBAAkB,GAClB,mBAAmB,GACnB,iBAAiB,GACjB,QAAQ,CACV,CAAC"}
|