@adamjanicki/ui 1.5.7 → 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.
Files changed (40) hide show
  1. package/components/Accordion/Accordion.d.ts +37 -0
  2. package/components/Accordion/Accordion.js +69 -0
  3. package/components/Accordion/index.d.ts +2 -0
  4. package/components/Accordion/index.js +2 -0
  5. package/components/Box/Box.d.ts +6 -2
  6. package/components/Button/Button.d.ts +4 -23
  7. package/components/Button/Button.js +11 -16
  8. package/components/Button/index.d.ts +2 -2
  9. package/components/Button/index.js +2 -2
  10. package/components/Carousel/Carousel.d.ts +2 -2
  11. package/components/Carousel/Carousel.js +2 -1
  12. package/components/ClickOutside/ClickOutside.d.ts +3 -3
  13. package/components/ClickOutside/ClickOutside.js +1 -1
  14. package/components/Icon/Icon.d.ts +14 -0
  15. package/components/Icon/Icon.js +33 -0
  16. package/components/Icon/icons.d.ts +9 -0
  17. package/components/Icon/icons.js +26 -0
  18. package/components/Icon/index.d.ts +2 -0
  19. package/components/Icon/index.js +2 -0
  20. package/components/Input/IconInput.js +1 -1
  21. package/components/Input/Input.js +1 -1
  22. package/components/Input/TextArea.js +1 -1
  23. package/components/Layer/Layer.d.ts +3 -3
  24. package/components/Layer/Layer.js +19 -18
  25. package/components/Link/Link.d.ts +28 -7
  26. package/components/Link/Link.js +13 -8
  27. package/components/Link/index.d.ts +2 -2
  28. package/components/Link/index.js +2 -2
  29. package/components/Select/Select.js +2 -1
  30. package/functions/assertDefined.d.ts +8 -0
  31. package/functions/assertDefined.js +13 -0
  32. package/functions/index.d.ts +2 -2
  33. package/functions/index.js +2 -2
  34. package/index.d.ts +2 -0
  35. package/index.js +2 -0
  36. package/package.json +11 -3
  37. package/style.css +47 -22
  38. package/utils/types.d.ts +4 -0
  39. package/functions/assert.d.ts +0 -15
  40. package/functions/assert.js +0 -24
