@gobolt/genesis 0.3.28 → 0.4.1

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.
Files changed (37) hide show
  1. package/dist/components/Avatar/styles.d.ts +12 -1
  2. package/dist/components/Badge/styles.d.ts +10 -1
  3. package/dist/components/Breadcrumb/styles.d.ts +23 -2
  4. package/dist/components/Button/icon-button-styles.d.ts +12 -1
  5. package/dist/components/Button/styles.d.ts +16 -1
  6. package/dist/components/Card/styles.d.ts +10 -1
  7. package/dist/components/Checkbox/styles.d.ts +6 -1
  8. package/dist/components/ErrorBoundaryFallback/styles.d.ts +1 -1
  9. package/dist/components/Input/styles.d.ts +17 -1
  10. package/dist/components/Insights/BarChart/styles.d.ts +9 -2
  11. package/dist/components/Insights/DonutChart/styles.d.ts +9 -2
  12. package/dist/components/Insights/LineChart/styles.d.ts +9 -2
  13. package/dist/components/Layout/Content/styles.d.ts +7 -1
  14. package/dist/components/Message/styles.d.ts +9 -3
  15. package/dist/components/Notification/NotificationBadge/styles.d.ts +3 -3
  16. package/dist/components/Notification/styles.d.ts +16 -5
  17. package/dist/components/Popover/styles.d.ts +13 -1
  18. package/dist/components/Progress/Progress.d.ts +2 -1
  19. package/dist/components/Progress/styles.d.ts +13 -1
  20. package/dist/components/Radio/Radio.d.ts +4 -1
  21. package/dist/components/Row/RowActions/styles.d.ts +1 -1
  22. package/dist/components/Row/RowLabelValue/styles.d.ts +12 -2
  23. package/dist/components/Row/styles.d.ts +9 -1
  24. package/dist/components/SegmentedControls/styles.d.ts +9 -1
  25. package/dist/components/Switch/styles.d.ts +7 -1
  26. package/dist/components/Table/Table.d.ts +13 -3
  27. package/dist/components/Table/styles.d.ts +15 -1
  28. package/dist/components/Tabs/styles.d.ts +11 -1
  29. package/dist/components/Tile/styles.d.ts +7 -1
  30. package/dist/components/Toast/styles.d.ts +9 -3
  31. package/dist/components/Tooltip/styles.d.ts +14 -1
  32. package/dist/components/Typography/styles.d.ts +21 -3
  33. package/dist/index.cjs +255 -57
  34. package/dist/index.js +255 -57
  35. package/dist/styles/global-styles.d.ts +1 -1
  36. package/dist/utils/styled.d.ts +1 -0
  37. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -38570,7 +38570,7 @@ function throttle(delay, callback, options) {
38570
38570
  wrapper.cancel = cancel;
38571
38571
  return wrapper;
38572
38572
  }
