@gobolt/genesis 0.3.21 → 0.3.23

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 (133) hide show
  1. package/dist/components/Button/components/Button/Button.d.ts +16 -0
  2. package/dist/components/Button/components/Button/Button.js +13 -0
  3. package/dist/components/Button/components/Button/styles.d.ts +1 -0
  4. package/dist/components/Button/components/Button/styles.js +118 -0
  5. package/dist/components/Button/constants/index.d.ts +163 -0
  6. package/dist/components/Button/constants/index.js +89 -0
  7. package/dist/components/Table/Table/Table.d.ts +51 -0
  8. package/dist/components/Table/Table/Table.js +14 -0
  9. package/dist/components/Table/Table/TableControls/CustomPagination.d.ts +13 -0
  10. package/dist/components/Table/Table/TableControls/CustomPagination.js +158 -0
  11. package/dist/components/Table/Table/TableControls/PaginationNumber.d.ts +7 -0
  12. package/dist/components/Table/Table/TableControls/PaginationNumber.js +30 -0
  13. package/dist/components/Table/Table/styles.d.ts +14 -0
  14. package/dist/components/Table/Table/styles.js +64 -0
  15. package/dist/components/Table/Table/useTable.d.ts +26 -0
  16. package/dist/components/Table/Table/useTable.js +141 -0
  17. package/dist/components/Table/Typography/Typography.d.ts +17 -0
  18. package/dist/components/Table/Typography/Typography.js +16 -0
  19. package/dist/components/Table/Typography/index.d.ts +2 -0
  20. package/dist/components/Table/Typography/index.js +1 -0
  21. package/dist/components/Table/Typography/styles.d.ts +3 -0
  22. package/dist/components/Table/Typography/styles.js +54 -0
  23. package/dist/components/TableWithControls/components/Badge/Badge.d.ts +16 -0
  24. package/dist/components/TableWithControls/components/Badge/Badge.js +28 -0
  25. package/dist/components/TableWithControls/components/Badge/index.d.ts +2 -0
  26. package/dist/components/TableWithControls/components/Badge/index.js +1 -0
  27. package/dist/components/TableWithControls/components/Badge/styles.d.ts +4 -0
  28. package/dist/components/TableWithControls/components/Badge/styles.js +46 -0
  29. package/dist/components/TableWithControls/components/Button/Button.d.ts +16 -0
  30. package/dist/components/TableWithControls/components/Button/Button.js +13 -0
  31. package/dist/components/TableWithControls/components/Button/IconButton.d.ts +8 -0
  32. package/dist/components/TableWithControls/components/Button/IconButton.js +9 -0
  33. package/dist/components/TableWithControls/components/Button/icon-button-styles.d.ts +1 -0
  34. package/dist/components/TableWithControls/components/Button/icon-button-styles.js +76 -0
  35. package/dist/components/TableWithControls/components/Button/index.d.ts +4 -0
  36. package/dist/components/TableWithControls/components/Button/index.js +2 -0
  37. package/dist/components/TableWithControls/components/Button/styles.d.ts +1 -0
  38. package/dist/components/TableWithControls/components/Button/styles.js +118 -0
  39. package/dist/components/TableWithControls/components/Input/Input.d.ts +13 -0
  40. package/dist/components/TableWithControls/components/Input/Input.js +34 -0
  41. package/dist/components/TableWithControls/components/Input/index.d.ts +2 -0
  42. package/dist/components/TableWithControls/components/Input/index.js +1 -0
  43. package/dist/components/TableWithControls/components/Input/styles.d.ts +1 -0
  44. package/dist/components/TableWithControls/components/Input/styles.js +180 -0
  45. package/dist/components/TableWithControls/components/Select/Select.d.ts +26 -0
  46. package/dist/components/TableWithControls/components/Select/Select.js +175 -0
  47. package/dist/components/TableWithControls/components/Select/SelectTrigger.d.ts +23 -0
  48. package/dist/components/TableWithControls/components/Select/SelectTrigger.js +103 -0
  49. package/dist/components/TableWithControls/components/Select/index.d.ts +2 -0
  50. package/dist/components/TableWithControls/components/Select/index.js +1 -0
  51. package/dist/components/TableWithControls/components/Table/Table.d.ts +51 -0
  52. package/dist/components/TableWithControls/components/Table/Table.js +14 -0
  53. package/dist/components/TableWithControls/components/Table/TableControls/CustomPagination.d.ts +13 -0
  54. package/dist/components/TableWithControls/components/Table/TableControls/CustomPagination.js +158 -0
  55. package/dist/components/TableWithControls/components/Table/TableControls/PaginationNumber.d.ts +7 -0
  56. package/dist/components/TableWithControls/components/Table/TableControls/PaginationNumber.js +30 -0
  57. package/dist/components/TableWithControls/components/Table/TableControls/PrimaryTableControlsRow.d.ts +18 -0
  58. package/dist/components/TableWithControls/components/Table/TableControls/PrimaryTableControlsRow.js +77 -0
  59. package/dist/components/TableWithControls/components/Table/TableControls/SecondaryTableControlsRow.d.ts +11 -0
  60. package/dist/components/TableWithControls/components/Table/TableControls/SecondaryTableControlsRow.js +43 -0
  61. package/dist/components/TableWithControls/components/Table/TableControls/TableControls.d.ts +14 -0
  62. package/dist/components/TableWithControls/components/Table/TableControls/TableControls.js +13 -0
  63. package/dist/components/TableWithControls/components/Table/TableControls/index.d.ts +2 -0
  64. package/dist/components/TableWithControls/components/Table/TableControls/index.js +1 -0
  65. package/dist/components/TableWithControls/components/Table/TablePagination.d.ts +13 -0
  66. package/dist/components/TableWithControls/components/Table/TablePagination.js +11 -0
  67. package/dist/components/TableWithControls/components/Table/__mocks__/table-mocks.d.ts +20 -0
  68. package/dist/components/TableWithControls/components/Table/__mocks__/table-mocks.js +301 -0
  69. package/dist/components/TableWithControls/components/Table/index.d.ts +6 -0
  70. package/dist/components/TableWithControls/components/Table/index.js +3 -0
  71. package/dist/components/TableWithControls/components/Table/styles.d.ts +14 -0
  72. package/dist/components/TableWithControls/components/Table/styles.js +64 -0
  73. package/dist/components/TableWithControls/components/Table/useTable.d.ts +26 -0
  74. package/dist/components/TableWithControls/components/Table/useTable.js +141 -0
  75. package/dist/components/TableWithControls/components/TableWithControls/TableWithControls.d.ts +12 -0
  76. package/dist/components/TableWithControls/components/TableWithControls/TableWithControls.js +20 -0
  77. package/dist/components/TableWithControls/components/TableWithControls/useTableWithControls.d.ts +29 -0
  78. package/dist/components/TableWithControls/components/TableWithControls/useTableWithControls.js +136 -0
  79. package/dist/components/TableWithControls/components/Tooltip/Tooltip.d.ts +7 -0
  80. package/dist/components/TableWithControls/components/Tooltip/Tooltip.js +8 -0
  81. package/dist/components/TableWithControls/components/Tooltip/index.d.ts +2 -0
  82. package/dist/components/TableWithControls/components/Tooltip/index.js +1 -0
  83. package/dist/components/TableWithControls/components/Tooltip/styles.d.ts +6 -0
  84. package/dist/components/TableWithControls/components/Tooltip/styles.js +26 -0
  85. package/dist/components/TableWithControls/components/Typography/Typography.d.ts +17 -0
  86. package/dist/components/TableWithControls/components/Typography/Typography.js +16 -0
  87. package/dist/components/TableWithControls/components/Typography/index.d.ts +2 -0
  88. package/dist/components/TableWithControls/components/Typography/index.js +1 -0
  89. package/dist/components/TableWithControls/components/Typography/styles.d.ts +3 -0
  90. package/dist/components/TableWithControls/components/Typography/styles.js +54 -0
  91. package/dist/components/TableWithControls/components/UtilityButton/UtilityButton.d.ts +5 -0
  92. package/dist/components/TableWithControls/components/UtilityButton/UtilityButton.js +9 -0
  93. package/dist/components/TableWithControls/components/UtilityButton/index.d.ts +2 -0
  94. package/dist/components/TableWithControls/components/UtilityButton/index.js +1 -0
  95. package/dist/components/TableWithControls/components/shared/DropdownChevron.d.ts +2 -0
  96. package/dist/components/TableWithControls/components/shared/DropdownChevron.js +7 -0
  97. package/dist/components/TableWithControls/constants/index.d.ts +163 -0
  98. package/dist/components/TableWithControls/constants/index.js +89 -0
  99. package/dist/components/TableWithControls/types/events.d.ts +22 -0
  100. package/dist/components/TableWithControls/types/events.js +1 -0
  101. package/dist/components/TableWithControls/utils/icon-util.d.ts +3 -0
  102. package/dist/components/TableWithControls/utils/icon-util.js +116 -0
  103. package/dist/components/UtilityButton/components/Button/Button.d.ts +16 -0
  104. package/dist/components/UtilityButton/components/Button/Button.js +13 -0
  105. package/dist/components/UtilityButton/components/Button/IconButton.d.ts +8 -0
  106. package/dist/components/UtilityButton/components/Button/IconButton.js +9 -0
  107. package/dist/components/UtilityButton/components/Button/icon-button-styles.d.ts +1 -0
  108. package/dist/components/UtilityButton/components/Button/icon-button-styles.js +76 -0
  109. package/dist/components/UtilityButton/components/Button/index.d.ts +4 -0
  110. package/dist/components/UtilityButton/components/Button/index.js +2 -0
  111. package/dist/components/UtilityButton/components/Button/styles.d.ts +1 -0
  112. package/dist/components/UtilityButton/components/Button/styles.js +118 -0
  113. package/dist/components/UtilityButton/components/UtilityButton/UtilityButton.d.ts +5 -0
  114. package/dist/components/UtilityButton/components/UtilityButton/UtilityButton.js +9 -0
  115. package/dist/components/UtilityButton/constants/index.d.ts +163 -0
  116. package/dist/components/UtilityButton/constants/index.js +89 -0
  117. package/dist/components/index.d.ts +6 -6
  118. package/dist/components/index.js +7 -0
  119. package/dist/components/index.ts +6 -6
  120. package/dist/constants/index.js +14 -14
  121. package/dist/index.d.ts +9 -9
  122. package/dist/index.js +10 -0
  123. package/dist/index.ts +9 -9
  124. package/package.json +1 -1
  125. package/dist/components/Button/Button.tsx +0 -59
  126. package/dist/components/Table/Table.tsx +0 -112
  127. package/dist/components/Table/useTable.ts +0 -194
  128. package/dist/components/TableWithControls/TableWithControls.tsx +0 -54
  129. package/dist/components/TableWithControls/useTableWithControls.tsx +0 -161
  130. package/dist/components/UtilityButton/UtilityButton.tsx +0 -36
  131. package/dist/constants/index.ts +0 -98
  132. package/dist/styles/theme/genesis-theme.types.ts +0 -297
  133. package/dist/utils/styled.ts +0 -52
