@fibery/ui-kit 1.5.0 → 1.7.0

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 (72) hide show
  1. package/index.ts +0 -1
  2. package/package.json +37 -23
  3. package/src/Item.tsx +5 -2
  4. package/src/Pallete.ts +191 -191
  5. package/src/Select/components.tsx +22 -21
  6. package/src/Select/index.tsx +60 -25
  7. package/src/Select/select-control-settings-context.tsx +20 -0
  8. package/src/Select/select-in-popover.tsx +333 -0
  9. package/src/Select/styles.ts +27 -1
  10. package/src/ThemeProvider.tsx +1 -1
  11. package/src/antd/styles.ts +3 -3
  12. package/src/designSystem.ts +80 -63
  13. package/src/error-alert.tsx +2 -2
  14. package/src/icons/Icon.tsx +17 -12
  15. package/src/icons/ast/AddGroup.ts +8 -0
  16. package/src/icons/ast/AiAssistant.ts +8 -0
  17. package/src/icons/ast/AiAvatar.ts +8 -0
  18. package/src/icons/ast/ArrowBottom.ts +3 -27
  19. package/src/icons/ast/ArrowCollapse.ts +3 -27
  20. package/src/icons/ast/ArrowCollapseVertical.ts +3 -27
  21. package/src/icons/ast/ArrowLeft.ts +3 -27
  22. package/src/icons/ast/ArrowRight.ts +3 -27
  23. package/src/icons/ast/ArrowTop.ts +3 -27
  24. package/src/icons/ast/Atom.ts +8 -0
  25. package/src/icons/ast/Copy.ts +8 -0
  26. package/src/icons/ast/DynamicFilterValue.ts +8 -0
  27. package/src/icons/ast/ExtensionAssignments.ts +3 -35
  28. package/src/icons/ast/FileUpload.ts +8 -0
  29. package/src/icons/ast/FormWithCover.ts +8 -0
  30. package/src/icons/ast/FormWithoutCover.ts +8 -0
  31. package/src/icons/ast/Github.ts +3 -27
  32. package/src/icons/ast/Gitlab.ts +3 -25
  33. package/src/icons/ast/Hint.ts +1 -1
  34. package/src/icons/ast/Jira.ts +8 -0
  35. package/src/icons/ast/Markdown.ts +8 -0
  36. package/src/icons/ast/Minus.ts +3 -23
  37. package/src/icons/ast/MoreCompact.ts +1 -1
  38. package/src/icons/ast/RicheditorBlockFile.ts +8 -0
  39. package/src/icons/ast/RicheditorBlockH4.ts +1 -1
  40. package/src/icons/ast/SimpleCompass.ts +8 -0
  41. package/src/icons/ast/Templates.ts +8 -0
  42. package/src/icons/ast/TypeLocation.ts +8 -0
  43. package/src/icons/ast/ViewForm.ts +3 -25
  44. package/src/icons/ast/ViewMap.ts +8 -0
  45. package/src/icons/ast/index.tsx +199 -182
  46. package/src/icons/react/AddGroup.tsx +12 -0
  47. package/src/icons/react/AiAssistant.tsx +12 -0
  48. package/src/icons/react/AiAvatar.tsx +12 -0
  49. package/src/icons/react/Atom.tsx +12 -0
  50. package/src/icons/react/Copy.tsx +12 -0
  51. package/src/icons/react/DynamicFilterValue.tsx +12 -0
  52. package/src/icons/react/FileUpload.tsx +12 -0
  53. package/src/icons/react/FormWithCover.tsx +12 -0
  54. package/src/icons/react/FormWithoutCover.tsx +12 -0
  55. package/src/icons/react/Github.tsx +8 -6
  56. package/src/icons/react/Gitlab.tsx +8 -6
  57. package/src/icons/react/Jira.tsx +12 -0
  58. package/src/icons/react/Markdown.tsx +12 -0
  59. package/src/icons/react/Minus.tsx +8 -6
  60. package/src/icons/react/RicheditorBlockFile.tsx +12 -0
  61. package/src/icons/react/SimpleCompass.tsx +12 -0
  62. package/src/icons/react/Templates.tsx +12 -0
  63. package/src/icons/react/TypeLocation.tsx +12 -0
  64. package/src/icons/react/ViewForm.tsx +8 -6
  65. package/src/icons/react/ViewMap.tsx +12 -0
  66. package/src/icons/react/index.tsx +199 -182
  67. package/src/tooltip.tsx +132 -152
  68. package/src/BackButton.tsx +0 -27
  69. package/src/Button.d.ts +0 -28
  70. package/src/Button.js +0 -360
  71. package/src/antd/ant-tooltip.tsx +0 -5
  72. package/src/icons/IconAsBackground.tsx +0 -15
