@fibery/ui-kit 2.0.0 → 2.0.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 (100) hide show
  1. package/.oxlintrc.json +24 -0
  2. package/CHANGELOG.md +7 -0
  3. package/eslint.config.mjs +1 -1
  4. package/jest.config.cjs +36 -0
  5. package/package.json +10 -50
  6. package/src/@types/css.d.ts +1 -0
  7. package/src/actions-menu/actions-menu-checkbox-item.tsx +74 -0
  8. package/src/actions-menu/contexts/actions-menu-context.tsx +1 -0
  9. package/src/actions-menu/index.tsx +1 -0
  10. package/src/animated-number.tsx +2 -2
  11. package/src/antd/AutoComplete.d.ts +1 -0
  12. package/src/app-icon-with-fallback.tsx +4 -4
  13. package/src/app-icon.tsx +4 -4
  14. package/src/appIcons.json +1227 -1227
  15. package/src/avatar.tsx +44 -5
  16. package/src/box.tsx +10 -17
  17. package/src/button/make-button-colors.ts +13 -13
  18. package/src/checkbox.tsx +3 -3
  19. package/src/collapsible-section.tsx +1 -1
  20. package/src/context-menu/index.tsx +4 -0
  21. package/src/date-picker/date-range-picker.tsx +1 -1
  22. package/src/date-picker/relative-date-picker.tsx +3 -0
  23. package/src/date-picker/single-date-picker.tsx +10 -9
  24. package/src/design-system/alpha.ts +9 -0
  25. package/src/design-system/colors-css.test.ts +1 -9
  26. package/src/design-system/colors-css.ts +1 -1
  27. package/src/design-system/colors.ts +351 -313
  28. package/src/design-system/layout.ts +1 -1
  29. package/src/design-system/theme.ts +4 -1
  30. package/src/design-system/vars.test.ts +4 -0
  31. package/src/design-system.test.ts +1 -0
  32. package/src/design-system.ts +1 -1
  33. package/src/dropdown-menu/index.tsx +4 -0
  34. package/src/emoji-picker/primitives/emoji.tsx +12 -0
  35. package/src/emoji-picker/primitives/grid.tsx +100 -104
  36. package/src/emoji.tsx +1 -0
  37. package/src/file-item.tsx +308 -265
  38. package/src/icons/ast/AddDatabase.ts +1 -1
  39. package/src/icons/ast/AddIntegration.ts +1 -1
  40. package/src/icons/ast/ArrowsRightLeft.ts +1 -1
  41. package/src/icons/ast/ChatBubble.ts +1 -1
  42. package/src/icons/ast/ChatFloat.ts +1 -1
  43. package/src/icons/ast/ChatSidebar.ts +1 -1
  44. package/src/icons/ast/Clean.ts +1 -1
  45. package/src/icons/ast/Create.ts +1 -1
  46. package/src/icons/ast/ItemsTimeline.ts +1 -1
  47. package/src/icons/ast/Key.ts +1 -1
  48. package/src/icons/ast/NetworkAdd.ts +1 -1
  49. package/src/icons/ast/Print.ts +1 -1
  50. package/src/icons/ast/Success.ts +1 -1
  51. package/src/icons/ast/SuggestIntegration.ts +1 -1
  52. package/src/icons/ast/WarningTriangle.ts +1 -1
  53. package/src/icons/ast/Windows.ts +1 -1
  54. package/src/icons/svg/add-database.svg +1 -1
  55. package/src/icons/svg/add-integration.svg +1 -1
  56. package/src/icons/svg/arrows-right-left.svg +1 -1
  57. package/src/icons/svg/chat-bubble.svg +1 -1
  58. package/src/icons/svg/chat-float.svg +1 -1
  59. package/src/icons/svg/chat-sidebar.svg +3 -3
  60. package/src/icons/svg/clean.svg +1 -1
  61. package/src/icons/svg/create.svg +1 -1
  62. package/src/icons/svg/items-timeline.svg +1 -1
  63. package/src/icons/svg/key.svg +1 -1
  64. package/src/icons/svg/network-add.svg +1 -1
  65. package/src/icons/svg/print.svg +1 -1
  66. package/src/icons/svg/success.svg +1 -1
  67. package/src/icons/svg/suggest-integration.svg +1 -1
  68. package/src/icons/svg/warning-triangle.svg +1 -1
  69. package/src/icons/svg/windows.svg +1 -1
  70. package/src/images-gallery/images-gallery.tsx +24 -0
  71. package/src/lists/actions-menu-row-surface.tsx +2 -1
  72. package/src/logo.tsx +14 -13
  73. package/src/modal-menu/index.tsx +1 -0
  74. package/src/modal-menu/modal-menu-checkbox-item.tsx +50 -0
  75. package/src/online-users.tsx +45 -46
  76. package/src/palettes/slate-arch.colors-snapshot.test.ts +7 -7
  77. package/src/palettes/slate-user.colors-snapshot.test.ts +11 -11
  78. package/src/palettes/warm-arch.colors-snapshot.test.ts +7 -7
  79. package/src/palettes/warm-user.colors-snapshot.test.ts +7 -7
  80. package/src/popover/index.tsx +91 -203
  81. package/src/popover/popover-old.tsx +113 -0
  82. package/src/popover/popup-modifiers-context.ts +1 -1
  83. package/src/scale-generator.ts +2 -2
  84. package/src/select/components/clear-indicator.tsx +1 -1
  85. package/src/select/components/drop-down-indicator.tsx +2 -2
  86. package/src/select/components/group-heading.tsx +2 -2
  87. package/src/select/components/menu-list-virtualized.tsx +1 -1
  88. package/src/select/components/option.tsx +1 -1
  89. package/src/select/index.tsx +34 -37
  90. package/src/select/select-in-popover.tsx +34 -202
  91. package/src/select/select.tsx +5 -4
  92. package/src/select/styles.ts +3 -0
  93. package/src/thematic-state.ts +1 -1
  94. package/src/theme-provider.tsx +14 -2
  95. package/src/theme-styles.ts +14 -7
  96. package/src/toggle-button/toggle-button.tsx +48 -35
  97. package/src/tree-utils.test.ts +166 -0
  98. package/src/tree-utils.ts +107 -0
  99. package/src/file-item/use-register-in-image-gallery.tsx +0 -70
  100. package/src/file-item-2.tsx +0 -357
