@autoguru/overdrive 4.44.4-next.0 → 4.44.4
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.js +12 -15
- package/dist/components/Alert/Alert.js +8 -9
- package/dist/components/AutoSuggest/AutoSuggest.js +114 -126
- package/dist/components/Badge/Badge.js +8 -9
- package/dist/components/BulletList/Bullet.js +4 -5
- package/dist/components/BulletList/BulletList.js +4 -5
- package/dist/components/BulletText/BulletText.js +44 -47
- package/dist/components/Button/Button.js +23 -24
- package/dist/components/CheckBox/CheckBox.js +11 -12
- package/dist/components/DateTimePicker/CalendarGrid.js +7 -8
- package/dist/components/DateTimePicker/DateTimePicker.js +9 -10
- package/dist/components/DividerLine/DividerLine.js +16 -19
- package/dist/components/DropDown/DropDownOptionsList.js +15 -18
- package/dist/components/Flex/flex.js +35 -41
- package/dist/components/HorizontalAutoScroller/HorizontalAutoScroller.js +12 -13
- package/dist/components/HorizontalAutoScroller/useHorizontalAutoScroller.js +7 -8
- package/dist/components/Icon/Icon.js +6 -7
- package/dist/components/Image/ImageServerProvider.js +17 -21
- package/dist/components/Inline/Inline.js +13 -15
- package/dist/components/IntentStripe/IntentStripe.js +10 -13
- package/dist/components/LinearProgressIndicator/LinearProgressIndicator.js +3 -4
- package/dist/components/Meta/Meta.js +18 -21
- package/dist/components/Modal/Modal.js +13 -14
- package/dist/components/NumberBubble/NumberBubble.d.ts.map +1 -1
- package/dist/components/NumberBubble/NumberBubble.js +28 -29
- package/dist/components/NumberInput/useNumberInputBehaviours.js +8 -9
- package/dist/components/OptionGrid/OptionGrid.js +53 -57
- package/dist/components/OptionList/OptionListItem.js +4 -5
- package/dist/components/OrderedList/OrderedList.js +14 -18
- package/dist/components/OutsideClick/OutsideClick.js +4 -5
- package/dist/components/OverdriveProvider/FallbackProvider.js +3 -4
- package/dist/components/OverdriveProvider/OverdriveProvider.js +8 -9
- package/dist/components/Pagination/Bubble.js +8 -9
- package/dist/components/Pagination/Pagination.js +56 -63
- package/dist/components/Portal/Portal.js +5 -6
- package/dist/components/ProgressBar/ProgressBar.js +16 -19
- package/dist/components/ProgressBarGroup/ProgressBarGroup.js +7 -8
- package/dist/components/ProgressSpinner/ProgressSpinner.js +23 -26
- package/dist/components/Radio/Radio.js +6 -7
- package/dist/components/Radio/RadioGroup.js +7 -8
- package/dist/components/Section/Section.js +12 -15
- package/dist/components/SimplePagination/SimplePagination.js +5 -6
- package/dist/components/SliderProgress/ProgressStep.js +9 -10
- package/dist/components/SliderProgress/SliderProgress.js +25 -28
- package/dist/components/Stack/Stack.js +9 -10
- package/dist/components/StandardModal/StandardModal.js +11 -12
- package/dist/components/StarRating/StarRating.js +32 -36
- package/dist/components/Stepper/Stepper.js +45 -50
- package/dist/components/Table/Table.js +20 -23
- package/dist/components/Table/TableCell.js +8 -9
- package/dist/components/Table/TableHeadCell.js +10 -11
- package/dist/components/Table/TableRow.js +10 -13
- package/dist/components/Table/TableRowGroup.js +8 -11
- package/dist/components/Table/context.js +5 -6
- package/dist/components/Tabs/Tab.js +6 -7
- package/dist/components/Tabs/TabList.js +5 -6
- package/dist/components/Tabs/TabPane.js +4 -5
- package/dist/components/Tabs/TabPanes.js +18 -21
- package/dist/components/Tabs/Tabs.js +7 -8
- package/dist/components/TextContainer/TextContainer.js +21 -24
- package/dist/components/Toaster/Toast.js +65 -98
- package/dist/components/Tooltip/Tooltip.js +10 -11
- package/dist/components/Tooltip/useTooltip/useTooltip.js +11 -13
- package/dist/components/private/CheckableBase/CheckableBase.js +12 -13
- package/dist/components/private/InputBase/HintText.js +7 -8
- package/dist/components/private/InputBase/NotchedBase.js +17 -18
- package/dist/components/private/InputBase/withEnhancedInput.js +182 -187
- package/dist/hooks/useAnimationEvents/useAnimationEvents.js +5 -6
- package/dist/hooks/useAttachedBoxes/useAttachedBoxes.js +9 -10
- package/dist/hooks/useMedia/useMedia.js +1 -2
- package/dist/hooks/useWindowHeightFill/useWindowHeightFill.js +8 -9
- package/dist/styles/sprinkles.css.js +9 -18
- package/dist/styles/typography.js +28 -31
- package/dist/themes/helpers.js +13 -15
- package/dist/themes/makeTheme.js +8 -15
- package/dist/utils/css.js +1 -2
- package/dist/utils/dataAttrs.js +1 -2
- package/dist/utils/index.js +3 -9
- package/dist/utils/mapTokenToProperty.js +5 -14
- package/dist/utils/number.js +1 -2
- package/dist/utils/responsiveProps.css.js +1 -2
- package/dist/utils/sprinkles.js +1 -2
- package/package.json +2 -2
- package/dist/components/NumberBubble/NumberBubble.css.d.ts +0 -2
- package/dist/components/NumberBubble/NumberBubble.css.d.ts.map +0 -1
- package/dist/components/NumberBubble/NumberBubble.css.js +0 -11
|
@@ -21,202 +21,197 @@ import * as styles from "./withEnhancedInput.css.js"; // The event handlers we'l
|
|
|
21
21
|
// An amalgamation of the HoC props, event handlers and the consumer props.
|
|
22
22
|
// The final props we send into thw wrapping component
|
|
23
23
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
|
-
export const withEnhancedInput =
|
|
24
|
+
export const withEnhancedInput = (WrappingComponent, {
|
|
25
|
+
primitiveType = 'text',
|
|
26
|
+
withPrefixIcon = true,
|
|
27
|
+
withSuffixIcon = true,
|
|
28
|
+
defaultValue
|
|
29
|
+
// eslint-disable-next-line unicorn/no-object-as-default-parameter
|
|
30
|
+
} = {
|
|
31
|
+
primitiveType: 'text',
|
|
32
|
+
defaultValue: void 0
|
|
33
|
+
}) =>
|
|
34
|
+
/*#__PURE__*/
|
|
35
|
+
// eslint-disable-next-line react/display-name
|
|
36
|
+
forwardRef((_ref, ref) => {
|
|
25
37
|
let {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const iconSize = size === 'small' ? 'medium' : size;
|
|
84
|
-
const inputItselfClassName = clsx(elementStyles({
|
|
85
|
-
as: primitiveType === 'textarea' ? 'textarea' : 'input',
|
|
86
|
-
backgroundColour,
|
|
87
|
-
width: 'full',
|
|
88
|
-
position: 'relative',
|
|
89
|
-
display: 'flex',
|
|
90
|
-
borderRadius: 'md'
|
|
91
|
-
}), styles.input.itself.root, styles.types[primitiveType], styles.inputItselfSize[size].root.any, styles.inputItselfSize[size].root[primitiveType], {
|
|
92
|
-
[styles.inputItselfSize[size].prefixed.any]: Boolean(prefixIcon),
|
|
93
|
-
[styles.inputItselfSize[size].prefixed[primitiveType]]: Boolean(prefixIcon),
|
|
94
|
-
[styles.inputItselfSize[size].suffixed.any]: Boolean(suffixIcon || isLoading),
|
|
95
|
-
[styles.inputItselfSize[size].suffixed[primitiveType]]: Boolean(suffixIcon || isLoading)
|
|
96
|
-
});
|
|
38
|
+
// EnhanceInputPrimitiveProps
|
|
39
|
+
placeholder,
|
|
40
|
+
name,
|
|
41
|
+
id = name,
|
|
42
|
+
hintText,
|
|
43
|
+
disabled = false,
|
|
44
|
+
className,
|
|
45
|
+
isTouched,
|
|
46
|
+
isValid,
|
|
47
|
+
isLoading = false,
|
|
48
|
+
notch = true,
|
|
49
|
+
reserveHintSpace = false,
|
|
50
|
+
size = 'medium',
|
|
51
|
+
backgroundColour = 'transparent',
|
|
52
|
+
value: incomingValue = defaultValue || '',
|
|
53
|
+
onChange: incomingOnChange,
|
|
54
|
+
onReset,
|
|
55
|
+
onMouseLeave,
|
|
56
|
+
onMouseEnter,
|
|
57
|
+
onBlur,
|
|
58
|
+
onFocus,
|
|
59
|
+
onKeyDown,
|
|
60
|
+
prefixIcon,
|
|
61
|
+
suffixIcon,
|
|
62
|
+
wrapperRef,
|
|
63
|
+
autoFocus,
|
|
64
|
+
attach,
|
|
65
|
+
borderMerged
|
|
66
|
+
} = _ref,
|
|
67
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
68
|
+
!!(prefixIcon && !withPrefixIcon) ? process.env.NODE_ENV !== "production" ? invariant(false, 'prefix icon is not supported for this component') : invariant(false) : void 0;
|
|
69
|
+
!!(suffixIcon && !withSuffixIcon) ? process.env.NODE_ENV !== "production" ? invariant(false, 'suffix icon is not supported for this component') : invariant(false) : void 0;
|
|
70
|
+
const [value, onChange] = useInputControlledState(incomingValue, incomingOnChange);
|
|
71
|
+
const [isActive, setActive] = useState(false);
|
|
72
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
73
|
+
const isEmpty = primitiveType === 'date' && value === '' ? false : value === '';
|
|
74
|
+
const derivedColours = derivedColourIntent({
|
|
75
|
+
isValid,
|
|
76
|
+
isHovered,
|
|
77
|
+
isActive,
|
|
78
|
+
isTouched,
|
|
79
|
+
disabled
|
|
80
|
+
}, inputStateStyles);
|
|
81
|
+
const iconSize = size === 'small' ? 'medium' : size;
|
|
82
|
+
const inputItselfClassName = clsx(elementStyles({
|
|
83
|
+
as: primitiveType === 'textarea' ? 'textarea' : 'input',
|
|
84
|
+
backgroundColour,
|
|
85
|
+
width: 'full',
|
|
86
|
+
position: 'relative',
|
|
87
|
+
display: 'flex',
|
|
88
|
+
borderRadius: 'md'
|
|
89
|
+
}), styles.input.itself.root, styles.types[primitiveType], styles.inputItselfSize[size].root.any, styles.inputItselfSize[size].root[primitiveType], {
|
|
90
|
+
[styles.inputItselfSize[size].prefixed.any]: Boolean(prefixIcon),
|
|
91
|
+
[styles.inputItselfSize[size].prefixed[primitiveType]]: Boolean(prefixIcon),
|
|
92
|
+
[styles.inputItselfSize[size].suffixed.any]: Boolean(suffixIcon || isLoading),
|
|
93
|
+
[styles.inputItselfSize[size].suffixed[primitiveType]]: Boolean(suffixIcon || isLoading)
|
|
94
|
+
});
|
|
97
95
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
96
|
+
/*
|
|
97
|
+
Need to disable the type assertion here, as ts has no idea that P and an omitted P without its properties is just P
|
|
98
|
+
@see https://stackoverflow.com/a/53951825/2609301
|
|
99
|
+
type P = {firstName: string}
|
|
100
|
+
type A = P
|
|
101
|
+
type B = Omit<P, 'firstName'>
|
|
102
|
+
A & B != A _or_ P & Omit<P, 'firstName'> != P
|
|
103
|
+
*/
|
|
106
104
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
105
|
+
// @ts-expect-error props not assignable to type
|
|
106
|
+
const wrappingComponent = _objectSpread({
|
|
107
|
+
validation: {
|
|
108
|
+
isTouched,
|
|
109
|
+
isValid
|
|
110
|
+
},
|
|
111
|
+
size,
|
|
112
|
+
eventHandlers: {
|
|
113
|
+
onChange: wrapEvent(event => {
|
|
114
|
+
if (disabled) {
|
|
115
|
+
event.preventDefault();
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
return true;
|
|
119
|
+
}, onChange),
|
|
120
|
+
// Until https://developer.mozilla.org/en-US/docs/Web/CSS/:focus-within is more stable, the below
|
|
121
|
+
// will wrap now
|
|
122
|
+
onFocus: wrapEvent(() => setActive(true), onFocus),
|
|
123
|
+
onBlur: wrapEvent(() => setActive(false), onBlur),
|
|
124
|
+
onMouseEnter,
|
|
125
|
+
onMouseLeave,
|
|
126
|
+
onKeyDown,
|
|
127
|
+
onReset
|
|
128
|
+
},
|
|
129
|
+
field: {
|
|
130
|
+
name,
|
|
131
|
+
id,
|
|
132
|
+
disabled,
|
|
133
|
+
value,
|
|
134
|
+
autoFocus,
|
|
135
|
+
className: inputItselfClassName,
|
|
136
|
+
placeholder: notch ? undefined : placeholder,
|
|
137
|
+
ref
|
|
138
|
+
},
|
|
139
|
+
prefixed: Boolean(prefixIcon),
|
|
140
|
+
suffixed: Boolean(suffixIcon),
|
|
141
|
+
isLoading,
|
|
142
|
+
'aria-busy': isLoading || void 0
|
|
143
|
+
}, rest);
|
|
144
|
+
const onMouseOver = useCallback(() => {
|
|
145
|
+
setIsHovered(true);
|
|
146
|
+
}, []);
|
|
147
|
+
const onMouseOut = useCallback(() => {
|
|
148
|
+
setIsHovered(false);
|
|
149
|
+
}, []);
|
|
150
|
+
const iconStyles = sprinkles({
|
|
151
|
+
pointerEvents: 'none',
|
|
152
|
+
position: 'absolute'
|
|
153
|
+
});
|
|
154
|
+
return /*#__PURE__*/_jsxs(Box, {
|
|
155
|
+
width: "full",
|
|
156
|
+
className: className,
|
|
157
|
+
onMouseEnter: onMouseOver,
|
|
158
|
+
onMouseLeave: onMouseOut,
|
|
159
|
+
children: [/*#__PURE__*/_jsx(NotchedBase, {
|
|
160
|
+
id: id,
|
|
161
|
+
prefixed: Boolean(prefixIcon),
|
|
162
|
+
isEmpty: isEmpty,
|
|
163
|
+
size: size,
|
|
164
|
+
disabled: disabled,
|
|
165
|
+
notch: notch,
|
|
166
|
+
placeholder: placeholder,
|
|
167
|
+
attach: attach,
|
|
168
|
+
borderMerged: borderMerged,
|
|
169
|
+
isFocused: isActive,
|
|
170
|
+
isHovered: isHovered,
|
|
171
|
+
placeholderColourClassName: clsx({
|
|
172
|
+
[derivedColours.colour]: !isEmpty
|
|
173
|
+
}),
|
|
174
|
+
borderColourClassName: derivedColours.borderColour,
|
|
175
|
+
children: /*#__PURE__*/_jsxs(Box, {
|
|
176
|
+
ref: wrapperRef,
|
|
177
|
+
className: styles.inputWrapperSize[size].root[primitiveType],
|
|
157
178
|
width: "full",
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
size: size,
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
children: [prefixIcon ? /*#__PURE__*/_jsx(Icon, {
|
|
183
|
-
icon: prefixIcon,
|
|
184
|
-
size: iconSize,
|
|
185
|
-
className: clsx(iconStyles, styles.iconRoot, styles.prefixIcon, styles.iconSize[size], derivedColours.colour)
|
|
186
|
-
}) : null, isLoading ? /*#__PURE__*/_jsx(ProgressSpinner, {
|
|
187
|
-
colour: "default",
|
|
188
|
-
size: size === 'large' ? size : undefined,
|
|
189
|
-
className: clsx(iconStyles, styles.iconRoot, styles.suffixIcon, styles.iconSize[size])
|
|
190
|
-
}) : null, suffixIcon && !isLoading ? /*#__PURE__*/_jsx(Icon, {
|
|
191
|
-
icon: suffixIcon,
|
|
192
|
-
size: iconSize,
|
|
193
|
-
className: clsx(iconStyles, styles.iconRoot, styles.suffixIcon, styles.iconSize[size], derivedColours.colour)
|
|
194
|
-
}) : null, /*#__PURE__*/_jsx(WrappingComponent, _objectSpread({}, wrappingComponent))]
|
|
195
|
-
})
|
|
196
|
-
}), hintText || reserveHintSpace ? /*#__PURE__*/_jsx(HintText, {
|
|
197
|
-
className: derivedColours.colour,
|
|
198
|
-
hintText: hintText,
|
|
199
|
-
disabled: disabled,
|
|
200
|
-
reserveHintSpace: reserveHintSpace,
|
|
201
|
-
size: size
|
|
202
|
-
}) : null]
|
|
203
|
-
});
|
|
204
|
-
})
|
|
205
|
-
);
|
|
206
|
-
};
|
|
179
|
+
height: "full",
|
|
180
|
+
children: [prefixIcon ? /*#__PURE__*/_jsx(Icon, {
|
|
181
|
+
icon: prefixIcon,
|
|
182
|
+
size: iconSize,
|
|
183
|
+
className: clsx(iconStyles, styles.iconRoot, styles.prefixIcon, styles.iconSize[size], derivedColours.colour)
|
|
184
|
+
}) : null, isLoading ? /*#__PURE__*/_jsx(ProgressSpinner, {
|
|
185
|
+
colour: "default",
|
|
186
|
+
size: size === 'large' ? size : undefined,
|
|
187
|
+
className: clsx(iconStyles, styles.iconRoot, styles.suffixIcon, styles.iconSize[size])
|
|
188
|
+
}) : null, suffixIcon && !isLoading ? /*#__PURE__*/_jsx(Icon, {
|
|
189
|
+
icon: suffixIcon,
|
|
190
|
+
size: iconSize,
|
|
191
|
+
className: clsx(iconStyles, styles.iconRoot, styles.suffixIcon, styles.iconSize[size], derivedColours.colour)
|
|
192
|
+
}) : null, /*#__PURE__*/_jsx(WrappingComponent, _objectSpread({}, wrappingComponent))]
|
|
193
|
+
})
|
|
194
|
+
}), hintText || reserveHintSpace ? /*#__PURE__*/_jsx(HintText, {
|
|
195
|
+
className: derivedColours.colour,
|
|
196
|
+
hintText: hintText,
|
|
197
|
+
disabled: disabled,
|
|
198
|
+
reserveHintSpace: reserveHintSpace,
|
|
199
|
+
size: size
|
|
200
|
+
}) : null]
|
|
201
|
+
});
|
|
202
|
+
});
|
|
207
203
|
const stateNodeGetter = styles => (isHovered, isActive) => {
|
|
208
204
|
if (isHovered) return styles.hover;
|
|
209
205
|
if (isActive) return styles.active;
|
|
210
206
|
return styles.default;
|
|
211
207
|
};
|
|
212
|
-
const derivedColourIntent = (
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
} = _ref2;
|
|
208
|
+
const derivedColourIntent = ({
|
|
209
|
+
isTouched,
|
|
210
|
+
isValid,
|
|
211
|
+
disabled,
|
|
212
|
+
isHovered,
|
|
213
|
+
isActive
|
|
214
|
+
}, styles) => {
|
|
220
215
|
if (disabled) return styles.disabled;
|
|
221
216
|
if (isTouched === true) {
|
|
222
217
|
// Validation route
|
|
@@ -3,12 +3,11 @@
|
|
|
3
3
|
import { useEffect, useRef } from 'react';
|
|
4
4
|
const finishEvents = ['animationend', 'transitionend', 'transitioncancel'];
|
|
5
5
|
const startEvents = ['animationstart', 'transitionrun'];
|
|
6
|
-
export const useAnimationEvents =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
} = _ref;
|
|
6
|
+
export const useAnimationEvents = ({
|
|
7
|
+
onAnimationStart: incomingOnAnimationStart = () => void 0,
|
|
8
|
+
onAnimationEnd: incomingOnAnimationEnd = () => void 0,
|
|
9
|
+
elementRef: incomingRef
|
|
10
|
+
}) => {
|
|
12
11
|
const elementRef = incomingRef !== null && incomingRef !== void 0 && incomingRef.current ? incomingRef : useRef(null);
|
|
13
12
|
const onAnimationStart = useRef(incomingOnAnimationStart);
|
|
14
13
|
const onAnimationEnd = useRef(incomingOnAnimationEnd);
|
|
@@ -20,13 +20,12 @@ function useResponsiveValue(responsiveValue) {
|
|
|
20
20
|
}, 1);
|
|
21
21
|
return getEarliestKnownToken(responsiveValue, activeBP);
|
|
22
22
|
}
|
|
23
|
-
export const useAttachedBoxes =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
} = _ref;
|
|
23
|
+
export const useAttachedBoxes = ({
|
|
24
|
+
count,
|
|
25
|
+
columnCount: incomingColumnCount,
|
|
26
|
+
gap = '1',
|
|
27
|
+
backgroundColour = 'gray900'
|
|
28
|
+
}) => {
|
|
30
29
|
const columnCount = useResponsiveValue(incomingColumnCount);
|
|
31
30
|
const decimals = count / columnCount % 1;
|
|
32
31
|
let colStart;
|
|
@@ -36,12 +35,12 @@ export const useAttachedBoxes = _ref => {
|
|
|
36
35
|
const bottomLeftIndex = decimals ? Math.floor(count / columnCount) * columnCount : count - columnCount;
|
|
37
36
|
return [Array.from({
|
|
38
37
|
length: count
|
|
39
|
-
}).map((_, index) =>
|
|
38
|
+
}).map((_, index) => _ref => {
|
|
40
39
|
let {
|
|
41
40
|
children,
|
|
42
41
|
className
|
|
43
|
-
} =
|
|
44
|
-
rest = _objectWithoutProperties(
|
|
42
|
+
} = _ref,
|
|
43
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
45
44
|
isLastItem = index === count - 1;
|
|
46
45
|
if (isLastItem && decimals) {
|
|
47
46
|
//is last item and is not a perfect division
|
|
@@ -4,8 +4,7 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
|
4
4
|
import { useCallback, useLayoutEffect, useMemo, useState } from 'react';
|
|
5
5
|
import { useRuntimeTokens } from "../../components/OverdriveProvider/index.js";
|
|
6
6
|
import { isBrowser } from "../../utils/index.js";
|
|
7
|
-
export const useMedia =
|
|
8
|
-
let fallbackCase = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
7
|
+
export const useMedia = (queries, fallbackCase = false) => {
|
|
9
8
|
const {
|
|
10
9
|
breakpoints
|
|
11
10
|
} = useRuntimeTokens();
|
|
@@ -5,15 +5,14 @@ import { useTheme } from "../../components/OverdriveProvider/index.js";
|
|
|
5
5
|
import { overdriveTokens } from "../../themes/theme.css.js";
|
|
6
6
|
import { getThemeTokenValue } from "../../utils/css.js";
|
|
7
7
|
import { useResponsiveValue } from "../useResponsiveValue/useResponsiveValue.js";
|
|
8
|
-
export const useWindowHeightFill =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
} = _ref;
|
|
8
|
+
export const useWindowHeightFill = ({
|
|
9
|
+
bottomGap = 'none',
|
|
10
|
+
includeMobile = false,
|
|
11
|
+
serverVhFallback = 100,
|
|
12
|
+
containerRef,
|
|
13
|
+
observedElementRef,
|
|
14
|
+
maxHeight
|
|
15
|
+
}) => {
|
|
17
16
|
// Create an observer instance linked to the callback function
|
|
18
17
|
const cappedHeight = useResponsiveValue([includeMobile,, true]);
|
|
19
18
|
const {
|
|
@@ -38,24 +38,15 @@ const flexAlignmentsWithSpace = _objectSpread(_objectSpread({}, flexAlignments),
|
|
|
38
38
|
'space-between': 'space-between',
|
|
39
39
|
'space-evenly': 'space-evenly'
|
|
40
40
|
});
|
|
41
|
-
const intentForegroundColours = mapValues(tokens.colours.intent,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
});
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
} = _ref2;
|
|
51
|
-
return background.standard;
|
|
52
|
-
});
|
|
53
|
-
const intentBorderColours = mapValues(tokens.colours.intent, _ref3 => {
|
|
54
|
-
let {
|
|
55
|
-
border
|
|
56
|
-
} = _ref3;
|
|
57
|
-
return border;
|
|
58
|
-
});
|
|
41
|
+
const intentForegroundColours = mapValues(tokens.colours.intent, ({
|
|
42
|
+
foreground
|
|
43
|
+
}) => foreground);
|
|
44
|
+
const intentBackgroundColoursStandard = mapValues(tokens.colours.intent, ({
|
|
45
|
+
background
|
|
46
|
+
}) => background.standard);
|
|
47
|
+
const intentBorderColours = mapValues(tokens.colours.intent, ({
|
|
48
|
+
border
|
|
49
|
+
}) => border);
|
|
59
50
|
const backgroundColours = _objectSpread(_objectSpread(_objectSpread({}, intentBackgroundColoursStandard), tokens.colours.gamut), {}, {
|
|
60
51
|
transparent: 'transparent'
|
|
61
52
|
});
|
|
@@ -26,34 +26,31 @@ const headingSizeMap = {
|
|
|
26
26
|
/**
|
|
27
27
|
* Applies typography-related styling including font size and weight, has opinionated defaults.
|
|
28
28
|
*/
|
|
29
|
-
export const typography =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
color: colour !== null && colour !== void 0 ? colour : strong === true ? 'dark' : DEFAULT_TEXT_COLOUR
|
|
55
|
-
}));
|
|
56
|
-
};
|
|
29
|
+
export const typography = ({
|
|
30
|
+
align: textAlign,
|
|
31
|
+
breakWord = false,
|
|
32
|
+
color,
|
|
33
|
+
// modern semantic colour tokens
|
|
34
|
+
colour,
|
|
35
|
+
// legacy colours
|
|
36
|
+
noWrap = false,
|
|
37
|
+
size: text = DEFAULT_TEXT_SIZE,
|
|
38
|
+
strong = false,
|
|
39
|
+
transform: textTransform,
|
|
40
|
+
weight = DEFAULT_TEXT_WEIGHT,
|
|
41
|
+
wrap,
|
|
42
|
+
wordBreak
|
|
43
|
+
}) => clsx(common, sprinkles({
|
|
44
|
+
color,
|
|
45
|
+
fontWeight: strong === true ? 'bold' : weight,
|
|
46
|
+
text,
|
|
47
|
+
textAlign,
|
|
48
|
+
textTransform,
|
|
49
|
+
textWrap: noWrap === true ? 'nowrap' : wrap,
|
|
50
|
+
wordBreak: breakWord === true ? 'break-word' : wordBreak
|
|
51
|
+
}), !color && sprinklesLegacyText({
|
|
52
|
+
color: colour !== null && colour !== void 0 ? colour : strong === true ? 'dark' : DEFAULT_TEXT_COLOUR
|
|
53
|
+
}));
|
|
57
54
|
/**
|
|
58
55
|
* Primary utility for styling typography, combines reset styles, style props and element props.
|
|
59
56
|
* Also accepts a heading tag which will apply colour, font weight and size defaults.
|
|
@@ -75,7 +72,7 @@ export const typography = _ref => {
|
|
|
75
72
|
* breakWord: true
|
|
76
73
|
* })
|
|
77
74
|
*/
|
|
78
|
-
export function textStyles(
|
|
75
|
+
export function textStyles(_ref) {
|
|
79
76
|
let {
|
|
80
77
|
as = 'span',
|
|
81
78
|
className,
|
|
@@ -83,8 +80,8 @@ export function textStyles(_ref2) {
|
|
|
83
80
|
size = isHeadingTag(as) ? headingSizeMap[as] : undefined,
|
|
84
81
|
weight = isHeadingTag(as) ? 'bold' : undefined
|
|
85
82
|
// remaining style props
|
|
86
|
-
} =
|
|
87
|
-
props = _objectWithoutProperties(
|
|
83
|
+
} = _ref,
|
|
84
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
88
85
|
return clsx(resetStyles(as), typography(_objectSpread({
|
|
89
86
|
colour,
|
|
90
87
|
size,
|
package/dist/themes/helpers.js
CHANGED
|
@@ -25,14 +25,13 @@ import { colord } from 'colord';
|
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
|
-
export const shadedColour =
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
} = _ref;
|
|
28
|
+
export const shadedColour = ({
|
|
29
|
+
colour,
|
|
30
|
+
intensity,
|
|
31
|
+
direction,
|
|
32
|
+
isDarkTheme,
|
|
33
|
+
transparency = 0
|
|
34
|
+
}) => {
|
|
36
35
|
const intensityValue = typeof intensity === 'string' ? Number(intensity) : intensity;
|
|
37
36
|
const transparencyValue = typeof transparency === 'string' ? Number(transparency) : transparency;
|
|
38
37
|
return colord(colour)[!isDarkTheme && direction === 'backward' || isDarkTheme && direction === 'forward' ? 'darken' : 'lighten'](intensityValue || void 0).alpha(typeof transparencyValue === 'number' ? 1 - transparencyValue : 1).toHex();
|
|
@@ -74,13 +73,12 @@ export const getContrastRatio = (colour1, colour2) => {
|
|
|
74
73
|
const color2luminance = getColourLuminance(getRGBValues(colour2));
|
|
75
74
|
return color1luminance > color2luminance ? (color2luminance + 0.05) / (color1luminance + 0.05) : (color1luminance + 0.05) / (color2luminance + 0.05);
|
|
76
75
|
};
|
|
77
|
-
export const passesAccessibilityContrast =
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
} = _ref2;
|
|
76
|
+
export const passesAccessibilityContrast = ({
|
|
77
|
+
colour1,
|
|
78
|
+
colour2,
|
|
79
|
+
level,
|
|
80
|
+
textSize
|
|
81
|
+
}) => {
|
|
84
82
|
const contrastRatio = getContrastRatio(colour1, colour2);
|
|
85
83
|
if (textSize === 'LARGE') {
|
|
86
84
|
return level === 'AAA' ? contrastRatio < 1 / 4.5 : contrastRatio < 1 / 3;
|