package/src/tooltip.tsx CHANGED
@@ -1,184 +1,164 @@
1
- import {css} from "@linaria/core";
2
- import type {ReactNode} from "react";
3
- import cx from "classnames";
4
- import PropTypes from "prop-types";
5
- import {AntTooltip, TooltipPlacement} from "./antd/ant-tooltip";
6
- import {border, opacity, textStyles, themeVars, tooltipDelay} from "./designSystem";
1
+ import {css, cx} from "@linaria/core";
2
+ import * as TooltipPrimitive from "@radix-ui/react-tooltip";
3
+ import type {ReactNode, SyntheticEvent} from "react";
4
+ import {border, lineHeight, space, themeVars, tooltipDelay} from "./designSystem";
5
+
6
+ const preventDefaultAndStopPropagation = (e: SyntheticEvent) => {
7
+ e.preventDefault();
8
+ e.stopPropagation();
9
+ };
7
10
 
8
11
  const titleStyle = css`
9
- ${{
10
- color: themeVars.whiteColor,
11
- fontWeight: 500,
12
- opacity: opacity.opacity90,
13
- }}
12
+ color: ${themeVars.whiteColor};
13
+ line-height: ${lineHeight.heading};
14
+ font-weight: 500;
14
15
  `;
15
16
 
16
17
  const descriptionStyle = css`
17
- ${{
18
- color: themeVars.shortcutTextColor,
19
- fontWeight: 400,
20
- }}
18
+ color: ${themeVars.shortcutTextColor};
19
+ line-height: ${lineHeight.heading};
20
+ font-weight: 400;
21
21
  `;
22
22
 
23
23
  const tooltipStyle = css`
24
- ${{
25
- zIndex: 100000,
26
- transition: "none",
27
- pointerEvents: "none",
28
- maxWidth: 300,
29
- ...textStyles.small,
30
- "& .ant-tooltip-arrow": {
31
- visibility: "hidden",
32
- },
33
- "& .ant-tooltip-inner": {
34
- maxWidth: 300,
35
- minHeight: 30,
36
- backgroundColor: themeVars.tooltipBgColor,
37
- borderRadius: border.radius6,
38
- },
39
- }}
24
+ font-size: 13px;
25
+ color: ${themeVars.whiteColor};
26
+ z-index: 100000;
27
+ min-height: 30px;
28
+ max-width: 300px;
29
+ background-color: ${themeVars.tooltipBgColor};
30
+ padding: ${space.s}px ${space.m}px;
31
+ border-radius: ${border.radius6}px;
32
+ box-shadow: ${themeVars.actionMenuShadow};
33
+
34
+ @media (prefers-reduced-motion: no-preference) {
35
+ @keyframes zoomIn {
36
+ from {
37
+ opacity: 0;
38
+ transform: scale(0.8);
39
+ }
40
+
41
+ to {
42
+ opacity: 1;
43
+ transform: scale(1);
44
+ }
45
+ }
46
+
47
+ @keyframes zoomOut {
48
+ from {
49
+ transform: scale(1);
50
+ }
51
+
52
+ to {
53
+ opacity: 0;
54
+ transform: scale(0.8);
55
+ }
56
+ }
57
+
58
+ will-change: transform, opacity;
59
+ transform-origin: var(--radix-tooltip-content-transform-origin);
60
+ animation-duration: 0.1s;
61
+
62
+ &[data-state="delayed-open"] {
63
+ animation-name: zoomIn;
64
+ animation-timing-function: ease-out;
65
+ }
66
+ }
40
67
  `;
41
68
 
42
69
  const whiteBgStyle = css`
43
- ${{
44
- "& .ant-tooltip-inner": {
45
- backgroundColor: themeVars.actionMenuInnerBg,
46
- color: themeVars.textColor,
47
- },
48
- }}
70
+ background-color: ${themeVars.actionMenuInnerBg};
71
+ color: ${themeVars.textColor};
49
72
  `;
50
73
 
