@rojaostudio/ds 2.0.0-next.17 → 2.0.0-next.18
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.
|
@@ -32,15 +32,15 @@ type DataTableHeaderProps = {
|
|
|
32
32
|
onClear?: () => void;
|
|
33
33
|
/**
|
|
34
34
|
* A view control after the filters and before the actions (Figma: `showView` + the `view` slot), such as a
|
|
35
|
-
* Checkbox "Agrupar por produto". In view
|
|
35
|
+
* Checkbox "Agrupar por produto". In view in the compact arrangement too.
|
|
36
36
|
*/
|
|
37
37
|
view?: ReactNode;
|
|
38
38
|
actions?: ReactNode;
|
|
39
39
|
className?: string;
|
|
40
|
-
/**
|
|
40
|
+
/** In the compact arrangement (bar below 1024), moves the filters and the actions into a Drawer. The quick filters stay in view. */
|
|
41
41
|
mobileCollapse?: boolean;
|
|
42
42
|
};
|
|
43
|
-
/** One filter as a DropdownMenu of radio items (one filter
|
|
43
|
+
/** One filter as a DropdownMenu of radio items (one filter, expanded). */
|
|
44
44
|
declare function FilterDropdown({ f, placement }: {
|
|
45
45
|
f: DataTableFilterDef;
|
|
46
46
|
placement?: 'bottom-start' | 'bottom-end';
|
|
@@ -50,8 +50,13 @@ declare function FilterDropdown({ f, placement }: {
|
|
|
50
50
|
* the Drawer: the bar above a table. The search is always on the left and takes the free width (at least 320); the
|
|
51
51
|
* filters are always on the right; what does not fit wraps. Quick filters go in the `quickFilters` slot; one filter
|
|
52
52
|
* is a dropdown, two or more collapse into "Filtros" (the active ones stay in view as removable Chips); the `view`
|
|
53
|
-
* control comes after the filters, before the actions.
|
|
54
|
-
*
|
|
53
|
+
* control comes after the filters, before the actions. "Filtros · N" counts the active `filters`, the ones that
|
|
54
|
+
* button opens.
|
|
55
|
+
*
|
|
56
|
+
* Two arrangements, by the bar's own width (a size container, as the Figma's viewport mode; the SavingBar's cut):
|
|
57
|
+
* expanded from 1024, the Separator and the Buttons with their labels; compact below it, the search accepts 200 and
|
|
58
|
+
* the filter is an outline IconButton (sliders, 44) with a dot (one filter on) or a counter (several), opening the
|
|
59
|
+
* same Drawer or Popover. There is no screen prop.
|
|
55
60
|
* Styles: data-table-header.css.
|
|
56
61
|
*/
|
|
57
62
|
declare function DataTableHeader({ search, filters, quickFilters, onClear, view, actions, className, mobileCollapse, }: DataTableHeaderProps): react.JSX.Element;
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
} from "../chunk-ORMEWXMH.js";
|
|
7
7
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import { useState } from "react";
|
|
9
|
+
import { Badge } from "./badge.js";
|
|
9
10
|
import { Button } from "./button.js";
|
|
10
11
|
import { Chip } from "./chip.js";
|
|
11
12
|
import { Drawer } from "./drawer.js";
|
|
@@ -80,10 +81,49 @@ function FiltersPopover({
|
|
|
80
81
|
}
|
|
81
82
|
) }) });
|
|
82
83
|
}
|
|
84
|
+
function CompactFilterTrigger(_e) {
|
|
85
|
+
var _f = _e, {
|
|
86
|
+
label,
|
|
87
|
+
state,
|
|
88
|
+
indicator
|
|
89
|
+
} = _f, rest = __objRest(_f, [
|
|
90
|
+
"label",
|
|
91
|
+
"state",
|
|
92
|
+
"indicator"
|
|
93
|
+
]);
|
|
94
|
+
return /* @__PURE__ */ jsxs("span", { className: "rds-data-table-header__trigger", children: [
|
|
95
|
+
/* @__PURE__ */ jsx(Tooltip, { text: label, children: /* @__PURE__ */ jsx(
|
|
96
|
+
IconButton,
|
|
97
|
+
__spreadProps(__spreadValues({}, rest), {
|
|
98
|
+
icon: /* @__PURE__ */ jsx(SlidersIcon, {}),
|
|
99
|
+
label: state ? `${label}, ${state}` : label,
|
|
100
|
+
variant: "outline",
|
|
101
|
+
tone: "neutral",
|
|
102
|
+
size: "md",
|
|
103
|
+
"data-filter-toggle": ""
|
|
104
|
+
})
|
|
105
|
+
) }),
|
|
106
|
+
indicator === "dot" && /* @__PURE__ */ jsx("span", { className: "rds-data-table-header__dot", "aria-hidden": "true" }),
|
|
107
|
+
typeof indicator === "number" && /* @__PURE__ */ jsx(Badge, { className: "rds-data-table-header__count", tone: "neutral", value: indicator, "aria-hidden": "true" })
|
|
108
|
+
] });
|
|
109
|
+
}
|
|
110
|
+
function activeState(count) {
|
|
111
|
+
if (count === 0) return void 0;
|
|
112
|
+
return count === 1 ? "1 ativo" : `${count} ativos`;
|
|
113
|
+
}
|
|
83
114
|
function MobileSingleFilter({ f }) {
|
|
84
115
|
const [open, setOpen] = useState(false);
|
|
116
|
+
const on = f.value !== "";
|
|
85
117
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
86
|
-
/* @__PURE__ */ jsx(
|
|
118
|
+
/* @__PURE__ */ jsx(
|
|
119
|
+
CompactFilterTrigger,
|
|
120
|
+
{
|
|
121
|
+
label: f.label,
|
|
122
|
+
state: on ? optionLabel(f) : void 0,
|
|
123
|
+
indicator: on ? "dot" : void 0,
|
|
124
|
+
onClick: () => setOpen(true)
|
|
125
|
+
}
|
|
126
|
+
),
|
|
87
127
|
/* @__PURE__ */ jsx(Drawer, { open, onOpenChange: setOpen, title: f.label, children: /* @__PURE__ */ jsx(
|
|
88
128
|
FilterGroups,
|
|
89
129
|
{
|
|
@@ -153,11 +193,26 @@ function DataTableHeader({
|
|
|
153
193
|
filters,
|
|
154
194
|
onClear,
|
|
155
195
|
showClear: activeFilterCount > 0,
|
|
156
|
-
trigger: /* @__PURE__ */ jsx(
|
|
196
|
+
trigger: /* @__PURE__ */ jsx(
|
|
197
|
+
CompactFilterTrigger,
|
|
198
|
+
{
|
|
199
|
+
label: "Filtros",
|
|
200
|
+
state: activeState(activeFilterCount),
|
|
201
|
+
indicator: activeFilterCount > 0 ? activeFilterCount : void 0
|
|
202
|
+
}
|
|
203
|
+
)
|
|
157
204
|
}
|
|
158
205
|
) }),
|
|
159
206
|
mobileCollapse && (filters.length >= 2 || actions) && /* @__PURE__ */ jsxs("div", { className: "rds-data-table-header__narrow", children: [
|
|
160
|
-
/* @__PURE__ */ jsx(
|
|
207
|
+
/* @__PURE__ */ jsx(
|
|
208
|
+
CompactFilterTrigger,
|
|
209
|
+
{
|
|
210
|
+
label: "Filtros",
|
|
211
|
+
state: activeState(activeFilterCount),
|
|
212
|
+
indicator: activeFilterCount === 0 ? void 0 : filters.length === 1 ? "dot" : activeFilterCount,
|
|
213
|
+
onClick: () => setSheetOpen(true)
|
|
214
|
+
}
|
|
215
|
+
),
|
|
161
216
|
/* @__PURE__ */ jsx(Drawer, { open: sheetOpen, onOpenChange: setSheetOpen, title: "Filtros", children: /* @__PURE__ */ jsxs("div", { className: "rds-data-table-header__groups", children: [
|
|
162
217
|
/* @__PURE__ */ jsx(
|
|
163
218
|
FilterGroups,
|
package/package.json
CHANGED
|
@@ -3585,10 +3585,17 @@ input:focus-visible + .rds-checkbox__box {
|
|
|
3585
3585
|
* DataTableHeader: no tokens of its own; the Input, FilterChip, Chip, Button, Separator, Checkbox, DropdownMenu,
|
|
3586
3586
|
* Popover and Drawer bring theirs. One row, 8 apart, 12 above the table, packed to the right: the search on the left
|
|
3587
3587
|
* takes the free width, at least 320 (never wider than the bar); the quick filters, the filters, the view control
|
|
3588
|
-
* and the actions follow it on the right, and what does not fit wraps.
|
|
3589
|
-
*
|
|
3588
|
+
* and the actions follow it on the right, and what does not fit wraps.
|
|
3589
|
+
* Two arrangements, by the bar's own width (a size container, as the Figma's viewport mode; the SavingBar's cut):
|
|
3590
|
+
* expanded from 1024 (the __wide parts: Separator, Buttons with labels); compact below it (the __narrow parts: the
|
|
3591
|
+
* filter as an IconButton of 44), where the search accepts 200. On the IconButton, while a filter is on, a dot of 8
|
|
3592
|
+
* (badge neutral fill, 6 in from the top right corner) or a neutral number Badge over the corner (-6 top, -12 right).
|
|
3593
|
+
* In the Popover and the Drawer the filters stack 16 apart, each one a caption-sized label over its chips.
|
|
3590
3594
|
*/
|
|
3591
3595
|
.rds-data-table-header {
|
|
3596
|
+
box-sizing: border-box;
|
|
3597
|
+
container-type: inline-size;
|
|
3598
|
+
width: 100%;
|
|
3592
3599
|
display: flex;
|
|
3593
3600
|
flex-wrap: wrap;
|
|
3594
3601
|
align-items: center;
|
|
@@ -3614,17 +3621,55 @@ input:focus-visible + .rds-checkbox__box {
|
|
|
3614
3621
|
gap: var(--space-8);
|
|
3615
3622
|
}
|
|
3616
3623
|
|
|
3617
|
-
.rds-data-table-
|
|
3624
|
+
.rds-data-table-header__narrow {
|
|
3618
3625
|
display: none;
|
|
3619
3626
|
}
|
|
3620
3627
|
|
|
3621
|
-
@
|
|
3628
|
+
@container (max-width: 1023px) {
|
|
3622
3629
|
.rds-data-table-header__wide {
|
|
3623
|
-
display:
|
|
3630
|
+
display: none;
|
|
3624
3631
|
}
|
|
3625
3632
|
|
|
3626
3633
|
.rds-data-table-header__narrow {
|
|
3627
|
-
display:
|
|
3634
|
+
display: flex;
|
|
3635
|
+
}
|
|
3636
|
+
|
|
3637
|
+
/* Compact: the search accepts 200 (40 × 5), so it sits on one line with the filter and an IconButton at 390. */
|
|
3638
|
+
.rds-data-table-header .rds-data-table-header__search {
|
|
3639
|
+
flex-basis: calc(var(--space-40) * 5);
|
|
3640
|
+
min-width: min(calc(var(--space-40) * 5), 100%);
|
|
3641
|
+
}
|
|
3642
|
+
}
|
|
3643
|
+
|
|
3644
|
+
/* The compact filter: the IconButton with its indicator on the corner. */
|
|
3645
|
+
.rds-data-table-header__trigger {
|
|
3646
|
+
position: relative;
|
|
3647
|
+
display: inline-flex;
|
|
3648
|
+
}
|
|
3649
|
+
|
|
3650
|
+
.rds-data-table-header__dot,
|
|
3651
|
+
.rds-data-table-header__count {
|
|
3652
|
+
position: absolute;
|
|
3653
|
+
pointer-events: none;
|
|
3654
|
+
}
|
|
3655
|
+
|
|
3656
|
+
.rds-data-table-header__dot {
|
|
3657
|
+
top: calc(var(--space-4) * 1.5);
|
|
3658
|
+
right: calc(var(--space-4) * 1.5);
|
|
3659
|
+
width: var(--space-8);
|
|
3660
|
+
height: var(--space-8);
|
|
3661
|
+
border-radius: var(--radius-full);
|
|
3662
|
+
background: var(--badge-neutral-fill-background);
|
|
3663
|
+
}
|
|
3664
|
+
|
|
3665
|
+
.rds-data-table-header__count {
|
|
3666
|
+
top: calc(var(--space-4) * -1.5);
|
|
3667
|
+
right: calc(var(--space-12) * -1);
|
|
3668
|
+
}
|
|
3669
|
+
|
|
3670
|
+
@media (forced-colors: active) {
|
|
3671
|
+
.rds-data-table-header__dot {
|
|
3672
|
+
background: CanvasText;
|
|
3628
3673
|
}
|
|
3629
3674
|
}
|
|
3630
3675
|
|