@fibery/ui-kit 13.0.0 → 14.0.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 (73) hide show
  1. package/lib/actions-menu/actions-menu-item.js +4 -3
  2. package/lib/actions-menu/actions-menu.js +2 -2
  3. package/lib/actions-menu/context-actions-menu.js +2 -2
  4. package/lib/banner/banner.wyw-in-js.css +2 -2
  5. package/lib/button/button.js +2 -1
  6. package/lib/color-picker/color-picker-or-loader.d.ts +5 -0
  7. package/lib/color-picker/color-picker-or-loader.js +18 -5
  8. package/lib/color-picker/color-picker-or-loader.wyw-in-js.css +1 -1
  9. package/lib/color-picker/index.js +5 -5
  10. package/lib/color-picker/index.wyw-in-js.css +4 -5
  11. package/lib/color-picker/swatch-grid.d.ts +11 -0
  12. package/lib/color-picker/swatch-grid.js +14 -0
  13. package/lib/color-picker/swatch-grid.wyw-in-js.css +1 -0
  14. package/lib/color-picker/swatch.js +2 -9
  15. package/lib/command-menu/index.js +1 -1
  16. package/lib/command-menu/nested-command-menu.js +1 -1
  17. package/lib/date-picker/contexts.d.ts +2 -0
  18. package/lib/date-picker/contexts.js +2 -1
  19. package/lib/date-picker/date-range-picker-popup-content.js +12 -8
  20. package/lib/date-picker/date-range-picker.js +3 -2
  21. package/lib/date-picker/day-with-start-end-buttons.js +13 -18
  22. package/lib/date-picker/single-date-picker-popup-content.js +1 -1
  23. package/lib/date-picker/single-date-picker.js +3 -2
  24. package/lib/emoji-picker/utils/store.js +3 -2
  25. package/lib/empty-state/empty-state.wyw-in-js.css +2 -2
  26. package/lib/file-item/file-item-preview.d.ts +7 -0
  27. package/lib/file-item/file-item-preview.js +31 -0
  28. package/lib/file-item/file-item-preview.wyw-in-js.css +4 -0
  29. package/lib/form-field-loader.d.ts +5 -6
  30. package/lib/form-field-loader.js +7 -10
  31. package/lib/form-field-loader.wyw-in-js.css +2 -1
  32. package/lib/lists/list-row-surface.wyw-in-js.css +1 -1
  33. package/lib/open-popover-tracker.d.ts +2 -4
  34. package/lib/open-popover-tracker.js +14 -22
  35. package/lib/popover/index.js +3 -3
  36. package/lib/preference-setting.d.ts +2 -1
  37. package/lib/preference-setting.js +4 -4
  38. package/lib/rich-text-skeleton.d.ts +9 -0
  39. package/lib/rich-text-skeleton.js +32 -0
  40. package/lib/rich-text-skeleton.wyw-in-js.css +2 -0
  41. package/lib/select/components/menu-list-virtua.js +2 -1
  42. package/lib/select/components/menu-list-virtualized.js +19 -12
  43. package/lib/select/components/menu.d.ts +1 -4
  44. package/lib/select/components/menu.js +2 -9
  45. package/lib/select/components/option.js +5 -2
  46. package/lib/select/select-loader.js +5 -2
  47. package/lib/select/select.d.ts +1 -1
  48. package/lib/select/select.js +3 -3
  49. package/lib/select/styles.js +4 -3
  50. package/lib/select/util.d.ts +2 -0
  51. package/lib/select/util.js +3 -1
  52. package/lib/storage-keys.d.ts +12 -0
  53. package/lib/storage-keys.js +20 -0
  54. package/lib/storage.d.ts +9 -0
  55. package/lib/storage.js +5 -0
  56. package/lib/tab-nav/tab-nav.js +1 -1
  57. package/lib/text.d.ts +5 -0
  58. package/lib/text.js +5 -0
  59. package/lib/thematic-cvd.js +2 -2
  60. package/lib/thematic-state.js +1 -0
  61. package/lib/thematic.js +8 -18
  62. package/lib/theme-bootstrap.js +3 -1
  63. package/lib/theme-css-fallback.d.ts +5 -0
  64. package/lib/theme-css-fallback.js +29 -0
  65. package/lib/theme-css-snapshot.d.ts +8 -1
  66. package/lib/theme-css-snapshot.js +34 -8
  67. package/lib/theme-settings-core.js +7 -8
  68. package/lib/theme-styles.js +5 -8
  69. package/lib/type-badge.js +3 -1
  70. package/package.json +4 -4
  71. package/lib/rich-input-loader.d.ts +0 -7
  72. package/lib/rich-input-loader.js +0 -34
  73. package/lib/rich-input-loader.wyw-in-js.css +0 -2
