@bloxwap/hig 0.6.0 → 0.7.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.
Files changed (167) hide show
  1. package/chart/README.md +1 -1
  2. package/contracts/README.md +1 -1
  3. package/contracts/dist/index.d.ts +16 -0
  4. package/contracts/dist/index.js +22 -0
  5. package/contracts/dist/messages.d.ts +6 -0
  6. package/contracts/dist/messages.js +3 -1
  7. package/feedback/README.md +1 -1
  8. package/native/README.md +1 -1
  9. package/native/dist/account-block.d.ts +53 -7
  10. package/native/dist/account-block.js +42 -9
  11. package/native/dist/animated-number-model.d.ts +7 -1
  12. package/native/dist/animated-number-model.js +50 -1
  13. package/native/dist/animated-number.d.ts +3 -1
  14. package/native/dist/animated-number.js +8 -5
  15. package/native/dist/asset-balance-row.d.ts +17 -1
  16. package/native/dist/asset-balance-row.js +13 -8
  17. package/native/dist/bar-mark.d.ts +14 -2
  18. package/native/dist/bar-mark.js +19 -5
  19. package/native/dist/bar-pnl.js +5 -4
  20. package/native/dist/blocks.d.ts +8 -14
  21. package/native/dist/blocks.js +5 -6
  22. package/native/dist/button.js +3 -1
  23. package/native/dist/data.d.ts +1 -1
  24. package/native/dist/data.js +6 -4
  25. package/native/dist/field.d.ts +14 -4
  26. package/native/dist/field.js +33 -7
  27. package/native/dist/figure.d.ts +23 -0
  28. package/native/dist/figure.js +10 -0
  29. package/native/dist/language-block.d.ts +5 -1
  30. package/native/dist/language-block.js +3 -3
  31. package/native/dist/list-group.d.ts +42 -8
  32. package/native/dist/list-group.js +71 -13
  33. package/native/dist/manage-position-block.d.ts +28 -2
  34. package/native/dist/manage-position-block.js +36 -11
  35. package/native/dist/market-row.d.ts +46 -0
  36. package/native/dist/market-row.js +30 -0
  37. package/native/dist/notifications-block.d.ts +30 -2
  38. package/native/dist/notifications-block.js +16 -8
  39. package/native/dist/pickers.d.ts +24 -2
  40. package/native/dist/pickers.js +16 -8
  41. package/native/dist/position-block.d.ts +66 -10
  42. package/native/dist/position-block.js +45 -11
  43. package/native/dist/profile-block.d.ts +29 -5
  44. package/native/dist/profile-block.js +25 -5
  45. package/native/dist/provider.d.ts +9 -3
  46. package/native/dist/provider.js +7 -3
  47. package/native/dist/radio-group.d.ts +9 -3
  48. package/native/dist/radio-group.js +4 -5
  49. package/native/dist/recipes.d.ts +6 -0
  50. package/native/dist/recipes.js +6 -0
  51. package/native/dist/reward-block.d.ts +45 -6
  52. package/native/dist/reward-block.js +30 -12
  53. package/native/dist/screen-header.d.ts +49 -0
  54. package/native/dist/screen-header.js +29 -0
  55. package/native/dist/selection.d.ts +2 -2
  56. package/native/dist/setting-header.d.ts +2 -8
  57. package/native/dist/setting-header.js +2 -11
  58. package/native/dist/setting-switch.d.ts +14 -1
  59. package/native/dist/setting-switch.js +5 -2
  60. package/native/dist/signals-block.d.ts +26 -2
  61. package/native/dist/signals-block.js +14 -4
  62. package/native/dist/sound-haptics-block.d.ts +29 -2
  63. package/native/dist/sound-haptics-block.js +18 -7
  64. package/native/dist/status.d.ts +6 -5
  65. package/native/dist/status.js +5 -5
  66. package/native/dist/sticky-header.d.ts +28 -0
  67. package/native/dist/sticky-header.js +21 -0
  68. package/native/dist/surface.d.ts +3 -1
  69. package/native/dist/surface.js +2 -1
  70. package/native/dist/swap-panel-block.d.ts +2 -1
  71. package/native/dist/swap-panel-block.js +9 -6
  72. package/native/dist/swap-parts.d.ts +5 -3
  73. package/native/dist/swap-parts.js +2 -2
  74. package/native/dist/swap-shared.d.ts +6 -0
  75. package/native/dist/swap-views.js +5 -3
  76. package/native/dist/switch-row.d.ts +3 -2
  77. package/native/dist/switch-row.js +5 -3
  78. package/native/dist/switch.d.ts +4 -2
  79. package/native/dist/switch.js +3 -3
  80. package/native/dist/target-block.d.ts +33 -6
  81. package/native/dist/target-block.js +19 -6
  82. package/native/dist/token-action-block.d.ts +17 -9
  83. package/native/dist/token-action-block.js +14 -6
  84. package/native/dist/trade-history-detail-block.d.ts +26 -1
  85. package/native/dist/trade-history-detail-block.js +17 -9
  86. package/native/dist/trade-history-list-block.d.ts +71 -5
  87. package/native/dist/trade-history-list-block.js +50 -15
  88. package/native/dist/wallet-address-core.d.ts +25 -0
  89. package/native/dist/wallet-address-core.js +31 -0
  90. package/native/dist/wallet-address.d.ts +6 -10
  91. package/native/dist/wallet-address.js +16 -20
  92. package/native-fonts/README.md +1 -1
  93. package/og-fonts/README.md +1 -1
  94. package/package.json +21 -1
  95. package/react/README.md +1 -1
  96. package/react/dist/animated-number-model.d.ts +6 -0
  97. package/react/dist/animated-number-model.js +33 -0
  98. package/react/dist/animated-number.d.ts +5 -1
  99. package/react/dist/animated-number.js +12 -8
  100. package/react/dist/asset-balance-row.d.ts +17 -1
  101. package/react/dist/asset-balance-row.js +11 -3
  102. package/react/dist/bar-mark.d.ts +5 -2
  103. package/react/dist/bar-mark.js +5 -3
  104. package/react/dist/blocks/account-block.d.ts +53 -7
  105. package/react/dist/blocks/account-block.js +45 -10
  106. package/react/dist/blocks/language-block.d.ts +5 -1
  107. package/react/dist/blocks/language-block.js +6 -5
  108. package/react/dist/blocks/manage-position-block.d.ts +28 -2
  109. package/react/dist/blocks/manage-position-block.js +23 -4
  110. package/react/dist/blocks/market-row.d.ts +20 -9
  111. package/react/dist/blocks/market-row.js +12 -4
  112. package/react/dist/blocks/notifications-block.d.ts +25 -2
  113. package/react/dist/blocks/notifications-block.js +11 -2
  114. package/react/dist/blocks/pickers.d.ts +21 -1
  115. package/react/dist/blocks/pickers.js +30 -10
  116. package/react/dist/blocks/position-block.d.ts +34 -11
  117. package/react/dist/blocks/position-block.js +16 -5
  118. package/react/dist/blocks/profile-block.d.ts +29 -6
  119. package/react/dist/blocks/profile-block.js +31 -5
  120. package/react/dist/blocks/reward-block.d.ts +53 -14
  121. package/react/dist/blocks/reward-block.js +20 -10
  122. package/react/dist/blocks/screen-header.d.ts +26 -2
  123. package/react/dist/blocks/screen-header.js +13 -5
  124. package/react/dist/blocks/setting-switch.d.ts +14 -1
  125. package/react/dist/blocks/setting-switch.js +8 -4
  126. package/react/dist/blocks/signals-block.d.ts +21 -2
  127. package/react/dist/blocks/signals-block.js +5 -5
  128. package/react/dist/blocks/sound-haptics-block.d.ts +25 -3
  129. package/react/dist/blocks/sound-haptics-block.js +11 -7
  130. package/react/dist/blocks/sticky-header.d.ts +9 -0
  131. package/react/dist/blocks/sticky-header.js +43 -0
  132. package/react/dist/blocks/swap/amount-card.js +2 -1
  133. package/react/dist/blocks/swap/settings.js +2 -2
  134. package/react/dist/blocks/swap/shared.d.ts +7 -1
  135. package/react/dist/blocks/swap/shared.js +6 -4
  136. package/react/dist/blocks/swap-panel-block.d.ts +2 -0
  137. package/react/dist/blocks/swap-panel-block.js +6 -6
  138. package/react/dist/blocks/target-block.d.ts +28 -6
  139. package/react/dist/blocks/target-block.js +17 -9
  140. package/react/dist/blocks/token-action-block.d.ts +17 -8
  141. package/react/dist/blocks/token-action-block.js +9 -6
  142. package/react/dist/blocks/trade-history-detail-block.d.ts +21 -1
  143. package/react/dist/blocks/trade-history-detail-block.js +5 -4
  144. package/react/dist/blocks/trade-history-list-block.d.ts +29 -5
  145. package/react/dist/blocks/trade-history-list-block.js +15 -8
  146. package/react/dist/blocks.d.ts +8 -8
  147. package/react/dist/blocks.js +2 -2
  148. package/react/dist/button.js +6 -4
  149. package/react/dist/data.js +3 -3
  150. package/react/dist/field.d.ts +14 -4
  151. package/react/dist/field.js +19 -6
  152. package/react/dist/figure.d.ts +23 -0
  153. package/react/dist/figure.js +12 -0
  154. package/react/dist/list-group.d.ts +41 -8
  155. package/react/dist/list-group.js +44 -12
  156. package/react/dist/provider.d.ts +40 -3
  157. package/react/dist/provider.js +63 -6
  158. package/react/dist/selection.d.ts +8 -2
  159. package/react/dist/selection.js +11 -6
  160. package/react/dist/styles.css +164 -9
  161. package/react/dist/surface.d.ts +5 -1
  162. package/react/dist/surface.js +1 -1
  163. package/react/dist/wallet-address-core.d.ts +23 -0
  164. package/react/dist/wallet-address-core.js +24 -0
  165. package/react/dist/wallet-address.d.ts +6 -12
  166. package/react/dist/wallet-address.js +5 -16
  167. package/tokens/README.md +1 -1
