@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.
Files changed (183) hide show
  1. package/README.md +1 -1
  2. package/ai/Bubble.d.ts +16 -0
  3. package/ai/Bubble.js +71 -0
  4. package/ai/ChatMessage.js +2 -5
  5. package/ai/Confirmation.d.ts +0 -7
  6. package/ai/Confirmation.js +3 -6
  7. package/ai/GeneratedImage.d.ts +0 -2
  8. package/ai/GeneratedImage.js +2 -4
  9. package/ai/Marker.d.ts +26 -0
  10. package/ai/Marker.js +67 -0
  11. package/ai/Message.d.ts +13 -0
  12. package/ai/Message.js +68 -0
  13. package/ai/MessageScroller.d.ts +21 -0
  14. package/ai/MessageScroller.js +283 -0
  15. package/ai/ModelSelector.d.ts +2 -2
  16. package/ai/ModelSelector.js +1 -2
  17. package/ai/Player.js +1 -1
  18. package/ai/PromptSteps.js +4 -2
  19. package/ai/Sandbox.d.ts +0 -2
  20. package/ai/Sandbox.js +2 -4
  21. package/ai/Suggestions.d.ts +0 -2
  22. package/ai/Suggestions.js +1 -4
  23. package/ai/WebPreview.d.ts +0 -2
  24. package/ai/WebPreview.js +2 -4
  25. package/code/Console.js +1 -1
  26. package/code/EnvList.d.ts +0 -2
  27. package/code/EnvList.js +2 -3
  28. package/components.css +660 -423
  29. package/data/BarChart.d.ts +0 -2
  30. package/data/BarChart.js +1 -4
  31. package/data/Chart.d.ts +14 -0
  32. package/data/Chart.js +149 -0
  33. package/data/EmptyState.d.ts +8 -13
  34. package/data/EmptyState.js +62 -24
  35. package/data/LineChart.js +7 -4
  36. package/data/Skeleton.d.ts +2 -11
  37. package/data/Skeleton.js +8 -38
  38. package/data/Sparkline.js +4 -1
  39. package/data/StatusDot.d.ts +0 -4
  40. package/data/StatusDot.js +3 -6
  41. package/data/Table.d.ts +11 -4
  42. package/data/Table.js +39 -7
  43. package/dates/Calendar.d.ts +10 -27
  44. package/dates/Calendar.js +250 -184
  45. package/dates/TimePicker.js +2 -2
  46. package/display/Accordion.d.ts +47 -15
  47. package/display/Accordion.js +257 -27
  48. package/display/AspectRatio.d.ts +4 -6
  49. package/display/AspectRatio.js +7 -5
  50. package/display/Avatar.d.ts +17 -14
  51. package/display/Avatar.js +68 -43
  52. package/display/Badge.d.ts +9 -8
  53. package/display/Badge.js +32 -14
  54. package/display/Card.d.ts +11 -13
  55. package/display/Card.js +74 -29
  56. package/display/Carousel.d.ts +23 -15
  57. package/display/Carousel.js +217 -66
  58. package/display/Collapsible.d.ts +19 -9
  59. package/display/Collapsible.js +140 -28
  60. package/display/Direction.d.ts +10 -0
  61. package/display/Direction.js +24 -0
  62. package/display/Item.d.ts +19 -0
  63. package/display/Item.js +152 -0
  64. package/display/Kbd.d.ts +5 -7
  65. package/display/Kbd.js +22 -10
  66. package/display/Link.js +2 -4
  67. package/display/Resizable.d.ts +6 -16
  68. package/display/Resizable.js +141 -58
  69. package/display/ScrollArea.d.ts +3 -1
  70. package/display/ScrollArea.js +30 -5
  71. package/display/Separator.d.ts +9 -0
  72. package/display/Separator.js +18 -0
  73. package/display/Timeline.d.ts +24 -0
  74. package/display/Timeline.js +51 -0
  75. package/display/Toolbar.js +5 -4
  76. package/display/TreeList.d.ts +0 -2
  77. package/display/TreeList.js +2 -5
  78. package/feedback/Alert.d.ts +13 -13
  79. package/feedback/Alert.js +40 -36
  80. package/feedback/AlertDialog.d.ts +30 -0
  81. package/feedback/AlertDialog.js +249 -0
  82. package/feedback/Banner.d.ts +1 -3
  83. package/feedback/Banner.js +1 -5
  84. package/feedback/ConfirmDialog.d.ts +1 -1
  85. package/feedback/ConfirmDialog.js +18 -20
  86. package/feedback/Dialog.d.ts +13 -16
  87. package/feedback/Dialog.js +204 -62
  88. package/feedback/Progress.d.ts +8 -9
  89. package/feedback/Progress.js +42 -24
  90. package/feedback/Sonner.d.ts +8 -0
  91. package/feedback/Sonner.js +238 -0
  92. package/feedback/Spinner.d.ts +2 -9
  93. package/feedback/Spinner.js +19 -28
  94. package/feedback/Tooltip.d.ts +9 -10
  95. package/feedback/Tooltip.js +147 -96
  96. package/files/Attachment.d.ts +27 -0
  97. package/files/Attachment.js +111 -0
  98. package/files/FileDrop.js +3 -1
  99. package/finance/PaymentCard.js +3 -3
  100. package/forms/Button.d.ts +6 -5
  101. package/forms/Button.js +42 -8
  102. package/forms/ButtonGroup.d.ts +11 -3
  103. package/forms/ButtonGroup.js +57 -6
  104. package/forms/Checkbox.d.ts +14 -3
  105. package/forms/Checkbox.js +84 -16
  106. package/forms/Combobox.d.ts +24 -16
  107. package/forms/Combobox.js +466 -135
  108. package/forms/Field.d.ts +14 -0
  109. package/forms/Field.js +99 -0
  110. package/forms/IconButton.d.ts +1 -1
  111. package/forms/IconButton.js +4 -3
  112. package/forms/Input.d.ts +8 -8
  113. package/forms/Input.js +46 -33
  114. package/forms/InputGroup.d.ts +8 -15
  115. package/forms/InputGroup.js +74 -35
  116. package/forms/InputOTP.d.ts +13 -0
  117. package/forms/InputOTP.js +125 -0
  118. package/forms/Label.d.ts +2 -6
  119. package/forms/Label.js +6 -4
  120. package/forms/NativeSelect.d.ts +16 -0
  121. package/forms/NativeSelect.js +35 -0
  122. package/forms/NumberInput.js +2 -2
  123. package/forms/Radio.d.ts +12 -1
  124. package/forms/Radio.js +76 -6
  125. package/forms/Select.d.ts +12 -9
  126. package/forms/Select.js +254 -42
  127. package/forms/Slider.d.ts +10 -17
  128. package/forms/Slider.js +78 -39
  129. package/forms/Switch.d.ts +8 -2
  130. package/forms/Switch.js +46 -15
  131. package/forms/Textarea.d.ts +1 -1
  132. package/forms/Textarea.js +26 -18
  133. package/forms/Toggle.d.ts +18 -15
  134. package/forms/Toggle.js +96 -42
  135. package/icons/_svg.js +2 -0
  136. package/index.d.ts +20 -8
  137. package/index.js +50 -38
  138. package/navigation/Breadcrumbs.d.ts +18 -11
  139. package/navigation/Breadcrumbs.js +99 -26
  140. package/navigation/Menubar.d.ts +52 -10
  141. package/navigation/Menubar.js +191 -146
  142. package/navigation/NavigationMenu.d.ts +15 -0
  143. package/navigation/NavigationMenu.js +296 -0
  144. package/navigation/Pagination.d.ts +10 -9
  145. package/navigation/Pagination.js +94 -51
  146. package/navigation/SideNav.js +4 -3
  147. package/navigation/Sidebar.d.ts +29 -0
  148. package/navigation/Sidebar.js +311 -0
  149. package/navigation/Tabs.d.ts +9 -5
  150. package/navigation/Tabs.js +132 -44
  151. package/overlay/Command.d.ts +32 -0
  152. package/overlay/Command.js +257 -0
  153. package/overlay/ContextMenu.d.ts +40 -8
  154. package/overlay/ContextMenu.js +468 -107
  155. package/overlay/Drawer.d.ts +29 -14
  156. package/overlay/Drawer.js +178 -80
  157. package/overlay/DropdownMenu.d.ts +43 -0
  158. package/overlay/DropdownMenu.js +502 -0
  159. package/overlay/HoverCard.d.ts +21 -12
  160. package/overlay/HoverCard.js +129 -61
  161. package/overlay/Popover.d.ts +11 -13
  162. package/overlay/Popover.js +138 -65
  163. package/overlay/Portal.js +21 -7
  164. package/overlay/Sheet.d.ts +11 -0
  165. package/overlay/Sheet.js +62 -0
  166. package/package.json +4 -1
  167. package/tokens/base.css +1 -1
  168. package/dates/DatePicker.d.ts +0 -14
  169. package/dates/DatePicker.js +0 -111
  170. package/dates/DateRangePicker.d.ts +0 -23
  171. package/dates/DateRangePicker.js +0 -150
  172. package/display/ListItem.d.ts +0 -19
  173. package/display/ListItem.js +0 -50
  174. package/feedback/Toast.d.ts +0 -78
  175. package/feedback/Toast.js +0 -192
  176. package/forms/DigitEntry.d.ts +0 -15
  177. package/forms/DigitEntry.js +0 -79
  178. package/forms/FormField.d.ts +0 -82
  179. package/forms/FormField.js +0 -209
  180. package/overlay/CommandPalette.d.ts +0 -21
  181. package/overlay/CommandPalette.js +0 -148
  182. package/overlay/Menu.d.ts +0 -24
  183. 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
