@fibery/ui-kit 1.40.4 → 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 (141) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/eslint.config.mjs +16 -0
  3. package/package.json +8 -7
  4. package/src/a11y-color.test.ts +5 -24
  5. package/src/actions-menu/actions-menu-item.tsx +6 -9
  6. package/src/actions-menu/context-actions-menu.tsx +8 -3
  7. package/src/ai/model.tsx +0 -1
  8. package/src/ai/temperature.tsx +0 -1
  9. package/src/animated-height-container.tsx +3 -3
  10. package/src/antd/index.tsx +3 -0
  11. package/src/antd/input.tsx +0 -1
  12. package/src/antd/styles.ts +9 -9
  13. package/src/app-icon-with-fallback.tsx +5 -5
  14. package/src/app-icon-wrapper.tsx +2 -3
  15. package/src/app-icon.tsx +3 -3
  16. package/src/avatar.tsx +3 -3
  17. package/src/button/base-button.tsx +0 -1
  18. package/src/button/make-button-colors.ts +2 -2
  19. package/src/checkbox.tsx +1 -1
  20. package/src/collapsible-section.tsx +11 -1
  21. package/src/color-utils.test.ts +15 -25
  22. package/src/color-utils.ts +43 -8
  23. package/src/command-menu/index.tsx +1 -0
  24. package/src/context-menu/index.tsx +5 -5
  25. package/src/date-picker/contexts.ts +2 -2
  26. package/src/date-picker/date-range-picker.tsx +3 -4
  27. package/src/date-picker/single-date-picker.tsx +147 -119
  28. package/src/date-picker/types.ts +4 -3
  29. package/src/day-select/iso-week-day-select.tsx +2 -2
  30. package/src/day-select/week-day-select.tsx +2 -2
  31. package/src/delayed.tsx +0 -1
  32. package/src/design-system/alpha.test.ts +59 -0
  33. package/src/design-system/alpha.ts +41 -0
  34. package/src/design-system/animation.ts +10 -0
  35. package/src/design-system/colors-css.test.ts +39 -0
  36. package/src/design-system/colors-css.ts +25 -0
  37. package/src/design-system/colors-js.test.ts +232 -0
  38. package/src/design-system/colors-js.ts +107 -0
  39. package/src/design-system/colors.test.ts +74 -0
  40. package/src/{design-system.colors.ts → design-system/colors.ts} +133 -134
  41. package/src/design-system/date.ts +3 -0
  42. package/src/design-system/layout.ts +106 -0
  43. package/src/design-system/theme.test.ts +94 -0
  44. package/src/design-system/theme.ts +93 -0
  45. package/src/design-system/typography.ts +179 -0
  46. package/src/design-system/vars.test.ts +1679 -0
  47. package/src/design-system/vars.ts +52 -0
  48. package/src/design-system.test.ts +46 -303
  49. package/src/design-system.ts +25 -545
  50. package/src/dropdown-menu/index.tsx +5 -5
  51. package/src/emoji-picker/icon-emoji-picker.tsx +1 -1
  52. package/src/fibermoji-placeholder.tsx +3 -3
  53. package/src/field-container.tsx +11 -2
  54. package/src/file-item/file-icon.tsx +3 -3
  55. package/src/file-item-2.tsx +4 -10
  56. package/src/file-item.tsx +0 -1
  57. package/src/icons/ast/ChatBubble.ts +8 -0
  58. package/src/icons/ast/ChatFloat.ts +8 -0
  59. package/src/icons/ast/ChatSidebar.ts +8 -0
  60. package/src/icons/ast/FileOther.ts +8 -0
  61. package/src/icons/ast/NoBorder.ts +8 -0
  62. package/src/icons/ast/NoFill.ts +8 -0
  63. package/src/icons/ast/index.tsx +6 -0
  64. package/src/icons/react/ChatBubble.tsx +13 -0
  65. package/src/icons/react/ChatFloat.tsx +13 -0
  66. package/src/icons/react/ChatSidebar.tsx +13 -0
  67. package/src/icons/react/FileOther.tsx +13 -0
  68. package/src/icons/react/NoBorder.tsx +13 -0
  69. package/src/icons/react/NoFill.tsx +13 -0
  70. package/src/icons/react/index.tsx +6 -0
  71. package/src/icons/svg/chat-bubble.svg +4 -0
  72. package/src/icons/svg/chat-float.svg +4 -0
  73. package/src/icons/svg/chat-sidebar.svg +4 -0
  74. package/src/icons/svg/file-other.svg +3 -0
  75. package/src/icons/svg/no-border.svg +17 -0
  76. package/src/icons/svg/no-fill.svg +4 -0
  77. package/src/images-gallery/images-gallery.tsx +8 -6
  78. package/src/images-gallery/slide-buttons.tsx +2 -2
  79. package/src/is-iOS.ts +0 -1
  80. package/src/is-in-popup.ts +2 -1
  81. package/src/lists/actions-menu-row-surface.tsx +4 -4
  82. package/src/loading-sausage.tsx +2 -2
  83. package/src/media-query-utils.ts +1 -2
  84. package/src/mobile-keyboard-aware-popup.tsx +2 -2
  85. package/src/modal-menu/modal-menu-content.tsx +2 -2
  86. package/src/number-input/decimal.js +9 -7
  87. package/src/number-input/{number-inline-input-with-autosize.tsx → number-input-inline-with-autosize.tsx} +20 -41
  88. package/src/number-input/number-input-inline.tsx +118 -0
  89. package/src/number-input/{index.test.js → number-input.test.tsx} +38 -43
  90. package/src/number-input/number-input.tsx +63 -121
  91. package/src/number-input/types.ts +19 -0
  92. package/src/number-input/utils.ts +61 -0
  93. package/src/online-users.tsx +2 -2
  94. package/src/palette-generator.test.ts +24 -281
  95. package/src/palette-generator.ts +39 -45
  96. package/src/palettes/_.ts +72 -0
  97. package/src/palettes/slate-arch.colors-snapshot.test.ts +1689 -0
  98. package/src/palettes/slate-arch.ts +188 -0
  99. package/src/palettes/slate-user.colors-snapshot.test.ts +1689 -0
  100. package/src/palettes/slate-user.ts +187 -0
  101. package/src/palettes/warm-arch.colors-snapshot.test.ts +1689 -0
  102. package/src/palettes/warm-arch.ts +222 -0
  103. package/src/palettes/warm-user.colors-snapshot.test.ts +1689 -0
  104. package/src/palettes/warm-user.ts +222 -0
  105. package/src/popover/get-element-ref.ts +28 -0
  106. package/src/popover/index.tsx +232 -333
  107. package/src/popover/{mobile-popup-context.tsx → mobile-popover-context.tsx} +7 -7
  108. package/src/popover/mobile-popover.tsx +169 -0
  109. package/src/popover/modifiers.tsx +2 -2
  110. package/src/popover/popup-stack-context.tsx +8 -9
  111. package/src/root-theme-provider.test.tsx +114 -19
  112. package/src/scale-generator.ts +31 -22
  113. package/src/select/components/menu-list-virtualized.tsx +5 -3
  114. package/src/select/index.tsx +6 -5
  115. package/src/select/select.tsx +36 -38
  116. package/src/select/util.ts +1 -1
  117. package/src/static-palettes.ts +221 -11
  118. package/src/thematic-controls.tsx +6 -6
  119. package/src/thematic-scales.tsx +15 -15
  120. package/src/thematic-state.ts +57 -20
  121. package/src/thematic.tsx +36 -32
  122. package/src/theme-provider.test.tsx +31 -19
  123. package/src/theme-provider.tsx +41 -38
  124. package/src/theme-settings.ts +66 -11
  125. package/src/theme-styles.ts +53 -8
  126. package/src/toast/toast.tsx +1 -2
  127. package/src/toggle.tsx +2 -2
  128. package/src/tooltip.tsx +4 -3
  129. package/src/type-badge.tsx +4 -11
  130. package/src/unit/styles.ts +0 -23
  131. package/src/use-is-phone.tsx +7 -2
  132. package/src/use-on-screen-keyboard-data.tsx +2 -2
  133. package/src/with-data.tsx +4 -3
  134. package/src/workflow-progress-icon.tsx +2 -2
  135. package/.eslintignore +0 -3
  136. package/.eslintrc +0 -14
  137. package/src/__mocks__/createInlineTheme.js +0 -3
  138. package/src/__snapshots__/design-system.test.ts.snap +0 -7265
  139. package/src/create-inline-theme.ts +0 -67
  140. package/src/number-input/index.js +0 -191
  141. package/src/palette.ts +0 -253
