@gobolt/genesis 0.4.1 → 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.
@@ -1,4 +1,4 @@
1
- import { BadgeProps } from '../..';
1
+ import { BadgeProps } from '../Badge';
2
2
  import { Action } from './RowActions/RowActions';
3
3
  export interface RowProps {
4
4
  label: string;
@@ -1,4 +1,4 @@
1
- import { BadgeProps } from '../..';
1
+ import { BadgeProps } from '../../Badge';
2
2
  interface RowLabelValueProperties {
3
3
  label: string;
4
4
  value: string;
@@ -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[];
@@ -1,12 +1,10 @@
1
1
  import { TableProps } from '../Table';
2
2
  import { TableControlsData } from '../Table/TableControls/TableControls';
3
+ import { ActionEvent, TableEventPayload } from '../../types/events';
3
4
  export interface TableWithControlsProps {
4
5
  tableControlsData: TableControlsData;
5
6
  tableData: TableProps<Record<string, any>>;
6
- onChange: (event: {
7
- event: string;
8
- payload: any;
9
- }) => void;
7
+ onChange: (event: ActionEvent<TableEventPayload>) => void;
10
8
  }
11
9
  declare const TableWithControls: ({ tableData, tableControlsData, onChange, }: TableWithControlsProps) => import("react/jsx-runtime").JSX.Element;
12
10
  export default TableWithControls;
package/dist/index.cjs CHANGED
@@ -82128,6 +82128,9 @@ const getTextComponent = (firstBarData, secondBarData, stateColor, theme, isText
82128
82128
  );
82129
82129
  };
82130
82130
  const getCombinedPercent = (firstBarData, secondBarData) => {
82131
+ if (secondBarData?.value === 0) {
82132
+ return firstBarData?.value;
82133
+ }
82131
82134
  if (firstBarData?.value && secondBarData?.value) {
82132
82135
  const total = firstBarData?.value + secondBarData?.value;
82133
82136
  const dividedBy = total / 2;
@@ -82402,7 +82405,7 @@ const Radio = ({ id: id2, label, selectedId, onChange, isDisabled }) => {
82402
82405
  RadioWrapper,
82403
82406
  {
82404
82407
  ref: radioReference,
82405
- $isDisabled: isDisabled,
82408
+ $isDisabled: isDisabled ?? false,
82406
82409
  onFocus: (e3) => {
82407
82410
  if (isDisabled || e3.target !== radioReference.current) return;
82408
82411
  setIsFocused(true);
@@ -82571,7 +82574,7 @@ const RowLabelValue = ({
82571
82574
  children: label
82572
82575
  }
82573
82576
  ) }),
82574
- /* @__PURE__ */ jsxRuntime.jsx("div", { children: isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(RowSkeleton, { isFullWidth }) }) : getBadgeOrTypography(badgeProps, value2) })
82577
+ /* @__PURE__ */ jsxRuntime.jsx("div", { children: isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(RowSkeleton, { isFullWidth: isFullWidth ?? false }) }) : getBadgeOrTypography(badgeProps, value2) })
82575
82578
  ] });
82576
82579
  };
82577
82580
  const ActionsContainer = styled.div`
@@ -82621,13 +82624,13 @@ const Row = ({
82621
82624
  RowLabelValue,
82622
82625
  {
82623
82626
  label,
82624
- value: value2,
82627
+ value: value2 ?? "",
82625
82628
  isFullWidth,
82626
82629
  isLoading,
82627
82630
  badgeProps: badgeProperties
82628
82631
  }
82629
82632
  ),
82630
- /* @__PURE__ */ jsxRuntime.jsx(RowActions, { actions })
82633
+ /* @__PURE__ */ jsxRuntime.jsx(RowActions, { actions: actions ?? null })
82631
82634
  ]
82632
82635
  }
82633
82636
  );
@@ -82682,11 +82685,14 @@ const SegmentedControls = ({
82682
82685
  value: id2,
82683
82686
  icon
82684
82687
  }));
82688
+ const handleChange = (value2) => {
82689
+ onChange(String(value2));
82690
+ };
82685
82691
  return /* @__PURE__ */ jsxRuntime.jsx(
82686
82692
  SegmentedControls$1,
82687
82693
  {
82688
82694
  options: antOptions,
82689
- onChange,
82695
+ onChange: handleChange,
82690
82696
  value: selectedTabId,
82691
82697
  block: isScaled
82692
82698
  }
@@ -82944,6 +82950,7 @@ const Select = ({
82944
82950
  }
82945
82951
  };
82946
82952
  const getSelectModeValue = (value22) => {
82953
+ if (!value22) return "";
82947
82954
  if (Array.isArray(value22)) {
82948
82955
  if (selectDisplayMode === "count") {
82949
82956
  return `${value22.length} selected`;
@@ -83167,10 +83174,16 @@ const getGenesisClass$1 = ({ colors: colors2, borderRadius: borderRadius2, sizin
83167
83174
  return `
