@fibery/ui-kit 2.1.0 → 2.1.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 (61) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/package.json +6 -3
  3. package/src/@types/react-color.d.ts +36 -0
  4. package/src/antd/{Tabs.js → Tabs.tsx} +5 -2
  5. package/src/color-filter.test.ts +24 -65
  6. package/src/color-filter.ts +62 -93
  7. package/src/color-picker/{ColorPickerOrLoader.js → ColorPickerOrLoader.tsx} +1 -1
  8. package/src/color-picker/{index.js → index.tsx} +32 -6
  9. package/src/color-utils.ts +3 -9
  10. package/src/design-system/colors-css.ts +16 -0
  11. package/src/design-system/colors.ts +23 -45
  12. package/src/design-system/def.ts +17 -0
  13. package/src/design-system/theme.ts +6 -2
  14. package/src/design-system/types.ts +102 -0
  15. package/src/design-system/vars.test.ts +9 -2
  16. package/src/design-system/vars.ts +4 -2
  17. package/src/design-system.ts +9 -1
  18. package/src/emoji-picker/emoji-picker-content-with-color.tsx +3 -3
  19. package/src/heat.ts +8 -0
  20. package/src/highlight-colors.test.ts +68 -0
  21. package/src/highlight-colors.ts +91 -0
  22. package/src/link-input/components/{AntTextAreaWithCustomReadState.js → AntTextAreaWithCustomReadState.tsx} +19 -8
  23. package/src/link-input/index.tsx +94 -0
  24. package/src/link-input/{utils.js → utils.ts} +1 -6
  25. package/src/number-input/decimal.ts +50 -0
  26. package/src/number-input/utils.ts +2 -2
  27. package/src/palette-generator.test.ts +2 -1
  28. package/src/palette-generator.ts +8 -26
  29. package/src/palettes/_.ts +2 -2
  30. package/src/palettes/common.ts +31 -0
  31. package/src/palettes/diff-colors.ts +29 -12
  32. package/src/palettes/inspect.defs.colors.neutral-arch.test.ts +72 -36
  33. package/src/palettes/inspect.defs.colors.neutral-user.test.ts +72 -36
  34. package/src/palettes/inspect.defs.colors.warm-arch.test.ts +226 -190
  35. package/src/palettes/inspect.defs.colors.warm-user.test.ts +226 -190
  36. package/src/palettes/neutral-arch.ts +3 -3
  37. package/src/palettes/neutral-user.ts +3 -3
  38. package/src/palettes/neutral.ts +4 -2
  39. package/src/palettes/warm-arch.ts +3 -3
  40. package/src/palettes/warm-user.ts +3 -3
  41. package/src/palettes/warm.ts +4 -3
  42. package/src/pretty-size.ts +5 -2
  43. package/src/root-theme-provider.test.tsx +1 -1
  44. package/src/scale-generator.ts +1 -32
  45. package/src/select/components/menu-list-virtua.tsx +127 -0
  46. package/src/select/index.tsx +1 -1
  47. package/src/select/reflection.ts +22 -0
  48. package/src/select/select.tsx +1 -0
  49. package/src/static-palettes.ts +2 -1
  50. package/src/thematic-color-picker.tsx +8 -1
  51. package/src/thematic-constants.tsx +2 -0
  52. package/src/thematic-controls.tsx +9 -1
  53. package/src/thematic-cvd.tsx +73 -0
  54. package/src/thematic-highlights.tsx +49 -0
  55. package/src/thematic-scales.tsx +8 -6
  56. package/src/thematic-state.ts +37 -16
  57. package/src/thematic.tsx +298 -305
  58. package/src/theme-provider.tsx +9 -3
  59. package/src/theme-styles.ts +2 -1
  60. package/src/link-input/index.js +0 -89
  61. package/src/number-input/decimal.js +0 -61
@@ -1,14 +1,12 @@
1
1
  import {useCallback, useEffect, useMemo, useState} from "react";
2
2
  import {useThematic, useThemeMode} from "./theme-provider";
3
3
  import {
4
- type ColorScale,
5
4
  DEFAULT_DARK_CURVES,
6
5
  DEFAULT_LIGHT_CURVES,
7
6
  generateColorScale,
8
7
  makeThematicPalette,
9
8
  type ScaleCurves,
10
9
  type ThematicPrefs,
11
- type ThemePalette,
12
10
  } from "./palette-generator";
13
11
  import {getThemePreference, setThemePreference, type ThemePreference} from "./theme-settings";
14
12
  import {type ColorFilterSpec} from "./color-filter";
@@ -16,8 +14,12 @@ import {oklchFrom} from "./color-utils";
16
14
  import {StaticPalettes} from "./static-palettes";
17
15
  import {defaultPrefs, nextThemePref} from "./thematic-constants";
18
16
  import {useToast} from "./toast/toast-provider";
17
+ import type {HighlightDefs, ModeDef, ThemePalette} from "./design-system/types";
18
+ import {common} from "./palettes/common";
19
19
 
