@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.js CHANGED
@@ -38552,7 +38552,7 @@ function throttle(delay, callback, options) {
38552
38552
  wrapper.cancel = cancel;
38553
38553
  return wrapper;
38554
38554
  }
38555
- function debounce(delay, callback, options) {
38555
+ function debounce$2(delay, callback, options) {
38556
38556
  var _ref = {}, _ref$atBegin = _ref.atBegin, atBegin = _ref$atBegin === void 0 ? false : _ref$atBegin;
38557
38557
  return throttle(delay, callback, {
38558
38558
  debounceMode: atBegin !== false
@@ -46033,7 +46033,7 @@ const Spin = (props) => {
46033
46033
  const mergedPercent = usePercent(spinning, percent);
46034
46034
  React.useEffect(() => {
46035
46035
  if (customSpinning) {
46036
- const showSpinning = debounce(delay, () => {
46036
+ const showSpinning = debounce$2(delay, () => {
46037
46037
  setSpinning(true);
46038
46038
  });
46039
46039
  showSpinning();
@@ -82010,6 +82010,34 @@ const Progress$1 = styled(Progress$2)`
82010
82010
  return getGenesisClass$5(theme, state);
82011
82011
  }}
82012
82012
  `;
82013
+ const getGenesisClass$4 = ({ sizing: sizing2 }, $isHorizontal = false) => `
82014
+ display: flex;
82015
+ flex-direction: ${$isHorizontal ? "row" : "column"};
82016
+ padding: ${sizing2.Size4};
82017
+ `;
82018
+ const Tile$1 = styled.div`
82019
+ ${({ theme, $isHorizontal }) => {
82020
+ return getGenesisClass$4(theme, $isHorizontal);
82021
+ }}
82022
+ `;
82023
+ const Tile = ({
82024
+ children: children2,
82025
+ dataTestId,
82026
+ className,
82027
+ style: style2,
82028
+ isHorizontal = false
82029
+ }) => {
82030
+ return /* @__PURE__ */ jsx(
82031
+ Tile$1,
82032
+ {
82033
+ className,
82034
+ "data-testid": dataTestId,
82035
+ style: style2,
82036
+ $isHorizontal: isHorizontal,
82037
+ children: children2
82038
+ }
82039
+ );
82040
+ };
82013
82041
  const ProgressText = ({
82014
82042
  firstBarData,
82015
82043
  secondBarData,
@@ -82081,22 +82109,52 @@ const getTextComponent = (firstBarData, secondBarData, stateColor, theme, isText
82081
82109
  }
82082
82110
  );
82083
82111
  };
82112
+ const getCombinedPercent = (firstBarData, secondBarData) => {
82113
+ if (firstBarData?.value && secondBarData?.value) {
82114
+ const total = firstBarData?.value + secondBarData?.value;
82115
+ const dividedBy = total / 2;
82116
+ return dividedBy;
82117
+ }
82118
+ return 0;
82119
+ };
82084
82120
  const Progress = ({
82085
82121
  firstBarData,
82086
82122
  secondBarData = null,
82087
82123
  width = 200,
82088
82124
  height = 24,
82089
- isTextBeforeBar = false
82125
+ isTextBeforeBar = false,
82126
+ isProgressCombined = false
82090
82127
  }) => {
82091
82128
  const theme = useTheme$1();
82092
- const percent = firstBarData.value || 0;
82093
- const strokeColor = theme.colors.inputs.progress[firstBarData.status];
82129
+ const percent = firstBarData?.value || 0;
82130
+ const strokeColor = theme?.colors?.inputs.progress[firstBarData?.status];
82094
82131
  const success = secondBarData ? {
82095
82132
  percent: secondBarData.value,
82096
- strokeColor: theme.colors.inputs.progress[secondBarData.status]
82133
+ strokeColor: theme?.colors?.inputs.progress[secondBarData.status]
82097
82134
  } : null;
82098
82135
  const stateColor = strokeColor;
82099
82136
  const gap = 8;
82137
+ if (isProgressCombined) {
82138
+ const combinedPercent = getCombinedPercent(firstBarData, secondBarData);
82139
+ const textColor = Number(combinedPercent) === 100 ? "green" : "black";
82140
+ console.log({ combinedPercent, firstBarData, secondBarData });
82141
+ return /* @__PURE__ */ jsxs(Tile, { style: { width, height, alignItems: "center", gap }, isHorizontal: true, children: [
82142
+ /* @__PURE__ */ jsx(
82143
+ Progress$1,
82144
+ {
82145
+ "data-testid": "progress",
82146
+ percent,
82147
+ success,
82148
+ strokeColor,
82149
+ showInfo: false
82150
+ }
82151
+ ),
82152
+ /* @__PURE__ */ jsx("div", { style: { display: "flex", alignItems: "center", width: 80 }, children: /* @__PURE__ */ jsxs(Typography, { color: textColor, variant: "digits3", children: [
82153
+ combinedPercent,
82154
+ "%"
82155
+ ] }) })
82156
+ ] });
82157
+ }
82100
82158
  if (isTextBeforeBar) {
82101
82159
  return /* @__PURE__ */ jsxs(Tile, { style: { width, height, alignItems: "center", gap }, isHorizontal: true, children: [
82102
82160
  getTextComponent(
@@ -82556,7 +82614,7 @@ const Row = ({
82556
82614
  }
82557
82615
  );
82558
82616
  };
82559
- const getGenesisClass$4 = ({ colors: colors2, borderRadius: borderRadius2, sizing: sizing2, typography: typography2 }, type4 = "primary", state = "active") => `
82617
+ const getGenesisClass$3 = ({ colors: colors2, borderRadius: borderRadius2, sizing: sizing2, typography: typography2 }, type4 = "primary", state = "active") => `
82560
82618
  &.ant-segmented {
82561
82619
  border-radius: ${borderRadius2.BorderRadiusMd};
82562
82620
  color: ${colors2.onsurface.copy};
@@ -82593,7 +82651,7 @@ const getGenesisClass$4 = ({ colors: colors2, borderRadius: borderRadius2, sizin
82593
82651
  const SegmentedControls$1 = styled(
82594
82652
  Segmented
82595
82653
  )`
82596
- ${({ theme, type: type4 = "primary", state = "active" }) => getGenesisClass$4(theme, type4, state)}
82654
+ ${({ theme, type: type4 = "primary", state = "active" }) => getGenesisClass$3(theme, type4, state)}
82597
82655
  `;
82598
82656
  const SegmentedControls = ({
82599
82657
  options,
@@ -83009,7 +83067,7 @@ const Shapes = ({ variant = "triangle", fill }) => {
83009
83067
  }
83010
83068
  return /* @__PURE__ */ jsx(Triangle, { fill, dataTestId: "shape-triangle" });
83011
83069
  };
83012
- const getGenesisClass$3 = ({ colors: colors2, borderRadius: borderRadius2 }) => `
83070
+ const getGenesisClass$2 = ({ colors: colors2, borderRadius: borderRadius2 }) => `
83013
83071
  &.ant-switch {
83014
83072
  background-color: ${colors2.primary.active};
83015
83073
  border-radius: ${borderRadius2?.BorderRadiusMd};
@@ -83066,7 +83124,7 @@ const getGenesisClass$3 = ({ colors: colors2, borderRadius: borderRadius2 }) =>
83066
83124
  }
83067
83125
  `;
83068
83126
  const Switch$1 = styled(Switch$2)`
83069
- ${({ theme }) => getGenesisClass$3(theme)}
83127
+ ${({ theme }) => getGenesisClass$2(theme)}
83070
83128
  `;
83071
83129
  const Switch = ({
83072
83130
  state,
@@ -83087,7 +83145,7 @@ const Switch = ({
83087
83145
  }
83088
83146
  );
83089
83147
  };
83090
- const getGenesisClass$2 = ({ colors: colors2, borderRadius: borderRadius2, sizing: sizing2, typography: typography2, components: components2 }, $isMainContentCell) => {
83148
+ const getGenesisClass$1 = ({ colors: colors2, borderRadius: borderRadius2, sizing: sizing2, typography: typography2, components: components2 }, $isMainContentCell) => {
83091
83149
  return `
83092
83150
  &.ant-table-wrapper {
83093
83151
  // Add your custom styles here
@@ -83141,7 +83199,7 @@ const getGenesisClass$2 = ({ colors: colors2, borderRadius: borderRadius2, sizin
83141
83199
  };
83142
83200
  const Table$1 = styled(ForwardTable)`
83143
83201
  ${({ theme, $isMainContentCell }) => {
83144
- return getGenesisClass$2(theme, $isMainContentCell);
83202
+ return getGenesisClass$1(theme, $isMainContentCell);
83145
83203
  }}
83146
83204
  `;
83147
83205
  const NumberButton = styled.button`
@@ -83495,6 +83553,89 @@ const CustomPagination = ({
83495
83553
  }
83496
83554
  return null;
83497
83555
  };
83556
+ var debounce$1 = { exports: {} };
83557
+ var hasRequiredDebounce;
83558
+ function requireDebounce() {
83559
+ if (hasRequiredDebounce) return debounce$1.exports;
83560
+ hasRequiredDebounce = 1;
83561
+ function debounce2(function_, wait = 100, options = {}) {
83562
+ if (typeof function_ !== "function") {
83563
+ throw new TypeError(`Expected the first parameter to be a function, got \`${typeof function_}\`.`);
83564
+ }
83565
+ if (wait < 0) {
83566
+ throw new RangeError("`wait` must not be negative.");
83567
+ }
83568
+ const { immediate } = typeof options === "boolean" ? { immediate: options } : options;
83569
+ let storedContext;
83570
+ let storedArguments;
83571
+ let timeoutId;
83572
+ let timestamp;
83573
+ let result;
83574
+ function run() {
83575
+ const callContext = storedContext;
83576
+ const callArguments = storedArguments;
83577
+ storedContext = void 0;
83578
+ storedArguments = void 0;
83579
+ result = function_.apply(callContext, callArguments);
83580
+ return result;
83581
+ }
83582
+ function later() {
83583
+ const last = Date.now() - timestamp;
83584
+ if (last < wait && last >= 0) {
83585
+ timeoutId = setTimeout(later, wait - last);
83586
+ } else {
83587
+ timeoutId = void 0;
83588
+ if (!immediate) {
83589
+ result = run();
83590
+ }
83591
+ }
83592
+ }
83593
+ const debounced = function(...arguments_) {
83594
+ if (storedContext && this !== storedContext && Object.getPrototypeOf(this) === Object.getPrototypeOf(storedContext)) {
83595
+ throw new Error("Debounced method called with different contexts of the same prototype.");
83596
+ }
83597
+ storedContext = this;
83598
+ storedArguments = arguments_;
83599
+ timestamp = Date.now();
83600
+ const callNow = immediate && !timeoutId;
83601
+ if (!timeoutId) {
83602
+ timeoutId = setTimeout(later, wait);
83603
+ }
83604
+ if (callNow) {
83605
+ result = run();
83606
+ }
83607
+ return result;
83608
+ };
83609
+ Object.defineProperty(debounced, "isPending", {
83610
+ get() {
83611
+ return timeoutId !== void 0;
83612
+ }
83613
+ });
83614
+ debounced.clear = () => {
83615
+ if (!timeoutId) {
83616
+ return;
83617
+ }
83618
+ clearTimeout(timeoutId);
83619
+ timeoutId = void 0;
83620
+ };
83621
+ debounced.flush = () => {
83622
+ if (!timeoutId) {
83623
+ return;
83624
+ }
83625
+ debounced.trigger();
83626
+ };
83627
+ debounced.trigger = () => {
83628
+ result = run();
83629
+ debounced.clear();
83630
+ };
83631
+ return debounced;
83632
+ }
83633
+ debounce$1.exports.debounce = debounce2;
83634
+ debounce$1.exports = debounce2;
83635
+ return debounce$1.exports;
83636
+ }
83637
+ var debounceExports = /* @__PURE__ */ requireDebounce();
83638
+ const debounce = /* @__PURE__ */ getDefaultExportFromCjs(debounceExports);
83498
83639
  function Table({
83499
83640
  columns,
83500
83641
  dataSource,
@@ -83504,25 +83645,98 @@ function Table({
83504
83645
  rowSelection,
83505
83646
  pagination,
83506
83647
  isMainContentCell = false,
83648
+ isMaterializedView = false,
83649
+ materializedViewConfig,
83507
83650
  ...rest
83508
83651
  }) {
83509
- const paginationConfig = pagination === false ? false : {
83510
- ...pagination,
83511
- itemRender: void 0,
83512
- // Clear any existing itemRender to avoid conflicts
83513
- render: (properties) => /* @__PURE__ */ jsx(
83514
- CustomPagination,
83515
- {
83516
- ...properties,
83517
- paginationStyle: pagination?.paginationStyle || PaginationStyle.SIMPLE
83652
+ const [materializedData, setMaterializedData] = React.useState([]);
83653
+ const [isLoadingMore, setIsLoadingMore] = React.useState(false);
83654
+ const [hasMoreData, setHasMoreData] = React.useState(true);
83655
+ const tableRef = React.useRef(null);
83656
+ React.useEffect(() => {
83657
+ if (isMaterializedView) {
83658
+ const initialSize = materializedViewConfig?.initialLoadSize || 50;
83659
+ const initialData = dataSource.slice(0, initialSize);
83660
+ setMaterializedData(initialData);
83661
+ setHasMoreData(dataSource.length > initialSize);
83662
+ }
83663
+ }, [dataSource, isMaterializedView, materializedViewConfig]);
83664
+ const handleScroll = React.useCallback(
83665
+ debounce((e3) => {
83666
+ if (!isMaterializedView || !materializedViewConfig?.onLoadMore || isLoadingMore || !hasMoreData) {
83667
+ return;
83518
83668
  }
83519
- )
83520
- };
83669
+ const { target } = e3;
83670
+ const { scrollTop, scrollHeight, clientHeight } = target;
83671
+ const threshold = materializedViewConfig?.loadMoreThreshold || 100;
83672
+ if (scrollTop + clientHeight >= scrollHeight - threshold) {
83673
+ setIsLoadingMore(true);
83674
+ const currentLength = materializedData.length;
83675
+ const loadSize = materializedViewConfig?.initialLoadSize || 50;
83676
+ if (materializedViewConfig?.onLoadMore) {
83677
+ Promise.resolve(
83678
+ materializedViewConfig.onLoadMore(currentLength, loadSize)
83679
+ ).then((newData) => {
83680
+ setMaterializedData((prev2) => [...prev2, ...newData]);
83681
+ setHasMoreData(newData.length === loadSize);
83682
+ }).catch((error2) => {
83683
+ console.error("Error loading more data:", error2);
83684
+ }).finally(() => {
83685
+ setIsLoadingMore(false);
83686
+ });
83687
+ } else {
83688
+ const newData = dataSource.slice(
83689
+ currentLength,
83690
+ currentLength + loadSize
83691
+ );
83692
+ setMaterializedData((prev2) => [...prev2, ...newData]);
83693
+ setHasMoreData(newData.length === loadSize);
83694
+ setIsLoadingMore(false);
83695
+ }
83696
+ }
83697
+ }, 200),
83698
+ [
83699
+ isMaterializedView,
83700
+ materializedViewConfig,
83701
+ materializedData,
83702
+ isLoadingMore,
83703
+ hasMoreData,
83704
+ dataSource
83705
+ ]
83706
+ );
83707
+ const paginationConfig = React.useMemo(() => {
83708
+ if (isMaterializedView) {
83709
+ return false;
83710
+ }
83711
+ return pagination === false ? false : {
83712
+ ...pagination,
83713
+ itemRender: void 0,
83714
+ // Clear any existing itemRender to avoid conflicts
83715
+ render: (properties) => /* @__PURE__ */ jsx(
83716
+ CustomPagination,
83717
+ {
83718
+ ...properties,
83719
+ paginationStyle: pagination?.paginationStyle || PaginationStyle.SIMPLE
83720
+ }
83721
+ )
83722
+ };
83723
+ }, [isMaterializedView, pagination]);
83724
+ const scrollConfig = React.useMemo(() => {
83725
+ if (isMaterializedView) {
83726
+ return {
83727
+ ...rest.scroll,
83728
+ y: materializedViewConfig?.height || 400
83729
+ };
83730
+ }
83731
+ return rest.scroll;
83732
+ }, [isMaterializedView, materializedViewConfig, rest.scroll]);
83733
+ const tableDataSource = isMaterializedView ? materializedData : dataSource;
83521
83734
  return /* @__PURE__ */ jsx(
83522
83735
  Table$1,
83523
83736
  {
83737
+ ref: tableRef,
83524
83738
  "data-testid": "Table",
83525
- dataSource,
83739
+ dataSource: tableDataSource,
83526
83740
  columns,
83527
83741
  rowKey,
83528
83742
  locale: { emptyText: "No Data" },
@@ -83530,6 +83744,8 @@ function Table({
83530
83744
  onChange,
83531
83745
  rowSelection,
83532
83746
  pagination: paginationConfig,
83747
+ scroll: scrollConfig,
83748
+ onScroll: isMaterializedView ? handleScroll : void 0,
83533
83749
  $isMainContentCell: isMainContentCell,
83534
83750
  ...rest
83535
83751
  }
@@ -83949,7 +84165,15 @@ const TableWithControls = ({
83949
84165
  onChange
83950
84166
  }) => {
83951
84167
  const { primaryTableRowData, secondaryTableRowData } = tableControlsData2;
83952
- const { dataSource, columns, rowSelection, hasSettings, hasFilter } = tableData;
84168
+ const {
84169
+ dataSource,
84170
+ columns,
84171
+ rowSelection,
84172
+ hasSettings,
84173
+ hasFilter,
84174
+ isMaterializedView,
84175
+ materializedViewConfig
84176
+ } = tableData;
83953
84177
  const onTableControlsChange = (event) => {
83954
84178
  onChange(event);
83955
84179
  };
@@ -83969,12 +84193,14 @@ const TableWithControls = ({
83969
84193
  }
83970
84194
  ),
83971
84195
  /* @__PURE__ */ jsx(
83972
- TablePagination,
84196
+ Table,
83973
84197
  {
83974
84198
  dataSource,
83975
84199
  columns,
83976
84200
  rowSelection,
83977
- onChange: onTableChange
84201
+ onChange: onTableChange,
84202
+ isMaterializedView,
84203
+ materializedViewConfig
83978
84204
  }
83979
84205
  )
83980
84206
  ] });
@@ -84444,7 +84670,7 @@ const useTableWithControls = (tableConfig) => {
84444
84670
  updateDataSource
84445
84671
  };
84446
84672
  };
84447
- const getGenesisClass$1 = ({ colors: colors2, borderRadius: borderRadius2, sizing: sizing2 }, type4 = "primary", state = "active") => `
84673
+ const getGenesisClass = ({ colors: colors2, borderRadius: borderRadius2, sizing: sizing2 }, type4 = "primary", state = "active") => `
84448
84674
  &.ant-tabs {
84449
84675
  background: #F4F4F4;
84450
84676
 
@@ -84540,7 +84766,7 @@ const getGenesisClass$1 = ({ colors: colors2, borderRadius: borderRadius2, sizin
84540
84766
  `;
84541
84767
  const Tabs$1 = styled(Tabs$2)`
84542
84768
  ${({ theme, type: type4, state }) => {
84543
- return getGenesisClass$1(theme, type4, state);
84769
+ return getGenesisClass(theme, type4, state);
84544
84770
  }}
84545
84771
  `;
84546
84772
  const Tabs = ({ items, onChange, selectedId }) => {
@@ -84560,34 +84786,6 @@ const Tabs = ({ items, onChange, selectedId }) => {
84560
84786
  }
84561
84787
  );
84562
84788
  };
84563
- const getGenesisClass = ({ sizing: sizing2 }, $isHorizontal = false) => `
84564
- display: flex;
84565
- flex-direction: ${$isHorizontal ? "row" : "column"};
84566
- padding: ${sizing2.Size4};
84567
- `;
84568
- const Tile$1 = styled.div`
84569
- ${({ theme, $isHorizontal }) => {
84570
- return getGenesisClass(theme, $isHorizontal);
84571
- }}
84572
- `;
84573
- const Tile = ({
84574
- children: children2,
84575
- dataTestId,
84576
- className,
84577
- style: style2,
84578
- isHorizontal = false
84579
- }) => {
84580
- return /* @__PURE__ */ jsx(
84581
- Tile$1,
84582
- {
84583
- className,
84584
- "data-testid": dataTestId,
84585
- style: style2,
84586
- $isHorizontal: isHorizontal,
84587
- children: children2
84588
- }
84589
- );
84590
- };
84591
84789
  const ToastRow = styled.div`
84592
84790
  display: flex;
84593
84791
  align-items: center;
@@ -1 +1 @@
1
- export declare const GlobalStyles: any;
1
+ export declare const GlobalStyles: import('react').NamedExoticComponent<import('styled-components').ExecutionProps & object>;
@@ -0,0 +1 @@
1
+ export { default, createGlobalStyle, useTheme, ThemeProvider, css, } from 'styled-components';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gobolt/genesis",
3
- "version": "0.3.28",
3
+ "version": "0.4.1",
4
4
  "description": "genesis design system",
5
5
  "author": "gobolt",
6
6
  "license": "MIT",