@youngonesworks/ui 0.1.104 → 0.1.105

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.
package/dist/index.js CHANGED
@@ -7,12 +7,12 @@ import { IconAlertCircle, IconAlertTriangle, IconArrowNarrowLeft, IconBold, Icon
7
7
  import clsx from "clsx";
8
8
  import { twMerge } from "tailwind-merge";
9
9
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
10
- import { Tooltip as Tooltip$1 } from "react-tooltip";
10
+ import { FloatingArrow, FloatingFocusManager, FloatingPortal, arrow, autoUpdate, flip, offset, shift, useClick, useDismiss, useFloating, useFocus, useHover, useInteractions, useRole } from "@floating-ui/react";
11
11
  import { DayPicker, useDayPicker } from "react-day-picker";
12
12
  import { addMonths, format, setMonth } from "date-fns";
13
13
  import { enGB, fr, nl, nlBE } from "date-fns/locale";
14
- import { FloatingArrow, FloatingFocusManager, FloatingPortal, arrow, autoUpdate, flip, offset, shift, useClick, useDismiss, useFloating, useFocus, useHover, useInteractions, useRole } from "@floating-ui/react";
15
14
  import { createPortal } from "react-dom";
15
+ import { Tooltip as Tooltip$1 } from "react-tooltip";
16
16
  import { Placeholder } from "@tiptap/extension-placeholder";
17
17
  import { Underline } from "@tiptap/extension-underline";
18
18
  import { EditorContent, useEditor } from "@tiptap/react";
@@ -92,6 +92,113 @@ const AccordionWrapper = ({ children, className }) => /* @__PURE__ */ jsx("div",
92
92
  children
93
93
  });
94
94
 