@@ -0,0 +1,37 @@
1
+ import React from "react";
2
+ import { type BoxProps } from "../Box/Box";
3
+ type Props = Omit<BoxProps, "children"> & {
4
+ /**
5
+ * Drawers to render as accordion sections
6
+ */
7
+ drawers: Drawer[];
8
+ /**
9
+ * Duration of the drawer animation (in seconds)
10
+ */
11
+ duration?: number;
12
+ /**
13
+ * Whether to hide the dividers between drawers
14
+ * @default false
15
+ */
16
+ hideDividers?: boolean;
17
+ };
18
+ declare const Accordion: React.ForwardRefExoticComponent<Omit<Props, "ref"> & React.RefAttributes<HTMLDivElement>>;
19
+ type Drawer = {
20
+ /**
21
+ * Label for the accordion drawer
22
+ */
23
+ label: string;
24
+ /**
25
+ * Content hidden within this accordion drawer
26
+ */
27
+ content: React.ReactNode;
28
+ };
29
+ type DrawerProps = {
30
+ open: boolean;
31
+ onOpenChange: (open: boolean) => void;
32
+ item: Drawer;
33
+ duration?: number;
34
+ showDivider: boolean;
35
+ };
36
+ declare const Drawer: ({ item, open, onOpenChange, duration, showDivider, }: DrawerProps) => import("react/jsx-runtime").JSX.Element;
37
+ export default Accordion;
@@ -0,0 +1,69 @@
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
+ };
23
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
24
+ import React, { useState, useRef, useEffect } from "react";
25
+ import Box from "../Box/Box";
26
+ import Icon from "../Icon";
27
+ import { UnstyledButton } from "../Button";
28
+ import Animated from "../Animated";
29
+ import { classNames } from "../../functions";
30
+ var Accordion = React.forwardRef(function (_a, ref) {
31
+ var drawers = _a.drawers, className = _a.className, duration = _a.duration, hideDividers = _a.hideDividers, rest = __rest(_a, ["drawers", "className", "duration", "hideDividers"]);
32
+ var _b = useState(new Set()), openIndices = _b[0], setOpenIndices = _b[1];
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) {
34
+ return setOpenIndices(function (prev) {
35
+ var next = new Set(prev);
36
+ if (open) {
37
+ next.add(i);
38
+ }
39
+ else {
40
+ next.delete(i);
41
+ }
42
+ return next;
43
+ });
44
+ }, duration: duration, showDivider: !hideDividers && i < drawers.length - 1 }, i)); }) })));
45
+ });
46
+ var Drawer = function (_a) {
47
+ var item = _a.item, open = _a.open, onOpenChange = _a.onOpenChange, duration = _a.duration, showDivider = _a.showDivider;
48
+ var boxRef = useRef(null);
49
+ var _b = useState(), height = _b[0], setHeight = _b[1];
50
+ var children = item.content;
51
+ useEffect(function () {
52
+ if (open && children && boxRef.current) {
53
+ setHeight(boxRef.current.offsetHeight);
54
+ }
55
+ }, [open, children]);
56
+ // TODO: change this to use calc-size when supported
57
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/calc-size#browser_compatibility
58
+ return (_jsxs(_Fragment, { children: [_jsxs(Box, { layout: { axis: "y" }, children: [_jsx(UnstyledButton, { onClick: function () { return onOpenChange(!open); }, children: _jsxs(Box, { layout: { axis: "x", align: "center", gap: "m", padding: "l" }, children: [_jsx(Icon, { size: 12, icon: open ? "down" : "right", className: "aui-accordion-arrow" }), _jsx("span", { className: "aui-accordion-label", children: item.label })] }) }), _jsx(Animated, { style: { overflow: "hidden" }, keepMounted: true, duration: duration, animated: open, animateFrom: {
59
+ style: {
60
+ visibility: "hidden",
61
+ height: 0,
62
+ transform: "translateY(-4px)",
63
+ opacity: 0.9,
64
+ },
65
+ }, animateTo: {
66
+ style: { height: height, transform: "translateY(0)", opacity: 1 },
67
+ }, children: _jsx(Box, { ref: boxRef, children: children }) })] }), showDivider && _jsx("hr", { className: "aui-accordion-hr" })] }));
68
+ };
69
+ export default Accordion;
@@ -0,0 +1,2 @@
1
+ import Accordion from "./Accordion";
2
+ export default Accordion;
@@ -0,0 +1,2 @@
1
+ import Accordion from "./Accordion";
2
+ export default Accordion;
@@ -1,6 +1,10 @@
1
1
  import React from "react";
2
- import type { Layout } from "../../utils/types";
3
- type Props = React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> & {
2
+ import type { Layout, Children } from "../../utils/types";
3
+ type Props = Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "children"> & {
4
+ /**
5
+ * Children to render inside the box
6
+ */
7
+ children?: Children;
4
8
  /**
5
9
  * The organization of the container and its children.
6
10
  */
@@ -1,27 +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 IconButtonProps = Omit<DefaultButtonProps, "children"> & {
18
- /**
19
- * Icon to display inside the button
20
- * I would usually use FontAwesome, but for added flexibility, it's any node
21
- */
22
- icon: React.ReactNode;
23
- };
24
- type ButtonProps = DefaultButtonProps & {
3
+ type DefaultButtonProps = React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>;
4
+ export type VisualButtonProps = {
25
5
  /**
26
6
  * Type of button
27
7
  * @default "primary"
@@ -38,7 +18,8 @@ type ButtonProps = DefaultButtonProps & {
38
18
  */
39
19
  size?: "regular" | "small";
40
20
  };
21
+ type ButtonProps = DefaultButtonProps & VisualButtonProps;
41
22
  export declare const UnstyledButton: React.ForwardRefExoticComponent<Omit<DefaultButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
42
- export declare const IconButton: React.ForwardRefExoticComponent<Omit<IconButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
43
23
  declare const Button: React.ForwardRefExoticComponent<Omit<ButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
24
+ export declare const getButtonClassName: ({ variant, corners, size, }: VisualButtonProps) => string;
44
25
  export default Button;
@@ -21,23 +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
- export var IconButton = forwardRef(function (_a, ref) {
36
- var icon = _a.icon, className = _a.className, props = __rest(_a, ["icon", "className"]);
37
- return (_jsx(UnstyledButton, __assign({}, props, { className: classNames("aui-icon-button", className), ref: ref, children: icon })));
38
- });
39
- var Button = forwardRef(function (_a, ref) {
40
- 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"]);
41
- 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 })));
42
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
+ };
43
38
  export default Button;