@@ -1,22 +1,67 @@
1
1
  import {css} from "@linaria/core";
2
- import {createInlineTheme, getThemeColors, themeVars} from "./design-system";
3
- import {makeDefaultPalette} from "./palette-generator";
2
+ import {createInlineStyles, getThemeColors, ThemeColors, ThemeStyles} from "./design-system";
3
+ import {warmUserPalette} from "./palettes/warm-user";
4
+ import {slateUserPalette} from "./palettes/slate-user";
5
+ import {ThemeMode} from "./theme-settings";
4
6
 
5
- export const defaultPalette = makeDefaultPalette();
7
+ export const defaultPalette = slateUserPalette;
8
+ export const defaultLightTheme = getThemeColors(null, "light", defaultPalette);
9
+ export const defaultDarkTheme = getThemeColors(null, "dark", defaultPalette);
6
10
 
7
- export const defaultLightTheme = getThemeColors(themeVars.brandColors.blue, "light", defaultPalette);
8
- export const defaultDarkTheme = getThemeColors(themeVars.brandColors.blue, "dark", defaultPalette);
11
+ const warmPalette = warmUserPalette;
12
+ const warmLightTheme = getThemeColors(null, "light", warmPalette);
13
+ const warmDarkTheme = getThemeColors(null, "dark", warmPalette);
9
14
 
