@fibery/ui-kit 1.5.0 → 1.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/index.ts +0 -1
  2. package/package.json +38 -24
  3. package/src/Button/AddButton.tsx +13 -0
  4. package/src/{BackButton.tsx → Button/BackButton.tsx} +3 -4
  5. package/src/Button/button-base.tsx +190 -0
  6. package/src/Button/button-group.tsx +76 -0
  7. package/src/Button/button.tsx +242 -0
  8. package/src/Button/icon-button-with-tooltip.tsx +15 -0
  9. package/src/Button/icon-button.tsx +42 -0
  10. package/src/Item.tsx +5 -2
  11. package/src/Pallete.ts +191 -191
  12. package/src/Select/components.tsx +22 -21
  13. package/src/Select/index.tsx +60 -25
  14. package/src/Select/select-control-settings-context.tsx +20 -0
  15. package/src/Select/select-in-popover.tsx +333 -0
  16. package/src/Select/styles.ts +27 -1
  17. package/src/ThemeProvider.tsx +1 -1
  18. package/src/antd/styles.ts +3 -3
  19. package/src/designSystem.ts +80 -63
  20. package/src/error-alert.tsx +2 -2
  21. package/src/icons/Icon.tsx +17 -12
  22. package/src/icons/ast/AddGroup.ts +8 -0
  23. package/src/icons/ast/AiAssistant.ts +8 -0
  24. package/src/icons/ast/AiAvatar.ts +8 -0
  25. package/src/icons/ast/ArrowBottom.ts +3 -27
  26. package/src/icons/ast/ArrowCollapse.ts +3 -27
  27. package/src/icons/ast/ArrowCollapseVertical.ts +3 -27
  28. package/src/icons/ast/ArrowLeft.ts +3 -27
  29. package/src/icons/ast/ArrowRight.ts +3 -27
  30. package/src/icons/ast/ArrowTop.ts +3 -27
  31. package/src/icons/ast/Atom.ts +8 -0
  32. package/src/icons/ast/Copy.ts +8 -0
  33. package/src/icons/ast/DynamicFilterValue.ts +8 -0
  34. package/src/icons/ast/ExtensionAssignments.ts +3 -35
  35. package/src/icons/ast/FileUpload.ts +8 -0
  36. package/src/icons/ast/FormWithCover.ts +8 -0
  37. package/src/icons/ast/FormWithoutCover.ts +8 -0
  38. package/src/icons/ast/Github.ts +3 -27
  39. package/src/icons/ast/Gitlab.ts +3 -25
  40. package/src/icons/ast/Hint.ts +1 -1
  41. package/src/icons/ast/Jira.ts +8 -0
  42. package/src/icons/ast/Markdown.ts +8 -0
  43. package/src/icons/ast/Minus.ts +3 -23
  44. package/src/icons/ast/MoreCompact.ts +1 -1
  45. package/src/icons/ast/RicheditorBlockFile.ts +8 -0
  46. package/src/icons/ast/RicheditorBlockH4.ts +1 -1
  47. package/src/icons/ast/SimpleCompass.ts +8 -0
  48. package/src/icons/ast/Templates.ts +8 -0
  49. package/src/icons/ast/TypeLocation.ts +8 -0
  50. package/src/icons/ast/ViewForm.ts +3 -25
  51. package/src/icons/ast/ViewMap.ts +8 -0
  52. package/src/icons/ast/index.tsx +199 -182
  53. package/src/icons/react/AddGroup.tsx +12 -0
  54. package/src/icons/react/AiAssistant.tsx +12 -0
  55. package/src/icons/react/AiAvatar.tsx +12 -0
  56. package/src/icons/react/Atom.tsx +12 -0
  57. package/src/icons/react/Copy.tsx +12 -0
  58. package/src/icons/react/DynamicFilterValue.tsx +12 -0
  59. package/src/icons/react/FileUpload.tsx +12 -0
  60. package/src/icons/react/FormWithCover.tsx +12 -0
  61. package/src/icons/react/FormWithoutCover.tsx +12 -0
  62. package/src/icons/react/Github.tsx +8 -6
  63. package/src/icons/react/Gitlab.tsx +8 -6
  64. package/src/icons/react/Jira.tsx +12 -0
  65. package/src/icons/react/Markdown.tsx +12 -0
  66. package/src/icons/react/Minus.tsx +8 -6
  67. package/src/icons/react/RicheditorBlockFile.tsx +12 -0
  68. package/src/icons/react/SimpleCompass.tsx +12 -0
  69. package/src/icons/react/Templates.tsx +12 -0
  70. package/src/icons/react/TypeLocation.tsx +12 -0
  71. package/src/icons/react/ViewForm.tsx +8 -6
  72. package/src/icons/react/ViewMap.tsx +12 -0
  73. package/src/icons/react/index.tsx +199 -182
  74. package/src/tooltip.tsx +132 -152
  75. package/src/Button.d.ts +0 -28
  76. package/src/Button.js +0 -360
  77. package/src/antd/ant-tooltip.tsx +0 -5
  78. package/src/icons/IconAsBackground.tsx +0 -15
