@fibery/ui-kit 1.37.0 → 1.38.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 (194) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/config/jest/testFrameworkSetup.js +1 -1
  3. package/package.json +20 -16
  4. package/src/abbreviate-name.ts +42 -0
  5. package/src/actions-menu/actions-menu-item.tsx +32 -11
  6. package/src/actions-menu/actions-menu-props.tsx +5 -0
  7. package/src/actions-menu/actions-menu-sub-command-menu.tsx +7 -4
  8. package/src/actions-menu/actions-menu-sub-menu.tsx +9 -3
  9. package/src/actions-menu/actions-menu.tsx +28 -9
  10. package/src/actions-menu/context-actions-menu.tsx +22 -0
  11. package/src/actions-panel.tsx +12 -2
  12. package/src/animated-height-container.tsx +24 -5
  13. package/src/antd/ant-upload.tsx +1 -1
  14. package/src/antd/input.tsx +4 -0
  15. package/src/avatar.tsx +1 -27
  16. package/src/axis-header.tsx +136 -76
  17. package/src/box.tsx +1 -1
  18. package/src/breadcrumb.tsx +78 -0
  19. package/src/button/actions-button-compact.tsx +4 -1
  20. package/src/button/base-button.tsx +7 -3
  21. package/src/button/button-group.tsx +1 -1
  22. package/src/button/button.tsx +33 -1
  23. package/src/button/icon-button.tsx +10 -1
  24. package/src/button/select-button.tsx +4 -0
  25. package/src/card-container.tsx +10 -6
  26. package/src/checkbox.tsx +17 -0
  27. package/src/collapsible-section.tsx +3 -1
  28. package/src/color-picker/swatch.tsx +1 -0
  29. package/src/command-menu/index.tsx +3 -3
  30. package/src/context-menu/index.tsx +10 -1
  31. package/src/date-picker/autocomplete.tsx +11 -5
  32. package/src/date-picker/date-range-input.tsx +5 -1
  33. package/src/date-picker/date-range-picker-popup-content.tsx +31 -13
  34. package/src/date-picker/date-range-picker.tsx +6 -3
  35. package/src/date-picker/relative-date-picker.tsx +6 -2
  36. package/src/date-picker/single-date-input.tsx +5 -1
  37. package/src/date-picker/single-date-picker.tsx +8 -5
  38. package/src/date-picker/styles.ts +52 -26
  39. package/src/date-picker/types.ts +3 -1
  40. package/src/day-select/day-select.tsx +21 -75
  41. package/src/day-select/iso-week-day-select.tsx +1 -1
  42. package/src/day-select/mount-day-select.tsx +2 -2
  43. package/src/day-select/week-day-select.tsx +1 -5
  44. package/src/design-system.ts +45 -12
  45. package/src/dropdown-menu/index.tsx +19 -2
  46. package/src/emoji-picker/app-icon-picker.tsx +6 -4
  47. package/src/emoji-picker/emoji-picker-preview-footer.tsx +5 -1
  48. package/src/emoji-picker/emoji-picker.tsx +3 -0
  49. package/src/emoji-picker/emoji.tsx +5 -3
  50. package/src/emoji-picker/icon-emoji-picker.tsx +10 -1
  51. package/src/emoji-picker/primitives/emoji.tsx +49 -51
  52. package/src/emoji-picker/primitives/footer.tsx +5 -0
  53. package/src/emoji-picker/primitives/search.tsx +8 -0
  54. package/src/emoji-picker/primitives/skin-tone.tsx +12 -1
  55. package/src/emoji-picker/use-responsive-emoji-size.ts +11 -0
  56. package/src/emoji-picker/utils/emoji-set.ts +2 -1
  57. package/src/empty-state/empty-state.tsx +6 -0
  58. package/src/fibermoji-placeholder.tsx +1 -27
  59. package/src/field-icon.tsx +4 -1
  60. package/src/file-item-2.tsx +408 -0
  61. package/src/file-item.tsx +215 -47
  62. package/src/header-layout.tsx +11 -0
  63. package/src/html-styles.ts +21 -4
  64. package/src/icons/ast/ActivityFilled.ts +8 -0
  65. package/src/icons/ast/AiAssistantFilled.ts +8 -0
  66. package/src/icons/ast/Back.ts +1 -1
  67. package/src/icons/ast/CollapseAllHorizontal.ts +8 -0
  68. package/src/icons/ast/DateRange.ts +1 -1
  69. package/src/icons/ast/EntityCreateFilled.ts +8 -0
  70. package/src/icons/ast/ExpandAllHorizontal.ts +8 -0
  71. package/src/icons/ast/ExtensionFiles.ts +1 -1
  72. package/src/icons/ast/FileUpload.ts +1 -1
  73. package/src/icons/ast/GlobeUnpublish.ts +8 -0
  74. package/src/icons/ast/HomeFilled.ts +8 -0
  75. package/src/icons/ast/KeyboardHideDown.ts +8 -0
  76. package/src/icons/ast/LayoutMultiple.ts +8 -0
  77. package/src/icons/ast/RicheditorHistoryRedo.ts +1 -1
  78. package/src/icons/ast/RicheditorHistoryUndo.ts +1 -1
  79. package/src/icons/ast/SearchFilled.ts +8 -0
  80. package/src/icons/ast/SettingsFilled.ts +8 -0
  81. package/src/icons/ast/SlideMenuFilled.ts +8 -0
  82. package/src/icons/ast/SwitchToMention.ts +8 -0
  83. package/src/icons/ast/SwitchToText.ts +8 -0
  84. package/src/icons/ast/SwitchToWidget.ts +8 -0
  85. package/src/icons/ast/TypeDate.ts +1 -1
  86. package/src/icons/ast/ViewGallery.ts +8 -0
  87. package/src/icons/ast/index.tsx +16 -0
  88. package/src/icons/react/ActivityFilled.tsx +13 -0
  89. package/src/icons/react/AiAssistantFilled.tsx +13 -0
  90. package/src/icons/react/CollapseAllHorizontal.tsx +13 -0
  91. package/src/icons/react/EntityCreateFilled.tsx +13 -0
  92. package/src/icons/react/ExpandAllHorizontal.tsx +13 -0
  93. package/src/icons/react/GlobeUnpublish.tsx +13 -0
  94. package/src/icons/react/HomeFilled.tsx +13 -0
  95. package/src/icons/react/KeyboardHideDown.tsx +13 -0
  96. package/src/icons/react/LayoutMultiple.tsx +13 -0
  97. package/src/icons/react/SearchFilled.tsx +13 -0
  98. package/src/icons/react/SettingsFilled.tsx +13 -0
  99. package/src/icons/react/SlideMenuFilled.tsx +13 -0
  100. package/src/icons/react/SwitchToMention.tsx +13 -0
  101. package/src/icons/react/SwitchToText.tsx +13 -0
  102. package/src/icons/react/SwitchToWidget.tsx +13 -0
  103. package/src/icons/react/ViewGallery.tsx +13 -0
  104. package/src/icons/react/index.tsx +16 -0
  105. package/src/icons/svg/activity-filled.svg +4 -0
  106. package/src/icons/svg/ai-assistant-filled.svg +3 -0
  107. package/src/icons/svg/back.svg +3 -1
  108. package/src/icons/svg/collapse-all-horizontal.svg +3 -0
  109. package/src/icons/svg/date-range.svg +3 -3
  110. package/src/icons/svg/entity-create-filled.svg +4 -0
  111. package/src/icons/svg/expand-all-horizontal.svg +3 -0
  112. package/src/icons/svg/extension/files.svg +3 -1
  113. package/src/icons/svg/file-upload.svg +3 -6
  114. package/src/icons/svg/globe-unpublish.svg +4 -0
  115. package/src/icons/svg/home-filled.svg +3 -0
  116. package/src/icons/svg/keyboard-hide-down.svg +1 -0
  117. package/src/icons/svg/layout-multiple.svg +3 -0
  118. package/src/icons/svg/richeditor/history/redo.svg +3 -2
  119. package/src/icons/svg/richeditor/history/undo.svg +3 -2
  120. package/src/icons/svg/search-filled.svg +3 -0
  121. package/src/icons/svg/settings-filled.svg +3 -0
  122. package/src/icons/svg/slide-menu-filled.svg +1 -0
  123. package/src/icons/svg/switch-to-mention.svg +3 -0
  124. package/src/icons/svg/switch-to-text.svg +4 -0
  125. package/src/icons/svg/switch-to-widget.svg +4 -0
  126. package/src/icons/svg/type/date.svg +3 -2
  127. package/src/icons/svg/view-gallery.svg +4 -0
  128. package/src/images-gallery/images-gallery-fall-through-provider.tsx +11 -0
  129. package/src/images-gallery/images-gallery.tsx +257 -0
  130. package/src/images-gallery/zoom.tsx +123 -0
  131. package/src/images-gallery-2/images-gallery-2.tsx +442 -0
  132. package/src/images-gallery-2/slide-buttons.tsx +230 -0
  133. package/src/images-gallery-2/zoom.tsx +35 -0
  134. package/src/is-in-popup.ts +1 -1
  135. package/src/kbd.tsx +46 -0
  136. package/src/layout-styles.ts +21 -1
  137. package/src/lists/actions-menu-row-surface.tsx +3 -1
  138. package/src/lists/list-row-surface.tsx +7 -1
  139. package/src/mobile-keyboard-aware-popup.tsx +87 -0
  140. package/src/mobile-styles.ts +8 -0
  141. package/src/modal-menu/contexts/modal-menu-context.tsx +22 -0
  142. package/src/modal-menu/contexts/modal-submenu-context.tsx +16 -0
  143. package/src/modal-menu/index.tsx +14 -0
  144. package/src/modal-menu/modal-menu-content.tsx +68 -0
  145. package/src/modal-menu/modal-menu-group.tsx +10 -0
  146. package/src/modal-menu/modal-menu-item.tsx +45 -0
  147. package/src/modal-menu/modal-menu-label.tsx +24 -0
  148. package/src/modal-menu/modal-menu-root.tsx +57 -0
  149. package/src/modal-menu/modal-menu-separator.tsx +14 -0
  150. package/src/modal-menu/modal-menu-trigger.tsx +54 -0
  151. package/src/modal-menu/modal-submenu-content.tsx +49 -0
  152. package/src/modal-menu/modal-submenu-trigger.tsx +34 -0
  153. package/src/modal-menu/modal-submenu.tsx +17 -0
  154. package/src/notification-dot.tsx +16 -7
  155. package/src/online-users.tsx +3 -3
  156. package/src/palette.ts +1 -1
  157. package/src/platform-symbols.ts +9 -0
  158. package/src/platform.ts +2 -0
  159. package/src/popover/index.tsx +710 -0
  160. package/src/popover/mobile-popup-context.tsx +29 -0
  161. package/src/{popup → popover}/modifiers.tsx +25 -25
  162. package/src/{popup → popover}/popup-modifiers-context.ts +3 -3
  163. package/src/reactions/reaction-button.tsx +342 -135
  164. package/src/reactions/reaction-picker.tsx +51 -44
  165. package/src/reactions/reactions.tsx +11 -1
  166. package/src/reactions/tootltip.tsx +55 -0
  167. package/src/rich-text-embed-error.tsx +2 -1
  168. package/src/select/components/group-heading.tsx +8 -0
  169. package/src/select/components/menu-list-virtualized.tsx +6 -2
  170. package/src/select/components/option.tsx +4 -0
  171. package/src/select/index.tsx +8 -4
  172. package/src/select/select-control-settings-context.tsx +11 -2
  173. package/src/select/select-in-popover.tsx +30 -39
  174. package/src/select/styles.ts +21 -1
  175. package/src/tab-nav/tab-nav.tsx +36 -10
  176. package/src/toast/primitives.tsx +8 -1
  177. package/src/toggle-button/round-toggle-button.tsx +23 -0
  178. package/src/toggle-button/toggle-button-group.tsx +34 -0
  179. package/src/toggle-button/toggle-button.tsx +164 -0
  180. package/src/toggle.tsx +11 -3
  181. package/src/tooltip.tsx +29 -20
  182. package/src/type-badge.tsx +5 -2
  183. package/src/unit/styles.ts +2 -2
  184. package/src/unit/unit-with-tooltip.tsx +1 -1
  185. package/src/use-is-phone.tsx +50 -4
  186. package/src/use-is-support-hover.ts +1 -1
  187. package/src/use-on-screen-keyboard-data.tsx +66 -0
  188. package/src/workflow-progress-icon.tsx +16 -22
  189. package/src/popup/index.tsx +0 -383
  190. package/src/shortcut-badge.tsx +0 -29
  191. /package/src/{popup → popover}/popup-stack-context.tsx +0 -0
  192. /package/src/{popup → popover}/reference.ts +0 -0
  193. /package/src/{popup → popover}/styles.ts +0 -0
  194. /package/src/{popup → popover}/use-click-outside.ts +0 -0
