@ostack.tech/ui 0.6.3 → 0.6.4

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.
@@ -3,7 +3,7 @@ import { TableBody } from '../Table';
3
3
  import { DataTableContentProps } from './DataTableContent.tsx';
4
4
  /** Properties of the data table foot component. */
5
5
  export interface DataTableBodyProps extends ComponentPropsWithoutRef<typeof TableBody>, Pick<DataTableContentProps, "emptyMessage" | "emptyMessageProps"> {
6
- containerRef: RefObject<HTMLDivElement | null>;
6
+ scrollableRef: RefObject<HTMLDivElement | null>;
7
7
  }
8
8
  /** Body of the data table. */
9
9
  export declare const DataTableBody: import('react').ForwardRefExoticComponent<DataTableBodyProps & import('react').RefAttributes<HTMLTableSectionElement>>;
@@ -2,6 +2,13 @@ import { ComponentPropsWithoutRef } from 'react';
2
2
  import { Input } from '../Input';
3
3
  /** Properties of the data table filter component. */
4
4
  export interface DataTableFilterProps extends Omit<ComponentPropsWithoutRef<typeof Input>, "defaultValue" | "value"> {
5
+ /**
6
+ * Whether the component should preferably be aligned to the right. This only
7
+ * has an effect when the component is nested directly under the `DataTable`.
8
+ *
9
+ * @default true
10
+ */
11
+ preferRightAlignment?: boolean;
5
12
  }
6
13
  /** Input used to globally filter a data table. */
7
14
  export declare const DataTableFilter: import('react').ForwardRefExoticComponent<DataTableFilterProps & import('react').RefAttributes<HTMLInputElement>>;
@@ -14,6 +14,13 @@ export interface DataTablePaginationProps extends ComponentPropsWithoutRef<"div"
14
14
  previousPageButtonLabel?: string;
15
15
  /** Label of the next page button (only relevant in paged mode). */
16
16
  nextPageButtonLabel?: string;
17
+ /**
18
+ * Whether the component should preferably be aligned to the right. This only
19
+ * has an effect when the component is nested directly under the `DataTable`.
20
+ *
21
+ * @default true
22
+ */
23
+ preferRightAlignment?: boolean;
17
24
  /**
18
25
  * Properties to pass to the previous page button (only relevant in paged
19
26
  * mode).
@@ -14,6 +14,13 @@ export interface DataTableRowsPerPageProps extends ComponentPropsWithoutRef<"div
14
14
  * @param rows Node representing the number of rows (a select).
15
15
  */
16
16
  label?: ReactNode;
17
+ /**
18
+ * Whether the component should preferably be aligned to the right. This only
19
+ * has an effect when the component is nested directly under the `DataTable`.
20
+ *
21
+ * @default false
22
+ */
23
+ preferRightAlignment?: boolean;
17
24
  }
18
25
  /** Component displaying a select used to change the number of rows per page. */
19
26
  export declare const DataTableRowsPerPage: import('react').ForwardRefExoticComponent<DataTableRowsPerPageProps & import('react').RefAttributes<HTMLDivElement>>;
@@ -2,6 +2,13 @@ import { ComponentPropsWithoutRef, Key, MouseEvent, ReactNode } from 'react';
2
2
  import { Button } from '../Button';
3
3
  /** Properties of the data table selection trigger component. */