@@ -1,3 +1,3 @@
1
- import Button, { UnstyledButton, IconButton } from "./Button";
2
- export { UnstyledButton, IconButton };
1
+ import Button, { UnstyledButton } from "./Button";
2
+ export { UnstyledButton };
3
3
  export default Button;
@@ -1,3 +1,3 @@
1
- import Button, { UnstyledButton, IconButton } from "./Button";
2
- export { UnstyledButton, IconButton };
1
+ import Button, { UnstyledButton } from "./Button";
2
+ export { UnstyledButton };
3
3
  export default Button;
@@ -1,11 +1,11 @@
1
1
  import React from "react";
2
- import type { Style } from "../../utils/types";
2
+ import type { Children, Style } from "../../utils/types";
3
3
  import { type BoxProps } from "../Box/Box";
4
4
  type ButtonProps = {
5
5
  /**
6
6
  * Children to render inside the button
7
7
  */
8
- children?: React.ReactNode | React.ReactNode[];
8
+ children?: Children;
9
9
  /**
10
10
  * Additional class name to apply to the button
11
11
  */
@@ -25,6 +25,7 @@ import React, { useState, useEffect, useRef, useCallback } from "react";
25
25
  import { classNames } from "../../functions";
26
26
  import Button from "../Button";
27
27
  import Box from "../Box/Box";
28
+ import Icon from "../Icon";
28
29
  var DEFAULT_DURATION_S = 1;
29
30
  var Carousel = React.forwardRef(function (_a, ref) {
30
31
  var _b, _c;
@@ -80,7 +81,7 @@ var Carousel = React.forwardRef(function (_a, ref) {
80
81
  transition: "transform ".concat(duration, "s ease-in-out"),
81
82
  }
82
83
  : undefined;
83
- return (_jsxs(Box, __assign({}, rest, { className: classNames("aui-carousel", className), ref: ref, children: [_jsxs(Box, { className: "aui-carousel-slider", style: __assign(__assign({}, animatingStyles), { flexDirection: delta >= 0 ? "row" : "row-reverse" }), onTransitionEnd: onTransitionEnd, children: [_jsx(Box, { className: "aui-carousel-item", children: children[cur] }), _jsx(Box, { className: "aui-carousel-item", "aria-hidden": true, children: children[next] })] }), length > 1 && (_jsxs(_Fragment, { children: [!hideArrows && (_jsxs(_Fragment, { children: [_jsx(Button, { className: classNames("aui-flex-x aui-align-center aui-justify-center aui-carousel-arrow", leftArrowProps === null || leftArrowProps === void 0 ? void 0 : leftArrowProps.className), style: __assign({ left: 8 }, leftArrowProps === null || leftArrowProps === void 0 ? void 0 : leftArrowProps.style), corners: "pill", "aria-label": "previous", onClick: function () { return startTransition(-1); }, children: (_b = leftArrowProps === null || leftArrowProps === void 0 ? void 0 : leftArrowProps.children) !== null && _b !== void 0 ? _b : "" }), _jsx(Button, { className: classNames("aui-flex-x aui-align-center aui-justify-center aui-carousel-arrow", rightArrowProps === null || rightArrowProps === void 0 ? void 0 : rightArrowProps.className), style: __assign({ right: 8 }, rightArrowProps === null || rightArrowProps === void 0 ? void 0 : rightArrowProps.style), corners: "pill", "aria-label": "next", onClick: function () { return startTransition(1); }, children: (_c = rightArrowProps === null || rightArrowProps === void 0 ? void 0 : rightArrowProps.children) !== null && _c !== void 0 ? _c : "" })] })), !hideDots && (_jsx(Box, { layout: { axis: "x", align: "center", gap: "xs" }, className: "aui-carousel-dots", children: children.map(function (_, i) { return (_jsx(Button, { className: classNames("aui-carousel-dot", dotProps === null || dotProps === void 0 ? void 0 : dotProps.className), corners: "pill", disabled: cur === i || animating, onClick: function () { return startTransition(i - cur); }, style: dotProps === null || dotProps === void 0 ? void 0 : dotProps.style }, i)); }) }))] }))] })));
84
+ return (_jsxs(Box, __assign({}, rest, { className: classNames("aui-carousel", className), ref: ref, children: [_jsxs(Box, { className: "aui-carousel-slider", style: __assign(__assign({}, animatingStyles), { flexDirection: delta >= 0 ? "row" : "row-reverse" }), onTransitionEnd: onTransitionEnd, children: [_jsx(Box, { className: "aui-carousel-item", children: children[cur] }), _jsx(Box, { className: "aui-carousel-item", "aria-hidden": true, children: children[next] })] }), length > 1 && (_jsxs(_Fragment, { children: [!hideArrows && (_jsxs(_Fragment, { children: [_jsx(Button, { className: classNames("aui-flex-x aui-align-center aui-justify-center aui-carousel-arrow", leftArrowProps === null || leftArrowProps === void 0 ? void 0 : leftArrowProps.className), style: __assign({ left: 8 }, leftArrowProps === null || leftArrowProps === void 0 ? void 0 : leftArrowProps.style), corners: "pill", "aria-label": "previous", onClick: function () { return startTransition(-1); }, children: (_b = leftArrowProps === null || leftArrowProps === void 0 ? void 0 : leftArrowProps.children) !== null && _b !== void 0 ? _b : (_jsx(Icon, { icon: "left", size: 12, style: { marginRight: 2 } })) }), _jsx(Button, { className: classNames("aui-flex-x aui-align-center aui-justify-center aui-carousel-arrow", rightArrowProps === null || rightArrowProps === void 0 ? void 0 : rightArrowProps.className), style: __assign({ right: 8 }, rightArrowProps === null || rightArrowProps === void 0 ? void 0 : rightArrowProps.style), corners: "pill", "aria-label": "next", onClick: function () { return startTransition(1); }, children: (_c = rightArrowProps === null || rightArrowProps === void 0 ? void 0 : rightArrowProps.children) !== null && _c !== void 0 ? _c : (_jsx(Icon, { icon: "right", size: 12, style: { marginLeft: 2 } })) })] })), !hideDots && (_jsx(Box, { layout: { axis: "x", align: "center", gap: "xs" }, className: "aui-carousel-dots", children: children.map(function (_, i) { return (_jsx(Button, { className: classNames("aui-carousel-dot", dotProps === null || dotProps === void 0 ? void 0 : dotProps.className), corners: "pill", disabled: cur === i || animating, onClick: function () { return startTransition(i - cur); }, style: dotProps === null || dotProps === void 0 ? void 0 : dotProps.style }, i)); }) }))] }))] })));
84
85
  });
85
86
  function safeMod(n, m) {
86
87
  return ((n % m) + m) % m;
@@ -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
  },
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+ import { type IconType } from "./icons";
3
+ type Props = Omit<React.DetailedHTMLProps<React.SVGAttributes<SVGSVGElement>, SVGSVGElement>, "children" | "viewBox"> & {
4
+ /**
5
+ * The version of icon to render
6
+ */
7
+ icon: IconType;
8
+ /**
9
+ * Size of the icon
10
+ */
11
+ size?: number;
12
+ };
13
+ declare const Icon: React.ForwardRefExoticComponent<Omit<Props, "ref"> & React.RefAttributes<SVGSVGElement>>;
14
+ export default Icon;
@@ -0,0 +1,33 @@
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
+ };
23
+ import { jsx as _jsx } from "react/jsx-runtime";
24
+ import React from "react";
25
+ import icons from "./icons";
26
+ import { classNames } from "../../functions";
27
+ var defaultViewBox = "0 0 512 512";
28
+ var Icon = React.forwardRef(function (_a, ref) {
29
+ var icon = _a.icon, className = _a.className, size = _a.size, style = _a.style, rest = __rest(_a, ["icon", "className", "size", "style"]);
30
+ var _b = icons[icon], contents = _b.contents, viewBox = _b.viewBox;
31
+ return (_jsx("svg", __assign({ xmlns: "http://www.w3.org/2000/svg", viewBox: viewBox || defaultViewBox, className: classNames("aui-icon", className), style: __assign({ width: size, height: size }, style) }, rest, { ref: ref, children: contents.map(function (icon, i) { return (_jsx(React.Fragment, { children: icon }, i)); }) })));
32
+ });
33
+ export default Icon;
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ type IconDefinition = {
3
+ readonly contents: React.JSX.Element[];
4
+ readonly viewBox?: string;
5
+ };
6
+ export declare const iconTypes: readonly ["up", "down", "left", "right"];
7
+ export type IconType = (typeof iconTypes)[number];
8
+ declare const icons: Record<IconType, IconDefinition>;
9
+ export default icons;
@@ -0,0 +1,26 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ export var iconTypes = ["up", "down", "left", "right"];
3
+ var arrowPath = "M94.0908,296.3057c-29.82338,0-54-24.17662-54-54s24.17662-54,54-54c.00237,0,.00475,0,.00712,0c.0017,0,141.65138,0,221.99288,0v-222c0-29.82338,24.17662-54,54-54s54,24.17662,54,54c0,.00237,0,.00475,0,.00712s0,273.40726,0,275.97468c0,.00607,0,.01213,0,.0182c0,29.82338-24.17662,54-54,54h-276Z";
4
+ var icons = {
5
+ down: {
6
+ contents: [
7
+ _jsx("path", { d: arrowPath, transform: "matrix(.707107 0.707107-.707107 0.707107 165.642289-79.868246)" }),
8
+ ],
9
+ },
10
+ up: {
11
+ contents: [
12
+ _jsx("path", { d: arrowPath, transform: "matrix(-.707107-.707107 0.707107-.707107 346.357711 591.868246)" }),
13
+ ],
14
+ },
15
+ left: {
16
+ contents: [
17
+ _jsx("path", { d: arrowPath, transform: "matrix(-.707107 0.707107-.707107-.707107 591.868246 165.642289)" }),
18
+ ],
19
+ },
20
+ right: {
21
+ contents: [
22
+ _jsx("path", { d: arrowPath, transform: "matrix(.707107-.707107 0.707107 0.707107-79.868246 346.357711)" }),
23
+ ],
24
+ },
25
+ };
26
+ export default icons;
@@ -0,0 +1,2 @@
1
+ import Icon from "./Icon";
2
+ export default Icon;
@@ -0,0 +1,2 @@
1
+ import Icon from "./Icon";
2
+ export default Icon;
@@ -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 };
@@ -24,8 +24,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
24
24
  import { forwardRef } from "react";
