@adamjanicki/ui-extended 1.0.8 → 1.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.
@@ -25,7 +25,7 @@ import React from "react";
25
25
  import Popover from "./Popover";
26
26
  import ClickOutside from "@adamjanicki/ui/components/ClickOutside";
27
27
  import { IconInput } from "@adamjanicki/ui";
28
- import { classNames } from "@adamjanicki/ui/utils/util";
28
+ import { classNames } from "@adamjanicki/ui/functions";
29
29
  var defaultRenderOption = function (option) { return (_jsx("div", { className: "ajui-autocomplete-default-rendering", children: "".concat(option) })); };
30
30
  var Autocomplete = function (props) {
31
31
  var _a, _b;
@@ -1,3 +1,4 @@
1
+ import React from "react";
1
2
  import { type Placement } from "@floating-ui/react";
2
3
  type Props = {
3
4
  /**
@@ -31,6 +32,11 @@ type Props = {
31
32
  * Whether to disable the flip behavior of the tooltip.
32
33
  */
33
34
  disableFlip?: boolean;
35
+ /**
36
+ * Whether the tooltip is disabled. If true, will not show the tooltip.
37
+ * @default false
38
+ */
39
+ disabled?: boolean;
34
40
  };
35
41
  declare const Tooltip: (props: Props) => JSX.Element;
36
42
  export default Tooltip;
@@ -13,27 +13,29 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
13
13
  import { cloneElement, useState } from "react";
14
14
  import { useFloating, useHover, useInteractions, flip, safePolygon, autoUpdate, offset, useTransitionStyles, } from "@floating-ui/react";
15
15
  var Tooltip = function (props) {
16
- var children = props.children, content = props.tooltipContent, _a = props.placement, placement = _a === void 0 ? "bottom" : _a, style = props.style, _b = props.offset, placementOffset = _b === void 0 ? 0 : _b, className = props.className, _c = props.disableFlip, disableFlip = _c === void 0 ? false : _c;
17
- var _d = useState(false), open = _d[0], setOpen = _d[1];
16
+ var children = props.children, content = props.tooltipContent, _a = props.placement, placement = _a === void 0 ? "bottom" : _a, style = props.style, _b = props.offset, placementOffset = _b === void 0 ? 0 : _b, className = props.className, _c = props.disableFlip, disableFlip = _c === void 0 ? false : _c, _d = props.disabled, disabled = _d === void 0 ? false : _d;
17
+ var _e = useState(false), open = _e[0], setOpen = _e[1];
18
18
  var middleware = [offset(placementOffset)];
19
19
  if (!disableFlip) {
20
20
  middleware.push(flip());
21
21
  }
22
- var _e = useFloating({
22
+ var _f = useFloating({
23
23
  open: open,
24
24
  onOpenChange: setOpen,
25
25
  middleware: middleware,
26
26
  whileElementsMounted: autoUpdate,
27
27
  placement: placement,
28
- }), refs = _e.refs, floatingStyles = _e.floatingStyles, context = _e.context;
28
+ }), refs = _f.refs, floatingStyles = _f.floatingStyles, context = _f.context;
29
29
  var hover = useHover(context, {
30
30
  handleClose: safePolygon(),
31
31
  mouseOnly: true,
32
32
  });
33
- var _f = useTransitionStyles(context, {
33
+ var _g = useTransitionStyles(context, {
34
34
  duration: 250, // default ajui-transition value
35
- }), isMounted = _f.isMounted, transitionStyles = _f.styles;
36
- var _g = useInteractions([hover]), getReferenceProps = _g.getReferenceProps, getFloatingProps = _g.getFloatingProps;
35
+ }), isMounted = _g.isMounted, transitionStyles = _g.styles;
36
+ var _h = useInteractions([hover]), getReferenceProps = _h.getReferenceProps, getFloatingProps = _h.getFloatingProps;
37
+ if (disabled)
38
+ return children;
37
39
  return (_jsxs(_Fragment, { children: [cloneElement(children, __assign({ ref: refs.setReference }, getReferenceProps())), isMounted && (_jsx("div", __assign({ ref: refs.setFloating, style: __assign(__assign(__assign({}, (style || {})), floatingStyles), transitionStyles) }, getFloatingProps(), { className: className, children: content })))] }));
38
40
  };
39
41
  export default Tooltip;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adamjanicki/ui-extended",
3
- "version": "1.0.8",
3
+ "version": "1.1.0",
4
4
  "description": "More advanced UI components and hooks for React in TypeScript",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",
@@ -22,7 +22,7 @@
22
22
  "react-dom": ">=18"
23
23
  },
24
24
  "dependencies": {
25
- "@adamjanicki/ui": ">=1.0.3",
25
+ "@adamjanicki/ui": ">=1.3.6",
26
26
  "@floating-ui/react": ">=0.26.17"
27
27
  },
28
28
  "devDependencies": {
package/style.css CHANGED
@@ -35,8 +35,5 @@
35
35
  display: flex;
36
36
  cursor: pointer;
37
37
  border-radius: var(--ajui-rounded-radius);
38
- }
39
-
40
- .ajui-autocomplete-li > :first-child {
41
- border-radius: var(--ajui-rounded-radius);
38
+ overflow: hidden;
42
39
  }