51
- type AlignPoint = string;
52
-
53
- export interface AlignType {
54
- /**
55
- * move point of source node to align with point of target node.
56
- * Such as ['tr','cc'], align top right point of source node with center point of target node.
57
- * Point can be 't'(top), 'b'(bottom), 'c'(center), 'l'(left), 'r'(right) */
58
- points?: AlignPoint[];
59
- /**
60
- * offset source node by offset[0] in x and offset[1] in y.
61
- * If offset contains percentage string value, it is relative to sourceNode region.
62
- */
63
- offset?: number[];
64
- /**
65
- * offset target node by offset[0] in x and offset[1] in y.
66
- * If targetOffset contains percentage string value, it is relative to targetNode region.
67
- */
68
- targetOffset?: number[];
69
- /**
70
- * If adjustX field is true, will adjust source node in x direction if source node is invisible.
71
- * If adjustY field is true, will adjust source node in y direction if source node is invisible.
72
- */
73
- overflow?: {
74
- adjustX?: boolean | number;
75
- adjustY?: boolean | number;
76
- };
77
- /**
78
- * Whether use css right instead of left to position
79
- */
80
- useCssRight?: boolean;
81
- /**
82
- * Whether use css bottom instead of top to position
83
- */
84
- useCssBottom?: boolean;
85
- /**
86
- * Whether use css transform instead of left/top/right/bottom to position if browser supports.
87
- * Defaults to false.
88
- */
89
- useCssTransform?: boolean;
90
- ignoreShake?: boolean;
91
- }
92
-
93
- const alignByPlacement = {
94
- bottom: {offset: [0, -2] as [number, number]},
95
- };
96
-
97
74
  export const TooltipTitle = ({children}: {children: ReactNode}) => <div className={titleStyle}>{children}</div>;
98
75
  export const TooltipDescription = ({children}: {children: ReactNode}) => (
99
76
  <div className={descriptionStyle}>{children}</div>
100
77
  );
101
78
 
102
- export function TooltipContent({title, shortcut}: {title: string; shortcut?: string}) {
103
- return (
104
- <div
105
- className={css`
106
- display: flex;
107
- flex-direction: column;
108
- align-items: center;
109
- `}
110
- >
111
- <TooltipTitle>{title}</TooltipTitle>
112
- {shortcut ? <TooltipDescription>{shortcut}</TooltipDescription> : null}
113
- </div>
114
- );
115
- }
79
+ export const TooltipContent = ({title, shortcut}: {title: string; shortcut?: string}) => (
80
+ <div
81
+ className={css`
82
+ display: flex;
83
+ flex-direction: column;
84
+ align-items: center;
85
+ `}
86
+ >
87
+ <TooltipTitle>{title}</TooltipTitle>
88
+ {shortcut ? <TooltipDescription>{shortcut}</TooltipDescription> : null}
89
+ </div>
90
+ );
116
91
 
