@fibery/ui-kit 1.29.2 → 1.29.5

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 (59) hide show
  1. package/package.json +5 -4
  2. package/src/actions-menu/actions-menu-item.tsx +3 -1
  3. package/src/actions-menu/actions-menu-sub-command-menu.tsx +14 -6
  4. package/src/button/button-base.tsx +1 -1
  5. package/src/button/button.tsx +1 -1
  6. package/src/design-system.ts +78 -23
  7. package/src/emoji-picker/primitives/footer.tsx +1 -1
  8. package/src/icons/ast/Abort.ts +8 -0
  9. package/src/icons/ast/AiAssistant.ts +1 -1
  10. package/src/icons/ast/AiAvatar.ts +1 -1
  11. package/src/icons/ast/Clear.ts +8 -0
  12. package/src/icons/ast/Database.ts +1 -1
  13. package/src/icons/ast/DatabaseStroke.ts +8 -0
  14. package/src/icons/ast/ExtensionComments.ts +1 -1
  15. package/src/icons/ast/FieldUnit.ts +1 -1
  16. package/src/icons/ast/InfoCircle.ts +8 -0
  17. package/src/icons/ast/Key.ts +8 -0
  18. package/src/icons/ast/MoveBottom.ts +1 -1
  19. package/src/icons/ast/MoveLeft.ts +1 -1
  20. package/src/icons/ast/MoveRight.ts +1 -1
  21. package/src/icons/ast/MoveTop.ts +1 -1
  22. package/src/icons/ast/Pin.ts +1 -1
  23. package/src/icons/ast/RicheditorCommentCreate.ts +1 -1
  24. package/src/icons/ast/SendArrow.ts +8 -0
  25. package/src/icons/ast/UnitsAvatar.ts +8 -0
  26. package/src/icons/ast/UnitsCollection.ts +8 -0
  27. package/src/icons/ast/UnitsCounter.ts +8 -0
  28. package/src/icons/ast/UnitsDbBadgeAbbr.ts +8 -0
  29. package/src/icons/ast/UnitsDbBadgeFull.ts +8 -0
  30. package/src/icons/ast/UnitsDbIcon.ts +8 -0
  31. package/src/icons/ast/UnitsField.ts +8 -0
  32. package/src/icons/ast/UnitsInput.ts +8 -0
  33. package/src/icons/ast/UnitsProgressBar.ts +8 -0
  34. package/src/icons/ast/UnitsRichText.ts +8 -0
  35. package/src/icons/ast/UnitsSnippet.ts +8 -0
  36. package/src/icons/ast/index.tsx +17 -0
  37. package/src/icons/react/Abort.tsx +12 -0
  38. package/src/icons/react/Clear.tsx +12 -0
  39. package/src/icons/react/DatabaseStroke.tsx +12 -0
  40. package/src/icons/react/InfoCircle.tsx +12 -0
  41. package/src/icons/react/Key.tsx +12 -0
  42. package/src/icons/react/SendArrow.tsx +12 -0
  43. package/src/icons/react/UnitsAvatar.tsx +12 -0
  44. package/src/icons/react/UnitsCollection.tsx +12 -0
  45. package/src/icons/react/UnitsCounter.tsx +12 -0
  46. package/src/icons/react/UnitsDbBadgeAbbr.tsx +12 -0
  47. package/src/icons/react/UnitsDbBadgeFull.tsx +12 -0
  48. package/src/icons/react/UnitsDbIcon.tsx +12 -0
  49. package/src/icons/react/UnitsField.tsx +12 -0
  50. package/src/icons/react/UnitsInput.tsx +12 -0
  51. package/src/icons/react/UnitsProgressBar.tsx +12 -0
  52. package/src/icons/react/UnitsRichText.tsx +12 -0
  53. package/src/icons/react/UnitsSnippet.tsx +12 -0
  54. package/src/icons/react/index.tsx +17 -0
  55. package/src/select/custom-select-partials/menu.tsx +1 -1
  56. package/src/select/select-in-popover.tsx +56 -10
  57. package/src/theme-settings.ts +10 -8
  58. package/src/toggle.tsx +3 -1
  59. package/src/tooltip.tsx +4 -2
@@ -2,6 +2,7 @@ import {css, cx} from "@linaria/core";
2
2
  import {border, space, textStyles} from "../design-system";
