@gobolt/genesis 0.4.2 → 0.4.3

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.
@@ -5,12 +5,14 @@ import * as React from "react";
5
5
  export type Change = (actionEvent: ActionEvent) => void;
6
6
  export type SelectionType = "checkbox" | "radio";
7
7
  export interface MaterializedViewConfig<T = any> {
8
- height?: number | string;
8
+ height?: number | string | "dynamic";
9
9
  onLoadMore?: (offset: number, limit: number) => Promise<T[]> | T[];
10
10
  loadMoreThreshold?: number;
11
11
  initialLoadSize?: number;
12
12
  hasMore?: boolean;
13
13
  loading?: boolean;
14
+ maxHeight?: number | string;
15
+ minHeight?: number | string;
14
16
  }
15
17
  export interface TableProps<T extends Record<string, any>> {
16
18
  dataSource: T[];
package/dist/index.cjs CHANGED
@@ -83174,10 +83174,16 @@ const getGenesisClass$1 = ({ colors: colors2, borderRadius: borderRadius2, sizin
83174
83174
  return `
83175
83175
  &.ant-table-wrapper {
83176
83176
  // Add your custom styles here
83177
+ border-radius: 0 !important;
83177
83178
  }
83178
83179
 
83179
83180
  .ant-table {
83180
83181
  // Add your custom table styles here
83182
+ border-radius: 0 !important;
83183
+ }
83184
+
83185
+ .ant-table-container {
83186
+ border-radius: 0 !important;
83181
83187
  }
83182
83188
 
83183
83189
  .ant-table-cell {
@@ -83202,6 +83208,16 @@ const getGenesisClass$1 = ({ colors: colors2, borderRadius: borderRadius2, sizin
83202
83208
  font-size: ${$isMainContentCell ? "16px" : "14px"} !important;
83203
83209
  font-weight: 400;
83204
83210
  color: ${$isMainContentCell ? colors2.onsurface.copy : colors2.onsurface["copy-light"]} !important;
83211
+ background-color: #F4F4F4 !important;
83212
+ border-radius: 0 !important;
83213
+ }
83214
+
83215
+ .ant-table-thead > tr:first-child > th:first-child {
83216
+ border-top-left-radius: 0 !important;
83217
+ }
83218
+
83219
+ .ant-table-thead > tr:first-child > th:last-child {
83220
+ border-top-right-radius: 0 !important;
83205
83221
  }
83206
83222
 
83207
83223
  .ant-table-tbody > tr {
@@ -83677,7 +83693,32 @@ function Table({
83677
83693
  const [materializedData, setMaterializedData] = React__namespace.useState([]);
83678
83694
  const [isLoadingMore, setIsLoadingMore] = React__namespace.useState(false);
83679
83695
  const [hasMoreData, setHasMoreData] = React__namespace.useState(true);
83696
+ const [dynamicHeight, setDynamicHeight] = React__namespace.useState(
83697
+ 400
83698
+ );
83680
83699
  const tableRef = React__namespace.useRef(null);
83700
+ const containerRef = React__namespace.useRef(null);
83701
+ React__namespace.useEffect(() => {
83702
+ if (isMaterializedView && materializedViewConfig?.height === "dynamic") {
83703
+ const calculateHeight = () => {
83704
+ if (!containerRef.current) return;
83705
+ const container = containerRef.current;
83706
+ const rect = container.getBoundingClientRect();
83707
+ const viewportHeight = window.innerHeight;
83708
+ const availableHeight = viewportHeight - rect.top - 100;
83709
+ const minHeight = typeof materializedViewConfig.minHeight === "number" ? materializedViewConfig.minHeight : 200;
83710
+ const maxHeight = typeof materializedViewConfig.maxHeight === "number" ? materializedViewConfig.maxHeight : availableHeight;
83711
+ const calculatedHeight = Math.max(
83712
+ minHeight,
83713
+ Math.min(maxHeight, availableHeight)
83714
+ );
83715
+ setDynamicHeight(calculatedHeight);
83716
+ };
83717
+ calculateHeight();
83718
+ window.addEventListener("resize", calculateHeight);
83719
+ return () => window.removeEventListener("resize", calculateHeight);
83720
+ }
83721
+ }, [isMaterializedView, materializedViewConfig]);
83681
83722
  React__namespace.useEffect(() => {
83682
83723
  if (isMaterializedView) {
83683
83724
  const initialSize = materializedViewConfig?.initialLoadSize || 50;
@@ -83748,15 +83789,16 @@ function Table({
83748
83789
  }, [isMaterializedView, pagination]);
83749
83790
  const scrollConfig = React__namespace.useMemo(() => {
83750
83791
  if (isMaterializedView) {
83792
+ const height = materializedViewConfig?.height === "dynamic" ? dynamicHeight : materializedViewConfig?.height || 400;
83751
83793
  return {
83752
83794
  ...rest.scroll,
83753
- y: materializedViewConfig?.height || 400
83795
+ y: height
83754
83796
  };
83755
83797
  }
83756
83798
  return rest.scroll;
83757
- }, [isMaterializedView, materializedViewConfig, rest.scroll]);
83799
+ }, [isMaterializedView, materializedViewConfig, dynamicHeight, rest.scroll]);
83758
83800
  const tableDataSource = isMaterializedView ? materializedData : dataSource;
83759
- return /* @__PURE__ */ jsxRuntime.jsx(
83801
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: containerRef, children: /* @__PURE__ */ jsxRuntime.jsx(
83760
83802
  Table$1,
83761
83803
  {
83762
83804
  ref: tableRef,
@@ -83774,7 +83816,7 @@ function Table({
83774
83816
  $isMainContentCell: isMainContentCell,
83775
83817
  ...rest
83776
83818
  }
83777
- );
83819
+ ) });
83778
83820
  }
83779
83821
  const TablePagination = ({
83780
83822
  columns,
package/dist/index.js CHANGED
@@ -83156,10 +83156,16 @@ const getGenesisClass$1 = ({ colors: colors2, borderRadius: borderRadius2, sizin
83156
83156
  return `
83157
83157
  &.ant-table-wrapper {
83158
83158
  // Add your custom styles here
83159
+ border-radius: 0 !important;
83159
83160
  }
83160
83161
 
83161
83162
  .ant-table {
83162
83163
  // Add your custom table styles here
83164
+ border-radius: 0 !important;
83165
+ }
83166
+
83167
+ .ant-table-container {
83168
+ border-radius: 0 !important;
83163
83169
  }
83164
83170
 
83165
83171
  .ant-table-cell {
@@ -83184,6 +83190,16 @@ const getGenesisClass$1 = ({ colors: colors2, borderRadius: borderRadius2, sizin
83184
83190
  font-size: ${$isMainContentCell ? "16px" : "14px"} !important;
83185
83191
  font-weight: 400;
83186
83192
  color: ${$isMainContentCell ? colors2.onsurface.copy : colors2.onsurface["copy-light"]} !important;
83193
+ background-color: #F4F4F4 !important;
83194
+ border-radius: 0 !important;
83195
+ }
83196
+
83197
+ .ant-table-thead > tr:first-child > th:first-child {
83198
+ border-top-left-radius: 0 !important;
83199
+ }
83200
+
83201
+ .ant-table-thead > tr:first-child > th:last-child {
83202
+ border-top-right-radius: 0 !important;
83187
83203
  }
83188
83204
 
83189
83205
  .ant-table-tbody > tr {
@@ -83659,7 +83675,32 @@ function Table({
83659
83675
  const [materializedData, setMaterializedData] = React.useState([]);
83660
83676
  const [isLoadingMore, setIsLoadingMore] = React.useState(false);
83661
83677
  const [hasMoreData, setHasMoreData] = React.useState(true);
83678
+ const [dynamicHeight, setDynamicHeight] = React.useState(
83679
+ 400
83680
+ );
83662
83681
  const tableRef = React.useRef(null);
83682
+ const containerRef = React.useRef(null);
83683
+ React.useEffect(() => {
83684
+ if (isMaterializedView && materializedViewConfig?.height === "dynamic") {
83685
+ const calculateHeight = () => {
83686
+ if (!containerRef.current) return;
83687
+ const container = containerRef.current;
83688
+ const rect = container.getBoundingClientRect();
83689
+ const viewportHeight = window.innerHeight;
83690
+ const availableHeight = viewportHeight - rect.top - 100;
83691
+ const minHeight = typeof materializedViewConfig.minHeight === "number" ? materializedViewConfig.minHeight : 200;
83692
+ const maxHeight = typeof materializedViewConfig.maxHeight === "number" ? materializedViewConfig.maxHeight : availableHeight;
83693
+ const calculatedHeight = Math.max(
83694
+ minHeight,
83695
+ Math.min(maxHeight, availableHeight)
83696
+ );
83697
+ setDynamicHeight(calculatedHeight);
83698
+ };
83699
+ calculateHeight();
83700
+ window.addEventListener("resize", calculateHeight);
83701
+ return () => window.removeEventListener("resize", calculateHeight);
83702
+ }
83703
+ }, [isMaterializedView, materializedViewConfig]);
83663
83704
  React.useEffect(() => {
83664
83705
  if (isMaterializedView) {
83665
83706
  const initialSize = materializedViewConfig?.initialLoadSize || 50;
@@ -83730,15 +83771,16 @@ function Table({
83730
83771
  }, [isMaterializedView, pagination]);
83731
83772
  const scrollConfig = React.useMemo(() => {
83732
83773
  if (isMaterializedView) {
83774
+ const height = materializedViewConfig?.height === "dynamic" ? dynamicHeight : materializedViewConfig?.height || 400;
83733
83775
  return {
83734
83776
  ...rest.scroll,
83735
- y: materializedViewConfig?.height || 400
83777
+ y: height
83736
83778
  };
83737
83779
  }
83738
83780
  return rest.scroll;
83739
- }, [isMaterializedView, materializedViewConfig, rest.scroll]);
83781
+ }, [isMaterializedView, materializedViewConfig, dynamicHeight, rest.scroll]);
83740
83782
  const tableDataSource = isMaterializedView ? materializedData : dataSource;
83741
- return /* @__PURE__ */ jsx(
83783
+ return /* @__PURE__ */ jsx("div", { ref: containerRef, children: /* @__PURE__ */ jsx(
83742
83784
  Table$1,
83743
83785
  {
83744
83786
  ref: tableRef,
@@ -83756,7 +83798,7 @@ function Table({
83756
83798
  $isMainContentCell: isMainContentCell,
83757
83799
  ...rest
83758
83800
  }
83759
- );
83801
+ ) });
83760
83802
  }
83761
83803
  const TablePagination = ({
83762
83804
  columns,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gobolt/genesis",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "genesis design system",
5
5
  "author": "gobolt",
6
6
  "license": "MIT",