@@ -0,0 +1,29 @@
1
+ import { wideGamutStyles } from "./styles.generated.js";
2
+ import { neutralArchDark, neutralUserDark } from "./styles.neutral-dark.generated.js";
3
+ import { neutralArchLight, neutralUserLight } from "./styles.neutral-light.generated.js";
4
+ import { warmArchDark, warmUserDark } from "./styles.warm-dark.generated.js";
5
+ import { warmArchLight, warmUserLight } from "./styles.warm-light.generated.js";
6
+ //#region src/theme-css-fallback.ts
7
+ var baseStyles = {
8
+ neutralUserLight,
9
+ neutralUserDark,
10
+ warmUserLight,
11
+ warmUserDark,
12
+ neutralArchLight,
13
+ neutralArchDark,
14
+ warmArchLight,
15
+ warmArchDark
16
+ };
17
+ var wideTiers = {
18
+ rgb: [],
19
+ p3: ["p3"],
20
+ rec2020: ["p3", "rec2020"]
21
+ };
22
+ function themeStylesFallback({ warm, arch, mode }, gamut) {
23
+ const look = warm ? "warm" : "neutral";
24
+ const suffix = mode === "dark" ? "Dark" : "Light";
25
+ const names = arch ? [`${look}User${suffix}`, `${look}Arch${suffix}`] : [`${look}User${suffix}`];
26
+ return new Map(names.flatMap((name) => [baseStyles[name], ...wideTiers[gamut].map((tier) => wideGamutStyles[tier][name])].flatMap((styles) => Object.entries(styles))));
27
+ }
28
+ //#endregion
29
+ export { themeStylesFallback };
@@ -1,6 +1,13 @@
1
+ import { ThemeMode } from "./theme-bootstrap.js";
1
2
  import { CssGamut, Gamut } from "./color-gamut.js";
2
3
  import { ThemeVariable } from "./theme-values.js";
3
4
  //#region src/theme-css-snapshot.d.ts
