@fibery/ui-kit 1.40.3 → 1.41.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 (174) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/eslint.config.mjs +16 -0
  3. package/package.json +11 -13
  4. package/src/a11y-color.test.ts +162 -0
  5. package/src/a11y-color.ts +13 -20
  6. package/src/actions-menu/actions-menu-item.tsx +9 -12
  7. package/src/actions-menu/context-actions-menu.tsx +8 -3
  8. package/src/ai/model.tsx +0 -1
  9. package/src/ai/temperature.tsx +0 -1
  10. package/src/animated-height-container.tsx +3 -3
  11. package/src/antd/ant-modal.tsx +10 -5
  12. package/src/antd/index.tsx +3 -0
  13. package/src/antd/input.tsx +0 -1
  14. package/src/antd/styles.ts +15 -15
  15. package/src/app-icon-with-fallback.tsx +6 -6
  16. package/src/app-icon-wrapper.tsx +2 -3
  17. package/src/app-icon.tsx +4 -4
  18. package/src/avatar.tsx +3 -3
  19. package/src/button/base-button.tsx +0 -1
  20. package/src/button/button.tsx +1 -0
  21. package/src/button/make-button-colors.ts +5 -13
  22. package/src/checkbox.tsx +2 -2
  23. package/src/collapsible-section.tsx +11 -1
  24. package/src/color-picker/ColorPickerOrLoader.js +2 -2
  25. package/src/color-utils.test.ts +307 -0
  26. package/src/color-utils.ts +215 -0
  27. package/src/command-menu/index.tsx +1 -0
  28. package/src/comment.tsx +3 -2
  29. package/src/context-menu/index.tsx +12 -7
  30. package/src/date-picker/contexts.ts +2 -2
  31. package/src/date-picker/date-range-picker.tsx +3 -4
  32. package/src/date-picker/single-date-picker.tsx +147 -119
  33. package/src/date-picker/types.ts +4 -3
  34. package/src/day-select/iso-week-day-select.tsx +2 -2
  35. package/src/day-select/week-day-select.tsx +2 -2
  36. package/src/delayed.tsx +0 -1
  37. package/src/design-system/alpha.test.ts +59 -0
  38. package/src/design-system/alpha.ts +41 -0
  39. package/src/design-system/animation.ts +10 -0
  40. package/src/design-system/colors-css.test.ts +39 -0
  41. package/src/design-system/colors-css.ts +25 -0
  42. package/src/design-system/colors-js.test.ts +232 -0
  43. package/src/design-system/colors-js.ts +107 -0
  44. package/src/design-system/colors.test.ts +74 -0
  45. package/src/design-system/colors.ts +759 -0
  46. package/src/design-system/date.ts +3 -0
  47. package/src/design-system/layout.ts +106 -0
  48. package/src/design-system/theme.test.ts +94 -0
  49. package/src/design-system/theme.ts +93 -0
  50. package/src/design-system/typography.ts +179 -0
  51. package/src/design-system/vars.test.ts +1679 -0
  52. package/src/design-system/vars.ts +52 -0
  53. package/src/design-system.test.ts +45 -22
  54. package/src/design-system.ts +25 -1339
  55. package/src/dropdown-menu/index.tsx +21 -16
  56. package/src/emoji-picker/app-icon-picker.tsx +5 -5
  57. package/src/emoji-picker/emoji-picker-content-with-color.tsx +4 -4
  58. package/src/emoji-picker/icon-emoji-picker.tsx +3 -3
  59. package/src/favorites-icon.tsx +1 -1
  60. package/src/fibermoji-placeholder.tsx +3 -3
  61. package/src/field-container.tsx +11 -2
  62. package/src/file-item/file-icon.tsx +169 -0
  63. package/src/file-item/file-menu-items.tsx +68 -0
  64. package/src/file-item/file-preview-actions.tsx +38 -0
  65. package/src/file-item/file-title.tsx +48 -0
  66. package/src/file-item/types.ts +27 -0
  67. package/src/file-item/use-register-in-image-gallery.tsx +70 -0
  68. package/src/file-item-2.tsx +32 -348
  69. package/src/file-item.tsx +6 -3
  70. package/src/hue-shift.test.ts +91 -0
  71. package/src/icons/ast/ChatBubble.ts +8 -0
  72. package/src/icons/ast/ChatFloat.ts +8 -0
  73. package/src/icons/ast/ChatSidebar.ts +8 -0
  74. package/src/icons/ast/FileCounter.ts +8 -0
  75. package/src/icons/ast/FileMultiple.ts +8 -0
  76. package/src/icons/ast/FileOther.ts +8 -0
  77. package/src/icons/ast/NoBorder.ts +8 -0
  78. package/src/icons/ast/NoFill.ts +8 -0
  79. package/src/icons/ast/ValueEdit.ts +8 -0
  80. package/src/icons/ast/index.tsx +9 -0
  81. package/src/icons/react/ChatBubble.tsx +13 -0
  82. package/src/icons/react/ChatFloat.tsx +13 -0
  83. package/src/icons/react/ChatSidebar.tsx +13 -0
  84. package/src/icons/react/FileCounter.tsx +13 -0
  85. package/src/icons/react/FileMultiple.tsx +13 -0
  86. package/src/icons/react/FileOther.tsx +13 -0
  87. package/src/icons/react/NoBorder.tsx +13 -0
  88. package/src/icons/react/NoFill.tsx +13 -0
  89. package/src/icons/react/ValueEdit.tsx +13 -0
  90. package/src/icons/react/index.tsx +9 -0
  91. package/src/icons/svg/chat-bubble.svg +4 -0
  92. package/src/icons/svg/chat-float.svg +4 -0
  93. package/src/icons/svg/chat-sidebar.svg +4 -0
  94. package/src/icons/svg/file-counter.svg +3 -0
  95. package/src/icons/svg/file-multiple.svg +3 -0
  96. package/src/icons/svg/file-other.svg +3 -0
  97. package/src/icons/svg/no-border.svg +17 -0
  98. package/src/icons/svg/no-fill.svg +4 -0
  99. package/src/icons/svg/value-edit.svg +3 -0
  100. package/src/images-gallery/images-gallery.tsx +8 -6
  101. package/src/images-gallery/slide-buttons.tsx +4 -11
  102. package/src/is-iOS.ts +0 -1
  103. package/src/is-in-popup.ts +2 -1
  104. package/src/lists/actions-menu-row-surface.tsx +7 -7
  105. package/src/loading-sausage.tsx +2 -2
  106. package/src/media-query-utils.ts +1 -2
  107. package/src/mobile-keyboard-aware-popup.tsx +6 -5
  108. package/src/modal-menu/modal-menu-content.tsx +2 -2
  109. package/src/number-input/decimal.js +9 -7
  110. package/src/number-input/{number-inline-input-with-autosize.tsx → number-input-inline-with-autosize.tsx} +20 -41
  111. package/src/number-input/number-input-inline.tsx +118 -0
  112. package/src/number-input/{index.test.js → number-input.test.tsx} +38 -43
  113. package/src/number-input/number-input.tsx +63 -121
  114. package/src/number-input/types.ts +19 -0
  115. package/src/number-input/utils.ts +61 -0
  116. package/src/online-users.tsx +2 -2
  117. package/src/palette-generator.test.ts +309 -0
  118. package/src/palette-generator.ts +160 -0
  119. package/src/palettes/_.ts +72 -0
  120. package/src/palettes/slate-arch.colors-snapshot.test.ts +1689 -0
  121. package/src/palettes/slate-arch.ts +188 -0
  122. package/src/palettes/slate-user.colors-snapshot.test.ts +1689 -0
  123. package/src/palettes/slate-user.ts +187 -0
  124. package/src/palettes/warm-arch.colors-snapshot.test.ts +1689 -0
  125. package/src/palettes/warm-arch.ts +222 -0
  126. package/src/palettes/warm-user.colors-snapshot.test.ts +1689 -0
  127. package/src/palettes/warm-user.ts +222 -0
  128. package/src/platform.ts +0 -3
  129. package/src/popover/get-element-ref.ts +28 -0
  130. package/src/popover/index.tsx +236 -339
  131. package/src/popover/{mobile-popup-context.tsx → mobile-popover-context.tsx} +7 -7
  132. package/src/popover/mobile-popover.tsx +169 -0
  133. package/src/popover/modifiers.tsx +2 -2
  134. package/src/popover/popup-stack-context.tsx +8 -9
  135. package/src/progress.tsx +2 -2
  136. package/src/reactions/reaction-button.tsx +12 -6
  137. package/src/root-theme-provider.test.tsx +411 -0
  138. package/src/scale-generator.ts +356 -0
  139. package/src/select/components/menu-list-virtualized.tsx +12 -25
  140. package/src/select/components/menu.tsx +12 -2
  141. package/src/select/index.tsx +6 -5
  142. package/src/select/select.tsx +38 -39
  143. package/src/select/styles.ts +0 -1
  144. package/src/select/util.ts +1 -1
  145. package/src/static-palettes.ts +356 -0
  146. package/src/thematic-color-picker.tsx +266 -0
  147. package/src/thematic-constants.tsx +27 -0
  148. package/src/thematic-controls.tsx +144 -0
  149. package/src/thematic-scales.tsx +122 -0
  150. package/src/thematic-state.ts +370 -0
  151. package/src/thematic.tsx +386 -0
  152. package/src/theme-provider.test.tsx +820 -0
  153. package/src/theme-provider.tsx +158 -92
  154. package/src/theme-settings.ts +67 -12
  155. package/src/theme-styles.ts +58 -6
  156. package/src/toast/toast-action.tsx +1 -1
  157. package/src/toast/toast.tsx +1 -2
  158. package/src/toggle-on-off.tsx +2 -2
  159. package/src/toggle.tsx +7 -8
  160. package/src/tooltip.tsx +14 -10
  161. package/src/type-badge.tsx +7 -14
  162. package/src/unit/styles.ts +2 -25
  163. package/src/unit/unit-with-tooltip.tsx +3 -2
  164. package/src/use-is-phone.tsx +7 -2
  165. package/src/use-long-press.tsx +2 -2
  166. package/src/use-on-screen-keyboard-data.tsx +2 -2
  167. package/src/with-data.tsx +4 -3
  168. package/src/workflow-progress-icon.tsx +2 -2
  169. package/.eslintignore +0 -3
  170. package/.eslintrc +0 -14
  171. package/src/__mocks__/createInlineTheme.js +0 -3
  172. package/src/create-inline-theme.ts +0 -66
  173. package/src/number-input/index.js +0 -191
  174. package/src/palette.ts +0 -237