@@ -29,31 +29,25 @@ export const WorkflowProgressIcon: FC<WorkflowProgressIcon> = ({
29
29
  <svg
30
30
  width={size}
31
31
  height={size}
32
- viewBox={`0 0 ${size} ${size}`}
32
+ viewBox={`0 0 16 16`}
33
33
  className={css`
34
34
  display: block;
35
35
  `}
36
36
  >
37
- <g transform={`translate(${size / 2}, ${size / 2})`}>
38
- {isDone ? (
39
- <>
40
- <circle r={size / 2} fill={doneFillColor} />
41
- <polyline
42
- points={`${-size / 4},0 ${-size / 10},${size / 4.5} ${size / 4.5},${-size / 6}`}
43
- stroke={doneStrokeColor}
44
- strokeWidth={size / 8}
45
- strokeLinecap={"round"}
46
- strokeLinejoin={"round"}
47
- fill={"none"}
48
- />
49
- </>
50
- ) : (
51
- <>
52
- <path d={getPath(total, total, size)} fill={fillBackground} />
53
- <path d={getPath(index, total, size)} fill={fillProgress} />
54
- </>
55
- )}
56
- </g>
37
+ {isDone ? (
38
+ <>
39
+ <circle cx="8" cy="8" r="8" fill={doneFillColor} fillOpacity="0.8" />
40
+ <path
41
+ d="M6.93229 11.98C7.25645 11.98 7.5091 11.8562 7.68071 11.5941L12.1236 4.80535C12.2476 4.61478 12.3 4.43852 12.3 4.27178C12.3 3.82395 11.9663 3.5 11.5086 3.5C11.1941 3.5 10.9986 3.61434 10.8079 3.91447L6.90845 10.0601L4.93012 7.60661C4.75374 7.39699 4.56306 7.30171 4.2961 7.30171C3.8337 7.30171 3.5 7.63042 3.5 8.07824C3.5 8.27832 3.56197 8.45464 3.73358 8.64992L6.19339 11.6274C6.39838 11.8704 6.62719 11.98 6.93229 11.98Z"
42
+ fill={doneStrokeColor}
43
+ />
44
+ </>
45
+ ) : (
46
+ <g transform={`translate(8, 8)`}>
47
+ <path d={getPath(total, total, 16)} fill={fillBackground} />
48
+ <path d={getPath(index, total, 16)} fill={fillProgress} />
49
+ </g>
50
+ )}
57
51
  </svg>
58
52
  );
59
53
  };