4
4
  export interface DataTableSelectionTriggerProps extends Omit<ComponentPropsWithoutRef<typeof Button>, "onClick"> {
5
+ /**
6
+ * Whether the component should preferably be aligned to the right. This only
7
+ * has an effect when the component is nested directly under the `DataTable`.
8
+ *
9
+ * @default true
10
+ */
11
+ preferRightAlignment?: boolean;
5
12
  /**
6
13
  * Whether the button should be displayed when no rows are selected.
7
14
  *
@@ -1,7 +1,7 @@
1
1
  import { ComponentPropsWithoutRef } from 'react';
2
2
  import { DataTablePaginationProps } from './DataTablePagination.tsx';
3
3
  /** Properties of the scrolled data table pagination. */
4
- export interface PagedDataTablePaginationProps extends ComponentPropsWithoutRef<"div">, Pick<DataTablePaginationProps, "rowsRange" | "previousPageButtonLabel" | "nextPageButtonLabel" | "previousPageButtonProps" | "nextPageButtonProps"> {
4
+ export interface PagedDataTablePaginationProps extends ComponentPropsWithoutRef<"div">, Pick<DataTablePaginationProps, "rowsRange" | "previousPageButtonLabel" | "nextPageButtonLabel" | "preferRightAlignment" | "previousPageButtonProps" | "nextPageButtonProps"> {
5
5
  }
6
6
  /** Pagination component of the scrolled data table. */
7
7
  export declare const PagedDataTablePagination: import('react').ForwardRefExoticComponent<PagedDataTablePaginationProps & import('react').RefAttributes<HTMLDivElement>>;
@@ -1,7 +1,7 @@
1
1
  import { ComponentPropsWithoutRef } from 'react';
2
2
  import { DataTablePaginationProps } from './DataTablePagination.tsx';
3
3
  /** Properties of the scrolled data table pagination. */
4
- export interface ScrolledDataTablePaginationProps extends ComponentPropsWithoutRef<"div">, Pick<DataTablePaginationProps, "rowsRange"> {
4
+ export interface ScrolledDataTablePaginationProps extends ComponentPropsWithoutRef<"div">, Pick<DataTablePaginationProps, "rowsRange" | "preferRightAlignment"> {
5
5
  }
6
6
  /** Pagination component of the scrolled data table. */
7
7
  export declare const ScrolledDataTablePagination: import('react').ForwardRefExoticComponent<ScrolledDataTablePaginationProps & import('react').RefAttributes<HTMLDivElement>>;
@@ -1,7 +1,7 @@
1
1
  import { DataTableBodyProps } from './DataTableBody.tsx';
2
2
  /** Properties of the scrolled data table body component. */
3
- interface ScrolledDataTableRowsProps extends Pick<DataTableBodyProps, "containerRef"> {
3
+ interface ScrolledDataTableRowsProps extends Pick<DataTableBodyProps, "scrollableRef"> {
4
4
  }
5
5
  /** Body of the data table in "scrolled" display mode. */
6
- export declare function ScrolledDataTableRows<T = unknown>({ containerRef, }: ScrolledDataTableRowsProps): import("react/jsx-runtime").JSX.Element;
6
+ export declare function ScrolledDataTableRows<T = unknown>({ scrollableRef, }: ScrolledDataTableRowsProps): import("react/jsx-runtime").JSX.Element;
7
7
  export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ostack.tech/ui",
3
3
  "description": "ostack/UI component library.",
4
- "version": "0.6.3",
4
+ "version": "0.6.4",
5
5
  "homepage": "https://ui.ostack.tech/",
6
6
  "author": {
7
7
  "name": "Opensoft",
@@ -45,7 +45,7 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "@fortawesome/react-fontawesome": "^3.1.1",
48
- "@tanstack/react-virtual": "^3.13.12",
48
+ "@tanstack/react-virtual": "^3.13.13",
49
49
  "cmdk": "^1.1.1",
50
50
  "from-exponential": "^1.1.1",
51
51
  "radix-ui": "^1.4.3",
package/scss/_utils.scss CHANGED
@@ -28,6 +28,7 @@
28
28
  @forward "components/Checkbox/Checkbox-variables";
29
29
  @forward "components/Code/Code-variables";
30
30
  @forward "components/Collapsible/Collapsible-variables";
31
+ @forward "components/DataTable/DataTable-variables";
31
32
  @forward "components/Dialog/Dialog-variables";
32
33
  @forward "components/CommandMenu/CommandMenu-variables";
33
34
  @forward "components/Container/Container-variables";
@@ -36,6 +36,7 @@
36
36
  margin: $calendar-month-padding;
37
37
  border-spacing: 0;
38
38
  border-collapse: collapse;
39
+ font: inherit;
39
40
  }
40
41
 
41
42
  &__weeks,
@@ -0,0 +1,25 @@
1
+ @use "../../scss/base-variables" as *;
2
+ @use "../../scss/utils/spacing" as *;
3
+
4
+ // Cell - Loading
5
+ $data-table-cell-loading-padding-y: spacing(2.5) !default;
6
+ $data-table-cell-loading-padding-x: spacing(3) !default;
7
+
8
+ // Empty message
9
+ $data-table-empty-message-color: var(--#{$prefix}neutral-10) !default;
10
+
11
+ // Filter
12
+ $data-table-filter-max-width: 250px !default;
13
+
14
+ // Rows per page
15
+ $data-table-rows-per-page-gap-x: spacing(1) !default;
16
+
17
+ // Pagination
18
+ $data-table-pagination-gap-x: spacing(2) !default;
19
+
20
+ // Pagination arrows
21
+ $data-table-pagination-arrows-gap-x: spacing(1) !default;
22
+
23
+ // Direct children
24
+ $data-table-child-gap-y: spacing(1) !default;
25
+ $data-table-child-gap-x: spacing(2) !default;
@@ -1,3 +1,4 @@
1
+ @use "DataTable-variables" as *;
1
2
  @use "../ControlCode/ControlCode-variables" as *;
2
3
  @use "../../scss/base-variables" as *;
3
4
  @use "../../scss/utils/breakpoints" as *;
@@ -11,16 +12,9 @@
11
12
  flex-wrap: wrap;
12
13
  align-items: center;
13
14
 
14
- // Clearfix due to usage of floats for the default positioning
15
- &::after {
16
- content: "";
17
- display: table;
18
- clear: both;
19
- }
20
-
21
15
  // Empty message
22
16
  &__empty-message {
23
- color: $neutral-10;
17
+ color: $data-table-empty-message-color;
24
18
  }
25
19
 
26
20
  // When in scrolled mode, the virtualization component uses mock rows
@@ -31,7 +25,8 @@
31
25
  }
32
26
 
33
27
  &__cell[data-loading] {
34
- padding: spacing(2.5) spacing(3) !important;
28
+ padding: $data-table-cell-loading-padding-y
29
+ $data-table-cell-loading-padding-x !important;
35
30
  }
36
31
 
37
32
  // Spinner within a cell
@@ -41,7 +36,7 @@
41
36
 
42
37
  // Filter
43
38
  &__filter-root {
44
- max-width: 250px;
39
+ max-width: $data-table-filter-max-width;
45
40
  }
46
41
 
47
42
  // Rows per page, pagination
@@ -52,7 +47,7 @@
52
47
  }
53
48
 
54
49
  &__rows-per-page-label {
55
- margin-right: spacing(1);
50
+ margin-right: $data-table-rows-per-page-gap-x;
56
51
  }
57
52
 
58
53
  &__rows-per-page-select-root,
@@ -67,40 +62,43 @@
67
62
  }
68
63
 
69
64
  &__pagination-arrows {
70
- margin-left: spacing(2);
65
+ margin-left: $data-table-pagination-gap-x;
71
66
  flex: 0 0 auto;
72
67
 
73
68
  & > :first-child {
74
- margin-right: spacing(1);
69
+ margin-right: $data-table-pagination-arrows-gap-x;
75
70
  }
76
71
  }
77
72
 
73
+ // Selection column
74
+ &__selection-column-cell .#{$prefix}checkbox__container {
75
+ background-color: transparent;
76
+ }
77
+
78
78
  // Auto-layout of data table components (when they're direct children of the
79
79
  // data table):
80
80
 
81
- // Add margins to elements
82
- & > *:not(:last-child) {
83
- margin-bottom: spacing(1);
81
+ // Add spacing to children
82
+ & > *:not(&__content-container) {
83
+ margin-bottom: $data-table-child-gap-y;
84
+ }
85
+ & > &__content-container ~ * {
86
+ margin-top: $data-table-child-gap-y;
87
+ margin-bottom: 0;
84
88
  }
85
-
86
- // Separate elements
87
89
  & > *:not(&__content-container):not(:first-child) {
88
- margin-left: spacing(2);
90
+ margin-left: $data-table-child-gap-x;
89
91
  }
90
92
  & > &__content-container + * {
91
93
  margin-left: 0 !important;
92
94
  }
93
95
 
94
- // The filter, pagination, and selection default to being on the right
95
- & > :is(&__filter-root, &__pagination, &__selection-trigger):first-child,
96
- &
97
- > &__content-container
98
- + :is(&__filter-root, &__pagination, &__selection-trigger) {
99
- margin-left: auto;
96
+ // Some elements prefer to be right-aligned
97
+ & > [data-prefer-right-alignment] {
98
+ margin-left: auto !important;
100
99
  }
101
-
102
- & > :is(.#{$prefix}label__container, &__rows-per-page) {
103
- flex: 1;
100
+ & > [data-prefer-right-alignment] + [data-prefer-right-alignment] {
101
+ margin-left: $data-table-child-gap-x !important;
104
102
  }
105
103
 
106
104
  // Label styles
@@ -114,11 +112,6 @@
114
112
  margin-left: $control-code-label-margin-x;
115
113
  }
116
114
 
117
- // Selection column
118
- &__selection-column-cell .#{$prefix}checkbox__container {
119
- background-color: transparent;
120
- }
121
-
122
115
  @include media-breakpoint-down(sm) {
123
116
  &__rows-per-page,
124
117
  &__pagination {
@@ -17,15 +17,12 @@ $field-group-code-font-size: var(--#{$prefix}font-size-sm) !default;
17
17
  $field-group-code-line-height: var(--#{$prefix}line-height-sm) !default;
18
18
  $field-group-code-font-weight: $font-weight-semibold !default;
19
19
  $field-group-code-border-radius: var(--#{$prefix}border-radius-sm) !default;
20
- $field-group-code-border-color: color.adjust(
21
- $primary-6,
22
- $lightness: 10%
23
- ) !default;
20
+ $field-group-code-border-color: var(--#{$prefix}primary-a5) !default;
24
21
  $field-group-code-background-color: var(--#{$prefix}background-color) !default;
25
- $field-group-code-color: $primary-9 !default;
22
+ $field-group-code-color: var(--#{$prefix}primary-11) !default;
26
23
 
27
24
  // Field group title
28
- $field-group-title-font-size: var(--#{$prefix}font-size-lg) !default;
29
- $field-group-title-line-height: var(--#{$prefix}line-height-lg) !default;
30
- $field-group-title-font-weight: $font-weight-semibold !default;
31
- $field-group-title-color: color.adjust($primary-11, $lightness: -5%) !default;
25
+ $field-group-title-font-size: var(--#{$prefix}font-size-sm) !default;
26
+ $field-group-title-line-height: var(--#{$prefix}line-height-sm) !default;
27
+ $field-group-title-font-weight: $font-weight-medium !default;
28
+ $field-group-title-color: var(--#{$prefix}primary-11) !default;