@adamjanicki/ui-extended 1.1.8 → 1.2.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.
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import Popover from "./Popover";
3
- import { IconInput } from "@adamjanicki/ui";
3
+ import { IconInput, ui } from "@adamjanicki/ui";
4
4
  type Props<T> = {
5
5
  /**
6
6
  * The value of the input field
@@ -71,11 +71,11 @@ type Props<T> = {
71
71
  /**
72
72
  * Props for the list element
73
73
  */
74
- listProps?: React.ComponentProps<"ul">;
74
+ listProps?: React.ComponentProps<typeof ui.ul>;
75
75
  /**
76
76
  * Props for the list item elements
77
77
  */
78
- listItemProps?: React.ComponentProps<"li">;
78
+ listItemProps?: React.ComponentProps<typeof ui.li>;
79
79
  /**
80
80
  * Footer node to render at the bottom of the popover
81
81
  */
@@ -20,12 +20,12 @@ var __rest = (this && this.__rest) || function (s, e) {
20
20
  }
21
21
  return t;
22
22
  };
23
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
23
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
24
24
  import React from "react";
25
25
  import Popover from "./Popover";
26
- import { Box, ClickOutside, IconInput } from "@adamjanicki/ui";
26
+ import { Box, ClickOutside, IconInput, ui } from "@adamjanicki/ui";
27
27
  import { classNames } from "@adamjanicki/ui/functions";
28
- var defaultRenderOption = function (option) { return (_jsx(Box, { layout: { padding: "s" }, children: "".concat(option) })); };
28
+ var defaultRenderOption = function (option) { return (_jsx(Box, { vfx: { padding: "s" }, children: "".concat(option) })); };
29
29
  var Autocomplete = function (props) {
30
30
  var _a, _b;
31
31
  var options = props.options, _c = props.renderOption, renderOption = _c === void 0 ? defaultRenderOption : _c, _d = props.filterOption, filterOption = _d === void 0 ? function () { return true; } : _d, groupBy = props.groupBy, renderGroup = props.renderGroup, noOptionsNode = props.noOptionsNode, _e = props.InputProps, InputProps = _e === void 0 ? {} : _e, _f = props.freeSolo, freeSolo = _f === void 0 ? false : _f, value = props.value, onInputChange = props.onInputChange, onSelect = props.onSelect, popoverProps = props.popoverProps, footer = props.footer, _g = props.listItemProps, listItemProps = _g === void 0 ? {} : _g, _h = props.listProps, listProps = _h === void 0 ? {} : _h, onUnselectedEnter = props.onUnselectedEnter, _j = props.closeOnFooterClick, closeOnFooterClick = _j === void 0 ? true : _j, _k = props.remainOpenOnSelectOrEnter, remainOpenOnSelectOrEnter = _k === void 0 ? false : _k, rest = __rest(props, ["options", "renderOption", "filterOption", "groupBy", "renderGroup", "noOptionsNode", "InputProps", "freeSolo", "value", "onInputChange", "onSelect", "popoverProps", "footer", "listItemProps", "listProps", "onUnselectedEnter", "closeOnFooterClick", "remainOpenOnSelectOrEnter"]);
@@ -126,15 +126,20 @@ var Autocomplete = function (props) {
126
126
  if (!open) {
127
127
  openMenu();
128
128
  }
129
- }, ref: inputRef, autoComplete: "off" }) })), _jsxs(Popover, __assign({}, popoverProps, { open: popoverOpen, triggerRef: inputContainerRef, layout: { padding: "none", margin: "none" }, style: __assign(__assign({}, popoverProps === null || popoverProps === void 0 ? void 0 : popoverProps.style), { width: (_b = (_a = inputContainerRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) !== null && _b !== void 0 ? _b : 0 }), className: classNames("aui-autocomplete-popover", popoverProps === null || popoverProps === void 0 ? void 0 : popoverProps.className), children: [_jsx("ul", __assign({}, listProps, { className: classNames("aui-autocomplete-ul aui-pa-s aui-ma-none", listProps.className), children: filteredOptions.length
130
- ? filteredOptions.map(function (option, index) {
131
- var group = groupMap.get(index);
132
- var ref = index === on ? onRef : undefined;
133
- return (_jsxs(React.Fragment, { children: [group && ((renderGroup === null || renderGroup === void 0 ? void 0 : renderGroup(group)) || group), _jsx("li", __assign({}, listItemProps, { ref: ref, onMouseEnter: function () { return setOn(index); }, className: classNames("aui-autocomplete-li", on === index
134
- ? "aui-autocomplete-on-option"
135
- : undefined, listItemProps.className), onClick: function () { return handleChange(option); }, children: renderOption(option) }))] }, index));
136
- })
137
- : !freeSolo &&
138
- (noOptionsNode || defaultRenderOption("No results found")) })), !!footer && (_jsx(Box, { onClick: closeOnFooterClick ? closeMenu : undefined, children: _jsx(_Fragment, { children: footer }) }))] }))] })) }));
129
+ }, ref: inputRef, autoComplete: "off" }) })), _jsxs(Popover, __assign({}, popoverProps, { open: popoverOpen, triggerRef: inputContainerRef, vfx: {
130
+ padding: "none",
131
+ margin: "none",
132
+ overflow: "hidden",
133
+ fontWeight: 4,
134
+ }, style: __assign(__assign({}, popoverProps === null || popoverProps === void 0 ? void 0 : popoverProps.style), { width: (_b = (_a = inputContainerRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) !== null && _b !== void 0 ? _b : 0 }), children: [_jsx(ui.ul, __assign({}, listProps, { vfx: __assign({ axis: "y", padding: "s", margin: "none", overflow: "scroll" }, listProps.vfx), style: __assign({ maxHeight: 300 }, listProps.style), tabIndex: -1, children: _jsx(_Fragment, { children: filteredOptions.length
135
+ ? filteredOptions.map(function (option, index) {
136
+ var group = groupMap.get(index);
137
+ var ref = index === on ? onRef : undefined;
138
+ return (_jsxs(React.Fragment, { children: [group && ((renderGroup === null || renderGroup === void 0 ? void 0 : renderGroup(group)) || group), _jsx(ui.li, __assign({}, listItemProps, { vfx: __assign({ axis: "x", cursor: "pointer", radius: "rounded" }, listItemProps.vfx), ref: ref, onMouseEnter: function () { return setOn(index); }, className: classNames(on === index
139
+ ? "aui-autocomplete-on-option"
140
+ : undefined, listItemProps.className), onClick: function () { return handleChange(option); }, children: _jsx(_Fragment, { children: renderOption(option) }) }))] }, index));
141
+ })
142
+ : !freeSolo &&
143
+ (noOptionsNode || defaultRenderOption("No results found")) }) })), !!footer && (_jsx(Box, { onClick: closeOnFooterClick ? closeMenu : undefined, children: _jsx(_Fragment, { children: footer }) }))] }))] })) }));
139
144
  };
