@fibery/ui-kit 1.29.1 → 1.29.4

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 (77) hide show
  1. package/package.json +4 -4
  2. package/src/actions-menu/actions-menu-confirmation.tsx +70 -0
  3. package/src/actions-menu/actions-menu-item.tsx +3 -1
  4. package/src/actions-menu/actions-menu-sub-command-menu.tsx +104 -141
  5. package/src/actions-menu/actions-menu-sub-menu.tsx +3 -1
  6. package/src/actions-menu/actions-menu.tsx +6 -1
  7. package/src/actions-menu/context-actions-menu.tsx +5 -1
  8. package/src/actions-menu/contexts/actions-menu-context.tsx +6 -2
  9. package/src/button/button-base.tsx +1 -1
  10. package/src/button/button.tsx +1 -1
  11. package/src/design-system.ts +83 -25
  12. package/src/dropdown-menu/index.tsx +7 -2
  13. package/src/emoji-picker/primitives/footer.tsx +1 -1
  14. package/src/icons/ast/Abort.ts +8 -0
  15. package/src/icons/ast/AiAvatar.ts +1 -1
  16. package/src/icons/ast/Database.ts +1 -1
  17. package/src/icons/ast/DatabaseStroke.ts +8 -0
  18. package/src/icons/ast/ExtensionComments.ts +1 -1
  19. package/src/icons/ast/FieldUnit.ts +8 -0
  20. package/src/icons/ast/InfoCircle.ts +8 -0
  21. package/src/icons/ast/IntegrationsIntegrationDiscourseColor.ts +8 -0
  22. package/src/icons/ast/IntegrationsIntegrationIntercomColor.ts +8 -0
  23. package/src/icons/ast/IntegrationsIntegrationSlackColor.ts +8 -0
  24. package/src/icons/ast/IntegrationsIntegrationZendeskColor.ts +8 -0
  25. package/src/icons/ast/Key.ts +8 -0
  26. package/src/icons/ast/MoveBottom.ts +8 -0
  27. package/src/icons/ast/MoveLeft.ts +8 -0
  28. package/src/icons/ast/MoveRight.ts +8 -0
  29. package/src/icons/ast/MoveTop.ts +8 -0
  30. package/src/icons/ast/Pin.ts +8 -0
  31. package/src/icons/ast/RicheditorCommentCreate.ts +1 -1
  32. package/src/icons/ast/SendArrow.ts +8 -0
  33. package/src/icons/ast/UnitsAvatar.ts +8 -0
  34. package/src/icons/ast/UnitsCollection.ts +8 -0
  35. package/src/icons/ast/UnitsCounter.ts +8 -0
  36. package/src/icons/ast/UnitsDbBadgeAbbr.ts +8 -0
  37. package/src/icons/ast/UnitsDbBadgeFull.ts +8 -0
  38. package/src/icons/ast/UnitsDbIcon.ts +8 -0
  39. package/src/icons/ast/UnitsField.ts +8 -0
  40. package/src/icons/ast/UnitsInput.ts +8 -0
  41. package/src/icons/ast/UnitsProgressBar.ts +8 -0
  42. package/src/icons/ast/UnitsRichText.ts +8 -0
  43. package/src/icons/ast/UnitsSnippet.ts +8 -0
  44. package/src/icons/ast/index.tsx +26 -0
  45. package/src/icons/react/Abort.tsx +12 -0
  46. package/src/icons/react/DatabaseStroke.tsx +12 -0
  47. package/src/icons/react/FieldUnit.tsx +12 -0
  48. package/src/icons/react/InfoCircle.tsx +12 -0
  49. package/src/icons/react/IntegrationsIntegrationDiscourseColor.tsx +12 -0
  50. package/src/icons/react/IntegrationsIntegrationIntercomColor.tsx +12 -0
  51. package/src/icons/react/IntegrationsIntegrationSlackColor.tsx +12 -0
  52. package/src/icons/react/IntegrationsIntegrationZendeskColor.tsx +12 -0
  53. package/src/icons/react/Key.tsx +12 -0
  54. package/src/icons/react/MoveBottom.tsx +12 -0
  55. package/src/icons/react/MoveLeft.tsx +12 -0
  56. package/src/icons/react/MoveRight.tsx +12 -0
  57. package/src/icons/react/MoveTop.tsx +12 -0
  58. package/src/icons/react/Pin.tsx +12 -0
  59. package/src/icons/react/SendArrow.tsx +12 -0
  60. package/src/icons/react/UnitsAvatar.tsx +12 -0
  61. package/src/icons/react/UnitsCollection.tsx +12 -0
  62. package/src/icons/react/UnitsCounter.tsx +12 -0
  63. package/src/icons/react/UnitsDbBadgeAbbr.tsx +12 -0
  64. package/src/icons/react/UnitsDbBadgeFull.tsx +12 -0
  65. package/src/icons/react/UnitsDbIcon.tsx +12 -0
  66. package/src/icons/react/UnitsField.tsx +12 -0
  67. package/src/icons/react/UnitsInput.tsx +12 -0
  68. package/src/icons/react/UnitsProgressBar.tsx +12 -0
  69. package/src/icons/react/UnitsRichText.tsx +12 -0
  70. package/src/icons/react/UnitsSnippet.tsx +12 -0
  71. package/src/icons/react/index.tsx +26 -0
  72. package/src/item.tsx +1 -1
  73. package/src/select/custom-select-partials/menu.tsx +1 -1
  74. package/src/select/select-in-popover.tsx +58 -11
  75. package/src/theme-settings.ts +10 -8
  76. package/src/toggle.tsx +3 -1
  77. 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,15 +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
