@bloxwap/hig 0.0.0-stage → 0.2.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/LICENSE +5 -0
- package/README.md +44 -2
- package/chart/README.md +23 -0
- package/chart/dist/index.d.ts +8 -0
- package/chart/dist/index.js +12 -0
- package/contracts/README.md +3 -0
- package/contracts/dist/announcements.d.ts +12 -0
- package/contracts/dist/announcements.js +8 -0
- package/contracts/dist/feedback.d.ts +40 -0
- package/contracts/dist/feedback.js +1 -0
- package/contracts/dist/index.d.ts +41 -0
- package/contracts/dist/index.js +52 -0
- package/contracts/dist/messages.d.ts +162 -0
- package/contracts/dist/messages.js +68 -0
- package/feedback/README.md +7 -0
- package/feedback/assets/error.wav +0 -0
- package/feedback/assets/manifest.json +68 -0
- package/feedback/assets/success.wav +0 -0
- package/feedback/assets/tick.wav +0 -0
- package/feedback/assets/toggle.wav +0 -0
- package/feedback/dist/browser-haptic.d.ts +23 -0
- package/feedback/dist/browser-haptic.js +41 -0
- package/feedback/dist/contract.d.ts +96 -0
- package/feedback/dist/contract.js +58 -0
- package/feedback/dist/native.d.ts +27 -0
- package/feedback/dist/native.js +63 -0
- package/feedback/dist/preferences.d.ts +8 -0
- package/feedback/dist/preferences.js +24 -0
- package/feedback/dist/react.d.ts +19 -0
- package/feedback/dist/react.js +23 -0
- package/feedback/dist/web-haptic.d.ts +6 -0
- package/feedback/dist/web-haptic.js +6 -0
- package/feedback/dist/web-sound.d.ts +5 -0
- package/feedback/dist/web-sound.js +32 -0
- package/feedback/dist/web.d.ts +3 -0
- package/feedback/dist/web.js +4 -0
- package/native/README.md +11 -0
- package/native/android/build.gradle +28 -0
- package/native/android/src/main/java/com/bloxwap/hig/HIGAdjustableView.java +173 -0
- package/native/android/src/main/java/com/bloxwap/hig/HIGAdjustableViewManager.java +23 -0
- package/native/android/src/main/java/com/bloxwap/hig/HIGPackage.java +24 -0
- package/native/dist/animated-number-model.d.ts +24 -0
- package/native/dist/animated-number-model.js +110 -0
- package/native/dist/animated-number.d.ts +9 -0
- package/native/dist/animated-number.js +93 -0
- package/native/dist/brand.d.ts +7 -0
- package/native/dist/brand.js +6 -0
- package/native/dist/button.d.ts +29 -0
- package/native/dist/button.js +34 -0
- package/native/dist/checkbox.d.ts +3 -0
- package/native/dist/checkbox.js +11 -0
- package/native/dist/data.d.ts +40 -0
- package/native/dist/data.js +27 -0
- package/native/dist/field.d.ts +15 -0
- package/native/dist/field.js +13 -0
- package/native/dist/gesture-sheet.d.ts +73 -0
- package/native/dist/gesture-sheet.js +151 -0
- package/native/dist/navigation.d.ts +47 -0
- package/native/dist/navigation.js +16 -0
- package/native/dist/overlay.d.ts +36 -0
- package/native/dist/overlay.js +65 -0
- package/native/dist/provider.d.ts +43 -0
- package/native/dist/provider.js +52 -0
- package/native/dist/radio-group.d.ts +5 -0
- package/native/dist/radio-group.js +53 -0
- package/native/dist/recipes.d.ts +42 -0
- package/native/dist/recipes.js +19 -0
- package/native/dist/roles.d.ts +6 -0
- package/native/dist/roles.js +4 -0
- package/native/dist/select.d.ts +3 -0
- package/native/dist/select.js +9 -0
- package/native/dist/selection-types.d.ts +22 -0
- package/native/dist/selection-types.js +1 -0
- package/native/dist/selection.d.ts +7 -0
- package/native/dist/selection.js +6 -0
- package/native/dist/slider.d.ts +11 -0
- package/native/dist/slider.js +41 -0
- package/native/dist/status.d.ts +75 -0
- package/native/dist/status.js +72 -0
- package/native/dist/surface.d.ts +18 -0
- package/native/dist/surface.js +41 -0
- package/native/dist/switch-row.d.ts +8 -0
- package/native/dist/switch-row.js +18 -0
- package/native/dist/switch.d.ts +10 -0
- package/native/dist/switch.js +23 -0
- package/native/dist/text-content.d.ts +5 -0
- package/native/dist/text-content.js +6 -0
- package/native-fonts/README.md +17 -0
- package/native-fonts/dist/index.d.ts +164 -0
- package/native-fonts/dist/index.js +164 -0
- package/native-fonts/fonts/BloxwapMono-Bold.ttf +0 -0
- package/native-fonts/fonts/BloxwapMono-ExtraBold.ttf +0 -0
- package/native-fonts/fonts/BloxwapMono-Medium.ttf +0 -0
- package/native-fonts/fonts/BloxwapMono-SemiBold.ttf +0 -0
- package/native-fonts/fonts/BloxwapMono.ttf +0 -0
- package/native-fonts/fonts/BloxwapSans-Black.ttf +0 -0
- package/native-fonts/fonts/BloxwapSans-Bold.ttf +0 -0
- package/native-fonts/fonts/BloxwapSans-ExtraBold.ttf +0 -0
- package/native-fonts/fonts/BloxwapSans-Medium.ttf +0 -0
- package/native-fonts/fonts/BloxwapSans-SemiBold.ttf +0 -0
- package/native-fonts/fonts/BloxwapSans.ttf +0 -0
- package/native-fonts/fonts/BloxwapSansKR-SemiBold.ttf +0 -0
- package/native-fonts/fonts/BloxwapSansKR.ttf +0 -0
- package/native-fonts/fonts/BloxwapSansSC-SemiBold.ttf +0 -0
- package/native-fonts/fonts/BloxwapSansSC.ttf +0 -0
- package/native-fonts/fonts/OFL.txt +93 -0
- package/native-fonts/fonts/manifest.json +164 -0
- package/og-fonts/README.md +34 -0
- package/og-fonts/dist/index.d.ts +116 -0
- package/og-fonts/dist/index.js +102 -0
- package/og-fonts/dist/node.d.ts +11 -0
- package/og-fonts/dist/node.js +39 -0
- package/og-fonts/fonts/BloxwapMono-Medium.ttf +0 -0
- package/og-fonts/fonts/BloxwapSans-Black.ttf +0 -0
- package/og-fonts/fonts/BloxwapSans-Bold.ttf +0 -0
- package/og-fonts/fonts/BloxwapSans-Medium.ttf +0 -0
- package/og-fonts/fonts/BloxwapSans.ttf +0 -0
- package/og-fonts/fonts/OFL.txt +93 -0
- package/og-fonts/fonts/manifest.json +65 -0
- package/package.json +358 -4
- package/react/README.md +9 -0
- package/react/dist/animated-number-model.d.ts +20 -0
- package/react/dist/animated-number-model.js +92 -0
- package/react/dist/animated-number.d.ts +8 -0
- package/react/dist/animated-number.js +71 -0
- package/react/dist/base.css +9 -0
- package/react/dist/brand.d.ts +7 -0
- package/react/dist/brand.js +4 -0
- package/react/dist/button.d.ts +14 -0
- package/react/dist/button.js +20 -0
- package/react/dist/data.d.ts +63 -0
- package/react/dist/data.js +23 -0
- package/react/dist/dialog.d.ts +29 -0
- package/react/dist/dialog.js +21 -0
- package/react/dist/field.d.ts +15 -0
- package/react/dist/field.js +19 -0
- package/react/dist/gesture-sheet.d.ts +41 -0
- package/react/dist/gesture-sheet.js +128 -0
- package/react/dist/navigation.d.ts +48 -0
- package/react/dist/navigation.js +69 -0
- package/react/dist/overlay.d.ts +17 -0
- package/react/dist/overlay.js +18 -0
- package/react/dist/provider.d.ts +25 -0
- package/react/dist/provider.js +50 -0
- package/react/dist/recipes/activity-list.d.ts +8 -0
- package/react/dist/recipes/activity-list.js +6 -0
- package/react/dist/recipes/balance-card.d.ts +6 -0
- package/react/dist/recipes/balance-card.js +5 -0
- package/react/dist/recipes/code-window.d.ts +4 -0
- package/react/dist/recipes/code-window.js +4 -0
- package/react/dist/recipes/install-command.d.ts +5 -0
- package/react/dist/recipes/install-command.js +8 -0
- package/react/dist/recipes/market-row.d.ts +25 -0
- package/react/dist/recipes/market-row.js +8 -0
- package/react/dist/recipes/marketing-hero.d.ts +7 -0
- package/react/dist/recipes/marketing-hero.js +5 -0
- package/react/dist/recipes/trade-entry.d.ts +11 -0
- package/react/dist/recipes/trade-entry.js +12 -0
- package/react/dist/recipes.d.ts +8 -0
- package/react/dist/recipes.js +9 -0
- package/react/dist/select.d.ts +4 -0
- package/react/dist/select.js +172 -0
- package/react/dist/selection.d.ts +27 -0
- package/react/dist/selection.js +16 -0
- package/react/dist/slider.d.ts +11 -0
- package/react/dist/slider.js +10 -0
- package/react/dist/status.d.ts +53 -0
- package/react/dist/status.js +43 -0
- package/react/dist/styles.css +228 -0
- package/react/dist/surface.d.ts +291 -0
- package/react/dist/surface.js +9 -0
- package/tokens/README.md +9 -0
- package/tokens/assets/bloxwap-icon.svg +1 -0
- package/tokens/dist/index.d.ts +429 -0
- package/tokens/dist/index.js +507 -0
- package/tokens/dist/manifest.json +197 -0
- package/tokens/dist/theme.d.ts +11 -0
- package/tokens/dist/theme.js +22 -0
- package/tokens/dist/tokens.css +119 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as en from '@bloxwap/hig/contracts/messages';
|
|
4
|
+
import { useHIG } from '../provider.js';
|
|
5
|
+
import { Text } from '../surface.js';
|
|
6
|
+
export function ActivityList({ items }) { const { messages } = useHIG(); return items.length ? _jsx("ul", { children: items.map(i => _jsxs("li", { children: [_jsx("strong", { children: i.label }), " \u2014 ", i.status] }, i.id)) }) : _jsx(Text, { children: messages.noActivity ?? en.noActivity }); }
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Surface, Text } from '../surface.js';
|
|
4
|
+
import { Usd } from '../data.js';
|
|
5
|
+
export function BalanceCard({ label, balance, stale }) { return _jsxs(Surface, { className: 'hig-balance-card', children: [_jsx(Text, { children: label }), _jsx(Usd, { value: balance, stale: stale })] }); }
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Surface, Text } from '../surface.js';
|
|
4
|
+
export function CodeWindow({ language, children }) { return _jsxs(Surface, { children: [_jsx(Text, { children: language }), _jsx("pre", { className: 'hig-code', tabIndex: 0, children: _jsx("code", { children: children }) })] }); }
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import * as en from '@bloxwap/hig/contracts/messages';
|
|
5
|
+
import { useHIG } from '../provider.js';
|
|
6
|
+
import { Button } from '../button.js';
|
|
7
|
+
import { Surface } from '../surface.js';
|
|
8
|
+
export function InstallCommand({ command, onCopy }) { const { messages } = useHIG(); const [status, setStatus] = useState(''); return _jsxs(Surface, { children: [_jsx("pre", { className: 'hig-code', tabIndex: 0, children: _jsx("code", { children: command }) }), _jsx(Button, { intent: 'secondary', onClick: () => { Promise.resolve().then(onCopy).then(() => setStatus(messages.copied ?? en.copied)).catch(() => setStatus(messages.copyFailed ?? en.copyFailed)); }, children: messages.copyInstallCommand ?? en.copyInstallCommand }), _jsx("p", { role: 'status', children: status })] }); }
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface MarketRowContent {
|
|
3
|
+
symbol: string;
|
|
4
|
+
name: string;
|
|
5
|
+
price: number | null;
|
|
6
|
+
change: number | null; /** Intl display options, including a decimal style when the host omits a currency symbol. */
|
|
7
|
+
priceOptions?: Intl.NumberFormatOptions; /** Percent-point display precision/sign; forwarded to Percent. */
|
|
8
|
+
changeOptions?: Intl.NumberFormatOptions; /** Optional host-rendered market icon, favourite indicator/control and formatted volume. */
|
|
9
|
+
icon?: React.ReactNode;
|
|
10
|
+
favorite?: React.ReactNode;
|
|
11
|
+
volume?: React.ReactNode;
|
|
12
|
+
className?: string;
|
|
13
|
+
style?: React.CSSProperties;
|
|
14
|
+
}
|
|
15
|
+
export type MarketRowProps = MarketRowContent & ({
|
|
16
|
+
mode?: 'action';
|
|
17
|
+
onSelect: () => void;
|
|
18
|
+
identity?: never;
|
|
19
|
+
} | {
|
|
20
|
+
mode: 'presentation';
|
|
21
|
+
onSelect?: never; /** Host market identity, such as symbol/name with its existing compact layout. */
|
|
22
|
+
identity?: React.ReactNode;
|
|
23
|
+
});
|
|
24
|
+
export declare function MarketRow({ symbol, name, price, change, onSelect, priceOptions, changeOptions, mode, identity, icon, favorite, volume, className, style }: MarketRowProps): React.JSX.Element;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Button } from '../button.js';
|
|
4
|
+
import { Usd, Percent } from '../data.js';
|
|
5
|
+
export function MarketRow({ symbol, name, price, change, onSelect, priceOptions, changeOptions, mode = 'action', identity, icon, favorite, volume, className, style }) {
|
|
6
|
+
const content = _jsxs(_Fragment, { children: [favorite !== undefined && _jsx("span", { className: 'hig-market-favorite', children: favorite }), icon !== undefined && _jsx("span", { className: 'hig-market-icon', children: icon }), mode === 'presentation' ? _jsx("span", { className: 'hig-market-name', children: identity === undefined ? _jsxs(_Fragment, { children: [name, " (", symbol, ")"] }) : identity }) : _jsxs(Button, { intent: 'ghost', onClick: onSelect, children: [name, " (", symbol, ")"] })] });
|
|
7
|
+
return _jsxs("div", { className: `hig-row hig-market-row${className ? ` ${className}` : ''}`, style: style, "data-mode": mode, "data-has-volume": volume !== undefined || undefined, children: [_jsx("div", { className: 'hig-market-identity', children: content }), _jsx("span", { className: 'hig-market-price', children: _jsx(Usd, { value: price, options: priceOptions }) }), _jsx("span", { className: 'hig-market-change', children: _jsx(Percent, { value: change, options: changeOptions }) }), volume !== undefined && _jsx("span", { className: 'hig-market-volume', children: volume })] });
|
|
8
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Link } from '../button.js';
|
|
4
|
+
import { Heading, Text } from '../surface.js';
|
|
5
|
+
export function MarketingHero({ title, description, href, cta }) { return _jsxs("section", { children: [_jsx(Heading, { level: 1, children: title }), _jsx(Text, { children: description }), _jsx(Link, { href: href, children: cta })] }); }
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/** Host validates and submits. Opening review never submits a transaction. */
|
|
3
|
+
export declare function TradeEntry({ asset, amount, onAmountChange, onConfirm, busy, error, available }: {
|
|
4
|
+
asset: string;
|
|
5
|
+
amount: string;
|
|
6
|
+
onAmountChange: (v: string) => void;
|
|
7
|
+
onConfirm: () => void;
|
|
8
|
+
busy?: boolean;
|
|
9
|
+
error?: string;
|
|
10
|
+
available: string;
|
|
11
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import * as en from '@bloxwap/hig/contracts/messages';
|
|
5
|
+
import { useHIG } from '../provider.js';
|
|
6
|
+
import { Button } from '../button.js';
|
|
7
|
+
import { Surface, Stack, Heading } from '../surface.js';
|
|
8
|
+
import { Field, AmountInput } from '../field.js';
|
|
9
|
+
import { Dialog } from '../dialog.js';
|
|
10
|
+
import { Alert } from '../status.js';
|
|
11
|
+
/** Host validates and submits. Opening review never submits a transaction. */
|
|
12
|
+
export function TradeEntry({ asset, amount, onAmountChange, onConfirm, busy, error, available }) { const { messages } = useHIG(); const [review, setReview] = useState(false); return _jsx(Surface, { children: _jsxs(Stack, { children: [_jsx(Heading, { children: (messages.reviewAssetOrder ?? en.reviewAssetOrder)(asset) }), _jsx(Field, { label: (messages.amountInAsset ?? en.amountInAsset)(asset), description: (messages.availableAmount ?? en.availableAmount)(available), error: error, children: _jsx(AmountInput, { value: amount, onChange: e => onAmountChange(e.target.value), readOnly: busy }) }), _jsx(Button, { fullWidth: true, disabled: !amount || !!error, busy: busy, onClick: () => setReview(true), children: messages.reviewOrder ?? en.reviewOrder }), _jsxs(Dialog, { open: review, onOpenChange: setReview, title: messages.confirmOrder ?? en.confirmOrder, description: (messages.confirmOrderDescription ?? en.confirmOrderDescription)(amount, asset), children: [_jsx(Button, { busy: busy, disabled: !!error, onClick: onConfirm, children: messages.confirmOrder ?? en.confirmOrder }), error && _jsx(Alert, { title: messages.orderUnavailable ?? en.orderUnavailable, severity: 'error', children: _jsx("p", { children: error }) })] })] }) }); }
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Aggregate entry. TradeEntry needs @radix-ui/react-dialog; import single recipes from `@bloxwap/hig/react/recipes/<name>` to avoid overlay peers. */
|
|
2
|
+
export { MarketRow } from './recipes/market-row.js';
|
|
3
|
+
export { BalanceCard } from './recipes/balance-card.js';
|
|
4
|
+
export { TradeEntry } from './recipes/trade-entry.js';
|
|
5
|
+
export { InstallCommand } from './recipes/install-command.js';
|
|
6
|
+
export { CodeWindow } from './recipes/code-window.js';
|
|
7
|
+
export { MarketingHero } from './recipes/marketing-hero.js';
|
|
8
|
+
export { ActivityList } from './recipes/activity-list.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/** Aggregate entry. TradeEntry needs @radix-ui/react-dialog; import single recipes from `@bloxwap/hig/react/recipes/<name>` to avoid overlay peers. */
|
|
3
|
+
export { MarketRow } from './recipes/market-row.js';
|
|
4
|
+
export { BalanceCard } from './recipes/balance-card.js';
|
|
5
|
+
export { TradeEntry } from './recipes/trade-entry.js';
|
|
6
|
+
export { InstallCommand } from './recipes/install-command.js';
|
|
7
|
+
export { CodeWindow } from './recipes/code-window.js';
|
|
8
|
+
export { MarketingHero } from './recipes/marketing-hero.js';
|
|
9
|
+
export { ActivityList } from './recipes/activity-list.js';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ChoicesProps } from './selection.js';
|
|
3
|
+
/** A select-only combobox. DOM focus stays on the trigger while its active option is announced. */
|
|
4
|
+
export declare function Select({ label, options, value, defaultValue, disabled, onValueChange }: ChoicesProps): React.JSX.Element;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useId, useLayoutEffect, useRef, useState } from 'react';
|
|
4
|
+
import { useControllable, useHIG } from './provider.js';
|
|
5
|
+
/** A select-only combobox. DOM focus stays on the trigger while its active option is announced. */
|
|
6
|
+
export function Select({ label, options, value, defaultValue, disabled, onValueChange }) {
|
|
7
|
+
const id = useId();
|
|
8
|
+
const { direction, locale } = useHIG();
|
|
9
|
+
const [current, setCurrent] = useControllable(value, defaultValue ?? options.find(option => !option.disabled)?.value ?? '', onValueChange);
|
|
10
|
+
const [open, setOpen] = useState(false);
|
|
11
|
+
const [active, setActive] = useState(-1);
|
|
12
|
+
const trigger = useRef(null);
|
|
13
|
+
const list = useRef(null);
|
|
14
|
+
const search = useRef({ text: '', time: 0 });
|
|
15
|
+
const match = options.findIndex(option => option.value === current);
|
|
16
|
+
const selected = match >= 0 ? match : options.findIndex(option => !option.disabled);
|
|
17
|
+
const expanded = open && !disabled && options.length > 0;
|
|
18
|
+
const activeOption = active >= 0 && !options[active]?.disabled ? options[active] : undefined;
|
|
19
|
+
const optionId = (index) => `${id}-option-${index}`;
|
|
20
|
+
function show(edge) {
|
|
21
|
+
if (disabled || !options.length)
|
|
22
|
+
return;
|
|
23
|
+
// Safari does not focus buttons on pointer activation; the combobox owns keyboard navigation.
|
|
24
|
+
trigger.current?.focus();
|
|
25
|
+
const enabled = options.flatMap((option, index) => option.disabled ? [] : [index]);
|
|
26
|
+
setActive(edge === 'last' ? (enabled.at(-1) ?? -1) : edge === 'first' ? (enabled[0] ?? -1) : selected >= 0 && !options[selected].disabled ? selected : enabled[0] ?? -1);
|
|
27
|
+
setOpen(true);
|
|
28
|
+
search.current = { text: '', time: 0 };
|
|
29
|
+
}
|
|
30
|
+
function choose(index) {
|
|
31
|
+
const option = options[index];
|
|
32
|
+
if (disabled || !option || option.disabled)
|
|
33
|
+
return;
|
|
34
|
+
setCurrent(option.value);
|
|
35
|
+
setOpen(false);
|
|
36
|
+
trigger.current?.focus();
|
|
37
|
+
}
|
|
38
|
+
function move(delta) {
|
|
39
|
+
const enabled = options.flatMap((option, index) => option.disabled ? [] : [index]);
|
|
40
|
+
if (!enabled.length)
|
|
41
|
+
return;
|
|
42
|
+
const position = enabled.indexOf(active);
|
|
43
|
+
setActive(enabled[Math.min(enabled.length - 1, Math.max(0, position + delta))]);
|
|
44
|
+
}
|
|
45
|
+
function onKeyDown(event) {
|
|
46
|
+
if (disabled)
|
|
47
|
+
return;
|
|
48
|
+
if (event.key === 'Escape' && expanded) {
|
|
49
|
+
event.preventDefault();
|
|
50
|
+
event.stopPropagation();
|
|
51
|
+
setOpen(false);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (event.key === 'Tab') {
|
|
55
|
+
setOpen(false);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
|
59
|
+
event.preventDefault();
|
|
60
|
+
if (!expanded)
|
|
61
|
+
show();
|
|
62
|
+
else
|
|
63
|
+
move(event.key === 'ArrowDown' ? 1 : -1);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (event.key === 'Home' || event.key === 'End') {
|
|
67
|
+
event.preventDefault();
|
|
68
|
+
show(event.key === 'Home' ? 'first' : 'last');
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (event.key === 'Enter' || (event.key === ' ' && (!search.current.text || Date.now() - search.current.time >= 700))) {
|
|
72
|
+
event.preventDefault();
|
|
73
|
+
if (expanded)
|
|
74
|
+
choose(active);
|
|
75
|
+
else
|
|
76
|
+
show();
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (event.key.length !== 1 || event.ctrlKey || event.metaKey || event.altKey)
|
|
80
|
+
return;
|
|
81
|
+
event.preventDefault();
|
|
82
|
+
const now = Date.now();
|
|
83
|
+
const previous = now - search.current.time < 700 ? search.current.text : '';
|
|
84
|
+
const text = (previous + event.key).toLocaleLowerCase(locale);
|
|
85
|
+
search.current = { text, time: now };
|
|
86
|
+
const query = [...text].every(character => character === text[0]) ? text[0] : text;
|
|
87
|
+
const start = expanded ? active : selected;
|
|
88
|
+
// Multi-character typeahead also considers the active option; repeated letters cycle matches.
|
|
89
|
+
const offset = query.length > 1 ? 0 : 1;
|
|
90
|
+
for (let step = 0; step < options.length; step++) {
|
|
91
|
+
const index = (Math.max(start, 0) + step + offset) % options.length;
|
|
92
|
+
const option = options[index];
|
|
93
|
+
if (!option.disabled && option.label.toLocaleLowerCase(locale).startsWith(query)) {
|
|
94
|
+
if (expanded)
|
|
95
|
+
setActive(index);
|
|
96
|
+
else
|
|
97
|
+
setCurrent(option.value);
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
useLayoutEffect(() => {
|
|
103
|
+
if (!expanded || !trigger.current || !list.current)
|
|
104
|
+
return;
|
|
105
|
+
const popup = list.current;
|
|
106
|
+
const button = trigger.current;
|
|
107
|
+
// The top layer escapes overflow clipping without a portal, preserving host theme and modal ownership.
|
|
108
|
+
popup.showPopover?.();
|
|
109
|
+
const position = () => {
|
|
110
|
+
const rect = button.getBoundingClientRect();
|
|
111
|
+
const gap = 6;
|
|
112
|
+
const inset = 8;
|
|
113
|
+
const viewport = window.visualViewport;
|
|
114
|
+
const width = viewport?.width ?? window.innerWidth;
|
|
115
|
+
const height = viewport?.height ?? window.innerHeight;
|
|
116
|
+
const left = viewport?.offsetLeft ?? 0;
|
|
117
|
+
const top = viewport?.offsetTop ?? 0;
|
|
118
|
+
const below = top + height - rect.bottom - gap - inset;
|
|
119
|
+
const above = rect.top - top - gap - inset;
|
|
120
|
+
const desired = Math.min(320, popup.scrollHeight || 320);
|
|
121
|
+
const upwards = below < desired && above > below;
|
|
122
|
+
const maxHeight = Math.max(0, Math.min(320, upwards ? above : below));
|
|
123
|
+
const popupWidth = Math.min(rect.width, Math.max(0, width - inset * 2));
|
|
124
|
+
popup.style.width = `${popupWidth}px`;
|
|
125
|
+
popup.style.maxHeight = `${maxHeight}px`;
|
|
126
|
+
popup.style.left = `${Math.max(left + inset, Math.min(direction === 'rtl' ? rect.right - popupWidth : rect.left, left + width - popupWidth - inset))}px`;
|
|
127
|
+
popup.style.top = `${upwards ? Math.max(top + inset, rect.top - gap - Math.min(popup.scrollHeight, maxHeight)) : rect.bottom + gap}px`;
|
|
128
|
+
};
|
|
129
|
+
position();
|
|
130
|
+
const resize = typeof ResizeObserver === 'undefined' ? undefined : new ResizeObserver(position);
|
|
131
|
+
resize?.observe(button);
|
|
132
|
+
window.addEventListener('resize', position);
|
|
133
|
+
window.addEventListener('scroll', position, true);
|
|
134
|
+
window.visualViewport?.addEventListener('resize', position);
|
|
135
|
+
window.visualViewport?.addEventListener('scroll', position);
|
|
136
|
+
return () => { resize?.disconnect(); window.removeEventListener('resize', position); window.removeEventListener('scroll', position, true); window.visualViewport?.removeEventListener('resize', position); window.visualViewport?.removeEventListener('scroll', position); };
|
|
137
|
+
}, [expanded, direction, options.length]);
|
|
138
|
+
useEffect(() => {
|
|
139
|
+
if (disabled || !options.length)
|
|
140
|
+
setOpen(false);
|
|
141
|
+
}, [disabled, options.length]);
|
|
142
|
+
useEffect(() => {
|
|
143
|
+
if (!expanded)
|
|
144
|
+
return;
|
|
145
|
+
const outside = (event) => { const target = event.target; if (!trigger.current?.contains(target) && !list.current?.contains(target))
|
|
146
|
+
setOpen(false); };
|
|
147
|
+
// Consume Escape before an enclosing modal's document capture listener can dismiss it too.
|
|
148
|
+
const escape = (event) => { if (event.key === 'Escape') {
|
|
149
|
+
event.preventDefault();
|
|
150
|
+
event.stopPropagation();
|
|
151
|
+
setOpen(false);
|
|
152
|
+
} };
|
|
153
|
+
document.addEventListener('pointerdown', outside);
|
|
154
|
+
window.addEventListener('keydown', escape, true);
|
|
155
|
+
return () => { document.removeEventListener('pointerdown', outside); window.removeEventListener('keydown', escape, true); };
|
|
156
|
+
}, [expanded]);
|
|
157
|
+
useEffect(() => {
|
|
158
|
+
if (!expanded || !activeOption)
|
|
159
|
+
return;
|
|
160
|
+
const option = document.getElementById(optionId(active));
|
|
161
|
+
const popup = list.current;
|
|
162
|
+
if (!option || !popup)
|
|
163
|
+
return;
|
|
164
|
+
// Scroll only the option list: scrollIntoView can unexpectedly move the surrounding page.
|
|
165
|
+
if (option.offsetTop < popup.scrollTop)
|
|
166
|
+
popup.scrollTop = option.offsetTop;
|
|
167
|
+
else if (option.offsetTop + option.offsetHeight > popup.scrollTop + popup.clientHeight)
|
|
168
|
+
popup.scrollTop = option.offsetTop + option.offsetHeight - popup.clientHeight;
|
|
169
|
+
}, [expanded, active, activeOption, id]);
|
|
170
|
+
return _jsxs("div", { className: 'hig-field', children: [_jsx("label", { id: `${id}-label`, htmlFor: id, children: label }), _jsxs("div", { className: 'hig-select', children: [_jsxs("button", { ref: trigger, id: id, type: 'button', role: 'combobox', className: 'hig-input hig-select-trigger', disabled: disabled, "aria-labelledby": `${id}-label`, "aria-haspopup": 'listbox', "aria-expanded": expanded, "aria-controls": expanded ? `${id}-list` : undefined, "aria-activedescendant": expanded && activeOption ? optionId(active) : undefined, onClick: () => expanded ? setOpen(false) : show(), onKeyDown: onKeyDown, onBlur: () => setOpen(false), children: [_jsx("span", { className: 'hig-select-value', children: options[selected]?.label ?? '' }), _jsx("svg", { className: 'hig-select-chevron', "aria-hidden": 'true', viewBox: '0 0 20 20', children: _jsx("path", { d: 'm5 7.5 5 5 5-5' }) })] }), expanded && _jsx("div", { ref: list, id: `${id}-list`, className: 'hig-select-list', role: 'listbox', "aria-labelledby": `${id}-label`, popover: 'manual', onPointerDown: event => event.preventDefault(), children: options.map((option, index) => _jsxs("div", { id: optionId(index), role: 'option', className: 'hig-select-option', "aria-selected": index === selected, "aria-disabled": option.disabled || undefined, "data-active": index === active || undefined, onPointerMove: () => { if (!option.disabled)
|
|
171
|
+
setActive(index); }, onClick: () => choose(index), children: [_jsx("span", { children: option.label }), _jsx("svg", { className: 'hig-select-check', "aria-hidden": 'true', viewBox: '0 0 20 20', children: _jsx("path", { d: 'm4 10 4 4 8-8' }) })] }, option.value)) })] })] });
|
|
172
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface Choice {
|
|
3
|
+
value: string;
|
|
4
|
+
label: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
}
|
|
7
|
+
interface CheckedProps {
|
|
8
|
+
label: string;
|
|
9
|
+
checked?: boolean;
|
|
10
|
+
defaultChecked?: boolean;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
onCheckedChange?: (value: boolean) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare function Checkbox({ label, checked, defaultChecked, disabled, onCheckedChange }: CheckedProps): React.JSX.Element;
|
|
15
|
+
export declare function Switch({ label, checked, defaultChecked, disabled, onCheckedChange }: CheckedProps): React.JSX.Element;
|
|
16
|
+
export interface ChoicesProps {
|
|
17
|
+
label: string;
|
|
18
|
+
options: readonly Choice[];
|
|
19
|
+
value?: string;
|
|
20
|
+
defaultValue?: string;
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
onValueChange?: (value: string) => void;
|
|
23
|
+
}
|
|
24
|
+
export declare function RadioGroup({ label, options, value, defaultValue, disabled, onValueChange }: ChoicesProps): React.JSX.Element;
|
|
25
|
+
export declare function SegmentedControl({ label, options, value, defaultValue, disabled, onValueChange }: ChoicesProps): React.JSX.Element;
|
|
26
|
+
export { Select } from './select.js';
|
|
27
|
+
export { Slider } from './slider.js';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useId } from 'react';
|
|
4
|
+
import { useControllable } from './provider.js';
|
|
5
|
+
export function Checkbox({ label, checked, defaultChecked = false, disabled, onCheckedChange }) { const [value, set] = useControllable(checked, defaultChecked, onCheckedChange); return _jsxs("label", { className: 'hig-choice', children: [_jsx("input", { type: 'checkbox', checked: value, disabled: disabled, onChange: e => set(e.target.checked) }), _jsx("span", { children: label })] }); }
|
|
6
|
+
export function Switch({ label, checked, defaultChecked = false, disabled, onCheckedChange }) { const [value, set] = useControllable(checked, defaultChecked, onCheckedChange); return _jsxs("label", { className: 'hig-choice hig-switch', children: [_jsx("input", { role: 'switch', type: 'checkbox', checked: value, disabled: disabled, onChange: e => set(e.target.checked) }), _jsx("span", { children: label })] }); }
|
|
7
|
+
export function RadioGroup({ label, options, value, defaultValue = '', disabled, onValueChange }) { const name = useId(); const [current, set] = useControllable(value, defaultValue, onValueChange); return _jsxs("fieldset", { className: 'hig-group', disabled: disabled, children: [_jsx("legend", { children: label }), options.map(o => _jsxs("label", { className: 'hig-choice', children: [_jsx("input", { type: 'radio', name: name, value: o.value, checked: current === o.value, disabled: o.disabled, onChange: () => set(o.value) }), _jsx("span", { children: o.label })] }, o.value))] }); }
|
|
8
|
+
export function SegmentedControl({ label, options, value, defaultValue = '', disabled, onValueChange }) {
|
|
9
|
+
const name = useId();
|
|
10
|
+
const [current, set] = useControllable(value, defaultValue, onValueChange);
|
|
11
|
+
const selected = options.findIndex(option => option.value === current);
|
|
12
|
+
return _jsxs("fieldset", { className: 'hig-group hig-segmented-control', disabled: disabled, children: [_jsx("legend", { children: label }), _jsxs("div", { className: 'hig-segments', style: { '--hig-segment-count': Math.max(1, options.length), '--hig-segment-index': selected }, children: [selected >= 0 && _jsx("span", { className: 'hig-segment-indicator', "aria-hidden": 'true', "data-disabled": disabled || options[selected].disabled || undefined }), options.map(o => _jsxs("label", { className: 'hig-segment', children: [_jsx("input", { type: 'radio', name: name, value: o.value, checked: current === o.value, disabled: o.disabled, onChange: () => { if (!disabled && !o.disabled)
|
|
13
|
+
set(o.value); } }), _jsx("span", { children: o.label })] }, o.value))] })] });
|
|
14
|
+
}
|
|
15
|
+
export { Select } from './select.js';
|
|
16
|
+
export { Slider } from './slider.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare function Slider({ label, value, defaultValue, min, max, step, disabled, onValueChange }: {
|
|
3
|
+
label: string;
|
|
4
|
+
value?: number;
|
|
5
|
+
defaultValue?: number;
|
|
6
|
+
min?: number;
|
|
7
|
+
max?: number;
|
|
8
|
+
step?: number;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
onValueChange?: (value: number) => void;
|
|
11
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useId } from 'react';
|
|
4
|
+
import { useControllable } from './provider.js';
|
|
5
|
+
export function Slider({ label, value, defaultValue = 0, min = 0, max = 100, step = 1, disabled, onValueChange }) {
|
|
6
|
+
const id = useId();
|
|
7
|
+
const [current, set] = useControllable(value, defaultValue, onValueChange);
|
|
8
|
+
const fill = max > min ? Math.min(100, Math.max(0, (current - min) / (max - min) * 100)) : 0;
|
|
9
|
+
return _jsxs("div", { className: 'hig-field hig-slider', children: [_jsxs("label", { htmlFor: id, children: [label, ": ", current] }), _jsx("input", { id: id, className: 'hig-range', style: { '--hig-range-fill': `${fill}%` }, type: 'range', min: min, max: max, step: step, disabled: disabled, value: current, onChange: e => set(e.target.valueAsNumber) })] });
|
|
10
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type BadgeTone = 'neutral' | 'positive' | 'negative' | 'warning' | 'info';
|
|
3
|
+
export interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
4
|
+
tone?: BadgeTone;
|
|
5
|
+
}
|
|
6
|
+
/** A quiet status label. The host owns announcements and may supply typography or an accessible name. */
|
|
7
|
+
export declare const Badge: React.ForwardRefExoticComponent<BadgeProps & React.RefAttributes<HTMLSpanElement>>;
|
|
8
|
+
/** `note` and `tip` are documentation callout severities: note uses the `info` token role and tip the `positive` role, like info and success. `default` is the neutral variant: border token stroke with a soft white glow instead of a tone. */
|
|
9
|
+
export type AlertSeverity = 'default' | 'info' | 'success' | 'warning' | 'error' | 'note' | 'tip';
|
|
10
|
+
/** Severity sets the glowing stroke from a token role (default → border, info/note → info, success/tip → positive, warning → warning, error → negative): a 2px tone border with a matching glow on a translucent surface. The title may be any inline node, such as text with a code span. */
|
|
11
|
+
export declare function Alert({ title, children, severity, action, announce }: React.PropsWithChildren<{
|
|
12
|
+
title: React.ReactNode;
|
|
13
|
+
severity?: AlertSeverity;
|
|
14
|
+
action?: React.ReactNode;
|
|
15
|
+
announce?: boolean;
|
|
16
|
+
}>): React.JSX.Element;
|
|
17
|
+
export declare const Callout: typeof Alert;
|
|
18
|
+
export interface Notice {
|
|
19
|
+
id: string;
|
|
20
|
+
message: string;
|
|
21
|
+
severity: 'info' | 'success' | 'warning' | 'error';
|
|
22
|
+
action?: React.ReactNode;
|
|
23
|
+
}
|
|
24
|
+
/** Persistent until dismissed; host deduplicates ids, critical messages remain inline. */
|
|
25
|
+
export declare function Toast({ notices, onDismiss, dismissLabel }: {
|
|
26
|
+
notices: readonly Notice[];
|
|
27
|
+
onDismiss: (id: string) => void; /** Dismiss button text; defaults to HIGProvider `messages.dismiss`. The accessible name comes from `messages.dismissNotice` and contains it. */
|
|
28
|
+
dismissLabel?: string;
|
|
29
|
+
}): React.JSX.Element;
|
|
30
|
+
export declare function Progress({ label, value, max }: {
|
|
31
|
+
label: string;
|
|
32
|
+
value?: number;
|
|
33
|
+
max?: number;
|
|
34
|
+
}): React.JSX.Element;
|
|
35
|
+
export declare function Spinner({ label }: {
|
|
36
|
+
label?: string;
|
|
37
|
+
}): React.JSX.Element;
|
|
38
|
+
export declare function Skeleton({ label }: {
|
|
39
|
+
label?: string;
|
|
40
|
+
}): React.JSX.Element;
|
|
41
|
+
export declare function EmptyState({ title, description, action }: {
|
|
42
|
+
title: string;
|
|
43
|
+
description: string;
|
|
44
|
+
action?: React.ReactNode;
|
|
45
|
+
}): React.JSX.Element;
|
|
46
|
+
export declare function Avatar({ name, src }: {
|
|
47
|
+
name: string;
|
|
48
|
+
src?: string;
|
|
49
|
+
}): React.JSX.Element;
|
|
50
|
+
export declare function StatusIndicator({ label, state }: {
|
|
51
|
+
label: string;
|
|
52
|
+
state: 'online' | 'offline' | 'stale';
|
|
53
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { notificationDelta } from '@bloxwap/hig/contracts/announcements';
|
|
5
|
+
import { Button } from './button.js';
|
|
6
|
+
import * as en from '@bloxwap/hig/contracts/messages';
|
|
7
|
+
import { useHIG } from './provider.js';
|
|
8
|
+
/** A quiet status label. The host owns announcements and may supply typography or an accessible name. */
|
|
9
|
+
export const Badge = React.forwardRef(function Badge({ children, tone = 'neutral', className, ...props }, ref) { const accent = ['positive', 'negative', 'warning', 'info'].includes(tone) ? tone : undefined; return _jsx("span", { ...props, ref: ref, className: ['hig-badge', className].filter(Boolean).join(' '), "data-tone": accent, children: children }); });
|
|
10
|
+
/** Severity sets the glowing stroke from a token role (default → border, info/note → info, success/tip → positive, warning → warning, error → negative): a 2px tone border with a matching glow on a translucent surface. The title may be any inline node, such as text with a code span. */
|
|
11
|
+
export function Alert({ title, children, severity = 'info', action, announce = true }) { return _jsxs("section", { className: 'hig-surface hig-alert', "data-severity": severity, role: announce ? (severity === 'error' ? 'alert' : 'status') : undefined, children: [_jsx("strong", { children: title }), children, action != null && _jsx("div", { className: 'hig-alert-actions', children: action })] }); }
|
|
12
|
+
export const Callout = Alert;
|
|
13
|
+
/** Persistent until dismissed; host deduplicates ids, critical messages remain inline. */
|
|
14
|
+
export function Toast({ notices, onDismiss, dismissLabel }) {
|
|
15
|
+
const { messages } = useHIG();
|
|
16
|
+
const dismiss = dismissLabel ?? messages.dismiss ?? en.dismiss;
|
|
17
|
+
const unique = [...new Map(notices.map(n => [n.id, n])).values()], previous = useRef(new Map());
|
|
18
|
+
const [announcement, setAnnouncement] = useState({ message: '', severity: 'info' });
|
|
19
|
+
const pending = useRef(null), timer = useRef(null);
|
|
20
|
+
const key = JSON.stringify(unique.map(n => [n.id, n.message, n.severity]));
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
const delta = notificationDelta(previous.current, unique);
|
|
23
|
+
previous.current = delta.next;
|
|
24
|
+
if (!delta.message || !delta.id)
|
|
25
|
+
return;
|
|
26
|
+
if (pending.current?.severity !== 'error' || !unique.some(n => n.id === pending.current?.id && n.message === pending.current.message))
|
|
27
|
+
pending.current = { id: delta.id, message: delta.message, severity: delta.severity };
|
|
28
|
+
if (timer.current !== null)
|
|
29
|
+
return;
|
|
30
|
+
setAnnouncement({ message: '', severity: pending.current.severity });
|
|
31
|
+
timer.current = setTimeout(() => { timer.current = null; const notice = pending.current; pending.current = null; if (notice && previous.current.get(notice.id) === JSON.stringify([notice.message, notice.severity]))
|
|
32
|
+
setAnnouncement({ message: notice.message, severity: notice.severity }); }, 25);
|
|
33
|
+
}, [key]);
|
|
34
|
+
useEffect(() => () => { if (timer.current !== null)
|
|
35
|
+
clearTimeout(timer.current); }, []);
|
|
36
|
+
return _jsxs("aside", { className: 'hig-toast', "aria-label": messages.notifications ?? en.notifications, children: [unique.map(n => _jsx(Alert, { announce: false, title: n.message, severity: n.severity, action: _jsxs(_Fragment, { children: [n.action, _jsx(Button, { intent: 'ghost', "aria-label": (messages.dismissNotice ?? en.dismissNotice)(n.message, dismiss), onClick: () => onDismiss(n.id), children: dismiss })] }) }, n.id)), _jsx("span", { className: 'hig-sr-only', role: announcement.severity === 'error' ? 'alert' : 'status', "aria-atomic": 'true', children: announcement.message })] });
|
|
37
|
+
}
|
|
38
|
+
export function Progress({ label, value, max = 100 }) { return _jsxs("label", { className: 'hig-progress', children: [label, _jsx("progress", { "aria-label": label, value: value, max: max })] }); }
|
|
39
|
+
export function Spinner({ label }) { const { messages } = useHIG(); return _jsxs("span", { className: 'hig-spinner', role: 'status', children: [_jsx("span", { className: 'hig-spinner-indicator', "aria-hidden": 'true' }), label ?? messages.loading ?? en.loading, "\u2026"] }); }
|
|
40
|
+
export function Skeleton({ label }) { const { messages } = useHIG(); return _jsx("div", { className: 'hig-skeleton', "aria-label": label ?? messages.loadingContent ?? en.loadingContent, role: 'status' }); }
|
|
41
|
+
export function EmptyState({ title, description, action }) { return _jsxs("section", { className: 'hig-surface hig-empty-state', children: [_jsx("h3", { children: title }), _jsx("p", { children: description }), action] }); }
|
|
42
|
+
export function Avatar({ name, src }) { return src ? _jsx("img", { className: 'hig-avatar', alt: name, src: src }) : _jsx("span", { className: 'hig-avatar', role: 'img', "aria-label": name, children: name.slice(0, 2) }); }
|
|
43
|
+
export function StatusIndicator({ label, state }) { const { messages } = useHIG(); const text = { online: messages.statusOnline ?? en.statusOnline, offline: messages.statusOffline ?? en.statusOffline, stale: messages.statusStale ?? en.statusStale }[state] ?? state; return _jsxs("span", { className: 'hig-status-indicator', "data-state": state, children: [label, ": ", text] }); }
|