@phreshos/react-ui 0.1.36 → 0.1.37

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 (201) hide show
  1. package/README.md +147 -167
  2. package/dist/accordion.d.ts +7 -6
  3. package/dist/accordion.js +5 -5
  4. package/dist/alert-dialog.js +3 -1
  5. package/dist/alert.d.ts +17 -0
  6. package/dist/alert.js +30 -0
  7. package/dist/app-layout.d.ts +13 -0
  8. package/dist/app-layout.js +84 -0
  9. package/dist/button.d.ts +12 -24
  10. package/dist/button.js +34 -39
  11. package/dist/calendar-layout.d.ts +9 -5
  12. package/dist/calendar-layout.js +67 -78
  13. package/dist/calendar-trigger.d.ts +4 -4
  14. package/dist/calendar-trigger.js +7 -29
  15. package/dist/calendar.d.ts +2 -2
  16. package/dist/calendar.js +6 -5
  17. package/dist/checkbox.d.ts +4 -4
  18. package/dist/checkbox.js +16 -6
  19. package/dist/color-area.d.ts +20 -0
  20. package/dist/color-area.js +30 -0
  21. package/dist/color-field.d.ts +17 -0
  22. package/dist/color-field.js +17 -0
  23. package/dist/color-picker.d.ts +24 -0
  24. package/dist/color-picker.js +30 -0
  25. package/dist/color-slider.d.ts +19 -0
  26. package/dist/color-slider.js +29 -0
  27. package/dist/color-swatch-picker.d.ts +23 -0
  28. package/dist/color-swatch-picker.js +36 -0
  29. package/dist/color-swatch.d.ts +18 -0
  30. package/dist/color-swatch.js +20 -0
  31. package/dist/combo-box.d.ts +18 -10
  32. package/dist/combo-box.js +43 -58
  33. package/dist/context-menu.d.ts +14 -10
  34. package/dist/context-menu.js +7 -6
  35. package/dist/control/color-thumb.d.ts +13 -0
  36. package/dist/control/color-thumb.js +33 -0
  37. package/dist/control/color-value.d.ts +6 -0
  38. package/dist/control/color-value.js +7 -0
  39. package/dist/control/control.d.ts +60 -0
  40. package/dist/control/control.js +71 -0
  41. package/dist/control/field-button.d.ts +13 -0
  42. package/dist/control/field-button.js +28 -0
  43. package/dist/control/field.d.ts +20 -0
  44. package/dist/control/field.js +34 -0
  45. package/dist/control/icon.d.ts +11 -0
  46. package/dist/control/icon.js +8 -0
  47. package/dist/control/item.d.ts +34 -0
  48. package/dist/control/item.js +53 -0
  49. package/dist/control/open-state.d.ts +25 -0
  50. package/dist/control/open-state.js +8 -0
  51. package/dist/control/selection-track.d.ts +39 -0
  52. package/dist/control/selection-track.js +122 -0
  53. package/dist/control/selection.d.ts +44 -0
  54. package/dist/{selection.js → control/selection.js} +16 -0
  55. package/dist/control/surface-render.d.ts +10 -0
  56. package/dist/control/surface-render.js +12 -0
  57. package/dist/control/text-control.d.ts +32 -0
  58. package/dist/control/text-control.js +31 -0
  59. package/dist/control/toggle.d.ts +32 -0
  60. package/dist/control/toggle.js +80 -0
  61. package/dist/date-control.d.ts +9 -9
  62. package/dist/date-control.js +31 -34
  63. package/dist/date-field.d.ts +7 -6
  64. package/dist/date-field.js +8 -6
  65. package/dist/date-picker.d.ts +13 -6
  66. package/dist/date-picker.js +9 -6
  67. package/dist/date-range-picker.d.ts +15 -6
  68. package/dist/date-range-picker.js +12 -9
  69. package/dist/dialog.d.ts +22 -8
  70. package/dist/dialog.js +37 -28
  71. package/dist/disclosure.d.ts +8 -7
  72. package/dist/disclosure.js +31 -52
  73. package/dist/drop-zone.d.ts +18 -0
  74. package/dist/drop-zone.js +32 -0
  75. package/dist/dropdown-menu.d.ts +7 -4
  76. package/dist/dropdown-menu.js +5 -4
  77. package/dist/fieldset.d.ts +13 -0
  78. package/dist/fieldset.js +26 -0
  79. package/dist/file-trigger.d.ts +13 -0
  80. package/dist/file-trigger.js +6 -0
  81. package/dist/flex.d.ts +1 -1
  82. package/dist/flex.js +5 -4
  83. package/dist/foundation/appearance.d.ts +83 -0
  84. package/dist/foundation/appearance.js +38 -0
  85. package/dist/{aria-direction.js → foundation/aria-direction.js} +3 -1
  86. package/dist/foundation/color.d.ts +61 -0
  87. package/dist/foundation/color.js +247 -0
  88. package/dist/{layout.d.ts → foundation/layout.d.ts} +6 -4
  89. package/dist/{layout.js → foundation/layout.js} +7 -5
  90. package/dist/foundation/motion-style.d.ts +9 -0
  91. package/dist/foundation/motion-style.js +50 -0
  92. package/dist/foundation/preferences.d.ts +15 -0
  93. package/dist/{ui-provider.d.ts → foundation/provider.d.ts} +3 -5
  94. package/dist/{ui-provider.js → foundation/provider.js} +14 -26
  95. package/dist/{radius.d.ts → foundation/radius.d.ts} +6 -3
  96. package/dist/foundation/radius.js +11 -0
  97. package/dist/foundation/spacing.d.ts +11 -0
  98. package/dist/foundation/spacing.js +4 -0
  99. package/dist/foundation/visual.d.ts +42 -0
  100. package/dist/{appearance-context.js → foundation/visual.js} +41 -27
  101. package/dist/grid.d.ts +1 -1
  102. package/dist/grid.js +5 -4
  103. package/dist/icons/main.d.ts +5 -3
  104. package/dist/icons/main.js +5 -3
  105. package/dist/input.d.ts +2 -2
  106. package/dist/input.js +9 -7
  107. package/dist/list-box.d.ts +24 -19
  108. package/dist/list-box.js +52 -109
  109. package/dist/main.d.ts +27 -16
  110. package/dist/main.js +22 -9
  111. package/dist/menu.d.ts +28 -32
  112. package/dist/menu.js +47 -93
  113. package/dist/number-field.d.ts +17 -0
  114. package/dist/number-field.js +28 -0
  115. package/dist/panel.d.ts +10 -5
  116. package/dist/panel.js +33 -12
  117. package/dist/popover.d.ts +19 -5
  118. package/dist/popover.js +22 -15
  119. package/dist/progress-bar.d.ts +8 -10
  120. package/dist/progress-bar.js +18 -34
  121. package/dist/radio.d.ts +15 -12
  122. package/dist/radio.js +27 -37
  123. package/dist/range-calendar.d.ts +5 -3
  124. package/dist/range-calendar.js +8 -7
  125. package/dist/scroll-area.d.ts +2 -2
  126. package/dist/scroll-area.js +10 -9
  127. package/dist/segmented-control.d.ts +23 -0
  128. package/dist/segmented-control.js +38 -0
  129. package/dist/select.d.ts +40 -13
  130. package/dist/select.js +63 -18
  131. package/dist/slider.d.ts +7 -3
  132. package/dist/slider.js +51 -50
  133. package/dist/spinner.d.ts +5 -8
  134. package/dist/spinner.js +12 -27
  135. package/dist/surface/grain.d.ts +12 -0
  136. package/dist/surface/grain.js +65 -0
  137. package/dist/{material-options.d.ts → surface/material-options.d.ts} +1 -2
  138. package/dist/{material-options.js → surface/material-options.js} +2 -2
  139. package/dist/surface/paint-class.d.ts +6 -0
  140. package/dist/surface/paint-class.js +36 -0
  141. package/dist/{shadow-options.d.ts → surface/shadow-options.d.ts} +13 -1
  142. package/dist/{shadow-options.js → surface/shadow-options.js} +17 -2
  143. package/dist/surface/surface.d.ts +73 -0
  144. package/dist/surface/surface.js +230 -0
  145. package/dist/switch.d.ts +4 -5
  146. package/dist/switch.js +17 -8
  147. package/dist/table.d.ts +29 -32
  148. package/dist/table.js +68 -106
  149. package/dist/tabs.d.ts +16 -15
  150. package/dist/tabs.js +44 -86
  151. package/dist/textarea.d.ts +2 -2
  152. package/dist/textarea.js +10 -14
  153. package/dist/time-field.d.ts +6 -6
  154. package/dist/time-field.js +8 -6
  155. package/dist/toolbar.d.ts +6 -4
  156. package/dist/toolbar.js +16 -15
  157. package/dist/tooltip.d.ts +13 -4
  158. package/dist/tooltip.js +17 -15
  159. package/dist/tree.d.ts +22 -27
  160. package/dist/tree.js +54 -99
  161. package/dist/window.d.ts +2 -2
  162. package/dist/window.js +18 -20
  163. package/package.json +3 -3
  164. package/dist/appearance-context.d.ts +0 -54
  165. package/dist/appearance.d.ts +0 -11
  166. package/dist/appearance.js +0 -11
  167. package/dist/color.d.ts +0 -69
  168. package/dist/color.js +0 -192
  169. package/dist/control-surface.d.ts +0 -20
  170. package/dist/control-surface.js +0 -11
  171. package/dist/control.d.ts +0 -70
  172. package/dist/control.js +0 -105
  173. package/dist/field-style.d.ts +0 -3
  174. package/dist/field-style.js +0 -12
  175. package/dist/material-paint.d.ts +0 -13
  176. package/dist/material-paint.js +0 -119
  177. package/dist/motion-style.d.ts +0 -13
  178. package/dist/motion-style.js +0 -75
  179. package/dist/preferences.d.ts +0 -12
  180. package/dist/radius.js +0 -11
  181. package/dist/readiness.d.ts +0 -37
  182. package/dist/readiness.js +0 -134
  183. package/dist/selection.d.ts +0 -18
  184. package/dist/spacing.d.ts +0 -8
  185. package/dist/spacing.js +0 -8
  186. package/dist/surface-edge.d.ts +0 -11
  187. package/dist/surface-edge.js +0 -55
  188. package/dist/surface.d.ts +0 -27
  189. package/dist/surface.js +0 -92
  190. package/dist/text-control.d.ts +0 -10
  191. package/dist/text-control.js +0 -0
  192. package/dist/toggle-indicator.d.ts +0 -18
  193. package/dist/toggle-indicator.js +0 -49
  194. /package/dist/{aria-direction.d.ts → foundation/aria-direction.d.ts} +0 -0
  195. /package/dist/{direction.d.ts → foundation/direction.d.ts} +0 -0
  196. /package/dist/{direction.js → foundation/direction.js} +0 -0
  197. /package/dist/{overlay-placement.d.ts → foundation/overlay-placement.d.ts} +0 -0
  198. /package/dist/{overlay-placement.js → foundation/overlay-placement.js} +0 -0
  199. /package/dist/{preferences.js → foundation/preferences.js} +0 -0
  200. /package/dist/{scale.d.ts → foundation/scale.d.ts} +0 -0
  201. /package/dist/{scale.js → foundation/scale.js} +0 -0