package/src/Button.js DELETED
@@ -1,360 +0,0 @@
1
- import {hasNonEmptyChild} from "@fibery/react/src/has-non-empty-child";
2
- import {css} from "@linaria/core";
3
- import {styled} from "@linaria/react";
4
- import cx from "classnames";
5
- import _ from "lodash";
6
- import PropTypes from "prop-types";
7
- import {forwardRef} from "react";
8
- import {border, colors, fontWeight, getDarkenColor, getOpacities, opacity, textStyles, themeVars} from "./designSystem";
9
- import MoreIcon from "./icons/react/More";
10
- import MoreCompactIcon from "./icons/react/MoreCompact";
11
- import {Item} from "./Item";
12
- import {Spinner} from "./loaders";
13
- import {useTheme} from "./ThemeProvider";
14
-
15
- const baseSize = 14;
16
-
17
- const fontSizes = {
18
- ":button-size/super-small": baseSize - 4,
19
- ":button-size/small": baseSize - 2,
20
- ":button-size/normal": baseSize,
21
- ":button-size/big": baseSize + 2,
22
- };
23
-
24
- const sizeShifts = {
25
- ":button-size/super-small": -2,
26
- ":button-size/small": -1,
27
- ":button-size/normal": 0,
28
- ":button-size/big": 1,
29
- };
30
-
31
- const buttonBorderWidth = 1;
32
-
33
- const staticButtonStyle = css`
34
- ${{
35
- boxSizing: "border-box",
36
- display: "flex",
37
- justifyContent: "center",
38
- alignItems: "center",
39
- verticalAlign: "middle",
40
- fontWeight: fontWeight.bold,
41
- lineHeight: 1,
42
- margin: 0,
43
- borderRadius: border.radius6,
44
- borderWidth: buttonBorderWidth,
45
- borderStyle: "solid",
46
- outline: "none",
47
- position: "relative",
48
- }}
49
- `;
50
-
51
- const ordersInGroup = {
52
- first: css`
53
- &.${staticButtonStyle} {
54
- ${{
55
- display: "inline-flex",
56
- borderRadius: `${border.radius6}px 0 0 ${border.radius6}px`,
57
- marginRight: -1,
58
- }}
59
- }
60
- `,
61
- middle: css`
62
- &.${staticButtonStyle} {
63
- ${{
64
- display: "inline-flex",
65
- borderRadius: border.radius0,
66
- marginRight: -1,
67
- }}
68
- }
69
- `,
70
- last: css`
71
- &.${staticButtonStyle} {
72
- ${{
73
- display: "inline-flex",
74
- borderRadius: `0 ${border.radius6}px ${border.radius6}px 0`,
75
- }}
76
- }
77
- `,
78
- };
79
-
80
- const getMainColor = ({color, dangerous, theme}) => {
81
- if (color) {
82
- return color;
83
- }
84
- if (dangerous) {
85
- return theme.danger;
86
- }
87
- if (!theme) {
88
- return colors.primary;
89
- }
90
- return theme.buttonColor;
91
- };
92
-
93
- const getBorderColor = ({mainColor, borderless, primary}) => {
94
- if (borderless) {
95
- return colors.transparent;
96
- }
97
- if (primary) {
98
- return mainColor;
99
- }
100
- return getOpacities(mainColor).opacity15;
101
- };
102
-
103
- const getHoverBorderColor = ({mainColor, borderless, primary, hoverBgColor}) => {
104
- if (borderless) {
105
- return colors.transparent;
106
- }
107
- if (primary) {
108
- return hoverBgColor;
109
- }
110
- return mainColor;
111
- };
112
-
113
- const getTextColor = ({mainColor, primary, theme}) => {
114
- if (primary) {
115
- return theme.buttonPrimaryTextColor;
116
- }
117
- return mainColor;
118
- };
119
-
120
- const getBgColor = ({mainColor, primary}) => {
121
- if (primary) {
122
- return mainColor;
123
- }
124
- return colors.transparent;
125
- };
126
-
127
- const getHoverBgColor = ({mainColor, borderless, primary}) => {
128
- if (primary) {
129
- return getDarkenColor(mainColor);
130
- }
131
- if (borderless) {
132
- return getOpacities(mainColor).opacity15;
133
- }
134
- return colors.transparent;
135
- };
136
-
137
- const getSpinnerColor = ({mainColor, primary}) => {
138
- if (primary) {
139
- return colors.inversedTextColor;
140
- }
141
- return mainColor;
142
- };
143
-
144
- const getButtonMagicConstants = _.memoize((size) => {
145
- const sizeShift = sizeShifts[size];
146
-
147
- const fontSize = fontSizes[size];
148
- const minSize = fontSize * 2;
149
- const horizontalPadding = baseSize - 2 + sizeShift * 4;
150
-
151
- return {fontSize, minSize, horizontalPadding};
152
- });
153
-
154
- const getIconMagicConstants = _.memoize((size) => {
155
- const sizeShift = sizeShifts[size];
156
-
157
- const iconSize = baseSize + 2 + sizeShift * 2;
158
- const leftContainerSize = 8;
159
- const leftContainerMarginRight = iconSize - leftContainerSize;
160
-
161
- return {iconSize, leftContainerSize, leftContainerMarginRight};
162
- });
163
-
164
- const StyledButton = styled.button`
165
- font-size: ${({buttonSize}) => getButtonMagicConstants(buttonSize).fontSize}px;
166
- min-height: ${({buttonSize}) => getButtonMagicConstants(buttonSize).minSize}px;
167
- min-width: ${({buttonSize}) => getButtonMagicConstants(buttonSize).minSize}px;
168
- padding-top: 0;
169
- padding-bottom: 0;
170
- padding-left: ${({buttonSize}) => getButtonMagicConstants(buttonSize).horizontalPadding}px;
171
- padding-right: ${({buttonSize}) => getButtonMagicConstants(buttonSize).horizontalPadding}px;
172
- opacity: ${({disabled}) => (disabled ? opacity.regular : 1)};
173
- width: ${({buttonWidth = "auto"}) => (typeof buttonWidth === "string" ? buttonWidth : `${buttonWidth}px`)};
174
- height: ${({buttonHeight = "auto"}) => (typeof buttonHeight === "string" ? buttonHeight : `${buttonHeight}px`)};
175
- color: ${({textColor}) => textColor};
176
- background-color: ${({bgColor}) => bgColor};
177
- border-color: ${({borderColor}) => borderColor};
178
- cursor: ${({clickable}) => (clickable ? "pointer" : "default")};
179
- transition: all 150ms ease-out;
180
-
181
- &:focus {
182
- box-shadow: ${({borderColor, activeStyle}) =>
183
- activeStyle ? `0 0 0 3px ${getOpacities(borderColor).light}` : "none"};
184
- background-color: ${({hoverBgColor}) => hoverBgColor};
185
- border-color: ${({hoverBorderColor}) => hoverBorderColor};
186
- transition: all 150ms ease-out;
187
- }
188
-
189
- &:focus:not(:focus-visible) {
190
- box-shadow: none;
191
- background-color: ${({bgColor}) => bgColor};
192
- border-color: ${({borderColor}) => borderColor};
193
- transition: none;
194
- }
195
-
196
- &:focus-visible {
197
- box-shadow: ${({borderColor, activeStyle}) =>
198
- activeStyle ? `0 0 0 3px ${getOpacities(borderColor).light}` : "none"};
199
- background-color: ${({hoverBgColor}) => hoverBgColor};
200
- border-color: ${({hoverBorderColor}) => hoverBorderColor};
201
- transition: all 150ms ease-out;
202
- }
203
-
204
- &:hover,
205
- &:focus:hover:not(:focus-visible) {
206
- background-color: ${({hoverBgColor}) => hoverBgColor};
207
- border-color: ${({hoverBorderColor}) => hoverBorderColor};
208
- transition: all 150ms ease-out;
209
- }
210
- `;
211
-
212
- export const buttonClassName = StyledButton;
213
-
214
- const shortcutStyle = css`
215
- ${{
216
- ...textStyles.small,
217
- color: themeVars.whiteColor,
218
- border: "solid 1px",
219
- borderRadius: border.radius4,
220
- paddingLeft: 4,
221
- paddingRight: 4,
222
- marginLeft: 4,
223
- opacity: 0.7,
224
- }}
225
- `;
226
-
227
- const leftContainerMarginRightVar = "--fibery-button-left-container-margin-right";
228
-
229
- const leftContainerClassName = css`
230
- margin-right: var(${leftContainerMarginRightVar});
231
- `;
232
-
233
- export const Button = forwardRef(
234
- (
235
- {
236
- children,
237
- color,
238
- dangerous,
239
- borderless,
240
- primary,
241
- pending,
242
- icon,
243
- Icon,
244
- size = ":button-size/normal",
245
- type = "button",
246
- disabled,
247
- width,
248
- height,
249
- inGroup,
250
- onClick,
251
- className,
252
- shortcut,
253
- noOverflow = true,
254
- ...rest
255
- },
256
- forwardedRef
257
- ) => {
258
- const theme = useTheme();
259
- const mainColor = getMainColor({color, dangerous, theme});
260
- const textColor = getTextColor({mainColor, primary, theme});
261
- const spinnerBgColor = getOpacities(textColor).light;
262
- const spinnerColor = getSpinnerColor({mainColor, primary});
263
- const bgColor = getBgColor({mainColor, primary});
264
- const hoverBgColor = getHoverBgColor({mainColor, borderless, primary});
265
- const borderColor = getBorderColor({mainColor, borderless, primary});
266
- const hoverBorderColor = getHoverBorderColor({
267
- mainColor,
268
- borderless,
269
- primary,
270
- hoverBgColor,
271
- });
272
- if (icon) {
273
- // eslint-disable-next-line no-console
274
- console.warn("'icon' props doesn't support anymore. Please use 'Icon' prop with explicit Icon Component");
275
- }
276
- const {iconSize, leftContainerSize, leftContainerMarginRight} = getIconMagicConstants(size);
277
-
278
- const leftContainer = pending ? (
279
- <Spinner
280
- backgroundColor={spinnerBgColor}
281
- color={spinnerColor}
282
- size={iconSize}
283
- containerSize={leftContainerSize}
284
- />
285
- ) : Icon ? (
286
- <Icon color={textColor} size={iconSize} containerSize={leftContainerSize} />
287
- ) : null;
288
- const styleVariable = {
289
- buttonSize: size,
290
- disabled,
291
- pending,
292
- buttonWidth: width,
293
- buttonHeight: height,
294
- textColor,
295
- clickable: !disabled && !pending,
296
- hoverBgColor: !disabled && !pending ? hoverBgColor : bgColor,
297
- hoverBorderColor: !disabled && !pending ? hoverBorderColor : borderColor,
298
- borderColor,
299
- bgColor,
300
- };
301
-
302
- return (
303
- <StyledButton
304
- {...styleVariable}
305
- ref={forwardedRef}
306
- type={type}
307
- onClick={!disabled && !pending && onClick ? onClick : _.noop}
308
- disabled={disabled}
309
- className={cx(className, staticButtonStyle, ordersInGroup[inGroup])}
310
- {...rest}
311
- >
312
- <Item
313
- leftContainer={leftContainer}
314
- style={{
315
- [leftContainerMarginRightVar]: `${leftContainerMarginRight}px`,
316
- }}
317
- containerClassName={cx({[leftContainerClassName]: leftContainer && hasNonEmptyChild(children)})}
318
- rightContainer={shortcut && <span className={cx(shortcutStyle)}>{shortcut}</span>}
319
- noOverflow={noOverflow}
320
- >
321
- {children}
322
- </Item>
323
- </StyledButton>
324
- );
325
- }
326
- );
327
-
328
- Button.propTypes = {
329
- size: PropTypes.oneOf(Object.keys(fontSizes)),
330
- type: PropTypes.string,
331
- primary: PropTypes.bool,
332
- dangerous: PropTypes.bool,
333
- disabled: PropTypes.bool,
334
- pending: PropTypes.bool,
335
- borderless: PropTypes.bool,
336
- icon: PropTypes.string,
337
- color: PropTypes.string,
338
- width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
339
- onClick: PropTypes.func,
340
- inGroup: PropTypes.oneOf(Object.keys(ordersInGroup)),
341
- };
342
-
343
- // TODO can be inlined
344
- export function ActionsButton({onClick, label = ``, disabled}) {
345
- return <Button Icon={MoreIcon} onClick={onClick} borderless aria-label={label} disabled={disabled} />;
346
- }
347
-
348
- export const ActionsButtonCompact = forwardRef(({inverted, ...rest}, ref) => {
349
- const theme = useTheme();
350
- return (
351
- <Button
352
- ref={ref}
353
- size={":button-size/small"}
354
- Icon={MoreCompactIcon}
355
- color={inverted ? colors.inversedTextColor : theme.buttonColor}
356
- borderless
357
- {...rest}
358
- />
359
- );
360
- });
@@ -1,5 +0,0 @@
1
- import Tooltip, {TooltipPlacement} from "antd/lib/tooltip";
2
- import "antd/lib/tooltip/style/css";
3
-
4
- export type {TooltipPlacement};
5
- export {Tooltip as AntTooltip};
@@ -1,15 +0,0 @@
1
- import ReactDOMServer from "react-dom/server";
2
- import {iconSize as defaultIconSize} from "../designSystem";
3
- import {generateIconFromAst} from "./generateIconFromAst";
4
- import {IconDefinition} from "./types";
5
-
6
- export function getBackgroundImage({color, icon}: {color: string; icon: IconDefinition}): string {
7
- const svg = generateIconFromAst(icon.icon.children[0], `svg-${icon.name}`, {
8
- xmlns: "http://www.w3.org/2000/svg",
9
- width: defaultIconSize,
10
- height: defaultIconSize,
11
- viewBox: "0 0 20 20",
12
- fill: encodeURIComponent(color),
13
- });
14
- return svg ? `url('data:image/svg+xml;utf8,${ReactDOMServer.renderToStaticMarkup(svg)}')` : ``;
15
- }