- max-width: 360px;
36
- padding-top: ${space.s8}px;
37
- padding-bottom: ${space.s4}px;
52
+ min-width: 320px;
53
+ max-width: 440px;
54
+ padding-top: ${popupPaddingTop}px;
55
+ padding-bottom: ${popupPaddingBottom}px;
38
56
  padding-left: ${space.s8}px;
39
57
  padding-right: ${space.s8}px;
40
58
  `;
@@ -66,6 +84,8 @@ const titleClassName = css`
66
84
  padding-bottom: ${space.s12}px;
67
85
  `;
68
86
 
87
+ export const valueMaxHeight = 116;
88
+
69
89
  export const selectInPopupStyles = {
70
90
  container: (props: $TSFixMe) => ({
71
91
  ...props,
@@ -79,6 +99,11 @@ export const selectInPopupStyles = {
79
99
  paddingLeft: 0,
80
100
  paddingRight: 0,
81
101
  }),
102
+ control: (props: $TSFixMe) => ({
103
+ ...props,
104
+ maxHeight: valueMaxHeight,
105
+ overflow: "auto",
106
+ }),
82
107
  menu: (props: $TSFixMe) => ({
83
108
  ...props,
84
109
  minWidth: 100,
@@ -95,6 +120,7 @@ export type TriggerProps = {
95
120
  children: ReactNode;
96
121
  onClick: React.MouseEventHandler;
97
122
  onKeyDown: React.KeyboardEventHandler;
123
+ disabled?: boolean;
98
124
  };
99
125
 
100
126
  const Trigger = ({innerRef, children, onClick, onKeyDown}: TriggerProps) => {
@@ -105,11 +131,14 @@ const Trigger = ({innerRef, children, onClick, onKeyDown}: TriggerProps) => {
105
131
  );
106
132
  };
107
133
 
108
- type Components = {Trigger: ComponentType<TriggerProps>};
134
+ type Components = {
135
+ Trigger: ComponentType<TriggerProps>;
136
+ Menu: ComponentType<ComponentProps<typeof Menu>>;
137
+ };
109
138
 
110
139
  export type ComponentsConfig = Partial<Components>;
111
140
 
112
- const defaultComponents = {Trigger};
141
+ const defaultComponents = {Trigger, Menu};
113
142
 
114
143
  type Ref = {
115
144
  valueRef: HTMLDivElement | null;
@@ -145,10 +174,11 @@ type Props<Option, IsMulti extends boolean, Group extends GroupBase<Option>> = {
145
174
  onChange: (newValue: OnChangeValue<Option, IsMulti>, actionMeta: ActionMeta<Option>) => void;
146
175
  onMenuOpen?: () => void;
147
176
  onMenuClose?: () => void | boolean;
177
+ getPopupContainer?: () => HTMLElement;
148
178
  };
149
179
 
150
180
  function SelectInPopoverInner<Option, IsMulti extends boolean, Group extends GroupBase<Option>>(
151
- props: Props<Option, IsMulti, Group>,
181
+ props: Omit<Props<Option, IsMulti, Group>, "maxMenuHeight">,
152
182
  forwardedRef: React.ForwardedRef<Ref>
153
183
  ) {
154
184
  const {
@@ -167,7 +197,6 @@ function SelectInPopoverInner<Option, IsMulti extends boolean, Group extends Gro
167
197
  isClearable = true,
168
198
  renderValue,
169
199
  title,
170
- maxMenuHeight,
171
200
  hideOnChange = true,
172
201
  renderInPortal = true,
173
202
  popupStyles,
@@ -180,12 +209,14 @@ function SelectInPopoverInner<Option, IsMulti extends boolean, Group extends Gro
180
209
  onChange,
181
210
  onMenuOpen,
182
211
  onMenuClose,
212
+ getPopupContainer,
183
213
  } = props;
184
214
  const [triggerElement, setTriggerElement] = useState<HTMLDivElement | null>(null);
185
215
  const [visible, setVisible] = useState(menuIsOpen);
186
216
  const blurTimeoutRef = useRef<ReturnType<typeof setTimeout>>();
187
217
  const selectRef = useRef<{focus: () => void}>(null);
188
218
  const ref = useRef<HTMLDivElement | null>(null);
219
+
189
220
  useImperativeHandle(
190
221
  forwardedRef,
191
222
  () =>
@@ -268,12 +299,23 @@ function SelectInPopoverInner<Option, IsMulti extends boolean, Group extends Gro
268
299
  },
269
300
  [onShow, visible]
270
301
  );
271
-
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;
272
309
  const mergedComponents = {...defaultComponents, ...components};
273
310
 
274
311
  return (
275
312
  <>
276
- <mergedComponents.Trigger innerRef={ref} onClick={onTriggerClick} onKeyDown={onTriggerKeyDown}>
313
+ <mergedComponents.Trigger
314
+ innerRef={ref}
315
+ onClick={onTriggerClick}
316
+ onKeyDown={onTriggerKeyDown}
317
+ disabled={disabled}
318
+ >
277
319
  {renderValue ? renderValue() : null}
278
320
  </mergedComponents.Trigger>
279
321
  {Boolean(triggerElement) && (
@@ -288,6 +330,7 @@ function SelectInPopoverInner<Option, IsMulti extends boolean, Group extends Gro
288
330
  onClose={() => onHide()}
289
331
  trigger={<></>}
290
332
  triggerDomElement={triggerElement}
333
+ getPopupContainer={getPopupContainer}
291
334
  >
292
335
  {title && <div className={titleClassName}>{title}</div>}
293
336
  {/*Usually we set popupContainerElement for react-select via context (SelectControlSettingsProvider). But here we render react-select in popover.*/}
@@ -337,7 +380,11 @@ function SelectInPopoverInner<Option, IsMulti extends boolean, Group extends Gro
337
380
  isClearable={!isCollectionMode && isClearable}
338
381
  formatGroupLabel={formatGroupLabel}
339
382
  formatOptionLabel={formatOptionLabel}
340
- components={{DropdownIndicator: null, IndicatorSeparator: null}}
383
+ components={{
384
+ DropdownIndicator: null,
385
+ IndicatorSeparator: null,
386
+ Menu: mergedComponents.Menu as $TSFixMe,
387
+ }}
341
388
  />
342
389
  </SelectControlSettingsProvider>
343
390
  </Popup>
@@ -347,7 +394,7 @@ function SelectInPopoverInner<Option, IsMulti extends boolean, Group extends Gro
347
394
  }
348
395
 
349
396
  type SelectInPopoverType = <Option, IsMulti extends boolean, Group extends GroupBase<Option>>(
350
- props: Props<Option, IsMulti, Group> & {ref?: React.ForwardedRef<Ref>}
397
+ props: Omit<Props<Option, IsMulti, Group>, "maxMenuHeight"> & {ref?: React.ForwardedRef<Ref>}
351
398
  ) => ReturnType<typeof SelectInPopoverInner>;
352
399
 
353
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>