10
- export const defaultLightThemeStyles = createInlineTheme(defaultLightTheme, []);
11
- export const defaultDarkThemeStyles = createInlineTheme(defaultDarkTheme, []);
15
+ export const defaultLightThemeStyles = createInlineStyles(defaultLightTheme);
16
+ export const defaultDarkThemeStyles = createInlineStyles(defaultDarkTheme);
12
17
 
13
- export const themeStyles = css`
18
+ const warmLightThemeStyles = createInlineStyles(warmLightTheme);
19
+ const warmDarkThemeStyles = createInlineStyles(warmDarkTheme);
20
+
21
+ export function selectGlobalTheme(warm: boolean, dark: boolean): [colors: ThemeColors, styles: ThemeStyles] {
22
+ if (warm) {
23
+ return dark ? [warmDarkTheme, warmDarkThemeStyles] : [warmLightTheme, warmLightThemeStyles];
24
+ } else {
25
+ return dark ? [defaultDarkTheme, defaultDarkThemeStyles] : [defaultLightTheme, defaultLightThemeStyles];
26
+ }
27
+ }
28
+
29
+ const darkClassName = "dark-theme";
30
+ const light2ClassName = "light-theme-and-dark-menu";
31
+ const warmClassName = "warm-palette";
32
+
33
+ export function chooseGlobalStyles(themeMode: ThemeMode, warm: boolean) {
34
+ const htmlElement = document.documentElement;
35
+ htmlElement.classList.toggle(darkClassName, themeMode === "dark");
36
+ htmlElement.classList.toggle(light2ClassName, themeMode === "light2");
37
+ htmlElement.classList.toggle(warmClassName, warm);
38
+
39
+ const colorScheme = themeMode === "dark" ? "dark" : "light";
40
+ htmlElement.style.colorScheme = colorScheme;
41
+
42
+ // Multiple color schemes (FIXME: missing, unknown implications) "light" | "dark" | "light dark" | "dark light"
43
+ // indicates that the first scheme is preferred by the document, but that the second scheme is acceptable if the user prefers it.
44
+ // see https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/meta/name/color-scheme#usage_notes
45
+ const colorSchemeMeta = document.querySelector('meta[name="color-scheme"]');
46
+ colorSchemeMeta?.setAttribute("content", colorScheme);
47
+
48
+ htmlElement.classList.add(globals);
49
+ }
50
+
51
+ export const globals = css`
14
52
  :global() {
15
53
  html:root {
16
54
  ${defaultLightThemeStyles}
17
55
  &.dark-theme {
18
56
  ${defaultDarkThemeStyles}
19
57
  }
58
+
59
+ &.warm-palette {
60
+ ${warmLightThemeStyles}
61
+ &.dark-theme {
62
+ ${warmDarkThemeStyles}
63
+ }
64
+ }
20
65
  }
21
66
  }