25
25
  import classNames from "../../functions/classNames";
26
26
  import Box from "../Box";
27
+ import Icon from "../Icon";
27
28
  var Select = function (_a, ref) {
28
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"]);
29
- 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("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 64 64", className: "aui-select-triangle", "aria-hidden": "true", children: _jsx("path", { fill: "currentColor", d: "M 29.175781 50.824219 C 30.738281 52.386719 33.273438 52.386719 34.835938 50.824219 L 58.835938 26.824219 C 60.398438 25.261719 60.398438 22.726562 58.835938 21.164062 C 57.273438 19.601562 54.738281 19.601562 53.175781 21.164062 L 32 42.335938 L 10.824219 21.175781 C 9.261719 19.613281 6.726562 19.613281 5.164062 21.175781 C 3.601562 22.738281 3.601562 25.273438 5.164062 26.835938 L 29.164062 50.835938 Z M 29.175781 50.824219" }) })] }));
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 })] }));
30
31
  };
31
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/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export { default as Accordion } from "./components/Accordion";
1
2
  export { default as Alert } from "./components/Alert";
2
3
  export { default as Animated } from "./components/Animated";
3
4
  export { default as Badge } from "./components/Badge";
@@ -9,6 +10,7 @@ export { default as Carousel } from "./components/Carousel";
9
10
  export { default as ClickOutside } from "./components/ClickOutside";
