@fibery/ui-kit 1.40.3 → 1.40.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 (82) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/package.json +4 -7
  3. package/src/__snapshots__/design-system.test.ts.snap +7265 -0
  4. package/src/a11y-color.test.ts +181 -0
  5. package/src/a11y-color.ts +13 -20
  6. package/src/actions-menu/actions-menu-item.tsx +7 -7
  7. package/src/antd/ant-modal.tsx +10 -5
  8. package/src/antd/styles.ts +6 -6
  9. package/src/app-icon-with-fallback.tsx +2 -2
  10. package/src/app-icon.tsx +2 -2
  11. package/src/button/button.tsx +1 -0
  12. package/src/button/make-button-colors.ts +5 -13
  13. package/src/checkbox.tsx +2 -2
  14. package/src/color-picker/ColorPickerOrLoader.js +2 -2
  15. package/src/color-utils.test.ts +317 -0
  16. package/src/color-utils.ts +180 -0
  17. package/src/comment.tsx +3 -2
  18. package/src/context-menu/index.tsx +12 -7
  19. package/src/create-inline-theme.ts +9 -8
  20. package/src/design-system.colors.ts +760 -0
  21. package/src/design-system.test.ts +287 -7
  22. package/src/design-system.ts +146 -940
  23. package/src/dropdown-menu/index.tsx +21 -16
  24. package/src/emoji-picker/app-icon-picker.tsx +5 -5
  25. package/src/emoji-picker/emoji-picker-content-with-color.tsx +4 -4
  26. package/src/emoji-picker/icon-emoji-picker.tsx +2 -2
  27. package/src/favorites-icon.tsx +1 -1
  28. package/src/file-item/file-icon.tsx +169 -0
  29. package/src/file-item/file-menu-items.tsx +68 -0
  30. package/src/file-item/file-preview-actions.tsx +38 -0
  31. package/src/file-item/file-title.tsx +48 -0
  32. package/src/file-item/types.ts +27 -0
  33. package/src/file-item/use-register-in-image-gallery.tsx +70 -0
  34. package/src/file-item-2.tsx +35 -345
  35. package/src/file-item.tsx +6 -2
  36. package/src/hue-shift.test.ts +91 -0
  37. package/src/icons/ast/FileCounter.ts +8 -0
  38. package/src/icons/ast/FileMultiple.ts +8 -0
  39. package/src/icons/ast/ValueEdit.ts +8 -0
  40. package/src/icons/ast/index.tsx +3 -0
  41. package/src/icons/react/FileCounter.tsx +13 -0
  42. package/src/icons/react/FileMultiple.tsx +13 -0
  43. package/src/icons/react/ValueEdit.tsx +13 -0
  44. package/src/icons/react/index.tsx +3 -0
  45. package/src/icons/svg/file-counter.svg +3 -0
  46. package/src/icons/svg/file-multiple.svg +3 -0
  47. package/src/icons/svg/value-edit.svg +3 -0
  48. package/src/images-gallery/slide-buttons.tsx +4 -11
  49. package/src/lists/actions-menu-row-surface.tsx +5 -5
  50. package/src/mobile-keyboard-aware-popup.tsx +4 -3
  51. package/src/palette-generator.test.ts +566 -0
  52. package/src/palette-generator.ts +166 -0
  53. package/src/palette.ts +71 -55
  54. package/src/platform.ts +0 -3
  55. package/src/popover/index.tsx +13 -15
  56. package/src/progress.tsx +2 -2
  57. package/src/reactions/reaction-button.tsx +12 -6
  58. package/src/root-theme-provider.test.tsx +316 -0
  59. package/src/scale-generator.ts +347 -0
  60. package/src/select/components/menu-list-virtualized.tsx +7 -22
  61. package/src/select/components/menu.tsx +12 -2
  62. package/src/select/select.tsx +2 -1
  63. package/src/select/styles.ts +0 -1
  64. package/src/static-palettes.ts +146 -0
  65. package/src/thematic-color-picker.tsx +266 -0
  66. package/src/thematic-constants.tsx +27 -0
  67. package/src/thematic-controls.tsx +144 -0
  68. package/src/thematic-scales.tsx +122 -0
  69. package/src/thematic-state.ts +333 -0
  70. package/src/thematic.tsx +382 -0
  71. package/src/theme-provider.test.tsx +808 -0
  72. package/src/theme-provider.tsx +132 -69
  73. package/src/theme-settings.ts +1 -1
  74. package/src/theme-styles.ts +12 -5
  75. package/src/toast/toast-action.tsx +1 -1
  76. package/src/toggle-on-off.tsx +2 -2
  77. package/src/toggle.tsx +5 -6
  78. package/src/tooltip.tsx +13 -10
  79. package/src/type-badge.tsx +3 -3
  80. package/src/unit/styles.ts +2 -2
  81. package/src/unit/unit-with-tooltip.tsx +3 -2
  82. package/src/use-long-press.tsx +2 -2
