@fibery/ui-kit 9.0.2 → 9.1.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 (189) hide show
  1. package/lib/a11y-color.js +12 -10
  2. package/lib/actions-menu/actions-menu-props.d.ts +2 -0
  3. package/lib/actions-menu/actions-menu-sub-command-menu.js +5 -4
  4. package/lib/actions-menu/actions-menu.d.ts +1 -1
  5. package/lib/actions-menu/actions-menu.js +2 -1
  6. package/lib/actions-menu/contexts/actions-menu-context.js +12 -11
  7. package/lib/ai/max-tokens.js +6 -5
  8. package/lib/antd/ant-modal.d.ts +1 -1
  9. package/lib/antd/ant-modal.js +28 -1
  10. package/lib/antd/ant-upload.d.ts +1 -1
  11. package/lib/antd/ant-upload.js +23 -18
  12. package/lib/antd/input.js +5 -4
  13. package/lib/antd/utils.js +2 -1
  14. package/lib/avatar-colors.js +1 -1
  15. package/lib/avatar.d.ts +1 -10
  16. package/lib/avatar.js +48 -38
  17. package/lib/avatar.wyw-in-js.css +1 -1
  18. package/lib/banner/banner-action.js +2 -1
  19. package/lib/button/button.js +1 -1
  20. package/lib/button/icon-button.js +1 -1
  21. package/lib/canvas-colors.js +2 -2
  22. package/lib/card-container.d.ts +2 -6
  23. package/lib/card-container.js +4 -4
  24. package/lib/color-filter.js +2 -2
  25. package/lib/color-inspect.js +1 -1
  26. package/lib/color-picker/color-picker-or-loader.d.ts +2 -2
  27. package/lib/color-utils.js +1 -1
  28. package/lib/comment.d.ts +1 -0
  29. package/lib/comment.js +29 -20
  30. package/lib/comment.wyw-in-js.css +9 -7
  31. package/lib/context-menu/index.js +1 -0
  32. package/lib/context-menu/index.wyw-in-js.css +1 -1
  33. package/lib/date-picker/autocomplete.js +12 -10
  34. package/lib/date-picker/date-range-input.js +8 -6
  35. package/lib/date-picker/day-with-start-end-buttons.js +0 -2
  36. package/lib/date-picker/get-weekends-for-month.js +4 -2
  37. package/lib/date-picker/single-date-input.js +8 -6
  38. package/lib/day-select/day-select.js +2 -1
  39. package/lib/day-select/week-day-select.d.ts +2 -2
  40. package/lib/day-select/week-day-select.js +4 -3
  41. package/lib/design-system/alpha.js +5 -7
  42. package/lib/design-system/colors-charts.d.ts +4 -0
  43. package/lib/design-system/colors-charts.js +14 -0
  44. package/lib/design-system/colors-js.d.ts +2 -4
  45. package/lib/design-system/colors-js.js +8 -10
  46. package/lib/design-system/fns.enum.js +7 -4
  47. package/lib/design-system/fns.icon.js +1 -1
  48. package/lib/design-system/fns.js +7 -4
  49. package/lib/design-system/theme.d.ts +7 -7
  50. package/lib/design-system/theme.js +7 -12
  51. package/lib/design-system/vars.js +1 -2
  52. package/lib/design-system.d.ts +3 -2
  53. package/lib/design-system.js +3 -2
  54. package/lib/emoji-picker/primitives/content.js +10 -9
  55. package/lib/emoji-picker/primitives/emoji.js +22 -14
  56. package/lib/emoji-picker/primitives/emoji.wyw-in-js.css +4 -3
  57. package/lib/emoji-picker/primitives/grid.js +0 -1
  58. package/lib/emoji-picker/primitives/preview-provider.js +4 -3
  59. package/lib/emoji-picker/primitives/root.js +10 -9
  60. package/lib/emoji-picker/primitives/skin-provider.js +5 -4
  61. package/lib/emoji-picker/stores/emoji-data-store.d.ts +2 -2
  62. package/lib/emoji-picker/stores/emoji-data-store.js +8 -8
  63. package/lib/emoji-picker/stores/static-emoji-data-store.js +2 -1
  64. package/lib/emoji.js +5 -2
  65. package/lib/fibermoji-placeholder.js +5 -7
  66. package/lib/field-type-icon.js +2 -1
  67. package/lib/file-item/file-icon.js +2 -1
  68. package/lib/file-item.js +3 -10
  69. package/lib/highlight-colors.js +2 -1
  70. package/lib/hotkey-scope.js +2 -1
  71. package/lib/icons/ast/index.d.ts +1 -4
  72. package/lib/icons/ast/index.js +2 -5
  73. package/lib/icons/ast/spinner.js +1 -14
  74. package/lib/icons/icon.js +4 -3
  75. package/lib/icons/react/index.d.ts +1 -4
  76. package/lib/icons/react/index.js +2 -5
  77. package/lib/images-gallery/get-gallery-src.js +1 -1
  78. package/lib/images-gallery/slide-buttons.js +8 -4
  79. package/lib/images-gallery/thumbnails-mime-types-white-list.js +1 -1
  80. package/lib/integration-compact-info-button.js +1 -1
  81. package/lib/loading-sausage.js +7 -6
  82. package/lib/mobile-drawer.d.ts +2 -1
  83. package/lib/mobile-drawer.js +24 -12
  84. package/lib/mobile-drawer.wyw-in-js.css +3 -2
  85. package/lib/mobile-keyboard-aware-popup.js +6 -5
  86. package/lib/modal-menu/contexts/modal-menu-context.d.ts +1 -0
  87. package/lib/modal-menu/modal-menu-content.d.ts +1 -1
  88. package/lib/modal-menu/modal-menu-content.js +16 -6
  89. package/lib/modal-menu/modal-menu-drawer-content.d.ts +7 -0
  90. package/lib/modal-menu/modal-menu-drawer-content.js +13 -0
  91. package/lib/modal-menu/modal-menu-root.d.ts +2 -1
  92. package/lib/modal-menu/modal-menu-root.js +24 -21
  93. package/lib/modal-menu/modal-submenu.js +10 -9
  94. package/lib/nested-menu-item.d.ts +1 -1
  95. package/lib/number-input/number-input-inline-with-autosize.d.ts +1 -2
  96. package/lib/number-input/number-input-inline-with-autosize.js +9 -6
  97. package/lib/number-input/number-input-inline-with-autosize.wyw-in-js.css +0 -1
  98. package/lib/number-input/number-input.js +13 -11
  99. package/lib/number-input/styles.d.ts +1 -9
  100. package/lib/number-input/styles.js +3 -9
  101. package/lib/number-input/styles.wyw-in-js.css +2 -3
  102. package/lib/number-input/text-area-auto-sized.d.ts +1 -2
  103. package/lib/number-input/text-area-auto-sized.js +2 -2
  104. package/lib/number-input/text-input-auto-sized.d.ts +1 -2
  105. package/lib/number-input/text-input-auto-sized.js +2 -2
  106. package/lib/online-users.js +2 -2
  107. package/lib/open-popover-tracker.js +7 -6
  108. package/lib/palettes/neutral.js +1 -1
  109. package/lib/palettes/warm.js +1 -1
  110. package/lib/phone.js +1 -1
  111. package/lib/popover/index.d.ts +4 -2
  112. package/lib/popover/index.js +61 -59
  113. package/lib/popover/mobile-popover-context.js +12 -11
  114. package/lib/popover/mobile-popover.js +16 -15
  115. package/lib/popover/modifiers.js +4 -4
  116. package/lib/preference-setting.js +6 -8
  117. package/lib/reactions/reaction-button.js +36 -25
  118. package/lib/reactions/reaction-button.wyw-in-js.css +16 -16
  119. package/lib/reactions/reaction-picker.js +22 -10
  120. package/lib/reactions/reaction-picker.wyw-in-js.css +1 -0
  121. package/lib/reactions/tootltip.js +2 -1
  122. package/lib/select/components/option.js +2 -1
  123. package/lib/select/index.d.ts +2 -1
  124. package/lib/select/select-trigger.d.ts +4 -0
  125. package/lib/select/select-trigger.js +25 -0
  126. package/lib/select/select-trigger.wyw-in-js.css +1 -0
  127. package/lib/select/select.d.ts +6 -2
  128. package/lib/select/select.js +10 -5
  129. package/lib/spinner.d.ts +2 -6
  130. package/lib/spinner.js +11 -7
  131. package/lib/spinner.wyw-in-js.css +1 -0
  132. package/lib/tab-nav/tab-nav.d.ts +4 -2
  133. package/lib/tab-nav/tab-nav.js +2 -2
  134. package/lib/thematic.js +322 -321
  135. package/lib/theme-provider.d.ts +1 -3
  136. package/lib/toast/toast-action.js +2 -1
  137. package/lib/toast/toast-provider.d.ts +1 -2
  138. package/lib/toast/toast-queue.d.ts +1 -2
  139. package/lib/toast/toast-queue.js +7 -8
  140. package/lib/toast/toast.js +7 -6
  141. package/lib/toggle.js +3 -3
  142. package/lib/tooltip-if-overflown.js +2 -1
  143. package/lib/tooltip.js +1 -1
  144. package/lib/type-badge.d.ts +8 -28
  145. package/lib/type-badge.js +39 -50
  146. package/lib/type-badge.wyw-in-js.css +11 -10
  147. package/lib/unit/container.d.ts +12 -0
  148. package/lib/unit/container.js +50 -0
  149. package/lib/unit/context.d.ts +29 -0
  150. package/lib/unit/context.js +9 -0
  151. package/lib/unit/index.d.ts +4 -2
  152. package/lib/unit/index.js +2 -1
  153. package/lib/unit/nav-button.d.ts +12 -0
  154. package/lib/unit/nav-button.js +18 -0
  155. package/lib/unit/styles.d.ts +6 -9
  156. package/lib/unit/styles.js +13 -16
  157. package/lib/unit/styles.wyw-in-js.css +10 -16
  158. package/lib/unit/unit-content-layout.d.ts +4 -3
  159. package/lib/unit/unit-content-layout.js +9 -9
  160. package/lib/unit/unit-content.d.ts +6 -5
  161. package/lib/unit/unit-content.js +83 -18
  162. package/lib/unit/unit-content.wyw-in-js.css +6 -2
  163. package/lib/unit/unit.d.ts +38 -5
  164. package/lib/unit/unit.js +43 -12
  165. package/lib/workflow-progress-icon.js +2 -2
  166. package/package.json +4 -4
  167. package/lib/features.d.ts +0 -8
  168. package/lib/features.js +0 -15
  169. package/lib/flags.d.ts +0 -4
  170. package/lib/flags.js +0 -7
  171. package/lib/icons/ast/alert-triangle.d.ts +0 -5
  172. package/lib/icons/ast/alert-triangle.js +0 -25
  173. package/lib/icons/ast/field-units-large.d.ts +0 -5
  174. package/lib/icons/ast/field-units-large.js +0 -25
  175. package/lib/icons/ast/plus.d.ts +0 -5
  176. package/lib/icons/ast/plus.js +0 -25
  177. package/lib/icons/react/alert-triangle.d.ts +0 -15
  178. package/lib/icons/react/alert-triangle.js +0 -21
  179. package/lib/icons/react/field-units-large.d.ts +0 -15
  180. package/lib/icons/react/field-units-large.js +0 -21
  181. package/lib/icons/react/plus.d.ts +0 -15
  182. package/lib/icons/react/plus.js +0 -21
  183. package/lib/unit/primitive.d.ts +0 -5
  184. package/lib/unit/primitive.js +0 -108
  185. package/lib/unit/primitive.wyw-in-js.css +0 -3
  186. package/lib/unit/types.d.ts +0 -34
  187. package/lib/unit/types.js +0 -0
  188. package/lib/unit/unit-button-group.d.ts +0 -13
  189. package/lib/unit/unit-button-group.js +0 -23