38573
- function debounce(delay, callback, options) {
38573
+ function debounce$2(delay, callback, options) {
38574
38574
  var _ref = {}, _ref$atBegin = _ref.atBegin, atBegin = _ref$atBegin === void 0 ? false : _ref$atBegin;
38575
38575
  return throttle(delay, callback, {
38576
38576
  debounceMode: atBegin !== false
@@ -46051,7 +46051,7 @@ const Spin = (props) => {
46051
46051
  const mergedPercent = usePercent(spinning, percent);
46052
46052
  React__namespace.useEffect(() => {
46053
46053
  if (customSpinning) {
46054
- const showSpinning = debounce(delay, () => {
46054
+ const showSpinning = debounce$2(delay, () => {
46055
46055
  setSpinning(true);
46056
46056
  });
46057
46057
  showSpinning();
@@ -82028,6 +82028,34 @@ const Progress$1 = styled(Progress$2)`
82028
82028
  return getGenesisClass$5(theme, state);
82029
82029
  }}
82030
82030
  `;
82031
+ const getGenesisClass$4 = ({ sizing: sizing2 }, $isHorizontal = false) => `
82032
+ display: flex;
82033
+ flex-direction: ${$isHorizontal ? "row" : "column"};
82034
+ padding: ${sizing2.Size4};
82035
+ `;
82036
+ const Tile$1 = styled.div`
82037
+ ${({ theme, $isHorizontal }) => {
82038
+ return getGenesisClass$4(theme, $isHorizontal);
82039
+ }}
82040
+ `;
82041
+ const Tile = ({
82042
+ children: children2,
82043
+ dataTestId,
82044
+ className,
82045
+ style: style2,
82046
+ isHorizontal = false
82047
+ }) => {
82048
+ return /* @__PURE__ */ jsxRuntime.jsx(
82049
+ Tile$1,
82050
+ {
82051
+ className,
82052
+ "data-testid": dataTestId,
82053
+ style: style2,
82054
+ $isHorizontal: isHorizontal,
82055
+ children: children2
82056
+ }
82057
+ );
82058
+ };
82031
82059
  const ProgressText = ({
82032
82060
  firstBarData,
82033
82061
  secondBarData,
@@ -82099,22 +82127,52 @@ const getTextComponent = (firstBarData, secondBarData, stateColor, theme, isText
82099
82127
  }
82100
82128
  );
82101
82129
  };
82130
+ const getCombinedPercent = (firstBarData, secondBarData) => {
82131
+ if (firstBarData?.value && secondBarData?.value) {
82132
+ const total = firstBarData?.value + secondBarData?.value;
82133
+ const dividedBy = total / 2;
82134
+ return dividedBy;
82135
+ }
82136
+ return 0;
82137
+ };
82102
82138
  const Progress = ({
82103
82139
  firstBarData,
82104
82140
  secondBarData = null,
82105
82141
  width = 200,
82106
82142
  height = 24,
82107
- isTextBeforeBar = false
82143
+ isTextBeforeBar = false,
82144
+ isProgressCombined = false
82108
82145
  }) => {
82109
82146
  const theme = styled.useTheme();
82110
- const percent = firstBarData.value || 0;
82111
- const strokeColor = theme.colors.inputs.progress[firstBarData.status];
82147
+ const percent = firstBarData?.value || 0;
82148
+ const strokeColor = theme?.colors?.inputs.progress[firstBarData?.status];
82112
82149
  const success = secondBarData ? {
82113
82150
  percent: secondBarData.value,
82114
- strokeColor: theme.colors.inputs.progress[secondBarData.status]
82151
+ strokeColor: theme?.colors?.inputs.progress[secondBarData.status]
82115
82152
  } : null;
82116
82153
  const stateColor = strokeColor;
82117
82154
  const gap = 8;
82155
+ if (isProgressCombined) {
82156
+ const combinedPercent = getCombinedPercent(firstBarData, secondBarData);
82157
+ const textColor = Number(combinedPercent) === 100 ? "green" : "black";
82158
+ console.log({ combinedPercent, firstBarData, secondBarData });
82159
+ return /* @__PURE__ */ jsxRuntime.jsxs(Tile, { style: { width, height, alignItems: "center", gap }, isHorizontal: true, children: [
82160
+ /* @__PURE__ */ jsxRuntime.jsx(
82161
+ Progress$1,
82162
+ {
82163
+ "data-testid": "progress",
82164
+ percent,
82165
+ success,
82166
+ strokeColor,
82167
+ showInfo: false
82168
+ }
82169
+ ),
82170
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", alignItems: "center", width: 80 }, children: /* @__PURE__ */ jsxRuntime.jsxs(Typography, { color: textColor, variant: "digits3", children: [
82171
+ combinedPercent,
82172
+ "%"
82173
+ ] }) })
82174
+ ] });
82175
+ }
82118
82176
  if (isTextBeforeBar) {
82119
82177
  return /* @__PURE__ */ jsxRuntime.jsxs(Tile, { style: { width, height, alignItems: "center", gap }, isHorizontal: true, children: [
82120
82178
  getTextComponent(
@@ -82574,7 +82632,7 @@ const Row = ({
82574
82632
  }
82575
82633
  );
82576
82634
  };
82577
- const getGenesisClass$4 = ({ colors: colors2, borderRadius: borderRadius2, sizing: sizing2, typography: typography2 }, type4 = "primary", state = "active") => `
82635
+ const getGenesisClass$3 = ({ colors: colors2, borderRadius: borderRadius2, sizing: sizing2, typography: typography2 }, type4 = "primary", state = "active") => `
82578
82636
  &.ant-segmented {
82579
82637
  border-radius: ${borderRadius2.BorderRadiusMd};
82580
82638
  color: ${colors2.onsurface.copy};
@@ -82611,7 +82669,7 @@ const getGenesisClass$4 = ({ colors: colors2, borderRadius: borderRadius2, sizin
82611
82669
  const SegmentedControls$1 = styled(
82612
82670
  Segmented
82613
82671
  )`
82614
- ${({ theme, type: type4 = "primary", state = "active" }) => getGenesisClass$4(theme, type4, state)}
82672
+ ${({ theme, type: type4 = "primary", state = "active" }) => getGenesisClass$3(theme, type4, state)}
82615
82673
  `;
82616
82674
  const SegmentedControls = ({
82617
82675
  options,
@@ -83027,7 +83085,7 @@ const Shapes = ({ variant = "triangle", fill }) => {
83027
83085
  }
83028
83086
  return /* @__PURE__ */ jsxRuntime.jsx(Triangle, { fill, dataTestId: "shape-triangle" });
83029
83087
  };
83030
- const getGenesisClass$3 = ({ colors: colors2, borderRadius: borderRadius2 }) => `
83088
+ const getGenesisClass$2 = ({ colors: colors2, borderRadius: borderRadius2 }) => `
83031
83089
  &.ant-switch {
83032
83090
  background-color: ${colors2.primary.active};
83033
83091
  border-radius: ${borderRadius2?.BorderRadiusMd};
@@ -83084,7 +83142,7 @@ const getGenesisClass$3 = ({ colors: colors2, borderRadius: borderRadius2 }) =>
83084
83142
  }
83085
83143
  `;
83086
83144
  const Switch$1 = styled(Switch$2)`
83087
- ${({ theme }) => getGenesisClass$3(theme)}
83145
+ ${({ theme }) => getGenesisClass$2(theme)}
83088
83146
  `;
83089
83147
  const Switch = ({
83090
83148
  state,
@@ -83105,7 +83163,7 @@ const Switch = ({
83105
83163
  }
83106
83164
  );
83107
83165
  };
83108
- const getGenesisClass$2 = ({ colors: colors2, borderRadius: borderRadius2, sizing: sizing2, typography: typography2, components: components2 }, $isMainContentCell) => {
83166
+ const getGenesisClass$1 = ({ colors: colors2, borderRadius: borderRadius2, sizing: sizing2, typography: typography2, components: components2 }, $isMainContentCell) => {
83109
83167
  return `
83110
83168
  &.ant-table-wrapper {
83111
83169
  // Add your custom styles here
@@ -83159,7 +83217,7 @@ const getGenesisClass$2 = ({ colors: colors2, borderRadius: borderRadius2, sizin
83159
83217
  };
83160
83218
  const Table$1 = styled(ForwardTable)`
83161
83219
  ${({ theme, $isMainContentCell }) => {
83162
- return getGenesisClass$2(theme, $isMainContentCell);
83220
+ return getGenesisClass$1(theme, $isMainContentCell);
83163
83221
  }}
83164
83222
  `;
83165
83223
  const NumberButton = styled.button`
@@ -83513,6 +83571,89 @@ const CustomPagination = ({
83513
83571
  }
83514
83572
  return null;
83515
83573
  };
83574
+ var debounce$1 = { exports: {} };
83575
+ var hasRequiredDebounce;
83576
+ function requireDebounce() {
83577
+ if (hasRequiredDebounce) return debounce$1.exports;
83578
+ hasRequiredDebounce = 1;
83579
+ function debounce2(function_, wait = 100, options = {}) {
83580
+ if (typeof function_ !== "function") {
83581
+ throw new TypeError(`Expected the first parameter to be a function, got \`${typeof function_}\`.`);
83582
+ }
83583
+ if (wait < 0) {
83584
+ throw new RangeError("`wait` must not be negative.");
83585
+ }
83586
+ const { immediate } = typeof options === "boolean" ? { immediate: options } : options;
83587
+ let storedContext;
83588
+ let storedArguments;
83589
+ let timeoutId;
83590
+ let timestamp;
83591
+ let result;
83592
+ function run() {
83593
+ const callContext = storedContext;
83594
+ const callArguments = storedArguments;
83595
+ storedContext = void 0;
83596
+ storedArguments = void 0;
83597
+ result = function_.apply(callContext, callArguments);
83598
+ return result;
83599
+ }
83600
+ function later() {
83601
+ const last = Date.now() - timestamp;
83602
+ if (last < wait && last >= 0) {
83603
+ timeoutId = setTimeout(later, wait - last);
83604
+ } else {
83605
+ timeoutId = void 0;
83606
+ if (!immediate) {
83607
+ result = run();
83608
+ }
83609
+ }
83610
+ }
83611
+ const debounced = function(...arguments_) {
83612
+ if (storedContext && this !== storedContext && Object.getPrototypeOf(this) === Object.getPrototypeOf(storedContext)) {
83613
+ throw new Error("Debounced method called with different contexts of the same prototype.");
83614
+ }
83615
+ storedContext = this;
83616
+ storedArguments = arguments_;
83617
+ timestamp = Date.now();
83618
+ const callNow = immediate && !timeoutId;
83619
+ if (!timeoutId) {
83620
+ timeoutId = setTimeout(later, wait);
83621
+ }
83622
+ if (callNow) {
83623
+ result = run();
83624
+ }
83625
+ return result;
83626
+ };
83627
+ Object.defineProperty(debounced, "isPending", {
83628
+ get() {
83629
+ return timeoutId !== void 0;
83630
+ }
83631
+ });
83632
+ debounced.clear = () => {
83633
+ if (!timeoutId) {
83634
+ return;
83635
+ }
83636
+ clearTimeout(timeoutId);
83637
+ timeoutId = void 0;
83638
+ };
83639
+ debounced.flush = () => {
83640
+ if (!timeoutId) {
83641
+ return;
83642
+ }
83643
+ debounced.trigger();
83644
+ };
83645
+ debounced.trigger = () => {
83646
+ result = run();
83647
+ debounced.clear();
83648
+ };
83649
+ return debounced;
83650
+ }
83651
+ debounce$1.exports.debounce = debounce2;
83652
+ debounce$1.exports = debounce2;
83653
+ return debounce$1.exports;
83654
+ }
83655
+ var debounceExports = /* @__PURE__ */ requireDebounce();
83656
+ const debounce = /* @__PURE__ */ getDefaultExportFromCjs(debounceExports);
83516
83657
  function Table({
83517
83658
  columns,
83518
83659
  dataSource,
@@ -83522,25 +83663,98 @@ function Table({
83522
83663
  rowSelection,
83523
83664
  pagination,
83524
83665
  isMainContentCell = false,
83666
+ isMaterializedView = false,
83667
+ materializedViewConfig,
83525
83668
  ...rest
83526
83669
  }) {
83527
- const paginationConfig = pagination === false ? false : {
83528
- ...pagination,
83529
- itemRender: void 0,
83530
- // Clear any existing itemRender to avoid conflicts
83531
- render: (properties) => /* @__PURE__ */ jsxRuntime.jsx(
83532
- CustomPagination,
83533
- {
83534
- ...properties,
83535
- paginationStyle: pagination?.paginationStyle || PaginationStyle.SIMPLE
83670
+ const [materializedData, setMaterializedData] = React__namespace.useState([]);
83671
+ const [isLoadingMore, setIsLoadingMore] = React__namespace.useState(false);
83672
+ const [hasMoreData, setHasMoreData] = React__namespace.useState(true);
83673
+ const tableRef = React__namespace.useRef(null);
83674
+ React__namespace.useEffect(() => {
83675
+ if (isMaterializedView) {
83676
+ const initialSize = materializedViewConfig?.initialLoadSize || 50;
83677
+ const initialData = dataSource.slice(0, initialSize);
83678
+ setMaterializedData(initialData);
83679
+ setHasMoreData(dataSource.length > initialSize);
83680
+ }
83681
+ }, [dataSource, isMaterializedView, materializedViewConfig]);
83682
+ const handleScroll = React__namespace.useCallback(
83683
+ debounce((e3) => {
83684
+ if (!isMaterializedView || !materializedViewConfig?.onLoadMore || isLoadingMore || !hasMoreData) {
83685
+ return;
83536
83686
  }
83537
- )
83538
- };
83687
+ const { target } = e3;
83688
+ const { scrollTop, scrollHeight, clientHeight } = target;
83689
+ const threshold = materializedViewConfig?.loadMoreThreshold || 100;
83690
+ if (scrollTop + clientHeight >= scrollHeight - threshold) {
83691
+ setIsLoadingMore(true);
83692
+ const currentLength = materializedData.length;
83693
+ const loadSize = materializedViewConfig?.initialLoadSize || 50;
83694
+ if (materializedViewConfig?.onLoadMore) {
83695
+ Promise.resolve(
83696
+ materializedViewConfig.onLoadMore(currentLength, loadSize)
83697
+ ).then((newData) => {
83698
+ setMaterializedData((prev2) => [...prev2, ...newData]);
83699
+ setHasMoreData(newData.length === loadSize);
83700
+ }).catch((error2) => {
83701
+ console.error("Error loading more data:", error2);
83702
+ }).finally(() => {
83703
+ setIsLoadingMore(false);
83704
+ });
83705
+ } else {
83706
+ const newData = dataSource.slice(
83707
+ currentLength,
83708
+ currentLength + loadSize
83709
+ );
83710
+ setMaterializedData((prev2) => [...prev2, ...newData]);
83711
+ setHasMoreData(newData.length === loadSize);
83712
+ setIsLoadingMore(false);
83713
+ }
83714
+ }
83715
+ }, 200),
83716
+ [
83717
+ isMaterializedView,
83718
+ materializedViewConfig,
83719
+ materializedData,
83720
+ isLoadingMore,
83721
+ hasMoreData,
83722
+ dataSource
83723
+ ]
83724
+ );
83725
+ const paginationConfig = React__namespace.useMemo(() => {
83726
+ if (isMaterializedView) {
83727
+ return false;
83728
+ }
83729
+ return pagination === false ? false : {
83730
+ ...pagination,
83731
+ itemRender: void 0,
83732
+ // Clear any existing itemRender to avoid conflicts
83733
+ render: (properties) => /* @__PURE__ */ jsxRuntime.jsx(
83734
+ CustomPagination,
83735
+ {
83736
+ ...properties,
83737
+ paginationStyle: pagination?.paginationStyle || PaginationStyle.SIMPLE
83738
+ }
83739
+ )
83740
+ };
83741
+ }, [isMaterializedView, pagination]);
83742
+ const scrollConfig = React__namespace.useMemo(() => {
83743
+ if (isMaterializedView) {
83744
+ return {
83745
+ ...rest.scroll,
83746
+ y: materializedViewConfig?.height || 400
83747
+ };
83748
+ }
83749
+ return rest.scroll;
83750
+ }, [isMaterializedView, materializedViewConfig, rest.scroll]);
83751
+ const tableDataSource = isMaterializedView ? materializedData : dataSource;
83539
83752
  return /* @__PURE__ */ jsxRuntime.jsx(
83540
83753
  Table$1,
83541
83754
  {
83755
+ ref: tableRef,
83542
83756
  "data-testid": "Table",
83543
- dataSource,
83757
+ dataSource: tableDataSource,
83544
83758
  columns,
83545
83759
  rowKey,
83546
83760
  locale: { emptyText: "No Data" },
@@ -83548,6 +83762,8 @@ function Table({
83548
83762
  onChange,
83549
83763
  rowSelection,
83550
83764
  pagination: paginationConfig,
83765
+ scroll: scrollConfig,
83766
+ onScroll: isMaterializedView ? handleScroll : void 0,
83551
83767
  $isMainContentCell: isMainContentCell,
83552
83768
  ...rest
83553
83769
  }
@@ -83967,7 +84183,15 @@ const TableWithControls = ({
83967
84183
  onChange
83968
84184
  }) => {
83969
84185
  const { primaryTableRowData, secondaryTableRowData } = tableControlsData2;
83970
- const { dataSource, columns, rowSelection, hasSettings, hasFilter } = tableData;
84186
+ const {
84187
+ dataSource,
84188
+ columns,
84189
+ rowSelection,
84190
+ hasSettings,
84191
+ hasFilter,
84192
+ isMaterializedView,
84193
+ materializedViewConfig
84194
+ } = tableData;
83971
84195
  const onTableControlsChange = (event) => {
83972
84196
  onChange(event);
83973
84197
  };
@@ -83987,12 +84211,14 @@ const TableWithControls = ({
83987
84211
  }
83988
84212
  ),
83989
84213
  /* @__PURE__ */ jsxRuntime.jsx(
83990
- TablePagination,
84214
+ Table,
83991
84215
  {
83992
84216
  dataSource,
83993
84217
  columns,
83994
84218
  rowSelection,
83995
- onChange: onTableChange
84219
+ onChange: onTableChange,
84220
+ isMaterializedView,
84221
+ materializedViewConfig
83996
84222
  }
83997
84223
  )
83998
84224
  ] });
@@ -84462,7 +84688,7 @@ const useTableWithControls = (tableConfig) => {
84462
84688
  updateDataSource
84463
84689
  };
84464
84690
  };
84465
- const getGenesisClass$1 = ({ colors: colors2, borderRadius: borderRadius2, sizing: sizing2 }, type4 = "primary", state = "active") => `
84691
+ const getGenesisClass = ({ colors: colors2, borderRadius: borderRadius2, sizing: sizing2 }, type4 = "primary", state = "active") => `
84466
84692
  &.ant-tabs {
84467
84693
  background: #F4F4F4;
84468
84694
 
@@ -84558,7 +84784,7 @@ const getGenesisClass$1 = ({ colors: colors2, borderRadius: borderRadius2, sizin
84558
84784
  `;
84559
84785
  const Tabs$1 = styled(Tabs$2)`
84560
84786
  ${({ theme, type: type4, state }) => {
84561
- return getGenesisClass$1(theme, type4, state);
84787
+ return getGenesisClass(theme, type4, state);
84562
84788
  }}
84563
84789
  `;
84564
84790
  const Tabs = ({ items, onChange, selectedId }) => {
@@ -84578,34 +84804,6 @@ const Tabs = ({ items, onChange, selectedId }) => {
84578
84804
  }
84579
84805
  );
84580
84806
  };
84581
- const getGenesisClass = ({ sizing: sizing2 }, $isHorizontal = false) => `
84582
- display: flex;
84583
- flex-direction: ${$isHorizontal ? "row" : "column"};
84584
- padding: ${sizing2.Size4};
84585
- `;
84586
- const Tile$1 = styled.div`
84587
- ${({ theme, $isHorizontal }) => {
84588
- return getGenesisClass(theme, $isHorizontal);
84589
- }}
84590
- `;
84591
- const Tile = ({
84592
- children: children2,
84593
- dataTestId,
84594
- className,
84595
- style: style2,
84596
- isHorizontal = false
84597
- }) => {
84598
- return /* @__PURE__ */ jsxRuntime.jsx(
84599
- Tile$1,
84600
- {
84601
- className,
84602
- "data-testid": dataTestId,
84603
- style: style2,
84604
- $isHorizontal: isHorizontal,
84605
- children: children2
84606
- }
84607
- );
84608
- };
84609
84807
  const ToastRow = styled.div`
84610
84808
  display: flex;
84611
84809
  align-items: center;