83168
83175
  &.ant-table-wrapper {
83169
83176
  // Add your custom styles here
83177
+ border-radius: 0 !important;
83170
83178
  }
83171
83179
 
83172
83180
  .ant-table {
83173
83181
  // Add your custom table styles here
83182
+ border-radius: 0 !important;
83183
+ }
83184
+
83185
+ .ant-table-container {
83186
+ border-radius: 0 !important;
83174
83187
  }
83175
83188
 
83176
83189
  .ant-table-cell {
@@ -83195,6 +83208,16 @@ const getGenesisClass$1 = ({ colors: colors2, borderRadius: borderRadius2, sizin
83195
83208
  font-size: ${$isMainContentCell ? "16px" : "14px"} !important;
83196
83209
  font-weight: 400;
83197
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;
83198
83221
  }
83199
83222
 
83200
83223
  .ant-table-tbody > tr {
@@ -83670,7 +83693,32 @@ function Table({
83670
83693
  const [materializedData, setMaterializedData] = React__namespace.useState([]);
83671
83694
  const [isLoadingMore, setIsLoadingMore] = React__namespace.useState(false);
83672
83695
  const [hasMoreData, setHasMoreData] = React__namespace.useState(true);
83696
+ const [dynamicHeight, setDynamicHeight] = React__namespace.useState(
83697
+ 400
83698
+ );
83673
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]);
83674
83722
  React__namespace.useEffect(() => {
83675
83723
  if (isMaterializedView) {
83676
83724
  const initialSize = materializedViewConfig?.initialLoadSize || 50;
@@ -83741,15 +83789,16 @@ function Table({
83741
83789
  }, [isMaterializedView, pagination]);
83742
83790
  const scrollConfig = React__namespace.useMemo(() => {
83743
83791
  if (isMaterializedView) {
83792
+ const height = materializedViewConfig?.height === "dynamic" ? dynamicHeight : materializedViewConfig?.height || 400;
83744
83793
  return {
83745
83794
  ...rest.scroll,
83746
- y: materializedViewConfig?.height || 400
83795
+ y: height
83747
83796
  };
83748
83797
  }
83749
83798
  return rest.scroll;
83750
- }, [isMaterializedView, materializedViewConfig, rest.scroll]);
83799
+ }, [isMaterializedView, materializedViewConfig, dynamicHeight, rest.scroll]);
83751
83800
  const tableDataSource = isMaterializedView ? materializedData : dataSource;
83752
- return /* @__PURE__ */ jsxRuntime.jsx(
83801
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: containerRef, children: /* @__PURE__ */ jsxRuntime.jsx(
83753
83802
  Table$1,
83754
83803
  {
83755
83804
  ref: tableRef,
@@ -83767,7 +83816,7 @@ function Table({
83767
83816
  $isMainContentCell: isMainContentCell,
83768
83817
  ...rest
83769
83818
  }
83770
- );
83819
+ ) });
83771
83820
  }
83772
83821
  const TablePagination = ({
83773
83822
  columns,
@@ -83935,7 +83984,7 @@ const PrimaryTableControlsRow = ({
83935
83984
  const onSortChange = (value2) => {
83936
83985
  const sortActionEvent = {
83937
83986
  event: "primarySortChange",
83938
- payload: { value: value2 }
83987
+ payload: { value: Array.isArray(value2) ? value2[0] : value2 }
83939
83988
  };
83940
83989
  onChange?.(sortActionEvent);
83941
83990
  };
@@ -84137,7 +84186,7 @@ const SecondaryTableControlsRow = ({
84137
84186
  },
84138
84187
  children: [
84139
84188
  /* @__PURE__ */ jsxRuntime.jsx(GroupsRow, { groups, onGroupItemClick }),
84140
- totalRecords > 0 ? /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "body2", color: "#6C6C6C", children: `${totalRecords} results` }) : null
84189
+ (totalRecords ?? 0) > 0 ? /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "body2", color: "#6C6C6C", children: `${totalRecords} results` }) : null
84141
84190
  ]
84142
84191
  }
84143
84192
  );
@@ -84198,7 +84247,7 @@ const TableWithControls = ({
84198
84247
  const onTableChange = (pagination, filters, sorter) => {
84199
84248
  onChange({
84200
84249
  event: "tableChange",
84201
- payload: { pagination, filters, sorter }
84250
+ payload: { value: "tableChange", pagination, filters, sorter }
84202
84251
  });
84203
84252
  };
84204
84253
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
package/dist/index.js CHANGED
@@ -82110,6 +82110,9 @@ const getTextComponent = (firstBarData, secondBarData, stateColor, theme, isText
82110
82110
  );
82111
82111
  };
82112
82112
  const getCombinedPercent = (firstBarData, secondBarData) => {
82113
+ if (secondBarData?.value === 0) {
82114
+ return firstBarData?.value;
82115
+ }
82113
82116
  if (firstBarData?.value && secondBarData?.value) {
82114
82117
  const total = firstBarData?.value + secondBarData?.value;
82115
82118
  const dividedBy = total / 2;
@@ -82384,7 +82387,7 @@ const Radio = ({ id: id2, label, selectedId, onChange, isDisabled }) => {
82384
82387
  RadioWrapper,
82385
82388
  {
82386
82389
  ref: radioReference,
82387
- $isDisabled: isDisabled,
82390
+ $isDisabled: isDisabled ?? false,
82388
82391
  onFocus: (e3) => {
82389
82392
  if (isDisabled || e3.target !== radioReference.current) return;
82390
82393
  setIsFocused(true);
@@ -82553,7 +82556,7 @@ const RowLabelValue = ({
82553
82556
  children: label
82554
82557
  }
82555
82558
  ) }),
82556
- /* @__PURE__ */ jsx("div", { children: isLoading ? /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(RowSkeleton, { isFullWidth }) }) : getBadgeOrTypography(badgeProps, value2) })
82559
+ /* @__PURE__ */ jsx("div", { children: isLoading ? /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(RowSkeleton, { isFullWidth: isFullWidth ?? false }) }) : getBadgeOrTypography(badgeProps, value2) })
82557
82560
  ] });