140
145
  export default Autocomplete;
@@ -32,5 +32,5 @@ type Props = BoxProps & {
32
32
  returnFocusOnEscape?: boolean;
33
33
  };
34
34
  export declare const UnstyledPopover: (props: Props) => import("react/jsx-runtime").JSX.Element | null;
35
- declare const Popover: ({ className, layout, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
35
+ declare const Popover: ({ vfx, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
36
36
  export default Popover;
@@ -23,7 +23,6 @@ var __rest = (this && this.__rest) || function (s, e) {
23
23
  import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
24
24
  import Box from "@adamjanicki/ui/components/Box/Box";
25
25
  import { useFloating, autoUpdate, offset, useDismiss, useTransitionStyles, } from "@floating-ui/react";
26
- import { classNames } from "@adamjanicki/ui";
27
26
  export var UnstyledPopover = function (props) {
28
27
  var triggerRef = props.triggerRef, open = props.open, _a = props.placement, placement = _a === void 0 ? "bottom" : _a, style = props.style, _b = props.offset, placementOffset = _b === void 0 ? 0 : _b, children = props.children, onClose = props.onClose, _c = props.returnFocusOnEscape, returnFocusOnEscape = _c === void 0 ? false : _c, rest = __rest(props, ["triggerRef", "open", "placement", "style", "offset", "children", "onClose", "returnFocusOnEscape"]);
29
28
  var handleOnClose = function () {
@@ -51,7 +50,7 @@ export var UnstyledPopover = function (props) {
51
50
  return isMounted ? (_jsx(Box, __assign({ ref: refs.setFloating, style: __assign(__assign(__assign({}, floatingStyles), transitionStyles), style) }, rest, { children: _jsx(_Fragment, { children: children }) }))) : null;
52
51
  };
53
52
  var Popover = function (_a) {
54
- var className = _a.className, layout = _a.layout, rest = __rest(_a, ["className", "layout"]);
55
- return (_jsx(UnstyledPopover, __assign({ className: classNames("aui-popover", className), layout: __assign({ padding: "s" }, layout) }, rest)));
53
+ var vfx = _a.vfx, rest = __rest(_a, ["vfx"]);
54
+ return (_jsx(UnstyledPopover, __assign({ vfx: __assign({ padding: "s", backgroundColor: "default", border: true, shadow: "floating", radius: "rounded", z: "floating" }, vfx) }, rest)));
56
55
  };
57
56
  export default Popover;
@@ -32,5 +32,5 @@ type Props = Omit<BoxProps, "children" | "onMouseEnter" | "onMouseLeave"> & {
32
32
  disabled?: boolean;
33
33
  };
34
34
  export declare const UnstyledTooltip: (props: Props) => import("react/jsx-runtime").JSX.Element;
35
- export declare const Tooltip: ({ className, layout, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
35
+ export declare const Tooltip: ({ vfx, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
36
36
  export default Tooltip;
@@ -24,7 +24,6 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
24
24
  import { cloneElement, useState } from "react";
25
25
  import Box from "@adamjanicki/ui/components/Box/Box";
26
26
  import { useFloating, useHover, useInteractions, flip, safePolygon, autoUpdate, offset, useTransitionStyles, } from "@floating-ui/react";
27
- import { classNames } from "@adamjanicki/ui";
28
27
  export var UnstyledTooltip = function (props) {
29
28
  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, _c = props.disableFlip, disableFlip = _c === void 0 ? false : _c, _d = props.disabled, disabled = _d === void 0 ? false : _d, rest = __rest(props, ["children", "tooltipContent", "placement", "style", "offset", "disableFlip", "disabled"]);
30
29
  var _e = useState(false), open = _e[0], setOpen = _e[1];
@@ -53,7 +52,7 @@ export var UnstyledTooltip = function (props) {
53
52
  return (_jsxs(_Fragment, { children: [cloneElement(children, __assign({ ref: refs.setReference }, getReferenceProps())), isMounted && (_jsx(Box, __assign({ ref: refs.setFloating, style: __assign(__assign(__assign({}, floatingStyles), transitionStyles), style) }, { onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave }, rest, { children: _jsx(_Fragment, { children: content }) })))] }));
54
53
  };
55
54
  export var Tooltip = function (_a) {
56
- var className = _a.className, layout = _a.layout, rest = __rest(_a, ["className", "layout"]);
57
- return (_jsx(UnstyledTooltip, __assign({ className: classNames("aui-tooltip", className), layout: __assign({ padding: "s" }, layout) }, rest)));
55
+ var vfx = _a.vfx, rest = __rest(_a, ["vfx"]);
56
+ return (_jsx(UnstyledTooltip, __assign({ vfx: __assign({ padding: "s", backgroundColor: "default", border: true, shadow: "floating", radius: "rounded", z: "floating" }, vfx) }, rest)));
58
57
  };
59
58
  export default Tooltip;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adamjanicki/ui-extended",
3
- "version": "1.1.8",
3
+ "version": "1.2.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.6.3",
25
+ "@adamjanicki/ui": "^1.7.6",
26
26
  "@floating-ui/react": "^0.26.17"
27
27
  },
28
28
  "devDependencies": {
package/style.css CHANGED
@@ -12,32 +12,3 @@
12
12
  background-color: var(--aui-autocomplete-highlighted);
13
13
  }
14
14
  }
15
-
16
- .aui-autocomplete-popover {
17
- font-weight: 400;
18
- overflow: hidden;
19
- padding: 0;
20
- }
21
-
22
- .aui-autocomplete-ul {
23
- overflow: scroll;
24
- max-height: 300px;
25
- display: flex;
26
- flex-direction: column;
27
- outline: none;
28
- }
29
-
30
- .aui-autocomplete-li {
31
- display: flex;
32
- cursor: pointer;
33
- border-radius: var(--aui-rounded-radius);
34
- }
35
-
36
- .aui-tooltip,
37
- .aui-popover {
38
- background-color: var(--aui-default-background);
39
- border: 1px solid var(--aui-default-border);
40
- box-shadow: var(--aui-floating-box-shadow);
41
- border-radius: var(--aui-rounded-radius);
42
- z-index: 1000;
43
- }