95
+ //#endregion
96
+ //#region src/hooks/useMergeRefs.ts
97
+ function useMergeRefs(...refs) {
98
+ return useCallback((value) => {
99
+ refs.forEach((ref) => {
100
+ if (typeof ref === "function") {
101
+ ref(value);
102
+ } else if (ref) {
103
+ ref.current = value;
104
+ }
105
+ });
106
+ }, [refs]);
107
+ }
108
+
109
+ //#endregion
110
+ //#region src/components/tooltip/index.tsx
111
+ const sizeClasses = {
112
+ xs: "max-w-xs",
113
+ sm: "max-w-sm",
114
+ md: "max-w-md",
115
+ lg: "max-w-lg"
116
+ };
117
+ const Tooltip = ({ content, children, passedOpen = false, size = "md", variant = "default" }) => {
118
+ const [isOpen, setIsOpen] = useState(passedOpen);
119
+ const arrowRef = useRef(null);
120
+ const { refs, floatingStyles, context } = useFloating({
121
+ open: isOpen,
122
+ onOpenChange: setIsOpen,
123
+ placement: "top",
124
+ middleware: [
125
+ variant === "default" ? offset(20) : offset(25),
126
+ flip(),
127
+ shift(),
128
+ arrow({ element: arrowRef })
129
+ ],
130
+ whileElementsMounted: autoUpdate
131
+ });
132
+ const hover = useHover(context, { move: false });
133
+ const focus = useFocus(context);
134
+ const dismiss = useDismiss(context);
135
+ const role = useRole(context, { role: "tooltip" });
136
+ const { getReferenceProps, getFloatingProps } = useInteractions([
137
+ hover,
138
+ focus,
139
+ dismiss,
140
+ role
141
+ ]);
142
+ const childRef = children.ref;
143
+ const mergedRef = useMergeRefs(refs.setReference, childRef);
144
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [isValidElement(children) && cloneElement(children, getReferenceProps({
145
+ ...children.props,
146
+ ...getReferenceProps(),
147
+ ref: mergedRef
148
+ })), isOpen && /* @__PURE__ */ jsx("div", {
149
+ ref: refs.setFloating,
150
+ style: floatingStyles,
151
+ ...getFloatingProps(),
152
+ className: "z-70 drop-shadow-xl",
153
+ "data-testid": "tooltip",
154
+ "data-component": "tooltip",
155
+ children: variant === "default" ? /* @__PURE__ */ jsxs("div", {
156
+ "data-testid": "tooltip-container",
157
+ className: "w-full rounded bg-gray-800 pt-[3px] text-white",
158
+ children: [/* @__PURE__ */ jsx("div", {
159
+ "data-testid": "tooltip-content",
160
+ className: `${sizeClasses[size]} px-2 py-1 text-sm font-normal`,
161
+ children: content
162
+ }), /* @__PURE__ */ jsx(FloatingArrow, {
163
+ ref: arrowRef,
164
+ context,
165
+ width: 10,
166
+ height: 6,
167
+ tipRadius: 1,
168
+ "data-testid": "tooltip-arrow",
169
+ className: "fill-gray-800 drop-shadow-xl"
170
+ })]
171
+ }) : /* @__PURE__ */ jsxs("div", {
172
+ "data-testid": "tooltip-container",
173
+ className: "bg-linear-gradient-x pt-[3px]",
174
+ children: [/* @__PURE__ */ jsx("div", {
175
+ "data-testid": "tooltip-content",
176
+ className: `${sizeClasses[size]} overflow-hidden bg-white p-5 px-2 py-1 text-start text-sm font-normal`,
177
+ children: /* @__PURE__ */ jsx("p", { children: content })
178
+ }), size === "md" ? /* @__PURE__ */ jsx(FloatingArrow, {
179
+ ref: arrowRef,
180
+ context,
181
+ width: 25,
182
+ height: 17,
183
+ tipRadius: 1,
184
+ fill: "white",
185
+ className: "drop-shadow-xl",
186
+ "data-testid": "tooltip-arrow"
187
+ }) : /* @__PURE__ */ jsx(FloatingArrow, {
188
+ ref: arrowRef,
189
+ context,
190
+ width: 10,
191
+ height: 6,
192
+ tipRadius: 1,
193
+ fill: "white",
194
+ className: "drop-shadow-xl",
195
+ "data-testid": "tooltip-arrow"
196
+ })]
197
+ })
198
+ })] });
199
+ };
200
+ Tooltip.displayName = "Tooltip";
201
+
95
202
  //#endregion
96
203
  //#region src/utils/enums.ts
