@fibery/ui-kit 13.0.0 → 13.0.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.
@@ -6,9 +6,9 @@ import ClearInputFilled from "../icons/react/clear-input-filled.js";
6
6
  import { cx } from "@linaria/core";
7
7
  import { jsx, jsxs } from "react/jsx-runtime";
8
8
  import { forwardRef, useRef, useState } from "react";
9
+ import { useComposedRefs } from "@fibery/react/src/use-composed-refs";
9
10
  import { useControllableState } from "@fibery/react/src/use-controllable-state";
10
11
  import { styled } from "@linaria/react";
11
- import { useComposedRefs } from "@fibery/react/src/use-composed-refs";
12
12
  import { CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandRoot, CommandSeparator } from "cmdk";
13
13
  //#region src/command-menu/index.tsx
14
14
  var _exp = () => CommandRoot;
@@ -1,7 +1,9 @@
1
1
  import { Dispatch, SetStateAction } from "react";
2
+ import { DateRange } from "react-day-picker";
2
3
  //#region src/date-picker/contexts.d.ts
3
4
  export declare const StartEndFocusContext: import("react").Context<{
4
5
  focusOnStart: boolean;
5
6
  setFocusOnStart: Dispatch<SetStateAction<boolean>>;
7
+ onRangeClick: (range: DateRange) => void;
6
8
  }>;
7
9
  //#endregion
@@ -3,7 +3,8 @@ import { noop } from "@fibery/helpers/src/_";
3
3
  //#region src/date-picker/contexts.ts
4
4
  var StartEndFocusContext = createContext({
5
5
  focusOnStart: true,
6
- setFocusOnStart: noop
6
+ setFocusOnStart: noop,
7
+ onRangeClick: noop
7
8
  });
8
9
  //#endregion
9
10
  export { StartEndFocusContext };
@@ -10,6 +10,7 @@ import { DateRangeInput } from "./date-range-input.js";
10
10
  import { cx } from "@linaria/core";
11
11
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
12
12
  import { forwardRef, useCallback, useMemo, useRef, useState } from "react";
13
+ import { noop } from "@fibery/helpers/src/_";
13
14
  import enGB from "date-fns/locale/en-GB";
14
15
  import { DayPicker } from "react-day-picker";
15
16
  import { formatDuration, intervalToDuration, roundToNearestMinutes } from "date-fns";
@@ -44,7 +45,7 @@ var DateRangePickerPopupContent = forwardRef((props, ref) => {
44
45
  setPrevEndValue(null);
45
46
  setCurrentEndValue(null);
46
47
  }, [onChange]);