10
11
  export { default as Hamburger } from "./components/Hamburger";
11
12
  export * from "./components/Hamburger";
13
+ export { default as Icon } from "./components/Icon";
12
14
  export { default as Input } from "./components/Input";
13
15
  export * from "./components/Input";
14
16
  export { default as Layer } from "./components/Layer";
package/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  // Components
2
+ export { default as Accordion } from "./components/Accordion";
2
3
  export { default as Alert } from "./components/Alert";
3
4
  export { default as Animated } from "./components/Animated";
4
5
  export { default as Badge } from "./components/Badge";
@@ -10,6 +11,7 @@ export { default as Carousel } from "./components/Carousel";
10
11
  export { default as ClickOutside } from "./components/ClickOutside";
11
12
  export { default as Hamburger } from "./components/Hamburger";
12
13
  export * from "./components/Hamburger";
14
+ export { default as Icon } from "./components/Icon";
13
15
  export { default as Input } from "./components/Input";
14
16
  export * from "./components/Input";
15
17
  export { default as Layer } from "./components/Layer";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adamjanicki/ui",
3
- "version": "1.5.7",
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
@@ -21,6 +21,7 @@
21
21
  --aui-disabled-opacity: 0.5;
22
22
  --aui-default-transition: 0.25s ease-in-out;