97
204
  let ACTION_ICON_STYLE_VARIANT = /* @__PURE__ */ function(ACTION_ICON_STYLE_VARIANT$1) {
@@ -169,34 +276,35 @@ function formatIcon(icon, defaultFormatAttributes) {
169
276
 
170
277
  //#endregion
171
278
  //#region src/components/actionIcon/index.tsx
172
- const ActionIcon = forwardRef(({ title, disabled = false, styleVariant = "default", icon, type = "button", "data-testid": testId, iconSize = 20, strokeWidth = 1, onClick, className,...props }, ref) => {
279
+ const ActionIcon = ({ ref, title, disabled = false, styleVariant = "default", icon, type = "button", "data-testid": testId, iconSize = 20, strokeWidth = 1, onClick, className,...props }) => {
173
280
  const variantClassNames = clsx({
174
281
  "active:translate-y-[1px] content-center flex items-center justify-center rounded-[4px] border border-gray-200 hover:border-black text-black child:p-10 w-[36px] h-[36px] disabled:text-gray-500": styleVariant === ACTION_ICON_STYLE_VARIANT.DEFAULT,
175
282
  "active:translate-y-[1px] border-none content-center flex items-center justify-center rounded-[4px] border text-black child:p-10 w-[36px] h-[36px] disabled:text-gray-500": styleVariant === ACTION_ICON_STYLE_VARIANT.TRANSPARENT,
176
283
  "active:translate-y-[1px] content-center flex items-center justify-center rounded-[4px] child:p-10 w-[37px] h-[37px] text-black rounded-full bg-primary hover:bg-turquoise-700 disabled:turquoise-50 disabled:text-gray-800": styleVariant === ACTION_ICON_STYLE_VARIANT.ROUND,
177
284
  "w-7 h-7 active:translate-y-[1px] content-center flex items-center justify-center rounded-[4px] border border-gray-200 hover:border-black text-black hover:bg-gray-50 disabled:text-gray-500": styleVariant === ACTION_ICON_STYLE_VARIANT.SMALL
178
285
  });
179
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("button", {
180
- title,
181
- type,
182
- disabled,
183
- "data-testid": testId,
184
- "data-component": "ActionIcon",
185
- className: cn(variantClassNames, { "hover:bg-transparant cursor-not-allowed hover:border-gray-200": disabled }, className),
186
- onClick,
187
- ref,
188
- "data-tooltip-id": title,
189
- "data-tooltip-content": title,
190
- ...props,
191
- children: icon ? formatIcon(icon, {
192
- stroke: strokeWidth,
193
- size: iconSize
194
- }) : props.children
195
- }), /* @__PURE__ */ jsx(Tooltip$1, {
196
- id: title,
197
- className: "z-[99]"
198
- })] });
199
- });
286
+ return /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(Tooltip, {
287
+ size: "sm",
288
+ content: title,
289
+ children: /* @__PURE__ */ jsx("button", {
290
+ title,
291
+ type,
292
+ disabled,
293
+ "data-testid": testId,
294
+ "data-component": "ActionIcon",
295
+ className: cn(variantClassNames, { "hover:bg-transparant cursor-not-allowed hover:border-gray-200": disabled }, className),
296
+ onClick,
297
+ ref,
298
+ "data-tooltip-id": title,
299
+ "data-tooltip-content": title,
300
+ ...props,
301
+ children: icon ? formatIcon(icon, {
302
+ stroke: strokeWidth,
303
+ size: iconSize
304
+ }) : props.children
305
+ })
306
+ }) });
307
+ };
200
308
  ActionIcon.displayName = "ActionIcon";
201
309
 
202
310
  //#endregion
@@ -1490,100 +1598,9 @@ const Island = ({ children, className, noShadow = false, noPadding = false,...pr
1490
1598
  });
1491
1599
  Island.displayName = "Island";
1492
1600
 