@@ -0,0 +1,14 @@
1
+ import { TableProps } from "antd";
2
+ import { type GenesisTheme } from "@gobolt/genesis/styles/theme/genesis-theme.types";
3
+ export interface StyledTableProps<T = any> extends TableProps<T> {
4
+ theme?: GenesisTheme;
5
+ $isMainContentCell?: boolean;
6
+ }
7
+ export declare const getGenesisClass: ({ colors, borderRadius, sizing, typography, components }: {
8
+ colors: any;
9
+ borderRadius: any;
10
+ sizing: any;
11
+ typography: any;
12
+ components: any;
13
+ }, $isMainContentCell: any) => string;
14
+ export declare const Table: any;
@@ -0,0 +1,64 @@
1
+ import styled from "@gobolt/genesis/utils/styled";
2
+ import { Table as AntTable } from "antd";
3
+ export const getGenesisClass = ({ colors, borderRadius, sizing, typography, components }, $isMainContentCell) => {
4
+ // Log the hovered color and the entire tableCell object
5
+ return `
6
+ &.ant-table-wrapper {
7
+ // Add your custom styles here
8
+ }
9
+
10
+ .ant-table {
11
+ // Add your custom table styles here
12
+ }
13
+
14
+ .ant-table-cell {
15
+ font-size: ${$isMainContentCell ? "16px" : "14px"} !important;
16
+ color: ${$isMainContentCell
17
+ ? colors.onsurface.copy
18
+ : colors.onsurface["copy-light"]} !important;
19
+ background-color: ${components.tableCell.surface} !important;
20
+ transition: background-color 0.2s ease;
21
+ }
22
+
23
+ .ant-table-tbody > tr:hover > td,
24
+ .ant-table-tbody > tr:hover > .ant-table-cell {
25
+ background-color: ${components.tableCell.hover} !important;
26
+ }
27
+
28
+ .ant-table-cell-selected {
29
+ background-color: ${components.tableCell.selected} !important;
30
+ }
31
+
32
+ .ant-table-thead > tr > th {
33
+ // Add your custom header styles here
34
+ font-family: 'Inter', sans-serif;
35
+ font-size: ${$isMainContentCell ? "16px" : "14px"} !important;
36
+ font-weight: 400;
37
+ color: ${$isMainContentCell
38
+ ? colors.onsurface.copy
39
+ : colors.onsurface["copy-light"]} !important;
40
+ }
41
+
42
+ .ant-table-tbody > tr {
43
+ // Add your custom row styles here
44
+ }
45
+
46
+ .ant-table-tbody > tr > td {
47
+ // Add your custom cell styles here
48
+ font-family: 'Inter', sans-serif;
49
+ font-size: 14px;
50
+ color: ${colors.onsurface["copy-light"]};
51
+ }
52
+
53
+ .ant-table-tbody > tr.ant-table-row-selected > td,
54
+ .ant-table-tbody > tr.ant-table-row-selected > .ant-table-cell {
55
+ background-color: ${components.tableCell.selected} !important;
56
+ color: #fff !important;
57
+ }
58
+ `;
59
+ };
60
+ export const Table = styled(AntTable) `
61
+ ${({ theme, $isMainContentCell }) => {
62
+ return getGenesisClass(theme, $isMainContentCell);
63
+ }}
64
+ `;
@@ -0,0 +1,26 @@
1
+ import type { ColumnsType } from "antd/es/table";
2
+ import type { SelectionType } from "./Table";
3
+ export type UseTableConfig = {
4
+ columns: ColumnsType<any>;
5
+ filters?: Record<string, any>;
6
+ fetchUrl?: string;
7
+ fetchOptions?: RequestInit;
8
+ selectionType?: SelectionType;
9
+ simulateDelay?: number;
10
+ disableRowSelection?: (record: any) => unknown;
11
+ disableAutoFetch?: boolean;
12
+ dataSource?: any[];
13
+ };
14
+ export declare const useTable: <T extends Record<string, any>>(useTableConfig: any) => {
15
+ isLoading: boolean;
16
+ rowSelection: {
17
+ type: SelectionType;
18
+ onChange: (selectedRowKeys: React.Key[], selectedRows: T[]) => void;
19
+ getCheckboxProps: (record: any) => unknown;
20
+ };
21
+ selectedRows: T[];
22
+ updateDataSource: (newDataSource: T[]) => void;
23
+ dataSource: T[];
24
+ columns: ColumnsType<T>;
25
+ error: Error | null;
26
+ };
@@ -0,0 +1,141 @@
1
+ import { useState, useEffect, useCallback } from "react";
2
+ // Function to sort data by field and order
3
+ const sortData = (data, sorter) => {
4
+ // Handle case when no sorting is applied
5
+ if (!sorter || (Array.isArray(sorter) && sorter.length === 0)) {
6
+ return [...data];
7
+ }
8
+ // Handle multiple sorters
9
+ if (Array.isArray(sorter)) {
10
+ return [...data].sort((a, b) => {
11
+ for (const sort of sorter) {
12
+ if (!sort.field)
13
+ continue;
14
+ const field = sort.field;
15
+ const aValue = a[field];
16
+ const bValue = b[field];
17
+ if (aValue < bValue)
18
+ return sort.order === "ascend" ? -1 : 1;
19
+ if (aValue > bValue)
20
+ return sort.order === "ascend" ? 1 : -1;
21
+ }
22
+ return 0;
23
+ });
24
+ }
25
+ // Handle single sorter
26
+ if (sorter.field) {
27
+ const field = sorter.field;
28
+ return [...data].sort((a, b) => {
29
+ const aValue = a[field];
30
+ const bValue = b[field];
31
+ if (sorter.order === "ascend") {
32
+ if (aValue < bValue)
33
+ return -1;
34
+ if (aValue > bValue)
35
+ return 1;
36
+ return 0;
37
+ }
38
+ if (sorter.order === "descend") {
39
+ if (aValue < bValue)
40
+ return 1;
41
+ if (aValue > bValue)
42
+ return -1;
43
+ return 0;
44
+ }
45
+ return 0;
46
+ });
47
+ }
48
+ return [...data];
49
+ };
50
+ /*
51
+ Example of disableRowSelection function which can be passed to the useTable hook
52
+ const disableRowSelection = (record: any) => ({
53
+ disabled: record.status === "completed", // Column configuration not to be checked
54
+ name: record.status.toString(),
55
+ });
56
+ */
57
+ const defaultRowSelection = (record) => ({
58
+ disabled: false, // Add your disable logic here
59
+ name: record.id,
60
+ });
61
+ export const useTable = (useTableConfig) => {
62
+ const [isLoading, setLoading] = useState(true);
63
+ const { columns, filters = null, fetchUrl = "/table/data", fetchOptions = {
64
+ method: "POST",
65
+ headers: {
66
+ "Content-Type": "application/json",
67
+ },
68
+ body: JSON.stringify(filters),
69
+ }, selectionType = "checkbox", simulateDelay = 0, disableRowSelection = defaultRowSelection, disableAutoFetch = false, dataSource: initialDataSource = [], } = useTableConfig;
70
+ // State to hold the original data and the current data
71
+ const [originalData, setOriginalData] = useState(initialDataSource);
72
+ const [data, setData] = useState({
73
+ dataSource: initialDataSource,
74
+ columns,
75
+ error: null,
76
+ });
77
+ const [selectedRows, setSelectedRows] = useState([]);
78
+ // Load initial data
79
+ useEffect(() => {
80
+ // If auto-fetch is disabled and we have initial data, skip fetching
81
+ if (disableAutoFetch && initialDataSource.length > 0) {
82
+ setLoading(false);
83
+ return;
84
+ }
85
+ const fetchData = async () => {
86
+ try {
87
+ const response = await fetch(fetchUrl, fetchOptions);
88
+ const result = await response.json();
89
+ const sourceData = result.data || [];
90
+ setOriginalData(sourceData);
91
+ setData({
92
+ dataSource: sourceData,
93
+ columns,
94
+ error: null,
95
+ });
96
+ }
97
+ catch (error) {
98
+ console.error("Error fetching table data:", error);
99
+ // Fallback to static data
100
+ setData({
101
+ dataSource: [],
102
+ columns,
103
+ error: error instanceof Error ? error : new Error(String(error)),
104
+ });
105
+ }
106
+ finally {
107
+ setLoading(false);
108
+ }
109
+ };
110
+ if (simulateDelay > 0) {
111
+ setTimeout(fetchData, simulateDelay);
112
+ }
113
+ else {
114
+ fetchData();
115
+ }
116
+ }, [fetchOptions, disableAutoFetch, initialDataSource]);
117
+ const handleRowSelection = useCallback((selectedRowKeys, selectedRows) => {
118
+ console.log("Row Selected:", selectedRowKeys, selectedRows);
119
+ setSelectedRows(selectedRows);
120
+ }, []);
121
+ // Function to manually update data source (for external data fetching)
122
+ const updateDataSource = useCallback((newDataSource) => {
123
+ setOriginalData(newDataSource);
124
+ setData((prev) => ({
125
+ ...prev,
126
+ dataSource: newDataSource,
127
+ }));
128
+ }, []);
129
+ const rowSelection = {
130
+ type: selectionType,
131
+ onChange: handleRowSelection,
132
+ getCheckboxProps: disableRowSelection,
133
+ };
134
+ return {
135
+ ...data,
136
+ isLoading,
137
+ rowSelection,
138
+ selectedRows,
139
+ updateDataSource,
140
+ };
141
+ };
@@ -0,0 +1,17 @@
1
+ import React, { CSSProperties } from "react";
2
+ import { TYPE, TYPOGRAPHY_VARIANT, STATE } from "@gobolt/genesis/constants";
3
+ type HeadingLevel = 1 | 2 | 3 | 4 | 5;
4
+ export interface TypographyProps {
5
+ children: React.ReactNode;
6
+ variant?: keyof typeof TYPOGRAPHY_VARIANT;
7
+ themeType?: keyof typeof TYPE;
8
+ state?: keyof typeof STATE;
9
+ color?: string;
10
+ level?: HeadingLevel;
11
+ isText?: boolean;
12
+ isFullWidth?: boolean;
13
+ style?: CSSProperties;
14
+ isDisabled?: boolean;
15
+ }
16
+ declare const Typography: ({ children, themeType, variant, state, color, isText, isFullWidth, style, isDisabled, ...rest }: TypographyProps) => import("react/jsx-runtime").JSX.Element;
17
+ export default Typography;
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import * as S from "./styles";
3
+ import { useGenesis } from "@gobolt/genesis/providers";
4
+ import { TYPE, TYPOGRAPHY_VARIANT, STATE, } from "@gobolt/genesis/constants";
5
+ const Typography = ({ children, themeType = TYPE.secondary, variant = TYPOGRAPHY_VARIANT.body1, state = STATE.active, color, isText = false, isFullWidth, style, isDisabled, ...rest }) => {
6
+ const { breakpoint } = useGenesis();
7
+ if (variant.startsWith("display") || variant.startsWith("heading")) {
8
+ const level = variant.split("heading")[1] || variant.split("display")[1];
9
+ return (_jsx(S.Headline, { state: state, "$themeType": themeType, variant: variant, breakpoint: breakpoint, color: color, level: Number.parseInt(level), "$isFullWidth": isFullWidth, style: style, disabled: isDisabled, ...rest, children: children }));
10
+ }
11
+ if (isText) {
12
+ return (_jsx(S.Text, { state: state, "$themeType": themeType, variant: variant, breakpoint: breakpoint, color: color, "$isFullWidth": isFullWidth, style: style, disabled: isDisabled, ...rest, children: children }));
13
+ }
14
+ return (_jsx(S.Paragraph, { state: state, "$themeType": themeType, variant: variant, breakpoint: breakpoint, color: color, "$isFullWidth": isFullWidth, style: style, disabled: isDisabled, ...rest, children: children }));
15
+ };
16
+ export default Typography;
@@ -0,0 +1,2 @@
1
+ export { default } from "./Typography";
2
+ export type { TypographyProps } from "./Typography";
@@ -0,0 +1 @@
1
+ export { default } from "./Typography";
@@ -0,0 +1,3 @@
1
+ export declare const Headline: any;
2
+ export declare const Paragraph: any;
3
+ export declare const Text: any;
@@ -0,0 +1,54 @@
1
+ import styled from "@gobolt/genesis/utils/styled";
2
+ import { Typography as AntTypography } from "antd";
3
+ const getVariant = (typography, variant, breakpoint) => {
4
+ return `
5
+ font-size: ${typography[breakpoint][variant].fontSize}px !important;
6
+ line-height: ${typography[breakpoint][variant].lineHeight};
7
+ letter-spacing: ${typography[breakpoint][variant].letterSpacing}px;
8
+ font-weight: ${typography[breakpoint][variant].fontWeight};
9
+ `;
10
+ };
11
+ const getColor = (color, colors, $themeType) => {
12
+ if (color) {
13
+ return color;
14
+ }
15
+ return colors[$themeType].active.color;
16
+ };
17
+ const getFontFamily = (variant) => {
18
+ return `
19
+ ${variant.includes("digits")
20
+ ? "'Roboto Mono', sans-serif"
21
+ : "'Inter', sans-serif"} !important;
22
+ `;
23
+ };
24
+ const getGenesisTypographyClass = ({ colors, typography }, $themeType, variant, state, breakpoint, color, $isFullWidth) => `
25
+ &.ant-typography {
26
+ font-family: ${getFontFamily(variant)};
27
+ color: ${getColor(color, colors, $themeType)} !important;
28
+ ${getVariant(typography, variant, breakpoint)}
29
+ margin-bottom: 0 !important;
30
+ width: ${$isFullWidth ? "100%" : "auto"};
31
+ line-height: 1;
32
+
33
+ &:disabled {
34
+ color: ${colors.status.disabled.default} !important;
35
+ userSelect: none;
36
+ cursor: not-allowed;
37
+ }
38
+ }
39
+ `;
40
+ export const Headline = styled(AntTypography.Title) `
41
+ ${({ theme, $themeType, variant, state, breakpoint, color, $isFullWidth, }) => {
42
+ return getGenesisTypographyClass(theme, $themeType, variant, state, breakpoint, color, $isFullWidth);
43
+ }}
44
+ `;
45
+ export const Paragraph = styled(AntTypography.Paragraph) `
46
+ ${({ theme, $themeType, variant, state, breakpoint, color, $isFullWidth, }) => {
47
+ return getGenesisTypographyClass(theme, $themeType, variant, state, breakpoint, color, $isFullWidth);
48
+ }}
49
+ `;
50
+ export const Text = styled(AntTypography.Text) `
51
+ ${({ theme, $themeType, variant, state, breakpoint, color, $isFullWidth, }) => {
52
+ return getGenesisTypographyClass(theme, $themeType, variant, state, breakpoint, color, $isFullWidth);
53
+ }}
54
+ `;
@@ -0,0 +1,16 @@
1
+ export type State = "success" | "warning" | "error" | "info" | "generic" | "hollow";
2
+ export interface BadgeProps {
3
+ label?: string;
4
+ isDisabled?: boolean;
5
+ state?: State;
6
+ hasClose?: boolean;
7
+ hasIcon?: boolean;
8
+ customIcon?: React.ReactNode | null;
9
+ size?: "small" | "normal" | "large";
10
+ backgroundColor?: string;
11
+ textColor?: string;
12
+ onClick?: () => void | null;
13
+ hasHover?: boolean;
14
+ }
15
+ declare const Badge: ({ label, state, isDisabled, hasClose, onClick, size, hasIcon, customIcon, backgroundColor, textColor, hasHover, ...rest }: BadgeProps) => import("react/jsx-runtime").JSX.Element;
16
+ export default Badge;
@@ -0,0 +1,28 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as S from "./styles";
3
+ import { Typography } from "@gobolt/genesis/components";
4
+ import { useGenesis } from "@gobolt/genesis/providers";
5
+ import { getBadgeStateIcon } from "@gobolt/genesis/utils/icon-util";
6
+ import { HiOutlineX } from "react-icons/hi";
7
+ const isBadgeIconFilled = false;
8
+ const Badge = ({ label, state = "info", isDisabled, hasClose = false, onClick = () => { }, size = "normal", hasIcon = true, customIcon = null, backgroundColor = null, textColor = null, hasHover = false, ...rest }) => {
9
+ const { theme } = useGenesis();
10
+ const role = hasClose ? "button" : "badge";
11
+ if (!label) {
12
+ return (_jsx(S.Badge, { label: label, role: "badge", state: state, disabled: isDisabled, style: {
13
+ padding: "4px 4px",
14
+ }, "$hasHover": hasHover, ...rest, children: _jsx("div", { style: {
15
+ display: "flex",
16
+ justifyContent: "center",
17
+ alignItems: "center",
18
+ }, children: getBadgeStateIcon(state, backgroundColor || theme.colors.status[state].onsurface, isBadgeIconFilled, hasIcon, customIcon) }) }));
19
+ }
20
+ return (_jsxs(S.Badge, { label: label, role: role, onClick: onClick, state: state, disabled: isDisabled, style: { cursor: role === "button" ? "pointer" : "default" }, "$backgroundColor": backgroundColor, "$hasHover": hasHover, ...rest, children: [getBadgeStateIcon(state, isDisabled
21
+ ? theme.colors.status.disabled.default
22
+ : textColor || theme.colors.status[state].onsurface, isBadgeIconFilled, hasIcon, customIcon), _jsx(Typography, { variant: size === "small" ? "label3" : "label2", color: isDisabled
23
+ ? theme.colors.status.disabled.default
24
+ : textColor || theme.colors.status[state].onsurface,
25
+ // @ts-ignore
26
+ isDisabled: isDisabled, children: label }), hasClose ? (_jsx(HiOutlineX, { color: theme.colors.status[state].onsurface })) : null] }));
27
+ };
28
+ export default Badge;
@@ -0,0 +1,2 @@
1
+ export { default } from "./Badge";
2
+ export type { BadgeProps } from "./Badge";
@@ -0,0 +1 @@
1
+ export { default } from "./Badge";
@@ -0,0 +1,4 @@
1
+ import { type GenesisTheme } from "@gobolt/genesis/styles/theme/genesis-theme.types";
2
+ import { type State } from "./Badge";
3
+ export declare const getGenesisClass: (theme: GenesisTheme, state: State, label?: string, disabled?: boolean, $backgroundColor?: string, $hasHover?: boolean) => string;
4
+ export declare const Badge: any;
@@ -0,0 +1,46 @@
1
+ import styled from "@gobolt/genesis/utils/styled";
2
+ const getBorderColor = (theme, state) => {
3
+ if (state === "hollow") {
4
+ return theme.colors.inputs.surface.border;
5
+ }
6
+ return theme.colors.status[state].surface;
7
+ };
8
+ export const getGenesisClass = (theme, state, label, disabled, $backgroundColor, $hasHover) => `
9
+ display: inline-flex;
10
+ align-self: inherit;
11
+ gap: 4px;
12
+ justify-content: center;
13
+ align-items: center;
14
+ position: relative;
15
+ padding-top: ${theme.components.badge["ver-padding"]}px;
16
+ padding-bottom: ${theme.components.badge["ver-padding"]}px;
17
+ padding-left: ${theme.components.badge["left-padding"]}px;
18
+ padding-right: ${theme.components.badge["right-padding"]}px;
19
+ border-radius: ${theme.components.badge.radius}px;
20
+ border: 1px solid ${getBorderColor(theme, state)};
21
+ background-color: ${$backgroundColor || theme.colors.status[state].surface};
22
+
23
+ &:not(:disabled):hover {
24
+ ${$hasHover
25
+ ? `background-color: ${theme.colors.status[state]["surface-hover"]};`
26
+ : ""}
27
+ }
28
+
29
+ ${disabled
30
+ ? `
31
+ background-color: ${theme.colors.status.disabled.surface} !important;
32
+ border-color: ${theme.colors.status.disabled} !important;
33
+ border: none;
34
+ cursor: not-allowed;
35
+
36
+ &:hover {
37
+ cursor: not-allowed;
38
+ }
39
+ `
40
+ : ""}
41
+ `;
42
+ export const Badge = styled.div `
43
+ ${({ theme, state, label, disabled, $backgroundColor, $hasHover, }) => {
44
+ return getGenesisClass(theme, state, label, disabled, $backgroundColor, $hasHover);
45
+ }}
46
+ `;
@@ -0,0 +1,16 @@
1
+ import React, { MouseEvent } from "react";
2
+ import type { ButtonProps as AntButtonProperties } from "antd/es/button";
3
+ import { STATE } from "../../constants";
4
+ type ButtonThemeType = "primary" | "secondary" | "tertiary" | "destructive" | "utility" | "icon";
5
+ export interface ButtonProps extends Omit<AntButtonProperties, "type" | "size"> {
6
+ onClick?: (event: MouseEvent<HTMLButtonElement>) => void;
7
+ children?: React.ReactNode;
8
+ themeType?: ButtonThemeType;
9
+ state?: keyof typeof STATE;
10
+ isIconButton?: boolean;
11
+ size?: "small" | "normal" | "large";
12
+ isSelected?: boolean;
13
+ icon?: React.ReactNode;
14
+ }
15
+ declare const Button: React.FC<ButtonProps>;
16
+ export default Button;
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import * as S from "./styles";
3
+ const getState = (state, isSelected) => {
4
+ if (isSelected) {
5
+ return "selected";
6
+ }
7
+ return state === "active" || state === "disabled" ? state : "active";
8
+ };
9
+ const Button = ({ children, onClick, themeType = "primary", state = "active", isIconButton = false, size = "normal", isSelected, ...rest }) => {
10
+ const buttonState = getState(state, isSelected);
11
+ return (_jsx(S.Button, { onClick: onClick, "$themeType": themeType, "$state": buttonState, disabled: state === "disabled" || rest.disabled, "$isIconButton": isIconButton, size: size, ...rest, children: children }));
12
+ };
13
+ export default Button;
@@ -0,0 +1,8 @@
1
+ import type { ButtonProps } from "./Button";
2
+ export interface IconButtonProps extends Omit<ButtonProps, "themeType" | "size"> {
3
+ icon: React.ReactNode;
4
+ size?: "small" | "normal" | "large";
5
+ isSelected?: boolean;
6
+ }
7
+ declare const IconButton: ({ isSelected, state, onClick, icon, size, ...rest }: IconButtonProps) => import("react/jsx-runtime").JSX.Element;
8
+ export default IconButton;
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import * as S from "./icon-button-styles";
3
+ import { TYPE } from "../../constants";
4
+ const IconButton = ({ isSelected = false, state = "active", onClick, icon, size = "small", ...rest }) => {
5
+ const buttonState = state === "active" || state === "disabled" ? state : "active";
6
+ const themeType = TYPE.icon;
7
+ return (_jsx(S.Button, { onClick: onClick, "$themeType": themeType, "$state": buttonState, disabled: state === "disabled" || rest.disabled, size: size, "$isSelected": isSelected, ...rest, children: icon }));
8
+ };
9
+ export default IconButton;
@@ -0,0 +1 @@
1
+ export declare const Button: any;
@@ -0,0 +1,76 @@
1
+ import styled from "@gobolt/genesis/utils/styled";
2
+ const getPadding = (size, sizing) => {
3
+ if (size === "small") {
4
+ return `${sizing.Size1}px ${sizing.Size1}px`;
5
+ }
6
+ return `${sizing.Size2}px ${sizing.Size2}px`;
7
+ };
8
+ const getVariant = ({ colors, sizing, borderRadius, components }, $themeType, $state, size, $isSelected) => {
9
+ return `
10
+ display: flex;
11
+ align-items: center;
12
+ justify-content: center;
13
+ text-align: center;
14
+ color: ${colors[$themeType][$state].color};
15
+ font-size: ${sizing.Size4}px;
16
+ line-height: ${sizing.Size6}px;
17
+ letter-spacing: 0;
18
+ font-weight: 400;
19
+ border-width: 1px;
20
+ cursor: pointer;
21
+ width: auto; !important;
22
+ height: auto; !important;
23
+
24
+ background-color:${$isSelected
25
+ ? colors[$themeType].hover.backgroundColor
26
+ : colors[$themeType][$state].backgroundColor};
27
+ padding: ${getPadding(size, sizing)};
28
+
29
+ box-shadow: ${$themeType === "utility" ? "0px 1px 2px 0px #00000026" : "none"};
30
+
31
+ border-radius: ${borderRadius.BorderRadiusMd}px;
32
+ gap: ${components.button.gap}px;
33
+ border-style: solid;
34
+ border-color: ${colors[$themeType][$state].borderColor};
35
+
36
+ transition: all 0.2s ease-in-out;
37
+
38
+ &:hover {
39
+ color: ${colors[$themeType].hover.color};
40
+ background-color: ${colors[$themeType].hover.backgroundColor};
41
+ border-color: ${colors[$themeType].hover.borderColor};
42
+ }
43
+
44
+ &:active {
45
+ color: ${colors[$themeType].pressed.color};
46
+ background-color: ${colors[$themeType].pressed.backgroundColor};
47
+ border-color: ${colors[$themeType].pressed.borderColor};
48
+ }
49
+
50
+ &:focus-visible {
51
+ outline: none;
52
+ color: ${colors[$themeType].focussed.color};
53
+ background-color: ${colors[$themeType].focussed.backgroundColor};
54
+ box-shadow: 0 0 0 1px #fff, 0 0 0 4px ${colors[$themeType].focussed.ringColor};
55
+ border-radius: ${borderRadius.BorderRadiusMd}px;
56
+ border-color: ${colors[$themeType].focussed.borderColor};
57
+ transition: box-shadow 0.2s ease-in-out;
58
+ }
59
+
60
+ &:disabled {
61
+ color: ${colors[$themeType].disabled.color};
62
+ background-color: ${colors[$themeType].disabled.backgroundColor};
63
+ border-color: ${colors[$themeType].disabled.borderColor};
64
+ cursor: not-allowed;
65
+ }
66
+ `;
67
+ };
68
+ const getGenesisButtonClass = (theme, $themeType, $state, size, $isSelected) => `
69
+ font-family: 'Inter', sans-serif;
70
+ ${getVariant(theme, $themeType, $state, size, $isSelected)}
71
+ `;
72
+ export const Button = styled.button `
73
+ ${({ theme, $themeType, $state, size, $isSelected }) => {
74
+ return getGenesisButtonClass(theme, $themeType, $state, size, $isSelected);
75
+ }}
76
+ `;
@@ -0,0 +1,4 @@
1
+ export { default } from "./Button";
2
+ export type { ButtonProps } from "./Button";
3
+ export { default as IconButton } from "./IconButton";
4
+ export type { IconButtonProps } from "./IconButton";
@@ -0,0 +1,2 @@
1
+ export { default } from "./Button";
2
+ export { default as IconButton } from "./IconButton";
@@ -0,0 +1 @@
1
+ export declare const Button: any;