@gobolt/genesis 0.3.28 → 0.4.0

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 +12 -2
  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 +232 -54
  34. package/dist/index.js +232 -54
  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,88 @@ function Table({
83522
83663
  rowSelection,
83523
83664
  pagination,
83524
83665
  isMainContentCell = false,
83666
+ materializedView,
83525
83667
  ...rest
83526
83668
  }) {
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
83669
+ const [materializedData, setMaterializedData] = React__namespace.useState([]);
83670
+ const [isLoadingMore, setIsLoadingMore] = React__namespace.useState(false);
83671
+ const [hasMoreData, setHasMoreData] = React__namespace.useState(true);
83672
+ const tableRef = React__namespace.useRef(null);
83673
+ React__namespace.useEffect(() => {
83674
+ if (materializedView?.enabled) {
83675
+ const initialSize = materializedView.initialLoadSize || 50;
83676
+ const initialData = dataSource.slice(0, initialSize);
83677
+ setMaterializedData(initialData);
83678
+ setHasMoreData(dataSource.length > initialSize);
83679
+ }
83680
+ }, [dataSource, materializedView]);
83681
+ const handleScroll = React__namespace.useCallback(
83682
+ debounce((e3) => {
83683
+ if (!materializedView?.enabled || !materializedView.onLoadMore || isLoadingMore || !hasMoreData) {
83684
+ return;
83536
83685
  }
83537
- )
83538
- };
83686
+ const { target } = e3;
83687
+ const { scrollTop, scrollHeight, clientHeight } = target;
83688
+ const threshold = materializedView.loadMoreThreshold || 100;
83689
+ if (scrollTop + clientHeight >= scrollHeight - threshold) {
83690
+ setIsLoadingMore(true);
83691
+ const currentLength = materializedData.length;
83692
+ const loadSize = materializedView.initialLoadSize || 50;
83693
+ if (materializedView.onLoadMore) {
83694
+ Promise.resolve(materializedView.onLoadMore(currentLength, loadSize)).then((newData) => {
83695
+ setMaterializedData((prev2) => [...prev2, ...newData]);
83696
+ setHasMoreData(newData.length === loadSize);
83697
+ }).catch((error2) => {
83698
+ console.error("Error loading more data:", error2);
83699
+ }).finally(() => {
83700
+ setIsLoadingMore(false);
83701
+ });
83702
+ } else {
83703
+ const newData = dataSource.slice(
83704
+ currentLength,
83705
+ currentLength + loadSize
83706
+ );
83707
+ setMaterializedData((prev2) => [...prev2, ...newData]);
83708
+ setHasMoreData(newData.length === loadSize);
83709
+ setIsLoadingMore(false);
83710
+ }
83711
+ }
83712
+ }, 200),
83713
+ [materializedView, materializedData, isLoadingMore, hasMoreData, dataSource]
83714
+ );
83715
+ const paginationConfig = React__namespace.useMemo(() => {
83716
+ if (materializedView?.enabled) {
83717
+ return false;
83718
+ }
83719
+ return pagination === false ? false : {
83720
+ ...pagination,
83721
+ itemRender: void 0,
83722
+ // Clear any existing itemRender to avoid conflicts
83723
+ render: (properties) => /* @__PURE__ */ jsxRuntime.jsx(
83724
+ CustomPagination,
83725
+ {
83726
+ ...properties,
83727
+ paginationStyle: pagination?.paginationStyle || PaginationStyle.SIMPLE
83728
+ }
83729
+ )
83730
+ };
83731
+ }, [materializedView, pagination]);
83732
+ const scrollConfig = React__namespace.useMemo(() => {
83733
+ if (materializedView?.enabled) {
83734
+ return {
83735
+ ...rest.scroll,
83736
+ y: materializedView.height || 400
83737
+ };
83738
+ }
83739
+ return rest.scroll;
83740
+ }, [materializedView, rest.scroll]);
83741
+ const tableDataSource = materializedView?.enabled ? materializedData : dataSource;
83539
83742
  return /* @__PURE__ */ jsxRuntime.jsx(
83540
83743
  Table$1,
83541
83744
  {
83745
+ ref: tableRef,
83542
83746
  "data-testid": "Table",
83543
- dataSource,
83747
+ dataSource: tableDataSource,
83544
83748
  columns,
83545
83749
  rowKey,
83546
83750
  locale: { emptyText: "No Data" },
@@ -83548,6 +83752,8 @@ function Table({
83548
83752
  onChange,
83549
83753
  rowSelection,
83550
83754
  pagination: paginationConfig,
83755
+ scroll: scrollConfig,
83756
+ onScroll: materializedView?.enabled ? handleScroll : void 0,
83551
83757
  $isMainContentCell: isMainContentCell,
83552
83758
  ...rest
83553
83759
  }
@@ -84462,7 +84668,7 @@ const useTableWithControls = (tableConfig) => {
84462
84668
  updateDataSource
84463
84669
  };
84464
84670
  };
84465
- const getGenesisClass$1 = ({ colors: colors2, borderRadius: borderRadius2, sizing: sizing2 }, type4 = "primary", state = "active") => `
84671
+ const getGenesisClass = ({ colors: colors2, borderRadius: borderRadius2, sizing: sizing2 }, type4 = "primary", state = "active") => `
84466
84672
  &.ant-tabs {
84467
84673
  background: #F4F4F4;
84468
84674
 
@@ -84558,7 +84764,7 @@ const getGenesisClass$1 = ({ colors: colors2, borderRadius: borderRadius2, sizin
84558
84764
  `;
84559
84765
  const Tabs$1 = styled(Tabs$2)`
84560
84766
  ${({ theme, type: type4, state }) => {
84561
- return getGenesisClass$1(theme, type4, state);
84767
+ return getGenesisClass(theme, type4, state);
84562
84768
  }}
84563
84769
  `;
84564
84770
  const Tabs = ({ items, onChange, selectedId }) => {
@@ -84578,34 +84784,6 @@ const Tabs = ({ items, onChange, selectedId }) => {
84578
84784
  }
84579
84785
  );
84580
84786
  };
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
84787
  const ToastRow = styled.div`
84610
84788
  display: flex;
84611
84789
  align-items: center;