82558
82561
  };
82559
82562
  const ActionsContainer = styled.div`
@@ -82603,13 +82606,13 @@ const Row = ({
82603
82606
  RowLabelValue,
82604
82607
  {
82605
82608
  label,
82606
- value: value2,
82609
+ value: value2 ?? "",
82607
82610
  isFullWidth,
82608
82611
  isLoading,
82609
82612
  badgeProps: badgeProperties
82610
82613
  }
82611
82614
  ),
82612
- /* @__PURE__ */ jsx(RowActions, { actions })
82615
+ /* @__PURE__ */ jsx(RowActions, { actions: actions ?? null })
82613
82616
  ]
82614
82617
  }
82615
82618
  );
@@ -82664,11 +82667,14 @@ const SegmentedControls = ({
82664
82667
  value: id2,
82665
82668
  icon
82666
82669
  }));
82670
+ const handleChange = (value2) => {
82671
+ onChange(String(value2));
82672
+ };
82667
82673
  return /* @__PURE__ */ jsx(
82668
82674
  SegmentedControls$1,
82669
82675
  {
82670
82676
  options: antOptions,
82671
- onChange,
82677
+ onChange: handleChange,
82672
82678
  value: selectedTabId,
82673
82679
  block: isScaled
82674
82680
  }
@@ -82926,6 +82932,7 @@ const Select = ({
82926
82932
  }
82927
82933
  };
82928
82934
  const getSelectModeValue = (value22) => {
82935
+ if (!value22) return "";
82929
82936
  if (Array.isArray(value22)) {
82930
82937
  if (selectDisplayMode === "count") {
82931
82938
  return `${value22.length} selected`;
@@ -83149,10 +83156,16 @@ const getGenesisClass$1 = ({ colors: colors2, borderRadius: borderRadius2, sizin
83149
83156
  return `
83150
83157
  &.ant-table-wrapper {
83151
83158
  // Add your custom styles here
83159
+ border-radius: 0 !important;
83152
83160
  }
83153
83161
 
