@box-kite/react 0.0.1 → 2.0.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/.claude/rules/box-kite-rules.md +65 -0
- package/.claude/skills/box-kite/SKILL.md +138 -0
- package/.claude/skills/box-kite/references/components.md +235 -0
- package/.claude/skills/box-kite/references/extending.md +42 -0
- package/.claude/skills/box-kite/references/patterns.md +27 -0
- package/.claude/skills/box-kite/references/styling.md +222 -0
- package/.cursor/rules/box-kite.mdc +73 -0
- package/AGENTS.md +102 -0
- package/BOX_AI_CONTEXT.md +2804 -0
- package/BOX_KITE_AI_CONTEXT.md +2804 -0
- package/LICENSE +21 -0
- package/README.md +744 -7
- package/a11y.cjs +1 -0
- package/a11y.d.ts +15 -0
- package/a11y.mjs +4 -0
- package/anchor.cjs +1 -0
- package/anchor.d.ts +14 -0
- package/anchor.mjs +3 -0
- package/behavior.cjs +1 -0
- package/behavior.mjs +277 -0
- package/box.cjs +1 -0
- package/box.d.ts +46 -0
- package/box.mjs +23 -0
- package/client.cjs +1 -0
- package/client.mjs +164 -0
- package/components/accordion.cjs +1 -0
- package/components/accordion.d.ts +114 -0
- package/components/accordion.mjs +251 -0
- package/components/baseSvg.cjs +1 -0
- package/components/baseSvg.d.ts +5 -0
- package/components/baseSvg.mjs +21 -0
- package/components/button.cjs +1 -0
- package/components/button.d.ts +19 -0
- package/components/button.mjs +19 -0
- package/components/chart.cjs +1 -0
- package/components/chart.d.ts +83 -0
- package/components/chart.mjs +236 -0
- package/components/checkbox.cjs +1 -0
- package/components/checkbox.d.ts +36 -0
- package/components/checkbox.mjs +38 -0
- package/components/combobox/comboboxChips.d.ts +21 -0
- package/components/combobox/comboboxListbox.d.ts +47 -0
- package/components/combobox.cjs +1 -0
- package/components/combobox.d.ts +121 -0
- package/components/combobox.mjs +563 -0
- package/components/dataGrid/components/dataGridAggregateValue.d.ts +10 -0
- package/components/dataGrid/components/dataGridBody.d.ts +7 -0
- package/components/dataGrid/components/dataGridBottomBar.d.ts +6 -0
- package/components/dataGrid/components/dataGridCell.d.ts +16 -0
- package/components/dataGrid/components/dataGridCellEditor.d.ts +15 -0
- package/components/dataGrid/components/dataGridCellPlaceholder.d.ts +14 -0
- package/components/dataGrid/components/dataGridCellRowDetail.d.ts +6 -0
- package/components/dataGrid/components/dataGridCellRowSelection.d.ts +6 -0
- package/components/dataGrid/components/dataGridCellText.d.ts +6 -0
- package/components/dataGrid/components/dataGridCellTree.d.ts +16 -0
- package/components/dataGrid/components/dataGridColumnFilter.d.ts +9 -0
- package/components/dataGrid/components/dataGridColumnGroups.d.ts +7 -0
- package/components/dataGrid/components/dataGridContent.d.ts +6 -0
- package/components/dataGrid/components/dataGridDataSourceError.d.ts +12 -0
- package/components/dataGrid/components/dataGridDetailRow.d.ts +8 -0
- package/components/dataGrid/components/dataGridEmptyColumns.d.ts +6 -0
- package/components/dataGrid/components/dataGridExport.d.ts +10 -0
- package/components/dataGrid/components/dataGridFilterCell.d.ts +11 -0
- package/components/dataGrid/components/dataGridFilterRow.d.ts +6 -0
- package/components/dataGrid/components/dataGridFooter.d.ts +11 -0
- package/components/dataGrid/components/dataGridGlobalFilter.d.ts +6 -0
- package/components/dataGrid/components/dataGridGroupRow.d.ts +8 -0
- package/components/dataGrid/components/dataGridHeader.d.ts +6 -0
- package/components/dataGrid/components/dataGridHeaderCell.d.ts +9 -0
- package/components/dataGrid/components/dataGridHeaderCellContextMenu.d.ts +11 -0
- package/components/dataGrid/components/dataGridHeaderCellResizer.d.ts +14 -0
- package/components/dataGrid/components/dataGridLoader.d.ts +11 -0
- package/components/dataGrid/components/dataGridPagination.d.ts +6 -0
- package/components/dataGrid/components/dataGridRow.d.ts +8 -0
- package/components/dataGrid/components/dataGridTopBar.d.ts +6 -0
- package/components/dataGrid/components/dataGridTopBarContextMenu.d.ts +6 -0
- package/components/dataGrid/contracts/dataGridContract.d.ts +671 -0
- package/components/dataGrid/export/gridExport.d.ts +10 -0
- package/components/dataGrid/gridNavigationContext.d.ts +32 -0
- package/components/dataGrid/models/aggregateCellModel.d.ts +34 -0
- package/components/dataGrid/models/aggregationModel.d.ts +32 -0
- package/components/dataGrid/models/cellKeys.d.ts +11 -0
- package/components/dataGrid/models/cellModel.d.ts +44 -0
- package/components/dataGrid/models/columnModel.d.ts +160 -0
- package/components/dataGrid/models/columnVisibilityModel.d.ts +24 -0
- package/components/dataGrid/models/dataSourceModel.d.ts +177 -0
- package/components/dataGrid/models/detailRowModel.d.ts +22 -0
- package/components/dataGrid/models/editModel.d.ts +77 -0
- package/components/dataGrid/models/exportModel.d.ts +51 -0
- package/components/dataGrid/models/filterModel.d.ts +22 -0
- package/components/dataGrid/models/gridModel.d.ts +293 -0
- package/components/dataGrid/models/groupRowCellModel.d.ts +34 -0
- package/components/dataGrid/models/groupRowModel.d.ts +68 -0
- package/components/dataGrid/models/headerCellModel.d.ts +83 -0
- package/components/dataGrid/models/paginationModel.d.ts +32 -0
- package/components/dataGrid/models/rowModel.d.ts +46 -0
- package/components/dataGrid/models/sourceGroupRowModel.d.ts +45 -0
- package/components/dataGrid/models/sourceLevel.d.ts +71 -0
- package/components/dataGrid/models/sourceRowModel.d.ts +29 -0
- package/components/dataGrid/models/sourceTreeRowModel.d.ts +23 -0
- package/components/dataGrid/models/treeModel.d.ts +94 -0
- package/components/dataGrid/models/treeRow.d.ts +22 -0
- package/components/dataGrid/models/treeRowModel.d.ts +50 -0
- package/components/dataGrid/models/viewportModel.d.ts +44 -0
- package/components/dataGrid/useGrid.d.ts +8 -0
- package/components/dataGrid/useGridNavigation.d.ts +21 -0
- package/components/dataGrid.cjs +1 -0
- package/components/dataGrid.d.ts +4 -0
- package/components/dataGrid.mjs +4907 -0
- package/components/dialog.cjs +1 -0
- package/components/dialog.d.ts +151 -0
- package/components/dialog.mjs +223 -0
- package/components/dropdown/dropdownContext.d.ts +44 -0
- package/components/dropdown/dropdownItems.d.ts +22 -0
- package/components/dropdown/dropdownRowRenderer.d.ts +8 -0
- package/components/dropdown/dropdownSearch.d.ts +21 -0
- package/components/dropdown/utils.d.ts +1 -0
- package/components/dropdown.cjs +1 -0
- package/components/dropdown.d.ts +77 -0
- package/components/dropdown.mjs +491 -0
- package/components/flex.cjs +1 -0
- package/components/flex.d.ts +6 -0
- package/components/flex.mjs +16 -0
- package/components/form.cjs +1 -0
- package/components/form.d.ts +10 -0
- package/components/form.mjs +58 -0
- package/components/grid.cjs +1 -0
- package/components/grid.d.ts +6 -0
- package/components/grid.mjs +16 -0
- package/components/icon.cjs +1 -0
- package/components/icon.d.ts +37 -0
- package/components/icon.mjs +41 -0
- package/components/menu.cjs +1 -0
- package/components/menu.d.ts +234 -0
- package/components/menu.mjs +422 -0
- package/components/overlay.cjs +1 -0
- package/components/overlay.d.ts +47 -0
- package/components/overlay.mjs +52 -0
- package/components/popover.cjs +1 -0
- package/components/popover.d.ts +100 -0
- package/components/popover.mjs +69 -0
- package/components/presence.cjs +1 -0
- package/components/presence.d.ts +36 -0
- package/components/presence.mjs +11 -0
- package/components/progress.cjs +1 -0
- package/components/progress.d.ts +47 -0
- package/components/progress.mjs +28 -0
- package/components/radioButton.cjs +1 -0
- package/components/radioButton.d.ts +32 -0
- package/components/radioButton.mjs +32 -0
- package/components/radioGroup.cjs +1 -0
- package/components/radioGroup.d.ts +51 -0
- package/components/radioGroup.mjs +83 -0
- package/components/select.cjs +1 -0
- package/components/select.d.ts +51 -0
- package/components/select.mjs +36 -0
- package/components/semantics.cjs +1 -0
- package/components/semantics.d.ts +39 -0
- package/components/semantics.mjs +17 -0
- package/components/slider.cjs +1 -0
- package/components/slider.d.ts +98 -0
- package/components/slider.mjs +250 -0
- package/components/svg.cjs +1 -0
- package/components/svg.d.ts +65 -0
- package/components/svg.mjs +141 -0
- package/components/switch.cjs +1 -0
- package/components/switch.d.ts +29 -0
- package/components/switch.mjs +25 -0
- package/components/tabs.cjs +1 -0
- package/components/tabs.d.ts +87 -0
- package/components/tabs.mjs +324 -0
- package/components/textarea.cjs +1 -0
- package/components/textarea.d.ts +41 -0
- package/components/textarea.mjs +33 -0
- package/components/textbox.cjs +1 -0
- package/components/textbox.d.ts +38 -0
- package/components/textbox.mjs +33 -0
- package/components/toaster.cjs +1 -0
- package/components/toaster.d.ts +106 -0
- package/components/toaster.mjs +295 -0
- package/components/tooltip.cjs +1 -0
- package/components/tooltip.d.ts +98 -0
- package/components/tooltip.mjs +110 -0
- package/components/visuallyHidden.cjs +1 -0
- package/components/visuallyHidden.d.ts +6 -0
- package/components/visuallyHidden.mjs +23 -0
- package/docs/a11y.md +199 -0
- package/docs/anchor.md +139 -0
- package/docs/components.md +48 -0
- package/docs/index.md +11 -0
- package/docs/props.md +1777 -0
- package/effects.cjs +1 -0
- package/effects.mjs +6 -0
- package/forms.cjs +1 -0
- package/forms.mjs +21 -0
- package/gridExport.cjs +2 -0
- package/gridExport.mjs +244 -0
- package/icons/dotsIcon.d.ts +2 -0
- package/icons/expandIcon.d.ts +2 -0
- package/icons/groupingIcon.d.ts +2 -0
- package/icons/pinIcon.d.ts +2 -0
- package/icons/searchIcon.d.ts +2 -0
- package/icons/sortIcon.d.ts +2 -0
- package/identity.cjs +1 -0
- package/identity.mjs +12 -0
- package/keyboard.cjs +1 -0
- package/keyboard.mjs +30 -0
- package/layer.cjs +1 -0
- package/layer.mjs +127 -0
- package/motion.cjs +1 -0
- package/motion.mjs +66 -0
- package/package.json +327 -7
- package/placement.cjs +1 -0
- package/placement.mjs +180 -0
- package/platform.cjs +1 -0
- package/platform.mjs +45 -0
- package/react/a11y/callbacks.d.ts +12 -0
- package/react/a11y/useControllableState.d.ts +25 -0
- package/react/a11y/useDismiss.d.ts +25 -0
- package/react/a11y/useFocusReturn.d.ts +18 -0
- package/react/a11y/useRovingFocus.d.ts +84 -0
- package/react/anchor/useAnchorPosition.d.ts +79 -0
- package/react/animation/usePresence.d.ts +32 -0
- package/react/boxClassNames.d.ts +25 -0
- package/react/boxProps.d.ts +49 -0
- package/react/boxTagProps.d.ts +7 -0
- package/react/clientRuntime.d.ts +11 -0
- package/react/dialog/useScrollLock.d.ts +12 -0
- package/react/effects.d.ts +10 -0
- package/react/forms/labelledControl.d.ts +17 -0
- package/react/forms/placeholderProp.d.ts +13 -0
- package/react/hooks/usePortalContainer.d.ts +6 -0
- package/react/hooks/useVirtualization.d.ts +32 -0
- package/react/hooks/useVisibility.d.ts +9 -0
- package/react/identity/useIdentifier.d.ts +17 -0
- package/react/popover/usePopoverLayer.d.ts +87 -0
- package/react/reactTypes.d.ts +10 -0
- package/react/resolveStyles.d.ts +18 -0
- package/react/styleElements.d.ts +3 -0
- package/react/svg/attributesInProps.d.ts +4 -0
- package/react/svg/svgNaming.d.ts +15 -0
- package/react/theme/theme.d.ts +26 -0
- package/react/theme/themeContext.d.ts +7 -0
- package/react/useStyles.d.ts +22 -0
- package/react-shared.cjs +1 -0
- package/react-shared.mjs +122 -0
- package/rolldown-runtime.cjs +1 -0
- package/rsc.cjs +1 -0
- package/rsc.d.ts +27 -0
- package/rsc.mjs +18 -0
- package/ssg.cjs +1 -0
- package/ssg.d.ts +24 -0
- package/ssg.mjs +25 -0
- package/utils/accordion/accordionUtils.d.ts +48 -0
- package/utils/anchor/anchorUtils.d.ts +79 -0
- package/utils/animation/animationUtils.d.ts +29 -0
- package/utils/array/arrayUtils.d.ts +15 -0
- package/utils/array/lazyList.d.ts +10 -0
- package/utils/box/boxUtils.d.ts +5 -0
- package/utils/chart/chartPalette.d.ts +15 -0
- package/utils/chart/chartUtils.d.ts +92 -0
- package/utils/combobox/comboboxUtils.d.ts +89 -0
- package/utils/dom/domUtils.d.ts +32 -0
- package/utils/environment/environmentUtils.d.ts +28 -0
- package/utils/export/csvUtils.d.ts +23 -0
- package/utils/export/downloadUtils.d.ts +12 -0
- package/utils/export/xlsxUtils.d.ts +56 -0
- package/utils/export/zipUtils.d.ts +26 -0
- package/utils/fn/fnUtils.d.ts +4 -0
- package/utils/form/formUtils.d.ts +8 -0
- package/utils/keyboard/typeaheadUtils.d.ts +31 -0
- package/utils/memo.d.ts +10 -0
- package/utils/menu/menuUtils.d.ts +25 -0
- package/utils/object/objectUtils.d.ts +13 -0
- package/utils/slider/sliderUtils.d.ts +67 -0
- package/utils/string/fuzzySearch.d.ts +27 -0
- package/utils/string/stringUtils.d.ts +4 -0
- package/utils/tabs/tabsUtils.d.ts +75 -0
- package/utils/toast/toastStore.d.ts +73 -0
- package/utils/virtual/virtualUtils.d.ts +47 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { BoxProps } from '../box';
|
|
2
|
+
import { ChangeHandler } from '../react/a11y/useControllableState';
|
|
3
|
+
import { ComponentsAndVariants } from '@box-kite/core/types';
|
|
4
|
+
/**
|
|
5
|
+
* Why a panel opened or closed. One reason today — a press on the header, which is also what Enter and
|
|
6
|
+
* Space on it produce — and the shape every other component in the library reports through.
|
|
7
|
+
*/
|
|
8
|
+
export type DisclosureReason = 'trigger';
|
|
9
|
+
/** Which heading the header sits in. It says where the section sits in the document outline, nothing more. */
|
|
10
|
+
export type AccordionLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
11
|
+
type AccordionBoxProps<TKey extends keyof ComponentsAndVariants> = Omit<BoxProps<'div', TKey>, 'onChange'>;
|
|
12
|
+
export interface AccordionProps<TKey extends keyof ComponentsAndVariants = 'accordion'> extends AccordionBoxProps<TKey> {
|
|
13
|
+
/** The sections: one `Accordion.Item` each, holding an `Accordion.Trigger` and an `Accordion.Panel`. */
|
|
14
|
+
children?: React.ReactNode;
|
|
15
|
+
/** Controlled: the values of every panel standing open. Leave it out and the widget owns them. */
|
|
16
|
+
value?: string[];
|
|
17
|
+
/** Which panels start open. Left out, all of them are closed. */
|
|
18
|
+
defaultValue?: string[];
|
|
19
|
+
/** Fires with the panels now open, in the order they were opened. */
|
|
20
|
+
onValueChange?: ChangeHandler<string[], DisclosureReason>;
|
|
21
|
+
/** Whether several panels may stand open at once. Default `false`, so opening one closes the last. */
|
|
22
|
+
multiple?: boolean;
|
|
23
|
+
/** Whether Down and Up wrap around at the ends. Default `true`. */
|
|
24
|
+
loop?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Which heading each header sits in. Default `3`. It has to fit the page around it — a heading level
|
|
27
|
+
* is the document's outline, and a screen reader navigates by it.
|
|
28
|
+
*/
|
|
29
|
+
level?: AccordionLevel;
|
|
30
|
+
}
|
|
31
|
+
export interface AccordionItemProps<TKey extends keyof ComponentsAndVariants = 'accordion.item'> extends BoxProps<'div', TKey> {
|
|
32
|
+
/** What this section stands for, and what the widget reports when it is open. */
|
|
33
|
+
value: string;
|
|
34
|
+
/** The header and the panel. */
|
|
35
|
+
children?: React.ReactNode;
|
|
36
|
+
/**
|
|
37
|
+
* Not openable, and stepped over by Down and Up. It is the `disabled` attribute, so the browser has
|
|
38
|
+
* already taken the header out of the tab sequence — arrows that still stopped there would be
|
|
39
|
+
* reaching what Tab cannot.
|
|
40
|
+
*/
|
|
41
|
+
disabled?: boolean;
|
|
42
|
+
}
|
|
43
|
+
/** Every Box prop, on the `<button>` inside the heading. */
|
|
44
|
+
export interface AccordionTriggerProps<TKey extends keyof ComponentsAndVariants = 'accordion.trigger'> extends Omit<BoxProps<'button', TKey>, 'disabled'> {
|
|
45
|
+
/** The header's label. */
|
|
46
|
+
children?: React.ReactNode;
|
|
47
|
+
/** This header's heading level, when it differs from the one the accordion sets. */
|
|
48
|
+
level?: AccordionLevel;
|
|
49
|
+
/** Whether to draw the chevron. Turn it off to supply an affordance of your own. Default `true`. */
|
|
50
|
+
arrow?: boolean;
|
|
51
|
+
}
|
|
52
|
+
export interface AccordionPanelProps<TKey extends keyof ComponentsAndVariants = 'accordion.panel'> extends BoxProps<'div', TKey> {
|
|
53
|
+
/** The section's content. */
|
|
54
|
+
children?: React.ReactNode;
|
|
55
|
+
}
|
|
56
|
+
interface AccordionType {
|
|
57
|
+
<TKey extends keyof ComponentsAndVariants = 'accordion'>(props: AccordionProps<TKey>): React.ReactNode;
|
|
58
|
+
Item: <TKey extends keyof ComponentsAndVariants = 'accordion.item'>(props: AccordionItemProps<TKey>) => React.ReactNode;
|
|
59
|
+
Trigger: <TKey extends keyof ComponentsAndVariants = 'accordion.trigger'>(props: AccordionTriggerProps<TKey>) => React.ReactNode;
|
|
60
|
+
Panel: <TKey extends keyof ComponentsAndVariants = 'accordion.panel'>(props: AccordionPanelProps<TKey>) => React.ReactNode;
|
|
61
|
+
displayName?: string;
|
|
62
|
+
}
|
|
63
|
+
/** The DOM attributes a collapsible's trigger has to carry. */
|
|
64
|
+
export interface CollapsibleTriggerAttributes {
|
|
65
|
+
id: string;
|
|
66
|
+
type: 'button';
|
|
67
|
+
'aria-expanded': boolean;
|
|
68
|
+
'aria-controls': string;
|
|
69
|
+
onClick(event: React.MouseEvent): void;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* What the trigger has to carry: spread it onto the control itself, not a wrapper.
|
|
73
|
+
*
|
|
74
|
+
* ```tsx
|
|
75
|
+
* {(trigger) => <Button {...trigger}>Details</Button>}
|
|
76
|
+
* {(trigger) => <button {...trigger.props}>Details</button>}
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
export interface CollapsibleTrigger {
|
|
80
|
+
props: CollapsibleTriggerAttributes;
|
|
81
|
+
}
|
|
82
|
+
export interface CollapsibleProps<TKey extends keyof ComponentsAndVariants = 'collapsible'> extends Omit<BoxProps<'div', TKey>, 'open'> {
|
|
83
|
+
/** The content the trigger reveals. */
|
|
84
|
+
children?: React.ReactNode;
|
|
85
|
+
/** The control that opens it, handed the props that wire it to the panel. It has to be a button. */
|
|
86
|
+
trigger: (trigger: CollapsibleTrigger) => React.ReactNode;
|
|
87
|
+
/** Controlled open state. Leave it out and the widget owns it. */
|
|
88
|
+
open?: boolean;
|
|
89
|
+
/** Whether it starts open. Default `false`. */
|
|
90
|
+
defaultOpen?: boolean;
|
|
91
|
+
/** Fires with the new state and why it changed. */
|
|
92
|
+
onOpenChange?: ChangeHandler<boolean, DisclosureReason>;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* One disclosure: a trigger, and the content it reveals.
|
|
96
|
+
*
|
|
97
|
+
* ```tsx
|
|
98
|
+
* <Collapsible trigger={(trigger) => <Button {...trigger}>What is in the box?</Button>}>
|
|
99
|
+
* <P>A kite.</P>
|
|
100
|
+
* </Collapsible>
|
|
101
|
+
* ```
|
|
102
|
+
*
|
|
103
|
+
* The same one-row grid an `Accordion` panel opens in, with no heading, no group and no arrow keys — a
|
|
104
|
+
* lone button needs none of them. Reach for it for a "show more", a filter drawer or a sidebar section;
|
|
105
|
+
* reach for `Accordion` when several sections know about each other.
|
|
106
|
+
*
|
|
107
|
+
* @a11y The trigger carries `aria-expanded` and `aria-controls`; the content has no role of its own,
|
|
108
|
+
* because a region wants a name and a trigger is not a heading. Use an `Accordion` where the sections
|
|
109
|
+
* are document structure.
|
|
110
|
+
*/
|
|
111
|
+
declare function Collapsible<TKey extends keyof ComponentsAndVariants = 'collapsible'>(props: CollapsibleProps<TKey>): import("react").JSX.Element;
|
|
112
|
+
export { Collapsible };
|
|
113
|
+
declare const Accordion: AccordionType;
|
|
114
|
+
export default Accordion;
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import e from "../box.mjs";
|
|
3
|
+
import { a as t, i as n } from "../behavior.mjs";
|
|
4
|
+
import { t as r } from "../identity.mjs";
|
|
5
|
+
import { createContext as i, useContext as a, useMemo as o, useRef as s } from "react";
|
|
6
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
7
|
+
//#region src/utils/accordion/accordionUtils.ts
|
|
8
|
+
var u;
|
|
9
|
+
(function(e) {
|
|
10
|
+
e.ROOT_ATTRIBUTE = "data-accordion", e.TRIGGER_ATTRIBUTE = "data-accordion-trigger";
|
|
11
|
+
let t = e.ROOT_SELECTOR = "[data-accordion]", n = e.TRIGGER_SELECTOR = "[data-accordion-trigger]";
|
|
12
|
+
function r(e, n) {
|
|
13
|
+
return n instanceof Element && n.closest(t) === e;
|
|
14
|
+
}
|
|
15
|
+
e.owns = r;
|
|
16
|
+
function i(e) {
|
|
17
|
+
return e ? [...e.querySelectorAll(n)].filter((t) => r(e, t)) : [];
|
|
18
|
+
}
|
|
19
|
+
e.triggers = i;
|
|
20
|
+
function a(e) {
|
|
21
|
+
return e.hasAttribute("disabled") || e.getAttribute("aria-disabled") === "true";
|
|
22
|
+
}
|
|
23
|
+
e.isDisabled = a;
|
|
24
|
+
function o(e, t, n, r) {
|
|
25
|
+
let i = e.length;
|
|
26
|
+
if (i === 0) return;
|
|
27
|
+
let o = t < 0 || t >= i ? n > 0 ? -1 : i : t;
|
|
28
|
+
for (let t = 0; t < i; t++) {
|
|
29
|
+
if (o += n, o < 0 || o >= i) {
|
|
30
|
+
if (!r) return;
|
|
31
|
+
o = (o % i + i) % i;
|
|
32
|
+
}
|
|
33
|
+
if (!a(e[o])) return e[o];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
e.step = o;
|
|
37
|
+
function s(e, t) {
|
|
38
|
+
return o(e, t === 1 ? -1 : e.length, t, !1);
|
|
39
|
+
}
|
|
40
|
+
e.edge = s;
|
|
41
|
+
function c(e, t) {
|
|
42
|
+
return t instanceof HTMLElement ? e.indexOf(t) : -1;
|
|
43
|
+
}
|
|
44
|
+
e.indexOf = c;
|
|
45
|
+
function l(e) {
|
|
46
|
+
if (e === "ArrowDown") return {
|
|
47
|
+
kind: "step",
|
|
48
|
+
delta: 1
|
|
49
|
+
};
|
|
50
|
+
if (e === "ArrowUp") return {
|
|
51
|
+
kind: "step",
|
|
52
|
+
delta: -1
|
|
53
|
+
};
|
|
54
|
+
if (e === "Home") return {
|
|
55
|
+
kind: "edge",
|
|
56
|
+
delta: 1
|
|
57
|
+
};
|
|
58
|
+
if (e === "End") return {
|
|
59
|
+
kind: "edge",
|
|
60
|
+
delta: -1
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
e.moveFor = l;
|
|
64
|
+
function u(e, t, n, r) {
|
|
65
|
+
return n.kind === "edge" ? s(e, n.delta) : o(e, t, n.delta, r);
|
|
66
|
+
}
|
|
67
|
+
e.target = u;
|
|
68
|
+
function d(e, t, n) {
|
|
69
|
+
return e.includes(t) ? e.filter((e) => e !== t) : n ? [...e, t] : [t];
|
|
70
|
+
}
|
|
71
|
+
e.toggle = d;
|
|
72
|
+
})(u ||= {});
|
|
73
|
+
var d = u, f = [
|
|
74
|
+
"h1",
|
|
75
|
+
"h2",
|
|
76
|
+
"h3",
|
|
77
|
+
"h4",
|
|
78
|
+
"h5",
|
|
79
|
+
"h6"
|
|
80
|
+
], p = i(null), m = i(null);
|
|
81
|
+
function h(e) {
|
|
82
|
+
let t = a(p);
|
|
83
|
+
if (!t) throw Error(`<${e}> has to be rendered inside an <Accordion>.`);
|
|
84
|
+
return t;
|
|
85
|
+
}
|
|
86
|
+
function g(e) {
|
|
87
|
+
let t = a(m);
|
|
88
|
+
if (!t) throw Error(`<${e}> has to be rendered inside an <Accordion.Item>.`);
|
|
89
|
+
return t;
|
|
90
|
+
}
|
|
91
|
+
function _(r) {
|
|
92
|
+
let { children: i, value: a, defaultValue: l, onValueChange: u, multiple: f = !1, loop: m = !0, level: h = 3, props: g, ..._ } = r, v = s(null), [y, b] = n({
|
|
93
|
+
value: a,
|
|
94
|
+
defaultValue: l ?? [],
|
|
95
|
+
onChange: u
|
|
96
|
+
}), x = t((e, t) => {
|
|
97
|
+
b((t) => d.toggle(t, e, f), t);
|
|
98
|
+
}), S = t((e) => {
|
|
99
|
+
let t = v.current;
|
|
100
|
+
if (!t || e.defaultPrevented || !d.owns(t, e.target)) return;
|
|
101
|
+
let n = d.triggers(t), r = d.indexOf(n, e.target);
|
|
102
|
+
if (r === -1) return;
|
|
103
|
+
let i = d.moveFor(e.key);
|
|
104
|
+
if (!i) return;
|
|
105
|
+
let a = d.target(n, r, i, m);
|
|
106
|
+
a && (e.preventDefault(), a.focus());
|
|
107
|
+
}), C = o(() => ({
|
|
108
|
+
open: y,
|
|
109
|
+
level: h,
|
|
110
|
+
toggle: x
|
|
111
|
+
}), [
|
|
112
|
+
y,
|
|
113
|
+
h,
|
|
114
|
+
x
|
|
115
|
+
]);
|
|
116
|
+
return /* @__PURE__ */ c(p.Provider, {
|
|
117
|
+
value: C,
|
|
118
|
+
children: /* @__PURE__ */ c(e, {
|
|
119
|
+
ref: v,
|
|
120
|
+
component: "accordion",
|
|
121
|
+
..._,
|
|
122
|
+
props: {
|
|
123
|
+
[d.ROOT_ATTRIBUTE]: "",
|
|
124
|
+
...g,
|
|
125
|
+
onKeyDown: S
|
|
126
|
+
},
|
|
127
|
+
children: i
|
|
128
|
+
})
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
function v(t) {
|
|
132
|
+
let { value: n, children: i, disabled: a = !1, props: s, ...l } = t, { open: u } = h("Accordion.Item"), d = r("accordion"), f = u.includes(n), p = o(() => ({
|
|
133
|
+
value: n,
|
|
134
|
+
open: f,
|
|
135
|
+
disabled: a,
|
|
136
|
+
triggerId: `${d}-trigger`,
|
|
137
|
+
panelId: `${d}-panel`
|
|
138
|
+
}), [
|
|
139
|
+
n,
|
|
140
|
+
f,
|
|
141
|
+
a,
|
|
142
|
+
d
|
|
143
|
+
]);
|
|
144
|
+
return /* @__PURE__ */ c(m.Provider, {
|
|
145
|
+
value: p,
|
|
146
|
+
children: /* @__PURE__ */ c(e, {
|
|
147
|
+
component: "accordion.item",
|
|
148
|
+
...l,
|
|
149
|
+
props: s,
|
|
150
|
+
children: i
|
|
151
|
+
})
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
v.displayName = "Accordion.Item";
|
|
155
|
+
function y(n) {
|
|
156
|
+
let { children: r, level: i, arrow: a = !0, props: o, ...s } = n, { level: u, toggle: p } = h("Accordion.Trigger"), { value: m, open: _, disabled: v, triggerId: y, panelId: b } = g("Accordion.Trigger"), x = t((e) => p(m, {
|
|
157
|
+
reason: "trigger",
|
|
158
|
+
event: e
|
|
159
|
+
}));
|
|
160
|
+
return /* @__PURE__ */ c(e, {
|
|
161
|
+
tag: f[(i ?? u) - 1],
|
|
162
|
+
component: "accordion.heading",
|
|
163
|
+
children: /* @__PURE__ */ l(e, {
|
|
164
|
+
tag: "button",
|
|
165
|
+
component: "accordion.trigger",
|
|
166
|
+
...s,
|
|
167
|
+
disabled: v,
|
|
168
|
+
id: y,
|
|
169
|
+
props: {
|
|
170
|
+
type: "button",
|
|
171
|
+
"aria-expanded": _,
|
|
172
|
+
"aria-controls": b,
|
|
173
|
+
[d.TRIGGER_ATTRIBUTE]: "",
|
|
174
|
+
...o,
|
|
175
|
+
onClick: x
|
|
176
|
+
},
|
|
177
|
+
children: [r, a && /* @__PURE__ */ c(e, {
|
|
178
|
+
tag: "span",
|
|
179
|
+
component: "accordion.arrow",
|
|
180
|
+
variant: { open: _ },
|
|
181
|
+
props: { "aria-hidden": !0 }
|
|
182
|
+
})]
|
|
183
|
+
})
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
y.displayName = "Accordion.Trigger";
|
|
187
|
+
function b(t) {
|
|
188
|
+
let { children: n, props: r, ...i } = t, { open: a, triggerId: o, panelId: s } = g("Accordion.Panel");
|
|
189
|
+
return /* @__PURE__ */ c(e, {
|
|
190
|
+
component: "accordion.track",
|
|
191
|
+
variant: { closed: !a },
|
|
192
|
+
children: /* @__PURE__ */ c(e, {
|
|
193
|
+
component: "accordion.clip",
|
|
194
|
+
children: /* @__PURE__ */ c(e, {
|
|
195
|
+
component: "accordion.panel",
|
|
196
|
+
...i,
|
|
197
|
+
id: s,
|
|
198
|
+
props: {
|
|
199
|
+
role: "region",
|
|
200
|
+
"aria-labelledby": o,
|
|
201
|
+
...r
|
|
202
|
+
},
|
|
203
|
+
children: n
|
|
204
|
+
})
|
|
205
|
+
})
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
b.displayName = "Accordion.Panel";
|
|
209
|
+
function x(i) {
|
|
210
|
+
let { children: a, trigger: s, open: u, defaultOpen: d = !1, onOpenChange: f, props: p, ...m } = i, h = r("collapsible"), g = `${h}-trigger`, _ = `${h}-panel`, [v, y] = n({
|
|
211
|
+
value: u,
|
|
212
|
+
defaultValue: d,
|
|
213
|
+
onChange: f
|
|
214
|
+
}), b = t((e) => y((e) => !e, {
|
|
215
|
+
reason: "trigger",
|
|
216
|
+
event: e
|
|
217
|
+
})), x = o(() => ({ props: {
|
|
218
|
+
id: g,
|
|
219
|
+
type: "button",
|
|
220
|
+
"aria-expanded": v,
|
|
221
|
+
"aria-controls": _,
|
|
222
|
+
onClick: b
|
|
223
|
+
} }), [
|
|
224
|
+
g,
|
|
225
|
+
_,
|
|
226
|
+
v,
|
|
227
|
+
b
|
|
228
|
+
]);
|
|
229
|
+
return /* @__PURE__ */ l(e, {
|
|
230
|
+
component: "collapsible",
|
|
231
|
+
...m,
|
|
232
|
+
props: p,
|
|
233
|
+
children: [s(x), /* @__PURE__ */ c(e, {
|
|
234
|
+
component: "collapsible.track",
|
|
235
|
+
variant: { closed: !v },
|
|
236
|
+
children: /* @__PURE__ */ c(e, {
|
|
237
|
+
component: "collapsible.clip",
|
|
238
|
+
children: /* @__PURE__ */ c(e, {
|
|
239
|
+
component: "collapsible.panel",
|
|
240
|
+
id: _,
|
|
241
|
+
children: a
|
|
242
|
+
})
|
|
243
|
+
})
|
|
244
|
+
})]
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
x.displayName = "Collapsible";
|
|
248
|
+
var S = _;
|
|
249
|
+
S.Item = v, S.Trigger = y, S.Panel = b, S.displayName = "Accordion";
|
|
250
|
+
//#endregion
|
|
251
|
+
export { x as Collapsible, S as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./svg.cjs");let t=require("react"),n=require("react/jsx-runtime");function r(t,r){let{viewBox:i=`0 0 24 24`,width:a=`1.5rem`,props:o,...s}=t;return(0,n.jsx)(e.Svg,{ref:r,viewBox:i,width:a,props:{...o,fill:`none`},...s})}var i=(0,t.forwardRef)(r);i.displayName=`BaseSvg`,exports.default=i;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { SvgProps } from './svg';
|
|
2
|
+
type Props = Omit<SvgProps, 'ref'>;
|
|
3
|
+
declare const BaseSvg: import('react').ForwardRefExoticComponent<Props & import('react').RefAttributes<SVGSVGElement>>;
|
|
4
|
+
export default BaseSvg;
|
|
5
|
+
export type BaseSvgProps = React.ComponentProps<typeof BaseSvg>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Svg as e } from "./svg.mjs";
|
|
2
|
+
import { forwardRef as t } from "react";
|
|
3
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/baseSvg.tsx
|
|
5
|
+
function r(t, r) {
|
|
6
|
+
let { viewBox: i = "0 0 24 24", width: a = "1.5rem", props: o, ...s } = t;
|
|
7
|
+
return /* @__PURE__ */ n(e, {
|
|
8
|
+
ref: r,
|
|
9
|
+
viewBox: i,
|
|
10
|
+
width: a,
|
|
11
|
+
props: {
|
|
12
|
+
...o,
|
|
13
|
+
fill: "none"
|
|
14
|
+
},
|
|
15
|
+
...s
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
var i = t(r);
|
|
19
|
+
i.displayName = "BaseSvg";
|
|
20
|
+
//#endregion
|
|
21
|
+
export { i as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../rolldown-runtime.cjs"),t=require("../react-shared.cjs");let n=require("react"),r=require("react/jsx-runtime"),i=require("@box-kite/react");i=e.t(i,1);var a=[`type`,`onClick`];function o(e,n){let o=t.i.buildProps(e,a);return(0,r.jsx)(i.default,{ref:n,tag:`button`,component:`button`,...o})}var s=(0,n.forwardRef)(o);s.displayName=`Button`,exports.default=s;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RefAttributes } from 'react';
|
|
2
|
+
import { BoxProps, BoxTagProps } from '../box';
|
|
3
|
+
import { OmitTagProps } from '../react/boxProps';
|
|
4
|
+
import { ComponentsAndVariants } from '@box-kite/core/types';
|
|
5
|
+
declare const tagProps: readonly ["type", "onClick"];
|
|
6
|
+
type TagPropsType = (typeof tagProps)[number];
|
|
7
|
+
type ButtonProps<TKey extends keyof ComponentsAndVariants> = Omit<BoxProps<'button', TKey>, 'tag' | 'props'>;
|
|
8
|
+
type ButtonTagProps = OmitTagProps<BoxTagProps<'button'>, TagPropsType>;
|
|
9
|
+
type ButtonType = Required<React.ComponentProps<'button'>>['type'];
|
|
10
|
+
interface Props<TKey extends keyof ComponentsAndVariants> extends ButtonProps<TKey> {
|
|
11
|
+
/** Attributes for the `<button>` itself — `disabled`, `aria-label`, `form`, `value`. */
|
|
12
|
+
props?: ButtonTagProps;
|
|
13
|
+
/** `button` unless you say otherwise. Inside a form a `<button>` with no type submits it. */
|
|
14
|
+
type?: ButtonType;
|
|
15
|
+
/** Fires on a click, and on Enter or Space, which the browser turns into one. */
|
|
16
|
+
onClick?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
17
|
+
}
|
|
18
|
+
declare const _default: <TKey extends keyof ComponentsAndVariants = "button">(props: Props<TKey> & RefAttributes<HTMLButtonElement>) => React.ReactNode;
|
|
19
|
+
export default _default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { i as e } from "../react-shared.mjs";
|
|
2
|
+
import { forwardRef as t } from "react";
|
|
3
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
4
|
+
import r from "@box-kite/react";
|
|
5
|
+
//#region src/components/button.tsx
|
|
6
|
+
var i = ["type", "onClick"];
|
|
7
|
+
function a(t, a) {
|
|
8
|
+
let o = e.buildProps(t, i);
|
|
9
|
+
return /* @__PURE__ */ n(r, {
|
|
10
|
+
ref: a,
|
|
11
|
+
tag: "button",
|
|
12
|
+
component: "button",
|
|
13
|
+
...o
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
var o = t(a);
|
|
17
|
+
o.displayName = "Button";
|
|
18
|
+
//#endregion
|
|
19
|
+
export { o as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../rolldown-runtime.cjs"),t=require("../react-shared.cjs"),n=require("./svg.cjs");let r=require("react"),i=require("react/jsx-runtime"),a=require("@box-kite/react");a=e.t(a,1);var o;(function(e){let n=e.VIEW=100,r=e.CENTRE=n/2,i=e.FRACTION_STEP=.005;function a(e){return Math.round(e*100)/100}function o(e){return Math.round(Math.min(Math.max(e,0),1)/i)*i}e.fraction=o;function s(e,t={}){if(e.length===0)return[];let i=t.min??Math.min(...e),o=(t.max??Math.max(...e))-i,s=e=>a(o===0?r:n-(e-i)/o*n);if(e.length===1)return[{x:0,y:s(e[0])},{x:n,y:s(e[0])}];let c=n/(e.length-1);return e.map((e,t)=>({x:a(t*c),y:s(e)}))}e.points=s;function c(e){return e.length===0?``:e.map((e,t)=>`${t===0?`M`:`L`}${e.x} ${e.y}`).join(``)}e.linePath=c;function l(e){if(e.length===0)return``;let t=e[e.length-1];return`${c(e)}L${t.x} ${n}L${e[0].x} ${n}Z`}e.areaPath=l;function u(e,t={},r=.25){if(e.length===0)return``;let i=n/e.length,o=a(i*(1-r)),c=a((i-o)/2);return s(e,t).map((e,t)=>{let r=Math.min(e.y,n-1);return`M${a(t*i+c)} ${r}h${o}v${a(n-r)}h${-o}Z`}).join(``)}e.barsPath=u;function d(e){return a(r-e/2)}e.radius=d;function f(e){return a(2*Math.PI*e)}e.circumference=f;function p(e,t){return{strokeDasharray:a(e),strokeDashoffset:a(e*(1-o(t)))}}e.dash=p;function m(e,t){let n=(t-90)*Math.PI/180;return{x:a(r+e*Math.cos(n)),y:a(r+e*Math.sin(n))}}function h(e,t){return a(f(e)*(Math.min(Math.abs(t),360)/360))}e.arcLength=h;function g(e,t,n){if(Math.abs(n)>=360){let n=m(e,t),r=m(e,t+180);return`M${n.x} ${n.y}A${e} ${e} 0 0 1 ${r.x} ${r.y}A${e} ${e} 0 0 1 ${n.x} ${n.y}`}let r=m(e,t),i=m(e,t+n),a=+(Math.abs(n)>180),o=n<0?0:1;return`M${r.x} ${r.y}A${e} ${e} 0 ${a} ${o} ${i.x} ${i.y}`}e.arcPath=g;function _(e,t){let n=e.reduce((e,t)=>e+Math.max(t,0),0);if(n<=0)return[];let r=0;return e.map((e,i)=>{let s=o(Math.max(e,0)/n),c=a(t*s),l=a(r*360);return r+=s,{strokeDasharray:`${c} ${a(t-c)}`,rotate:l,value:e,index:i}})}e.donutSegments=_;let v=e.PALETTE=t.n;e.DARK_PALETTE=t.t,e.paletteVariables=t.r;function y(e,t=v.length){return(Array.isArray(e)?e.map((e,n)=>[e,`var(--chart-${n%t+1})`]):Object.entries(e)).reduce((e,[t,n])=>(e[`color-${t}`]=n,e),{})}e.seriesVariables=y})(o||={});var s=o,c=`0 0 ${s.VIEW} ${s.VIEW}`,l=s.PALETTE;function u(e,t){let{data:r,variant:a=`line`,min:o,max:l,children:u,...d}=e,f={min:o,max:l},p=s.points(r,f);return(0,i.jsxs)(n.Svg,{viewBox:c,component:`sparkline`,preserveAspectRatio:`none`,width:`100%`,height:`1.5rem`,ref:t,...d,children:[a===`bar`?(0,i.jsx)(n.Path,{component:`sparkline.bar`,d:s.barsPath(r,f)}):(0,i.jsxs)(i.Fragment,{children:[a===`area`&&(0,i.jsx)(n.Path,{component:`sparkline.area`,d:s.areaPath(p)}),(0,i.jsx)(n.Path,{component:`sparkline.line`,d:s.linePath(p)})]}),u]})}var d=(0,r.forwardRef)(u);d.displayName=`Sparkline`;function f(e,t){let{value:r,thickness:a=10,trackOpacity:o,children:l,...u}=e,d=s.radius(a),f=s.circumference(d);return(0,i.jsxs)(n.Svg,{viewBox:c,component:`progressRing`,width:`3rem`,height:`3rem`,strokeWidth:a,ref:t,...u,children:[(0,i.jsx)(n.Circle,{component:`progressRing.track`,cx:s.CENTRE,cy:s.CENTRE,r:d,strokeOpacity:o}),(0,i.jsx)(n.Circle,{component:`progressRing.arc`,cx:s.CENTRE,cy:s.CENTRE,r:d,transform:`rotate(-90 ${s.CENTRE} ${s.CENTRE})`,...s.dash(f,r)}),l]})}var p=(0,r.forwardRef)(f);p.displayName=`ProgressRing`;function m(e,t){let{value:r,thickness:a=10,trackOpacity:o,sweep:l=270,start:u=225,children:d,...f}=e,p=s.radius(a),m=s.arcLength(p,l),h=s.arcPath(p,u,l);return(0,i.jsxs)(n.Svg,{viewBox:c,component:`gauge`,width:`4rem`,height:`4rem`,strokeWidth:a,ref:t,...f,children:[(0,i.jsx)(n.Path,{component:`gauge.track`,d:h,strokeOpacity:o}),(0,i.jsx)(n.Path,{component:`gauge.arc`,d:h,...s.dash(m,r)}),d]})}var h=(0,r.forwardRef)(m);h.displayName=`Gauge`;function g(e,t){let{data:r,colors:a=l,thickness:o=20,children:u,...d}=e,f=s.radius(o),p=s.circumference(f);return(0,i.jsxs)(n.Svg,{viewBox:c,component:`miniDonut`,width:`3rem`,height:`3rem`,strokeWidth:o,ref:t,...d,children:[s.donutSegments(r,p).map(e=>(0,i.jsx)(n.Circle,{component:`miniDonut.segment`,cx:s.CENTRE,cy:s.CENTRE,r:f,stroke:a[e.index%a.length],strokeDasharray:e.strokeDasharray,transform:`rotate(${e.rotate-90} ${s.CENTRE} ${s.CENTRE})`},e.index)),u]})}var _=(0,r.forwardRef)(g);_.displayName=`MiniDonut`;function v(e,t){let{series:n,vars:r,...o}=e,c={...n?s.seriesVariables(n):{},...r};return(0,i.jsx)(a.default,{ref:t,component:`chartContainer`,vars:c,...o})}var y=(0,r.forwardRef)(v);y.displayName=`ChartContainer`;var b=y;exports.ChartContainer=b,exports.Gauge=h,exports.MiniDonut=_,exports.ProgressRing=p,exports.Sparkline=d;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { RefAttributes } from 'react';
|
|
2
|
+
import { BoxProps } from '../box';
|
|
3
|
+
import { ExtractElementFromTag } from '../react/reactTypes';
|
|
4
|
+
import { BoxStyleProps, ComponentsAndVariants } from '@box-kite/core/types';
|
|
5
|
+
import { SvgProps } from './svg';
|
|
6
|
+
/**
|
|
7
|
+
* The chart micro-primitives: the small drawings a dashboard is made of, as Boxes. Deliberately not a chart
|
|
8
|
+
* *library* — no axes, no legends, no data transformations; what you get instead is that every prop,
|
|
9
|
+
* breakpoint and theme works. Two rules run through all four: **shape is an attribute, paint is a class**
|
|
10
|
+
* (so ten thousand rows share one rule), and a ring's fill is a **rounded fraction**, because a dash length
|
|
11
|
+
* lands in a class name and still has to transition. Naming is `Svg`'s: no `label` means `aria-hidden`.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* The props every primitive shares: an `Svg`'s, minus the `viewBox` and `variant` they own and with
|
|
15
|
+
* `children` narrowed to SVG content — a chart's children are a label in a ring, never a render prop.
|
|
16
|
+
*/
|
|
17
|
+
type ChartProps = Omit<SvgProps, 'viewBox' | 'variant' | 'children'> & {
|
|
18
|
+
children?: React.ReactNode;
|
|
19
|
+
};
|
|
20
|
+
/** A paint value: a colour token, or the `url(#…)`/`var(--…)` a gradient or a theme provides. */
|
|
21
|
+
type Paint = NonNullable<BoxStyleProps['fill']>;
|
|
22
|
+
export interface SparklineProps extends ChartProps {
|
|
23
|
+
/** The numbers to draw, oldest first. */
|
|
24
|
+
data: readonly number[];
|
|
25
|
+
/** `line` (default), `area` — the line with the space beneath it filled — or `bar`. */
|
|
26
|
+
variant?: 'line' | 'area' | 'bar';
|
|
27
|
+
/**
|
|
28
|
+
* Fix the ends of the value axis. Without them the line uses its own lowest and highest value, so
|
|
29
|
+
* every row of a table is scaled to itself; with them a column of sparklines is comparable.
|
|
30
|
+
*/
|
|
31
|
+
min?: number;
|
|
32
|
+
/** The top of the value axis — see `min`, which it is written beside. */
|
|
33
|
+
max?: number;
|
|
34
|
+
}
|
|
35
|
+
/** A line, area or bar chart small enough to sit inside a line of text or a table cell. */
|
|
36
|
+
export declare const Sparkline: import('react').ForwardRefExoticComponent<Omit<SparklineProps, "ref"> & RefAttributes<SVGSVGElement>>;
|
|
37
|
+
/** What a ring and a dial have in common: one value, and how thick the arc drawing it is. */
|
|
38
|
+
export interface ProgressRingProps extends ChartProps {
|
|
39
|
+
/** How full the arc is, from 0 to 1. Rounded to half a percent — see `ChartUtils.FRACTION_STEP`. */
|
|
40
|
+
value: number;
|
|
41
|
+
/** The width of the ring in view units, out of the 100 the box is wide. */
|
|
42
|
+
thickness?: number;
|
|
43
|
+
/** The unfilled part of the ring, as the same colour faded — so the track follows the theme too. Default `0.2`, from the style node. */
|
|
44
|
+
trackOpacity?: NonNullable<BoxStyleProps['strokeOpacity']>;
|
|
45
|
+
}
|
|
46
|
+
/** A full circle filled to `value`, starting at twelve o'clock — the percentage-complete ring. */
|
|
47
|
+
export declare const ProgressRing: import('react').ForwardRefExoticComponent<Omit<ProgressRingProps, "ref"> & RefAttributes<SVGSVGElement>>;
|
|
48
|
+
export interface GaugeProps extends ProgressRingProps {
|
|
49
|
+
/** How far round the dial goes, in degrees. Three quarters of a turn by default. */
|
|
50
|
+
sweep?: number;
|
|
51
|
+
/** Where it starts, in degrees clockwise from twelve o'clock. Bottom left by default. */
|
|
52
|
+
start?: number;
|
|
53
|
+
}
|
|
54
|
+
/** A dial: an arc of `sweep` degrees filled to `value`. A gauge with `sweep={360}` is a ring. */
|
|
55
|
+
export declare const Gauge: import('react').ForwardRefExoticComponent<Omit<GaugeProps, "ref"> & RefAttributes<SVGSVGElement>>;
|
|
56
|
+
export interface MiniDonutProps extends ChartProps {
|
|
57
|
+
/** One value per segment. Each is drawn as its share of the whole, so they need no total. */
|
|
58
|
+
data: readonly number[];
|
|
59
|
+
/** One colour per segment, cycled if there are fewer than there are values. */
|
|
60
|
+
colors?: readonly Paint[];
|
|
61
|
+
/** The width of the ring in view units, out of the 100 the box is wide. */
|
|
62
|
+
thickness?: number;
|
|
63
|
+
}
|
|
64
|
+
/** A ring divided into one segment per value — a pie chart with its middle left for a number. */
|
|
65
|
+
export declare const MiniDonut: import('react').ForwardRefExoticComponent<Omit<MiniDonutProps, "ref"> & RefAttributes<SVGSVGElement>>;
|
|
66
|
+
/**
|
|
67
|
+
* The series a `<ChartContainer>` draws: `series={['revenue', 'cost']}` takes the palette in order,
|
|
68
|
+
* `series={{ revenue: 'emerald-600' }}` names its own paint. A name becomes part of a custom-property
|
|
69
|
+
* name, so it has to be a CSS identifier — a dot-path `dataKey` is skipped rather than taking the rest.
|
|
70
|
+
*/
|
|
71
|
+
export type ChartSeries = readonly string[] | Readonly<Record<string, Paint>>;
|
|
72
|
+
export interface ChartContainerProps<TTag extends keyof React.JSX.IntrinsicElements = 'div', TKey extends keyof ComponentsAndVariants = never> extends BoxProps<TTag, TKey> {
|
|
73
|
+
/** The series drawn inside, and what colour each of them is. */
|
|
74
|
+
series?: ChartSeries;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The theming bridge: a Box that declares the variables a chart reads, so the chart itself names no
|
|
78
|
+
* colour. `vars` is an ordinary prop, so the palette is themed and responsive like everything else and
|
|
79
|
+
* lands in a *class* — two containers with the same series share one rule, and it renders on a server.
|
|
80
|
+
* The names are the ecosystem's, so a chart copied from shadcn works unchanged. It adds no ARIA.
|
|
81
|
+
*/
|
|
82
|
+
export declare const ChartContainer: <TTag extends keyof React.JSX.IntrinsicElements = "div", TKey extends keyof ComponentsAndVariants = never>(props: ChartContainerProps<TTag, TKey> & RefAttributes<ExtractElementFromTag<TTag>>) => React.ReactNode;
|
|
83
|
+
export {};
|