3
3
  import {inputOverrides} from "../antd/styles";
4
4
  import React, {
5
+ ComponentProps,
5
6
  ComponentType,
6
7
  forwardRef,
7
8
  ReactNode,
@@ -26,16 +27,32 @@ import {
26
27
  StylesConfig,
27
28
  } from "./index";
28
29
  import {SelectControlSettingsProvider} from "./select-control-settings-context";
30
+ import {Menu} from "./custom-select-partials/menu";
29
31
 
30
32
  const offset = [0, space.s4] as [number, number];
33
+ const popupHeightVH = 45;
34
+ const popupMinHeightPx = 300;
35
+ const popupPaddingTop = space.s8;
36
+ const popupPaddingBottom = space.s8;
31
37
  const popupContainerClassName = css`
32
38
  z-index: 1050;
39
+ height: max(${popupHeightVH}vh, ${popupMinHeightPx}px);
40
+ display: flex;
41
+ flex-direction: row;
42
+
43
+ &:is([data-popper-placement="bottom-start"], [data-popper-placement="bottom-end"]) {
44
+ align-items: flex-start;
45
+ }
46
+
47
+ &:is([data-popper-placement="top-start"], [data-popper-placement="top-end"]) {
48
+ align-items: flex-end;
49
+ }
33
50
  `;
34
51
  const popupClassName = css`
35
52
  min-width: 320px;
36
53
  max-width: 440px;
37
- padding-top: ${space.s8}px;
38
- padding-bottom: ${space.s4}px;
54
+ padding-top: ${popupPaddingTop}px;
55
+ padding-bottom: ${popupPaddingBottom}px;
39
56
  padding-left: ${space.s8}px;
40
57
  padding-right: ${space.s8}px;
41
58
  `;
@@ -67,6 +84,8 @@ const titleClassName = css`
67
84
  padding-bottom: ${space.s12}px;
68
85
  `;
69
86
 
87
+ export const valueMaxHeight = 116;
88
+
70
89
  export const selectInPopupStyles = {
71
90
  container: (props: $TSFixMe) => ({
72
91
  ...props,
@@ -80,6 +99,11 @@ export const selectInPopupStyles = {
80
99
  paddingLeft: 0,
81
100
  paddingRight: 0,
82
101
  }),
102
+ control: (props: $TSFixMe) => ({
103
+ ...props,
104
+ maxHeight: valueMaxHeight,
105
+ overflow: "auto",
106
+ }),
83
107
  menu: (props: $TSFixMe) => ({
84
108
  ...props,
85
109
  minWidth: 100,
@@ -96,6 +120,7 @@ export type TriggerProps = {
96
120
  children: ReactNode;
97
121
  onClick: React.MouseEventHandler;
98
122
  onKeyDown: React.KeyboardEventHandler;
123
+ disabled?: boolean;
99
124
  };
100
125
 
101
126
  const Trigger = ({innerRef, children, onClick, onKeyDown}: TriggerProps) => {
@@ -106,11 +131,14 @@ const Trigger = ({innerRef, children, onClick, onKeyDown}: TriggerProps) => {
106
131
  );
107
132
  };
108
133
 
109
- type Components = {Trigger: ComponentType<TriggerProps>};
134
+ type Components = {
135
+ Trigger: ComponentType<TriggerProps>;
136
+ Menu: ComponentType<ComponentProps<typeof Menu>>;
137
+ };
110
138
 
111
139
  export type ComponentsConfig = Partial<Components>;
112
140
 
113
- const defaultComponents = {Trigger};
141
+ const defaultComponents = {Trigger, Menu};
114
142
 
115
143
  type Ref = {
116
144
  valueRef: HTMLDivElement | null;
@@ -146,10 +174,11 @@ type Props<Option, IsMulti extends boolean, Group extends GroupBase<Option>> = {
146
174
  onChange: (newValue: OnChangeValue<Option, IsMulti>, actionMeta: ActionMeta<Option>) => void;
147
175
  onMenuOpen?: () => void;
148
176
  onMenuClose?: () => void | boolean;
177
+ getPopupContainer?: () => HTMLElement;
149
178
  };
150
179
 
151
180
  function SelectInPopoverInner<Option, IsMulti extends boolean, Group extends GroupBase<Option>>(
152
- props: Props<Option, IsMulti, Group>,
181
+ props: Omit<Props<Option, IsMulti, Group>, "maxMenuHeight">,
153
182
  forwardedRef: React.ForwardedRef<Ref>
154
183
  ) {
155
184
  const {
@@ -168,7 +197,6 @@ function SelectInPopoverInner<Option, IsMulti extends boolean, Group extends Gro
168
197
  isClearable = true,
169
198
  renderValue,
170
199
  title,
171
- maxMenuHeight,
172
200
  hideOnChange = true,
173
201
  renderInPortal = true,
174
202
  popupStyles,
@@ -181,12 +209,14 @@ function SelectInPopoverInner<Option, IsMulti extends boolean, Group extends Gro
181
209
  onChange,
182
210
  onMenuOpen,
183
211
  onMenuClose,
212
+ getPopupContainer,
184
213
  } = props;
185
214
  const [triggerElement, setTriggerElement] = useState<HTMLDivElement | null>(null);
186
215
  const [visible, setVisible] = useState(menuIsOpen);
187
216
  const blurTimeoutRef = useRef<ReturnType<typeof setTimeout>>();
188
217
  const selectRef = useRef<{focus: () => void}>(null);
189
218
  const ref = useRef<HTMLDivElement | null>(null);
219
+
190
220
  useImperativeHandle(
191
221
  forwardedRef,
192
222
  () =>
@@ -269,12 +299,23 @@ function SelectInPopoverInner<Option, IsMulti extends boolean, Group extends Gro
269
299
  },
270
300
  [onShow, visible]
271
301
  );
272
-
302
+ const paddingPopup = popupPaddingTop + popupPaddingBottom;
303
+ const paddingMenu = 6 + 6 + 6;
304
+ const maxMenuHeight =
305
+ Math.max((document.body.clientHeight / 100) * popupHeightVH, popupMinHeightPx) -
306
+ valueMaxHeight -
307
+ paddingPopup -
308
+ paddingMenu;
273
309
  const mergedComponents = {...defaultComponents, ...components};
274
310
 
275
311
  return (
276
312
  <>
277
- <mergedComponents.Trigger innerRef={ref} onClick={onTriggerClick} onKeyDown={onTriggerKeyDown}>
313
+ <mergedComponents.Trigger
314
+ innerRef={ref}
315
+ onClick={onTriggerClick}
316
+ onKeyDown={onTriggerKeyDown}
317
+ disabled={disabled}
318
+ >
278
319
  {renderValue ? renderValue() : null}
279
320
  </mergedComponents.Trigger>
280
321
  {Boolean(triggerElement) && (
@@ -289,6 +330,7 @@ function SelectInPopoverInner<Option, IsMulti extends boolean, Group extends Gro
289
330
  onClose={() => onHide()}
290
331
  trigger={<></>}
291
332
  triggerDomElement={triggerElement}
333
+ getPopupContainer={getPopupContainer}
292
334
  >
293
335
  {title && <div className={titleClassName}>{title}</div>}
294
336
  {/*Usually we set popupContainerElement for react-select via context (SelectControlSettingsProvider). But here we render react-select in popover.*/}
@@ -338,7 +380,11 @@ function SelectInPopoverInner<Option, IsMulti extends boolean, Group extends Gro
338
380
  isClearable={!isCollectionMode && isClearable}
339
381
  formatGroupLabel={formatGroupLabel}
340
382
  formatOptionLabel={formatOptionLabel}
341
- components={{DropdownIndicator: null, IndicatorSeparator: null}}
383
+ components={{
384
+ DropdownIndicator: null,
385
+ IndicatorSeparator: null,
386
+ Menu: mergedComponents.Menu as $TSFixMe,
387
+ }}
342
388
  />
343
389
  </SelectControlSettingsProvider>
344
390
  </Popup>
@@ -348,7 +394,7 @@ function SelectInPopoverInner<Option, IsMulti extends boolean, Group extends Gro
348
394
  }
349
395
 
350
396
  type SelectInPopoverType = <Option, IsMulti extends boolean, Group extends GroupBase<Option>>(
351
- props: Props<Option, IsMulti, Group> & {ref?: React.ForwardedRef<Ref>}
397
+ props: Omit<Props<Option, IsMulti, Group>, "maxMenuHeight"> & {ref?: React.ForwardedRef<Ref>}
352
398
  ) => ReturnType<typeof SelectInPopoverInner>;
353
399
 
354
400
  // Explicit type assertion to specify that component accepts generic props because forwardRef breaks it
@@ -13,17 +13,19 @@ export type ThemeMenuPreference = "dark" | "auto";
13
13
  export type ThemeMode = "dark" | "light" | "light2";
14
14
 
15
15
  export function getThemePreference(): ThemePreference {
16
+ const allowedValues = ["dark", "light", "auto"];
16
17
  try {
17
- const item = localStorage.getItem(themePreferenceKey);
18
- if (item === "auto") {
19
- return "auto";
20
- } else if (item === "dark") {
21
- return "dark";
22
- } else if (item === "light") {
23
- return "light";
18
+ const urlParams = new URLSearchParams(window.location.search);
19
+ const itemInUrl = urlParams.get("force-theme");
20
+ if (itemInUrl && allowedValues.includes(itemInUrl)) {
21
+ return itemInUrl as ThemePreference;
22
+ }
23
+ const itemInStorage = localStorage.getItem(themePreferenceKey);
24
+ if (itemInStorage && allowedValues.includes(itemInStorage)) {
25
+ return itemInStorage as ThemePreference;
24
26
  }
25
27
  } catch (e) {
26
- return "light";
28
+ // Just return the default below
27
29
  }
28
30
  return "light";
29
31
  }
package/src/toggle.tsx CHANGED
@@ -81,6 +81,7 @@ interface ToggleProps extends Omit<ComponentProps<"input">, "value"> {
81
81
  value?: boolean;
82
82
  label?: ReactNode;
83
83
  labelTitle?: string;
84
+ labelMutedWhenDisabled?: boolean;
84
85
  backgroundColor: string;
85
86
  labelPosition?: "first" | "last";
86
87
  wrapperClassName?: string;
@@ -95,6 +96,7 @@ export const Toggle: FC<ToggleProps> = ({
95
96
  size = 16,
96
97
  onChange,
97
98
  labelPosition = "last",
99
+ labelMutedWhenDisabled = true,
98
100
  className,
99
101
  wrapperClassName,
100
102
  ...rest
@@ -149,7 +151,7 @@ export const Toggle: FC<ToggleProps> = ({
149
151
  </CircleContainer>
150
152
 
151
153
  {label && (
152
- <Label disabled={disabled} labelPosition={labelPosition}>
154
+ <Label disabled={disabled && labelMutedWhenDisabled} labelPosition={labelPosition}>
153
155
  {label}
154
156
  </Label>
155
157
  )}
package/src/tooltip.tsx CHANGED
@@ -20,7 +20,7 @@ const descriptionStyle = css`
20
20
  font-weight: ${fontWeight.regular};
21
21
  `;
22
22
 
23
- const tooltipStyle = css`
23
+ export const tooltipStyle = css`
24
24
  font-size: 13px;
25
25
  color: ${themeVars.whiteColor};
26
26
  z-index: 100000;
@@ -96,6 +96,7 @@ export const TooltipProvider: React.FC<TooltipPrimitive.TooltipProviderProps> =
96
96
  export type TooltipProps = Omit<TooltipPrimitive.TooltipTriggerProps, "title"> & {
97
97
  title?: ReactNode;
98
98
  description?: ReactNode;
99
+ tooltipContentStyle?: string;
99
100
  setContentElement?: (el: HTMLDivElement | null) => void;
100
101
  content?: ReactNode;
101
102
  container?: HTMLElement | null | undefined;
@@ -146,6 +147,7 @@ export const Tooltip = forwardRef<HTMLButtonElement, TooltipProps>(
146
147
  disabled,
147
148
  setContentElement,
148
149
  container,
150
+ tooltipContentStyle,
149
151
  ...triggerProps
150
152
  },
151
153
  ref
@@ -179,7 +181,7 @@ export const Tooltip = forwardRef<HTMLButtonElement, TooltipProps>(
179
181
  sideOffset={sideOffset}
180
182
  align={align}
181
183
  alignOffset={alignOffset}
182
- className={cx(tooltipStyle, whiteBg && whiteBgStyle)}
184
+ className={cx(tooltipStyle, whiteBg && whiteBgStyle, tooltipContentStyle)}
183
185
  >
184
186
  {content}
185
187
  </TooltipPrimitive.Content>