20
- type PaletteScaleKey = Exclude<keyof ThemePalette, "key" | "deneutralize">;
20
+ export type PaletteScaleKey = Exclude<keyof ThemePalette, "key" | "deneutralize" | "highlight">;
21
+
22
+ const highlight = common.highlight;
21
23
 
22
24
  interface StoredState {
23
25
  prefs: ThematicPrefs | null;
@@ -177,9 +179,11 @@ export function useThematicState() {
177
179
  }
178
180
  if (customPalette) {
179
181
  const customKey = Object.entries(customPalette)
180
- .map(([k, v]) => `${k}:${Array.isArray(v) ? v.join(",") : JSON.stringify(v)}`)
182
+ .map(([k, v]) => `${k}:${JSON.stringify(v)}`)
181
183
  .join("|");
182
- result = {...result, key: `${result.key}-custom-${customKey}`};
184
+ const idx = result.key.indexOf("-custom-");
185
+ const stableKey = idx >= 0 ? result.key.slice(0, idx) : result.key;
186
+ result = {...result, key: `${stableKey}-custom-${customKey}`};
183
187
  }
184
188
  return result;
185
189
  }, [
@@ -219,14 +223,30 @@ export function useThematicState() {
219
223
  };
220
224
 
221
225
  const updateFilter = (partial: Partial<ColorFilterSpec>) => {
226
+ const sideIdx = editingDark ? 1 : 0;
222
227
  if (prefs) {
223
- const current = prefsPresent.filter ?? {};
228
+ const current = prefsPresent.filter ?? [{}, {}];
229
+ const updated: ModeDef<Partial<ColorFilterSpec>> = [...current];
230
+ updated[sideIdx] = {...updated[sideIdx], ...partial};
224
231
  setPrefs({
225
232
  ...prefsPresent,
226
- filter: {...current, ...partial},
233
+ filter: updated,
234
+ });
235
+ } else {
236
+ setCustomPalette((prev) => {
237
+ const current = palette.deneutralize ?? [{}, {}];
238
+ const updated: ModeDef<ColorFilterSpec> = [...current];
239
+ updated[sideIdx] = {...updated[sideIdx], ...partial};
240
+ return {...prev, deneutralize: updated};
227
241
  });
242
+ }
243
+ };
244
+
245
+ const updateHighlight = (highlight: HighlightDefs) => {
246
+ if (prefs) {
247
+ setPrefs({...prefsPresent, highlight});
228
248
  } else {
229
- setCustomPalette((prev) => ({...prev, deneutralize: {...palette.deneutralize, ...partial}}));
249
+ setCustomPalette((prev) => ({...prev, highlight}));
230
250
  }
231
251
  };
232
252
 
@@ -237,6 +257,7 @@ export function useThematicState() {
237
257
  baseChroma: Math.random() * 0.1,
238
258
  accentHue: Math.random() * 360,
239
259
  accentChroma: 0.08 + Math.random() * 0.12,
260
+ highlight,
240
261
  });
241
262
  };
242
263
 
@@ -268,15 +289,10 @@ export function useThematicState() {
268
289
  };
269
290
 
270
291
  const updateScaleColor = useCallback(
271
- (scaleName: PaletteScaleKey, index: number, color: string) => {
292
+ (key: PaletteScaleKey, index: number, color: string) => {
272
293
  setCustomPalette((prev) => {
273
- const currentValue = prev?.[scaleName] ?? palette[scaleName];
274
- if (typeof currentValue === "string") {
275
- return {...prev, [scaleName]: color};
276
- }
277
- const mutableScale = [...currentValue] as unknown as string[];
278
- mutableScale[index] = color;
279
- return {...prev, [scaleName]: mutableScale as unknown as ColorScale};
294
+ const colorOrScale = prev?.[key] ?? palette[key];
295
+ return {...prev, [key]: typeof colorOrScale === "string" ? color : colorOrScale.with(index, color)};
280
296
  });
281
297
  },
282
298
  [palette]
@@ -297,6 +313,8 @@ export function useThematicState() {
297
313
  }, [prefs, staticPaletteIndex, customPalette]);
298
314
 
299
315
  const editingDark = !isLightMode;
316
+ const dnSide = editingDark ? 1 : 0;
317
+ const deneutralizeSpec = palette.deneutralize?.[dnSide];
300
318
  const baseCurves = editingDark ? baseCurvesDark : baseCurvesLight;
301
319
  const setBaseCurves = editingDark ? setBaseCurvesDark : setBaseCurvesLight;
302
320
  const accentCurves = editingDark ? accentCurvesDark : accentCurvesLight;
@@ -352,6 +370,8 @@ export function useThematicState() {
352
370
 
353
371
  return {
354
372
  palette,
373
+ deneutralizeSpec,
374
+ dnSide,
355
375
  hoveredInfo,
356
376
  isAltPressed,
357
377
  pinned,
@@ -374,6 +394,7 @@ export function useThematicState() {
374
394
  update,
375
395
  updateHueShift,
376
396
  updateFilter,
397
+ updateHighlight,
377
398
  randomize,
378
399
  cycleStaticPalettes,
379
400
  cycleTheme,