22
67
  `;
@@ -1,7 +1,7 @@
1
1
  import {useCallbackRef} from "@fibery/react/src/use-callback-ref";
2
2
  import {useControllableState} from "@fibery/react/src/use-controllable-state";
3
3
  import {css, cx} from "@linaria/core";
4
- import {useEffect, useRef, useCallback} from "react";
4
+ import {useCallback, useEffect, useRef} from "react";
5
5
  import {space, themeVars} from "../design-system";
6
6
  import Spinner from "../icons/react/Spinner";
7
7
  import CheckCircleFilled from "../icons/react/CheckCircleFilled";
@@ -115,7 +115,6 @@ export const Toast: React.FC<ToastProps> = (props) => {
115
115
  clearTimeout(emergencyTimeout);
116
116
  };
117
117
  }
118
- // eslint-disable-next-line @typescript-eslint/no-empty-function
119
118
  return () => {};
120
119
  }, [isOpen, onHideCb]);
121
120
 
package/src/toggle.tsx CHANGED
@@ -2,7 +2,7 @@ import {css, cx} from "@linaria/core";
2
2
  import {styled} from "@linaria/react";
3
3
  import {ComponentProps, FC, ReactNode} from "react";
4
4
  import {space, textStyles, transition} from "./design-system";
5
- import _ from "lodash";
5
+ import memoize from "lodash/memoize";
6
6
  import SpinnerIcon from "./icons/react/Spinner";
7
7
  import {mobileRootSelector} from "./mobile-styles";
8
8
  import {darkenChroma, getAlpha, produceColor, setAlpha} from "./color-utils";
@@ -48,7 +48,7 @@ const labelWrapperStyle = css`
48
48
  align-items: center;
