@wonderflow/react-components 3.0.0-beta.3 → 3.0.0-beta.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/autocomplete/autocomplete-option.d.ts +39 -0
- package/autocomplete/autocomplete-option.js +11 -0
- package/autocomplete/autocomplete.d.ts +24 -0
- package/autocomplete/autocomplete.js +82 -0
- package/autocomplete/autocomplete.module.css +1 -0
- package/autocomplete/index.d.ts +2 -0
- package/autocomplete/index.js +1 -0
- package/button/button.module.css +1 -1
- package/card/card.module.css +1 -1
- package/core/typography.css +1 -1
- package/core/utils/media.css +19 -1
- package/core/utils/vibrancy.css +0 -24
- package/core.css +1 -1
- package/datetime/datetime.d.ts +7 -0
- package/datetime/datetime.js +16 -0
- package/datetime/index.d.ts +2 -0
- package/datetime/index.js +1 -0
- package/drawer/drawer.d.ts +85 -0
- package/drawer/drawer.js +34 -0
- package/drawer/drawer.module.css +1 -0
- package/drawer/index.d.ts +2 -0
- package/drawer/index.js +1 -0
- package/dropdown/dropdown.d.ts +25 -11
- package/dropdown/dropdown.js +36 -24
- package/dropdown/dropdown.module.css +1 -1
- package/dropdown/index.d.ts +0 -2
- package/icon/icon.d.ts +1 -1
- package/index.d.ts +11 -3
- package/index.js +6 -2
- package/input-group/input-group.js +3 -3
- package/list/list.js +2 -2
- package/list/list.module.css +1 -1
- 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} +23 -10
- package/menu/menu-item/menu-item.js +23 -0
- package/menu/menu-item/menu-item.module.css +1 -0
- package/menu/menu.d.ts +16 -0
- package/menu/menu.js +15 -0
- package/menu/menu.module.css +1 -0
- package/modal/content/modal-content.js +4 -3
- package/modal/content/modal-content.module.css +1 -1
- package/modal/index.d.ts +0 -1
- package/modal/index.js +0 -1
- package/modal/modal.d.ts +0 -10
- package/modal/modal.js +24 -7
- package/modal/modal.module.css +1 -1
- package/overlay-container/index.d.ts +1 -0
- package/overlay-container/index.js +1 -0
- package/overlay-container/overlay-container.d.ts +14 -0
- package/overlay-container/overlay-container.js +8 -4
- package/overlay-container/overlay-container.module.css +1 -0
- package/overlay-container/overlay-context.d.ts +9 -0
- package/overlay-container/overlay-context.js +23 -0
- package/package.json +65 -22
- package/select/select.js +2 -2
- 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/split-button/split-button.module.css +1 -1
- package/stack/stack.d.ts +3 -2
- package/stack/stack.module.css +1 -1
- package/star-meter/star-meter.d.ts +4 -0
- package/star-meter/star-meter.js +4 -4
- package/table/index.d.ts +1 -0
- package/text/text.d.ts +5 -0
- package/text/text.js +2 -2
- package/text/text.module.css +1 -1
- package/textfield/base-field/base-field.d.ts +1 -1
- package/textfield/base-field/base-field.module.css +1 -1
- package/textfield/textfield.d.ts +2 -2
- package/textfield/textfield.js +9 -8
- package/themes/dark.css +1 -1
- package/themes/light.css +1 -1
- package/title/title.js +1 -1
- package/title/title.module.css +1 -1
- package/tooltip/tooltip.d.ts +1 -1
- package/tooltip/tooltip.js +19 -19
- 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/modal/modal-context.d.ts +0 -9
- package/modal/modal-context.js +0 -23
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { MenuItemProps } from '..';
|
|
2
|
+
import { PropsWithChildren } from 'react';
|
|
3
|
+
import { Except } from 'type-fest';
|
|
4
|
+
export declare type AutocompleteOptionProps = PropsWithChildren<PropsWithClass> & Except<MenuItemProps, 'padding' | 'autoFocus' | 'description' | 'onClick'> & {
|
|
5
|
+
/**
|
|
6
|
+
* Value of the option.
|
|
7
|
+
* This is the value that will be passed to the `onChange` callback.
|
|
8
|
+
*/
|
|
9
|
+
value: string;
|
|
10
|
+
/**
|
|
11
|
+
* Callback called when the option is clicked.
|
|
12
|
+
* It passes the value and the inner text of the option as arguments.
|
|
13
|
+
*/
|
|
14
|
+
onClick?(value?: string, content?: string): void;
|
|
15
|
+
/**
|
|
16
|
+
* Label of the option. This is the text that will be displayed in the option, which can be
|
|
17
|
+
* different from the value.
|
|
18
|
+
*/
|
|
19
|
+
children: string;
|
|
20
|
+
};
|
|
21
|
+
export declare const AutocompleteOption: import("react").ForwardRefExoticComponent<PropsWithClass & {
|
|
22
|
+
children?: import("react").ReactNode;
|
|
23
|
+
} & Except<MenuItemProps, "description" | "onClick" | "autoFocus" | "padding"> & {
|
|
24
|
+
/**
|
|
25
|
+
* Value of the option.
|
|
26
|
+
* This is the value that will be passed to the `onChange` callback.
|
|
27
|
+
*/
|
|
28
|
+
value: string;
|
|
29
|
+
/**
|
|
30
|
+
* Callback called when the option is clicked.
|
|
31
|
+
* It passes the value and the inner text of the option as arguments.
|
|
32
|
+
*/
|
|
33
|
+
onClick?(value?: string | undefined, content?: string | undefined): void;
|
|
34
|
+
/**
|
|
35
|
+
* Label of the option. This is the text that will be displayed in the option, which can be
|
|
36
|
+
* different from the value.
|
|
37
|
+
*/
|
|
38
|
+
children: string;
|
|
39
|
+
} & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Menu } from '..';
|
|
3
|
+
import { forwardRef, useCallback, useRef } from 'react';
|
|
4
|
+
export const AutocompleteOption = forwardRef(({ children, value, onClick, ...otherProps }, forwardedRef) => {
|
|
5
|
+
const contentRef = useRef(null);
|
|
6
|
+
const handleClick = useCallback(() => {
|
|
7
|
+
onClick && onClick(value, contentRef?.current?.innerText);
|
|
8
|
+
}, [onClick, value]);
|
|
9
|
+
return (_jsx(Menu.Item, { ref: forwardedRef, role: "option", padding: false, onClick: handleClick, ...otherProps, children: _jsx("span", { ref: contentRef, children: children }, void 0) }, void 0));
|
|
10
|
+
});
|
|
11
|
+
AutocompleteOption.displayName = 'Autocomplete.Option';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AutocompleteOptionProps } from './autocomplete-option';
|
|
2
|
+
import { ForwardRefExoticComponent, ReactNode } from 'react';
|
|
3
|
+
import { TextfieldProps } from '..';
|
|
4
|
+
export declare type AutocompleteProps = TextfieldProps & {
|
|
5
|
+
/**
|
|
6
|
+
* The callback called when an option is picked from the list
|
|
7
|
+
*/
|
|
8
|
+
onChange?(value?: string): void;
|
|
9
|
+
/**
|
|
10
|
+
* Set the maximum height of the options list after which
|
|
11
|
+
* it will scroll.
|
|
12
|
+
*/
|
|
13
|
+
maxHeight?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Custom empty message to display when there are no options or
|
|
16
|
+
* when the value does not match any of the options.
|
|
17
|
+
*/
|
|
18
|
+
emptyMessage?: ReactNode;
|
|
19
|
+
};
|
|
20
|
+
declare type AutocompleteComponent = ForwardRefExoticComponent<AutocompleteProps> & {
|
|
21
|
+
Option: ForwardRefExoticComponent<AutocompleteOptionProps>;
|
|
22
|
+
};
|
|
23
|
+
export declare const Autocomplete: AutocompleteComponent;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { AnimatePresence, motion } from 'framer-motion';
|
|
3
|
+
import { AutocompleteOption } from './autocomplete-option';
|
|
4
|
+
import { Children, cloneElement, forwardRef, useCallback, useMemo, useRef, useState, useEffect } from 'react';
|
|
5
|
+
import { useDebounce, useFocusWithin, useKeyPress, useSize } from 'ahooks';
|
|
6
|
+
import { Text, Menu, Textfield } from '..';
|
|
7
|
+
import { Autocomplete as AutocompleteClass, OptionsList, PopUp } from './autocomplete.module.css';
|
|
8
|
+
import { usePopperTooltip } from 'react-popper-tooltip';
|
|
9
|
+
import { useUIDSeed } from 'react-uid';
|
|
10
|
+
const AutocompleteAnimation = {
|
|
11
|
+
visible: {
|
|
12
|
+
y: 0,
|
|
13
|
+
opacity: 1,
|
|
14
|
+
transition: {
|
|
15
|
+
ease: [0, 0, 0.34, 1],
|
|
16
|
+
duration: 0.1
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
hidden: {
|
|
20
|
+
y: -5,
|
|
21
|
+
opacity: 0,
|
|
22
|
+
transition: {
|
|
23
|
+
ease: [0.3, 0.07, 1, 1],
|
|
24
|
+
duration: 0.1
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
export const Autocomplete = forwardRef(({ children, onChange, disabled, readOnly, value, maxHeight = '200px', emptyMessage = 'No results found', ...otherProps }, forwardedRef) => {
|
|
29
|
+
const seedID = useUIDSeed();
|
|
30
|
+
const autocompleteRef = useRef(forwardedRef);
|
|
31
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
32
|
+
const [content, setContent] = useState(value ? String(value) : '');
|
|
33
|
+
const isInteractive = useMemo(() => !disabled && !readOnly, [disabled, readOnly]);
|
|
34
|
+
const debouncedFieldContent = useDebounce(content, { wait: 100 });
|
|
35
|
+
const filteredOptions = useMemo(() => {
|
|
36
|
+
const items = Children.toArray(children);
|
|
37
|
+
return debouncedFieldContent
|
|
38
|
+
? items.filter((o) => {
|
|
39
|
+
const stringToMatch = typeof o.props.children === 'string' ? o.props.children : o.props.children.join('');
|
|
40
|
+
return stringToMatch?.toLowerCase().includes(debouncedFieldContent.toLowerCase());
|
|
41
|
+
})
|
|
42
|
+
: items;
|
|
43
|
+
}, [debouncedFieldContent, children]);
|
|
44
|
+
const isFocusWithin = useFocusWithin(autocompleteRef, {
|
|
45
|
+
onChange: (isFocusWithin) => {
|
|
46
|
+
isFocusWithin ? setIsOpen(true) : setIsOpen(false);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
useKeyPress('esc', () => setIsOpen(false));
|
|
50
|
+
const { getTooltipProps, setTooltipRef, setTriggerRef, triggerRef, visible } = usePopperTooltip({
|
|
51
|
+
delayShow: 0,
|
|
52
|
+
delayHide: 0,
|
|
53
|
+
trigger: null,
|
|
54
|
+
visible: isInteractive ? isOpen : false,
|
|
55
|
+
closeOnTriggerHidden: true,
|
|
56
|
+
placement: 'bottom-start',
|
|
57
|
+
offset: [0, 8],
|
|
58
|
+
interactive: true
|
|
59
|
+
});
|
|
60
|
+
const triggerSize = useSize(triggerRef);
|
|
61
|
+
const handleOptionClick = useCallback((optionValue, optionContent) => {
|
|
62
|
+
setContent(optionContent);
|
|
63
|
+
setIsOpen(false);
|
|
64
|
+
onChange && onChange(optionValue);
|
|
65
|
+
}, [onChange]);
|
|
66
|
+
const handleFilter = useCallback(({ currentTarget }) => {
|
|
67
|
+
setContent(currentTarget.value);
|
|
68
|
+
}, []);
|
|
69
|
+
const dynamicStyle = {
|
|
70
|
+
'--max-h': maxHeight
|
|
71
|
+
};
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
value && setContent(String(value));
|
|
74
|
+
}, [value]);
|
|
75
|
+
return (_jsxs("div", { ref: autocompleteRef, className: AutocompleteClass, "data-focus-within": isFocusWithin, children: [_jsx(Textfield, { ref: setTriggerRef, id: seedID('autocomplete-trigger'), "aria-haspopup": "true", "aria-controls": seedID('autocomplete-menu'), "aria-expanded": isOpen, onChange: handleFilter, value: content, autoComplete: "off", disabled: disabled, readOnly: readOnly, ...otherProps }, seedID('autocomplete-trigger')), _jsx(AnimatePresence, { children: visible && (_jsx("div", { ref: setTooltipRef, ...getTooltipProps({ className: PopUp, style: { minInlineSize: triggerSize ? (triggerSize.width + 2) : 'auto' } }), children: _jsx(motion.div, { variants: AutocompleteAnimation, initial: "hidden", animate: "visible", exit: "hidden", children: _jsx(Menu, { role: "listbox", id: seedID('autocomplete-menu'), className: OptionsList, style: dynamicStyle, "aria-labelledby": seedID('autocomplete-trigger'), children: filteredOptions.length === 0
|
|
76
|
+
? _jsx(Text, { as: "div", textAlign: "center", dimmed: 5, children: emptyMessage }, void 0)
|
|
77
|
+
: Children.map(filteredOptions, (child) => cloneElement(child, {
|
|
78
|
+
onClick: handleOptionClick
|
|
79
|
+
})) }, void 0) }, void 0) }, void 0)) }, void 0)] }, void 0));
|
|
80
|
+
});
|
|
81
|
+
Autocomplete.Option = AutocompleteOption;
|
|
82
|
+
Autocomplete.displayName = 'Autocomplete';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.Autocomplete{display:contents}.PopUp{z-index:2}.OptionsList{-webkit-overflow-scrolling:touch;max-block-size:var(--max-h);overflow:auto;overscroll-behavior:contain}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Autocomplete } from './autocomplete';
|
package/button/button.module.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.Button{-webkit-touch-callout:none;grid-gap:.44rem;align-items:center;-webkit-appearance:none;appearance:none;background:none;border:0;border-radius:.22rem;box-sizing:border-box;cursor:pointer;display:inline-flex;font-family:inherit;font-weight:600;justify-content:center;margin:0;min-inline-size:min-content;overflow:hidden;position:relative;text-decoration:none;-webkit-user-select:none;user-select:none;white-space:nowrap}.Button[data-button-dimension=big]{block-size:2.67rem;font-size:1rem;padding:.55rem 1.33rem .66rem}.Button[data-button-dimension=regular]{block-size:2.22rem;font-size:.89rem;padding:.33rem .89rem .44rem}.Button[data-button-dimension=small]{grid-gap:.22rem;block-size:1.33rem;font-size:.78rem;padding:0 .22rem .11rem}.Button[data-button-kind=primary]{background:var(--cta-default);color:var(--cta-foreground)}.Button[data-button-kind=primary]:not([aria-pressed=true],[aria-disabled=true]):is(:active){background:var(--cta-dark)}.Button[data-button-kind=primary]:where([aria-pressed=true]),.Button[data-button-kind=primary]:where([aria-pressed=true]:active){background:#9e0018;color:#fff}.Button[data-button-kind=secondary]{-webkit-backdrop-filter:saturate(180%) blur(62px);backdrop-filter:saturate(180%) blur(62px);background:
|
|
1
|
+
.Button{-webkit-touch-callout:none;grid-gap:.44rem;align-items:center;-webkit-appearance:none;appearance:none;background:none;border:0;border-radius:.22rem;box-sizing:border-box;cursor:pointer;display:inline-flex;font-family:inherit;font-weight:600;justify-content:center;margin:0;min-inline-size:min-content;overflow:hidden;position:relative;text-decoration:none;-webkit-user-select:none;user-select:none;white-space:nowrap}.Button[data-button-dimension=big]{block-size:2.67rem;font-size:1rem;padding:.55rem 1.33rem .66rem}.Button[data-button-dimension=regular]{block-size:2.22rem;font-size:.89rem;padding:.33rem .89rem .44rem}.Button[data-button-dimension=small]{grid-gap:.22rem;block-size:1.33rem;font-size:.78rem;padding:0 .22rem .11rem}.Button[data-button-kind=primary]{background:var(--cta-default);color:var(--cta-foreground)}.Button[data-button-kind=primary]:not([aria-pressed=true],[aria-disabled=true]):is(:active){background:var(--cta-dark)}.Button[data-button-kind=primary]:where([aria-pressed=true]),.Button[data-button-kind=primary]:where([aria-pressed=true]:active){background:#9e0018;color:#fff}.Button[data-button-kind=secondary]{-webkit-backdrop-filter:saturate(180%) blur(62px);backdrop-filter:saturate(180%) blur(62px);background-color:var(--global-vibrancy-background);color:var(--global-vibrancy-foreground)}.Button[data-button-kind=secondary]:not([aria-pressed=true],[aria-disabled=true]):is(:active){background-color:var(--global-vibrancy-background-hover);color:var(--global-vibrancy-foreground)}.Button[data-button-kind=secondary]:where([aria-pressed=true]),.Button[data-button-kind=secondary]:where([aria-pressed=true]:active){background:var(--dimmed-7);color:var(--dimmed-0)}.Button[data-button-kind=flat]{color:var(--global-vibrancy-foreground)}.Button[data-button-kind=flat]:not([aria-pressed=true],[aria-disabled=true]):is(:active){background-color:var(--global-vibrancy-background-hover)}.Button[data-button-kind=flat]:is(:hover,:focus){-webkit-backdrop-filter:saturate(180%) blur(62px);backdrop-filter:saturate(180%) blur(62px);background-color:var(--global-vibrancy-background);color:var(--global-vibrancy-foreground)}.Button[data-button-kind=flat]:where([aria-pressed=true]),.Button[data-button-kind=flat]:where([aria-pressed=true]:is(:active,:focus)){background:var(--dimmed-7);color:var(--dimmed-0)}.Button[data-button-fullwidth=true]{inline-size:100%}.Button[data-button-icon-position=right]{flex-direction:row-reverse}.Button[aria-disabled=true],.Button[aria-disabled=true]:is(:hover,:focus,:active){background-color:var(--global-disabled-background);color:var(--global-disabled-foreground);cursor:not-allowed}.Button[aria-busy=true]>:not(.SpinnerIndicator){visibility:hidden}.SpinnerIndicator{align-content:center;bottom:0;display:grid;justify-content:center;left:0;place-content:center;position:absolute;right:0;top:0}.ButtonsGroup{display:inline-flex}.ButtonsGroup>:not(:first-child,:last-child,:only-of-type){border-radius:0}.ButtonsGroup>:first-child:not(:only-of-type){border-bottom-right-radius:0;border-top-right-radius:0;box-shadow:inset -1px 0 0 #6666661a}.ButtonsGroup>:last-child:not(:only-of-type){border-bottom-left-radius:0;border-top-left-radius:0;box-shadow:inset 1px 0 0 #6666661a}
|
package/card/card.module.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
:where(.Card){background:var(--global-background);border-radius:var(--radius);padding:var(--padding);position:relative}
|
|
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/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/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
|
}
|
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}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { HTMLAttributes } from 'react';
|
|
2
|
+
export declare type DatetimeProps = HTMLAttributes<HTMLTimeElement> & {
|
|
3
|
+
date: string;
|
|
4
|
+
locale?: string | string[];
|
|
5
|
+
options?: Intl.DateTimeFormatOptions;
|
|
6
|
+
};
|
|
7
|
+
export declare const Datetime: ({ date, locale, options, ...otherProps }: DatetimeProps) => JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
export const Datetime = ({ date, locale = 'en-US', options, ...otherProps }) => {
|
|
4
|
+
const [datetime, setDateTime] = useState('');
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
const timeDate = new Date(date);
|
|
7
|
+
const humanDate = new Intl.DateTimeFormat(locale, {
|
|
8
|
+
year: 'numeric',
|
|
9
|
+
month: 'long',
|
|
10
|
+
day: 'numeric',
|
|
11
|
+
...options
|
|
12
|
+
}).format(timeDate);
|
|
13
|
+
setDateTime(humanDate);
|
|
14
|
+
}, [date, locale, options]);
|
|
15
|
+
return (_jsx("time", { dateTime: date, ...otherProps, children: datetime }, void 0));
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Datetime } from './datetime';
|
|
@@ -0,0 +1,85 @@
|
|
|
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
|
+
* @important This property is considered only when `isModal` is `true`.
|
|
9
|
+
*/
|
|
10
|
+
closeOnClickOutside?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Set the accessible title of the drawer. This is used by screen readers to
|
|
13
|
+
* announce the title of the drawer when opened.
|
|
14
|
+
*/
|
|
15
|
+
title?: ReactNode;
|
|
16
|
+
/**
|
|
17
|
+
* Hide or show the drawer header which includes the title and the close button.
|
|
18
|
+
* If you hide the title, make sure to add yuor own title element in order
|
|
19
|
+
* to provide an accessible label to the drawer.
|
|
20
|
+
*/
|
|
21
|
+
showHeader?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Set the maximum width of the drawer, on mobile the drawer will be
|
|
24
|
+
* automatically collapsed when the width is reached.
|
|
25
|
+
*/
|
|
26
|
+
maxWidth?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Set the theme of the content card. To ensure contrast with the default overlay color (dark),
|
|
29
|
+
* this is set to `light` by default.
|
|
30
|
+
*/
|
|
31
|
+
theme?: 'dark' | 'light' | 'auto';
|
|
32
|
+
/**
|
|
33
|
+
* Set the side on which the drawer will be positioned.
|
|
34
|
+
*/
|
|
35
|
+
side?: 'left' | 'right';
|
|
36
|
+
/**
|
|
37
|
+
* Disable the modal behavior of the drawer.
|
|
38
|
+
* If `false`, disable the prop `closeOnClickOutside` and
|
|
39
|
+
* the page is not blocked when the drawer is open.
|
|
40
|
+
*/
|
|
41
|
+
isModal?: boolean;
|
|
42
|
+
};
|
|
43
|
+
export declare const Drawer: import("react").ForwardRefExoticComponent<PropsWithClass & {
|
|
44
|
+
children?: ReactNode;
|
|
45
|
+
} & {
|
|
46
|
+
/**
|
|
47
|
+
* This enable the drawer to be closed by clicking on the overlay.
|
|
48
|
+
* Even if this can be set to `false` we strongly recommend to leave
|
|
49
|
+
* it to `true` as it ensures the accessibility of the drawer.
|
|
50
|
+
*
|
|
51
|
+
* @important This property is considered only when `isModal` is `true`.
|
|
52
|
+
*/
|
|
53
|
+
closeOnClickOutside?: boolean | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Set the accessible title of the drawer. This is used by screen readers to
|
|
56
|
+
* announce the title of the drawer when opened.
|
|
57
|
+
*/
|
|
58
|
+
title?: ReactNode;
|
|
59
|
+
/**
|
|
60
|
+
* Hide or show the drawer header which includes the title and the close button.
|
|
61
|
+
* If you hide the title, make sure to add yuor own title element in order
|
|
62
|
+
* to provide an accessible label to the drawer.
|
|
63
|
+
*/
|
|
64
|
+
showHeader?: boolean | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Set the maximum width of the drawer, on mobile the drawer will be
|
|
67
|
+
* automatically collapsed when the width is reached.
|
|
68
|
+
*/
|
|
69
|
+
maxWidth?: string | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Set the theme of the content card. To ensure contrast with the default overlay color (dark),
|
|
72
|
+
* this is set to `light` by default.
|
|
73
|
+
*/
|
|
74
|
+
theme?: "auto" | "light" | "dark" | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* Set the side on which the drawer will be positioned.
|
|
77
|
+
*/
|
|
78
|
+
side?: "left" | "right" | undefined;
|
|
79
|
+
/**
|
|
80
|
+
* Disable the modal behavior of the drawer.
|
|
81
|
+
* If `false`, disable the prop `closeOnClickOutside` and
|
|
82
|
+
* the page is not blocked when the drawer is open.
|
|
83
|
+
*/
|
|
84
|
+
isModal?: boolean | undefined;
|
|
85
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
package/drawer/drawer.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
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, AutoFocusInside } from 'react-focus-on';
|
|
6
|
+
import { useKeyPress } from 'ahooks';
|
|
7
|
+
import { Drawer as DrawerClass, Container, Content, Header, CloseButton } from './drawer.module.css';
|
|
8
|
+
import { useOverlayContext } from '../overlay-container';
|
|
9
|
+
import { Elevator, IconButton, Stack, Title } from '../';
|
|
10
|
+
export const Drawer = forwardRef(({ children, className, closeOnClickOutside = true, showHeader = true, maxWidth = '400px', side = 'right', theme = 'light', isModal = true, title, ...otherProps }, forwardedRef) => {
|
|
11
|
+
const { titleId, onClose } = useOverlayContext();
|
|
12
|
+
useKeyPress('esc', () => (!isModal && onClose) && onClose());
|
|
13
|
+
const dynamicStyle = {
|
|
14
|
+
'--max-w': maxWidth
|
|
15
|
+
};
|
|
16
|
+
const DrawerAnimation = {
|
|
17
|
+
visible: {
|
|
18
|
+
x: 0,
|
|
19
|
+
transition: {
|
|
20
|
+
ease: [0, 0, 0.34, 1],
|
|
21
|
+
duration: 0.35
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
hidden: {
|
|
25
|
+
x: side === 'right' ? '100%' : '-100%',
|
|
26
|
+
transition: {
|
|
27
|
+
ease: [0.3, 0.07, 1, 1],
|
|
28
|
+
duration: 0.2
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
return (_jsx("div", { role: "dialog", "aria-modal": isModal, "data-theme": theme, "aria-labelledby": titleId, className: clsx(DrawerClass, className), ref: forwardedRef, ...otherProps, children: _jsx(FocusOn, { enabled: isModal, onClickOutside: closeOnClickOutside ? onClose : undefined, 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)), _jsx(AutoFocusInside, { children: children }, void 0)] }, void 0) }, void 0) }, void 0) }, void 0) }, void 0));
|
|
33
|
+
});
|
|
34
|
+
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.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,52 +1,64 @@
|
|
|
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 { useFocusWithin } from '@react-aria/interactions';
|
|
8
|
-
import { DropdownMenu } from './menu/dropdown-menu';
|
|
9
|
-
import { DropdownItem } from './item/dropdown-item';
|
|
10
|
-
import { DropdownItemCheckbox } from './item-checkbox/dropdown-item-checkbox';
|
|
11
6
|
import { usePopperTooltip } from 'react-popper-tooltip';
|
|
12
7
|
import { AnimatePresence, motion } from 'framer-motion';
|
|
13
|
-
|
|
8
|
+
import clsx from 'clsx';
|
|
9
|
+
const DropdownAnimation = {
|
|
10
|
+
visible: {
|
|
11
|
+
y: 0,
|
|
12
|
+
opacity: 1,
|
|
13
|
+
transition: {
|
|
14
|
+
ease: [0, 0, 0.34, 1],
|
|
15
|
+
duration: 0.1
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
hidden: {
|
|
19
|
+
y: -5,
|
|
20
|
+
opacity: 0,
|
|
21
|
+
transition: {
|
|
22
|
+
ease: [0.3, 0.07, 1, 1],
|
|
23
|
+
duration: 0.1
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
export const Dropdown = forwardRef(({ children, trigger, offset = 8, placement = 'auto-start', className, ...otherProps }, forwardedRef) => {
|
|
14
28
|
const renderedChildren = Children.toArray(children).filter(Boolean);
|
|
15
29
|
const seedID = useUIDSeed();
|
|
16
|
-
const
|
|
30
|
+
const dropdownRef = useRef(forwardedRef);
|
|
17
31
|
const [isOpen, setIsOpen] = useState(false);
|
|
18
32
|
const { getTooltipProps, setTooltipRef, setTriggerRef, visible } = usePopperTooltip({
|
|
19
33
|
delayShow: 0,
|
|
20
|
-
delayHide:
|
|
34
|
+
delayHide: 0,
|
|
21
35
|
trigger: ['click'],
|
|
22
36
|
visible: isOpen,
|
|
23
37
|
closeOnTriggerHidden: true,
|
|
24
38
|
onVisibleChange: setIsOpen,
|
|
25
39
|
placement: placement,
|
|
26
40
|
offset: [0, offset],
|
|
27
|
-
closeOnOutsideClick:
|
|
41
|
+
closeOnOutsideClick: true
|
|
28
42
|
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
onFocusWithinChange: () => null
|
|
43
|
+
const isFocusWithin = useFocusWithin(dropdownRef, {
|
|
44
|
+
onBlur: (e) => {
|
|
45
|
+
if (e.relatedTarget && visible) {
|
|
46
|
+
setIsOpen(false);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
36
49
|
});
|
|
37
50
|
useKeyPress('esc', () => setIsOpen(false));
|
|
38
|
-
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, {
|
|
39
52
|
ref: setTriggerRef,
|
|
40
53
|
id: seedID('dropdown-trigger'),
|
|
54
|
+
key: seedID('dropdown-trigger'),
|
|
41
55
|
'aria-haspopup': 'true',
|
|
42
56
|
'aria-controls': seedID('dropdown-menu'),
|
|
43
|
-
'aria-expanded': isOpen
|
|
44
|
-
|
|
57
|
+
'aria-expanded': isOpen,
|
|
58
|
+
...otherProps
|
|
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, {
|
|
45
60
|
id: seedID('dropdown-menu'),
|
|
46
61
|
'aria-labelledby': seedID('dropdown-trigger')
|
|
47
|
-
})) }, void 0) },
|
|
62
|
+
})) }, void 0) }, seedID('tooltip-content'))) }, void 0)] }, void 0));
|
|
48
63
|
});
|
|
49
64
|
Dropdown.displayName = 'Dropdown';
|
|
50
|
-
Dropdown.Menu = DropdownMenu;
|
|
51
|
-
Dropdown.Item = DropdownItem;
|
|
52
|
-
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/icon/icon.d.ts
CHANGED
|
@@ -33,5 +33,5 @@ export declare const Icon: import("react").ForwardRefExoticComponent<SVGAttribut
|
|
|
33
33
|
* Icons sized 16pt or less are displayed with the solid style.
|
|
34
34
|
* If the size is 24pt or larger, the icon is displayed with the outline style.
|
|
35
35
|
*/
|
|
36
|
-
dimension?:
|
|
36
|
+
dimension?: 14 | 16 | 24 | 32 | 40 | 48 | 56 | undefined;
|
|
37
37
|
} & import("react").RefAttributes<SVGSVGElement>>;
|