@mistriwork/ui 1.0.0-rc.38 → 1.0.0-rc.40
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/Avatar.d.ts +3 -1
- package/dist/Avatar.js +4 -1
- package/dist/Button.d.ts +13 -3
- package/dist/Button.js +9 -1
- package/dist/Choices.d.ts +11 -5
- package/dist/Choices.js +12 -5
- package/dist/DateField.d.ts +3 -1
- package/dist/DateField.js +4 -1
- package/dist/Drawer.d.ts +2 -1
- package/dist/Drawer.js +4 -1
- package/dist/DropMenu.d.ts +8 -4
- package/dist/DropMenu.js +10 -4
- package/dist/Dropdown.d.ts +4 -2
- package/dist/Dropdown.js +6 -2
- package/dist/Modal.d.ts +2 -1
- package/dist/Modal.js +4 -1
- package/dist/Pagination.d.ts +2 -1
- package/dist/Pagination.js +4 -1
- package/dist/Popover.d.ts +3 -1
- package/dist/Popover.js +4 -1
- package/dist/Select.d.ts +4 -2
- package/dist/Select.js +6 -2
- package/dist/SensitiveField.d.ts +3 -1
- package/dist/SensitiveField.js +4 -1
- package/dist/Slider.d.ts +3 -1
- package/dist/Slider.js +4 -1
- package/dist/Switch.d.ts +3 -1
- package/dist/Switch.js +4 -1
- package/dist/Tabs.d.ts +3 -1
- package/dist/Tabs.js +4 -1
- package/dist/TextField.d.ts +7 -3
- package/dist/TextField.js +8 -3
- package/dist/Tooltip.d.ts +3 -1
- package/dist/Tooltip.js +4 -1
- package/dist/Typeahead.d.ts +3 -2
- package/dist/Typeahead.js +4 -1
- package/dist/UiKit.d.ts +86 -0
- package/dist/UiKit.js +32 -0
- package/dist/conformance.d.ts +9 -0
- package/dist/conformance.js +470 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -1
- package/dist/internal/uiKitContext.d.ts +15 -0
- package/dist/internal/uiKitContext.js +23 -0
- package/dist/uiKitSlots.d.ts +13 -0
- package/dist/uiKitSlots.js +83 -0
- package/package.json +4 -1
package/dist/Avatar.d.ts
CHANGED
|
@@ -8,4 +8,6 @@ export interface AvatarProps {
|
|
|
8
8
|
className?: string;
|
|
9
9
|
}
|
|
10
10
|
export declare function initialsOf(name: string): string;
|
|
11
|
-
|
|
11
|
+
declare function DefaultAvatar({ name, src, size, className }: AvatarProps): import("react").JSX.Element;
|
|
12
|
+
export declare const Avatar: typeof DefaultAvatar;
|
|
13
|
+
export {};
|
package/dist/Avatar.js
CHANGED
|
@@ -9,6 +9,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
9
9
|
* disc's title. Sizes are the house ones: `sm` 28px, `md` 36px, `lg` 48px.
|
|
10
10
|
*/
|
|
11
11
|
import { Avatar as BaseAvatar } from '@base-ui/react/avatar';
|
|
12
|
+
import { slotted } from './internal/uiKitContext.js';
|
|
12
13
|
const graphemes = typeof Intl !== 'undefined' && 'Segmenter' in Intl ? new Intl.Segmenter(undefined, { granularity: 'grapheme' }) : null;
|
|
13
14
|
/* A letter is a grapheme, not a UTF-16 unit: `slice(0, 1)` splits an emoji or an astral letter into a lone surrogate. */
|
|
14
15
|
function firstLetter(word) {
|
|
@@ -23,6 +24,8 @@ export function initialsOf(name) {
|
|
|
23
24
|
return firstLetter(words[0]);
|
|
24
25
|
return firstLetter(words[0]) + firstLetter(words[1]);
|
|
25
26
|
}
|
|
26
|
-
|
|
27
|
+
function DefaultAvatar({ name, src, size = 'md', className }) {
|
|
27
28
|
return (_jsxs(BaseAvatar.Root, { className: ['ui-avatar', `ui-avatar-${size}`, className].filter(Boolean).join(' '), children: [src ? _jsx(BaseAvatar.Image, { className: "ui-avatar-image", src: src, alt: "" }) : null, _jsx(BaseAvatar.Fallback, { className: "ui-avatar-fallback", "aria-hidden": "true", children: name ? initialsOf(name) : '' })] }));
|
|
28
29
|
}
|
|
30
|
+
/* Slotted (UiKit.tsx): an App's control kit may draw its own in place of the default, with the same props. */
|
|
31
|
+
export const Avatar = slotted('Avatar', DefaultAvatar);
|
package/dist/Button.d.ts
CHANGED
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
* focus it holds, so a busy one says `aria-disabled` and refuses the press
|
|
10
10
|
* itself — a click, and the implicit submission Enter makes through it.
|
|
11
11
|
*/
|
|
12
|
-
import type { ButtonHTMLAttributes, ReactNode, Ref } from 'react';
|
|
12
|
+
import type { AnchorHTMLAttributes, ButtonHTMLAttributes, ReactNode, Ref } from 'react';
|
|
13
13
|
export type ButtonIntent = 'primary' | 'secondary' | 'quiet' | 'danger';
|
|
14
14
|
export type ButtonSize = 'compact' | 'default' | 'large';
|
|
15
|
-
interface ButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'type'> {
|
|
15
|
+
export interface ButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'type'> {
|
|
16
16
|
/** Primary is the one filled action; secondary the outlined rest; quiet a word in the link ink; danger what cannot be taken back. */
|
|
17
17
|
intent?: ButtonIntent;
|
|
18
18
|
size?: ButtonSize;
|
|
@@ -32,5 +32,15 @@ export declare function buttonClass({ intent, size, block, className, }?: {
|
|
|
32
32
|
block?: boolean;
|
|
33
33
|
className?: string;
|
|
34
34
|
}): string;
|
|
35
|
-
|
|
35
|
+
declare function DefaultButton({ intent, size, busy, busyLabel, block, type, className, onClick, children, ref, ...rest }: ButtonProps): import("react").JSX.Element;
|
|
36
|
+
export interface ButtonLinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
37
|
+
intent?: ButtonIntent;
|
|
38
|
+
size?: ButtonSize;
|
|
39
|
+
block?: boolean;
|
|
40
|
+
ref?: Ref<HTMLAnchorElement>;
|
|
41
|
+
}
|
|
42
|
+
/** A link dressed as a button: it goes somewhere (a download, another page) rather than doing something here. */
|
|
43
|
+
declare function DefaultButtonLink({ intent, size, block, className, ...rest }: ButtonLinkProps): import("react").JSX.Element;
|
|
44
|
+
export declare const Button: typeof DefaultButton;
|
|
45
|
+
export declare const ButtonLink: typeof DefaultButtonLink;
|
|
36
46
|
export {};
|
package/dist/Button.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { slotted } from './internal/uiKitContext.js';
|
|
2
3
|
/* The class a look already dresses for each intent, beside the primitive's own. */
|
|
3
4
|
const DRESS = {
|
|
4
5
|
primary: 'primary btn-primary',
|
|
@@ -10,7 +11,7 @@ const DRESS = {
|
|
|
10
11
|
export function buttonClass({ intent = 'secondary', size = 'default', block = false, className = '', } = {}) {
|
|
11
12
|
return ['btn', DRESS[intent], size === 'default' ? '' : `btn-${size}`, block ? 'btn-block' : '', className].filter(Boolean).join(' ');
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
+
function DefaultButton({ intent = 'secondary', size = 'default', busy = false, busyLabel, block = false, type = 'button', className, onClick, children, ref, ...rest }) {
|
|
14
15
|
const press = (event) => {
|
|
15
16
|
if (busy) {
|
|
16
17
|
event.preventDefault();
|
|
@@ -20,3 +21,10 @@ export function Button({ intent = 'secondary', size = 'default', busy = false, b
|
|
|
20
21
|
};
|
|
21
22
|
return (_jsx("button", { ...rest, ref: ref, type: type, className: buttonClass({ intent, size, block, className }), "aria-disabled": busy || rest['aria-disabled'] || undefined, "data-busy": busy || undefined, onClick: press, children: busy && busyLabel !== undefined ? busyLabel : children }));
|
|
22
23
|
}
|
|
24
|
+
/** A link dressed as a button: it goes somewhere (a download, another page) rather than doing something here. */
|
|
25
|
+
function DefaultButtonLink({ intent, size, block, className, ...rest }) {
|
|
26
|
+
return _jsx("a", { ...rest, className: buttonClass({ intent, size, block, className }) });
|
|
27
|
+
}
|
|
28
|
+
/* Slotted (UiKit.tsx): an App's control kit may draw its own in place of the default, with the same props. */
|
|
29
|
+
export const Button = slotted('Button', DefaultButton);
|
|
30
|
+
export const ButtonLink = slotted('ButtonLink', DefaultButtonLink);
|
package/dist/Choices.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export interface YesNoProps extends Omit<FieldFrame, 'label'> {
|
|
|
23
23
|
no: string;
|
|
24
24
|
}
|
|
25
25
|
/** Two buttons answering a question. */
|
|
26
|
-
|
|
26
|
+
declare function DefaultYesNo(props: YesNoProps): ReactNode;
|
|
27
27
|
export interface ChoiceCardsProps extends FieldFrame {
|
|
28
28
|
options: ChoiceOption[];
|
|
29
29
|
value: string[];
|
|
@@ -34,7 +34,7 @@ export interface ChoiceCardsProps extends FieldFrame {
|
|
|
34
34
|
exclusive?: string;
|
|
35
35
|
}
|
|
36
36
|
/** Cards with an icon, a label and a box. One choice is a radio group; `multiple` a group of checkboxes. */
|
|
37
|
-
|
|
37
|
+
declare function DefaultChoiceCards(props: ChoiceCardsProps): ReactNode;
|
|
38
38
|
/** One card of several: its words, its picture and whether it is on. */
|
|
39
39
|
export interface CheckCard {
|
|
40
40
|
key: string;
|
|
@@ -63,7 +63,7 @@ export interface CheckCardsProps {
|
|
|
63
63
|
* on, else the first), the arrows and Home and End move between them, and Space turns the one in hand on or off — and
|
|
64
64
|
* each is a `checkbox` saying `aria-checked`, so a screen reader hears "checked" as it moves.
|
|
65
65
|
*/
|
|
66
|
-
|
|
66
|
+
declare function DefaultCheckCards(props: CheckCardsProps): ReactNode;
|
|
67
67
|
export interface CheckboxProps extends Omit<FieldFrame, 'label'> {
|
|
68
68
|
checked: boolean;
|
|
69
69
|
onChange: (on: boolean) => void;
|
|
@@ -72,6 +72,12 @@ export interface CheckboxProps extends Omit<FieldFrame, 'label'> {
|
|
|
72
72
|
disabled?: boolean;
|
|
73
73
|
}
|
|
74
74
|
/** A checkbox beside its text. */
|
|
75
|
-
|
|
75
|
+
declare function DefaultCheckbox(props: CheckboxProps): ReactNode;
|
|
76
76
|
/** A checkbox for a long notice: the paragraph is the label, in the body's weight. */
|
|
77
|
-
|
|
77
|
+
declare function DefaultConsent(props: CheckboxProps): ReactNode;
|
|
78
|
+
export declare const YesNo: typeof DefaultYesNo;
|
|
79
|
+
export declare const ChoiceCards: typeof DefaultChoiceCards;
|
|
80
|
+
export declare const CheckCards: typeof DefaultCheckCards;
|
|
81
|
+
export declare const Checkbox: typeof DefaultCheckbox;
|
|
82
|
+
export declare const Consent: typeof DefaultConsent;
|
|
83
|
+
export {};
|
package/dist/Choices.js
CHANGED
|
@@ -9,13 +9,14 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
9
9
|
import { useId, useRef, useState } from 'react';
|
|
10
10
|
import { Field } from './Field.js';
|
|
11
11
|
import { frameOf } from './fieldFrame.js';
|
|
12
|
+
import { slotted } from './internal/uiKitContext.js';
|
|
12
13
|
/** Two buttons answering a question. */
|
|
13
|
-
|
|
14
|
+
function DefaultYesNo(props) {
|
|
14
15
|
const name = useId();
|
|
15
16
|
return (_jsx(Field, { ...frameOf(props), group: true, children: (control) => (_jsx("div", { className: "choice-pair", role: "radiogroup", "aria-labelledby": control['aria-labelledby'], "aria-describedby": control['aria-describedby'], "aria-invalid": control['aria-invalid'], children: ['yes', 'no'].map((v) => (_jsxs("label", { className: `choice-pick${props.value === v ? ' is-on' : ''}`, children: [_jsx("input", { type: "radio", name: name, className: "choice-input", checked: props.value === v, onChange: () => props.onChange(v) }), props[v]] }, v))) })) }));
|
|
16
17
|
}
|
|
17
18
|
/** Cards with an icon, a label and a box. One choice is a radio group; `multiple` a group of checkboxes. */
|
|
18
|
-
|
|
19
|
+
function DefaultChoiceCards(props) {
|
|
19
20
|
const name = useId();
|
|
20
21
|
const toggle = (v, on) => {
|
|
21
22
|
if (!props.multiple)
|
|
@@ -38,7 +39,7 @@ export function ChoiceCards(props) {
|
|
|
38
39
|
* on, else the first), the arrows and Home and End move between them, and Space turns the one in hand on or off — and
|
|
39
40
|
* each is a `checkbox` saying `aria-checked`, so a screen reader hears "checked" as it moves.
|
|
40
41
|
*/
|
|
41
|
-
|
|
42
|
+
function DefaultCheckCards(props) {
|
|
42
43
|
const { cards } = props;
|
|
43
44
|
const [held, setHeld] = useState(undefined);
|
|
44
45
|
const faces = useRef([]);
|
|
@@ -79,10 +80,16 @@ export function CheckCards(props) {
|
|
|
79
80
|
}, onFocus: () => setHeld(index), onKeyDown: (event) => keys(event, index), children: [card.icon ? (_jsx("span", { className: "choice-card-icon", "aria-hidden": "true", children: card.icon })) : null, _jsxs("span", { className: "choice-card-label", children: [card.label, card.help ? _jsx("span", { className: "choice-card-help", children: card.help }) : null] }), _jsx("span", { className: "choice-box", "aria-hidden": "true" })] }, card.key))) }));
|
|
80
81
|
}
|
|
81
82
|
/** A checkbox beside its text. */
|
|
82
|
-
|
|
83
|
+
function DefaultCheckbox(props) {
|
|
83
84
|
return (_jsx(Field, { ...frameOf(props), check: true, children: (control) => (_jsx("input", { ...control, type: "checkbox", className: "field-check", checked: props.checked, disabled: props.disabled, onChange: (e) => props.onChange(e.target.checked) })) }));
|
|
84
85
|
}
|
|
85
86
|
/** A checkbox for a long notice: the paragraph is the label, in the body's weight. */
|
|
86
|
-
|
|
87
|
+
function DefaultConsent(props) {
|
|
87
88
|
return _jsx(Checkbox, { ...props, className: ['form-field-consent', props.className].filter(Boolean).join(' ') });
|
|
88
89
|
}
|
|
90
|
+
/* Slotted (UiKit.tsx): an App's control kit may draw its own in place of the default, with the same props. */
|
|
91
|
+
export const YesNo = slotted('YesNo', DefaultYesNo);
|
|
92
|
+
export const ChoiceCards = slotted('ChoiceCards', DefaultChoiceCards);
|
|
93
|
+
export const CheckCards = slotted('CheckCards', DefaultCheckCards);
|
|
94
|
+
export const Checkbox = slotted('Checkbox', DefaultCheckbox);
|
|
95
|
+
export const Consent = slotted('Consent', DefaultConsent);
|
package/dist/DateField.d.ts
CHANGED
|
@@ -65,4 +65,6 @@ export interface DateFieldProps {
|
|
|
65
65
|
'aria-describedby'?: string;
|
|
66
66
|
}
|
|
67
67
|
/** A date field, or a date and a wall-clock time. No input is parsed as an instant or shifted by a timezone. */
|
|
68
|
-
|
|
68
|
+
declare function DefaultDateField({ id, words, calendarIcon, value, onChange, onBlur, onKeyDown, disabled, required, min, max, locale, timezone, now, firstDay, className, name, inputRef, placeholder, withTime, popupRef, onOpenChange, 'aria-label': label, 'aria-invalid': invalid, 'aria-describedby': describedBy, }: DateFieldProps): import("react").JSX.Element;
|
|
69
|
+
export declare const DateField: typeof DefaultDateField;
|
|
70
|
+
export {};
|
package/dist/DateField.js
CHANGED
|
@@ -12,6 +12,7 @@ import { Popover } from '@base-ui/react/popover';
|
|
|
12
12
|
import { layoutViewport, zoomAnchor } from './internal/anchor.js';
|
|
13
13
|
import { addDateDays, addDateMonths, clampDate, dateBounds, dateFormat, dateParts, dateTimeWithinBounds, dateWithinBounds, isPickerDate, isPickerDateTime, monthGrid, monthLabel, splitDateTime, todayInZone, weekdayLabels, withDate, } from './internal/datePickerModel.js';
|
|
14
14
|
import { popupContainer } from './internal/popups.js';
|
|
15
|
+
import { slotted } from './internal/uiKitContext.js';
|
|
15
16
|
/** How a locale writes a numeric date: the order of its parts and its separator ("MM/DD/YYYY" in en-US). */
|
|
16
17
|
function dateMask(locale) {
|
|
17
18
|
let parts;
|
|
@@ -54,7 +55,7 @@ function readDate(text, mask) {
|
|
|
54
55
|
return isPickerDate(iso) ? iso : undefined;
|
|
55
56
|
}
|
|
56
57
|
/** A date field, or a date and a wall-clock time. No input is parsed as an instant or shifted by a timezone. */
|
|
57
|
-
|
|
58
|
+
function DefaultDateField({ id, words, calendarIcon, value, onChange, onBlur, onKeyDown, disabled, required, min, max, locale, timezone, now, firstDay = 1, className = '', name, inputRef, placeholder, withTime = false, popupRef, onOpenChange, 'aria-label': label, 'aria-invalid': invalid, 'aria-describedby': describedBy, }) {
|
|
58
59
|
// The calendar only ever sees the date; a wall time's clock stays in the box.
|
|
59
60
|
const datePart = withTime ? (splitDateTime(value)?.date ?? value.slice(0, 10)) : value;
|
|
60
61
|
// A range facet may temporarily supply an incomplete or reversed bound.
|
|
@@ -253,3 +254,5 @@ export function DateField({ id, words, calendarIcon, value, onChange, onBlur, on
|
|
|
253
254
|
: false;
|
|
254
255
|
}, className: "date-field-popup", "aria-label": words.calendar(label || undefined), initialFocus: () => popup.current?.querySelector(`[data-date="${active}"]`) ?? true, children: [_jsxs("div", { className: "date-field-head", children: [_jsx("button", { type: "button", "aria-label": words.previousMonth, disabled: previous.slice(0, 7) === active.slice(0, 7) || previous.slice(0, 7) < bounds.min.slice(0, 7), onClick: () => setActive(clampDate(previous, bounds)), children: "\u2190" }), _jsx("span", { id: caption, "aria-live": "polite", "aria-atomic": "true", children: monthLabel(active, locale) }), _jsx("button", { type: "button", "aria-label": words.nextMonth, disabled: next.slice(0, 7) === active.slice(0, 7) || next.slice(0, 7) > bounds.max.slice(0, 7), onClick: () => setActive(clampDate(next, bounds)), children: "\u2192" })] }), _jsxs("table", { className: "date-field-calendar", role: "grid", "aria-labelledby": caption, children: [_jsx("thead", { children: _jsx("tr", { children: weekdays.map((day) => (_jsx("th", { scope: "col", "aria-label": day.long, children: day.short }, day.long))) }) }), _jsx("tbody", { children: Array.from({ length: 6 }, (_, week) => (_jsx("tr", { children: days.slice(week * 7, week * 7 + 7).map((day, index) => (_jsx("td", { "aria-selected": day.date === datePart, children: day.date && (_jsx("button", { type: "button", "data-date": day.date, "data-outside": !day.inMonth || undefined, "data-selected": day.date === datePart || undefined, "aria-current": day.date === today ? 'date' : undefined, disabled: day.disabled, tabIndex: day.date === active ? 0 : -1, "aria-label": dayName(day.date), onKeyDown: onDayKey, onClick: () => choose(day.date), children: Number(day.date.slice(8)) })) }, day.date ?? index))) }, week))) })] }), _jsxs("div", { className: "date-field-foot", children: [_jsx("button", { type: "button", onClick: () => choose(''), children: words.clear }), _jsx("button", { type: "button", disabled: !dateWithinBounds(today, bounds), onClick: () => choose(today), children: words.today })] })] }) }) })] }) }));
|
|
255
256
|
}
|
|
257
|
+
/* Slotted (UiKit.tsx): an App's control kit may draw its own in place of the default, with the same props. */
|
|
258
|
+
export const DateField = slotted('DateField', DefaultDateField);
|
package/dist/Drawer.d.ts
CHANGED
|
@@ -37,5 +37,6 @@ export type DrawerProps = DrawerBase & ({
|
|
|
37
37
|
title?: undefined;
|
|
38
38
|
ariaLabel: string;
|
|
39
39
|
});
|
|
40
|
-
|
|
40
|
+
declare function DefaultDrawer({ open, onOpenChange, side, title, ariaLabel, children, className, closeDisabled, closeLabel, }: DrawerProps): import("react").JSX.Element;
|
|
41
|
+
export declare const Drawer: typeof DefaultDrawer;
|
|
41
42
|
export {};
|
package/dist/Drawer.js
CHANGED
|
@@ -21,7 +21,8 @@ import { useContext } from 'react';
|
|
|
21
21
|
import { Drawer as BaseDrawer } from '@base-ui/react/drawer';
|
|
22
22
|
import { ComponentStyleScope } from './internal/ComponentStyleScope.js';
|
|
23
23
|
import { popupContainer } from './internal/popups.js';
|
|
24
|
-
|
|
24
|
+
import { slotted } from './internal/uiKitContext.js';
|
|
25
|
+
function DefaultDrawer({ open, onOpenChange, side = 'right', title, ariaLabel, children, className, closeDisabled = false, closeLabel = 'Close', }) {
|
|
25
26
|
const componentScope = useContext(ComponentStyleScope);
|
|
26
27
|
return (_jsx(BaseDrawer.Root, { open: open, disablePointerDismissal: closeDisabled, onOpenChange: (next) => {
|
|
27
28
|
/* A non-cancellable operation: a dismissal request (Escape, a
|
|
@@ -32,3 +33,5 @@ export function Drawer({ open, onOpenChange, side = 'right', title, ariaLabel, c
|
|
|
32
33
|
onOpenChange?.(next);
|
|
33
34
|
}, children: _jsxs(BaseDrawer.Portal, { container: popupContainer(), children: [_jsx(BaseDrawer.Backdrop, { className: "ui-drawer-backdrop" }), _jsx(BaseDrawer.Viewport, { className: ['ui-drawer-viewport', `ui-drawer-${side}`, className].filter(Boolean).join(' '), "data-component": componentScope, children: _jsxs(BaseDrawer.Popup, { className: "ui-drawer", "aria-label": ariaLabel ?? (typeof title === 'string' ? title : undefined), children: [_jsxs("div", { className: "ui-drawer-head", children: [title !== undefined ? _jsx(BaseDrawer.Title, { className: "ui-drawer-title", children: title }) : null, _jsx(BaseDrawer.Close, { className: "ui-drawer-close", "aria-label": closeLabel, disabled: closeDisabled, children: _jsx("svg", { viewBox: "0 0 16 16", width: "16", height: "16", "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: "M3.5 3.5l9 9M12.5 3.5l-9 9", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }) }) })] }), children] }) })] }) }));
|
|
34
35
|
}
|
|
36
|
+
/* Slotted (UiKit.tsx): an App's control kit may draw its own in place of the default, with the same props. */
|
|
37
|
+
export const Drawer = slotted('Drawer', DefaultDrawer);
|
package/dist/DropMenu.d.ts
CHANGED
|
@@ -34,20 +34,20 @@ interface DropMenuProps {
|
|
|
34
34
|
finalFocus?: Menu.Popup.Props['finalFocus'];
|
|
35
35
|
children: ReactNode;
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
declare function DefaultDropMenu({ className, triggerClassName, triggerTitle, triggerLabel, label, popupClassName, side, align, sideOffset, open, onOpenChange, finalFocus, children, }: DropMenuProps): import("react").JSX.Element;
|
|
38
38
|
/** A labelled run of items: a menu that changes several things says which each item changes. */
|
|
39
|
-
|
|
39
|
+
declare function DefaultDropGroup({ className, labelClassName, label, children, }: {
|
|
40
40
|
className?: string;
|
|
41
41
|
labelClassName?: string;
|
|
42
42
|
label: string;
|
|
43
43
|
children: ReactNode;
|
|
44
44
|
}): import("react").JSX.Element;
|
|
45
45
|
/** A rule between two runs of items, a separator to a screen reader. */
|
|
46
|
-
|
|
46
|
+
declare function DefaultDropSeparator({ className }: {
|
|
47
47
|
className?: string;
|
|
48
48
|
}): import("react").JSX.Element;
|
|
49
49
|
/** An item drawn as a button, so `disabled` and the button styles hold. Closes the menu unless told not to. */
|
|
50
|
-
|
|
50
|
+
declare function DefaultDropItem({ className, disabled, closeOnClick, onClick, title, children, ref, }: {
|
|
51
51
|
className?: string;
|
|
52
52
|
disabled?: boolean;
|
|
53
53
|
closeOnClick?: boolean;
|
|
@@ -56,4 +56,8 @@ export declare function DropItem({ className, disabled, closeOnClick, onClick, t
|
|
|
56
56
|
children: ReactNode;
|
|
57
57
|
ref?: Ref<HTMLButtonElement>;
|
|
58
58
|
}): import("react").JSX.Element;
|
|
59
|
+
export declare const DropMenu: typeof DefaultDropMenu;
|
|
60
|
+
export declare const DropGroup: typeof DefaultDropGroup;
|
|
61
|
+
export declare const DropSeparator: typeof DefaultDropSeparator;
|
|
62
|
+
export declare const DropItem: typeof DefaultDropItem;
|
|
59
63
|
export {};
|
package/dist/DropMenu.js
CHANGED
|
@@ -18,7 +18,8 @@ import { Menu } from '@base-ui/react/menu';
|
|
|
18
18
|
import { layoutViewport, zoomAnchor } from './internal/anchor.js';
|
|
19
19
|
import { popupContainer } from './internal/popups.js';
|
|
20
20
|
import { buttonClass } from './Button.js';
|
|
21
|
-
|
|
21
|
+
import { slotted } from './internal/uiKitContext.js';
|
|
22
|
+
function DefaultDropMenu({ className, triggerClassName = buttonClass(), triggerTitle, triggerLabel, label, popupClassName = 'dd-list', side = 'bottom', align = 'end', sideOffset = 4, open, onOpenChange, finalFocus, children, }) {
|
|
22
23
|
const trigger = useRef(null);
|
|
23
24
|
/* Inside a dialog the popup is drawn into that dialog, so it shares its
|
|
24
25
|
stacking context rather than landing behind it; elsewhere it goes to
|
|
@@ -39,14 +40,19 @@ export function DropMenu({ className, triggerClassName = buttonClass(), triggerT
|
|
|
39
40
|
return (_jsx("div", { className: className || undefined, children: _jsxs(Menu.Root, { open: isOpen, onOpenChange: change, children: [_jsx(Menu.Trigger, { render: _jsx("button", { type: "button", className: triggerClassName, title: triggerTitle, "aria-label": triggerLabel, ref: trigger }), children: label }), _jsx(Menu.Portal, { container: container ?? popupContainer(), children: _jsx(Menu.Positioner, { anchor: () => (trigger.current ? zoomAnchor(trigger.current) : null), positionMethod: "fixed", side: side, align: align, sideOffset: sideOffset, collisionBoundary: layoutViewport(), collisionPadding: 8, style: { zIndex: 90 }, children: _jsx(Menu.Popup, { className: popupClassName, finalFocus: finalFocus, children: children }) }) })] }) }));
|
|
40
41
|
}
|
|
41
42
|
/** A labelled run of items: a menu that changes several things says which each item changes. */
|
|
42
|
-
|
|
43
|
+
function DefaultDropGroup({ className, labelClassName, label, children, }) {
|
|
43
44
|
return (_jsxs(Menu.Group, { className: className, children: [_jsx(Menu.GroupLabel, { className: labelClassName, children: label }), children] }));
|
|
44
45
|
}
|
|
45
46
|
/** A rule between two runs of items, a separator to a screen reader. */
|
|
46
|
-
|
|
47
|
+
function DefaultDropSeparator({ className = 'dd-divider' }) {
|
|
47
48
|
return _jsx(Menu.Separator, { className: className });
|
|
48
49
|
}
|
|
49
50
|
/** An item drawn as a button, so `disabled` and the button styles hold. Closes the menu unless told not to. */
|
|
50
|
-
|
|
51
|
+
function DefaultDropItem({ className = 'dd-option', disabled, closeOnClick, onClick, title, children, ref, }) {
|
|
51
52
|
return (_jsx(Menu.Item, { render: _jsx("button", { type: "button", className: className, title: title, ref: ref }), nativeButton: true, disabled: disabled, closeOnClick: closeOnClick, onClick: onClick, children: children }));
|
|
52
53
|
}
|
|
54
|
+
/* Slotted (UiKit.tsx): an App's control kit may draw its own in place of the default, with the same props. */
|
|
55
|
+
export const DropMenu = slotted('DropMenu', DefaultDropMenu);
|
|
56
|
+
export const DropGroup = slotted('DropGroup', DefaultDropGroup);
|
|
57
|
+
export const DropSeparator = slotted('DropSeparator', DefaultDropSeparator);
|
|
58
|
+
export const DropItem = slotted('DropItem', DefaultDropItem);
|
package/dist/Dropdown.d.ts
CHANGED
|
@@ -67,7 +67,9 @@ export interface DropdownAction {
|
|
|
67
67
|
label: string;
|
|
68
68
|
onSelect: () => void;
|
|
69
69
|
}
|
|
70
|
-
|
|
70
|
+
declare function DefaultDropdown(props: DropdownProps): import("react").JSX.Element;
|
|
71
71
|
/** The same listbox choosing several: it stays open while it is chosen from, and the button says the choices. */
|
|
72
|
-
|
|
72
|
+
declare function DefaultMultiDropdown(props: MultiDropdownProps): import("react").JSX.Element;
|
|
73
|
+
export declare const Dropdown: typeof DefaultDropdown;
|
|
74
|
+
export declare const MultiDropdown: typeof DefaultMultiDropdown;
|
|
73
75
|
export {};
|
package/dist/Dropdown.js
CHANGED
|
@@ -19,13 +19,14 @@ import { useEffect, useId, useRef, useState } from 'react';
|
|
|
19
19
|
import { Select } from '@base-ui/react/select';
|
|
20
20
|
import { layoutViewport, zoomAnchor } from './internal/anchor.js';
|
|
21
21
|
import { popupContainer } from './internal/popups.js';
|
|
22
|
+
import { slotted } from './internal/uiKitContext.js';
|
|
22
23
|
/* A value no option could carry, so an action's row is told apart from an option's. */
|
|
23
24
|
const ACTION = '~~action:';
|
|
24
|
-
|
|
25
|
+
function DefaultDropdown(props) {
|
|
25
26
|
return _jsx(DropdownList, { ...props });
|
|
26
27
|
}
|
|
27
28
|
/** The same listbox choosing several: it stays open while it is chosen from, and the button says the choices. */
|
|
28
|
-
|
|
29
|
+
function DefaultMultiDropdown(props) {
|
|
29
30
|
return _jsx(DropdownList, { ...props, multiple: true });
|
|
30
31
|
}
|
|
31
32
|
function DropdownList(props) {
|
|
@@ -88,3 +89,6 @@ function DropdownList(props) {
|
|
|
88
89
|
props.onChange(next);
|
|
89
90
|
}, children: [_jsxs(Select.Trigger, { render: _jsx("button", { type: "button", role: "button", id: buttonId, className: buttonClassName ? `dd-button ${buttonClassName}` : 'dd-button', ref: setTrigger, "aria-label": ariaLabelledBy ? undefined : ariaLabel, "aria-labelledby": ariaLabelledBy ?? (ariaLabel ? `${buttonId} ${valueId ?? shownId}` : undefined), "aria-invalid": ariaInvalid || undefined, "aria-describedby": ariaDescribedBy, title: selected?.detail ?? '' }), children: [selected?.swatches && (_jsx("span", { className: "dd-swatches", "aria-hidden": "true", children: selected.swatches.map((color, index) => (_jsx("span", { style: { background: color } }, index))) })), _jsx("span", { id: valueId ?? shownId, className: `dd-value${valueClassName ? ` ${valueClassName}` : ''}${said ? '' : ' is-empty'}`, children: said || placeholder || '—' }), _jsx("span", { className: "dd-caret", "aria-hidden": "true", children: "\u25BE" })] }), _jsx(Select.Portal, { container: container ?? popupContainer(), children: _jsx(Select.Positioner, { anchor: () => (trigger.current ? zoomAnchor(trigger.current) : null), alignItemWithTrigger: false, positionMethod: "fixed", side: "bottom", align: "start", sideOffset: 4, collisionBoundary: layoutViewport(), collisionPadding: 8, style: { zIndex: 40 }, children: _jsx(Select.Popup, { ref: popupRef, className: "dd-popup", children: _jsxs(Select.List, { className: ['dd-list', many ? 'dd-list-multi' : '', listClassName].filter(Boolean).join(' '), "aria-label": ariaLabel, "aria-labelledby": ariaLabel ? undefined : ariaLabelledBy?.split(' ')[0], children: [items.map((item) => (_jsxs(Select.Item, { value: item.value, label: item.label, disabled: item.disabled, className: (s) => `dd-option${s.selected ? ' selected' : ''}${item.disabled ? ' disabled' : ''}${item.tone ? ` dd-tone-${item.tone}` : ''}${s.highlighted ? ' active' : ''}`, children: [many ? (_jsx("span", { className: "dd-box", "aria-hidden": "true" })) : (_jsx("span", { className: "dd-check", "aria-hidden": "true", children: item.value === props.value ? '✓' : '' })), item.swatches && (_jsx("span", { className: "dd-swatches", "aria-hidden": "true", children: item.swatches.map((color, index) => (_jsx("span", { style: { background: color } }, index))) })), _jsxs("span", { className: "dd-text", children: [_jsx("span", { className: "dd-label", children: item.label }), item.detail && _jsx("span", { className: "dd-detail", children: item.detail })] }), item.badge && _jsx("span", { className: "dd-badge", children: item.badge })] }, item.value))), actions.length ? _jsx("div", { className: "dd-divider", role: "presentation" }) : null, actions.map((action, i) => (_jsxs(Select.Item, { value: `${ACTION}${i}`, label: action.label, className: (s) => `dd-option dd-action${s.highlighted ? ' active' : ''}`, children: [_jsx("span", { className: "dd-check", "aria-hidden": "true" }), _jsx("span", { className: "dd-text", children: _jsx("span", { className: "dd-label", children: action.label }) })] }, action.label)))] }) }) }) })] }) }));
|
|
90
91
|
}
|
|
92
|
+
/* Slotted (UiKit.tsx): an App's control kit may draw its own in place of the default, with the same props. */
|
|
93
|
+
export const Dropdown = slotted('Dropdown', DefaultDropdown);
|
|
94
|
+
export const MultiDropdown = slotted('MultiDropdown', DefaultMultiDropdown);
|
package/dist/Modal.d.ts
CHANGED
|
@@ -44,5 +44,6 @@ interface ModalProps {
|
|
|
44
44
|
fullscreen?: boolean | 'mobile';
|
|
45
45
|
ref?: Ref<ModalHandle>;
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
declare function DefaultModal({ className, onClose, closeDisabled, beforeClose, children, initialFocus, finalFocus, ariaLabel, plain, backdrop, fullscreen, ref, }: ModalProps): import("react").JSX.Element;
|
|
48
|
+
export declare const Modal: typeof DefaultModal;
|
|
48
49
|
export {};
|
package/dist/Modal.js
CHANGED
|
@@ -17,7 +17,8 @@ import { useCallback, useContext, useId, useImperativeHandle, useRef, useState }
|
|
|
17
17
|
import { ComponentStyleScope } from './internal/ComponentStyleScope.js';
|
|
18
18
|
import { Dialog } from '@base-ui/react/dialog';
|
|
19
19
|
import { popupContainer } from './internal/popups.js';
|
|
20
|
-
|
|
20
|
+
import { slotted } from './internal/uiKitContext.js';
|
|
21
|
+
function DefaultModal({ className = '', onClose, closeDisabled = false, beforeClose, children, initialFocus, finalFocus, ariaLabel, plain = false, backdrop = true, fullscreen = 'mobile', ref, }) {
|
|
21
22
|
const componentScope = useContext(ComponentStyleScope);
|
|
22
23
|
const [open, setOpen] = useState(true);
|
|
23
24
|
const closed = useRef(false);
|
|
@@ -55,3 +56,5 @@ export function Modal({ className = '', onClose, closeDisabled = false, beforeCl
|
|
|
55
56
|
details.cancel();
|
|
56
57
|
}, children: _jsxs(Dialog.Portal, { container: popupContainer(), children: [backdrop ? _jsx(Dialog.Backdrop, { className: plain ? scrim.replace('modal-backdrop ', '') : scrim }) : null, _jsx(Dialog.Popup, { "data-component": componentScope, className: `${plain ? className : `modal ${className}`.trim()}${size}`, initialFocus: initialFocus, ...(finalFocus ? { finalFocus } : {}), ref: popup, "aria-label": ariaLabel, "aria-labelledby": ariaLabel ? undefined : labelledBy, "aria-modal": "true", children: children })] }) }));
|
|
57
58
|
}
|
|
59
|
+
/* Slotted (UiKit.tsx): an App's control kit may draw its own in place of the default, with the same props. */
|
|
60
|
+
export const Modal = slotted('Modal', DefaultModal);
|
package/dist/Pagination.d.ts
CHANGED
|
@@ -29,5 +29,6 @@ interface PaginationWords {
|
|
|
29
29
|
}
|
|
30
30
|
/** The page numbers to draw: the first, the last, and a window of five around the current, with gaps as ellipses. */
|
|
31
31
|
export declare function paginationItems(page: number, pages: number): Array<number | '…'>;
|
|
32
|
-
|
|
32
|
+
declare function DefaultPagination({ page, pages, onPageChange, ariaLabel, words: given }: PaginationProps): import("react").JSX.Element | null;
|
|
33
|
+
export declare const Pagination: typeof DefaultPagination;
|
|
33
34
|
export {};
|
package/dist/Pagination.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { slotted } from './internal/uiKitContext.js';
|
|
2
3
|
/** The page numbers to draw: the first, the last, and a window of five around the current, with gaps as ellipses. */
|
|
3
4
|
export function paginationItems(page, pages) {
|
|
4
5
|
if (pages <= 7)
|
|
@@ -16,10 +17,12 @@ export function paginationItems(page, pages) {
|
|
|
16
17
|
}
|
|
17
18
|
return items;
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
+
function DefaultPagination({ page, pages, onPageChange, ariaLabel, words: given }) {
|
|
20
21
|
const words = { pages: 'Pages', previous: 'Previous', next: 'Next', ...given };
|
|
21
22
|
if (pages <= 1)
|
|
22
23
|
return null;
|
|
23
24
|
const current = Math.min(Math.max(page, 1), pages);
|
|
24
25
|
return (_jsxs("nav", { className: "ui-pagination", "aria-label": ariaLabel ?? words.pages, children: [_jsx("button", { type: "button", className: "ui-page ui-page-step", disabled: current === 1, onClick: () => onPageChange(current - 1), children: words.previous }), paginationItems(current, pages).map((item, i) => item === '…' ? (_jsx("span", { className: "ui-page-gap", "aria-hidden": "true", children: "\u2026" }, `gap-${i}`)) : (_jsx("button", { type: "button", className: "ui-page", "aria-current": item === current ? 'page' : undefined, onClick: () => onPageChange(item), children: item }, item))), _jsx("button", { type: "button", className: "ui-page ui-page-step", disabled: current === pages, onClick: () => onPageChange(current + 1), children: words.next })] }));
|
|
25
26
|
}
|
|
27
|
+
/* Slotted (UiKit.tsx): an App's control kit may draw its own in place of the default, with the same props. */
|
|
28
|
+
export const Pagination = slotted('Pagination', DefaultPagination);
|
package/dist/Popover.d.ts
CHANGED
|
@@ -23,4 +23,6 @@ export interface PopoverProps {
|
|
|
23
23
|
/** The popup's accessible name, where it needs one. */
|
|
24
24
|
ariaLabel?: string;
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
declare function DefaultPopover({ trigger, children, open, defaultOpen, onOpenChange, className, ariaLabel }: PopoverProps): import("react").JSX.Element;
|
|
27
|
+
export declare const Popover: typeof DefaultPopover;
|
|
28
|
+
export {};
|
package/dist/Popover.js
CHANGED
|
@@ -18,7 +18,8 @@ import { Popover as BasePopover } from '@base-ui/react/popover';
|
|
|
18
18
|
import { layoutViewport, zoomAnchor } from './internal/anchor.js';
|
|
19
19
|
import { ComponentStyleScope } from './internal/ComponentStyleScope.js';
|
|
20
20
|
import { popupContainer, useDialogContainer } from './internal/popups.js';
|
|
21
|
-
|
|
21
|
+
import { slotted } from './internal/uiKitContext.js';
|
|
22
|
+
function DefaultPopover({ trigger, children, open, defaultOpen, onOpenChange, className, ariaLabel }) {
|
|
22
23
|
/* The trigger is rendered as the trigger, not inside one: a button
|
|
23
24
|
passed as a child nested inside Base UI's own button, giving two
|
|
24
25
|
buttons for one control. The render prop merges onto the caller's
|
|
@@ -30,3 +31,5 @@ export function Popover({ trigger, children, open, defaultOpen, onOpenChange, cl
|
|
|
30
31
|
const componentScope = useContext(ComponentStyleScope);
|
|
31
32
|
return (_jsxs(BasePopover.Root, { open: open, defaultOpen: defaultOpen, onOpenChange: onOpenChange, children: [_jsx(BasePopover.Trigger, { className: "ui-popover-trigger", render: triggerElement, ref: anchor }), _jsx(BasePopover.Portal, { container: container ?? popupContainer(), children: _jsx(BasePopover.Positioner, { anchor: () => (anchor.current ? zoomAnchor(anchor.current) : null), positionMethod: "fixed", sideOffset: 8, collisionBoundary: layoutViewport(), collisionPadding: 8, children: _jsx(BasePopover.Popup, { "data-component": componentScope, className: ['ui-popover', className].filter(Boolean).join(' '), "aria-label": ariaLabel, children: children }) }) })] }));
|
|
32
33
|
}
|
|
34
|
+
/* Slotted (UiKit.tsx): an App's control kit may draw its own in place of the default, with the same props. */
|
|
35
|
+
export const Popover = slotted('Popover', DefaultPopover);
|
package/dist/Select.d.ts
CHANGED
|
@@ -14,13 +14,15 @@ interface ListFrame extends FieldFrame {
|
|
|
14
14
|
buttonRef?: Ref<HTMLButtonElement>;
|
|
15
15
|
}
|
|
16
16
|
/** One choice from a list, under a field box. */
|
|
17
|
-
|
|
17
|
+
declare function DefaultSelect(props: ListFrame & {
|
|
18
18
|
value: string;
|
|
19
19
|
onChange: (value: string) => void;
|
|
20
20
|
}): ReactNode;
|
|
21
21
|
/** Several choices, each with a checkbox; the closed box says them as "Acura, Alfa Romeo". */
|
|
22
|
-
|
|
22
|
+
declare function DefaultMultiSelect(props: ListFrame & {
|
|
23
23
|
value: string[];
|
|
24
24
|
onChange: (value: string[]) => void;
|
|
25
25
|
}): ReactNode;
|
|
26
|
+
export declare const Select: typeof DefaultSelect;
|
|
27
|
+
export declare const MultiSelect: typeof DefaultMultiSelect;
|
|
26
28
|
export {};
|
package/dist/Select.js
CHANGED
|
@@ -8,13 +8,17 @@ import { useId } from 'react';
|
|
|
8
8
|
import { Dropdown, MultiDropdown } from './Dropdown.js';
|
|
9
9
|
import { Field } from './Field.js';
|
|
10
10
|
import { frameOf } from './fieldFrame.js';
|
|
11
|
+
import { slotted } from './internal/uiKitContext.js';
|
|
11
12
|
/** One choice from a list, under a field box. */
|
|
12
|
-
|
|
13
|
+
function DefaultSelect(props) {
|
|
13
14
|
const valueId = useId();
|
|
14
15
|
return (_jsx(Field, { ...frameOf(props), group: true, children: (control) => (_jsx(Dropdown, { items: props.options, value: props.value, onChange: props.onChange, id: control.id, ariaLabelledBy: `${control['aria-labelledby']} ${valueId}`, ariaDescribedBy: control['aria-describedby'], ariaInvalid: control['aria-invalid'], valueId: valueId, buttonClassName: "field-control field-select", listClassName: "field-list", buttonRef: props.buttonRef, placeholder: props.placeholder, disabled: props.disabled })) }));
|
|
15
16
|
}
|
|
16
17
|
/** Several choices, each with a checkbox; the closed box says them as "Acura, Alfa Romeo". */
|
|
17
|
-
|
|
18
|
+
function DefaultMultiSelect(props) {
|
|
18
19
|
const valueId = useId();
|
|
19
20
|
return (_jsx(Field, { ...frameOf(props), group: true, children: (control) => (_jsx(MultiDropdown, { items: props.options, value: props.value, onChange: props.onChange, id: control.id, ariaLabelledBy: `${control['aria-labelledby']} ${valueId}`, ariaDescribedBy: control['aria-describedby'], ariaInvalid: control['aria-invalid'], valueId: valueId, buttonClassName: "field-control field-select", listClassName: "field-list", buttonRef: props.buttonRef, placeholder: props.placeholder, disabled: props.disabled })) }));
|
|
20
21
|
}
|
|
22
|
+
/* Slotted (UiKit.tsx): an App's control kit may draw its own in place of the default, with the same props. */
|
|
23
|
+
export const Select = slotted('Select', DefaultSelect);
|
|
24
|
+
export const MultiSelect = slotted('MultiSelect', DefaultMultiSelect);
|
package/dist/SensitiveField.d.ts
CHANGED
|
@@ -23,4 +23,6 @@ export interface SensitiveFieldProps extends FieldFrame {
|
|
|
23
23
|
showLabel: string;
|
|
24
24
|
hideLabel: string;
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
declare function DefaultSensitiveField(props: SensitiveFieldProps): ReactNode;
|
|
27
|
+
export declare const SensitiveField: typeof DefaultSensitiveField;
|
|
28
|
+
export {};
|
package/dist/SensitiveField.js
CHANGED
|
@@ -12,7 +12,8 @@ import { Field } from './Field.js';
|
|
|
12
12
|
import { frameOf } from './fieldFrame.js';
|
|
13
13
|
import { digits } from './masks.js';
|
|
14
14
|
import { ValidMark } from './TextField.js';
|
|
15
|
-
|
|
15
|
+
import { slotted } from './internal/uiKitContext.js';
|
|
16
|
+
function DefaultSensitiveField(props) {
|
|
16
17
|
const [shown, setShown] = useState(false);
|
|
17
18
|
const formatted = props.mask.format(props.value);
|
|
18
19
|
const display = shown ? formatted : '•'.repeat(formatted.length);
|
|
@@ -25,3 +26,5 @@ export function SensitiveField(props) {
|
|
|
25
26
|
};
|
|
26
27
|
return (_jsx(Field, { ...frameOf(props), children: (control) => (_jsxs(_Fragment, { children: [_jsxs("div", { className: "field-with-action", children: [_jsxs("div", { className: `field-box${props.valid === undefined ? '' : ' has-mark'}`, children: [_jsx("input", { ...control, className: `field-control${shown ? '' : ' field-hidden'}`, value: display, inputMode: props.mask.inputMode ?? 'numeric', autoComplete: "off", autoCorrect: "off", autoCapitalize: "off", spellCheck: false, "data-1p-ignore": true, "data-lpignore": "true", onChange: (e) => change(e.target.value), onBlur: props.onBlur }), props.valid ? _jsx(ValidMark, { icon: props.validIcon }) : null] }), _jsx(Button, { intent: "quiet", onClick: () => setShown(!shown), children: shown ? props.hideLabel : props.showLabel })] }), props.note ? (_jsxs("p", { className: "field-note", children: [props.noteIcon, props.note] })) : null] })) }));
|
|
27
28
|
}
|
|
29
|
+
/* Slotted (UiKit.tsx): an App's control kit may draw its own in place of the default, with the same props. */
|
|
30
|
+
export const SensitiveField = slotted('SensitiveField', DefaultSensitiveField);
|
package/dist/Slider.d.ts
CHANGED
|
@@ -14,4 +14,6 @@ export interface SliderProps extends FieldFrame {
|
|
|
14
14
|
format?: (n: number) => string;
|
|
15
15
|
disabled?: boolean;
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
declare function DefaultSlider(props: SliderProps): ReactNode;
|
|
18
|
+
export declare const Slider: typeof DefaultSlider;
|
|
19
|
+
export {};
|
package/dist/Slider.js
CHANGED
|
@@ -2,9 +2,12 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { Field } from './Field.js';
|
|
3
3
|
import { frameOf } from './fieldFrame.js';
|
|
4
4
|
import { grouped } from './masks.js';
|
|
5
|
-
|
|
5
|
+
import { slotted } from './internal/uiKitContext.js';
|
|
6
|
+
function DefaultSlider(props) {
|
|
6
7
|
const say = props.format ?? grouped;
|
|
7
8
|
const span = props.max - props.min;
|
|
8
9
|
const share = span > 0 ? ((props.value - props.min) / span) * 100 : 0;
|
|
9
10
|
return (_jsx(Field, { ...frameOf(props), children: (control) => (_jsxs(_Fragment, { children: [_jsx("div", { className: "field-control field-readout", "aria-hidden": "true", children: say(props.value) }), _jsx("input", { ...control, type: "range", className: "field-range", min: props.min, max: props.max, step: props.step, value: props.value, disabled: props.disabled, "aria-valuetext": say(props.value), style: { '--range-share': `${share}%` }, onChange: (e) => props.onChange(Number(e.target.value)) }), _jsxs("div", { className: "field-range-ends", "aria-hidden": "true", children: [_jsx("span", { children: say(props.min) }), _jsx("span", { children: say(props.max) })] })] })) }));
|
|
10
11
|
}
|
|
12
|
+
/* Slotted (UiKit.tsx): an App's control kit may draw its own in place of the default, with the same props. */
|
|
13
|
+
export const Slider = slotted('Slider', DefaultSlider);
|
package/dist/Switch.d.ts
CHANGED
|
@@ -25,4 +25,6 @@ export interface SwitchProps {
|
|
|
25
25
|
className?: string;
|
|
26
26
|
ref?: Ref<HTMLButtonElement>;
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
declare function DefaultSwitch({ label, description, checked, defaultChecked, onCheckedChange, disabled, busy, id, className, ref, }: SwitchProps): import("react").JSX.Element;
|
|
29
|
+
export declare const Switch: typeof DefaultSwitch;
|
|
30
|
+
export {};
|
package/dist/Switch.js
CHANGED
|
@@ -11,7 +11,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
11
11
|
*/
|
|
12
12
|
import { useId } from 'react';
|
|
13
13
|
import { Switch as BaseSwitch } from '@base-ui/react/switch';
|
|
14
|
-
|
|
14
|
+
import { slotted } from './internal/uiKitContext.js';
|
|
15
|
+
function DefaultSwitch({ label, description, checked, defaultChecked, onCheckedChange, disabled = false, busy = false, id, className, ref, }) {
|
|
15
16
|
/* The label names the switch by its id; a caller who gives none gets
|
|
16
17
|
a generated one, never Base UI's own, which the label cannot know. */
|
|
17
18
|
const generatedId = useId();
|
|
@@ -22,3 +23,5 @@ export function Switch({ label, description, checked, defaultChecked, onCheckedC
|
|
|
22
23
|
onCheckedChange?.(next, event);
|
|
23
24
|
}, children: _jsx(BaseSwitch.Thumb, { className: "ui-switch-thumb" }) }), label !== undefined || description !== undefined ? (_jsxs("span", { className: "ui-switch-copy", children: [label !== undefined ? (_jsx("label", { htmlFor: switchId, className: "ui-switch-label", children: label })) : null, description !== undefined ? _jsx("span", { className: "ui-switch-description", children: description }) : null] })) : null] }));
|
|
24
25
|
}
|
|
26
|
+
/* Slotted (UiKit.tsx): an App's control kit may draw its own in place of the default, with the same props. */
|
|
27
|
+
export const Switch = slotted('Switch', DefaultSwitch);
|
package/dist/Tabs.d.ts
CHANGED
|
@@ -22,4 +22,6 @@ export interface TabsProps {
|
|
|
22
22
|
/** The tablist's accessible name, where the tabs need one ("Settings sections"). */
|
|
23
23
|
ariaLabel?: string;
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
declare function DefaultTabs({ tabs, value, defaultValue, onValueChange, className, ariaLabel }: TabsProps): import("react").JSX.Element;
|
|
26
|
+
export declare const Tabs: typeof DefaultTabs;
|
|
27
|
+
export {};
|
package/dist/Tabs.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Tabs as BaseTabs } from '@base-ui/react/tabs';
|
|
3
|
-
|
|
3
|
+
import { slotted } from './internal/uiKitContext.js';
|
|
4
|
+
function DefaultTabs({ tabs, value, defaultValue, onValueChange, className, ariaLabel }) {
|
|
4
5
|
return (_jsxs(BaseTabs.Root, { className: ['ui-tabs', className].filter(Boolean).join(' '), value: value, defaultValue: defaultValue ?? tabs.find((tab) => !tab.disabled)?.value, onValueChange: onValueChange, children: [_jsx(BaseTabs.List, { className: "ui-tabs-list", "aria-label": ariaLabel, children: tabs.map((tab) => (_jsx(BaseTabs.Tab, { className: "ui-tab", value: tab.value, disabled: tab.disabled, children: tab.label }, tab.value))) }), tabs.map((tab) => (_jsx(BaseTabs.Panel, { className: "ui-tab-panel", value: tab.value, children: tab.children }, tab.value)))] }));
|
|
5
6
|
}
|
|
7
|
+
/* Slotted (UiKit.tsx): an App's control kit may draw its own in place of the default, with the same props. */
|
|
8
|
+
export const Tabs = slotted('Tabs', DefaultTabs);
|