@@ -1,4 +1,6 @@
1
- import {getLightColors, getDarkColors, getLight2Colors} from "./design-system";
1
+ import * as ds from "./design-system";
2
+ import {makeThemeDefs, pickDarkColors, pickLight2Colors, pickLightColors} from "./design-system.colors";
3
+ import {makeDefaultPalette} from "./palette-generator";
2
4
 
3
5
  function getKeys(colors: Record<string, string | Record<string, string>>) {
4
6
  const keys = [];
@@ -15,10 +17,288 @@ function getKeys(colors: Record<string, string | Record<string, string>>) {
15
17
  }
16
18
  return keys.sort();
17
19
  }
18
- it("dark and light color should have the same keys", () => {
19
- const lKeys = getKeys(getLightColors());
20
- const dKeys = getKeys(getDarkColors());
21
- const l2Keys = getKeys(getLight2Colors());
22
- expect(lKeys).toEqual(dKeys);
23
- expect(l2Keys).toEqual(dKeys);
20
+
21
+ const {
22
+ themeVars,
23
+ createInlineTheme,
24
+ getDarkenColor,
25
+ getEnumTextColor,
26
+ getLinearGradient,
27
+ getObjectColorMemoized,
28
+ getOpacities,
29
+ getTextColor,
30
+ getThemeColors,
31
+ getThemeValue,
32
+ ...rest
33
+ } = ds;
34
+
35
+ test("getThemeColors memoization", () => {
36
+ const modes = ["light", "dark", "light2"] as const;
37
+ const themes = modes.map((mode) => getThemeColors(null, mode));
38
+
39
+ // same input → same reference
40
+ modes.forEach((mode, i) => {
41
+ expect(getThemeColors("_", mode)).toBe(themes[i]);
42
+ });
43
+
44
+ // different modes → different references
45
+ expect(new Set(themes)).toMatchObject({size: modes.length});
46
+
47
+ // different modes → same keys
48
+ expect(new Set(themes.map(({fns: _, key: _k, ...colors}) => getKeys(colors).join(",")))).toMatchObject({size: 1});
49
+ });
50
+
51
+ test("snapshot rest", () => {
52
+ expect(rest).toMatchSnapshot();
53
+ });
54
+
55
+ test("snapshot themeColors", () => {
56
+ const {colors, ...rest} = makeThemeDefs(makeDefaultPalette());
57
+ expect({...colors, ...rest}).toMatchSnapshot();
58
+ });
59
+
60
+ test("snapshot themeVars", () => {
61
+ expect(themeVars).toMatchSnapshot();
62
+ });
63
+
64
+ const testColors = [
65
+ "#FF5400", // brand red
66
+ "#4978D4", // brand blue
67
+ "#08BD9F", // brand green
68
+ "#000000", // black
69
+ "#FFFFFF", // white
70
+ "rgb(73, 120, 212)", // rgb format
71
+ "hsl(220, 62%, 56%)", // hsl format
72
+ ];
73
+
74
+ const testColorsForThemed = [
75
+ "#FF5400", // red
76
+ "#4978D4", // blue
77
+ "#08BD9F", // green
78
+ "#FBA32F", // yellow/orange
79
+ "#673DB6", // purple
80
+ "#000000", // black
81
+ "#FFFFFF", // white
82
+ ];
83
+
84
+ describe("getOpacities", () => {
85
+ test.each(testColors)("snapshot for %s", (color) => {
86
+ expect(getOpacities(color)).toMatchSnapshot();
87
+ });
88
+
89
+ test("transparent color", () => {
90
+ expect(getOpacities("rgba(255, 255, 255, 0)")).toMatchSnapshot();
91
+ });
92
+ });
93
+
94
+ describe("getDarkenColor", () => {
95
+ test.each(testColors)("snapshot for %s", (color) => {
96
+ expect(getDarkenColor(color)).toMatchSnapshot();
97
+ });
98
+ });
99
+
100
+ describe("getTextColor", () => {
101
+ test.each(testColors)("snapshot for %s", (color) => {
102
+ expect(getTextColor(color)).toMatchSnapshot();
103
+ });
104
+ });
105
+
106
+ describe("getLinearGradient", () => {
107
+ test("single color", () => {
108
+ expect(getLinearGradient(["#FF5400"])).toMatchSnapshot();
109
+ });
110
+
111
+ test("two colors", () => {
112
+ expect(getLinearGradient(["#FF5400", "#4978D4"])).toMatchSnapshot();
113
+ });
114
+
115
+ test("three colors", () => {
116
+ expect(getLinearGradient(["#FF5400", "#4978D4", "#08BD9F"])).toMatchSnapshot();
117
+ });
118
+
119
+ test("four colors", () => {
120
+ expect(getLinearGradient(["#FF5400", "#4978D4", "#08BD9F", "#FFFFFF"])).toMatchSnapshot();
121
+ });
122
+
123
+ test("card type colors subset", () => {
124
+ expect(getLinearGradient(["#4A4A4A", "#6A849B", "#99A2AB", "#D40915", "#E72065"])).toMatchSnapshot();
125
+ });
126
+ });
127
+
128
+ describe("getThemeColors", () => {
129
+ test("light theme", () => {
130
+ expect(getThemeColors("#4978D4", "light")).toMatchSnapshot();
131
+ });
132
+
133
+ test("dark theme", () => {
134
+ expect(getThemeColors("#4978D4", "dark")).toMatchSnapshot();
135
+ });
136
+
137
+ test("light2 theme", () => {
138
+ expect(getThemeColors("#4978D4", "light2")).toMatchSnapshot();
139
+ });
140
+ });
141
+
142
+ describe("getThemeValue", () => {
143
+ const values = {light: "light-value", light2: "light2-value", dark: "dark-value"};
144
+
145
+ test("light theme", () => {
146
+ expect(getThemeValue("light", values)).toMatchSnapshot();
147
+ });
148
+
149
+ test("dark theme", () => {
150
+ expect(getThemeValue("dark", values)).toMatchSnapshot();
151
+ });
152
+
153
+ test("light2 theme", () => {
154
+ expect(getThemeValue("light2", values)).toMatchSnapshot();
155
+ });
156
+
157
+ test("fallback to light when key missing", () => {
158
+ expect(getThemeValue("light", {light: "fallback", dark: "dark"})).toMatchSnapshot();
159
+ });
160
+ });
161
+
162
+ describe("getLightColors", () => {
163
+ test("snapshot", () => {
164
+ expect(pickLightColors(makeThemeDefs(makeDefaultPalette()))).toMatchSnapshot();
165
+ });
166
+ });
167
+
168
+ describe("getDarkColors", () => {
169
+ test("snapshot", () => {
170
+ expect(pickDarkColors(makeThemeDefs(makeDefaultPalette()))).toMatchSnapshot();
171
+ });
172
+ });
173
+
174
+ describe("getLight2Colors", () => {
175
+ test("snapshot", () => {
176
+ expect(pickLight2Colors(makeThemeDefs(makeDefaultPalette()))).toMatchSnapshot();
177
+ });
178
+ });
179
+
180
+ const themes = {
181
+ light: getThemeColors(null, "light"),
182
+ dark: getThemeColors(null, "dark"),
183
+ light2: getThemeColors(null, "light2"),
184
+ };
185
+
186
+ describe("getEnumBackgroundColor", () => {
187
+ describe.each(["light", "dark", "light2"] as const)("%s theme", (mode) => {
188
+ test.each(testColorsForThemed)("snapshot for %s", (color) => {
189
+ expect(themes[mode].fns.getEnumBackground(color)).toMatchSnapshot();
190
+ });
191
+ });
192
+ });
193
+
194
+ describe("getIconColor", () => {
195
+ describe.each(["light", "dark"] as const)("%s theme", (mode) => {
196
+ test.each(testColorsForThemed)("snapshot for %s", (color) => {
197
+ expect(themes[mode].fns.getIconColor(color)).toMatchSnapshot();
198
+ });
199
+ });
200
+ });
201
+
202
+ describe("getAppIconBackgroundColor", () => {
203
+ describe.each(["light", "dark", "light2"] as const)("%s theme", (mode) => {
204
+ test.each(testColorsForThemed)("snapshot for %s", (color) => {
205
+ expect(themes[mode].fns.getAppIconBackground(color)).toMatchSnapshot();
206
+ });
207
+ });
208
+ });
209
+
210
+ describe("getLinkedHighlightBackgroundColor", () => {
211
+ const highlightColors = ["#FF5400", "#4978D4", "#08BD9F", "#FBA32F", "#673DB6"];
212
+
213
+ describe.each(["light", "dark"] as const)("%s theme", (mode) => {
214
+ test.each(highlightColors)("snapshot for %s", (color) => {
215
+ expect(themes[mode].fns.getLinkedHighlightBackground(color)).toMatchSnapshot();
216
+ });
217
+ });
218
+ });
219
+
220
+ describe("getLinkedHighlightDecorationBackgroundColor", () => {
221
+ const highlightColors = ["#FF5400", "#4978D4", "#08BD9F", "#FBA32F", "#673DB6"];
222
+
223
+ describe.each(["light", "dark"] as const)("%s theme", (mode) => {
224
+ test.each(highlightColors)("snapshot for %s", (color) => {
225
+ expect(themes[mode].fns.getLinkedHighlightDecorationBackground(color)).toMatchSnapshot();
226
+ });
227
+ });
228
+ });
229
+
230
+ describe("getEnumTextColor", () => {
231
+ test.each(testColorsForThemed)("snapshot for %s", (color) => {
232
+ expect(getEnumTextColor(color)).toMatchSnapshot();
233
+ });
234
+ });
235
+
236
+ describe("getObjectColorMemoized", () => {
237
+ test("empty name returns default", () => {
238
+ expect(getObjectColorMemoized("")).toMatchSnapshot();
239
+ });
240
+
241
+ test("null/undefined returns default", () => {
242
+ expect(getObjectColorMemoized(null)).toMatchSnapshot();
243
+ expect(getObjectColorMemoized(undefined)).toMatchSnapshot();
244
+ });
245
+
246
+ test("typical entity names", () => {
247
+ expect(getObjectColorMemoized("Task")).toMatchSnapshot();
248
+ expect(getObjectColorMemoized("Feature")).toMatchSnapshot();
249
+ expect(getObjectColorMemoized("Bug")).toMatchSnapshot();
250
+ expect(getObjectColorMemoized("User Story")).toMatchSnapshot();
251
+ expect(getObjectColorMemoized("Epic")).toMatchSnapshot();
252
+ });
253
+
254
+ test("database names", () => {
255
+ expect(getObjectColorMemoized("Product Management")).toMatchSnapshot();
256
+ expect(getObjectColorMemoized("Engineering")).toMatchSnapshot();
257
+ expect(getObjectColorMemoized("Design")).toMatchSnapshot();
258
+ });
259
+
260
+ test("special characters", () => {
261
+ expect(getObjectColorMemoized("Task #1")).toMatchSnapshot();
262
+ expect(getObjectColorMemoized("Feature (v2)")).toMatchSnapshot();
263
+ expect(getObjectColorMemoized("Bug-123")).toMatchSnapshot();
264
+ });
265
+
266
+ test("long names", () => {
267
+ expect(
268
+ getObjectColorMemoized("This is a very long entity name that might be used in some cases")
269
+ ).toMatchSnapshot();
270
+ });
271
+
272
+ test("unicode names", () => {
273
+ expect(getObjectColorMemoized("Задача")).toMatchSnapshot();
274
+ expect(getObjectColorMemoized("機能")).toMatchSnapshot();
275
+ expect(getObjectColorMemoized("🚀 Feature")).toMatchSnapshot();
276
+ });
277
+ });
278
+
279
+ describe("createInlineTheme", () => {
280
+ test("light theme with default reject keys", () => {
281
+ const theme = getThemeColors("#4978D4", "light");
282
+ expect(createInlineTheme(theme)).toMatchSnapshot();
283
+ });
284
+
285
+ test("dark theme with default reject keys", () => {
286
+ const theme = getThemeColors("#4978D4", "dark");
287
+ expect(createInlineTheme(theme)).toMatchSnapshot();
288
+ });
289
+
290
+ test("light2 theme with default reject keys", () => {
291
+ const theme = getThemeColors("#4978D4", "light2");
292
+ expect(createInlineTheme(theme)).toMatchSnapshot();
293
+ });
294
+
295
+ test("with custom reject keys (empty array - include all)", () => {
296
+ const theme = getThemeColors("#4978D4", "light");
297
+ expect(createInlineTheme(theme, [])).toMatchSnapshot();
298
+ });
299
+
300
+ test("with custom reject keys (specific keys)", () => {
301
+ const theme = getThemeColors("#4978D4", "light");
302
+ expect(createInlineTheme(theme, ["primary", "darkenPrimary"])).toMatchSnapshot();
303
+ });
24
304
  });