117
- type Props = {
92
+ export const TooltipProvider: React.FC<TooltipPrimitive.TooltipProviderProps> = (props) => (
93
+ <TooltipPrimitive.Provider disableHoverableContent skipDelayDuration={150} {...props} />
94
+ );
95
+
96
+ export type TooltipProps = {
118
97
  title?: ReactNode;
119
98
  description?: ReactNode;
120
99
  content?: ReactNode;
121
- placement?: TooltipPlacement;
122
- align?: AlignType;
123
- trigger?: string | string[];
124
- visible?: boolean;
100
+ side?: TooltipPrimitive.TooltipContentProps["side"];
101
+ sideOffset?: TooltipPrimitive.TooltipContentProps["sideOffset"];
102
+ align?: TooltipPrimitive.TooltipContentProps["align"];
103
+ alignOffset?: TooltipPrimitive.TooltipContentProps["alignOffset"];
125
104
  instant?: boolean;
126
- mouseEnterDelay?: number;
127
- children: JSX.Element | string;
105
+ children: ReactNode;
128
106
  whiteBg?: boolean;
107
+ visible?: boolean;
129
108
  onVisibleChange?: (visible: boolean) => void;
130
- destroyTooltipOnHide?: boolean;
131
- getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
109
+ disabled?: boolean;
110
+ /** should keep tooltip visible after click */
111
+ keepOnClick?: boolean;
132
112
  };
133
113
 
134
- export function Tooltip(props: Props) {
135
- const {
136
- title,
137
- description,
138
- content = (title || description) && (
139
- <>
140
- <TooltipTitle>{title}</TooltipTitle>
141
- <TooltipDescription>{description}</TooltipDescription>
142
- </>
143
- ),
144
- align,
145
- placement,
146
- trigger,
147
- visible,
148
- instant,
149
- mouseEnterDelay,
150
- children,
151
- whiteBg,
152
- onVisibleChange,
153
- destroyTooltipOnHide,
154
- getPopupContainer,
155
- } = props;
156
- const maybeVisibleProp = visible === undefined ? {} : {visible};
114
+ export const Tooltip: React.FC<TooltipProps> = ({
115
+ title,
116
+ description,
117
+ content = (title || description) && (
118
+ <>
119
+ <TooltipTitle>{title}</TooltipTitle>
120
+ <TooltipDescription>{description}</TooltipDescription>
121
+ </>
122
+ ),
123
+ side,
124
+ sideOffset = space.xs,
125
+ align,
126
+ alignOffset,
127
+ instant,
128
+ children,
129
+ whiteBg,
130
+ visible,
131
+ onVisibleChange,
132
+ keepOnClick,
133
+ disabled,
134
+ }) => {
135
+ const triggerProps = keepOnClick
136
+ ? {
137
+ onPointerDown: preventDefaultAndStopPropagation,
138
+ onClick: preventDefaultAndStopPropagation,
139
+ }
140
+ : null;
157
141
 
158
142
  return (
159
- <AntTooltip
160
- title={content}
161
- {...maybeVisibleProp}
162
- trigger={trigger}
163
- placement={placement}
164
- mouseEnterDelay={mouseEnterDelay || (instant ? 0 : tooltipDelay.enter)}
165
- mouseLeaveDelay={instant ? 0 : tooltipDelay.leave}
166
- overlayClassName={cx(tooltipStyle, {[whiteBgStyle]: whiteBg})}
167
- align={align || (placement === "bottom" ? alignByPlacement.bottom : undefined)}
168
- onVisibleChange={onVisibleChange}
169
- destroyTooltipOnHide={destroyTooltipOnHide}
170
- getPopupContainer={getPopupContainer}
143
+ <TooltipPrimitive.Root
144
+ delayDuration={instant ? 0 : tooltipDelay.enter}
145
+ open={disabled ? false : Boolean(content) && visible}
146
+ onOpenChange={onVisibleChange}
171
147
  >
172
- {children}
173
- </AntTooltip>
148
+ <TooltipPrimitive.Trigger {...triggerProps} asChild>
149
+ {children}
150
+ </TooltipPrimitive.Trigger>
151
+ <TooltipPrimitive.Portal>
152
+ <TooltipPrimitive.Content
153
+ side={side}
154
+ sideOffset={sideOffset}
155
+ align={align}
156
+ alignOffset={alignOffset}
157
+ className={cx(tooltipStyle, whiteBg && whiteBgStyle)}
158
+ >
159
+ {content}
160
+ </TooltipPrimitive.Content>
161
+ </TooltipPrimitive.Portal>
162
+ </TooltipPrimitive.Root>
174
163
  );
175
- }
176
-
177
- Tooltip.propTypes = {
178
- title: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
179
- description: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
180
- content: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
181
- placement: PropTypes.string,
182
- visible: PropTypes.bool,
183
- instant: PropTypes.bool,
184
164
  };
@@ -1,27 +0,0 @@
1
- import {Button} from "@fibery/ui-kit";
2
- import BackIcon from "./icons/react/Back";
3
- import {Size} from "@fibery/ui-kit/src/Button";
4
-
5
- type Props = {
6
- disabled?: boolean;
7
- pending?: boolean;
8
- onClick: () => unknown;
9
- size?: Size;
10
- color?: string;
11
- };
12
-
13
- export function BackButton({disabled, onClick, pending, size, color}: Props) {
14
- return (
15
- <Button
16
- borderless
17
- Icon={BackIcon}
18
- disabled={disabled}
19
- onClick={onClick}
20
- pending={pending}
21
- size={size}
22
- color={color}
23
- >
24
- Back
25
- </Button>
26
- );
27
- }
package/src/Button.d.ts DELETED
@@ -1,28 +0,0 @@
1
- import type {ComponentPropsWithRef, FunctionComponent} from "react";
2
- import {IconBaseProps} from "./icons/types";
3
- export type Size = ":button-size/super-small" | ":button-size/small" | ":button-size/normal" | ":button-size/big";
4
- type PositionInGroup = "first" | "middle" | "last";
5
- type Props = {
6
- size?: Size;
7
- borderless?: boolean;
8
- Icon?: ((props: IconBaseProps) => JSX.Element) | null;
9
- color?: string;
10
- primary?: boolean;
11
- pending?: boolean;
12
- width?: string | number;
13
- height?: string | number;
14
- inGroup?: PositionInGroup;
15
- } & Omit<ComponentPropsWithRef<"button">, "size" | "width" | "height">;
16
-
17
- export const Button: FunctionComponent<Props>;
18
- export const buttonClassName: string;
19
-
20
- export const ActionsButton: FunctionComponent<{
21
- inverted?: boolean;
22
- label?: string;
23
- color?: string;
24
- onClick?: Props["onClick"];
25
- }>;
26
- export const ActionsButtonCompact: FunctionComponent<
27
- {inverted?: boolean} & Omit<Props, "color" | "borderless" | "Icon" | "size">
28
- >;