47
- const onDayClick = useCallback(({ from, to }) => {
48
+ const onRangeClick = useCallback(({ from, to }) => {
48
49
  if (!to) setCurrentStartValue(from ?? null);
49
50
  else {
50
51
  const { from: sortedFrom, to: sortedTo } = sortDates({
@@ -111,7 +112,8 @@ var DateRangePickerPopupContent = forwardRef((props, ref) => {
111
112
  /* @__PURE__ */ jsx(StartEndFocusContext.Provider, {
112
113
  value: {
113
114
  focusOnStart,
114
- setFocusOnStart
115
+ setFocusOnStart,
116
+ onRangeClick
115
117
  },
116
118
  children: /* @__PURE__ */ jsx(DayPicker, {
117
119
  mode: "default",
@@ -137,12 +139,10 @@ var DateRangePickerPopupContent = forwardRef((props, ref) => {
137
139
  from: currentStartValue || void 0,
138
140
  to: currentEndValue || void 0
139
141
  },
140
- onDayClick,
142
+ onDayClick: noop,
141
143
  disabled,
142
144
  locale: enGB,
143
145
  weekStartsOn,
144
- focusOnStart,
145
- setFocusOnStart,
146
146
  fixedWeeks: true
147
147
  })
148
148
  }),
@@ -19,7 +19,7 @@ var DayWithStartEndButtons = (props) => {
19
19
  const dayRender = useDayRender(props.date, props.displayMonth, buttonRef);
20
20
  const { focusDayAfter, focusDayBefore, focusWeekAfter, focusWeekBefore, focusMonthBefore, focusMonthAfter, focusYearBefore, focusYearAfter, focusStartOfWeek, focusEndOfWeek } = useFocusContext();
21
21
  const dayPicker = useDayPicker();
22
- const { focusOnStart, setFocusOnStart } = useContext(StartEndFocusContext);
22
+ const { focusOnStart, setFocusOnStart, onRangeClick } = useContext(StartEndFocusContext);
23
23
  const onKeyDown = (e) => {
24
24
  switch (e.key) {
25
25
  case "ArrowLeft":
@@ -68,28 +68,23 @@ var DayWithStartEndButtons = (props) => {
68
68
  };
69
69
  if (dayRender.isHidden) return /* @__PURE__ */ jsx(Fragment, {});
70
70
  if (!dayRender.isButton) return /* @__PURE__ */ jsx("div", { ...dayRender.divProps });
71
- const onDayClick = dayPicker.onDayClick;
72
71
  const selected = dayPicker?.selected;
73
72
  const from = selected?.from;
74
73
  const to = selected?.to;
75
74
  const current = props.date;
76
- const handleClickStart = (e) => {
77
- if (onDayClick) {
78
- onDayClick({
79
- from: current,
80
- to
81
- }, dayRender.activeModifiers, e);
82
- setFocusOnStart(true);
83
- }
75
+ const handleClickStart = () => {
76
+ onRangeClick({
77
+ from: current,
78
+ to
79
+ });
80
+ setFocusOnStart(true);
84
81
  };
85
- const handleClickEnd = (e) => {
86
- if (onDayClick) {
87
- onDayClick({
88
- from,
89
- to: current
90
- }, dayRender.activeModifiers, e);
91
- setFocusOnStart(false);
92
- }
82
+ const handleClickEnd = () => {
83
+ onRangeClick({
84
+ from,
85
+ to: current
86
+ });
87
+ setFocusOnStart(false);
93
88
  };
94
89
  const renderStart = from === void 0 || to === void 0 && isBefore(current, from) || isAfter(to, current) || isSameDay(to, current);
95
90
  const renderEnd = from !== void 0 && (isBefore(from, current) || isSameDay(from, current));
@@ -2,5 +2,5 @@
2
2
  .e1a8t525-emptyState{display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;gap:16px;padding:0 12px 48px 12px;}.evd7pvk-emptyStateAnchor .e1a8t525-emptyState{position:absolute;inset:0;justify-content:flex-start;padding:112px 12px 160px;pointer-events:none;}.evd7pvk-emptyStateAnchor .e1a8t525-emptyState >*{pointer-events:auto;}.evd7pvk-emptyStateAnchor .e1a8t525-emptyState >:first-child{margin-top:auto;}.evd7pvk-emptyStateAnchor .e1a8t525-emptyState >:last-child{margin-bottom:auto;}
3
3
  .s4xl8iq-stretch{height:100%;}
4
4
  .ccb77kb-content{display:flex;max-width:100%;flex-direction:column;align-items:center;gap:6px;}
5
- .h1tsx60n-heading{color:var(--fg);margin:0;}
6
- .drng4yd-description{color:var(--fg-subtle);margin:0;max-width:100%;}
5
+ .h1tsx60n-heading{color:var(--fg);margin:0;text-wrap:balance;}
6
+ .drng4yd-description{color:var(--fg-subtle);margin:0;text-wrap:balance;max-width:100%;}
@@ -17,11 +17,11 @@ import { jsx, jsxs } from "react/jsx-runtime";
17
17
  import { cloneElement, forwardRef, isValidElement, useCallback, useEffect, useId, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
18
18
  import { truthy } from "@fibery/helpers/src/_";
19
19
  import { createContext as createContext$1 } from "@fibery/react/src/create-context";
20
+ import { composeRefs, useComposedRefs } from "@fibery/react/src/use-composed-refs";
20
21
  import { composeEventHandlers } from "@fibery/react/src/compose-event-handlers";
21
22
  import { useControllableState } from "@fibery/react/src/use-controllable-state";
22
23
  import { createPortal } from "react-dom";
23
24
  import { stopPropagation } from "@fibery/react/src/stop-propagation";
24
- import { composeRefs, useComposedRefs } from "@fibery/react/src/use-composed-refs";
25
25
  import { usePointerDownOutside } from "@fibery/react/src/use-pointer-down-outside";
26
26
  import { createPopper } from "@popperjs/core";
27
27
  import { FocusScope } from "@radix-ui/react-focus-scope";
@@ -13,8 +13,8 @@ import { MenuListVirtua } from "./components/menu-list-virtua.js";
13
13
  import { jsx } from "react/jsx-runtime";
14
14
  import { forwardRef, useCallback, useMemo, useRef, useState } from "react";
15
15
  import { truthy } from "@fibery/helpers/src/_";
16
- import { composeEventHandlers } from "@fibery/react/src/compose-event-handlers";
17
16
  import { useComposedRefs } from "@fibery/react/src/use-composed-refs";
17
+ import { composeEventHandlers } from "@fibery/react/src/compose-event-handlers";
18
18
  import BaseSelect, { components as reactSelectComponents, createFilter, mergeStyles } from "react-select";
19
19
  import BaseCreatableSelect from "react-select/creatable";
20
20
  //#region src/select/select.tsx
@@ -5,9 +5,9 @@ import { cx } from "@linaria/core";
5
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
6
  import { forwardRef, useEffect, useLayoutEffect, useRef, useState } from "react";
7
7
  import { createContext as createContext$1 } from "@fibery/react/src/create-context";
8
+ import { useComposedRefs } from "@fibery/react/src/use-composed-refs";
8
9
  import { useResizeObserver } from "@fibery/react/src/use-resize-observer";
9
10
  import { useCallbackRef } from "@fibery/react/src/use-callback-ref";
10
- import { useComposedRefs } from "@fibery/react/src/use-composed-refs";
11
11
  import { NavigationMenu, NavigationMenuItem, NavigationMenuLink, NavigationMenuList } from "@radix-ui/react-navigation-menu";
12
12
  //#region src/tab-nav/tab-nav.tsx
13
13
  var positionIndicator = (indicator, activeItem) => {
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": "13.0.1",
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.1.0",
89
89
  "@fibery/icons": "0.1.0",
90
- "@fibery/react": "3.1.0",
90
+ "@fibery/react": "3.1.1",
91
91
  "@linaria/core": "8.2.0",
92
92
  "@linaria/react": "8.2.0",
93
93
  "@popperjs/core": "2.11.6",