23
23
  --aui-default-opacity-dim: 0.75;
24
+ --aui-container-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.16);
24
25
  /* Corners */
25
26
  --aui-sharp-radius: 0;
26
27
  --aui-rounded-radius: 8px;
@@ -53,6 +54,8 @@
53
54
  --aui-layer-backdrop-background: rgba(200, 200, 200, 0.7);
54
55
  /* Link */
55
56
  --aui-link-color: #0070ff;
57
+ /* Select */
58
+ --aui-select-icon: var(--aui-dark-gray);
56
59
  }
57
60
 
58
61
  [data-theme="dark"] {
@@ -61,6 +64,7 @@
61
64
  --aui-default-text-color: white;
62
65
  --aui-default-background: var(--aui-obsidian);
63
66
  --aui-default-border: var(--aui-dark-gray);
67
+ --aui-container-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.36);
64
68
  /* Buttons */
65
69
  --aui-button-primary-background: white;
66
70
  --aui-button-primary-color: var(--aui-obsidian);
@@ -89,6 +93,8 @@
89
93
  --aui-layer-backdrop-background: rgba(55, 55, 55, 0.7);
90
94
  /* Link */
91
95
  --aui-link-color: #33bfff;
96
+ /* Select */
97
+ --aui-select-icon: var(--aui-moon-gray);
92
98
  }
93
99
 
94
100
  /* General */
@@ -134,6 +140,28 @@
134
140
  border-color: var(--aui-default-border);
135
141
  }
136
142
 
143
+ /* Accordion */
144
+ .aui-accordion {
145
+ background-color: var(--aui-default-background);
146
+ box-shadow: 0 0 0 1px var(--aui-default-border) inset,
147
+ var(--aui-container-box-shadow);
148
+ }
149
+ .aui-accordion-label {
150
+ font-weight: 600;
151
+ }
152
+
153
+ .aui-accordion-hr {
154
+ border: none;
155
+ height: var(--aui-xxs);
156
+ background-color: var(--aui-default-border);
157
+ width: 100%;
158
+ margin: 0;
159
+ }
160
+
161
+ .aui-accordion-arrow {
162
+ color: var(--aui-select-icon);
163
+ }
164
+
137
165
  /* Alert */
138
166
  .aui-alert {
139
167
  padding: var(--aui-l);
@@ -173,9 +201,8 @@
173
201
  }
174
202
 
175
203
  /* Button */
176
- .aui-button-base {
204
+ .aui-button {
177
205
  background: none;
178
- color: inherit;
179
206
  border: none;
180
207
  padding: 0;
181
208
  }
@@ -191,15 +218,7 @@
191
218
  font-weight: 600;
192
219
  }