5
+ export type ThemeCssSource = {
6
+ warm: boolean;
7
+ arch: boolean;
8
+ mode: ThemeMode;
9
+ };
10
+ export declare function ensureThemeValues(): Promise<boolean>;
4
11
  export declare const themeCssSnapshotTrace: {
5
12
  enabled: boolean;
6
13
  count: number;
@@ -9,7 +16,7 @@ export declare const themeCssSnapshotTrace: {
9
16
  computedStylesDuration: number;
10
17
  duration: number;
11
18
  };
12
- export declare function themeCssValues(key: string, className: string, gamut: CssGamut): {
19
+ export declare function themeCssValues(key: string, source: ThemeCssSource, gamut: CssGamut): {
13
20
  names: readonly ThemeVariable[];
14
21
  read: (name: ThemeVariable) => string;
15
22
  gamut?: Gamut;
@@ -1,8 +1,31 @@
1
1
  import { withDisplayGamut } from "./color-gamut.js";
2
2
  import { serializeCssColors } from "./color-serialization.js";
3
+ import { archThemeClassName, builtinThemeClassName, darkThemeClassName, warmThemeClassName } from "./theme-bootstrap.js";
3
4
  import { themeTokenNames } from "./theming.generated.js";
4
5
  import { cacheThemeValues } from "./theme-values.js";
5
6
  //#region src/theme-css-snapshot.ts
7
+ var fallback;
8
+ function themeProbe(className) {
9
+ const probe = document.createElement("div");
10
+ probe.className = className;
11
+ probe.style.display = "none";
12
+ document.documentElement.append(probe);
13
+ return probe;
14
+ }
15
+ function themeCssApplied() {
16
+ const probe = themeProbe(builtinThemeClassName);
17
+ const applied = getComputedStyle(probe).getPropertyValue("--bg-canvas").trim() !== "";
18
+ probe.remove();
19
+ return applied;
20
+ }
21
+ async function ensureThemeValues() {
22
+ if (fallback || themeCssApplied()) return false;
23
+ ({themeStylesFallback: fallback} = await import(
24
+ /* webpackChunkName: "theme-css-fallback" */
25
+ "./theme-css-fallback.js"
26
+ ));
27
+ return true;
28
+ }
6
29
  var themeCssSnapshotTrace = {
7
30
  enabled: typeof location !== "undefined" && new URLSearchParams(location.search).has("trace-theme-css"),
8
31
  count: 0,
@@ -12,20 +35,23 @@ var themeCssSnapshotTrace = {
12
35
  duration: 0
13
36
  };
14
37
  if (themeCssSnapshotTrace.enabled) Object.assign(globalThis, { __FIBERY_THEME_CSS_TRACE: themeCssSnapshotTrace });
15
- function themeCssValues(key, className, gamut) {
38
+ function themeCssValues(key, source, gamut) {
39
+ const className = [
40
+ builtinThemeClassName,
41
+ source.warm ? warmThemeClassName : "",
42
+ source.arch ? archThemeClassName : "",
43
+ source.mode === "dark" ? darkThemeClassName : ""
44
+ ].join(" ");
16
45
  let computed;
46
+ let fallbackStyles;
17
47
  return {
18
48
  ...cacheThemeValues(themeTokenNames, (name) => {
19
49
  const started = themeCssSnapshotTrace.enabled ? performance.now() : 0;
20
50
  if (!computed) {
21
- const probe = document.createElement("div");
22
- probe.className = className;
23
- probe.style.display = "none";
24
- document.documentElement.append(probe);
25
- computed = getComputedStyle(probe);
51
+ computed = getComputedStyle(themeProbe(className));
26
52
  if (themeCssSnapshotTrace.enabled) themeCssSnapshotTrace.count += 1;
27
53
  }
28
- const raw = computed.getPropertyValue(name).trim();
54
+ const raw = computed.getPropertyValue(name).trim() || (fallbackStyles ??= fallback?.(source, gamut))?.get(name);
29
55
  const cssDuration = themeCssSnapshotTrace.enabled ? performance.now() - started : 0;
30
56
  if (!raw) throw new Error(`Theme CSS is unavailable: ${key}.${name}`);
31
57
  const value = withDisplayGamut(gamut, () => serializeCssColors(raw));
@@ -49,4 +75,4 @@ function themeCssValues(key, className, gamut) {
49
75
  };
50
76
  }
51
77
  //#endregion
52
- export { themeCssSnapshotTrace, themeCssValues };
78
+ export { ensureThemeValues, themeCssSnapshotTrace, themeCssValues };
@@ -1,6 +1,7 @@
1
1
  import { getThemeMode, getThemePreference, themePreferenceStorageKey } from "./theme-bootstrap.js";
2
2
  import { getMediaQueryList, subscribeOnChange } from "./media-query-utils.js";
3
3
  import { isPhoneMode } from "./phone.js";
4
+ import { localStorage } from "./storage.js";
4
5
  import { createPreferenceSetting } from "./preference-setting.js";
5
6
  //#region src/theme-settings-core.ts
6
7
  var listenersThemeMode = /* @__PURE__ */ new Map();
@@ -25,38 +26,36 @@ function setThemePreference(preference) {
25
26
  function subscribeOnThemePreferenceChange(cb) {
26
27
  listenersThemePreference.set(cb, cb);
27
28
  let currentPref = getThemePreference();
28
- const storageListener = () => {
29
+ const unsubscribeOtherTabs = localStorage.subscribe(themePreferenceStorageKey, () => {
29
30
  const newPref = getThemePreference();
30
31
  if (currentPref !== newPref) {
31
32
  currentPref = newPref;
32
33
  cb(newPref);
33
34
  }
34
- };
35
- window.addEventListener("storage", storageListener);
35
+ });
36
36
  return () => {
37
37
  listenersThemePreference.delete(cb);
38
- window.removeEventListener("storage", storageListener);
38
+ unsubscribeOtherTabs();
39
39
  };
40
40
  }
41
41
  function subscribeOnThemeModeChange(cb) {
42
42
  listenersThemeMode.set(cb, cb);
43
43
  let currentPref = getThemePreference();
44
44
  const darkMediaQuery = getDarkMediaQuery();
45
- const storageListener = () => {
45
+ const unsubscribeOtherTabs = localStorage.subscribe(themePreferenceStorageKey, () => {
46
46
  const newPref = getThemePreference();
47
47
  if (currentPref !== newPref) {
48
48
  currentPref = newPref;
49
49
  cb(getThemeMode());
50
50
  }
51
- };
52
- window.addEventListener("storage", storageListener);
51
+ });
53
52
  const unsubscribe = subscribeOnChange(darkMediaQuery, () => {
54
53
  if (getThemePreference() === "auto") cb(getThemeMode());
55
54
  });
56
55
  return () => {
57
56
  listenersThemeMode.delete(cb);
58
57
  unsubscribe();
59
- window.removeEventListener("storage", storageListener);
58
+ unsubscribeOtherTabs();
60
59
  };
61
60
  }
62
61
  var { has: hasWarmPreference, load: loadWarmPreference, store: storeWarmPreference, subscribe: subscribeOnWarmPreferenceChange } = createPreferenceSetting({
@@ -3,7 +3,6 @@ import { displayGamutKey, getCssGamut } from "./color-gamut.js";
3
3
  import { makeColorTransform } from "./color-filter-base.js";
4
4
  import { makeSelect } from "./design-system/colors-js.js";
5
5
  import { colorFnsForGamut, createColorFnsForMode } from "./design-system/fns.js";
6
- import { archThemeClassName, builtinThemeClassName, darkThemeClassName, warmThemeClassName } from "./theme-bootstrap.js";
7
6
  import { registerThemeValues } from "./theme-values.js";
8
7
  import { themeCssValues } from "./theme-css-snapshot.js";
9
8
  import "./styles.neutral-dark.generated.css";
@@ -15,13 +14,11 @@ function make(palette, gamut) {
15
14
  function makeTheme(mode) {
16
15
  let fns;
17
16
  const key = displayGamutKey(`${palette.key}-${mode}`, gamut);
18
- const className = [
19
- builtinThemeClassName,
20
- palette.warm ? warmThemeClassName : "",
21
- palette.arch ? archThemeClassName : "",
22
- mode === "dark" ? darkThemeClassName : ""
23
- ].join(" ");
24
- const values = themeCssValues(key, className, gamut);
17
+ const values = themeCssValues(key, {
18
+ warm: palette.warm,
19
+ arch: palette.arch,
20
+ mode
21
+ }, gamut);
25
22
  const theme = {
26
23
  key,
27
24
  mode,
package/lib/type-badge.js CHANGED
@@ -6,6 +6,7 @@ import { Tooltip } from "./tooltip.js";
6
6
  import { cx } from "@linaria/core";
7
7
  import { jsx } from "react/jsx-runtime";
8
8
  import { forwardRef, memo } from "react";
9
+ import { useComposedRefs } from "@fibery/react/src/use-composed-refs";
9
10
  //#region src/type-badge.tsx
10
11
  var baseCss = "b1qylqf5-base";
11
12
  var typeBadgeSize = {
@@ -35,6 +36,7 @@ var makeDescription = (typeObject) => {
35
36
  var makeAbbreviation = (title = "") => title.split(" ").map((word) => word[0]).join("");
36
37
  var TypeBadge = memo(forwardRef(function TypeBadge({ color, onMouseDown, onMouseEnter, onMouseLeave, onClick, children, selected, abbr, size = "medium", orientation = "horizontal", tooltip, faded = false, className, noTooltip, style }, ref) {
37
38
  const TagName = onClick ? "button" : "div";
39
+ const elementRef = useComposedRefs(ref);
38
40
  const title = typeof children === "string" && abbr ? noTooltip ? makeAbbreviation(children) : /* @__PURE__ */ jsx(Tooltip, {
39
41
  title: tooltip || children,
40
42
  side: "bottom",
@@ -49,7 +51,7 @@ var TypeBadge = memo(forwardRef(function TypeBadge({ color, onMouseDown, onMouse
49
51
  [selectedBorderProp]: badge.borderSelected
50
52
  };
51
53
  return /* @__PURE__ */ jsx(TagName, {
52
- ref,
54
+ ref: elementRef,
53
55
  style: resultingStyle,
54
56
  className: cx(textTransformClasses.uppercase, baseCss, typeBadgeCss, typeBadgeSize[size], abbr && orientation === "horizontal" && abbrHorizontalCssBySize[size], abbr && orientation === "vertical" && abbrVerticalCss, selected && selectedCss, onClick && clickableCss, faded && fadedCss, color === null && noColorCss, className),
55
57
  onMouseDown,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fibery/ui-kit",
3
- "version": "13.0.0",
3
+ "version": "14.0.0",
4
4
  "license": "UNLICENSED",
5
5
  "files": [
6
6
  "lib"
@@ -85,9 +85,9 @@
85
85
  },
86
86
  "dependencies": {
87
87
  "@fibery/emoji-data": "4.0.0",
88
- "@fibery/helpers": "5.0.0",
88
+ "@fibery/helpers": "5.2.0",
89
89
  "@fibery/icons": "0.1.0",
90
- "@fibery/react": "3.1.0",
90
+ "@fibery/react": "3.1.2",
91
91
  "@linaria/core": "8.2.0",
92
92
  "@linaria/react": "8.2.0",
93
93
  "@popperjs/core": "2.11.6",
@@ -110,7 +110,7 @@
110
110
  "cmdk": "1.1.1",
111
111
  "color-hash": "1.0.3",
112
112
  "culori": "4.0.2",
113
- "date-fns": "2.29.2",
113
+ "date-fns": "3.6.0",
114
114
  "invariant": "2.2.4",
115
115
  "lru-cache": "11.5.3",
116
116
  "moment": "2.31.0",
@@ -1,7 +0,0 @@
1
- //#region src/rich-input-loader.d.ts
2
- interface LoaderProps {
3
- className?: string;
4
- }
5
- export declare const RichInputLoader: import("react").NamedExoticComponent<LoaderProps>;
6
- export declare function RichFieldLoader(): import("react").JSX.Element;
7
- //#endregion
@@ -1,34 +0,0 @@
1
- import "./rich-input-loader.wyw-in-js.css";
2
- import { SkeletonList, SkeletonTextLine } from "./skeleton.js";
3
- import { regularRichEditorHTMLStyles } from "./html-styles.js";
4
- /* empty css */
5
- import { cx } from "@linaria/core";
6
- import { jsx, jsxs } from "react/jsx-runtime";
7
- import { memo } from "react";
8
- //#region src/rich-input-loader.tsx
9
- var RichInputLoader = memo(function RichInputLoaderComponent({ className = "" }) {
10
- return /* @__PURE__ */ jsx("div", {
11
- className,
12
- children: jsx(SkeletonList, {
13
- amount: 3,
14
- WrapperComponent: SkeletonTextLine
15
- })
16
- });
17
- });
18
- function RichFieldLoader() {
19
- return /* @__PURE__ */ jsxs("div", {
20
- className: cx("ProseMirror", regularRichEditorHTMLStyles, "cgnhmrn"),
21
- children: [/* @__PURE__ */ jsx("p", {
22
- className: "empty-node",
23
- children: /* @__PURE__ */ jsx("br", { className: "ProseMirror-trailingBreak" })
24
- }), /* @__PURE__ */ jsx("div", {
25
- className: "czwej5w",
26
- children: /* @__PURE__ */ jsx(SkeletonList, {
27
- amount: 1,
28
- WrapperComponent: SkeletonTextLine
29
- })
30
- })]
31
- });
32
- }
33
- //#endregion
34
- export { RichFieldLoader, RichInputLoader };
@@ -1,2 +0,0 @@
1
- .cgnhmrn{position:relative;}
2
- .czwej5w{position:absolute;inset:0;display:grid;align-content:center;}