@vokality/design-system 0.0.0-stage → 1.2.2
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/CHANGELOG.md +92 -0
- package/README.md +134 -2
- package/dist/charts/chart.d.ts +52 -0
- package/dist/charts/chart.js +108 -0
- package/dist/components/Accordion/Accordion.d.ts +15 -0
- package/dist/components/Accordion/Accordion.js +16 -0
- package/dist/components/Alert/Alert.d.ts +14 -0
- package/dist/components/Alert/Alert.js +12 -0
- package/dist/components/AppShell/AppShell.d.ts +21 -0
- package/dist/components/AppShell/AppShell.js +48 -0
- package/dist/components/Avatar/Avatar.d.ts +11 -0
- package/dist/components/Avatar/Avatar.js +19 -0
- package/dist/components/AvatarGroup/AvatarGroup.d.ts +11 -0
- package/dist/components/AvatarGroup/AvatarGroup.js +13 -0
- package/dist/components/Badge/Badge.d.ts +9 -0
- package/dist/components/Badge/Badge.js +6 -0
- package/dist/components/BarChart/BarChart.d.ts +7 -0
- package/dist/components/BarChart/BarChart.js +45 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +11 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.js +11 -0
- package/dist/components/Button/Button.d.ts +17 -0
- package/dist/components/Button/Button.js +23 -0
- package/dist/components/Calendar/Calendar.d.ts +21 -0
- package/dist/components/Calendar/Calendar.js +144 -0
- package/dist/components/Card/Card.d.ts +16 -0
- package/dist/components/Card/Card.js +11 -0
- package/dist/components/Checkbox/Checkbox.d.ts +12 -0
- package/dist/components/Checkbox/Checkbox.js +24 -0
- package/dist/components/Code/Code.d.ts +7 -0
- package/dist/components/Code/Code.js +6 -0
- package/dist/components/CodeBlock/CodeBlock.d.ts +10 -0
- package/dist/components/CodeBlock/CodeBlock.js +43 -0
- package/dist/components/Combobox/Combobox.d.ts +23 -0
- package/dist/components/Combobox/Combobox.js +188 -0
- package/dist/components/Combobox/ListPanel.d.ts +16 -0
- package/dist/components/Combobox/ListPanel.js +75 -0
- package/dist/components/CommandPalette/CommandPalette.d.ts +23 -0
- package/dist/components/CommandPalette/CommandPalette.js +86 -0
- package/dist/components/Container/Container.d.ts +10 -0
- package/dist/components/Container/Container.js +7 -0
- package/dist/components/ContextMenu/ContextMenu.d.ts +11 -0
- package/dist/components/ContextMenu/ContextMenu.js +56 -0
- package/dist/components/DatePicker/DatePicker.d.ts +25 -0
- package/dist/components/DatePicker/DatePicker.js +198 -0
- package/dist/components/DescriptionList/DescriptionList.d.ts +12 -0
- package/dist/components/DescriptionList/DescriptionList.js +6 -0
- package/dist/components/Dialog/Dialog.d.ts +23 -0
- package/dist/components/Dialog/Dialog.js +53 -0
- package/dist/components/Divider/Divider.d.ts +6 -0
- package/dist/components/Divider/Divider.js +10 -0
- package/dist/components/Drawer/Drawer.d.ts +6 -0
- package/dist/components/Drawer/Drawer.js +6 -0
- package/dist/components/EmptyState/EmptyState.d.ts +11 -0
- package/dist/components/EmptyState/EmptyState.js +10 -0
- package/dist/components/ErrorSummary/ErrorSummary.d.ts +10 -0
- package/dist/components/ErrorSummary/ErrorSummary.js +28 -0
- package/dist/components/FaqList/FaqList.d.ts +10 -0
- package/dist/components/FaqList/FaqList.js +6 -0
- package/dist/components/Field/Field.d.ts +12 -0
- package/dist/components/Field/Field.js +25 -0
- package/dist/components/Figure/Figure.d.ts +11 -0
- package/dist/components/Figure/Figure.js +6 -0
- package/dist/components/FileUpload/FileUpload.d.ts +25 -0
- package/dist/components/FileUpload/FileUpload.js +47 -0
- package/dist/components/Grid/Grid.d.ts +12 -0
- package/dist/components/Grid/Grid.js +10 -0
- package/dist/components/HatchDivider/HatchDivider.d.ts +2 -0
- package/dist/components/HatchDivider/HatchDivider.js +5 -0
- package/dist/components/Heading/Heading.d.ts +12 -0
- package/dist/components/Heading/Heading.js +11 -0
- package/dist/components/Icon/Icon.d.ts +8 -0
- package/dist/components/Icon/Icon.js +17 -0
- package/dist/components/IconButton/IconButton.d.ts +11 -0
- package/dist/components/IconButton/IconButton.js +16 -0
- package/dist/components/Inline/Inline.d.ts +13 -0
- package/dist/components/Inline/Inline.js +8 -0
- package/dist/components/Input/Input.d.ts +10 -0
- package/dist/components/Input/Input.js +25 -0
- package/dist/components/Kbd/Kbd.d.ts +7 -0
- package/dist/components/Kbd/Kbd.js +6 -0
- package/dist/components/LineChart/LineChart.d.ts +7 -0
- package/dist/components/LineChart/LineChart.js +53 -0
- package/dist/components/Link/Link.d.ts +7 -0
- package/dist/components/Link/Link.js +12 -0
- package/dist/components/LinkProvider/LinkProvider.d.ts +22 -0
- package/dist/components/LinkProvider/LinkProvider.js +21 -0
- package/dist/components/List/List.d.ts +24 -0
- package/dist/components/List/List.js +24 -0
- package/dist/components/MediaCard/MediaCard.d.ts +19 -0
- package/dist/components/MediaCard/MediaCard.js +25 -0
- package/dist/components/Menu/Menu.d.ts +14 -0
- package/dist/components/Menu/Menu.js +53 -0
- package/dist/components/Menu/entries.d.ts +40 -0
- package/dist/components/Menu/entries.js +146 -0
- package/dist/components/MultiSelect/MultiSelect.d.ts +24 -0
- package/dist/components/MultiSelect/MultiSelect.js +166 -0
- package/dist/components/NavList/NavList.d.ts +19 -0
- package/dist/components/NavList/NavList.js +10 -0
- package/dist/components/NumberInput/NumberInput.d.ts +13 -0
- package/dist/components/NumberInput/NumberInput.js +90 -0
- package/dist/components/OtpInput/OtpInput.d.ts +19 -0
- package/dist/components/OtpInput/OtpInput.js +75 -0
- package/dist/components/PageHeader/PageHeader.d.ts +18 -0
- package/dist/components/PageHeader/PageHeader.js +11 -0
- package/dist/components/Pagination/Pagination.d.ts +15 -0
- package/dist/components/Pagination/Pagination.js +22 -0
- package/dist/components/PasswordInput/PasswordInput.d.ts +7 -0
- package/dist/components/PasswordInput/PasswordInput.js +11 -0
- package/dist/components/Popover/Popover.d.ts +18 -0
- package/dist/components/Popover/Popover.js +26 -0
- package/dist/components/Progress/Progress.d.ts +13 -0
- package/dist/components/Progress/Progress.js +24 -0
- package/dist/components/Prose/Prose.d.ts +8 -0
- package/dist/components/Prose/Prose.js +7 -0
- package/dist/components/Quote/Quote.d.ts +10 -0
- package/dist/components/Quote/Quote.js +7 -0
- package/dist/components/Radio/Radio.d.ts +7 -0
- package/dist/components/Radio/Radio.js +9 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts +21 -0
- package/dist/components/RadioGroup/RadioGroup.js +41 -0
- package/dist/components/SearchInput/SearchInput.d.ts +10 -0
- package/dist/components/SearchInput/SearchInput.js +39 -0
- package/dist/components/SectionHeader/SectionHeader.d.ts +10 -0
- package/dist/components/SectionHeader/SectionHeader.js +9 -0
- package/dist/components/SegmentedControl/SegmentedControl.d.ts +19 -0
- package/dist/components/SegmentedControl/SegmentedControl.js +21 -0
- package/dist/components/Select/Select.d.ts +26 -0
- package/dist/components/Select/Select.js +262 -0
- package/dist/components/Skeleton/Skeleton.d.ts +8 -0
- package/dist/components/Skeleton/Skeleton.js +13 -0
- package/dist/components/Slider/Slider.d.ts +21 -0
- package/dist/components/Slider/Slider.js +43 -0
- package/dist/components/Sparkline/Sparkline.d.ts +11 -0
- package/dist/components/Sparkline/Sparkline.js +15 -0
- package/dist/components/Spinner/Spinner.d.ts +8 -0
- package/dist/components/Spinner/Spinner.js +8 -0
- package/dist/components/SquareGlyph/SquareGlyph.d.ts +7 -0
- package/dist/components/SquareGlyph/SquareGlyph.js +6 -0
- package/dist/components/Stack/Stack.d.ts +11 -0
- package/dist/components/Stack/Stack.js +8 -0
- package/dist/components/Stat/Stat.d.ts +13 -0
- package/dist/components/Stat/Stat.js +22 -0
- package/dist/components/Steps/Steps.d.ts +13 -0
- package/dist/components/Steps/Steps.js +13 -0
- package/dist/components/Switch/Switch.d.ts +7 -0
- package/dist/components/Switch/Switch.js +16 -0
- package/dist/components/Table/Table.d.ts +48 -0
- package/dist/components/Table/Table.js +144 -0
- package/dist/components/Tabs/Tabs.d.ts +19 -0
- package/dist/components/Tabs/Tabs.js +29 -0
- package/dist/components/Tag/Tag.d.ts +12 -0
- package/dist/components/Tag/Tag.js +8 -0
- package/dist/components/Text/Text.d.ts +10 -0
- package/dist/components/Text/Text.js +7 -0
- package/dist/components/Textarea/Textarea.d.ts +6 -0
- package/dist/components/Textarea/Textarea.js +17 -0
- package/dist/components/ThemeScript/ThemeScript.d.ts +7 -0
- package/dist/components/ThemeScript/ThemeScript.js +9 -0
- package/dist/components/TileGrid/TileGrid.d.ts +13 -0
- package/dist/components/TileGrid/TileGrid.js +8 -0
- package/dist/components/TimePicker/TimePicker.d.ts +28 -0
- package/dist/components/TimePicker/TimePicker.js +192 -0
- package/dist/components/Timeline/Timeline.d.ts +16 -0
- package/dist/components/Timeline/Timeline.js +10 -0
- package/dist/components/Toaster/Toaster.d.ts +50 -0
- package/dist/components/Toaster/Toaster.js +63 -0
- package/dist/components/Tooltip/Tooltip.d.ts +11 -0
- package/dist/components/Tooltip/Tooltip.js +21 -0
- package/dist/components/TreeView/TreeView.d.ts +30 -0
- package/dist/components/TreeView/TreeView.js +127 -0
- package/dist/components.css +1798 -0
- package/dist/fonts/FONT-NOTICES.txt +20 -0
- package/dist/fonts/IBMPlexSans-Latin.woff2 +0 -0
- package/dist/fonts/IBMPlexSans-OFL.txt +93 -0
- package/dist/fonts/Manrope-Latin.woff2 +0 -0
- package/dist/fonts/Manrope-OFL.txt +93 -0
- package/dist/fonts/SpaceGrotesk-Latin.woff2 +0 -0
- package/dist/fonts/SpaceGrotesk-OFL.txt +93 -0
- package/dist/fonts.css +23 -0
- package/dist/hooks/useTheme.d.ts +16 -0
- package/dist/hooks/useTheme.js +82 -0
- package/dist/icons/arrow-down.svg +1 -0
- package/dist/icons/arrow-up-right.svg +1 -0
- package/dist/icons/arrow-up.svg +1 -0
- package/dist/icons/calendar.svg +1 -0
- package/dist/icons/chart.svg +1 -0
- package/dist/icons/check.svg +1 -0
- package/dist/icons/chevron-down.svg +1 -0
- package/dist/icons/chevron-left.svg +1 -0
- package/dist/icons/chevron-right.svg +1 -0
- package/dist/icons/chevrons-up-down.svg +1 -0
- package/dist/icons/circle-alert.svg +1 -0
- package/dist/icons/circle-check.svg +1 -0
- package/dist/icons/clock.svg +1 -0
- package/dist/icons/copy.svg +1 -0
- package/dist/icons/ellipsis.svg +1 -0
- package/dist/icons/file.svg +1 -0
- package/dist/icons/folder.svg +1 -0
- package/dist/icons/home.svg +1 -0
- package/dist/icons/info.svg +1 -0
- package/dist/icons/map-pin.svg +1 -0
- package/dist/icons/menu.svg +1 -0
- package/dist/icons/minus.svg +1 -0
- package/dist/icons/pencil.svg +1 -0
- package/dist/icons/phone.svg +1 -0
- package/dist/icons/plus.svg +1 -0
- package/dist/icons/quote.svg +1 -0
- package/dist/icons/search.svg +1 -0
- package/dist/icons/sidebar.svg +1 -0
- package/dist/icons/trash.svg +1 -0
- package/dist/icons/triangle-alert.svg +1 -0
- package/dist/icons/upload.svg +1 -0
- package/dist/icons/users.svg +1 -0
- package/dist/icons/x.svg +1 -0
- package/dist/index.d.ts +178 -0
- package/dist/index.js +93 -0
- package/dist/internal/CharCount.d.ts +17 -0
- package/dist/internal/CharCount.js +23 -0
- package/dist/internal/choice.d.ts +65 -0
- package/dist/internal/choice.js +111 -0
- package/dist/internal/focusables.d.ts +3 -0
- package/dist/internal/focusables.js +8 -0
- package/dist/internal/options.d.ts +15 -0
- package/dist/internal/options.js +30 -0
- package/dist/internal/status.d.ts +6 -0
- package/dist/internal/status.js +5 -0
- package/dist/internal/useIsoLayoutEffect.d.ts +3 -0
- package/dist/internal/useIsoLayoutEffect.js +4 -0
- package/dist/internal/useScrollActive.d.ts +3 -0
- package/dist/internal/useScrollActive.js +12 -0
- package/dist/internal/useUid.d.ts +2 -0
- package/dist/internal/useUid.js +6 -0
- package/dist/lib/cx.d.ts +2 -0
- package/dist/lib/cx.js +4 -0
- package/dist/lib/dates.d.ts +10 -0
- package/dist/lib/dates.js +107 -0
- package/dist/lib/format.d.ts +15 -0
- package/dist/lib/format.js +50 -0
- package/dist/lib/icons.d.ts +220 -0
- package/dist/lib/icons.js +54 -0
- package/dist/lib/intl.d.ts +4 -0
- package/dist/lib/intl.js +19 -0
- package/dist/lib/math.d.ts +5 -0
- package/dist/lib/math.js +36 -0
- package/dist/lib/omit.d.ts +2 -0
- package/dist/lib/omit.js +10 -0
- package/dist/lib/space.d.ts +4 -0
- package/dist/lib/space.js +9 -0
- package/dist/lib/text.d.ts +8 -0
- package/dist/lib/text.js +12 -0
- package/dist/lib/theme.d.ts +16 -0
- package/dist/lib/theme.js +14 -0
- package/dist/lib/utils.d.ts +17 -0
- package/dist/lib/utils.js +5 -0
- package/dist/tailwind.css +110 -0
- package/dist/tokens.css +316 -0
- package/dist/tokens.dtcg.json +1606 -0
- package/dist/tokens.json +1217 -0
- package/dist/types.d.ts +67 -0
- package/dist/types.js +1 -0
- package/dist/vokality.css +2139 -0
- package/dist/vokality.iife.js +19408 -0
- package/docs/brand.md +163 -0
- package/docs/components/Accordion/README.md +24 -0
- package/docs/components/Alert/README.md +31 -0
- package/docs/components/AppShell/README.md +20 -0
- package/docs/components/Avatar/README.md +17 -0
- package/docs/components/AvatarGroup/README.md +12 -0
- package/docs/components/Badge/README.md +24 -0
- package/docs/components/BarChart/README.md +30 -0
- package/docs/components/Breadcrumbs/README.md +16 -0
- package/docs/components/Button/README.md +43 -0
- package/docs/components/Calendar/README.md +43 -0
- package/docs/components/Card/README.md +16 -0
- package/docs/components/Checkbox/README.md +30 -0
- package/docs/components/Code/README.md +9 -0
- package/docs/components/CodeBlock/README.md +15 -0
- package/docs/components/Combobox/README.md +43 -0
- package/docs/components/CommandPalette/README.md +20 -0
- package/docs/components/Container/README.md +10 -0
- package/docs/components/ContextMenu/README.md +13 -0
- package/docs/components/Dashboard/README.md +12 -0
- package/docs/components/DatePicker/README.md +34 -0
- package/docs/components/DescriptionList/README.md +18 -0
- package/docs/components/Dialog/README.md +28 -0
- package/docs/components/Divider/README.md +15 -0
- package/docs/components/Drawer/README.md +16 -0
- package/docs/components/EmptyState/README.md +17 -0
- package/docs/components/ErrorPage/README.md +11 -0
- package/docs/components/ErrorSummary/README.md +16 -0
- package/docs/components/FaqList/README.md +11 -0
- package/docs/components/Field/README.md +27 -0
- package/docs/components/Figure/README.md +9 -0
- package/docs/components/FileUpload/README.md +20 -0
- package/docs/components/FormPage/README.md +11 -0
- package/docs/components/Grid/README.md +11 -0
- package/docs/components/HatchDivider/README.md +10 -0
- package/docs/components/Heading/README.md +10 -0
- package/docs/components/Icon/README.md +23 -0
- package/docs/components/IconButton/README.md +28 -0
- package/docs/components/Inline/README.md +9 -0
- package/docs/components/Input/README.md +31 -0
- package/docs/components/Kbd/README.md +13 -0
- package/docs/components/LineChart/README.md +27 -0
- package/docs/components/Link/README.md +31 -0
- package/docs/components/List/README.md +21 -0
- package/docs/components/ListDetail/README.md +11 -0
- package/docs/components/MediaCard/README.md +16 -0
- package/docs/components/Menu/README.md +45 -0
- package/docs/components/MultiSelect/README.md +41 -0
- package/docs/components/NavList/README.md +21 -0
- package/docs/components/NumberInput/README.md +19 -0
- package/docs/components/OtpInput/README.md +17 -0
- package/docs/components/PageHeader/README.md +17 -0
- package/docs/components/Pagination/README.md +22 -0
- package/docs/components/PasswordInput/README.md +13 -0
- package/docs/components/Popover/README.md +23 -0
- package/docs/components/Progress/README.md +19 -0
- package/docs/components/Prose/README.md +12 -0
- package/docs/components/Quote/README.md +13 -0
- package/docs/components/Radio/README.md +25 -0
- package/docs/components/RadioGroup/README.md +23 -0
- package/docs/components/SearchInput/README.md +23 -0
- package/docs/components/SectionHeader/README.md +14 -0
- package/docs/components/SegmentedControl/README.md +19 -0
- package/docs/components/Select/README.md +52 -0
- package/docs/components/SettingsPage/README.md +11 -0
- package/docs/components/SignIn/README.md +11 -0
- package/docs/components/Skeleton/README.md +16 -0
- package/docs/components/Slider/README.md +22 -0
- package/docs/components/Sparkline/README.md +13 -0
- package/docs/components/Spinner/README.md +16 -0
- package/docs/components/SquareGlyph/README.md +18 -0
- package/docs/components/Stack/README.md +11 -0
- package/docs/components/Stat/README.md +20 -0
- package/docs/components/Steps/README.md +22 -0
- package/docs/components/Switch/README.md +27 -0
- package/docs/components/Table/README.md +35 -0
- package/docs/components/Tabs/README.md +26 -0
- package/docs/components/Tag/README.md +21 -0
- package/docs/components/Text/README.md +11 -0
- package/docs/components/Textarea/README.md +20 -0
- package/docs/components/ThemeScript/README.md +47 -0
- package/docs/components/TileGrid/README.md +12 -0
- package/docs/components/TimePicker/README.md +19 -0
- package/docs/components/Timeline/README.md +12 -0
- package/docs/components/Toaster/README.md +34 -0
- package/docs/components/Tooltip/README.md +23 -0
- package/docs/components/TreeView/README.md +15 -0
- package/package.json +76 -4
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { HatchDivider } from "../HatchDivider/HatchDivider.js";
|
|
3
|
+
import { cx } from "../../lib/cx.js";
|
|
4
|
+
/** Horizontal rule. */
|
|
5
|
+
export function Divider(props) {
|
|
6
|
+
const variant = props.variant || "solid";
|
|
7
|
+
if (variant === "hatch")
|
|
8
|
+
return _jsx(HatchDivider, {});
|
|
9
|
+
return _jsx("hr", { className: cx("vk-divider", "vk-divider-" + variant, props.className) });
|
|
10
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type DialogProps } from "../Dialog/Dialog.js";
|
|
2
|
+
export interface DrawerProps extends Omit<DialogProps, 'size'> {
|
|
3
|
+
side?: 'right' | 'left';
|
|
4
|
+
}
|
|
5
|
+
/** A modal panel that slides in from the side: a Dialog rendered as a sheet. */
|
|
6
|
+
export declare function Drawer(props: DrawerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Dialog } from "../Dialog/Dialog.js";
|
|
3
|
+
/** A modal panel that slides in from the side: a Dialog rendered as a sheet. */
|
|
4
|
+
export function Drawer(props) {
|
|
5
|
+
return _jsx(Dialog, { ...props, side: props.side || "right" });
|
|
6
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export interface EmptyStateProps {
|
|
3
|
+
title: ReactNode;
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
actions?: ReactNode;
|
|
6
|
+
glyph?: string;
|
|
7
|
+
headingAs?: "h2" | "h3" | "h4";
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
/** What a list, table or page shows when it has nothing in it yet. */
|
|
11
|
+
export declare function EmptyState({ title, children, actions, glyph, headingAs, className }: EmptyStateProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { SquareGlyph } from "../SquareGlyph/SquareGlyph.js";
|
|
3
|
+
import { cx } from "../../lib/cx.js";
|
|
4
|
+
import { para } from "../../lib/text.js";
|
|
5
|
+
/** What a list, table or page shows when it has nothing in it yet. */
|
|
6
|
+
export function EmptyState({ title, children, actions, glyph, headingAs, className }) {
|
|
7
|
+
const HeadingTag = headingAs || "h3";
|
|
8
|
+
const Body = para(children);
|
|
9
|
+
return (_jsxs("div", { className: cx("vk-empty", className), children: [_jsxs("div", { className: "vk-empty-glyphs", "aria-hidden": "true", children: [_jsx(SquareGlyph, { children: glyph || "+" }), _jsx("span", { className: "vk-empty-glyph-ghost" }), _jsx("span", { className: "vk-empty-glyph-ghost" })] }), _jsx(HeadingTag, { className: "vk-empty-title", children: title }), children ? _jsx(Body, { className: "vk-empty-text", children: children }) : null, actions ? _jsx("div", { className: "vk-row vk-empty-actions", children: actions }) : null] }));
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface ErrorSummaryProps {
|
|
2
|
+
errors: {
|
|
3
|
+
field?: string;
|
|
4
|
+
message: string;
|
|
5
|
+
}[];
|
|
6
|
+
title?: string;
|
|
7
|
+
autoFocus?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/** A form's problems at the top of the form after a failed submit; each item links to its field. */
|
|
10
|
+
export declare function ErrorSummary(props: ErrorSummaryProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useRef } from "react";
|
|
4
|
+
import { Icon } from "../Icon/Icon.js";
|
|
5
|
+
/** A form's problems at the top of the form after a failed submit; each item links to its field. */
|
|
6
|
+
export function ErrorSummary(props) {
|
|
7
|
+
const ref = useRef(null);
|
|
8
|
+
const errors = props.errors || [];
|
|
9
|
+
// Focus follows a change in the number of errors, not a change of autoFocus: the effect reads the latest value.
|
|
10
|
+
const autoFocusRef = useRef(props.autoFocus);
|
|
11
|
+
useEffect(() => { autoFocusRef.current = props.autoFocus; }, [props.autoFocus]);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (errors.length && ref.current && autoFocusRef.current !== false)
|
|
14
|
+
ref.current.focus();
|
|
15
|
+
}, [errors.length]);
|
|
16
|
+
if (!errors.length)
|
|
17
|
+
return null;
|
|
18
|
+
const title = props.title || (errors.length === 1 ? "Fix 1 problem to continue" : "Fix " + errors.length + " problems to continue");
|
|
19
|
+
return (_jsxs("div", { ref: ref, tabIndex: -1, role: "alert", className: "vk-alert vk-alert-danger vk-error-summary", "aria-labelledby": "vk-errsum-title", children: [_jsx(Icon, { name: "circle-alert", size: 18, className: "vk-alert-icon" }), _jsxs("div", { className: "vk-alert-body", children: [_jsx("p", { id: "vk-errsum-title", className: "vk-alert-title", children: title }), _jsx("ul", { className: "vk-error-summary-list", children: errors.map(({ field, message }) => (_jsx("li", { children: field ? (_jsx("a", { href: "#" + field, className: "vk-link", onClick: (ev) => {
|
|
20
|
+
const el = document.getElementById(field);
|
|
21
|
+
if (el) {
|
|
22
|
+
ev.preventDefault();
|
|
23
|
+
el.focus();
|
|
24
|
+
if (el.scrollIntoView)
|
|
25
|
+
el.scrollIntoView({ block: "center" });
|
|
26
|
+
}
|
|
27
|
+
}, children: message })) : (message) }, field || message))) })] })] }));
|
|
28
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Question-and-answer panels as a description list. */
|
|
2
|
+
export interface FaqListProps {
|
|
3
|
+
items: {
|
|
4
|
+
question: string;
|
|
5
|
+
answer: string;
|
|
6
|
+
}[];
|
|
7
|
+
columns?: 1 | 2;
|
|
8
|
+
}
|
|
9
|
+
/** Question-and-answer panels as a description list. */
|
|
10
|
+
export declare function FaqList({ items, columns }: FaqListProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cx } from "../../lib/cx.js";
|
|
3
|
+
/** Question-and-answer panels as a description list. */
|
|
4
|
+
export function FaqList({ items, columns }) {
|
|
5
|
+
return (_jsx("dl", { className: cx("vk-faq-list", columns === 2 && "vk-faq-list-2"), children: (items || []).map((item) => (_jsxs("div", { className: "vk-faq-item", children: [_jsx("dt", { className: "vk-faq-question", children: item.question }), _jsx("dd", { className: "vk-faq-answer", children: item.answer })] }, item.question))) }));
|
|
6
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ReactElement, type ReactNode } from "react";
|
|
2
|
+
export interface FieldProps {
|
|
3
|
+
label: ReactNode;
|
|
4
|
+
children: ReactElement;
|
|
5
|
+
hint?: ReactNode;
|
|
6
|
+
error?: ReactNode;
|
|
7
|
+
optional?: string;
|
|
8
|
+
id?: string;
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
/** Label (Radix Label), hint and error around one control; wires id, aria-describedby and aria-invalid onto the child. */
|
|
12
|
+
export declare function Field(props: FieldProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cloneElement, isValidElement } from "react";
|
|
4
|
+
import { Label } from "radix-ui";
|
|
5
|
+
import { useUid } from "../../internal/useUid.js";
|
|
6
|
+
import { cx } from "../../lib/cx.js";
|
|
7
|
+
/** Label (Radix Label), hint and error around one control; wires id, aria-describedby and aria-invalid onto the child. */
|
|
8
|
+
export function Field(props) {
|
|
9
|
+
const uid = useUid("vk-field");
|
|
10
|
+
const id = props.id || uid;
|
|
11
|
+
const describedBy = [props.hint ? id + "-hint" : null, props.error ? id + "-error" : null].filter(Boolean).join(" ") || undefined;
|
|
12
|
+
const labelId = id + "-label";
|
|
13
|
+
const control = isValidElement(props.children)
|
|
14
|
+
? cloneElement(props.children, { id, "aria-labelledby": labelId, "aria-describedby": describedBy, "aria-invalid": props.error ? true : undefined })
|
|
15
|
+
: props.children;
|
|
16
|
+
// A custom combobox only takes focus from its label; the click is not forwarded to it.
|
|
17
|
+
const focusControl = (e) => {
|
|
18
|
+
const el = document.getElementById(id);
|
|
19
|
+
if (el && el.getAttribute("role") === "combobox") {
|
|
20
|
+
e.preventDefault();
|
|
21
|
+
el.focus();
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
return (_jsxs("div", { className: cx("vk-field", props.className), children: [_jsxs(Label.Root, { id: labelId, className: "vk-field-label", htmlFor: id, onClick: focusControl, children: [props.label, props.optional ? _jsx("span", { className: "vk-field-optional", children: " " + props.optional }) : null] }), control, props.hint ? _jsx("span", { id: id + "-hint", className: "vk-field-hint", children: props.hint }) : null, props.error ? _jsx("span", { id: id + "-error", className: "vk-field-error", children: props.error }) : null] }));
|
|
25
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export interface FigureProps {
|
|
3
|
+
src?: string;
|
|
4
|
+
alt?: string;
|
|
5
|
+
ratio?: string;
|
|
6
|
+
caption?: ReactNode;
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
/** An image (or any media) with a caption. */
|
|
11
|
+
export declare function Figure({ src, alt, ratio, caption, children, className }: FigureProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cx } from "../../lib/cx.js";
|
|
3
|
+
/** An image (or any media) with a caption. */
|
|
4
|
+
export function Figure({ src, alt, ratio, caption, children, className }) {
|
|
5
|
+
return (_jsxs("figure", { className: cx("vk-figure", className), children: [_jsx("div", { className: "vk-figure-media", style: ratio ? { aspectRatio: ratio } : undefined, children: src ? _jsx("img", { src: src, alt: alt || "", loading: "lazy" }) : children }), caption ? _jsx("figcaption", { className: "vk-figure-caption", children: caption }) : null] }));
|
|
6
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export interface FileEntry {
|
|
3
|
+
name: string;
|
|
4
|
+
size: number;
|
|
5
|
+
file?: File;
|
|
6
|
+
error?: string | null;
|
|
7
|
+
}
|
|
8
|
+
export interface FileUploadProps {
|
|
9
|
+
accept?: string;
|
|
10
|
+
multiple?: boolean;
|
|
11
|
+
maxSize?: number;
|
|
12
|
+
name?: string;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
title?: string;
|
|
15
|
+
hint?: ReactNode;
|
|
16
|
+
defaultFiles?: FileEntry[];
|
|
17
|
+
onChange?: (files: File[], entries: FileEntry[]) => void;
|
|
18
|
+
id?: string;
|
|
19
|
+
className?: string;
|
|
20
|
+
'aria-label'?: string;
|
|
21
|
+
'aria-labelledby'?: string;
|
|
22
|
+
'aria-describedby'?: string;
|
|
23
|
+
}
|
|
24
|
+
/** Drop zone with a browse button for attaching files, and a list of the chosen files with sizes and errors. */
|
|
25
|
+
export declare function FileUpload(props: FileUploadProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useRef, useState } from "react";
|
|
4
|
+
import { Icon } from "../Icon/Icon.js";
|
|
5
|
+
import { IconButton } from "../IconButton/IconButton.js";
|
|
6
|
+
import { useUid } from "../../internal/useUid.js";
|
|
7
|
+
import { cx } from "../../lib/cx.js";
|
|
8
|
+
import { formatBytes } from "../../lib/format.js";
|
|
9
|
+
import { para } from "../../lib/text.js";
|
|
10
|
+
/** Drop zone with a browse button for attaching files, and a list of the chosen files with sizes and errors. */
|
|
11
|
+
export function FileUpload(props) {
|
|
12
|
+
const uid = useUid("vk-file");
|
|
13
|
+
const id = props.id || uid;
|
|
14
|
+
const [files, setFiles] = useState(props.defaultFiles || []);
|
|
15
|
+
const [dragging, setDragging] = useState(false);
|
|
16
|
+
const inputRef = useRef(null);
|
|
17
|
+
const update = (next) => {
|
|
18
|
+
setFiles(next);
|
|
19
|
+
// Entries from defaultFiles have no File; they are only in `entries`.
|
|
20
|
+
props.onChange?.(next.flatMap((f) => (!f.error && f.file ? [f.file] : [])), next);
|
|
21
|
+
};
|
|
22
|
+
const accept = (list) => {
|
|
23
|
+
const incoming = Array.from(list, (f) => {
|
|
24
|
+
const error = props.maxSize && f.size > props.maxSize ? "Larger than " + formatBytes(props.maxSize) + "." : null;
|
|
25
|
+
return { name: f.name, size: f.size, file: f, error };
|
|
26
|
+
});
|
|
27
|
+
update(props.multiple ? files.concat(incoming) : incoming.slice(0, 1));
|
|
28
|
+
};
|
|
29
|
+
const remove = (i) => update(files.filter((_, j) => j !== i));
|
|
30
|
+
const Hint = para(props.hint);
|
|
31
|
+
return (_jsxs("div", { className: cx("vk-upload", props.className), children: [_jsxs("div", { className: cx("vk-dropzone", dragging && "vk-dropzone-active", props.disabled && "vk-dropzone-disabled"), onDragOver: (e) => {
|
|
32
|
+
if (props.disabled)
|
|
33
|
+
return;
|
|
34
|
+
e.preventDefault();
|
|
35
|
+
setDragging(true);
|
|
36
|
+
}, onDragLeave: () => setDragging(false), onDrop: (e) => {
|
|
37
|
+
e.preventDefault();
|
|
38
|
+
setDragging(false);
|
|
39
|
+
if (!props.disabled)
|
|
40
|
+
accept(e.dataTransfer.files);
|
|
41
|
+
}, children: [_jsx(Icon, { name: "upload", className: "vk-dropzone-icon" }), _jsxs("div", { className: "vk-dropzone-text", children: [_jsxs("p", { className: "vk-dropzone-title", children: [props.title || (props.multiple ? "Drop files here" : "Drop a file here"), " or ", _jsx("button", { type: "button", className: "vk-link vk-dropzone-browse", disabled: props.disabled, onClick: () => inputRef.current?.click(), children: "browse" })] }), props.hint ? _jsx(Hint, { className: "vk-dropzone-hint", children: props.hint }) : null] }), _jsx("input", { ref: inputRef, id: id, type: "file", className: "vk-sr-only", tabIndex: -1, accept: props.accept, multiple: props.multiple, disabled: props.disabled, name: props.name, "aria-label": props["aria-label"], "aria-labelledby": props["aria-labelledby"], "aria-describedby": props["aria-describedby"], onChange: (e) => {
|
|
42
|
+
// A file input always has a FileList.
|
|
43
|
+
accept(e.target.files);
|
|
44
|
+
// Clear it so choosing the same file again still fires onChange.
|
|
45
|
+
e.target.value = "";
|
|
46
|
+
} })] }), files.length ? (_jsx("ul", { className: "vk-upload-list", children: files.map((f, i) => (_jsxs("li", { className: cx("vk-upload-item", f.error && "vk-upload-item-error"), children: [_jsx(Icon, { name: f.error ? "circle-alert" : "file", size: 16, className: "vk-upload-icon" }), _jsx("span", { className: "vk-upload-name", children: f.name }), f.error ? _jsx("span", { className: "vk-upload-error", children: f.error }) : _jsx("span", { className: "vk-upload-size", children: formatBytes(f.size) }), _jsx(IconButton, { icon: "x", size: 16, label: "Remove " + f.name, onClick: () => remove(i) })] }, f.name + i))) })) : null] }));
|
|
47
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CSSProperties, ReactNode } from "react";
|
|
2
|
+
import type { AsProp, SpaceStep } from "../../types.js";
|
|
3
|
+
export interface GridProps extends AsProp {
|
|
4
|
+
columns?: number;
|
|
5
|
+
min?: string;
|
|
6
|
+
gap?: SpaceStep | string;
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
className?: string;
|
|
9
|
+
style?: CSSProperties;
|
|
10
|
+
}
|
|
11
|
+
/** A responsive grid: a fixed number of columns, or as many columns of at least `min` width as fit. */
|
|
12
|
+
export declare function Grid({ as, columns, min, gap, children, className, style }: GridProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cx } from "../../lib/cx.js";
|
|
3
|
+
import { space } from "../../lib/space.js";
|
|
4
|
+
/** A responsive grid: a fixed number of columns, or as many columns of at least `min` width as fit. */
|
|
5
|
+
export function Grid({ as, columns, min, gap, children, className, style }) {
|
|
6
|
+
const Tag = as || "div";
|
|
7
|
+
const fixed = typeof columns === "number";
|
|
8
|
+
const template = fixed ? "repeat(" + columns + ", minmax(0, 1fr))" : "repeat(auto-fit, minmax(min(" + (min || "16rem") + ", 100%), 1fr))";
|
|
9
|
+
return _jsx(Tag, { className: cx("vk-layout-grid", fixed ? "vk-layout-grid-fixed" : null, className), style: { gap: space(gap, "lg"), gridTemplateColumns: template, ...style }, children: children });
|
|
10
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export interface HeadingProps {
|
|
3
|
+
level?: 1 | 2 | 3 | 4;
|
|
4
|
+
size?: string;
|
|
5
|
+
id?: string;
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
/** The text style each heading level uses unless `size` says otherwise. */
|
|
10
|
+
export declare const HEADING_SIZE: Record<1 | 2 | 3 | 4, string>;
|
|
11
|
+
/** A heading at the right level with the right type style; structure and visual size can differ. */
|
|
12
|
+
export declare function Heading({ level: levelProp, size, id, children, className }: HeadingProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cx } from "../../lib/cx.js";
|
|
3
|
+
/** The text style each heading level uses unless `size` says otherwise. */
|
|
4
|
+
export const HEADING_SIZE = { 1: "heading-1", 2: "heading-2", 3: "title", 4: "title-sm" };
|
|
5
|
+
/** A heading at the right level with the right type style; structure and visual size can differ. */
|
|
6
|
+
export function Heading({ level: levelProp, size, id, children, className }) {
|
|
7
|
+
const level = levelProp || 2;
|
|
8
|
+
const style = size || HEADING_SIZE[level];
|
|
9
|
+
const Tag = `h${level}`;
|
|
10
|
+
return _jsx(Tag, { id: id, className: cx("vk-heading", "vk-text-" + style, className), children: children });
|
|
11
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IconName } from "../../types.js";
|
|
2
|
+
export interface IconProps {
|
|
3
|
+
name: IconName;
|
|
4
|
+
size?: number;
|
|
5
|
+
className?: string;
|
|
6
|
+
}
|
|
7
|
+
/** Lucide outline icon, stroke currentColor. */
|
|
8
|
+
export declare function Icon({ name, size, className }: IconProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cx } from "../../lib/cx.js";
|
|
3
|
+
import { ICONS } from "../../lib/icons.js";
|
|
4
|
+
/** Lucide outline icon, stroke currentColor. */
|
|
5
|
+
export function Icon({ name, size, className }) {
|
|
6
|
+
const def = ICONS[name];
|
|
7
|
+
if (!def)
|
|
8
|
+
return null;
|
|
9
|
+
const px = size || def.size;
|
|
10
|
+
const common = { stroke: "currentColor", strokeWidth: def.stroke, strokeLinecap: "round", strokeLinejoin: "round" };
|
|
11
|
+
const circles = def.circle ? (Array.isArray(def.circle) ? def.circle : [def.circle]) : [];
|
|
12
|
+
const kids = [
|
|
13
|
+
...def.d.map((d, i) => _jsx("path", { d: d, ...common }, i)),
|
|
14
|
+
...circles.map((c, i) => _jsx("circle", { ...c, ...common }, "c" + i)),
|
|
15
|
+
];
|
|
16
|
+
return (_jsx("svg", { className: cx("vk-icon", className), viewBox: "0 0 24 24", width: px, height: px, fill: "none", "aria-hidden": "true", children: kids }));
|
|
17
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type AnchorHTMLAttributes, type ButtonHTMLAttributes } from "react";
|
|
2
|
+
import type { IconName } from "../../types.js";
|
|
3
|
+
export interface IconButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement> & AnchorHTMLAttributes<HTMLAnchorElement>, 'children'> {
|
|
4
|
+
icon: IconName;
|
|
5
|
+
label: string;
|
|
6
|
+
variant?: 'ghost' | 'outline';
|
|
7
|
+
size?: number;
|
|
8
|
+
href?: string;
|
|
9
|
+
}
|
|
10
|
+
/** Square icon-only button; label becomes aria-label and tooltip. */
|
|
11
|
+
export declare const IconButton: import("react").ForwardRefExoticComponent<IconButtonProps & import("react").RefAttributes<HTMLButtonElement & HTMLAnchorElement>>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { Icon } from "../Icon/Icon.js";
|
|
4
|
+
import { Anchor } from "../LinkProvider/LinkProvider.js";
|
|
5
|
+
import { cx } from "../../lib/cx.js";
|
|
6
|
+
import { omit } from "../../lib/omit.js";
|
|
7
|
+
/** Square icon-only button; label becomes aria-label and tooltip. */
|
|
8
|
+
export const IconButton = forwardRef(function IconButton(props, ref) {
|
|
9
|
+
const rest = omit(props, ["icon", "label", "variant", "href", "size", "className"]);
|
|
10
|
+
const className = cx("vk-icon-btn", "vk-icon-btn-" + (props.variant || "ghost"), props.className);
|
|
11
|
+
const glyph = _jsx(Icon, { name: props.icon, size: props.size });
|
|
12
|
+
if (props.href) {
|
|
13
|
+
return (_jsx(Anchor, { ref: ref, href: props.href, className: className, "aria-label": props.label, title: props.label, ...rest, children: glyph }));
|
|
14
|
+
}
|
|
15
|
+
return (_jsx("button", { ref: ref, type: "button", className: className, "aria-label": props.label, title: props.label, ...rest, children: glyph }));
|
|
16
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CSSProperties, ReactNode } from "react";
|
|
2
|
+
import type { AsProp, SpaceStep } from "../../types.js";
|
|
3
|
+
export interface InlineProps extends AsProp {
|
|
4
|
+
gap?: SpaceStep | string;
|
|
5
|
+
align?: CSSProperties['alignItems'];
|
|
6
|
+
justify?: CSSProperties['justifyContent'];
|
|
7
|
+
wrap?: boolean;
|
|
8
|
+
children?: ReactNode;
|
|
9
|
+
className?: string;
|
|
10
|
+
style?: CSSProperties;
|
|
11
|
+
}
|
|
12
|
+
/** Lays children out in a row that wraps, with one gap. */
|
|
13
|
+
export declare function Inline({ as, gap, align, justify, wrap, children, className, style }: InlineProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cx } from "../../lib/cx.js";
|
|
3
|
+
import { space } from "../../lib/space.js";
|
|
4
|
+
/** Lays children out in a row that wraps, with one gap. */
|
|
5
|
+
export function Inline({ as, gap, align, justify, wrap, children, className, style }) {
|
|
6
|
+
const Tag = as || "div";
|
|
7
|
+
return (_jsx(Tag, { className: cx("vk-layout-inline", className), style: { gap: space(gap, "sm"), alignItems: align || "center", justifyContent: justify, flexWrap: wrap === false ? "nowrap" : "wrap", ...style }, children: children }));
|
|
8
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type InputHTMLAttributes, type ReactNode } from "react";
|
|
2
|
+
export interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'prefix'> {
|
|
3
|
+
prefix?: ReactNode;
|
|
4
|
+
suffix?: ReactNode;
|
|
5
|
+
/** With maxLength: shows "n / max" under the field. */
|
|
6
|
+
showCount?: boolean;
|
|
7
|
+
inputClassName?: string;
|
|
8
|
+
}
|
|
9
|
+
/** Single-line text control, with optional add-ons and a character count. The ref is the <input>. */
|
|
10
|
+
export declare const Input: import("react").ForwardRefExoticComponent<InputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import { CharCount, useControlledText } from "../../internal/CharCount.js";
|
|
5
|
+
import { cx } from "../../lib/cx.js";
|
|
6
|
+
import { omit } from "../../lib/omit.js";
|
|
7
|
+
// A prefix or suffix beside the field; plain text is hidden from assistive tech.
|
|
8
|
+
function Addon({ side, children }) {
|
|
9
|
+
if (!children)
|
|
10
|
+
return null;
|
|
11
|
+
return (_jsx("span", { className: "vk-affix-addon vk-affix-" + side, "aria-hidden": typeof children === "string" ? "true" : undefined, children: children }));
|
|
12
|
+
}
|
|
13
|
+
/** Single-line text control, with optional add-ons and a character count. The ref is the <input>. */
|
|
14
|
+
export const Input = forwardRef(function Input(props, ref) {
|
|
15
|
+
const txt = useControlledText(props);
|
|
16
|
+
// The counter's limit; 0 when there is no counter (the native maxLength applies instead).
|
|
17
|
+
const countMax = props.showCount && props.maxLength ? props.maxLength : 0;
|
|
18
|
+
// Add-ons or a counter put the field in a wrapper, which then takes className.
|
|
19
|
+
const wrapped = !!(props.prefix || props.suffix || countMax);
|
|
20
|
+
const rest = omit(props, ["className", "prefix", "suffix", "showCount", "value", "defaultValue", "onChange", "inputClassName"]);
|
|
21
|
+
const input = (_jsx("input", { type: "text", ref: ref, ...rest, value: txt.value, onChange: txt.onChange, maxLength: countMax ? undefined : props.maxLength, className: cx("vk-input", props.prefix ? "vk-input-has-prefix" : null, props.suffix ? "vk-input-has-suffix" : null, props.inputClassName, wrapped ? null : props.className) }));
|
|
22
|
+
if (!wrapped)
|
|
23
|
+
return input;
|
|
24
|
+
return (_jsxs("span", { className: cx("vk-affix", props.className), children: [_jsxs("span", { className: "vk-affix-row", children: [_jsx(Addon, { side: "prefix", children: props.prefix }), input, _jsx(Addon, { side: "suffix", children: props.suffix })] }), countMax ? _jsx(CharCount, { value: txt.value, max: countMax }) : null] }));
|
|
25
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export interface KbdProps {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
className?: string;
|
|
5
|
+
}
|
|
6
|
+
/** A keyboard key, for shortcuts in help text, menus and tooltips. */
|
|
7
|
+
export declare function Kbd({ children, className }: KbdProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cx } from "../../lib/cx.js";
|
|
3
|
+
/** A keyboard key, for shortcuts in help text, menus and tooltips. */
|
|
4
|
+
export function Kbd({ children, className }) {
|
|
5
|
+
return _jsx("kbd", { className: cx("vk-kbd", className), children: children });
|
|
6
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ChartProps } from "../../types.js";
|
|
2
|
+
export interface LineChartProps<Row = Record<string, unknown>> extends ChartProps<Row> {
|
|
3
|
+
/** Label each line at its end instead of in a legend (up to four series). Default true. */
|
|
4
|
+
directLabels?: boolean;
|
|
5
|
+
}
|
|
6
|
+
/** Lines for change over time: one to four series, each labeled directly at its end. */
|
|
7
|
+
export declare function LineChart<Row = Record<string, unknown>>(props: LineChartProps<Row>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { ChartFrame, cellLabel, cellNumber, chartKeys, chartTooltip, seriesColor, useChart } from "../../charts/chart.js";
|
|
4
|
+
import { niceTicks } from "../../lib/math.js";
|
|
5
|
+
/** Lines for change over time: one to four series, each labeled directly at its end. */
|
|
6
|
+
export function LineChart(props) {
|
|
7
|
+
const c = useChart(props);
|
|
8
|
+
const data = props.data || [];
|
|
9
|
+
const height = props.height || 240;
|
|
10
|
+
const label = c.series.length <= 4 && props.directLabels !== false;
|
|
11
|
+
const pad = { top: 12, right: label ? 96 : 12, bottom: 28, left: 48 };
|
|
12
|
+
let max = 0;
|
|
13
|
+
for (const d of data)
|
|
14
|
+
for (const s of c.series)
|
|
15
|
+
max = Math.max(max, cellNumber(d, s.key));
|
|
16
|
+
const ticks = niceTicks(max, 4), top = ticks[ticks.length - 1];
|
|
17
|
+
const plotW = Math.max(10, c.width - pad.left - pad.right), plotH = height - pad.top - pad.bottom;
|
|
18
|
+
const x = (i) => pad.left + (data.length < 2 ? plotW / 2 : (plotW * i) / (data.length - 1));
|
|
19
|
+
const y = (v) => pad.top + plotH - (v / top) * plotH;
|
|
20
|
+
const fmtTick = props.tickFormat || c.fmt;
|
|
21
|
+
// Label every nth point so x labels stay about 72px apart.
|
|
22
|
+
const every = Math.max(1, Math.ceil(data.length / Math.max(2, Math.floor(plotW / 72))));
|
|
23
|
+
const view = { ...props, data, series: c.series, format: c.fmt, xKey: c.xKey };
|
|
24
|
+
const lastY = [];
|
|
25
|
+
const onMouseMove = (e) => {
|
|
26
|
+
const r = e.currentTarget.getBoundingClientRect(), px = e.clientX - r.left;
|
|
27
|
+
const i = Math.round(((px - pad.left) / plotW) * (data.length - 1));
|
|
28
|
+
c.setActive(Math.max(0, Math.min(data.length - 1, i)));
|
|
29
|
+
};
|
|
30
|
+
return (_jsx(ChartFrame, { ...view, children: _jsxs("div", { ref: c.ref, className: "vk-chart-plot", tabIndex: 0, role: "img", "aria-label": (props.title || "Line chart") + ". Use the arrow keys to read each value.", onKeyDown: chartKeys(c, data.length), onMouseLeave: () => c.setActive(null), onBlur: () => c.setActive(null), onMouseMove: onMouseMove, children: [_jsxs("svg", { width: c.width, height: height, viewBox: "0 0 " + c.width + " " + height, "aria-hidden": "true", className: "vk-chart-svg", children: [ticks.map((t) => (_jsxs("g", { children: [_jsx("line", { x1: pad.left, x2: pad.left + plotW, y1: y(t), y2: y(t), className: t === 0 ? "vk-chart-baseline" : "vk-chart-grid" }), _jsx("text", { x: pad.left - 8, y: y(t), dy: "0.32em", textAnchor: "end", className: "vk-chart-tick", children: fmtTick(t) })] }, t))), data.map((d, i) => i % every === 0 || i === data.length - 1 ? _jsx("text", { x: x(i), y: height - 8, textAnchor: i === 0 ? "start" : i === data.length - 1 ? "end" : "middle", className: "vk-chart-tick", children: cellLabel(d, c.xKey) }, "x" + i) : null), c.active != null ? _jsx("line", { x1: x(c.active), x2: x(c.active), y1: pad.top, y2: pad.top + plotH, className: "vk-chart-crosshair" }) : null, c.series.map((s, si) => {
|
|
31
|
+
const pts = data.map((d, i) => x(i) + "," + y(cellNumber(d, s.key))).join(" ");
|
|
32
|
+
return _jsx("polyline", { points: pts, fill: "none", stroke: seriesColor(si), strokeWidth: 2, strokeLinejoin: "round", strokeLinecap: "round" }, s.key);
|
|
33
|
+
}), c.series.map((s, si) => {
|
|
34
|
+
// A point on each line at the active row, or at the last one.
|
|
35
|
+
const i = c.active == null ? data.length - 1 : c.active;
|
|
36
|
+
const d = data[i];
|
|
37
|
+
if (!d)
|
|
38
|
+
return null;
|
|
39
|
+
return _jsx("circle", { cx: x(i), cy: y(cellNumber(d, s.key)), r: 4, fill: seriesColor(si), className: "vk-chart-point" }, "p" + s.key);
|
|
40
|
+
}), label
|
|
41
|
+
? c.series.map((s) => {
|
|
42
|
+
const d = data[data.length - 1];
|
|
43
|
+
if (!d)
|
|
44
|
+
return null;
|
|
45
|
+
// Push a label down when it would overlap one already placed.
|
|
46
|
+
let ly = y(cellNumber(d, s.key));
|
|
47
|
+
lastY.forEach((o) => { if (Math.abs(o - ly) < 14)
|
|
48
|
+
ly = o + 14; });
|
|
49
|
+
lastY.push(ly);
|
|
50
|
+
return _jsx("text", { x: x(data.length - 1) + 10, y: ly, dy: "0.32em", className: "vk-chart-direct", children: s.label }, "l" + s.key);
|
|
51
|
+
})
|
|
52
|
+
: null] }), chartTooltip(view, c.active, c.active == null ? 0 : x(c.active), c.width)] }) }));
|
|
53
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type AnchorHTMLAttributes } from "react";
|
|
2
|
+
export interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
3
|
+
tone?: 'default' | 'muted';
|
|
4
|
+
external?: boolean;
|
|
5
|
+
}
|
|
6
|
+
/** Inline text link. */
|
|
7
|
+
export declare const Link: import("react").ForwardRefExoticComponent<LinkProps & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { Icon } from "../Icon/Icon.js";
|
|
4
|
+
import { Anchor } from "../LinkProvider/LinkProvider.js";
|
|
5
|
+
import { cx } from "../../lib/cx.js";
|
|
6
|
+
import { omit } from "../../lib/omit.js";
|
|
7
|
+
/** Inline text link. */
|
|
8
|
+
export const Link = forwardRef(function Link(props, ref) {
|
|
9
|
+
const rest = omit(props, ["tone", "external", "className", "children"]);
|
|
10
|
+
const ext = props.external ? { target: "_blank", rel: "noopener noreferrer" } : {};
|
|
11
|
+
return (_jsxs(Anchor, { ref: ref, className: cx("vk-link", props.tone === "muted" && "vk-link-muted", props.className), ...ext, ...rest, children: [props.children, props.external ? _jsx(Icon, { name: "arrow-up-right", size: 13, className: "vk-link-icon" }) : null] }));
|
|
12
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { AnchorHTMLAttributes, ElementType, ReactNode } from "react";
|
|
2
|
+
/** Any link component that takes href, className and children, such as Next.js's Link. */
|
|
3
|
+
export type LinkComponent = ElementType<{
|
|
4
|
+
href: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
} & Record<string, unknown>>;
|
|
8
|
+
export interface LinkProviderProps {
|
|
9
|
+
component: LinkComponent;
|
|
10
|
+
children?: ReactNode;
|
|
11
|
+
}
|
|
12
|
+
export declare const LinkContext: import("react").Context<LinkComponent | null>;
|
|
13
|
+
/**
|
|
14
|
+
* Renders internal links in Button, IconButton, Link, Card, MediaCard, NavList,
|
|
15
|
+
* Breadcrumbs and ListItem with `component`, so navigation stays client-side.
|
|
16
|
+
* Hash, external, mailto: and tel: links, and links with target or download, stay plain <a>.
|
|
17
|
+
*/
|
|
18
|
+
export declare function LinkProvider({ component, children }: LinkProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
/** Hash links, links with a scheme (https:, mailto:, tel:) and protocol-relative links. */
|
|
20
|
+
export declare const PLAIN_HREF: RegExp;
|
|
21
|
+
/** The <a> behind every link in the system: the LinkProvider's component for internal links, else a plain <a>. */
|
|
22
|
+
export declare const Anchor: import("react").ForwardRefExoticComponent<AnchorHTMLAttributes<HTMLAnchorElement> & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, forwardRef, useContext } from "react";
|
|
4
|
+
export const LinkContext = createContext(null);
|
|
5
|
+
/**
|
|
6
|
+
* Renders internal links in Button, IconButton, Link, Card, MediaCard, NavList,
|
|
7
|
+
* Breadcrumbs and ListItem with `component`, so navigation stays client-side.
|
|
8
|
+
* Hash, external, mailto: and tel: links, and links with target or download, stay plain <a>.
|
|
9
|
+
*/
|
|
10
|
+
export function LinkProvider({ component, children }) {
|
|
11
|
+
return _jsx(LinkContext.Provider, { value: component || null, children: children });
|
|
12
|
+
}
|
|
13
|
+
/** Hash links, links with a scheme (https:, mailto:, tel:) and protocol-relative links. */
|
|
14
|
+
export const PLAIN_HREF = /^(#|[a-z][a-z0-9+.-]*:|\/\/)/i;
|
|
15
|
+
/** The <a> behind every link in the system: the LinkProvider's component for internal links, else a plain <a>. */
|
|
16
|
+
export const Anchor = forwardRef(function Anchor(props, ref) {
|
|
17
|
+
const Comp = useContext(LinkContext);
|
|
18
|
+
if (!Comp || typeof props.href !== "string" || PLAIN_HREF.test(props.href) || props.target || props.download)
|
|
19
|
+
return _jsx("a", { ref: ref, ...props });
|
|
20
|
+
return _jsx(Comp, { ref: ref, ...props });
|
|
21
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { AsProp } from "../../types.js";
|
|
3
|
+
export interface ListProps extends AsProp {
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
divided?: boolean;
|
|
6
|
+
bordered?: boolean;
|
|
7
|
+
label?: string;
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ListItemProps {
|
|
11
|
+
title: ReactNode;
|
|
12
|
+
description?: ReactNode;
|
|
13
|
+
meta?: ReactNode;
|
|
14
|
+
leading?: ReactNode;
|
|
15
|
+
trailing?: ReactNode;
|
|
16
|
+
href?: string;
|
|
17
|
+
onClick?: () => void;
|
|
18
|
+
selected?: boolean;
|
|
19
|
+
className?: string;
|
|
20
|
+
}
|
|
21
|
+
/** Rows of records: people, files, notifications, recent items. */
|
|
22
|
+
export declare function List({ as, children, divided, bordered, label, className }: ListProps): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
/** One row of a List: a leading element, a title and description, metadata and trailing actions. */
|
|
24
|
+
export declare function ListItem({ title, description, meta, leading, trailing, href, onClick, selected, className }: ListItemProps): import("react/jsx-runtime").JSX.Element;
|