- export function Card({
5
- title,
6
- subtitle,
7
- actions,
8
- footer,
9
- padding = 20,
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
- return /*#__PURE__*/React.createElement("div", _extends({
18
- className: `ef-card${elevated ? ' ef-card--elevated' : ''}${interactive ? ' ef-card--interactive' : ''}${className ? ' ' + className : ''}`,
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
- }, rest), title || actions ? /*#__PURE__*/React.createElement("div", {
21
- className: "ef-card__header"
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
+ });
@@ -1,16 +1,24 @@
1
- export interface CarouselProps {
2
- /** One slide per child */
3
- children: React.ReactNode;
4
- /** CSS width of each item @default '280px' */
5
- itemWidth?: string;
6
- /** Px between items @default 14 */
7
- gap?: number;
8
- /** Prev / next arrows @default true */
9
- showControls?: boolean;
10
- /** Position dots below @default true */
11
- showDots?: boolean;
12
- ariaLabel?: string;
13
- style?: React.CSSProperties;
14
- className?: string;
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 declare function Carousel(props: CarouselProps): React.JSX.Element;
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>>;
@@ -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
- export function Carousel({
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
- ...rest
16
- }) {
17
- const track = React.useRef(null);
18
- const [index, setIndex] = React.useState(0);
19
- const count = React.Children.count(children);
20
- const step = () => {
21
- const el = track.current;
22
- if (!el || !el.firstChild) return el ? el.clientWidth : 0;
23
- return el.firstChild.getBoundingClientRect().width + gap;
24
- };
25
- const goTo = i => {
26
- const el = track.current;
27
- if (el) el.scrollTo({
28
- left: i * step(),
29
- behavior: prefersReducedMotion() ? 'auto' : 'smooth'
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 onScroll = () => {
33
- const el = track.current;
34
- if (el) setIndex(Math.min(count - 1, Math.max(0, Math.round(el.scrollLeft / step()))));
35
- };
36
- return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
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-label": ariaLabel,
145
+ "aria-roledescription": "carousel",
146
+ "data-slot": "carousel",
147
+ "data-orientation": orientation,
148
+ "data-align": align,
39
149
  className: `ef-carousel${className ? ' ' + className : ''}`,
40
- style: style
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
- ref: track,
43
- className: "ef-carousel__track",
44
- style: {
45
- gridAutoColumns: itemWidth,
46
- gap
47
- },
48
- onScroll: onScroll
49
- }, React.Children.map(children, c => /*#__PURE__*/React.createElement("div", {
50
- className: "ef-carousel__item"
51
- }, c))), showControls ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("button", {
52
- type: "button",
53
- "aria-label": "Previous",
54
- disabled: index <= 0,
55
- className: "ef-carousel__nav ef-carousel__nav--prev",
56
- onClick: () => goTo(index - 1)
57
- }, /*#__PURE__*/React.createElement(Icon, {
58
- name: "chevron-left",
59
- size: 16
60
- })), /*#__PURE__*/React.createElement("button", {
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
- "aria-label": "Next",
63
- disabled: index >= count - 1,
64
- className: "ef-carousel__nav ef-carousel__nav--next",
65
- onClick: () => goTo(index + 1)
66
- }, /*#__PURE__*/React.createElement(Icon, {
67
- name: "chevron-right",
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
- }))) : null, showDots ? /*#__PURE__*/React.createElement("div", {
70
- className: "ef-carousel__dots"
71
- }, Array.from({
72
- length: count
73
- }, (_, i) => /*#__PURE__*/React.createElement("button", {
74
- key: i,
75
- type: "button",
76
- "aria-label": `Go to item ${i + 1}`,
77
- className: `ef-carousel__dot${i === index ? ' ef-carousel__dot--on' : ''}`,
78
- onClick: () => goTo(i)
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));
@@ -1,12 +1,22 @@
1
- export interface CollapsibleProps {
2
- /** Trigger row content */
3
- title: React.ReactNode;
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
- children?: React.ReactNode;
9
- style?: React.CSSProperties;
10
- className?: string;
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
- export declare function Collapsible(props: CollapsibleProps): React.JSX.Element;
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>>;
@@ -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 { Icon } from "../icons/Icon.js";
5
- export function Collapsible({
6
- title,
7
- defaultOpen,
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 [un, setUn] = React.useState(!!defaultOpen);
16
- const isOpen = open !== undefined ? open : un;
17
- const flip = () => {
18
- if (open === undefined) setUn(!isOpen);
19
- if (onOpenChange) onOpenChange(!isOpen);
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
- return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
22
- className: `ef-collapsible${isOpen ? ' ef-collapsible--open' : ''}${className ? ' ' + className : ''}`,
23
- style: style
24
- }), /*#__PURE__*/React.createElement("button", {
25
- type: "button",
26
- className: "ef-collapsible__trigger",
27
- "aria-expanded": isOpen,
28
- onClick: flip
29
- }, /*#__PURE__*/React.createElement("span", {
30
- className: "ef-collapsible__chev"
31
- }, /*#__PURE__*/React.createElement(Icon, {
32
- name: "chevron-right",
33
- size: 16
34
- })), title), isOpen ? /*#__PURE__*/React.createElement("div", {
35
- className: "ef-collapsible__body"
36
- }, children) : null);
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
+ });