@dbcdk/react-components 0.0.127 → 0.0.129
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/components/page-layout/PageLayout.cjs +22 -5
- package/dist/components/page-layout/PageLayout.d.ts +8 -0
- package/dist/components/page-layout/PageLayout.js +22 -5
- package/dist/components/page-layout/PageLayout.module.css +6 -0
- package/dist/components/table/TanstackTable.cjs +1 -1
- package/dist/components/table/TanstackTable.js +1 -1
- package/dist/components/table/tanstackTable.utils.cjs +12 -6
- package/dist/components/table/tanstackTable.utils.d.ts +3 -1
- package/dist/components/table/tanstackTable.utils.js +12 -6
- package/dist/styles/themes/dbc/colors.css +1 -1
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var react = require('react');
|
|
5
|
+
var EnvironmentBanner = require('../../components/environment-banner/EnvironmentBanner');
|
|
5
6
|
var styles = require('./PageLayout.module.css');
|
|
6
7
|
|
|
7
8
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -13,6 +14,17 @@ function getMaxWidthClass(value, styles2) {
|
|
|
13
14
|
if (value === "sm") return styles2.maxWidthSm;
|
|
14
15
|
return styles2.maxWidthMd;
|
|
15
16
|
}
|
|
17
|
+
const VALID_ENVIRONMENTS = ["production", "staging", "test"];
|
|
18
|
+
function resolveEnvBanner(environment, customEnv, customEnvSeverity) {
|
|
19
|
+
if (customEnv != null && customEnvSeverity != null) {
|
|
20
|
+
return /* @__PURE__ */ jsxRuntime.jsx(EnvironmentBanner.EnvironmentBanner, { customLabel: customEnv, customSeverity: customEnvSeverity });
|
|
21
|
+
}
|
|
22
|
+
const normalised = environment == null ? void 0 : environment.toLowerCase();
|
|
23
|
+
if (normalised != null && VALID_ENVIRONMENTS.includes(normalised)) {
|
|
24
|
+
return /* @__PURE__ */ jsxRuntime.jsx(EnvironmentBanner.EnvironmentBanner, { environment: normalised });
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
16
28
|
function getSlotName(el) {
|
|
17
29
|
var _a;
|
|
18
30
|
const t = el.type;
|
|
@@ -71,19 +83,24 @@ PageLayoutFooter.__PAGE_LAYOUT_SLOT__ = "Footer";
|
|
|
71
83
|
const PageLayoutBase = ({
|
|
72
84
|
children,
|
|
73
85
|
containScrolling = false,
|
|
74
|
-
orientation = "vertical"
|
|
86
|
+
orientation = "vertical",
|
|
87
|
+
environment,
|
|
88
|
+
customEnv,
|
|
89
|
+
customEnvSeverity
|
|
75
90
|
}) => {
|
|
76
|
-
var _a;
|
|
91
|
+
var _a, _b;
|
|
77
92
|
const { slots, rest } = splitSlots(children);
|
|
93
|
+
const envBanner = resolveEnvBanner(environment, customEnv, customEnvSeverity);
|
|
78
94
|
const content = (_a = slots.Content) != null ? _a : rest.length ? /* @__PURE__ */ jsxRuntime.jsx(PageLayoutContent, { maxWidth: "md", children: rest }) : void 0;
|
|
79
95
|
const rootClass = [
|
|
80
96
|
styles__default.default.root,
|
|
81
97
|
orientation === "vertical" ? styles__default.default.vertical : styles__default.default.horizontal,
|
|
82
98
|
containScrolling ? styles__default.default.containScrolling : styles__default.default.documentScrolling,
|
|
83
|
-
slots.Banner ? styles__default.default.hasBanner : ""
|
|
99
|
+
slots.Banner || envBanner ? styles__default.default.hasBanner : ""
|
|
84
100
|
].filter(Boolean).join(" ");
|
|
85
|
-
|
|
86
|
-
|
|
101
|
+
const banner = (_b = slots.Banner) != null ? _b : envBanner;
|
|
102
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: rootClass, "data-contain-scrolling": containScrolling || void 0, children: [
|
|
103
|
+
banner ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles__default.default.banner, children: banner }) : null,
|
|
87
104
|
slots.Sidebar ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles__default.default.sidebar, children: slots.Sidebar }) : null,
|
|
88
105
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles__default.default.mainColumn, children: [
|
|
89
106
|
slots.Header ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles__default.default.header, children: slots.Header }) : null,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { FC, PropsWithChildren, ReactNode } from 'react';
|
|
2
|
+
import type { Severity } from '../../constants/severity.types';
|
|
2
3
|
type Orientation = 'vertical' | 'horizontal';
|
|
3
4
|
export type PageLayoutMaxWidth = boolean | 'sm' | 'md';
|
|
4
5
|
export interface PageLayoutProps extends PropsWithChildren {
|
|
@@ -9,6 +10,13 @@ export interface PageLayoutProps extends PropsWithChildren {
|
|
|
9
10
|
*/
|
|
10
11
|
containScrolling?: boolean;
|
|
11
12
|
orientation?: Orientation;
|
|
13
|
+
/** Pass a deployment environment string (e.g. process.env.DEPLOYMENT_ENV).
|
|
14
|
+
* Renders a banner for 'production', 'staging', or 'test'. Ignored for unknown values or undefined. */
|
|
15
|
+
environment?: string;
|
|
16
|
+
/** Custom banner label — requires customEnvSeverity. */
|
|
17
|
+
customEnv?: string;
|
|
18
|
+
/** Severity for the custom banner. */
|
|
19
|
+
customEnvSeverity?: Severity;
|
|
12
20
|
}
|
|
13
21
|
export interface PageLayoutHeaderProps {
|
|
14
22
|
maxWidth?: PageLayoutMaxWidth;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { Children, isValidElement } from 'react';
|
|
3
|
+
import { EnvironmentBanner } from '../../components/environment-banner/EnvironmentBanner';
|
|
3
4
|
import styles from './PageLayout.module.css';
|
|
4
5
|
|
|
5
6
|
function getMaxWidthClass(value, styles2) {
|
|
@@ -7,6 +8,17 @@ function getMaxWidthClass(value, styles2) {
|
|
|
7
8
|
if (value === "sm") return styles2.maxWidthSm;
|
|
8
9
|
return styles2.maxWidthMd;
|
|
9
10
|
}
|
|
11
|
+
const VALID_ENVIRONMENTS = ["production", "staging", "test"];
|
|
12
|
+
function resolveEnvBanner(environment, customEnv, customEnvSeverity) {
|
|
13
|
+
if (customEnv != null && customEnvSeverity != null) {
|
|
14
|
+
return /* @__PURE__ */ jsx(EnvironmentBanner, { customLabel: customEnv, customSeverity: customEnvSeverity });
|
|
15
|
+
}
|
|
16
|
+
const normalised = environment == null ? void 0 : environment.toLowerCase();
|
|
17
|
+
if (normalised != null && VALID_ENVIRONMENTS.includes(normalised)) {
|
|
18
|
+
return /* @__PURE__ */ jsx(EnvironmentBanner, { environment: normalised });
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
10
22
|
function getSlotName(el) {
|
|
11
23
|
var _a;
|
|
12
24
|
const t = el.type;
|
|
@@ -65,19 +77,24 @@ PageLayoutFooter.__PAGE_LAYOUT_SLOT__ = "Footer";
|
|
|
65
77
|
const PageLayoutBase = ({
|
|
66
78
|
children,
|
|
67
79
|
containScrolling = false,
|
|
68
|
-
orientation = "vertical"
|
|
80
|
+
orientation = "vertical",
|
|
81
|
+
environment,
|
|
82
|
+
customEnv,
|
|
83
|
+
customEnvSeverity
|
|
69
84
|
}) => {
|
|
70
|
-
var _a;
|
|
85
|
+
var _a, _b;
|
|
71
86
|
const { slots, rest } = splitSlots(children);
|
|
87
|
+
const envBanner = resolveEnvBanner(environment, customEnv, customEnvSeverity);
|
|
72
88
|
const content = (_a = slots.Content) != null ? _a : rest.length ? /* @__PURE__ */ jsx(PageLayoutContent, { maxWidth: "md", children: rest }) : void 0;
|
|
73
89
|
const rootClass = [
|
|
74
90
|
styles.root,
|
|
75
91
|
orientation === "vertical" ? styles.vertical : styles.horizontal,
|
|
76
92
|
containScrolling ? styles.containScrolling : styles.documentScrolling,
|
|
77
|
-
slots.Banner ? styles.hasBanner : ""
|
|
93
|
+
slots.Banner || envBanner ? styles.hasBanner : ""
|
|
78
94
|
].filter(Boolean).join(" ");
|
|
79
|
-
|
|
80
|
-
|
|
95
|
+
const banner = (_b = slots.Banner) != null ? _b : envBanner;
|
|
96
|
+
return /* @__PURE__ */ jsxs("div", { className: rootClass, "data-contain-scrolling": containScrolling || void 0, children: [
|
|
97
|
+
banner ? /* @__PURE__ */ jsx("div", { className: styles.banner, children: banner }) : null,
|
|
81
98
|
slots.Sidebar ? /* @__PURE__ */ jsx("div", { className: styles.sidebar, children: slots.Sidebar }) : null,
|
|
82
99
|
/* @__PURE__ */ jsxs("div", { className: styles.mainColumn, children: [
|
|
83
100
|
slots.Header ? /* @__PURE__ */ jsx("div", { className: styles.header, children: slots.Header }) : null,
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/* When PageLayout owns scrolling, the body shouldn't reserve scrollbar gutter space.
|
|
2
|
+
This prevents the right-side gap that body { overflow-y: scroll } would otherwise create. */
|
|
3
|
+
:global(body):has([data-contain-scrolling]) {
|
|
4
|
+
overflow: hidden;
|
|
5
|
+
}
|
|
6
|
+
|
|
1
7
|
/* Root shell */
|
|
2
8
|
.root {
|
|
3
9
|
width: 100%;
|
|
@@ -177,7 +177,7 @@ function TanstackTable(props) {
|
|
|
177
177
|
dataKey,
|
|
178
178
|
data: visibleData,
|
|
179
179
|
columns: columnItems,
|
|
180
|
-
tableWidth: distributedLayout == null ? void 0 : distributedLayout.totalWidth,
|
|
180
|
+
tableWidth: (distributedLayout == null ? void 0 : distributedLayout.shouldOverflow) ? distributedLayout.totalWidth : void 0,
|
|
181
181
|
measuringLayout: !initialLayoutReady,
|
|
182
182
|
sortById,
|
|
183
183
|
sortDirection,
|
|
@@ -152,7 +152,7 @@ function TanstackTable(props) {
|
|
|
152
152
|
dataKey,
|
|
153
153
|
data: visibleData,
|
|
154
154
|
columns: columnItems,
|
|
155
|
-
tableWidth: distributedLayout == null ? void 0 : distributedLayout.totalWidth,
|
|
155
|
+
tableWidth: (distributedLayout == null ? void 0 : distributedLayout.shouldOverflow) ? distributedLayout.totalWidth : void 0,
|
|
156
156
|
measuringLayout: !initialLayoutReady,
|
|
157
157
|
sortById,
|
|
158
158
|
sortDirection,
|
|
@@ -93,7 +93,14 @@ function toIntegerTrackWidths(tracks, targetWidth) {
|
|
|
93
93
|
return Object.fromEntries(floored.map((track) => [track.id, track.width]));
|
|
94
94
|
}
|
|
95
95
|
function buildDistributedColumnWidths(args) {
|
|
96
|
-
const {
|
|
96
|
+
const {
|
|
97
|
+
table,
|
|
98
|
+
hasSelection,
|
|
99
|
+
hasContextMenu = false,
|
|
100
|
+
defaultMinPx,
|
|
101
|
+
columnSizing,
|
|
102
|
+
availableWidth
|
|
103
|
+
} = args;
|
|
97
104
|
const leaf = table.getVisibleLeafColumns();
|
|
98
105
|
const selectionWidth = hasSelection ? table_utils.SELECTION_COLUMN_PX : 0;
|
|
99
106
|
const contextMenuWidth = hasContextMenu ? table_utils.CONTEXT_MENU_COLUMN_PX : 0;
|
|
@@ -155,15 +162,14 @@ function buildDistributedColumnWidths(args) {
|
|
|
155
162
|
maxTrackWidth
|
|
156
163
|
);
|
|
157
164
|
const widths = toIntegerTrackWidths(tracks, targetTrackWidth);
|
|
158
|
-
const totalWidth =
|
|
159
|
-
selectionWidth + contextMenuWidth + Object.values(widths).reduce((sum, width) => sum + width, 0),
|
|
160
|
-
availableWidth
|
|
161
|
-
);
|
|
165
|
+
const totalWidth = selectionWidth + contextMenuWidth + Object.values(widths).reduce((sum, width) => sum + width, 0);
|
|
162
166
|
return {
|
|
163
167
|
selectionWidth: hasSelection ? table_utils.SELECTION_COLUMN_PX : void 0,
|
|
164
168
|
contextMenuWidth: hasContextMenu ? table_utils.CONTEXT_MENU_COLUMN_PX : void 0,
|
|
165
169
|
widths,
|
|
166
|
-
totalWidth
|
|
170
|
+
totalWidth,
|
|
171
|
+
availableWidth,
|
|
172
|
+
shouldOverflow: totalWidth > availableWidth
|
|
167
173
|
};
|
|
168
174
|
}
|
|
169
175
|
|
|
@@ -14,7 +14,7 @@ export declare function getSortPropsFromSorting(sorting: SortingState): {
|
|
|
14
14
|
export declare function buildDistributedColumnWidths(args: {
|
|
15
15
|
table: any;
|
|
16
16
|
hasSelection: boolean;
|
|
17
|
-
hasContextMenu
|
|
17
|
+
hasContextMenu?: boolean;
|
|
18
18
|
defaultMinPx: number;
|
|
19
19
|
columnSizing: ColumnSizingState;
|
|
20
20
|
availableWidth: number;
|
|
@@ -23,5 +23,7 @@ export declare function buildDistributedColumnWidths(args: {
|
|
|
23
23
|
contextMenuWidth?: number;
|
|
24
24
|
widths: Record<string, number>;
|
|
25
25
|
totalWidth: number;
|
|
26
|
+
availableWidth: number;
|
|
27
|
+
shouldOverflow: boolean;
|
|
26
28
|
};
|
|
27
29
|
export {};
|
|
@@ -91,7 +91,14 @@ function toIntegerTrackWidths(tracks, targetWidth) {
|
|
|
91
91
|
return Object.fromEntries(floored.map((track) => [track.id, track.width]));
|
|
92
92
|
}
|
|
93
93
|
function buildDistributedColumnWidths(args) {
|
|
94
|
-
const {
|
|
94
|
+
const {
|
|
95
|
+
table,
|
|
96
|
+
hasSelection,
|
|
97
|
+
hasContextMenu = false,
|
|
98
|
+
defaultMinPx,
|
|
99
|
+
columnSizing,
|
|
100
|
+
availableWidth
|
|
101
|
+
} = args;
|
|
95
102
|
const leaf = table.getVisibleLeafColumns();
|
|
96
103
|
const selectionWidth = hasSelection ? SELECTION_COLUMN_PX : 0;
|
|
97
104
|
const contextMenuWidth = hasContextMenu ? CONTEXT_MENU_COLUMN_PX : 0;
|
|
@@ -153,15 +160,14 @@ function buildDistributedColumnWidths(args) {
|
|
|
153
160
|
maxTrackWidth
|
|
154
161
|
);
|
|
155
162
|
const widths = toIntegerTrackWidths(tracks, targetTrackWidth);
|
|
156
|
-
const totalWidth =
|
|
157
|
-
selectionWidth + contextMenuWidth + Object.values(widths).reduce((sum, width) => sum + width, 0),
|
|
158
|
-
availableWidth
|
|
159
|
-
);
|
|
163
|
+
const totalWidth = selectionWidth + contextMenuWidth + Object.values(widths).reduce((sum, width) => sum + width, 0);
|
|
160
164
|
return {
|
|
161
165
|
selectionWidth: hasSelection ? SELECTION_COLUMN_PX : void 0,
|
|
162
166
|
contextMenuWidth: hasContextMenu ? CONTEXT_MENU_COLUMN_PX : void 0,
|
|
163
167
|
widths,
|
|
164
|
-
totalWidth
|
|
168
|
+
totalWidth,
|
|
169
|
+
availableWidth,
|
|
170
|
+
shouldOverflow: totalWidth > availableWidth
|
|
165
171
|
};
|
|
166
172
|
}
|
|
167
173
|
|
|
@@ -29,7 +29,7 @@ html {
|
|
|
29
29
|
--dbc-neutral-900: light-dark(#1a1a1a, #f9fafb);
|
|
30
30
|
--dbc-neutral-700: light-dark(#374151, #d1d5db);
|
|
31
31
|
--dbc-neutral-600: light-dark(#5f6368, #9ca3af);
|
|
32
|
-
--dbc-neutral-200: light-dark(#
|
|
32
|
+
--dbc-neutral-200: light-dark(#e8eaee, #374151);
|
|
33
33
|
--dbc-neutral-100: light-dark(#f3f4f6, #1f2937);
|
|
34
34
|
|
|
35
35
|
/* Added fixed surface neutrals */
|