@westpac/ui 0.17.0 → 0.18.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/CHANGELOG.md +6 -0
- package/dist/component-type.json +1 -1
- package/dist/components/accordion/accordion.component.d.ts +2 -1
- package/dist/components/autocomplete/autocomplete.component.js +4 -2
- package/dist/components/autocomplete/components/autocomplete-list-box/components/autocomplete-list-box-option/autocomplete-list-box-option.styles.d.ts +1 -1
- package/dist/components/autocomplete/components/autocomplete-list-box/components/autocomplete-list-box-option/autocomplete-list-box-option.styles.js +1 -1
- package/dist/components/autocomplete/components/autocomplete-popover/autocomplete-popover.component.js +2 -1
- package/dist/components/bottom-sheet/components/bottom-sheet-dialog/bottom-sheet-dialog.styles.js +2 -2
- package/dist/components/bottom-sheet/components/bottom-sheet-modal/bottom-sheet-modal.component.js +2 -1
- package/dist/components/button-group/button-group.component.js +58 -11
- package/dist/components/button-group/button-group.types.d.ts +9 -1
- package/dist/components/button-group/components/button-group-button/button-group-button.component.js +1 -2
- package/dist/components/checkbox-group/checkbox-group.component.js +61 -10
- package/dist/components/checkbox-group/checkbox-group.types.d.ts +5 -1
- package/dist/components/checkbox-group/components/checkbox-group-checkbox/checkbox-group-checkbox.component.js +1 -2
- package/dist/components/date-picker/date-picker.types.d.ts +1 -0
- package/dist/components/error-message/error-message.types.d.ts +3 -2
- package/dist/components/list/components/list-item/list-item.component.d.ts +1 -1
- package/dist/components/list/list.utils.d.ts +1 -1
- package/dist/components/modal/components/modal-backdrop/modal-backdrop.component.js +2 -1
- package/dist/components/modal/components/modal-dialog/modal-dialog.styles.js +2 -2
- package/dist/components/popover/components/panel/panel.styles.js +2 -2
- package/dist/components/radio-group/components/radio-group-radio/radio-group-radio.component.js +1 -2
- package/dist/components/radio-group/radio-group.component.js +58 -11
- package/dist/components/radio-group/radio-group.types.d.ts +5 -1
- package/dist/components/selector/components/selector-button-group/selector-button-group.component.js +9 -7
- package/dist/components/selector/components/selector-checkbox-group/selector-checkbox-group.component.js +50 -1
- package/dist/components/selector/components/selector-radio-group/components/selector-radio-group-option/selector-radio-group-option.component.js +1 -1
- package/dist/components/selector/components/selector-radio-group/selector-radio-group.component.js +58 -11
- package/dist/components/selector/components/selector-radio-group/selector-radio-group.types.d.ts +5 -1
- package/dist/components/tabs/components/tabs-tab/tabs-tab.component.js +1 -1
- package/dist/components/tabs/tabs.component.d.ts +6 -2
- package/dist/components/tabs/tabs.component.js +7 -1
- package/dist/constants/message.d.ts +1 -0
- package/dist/constants/message.js +1 -0
- package/package.json +10 -10
- package/src/components/accordion/accordion.component.tsx +3 -3
- package/src/components/accordion/components/accordion-item/accordion-item.component.tsx +2 -2
- package/src/components/autocomplete/autocomplete.component.tsx +5 -1
- package/src/components/autocomplete/components/autocomplete-list-box/components/autocomplete-list-box-option/autocomplete-list-box-option.component.tsx +1 -1
- package/src/components/autocomplete/components/autocomplete-list-box/components/autocomplete-list-box-option/autocomplete-list-box-option.styles.ts +1 -1
- package/src/components/autocomplete/components/autocomplete-popover/autocomplete-popover.component.tsx +4 -1
- package/src/components/bottom-sheet/components/bottom-sheet-dialog/bottom-sheet-dialog.styles.ts +2 -2
- package/src/components/bottom-sheet/components/bottom-sheet-modal/bottom-sheet-modal.component.tsx +4 -1
- package/src/components/button-group/button-group.component.tsx +58 -11
- package/src/components/button-group/button-group.types.ts +9 -2
- package/src/components/button-group/components/button-group-button/button-group-button.component.tsx +1 -2
- package/src/components/checkbox-group/checkbox-group.component.tsx +62 -10
- package/src/components/checkbox-group/checkbox-group.types.ts +5 -1
- package/src/components/checkbox-group/components/checkbox-group-checkbox/checkbox-group-checkbox.component.tsx +1 -2
- package/src/components/date-picker/date-picker.types.ts +4 -0
- package/src/components/error-message/error-message.component.tsx +2 -2
- package/src/components/error-message/error-message.types.ts +2 -1
- package/src/components/modal/components/modal-backdrop/modal-backdrop.component.tsx +4 -1
- package/src/components/modal/components/modal-dialog/modal-dialog.styles.ts +2 -2
- package/src/components/pagination/pagination.component.tsx +6 -6
- package/src/components/popover/components/panel/panel.styles.ts +2 -2
- package/src/components/radio-group/components/radio-group-radio/radio-group-radio.component.tsx +1 -2
- package/src/components/radio-group/radio-group.component.tsx +57 -13
- package/src/components/radio-group/radio-group.types.ts +5 -1
- package/src/components/selector/components/selector-button-group/selector-button-group.component.tsx +10 -7
- package/src/components/selector/components/selector-checkbox-group/selector-checkbox-group.component.tsx +49 -0
- package/src/components/selector/components/selector-radio-group/components/selector-radio-group-option/selector-radio-group-option.component.tsx +1 -1
- package/src/components/selector/components/selector-radio-group/selector-radio-group.component.tsx +58 -11
- package/src/components/selector/components/selector-radio-group/selector-radio-group.types.ts +5 -1
- package/src/components/tabs/components/tabs-tab/tabs-tab.component.tsx +1 -1
- package/src/components/tabs/tabs.component.tsx +26 -5
- package/src/constants/message.ts +1 -0
- package/src/tailwind/utils/create-font-sizes.ts +11 -8
- package/src/tailwind/utils/generate-font-components.ts +18 -15
- package/src/tailwind/utils/generate-form-control.ts +11 -8
package/dist/components/selector/components/selector-radio-group/selector-radio-group.component.js
CHANGED
|
@@ -16,19 +16,66 @@ function _extends() {
|
|
|
16
16
|
import React, { createContext } from 'react';
|
|
17
17
|
import { useRadioGroup } from 'react-aria';
|
|
18
18
|
import { useRadioGroupState } from 'react-stately';
|
|
19
|
+
import { FUNCTION_NOT_IMPLEMENTED } from '../../../../constants/message.js';
|
|
19
20
|
import { ErrorMessage, Hint, Label } from '../../../index.js';
|
|
20
21
|
import { styles } from './selector-radio-group.styles.js';
|
|
21
22
|
export const SelectorRadioGroupContext = createContext({
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
orientation: 'vertical',
|
|
24
|
+
state: {
|
|
25
|
+
name: '',
|
|
26
|
+
isDisabled: false,
|
|
27
|
+
isReadOnly: false,
|
|
28
|
+
isRequired: false,
|
|
29
|
+
validationState: null,
|
|
30
|
+
selectedValue: null,
|
|
31
|
+
setSelectedValue: ()=>null,
|
|
32
|
+
lastFocusedValue: null,
|
|
33
|
+
setLastFocusedValue: ()=>null,
|
|
34
|
+
isInvalid: false,
|
|
35
|
+
realtimeValidation: {
|
|
36
|
+
isInvalid: false,
|
|
37
|
+
validationErrors: [],
|
|
38
|
+
validationDetails: {
|
|
39
|
+
badInput: false,
|
|
40
|
+
customError: false,
|
|
41
|
+
patternMismatch: false,
|
|
42
|
+
rangeOverflow: false,
|
|
43
|
+
rangeUnderflow: false,
|
|
44
|
+
stepMismatch: false,
|
|
45
|
+
tooLong: false,
|
|
46
|
+
tooShort: false,
|
|
47
|
+
typeMismatch: false,
|
|
48
|
+
valid: false,
|
|
49
|
+
valueMissing: false
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
displayValidation: {
|
|
53
|
+
isInvalid: false,
|
|
54
|
+
validationErrors: [],
|
|
55
|
+
validationDetails: {
|
|
56
|
+
badInput: false,
|
|
57
|
+
customError: false,
|
|
58
|
+
patternMismatch: false,
|
|
59
|
+
rangeOverflow: false,
|
|
60
|
+
rangeUnderflow: false,
|
|
61
|
+
stepMismatch: false,
|
|
62
|
+
tooLong: false,
|
|
63
|
+
tooShort: false,
|
|
64
|
+
typeMismatch: false,
|
|
65
|
+
valid: false,
|
|
66
|
+
valueMissing: false
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
updateValidation: function() {
|
|
70
|
+
throw new Error(FUNCTION_NOT_IMPLEMENTED);
|
|
71
|
+
},
|
|
72
|
+
resetValidation: function() {
|
|
73
|
+
throw new Error(FUNCTION_NOT_IMPLEMENTED);
|
|
74
|
+
},
|
|
75
|
+
commitValidation: function() {
|
|
76
|
+
throw new Error(FUNCTION_NOT_IMPLEMENTED);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
32
79
|
});
|
|
33
80
|
export function SelectorRadioGroup({ className , children , label , orientation ='vertical' , errorMessage , description , ...props }) {
|
|
34
81
|
const state = useRadioGroupState({
|
|
@@ -51,7 +98,7 @@ export function SelectorRadioGroup({ className , children , label , orientation
|
|
|
51
98
|
})
|
|
52
99
|
}, radioGroupProps), React.createElement(SelectorRadioGroupContext.Provider, {
|
|
53
100
|
value: {
|
|
54
|
-
|
|
101
|
+
state,
|
|
55
102
|
orientation
|
|
56
103
|
}
|
|
57
104
|
}, children)));
|
package/dist/components/selector/components/selector-radio-group/selector-radio-group.types.d.ts
CHANGED
|
@@ -19,5 +19,9 @@ export type SelectorRadioGroupContextState = {
|
|
|
19
19
|
* Controls orientation of `Radio` components, can't be applied directly on `Radio`
|
|
20
20
|
*/
|
|
21
21
|
orientation: 'vertical' | 'horizontal';
|
|
22
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Radio group state
|
|
24
|
+
*/
|
|
25
|
+
state: RadioGroupState;
|
|
26
|
+
};
|
|
23
27
|
export {};
|
|
@@ -18,7 +18,7 @@ import { styles } from './tabs-tab.styles.js';
|
|
|
18
18
|
export function TabsTab({ item: { key , rendered } , state , orientation , justify , color , look }) {
|
|
19
19
|
const ref = useRef(null);
|
|
20
20
|
const { tabProps } = useTab({
|
|
21
|
-
key
|
|
21
|
+
key: key
|
|
22
22
|
}, state, ref);
|
|
23
23
|
const { isFocusVisible , focusProps } = useFocusRing();
|
|
24
24
|
return React.createElement("div", _extends({}, mergeProps(tabProps, focusProps), {
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" resolution-mode="require"/>
|
|
2
|
+
import { AriaLinkOptions } from 'react-aria';
|
|
3
|
+
import { ItemProps } from 'react-stately';
|
|
2
4
|
import { type TabsProps } from './tabs.types.js';
|
|
3
|
-
export declare function Tabs({ className, orientation, justify, children, color, look, sticky, stickyOffset, ...props }: TabsProps): import("react/jsx-runtime").JSX.Element;
|
|
4
|
-
export declare const TabsPanel:
|
|
5
|
+
export declare function Tabs({ className, orientation, justify, children, color, look, sticky, stickyOffset, disabledKeys, selectedKey, defaultSelectedKey, ...props }: TabsProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare const TabsPanel: (props: ItemProps<AriaLinkOptions> & AriaLinkOptions & {
|
|
7
|
+
href?: string;
|
|
8
|
+
}) => JSX.Element;
|
|
@@ -18,10 +18,13 @@ import { useTabList } from 'react-aria';
|
|
|
18
18
|
import { Item, useTabListState } from 'react-stately';
|
|
19
19
|
import { TabsTab, TabsTabPanel } from './components/index.js';
|
|
20
20
|
import { styles as tabStyles } from './tabs.styles.js';
|
|
21
|
-
export function Tabs({ className , orientation ='horizontal' , justify , children , color , look ='default' , sticky =false , stickyOffset ={} , ...props }) {
|
|
21
|
+
export function Tabs({ className , orientation ='horizontal' , justify , children , color , look ='default' , sticky =false , stickyOffset ={} , disabledKeys , selectedKey , defaultSelectedKey , ...props }) {
|
|
22
22
|
var _state_selectedItem;
|
|
23
23
|
const state = useTabListState({
|
|
24
24
|
...props,
|
|
25
|
+
disabledKeys: disabledKeys,
|
|
26
|
+
selectedKey: selectedKey,
|
|
27
|
+
defaultSelectedKey: defaultSelectedKey,
|
|
25
28
|
children
|
|
26
29
|
});
|
|
27
30
|
const styles = tabStyles({
|
|
@@ -32,6 +35,9 @@ export function Tabs({ className , orientation ='horizontal' , justify , childre
|
|
|
32
35
|
const ref = useRef(null);
|
|
33
36
|
const { tabListProps } = useTabList({
|
|
34
37
|
...props,
|
|
38
|
+
disabledKeys: disabledKeys,
|
|
39
|
+
selectedKey: selectedKey,
|
|
40
|
+
defaultSelectedKey: defaultSelectedKey,
|
|
35
41
|
orientation
|
|
36
42
|
}, state, ref);
|
|
37
43
|
return React.createElement("div", {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const FUNCTION_NOT_IMPLEMENTED = "Function not implemented";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const FUNCTION_NOT_IMPLEMENTED = 'Function not implemented';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@westpac/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"type": "module",
|
|
@@ -241,7 +241,7 @@
|
|
|
241
241
|
"plop": "~3.1.2",
|
|
242
242
|
"postcss": "~8.4.31",
|
|
243
243
|
"postcss-cli": "~10.1.0",
|
|
244
|
-
"prettier": "^2.
|
|
244
|
+
"prettier": "^3.2.5",
|
|
245
245
|
"prop-types": "^15.8.1",
|
|
246
246
|
"react": "^18.2.0",
|
|
247
247
|
"react-docgen-typescript": "~2.2.2",
|
|
@@ -255,20 +255,20 @@
|
|
|
255
255
|
"typescript": "^5.1.6",
|
|
256
256
|
"vite": "^4.3.9",
|
|
257
257
|
"vitest": "^0.30.1",
|
|
258
|
-
"@westpac/
|
|
259
|
-
"@westpac/
|
|
260
|
-
"@westpac/
|
|
258
|
+
"@westpac/ts-config": "~0.0.0",
|
|
259
|
+
"@westpac/eslint-config": "~0.2.0",
|
|
260
|
+
"@westpac/test-config": "~0.0.0"
|
|
261
261
|
},
|
|
262
262
|
"dependencies": {
|
|
263
263
|
"@duetds/date-picker": "~1.4.0",
|
|
264
|
-
"@react-aria/accordion": "3.0.0-alpha.
|
|
265
|
-
"@react-aria/utils": "~3.
|
|
266
|
-
"@react-spectrum/utils": "~3.
|
|
264
|
+
"@react-aria/accordion": "3.0.0-alpha.27",
|
|
265
|
+
"@react-aria/utils": "~3.23.2",
|
|
266
|
+
"@react-spectrum/utils": "~3.11.5",
|
|
267
267
|
"clsx": "^1.2.1",
|
|
268
268
|
"framer-motion": "~10.12.16",
|
|
269
269
|
"lodash.throttle": "~4.1.1",
|
|
270
|
-
"react-aria": "~3.
|
|
271
|
-
"react-stately": "~3.
|
|
270
|
+
"react-aria": "~3.32.1",
|
|
271
|
+
"react-stately": "~3.30.1"
|
|
272
272
|
},
|
|
273
273
|
"overrides": {
|
|
274
274
|
"react-aria": {
|
|
@@ -4,7 +4,7 @@ import { useAccordion } from '@react-aria/accordion';
|
|
|
4
4
|
import { filterDOMProps } from '@react-aria/utils';
|
|
5
5
|
import { useDOMRef } from '@react-spectrum/utils';
|
|
6
6
|
import React, { Children, cloneElement, forwardRef, isValidElement } from 'react';
|
|
7
|
-
import { Item, useTreeState } from 'react-stately';
|
|
7
|
+
import { Item, type ItemProps, useTreeState } from 'react-stately';
|
|
8
8
|
|
|
9
9
|
import { styles } from './accordion.styles.js';
|
|
10
10
|
import { type AccordionProps } from './accordion.types.js';
|
|
@@ -24,7 +24,7 @@ function Accordion<T extends object>(
|
|
|
24
24
|
// equal to (if (child == null || typeof child == 'string'))
|
|
25
25
|
if (!isValidElement(child)) return child;
|
|
26
26
|
return cloneElement(child, {
|
|
27
|
-
...child.props,
|
|
27
|
+
...(child.props as any),
|
|
28
28
|
// Adding hasChildItems false by default
|
|
29
29
|
hasChildItems: false,
|
|
30
30
|
});
|
|
@@ -52,4 +52,4 @@ const _Accordion = forwardRef(Accordion) as unknown as { displayName: string } &
|
|
|
52
52
|
_Accordion.displayName = 'Accordion';
|
|
53
53
|
|
|
54
54
|
export { _Accordion as Accordion };
|
|
55
|
-
export const AccordionItem = Item;
|
|
55
|
+
export const AccordionItem: <T>(props: ItemProps<T>) => JSX.Element = Item;
|
|
@@ -20,8 +20,8 @@ export function AccordionItem<T = any>({
|
|
|
20
20
|
const { state, item } = props;
|
|
21
21
|
const { buttonProps, regionProps } = useAccordionItem<T>(props, state, ref);
|
|
22
22
|
const { isFocusVisible, focusProps } = useFocusRing();
|
|
23
|
-
const isOpen = state.expandedKeys.has(item.key);
|
|
24
|
-
const isDisabled = state.disabledKeys.has(item.key);
|
|
23
|
+
const isOpen = state.expandedKeys.has(item.key as any);
|
|
24
|
+
const isDisabled = state.disabledKeys.has(item.key as any);
|
|
25
25
|
const { hoverProps } = useHover({ isDisabled });
|
|
26
26
|
const { direction } = useLocale();
|
|
27
27
|
const styles = accordionItemStyles({ isOpen, isDisabled, look, isFocusVisible });
|
|
@@ -112,7 +112,11 @@ export function Autocomplete<T extends object>({
|
|
|
112
112
|
|
|
113
113
|
<div ref={outerRef} className={styles.outerWrapper()}>
|
|
114
114
|
<div className={styles.iconWrapper()}>
|
|
115
|
-
{loadingState ?
|
|
115
|
+
{loadingState ? (
|
|
116
|
+
<ProgressIndicator size={iconSize} color="muted" />
|
|
117
|
+
) : (
|
|
118
|
+
<SearchIcon aria-hidden size={iconSize} color="muted" />
|
|
119
|
+
)}
|
|
116
120
|
</div>
|
|
117
121
|
<input
|
|
118
122
|
{...mergeProps(inputProps, inputFocusProps)}
|
|
@@ -2,7 +2,7 @@ import { tv } from 'tailwind-variants';
|
|
|
2
2
|
|
|
3
3
|
export const styles = tv(
|
|
4
4
|
{
|
|
5
|
-
base: 'flex cursor-pointer items-center justify-between border-t border-t-border bg-white p-2 px-3 text-sm transition-colors first:border-t-0 hover:bg-hero hover:text-white focus:bg-hero focus:text-white',
|
|
5
|
+
base: 'flex cursor-pointer items-center justify-between border-t border-t-border bg-white p-2 px-3 text-sm text-text transition-colors first:border-t-0 hover:bg-hero hover:text-white focus:bg-hero focus:text-white',
|
|
6
6
|
variants: {
|
|
7
7
|
isFocused: {
|
|
8
8
|
true: 'bg-hero !text-white',
|
|
@@ -17,9 +17,12 @@ export function AutocompletePopover(props: AutocompletePopoverProps) {
|
|
|
17
17
|
state,
|
|
18
18
|
);
|
|
19
19
|
|
|
20
|
+
// This is required so branding applies correctly by default due to portal location, can be overridden with portalContainer prop
|
|
21
|
+
const brandContainer = document.querySelector('[data-theme]') || document.querySelector('[className="data-theme"]');
|
|
22
|
+
|
|
20
23
|
const width = props.triggerRef.current?.getBoundingClientRect().width;
|
|
21
24
|
return (
|
|
22
|
-
<Overlay portalContainer={portalContainer}>
|
|
25
|
+
<Overlay portalContainer={portalContainer || brandContainer || document.body}>
|
|
23
26
|
{!isNonModal && <div {...underlayProps} className="fixed inset-0" />}
|
|
24
27
|
|
|
25
28
|
<div
|
package/src/components/bottom-sheet/components/bottom-sheet-dialog/bottom-sheet-dialog.styles.ts
CHANGED
|
@@ -4,8 +4,8 @@ export const styles = tv(
|
|
|
4
4
|
{
|
|
5
5
|
slots: {
|
|
6
6
|
base: 'flex max-h-screen max-w-full flex-1 flex-col overflow-hidden rounded-t-md bg-white shadow-sm md:w-[37.5rem] md:rounded-md',
|
|
7
|
-
title: 'typography-body-7 p-7 pb-4 pt-9 font-bold max-md:px-5',
|
|
8
|
-
body: 'flex-1 overflow-auto px-7 pb-7 max-md:px-5',
|
|
7
|
+
title: 'typography-body-7 p-7 pb-4 pt-9 font-bold text-text max-md:px-5',
|
|
8
|
+
body: 'flex-1 overflow-auto px-7 pb-7 text-text max-md:px-5',
|
|
9
9
|
closeBtn: 'absolute right-3 top-3 p-0',
|
|
10
10
|
buttonWrapper: '-mt-2 flex gap-1 px-7 pb-7 max-md:flex-col max-md:px-5 max-md:pb-5',
|
|
11
11
|
primaryBtn: '',
|
package/src/components/bottom-sheet/components/bottom-sheet-modal/bottom-sheet-modal.component.tsx
CHANGED
|
@@ -29,6 +29,9 @@ export function BottomSheetModal({ state, height, width, children, portalContain
|
|
|
29
29
|
const controls = useAnimation();
|
|
30
30
|
const [isMobile, setIsMobile] = useState(checkIfItIsMobile(MEDIUM_BREAKPOINT_AS_NUMBER));
|
|
31
31
|
|
|
32
|
+
// This is required so branding applies correctly by default due to portal location, can be overridden with portalContainer prop
|
|
33
|
+
const brandContainer = document.querySelector('[data-theme]') || document.querySelector('[className="data-theme"]');
|
|
34
|
+
|
|
32
35
|
useEffect(() => {
|
|
33
36
|
function handleResize() {
|
|
34
37
|
setIsMobile(checkIfItIsMobile(MEDIUM_BREAKPOINT_AS_NUMBER));
|
|
@@ -65,7 +68,7 @@ export function BottomSheetModal({ state, height, width, children, portalContain
|
|
|
65
68
|
}
|
|
66
69
|
|
|
67
70
|
return (
|
|
68
|
-
<Overlay portalContainer={portalContainer}>
|
|
71
|
+
<Overlay portalContainer={portalContainer || brandContainer || document.body}>
|
|
69
72
|
<div className={styles.underlay()} {...underlayProps}>
|
|
70
73
|
<motion.div
|
|
71
74
|
animate={controls}
|
|
@@ -4,25 +4,72 @@ import React, { createContext } from 'react';
|
|
|
4
4
|
import { useRadioGroup } from 'react-aria';
|
|
5
5
|
import { useRadioGroupState } from 'react-stately';
|
|
6
6
|
|
|
7
|
+
import { FUNCTION_NOT_IMPLEMENTED } from '../../constants/message.js';
|
|
7
8
|
import { ButtonGroupButton, ErrorMessage, Hint, Label } from '../index.js';
|
|
8
9
|
|
|
9
10
|
import { styles as buttonGroupStyles } from './button-group.styles.js';
|
|
10
11
|
import { ButtonGroupContextState, type ButtonGroupProps } from './button-group.types.js';
|
|
11
12
|
|
|
12
13
|
export const ButtonGroupContext = createContext<ButtonGroupContextState>({
|
|
13
|
-
// TODO: Remove deprecated name prop once React Aria removes it from RadioGroupState
|
|
14
|
-
name: '',
|
|
15
|
-
isDisabled: false,
|
|
16
|
-
isReadOnly: false,
|
|
17
|
-
isRequired: false,
|
|
18
|
-
validationState: null,
|
|
19
|
-
selectedValue: null,
|
|
20
|
-
setSelectedValue: () => null,
|
|
21
|
-
lastFocusedValue: null,
|
|
22
|
-
setLastFocusedValue: () => null,
|
|
23
14
|
block: false,
|
|
24
15
|
look: 'hero',
|
|
25
16
|
size: 'medium',
|
|
17
|
+
state: {
|
|
18
|
+
// TODO: Remove deprecated name prop once React Aria removes it from RadioGroupState
|
|
19
|
+
name: '',
|
|
20
|
+
isDisabled: false,
|
|
21
|
+
isReadOnly: false,
|
|
22
|
+
isRequired: false,
|
|
23
|
+
validationState: null,
|
|
24
|
+
selectedValue: null,
|
|
25
|
+
setSelectedValue: () => null,
|
|
26
|
+
lastFocusedValue: null,
|
|
27
|
+
setLastFocusedValue: () => null,
|
|
28
|
+
isInvalid: false,
|
|
29
|
+
realtimeValidation: {
|
|
30
|
+
isInvalid: false,
|
|
31
|
+
validationErrors: [],
|
|
32
|
+
validationDetails: {
|
|
33
|
+
badInput: false,
|
|
34
|
+
customError: false,
|
|
35
|
+
patternMismatch: false,
|
|
36
|
+
rangeOverflow: false,
|
|
37
|
+
rangeUnderflow: false,
|
|
38
|
+
stepMismatch: false,
|
|
39
|
+
tooLong: false,
|
|
40
|
+
tooShort: false,
|
|
41
|
+
typeMismatch: false,
|
|
42
|
+
valid: false,
|
|
43
|
+
valueMissing: false,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
displayValidation: {
|
|
47
|
+
isInvalid: false,
|
|
48
|
+
validationErrors: [],
|
|
49
|
+
validationDetails: {
|
|
50
|
+
badInput: false,
|
|
51
|
+
customError: false,
|
|
52
|
+
patternMismatch: false,
|
|
53
|
+
rangeOverflow: false,
|
|
54
|
+
rangeUnderflow: false,
|
|
55
|
+
stepMismatch: false,
|
|
56
|
+
tooLong: false,
|
|
57
|
+
tooShort: false,
|
|
58
|
+
typeMismatch: false,
|
|
59
|
+
valid: false,
|
|
60
|
+
valueMissing: false,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
updateValidation: function (): void {
|
|
64
|
+
throw new Error(FUNCTION_NOT_IMPLEMENTED);
|
|
65
|
+
},
|
|
66
|
+
resetValidation: function (): void {
|
|
67
|
+
throw new Error(FUNCTION_NOT_IMPLEMENTED);
|
|
68
|
+
},
|
|
69
|
+
commitValidation: function (): void {
|
|
70
|
+
throw new Error(FUNCTION_NOT_IMPLEMENTED);
|
|
71
|
+
},
|
|
72
|
+
},
|
|
26
73
|
});
|
|
27
74
|
|
|
28
75
|
export function ButtonGroup({
|
|
@@ -56,7 +103,7 @@ export function ButtonGroup({
|
|
|
56
103
|
<ErrorMessage {...errorMessageProps} message={errorMessage} />
|
|
57
104
|
)}
|
|
58
105
|
<div className={styles.buttonWrapper()}>
|
|
59
|
-
<ButtonGroupContext.Provider value={{
|
|
106
|
+
<ButtonGroupContext.Provider value={{ state, size, look, block }}>
|
|
60
107
|
{buttons.map((button, index) => (
|
|
61
108
|
<ButtonGroupButton key={index} className="group/buttons" {...button} />
|
|
62
109
|
))}
|
|
@@ -46,5 +46,12 @@ export type ButtonGroupContextState = {
|
|
|
46
46
|
* Controls look of `Button` components, can't be applied directly to `Button`
|
|
47
47
|
*/
|
|
48
48
|
look?: 'hero' | 'primary';
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Controls look of `Button` components, can't be applied directly to `Button`
|
|
51
|
+
*/
|
|
52
|
+
size: ButtonProps['size'];
|
|
53
|
+
/**
|
|
54
|
+
* Radio group state
|
|
55
|
+
*/
|
|
56
|
+
state: RadioGroupState;
|
|
57
|
+
};
|
package/src/components/button-group/components/button-group-button/button-group-button.component.tsx
CHANGED
|
@@ -10,8 +10,7 @@ import { styles as buttonStyles } from './button-group-button.styles.js';
|
|
|
10
10
|
import { type ButtonGroupButtonProps } from './button-group-button.types.js';
|
|
11
11
|
|
|
12
12
|
export function ButtonGroupButton({ className, label, ...props }: ButtonGroupButtonProps) {
|
|
13
|
-
const state = useContext(ButtonGroupContext);
|
|
14
|
-
const { size, look, block } = state;
|
|
13
|
+
const { state, size, look, block } = useContext(ButtonGroupContext);
|
|
15
14
|
const ref = useRef(null);
|
|
16
15
|
const { inputProps, isSelected, isDisabled } = useRadio({ ...props, children: label }, state, ref);
|
|
17
16
|
const { isFocusVisible, focusProps } = useFocusRing();
|
|
@@ -4,6 +4,7 @@ import React, { createContext, useEffect, useId, useMemo, useRef, useState } fro
|
|
|
4
4
|
import { useCheckboxGroup, useFocusRing } from 'react-aria';
|
|
5
5
|
import { useCheckboxGroupState } from 'react-stately';
|
|
6
6
|
|
|
7
|
+
import { FUNCTION_NOT_IMPLEMENTED } from '../../constants/message.js';
|
|
7
8
|
import { Button } from '../button/index.js';
|
|
8
9
|
import { ExpandMoreIcon } from '../icon/index.js';
|
|
9
10
|
import { CheckboxGroupCheckbox, ErrorMessage, Hint, Label } from '../index.js';
|
|
@@ -14,15 +15,66 @@ import { type CheckboxGroupContextState, type CheckboxGroupProps } from './check
|
|
|
14
15
|
export const CheckboxGroupContext = createContext<CheckboxGroupContextState>({
|
|
15
16
|
orientation: 'vertical',
|
|
16
17
|
size: 'medium',
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
state: {
|
|
19
|
+
value: [],
|
|
20
|
+
isDisabled: false,
|
|
21
|
+
isReadOnly: false,
|
|
22
|
+
isSelected: () => false,
|
|
23
|
+
setValue: () => null,
|
|
24
|
+
addValue: () => null,
|
|
25
|
+
removeValue: () => null,
|
|
26
|
+
toggleValue: () => null,
|
|
27
|
+
validationState: 'valid',
|
|
28
|
+
isInvalid: false,
|
|
29
|
+
isRequired: false,
|
|
30
|
+
setInvalid: () =>
|
|
31
|
+
function (): void {
|
|
32
|
+
throw new Error(FUNCTION_NOT_IMPLEMENTED);
|
|
33
|
+
},
|
|
34
|
+
realtimeValidation: {
|
|
35
|
+
isInvalid: false,
|
|
36
|
+
validationErrors: [],
|
|
37
|
+
validationDetails: {
|
|
38
|
+
badInput: false,
|
|
39
|
+
customError: false,
|
|
40
|
+
patternMismatch: false,
|
|
41
|
+
rangeOverflow: false,
|
|
42
|
+
rangeUnderflow: false,
|
|
43
|
+
stepMismatch: false,
|
|
44
|
+
tooLong: false,
|
|
45
|
+
tooShort: false,
|
|
46
|
+
typeMismatch: false,
|
|
47
|
+
valid: false,
|
|
48
|
+
valueMissing: false,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
displayValidation: {
|
|
52
|
+
isInvalid: false,
|
|
53
|
+
validationErrors: [],
|
|
54
|
+
validationDetails: {
|
|
55
|
+
badInput: false,
|
|
56
|
+
customError: false,
|
|
57
|
+
patternMismatch: false,
|
|
58
|
+
rangeOverflow: false,
|
|
59
|
+
rangeUnderflow: false,
|
|
60
|
+
stepMismatch: false,
|
|
61
|
+
tooLong: false,
|
|
62
|
+
tooShort: false,
|
|
63
|
+
typeMismatch: false,
|
|
64
|
+
valid: false,
|
|
65
|
+
valueMissing: false,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
updateValidation: function (): void {
|
|
69
|
+
throw new Error(FUNCTION_NOT_IMPLEMENTED);
|
|
70
|
+
},
|
|
71
|
+
resetValidation: function (): void {
|
|
72
|
+
throw new Error(FUNCTION_NOT_IMPLEMENTED);
|
|
73
|
+
},
|
|
74
|
+
commitValidation: function (): void {
|
|
75
|
+
throw new Error(FUNCTION_NOT_IMPLEMENTED);
|
|
76
|
+
},
|
|
77
|
+
},
|
|
26
78
|
});
|
|
27
79
|
export function CheckboxGroup({
|
|
28
80
|
className,
|
|
@@ -65,7 +117,7 @@ export function CheckboxGroup({
|
|
|
65
117
|
<ErrorMessage {...errorMessageProps} message={errorMessage} />
|
|
66
118
|
)}
|
|
67
119
|
<div className={styles.itemWrapper()} id={panelId}>
|
|
68
|
-
<CheckboxGroupContext.Provider value={{
|
|
120
|
+
<CheckboxGroupContext.Provider value={{ state, orientation, size }}>
|
|
69
121
|
{childrenToRender}
|
|
70
122
|
</CheckboxGroupContext.Provider>
|
|
71
123
|
{hiddenOptions && (
|
|
@@ -32,8 +32,7 @@ function CheckIcon({ copyrightYear = '2024', size, ...props }: IconProps) {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
function BaseCheckbox({ className, hint, label, value, ...props }: CheckboxGroupCheckboxProps, ref: any) {
|
|
35
|
-
const state = useContext(CheckboxGroupContext);
|
|
36
|
-
const { size, orientation } = state;
|
|
35
|
+
const { state, size, orientation } = useContext(CheckboxGroupContext);
|
|
37
36
|
const localRef = useRef(null);
|
|
38
37
|
const { inputProps, isDisabled, isSelected } = useCheckboxGroupItem(
|
|
39
38
|
{ ...props, value, children: label },
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
2
|
|
|
3
3
|
import { AlertIcon } from '../../components/icon/index.js';
|
|
4
4
|
|
|
@@ -21,7 +21,7 @@ export function ErrorMessage({ className, tag: Tag = 'div', icon: Icon, message,
|
|
|
21
21
|
) : (
|
|
22
22
|
<Tag className={styles.base({ className: `${className} mb-2` })} {...props}>
|
|
23
23
|
<FinalIcon copyrightYear="2023" className={styles.icon({})} size="xsmall" look="outlined" />
|
|
24
|
-
{message}
|
|
24
|
+
{message as ReactNode}
|
|
25
25
|
</Tag>
|
|
26
26
|
);
|
|
27
27
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import { AriaFieldProps } from 'react-aria';
|
|
2
3
|
|
|
3
4
|
export type ErrorMessageProps = {
|
|
4
5
|
/**
|
|
@@ -8,7 +9,7 @@ export type ErrorMessageProps = {
|
|
|
8
9
|
/**
|
|
9
10
|
* Message or messages
|
|
10
11
|
*/
|
|
11
|
-
message?:
|
|
12
|
+
message?: AriaFieldProps['errorMessage'];
|
|
12
13
|
/**
|
|
13
14
|
* Tag to render
|
|
14
15
|
*/
|
|
@@ -20,8 +20,11 @@ export function ModalBackdrop({ zIndex = 100, portalContainer, size, ...props }:
|
|
|
20
20
|
return null;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
// This is required so branding applies correctly by default due to portal location, can be overridden with portalContainer prop
|
|
24
|
+
const brandContainer = document.querySelector('[data-theme]') || document.querySelector('[className="data-theme"]');
|
|
25
|
+
|
|
23
26
|
return (
|
|
24
|
-
<Overlay portalContainer={portalContainer}>
|
|
27
|
+
<Overlay portalContainer={portalContainer || brandContainer || document.body}>
|
|
25
28
|
<div style={{ zIndex }} className={styles.base()} {...underlayProps}>
|
|
26
29
|
<div {...modalProps} ref={ref} className={styles.modal()}>
|
|
27
30
|
{children}
|
|
@@ -3,8 +3,8 @@ import { tv } from 'tailwind-variants';
|
|
|
3
3
|
export const styles = tv(
|
|
4
4
|
{
|
|
5
5
|
slots: {
|
|
6
|
-
base: 'relative mx-auto flex max-w-full flex-col overflow-hidden rounded bg-white outline-none',
|
|
7
|
-
title: 'typography-body-7 pb-4 pt-9 font-bold',
|
|
6
|
+
base: 'relative mx-auto flex max-w-full flex-col overflow-hidden rounded bg-white text-text outline-none',
|
|
7
|
+
title: 'typography-body-7 pb-4 pt-9 font-bold text-text',
|
|
8
8
|
close: 'absolute right-0 top-0 block p-3',
|
|
9
9
|
},
|
|
10
10
|
variants: {
|
|
@@ -23,12 +23,12 @@ export function Pagination({
|
|
|
23
23
|
|
|
24
24
|
const generateHandleOnClickBackwards = useCallback(
|
|
25
25
|
(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
current: number,
|
|
27
|
+
infinite: boolean,
|
|
28
|
+
forwardOnly: boolean,
|
|
29
|
+
onChange: (page: number) => unknown,
|
|
30
|
+
pages: PaginationProps['pages'],
|
|
31
|
+
) =>
|
|
32
32
|
() => {
|
|
33
33
|
if (infinite && forwardOnly) {
|
|
34
34
|
return onChange(pages.length);
|
|
@@ -9,8 +9,8 @@ export const styles = tv(
|
|
|
9
9
|
'absolute h-0 w-0 border-x-[8px] border-t-[12px] border-x-[transparent] border-t-muted after:absolute after:h-0 after:w-0 after:border-x-[7px] after:border-t-[11px] after:border-x-[transparent] after:border-t-white',
|
|
10
10
|
closeBtn: 'absolute right-1 top-1 m-1 p-0 hover:opacity-80',
|
|
11
11
|
content: 'w-[17.625rem] py-4 pl-3 pr-5',
|
|
12
|
-
heading: 'typography-body-9 mb-2 font-bold',
|
|
13
|
-
body: 'typography-body-10',
|
|
12
|
+
heading: 'typography-body-9 mb-2 font-bold text-text',
|
|
13
|
+
body: 'typography-body-10 text-text',
|
|
14
14
|
},
|
|
15
15
|
variants: {
|
|
16
16
|
placement: {
|