1493
- //#endregion
1494
- //#region src/components/tooltip/index.tsx
1495
- const sizeClasses = {
1496
- xs: "max-w-xs",
1497
- sm: "max-w-sm",
1498
- md: "max-w-md",
1499
- lg: "max-w-lg"
1500
- };
1501
- const Tooltip = ({ content, children, passedOpen = false, size = "md", variant = "default" }) => {
1502
- const [isOpen, setIsOpen] = useState(passedOpen);
1503
- const arrowRef = useRef(null);
1504
- const { refs, floatingStyles, context } = useFloating({
1505
- open: isOpen,
1506
- onOpenChange: setIsOpen,
1507
- placement: "top",
1508
- middleware: [
1509
- variant === "default" ? offset(20) : offset(25),
1510
- flip(),
1511
- shift(),
1512
- arrow({ element: arrowRef })
1513
- ],
1514
- whileElementsMounted: autoUpdate
1515
- });
1516
- const hover = useHover(context, { move: false });
1517
- const focus = useFocus(context);
1518
- const dismiss = useDismiss(context);
1519
- const role = useRole(context, { role: "tooltip" });
1520
- const { getReferenceProps, getFloatingProps } = useInteractions([
1521
- hover,
1522
- focus,
1523
- dismiss,
1524
- role
1525
- ]);
1526
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [isValidElement(children) && cloneElement(children, getReferenceProps({
1527
- ref: refs.setReference,
1528
- ...children.props,
1529
- ...getReferenceProps()
1530
- })), isOpen && /* @__PURE__ */ jsx("div", {
1531
- ref: refs.setFloating,
1532
- style: floatingStyles,
1533
- ...getFloatingProps(),
1534
- className: "z-70 drop-shadow-xl",
1535
- "data-testid": "tooltip",
1536
- "data-component": "tooltip",
1537
- children: variant === "default" ? /* @__PURE__ */ jsxs("div", {
1538
- "data-testid": "tooltip-container",
1539
- className: "w-full rounded bg-gray-800 pt-[3px] text-white",
1540
- children: [/* @__PURE__ */ jsx("div", {
1541
- "data-testid": "tooltip-content",
1542
- className: `${sizeClasses[size]} px-2 py-1 text-sm font-normal`,
1543
- children: content
1544
- }), /* @__PURE__ */ jsx(FloatingArrow, {
1545
- ref: arrowRef,
1546
- context,
1547
- width: 10,
1548
- height: 6,
1549
- tipRadius: 1,
1550
- "data-testid": "tooltip-arrow",
1551
- className: "fill-gray-800 drop-shadow-xl"
1552
- })]
1553
- }) : /* @__PURE__ */ jsxs("div", {
1554
- "data-testid": "tooltip-container",
1555
- className: "bg-linear-gradient-x pt-[3px]",
1556
- children: [/* @__PURE__ */ jsx("div", {
1557
- "data-testid": "tooltip-content",
1558
- className: `${sizeClasses[size]} overflow-hidden bg-white p-5 px-2 py-1 text-start text-sm font-normal`,
1559
- children: /* @__PURE__ */ jsx("p", { children: content })
1560
- }), size === "md" ? /* @__PURE__ */ jsx(FloatingArrow, {
1561
- ref: arrowRef,
1562
- context,
1563
- width: 25,
1564
- height: 17,
1565
- tipRadius: 1,
1566
- fill: "white",
1567
- className: "drop-shadow-xl",
1568
- "data-testid": "tooltip-arrow"
1569
- }) : /* @__PURE__ */ jsx(FloatingArrow, {
1570
- ref: arrowRef,
1571
- context,
1572
- width: 10,
1573
- height: 6,
1574
- tipRadius: 1,
1575
- fill: "white",
1576
- className: "drop-shadow-xl",
1577
- "data-testid": "tooltip-arrow"
1578
- })]
1579
- })
1580
- })] });
1581
- };
1582
- Tooltip.displayName = "Tooltip";
1583
-
1584
1601
  //#endregion
1585
1602
  //#region src/components/kebabMenu/index.tsx
