@calcifer-design/ui 0.2.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Alert/Alert.js +4 -15
- package/dist/components/Alert/Alert.module.js +1 -2
- package/dist/components/Alert/Alert_module.css +0 -12
- package/dist/components/Avatar/Avatar.js +2 -1
- package/dist/components/Avatar/Avatar.module.js +1 -2
- package/dist/components/Avatar/Avatar_module.css +0 -12
- package/dist/components/Checkbox/Checkbox.d.ts +23 -0
- package/dist/components/Checkbox/Checkbox.js +33 -0
- package/dist/components/Checkbox/Checkbox.module.js +6 -0
- package/dist/components/Checkbox/Checkbox_module.css +16 -0
- package/dist/components/DataTable/DataTable.js +7 -2
- package/dist/components/DataTable/DataTable_module.css +0 -16
- package/dist/components/Dialog/Dialog.d.ts +44 -0
- package/dist/components/Dialog/Dialog.js +82 -0
- package/dist/components/Dialog/Dialog.module.js +10 -0
- package/dist/components/Dialog/Dialog_module.css +51 -0
- package/dist/components/Field/Field.d.ts +118 -0
- package/dist/components/Field/Field.js +84 -0
- package/dist/components/LiveRegion/LiveRegion.js +2 -2
- package/dist/components/Menu/Menu.d.ts +35 -0
- package/dist/components/Menu/Menu.js +44 -0
- package/dist/components/Menu/Menu.module.js +6 -0
- package/dist/components/Menu/Menu_module.css +29 -0
- package/dist/components/NavMenu/NavMenu.js +4 -2
- package/dist/components/NavMenu/NavMenu.module.js +0 -2
- package/dist/components/NavMenu/NavMenu_module.css +0 -15
- package/dist/components/Popover/Popover.d.ts +42 -0
- package/dist/components/Popover/Popover.js +61 -0
- package/dist/components/Popover/Popover.module.js +6 -0
- package/dist/components/Popover/Popover_module.css +13 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts +35 -0
- package/dist/components/RadioGroup/RadioGroup.js +64 -0
- package/dist/components/RadioGroup/RadioGroup.module.js +6 -0
- package/dist/components/RadioGroup/RadioGroup_module.css +13 -0
- package/dist/components/Select/Select.d.ts +42 -0
- package/dist/components/Select/Select.js +90 -0
- package/dist/components/Select/Select.module.js +9 -0
- package/dist/components/Select/Select_module.css +70 -0
- package/dist/components/Spinner/Spinner.js +2 -1
- package/dist/components/Spinner/Spinner.module.js +1 -2
- package/dist/components/Spinner/Spinner_module.css +0 -12
- package/dist/components/StatusDot/StatusDot.js +6 -1
- package/dist/components/StatusDot/StatusDot_module.css +0 -12
- package/dist/components/Switch/Switch.d.ts +23 -0
- package/dist/components/Switch/Switch.js +25 -0
- package/dist/components/Switch/Switch.module.js +6 -0
- package/dist/components/Switch/Switch_module.css +41 -0
- package/dist/components/TextInput/TextInput.d.ts +17 -0
- package/dist/components/TextInput/TextInput.js +18 -0
- package/dist/components/ToastRegion/ToastRegion.d.ts +72 -0
- package/dist/components/ToastRegion/ToastRegion.js +85 -0
- package/dist/components/ToastRegion/ToastRegion.module.js +10 -0
- package/dist/components/ToastRegion/ToastRegion_module.css +104 -0
- package/dist/components/Tooltip/Tooltip.d.ts +33 -0
- package/dist/components/Tooltip/Tooltip.js +28 -0
- package/dist/components/Tooltip/TooltipProvider.d.ts +24 -0
- package/dist/components/Tooltip/TooltipProvider.js +11 -0
- package/dist/icons/CheckIcon.d.ts +6 -0
- package/dist/icons/CheckIcon.js +17 -0
- package/dist/icons/ChevronDownIcon.d.ts +6 -0
- package/dist/icons/ChevronDownIcon.js +17 -0
- package/dist/icons/CloseIcon.d.ts +10 -0
- package/dist/icons/CloseIcon.js +21 -0
- package/dist/icons/MinusIcon.d.ts +5 -0
- package/dist/icons/MinusIcon.js +16 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +12 -0
- package/dist/styles/a11y.module.js +5 -0
- package/dist/{components/LiveRegion/LiveRegion_module.css → styles/a11y_module.css} +1 -1
- package/dist/styles/field.module.js +15 -0
- package/dist/styles/field_module.css +133 -0
- package/dist/styles/popup.module.js +9 -0
- package/dist/styles/popup_module.css +109 -0
- package/package.json +2 -2
- package/dist/components/LiveRegion/LiveRegion.module.js +0 -5
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { CloseIcon } from "../../icons/CloseIcon.js";
|
|
2
3
|
import { IconButton } from "../IconButton/IconButton.js";
|
|
4
|
+
import a11y_module from "../../styles/a11y.module.js";
|
|
3
5
|
import Alert_module from "./Alert.module.js";
|
|
4
6
|
const toneWords = {
|
|
5
7
|
info: 'Information',
|
|
@@ -78,19 +80,6 @@ function ToneIcon({ tone }) {
|
|
|
78
80
|
]
|
|
79
81
|
});
|
|
80
82
|
}
|
|
81
|
-
function DismissIcon() {
|
|
82
|
-
return /*#__PURE__*/ jsxs("svg", {
|
|
83
|
-
...iconProps,
|
|
84
|
-
children: [
|
|
85
|
-
/*#__PURE__*/ jsx("path", {
|
|
86
|
-
d: "m4.5 4.5 7 7"
|
|
87
|
-
}),
|
|
88
|
-
/*#__PURE__*/ jsx("path", {
|
|
89
|
-
d: "m11.5 4.5-7 7"
|
|
90
|
-
})
|
|
91
|
-
]
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
83
|
function Alert({ tone = 'info', heading, headingLevel = 3, children, announce = false, onDismiss, dismissLabel = 'Dismiss' }) {
|
|
95
84
|
const politeness = 'danger' === tone ? 'assertive' : 'polite';
|
|
96
85
|
const liveProps = announce ? {
|
|
@@ -114,7 +103,7 @@ function Alert({ tone = 'info', heading, headingLevel = 3, children, announce =
|
|
|
114
103
|
className: Alert_module.body,
|
|
115
104
|
children: [
|
|
116
105
|
/*#__PURE__*/ jsx("span", {
|
|
117
|
-
className:
|
|
106
|
+
className: a11y_module.visuallyHidden,
|
|
118
107
|
children: toneWords[tone]
|
|
119
108
|
}),
|
|
120
109
|
void 0 !== heading ? /*#__PURE__*/ jsx(Heading, {
|
|
@@ -133,7 +122,7 @@ function Alert({ tone = 'info', heading, headingLevel = 3, children, announce =
|
|
|
133
122
|
variant: "ghost",
|
|
134
123
|
size: "sm",
|
|
135
124
|
onClick: onDismiss,
|
|
136
|
-
children: /*#__PURE__*/ jsx(
|
|
125
|
+
children: /*#__PURE__*/ jsx(CloseIcon, {})
|
|
137
126
|
})
|
|
138
127
|
}) : null
|
|
139
128
|
]
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Avatar } from "@base-ui/react/avatar";
|
|
3
|
+
import a11y_module from "../../styles/a11y.module.js";
|
|
3
4
|
import Avatar_module from "./Avatar.module.js";
|
|
4
5
|
function leadingCharacters(word, count) {
|
|
5
6
|
return Array.from(word).slice(0, count).join('');
|
|
@@ -32,7 +33,7 @@ function Avatar_Avatar({ name, src, size = 'md', shape = 'circle' }) {
|
|
|
32
33
|
children: initialsFrom(name)
|
|
33
34
|
}),
|
|
34
35
|
/*#__PURE__*/ jsx("span", {
|
|
35
|
-
className:
|
|
36
|
+
className: a11y_module.visuallyHidden,
|
|
36
37
|
children: name
|
|
37
38
|
})
|
|
38
39
|
]
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { type FieldFrameProps } from '../Field/Field.js';
|
|
3
|
+
export interface CheckboxProps extends FieldFrameProps {
|
|
4
|
+
/** The text beside the box, and the checkbox's accessible name. */
|
|
5
|
+
label: string;
|
|
6
|
+
/** Sits under the row and joins the checkbox's `aria-describedby`. */
|
|
7
|
+
description?: ReactNode;
|
|
8
|
+
/** Controlled. Pair it with `onCheckedChange`; use `defaultChecked` for an uncontrolled box. */
|
|
9
|
+
checked?: boolean;
|
|
10
|
+
defaultChecked?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Neither ticked nor unticked: `aria-checked="mixed"`, and a bar instead of a tick. The
|
|
13
|
+
* "select all" state above a list of boxes.
|
|
14
|
+
*/
|
|
15
|
+
indeterminate?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* The new checked state. One argument, as on every other control in the tier: Base UI calls
|
|
18
|
+
* its own callback `(checked, eventDetails)` and this wrapper drops the second, which no
|
|
19
|
+
* consumer can read without a cast.
|
|
20
|
+
*/
|
|
21
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
22
|
+
}
|
|
23
|
+
export declare function Checkbox({ label, name, description, error, checked, defaultChecked, indeterminate, onCheckedChange, required, disabled, }: CheckboxProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Checkbox } from "@base-ui/react/checkbox";
|
|
3
|
+
import { CheckIcon } from "../../icons/CheckIcon.js";
|
|
4
|
+
import { MinusIcon } from "../../icons/MinusIcon.js";
|
|
5
|
+
import field_module from "../../styles/field.module.js";
|
|
6
|
+
import { InlineField } from "../Field/Field.js";
|
|
7
|
+
import Checkbox_module from "./Checkbox.module.js";
|
|
8
|
+
function Checkbox_Checkbox({ label, name, description, error, checked, defaultChecked, indeterminate = false, onCheckedChange, required = false, disabled = false }) {
|
|
9
|
+
return /*#__PURE__*/ jsx(InlineField, {
|
|
10
|
+
label: label,
|
|
11
|
+
name: name,
|
|
12
|
+
description: description,
|
|
13
|
+
error: error,
|
|
14
|
+
required: required,
|
|
15
|
+
disabled: disabled,
|
|
16
|
+
children: /*#__PURE__*/ jsx(Checkbox.Root, {
|
|
17
|
+
className: [
|
|
18
|
+
field_module.controlBox,
|
|
19
|
+
Checkbox_module.box
|
|
20
|
+
].join(' '),
|
|
21
|
+
checked: checked,
|
|
22
|
+
defaultChecked: defaultChecked,
|
|
23
|
+
indeterminate: indeterminate,
|
|
24
|
+
onCheckedChange: (nextChecked)=>onCheckedChange?.(nextChecked),
|
|
25
|
+
required: required,
|
|
26
|
+
children: /*#__PURE__*/ jsx(Checkbox.Indicator, {
|
|
27
|
+
className: Checkbox_module.indicator,
|
|
28
|
+
children: indeterminate ? /*#__PURE__*/ jsx(MinusIcon, {}) : /*#__PURE__*/ jsx(CheckIcon, {})
|
|
29
|
+
})
|
|
30
|
+
})
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
export { Checkbox_Checkbox as Checkbox };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
.box-DHMQq {
|
|
2
|
+
border-radius: var(--radius-sm);
|
|
3
|
+
width: 1.25rem;
|
|
4
|
+
height: 1.25rem;
|
|
5
|
+
color: var(--color-accent-text);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.indicator-g_8JY {
|
|
9
|
+
display: inline-flex;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.indicator-g_8JY > svg {
|
|
13
|
+
width: .875rem;
|
|
14
|
+
height: .875rem;
|
|
15
|
+
}
|
|
16
|
+
|
|
@@ -2,6 +2,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { createColumnHelper, createSortedRowModel, flexRender, rowSortingFeature, sortFn_alphanumeric, sortFn_datetime, sortFn_text, tableFeatures, useTable } from "@tanstack/react-table";
|
|
3
3
|
import { useId, useState } from "react";
|
|
4
4
|
import { minWidth, useMediaQuery } from "../../hooks/useMediaQuery.js";
|
|
5
|
+
import a11y_module from "../../styles/a11y.module.js";
|
|
5
6
|
import DataTable_module from "./DataTable.module.js";
|
|
6
7
|
const features = tableFeatures({
|
|
7
8
|
rowSortingFeature: rowSortingFeature,
|
|
@@ -24,6 +25,10 @@ function DataTable({ caption, columns, data, getRowId, initialSort = [], stackBe
|
|
|
24
25
|
const captionId = useId();
|
|
25
26
|
const isWide = useMediaQuery(stackBelow ? minWidth(stackBelow) : '(min-width: 0px)');
|
|
26
27
|
const stacked = Boolean(stackBelow) && !isWide;
|
|
28
|
+
const captionClassName = [
|
|
29
|
+
DataTable_module.caption,
|
|
30
|
+
hideCaption ? a11y_module.visuallyHidden : null
|
|
31
|
+
].filter(Boolean).join(' ');
|
|
27
32
|
const table = useTable({
|
|
28
33
|
features: features,
|
|
29
34
|
data,
|
|
@@ -46,12 +51,12 @@ function DataTable({ caption, columns, data, getRowId, initialSort = [], stackBe
|
|
|
46
51
|
children: [
|
|
47
52
|
/*#__PURE__*/ jsx("caption", {
|
|
48
53
|
id: captionId,
|
|
49
|
-
className:
|
|
54
|
+
className: captionClassName,
|
|
50
55
|
"data-hidden": hideCaption ? '' : void 0,
|
|
51
56
|
children: caption
|
|
52
57
|
}),
|
|
53
58
|
/*#__PURE__*/ jsx("thead", {
|
|
54
|
-
className: DataTable_module.head,
|
|
59
|
+
className: stacked ? a11y_module.visuallyHidden : DataTable_module.head,
|
|
55
60
|
children: table.getHeaderGroups().map((headerGroup)=>/*#__PURE__*/ jsx("tr", {
|
|
56
61
|
children: headerGroup.headers.map((header)=>{
|
|
57
62
|
const sortDirection = header.column.getIsSorted();
|
|
@@ -27,15 +27,7 @@
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
.caption-glW7e[data-hidden] {
|
|
30
|
-
clip-path: inset(50%);
|
|
31
|
-
white-space: nowrap;
|
|
32
|
-
border: 0;
|
|
33
|
-
width: 1px;
|
|
34
|
-
height: 1px;
|
|
35
|
-
margin: -1px;
|
|
36
30
|
padding: 0;
|
|
37
|
-
position: absolute;
|
|
38
|
-
overflow: hidden;
|
|
39
31
|
}
|
|
40
32
|
|
|
41
33
|
.head-KQpiR {
|
|
@@ -113,14 +105,6 @@
|
|
|
113
105
|
padding-inline-end: var(--space-5);
|
|
114
106
|
}
|
|
115
107
|
|
|
116
|
-
.table-H20Eb[data-stacked] .head-KQpiR {
|
|
117
|
-
clip-path: inset(50%);
|
|
118
|
-
width: 1px;
|
|
119
|
-
height: 1px;
|
|
120
|
-
position: absolute;
|
|
121
|
-
overflow: hidden;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
108
|
.table-H20Eb[data-stacked] .row-oItIj {
|
|
125
109
|
gap: var(--space-1);
|
|
126
110
|
padding: var(--space-3) var(--space-5);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
2
|
+
export type DialogVariant = 'center' | 'sheet';
|
|
3
|
+
/** The edge a sheet docks to: `bottom` is the phone pattern, `end` a full-height side panel. */
|
|
4
|
+
export type SheetSide = 'bottom' | 'end';
|
|
5
|
+
export interface DialogProps {
|
|
6
|
+
/**
|
|
7
|
+
* The control that opens the dialog. Optional: a dialog driven by application state passes
|
|
8
|
+
* `open` and `onOpenChange` instead and renders no trigger at all.
|
|
9
|
+
*/
|
|
10
|
+
trigger?: ReactElement;
|
|
11
|
+
/** Names the popup: it is both the visible heading and the popup's `aria-labelledby` target. */
|
|
12
|
+
heading: string;
|
|
13
|
+
headingLevel?: 2 | 3 | 4;
|
|
14
|
+
/** Sits under the heading and becomes the popup's `aria-describedby` target. */
|
|
15
|
+
description?: ReactNode;
|
|
16
|
+
children?: ReactNode;
|
|
17
|
+
/**
|
|
18
|
+
* Pinned below the scrolling body; put the confirming action here. These controls are the
|
|
19
|
+
* caller's own — the header's close control always closes the dialog, and a footer control
|
|
20
|
+
* that needs to close it does so through `open`/`onOpenChange`.
|
|
21
|
+
*/
|
|
22
|
+
footer?: ReactNode;
|
|
23
|
+
/** `center` floats in the middle of the viewport; `sheet` docks to an edge — see `side`. */
|
|
24
|
+
variant?: DialogVariant;
|
|
25
|
+
/**
|
|
26
|
+
* The edge a `sheet` docks to. `bottom` (the default) is the phone pattern; `end` is a
|
|
27
|
+
* full-height panel on the trailing edge, for an item editor or a filter drawer. Ignored when
|
|
28
|
+
* `variant` is `center`, and not rendered for it.
|
|
29
|
+
*/
|
|
30
|
+
side?: SheetSide;
|
|
31
|
+
/** The accessible name of the close control in the header. */
|
|
32
|
+
closeLabel?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Whether a press outside the popup closes it. Escape always does: Base UI has no prop for
|
|
35
|
+
* that, and vetoing it means cancelling the event inside `onOpenChange`, which this wrapper
|
|
36
|
+
* deliberately does not expose.
|
|
37
|
+
*/
|
|
38
|
+
dismissOnOutsidePress?: boolean;
|
|
39
|
+
open?: boolean;
|
|
40
|
+
defaultOpen?: boolean;
|
|
41
|
+
/** Base UI calls this as `(open, eventDetails)`; the second argument is passed through. */
|
|
42
|
+
onOpenChange?: (open: boolean, eventDetails: unknown) => void;
|
|
43
|
+
}
|
|
44
|
+
export declare function Dialog({ trigger, heading, headingLevel, description, children, footer, variant, side, closeLabel, dismissOnOutsidePress, open, defaultOpen, onOpenChange, }: DialogProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Dialog } from "@base-ui/react/dialog";
|
|
3
|
+
import { CloseIcon } from "../../icons/CloseIcon.js";
|
|
4
|
+
import { IconButton } from "../IconButton/IconButton.js";
|
|
5
|
+
import popup_module from "../../styles/popup.module.js";
|
|
6
|
+
import Dialog_module from "./Dialog.module.js";
|
|
7
|
+
const headingTags = {
|
|
8
|
+
2: 'h2',
|
|
9
|
+
3: 'h3',
|
|
10
|
+
4: 'h4'
|
|
11
|
+
};
|
|
12
|
+
function Dialog_Dialog({ trigger, heading, headingLevel = 2, description, children, footer, variant = 'center', side = 'bottom', closeLabel = 'Close', dismissOnOutsidePress = true, open, defaultOpen, onOpenChange }) {
|
|
13
|
+
const sheetSide = 'sheet' === variant ? side : void 0;
|
|
14
|
+
const Heading = headingTags[headingLevel] ?? 'h2';
|
|
15
|
+
return /*#__PURE__*/ jsxs(Dialog.Root, {
|
|
16
|
+
open: open,
|
|
17
|
+
defaultOpen: defaultOpen,
|
|
18
|
+
onOpenChange: onOpenChange,
|
|
19
|
+
disablePointerDismissal: !dismissOnOutsidePress,
|
|
20
|
+
children: [
|
|
21
|
+
void 0 === trigger ? null : /*#__PURE__*/ jsx(Dialog.Trigger, {
|
|
22
|
+
render: trigger
|
|
23
|
+
}),
|
|
24
|
+
/*#__PURE__*/ jsxs(Dialog.Portal, {
|
|
25
|
+
children: [
|
|
26
|
+
/*#__PURE__*/ jsx(Dialog.Backdrop, {
|
|
27
|
+
className: [
|
|
28
|
+
popup_module.dialogLayer,
|
|
29
|
+
popup_module.scrim
|
|
30
|
+
].join(' ')
|
|
31
|
+
}),
|
|
32
|
+
/*#__PURE__*/ jsx(Dialog.Viewport, {
|
|
33
|
+
className: [
|
|
34
|
+
popup_module.dialogLayer,
|
|
35
|
+
Dialog_module.viewport
|
|
36
|
+
].join(' '),
|
|
37
|
+
"data-variant": variant,
|
|
38
|
+
"data-side": sheetSide,
|
|
39
|
+
children: /*#__PURE__*/ jsxs(Dialog.Popup, {
|
|
40
|
+
className: popup_module.surface,
|
|
41
|
+
"data-popup": 'sheet' === variant ? 'sheet' : 'dialog',
|
|
42
|
+
"data-side": sheetSide,
|
|
43
|
+
children: [
|
|
44
|
+
/*#__PURE__*/ jsxs("div", {
|
|
45
|
+
className: Dialog_module.header,
|
|
46
|
+
children: [
|
|
47
|
+
/*#__PURE__*/ jsx(Dialog.Title, {
|
|
48
|
+
className: Dialog_module.heading,
|
|
49
|
+
render: /*#__PURE__*/ jsx(Heading, {}),
|
|
50
|
+
children: heading
|
|
51
|
+
}),
|
|
52
|
+
/*#__PURE__*/ jsx(Dialog.Close, {
|
|
53
|
+
render: /*#__PURE__*/ jsx(IconButton, {
|
|
54
|
+
label: closeLabel,
|
|
55
|
+
variant: "ghost",
|
|
56
|
+
size: "sm",
|
|
57
|
+
children: /*#__PURE__*/ jsx(CloseIcon, {})
|
|
58
|
+
})
|
|
59
|
+
})
|
|
60
|
+
]
|
|
61
|
+
}),
|
|
62
|
+
void 0 === description ? null : /*#__PURE__*/ jsx(Dialog.Description, {
|
|
63
|
+
className: Dialog_module.description,
|
|
64
|
+
children: description
|
|
65
|
+
}),
|
|
66
|
+
void 0 === children ? null : /*#__PURE__*/ jsx("div", {
|
|
67
|
+
className: Dialog_module.body,
|
|
68
|
+
children: children
|
|
69
|
+
}),
|
|
70
|
+
void 0 === footer ? null : /*#__PURE__*/ jsx("div", {
|
|
71
|
+
className: Dialog_module.footer,
|
|
72
|
+
children: footer
|
|
73
|
+
})
|
|
74
|
+
]
|
|
75
|
+
})
|
|
76
|
+
})
|
|
77
|
+
]
|
|
78
|
+
})
|
|
79
|
+
]
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
export { Dialog_Dialog as Dialog };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
.viewport-nOzLZ {
|
|
2
|
+
padding: var(--space-4);
|
|
3
|
+
place-items: center;
|
|
4
|
+
display: grid;
|
|
5
|
+
position: fixed;
|
|
6
|
+
inset: 0;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.viewport-nOzLZ[data-variant="sheet"] {
|
|
10
|
+
place-items: end center;
|
|
11
|
+
padding: 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.viewport-nOzLZ[data-side="end"] {
|
|
15
|
+
place-items: center end;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.header-KgP3n {
|
|
19
|
+
align-items: flex-start;
|
|
20
|
+
gap: var(--space-3);
|
|
21
|
+
display: flex;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.heading-EfBAx {
|
|
25
|
+
min-width: 0;
|
|
26
|
+
color: var(--color-text);
|
|
27
|
+
font-size: var(--text-h3);
|
|
28
|
+
font-weight: 600;
|
|
29
|
+
line-height: var(--leading-snug);
|
|
30
|
+
flex: auto;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.description-ZV1a4 {
|
|
34
|
+
color: var(--color-text-muted);
|
|
35
|
+
font-size: var(--text-sm);
|
|
36
|
+
line-height: var(--leading-prose);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.body-mavCB {
|
|
40
|
+
overscroll-behavior: contain;
|
|
41
|
+
min-height: 0;
|
|
42
|
+
overflow-y: auto;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.footer-CAuV7 {
|
|
46
|
+
justify-content: flex-end;
|
|
47
|
+
gap: var(--space-2);
|
|
48
|
+
flex-wrap: wrap;
|
|
49
|
+
display: flex;
|
|
50
|
+
}
|
|
51
|
+
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
/** Internal. Read by `TextInput`; not exported from the barrel. */
|
|
3
|
+
export declare function useFieldRequired(): boolean;
|
|
4
|
+
export interface FieldMessagesProps {
|
|
5
|
+
/** Sits under the control and joins the control's `aria-describedby`. */
|
|
6
|
+
description: ReactNode;
|
|
7
|
+
/**
|
|
8
|
+
* The description node's own id. Left `undefined` lets Base UI generate one; a later
|
|
9
|
+
* component's own frame passes an id of its own when something else needs to point at the
|
|
10
|
+
* same node.
|
|
11
|
+
*/
|
|
12
|
+
descriptionId?: string;
|
|
13
|
+
/** The validation message. Its presence — not its content — is the error state. */
|
|
14
|
+
error: string | undefined;
|
|
15
|
+
/** The error node's own id, on the same terms as `descriptionId`. */
|
|
16
|
+
errorId?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The description/error block every Tier 3 field frame renders: a description that shows
|
|
20
|
+
* whenever one is given, and an error that only shows once one is given. Exported, but
|
|
21
|
+
* deliberately absent from `src/index.ts` — not part of the barrel, exactly as
|
|
22
|
+
* `useFieldRequired` above and `icons/CloseIcon` are reachable across modules without being
|
|
23
|
+
* published. `Field` is the first of six components that render this exact pair; `Select`,
|
|
24
|
+
* `Checkbox`, `RadioGroup` and `Switch` import it from here in later tasks, each supplying its
|
|
25
|
+
* own frame's `description` and `error` and, where its frame does not already sit inside a
|
|
26
|
+
* `Field.Root` whose context wires `aria-describedby` on its own, the ids that frame needs the
|
|
27
|
+
* nodes to carry.
|
|
28
|
+
*/
|
|
29
|
+
export declare function FieldMessages({ description, descriptionId, error, errorId }: FieldMessagesProps): import("react").JSX.Element;
|
|
30
|
+
export interface RequiredMarkProps {
|
|
31
|
+
/** Draws the mark when true. Every frame passes its own `required` prop straight in. */
|
|
32
|
+
when: boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The required mark every Tier 3 frame draws after its label. Childless and `aria-hidden` on
|
|
36
|
+
* purpose: the control's own `required` attribute is what carries the requirement into the
|
|
37
|
+
* accessibility tree, and the asterisk is generated content, because a text child would join
|
|
38
|
+
* the label's raw text content — which is what Testing Library's `getByLabelText` matches
|
|
39
|
+
* against. `field.module.css`'s `.required` has the long version. One line written five times
|
|
40
|
+
* before this, and written wrong in two of them. Internal, like `FieldMessages`.
|
|
41
|
+
*/
|
|
42
|
+
export declare function RequiredMark({ when }: RequiredMarkProps): import("react").JSX.Element | null;
|
|
43
|
+
/**
|
|
44
|
+
* The prop set every Tier 3 field frame takes. `Field`, `Select`, `Checkbox`, `RadioGroup`,
|
|
45
|
+
* `Switch` and the `InlineField` below all extend it and restate only the members their own
|
|
46
|
+
* anatomy rewords — a checkbox's label sits beside its box, a radio group's description sits
|
|
47
|
+
* under its options, and `Field` is the one frame whose control is a real `<input>`, so its
|
|
48
|
+
* `required` behaves differently on submit. `TextInput` is the tier's exception: it has no
|
|
49
|
+
* frame of its own and reads `name`, `disabled` and `required` off the one around it.
|
|
50
|
+
*/
|
|
51
|
+
export interface FieldFrameProps {
|
|
52
|
+
/** The visible label, and the control's accessible name. */
|
|
53
|
+
label: string;
|
|
54
|
+
/** Identifies the field when a form is submitted. */
|
|
55
|
+
name?: string;
|
|
56
|
+
/** Sits under the control and joins the control's `aria-describedby`. */
|
|
57
|
+
description?: ReactNode;
|
|
58
|
+
/**
|
|
59
|
+
* The validation message. Its presence — not its content — is the error state: the frame
|
|
60
|
+
* becomes `invalid`, the control gets `aria-invalid="true"` and the message joins the
|
|
61
|
+
* control's `aria-describedby`. Validation itself belongs to the consuming app; the library
|
|
62
|
+
* owns only how an error looks and how it is announced.
|
|
63
|
+
*/
|
|
64
|
+
error?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Draws the required mark and puts `required` on the control. Base UI carries it on the
|
|
67
|
+
* visually hidden, `aria-hidden`, `tabindex="-1"` companion input it submits with — the exact
|
|
68
|
+
* shape a browser refuses to report a validation message on, so the native bubble blocks the
|
|
69
|
+
* submit silently instead. A form driven by a form library must carry `noValidate` on the
|
|
70
|
+
* `<form>`, as `Field`'s own `required` documents and the composed example does.
|
|
71
|
+
*/
|
|
72
|
+
required?: boolean;
|
|
73
|
+
disabled?: boolean;
|
|
74
|
+
}
|
|
75
|
+
export interface FieldProps extends FieldFrameProps {
|
|
76
|
+
/**
|
|
77
|
+
* Identifies the field when a form is submitted. It takes precedence over any `name` the
|
|
78
|
+
* control carries, which is why no control in this tier has one.
|
|
79
|
+
*/
|
|
80
|
+
name?: string;
|
|
81
|
+
/**
|
|
82
|
+
* Draws the required mark and puts `required` on the control. Note that a native `required`
|
|
83
|
+
* also arms the browser's own validation bubble on submit; a form driven by TanStack Form or
|
|
84
|
+
* any other library should carry `noValidate` on the `<form>`, as such forms normally do.
|
|
85
|
+
* `Field`'s control is a real `<input>`, so the browser reports the message rather than
|
|
86
|
+
* blocking the submit in silence, which is what the other four frames' `required` documents.
|
|
87
|
+
*/
|
|
88
|
+
required?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* The control. `TextInput` is the one this tier ships for it; anything else Base UI's field
|
|
91
|
+
* context reaches works too, and `TextInput`'s `render` prop is how a caller's own element —
|
|
92
|
+
* a `<textarea>`, an `<input type="file">` — gets the same wiring and the same skin.
|
|
93
|
+
*
|
|
94
|
+
* `Select`, `Checkbox`, `RadioGroup` and `Switch` are **not** composed in here: each owns its
|
|
95
|
+
* own field frame, because a `<label for>` above a control is not the anatomy any of them has.
|
|
96
|
+
*/
|
|
97
|
+
children: ReactNode;
|
|
98
|
+
}
|
|
99
|
+
export declare function Field({ label, name, description, error, required, disabled, children, }: FieldProps): import("react").JSX.Element;
|
|
100
|
+
export interface InlineFieldProps extends FieldFrameProps {
|
|
101
|
+
/** The text beside the control, and the control's accessible name. */
|
|
102
|
+
label: string;
|
|
103
|
+
/** Sits under the row and joins the control's `aria-describedby`. */
|
|
104
|
+
description?: ReactNode;
|
|
105
|
+
/** Draws the required mark. The control in the row still takes its own `required`. */
|
|
106
|
+
required?: boolean;
|
|
107
|
+
/** The control that sits at the head of the row: a `Checkbox.Root`, a `Switch.Root`. */
|
|
108
|
+
children: ReactNode;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* The frame `Checkbox` and `Switch` share: a row whose label wraps the control and the text,
|
|
112
|
+
* with the description and the error beneath it. That is the whole difference between this
|
|
113
|
+
* frame and `Field`'s — the label sits beside the control rather than above it — and it is why
|
|
114
|
+
* neither of those two is composed inside `Field`. Exported, but deliberately absent from
|
|
115
|
+
* `src/index.ts`, on the same terms as `FieldMessages` and `useFieldRequired` above: a
|
|
116
|
+
* consumer composes a `Checkbox` or a `Switch`, not the frame under them.
|
|
117
|
+
*/
|
|
118
|
+
export declare function InlineField({ label, name, description, error, required, disabled, children, }: InlineFieldProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Field } from "@base-ui/react/field";
|
|
3
|
+
import { createContext, useContext } from "react";
|
|
4
|
+
import field_module from "../../styles/field.module.js";
|
|
5
|
+
const FieldRequiredContext = /*#__PURE__*/ createContext(false);
|
|
6
|
+
function useFieldRequired() {
|
|
7
|
+
return useContext(FieldRequiredContext);
|
|
8
|
+
}
|
|
9
|
+
function FieldMessages({ description, descriptionId, error, errorId }) {
|
|
10
|
+
const hasDescription = null != description && false !== description;
|
|
11
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
12
|
+
children: [
|
|
13
|
+
hasDescription ? /*#__PURE__*/ jsx(Field.Description, {
|
|
14
|
+
id: descriptionId,
|
|
15
|
+
className: field_module.description,
|
|
16
|
+
children: description
|
|
17
|
+
}) : null,
|
|
18
|
+
void 0 === error ? null : /*#__PURE__*/ jsx(Field.Error, {
|
|
19
|
+
id: errorId,
|
|
20
|
+
className: field_module.error,
|
|
21
|
+
match: true,
|
|
22
|
+
children: error
|
|
23
|
+
})
|
|
24
|
+
]
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function RequiredMark({ when }) {
|
|
28
|
+
return when ? /*#__PURE__*/ jsx("span", {
|
|
29
|
+
className: field_module.required,
|
|
30
|
+
"aria-hidden": "true"
|
|
31
|
+
}) : null;
|
|
32
|
+
}
|
|
33
|
+
function Field_Field({ label, name, description, error, required = false, disabled = false, children }) {
|
|
34
|
+
return /*#__PURE__*/ jsxs(Field.Root, {
|
|
35
|
+
className: field_module.frame,
|
|
36
|
+
name: name,
|
|
37
|
+
disabled: disabled,
|
|
38
|
+
invalid: void 0 !== error,
|
|
39
|
+
children: [
|
|
40
|
+
/*#__PURE__*/ jsxs(Field.Label, {
|
|
41
|
+
className: field_module.label,
|
|
42
|
+
children: [
|
|
43
|
+
label,
|
|
44
|
+
/*#__PURE__*/ jsx(RequiredMark, {
|
|
45
|
+
when: required
|
|
46
|
+
})
|
|
47
|
+
]
|
|
48
|
+
}),
|
|
49
|
+
/*#__PURE__*/ jsx(FieldRequiredContext.Provider, {
|
|
50
|
+
value: required,
|
|
51
|
+
children: children
|
|
52
|
+
}),
|
|
53
|
+
/*#__PURE__*/ jsx(FieldMessages, {
|
|
54
|
+
description: description,
|
|
55
|
+
error: error
|
|
56
|
+
})
|
|
57
|
+
]
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
function InlineField({ label, name, description, error, required = false, disabled = false, children }) {
|
|
61
|
+
return /*#__PURE__*/ jsxs(Field.Root, {
|
|
62
|
+
className: field_module.inlineFrame,
|
|
63
|
+
name: name,
|
|
64
|
+
disabled: disabled,
|
|
65
|
+
invalid: void 0 !== error,
|
|
66
|
+
children: [
|
|
67
|
+
/*#__PURE__*/ jsxs(Field.Label, {
|
|
68
|
+
className: field_module.optionLabel,
|
|
69
|
+
children: [
|
|
70
|
+
children,
|
|
71
|
+
label,
|
|
72
|
+
/*#__PURE__*/ jsx(RequiredMark, {
|
|
73
|
+
when: required
|
|
74
|
+
})
|
|
75
|
+
]
|
|
76
|
+
}),
|
|
77
|
+
/*#__PURE__*/ jsx(FieldMessages, {
|
|
78
|
+
description: description,
|
|
79
|
+
error: error
|
|
80
|
+
})
|
|
81
|
+
]
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
export { FieldMessages, Field_Field as Field, InlineField, RequiredMark, useFieldRequired };
|