@@ -1,20 +1,20 @@
1
- import _ from "lodash";
1
+ import noop from "lodash/noop";
2
2
  import {FC, ReactNode, useState, useMemo} from "react";
3
3
  import {createContext} from "@fibery/react/src/create-context";
4
4
 
5
- type MobilePopupContext = {
5
+ type MobilePopoverContext = {
6
6
  title?: string;
7
7
  headerSlot?: ReactNode;
8
8
  setTitle: (title: string) => void;
9
9
  setHeader: (header?: ReactNode) => void;
10
10
  };
11
11
 
12
- const [Provider, useMobilePopup] = createContext<MobilePopupContext>("MobilePopupContext", {
13
- setTitle: _.noop,
14
- setHeader: _.noop,
12
+ const [Provider, useMobilePopover] = createContext<MobilePopoverContext>("MobilePopoverContext", {
13
+ setTitle: noop,
14
+ setHeader: noop,
15
15
  });
16
16
 
17
- export const MobilePopupProvider: FC<{children?: ReactNode}> = ({children}) => {
17
+ export const MobilePopoverProvider: FC<{children?: ReactNode}> = ({children}) => {
18
18
  const [title, setTitle] = useState<string | undefined>();
19
19
  const [headerSlot, setHeader] = useState<ReactNode | undefined>();
20
20
 
@@ -26,4 +26,4 @@ export const MobilePopupProvider: FC<{children?: ReactNode}> = ({children}) => {
26
26
  return <Provider value={contextValue}>{children}</Provider>;
27
27
  };
28
28
 
29
- export {useMobilePopup};
29
+ export {useMobilePopover};
@@ -0,0 +1,169 @@
1
+ import {stopPropagation} from "@fibery/react/src/stop-propagation";
2
+ import {css} from "@linaria/core";
3
+ import cx from "classnames";
4
+ import {CSSProperties, ReactNode} from "react";
5
+ import {
6
+ safeAreaInsetBottomVar,
7
+ safeAreaInsetLeftVar,
8
+ safeAreaInsetRightVar,
9
+ safeAreaInsetTopVar,
10
+ } from "../mobile-styles";
11
+ import {space, textStyles, themeVars, transition} from "../design-system";
12
+ import {IconButton} from "../button/icon-button";
13
+ import CloseIcon from "../icons/react/Close";
14
+ import ArrowLeftIcon from "../icons/react/ArrowLeft";
15
+ import {ThemeProvider} from "../theme-provider";
16
+ import {useMobilePopover} from "./mobile-popover-context";
17
+
18
+ const mobileAnimationClassName = css`
19
+ transition: transform ${transition}, opacity ${transition};
20
+ transform: translateY(0);
21
+ opacity: 1;
22
+
23
+ @media (prefers-reduced-motion: no-preference) {
24
+ @starting-style {
25
+ transform: translateY(20%);
26
+ opacity: 0;
27
+ }
28
+ }
29
+ `;
30
+
31
+ const popupContentClassName = css`
32
+ display: grid;
33
+ background: ${themeVars.actionMenuBg};
34
+ grid-template-rows: 60px 1fr;
35
+ `;
36
+
37
+ export const mobileZIndex = 1002;
38
+
39
+ export function MobilePopover({
40
+ content,
41
+ mobilePopupStyle,
42
+ mobilePopupContentClassName,
43
+ title,
44
+ onClose,
45
+ height,
46
+ onNavigateBack,
47
+ }: {
48
+ content: ReactNode;
49
+ mobilePopupStyle?: CSSProperties;
50
+ mobilePopupContentClassName?: string;
51
+ title: string;
52
+ height?: string;
53
+ onClose?: () => void;
54
+ onNavigateBack?: () => void;
55
+ }) {
56
+ const {title: contextTitle, headerSlot} = useMobilePopover();
57
+
58
+ const headerContent = headerSlot ?? (
59
+ <>
60
+ {onNavigateBack && (
61
+ <IconButton onClick={onNavigateBack} size="xLarge">
62
+ <ArrowLeftIcon />
63
+ </IconButton>
64
+ )}
65
+ <div
66
+ className={css`
67
+ ${textStyles.heading3}
68
+ flex: 1;
69
+ min-width: 0;
70
+ overflow: hidden;
71
+ text-overflow: ellipsis;
72
+ white-space: nowrap;
73
+ `}
74
+ >
75
+ {contextTitle ?? title}
76
+ </div>
77
+ {onClose && (
78
+ <IconButton onClick={onClose} size="xLarge">
79
+ <CloseIcon />
80
+ </IconButton>
81
+ )}
82
+ </>
83
+ );
84
+
85
+ const popupContent = (
86
+ <>
87
+ <div
88
+ className={cx(
89
+ css`
90
+ display: flex;
91
+ align-items: center;
92
+ gap: ${space.s8}px;
93
+ padding: ${space.s8}px ${space.s8}px ${space.s8}px ${space.s20}px;
94
+ min-width: 0;
95
+ `,
96
+ onNavigateBack &&
97
+ css`
98
+ padding-left: ${space.s4}px;
99
+ `
100
+ )}
101
+ >
102
+ {headerContent}
103
+ </div>
104
+ <div
105
+ className={cx(
106
+ css`
107
+ border-top: ${themeVars.separators.opacity5};
108
+ min-width: 0;
109
+ `,
110
+ mobilePopupContentClassName
111
+ )}
112
+ >
113
+ {content}
114
+ </div>
115
+ </>
116
+ );
117
+
118
+ const res = (
119
+ <div
120
+ className={cx(
121
+ css`
122
+ position: absolute;
123
+ left: var(${safeAreaInsetLeftVar});
124
+ right: var(${safeAreaInsetRightVar});
125
+ top: var(${safeAreaInsetTopVar});
126
+ bottom: var(${safeAreaInsetBottomVar});
127
+ z-index: ${mobileZIndex};
128
+ `,
129
+ !height && mobileAnimationClassName,
130
+ !height && popupContentClassName,
131
+ height &&
132
+ css`
133
+ display: grid;
134
+ `
135
+ )}
136
+ style={{
137
+ ...mobilePopupStyle,
138
+ ...(height ? {gridTemplateRows: `1fr ${height}`} : {}),
139
+ }}
140
+ onClick={stopPropagation}
141
+ >
142
+ {height ? (
143
+ <>
144
+ <div
145
+ onClick={onClose}
146
+ className={css`
147
+ background-color: ${themeVars.modalBg};
148
+ `}
149
+ />
150
+ <div
151
+ className={cx(
152
+ css`
153
+ display: grid;
154
+ grid-template-rows: 60px 1fr;
155
+ `,
156
+ mobileAnimationClassName,
157
+ popupContentClassName
158
+ )}
159
+ >
160
+ {popupContent}
161
+ </div>
162
+ </>
163
+ ) : (
164
+ popupContent
165
+ )}
166
+ </div>
167
+ );
168
+ return <ThemeProvider portal>{res}</ThemeProvider>;
169
+ }
@@ -3,7 +3,7 @@ import {Modifier, ModifierArguments, Placement, Boundary, RootBoundary, Padding,
3
3
  import maxSize from "popper-max-size-modifier";
4
4
  import {getResizeListener} from "@fibery/helpers/utils/resize-listener";
5
5
  import {isElementReference} from "./reference";
6
- import _ from "lodash";
6
+ import noop from "lodash/noop";
7
7
 
8
8
  type MaxSizeOptions = {
9
9
  placement: Placement;
@@ -65,6 +65,6 @@ export const observeWidth: Modifier<"observeWidth", Record<string, never>> = {
65
65
  name: "observeWidth",
66
66
  enabled: true,
67
67
  phase: "main",
68
- fn: _.noop,
68
+ fn: noop,
69
69
  effect: observeWidthEffect,
70
70
  };
@@ -25,17 +25,16 @@ const [Provider, usePopupStackContext] = createContext<{
25
25
 
26
26
  export function PopupStackContextProvider({children}: {children: ReactNode}) {
27
27
  useEffect(() => {
28
- const escapeHandler = (event: KeyboardEvent) => {
29
- const reverse = [...callbacksMap].reverse();
30
- reverse.forEach(([_id, cb]) => {
31
- if (cb) {
32
- cb(event);
33
- }
34
- });
28
+ const onKeyDown = (event: KeyboardEvent) => {
29
+ if (event.key === "Escape") {
30
+ const callbacks = [...callbacksMap.values()].filter(Boolean);
31
+ const topmost = callbacks[callbacks.length - 1];
32
+ topmost?.(event);
33
+ }
35
34
  };
36
- document.addEventListener("keydown", escapeHandler);
35
+ document.addEventListener("keydown", onKeyDown);
37
36
  return () => {
38
- document.removeEventListener("keydown", escapeHandler);
37
+ document.removeEventListener("keydown", onKeyDown);
39
38
  };
40
39
  }, []);
41
40
  return <Provider value={value}>{children}</Provider>;
package/src/progress.tsx CHANGED
@@ -1,13 +1,13 @@
1
1
  import {Line, Circle, ProgressProps} from "rc-progress";
2
2
  import {FC} from "react";
3
3
 
4
- interface CircleProgressProps extends ProgressProps {}
4
+ type CircleProgressProps = ProgressProps;
5
5
 
6
6
  export const CircleProgress: FC<CircleProgressProps> = (props) => {
7
7
  return <Circle trailWidth={12} strokeWidth={12} {...props} />;
8
8
  };
9
9
 
10
- interface ProgressBarProps extends ProgressProps {}
10
+ type ProgressBarProps = ProgressProps;
11
11
 
12
12
  export const ProgressBar: FC<ProgressBarProps> = (props) => {
13
13
  return <Line className={props.className} trailWidth={8} strokeWidth={8} {...props} />;
@@ -1,7 +1,8 @@
1
1
  import {css} from "@linaria/core";
2
- import {Fragment, ReactEventHandler, ReactNode, useCallback, useState, useRef} from "react";
2
+ import {Fragment, ReactEventHandler, ReactNode, useCallback, useRef, useState} from "react";
3
3
  import {createPortal} from "react-dom";
4
4
  import {fontSize, fontWeight, space, themeVars} from "../design-system";
5
+ import {ThemeProvider} from "../theme-provider";
5
6
  import {Emoji} from "../emoji-picker/emoji";
6
7
  import {ToggleButton} from "../toggle-button/toggle-button";
7
8
  import {Tooltip} from "../tooltip";
@@ -10,7 +11,7 @@ import {mobileRootSelector, safeAreaInsetBottomVar} from "../mobile-styles";
10
11
  import {useLongPress} from "../use-long-press";
11
12
  import {getWordDivider} from "./get-word-divider";
12
13
  import {EmojiTooltipDescription, EmojiTooltipTitle} from "./tootltip";
13
- import {TabNavLink, TabNavRoot, TabNavList, tabButton} from "../tab-nav/tab-nav";
14
+ import {tabButton, TabNavLink, TabNavList, TabNavRoot} from "../tab-nav/tab-nav";
14
15
  import {AvatarImage} from "../avatar";
15
16
  import {getPopupContainerElement} from "../utils-dom";
16
17
 
@@ -46,7 +47,12 @@ const overlayClassName = css`
46
47
  `;
47
48
 
48
49
  function TouchOverlay({onClick}: {onClick: () => void}) {
49
- return createPortal(<div className={overlayClassName} onClick={onClick} />, getPopupContainerElement());
50
+ return createPortal(
51
+ <ThemeProvider portal>
52
+ <div className={overlayClassName} onClick={onClick} />
53
+ </ThemeProvider>,
54
+ getPopupContainerElement()
55
+ );
50
56
  }
51
57
 
52
58
  function MobileOverlay({content, onClose}: {content: ReactNode; onClose: () => void}) {
@@ -57,7 +63,7 @@ function MobileOverlay({content, onClose}: {content: ReactNode; onClose: () => v
57
63
  },
58
64
  [onClose]
59
65
  );
60
- return createPortal(
66
+ const res = (
61
67
  <div className={overlayClassName}>
62
68
  <div
63
69
  onPointerDown={handleClose}
@@ -79,9 +85,9 @@ function MobileOverlay({content, onClose}: {content: ReactNode; onClose: () => v
79
85
  >
80
86
  {content}
81
87
  </div>
82
- </div>,
83
- getPopupContainerElement()
88
+ </div>
84
89
  );
90
+ return createPortal(<ThemeProvider portal>{res}</ThemeProvider>, getPopupContainerElement());
85
91
  }
86
92
 
87
93
  const navLinkClassName = css`