@westpac/ui 0.19.0 → 0.20.1
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/.eslintrc.cjs +7 -2
- package/CHANGELOG.md +12 -0
- package/dist/component-type.json +1 -1
- package/dist/components/accordion/accordion.component.d.ts +3 -2
- package/dist/components/accordion/accordion.types.d.ts +1 -1
- package/dist/components/accordion/components/accordion-item/accordion-item.component.d.ts +1 -1
- package/dist/components/accordion/components/accordion-item/accordion-item.types.d.ts +1 -1
- package/dist/components/autocomplete/autocomplete.component.js +6 -3
- package/dist/components/autocomplete/components/autocomplete-item/autocomplete-item.component.js +0 -1
- package/dist/components/autocomplete/components/autocomplete-item/autocomplete-item.types.d.ts +1 -1
- package/dist/components/autocomplete/components/autocomplete-list-box/autocomplete-list-box.types.d.ts +2 -2
- package/dist/components/autocomplete/components/autocomplete-list-box/components/autocomplete-list-box-option/autocomplete-list-box-option.component.d.ts +1 -1
- package/dist/components/autocomplete/components/autocomplete-list-box/components/autocomplete-list-box-option/autocomplete-list-box-option.types.d.ts +1 -1
- package/dist/components/autocomplete/components/autocomplete-list-box/components/autocomplete-list-box-section/autocomplete-list-box-section.component.d.ts +1 -1
- package/dist/components/autocomplete/components/autocomplete-list-box/components/autocomplete-list-box-section/autocomplete-list-box-section.types.d.ts +1 -1
- package/dist/components/badge/badge.component.d.ts +3 -3
- package/dist/components/badge/badge.component.js +1 -3
- package/dist/components/badge/badge.styles.d.ts +1 -1
- package/dist/components/badge/badge.styles.js +3 -3
- package/dist/components/bottom-sheet/components/bottom-sheet-modal/bottom-sheet-modal.component.js +3 -1
- package/dist/components/breadcrumb/components/breadcrumb-item/breadcrumb-item.component.d.ts +3 -3
- package/dist/components/button/button.component.d.ts +1 -1
- package/dist/components/button/button.styles.js +1 -1
- package/dist/components/button-dropdown/button-dropdown.component.js +1 -1
- package/dist/components/button-dropdown/components/button-dropdown-panel/button-dropdown-panel.component.js +8 -3
- package/dist/components/button-group/button-group.component.js +1 -1
- package/dist/components/checkbox-group/checkbox-group.component.js +1 -1
- package/dist/components/checkbox-group/components/checkbox-group-checkbox/checkbox-group-checkbox.component.d.ts +1 -1
- package/dist/components/collapsible/collapsible.component.js +1 -1
- package/dist/components/date-picker/date-picker.component.js +9 -1
- package/dist/components/date-picker/date-picker.types.d.ts +8 -8
- package/dist/components/date-picker/date-picker.utils.d.ts +2 -2
- package/dist/components/date-picker/date-picker.utils.js +2 -1
- package/dist/components/error-message/error-message.component.js +2 -1
- package/dist/components/field/field.component.js +2 -1
- package/dist/components/flexi-cell/flexi-cell.component.d.ts +1 -1
- package/dist/components/header/header.component.js +4 -1
- package/dist/components/input-group/components/input-group-add-ons/components/input-group-add-on-default-add-on/input-group-add-on-default-add-on.component.d.ts +1 -1
- package/dist/components/input-group/components/input-group-add-ons/components/input-group-add-on-default-add-on/input-group-add-on-default-add-on.component.js +1 -1
- package/dist/components/input-group/components/input-group-add-ons/input-group-add-ons.styles.js +2 -2
- package/dist/components/input-group/input-group.component.js +8 -3
- package/dist/components/input-group/input-group.styles.d.ts +74 -4
- package/dist/components/input-group/input-group.styles.js +16 -8
- package/dist/components/list/components/list-item/list-item.component.d.ts +3 -3
- package/dist/components/pagination/pagination.component.js +6 -4
- package/dist/components/pagination/pagination.hooks.js +4 -2
- package/dist/components/pass-code/pass-code.component.js +6 -4
- package/dist/components/pass-code-view/pass-code-view.types.d.ts +2 -2
- package/dist/components/popover/components/panel/panel.component.js +6 -3
- package/dist/components/popover/popover.component.js +5 -3
- package/dist/components/popover/{popover.hooks.d.ts → popover.utils.d.ts} +1 -1
- package/dist/components/popover/{popover.hooks.js → popover.utils.js} +1 -1
- package/dist/components/progress-rope/components/progress-rope-step/progress-rope-step.component.d.ts +1 -1
- package/dist/components/progress-rope/components/progress-rope-step/progress-rope-step.component.js +3 -1
- package/dist/components/progress-rope/components/progress-rope-step/progress-rope-step.types.d.ts +1 -1
- package/dist/components/progress-rope/progress-rope.component.js +3 -2
- package/dist/components/radio-group/components/radio-group-radio/radio-group-radio.component.d.ts +1 -1
- package/dist/components/radio-group/radio-group.component.js +1 -1
- package/dist/components/select/select.styles.d.ts +1 -1
- package/dist/components/select/select.styles.js +1 -1
- package/dist/components/selector/components/selector-button-group/components/selector-button-group-option/selector-button-group-option.component.js +2 -1
- package/dist/components/selector/components/selector-button-group/selector-button-group.component.js +3 -1
- package/dist/components/selector/components/selector-checkbox-group/selector-checkbox-group.component.js +1 -1
- package/dist/components/selector/components/selector-radio-group/selector-radio-group.component.js +1 -1
- package/dist/components/skip-link/skip-link.component.d.ts +1 -1
- package/dist/components/tabs/components/tabs-tab/tabs-tab.types.d.ts +1 -1
- package/dist/components/tabs/components/tabs-tab-panel/tabs-tab-panel.types.d.ts +1 -1
- package/dist/components/tabs/tabs.types.d.ts +1 -1
- package/dist/css/westpac-ui.css +20 -38
- package/dist/css/westpac-ui.min.css +20 -38
- package/dist/tailwind/tailwind-plugin.js +1 -1
- package/dist/tailwind/utils/create-font-sizes.d.ts +10 -1
- package/dist/tailwind/utils/generate-font-components.d.ts +2 -2
- package/package.json +3 -3
- package/src/components/accordion/accordion.component.tsx +15 -9
- package/src/components/accordion/accordion.types.ts +1 -1
- package/src/components/accordion/components/accordion-item/accordion-item.component.tsx +4 -4
- package/src/components/accordion/components/accordion-item/accordion-item.types.ts +1 -1
- package/src/components/autocomplete/autocomplete.component.tsx +9 -2
- package/src/components/autocomplete/components/autocomplete-item/autocomplete-item.component.tsx +0 -1
- package/src/components/autocomplete/components/autocomplete-item/autocomplete-item.types.ts +1 -1
- package/src/components/autocomplete/components/autocomplete-list-box/autocomplete-list-box.types.ts +2 -2
- package/src/components/autocomplete/components/autocomplete-list-box/components/autocomplete-list-box-option/autocomplete-list-box-option.component.tsx +3 -3
- package/src/components/autocomplete/components/autocomplete-list-box/components/autocomplete-list-box-option/autocomplete-list-box-option.types.ts +1 -1
- package/src/components/autocomplete/components/autocomplete-list-box/components/autocomplete-list-box-section/autocomplete-list-box-section.component.tsx +1 -1
- package/src/components/autocomplete/components/autocomplete-list-box/components/autocomplete-list-box-section/autocomplete-list-box-section.types.ts +1 -1
- package/src/components/badge/badge.component.tsx +5 -6
- package/src/components/badge/badge.styles.ts +3 -3
- package/src/components/bottom-sheet/components/bottom-sheet-dialog/bottom-sheet-dialog.component.tsx +0 -1
- package/src/components/bottom-sheet/components/bottom-sheet-modal/bottom-sheet-modal.component.tsx +2 -3
- package/src/components/breadcrumb/breadcrumb.component.tsx +4 -1
- package/src/components/breadcrumb/components/breadcrumb-item/breadcrumb-item.component.tsx +5 -5
- package/src/components/button/button.component.tsx +2 -2
- package/src/components/button/button.styles.ts +1 -1
- package/src/components/button-dropdown/button-dropdown.component.tsx +2 -2
- package/src/components/button-dropdown/components/button-dropdown-panel/button-dropdown-panel.component.tsx +3 -3
- package/src/components/button-group/button-group.component.tsx +1 -3
- package/src/components/checkbox-group/checkbox-group.component.tsx +2 -4
- package/src/components/checkbox-group/components/checkbox-group-checkbox/checkbox-group-checkbox.component.tsx +5 -2
- package/src/components/collapsible/collapsible.component.tsx +1 -1
- package/src/components/compacta/compacta.component.tsx +1 -1
- package/src/components/date-picker/date-picker.component.tsx +2 -2
- package/src/components/date-picker/date-picker.types.ts +18 -8
- package/src/components/date-picker/date-picker.utils.ts +3 -3
- package/src/components/error-message/error-message.component.tsx +2 -2
- package/src/components/error-message/error-message.types.ts +1 -1
- package/src/components/field/field.component.tsx +1 -1
- package/src/components/flexi-cell/flexi-cell.component.tsx +3 -3
- package/src/components/header/header.component.tsx +1 -1
- package/src/components/input-group/components/input-group-add-ons/components/input-group-add-on-default-add-on/input-group-add-on-default-add-on.component.tsx +1 -6
- package/src/components/input-group/components/input-group-add-ons/input-group-add-ons.styles.ts +2 -2
- package/src/components/input-group/input-group.component.tsx +14 -5
- package/src/components/input-group/input-group.styles.ts +15 -8
- package/src/components/list/components/list-item/list-item.component.tsx +2 -2
- package/src/components/pagination/components/pagination-item/pagination-item.types.ts +2 -0
- package/src/components/pagination/pagination.component.tsx +2 -2
- package/src/components/pagination/pagination.hooks.ts +2 -2
- package/src/components/pass-code/pass-code.component.tsx +3 -3
- package/src/components/pass-code-view/pass-code-view.types.ts +2 -2
- package/src/components/popover/components/panel/panel.component.tsx +3 -3
- package/src/components/popover/popover.component.tsx +5 -5
- package/src/components/popover/{popover.hooks.tsx → popover.utils.tsx} +2 -2
- package/src/components/progress-rope/components/progress-rope-step/progress-rope-step.component.tsx +2 -3
- package/src/components/progress-rope/components/progress-rope-step/progress-rope-step.types.ts +1 -1
- package/src/components/progress-rope/progress-rope.component.tsx +1 -2
- package/src/components/radio-group/components/radio-group-radio/radio-group-radio.component.tsx +2 -2
- package/src/components/radio-group/radio-group.component.tsx +2 -4
- package/src/components/select/select.styles.ts +1 -1
- package/src/components/selector/components/selector-button-group/components/selector-button-group-option/selector-button-group-option.component.tsx +3 -3
- package/src/components/selector/components/selector-button-group/selector-button-group.component.tsx +2 -2
- package/src/components/selector/components/selector-checkbox-group/components/selector-checkbox-group-option/selector-checkbox-group-option.component.tsx +2 -2
- package/src/components/selector/components/selector-checkbox-group/selector-checkbox-group.component.tsx +1 -3
- package/src/components/selector/components/selector-link-group/components/selector-link-group-option/selector-link-group-option.component.tsx +3 -3
- package/src/components/selector/components/selector-radio-group/components/selector-radio-group-option/selector-radio-group-option.component.tsx +2 -2
- package/src/components/selector/components/selector-radio-group/selector-radio-group.component.tsx +1 -3
- package/src/components/skip-link/skip-link.component.tsx +3 -3
- package/src/components/tabs/components/tabs-tab/tabs-tab.component.tsx +2 -2
- package/src/components/tabs/components/tabs-tab/tabs-tab.types.ts +1 -1
- package/src/components/tabs/components/tabs-tab-panel/tabs-tab-panel.types.ts +1 -1
- package/src/components/tabs/tabs.component.tsx +7 -7
- package/src/components/tabs/tabs.types.ts +1 -1
- package/src/tailwind/tailwind-plugin.ts +1 -1
- package/src/tailwind/utils/create-font-sizes.ts +22 -11
- package/src/tailwind/utils/generate-font-components.ts +16 -19
- package/src/tailwind/utils/generate-form-control.ts +10 -11
|
@@ -180,7 +180,7 @@ export const WestpacUIKitBasePlugin = plugin.withOptions(function(options = {})
|
|
|
180
180
|
}
|
|
181
181
|
},
|
|
182
182
|
button: {
|
|
183
|
-
base: 'inline-flex items-center justify-center rounded leading-[1.5] transition-[background] disabled:pointer-events-none disabled:opacity-50 group-
|
|
183
|
+
base: 'inline-flex items-center justify-center rounded leading-[1.5] transition-[background] disabled:pointer-events-none disabled:opacity-50 group-last/add-on-after:rounded-l-none group-first/add-on-before:rounded-r-none',
|
|
184
184
|
look: {
|
|
185
185
|
base: {
|
|
186
186
|
primary: 'border border-primary bg-primary text-white hover:bg-primary-70 active:bg-primary-50',
|
|
@@ -1 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
type FontSizeType = Record<string, string | [fontSize: string, lineHeight: string] | [
|
|
2
|
+
fontSize: string,
|
|
3
|
+
configuration: Partial<{
|
|
4
|
+
fontWeight: string | number;
|
|
5
|
+
letterSpacing: string;
|
|
6
|
+
lineHeight: string;
|
|
7
|
+
}>
|
|
8
|
+
]>;
|
|
9
|
+
export declare const createFontSizes: (fontTypes: string[]) => FontSizeType;
|
|
10
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PluginAPI } from 'tailwindcss/types/config.js';
|
|
1
|
+
import { CSSRuleObject, PluginAPI } from 'tailwindcss/types/config.js';
|
|
2
2
|
export declare const generateFontComponents: (typographySizes: Record<string, {
|
|
3
3
|
fontSize: string;
|
|
4
4
|
lineHeight: string;
|
|
5
|
-
}>, theme: PluginAPI['theme']) =>
|
|
5
|
+
}>, theme: PluginAPI['theme']) => CSSRuleObject[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@westpac/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"type": "module",
|
|
@@ -255,9 +255,9 @@
|
|
|
255
255
|
"typescript": "^5.1.6",
|
|
256
256
|
"vite": "^4.3.9",
|
|
257
257
|
"vitest": "^0.30.1",
|
|
258
|
-
"@westpac/
|
|
258
|
+
"@westpac/ts-config": "~0.0.0",
|
|
259
259
|
"@westpac/test-config": "~0.0.0",
|
|
260
|
-
"@westpac/
|
|
260
|
+
"@westpac/eslint-config": "~0.2.1"
|
|
261
261
|
},
|
|
262
262
|
"dependencies": {
|
|
263
263
|
"@duetds/date-picker": "~1.4.0",
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { useAccordion } from '@react-aria/accordion';
|
|
3
|
+
import { AriaAccordionProps, useAccordion } from '@react-aria/accordion';
|
|
4
4
|
import { filterDOMProps } from '@react-aria/utils';
|
|
5
5
|
import { useDOMRef } from '@react-spectrum/utils';
|
|
6
|
+
import { DOMProps, DOMRef } from '@react-types/shared';
|
|
6
7
|
import React, { Children, cloneElement, forwardRef, isValidElement } from 'react';
|
|
7
|
-
import { Item, type ItemProps, useTreeState } from 'react-stately';
|
|
8
|
+
import { Item, type ItemProps, TreeProps, useTreeState } from 'react-stately';
|
|
8
9
|
|
|
9
10
|
import { styles } from './accordion.styles.js';
|
|
10
11
|
import { type AccordionProps } from './accordion.types.js';
|
|
@@ -12,30 +13,35 @@ import { AccordionItem as AccordionItemContent } from './components/index.js';
|
|
|
12
13
|
|
|
13
14
|
function Accordion<T extends object>(
|
|
14
15
|
{ className, rounded = true, look = 'soft', ...props }: AccordionProps<T>,
|
|
15
|
-
ref:
|
|
16
|
+
ref: DOMRef<HTMLDivElement>,
|
|
16
17
|
) {
|
|
17
18
|
// react-aria doesn't allow for now to use component children when there is multiple levels
|
|
18
19
|
// in our case we don't need that functionality and we have to render html tags or components
|
|
19
20
|
// therefore as a workaround we are setting hasChildItems false for all of them
|
|
20
21
|
// https://github.com/adobe/react-spectrum/issues/3882
|
|
21
|
-
const finalProps
|
|
22
|
+
const finalProps = {
|
|
22
23
|
...props,
|
|
23
24
|
children: Children.map(props.children, child => {
|
|
24
25
|
// equal to (if (child == null || typeof child == 'string'))
|
|
25
26
|
if (!isValidElement(child)) return child;
|
|
26
27
|
return cloneElement(child, {
|
|
27
|
-
...
|
|
28
|
+
...child.props,
|
|
28
29
|
// Adding hasChildItems false by default
|
|
29
30
|
hasChildItems: false,
|
|
30
31
|
});
|
|
31
32
|
}),
|
|
32
33
|
};
|
|
33
|
-
const state = useTreeState<T>(finalProps);
|
|
34
|
+
const state = useTreeState<T>(finalProps as TreeProps<T>);
|
|
34
35
|
const domRef = useDOMRef<HTMLDivElement>(ref);
|
|
35
|
-
const { accordionProps } = useAccordion(finalProps
|
|
36
|
+
const { accordionProps } = useAccordion(finalProps as AriaAccordionProps<T>, state, domRef);
|
|
36
37
|
|
|
37
38
|
return (
|
|
38
|
-
<div
|
|
39
|
+
<div
|
|
40
|
+
{...filterDOMProps(finalProps as DOMProps)}
|
|
41
|
+
{...accordionProps}
|
|
42
|
+
ref={domRef}
|
|
43
|
+
className={styles({ className, rounded })}
|
|
44
|
+
>
|
|
39
45
|
<div className="ml-[-1px] mt-[-1px]">
|
|
40
46
|
{[...state.collection].map(item => (
|
|
41
47
|
<AccordionItemContent<T> key={item.key} item={item} state={state} look={look} />
|
|
@@ -46,7 +52,7 @@ function Accordion<T extends object>(
|
|
|
46
52
|
}
|
|
47
53
|
|
|
48
54
|
const _Accordion = forwardRef(Accordion) as unknown as { displayName: string } & (<T>(
|
|
49
|
-
props: AccordionProps<T> & { ref?:
|
|
55
|
+
props: AccordionProps<T> & { ref?: HTMLElement },
|
|
50
56
|
) => ReturnType<typeof Accordion>);
|
|
51
57
|
|
|
52
58
|
_Accordion.displayName = 'Accordion';
|
|
@@ -6,7 +6,7 @@ import { styles } from './accordion.styles.js';
|
|
|
6
6
|
import { AccordionItemProps } from './components/index.js';
|
|
7
7
|
|
|
8
8
|
type Variants = VariantProps<typeof styles>;
|
|
9
|
-
export type AccordionProps<T =
|
|
9
|
+
export type AccordionProps<T = HTMLElement> = SpectrumAccordionProps<T> & {
|
|
10
10
|
/**
|
|
11
11
|
* <AccordionItem /> as a collection
|
|
12
12
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useAccordionItem } from '@react-aria/accordion';
|
|
2
2
|
import { AnimatePresence, LazyMotion, m } from 'framer-motion';
|
|
3
3
|
import React, { useRef } from 'react';
|
|
4
|
-
import { mergeProps, useFocusRing, useHover, useLocale } from 'react-aria';
|
|
4
|
+
import { Key, mergeProps, useFocusRing, useHover, useLocale } from 'react-aria';
|
|
5
5
|
|
|
6
6
|
import { ArrowLeftIcon, ArrowRightIcon } from '../../../icon/index.js';
|
|
7
7
|
|
|
@@ -10,7 +10,7 @@ import { type AccordionItemProps } from './accordion-item.types.js';
|
|
|
10
10
|
|
|
11
11
|
const loadAnimations = () => import('./accordion-item.utils.js').then(res => res.default);
|
|
12
12
|
|
|
13
|
-
export function AccordionItem<T =
|
|
13
|
+
export function AccordionItem<T = HTMLElement>({
|
|
14
14
|
className,
|
|
15
15
|
tag: Tag = 'div',
|
|
16
16
|
look = 'soft',
|
|
@@ -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 as
|
|
24
|
-
const isDisabled = state.disabledKeys.has(item.key as
|
|
23
|
+
const isOpen = state.expandedKeys.has(item.key as Key);
|
|
24
|
+
const isDisabled = state.disabledKeys.has(item.key as Key);
|
|
25
25
|
const { hoverProps } = useHover({ isDisabled });
|
|
26
26
|
const { direction } = useLocale();
|
|
27
27
|
const styles = accordionItemStyles({ isOpen, isDisabled, look, isFocusVisible });
|
|
@@ -92,7 +92,14 @@ export function Autocomplete<T extends object>({
|
|
|
92
92
|
((!state.isOpen && state.isFocused && searchProps.value.length > 0 && !state.selectedItem) ||
|
|
93
93
|
(state.collection.size === 0 && searchProps.value.length > 0))
|
|
94
94
|
);
|
|
95
|
-
}, [
|
|
95
|
+
}, [
|
|
96
|
+
noOptionsMessage,
|
|
97
|
+
state.isOpen,
|
|
98
|
+
state.isFocused,
|
|
99
|
+
state.selectedItem,
|
|
100
|
+
state.collection.size,
|
|
101
|
+
searchProps.value.length,
|
|
102
|
+
]);
|
|
96
103
|
|
|
97
104
|
const iconSize = useMemo(() => {
|
|
98
105
|
switch (size) {
|
|
@@ -161,7 +168,7 @@ export function Autocomplete<T extends object>({
|
|
|
161
168
|
>
|
|
162
169
|
<AutocompleteListBox
|
|
163
170
|
{...listBoxProps}
|
|
164
|
-
autoFocus={listBoxProps.autoFocus as
|
|
171
|
+
autoFocus={listBoxProps.autoFocus as boolean | undefined}
|
|
165
172
|
listBoxRef={listBoxRef}
|
|
166
173
|
state={state}
|
|
167
174
|
/>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { type ItemProps } from 'react-stately';
|
|
3
3
|
|
|
4
|
-
export type AutocompleteItemProps<T =
|
|
4
|
+
export type AutocompleteItemProps<T = HTMLElement> = ItemProps<T> & {
|
|
5
5
|
/**
|
|
6
6
|
* AutocompleteItem body content
|
|
7
7
|
*/
|
package/src/components/autocomplete/components/autocomplete-list-box/autocomplete-list-box.types.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { HTMLAttributes } from 'react';
|
|
|
2
2
|
import { AriaListBoxOptions } from 'react-aria';
|
|
3
3
|
import { ListState } from 'react-stately';
|
|
4
4
|
|
|
5
|
-
export type AutocompleteListBoxProps
|
|
5
|
+
export type AutocompleteListBoxProps = AriaListBoxOptions<unknown> & {
|
|
6
6
|
listBoxRef?: React.RefObject<HTMLUListElement>;
|
|
7
|
-
state: ListState<
|
|
7
|
+
state: ListState<unknown>;
|
|
8
8
|
} & HTMLAttributes<Element>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { type Node } from '@react-types/shared';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { useOption } from 'react-aria';
|
|
3
|
+
import { Key, useOption } from 'react-aria';
|
|
4
4
|
import { type ListState } from 'react-stately';
|
|
5
5
|
|
|
6
6
|
import { styles } from './autocomplete-list-box-option.styles.js';
|
|
7
7
|
|
|
8
|
-
interface AutocompleteListBoxOptionProps<T =
|
|
8
|
+
interface AutocompleteListBoxOptionProps<T = unknown> {
|
|
9
9
|
item: Node<T>;
|
|
10
10
|
state: ListState<T>;
|
|
11
11
|
}
|
|
@@ -18,7 +18,7 @@ export function AutocompleteListBoxOption({ item, state }: AutocompleteListBoxOp
|
|
|
18
18
|
|
|
19
19
|
const { optionProps, isDisabled, isSelected, isFocused } = useOption(
|
|
20
20
|
{
|
|
21
|
-
key: item.key as
|
|
21
|
+
key: item.key as Key,
|
|
22
22
|
},
|
|
23
23
|
state,
|
|
24
24
|
ref,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Node } from '@react-types/shared';
|
|
2
2
|
import { type ListState } from 'react-stately';
|
|
3
3
|
|
|
4
|
-
export type AutocompleteListBoxOptionProps<T =
|
|
4
|
+
export type AutocompleteListBoxOptionProps<T = HTMLLIElement> = {
|
|
5
5
|
item: Node<T>;
|
|
6
6
|
state: ListState<T>;
|
|
7
7
|
};
|
|
@@ -8,7 +8,7 @@ import { type AutocompleteListBoxSectionProps } from './autocomplete-list-box-se
|
|
|
8
8
|
/**
|
|
9
9
|
* @private
|
|
10
10
|
*/
|
|
11
|
-
export function AutocompleteListBoxSection({ section, state }: AutocompleteListBoxSectionProps) {
|
|
11
|
+
export function AutocompleteListBoxSection({ section, state }: AutocompleteListBoxSectionProps<unknown>) {
|
|
12
12
|
const { itemProps, headingProps, groupProps } = useListBoxSection({
|
|
13
13
|
heading: section.rendered,
|
|
14
14
|
'aria-label': section['aria-label'],
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import React, { forwardRef } from 'react';
|
|
3
|
+
import React, { Ref, forwardRef } from 'react';
|
|
4
4
|
|
|
5
5
|
import { styles } from './badge.styles.js';
|
|
6
6
|
import { type BadgeProps } from './badge.types.js';
|
|
7
7
|
|
|
8
8
|
export function BaseBadge(
|
|
9
9
|
{ className, tag: Tag = 'div', color = 'hero', type = 'default', soft = false, children, ...props }: BadgeProps,
|
|
10
|
-
ref:
|
|
10
|
+
ref: Ref<HTMLElement>,
|
|
11
11
|
) {
|
|
12
12
|
return (
|
|
13
|
-
<Tag {...({ ref } as
|
|
14
|
-
{
|
|
15
|
-
<div className="relative bottom-[1px]">{children}</div>
|
|
13
|
+
<Tag {...({ ref } as object)} className={styles({ className, color, type, soft })} {...props}>
|
|
14
|
+
{children}
|
|
16
15
|
</Tag>
|
|
17
16
|
);
|
|
18
17
|
}
|
|
19
18
|
|
|
20
|
-
export const Badge = forwardRef<
|
|
19
|
+
export const Badge = forwardRef<HTMLElement, BadgeProps>(BaseBadge);
|
|
@@ -2,7 +2,7 @@ import { tv } from 'tailwind-variants';
|
|
|
2
2
|
|
|
3
3
|
export const styles = tv(
|
|
4
4
|
{
|
|
5
|
-
base: 'inline-block whitespace-nowrap border text-center
|
|
5
|
+
base: 'inline-block whitespace-nowrap border text-center',
|
|
6
6
|
variants: {
|
|
7
7
|
color: {
|
|
8
8
|
danger: 'border-danger bg-danger text-white',
|
|
@@ -24,8 +24,8 @@ export const styles = tv(
|
|
|
24
24
|
'warning-inverted': 'border-none bg-white text-warning',
|
|
25
25
|
},
|
|
26
26
|
type: {
|
|
27
|
-
pill: 'typography-body-10 rounded-xl px-[0.4375rem] py-[0.25rem] font-medium leading-none',
|
|
28
|
-
default: 'rounded-sm px-1
|
|
27
|
+
pill: 'typography-body-10 h-4 rounded-xl px-[0.4375rem] py-[0.25rem] font-medium leading-none',
|
|
28
|
+
default: 'h-3 rounded-sm px-1 text-[0.75rem] leading-none',
|
|
29
29
|
},
|
|
30
30
|
soft: {
|
|
31
31
|
true: 'bg-white',
|
package/src/components/bottom-sheet/components/bottom-sheet-modal/bottom-sheet-modal.component.tsx
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { clsx } from 'clsx';
|
|
2
1
|
import { PanInfo, motion, useAnimation } from 'framer-motion';
|
|
3
2
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
4
3
|
import { Overlay, useModalOverlay } from 'react-aria';
|
|
@@ -52,7 +51,7 @@ export function BottomSheetModal({ state, height, width, children, portalContain
|
|
|
52
51
|
return;
|
|
53
52
|
}
|
|
54
53
|
controls.start('hidden');
|
|
55
|
-
}, [state.isOpen]);
|
|
54
|
+
}, [controls, state.isOpen]);
|
|
56
55
|
|
|
57
56
|
const onDragEnd = useCallback(
|
|
58
57
|
(_: unknown, info: PanInfo) => {
|
|
@@ -66,7 +65,7 @@ export function BottomSheetModal({ state, height, width, children, portalContain
|
|
|
66
65
|
controls.start('visible');
|
|
67
66
|
state.open();
|
|
68
67
|
},
|
|
69
|
-
[controls],
|
|
68
|
+
[controls, state],
|
|
70
69
|
);
|
|
71
70
|
|
|
72
71
|
if (!isBrowser || !state.isOpen) {
|
|
@@ -4,6 +4,7 @@ import React, { Children, FunctionComponentElement, cloneElement } from 'react';
|
|
|
4
4
|
import { useBreadcrumbs } from 'react-aria';
|
|
5
5
|
|
|
6
6
|
import { type BreadcrumbProps } from './breadcrumb.types.js';
|
|
7
|
+
import { BreadcrumbItemProps } from './components/breadcrumb-item/breadcrumb-item.types.js';
|
|
7
8
|
|
|
8
9
|
export function Breadcrumb({ className, children, 'aria-label': ariaLabel = 'Breadcrumb', ...props }: BreadcrumbProps) {
|
|
9
10
|
const { navProps } = useBreadcrumbs(props);
|
|
@@ -15,7 +16,9 @@ export function Breadcrumb({ className, children, 'aria-label': ariaLabel = 'Bre
|
|
|
15
16
|
{Children.map(
|
|
16
17
|
children,
|
|
17
18
|
(child, i) =>
|
|
18
|
-
cloneElement(child as FunctionComponentElement<
|
|
19
|
+
cloneElement(child as FunctionComponentElement<BreadcrumbItemProps>, {
|
|
20
|
+
isCurrent: i === childCount - 1,
|
|
21
|
+
}) ?? <></>,
|
|
19
22
|
)}
|
|
20
23
|
</ol>
|
|
21
24
|
</nav>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import React, { forwardRef, useRef } from 'react';
|
|
3
|
+
import React, { Ref, RefObject, forwardRef, useRef } from 'react';
|
|
4
4
|
import { useBreadcrumbItem } from 'react-aria';
|
|
5
5
|
|
|
6
6
|
import { ArrowRightIcon } from '../../../icon/index.js';
|
|
@@ -18,7 +18,7 @@ export function BaseBreadcrumbItem(
|
|
|
18
18
|
tag: Tag = 'span',
|
|
19
19
|
...props
|
|
20
20
|
}: BreadcrumbItemProps,
|
|
21
|
-
propRef:
|
|
21
|
+
propRef: Ref<HTMLElement>,
|
|
22
22
|
) {
|
|
23
23
|
const ref = useRef(propRef);
|
|
24
24
|
const FinalTag = (Tag === 'a' && isDisabled) || (Tag === 'a' && isCurrent) ? 'span' : Tag;
|
|
@@ -30,12 +30,12 @@ export function BaseBreadcrumbItem(
|
|
|
30
30
|
isCurrent,
|
|
31
31
|
elementType: FinalTag,
|
|
32
32
|
},
|
|
33
|
-
ref
|
|
33
|
+
ref as RefObject<HTMLElement>,
|
|
34
34
|
);
|
|
35
35
|
return (
|
|
36
36
|
<li className="inline-flex items-center">
|
|
37
37
|
<FinalTag
|
|
38
|
-
{...({ ...itemProps, ref: propRef, href: FinalTag === 'a' ? href : undefined } as
|
|
38
|
+
{...({ ...itemProps, ref: propRef, href: FinalTag === 'a' ? href : undefined } as object)}
|
|
39
39
|
className={styles({ className, isDisabled, isCurrent })}
|
|
40
40
|
>
|
|
41
41
|
{children}
|
|
@@ -49,4 +49,4 @@ export function BaseBreadcrumbItem(
|
|
|
49
49
|
);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
export const BreadcrumbItem = forwardRef<
|
|
52
|
+
export const BreadcrumbItem = forwardRef<HTMLElement, BreadcrumbItemProps>(BaseBreadcrumbItem);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import React, { forwardRef, useMemo } from 'react';
|
|
3
|
+
import React, { Ref, forwardRef, useMemo } from 'react';
|
|
4
4
|
import { mergeProps, useFocusRing } from 'react-aria';
|
|
5
5
|
|
|
6
6
|
import { styles as buttonStyles } from './button.styles.js';
|
|
@@ -22,7 +22,7 @@ function BaseButton(
|
|
|
22
22
|
children,
|
|
23
23
|
...props
|
|
24
24
|
}: ButtonProps,
|
|
25
|
-
ref:
|
|
25
|
+
ref: Ref<HTMLButtonElement & HTMLAnchorElement & HTMLSpanElement & HTMLDivElement>,
|
|
26
26
|
) {
|
|
27
27
|
const { isFocusVisible, focusProps } = useFocusRing();
|
|
28
28
|
const iconSize = useMemo(() => getIconSize(size), [size]);
|
|
@@ -6,7 +6,7 @@ import { tv } from 'tailwind-variants';
|
|
|
6
6
|
export const styles = tv(
|
|
7
7
|
{
|
|
8
8
|
slots: {
|
|
9
|
-
base: 'items-center justify-center rounded leading-[1.5] transition-[background] disabled:pointer-events-none disabled:opacity-50 group-
|
|
9
|
+
base: 'items-center justify-center rounded leading-[1.5] transition-[background] disabled:pointer-events-none disabled:opacity-50 group-first/add-on-before:rounded-r-none group-last/add-on-after:rounded-l-none',
|
|
10
10
|
iconBefore: '',
|
|
11
11
|
iconAfter: '',
|
|
12
12
|
dropdown: 'ml-[0.4em]',
|
|
@@ -23,7 +23,7 @@ export function ButtonDropdown({
|
|
|
23
23
|
soft = false,
|
|
24
24
|
block = false,
|
|
25
25
|
}: ButtonDropdownProps) {
|
|
26
|
-
const ref = useRef<HTMLDivElement>(null);
|
|
26
|
+
const ref = useRef<HTMLButtonElement & HTMLAnchorElement & HTMLSpanElement & HTMLDivElement>(null);
|
|
27
27
|
const panelId = useId();
|
|
28
28
|
const styles = buttonDropdownStyles({ block, dropdownSize });
|
|
29
29
|
const state = useOverlayTriggerState({ defaultOpen: open });
|
|
@@ -35,7 +35,7 @@ export function ButtonDropdown({
|
|
|
35
35
|
(event: globalThis.KeyboardEvent) => {
|
|
36
36
|
if (state.isOpen && event.key === 'Escape') state.close();
|
|
37
37
|
},
|
|
38
|
-
[state
|
|
38
|
+
[state],
|
|
39
39
|
);
|
|
40
40
|
|
|
41
41
|
useEffect(() => {
|
|
@@ -26,7 +26,7 @@ export function ButtonDropdownPanel({ className, children, state, block, id, ...
|
|
|
26
26
|
)
|
|
27
27
|
state.close();
|
|
28
28
|
},
|
|
29
|
-
[state
|
|
29
|
+
[props.triggerRef, state],
|
|
30
30
|
);
|
|
31
31
|
|
|
32
32
|
// React Aria does not handle click as we need when isNonModal is true so this is needed
|
|
@@ -42,7 +42,7 @@ export function ButtonDropdownPanel({ className, children, state, block, id, ...
|
|
|
42
42
|
)
|
|
43
43
|
state.close();
|
|
44
44
|
},
|
|
45
|
-
[state
|
|
45
|
+
[props.triggerRef, state],
|
|
46
46
|
);
|
|
47
47
|
|
|
48
48
|
useEffect(() => {
|
|
@@ -52,7 +52,7 @@ export function ButtonDropdownPanel({ className, children, state, block, id, ...
|
|
|
52
52
|
window.document.removeEventListener('focusin', focusHandler);
|
|
53
53
|
window.document.removeEventListener('click', clickHandler);
|
|
54
54
|
};
|
|
55
|
-
}, []);
|
|
55
|
+
}, [clickHandler, focusHandler]);
|
|
56
56
|
|
|
57
57
|
return (
|
|
58
58
|
<div
|
|
@@ -99,9 +99,7 @@ export function ButtonGroup({
|
|
|
99
99
|
<div className={styles.base({ className })} {...radioGroupProps}>
|
|
100
100
|
<Label {...labelProps}>{label}</Label>
|
|
101
101
|
{hintMessage && <Hint {...descriptionProps}>{hintMessage}</Hint>}
|
|
102
|
-
{errorMessage && state.
|
|
103
|
-
<ErrorMessage {...errorMessageProps} message={errorMessage} />
|
|
104
|
-
)}
|
|
102
|
+
{errorMessage && state.isInvalid && <ErrorMessage {...errorMessageProps} message={errorMessage} />}
|
|
105
103
|
<div className={styles.buttonWrapper()}>
|
|
106
104
|
<ButtonGroupContext.Provider value={{ state, size, look, block }}>
|
|
107
105
|
{buttons.map((button, index) => (
|
|
@@ -91,7 +91,7 @@ export function CheckboxGroup({
|
|
|
91
91
|
const { groupProps, labelProps, errorMessageProps, descriptionProps } = useCheckboxGroup({ ...props, label }, state);
|
|
92
92
|
const { isFocusVisible, focusProps } = useFocusRing();
|
|
93
93
|
const [hiddenOptions, setHiddenOptions] = useState<boolean>(showAmount > 0);
|
|
94
|
-
const firstNewCheckboxRef = useRef<
|
|
94
|
+
const firstNewCheckboxRef = useRef<HTMLLabelElement>(null);
|
|
95
95
|
const revealAmount = checkboxes && checkboxes.length - showAmount;
|
|
96
96
|
const styles = checkboxStyles({ orientation, isFocusVisible });
|
|
97
97
|
const panelId = useId();
|
|
@@ -113,9 +113,7 @@ export function CheckboxGroup({
|
|
|
113
113
|
<div className={styles.base({ className })} {...groupProps}>
|
|
114
114
|
<Label {...labelProps}>{label}</Label>
|
|
115
115
|
{hintMessage && <Hint {...descriptionProps}>{hintMessage}</Hint>}
|
|
116
|
-
{errorMessage && state.
|
|
117
|
-
<ErrorMessage {...errorMessageProps} message={errorMessage} />
|
|
118
|
-
)}
|
|
116
|
+
{errorMessage && state.isInvalid && <ErrorMessage {...errorMessageProps} message={errorMessage} />}
|
|
119
117
|
<div className={styles.itemWrapper()} id={panelId}>
|
|
120
118
|
<CheckboxGroupContext.Provider value={{ state, orientation, size }}>
|
|
121
119
|
{childrenToRender}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import React, { forwardRef, useContext, useRef } from 'react';
|
|
3
|
+
import React, { Ref, forwardRef, useContext, useRef } from 'react';
|
|
4
4
|
import { VisuallyHidden, useCheckboxGroupItem, useFocusRing } from 'react-aria';
|
|
5
5
|
|
|
6
6
|
import { Icon } from '../../../icon/icon.component.js';
|
|
@@ -31,7 +31,10 @@ function CheckIcon({ copyrightYear = '2024', size, ...props }: IconProps) {
|
|
|
31
31
|
);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
function BaseCheckbox(
|
|
34
|
+
function BaseCheckbox(
|
|
35
|
+
{ className, hint, label, value, ...props }: CheckboxGroupCheckboxProps,
|
|
36
|
+
ref: Ref<HTMLLabelElement>,
|
|
37
|
+
) {
|
|
35
38
|
const { state, size, orientation } = useContext(CheckboxGroupContext);
|
|
36
39
|
const localRef = useRef(null);
|
|
37
40
|
const { inputProps, isDisabled, isSelected } = useCheckboxGroupItem(
|
|
@@ -146,7 +146,7 @@ export function Compacta({
|
|
|
146
146
|
look="link"
|
|
147
147
|
size="large"
|
|
148
148
|
onClick={() => handleToggle(item.id, index)}
|
|
149
|
-
ref={(el:
|
|
149
|
+
ref={(el: HTMLButtonElement & HTMLAnchorElement & HTMLSpanElement & HTMLDivElement) => {
|
|
150
150
|
toggleRefs.current[index] = el;
|
|
151
151
|
}}
|
|
152
152
|
aria-labelledby={`gel-compacta-title-${item.id}`}
|
|
@@ -46,7 +46,7 @@ export function DatePicker({
|
|
|
46
46
|
|
|
47
47
|
const dateAdapter = useMemo(
|
|
48
48
|
() => ({
|
|
49
|
-
parse(value = '', createDate:
|
|
49
|
+
parse(value = '', createDate: (year: string, month: string, day: string) => Date) {
|
|
50
50
|
const matches = value.match(/^(\d{1,2})-(\d{1,2})-(\d{4})$/);
|
|
51
51
|
if (matches) {
|
|
52
52
|
return createDate(matches[3], matches[2], matches[1]);
|
|
@@ -103,7 +103,7 @@ export function DatePicker({
|
|
|
103
103
|
ref.current.isDateDisabled = (date: Date) => {
|
|
104
104
|
return isDateDisabled(date, disableWeekends, disableDaysOfWeek, disableDates);
|
|
105
105
|
};
|
|
106
|
-
}, [ref, initialized]);
|
|
106
|
+
}, [ref, initialized, dateAdapter, localization, value, id, name, disableWeekends, disableDaysOfWeek, disableDates]);
|
|
107
107
|
|
|
108
108
|
useLayoutEffect(() => {
|
|
109
109
|
if (!ref.current) {
|
|
@@ -4,10 +4,10 @@ import { VariantProps } from 'tailwind-variants';
|
|
|
4
4
|
import { styles } from './date-picker.styles.js';
|
|
5
5
|
|
|
6
6
|
export type DuetDatePickerElement = Element & {
|
|
7
|
-
dateAdapter:
|
|
8
|
-
identifier
|
|
7
|
+
dateAdapter: object;
|
|
8
|
+
identifier?: string;
|
|
9
9
|
isDateDisabled: (date: Date) => boolean;
|
|
10
|
-
localization:
|
|
10
|
+
localization: object;
|
|
11
11
|
max?: string;
|
|
12
12
|
min?: string;
|
|
13
13
|
name?: string;
|
|
@@ -48,23 +48,33 @@ export type DatePickerProps = {
|
|
|
48
48
|
/*
|
|
49
49
|
* onBlur
|
|
50
50
|
*/
|
|
51
|
-
|
|
51
|
+
// NOTE: duet library uses custom events build with another library causing these to be hard to type
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
53
|
+
onBlur?: (...args: any[]) => void;
|
|
52
54
|
/*
|
|
53
55
|
* onChange
|
|
54
56
|
*/
|
|
55
|
-
|
|
57
|
+
// NOTE: duet library uses custom events build with another library causing these to be hard to type
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
59
|
+
onChange?: (...args: any[]) => void;
|
|
56
60
|
/*
|
|
57
61
|
* onClose
|
|
58
62
|
*/
|
|
59
|
-
|
|
63
|
+
// NOTE: duet library uses custom events build with another library causing these to be hard to type
|
|
64
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
65
|
+
onClose?: (...args: any[]) => void;
|
|
60
66
|
/*
|
|
61
67
|
* onFocus
|
|
62
68
|
*/
|
|
63
|
-
|
|
69
|
+
// NOTE: duet library uses custom events build with another library causing these to be hard to type
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
71
|
+
onFocus?: (...args: any[]) => void;
|
|
64
72
|
/*
|
|
65
73
|
* onOpen
|
|
66
74
|
*/
|
|
67
|
-
|
|
75
|
+
// NOTE: duet library uses custom events build with another library causing these to be hard to type
|
|
76
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
77
|
+
onOpen?: (...args: any[]) => void;
|
|
68
78
|
/*
|
|
69
79
|
* placeholder
|
|
70
80
|
*/
|