package/dist/table.d.ts CHANGED
@@ -1,71 +1,68 @@
1
1
  import type { CSSProperties, ReactElement, RefAttributes } from "react";
2
2
  import type { CellProps as AriaCellProps, ColumnProps as AriaColumnProps, RowProps as AriaRowProps, TableBodyProps as AriaTableBodyProps, TableHeaderProps as AriaTableHeaderProps, TableProps as AriaTableProps } from "react-aria-components";
3
- import type { ControlColor } from "./control.js";
4
- import type { RadiusProps } from "./radius.js";
5
- import type { ScaleLevel } from "./scale.js";
6
- import { type MultipleStringSelection, type MultipleStringSelectionProps, type SingleStringSelectionProps } from "./selection.js";
3
+ import { type MultipleSelectionProps, type MultipleStringSelection, type NoSelectionProps, type SingleSelectionProps } from "./control/selection.js";
4
+ import { type Color } from "./foundation/color.js";
5
+ import type { RadiusProps } from "./foundation/radius.js";
6
+ import type { ScaleLevel } from "./foundation/scale.js";
7
7
  export type TableSortDirection = "ascending" | "descending";
8
8
  export interface TableSort {
9
9
  readonly column: string;
10
10
  readonly direction: TableSortDirection;
11
11
  }