1586
- const KebabMenu = ({ title, content, disabled = false, styleVariant = "default" }) => {
1603
+ const KebabMenu = ({ title, tooltip, content, disabled = false, styleVariant = "default" }) => {
1587
1604
  const [isOpen, setIsOpen] = useState(false);
1588
1605
  const menuRef = useRef(null);
1589
1606
  const defaultStyling = "text-black flex items-center justify-self-end gap-1 bg-transparent font-medium py-1 h-9 min-w-9 cursor-pointer px-0";
@@ -1605,6 +1622,28 @@ const KebabMenu = ({ title, content, disabled = false, styleVariant = "default"
1605
1622
  document.removeEventListener("mousedown", handleClickOutside);
1606
1623
  };
1607
1624
  }, []);
1625
+ const button = useMemo(() => /* @__PURE__ */ jsxs(UnstyledButton, {
1626
+ "aria-label": "Options Menu",
1627
+ className: cn(buttonVariants["secondary"], defaultStyling, {
1628
+ "md:pr-3.5 md:pl-5": title,
1629
+ "h-7 min-w-7": styleVariant === "small"
1630
+ }),
1631
+ disabled,
1632
+ onClick: handleToggle,
1633
+ children: [title && /* @__PURE__ */ jsx("span", {
1634
+ className: "hidden md:block",
1635
+ children: title
1636
+ }), /* @__PURE__ */ jsx(IconDotsVertical, {
1637
+ size: 20,
1638
+ stroke: 1,
1639
+ fill: "black"
1640
+ })]
1641
+ }), [
1642
+ title,
1643
+ styleVariant,
1644
+ disabled,
1645
+ handleToggle
1646
+ ]);
1608
1647
  return /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsxs("div", {
1609
1648
  className: "relative",
1610
1649
  "data-component": "kebabMenu",
@@ -1612,26 +1651,15 @@ const KebabMenu = ({ title, content, disabled = false, styleVariant = "default"
1612
1651
  ref: menuRef,
1613
1652
  "data-tooltip-id": title,
1614
1653
  "data-tooltip-content": title,
1615
- children: [/* @__PURE__ */ jsxs(UnstyledButton, {
1616
- "aria-label": "Options Menu",
1617
- className: cn(buttonVariants["secondary"], defaultStyling, {
1618
- "md:pr-3.5 md:pl-5": title,
1619
- "h-7 min-w-7": styleVariant === "small"
1620
- }),
1621
- disabled,
1622
- onClick: handleToggle,
1623
- children: [title && /* @__PURE__ */ jsx("span", {
1624
- className: "hidden md:block",
1625
- children: title
1626
- }), /* @__PURE__ */ jsx(IconDotsVertical, {
1627
- size: 20,
1628
- stroke: 1,
1629
- fill: "black"
1630
- })]
1631
- }), isOpen && /* @__PURE__ */ jsx("div", {
1654
+ children: [tooltip ? /* @__PURE__ */ jsx(Tooltip, {
1655
+ passedOpen: false,
1656
+ size: "sm",
1657
+ content: tooltip,
1658
+ children: button
1659
+ }) : button, isOpen && /* @__PURE__ */ jsx("div", {
1632
1660
  className: "absolute right-0 z-10 mt-2 w-auto min-w-[200px] rounded-md border-[0.0625rem] border-gray-200 bg-white p-1 shadow-md",
1633
1661
  children: content.map((c, index) => {
1634
- const button = /* @__PURE__ */ jsx(UnstyledButton, {
1662
+ const button$1 = /* @__PURE__ */ jsx(UnstyledButton, {
1635
1663
  onClick: () => handleItemClick(c.onClick),
1636
1664
  className: "w-full rounded-md px-4 py-2 text-left text-sm font-normal whitespace-nowrap hover:bg-gray-50",
1637
1665
  "aria-label": "Options Menu Item",
@@ -1642,8 +1670,8 @@ const KebabMenu = ({ title, content, disabled = false, styleVariant = "default"
1642
1670
  passedOpen: false,
1643
1671
  size: "sm",
1644
1672
  content: c.tooltip,
1645
- children: button
1646
- }, index) : /* @__PURE__ */ jsx(React.Fragment, { children: button }, index);
1673
+ children: button$1
1674
+ }, index) : /* @__PURE__ */ jsx(React.Fragment, { children: button$1 }, index);
1647
1675
  })
1648
1676
  })]
1649
1677
  }) });
@@ -2301,20 +2329,6 @@ function useDebouncedValue(value, delay = 200) {
2301
2329
  return debouncedValue;
2302
2330
  }
2303
2331
 
2304
- //#endregion
2305
- //#region src/hooks/useMergeRefs.ts
2306
- function useMergeRefs(...refs) {
2307
- return useCallback((value) => {
2308
- refs.forEach((ref) => {
2309
- if (typeof ref === "function") {
2310
- ref(value);
2311
- } else if (ref) {
2312
- ref.current = value;
2313
- }
2314
- });
2315
- }, [refs]);
2316
- }
2317
-
2318
2332
  //#endregion
2319
2333
  //#region src/components/select/index.tsx
2320
2334
  function Select({ id, options, placeholder, label, errorText, hideError = false, isClearable = false, disabled = false, multiSelect = false, searchable = false, value, defaultValue, onValueChange, className, searchPlaceholder, noResultsText,...props }) {