@aaas-pro/library 0.0.0-stage → 0.1.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 +107 -2
- package/dist/components/address-picker.d.ts +18 -0
- package/dist/components/address-picker.js +46 -0
- package/dist/components/card-date-filter.d.ts +12 -0
- package/dist/components/card-date-filter.js +95 -0
- package/dist/components/date-time-picker.d.ts +12 -0
- package/dist/components/date-time-picker.js +96 -0
- package/dist/components/detail-dialog.d.ts +48 -0
- package/dist/components/detail-dialog.js +97 -0
- package/dist/components/document-links.d.ts +13 -0
- package/dist/components/document-links.js +19 -0
- package/dist/components/draft-row-actions.d.ts +14 -0
- package/dist/components/draft-row-actions.js +70 -0
- package/dist/components/error-boundary.d.ts +14 -0
- package/dist/components/error-boundary.js +35 -0
- package/dist/components/glow-card.d.ts +13 -0
- package/dist/components/glow-card.js +48 -0
- package/dist/components/org-picker.d.ts +17 -0
- package/dist/components/org-picker.js +56 -0
- package/dist/components/overflow-row-actions.d.ts +29 -0
- package/dist/components/overflow-row-actions.js +135 -0
- package/dist/components/page-header.d.ts +21 -0
- package/dist/components/page-header.js +21 -0
- package/dist/components/permission-button.d.ts +4 -0
- package/dist/components/permission-button.js +17 -0
- package/dist/components/permission-context.d.ts +12 -0
- package/dist/components/permission-context.js +17 -0
- package/dist/components/person-picker.d.ts +20 -0
- package/dist/components/person-picker.js +38 -0
- package/dist/components/process-flow-bar.d.ts +15 -0
- package/dist/components/process-flow-bar.js +19 -0
- package/dist/components/product-picker.d.ts +19 -0
- package/dist/components/product-picker.js +155 -0
- package/dist/components/ref-doc-picker.d.ts +24 -0
- package/dist/components/ref-doc-picker.js +139 -0
- package/dist/components/scroll-to-top.d.ts +1 -0
- package/dist/components/scroll-to-top.js +20 -0
- package/dist/components/state-view.d.ts +26 -0
- package/dist/components/state-view.js +75 -0
- package/dist/components/theme-switcher.d.ts +27 -0
- package/dist/components/theme-switcher.js +77 -0
- package/dist/components/time-filter.d.ts +7 -0
- package/dist/components/time-filter.js +65 -0
- package/dist/components/ui/accordion.d.ts +7 -0
- package/dist/components/ui/accordion.js +64 -0
- package/dist/components/ui/alert-dialog.d.ts +15 -0
- package/dist/components/ui/alert-dialog.js +160 -0
- package/dist/components/ui/alert.d.ts +12 -0
- package/dist/components/ui/alert.js +66 -0
- package/dist/components/ui/aspect-ratio.d.ts +3 -0
- package/dist/components/ui/aspect-ratio.js +10 -0
- package/dist/components/ui/avatar.d.ts +6 -0
- package/dist/components/ui/avatar.js +53 -0
- package/dist/components/ui/badge.d.ts +12 -0
- package/dist/components/ui/badge.js +44 -0
- package/dist/components/ui/breadcrumb.d.ts +11 -0
- package/dist/components/ui/breadcrumb.js +103 -0
- package/dist/components/ui/button-group.d.ts +14 -0
- package/dist/components/ui/button-group.js +76 -0
- package/dist/components/ui/button.d.ts +20 -0
- package/dist/components/ui/button.js +93 -0
- package/dist/components/ui/calendar.d.ts +73 -0
- package/dist/components/ui/calendar.js +103 -0
- package/dist/components/ui/card.d.ts +9 -0
- package/dist/components/ui/card.js +90 -0
- package/dist/components/ui/carousel.d.ts +14 -0
- package/dist/components/ui/carousel.js +200 -0
- package/dist/components/ui/chart.d.ts +43 -0
- package/dist/components/ui/chart.js +252 -0
- package/dist/components/ui/checkbox.d.ts +4 -0
- package/dist/components/ui/checkbox.js +31 -0
- package/dist/components/ui/collapsible.d.ts +5 -0
- package/dist/components/ui/collapsible.js +34 -0
- package/dist/components/ui/command.d.ts +18 -0
- package/dist/components/ui/command.js +170 -0
- package/dist/components/ui/context-menu.d.ts +26 -0
- package/dist/components/ui/context-menu.js +237 -0
- package/dist/components/ui/dialog.d.ts +17 -0
- package/dist/components/ui/dialog.js +139 -0
- package/dist/components/ui/drawer.d.ts +13 -0
- package/dist/components/ui/drawer.js +129 -0
- package/dist/components/ui/dropdown-menu.d.ts +26 -0
- package/dist/components/ui/dropdown-menu.js +245 -0
- package/dist/components/ui/empty.d.ts +14 -0
- package/dist/components/ui/empty.js +102 -0
- package/dist/components/ui/field.d.ts +27 -0
- package/dist/components/ui/field.js +229 -0
- package/dist/components/ui/form.d.ts +26 -0
- package/dist/components/ui/form.js +118 -0
- package/dist/components/ui/hover-card.d.ts +6 -0
- package/dist/components/ui/hover-card.js +39 -0
- package/dist/components/ui/input-group.d.ts +22 -0
- package/dist/components/ui/input-group.js +156 -0
- package/dist/components/ui/input-otp.d.ts +11 -0
- package/dist/components/ui/input-otp.js +66 -0
- package/dist/components/ui/input.d.ts +3 -0
- package/dist/components/ui/input.js +21 -0
- package/dist/components/ui/item.d.ts +29 -0
- package/dist/components/ui/item.js +187 -0
- package/dist/components/ui/kbd.d.ts +3 -0
- package/dist/components/ui/kbd.js +31 -0
- package/dist/components/ui/label.d.ts +4 -0
- package/dist/components/ui/label.js +22 -0
- package/dist/components/ui/menubar.d.ts +26 -0
- package/dist/components/ui/menubar.js +252 -0
- package/dist/components/ui/navigation-menu.d.ts +17 -0
- package/dist/components/ui/navigation-menu.js +170 -0
- package/dist/components/ui/pagination.d.ts +13 -0
- package/dist/components/ui/pagination.js +118 -0
- package/dist/components/ui/popover.d.ts +8 -0
- package/dist/components/ui/popover.js +47 -0
- package/dist/components/ui/progress.d.ts +4 -0
- package/dist/components/ui/progress.js +34 -0
- package/dist/components/ui/radio-group.d.ts +5 -0
- package/dist/components/ui/radio-group.js +45 -0
- package/dist/components/ui/resizable.d.ts +7 -0
- package/dist/components/ui/resizable.js +49 -0
- package/dist/components/ui/scroll-area.d.ts +5 -0
- package/dist/components/ui/scroll-area.js +60 -0
- package/dist/components/ui/select.d.ts +17 -0
- package/dist/components/ui/select.js +215 -0
- package/dist/components/ui/separator.d.ts +4 -0
- package/dist/components/ui/separator.js +26 -0
- package/dist/components/ui/sheet.d.ts +13 -0
- package/dist/components/ui/sheet.js +127 -0
- package/dist/components/ui/sidebar.d.ts +72 -0
- package/dist/components/ui/sidebar.js +656 -0
- package/dist/components/ui/skeleton.d.ts +2 -0
- package/dist/components/ui/skeleton.js +15 -0
- package/dist/components/ui/slider.d.ts +4 -0
- package/dist/components/ui/slider.js +63 -0
- package/dist/components/ui/sonner.d.ts +4 -0
- package/dist/components/ui/sonner.js +34 -0
- package/dist/components/ui/spinner.d.ts +2 -0
- package/dist/components/ui/spinner.js +17 -0
- package/dist/components/ui/switch.d.ts +4 -0
- package/dist/components/ui/switch.js +31 -0
- package/dist/components/ui/table.d.ts +10 -0
- package/dist/components/ui/table.js +114 -0
- package/dist/components/ui/tabs.d.ts +7 -0
- package/dist/components/ui/tabs.js +67 -0
- package/dist/components/ui/textarea.d.ts +3 -0
- package/dist/components/ui/textarea.js +18 -0
- package/dist/components/ui/toggle-group.d.ts +9 -0
- package/dist/components/ui/toggle-group.js +68 -0
- package/dist/components/ui/toggle.d.ts +12 -0
- package/dist/components/ui/toggle.js +43 -0
- package/dist/components/ui/tooltip.d.ts +7 -0
- package/dist/components/ui/tooltip.js +56 -0
- package/dist/hooks/use-mobile.d.ts +1 -0
- package/dist/hooks/use-mobile.js +18 -0
- package/dist/icons/index.d.ts +57 -0
- package/dist/icons/index.js +115 -0
- package/dist/icons/paths.d.ts +556 -0
- package/dist/icons/paths.js +231 -0
- package/dist/index.d.ts +68 -0
- package/dist/index.js +399 -0
- package/dist/internal/selection-base.d.ts +37 -0
- package/dist/internal/selection-base.js +40 -0
- package/dist/lib/class-names.d.ts +6 -0
- package/dist/lib/class-names.js +159 -0
- package/dist/lib/utils.d.ts +3 -0
- package/dist/lib/utils.js +7 -0
- package/dist/lib/variants.d.ts +21 -0
- package/dist/lib/variants.js +21 -0
- package/dist/primitives/accordion.d.ts +29 -0
- package/dist/primitives/accordion.js +49 -0
- package/dist/primitives/alert-dialog.d.ts +10 -0
- package/dist/primitives/alert-dialog.js +22 -0
- package/dist/primitives/aspect-ratio.d.ts +4 -0
- package/dist/primitives/aspect-ratio.js +7 -0
- package/dist/primitives/avatar.d.ts +8 -0
- package/dist/primitives/avatar.js +45 -0
- package/dist/primitives/carousel.d.ts +22 -0
- package/dist/primitives/carousel.js +78 -0
- package/dist/primitives/chart.d.ts +71 -0
- package/dist/primitives/chart.js +125 -0
- package/dist/primitives/checkbox.d.ts +13 -0
- package/dist/primitives/checkbox.js +24 -0
- package/dist/primitives/collapsible.d.ts +14 -0
- package/dist/primitives/collapsible.js +29 -0
- package/dist/primitives/command.d.ts +43 -0
- package/dist/primitives/command.js +98 -0
- package/dist/primitives/context-menu.d.ts +24 -0
- package/dist/primitives/context-menu.js +19 -0
- package/dist/primitives/core.d.ts +25 -0
- package/dist/primitives/core.js +89 -0
- package/dist/primitives/dialog.d.ts +7 -0
- package/dist/primitives/dialog.js +15 -0
- package/dist/primitives/drawer.d.ts +30 -0
- package/dist/primitives/drawer.js +39 -0
- package/dist/primitives/dropdown-menu.d.ts +24 -0
- package/dist/primitives/dropdown-menu.js +19 -0
- package/dist/primitives/form.d.ts +154 -0
- package/dist/primitives/form.js +139 -0
- package/dist/primitives/hover-card.d.ts +4 -0
- package/dist/primitives/hover-card.js +8 -0
- package/dist/primitives/input-otp.d.ts +21 -0
- package/dist/primitives/input-otp.js +78 -0
- package/dist/primitives/label.d.ts +2 -0
- package/dist/primitives/label.js +7 -0
- package/dist/primitives/layer.d.ts +84 -0
- package/dist/primitives/layer.js +300 -0
- package/dist/primitives/menu.d.ts +56 -0
- package/dist/primitives/menu.js +126 -0
- package/dist/primitives/menubar.d.ts +91 -0
- package/dist/primitives/menubar.js +44 -0
- package/dist/primitives/navigation-menu.d.ts +32 -0
- package/dist/primitives/navigation-menu.js +121 -0
- package/dist/primitives/popover.d.ts +4 -0
- package/dist/primitives/popover.js +12 -0
- package/dist/primitives/progress.d.ts +7 -0
- package/dist/primitives/progress.js +13 -0
- package/dist/primitives/radio-group.d.ts +18 -0
- package/dist/primitives/radio-group.js +36 -0
- package/dist/primitives/resizable.d.ts +19 -0
- package/dist/primitives/resizable.js +91 -0
- package/dist/primitives/scroll-area.d.ts +12 -0
- package/dist/primitives/scroll-area.js +26 -0
- package/dist/primitives/select.d.ts +42 -0
- package/dist/primitives/select.js +167 -0
- package/dist/primitives/separator.d.ts +5 -0
- package/dist/primitives/separator.js +7 -0
- package/dist/primitives/slider.d.ts +25 -0
- package/dist/primitives/slider.js +98 -0
- package/dist/primitives/slot.d.ts +1 -0
- package/dist/primitives/slot.js +4 -0
- package/dist/primitives/switch.d.ts +11 -0
- package/dist/primitives/switch.js +22 -0
- package/dist/primitives/tabs.d.ts +23 -0
- package/dist/primitives/tabs.js +38 -0
- package/dist/primitives/toast.d.ts +55 -0
- package/dist/primitives/toast.js +86 -0
- package/dist/primitives/toggle-group.d.ts +24 -0
- package/dist/primitives/toggle-group.js +33 -0
- package/dist/primitives/toggle.d.ts +7 -0
- package/dist/primitives/toggle.js +13 -0
- package/dist/primitives/tooltip.d.ts +7 -0
- package/dist/primitives/tooltip.js +10 -0
- package/dist/style-entry.d.ts +1 -0
- package/dist/style-entry.js +1 -0
- package/dist/styles.css +7016 -0
- package/dist/styles.js +1 -0
- package/dist/theme/index.d.ts +110 -0
- package/dist/theme/index.js +199 -0
- package/licenses/Lucide.txt +15 -0
- package/package.json +67 -4
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ClassValue } from './class-names';
|
|
2
|
+
type VariantMap = Record<string, Record<string, ClassValue>>;
|
|
3
|
+
type Value<V> = V extends 'true' | 'false' ? boolean : V;
|
|
4
|
+
type Selection<V extends VariantMap> = {
|
|
5
|
+
[K in keyof V]?: Value<keyof V[K]> | null | undefined;
|
|
6
|
+
};
|
|
7
|
+
type ClassProps = {
|
|
8
|
+
class?: ClassValue;
|
|
9
|
+
className?: ClassValue;
|
|
10
|
+
};
|
|
11
|
+
type Compound<V extends VariantMap> = {
|
|
12
|
+
[K in keyof V]?: Selection<V>[K] | Selection<V>[K][];
|
|
13
|
+
} & ClassProps;
|
|
14
|
+
export type VariantProps<T extends (...args: any[]) => unknown> = Omit<Exclude<Parameters<T>[0], undefined>, 'class' | 'className'>;
|
|
15
|
+
/** Typed variants: undefined uses the default; null explicitly omits the variant. */
|
|
16
|
+
export declare function cva<V extends VariantMap = Record<never, never>>(base?: ClassValue, config?: {
|
|
17
|
+
variants?: V;
|
|
18
|
+
defaultVariants?: Selection<V>;
|
|
19
|
+
compoundVariants?: Compound<V>[];
|
|
20
|
+
}): (props?: Selection<V> & ClassProps) => string;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { classNames } from "./class-names.js";
|
|
2
|
+
function cva(base, config) {
|
|
3
|
+
return (props) => {
|
|
4
|
+
const classes = [base];
|
|
5
|
+
const selected = { ...config?.defaultVariants };
|
|
6
|
+
for (const key of Object.keys(config?.variants ?? {})) {
|
|
7
|
+
const value = props?.[key] === void 0 ? config?.defaultVariants?.[key] : props[key];
|
|
8
|
+
selected[key] = value;
|
|
9
|
+
if (value !== null && value !== void 0) classes.push(config?.variants?.[key]?.[String(value)]);
|
|
10
|
+
}
|
|
11
|
+
for (const compound of config?.compoundVariants ?? []) {
|
|
12
|
+
const { class: extra, className, ...conditions } = compound;
|
|
13
|
+
if (Object.entries(conditions).every(([key, expected]) => Array.isArray(expected) ? expected.includes(selected[key]) : expected === selected[key])) classes.push(extra, className);
|
|
14
|
+
}
|
|
15
|
+
classes.push(props?.class, props?.className);
|
|
16
|
+
return classNames(...classes);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
cva
|
|
21
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type ButtonProps, type DivProps } from './core';
|
|
3
|
+
type Selection = {
|
|
4
|
+
type: 'single';
|
|
5
|
+
value?: string;
|
|
6
|
+
defaultValue?: string;
|
|
7
|
+
onValueChange?: (value: string) => void;
|
|
8
|
+
} | {
|
|
9
|
+
type: 'multiple';
|
|
10
|
+
value?: string[];
|
|
11
|
+
defaultValue?: string[];
|
|
12
|
+
onValueChange?: (value: string[]) => void;
|
|
13
|
+
};
|
|
14
|
+
export type AccordionProps = Omit<DivProps, 'defaultValue'> & Selection & {
|
|
15
|
+
collapsible?: boolean;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
orientation?: 'horizontal' | 'vertical';
|
|
18
|
+
};
|
|
19
|
+
export declare function Root({ type, value, defaultValue, onValueChange, collapsible, disabled, orientation, onKeyDown, ...props }: AccordionProps): React.JSX.Element;
|
|
20
|
+
export declare function Item({ value, disabled, ...props }: DivProps & {
|
|
21
|
+
value: string;
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
}): React.JSX.Element;
|
|
24
|
+
export declare function Header(props: React.ComponentProps<'h3'>): React.JSX.Element;
|
|
25
|
+
export declare function Trigger({ onClick, ...props }: ButtonProps): React.JSX.Element;
|
|
26
|
+
export declare function Content({ forceMount, ...props }: DivProps & {
|
|
27
|
+
forceMount?: true;
|
|
28
|
+
}): React.JSX.Element | null;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { DivPart, useControllable, moveFocus, ButtonPart } from "./core.js";
|
|
4
|
+
const Context = React.createContext({ values: [], toggle: (_value) => {
|
|
5
|
+
}, disabled: false });
|
|
6
|
+
const ItemContext = React.createContext({ open: false, value: "", disabled: false, id: "" });
|
|
7
|
+
function Root({ type, value, defaultValue, onValueChange, collapsible = false, disabled = false, orientation = "vertical", onKeyDown, ...props }) {
|
|
8
|
+
const [current, set] = useControllable(value, defaultValue ?? (type === "single" ? "" : []), (next) => {
|
|
9
|
+
if (type === "single")
|
|
10
|
+
onValueChange?.(next);
|
|
11
|
+
else
|
|
12
|
+
onValueChange?.(next);
|
|
13
|
+
});
|
|
14
|
+
const values = Array.isArray(current) ? current : current ? [current] : [];
|
|
15
|
+
const toggle = (key) => set(type === "single" ? values.includes(key) ? collapsible ? "" : key : key : values.includes(key) ? values.filter((v) => v !== key) : [...values, key]);
|
|
16
|
+
return /* @__PURE__ */ jsx(Context.Provider, { value: { values, toggle, disabled }, children: /* @__PURE__ */ jsx(DivPart, { ...props, "data-orientation": orientation, onKeyDown: (event) => {
|
|
17
|
+
onKeyDown?.(event);
|
|
18
|
+
if (!event.defaultPrevented)
|
|
19
|
+
moveFocus(event, "[data-accordion-trigger]", { vertical: orientation === "vertical" });
|
|
20
|
+
} }) });
|
|
21
|
+
}
|
|
22
|
+
function Item({ value, disabled = false, ...props }) {
|
|
23
|
+
const state = React.useContext(Context);
|
|
24
|
+
const id = React.useId();
|
|
25
|
+
const open = state.values.includes(value);
|
|
26
|
+
return /* @__PURE__ */ jsx(ItemContext.Provider, { value: { open, value, disabled: disabled || state.disabled, id }, children: /* @__PURE__ */ jsx(DivPart, { ...props, "data-state": open ? "open" : "closed", "data-disabled": disabled || state.disabled ? "" : void 0 }) });
|
|
27
|
+
}
|
|
28
|
+
function Header(props) {
|
|
29
|
+
return /* @__PURE__ */ jsx("h3", { ...props });
|
|
30
|
+
}
|
|
31
|
+
function Trigger({ onClick, ...props }) {
|
|
32
|
+
const state = React.useContext(Context), item = React.useContext(ItemContext);
|
|
33
|
+
return /* @__PURE__ */ jsx(ButtonPart, { ...props, id: `${item.id}-trigger`, "data-accordion-trigger": "", disabled: item.disabled || props.disabled, "aria-expanded": item.open, "aria-controls": `${item.id}-content`, "data-state": item.open ? "open" : "closed", onClick: (event) => {
|
|
34
|
+
onClick?.(event);
|
|
35
|
+
if (!event.defaultPrevented)
|
|
36
|
+
state.toggle(item.value);
|
|
37
|
+
} });
|
|
38
|
+
}
|
|
39
|
+
function Content({ forceMount, ...props }) {
|
|
40
|
+
const item = React.useContext(ItemContext);
|
|
41
|
+
return item.open || forceMount ? /* @__PURE__ */ jsx(DivPart, { ...props, id: `${item.id}-content`, role: "region", "aria-labelledby": `${item.id}-trigger`, hidden: !item.open, "data-state": item.open ? "open" : "closed" }) : null;
|
|
42
|
+
}
|
|
43
|
+
export {
|
|
44
|
+
Content,
|
|
45
|
+
Header,
|
|
46
|
+
Item,
|
|
47
|
+
Root,
|
|
48
|
+
Trigger
|
|
49
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type ModalRootProps, type ModalContentProps } from './layer';
|
|
3
|
+
import type { ButtonProps } from './core';
|
|
4
|
+
export declare const Trigger: ({ onClick, onKeyDown, onPointerEnter, onPointerLeave, onFocus, onBlur, onContextMenu, ref, disabled, ...props }: ButtonProps) => React.JSX.Element, Close: ({ onClick, ...props }: ButtonProps) => React.JSX.Element, Portal: ({ children, container, forceMount }: import("./layer").PortalProps) => React.ReactPortal | null, Overlay: ({ forceMount, ...props }: import("./core").DivProps & {
|
|
5
|
+
forceMount?: true;
|
|
6
|
+
}) => React.JSX.Element | null, Title: (props: React.ComponentProps<"h2">) => React.JSX.Element, Description: (props: React.ComponentProps<"p">) => React.JSX.Element;
|
|
7
|
+
export declare const Root: (props: ModalRootProps) => React.ReactElement;
|
|
8
|
+
export declare const Content: (props: ModalContentProps) => React.ReactElement | null;
|
|
9
|
+
export declare const Action: ({ onClick, ...props }: ButtonProps) => React.JSX.Element;
|
|
10
|
+
export declare function Cancel(props: ButtonProps): React.JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createLayer } from "./layer.js";
|
|
3
|
+
const family = createLayer({ modal: true, floating: false, role: "alertdialog", alert: true });
|
|
4
|
+
const { Trigger, Close, Portal, Overlay, Title, Description } = family;
|
|
5
|
+
const Root = family.Root;
|
|
6
|
+
const Content = family.Content;
|
|
7
|
+
const Action = Close;
|
|
8
|
+
function Cancel(props) {
|
|
9
|
+
return /* @__PURE__ */ jsx(Close, { "data-slot": "alert-dialog-cancel", ...props });
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
Action,
|
|
13
|
+
Cancel,
|
|
14
|
+
Close,
|
|
15
|
+
Content,
|
|
16
|
+
Description,
|
|
17
|
+
Overlay,
|
|
18
|
+
Portal,
|
|
19
|
+
Root,
|
|
20
|
+
Title,
|
|
21
|
+
Trigger
|
|
22
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
function Root({ ratio = 1, style, ...props }) {
|
|
3
|
+
return /* @__PURE__ */ jsx("div", { ...props, style: { position: "relative", width: "100%", aspectRatio: Number.isFinite(ratio) && ratio > 0 ? ratio : 1, ...style } });
|
|
4
|
+
}
|
|
5
|
+
export {
|
|
6
|
+
Root
|
|
7
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export declare function Root(props: React.ComponentProps<'span'>): React.JSX.Element;
|
|
3
|
+
export declare function Image({ onLoadingStatusChange, onLoad, onError, src, style, ...props }: React.ComponentProps<'img'> & {
|
|
4
|
+
onLoadingStatusChange?: (status: 'idle' | 'loading' | 'loaded' | 'error') => void;
|
|
5
|
+
}): React.JSX.Element;
|
|
6
|
+
export declare function Fallback({ delayMs, ...props }: React.ComponentProps<'span'> & {
|
|
7
|
+
delayMs?: number;
|
|
8
|
+
}): React.JSX.Element | null;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
const Context = React.createContext({ status: "idle", set: (_status) => {
|
|
4
|
+
} });
|
|
5
|
+
function Root(props) {
|
|
6
|
+
const [status, set] = React.useState("idle");
|
|
7
|
+
return /* @__PURE__ */ jsx(Context.Provider, { value: { status, set }, children: /* @__PURE__ */ jsx("span", { ...props }) });
|
|
8
|
+
}
|
|
9
|
+
function Image({ onLoadingStatusChange, onLoad, onError, src, style, ...props }) {
|
|
10
|
+
const context = React.useContext(Context), ref = React.useRef(null), merged = React.useMemo(() => (node) => {
|
|
11
|
+
ref.current = node;
|
|
12
|
+
if (typeof props.ref === "function")
|
|
13
|
+
props.ref(node);
|
|
14
|
+
else if (props.ref)
|
|
15
|
+
props.ref.current = node;
|
|
16
|
+
}, [props.ref]);
|
|
17
|
+
React.useEffect(() => {
|
|
18
|
+
const status = src ? ref.current?.complete && ref.current.naturalWidth ? "loaded" : "loading" : "error";
|
|
19
|
+
context.set(status);
|
|
20
|
+
onLoadingStatusChange?.(status);
|
|
21
|
+
}, [src]);
|
|
22
|
+
return /* @__PURE__ */ jsx("img", { ...props, ref: merged, src, style: { ...style, display: context.status === "loaded" ? style?.display : "none" }, onLoad: (event) => {
|
|
23
|
+
context.set("loaded");
|
|
24
|
+
onLoadingStatusChange?.("loaded");
|
|
25
|
+
onLoad?.(event);
|
|
26
|
+
}, onError: (event) => {
|
|
27
|
+
context.set("error");
|
|
28
|
+
onLoadingStatusChange?.("error");
|
|
29
|
+
onError?.(event);
|
|
30
|
+
} });
|
|
31
|
+
}
|
|
32
|
+
function Fallback({ delayMs = 0, ...props }) {
|
|
33
|
+
const { status } = React.useContext(Context);
|
|
34
|
+
const [ready, setReady] = React.useState(!delayMs);
|
|
35
|
+
React.useEffect(() => {
|
|
36
|
+
const timer = setTimeout(() => setReady(true), delayMs);
|
|
37
|
+
return () => clearTimeout(timer);
|
|
38
|
+
}, [delayMs]);
|
|
39
|
+
return ready && status !== "loaded" ? /* @__PURE__ */ jsx("span", { ...props }) : null;
|
|
40
|
+
}
|
|
41
|
+
export {
|
|
42
|
+
Fallback,
|
|
43
|
+
Image,
|
|
44
|
+
Root
|
|
45
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export interface CarouselOptions {
|
|
3
|
+
axis?: 'x' | 'y';
|
|
4
|
+
loop?: boolean;
|
|
5
|
+
startIndex?: number;
|
|
6
|
+
slidesToScroll?: number;
|
|
7
|
+
align?: 'start' | 'center' | 'end';
|
|
8
|
+
}
|
|
9
|
+
type EventName = 'select' | 'reInit';
|
|
10
|
+
export interface CarouselApi {
|
|
11
|
+
scrollPrev(): void;
|
|
12
|
+
scrollNext(): void;
|
|
13
|
+
scrollTo(index: number): void;
|
|
14
|
+
canScrollPrev(): boolean;
|
|
15
|
+
canScrollNext(): boolean;
|
|
16
|
+
selectedScrollSnap(): number;
|
|
17
|
+
scrollSnapList(): number[];
|
|
18
|
+
on(event: EventName, callback: (api: CarouselApi) => void): CarouselApi;
|
|
19
|
+
off(event: EventName, callback: (api: CarouselApi) => void): CarouselApi;
|
|
20
|
+
}
|
|
21
|
+
export default function useCarouselEngine(options?: CarouselOptions): readonly [React.Dispatch<React.SetStateAction<HTMLDivElement | null>>, CarouselApi];
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
function useCarouselEngine(options = {}) {
|
|
3
|
+
const [node, setNode] = React.useState(null);
|
|
4
|
+
const latest = React.useRef({ index: options.startIndex ?? 0, count: 0, node, options });
|
|
5
|
+
latest.current.node = node;
|
|
6
|
+
latest.current.options = options;
|
|
7
|
+
const listeners = React.useRef({ select: /* @__PURE__ */ new Set(), reInit: /* @__PURE__ */ new Set() });
|
|
8
|
+
const api = React.useMemo(() => {
|
|
9
|
+
const change = (requested) => {
|
|
10
|
+
const state = latest.current, count = state.count;
|
|
11
|
+
if (!count) return;
|
|
12
|
+
const index = state.options.loop ? (requested % count + count) % count : Math.max(0, Math.min(count - 1, requested));
|
|
13
|
+
const slides = state.node?.querySelectorAll('[data-slot="carousel-item"]'), slide = slides?.[index];
|
|
14
|
+
if (state.node && slide) {
|
|
15
|
+
const bounds = state.node.getBoundingClientRect(), rect = slide.getBoundingClientRect();
|
|
16
|
+
const vertical = state.options.axis === "y";
|
|
17
|
+
const adjustment = state.options.align === "center" ? (vertical ? bounds.height - rect.height : bounds.width - rect.width) / 2 : state.options.align === "end" ? vertical ? bounds.height - rect.height : bounds.width - rect.width : 0;
|
|
18
|
+
const offset = (vertical ? rect.top - bounds.top + state.node.scrollTop : rect.left - bounds.left + state.node.scrollLeft) - adjustment;
|
|
19
|
+
state.node.scrollTo?.({ [vertical ? "top" : "left"]: offset, behavior: "smooth" });
|
|
20
|
+
}
|
|
21
|
+
state.index = index;
|
|
22
|
+
listeners.current.select.forEach((callback) => callback(api));
|
|
23
|
+
};
|
|
24
|
+
return { scrollTo: change, scrollPrev: () => change(latest.current.index - Math.max(1, latest.current.options.slidesToScroll ?? 1)), scrollNext: () => change(latest.current.index + Math.max(1, latest.current.options.slidesToScroll ?? 1)), canScrollPrev: () => latest.current.count > 1 && (!!latest.current.options.loop || latest.current.index > 0), canScrollNext: () => latest.current.count > 1 && (!!latest.current.options.loop || latest.current.index < latest.current.count - 1), selectedScrollSnap: () => latest.current.index, scrollSnapList: () => Array.from({ length: latest.current.count }, (_, i) => i), on: (event, callback) => {
|
|
25
|
+
listeners.current[event].add(callback);
|
|
26
|
+
return api;
|
|
27
|
+
}, off: (event, callback) => {
|
|
28
|
+
listeners.current[event].delete(callback);
|
|
29
|
+
return api;
|
|
30
|
+
} };
|
|
31
|
+
}, []);
|
|
32
|
+
React.useEffect(() => {
|
|
33
|
+
if (!node) return;
|
|
34
|
+
const update = () => {
|
|
35
|
+
latest.current.count = node.querySelectorAll('[data-slot="carousel-item"]').length;
|
|
36
|
+
latest.current.index = Math.min(latest.current.index, Math.max(0, latest.current.count - 1));
|
|
37
|
+
listeners.current.reInit.forEach((callback) => callback(api));
|
|
38
|
+
};
|
|
39
|
+
const scroll = () => {
|
|
40
|
+
const slides = [...node.querySelectorAll('[data-slot="carousel-item"]')], bounds = node.getBoundingClientRect();
|
|
41
|
+
const index = slides.reduce((best, slide, i) => Math.abs(options.axis === "y" ? slide.getBoundingClientRect().top - bounds.top : slide.getBoundingClientRect().left - bounds.left) < Math.abs(options.axis === "y" ? slides[best].getBoundingClientRect().top - bounds.top : slides[best].getBoundingClientRect().left - bounds.left) ? i : best, 0);
|
|
42
|
+
if (index !== latest.current.index) {
|
|
43
|
+
latest.current.index = index;
|
|
44
|
+
listeners.current.select.forEach((callback) => callback(api));
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
let start;
|
|
48
|
+
const down = (event) => {
|
|
49
|
+
if (event.button === 0) start = { x: event.clientX, y: event.clientY };
|
|
50
|
+
};
|
|
51
|
+
const up = (event) => {
|
|
52
|
+
if (!start) return;
|
|
53
|
+
const delta = options.axis === "y" ? event.clientY - start.y : event.clientX - start.x;
|
|
54
|
+
start = void 0;
|
|
55
|
+
if (Math.abs(delta) > 40) delta < 0 ? api.scrollNext() : api.scrollPrev();
|
|
56
|
+
};
|
|
57
|
+
update();
|
|
58
|
+
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(update);
|
|
59
|
+
observer?.observe(node);
|
|
60
|
+
const mutation = new MutationObserver(update);
|
|
61
|
+
mutation.observe(node, { childList: true, subtree: true });
|
|
62
|
+
node.addEventListener("scroll", scroll);
|
|
63
|
+
node.addEventListener("pointerdown", down);
|
|
64
|
+
window.addEventListener("pointerup", up);
|
|
65
|
+
api.scrollTo(options.startIndex ?? 0);
|
|
66
|
+
return () => {
|
|
67
|
+
observer?.disconnect();
|
|
68
|
+
mutation.disconnect();
|
|
69
|
+
node.removeEventListener("scroll", scroll);
|
|
70
|
+
node.removeEventListener("pointerdown", down);
|
|
71
|
+
window.removeEventListener("pointerup", up);
|
|
72
|
+
};
|
|
73
|
+
}, [node, api, options.axis, options.startIndex]);
|
|
74
|
+
return [setNode, api];
|
|
75
|
+
}
|
|
76
|
+
export {
|
|
77
|
+
useCarouselEngine as default
|
|
78
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export interface ChartPayload {
|
|
3
|
+
dataKey: string;
|
|
4
|
+
name: string;
|
|
5
|
+
value: number;
|
|
6
|
+
color?: string;
|
|
7
|
+
type?: string;
|
|
8
|
+
payload: Record<string, any>;
|
|
9
|
+
}
|
|
10
|
+
export interface TooltipProps {
|
|
11
|
+
active?: boolean;
|
|
12
|
+
payload?: ChartPayload[];
|
|
13
|
+
label?: React.ReactNode;
|
|
14
|
+
content?: React.ReactElement | ((props: TooltipProps) => React.ReactNode);
|
|
15
|
+
formatter?: (value: number, name: string, item: ChartPayload, index: number, row: Record<string, any>) => React.ReactNode;
|
|
16
|
+
labelFormatter?: (label: React.ReactNode, payload: ChartPayload[]) => React.ReactNode;
|
|
17
|
+
color?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface LegendProps {
|
|
20
|
+
payload?: ChartPayload[];
|
|
21
|
+
verticalAlign?: 'top' | 'bottom';
|
|
22
|
+
content?: React.ReactElement | ((props: LegendProps) => React.ReactNode);
|
|
23
|
+
}
|
|
24
|
+
export interface SeriesProps {
|
|
25
|
+
dataKey: string;
|
|
26
|
+
name?: string;
|
|
27
|
+
fill?: string;
|
|
28
|
+
stroke?: string;
|
|
29
|
+
strokeWidth?: number;
|
|
30
|
+
radius?: number;
|
|
31
|
+
hide?: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface AxisProps {
|
|
34
|
+
dataKey?: string;
|
|
35
|
+
hide?: boolean;
|
|
36
|
+
tickFormatter?: (value: string | number) => string;
|
|
37
|
+
}
|
|
38
|
+
export interface ChartProps extends Omit<React.ComponentProps<'div'>, 'onChange'> {
|
|
39
|
+
data: Record<string, any>[];
|
|
40
|
+
width?: number;
|
|
41
|
+
height?: number;
|
|
42
|
+
margin?: {
|
|
43
|
+
top?: number;
|
|
44
|
+
right?: number;
|
|
45
|
+
bottom?: number;
|
|
46
|
+
left?: number;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export declare function Bar(_props: SeriesProps): null;
|
|
50
|
+
export declare function Line(_props: SeriesProps): null;
|
|
51
|
+
export declare function Area(_props: SeriesProps): null;
|
|
52
|
+
export declare function XAxis(_props: AxisProps): null;
|
|
53
|
+
export declare function YAxis(_props: AxisProps): null;
|
|
54
|
+
export declare function CartesianGrid(_props: {
|
|
55
|
+
stroke?: string;
|
|
56
|
+
strokeDasharray?: string;
|
|
57
|
+
vertical?: boolean;
|
|
58
|
+
horizontal?: boolean;
|
|
59
|
+
}): null;
|
|
60
|
+
export declare function ResponsiveContainer({ children, width, height }: {
|
|
61
|
+
children: React.ReactElement;
|
|
62
|
+
width?: number | string;
|
|
63
|
+
height?: number | string;
|
|
64
|
+
}): React.JSX.Element;
|
|
65
|
+
declare function CartesianChart({ data, children, width, height, margin, style, ...props }: ChartProps): React.JSX.Element;
|
|
66
|
+
export declare const BarChart: typeof CartesianChart;
|
|
67
|
+
export declare const LineChart: typeof CartesianChart;
|
|
68
|
+
export declare const AreaChart: typeof CartesianChart;
|
|
69
|
+
export declare function Tooltip(props: TooltipProps): React.JSX.Element | null;
|
|
70
|
+
export declare function Legend(props: LegendProps): React.JSX.Element;
|
|
71
|
+
export {};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
const Context = React.createContext({ active: false, payload: [], legend: [] });
|
|
4
|
+
function Bar(_props) {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
function Line(_props) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
function Area(_props) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
function XAxis(_props) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
function YAxis(_props) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
function CartesianGrid(_props) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
function chartChildren(children) {
|
|
23
|
+
return React.Children.toArray(children).flatMap((child) => React.isValidElement(child) ? child.type === React.Fragment ? chartChildren(child.props.children) : [child] : []);
|
|
24
|
+
}
|
|
25
|
+
function ResponsiveContainer({ children, width = "100%", height = "100%" }) {
|
|
26
|
+
const node = React.useRef(null), [size, setSize] = React.useState({ width: 640, height: 320 });
|
|
27
|
+
React.useEffect(() => {
|
|
28
|
+
const update = () => {
|
|
29
|
+
const bounds = node.current?.getBoundingClientRect();
|
|
30
|
+
if (bounds?.width && bounds.height) setSize({ width: bounds.width, height: bounds.height });
|
|
31
|
+
};
|
|
32
|
+
update();
|
|
33
|
+
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(update);
|
|
34
|
+
if (node.current) observer?.observe(node.current);
|
|
35
|
+
window.addEventListener("resize", update);
|
|
36
|
+
return () => {
|
|
37
|
+
observer?.disconnect();
|
|
38
|
+
window.removeEventListener("resize", update);
|
|
39
|
+
};
|
|
40
|
+
}, []);
|
|
41
|
+
return /* @__PURE__ */ jsx("div", { ref: node, style: { width, height, minWidth: 0, minHeight: 0 }, children: React.cloneElement(children, size) });
|
|
42
|
+
}
|
|
43
|
+
function CartesianChart({ data, children, width = 640, height = 320, margin, style, ...props }) {
|
|
44
|
+
const [activeIndex, setActiveIndex] = React.useState(null);
|
|
45
|
+
const tooltipId = React.useId();
|
|
46
|
+
const elements = chartChildren(children), series = elements.filter((child) => [Bar, Line, Area].includes(child.type) && !child.props.hide);
|
|
47
|
+
const axisX = elements.find((child) => child.type === XAxis)?.props, axisY = elements.find((child) => child.type === YAxis)?.props;
|
|
48
|
+
const grid = elements.find((child) => child.type === CartesianGrid)?.props;
|
|
49
|
+
const legend = elements.find((child) => child.type === Legend)?.props;
|
|
50
|
+
const frame = { top: margin?.top ?? (legend?.verticalAlign === "top" ? 36 : 16), bottom: margin?.bottom ?? (legend && legend.verticalAlign !== "top" ? 48 : axisX && !axisX.hide ? 32 : 16), left: margin?.left ?? (axisY && !axisY.hide ? 44 : 16), right: margin?.right ?? 16 };
|
|
51
|
+
const plotWidth = Math.max(1, width - frame.left - frame.right), plotHeight = Math.max(1, height - frame.top - frame.bottom);
|
|
52
|
+
const values = data.flatMap((row) => series.map((child) => Number(row[child.props.dataKey]) || 0));
|
|
53
|
+
const low = Math.min(0, ...values), high = Math.max(0, ...values) || 1;
|
|
54
|
+
const y = (value) => frame.top + (high - value) / (high - low) * plotHeight, base = y(0), band = plotWidth / Math.max(1, data.length), x = (index) => frame.left + band * (index + 0.5);
|
|
55
|
+
const barSeries = series.filter((child) => child.type === Bar), barWidth = band * 0.7 / Math.max(1, barSeries.length);
|
|
56
|
+
const payload = (row) => series.map((child) => {
|
|
57
|
+
const item = child.props;
|
|
58
|
+
return { dataKey: item.dataKey, name: item.name ?? item.dataKey, value: Number(row[item.dataKey]) || 0, color: item.fill ?? item.stroke ?? `var(--color-${item.dataKey}, var(--primary))`, payload: row };
|
|
59
|
+
});
|
|
60
|
+
const active = activeIndex !== null && !!data[activeIndex];
|
|
61
|
+
const label = active ? String(axisX?.dataKey ? data[activeIndex][axisX.dataKey] ?? "" : data[activeIndex].name ?? activeIndex + 1) : void 0;
|
|
62
|
+
return /* @__PURE__ */ jsx(Context.Provider, { value: { active, payload: active ? payload(data[activeIndex]) : [], legend: payload(data[0] ?? {}), label, tooltipId }, children: /* @__PURE__ */ jsxs("div", { ...props, "data-slot": "cartesian-chart", style: { position: "relative", width, height, ...style }, onMouseLeave: () => setActiveIndex(null), children: [
|
|
63
|
+
/* @__PURE__ */ jsxs("svg", { role: "img", "aria-label": props["aria-label"] ?? "数据图表", width: "100%", height: "100%", viewBox: `0 0 ${width} ${height}`, children: [
|
|
64
|
+
grid && grid.horizontal !== false && Array.from({ length: 5 }, (_, index) => /* @__PURE__ */ jsx("line", { x1: frame.left, x2: width - frame.right, y1: frame.top + plotHeight * index / 4, y2: frame.top + plotHeight * index / 4, stroke: grid.stroke ?? "var(--border)", strokeDasharray: grid.strokeDasharray, opacity: 0.7 }, index)),
|
|
65
|
+
grid?.vertical && data.map((_, index) => /* @__PURE__ */ jsx("line", { x1: x(index), x2: x(index), y1: frame.top, y2: height - frame.bottom, stroke: grid.stroke ?? "var(--border)", strokeDasharray: grid.strokeDasharray }, index)),
|
|
66
|
+
axisY && !axisY.hide && Array.from({ length: 5 }, (_, index) => {
|
|
67
|
+
const value = low + (high - low) * index / 4;
|
|
68
|
+
return /* @__PURE__ */ jsx("text", { x: frame.left - 8, y: y(value) + 4, textAnchor: "end", fill: "var(--muted-foreground)", fontSize: 11, children: axisY.tickFormatter ? axisY.tickFormatter(value) : Number(value.toFixed(2)) }, index);
|
|
69
|
+
}),
|
|
70
|
+
axisX && !axisX.hide && data.map((row, index) => /* @__PURE__ */ jsx("text", { x: x(index), y: height - frame.bottom + 20, textAnchor: "middle", fill: "var(--muted-foreground)", fontSize: 11, children: axisX.tickFormatter ? axisX.tickFormatter(row[axisX.dataKey ?? "name"] ?? index + 1) : String(row[axisX.dataKey ?? "name"] ?? index + 1) }, index)),
|
|
71
|
+
series.map((child, seriesIndex) => {
|
|
72
|
+
const item = child.props, color = item.fill ?? item.stroke ?? `var(--color-${item.dataKey}, var(--primary))`, points = data.map((row, index) => `${x(index)},${y(Number(row[item.dataKey]) || 0)}`).join(" ");
|
|
73
|
+
if (child.type === Bar) return /* @__PURE__ */ jsx("g", { "data-series": item.dataKey, children: data.map((row, index) => {
|
|
74
|
+
const value = Number(row[item.dataKey]) || 0, top = y(value);
|
|
75
|
+
return /* @__PURE__ */ jsx("rect", { "data-value": value, x: x(index) - band * 0.35 + barSeries.indexOf(child) * barWidth, y: Math.min(base, top), width: Math.max(1, barWidth - 2), height: Math.abs(base - top), rx: Math.max(0, item.radius ?? 3), fill: color }, index);
|
|
76
|
+
}) }, seriesIndex);
|
|
77
|
+
return /* @__PURE__ */ jsxs("g", { "data-series": item.dataKey, children: [
|
|
78
|
+
child.type === Area && data.length > 0 && /* @__PURE__ */ jsx("polygon", { points: `${x(0)},${base} ${points} ${x(data.length - 1)},${base}`, fill: color, opacity: 0.18 }),
|
|
79
|
+
/* @__PURE__ */ jsx("polyline", { points, fill: "none", stroke: item.stroke ?? color, strokeWidth: item.strokeWidth ?? 2 }),
|
|
80
|
+
data.map((row, index) => /* @__PURE__ */ jsx("circle", { cx: x(index), cy: y(Number(row[item.dataKey]) || 0), r: 3, fill: color }, index))
|
|
81
|
+
] }, seriesIndex);
|
|
82
|
+
}),
|
|
83
|
+
data.map((row, index) => /* @__PURE__ */ jsx("rect", { "data-chart-index": index, "aria-describedby": activeIndex === index && elements.some((child) => child.type === Tooltip) ? tooltipId : void 0, role: "button", tabIndex: 0, "aria-label": payload(row).map((item) => `${item.name}:${item.value}`).join(","), x: frame.left + band * index, y: frame.top, width: band, height: plotHeight, fill: "transparent", stroke: activeIndex === index ? "var(--primary)" : "transparent", strokeDasharray: "3 3", onMouseEnter: () => setActiveIndex(index), onFocus: () => setActiveIndex(index), onBlur: () => setActiveIndex(null), onKeyDown: (event) => {
|
|
84
|
+
if (["ArrowLeft", "ArrowRight", "Home", "End"].includes(event.key)) {
|
|
85
|
+
event.preventDefault();
|
|
86
|
+
const next = event.key === "Home" ? 0 : event.key === "End" ? data.length - 1 : Math.max(0, Math.min(data.length - 1, index + (event.key === "ArrowRight" ? 1 : -1)));
|
|
87
|
+
event.currentTarget.parentElement?.querySelector(`[data-chart-index="${next}"]`)?.focus();
|
|
88
|
+
}
|
|
89
|
+
} }, index))
|
|
90
|
+
] }),
|
|
91
|
+
elements.filter((child) => child.type === Tooltip || child.type === Legend)
|
|
92
|
+
] }) });
|
|
93
|
+
}
|
|
94
|
+
const BarChart = CartesianChart;
|
|
95
|
+
const LineChart = CartesianChart;
|
|
96
|
+
const AreaChart = CartesianChart;
|
|
97
|
+
function Tooltip(props) {
|
|
98
|
+
const state = React.useContext(Context), actual = { ...props, active: props.active ?? state.active, payload: props.payload ?? state.payload, label: props.label ?? state.label };
|
|
99
|
+
if (!actual.active) return null;
|
|
100
|
+
return /* @__PURE__ */ jsx("div", { id: state.tooltipId, role: "tooltip", style: { position: "absolute", top: 8, right: 8, pointerEvents: "none" }, children: props.content ? typeof props.content === "function" ? props.content(actual) : React.cloneElement(props.content, actual) : /* @__PURE__ */ jsxs("div", { style: { background: "var(--popover)", color: "var(--popover-foreground)", padding: 12, border: "1px solid var(--border)", borderRadius: 8 }, children: [
|
|
101
|
+
/* @__PURE__ */ jsx("strong", { children: actual.label }),
|
|
102
|
+
actual.payload?.map((item, index) => /* @__PURE__ */ jsx("div", { children: props.formatter ? props.formatter(item.value, item.name, item, index, item.payload) : `${item.name}:${item.value}` }, item.dataKey))
|
|
103
|
+
] }) });
|
|
104
|
+
}
|
|
105
|
+
function Legend(props) {
|
|
106
|
+
const state = React.useContext(Context), actual = { ...props, payload: props.payload ?? state.legend };
|
|
107
|
+
return /* @__PURE__ */ jsx("div", { style: { position: "absolute", [props.verticalAlign === "top" ? "top" : "bottom"]: 0, left: 0, right: 0 }, children: props.content ? typeof props.content === "function" ? props.content(actual) : React.cloneElement(props.content, actual) : /* @__PURE__ */ jsx("div", { style: { display: "flex", justifyContent: "center", gap: 16 }, children: actual.payload.map((item) => /* @__PURE__ */ jsxs("span", { style: { color: item.color }, children: [
|
|
108
|
+
"● ",
|
|
109
|
+
item.name
|
|
110
|
+
] }, item.dataKey)) }) });
|
|
111
|
+
}
|
|
112
|
+
export {
|
|
113
|
+
Area,
|
|
114
|
+
AreaChart,
|
|
115
|
+
Bar,
|
|
116
|
+
BarChart,
|
|
117
|
+
CartesianGrid,
|
|
118
|
+
Legend,
|
|
119
|
+
Line,
|
|
120
|
+
LineChart,
|
|
121
|
+
ResponsiveContainer,
|
|
122
|
+
Tooltip,
|
|
123
|
+
XAxis,
|
|
124
|
+
YAxis
|
|
125
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type ButtonProps } from './core';
|
|
3
|
+
export type CheckedState = boolean | 'indeterminate';
|
|
4
|
+
export interface CheckboxProps extends Omit<ButtonProps, 'defaultChecked' | 'onChange'> {
|
|
5
|
+
checked?: CheckedState;
|
|
6
|
+
defaultChecked?: CheckedState;
|
|
7
|
+
onCheckedChange?: (checked: CheckedState) => void;
|
|
8
|
+
required?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function Root({ checked, defaultChecked, onCheckedChange, onClick, children, name, value, required, ...props }: CheckboxProps): React.JSX.Element;
|
|
11
|
+
export declare function Indicator({ forceMount, ...props }: React.ComponentProps<'span'> & {
|
|
12
|
+
forceMount?: true;
|
|
13
|
+
}): React.JSX.Element | null;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { useControllable, ButtonPart } from "./core.js";
|
|
4
|
+
const CheckedContext = React.createContext(false);
|
|
5
|
+
function Root({ checked, defaultChecked = false, onCheckedChange, onClick, children, name, value = "on", required, ...props }) {
|
|
6
|
+
const [current, set] = useControllable(checked, defaultChecked, onCheckedChange);
|
|
7
|
+
return /* @__PURE__ */ jsxs(CheckedContext.Provider, { value: current, children: [
|
|
8
|
+
/* @__PURE__ */ jsx(ButtonPart, { ...props, role: "checkbox", "aria-checked": current === "indeterminate" ? "mixed" : current, "aria-required": required, "data-state": current === "indeterminate" ? "indeterminate" : current ? "checked" : "unchecked", "data-disabled": props.disabled ? "" : void 0, onClick: (event) => {
|
|
9
|
+
onClick?.(event);
|
|
10
|
+
if (!event.defaultPrevented)
|
|
11
|
+
set(current !== true);
|
|
12
|
+
}, children }),
|
|
13
|
+
name && /* @__PURE__ */ jsx("input", { type: "checkbox", tabIndex: -1, "aria-hidden": "true", name, value, required, disabled: props.disabled, checked: current === true, onChange: () => {
|
|
14
|
+
}, style: { position: "absolute", opacity: 0, width: 1, height: 1, pointerEvents: "none" } })
|
|
15
|
+
] });
|
|
16
|
+
}
|
|
17
|
+
function Indicator({ forceMount, ...props }) {
|
|
18
|
+
const checked = React.useContext(CheckedContext);
|
|
19
|
+
return checked || forceMount ? /* @__PURE__ */ jsx("span", { ...props, hidden: !checked, "data-state": checked === "indeterminate" ? "indeterminate" : "checked" }) : null;
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
Indicator,
|
|
23
|
+
Root
|
|
24
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type ButtonProps, type DivProps } from './core';
|
|
3
|
+
export interface CollapsibleProps extends DivProps {
|
|
4
|
+
open?: boolean;
|
|
5
|
+
defaultOpen?: boolean;
|
|
6
|
+
onOpenChange?: (open: boolean) => void;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function Root({ open, defaultOpen, onOpenChange, disabled, ...props }: CollapsibleProps): React.JSX.Element;
|
|
10
|
+
export declare function Trigger({ onClick, ...props }: ButtonProps): React.JSX.Element;
|
|
11
|
+
export declare function Content({ forceMount, ...props }: DivProps & {
|
|
12
|
+
forceMount?: true;
|
|
13
|
+
}): React.JSX.Element | null;
|
|
14
|
+
export { Trigger as CollapsibleTrigger, Content as CollapsibleContent };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { DivPart, ButtonPart, useControllable } from "./core.js";
|
|
4
|
+
const Context = React.createContext({ open: false, setOpen: (_open) => {
|
|
5
|
+
}, disabled: false, id: "" });
|
|
6
|
+
function Root({ open, defaultOpen = false, onOpenChange, disabled = false, ...props }) {
|
|
7
|
+
const [current, setOpen] = useControllable(open, defaultOpen, onOpenChange);
|
|
8
|
+
const id = React.useId();
|
|
9
|
+
return /* @__PURE__ */ jsx(Context.Provider, { value: { open: current, setOpen, disabled, id }, children: /* @__PURE__ */ jsx(DivPart, { ...props, "data-state": current ? "open" : "closed", "data-disabled": disabled ? "" : void 0 }) });
|
|
10
|
+
}
|
|
11
|
+
function Trigger({ onClick, ...props }) {
|
|
12
|
+
const state = React.useContext(Context);
|
|
13
|
+
return /* @__PURE__ */ jsx(ButtonPart, { ...props, disabled: state.disabled || props.disabled, "aria-expanded": state.open, "aria-controls": state.id, "data-state": state.open ? "open" : "closed", onClick: (event) => {
|
|
14
|
+
onClick?.(event);
|
|
15
|
+
if (!event.defaultPrevented)
|
|
16
|
+
state.setOpen(!state.open);
|
|
17
|
+
} });
|
|
18
|
+
}
|
|
19
|
+
function Content({ forceMount, ...props }) {
|
|
20
|
+
const state = React.useContext(Context);
|
|
21
|
+
return state.open || forceMount ? /* @__PURE__ */ jsx(DivPart, { ...props, id: state.id, hidden: !state.open, "data-state": state.open ? "open" : "closed" }) : null;
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
Content as CollapsibleContent,
|
|
25
|
+
Trigger as CollapsibleTrigger,
|
|
26
|
+
Content,
|
|
27
|
+
Root,
|
|
28
|
+
Trigger
|
|
29
|
+
};
|