@gobolt/genesis 0.3.21 → 0.3.22

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 (60) hide show
  1. package/dist/Table/Table.d.ts +51 -0
  2. package/dist/Table/Table.js +14 -0
  3. package/dist/Table/TableControls/CustomPagination.d.ts +13 -0
  4. package/dist/Table/TableControls/CustomPagination.js +158 -0
  5. package/dist/Table/TableControls/PaginationNumber.d.ts +7 -0
  6. package/dist/Table/TableControls/PaginationNumber.js +30 -0
  7. package/dist/Table/styles.d.ts +14 -0
  8. package/dist/Table/styles.js +64 -0
  9. package/dist/Table/useTable.d.ts +26 -0
  10. package/dist/Table/useTable.js +141 -0
  11. package/dist/Typography/Typography.d.ts +17 -0
  12. package/dist/Typography/Typography.js +16 -0
  13. package/dist/Typography/index.d.ts +2 -0
  14. package/dist/Typography/index.js +1 -0
  15. package/dist/Typography/styles.d.ts +3 -0
  16. package/dist/Typography/styles.js +54 -0
  17. package/dist/components/Badge/Badge.js +9 -32
  18. package/dist/components/Badge/styles.d.ts +1 -10
  19. package/dist/components/Badge/styles.js +39 -14
  20. package/dist/components/Button/Button.js +4 -27
  21. package/dist/components/Button/IconButton.js +4 -27
  22. package/dist/components/Button/icon-button-styles.d.ts +1 -12
  23. package/dist/components/Button/icon-button-styles.js +69 -16
  24. package/dist/components/Button/styles.d.ts +1 -16
  25. package/dist/components/Button/styles.js +88 -30
  26. package/dist/components/Input/Input.js +6 -29
  27. package/dist/components/Input/styles.d.ts +1 -18
  28. package/dist/components/Input/styles.js +146 -42
  29. package/dist/components/Select/Select.js +101 -125
  30. package/dist/components/Select/SelectTrigger.js +71 -57
  31. package/dist/components/Table/Table.js +8 -27
  32. package/dist/components/Table/TableControls/CustomPagination.js +50 -66
  33. package/dist/components/Table/TableControls/PaginationNumber.js +27 -43
  34. package/dist/components/Table/TableControls/PrimaryTableControlsRow.js +16 -17
  35. package/dist/components/Table/TableControls/SecondaryTableControlsRow.js +14 -36
  36. package/dist/components/Table/TableControls/TableControls.js +3 -4
  37. package/dist/components/Table/TablePagination.js +4 -21
  38. package/dist/components/Table/__mocks__/table-mocks.js +15 -24
  39. package/dist/components/Table/styles.d.ts +1 -15
  40. package/dist/components/Table/styles.js +57 -13
  41. package/dist/components/Table/useTable.js +69 -166
  42. package/dist/components/TableWithControls/TableWithControls.js +6 -7
  43. package/dist/components/TableWithControls/useTableWithControls.js +82 -63
  44. package/dist/components/Tooltip/Tooltip.js +1 -2
  45. package/dist/components/Tooltip/styles.d.ts +1 -14
  46. package/dist/components/Tooltip/styles.js +23 -14
  47. package/dist/components/Typography/Typography.js +6 -29
  48. package/dist/components/Typography/styles.d.ts +3 -21
  49. package/dist/components/Typography/styles.js +41 -24
  50. package/dist/components/UtilityButton/UtilityButton.js +4 -27
  51. package/dist/components/shared/DropdownChevron.js +3 -14
  52. package/dist/constants/index.js +14 -14
  53. package/dist/genesis-theme.types.d.ts +263 -0
  54. package/dist/genesis-theme.types.js +6 -0
  55. package/dist/index.js +89 -0
  56. package/dist/styled.d.ts +1 -0
  57. package/dist/styled.js +44 -0
  58. package/dist/utils/icon-util.d.ts +2 -2
  59. package/dist/utils/icon-util.js +16 -19
  60. package/package.json +1 -1