@@ -1,10 +1,10 @@
1
1
  "use client";
2
2
  import { createElement as _createElement } from "react";
3
3
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
- import { formatNumber } from '@bloxwap/hig/contracts';
4
+ import { formatNumber, presentNumberFormat } from '@bloxwap/hig/contracts';
5
5
  import * as en from '@bloxwap/hig/contracts/messages';
6
- import { useHIG } from './provider.js';
7
- export function NumberReadout({ value, options, stale, label, prefix = '', suffix = '' }) { const { locale, messages } = useHIG(); const known = value != null && Number.isFinite(value), formatted = formatNumber(value, locale, options), reading = known ? `${prefix}${formatted}${suffix}` : formatted; return _jsxs("span", { className: 'hig-number', "aria-label": label ? `${label}: ${reading}${stale ? ` ${messages.stale ?? en.stale}` : ''}` : undefined, children: [reading, stale && _jsxs("span", { children: [" ", messages.stale ?? en.stale] })] }); }
6
+ import { useHIG, useNumberLocale } from './provider.js';
7
+ export function NumberReadout({ value, options, stale, label, prefix = '', suffix = '' }) { const { messages, numberFormat } = useHIG(); const locale = useNumberLocale(); const known = value != null && Number.isFinite(value), formatted = formatNumber(value, locale, presentNumberFormat(options, numberFormat)), reading = known ? `${prefix}${formatted}${suffix}` : formatted; return _jsxs("span", { className: 'hig-number', "aria-label": label ? `${label}: ${reading}${stale ? ` ${messages.stale ?? en.stale}` : ''}` : undefined, children: [reading, stale && _jsxs("span", { children: [" ", messages.stale ?? en.stale] })] }); }
8
8
  export function Usd(props) { return _jsx(NumberReadout, { ...props, options: { style: 'currency', currency: 'USD', ...props.options } }); }
9
9
  /** Input is percent points: 5 means 5%, not 500%. */
10
10
  export function Percent(props) { return _jsx(NumberReadout, { ...props, value: props.value == null ? props.value : props.value / 100, options: { maximumFractionDigits: Math.max(3, props.options?.minimumFractionDigits ?? 0), ...props.options, style: 'percent' } }); }
@@ -1,14 +1,24 @@
1
1
  import React from 'react';
2
- export declare function Field({ id: provided, label, description, error, required, disabled, children }: React.PropsWithChildren<{
2
+ export interface FieldProps {
3
3
  id?: string;
4
4
  label: string;
5
- description?: string;
5
+ description?: string; /** `positive` draws the description as a success line, such as a name that is available, and announces it when it changes. The words carry the meaning; the colour repeats it. */
6
+ descriptionTone?: 'muted' | 'positive';
6
7
  error?: string;
7
8
  required?: boolean;
8
9
  disabled?: boolean;
9
- }>): React.JSX.Element;
10
+ }
11
+ export declare function Field({ id: provided, label, description, descriptionTone, error, required, disabled, children }: React.PropsWithChildren<FieldProps>): React.JSX.Element;
10
12
  export declare const Label: (props: React.LabelHTMLAttributes<HTMLLabelElement>) => React.JSX.Element;
11
13
  export declare const Input: React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & React.RefAttributes<HTMLInputElement>>;
12
14
  export declare const TextArea: React.ForwardRefExoticComponent<React.TextareaHTMLAttributes<HTMLTextAreaElement> & React.RefAttributes<HTMLTextAreaElement>>;
