@refraction-ui/react 0.19.1 → 0.20.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/dist/chunk-533MCMSU.js +2355 -0
- package/dist/chunk-533MCMSU.js.map +7 -0
- package/dist/chunk-AMK4VCBG.js +250 -0
- package/dist/chunk-AMK4VCBG.js.map +7 -0
- package/dist/chunk-BOLFYVI6.js +90 -0
- package/dist/chunk-BOLFYVI6.js.map +7 -0
- package/dist/chunk-F7B64KT3.js +187 -0
- package/dist/chunk-F7B64KT3.js.map +7 -0
- package/dist/chunk-FD37DFCC.js +77 -0
- package/dist/chunk-FD37DFCC.js.map +7 -0
- package/dist/chunk-H54FLNAF.js +132 -0
- package/dist/chunk-H54FLNAF.js.map +7 -0
- package/dist/chunk-INP46354.js +664 -0
- package/dist/chunk-INP46354.js.map +7 -0
- package/dist/chunk-ONACRMG4.js +116 -0
- package/dist/chunk-ONACRMG4.js.map +7 -0
- package/dist/chunk-SDZ3LROZ.js +7 -0
- package/dist/chunk-SDZ3LROZ.js.map +7 -0
- package/dist/chunk-TOZBR4GL.js +154 -0
- package/dist/chunk-TOZBR4GL.js.map +7 -0
- package/dist/chunk-UNEM2TRI.js +225 -0
- package/dist/chunk-UNEM2TRI.js.map +7 -0
- package/dist/chunk-VK3EQ34F.js +92 -0
- package/dist/chunk-VK3EQ34F.js.map +7 -0
- package/dist/chunk-WK2IIUFO.js +316 -0
- package/dist/chunk-WK2IIUFO.js.map +7 -0
- package/dist/chunk-WSPJTQAV.js +59 -0
- package/dist/chunk-WSPJTQAV.js.map +7 -0
- package/dist/chunk-XWP763SH.js +3 -2
- package/dist/chunk-XWP763SH.js.map +7 -1
- package/dist/chunk-Y2FNNAIL.js +80 -0
- package/dist/chunk-Y2FNNAIL.js.map +1 -0
- package/dist/{chunk-4A4BW3GR.js → chunk-ZF3OHCGV.js} +28 -5
- package/dist/chunk-ZF3OHCGV.js.map +7 -0
- package/dist/form.cjs +5 -11
- package/dist/form.cjs.map +1 -1
- package/dist/form.js +6 -12
- package/dist/form.js.map +1 -1
- package/dist/index.cjs +2879 -33936
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +126 -28780
- package/dist/internal/react-app-shell/index.d.cts +2 -22
- package/dist/internal/react-app-shell/index.d.ts +2 -22
- package/dist/internal/react-badge/index.d.cts +5 -0
- package/dist/internal/react-badge/index.d.ts +5 -0
- package/dist/internal/react-callout/index.d.cts +4 -0
- package/dist/internal/react-callout/index.d.ts +4 -0
- package/dist/internal/react-card/index.d.cts +8 -1
- package/dist/internal/react-card/index.d.ts +8 -1
- package/dist/internal/react-collapsible/index.d.cts +0 -3
- package/dist/internal/react-collapsible/index.d.ts +0 -3
- package/dist/internal/react-combobox/index.d.cts +0 -3
- package/dist/internal/react-combobox/index.d.ts +0 -3
- package/dist/internal/react-command/index.d.cts +0 -3
- package/dist/internal/react-command/index.d.ts +0 -3
- package/dist/internal/react-data-table/index.d.cts +0 -3
- package/dist/internal/react-data-table/index.d.ts +0 -3
- package/dist/internal/react-dialog/index.d.cts +0 -3
- package/dist/internal/react-dialog/index.d.ts +0 -3
- package/dist/internal/react-dropdown-menu/index.d.cts +0 -3
- package/dist/internal/react-dropdown-menu/index.d.ts +0 -3
- package/dist/internal/react-feedback-dialog/index.d.cts +0 -3
- package/dist/internal/react-feedback-dialog/index.d.ts +0 -3
- package/dist/internal/react-form/index.d.cts +2 -21
- package/dist/internal/react-form/index.d.ts +2 -21
- package/dist/internal/react-keyboard-shortcut/index.d.cts +0 -6
- package/dist/internal/react-keyboard-shortcut/index.d.ts +0 -6
- package/dist/internal/react-link-card/index.d.cts +8 -2
- package/dist/internal/react-link-card/index.d.ts +8 -2
- package/dist/internal/react-popover/index.d.cts +0 -3
- package/dist/internal/react-popover/index.d.ts +0 -3
- package/dist/internal/react-sheet/index.d.cts +0 -3
- package/dist/internal/react-sheet/index.d.ts +0 -3
- package/dist/internal/react-slot/index.d.cts +23 -0
- package/dist/internal/react-slot/index.d.ts +23 -0
- package/dist/internal/react-toast/index.d.cts +0 -3
- package/dist/internal/react-toast/index.d.ts +0 -3
- package/dist/internal/react-tooltip/index.d.cts +0 -3
- package/dist/internal/react-tooltip/index.d.ts +0 -3
- package/dist/react-accordion.js +125 -0
- package/dist/react-accordion.js.map +7 -0
- package/dist/react-ai.js +257 -0
- package/dist/react-ai.js.map +7 -0
- package/dist/react-analytics.js +1698 -0
- package/dist/react-analytics.js.map +7 -0
- package/dist/react-animated-text.js +164 -0
- package/dist/react-animated-text.js.map +7 -0
- package/dist/react-app-shell.js +631 -0
- package/dist/react-app-shell.js.map +7 -0
- package/dist/react-audience-feature-card.js +53 -0
- package/dist/react-audience-feature-card.js.map +7 -0
- package/dist/react-audio-room.js +166 -0
- package/dist/react-audio-room.js.map +7 -0
- package/dist/react-auth.js +211 -0
- package/dist/react-auth.js.map +7 -0
- package/dist/react-avatar-group.js +154 -0
- package/dist/react-avatar-group.js.map +7 -0
- package/dist/react-avatar.js +168 -0
- package/dist/react-avatar.js.map +7 -0
- package/dist/react-badge.js +86 -0
- package/dist/react-badge.js.map +7 -0
- package/dist/react-bottom-nav.js +67 -0
- package/dist/react-bottom-nav.js.map +7 -0
- package/dist/react-brand-network-cell.js +92 -0
- package/dist/react-brand-network-cell.js.map +7 -0
- package/dist/react-breadcrumbs.js +104 -0
- package/dist/react-breadcrumbs.js.map +7 -0
- package/dist/react-browser-chrome-mock.js +89 -0
- package/dist/react-browser-chrome-mock.js.map +7 -0
- package/dist/react-button.js +13 -0
- package/dist/react-button.js.map +7 -0
- package/dist/react-calendar.js +301 -0
- package/dist/react-calendar.js.map +7 -0
- package/dist/react-call-controls.js +113 -0
- package/dist/react-call-controls.js.map +7 -0
- package/dist/react-callout.js +152 -0
- package/dist/react-callout.js.map +7 -0
- package/dist/react-card-grid.js +34 -0
- package/dist/react-card-grid.js.map +7 -0
- package/dist/react-card.js +200 -0
- package/dist/react-card.js.map +7 -0
- package/dist/react-carousel.js +132 -0
- package/dist/react-carousel.js.map +7 -0
- package/dist/react-charts.js +509 -0
- package/dist/react-charts.js.map +7 -0
- package/dist/react-checkbox.js +156 -0
- package/dist/react-checkbox.js.map +7 -0
- package/dist/react-checklist.js +168 -0
- package/dist/react-checklist.js.map +7 -0
- package/dist/react-code-block.js +78 -0
- package/dist/react-code-block.js.map +7 -0
- package/dist/react-code-editor.js +184 -0
- package/dist/react-code-editor.js.map +7 -0
- package/dist/react-collapsible.js +192 -0
- package/dist/react-collapsible.js.map +7 -0
- package/dist/react-combobox.js +609 -0
- package/dist/react-combobox.js.map +7 -0
- package/dist/react-command-input.js +202 -0
- package/dist/react-command-input.js.map +7 -0
- package/dist/react-command.js +364 -0
- package/dist/react-command.js.map +7 -0
- package/dist/react-composer.js +2036 -0
- package/dist/react-composer.js.map +7 -0
- package/dist/react-content-protection.js +133 -0
- package/dist/react-content-protection.js.map +7 -0
- package/dist/react-conversation.js +1226 -0
- package/dist/react-conversation.js.map +7 -0
- package/dist/react-cookie-consent.js +291 -0
- package/dist/react-cookie-consent.js.map +7 -0
- package/dist/react-data-table.js +310 -0
- package/dist/react-data-table.js.map +7 -0
- package/dist/react-date-picker.js +95 -0
- package/dist/react-date-picker.js.map +7 -0
- package/dist/react-device-frame.js +137 -0
- package/dist/react-device-frame.js.map +7 -0
- package/dist/react-dialog.js +218 -0
- package/dist/react-dialog.js.map +7 -0
- package/dist/react-diff-viewer.js +460 -0
- package/dist/react-diff-viewer.js.map +7 -0
- package/dist/react-dropdown-menu.js +292 -0
- package/dist/react-dropdown-menu.js.map +7 -0
- package/dist/react-editor-status-bar.js +148 -0
- package/dist/react-editor-status-bar.js.map +7 -0
- package/dist/react-editor-tabs.js +159 -0
- package/dist/react-editor-tabs.js.map +7 -0
- package/dist/react-emoji-picker.js +238 -0
- package/dist/react-emoji-picker.js.map +7 -0
- package/dist/react-empty-state.js +90 -0
- package/dist/react-empty-state.js.map +7 -0
- package/dist/react-feedback-dialog.js +275 -0
- package/dist/react-feedback-dialog.js.map +7 -0
- package/dist/react-file-tree.js +376 -0
- package/dist/react-file-tree.js.map +7 -0
- package/dist/react-file-upload.js +360 -0
- package/dist/react-file-upload.js.map +7 -0
- package/dist/react-floating-reactions.js +124 -0
- package/dist/react-floating-reactions.js.map +7 -0
- package/dist/react-flow-editor.js +198 -0
- package/dist/react-flow-editor.js.map +7 -0
- package/dist/react-footer.js +67 -0
- package/dist/react-footer.js.map +7 -0
- package/dist/react-graph-view.js +197 -0
- package/dist/react-graph-view.js.map +7 -0
- package/dist/react-icon-system.js +9 -0
- package/dist/react-icon-system.js.map +7 -0
- package/dist/react-infinite-canvas.js +8 -0
- package/dist/react-infinite-canvas.js.map +7 -0
- package/dist/react-inline-editor.js +216 -0
- package/dist/react-inline-editor.js.map +7 -0
- package/dist/react-input-group.js +150 -0
- package/dist/react-input-group.js.map +7 -0
- package/dist/react-input.js +10 -0
- package/dist/react-input.js.map +7 -0
- package/dist/react-install-prompt.js +132 -0
- package/dist/react-install-prompt.js.map +7 -0
- package/dist/react-kanban-board.js +198 -0
- package/dist/react-kanban-board.js.map +7 -0
- package/dist/react-keyboard-shortcut.js +36 -0
- package/dist/react-keyboard-shortcut.js.map +7 -0
- package/dist/react-language-selector.js +311 -0
- package/dist/react-language-selector.js.map +7 -0
- package/dist/react-link-card.js +48 -0
- package/dist/react-link-card.js.map +7 -0
- package/dist/react-live-captions.js +92 -0
- package/dist/react-live-captions.js.map +7 -0
- package/dist/react-live-cursors.js +145 -0
- package/dist/react-live-cursors.js.map +7 -0
- package/dist/react-live-transcript.js +117 -0
- package/dist/react-live-transcript.js.map +7 -0
- package/dist/react-location-selector.js +252 -0
- package/dist/react-location-selector.js.map +7 -0
- package/dist/react-logger.js +415 -0
- package/dist/react-logger.js.map +7 -0
- package/dist/react-markdown-renderer.js +12 -0
- package/dist/react-markdown-renderer.js.map +7 -0
- package/dist/react-marquee-strip.js +62 -0
- package/dist/react-marquee-strip.js.map +7 -0
- package/dist/react-mascot.js +367 -0
- package/dist/react-mascot.js.map +7 -0
- package/dist/react-mastery-bar.js +97 -0
- package/dist/react-mastery-bar.js.map +7 -0
- package/dist/react-mini-map.js +207 -0
- package/dist/react-mini-map.js.map +7 -0
- package/dist/react-mobile-nav.js +216 -0
- package/dist/react-mobile-nav.js.map +7 -0
- package/dist/react-navbar.js +96 -0
- package/dist/react-navbar.js.map +7 -0
- package/dist/react-numbered-steps.js +67 -0
- package/dist/react-numbered-steps.js.map +7 -0
- package/dist/react-otp-input.js +318 -0
- package/dist/react-otp-input.js.map +7 -0
- package/dist/react-pagination.js +199 -0
- package/dist/react-pagination.js.map +7 -0
- package/dist/react-password-input.js +104 -0
- package/dist/react-password-input.js.map +7 -0
- package/dist/react-payment.js +81 -0
- package/dist/react-payment.js.map +7 -0
- package/dist/react-popover.js +176 -0
- package/dist/react-popover.js.map +7 -0
- package/dist/react-pre-call-lobby.js +309 -0
- package/dist/react-pre-call-lobby.js.map +7 -0
- package/dist/react-presence-indicator.js +86 -0
- package/dist/react-presence-indicator.js.map +7 -0
- package/dist/react-pricing-card.js +142 -0
- package/dist/react-pricing-card.js.map +7 -0
- package/dist/react-progress-display.js +188 -0
- package/dist/react-progress-display.js.map +7 -0
- package/dist/react-radial-gauge.js +193 -0
- package/dist/react-radial-gauge.js.map +7 -0
- package/dist/react-radio.js +169 -0
- package/dist/react-radio.js.map +7 -0
- package/dist/react-rating-scale.js +171 -0
- package/dist/react-rating-scale.js.map +7 -0
- package/dist/react-reaction-bar.js +111 -0
- package/dist/react-reaction-bar.js.map +7 -0
- package/dist/react-resizable-layout.js +298 -0
- package/dist/react-resizable-layout.js.map +7 -0
- package/dist/react-rich-editor.js +1 -0
- package/dist/react-rich-editor.js.map +7 -0
- package/dist/react-search-bar.js +285 -0
- package/dist/react-search-bar.js.map +7 -0
- package/dist/react-section-head.js +65 -0
- package/dist/react-section-head.js.map +7 -0
- package/dist/react-segmented-control.js +215 -0
- package/dist/react-segmented-control.js.map +7 -0
- package/dist/react-select.js +389 -0
- package/dist/react-select.js.map +7 -0
- package/dist/react-separator.js +86 -0
- package/dist/react-separator.js.map +7 -0
- package/dist/react-sheet.js +310 -0
- package/dist/react-sheet.js.map +7 -0
- package/dist/react-sidebar.js +100 -0
- package/dist/react-sidebar.js.map +7 -0
- package/dist/react-skeleton.js +91 -0
- package/dist/react-skeleton.js.map +7 -0
- package/dist/react-skip-to-content.js +38 -0
- package/dist/react-skip-to-content.js.map +7 -0
- package/dist/react-slide-viewer.js +264 -0
- package/dist/react-slide-viewer.js.map +7 -0
- package/dist/react-slider.js +105 -0
- package/dist/react-slider.js.map +7 -0
- package/dist/react-slot-picker.js +184 -0
- package/dist/react-slot-picker.js.map +7 -0
- package/dist/react-slot.js +7 -0
- package/dist/react-slot.js.map +7 -0
- package/dist/react-social-auth-button.js +169 -0
- package/dist/react-social-auth-button.js.map +7 -0
- package/dist/react-sortable-list.js +204 -0
- package/dist/react-sortable-list.js.map +7 -0
- package/dist/react-stat-grid.js +69 -0
- package/dist/react-stat-grid.js.map +7 -0
- package/dist/react-status-indicator.js +117 -0
- package/dist/react-status-indicator.js.map +7 -0
- package/dist/react-steps.js +167 -0
- package/dist/react-steps.js.map +7 -0
- package/dist/react-sticky-note.js +131 -0
- package/dist/react-sticky-note.js.map +7 -0
- package/dist/react-switch.js +139 -0
- package/dist/react-switch.js.map +7 -0
- package/dist/react-table-of-contents.js +80 -0
- package/dist/react-table-of-contents.js.map +7 -0
- package/dist/react-tabs.js +230 -0
- package/dist/react-tabs.js.map +7 -0
- package/dist/react-terminal.js +101 -0
- package/dist/react-terminal.js.map +7 -0
- package/dist/react-test-results.js +158 -0
- package/dist/react-test-results.js.map +7 -0
- package/dist/react-textarea.js +89 -0
- package/dist/react-textarea.js.map +7 -0
- package/dist/react-thread-view.js +139 -0
- package/dist/react-thread-view.js.map +7 -0
- package/dist/react-timeline.js +153 -0
- package/dist/react-timeline.js.map +7 -0
- package/dist/react-toast.js +253 -0
- package/dist/react-toast.js.map +7 -0
- package/dist/react-tooltip.js +221 -0
- package/dist/react-tooltip.js.map +7 -0
- package/dist/react-version-selector.js +270 -0
- package/dist/react-version-selector.js.map +7 -0
- package/dist/react-video-grid.js +129 -0
- package/dist/react-video-grid.js.map +7 -0
- package/dist/react-video-player.js +206 -0
- package/dist/react-video-player.js.map +7 -0
- package/dist/react-video-tile.js +8 -0
- package/dist/react-video-tile.js.map +7 -0
- package/dist/react-voice-pill.js +314 -0
- package/dist/react-voice-pill.js.map +7 -0
- package/dist/react-waveform.js +558 -0
- package/dist/react-waveform.js.map +7 -0
- package/dist/react-wizard.js +337 -0
- package/dist/react-wizard.js.map +7 -0
- package/dist/styles.css +7 -0
- package/dist/theme.js +1 -1
- package/package.json +3 -2
- package/dist/applicationinsights-web-H7OBLIVJ.js +0 -23393
- package/dist/applicationinsights-web-H7OBLIVJ.js.map +0 -1
- package/dist/chunk-4A4BW3GR.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/module-X3HTTRQK.js +0 -6438
- package/dist/module-X3HTTRQK.js.map +0 -1
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createAccordion,
|
|
3
|
+
isItemOpen
|
|
4
|
+
} from "./chunk-FD37DFCC.js";
|
|
5
|
+
import {
|
|
6
|
+
cn,
|
|
7
|
+
devWarn
|
|
8
|
+
} from "./chunk-ZF3OHCGV.js";
|
|
9
|
+
|
|
10
|
+
// ../react-carousel/dist/index.js
|
|
11
|
+
import * as React from "react";
|
|
12
|
+
|
|
13
|
+
// ../carousel/dist/index.js
|
|
14
|
+
function createCarousel(config = {}) {
|
|
15
|
+
return createAccordion(config);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// ../react-carousel/dist/index.js
|
|
19
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
20
|
+
var CarouselContext = React.createContext(null);
|
|
21
|
+
var Carousel = React.forwardRef(
|
|
22
|
+
function Carousel2({ className, type = "single", collapsible, value: controlledValue, defaultValue, onValueChange, ...props }, ref) {
|
|
23
|
+
const apiRef = React.useRef(null);
|
|
24
|
+
if (apiRef.current === null) {
|
|
25
|
+
apiRef.current = createCarousel({ type, collapsible, defaultValue, value: controlledValue, onValueChange });
|
|
26
|
+
}
|
|
27
|
+
const api = apiRef.current;
|
|
28
|
+
const state = React.useSyncExternalStore(api.subscribe, api.getState, api.getState);
|
|
29
|
+
React.useEffect(() => {
|
|
30
|
+
api.setOptions({ type, collapsible, onValueChange });
|
|
31
|
+
});
|
|
32
|
+
React.useEffect(() => {
|
|
33
|
+
if (controlledValue !== void 0) api.setValue(controlledValue);
|
|
34
|
+
}, [api, controlledValue]);
|
|
35
|
+
return /* @__PURE__ */ jsx(CarouselContext.Provider, { value: { state, toggleItem: api.toggleItem }, children: /* @__PURE__ */ jsx("div", { ref, className: cn("flex flex-col w-full", className), ...props }) });
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
var CarouselItemContext = React.createContext(null);
|
|
39
|
+
var CarouselItem = React.forwardRef(
|
|
40
|
+
function CarouselItem2({ className, value, ...props }, ref) {
|
|
41
|
+
const context = React.useContext(CarouselContext);
|
|
42
|
+
if (!context) {
|
|
43
|
+
devWarn(
|
|
44
|
+
"react-carousel/carousel-item-outside-carousel",
|
|
45
|
+
"CarouselItem was rendered outside of <Carousel>. Wrap it in <Carousel>."
|
|
46
|
+
);
|
|
47
|
+
throw new Error("CarouselItem must be within Carousel");
|
|
48
|
+
}
|
|
49
|
+
const isOpen = isItemOpen(context.state, value);
|
|
50
|
+
return /* @__PURE__ */ jsx(CarouselItemContext.Provider, { value: { value, isOpen }, children: /* @__PURE__ */ jsx("div", { ref, className: cn("border-b border-border", className), "data-state": isOpen ? "open" : "closed", ...props }) });
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
var CarouselTrigger = React.forwardRef(
|
|
54
|
+
function CarouselTrigger2({ className, children, ...props }, ref) {
|
|
55
|
+
const carouselContext = React.useContext(CarouselContext);
|
|
56
|
+
const itemContext = React.useContext(CarouselItemContext);
|
|
57
|
+
if (!carouselContext || !itemContext) {
|
|
58
|
+
devWarn(
|
|
59
|
+
"react-carousel/carousel-trigger-outside-item",
|
|
60
|
+
"CarouselTrigger was rendered outside of a <CarouselItem> within <Carousel>. Nest it inside <CarouselItem>."
|
|
61
|
+
);
|
|
62
|
+
throw new Error("CarouselTrigger missing context");
|
|
63
|
+
}
|
|
64
|
+
return /* @__PURE__ */ jsx("h3", { className: "flex m-0 p-0", children: /* @__PURE__ */ jsxs(
|
|
65
|
+
"button",
|
|
66
|
+
{
|
|
67
|
+
ref,
|
|
68
|
+
type: "button",
|
|
69
|
+
"aria-expanded": itemContext.isOpen,
|
|
70
|
+
className: cn(
|
|
71
|
+
"flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",
|
|
72
|
+
className
|
|
73
|
+
),
|
|
74
|
+
"data-state": itemContext.isOpen ? "open" : "closed",
|
|
75
|
+
onClick: () => carouselContext.toggleItem(itemContext.value),
|
|
76
|
+
...props,
|
|
77
|
+
children: [
|
|
78
|
+
children,
|
|
79
|
+
/* @__PURE__ */ jsx(
|
|
80
|
+
"svg",
|
|
81
|
+
{
|
|
82
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
83
|
+
width: "24",
|
|
84
|
+
height: "24",
|
|
85
|
+
viewBox: "0 0 24 24",
|
|
86
|
+
fill: "none",
|
|
87
|
+
stroke: "currentColor",
|
|
88
|
+
strokeWidth: "2",
|
|
89
|
+
strokeLinecap: "round",
|
|
90
|
+
strokeLinejoin: "round",
|
|
91
|
+
className: "h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200",
|
|
92
|
+
children: /* @__PURE__ */ jsx("path", { d: "m6 9 6 6 6-6" })
|
|
93
|
+
}
|
|
94
|
+
)
|
|
95
|
+
]
|
|
96
|
+
}
|
|
97
|
+
) });
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
var CarouselContent = React.forwardRef(
|
|
101
|
+
function CarouselContent2({ className, children, ...props }, ref) {
|
|
102
|
+
const itemContext = React.useContext(CarouselItemContext);
|
|
103
|
+
if (!itemContext) {
|
|
104
|
+
devWarn(
|
|
105
|
+
"react-carousel/carousel-content-outside-item",
|
|
106
|
+
"CarouselContent was rendered outside of a <CarouselItem> within <Carousel>. Nest it inside <CarouselItem>."
|
|
107
|
+
);
|
|
108
|
+
throw new Error("CarouselContent missing context");
|
|
109
|
+
}
|
|
110
|
+
return /* @__PURE__ */ jsx(
|
|
111
|
+
"div",
|
|
112
|
+
{
|
|
113
|
+
ref,
|
|
114
|
+
className: cn(
|
|
115
|
+
"overflow-hidden text-sm",
|
|
116
|
+
className
|
|
117
|
+
),
|
|
118
|
+
"data-state": itemContext.isOpen ? "open" : "closed",
|
|
119
|
+
hidden: !itemContext.isOpen,
|
|
120
|
+
...props,
|
|
121
|
+
children: /* @__PURE__ */ jsx("div", { className: "pb-4 pt-0 text-muted-foreground leading-relaxed", children })
|
|
122
|
+
}
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
);
|
|
126
|
+
export {
|
|
127
|
+
Carousel,
|
|
128
|
+
CarouselContent,
|
|
129
|
+
CarouselItem,
|
|
130
|
+
CarouselTrigger
|
|
131
|
+
};
|
|
132
|
+
//# sourceMappingURL=react-carousel.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../carousel/src/carousel.ts", "../../react-carousel/src/carousel.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * @refraction-ui/carousel — headless \"carousel\" store.\n *\n * Honest note: despite the name, this component is an expand/collapse panel\n * set (an accordion in disguise) — that is the behavior the React adapter and\n * the docs site demo (single/multiple open panels, collapsible toggles). The\n * state machine is therefore shared with `@refraction-ui/accordion` rather\n * than duplicated. A real slide-navigation carousel (active index, next/prev)\n * would be a different core; this package keeps the shipped behavior.\n */\nimport {\n createAccordion,\n isItemOpen,\n type AccordionAPI,\n type AccordionConfig,\n type AccordionState,\n type AccordionType,\n type AccordionValue,\n} from '@refraction-ui/accordion'\n\n/** Expansion mode: one item open at a time, or any number. */\nexport type CarouselType = AccordionType\n\n/** Open item id (`single`) or ids (`multiple`). */\nexport type CarouselValue = AccordionValue\n\n/** Options for {@link createCarousel}. Mirrors {@link AccordionConfig}. */\nexport interface CarouselConfig extends AccordionConfig {}\n\n/** Snapshot of the store. Returned by `getState()`; treat as immutable. */\nexport interface CarouselState extends AccordionState {}\n\n/** The framework-agnostic store. React/Astro adapters wrap this. */\nexport type CarouselAPI = AccordionAPI\n\n/**\n * createCarousel — headless expand/collapse panel store. This is the\n * accordion state machine under the carousel name; see the package note.\n */\nexport function createCarousel(config: CarouselConfig = {}): CarouselAPI {\n return createAccordion(config)\n}\n\n/** Pure open-state check shared by every adapter. */\nexport { isItemOpen }\n", "import * as React from 'react'\nimport { cn, devWarn } from '@refraction-ui/shared'\nimport {\n createCarousel,\n isItemOpen,\n type CarouselAPI,\n type CarouselState,\n} from '@refraction-ui/carousel'\n\nconst CarouselContext = React.createContext<{\n state: CarouselState\n toggleItem: CarouselAPI['toggleItem']\n} | null>(null)\n\nexport interface CarouselProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'defaultValue' | 'onChange'> {\n type?: 'single' | 'multiple'\n collapsible?: boolean\n defaultValue?: string | string[]\n value?: string | string[]\n onValueChange?: (value: string | string[]) => void\n}\n\nexport const Carousel = React.forwardRef<HTMLDivElement, CarouselProps>(\n function Carousel({ className, type = 'single', collapsible, value: controlledValue, defaultValue, onValueChange, ...props }, ref) {\n // The headless core owns the open/closed state machine; it is created once\n // and props are synced into it below.\n const apiRef = React.useRef<CarouselAPI | null>(null)\n if (apiRef.current === null) {\n apiRef.current = createCarousel({ type, collapsible, defaultValue, value: controlledValue, onValueChange })\n }\n const api = apiRef.current\n\n const state = React.useSyncExternalStore(api.subscribe, api.getState, api.getState)\n\n React.useEffect(() => {\n api.setOptions({ type, collapsible, onValueChange })\n })\n React.useEffect(() => {\n if (controlledValue !== undefined) api.setValue(controlledValue)\n }, [api, controlledValue])\n\n return (\n <CarouselContext.Provider value={{ state, toggleItem: api.toggleItem }}>\n <div ref={ref} className={cn(\"flex flex-col w-full\", className)} {...props} />\n </CarouselContext.Provider>\n )\n }\n)\n\nconst CarouselItemContext = React.createContext<{ value: string; isOpen: boolean } | null>(null)\n\nexport interface CarouselItemProps extends React.HTMLAttributes<HTMLDivElement> {\n value: string\n}\n\nexport const CarouselItem = React.forwardRef<HTMLDivElement, CarouselItemProps>(\n function CarouselItem({ className, value, ...props }, ref) {\n const context = React.useContext(CarouselContext)\n if (!context) {\n devWarn(\n 'react-carousel/carousel-item-outside-carousel',\n 'CarouselItem was rendered outside of <Carousel>. Wrap it in <Carousel>.',\n )\n throw new Error('CarouselItem must be within Carousel')\n }\n\n const isOpen = isItemOpen(context.state, value)\n\n return (\n <CarouselItemContext.Provider value={{ value, isOpen }}>\n <div ref={ref} className={cn(\"border-b border-border\", className)} data-state={isOpen ? 'open' : 'closed'} {...props} />\n </CarouselItemContext.Provider>\n )\n }\n)\n\nexport interface CarouselTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {}\n\nexport const CarouselTrigger = React.forwardRef<HTMLButtonElement, CarouselTriggerProps>(\n function CarouselTrigger({ className, children, ...props }, ref) {\n const carouselContext = React.useContext(CarouselContext)\n const itemContext = React.useContext(CarouselItemContext)\n\n if (!carouselContext || !itemContext) {\n devWarn(\n 'react-carousel/carousel-trigger-outside-item',\n 'CarouselTrigger was rendered outside of a <CarouselItem> within <Carousel>. Nest it inside <CarouselItem>.',\n )\n throw new Error('CarouselTrigger missing context')\n }\n\n return (\n <h3 className=\"flex m-0 p-0\">\n <button\n ref={ref}\n type=\"button\"\n aria-expanded={itemContext.isOpen}\n className={cn(\n \"flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180\",\n className\n )}\n data-state={itemContext.isOpen ? 'open' : 'closed'}\n onClick={() => carouselContext.toggleItem(itemContext.value)}\n {...props}\n >\n {children}\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className=\"h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200\"\n >\n <path d=\"m6 9 6 6 6-6\"/>\n </svg>\n </button>\n </h3>\n )\n }\n)\n\nexport interface CarouselContentProps extends React.HTMLAttributes<HTMLDivElement> {}\n\nexport const CarouselContent = React.forwardRef<HTMLDivElement, CarouselContentProps>(\n function CarouselContent({ className, children, ...props }, ref) {\n const itemContext = React.useContext(CarouselItemContext)\n if (!itemContext) {\n devWarn(\n 'react-carousel/carousel-content-outside-item',\n 'CarouselContent was rendered outside of a <CarouselItem> within <Carousel>. Nest it inside <CarouselItem>.',\n )\n throw new Error('CarouselContent missing context')\n }\n\n return (\n <div\n ref={ref}\n className={cn(\n \"overflow-hidden text-sm\",\n className\n )}\n data-state={itemContext.isOpen ? 'open' : 'closed'}\n hidden={!itemContext.isOpen}\n {...props}\n >\n <div className=\"pb-4 pt-0 text-muted-foreground leading-relaxed\">{children}</div>\n </div>\n )\n }\n)\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["Carousel", "CarouselItem", "CarouselTrigger", "CarouselContent"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,509 @@
|
|
|
1
|
+
import {
|
|
2
|
+
devWarn
|
|
3
|
+
} from "./chunk-ZF3OHCGV.js";
|
|
4
|
+
|
|
5
|
+
// ../charts/dist/index.js
|
|
6
|
+
function createLinearScale(domain, range) {
|
|
7
|
+
const [d0, d1] = domain;
|
|
8
|
+
const [r0, r1] = range;
|
|
9
|
+
const domainSpan = d1 - d0;
|
|
10
|
+
const rangeSpan = r1 - r0;
|
|
11
|
+
const scale = ((value) => {
|
|
12
|
+
if (domainSpan === 0) return r0;
|
|
13
|
+
return r0 + (value - d0) / domainSpan * rangeSpan;
|
|
14
|
+
});
|
|
15
|
+
scale.invert = (value) => {
|
|
16
|
+
if (rangeSpan === 0) return d0;
|
|
17
|
+
return d0 + (value - r0) / rangeSpan * domainSpan;
|
|
18
|
+
};
|
|
19
|
+
scale.ticks = (count = 10) => {
|
|
20
|
+
if (count <= 0) return [];
|
|
21
|
+
const ticks = [];
|
|
22
|
+
for (let i = 0; i < count; i++) {
|
|
23
|
+
ticks.push(d0 + domainSpan * i / (count - 1 || 1));
|
|
24
|
+
}
|
|
25
|
+
return ticks;
|
|
26
|
+
};
|
|
27
|
+
scale.type = "linear";
|
|
28
|
+
scale.domain = domain;
|
|
29
|
+
scale.range = range;
|
|
30
|
+
return scale;
|
|
31
|
+
}
|
|
32
|
+
function createBandScale(domain, range, padding = 0) {
|
|
33
|
+
const [r0, r1] = range;
|
|
34
|
+
const rangeSpan = r1 - r0;
|
|
35
|
+
const n = domain.length;
|
|
36
|
+
let step = 0;
|
|
37
|
+
let bw = 0;
|
|
38
|
+
if (n > 0) {
|
|
39
|
+
if (n === 1) {
|
|
40
|
+
bw = rangeSpan;
|
|
41
|
+
step = rangeSpan;
|
|
42
|
+
} else {
|
|
43
|
+
step = n > 0 ? rangeSpan / (n - padding) : 0;
|
|
44
|
+
bw = step * (1 - padding);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const indexMap = /* @__PURE__ */ new Map();
|
|
48
|
+
domain.forEach((d, i) => indexMap.set(d, i));
|
|
49
|
+
const scale = ((value) => {
|
|
50
|
+
const idx = indexMap.get(value);
|
|
51
|
+
if (idx === void 0) return 0;
|
|
52
|
+
return r0 + idx * step;
|
|
53
|
+
});
|
|
54
|
+
scale.bandwidth = () => {
|
|
55
|
+
return Math.max(0, bw);
|
|
56
|
+
};
|
|
57
|
+
scale.type = "band";
|
|
58
|
+
scale.domain = domain;
|
|
59
|
+
scale.range = range;
|
|
60
|
+
return scale;
|
|
61
|
+
}
|
|
62
|
+
function computeExtent(data) {
|
|
63
|
+
let min = data[0];
|
|
64
|
+
let max = data[0];
|
|
65
|
+
for (let i = 1; i < data.length; i++) {
|
|
66
|
+
if (data[i] < min) min = data[i];
|
|
67
|
+
if (data[i] > max) max = data[i];
|
|
68
|
+
}
|
|
69
|
+
return [min, max];
|
|
70
|
+
}
|
|
71
|
+
function computeHistogramBins(data, binCount) {
|
|
72
|
+
const count = binCount ?? Math.ceil(Math.sqrt(data.length));
|
|
73
|
+
const [min, max] = computeExtent(data);
|
|
74
|
+
const span = max - min;
|
|
75
|
+
if (span === 0) {
|
|
76
|
+
const bins2 = [];
|
|
77
|
+
for (let i = 0; i < count; i++) {
|
|
78
|
+
bins2.push({ x0: min, x1: max, count: 0 });
|
|
79
|
+
}
|
|
80
|
+
bins2[0].count = data.length;
|
|
81
|
+
return bins2;
|
|
82
|
+
}
|
|
83
|
+
const binWidth = span / count;
|
|
84
|
+
const bins = [];
|
|
85
|
+
for (let i = 0; i < count; i++) {
|
|
86
|
+
bins.push({
|
|
87
|
+
x0: min + i * binWidth,
|
|
88
|
+
x1: min + (i + 1) * binWidth,
|
|
89
|
+
count: 0
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
for (const value of data) {
|
|
93
|
+
let idx = Math.floor((value - min) / binWidth);
|
|
94
|
+
if (idx >= count) idx = count - 1;
|
|
95
|
+
bins[idx].count++;
|
|
96
|
+
}
|
|
97
|
+
return bins;
|
|
98
|
+
}
|
|
99
|
+
function linePath(points) {
|
|
100
|
+
if (points.length === 0) return "";
|
|
101
|
+
let d = `M${points[0].x},${points[0].y}`;
|
|
102
|
+
for (let i = 1; i < points.length; i++) {
|
|
103
|
+
d += `L${points[i].x},${points[i].y}`;
|
|
104
|
+
}
|
|
105
|
+
return d;
|
|
106
|
+
}
|
|
107
|
+
function arcPath(cx, cy, radius, startAngle, endAngle) {
|
|
108
|
+
const x1 = cx + radius * Math.cos(startAngle);
|
|
109
|
+
const y1 = cy + radius * Math.sin(startAngle);
|
|
110
|
+
const x2 = cx + radius * Math.cos(endAngle);
|
|
111
|
+
const y2 = cy + radius * Math.sin(endAngle);
|
|
112
|
+
const largeArcFlag = endAngle - startAngle > Math.PI ? 1 : 0;
|
|
113
|
+
const r = (n) => Math.round(n * 1e6) / 1e6;
|
|
114
|
+
let d = `M${r(x1)},${r(y1)}`;
|
|
115
|
+
d += `A${radius},${radius} 0 ${largeArcFlag} 1 ${r(x2)},${r(y2)}`;
|
|
116
|
+
d += `L${cx},${cy}`;
|
|
117
|
+
d += "Z";
|
|
118
|
+
return d;
|
|
119
|
+
}
|
|
120
|
+
var DEFAULT_MARGIN = {
|
|
121
|
+
top: 40,
|
|
122
|
+
right: 30,
|
|
123
|
+
bottom: 40,
|
|
124
|
+
left: 75
|
|
125
|
+
};
|
|
126
|
+
var DEFAULT_WIDTH = 600;
|
|
127
|
+
var DEFAULT_HEIGHT = 400;
|
|
128
|
+
function combineDimensions(partial) {
|
|
129
|
+
const width = partial.width ?? DEFAULT_WIDTH;
|
|
130
|
+
const height = partial.height ?? DEFAULT_HEIGHT;
|
|
131
|
+
const margin = {
|
|
132
|
+
...DEFAULT_MARGIN,
|
|
133
|
+
...partial.margin ?? {}
|
|
134
|
+
};
|
|
135
|
+
const boundedWidth = Math.max(0, width - margin.left - margin.right);
|
|
136
|
+
const boundedHeight = Math.max(0, height - margin.top - margin.bottom);
|
|
137
|
+
return { width, height, margin, boundedWidth, boundedHeight };
|
|
138
|
+
}
|
|
139
|
+
function formatTick(value, type) {
|
|
140
|
+
if (type === "string") {
|
|
141
|
+
return String(value);
|
|
142
|
+
}
|
|
143
|
+
if (type === "date") {
|
|
144
|
+
if (value instanceof Date) {
|
|
145
|
+
return value.toISOString().split("T")[0];
|
|
146
|
+
}
|
|
147
|
+
return String(value);
|
|
148
|
+
}
|
|
149
|
+
const num = value;
|
|
150
|
+
if (!Number.isFinite(num)) return String(num);
|
|
151
|
+
if (Number.isInteger(num)) {
|
|
152
|
+
return num.toLocaleString("en-US", { maximumFractionDigits: 0 });
|
|
153
|
+
}
|
|
154
|
+
const formatted = num.toLocaleString("en-US", {
|
|
155
|
+
minimumFractionDigits: 0,
|
|
156
|
+
maximumFractionDigits: 2
|
|
157
|
+
});
|
|
158
|
+
return formatted;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// ../react-charts/dist/index.js
|
|
162
|
+
import { createContext, useContext } from "react";
|
|
163
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
164
|
+
var DEFAULT_MARGIN2 = { top: 40, right: 30, bottom: 40, left: 75 };
|
|
165
|
+
var ChartContext = createContext({
|
|
166
|
+
__isDefault: true,
|
|
167
|
+
dimensions: {
|
|
168
|
+
width: 600,
|
|
169
|
+
height: 400,
|
|
170
|
+
margin: DEFAULT_MARGIN2,
|
|
171
|
+
boundedWidth: 600 - DEFAULT_MARGIN2.left - DEFAULT_MARGIN2.right,
|
|
172
|
+
boundedHeight: 400 - DEFAULT_MARGIN2.top - DEFAULT_MARGIN2.bottom
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
function useChartContext() {
|
|
176
|
+
const ctx = useContext(ChartContext);
|
|
177
|
+
if (ctx.__isDefault) {
|
|
178
|
+
devWarn(
|
|
179
|
+
"react-charts/no-chart-provider",
|
|
180
|
+
"A chart sub-component (Bars/Line/Circles/\u2026) was rendered without a <Chart> ancestor. It is silently falling back to default 600x400 dimensions and will render with the wrong scale. Wrap it in <Chart>\u2026</Chart>."
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
return ctx;
|
|
184
|
+
}
|
|
185
|
+
function Chart({
|
|
186
|
+
width = 600,
|
|
187
|
+
height = 400,
|
|
188
|
+
margin,
|
|
189
|
+
children,
|
|
190
|
+
className
|
|
191
|
+
}) {
|
|
192
|
+
const dimensions = combineDimensions({ width, height, margin });
|
|
193
|
+
return /* @__PURE__ */ jsx("svg", { width, height, className, children: /* @__PURE__ */ jsx(ChartContext.Provider, { value: { dimensions }, children: /* @__PURE__ */ jsx("g", { transform: `translate(${dimensions.margin.left},${dimensions.margin.top})`, children }) }) });
|
|
194
|
+
}
|
|
195
|
+
function Bars({ data, x, y, fill = "currentColor", className }) {
|
|
196
|
+
const { dimensions } = useChartContext();
|
|
197
|
+
const { boundedWidth, boundedHeight } = dimensions;
|
|
198
|
+
const labels = data.map(x);
|
|
199
|
+
const values = data.map(y);
|
|
200
|
+
const [, maxVal] = computeExtent(values);
|
|
201
|
+
const xScale = createBandScale(labels, [0, boundedWidth], 0.1);
|
|
202
|
+
const yScale = createLinearScale([0, maxVal], [boundedHeight, 0]);
|
|
203
|
+
return /* @__PURE__ */ jsx("g", { className, children: data.map((d, i) => {
|
|
204
|
+
const label = labels[i];
|
|
205
|
+
const value = values[i];
|
|
206
|
+
const barX = xScale(label);
|
|
207
|
+
const barY = yScale(value);
|
|
208
|
+
const barHeight = boundedHeight - barY;
|
|
209
|
+
const barWidth = xScale.bandwidth();
|
|
210
|
+
return /* @__PURE__ */ jsx(
|
|
211
|
+
"rect",
|
|
212
|
+
{
|
|
213
|
+
x: barX,
|
|
214
|
+
y: barY,
|
|
215
|
+
width: barWidth,
|
|
216
|
+
height: barHeight,
|
|
217
|
+
fill
|
|
218
|
+
},
|
|
219
|
+
i
|
|
220
|
+
);
|
|
221
|
+
}) });
|
|
222
|
+
}
|
|
223
|
+
function Line({
|
|
224
|
+
data,
|
|
225
|
+
x,
|
|
226
|
+
y,
|
|
227
|
+
stroke = "currentColor",
|
|
228
|
+
strokeWidth = 2,
|
|
229
|
+
fill = "none",
|
|
230
|
+
className
|
|
231
|
+
}) {
|
|
232
|
+
const { dimensions } = useChartContext();
|
|
233
|
+
const { boundedWidth, boundedHeight } = dimensions;
|
|
234
|
+
const xValues = data.map(x);
|
|
235
|
+
const yValues = data.map(y);
|
|
236
|
+
const [xMin, xMax] = computeExtent(xValues);
|
|
237
|
+
const [yMin, yMax] = computeExtent(yValues);
|
|
238
|
+
const xScale = createLinearScale([xMin, xMax], [0, boundedWidth]);
|
|
239
|
+
const yScale = createLinearScale([yMin, yMax], [boundedHeight, 0]);
|
|
240
|
+
const points = data.map((d2) => ({
|
|
241
|
+
x: xScale(x(d2)),
|
|
242
|
+
y: yScale(y(d2))
|
|
243
|
+
}));
|
|
244
|
+
const d = linePath(points);
|
|
245
|
+
return /* @__PURE__ */ jsx(
|
|
246
|
+
"path",
|
|
247
|
+
{
|
|
248
|
+
className,
|
|
249
|
+
d,
|
|
250
|
+
stroke,
|
|
251
|
+
strokeWidth,
|
|
252
|
+
fill
|
|
253
|
+
}
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
function Circles({
|
|
257
|
+
data,
|
|
258
|
+
cx,
|
|
259
|
+
cy,
|
|
260
|
+
r = 4,
|
|
261
|
+
fill = "currentColor",
|
|
262
|
+
className
|
|
263
|
+
}) {
|
|
264
|
+
const { dimensions } = useChartContext();
|
|
265
|
+
const { boundedWidth, boundedHeight } = dimensions;
|
|
266
|
+
const xValues = data.map(cx);
|
|
267
|
+
const yValues = data.map(cy);
|
|
268
|
+
const [xMin, xMax] = computeExtent(xValues);
|
|
269
|
+
const [yMin, yMax] = computeExtent(yValues);
|
|
270
|
+
const xScale = createLinearScale([xMin, xMax], [0, boundedWidth]);
|
|
271
|
+
const yScale = createLinearScale([yMin, yMax], [boundedHeight, 0]);
|
|
272
|
+
return /* @__PURE__ */ jsx("g", { className, children: data.map((d, i) => /* @__PURE__ */ jsx(
|
|
273
|
+
"circle",
|
|
274
|
+
{
|
|
275
|
+
cx: xScale(cx(d)),
|
|
276
|
+
cy: yScale(cy(d)),
|
|
277
|
+
r,
|
|
278
|
+
fill
|
|
279
|
+
},
|
|
280
|
+
i
|
|
281
|
+
)) });
|
|
282
|
+
}
|
|
283
|
+
function XAxis({
|
|
284
|
+
ticks,
|
|
285
|
+
scale,
|
|
286
|
+
height,
|
|
287
|
+
tickSize = 6,
|
|
288
|
+
className
|
|
289
|
+
}) {
|
|
290
|
+
return /* @__PURE__ */ jsx("g", { className, transform: `translate(0,${height})`, children: ticks.map((tick, i) => {
|
|
291
|
+
const x = scale(tick);
|
|
292
|
+
return /* @__PURE__ */ jsxs("g", { transform: `translate(${x},0)`, children: [
|
|
293
|
+
/* @__PURE__ */ jsx("line", { y2: tickSize, stroke: "currentColor" }),
|
|
294
|
+
/* @__PURE__ */ jsx(
|
|
295
|
+
"text",
|
|
296
|
+
{
|
|
297
|
+
y: tickSize + 9,
|
|
298
|
+
textAnchor: "middle",
|
|
299
|
+
fontSize: 12,
|
|
300
|
+
fill: "currentColor",
|
|
301
|
+
children: String(tick)
|
|
302
|
+
}
|
|
303
|
+
)
|
|
304
|
+
] }, i);
|
|
305
|
+
}) });
|
|
306
|
+
}
|
|
307
|
+
function YAxis({
|
|
308
|
+
ticks,
|
|
309
|
+
scale,
|
|
310
|
+
tickSize = 6,
|
|
311
|
+
className
|
|
312
|
+
}) {
|
|
313
|
+
return /* @__PURE__ */ jsx("g", { className, children: ticks.map((tick, i) => {
|
|
314
|
+
const y = scale(tick);
|
|
315
|
+
return /* @__PURE__ */ jsxs("g", { transform: `translate(0,${y})`, children: [
|
|
316
|
+
/* @__PURE__ */ jsx("line", { x2: -tickSize, stroke: "currentColor" }),
|
|
317
|
+
/* @__PURE__ */ jsx(
|
|
318
|
+
"text",
|
|
319
|
+
{
|
|
320
|
+
x: -tickSize - 4,
|
|
321
|
+
dy: "0.32em",
|
|
322
|
+
textAnchor: "end",
|
|
323
|
+
fontSize: 12,
|
|
324
|
+
fill: "currentColor",
|
|
325
|
+
children: String(tick)
|
|
326
|
+
}
|
|
327
|
+
)
|
|
328
|
+
] }, i);
|
|
329
|
+
}) });
|
|
330
|
+
}
|
|
331
|
+
function Gradient({
|
|
332
|
+
id,
|
|
333
|
+
from,
|
|
334
|
+
to,
|
|
335
|
+
direction = "vertical",
|
|
336
|
+
className
|
|
337
|
+
}) {
|
|
338
|
+
const isVertical = direction === "vertical";
|
|
339
|
+
return /* @__PURE__ */ jsx("defs", { className, children: /* @__PURE__ */ jsxs(
|
|
340
|
+
"linearGradient",
|
|
341
|
+
{
|
|
342
|
+
id,
|
|
343
|
+
x1: "0",
|
|
344
|
+
y1: "0",
|
|
345
|
+
x2: isVertical ? "0" : "1",
|
|
346
|
+
y2: isVertical ? "1" : "0",
|
|
347
|
+
children: [
|
|
348
|
+
/* @__PURE__ */ jsx("stop", { offset: "0%", stopColor: from }),
|
|
349
|
+
/* @__PURE__ */ jsx("stop", { offset: "100%", stopColor: to })
|
|
350
|
+
]
|
|
351
|
+
}
|
|
352
|
+
) });
|
|
353
|
+
}
|
|
354
|
+
function Histogram({
|
|
355
|
+
data,
|
|
356
|
+
width = 600,
|
|
357
|
+
height = 400,
|
|
358
|
+
bins: binCount = 10,
|
|
359
|
+
fill = "steelblue",
|
|
360
|
+
margin,
|
|
361
|
+
className
|
|
362
|
+
}) {
|
|
363
|
+
const dimensions = combineDimensions({ width, height, margin });
|
|
364
|
+
const { boundedWidth, boundedHeight } = dimensions;
|
|
365
|
+
const histBins = computeHistogramBins(data, binCount);
|
|
366
|
+
const maxCount = Math.max(...histBins.map((b) => b.count));
|
|
367
|
+
const labels = histBins.map((b) => `${formatTick(b.x0, "number")}-${formatTick(b.x1, "number")}`);
|
|
368
|
+
const xScale = createBandScale(labels, [0, boundedWidth], 0.05);
|
|
369
|
+
const yScale = createLinearScale([0, maxCount], [boundedHeight, 0]);
|
|
370
|
+
const yTicks = yScale.ticks(5);
|
|
371
|
+
return /* @__PURE__ */ jsx("svg", { width, height, className, children: /* @__PURE__ */ jsxs("g", { transform: `translate(${dimensions.margin.left},${dimensions.margin.top})`, children: [
|
|
372
|
+
histBins.map((bin, i) => {
|
|
373
|
+
const label = labels[i];
|
|
374
|
+
const barX = xScale(label);
|
|
375
|
+
const barY = yScale(bin.count);
|
|
376
|
+
const barHeight = boundedHeight - barY;
|
|
377
|
+
const barWidth = xScale.bandwidth();
|
|
378
|
+
return /* @__PURE__ */ jsx(
|
|
379
|
+
"rect",
|
|
380
|
+
{
|
|
381
|
+
x: barX,
|
|
382
|
+
y: barY,
|
|
383
|
+
width: barWidth,
|
|
384
|
+
height: barHeight,
|
|
385
|
+
fill
|
|
386
|
+
},
|
|
387
|
+
i
|
|
388
|
+
);
|
|
389
|
+
}),
|
|
390
|
+
/* @__PURE__ */ jsx("g", { transform: `translate(0,${boundedHeight})`, children: labels.map((label, i) => {
|
|
391
|
+
const x = xScale(label) + xScale.bandwidth() / 2;
|
|
392
|
+
return /* @__PURE__ */ jsxs("g", { transform: `translate(${x},0)`, children: [
|
|
393
|
+
/* @__PURE__ */ jsx("line", { y2: 6, stroke: "currentColor" }),
|
|
394
|
+
/* @__PURE__ */ jsx("text", { y: 18, textAnchor: "middle", fontSize: 10, fill: "currentColor", children: label })
|
|
395
|
+
] }, i);
|
|
396
|
+
}) }),
|
|
397
|
+
/* @__PURE__ */ jsx("g", { children: yTicks.map((tick, i) => {
|
|
398
|
+
const y = yScale(tick);
|
|
399
|
+
return /* @__PURE__ */ jsxs("g", { transform: `translate(0,${y})`, children: [
|
|
400
|
+
/* @__PURE__ */ jsx("line", { x2: -6, stroke: "currentColor" }),
|
|
401
|
+
/* @__PURE__ */ jsx("text", { x: -9, dy: "0.32em", textAnchor: "end", fontSize: 10, fill: "currentColor", children: formatTick(tick, "number") })
|
|
402
|
+
] }, i);
|
|
403
|
+
}) })
|
|
404
|
+
] }) });
|
|
405
|
+
}
|
|
406
|
+
function ScatterPlot({
|
|
407
|
+
data,
|
|
408
|
+
x,
|
|
409
|
+
y,
|
|
410
|
+
width = 600,
|
|
411
|
+
height = 400,
|
|
412
|
+
r = 4,
|
|
413
|
+
fill = "steelblue",
|
|
414
|
+
margin,
|
|
415
|
+
className
|
|
416
|
+
}) {
|
|
417
|
+
const dimensions = combineDimensions({ width, height, margin });
|
|
418
|
+
const { boundedWidth, boundedHeight } = dimensions;
|
|
419
|
+
const xValues = data.map(x);
|
|
420
|
+
const yValues = data.map(y);
|
|
421
|
+
const [xMin, xMax] = computeExtent(xValues);
|
|
422
|
+
const [yMin, yMax] = computeExtent(yValues);
|
|
423
|
+
const xScale = createLinearScale([xMin, xMax], [0, boundedWidth]);
|
|
424
|
+
const yScale = createLinearScale([yMin, yMax], [boundedHeight, 0]);
|
|
425
|
+
const xTicks = xScale.ticks(5);
|
|
426
|
+
const yTicks = yScale.ticks(5);
|
|
427
|
+
return /* @__PURE__ */ jsx("svg", { width, height, className, children: /* @__PURE__ */ jsxs("g", { transform: `translate(${dimensions.margin.left},${dimensions.margin.top})`, children: [
|
|
428
|
+
data.map((d, i) => /* @__PURE__ */ jsx(
|
|
429
|
+
"circle",
|
|
430
|
+
{
|
|
431
|
+
cx: xScale(x(d)),
|
|
432
|
+
cy: yScale(y(d)),
|
|
433
|
+
r,
|
|
434
|
+
fill
|
|
435
|
+
},
|
|
436
|
+
i
|
|
437
|
+
)),
|
|
438
|
+
/* @__PURE__ */ jsx("g", { transform: `translate(0,${boundedHeight})`, children: xTicks.map((tick, i) => {
|
|
439
|
+
const px = xScale(tick);
|
|
440
|
+
return /* @__PURE__ */ jsxs("g", { transform: `translate(${px},0)`, children: [
|
|
441
|
+
/* @__PURE__ */ jsx("line", { y2: 6, stroke: "currentColor" }),
|
|
442
|
+
/* @__PURE__ */ jsx("text", { y: 18, textAnchor: "middle", fontSize: 10, fill: "currentColor", children: formatTick(tick, "number") })
|
|
443
|
+
] }, i);
|
|
444
|
+
}) }),
|
|
445
|
+
/* @__PURE__ */ jsx("g", { children: yTicks.map((tick, i) => {
|
|
446
|
+
const py = yScale(tick);
|
|
447
|
+
return /* @__PURE__ */ jsxs("g", { transform: `translate(0,${py})`, children: [
|
|
448
|
+
/* @__PURE__ */ jsx("line", { x2: -6, stroke: "currentColor" }),
|
|
449
|
+
/* @__PURE__ */ jsx("text", { x: -9, dy: "0.32em", textAnchor: "end", fontSize: 10, fill: "currentColor", children: formatTick(tick, "number") })
|
|
450
|
+
] }, i);
|
|
451
|
+
}) })
|
|
452
|
+
] }) });
|
|
453
|
+
}
|
|
454
|
+
var DEFAULT_COLORS = [
|
|
455
|
+
"#4e79a7",
|
|
456
|
+
"#f28e2b",
|
|
457
|
+
"#e15759",
|
|
458
|
+
"#76b7b2",
|
|
459
|
+
"#59a14f",
|
|
460
|
+
"#edc948",
|
|
461
|
+
"#b07aa1",
|
|
462
|
+
"#ff9da7",
|
|
463
|
+
"#9c755f",
|
|
464
|
+
"#bab0ac"
|
|
465
|
+
];
|
|
466
|
+
function PieChart({
|
|
467
|
+
data,
|
|
468
|
+
value,
|
|
469
|
+
width = 300,
|
|
470
|
+
height = 300,
|
|
471
|
+
colors = DEFAULT_COLORS,
|
|
472
|
+
className
|
|
473
|
+
}) {
|
|
474
|
+
const cx = width / 2;
|
|
475
|
+
const cy = height / 2;
|
|
476
|
+
const radius = Math.min(cx, cy) - 10;
|
|
477
|
+
const values = data.map(value);
|
|
478
|
+
const total = values.reduce((sum, v) => sum + v, 0);
|
|
479
|
+
let currentAngle = -Math.PI / 2;
|
|
480
|
+
const arcs = data.map((_, i) => {
|
|
481
|
+
const sliceAngle = values[i] / total * Math.PI * 2;
|
|
482
|
+
const startAngle = currentAngle;
|
|
483
|
+
const endAngle = currentAngle + sliceAngle;
|
|
484
|
+
currentAngle = endAngle;
|
|
485
|
+
return { startAngle, endAngle, color: colors[i % colors.length] };
|
|
486
|
+
});
|
|
487
|
+
return /* @__PURE__ */ jsx("svg", { width, height, className, children: arcs.map((arc, i) => /* @__PURE__ */ jsx(
|
|
488
|
+
"path",
|
|
489
|
+
{
|
|
490
|
+
d: arcPath(cx, cy, radius, arc.startAngle, arc.endAngle),
|
|
491
|
+
fill: arc.color
|
|
492
|
+
},
|
|
493
|
+
i
|
|
494
|
+
)) });
|
|
495
|
+
}
|
|
496
|
+
export {
|
|
497
|
+
Bars,
|
|
498
|
+
Chart,
|
|
499
|
+
ChartContext,
|
|
500
|
+
Circles,
|
|
501
|
+
Gradient,
|
|
502
|
+
Histogram,
|
|
503
|
+
Line,
|
|
504
|
+
PieChart,
|
|
505
|
+
ScatterPlot,
|
|
506
|
+
XAxis,
|
|
507
|
+
YAxis
|
|
508
|
+
};
|
|
509
|
+
//# sourceMappingURL=react-charts.js.map
|