@@ -1,8 +1,6 @@
1
1
  import { ThemePalette } from "./design-system/types.js";
2
2
  import { ThemeMode, ThemePreference } from "./theme-settings-core.js";
3
- import { ThemeDefs } from "./design-system/colors.js";
4
3
  import { Styles, Theme } from "./design-system/theme.js";
5
- import "./design-system.js";
6
4
  import { ComponentType, PropsWithChildren } from "react";
7
5
  //#region src/theme-provider.d.ts
8
6
  declare const ThemePreferenceContext: import("react").Context<ThemePreference | null>;
@@ -614,7 +612,7 @@ declare const ThemeContext: import("react").Context<{
614
612
  bgDecor: string;
615
613
  }>;
616
614
  };
617
- varname: (key: keyof ThemeDefs["colors"]) => string;
615
+ varname: (key: string) => string;
618
616
  }>;
619
617
  declare function useTheme(): Theme;
620
618
  declare function useThemeMode(): ThemeMode;
@@ -10,13 +10,14 @@ import { Action as RadixToastAction } from "@radix-ui/react-toast";
10
10
  var toastActionCss = "tvoosnp-toastAction";
11
11
  var ToastAction = forwardRef(({ children, altText, ...props }, ref) => {
12
12
  const theme = useTheme();
13
+ const buttonColors = theme.mode === "dark" ? makeButtonColors(theme.colors.textColor, "outline", theme) : {};
13
14
  return /* @__PURE__ */ jsx(RadixToastAction, {
14
15
  className: toastActionCss,
15
16
  ref,
16
17
  altText,
17
18
  asChild: true,
18
19
  children: jsx(Button, {
19
- style: theme.mode === "dark" ? makeButtonColors(theme.colors.textColor, "outline", theme) : {},
20
+ style: buttonColors,
20
21
  variant: "outline",
21
22
  color: "neutral",
22
23
  ...props,
@@ -17,8 +17,7 @@ declare const useToast: () => {
17
17
  })[];
18
18
  addBottomOffset: (bottomOffset: number) => () => void;
19
19
  getBottomOffset(): number;
20
- subscribe: (listener: () => void) => () => void;
21
- unsubscribe: (listener: () => void) => void;
20
+ subscribe: (listener: (value: void) => void) => import("@fibery/helpers/src/subject").Unsubscribe;
22
21
  info(t: {
23
22
  title: React.ReactNode;
24
23
  variant?: "line" | "card";
@@ -25,8 +25,7 @@ declare const makeToastQueue: ({ maxActiveToasts, onToastAdd, transformToast }?:
25
25
  getActiveToasts(): QueuedToast[];
26
26
  addBottomOffset: (bottomOffset: number) => () => void;
27
27
  getBottomOffset(): number;
28
- subscribe: (listener: () => void) => () => void;
29
- unsubscribe: (listener: () => void) => void;
28
+ subscribe: (listener: (value: void) => void) => import("@fibery/helpers/src/subject").Unsubscribe;
30
29
  info(t: TypedAddProps): string;
31
30
  success(t: TypedAddProps): string;
32
31
  error(t: TypedAddProps): string;
@@ -1,7 +1,7 @@
1
- import { makePubSub } from "@fibery/helpers/utils/pub-sub";
1
+ import { makeSubject } from "@fibery/helpers/src/subject";
2
2
  //#region src/toast/toast-queue.ts
3
3
  var makeToastQueue = ({ maxActiveToasts = 1, onToastAdd, transformToast } = {}) => {
4
- const pubSub = makePubSub();
4
+ const subject = makeSubject();
5
5
  let queue = [];
6
6
  let activeToasts = [];
7
7
  let bottomOffsets = [];
@@ -14,7 +14,7 @@ var makeToastQueue = ({ maxActiveToasts = 1, onToastAdd, transformToast } = {})
14
14
  const newToasts = queue.slice(0, freeSlots);
15
15
  queue = queue.slice(freeSlots);
16
16
  activeToasts = activeToasts.concat(newToasts);
17
- pubSub.publish();
17
+ subject.publish();
18
18
  };
19
19
  /**
20
20
  * Add toast to queue
@@ -41,7 +41,7 @@ var makeToastQueue = ({ maxActiveToasts = 1, onToastAdd, transformToast } = {})
41
41
  ...t,
42
42
  open: false
43
43
  } : t);
44
- pubSub.publish();
44
+ subject.publish();
45
45
  },
46
46
  /** remove toast from active ones, should be called after exit animation */
47
47
  remove(id) {
@@ -57,18 +57,17 @@ var makeToastQueue = ({ maxActiveToasts = 1, onToastAdd, transformToast } = {})
57
57
  id,
58
58
  bottomOffset
59
59
  });
60
- pubSub.publish();
60
+ subject.publish();
61
61
  return () => {
62
62
  bottomOffsets = bottomOffsets.filter((v) => v.id !== id);
63
- pubSub.publish();
63
+ subject.publish();
64
64
  };
65
65
  },
66
66
  getBottomOffset() {
67
67
  if (bottomOffsets.length === 0) return 0;
68
68
  return Math.max(...bottomOffsets.map((v) => v.bottomOffset));
69
69
  },
70
- subscribe: pubSub.subscribe,
71
- unsubscribe: pubSub.unsubscribe,
70
+ subscribe: subject.subscribe,
72
71
  info(t) {
73
72
  return add(t);
74
73
  },
@@ -1,9 +1,9 @@
1
1
  import "./toast.wyw-in-js.css";
2
2
  import { themeVars } from "../theming.generated.js";
3
- import Spinner from "../icons/react/spinner.js";
3
+ import { Spinner } from "../spinner.js";
4
4
  import { ToastClose, ToastRoot, ToastSubtitle, ToastTitle } from "./primitives.js";
5
- import AlertTriangle from "../icons/react/alert-triangle.js";
6
5
  import CircleCheckFilled from "../icons/react/circle-check-filled.js";
6
+ import WarningTriangleFilled from "../icons/react/warning-triangle-filled.js";
7
7
  /* empty css */
8
8
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
9
  import { useCallback, useEffect, useRef } from "react";
@@ -14,7 +14,7 @@ import { useCallbackRef } from "@fibery/react/src/use-callback-ref";
14
14
  var defaultPropsPerType = {
15
15
  info: {},
16
16
  error: {
17
- icon: jsx(AlertTriangle, { color: themeVars.warning }),
17
+ icon: jsx(WarningTriangleFilled, { color: themeVars.warning }),
18
18
  duration: 1e4,
19
19
  dismissable: true
20
20
  },
@@ -51,10 +51,11 @@ var Toast = (props) => {
51
51
  return () => {};
52
52
  }, [isOpen, onHideCb]);
53
53
  const close = dismissable ? /* @__PURE__ */ jsx(ToastClose, {}) : null;
54
+ const onEscapeKeyDown = useCallback((evt) => {
55
+ if (evt.target && evt.target instanceof Element && (evt.target.tagName === "INPUT" || evt.target.tagName === "TEXTAREA")) evt.preventDefault();
56
+ }, []);
54
57
  return /* @__PURE__ */ jsx(ToastRoot, {
55
- onEscapeKeyDown: useCallback((evt) => {
56
- if (evt.target && evt.target instanceof Element && (evt.target.tagName === "INPUT" || evt.target.tagName === "TEXTAREA")) evt.preventDefault();
57
- }, []),
58
+ onEscapeKeyDown,
58
59
  type: "background",
59
60
  ref,
60
61
  open,
package/lib/toggle.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import "./toggle.wyw-in-js.css";
2
2
  import { produceColor } from "./color-utils.js";
3
+ import { memoizeColor } from "./memoize.js";
3
4
  import { space } from "./design-system/layout.js";
4
5
  import { textClasses } from "./design-system/typography.js";
5
- import Spinner from "./icons/react/spinner.js";
6
+ import { Spinner } from "./spinner.js";
6
7
  /* empty css */
7
- import { memoize } from "@fibery/helpers/src/_";
8
8
  import { jsx, jsxs } from "react/jsx-runtime";
9
9
  import { cx } from "@linaria/core";
10
10
  import { styled } from "@linaria/react";
@@ -32,7 +32,7 @@ var Label = /*#__PURE__*/ styled("div")({
32
32
  }
33
33
  });
34
34
  var labelWrapperStyle = "l1lhosnx-labelWrapper";
35
- var getOutlineColor = memoize((color) => produceColor(color, (oklch) => oklch.alpha === void 0 || oklch.alpha >= 1 ? {
35
+ var getOutlineColor = memoizeColor((color) => produceColor(color, (oklch) => oklch.alpha === void 0 || oklch.alpha >= 1 ? {
36
36
  ...oklch,
37
37
  l: Math.max(0, oklch.l - .18)
38
38
  } : {
@@ -8,7 +8,8 @@ var useTruncated = () => {
8
8
  const [node, setNode] = useState(null);
9
9
  useResizeObserver(node, (entry) => {
10
10
  const target = entry.target;
11
- setTruncated(getComputedStyle(target).webkitLineClamp !== "none" ? target.scrollHeight > target.clientHeight : target.scrollWidth > target.clientWidth);
11
+ const truncated = getComputedStyle(target).webkitLineClamp !== "none" ? target.scrollHeight > target.clientHeight : target.scrollWidth > target.clientWidth;
12
+ setTruncated(truncated);
12
13
  });
13
14
  return {
14
15
  setNode,
package/lib/tooltip.js CHANGED
@@ -3,6 +3,7 @@ import { tooltipDelay } from "./design-system/animation.js";
3
3
  import { space } from "./design-system/layout.js";
4
4
  import { RadixPortalThemeProvider } from "./theme-provider.js";
5
5
  /* empty css */
6
+ import { isFlagPresent } from "@fibery/helpers/src/flags";
6
7
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
8
  import { forwardRef, useRef } from "react";
8
9
  import { composeEventHandlers } from "@fibery/react/src/compose-event-handlers";
@@ -10,7 +11,6 @@ import { useControllableState } from "@fibery/react/src/use-controllable-state";
10
11
  import { cx } from "@linaria/core";
11
12
  import * as TooltipPrimitive from "@radix-ui/react-tooltip";
12
13
  //#region src/tooltip.tsx
13
- var isFlagPresent = (flag) => new RegExp(`[?&]${flag}\\b`).test(window.location.search);
14
14
  var preventDefaultAndStopPropagation = (e) => {
15
15
  e.preventDefault();
16
16
  e.stopPropagation();
@@ -1,26 +1,7 @@
1
1
  import { CSSProperties, ReactNode } from "react";
2
2
  //#region src/type-badge.d.ts
3
- declare const normalTypeBadgeStyleObject: {
4
- fontFamily: "\"Inter Variable\", \"SF Pro Display\", -apple-system, BlinkMacSystemFont, \"Segoe UI Variable Display\", \"Segoe UI\", Roboto, Oxygen, Ubuntu, Cantarell, \"Open Sans\", \"Helvetica Neue\", sans-serif";
5
- textTransform: "uppercase";
6
- fontWeight: 410;
7
- color: "var(--textColor)";
8
- display: string;
9
- fontSize: number;
10
- letterSpacing: number;
11
- lineHeight: number;
12
- outline: string;
13
- whiteSpace: string;
14
- transition: string;
15
- borderWidth: number;
16
- borderStyle: string;
17
- paddingTop: number;
18
- paddingBottom: number;
19
- paddingLeft: 4;
20
- paddingRight: 4;
21
- borderRadius: 4;
22
- };
23
- declare const normalTypeBadgeStaticStyle: import("@linaria/core").LinariaClassName;
3
+ type TypeBadgeSize = "small" | "medium" | "large";
4
+ type TypeBadgeOrientation = "horizontal" | "vertical";
24
5
  declare const makeDescription: (typeObject: {
25
6
  description?: string | null;
26
7
  }) => string | null;
@@ -34,12 +15,11 @@ type TypeBadgeProps = {
34
15
  children: ReactNode;
35
16
  selected?: boolean;
36
17
  abbr?: boolean;
37
- compact?: boolean;
18
+ size?: TypeBadgeSize;
19
+ orientation?: TypeBadgeOrientation;
38
20
  tooltip?: ReactNode;
39
21
  faded?: boolean;
40
- big?: boolean;
41
22
  style?: CSSProperties;
42
- vertical?: boolean;
43
23
  className?: string;
44
24
  noTooltip?: boolean;
45
25
  };
@@ -58,16 +38,16 @@ type TypeObjectBadgeParams = {
58
38
  onMouseLeave?: () => void;
59
39
  onClick?: React.MouseEventHandler;
60
40
  abbr?: boolean;
61
- compact?: boolean;
62
- vertical?: boolean;
41
+ size?: TypeBadgeSize;
42
+ orientation?: TypeBadgeOrientation;
63
43
  form?: "singular" | "plural";
64
44
  className?: string;
65
- big?: boolean;
66
45
  selected?: boolean;
67
46
  faded?: boolean;
68
47
  tooltip?: boolean;
69
48
  noColor?: boolean;
49
+ tooltipTitle?: string;
70
50
  };
71
51
  declare const TypeObjectBadge: import("react").ForwardRefExoticComponent<TypeObjectBadgeParams & import("react").RefAttributes<HTMLButtonElement | HTMLDivElement>>;
72
52
  //#endregion
73
- export { TypeBadge, TypeObjectBadge, makeAbbreviation, makeDescription, normalTypeBadgeStaticStyle, normalTypeBadgeStyleObject };
53
+ export { TypeBadge, TypeBadgeOrientation, TypeBadgeSize, TypeObjectBadge, makeAbbreviation, makeDescription };
package/lib/type-badge.js CHANGED
@@ -1,49 +1,37 @@
1
1
  import "./type-badge.wyw-in-js.css";
2
- import { transition } from "./design-system/animation.js";
3
- import { border, space } from "./design-system/layout.js";
4
- import { textStyles } from "./design-system/typography.js";
5
2
  import { useTheme } from "./theme-provider.js";
6
3
  import { Tooltip } from "./tooltip.js";
7
4
  /* empty css */
8
5
  import { jsx } from "react/jsx-runtime";
9
6
  import { forwardRef, memo } from "react";
10
7
  import cx from "classnames";
11
- var normalTypeBadgeStyleObject = {
12
- display: "inline-grid",
13
- ...textStyles.heading6,
14
- fontSize: 11,
15
- letterSpacing: 1.5,
16
- lineHeight: 1.24,
17
- outline: "none",
18
- whiteSpace: "nowrap",
19
- transition: `box-shadow ${transition}`,
20
- borderWidth: 1,
21
- borderStyle: "solid",
22
- paddingTop: 0,
23
- paddingBottom: 0,
24
- paddingLeft: space.s4,
25
- paddingRight: space.s4,
26
- borderRadius: border.radius4
8
+ //#region src/type-badge.tsx
9
+ var typeBadgeSize = {
10
+ small: "s1qylqf5-small",
11
+ medium: "m1m0uvhu-medium",
12
+ large: "lhmelw4-large"
27
13
  };
28
- var normalTypeBadgeStaticStyle = "n1qylqf5-normalTypeBadgeStatic";
29
- var bigTypeBadgeStaticStyle = "b1m0uvhu-bigTypeBadgeStatic";
30
- var compactTypeBadgeStaticStyle = "chmelw4-compactTypeBadgeStatic";
31
- var abbrCompactStyle = "a26rpox-abbrCompact";
32
- var abbrVerticalCompactStyle = "a1x8jlwm-abbrVerticalCompact";
14
+ var abbrHorizontalCss = "a26rpox-abbrHorizontal";
15
+ var abbrHorizontalCssBySize = {
16
+ small: abbrHorizontalCss,
17
+ medium: abbrHorizontalCss,
18
+ large: "a1x8jlwm-abbrHorizontalLarge"
19
+ };
20
+ var abbrVerticalCss = "aq1boe2-abbrVertical";
33
21
  var colorProp = "--fibery-type-badge-color";
34
22
  var selectedBorderProp = "--fibery-type-badge-color-dark";
35
23
  var colorBackgroundProp = "--fibery-type-badge-background-color";
36
24
  var colorBorderProp = "--fibery-type-badge-border-color";
37
- var typeBadgeStyle = "tq1boe2-typeBadge";
38
- var selectedStyle = "s10sagx9-selected";
39
- var clickableStyle = "cmf5kc4-clickable";
40
- var fadedStyle = "f1whvqrd-faded";
41
- var noColorStyle = "n1edvjqb-noColor";
25
+ var typeBadgeCss = "t10sagx9-typeBadge";
26
+ var selectedCss = "smf5kc4-selected";
27
+ var clickableCss = "c1whvqrd-clickable";
28
+ var fadedCss = "f1edvjqb-faded";
29
+ var noColorCss = "n1njzdi0-noColor";
42
30
  var makeDescription = (typeObject) => {
43
31
  return typeObject.description || null;
44
32
  };
45
33
  var makeAbbreviation = (title = "") => title.split(" ").map((word) => word[0]).join("");
46
- var TypeBadge = memo(forwardRef(function TypeBadge({ color, onMouseDown, onMouseEnter, onMouseLeave, onClick, children, selected, abbr, compact, tooltip, faded = false, big = false, vertical = false, className, noTooltip, style }, ref) {
34
+ 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) {
47
35
  const TagName = onClick ? "button" : "div";
48
36
  const title = typeof children === "string" && abbr ? noTooltip ? makeAbbreviation(children) : /* @__PURE__ */ jsx(Tooltip, {
49
37
  title: tooltip || children,
@@ -51,22 +39,23 @@ var TypeBadge = memo(forwardRef(function TypeBadge({ color, onMouseDown, onMouse
51
39
  children: jsx("span", { children: makeAbbreviation(children) })
52
40
  }) : children;
53
41
  const badge = useTheme().fns.badge(color);
42
+ const resultingStyle = {
43
+ ...style,
44
+ [colorProp]: badge.fg,
45
+ [colorBackgroundProp]: badge.bg,
46
+ [colorBorderProp]: badge.border,
47
+ [selectedBorderProp]: badge.borderSelected
48
+ };
54
49
  return /* @__PURE__ */ jsx(TagName, {
55
50
  ref,
56
- style: {
57
- ...style,
58
- [colorProp]: badge.fg,
59
- [colorBackgroundProp]: badge.bg,
60
- [colorBorderProp]: badge.border,
61
- [selectedBorderProp]: badge.borderSelected
62
- },
63
- className: cx(typeBadgeStyle, big ? bigTypeBadgeStaticStyle : compact ? compactTypeBadgeStaticStyle : normalTypeBadgeStaticStyle, {
64
- [abbrCompactStyle]: abbr && !vertical,
65
- [abbrVerticalCompactStyle]: abbr && vertical,
66
- [selectedStyle]: selected,
67
- [clickableStyle]: onClick,
68
- [fadedStyle]: faded,
69
- [noColorStyle]: color === null
51
+ style: resultingStyle,
52
+ className: cx(typeBadgeCss, typeBadgeSize[size], {
53
+ [abbrHorizontalCssBySize[size]]: abbr && orientation === "horizontal",
54
+ [abbrVerticalCss]: abbr && orientation === "vertical",
55
+ [selectedCss]: selected,
56
+ [clickableCss]: onClick,
57
+ [fadedCss]: faded,
58
+ [noColorCss]: color === null
70
59
  }, className),
71
60
  onMouseDown,
72
61
  onClick,
@@ -76,17 +65,17 @@ var TypeBadge = memo(forwardRef(function TypeBadge({ color, onMouseDown, onMouse
76
65
  });
77
66
  }));
78
67
  var getTypeObjectTitleForm = (typeObject, form) => form === "singular" ? typeObject.singularTitle : typeObject.pluralTitle;
79
- var TypeObjectBadge = forwardRef(({ typeObject, onMouseDown, onMouseEnter, onMouseLeave, onClick, abbr, compact, vertical, form, className, big, selected, faded, tooltip = true, noColor }, ref) => {
68
+ var TypeObjectBadge = forwardRef(({ typeObject, onMouseDown, onMouseEnter, onMouseLeave, onClick, abbr, size, orientation, form, className, selected, faded, tooltip = true, noColor, tooltipTitle }, ref) => {
80
69
  const typeTitle = String(form ? getTypeObjectTitleForm(typeObject, form) : typeObject.title);
81
70
  const caption = abbr ? makeAbbreviation(typeTitle) : typeTitle;
71
+ const resolvedTooltipTitle = tooltipTitle ?? typeTitle;
82
72
  return /* @__PURE__ */ jsx(TypeBadge, {
83
73
  ref,
84
74
  color: noColor ? null : typeObject.color,
85
75
  abbr,
86
- compact,
87
- vertical,
76
+ size,
77
+ orientation,
88
78
  className,
89
- big,
90
79
  selected,
91
80
  onClick,
92
81
  onMouseDown,
@@ -94,7 +83,7 @@ var TypeObjectBadge = forwardRef(({ typeObject, onMouseDown, onMouseEnter, onMou
94
83
  onMouseLeave,
95
84
  faded,
96
85
  children: jsx(Tooltip, {
97
- title: typeTitle,
86
+ title: resolvedTooltipTitle,
98
87
  disabled: !tooltip,
99
88
  description: makeDescription(typeObject),
100
89
  side: "bottom",
@@ -103,4 +92,4 @@ var TypeObjectBadge = forwardRef(({ typeObject, onMouseDown, onMouseEnter, onMou
103
92
  });
104
93
  });
105
94
  //#endregion
106
- export { TypeBadge, TypeObjectBadge, makeAbbreviation, makeDescription, normalTypeBadgeStaticStyle, normalTypeBadgeStyleObject };
95
+ export { TypeBadge, TypeObjectBadge, makeAbbreviation, makeDescription };
@@ -1,10 +1,11 @@
1
- .n1qylqf5-normalTypeBadgeStatic{display:inline-grid;font-family:"Inter Variable","SF Pro Display",-apple-system,BlinkMacSystemFont,"Segoe UI Variable Display","Segoe UI",Roboto,Oxygen,Ubuntu,Cantarell,"Open Sans","Helvetica Neue",sans-serif;font-size:11px;line-height:1.24;letter-spacing:1.5px;text-transform:uppercase;font-weight:410;color:var(--textColor);outline:none;white-space:nowrap;transition:box-shadow 120ms ease-in-out;border-width:1px;border-style:solid;padding-top:0;padding-bottom:0;padding-left:4px;padding-right:4px;border-radius:4px;}
2
- .b1m0uvhu-bigTypeBadgeStatic{display:inline-grid;font-family:"Inter Variable","SF Pro Display",-apple-system,BlinkMacSystemFont,"Segoe UI Variable Display","Segoe UI",Roboto,Oxygen,Ubuntu,Cantarell,"Open Sans","Helvetica Neue",sans-serif;font-size:12px;line-height:1;letter-spacing:2px;text-transform:uppercase;font-weight:500;color:var(--textColor);outline:none;white-space:nowrap;transition:box-shadow 120ms ease-in-out;border-width:1px;border-style:solid;padding-top:4px;padding-bottom:4px;padding-left:8px;padding-right:6px;border-radius:5px;}
3
- .chmelw4-compactTypeBadgeStatic{display:grid;font-family:"Inter Variable","SF Pro Display",-apple-system,BlinkMacSystemFont,"Segoe UI Variable Display","Segoe UI",Roboto,Oxygen,Ubuntu,Cantarell,"Open Sans","Helvetica Neue",sans-serif;font-size:11px;line-height:1.1;letter-spacing:1.5px;text-transform:uppercase;font-weight:410;color:var(--textColor);outline:none;white-space:nowrap;transition:box-shadow 120ms ease-in-out;border-width:1px;border-style:solid;padding-top:1px;padding-bottom:1px;padding-left:5px;padding-right:4px;border-radius:4px;}
4
- .a26rpox-abbrCompact{padding-left:3px;padding-right:2px;text-align:center;min-width:16px;}
5
- .a1x8jlwm-abbrVerticalCompact{padding-right:1px;padding-top:3px;padding-bottom:2px;padding-left:1px;writing-mode:vertical-lr;text-align:center;min-height:16px;}
6
- .tq1boe2-typeBadge{color:var(--fibery-type-badge-color);background-color:var(--fibery-type-badge-background-color);border-color:var(--fibery-type-badge-border-color);}
7
- .s10sagx9-selected{box-shadow:0 0 0 2px var(--fibery-type-badge-color-dark);}
8
- .cmf5kc4-clickable{cursor:pointer;}
9
- .f1whvqrd-faded{opacity:var(--opacity25);}
10
- .n1edvjqb-noColor{opacity:var(--opacity60);}
1
+ .s1qylqf5-small{display:grid;font-family:"Inter Variable","SF Pro Display",-apple-system,BlinkMacSystemFont,"Segoe UI Variable Display","Segoe UI",Roboto,Oxygen,Ubuntu,Cantarell,"Open Sans","Helvetica Neue",sans-serif;font-size:11px;line-height:1.1;letter-spacing:1.5px;text-transform:uppercase;font-weight:410;color:var(--textColor);outline:none;white-space:nowrap;transition:box-shadow 120ms ease-in-out;border-width:1px;border-style:solid;padding-top:1px;padding-bottom:1px;padding-left:5px;padding-right:4px;border-radius:4px;}
2
+ .m1m0uvhu-medium{display:inline-grid;font-family:"Inter Variable","SF Pro Display",-apple-system,BlinkMacSystemFont,"Segoe UI Variable Display","Segoe UI",Roboto,Oxygen,Ubuntu,Cantarell,"Open Sans","Helvetica Neue",sans-serif;font-size:11px;line-height:1.24;letter-spacing:1.5px;text-transform:uppercase;font-weight:410;color:var(--textColor);outline:none;white-space:nowrap;transition:box-shadow 120ms ease-in-out;border-width:1px;border-style:solid;padding-top:0;padding-bottom:0;padding-left:4px;padding-right:4px;border-radius:4px;}
3
+ .lhmelw4-large{display:inline-grid;font-family:"Inter Variable","SF Pro Display",-apple-system,BlinkMacSystemFont,"Segoe UI Variable Display","Segoe UI",Roboto,Oxygen,Ubuntu,Cantarell,"Open Sans","Helvetica Neue",sans-serif;font-size:12px;line-height:1;letter-spacing:2px;text-transform:uppercase;font-weight:500;color:var(--textColor);outline:none;white-space:nowrap;transition:box-shadow 120ms ease-in-out;border-width:1px;border-style:solid;padding-top:4px;padding-bottom:4px;padding-left:8px;padding-right:6px;border-radius:5px;}
4
+ .a26rpox-abbrHorizontal{text-align:center;min-width:16px;padding-left:3px;padding-right:2px;}
5
+ .a1x8jlwm-abbrHorizontalLarge{text-align:center;min-width:16px;padding-left:6px;padding-right:4px;}
6
+ .aq1boe2-abbrVertical{padding-right:1px;padding-top:3px;padding-bottom:2px;padding-left:1px;writing-mode:vertical-lr;text-align:center;min-height:16px;}
7
+ .t10sagx9-typeBadge{color:var(--fibery-type-badge-color);background-color:var(--fibery-type-badge-background-color);border-color:var(--fibery-type-badge-border-color);}
8
+ .smf5kc4-selected{box-shadow:0 0 0 2px var(--fibery-type-badge-color-dark);}
9
+ .c1whvqrd-clickable{cursor:pointer;}
10
+ .f1edvjqb-faded{opacity:var(--opacity25);}
11
+ .n1njzdi0-noColor{opacity:var(--opacity60);}
@@ -0,0 +1,12 @@
1
+ import { UnitChipProps, UnitTooltipConfig } from "./context.js";
2
+ import { ReactNode } from "react";
3
+ //#region src/unit/container.d.ts
4
+ type UnitContainerProps = UnitChipProps & {
5
+ inline?: boolean;
6
+ tooltip?: UnitTooltipConfig;
7
+ className?: string;
8
+ children?: ReactNode;
9
+ };
10
+ declare const UnitContainer: ({ size, inline, border, invalid, clickable, setMinWidth, setMinHeight, color, bgColor, fontWeight, tooltip, className, children }: UnitContainerProps) => import("react/jsx-runtime").JSX.Element;
11
+ //#endregion
12
+ export { UnitContainer, UnitContainerProps };
@@ -0,0 +1,50 @@
1
+ import { themeVars } from "../theming.generated.js";
2
+ import { UnitContext } from "./context.js";
3
+ import { basicUnitClassName, mediumSizeCss, smallSizeCss } from "./styles.js";
4
+ import { jsx } from "react/jsx-runtime";
5
+ import { useMemo } from "react";
6
+ import cx from "classnames";
7
+ //#region src/unit/container.tsx
8
+ var UnitContainer = ({ size = "small", inline = true, border = true, invalid = false, clickable = false, setMinWidth = true, setMinHeight = true, color = themeVars.textColor, bgColor = themeVars.transparent, fontWeight, tooltip, className, children }) => {
9
+ const contextValue = useMemo(() => ({
10
+ size,
11
+ chipProps: {
12
+ size,
13
+ border,
14
+ invalid,
15
+ clickable,
16
+ setMinWidth,
17
+ setMinHeight,
18
+ color,
19
+ bgColor,
20
+ fontWeight
21
+ },
22
+ tooltip
23
+ }), [
24
+ size,
25
+ border,
26
+ invalid,
27
+ clickable,
28
+ setMinWidth,
29
+ setMinHeight,
30
+ color,
31
+ bgColor,
32
+ fontWeight,
33
+ tooltip
34
+ ]);
35
+ return /* @__PURE__ */ jsx(UnitContext.Provider, {
36
+ value: contextValue,
37
+ children: /* @__PURE__ */ jsx("div", {
38
+ style: {
39
+ display: inline ? "inline-flex" : "flex",
40
+ color,
41
+ backgroundColor: bgColor || themeVars.inputDisabledBgColor,
42
+ fontWeight
43
+ },
44
+ className: cx(basicUnitClassName, size === "medium" ? mediumSizeCss : smallSizeCss, setMinWidth && (size === "medium" ? "m1yn8ezw-mediumSizeMinWidth" : "s45fj0l-smallSizeMinWidth"), setMinHeight && "updarf0-unitMinHeight", border && "b18mqj2f-border", invalid && "ibaz4qk-invalidUnit", clickable && "c14l2yxo-clickable", className),
45
+ children
46
+ })
47
+ });
48
+ };
49
+ //#endregion
50
+ export { UnitContainer };
@@ -0,0 +1,29 @@
1
+ import { ReactNode } from "react";
2
+ //#region src/unit/context.d.ts
3
+ type UnitSize = "small" | "medium";
4
+ type UnitChipProps = {
5
+ size?: UnitSize;
6
+ border?: boolean;
7
+ invalid?: boolean;
8
+ clickable?: boolean;
9
+ setMinWidth?: boolean;
10
+ setMinHeight?: boolean;
11
+ color?: string;
12
+ bgColor?: string | null;
13
+ fontWeight?: number;
14
+ };
15
+ type UnitTooltipConfig = {
16
+ title?: ReactNode;
17
+ fieldIcon?: string;
18
+ description?: ReactNode;
19
+ hint?: ReactNode;
20
+ };
21
+ type UnitContextValue = {
22
+ size: UnitSize;
23
+ chipProps: UnitChipProps;
24
+ tooltip?: UnitTooltipConfig;
25
+ };
26
+ declare const UnitContext: import("react").Context<UnitContextValue>;
27
+ declare const useUnitContext: () => UnitContextValue;
28
+ //#endregion
29
+ export { UnitChipProps, UnitContext, UnitContextValue, UnitSize, UnitTooltipConfig, useUnitContext };
@@ -0,0 +1,9 @@
1
+ import { createContext, useContext } from "react";
2
+ //#region src/unit/context.ts
3
+ var UnitContext = createContext({
4
+ size: "small",
5
+ chipProps: {}
6
+ });
7
+ var useUnitContext = () => useContext(UnitContext);
8
+ //#endregion
9
+ export { UnitContext, useUnitContext };
@@ -1,2 +1,4 @@
1
- import { Unit, UnitProps, UnitSize, UnitVariant } from "./unit.js";
2
- export { Unit, type UnitProps, type UnitSize, type UnitVariant };
1
+ import { UnitChipProps, UnitSize, UnitTooltipConfig, useUnitContext } from "./context.js";
2
+ import { UnitContainerProps } from "./container.js";
3
+ import { Unit, UnitProps, UnitVariant } from "./unit.js";
4
+ export { Unit, type UnitChipProps, type UnitContainerProps, type UnitProps, type UnitSize, type UnitTooltipConfig, type UnitVariant, useUnitContext };
package/lib/unit/index.js CHANGED
@@ -1,2 +1,3 @@
1
+ import { useUnitContext } from "./context.js";
1
2
  import { Unit } from "./unit.js";
2
- export { Unit };
3
+ export { Unit, useUnitContext };
@@ -0,0 +1,12 @@
1
+ import { UnitSize } from "./context.js";
2
+ import { ReactElement, ReactNode } from "react";
3
+ //#region src/unit/nav-button.d.ts
4
+ type UnitNavButtonProps = {
5
+ children: ReactNode;
6
+ };
7
+ declare const getNavButtonSize: (size: UnitSize) => number;
8
+ declare const UnitNavButton: ({ children }: UnitNavButtonProps) => ReactElement<{
9
+ style?: React.CSSProperties;
10
+ }, string | import("react").JSXElementConstructor<any>>;
11
+ //#endregion
12
+ export { UnitNavButton, UnitNavButtonProps, getNavButtonSize };
@@ -0,0 +1,18 @@
1
+ import { space } from "../design-system/layout.js";
2
+ import { useUnitContext } from "./context.js";
3
+ import { getHeight } from "./unit-content-layout.js";
4
+ import { Children, cloneElement } from "react";
5
+ //#region src/unit/nav-button.tsx
6
+ var getNavButtonSize = (size) => getHeight(size) + 2 * space.s2;
7
+ var UnitNavButton = ({ children }) => {
8
+ const { size } = useUnitContext();
9
+ const element = Children.only(children);
10
+ const slotSize = getNavButtonSize(size);
11
+ return cloneElement(element, { style: {
12
+ ...element.props.style,
13
+ width: slotSize,
14
+ height: slotSize
15
+ } });
16
+ };
17
+ //#endregion
18
+ export { UnitNavButton, getNavButtonSize };
@@ -1,19 +1,16 @@
1
1
  //#region src/unit/styles.d.ts
2
- declare const textEllipsisClassName: import("@linaria/core").LinariaClassName;
3
2
  declare const basicUnitClassName: import("@linaria/core").LinariaClassName;
4
3
  declare const alignCenterClassName: import("@linaria/core").LinariaClassName;
5
- declare const regularTextUnitSize: number;
4
+ declare const mediumTextUnitSize: number;
6
5
  declare const smallTextUnitSize: number;
7
- declare const bigSizeUnitClassName: import("@linaria/core").LinariaClassName;
8
- declare const bigSizeUnitMinWidthClassName: import("@linaria/core").LinariaClassName;
9
- declare const regularSizeUnitClassName: import("@linaria/core").LinariaClassName;
10
- declare const regularSizeUnitMinWidthClassName: import("@linaria/core").LinariaClassName;
6
+ declare const mediumSizeCss: import("@linaria/core").LinariaClassName;
7
+ declare const mediumSizeMinWidthCss: import("@linaria/core").LinariaClassName;
8
+ declare const smallSizeCss: import("@linaria/core").LinariaClassName;
9
+ declare const smallSizeMinWidthCss: import("@linaria/core").LinariaClassName;
11
10
  declare const unitMinHeightClassName: import("@linaria/core").LinariaClassName;
12
11
  declare const invalidUnitClassName: import("@linaria/core").LinariaClassName;
13
12
  declare const clickableClassName: import("@linaria/core").LinariaClassName;
14
13
  declare const borderClassName: import("@linaria/core").LinariaClassName;
15
- declare const pillRadiusClassName: import("@linaria/core").LinariaClassName;
16
- declare const fullUnitWrapperClassName: import("@linaria/core").LinariaClassName;
17
14
  declare const positionUnitClass: import("@linaria/core").LinariaClassName;
18
15
  //#endregion
19
- export { alignCenterClassName, basicUnitClassName, bigSizeUnitClassName, bigSizeUnitMinWidthClassName, borderClassName, clickableClassName, fullUnitWrapperClassName, invalidUnitClassName, pillRadiusClassName, positionUnitClass, regularSizeUnitClassName, regularSizeUnitMinWidthClassName, regularTextUnitSize, smallTextUnitSize, textEllipsisClassName, unitMinHeightClassName };
16
+ export { alignCenterClassName, basicUnitClassName, borderClassName, clickableClassName, invalidUnitClassName, mediumSizeCss, mediumSizeMinWidthCss, mediumTextUnitSize, positionUnitClass, smallSizeCss, smallSizeMinWidthCss, smallTextUnitSize, unitMinHeightClassName };