49
49
  `;
50
50
 
51
- const getOutlineColor = _.memoize((color: string) => {
51
+ const getOutlineColor = memoize((color: string) => {
52
52
  const alpha = getAlpha(color);
53
53
  if (alpha < 1) {
54
54
  return produceColor(color, (c) => setAlpha(c, Math.min(1, alpha + 0.3)));
package/src/tooltip.tsx CHANGED
@@ -2,8 +2,9 @@ import {css, cx} from "@linaria/core";
2
2
  import * as TooltipPrimitive from "@radix-ui/react-tooltip";
3
3
  import {forwardRef, type ReactNode, type SyntheticEvent} from "react";
4
4
  import {border, fontWeight, lineHeight, space, themeVars, tooltipDelay} from "./design-system";
5
- import {ThemeProvider} from "./theme-provider";
5
+ import {RadixPortalThemeProvider} from "./theme-provider";
6
6
 
7
+ // FIXME consolidate as common util
7
8
  const isFlagPresent = (flag: string) => new RegExp(`[?&]${flag}\\b`).test(window.location.search);
8
9
 
9
10
  const preventDefaultAndStopPropagation = (e: SyntheticEvent) => {
@@ -205,7 +206,7 @@ export const Tooltip = forwardRef<HTMLButtonElement, TooltipProps>(
205
206
  {children}
206
207
  </TooltipPrimitive.Trigger>
207
208
  <TooltipPrimitive.Portal container={container}>
208
- <ThemeProvider portal>
209
+ <RadixPortalThemeProvider>
209
210
  <TooltipPrimitive.Content
210
211
  ref={setContentElement}
211
212
  side={side}
@@ -216,7 +217,7 @@ export const Tooltip = forwardRef<HTMLButtonElement, TooltipProps>(
216
217
  >
217
218
  {content}
218
219
  </TooltipPrimitive.Content>
219
- </ThemeProvider>
220
+ </RadixPortalThemeProvider>
220
221
  </TooltipPrimitive.Portal>
221
222
  </TooltipPrimitive.Root>
222
223
  );
@@ -1,6 +1,6 @@
1
1
  import {css} from "@linaria/core";
2
2
  import cx from "classnames";
3
- import _ from "lodash";
3
+ import isString from "lodash/isString";
4
4
  import {CSSProperties, forwardRef, memo, ReactNode} from "react";
5
5
  import {a11yColor} from "./a11y-color";
6
6
  import {
@@ -8,7 +8,6 @@ import {
8
8
  fontWeight,
9
9
  getDarkenColor,
10
10
  getTextColor,
11
- getThemeValue,
12
11
  opacity,
13
12
  space,
14
13
  textStyles,
@@ -180,7 +179,7 @@ export const TypeBadge = memo(
180
179
  ) {
181
180
  const TagName = onClick ? "button" : "div";
182
181
  const title =
183
- _.isString(children) && abbr ? (
182
+ isString(children) && abbr ? (
184
183
  noTooltip ? (
185
184
  makeAbbreviation(children)
186
185
  ) : (
@@ -196,13 +195,9 @@ export const TypeBadge = memo(
196
195
 
197
196
  const baseColor = color || theme.iconColor;
198
197
 
199
- const textBadgeColor = getThemeValue(theme.mode, {
200
- dark: a11yColor(getTextColor(baseColor), getDarkenColor(baseColor), 12),
201
- light: a11yColor(getTextColor(baseColor), getDarkenColor(baseColor), 12),
202
- light2: a11yColor(getTextColor(baseColor), getDarkenColor(baseColor), 12),
203
- });
198
+ const textBadgeColor = a11yColor(getTextColor(baseColor), getDarkenColor(baseColor), 12);
204
199
 
205
- const backgroundBadgeColor = getThemeValue(theme.mode, {
200
+ const backgroundBadgeColor = theme.select({
206
201
  dark: getDarkenColor(baseColor),
207
202
  light: baseColor,
208
203
  light2: baseColor,
@@ -211,9 +206,7 @@ export const TypeBadge = memo(
211
206
  const resultingStyle = {
212
207
  ...style,
213
208
  [colorProp]: baseColor ? textBadgeColor : themeVars.inversedTextColor,
214
- //[colorProp]: baseColor ? getTextColor(baseColor) : colors.inversedTextColor,
215
209
  [colorBackgroundProp]: backgroundBadgeColor || themeVars.shades.opacity25,
216
- //[colorBackgroundProp]: baseColor || colors.shades.opacity25,
217
210
  [colorBorderProp]: backgroundBadgeColor,
218
211
  [colorDarkProp]: getDarkenColor(baseColor),
219
212
  } as CSSProperties;
@@ -62,7 +62,6 @@ export const unitWithTitleClassName = css`
62
62
  `;
63
63
 
64
64
  export const invalidUnitClassName = css``;
65
- export const invalidUnitClassNameInForm = css``;
66
65
 
67
66
  export const clickableClassName = css`
68
67
  cursor: pointer;
@@ -97,14 +96,6 @@ export const borderClassName = css`
97
96
  }
98
97
 
99
98
  &.${invalidUnitClassName} {
100
- padding-left: 20px;
101
- &:has(button) {
102
- padding-left: 0;
103
- }
104
- & button {
105
- padding-left: 20px;
106
- }
107
-
108
99
  &::before {
109
100
  box-shadow: none;
110
101
  border: 1px solid ${themeVars.colorBorderButtonOutlineAccentDefault};
@@ -119,20 +110,6 @@ export const borderClassName = css`
119
110
  box-shadow: ${themeVars.inputBorderFocusColor} inset;
120
111
  border: none;
121
112
  }
122
- &::after {
123
- content: "";
124
- position: absolute;
125
- top: 0;
126
- width: 20px;
127
- left: 4px;
128
- right: 0;
129
- bottom: 0;
130
- background-image: url("./required-indicator.svg");
131
- background-repeat: no-repeat;
132
- background-size: 16px 16px;
133
- background-position: center;
134
- pointer-events: none;
135
- }
136
113
  }