13
15
  /** The magnifying glass sits inset on the leading edge; the input keeps the ref, class and every prop. Marked pure so a bundle that imports another field drops the icon. */
14
- export declare const SearchInput: React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & React.RefAttributes<HTMLInputElement>>;
16
+ export interface SearchInputProps extends React.InputHTMLAttributes<HTMLInputElement> {
17
+ /** Host content on the trailing edge inside the field, such as a filter button. The text stops 48 units short of the edge; wider content sets the input's `padding-inline-end`. */
18
+ trailing?: React.ReactNode;
19
+ /** Shows a clear button on the trailing edge while the controlled `value` is not empty. It calls this and returns focus to the field. */
20
+ onClear?: () => void;
21
+ /** Accessible name of the clear button; defaults to HIGProvider `messages.clearSearch`. */
22
+ clearLabel?: string;
23
+ }
24
+ export declare const SearchInput: React.ForwardRefExoticComponent<SearchInputProps & React.RefAttributes<HTMLInputElement>>;
@@ -1,18 +1,31 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { createContext, useContext, useId, forwardRef } from 'react';
3
+ import { createContext, useContext, useId, useRef, forwardRef } from 'react';
4
4
  import * as en from '@bloxwap/hig/contracts/messages';
5
- import { useHIG } from './provider.js';
5
+ import { PressDecoration, useHIG } from './provider.js';
6
6
  const Context = createContext({ id: '' });
