@wonderflow/react-components 3.0.0-beta.24 → 3.0.0-beta.25
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/autocomplete/autocomplete-option.d.ts +15 -0
- package/autocomplete/autocomplete-option.js +11 -0
- package/autocomplete/autocomplete.d.ts +13 -0
- package/autocomplete/autocomplete.js +82 -0
- package/autocomplete/autocomplete.module.css +1 -0
- package/autocomplete/index.d.ts +2 -0
- package/autocomplete/index.js +1 -0
- package/button/button.module.css +1 -1
- package/dropdown/dropdown.js +2 -2
- package/icon/icon.d.ts +1 -1
- package/index.d.ts +2 -0
- package/index.js +1 -0
- package/menu/menu-item/menu-item.d.ts +2 -2
- package/menu/menu-item/menu-item.js +6 -6
- package/menu/menu.d.ts +5 -4
- package/menu/menu.js +2 -2
- package/menu/menu.module.css +1 -1
- package/package.json +1 -1
- package/textfield/base-field/base-field.d.ts +1 -1
- package/textfield/textfield.d.ts +2 -2
- package/textfield/textfield.js +8 -7
- package/themes/dark.css +1 -1
- package/themes/light.css +1 -1
- package/title/title.js +1 -1
- package/tooltip/tooltip.js +2 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { MenuItemProps } from '..';
|
|
2
|
+
import { PropsWithChildren } from 'react';
|
|
3
|
+
import { Except } from 'type-fest';
|
|
4
|
+
export declare type AutocompleteOptionProps = PropsWithChildren<PropsWithClass> & Except<MenuItemProps, 'padding' | 'autoFocus' | 'description' | 'onClick'> & {
|
|
5
|
+
value: string;
|
|
6
|
+
onClick?(value?: string, content?: string): void;
|
|
7
|
+
children: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const AutocompleteOption: import("react").ForwardRefExoticComponent<PropsWithClass & {
|
|
10
|
+
children?: import("react").ReactNode;
|
|
11
|
+
} & Except<MenuItemProps, "description" | "onClick" | "autoFocus" | "padding"> & {
|
|
12
|
+
value: string;
|
|
13
|
+
onClick?(value?: string | undefined, content?: string | undefined): void;
|
|
14
|
+
children: string;
|
|
15
|
+
} & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Menu } from '..';
|
|
3
|
+
import { forwardRef, useCallback, useRef } from 'react';
|
|
4
|
+
export const AutocompleteOption = forwardRef(({ children, value, onClick, ...otherProps }, forwardedRef) => {
|
|
5
|
+
const contentRef = useRef(null);
|
|
6
|
+
const handleClick = useCallback(() => {
|
|
7
|
+
onClick && onClick(value, contentRef?.current?.innerText);
|
|
8
|
+
}, [onClick, value]);
|
|
9
|
+
return (_jsx(Menu.Item, { ref: forwardedRef, role: "option", padding: false, onClick: handleClick, ...otherProps, children: _jsx("span", { ref: contentRef, children: children }, void 0) }, void 0));
|
|
10
|
+
});
|
|
11
|
+
AutocompleteOption.displayName = 'Autocomplete.Option';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AutocompleteOptionProps } from './autocomplete-option';
|
|
2
|
+
import { ForwardRefExoticComponent, ReactNode } from 'react';
|
|
3
|
+
import { TextfieldProps } from '..';
|
|
4
|
+
export declare type AutocompleteProps = TextfieldProps & {
|
|
5
|
+
onChange?(value?: string): void;
|
|
6
|
+
maxHeight?: string;
|
|
7
|
+
emptyMessage?: ReactNode;
|
|
8
|
+
};
|
|
9
|
+
declare type AutocompleteComponent = ForwardRefExoticComponent<AutocompleteProps> & {
|
|
10
|
+
Option: ForwardRefExoticComponent<AutocompleteOptionProps>;
|
|
11
|
+
};
|
|
12
|
+
export declare const Autocomplete: AutocompleteComponent;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { AnimatePresence, motion } from 'framer-motion';
|
|
3
|
+
import { AutocompleteOption } from './autocomplete-option';
|
|
4
|
+
import { Children, cloneElement, forwardRef, useCallback, useMemo, useRef, useState, useEffect } from 'react';
|
|
5
|
+
import { useDebounce, useFocusWithin, useKeyPress, useSize } from 'ahooks';
|
|
6
|
+
import { Text, Menu, Textfield } from '..';
|
|
7
|
+
import { Autocomplete as AutocompleteClass, OptionsList } from './autocomplete.module.css';
|
|
8
|
+
import { usePopperTooltip } from 'react-popper-tooltip';
|
|
9
|
+
import { useUIDSeed } from 'react-uid';
|
|
10
|
+
const AutocompleteAnimation = {
|
|
11
|
+
visible: {
|
|
12
|
+
y: 0,
|
|
13
|
+
opacity: 1,
|
|
14
|
+
transition: {
|
|
15
|
+
ease: [0, 0, 0.34, 1],
|
|
16
|
+
duration: 0.1
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
hidden: {
|
|
20
|
+
y: -5,
|
|
21
|
+
opacity: 0,
|
|
22
|
+
transition: {
|
|
23
|
+
ease: [0.3, 0.07, 1, 1],
|
|
24
|
+
duration: 0.1
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
export const Autocomplete = forwardRef(({ children, onChange, disabled, readOnly, value, maxHeight = '200px', emptyMessage = 'No results found', ...otherProps }, forwardedRef) => {
|
|
29
|
+
const seedID = useUIDSeed();
|
|
30
|
+
const autocompleteRef = useRef(forwardedRef);
|
|
31
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
32
|
+
const [content, setContent] = useState(String(value));
|
|
33
|
+
const isInteractive = useMemo(() => !disabled && !readOnly, [disabled, readOnly]);
|
|
34
|
+
const debouncedFieldContent = useDebounce(content, { wait: 100 });
|
|
35
|
+
const filteredOptions = useMemo(() => {
|
|
36
|
+
const items = Children.toArray(children);
|
|
37
|
+
return debouncedFieldContent
|
|
38
|
+
? items.filter((o) => {
|
|
39
|
+
const stringToMatch = typeof o.props.children === 'string' ? o.props.children : o.props.children.join('');
|
|
40
|
+
return stringToMatch?.toLowerCase().includes(debouncedFieldContent.toLowerCase());
|
|
41
|
+
})
|
|
42
|
+
: items;
|
|
43
|
+
}, [debouncedFieldContent, children]);
|
|
44
|
+
const isFocusWithin = useFocusWithin(autocompleteRef, {
|
|
45
|
+
onChange: (isFocusWithin) => {
|
|
46
|
+
isFocusWithin ? setIsOpen(true) : setIsOpen(false);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
useKeyPress('esc', () => setIsOpen(false));
|
|
50
|
+
const { getTooltipProps, setTooltipRef, setTriggerRef, triggerRef, visible } = usePopperTooltip({
|
|
51
|
+
delayShow: 0,
|
|
52
|
+
delayHide: 0,
|
|
53
|
+
trigger: null,
|
|
54
|
+
visible: isInteractive ? isOpen : false,
|
|
55
|
+
closeOnTriggerHidden: true,
|
|
56
|
+
placement: 'bottom-start',
|
|
57
|
+
offset: [0, 8],
|
|
58
|
+
interactive: true
|
|
59
|
+
});
|
|
60
|
+
const triggerSize = useSize(triggerRef);
|
|
61
|
+
const handleOptionClick = useCallback((optionValue, optionContent) => {
|
|
62
|
+
setContent(optionContent);
|
|
63
|
+
setIsOpen(false);
|
|
64
|
+
onChange && onChange(optionValue);
|
|
65
|
+
}, [onChange]);
|
|
66
|
+
const handleFilter = useCallback(({ currentTarget }) => {
|
|
67
|
+
setContent(currentTarget.value);
|
|
68
|
+
}, []);
|
|
69
|
+
const dynamicStyle = {
|
|
70
|
+
'--max-h': maxHeight
|
|
71
|
+
};
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
value && setContent(String(value));
|
|
74
|
+
}, [value]);
|
|
75
|
+
return (_jsxs("div", { ref: autocompleteRef, className: AutocompleteClass, "data-focus-within": isFocusWithin, children: [_jsx(Textfield, { ref: setTriggerRef, id: seedID('autocomplete-trigger'), "aria-haspopup": "true", "aria-controls": seedID('autocomplete-menu'), "aria-expanded": isOpen, onChange: handleFilter, value: content, autoComplete: "off", disabled: disabled, readOnly: readOnly, ...otherProps }, seedID('autocomplete-trigger')), _jsx(AnimatePresence, { children: visible && (_jsx("div", { ref: setTooltipRef, ...getTooltipProps({ style: { minInlineSize: triggerSize ? (triggerSize.width + 2) : 'auto' } }), children: _jsx(motion.div, { variants: AutocompleteAnimation, initial: "hidden", animate: "visible", exit: "hidden", children: _jsx(Menu, { role: "listbox", id: seedID('autocomplete-menu'), className: OptionsList, style: dynamicStyle, "aria-labelledby": seedID('autocomplete-trigger'), children: filteredOptions.length === 0
|
|
76
|
+
? _jsx(Text, { as: "div", textAlign: "center", dimmed: 5, children: emptyMessage }, void 0)
|
|
77
|
+
: Children.map(filteredOptions, (child) => cloneElement(child, {
|
|
78
|
+
onClick: handleOptionClick
|
|
79
|
+
})) }, void 0) }, void 0) }, void 0)) }, void 0)] }, void 0));
|
|
80
|
+
});
|
|
81
|
+
Autocomplete.Option = AutocompleteOption;
|
|
82
|
+
Autocomplete.displayName = 'Autocomplete';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.Autocomplete{display:contents}.OptionsList{-webkit-overflow-scrolling:touch;max-block-size:var(--max-h);overflow:auto;overscroll-behavior:contain}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Autocomplete } from './autocomplete';
|
package/button/button.module.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.Button{-webkit-touch-callout:none;grid-gap:.44rem;align-items:center;-webkit-appearance:none;appearance:none;background:none;border:0;border-radius:.22rem;box-sizing:border-box;cursor:pointer;display:inline-flex;font-family:inherit;font-weight:600;justify-content:center;margin:0;min-inline-size:min-content;overflow:hidden;position:relative;text-decoration:none;-webkit-user-select:none;user-select:none;white-space:nowrap}.Button[data-button-dimension=big]{block-size:2.67rem;font-size:1rem;padding:.55rem 1.33rem .66rem}.Button[data-button-dimension=regular]{block-size:2.22rem;font-size:.89rem;padding:.33rem .89rem .44rem}.Button[data-button-dimension=small]{grid-gap:.22rem;block-size:1.33rem;font-size:.78rem;padding:0 .22rem .11rem}.Button[data-button-kind=primary]{background:var(--cta-default);color:var(--cta-foreground)}.Button[data-button-kind=primary]:not([aria-pressed=true],[aria-disabled=true]):is(:active){background:var(--cta-dark)}.Button[data-button-kind=primary]:where([aria-pressed=true]),.Button[data-button-kind=primary]:where([aria-pressed=true]:active){background:#9e0018;color:#fff}.Button[data-button-kind=secondary]{-webkit-backdrop-filter:saturate(180%) blur(62px);backdrop-filter:saturate(180%) blur(62px);background-color:var(--global-vibrancy-background);color:var(--global-vibrancy-foreground)}.Button[data-button-kind=secondary]:not([aria-pressed=true],[aria-disabled=true]):is(:active){background-color:var(--global-vibrancy-background-hover);color:var(--global-vibrancy-foreground)}.Button[data-button-kind=secondary]:where([aria-pressed=true]),.Button[data-button-kind=secondary]:where([aria-pressed=true]:active){background:var(--dimmed-7);color:var(--dimmed-0)}.Button[data-button-kind=flat]{color:var(--global-vibrancy-foreground)}.Button[data-button-kind=flat]:not([aria-pressed=true],[aria-disabled=true]):is(:active){background-color:var(--global-vibrancy-background-hover)}.Button[data-button-kind=flat]:is(:hover,:focus){-webkit-backdrop-filter:saturate(180%) blur(62px);backdrop-filter:saturate(180%) blur(62px);background-color:var(--global-vibrancy-background);color:var(--global-vibrancy-foreground)}.Button[data-button-kind=flat]:where([aria-pressed=true]),.Button[data-button-kind=flat]:where([aria-pressed=true]:is(:active,:focus)){background:var(--dimmed-7);color:var(--dimmed-0)}.Button[data-button-fullwidth=true]{inline-size:100%}.Button[data-button-icon-position=right]{flex-direction:row-reverse}.Button[aria-disabled=true],.Button[aria-disabled=true]:is(:hover,:focus,:active){background-color:var(--global-
|
|
1
|
+
.Button{-webkit-touch-callout:none;grid-gap:.44rem;align-items:center;-webkit-appearance:none;appearance:none;background:none;border:0;border-radius:.22rem;box-sizing:border-box;cursor:pointer;display:inline-flex;font-family:inherit;font-weight:600;justify-content:center;margin:0;min-inline-size:min-content;overflow:hidden;position:relative;text-decoration:none;-webkit-user-select:none;user-select:none;white-space:nowrap}.Button[data-button-dimension=big]{block-size:2.67rem;font-size:1rem;padding:.55rem 1.33rem .66rem}.Button[data-button-dimension=regular]{block-size:2.22rem;font-size:.89rem;padding:.33rem .89rem .44rem}.Button[data-button-dimension=small]{grid-gap:.22rem;block-size:1.33rem;font-size:.78rem;padding:0 .22rem .11rem}.Button[data-button-kind=primary]{background:var(--cta-default);color:var(--cta-foreground)}.Button[data-button-kind=primary]:not([aria-pressed=true],[aria-disabled=true]):is(:active){background:var(--cta-dark)}.Button[data-button-kind=primary]:where([aria-pressed=true]),.Button[data-button-kind=primary]:where([aria-pressed=true]:active){background:#9e0018;color:#fff}.Button[data-button-kind=secondary]{-webkit-backdrop-filter:saturate(180%) blur(62px);backdrop-filter:saturate(180%) blur(62px);background-color:var(--global-vibrancy-background);color:var(--global-vibrancy-foreground)}.Button[data-button-kind=secondary]:not([aria-pressed=true],[aria-disabled=true]):is(:active){background-color:var(--global-vibrancy-background-hover);color:var(--global-vibrancy-foreground)}.Button[data-button-kind=secondary]:where([aria-pressed=true]),.Button[data-button-kind=secondary]:where([aria-pressed=true]:active){background:var(--dimmed-7);color:var(--dimmed-0)}.Button[data-button-kind=flat]{color:var(--global-vibrancy-foreground)}.Button[data-button-kind=flat]:not([aria-pressed=true],[aria-disabled=true]):is(:active){background-color:var(--global-vibrancy-background-hover)}.Button[data-button-kind=flat]:is(:hover,:focus){-webkit-backdrop-filter:saturate(180%) blur(62px);backdrop-filter:saturate(180%) blur(62px);background-color:var(--global-vibrancy-background);color:var(--global-vibrancy-foreground)}.Button[data-button-kind=flat]:where([aria-pressed=true]),.Button[data-button-kind=flat]:where([aria-pressed=true]:is(:active,:focus)){background:var(--dimmed-7);color:var(--dimmed-0)}.Button[data-button-fullwidth=true]{inline-size:100%}.Button[data-button-icon-position=right]{flex-direction:row-reverse}.Button[aria-disabled=true],.Button[aria-disabled=true]:is(:hover,:focus,:active){background-color:var(--global-disabled-background);color:var(--global-disabled-foreground);cursor:not-allowed}.Button[aria-busy=true]>:not(.SpinnerIndicator){visibility:hidden}.SpinnerIndicator{align-content:center;bottom:0;display:grid;justify-content:center;left:0;place-content:center;position:absolute;right:0;top:0}.ButtonsGroup{display:inline-flex}.ButtonsGroup>:not(:first-child,:last-child,:only-of-type){border-radius:0}.ButtonsGroup>:first-child:not(:only-of-type){border-bottom-right-radius:0;border-top-right-radius:0;box-shadow:inset -1px 0 0 #6666661a}.ButtonsGroup>:last-child:not(:only-of-type){border-bottom-left-radius:0;border-top-left-radius:0;box-shadow:inset 1px 0 0 #6666661a}
|
package/dropdown/dropdown.js
CHANGED
|
@@ -24,7 +24,7 @@ const DropdownAnimation = {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
|
-
export const Dropdown = forwardRef(({ children, trigger, offset = 8, placement = 'auto-start', className }, forwardedRef) => {
|
|
27
|
+
export const Dropdown = forwardRef(({ children, trigger, offset = 8, placement = 'auto-start', className, ...otherProps }, forwardedRef) => {
|
|
28
28
|
const renderedChildren = Children.toArray(children).filter(Boolean);
|
|
29
29
|
const seedID = useUIDSeed();
|
|
30
30
|
const dropdownRef = useRef(forwardedRef);
|
|
@@ -55,7 +55,7 @@ export const Dropdown = forwardRef(({ children, trigger, offset = 8, placement =
|
|
|
55
55
|
'aria-haspopup': 'true',
|
|
56
56
|
'aria-controls': seedID('dropdown-menu'),
|
|
57
57
|
'aria-expanded': isOpen,
|
|
58
|
-
|
|
58
|
+
...otherProps
|
|
59
59
|
})), _jsx(AnimatePresence, { children: visible && (_jsx("div", { ref: setTooltipRef, role: "tooltip", id: seedID('tooltip-content'), ...getTooltipProps({ className: PopUp }), children: _jsx(motion.div, { variants: DropdownAnimation, initial: "hidden", animate: "visible", exit: "hidden", children: Children.map(renderedChildren, (child) => cloneElement(child, {
|
|
60
60
|
id: seedID('dropdown-menu'),
|
|
61
61
|
'aria-labelledby': seedID('dropdown-trigger')
|
package/icon/icon.d.ts
CHANGED
|
@@ -33,5 +33,5 @@ export declare const Icon: import("react").ForwardRefExoticComponent<SVGAttribut
|
|
|
33
33
|
* Icons sized 16pt or less are displayed with the solid style.
|
|
34
34
|
* If the size is 24pt or larger, the icon is displayed with the outline style.
|
|
35
35
|
*/
|
|
36
|
-
dimension?:
|
|
36
|
+
dimension?: 14 | 16 | 24 | 32 | 40 | 48 | 56 | undefined;
|
|
37
37
|
} & import("react").RefAttributes<SVGSVGElement>>;
|
package/index.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ export { UIDReset as IdProvider } from 'react-uid';
|
|
|
2
2
|
export * as Polymorphic from './polymorphic';
|
|
3
3
|
export { Avatar } from './avatar';
|
|
4
4
|
export type { AvatarProps } from './avatar';
|
|
5
|
+
export { Autocomplete } from './autocomplete';
|
|
6
|
+
export type { AutocompleteProps } from './autocomplete';
|
|
5
7
|
export { Button, ButtonsGroup } from './button';
|
|
6
8
|
export type { ButtonProps, ButtonsGroupProps } from './button';
|
|
7
9
|
export { Card } from './card';
|
package/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { UIDReset as IdProvider } from 'react-uid';
|
|
2
2
|
export * as Polymorphic from './polymorphic';
|
|
3
3
|
export { Avatar } from './avatar';
|
|
4
|
+
export { Autocomplete } from './autocomplete';
|
|
4
5
|
export { Button, ButtonsGroup } from './button';
|
|
5
6
|
export { Card } from './card';
|
|
6
7
|
export { Checkbox, Radio, Toggle } from './selection-controls';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { Polymorphic } from '../..';
|
|
1
2
|
import { ReactNode } from 'react';
|
|
2
3
|
import { IconNames } from '../../icons/types';
|
|
3
|
-
import { Polymorphic } from '../..';
|
|
4
4
|
export declare type MenuItemProps = {
|
|
5
5
|
/**
|
|
6
6
|
* Content to display in the menu item.
|
|
@@ -22,7 +22,7 @@ export declare type MenuItemProps = {
|
|
|
22
22
|
/**
|
|
23
23
|
* Callback function to be called when the menu item is pressed.
|
|
24
24
|
*/
|
|
25
|
-
onClick?(): void;
|
|
25
|
+
onClick?(event?: Event): void;
|
|
26
26
|
/**
|
|
27
27
|
* Add an extra description to the menu item.
|
|
28
28
|
* This uses the `<Tooltip>` component internally.
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { Icon, Stack, Tooltip } from '../..';
|
|
3
|
+
import { Icon as IconClass, ItemContent, MenuItem as MenuItemClass } from './menu-item.module.css';
|
|
4
|
+
import { forwardRef, useCallback, useMemo, useRef } from 'react';
|
|
5
|
+
import { useFocusEffect, useRovingTabIndex } from 'react-roving-tabindex';
|
|
6
6
|
import clsx from 'clsx';
|
|
7
7
|
export const MenuItem = forwardRef(({ className, children, onClick, icon, dimension = 'regular', as: Wrapper = 'button', iconPosition = 'left', description, padding = true, disabled = false, autoFocus, decoration, ...otherProps }, forwardedRef) => {
|
|
8
8
|
const itemRef = useRef(forwardedRef);
|
|
9
9
|
const [tabIndex, focused, handleKeyDown, handleClick] = useRovingTabIndex(itemRef, disabled);
|
|
10
10
|
const isIconRight = iconPosition === 'right';
|
|
11
11
|
useFocusEffect(focused, itemRef);
|
|
12
|
-
const triggerClick = useCallback(() => {
|
|
12
|
+
const triggerClick = useCallback((e) => {
|
|
13
13
|
if (onClick) {
|
|
14
14
|
handleClick();
|
|
15
|
-
onClick();
|
|
15
|
+
onClick(e);
|
|
16
16
|
}
|
|
17
17
|
}, [handleClick, onClick]);
|
|
18
18
|
const InnerContent = useMemo(() => (_jsxs(Stack, { direction: isIconRight ? 'row-reverse' : 'row', as: "span", className: ItemContent, horizontalAlign: isIconRight ? 'space-between' : 'start', verticalAlign: "center", columnGap: 8, horizontalPadding: 16, verticalPadding: 8, "data-menu-item-icon-right": isIconRight, "data-menu-item-has-icon": Boolean(icon), "data-menu-item-padding": padding, style: { inlineSize: '100%' }, children: [icon && (_jsx(Icon, { className: IconClass, name: icon, dimension: dimension === 'small' ? 14 : 16 }, void 0)), _jsxs(Stack, { columnGap: 16, fill: false, direction: "row", horizontalAlign: "space-between", children: [children, decoration] }, void 0)] }, void 0)), [children, dimension, icon, isIconRight, decoration, padding]);
|
package/menu/menu.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ReactNode, HTMLAttributes, ForwardRefExoticComponent } from 'react';
|
|
2
|
-
import { MenuItemProps } from './menu-item/menu-item';
|
|
3
|
-
import { MenuItemCheckboxProps } from './menu-item/menu-item-checkbox';
|
|
2
|
+
import { MenuItem, MenuItemProps } from './menu-item/menu-item';
|
|
3
|
+
import { MenuItemCheckbox, MenuItemCheckboxProps } from './menu-item/menu-item-checkbox';
|
|
4
|
+
import { Polymorphic } from '..';
|
|
4
5
|
export declare type MenuProps = HTMLAttributes<HTMLUListElement> & {
|
|
5
6
|
/**
|
|
6
7
|
* The items of the dropdown menu.
|
|
@@ -8,8 +9,8 @@ export declare type MenuProps = HTMLAttributes<HTMLUListElement> & {
|
|
|
8
9
|
children: ReactNode;
|
|
9
10
|
};
|
|
10
11
|
declare type MenuComponent = ForwardRefExoticComponent<MenuProps> & {
|
|
11
|
-
Item:
|
|
12
|
-
ItemCheckbox:
|
|
12
|
+
Item: Polymorphic.ForwardRefComponent<Polymorphic.IntrinsicElement<typeof MenuItem>, Polymorphic.OwnProps<typeof MenuItem> & MenuItemProps>;
|
|
13
|
+
ItemCheckbox: Polymorphic.ForwardRefComponent<Polymorphic.IntrinsicElement<typeof MenuItemCheckbox>, Polymorphic.OwnProps<typeof MenuItemCheckbox> & MenuItemCheckboxProps>;
|
|
13
14
|
};
|
|
14
15
|
export declare const Menu: MenuComponent;
|
|
15
16
|
export {};
|
package/menu/menu.js
CHANGED
|
@@ -3,12 +3,12 @@ import { Children, forwardRef } from 'react';
|
|
|
3
3
|
import { RovingTabIndexProvider } from 'react-roving-tabindex';
|
|
4
4
|
import { MenuItem } from './menu-item/menu-item';
|
|
5
5
|
import { MenuItemCheckbox } from './menu-item/menu-item-checkbox';
|
|
6
|
-
import { Stack, Elevator
|
|
6
|
+
import { Stack, Elevator } from '..';
|
|
7
7
|
import { Menu as MenuClass } from './menu.module.css';
|
|
8
8
|
import clsx from 'clsx';
|
|
9
9
|
export const Menu = forwardRef(({ className, children, ...otherProps }, forwardedRef) => {
|
|
10
10
|
const renderedChildren = Children.toArray(children).filter(Boolean);
|
|
11
|
-
return (_jsx(Elevator, { resting: 2, children: _jsx(
|
|
11
|
+
return (_jsx(Elevator, { resting: 2, children: _jsx(Stack, { as: "ul", ref: forwardedRef, className: clsx(MenuClass, className), role: "menu", ...otherProps, children: _jsx(RovingTabIndexProvider, { options: { direction: 'vertical', loopAround: true }, children: Children.map(renderedChildren, (child) => (_jsx(Stack, { as: "li", role: "none", verticalPadding: child.type?.displayName === 'Separator' ? 8 : undefined, children: child }, void 0))) }, void 0) }, void 0) }, void 0));
|
|
12
12
|
});
|
|
13
13
|
Menu.displayName = 'Menu';
|
|
14
14
|
Menu.Item = MenuItem;
|
package/menu/menu.module.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.Menu{list-style-type:none;overflow:hidden;padding:.44rem 0;position:relative}.Menu hr{margin:0 .44rem}
|
|
1
|
+
.Menu{background-color:var(--global-background);border:1px solid var(--dimmed-1);border-radius:.44rem;list-style-type:none;overflow:hidden;padding:.44rem 0;position:relative}.Menu hr{margin:0 .44rem}
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@ export declare type PrimitiveInputType = HTMLInputElement | HTMLTextAreaElement;
|
|
|
7
7
|
/**
|
|
8
8
|
* @internal
|
|
9
9
|
*/
|
|
10
|
-
export declare type BaseFieldProps = InputHTMLAttributes<
|
|
10
|
+
export declare type BaseFieldProps = InputHTMLAttributes<PrimitiveInputType> & {
|
|
11
11
|
invalid?: boolean;
|
|
12
12
|
};
|
|
13
13
|
/**
|
package/textfield/textfield.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { BaseFieldProps, PrimitiveInputType } from './base-field';
|
|
1
2
|
import { ChangeEvent } from 'react';
|
|
2
3
|
import { IconNames } from '../icons/types';
|
|
3
|
-
import { BaseFieldProps, PrimitiveInputType } from './base-field';
|
|
4
4
|
export declare type TextfieldProps = BaseFieldProps & {
|
|
5
5
|
/**
|
|
6
6
|
* Set the icon to show on the left or right side of the input.
|
|
@@ -47,7 +47,7 @@ export declare type TextfieldProps = BaseFieldProps & {
|
|
|
47
47
|
*/
|
|
48
48
|
onChange?: (event: ChangeEvent<PrimitiveInputType>) => void;
|
|
49
49
|
};
|
|
50
|
-
export declare const Textfield: import("react").ForwardRefExoticComponent<import("react").InputHTMLAttributes<
|
|
50
|
+
export declare const Textfield: import("react").ForwardRefExoticComponent<import("react").InputHTMLAttributes<PrimitiveInputType> & {
|
|
51
51
|
invalid?: boolean | undefined;
|
|
52
52
|
} & {
|
|
53
53
|
/**
|
package/textfield/textfield.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useCallback, useState } from 'react';
|
|
3
|
-
import { Text, Stack, Icon, IconButton } from '../';
|
|
4
2
|
import { BaseField } from './base-field';
|
|
3
|
+
import { forwardRef, useCallback, useState, useMemo } from 'react';
|
|
4
|
+
import { FieldContainer, IconButton as IconButtonClass, Icon as IconClass, InputField, Textfield as TextfieldClass } from './textfield.module.css';
|
|
5
|
+
import { Icon, IconButton, Stack, Text } from '../';
|
|
5
6
|
import clsx from 'clsx';
|
|
6
7
|
import { useUIDSeed } from 'react-uid';
|
|
7
|
-
|
|
8
|
-
export const Textfield = forwardRef(({ children, className, disabled = false, icon, label, textarea, readOnly, invalid, iconPosition = 'right', dimension = 'regular', type, style, onChange, ...otherProps }, forwardedRef) => {
|
|
8
|
+
export const Textfield = forwardRef(({ children, className, disabled = false, icon, label, textarea, readOnly, invalid, id, iconPosition = 'right', dimension = 'regular', type, style, onChange, ...otherProps }, forwardedRef) => {
|
|
9
9
|
const [passwordVisible, setPasswordVisible] = useState(false);
|
|
10
10
|
const seedID = useUIDSeed();
|
|
11
11
|
const isPassword = type === 'password';
|
|
12
|
+
const fieldID = useMemo(() => id || seedID('field'), [id, seedID]);
|
|
12
13
|
const handlePasswordVisibility = useCallback(() => {
|
|
13
14
|
setPasswordVisible(visibility => !visibility);
|
|
14
15
|
}, []);
|
|
@@ -28,8 +29,8 @@ export const Textfield = forwardRef(({ children, className, disabled = false, ic
|
|
|
28
29
|
disabled,
|
|
29
30
|
onChange
|
|
30
31
|
};
|
|
31
|
-
return (_jsxs(Stack, { as: "fieldset", rowGap: 4, className: clsx(TextfieldClass, className), "data-textfield-has-icon": isPassword || Boolean(icon), "data-textfield-icon-position": iconPosition, "data-textfield-dimension": dimension, "data-textfield-invalid": invalid, "aria-disabled": disabled, horizontalAlign: "stretch", verticalAlign: "start", tabIndex: disabled ? 0 : undefined, style: style, children: [label && _jsx(Text, { as: "label", size: dimension === 'small' ? 14 : 16, htmlFor:
|
|
32
|
-
? (_jsx(BaseField, { ref: forwardedRef, as: "textarea", id:
|
|
33
|
-
: (_jsx(BaseField, { className: InputField, id:
|
|
32
|
+
return (_jsxs(Stack, { as: "fieldset", rowGap: 4, className: clsx(TextfieldClass, className), "data-textfield-has-icon": isPassword || Boolean(icon), "data-textfield-icon-position": iconPosition, "data-textfield-dimension": dimension, "data-textfield-invalid": invalid, "aria-disabled": disabled, horizontalAlign: "stretch", verticalAlign: "start", tabIndex: disabled ? 0 : undefined, style: style, children: [label && _jsx(Text, { as: "label", size: dimension === 'small' ? 14 : 16, htmlFor: fieldID, children: label }, void 0), _jsxs("div", { className: FieldContainer, children: [textarea
|
|
33
|
+
? (_jsx(BaseField, { ref: forwardedRef, as: "textarea", id: fieldID, ...commonProps, ...otherProps }, void 0))
|
|
34
|
+
: (_jsx(BaseField, { className: InputField, id: fieldID, ref: forwardedRef, type: passwordVisible ? 'text' : type, ...commonProps, ...otherProps }, void 0)), isPassword && (_jsx(IconButton, { className: IconButtonClass, dimension: actionSizes[dimension], onClick: handlePasswordVisibility, kind: "flat", "aria-label": "Reveal password", icon: passwordVisible ? 'eye-slash' : 'eye' }, void 0)), !textarea && icon && !isPassword && (_jsx(Icon, { className: IconClass, name: icon, dimension: iconSizes[dimension] }, void 0))] }, void 0)] }, void 0));
|
|
34
35
|
});
|
|
35
36
|
Textfield.displayName = 'Textfield';
|
package/themes/dark.css
CHANGED
package/themes/light.css
CHANGED
package/title/title.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef } from 'react';
|
|
3
2
|
import * as styles from './title.module.css';
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
export const Title = forwardRef(({ children, className, as: Wrapper = 'span', lineHeight = 'small', level = '1', textAlign = 'start', maxWidth, responsive = true, style, ...otherProps }, forwardedRef) => {
|
|
6
6
|
const computedLevel = level.match(/\d/g) ? `H${level}` : level.charAt(0).toUpperCase() + level.slice(1);
|
package/tooltip/tooltip.js
CHANGED
|
@@ -36,6 +36,7 @@ export const Tooltip = ({ children, trigger, placement = 'bottom-start', open, s
|
|
|
36
36
|
};
|
|
37
37
|
return (_jsxs("div", { "data-tooltip-fill": fill, className: TooltipClass, ref: tooltipContainerRef, "data-tooltip-has-focus-within": isFocusWithin, style: { ...style }, children: [Children.map(trigger, (child) => cloneElement(child, {
|
|
38
38
|
ref: setTriggerRef,
|
|
39
|
+
tabIndex: 0,
|
|
39
40
|
'aria-describedby': seedID('tooltip-content')
|
|
40
|
-
})), visible && (_jsx(Elevator, { resting:
|
|
41
|
+
})), visible && (_jsx(Elevator, { resting: 1, children: _jsxs("div", { ref: setTooltipRef, role: "tooltip", id: seedID('tooltip-content'), "data-theme": "dark", ...getTooltipProps({ className: Balloon, style: dynamycStyle }), children: [children, _jsx("div", { ...getArrowProps({ className: Arrow }) }, void 0)] }, void 0) }, void 0))] }, void 0));
|
|
41
42
|
};
|