@wonderflow/react-components 3.0.0-beta.4 → 3.0.0-beta.8
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/button/button.module.css +1 -1
- package/card/card.module.css +1 -1
- package/core/utils/media.css +19 -1
- package/core/utils/vibrancy.css +0 -24
- package/drawer/drawer.d.ts +65 -0
- package/drawer/drawer.js +32 -0
- package/drawer/drawer.module.css +1 -0
- package/drawer/index.d.ts +2 -0
- package/drawer/index.js +1 -0
- package/dropdown/dropdown.js +8 -8
- package/index.d.ts +2 -0
- package/index.js +1 -0
- package/modal/content/modal-content.js +1 -1
- package/modal/content/modal-content.module.css +1 -1
- package/modal/modal.js +19 -3
- package/modal/modal.module.css +1 -1
- package/overlay-container/overlay-container.d.ts +6 -2
- package/overlay-container/overlay-container.js +4 -4
- package/overlay-container/overlay-container.module.css +1 -1
- package/package.json +6 -7
- package/select/select.module.css +1 -1
- package/selection-controls/selection-controls.module.css +1 -1
- package/snackbar/snackbar.d.ts +1 -1
- package/snackbar/snackbar.js +2 -2
- package/snackbar/snackbar.module.css +1 -1
- package/textfield/base-field/base-field.module.css +1 -1
- package/themes/dark.css +1 -1
- package/themes/light.css +1 -1
- package/tooltip/tooltip.js +10 -11
- package/hooks/index.d.ts +0 -1
- package/hooks/index.js +0 -1
- package/hooks/useFocusWithin.d.ts +0 -20
- package/hooks/useFocusWithin.js +0 -37
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:
|
|
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-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/card/card.module.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
:where(.Card){background:var(--global-background);border-radius:var(--radius);padding:var(--padding);position:relative}[data-card-dimmed="1"]:where(.Card){background:var(--dimmed-0)}[data-card-dimmed="2"]:where(.Card){background:var(--dimmed-1)}[data-card-dimmed="3"]:where(.Card){background:var(--dimmed-2)}[data-card-vibrant=true]:where(.Card){-webkit-backdrop-filter:saturate(180%) blur(62px);backdrop-filter:saturate(180%) blur(62px);background:
|
|
1
|
+
:where(.Card){background:var(--global-background);border-radius:var(--radius);padding:var(--padding);position:relative}[data-card-dimmed="1"]:where(.Card){background:var(--dimmed-0)}[data-card-dimmed="2"]:where(.Card){background:var(--dimmed-1)}[data-card-dimmed="3"]:where(.Card){background:var(--dimmed-2)}[data-card-vibrant=true]:where(.Card){-webkit-backdrop-filter:saturate(180%) blur(62px);backdrop-filter:saturate(180%) blur(62px);background-color:var(--global-vibrancy-background)}[data-card-highlight-hover=true][data-card-vibrant=true]:where(.Card).focus-visible,[data-card-highlight-hover=true][data-card-vibrant=true]:where(.Card):hover{background-color:var(--global-vibrancy-background-hover)}[data-card-highlight-hover=true][data-card-vibrant=true]:where(.Card):focus-visible,[data-card-highlight-hover=true][data-card-vibrant=true]:where(.Card):hover{background-color:var(--global-vibrancy-background-hover)}[data-card-bordered=true]:where(.Card){border:1px solid var(--dimmed-1)}[data-card-vibrant=true][data-card-bordered=true]:where(.Card){border:1px solid var(--dimmed-2)}.Left{flex-shrink:0}.Content{flex-grow:1}.Right{flex-shrink:0}
|
package/core/utils/media.css
CHANGED
|
@@ -27,4 +27,22 @@
|
|
|
27
27
|
|
|
28
28
|
/* Motion Media Queries */
|
|
29
29
|
|
|
30
|
-
@custom-media --
|
|
30
|
+
@custom-media --motion (prefers-reduced-motion: no-preference);
|
|
31
|
+
@custom-media --reduced-motion (prefers-reduced-motion: reduce);
|
|
32
|
+
|
|
33
|
+
/* Opacity Media Queries */
|
|
34
|
+
|
|
35
|
+
@custom-media --opacity (prefers-reduced-transparency: no-preference);
|
|
36
|
+
@custom-media --reduce-opacity (prefers-reduced-transparency: reduce);
|
|
37
|
+
|
|
38
|
+
/* Contrast Media Queries */
|
|
39
|
+
|
|
40
|
+
@custom-media --high-contrast (prefers-contrast: high);
|
|
41
|
+
@custom-media --low-contrast (prefers-contrast: low);
|
|
42
|
+
|
|
43
|
+
/* Pointer Media Queries */
|
|
44
|
+
|
|
45
|
+
@custom-media --touch (hover: none) and (pointer: coarse);
|
|
46
|
+
@custom-media --stylus (hover: none) and (pointer: fine);
|
|
47
|
+
@custom-media --pointer (hover) and (pointer: coarse);
|
|
48
|
+
@custom-media --mouse (hover) and (pointer: fine);
|
package/core/utils/vibrancy.css
CHANGED
|
@@ -1,27 +1,3 @@
|
|
|
1
1
|
@define-mixin vibrancy {
|
|
2
2
|
backdrop-filter: saturate(180%) blur(62px);
|
|
3
|
-
background:
|
|
4
|
-
linear-gradient(
|
|
5
|
-
to bottom,
|
|
6
|
-
var(--global-vibrancy-background),
|
|
7
|
-
var(--global-vibrancy-background)
|
|
8
|
-
);
|
|
9
|
-
}
|
|
10
|
-
@define-mixin vibrancy-hover {
|
|
11
|
-
background:
|
|
12
|
-
linear-gradient(
|
|
13
|
-
to bottom,
|
|
14
|
-
var(--global-vibrancy-background-hover),
|
|
15
|
-
var(--global-vibrancy-background-hover)
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
@define-mixin vibrancy-disabled {
|
|
19
|
-
color: var(--global-disabled-foreground);
|
|
20
|
-
backdrop-filter: saturate(180%) blur(62px);
|
|
21
|
-
background:
|
|
22
|
-
linear-gradient(
|
|
23
|
-
to bottom,
|
|
24
|
-
var(--global-disabled-background),
|
|
25
|
-
var(--global-disabled-background)
|
|
26
|
-
);
|
|
27
3
|
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { PropsWithChildren, ReactNode } from 'react';
|
|
2
|
+
export declare type DrawerProps = PropsWithChildren<PropsWithClass> & {
|
|
3
|
+
/**
|
|
4
|
+
* This enable the drawer to be closed by clicking on the overlay.
|
|
5
|
+
* Even if this can be set to `false` we strongly recommend to leave
|
|
6
|
+
* it to `true` as it ensures the accessibility of the drawer.
|
|
7
|
+
*/
|
|
8
|
+
closeOnClickOutside?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Set the accessible title of the drawer. This is used by screen readers to
|
|
11
|
+
* announce the title of the drawer when opened.
|
|
12
|
+
*/
|
|
13
|
+
title?: ReactNode;
|
|
14
|
+
/**
|
|
15
|
+
* Hide or show the drawer header which includes the title and the close button.
|
|
16
|
+
*/
|
|
17
|
+
showHeader?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Set the maximum width of the drawer, on mobile the drawer will be
|
|
20
|
+
* automatically collapsed when the width is reached.
|
|
21
|
+
*/
|
|
22
|
+
maxWidth?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Set the theme of the content card. To ensure contrast with the default overlay color (dark),
|
|
25
|
+
* this is set to `light` by default.
|
|
26
|
+
*/
|
|
27
|
+
theme?: 'dark' | 'light' | 'auto';
|
|
28
|
+
/**
|
|
29
|
+
* Set the side on which the drawer will be positioned.
|
|
30
|
+
*/
|
|
31
|
+
side?: 'left' | 'right';
|
|
32
|
+
};
|
|
33
|
+
export declare const Drawer: import("react").ForwardRefExoticComponent<PropsWithClass & {
|
|
34
|
+
children?: ReactNode;
|
|
35
|
+
} & {
|
|
36
|
+
/**
|
|
37
|
+
* This enable the drawer to be closed by clicking on the overlay.
|
|
38
|
+
* Even if this can be set to `false` we strongly recommend to leave
|
|
39
|
+
* it to `true` as it ensures the accessibility of the drawer.
|
|
40
|
+
*/
|
|
41
|
+
closeOnClickOutside?: boolean | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Set the accessible title of the drawer. This is used by screen readers to
|
|
44
|
+
* announce the title of the drawer when opened.
|
|
45
|
+
*/
|
|
46
|
+
title?: ReactNode;
|
|
47
|
+
/**
|
|
48
|
+
* Hide or show the drawer header which includes the title and the close button.
|
|
49
|
+
*/
|
|
50
|
+
showHeader?: boolean | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Set the maximum width of the drawer, on mobile the drawer will be
|
|
53
|
+
* automatically collapsed when the width is reached.
|
|
54
|
+
*/
|
|
55
|
+
maxWidth?: string | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Set the theme of the content card. To ensure contrast with the default overlay color (dark),
|
|
58
|
+
* this is set to `light` by default.
|
|
59
|
+
*/
|
|
60
|
+
theme?: "auto" | "light" | "dark" | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Set the side on which the drawer will be positioned.
|
|
63
|
+
*/
|
|
64
|
+
side?: "left" | "right" | undefined;
|
|
65
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
package/drawer/drawer.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { motion } from 'framer-motion';
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import { FocusOn } from 'react-focus-on';
|
|
6
|
+
import { Drawer as DrawerClass, Container, Content, Header, CloseButton } from './drawer.module.css';
|
|
7
|
+
import { useOverlayContext } from '../overlay-container';
|
|
8
|
+
import { Elevator, IconButton, Stack, Title } from '../';
|
|
9
|
+
export const Drawer = forwardRef(({ children, className, closeOnClickOutside = true, showHeader = true, maxWidth = '400px', side = 'right', theme = 'light', title, ...otherProps }, forwardedRef) => {
|
|
10
|
+
const { titleId, onClose } = useOverlayContext();
|
|
11
|
+
const dynamicStyle = {
|
|
12
|
+
'--max-w': maxWidth
|
|
13
|
+
};
|
|
14
|
+
const DrawerAnimation = {
|
|
15
|
+
visible: {
|
|
16
|
+
x: 0,
|
|
17
|
+
transition: {
|
|
18
|
+
ease: [0, 0, 0.34, 1],
|
|
19
|
+
duration: 0.35
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
hidden: {
|
|
23
|
+
x: side === 'right' ? '100%' : '-100%',
|
|
24
|
+
transition: {
|
|
25
|
+
ease: [0.3, 0.07, 1, 1],
|
|
26
|
+
duration: 0.2
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
return (_jsx("div", { role: "dialog", "aria-modal": "true", "data-theme": theme, "aria-labelledby": titleId, className: clsx(DrawerClass, className), ref: forwardedRef, ...otherProps, children: _jsx(FocusOn, { onClickOutside: onClose, onEscapeKey: onClose, children: _jsx(motion.div, { variants: DrawerAnimation, initial: "hidden", animate: "visible", exit: "hidden", className: Container, "data-drawer-side": side, children: _jsx(Elevator, { resting: 4, children: _jsxs("div", { className: Content, style: dynamicStyle, ref: forwardedRef, ...otherProps, children: [(showHeader && title) && (_jsxs(Stack, { verticalAlign: "center", fill: false, horizontalAlign: "space-between", direction: "row", className: Header, children: [_jsx(Title, { responsive: false, level: "6", id: titleId, children: title }, void 0), onClose && _jsx(IconButton, { dimension: "small", onClick: onClose, className: CloseButton, icon: "xmark", kind: "flat" }, void 0)] }, void 0)), children] }, void 0) }, void 0) }, void 0) }, void 0) }, void 0));
|
|
31
|
+
});
|
|
32
|
+
Drawer.displayName = 'Drawer';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.Drawer{display:contents}.Container{align-items:stretch;bottom:0;display:grid;left:0;pointer-events:none;position:absolute;right:0;top:0}.Container[data-drawer-side=right]{justify-content:flex-end}.Container[data-drawer-side=left]{justify-content:flex-start}@media (min-width:30em){.Container{overflow:auto}}.Container>*{pointer-events:auto}.Content{-webkit-overflow-scrolling:touch;background-color:var(--global-background);inline-size:100%;max-inline-size:var(--max-w);overflow:auto;overscroll-behavior:contain}.Header{background-color:inherit;border-bottom:1px solid var(--dimmed-1);padding:.89rem 4.44rem .89rem 1.33rem;position:sticky;top:0}.CloseButton.CloseButton{position:absolute;right:.44rem;top:50%;transform:translateY(-50%)}
|
package/drawer/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Drawer } from './drawer';
|
package/dropdown/dropdown.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
import { useState, Children, cloneElement, useRef, forwardRef } from 'react';
|
|
4
|
-
import { useKeyPress, useClickAway } from 'ahooks';
|
|
4
|
+
import { useKeyPress, useClickAway, useFocusWithin } from 'ahooks';
|
|
5
5
|
import { Dropdown as DropdownClass, PopUp } from './dropdown.module.css';
|
|
6
6
|
import { useUIDSeed } from 'react-uid';
|
|
7
|
-
import { useFocusWithin } from '../hooks';
|
|
8
7
|
import { DropdownMenu } from './menu/dropdown-menu';
|
|
9
8
|
import { DropdownItem } from './item/dropdown-item';
|
|
10
9
|
import { DropdownItemCheckbox } from './item-checkbox/dropdown-item-checkbox';
|
|
@@ -26,16 +25,17 @@ export const Dropdown = forwardRef(({ className, children, trigger, offset = 8,
|
|
|
26
25
|
offset: [0, offset],
|
|
27
26
|
closeOnOutsideClick: false
|
|
28
27
|
});
|
|
28
|
+
const isFocusWithin = useFocusWithin(popupRef, {
|
|
29
|
+
onBlur: (e) => e.relatedTarget && setIsOpen(false),
|
|
30
|
+
onChange: (isFocusWithin) => {
|
|
31
|
+
!isFocusWithin && setIsOpen(false);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
29
34
|
useClickAway(() => {
|
|
30
35
|
setIsOpen(false);
|
|
31
36
|
}, popupRef);
|
|
32
|
-
const { focusWithinProps } = useFocusWithin({
|
|
33
|
-
onFocusWithin: () => null,
|
|
34
|
-
onBlurWithin: (e) => e.relatedTarget && setIsOpen(false),
|
|
35
|
-
onFocusWithinChange: () => null
|
|
36
|
-
});
|
|
37
37
|
useKeyPress('esc', () => setIsOpen(false));
|
|
38
|
-
return (_jsxs("div", { ref: popupRef, className: clsx(DropdownClass, className),
|
|
38
|
+
return (_jsxs("div", { ref: popupRef, "data-dropdown-has-focus-within": isFocusWithin, className: clsx(DropdownClass, className), children: [Children.map(trigger, (child) => cloneElement(child, {
|
|
39
39
|
ref: setTriggerRef,
|
|
40
40
|
id: seedID('dropdown-trigger'),
|
|
41
41
|
'aria-haspopup': 'true',
|
package/index.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ export { ClampText } from './clamp-text';
|
|
|
16
16
|
export type { ClampTextProps } from './clamp-text';
|
|
17
17
|
export { Container } from './container';
|
|
18
18
|
export type { ContainerProps } from './container';
|
|
19
|
+
export { Drawer } from './drawer';
|
|
20
|
+
export type { DrawerProps } from './drawer';
|
|
19
21
|
export { Table } from './table';
|
|
20
22
|
export type { TableProps } from './table';
|
|
21
23
|
export { Disclosure } from './disclosure';
|
package/index.js
CHANGED
|
@@ -8,6 +8,7 @@ export { Chip } from './chip';
|
|
|
8
8
|
export { CircularProgress } from './circular-progress';
|
|
9
9
|
export { ClampText } from './clamp-text';
|
|
10
10
|
export { Container } from './container';
|
|
11
|
+
export { Drawer } from './drawer';
|
|
11
12
|
export { Table } from './table';
|
|
12
13
|
export { Disclosure } from './disclosure';
|
|
13
14
|
export { Dropdown } from './dropdown';
|
|
@@ -6,6 +6,6 @@ import { Title, Elevator, IconButton, Stack } from '../../';
|
|
|
6
6
|
import { useOverlayContext } from '../../overlay-container';
|
|
7
7
|
export const ModalContent = forwardRef(({ children, className, title, theme = 'light', ...otherProps }, forwardedRef) => {
|
|
8
8
|
const { onClose, titleId } = useOverlayContext();
|
|
9
|
-
return (_jsx(Elevator, { resting: 4, children: _jsxs("div", { className: clsx(Content, className), ref: forwardedRef, "data-theme": theme, ...otherProps, children: [_jsxs(Stack, { verticalAlign: "center", fill: false, horizontalAlign: "space-between", direction: "row", className: Header, children: [_jsx(Title, { level: "5", id: titleId, children: title }, void 0), onClose && _jsx(IconButton, { onClick: onClose, className: CloseButton, icon: "xmark", kind: "flat" }, void 0)] }, void 0), children] }, void 0) }, void 0));
|
|
9
|
+
return (_jsx(Elevator, { resting: 4, children: _jsxs("div", { className: clsx(Content, className), ref: forwardedRef, "data-theme": theme, ...otherProps, children: [_jsxs(Stack, { verticalAlign: "center", fill: false, horizontalAlign: "space-between", direction: "row", className: Header, children: [_jsx(Title, { responsive: false, level: "5", id: titleId, children: title }, void 0), onClose && _jsx(IconButton, { onClick: onClose, className: CloseButton, icon: "xmark", kind: "flat" }, void 0)] }, void 0), children] }, void 0) }, void 0));
|
|
10
10
|
});
|
|
11
11
|
ModalContent.displayName = 'Modal.Content';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.Content{-webkit-overflow-scrolling:touch;align-self:end;background-color:var(--global-background);border-radius:.89rem .89rem 0 0;
|
|
1
|
+
.Content{-webkit-overflow-scrolling:touch;align-self:end;background-color:var(--global-background);border-radius:.89rem .89rem 0 0;inline-size:100%;justify-self:center;max-block-size:95vh;overflow:auto;overscroll-behavior:contain}@media (min-width:30em){.Content{align-self:center;border-radius:.44rem;justify-self:center;max-block-size:80vh;max-inline-size:600px}}.Header{background-color:inherit;border-bottom:1px solid var(--dimmed-1);padding:.89rem 4.44rem .89rem 1.33rem;position:sticky;top:0}.CloseButton.CloseButton{position:absolute;right:.44rem;top:.44rem}
|
package/modal/modal.js
CHANGED
|
@@ -1,16 +1,32 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
|
-
import { useUIDSeed } from 'react-uid';
|
|
4
3
|
import { motion } from 'framer-motion';
|
|
5
4
|
import clsx from 'clsx';
|
|
6
5
|
import { FocusOn } from 'react-focus-on';
|
|
7
6
|
import { ModalContent } from './content/modal-content';
|
|
8
7
|
import { Modal as ModalClass, Container } from './modal.module.css';
|
|
9
8
|
import { useOverlayContext } from '../overlay-container';
|
|
9
|
+
const ModalAnimation = {
|
|
10
|
+
visible: {
|
|
11
|
+
scale: 1,
|
|
12
|
+
opacity: 1,
|
|
13
|
+
transition: {
|
|
14
|
+
ease: [0, 0, 0.34, 1],
|
|
15
|
+
duration: 0.35
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
hidden: {
|
|
19
|
+
scale: 0.98,
|
|
20
|
+
opacity: 0,
|
|
21
|
+
transition: {
|
|
22
|
+
ease: [0.3, 0.07, 1, 1],
|
|
23
|
+
duration: 0.2
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
10
27
|
export const Modal = forwardRef(({ children, className, closeOnClickOutside = true, ...otherProps }, forwardedRef) => {
|
|
11
|
-
const seedID = useUIDSeed();
|
|
12
28
|
const { titleId, onClose } = useOverlayContext();
|
|
13
|
-
return (_jsx("div", { role: "dialog", "aria-modal": "true", "aria-labelledby": titleId, className: clsx(ModalClass, className), ref: forwardedRef, ...otherProps, children: _jsx(FocusOn, { onClickOutside: onClose, onEscapeKey: onClose, children: _jsx(motion.div, {
|
|
29
|
+
return (_jsx("div", { role: "dialog", "aria-modal": "true", "aria-labelledby": titleId, className: clsx(ModalClass, className), ref: forwardedRef, ...otherProps, children: _jsx(FocusOn, { onClickOutside: onClose, onEscapeKey: onClose, children: _jsx(motion.div, { variants: ModalAnimation, initial: "hidden", animate: "visible", exit: "hidden", className: Container, children: children }, void 0) }, void 0) }, void 0));
|
|
14
30
|
});
|
|
15
31
|
Modal.displayName = 'Modal';
|
|
16
32
|
Modal.Content = ModalContent;
|
package/modal/modal.module.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.Modal{
|
|
1
|
+
.Modal{display:contents}.Container{align-items:center;bottom:0;display:grid;justify-content:center;left:0;pointer-events:none;position:absolute;right:0;top:0;z-index:1}@media (min-width:30em){.Container{overflow:auto;padding:0 1.33rem}}.Container>*{pointer-events:auto}
|
|
@@ -16,8 +16,8 @@ export declare type OverlayContainerProps = {
|
|
|
16
16
|
*/
|
|
17
17
|
index?: number;
|
|
18
18
|
/**
|
|
19
|
-
* Set the overlay style. This is used to obscure the
|
|
20
|
-
* behind the
|
|
19
|
+
* Set the overlay style. This is used to obscure the content
|
|
20
|
+
* behind the overlay if `obfuscate` is `true`. If set to `auto`, the overlay
|
|
21
21
|
* color is determined by the global active theme (light or dark).
|
|
22
22
|
*/
|
|
23
23
|
overlayColor?: 'light' | 'dark' | 'auto';
|
|
@@ -25,5 +25,9 @@ export declare type OverlayContainerProps = {
|
|
|
25
25
|
* The callback function that is called when the overlay is closed.
|
|
26
26
|
*/
|
|
27
27
|
onClose?(): void;
|
|
28
|
+
/**
|
|
29
|
+
* Set the overlay to be obscuring the page content behind it.
|
|
30
|
+
*/
|
|
31
|
+
obfuscate?: boolean;
|
|
28
32
|
};
|
|
29
33
|
export declare const OverlayContainer: React.FC<OverlayContainerProps>;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { jsx as _jsx,
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { AnimatePresence, motion } from 'framer-motion';
|
|
3
3
|
import { useEffect } from 'react';
|
|
4
4
|
import { createPortal } from 'react-dom';
|
|
5
5
|
import { useUIDSeed } from 'react-uid';
|
|
6
6
|
import { OverlayProvider } from './overlay-context';
|
|
7
|
-
import { Backdrop } from './overlay-container.module.css';
|
|
8
|
-
export const OverlayContainer = ({ children, root = document.body, overlayColor = 'dark', index = 4, onClose }) => {
|
|
7
|
+
import { OverlayContainer as OverlayContainerClass, Backdrop } from './overlay-container.module.css';
|
|
8
|
+
export const OverlayContainer = ({ children, root = document.body, overlayColor = 'dark', index = 4, obfuscate = true, onClose }) => {
|
|
9
9
|
const seedID = useUIDSeed();
|
|
10
10
|
useEffect(() => {
|
|
11
11
|
if (root.closest('[data-overlay-container]')) {
|
|
12
12
|
throw new Error('An OverlayContainer must not be inside another container. Please change the root prop.');
|
|
13
13
|
}
|
|
14
14
|
}, [root]);
|
|
15
|
-
const content = (_jsx(OverlayProvider, { onClose: onClose, children: _jsx(AnimatePresence, { children: children && (_jsxs(
|
|
15
|
+
const content = (_jsx(OverlayProvider, { onClose: onClose, children: _jsx(AnimatePresence, { exitBeforeEnter: true, children: children && (_jsxs("div", { "data-overlay-container": true, className: OverlayContainerClass, style: { zIndex: index }, children: [obfuscate && (_jsx(motion.span, { className: Backdrop, "data-overlay-color": overlayColor, initial: { opacity: 0 }, animate: { opacity: 0.95 }, transition: { duration: 0.2 }, exit: { opacity: 0 } }, seedID('modal-backdrop'))), children] }, void 0)) }, void 0) }, void 0));
|
|
16
16
|
return createPortal(content, root);
|
|
17
17
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.Backdrop{
|
|
1
|
+
.OverlayContainer{display:block}.Backdrop,.OverlayContainer{bottom:0;left:0;position:fixed;right:0;top:0}.Backdrop{background-color:var(--dimmed-0);z-index:-1}.Backdrop[data-overlay-color=light]{background-color:#f9fafb}.Backdrop[data-overlay-color=dark]{background-color:#202328}
|
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.8",
|
|
5
5
|
"author": "Wonderflow",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "index.js",
|
|
@@ -64,14 +64,13 @@
|
|
|
64
64
|
"postbuild": "run-s prepare:package"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@react-aria/interactions": "3.7.0",
|
|
68
67
|
"@wonderflow/tokens": "1.3.7",
|
|
69
|
-
"ahooks": "3.
|
|
68
|
+
"ahooks": "3.1.1",
|
|
70
69
|
"clsx": "1.1.1",
|
|
71
70
|
"framer-motion": "4.1.17",
|
|
72
71
|
"postcss": "^8.4.5",
|
|
73
72
|
"react": "^17.0",
|
|
74
|
-
"react-data-table-component": "7.4.
|
|
73
|
+
"react-data-table-component": "7.4.6",
|
|
75
74
|
"react-dom": "^17.0",
|
|
76
75
|
"react-focus-on": "3.5.4",
|
|
77
76
|
"react-loading-skeleton": "3.0.1",
|
|
@@ -107,8 +106,8 @@
|
|
|
107
106
|
"@storybook/react": "6.5.0-alpha.4",
|
|
108
107
|
"@storybook/theming": "6.5.0-alpha.4",
|
|
109
108
|
"@types/react-dom": "17.0.11",
|
|
110
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
111
|
-
"@typescript-eslint/parser": "5.
|
|
109
|
+
"@typescript-eslint/eslint-plugin": "5.8.0",
|
|
110
|
+
"@typescript-eslint/parser": "5.8.0",
|
|
112
111
|
"@wonderflow/config": "3.0.3",
|
|
113
112
|
"@wonderflow/eslint-config": "1.1.8",
|
|
114
113
|
"@wonderflow/stylelint-config": "1.1.3",
|
|
@@ -119,7 +118,7 @@
|
|
|
119
118
|
"cz-conventional-changelog": "3.3.0",
|
|
120
119
|
"directory-tree": "3.0.1",
|
|
121
120
|
"eslint": "7.32.0",
|
|
122
|
-
"eslint-plugin-react": "7.
|
|
121
|
+
"eslint-plugin-react": "7.28.0",
|
|
123
122
|
"eslint-plugin-storybook": "0.5.5",
|
|
124
123
|
"fs-extra": "10.0.0",
|
|
125
124
|
"husky": "7.0.4",
|
package/select/select.module.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.Select{-webkit-appearance:none;appearance:none;padding:0;position:relative}.Select[data-select-dimension=small]{--field-height:1.33rem;--field-padding:0.33rem;--font-size:0.78rem}.Select[data-select-dimension=regular]{--field-height:2.22rem;--field-padding:0.89rem;--font-size:0.89rem}.Select[data-select-dimension=big]{--field-height:2.67rem;--field-padding:0.89rem;--font-size:1.00rem}.FieldContainer{color:var(--global-vibrancy-foreground);inline-size:100%;position:relative}.Select[aria-disabled=true] .FieldContainer{color:var(--global-disabled-foreground)}.Field{-webkit-appearance:none;appearance:none;background:linear-gradient(to bottom,var(--global-vibrancy-background),var(--global-vibrancy-background));block-size:var(--field-height);border:0;border-radius:.22rem;box-sizing:border-box;color:inherit;display:block;font-family:inherit;font-size:var(--font-size);inline-size:100%;
|
|
1
|
+
.Select{-webkit-appearance:none;appearance:none;padding:0;position:relative}.Select[data-select-dimension=small]{--field-height:1.33rem;--field-padding:0.33rem;--font-size:0.78rem}.Select[data-select-dimension=regular]{--field-height:2.22rem;--field-padding:0.89rem;--font-size:0.89rem}.Select[data-select-dimension=big]{--field-height:2.67rem;--field-padding:0.89rem;--font-size:1.00rem}.FieldContainer{color:var(--global-vibrancy-foreground);inline-size:100%;position:relative}.Select[aria-disabled=true] .FieldContainer{color:var(--global-disabled-foreground)}.Field{-webkit-appearance:none;appearance:none;-webkit-backdrop-filter:saturate(180%) blur(62px);backdrop-filter:saturate(180%) blur(62px);background:linear-gradient(to bottom,var(--global-vibrancy-background),var(--global-vibrancy-background));block-size:var(--field-height);border:0;border-radius:.22rem;box-sizing:border-box;color:inherit;display:block;font-family:inherit;font-size:var(--font-size);inline-size:100%;margin:0;overflow:hidden;padding:0 calc(var(--field-padding)*3.5) 0 var(--field-padding);text-overflow:ellipsis}.Field:disabled{background:linear-gradient(to bottom,var(--global-disabled-background),var(--global-disabled-background));color:var(--global-disabled-foreground);cursor:not-allowed}.Field option{color:#000}.Field optgroup{color:initial}.Field[multiple]{block-size:auto;overflow:auto;padding:.44rem .89rem}.Field[multiple] option{color:currentColor;padding:calc(var(--field-padding)/2) var(--field-padding)}.Field[multiple] option:checked{background:var(--dimmed-4) linear-gradient(to bottom,var(--dimmed-4) 0,var(--dimmed-4) 100%);background-color:var(--dimmed-4);color:var(--dimmed-0)}.Field[multiple] optgroup{color:currentColor;font-family:inherit;font-size:inherit;line-height:inherit;margin:0 0 1rem}.Icon{border-radius:.22rem;pointer-events:none;position:absolute;right:calc(var(--field-padding) - var(--field-padding)/3);top:calc(var(--field-padding) - var(--field-padding)/4)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.Checkbox{--w:24px;--h:24px;-webkit-appearance:none;appearance:none;-webkit-backdrop-filter:saturate(180%) blur(62px);backdrop-filter:saturate(180%) blur(62px);background:
|
|
1
|
+
.Checkbox{--w:24px;--h:24px;-webkit-appearance:none;appearance:none;-webkit-backdrop-filter:saturate(180%) blur(62px);backdrop-filter:saturate(180%) blur(62px);background-color:var(--global-vibrancy-background);block-size:var(--h);border-radius:.22rem;color:var(--global-background);inline-size:var(--w);max-block-size:var(--h);max-inline-size:var(--w);position:relative}.Checkbox:after{block-size:27%;border-bottom:2px solid;border-left:2px solid;content:"";display:none;inline-size:50%;left:50%;position:absolute;top:50%;transform:translate(-50%,-80%) rotate(-45deg)}.Checkbox:active{background-color:var(--global-vibrancy-background-hover)}.Checkbox:checked,.Checkbox[data-control-indeterminate=true]{background:var(--dimmed-7)}.Checkbox:checked:after,.Checkbox[data-control-indeterminate=true]:after{display:block}.Checkbox:disabled{background-color:var(--global-disabled-background);color:var(--global-disabled-foreground);cursor:not-allowed}.Checkbox[data-control-dimension=small]{--w:16px;--h:16px}.Checkbox[data-control-indeterminate=true]:after{block-size:2px;border-left:0;transform:translate(-50%,-50%)}.Radio{composes:Checkbox;border-radius:100%}.Radio:after{background-color:currentColor;block-size:50%;border:0;border-radius:100%;inline-size:50%;transform:translate(-50%,-50%)}.Toggle{--w:44px;--h:24px;--p:2px;composes:Radio;border-radius:200px;color:var(--dimmed-7)}.Toggle:checked{color:var(--global-background)}.Toggle:disabled{color:var(--global-disabled-foreground)}.Toggle:after{block-size:calc(var(--h) - var(--p)*2);bottom:var(--p);display:block;inline-size:calc(var(--h) - var(--p)*2);left:var(--p);top:var(--p);transform:none;transition:transform .1s cubic-bezier(.3,.07,.34,1),background-color .1s cubic-bezier(.3,.07,.34,1)}.Toggle:checked:after{display:block;transform:translateX(100%)}.Toggle[data-control-dimension=small]{--w:28px;--h:16px}
|
package/snackbar/snackbar.d.ts
CHANGED
|
@@ -36,6 +36,6 @@ export declare type SnackbarProps = {
|
|
|
36
36
|
*/
|
|
37
37
|
onDismiss?(): void;
|
|
38
38
|
};
|
|
39
|
-
declare type PolymorphicSnackbar = Polymorphic.ForwardRefComponent<'
|
|
39
|
+
declare type PolymorphicSnackbar = Polymorphic.ForwardRefComponent<'output', SnackbarProps>;
|
|
40
40
|
export declare const Snackbar: PolymorphicSnackbar;
|
|
41
41
|
export {};
|
package/snackbar/snackbar.js
CHANGED
|
@@ -3,7 +3,7 @@ import { forwardRef } from 'react';
|
|
|
3
3
|
import { Snackbar as SnackbarClass, Icon as IconClass, Action } from './snackbar.module.css';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import { Title, Stack, Icon, Button } from '../';
|
|
6
|
-
export const Snackbar = forwardRef(({ children, className, title, icon, kind = 'neutral', as: Wrapper = '
|
|
6
|
+
export const Snackbar = forwardRef(({ children, className, title, icon, kind = 'neutral', as: Wrapper = 'output', dismissable, dismissLabel = 'Dismiss', onDismiss, ...otherProps }, forwardedRef) => {
|
|
7
7
|
const defaultIcons = {
|
|
8
8
|
info: 'circle-info',
|
|
9
9
|
warning: 'triangle-exclamation',
|
|
@@ -11,5 +11,5 @@ export const Snackbar = forwardRef(({ children, className, title, icon, kind = '
|
|
|
11
11
|
positive: 'check',
|
|
12
12
|
danger: 'circle-x'
|
|
13
13
|
};
|
|
14
|
-
return (_jsx(Wrapper, { ref: forwardedRef, className: clsx(SnackbarClass, className), "data-snackbar-kind": kind, role: "
|
|
14
|
+
return (_jsx(Wrapper, { ref: forwardedRef, className: clsx(SnackbarClass, className), "data-snackbar-kind": kind, role: "status", ...otherProps, children: _jsxs(Stack, { verticalAlign: "start", horizontalAlign: "start", direction: "row", columnGap: 16, fill: false, children: [_jsx(Icon, { className: IconClass, name: icon || defaultIcons[kind], dimension: 24 }, void 0), _jsxs(Stack, { rowGap: 16, children: [_jsxs(Stack, { rowGap: 8, children: [title && _jsx(Title, { level: "5", children: title }, void 0), _jsx("p", { children: children }, void 0)] }, void 0), dismissable && (_jsx(Stack, { horizontalAlign: "end", children: _jsx(Button, { onClick: onDismiss, className: Action, children: dismissLabel }, void 0) }, void 0))] }, void 0)] }, void 0) }, void 0));
|
|
15
15
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.Snackbar{background:linear-gradient(to right,var(--snackbar-fg) 4px,var(--snackbar-bg) 4px);border-radius:.22rem;color:var(--snackbar-fg);overflow:hidden;padding:.89rem 1.33rem}.Snackbar p{font-size:.89rem}.Snackbar[data-snackbar-kind=neutral]{--snackbar-bg:var(--highlight-gray-background);--snackbar-fg:var(--highlight-gray-foreground)}.Snackbar[data-snackbar-kind=positive]{--snackbar-bg:var(--highlight-green-background);--snackbar-fg:var(--highlight-green-foreground)}.Snackbar[data-snackbar-kind=warning]{--snackbar-bg:var(--highlight-yellow-background);--snackbar-fg:var(--highlight-yellow-foreground)}.Snackbar[data-snackbar-kind=info]{--snackbar-bg:var(--highlight-blue-background);--snackbar-fg:var(--highlight-blue-foreground)}.Snackbar[data-snackbar-kind=danger]{--snackbar-bg:var(--highlight-red-background);--snackbar-fg:var(--highlight-red-foreground)}.Icon{flex-shrink:0}.Action:is(.Action.Action){background-color:var(--snackbar-fg);color:var(--snackbar-bg)}
|
|
1
|
+
.Snackbar{background:linear-gradient(to right,var(--snackbar-fg) 4px,var(--snackbar-bg) 4px);border-radius:.22rem;color:var(--snackbar-fg);display:block;overflow:hidden;padding:.89rem 1.33rem}.Snackbar p{font-size:.89rem}.Snackbar[data-snackbar-kind=neutral]{--snackbar-bg:var(--highlight-gray-background);--snackbar-fg:var(--highlight-gray-foreground)}.Snackbar[data-snackbar-kind=positive]{--snackbar-bg:var(--highlight-green-background);--snackbar-fg:var(--highlight-green-foreground)}.Snackbar[data-snackbar-kind=warning]{--snackbar-bg:var(--highlight-yellow-background);--snackbar-fg:var(--highlight-yellow-foreground)}.Snackbar[data-snackbar-kind=info]{--snackbar-bg:var(--highlight-blue-background);--snackbar-fg:var(--highlight-blue-foreground)}.Snackbar[data-snackbar-kind=danger]{--snackbar-bg:var(--highlight-red-background);--snackbar-fg:var(--highlight-red-foreground)}.Icon{flex-shrink:0}.Action:is(.Action.Action){background-color:var(--snackbar-fg);color:var(--snackbar-bg)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.BaseField{-webkit-appearance:none;appearance:none;background-color:var(--global-background);block-size:var(--field-height);border:1px solid var(--dimmed-2);border-radius:.22rem;box-sizing:border-box;caret-color:var(--cta-default);color:inherit;display:flex;font-family:inherit;font-size:var(--font-size);inline-size:100%;line-height:1;margin:0;outline-offset:2px;overflow:hidden;padding:0 var(--field-padding);text-overflow:ellipsis}[data-textfield-has-icon=true] .BaseField::-webkit-calendar-picker-indicator{opacity:0;position:absolute;right:calc(var(--field-padding)/2)}.BaseField:-moz-ui-invalid{box-shadow:none}.BaseField::placeholder{color:var(--dimmed-5)}.BaseField.focus-visible{border-color:var(--dimmed-5)}.BaseField:focus-visible{border-color:var(--dimmed-5)}.BaseField:disabled{
|
|
1
|
+
.BaseField{-webkit-appearance:none;appearance:none;background-color:var(--global-background);block-size:var(--field-height);border:1px solid var(--dimmed-2);border-radius:.22rem;box-sizing:border-box;caret-color:var(--cta-default);color:inherit;display:flex;font-family:inherit;font-size:var(--font-size);inline-size:100%;line-height:1;margin:0;outline-offset:2px;overflow:hidden;padding:0 var(--field-padding);text-overflow:ellipsis}[data-textfield-has-icon=true] .BaseField::-webkit-calendar-picker-indicator{opacity:0;position:absolute;right:calc(var(--field-padding)/2)}.BaseField:-moz-ui-invalid{box-shadow:none}.BaseField::placeholder{color:var(--dimmed-5)}.BaseField.focus-visible{border-color:var(--dimmed-5)}.BaseField:focus-visible{border-color:var(--dimmed-5)}.BaseField:disabled{background:linear-gradient(to bottom,var(--global-disabled-background),var(--global-disabled-background));border-color:#0000;color:var(--global-disabled-foreground);cursor:not-allowed}.BaseField:disabled::placeholder{color:var(--dimmed-6)}.BaseField[readonly]{border-style:dashed;box-shadow:none;cursor:default}.BaseField:-webkit-autofill,.BaseField:-webkit-autofill:active,.BaseField:-webkit-autofill:focus,.BaseField:-webkit-autofill:hover{border:1px solid var(--dimmed-2);box-shadow:0 0 0 100px var(--global-background) inset}.BaseField:autofill,.BaseField:autofill:active,.BaseField:autofill:focus,.BaseField:autofill:hover{border:1px solid var(--dimmed-2);box-shadow:0 0 0 100px var(--global-background) inset}.BaseField:is(:invalid,[data-basefield-invalid=true],:out-of-range),.BaseField:is(:invalid,[data-basefield-invalid=true],:out-of-range).focus-visible{border-color:var(--highlight-red-foreground)}.BaseField:is(:invalid,[data-basefield-invalid=true],:out-of-range),.BaseField:is(:invalid,[data-basefield-invalid=true],:out-of-range):focus-visible{border-color:var(--highlight-red-foreground)}.BaseField[type=number]{-webkit-appearance:textfield;appearance:textfield}.BaseField[type=number]::-webkit-inner-spin-button,.BaseField[type=number]::-webkit-outer-spin-button{display:none}.BaseField[type=search]{-webkit-appearance:none;appearance:none}.BaseField[type=search]::-webkit-search-cancel-button,.BaseField[type=search]::-webkit-search-decoration{-webkit-appearance:none;appearance:none}textarea.BaseField{block-size:auto;line-height:1.5;min-block-size:1.78rem;padding:calc(var(--field-padding)/2) calc(var(--field-padding) + .89rem) calc(var(--field-padding)/2) var(--field-padding);resize:vertical}textarea.BaseField::-webkit-datetime-edit-text{opacity:30%}textarea.BaseField::-webkit-calendar-picker-indicator{color:var(--global-foreground)}textarea.BaseField:-moz-ui-invalid{box-shadow:none}textarea.BaseField::-webkit-calendar-picker-indicator:hover{background-color:initial}
|
package/themes/dark.css
CHANGED
package/themes/light.css
CHANGED
package/tooltip/tooltip.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Children, cloneElement, useState } from 'react';
|
|
2
|
+
import { Children, cloneElement, useState, useRef } from 'react';
|
|
3
3
|
import { useUIDSeed } from 'react-uid';
|
|
4
|
-
import { useKeyPress } from 'ahooks';
|
|
4
|
+
import { useKeyPress, useFocusWithin } from 'ahooks';
|
|
5
5
|
import { Elevator } from '../';
|
|
6
|
-
import { useFocusWithin } from '../hooks';
|
|
7
6
|
import { Tooltip as TooltipClass, Arrow, Trigger } from './tooltip.module.css';
|
|
8
7
|
import { usePopperTooltip } from 'react-popper-tooltip';
|
|
9
8
|
export const Tooltip = ({ children, trigger, placement = 'bottom-start', show, style, maxWidth = '40ch', fill = false, interactive = false, delay = 500 }) => {
|
|
10
9
|
const seedID = useUIDSeed();
|
|
11
10
|
const [controlledVisible, setControlledVisible] = useState(false);
|
|
11
|
+
const tooltipContainerRef = useRef(null);
|
|
12
12
|
useKeyPress('esc', () => setControlledVisible(false));
|
|
13
13
|
const { getArrowProps, getTooltipProps, setTooltipRef, setTriggerRef, visible } = usePopperTooltip({
|
|
14
14
|
delayShow: delay,
|
|
15
15
|
delayHide: 300,
|
|
16
|
-
trigger: ['hover'
|
|
16
|
+
trigger: ['hover'],
|
|
17
17
|
visible: show || controlledVisible,
|
|
18
18
|
closeOnTriggerHidden: true,
|
|
19
19
|
interactive: interactive,
|
|
@@ -23,19 +23,18 @@ export const Tooltip = ({ children, trigger, placement = 'bottom-start', show, s
|
|
|
23
23
|
}, {
|
|
24
24
|
strategy: 'fixed'
|
|
25
25
|
});
|
|
26
|
-
const
|
|
27
|
-
|
|
26
|
+
const isFocusWithin = useFocusWithin(tooltipContainerRef, {
|
|
27
|
+
onFocus: () => {
|
|
28
28
|
setControlledVisible(true);
|
|
29
29
|
},
|
|
30
|
-
|
|
31
|
-
setControlledVisible(false);
|
|
32
|
-
}
|
|
33
|
-
onFocusWithinChange: () => null
|
|
30
|
+
onBlur: (e) => {
|
|
31
|
+
(e.target?.parentElement !== tooltipContainerRef.current) && setControlledVisible(false);
|
|
32
|
+
}
|
|
34
33
|
});
|
|
35
34
|
const dynamycStyle = {
|
|
36
35
|
'--maxW': maxWidth
|
|
37
36
|
};
|
|
38
|
-
return (_jsxs("div", { "data-tooltip-fill": fill, className: Trigger,
|
|
37
|
+
return (_jsxs("div", { "data-tooltip-fill": fill, className: Trigger, ref: tooltipContainerRef, "data-tooltip-has-focus-within": isFocusWithin, style: { ...style }, children: [Children.map(trigger, (child) => cloneElement(child, {
|
|
39
38
|
ref: setTriggerRef,
|
|
40
39
|
'aria-describedby': seedID('tooltip-content')
|
|
41
40
|
})), visible && (_jsx(Elevator, { resting: 2, children: _jsxs("div", { ref: setTooltipRef, role: "tooltip", id: seedID('tooltip-content'), "data-theme": "dark", ...getTooltipProps({ className: TooltipClass, style: dynamycStyle }), children: [children, _jsx("div", { ...getArrowProps({ className: Arrow }) }, void 0)] }, void 0) }, void 0))] }, void 0));
|
package/hooks/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useFocusWithin } from './useFocusWithin';
|
package/hooks/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useFocusWithin } from './useFocusWithin';
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { FocusEvent, HTMLAttributes } from 'react';
|
|
2
|
-
interface FocusWithinProps {
|
|
3
|
-
/** Whether the focus within events should be disabled. */
|
|
4
|
-
isDisabled?: boolean;
|
|
5
|
-
/** Handler that is called when the target element or a descendant receives focus. */
|
|
6
|
-
onFocusWithin?: (e: FocusEvent) => void;
|
|
7
|
-
/** Handler that is called when the target element and all descendants lose focus. */
|
|
8
|
-
onBlurWithin?: (e: FocusEvent) => void;
|
|
9
|
-
/** Handler that is called when the the focus within state changes. */
|
|
10
|
-
onFocusWithinChange?: (isFocusWithin: boolean) => void;
|
|
11
|
-
}
|
|
12
|
-
interface FocusWithinResult {
|
|
13
|
-
/** Props to spread onto the target element. */
|
|
14
|
-
focusWithinProps: HTMLAttributes<HTMLElement>;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Handles focus events for the target and its descendants.
|
|
18
|
-
*/
|
|
19
|
-
export declare function useFocusWithin(props: FocusWithinProps): FocusWithinResult;
|
|
20
|
-
export {};
|
package/hooks/useFocusWithin.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { useRef } from 'react';
|
|
2
|
-
export function useFocusWithin(props) {
|
|
3
|
-
const state = useRef({
|
|
4
|
-
isFocusWithin: false
|
|
5
|
-
}).current;
|
|
6
|
-
if (props.isDisabled) {
|
|
7
|
-
return { focusWithinProps: {} };
|
|
8
|
-
}
|
|
9
|
-
const onFocus = (e) => {
|
|
10
|
-
if (!state.isFocusWithin) {
|
|
11
|
-
if (props.onFocusWithin) {
|
|
12
|
-
props.onFocusWithin(e);
|
|
13
|
-
}
|
|
14
|
-
if (props.onFocusWithinChange) {
|
|
15
|
-
props.onFocusWithinChange(true);
|
|
16
|
-
}
|
|
17
|
-
state.isFocusWithin = true;
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
const onBlur = (e) => {
|
|
21
|
-
if (state.isFocusWithin && !e.currentTarget.contains(e.relatedTarget)) {
|
|
22
|
-
if (props.onBlurWithin) {
|
|
23
|
-
props.onBlurWithin(e);
|
|
24
|
-
}
|
|
25
|
-
if (props.onFocusWithinChange) {
|
|
26
|
-
props.onFocusWithinChange(false);
|
|
27
|
-
}
|
|
28
|
-
state.isFocusWithin = false;
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
return {
|
|
32
|
-
focusWithinProps: {
|
|
33
|
-
onFocus: onFocus,
|
|
34
|
-
onBlur: onBlur
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
}
|