@@ -1,38 +1,23 @@
1
- var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
2
- if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
3
- return cooked;
4
- };
5
- var __rest = (this && this.__rest) || function (s, e) {
6
- var t = {};
7
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
8
- t[p] = s[p];
9
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
10
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
11
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
12
- t[p[i]] = s[p[i]];
13
- }
14
- return t;
15
- };
16
1
  import styled from "@gobolt/genesis/utils/styled";
17
2
  import { Input as AntInput } from "antd";
18
3
  import { TYPE, STATE } from "@gobolt/genesis/constants";
19
- var getStateColors = function (colors, type, state) {
20
- var filled = {
4
+ const getStateColors = (colors, type, state) => {
5
+ const filled = {
21
6
  color: colors.inputs.onsurface.active,
22
7
  borderColor: colors[TYPE.secondary].active.borderColor,
23
8
  ringColor: colors[type].focussed.ringColor,
24
9
  };
25
- var success = {
10
+ const success = {
26
11
  color: colors.status.success.default,
27
12
  borderColor: colors.status.success.default,
28
13
  ringColor: colors.status.success.ringColor,
29
14
  };
30
- var error = {
15
+ const error = {
31
16
  color: colors.status.error.default,
32
17
  borderColor: colors.status.error.default,
33
18
  ringColor: colors.status.error.ringColor,
34
19
  };
35
- var themeState = state !== STATE.error && state !== STATE.success && state !== STATE.filled
20
+ const themeState = state !== STATE.error && state !== STATE.success && state !== STATE.filled
36
21
  ? {
37
22
  color: colors.inputs.onsurface.active,
38
23
  backgroundColor: colors.inputs.surface.active,
@@ -40,37 +25,156 @@ var getStateColors = function (colors, type, state) {
40
25
  ringColor: colors[type][state].ringColor,
41
26
  }
42
27
  : null;
43
- var stateMap = {
44
- filled: filled,
45
- error: error,
46
- success: success,
47
- themeState: themeState,
28
+ const stateMap = {
29
+ filled,
30
+ error,
31
+ success,
32
+ themeState,
48
33
  };
49
- var getValidKey = function (state) {
50
- var validStates = [STATE.filled, STATE.error, STATE.success];
34
+ const getValidKey = (state) => {
35
+ const validStates = [STATE.filled, STATE.error, STATE.success];
51
36
  return validStates.includes(state) ? state : "themeState";
52
37
  };
53
- var css = stateMap[getValidKey(state)];
38
+ const css = stateMap[getValidKey(state)];
54
39
  return css;
55
40
  };
56
- var getGenesisInputClass = function (_a, type, state, hasBeforeAddon, hasAfterAddon, size) {
57
- var colors = _a.colors, borderRadius = _a.borderRadius, components = _a.components, shadows = _a.shadows;
58
- var stateColors = getStateColors(colors, type, state);
59
- var getBorderRadius = function (hasBeforeAddon, hasAfterAddon) {
41
+ const getGenesisInputClass = ({ colors, borderRadius, components, shadows }, type, state, hasBeforeAddon, hasAfterAddon, size) => {
42
+ const stateColors = getStateColors(colors, type, state);
43
+ const getBorderRadius = (hasBeforeAddon, hasAfterAddon) => {
60
44
  if (hasAfterAddon && !hasBeforeAddon) {
61
- return "".concat(borderRadius.BorderRadiusMd, "px 0px 0px ").concat(borderRadius.BorderRadiusMd, "px");
45
+ return `${borderRadius.BorderRadiusMd}px 0px 0px ${borderRadius.BorderRadiusMd}px`;
62
46
  }
63
47
  if (hasBeforeAddon && !hasAfterAddon) {
64
- return "0px ".concat(borderRadius.BorderRadiusMd, "px ").concat(borderRadius.BorderRadiusMd, "px 0px");
48
+ return `0px ${borderRadius.BorderRadiusMd}px ${borderRadius.BorderRadiusMd}px 0px`;
65
49
  }
66
- return "0px";
50
+ return `0px`;
67
51
  };
68
- return "\n &.ant-input {\n font-family: 'Inter', sans-serif;\n color: ".concat(stateColors.color, ";\n border-color: ").concat(stateColors.borderColor, ";\n box-shadow: ").concat(shadows.inputs[1], " !important;\n height: ").concat(size === "normal" || size === "large" ? "40px" : "32px", " !important;\n }\n\n /* Increase specificity for focus states */\n &.ant-input.ant-input:focus,\n &.ant-input.ant-input:focus-visible,\n &.ant-input.ant-input-focused {\n outline: none !important;\n border-color: ").concat(colors[type].focussed.borderColor, " !important;\n box-shadow: 0 0 0 1px #fff, 0 0 0 3px ").concat(colors[type].focussed.ringColor, " !important;\n }\n\n &.ant-input-outlined {\n border: 1px solid ").concat(stateColors.borderColor, ";\n\n &:hover {\n border-color: ").concat(stateColors.borderColor, ";\n }\n }\n\n .ant-input-group & {\n &:focus-within {\n outline: none;\n color: ").concat(stateColors.color, ";\n box-shadow: none;\n border-color: ").concat(colors[type].focussed.borderColor, ";\n }\n }\n\n .ant-input-group:focus-within {\n outline: none;\n box-shadow: 0 0 0 1px #fff, 0 0 0 3px ").concat(colors[type].focussed.ringColor, ";\n border-radius: ").concat(borderRadius.BorderRadiusMd, "px;\n transition: box-shadow 0.2s ease-in-out;\n\n /* Hide focus styles on inner input when parent is focused */\n .ant-input:focus-within {\n box-shadow: none;\n border-radius: 0;\n border-radius: ").concat(getBorderRadius(hasBeforeAddon, hasAfterAddon), ";\n border-color: #ddd;\n }\n }\n\n /* Remove inner input focus styles when in a group */\n .ant-input-group .ant-input:focus,\n .ant-input-group .ant-input:focus-visible,\n .ant-input-group .ant-input:focus-within {\n outline: none;\n box-shadow: none;\n border-color: ").concat(colors[type].focussed.borderColor, ";\n }\n\n /* Single focus ring on group */\n .ant-input-group:focus-within {\n outline: none;\n box-shadow: 0 0 0 1px #fff, 0 0 0 3px ").concat(colors[type].focussed.ringColor, ";\n border-radius: ").concat(borderRadius.BorderRadiusMd, "px;\n transition: box-shadow 0.2s ease-in-out;\n }\n\n /* Remove focus styles for standalone inputs */\n &:not(.ant-input-group):focus-visible {\n outline: none;\n color: ").concat(stateColors.color, ";\n box-shadow: 0 0 0 1px #fff, 0 0 0 3px ").concat(colors[type].focussed.ringColor, ";\n border-radius: ").concat(borderRadius.BorderRadiusMd, "px;\n border-color: ").concat(colors[type].focussed.borderColor, ";\n transition: box-shadow 0.2s ease-in-out;\n }\n\n &:not(.ant-input-group .ant-input):focus-visible {\n outline: none;\n color: ").concat(stateColors.color, ";\n box-shadow: 0 0 0 1px #fff, 0 0 0 3px ").concat(colors[type].focussed.ringColor, ";\n border-radius: ").concat(borderRadius.BorderRadiusMd, "px;\n border-color: ").concat(colors[type].focussed.borderColor, ";\n transition: box-shadow 0.2s ease-in-out;\n }\n\n &.ant-input-group-wrapper {\n .ant-input-group {\n display: flex;\n align-items: center;\n height: ").concat(size === "normal" || size === "large" ? "40px" : "32px", ";\n\n .ant-input {\n height: 100% !important;\n }\n\n .ant-input-group-addon {\n padding: 0 ").concat(components.input.suffixPrefixHorPadding, ";\n height: 100%;\n display: flex;\n align-items: center;\n min-width: fit-content;\n width: auto;\n \n > * {\n width: 100%;\n }\n \n .ant-select {\n height: 100%;\n \n .ant-select-selector {\n height: 100%;\n display: flex;\n align-items: center;\n }\n }\n }\n }\n }\n ");
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
+ `;
69
173
  };
70
- export var Input = styled(AntInput)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), function (_a) {
71
- var theme = _a.theme, state = _a.state, _b = _a.type, type = _b === void 0 ? TYPE.primary : _b, _c = _a.size, size = _c === void 0 ? "normal" : _c, rest = __rest(_a, ["theme", "state", "type", "size"]);
72
- var hasBeforeAddon = !!rest.addonBefore;
73
- var hasAfterAddon = !!rest.addonAfter;
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;
74
178
  return getGenesisInputClass(theme, type, state, hasBeforeAddon, hasAfterAddon, size);
75
- });
76
- var templateObject_1;
179
+ }}
180
+ `;
@@ -1,114 +1,91 @@
1
- var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
2
- if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
3
- return cooked;
4
- };
5
- var __rest = (this && this.__rest) || function (s, e) {
6
- var t = {};
7
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
8
- t[p] = s[p];
9
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
10
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
11
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
12
- t[p[i]] = s[p[i]];
13
- }
14
- return t;
15
- };
16
- var __read = (this && this.__read) || function (o, n) {
17
- var m = typeof Symbol === "function" && o[Symbol.iterator];
18
- if (!m) return o;
19
- var i = m.call(o), r, ar = [], e;
20
- try {
21
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
22
- }
23
- catch (error) { e = { error: error }; }
24
- finally {
25
- try {
26
- if (r && !r.done && (m = i["return"])) m.call(i);
27
- }
28
- finally { if (e) throw e.error; }
29
- }
30
- return ar;
31
- };
32
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
33
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
34
- if (ar || !(i in from)) {
35
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
36
- ar[i] = from[i];
37
- }
38
- }
39
- return to.concat(ar || Array.prototype.slice.call(from));
40
- };
41
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
42
2
  import React from "react";
43
3
  import { TYPE } from "@gobolt/genesis/constants";
44
4
  import styled from "@gobolt/genesis/utils/styled";
45
5
  import SelectTrigger from "./SelectTrigger";
46
6
  import { useGenesis } from "@gobolt/genesis/providers";
47
- var SelectWrapper = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: relative;\n background-color: transparent;\n border-radius: 8px;\n width: auto;\n\n ", "\n\n ", "\n"], ["\n position: relative;\n background-color: transparent;\n border-radius: 8px;\n width: auto;\n\n ", "\n\n ", "\n"])), function (_a) {
48
- var $isFocused = _a.$isFocused, theme = _a.theme, _b = _a.type, type = _b === void 0 ? "primary" : _b;
49
- return $isFocused &&
50
- "\n background-color: transparent;\n ";
51
- }, function (_a) {
52
- var disabled = _a.disabled, theme = _a.theme;
53
- return disabled &&
54
- "\n cursor: not-allowed;\n \n &:hover {\n border-color: ".concat(theme.colors.inputs.surface.border, ";\n }\n ");
55
- });
56
- var SelectDropdown = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n padding: 0px;\n border-radius: 0px;\n animation-duration: ", ";\n transition: all ", "\n cubic-bezier(0.645, 0.045, 0.355, 1);\n\n &.entering {\n opacity: 0;\n transform: scaleY(0.8);\n }\n\n &.entered {\n opacity: 1;\n transform: scaleY(1);\n }\n\n &.exiting {\n opacity: 0;\n transform: scaleY(0.8);\n }\n"], ["\n padding: 0px;\n border-radius: 0px;\n animation-duration: ", ";\n transition: all ", "\n cubic-bezier(0.645, 0.045, 0.355, 1);\n\n &.entering {\n opacity: 0;\n transform: scaleY(0.8);\n }\n\n &.entered {\n opacity: 1;\n transform: scaleY(1);\n }\n\n &.exiting {\n opacity: 0;\n transform: scaleY(0.8);\n }\n"])), function (_a) {
57
- var theme = _a.theme;
58
- return "".concat(theme.motion.veryfast, "s");
59
- }, function (_a) {
60
- var theme = _a.theme;
61
- return "".concat(theme.motion.veryfast, "s");
62
- });
63
- var MenuItem = styled.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n padding: 8px 12px;\n cursor: ", ";\n background-color: ", ";\n color: ", ";\n display: flex;\n justify-content: space-between;\n align-items: center;\n transition: all ", " ease-in-out;\n opacity: ", ";\n\n ", "\n"], ["\n padding: 8px 12px;\n cursor: ", ";\n background-color: ", ";\n color: ", ";\n display: flex;\n justify-content: space-between;\n align-items: center;\n transition: all ", " ease-in-out;\n opacity: ", ";\n\n ", "\n"])), function (_a) {
64
- var disabled = _a.disabled;
65
- return (disabled ? "not-allowed" : "pointer");
66
- }, function (_a) {
67
- var $isSelected = _a.$isSelected, theme = _a.theme, _b = _a.type, type = _b === void 0 ? "primary" : _b;
68
- return $isSelected ? theme.colors[type].hover.backgroundColor : "transparent";
69
- }, function (_a) {
70
- var $isSelected = _a.$isSelected, disabled = _a.disabled, theme = _a.theme, _b = _a.type, type = _b === void 0 ? "primary" : _b;
71
- return disabled
72
- ? theme.colors.inputs.onsurface.disabled
73
- : $isSelected
74
- ? theme.colors[type].hover.color
75
- : theme.colors.onsurface.copy;
76
- }, function (_a) {
77
- var theme = _a.theme;
78
- return "".concat(theme.motion.veryfast, "s");
79
- }, function (_a) {
80
- var disabled = _a.disabled;
81
- return (disabled ? 0.5 : 1);
82
- }, function (_a) {
83
- var disabled = _a.disabled;
84
- return !disabled &&
85
- "\n &:hover {\n background-color: ".concat(function (_a) {
86
- var $isSelected = _a.$isSelected, theme = _a.theme, _b = _a.type, type = _b === void 0 ? "primary" : _b;
87
- return $isSelected
88
- ? theme.colors[type].hover.backgroundColor
89
- : "rgba(0, 0, 0, 0.04)";
90
- }, ";\n color: ").concat(function (_a) {
91
- var $isSelected = _a.$isSelected, theme = _a.theme, _b = _a.type, type = _b === void 0 ? "primary" : _b;
92
- return $isSelected
93
- ? theme.colors[type].hover.color
94
- : theme.colors.onsurface["copy-dark"];
95
- }, ";\n }\n\n &:active {\n background-color: ").concat(function (_a) {
96
- var theme = _a.theme, _b = _a.type, type = _b === void 0 ? "primary" : _b;
97
- return theme.colors[type].hover.backgroundColor;
98
- }, ";\n color: ").concat(function (_a) {
99
- var theme = _a.theme, _b = _a.type, type = _b === void 0 ? "primary" : _b;
100
- return theme.colors[type].hover.color;
101
- }, ";\n }\n ");
102
- });
103
- var Select = function (_a) {
104
- var _b = _a.type, type = _b === void 0 ? TYPE.primary : _b, state = _a.state, _c = _a.variant, variant = _c === void 0 ? "none" : _c, defaultValue = _a.defaultValue, onChange = _a.onChange, _d = _a.size, size = _d === void 0 ? "normal" : _d, _e = _a.width, width = _e === void 0 ? "100%" : _e, value = _a.value, _f = _a.options, options = _f === void 0 ? [] : _f, placeholder = _a.placeholder, _g = _a.selectDisplayMode, selectDisplayMode = _g === void 0 ? "count" : _g, _h = _a.isSingleSelect, isSingleSelect = _h === void 0 ? true : _h, _j = _a.disabled, disabled = _j === void 0 ? false : _j, rest = __rest(_a, ["type", "state", "variant", "defaultValue", "onChange", "size", "width", "value", "options", "placeholder", "selectDisplayMode", "isSingleSelect", "disabled"]);
105
- var _k = __read(React.useState(false), 2), isOpen = _k[0], setIsOpen = _k[1];
106
- var _l = __read(React.useState(false), 2), isFocused = _l[0], setIsFocused = _l[1];
107
- var _m = __read(React.useState("entered"), 2), dropdownAnimation = _m[0], setDropdownAnimation = _m[1];
108
- var selectReference = React.useRef(null);
109
- var theme = useGenesis().theme;
110
- React.useEffect(function () {
111
- var handleClickOutside = function (event) {
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) => {
112
89
  if (selectReference.current &&
113
90
  !selectReference.current.contains(event.target)) {
114
91
  handleClose();
@@ -118,18 +95,18 @@ var Select = function (_a) {
118
95
  if (isOpen) {
119
96
  document.addEventListener("mousedown", handleClickOutside);
120
97
  }
121
- return function () {
98
+ return () => {
122
99
  document.removeEventListener("mousedown", handleClickOutside);
123
100
  };
124
101
  }, [isOpen]);
125
- var handleClose = function () {
102
+ const handleClose = () => {
126
103
  setDropdownAnimation("exiting");
127
- setTimeout(function () {
104
+ setTimeout(() => {
128
105
  setIsOpen(false);
129
106
  setDropdownAnimation("entered");
130
107
  }, 200);
131
108
  };
132
- var handleTriggerClick = function () {
109
+ const handleTriggerClick = () => {
133
110
  if (disabled)
134
111
  return;
135
112
  setIsFocused(true);
@@ -139,21 +116,21 @@ var Select = function (_a) {
139
116
  else {
140
117
  setIsOpen(true);
141
118
  setDropdownAnimation("entering");
142
- setTimeout(function () {
119
+ setTimeout(() => {
143
120
  setDropdownAnimation("entered");
144
121
  }, 0);
145
122
  }
146
123
  };
147
- var handleOptionSelect = function (optionValue) {
124
+ const handleOptionSelect = (optionValue) => {
148
125
  if (disabled)
149
126
  return;
150
- var newValue;
127
+ let newValue;
151
128
  if (Array.isArray(value)) {
152
129
  // Handle multi-select
153
- var stringValue = value.map(String);
130
+ const stringValue = value.map(String);
154
131
  newValue = stringValue.includes(optionValue)
155
- ? stringValue.filter(function (v) { return v !== optionValue; })
156
- : __spreadArray(__spreadArray([], __read(stringValue), false), [optionValue], false);
132
+ ? stringValue.filter((v) => v !== optionValue)
133
+ : [...stringValue, optionValue];
157
134
  }
158
135
  else {
159
136
  // Handle single select
@@ -162,23 +139,23 @@ var Select = function (_a) {
162
139
  // Autoclose if single select or variant is 'simple'
163
140
  if (isSingleSelect || variant === "simple") {
164
141
  handleClose(); // Close immediately
165
- onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
142
+ onChange?.(newValue);
166
143
  }
167
144
  else {
168
- onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
145
+ onChange?.(newValue);
169
146
  }
170
147
  };
171
- var getSelectModeValue = function (value) {
148
+ const getSelectModeValue = (value) => {
172
149
  if (Array.isArray(value)) {
173
150
  if (selectDisplayMode === "count") {
174
- return "".concat(value.length, " selected");
151
+ return `${value.length} selected`;
175
152
  }
176
153
  return value;
177
154
  }
178
155
  return value;
179
156
  };
180
- var modeValue = getSelectModeValue(value);
181
- return (_jsx("div", { style: { position: "relative", width: width }, children: _jsxs(SelectWrapper, { ref: selectReference, "$isFocused": isFocused, type: type, disabled: disabled, onFocus: function () { return !disabled && setIsFocused(true); }, onBlur: function () { return !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: {
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: {
182
159
  position: "absolute",
183
160
  top: "calc(100% + 4px)",
184
161
  left: 0,
@@ -188,12 +165,11 @@ var Select = function (_a) {
188
165
  boxShadow: "0 2px 8px rgba(0, 0, 0, 0.15)",
189
166
  border: "1px solid #d9d9d9",
190
167
  transformOrigin: "top",
191
- }, children: options.map(function (option) {
192
- var isSelected = Array.isArray(value)
168
+ }, children: options.map((option) => {
169
+ const isSelected = Array.isArray(value)
193
170
  ? value.map(String).includes(option.value)
194
171
  : String(value) === option.value;
195
- return (_jsxs(MenuItem, { onClick: function () { return handleOptionSelect(option.value); }, "$isSelected": isSelected, type: type, disabled: disabled, children: [option.label, isSelected && _jsx("span", { style: { marginLeft: "8px" }, children: "\u2713" })] }, 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));
196
173
  }) }))] }) }));
197
174
  };
198
175
  export default Select;
199
- var templateObject_1, templateObject_2, templateObject_3;