7
- export function Field({ id: provided, label, description, error, required, disabled, children }) {
7
+ export function Field({ id: provided, label, description, descriptionTone, error, required, disabled, children }) {
8
8
  const { messages } = useHIG();
9
9
  const generated = useId();
10
10
  const id = provided ?? generated;
11
11
  const ids = [description && `${id}-help`, error && `${id}-error`].filter(Boolean).join(' ') || undefined;
12
- return _jsx(Context.Provider, { value: { id, description: ids, invalid: !!error, disabled, required }, children: _jsxs("div", { className: 'hig-field', children: [_jsxs("label", { htmlFor: id, children: [label, required ? ` ${messages.required ?? en.required}` : ''] }), children, description && _jsx("p", { id: `${id}-help`, children: description }), error && _jsx("p", { id: `${id}-error`, role: 'alert', children: error })] }) });
12
+ const positive = descriptionTone === 'positive';
13
+ return _jsx(Context.Provider, { value: { id, description: ids, invalid: !!error, disabled, required }, children: _jsxs("div", { className: 'hig-field', children: [_jsxs("label", { htmlFor: id, children: [label, required ? ` ${messages.required ?? en.required}` : ''] }), children, description && _jsx("p", { id: `${id}-help`, "data-tone": positive ? 'positive' : undefined, "aria-live": positive ? 'polite' : undefined, children: description }), error && _jsx("p", { id: `${id}-error`, role: 'alert', children: error })] }) });
13
14
  }
14
15
  export const Label = (props) => _jsx("label", { ...props });
15
16
  export const Input = forwardRef(function Input(props, ref) { const field = useContext(Context); return _jsx("input", { id: field.id || undefined, "aria-describedby": field.description, "aria-invalid": field.invalid || undefined, required: field.required, ...props, disabled: !!field.disabled || props.disabled, ref: ref, className: `hig-input ${props.className ?? ''}` }); });
16
17
  export const TextArea = forwardRef(function TextArea(props, ref) { const field = useContext(Context); return _jsx("textarea", { id: field.id || undefined, "aria-describedby": field.description, "aria-invalid": field.invalid || undefined, required: field.required, ...props, disabled: !!field.disabled || props.disabled, ref: ref, className: `hig-input ${props.className ?? ''}` }); });
17
- /** The magnifying glass sits inset on the leading edge; the input keeps the ref, class and every prop. Marked pure so a bundle that imports another field drops the icon. */
18
- export const SearchInput = /* @__PURE__ */ forwardRef(function SearchInput(props, ref) { return _jsxs("span", { className: 'hig-search-input', children: [_jsxs("svg", { className: 'hig-search-icon', "aria-hidden": 'true', focusable: 'false', viewBox: '0 0 20 20', children: [_jsx("circle", { cx: '9', cy: '9', r: '5.25' }), _jsx("path", { d: 'm13 13 3.5 3.5' })] }), _jsx(Input, { type: 'search', ...props, ref: ref })] }); });
18
+ export const SearchInput = /* @__PURE__ */ forwardRef(function SearchInput({ trailing, onClear, clearLabel, ...props }, ref) {
19
+ const { messages } = useHIG();
20
+ const inner = useRef(null);
21
+ const off = !!useContext(Context).disabled || !!props.disabled;
22
+ const attach = (node) => { inner.current = node; if (typeof ref === 'function')
23
+ ref(node);
24
+ else if (ref)
25
+ ref.current = node; };
26
+ const clear = onClear && props.value != null && String(props.value) !== '' ? _jsxs("button", { type: 'button', className: 'hig-search-clear', "aria-label": clearLabel ?? messages.clearSearch ?? en.clearSearch, disabled: off, onClick: () => { onClear(); inner.current?.focus(); }, children: [_jsx("svg", { "aria-hidden": 'true', focusable: 'false', viewBox: '0 0 16 16', children: _jsx("path", { d: 'm4 4 8 8m0-8-8 8' }) }), _jsx(PressDecoration, { kind: 'icon-button', disabled: off })] }) : null;
27
+ const extra = trailing != null && trailing !== false;
28
+ const end = extra || clear ? _jsxs("span", { className: 'hig-search-trailing', children: [trailing, clear] }) : null;
29
+ // The end padding stays while the clear button comes and goes, so typed text never reflows.
30
+ return _jsxs("span", { className: 'hig-search-input', "data-trailing": extra || onClear ? '' : undefined, children: [_jsxs("svg", { className: 'hig-search-icon', "aria-hidden": 'true', focusable: 'false', viewBox: '0 0 20 20', children: [_jsx("circle", { cx: '9', cy: '9', r: '5.25' }), _jsx("path", { d: 'm13 13 3.5 3.5' })] }), _jsx(Input, { type: 'search', ...props, ref: onClear ? attach : ref }), end] });
31
+ });
@@ -0,0 +1,23 @@
1
+ /**
2
+ * A number the host supplies as a number so it updates place by place: `{value:0.53,options:{style:'currency',currency:'USD'}}`.
3
+ * `null` reads as unknown. `formattedValue` is the host's own text for the value, drawn and read in place of Intl's, which
4
+ * still moves place by place: use it where the browser's Intl does not match the host's number table. Never parse it back.
5
+ */
6
+ export interface Figure {
7
+ value: number | null;
8
+ options?: Intl.NumberFormatOptions;
9
+ prefix?: string;
10
+ suffix?: string;
11
+ formattedValue?: string;
12
+ }
13
+ /** The props of an `AnimatedNumberReadout` that draws a figure: its host text, when given, moves place by place too. */
14
+ export declare function figureProps(figure: Figure): {
15
+ value: number | null;
16
+ options?: Intl.NumberFormatOptions;
17
+ prefix?: string;
18
+ suffix?: string;
19
+ formattedValue?: string;
20
+ animateFormatted?: boolean;
21
+ };
22
+ /** What a figure reads as, with the provider's money format already merged into `options` by the caller. Unknown values read as the dash, without affixes. */
23
+ export declare function figureReading(figure: Figure, locale: string, options?: Intl.NumberFormatOptions): string;
@@ -0,0 +1,12 @@
1
+ import { formatNumber } from '@bloxwap/hig/contracts';
2
+ /** The props of an `AnimatedNumberReadout` that draws a figure: its host text, when given, moves place by place too. */
3
+ export function figureProps(figure) {
4
+ const { value, options, prefix, suffix, formattedValue } = figure;
5
+ return formattedValue ? { value, options, prefix, suffix, formattedValue, animateFormatted: true } : { value, options, prefix, suffix };
6
+ }
7
+ /** What a figure reads as, with the provider's money format already merged into `options` by the caller. Unknown values read as the dash, without affixes. */
8
+ export function figureReading(figure, locale, options) {
9
+ if (figure.value == null || !Number.isFinite(figure.value))
10
+ return '—';
11
+ return `${figure.prefix ?? ''}${figure.formattedValue || formatNumber(figure.value, locale, options)}${figure.suffix ?? ''}`;
12
+ }
@@ -1,26 +1,59 @@
1
1
  import React from 'react';
2
+ /** A text action on the trailing edge of a `ListGroup` heading, such as “Cancel all”. */
3
+ export interface ListGroupAction {
4
+ /** Host text drawn as the action and naming it. */
5
+ label: string;
6
+ onSelect: () => void;
7
+ disabled?: boolean;
8
+ }
2
9
  export interface ListGroupProps extends Omit<React.HTMLAttributes<HTMLElement>, 'title'> {
3
- /** Heading above the group, such as “Settings”. Omit it for an untitled group. */
4
- title?: string;
10
+ /** Heading above the group, such as “Settings”: host text or an element such as a live count. Omit it for an untitled group. */
11
+ title?: React.ReactNode;
12
+ /** Host content after the title, such as a count or a figure. It is read with the heading; the group itself stays named by the title. */
13
+ titleAccessory?: React.ReactNode;
14
+ /** A text action on the trailing edge of the heading. */
15
+ action?: ListGroupAction;
16
+ /** Host content between the heading and the rows, such as a note or a field. A group with `intro` and no rows draws no row container. */
17
+ intro?: React.ReactNode;
5
18
  /** `ListRow` elements. */
6
19
  children?: React.ReactNode;
7
20
  }
8
21
  /** A grouped list for menus and settings: an optional heading over rows that share one rounded container. */
9
- export declare function ListGroup({ title, children, className, ...rest }: ListGroupProps): React.JSX.Element;
10
- export interface ListRowProps extends Omit<React.HTMLAttributes<HTMLElement>, 'onSelect'> {
22
+ export declare function ListGroup({ title, titleAccessory, action, intro, children, className, ...rest }: ListGroupProps): React.JSX.Element;
23
+ export interface ListRowProps extends Omit<React.HTMLAttributes<HTMLElement>, 'onSelect' | 'defaultChecked'> {
11
24
  label: string;
25
+ /** A muted second line under the label, such as a subtitle or an address. The row grows to fit it, and it is read with the label. */
26
+ description?: React.ReactNode;
27
+ /** Colours the label: `destructive` for an action that deletes or ends something, `muted` for one that is done or inactive. */
28
+ tone?: 'destructive' | 'muted';
12
29
  /** Artwork before the label, such as an icon. Decorative: the label names the row. */
13
30
  leading?: React.ReactNode;
14
- /** Short text on the trailing edge, such as `Off`, `English` or a balance. */
31
+ /** Short text on the trailing edge, such as `Off`, `English` or a balance. A string or number is drawn muted. */
15
32
  value?: React.ReactNode;
33
+ /** What a `value` that is not text reads as, such as the formatted amount of a live figure. The element is then hidden from assistive technology and this text is read in its place. */
34
+ valueLabel?: string;
35
+ /** Colours a string or number `value` instead of the muted default, keeping its layout and reading. */
36
+ valueTone?: 'positive' | 'warning' | 'negative' | 'muted';
16
37
  /** Anything richer on the trailing edge: icons, a `Badge`, or a control such as a `Switch`. */
17
38
  trailing?: React.ReactNode;
18
39
  /** Makes the whole row a button, usually one that opens another view, and shows the disclosure chevron. */
19
40
  onSelect?: () => void;
20
41
  /** Makes the whole row a link and shows the disclosure chevron. */
21
42
  href?: string;
22
- /** Dims the row and blocks `onSelect` and `href`. */
43
+ /** Dims the row and blocks `onSelect`, `href` and the switch. */
23
44
  disabled?: boolean;
45
+ /** A row in a list of choices, such as a picker that selects and closes: `true` draws a check on the trailing edge and marks the row `aria-current`. With `selected` set, true or false, the row draws no chevron unless `disclosure` asks for one. */
46
+ selected?: boolean;
47
+ /** Something the row started is in progress: a spinner takes the disclosure's place, the row is marked busy and presses are ignored, without dimming it. */
48
+ busy?: boolean;
49
+ /** Busy text appended to the accessible name while `busy`; defaults to HIGProvider `messages.busy`. `''` omits it (the busy state stays exposed). */
50
+ busyLabel?: string;
51
+ /** The glyph a row with `onSelect` or `href` draws on its trailing edge: the `chevron` (default), `external` (an arrow, for something that opens outside the app) or `none`. */
52
+ disclosure?: 'chevron' | 'external' | 'none';
53
+ /** Makes the row a switch: the whole row is the target, the switch on its trailing edge is named by `label`, and `onCheckedChange` receives the new state. Use with no `onSelect` or `href`. */
54
+ checked?: boolean;
55
+ defaultChecked?: boolean;
56
+ onCheckedChange?: (checked: boolean) => void;
24
57
  }
25
- /** One row of a `ListGroup`: the label leads; a value, icons, a badge or a control trail. With `onSelect` or `href` the whole row is one target and shows a disclosure chevron; without them the row is static, so a control in `trailing` is its only target. */
26
- export declare function ListRow({ label, leading, value, trailing, onSelect, href, disabled, className, ...rest }: ListRowProps): React.JSX.Element;
58
+ /** One row of a `ListGroup`: the label leads; a value, icons, a badge or a control trail. With `onSelect` or `href` the whole row is one target and shows a disclosure chevron; with `checked` or `onCheckedChange` the whole row is a switch; otherwise the row is static, so a control in `trailing` is its only target. The ref reaches the row's element. */
59
+ export declare const ListRow: React.ForwardRefExoticComponent<ListRowProps & React.RefAttributes<HTMLElement>>;
@@ -1,20 +1,52 @@
1
1
  "use client";
2
2
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import React, { Children, useId } from 'react';
3
+ import React, { Children, forwardRef, useId, useRef } from 'react';
4
+ import * as en from '@bloxwap/hig/contracts/messages';
5
+ import { PressDecoration, useControllable, useHIG } from './provider.js';
6
+ const shown = (node) => node != null && node !== false && node !== '';
4
7
  /** A grouped list for menus and settings: an optional heading over rows that share one rounded container. */
5
- export function ListGroup({ title, children, className, ...rest }) {
8
+ export function ListGroup({ title, titleAccessory, action, intro, children, className, ...rest }) {
6
9
  const id = useId();
7
- return _jsxs("section", { ...rest, className: `hig-list-group${className ? ` ${className}` : ''}`, "aria-labelledby": title ? id : undefined, children: [title && _jsx("h3", { id: id, className: 'hig-list-group-title', children: title }), _jsx("ul", { className: 'hig-list-group-rows', children: Children.toArray(children).map((child, index) => _jsx("li", { children: child }, React.isValidElement(child) && child.key != null ? child.key : index)) })] });
10
+ const titled = shown(title), accessory = shown(titleAccessory);
11
+ const heading = titled ? accessory
12
+ ? _jsxs("h3", { className: 'hig-list-group-title', "data-accessory": '', children: [_jsx("span", { id: id, children: title }), ' ', _jsx("span", { className: 'hig-list-group-title-accessory', children: titleAccessory })] })
13
+ : _jsx("h3", { id: id, className: 'hig-list-group-title', children: title }) : null;
14
+ const rows = Children.toArray(children);
15
+ return _jsxs("section", { ...rest, className: `hig-list-group${className ? ` ${className}` : ''}`, "aria-labelledby": titled ? id : undefined, children: [action ? _jsxs("div", { className: 'hig-list-group-header', children: [heading, _jsxs("button", { type: 'button', className: 'hig-list-group-action', disabled: action.disabled, onClick: action.onSelect, children: [action.label, _jsx(PressDecoration, { kind: 'button', disabled: !!action.disabled })] })] }) : heading, shown(intro) && _jsx("div", { className: 'hig-list-group-intro', children: intro }), (!shown(intro) || rows.length > 0) && _jsx("ul", { className: 'hig-list-group-rows', children: rows.map((child, index) => _jsx("li", { children: child }, React.isValidElement(child) && child.key != null ? child.key : index)) })] });
8
16
  }
17
+ const svg = { 'aria-hidden': true, focusable: false, viewBox: '0 0 20 20', width: 20, height: 20, fill: 'none', stroke: 'currentColor', strokeLinecap: 'round', strokeLinejoin: 'round' };
9
18
  const chevron = _jsx("svg", { className: 'hig-list-row-chevron', "aria-hidden": 'true', focusable: 'false', viewBox: '0 0 20 20', width: '20', height: '20', fill: 'none', stroke: 'currentColor', strokeWidth: '1.8', strokeLinecap: 'round', strokeLinejoin: 'round', children: _jsx("path", { d: 'm7.5 4.5 5.5 5.5-5.5 5.5' }) });
10
- /** One row of a `ListGroup`: the label leads; a value, icons, a badge or a control trail. With `onSelect` or `href` the whole row is one target and shows a disclosure chevron; without them the row is static, so a control in `trailing` is its only target. */
11
- export function ListRow({ label, leading, value, trailing, onSelect, href, disabled, className, ...rest }) {
12
- const action = !disabled && (onSelect || href != null);
13
- const content = _jsxs(_Fragment, { children: [leading != null && _jsx("span", { className: 'hig-list-row-leading', "aria-hidden": 'true', children: leading }), _jsx("span", { className: 'hig-list-row-label', children: label }), value != null && _jsx("span", { className: 'hig-list-row-value', children: value }), trailing != null && _jsx("span", { className: 'hig-list-row-trailing', children: trailing }), (onSelect || href != null) && chevron] });
19
+ const external = _jsx("svg", { ...svg, className: 'hig-list-row-chevron', "data-glyph": 'external', strokeWidth: '1.8', children: _jsx("path", { d: 'M6.5 13.5 14 6M8 5.5h6.5V12' }) });
20
+ const check = _jsx("svg", { ...svg, className: 'hig-list-row-check', strokeWidth: '2', children: _jsx("path", { d: 'm4.5 10.5 3.5 3.5 7.5-8' }) });
21
+ /** One row of a `ListGroup`: the label leads; a value, icons, a badge or a control trail. With `onSelect` or `href` the whole row is one target and shows a disclosure chevron; with `checked` or `onCheckedChange` the whole row is a switch; otherwise the row is static, so a control in `trailing` is its only target. The ref reaches the row's element. */
22
+ export const ListRow = /* @__PURE__ */ forwardRef(function ListRow({ label, description, tone, leading, value, valueLabel, valueTone, trailing, onSelect, href, disabled, selected, busy, busyLabel, disclosure, checked, defaultChecked, onCheckedChange, className, ...rest }, ref) {
23
+ const { messages } = useHIG();
24
+ const descriptionId = useId();
25
+ const input = useRef(null);
26
+ const [on, setOn] = useControllable(checked, defaultChecked ?? false, onCheckedChange);
27
+ const pressable = onSelect != null || href != null;
28
+ const toggles = !pressable && (checked !== undefined || defaultChecked !== undefined || onCheckedChange != null);
29
+ const text = typeof value === 'string' || typeof value === 'number';
30
+ const busyText = busyLabel ?? messages.busy ?? en.busy;
31
+ const name = _jsx("span", { className: 'hig-list-row-label', "data-tone": tone, children: label });
32
+ const glyphKind = disclosure ?? (selected !== undefined ? 'none' : 'chevron');
33
+ const glyph = busy && !toggles ? _jsx("span", { className: 'hig-button-spinner hig-list-row-spinner', "aria-hidden": 'true' }) : selected ? check : pressable ? (glyphKind === 'chevron' ? chevron : glyphKind === 'external' ? external : null) : null;
34
+ const swatch = toggles ? _jsxs("label", { className: 'hig-choice hig-switch', children: [_jsx("input", { ref: input, role: 'switch', type: 'checkbox', checked: on, disabled: disabled, "aria-busy": busy || undefined, "aria-describedby": shown(description) ? descriptionId : undefined, onChange: event => { if (!busy)
35
+ setOn(event.target.checked); } }), _jsx("span", { children: label })] }) : null;
36
+ const content = _jsxs(_Fragment, { children: [leading != null && _jsx("span", { className: 'hig-list-row-leading', "aria-hidden": 'true', children: leading }), shown(description) ? _jsxs("span", { className: 'hig-list-row-text', children: [name, _jsx("span", { id: descriptionId, className: 'hig-list-row-description', children: description })] }) : name, value != null && _jsx("span", { className: 'hig-list-row-value', "data-tone": text && valueTone && valueTone !== 'muted' ? valueTone : undefined, children: !text && valueLabel ? _jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": 'true', children: value }), _jsx("span", { className: 'hig-sr-only', children: valueLabel })] }) : value }), (trailing != null || swatch) && _jsxs("span", { className: 'hig-list-row-trailing', children: [trailing, swatch] }), glyph, busy && !toggles && busyText ? _jsxs("span", { role: 'status', className: 'hig-busy hig-sr-only', children: [" \u00B7 ", busyText] }) : null] });
14
37
  const classes = `hig-list-row${className ? ` ${className}` : ''}`;
15
- if (action && href != null)
16
- return _jsx("a", { ...rest, className: classes, href: href, onClick: onSelect, children: content });
38
+ const current = selected ? { 'aria-current': true } : {};
39
+ if (toggles) {
40
+ // A press anywhere outside the switch and the host's own controls toggles it; the input stays the one named control.
41
+ const toggle = (event) => { const target = event.target; if (disabled || busy || target.closest('.hig-switch') || target.closest('a[href],button,input,select,textarea,label'))
42
+ return; input.current?.click(); };
43
+ return _jsxs("div", { ...rest, ref: ref, className: classes, "data-switch": '', "aria-disabled": disabled || undefined, onClick: event => { rest.onClick?.(event); if (!event.defaultPrevented)
44
+ toggle(event); }, children: [content, _jsx(PressDecoration, { kind: 'switch', disabled: !!disabled || !!busy, input: input })] });
45
+ }
46
+ // A busy link stays the same element, so the focus the press left on it stays; it only stops navigating.
47
+ if (!disabled && href != null)
48
+ return _jsxs("a", { ...current, ...rest, ref: ref, className: classes, href: href, "aria-disabled": busy || undefined, "aria-busy": busy || undefined, onClick: busy ? event => event.preventDefault() : onSelect, children: [content, _jsx(PressDecoration, { kind: 'row', disabled: !!busy })] });
17
49
  if (onSelect)
18
- return _jsx("button", { type: 'button', ...rest, className: classes, disabled: disabled, onClick: onSelect, children: content });
19
- return _jsx("div", { ...rest, className: classes, "aria-disabled": disabled || undefined, children: content });
20
- }
50
+ return _jsxs("button", { type: 'button', ...current, ...rest, ref: ref, className: classes, disabled: disabled, "aria-busy": busy || undefined, onClick: busy ? undefined : onSelect, children: [content, _jsx(PressDecoration, { kind: 'row', disabled: !!disabled || !!busy })] });
51
+ return _jsx("div", { ...current, ...rest, ref: ref, className: classes, "aria-disabled": disabled || undefined, "aria-busy": busy || undefined, children: content });
52
+ });
@@ -1,21 +1,58 @@
1
1
  import type { FeedbackSink, FeedbackIntent } from '@bloxwap/hig/contracts/feedback';
2
2
  import React from 'react';
3
- import { type Environment } from '@bloxwap/hig/contracts';
3
+ import { type Environment, type NumberFormatPresentation } from '@bloxwap/hig/contracts';
4
4
  import { type HIGMessages } from '@bloxwap/hig/contracts/messages';
5
5
  import { nativeSrgb } from '@bloxwap/hig/tokens';
6
6
  export type { HIGMessages } from '@bloxwap/hig/contracts/messages';
7
+ export type { NumberFormatPresentation } from '@bloxwap/hig/contracts';
8
+ /** The kind of pressable HIG control a press decoration is drawn in: `button` (Button, the block action buttons and a ListGroup heading action), `icon-button` (IconButton and the SearchInput clear button), `row` (a pressable ListRow, AssetBalanceRow, the WalletAddress copy button or a block row), `switch` (Switch, a switch ListRow and the setting switch rows), `segment` (each SegmentedControl segment) and `back` (the block header's Back, Close and address controls). */
9
+ export type PressDecorationKind = 'button' | 'icon-button' | 'row' | 'switch' | 'segment' | 'back';
10
+ export interface PressDecorationInfo {
11
+ kind: PressDecorationKind; /** The control is disabled or busy and will not act on a press. */
12
+ disabled: boolean;
13
+ }
7
14
  export interface HIGContext extends Environment {
8
15
  onAccepted?: (id: string) => void;
9
16
  feedback?: FeedbackSink; /** Brand accent as opaque sRGB hex (#RGB or #RRGGBB). Nested providers inherit it; omitted at the root, Bloxwap green applies. */
10
17
  primaryColor?: string; /** Host translations of built-in copy, merged through nested providers. Components fall back to the English export per key; read the full resolved catalog with `useMessages()`. */
11
18
  messages: Readonly<Partial<HIGMessages>>;
19
+ /** Host content drawn inside every pressable HIG control, such as a native switch input that gives iOS Safari a haptic. It sits in an absolutely positioned layer over the control that changes no layout and catches no pointer events itself; its children do. Nested providers inherit it. Omitted, nothing is drawn. */
20
+ pressDecoration?: (info: PressDecorationInfo) => React.ReactNode;
21
+ /** Money presentation merged under every currency format HIG draws: the blocks, BarMark, BarPnl, AssetBalanceRow, the swap pieces and the number readouts. Options a format sets itself win. Nested providers inherit it. */
22
+ numberFormat?: NumberFormatPresentation;
23
+ /** Market-direction colours: `up` (rising, long, gain) and `down` (falling, short, loss), as CSS colours. They default to `--hig-buy` and `--hig-sell`; the provider sets `--hig-up` and `--hig-down` on its wrapper. Nested providers inherit them. */
24
+ marketColors?: HIGMarketColors;
25
+ }
26
+ /** Host colours for the market-direction roles. An omitted, empty or non-string role keeps `buy`/`sell`. */
27
+ export interface HIGMarketColors {
28
+ up?: string;
29
+ down?: string;
12
30
  }
13
31
  export interface HIGProviderProps extends Partial<Omit<HIGContext, 'messages'>> {
14
32
  messages?: Partial<HIGMessages>;
15
33
  }
16
- export declare function HIGProvider({ children, density, locale, direction, reducedMotion, onAccepted, feedback, primaryColor, messages }: React.PropsWithChildren<HIGProviderProps>): React.JSX.Element;
34
+ export declare function HIGProvider({ children, density, locale, direction, reducedMotion, onAccepted, feedback, primaryColor, messages, pressDecoration, numberFormat, marketColors }: React.PropsWithChildren<HIGProviderProps>): React.JSX.Element;
17
35
  export declare const useHIG: () => HIGContext;
18
- /** Scoped primary colour variables for host-owned portals outside the provider's DOM. */
36
+ /** Number options with the nearest provider's `numberFormat` merged under them; only currency formats change. */
37
+ export declare function usePresentNumber(): <T extends Intl.NumberFormatOptions | undefined>(options: T) => T;
38
+ /** The locale numbers are formatted in: the nearest provider's `numberFormat.locale`, else its `locale`. */
39
+ export declare function useNumberLocale(): string;
40
+ /**
41
+ * The provider's press decoration for one control: the host content in an absolutely positioned layer that is the control's last
42
+ * child, or nothing without a `pressDecoration`. Place it inside a host control to give it the same treatment as HIG's own.
43
+ * A press on an interactive element in the layer makes that element the activation target (the HTML activation rules), so the
44
+ * control around it would skip its own default action: a submit or reset button would not submit, a link would not navigate and
45
+ * a label would not toggle its input. The layer therefore stops that click and sends the control one click of its own, which
46
+ * runs the control's handlers and its default action once. For a control drawn as a `<label>` around its `input`, pass that
47
+ * input and the click goes to it. A host `<label>` that names a control is left alone, because the click it then sends to that
48
+ * control comes through next. A disabled control gets nothing.
49
+ */
50
+ export declare function PressDecoration({ kind, disabled, input }: {
51
+ kind: PressDecorationKind;
52
+ disabled?: boolean;
53
+ input?: React.RefObject<HTMLInputElement | null>;
54
+ }): React.JSX.Element | null;
55
+ /** Scoped primary and market colour variables for host-owned portals outside the provider's DOM. */
19
56
  export declare function useThemeStyle(): React.CSSProperties | undefined;
20
57
  /** Resolved sRGB roles for canvas and host-drawn content. CSS retains the default wide-gamut palette. */
21
58
  export declare function useColors(): Readonly<Record<keyof typeof nativeSrgb, string>>;
@@ -1,30 +1,87 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { createContext, useContext, useEffect, useMemo, useState, useRef, useId } from 'react';
4
- import { defaultEnvironment } from '@bloxwap/hig/contracts';
4
+ import { defaultEnvironment, numberLocale, presentNumberFormat } from '@bloxwap/hig/contracts';
5
5
  import { defaultMessages, resolveMessages } from '@bloxwap/hig/contracts/messages';
6
6
  import { nativeSrgb, resolvePrimaryColor } from '@bloxwap/hig/tokens';
7
7
  const Context = createContext({ ...defaultEnvironment, messages: {} });
8
- export function HIGProvider({ children, density = 'comfortable', locale = 'en-US', direction = 'ltr', reducedMotion, onAccepted, feedback, primaryColor, messages }) {
8
+ const marketColor = (value) => typeof value === 'string' && value !== '' ? value : undefined;
9
+ export function HIGProvider({ children, density = 'comfortable', locale = 'en-US', direction = 'ltr', reducedMotion, onAccepted, feedback, primaryColor, messages, pressDecoration, numberFormat, marketColors }) {
9
10
  const parent = useContext(Context);
10
11
  const inherited = parent.messages;
11
12
  const resolved = useMemo(() => resolveMessages(inherited, messages), [inherited, messages]);
13
+ const market = marketColors ?? parent.marketColors;
14
+ const up = marketColor(market?.up), down = marketColor(market?.down);
15
+ const inheritedMarket = useMemo(() => up === undefined && down === undefined ? undefined : { up, down }, [up, down]);
12
16
  const accent = primaryColor ?? parent.primaryColor;
13
- const theme = useMemo(() => primaryStyle(accent), [accent]);
17
+ const theme = useMemo(() => marketStyle(primaryStyle(accent), up, down), [accent, up, down]);
18
+ const decorate = pressDecoration ?? parent.pressDecoration;
19
+ const drawPress = useMemo(() => decorate ? pressLayer(decorate) : undefined, [decorate]);
14
20
  const [osReduced, setOSReduced] = useState(false);
15
21
  useEffect(() => { const query = window.matchMedia?.('(prefers-reduced-motion: reduce)'); if (!query)
16
22
  return; const update = () => setOSReduced(query.matches); update(); query.addEventListener('change', update); return () => query.removeEventListener('change', update); }, []);
17
- return _jsx(Context.Provider, { value: { density, locale, direction, reducedMotion: reducedMotion ?? osReduced, onAccepted, feedback, primaryColor: accent, messages: resolved }, children: _jsx("div", { style: theme, "data-hig-density": density, "data-hig-motion": reducedMotion ?? osReduced ? 'reduced' : 'full', dir: direction, lang: locale, children: children }) });
23
+ return _jsx(Context.Provider, { value: { density, locale, direction, reducedMotion: reducedMotion ?? osReduced, onAccepted, feedback, primaryColor: accent, messages: resolved, pressDecoration: decorate, numberFormat: numberFormat ?? parent.numberFormat, marketColors: inheritedMarket, drawPress }, children: _jsx("div", { style: theme, "data-hig-density": density, "data-hig-motion": reducedMotion ?? osReduced ? 'reduced' : 'full', dir: direction, lang: locale, children: children }) });
18
24
  }
19
25
  export const useHIG = () => useContext(Context);
26
+ /** Number options with the nearest provider's `numberFormat` merged under them; only currency formats change. */
27
+ export function usePresentNumber() { const { numberFormat } = useContext(Context); return useMemo(() => (options) => presentNumberFormat(options, numberFormat), [numberFormat]); }
28
+ /** The locale numbers are formatted in: the nearest provider's `numberFormat.locale`, else its `locale`. */
29
+ export function useNumberLocale() { const { locale, numberFormat } = useContext(Context); return numberLocale(locale, numberFormat); }
30
+ const interactive = 'a[href],button,input,select,textarea,label';
31
+ /**
32
+ * The provider's press decoration for one control: the host content in an absolutely positioned layer that is the control's last
33
+ * child, or nothing without a `pressDecoration`. Place it inside a host control to give it the same treatment as HIG's own.
34
+ * A press on an interactive element in the layer makes that element the activation target (the HTML activation rules), so the
35
+ * control around it would skip its own default action: a submit or reset button would not submit, a link would not navigate and
36
+ * a label would not toggle its input. The layer therefore stops that click and sends the control one click of its own, which
37
+ * runs the control's handlers and its default action once. For a control drawn as a `<label>` around its `input`, pass that
38
+ * input and the click goes to it. A host `<label>` that names a control is left alone, because the click it then sends to that
39
+ * control comes through next. A disabled control gets nothing.
40
+ */
41
+ export function PressDecoration({ kind, disabled = false, input }) {
42
+ const draw = useContext(Context).drawPress;
43
+ return draw ? draw(kind, disabled, input) : null;
44
+ }
45
+ function pressLayer(decorate) {
46
+ return (kind, disabled, input) => {
47
+ const content = decorate({ kind, disabled });
48
+ if (content == null || content === false)
49
+ return null;
50
+ return _jsx("span", { className: 'hig-press-decoration', "data-kind": kind, onClick: event => forwardPress(event, input), children: content });
51
+ };
52
+ }
53
+ function forwardPress(event, input) {
54
+ const layer = event.currentTarget;
55
+ for (let node = event.target; node && node !== layer; node = node.parentElement) {
56
+ if (!node.matches(interactive))
57
+ continue;
58
+ if (node instanceof HTMLLabelElement && node.control)
59
+ return;
60
+ const control = input ? input.current : layer.parentElement;
61
+ if (!control)
62
+ return;
63
+ event.stopPropagation();
64
+ if (control.matches(':disabled'))
65
+ return;
66
+ const { detail, screenX, screenY, clientX, clientY, ctrlKey, shiftKey, altKey, metaKey, button } = event;
67
+ control.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, composed: true, view: event.nativeEvent.view, detail, screenX, screenY, clientX, clientY, ctrlKey, shiftKey, altKey, metaKey, button }));
68
+ return;
69
+ }
70
+ }
20
71
  function primaryStyle(primaryColor) {
21
72
  if (primaryColor === undefined)
22
73
  return undefined;
23
74
  const colors = resolvePrimaryColor(primaryColor);
24
75
  return { '--hig-action': colors.action, '--hig-focus': colors.focus, '--hig-onAction': colors.onAction };
25
76
  }
26
- /** Scoped primary colour variables for host-owned portals outside the provider's DOM. */
27
- export function useThemeStyle() { const { primaryColor } = useHIG(); return useMemo(() => primaryStyle(primaryColor), [primaryColor]); }
77
+ /** Adds `--hig-up` / `--hig-down` for a market colour override; without one the style is returned unchanged. */
78
+ function marketStyle(style, up, down) {
79
+ if (up === undefined && down === undefined)
80
+ return style;
81
+ return { ...style, ...(up !== undefined ? { '--hig-up': up } : {}), ...(down !== undefined ? { '--hig-down': down } : {}) };
82
+ }
83
+ /** Scoped primary and market colour variables for host-owned portals outside the provider's DOM. */
84
+ export function useThemeStyle() { const { primaryColor, marketColors } = useHIG(); return useMemo(() => marketStyle(primaryStyle(primaryColor), marketColors?.up, marketColors?.down), [primaryColor, marketColors]); }
28
85
  /** Resolved sRGB roles for canvas and host-drawn content. CSS retains the default wide-gamut palette. */
29
86
  export function useColors() { const { primaryColor } = useHIG(); return useMemo(() => primaryColor === undefined ? nativeSrgb : { ...nativeSrgb, ...resolvePrimaryColor(primaryColor) }, [primaryColor]); }
30
87
  /** Complete built-in copy for the nearest HIGProvider: host translations over the English defaults. */
@@ -12,7 +12,10 @@ interface CheckedProps {
12
12
  onCheckedChange?: (value: boolean) => void;
13
13
  }
14
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;
15
+ export interface SwitchProps extends CheckedProps {
16
+ hideLabel?: boolean;
17
+ }
18
+ export declare function Switch({ label, checked, defaultChecked, disabled, hideLabel, onCheckedChange }: SwitchProps): React.JSX.Element;
16
19
  export interface ChoicesProps {
17
20
  label: string;
18
21
  options: readonly Choice[];
@@ -21,8 +24,11 @@ export interface ChoicesProps {
21
24
  disabled?: boolean;
22
25
  onValueChange?: (value: string) => void;
23
26
  }
27
+ export interface SegmentedControlProps extends ChoicesProps {
28
+ hideLabel?: boolean;
29
+ }
24
30
  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;
31
+ export declare function SegmentedControl({ label, options, value, defaultValue, disabled, hideLabel, onValueChange }: SegmentedControlProps): React.JSX.Element;
26
32
  export interface FilterOption extends Choice {
27
33
  icon?: string;
28
34
  }
@@ -1,16 +1,21 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useId } from 'react';
4
- import { useControllable } from './provider.js';
3
+ import { useId, useRef } from 'react';
4
+ import { PressDecoration, useControllable } from './provider.js';
5
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 })] }); }
6
+ export function Switch({ label, checked, defaultChecked = false, disabled, hideLabel, onCheckedChange }) { const [value, set] = useControllable(checked, defaultChecked, onCheckedChange); const input = useRef(null); return _jsxs("label", { className: 'hig-choice hig-switch', children: [_jsx("input", { ref: input, role: 'switch', type: 'checkbox', checked: value, disabled: disabled, onChange: e => set(e.target.checked) }), _jsx("span", { className: hideLabel ? 'hig-sr-only' : undefined, children: label }), _jsx(PressDecoration, { kind: 'switch', disabled: !!disabled, input: input })] }); }
7
+ /** One segment: a label around its radio, with the provider's press decoration aimed at that radio. */
8
+ function Segment({ name, option, checked, blocked, onSelect }) {
9
+ const input = useRef(null);
10
+ return _jsxs("label", { className: 'hig-segment', children: [_jsx("input", { ref: input, type: 'radio', name: name, value: option.value, checked: checked, disabled: option.disabled, onChange: () => { if (!blocked)
11
+ onSelect(); } }), _jsx("span", { children: option.label }), _jsx(PressDecoration, { kind: 'segment', disabled: blocked, input: input })] });
12
+ }
7
13
  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 }) {
14
+ export function SegmentedControl({ label, options, value, defaultValue = '', disabled, hideLabel, onValueChange }) {
9
15
  const name = useId();
10
16
  const [current, set] = useControllable(value, defaultValue, onValueChange);
11
17
  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))] })] });
18
+ return _jsxs("fieldset", { className: 'hig-group hig-segmented-control', disabled: disabled, children: [_jsx("legend", { className: hideLabel ? 'hig-sr-only' : undefined, 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 => _jsx(Segment, { name: name, option: o, checked: current === o.value, blocked: !!disabled || !!o.disabled, onSelect: () => set(o.value) }, o.value))] })] });
14
19
  }
15
20
  /** One row of filter capsules that scrolls sideways. Single choice with radio semantics; the chosen capsule inverts and a check draws into its circle. */
16
21
  export function Filter({ label, options, value, defaultValue = '', disabled, onValueChange }) {