package/src/avatar.tsx CHANGED
@@ -1,7 +1,7 @@
1
- import {css} from "@linaria/core";
1
+ import {css, cx} from "@linaria/core";
2
2
  import memoize from "lodash/memoize";
3
3
  import {CSSProperties, FC, memo, useCallback, useMemo, useState} from "react";
4
- import {getDarkenColor, getObjectColorMemoized, textStyles, themeVars} from "./design-system";
4
+ import {getDarkenColor, getObjectColorMemoized, space, textStyles, themeVars} from "./design-system";
5
5
  import {FibermojiPlaceholder} from "./fibermoji-placeholder";
6
6
  import {getShiftStyle} from "./icons/get-shift-style";
7
7
  import {useFeatures} from "./features";
@@ -89,7 +89,7 @@ type AvatarImageProps = {
89
89
  placeholder?: React.ReactNode;
90
90
  };
91
91
 
92
- export const AvatarImage: FC<AvatarImageProps> = memo(function AvatarImage({
92
+ const AvatarImage: FC<AvatarImageProps> = memo(function AvatarImage({
93
93
  size,
94
94
  containerSize,
95
95
  title,
@@ -188,7 +188,7 @@ type AvatarPlaceholderProps = {
188
188
  backgroundColor?: string;
189
189
  };
190
190
 
191
- export const AvatarPlaceholder: FC<AvatarPlaceholderProps> = memo(function AvatarPlaceholder(props) {
191
+ const AvatarPlaceholder: FC<AvatarPlaceholderProps> = memo(function AvatarPlaceholder(props) {
192
192
  const features = useFeatures<{enableFibermojiAvatars: boolean}>();
193
193
  if (features.enableFibermojiAvatars) {
194
194
  return <FibermojiPlaceholder {...props} />;
@@ -230,7 +230,7 @@ type NullUserAvatarProps = {
230
230
  containerSize: number;
231
231
  };
232
232
 
233
- export const NullUserAvatar: FC<NullUserAvatarProps> = memo(function NullUserAvatar({size, containerSize}) {
233
+ const NullUserAvatar: FC<NullUserAvatarProps> = memo(function NullUserAvatar({size, containerSize}) {
234
234
  const dashSize = (Math.PI * size) / magicCoefficient / 12;
235
235
  return (
236
236
  <div style={getNullUserAvatarContainerStyle({containerSize})}>
@@ -248,3 +248,42 @@ export const NullUserAvatar: FC<NullUserAvatarProps> = memo(function NullUserAva
248
248
  </div>
249
249
  );
250
250
  });
251
+
252
+ const avatarGroupCss = css`
253
+ display: flex;
254
+ `;
255
+
256
+ function AvatarGroup({className, ...props}: React.ComponentProps<"div">) {
257
+ return <div className={cx(avatarGroupCss, className)} {...props} />;
258
+ }
259
+
260
+ const avatarCss = css`
261
+ margin-left: -${space.s4}px;
262
+ &:first-of-type {
263
+ margin-left: 0;
264
+ }
265
+ z-index: 1;
266
+ `;
267
+
268
+ function Avatar({className, ...props}: React.ComponentProps<"div">) {
269
+ return <div className={cx(avatarCss, className)} {...props} />;
270
+ }
271
+
272
+ const avatarGroupCountCss = css`
273
+ display: flex;
274
+ align-items: center;
275
+ justify-content: center;
276
+ width: var(--fibery-avatar-group-count-size);
277
+ height: var(--fibery-avatar-group-count-size);
278
+ color: ${themeVars.accentTextColor};
279
+ font-size: calc(var(--fibery-avatar-group-count-size) * 0.5);
280
+ background-color: ${themeVars.badgeBgColor};
281
+ border-radius: 50%;
282
+ `;
283
+
284
+ function AvatarGroupCount({className, size, ...props}: {size: number} & React.ComponentProps<"div">) {
285
+ const style = {"--fibery-avatar-group-count-size": size + "px"} as CSSProperties;
286
+ return <div data-slot="avatar-group-count" style={style} className={cx(avatarGroupCountCss, className)} {...props} />;
287
+ }
288
+
289
+ export {AvatarGroup, Avatar, AvatarImage, AvatarPlaceholder, AvatarGroupCount, NullUserAvatar};
package/src/box.tsx CHANGED
@@ -2,7 +2,7 @@ import {css} from "@linaria/core";
2
2
  import {styled} from "@linaria/react";
3
3
  import cx from "classnames";
4
4
  import {CSSProperties, forwardRef, HTMLProps, ReactNode, Ref, useCallback, useMemo, useState} from "react";
5
- import {border, getLinearGradient, getOpacities, space, textStyles, themeVars, transition} from "./design-system";
5
+ import {alpha, border, getLinearGradient, space, textStyles, themeVars, transition} from "./design-system";
6
6
  import {useClickOutside} from "./popover/use-click-outside";
7
7
 
8
8
  export const getBg = (backgroundColors: string[]) => {
@@ -266,22 +266,15 @@ export function getBoxColorCoding({backgroundColors}: {backgroundColors: string[
266
266
  const colorCodingStyle = colorCodingColor
267
267
  ? ({
268
268
  [colorCodingBackgroundCustomProperty]: colorCodingColor,
269
- [colorCodingShadowEntityBoxDefaultCustomProperty]: `0px 2px 4px 0px ${
270
- getOpacities(colorCodingColor).opacity10
271
- }`,
272
- [colorCodingShadowStrokeEntityBoxDefaultCustomProperty]: `0 0 0 1px ${
273
- getOpacities(colorCodingColor).opacity30
274
- }`,
275
- [colorCodingBackgroundHoverShadowCustomProperty]: `0px 4px 8px 0px ${getOpacities(colorCodingColor).opacity10}`,
276
- [colorCodingFocusShadowStrokeEntityBoxDefaultCustomProperty]: `0 0 0 2px ${
277
- getOpacities(colorCodingColor).opacity40
278
- }`,
279
- [colorCodingHoverFocusShadowStrokeEntityBoxDefaultCustomProperty]: `0 0 0 2px ${
280
- getOpacities(colorCodingColor).opacity60
281
- }`,
282
- [colorCodingShadowStrokeEntityBoxSelectedCustomProperty]: `0 0 0 1px ${
283
- getOpacities(colorCodingColor).opacity60
284
- }, 0 0 0 3px ${getOpacities(colorCodingColor).opacity40}`,
269
+ [colorCodingShadowEntityBoxDefaultCustomProperty]: `0px 2px 4px 0px ${alpha(colorCodingColor, 0.1)}`,
270
+ [colorCodingShadowStrokeEntityBoxDefaultCustomProperty]: `0 0 0 1px ${alpha(colorCodingColor, 0.3)}`,
271
+ [colorCodingBackgroundHoverShadowCustomProperty]: `0px 4px 8px 0px ${alpha(colorCodingColor, 0.1)}`,
272
+ [colorCodingFocusShadowStrokeEntityBoxDefaultCustomProperty]: `0 0 0 2px ${alpha(colorCodingColor, 0.4)}`,
273
+ [colorCodingHoverFocusShadowStrokeEntityBoxDefaultCustomProperty]: `0 0 0 2px ${alpha(colorCodingColor, 0.6)}`,
274
+ [colorCodingShadowStrokeEntityBoxSelectedCustomProperty]: `0 0 0 1px ${alpha(
275
+ colorCodingColor,
276
+ 0.6
277
+ )}, 0 0 0 3px ${alpha(colorCodingColor, 0.4)}`,
285
278
  } as CSSProperties)
286
279
  : {};
287
280
  return {
@@ -3,7 +3,7 @@
3
3
  // so it's easier to find buttons with custom colors
4
4
 
5
5
  import {CSSProperties} from "@linaria/core";
6
- import {getDarkenColor, getOpacities, ThemeColors, themeVars} from "../design-system";
6
+ import {alpha, getDarkenColor, ThemeColors, themeVars} from "../design-system";
7
7
  import {ButtonVariant} from "./base-button";
8
8
 
9
9
  export const makeButtonColors = (color: string, variant: ButtonVariant, theme: ThemeColors): CSSProperties => {
@@ -14,24 +14,24 @@ export const makeButtonColors = (color: string, variant: ButtonVariant, theme: T
14
14
  "--fibery-button-hover-color": getDarkenColor(color),
15
15
  "--fibery-button-text-color": themeVars.buttonPrimaryTextColor,
16
16
  "--fibery-button-text-active-color": themeVars.buttonPrimaryTextColor,
17
- "--fibery-button-focus-color": getOpacities(color).opacity30,
17
+ "--fibery-button-focus-color": alpha(color, 0.3),
18
18
  };
19
19
  case "ghost":
20
20
  return {
21
21
  "--fibery-button-color": "transparent",
22
- "--fibery-button-hover-color": getOpacities(color).opacity15,
22
+ "--fibery-button-hover-color": alpha(color, 0.15),
23
23
  "--fibery-button-text-color": color,
24
- "--fibery-button-text-active-color": getOpacities(color).opacity80,
25
- "--fibery-button-focus-color": getOpacities(color).opacity30,
24
+ "--fibery-button-text-active-color": alpha(color, 0.8),
25
+ "--fibery-button-focus-color": alpha(color, 0.3),
26
26
  };
27
27
  case "outline":
28
28
  return {
29
29
  "--fibery-button-color": "transparent",
30
- "--fibery-button-hover-color": getOpacities(color).opacity15,
30
+ "--fibery-button-hover-color": alpha(color, 0.15),
31
31
  "--fibery-button-text-color": color,
32
- "--fibery-button-text-active-color": getOpacities(color).opacity80,
33
- "--fibery-button-focus-color": getOpacities(color).opacity30,
34
- "--fibery-button-border-color": getOpacities(color).opacity30,
32
+ "--fibery-button-text-active-color": alpha(color, 0.8),
33
+ "--fibery-button-focus-color": alpha(color, 0.3),
34
+ "--fibery-button-border-color": alpha(color, 0.3),
35
35
  };
36
36
  default:
37
37
  case "soft": {
@@ -41,12 +41,12 @@ export const makeButtonColors = (color: string, variant: ButtonVariant, theme: T
41
41
  return {
42
42
  "--fibery-button-color": bgColor,
43
43
  "--fibery-button-hover-color": theme.select({
44
- light: getOpacities(color).opacity30,
45
- dark: getOpacities(color).opacity45,
44
+ light: alpha(color, 0.3),
45
+ dark: alpha(color, 0.45),
46
46
  }),
47
47
  "--fibery-button-text-color": textColor,
48
- "--fibery-button-text-active-color": getOpacities(textColor).opacity80,
49
- "--fibery-button-focus-color": getOpacities(color).opacity30,
48
+ "--fibery-button-text-active-color": alpha(textColor, 0.8),
49
+ "--fibery-button-focus-color": alpha(color, 0.3),
50
50
  };
51
51
  }
52
52
  }
package/src/checkbox.tsx CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  useEffect,
13
13
  useRef,
14
14
  } from "react";
15
- import {getDarkenColor, getOpacities, layout, space, textStyles, ThemeColors, themeVars} from "./design-system";
15
+ import {alpha, getDarkenColor, layout, space, textStyles, ThemeColors, themeVars} from "./design-system";
16
16
  import {smallHtmlStylesClass} from "./html-styles";
17
17
  import {mobileRootSelector} from "./mobile-styles";
18
18
 
@@ -154,8 +154,8 @@ const CheckboxComponent = memo(
154
154
  const indeterminate = checked === null;
155
155
  const defaultIndeterminate = defaultChecked === null;
156
156
  const cColor = color || theme.primaryBlue;
157
- const fColor = getOpacities(cColor).opacity25;
158
- const hColor = getOpacities(cColor).opacity10;
157
+ const fColor = alpha(cColor, 0.25);
158
+ const hColor = alpha(cColor, 0.1);
159
159
  const dColor = getDarkenColor(cColor);
160
160
  const bColor = themeVars.checkboxColor;
161
161
 
@@ -84,7 +84,7 @@ export const CollapsibleSection = ({
84
84
  const regularHeader = label && <div className={headerCss}>{label}</div>;
85
85
 
86
86
  return (
87
- <div className={className}>
87
+ <div className={className} data-testid="collapsible-section">
88
88
  {collapsible ? collapsibleHeader : regularHeader}
89
89
  <div style={{display: collapsible && isCollapsed ? "none" : "block"}}>{children}</div>
90
90
  </div>
@@ -111,6 +111,10 @@ export const Item = styled(ContextMenuPrimitive.Item)`
111
111
  ${rowItemStyles}
112
112
  `;
113
113
 
114
+ export const CheckboxItem = styled(ContextMenuPrimitive.CheckboxItem)`
115
+ ${rowItemStyles}
116
+ `;
117
+
114
118
  export const Separator = styled(ContextMenuPrimitive.Separator)`
115
119
  ${{
116
120
  backgroundColor: themeVars.actionMenuSeparatorColor,
@@ -37,7 +37,7 @@ export const DateRangePicker = forwardRef<
37
37
 
38
38
  const dateValue = [value[0] ? value[0].toDate() : null, value[1] ? value[1].toDate() : null] as [
39
39
  Date | null,
40
- Date | null
40
+ Date | null,
41
41
  ];
42
42
  const onDatesChange = useCallback(
43
43
  (value: [Date | null, Date | null]) => {
@@ -94,6 +94,7 @@ export const RelativeDatePicker = (props: RelativeDatePickerProps) => {
94
94
  >
95
95
  <div>
96
96
  <AntInputNumber
97
+ aria-label="Amount"
97
98
  autoFocus={true}
98
99
  value={valueWithDefault.amount}
99
100
  controls={false}
@@ -109,6 +110,7 @@ export const RelativeDatePicker = (props: RelativeDatePickerProps) => {
109
110
  `}
110
111
  >
111
112
  <SingleRowReactSelect
113
+ aria-label="Unit"
112
114
  value={unitOptions.find((option) => option.value === valueWithDefault.unit)}
113
115
  components={{
114
116
  DropdownIndicator: AlwaysVisibleDropdownIndicator,
@@ -127,6 +129,7 @@ export const RelativeDatePicker = (props: RelativeDatePickerProps) => {
127
129
  `}
128
130
  >
129
131
  <SingleRowReactSelect
132
+ aria-label="Direction"
130
133
  value={isBeforeNowOptions.find(
131
134
  (option) => option.value === (valueWithDefault.isBeforeNow ? "ago" : "from now")
132
135
  )}
@@ -69,9 +69,9 @@ interface SingleDatePickerWithForwardRefType extends React.FC<SingleDatePickerPr
69
69
  }
70
70
 
71
71
  interface ControlledSingleDatePickerWithForwardRefType extends React.FC<UncontrolledSingleDatePickerProps<boolean>> {
72
- <T extends boolean>(props: UncontrolledSingleDatePickerProps<T>): ReturnType<
73
- React.FC<UncontrolledSingleDatePickerProps<T>>
74
- >;
72
+ <T extends boolean>(
73
+ props: UncontrolledSingleDatePickerProps<T>
74
+ ): ReturnType<React.FC<UncontrolledSingleDatePickerProps<T>>>;
75
75
  }
76
76
 
77
77
  type DatePickerRef = {
@@ -221,12 +221,12 @@ export const SingleDatePicker: SingleDatePickerWithForwardRefType = forwardRef<
221
221
  const dateValueFormatted = isRelativeValue
222
222
  ? formatRelativeDate(value as RelativeDateValue)
223
223
  : value
224
- ? formatDateInputValue((value as Moment).toDate(), {
225
- showTime,
226
- dateFormat,
227
- dateTimeFormat,
228
- })
229
- : null;
224
+ ? formatDateInputValue((value as Moment).toDate(), {
225
+ showTime,
226
+ dateFormat,
227
+ dateTimeFormat,
228
+ })
229
+ : null;
230
230
 
231
231
  const fakeWrapperRef = useRef<HTMLDivElement>(null);
232
232
 
@@ -249,6 +249,7 @@ export const SingleDatePicker: SingleDatePickerWithForwardRefType = forwardRef<
249
249
  </Popover.Trigger>
250
250
  <Popover.Portal>
251
251
  <Popover.Content
252
+ data-testid="single-date-picker-content"
252
253
  title={title}
253
254
  offset={[0, space.s6]}
254
255
  placement="bottom-start"
@@ -3,6 +3,7 @@ import mapValues from "lodash/mapValues";
3
3
  import memoize from "lodash/memoize";
4
4
  export const transparent = "rgba(255, 255, 255, 0)";
5
5
 
6
+ // TODO grades may become semantic someday?
6
7
  export const opacity = {
7
8
  opacity100: 1,
8
9
  opacity95: 0.95,
@@ -39,3 +40,11 @@ export const getOpacities = memoize((color: string) =>
39
40
  return produceColor(color, (c) => setAlpha(c, opacityValue));
40
41
  })
41
42
  );
43
+
44
+ // inspired by https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/alpha-value
45
+ export const alpha = memoize(
46
+ (color: string, value: (typeof opacity)[keyof typeof opacity]) => {
47
+ return produceColor(color, (c) => setAlpha(c, value));
48
+ },
49
+ (a, b) => a + b
50
+ );
@@ -1,4 +1,4 @@
1
- import {getEnumTextColor, getLinearGradient} from "./colors-css";
1
+ import {getLinearGradient} from "./colors-css";
2
2
 
3
3
  describe("getLinearGradient", () => {
4
4
  test("single color", () => {
@@ -29,11 +29,3 @@ describe("getLinearGradient", () => {
29
29
  );
30
30
  });
31
31
  });
32
-
33
- describe("getEnumTextColor", () => {
34
- test("snapshot", () => {
35
- expect(getEnumTextColor("#4978D4")).toMatchInlineSnapshot(
36
- `"color-mix(in srgb, #4978D4 25%, var(--fibery-color-textColor) 75%)"`
37
- );
38
- });
39
- });
@@ -9,7 +9,7 @@ export function getLinearGradient(backgroundColors: Array<string>): string {
9
9
  }
10
10
 
11
11
  export function getEnumTextColor(color: string) {
12
- return `color-mix(in srgb, ${color} 25%, ${themeVars.textColor} 75%)`;
12
+ return `color-mix(in srgb, ${color} 40%, ${themeVars.textColor} 60%)`;
13
13
  }
14
14
 
15
15
  function themeVarWithAlpha(themeVar: string, alpha: number) {