@wonderflow/react-components 3.0.0-beta.15 → 3.0.0-beta.19
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/core/typography.css +1 -1
- package/core.css +1 -1
- package/dropdown/dropdown.d.ts +25 -11
- package/dropdown/dropdown.js +19 -20
- package/dropdown/dropdown.module.css +1 -1
- package/dropdown/index.d.ts +0 -2
- package/index.d.ts +3 -1
- package/index.js +1 -0
- package/menu/index.d.ts +6 -0
- package/menu/index.js +3 -0
- package/menu/menu-item/menu-item-checkbox.d.ts +11 -0
- package/menu/menu-item/menu-item-checkbox.js +5 -0
- package/{dropdown/item/dropdown-item.d.ts → menu/menu-item/menu-item.d.ts} +8 -8
- package/menu/menu-item/menu-item.js +23 -0
- package/menu/menu-item/menu-item.module.css +1 -0
- package/menu/menu.d.ts +15 -0
- package/menu/menu.js +17 -0
- package/menu/menu.module.css +1 -0
- package/package.json +7 -7
- package/textfield/textfield.js +2 -2
- package/themes/dark.css +1 -1
- package/themes/light.css +1 -1
- package/title/title.module.css +1 -1
- package/tooltip/tooltip.d.ts +1 -1
- package/tooltip/tooltip.js +10 -10
- package/tooltip/tooltip.module.css +1 -1
- package/dropdown/item/dropdown-item.js +0 -23
- package/dropdown/item/dropdown-item.module.css +0 -1
- package/dropdown/item-checkbox/dropdown-item-checkbox.d.ts +0 -11
- package/dropdown/item-checkbox/dropdown-item-checkbox.js +0 -5
- package/dropdown/menu/dropdown-menu.d.ts +0 -13
- package/dropdown/menu/dropdown-menu.js +0 -13
- package/dropdown/menu/dropdown-menu.module.css +0 -1
package/core/typography.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
:where(p){font-size:.89rem;line-height:1.5;min-block-size:.01vh}small{font-size:.7em}b,strong{font-weight:600}:where(a:any-link){background-image:linear-gradient(currentColor,currentColor);background-position:0 100%;background-repeat:no-repeat;background-size:0 1px;color:var(--global-interactive-text);text-decoration:none;transition:background-size .2s cubic-bezier(0,0,.34,1);word-break:break-word}:where(a:any-link):focus,:where(a:any-link):hover{background-size:100% 1px}del{background-color:var(--highlight-red-background);box-shadow:0 0 0 2px var(--highlight-red-background);color:var(--highlight-red-foreground)}del,ins{border-radius:.22rem;padding:2px 4px}ins{background-color:var(--highlight-green-background);box-shadow:0 0 0 2px var(--highlight-green-background);color:var(--highlight-green-foreground);text-decoration:none}address{font-style:normal;line-height:inherit}dt{font-weight:600}dd{margin:0;padding:0}ol,ul{padding-left:1rem}ul li::marker{font-size:inherit;font-weight:600;min-inline-size:1.78rem;text-align:right}ol li::marker{font-feature-settings:"tnum";font-size:inherit;font-variant-numeric:tabular-nums;font-weight:600;min-inline-size:1.78rem;white-space:nowrap}kbd{border:1px solid var(--dimmed-1);border-radius:.22rem;box-shadow:0 2px 0 var(--dimmed-1);font-weight:600;padding:2px 4px}mark{background:var(--highlight-yellow-background);color:var(--highlight-yellow-foreground);padding:0 2px}abbr{text-decoration:underline dashed var(--cta-default)}label,legend{font-size:inherit}code{
|
|
1
|
+
:where(p){font-size:.89rem;line-height:1.5;min-block-size:.01vh}small{font-size:.7em}b,strong{font-weight:600}:where(a:any-link){background-image:linear-gradient(currentColor,currentColor);background-position:0 100%;background-repeat:no-repeat;background-size:0 1px;color:var(--global-interactive-text);text-decoration:none;transition:background-size .2s cubic-bezier(0,0,.34,1);word-break:break-word}:where(a:any-link):focus,:where(a:any-link):hover{background-size:100% 1px}del{background-color:var(--highlight-red-background);box-shadow:0 0 0 2px var(--highlight-red-background);color:var(--highlight-red-foreground)}del,ins{border-radius:.22rem;padding:2px 4px}ins{background-color:var(--highlight-green-background);box-shadow:0 0 0 2px var(--highlight-green-background);color:var(--highlight-green-foreground);text-decoration:none}address{font-style:normal;line-height:inherit}dt{font-weight:600}dd{margin:0;padding:0}ol,ul{padding-left:1rem}ul li::marker{font-size:inherit;font-weight:600;min-inline-size:1.78rem;text-align:right}ol li::marker{font-feature-settings:"tnum";font-size:inherit;font-variant-numeric:tabular-nums;font-weight:600;min-inline-size:1.78rem;white-space:nowrap}kbd{border:1px solid var(--dimmed-1);border-radius:.22rem;box-shadow:0 2px 0 var(--dimmed-1);font-weight:600;padding:2px 4px}mark{background:var(--highlight-yellow-background);color:var(--highlight-yellow-foreground);padding:0 2px}abbr{text-decoration:underline dashed var(--cta-default)}label,legend{font-size:inherit}code{background-color:var(--highlight-gray-background);border-radius:.22rem;font-family:monospace;font-size:1em;padding:0 4px 3px;vertical-align:top}
|
package/core.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
html{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;background-color:var(--global-background);box-sizing:border-box;font-size:112.5%;line-height:1.5}*,:after,:before{-webkit-tap-highlight-color:hsla(0,100%,47%,.2);box-sizing:inherit;margin:0}.focus-visible{outline:5px auto Highlight;outline:5px auto -webkit-focus-ring-color}:focus-visible{outline:5px auto Highlight;outline:5px auto -webkit-focus-ring-color}body{font-feature-settings:"calt" off;color:var(--global-foreground);font-family:system-ui,sans-serif;margin:0;scroll-padding:4.44rem}::selection{background-color:var(--dimmed-7);color:var(--dimmed-0);text-shadow:none}img{display:block;inline-size:100%;max-inline-size:100%}svg:not([fill]){fill:currentColor}fieldset{border:0}[data-elevation]{--shadow-color:0deg 0% 0%}[data-elevation-hover="0"]:hover,[data-elevation="0"]{box-shadow:none;transition:box-shadow .1s cubic-bezier(.3,.07,.34,1)}[data-elevation-hover="1"]:hover,[data-elevation="1"]{box-shadow:0 3px 13px hsl(var(--shadow-color)/6%),0 2.5px 4.59px hsl(var(--shadow-color)/4.06%),0 1.34px 2.45px hsl(var(--shadow-color)/2.35%),0 .75px 1.37px hsl(var(--shadow-color)/4%),0 .39px .73px hsl(var(--shadow-color)/1.65%),0 .16px .3px hsl(var(--shadow-color)/.94%);transition:box-shadow .1s cubic-bezier(.3,.07,.34,1)}[data-elevation-hover="2"]:hover,[data-elevation="2"]{box-shadow:0 9px 25px hsl(var(--shadow-color)/8%),0 3.75px 10.44px hsl(var(--shadow-color)/6.35%),0 2.01px 5.58px hsl(var(--shadow-color)/4.75%),0 1.12px 3.13px hsl(var(--shadow-color)/4.5%),0 .6px 1.66px hsl(var(--shadow-color)/4.25%),0 .25px .69px hsl(var(--shadow-color)/3.65%);transition:box-shadow .1s cubic-bezier(.3,.07,.34,1)}[data-elevation-hover="3"]:hover,[data-elevation="3"]{box-shadow:0 18px 40px hsl(var(--shadow-color)/9%),0 7.51px 16.71px hsl(var(--shadow-color)/5.63%),0 4.02px 8.93px hsl(var(--shadow-color)/4.15%),0 2.25px 5px hsl(var(--shadow-color)/4%),0 1.19px 2.66px hsl(var(--shadow-color)/3.85%),0 .49px 1.1px hsl(var(--shadow-color)/3.37%);transition:box-shadow .1s cubic-bezier(.3,.07,.34,1)}[data-elevation-hover="4"]:hover,[data-elevation="4"]{box-shadow:0 33px 78px hsl(var(--shadow-color)/11%),0 12.04px 28.47px hsl(var(--shadow-color)/7.59%),0 5.84px 13.82px hsl(var(--shadow-color)/6.12%),0 2.86px 6.77px hsl(var(--shadow-color)/4.88%),0 1.13px 2.67px hsl(var(--shadow-color)/5.41%);transition:box-shadow .1s cubic-bezier(.3,.07,.34,1)}:where(p){font-size:.89rem;line-height:1.5;min-block-size:.01vh}small{font-size:.7em}b,strong{font-weight:600}:where(a:any-link){background-image:linear-gradient(currentColor,currentColor);background-position:0 100%;background-repeat:no-repeat;background-size:0 1px;color:var(--global-interactive-text);text-decoration:none;transition:background-size .2s cubic-bezier(0,0,.34,1);word-break:break-word}:where(a:any-link):focus,:where(a:any-link):hover{background-size:100% 1px}del{background-color:var(--highlight-red-background);box-shadow:0 0 0 2px var(--highlight-red-background);color:var(--highlight-red-foreground)}del,ins{border-radius:.22rem;padding:2px 4px}ins{background-color:var(--highlight-green-background);box-shadow:0 0 0 2px var(--highlight-green-background);color:var(--highlight-green-foreground);text-decoration:none}address{font-style:normal;line-height:inherit}dt{font-weight:600}dd{margin:0;padding:0}ol,ul{padding-left:1rem}ul li::marker{font-size:inherit;font-weight:600;min-inline-size:1.78rem;text-align:right}ol li::marker{font-feature-settings:"tnum";font-size:inherit;font-variant-numeric:tabular-nums;font-weight:600;min-inline-size:1.78rem;white-space:nowrap}kbd{border:1px solid var(--dimmed-1);border-radius:.22rem;box-shadow:0 2px 0 var(--dimmed-1);font-weight:600;padding:2px 4px}mark{background:var(--highlight-yellow-background);color:var(--highlight-yellow-foreground);padding:0 2px}abbr{text-decoration:underline dashed var(--cta-default)}label,legend{font-size:inherit}code{
|
|
1
|
+
html{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;background-color:var(--global-background);box-sizing:border-box;font-size:112.5%;line-height:1.5}*,:after,:before{-webkit-tap-highlight-color:hsla(0,100%,47%,.2);box-sizing:inherit;margin:0}.focus-visible{outline:5px auto Highlight;outline:5px auto -webkit-focus-ring-color}:focus-visible{outline:5px auto Highlight;outline:5px auto -webkit-focus-ring-color}body{font-feature-settings:"calt" off;color:var(--global-foreground);font-family:system-ui,sans-serif;margin:0;scroll-padding:4.44rem}::selection{background-color:var(--dimmed-7);color:var(--dimmed-0);text-shadow:none}img{display:block;inline-size:100%;max-inline-size:100%}svg:not([fill]){fill:currentColor}fieldset{border:0}[data-elevation]{--shadow-color:0deg 0% 0%}[data-elevation-hover="0"]:hover,[data-elevation="0"]{box-shadow:none;transition:box-shadow .1s cubic-bezier(.3,.07,.34,1)}[data-elevation-hover="1"]:hover,[data-elevation="1"]{box-shadow:0 3px 13px hsl(var(--shadow-color)/6%),0 2.5px 4.59px hsl(var(--shadow-color)/4.06%),0 1.34px 2.45px hsl(var(--shadow-color)/2.35%),0 .75px 1.37px hsl(var(--shadow-color)/4%),0 .39px .73px hsl(var(--shadow-color)/1.65%),0 .16px .3px hsl(var(--shadow-color)/.94%);transition:box-shadow .1s cubic-bezier(.3,.07,.34,1)}[data-elevation-hover="2"]:hover,[data-elevation="2"]{box-shadow:0 9px 25px hsl(var(--shadow-color)/8%),0 3.75px 10.44px hsl(var(--shadow-color)/6.35%),0 2.01px 5.58px hsl(var(--shadow-color)/4.75%),0 1.12px 3.13px hsl(var(--shadow-color)/4.5%),0 .6px 1.66px hsl(var(--shadow-color)/4.25%),0 .25px .69px hsl(var(--shadow-color)/3.65%);transition:box-shadow .1s cubic-bezier(.3,.07,.34,1)}[data-elevation-hover="3"]:hover,[data-elevation="3"]{box-shadow:0 18px 40px hsl(var(--shadow-color)/9%),0 7.51px 16.71px hsl(var(--shadow-color)/5.63%),0 4.02px 8.93px hsl(var(--shadow-color)/4.15%),0 2.25px 5px hsl(var(--shadow-color)/4%),0 1.19px 2.66px hsl(var(--shadow-color)/3.85%),0 .49px 1.1px hsl(var(--shadow-color)/3.37%);transition:box-shadow .1s cubic-bezier(.3,.07,.34,1)}[data-elevation-hover="4"]:hover,[data-elevation="4"]{box-shadow:0 33px 78px hsl(var(--shadow-color)/11%),0 12.04px 28.47px hsl(var(--shadow-color)/7.59%),0 5.84px 13.82px hsl(var(--shadow-color)/6.12%),0 2.86px 6.77px hsl(var(--shadow-color)/4.88%),0 1.13px 2.67px hsl(var(--shadow-color)/5.41%);transition:box-shadow .1s cubic-bezier(.3,.07,.34,1)}:where(p){font-size:.89rem;line-height:1.5;min-block-size:.01vh}small{font-size:.7em}b,strong{font-weight:600}:where(a:any-link){background-image:linear-gradient(currentColor,currentColor);background-position:0 100%;background-repeat:no-repeat;background-size:0 1px;color:var(--global-interactive-text);text-decoration:none;transition:background-size .2s cubic-bezier(0,0,.34,1);word-break:break-word}:where(a:any-link):focus,:where(a:any-link):hover{background-size:100% 1px}del{background-color:var(--highlight-red-background);box-shadow:0 0 0 2px var(--highlight-red-background);color:var(--highlight-red-foreground)}del,ins{border-radius:.22rem;padding:2px 4px}ins{background-color:var(--highlight-green-background);box-shadow:0 0 0 2px var(--highlight-green-background);color:var(--highlight-green-foreground);text-decoration:none}address{font-style:normal;line-height:inherit}dt{font-weight:600}dd{margin:0;padding:0}ol,ul{padding-left:1rem}ul li::marker{font-size:inherit;font-weight:600;min-inline-size:1.78rem;text-align:right}ol li::marker{font-feature-settings:"tnum";font-size:inherit;font-variant-numeric:tabular-nums;font-weight:600;min-inline-size:1.78rem;white-space:nowrap}kbd{border:1px solid var(--dimmed-1);border-radius:.22rem;box-shadow:0 2px 0 var(--dimmed-1);font-weight:600;padding:2px 4px}mark{background:var(--highlight-yellow-background);color:var(--highlight-yellow-foreground);padding:0 2px}abbr{text-decoration:underline dashed var(--cta-default)}label,legend{font-size:inherit}code{background-color:var(--highlight-gray-background);border-radius:.22rem;font-family:monospace;font-size:1em;padding:0 4px 3px;vertical-align:top}
|
package/dropdown/dropdown.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { ReactNode
|
|
2
|
-
import { DropdownMenuProps } from './menu/dropdown-menu';
|
|
3
|
-
import { DropdownItemProps } from './item/dropdown-item';
|
|
4
|
-
import { DropdownItemCheckboxProps } from './item-checkbox/dropdown-item-checkbox';
|
|
1
|
+
import { ReactNode } from 'react';
|
|
5
2
|
import { AutoPlacement, BasePlacement, VariationPlacement } from '@popperjs/core';
|
|
6
3
|
export declare type DropdownProps = PropsWithClass & {
|
|
7
4
|
/**
|
|
@@ -27,10 +24,27 @@ export declare type DropdownProps = PropsWithClass & {
|
|
|
27
24
|
*/
|
|
28
25
|
placement?: AutoPlacement | BasePlacement | VariationPlacement;
|
|
29
26
|
};
|
|
30
|
-
declare
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
27
|
+
export declare const Dropdown: import("react").ForwardRefExoticComponent<PropsWithClass & {
|
|
28
|
+
/**
|
|
29
|
+
* The content of the dropdown to display when the dropdown is open.
|
|
30
|
+
*/
|
|
31
|
+
children: ReactNode;
|
|
32
|
+
/**
|
|
33
|
+
* The element to use as the trigger for the dropdown.
|
|
34
|
+
*/
|
|
35
|
+
trigger: ReactNode;
|
|
36
|
+
/**
|
|
37
|
+
* The distance from the trigger to the dropdown.
|
|
38
|
+
*/
|
|
39
|
+
offset?: number | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* The placement of the dropdown. This is automatically handled based on
|
|
42
|
+
* scroll and viewport edges. By default the dropdown is anchored at
|
|
43
|
+
* the beginning of the trigger.
|
|
44
|
+
*
|
|
45
|
+
* The first key refers to the X axis, the second key refers to the Y axis.
|
|
46
|
+
* Eg: `auto-start` means the dropdown will be placed automatically on left or right
|
|
47
|
+
* based on the available space, and anchored at the top (start) of the trigger.
|
|
48
|
+
*/
|
|
49
|
+
placement?: AutoPlacement | BasePlacement | VariationPlacement | undefined;
|
|
50
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
package/dropdown/dropdown.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import clsx from 'clsx';
|
|
3
2
|
import { useState, Children, cloneElement, useRef, forwardRef } from 'react';
|
|
4
|
-
import { useKeyPress,
|
|
3
|
+
import { useKeyPress, useFocusWithin } from 'ahooks';
|
|
5
4
|
import { Dropdown as DropdownClass, PopUp } from './dropdown.module.css';
|
|
6
5
|
import { useUIDSeed } from 'react-uid';
|
|
7
|
-
import { DropdownMenu } from './menu/dropdown-menu';
|
|
8
|
-
import { DropdownItem } from './item/dropdown-item';
|
|
9
|
-
import { DropdownItemCheckbox } from './item-checkbox/dropdown-item-checkbox';
|
|
10
6
|
import { usePopperTooltip } from 'react-popper-tooltip';
|
|
11
7
|
import { AnimatePresence, motion } from 'framer-motion';
|
|
8
|
+
import clsx from 'clsx';
|
|
12
9
|
const DropdownAnimation = {
|
|
13
10
|
visible: {
|
|
14
11
|
y: 0,
|
|
@@ -27,39 +24,41 @@ const DropdownAnimation = {
|
|
|
27
24
|
}
|
|
28
25
|
}
|
|
29
26
|
};
|
|
30
|
-
export const Dropdown = forwardRef(({
|
|
27
|
+
export const Dropdown = forwardRef(({ children, trigger, offset = 8, placement = 'auto-start', className }, forwardedRef) => {
|
|
31
28
|
const renderedChildren = Children.toArray(children).filter(Boolean);
|
|
32
29
|
const seedID = useUIDSeed();
|
|
33
|
-
const
|
|
30
|
+
const dropdownRef = useRef(forwardedRef);
|
|
34
31
|
const [isOpen, setIsOpen] = useState(false);
|
|
35
32
|
const { getTooltipProps, setTooltipRef, setTriggerRef, visible } = usePopperTooltip({
|
|
36
33
|
delayShow: 0,
|
|
37
|
-
delayHide:
|
|
34
|
+
delayHide: 0,
|
|
38
35
|
trigger: ['click'],
|
|
39
36
|
visible: isOpen,
|
|
40
37
|
closeOnTriggerHidden: true,
|
|
41
38
|
onVisibleChange: setIsOpen,
|
|
42
39
|
placement: placement,
|
|
43
40
|
offset: [0, offset],
|
|
44
|
-
closeOnOutsideClick:
|
|
41
|
+
closeOnOutsideClick: true
|
|
42
|
+
});
|
|
43
|
+
const isFocusWithin = useFocusWithin(dropdownRef, {
|
|
44
|
+
onBlur: (e) => {
|
|
45
|
+
if (e.relatedTarget && visible) {
|
|
46
|
+
setIsOpen(false);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
45
49
|
});
|
|
46
|
-
const isFocusWithin = useFocusWithin(popupRef);
|
|
47
|
-
useClickAway(() => {
|
|
48
|
-
setIsOpen(false);
|
|
49
|
-
}, popupRef);
|
|
50
50
|
useKeyPress('esc', () => setIsOpen(false));
|
|
51
|
-
return (_jsxs("div", { ref:
|
|
51
|
+
return (_jsxs("div", { ref: dropdownRef, className: clsx(DropdownClass, className), "data-dropdown-has-focus": isFocusWithin, children: [Children.map(trigger, (child) => cloneElement(child, {
|
|
52
52
|
ref: setTriggerRef,
|
|
53
53
|
id: seedID('dropdown-trigger'),
|
|
54
|
+
key: seedID('dropdown-trigger'),
|
|
54
55
|
'aria-haspopup': 'true',
|
|
55
56
|
'aria-controls': seedID('dropdown-menu'),
|
|
56
|
-
'aria-expanded': isOpen
|
|
57
|
-
|
|
57
|
+
'aria-expanded': isOpen,
|
|
58
|
+
'data-open': isOpen
|
|
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, {
|
|
58
60
|
id: seedID('dropdown-menu'),
|
|
59
61
|
'aria-labelledby': seedID('dropdown-trigger')
|
|
60
|
-
})) }, void 0) },
|
|
62
|
+
})) }, void 0) }, seedID('tooltip-content'))) }, void 0)] }, void 0));
|
|
61
63
|
});
|
|
62
64
|
Dropdown.displayName = 'Dropdown';
|
|
63
|
-
Dropdown.Menu = DropdownMenu;
|
|
64
|
-
Dropdown.Item = DropdownItem;
|
|
65
|
-
Dropdown.ItemCheckbox = DropdownItemCheckbox;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.Dropdown{display:
|
|
1
|
+
.Dropdown{display:contents}.PopUp{inline-size:max-content;z-index:2}
|
package/dropdown/index.d.ts
CHANGED
package/index.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export type { TableProps } from './table';
|
|
|
25
25
|
export { Disclosure } from './disclosure';
|
|
26
26
|
export type { DisclosureProps } from './disclosure';
|
|
27
27
|
export { Dropdown } from './dropdown';
|
|
28
|
-
export type { DropdownProps
|
|
28
|
+
export type { DropdownProps } from './dropdown';
|
|
29
29
|
export { Elevator } from './elevator';
|
|
30
30
|
export type { ElevatorProps } from './elevator';
|
|
31
31
|
export { Icon } from './icon';
|
|
@@ -44,6 +44,8 @@ export { Modal } from './modal';
|
|
|
44
44
|
export type { ModalProps } from './modal';
|
|
45
45
|
export { LinearProgress } from './linear-progress';
|
|
46
46
|
export type { LinearProgressProps } from './linear-progress';
|
|
47
|
+
export { Menu } from './menu';
|
|
48
|
+
export type { MenuProps, MenuItemProps, MenuItemCheckboxProps } from './menu';
|
|
47
49
|
export { OverlayContainer, useOverlayContext, OverlayProvider } from './overlay-container';
|
|
48
50
|
export type { OverlayContainerProps } from './overlay-container';
|
|
49
51
|
export { Prose } from './prose';
|
package/index.js
CHANGED
|
@@ -22,6 +22,7 @@ export { List } from './list';
|
|
|
22
22
|
export { SplitButton } from './split-button';
|
|
23
23
|
export { Modal } from './modal';
|
|
24
24
|
export { LinearProgress } from './linear-progress';
|
|
25
|
+
export { Menu } from './menu';
|
|
25
26
|
export { OverlayContainer, useOverlayContext, OverlayProvider } from './overlay-container';
|
|
26
27
|
export { Prose } from './prose';
|
|
27
28
|
export { Pagination } from './pagination';
|
package/menu/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { Menu } from './menu';
|
|
2
|
+
export type { MenuProps } from './menu';
|
|
3
|
+
export { MenuItem } from './menu-item/menu-item';
|
|
4
|
+
export type { MenuItemProps } from './menu-item/menu-item';
|
|
5
|
+
export { MenuItemCheckbox } from './menu-item/menu-item-checkbox';
|
|
6
|
+
export type { MenuItemCheckboxProps } from './menu-item/menu-item-checkbox';
|
package/menu/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MenuItem, MenuItemProps } from '..';
|
|
2
|
+
import { Polymorphic } from '../..';
|
|
3
|
+
export declare type MenuItemCheckboxProps = MenuItemProps & {
|
|
4
|
+
/**
|
|
5
|
+
* Set the default checked state of the checkbox item
|
|
6
|
+
*/
|
|
7
|
+
checked?: boolean;
|
|
8
|
+
};
|
|
9
|
+
declare type MenuItemCheckboxComponent = Polymorphic.ForwardRefComponent<Polymorphic.IntrinsicElement<typeof MenuItem>, Polymorphic.OwnProps<typeof MenuItem> & MenuItemCheckboxProps>;
|
|
10
|
+
export declare const MenuItemCheckbox: MenuItemCheckboxComponent;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { MenuItem } from '..';
|
|
4
|
+
export const MenuItemCheckbox = forwardRef(({ children, checked, ...otherProps }, forwardedRef) => (_jsx(MenuItem, { role: "menuitemcheckbox", "aria-checked": checked, ref: forwardedRef, ...otherProps, children: children }, void 0)));
|
|
5
|
+
MenuItemCheckbox.displayName = 'Menu.ItemCheckbox';
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { IconNames } from '../../icons/types';
|
|
3
3
|
import { Polymorphic } from '../..';
|
|
4
|
-
export declare type
|
|
4
|
+
export declare type MenuItemProps = {
|
|
5
5
|
/**
|
|
6
|
-
* Content to display in the
|
|
6
|
+
* Content to display in the menu item.
|
|
7
7
|
*/
|
|
8
8
|
children: ReactNode;
|
|
9
9
|
/**
|
|
10
|
-
* Whether the
|
|
10
|
+
* Whether the menu item should have an icon
|
|
11
11
|
*/
|
|
12
12
|
icon?: IconNames;
|
|
13
13
|
/**
|
|
@@ -24,7 +24,7 @@ export declare type DropdownItemProps = {
|
|
|
24
24
|
*/
|
|
25
25
|
onClick?(): void;
|
|
26
26
|
/**
|
|
27
|
-
* Add an extra description to the
|
|
27
|
+
* Add an extra description to the menu item.
|
|
28
28
|
* This uses the `<Tooltip>` component internally.
|
|
29
29
|
*/
|
|
30
30
|
description?: ReactNode;
|
|
@@ -33,15 +33,15 @@ export declare type DropdownItemProps = {
|
|
|
33
33
|
*/
|
|
34
34
|
disabled?: boolean;
|
|
35
35
|
/**
|
|
36
|
-
* Add or remove the padding from the
|
|
36
|
+
* Add or remove the padding from the menu item.
|
|
37
37
|
* This space is used to keep the content aligned across items with or without icons.
|
|
38
38
|
* We suggest to not remove the padding if you have items with icons in the same menu to
|
|
39
39
|
* keep a good readability.
|
|
40
40
|
*
|
|
41
|
-
* Read more: https://design.wonderflow.ai/design/recipes/
|
|
41
|
+
* Read more: https://design.wonderflow.ai/design/recipes/menu/#items-with-icons
|
|
42
42
|
*/
|
|
43
43
|
padding?: boolean;
|
|
44
44
|
};
|
|
45
|
-
declare type
|
|
46
|
-
export declare const
|
|
45
|
+
declare type PolymorphicMenuItem = Polymorphic.ForwardRefComponent<'button', MenuItemProps>;
|
|
46
|
+
export declare const MenuItem: PolymorphicMenuItem;
|
|
47
47
|
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, forwardRef, useRef, useMemo } from 'react';
|
|
3
|
+
import { useRovingTabIndex, useFocusEffect } from 'react-roving-tabindex';
|
|
4
|
+
import { MenuItem as MenuItemClass, Icon as IconClass, ItemContent } from './menu-item.module.css';
|
|
5
|
+
import { Tooltip, Stack, Icon } from '../..';
|
|
6
|
+
import clsx from 'clsx';
|
|
7
|
+
export const MenuItem = forwardRef(({ className, children, onClick, icon, dimension = 'regular', as: Wrapper = 'button', iconPosition = 'left', description, padding = true, disabled = false, ...otherProps }, forwardedRef) => {
|
|
8
|
+
const itemRef = useRef(forwardedRef);
|
|
9
|
+
const [tabIndex, focused, handleKeyDown, handleClick] = useRovingTabIndex(itemRef, disabled);
|
|
10
|
+
const isIconRight = iconPosition === 'right';
|
|
11
|
+
useFocusEffect(focused, itemRef);
|
|
12
|
+
const triggerClick = useCallback(() => {
|
|
13
|
+
if (onClick) {
|
|
14
|
+
handleClick();
|
|
15
|
+
onClick();
|
|
16
|
+
}
|
|
17
|
+
}, [handleClick, onClick]);
|
|
18
|
+
const InnerContent = useMemo(() => (_jsxs(Stack, { direction: "row", as: "span", fill: false, className: ItemContent, horizontalAlign: isIconRight ? 'space-between' : 'start', verticalAlign: "start", 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)), children] }, void 0)), [children, dimension, icon, isIconRight, padding]);
|
|
19
|
+
return (_jsx(Wrapper, { ref: itemRef, role: "menuitem", className: clsx(MenuItemClass, className), onClick: disabled ? undefined : triggerClick, onKeyDown: disabled ? undefined : handleKeyDown, tabIndex: tabIndex, "aria-disabled": disabled, type: Wrapper === 'button' ? 'button' : undefined, "data-menu-item-dimension": dimension, ...otherProps, children: description
|
|
20
|
+
? (_jsx(Tooltip, { fill: true, open: focused, placement: "right-start", interactive: true, trigger: InnerContent, children: description }, void 0))
|
|
21
|
+
: InnerContent }, void 0));
|
|
22
|
+
});
|
|
23
|
+
MenuItem.displayName = 'Menu.Item';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.MenuItem{background:none;border:0;box-sizing:border-box;color:var(--dimmed-6);cursor:pointer;font:inherit;font-size:.89rem;font-weight:600;inline-size:100%;line-height:1.2;padding:0;position:relative;text-align:start}.MenuItem[aria-checked=true]{color:var(--global-interactive-text)}.MenuItem:before{border-radius:.22rem;bottom:0;content:"";left:.44rem;opacity:60%;position:absolute;right:.44rem;top:0;z-index:0}.MenuItem:is(:hover,.focus-visible,[aria-pressed=true]):not([aria-disabled=true]){outline:none}.MenuItem:is(:hover,:focus-visible,[aria-pressed=true]):not([aria-disabled=true]){outline:none}.MenuItem:is(:hover,.focus-visible,[aria-pressed=true]):not([aria-disabled=true]):before{background-color:var(--dimmed-1)}.MenuItem:is(:hover,:focus-visible,[aria-pressed=true]):not([aria-disabled=true]):before{background-color:var(--dimmed-1)}.MenuItem[data-menu-item-dimension=small]{font-size:.78rem}.MenuItem>*{position:relative}.MenuItem[aria-disabled=true]{color:var(--global-disabled-foreground);cursor:not-allowed}.MenuItem [data-menu-item-padding=true][data-menu-item-has-icon=false][data-menu-item-icon-right=false]{padding-left:2.22rem}.MenuItem [data-menu-item-padding=true][data-menu-item-has-icon=false][data-menu-item-icon-right=true]{padding-right:2.22rem}.ItemContent{position:relative}.Icon{flex-shrink:0;margin-top:1px}[data-menu-item-icon-right=true] .Icon{order:2}
|
package/menu/menu.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ReactNode, HTMLAttributes, ForwardRefExoticComponent } from 'react';
|
|
2
|
+
import { MenuItemProps } from './menu-item/menu-item';
|
|
3
|
+
import { MenuItemCheckboxProps } from './menu-item/menu-item-checkbox';
|
|
4
|
+
export declare type MenuProps = HTMLAttributes<HTMLUListElement> & {
|
|
5
|
+
/**
|
|
6
|
+
* The items of the dropdown menu.
|
|
7
|
+
*/
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
};
|
|
10
|
+
declare type MenuComponent = ForwardRefExoticComponent<MenuProps> & {
|
|
11
|
+
Item: ForwardRefExoticComponent<MenuItemProps>;
|
|
12
|
+
ItemCheckbox: ForwardRefExoticComponent<MenuItemCheckboxProps>;
|
|
13
|
+
};
|
|
14
|
+
export declare const Menu: MenuComponent;
|
|
15
|
+
export {};
|
package/menu/menu.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Children, cloneElement, forwardRef } from 'react';
|
|
3
|
+
import { RovingTabIndexProvider } from 'react-roving-tabindex';
|
|
4
|
+
import { MenuItem } from './menu-item/menu-item';
|
|
5
|
+
import { MenuItemCheckbox } from './menu-item/menu-item-checkbox';
|
|
6
|
+
import { Stack, Elevator } from '..';
|
|
7
|
+
import { Menu as MenuClass } from './menu.module.css';
|
|
8
|
+
import clsx from 'clsx';
|
|
9
|
+
export const Menu = forwardRef(({ className, children, ...otherProps }, forwardedRef) => {
|
|
10
|
+
const renderedChildren = Children.toArray(children).filter(Boolean);
|
|
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, index) => (_jsx(Stack, { as: "li", role: "none", verticalPadding: child.type?.displayName === 'Separator' ? 8 : undefined, children: cloneElement(child, {
|
|
12
|
+
autoFocus: index === 0 && true
|
|
13
|
+
}) }, void 0))) }, void 0) }, void 0) }, void 0));
|
|
14
|
+
});
|
|
15
|
+
Menu.displayName = 'Menu';
|
|
16
|
+
Menu.Item = MenuItem;
|
|
17
|
+
Menu.ItemCheckbox = MenuItemCheckbox;
|
|
@@ -0,0 +1 @@
|
|
|
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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wonderflow/react-components",
|
|
3
3
|
"description": "UI components from Wonderflow's Wanda design system",
|
|
4
|
-
"version": "3.0.0-beta.
|
|
4
|
+
"version": "3.0.0-beta.19",
|
|
5
5
|
"author": "Wonderflow",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "index.js",
|
|
@@ -65,9 +65,9 @@
|
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"@wonderflow/tokens": "1.3.7",
|
|
68
|
-
"ahooks": "3.1.
|
|
68
|
+
"ahooks": "3.1.3",
|
|
69
69
|
"clsx": "1.1.1",
|
|
70
|
-
"framer-motion": "
|
|
70
|
+
"framer-motion": "5.5.5",
|
|
71
71
|
"postcss": "^8.4.5",
|
|
72
72
|
"react": "^17.0",
|
|
73
73
|
"react-data-table-component": "7.4.6",
|
|
@@ -88,8 +88,8 @@
|
|
|
88
88
|
"react-dom": "^17.0"
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
|
-
"@babel/core": "7.16.
|
|
92
|
-
"@commitlint/cli": "16.0.
|
|
91
|
+
"@babel/core": "7.16.7",
|
|
92
|
+
"@commitlint/cli": "16.0.1",
|
|
93
93
|
"@commitlint/config-conventional": "16.0.0",
|
|
94
94
|
"@semantic-release/exec": "6.0.3",
|
|
95
95
|
"@semantic-release/git": "10.0.1",
|
|
@@ -106,8 +106,8 @@
|
|
|
106
106
|
"@storybook/react": "6.5.0-alpha.4",
|
|
107
107
|
"@storybook/theming": "6.5.0-alpha.4",
|
|
108
108
|
"@types/react-dom": "17.0.11",
|
|
109
|
-
"@typescript-eslint/eslint-plugin": "5.8.
|
|
110
|
-
"@typescript-eslint/parser": "5.8.
|
|
109
|
+
"@typescript-eslint/eslint-plugin": "5.8.1",
|
|
110
|
+
"@typescript-eslint/parser": "5.8.1",
|
|
111
111
|
"@wonderflow/config": "3.0.3",
|
|
112
112
|
"@wonderflow/eslint-config": "1.1.8",
|
|
113
113
|
"@wonderflow/stylelint-config": "1.1.3",
|
package/textfield/textfield.js
CHANGED
|
@@ -5,7 +5,7 @@ import { BaseField } from './base-field';
|
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import { useUIDSeed } from 'react-uid';
|
|
7
7
|
import { Textfield as TextfieldClass, FieldContainer, InputField, Icon as IconClass, IconButton as IconButtonClass } from './textfield.module.css';
|
|
8
|
-
export const Textfield = forwardRef(({ children, className, disabled = false, icon, label, textarea, readOnly, invalid, iconPosition = 'right', dimension = 'regular', type, onChange, ...otherProps }, forwardedRef) => {
|
|
8
|
+
export const Textfield = forwardRef(({ children, className, disabled = false, icon, label, textarea, readOnly, invalid, 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';
|
|
@@ -28,7 +28,7 @@ export const Textfield = forwardRef(({ children, className, disabled = false, ic
|
|
|
28
28
|
disabled,
|
|
29
29
|
onChange
|
|
30
30
|
};
|
|
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, children: [label && _jsx(Text, { as: "label", size: dimension === 'small' ? 14 : 16, htmlFor: seedID('field'), children: label }, void 0), _jsxs("div", { className: FieldContainer, children: [textarea
|
|
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: seedID('field'), children: label }, void 0), _jsxs("div", { className: FieldContainer, children: [textarea
|
|
32
32
|
? (_jsx(BaseField, { ref: forwardedRef, as: "textarea", id: seedID('field'), ...commonProps, ...otherProps }, void 0))
|
|
33
33
|
: (_jsx(BaseField, { className: InputField, id: seedID('field'), 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 && type !== 'password' && (_jsx(Icon, { className: IconClass, name: icon, dimension: iconSizes[dimension] }, void 0))] }, void 0)] }, void 0));
|
|
34
34
|
});
|
package/themes/dark.css
CHANGED
package/themes/light.css
CHANGED
package/title/title.module.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.Title:is(.H1,.H2,.H3,.H4,.H5,.H6,.Display){--lh:
|
|
1
|
+
.Title:is(.H1,.H2,.H3,.H4,.H5,.H6,.Display){--lh:1.5;color:var(--heading-foreground);display:block;font-size:var(--fs-max);line-height:1.2;max-inline-size:var(--maxW,initial);min-block-size:.01vh;overflow-wrap:break-word;text-align:var(--tAlign)}.Title[data-title-line-height=small]:is(.H1,.H2,.H3,.H4,.H5,.H6,.Display){--lh:1.2}.Title[data-title-line-height=large]:is(.H1,.H2,.H3,.H4,.H5,.H6,.Display){line-height:1.5}.Title:is(.H6){--fs-min:0.78rem;--fs-max:1.00rem;font-weight:700}.Title:is(.H5){--fs-min:1rem;--fs-max:1.33rem;font-weight:700}.Title:is(.H5):before{content:"";display:block;height:0;margin-top:calc((1 - var(--lh))*.6em);width:0}.Title:is(.H4){--fs-min:1.33rem;--fs-max:1.77rem;font-weight:700}.Title:is(.H4):before{content:"";display:block;height:0;margin-top:calc((1 - var(--lh))*.6em);width:0}.Title:is(.H3){--fs-min:1.77rem;--fs-max:2.37rem;font-weight:800}.Title:is(.H3):before{content:"";display:block;height:0;margin-top:calc((1 - var(--lh))*.6em);width:0}.Title:is(.H2){--fs-min:2.37rem;--fs-max:3.16rem;font-weight:800}.Title:is(.H2):before{content:"";display:block;height:0;margin-top:calc((1 - var(--lh))*.6em);width:0}.Title:is(.H1){--fs-min:3.16rem;--fs-max:4.2rem;font-weight:800}.Title:is(.H1):before{content:"";display:block;height:0;margin-top:calc((1 - var(--lh))*.6em);width:0}.Title.Display{--fs-min:4.2rem;--fs-max:5.6rem;font-weight:800}.Title.Display:before{content:"";display:block;height:0;margin-top:calc((1 - var(--lh))*.6em);width:0}.Title[data-title-responsive=true]{font-size:var(--fs-min)}@media (min-width:48em){.Title[data-title-responsive=true]{font-size:var(--fs-max)}}
|
package/tooltip/tooltip.d.ts
CHANGED
package/tooltip/tooltip.js
CHANGED
|
@@ -3,21 +3,21 @@ import { Children, cloneElement, useState, useRef } from 'react';
|
|
|
3
3
|
import { useUIDSeed } from 'react-uid';
|
|
4
4
|
import { useKeyPress, useFocusWithin } from 'ahooks';
|
|
5
5
|
import { Elevator } from '../';
|
|
6
|
-
import { Tooltip as TooltipClass,
|
|
6
|
+
import { Tooltip as TooltipClass, Balloon, Arrow } from './tooltip.module.css';
|
|
7
7
|
import { usePopperTooltip } from 'react-popper-tooltip';
|
|
8
|
-
export const Tooltip = ({ children, trigger, placement = 'bottom-start',
|
|
8
|
+
export const Tooltip = ({ children, trigger, placement = 'bottom-start', open, style, maxWidth = '40ch', fill = false, interactive = false, delay = 500 }) => {
|
|
9
9
|
const seedID = useUIDSeed();
|
|
10
|
-
const [
|
|
10
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
11
11
|
const tooltipContainerRef = useRef(null);
|
|
12
|
-
useKeyPress('esc', () =>
|
|
12
|
+
useKeyPress('esc', () => setIsOpen(false));
|
|
13
13
|
const { getArrowProps, getTooltipProps, setTooltipRef, setTriggerRef, visible } = usePopperTooltip({
|
|
14
14
|
delayShow: delay,
|
|
15
15
|
delayHide: 300,
|
|
16
16
|
trigger: ['hover'],
|
|
17
|
-
visible:
|
|
17
|
+
visible: open || isOpen,
|
|
18
18
|
closeOnTriggerHidden: true,
|
|
19
19
|
interactive: interactive,
|
|
20
|
-
onVisibleChange:
|
|
20
|
+
onVisibleChange: setIsOpen,
|
|
21
21
|
placement: placement,
|
|
22
22
|
offset: [0, 16]
|
|
23
23
|
}, {
|
|
@@ -25,17 +25,17 @@ export const Tooltip = ({ children, trigger, placement = 'bottom-start', show, s
|
|
|
25
25
|
});
|
|
26
26
|
const isFocusWithin = useFocusWithin(tooltipContainerRef, {
|
|
27
27
|
onFocus: () => {
|
|
28
|
-
|
|
28
|
+
setIsOpen(true);
|
|
29
29
|
},
|
|
30
30
|
onBlur: (e) => {
|
|
31
|
-
(e.target?.parentElement !== tooltipContainerRef.current) &&
|
|
31
|
+
(e.target?.parentElement !== tooltipContainerRef.current) && setIsOpen(false);
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
34
|
const dynamycStyle = {
|
|
35
35
|
'--maxW': maxWidth
|
|
36
36
|
};
|
|
37
|
-
return (_jsxs("div", { "data-tooltip-fill": fill, className:
|
|
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
39
|
'aria-describedby': seedID('tooltip-content')
|
|
40
|
-
})), visible && (_jsx(Elevator, { resting: 2, children: _jsxs("div", { ref: setTooltipRef, role: "tooltip", id: seedID('tooltip-content'), "data-theme": "dark", ...getTooltipProps({ className:
|
|
40
|
+
})), visible && (_jsx(Elevator, { resting: 2, 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
41
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.Tooltip{word-wrap:break-word;background-color:#31363f;border-radius:.22rem;font-size:.89rem;max-inline-size:var(--maxW);padding:.44rem .89rem;position:relative;z-index:2}.
|
|
1
|
+
.Tooltip{display:contents}.Balloon{word-wrap:break-word;background-color:#31363f;border-radius:.22rem;font-size:.89rem;max-inline-size:var(--maxW);padding:.44rem .89rem;position:relative;z-index:2}.Balloon[data-popper-reference-hidden=true]{pointer-events:none;visibility:hidden}.Arrow:before{background-color:#31363f;block-size:12px;content:"";inline-size:12px;position:absolute;transform:rotate(45deg);visibility:visible}.Balloon[data-popper-reference-hidden=true] .Arrow{pointer-events:none;visibility:hidden}.Balloon[data-popper-placement^=top] .Arrow{bottom:6px}.Balloon[data-popper-placement^=top] .Arrow:before{transform:translateX(-50%) rotate(45deg)}.Balloon[data-popper-placement^=left] .Arrow{right:6px}.Balloon[data-popper-placement^=left] .Arrow:before{transform:translateY(-50%) rotate(45deg)}.Balloon[data-popper-placement^=bottom] .Arrow{top:-6px}.Balloon[data-popper-placement^=bottom] .Arrow:before{transform:translateX(-50%) rotate(45deg)}.Balloon[data-popper-placement^=right] .Arrow{left:-6px}.Balloon[data-popper-placement^=right] .Arrow:before{transform:translateY(-50%) rotate(45deg)}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, forwardRef, useRef, useMemo } from 'react';
|
|
3
|
-
import { useRovingTabIndex, useFocusEffect } from 'react-roving-tabindex';
|
|
4
|
-
import { DropdownItem as DropdownItemClass, Icon as IconClass } from './dropdown-item.module.css';
|
|
5
|
-
import { Tooltip, Stack, Icon } from '../..';
|
|
6
|
-
import clsx from 'clsx';
|
|
7
|
-
export const DropdownItem = forwardRef(({ className, children, onClick, icon, dimension = 'regular', as: Wrapper = 'button', iconPosition = 'left', description, padding = true, disabled = false, ...props }, forwardedRef) => {
|
|
8
|
-
const itemRef = useRef(forwardedRef);
|
|
9
|
-
const [tabIndex, focused, handleKeyDown, handleClick] = useRovingTabIndex(itemRef, disabled);
|
|
10
|
-
const isIconRight = iconPosition === 'right';
|
|
11
|
-
useFocusEffect(focused, itemRef);
|
|
12
|
-
const triggerClick = useCallback(() => {
|
|
13
|
-
if (onClick) {
|
|
14
|
-
handleClick();
|
|
15
|
-
onClick();
|
|
16
|
-
}
|
|
17
|
-
}, [handleClick, onClick]);
|
|
18
|
-
const InnerContent = useMemo(() => (_jsxs(Stack, { direction: "row", as: "span", fill: false, horizontalAlign: isIconRight ? 'space-between' : 'start', verticalAlign: "center", columnGap: 8, horizontalPadding: 16, verticalPadding: 8, "data-dropdown-icon-right": isIconRight, "data-dropdown-has-icon": Boolean(icon), "data-dropdown-padding": padding, style: { inlineSize: '100%' }, children: [icon && (_jsx(Icon, { className: IconClass, name: icon, dimension: dimension === 'small' ? 14 : 16 }, void 0)), children] }, void 0)), [children, dimension, icon, isIconRight, padding]);
|
|
19
|
-
return (_jsx(Wrapper, { ref: itemRef, role: "menuitem", className: clsx(DropdownItemClass, className), onClick: disabled ? undefined : triggerClick, onKeyDown: disabled ? undefined : handleKeyDown, tabIndex: tabIndex, "aria-disabled": disabled, type: Wrapper === 'button' ? 'button' : undefined, "data-dropdown-item-dimension": dimension, ...props, children: description
|
|
20
|
-
? (_jsx(Tooltip, { fill: true, show: focused, placement: "right-start", trigger: InnerContent, children: description }, void 0))
|
|
21
|
-
: InnerContent }, void 0));
|
|
22
|
-
});
|
|
23
|
-
DropdownItem.displayName = 'Dropdown.Item';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.DropdownItem{background:none;border:0;box-sizing:border-box;color:var(--dimmed-6);cursor:pointer;font:inherit;font-size:.89rem;font-weight:600;inline-size:100%;line-height:1.2;position:relative;text-align:start}.DropdownItem[aria-checked=true]{color:var(--global-interactive-text)}.DropdownItem:before{border-radius:.22rem;bottom:0;content:"";left:.44rem;opacity:60%;position:absolute;right:.44rem;top:0}.DropdownItem:is(:hover,.focus-visible,[aria-pressed=true]):not([aria-disabled=true]){outline:none}.DropdownItem:is(:hover,:focus-visible,[aria-pressed=true]):not([aria-disabled=true]){outline:none}.DropdownItem:is(:hover,.focus-visible,[aria-pressed=true]):not([aria-disabled=true]):before{background-color:var(--dimmed-1)}.DropdownItem:is(:hover,:focus-visible,[aria-pressed=true]):not([aria-disabled=true]):before{background-color:var(--dimmed-1)}.DropdownItem[data-dropdown-item-dimension=small]{font-size:.78rem}.DropdownItem>*{position:relative}.DropdownItem[aria-disabled=true]{color:var(--global-disabled-foreground);cursor:not-allowed}.DropdownItem [data-dropdown-padding=true][data-dropdown-has-icon=false][data-dropdown-icon-right=false]{padding-left:2.22rem}.DropdownItem [data-dropdown-padding=true][data-dropdown-has-icon=false][data-dropdown-icon-right=true]{padding-right:2.22rem}[data-dropdown-icon-right=true] .Icon{order:2}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { DropdownItem, DropdownItemProps } from '../item/dropdown-item';
|
|
2
|
-
import { Polymorphic } from '../..';
|
|
3
|
-
export declare type DropdownItemCheckboxProps = DropdownItemProps & {
|
|
4
|
-
/**
|
|
5
|
-
* Set the default checked state of the checkbox item
|
|
6
|
-
*/
|
|
7
|
-
checked?: boolean;
|
|
8
|
-
};
|
|
9
|
-
declare type PolymorphicDropdownItemCheckbox = Polymorphic.ForwardRefComponent<Polymorphic.IntrinsicElement<typeof DropdownItem>, Polymorphic.OwnProps<typeof DropdownItem> & DropdownItemCheckboxProps>;
|
|
10
|
-
export declare const DropdownItemCheckbox: PolymorphicDropdownItemCheckbox;
|
|
11
|
-
export {};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef } from 'react';
|
|
3
|
-
import { DropdownItem } from '../item/dropdown-item';
|
|
4
|
-
export const DropdownItemCheckbox = forwardRef(({ children, checked, ...props }, forwardedRef) => _jsx(DropdownItem, { role: "menuitemcheckbox", "aria-checked": checked, ref: forwardedRef, ...props, children: children }, void 0));
|
|
5
|
-
DropdownItemCheckbox.displayName = 'Dropdown.ItemCheckbox';
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ReactNode, HTMLAttributes } from 'react';
|
|
2
|
-
export declare type DropdownMenuProps = HTMLAttributes<HTMLUListElement> & {
|
|
3
|
-
/**
|
|
4
|
-
* The items of the dropdown menu.
|
|
5
|
-
*/
|
|
6
|
-
children: ReactNode;
|
|
7
|
-
};
|
|
8
|
-
export declare const DropdownMenu: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLUListElement> & {
|
|
9
|
-
/**
|
|
10
|
-
* The items of the dropdown menu.
|
|
11
|
-
*/
|
|
12
|
-
children: ReactNode;
|
|
13
|
-
} & import("react").RefAttributes<HTMLUListElement>>;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Children, cloneElement, forwardRef } from 'react';
|
|
3
|
-
import { RovingTabIndexProvider } from 'react-roving-tabindex';
|
|
4
|
-
import { Stack, Elevator } from '../..';
|
|
5
|
-
import clsx from 'clsx';
|
|
6
|
-
import { DropdownMenu as DropdownMenuClass } from './dropdown-menu.module.css';
|
|
7
|
-
export const DropdownMenu = forwardRef(({ className, children, ...otherProps }, forwardedRef) => {
|
|
8
|
-
const renderedChildren = Children.toArray(children).filter(Boolean);
|
|
9
|
-
return (_jsx(Elevator, { resting: 2, children: _jsx(Stack, { as: "ul", ref: forwardedRef, className: clsx(DropdownMenuClass, className), role: "menu", ...otherProps, children: _jsx(RovingTabIndexProvider, { options: { direction: 'vertical', loopAround: true }, children: Children.map(renderedChildren, (child, index) => (_jsx(Stack, { as: "li", role: "none", verticalPadding: child.type?.displayName === 'Separator' ? 8 : undefined, children: cloneElement(child, {
|
|
10
|
-
autoFocus: index === 0 && true
|
|
11
|
-
}) }, void 0))) }, void 0) }, void 0) }, void 0));
|
|
12
|
-
});
|
|
13
|
-
DropdownMenu.displayName = 'Dropdown.Menu';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.DropdownMenu{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}.DropdownMenu hr{margin:0 .44rem}
|