137
114
  `;
138
115
 
@@ -20,8 +20,13 @@ function isVerticalMobileBreakpointDisabled() {
20
20
  ) {
21
21
  return true;
22
22
  }
23
- const urlParams = new URLSearchParams(window.location.search);
24
- return urlParams.has("no-vertical-mobile-breakpoint");
23
+
24
+ if (globalThis.URLSearchParams) {
25
+ const urlParams = new URLSearchParams(window.location.search);
26
+ return urlParams.has("no-vertical-mobile-breakpoint");
27
+ } else {
28
+ return false;
29
+ }
25
30
  }
26
31
 
27
32
  export const isPhoneApp = () =>
@@ -1,6 +1,6 @@
1
1
  import {ReactNode, useEffect, useState} from "react";
2
2
  import {createContext} from "@fibery/react/src/create-context";
3
- import _ from "lodash";
3
+ import noop from "lodash/noop";
4
4
  import {isPhoneApp} from "./use-is-phone";
5
5
  import {keyboardHeightVar, mobileKeyboardOpenClassName} from "./mobile-styles";
6
6
 
@@ -23,7 +23,7 @@ export function OnScreenKeyboardContextProvider({children}: {children: ReactNode
23
23
  useEffect(() => {
24
24
  const viewport = window.visualViewport;
25
25
  if (!viewport || !isPhoneApp()) {
26
- return _.noop;
26
+ return noop;
27
27
  }
28
28
 
29
29
  function viewportHandler() {
package/src/with-data.tsx CHANGED
@@ -1,4 +1,5 @@
1
- import _ from "lodash";
1
+ import mapValues from "lodash/mapValues";
2
+ import noop from "lodash/noop";
2
3
  import {PureComponent, ComponentType} from "react";
3
4
  import {asError} from "./errors";
4
5
  import {$TSFixMe} from "./tsfixme";
@@ -25,7 +26,7 @@ type ProvidedState = Record<string, FetchState>;
25
26
  export function provideData<T>({sources}: {sources: Record<string, () => Promise<$TSFixMe>>}) {
26
27
  return (Component: ComponentType<T & ProvidedState>) =>
27
28
  class DataProvider extends PureComponent<T, ProvidedState> {
28
- state = _.mapValues(
29
+ state = mapValues(
29
30
  sources,
30
31
  (): FetchState => ({
31
32
  fetchState: ":fetch-state/start",
@@ -66,7 +67,7 @@ export function provideData<T>({sources}: {sources: Record<string, () => Promise
66
67
  }
67
68
 
68
69
  componentWillUnmount() {
69
- this.setStateIfMounted = _.noop;
70
+ this.setStateIfMounted = noop;
70
71
  }
71
72
 
72
73
  render() {
@@ -1,6 +1,6 @@
1
1
  import {css} from "@linaria/core";
2
2
  import {arc} from "d3-shape";
3
- import _ from "lodash";
3
+ import memoize from "lodash/memoize";
4
4
  import {FC} from "react";
5
5
  import {themeVars} from "./design-system";
6
6
 
@@ -52,7 +52,7 @@ export const WorkflowProgressIcon: FC<WorkflowProgressIcon> = ({
52
52
  );
53
53
  };
54
54
 
55
- const getPath = _.memoize(
55
+ const getPath = memoize(
56
56
  (index, total, size) => {
57
57
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
58
58
  // @ts-ignore bad d3-shape typings
package/.eslintignore DELETED
@@ -1,3 +0,0 @@
1
- *.d.ts
2
- src/icons/react
3
- src/icons/ast
package/.eslintrc DELETED
@@ -1,14 +0,0 @@
1
- {
2
- "extends": "@fibery/eslint-config",
3
- "rules": {
4
- "no-restricted-imports": ["error", {"patterns": ["@fibery/ui-kit/*"]}]
5
- },
6
- "overrides": [
7
- {
8
- "files": ["src/icons/*"],
9
- "rules": {
10
- "unicorn/filename-case": "off"
11
- }
12
- }
13
- ]
14
- }
@@ -1,3 +0,0 @@
1
- export function createInlineTheme() {
2
- return {};
3
- }