193
220
 
194
- .aui-icon-button {
195
- display: flex;
196
- justify-content: center;
197
- align-items: center;
198
- transition: opacity var(--aui-default-transition);
199
- padding: var(--aui-m);
200
- }
201
-
202
- .aui-button-base:disabled {
221
+ .aui-button:disabled {
203
222
  cursor: default !important;
204
223
  opacity: var(--aui-disabled-opacity);
205
224
  }
@@ -212,13 +231,14 @@
212
231
  }
213
232
 
214
233
  .aui-button--secondary {
234
+ color: var(--aui-default-text-color);
215
235
  background-color: var(--aui-default-background);
216
236
  box-shadow: 0 0 0 1px var(--aui-default-border) inset,
217
237
  var(--aui-subtle-box-shadow);
218
238
  transition: box-shadow var(--aui-default-transition);
219
239
  }
220
240
 
221
- .aui-link-default {
241
+ .aui-link {
222
242
  font-weight: 600;
223
243
  color: var(--aui-link-color);
224
244
  transition: opacity var(--aui-default-transition);
@@ -226,8 +246,7 @@
226
246
 
227
247
  @media (hover: hover) {
228
248
  .aui-button--primary:not([disabled]):hover,
229
- .aui-icon-button:not([disabled]):hover,
230
- .aui-link-default:hover {
249
+ .aui-link:hover {
231
250
  opacity: var(--aui-default-opacity-dim);
232
251
  }
233
252
 
@@ -260,19 +279,19 @@
260
279
  width: 100%;
261
280
  }
262
281
 
263
- .aui-input-default {
282
+ .aui-input {
264
283
  transition: box-shadow var(--aui-default-transition);
265
284
  box-shadow: 0 0 0 1px var(--aui-default-border) inset,
266
285
  var(--aui-subtle-box-shadow);
267
286
  background-color: var(--aui-default-background);
268
287
  }
269
288
 
270
- .aui-input-default:disabled {
289
+ .aui-input:disabled {
271
290
  opacity: var(--aui-disabled-opacity);
272
291
  cursor: default;
273
292
  }
274
293
 
275
- .aui-input-default:not([disabled]):focus-within,
294
+ .aui-input:not([disabled]):focus-within,
276
295
  .aui-select-container:not([disabled]):focus-within {
277
296
  box-shadow: 0 0 0 1px var(--aui-default-border) inset,
278
297
  var(--aui-subtle-box-shadow), 0 0 0 3px var(--aui-focus-ring-color);
@@ -289,7 +308,7 @@
289
308
  background-color: var(--aui-default-background);
290
309
  }
291
310
 
292
- .aui-select-base {
311
+ .aui-select {
293
312
  width: 100%;
294
313
  color: inherit;
295
314
  border: none;
@@ -309,14 +328,15 @@
309
328
  cursor: default;
310
329
  }
311
330
 
312
- .aui-select-triangle {
313
- --size: 12px;
331
+ .aui-select-icon {
332
+ --size: 10px;
333
+ color: var(--aui-select-icon);
314
334
  width: var(--size);
315
335
  height: var(--size);
316
336
  position: absolute;
317
- top: 50%;
337
+ top: calc(50% + 1px);
318
338
  transform: translateY(-50%);
319
- right: calc(var(--size) - 4px);
339
+ right: var(--size);
320
340
  pointer-events: none;
321
341
  }
322
342
 
@@ -331,6 +351,11 @@
331
351
  background: var(--aui-layer-backdrop-background);
332
352
  }
333
353
 
354
+ /* Icons */
355
+ .aui-icon * {
356
+ fill: currentColor;
357
+ }
358
+
334
359
  /* Spinner */
335
360
  .aui-spinner {
336
361
  animation: aui-spinner-animation 1s linear infinite;
package/utils/types.d.ts CHANGED
@@ -1,4 +1,8 @@
1
1
  import React from "react";
2
+ /**
3
+ * Default children type; can be a node or list of nodes
4
+ */
5
+ export type Children = React.ReactNode | React.ReactNode[];
2
6
  /**
3
7
  * The type of corner to display, controlling the border radius property.
4
8
  */
@@ -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
- }