83154
83162
  .ant-table {
83155
83163
  // Add your custom table styles here
83164
+ border-radius: 0 !important;
83165
+ }
83166
+
83167
+ .ant-table-container {
83168
+ border-radius: 0 !important;
83156
83169
  }
83157
83170
 
83158
83171
  .ant-table-cell {
@@ -83177,6 +83190,16 @@ const getGenesisClass$1 = ({ colors: colors2, borderRadius: borderRadius2, sizin
83177
83190
  font-size: ${$isMainContentCell ? "16px" : "14px"} !important;
83178
83191
  font-weight: 400;
83179
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;
83180
83203
  }
83181
83204
 
83182
83205
  .ant-table-tbody > tr {
@@ -83652,7 +83675,32 @@ function Table({
83652
83675
  const [materializedData, setMaterializedData] = React.useState([]);
83653
83676
  const [isLoadingMore, setIsLoadingMore] = React.useState(false);
83654
83677
  const [hasMoreData, setHasMoreData] = React.useState(true);
83678
+ const [dynamicHeight, setDynamicHeight] = React.useState(
83679
+ 400
83680
+ );
83655
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]);
83656
83704
  React.useEffect(() => {
83657
83705
  if (isMaterializedView) {
83658
83706
  const initialSize = materializedViewConfig?.initialLoadSize || 50;
@@ -83723,15 +83771,16 @@ function Table({
83723
83771
  }, [isMaterializedView, pagination]);
83724
83772
  const scrollConfig = React.useMemo(() => {
83725
83773
  if (isMaterializedView) {
83774
+ const height = materializedViewConfig?.height === "dynamic" ? dynamicHeight : materializedViewConfig?.height || 400;
83726
83775
  return {
83727
83776
  ...rest.scroll,
83728
- y: materializedViewConfig?.height || 400
83777
+ y: height
83729
83778
  };
83730
83779
  }
83731
83780
  return rest.scroll;
83732
- }, [isMaterializedView, materializedViewConfig, rest.scroll]);
83781
+ }, [isMaterializedView, materializedViewConfig, dynamicHeight, rest.scroll]);
83733
83782
  const tableDataSource = isMaterializedView ? materializedData : dataSource;
83734
- return /* @__PURE__ */ jsx(
83783
+ return /* @__PURE__ */ jsx("div", { ref: containerRef, children: /* @__PURE__ */ jsx(
83735
83784
  Table$1,
83736
83785
  {
83737
83786
  ref: tableRef,
@@ -83749,7 +83798,7 @@ function Table({
83749
83798
  $isMainContentCell: isMainContentCell,
83750
83799
  ...rest
83751
83800
  }
83752
- );
83801
+ ) });
83753
83802
  }
83754
83803
  const TablePagination = ({
83755
83804
  columns,
@@ -83917,7 +83966,7 @@ const PrimaryTableControlsRow = ({
83917
83966
  const onSortChange = (value2) => {
83918
83967
  const sortActionEvent = {
83919
83968
  event: "primarySortChange",
83920
- payload: { value: value2 }
83969
+ payload: { value: Array.isArray(value2) ? value2[0] : value2 }
83921
83970
  };
83922
83971
  onChange?.(sortActionEvent);
83923
83972
  };
@@ -84119,7 +84168,7 @@ const SecondaryTableControlsRow = ({
84119
84168
  },
84120
84169
  children: [
84121
84170
  /* @__PURE__ */ jsx(GroupsRow, { groups, onGroupItemClick }),
84122
- totalRecords > 0 ? /* @__PURE__ */ jsx(Typography, { variant: "body2", color: "#6C6C6C", children: `${totalRecords} results` }) : null
84171
+ (totalRecords ?? 0) > 0 ? /* @__PURE__ */ jsx(Typography, { variant: "body2", color: "#6C6C6C", children: `${totalRecords} results` }) : null
84123
84172
  ]
84124
84173
  }
84125
84174
  );
@@ -84180,7 +84229,7 @@ const TableWithControls = ({
84180
84229
  const onTableChange = (pagination, filters, sorter) => {
84181
84230
  onChange({
84182
84231
  event: "tableChange",
84183
- payload: { pagination, filters, sorter }
84232
+ payload: { value: "tableChange", pagination, filters, sorter }
84184
84233
  });
84185
84234
  };
84186
84235
  return /* @__PURE__ */ jsxs(Fragment, { children: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gobolt/genesis",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "description": "genesis design system",
5
5
  "author": "gobolt",
6
6
  "license": "MIT",