@jobber/components 9.8.0 → 9.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,5 +14,11 @@ export interface DataTableSortableHeaderProps {
14
14
  * When undefined, the header renders as non-interactive.
15
15
  */
16
16
  readonly onSort?: () => void;
17
+ /**
18
+ * The horizontal alignment of the header content and sort icon.
19
+ *
20
+ * @default "start"
21
+ */
22
+ readonly align?: "start" | "center" | "end";
17
23
  }
18
24
  export declare function DataTableSortableHeader(props: DataTableSortableHeaderProps & React.HTMLAttributes<HTMLTableCellElement>): React.JSX.Element;
@@ -39,7 +39,7 @@ function SortIcon({ direction }) {
39
39
  React.createElement("path", { className: finalStyle.downArrowStyle, d: "M8.29292 13.3339C8.68345 12.9434 9.31661 12.9434 9.70714 13.3339L12.2968 15.8573L14.8787 13.3339C15.2692 12.9434 15.9024 12.9434 16.2929 13.3339C16.6834 13.7244 16.6834 14.3576 16.2929 14.7481L13 18.041C12.6095 18.4315 11.9763 18.4315 11.5858 18.041L8.29292 14.7481C7.9024 14.3576 7.9024 13.7244 8.29292 13.3339Z" }))));
40
40
  }
41
41
 
42
- var styles = {"container":"_1-DPmbxOkZ8-","tableElement":"kJeYcsgg700-","header":"_5d2OcsTVgzU-","headerCell":"LTx0tCU3F2I-","sortableButton":"WTQCrd2d8nw-","focusArea":"RipbH3rRU-E-","row":"sJQbtw-NEHU-","clickableRow":"J2p1EeT252A-","cell":"_1UpLYTK64uY-","footer":"qe-6UrAFLTo-","actions":"_2fZsLSaNPnI-","rowActions":"pElxuwpGmCI-","pagination":"thJ-CSoe0ps-","spinning":"EBpmC7cZzCs-"};
42
+ var styles = {"container":"_1-DPmbxOkZ8-","tableElement":"kJeYcsgg700-","header":"_5d2OcsTVgzU-","headerCell":"LTx0tCU3F2I-","sortableButton":"WTQCrd2d8nw-","focusArea":"RipbH3rRU-E-","alignCenter":"w4UHxTf-Z0Q-","alignEnd":"O7R9Tt281nY-","row":"sJQbtw-NEHU-","clickableRow":"J2p1EeT252A-","cell":"_1UpLYTK64uY-","footer":"qe-6UrAFLTo-","actions":"_2fZsLSaNPnI-","rowActions":"pElxuwpGmCI-","pagination":"thJ-CSoe0ps-","spinning":"EBpmC7cZzCs-"};
43
43
 
44
44
  function DataTableActions(props) {
45
45
  return (React.createElement("div", Object.assign({}, props, { className: classnames(styles.actions, props.className) }), props.children));
@@ -94,13 +94,18 @@ function DataTableRowActions(props) {
94
94
  }
95
95
 
96
96
  function DataTableSortableHeader(props) {
97
- const { children, direction, onSort } = props, rest = tslib_es6.__rest(props, ["children", "direction", "onSort"]);
97
+ const { children, direction, onSort, align = "start" } = props, rest = tslib_es6.__rest(props, ["children", "direction", "onSort", "align"]);
98
98
  const isSortable = direction !== undefined && onSort !== undefined;
99
+ const alignmentClass = {
100
+ start: undefined,
101
+ center: styles.alignCenter,
102
+ end: styles.alignEnd,
103
+ }[align];
99
104
  if (!isSortable) {
100
- return React.createElement(DataTableHeaderCell, Object.assign({}, rest), children);
105
+ return (React.createElement(DataTableHeaderCell, Object.assign({}, rest, { className: classnames(rest.className, alignmentClass) }), children));
101
106
  }
102
107
  return (React.createElement(DataTableHeaderCell, Object.assign({}, rest),
103
- React.createElement("button", { type: "button", onClick: onSort, className: styles.sortableButton },
108
+ React.createElement("button", { type: "button", onClick: onSort, className: classnames(styles.sortableButton, alignmentClass) },
104
109
  React.createElement("span", { className: styles.focusArea },
105
110
  children,
106
111
  React.createElement(SortIcon, { direction: direction })))));
@@ -37,7 +37,7 @@ function SortIcon({ direction }) {
37
37
  React__default.createElement("path", { className: finalStyle.downArrowStyle, d: "M8.29292 13.3339C8.68345 12.9434 9.31661 12.9434 9.70714 13.3339L12.2968 15.8573L14.8787 13.3339C15.2692 12.9434 15.9024 12.9434 16.2929 13.3339C16.6834 13.7244 16.6834 14.3576 16.2929 14.7481L13 18.041C12.6095 18.4315 11.9763 18.4315 11.5858 18.041L8.29292 14.7481C7.9024 14.3576 7.9024 13.7244 8.29292 13.3339Z" }))));
38
38
  }
39
39
 
