@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/display/Card.js
CHANGED
|
@@ -1,39 +1,84 @@
|
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
function cx(base, className) {
|
|
5
|
+
return base + (className ? ` ${className}` : '');
|
|
6
|
+
}
|
|
7
|
+
export const CardHeader = /*#__PURE__*/React.forwardRef(function CardHeader({
|
|
8
|
+
className,
|
|
9
|
+
...rest
|
|
10
|
+
}, ref) {
|
|
11
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
12
|
+
ref: ref,
|
|
13
|
+
"data-slot": "card-header",
|
|
14
|
+
className: cx('ef-card__header', className)
|
|
15
|
+
}));
|
|
16
|
+
});
|
|
17
|
+
export const CardTitle = /*#__PURE__*/React.forwardRef(function CardTitle({
|
|
18
|
+
className,
|
|
19
|
+
...rest
|
|
20
|
+
}, ref) {
|
|
21
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
22
|
+
ref: ref,
|
|
23
|
+
"data-slot": "card-title",
|
|
24
|
+
className: cx('ef-card__title', className)
|
|
25
|
+
}));
|
|
26
|
+
});
|
|
27
|
+
export const CardDescription = /*#__PURE__*/React.forwardRef(function CardDescription({
|
|
28
|
+
className,
|
|
29
|
+
...rest
|
|
30
|
+
}, ref) {
|
|
31
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
32
|
+
ref: ref,
|
|
33
|
+
"data-slot": "card-description",
|
|
34
|
+
className: cx('ef-card__description', className)
|
|
35
|
+
}));
|
|
36
|
+
});
|
|
37
|
+
export const CardAction = /*#__PURE__*/React.forwardRef(function CardAction({
|
|
38
|
+
className,
|
|
39
|
+
...rest
|
|
40
|
+
}, ref) {
|
|
41
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
42
|
+
ref: ref,
|
|
43
|
+
"data-slot": "card-action",
|
|
44
|
+
className: cx('ef-card__action', className)
|
|
45
|
+
}));
|
|
46
|
+
});
|
|
47
|
+
export const CardContent = /*#__PURE__*/React.forwardRef(function CardContent({
|
|
48
|
+
className,
|
|
49
|
+
...rest
|
|
50
|
+
}, ref) {
|
|
51
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
52
|
+
ref: ref,
|
|
53
|
+
"data-slot": "card-content",
|
|
54
|
+
className: cx('ef-card__content', className)
|
|
55
|
+
}));
|
|
56
|
+
});
|
|
57
|
+
export const CardFooter = /*#__PURE__*/React.forwardRef(function CardFooter({
|
|
58
|
+
className,
|
|
59
|
+
...rest
|
|
60
|
+
}, ref) {
|
|
61
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
62
|
+
ref: ref,
|
|
63
|
+
"data-slot": "card-footer",
|
|
64
|
+
className: cx('ef-card__footer', className)
|
|
65
|
+
}));
|
|
66
|
+
});
|
|
67
|
+
export const Card = /*#__PURE__*/React.forwardRef(function Card({
|
|
68
|
+
size = 'default',
|
|
10
69
|
elevated,
|
|
11
70
|
interactive,
|
|
12
71
|
children,
|
|
13
72
|
style,
|
|
14
73
|
className,
|
|
15
74
|
...rest
|
|
16
|
-
}) {
|
|
17
|
-
|
|
18
|
-
|
|
75
|
+
}, ref) {
|
|
76
|
+
const rootClass = `ef-card ef-card--composed${elevated ? ' ef-card--elevated' : ''}${interactive ? ' ef-card--interactive' : ''}${className ? ` ${className}` : ''}`;
|
|
77
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
78
|
+
ref: ref,
|
|
79
|
+
"data-slot": "card",
|
|
80
|
+
"data-size": size,
|
|
81
|
+
className: rootClass,
|
|
19
82
|
style: style
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
}, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
23
|
-
className: "ef-card__title"
|
|
24
|
-
}, title), subtitle ? /*#__PURE__*/React.createElement("div", {
|
|
25
|
-
className: "ef-card__subtitle"
|
|
26
|
-
}, subtitle) : null), actions ? /*#__PURE__*/React.createElement("div", {
|
|
27
|
-
style: {
|
|
28
|
-
display: 'flex',
|
|
29
|
-
gap: 8,
|
|
30
|
-
flex: 'none'
|
|
31
|
-
}
|
|
32
|
-
}, actions) : null) : null, /*#__PURE__*/React.createElement("div", {
|
|
33
|
-
style: {
|
|
34
|
-
padding
|
|
35
|
-
}
|
|
36
|
-
}, children), footer ? /*#__PURE__*/React.createElement("div", {
|
|
37
|
-
className: "ef-card__footer"
|
|
38
|
-
}, footer) : null);
|
|
39
|
-
}
|
|
83
|
+
}), children);
|
|
84
|
+
});
|
package/display/Carousel.d.ts
CHANGED
|
@@ -1,16 +1,24 @@
|
|
|
1
|
-
export interface
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
export interface CarouselApi {
|
|
2
|
+
canScrollNext(): boolean;
|
|
3
|
+
canScrollPrev(): boolean;
|
|
4
|
+
containerNode(): HTMLElement | null;
|
|
5
|
+
destroy(): void;
|
|
6
|
+
off(event: string, callback: (api: CarouselApi) => void): CarouselApi;
|
|
7
|
+
on(event: string, callback: (api: CarouselApi) => void): CarouselApi;
|
|
8
|
+
reInit(): void;
|
|
9
|
+
rootNode(): HTMLElement | null;
|
|
10
|
+
scrollNext(): void;
|
|
11
|
+
scrollPrev(): void;
|
|
12
|
+
scrollSnapList(): number[];
|
|
13
|
+
scrollTo(index: number): void;
|
|
14
|
+
selectedScrollSnap(): number;
|
|
15
|
+
slideNodes(): HTMLElement[];
|
|
15
16
|
}
|
|
16
|
-
export
|
|
17
|
+
export interface CarouselOptions { align?: 'start' | 'center' | 'end'; loop?: boolean; direction?: 'ltr' | 'rtl'; }
|
|
18
|
+
export interface CarouselPlugin { init?(api: CarouselApi): void; destroy?(): void; }
|
|
19
|
+
export interface CarouselProps extends React.HTMLAttributes<HTMLDivElement> { orientation?: 'horizontal' | 'vertical'; opts?: CarouselOptions; plugins?: CarouselPlugin[]; setApi?: (api: CarouselApi | undefined) => void; }
|
|
20
|
+
export declare const Carousel: React.ForwardRefExoticComponent<CarouselProps & React.RefAttributes<HTMLDivElement>>;
|
|
21
|
+
export declare const CarouselContent: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
22
|
+
export declare const CarouselItem: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
23
|
+
export declare const CarouselPrevious: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & React.RefAttributes<HTMLButtonElement>>;
|
|
24
|
+
export declare const CarouselNext: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & React.RefAttributes<HTMLButtonElement>>;
|
package/display/Carousel.js
CHANGED
|
@@ -3,78 +3,229 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { prefersReducedMotion } from "../forms/Button.js";
|
|
5
5
|
import { Icon } from "../icons/Icon.js";
|
|
6
|
-
|
|
6
|
+
import { useDirection } from "./Direction.js";
|
|
7
|
+
const CarouselCtx = /*#__PURE__*/React.createContext(null);
|
|
8
|
+
const EMPTY_PLUGINS = [];
|
|
9
|
+
function closestIndex(element, orientation) {
|
|
10
|
+
const position = orientation === 'vertical' ? element.scrollTop : Math.abs(element.scrollLeft);
|
|
11
|
+
const slides = [...element.querySelectorAll('[data-slot="carousel-item"]')];
|
|
12
|
+
if (!slides.length) return 0;
|
|
13
|
+
let best = 0;
|
|
14
|
+
let distance = Infinity;
|
|
15
|
+
slides.forEach((slide, index) => {
|
|
16
|
+
const offset = orientation === 'vertical' ? slide.offsetTop : slide.offsetLeft;
|
|
17
|
+
const nextDistance = Math.abs(offset - position);
|
|
18
|
+
if (nextDistance < distance) {
|
|
19
|
+
best = index;
|
|
20
|
+
distance = nextDistance;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
return best;
|
|
24
|
+
}
|
|
25
|
+
export const Carousel = /*#__PURE__*/React.forwardRef(function Carousel({
|
|
26
|
+
orientation = 'horizontal',
|
|
27
|
+
opts = {},
|
|
28
|
+
plugins = EMPTY_PLUGINS,
|
|
29
|
+
setApi,
|
|
7
30
|
children,
|
|
8
|
-
itemWidth = '280px',
|
|
9
|
-
gap = 14,
|
|
10
|
-
showControls = true,
|
|
11
|
-
showDots = true,
|
|
12
|
-
ariaLabel = 'Carousel',
|
|
13
|
-
style,
|
|
14
31
|
className,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
onKeyDown,
|
|
33
|
+
...props
|
|
34
|
+
}, ref) {
|
|
35
|
+
const inheritedDirection = useDirection();
|
|
36
|
+
const direction = opts.direction || props.dir || inheritedDirection;
|
|
37
|
+
const align = opts.align || 'start';
|
|
38
|
+
const contentRef = React.useRef(null);
|
|
39
|
+
const listeners = React.useRef(new Map());
|
|
40
|
+
const [selected, setSelected] = React.useState(0);
|
|
41
|
+
const [slideCount, setSlideCount] = React.useState(0);
|
|
42
|
+
const selectedRef = React.useRef(0);
|
|
43
|
+
const slideCountRef = React.useRef(0);
|
|
44
|
+
selectedRef.current = selected;
|
|
45
|
+
slideCountRef.current = slideCount;
|
|
46
|
+
const loop = !!opts.loop;
|
|
47
|
+
const emit = React.useCallback(event => {
|
|
48
|
+
listeners.current.get(event)?.forEach(callback => callback(api));
|
|
49
|
+
}, []);
|
|
50
|
+
const scrollTo = React.useCallback(index => {
|
|
51
|
+
const element = contentRef.current;
|
|
52
|
+
if (!element) return;
|
|
53
|
+
const slides = [...element.querySelectorAll('[data-slot="carousel-item"]')];
|
|
54
|
+
if (!slides.length) return;
|
|
55
|
+
const targetIndex = loop ? (index + slides.length) % slides.length : Math.max(0, Math.min(slides.length - 1, index));
|
|
56
|
+
const slide = slides[targetIndex];
|
|
57
|
+
const behavior = prefersReducedMotion() ? 'auto' : 'smooth';
|
|
58
|
+
const alignmentOffset = orientation === 'vertical' ? align === 'center' ? (element.clientHeight - slide.offsetHeight) / 2 : align === 'end' ? element.clientHeight - slide.offsetHeight : 0 : align === 'center' ? (element.clientWidth - slide.offsetWidth) / 2 : align === 'end' ? element.clientWidth - slide.offsetWidth : 0;
|
|
59
|
+
if (orientation === 'vertical') element.scrollTo({
|
|
60
|
+
top: slide.offsetTop - alignmentOffset,
|
|
61
|
+
behavior
|
|
62
|
+
});else element.scrollTo({
|
|
63
|
+
left: (direction === 'rtl' ? -1 : 1) * (slide.offsetLeft - alignmentOffset),
|
|
64
|
+
behavior
|
|
30
65
|
});
|
|
66
|
+
setSelected(targetIndex);
|
|
67
|
+
queueMicrotask(() => emit('select'));
|
|
68
|
+
}, [align, direction, emit, loop, orientation]);
|
|
69
|
+
const api = React.useMemo(() => ({
|
|
70
|
+
canScrollNext: () => loop || selectedRef.current < slideCountRef.current - 1,
|
|
71
|
+
canScrollPrev: () => loop || selectedRef.current > 0,
|
|
72
|
+
containerNode: () => contentRef.current?.querySelector('[data-slot="carousel-track"]') || null,
|
|
73
|
+
destroy: () => {
|
|
74
|
+
emit('destroy');
|
|
75
|
+
listeners.current.clear();
|
|
76
|
+
},
|
|
77
|
+
off: (event, callback) => {
|
|
78
|
+
listeners.current.get(event)?.delete(callback);
|
|
79
|
+
return api;
|
|
80
|
+
},
|
|
81
|
+
on: (event, callback) => {
|
|
82
|
+
if (!listeners.current.has(event)) listeners.current.set(event, new Set());
|
|
83
|
+
listeners.current.get(event).add(callback);
|
|
84
|
+
return api;
|
|
85
|
+
},
|
|
86
|
+
reInit: () => {
|
|
87
|
+
setSlideCount(contentRef.current?.querySelectorAll('[data-slot="carousel-item"]').length || 0);
|
|
88
|
+
emit('reInit');
|
|
89
|
+
},
|
|
90
|
+
rootNode: () => contentRef.current,
|
|
91
|
+
scrollNext: () => scrollTo(selectedRef.current + 1),
|
|
92
|
+
scrollPrev: () => scrollTo(selectedRef.current - 1),
|
|
93
|
+
scrollSnapList: () => Array.from({
|
|
94
|
+
length: slideCountRef.current
|
|
95
|
+
}, (_, index) => index),
|
|
96
|
+
scrollTo,
|
|
97
|
+
selectedScrollSnap: () => selectedRef.current,
|
|
98
|
+
slideNodes: () => [...(contentRef.current?.querySelectorAll('[data-slot="carousel-item"]') || [])]
|
|
99
|
+
}), [emit, loop, scrollTo]);
|
|
100
|
+
React.useEffect(() => {
|
|
101
|
+
setApi?.(api);
|
|
102
|
+
return () => setApi?.(undefined);
|
|
103
|
+
}, [api, setApi]);
|
|
104
|
+
React.useEffect(() => {
|
|
105
|
+
const active = plugins.filter(Boolean);
|
|
106
|
+
active.forEach(plugin => plugin.init?.(api));
|
|
107
|
+
return () => active.forEach(plugin => plugin.destroy?.());
|
|
108
|
+
}, [api, plugins]);
|
|
109
|
+
const registerContent = React.useCallback(element => {
|
|
110
|
+
contentRef.current = element;
|
|
111
|
+
setSlideCount(element?.querySelectorAll('[data-slot="carousel-item"]').length || 0);
|
|
112
|
+
}, []);
|
|
113
|
+
const selectFromScroll = React.useCallback(index => {
|
|
114
|
+
setSelected(index);
|
|
115
|
+
queueMicrotask(() => emit('select'));
|
|
116
|
+
}, [emit]);
|
|
117
|
+
const handleKeyDown = event => {
|
|
118
|
+
onKeyDown?.(event);
|
|
119
|
+
if (event.defaultPrevented) return;
|
|
120
|
+
const previousKey = orientation === 'vertical' ? 'ArrowUp' : direction === 'rtl' ? 'ArrowRight' : 'ArrowLeft';
|
|
121
|
+
const nextKey = orientation === 'vertical' ? 'ArrowDown' : direction === 'rtl' ? 'ArrowLeft' : 'ArrowRight';
|
|
122
|
+
if (event.key === previousKey) {
|
|
123
|
+
event.preventDefault();
|
|
124
|
+
api.scrollPrev();
|
|
125
|
+
}
|
|
126
|
+
if (event.key === nextKey) {
|
|
127
|
+
event.preventDefault();
|
|
128
|
+
api.scrollNext();
|
|
129
|
+
}
|
|
31
130
|
};
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
131
|
+
const value = React.useMemo(() => ({
|
|
132
|
+
api,
|
|
133
|
+
direction,
|
|
134
|
+
orientation,
|
|
135
|
+
registerContent,
|
|
136
|
+
selectFromScroll,
|
|
137
|
+
selected,
|
|
138
|
+
slideCount
|
|
139
|
+
}), [api, direction, orientation, registerContent, selectFromScroll, selected, slideCount]);
|
|
140
|
+
return /*#__PURE__*/React.createElement(CarouselCtx.Provider, {
|
|
141
|
+
value: value
|
|
142
|
+
}, /*#__PURE__*/React.createElement("div", _extends({}, props, {
|
|
143
|
+
ref: ref,
|
|
37
144
|
role: "region",
|
|
38
|
-
"aria-
|
|
145
|
+
"aria-roledescription": "carousel",
|
|
146
|
+
"data-slot": "carousel",
|
|
147
|
+
"data-orientation": orientation,
|
|
148
|
+
"data-align": align,
|
|
39
149
|
className: `ef-carousel${className ? ' ' + className : ''}`,
|
|
40
|
-
|
|
150
|
+
onKeyDown: handleKeyDown
|
|
151
|
+
}), children));
|
|
152
|
+
});
|
|
153
|
+
export const CarouselContent = /*#__PURE__*/React.forwardRef(function CarouselContent({
|
|
154
|
+
children,
|
|
155
|
+
className,
|
|
156
|
+
style,
|
|
157
|
+
onScroll,
|
|
158
|
+
...props
|
|
159
|
+
}, forwardedRef) {
|
|
160
|
+
const ctx = React.useContext(CarouselCtx);
|
|
161
|
+
const registerContent = ctx?.registerContent;
|
|
162
|
+
const setRef = React.useCallback(element => {
|
|
163
|
+
registerContent?.(element);
|
|
164
|
+
if (typeof forwardedRef === 'function') forwardedRef(element);else if (forwardedRef) forwardedRef.current = element;
|
|
165
|
+
}, [forwardedRef, registerContent]);
|
|
166
|
+
const handleScroll = event => {
|
|
167
|
+
onScroll?.(event);
|
|
168
|
+
if (event.defaultPrevented || !ctx) return;
|
|
169
|
+
const next = closestIndex(event.currentTarget, ctx.orientation);
|
|
170
|
+
if (next !== ctx.selected) ctx.selectFromScroll(next);
|
|
171
|
+
};
|
|
172
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, props, {
|
|
173
|
+
ref: setRef,
|
|
174
|
+
"data-slot": "carousel-content",
|
|
175
|
+
"data-orientation": ctx?.orientation || 'horizontal',
|
|
176
|
+
className: `ef-carousel__content${className ? ' ' + className : ''}`,
|
|
177
|
+
style: style,
|
|
178
|
+
onScroll: handleScroll
|
|
41
179
|
}), /*#__PURE__*/React.createElement("div", {
|
|
42
|
-
|
|
43
|
-
className: "ef-carousel__track"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"aria-
|
|
54
|
-
|
|
55
|
-
className:
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
180
|
+
"data-slot": "carousel-track",
|
|
181
|
+
className: "ef-carousel__track"
|
|
182
|
+
}, children));
|
|
183
|
+
});
|
|
184
|
+
export const CarouselItem = /*#__PURE__*/React.forwardRef(function CarouselItem({
|
|
185
|
+
className,
|
|
186
|
+
...props
|
|
187
|
+
}, ref) {
|
|
188
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, props, {
|
|
189
|
+
ref: ref,
|
|
190
|
+
role: "group",
|
|
191
|
+
"aria-roledescription": "slide",
|
|
192
|
+
"data-slot": "carousel-item",
|
|
193
|
+
className: `ef-carousel__item${className ? ' ' + className : ''}`
|
|
194
|
+
}));
|
|
195
|
+
});
|
|
196
|
+
function CarouselButton({
|
|
197
|
+
kind,
|
|
198
|
+
className,
|
|
199
|
+
children,
|
|
200
|
+
...props
|
|
201
|
+
}, ref) {
|
|
202
|
+
const ctx = React.useContext(CarouselCtx);
|
|
203
|
+
const previous = kind === 'previous';
|
|
204
|
+
const disabled = previous ? !ctx?.api.canScrollPrev() : !ctx?.api.canScrollNext();
|
|
205
|
+
const vertical = ctx?.orientation === 'vertical';
|
|
206
|
+
const rtl = ctx?.direction === 'rtl';
|
|
207
|
+
const icon = vertical ? previous ? 'chevron-up' : 'chevron-down' : previous !== rtl ? 'chevron-left' : 'chevron-right';
|
|
208
|
+
return /*#__PURE__*/React.createElement("button", _extends({}, props, {
|
|
209
|
+
ref: ref,
|
|
61
210
|
type: "button",
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
211
|
+
disabled: props.disabled || disabled,
|
|
212
|
+
"aria-label": props['aria-label'] || (previous ? 'Previous slide' : 'Next slide'),
|
|
213
|
+
"data-slot": `carousel-${kind}`,
|
|
214
|
+
className: `ef-carousel__nav ef-carousel__nav--${kind}${className ? ' ' + className : ''}`,
|
|
215
|
+
onClick: event => {
|
|
216
|
+
props.onClick?.(event);
|
|
217
|
+
if (!event.defaultPrevented) previous ? ctx?.api.scrollPrev() : ctx?.api.scrollNext();
|
|
218
|
+
}
|
|
219
|
+
}), children || /*#__PURE__*/React.createElement(Icon, {
|
|
220
|
+
name: icon,
|
|
68
221
|
size: 16
|
|
69
|
-
}))
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}))) : null);
|
|
80
|
-
}
|
|
222
|
+
}));
|
|
223
|
+
}
|
|
224
|
+
export const CarouselPrevious = /*#__PURE__*/React.forwardRef((props, ref) => CarouselButton({
|
|
225
|
+
...props,
|
|
226
|
+
kind: 'previous'
|
|
227
|
+
}, ref));
|
|
228
|
+
export const CarouselNext = /*#__PURE__*/React.forwardRef((props, ref) => CarouselButton({
|
|
229
|
+
...props,
|
|
230
|
+
kind: 'next'
|
|
231
|
+
}, ref));
|
package/display/Collapsible.d.ts
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
defaultOpen?: boolean;
|
|
5
|
-
/** Controlled open state */
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
|
|
3
|
+
export interface CollapsibleProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
6
4
|
open?: boolean;
|
|
5
|
+
defaultOpen?: boolean;
|
|
7
6
|
onOpenChange?: (open: boolean) => void;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
asChild?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface CollapsibleTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
12
|
+
asChild?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface CollapsibleContentProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
16
|
+
asChild?: boolean;
|
|
17
|
+
forceMount?: boolean;
|
|
11
18
|
}
|
|
12
|
-
|
|
19
|
+
|
|
20
|
+
export declare const Collapsible: React.ForwardRefExoticComponent<CollapsibleProps & React.RefAttributes<HTMLDivElement>>;
|
|
21
|
+
export declare const CollapsibleTrigger: React.ForwardRefExoticComponent<CollapsibleTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
22
|
+
export declare const CollapsibleContent: React.ForwardRefExoticComponent<CollapsibleContentProps & React.RefAttributes<HTMLDivElement>>;
|
package/display/Collapsible.js
CHANGED
|
@@ -1,37 +1,149 @@
|
|
|
1
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
2
|
import React from 'react';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import { mergeRefs } from "../forms/Button.js";
|
|
4
|
+
const CollapsibleStateContext = /*#__PURE__*/React.createContext(null);
|
|
5
|
+
function useCollapsibleState(part) {
|
|
6
|
+
const context = React.useContext(CollapsibleStateContext);
|
|
7
|
+
if (!context) throw new Error(`${part} must be used inside Collapsible`);
|
|
8
|
+
return context;
|
|
9
|
+
}
|
|
10
|
+
function composeEventHandlers(childHandler, ownHandler) {
|
|
11
|
+
return event => {
|
|
12
|
+
childHandler?.(event);
|
|
13
|
+
if (!event.defaultPrevented) ownHandler?.(event);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export const Collapsible = /*#__PURE__*/React.forwardRef(function Collapsible({
|
|
8
17
|
open,
|
|
18
|
+
defaultOpen = false,
|
|
9
19
|
onOpenChange,
|
|
20
|
+
disabled = false,
|
|
21
|
+
asChild = false,
|
|
10
22
|
children,
|
|
11
23
|
style,
|
|
12
24
|
className,
|
|
13
25
|
...rest
|
|
14
|
-
}) {
|
|
15
|
-
const [
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
26
|
+
}, ref) {
|
|
27
|
+
const [uncontrolledOpen, setUncontrolledOpen] = React.useState(defaultOpen);
|
|
28
|
+
const isControlled = open !== undefined;
|
|
29
|
+
const isOpen = isControlled ? open : uncontrolledOpen;
|
|
30
|
+
const contentId = React.useId();
|
|
31
|
+
const setOpen = React.useCallback(next => {
|
|
32
|
+
if (disabled) return;
|
|
33
|
+
const value = typeof next === 'function' ? next(isOpen) : next;
|
|
34
|
+
if (!isControlled) setUncontrolledOpen(value);
|
|
35
|
+
onOpenChange?.(value);
|
|
36
|
+
}, [disabled, isControlled, isOpen, onOpenChange]);
|
|
37
|
+
const state = isOpen ? 'open' : 'closed';
|
|
38
|
+
const context = React.useMemo(() => ({
|
|
39
|
+
contentId,
|
|
40
|
+
disabled,
|
|
41
|
+
open: isOpen,
|
|
42
|
+
setOpen
|
|
43
|
+
}), [contentId, disabled, isOpen, setOpen]);
|
|
44
|
+
const rootProps = {
|
|
45
|
+
...rest,
|
|
46
|
+
ref,
|
|
47
|
+
'data-slot': 'collapsible',
|
|
48
|
+
'data-state': state,
|
|
49
|
+
'data-disabled': disabled ? '' : undefined,
|
|
50
|
+
className: `ef-collapsible${className ? ' ' + className : ''}`,
|
|
51
|
+
style
|
|
52
|
+
};
|
|
53
|
+
const root = asChild ? (() => {
|
|
54
|
+
const child = React.Children.only(children);
|
|
55
|
+
return /*#__PURE__*/React.cloneElement(child, {
|
|
56
|
+
...rootProps,
|
|
57
|
+
...child.props,
|
|
58
|
+
ref: mergeRefs(ref, child.ref),
|
|
59
|
+
'data-slot': 'collapsible',
|
|
60
|
+
'data-state': state,
|
|
61
|
+
'data-disabled': disabled ? '' : undefined,
|
|
62
|
+
className: `${rootProps.className}${child.props.className ? ' ' + child.props.className : ''}`,
|
|
63
|
+
style: {
|
|
64
|
+
...style,
|
|
65
|
+
...child.props.style
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
})() : /*#__PURE__*/React.createElement("div", rootProps, children);
|
|
69
|
+
return /*#__PURE__*/React.createElement(CollapsibleStateContext.Provider, {
|
|
70
|
+
value: context
|
|
71
|
+
}, root);
|
|
72
|
+
});
|
|
73
|
+
export const CollapsibleTrigger = /*#__PURE__*/React.forwardRef(function CollapsibleTrigger({
|
|
74
|
+
asChild = false,
|
|
75
|
+
children,
|
|
76
|
+
onClick,
|
|
77
|
+
...rest
|
|
78
|
+
}, ref) {
|
|
79
|
+
const context = useCollapsibleState('CollapsibleTrigger');
|
|
80
|
+
const state = context.open ? 'open' : 'closed';
|
|
81
|
+
const props = {
|
|
82
|
+
...rest,
|
|
83
|
+
ref,
|
|
84
|
+
type: asChild ? undefined : rest.type || 'button',
|
|
85
|
+
'data-slot': 'collapsible-trigger',
|
|
86
|
+
'data-state': state,
|
|
87
|
+
'data-disabled': context.disabled ? '' : undefined,
|
|
88
|
+
'aria-controls': context.contentId,
|
|
89
|
+
'aria-expanded': context.open,
|
|
90
|
+
disabled: context.disabled || undefined,
|
|
91
|
+
onClick: composeEventHandlers(onClick, () => context.setOpen(value => !value))
|
|
92
|
+
};
|
|
93
|
+
if (asChild) {
|
|
94
|
+
const child = React.Children.only(children);
|
|
95
|
+
return /*#__PURE__*/React.cloneElement(child, {
|
|
96
|
+
...props,
|
|
97
|
+
...child.props,
|
|
98
|
+
ref: mergeRefs(ref, child.ref),
|
|
99
|
+
'data-slot': 'collapsible-trigger',
|
|
100
|
+
'data-state': state,
|
|
101
|
+
'data-disabled': context.disabled ? '' : undefined,
|
|
102
|
+
'aria-controls': context.contentId,
|
|
103
|
+
'aria-expanded': context.open,
|
|
104
|
+
'aria-disabled': context.disabled || undefined,
|
|
105
|
+
onClick: composeEventHandlers(child.props.onClick, props.onClick)
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
return /*#__PURE__*/React.createElement("button", props, children);
|
|
109
|
+
});
|
|
110
|
+
export const CollapsibleContent = /*#__PURE__*/React.forwardRef(function CollapsibleContent({
|
|
111
|
+
asChild = false,
|
|
112
|
+
forceMount = false,
|
|
113
|
+
children,
|
|
114
|
+
...rest
|
|
115
|
+
}, ref) {
|
|
116
|
+
const context = useCollapsibleState('CollapsibleContent');
|
|
117
|
+
const state = context.open ? 'open' : 'closed';
|
|
118
|
+
if (!forceMount && !context.open) return null;
|
|
119
|
+
const props = {
|
|
120
|
+
...rest,
|
|
121
|
+
ref,
|
|
122
|
+
id: context.contentId,
|
|
123
|
+
'data-slot': 'collapsible-content',
|
|
124
|
+
'data-state': state,
|
|
125
|
+
'data-disabled': context.disabled ? '' : undefined,
|
|
126
|
+
hidden: !context.open,
|
|
127
|
+
className: `ef-collapsible__content${rest.className ? ' ' + rest.className : ''}`,
|
|
128
|
+
style: rest.style
|
|
20
129
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
130
|
+
if (asChild) {
|
|
131
|
+
const child = React.Children.only(children);
|
|
132
|
+
return /*#__PURE__*/React.cloneElement(child, {
|
|
133
|
+
...props,
|
|
134
|
+
...child.props,
|
|
135
|
+
ref: mergeRefs(ref, child.ref),
|
|
136
|
+
id: context.contentId,
|
|
137
|
+
'data-slot': 'collapsible-content',
|
|
138
|
+
'data-state': state,
|
|
139
|
+
'data-disabled': context.disabled ? '' : undefined,
|
|
140
|
+
hidden: !context.open,
|
|
141
|
+
className: `${props.className}${child.props.className ? ' ' + child.props.className : ''}`,
|
|
142
|
+
style: {
|
|
143
|
+
...rest.style,
|
|
144
|
+
...child.props.style
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
return /*#__PURE__*/React.createElement("div", props, children);
|
|
149
|
+
});
|