@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,118 @@
1
+ import styled from "@gobolt/genesis/utils/styled";
2
+ import { Button as AntButton } from "antd";
3
+ const getPadding = (size, $themeType, sizing, $isIconButton) => {
4
+ if ($isIconButton && (size === "normal" || size === "large")) {
5
+ return `${sizing.Size2}px ${sizing.Size2}px`;
6
+ }
7
+ if ($isIconButton && size === "small") {
8
+ return `${sizing.Size1}px ${sizing.Size1}px`;
9
+ }
10
+ // utility button padding is different from the main button
11
+ if ($themeType === "utility" && size === "small") {
12
+ return `${sizing.Size1_5}px ${sizing.Size2}px`;
13
+ }
14
+ if ($themeType === "utility" && (size === "normal" || size === "large")) {
15
+ return `${sizing.Size2_5}px ${sizing.Size3}px`;
16
+ }
17
+ if (size === "small") {
18
+ return `${sizing.Size1_5}px ${sizing.Size4}px`;
19
+ }
20
+ if (size === "normal" || size === "large") {
21
+ return `${sizing.Size2_5}px ${sizing.Size6}px`;
22
+ }
23
+ return `${sizing.Size2}px ${sizing.Size2}px`;
24
+ };
25
+ const getHeight = (size) => {
26
+ if (size === "normal" || size === "large") {
27
+ return `40px`;
28
+ }
29
+ if (size === "small") {
30
+ return `32px`;
31
+ }
32
+ return `40px`;
33
+ };
34
+ const getWidth = (size, $isIconButton) => {
35
+ if (!$isIconButton) {
36
+ return `auto`;
37
+ }
38
+ if (size === "normal" || size === "large") {
39
+ return `40px`;
40
+ }
41
+ if (size === "small") {
42
+ return `32px`;
43
+ }
44
+ return `40px`;
45
+ };
46
+ const getVariant = ({ colors, sizing, borderRadius, components }, $themeType, $state, size, $isIconButton) => {
47
+ const backgroundColor = colors[$themeType][$state].backgroundColor;
48
+ return `
49
+ &.ant-btn {
50
+
51
+ color: ${colors[$themeType][$state].color};
52
+ font-size: ${sizing.Size4}px;
53
+ line-height: ${sizing.Size6}px;
54
+ letter-spacing: 0;
55
+ font-weight: 400;
56
+ border-width: 1px;
57
+ line-height: 1 !important;
58
+
59
+ width: ${getWidth(size, $isIconButton)}; !important;
60
+ height: ${getHeight(size)}; !important;
61
+
62
+ background-color: ${colors[$themeType][$state].backgroundColor};
63
+ padding: ${getPadding(size, $themeType, sizing, $isIconButton)};
64
+
65
+ box-shadow: ${$themeType === "utility" ? "0px 1px 2px 0px #00000026" : "none"};
66
+
67
+ border-radius: ${borderRadius.BorderRadiusMd}px;
68
+ gap: ${components.button.gap}px;
69
+ border-style: solid;
70
+ border-color: ${colors[$themeType][$state].borderColor};
71
+
72
+ transition: all 0.2s ease-in-out;
73
+
74
+ &:hover {
75
+ color: ${colors[$themeType].hover.color};
76
+ background-color: ${colors[$themeType].hover.backgroundColor};
77
+ border-color: ${colors[$themeType].hover.borderColor};
78
+ }
79
+
80
+ &:active {
81
+ color: ${colors[$themeType].pressed.color};
82
+ background-color: ${colors[$themeType].pressed.backgroundColor};
83
+ border-color: ${colors[$themeType].pressed.borderColor};
84
+ }
85
+
86
+ &:focus-visible {
87
+ outline: none;
88
+ color: ${colors[$themeType].focussed.color};
89
+ background-color: ${colors[$themeType].focussed.backgroundColor};
90
+ box-shadow: 0 0 0 1px #fff, 0 0 0 4px ${colors[$themeType].focussed.ringColor};
91
+ border-radius: ${borderRadius.BorderRadiusMd}px;
92
+ border-color: ${colors[$themeType].focussed.borderColor};
93
+ transition: box-shadow 0.2s ease-in-out;
94
+ }
95
+
96
+ &:disabled {
97
+ color: ${colors[$themeType].disabled.color};
98
+ background-color: ${colors[$themeType].disabled.backgroundColor};
99
+ border-color: ${colors[$themeType].disabled.borderColor};
100
+ cursor: not-allowed;
101
+ }
102
+
103
+ }
104
+
105
+ `;
106
+ };
107
+ const getGenesisButtonClass = (theme, $themeType, $state, $isIconButton, size) => `
108
+ &.ant-btn {
109
+ font-family: 'Inter', sans-serif;
110
+
111
+ ${getVariant(theme, $themeType, $state, size, $isIconButton)}
112
+ }
113
+ `;
114
+ export const Button = styled(AntButton) `
115
+ ${({ theme, $themeType, $state, children, $isIconButton, size }) => {
116
+ return getGenesisButtonClass(theme, $themeType, $state, $isIconButton, size);
117
+ }}
118
+ `;
@@ -0,0 +1,13 @@
1
+ import React from "react";
2
+ import { STATE } from "../../constants";
3
+ import type { InputProps as AntInputProperties, InputRef } from "antd";
4
+ import type { InputEvent } from "../../types/events";
5
+ type BaseInputProps = Omit<AntInputProperties, "size" | "onChange" | "value">;
6
+ export interface InputProps extends BaseInputProps {
7
+ state?: keyof typeof STATE;
8
+ size?: "normal" | "small" | "large";
9
+ onChange?: (actionEvent: InputEvent) => void;
10
+ value?: string;
11
+ }
12
+ declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<InputRef>>;
13
+ export default Input;
@@ -0,0 +1,34 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React from "react";
3
+ import * as S from "./styles";
4
+ import { STATE } from "../../constants";
5
+ import DropdownChevron from "../shared/DropdownChevron";
6
+ import { Select } from "antd";
7
+ const Input = React.forwardRef(({ state = STATE.active, size = "normal", onChange, value, ...rest }, ref) => {
8
+ // make sure rest.type is ignored in the final output
9
+ // we don't want the rest type "number" to be passed to the input
10
+ // since we have our own version of type
11
+ const { type, ...validRest } = rest;
12
+ // If addonAfter is a Select, use our custom chevron
13
+ const addonAfter = React.isValidElement(rest.addonAfter) && rest.addonAfter.type === Select
14
+ ? React.cloneElement(rest.addonAfter, {
15
+ suffixIcon: _jsx(DropdownChevron, {}),
16
+ })
17
+ : rest.addonAfter;
18
+ const handleChange = React.useCallback((e) => {
19
+ if (onChange) {
20
+ onChange({
21
+ event: "inputChange",
22
+ payload: {
23
+ value: e.target.value,
24
+ },
25
+ });
26
+ }
27
+ }, [onChange]);
28
+ return (_jsx(S.Input, { ...validRest, ref: ref, size: size, state: state, disabled: state === "disabled" || rest.disabled, addonAfter: addonAfter, style: {
29
+ height: size === "normal" || size === "large" ? "40px" : "32px",
30
+ }, onChange: handleChange, value: value }));
31
+ });
32
+ Input.displayName = "Input";
33
+ Input.__ANT_INPUT = true;
34
+ export default Input;
@@ -0,0 +1,2 @@
1
+ export { default } from "./Input";
2
+ export type { InputProps } from "./Input";
@@ -0,0 +1 @@
1
+ export { default } from "./Input";
@@ -0,0 +1 @@
1
+ export declare const Input: any;
@@ -0,0 +1,180 @@
1
+ import styled from "@gobolt/genesis/utils/styled";
2
+ import { Input as AntInput } from "antd";
3
+ import { TYPE, STATE } from "@gobolt/genesis/constants";
4
+ const getStateColors = (colors, type, state) => {
5
+ const filled = {
6
+ color: colors.inputs.onsurface.active,
7
+ borderColor: colors[TYPE.secondary].active.borderColor,
8
+ ringColor: colors[type].focussed.ringColor,
9
+ };
10
+ const success = {
11
+ color: colors.status.success.default,
12
+ borderColor: colors.status.success.default,
13
+ ringColor: colors.status.success.ringColor,
14
+ };
15
+ const error = {
16
+ color: colors.status.error.default,
17
+ borderColor: colors.status.error.default,
18
+ ringColor: colors.status.error.ringColor,
19
+ };
20
+ const themeState = state !== STATE.error && state !== STATE.success && state !== STATE.filled
21
+ ? {
22
+ color: colors.inputs.onsurface.active,
23
+ backgroundColor: colors.inputs.surface.active,
24
+ borderColor: colors.inputs.surface.border,
25
+ ringColor: colors[type][state].ringColor,
26
+ }
27
+ : null;
28
+ const stateMap = {
29
+ filled,
30
+ error,
31
+ success,
32
+ themeState,
33
+ };
34
+ const getValidKey = (state) => {
35
+ const validStates = [STATE.filled, STATE.error, STATE.success];
36
+ return validStates.includes(state) ? state : "themeState";
37
+ };
38
+ const css = stateMap[getValidKey(state)];
39
+ return css;
40
+ };
41
+ const getGenesisInputClass = ({ colors, borderRadius, components, shadows }, type, state, hasBeforeAddon, hasAfterAddon, size) => {
42
+ const stateColors = getStateColors(colors, type, state);
43
+ const getBorderRadius = (hasBeforeAddon, hasAfterAddon) => {
44
+ if (hasAfterAddon && !hasBeforeAddon) {
45
+ return `${borderRadius.BorderRadiusMd}px 0px 0px ${borderRadius.BorderRadiusMd}px`;
46
+ }
47
+ if (hasBeforeAddon && !hasAfterAddon) {
48
+ return `0px ${borderRadius.BorderRadiusMd}px ${borderRadius.BorderRadiusMd}px 0px`;
49
+ }
50
+ return `0px`;
51
+ };
52
+ return `
53
+ &.ant-input {
54
+ font-family: 'Inter', sans-serif;
55
+ color: ${stateColors.color};
56
+ border-color: ${stateColors.borderColor};
57
+ box-shadow: ${shadows.inputs[1]} !important;
58
+ height: ${size === "normal" || size === "large" ? "40px" : "32px"} !important;
59
+ }
60
+
61
+ /* Increase specificity for focus states */
62
+ &.ant-input.ant-input:focus,
63
+ &.ant-input.ant-input:focus-visible,
64
+ &.ant-input.ant-input-focused {
65
+ outline: none !important;
66
+ border-color: ${colors[type].focussed.borderColor} !important;
67
+ box-shadow: 0 0 0 1px #fff, 0 0 0 3px ${colors[type].focussed.ringColor} !important;
68
+ }
69
+
70
+ &.ant-input-outlined {
71
+ border: 1px solid ${stateColors.borderColor};
72
+
73
+ &:hover {
74
+ border-color: ${stateColors.borderColor};
75
+ }
76
+ }
77
+
78
+ .ant-input-group & {
79
+ &:focus-within {
80
+ outline: none;
81
+ color: ${stateColors.color};
82
+ box-shadow: none;
83
+ border-color: ${colors[type].focussed.borderColor};
84
+ }
85
+ }
86
+
87
+ .ant-input-group:focus-within {
88
+ outline: none;
89
+ box-shadow: 0 0 0 1px #fff, 0 0 0 3px ${colors[type].focussed.ringColor};
90
+ border-radius: ${borderRadius.BorderRadiusMd}px;
91
+ transition: box-shadow 0.2s ease-in-out;
92
+
93
+ /* Hide focus styles on inner input when parent is focused */
94
+ .ant-input:focus-within {
95
+ box-shadow: none;
96
+ border-radius: 0;
97
+ border-radius: ${getBorderRadius(hasBeforeAddon, hasAfterAddon)};
98
+ border-color: #ddd;
99
+ }
100
+ }
101
+
102
+ /* Remove inner input focus styles when in a group */
103
+ .ant-input-group .ant-input:focus,
104
+ .ant-input-group .ant-input:focus-visible,
105
+ .ant-input-group .ant-input:focus-within {
106
+ outline: none;
107
+ box-shadow: none;
108
+ border-color: ${colors[type].focussed.borderColor};
109
+ }
110
+
111
+ /* Single focus ring on group */
112
+ .ant-input-group:focus-within {
113
+ outline: none;
114
+ box-shadow: 0 0 0 1px #fff, 0 0 0 3px ${colors[type].focussed.ringColor};
115
+ border-radius: ${borderRadius.BorderRadiusMd}px;
116
+ transition: box-shadow 0.2s ease-in-out;
117
+ }
118
+
119
+ /* Remove focus styles for standalone inputs */
120
+ &:not(.ant-input-group):focus-visible {
121
+ outline: none;
122
+ color: ${stateColors.color};
123
+ box-shadow: 0 0 0 1px #fff, 0 0 0 3px ${colors[type].focussed.ringColor};
124
+ border-radius: ${borderRadius.BorderRadiusMd}px;
125
+ border-color: ${colors[type].focussed.borderColor};
126
+ transition: box-shadow 0.2s ease-in-out;
127
+ }
128
+
129
+ &:not(.ant-input-group .ant-input):focus-visible {
130
+ outline: none;
131
+ color: ${stateColors.color};
132
+ box-shadow: 0 0 0 1px #fff, 0 0 0 3px ${colors[type].focussed.ringColor};
133
+ border-radius: ${borderRadius.BorderRadiusMd}px;
134
+ border-color: ${colors[type].focussed.borderColor};
135
+ transition: box-shadow 0.2s ease-in-out;
136
+ }
137
+
138
+ &.ant-input-group-wrapper {
139
+ .ant-input-group {
140
+ display: flex;
141
+ align-items: center;
142
+ height: ${size === "normal" || size === "large" ? "40px" : "32px"};
143
+
144
+ .ant-input {
145
+ height: 100% !important;
146
+ }
147
+
148
+ .ant-input-group-addon {
149
+ padding: 0 ${components.input.suffixPrefixHorPadding};
150
+ height: 100%;
151
+ display: flex;
152
+ align-items: center;
153
+ min-width: fit-content;
154
+ width: auto;
155
+
156
+ > * {
157
+ width: 100%;
158
+ }
159
+
160
+ .ant-select {
161
+ height: 100%;
162
+
163
+ .ant-select-selector {
164
+ height: 100%;
165
+ display: flex;
166
+ align-items: center;
167
+ }
168
+ }
169
+ }
170
+ }
171
+ }
172
+ `;
173
+ };
174
+ export const Input = styled(AntInput) `
175
+ ${({ theme, state, type = TYPE.primary, size = "normal", ...rest }) => {
176
+ const hasBeforeAddon = !!rest.addonBefore;
177
+ const hasAfterAddon = !!rest.addonAfter;
178
+ return getGenesisInputClass(theme, type, state, hasBeforeAddon, hasAfterAddon, size);
179
+ }}
180
+ `;
@@ -0,0 +1,26 @@
1
+ import React from "react";
2
+ import { TYPE, STATE } from "@gobolt/genesis/constants";
3
+ import { SelectProps as AntSelectProps } from "antd";
4
+ import { GenesisTheme } from "@/lib/styles/theme/genesis-theme.types";
5
+ type Variant = "none" | "simple";
6
+ export interface SelectProps extends Omit<AntSelectProps, "variant" | "size"> {
7
+ type?: keyof typeof TYPE;
8
+ state?: keyof typeof STATE;
9
+ options?: {
10
+ value: string;
11
+ label: React.ReactNode;
12
+ }[];
13
+ variant?: Variant;
14
+ defaultValue?: string | string[] | number | number[] | unknown;
15
+ onChange?: (value: string | string[]) => void;
16
+ size?: "normal" | "small" | "large";
17
+ value?: string[] | string | number[] | number;
18
+ width?: number | string;
19
+ placeholder?: string;
20
+ selectDisplayMode?: "chip" | "count";
21
+ isSingleSelect?: boolean;
22
+ disabled?: boolean;
23
+ theme?: GenesisTheme;
24
+ }
25
+ declare const Select: ({ type, state, variant, defaultValue, onChange, size, width, value, options, placeholder, selectDisplayMode, isSingleSelect, disabled, ...rest }: SelectProps) => import("react/jsx-runtime").JSX.Element;
26
+ export default Select;
@@ -0,0 +1,175 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React from "react";
3
+ import { TYPE } from "@gobolt/genesis/constants";
4
+ import styled from "@gobolt/genesis/utils/styled";
5
+ import SelectTrigger from "./SelectTrigger";
6
+ import { useGenesis } from "@gobolt/genesis/providers";
7
+ const SelectWrapper = styled.div `
8
+ position: relative;
9
+ background-color: transparent;
10
+ border-radius: 8px;
11
+ width: auto;
12
+
13
+ ${({ $isFocused, theme, type = "primary" }) => $isFocused &&
14
+ `
15
+ background-color: transparent;
16
+ `}
17
+
18
+ ${({ disabled, theme }) => disabled &&
19
+ `
20
+ cursor: not-allowed;
21
+
22
+ &:hover {
23
+ border-color: ${theme.colors.inputs.surface.border};
24
+ }
25
+ `}
26
+ `;
27
+ const SelectDropdown = styled.div `
28
+ padding: 0px;
29
+ border-radius: 0px;
30
+ animation-duration: ${({ theme }) => `${theme.motion.veryfast}s`};
31
+ transition: all ${({ theme }) => `${theme.motion.veryfast}s`}
32
+ cubic-bezier(0.645, 0.045, 0.355, 1);
33
+
34
+ &.entering {
35
+ opacity: 0;
36
+ transform: scaleY(0.8);
37
+ }
38
+
39
+ &.entered {
40
+ opacity: 1;
41
+ transform: scaleY(1);
42
+ }
43
+
44
+ &.exiting {
45
+ opacity: 0;
46
+ transform: scaleY(0.8);
47
+ }
48
+ `;
49
+ const MenuItem = styled.div `
50
+ padding: 8px 12px;
51
+ cursor: ${({ disabled }) => (disabled ? "not-allowed" : "pointer")};
52
+ background-color: ${({ $isSelected, theme, type = "primary" }) => $isSelected ? theme.colors[type].hover.backgroundColor : "transparent"};
53
+ color: ${({ $isSelected, disabled, theme, type = "primary" }) => disabled
54
+ ? theme.colors.inputs.onsurface.disabled
55
+ : $isSelected
56
+ ? theme.colors[type].hover.color
57
+ : theme.colors.onsurface.copy};
58
+ display: flex;
59
+ justify-content: space-between;
60
+ align-items: center;
61
+ transition: all ${({ theme }) => `${theme.motion.veryfast}s`} ease-in-out;
62
+ opacity: ${({ disabled }) => (disabled ? 0.5 : 1)};
63
+
64
+ ${({ disabled }) => !disabled &&
65
+ `
66
+ &:hover {
67
+ background-color: ${({ $isSelected, theme, type = "primary" }) => $isSelected
68
+ ? theme.colors[type].hover.backgroundColor
69
+ : "rgba(0, 0, 0, 0.04)"};
70
+ color: ${({ $isSelected, theme, type = "primary" }) => $isSelected
71
+ ? theme.colors[type].hover.color
72
+ : theme.colors.onsurface["copy-dark"]};
73
+ }
74
+
75
+ &:active {
76
+ background-color: ${({ theme, type = "primary" }) => theme.colors[type].hover.backgroundColor};
77
+ color: ${({ theme, type = "primary" }) => theme.colors[type].hover.color};
78
+ }
79
+ `}
80
+ `;
81
+ const Select = ({ type = TYPE.primary, state, variant = "none", defaultValue, onChange, size = "normal", width = "100%", value, options = [], placeholder, selectDisplayMode = "count", isSingleSelect = true, disabled = false, ...rest }) => {
82
+ const [isOpen, setIsOpen] = React.useState(false);
83
+ const [isFocused, setIsFocused] = React.useState(false);
84
+ const [dropdownAnimation, setDropdownAnimation] = React.useState("entered");
85
+ const selectReference = React.useRef(null);
86
+ const { theme } = useGenesis();
87
+ React.useEffect(() => {
88
+ const handleClickOutside = (event) => {
89
+ if (selectReference.current &&
90
+ !selectReference.current.contains(event.target)) {
91
+ handleClose();
92
+ setIsFocused(false);
93
+ }
94
+ };
95
+ if (isOpen) {
96
+ document.addEventListener("mousedown", handleClickOutside);
97
+ }
98
+ return () => {
99
+ document.removeEventListener("mousedown", handleClickOutside);
100
+ };
101
+ }, [isOpen]);
102
+ const handleClose = () => {
103
+ setDropdownAnimation("exiting");
104
+ setTimeout(() => {
105
+ setIsOpen(false);
106
+ setDropdownAnimation("entered");
107
+ }, 200);
108
+ };
109
+ const handleTriggerClick = () => {
110
+ if (disabled)
111
+ return;
112
+ setIsFocused(true);
113
+ if (isOpen) {
114
+ handleClose();
115
+ }
116
+ else {
117
+ setIsOpen(true);
118
+ setDropdownAnimation("entering");
119
+ setTimeout(() => {
120
+ setDropdownAnimation("entered");
121
+ }, 0);
122
+ }
123
+ };
124
+ const handleOptionSelect = (optionValue) => {
125
+ if (disabled)
126
+ return;
127
+ let newValue;
128
+ if (Array.isArray(value)) {
129
+ // Handle multi-select
130
+ const stringValue = value.map(String);
131
+ newValue = stringValue.includes(optionValue)
132
+ ? stringValue.filter((v) => v !== optionValue)
133
+ : [...stringValue, optionValue];
134
+ }
135
+ else {
136
+ // Handle single select
137
+ newValue = optionValue;
138
+ }
139
+ // Autoclose if single select or variant is 'simple'
140
+ if (isSingleSelect || variant === "simple") {
141
+ handleClose(); // Close immediately
142
+ onChange?.(newValue);
143
+ }
144
+ else {
145
+ onChange?.(newValue);
146
+ }
147
+ };
148
+ const getSelectModeValue = (value) => {
149
+ if (Array.isArray(value)) {
150
+ if (selectDisplayMode === "count") {
151
+ return `${value.length} selected`;
152
+ }
153
+ return value;
154
+ }
155
+ return value;
156
+ };
157
+ const modeValue = getSelectModeValue(value);
158
+ return (_jsx("div", { style: { position: "relative", width }, children: _jsxs(SelectWrapper, { ref: selectReference, "$isFocused": isFocused, type: type, disabled: disabled, onFocus: () => !disabled && setIsFocused(true), onBlur: () => !isOpen && setIsFocused(false), tabIndex: disabled ? -1 : 0, children: [_jsx(SelectTrigger, { theme: theme, type: type, state: state, value: modeValue, placeholder: placeholder, open: isOpen, onClick: handleTriggerClick, options: options, disabled: disabled, variant: variant }), isOpen && !disabled && (_jsx(SelectDropdown, { type: type, state: state, className: dropdownAnimation, style: {
159
+ position: "absolute",
160
+ top: "calc(100% + 4px)",
161
+ left: 0,
162
+ right: 0,
163
+ zIndex: 1000,
164
+ backgroundColor: "white",
165
+ boxShadow: "0 2px 8px rgba(0, 0, 0, 0.15)",
166
+ border: "1px solid #d9d9d9",
167
+ transformOrigin: "top",
168
+ }, children: options.map((option) => {
169
+ const isSelected = Array.isArray(value)
170
+ ? value.map(String).includes(option.value)
171
+ : String(value) === option.value;
172
+ return (_jsxs(MenuItem, { onClick: () => handleOptionSelect(option.value), "$isSelected": isSelected, type: type, disabled: disabled, children: [option.label, isSelected && _jsx("span", { style: { marginLeft: "8px" }, children: "\u2713" })] }, option.value));
173
+ }) }))] }) }));
174
+ };
175
+ export default Select;
@@ -0,0 +1,23 @@
1
+ import React from "react";
2
+ import { STATE } from "@gobolt/genesis/constants";
3
+ import { GenesisTheme } from "@/lib/styles/theme/genesis-theme.types";
4
+ type ThemeType = "primary" | "secondary" | "tertiary" | "destructive" | "utility" | "icon";
5
+ type Variant = "none" | "simple";
6
+ interface SelectTriggerProperties {
7
+ type?: ThemeType;
8
+ theme?: GenesisTheme;
9
+ state?: keyof typeof STATE;
10
+ value?: string[] | string | number[] | number;
11
+ placeholder?: string;
12
+ open?: boolean;
13
+ onClick?: () => void;
14
+ renderValue?: (value: any) => React.ReactNode;
15
+ options?: {
16
+ value: string;
17
+ label: React.ReactNode;
18
+ }[];
19
+ disabled?: boolean;
20
+ variant?: Variant;
21
+ }
22
+ declare const SelectTrigger: React.FC<SelectTriggerProperties>;
23
+ export default SelectTrigger;
@@ -0,0 +1,103 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React from "react";
3
+ import styled from "@gobolt/genesis/utils/styled";
4
+ import DropdownChevron from "../shared/DropdownChevron";
5
+ import { Typography } from "@gobolt/genesis/components";
6
+ const getBackgroundColor = (colors, disabled, $variant) => {
7
+ if ($variant === "simple")
8
+ return "#F4F4F4";
9
+ if (disabled)
10
+ return "#F4F4F4";
11
+ return "#fff";
12
+ };
13
+ const TriggerWrapper = styled.div `
14
+ display: flex;
15
+ align-items: center;
16
+ justify-content: space-between;
17
+ cursor: ${({ $disabled }) => ($disabled ? "not-allowed" : "pointer")};
18
+ opacity: ${({ $disabled }) => ($disabled ? 0.4 : 1)};
19
+ position: relative;
20
+ box-shadow: ${({ $variant }) => $variant === "simple" ? "none" : "0px 1px 2px 0px rgba(0, 0, 0, 0.12)"};
21
+ transition: all 0.2s ease-in-out;
22
+ min-height: ${({ $variant }) => ($variant === "simple" ? "32px" : "40px")};
23
+
24
+ &:focus-visible {
25
+ outline: none;
26
+ }
27
+
28
+ &:focus {
29
+ box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.12),
30
+ 0 0 0 3px
31
+ ${({ theme, $themeType = "primary" }) => theme.colors[$themeType].focussed.ringColor};
32
+ }
33
+
34
+ ${({ $variant, theme, $disabled }) => $variant === "simple"
35
+ ? `
36
+ padding: ${theme.sizing.Size1} ${theme.sizing.Size2};
37
+ background: ${$disabled ? theme.colors.inputs.surface.disabled : "rgba(0, 0, 0, 0.04)"};
38
+ border: none;
39
+ border-radius: ${theme.borderRadius.BorderRadiusSm}px;
40
+ min-height: ${({ $variant }) => ($variant === "simple" ? "32px" : "40px")};
41
+
42
+ &:hover {
43
+ border: none;
44
+ }
45
+ `
46
+ : `
47
+ padding: ${theme.sizing.Size1} ${theme.sizing.Size2};
48
+ background: ${$disabled
49
+ ? theme.colors.inputs.surface.disabled
50
+ : theme.colors.surface.default?.backgroundColor};
51
+ border: 1px solid #9a9a9a;
52
+ border-radius: ${theme.borderRadius.BorderRadiusSm}px;
53
+ min-height: ${({ $variant }) => ($variant === "simple" ? "32px" : "40px")};
54
+
55
+ &:hover {
56
+ border-color: rgba(0, 0, 0, 0.2);
57
+ }
58
+ `}
59
+ `;
60
+ const ValueContainer = styled.div `
61
+ display: flex;
62
+ align-items: center;
63
+ gap: ${({ theme }) => theme.sizing.Size2}px;
64
+ flex: 1;
65
+ padding: 4px 8px;
66
+ `;
67
+ const ChevronContainer = styled.div `
68
+ display: flex;
69
+ align-items: center;
70
+ justify-content: center;
71
+ margin-right: ${({ $variant }) => ($variant === "simple" ? "4px" : "4px")};
72
+ margin-left: ${({ $variant }) => ($variant === "simple" ? "4px" : "0")};
73
+ `;
74
+ const SelectTrigger = ({ type = "primary", theme, state, value, placeholder = "Select...", open, onClick, renderValue, options = [], disabled = false, variant = "none", }) => {
75
+ const handleClick = React.useCallback(() => {
76
+ if (disabled)
77
+ return;
78
+ onClick?.();
79
+ }, [disabled, onClick]);
80
+ const displayValue = React.useMemo(() => {
81
+ if (!value)
82
+ return null;
83
+ if (renderValue)
84
+ return renderValue(value);
85
+ if (Array.isArray(value)) {
86
+ if (value.length === 0)
87
+ return null;
88
+ const selectedLabels = value
89
+ .map(String)
90
+ .map((v) => options.find((opt) => opt.value === v)?.label)
91
+ .filter(Boolean);
92
+ return selectedLabels.length > 0
93
+ ? selectedLabels.join(", ")
94
+ : `${value.length} selected`;
95
+ }
96
+ const selectedOption = options.find((opt) => opt.value === String(value));
97
+ return selectedOption?.label || value.toString();
98
+ }, [value, renderValue, options]);
99
+ return (_jsxs(TriggerWrapper, { "$themeType": type, "$state": state, onClick: handleClick, tabIndex: disabled ? -1 : 0, role: "button", "$disabled": disabled, "$variant": variant, style: {
100
+ backgroundColor: getBackgroundColor(theme, disabled, variant),
101
+ }, children: [_jsx(ValueContainer, { "$variant": variant, children: displayValue ? (_jsx(Typography, { variant: "body2", color: disabled ? "copy-light" : "copy", children: displayValue })) : (_jsx(Typography, { variant: "body2", color: disabled ? "copy-light" : "copy-light", children: placeholder })) }), _jsx(ChevronContainer, { "$variant": variant, children: _jsx(DropdownChevron, {}) })] }));
102
+ };
103
+ export default SelectTrigger;