12
- type TableRootBaseProps = Omit<AriaTableProps, "className" | "defaultSelectedKeys" | "disabledKeys" | "onRowAction" | "onSelectionChange" | "onSortChange" | "selectedKeys" | "selectionMode" | "sortDescriptor" | "style"> & RadiusProps & Readonly<{
12
+ type TableRootBaseProps = Omit<AriaTableProps, "className" | "defaultSelectedKeys" | "disabledKeys" | "onRowAction" | "onSelectionChange" | "onSortChange" | "selectedKeys" | "selectionMode" | "sortDescriptor" | "style" | "expandedKeys" | "defaultExpandedKeys" | "onExpandedChange" | "treeColumn" | "shouldSelectOnPressUp"> & RadiusProps & Readonly<{
13
13
  className?: string;
14
- color?: ControlColor;
15
- disabledValues?: readonly string[];
16
- onRowAction?: (value: string) => void;
14
+ /** Color laid beneath selected Rows. */
15
+ color?: Color;
16
+ /** Runs with the value of the Row that was activated. */
17
+ onAction?: (value: string) => void;
17
18
  onSortChange?: (sort: TableSort) => void;
19
+ /** Whether a Row is selected when the press ends instead of when it starts. */
20
+ selectOnPressUp?: boolean;
18
21
  size?: ScaleLevel;
19
22
  sort?: TableSort;
20
23
  style?: CSSProperties;
21
24
  }>;
22
- export type TableNoSelectionProps = Readonly<{
23
- selectionMode?: "none";
24
- value?: never;
25
- defaultValue?: never;
26
- onChange?: never;
27
- }>;
28
- export type TableSingleSelectionProps = SingleStringSelectionProps & Readonly<{
29
- selectionMode: "single";
30
- }>;
25
+ export type TableNoSelectionProps = NoSelectionProps;
26
+ export type TableSingleSelectionProps = SingleSelectionProps;
31
27
  export type TableMultipleValue = MultipleStringSelection;
32
- export type TableMultipleSelectionProps = MultipleStringSelectionProps & Readonly<{
33
- selectionMode: "multiple";
34
- }>;
28
+ export type TableMultipleSelectionProps = MultipleSelectionProps;
35
29
  export type TableRootProps = TableRootBaseProps & (TableNoSelectionProps | TableSingleSelectionProps | TableMultipleSelectionProps);
36
- export declare const TableRoot: import("react").ForwardRefExoticComponent<TableRootProps & RefAttributes<HTMLDivElement | HTMLTableElement>>;
37
30
  export interface TableHeaderProps<T extends object = object> extends Omit<AriaTableHeaderProps<T>, "className" | "style"> {
38
31
  readonly className?: string;
39
- readonly color?: ControlColor;
40
32
  readonly style?: CSSProperties;
41
33
  }
42
34
  export type TableHeaderComponent = <T extends object = object>(properties: TableHeaderProps<T> & RefAttributes<HTMLTableSectionElement | HTMLDivElement>) => ReactElement | null;
43
- export declare const TableHeader: TableHeaderComponent;
44
- export interface TableColumnProps extends Omit<AriaColumnProps, "className" | "id" | "style"> {
45
- readonly className?: string;
35
+ export interface TableColumnProps extends Omit<AriaColumnProps, "allowsSorting" | "allowsArrowNavigation" | "className" | "id" | "isRowHeader" | "style"> {
36
+ /** Whether arrow keys move between cells while focus is inside this one. */
37
+ readonly arrowNavigation?: boolean;
38
+ /** Identity of this Column, reported in sort changes. */
46
39
  readonly id: string;
40
+ /** Whether cells in this Column label their Row. */
41
+ readonly rowHeader?: boolean;
42
+ /** Whether pressing this Column requests a sort. */
43
+ readonly sortable?: boolean;
44
+ readonly className?: string;
47
45
  readonly style?: CSSProperties;
48
46
  }
49
- export declare const TableColumn: import("react").ForwardRefExoticComponent<TableColumnProps & RefAttributes<HTMLDivElement | HTMLTableCellElement>>;
50
47
  export interface TableBodyProps<T extends object = object> extends Omit<AriaTableBodyProps<T>, "className" | "style"> {
51
48
  readonly className?: string;
52
49
  readonly style?: CSSProperties;
53
50
  }
54
51
  export type TableBodyComponent = <T extends object = object>(properties: TableBodyProps<T> & RefAttributes<HTMLTableSectionElement | HTMLDivElement>) => ReactElement | null;
55
- export declare const TableBody: TableBodyComponent;
56
- export interface TableRowProps<T extends object = object> extends Omit<AriaRowProps<T>, "className" | "id" | "isDisabled" | "style"> {
52
+ export interface TableRowProps<T extends object = object> extends Omit<AriaRowProps<T>, "className" | "id" | "isDisabled" | "style" | "hasChildItems"> {
53
+ /** Identity of this Row within its Table. */
54
+ readonly id: string;
57
55
  readonly className?: string;
58
56
  readonly disabled?: boolean;
59
- readonly id: string;
60
57
  readonly style?: CSSProperties;
61
58
  }
62
59
  export type TableRowComponent = <T extends object = object>(properties: TableRowProps<T> & RefAttributes<HTMLTableRowElement | HTMLDivElement>) => ReactElement | null;
63
- export declare const TableRow: TableRowComponent;
64
- export interface TableCellProps extends Omit<AriaCellProps, "className" | "style"> {
60
+ export interface TableCellProps extends Omit<AriaCellProps, "className" | "style" | "allowsArrowNavigation"> {
61
+ /** Whether arrow keys move between cells while focus is inside this one. */
62
+ readonly arrowNavigation?: boolean;
65
63
  readonly className?: string;
66
64
  readonly style?: CSSProperties;
67
65
  }
68
- export declare const TableCell: import("react").ForwardRefExoticComponent<TableCellProps & RefAttributes<HTMLDivElement | HTMLTableCellElement>>;
69
66
  /** Structured rows and columns with optional selection and consumer-owned sorting. */
70
67
  export declare const Table: import("react").ForwardRefExoticComponent<TableRootProps & RefAttributes<HTMLDivElement | HTMLTableElement>> & {
71
68
  Header: TableHeaderComponent;
package/dist/table.js CHANGED
@@ -1,148 +1,110 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { createContext, forwardRef, useContext, useMemo } from "react";
3
3
  import { Cell as AriaCell, Column as AriaColumn, Row as AriaRow, Table as AriaTable, TableBody as AriaTableBody, TableHeader as AriaTableHeader } from "react-aria-components";
4
- import { colorOpacity } from "./color.js";
5
- import { controlFontWeight, controlOpacity, useControlTheme } from "./control.js";
6
- import { resolveDirection, useDirection } from "./direction.js";
7
- import { multipleSelection, singleSelection, stringKey, toAriaSelection } from "./selection.js";
8
- import { AriaDirectionBoundary } from "./aria-direction.js";
9
- const TableThemeContext = createContext(null);
10
- export const TableRoot = forwardRef(function TableRoot(properties, ref) {
11
- const { className, color, defaultValue, disabledValues, onChange, onRowAction, onSortChange, radius = "medium", selectionMode = "none", size = "medium", sort, style, value, ...native } = properties;
12
- const theme = useControlTheme({ color, radius, size });
13
- const context = useMemo(() => ({ color, interactive: selectionMode !== "none" || onRowAction != null, radius, size, theme }), [color, onRowAction, radius, selectionMode, size, theme]);
4
+ import { controlFontWeight, controlOpacity, transition, useControlMetrics } from "./control/control.js";
5
+ import { separatorColor } from "./control/field.js";
6
+ import { itemPaint } from "./control/item.js";
7
+ import { ariaSelection, stringKey } from "./control/selection.js";
8
+ import { AriaDirectionBoundary } from "./foundation/aria-direction.js";
9
+ import { colorOpacity } from "./foundation/color.js";
10
+ import { resolveDirection, useDirection } from "./foundation/direction.js";
11
+ import { dimmedClass } from "./surface/surface.js";
12
+ import { ChevronUp } from "lucide-react";
13
+ import { iconProps } from "./control/icon.js";
14
+ const TableStyleContext = createContext(null);
15
+ /** Structured rows and columns with optional selection and consumer-owned sorting. */
16
+ const TableRoot = forwardRef(function Table(properties, ref) {
17
+ const { className, color = "primary", defaultValue: _defaultValue, onAction, onChange: _onChange, onSortChange, radius, selectOnPressUp, selectionMode = "none", size, sort, style, value: _value, ...native } = properties;
18
+ const metrics = useControlMetrics(size, radius);
19
+ const context = useMemo(() => ({ color, interactive: selectionMode !== "none" || onAction != null, metrics }), [color, metrics, onAction, selectionMode]);
14
20
  const direction = resolveDirection(native.dir, useDirection());
15
- return _jsx(TableThemeContext.Provider, { value: context, children: _jsx(AriaDirectionBoundary, { direction: direction, children: _jsx(AriaTable, { ...native, ...selectionProperties(properties), ...(sort === undefined ? {} : { sortDescriptor: sort }), ref: ref, dir: direction, className: className, disabledKeys: disabledValues, selectionMode: selectionMode, onRowAction: onRowAction == null ? undefined : key => onRowAction(stringKey(key)), onSortChange: onSortChange == null ? undefined : descriptor => onSortChange(tableSort(descriptor)), style: {
21
+ return _jsx(TableStyleContext.Provider, { value: context, children: _jsx(AriaDirectionBoundary, { direction: direction, children: _jsx(AriaTable, { ...native, shouldSelectOnPressUp: selectOnPressUp, ...ariaSelection(properties, "none"), ...(sort === undefined ? {} : { sortDescriptor: sort }), ref: ref, dir: direction, className: className, onRowAction: onAction == null ? undefined : key => onAction(stringKey(key)), onSortChange: onSortChange == null ? undefined : descriptor => onSortChange(tableSort(descriptor)), style: {
16
22
  width: "100%",
17
23
  minWidth: "max-content",
18
24
  borderCollapse: "separate",
19
25
  borderSpacing: 0,
20
26
  boxSizing: "border-box",
21
- borderRadius: theme.radius,
22
- // Header and row paints belong to the table, so the table must clip
23
- // them rather than relying on a surrounding surface for its radius.
27
+ // Row paints belong to the table, so the table clips them to its own radius.
28
+ borderRadius: metrics.radius,
24
29
  overflow: "hidden",
25
30
  fontFamily: "inherit",
26
- fontSize: theme.fontSize,
31
+ fontSize: metrics.fontSize,
27
32
  ...style
28
33
  } }) }) });
29
34
  });
30
- function selectionProperties(properties) {
31
- const selectedKeys = toAriaSelection(properties.value);
32
- const defaultSelectedKeys = toAriaSelection(properties.defaultValue);
33
- const onSelectionChange = properties.onChange == null
34
- ? undefined
35
- : (selection) => {
36
- if (properties.selectionMode === "multiple") {
37
- properties.onChange?.(multipleSelection(selection));
38
- return;
39
- }
40
- if (properties.selectionMode === "single")
41
- properties.onChange?.(singleSelection(selection));
42
- };
43
- return {
44
- ...(selectedKeys !== undefined ? { selectedKeys } : {}),
45
- ...(defaultSelectedKeys !== undefined ? { defaultSelectedKeys } : {}),
46
- ...(onSelectionChange !== undefined ? { onSelectionChange } : {})
47
- };
48
- }
49
35
  function tableSort(descriptor) {
50
36
  return { column: stringKey(descriptor.column), direction: descriptor.direction };
51
37
  }
52
- const TableHeaderImplementation = forwardRef(function TableHeader({ className, color, style, ...properties }, ref) {
53
- const inherited = useTableContext();
54
- const resolvedColor = color ?? inherited.color;
55
- const theme = useControlTheme({ color: resolvedColor, radius: inherited.radius, size: inherited.size });
56
- const context = useMemo(() => ({ ...inherited, color: resolvedColor, theme }), [inherited, resolvedColor, theme]);
57
- return _jsx(TableThemeContext.Provider, { value: context, children: _jsx(AriaTableHeader, { ...properties, ref: ref, className: className, style: { ...style } }) });
38
+ const TableHeaderImplementation = forwardRef(function TableHeader({ className, style, ...properties }, ref) {
39
+ useTableStyle();
40
+ return _jsx(AriaTableHeader, { ...properties, ref: ref, className: className, style: style });
58
41
  });
59
- export const TableHeader = TableHeaderImplementation;
60
- export const TableColumn = forwardRef(function TableColumn({ allowsSorting = false, children, className, style, textValue, ...properties }, ref) {
61
- const theme = useTableTheme();
62
- return _jsx(AriaColumn, { ...properties, ref: ref, allowsSorting: allowsSorting, className: className, textValue: textValue ?? (typeof children === "string" ? children : undefined), style: state => ({
63
- ...theme.transition,
64
- minWidth: 0,
65
- height: theme.height,
66
- paddingBlock: theme.gap,
67
- paddingInline: Math.max(8, theme.spacing),
42
+ const TableColumn = forwardRef(function TableColumn({ sortable = false, rowHeader, arrowNavigation, children, className, style, textValue, ...properties }, ref) {
43
+ const { metrics } = useTableStyle();
44
+ const { colors } = metrics.visual;
45
+ return _jsx(AriaColumn, { ...properties, allowsArrowNavigation: arrowNavigation, ref: ref, isRowHeader: rowHeader, allowsSorting: sortable, className: className, textValue: textValue ?? (typeof children === "string" ? children : undefined), style: state => ({
46
+ ...transition(metrics.visual, "color, outline-color"),
47
+ height: metrics.height,
48
+ paddingInline: metrics.inset,
68
49
  boxSizing: "border-box",
69
- outline: state.isFocusVisible ? `1px solid ${theme.focusColor}` : "none",
70
- outlineOffset: -1,
71
- ...(state.isHovered && allowsSorting ? theme.paints.palette.hover : theme.paints.palette.rest),
72
- cursor: allowsSorting ? "pointer" : "default",
50
+ outline: `3px solid ${state.isFocusVisible ? colorOpacity(colors.primary, 0.34) : "transparent"}`,
51
+ outlineOffset: -3,
52
+ cursor: sortable ? "pointer" : "default",
53
+ fontSize: "0.92em",
73
54
  fontWeight: controlFontWeight,
74
55
  textAlign: "start",
75
56
  userSelect: "none",
57
+ opacity: state.isHovered && sortable ? 1 : controlOpacity.secondary,
76
58
  ...style
77
- }), children: state => _jsxs("span", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: theme.gap, minWidth: 0 }, children: [_jsx("span", { style: { minWidth: 0 }, children: typeof children === "function" ? children(state) : children }), allowsSorting && state.sortDirection != null && _jsx(SortIndicator, { direction: state.sortDirection, theme: theme })] }) });
59
+ }), children: state => _jsxs("span", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: metrics.gap, minWidth: 0 }, children: [_jsx("span", { style: { minWidth: 0 }, children: typeof children === "function" ? children(state) : children }), sortable && state.sortDirection != null && _jsx(ChevronUp, { ...iconProps(14), style: { ...transition(metrics.visual, "rotate"), flexShrink: 0, rotate: state.sortDirection === "descending" ? "180deg" : "0deg" } })] }) });
78
60
  });
79
- function SortIndicator({ direction, theme }) {
80
- return _jsx("svg", { "aria-hidden": "true", width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", stroke: "currentColor", strokeWidth: "1.5", style: {
81
- ...theme.transition,
82
- flexShrink: 0,
83
- transitionProperty: "transform",
84
- transform: `rotate(${direction === "descending" ? 180 : 0}deg)`
85
- }, children: _jsx("path", { d: "m2 8 4-4 4 4" }) });
86
- }
87
61
  const TableBodyImplementation = forwardRef(function TableBody({ className, style, ...properties }, ref) {
88
- return _jsx(AriaTableBody, { ...properties, ref: ref, className: className, style: { ...style } });
62
+ return _jsx(AriaTableBody, { ...properties, ref: ref, className: className, style: style });
89
63
  });
90
- export const TableBody = TableBodyImplementation;
64
+ /** Rows use the collection Item treatment as their own paint. */
91
65
  const TableRowImplementation = forwardRef(function TableRow({ className, disabled = false, onAction, style, ...properties }, ref) {
92
- const { interactive, theme } = useTableContext();
93
- return _jsx(AriaRow, { ...properties, ref: ref, className: className, isDisabled: disabled, onAction: onAction, style: state => ({
94
- ...theme.transition,
95
- outline: state.isFocusVisible ? `1px solid ${theme.focusColor}` : "none",
96
- outlineOffset: -1,
97
- cursor: disabled ? "not-allowed" : interactive || onAction != null ? "pointer" : "default",
98
- opacity: disabled ? controlOpacity.disabled : 1,
99
- ...(state.isSelected
100
- ? state.isPressed
101
- ? theme.paints.palette.pressed
102
- : state.isHovered
103
- ? theme.paints.palette.hover
104
- : theme.paints.palette.rest
105
- : state.isHovered && (interactive || onAction != null)
106
- ? theme.paints.subtle.hover
107
- : { background: "transparent", color: "inherit" }),
66
+ const { color, interactive, metrics } = useTableStyle();
67
+ const responds = interactive || onAction != null;
68
+ return _jsx(AriaRow, { ...properties, ref: ref, className: state => dimmedClass(state.isDisabled, className ?? state.defaultClassName) ?? "", isDisabled: disabled, onAction: onAction, style: state => ({
69
+ ...transition(metrics.visual, "background-color, color, outline-color"),
70
+ ...itemPaint(metrics.visual, color, {
71
+ selected: state.isSelected,
72
+ hovered: responds && state.isHovered,
73
+ pressed: responds && state.isPressed,
74
+ focusVisible: false,
75
+ disabled: state.isDisabled
76
+ }),
77
+ outline: `3px solid ${state.isFocusVisible ? colorOpacity(metrics.visual.colors.primary, 0.34) : "transparent"}`,
78
+ outlineOffset: -3,
79
+ cursor: state.isDisabled ? "not-allowed" : responds ? "pointer" : "default",
108
80
  ...style
109
81
  }) });
110
82
  });
111
- export const TableRow = TableRowImplementation;
112
- export const TableCell = forwardRef(function TableCell({ className, style, ...properties }, ref) {
113
- const theme = useTableTheme();
114
- const separator = colorOpacity(theme.tint, controlOpacity.separator);
115
- return _jsx(AriaCell, { ...properties, ref: ref, className: className, style: state => ({
116
- minWidth: 0,
117
- height: theme.height,
118
- paddingBlock: theme.gap,
119
- paddingInline: Math.max(8, theme.spacing),
83
+ const TableCell = forwardRef(function TableCell({ arrowNavigation, className, style, ...properties }, ref) {
84
+ const { metrics } = useTableStyle();
85
+ return _jsx(AriaCell, { ...properties, allowsArrowNavigation: arrowNavigation, ref: ref, className: className, style: state => ({
86
+ height: metrics.height,
87
+ paddingInline: metrics.inset,
120
88
  boxSizing: "border-box",
121
- // Separators belong to the row that follows them. This preserves every
122
- // internal boundary while leaving the final row without a bottom edge.
123
- borderBlockStart: `1px solid ${separator}`,
124
- outline: state.isFocusVisible ? `1px solid ${theme.focusColor}` : "none",
125
- outlineOffset: -1,
126
- background: "transparent",
127
- color: "inherit",
89
+ // Separators belong to the row that follows them, so the last row has no bottom edge.
90
+ borderBlockStart: `1px solid ${separatorColor(metrics)}`,
91
+ outline: `3px solid ${state.isFocusVisible ? colorOpacity(metrics.visual.colors.primary, 0.34) : "transparent"}`,
92
+ outlineOffset: -3,
128
93
  textAlign: "start",
129
94
  ...style
130
95
  }) });
131
96
  });
132
- function useTableContext() {
133
- const value = useContext(TableThemeContext);
134
- if (value == null)
97
+ function useTableStyle() {
98
+ const context = useContext(TableStyleContext);
99
+ if (context == null)
135
100
  throw new Error("Table parts must be used inside Table");
136
- return value;
137
- }
138
- function useTableTheme() {
139
- return useTableContext().theme;
101
+ return context;
140
102
  }
141
103
  /** Structured rows and columns with optional selection and consumer-owned sorting. */
142
104
  export const Table = Object.assign(TableRoot, {
143
- Header: TableHeader,
105
+ Header: TableHeaderImplementation,
144
106
  Column: TableColumn,
145
- Body: TableBody,
146
- Row: TableRow,
107
+ Body: TableBodyImplementation,
108
+ Row: TableRowImplementation,
147
109
  Cell: TableCell
148
110
  });
package/dist/tabs.d.ts CHANGED
@@ -1,11 +1,13 @@
1
1
  import type { CSSProperties, ReactElement, RefAttributes } from "react";
2
2
  import type { TabListProps as AriaTabListProps, TabPanelProps as AriaTabPanelProps, TabPanelsProps as AriaTabPanelsProps, TabProps as AriaTabProps, TabsProps as AriaTabsProps } from "react-aria-components";
3
- import type { ControlColor } from "./control.js";
4
- import type { RadiusProps } from "./radius.js";
5
- import type { ScaleLevel } from "./scale.js";
6
- export interface TabsRootProps extends Omit<AriaTabsProps, "className" | "defaultSelectedKey" | "isDisabled" | "onSelectionChange" | "selectedKey" | "style">, RadiusProps {
3
+ import { type Color } from "./foundation/color.js";
4
+ import type { RadiusProps } from "./foundation/radius.js";
5
+ import type { ScaleLevel } from "./foundation/scale.js";
6
+ import type { MaterialOverrides } from "./surface/material-options.js";
7
+ export interface TabsRootProps extends Omit<AriaTabsProps, "className" | "defaultSelectedKey" | "disabledKeys" | "isDisabled" | "onSelectionChange" | "selectedKey" | "style">, RadiusProps, MaterialOverrides {
7
8
  readonly className?: string;
8
- readonly color?: ControlColor;
9
+ /** Paint of the raised selection. */
10
+ readonly color?: Color;
9
11
  readonly defaultValue?: string;
10
12
  readonly disabled?: boolean;
11
13
  readonly onChange?: (value: string) => void;
@@ -13,29 +15,28 @@ export interface TabsRootProps extends Omit<AriaTabsProps, "className" | "defaul
13
15
  readonly style?: CSSProperties;
14
16
  readonly value?: string;
15
17
  }
16
- export declare const TabsRoot: import("react").ForwardRefExoticComponent<TabsRootProps & RefAttributes<HTMLDivElement>>;
17
18
  export interface TabsListProps<T extends object = object> extends Omit<AriaTabListProps<T>, "className" | "style"> {
18
19
  readonly className?: string;
19
20
  readonly style?: CSSProperties;
20
21
  }
21
22
  export type TabsListComponent = <T extends object = object>(properties: TabsListProps<T> & RefAttributes<HTMLDivElement>) => ReactElement | null;
22
- export declare const TabsList: TabsListComponent;
23
- export interface TabsTabProps extends Omit<AriaTabProps, "className" | "id" | "isDisabled" | "style"> {
23
+ export interface TabsTabProps extends Omit<AriaTabProps, "className" | "id" | "isDisabled" | "render" | "style"> {
24
+ /** Identity shared with the corresponding Panel. */
25
+ readonly id: string;
24
26
  readonly className?: string;
25
27
  readonly disabled?: boolean;
26
- readonly id: string;
27
28
  readonly style?: CSSProperties;
28
29
  }
29
- export declare const TabsTab: import("react").ForwardRefExoticComponent<TabsTabProps & RefAttributes<HTMLDivElement>>;
30
30
  export type TabsPanelsProps<T extends object = object> = AriaTabPanelsProps<T>;
31
- export declare const TabsPanels: <T>(props: AriaTabPanelsProps<T> & React.RefAttributes<HTMLDivElement>) => React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | null;
32
- export interface TabsPanelProps extends Omit<AriaTabPanelProps, "className" | "id" | "style"> {
33
- readonly className?: string;
31
+ export interface TabsPanelProps extends Omit<AriaTabPanelProps, "className" | "id" | "style" | "shouldForceMount"> {
32
+ /** Identity shared with the corresponding Tab. */
34
33
  readonly id: string;
34
+ readonly className?: string;
35
+ /** Whether the Panel stays mounted while another Tab is selected. */
36
+ readonly forceMount?: boolean;
35
37
  readonly style?: CSSProperties;
36
38
  }
37
- export declare const TabsPanel: import("react").ForwardRefExoticComponent<TabsPanelProps & RefAttributes<HTMLDivElement>>;
38
- /** Peer views with one selected tab and one corresponding panel. */
39
+ /** Peer views with one selected Tab and one corresponding Panel. */
39
40
  export declare const Tabs: import("react").ForwardRefExoticComponent<TabsRootProps & RefAttributes<HTMLDivElement>> & {
40
41
  List: TabsListComponent;
41
42
  Tab: import("react").ForwardRefExoticComponent<TabsTabProps & RefAttributes<HTMLDivElement>>;
package/dist/tabs.js CHANGED
@@ -1,103 +1,61 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { createContext, forwardRef, useContext, useId, useMemo } from "react";
3
- import { Tab as AriaTab, TabList as AriaTabList, TabPanel as AriaTabPanel, TabPanels as AriaTabPanels, Tabs as AriaTabs } from "react-aria-components";
4
- import { LayoutGroup, motion } from "motion/react";
5
- import { AriaDirectionBoundary } from "./aria-direction.js";
6
- import { controlOpacity, useControlTheme } from "./control.js";
7
- import { resolveDirection, useDirection } from "./direction.js";
8
- import { stringKey } from "./selection.js";
9
- import { Surface } from "./surface.js";
10
- const TabsThemeContext = createContext(null);
11
- export const TabsRoot = forwardRef(function TabsRoot({ className, color, defaultValue, disabled = false, onChange, orientation = "horizontal", radius = "medium", size = "medium", style, value, ...properties }, ref) {
12
- const theme = useControlTheme({ color, radius, size });
13
- const context = useMemo(() => ({ orientation, theme }), [orientation, theme]);
14
- const layoutGroup = useId();
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, forwardRef, useContext, useMemo } from "react";
3
+ import { Tab as AriaTab, TabList as AriaTabList, TabPanel as AriaTabPanel, TabPanels as AriaTabPanels, Tabs as AriaTabs, TabListStateContext } from "react-aria-components";
4
+ import { useControlMetrics } from "./control/control.js";
5
+ import { SelectionItemLabel, selectionItemStyle, selectionListStyle, SelectionTrack } from "./control/selection-track.js";
6
+ import { stringKey } from "./control/selection.js";
7
+ import { AriaDirectionBoundary } from "./foundation/aria-direction.js";
8
+ import { colorOpacity } from "./foundation/color.js";
9
+ import { resolveDirection, useDirection } from "./foundation/direction.js";
10
+ import { dimmedClass } from "./surface/surface.js";
11
+ const TabsStyleContext = createContext(null);
12
+ /** Peer views with one selected Tab and its corresponding Panel. */
13
+ const TabsRoot = forwardRef(function Tabs({ className, color = "default", defaultValue, disabled = false, onChange, orientation = "horizontal", material, radius, size, style, value, ...properties }, ref) {
14
+ const metrics = useControlMetrics(size, radius);
15
+ const context = useMemo(() => ({ color, material, metrics, orientation }), [color, material, metrics, orientation]);
15
16
  const direction = resolveDirection(properties.dir, useDirection());
16
- return _jsx(TabsThemeContext.Provider, { value: context, children: _jsx(LayoutGroup, { id: layoutGroup, children: _jsx(AriaDirectionBoundary, { direction: direction, children: _jsx(AriaTabs, { ...properties, ...(value !== undefined ? { selectedKey: value } : {}), ...(defaultValue !== undefined ? { defaultSelectedKey: defaultValue } : {}), ref: ref, dir: direction, className: className, isDisabled: disabled, orientation: orientation, onSelectionChange: key => onChange?.(stringKey(key)), style: {
17
- display: "flex",
18
- flexDirection: orientation === "horizontal" ? "column" : "row",
19
- alignItems: "stretch",
20
- gap: theme.gap,
21
- minWidth: 0,
22
- fontFamily: "inherit",
23
- fontSize: theme.fontSize,
24
- ...style
25
- } }) }) }) });
17
+ return _jsx(TabsStyleContext.Provider, { value: context, children: _jsx(AriaDirectionBoundary, { direction: direction, children: _jsx(AriaTabs, { ...properties, ...(value !== undefined ? { selectedKey: value } : {}), ...(defaultValue !== undefined ? { defaultSelectedKey: defaultValue } : {}), ref: ref, dir: direction, className: className, isDisabled: disabled, orientation: orientation, onSelectionChange: key => onChange?.(stringKey(key)), style: {
18
+ display: "flex",
19
+ flexDirection: orientation === "horizontal" ? "column" : "row",
20
+ alignItems: "stretch",
21
+ gap: metrics.gap,
22
+ minWidth: 0,
23
+ fontFamily: "inherit",
24
+ fontSize: metrics.fontSize,
25
+ ...style
26
+ } }) }) });
26
27
  });
28
+ /** The Tabs sit in a SelectionTrack; the selection slides to the selected Tab. */
27
29
  const TabsListImplementation = forwardRef(function TabsList({ className, style, ...properties }, ref) {
28
- const { orientation, theme } = useTabsTheme();
29
- return _jsx(AriaTabList, { ...properties, ref: ref, className: className, style: {
30
- display: "grid",
31
- gridAutoFlow: orientation === "horizontal" ? "column" : "row",
32
- gridAutoColumns: orientation === "horizontal" ? "minmax(0, 1fr)" : undefined,
33
- alignContent: "start",
34
- alignItems: "stretch",
35
- gap: Math.max(2, theme.gap / 2),
36
- minWidth: 0,
37
- width: orientation === "horizontal" ? "100%" : undefined,
38
- boxSizing: "border-box",
39
- padding: Math.max(2, theme.gap / 2),
40
- borderRadius: theme.radius,
41
- background: theme.paints.palette.rest.background,
42
- ...style
43
- } });
30
+ const { color, material, metrics, orientation } = useTabsStyle();
31
+ const selectedKey = useContext(TabListStateContext)?.selectedKey;
32
+ return _jsx(SelectionTrack, { metrics: metrics, color: color, material: material, orientation: orientation, selectedKey: selectedKey, className: className, style: style, children: _jsx(AriaTabList, { ...properties, ref: ref, "data-selection-list": "", style: selectionListStyle(orientation) }) });
44
33
  });
45
- export const TabsList = TabsListImplementation;
46
- export const TabsTab = forwardRef(function TabsTab({ children, className, disabled = false, style, ...properties }, ref) {
47
- const { orientation, theme } = useTabsTheme();
48
- return _jsx(AriaTab, { ...properties, ref: ref, className: className, isDisabled: disabled, style: state => ({
49
- ...theme.transition,
50
- position: "relative",
51
- zIndex: 0,
52
- display: "flex",
53
- alignItems: "center",
54
- justifyContent: "center",
55
- width: "100%",
56
- minWidth: 0,
57
- minHeight: theme.height,
58
- paddingBlock: 0,
59
- paddingInline: Math.max(8, theme.spacing),
60
- boxSizing: "border-box",
61
- borderRadius: theme.radius,
62
- outline: state.isFocusVisible ? `1px solid ${theme.focusColor}` : "none",
63
- outlineOffset: 1,
64
- cursor: disabled ? "not-allowed" : "pointer",
65
- opacity: disabled ? controlOpacity.disabled : 1,
66
- userSelect: "none",
67
- background: "transparent",
68
- color: theme.paints.palette.rest.color,
69
- ...(orientation === "vertical" ? { justifyContent: "start" } : {}),
70
- ...style
71
- }), children: state => _jsxs(_Fragment, { children: [state.isSelected && _jsx(Surface, { as: motion.span, "data-tabs-indicator": "", "aria-hidden": "true", initial: false, layoutId: "selection", color: theme.paints.palette.hover.background, transition: theme.motionTransition, style: {
72
- position: "absolute",
73
- zIndex: -1,
74
- inset: 0,
75
- boxSizing: "border-box",
76
- borderRadius: theme.radius,
77
- pointerEvents: "none"
78
- } }), _jsx("span", { style: { minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: typeof children === "function" ? children(state) : children })] }) });
34
+ const TabsTab = forwardRef(function TabsTab({ children, className, disabled = false, style, ...properties }, ref) {
35
+ const { color, metrics, orientation } = useTabsStyle();
36
+ return _jsx(AriaTab, { ...properties, ref: ref, className: state => dimmedClass(state.isDisabled, className ?? state.defaultClassName) ?? "", isDisabled: disabled, style: state => ({ ...selectionItemStyle(metrics, color, orientation, state), ...style }), children: state => _jsx(SelectionItemLabel, { metrics: metrics, emphasized: state.isSelected || state.isHovered, children: typeof children === "function" ? children(state) : children }) });
79
37
  });
80
- export const TabsPanels = AriaTabPanels;
81
- export const TabsPanel = forwardRef(function TabsPanel({ className, style, ...properties }, ref) {
82
- const { orientation, theme } = useTabsTheme();
83
- return _jsx(AriaTabPanel, { ...properties, ref: ref, className: className, style: state => ({
38
+ const TabsPanel = forwardRef(function TabsPanel({ className, forceMount, style, ...properties }, ref) {
39
+ const { metrics, orientation } = useTabsStyle();
40
+ return _jsx(AriaTabPanel, { ...properties, shouldForceMount: forceMount, ref: ref, className: className, style: state => ({
84
41
  flex: orientation === "vertical" ? "1 1 auto" : undefined,
85
42
  minWidth: 0,
86
- outline: state.isFocusVisible ? `1px solid ${theme.focusColor}` : "none",
43
+ borderRadius: metrics.radius,
44
+ outline: `3px solid ${state.isFocusVisible ? colorOpacity(metrics.visual.colors.primary, 0.34) : "transparent"}`,
87
45
  outlineOffset: 1,
88
46
  ...style
89
47
  }) });
90
48
  });
91
- function useTabsTheme() {
92
- const value = useContext(TabsThemeContext);
93
- if (value == null)
49
+ function useTabsStyle() {
50
+ const context = useContext(TabsStyleContext);
51
+ if (context == null)
94
52
  throw new Error("Tabs parts must be used inside Tabs");
95
- return value;
53
+ return context;
96
54
  }
97
- /** Peer views with one selected tab and one corresponding panel. */
55
+ /** Peer views with one selected Tab and one corresponding Panel. */
98
56
  export const Tabs = Object.assign(TabsRoot, {
99
- List: TabsList,
57
+ List: TabsListImplementation,
100
58
  Tab: TabsTab,
101
- Panels: TabsPanels,
59
+ Panels: AriaTabPanels,
102
60
  Panel: TabsPanel
103
61
  });
@@ -1,6 +1,6 @@
1
- import type { TextControlProps } from "./text-control.js";
1
+ import { type TextControlProps } from "./control/text-control.js";
2
2
  export interface TextareaProps extends Omit<TextControlProps, "type" | "pattern"> {
3
3
  readonly rows?: number;
4
4
  }
5
- /** A labeled multiline text control, vertically resizable without escaping its width. */
5
+ /** A labeled multiline text field, vertically resizable without escaping its width. */
6
6
  export declare const Textarea: import("react").ForwardRefExoticComponent<TextareaProps & import("react").RefAttributes<HTMLTextAreaElement>>;
package/dist/textarea.js CHANGED
@@ -1,17 +1,13 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { forwardRef } from "react";
3
- import { TextArea as AriaTextarea, TextField } from "react-aria-components";
4
- import { controlPaint, controlStyle, FieldFeedback, FieldLabel, fieldStyle, useControlTheme } from "./control.js";
5
- import { SurfaceField } from "./control-surface.js";
6
- import FieldStyle, { textControlClass } from "./field-style.js";
7
- /** A labeled multiline text control, vertically resizable without escaping its width. */
8
- export const Textarea = forwardRef(function Textarea({ label, description, errorMessage, disabled, readOnly, required, invalid, size, color, radius, style, className, placeholder, rows = 4, material, shadow, ...properties }, ref) {
9
- const theme = useControlTheme({ size, color, radius });
10
- return _jsxs(TextField, { ...properties, className: className, isDisabled: disabled, isReadOnly: readOnly, isRequired: required, isInvalid: invalid, style: fieldStyle(theme, disabled, style), children: [_jsx(FieldStyle, {}), _jsx(FieldLabel, { label: label }), _jsx(AriaTextarea, { ref: ref, placeholder: placeholder, rows: rows, className: textControlClass, render: (native, state) => _jsx(SurfaceField, { material: material, shadow: shadow, radius: theme.radius, paint: controlPaint(theme, state.isFocused, state.isInvalid, state.isHovered), children: _jsx("textarea", { ...native, style: { ...native.style, borderRadius: "inherit", background: "transparent" } }) }), style: state => ({
11
- ...controlStyle(theme, state.isFocused, state.isInvalid, state.isHovered, state.isFocusVisible),
12
- height: "auto",
13
- minHeight: theme.height,
14
- paddingBlock: Math.max(6, theme.spacing / 2),
15
- resize: "vertical"
16
- }) }), _jsx(FieldFeedback, { theme: theme, description: description, errorMessage: errorMessage })] });
3
+ import { TextArea as AriaTextArea, TextField } from "react-aria-components";
4
+ import { useControlMetrics } from "./control/control.js";
5
+ import { FieldFeedback, FieldLabel, fieldStyle } from "./control/field.js";
6
+ import { nativeTextStyle, TextWell } from "./control/text-control.js";
7
+ import MotionStyle, { textControlClass } from "./foundation/motion-style.js";
8
+ import { dimmedClass } from "./surface/surface.js";
9
+ /** A labeled multiline text field, vertically resizable without escaping its width. */
10
+ export const Textarea = forwardRef(function Textarea({ label, description, errorMessage, disabled, readOnly, required, invalid, size, color = "background", radius, style, className, placeholder, rows = 4, material, ...properties }, ref) {
11
+ const metrics = useControlMetrics(size, radius);
12
+ return _jsxs(TextField, { ...properties, className: dimmedClass(disabled ?? false, className), isDisabled: disabled, isReadOnly: readOnly, isRequired: required, isInvalid: invalid, style: fieldStyle(metrics, style), children: [_jsx(MotionStyle, {}), _jsx(FieldLabel, { label: label }), _jsx(AriaTextArea, { ref: ref, placeholder: placeholder, rows: rows, className: textControlClass, render: (native, state) => _jsx(TextWell, { color: color, material: material, metrics: metrics, state: state, children: _jsx("textarea", { ...native }) }), style: nativeTextStyle(metrics, true) }), _jsx(FieldFeedback, { metrics: metrics, description: description, errorMessage: errorMessage })] });
17
13
  });
@@ -1,11 +1,10 @@
1
1
  import type { Time } from "@internationalized/date";
2
2
  import type { TimeFieldProps as AriaTimeFieldProps } from "react-aria-components";
3
- import type { ControlOverrides, ControlProps, FieldProps } from "./control.js";
4
- import type { MaterialOverrides } from "./material-options.js";
5
- import type { RadiusProps } from "./radius.js";
6
- import type { ShadowOverrides } from "./shadow-options.js";
3
+ import { type ControlOverrides, type ControlProps, type FieldProps } from "./control/control.js";
4
+ import type { MaterialOverrides } from "./surface/material-options.js";
5
+ import type { RadiusProps } from "./foundation/radius.js";
7
6
  type TimeFieldOverrides = ControlOverrides | "isReadOnly" | "value" | "defaultValue" | "onChange" | "minValue" | "maxValue" | "placeholderValue" | "granularity" | "hourCycle" | "hideTimeZone" | "shouldForceLeadingZeros";
8
- export interface TimeFieldProps extends Omit<AriaTimeFieldProps<Time>, TimeFieldOverrides>, ControlProps, FieldProps, RadiusProps, MaterialOverrides, ShadowOverrides {
7
+ export interface TimeFieldProps extends Omit<AriaTimeFieldProps<Time>, TimeFieldOverrides>, ControlProps, FieldProps, RadiusProps, MaterialOverrides {
9
8
  readonly value?: Time | null;
10
9
  readonly defaultValue?: Time | null;
11
10
  readonly onChange?: (value: Time | null) => void;
@@ -14,7 +13,8 @@ export interface TimeFieldProps extends Omit<AriaTimeFieldProps<Time>, TimeField
14
13
  readonly placeholderValue?: Time;
15
14
  readonly granularity?: "hour" | "minute" | "second";
16
15
  readonly hourCycle?: 12 | 24;
17
- readonly shouldForceLeadingZeros?: boolean;
16
+ /** Whether hours, days, and months always show two digits. */
17
+ readonly leadingZeros?: boolean;
18
18
  readonly readOnly?: boolean;
19
19
  }
20
20
  /** A locale-aware time-only field whose visible clock units are independent editable segments. */