@efolusi/meridian 1.19.1 → 1.21.0
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/README.md +1 -1
- package/ai/Bubble.d.ts +16 -0
- package/ai/Bubble.js +71 -0
- package/ai/ChatMessage.js +2 -5
- package/ai/Confirmation.d.ts +0 -7
- package/ai/Confirmation.js +3 -6
- package/ai/GeneratedImage.d.ts +0 -2
- package/ai/GeneratedImage.js +2 -4
- package/ai/Marker.d.ts +26 -0
- package/ai/Marker.js +67 -0
- package/ai/Message.d.ts +13 -0
- package/ai/Message.js +68 -0
- package/ai/MessageScroller.d.ts +21 -0
- package/ai/MessageScroller.js +283 -0
- package/ai/ModelSelector.d.ts +2 -2
- package/ai/ModelSelector.js +1 -2
- package/ai/Player.js +1 -1
- package/ai/PromptSteps.js +4 -2
- package/ai/Sandbox.d.ts +0 -2
- package/ai/Sandbox.js +2 -4
- package/ai/Suggestions.d.ts +0 -2
- package/ai/Suggestions.js +1 -4
- package/ai/WebPreview.d.ts +0 -2
- package/ai/WebPreview.js +2 -4
- package/code/Console.js +1 -1
- package/code/EnvList.d.ts +0 -2
- package/code/EnvList.js +2 -3
- package/components.css +660 -423
- package/data/BarChart.d.ts +0 -2
- package/data/BarChart.js +1 -4
- package/data/Chart.d.ts +14 -0
- package/data/Chart.js +149 -0
- package/data/EmptyState.d.ts +8 -13
- package/data/EmptyState.js +62 -24
- package/data/LineChart.js +7 -4
- package/data/Skeleton.d.ts +2 -11
- package/data/Skeleton.js +8 -38
- package/data/Sparkline.js +4 -1
- package/data/StatusDot.d.ts +0 -4
- package/data/StatusDot.js +3 -6
- package/data/Table.d.ts +11 -4
- package/data/Table.js +39 -7
- package/dates/Calendar.d.ts +10 -27
- package/dates/Calendar.js +250 -184
- package/dates/TimePicker.js +2 -2
- package/display/Accordion.d.ts +47 -15
- package/display/Accordion.js +257 -27
- package/display/AspectRatio.d.ts +4 -6
- package/display/AspectRatio.js +7 -5
- package/display/Avatar.d.ts +17 -14
- package/display/Avatar.js +68 -43
- package/display/Badge.d.ts +9 -8
- package/display/Badge.js +32 -14
- package/display/Card.d.ts +11 -13
- package/display/Card.js +74 -29
- package/display/Carousel.d.ts +23 -15
- package/display/Carousel.js +217 -66
- package/display/Collapsible.d.ts +19 -9
- package/display/Collapsible.js +140 -28
- package/display/Direction.d.ts +10 -0
- package/display/Direction.js +24 -0
- package/display/Item.d.ts +19 -0
- package/display/Item.js +152 -0
- package/display/Kbd.d.ts +5 -7
- package/display/Kbd.js +22 -10
- package/display/Link.js +2 -4
- package/display/Resizable.d.ts +6 -16
- package/display/Resizable.js +141 -58
- package/display/ScrollArea.d.ts +3 -1
- package/display/ScrollArea.js +30 -5
- package/display/Separator.d.ts +9 -0
- package/display/Separator.js +18 -0
- package/display/Timeline.d.ts +24 -0
- package/display/Timeline.js +51 -0
- package/display/Toolbar.js +5 -4
- package/display/TreeList.d.ts +0 -2
- package/display/TreeList.js +2 -5
- package/feedback/Alert.d.ts +13 -13
- package/feedback/Alert.js +40 -36
- package/feedback/AlertDialog.d.ts +30 -0
- package/feedback/AlertDialog.js +249 -0
- package/feedback/Banner.d.ts +1 -3
- package/feedback/Banner.js +1 -5
- package/feedback/ConfirmDialog.d.ts +1 -1
- package/feedback/ConfirmDialog.js +18 -20
- package/feedback/Dialog.d.ts +13 -16
- package/feedback/Dialog.js +204 -62
- package/feedback/Progress.d.ts +8 -9
- package/feedback/Progress.js +42 -24
- package/feedback/Sonner.d.ts +8 -0
- package/feedback/Sonner.js +238 -0
- package/feedback/Spinner.d.ts +2 -9
- package/feedback/Spinner.js +19 -28
- package/feedback/Tooltip.d.ts +9 -10
- package/feedback/Tooltip.js +147 -96
- package/files/Attachment.d.ts +27 -0
- package/files/Attachment.js +111 -0
- package/files/FileDrop.js +3 -1
- package/finance/PaymentCard.js +3 -3
- package/forms/Button.d.ts +6 -5
- package/forms/Button.js +42 -8
- package/forms/ButtonGroup.d.ts +11 -3
- package/forms/ButtonGroup.js +57 -6
- package/forms/Checkbox.d.ts +14 -3
- package/forms/Checkbox.js +84 -16
- package/forms/Combobox.d.ts +24 -16
- package/forms/Combobox.js +466 -135
- package/forms/Field.d.ts +14 -0
- package/forms/Field.js +99 -0
- package/forms/IconButton.d.ts +1 -1
- package/forms/IconButton.js +4 -3
- package/forms/Input.d.ts +8 -8
- package/forms/Input.js +46 -33
- package/forms/InputGroup.d.ts +8 -15
- package/forms/InputGroup.js +74 -35
- package/forms/InputOTP.d.ts +13 -0
- package/forms/InputOTP.js +125 -0
- package/forms/Label.d.ts +2 -6
- package/forms/Label.js +6 -4
- package/forms/NativeSelect.d.ts +16 -0
- package/forms/NativeSelect.js +35 -0
- package/forms/NumberInput.js +2 -2
- package/forms/Radio.d.ts +12 -1
- package/forms/Radio.js +76 -6
- package/forms/Select.d.ts +12 -9
- package/forms/Select.js +254 -42
- package/forms/Slider.d.ts +10 -17
- package/forms/Slider.js +78 -39
- package/forms/Switch.d.ts +8 -2
- package/forms/Switch.js +46 -15
- package/forms/Textarea.d.ts +1 -1
- package/forms/Textarea.js +26 -18
- package/forms/Toggle.d.ts +18 -15
- package/forms/Toggle.js +96 -42
- package/icons/_svg.js +2 -0
- package/index.d.ts +20 -8
- package/index.js +50 -38
- package/navigation/Breadcrumbs.d.ts +18 -11
- package/navigation/Breadcrumbs.js +99 -26
- package/navigation/Menubar.d.ts +52 -10
- package/navigation/Menubar.js +191 -146
- package/navigation/NavigationMenu.d.ts +15 -0
- package/navigation/NavigationMenu.js +296 -0
- package/navigation/Pagination.d.ts +10 -9
- package/navigation/Pagination.js +94 -51
- package/navigation/SideNav.js +4 -3
- package/navigation/Sidebar.d.ts +29 -0
- package/navigation/Sidebar.js +311 -0
- package/navigation/Tabs.d.ts +9 -5
- package/navigation/Tabs.js +132 -44
- package/overlay/Command.d.ts +32 -0
- package/overlay/Command.js +257 -0
- package/overlay/ContextMenu.d.ts +40 -8
- package/overlay/ContextMenu.js +468 -107
- package/overlay/Drawer.d.ts +29 -14
- package/overlay/Drawer.js +178 -80
- package/overlay/DropdownMenu.d.ts +43 -0
- package/overlay/DropdownMenu.js +502 -0
- package/overlay/HoverCard.d.ts +21 -12
- package/overlay/HoverCard.js +129 -61
- package/overlay/Popover.d.ts +11 -13
- package/overlay/Popover.js +138 -65
- package/overlay/Portal.js +21 -7
- package/overlay/Sheet.d.ts +11 -0
- package/overlay/Sheet.js +62 -0
- package/package.json +4 -1
- package/tokens/base.css +1 -1
- package/dates/DatePicker.d.ts +0 -14
- package/dates/DatePicker.js +0 -111
- package/dates/DateRangePicker.d.ts +0 -23
- package/dates/DateRangePicker.js +0 -150
- package/display/ListItem.d.ts +0 -19
- package/display/ListItem.js +0 -50
- package/feedback/Toast.d.ts +0 -78
- package/feedback/Toast.js +0 -192
- package/forms/DigitEntry.d.ts +0 -15
- package/forms/DigitEntry.js +0 -79
- package/forms/FormField.d.ts +0 -82
- package/forms/FormField.js +0 -209
- package/overlay/CommandPalette.d.ts +0 -21
- package/overlay/CommandPalette.js +0 -148
- package/overlay/Menu.d.ts +0 -24
- package/overlay/Menu.js +0 -139
package/overlay/HoverCard.js
CHANGED
|
@@ -1,77 +1,145 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
3
|
import React from 'react';
|
|
4
|
+
import { mergeRefs } from "../forms/Button.js";
|
|
4
5
|
import { Portal, useAnchoredStyle } from "./Portal.js";
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
const HoverCardCtx = /*#__PURE__*/React.createContext(null);
|
|
7
|
+
function compose(theirs, ours) {
|
|
8
|
+
return event => {
|
|
9
|
+
theirs?.(event);
|
|
10
|
+
if (!event.defaultPrevented) ours?.(event);
|
|
11
|
+
};
|
|
12
|
+
}
|
|
7
13
|
export function HoverCard({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
children
|
|
14
|
-
style,
|
|
15
|
-
className,
|
|
16
|
-
...rest
|
|
14
|
+
open: controlled,
|
|
15
|
+
defaultOpen = false,
|
|
16
|
+
onOpenChange,
|
|
17
|
+
openDelay = 700,
|
|
18
|
+
closeDelay = 300,
|
|
19
|
+
children
|
|
17
20
|
}) {
|
|
18
|
-
const [
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
React.useEffect(() => () => clearTimeout(t.current), []);
|
|
21
|
+
const [inner, setInner] = React.useState(defaultOpen);
|
|
22
|
+
const open = controlled !== undefined ? controlled : inner;
|
|
23
|
+
const triggerRef = React.useRef(null);
|
|
24
|
+
const contentRef = React.useRef(null);
|
|
25
|
+
const timerRef = React.useRef(null);
|
|
26
|
+
const contentId = React.useId();
|
|
27
|
+
const setOpen = React.useCallback(next => {
|
|
28
|
+
if (controlled === undefined) setInner(next);
|
|
29
|
+
onOpenChange?.(next);
|
|
30
|
+
}, [controlled, onOpenChange]);
|
|
31
|
+
const clearTimer = React.useCallback(() => clearTimeout(timerRef.current), []);
|
|
32
|
+
const openSoon = React.useCallback(() => {
|
|
33
|
+
clearTimer();
|
|
34
|
+
timerRef.current = setTimeout(() => setOpen(true), openDelay);
|
|
35
|
+
}, [clearTimer, openDelay, setOpen]);
|
|
36
|
+
const closeSoon = React.useCallback(() => {
|
|
37
|
+
clearTimer();
|
|
38
|
+
timerRef.current = setTimeout(() => setOpen(false), closeDelay);
|
|
39
|
+
}, [clearTimer, closeDelay, setOpen]);
|
|
40
|
+
React.useEffect(() => clearTimer, [clearTimer]);
|
|
39
41
|
React.useEffect(() => {
|
|
40
42
|
if (!open) return;
|
|
41
|
-
const key =
|
|
42
|
-
if (
|
|
43
|
-
|
|
43
|
+
const key = event => {
|
|
44
|
+
if (event.key === 'Escape') {
|
|
45
|
+
clearTimer();
|
|
44
46
|
setOpen(false);
|
|
45
47
|
}
|
|
46
48
|
};
|
|
47
49
|
document.addEventListener('keydown', key);
|
|
48
50
|
return () => document.removeEventListener('keydown', key);
|
|
49
|
-
}, [open]);
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
51
|
+
}, [clearTimer, open, setOpen]);
|
|
52
|
+
const value = React.useMemo(() => ({
|
|
53
|
+
open,
|
|
54
|
+
setOpen,
|
|
55
|
+
openSoon,
|
|
56
|
+
closeSoon,
|
|
57
|
+
clearTimer,
|
|
58
|
+
triggerRef,
|
|
59
|
+
contentRef,
|
|
60
|
+
contentId
|
|
61
|
+
}), [open, setOpen, openSoon, closeSoon, clearTimer, contentId]);
|
|
62
|
+
return /*#__PURE__*/React.createElement(HoverCardCtx.Provider, {
|
|
63
|
+
value: value
|
|
64
|
+
}, children);
|
|
65
|
+
}
|
|
66
|
+
export const HoverCardTrigger = /*#__PURE__*/React.forwardRef(function HoverCardTrigger({
|
|
67
|
+
asChild = false,
|
|
68
|
+
children,
|
|
69
|
+
...rest
|
|
70
|
+
}, forwardedRef) {
|
|
71
|
+
const ctx = React.useContext(HoverCardCtx);
|
|
72
|
+
const props = {
|
|
73
|
+
...rest,
|
|
74
|
+
ref: mergeRefs(forwardedRef, ctx?.triggerRef),
|
|
75
|
+
'data-slot': 'hover-card-trigger',
|
|
76
|
+
'data-state': ctx?.open ? 'open' : 'closed',
|
|
77
|
+
'aria-expanded': ctx?.open,
|
|
78
|
+
'aria-controls': ctx?.open ? ctx.contentId : undefined,
|
|
79
|
+
onMouseEnter: compose(rest.onMouseEnter, ctx?.openSoon),
|
|
80
|
+
onMouseLeave: compose(rest.onMouseLeave, ctx?.closeSoon),
|
|
81
|
+
onFocus: compose(rest.onFocus, () => {
|
|
82
|
+
ctx?.clearTimer();
|
|
83
|
+
ctx?.setOpen(true);
|
|
84
|
+
}),
|
|
85
|
+
onBlur: compose(rest.onBlur, ctx?.closeSoon)
|
|
86
|
+
};
|
|
87
|
+
if (asChild && /*#__PURE__*/React.isValidElement(children)) {
|
|
88
|
+
return /*#__PURE__*/React.cloneElement(children, {
|
|
89
|
+
...props,
|
|
90
|
+
...children.props,
|
|
91
|
+
ref: mergeRefs(children.ref, props.ref),
|
|
92
|
+
onMouseEnter: compose(children.props.onMouseEnter, props.onMouseEnter),
|
|
93
|
+
onMouseLeave: compose(children.props.onMouseLeave, props.onMouseLeave),
|
|
94
|
+
onFocus: compose(children.props.onFocus, props.onFocus),
|
|
95
|
+
onBlur: compose(children.props.onBlur, props.onBlur),
|
|
96
|
+
'data-slot': 'hover-card-trigger',
|
|
97
|
+
'data-state': props['data-state'],
|
|
98
|
+
'aria-expanded': props['aria-expanded'],
|
|
99
|
+
'aria-controls': props['aria-controls']
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
return /*#__PURE__*/React.createElement("button", _extends({
|
|
103
|
+
type: "button"
|
|
104
|
+
}, props), children);
|
|
105
|
+
});
|
|
106
|
+
export const HoverCardContent = /*#__PURE__*/React.forwardRef(function HoverCardContent({
|
|
107
|
+
align = 'center',
|
|
108
|
+
side = 'bottom',
|
|
109
|
+
sideOffset = 4,
|
|
110
|
+
alignOffset = 0,
|
|
111
|
+
className,
|
|
112
|
+
style,
|
|
113
|
+
children,
|
|
114
|
+
...rest
|
|
115
|
+
}, forwardedRef) {
|
|
116
|
+
const ctx = React.useContext(HoverCardCtx);
|
|
117
|
+
const fallbackTriggerRef = React.useRef(null);
|
|
118
|
+
const fallbackContentRef = React.useRef(null);
|
|
119
|
+
const {
|
|
120
|
+
style: anchored,
|
|
121
|
+
side: resolvedSide
|
|
122
|
+
} = useAnchoredStyle(ctx?.triggerRef ?? fallbackTriggerRef, ctx?.contentRef ?? fallbackContentRef, {
|
|
123
|
+
open: !!ctx?.open,
|
|
124
|
+
placement: side,
|
|
125
|
+
align,
|
|
126
|
+
offset: sideOffset,
|
|
127
|
+
crossOffset: alignOffset
|
|
128
|
+
});
|
|
129
|
+
if (!ctx?.open) return null;
|
|
130
|
+
return /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
131
|
+
ref: mergeRefs(forwardedRef, ctx.contentRef),
|
|
132
|
+
id: ctx.contentId,
|
|
133
|
+
"data-slot": "hover-card-content",
|
|
134
|
+
"data-state": "open",
|
|
135
|
+
"data-side": resolvedSide,
|
|
136
|
+
"data-align": align,
|
|
137
|
+
onMouseEnter: compose(rest.onMouseEnter, ctx.clearTimer),
|
|
138
|
+
onMouseLeave: compose(rest.onMouseLeave, ctx.closeSoon),
|
|
139
|
+
className: `ef-hovercard__panel${className ? ' ' + className : ''}`,
|
|
72
140
|
style: {
|
|
73
141
|
...anchored,
|
|
74
|
-
|
|
142
|
+
...style
|
|
75
143
|
}
|
|
76
|
-
}, children))
|
|
77
|
-
}
|
|
144
|
+
}), children));
|
|
145
|
+
});
|
package/overlay/Popover.d.ts
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
export interface PopoverProps {
|
|
2
|
-
/** The element that toggles the popover */
|
|
3
|
-
trigger: React.ReactNode;
|
|
4
|
-
/** Panel content */
|
|
5
2
|
children?: React.ReactNode;
|
|
6
|
-
|
|
7
|
-
align?: 'left' | 'right';
|
|
8
|
-
/** Panel width @default 280 */
|
|
9
|
-
width?: number;
|
|
10
|
-
/** Controlled open state */
|
|
11
|
-
open?: boolean;
|
|
12
|
-
onOpenChange?: (open: boolean) => void;
|
|
13
|
-
style?: React.CSSProperties;
|
|
14
|
-
className?: string;
|
|
3
|
+
open?: boolean; defaultOpen?: boolean; onOpenChange?: (open: boolean) => void;
|
|
15
4
|
}
|
|
16
|
-
export
|
|
5
|
+
export interface PopoverTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> { asChild?: boolean; }
|
|
6
|
+
export interface PopoverContentProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
7
|
+
align?: 'start' | 'center' | 'end'; side?: 'top' | 'bottom'; sideOffset?: number; width?: number | string;
|
|
8
|
+
}
|
|
9
|
+
export declare function Popover(props: PopoverProps): React.JSX.Element;
|
|
10
|
+
export declare const PopoverTrigger: React.ForwardRefExoticComponent<PopoverTriggerProps & React.RefAttributes<HTMLElement>>;
|
|
11
|
+
export declare const PopoverContent: React.ForwardRefExoticComponent<PopoverContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
12
|
+
export declare const PopoverHeader: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
13
|
+
export declare const PopoverTitle: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLHeadingElement> & React.RefAttributes<HTMLHeadingElement>>;
|
|
14
|
+
export declare const PopoverDescription: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLParagraphElement> & React.RefAttributes<HTMLParagraphElement>>;
|
package/overlay/Popover.js
CHANGED
|
@@ -3,89 +3,162 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { mergeRefs } from "../forms/Button.js";
|
|
5
5
|
import { Portal, useAnchoredStyle } from "./Portal.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
const PopoverCtx = /*#__PURE__*/React.createContext(null);
|
|
7
|
+
function compose(theirs, ours) {
|
|
8
|
+
return event => {
|
|
9
|
+
theirs?.(event);
|
|
10
|
+
if (!event.defaultPrevented) ours?.(event);
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export function Popover({
|
|
10
14
|
children,
|
|
11
|
-
align = 'left',
|
|
12
|
-
width = 280,
|
|
13
15
|
open: controlled,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
if (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
const {
|
|
28
|
-
style: anchored
|
|
29
|
-
} = useAnchoredStyle(ref, panelRef, {
|
|
16
|
+
defaultOpen = false,
|
|
17
|
+
onOpenChange
|
|
18
|
+
}) {
|
|
19
|
+
const [inner, setInner] = React.useState(defaultOpen);
|
|
20
|
+
const open = controlled !== undefined ? controlled : inner;
|
|
21
|
+
const triggerRef = React.useRef(null);
|
|
22
|
+
const contentRef = React.useRef(null);
|
|
23
|
+
const contentId = React.useId();
|
|
24
|
+
const setOpen = React.useCallback(next => {
|
|
25
|
+
if (controlled === undefined) setInner(next);
|
|
26
|
+
onOpenChange?.(next);
|
|
27
|
+
}, [controlled, onOpenChange]);
|
|
28
|
+
const value = React.useMemo(() => ({
|
|
30
29
|
open,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const t = ref.current && ref.current.querySelector('button,[href],[tabindex]');
|
|
37
|
-
if (t) t.focus();
|
|
38
|
-
};
|
|
30
|
+
setOpen,
|
|
31
|
+
triggerRef,
|
|
32
|
+
contentRef,
|
|
33
|
+
contentId
|
|
34
|
+
}), [open, setOpen, contentId]);
|
|
39
35
|
React.useEffect(() => {
|
|
40
36
|
if (!open) return;
|
|
41
|
-
const away =
|
|
42
|
-
|
|
43
|
-
const inPanel = panelRef.current && panelRef.current.contains(e.target);
|
|
44
|
-
if (!inTrigger && !inPanel) setOpen(false);
|
|
37
|
+
const away = event => {
|
|
38
|
+
if (!triggerRef.current?.contains(event.target) && !contentRef.current?.contains(event.target)) setOpen(false);
|
|
45
39
|
};
|
|
46
|
-
const key =
|
|
47
|
-
if (
|
|
40
|
+
const key = event => {
|
|
41
|
+
if (event.key === 'Escape') {
|
|
48
42
|
setOpen(false);
|
|
49
|
-
|
|
43
|
+
triggerRef.current?.focus();
|
|
50
44
|
}
|
|
51
45
|
};
|
|
46
|
+
document.addEventListener('pointerdown', away);
|
|
52
47
|
document.addEventListener('mousedown', away);
|
|
53
48
|
document.addEventListener('keydown', key);
|
|
54
49
|
return () => {
|
|
50
|
+
document.removeEventListener('pointerdown', away);
|
|
55
51
|
document.removeEventListener('mousedown', away);
|
|
56
52
|
document.removeEventListener('keydown', key);
|
|
57
53
|
};
|
|
58
|
-
}, [open]);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
54
|
+
}, [open, setOpen]);
|
|
55
|
+
return /*#__PURE__*/React.createElement(PopoverCtx.Provider, {
|
|
56
|
+
value: value
|
|
57
|
+
}, children);
|
|
58
|
+
}
|
|
59
|
+
export const PopoverTrigger = /*#__PURE__*/React.forwardRef(function PopoverTrigger({
|
|
60
|
+
asChild = false,
|
|
61
|
+
children,
|
|
62
|
+
...rest
|
|
63
|
+
}, forwardedRef) {
|
|
64
|
+
const ctx = React.useContext(PopoverCtx);
|
|
65
|
+
if (!ctx) return /*#__PURE__*/React.createElement("button", _extends({
|
|
66
|
+
type: "button"
|
|
67
|
+
}, rest, {
|
|
68
|
+
ref: forwardedRef
|
|
69
|
+
}), children);
|
|
70
|
+
const props = {
|
|
71
|
+
...rest,
|
|
72
|
+
ref: mergeRefs(forwardedRef, ctx.triggerRef),
|
|
73
|
+
'data-slot': 'popover-trigger',
|
|
70
74
|
'aria-haspopup': 'dialog',
|
|
71
|
-
'aria-expanded': open
|
|
75
|
+
'aria-expanded': ctx.open,
|
|
76
|
+
'aria-controls': ctx.open ? ctx.contentId : undefined,
|
|
77
|
+
onClick: compose(rest.onClick, () => ctx.setOpen(!ctx.open))
|
|
72
78
|
};
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
79
|
+
if (asChild && /*#__PURE__*/React.isValidElement(children)) {
|
|
80
|
+
return /*#__PURE__*/React.cloneElement(children, {
|
|
81
|
+
...props,
|
|
82
|
+
...children.props,
|
|
83
|
+
ref: mergeRefs(children.ref, props.ref),
|
|
84
|
+
onClick: compose(children.props.onClick, props.onClick),
|
|
85
|
+
'data-slot': 'popover-trigger',
|
|
86
|
+
'aria-haspopup': 'dialog',
|
|
87
|
+
'aria-expanded': ctx.open,
|
|
88
|
+
'aria-controls': props['aria-controls']
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return /*#__PURE__*/React.createElement("button", _extends({
|
|
92
|
+
type: "button"
|
|
93
|
+
}, props), children);
|
|
94
|
+
});
|
|
95
|
+
export const PopoverContent = /*#__PURE__*/React.forwardRef(function PopoverContent({
|
|
96
|
+
align = 'center',
|
|
97
|
+
side = 'bottom',
|
|
98
|
+
sideOffset = 8,
|
|
99
|
+
width,
|
|
100
|
+
role = 'dialog',
|
|
101
|
+
className,
|
|
102
|
+
style,
|
|
103
|
+
children,
|
|
104
|
+
...rest
|
|
105
|
+
}, forwardedRef) {
|
|
106
|
+
const ctx = React.useContext(PopoverCtx);
|
|
107
|
+
const fallbackTriggerRef = React.useRef(null);
|
|
108
|
+
const fallbackContentRef = React.useRef(null);
|
|
109
|
+
const placement = side === 'top' ? 'top' : 'bottom';
|
|
110
|
+
const {
|
|
111
|
+
style: anchored
|
|
112
|
+
} = useAnchoredStyle(ctx?.triggerRef ?? fallbackTriggerRef, ctx?.contentRef ?? fallbackContentRef, {
|
|
113
|
+
open: !!ctx?.open,
|
|
114
|
+
placement,
|
|
115
|
+
align,
|
|
116
|
+
offset: sideOffset
|
|
117
|
+
});
|
|
118
|
+
if (!ctx?.open) return null;
|
|
119
|
+
return /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
120
|
+
ref: mergeRefs(forwardedRef, ctx.contentRef),
|
|
121
|
+
id: ctx.contentId,
|
|
122
|
+
role: role,
|
|
123
|
+
"data-slot": "popover-content",
|
|
124
|
+
"data-state": "open",
|
|
125
|
+
"data-side": placement,
|
|
126
|
+
"data-align": align,
|
|
127
|
+
className: `ef-popover__panel${className ? ' ' + className : ''}`,
|
|
86
128
|
style: {
|
|
87
129
|
...anchored,
|
|
88
|
-
width
|
|
130
|
+
width: width ?? undefined,
|
|
131
|
+
...style
|
|
89
132
|
}
|
|
90
|
-
}, children))
|
|
133
|
+
}), children));
|
|
134
|
+
});
|
|
135
|
+
export const PopoverHeader = /*#__PURE__*/React.forwardRef(function PopoverHeader({
|
|
136
|
+
className,
|
|
137
|
+
...props
|
|
138
|
+
}, ref) {
|
|
139
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, props, {
|
|
140
|
+
ref: ref,
|
|
141
|
+
"data-slot": "popover-header",
|
|
142
|
+
className: `ef-popover__header${className ? ' ' + className : ''}`
|
|
143
|
+
}));
|
|
144
|
+
});
|
|
145
|
+
export const PopoverTitle = /*#__PURE__*/React.forwardRef(function PopoverTitle({
|
|
146
|
+
className,
|
|
147
|
+
...props
|
|
148
|
+
}, ref) {
|
|
149
|
+
return /*#__PURE__*/React.createElement("h2", _extends({}, props, {
|
|
150
|
+
ref: ref,
|
|
151
|
+
"data-slot": "popover-title",
|
|
152
|
+
className: `ef-popover__title${className ? ' ' + className : ''}`
|
|
153
|
+
}));
|
|
154
|
+
});
|
|
155
|
+
export const PopoverDescription = /*#__PURE__*/React.forwardRef(function PopoverDescription({
|
|
156
|
+
className,
|
|
157
|
+
...props
|
|
158
|
+
}, ref) {
|
|
159
|
+
return /*#__PURE__*/React.createElement("p", _extends({}, props, {
|
|
160
|
+
ref: ref,
|
|
161
|
+
"data-slot": "popover-description",
|
|
162
|
+
className: `ef-popover__description${className ? ' ' + className : ''}`
|
|
163
|
+
}));
|
|
91
164
|
});
|
package/overlay/Portal.js
CHANGED
|
@@ -53,6 +53,7 @@ export function useAnchoredStyle(anchorRef, panelRef, {
|
|
|
53
53
|
placement = 'bottom',
|
|
54
54
|
align = 'start',
|
|
55
55
|
offset = 6,
|
|
56
|
+
crossOffset = 0,
|
|
56
57
|
matchWidth = false
|
|
57
58
|
} = {}) {
|
|
58
59
|
const [state, setState] = React.useState({
|
|
@@ -91,16 +92,29 @@ export function useAnchoredStyle(anchorRef, panelRef, {
|
|
|
91
92
|
const vw = document.documentElement.clientWidth;
|
|
92
93
|
const vh = document.documentElement.clientHeight;
|
|
93
94
|
const edge = 8;
|
|
94
|
-
const
|
|
95
|
-
const
|
|
96
|
-
const
|
|
97
|
-
const
|
|
95
|
+
const horizontal = placement === 'left' || placement === 'right';
|
|
96
|
+
const roomAfter = horizontal ? vw - a.right - offset : vh - a.bottom - offset;
|
|
97
|
+
const roomBefore = horizontal ? a.left - offset : a.top - offset;
|
|
98
|
+
const panelSize = horizontal ? p.width : p.height;
|
|
99
|
+
const wantsBefore = placement === 'top' || placement === 'left';
|
|
100
|
+
const beforeSide = horizontal ? 'left' : 'top';
|
|
101
|
+
const afterSide = horizontal ? 'right' : 'bottom';
|
|
102
|
+
const side = wantsBefore ? roomBefore >= panelSize || roomBefore >= roomAfter ? beforeSide : afterSide : roomAfter >= panelSize || roomAfter >= roomBefore ? afterSide : beforeSide;
|
|
98
103
|
|
|
99
104
|
// a width-matched panel (a listbox under its input) is measured at the
|
|
100
105
|
// anchor's width, not its own, or the clamp below uses the wrong number
|
|
101
106
|
const width = matchWidth ? a.width : p.width;
|
|
102
|
-
let top
|
|
103
|
-
let left
|
|
107
|
+
let top;
|
|
108
|
+
let left;
|
|
109
|
+
if (horizontal) {
|
|
110
|
+
left = side === 'right' ? a.right + offset : a.left - offset - width;
|
|
111
|
+
top = align === 'end' ? a.bottom - p.height : align === 'center' ? a.top + a.height / 2 - p.height / 2 : a.top;
|
|
112
|
+
top += crossOffset;
|
|
113
|
+
} else {
|
|
114
|
+
top = side === 'bottom' ? a.bottom + offset : a.top - offset - p.height;
|
|
115
|
+
left = align === 'end' ? a.right - width : align === 'center' ? a.left + a.width / 2 - width / 2 : a.left;
|
|
116
|
+
left += crossOffset;
|
|
117
|
+
}
|
|
104
118
|
left = Math.max(edge, Math.min(left, vw - width - edge));
|
|
105
119
|
top = Math.max(edge, Math.min(top, vh - p.height - edge));
|
|
106
120
|
const next = {
|
|
@@ -125,6 +139,6 @@ export function useAnchoredStyle(anchorRef, panelRef, {
|
|
|
125
139
|
window.removeEventListener('scroll', place, true);
|
|
126
140
|
window.removeEventListener('resize', place);
|
|
127
141
|
};
|
|
128
|
-
}, [open, placement, align, offset, matchWidth, anchorRef, panelRef]);
|
|
142
|
+
}, [open, placement, align, offset, crossOffset, matchWidth, anchorRef, panelRef]);
|
|
129
143
|
return state;
|
|
130
144
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import type { DialogContentProps, DialogRootProps, DialogSlotProps } from '../feedback/Dialog.jsx';
|
|
3
|
+
export declare const Sheet: React.ForwardRefExoticComponent<DialogRootProps & React.RefAttributes<HTMLDivElement>>;
|
|
4
|
+
export declare const SheetTrigger: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & { asChild?: boolean } & React.RefAttributes<HTMLButtonElement>>;
|
|
5
|
+
export declare const SheetClose: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & { asChild?: boolean } & React.RefAttributes<HTMLButtonElement>>;
|
|
6
|
+
export interface SheetContentProps extends DialogContentProps { side?: 'top' | 'right' | 'bottom' | 'left'; }
|
|
7
|
+
export declare const SheetContent: React.ForwardRefExoticComponent<SheetContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
8
|
+
export declare const SheetHeader: React.ForwardRefExoticComponent<DialogSlotProps & React.RefAttributes<HTMLDivElement>>;
|
|
9
|
+
export declare const SheetFooter: React.ForwardRefExoticComponent<DialogSlotProps & React.RefAttributes<HTMLDivElement>>;
|
|
10
|
+
export declare const SheetTitle: React.ForwardRefExoticComponent<DialogSlotProps & React.RefAttributes<HTMLDivElement>>;
|
|
11
|
+
export declare const SheetDescription: React.ForwardRefExoticComponent<DialogSlotProps & React.RefAttributes<HTMLDivElement>>;
|
package/overlay/Sheet.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "../feedback/Dialog.js";
|
|
5
|
+
export const Sheet = Dialog;
|
|
6
|
+
export const SheetTrigger = DialogTrigger;
|
|
7
|
+
export const SheetClose = DialogClose;
|
|
8
|
+
export const SheetContent = /*#__PURE__*/React.forwardRef(function SheetContent({
|
|
9
|
+
side = 'right',
|
|
10
|
+
className,
|
|
11
|
+
children,
|
|
12
|
+
style,
|
|
13
|
+
...props
|
|
14
|
+
}, ref) {
|
|
15
|
+
return /*#__PURE__*/React.createElement(DialogContent, _extends({}, props, {
|
|
16
|
+
ref: ref,
|
|
17
|
+
slot: "sheet-content",
|
|
18
|
+
"data-side": side,
|
|
19
|
+
className: `ef-sheet${className ? ' ' + className : ''}`,
|
|
20
|
+
width: "none",
|
|
21
|
+
style: {
|
|
22
|
+
...style,
|
|
23
|
+
position: 'fixed'
|
|
24
|
+
}
|
|
25
|
+
}), children);
|
|
26
|
+
});
|
|
27
|
+
export const SheetHeader = /*#__PURE__*/React.forwardRef(function SheetHeader({
|
|
28
|
+
className,
|
|
29
|
+
...props
|
|
30
|
+
}, ref) {
|
|
31
|
+
return /*#__PURE__*/React.createElement(DialogHeader, _extends({}, props, {
|
|
32
|
+
ref: ref,
|
|
33
|
+
slot: "sheet-header",
|
|
34
|
+
className: `ef-sheet__header${className ? ' ' + className : ''}`
|
|
35
|
+
}));
|
|
36
|
+
});
|
|
37
|
+
export const SheetFooter = /*#__PURE__*/React.forwardRef(function SheetFooter({
|
|
38
|
+
className,
|
|
39
|
+
...props
|
|
40
|
+
}, ref) {
|
|
41
|
+
return /*#__PURE__*/React.createElement(DialogFooter, _extends({}, props, {
|
|
42
|
+
ref: ref,
|
|
43
|
+
slot: "sheet-footer",
|
|
44
|
+
className: `ef-sheet__footer${className ? ' ' + className : ''}`
|
|
45
|
+
}));
|
|
46
|
+
});
|
|
47
|
+
export const SheetTitle = /*#__PURE__*/React.forwardRef(function SheetTitle(props, ref) {
|
|
48
|
+
return /*#__PURE__*/React.createElement(DialogTitle, _extends({}, props, {
|
|
49
|
+
ref: ref,
|
|
50
|
+
slot: "sheet-title"
|
|
51
|
+
}));
|
|
52
|
+
});
|
|
53
|
+
export const SheetDescription = /*#__PURE__*/React.forwardRef(function SheetDescription({
|
|
54
|
+
className,
|
|
55
|
+
...props
|
|
56
|
+
}, ref) {
|
|
57
|
+
return /*#__PURE__*/React.createElement(DialogDescription, _extends({}, props, {
|
|
58
|
+
ref: ref,
|
|
59
|
+
slot: "sheet-description",
|
|
60
|
+
className: `ef-sheet__description${className ? ' ' + className : ''}`
|
|
61
|
+
}));
|
|
62
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@efolusi/meridian",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.21.0",
|
|
4
4
|
"description": "A general-purpose open-source design system by Efolusi: accessible React components, design tokens, blocks and example apps.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://meridian.efolusi.com",
|
|
@@ -39,6 +39,9 @@
|
|
|
39
39
|
"react": ">=18",
|
|
40
40
|
"react-dom": ">=18"
|
|
41
41
|
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"recharts": "^3.8.0"
|
|
44
|
+
},
|
|
42
45
|
"keywords": [
|
|
43
46
|
"design-system",
|
|
44
47
|
"react",
|
package/tokens/base.css
CHANGED
|
@@ -2,7 +2,7 @@ body{margin:0;font-family:var(--font-sans);font-size:var(--text-md);line-height:
|
|
|
2
2
|
h1,h2,h3,h4{font-family:var(--font-display);letter-spacing:var(--tracking-display);line-height:var(--leading-snug);margin:0}
|
|
3
3
|
p{margin:0}
|
|
4
4
|
a{color:var(--text-link);text-decoration:none;transition:color var(--dur-fast) var(--ease-out)}
|
|
5
|
-
a:hover{color:var(--accent-hover);text-decoration:
|
|
5
|
+
a:hover{color:var(--accent-hover);text-decoration:none}
|
|
6
6
|
a:focus-visible{outline:none;box-shadow:var(--focus-ring);border-radius:var(--radius-sm)}
|
|
7
7
|
code,pre,kbd{font-family:var(--font-mono)}
|
|
8
8
|
::selection{background:var(--brand-100);color:var(--cocoa-900)}
|
package/dates/DatePicker.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export interface DatePickerProps {
|
|
2
|
-
label?: string;
|
|
3
|
-
/** Controlled YYYY-MM-DD */
|
|
4
|
-
value?: string;
|
|
5
|
-
defaultValue?: string;
|
|
6
|
-
onChange?: (date: string) => void;
|
|
7
|
-
/** @default 'Pick a date' */
|
|
8
|
-
placeholder?: string;
|
|
9
|
-
/** BCP 47 locale for the trigger's date label and the calendar's names via Intl (e.g. 'id', 'en'); omit for en-US. */
|
|
10
|
-
locale?: string;
|
|
11
|
-
style?: React.CSSProperties;
|
|
12
|
-
className?: string;
|
|
13
|
-
}
|
|
14
|
-
export declare function DatePicker(props: DatePickerProps): React.JSX.Element;
|