@adamjanicki/ui 1.5.8 → 1.5.9

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,18 +1,10 @@
1
1
  import React from "react";
2
- import type { Style } from "../../utils/types";
3
- type Props = {
2
+ import { type BoxProps } from "../Box/Box";
3
+ type Props = Omit<BoxProps, "children"> & {
4
4
  /**
5
5
  * Drawers to render as accordion sections
6
6
  */
7
7
  drawers: Drawer[];
8
- /**
9
- * [Optional] additional class name to apply to the accordion
10
- */
11
- className?: string;
12
- /**
13
- * [Optional] additional styles to apply to the accordion
14
- */
15
- style?: Style;
16
8
  /**
17
9
  * Duration of the drawer animation (in seconds)
18
10
  */
@@ -23,7 +15,7 @@ type Props = {
23
15
  */
24
16
  hideDividers?: boolean;
25
17
  };
26
- declare const Accordion: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLDivElement>>;
18
+ declare const Accordion: React.ForwardRefExoticComponent<Omit<Props, "ref"> & React.RefAttributes<HTMLDivElement>>;
27
19
  type Drawer = {
28
20
  /**
29
21
  * Label for the accordion drawer
@@ -1,14 +1,36 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
1
23
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
24
  import React, { useState, useRef, useEffect } from "react";
3
- import Box from "../Box";
25
+ import Box from "../Box/Box";
4
26
  import Icon from "../Icon";
5
27
  import { UnstyledButton } from "../Button";
6
28
  import Animated from "../Animated";
7
29
  import { classNames } from "../../functions";
8
30
  var Accordion = React.forwardRef(function (_a, ref) {
9
- var drawers = _a.drawers, className = _a.className, style = _a.style, duration = _a.duration, hideDividers = _a.hideDividers;
31
+ var drawers = _a.drawers, className = _a.className, duration = _a.duration, hideDividers = _a.hideDividers, rest = __rest(_a, ["drawers", "className", "duration", "hideDividers"]);
10
32
  var _b = useState(new Set()), openIndices = _b[0], setOpenIndices = _b[1];
11
- return (_jsx(Box, { layout: { axis: "y" }, className: classNames("aui-accordion aui-corners--rounded", className), style: style, ref: ref, children: drawers.map(function (item, i) { return (_jsx(Drawer, { item: item, open: openIndices.has(i), onOpenChange: function (open) {
33
+ return (_jsx(Box, __assign({ layout: { axis: "y" } }, rest, { className: classNames("aui-accordion aui-corners--rounded", className), ref: ref, children: drawers.map(function (item, i) { return (_jsx(Drawer, { item: item, open: openIndices.has(i), onOpenChange: function (open) {
12
34
  return setOpenIndices(function (prev) {
13
35
  var next = new Set(prev);
14
36
  if (open) {
@@ -19,7 +41,7 @@ var Accordion = React.forwardRef(function (_a, ref) {
19
41
  }
20
42
  return next;
21
43
  });
22
- }, duration: duration, showDivider: !hideDividers && i < drawers.length - 1 }, i)); }) }));
44
+ }, duration: duration, showDivider: !hideDividers && i < drawers.length - 1 }, i)); }) })));
23
45
  });
24
46
  var Drawer = function (_a) {
25
47
  var item = _a.item, open = _a.open, onOpenChange = _a.onOpenChange, duration = _a.duration, showDivider = _a.showDivider;
@@ -1,20 +1,7 @@
1
1
  import React from "react";
2
- import { type CustomLinkElement } from "../Link/Link";
3
2
  import type { CornerType } from "../../utils/types";
4
- type DefaultButtonProps = React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement> & {
5
- /**
6
- * [Optional] This can be used as a link if the `to` prop is provided
7
- * If this is the case, the onClick event will be ignored
8
- */
9
- to?: string;
10
- /**
11
- * [Optional] Custom link element to use
12
- * This is useful for using a different link element, like a React Router Link
13
- * If this is not provided, a normal anchor tag will be used
14
- */
15
- LinkElement?: CustomLinkElement;
16
- };
17
- type ButtonProps = DefaultButtonProps & {
3
+ type DefaultButtonProps = React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>;
4
+ export type VisualButtonProps = {
18
5
  /**
19
6
  * Type of button
20
7
  * @default "primary"
@@ -31,6 +18,8 @@ type ButtonProps = DefaultButtonProps & {
31
18
  */
32
19
  size?: "regular" | "small";
33
20
  };
21
+ type ButtonProps = DefaultButtonProps & VisualButtonProps;
34
22
  export declare const UnstyledButton: React.ForwardRefExoticComponent<Omit<DefaultButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
35
23
  declare const Button: React.ForwardRefExoticComponent<Omit<ButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
24
+ export declare const getButtonClassName: ({ variant, corners, size, }: VisualButtonProps) => string;
36
25
  export default Button;
@@ -21,19 +21,18 @@ var __rest = (this && this.__rest) || function (s, e) {
21
21
  return t;
22
22
  };
23
23
  import { jsx as _jsx } from "react/jsx-runtime";
24
- import { forwardRef } from "react";
25
- import { UnstyledLink } from "../Link/Link";
24
+ import React from "react";
26
25
  import classNames from "../../functions/classNames";
27
- export var UnstyledButton = forwardRef(function (_a, ref) {
28
- var to = _a.to, LinkElement = _a.LinkElement, className = _a.className, props = __rest(_a, ["to", "LinkElement", "className"]);
29
- className = classNames("aui-button-base", className);
30
- if (to) {
31
- return (_jsx(UnstyledLink, { to: to, className: className, style: props.style, role: "button", LinkElement: LinkElement, "aria-label": props["aria-label"], children: props.children }));
32
- }
33
- return (_jsx("button", __assign({}, props, { className: classNames("aui-action", className), ref: ref })));
26
+ export var UnstyledButton = React.forwardRef(function (_a, ref) {
27
+ var className = _a.className, props = __rest(_a, ["className"]);
28
+ return (_jsx("button", __assign({}, props, { className: classNames("aui-action aui-button", className), ref: ref })));
34
29
  });
35
- var Button = forwardRef(function (_a, ref) {
36
- var _b = _a.variant, variant = _b === void 0 ? "primary" : _b, _c = _a.corners, corners = _c === void 0 ? "rounded" : _c, className = _a.className, _d = _a.size, size = _d === void 0 ? "regular" : _d, rest = __rest(_a, ["variant", "corners", "className", "size"]);
37
- return (_jsx(UnstyledButton, __assign({}, rest, { className: classNames("aui-button--".concat(variant, " aui-button-size--").concat(size, " aui-corners--").concat(corners), className), ref: ref })));
30
+ var Button = React.forwardRef(function (_a, ref) {
31
+ var variant = _a.variant, corners = _a.corners, className = _a.className, size = _a.size, rest = __rest(_a, ["variant", "corners", "className", "size"]);
32
+ return (_jsx(UnstyledButton, __assign({}, rest, { className: classNames(getButtonClassName({ variant: variant, corners: corners, size: size }), className), ref: ref })));
38
33
  });
34
+ export var getButtonClassName = function (_a) {
35
+ var _b = _a.variant, variant = _b === void 0 ? "primary" : _b, _c = _a.corners, corners = _c === void 0 ? "rounded" : _c, _d = _a.size, size = _d === void 0 ? "regular" : _d;
36
+ return "aui-button--".concat(variant, " aui-button-size--").concat(size, " aui-corners--").concat(corners);
37
+ };
39
38
  export default Button;
@@ -1,10 +1,10 @@
1
1
  import React from "react";
2
- type Props<T extends React.ElementType> = {
2
+ type Props = {
3
3
  /**
4
4
  * The children to render.
5
5
  * IMPORTANT: The child must be a single element which can hold a ref.
6
6
  */
7
- children: React.ReactElement<React.ComponentPropsWithRef<T>>;
7
+ children: React.ReactElement<any>;
8
8
  /**
9
9
  * The function to call when a click occurs outside the child element.
10
10
  *
@@ -12,5 +12,5 @@ type Props<T extends React.ElementType> = {
12
12
  */
13
13
  onClickOutside: (event: MouseEvent) => void;
14
14
  };
15
- declare const ClickOutside: <T extends React.ElementType>({ children, onClickOutside, }: Props<T>) => React.JSX.Element;
15
+ declare const ClickOutside: ({ children, onClickOutside, }: Props) => React.JSX.Element;
16
16
  export default ClickOutside;
@@ -31,7 +31,7 @@ var ClickOutside = function (_a) {
31
31
  onClick: function (event) {
32
32
  var _a, _b;
33
33
  // point of this is to let us know that click originated
34
- // from the child element, so we can ignore it if the click ends outside
34
+ // from the child element, so we can ignore it
35
35
  clickWithinChildRef.current = true;
36
36
  (_b = (_a = children.props) === null || _a === void 0 ? void 0 : _a.onClick) === null || _b === void 0 ? void 0 : _b.call(_a, event);
37
37
  },
@@ -15,6 +15,6 @@ import classNames from "../../functions/classNames";
15
15
  import Box from "../Box";
16
16
  var IconInput = forwardRef(function (_a, ref) {
17
17
  var startIcon = _a.startIcon, endIcon = _a.endIcon, className = _a.className, style = _a.style, _b = _a.corners, corners = _b === void 0 ? "rounded" : _b, inputProps = _a.inputProps;
18
- return (_jsxs(Box, { layout: { axis: "x", align: "center" }, className: classNames("aui-input-default aui-icon-input aui-corners--".concat(corners), className), style: style, ref: ref, children: [startIcon, _jsx("input", __assign({}, inputProps, { className: classNames("aui-input-base aui-corners--".concat(corners), inputProps === null || inputProps === void 0 ? void 0 : inputProps.className) })), endIcon] }));
18
+ return (_jsxs(Box, { layout: { axis: "x", align: "center" }, className: classNames("aui-input aui-icon-input aui-corners--".concat(corners), className), style: style, ref: ref, children: [startIcon, _jsx("input", __assign({}, inputProps, { className: classNames("aui-input-base aui-corners--".concat(corners), inputProps === null || inputProps === void 0 ? void 0 : inputProps.className) })), endIcon] }));
19
19
  });
20
20
  export default IconInput;
@@ -25,6 +25,6 @@ import { forwardRef } from "react";
25
25
  import classNames from "../../functions/classNames";
26
26
  var Input = forwardRef(function (_a, ref) {
27
27
  var className = _a.className, _b = _a.corners, corners = _b === void 0 ? "rounded" : _b, props = __rest(_a, ["className", "corners"]);
28
- return (_jsx("input", __assign({}, props, { ref: ref, className: classNames("aui-input-base aui-input-default aui-corners--".concat(corners), className) })));
28
+ return (_jsx("input", __assign({}, props, { ref: ref, className: classNames("aui-input-base aui-input aui-corners--".concat(corners), className) })));
29
29
  });
30
30
  export default Input;
@@ -25,6 +25,6 @@ import { forwardRef } from "react";
25
25
  import classNames from "../../functions/classNames";
26
26
  var TextArea = forwardRef(function (_a, ref) {
27
27
  var className = _a.className, _b = _a.rows, rows = _b === void 0 ? 3 : _b, _c = _a.corners, corners = _c === void 0 ? "rounded" : _c, props = __rest(_a, ["className", "rows", "corners"]);
28
- return (_jsx("textarea", __assign({}, props, { ref: ref, className: classNames("aui-input-base aui-input-default aui-corners--".concat(corners), className), rows: rows })));
28
+ return (_jsx("textarea", __assign({}, props, { ref: ref, className: classNames("aui-input-base aui-input aui-corners--".concat(corners), className), rows: rows })));
29
29
  });
30
30
  export default TextArea;
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { type BoxProps } from "../Box/Box";
3
- type Props<T extends React.ElementType> = Omit<BoxProps, "children"> & {
3
+ type Props = Omit<BoxProps, "children"> & {
4
4
  /**
5
5
  * Callback that fires when the user clicks outside the layer
6
6
  */
@@ -9,7 +9,7 @@ type Props<T extends React.ElementType> = Omit<BoxProps, "children"> & {
9
9
  * The child of the layer.
10
10
  * IMPORTANT: the child must be able to accept a ref
11
11
  */
12
- children: React.ReactElement<React.ComponentPropsWithRef<T>>;
12
+ children: React.ReactElement<any>;
13
13
  /**
14
14
  * [Optional] Whether to disable the escape key to close the layer
15
15
  * @default false
@@ -26,5 +26,5 @@ type Props<T extends React.ElementType> = Omit<BoxProps, "children"> & {
26
26
  */
27
27
  disableScrollLock?: boolean;
28
28
  };
29
- declare const Layer: <T extends React.ElementType>({ returnFocusOnEscape, disableScrollLock, ...props }: Props<T>) => React.JSX.Element;
29
+ declare const Layer: React.ForwardRefExoticComponent<Omit<Props, "ref"> & React.RefAttributes<HTMLDivElement>>;
30
30
  export default Layer;
@@ -25,8 +25,8 @@ import React, { useEffect } from "react";
25
25
  import { useFocusTrap, useScrollLock } from "../../hooks";
26
26
  import classNames from "../../functions/classNames";
27
27
  import Box from "../Box/Box";
28
- var BaseLayer = function (_a) {
29
- var onClose = _a.onClose, children = _a.children, style = _a.style, className = _a.className, _b = _a.disableEscape, disableEscape = _b === void 0 ? false : _b, visible = _a.visible;
28
+ var BaseLayer = React.forwardRef(function (_a, ref) {
29
+ var onClose = _a.onClose, children = _a.children, className = _a.className, _b = _a.disableEscape, disableEscape = _b === void 0 ? false : _b, visible = _a.visible, onMouseDown = _a.onMouseDown, rest = __rest(_a, ["onClose", "children", "className", "disableEscape", "visible", "onMouseDown"]);
30
30
  var focusRef = useFocusTrap(visible);
31
31
  useEffect(function () {
32
32
  var handleEscape = function (event) {
@@ -41,28 +41,29 @@ var BaseLayer = function (_a) {
41
41
  document.removeEventListener("keydown", handleEscape);
42
42
  };
43
43
  }, [onClose, disableEscape]);
44
- return (_jsx(Box, { layout: { axis: "y", align: "center", justify: "center" }, className: classNames("aui-layer-backdrop", className), style: style, onMouseDown: onClose, children: React.cloneElement(children, {
44
+ return (_jsx(Box, __assign({ layout: { axis: "y", align: "center", justify: "center" } }, rest, { className: classNames("aui-layer-backdrop", className), onMouseDown: function (e) {
45
+ onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(e);
46
+ onClose === null || onClose === void 0 ? void 0 : onClose();
47
+ }, ref: ref, children: React.cloneElement(children, {
45
48
  ref: focusRef,
46
49
  onMouseDown: function (e) {
47
50
  var _a, _b;
48
51
  e.stopPropagation();
49
52
  (_b = (_a = children.props) === null || _a === void 0 ? void 0 : _a.onMouseDown) === null || _b === void 0 ? void 0 : _b.call(_a, e);
50
53
  },
51
- }) }));
52
- };
53
- var Layer = function (_a) {
54
- var returnFocusOnEscape = _a.returnFocusOnEscape, disableScrollLock = _a.disableScrollLock, props = __rest(_a, ["returnFocusOnEscape", "disableScrollLock"]);
54
+ }) })));
55
+ });
56
+ var Layer = React.forwardRef(function (_a, ref) {
57
+ var returnFocusOnEscape = _a.returnFocusOnEscape, disableScrollLock = _a.disableScrollLock, rest = __rest(_a, ["returnFocusOnEscape", "disableScrollLock"]);
55
58
  // Lock and unlock on mount and unmount
56
59
  useScrollLock(!disableScrollLock);
57
- useEffect(function () {
58
- return function () {
59
- var _a;
60
- var activeEl = document.activeElement;
61
- if (!returnFocusOnEscape) {
62
- (_a = activeEl === null || activeEl === void 0 ? void 0 : activeEl.blur) === null || _a === void 0 ? void 0 : _a.call(activeEl);
63
- }
64
- };
65
- }, [returnFocusOnEscape]);
66
- return _jsx(BaseLayer, __assign({}, props, { visible: true }));
67
- };
60
+ useEffect(function () { return function () {
61
+ var _a;
62
+ var activeEl = document.activeElement;
63
+ if (!returnFocusOnEscape) {
64
+ (_a = activeEl === null || activeEl === void 0 ? void 0 : activeEl.blur) === null || _a === void 0 ? void 0 : _a.call(activeEl);
65
+ }
66
+ }; }, [returnFocusOnEscape]);
67
+ return _jsx(BaseLayer, __assign({}, rest, { visible: true, ref: ref }));
68
+ });
68
69
  export default Layer;
@@ -1,13 +1,17 @@
1
1
  import React from "react";
2
- type BuiltinLinkProps = Omit<React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "href">;
3
- export type CustomLinkElement = React.ForwardRefExoticComponent<BuiltinLinkProps & {
4
- to: string;
5
- } & React.RefAttributes<HTMLAnchorElement>>;
6
- type DefaultLinkProps = BuiltinLinkProps & {
2
+ import { type VisualButtonProps } from "../Button/Button";
3
+ type BaseLinkProps = Omit<React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "href"> & {
7
4
  /**
8
5
  * URL to navigate to
9
6
  */
10
7
  to: string;
8
+ };
9
+ type CustomLinkElement = React.ForwardRefExoticComponent<BaseLinkProps & React.RefAttributes<HTMLAnchorElement>>;
10
+ type LinkProps = BaseLinkProps & {
11
+ /**
12
+ * Whether the link should open in a new tab
13
+ */
14
+ external?: boolean;
11
15
  /**
12
16
  * [Optional] Custom link element to use
13
17
  * This is useful for using a different link element, like a React Router Link
@@ -15,6 +19,23 @@ type DefaultLinkProps = BuiltinLinkProps & {
15
19
  */
16
20
  LinkElement?: CustomLinkElement;
17
21
  };
18
- export declare const UnstyledLink: React.ForwardRefExoticComponent<Omit<DefaultLinkProps, "ref"> & React.RefAttributes<HTMLAnchorElement>>;
19
- declare const Link: React.ForwardRefExoticComponent<Omit<DefaultLinkProps, "ref"> & React.RefAttributes<HTMLAnchorElement>>;
22
+ export declare const UnstyledLink: React.ForwardRefExoticComponent<Omit<LinkProps, "ref"> & React.RefAttributes<HTMLAnchorElement>>;
23
+ export declare const ButtonLink: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "href"> & {
24
+ /**
25
+ * URL to navigate to
26
+ */
27
+ to: string;
28
+ } & {
29
+ /**
30
+ * Whether the link should open in a new tab
31
+ */
32
+ external?: boolean;
33
+ /**
34
+ * [Optional] Custom link element to use
35
+ * This is useful for using a different link element, like a React Router Link
36
+ * If this is not provided, a normal anchor tag will be used
37
+ */
38
+ LinkElement?: CustomLinkElement;
39
+ } & VisualButtonProps, "ref"> & React.RefAttributes<HTMLAnchorElement>>;
40
+ declare const Link: React.ForwardRefExoticComponent<Omit<LinkProps, "ref"> & React.RefAttributes<HTMLAnchorElement>>;
20
41
  export default Link;
@@ -21,18 +21,23 @@ var __rest = (this && this.__rest) || function (s, e) {
21
21
  return t;
22
22
  };
23
23
  import { jsx as _jsx } from "react/jsx-runtime";
24
- import { forwardRef } from "react";
24
+ import React from "react";
25
+ import { getButtonClassName } from "../Button/Button";
25
26
  import classNames from "../../functions/classNames";
26
- var DefaultLinkElement = forwardRef(function (_a, ref) {
27
- var to = _a.to, props = __rest(_a, ["to"]);
27
+ export var UnstyledLink = React.forwardRef(function (_a, ref) {
28
+ var LinkElement = _a.LinkElement, to = _a.to, className = _a.className, external = _a.external, rest = __rest(_a, ["LinkElement", "to", "className", "external"]);
29
+ var props = __assign(__assign(__assign({}, (external ? { target: "_blank", rel: "noreferrer noopener" } : {})), rest), { className: classNames("aui-action", className) });
30
+ if (LinkElement) {
31
+ return _jsx(LinkElement, __assign({}, props, { to: to, ref: ref }));
32
+ }
28
33
  return _jsx("a", __assign({}, props, { href: to, ref: ref }));
29
34
  });
30
- export var UnstyledLink = forwardRef(function (_a, ref) {
31
- var _b = _a.LinkElement, LinkElement = _b === void 0 ? DefaultLinkElement : _b, className = _a.className, props = __rest(_a, ["LinkElement", "className"]);
32
- return (_jsx(LinkElement, __assign({}, props, { className: classNames("aui-action", className), ref: ref })));
35
+ export var ButtonLink = React.forwardRef(function (_a, ref) {
36
+ var className = _a.className, variant = _a.variant, corners = _a.corners, size = _a.size, props = __rest(_a, ["className", "variant", "corners", "size"]);
37
+ return (_jsx(UnstyledLink, __assign({}, props, { className: classNames(getButtonClassName({ variant: variant, corners: corners, size: size }), className), ref: ref })));
33
38
  });
34
- var Link = forwardRef(function (_a, ref) {
39
+ var Link = React.forwardRef(function (_a, ref) {
35
40
  var className = _a.className, props = __rest(_a, ["className"]);
36
- return (_jsx(UnstyledLink, __assign({}, props, { className: classNames("aui-link-default", className), ref: ref })));
41
+ return (_jsx(UnstyledLink, __assign({}, props, { className: classNames("aui-link", className), ref: ref })));
37
42
  });
38
43
  export default Link;
@@ -1,3 +1,3 @@
1
- import Link from "./Link";
1
+ import Link, { UnstyledLink, ButtonLink } from "./Link";
2
2
  export default Link;
3
- export * from "./Link";
3
+ export { UnstyledLink, ButtonLink };
@@ -1,3 +1,3 @@
1
- import Link from "./Link";
1
+ import Link, { UnstyledLink, ButtonLink } from "./Link";
2
2
  export default Link;
3
- export * from "./Link";
3
+ export { UnstyledLink, ButtonLink };
@@ -27,6 +27,6 @@ import Box from "../Box";
27
27
  import Icon from "../Icon";
28
28
  var Select = function (_a, ref) {
29
29
  var className = _a.className, options = _a.options, getOptionLabel = _a.getOptionLabel, _b = _a.corners, corners = _b === void 0 ? "rounded" : _b, style = _a.style, disabled = _a.disabled, props = __rest(_a, ["className", "options", "getOptionLabel", "corners", "style", "disabled"]);
30
- return (_jsxs(Box, { className: classNames("aui-select-container", "aui-corners--".concat(corners), disabled ? "aui-select-disabled" : undefined, className), style: style, children: [_jsx("select", __assign({}, props, { ref: ref, className: "aui-select-base aui-corners--".concat(corners), disabled: disabled, children: options.map(function (option, index) { return (_jsx("option", { value: option, children: (getOptionLabel === null || getOptionLabel === void 0 ? void 0 : getOptionLabel(option)) || option }, index)); }) })), _jsx(Icon, { icon: "down", className: "aui-select-icon", "aria-hidden": true })] }));
30
+ return (_jsxs(Box, { className: classNames("aui-select-container", "aui-corners--".concat(corners), disabled ? "aui-select-disabled" : undefined, className), style: style, children: [_jsx("select", __assign({}, props, { ref: ref, className: "aui-select aui-corners--".concat(corners), disabled: disabled, children: options.map(function (option, index) { return (_jsx("option", { value: option, children: (getOptionLabel === null || getOptionLabel === void 0 ? void 0 : getOptionLabel(option)) || option }, index)); }) })), _jsx(Icon, { icon: "down", className: "aui-select-icon", "aria-hidden": true })] }));
31
31
  };
32
32
  export default forwardRef(Select);
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Assert a value is defined
3
+ *
4
+ * @param value the value to assert presence of
5
+ * @param message optional error message
6
+ * @returns the present value
7
+ */
8
+ export default function assertDefined<T>(value: T | undefined, message?: string): T;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Assert a value is defined
3
+ *
4
+ * @param value the value to assert presence of
5
+ * @param message optional error message
6
+ * @returns the present value
7
+ */
8
+ export default function assertDefined(value, message) {
9
+ if (value === undefined) {
10
+ throw new Error(message || "Unexpected undefined value");
11
+ }
12
+ return value;
13
+ }
@@ -1,4 +1,4 @@
1
1
  import classNames from "./classNames";
2
2
  import scrollToId from "./scrollToId";
3
- import assert, { assertDefined } from "./assert";
4
- export { classNames, scrollToId, assert, assertDefined };
3
+ import assertDefined from "./assertDefined";
4
+ export { classNames, scrollToId, assertDefined };
@@ -1,4 +1,4 @@
1
1
  import classNames from "./classNames";
2
2
  import scrollToId from "./scrollToId";
3
- import assert, { assertDefined } from "./assert";
4
- export { classNames, scrollToId, assert, assertDefined };
3
+ import assertDefined from "./assertDefined";
4
+ export { classNames, scrollToId, assertDefined };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adamjanicki/ui",
3
- "version": "1.5.8",
3
+ "version": "1.5.9",
4
4
  "description": "Basic UI components and hooks for React in TypeScript",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -13,8 +13,9 @@
13
13
  },
14
14
  "scripts": {
15
15
  "clean": "./clean.sh",
16
- "lint": "eslint src --max-warnings=0",
17
- "build": "npm run clean && npm run lint && tsc; cp src/style.css ./style.css",
16
+ "lint": "eslint src test --max-warnings=0",
17
+ "test": "jest",
18
+ "build": "npm run clean && npm run lint && npm run test && tsc; cp src/style.css ./style.css",
18
19
  "prepare": "npm run build",
19
20
  "dryrun": "npm publish --dry-run"
20
21
  },
@@ -23,8 +24,15 @@
23
24
  "react-dom": ">=18"
24
25
  },
25
26
  "devDependencies": {
27
+ "@testing-library/jest-dom": "^6.7.0",
28
+ "@testing-library/react": "^16.3.0",
29
+ "@testing-library/user-event": "^14.6.1",
30
+ "@types/jest": "^30.0.0",
26
31
  "@types/react": "^19.1.9",
27
32
  "@types/react-dom": "^19.1.7",
33
+ "jest": "^30.0.5",
34
+ "jest-environment-jsdom": "^30.0.5",
35
+ "ts-jest": "^29.4.1",
28
36
  "typescript": "^5.9.2"
29
37
  }
30
38
  }
package/style.css CHANGED
@@ -201,7 +201,7 @@
201
201
  }
202
202
 
203
203
  /* Button */
204
- .aui-button-base {
204
+ .aui-button {
205
205
  background: none;
206
206
  border: none;
207
207
  padding: 0;
@@ -218,7 +218,7 @@
218
218
  font-weight: 600;
219
219
  }
220
220
 
221
- .aui-button-base:disabled {
221
+ .aui-button:disabled {
222
222
  cursor: default !important;
223
223
  opacity: var(--aui-disabled-opacity);
224
224
  }
@@ -238,7 +238,7 @@
238
238
  transition: box-shadow var(--aui-default-transition);
239
239
  }
240
240
 
241
- .aui-link-default {
241
+ .aui-link {
242
242
  font-weight: 600;
243
243
  color: var(--aui-link-color);
244
244
  transition: opacity var(--aui-default-transition);
@@ -246,7 +246,7 @@
246
246
 
247
247
  @media (hover: hover) {
248
248
  .aui-button--primary:not([disabled]):hover,
249
- .aui-link-default:hover {
249
+ .aui-link:hover {
250
250
  opacity: var(--aui-default-opacity-dim);
251
251
  }
252
252
 
@@ -279,19 +279,19 @@
279
279
  width: 100%;
280
280
  }
281
281
 
282
- .aui-input-default {
282
+ .aui-input {
283
283
  transition: box-shadow var(--aui-default-transition);
284
284
  box-shadow: 0 0 0 1px var(--aui-default-border) inset,
285
285
  var(--aui-subtle-box-shadow);
286
286
  background-color: var(--aui-default-background);
287
287
  }
288
288
 
289
- .aui-input-default:disabled {
289
+ .aui-input:disabled {
290
290
  opacity: var(--aui-disabled-opacity);
291
291
  cursor: default;
292
292
  }
293
293
 
294
- .aui-input-default:not([disabled]):focus-within,
294
+ .aui-input:not([disabled]):focus-within,
295
295
  .aui-select-container:not([disabled]):focus-within {
296
296
  box-shadow: 0 0 0 1px var(--aui-default-border) inset,
297
297
  var(--aui-subtle-box-shadow), 0 0 0 3px var(--aui-focus-ring-color);
@@ -308,7 +308,7 @@
308
308
  background-color: var(--aui-default-background);
309
309
  }
310
310
 
311
- .aui-select-base {
311
+ .aui-select {
312
312
  width: 100%;
313
313
  color: inherit;
314
314
  border: none;
@@ -1,15 +0,0 @@
1
- /**
2
- * Assert a condition
3
- *
4
- * @param predicate the condition to assert
5
- * @param message optional error message
6
- */
7
- export default function assert<T>(predicate: T, message?: string): void;
8
- /**
9
- * Assert a value is defined
10
- *
11
- * @param value the value to assert presence of
12
- * @param message optional error message
13
- * @returns the present value
14
- */
15
- export declare function assertDefined<T>(value: T | undefined, message?: string): T;
@@ -1,24 +0,0 @@
1
- /**
2
- * Assert a condition
3
- *
4
- * @param predicate the condition to assert
5
- * @param message optional error message
6
- */
7
- export default function assert(predicate, message) {
8
- if (!predicate) {
9
- throw new Error(message || "Assertion error");
10
- }
11
- }
12
- /**
13
- * Assert a value is defined
14
- *
15
- * @param value the value to assert presence of
16
- * @param message optional error message
17
- * @returns the present value
18
- */
19
- export function assertDefined(value, message) {
20
- if (value === undefined) {
21
- throw new Error(message || "Unexpected undefined value");
22
- }
23
- return value;
24
- }