@crisp-ui-kit/crisp 0.23.1 → 0.23.3
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/cjs/components/accordion/accordion.js +8 -2
- package/dist/cjs/components/datatable/datatable.js +15 -1
- package/dist/cjs/components/datepicker/datepicker.js +4 -2
- package/dist/cjs/components/tabs/tabs.js +8 -2
- package/dist/cjs/product/recordstable/recordstable.js +5 -1
- package/dist/esm/components/accordion/accordion.js +8 -2
- package/dist/esm/components/datatable/datatable.js +15 -1
- package/dist/esm/components/datepicker/datepicker.js +4 -2
- package/dist/esm/components/tabs/tabs.js +8 -2
- package/dist/esm/product/recordstable/recordstable.js +5 -1
- package/package.json +1 -1
|
@@ -45,6 +45,7 @@ const accordion_recipe_1 = require("./accordion.recipe");
|
|
|
45
45
|
*/
|
|
46
46
|
const toSet = (v) => new Set(v == null ? [] : Array.isArray(v) ? v : [v]);
|
|
47
47
|
function Accordion({ items, multiple, value, defaultValue, onValueChange, className, ...rest }) {
|
|
48
|
+
const uid = React.useId();
|
|
48
49
|
const [internal, setInternal] = React.useState(() => toSet(defaultValue));
|
|
49
50
|
// `value` present means the caller owns the open set; our own state is then
|
|
50
51
|
// never read, so a click can only change what is shown by going through
|
|
@@ -62,8 +63,13 @@ function Accordion({ items, multiple, value, defaultValue, onValueChange, classN
|
|
|
62
63
|
};
|
|
63
64
|
return ((0, jsx_runtime_1.jsx)("div", { className: (0, accordion_recipe_1.accordionRecipe)({ className }), ...rest, children: items.map((item) => {
|
|
64
65
|
const isOpen = open.has(item.value);
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
// Scoped to this instance. `accordion-panel-${value}` is global, so two
|
|
67
|
+
// accordions with an item of the same value on one page mint the same
|
|
68
|
+
// id twice — and getElementById returns the first, so the second
|
|
69
|
+
// accordion's triggers silently control the first one's panels (#227).
|
|
70
|
+
const panelId = `${uid}-panel-${item.value}`;
|
|
71
|
+
const triggerId = `${uid}-trigger-${item.value}`;
|
|
72
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "accordion-item", children: [(0, jsx_runtime_1.jsxs)("button", { type: "button", id: triggerId, className: "accordion-trigger", "aria-expanded": isOpen, "aria-controls": panelId, onClick: () => toggle(item.value), children: [(0, jsx_runtime_1.jsx)("span", { className: "accordion-title", children: item.title }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronDown, { className: "accordion-chevron", size: 16, strokeWidth: 1.75, "aria-hidden": "true" })] }), (0, jsx_runtime_1.jsx)("div", { id: panelId, className: "accordion-panel", role: "region", "aria-labelledby": triggerId, "data-open": isOpen ? "" : undefined, hidden: !isOpen, children: (0, jsx_runtime_1.jsx)("div", { className: "accordion-panel-inner", children: (0, jsx_runtime_1.jsx)("div", { className: "accordion-content", children: item.content }) }) })] }, item.value));
|
|
67
73
|
}) }));
|
|
68
74
|
}
|
|
69
75
|
Accordion.displayName = "Accordion";
|
|
@@ -452,8 +452,22 @@ function DataTable({ columns: columnsProp, data, selectable = false, selectedIds
|
|
|
452
452
|
...(scrolledX ? { "data-scrolled-x": "" } : {}),
|
|
453
453
|
}, children: [(0, jsx_runtime_1.jsxs)("colgroup", { children: [showGrip && (0, jsx_runtime_1.jsx)("col", { style: { width: GRIP_W } }), selectable && (0, jsx_runtime_1.jsx)("col", { style: { width: CHECK_W } }), columns.map((col) => ((0, jsx_runtime_1.jsx)("col", { style: { width: colWidth(col) } }, col.key)))] }), (0, jsx_runtime_1.jsx)(table_1.TableHeader, { children: (0, jsx_runtime_1.jsxs)(table_1.TableRow, { children: [showGrip && ((0, jsx_runtime_1.jsx)(table_1.TableHead, { className: "datatable-col-grip", ...stickyCol(-2) })), selectable && ((0, jsx_runtime_1.jsx)(table_1.TableHead, { className: "datatable-col-check", ...stickyCol(-1), children: (0, jsx_runtime_1.jsx)("span", { className: "datatable-check", children: (0, jsx_runtime_1.jsx)(checkbox_1.Checkbox, { "aria-label": selectAllLabel, checked: allSelected, indeterminate: someSelected, onChange: toggleAll }) }) })), columns.map((col, i) => {
|
|
454
454
|
const Icon = col.icon;
|
|
455
|
+
// The sort direction was painted (`data-sorted`) and never
|
|
456
|
+
// announced: a screen reader heard the same header before and
|
|
457
|
+
// after sorting (#229). Only the PRIMARY sort is exposed —
|
|
458
|
+
// aria-sort is specified as one header per table, and with the
|
|
459
|
+
// multi-sort the `sort` prop allows, a second "ascending" says
|
|
460
|
+
// nothing about which column came first.
|
|
461
|
+
const sortable = col.sortable || !!columnMenu;
|
|
462
|
+
const ariaSort = !sortable
|
|
463
|
+
? undefined
|
|
464
|
+
: sorts[0]?.key === col.key
|
|
465
|
+
? sorts[0].dir === "asc"
|
|
466
|
+
? "ascending"
|
|
467
|
+
: "descending"
|
|
468
|
+
: "none";
|
|
455
469
|
const inner = ((0, jsx_runtime_1.jsxs)("span", { className: "datatable-th-inner", children: [Icon ? (0, jsx_runtime_1.jsx)(Icon, { size: 14, strokeWidth: 1.75 }) : null, (0, jsx_runtime_1.jsx)("span", { className: "datatable-th-label", children: col.header }), col.sortable ? (0, jsx_runtime_1.jsx)(ChevronFor, { colKey: col.key }) : null] }));
|
|
456
|
-
return ((0, jsx_runtime_1.jsxs)(table_1.TableHead, { align: alignFor(col), ...stickyCol(i), children: [renaming === col.key ? ((0, jsx_runtime_1.jsx)("input", {
|
|
470
|
+
return ((0, jsx_runtime_1.jsxs)(table_1.TableHead, { align: alignFor(col), "aria-sort": ariaSort, ...stickyCol(i), children: [renaming === col.key ? ((0, jsx_runtime_1.jsx)("input", {
|
|
457
471
|
// biome-ignore lint/a11y/noAutofocus: the rename item opens this field
|
|
458
472
|
autoFocus: true, className: "datatable-th-rename", defaultValue: typeof col.header === "string" ? col.header : "", "aria-label": `Rename column`, onBlur: (e) => {
|
|
459
473
|
renameColumn(col.key, e.currentTarget.value);
|
|
@@ -60,7 +60,9 @@ function Header({ api }) {
|
|
|
60
60
|
// in RTL the chevrons swap: "previous" is on the right
|
|
61
61
|
const previousDirection = api.isRtl ? "right" : "left";
|
|
62
62
|
const nextDirection = api.isRtl ? "left" : "right";
|
|
63
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "datepicker-header", children: [(0, jsx_runtime_1.jsxs)("button", { ...api.monthYearButtonProps,
|
|
63
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "datepicker-header", children: [(0, jsx_runtime_1.jsxs)("button", { ...api.monthYearButtonProps, "aria-controls": api.isWheelOpen
|
|
64
|
+
? api.monthYearButtonProps["aria-controls"]
|
|
65
|
+
: undefined, type: "button", id: `${api.rootProps.id}-header-label`, className: "datepicker-header-label", children: [(0, jsx_runtime_1.jsx)("span", { "data-date-picker-header-label": "", children: api.headerLabel }), (0, jsx_runtime_1.jsx)("span", { className: "datepicker-header-chevron", "data-open": api.isWheelOpen ? "" : undefined, children: (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronDown, { size: 16, strokeWidth: 1.75, "aria-hidden": "true" }) })] }), (0, jsx_runtime_1.jsxs)("div", { className: "datepicker-nav", children: [(0, jsx_runtime_1.jsx)(NavigationButton, { ...api.previousButtonProps, direction: previousDirection, className: "datepicker-nav-button" }), (0, jsx_runtime_1.jsx)(NavigationButton, { ...api.nextButtonProps, direction: nextDirection, className: "datepicker-nav-button" })] })] }));
|
|
64
66
|
}
|
|
65
67
|
function TwoMonthHeader({ api, label, labelId, position, }) {
|
|
66
68
|
const isFirst = position === "first";
|
|
@@ -83,7 +85,7 @@ function MonthView({ api, month, renderDateCellContent, renderDateCellSupplement
|
|
|
83
85
|
: labelId, className: "datepicker-grid", children: [showWeekdays && (0, jsx_runtime_1.jsx)(WeekdayRow, { api: api }), month.weeks.map((week) => ((0, jsx_runtime_1.jsx)("div", { role: "row", className: "datepicker-week-row", children: week.cells.map((cell, index) => ((0, jsx_runtime_1.jsx)(DateCellView, { cell: cell, renderDateCellContent: renderDateCellContent, renderDateCellSupplement: renderDateCellSupplement }, cell?.key ?? `${week.key}-empty-${index}`))) }, week.key)))] })] }));
|
|
84
86
|
}
|
|
85
87
|
function WheelView({ api }) {
|
|
86
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: "datepicker-wheel-container", children: (0, jsx_runtime_1.jsx)(wheelpicker_1.WheelPicker, { className: "datepicker-wheel", "aria-label": api.headerLabel, columns: [
|
|
88
|
+
return ((0, jsx_runtime_1.jsx)("div", { ...api.wheelProps, className: "datepicker-wheel-container", children: (0, jsx_runtime_1.jsx)(wheelpicker_1.WheelPicker, { className: "datepicker-wheel", "aria-label": api.headerLabel, columns: [
|
|
87
89
|
{
|
|
88
90
|
key: "year",
|
|
89
91
|
label: api.ariaLabels.yearWheel,
|
|
@@ -45,6 +45,12 @@ const tabs_keyboard_1 = require("./tabs-keyboard");
|
|
|
45
45
|
* `value`/`onValueChange`, or uncontrolled from `defaultValue`.
|
|
46
46
|
*/
|
|
47
47
|
function Tabs({ tabs, value, defaultValue, onValueChange, leading, children, className, "aria-label": ariaLabel, ...rest }) {
|
|
48
|
+
// Scoped to this instance: `tab-${value}` and `panel-${value}` are global,
|
|
49
|
+
// so two tab bars sharing a value mint the same id twice and every
|
|
50
|
+
// aria-labelledby resolves to the first one (#227).
|
|
51
|
+
const uid = React.useId();
|
|
52
|
+
const tabId = (v) => `${uid}-tab-${v}`;
|
|
53
|
+
const panelId = (v) => `${uid}-panel-${v}`;
|
|
48
54
|
const [internal, setInternal] = React.useState(defaultValue ?? tabs[0]?.value);
|
|
49
55
|
const active = value ?? internal;
|
|
50
56
|
const listRef = React.useRef(null);
|
|
@@ -79,11 +85,11 @@ function Tabs({ tabs, value, defaultValue, onValueChange, leading, children, cla
|
|
|
79
85
|
});
|
|
80
86
|
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, tabs_recipe_1.tabsRecipe)({ className }), ...rest, children: [(0, jsx_runtime_1.jsxs)("div", { ref: listRef, className: "tabs-list", role: "tablist", "aria-label": ariaLabel, onKeyDown: onKeyDown, children: [leading && (0, jsx_runtime_1.jsx)("span", { className: "tabs-leading", children: leading }), tabs.map((t) => {
|
|
81
87
|
const selected = t.value === active;
|
|
82
|
-
return ((0, jsx_runtime_1.jsxs)("button", { type: "button", role: "tab", id:
|
|
88
|
+
return ((0, jsx_runtime_1.jsxs)("button", { type: "button", role: "tab", id: tabId(t.value), "aria-selected": selected, "aria-controls": children && selected ? panelId(t.value) : undefined, tabIndex: tabIndexFor(t.value), "data-value": t.value, "data-selected": selected ? "" : undefined, disabled: t.disabled, className: "tabs-tab", onClick: () => select(t.value), children: [t.icon, (0, jsx_runtime_1.jsx)("span", { className: "tabs-tab-label", children: t.label }), t.badge != null && ((0, jsx_runtime_1.jsx)("span", { className: "tabs-tab-badge", children: t.badge }))] }, t.value));
|
|
83
89
|
}), indicator && ((0, jsx_runtime_1.jsx)("span", { className: "tabs-indicator", style: {
|
|
84
90
|
width: indicator.width,
|
|
85
91
|
transform: `translateX(${indicator.left}px)`,
|
|
86
|
-
} }))] }), children && ((0, jsx_runtime_1.jsx)("div", { className: "tabs-panel", role: "tabpanel", id:
|
|
92
|
+
} }))] }), children && ((0, jsx_runtime_1.jsx)("div", { className: "tabs-panel", role: "tabpanel", id: panelId(active), "aria-labelledby": tabId(active),
|
|
87
93
|
// biome-ignore lint/a11y/noNoninteractiveTabindex: a tabpanel is focusable per the WAI-ARIA tabs pattern
|
|
88
94
|
tabIndex: 0, children: children(active) }))] }));
|
|
89
95
|
}
|
|
@@ -1002,7 +1002,11 @@ function RecordsTable({ labels, columns: columnsProp = exports.defaultColumns, r
|
|
|
1002
1002
|
}, children: [(0, jsx_runtime_1.jsxs)("colgroup", { children: [(0, jsx_runtime_1.jsx)("col", { style: { width: CHECK_W } }), cols.map((col) => ((0, jsx_runtime_1.jsx)("col", { style: { width: colWidth(col) } }, col.key))), (0, jsx_runtime_1.jsx)("col", {})] }), (0, jsx_runtime_1.jsx)("thead", { children: (0, jsx_runtime_1.jsxs)("tr", { children: [(0, jsx_runtime_1.jsx)("th", { className: "recordstable-th recordstable-col-check", children: (0, jsx_runtime_1.jsx)("span", { className: "recordstable-check-inner", children: (0, jsx_runtime_1.jsx)(checkbox_1.Checkbox, { "aria-label": t.selectAll, checked: allSelected, indeterminate: someSelected, onChange: toggleAll }) }) }), cols.map((col, i) => {
|
|
1003
1003
|
const Icon = col.icon;
|
|
1004
1004
|
const sc = sorts.find((s) => s.key === col.key);
|
|
1005
|
-
return ((0, jsx_runtime_1.jsxs)("th", { className: `recordstable-th${i === 0 ? " recordstable-col-entity" : ""}`, "data-sorted": sc?.dir, "
|
|
1005
|
+
return ((0, jsx_runtime_1.jsxs)("th", { className: `recordstable-th${i === 0 ? " recordstable-col-entity" : ""}`, "data-sorted": sc?.dir, "aria-sort": sorts[0]?.key === col.key
|
|
1006
|
+
? sorts[0].dir === "asc"
|
|
1007
|
+
? "ascending"
|
|
1008
|
+
: "descending"
|
|
1009
|
+
: "none", "data-drop": dragCol && dragCol !== col.key && i >= 1 ? "" : undefined, onDragOver: dragCol && i >= 1 ? (e) => e.preventDefault() : undefined, onDrop: dragCol && i >= 1
|
|
1006
1010
|
? (e) => {
|
|
1007
1011
|
e.preventDefault();
|
|
1008
1012
|
reorderColumn(dragCol, col.key);
|
|
@@ -9,6 +9,7 @@ import { accordionRecipe } from "./accordion.recipe.js";
|
|
|
9
9
|
*/
|
|
10
10
|
const toSet = (v) => new Set(v == null ? [] : Array.isArray(v) ? v : [v]);
|
|
11
11
|
export function Accordion({ items, multiple, value, defaultValue, onValueChange, className, ...rest }) {
|
|
12
|
+
const uid = React.useId();
|
|
12
13
|
const [internal, setInternal] = React.useState(() => toSet(defaultValue));
|
|
13
14
|
// `value` present means the caller owns the open set; our own state is then
|
|
14
15
|
// never read, so a click can only change what is shown by going through
|
|
@@ -26,8 +27,13 @@ export function Accordion({ items, multiple, value, defaultValue, onValueChange,
|
|
|
26
27
|
};
|
|
27
28
|
return (_jsx("div", { className: accordionRecipe({ className }), ...rest, children: items.map((item) => {
|
|
28
29
|
const isOpen = open.has(item.value);
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
// Scoped to this instance. `accordion-panel-${value}` is global, so two
|
|
31
|
+
// accordions with an item of the same value on one page mint the same
|
|
32
|
+
// id twice — and getElementById returns the first, so the second
|
|
33
|
+
// accordion's triggers silently control the first one's panels (#227).
|
|
34
|
+
const panelId = `${uid}-panel-${item.value}`;
|
|
35
|
+
const triggerId = `${uid}-trigger-${item.value}`;
|
|
36
|
+
return (_jsxs("div", { className: "accordion-item", children: [_jsxs("button", { type: "button", id: triggerId, className: "accordion-trigger", "aria-expanded": isOpen, "aria-controls": panelId, onClick: () => toggle(item.value), children: [_jsx("span", { className: "accordion-title", children: item.title }), _jsx(ChevronDown, { className: "accordion-chevron", size: 16, strokeWidth: 1.75, "aria-hidden": "true" })] }), _jsx("div", { id: panelId, className: "accordion-panel", role: "region", "aria-labelledby": triggerId, "data-open": isOpen ? "" : undefined, hidden: !isOpen, children: _jsx("div", { className: "accordion-panel-inner", children: _jsx("div", { className: "accordion-content", children: item.content }) }) })] }, item.value));
|
|
31
37
|
}) }));
|
|
32
38
|
}
|
|
33
39
|
Accordion.displayName = "Accordion";
|
|
@@ -416,8 +416,22 @@ export function DataTable({ columns: columnsProp, data, selectable = false, sele
|
|
|
416
416
|
...(scrolledX ? { "data-scrolled-x": "" } : {}),
|
|
417
417
|
}, children: [_jsxs("colgroup", { children: [showGrip && _jsx("col", { style: { width: GRIP_W } }), selectable && _jsx("col", { style: { width: CHECK_W } }), columns.map((col) => (_jsx("col", { style: { width: colWidth(col) } }, col.key)))] }), _jsx(TableHeader, { children: _jsxs(TableRow, { children: [showGrip && (_jsx(TableHead, { className: "datatable-col-grip", ...stickyCol(-2) })), selectable && (_jsx(TableHead, { className: "datatable-col-check", ...stickyCol(-1), children: _jsx("span", { className: "datatable-check", children: _jsx(Checkbox, { "aria-label": selectAllLabel, checked: allSelected, indeterminate: someSelected, onChange: toggleAll }) }) })), columns.map((col, i) => {
|
|
418
418
|
const Icon = col.icon;
|
|
419
|
+
// The sort direction was painted (`data-sorted`) and never
|
|
420
|
+
// announced: a screen reader heard the same header before and
|
|
421
|
+
// after sorting (#229). Only the PRIMARY sort is exposed —
|
|
422
|
+
// aria-sort is specified as one header per table, and with the
|
|
423
|
+
// multi-sort the `sort` prop allows, a second "ascending" says
|
|
424
|
+
// nothing about which column came first.
|
|
425
|
+
const sortable = col.sortable || !!columnMenu;
|
|
426
|
+
const ariaSort = !sortable
|
|
427
|
+
? undefined
|
|
428
|
+
: sorts[0]?.key === col.key
|
|
429
|
+
? sorts[0].dir === "asc"
|
|
430
|
+
? "ascending"
|
|
431
|
+
: "descending"
|
|
432
|
+
: "none";
|
|
419
433
|
const inner = (_jsxs("span", { className: "datatable-th-inner", children: [Icon ? _jsx(Icon, { size: 14, strokeWidth: 1.75 }) : null, _jsx("span", { className: "datatable-th-label", children: col.header }), col.sortable ? _jsx(ChevronFor, { colKey: col.key }) : null] }));
|
|
420
|
-
return (_jsxs(TableHead, { align: alignFor(col), ...stickyCol(i), children: [renaming === col.key ? (_jsx("input", {
|
|
434
|
+
return (_jsxs(TableHead, { align: alignFor(col), "aria-sort": ariaSort, ...stickyCol(i), children: [renaming === col.key ? (_jsx("input", {
|
|
421
435
|
// biome-ignore lint/a11y/noAutofocus: the rename item opens this field
|
|
422
436
|
autoFocus: true, className: "datatable-th-rename", defaultValue: typeof col.header === "string" ? col.header : "", "aria-label": `Rename column`, onBlur: (e) => {
|
|
423
437
|
renameColumn(col.key, e.currentTarget.value);
|
|
@@ -24,7 +24,9 @@ function Header({ api }) {
|
|
|
24
24
|
// in RTL the chevrons swap: "previous" is on the right
|
|
25
25
|
const previousDirection = api.isRtl ? "right" : "left";
|
|
26
26
|
const nextDirection = api.isRtl ? "left" : "right";
|
|
27
|
-
return (_jsxs("div", { className: "datepicker-header", children: [_jsxs("button", { ...api.monthYearButtonProps,
|
|
27
|
+
return (_jsxs("div", { className: "datepicker-header", children: [_jsxs("button", { ...api.monthYearButtonProps, "aria-controls": api.isWheelOpen
|
|
28
|
+
? api.monthYearButtonProps["aria-controls"]
|
|
29
|
+
: undefined, type: "button", id: `${api.rootProps.id}-header-label`, className: "datepicker-header-label", children: [_jsx("span", { "data-date-picker-header-label": "", children: api.headerLabel }), _jsx("span", { className: "datepicker-header-chevron", "data-open": api.isWheelOpen ? "" : undefined, children: _jsx(ChevronDown, { size: 16, strokeWidth: 1.75, "aria-hidden": "true" }) })] }), _jsxs("div", { className: "datepicker-nav", children: [_jsx(NavigationButton, { ...api.previousButtonProps, direction: previousDirection, className: "datepicker-nav-button" }), _jsx(NavigationButton, { ...api.nextButtonProps, direction: nextDirection, className: "datepicker-nav-button" })] })] }));
|
|
28
30
|
}
|
|
29
31
|
function TwoMonthHeader({ api, label, labelId, position, }) {
|
|
30
32
|
const isFirst = position === "first";
|
|
@@ -47,7 +49,7 @@ function MonthView({ api, month, renderDateCellContent, renderDateCellSupplement
|
|
|
47
49
|
: labelId, className: "datepicker-grid", children: [showWeekdays && _jsx(WeekdayRow, { api: api }), month.weeks.map((week) => (_jsx("div", { role: "row", className: "datepicker-week-row", children: week.cells.map((cell, index) => (_jsx(DateCellView, { cell: cell, renderDateCellContent: renderDateCellContent, renderDateCellSupplement: renderDateCellSupplement }, cell?.key ?? `${week.key}-empty-${index}`))) }, week.key)))] })] }));
|
|
48
50
|
}
|
|
49
51
|
function WheelView({ api }) {
|
|
50
|
-
return (_jsx("div", { className: "datepicker-wheel-container", children: _jsx(WheelPicker, { className: "datepicker-wheel", "aria-label": api.headerLabel, columns: [
|
|
52
|
+
return (_jsx("div", { ...api.wheelProps, className: "datepicker-wheel-container", children: _jsx(WheelPicker, { className: "datepicker-wheel", "aria-label": api.headerLabel, columns: [
|
|
51
53
|
{
|
|
52
54
|
key: "year",
|
|
53
55
|
label: api.ariaLabels.yearWheel,
|
|
@@ -9,6 +9,12 @@ import { useTablistKeyboard } from "./tabs-keyboard.js";
|
|
|
9
9
|
* `value`/`onValueChange`, or uncontrolled from `defaultValue`.
|
|
10
10
|
*/
|
|
11
11
|
export function Tabs({ tabs, value, defaultValue, onValueChange, leading, children, className, "aria-label": ariaLabel, ...rest }) {
|
|
12
|
+
// Scoped to this instance: `tab-${value}` and `panel-${value}` are global,
|
|
13
|
+
// so two tab bars sharing a value mint the same id twice and every
|
|
14
|
+
// aria-labelledby resolves to the first one (#227).
|
|
15
|
+
const uid = React.useId();
|
|
16
|
+
const tabId = (v) => `${uid}-tab-${v}`;
|
|
17
|
+
const panelId = (v) => `${uid}-panel-${v}`;
|
|
12
18
|
const [internal, setInternal] = React.useState(defaultValue ?? tabs[0]?.value);
|
|
13
19
|
const active = value ?? internal;
|
|
14
20
|
const listRef = React.useRef(null);
|
|
@@ -43,11 +49,11 @@ export function Tabs({ tabs, value, defaultValue, onValueChange, leading, childr
|
|
|
43
49
|
});
|
|
44
50
|
return (_jsxs("div", { className: tabsRecipe({ className }), ...rest, children: [_jsxs("div", { ref: listRef, className: "tabs-list", role: "tablist", "aria-label": ariaLabel, onKeyDown: onKeyDown, children: [leading && _jsx("span", { className: "tabs-leading", children: leading }), tabs.map((t) => {
|
|
45
51
|
const selected = t.value === active;
|
|
46
|
-
return (_jsxs("button", { type: "button", role: "tab", id:
|
|
52
|
+
return (_jsxs("button", { type: "button", role: "tab", id: tabId(t.value), "aria-selected": selected, "aria-controls": children && selected ? panelId(t.value) : undefined, tabIndex: tabIndexFor(t.value), "data-value": t.value, "data-selected": selected ? "" : undefined, disabled: t.disabled, className: "tabs-tab", onClick: () => select(t.value), children: [t.icon, _jsx("span", { className: "tabs-tab-label", children: t.label }), t.badge != null && (_jsx("span", { className: "tabs-tab-badge", children: t.badge }))] }, t.value));
|
|
47
53
|
}), indicator && (_jsx("span", { className: "tabs-indicator", style: {
|
|
48
54
|
width: indicator.width,
|
|
49
55
|
transform: `translateX(${indicator.left}px)`,
|
|
50
|
-
} }))] }), children && (_jsx("div", { className: "tabs-panel", role: "tabpanel", id:
|
|
56
|
+
} }))] }), children && (_jsx("div", { className: "tabs-panel", role: "tabpanel", id: panelId(active), "aria-labelledby": tabId(active),
|
|
51
57
|
// biome-ignore lint/a11y/noNoninteractiveTabindex: a tabpanel is focusable per the WAI-ARIA tabs pattern
|
|
52
58
|
tabIndex: 0, children: children(active) }))] }));
|
|
53
59
|
}
|
|
@@ -962,7 +962,11 @@ export function RecordsTable({ labels, columns: columnsProp = defaultColumns, ro
|
|
|
962
962
|
}, children: [_jsxs("colgroup", { children: [_jsx("col", { style: { width: CHECK_W } }), cols.map((col) => (_jsx("col", { style: { width: colWidth(col) } }, col.key))), _jsx("col", {})] }), _jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { className: "recordstable-th recordstable-col-check", children: _jsx("span", { className: "recordstable-check-inner", children: _jsx(Checkbox, { "aria-label": t.selectAll, checked: allSelected, indeterminate: someSelected, onChange: toggleAll }) }) }), cols.map((col, i) => {
|
|
963
963
|
const Icon = col.icon;
|
|
964
964
|
const sc = sorts.find((s) => s.key === col.key);
|
|
965
|
-
return (_jsxs("th", { className: `recordstable-th${i === 0 ? " recordstable-col-entity" : ""}`, "data-sorted": sc?.dir, "
|
|
965
|
+
return (_jsxs("th", { className: `recordstable-th${i === 0 ? " recordstable-col-entity" : ""}`, "data-sorted": sc?.dir, "aria-sort": sorts[0]?.key === col.key
|
|
966
|
+
? sorts[0].dir === "asc"
|
|
967
|
+
? "ascending"
|
|
968
|
+
: "descending"
|
|
969
|
+
: "none", "data-drop": dragCol && dragCol !== col.key && i >= 1 ? "" : undefined, onDragOver: dragCol && i >= 1 ? (e) => e.preventDefault() : undefined, onDrop: dragCol && i >= 1
|
|
966
970
|
? (e) => {
|
|
967
971
|
e.preventDefault();
|
|
968
972
|
reorderColumn(dragCol, col.key);
|