@@ -63,7 +57,7 @@ const getPath = _.memoize(
63
57
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
64
58
  // @ts-ignore bad d3-shape typings
65
59
  return arc()
66
- .innerRadius(size / 3)
60
+ .innerRadius(size / 2.75)
67
61
  .outerRadius(size / 2)
68
62
  .startAngle(0)
69
63
  .endAngle(2 * (index / total) * Math.PI)
@@ -1,383 +0,0 @@
1
- import {stopPropagation} from "@fibery/react/src/stop-propagation";
2
- import {useControllableState} from "@fibery/react/src/use-controllable-state";
3
- import {usePointerDownOutside} from "@fibery/react/src/use-pointer-down-outside";
4
- import {css} from "@linaria/core";
5
- import {createPopper, Modifier, Placement, State} from "@popperjs/core";
6
- import {Options as FlipOptions} from "@popperjs/core/lib/modifiers/flip";
7
- import {Options as PreventOverflowOptions} from "@popperjs/core/lib/modifiers/preventOverflow";
8
- import cx from "classnames";
9
- import _ from "lodash";
10
- import {
11
- CSSProperties,
12
- forwardRef,
13
- MouseEvent,
14
- ReactNode,
15
- useEffect,
16
- useId,
17
- useImperativeHandle,
18
- useMemo,
19
- useRef,
20
- useState,
21
- } from "react";
22
- import {createPortal} from "react-dom";
23
- import {usePopper} from "react-popper";
24
- import {createInlineTheme, fontWeight, space, themeVars} from "../design-system";
25
- import {IconButton} from "../button/icon-button";
26
- import CloseIcon from "../icons/react/Close";
27
- import {useTheme} from "../theme-provider";
28
- import {$TSFixMe} from "../tsfixme";
29
- import {useIsPhone} from "../use-is-phone";
30
- import {usePopupModifiers} from "./popup-modifiers-context";
31
- import {getMaxSize, observeWidth} from "./modifiers";
32
- import {isElementReference, Reference} from "./reference";
33
- import {basicPopupClassName, basicPopupContainerClassName, hidePopupWhenTriggerIsHiddenClassName} from "./styles";
34
- import {usePopupStackContext} from "./popup-stack-context";
35
-
36
- export type Props = {
37
- trigger?: ReactNode;
38
- children: ReactNode;
39
- placement: Placement;
40
- open: boolean;
41
- popupStyle?: $TSFixMe;
42
- mobilePopupStyle?: CSSProperties;
43
- mobilePopupContentClassName?: string;
44
- popupClassName?: string;
45
- popupContainerClassName?: string;
46
- renderInPortal?: boolean;
47
- offset?: [number, number];
48
- disabled?: boolean;
49
- triggerDomElement?: Reference;
50
- onMouseLeave?: (e: MouseEvent<HTMLDivElement>) => void;
51
- renderBackdrop?: boolean;
52
- backdropClassName?: string;
53
- closeOnEscape?: boolean;
54
- preventOverflowOptions?: Partial<PreventOverflowOptions>;
55
- flipOptions?: Partial<FlipOptions>;
56
- additionalModifiers?: Array<Partial<Modifier<$TSFixMe, $TSFixMe>>>;
57
- hidePopupWhenTriggerIsHidden?: boolean;
58
- shrinkable?: boolean;
59
- onOpen?: () => unknown;
60
- onClose?: (event: Event) => unknown;
61
- supportMobile?: boolean;
62
- title?: string;
63
- getPopupContainer?: () => HTMLElement;
64
-
65
- /**
66
- * @deprecated
67
- * Because of openning animation popup creates new stacking context https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_positioned_layout/Understanding_z-index/Stacking_context
68
- * this might break any components that use position: fixed inside the popup (i.e. formula editor -> monaco editor)
69
- * Pass true to restore stacking context after animation is finished.
70
- *
71
- * Marked as deprecated because it's better to avoid this prop
72
- */
73
- fixStackingContextAfterOpen?: boolean;
74
- /**
75
- * ran after Popup positioned the element the first time
76
- */
77
- onFirstUpdate?: () => void;
78
- };
79
-
80
- export type {State};
81
-
82
- export type PopupApi = {popupElement: HTMLDivElement | null; update: (() => Promise<unknown>) | null};
83
-
84
- function MobilePopup({
85
- content,
86
- mobilePopupStyle,
87
- mobilePopupContentClassName,
88
- title,
89
- onClose,
90
- }: {
91
- content: ReactNode;
92
- mobilePopupStyle?: CSSProperties;
93
- mobilePopupContentClassName?: string;
94
- title: string;
95
- onClose: () => void;
96
- }) {
97
- const theme = useTheme();
98
-
99
- return createPortal(
100
- <div
101
- className={css`
102
- position: absolute;
103
- top: 0;
104
- bottom: 0;
105
- left: 0;
106
- right: 0;
107
- background: ${themeVars.actionMenuBg};
108
- z-index: 1002;
109
- display: grid;
110
- grid-template-rows: 45px 1fr;
111
- `}
112
- style={{...createInlineTheme(theme), ...mobilePopupStyle}}
113
- >
114
- <div
115
- className={css`
116
- display: flex;
117
- align-items: center;
118
- justify-content: space-between;
119
- gap: ${space.s8}px;
120
- padding: 0 ${space.s8}px 0 ${space.s12}px;
121
- `}
122
- >
123
- <div
124
- className={css`
125
- font-weight: ${fontWeight.medium};
126
- font-size: 16px;
127
- min-width: 0;
128
- overflow: hidden;
129
- text-overflow: ellipsis;
130
- `}
131
- >
132
- {title}
133
- </div>
134
- <IconButton onClick={onClose} size={"large"}>
135
- <CloseIcon />
136
- </IconButton>
137
- </div>
138
- <div
139
- className={cx(
140
- css`
141
- border-top: ${themeVars.separators.opacity5};
142
- min-width: 0;
143
- `,
144
- mobilePopupContentClassName
145
- )}
146
- >
147
- {content}
148
- </div>
149
- </div>,
150
- document.body
151
- );
152
- }
153
-
154
- export const Popup = forwardRef<PopupApi, Props>(
155
- (
156
- {
157
- trigger,
158
- children,
159
- placement,
160
- open,
161
- popupStyle,
162
- popupContainerClassName,
163
- popupClassName,
164
- renderInPortal,
165
- offset = [0, 0],
166
- disabled = false,
167
- triggerDomElement,
168
- onMouseLeave,
169
- renderBackdrop,
170
- backdropClassName,
171
- closeOnEscape = true,
172
- preventOverflowOptions = {},
173
- flipOptions = {},
174
- additionalModifiers = [],
175
- hidePopupWhenTriggerIsHidden = true,
176
- shrinkable,
177
- onOpen = _.noop,
178
- onClose = _.noop,
179
- supportMobile = false,
180
- title = "",
181
- mobilePopupStyle,
182
- mobilePopupContentClassName,
183
- getPopupContainer: popupContainerOverride,
184
- fixStackingContextAfterOpen = false,
185
- onFirstUpdate,
186
- },
187
- ref
188
- ) => {
189
- const popupModifiers = usePopupModifiers();
190
- const getPopupContainer = popupContainerOverride ?? popupModifiers.getPopupContainer;
191
- const id = useId();
192
- const theme = useTheme();
193
- const {registerEscapeCallback, registerPopup} = usePopupStackContext();
194
- const isPhone = useIsPhone();
195
- const updateRef = useRef<(() => Promise<unknown>) | null>(null);
196
- const [triggerElement, setTriggerElement] = useControllableState<Reference>({value: triggerDomElement});
197
- const [popupElement, setPopupElement] = useState<HTMLDivElement | null>(null);
198
-
199
- const shrinkableModifiers = useMemo(() => {
200
- return shrinkable ? getMaxSize(preventOverflowOptions) : [];
201
- }, [preventOverflowOptions, shrinkable]);
202
- // migrate to floating-ui https://floating-ui.com/docs/migration
203
- const {styles, attributes, update} = usePopper(triggerElement, popupElement, {
204
- placement,
205
- onFirstUpdate,
206
- modifiers: [
207
- {
208
- name: "flip",
209
- options: {
210
- ...popupModifiers.flipOptions,
211
- ...flipOptions,
212
- },
213
- },
214
- {
215
- name: "preventOverflow",
216
- options: {
217
- tether: false,
218
- padding: space.s6,
219
- ...popupModifiers.preventOverflowOptions,
220
- ...preventOverflowOptions,
221
- },
222
- },
223
- {
224
- name: "offset",
225
- options: {
226
- offset: offset,
227
- },
228
- },
229
- observeWidth,
230
- ...shrinkableModifiers,
231
- ...additionalModifiers,
232
- ...(popupModifiers.additionalModifiers ?? []),
233
- ],
234
- });
235
- updateRef.current = update;
236
- useImperativeHandle(
237
- ref,
238
- () => {
239
- return {popupElement, update};
240
- },
241
- [popupElement, update]
242
- );
243
- useEffect(() => {
244
- let unregister: () => void;
245
- if (registerPopup && open) {
246
- unregister = registerPopup(id);
247
- }
248
- return () => {
249
- unregister?.();
250
- };
251
- }, [registerPopup, id, open]);
252
- useEffect(() => {
253
- if (triggerElement && closeOnEscape && open) {
254
- const onKeyDown = (evt: KeyboardEvent) => {
255
- if (evt.defaultPrevented) {
256
- return;
257
- }
258
- if (evt.key === "Escape") {
259
- onClose(evt);
260
- evt.preventDefault();
261
- evt.stopPropagation();
262
- }
263
- };
264
-
265
- if (registerEscapeCallback) {
266
- registerEscapeCallback(id, onKeyDown);
267
- } else {
268
- document.addEventListener("keydown", onKeyDown);
269
- }
270
-
271
- // if popup was opened but nothing was focused inside it we should catch 'Escape' key from trigger as well
272
- // otherwise it can be caught by navigation panel
273
- "addEventListener" in triggerElement && triggerElement.addEventListener("keydown", onKeyDown);
274
-
275
- return () => {
276
- if (!registerEscapeCallback) {
277
- document.removeEventListener("keydown", onKeyDown);
278
- }
279
-
280
- "removeEventListener" in triggerElement && triggerElement.removeEventListener("keydown", onKeyDown);
281
- };
282
- }
283
- // eslint-disable-next-line @typescript-eslint/no-empty-function
284
- return () => {};
285
- }, [closeOnEscape, onClose, open, triggerElement, registerEscapeCallback, id]);
286
-
287
- const {onPointerDownCapture} = usePointerDownOutside((event) => {
288
- if (!open || (isPhone && supportMobile)) {
289
- return;
290
- }
291
- const target = event.target;
292
- if (target instanceof Node) {
293
- const ignoreElements = _.compact([isElementReference(triggerElement) && triggerElement]);
294
- if (ignoreElements.some((element) => element.contains(target))) {
295
- return;
296
- }
297
- }
298
- onClose(event);
299
- });
300
-
301
- if (isPhone && supportMobile) {
302
- return open ? (
303
- <MobilePopup
304
- onClose={onClose}
305
- title={title}
306
- mobilePopupContentClassName={mobilePopupContentClassName}
307
- mobilePopupStyle={mobilePopupStyle}
308
- content={children}
309
- />
310
- ) : null;
311
- }
312
-
313
- const renderPopup = () => {
314
- return (
315
- <>
316
- {renderBackdrop && (
317
- <div
318
- id={"popup-backdrop"}
319
- data-testid={"popup-backdrop"}
320
- className={cx(
321
- backdropClassName,
322
- css`
323
- position: absolute;
324
- inset: 0;
325
- z-index: 1000;
326
- `
327
- )}
328
- />
329
- )}
330
- <div
331
- className={cx(
332
- basicPopupContainerClassName,
333
- hidePopupWhenTriggerIsHidden && hidePopupWhenTriggerIsHiddenClassName,
334
- popupContainerClassName
335
- )}
336
- onMouseLeave={onMouseLeave}
337
- ref={setPopupElement}
338
- onClick={stopPropagation}
339
- {...attributes.popper}
340
- onPointerDownCapture={onPointerDownCapture}
341
- style={{...styles.popper, ...createInlineTheme(theme), ...popupStyle}}
342
- >
343
- <div
344
- className={cx(basicPopupClassName, popupClassName)}
345
- onAnimationEnd={
346
- fixStackingContextAfterOpen
347
- ? (e) => (e.target as HTMLElement).setAttribute("data-fix-stacking-context", "")
348
- : undefined
349
- }
350
- style={popupStyle}
351
- >
352
- {children}
353
- </div>
354
- </div>
355
- </>
356
- );
357
- };
358
-
359
- // TODO: ui-kit should not know about portal container in main ui
360
- if (triggerDomElement) {
361
- return open ? (renderInPortal ? createPortal(renderPopup(), getPopupContainer()) : renderPopup()) : null;
362
- }
363
-
364
- const onMouseDown: React.MouseEventHandler<HTMLDivElement> = (e) => {
365
- if (e.button === 0) {
366
- open ? onClose(e as unknown as Event) : onOpen();
367
- }
368
- };
369
-
370
- return (
371
- <div>
372
- <div ref={setTriggerElement} onMouseDown={disabled ? undefined : onMouseDown}>
373
- {trigger}
374
- </div>
375
- {open ? (renderInPortal ? createPortal(renderPopup(), getPopupContainer()) : renderPopup()) : null}
376
- </div>
377
- );
378
- }
379
- );
380
-
381
- export {createPopper};
382
-
383
- export type {Placement};
@@ -1,29 +0,0 @@
1
- import {css, cx} from "@linaria/core";
2
- import {textStyles, border, space, lineHeight, themeVars} from "./design-system";
3
- import {useIsSupportHardwareKeyboard} from "./use-is-support-hardware-keyboard";
4
-
5
- export const shortcutCss = css`
6
- ${{
7
- ...textStyles.small,
8
- ...textStyles.numeric.tabularOn,
9
- borderRadius: border.radius4,
10
- border: themeVars.shortcutBorderColor,
11
- color: themeVars.shortcutTextColor,
12
- paddingTop: space.s2,
13
- paddingBottom: space.s2,
14
- paddingLeft: space.s4,
15
- paddingRight: space.s4,
16
- lineHeight: lineHeight.nowrap,
17
- whiteSpace: "nowrap",
18
- display: "inline-block",
19
- userSelect: "none",
20
- }}
21
- `;
22
-
23
- export const ShortcutBadge = ({className, shortcut}: {className?: string; shortcut: string}): JSX.Element | null => {
24
- const isSupportHardwareKeyboard = useIsSupportHardwareKeyboard();
25
- if (!isSupportHardwareKeyboard) {
26
- return null;
27
- }
28
- return <div className={cx(shortcutCss, className)}>{shortcut}</div>;
29
- };
File without changes
File without changes
File without changes
File without changes