@capra/core 1.8.2 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +264 -23
- package/dist/index.d.cts +119 -17
- package/dist/index.d.mts +119 -17
- package/dist/index.mjs +265 -26
- package/dist/style.css +186 -25
- package/docs/core-alert--usage.md +2 -0
- package/docs/core-anchor--usage.md +2 -0
- package/docs/core-autocompletefield--usage.md +2 -0
- package/docs/core-badge--usage.md +2 -0
- package/docs/core-breadcrumbs--usage.md +2 -0
- package/docs/core-button--usage.md +2 -0
- package/docs/core-buttonlink--usage.md +2 -0
- package/docs/core-checkbox--usage.md +2 -0
- package/docs/core-collapse--usage.md +2 -0
- package/docs/core-datepickerfield--usage.md +2 -0
- package/docs/core-daterangepickerfield--usage.md +2 -0
- package/docs/core-divider--usage.md +2 -0
- package/docs/core-emptystate--usage.md +2 -0
- package/docs/core-helpertext--usage.md +2 -0
- package/docs/core-iconbutton--usage.md +2 -0
- package/docs/core-inputrow--usage.md +2 -0
- package/docs/core-label--usage.md +2 -0
- package/docs/core-link--usage.md +2 -0
- package/docs/core-listitem--usage.md +2 -0
- package/docs/core-menu--usage.md +2 -0
- package/docs/core-modal--usage.md +2 -0
- package/docs/core-pagination--usage.md +2 -0
- package/docs/core-pill--usage.md +2 -0
- package/docs/core-radio--usage.md +2 -0
- package/docs/core-radiogroup--usage.md +2 -0
- package/docs/core-radiotile--usage.md +2 -0
- package/docs/core-ribbon--usage.md +2 -0
- package/docs/core-skeleton--usage.md +1 -2
- package/docs/core-skeletongroup--usage.md +0 -1
- package/docs/core-spinner--usage.md +2 -0
- package/docs/core-switch--usage.md +2 -0
- package/docs/core-tabnav--usage.md +2 -0
- package/docs/core-tag--usage.md +2 -0
- package/docs/core-text--usage.md +2 -0
- package/docs/core-textarea--usage.md +2 -0
- package/docs/core-textinput--usage.md +2 -0
- package/docs/core-tooltip--usage.md +2 -0
- package/docs/core-topnav--usage.md +2 -0
- package/docs/core-tree--design.md +31 -0
- package/docs/core-tree--usage.md +102 -0
- package/docs/core-verticalnavigation--usage.md +2 -0
- package/docs/history-changelogs-capra-core--docs.md +23 -0
- package/docs/index.md +2 -0
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import * as React$2 from "react";
|
|
2
2
|
import React$1, { HTMLAttributeAnchorTarget, HTMLAttributeReferrerPolicy } from "react";
|
|
3
3
|
import { SvgIcon } from "@capra/icons";
|
|
4
|
-
import { BreadcrumbProps as BreadcrumbProps$1, BreadcrumbsProps as BreadcrumbsProps$1, ButtonProps as ButtonProps$1, ComboBoxRenderProps, DatePickerProps, DateRangePickerProps, DateValue, DisclosureProps, Focusable, LinkProps as LinkProps$1, ListBoxItemProps, PopoverProps as PopoverProps$1, PressEvent, RouterProvider } from "react-aria-components";
|
|
4
|
+
import { BreadcrumbProps as BreadcrumbProps$1, BreadcrumbsProps as BreadcrumbsProps$1, ButtonProps as ButtonProps$1, ComboBoxRenderProps, DatePickerProps, DateRangePickerProps, DateValue, DisclosureProps, Focusable, Key, LinkProps as LinkProps$1, ListBoxItemProps, PopoverProps as PopoverProps$1, PressEvent, RouterProvider } from "react-aria-components";
|
|
5
5
|
import { SvgLogo } from "@capra/icons/logos";
|
|
6
6
|
//#region src/utils/stylingOverride.d.ts
|
|
7
7
|
interface StylingOverrideProps {
|
|
8
|
+
/** Use `FORCE__className` instead. */
|
|
9
|
+
className?: never;
|
|
10
|
+
/** Inline styles are not supported; use component props or `FORCE__className`. */
|
|
11
|
+
style?: never;
|
|
8
12
|
/**
|
|
9
13
|
* 🚨 This prop is meant to be an escape hatch. 🚨
|
|
10
14
|
*
|
|
@@ -208,7 +212,7 @@ type TextProps<As extends React$2.ElementType> = {
|
|
|
208
212
|
* The underlying element rendered by the component. Defaults to `span`.
|
|
209
213
|
*/
|
|
210
214
|
as?: As;
|
|
211
|
-
} & StylingOverrideProps &
|
|
215
|
+
} & StylingOverrideProps & React$2.ComponentPropsWithoutRef<As>;
|
|
212
216
|
/**
|
|
213
217
|
* Component for displaying text. The visual display can be controlled via
|
|
214
218
|
* `variant`. The underlying HTML element can be controlled via the `as` prop,
|
|
@@ -228,7 +232,7 @@ declare const Text: <As extends React$2.ElementType = "span">(props: {
|
|
|
228
232
|
* The underlying element rendered by the component. Defaults to `span`.
|
|
229
233
|
*/
|
|
230
234
|
as?: As | undefined;
|
|
231
|
-
} & StylingOverrideProps &
|
|
235
|
+
} & StylingOverrideProps & React$2.PropsWithoutRef<React$2.ComponentProps<As>> & React$2.RefAttributes<unknown>) => React$2.ReactElement;
|
|
232
236
|
//#endregion
|
|
233
237
|
//#region src/components/Card/Card.d.ts
|
|
234
238
|
/**
|
|
@@ -345,7 +349,7 @@ type ListItemProps<As extends React$2.ElementType> = {
|
|
|
345
349
|
declare function ListItem<As extends React$2.ElementType = 'li'>({ as: asComponent, children, FORCE__className: classNameOverride, ...props }: ListItemProps<As>): React$2.JSX.Element;
|
|
346
350
|
declare namespace ListItem {
|
|
347
351
|
export { Content };
|
|
348
|
-
export { Label };
|
|
352
|
+
export { Label$1 as Label };
|
|
349
353
|
export { Description };
|
|
350
354
|
export { Suffix };
|
|
351
355
|
export { Spacer };
|
|
@@ -358,7 +362,7 @@ declare const Content: ({ children, FORCE__className }: React$2.PropsWithChildre
|
|
|
358
362
|
type ListItemLabelProps = React$2.PropsWithChildren & {
|
|
359
363
|
id?: string;
|
|
360
364
|
};
|
|
361
|
-
declare const Label: ({ children, id }: ListItemLabelProps) => React$2.JSX.Element;
|
|
365
|
+
declare const Label$1: ({ children, id }: ListItemLabelProps) => React$2.JSX.Element;
|
|
362
366
|
declare const Suffix: ({ children }: React$2.PropsWithChildren) => React$2.JSX.Element;
|
|
363
367
|
declare const Description: ({ children }: React$2.PropsWithChildren) => React$2.JSX.Element;
|
|
364
368
|
declare const Spacer: () => React$2.JSX.Element;
|
|
@@ -450,11 +454,11 @@ type ChildrenLabel = {
|
|
|
450
454
|
/**
|
|
451
455
|
* Require either 'aria-label', 'aria-labelledby', or 'children' for accessibility
|
|
452
456
|
*/
|
|
453
|
-
type LabelProps = AccessibleLabelProps | ChildrenLabel;
|
|
457
|
+
type LabelProps$1 = AccessibleLabelProps | ChildrenLabel;
|
|
454
458
|
type RadioProps = {
|
|
455
459
|
/** The value of the radio button. */
|
|
456
460
|
value: string | null;
|
|
457
|
-
} & Partial<RadioGroupContextValue> & LabelProps & StylingOverrideProps & Omit<React$2.ComponentPropsWithoutRef<'input'>, 'className' | 'type'>;
|
|
461
|
+
} & Partial<RadioGroupContextValue> & LabelProps$1 & StylingOverrideProps & Omit<React$2.ComponentPropsWithoutRef<'input'>, 'className' | 'type'>;
|
|
458
462
|
/**
|
|
459
463
|
* A presentational radio button component. You will typically use this component within a RadioGroup component.
|
|
460
464
|
*/
|
|
@@ -1324,7 +1328,7 @@ declare const Link: <As extends React$2.ElementType = "a">(props: {
|
|
|
1324
1328
|
} & RoutedLinkProps & StylingOverrideProps & Omit<React$2.PropsWithoutRef<React$2.ComponentProps<As>>, "className"> & React$2.RefAttributes<unknown>) => React$2.ReactElement;
|
|
1325
1329
|
//#endregion
|
|
1326
1330
|
//#region src/components/VerticalNavigation/VerticalNavigation.d.ts
|
|
1327
|
-
|
|
1331
|
+
type VerticalNavigationProps = React$2.HTMLAttributes<HTMLElement> & StylingOverrideProps & {
|
|
1328
1332
|
/**
|
|
1329
1333
|
* Controlled collapsed state.
|
|
1330
1334
|
*/
|
|
@@ -1338,7 +1342,7 @@ interface VerticalNavigationProps extends React$2.HTMLAttributes<HTMLElement>, S
|
|
|
1338
1342
|
* @default false
|
|
1339
1343
|
*/
|
|
1340
1344
|
defaultCollapsed?: boolean;
|
|
1341
|
-
}
|
|
1345
|
+
};
|
|
1342
1346
|
type VerticalNavigationItemBaseProps<As extends React$2.ElementType> = Omit<React$2.ComponentPropsWithoutRef<As>, 'className' | 'as' | 'href' | 'isActive' | 'isDisabled' | 'rightElement' | 'label'> & StylingOverrideProps & {
|
|
1343
1347
|
/**
|
|
1344
1348
|
* The component to use for the item. Default is either 'a' or 'button' based on the presence of the href prop.
|
|
@@ -1391,19 +1395,19 @@ type VerticalNavigationItemProps<As extends React$2.ElementType> = VerticalNavig
|
|
|
1391
1395
|
* Supports icons, active state, and 'subItem' variant for indentation.
|
|
1392
1396
|
*/
|
|
1393
1397
|
declare const Item: <As extends React$2.ElementType>({ as, icon, label, isActive, href, FORCE__className, isDisabled, onClick, variant, rightElement, ...props }: VerticalNavigationItemProps<As>) => React$2.JSX.Element;
|
|
1394
|
-
|
|
1398
|
+
type VerticalNavigationCollapseProps = React$2.ButtonHTMLAttributes<HTMLButtonElement> & StylingOverrideProps;
|
|
1395
1399
|
/**
|
|
1396
1400
|
* A toggle button to collapse/expand the navigation.
|
|
1397
1401
|
* Should be placed within VerticalNavigation to control its state.
|
|
1398
1402
|
*/
|
|
1399
1403
|
declare const Collapse$1: ({ FORCE__className, onClick, ...props }: VerticalNavigationCollapseProps) => React$2.JSX.Element;
|
|
1400
|
-
|
|
1404
|
+
type VerticalNavigationItemListProps = React$2.HTMLAttributes<HTMLUListElement> & StylingOverrideProps;
|
|
1401
1405
|
/**
|
|
1402
1406
|
* Container for the primary list of navigation items.
|
|
1403
1407
|
* Renders an unordered list with consistent spacing and layout.
|
|
1404
1408
|
*/
|
|
1405
1409
|
declare const ItemList: ({ children, FORCE__className, ...props }: VerticalNavigationItemListProps) => React$2.JSX.Element;
|
|
1406
|
-
|
|
1410
|
+
type VerticalNavigationFooterProps = React$2.HTMLAttributes<HTMLUListElement> & StylingOverrideProps;
|
|
1407
1411
|
/**
|
|
1408
1412
|
* Secondary container for footer navigation actions such as settings or help.
|
|
1409
1413
|
*/
|
|
@@ -1588,7 +1592,7 @@ type SkeletonProps = {
|
|
|
1588
1592
|
* (`title={false}` and `paragraph={false}`) children render inside the placeholder while loading.
|
|
1589
1593
|
*/
|
|
1590
1594
|
children?: React$2.ReactNode;
|
|
1591
|
-
} & StylingOverrideProps & Omit<React$2.HTMLAttributes<HTMLSpanElement>, 'children' | 'title' | 'paragraph'>;
|
|
1595
|
+
} & Omit<StylingOverrideProps, 'style'> & Omit<React$2.HTMLAttributes<HTMLSpanElement>, 'children' | 'title' | 'paragraph' | 'className'>;
|
|
1592
1596
|
declare function Skeleton(props: SkeletonProps): React$2.JSX.Element | null;
|
|
1593
1597
|
declare namespace Skeleton {
|
|
1594
1598
|
var displayName: string;
|
|
@@ -1610,7 +1614,7 @@ type SkeletonElementProps = {
|
|
|
1610
1614
|
size?: SkeletonSize;
|
|
1611
1615
|
/** Show animation effect. @default false */
|
|
1612
1616
|
active?: boolean;
|
|
1613
|
-
} & StylingOverrideProps & Omit<React$2.HTMLAttributes<HTMLSpanElement>, 'children'>;
|
|
1617
|
+
} & Omit<StylingOverrideProps, 'style'> & Omit<React$2.HTMLAttributes<HTMLSpanElement>, 'children' | 'className' | 'style'>;
|
|
1614
1618
|
type SkeletonGroupButtonProps = SkeletonElementProps & {
|
|
1615
1619
|
block?: boolean;
|
|
1616
1620
|
shape?: 'circle' | 'round' | 'square' | 'default';
|
|
@@ -1810,12 +1814,12 @@ type MenuSectionProps = StylingOverrideProps & Omit<React$2.HTMLAttributes<HTMLD
|
|
|
1810
1814
|
*/
|
|
1811
1815
|
children?: React$2.ReactNode;
|
|
1812
1816
|
};
|
|
1813
|
-
|
|
1817
|
+
type MenuListProps = StylingOverrideProps & React$2.HTMLAttributes<HTMLDivElement> & {
|
|
1814
1818
|
/**
|
|
1815
1819
|
* Menu content. Use Menu.Item, Menu.Section, Menu.Header, Menu.Divider.
|
|
1816
1820
|
*/
|
|
1817
1821
|
children?: React$2.ReactNode;
|
|
1818
|
-
}
|
|
1822
|
+
};
|
|
1819
1823
|
interface MenuSubmenuProps extends StylingOverrideProps {
|
|
1820
1824
|
/**
|
|
1821
1825
|
* Label for the parent row (trailing chevron indicates a nested panel).
|
|
@@ -2133,4 +2137,102 @@ type CustomTooltipTriggerProps = {
|
|
|
2133
2137
|
*/
|
|
2134
2138
|
declare const CustomTooltipTrigger: React$2.ForwardRefExoticComponent<CustomTooltipTriggerProps & React$2.RefAttributes<HTMLElement>>;
|
|
2135
2139
|
//#endregion
|
|
2136
|
-
|
|
2140
|
+
//#region src/components/Tree/Tree.d.ts
|
|
2141
|
+
interface TreeItemType {
|
|
2142
|
+
/**
|
|
2143
|
+
* The unique key of the tree item.
|
|
2144
|
+
*/
|
|
2145
|
+
key: Key;
|
|
2146
|
+
/**
|
|
2147
|
+
* The label of the tree item.
|
|
2148
|
+
*/
|
|
2149
|
+
label: React$2.ReactNode;
|
|
2150
|
+
/**
|
|
2151
|
+
* The children of the tree item.
|
|
2152
|
+
*/
|
|
2153
|
+
children?: TreeItemType[];
|
|
2154
|
+
/**
|
|
2155
|
+
* Whether the tree item is disabled.
|
|
2156
|
+
*/
|
|
2157
|
+
isDisabled?: boolean;
|
|
2158
|
+
/**
|
|
2159
|
+
* The suffix of the tree item.
|
|
2160
|
+
*/
|
|
2161
|
+
suffix?: React$2.ReactNode;
|
|
2162
|
+
/**
|
|
2163
|
+
* The trailing slot of the tree item.
|
|
2164
|
+
*/
|
|
2165
|
+
trailingSlot?: React$2.ReactNode;
|
|
2166
|
+
}
|
|
2167
|
+
type TreeProps = StylingOverrideProps & {
|
|
2168
|
+
/**
|
|
2169
|
+
* Defines a string value that labels the current element.
|
|
2170
|
+
*/
|
|
2171
|
+
'aria-label'?: string;
|
|
2172
|
+
/**
|
|
2173
|
+
* Identifies the element (or elements) that labels the current element.
|
|
2174
|
+
*/
|
|
2175
|
+
'aria-labelledby'?: string;
|
|
2176
|
+
/**
|
|
2177
|
+
* Items to render in the tree.
|
|
2178
|
+
*/
|
|
2179
|
+
items: TreeItemType[];
|
|
2180
|
+
/**
|
|
2181
|
+
* Handler that is called when a user performs an action on an item.
|
|
2182
|
+
*/
|
|
2183
|
+
onAction?: (key: Key) => void;
|
|
2184
|
+
/**
|
|
2185
|
+
* The initial expanded keys when in uncontrolled mode.
|
|
2186
|
+
*/
|
|
2187
|
+
defaultExpandedKeys?: Iterable<Key>;
|
|
2188
|
+
/**
|
|
2189
|
+
* The initial selected keys when in uncontrolled mode.
|
|
2190
|
+
*/
|
|
2191
|
+
defaultSelectedKeys?: Iterable<Key>;
|
|
2192
|
+
/**
|
|
2193
|
+
* The currently expanded keys when in controlled mode.
|
|
2194
|
+
*/
|
|
2195
|
+
expandedKeys?: Iterable<Key>;
|
|
2196
|
+
/**
|
|
2197
|
+
* Handler that is called when the expanded keys change.
|
|
2198
|
+
*/
|
|
2199
|
+
onExpandedChange?: (keys: Set<Key>) => void;
|
|
2200
|
+
/**
|
|
2201
|
+
* Callback that is fired when the selection changes.
|
|
2202
|
+
*/
|
|
2203
|
+
onSelectionChange?: (keys: Set<Key>) => void;
|
|
2204
|
+
/**
|
|
2205
|
+
* The currently selected keys when in controlled mode.
|
|
2206
|
+
*/
|
|
2207
|
+
selectedKeys?: Iterable<Key>;
|
|
2208
|
+
/**
|
|
2209
|
+
* The selection mode of the tree.
|
|
2210
|
+
* @default 'multiple'
|
|
2211
|
+
*/
|
|
2212
|
+
selectionMode?: 'none' | 'multiple';
|
|
2213
|
+
};
|
|
2214
|
+
/**
|
|
2215
|
+
* A hierarchical tree with cascading multi-select and Capra ListItem row layout.
|
|
2216
|
+
*/
|
|
2217
|
+
declare function Tree({ FORCE__className: classNameOverride, items, selectionMode, defaultSelectedKeys, selectedKeys, onSelectionChange, expandedKeys, defaultExpandedKeys, ...props }: TreeProps): React$2.JSX.Element;
|
|
2218
|
+
//#endregion
|
|
2219
|
+
//#region src/components/input-helpers/Label.d.ts
|
|
2220
|
+
type LabelProps = {
|
|
2221
|
+
/** Text to display in the label. */
|
|
2222
|
+
children?: string;
|
|
2223
|
+
/** Whether the field the label is labeling is required (shows asterisk after label). */
|
|
2224
|
+
required?: boolean;
|
|
2225
|
+
/** Content after the label text. */
|
|
2226
|
+
trailingSlot?: React$2.ReactNode;
|
|
2227
|
+
} & StylingOverrideProps & Omit<React$2.ComponentPropsWithoutRef<'label'>, 'className' | 'style'>;
|
|
2228
|
+
/** Label text and optional required indicator for form fields, aligned with Capra field layouts. */
|
|
2229
|
+
declare const Label: React$2.ForwardRefExoticComponent<{
|
|
2230
|
+
/** Text to display in the label. */
|
|
2231
|
+
children?: string;
|
|
2232
|
+
/** Whether the field the label is labeling is required (shows asterisk after label). */
|
|
2233
|
+
required?: boolean;
|
|
2234
|
+
/** Content after the label text. */
|
|
2235
|
+
trailingSlot?: React$2.ReactNode;
|
|
2236
|
+
} & StylingOverrideProps & Omit<Omit<React$2.DetailedHTMLProps<React$2.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "ref">, "className" | "style"> & React$2.RefAttributes<HTMLLabelElement>>;
|
|
2237
|
+
//#endregion
|
|
2238
|
+
export { Alert, type AlertProps, Anchor, type AnchorProps, AutocompleteField, type AutocompleteFieldProps, Badge, BadgeLayout, type BadgeProps, Breadcrumb, type BreadcrumbProps, Breadcrumbs, type BreadcrumbsProps, Button, ButtonLink, type ButtonLinkProps, type ButtonProps, Card, Checkbox, type CheckboxProps, Collapse, type CollapseProps, CustomTooltipTrigger, type CustomTooltipTriggerProps, DatePickerField, type DatePickerFieldProps, DateRangePickerField, type DateRangePickerFieldPlaceholder, type DateRangePickerFieldProps, Divider, type DividerProps, type DividerType, Drawer, type DrawerPlacement, type DrawerProps, EmptyState, type EmptyStateProps, IconButton, type IconButtonProps, InputRow, type InputRowAddonProps, type InputRowProps, Label, type LabelProps, Link, type LinkProps, ListItem, type ListItemProps, Menu, type MenuDividerProps, type MenuHeaderProps, type MenuItemProps, type MenuListProps, type MenuPanelPadding, type MenuProps, type MenuSectionProps, type MenuSubmenuProps, Modal, type ModalProps, NumberField, type NumberFieldProps, Pagination, type PaginationProps, PasswordField, type PasswordFieldProps, Pill, type PillProps, Popover, type PopoverProps, Radio, RadioGroup, type RadioGroupProps, type RadioProps, RadioTile, type RadioTileProps, Ribbon, type RibbonProps, type RoutedLinkProps, RouterProvider, SKELETON_SIZE, SKELETON_SIZE_TOKENS, Skeleton, type SkeletonElementProps, SkeletonGroup, type SkeletonGroupButtonProps, type SkeletonGroupInputProps, type SkeletonGroupNodeProps, type SkeletonParagraphProps, type SkeletonProps, type SkeletonSize, type SkeletonTitleProps, Spinner, type SpinnerProps, type StylingOverrideProps, Switch, type SwitchProps, TabNav, type TabNavItemType, type TabNavItemVariant, type TabNavPlacement, type TabNavProps, type TabNavSubItemType, Tag, type TagColor, type TagProps, Text, TextArea, type TextAreaAutoSize, type TextAreaProps, TextField, type TextFieldProps, type TextProps, Toast, type ToastOptions, type ToastPosition, type ToastType, Tooltip, type TooltipProps, TopNav, type TopNavCenterProps, type TopNavEndProps, type TopNavProps, type TopNavStartProps, Tree, type TreeItemType, type TreeProps, VerticalNavigation, type VerticalNavigationCollapseProps, type VerticalNavigationFooterProps, type VerticalNavigationItemListProps, type VerticalNavigationItemProps, type VerticalNavigationProps, VisuallyHidden, type VisuallyHiddenProps, submenuPanelClassName, tagColors };
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React$1 from "react";
|
|
2
2
|
import React, { Suspense, useCallback, useState } from "react";
|
|
3
|
-
import { AnglesLeft, AnglesRight, ArrowUpRightFromSquare, AttentionOutlined, AttentionSolid, CalendarNextOutlined, CalendarOutlined, CalendarPrevOutlined, ChevronDown, ChevronLeft, ChevronRight, ChevronUp, CircleXmark, CloseOutlined, DragGrip, Exclamation, EyeInvisibleOutlined, EyeOutlined, InfoOutlined, InfoSolid, Loading, SuccessOutlined, SuccessSolid, SwapRightOutlined, WarningOutlined, WarningSolid } from "@capra/icons";
|
|
4
|
-
import { Breadcrumb as Breadcrumb$1, Breadcrumbs as Breadcrumbs$1, Button as Button$1, ButtonContext, Calendar, CalendarCell, CalendarGrid, CalendarGridBody, CalendarGridHeader, CalendarHeaderCell, ComboBox, DateInput, DatePicker, DatePickerStateContext, DateRangePicker, DateRangePickerStateContext, DateSegment, Dialog, DialogTrigger, Disclosure, DisclosurePanel, Focusable, Group, Header, Heading, HeadingContext, Input, InputContext, LabelContext, Link as Link$1, ListBox, ListBoxItem, Menu as Menu$1, MenuItem, MenuSection, MenuTrigger, Modal as Modal$1, ModalOverlay, NumberField as NumberField$1, OverlayArrow, OverlayTriggerStateContext, Popover as Popover$1, Pressable, RangeCalendar, RangeCalendarStateContext, RouterProvider, Separator, SubmenuTrigger, Text as Text$1, TextArea as TextArea$1, TextContext, TextField as TextField$1, Tooltip as Tooltip$1, TooltipTrigger, composeRenderProps, useContextProps, useSlottedContext } from "react-aria-components";
|
|
3
|
+
import { AnglesLeft, AnglesRight, ArrowUpRightFromSquare, AttentionOutlined, AttentionSolid, CalendarNextOutlined, CalendarOutlined, CalendarPrevOutlined, CaretRight, ChevronDown, ChevronLeft, ChevronRight, ChevronUp, CircleXmark, CloseOutlined, DragGrip, Exclamation, EyeInvisibleOutlined, EyeOutlined, InfoOutlined, InfoSolid, Loading, SuccessOutlined, SuccessSolid, SwapRightOutlined, WarningOutlined, WarningSolid } from "@capra/icons";
|
|
4
|
+
import { Breadcrumb as Breadcrumb$1, Breadcrumbs as Breadcrumbs$1, Button as Button$1, ButtonContext, Calendar, CalendarCell, CalendarGrid, CalendarGridBody, CalendarGridHeader, CalendarHeaderCell, Collection, ComboBox, DateInput, DatePicker, DatePickerStateContext, DateRangePicker, DateRangePickerStateContext, DateSegment, Dialog, DialogTrigger, Disclosure, DisclosurePanel, Focusable, Group, Header, Heading, HeadingContext, Input, InputContext, LabelContext, Link as Link$1, ListBox, ListBoxItem, Menu as Menu$1, MenuItem, MenuSection, MenuTrigger, Modal as Modal$1, ModalOverlay, NumberField as NumberField$1, OverlayArrow, OverlayTriggerStateContext, Popover as Popover$1, Pressable, RangeCalendar, RangeCalendarStateContext, RouterProvider, Separator, SubmenuTrigger, Text as Text$1, TextArea as TextArea$1, TextContext, TextField as TextField$1, Tooltip as Tooltip$1, TooltipTrigger, Tree as Tree$1, TreeItem, TreeItemContent, composeRenderProps, useContextProps, useSlottedContext } from "react-aria-components";
|
|
5
5
|
import { FocusScope, UNSAFE_PortalProvider, useDateFormatter, useFocusWithin, usePreventScroll } from "react-aria";
|
|
6
6
|
import { createRoot } from "react-dom/client";
|
|
7
7
|
import { createPortal } from "react-dom";
|
|
@@ -229,7 +229,7 @@ const VisuallyHidden = ({ children, ...props }) => {
|
|
|
229
229
|
//#endregion
|
|
230
230
|
//#region src/components/input-helpers/Label.tsx
|
|
231
231
|
/** Label text and optional required indicator for form fields, aligned with Capra field layouts. */
|
|
232
|
-
const Label
|
|
232
|
+
const Label = React$1.forwardRef((props, ref) => {
|
|
233
233
|
const [mergedProps, mergedRef] = useContextProps(props, ref, LabelContext);
|
|
234
234
|
const { trailingSlot, children, required, FORCE__className: classNameOverride, style, ...labelProps } = mergedProps;
|
|
235
235
|
if (!children) return null;
|
|
@@ -242,7 +242,7 @@ const Label$1 = React$1.forwardRef((props, ref) => {
|
|
|
242
242
|
"aria-hidden": true
|
|
243
243
|
}, "*"), /* @__PURE__ */ React$1.createElement(VisuallyHidden, null, "This field is required"))), trailingSlot && /* @__PURE__ */ React$1.createElement("span", { className: Label_module_default.trailingSlot }, trailingSlot));
|
|
244
244
|
});
|
|
245
|
-
Label
|
|
245
|
+
Label.displayName = "Label";
|
|
246
246
|
//#endregion
|
|
247
247
|
//#region src/components/TextInput/TextInput.module.css
|
|
248
248
|
var TextInput_module_default = {
|
|
@@ -372,7 +372,7 @@ function AutocompleteFieldWithoutRef(props, ref) {
|
|
|
372
372
|
id,
|
|
373
373
|
shouldFocusWrap: true,
|
|
374
374
|
ref: comboboxRef
|
|
375
|
-
}, /* @__PURE__ */ React.createElement(Label
|
|
375
|
+
}, /* @__PURE__ */ React.createElement(Label, null, label), /* @__PURE__ */ React.createElement(TextInput, {
|
|
376
376
|
...inputProps,
|
|
377
377
|
ref,
|
|
378
378
|
trailingSlot: trailingContent
|
|
@@ -586,27 +586,32 @@ function BadgeLayout({ children }) {
|
|
|
586
586
|
//#endregion
|
|
587
587
|
//#region src/components/ListItem/ListItem.module.css
|
|
588
588
|
var ListItem_module_default = {
|
|
589
|
-
"
|
|
590
|
-
"
|
|
591
|
-
"
|
|
592
|
-
"
|
|
593
|
-
"
|
|
594
|
-
"
|
|
595
|
-
"
|
|
596
|
-
"
|
|
597
|
-
"
|
|
589
|
+
"__listItem-layout": "capra-ListItem-module-QN6vFW-__listItem-layout",
|
|
590
|
+
"content": "capra-ListItem-module-QN6vFW-content",
|
|
591
|
+
"description": "capra-ListItem-module-QN6vFW-description",
|
|
592
|
+
"label": "capra-ListItem-module-QN6vFW-label",
|
|
593
|
+
"leading": "capra-ListItem-module-QN6vFW-leading",
|
|
594
|
+
"listItem": "capra-ListItem-module-QN6vFW-listItem capra-ListItem-module-QN6vFW-__listItem-layout",
|
|
595
|
+
"slot": "capra-ListItem-module-QN6vFW-slot",
|
|
596
|
+
"slots": "capra-ListItem-module-QN6vFW-slots",
|
|
597
|
+
"suffix": "capra-ListItem-module-QN6vFW-suffix",
|
|
598
|
+
"trailing": "capra-ListItem-module-QN6vFW-trailing"
|
|
598
599
|
};
|
|
599
600
|
//#endregion
|
|
600
601
|
//#region src/components/ListItem/ListItemSlots.tsx
|
|
602
|
+
const CollapsedSlot = "__CollapsedSlot__";
|
|
601
603
|
const ListItemSlots = ({ children, trailing = false, FORCE__className }) => {
|
|
602
604
|
if (React.Children.count(children) === 0) return null;
|
|
603
605
|
return /* @__PURE__ */ React.createElement("div", {
|
|
604
606
|
className: clsx(ListItem_module_default.slots, FORCE__className),
|
|
605
607
|
"data-trailing": trailing || void 0
|
|
606
|
-
}, React.Children.map(children, (child, index) =>
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
608
|
+
}, React.Children.map(children, (child, index) => {
|
|
609
|
+
if (child === "__CollapsedSlot__") return void 0;
|
|
610
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
611
|
+
key: index,
|
|
612
|
+
className: ListItem_module_default.slot
|
|
613
|
+
}, child);
|
|
614
|
+
}));
|
|
610
615
|
};
|
|
611
616
|
//#endregion
|
|
612
617
|
//#region src/components/ListItem/ListItem.tsx
|
|
@@ -629,7 +634,7 @@ const Trailing = ({ children, FORCE__className }) => {
|
|
|
629
634
|
const Content = ({ children, FORCE__className }) => {
|
|
630
635
|
return /* @__PURE__ */ React$1.createElement("div", { className: clsx(ListItem_module_default.content, FORCE__className) }, children);
|
|
631
636
|
};
|
|
632
|
-
const Label = ({ children, id }) => {
|
|
637
|
+
const Label$1 = ({ children, id }) => {
|
|
633
638
|
return /* @__PURE__ */ React$1.createElement("div", {
|
|
634
639
|
id,
|
|
635
640
|
className: ListItem_module_default.label
|
|
@@ -648,7 +653,7 @@ const Spacer = () => {
|
|
|
648
653
|
});
|
|
649
654
|
};
|
|
650
655
|
ListItem.Content = Content;
|
|
651
|
-
ListItem.Label = Label;
|
|
656
|
+
ListItem.Label = Label$1;
|
|
652
657
|
ListItem.Description = Description;
|
|
653
658
|
ListItem.Suffix = Suffix;
|
|
654
659
|
ListItem.Spacer = Spacer;
|
|
@@ -1089,7 +1094,7 @@ const TextField = React$1.forwardRef((props, ref) => {
|
|
|
1089
1094
|
className: fieldLayout_module_default.field,
|
|
1090
1095
|
"data-capra-field-root": "",
|
|
1091
1096
|
"data-layout": layout
|
|
1092
|
-
}, /* @__PURE__ */ React$1.createElement(Label
|
|
1097
|
+
}, /* @__PURE__ */ React$1.createElement(Label, { required }, label), /* @__PURE__ */ React$1.createElement(TextInput, {
|
|
1093
1098
|
ref,
|
|
1094
1099
|
...inputRest,
|
|
1095
1100
|
appearance,
|
|
@@ -1193,7 +1198,7 @@ const NumberField = React$1.forwardRef((props, ref) => {
|
|
|
1193
1198
|
className: fieldLayout_module_default.field,
|
|
1194
1199
|
"data-capra-field-root": "",
|
|
1195
1200
|
"data-layout": layout
|
|
1196
|
-
}, /* @__PURE__ */ React$1.createElement(Label
|
|
1201
|
+
}, /* @__PURE__ */ React$1.createElement(Label, { required }, label), /* @__PURE__ */ React$1.createElement(Group, {
|
|
1197
1202
|
"data-capra-text-input": "",
|
|
1198
1203
|
"data-size": size,
|
|
1199
1204
|
className: clsx(TextInput_module_default.wrapper, NumberField_module_default.withStepper, classNameOverride)
|
|
@@ -2209,7 +2214,7 @@ function DatePickerFieldInner(props, ref) {
|
|
|
2209
2214
|
isInvalid,
|
|
2210
2215
|
shouldForceLeadingZeros: true,
|
|
2211
2216
|
validationBehavior: "aria"
|
|
2212
|
-
}, /* @__PURE__ */ React$1.createElement(Label
|
|
2217
|
+
}, /* @__PURE__ */ React$1.createElement(Label, { required }, label), /* @__PURE__ */ React$1.createElement(DatePickerFieldRow, {
|
|
2213
2218
|
appearance,
|
|
2214
2219
|
size,
|
|
2215
2220
|
leadingSlot,
|
|
@@ -2451,7 +2456,7 @@ function DateRangePickerFieldInner(props, ref) {
|
|
|
2451
2456
|
isInvalid,
|
|
2452
2457
|
shouldForceLeadingZeros: true,
|
|
2453
2458
|
validationBehavior: "aria"
|
|
2454
|
-
}, /* @__PURE__ */ React$1.createElement(Label
|
|
2459
|
+
}, /* @__PURE__ */ React$1.createElement(Label, { required }, label), /* @__PURE__ */ React$1.createElement(DateRangePickerFieldRow, {
|
|
2455
2460
|
appearance,
|
|
2456
2461
|
size,
|
|
2457
2462
|
leadingSlot,
|
|
@@ -2680,7 +2685,7 @@ const TextArea = React$1.forwardRef((props, ref) => {
|
|
|
2680
2685
|
...ariaFieldProps,
|
|
2681
2686
|
className: fieldLayout_module_default.field,
|
|
2682
2687
|
"data-layout": layout
|
|
2683
|
-
}, /* @__PURE__ */ React$1.createElement(Label
|
|
2688
|
+
}, /* @__PURE__ */ React$1.createElement(Label, { required }, label), /* @__PURE__ */ React$1.createElement("div", {
|
|
2684
2689
|
className: clsx(TextArea_module_default.wrapper, classNameOverride),
|
|
2685
2690
|
"data-has-indicator": hasIndicator,
|
|
2686
2691
|
"data-autosize": autoSizeActive,
|
|
@@ -4947,4 +4952,238 @@ function ArrowSvg() {
|
|
|
4947
4952
|
}));
|
|
4948
4953
|
}
|
|
4949
4954
|
//#endregion
|
|
4950
|
-
|
|
4955
|
+
//#region src/components/Tree/Tree.module.css
|
|
4956
|
+
var Tree_module_default = {
|
|
4957
|
+
"chevronButton": "capra-Tree-module--hXpBa-chevronButton",
|
|
4958
|
+
"chevronIcon": "capra-Tree-module--hXpBa-chevronIcon",
|
|
4959
|
+
"indentSpacer": "capra-Tree-module--hXpBa-indentSpacer",
|
|
4960
|
+
"item": "capra-Tree-module--hXpBa-item capra-ListItem-module-QN6vFW-__listItem-layout",
|
|
4961
|
+
"itemContent": "capra-Tree-module--hXpBa-itemContent capra-ListItem-module-QN6vFW-content",
|
|
4962
|
+
"itemLabel": "capra-Tree-module--hXpBa-itemLabel capra-ListItem-module-QN6vFW-label",
|
|
4963
|
+
"itemSuffix": "capra-Tree-module--hXpBa-itemSuffix capra-ListItem-module-QN6vFW-suffix",
|
|
4964
|
+
"label": "capra-Tree-module--hXpBa-label",
|
|
4965
|
+
"root": "capra-Tree-module--hXpBa-root",
|
|
4966
|
+
"selectionCheckbox": "capra-Tree-module--hXpBa-selectionCheckbox",
|
|
4967
|
+
"suffix": "capra-Tree-module--hXpBa-suffix"
|
|
4968
|
+
};
|
|
4969
|
+
//#endregion
|
|
4970
|
+
//#region src/components/Tree/Tree.tsx
|
|
4971
|
+
const TreeSelectionContext = React$1.createContext(null);
|
|
4972
|
+
function getTextValue(item) {
|
|
4973
|
+
return typeof item.label === "string" ? item.label : String(item.key);
|
|
4974
|
+
}
|
|
4975
|
+
function buildTreeIndex(items) {
|
|
4976
|
+
const parentByKey = /* @__PURE__ */ new Map();
|
|
4977
|
+
const descendantsByKey = /* @__PURE__ */ new Map();
|
|
4978
|
+
const selectableDescendantsByKey = /* @__PURE__ */ new Map();
|
|
4979
|
+
const disabledKeys = /* @__PURE__ */ new Set();
|
|
4980
|
+
const selectableKeys = /* @__PURE__ */ new Set();
|
|
4981
|
+
const visit = (item, parent) => {
|
|
4982
|
+
parentByKey.set(item.key, parent);
|
|
4983
|
+
if (item.isDisabled) disabledKeys.add(item.key);
|
|
4984
|
+
else selectableKeys.add(item.key);
|
|
4985
|
+
const descendants = [];
|
|
4986
|
+
const selectableDescendants = [];
|
|
4987
|
+
for (const child of item.children ?? []) {
|
|
4988
|
+
visit(child, item.key);
|
|
4989
|
+
descendants.push(child.key, ...descendantsByKey.get(child.key) ?? []);
|
|
4990
|
+
if (!child.isDisabled) selectableDescendants.push(child.key);
|
|
4991
|
+
for (const descendant of selectableDescendantsByKey.get(child.key) ?? []) selectableDescendants.push(descendant);
|
|
4992
|
+
}
|
|
4993
|
+
descendantsByKey.set(item.key, descendants);
|
|
4994
|
+
selectableDescendantsByKey.set(item.key, selectableDescendants);
|
|
4995
|
+
};
|
|
4996
|
+
for (const item of items) visit(item, null);
|
|
4997
|
+
return {
|
|
4998
|
+
parentByKey,
|
|
4999
|
+
descendantsByKey,
|
|
5000
|
+
selectableDescendantsByKey,
|
|
5001
|
+
disabledKeys,
|
|
5002
|
+
selectableKeys
|
|
5003
|
+
};
|
|
5004
|
+
}
|
|
5005
|
+
function sanitizeSelection(selection, index) {
|
|
5006
|
+
const next = /* @__PURE__ */ new Set();
|
|
5007
|
+
for (const key of selection) if (index.parentByKey.has(key) && !index.disabledKeys.has(key)) next.add(key);
|
|
5008
|
+
return next;
|
|
5009
|
+
}
|
|
5010
|
+
function reconcileParentKeys(selection, index) {
|
|
5011
|
+
const next = new Set(selection);
|
|
5012
|
+
for (const [key, selectableDescendants] of index.selectableDescendantsByKey) {
|
|
5013
|
+
if (selectableDescendants.length === 0) continue;
|
|
5014
|
+
if (!selectableDescendants.every((descendantKey) => next.has(descendantKey))) next.delete(key);
|
|
5015
|
+
}
|
|
5016
|
+
return next;
|
|
5017
|
+
}
|
|
5018
|
+
function selectionToSet(selection, index) {
|
|
5019
|
+
if (selection === "all") return new Set(index.selectableKeys);
|
|
5020
|
+
if (selection == null) return /* @__PURE__ */ new Set();
|
|
5021
|
+
return sanitizeSelection(selection, index);
|
|
5022
|
+
}
|
|
5023
|
+
function expandKeysWithAncestors(keys, index) {
|
|
5024
|
+
if (keys == null) return;
|
|
5025
|
+
const expanded = /* @__PURE__ */ new Set();
|
|
5026
|
+
for (const key of keys) {
|
|
5027
|
+
if (!index.parentByKey.has(key)) continue;
|
|
5028
|
+
let current = key;
|
|
5029
|
+
while (current != null) {
|
|
5030
|
+
expanded.add(current);
|
|
5031
|
+
current = index.parentByKey.get(current) ?? null;
|
|
5032
|
+
}
|
|
5033
|
+
}
|
|
5034
|
+
return expanded;
|
|
5035
|
+
}
|
|
5036
|
+
function getCheckboxState(key, selectedKeys, index) {
|
|
5037
|
+
const selectableDescendants = index.selectableDescendantsByKey.get(key) ?? [];
|
|
5038
|
+
if (selectableDescendants.length === 0) return {
|
|
5039
|
+
checked: selectedKeys.has(key),
|
|
5040
|
+
indeterminate: false
|
|
5041
|
+
};
|
|
5042
|
+
const selectedDescendantCount = selectableDescendants.filter((descendantKey) => selectedKeys.has(descendantKey)).length;
|
|
5043
|
+
const allSelectableDescendantsSelected = selectedDescendantCount === selectableDescendants.length;
|
|
5044
|
+
const someSelectableDescendantsSelected = selectedDescendantCount > 0;
|
|
5045
|
+
if (allSelectableDescendantsSelected || selectedKeys.has(key)) return {
|
|
5046
|
+
checked: true,
|
|
5047
|
+
indeterminate: false
|
|
5048
|
+
};
|
|
5049
|
+
return {
|
|
5050
|
+
checked: false,
|
|
5051
|
+
indeterminate: someSelectableDescendantsSelected
|
|
5052
|
+
};
|
|
5053
|
+
}
|
|
5054
|
+
function applySelectionChange(prev, next, index) {
|
|
5055
|
+
const cascadedSelection = sanitizeSelection(next, index);
|
|
5056
|
+
for (const key of next) {
|
|
5057
|
+
if (prev.has(key) || index.disabledKeys.has(key)) continue;
|
|
5058
|
+
if ((index.descendantsByKey.get(key) ?? []).length === 0) continue;
|
|
5059
|
+
cascadedSelection.add(key);
|
|
5060
|
+
for (const descendantKey of index.selectableDescendantsByKey.get(key) ?? []) cascadedSelection.add(descendantKey);
|
|
5061
|
+
}
|
|
5062
|
+
for (const key of prev) {
|
|
5063
|
+
if (next.has(key) || index.disabledKeys.has(key)) continue;
|
|
5064
|
+
if ((index.descendantsByKey.get(key) ?? []).length === 0) continue;
|
|
5065
|
+
cascadedSelection.delete(key);
|
|
5066
|
+
for (const descendantKey of index.descendantsByKey.get(key) ?? []) cascadedSelection.delete(descendantKey);
|
|
5067
|
+
}
|
|
5068
|
+
return reconcileParentKeys(cascadedSelection, index);
|
|
5069
|
+
}
|
|
5070
|
+
function TreeSelectionCheckbox({ item }) {
|
|
5071
|
+
const context = React$1.useContext(TreeSelectionContext);
|
|
5072
|
+
if (context?.selectionMode !== "multiple") return null;
|
|
5073
|
+
const checkboxState = getCheckboxState(item.key, context.selectedKeys, context.index);
|
|
5074
|
+
return /* @__PURE__ */ React$1.createElement(Checkbox, {
|
|
5075
|
+
"aria-checked": checkboxState.indeterminate ? "mixed" : checkboxState.checked ? "true" : "false",
|
|
5076
|
+
"aria-label": getTextValue(item),
|
|
5077
|
+
checked: checkboxState.checked,
|
|
5078
|
+
disabled: context.index.disabledKeys.has(item.key),
|
|
5079
|
+
indeterminate: checkboxState.indeterminate,
|
|
5080
|
+
FORCE__className: Tree_module_default.selectionCheckbox,
|
|
5081
|
+
onChange: (event) => {
|
|
5082
|
+
event.stopPropagation();
|
|
5083
|
+
context.toggleSelection(item.key);
|
|
5084
|
+
},
|
|
5085
|
+
onClick: (event) => {
|
|
5086
|
+
event.stopPropagation();
|
|
5087
|
+
},
|
|
5088
|
+
onMouseDown: (event) => {
|
|
5089
|
+
event.stopPropagation();
|
|
5090
|
+
},
|
|
5091
|
+
onKeyDown: (event) => {
|
|
5092
|
+
event.stopPropagation();
|
|
5093
|
+
},
|
|
5094
|
+
onPointerDown: (event) => {
|
|
5095
|
+
event.stopPropagation();
|
|
5096
|
+
}
|
|
5097
|
+
});
|
|
5098
|
+
}
|
|
5099
|
+
function renderTreeItem(item) {
|
|
5100
|
+
return /* @__PURE__ */ React$1.createElement(TreeItem, {
|
|
5101
|
+
id: item.key,
|
|
5102
|
+
key: item.key,
|
|
5103
|
+
className: Tree_module_default.item,
|
|
5104
|
+
isDisabled: item.isDisabled,
|
|
5105
|
+
textValue: getTextValue(item)
|
|
5106
|
+
}, /* @__PURE__ */ React$1.createElement(TreeItemContent, null, ({ hasChildItems, id, level, selectionMode }) => /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, /* @__PURE__ */ React$1.createElement(ListItem.Leading, null, Array.from({ length: Math.max(level - 1, 0) }).map((_, index) => /* @__PURE__ */ React$1.createElement("span", {
|
|
5107
|
+
key: `${String(item.key)}-indent-${index}`,
|
|
5108
|
+
"aria-hidden": "true",
|
|
5109
|
+
className: Tree_module_default.indentSpacer
|
|
5110
|
+
})), hasChildItems ? /* @__PURE__ */ React$1.createElement(Button$1, {
|
|
5111
|
+
slot: "chevron",
|
|
5112
|
+
className: Tree_module_default.chevronButton
|
|
5113
|
+
}, /* @__PURE__ */ React$1.createElement("span", {
|
|
5114
|
+
"aria-hidden": "true",
|
|
5115
|
+
className: Tree_module_default.chevronIcon
|
|
5116
|
+
}, /* @__PURE__ */ React$1.createElement(CaretRight, { size: "xs" }))) : /* @__PURE__ */ React$1.createElement("div", null), selectionMode === "multiple" ? /* @__PURE__ */ React$1.createElement(TreeSelectionCheckbox, { item }) : CollapsedSlot), /* @__PURE__ */ React$1.createElement("div", { className: Tree_module_default.itemContent }, /* @__PURE__ */ React$1.createElement("div", {
|
|
5117
|
+
id: String(id),
|
|
5118
|
+
className: Tree_module_default.itemLabel
|
|
5119
|
+
}, item.label)), /* @__PURE__ */ React$1.createElement(ListItem.Trailing, null, item.suffix ? /* @__PURE__ */ React$1.createElement("div", { className: Tree_module_default.itemSuffix }, item.suffix) : CollapsedSlot, item.trailingSlot || "__CollapsedSlot__"))), /* @__PURE__ */ React$1.createElement(Collection, { items: item.children }, renderTreeItem));
|
|
5120
|
+
}
|
|
5121
|
+
/**
|
|
5122
|
+
* A hierarchical tree with cascading multi-select and Capra ListItem row layout.
|
|
5123
|
+
*/
|
|
5124
|
+
function Tree({ FORCE__className: classNameOverride, items, selectionMode = "multiple", defaultSelectedKeys, selectedKeys, onSelectionChange, expandedKeys, defaultExpandedKeys, ...props }) {
|
|
5125
|
+
const index = React$1.useMemo(() => buildTreeIndex(items), [items]);
|
|
5126
|
+
const resolvedExpandedKeys = React$1.useMemo(() => expandKeysWithAncestors(expandedKeys, index), [expandedKeys, index]);
|
|
5127
|
+
const resolvedDefaultExpandedKeys = React$1.useMemo(() => expandKeysWithAncestors(defaultExpandedKeys, index), [defaultExpandedKeys, index]);
|
|
5128
|
+
const [internalSelectedKeys, setInternalSelectedKeys] = React$1.useState(() => applySelectionChange(/* @__PURE__ */ new Set(), selectionToSet(selectedKeys ?? defaultSelectedKeys, index), index));
|
|
5129
|
+
React$1.useEffect(() => {
|
|
5130
|
+
const nextSelectedKeys = selectedKeys != null ? applySelectionChange(/* @__PURE__ */ new Set(), selectionToSet(selectedKeys, index), index) : reconcileParentKeys(sanitizeSelection(internalSelectedKeys, index), index);
|
|
5131
|
+
if (nextSelectedKeys.size !== internalSelectedKeys.size || Array.from(nextSelectedKeys).some((key) => !internalSelectedKeys.has(key))) setInternalSelectedKeys(nextSelectedKeys);
|
|
5132
|
+
}, [
|
|
5133
|
+
index,
|
|
5134
|
+
internalSelectedKeys,
|
|
5135
|
+
selectedKeys
|
|
5136
|
+
]);
|
|
5137
|
+
const selectedKeysRef = React$1.useRef(internalSelectedKeys);
|
|
5138
|
+
selectedKeysRef.current = internalSelectedKeys;
|
|
5139
|
+
const commitSelection = React$1.useCallback((nextSelectedKeys) => {
|
|
5140
|
+
setInternalSelectedKeys(nextSelectedKeys);
|
|
5141
|
+
onSelectionChange?.(new Set(nextSelectedKeys));
|
|
5142
|
+
}, [onSelectionChange]);
|
|
5143
|
+
const toggleSelection = React$1.useCallback((key) => {
|
|
5144
|
+
if (selectionMode !== "multiple" || index.disabledKeys.has(key)) return;
|
|
5145
|
+
const nextSelectedKeys = new Set(selectedKeysRef.current);
|
|
5146
|
+
if (nextSelectedKeys.has(key)) nextSelectedKeys.delete(key);
|
|
5147
|
+
else nextSelectedKeys.add(key);
|
|
5148
|
+
commitSelection(applySelectionChange(selectedKeysRef.current, nextSelectedKeys, index));
|
|
5149
|
+
}, [
|
|
5150
|
+
commitSelection,
|
|
5151
|
+
index,
|
|
5152
|
+
selectionMode
|
|
5153
|
+
]);
|
|
5154
|
+
const handleSelectionChange = React$1.useCallback((nextSelection) => {
|
|
5155
|
+
if (selectionMode !== "multiple") {
|
|
5156
|
+
commitSelection(selectionToSet(nextSelection, index));
|
|
5157
|
+
return;
|
|
5158
|
+
}
|
|
5159
|
+
commitSelection(applySelectionChange(selectedKeysRef.current, selectionToSet(nextSelection, index), index));
|
|
5160
|
+
}, [
|
|
5161
|
+
commitSelection,
|
|
5162
|
+
index,
|
|
5163
|
+
selectionMode
|
|
5164
|
+
]);
|
|
5165
|
+
const selectionContext = React$1.useMemo(() => ({
|
|
5166
|
+
index,
|
|
5167
|
+
selectedKeys: internalSelectedKeys,
|
|
5168
|
+
selectionMode,
|
|
5169
|
+
toggleSelection
|
|
5170
|
+
}), [
|
|
5171
|
+
index,
|
|
5172
|
+
internalSelectedKeys,
|
|
5173
|
+
selectionMode,
|
|
5174
|
+
toggleSelection
|
|
5175
|
+
]);
|
|
5176
|
+
return /* @__PURE__ */ React$1.createElement(TreeSelectionContext.Provider, { value: selectionContext }, /* @__PURE__ */ React$1.createElement(Tree$1, {
|
|
5177
|
+
...props,
|
|
5178
|
+
selectionBehavior: "toggle",
|
|
5179
|
+
className: clsx(Tree_module_default.root, classNameOverride),
|
|
5180
|
+
items,
|
|
5181
|
+
selectedKeys: internalSelectedKeys,
|
|
5182
|
+
selectionMode,
|
|
5183
|
+
onSelectionChange: handleSelectionChange,
|
|
5184
|
+
expandedKeys: resolvedExpandedKeys,
|
|
5185
|
+
defaultExpandedKeys: resolvedDefaultExpandedKeys
|
|
5186
|
+
}, /* @__PURE__ */ React$1.createElement(Collection, { items }, renderTreeItem)));
|
|
5187
|
+
}
|
|
5188
|
+
//#endregion
|
|
5189
|
+
export { Alert, Anchor, AutocompleteField, Badge, BadgeLayout, Breadcrumb, Breadcrumbs, Button, ButtonLink, Card, Checkbox, Collapse, CustomTooltipTrigger, DatePickerField, DateRangePickerField, Divider, Drawer, EmptyState, IconButton, InputRow, Label, Link, ListItem, Menu, Modal, NumberField, Pagination, PasswordField, Pill, Popover, Radio, RadioGroup, RadioTile, Ribbon, RouterProvider, SKELETON_SIZE, SKELETON_SIZE_TOKENS, Skeleton, SkeletonGroup, Spinner, Switch, TabNav, Tag, Text, TextArea, TextField, Toast, Tooltip, TopNav, Tree, VerticalNavigation, VisuallyHidden, submenuPanelClassName, tagColors };
|