@vokality/design-system 1.3.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +54 -0
- package/README.md +51 -5
- package/dist/browser.d.ts +13 -0
- package/dist/browser.js +7 -0
- package/dist/charts/chart.d.ts +6 -5
- package/dist/charts/chart.js +44 -25
- package/dist/chat.d.ts +54 -0
- package/dist/chat.js +1 -0
- package/dist/components/Accordion/Accordion.js +1 -1
- package/dist/components/Alert/Alert.js +5 -2
- package/dist/components/AppShell/AppShell.js +10 -14
- package/dist/components/Avatar/Avatar.js +2 -2
- package/dist/components/AvatarGroup/AvatarGroup.js +2 -2
- package/dist/components/BarChart/BarChart.js +17 -15
- package/dist/components/Breadcrumbs/Breadcrumbs.js +6 -3
- package/dist/components/Calendar/Calendar.js +6 -5
- package/dist/components/Card/Card.js +2 -3
- package/dist/components/ChatInbox/ChatInbox.d.ts +11 -0
- package/dist/components/ChatInbox/ChatInbox.js +49 -0
- package/dist/components/ChatPanel/ChatPanel.d.ts +3 -0
- package/dist/components/ChatPanel/ChatPanel.js +13 -0
- package/dist/components/ChatPanel/composer.d.ts +5 -0
- package/dist/components/ChatPanel/composer.js +32 -0
- package/dist/components/ChatPanel/transcript.d.ts +13 -0
- package/dist/components/ChatPanel/transcript.js +39 -0
- package/dist/components/ChatWidget/ChatWidget.d.ts +12 -0
- package/dist/components/ChatWidget/ChatWidget.js +42 -0
- package/dist/components/Checkbox/Checkbox.d.ts +5 -10
- package/dist/components/Checkbox/Checkbox.js +5 -19
- package/dist/components/CodeBlock/CodeBlock.js +19 -5
- package/dist/components/Combobox/Combobox.js +22 -15
- package/dist/components/Combobox/ListPanel.js +20 -9
- package/dist/components/CommandPalette/CommandPalette.js +33 -14
- package/dist/components/ContextMenu/ContextMenu.d.ts +2 -2
- package/dist/components/ContextMenu/ContextMenu.js +5 -50
- package/dist/components/DatePicker/DatePicker.js +35 -29
- package/dist/components/DescriptionList/DescriptionList.js +1 -1
- package/dist/components/Dialog/Dialog.d.ts +24 -7
- package/dist/components/Dialog/Dialog.js +30 -41
- package/dist/components/Drawer/Drawer.d.ts +4 -2
- package/dist/components/EmptyState/EmptyState.js +2 -2
- package/dist/components/ErrorSummary/ErrorSummary.js +5 -3
- package/dist/components/FaqList/FaqList.js +1 -1
- package/dist/components/Field/Field.js +4 -4
- package/dist/components/Fieldset/Fieldset.js +3 -3
- package/dist/components/FileUpload/FileUpload.js +17 -9
- package/dist/components/Grid/Grid.d.ts +867 -5
- package/dist/components/Grid/Grid.js +3 -4
- package/dist/components/Heading/Heading.js +2 -1
- package/dist/components/Icon/Icon.js +4 -2
- package/dist/components/Inline/Inline.d.ts +867 -5
- package/dist/components/Inline/Inline.js +2 -3
- package/dist/components/LineChart/LineChart.js +17 -15
- package/dist/components/LinkProvider/LinkProvider.d.ts +1 -1
- package/dist/components/LinkProvider/LinkProvider.js +6 -2
- package/dist/components/List/List.js +1 -1
- package/dist/components/MediaCard/MediaCard.js +2 -2
- package/dist/components/Menu/Menu.js +6 -43
- package/dist/components/Menu/entries.d.ts +1 -30
- package/dist/components/Menu/entries.js +16 -100
- package/dist/components/MultiSelect/MultiSelect.js +43 -34
- package/dist/components/NumberInput/NumberInput.js +17 -18
- package/dist/components/OtpInput/OtpInput.d.ts +1 -1
- package/dist/components/OtpInput/OtpInput.js +10 -67
- package/dist/components/PageHeader/PageHeader.js +2 -2
- package/dist/components/Pagination/Pagination.js +3 -1
- package/dist/components/PasswordInput/PasswordInput.d.ts +1 -1
- package/dist/components/PasswordInput/PasswordInput.js +9 -4
- package/dist/components/Popover/Popover.d.ts +6 -7
- package/dist/components/Popover/Popover.js +2 -19
- package/dist/components/Progress/Progress.d.ts +1 -1
- package/dist/components/Progress/Progress.js +7 -11
- package/dist/components/Radio/Radio.d.ts +4 -2
- package/dist/components/RadioGroup/RadioGroup.d.ts +5 -12
- package/dist/components/RadioGroup/RadioGroup.js +6 -33
- package/dist/components/RichTextEditor/RichTextEditor.d.ts +63 -0
- package/dist/components/RichTextEditor/RichTextEditor.js +175 -0
- package/dist/components/RichTextEditor/toolbar.d.ts +15 -0
- package/dist/components/RichTextEditor/toolbar.js +142 -0
- package/dist/components/RichTextEditor/uploads.d.ts +41 -0
- package/dist/components/RichTextEditor/uploads.js +124 -0
- package/dist/components/SearchInput/SearchInput.js +4 -2
- package/dist/components/SectionHeader/SectionHeader.js +1 -3
- package/dist/components/SegmentedControl/SegmentedControl.js +2 -12
- package/dist/components/Select/Select.d.ts +15 -16
- package/dist/components/Select/Select.js +11 -252
- package/dist/components/Slider/Slider.js +11 -21
- package/dist/components/Sparkline/Sparkline.js +8 -3
- package/dist/components/Spinner/Spinner.js +5 -2
- package/dist/components/Stack/Stack.d.ts +867 -5
- package/dist/components/Stack/Stack.js +2 -3
- package/dist/components/Stat/Stat.js +6 -3
- package/dist/components/Steps/Steps.js +6 -3
- package/dist/components/Switch/Switch.d.ts +7 -7
- package/dist/components/Switch/Switch.js +4 -10
- package/dist/components/Table/Table.js +38 -19
- package/dist/components/Tabs/Tabs.js +2 -22
- package/dist/components/Tag/Tag.js +3 -1
- package/dist/components/Text/Text.d.ts +9 -5
- package/dist/components/Text/Text.js +3 -4
- package/dist/components/TileGrid/TileGrid.js +1 -1
- package/dist/components/TimePicker/TimePicker.js +35 -33
- package/dist/components/Timeline/Timeline.js +5 -4
- package/dist/components/Toaster/Toaster.js +21 -17
- package/dist/components/Tooltip/Tooltip.d.ts +6 -6
- package/dist/components/Tooltip/Tooltip.js +3 -17
- package/dist/components/TreeView/TreeView.js +15 -12
- package/dist/components.css +281 -60
- package/dist/hooks/useTheme.js +6 -6
- package/dist/icons/message-circle.svg +1 -0
- package/dist/internal/CharCount.js +3 -1
- package/dist/internal/choice.d.ts +10 -48
- package/dist/internal/choice.js +8 -96
- package/dist/internal/describedBy.d.ts +3 -0
- package/dist/internal/describedBy.js +4 -0
- package/dist/internal/options.d.ts +10 -5
- package/dist/internal/options.js +25 -11
- package/dist/internal/status.d.ts +3 -2
- package/dist/internal/status.js +10 -2
- package/dist/internal/useScrollActive.js +2 -2
- package/dist/internal/useToday.d.ts +3 -0
- package/dist/internal/useToday.js +42 -0
- package/dist/lib/dates.js +25 -15
- package/dist/lib/format.js +11 -8
- package/dist/lib/icons.d.ts +5 -0
- package/dist/lib/icons.js +2 -0
- package/dist/lib/math.js +17 -5
- package/dist/lib/rich-text.d.ts +13 -0
- package/dist/lib/rich-text.js +62 -0
- package/dist/lib/space.d.ts +1 -2
- package/dist/lib/space.js +4 -1
- package/dist/lib/text.js +1 -1
- package/dist/lib/theme.js +1 -1
- package/dist/localization.d.ts +166 -0
- package/dist/localization.js +142 -0
- package/dist/tokens.css +2 -0
- package/dist/tokens.dtcg.json +10 -0
- package/dist/tokens.json +10 -0
- package/dist/types.d.ts +6 -1
- package/dist/vokality.css +283 -60
- package/dist/vokality.iife.js +35981 -9698
- package/docs/brand.md +8 -5
- package/docs/components/AppShell/README.md +1 -1
- package/docs/components/Badge/README.md +1 -1
- package/docs/components/BarChart/README.md +1 -0
- package/docs/components/Button/README.md +4 -2
- package/docs/components/ChatInbox/README.md +41 -0
- package/docs/components/ChatWidget/README.md +47 -0
- package/docs/components/Checkbox/README.md +7 -3
- package/docs/components/ContextMenu/README.md +7 -3
- package/docs/components/Dialog/README.md +9 -4
- package/docs/components/Drawer/README.md +1 -1
- package/docs/components/Field/README.md +1 -1
- package/docs/components/Fieldset/README.md +2 -2
- package/docs/components/Inline/README.md +1 -1
- package/docs/components/LineChart/README.md +1 -0
- package/docs/components/LocaleProvider/README.md +48 -0
- package/docs/components/Menu/README.md +13 -8
- package/docs/components/OtpInput/README.md +9 -5
- package/docs/components/PasswordInput/README.md +11 -2
- package/docs/components/Popover/README.md +6 -3
- package/docs/components/Progress/README.md +3 -1
- package/docs/components/RadioGroup/README.md +5 -2
- package/docs/components/RichTextEditor/README.md +84 -0
- package/docs/components/SegmentedControl/README.md +2 -0
- package/docs/components/Select/README.md +13 -17
- package/docs/components/Skeleton/README.md +1 -1
- package/docs/components/Slider/README.md +4 -2
- package/docs/components/Steps/README.md +1 -1
- package/docs/components/Switch/README.md +5 -2
- package/docs/components/Tabs/README.md +4 -2
- package/docs/components/Text/README.md +1 -1
- package/docs/components/Toaster/README.md +3 -1
- package/docs/components/Tooltip/README.md +5 -3
- package/package.json +49 -5
package/dist/hooks/useTheme.js
CHANGED
|
@@ -4,7 +4,7 @@ import { THEMES } from "../lib/theme.js";
|
|
|
4
4
|
export const THEME_EVENT = "vk-themechange";
|
|
5
5
|
const isTheme = (value) => THEMES.some((t) => t === value);
|
|
6
6
|
export function systemTheme() {
|
|
7
|
-
if (typeof window === "undefined" ||
|
|
7
|
+
if (typeof window === "undefined" || typeof Reflect.get(window, "matchMedia") !== "function")
|
|
8
8
|
return "dark";
|
|
9
9
|
if (window.matchMedia("(prefers-contrast: more)").matches)
|
|
10
10
|
return "contrast";
|
|
@@ -34,7 +34,7 @@ export function useTheme(options) {
|
|
|
34
34
|
const follow = o.followSystem !== false;
|
|
35
35
|
const resolve = useCallback((pref) => (pref !== "system" ? pref : follow ? systemTheme() : fallback), [follow, fallback]);
|
|
36
36
|
const subscribe = useCallback((cb) => {
|
|
37
|
-
const mqs = ["(prefers-contrast: more)", "(prefers-color-scheme: light)"].map((q) => (window
|
|
37
|
+
const mqs = ["(prefers-contrast: more)", "(prefers-color-scheme: light)"].map((q) => (typeof Reflect.get(window, "matchMedia") === "function" ? window.matchMedia(q) : null));
|
|
38
38
|
const onSystem = () => {
|
|
39
39
|
if (readPreference(key) === "system")
|
|
40
40
|
document.documentElement.setAttribute("data-theme", resolve("system"));
|
|
@@ -46,12 +46,12 @@ export function useTheme(options) {
|
|
|
46
46
|
cb();
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
-
mqs.forEach((m) => { if (m && m
|
|
49
|
+
mqs.forEach((m) => { if (m && typeof Reflect.get(m, "addEventListener") === "function")
|
|
50
50
|
m.addEventListener("change", onSystem); });
|
|
51
51
|
window.addEventListener(THEME_EVENT, cb);
|
|
52
52
|
window.addEventListener("storage", onStorage);
|
|
53
53
|
return () => {
|
|
54
|
-
mqs.forEach((m) => { if (m && m
|
|
54
|
+
mqs.forEach((m) => { if (m && typeof Reflect.get(m, "removeEventListener") === "function")
|
|
55
55
|
m.removeEventListener("change", onSystem); });
|
|
56
56
|
window.removeEventListener(THEME_EVENT, cb);
|
|
57
57
|
window.removeEventListener("storage", onStorage);
|
|
@@ -68,14 +68,14 @@ export function useTheme(options) {
|
|
|
68
68
|
else
|
|
69
69
|
window.localStorage.setItem(key, choice);
|
|
70
70
|
}
|
|
71
|
-
catch { }
|
|
71
|
+
catch { /* Private browsing can make storage unavailable; the selected theme still applies. */ }
|
|
72
72
|
document.documentElement.setAttribute("data-theme", resolve(choice));
|
|
73
73
|
window.dispatchEvent(new Event(THEME_EVENT));
|
|
74
74
|
}, [key, resolve]);
|
|
75
75
|
return {
|
|
76
76
|
theme: isTheme(pref) ? pref : "system",
|
|
77
77
|
// Read from <html>'s data-theme, which ThemeScript and setTheme write.
|
|
78
|
-
resolvedTheme: resolved,
|
|
78
|
+
resolvedTheme: isTheme(resolved) ? resolved : fallback,
|
|
79
79
|
setTheme,
|
|
80
80
|
themes: THEMES.slice(),
|
|
81
81
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="#e1dfdb" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719"/></svg>
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useLocale } from "../localization.js";
|
|
3
4
|
import { useState } from "react";
|
|
4
5
|
import { cx } from "../lib/cx.js";
|
|
5
6
|
/** "12 / 280" under a field; announces the characters left once 90% are used. */
|
|
6
7
|
export function CharCount({ value, max }) {
|
|
8
|
+
const { messages } = useLocale();
|
|
7
9
|
const n = String(value || "").length;
|
|
8
10
|
const near = n >= max * 0.9;
|
|
9
|
-
return (_jsxs("span", { className: cx("vk-char-count", n > max && "vk-char-count-over"), "aria-live": near ? "polite" : "off", children: [_jsx("span", { className: "vk-sr-only", children: near ? (max - n >= 0 ? max - n
|
|
11
|
+
return (_jsxs("span", { className: cx("vk-char-count", n > max && "vk-char-count-over"), "aria-live": near ? "polite" : "off", children: [_jsx("span", { className: "vk-sr-only", children: near ? (max - n >= 0 ? messages.charactersLeft(max - n) : messages.charactersOver(n - max)) : "" }), _jsx("span", { "aria-hidden": "true", children: String(n) + " / " + String(max) })] }));
|
|
10
12
|
}
|
|
11
13
|
/** The text of an input that may be controlled (value) or not (defaultValue), so a counter can follow it. */
|
|
12
14
|
export function useControlledText(props) {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
3
|
-
interface
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { RadioProps } from "../components/Radio/Radio.js";
|
|
3
|
+
export interface ChoiceTextProps {
|
|
4
4
|
label: ReactNode;
|
|
5
5
|
description?: ReactNode;
|
|
6
6
|
hideLabel?: boolean;
|
|
7
|
+
}
|
|
8
|
+
interface ChoiceLabelProps extends ChoiceTextProps {
|
|
7
9
|
disabled?: boolean;
|
|
8
10
|
className?: string;
|
|
9
11
|
/** The control's own class on the label, e.g. "vk-switch". */
|
|
@@ -13,53 +15,13 @@ interface ChoiceLabelProps {
|
|
|
13
15
|
}
|
|
14
16
|
/** The label around a choice control, then its label and description; clicking anywhere on it toggles the control. */
|
|
15
17
|
export declare function ChoiceLabel(props: ChoiceLabelProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
-
/**
|
|
18
|
+
/** Extract readable label text when the visible choice label is hidden. */
|
|
17
19
|
export declare function hiddenLabel(props: {
|
|
18
20
|
label: ReactNode;
|
|
19
21
|
hideLabel?: boolean;
|
|
20
22
|
}): string | undefined;
|
|
21
|
-
/**
|
|
22
|
-
export declare function checkMark(
|
|
23
|
-
/**
|
|
24
|
-
export
|
|
25
|
-
type: "checkbox" | "radio";
|
|
26
|
-
checked: boolean;
|
|
27
|
-
value: string;
|
|
28
|
-
name?: string;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* The change event for a Radix choice control, so `onChange` handlers written for a native input keep working.
|
|
32
|
-
* It is the click that changed the control, with `type: "change"` and a target that is the control element
|
|
33
|
-
* reading `checked`, `value`, `name` and `type` as the native input would.
|
|
34
|
-
*/
|
|
35
|
-
export declare function choiceChangeEvent(click: SyntheticEvent, control: HTMLElement, input: ChoiceTarget): ChangeEvent<HTMLInputElement>;
|
|
36
|
-
/**
|
|
37
|
-
* Checked state for a Radix Checkbox or Switch with the native input's API: `checked` or `defaultChecked`, and
|
|
38
|
-
* `onChange` with an event. Radix is always controlled from here, so its onCheckedChange runs inside the click.
|
|
39
|
-
*/
|
|
40
|
-
export declare function useChoiceToggle(props: CheckboxProps): {
|
|
41
|
-
checked: boolean;
|
|
42
|
-
/** Runs before Radix's own click handler; a prevented click does not toggle, as natively. */
|
|
43
|
-
onClick(e: MouseEvent<HTMLButtonElement>): void;
|
|
44
|
-
/** For Radix's onCheckedChange: true after a click; false when the form was reset, which (as natively) fires no change. */
|
|
45
|
-
change(): boolean;
|
|
46
|
-
};
|
|
47
|
-
/**
|
|
48
|
-
* Selection follows focus on arrow keys in a Radix RadioGroup even when the key is released at once. Radix moves
|
|
49
|
-
* focus on a timer and checks the focused radio only if the key is still down then, so a quick press (some assistive
|
|
50
|
-
* tech, scripted input) moved focus without selecting. Spread `group` on the Root and `item` on each Item.
|
|
51
|
-
*/
|
|
52
|
-
export declare function useArrowSelect(): {
|
|
53
|
-
group: {
|
|
54
|
-
onKeyDown(e: KeyboardEvent): void;
|
|
55
|
-
onKeyUp(): void;
|
|
56
|
-
onBlur(e: FocusEvent<HTMLElement>): void;
|
|
57
|
-
onPointerDown(): void;
|
|
58
|
-
};
|
|
59
|
-
item: {
|
|
60
|
-
onFocus(e: FocusEvent<HTMLButtonElement>): void;
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
/** A standalone Radio: a native radio under a drawn box (Radix radios only work inside a RadioGroup). */
|
|
64
|
-
export declare function nativeRadio(props: CheckboxProps): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
/** Radix data-state selects the check or indeterminate dash through CSS. */
|
|
24
|
+
export declare function checkMark(): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
/** A standalone Radio uses the native control because Radix RadioGroup requires a group. */
|
|
26
|
+
export declare function nativeRadio(props: RadioProps): import("react/jsx-runtime").JSX.Element;
|
|
65
27
|
export {};
|
package/dist/internal/choice.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { textFromNode } from "./options.js";
|
|
4
4
|
import { CHECK_PATH } from "./status.js";
|
|
5
5
|
import { cx } from "../lib/cx.js";
|
|
6
6
|
import { omit } from "../lib/omit.js";
|
|
@@ -8,104 +8,16 @@ import { omit } from "../lib/omit.js";
|
|
|
8
8
|
export function ChoiceLabel(props) {
|
|
9
9
|
return (_jsxs("label", { className: cx("vk-choice", props.kind, props.disabled && "vk-choice-disabled", props.className), children: [props.children, props.hideLabel ? null : (_jsxs("span", { className: "vk-choice-text", children: [_jsx("span", { className: "vk-choice-label", children: props.label }), props.description ? _jsx("span", { className: "vk-choice-description", children: props.description }) : null] }))] }));
|
|
10
10
|
}
|
|
11
|
-
/**
|
|
11
|
+
/** Extract readable label text when the visible choice label is hidden. */
|
|
12
12
|
export function hiddenLabel(props) {
|
|
13
|
-
return props.hideLabel && props.label != null ?
|
|
13
|
+
return props.hideLabel && props.label != null ? textFromNode(props.label) : undefined;
|
|
14
14
|
}
|
|
15
|
-
/**
|
|
16
|
-
export function checkMark(
|
|
17
|
-
return (
|
|
15
|
+
/** Radix data-state selects the check or indeterminate dash through CSS. */
|
|
16
|
+
export function checkMark() {
|
|
17
|
+
return (_jsxs("svg", { className: "vk-choice-mark", viewBox: "0 0 16 16", width: 12, height: 12, fill: "none", "aria-hidden": "true", children: [_jsx("path", { className: "vk-choice-check", d: CHECK_PATH, stroke: "currentColor", strokeWidth: 2, strokeLinecap: "square" }), _jsx("path", { className: "vk-choice-dash", d: "M4 8h8", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "square" })] }));
|
|
18
18
|
}
|
|
19
|
-
/**
|
|
20
|
-
* The change event for a Radix choice control, so `onChange` handlers written for a native input keep working.
|
|
21
|
-
* It is the click that changed the control, with `type: "change"` and a target that is the control element
|
|
22
|
-
* reading `checked`, `value`, `name` and `type` as the native input would.
|
|
23
|
-
*/
|
|
24
|
-
export function choiceChangeEvent(click, control, input) {
|
|
25
|
-
const own = input;
|
|
26
|
-
const target = new Proxy(control, {
|
|
27
|
-
get(el, key) {
|
|
28
|
-
if (Object.prototype.hasOwnProperty.call(own, key))
|
|
29
|
-
return own[key];
|
|
30
|
-
const v = Reflect.get(el, key, el);
|
|
31
|
-
return typeof v === "function" ? v.bind(el) : v;
|
|
32
|
-
},
|
|
33
|
-
set: (el, key, v) => Reflect.set(el, key, v, el),
|
|
34
|
-
});
|
|
35
|
-
return Object.assign(Object.create(click), { type: "change", target, currentTarget: target });
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Checked state for a Radix Checkbox or Switch with the native input's API: `checked` or `defaultChecked`, and
|
|
39
|
-
* `onChange` with an event. Radix is always controlled from here, so its onCheckedChange runs inside the click.
|
|
40
|
-
*/
|
|
41
|
-
export function useChoiceToggle(props) {
|
|
42
|
-
const controlled = props.checked !== undefined;
|
|
43
|
-
const [own, setOwn] = useState(Boolean(props.defaultChecked));
|
|
44
|
-
const checked = controlled ? Boolean(props.checked) : own;
|
|
45
|
-
const click = useRef(null);
|
|
46
|
-
return {
|
|
47
|
-
checked,
|
|
48
|
-
/** Runs before Radix's own click handler; a prevented click does not toggle, as natively. */
|
|
49
|
-
onClick(e) {
|
|
50
|
-
props.onClick?.(e);
|
|
51
|
-
click.current = e.defaultPrevented ? null : { event: e, control: e.currentTarget };
|
|
52
|
-
},
|
|
53
|
-
/** For Radix's onCheckedChange: true after a click; false when the form was reset, which (as natively) fires no change. */
|
|
54
|
-
change() {
|
|
55
|
-
const c = click.current;
|
|
56
|
-
click.current = null;
|
|
57
|
-
if (!c) {
|
|
58
|
-
if (!controlled)
|
|
59
|
-
setOwn(Boolean(props.defaultChecked));
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
const next = !checked;
|
|
63
|
-
if (!controlled)
|
|
64
|
-
setOwn(next);
|
|
65
|
-
props.onChange?.(choiceChangeEvent(c.event, c.control, { type: "checkbox", checked: next, value: c.control.value, name: props.name }));
|
|
66
|
-
return true;
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
const ARROWS = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"];
|
|
71
|
-
/**
|
|
72
|
-
* Selection follows focus on arrow keys in a Radix RadioGroup even when the key is released at once. Radix moves
|
|
73
|
-
* focus on a timer and checks the focused radio only if the key is still down then, so a quick press (some assistive
|
|
74
|
-
* tech, scripted input) moved focus without selecting. Spread `group` on the Root and `item` on each Item.
|
|
75
|
-
*/
|
|
76
|
-
export function useArrowSelect() {
|
|
77
|
-
const pending = useRef(false), held = useRef(false);
|
|
78
|
-
return {
|
|
79
|
-
group: {
|
|
80
|
-
onKeyDown(e) {
|
|
81
|
-
pending.current = held.current = ARROWS.includes(e.key);
|
|
82
|
-
},
|
|
83
|
-
onKeyUp() {
|
|
84
|
-
held.current = false;
|
|
85
|
-
},
|
|
86
|
-
// An arrow key that moved nowhere must not select whatever is focused next.
|
|
87
|
-
onBlur(e) {
|
|
88
|
-
if (!e.currentTarget.contains(e.relatedTarget))
|
|
89
|
-
pending.current = false;
|
|
90
|
-
},
|
|
91
|
-
onPointerDown() {
|
|
92
|
-
pending.current = false;
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
item: {
|
|
96
|
-
onFocus(e) {
|
|
97
|
-
if (!pending.current)
|
|
98
|
-
return;
|
|
99
|
-
pending.current = false;
|
|
100
|
-
// While the key is held, Radix's own focus handler checks the radio.
|
|
101
|
-
if (!held.current)
|
|
102
|
-
e.currentTarget.click();
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
/** A standalone Radio: a native radio under a drawn box (Radix radios only work inside a RadioGroup). */
|
|
19
|
+
/** A standalone Radio uses the native control because Radix RadioGroup requires a group. */
|
|
108
20
|
export function nativeRadio(props) {
|
|
109
|
-
const rest = omit(props, ["label", "description", "className", "
|
|
21
|
+
const rest = omit(props, ["label", "description", "className", "hideLabel"]);
|
|
110
22
|
return (_jsxs(ChoiceLabel, { label: props.label, description: props.description, hideLabel: props.hideLabel, disabled: props.disabled, className: props.className, children: [_jsx("input", { type: "radio", className: "vk-choice-input", "aria-label": hiddenLabel(props), ...rest }), _jsx("span", { className: "vk-choice-box vk-choice-box-radio", "aria-hidden": "true", children: _jsx("span", { className: "vk-choice-dot", "aria-hidden": "true" }) })] }));
|
|
111
23
|
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
/** The aria-describedby list for a control or group with an optional hint and error rendered as `id-hint` and `id-error`. */
|
|
3
|
+
export declare function describedBy(id: string, hint: ReactNode, error: ReactNode, existing?: string): string | undefined;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** The aria-describedby list for a control or group with an optional hint and error rendered as `id-hint` and `id-error`. */
|
|
2
|
+
export function describedBy(id, hint, error, existing) {
|
|
3
|
+
return [existing, hint ? id + "-hint" : null, error ? id + "-error" : null].filter(Boolean).join(" ") || undefined;
|
|
4
|
+
}
|
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
2
|
import type { SelectOption } from "../types.js";
|
|
3
|
-
|
|
4
|
-
export declare function normalizeOptions<T extends {
|
|
3
|
+
interface LabelledOption {
|
|
5
4
|
value: string;
|
|
6
5
|
label: ReactNode;
|
|
7
|
-
}
|
|
6
|
+
}
|
|
7
|
+
/** Plain options need no extra fields; richer contracts provide their own typed constructor. */
|
|
8
|
+
export declare function normalizeOptions(list: ReadonlyArray<string | SelectOption> | undefined): SelectOption[];
|
|
9
|
+
export declare function normalizeOptions<T extends LabelledOption>(list: ReadonlyArray<string | T> | undefined, createPlain: (value: string) => T): T[];
|
|
8
10
|
/** The next enabled option from `from` in direction `dir`, or -1. */
|
|
9
11
|
export declare function nextEnabled(list: ReadonlyArray<{
|
|
10
12
|
disabled?: boolean;
|
|
11
13
|
}>, from: number, dir: 1 | -1): number;
|
|
14
|
+
/** Read the text of a React label without exposing object stringification to accessible names. */
|
|
15
|
+
export declare function textFromNode(value: unknown): string;
|
|
12
16
|
/** The label with the matched part wrapped in <mark>. */
|
|
13
17
|
export declare function highlight(label: ReactNode, query: string): ReactNode;
|
|
14
18
|
/** Whether the option's label or description contains the query (case-insensitive). */
|
|
15
|
-
export declare function matches(
|
|
19
|
+
export declare function matches(option: SelectOption, query: string): boolean;
|
|
20
|
+
export {};
|
package/dist/internal/options.js
CHANGED
|
@@ -1,30 +1,44 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
|
|
3
|
-
export function normalizeOptions(list) {
|
|
4
|
-
|
|
5
|
-
return (list || []).map((o) => (typeof o === "string" ? { value: o, label: o } : o));
|
|
2
|
+
import { isValidElement } from "react";
|
|
3
|
+
export function normalizeOptions(list, createPlain) {
|
|
4
|
+
return (list || []).map((option) => typeof option === "string" ? createPlain ? createPlain(option) : { value: option, label: option } : option);
|
|
6
5
|
}
|
|
7
6
|
/** The next enabled option from `from` in direction `dir`, or -1. */
|
|
8
7
|
export function nextEnabled(list, from, dir) {
|
|
9
|
-
for (let i = from; i >= 0 && i < list.length; i += dir)
|
|
10
|
-
|
|
8
|
+
for (let i = from; i >= 0 && i < list.length; i += dir) {
|
|
9
|
+
const option = list[i];
|
|
10
|
+
if (option && !option.disabled)
|
|
11
11
|
return i;
|
|
12
|
+
}
|
|
12
13
|
return -1;
|
|
13
14
|
}
|
|
15
|
+
/** Read the text of a React label without exposing object stringification to accessible names. */
|
|
16
|
+
export function textFromNode(value) {
|
|
17
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "bigint")
|
|
18
|
+
return String(value);
|
|
19
|
+
if (Array.isArray(value))
|
|
20
|
+
return value.map(textFromNode).join("");
|
|
21
|
+
if (isValidElement(value)) {
|
|
22
|
+
const props = value.props;
|
|
23
|
+
if (typeof props === "object" && props !== null && "children" in props)
|
|
24
|
+
return textFromNode(props.children);
|
|
25
|
+
}
|
|
26
|
+
return "";
|
|
27
|
+
}
|
|
14
28
|
/** The label with the matched part wrapped in <mark>. */
|
|
15
29
|
export function highlight(label, query) {
|
|
16
|
-
const text = String(label);
|
|
17
30
|
if (!query)
|
|
18
|
-
return
|
|
31
|
+
return label;
|
|
32
|
+
const text = textFromNode(label);
|
|
19
33
|
const at = text.toLowerCase().indexOf(query.toLowerCase());
|
|
20
34
|
if (at < 0)
|
|
21
|
-
return
|
|
35
|
+
return label;
|
|
22
36
|
return [text.slice(0, at), _jsx("mark", { className: "vk-match", children: text.slice(at, at + query.length) }, "m"), text.slice(at + query.length)];
|
|
23
37
|
}
|
|
24
38
|
/** Whether the option's label or description contains the query (case-insensitive). */
|
|
25
|
-
export function matches(
|
|
39
|
+
export function matches(option, query) {
|
|
26
40
|
if (!query)
|
|
27
41
|
return true;
|
|
28
42
|
const q = query.toLowerCase();
|
|
29
|
-
return
|
|
43
|
+
return option.label.toLowerCase().includes(q) || Boolean(option.description?.toLowerCase().includes(q));
|
|
30
44
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { LocaleMessages } from "../localization.js";
|
|
1
2
|
import type { IconName, Status } from "../types.js";
|
|
2
3
|
/** The checkbox tick. */
|
|
3
4
|
export declare const CHECK_PATH = "M4 8.5 6.75 11.25 12 5";
|
|
4
5
|
export declare const STATUS_ICON: Record<Status, IconName>;
|
|
5
|
-
/** Announced
|
|
6
|
-
export declare
|
|
6
|
+
/** Announced status words share one dictionary; custom statuses retain their own label. */
|
|
7
|
+
export declare function statusWord(status: string, messages: LocaleMessages): string;
|
package/dist/internal/status.js
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
/** The checkbox tick. */
|
|
2
2
|
export const CHECK_PATH = "M4 8.5 6.75 11.25 12 5";
|
|
3
3
|
export const STATUS_ICON = { info: "info", success: "circle-check", warning: "triangle-alert", danger: "circle-alert" };
|
|
4
|
-
/** Announced
|
|
5
|
-
export
|
|
4
|
+
/** Announced status words share one dictionary; custom statuses retain their own label. */
|
|
5
|
+
export function statusWord(status, messages) {
|
|
6
|
+
switch (status) {
|
|
7
|
+
case "info": return messages.statusInfo;
|
|
8
|
+
case "success": return messages.statusSuccess;
|
|
9
|
+
case "warning": return messages.statusWarning;
|
|
10
|
+
case "danger": return messages.statusDanger;
|
|
11
|
+
default: return status;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -5,8 +5,8 @@ export function useScrollActive(open, listRef, active) {
|
|
|
5
5
|
useEffect(() => {
|
|
6
6
|
if (!open || !listRef.current || active < 0)
|
|
7
7
|
return;
|
|
8
|
-
const el = listRef.current.querySelector(`[data-index="${active}"]`);
|
|
9
|
-
if (el
|
|
8
|
+
const el = listRef.current.querySelector(`[data-index="${String(active)}"]`);
|
|
9
|
+
if (el)
|
|
10
10
|
el.scrollIntoView({ block: "nearest" });
|
|
11
11
|
}, [open, listRef, active]);
|
|
12
12
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useCallback, useSyncExternalStore } from "react";
|
|
3
|
+
import { parseISO, toISO } from "../lib/dates.js";
|
|
4
|
+
/** A primitive snapshot stays equal through the day and changes at local midnight. */
|
|
5
|
+
function currentDay() { return toISO(new Date()); }
|
|
6
|
+
/** Timers follow local midnight (including DST); foreground events recover from suspended tabs or clock changes. */
|
|
7
|
+
function subscribeToDay(onChange) {
|
|
8
|
+
let timer;
|
|
9
|
+
const schedule = () => {
|
|
10
|
+
if (timer !== undefined)
|
|
11
|
+
clearTimeout(timer);
|
|
12
|
+
const now = new Date();
|
|
13
|
+
const midnight = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1);
|
|
14
|
+
timer = setTimeout(refresh, Math.max(1, midnight.getTime() - now.getTime()));
|
|
15
|
+
};
|
|
16
|
+
const refresh = () => { onChange(); schedule(); };
|
|
17
|
+
const onVisibility = () => { if (document.visibilityState === "visible")
|
|
18
|
+
refresh(); };
|
|
19
|
+
schedule();
|
|
20
|
+
window.addEventListener("focus", refresh);
|
|
21
|
+
window.addEventListener("pageshow", refresh);
|
|
22
|
+
document.addEventListener("visibilitychange", onVisibility);
|
|
23
|
+
return () => {
|
|
24
|
+
if (timer !== undefined)
|
|
25
|
+
clearTimeout(timer);
|
|
26
|
+
window.removeEventListener("focus", refresh);
|
|
27
|
+
window.removeEventListener("pageshow", refresh);
|
|
28
|
+
document.removeEventListener("visibilitychange", onVisibility);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function subscribeToFixedDay() { return () => undefined; }
|
|
32
|
+
/** Live current day, or the caller's deterministic server/client today override. */
|
|
33
|
+
export function useToday(override) {
|
|
34
|
+
const explicit = parseISO(override);
|
|
35
|
+
const fixedDay = explicit ? toISO(explicit) : undefined;
|
|
36
|
+
const read = useCallback(() => fixedDay ?? currentDay(), [fixedDay]);
|
|
37
|
+
const snapshot = useSyncExternalStore(fixedDay ? subscribeToFixedDay : subscribeToDay, read, read);
|
|
38
|
+
const day = parseISO(snapshot);
|
|
39
|
+
if (day === null)
|
|
40
|
+
throw new TypeError("The current-day source must return an ISO date.");
|
|
41
|
+
return day;
|
|
42
|
+
}
|
package/dist/lib/dates.js
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { resolveLocale } from "./format.js";
|
|
2
2
|
import { dateFormat } from "./intl.js";
|
|
3
3
|
/* Dates are exchanged as "YYYY-MM-DD" strings and handled as local-midnight Date objects. */
|
|
4
|
-
export function pad2(n) { return (n < 10 ? "0" : "") + n; }
|
|
5
|
-
export function toISO(d) { return d.getFullYear() + "-" + pad2(d.getMonth() + 1) + "-" + pad2(d.getDate()); }
|
|
4
|
+
export function pad2(n) { return (n < 10 ? "0" : "") + String(n); }
|
|
5
|
+
export function toISO(d) { return String(d.getFullYear()) + "-" + pad2(d.getMonth() + 1) + "-" + pad2(d.getDate()); }
|
|
6
6
|
export function parseISO(s) {
|
|
7
7
|
if (!s)
|
|
8
8
|
return null;
|
|
9
9
|
if (s instanceof Date)
|
|
10
10
|
return new Date(s.getFullYear(), s.getMonth(), s.getDate());
|
|
11
11
|
const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(s);
|
|
12
|
-
|
|
12
|
+
if (!m)
|
|
13
|
+
return null;
|
|
14
|
+
const [, year, month, day] = m;
|
|
15
|
+
if (year === undefined || month === undefined || day === undefined)
|
|
16
|
+
return null;
|
|
17
|
+
return new Date(Number(year), Number(month) - 1, Number(day));
|
|
13
18
|
}
|
|
14
19
|
export function addDays(d, n) { return new Date(d.getFullYear(), d.getMonth(), d.getDate() + n); }
|
|
15
20
|
export function addMonths(d, n) {
|
|
@@ -18,14 +23,14 @@ export function addMonths(d, n) {
|
|
|
18
23
|
return new Date(t.getFullYear(), t.getMonth(), Math.min(d.getDate(), last));
|
|
19
24
|
}
|
|
20
25
|
export function sameDay(a, b) {
|
|
21
|
-
return
|
|
26
|
+
return a != null && b != null && a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
22
27
|
}
|
|
23
28
|
export function clampDate(d, min, max) {
|
|
24
29
|
return min && d < min ? min : max && d > max ? max : d;
|
|
25
30
|
}
|
|
26
31
|
/* Time: values are "HH:MM" (24-hour); display follows the locale's clock. */
|
|
27
32
|
export function parseTime(text) {
|
|
28
|
-
let s =
|
|
33
|
+
let s = (text || "").trim().toLowerCase().replace(/\s+/g, "");
|
|
29
34
|
if (!s)
|
|
30
35
|
return null;
|
|
31
36
|
const pm = /p\.?m?\.?$/.test(s), am = /a\.?m?\.?$/.test(s);
|
|
@@ -33,7 +38,10 @@ export function parseTime(text) {
|
|
|
33
38
|
const m = /^(\d{1,2})(?:[:.h]?(\d{2}))?$/.exec(s);
|
|
34
39
|
if (!m)
|
|
35
40
|
return null;
|
|
36
|
-
|
|
41
|
+
const hour = m[1];
|
|
42
|
+
if (hour === undefined)
|
|
43
|
+
return null;
|
|
44
|
+
let hh = Number(hour);
|
|
37
45
|
const mm = m[2] ? +m[2] : 0;
|
|
38
46
|
if (pm && hh < 12)
|
|
39
47
|
hh += 12;
|
|
@@ -46,12 +54,12 @@ export function parseTime(text) {
|
|
|
46
54
|
export function formatTime(value, locale) {
|
|
47
55
|
if (!value)
|
|
48
56
|
return "";
|
|
49
|
-
const [h, m] = value.split(":");
|
|
57
|
+
const [h = "0", m = "0"] = value.split(":");
|
|
50
58
|
return dateFormat(resolveLocale(locale), { hour: "numeric", minute: "2-digit" }).format(new Date(2000, 0, 1, +h, +m));
|
|
51
59
|
}
|
|
52
60
|
/* Typed dates: ISO, the locale's numeric order (10/11/2026, 11-10-2026), or month names (Oct 11 2026, 11 okt 2026). */
|
|
53
61
|
export function parseDateInput(text, locale) {
|
|
54
|
-
const s =
|
|
62
|
+
const s = (text || "").trim();
|
|
55
63
|
if (!s)
|
|
56
64
|
return null;
|
|
57
65
|
if (/^\d{4}-\d{2}-\d{2}$/.test(s))
|
|
@@ -59,8 +67,7 @@ export function parseDateInput(text, locale) {
|
|
|
59
67
|
const loc = resolveLocale(locale);
|
|
60
68
|
const order = dateFormat(loc, { year: "numeric", month: "2-digit", day: "2-digit" })
|
|
61
69
|
.formatToParts(new Date(2026, 10, 22))
|
|
62
|
-
.
|
|
63
|
-
.map((p) => p.type);
|
|
70
|
+
.flatMap((part) => part.type === "day" || part.type === "month" || part.type === "year" ? [part.type] : []);
|
|
64
71
|
const months = {};
|
|
65
72
|
for (const width of ["long", "short"]) {
|
|
66
73
|
const f = dateFormat(loc, { month: width });
|
|
@@ -70,22 +77,23 @@ export function parseDateInput(text, locale) {
|
|
|
70
77
|
months[fe.format(new Date(2026, m, 1)).toLowerCase()] = m + 1;
|
|
71
78
|
}
|
|
72
79
|
}
|
|
73
|
-
const tokens = s.toLowerCase().replace(/,/g, " ").split(/[\s
|
|
80
|
+
const tokens = s.toLowerCase().replace(/,/g, " ").split(/[\s/.-]+/).filter(Boolean);
|
|
74
81
|
let named = null;
|
|
75
82
|
const nums = [];
|
|
76
83
|
for (const t of tokens) {
|
|
77
84
|
if (/^\d+$/.test(t))
|
|
78
85
|
nums.push(+t);
|
|
79
86
|
else if (months[t.replace(/\.$/, "")])
|
|
80
|
-
named = months[t.replace(/\.$/, "")];
|
|
87
|
+
named = months[t.replace(/\.$/, "")] ?? null;
|
|
81
88
|
}
|
|
82
89
|
let y, mo, d;
|
|
83
90
|
if (named) {
|
|
84
91
|
mo = named;
|
|
85
|
-
|
|
92
|
+
const [first, second] = nums;
|
|
93
|
+
if (first === undefined)
|
|
86
94
|
return null;
|
|
87
|
-
d =
|
|
88
|
-
y =
|
|
95
|
+
d = first > 31 ? second : first;
|
|
96
|
+
y = first > 31 ? first : second;
|
|
89
97
|
}
|
|
90
98
|
else {
|
|
91
99
|
if (nums.length !== 3)
|
|
@@ -96,6 +104,8 @@ export function parseDateInput(text, locale) {
|
|
|
96
104
|
mo = map.month;
|
|
97
105
|
d = map.day;
|
|
98
106
|
}
|
|
107
|
+
if (mo === undefined || d === undefined)
|
|
108
|
+
return null;
|
|
99
109
|
if (y == null)
|
|
100
110
|
y = new Date().getFullYear();
|
|
101
111
|
if (y < 100)
|
package/dist/lib/format.js
CHANGED
|
@@ -10,10 +10,12 @@ export function resolveLocale(locale) {
|
|
|
10
10
|
if (Intl.NumberFormat.supportedLocalesOf([loc]).length)
|
|
11
11
|
return loc;
|
|
12
12
|
}
|
|
13
|
-
catch {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
catch {
|
|
14
|
+
// Invalid locale tags fall back through the same explicit locale policy.
|
|
15
|
+
}
|
|
16
|
+
const region = /^pap-([A-Za-z]{2})$/i.exec(loc)?.[1];
|
|
17
|
+
if (region)
|
|
18
|
+
return "nl-" + region.toUpperCase();
|
|
17
19
|
return "en-US";
|
|
18
20
|
}
|
|
19
21
|
export function formatNumber(value, opts = {}) {
|
|
@@ -27,15 +29,16 @@ export function formatCurrency(amount, currency, opts = {}) {
|
|
|
27
29
|
base.currencyDisplay = "code";
|
|
28
30
|
let out = numberFormat(resolveLocale(opts.locale), { ...base, ...omit(opts, ["locale"]) }).format(amount);
|
|
29
31
|
// Older browsers without CLDR 46 data print the bare ISO code for the Caribbean guilder.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
const symbol = CURRENCY_SYMBOL_FALLBACK[cur];
|
|
33
|
+
if (symbol && cur !== "SRD")
|
|
34
|
+
out = out.replace(new RegExp("\\b" + cur + "\\b\\s?"), symbol + " ");
|
|
32
35
|
return out;
|
|
33
36
|
}
|
|
34
37
|
export function formatPercent(value, opts = {}) {
|
|
35
38
|
return numberFormat(resolveLocale(opts.locale), { style: "percent", maximumFractionDigits: 1, ...omit(opts, ["locale"]) }).format(value);
|
|
36
39
|
}
|
|
37
40
|
export function formatDate(value, opts = {}) {
|
|
38
|
-
const d = value instanceof Date ? value : /^\d{4}-\d{2}-\d{2}$/.test(
|
|
41
|
+
const d = value instanceof Date ? value : /^\d{4}-\d{2}-\d{2}$/.test(value) ? parseISO(value) : new Date(value);
|
|
39
42
|
const style = opts.style || "medium";
|
|
40
43
|
const rest = omit(opts, ["locale", "style"]);
|
|
41
44
|
const hasParts = Object.keys(rest).some((k) => ["weekday", "year", "month", "day", "hour", "minute"].includes(k));
|
|
@@ -43,7 +46,7 @@ export function formatDate(value, opts = {}) {
|
|
|
43
46
|
}
|
|
44
47
|
export function formatBytes(n) {
|
|
45
48
|
if (n < 1024)
|
|
46
|
-
return n + " B";
|
|
49
|
+
return String(n) + " B";
|
|
47
50
|
if (n < 1048576)
|
|
48
51
|
return (n / 1024).toFixed(n < 10240 ? 1 : 0) + " KB";
|
|
49
52
|
return (n / 1048576).toFixed(1) + " MB";
|
package/dist/lib/icons.d.ts
CHANGED
|
@@ -11,6 +11,11 @@ export interface IconDef {
|
|
|
11
11
|
}
|
|
12
12
|
/** Lucide outlines in the Vokality icon set. */
|
|
13
13
|
export declare const ICONS: {
|
|
14
|
+
"message-circle": {
|
|
15
|
+
size: number;
|
|
16
|
+
stroke: number;
|
|
17
|
+
d: string[];
|
|
18
|
+
};
|
|
14
19
|
"arrow-up-right": {
|
|
15
20
|
size: number;
|
|
16
21
|
stroke: number;
|
package/dist/lib/icons.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/** Lucide outlines in the Vokality icon set. */
|
|
2
2
|
export const ICONS = {
|
|
3
|
+
// https://github.com/lucide-icons/lucide/blob/main/icons/message-circle.svg
|
|
4
|
+
"message-circle": { size: 24, stroke: 1.75, d: ["M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719"] },
|
|
3
5
|
"arrow-up-right": { size: 17, stroke: 1.5, d: ["M7 7h10v10M7 17 17 7"] },
|
|
4
6
|
quote: {
|
|
5
7
|
size: 18,
|