40
- var styles = {"container":"_1-DPmbxOkZ8-","tableElement":"kJeYcsgg700-","header":"_5d2OcsTVgzU-","headerCell":"LTx0tCU3F2I-","sortableButton":"WTQCrd2d8nw-","focusArea":"RipbH3rRU-E-","row":"sJQbtw-NEHU-","clickableRow":"J2p1EeT252A-","cell":"_1UpLYTK64uY-","footer":"qe-6UrAFLTo-","actions":"_2fZsLSaNPnI-","rowActions":"pElxuwpGmCI-","pagination":"thJ-CSoe0ps-","spinning":"EBpmC7cZzCs-"};
40
+ var styles = {"container":"_1-DPmbxOkZ8-","tableElement":"kJeYcsgg700-","header":"_5d2OcsTVgzU-","headerCell":"LTx0tCU3F2I-","sortableButton":"WTQCrd2d8nw-","focusArea":"RipbH3rRU-E-","alignCenter":"w4UHxTf-Z0Q-","alignEnd":"O7R9Tt281nY-","row":"sJQbtw-NEHU-","clickableRow":"J2p1EeT252A-","cell":"_1UpLYTK64uY-","footer":"qe-6UrAFLTo-","actions":"_2fZsLSaNPnI-","rowActions":"pElxuwpGmCI-","pagination":"thJ-CSoe0ps-","spinning":"EBpmC7cZzCs-"};
41
41
 
42
42
  function DataTableActions(props) {
43
43
  return (React__default.createElement("div", Object.assign({}, props, { className: classnames(styles.actions, props.className) }), props.children));
@@ -92,13 +92,18 @@ function DataTableRowActions(props) {
92
92
  }
93
93
 
94
94
  function DataTableSortableHeader(props) {
95
- const { children, direction, onSort } = props, rest = __rest(props, ["children", "direction", "onSort"]);
95
+ const { children, direction, onSort, align = "start" } = props, rest = __rest(props, ["children", "direction", "onSort", "align"]);
96
96
  const isSortable = direction !== undefined && onSort !== undefined;
97
+ const alignmentClass = {
98
+ start: undefined,
99
+ center: styles.alignCenter,
100
+ end: styles.alignEnd,
101
+ }[align];
97
102
  if (!isSortable) {
98
- return React__default.createElement(DataTableHeaderCell, Object.assign({}, rest), children);
103
+ return (React__default.createElement(DataTableHeaderCell, Object.assign({}, rest, { className: classnames(rest.className, alignmentClass) }), children));
99
104
  }
100
105
  return (React__default.createElement(DataTableHeaderCell, Object.assign({}, rest),
101
- React__default.createElement("button", { type: "button", onClick: onSort, className: styles.sortableButton },
106
+ React__default.createElement("button", { type: "button", onClick: onSort, className: classnames(styles.sortableButton, alignmentClass) },
102
107
  React__default.createElement("span", { className: styles.focusArea },
103
108
  children,
104
109
  React__default.createElement(SortIcon, { direction: direction })))));
@@ -305,6 +305,20 @@ The `direction` prop accepts:
305
305
  When both `direction` and `onSort` are provided, the header becomes interactive
306
306
  with a sort icon. When either is missing, it renders as a regular header cell.
307
307
 
308
+ Use the `align` prop to align the header content and sort icon. This is useful
309
+ for numerical columns, where both the values and the header should be
310
+ end-aligned:
311
+
312
+ ```tsx
313
+ <DataTable.SortableHeader
314
+ align="end"
315
+ direction={currentSort}
316
+ onSort={() => handleColumnSort("totalPrice")}
317
+ >
318
+ Total price
319
+ </DataTable.SortableHeader>
320
+ ```
321
+
308
322
  The `direction` prop represents the current sort state of the column. Your
309
323
  `onSort` callback should handle the state transitions (ascending → descending →
310
324
  equilibrium) based on your application's logic.
@@ -526,6 +540,7 @@ const table = useReactTable({
526
540
 
527
541
  | Prop | Type | Required | Default | Description |
528
542
  |------|------|----------|---------|-------------|
543
+ | `align` | `"center" | "end" | "start"` | No | `"start"` | The horizontal alignment of the header content and sort icon. |
529
544
  | `children` | `ReactNode` | No | — | The header content to display (text, icons, etc.) |
530
545
  | `direction` | `SortDirection` | No | — | The current sort direction for this column. When undefined, the header renders as non-interactive. |
531
546
  | `onSort` | `() => void` | No | — | Callback function triggered when the sortable header is clicked. When undefined, the header renders as non-interactive. |
package/dist/styles.css CHANGED
@@ -9565,6 +9565,24 @@ a._7BLGtYNuJOU-.zgRx3ehZ2z8-:hover {
9565
9565
  box-shadow: var(--shadow-focus);
9566
9566
  }
9567
9567
 
9568
+ .WTQCrd2d8nw-.w4UHxTf-Z0Q- {
9569
+ -ms-flex-pack: center;
9570
+ justify-content: center;
9571
+ }
9572
+
9573
+ .WTQCrd2d8nw-.O7R9Tt281nY- {
9574
+ -ms-flex-pack: end;
9575
+ justify-content: flex-end;
9576
+ }
9577
+
9578
+ .LTx0tCU3F2I-.w4UHxTf-Z0Q- {
9579
+ text-align: center;
9580
+ }
9581
+
9582
+ .LTx0tCU3F2I-.O7R9Tt281nY- {
9583
+ text-align: right;
9584
+ }
9585
+
9568
9586
  .sJQbtw-NEHU- {
9569
9587
  position: relative;
9570
9588
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components",
3
- "version": "9.8.0",
3
+ "version": "9.9.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -549,5 +549,5 @@
549
549
  "> 1%",
550
550
  "IE 10"
551
551
  ],
552
- "gitHead": "740cda8097c2d00fd68de5ed04e3af839f3f18b9"
552
+ "gitHead": "384a88d1d70cfd6069c4a54436f58fa9b5d40c66"
553
553
  }