@autoguru/overdrive 4.48.0 → 4.50.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/Calendar/Calendar.css.d.ts.map +1 -1
- package/dist/components/Calendar/Calendar.css.js +4 -4
- package/dist/components/Calendar/Calendar.d.ts +3 -10
- package/dist/components/Calendar/Calendar.d.ts.map +1 -1
- package/dist/components/Calendar/Calendar.js +4 -11
- package/dist/components/DatePicker/DatePicker.d.ts +10 -4
- package/dist/components/DatePicker/DatePicker.d.ts.map +1 -1
- package/dist/components/DatePicker/DatePicker.js +36 -63
- package/dist/components/DatePicker/hooks/useCalendarPopover.d.ts +38 -0
- package/dist/components/DatePicker/hooks/useCalendarPopover.d.ts.map +1 -0
- package/dist/components/DatePicker/hooks/useCalendarPopover.js +44 -0
- package/dist/components/DateTimeField/DateField/DateField.d.ts +40 -0
- package/dist/components/DateTimeField/DateField/DateField.d.ts.map +1 -0
- package/dist/components/DateTimeField/DateField/DateField.js +110 -0
- package/dist/components/DateTimeField/DateTimeField.css.d.ts +21 -0
- package/dist/components/DateTimeField/DateTimeField.css.d.ts.map +1 -0
- package/dist/components/DateTimeField/DateTimeField.css.js +127 -0
- package/dist/components/DateTimeField/DateTimeField.d.ts +116 -0
- package/dist/components/DateTimeField/DateTimeField.d.ts.map +1 -0
- package/dist/components/DateTimeField/DateTimeField.js +107 -0
- package/dist/components/DateTimeField/TimeField/TimeField.d.ts +26 -0
- package/dist/components/DateTimeField/TimeField/TimeField.d.ts.map +1 -0
- package/dist/components/DateTimeField/TimeField/TimeField.js +99 -0
- package/dist/components/DateTimeField/default.d.ts +2 -0
- package/dist/components/DateTimeField/default.d.ts.map +1 -0
- package/dist/components/DateTimeField/default.js +3 -0
- package/dist/components/DateTimeField/index.d.ts +5 -0
- package/dist/components/DateTimeField/index.d.ts.map +1 -0
- package/dist/components/DateTimeField/index.js +5 -0
- package/dist/components/DateTimeField/types.d.ts +34 -0
- package/dist/components/DateTimeField/types.d.ts.map +1 -0
- package/dist/components/DateTimeField/types.js +3 -0
- package/dist/components/Popover/Popover.d.ts +2 -2
- package/dist/components/Popover/Popover.d.ts.map +1 -1
- package/dist/components/Popover/Popover.js +2 -2
- package/dist/components/Popover/PopoverTrigger.d.ts +9 -6
- package/dist/components/Popover/PopoverTrigger.d.ts.map +1 -1
- package/dist/components/Popover/PopoverTrigger.js +6 -3
- package/dist/components/Tabs/Tabs.d.ts +44 -0
- package/dist/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/components/Tabs/Tabs.js +41 -0
- package/dist/components/ToggleButtons/ToggleButtons.css.d.ts +18 -0
- package/dist/components/ToggleButtons/ToggleButtons.css.d.ts.map +1 -0
- package/dist/components/ToggleButtons/ToggleButtons.css.js +138 -0
- package/dist/components/ToggleButtons/ToggleButtons.d.ts +113 -0
- package/dist/components/ToggleButtons/ToggleButtons.d.ts.map +1 -0
- package/dist/components/ToggleButtons/ToggleButtons.js +199 -0
- package/dist/components/ToggleButtons/index.d.ts +2 -0
- package/dist/components/ToggleButtons/index.d.ts.map +1 -0
- package/dist/components/ToggleButtons/index.js +3 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +2 -0
- 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/useContainerWidth/index.d.ts +2 -0
- package/dist/hooks/useContainerWidth/index.d.ts.map +1 -0
- package/dist/hooks/useContainerWidth/index.js +3 -0
- package/dist/hooks/useContainerWidth/useContainerWidth.d.ts +27 -0
- package/dist/hooks/useContainerWidth/useContainerWidth.d.ts.map +1 -0
- package/dist/hooks/useContainerWidth/useContainerWidth.js +68 -0
- package/dist/styles/selectors.d.ts +1 -0
- package/dist/styles/selectors.d.ts.map +1 -1
- package/dist/styles/selectors.js +1 -0
- package/dist/utils/dateFormat.d.ts +5 -4
- package/dist/utils/dateFormat.d.ts.map +1 -1
- package/dist/utils/dateFormat.js +9 -9
- package/package.json +24 -24
- package/dist/components/DateTimePicker/DateTimePicker.css.d.ts +0 -4
- package/dist/components/DateTimePicker/DateTimePicker.css.d.ts.map +0 -1
- package/dist/components/DateTimePicker/DateTimePicker.css.js +0 -30
- package/dist/components/DateTimePicker/DateTimePicker.d.ts +0 -68
- package/dist/components/DateTimePicker/DateTimePicker.d.ts.map +0 -1
- package/dist/components/DateTimePicker/DateTimePicker.js +0 -130
- package/dist/components/DateTimePicker/default.d.ts +0 -2
- package/dist/components/DateTimePicker/default.d.ts.map +0 -1
- package/dist/components/DateTimePicker/default.js +0 -3
|
@@ -39,19 +39,22 @@ export const PopoverTrigger = ({
|
|
|
39
39
|
shouldFlip,
|
|
40
40
|
testId,
|
|
41
41
|
lang,
|
|
42
|
+
ref,
|
|
42
43
|
onStateReady
|
|
43
44
|
}) => {
|
|
44
45
|
const state = useOverlayTriggerState({});
|
|
45
|
-
const
|
|
46
|
+
const internalRef = useRef(null);
|
|
47
|
+
const triggerRef = ref !== null && ref !== void 0 ? ref : internalRef;
|
|
46
48
|
|
|
47
49
|
// Provide state access to parent component
|
|
48
50
|
React.useEffect(() => {
|
|
49
51
|
if (onStateReady) {
|
|
50
52
|
onStateReady({
|
|
51
|
-
close: state.close
|
|
53
|
+
close: state.close,
|
|
54
|
+
isOpen: state.isOpen
|
|
52
55
|
});
|
|
53
56
|
}
|
|
54
|
-
}, [onStateReady, state.close]);
|
|
57
|
+
}, [onStateReady, state.close, state.isOpen]);
|
|
55
58
|
const {
|
|
56
59
|
triggerProps,
|
|
57
60
|
overlayProps
|
|
@@ -10,11 +10,55 @@ interface TabsContextValue {
|
|
|
10
10
|
getTabCount: () => number;
|
|
11
11
|
}
|
|
12
12
|
export declare const TabsContext: React.Context<TabsContextValue | null>;
|
|
13
|
+
/**
|
|
14
|
+
* ## Tabs
|
|
15
|
+
*
|
|
16
|
+
* A tabbed interface component that manages tab navigation and content panels. The tabs system consists of several coordinated components:
|
|
17
|
+
*
|
|
18
|
+
* ### Component Structure
|
|
19
|
+
*
|
|
20
|
+
* - **Tabs** - Root container that provides context and state management
|
|
21
|
+
* - **TabList** - Container for tab navigation elements with keyboard navigation and scrolling support
|
|
22
|
+
* - **Tab** - Individual clickable tab with support for indications and custom rendering
|
|
23
|
+
* - **TabPanes** - Container for tab content panels with optional inactive rendering
|
|
24
|
+
* - **TabPane** - Individual content panel associated with each tab
|
|
25
|
+
*
|
|
26
|
+
* ### Component Props Overview
|
|
27
|
+
*
|
|
28
|
+
* #### TabList Props
|
|
29
|
+
* - `stretch?: boolean` - Whether tabs should stretch to fill available width
|
|
30
|
+
* - `scrollable?: boolean` - Enable horizontal scrolling with navigation buttons (cannot be used with stretch)
|
|
31
|
+
*
|
|
32
|
+
* #### Tab Props
|
|
33
|
+
* - `id?: string` - Custom ID for the tab element (auto-generated if not provided)
|
|
34
|
+
* - `as?: ElementType | ReactElement` - Custom component or element to render the tab as
|
|
35
|
+
* - `indication?: number` - Optional numeric badge displayed on the tab
|
|
36
|
+
*
|
|
37
|
+
* #### TabPanes Props
|
|
38
|
+
* - `renderInactivePanes?: boolean` - Whether to render inactive tab panels in the DOM (hidden but present)
|
|
39
|
+
* - `paddingTop?: string` - Top padding for the panes container (default: '6')
|
|
40
|
+
* - `paddingBottom?: string` - Bottom padding for the panes container (default: '6')
|
|
41
|
+
*
|
|
42
|
+
* #### TabPane Props
|
|
43
|
+
* - `id?: string` - Custom ID for the tab panel element (auto-generated if not provided)
|
|
44
|
+
*
|
|
45
|
+
* ### Visual Variants
|
|
46
|
+
*
|
|
47
|
+
* The `appearance` prop supports different visual styles:
|
|
48
|
+
* - `"underlined"` (default) - Tabs with bottom border indication
|
|
49
|
+
* - `"pill"`
|
|
50
|
+
* - `"minimal"`
|
|
51
|
+
*/
|
|
13
52
|
export interface TabsProps {
|
|
53
|
+
/** Custom ID for the tabs container. Auto-generated if not provided. */
|
|
14
54
|
id?: string | null;
|
|
55
|
+
/** Index of the currently active tab (0-based) */
|
|
15
56
|
active: number;
|
|
57
|
+
/** Visual appearance style for the tabs */
|
|
16
58
|
appearance?: TabAppearance;
|
|
59
|
+
/** Tab navigation and content elements (typically TabList and TabPanes) */
|
|
17
60
|
children?: ReactNode;
|
|
61
|
+
/** Callback fired when the active tab changes */
|
|
18
62
|
onChange?: (index: number) => void;
|
|
19
63
|
}
|
|
20
64
|
export declare const Tabs: FunctionComponent<TabsProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tabs.d.ts","sourceRoot":"","sources":["../../../lib/components/Tabs/Tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAEb,KAAK,iBAAiB,EACtB,KAAK,SAAS,EAId,MAAM,OAAO,CAAC;AAIf,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C,UAAU,gBAAgB;IACzB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,aAAa,CAAC;IAC1B,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAC;IAC7D,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,WAAW,GAAG,SAAS,CAAC;IACnD,WAAW,EAAE,MAAM,MAAM,CAAC;CAC1B;AAED,eAAO,MAAM,WAAW,wCAA+C,CAAC;AAExE,MAAM,WAAW,SAAS;IACzB,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,aAAa,CAAC;IAC3B,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAED,eAAO,MAAM,IAAI,EAAE,iBAAiB,CAAC,SAAS,CAuD7C,CAAC"}
|
|
1
|
+
{"version":3,"file":"Tabs.d.ts","sourceRoot":"","sources":["../../../lib/components/Tabs/Tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAEb,KAAK,iBAAiB,EACtB,KAAK,SAAS,EAId,MAAM,OAAO,CAAC;AAIf,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C,UAAU,gBAAgB;IACzB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,aAAa,CAAC;IAC1B,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAC;IAC7D,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,WAAW,GAAG,SAAS,CAAC;IACnD,WAAW,EAAE,MAAM,MAAM,CAAC;CAC1B;AAED,eAAO,MAAM,WAAW,wCAA+C,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,WAAW,SAAS;IACzB,wEAAwE;IACxE,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,kDAAkD;IAClD,MAAM,EAAE,MAAM,CAAC;IACf,2CAA2C;IAC3C,UAAU,CAAC,EAAE,aAAa,CAAC;IAC3B,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,iDAAiD;IACjD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAED,eAAO,MAAM,IAAI,EAAE,iBAAiB,CAAC,SAAS,CAuD7C,CAAC"}
|
|
@@ -4,6 +4,47 @@ import React, { createContext, useCallback, useMemo, useRef } from 'react';
|
|
|
4
4
|
import { useId, useUncontrolledState } from "../../utils/index.js";
|
|
5
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
6
|
export const TabsContext = /*#__PURE__*/createContext(null);
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* ## Tabs
|
|
10
|
+
*
|
|
11
|
+
* A tabbed interface component that manages tab navigation and content panels. The tabs system consists of several coordinated components:
|
|
12
|
+
*
|
|
13
|
+
* ### Component Structure
|
|
14
|
+
*
|
|
15
|
+
* - **Tabs** - Root container that provides context and state management
|
|
16
|
+
* - **TabList** - Container for tab navigation elements with keyboard navigation and scrolling support
|
|
17
|
+
* - **Tab** - Individual clickable tab with support for indications and custom rendering
|
|
18
|
+
* - **TabPanes** - Container for tab content panels with optional inactive rendering
|
|
19
|
+
* - **TabPane** - Individual content panel associated with each tab
|
|
20
|
+
*
|
|
21
|
+
* ### Component Props Overview
|
|
22
|
+
*
|
|
23
|
+
* #### TabList Props
|
|
24
|
+
* - `stretch?: boolean` - Whether tabs should stretch to fill available width
|
|
25
|
+
* - `scrollable?: boolean` - Enable horizontal scrolling with navigation buttons (cannot be used with stretch)
|
|
26
|
+
*
|
|
27
|
+
* #### Tab Props
|
|
28
|
+
* - `id?: string` - Custom ID for the tab element (auto-generated if not provided)
|
|
29
|
+
* - `as?: ElementType | ReactElement` - Custom component or element to render the tab as
|
|
30
|
+
* - `indication?: number` - Optional numeric badge displayed on the tab
|
|
31
|
+
*
|
|
32
|
+
* #### TabPanes Props
|
|
33
|
+
* - `renderInactivePanes?: boolean` - Whether to render inactive tab panels in the DOM (hidden but present)
|
|
34
|
+
* - `paddingTop?: string` - Top padding for the panes container (default: '6')
|
|
35
|
+
* - `paddingBottom?: string` - Bottom padding for the panes container (default: '6')
|
|
36
|
+
*
|
|
37
|
+
* #### TabPane Props
|
|
38
|
+
* - `id?: string` - Custom ID for the tab panel element (auto-generated if not provided)
|
|
39
|
+
*
|
|
40
|
+
* ### Visual Variants
|
|
41
|
+
*
|
|
42
|
+
* The `appearance` prop supports different visual styles:
|
|
43
|
+
* - `"underlined"` (default) - Tabs with bottom border indication
|
|
44
|
+
* - `"pill"`
|
|
45
|
+
* - `"minimal"`
|
|
46
|
+
*/
|
|
47
|
+
|
|
7
48
|
export const Tabs = ({
|
|
8
49
|
id: incomingId,
|
|
9
50
|
active = 0,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { cssLayerComponent } from '../../styles/layers.css';
|
|
2
|
+
export declare const toggleButtonsContainer: string;
|
|
3
|
+
export declare const toggleButtonsContainerStyle: string;
|
|
4
|
+
export declare const toggleButtonGroup: import("@vanilla-extract/recipes").RuntimeFn<{
|
|
5
|
+
iconOnly: {
|
|
6
|
+
true: {
|
|
7
|
+
'@layer': {
|
|
8
|
+
[cssLayerComponent]: {
|
|
9
|
+
color: `var(--${string})`;
|
|
10
|
+
display: "block";
|
|
11
|
+
lineHeight: number;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
}>;
|
|
17
|
+
export declare const toggleButton: string;
|
|
18
|
+
//# sourceMappingURL=ToggleButtons.css.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToggleButtons.css.d.ts","sourceRoot":"","sources":["../../../lib/components/ToggleButtons/ToggleButtons.css.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAS5D,eAAO,MAAM,sBAAsB,QAAoB,CAAC;AACxD,eAAO,MAAM,2BAA2B,QAOtC,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;gBAuBzB,CAAC,iBAAiB,CAAC;;;;kBAIlB;;;;EAQJ,CAAC;AAIH,eAAO,MAAM,YAAY,QA0FvB,CAAC"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import * as __vanilla_filescope__ from '@vanilla-extract/css/fileScope';
|
|
4
|
+
__vanilla_filescope__.setFileScope("lib/components/ToggleButtons/ToggleButtons.css.ts", "@autoguru/overdrive");
|
|
5
|
+
import { createContainer, style } from '@vanilla-extract/css';
|
|
6
|
+
import { recipe } from '@vanilla-extract/recipes';
|
|
7
|
+
import { elementReset } from "../../styles/elementReset.css.js";
|
|
8
|
+
import { focusOutlineStyle } from "../../styles/focusOutline.css.js";
|
|
9
|
+
import { cssLayerComponent } from "../../styles/layers.css.js";
|
|
10
|
+
import { selectors } from "../../styles/selectors.js";
|
|
11
|
+
import { sprinkles } from "../../styles/sprinkles.css.js";
|
|
12
|
+
import { overdriveTokens as vars } from "../../themes/theme.css.js";
|
|
13
|
+
import { WIDTH_COMPACT_ORIENTATION } from "./ToggleButtons.js";
|
|
14
|
+
const TOGGLE_BUTTON_HEIGHT = '40px';
|
|
15
|
+
export const toggleButtonsContainer = createContainer("toggleButtonsContainer");
|
|
16
|
+
export const toggleButtonsContainerStyle = style({
|
|
17
|
+
'@layer': {
|
|
18
|
+
[cssLayerComponent]: {
|
|
19
|
+
containerName: toggleButtonsContainer,
|
|
20
|
+
containerType: 'inline-size'
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}, "toggleButtonsContainerStyle");
|
|
24
|
+
export const toggleButtonGroup = recipe({
|
|
25
|
+
base: [{
|
|
26
|
+
'@layer': {
|
|
27
|
+
[cssLayerComponent]: {
|
|
28
|
+
color: vars.color.gamut.gray[500],
|
|
29
|
+
display: 'grid',
|
|
30
|
+
gridTemplateColumns: '1fr',
|
|
31
|
+
'@container': {
|
|
32
|
+
[`${toggleButtonsContainer} (min-width: ${WIDTH_COMPACT_ORIENTATION}px)`]: {
|
|
33
|
+
gridTemplateColumns: 'repeat(auto-fit, minmax(0, 1fr))'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}],
|
|
39
|
+
variants: {
|
|
40
|
+
iconOnly: {
|
|
41
|
+
true: {
|
|
42
|
+
'@layer': {
|
|
43
|
+
[cssLayerComponent]: {
|
|
44
|
+
color: vars.color.content.normal,
|
|
45
|
+
display: 'block',
|
|
46
|
+
lineHeight: 1
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
defaultVariants: {
|
|
53
|
+
iconOnly: false
|
|
54
|
+
}
|
|
55
|
+
}, "toggleButtonGroup");
|
|
56
|
+
const selectorNotIconOnly = `${toggleButtonGroup.classNames.base}:not([data-icon-only])`;
|
|
57
|
+
export const toggleButton = style([elementReset.button, focusOutlineStyle, sprinkles({
|
|
58
|
+
backgroundColor: 'page',
|
|
59
|
+
borderColour: 'gray',
|
|
60
|
+
borderStyle: 'solid',
|
|
61
|
+
borderWidth: '1',
|
|
62
|
+
px: '3',
|
|
63
|
+
text: '4',
|
|
64
|
+
textWrap: 'nowrap'
|
|
65
|
+
}), {
|
|
66
|
+
'@layer': {
|
|
67
|
+
[cssLayerComponent]: {
|
|
68
|
+
appearance: 'none',
|
|
69
|
+
color: 'inherit',
|
|
70
|
+
height: TOGGLE_BUTTON_HEIGHT,
|
|
71
|
+
overflow: 'hidden',
|
|
72
|
+
textOverflow: 'ellipsis',
|
|
73
|
+
transitionDuration: '0.1s',
|
|
74
|
+
transitionProperty: 'background-color, border-color, box-shadow, color',
|
|
75
|
+
transitionTimingFunction: vars.animation.easing.standard,
|
|
76
|
+
userSelect: 'none',
|
|
77
|
+
selectors: {
|
|
78
|
+
'&:first-child': {
|
|
79
|
+
borderBottomLeftRadius: vars.border.radius.md,
|
|
80
|
+
borderTopLeftRadius: vars.border.radius.md
|
|
81
|
+
},
|
|
82
|
+
'&:last-child': {
|
|
83
|
+
borderBottomRightRadius: vars.border.radius.md,
|
|
84
|
+
borderTopRightRadius: vars.border.radius.md
|
|
85
|
+
},
|
|
86
|
+
'&:focus-visible': {
|
|
87
|
+
position: 'relative',
|
|
88
|
+
zIndex: 1
|
|
89
|
+
},
|
|
90
|
+
'&+&': {
|
|
91
|
+
borderLeftStyle: 'none'
|
|
92
|
+
},
|
|
93
|
+
[selectors.hoverNotDisabled]: {
|
|
94
|
+
cursor: 'pointer'
|
|
95
|
+
},
|
|
96
|
+
[selectors.hoverNotSelected]: {
|
|
97
|
+
backgroundColor: vars.color.gamut.gray[200],
|
|
98
|
+
boxShadow: 'inset 0 1px 5px 0 rgba(0, 0, 0, 0.03), inset 0 2px 2px 0 rgba(0, 0, 0, 0.03), inset 0 3px 1px -2px rgba(0, 0, 0, 0.05)',
|
|
99
|
+
transitionDelay: '50ms',
|
|
100
|
+
transitionDuration: '0.2s'
|
|
101
|
+
},
|
|
102
|
+
[selectors.selected]: {
|
|
103
|
+
backgroundColor: vars.color.surface.hard,
|
|
104
|
+
borderColor: vars.color.surface.hard,
|
|
105
|
+
color: vars.color.content.inverse
|
|
106
|
+
},
|
|
107
|
+
[selectors.disabled]: {
|
|
108
|
+
cursor: 'not-allowed',
|
|
109
|
+
opacity: 0.6
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
// Container-based responsive styles for mobile stacking (only for non-iconOnly)
|
|
113
|
+
'@container': {
|
|
114
|
+
[`${toggleButtonsContainer} (max-width: ${WIDTH_COMPACT_ORIENTATION}px)`]: {
|
|
115
|
+
selectors: {
|
|
116
|
+
[`${selectorNotIconOnly} &`]: {
|
|
117
|
+
borderLeftStyle: 'solid'
|
|
118
|
+
},
|
|
119
|
+
[`${selectorNotIconOnly} &+&`]: {
|
|
120
|
+
borderTopStyle: 'none'
|
|
121
|
+
},
|
|
122
|
+
[`${selectorNotIconOnly} &:first-child`]: {
|
|
123
|
+
borderBottomLeftRadius: 0,
|
|
124
|
+
borderTopLeftRadius: vars.border.radius.md,
|
|
125
|
+
borderTopRightRadius: vars.border.radius.md
|
|
126
|
+
},
|
|
127
|
+
[`${selectorNotIconOnly} &:last-child`]: {
|
|
128
|
+
borderBottomLeftRadius: vars.border.radius.md,
|
|
129
|
+
borderBottomRightRadius: vars.border.radius.md,
|
|
130
|
+
borderTopRightRadius: 0
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}], "toggleButton");
|
|
138
|
+
__vanilla_filescope__.endFileScope();
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { AriaToggleButtonGroupItemProps } from '@react-types/button';
|
|
2
|
+
import type { Key } from '@react-types/shared';
|
|
3
|
+
import React, { type ReactNode } from 'react';
|
|
4
|
+
import { type AriaToggleButtonGroupProps } from 'react-aria';
|
|
5
|
+
import type { TestIdProp } from '../../types';
|
|
6
|
+
import { type UseBoxProps } from '../Box/useBox/useBox';
|
|
7
|
+
export interface ToggleButtonsProps extends AriaToggleButtonGroupProps, UseBoxProps, TestIdProp {
|
|
8
|
+
/**
|
|
9
|
+
* The toggle buttons to display in the group
|
|
10
|
+
* ```tsx
|
|
11
|
+
* <ToggleButton id="option1">Option 1</ToggleButton>
|
|
12
|
+
* <ToggleButton id="option2">Option 2</ToggleButton>
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
/** Whether the buttons contain only icons (affects layout styling) */
|
|
17
|
+
iconOnly?: boolean;
|
|
18
|
+
/** Whether single or multiple selection is enabled. @default 'single' */
|
|
19
|
+
selectionMode?: 'single' | 'multiple';
|
|
20
|
+
/** Whether the collection allows empty selection. @default true */
|
|
21
|
+
disallowEmptySelection?: boolean;
|
|
22
|
+
/** The currently selected keys in the collection (controlled). */
|
|
23
|
+
selectedKeys?: Iterable<Key>;
|
|
24
|
+
/** The initial selected keys in the collection (uncontrolled). */
|
|
25
|
+
defaultSelectedKeys?: Iterable<Key>;
|
|
26
|
+
/** Handler that is called when the selection changes. */
|
|
27
|
+
onSelectionChange?: (keys: Set<Key>) => void;
|
|
28
|
+
/** Whether all toggle buttons are disabled. */
|
|
29
|
+
isDisabled?: boolean;
|
|
30
|
+
/** (_Not in use_) The orientation of the toggle button group. @default 'horizontal' */
|
|
31
|
+
orientation?: 'horizontal' | 'vertical';
|
|
32
|
+
}
|
|
33
|
+
export declare const WIDTH_COMPACT_ORIENTATION = 640;
|
|
34
|
+
/**
|
|
35
|
+
* ## ToggleButtons
|
|
36
|
+
*
|
|
37
|
+
* A toggle button group component that allows users to select one option from a set (multiple selection
|
|
38
|
+
* configurable). The ToggleButtons component also exports `ToggleButton` which are the child contents.
|
|
39
|
+
* Each `ToggleButton` item must be populated with an `id="[value]"` prop which is used to identify it
|
|
40
|
+
* both for default selection and in the on-change event.
|
|
41
|
+
*
|
|
42
|
+
* ### Configuration Overview
|
|
43
|
+
* - **Selection mode**: `selectionMode` - "single" or "multiple" behavior
|
|
44
|
+
* - **Default selection**: `defaultSelectedKeys` - initial selected keys as `string[]` (uncontrolled)
|
|
45
|
+
* - **Controlled mode**: `selectedKeys` + `onSelectionChange` - external state control
|
|
46
|
+
* - **Icon-only**: `iconOnly` - changes layout for single icon content (ARIA label or hidden text label required)
|
|
47
|
+
* - `disallowEmptySelection`: Prevents deselecting all options (**default**: `true`)
|
|
48
|
+
* - `isDisabled`: Disables the entire group
|
|
49
|
+
*
|
|
50
|
+
* ### Responsive Behaviour
|
|
51
|
+
* - For toggle buttons that are not `iconOnly` the layout will be vertical below tablet viewport width
|
|
52
|
+
*
|
|
53
|
+
* ### Accessibility
|
|
54
|
+
* - **Group Label**: When the button group has a label, associate it with `aria-labelledby` to and `id` on the heading text.
|
|
55
|
+
* To add a label without a heading use `aria-label`
|
|
56
|
+
* - **Button Label**: For icons and other visual-only buttons add `aria-label` or label text within VisuallyHidden
|
|
57
|
+
*
|
|
58
|
+
* ### Selection Handling
|
|
59
|
+
* The `onSelectionChange` callback receives a `Set<Key>` containing the IDs of current selected buttons.
|
|
60
|
+
* Since a Set is not seralizable, the common approach is to convert it to an array for operations:
|
|
61
|
+
* ```tsx
|
|
62
|
+
* onSelectionChange={(keys) => {
|
|
63
|
+
* console.log([...keys]); // Convert Set to array: ["option1", "option3"]
|
|
64
|
+
* setSelected(new Set(keys)); // Store as Set for controlled state
|
|
65
|
+
* }}
|
|
66
|
+
* ```
|
|
67
|
+
* @example
|
|
68
|
+
* ```tsx
|
|
69
|
+
* // Uncontrolled (recommended)
|
|
70
|
+
* <ToggleButtons
|
|
71
|
+
* defaultSelectedKeys={['confirm']}
|
|
72
|
+
* onSelectionChange={(keys) => handleChange(keys)}
|
|
73
|
+
* >
|
|
74
|
+
* <ToggleButton id="confirm">Confirm</ToggleButton>
|
|
75
|
+
* <ToggleButton id="decline">Decline</ToggleButton>
|
|
76
|
+
* <ToggleButton id="change-date">Change date</ToggleButton>
|
|
77
|
+
* </ToggleButtons>
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```tsx
|
|
82
|
+
* // Controlled mode
|
|
83
|
+
* const [selected, setSelected] = useState(new Set(['list']));
|
|
84
|
+
*
|
|
85
|
+
* <ToggleButtons
|
|
86
|
+
* selectedKeys={selected}
|
|
87
|
+
* onSelectionChange={setSelected}
|
|
88
|
+
* >
|
|
89
|
+
* <ToggleButton id="list">List</ToggleButton>
|
|
90
|
+
* <ToggleButton id="grid">Grid</ToggleButton>
|
|
91
|
+
* </ToggleButtons>
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```tsx
|
|
96
|
+
* // Icon-only buttons
|
|
97
|
+
* <ToggleButtons
|
|
98
|
+
* defaultSelectedKeys={['list']}
|
|
99
|
+
* iconOnly
|
|
100
|
+
* onSelectionChange={handleViewChange}
|
|
101
|
+
* >
|
|
102
|
+
* <ToggleButton id="list" aria-label="List view">
|
|
103
|
+
* <Icon icon={ListIcon} />
|
|
104
|
+
* </ToggleButton>
|
|
105
|
+
* <ToggleButton id="map" aria-label="Map view">
|
|
106
|
+
* <Icon icon={MapIcon} />
|
|
107
|
+
* </ToggleButton>
|
|
108
|
+
* </ToggleButtons>
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
export declare const ToggleButtons: React.ForwardRefExoticComponent<ToggleButtonsProps & React.RefAttributes<HTMLDivElement>>;
|
|
112
|
+
export declare const ToggleButton: React.ForwardRefExoticComponent<AriaToggleButtonGroupItemProps<"button"> & React.RefAttributes<HTMLButtonElement>>;
|
|
113
|
+
//# sourceMappingURL=ToggleButtons.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToggleButtons.d.ts","sourceRoot":"","sources":["../../../lib/components/ToggleButtons/ToggleButtons.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,KAAK,EAAE,EAIb,KAAK,SAAS,EAEd,MAAM,OAAO,CAAC;AACf,OAAO,EAGN,KAAK,0BAA0B,EAC/B,MAAM,YAAY,CAAC;AAIpB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAIhE,MAAM,WAAW,kBAChB,SAAQ,0BAA0B,EACjC,WAAW,EACX,UAAU;IACX;;;;;;OAMG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB,sEAAsE;IACtE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,yEAAyE;IACzE,aAAa,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;IACtC,mEAAmE;IACnE,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,kEAAkE;IAClE,YAAY,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC7B,kEAAkE;IAClE,mBAAmB,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;IACpC,yDAAyD;IACzD,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC;IAC7C,+CAA+C;IAC/C,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,uFAAuF;IACvF,WAAW,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;CACxC;AAGD,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAM7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4EG;AACH,eAAO,MAAM,aAAa,2FA0FzB,CAAC;AAIF,eAAO,MAAM,YAAY,oHAsCvB,CAAC"}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
4
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
|
+
const _excluded = ["children", "disallowEmptySelection", "iconOnly", "orientation", "selectionMode"],
|
|
6
|
+
_excluded2 = ["selectedKeys", "defaultSelectedKeys", "onSelectionChange", "isDisabled", "aria-describedby", "aria-details", "aria-label", "aria-labelledby"],
|
|
7
|
+
_excluded3 = ["children"];
|
|
8
|
+
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; }
|
|
9
|
+
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; }
|
|
10
|
+
import { invariant } from '@autoguru/utilities';
|
|
11
|
+
import React, { Children, forwardRef, useRef } from 'react';
|
|
12
|
+
import { useToggleButtonGroup, useToggleButtonGroupItem } from 'react-aria';
|
|
13
|
+
import { useToggleGroupState } from 'react-stately';
|
|
14
|
+
import { useContainerWidth } from "../../hooks/index.js";
|
|
15
|
+
import { mergeRefs } from "../../utils/index.js";
|
|
16
|
+
import { dataAttrs } from "../../utils/dataAttrs.js";
|
|
17
|
+
import { useBox } from "../Box/useBox/useBox.js";
|
|
18
|
+
import * as styles from "./ToggleButtons.css.js";
|
|
19
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
20
|
+
// only applies to non `iconOnly` layout
|
|
21
|
+
export const WIDTH_COMPACT_ORIENTATION = 640;
|
|
22
|
+
const ToggleButtonGroupContext = /*#__PURE__*/React.createContext(null);
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* ## ToggleButtons
|
|
26
|
+
*
|
|
27
|
+
* A toggle button group component that allows users to select one option from a set (multiple selection
|
|
28
|
+
* configurable). The ToggleButtons component also exports `ToggleButton` which are the child contents.
|
|
29
|
+
* Each `ToggleButton` item must be populated with an `id="[value]"` prop which is used to identify it
|
|
30
|
+
* both for default selection and in the on-change event.
|
|
31
|
+
*
|
|
32
|
+
* ### Configuration Overview
|
|
33
|
+
* - **Selection mode**: `selectionMode` - "single" or "multiple" behavior
|
|
34
|
+
* - **Default selection**: `defaultSelectedKeys` - initial selected keys as `string[]` (uncontrolled)
|
|
35
|
+
* - **Controlled mode**: `selectedKeys` + `onSelectionChange` - external state control
|
|
36
|
+
* - **Icon-only**: `iconOnly` - changes layout for single icon content (ARIA label or hidden text label required)
|
|
37
|
+
* - `disallowEmptySelection`: Prevents deselecting all options (**default**: `true`)
|
|
38
|
+
* - `isDisabled`: Disables the entire group
|
|
39
|
+
*
|
|
40
|
+
* ### Responsive Behaviour
|
|
41
|
+
* - For toggle buttons that are not `iconOnly` the layout will be vertical below tablet viewport width
|
|
42
|
+
*
|
|
43
|
+
* ### Accessibility
|
|
44
|
+
* - **Group Label**: When the button group has a label, associate it with `aria-labelledby` to and `id` on the heading text.
|
|
45
|
+
* To add a label without a heading use `aria-label`
|
|
46
|
+
* - **Button Label**: For icons and other visual-only buttons add `aria-label` or label text within VisuallyHidden
|
|
47
|
+
*
|
|
48
|
+
* ### Selection Handling
|
|
49
|
+
* The `onSelectionChange` callback receives a `Set<Key>` containing the IDs of current selected buttons.
|
|
50
|
+
* Since a Set is not seralizable, the common approach is to convert it to an array for operations:
|
|
51
|
+
* ```tsx
|
|
52
|
+
* onSelectionChange={(keys) => {
|
|
53
|
+
* console.log([...keys]); // Convert Set to array: ["option1", "option3"]
|
|
54
|
+
* setSelected(new Set(keys)); // Store as Set for controlled state
|
|
55
|
+
* }}
|
|
56
|
+
* ```
|
|
57
|
+
* @example
|
|
58
|
+
* ```tsx
|
|
59
|
+
* // Uncontrolled (recommended)
|
|
60
|
+
* <ToggleButtons
|
|
61
|
+
* defaultSelectedKeys={['confirm']}
|
|
62
|
+
* onSelectionChange={(keys) => handleChange(keys)}
|
|
63
|
+
* >
|
|
64
|
+
* <ToggleButton id="confirm">Confirm</ToggleButton>
|
|
65
|
+
* <ToggleButton id="decline">Decline</ToggleButton>
|
|
66
|
+
* <ToggleButton id="change-date">Change date</ToggleButton>
|
|
67
|
+
* </ToggleButtons>
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```tsx
|
|
72
|
+
* // Controlled mode
|
|
73
|
+
* const [selected, setSelected] = useState(new Set(['list']));
|
|
74
|
+
*
|
|
75
|
+
* <ToggleButtons
|
|
76
|
+
* selectedKeys={selected}
|
|
77
|
+
* onSelectionChange={setSelected}
|
|
78
|
+
* >
|
|
79
|
+
* <ToggleButton id="list">List</ToggleButton>
|
|
80
|
+
* <ToggleButton id="grid">Grid</ToggleButton>
|
|
81
|
+
* </ToggleButtons>
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```tsx
|
|
86
|
+
* // Icon-only buttons
|
|
87
|
+
* <ToggleButtons
|
|
88
|
+
* defaultSelectedKeys={['list']}
|
|
89
|
+
* iconOnly
|
|
90
|
+
* onSelectionChange={handleViewChange}
|
|
91
|
+
* >
|
|
92
|
+
* <ToggleButton id="list" aria-label="List view">
|
|
93
|
+
* <Icon icon={ListIcon} />
|
|
94
|
+
* </ToggleButton>
|
|
95
|
+
* <ToggleButton id="map" aria-label="Map view">
|
|
96
|
+
* <Icon icon={MapIcon} />
|
|
97
|
+
* </ToggleButton>
|
|
98
|
+
* </ToggleButtons>
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
export const ToggleButtons = /*#__PURE__*/forwardRef((_ref, forwardedRef) => {
|
|
102
|
+
let {
|
|
103
|
+
children,
|
|
104
|
+
disallowEmptySelection = true,
|
|
105
|
+
iconOnly = false,
|
|
106
|
+
orientation: incomingOrientation,
|
|
107
|
+
selectionMode = 'single'
|
|
108
|
+
} = _ref,
|
|
109
|
+
withBoxProps = _objectWithoutProperties(_ref, _excluded);
|
|
110
|
+
const {
|
|
111
|
+
selectedKeys,
|
|
112
|
+
defaultSelectedKeys,
|
|
113
|
+
onSelectionChange,
|
|
114
|
+
isDisabled,
|
|
115
|
+
'aria-describedby': ariaDescribedBy,
|
|
116
|
+
'aria-details': ariaDetails,
|
|
117
|
+
'aria-label': ariaLabel,
|
|
118
|
+
'aria-labelledby': ariaLabelledBy
|
|
119
|
+
} = withBoxProps,
|
|
120
|
+
boxProps = _objectWithoutProperties(withBoxProps, _excluded2);
|
|
121
|
+
const childArray = Children.toArray(children);
|
|
122
|
+
!(childArray.length > 0) ? process.env.NODE_ENV !== "production" ? invariant(false, 'ToggleButtons: Must contain at least one ToggleButton child') : invariant(false) : void 0;
|
|
123
|
+
const internalRef = useRef(null);
|
|
124
|
+
const containerWidth = useContainerWidth({
|
|
125
|
+
containerRef: internalRef
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// Determine orientation based on container width (not iconOnly)
|
|
129
|
+
const hasCompactLayout = !iconOnly && containerWidth > 0 && containerWidth < WIDTH_COMPACT_ORIENTATION;
|
|
130
|
+
const orientation = hasCompactLayout ? 'vertical' : incomingOrientation !== null && incomingOrientation !== void 0 ? incomingOrientation : 'horizontal';
|
|
131
|
+
const ariaProps = {
|
|
132
|
+
disallowEmptySelection,
|
|
133
|
+
defaultSelectedKeys,
|
|
134
|
+
isDisabled,
|
|
135
|
+
selectionMode,
|
|
136
|
+
onSelectionChange,
|
|
137
|
+
orientation,
|
|
138
|
+
selectedKeys,
|
|
139
|
+
'aria-describedby': ariaDescribedBy,
|
|
140
|
+
'aria-details': ariaDetails,
|
|
141
|
+
'aria-label': ariaLabel,
|
|
142
|
+
'aria-labelledby': ariaLabelledBy
|
|
143
|
+
};
|
|
144
|
+
const state = useToggleGroupState(ariaProps);
|
|
145
|
+
const {
|
|
146
|
+
groupProps
|
|
147
|
+
} = useToggleButtonGroup(ariaProps, state, internalRef);
|
|
148
|
+
const {
|
|
149
|
+
Component,
|
|
150
|
+
componentProps
|
|
151
|
+
} = useBox(_objectSpread(_objectSpread({}, boxProps), {}, {
|
|
152
|
+
className: !iconOnly && styles.toggleButtonsContainerStyle,
|
|
153
|
+
display: iconOnly ? 'flex' : undefined,
|
|
154
|
+
odComponent: 'toggle-buttons'
|
|
155
|
+
}));
|
|
156
|
+
return /*#__PURE__*/_jsx(Component, _objectSpread(_objectSpread({}, componentProps), {}, {
|
|
157
|
+
ref: mergeRefs([internalRef, forwardedRef]),
|
|
158
|
+
children: /*#__PURE__*/_jsx("div", _objectSpread(_objectSpread(_objectSpread({
|
|
159
|
+
className: styles.toggleButtonGroup({
|
|
160
|
+
iconOnly
|
|
161
|
+
})
|
|
162
|
+
}, groupProps), dataAttrs({
|
|
163
|
+
iconOnly
|
|
164
|
+
})), {}, {
|
|
165
|
+
children: /*#__PURE__*/_jsx(ToggleButtonGroupContext.Provider, {
|
|
166
|
+
value: state,
|
|
167
|
+
children: children
|
|
168
|
+
})
|
|
169
|
+
}))
|
|
170
|
+
}));
|
|
171
|
+
});
|
|
172
|
+
ToggleButtons.displayName = 'ToggleButtons';
|
|
173
|
+
export const ToggleButton = /*#__PURE__*/forwardRef((_ref2, forwardedRef) => {
|
|
174
|
+
let {
|
|
175
|
+
children
|
|
176
|
+
} = _ref2,
|
|
177
|
+
props = _objectWithoutProperties(_ref2, _excluded3);
|
|
178
|
+
const internalRef = useRef(null);
|
|
179
|
+
const state = React.useContext(ToggleButtonGroupContext);
|
|
180
|
+
!(state !== null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'ToggleButton: Must be used within ToggleButtons component') : invariant(false) : void 0;
|
|
181
|
+
!(props.id !== undefined) ? process.env.NODE_ENV !== "production" ? invariant(false, 'ToggleButton: Missing required "id" prop') : invariant(false) : void 0;
|
|
182
|
+
const {
|
|
183
|
+
buttonProps,
|
|
184
|
+
isSelected
|
|
185
|
+
} = useToggleButtonGroupItem(props, state, internalRef);
|
|
186
|
+
const {
|
|
187
|
+
isDisabled
|
|
188
|
+
} = props;
|
|
189
|
+
return /*#__PURE__*/_jsx("button", _objectSpread(_objectSpread(_objectSpread({}, buttonProps), {}, {
|
|
190
|
+
className: styles.toggleButton
|
|
191
|
+
}, dataAttrs({
|
|
192
|
+
selected: isSelected,
|
|
193
|
+
disabled: isDisabled
|
|
194
|
+
})), {}, {
|
|
195
|
+
ref: mergeRefs([internalRef, forwardedRef]),
|
|
196
|
+
children: children
|
|
197
|
+
}));
|
|
198
|
+
});
|
|
199
|
+
ToggleButton.displayName = 'ToggleButton';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/components/ToggleButtons/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,aAAa,EACb,YAAY,EACZ,KAAK,kBAAkB,GACvB,MAAM,iBAAiB,CAAC"}
|
|
@@ -12,6 +12,7 @@ export * from './ColourInput';
|
|
|
12
12
|
export * from './Columns';
|
|
13
13
|
export * from './DateInput';
|
|
14
14
|
export * from './DatePicker';
|
|
15
|
+
export * from './DateTimeField';
|
|
15
16
|
export * from './DividerLine';
|
|
16
17
|
export * from './DropDown';
|
|
17
18
|
export * from './EditableText';
|
|
@@ -65,6 +66,7 @@ export * from './TextContainer';
|
|
|
65
66
|
export * from './TextInput';
|
|
66
67
|
export * from './TextLink';
|
|
67
68
|
export * from './Toaster';
|
|
69
|
+
export * from './ToggleButtons';
|
|
68
70
|
export * from './Tooltip';
|
|
69
71
|
export * from './VisuallyHidden';
|
|
70
72
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,0BAA0B,CAAC;AACzC,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,0BAA0B,CAAC;AACzC,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC"}
|