@rojaostudio/ds 2.0.0-next.17 → 2.0.0-next.19

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 on a narrow screen too.
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
- /** On a narrow screen, moves the filters and the actions into a Drawer. The quick filters stay in view. */
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 on a wide screen). */
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. From 768 the wide layout shows; below it, the filters open
54
- * in a Drawer or a Popover. "Filtros · N" counts the active `filters`, the ones that button opens.
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 screen width, as the Figma viewport mode (layout/compact below lg 1024; 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(FilterTrigger, { filter: f, onClick: () => setOpen(true) }),
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(FiltersButton, { count: activeFilterCount })
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(FiltersButton, { count: activeFilterCount, onClick: () => setSheetOpen(true) }),
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rojaostudio/ds",
3
- "version": "2.0.0-next.17",
3
+ "version": "2.0.0-next.19",
4
4
  "type": "module",
5
5
  "description": "Rojão Design System — componentes React, estilos e alvo React Native. O motor vive em @rojaostudio/ds-core.",
6
6
  "license": "MIT",
@@ -3585,10 +3585,16 @@ 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. The wide parts show from 768, the narrow ones
3589
- * below it. In the Popover and the Drawer the filters stack 16 apart, each one a caption-sized label over its chips.
3588
+ * and the actions follow it on the right, and what does not fit wraps.
3589
+ * Two arrangements, by the screen width, as the Figma viewport mode (layout/compact below lg 1024; 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
+ width: 100%;
3592
3598
  display: flex;
3593
3599
  flex-wrap: wrap;
3594
3600
  align-items: center;
@@ -3614,17 +3620,55 @@ input:focus-visible + .rds-checkbox__box {
3614
3620
  gap: var(--space-8);
3615
3621
  }
3616
3622
 
3617
- .rds-data-table-header__wide {
3623
+ .rds-data-table-header__narrow {
3618
3624
  display: none;
3619
3625
  }
3620
3626
 
3621
- @media (min-width: 768px) {
3627
+ @media (max-width: 1023px) {
3622
3628
  .rds-data-table-header__wide {
3623
- display: flex;
3629
+ display: none;
3624
3630
  }
3625
3631
 
3626
3632
  .rds-data-table-header__narrow {
3627
- display: none;
3633
+ display: flex;
3634
+ }
3635
+
3636
+ /* Compact: the search accepts 200 (40 × 5), so it sits on one line with the filter and an IconButton at 390. */
3637
+ .rds-data-table-header .rds-data-table-header__search {
3638
+ flex-basis: calc(var(--space-40) * 5);
3639
+ min-width: min(calc(var(--space-40) * 5), 100%);
3640
+ }
3641
+ }
3642
+
3643
+ /* The compact filter: the IconButton with its indicator on the corner. */
3644
+ .rds-data-table-header__trigger {
3645
+ position: relative;
3646
+ display: inline-flex;
3647
+ }
3648
+
3649
+ .rds-data-table-header__dot,
3650
+ .rds-data-table-header__count {
3651
+ position: absolute;
3652
+ pointer-events: none;
3653
+ }
3654
+
3655
+ .rds-data-table-header__dot {
3656
+ top: calc(var(--space-4) * 1.5);
3657
+ right: calc(var(--space-4) * 1.5);
3658
+ width: var(--space-8);
3659
+ height: var(--space-8);
3660
+ border-radius: var(--radius-full);
3661
+ background: var(--badge-neutral-fill-background);
3662
+ }
3663
+
3664
+ .rds-data-table-header__count {
3665
+ top: calc(var(--space-4) * -1.5);
3666
+ right: calc(var(--space-12) * -1);
3667
+ }
3668
+
3669
+ @media (forced-colors: active) {
3670
+ .rds-data-table-header__dot {
3671
+ background: CanvasText;
3628
3672
  }
3629
3673
  }
3630
3674
 
@@ -8387,13 +8431,12 @@ input:focus-visible + .rds-radio__circle {
8387
8431
  * SavingBar (Actions collection, savingbar/*): full width (at least 320), 12 24 padding, 16 between the
8388
8432
  * message (label, medium, at most 2 lines with an ellipsis) and the actions (8 apart). The Buttons use the inverse
8389
8433
  * tone, drawn for this band in both modes, so the bar needs no theme switch of its own.
8390
- * Two arrangements, by the bar's own width (a size container, as the Figma's viewport mode): expanded from 1024,
8434
+ * Two arrangements, by the screen width, as the Figma viewport mode (layout/compact below lg 1024): expanded from 1024,
8391
8435
  * the message grows (at least 160) beside the actions; compact below it, the message on top and Descartar and
8392
8436
  * Salvar under it, sharing the width.
8393
8437
  */
8394
8438
  .rds-savingbar {
8395
8439
  box-sizing: border-box;
8396
- container-type: inline-size;
8397
8440
  width: 100%;
8398
8441
  min-width: min(320px, 100%);
8399
8442
  padding: var(--space-12) var(--space-24);
@@ -8464,7 +8507,7 @@ input:focus-visible + .rds-radio__circle {
8464
8507
  gap: var(--space-8);
8465
8508
  }
8466
8509
 
8467
- @container (max-width: 1023px) {
8510
+ @media (max-width: 1023px) {
8468
8511
  .rds-savingbar__row {
8469
8512
  flex-direction: column;
8470
8513
  align-items: stretch;