@adamjanicki/ui 1.5.6 → 1.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/Accordion/Accordion.d.ts +45 -0
- package/components/Accordion/Accordion.js +47 -0
- package/components/Accordion/index.d.ts +2 -0
- package/components/Accordion/index.js +2 -0
- package/components/Alert/Alert.d.ts +3 -2
- package/components/Alert/Alert.js +3 -2
- package/components/Animated/Animated.d.ts +3 -2
- package/components/Animated/Animated.js +3 -2
- package/components/Badge/Badge.d.ts +3 -2
- package/components/Badge/Badge.js +2 -1
- package/components/Banner/Banner.d.ts +3 -2
- package/components/Banner/Banner.js +2 -1
- package/components/Box/Box.d.ts +15 -0
- package/components/Box/Box.js +66 -0
- package/components/Box/index.d.ts +2 -0
- package/components/Box/index.js +2 -0
- package/components/Button/Button.d.ts +1 -9
- package/components/Button/Button.js +3 -7
- package/components/Button/index.d.ts +2 -2
- package/components/Button/index.js +2 -2
- package/components/Carousel/Carousel.d.ts +4 -3
- package/components/Carousel/Carousel.js +9 -7
- package/components/Hamburger/Hamburger.d.ts +1 -1
- package/components/Icon/Icon.d.ts +14 -0
- package/components/Icon/Icon.js +33 -0
- package/components/Icon/icons.d.ts +9 -0
- package/components/Icon/icons.js +26 -0
- package/components/Icon/index.d.ts +2 -0
- package/components/Icon/index.js +2 -0
- package/components/Input/IconInput.d.ts +1 -1
- package/components/Input/IconInput.js +2 -1
- package/components/Input/Input.d.ts +1 -1
- package/components/Input/Input.js +1 -1
- package/components/Input/TextArea.d.ts +1 -1
- package/components/Input/TextArea.js +1 -1
- package/components/Layer/Layer.d.ts +2 -2
- package/components/Layer/Layer.js +2 -1
- package/components/Link/Link.js +2 -2
- package/components/Select/Select.d.ts +1 -1
- package/components/Select/Select.js +3 -1
- package/components/Spinner/Spinner.d.ts +1 -1
- package/components/Spinner/Spinner.js +1 -1
- package/index.d.ts +3 -2
- package/index.js +3 -3
- package/package.json +3 -2
- package/style.css +355 -211
- package/utils/types.d.ts +62 -0
- package/components/InlineCode/InlineCode.d.ts +0 -13
- package/components/InlineCode/InlineCode.js +0 -50
- package/components/InlineCode/index.d.ts +0 -2
- package/components/InlineCode/index.js +0 -2
- package/types/index.d.ts +0 -17
- /package/{types/index.js → utils/types.js} +0 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { Style } from "../../utils/types";
|
|
3
|
+
type Props = {
|
|
4
|
+
/**
|
|
5
|
+
* Drawers to render as accordion sections
|
|
6
|
+
*/
|
|
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
|
+
/**
|
|
17
|
+
* Duration of the drawer animation (in seconds)
|
|
18
|
+
*/
|
|
19
|
+
duration?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Whether to hide the dividers between drawers
|
|
22
|
+
* @default false
|
|
23
|
+
*/
|
|
24
|
+
hideDividers?: boolean;
|
|
25
|
+
};
|
|
26
|
+
declare const Accordion: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLDivElement>>;
|
|
27
|
+
type Drawer = {
|
|
28
|
+
/**
|
|
29
|
+
* Label for the accordion drawer
|
|
30
|
+
*/
|
|
31
|
+
label: string;
|
|
32
|
+
/**
|
|
33
|
+
* Content hidden within this accordion drawer
|
|
34
|
+
*/
|
|
35
|
+
content: React.ReactNode;
|
|
36
|
+
};
|
|
37
|
+
type DrawerProps = {
|
|
38
|
+
open: boolean;
|
|
39
|
+
onOpenChange: (open: boolean) => void;
|
|
40
|
+
item: Drawer;
|
|
41
|
+
duration?: number;
|
|
42
|
+
showDivider: boolean;
|
|
43
|
+
};
|
|
44
|
+
declare const Drawer: ({ item, open, onOpenChange, duration, showDivider, }: DrawerProps) => import("react/jsx-runtime").JSX.Element;
|
|
45
|
+
export default Accordion;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import React, { useState, useRef, useEffect } from "react";
|
|
3
|
+
import Box from "../Box";
|
|
4
|
+
import Icon from "../Icon";
|
|
5
|
+
import { UnstyledButton } from "../Button";
|
|
6
|
+
import Animated from "../Animated";
|
|
7
|
+
import { classNames } from "../../functions";
|
|
8
|
+
var Accordion = React.forwardRef(function (_a, ref) {
|
|
9
|
+
var drawers = _a.drawers, className = _a.className, style = _a.style, duration = _a.duration, hideDividers = _a.hideDividers;
|
|
10
|
+
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) {
|
|
12
|
+
return setOpenIndices(function (prev) {
|
|
13
|
+
var next = new Set(prev);
|
|
14
|
+
if (open) {
|
|
15
|
+
next.add(i);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
next.delete(i);
|
|
19
|
+
}
|
|
20
|
+
return next;
|
|
21
|
+
});
|
|
22
|
+
}, duration: duration, showDivider: !hideDividers && i < drawers.length - 1 }, i)); }) }));
|
|
23
|
+
});
|
|
24
|
+
var Drawer = function (_a) {
|
|
25
|
+
var item = _a.item, open = _a.open, onOpenChange = _a.onOpenChange, duration = _a.duration, showDivider = _a.showDivider;
|
|
26
|
+
var boxRef = useRef(null);
|
|
27
|
+
var _b = useState(), height = _b[0], setHeight = _b[1];
|
|
28
|
+
var children = item.content;
|
|
29
|
+
useEffect(function () {
|
|
30
|
+
if (open && children && boxRef.current) {
|
|
31
|
+
setHeight(boxRef.current.offsetHeight);
|
|
32
|
+
}
|
|
33
|
+
}, [open, children]);
|
|
34
|
+
// TODO: change this to use calc-size when supported
|
|
35
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/calc-size#browser_compatibility
|
|
36
|
+
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: {
|
|
37
|
+
style: {
|
|
38
|
+
visibility: "hidden",
|
|
39
|
+
height: 0,
|
|
40
|
+
transform: "translateY(-4px)",
|
|
41
|
+
opacity: 0.9,
|
|
42
|
+
},
|
|
43
|
+
}, animateTo: {
|
|
44
|
+
style: { height: height, transform: "translateY(0)", opacity: 1 },
|
|
45
|
+
}, children: _jsx(Box, { ref: boxRef, children: children }) })] }), showDivider && _jsx("hr", { className: "aui-accordion-hr" })] }));
|
|
46
|
+
};
|
|
47
|
+
export default Accordion;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type { ContentType, CornerType
|
|
3
|
-
type
|
|
2
|
+
import type { ContentType, CornerType } from "../../utils/types";
|
|
3
|
+
import { type BoxProps } from "../Box/Box";
|
|
4
|
+
type Props = BoxProps & {
|
|
4
5
|
/**
|
|
5
6
|
* The type of alert to display.
|
|
6
7
|
*/
|
|
@@ -23,8 +23,9 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
23
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
24
|
import React from "react";
|
|
25
25
|
import classNames from "../../functions/classNames";
|
|
26
|
+
import Box from "../Box/Box";
|
|
26
27
|
var Alert = React.forwardRef(function (_a, ref) {
|
|
27
|
-
var type = _a.type,
|
|
28
|
-
return (_jsx(
|
|
28
|
+
var type = _a.type, _b = _a.corners, corners = _b === void 0 ? "rounded" : _b, className = _a.className, rest = __rest(_a, ["type", "corners", "className"]);
|
|
29
|
+
return (_jsx(Box, __assign({}, rest, { className: classNames("aui-alert aui-content--".concat(type, " aui-corners--").concat(corners), className), ref: ref })));
|
|
29
30
|
});
|
|
30
31
|
export default Alert;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type {
|
|
3
|
-
type
|
|
2
|
+
import type { Style } from "../../utils/types";
|
|
3
|
+
import { type BoxProps } from "../Box/Box";
|
|
4
|
+
type Props = BoxProps & {
|
|
4
5
|
/**
|
|
5
6
|
* Whether to begin the animation.
|
|
6
7
|
* Set to true to start animation, false to start the exit animation.
|
|
@@ -23,8 +23,9 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
23
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
24
|
import React, { useState, useEffect, useRef } from "react";
|
|
25
25
|
import classNames from "../../functions/classNames";
|
|
26
|
+
import Box from "../Box/Box";
|
|
26
27
|
var Animated = React.forwardRef(function (props, ref) {
|
|
27
|
-
var animated = props.animated, _a = props.duration, duration = _a === void 0 ? 0.25 : _a, _b = props.keepMounted, keepMounted = _b === void 0 ? false : _b, animateTo = props.animateTo, animateFrom = props.animateFrom,
|
|
28
|
+
var animated = props.animated, _a = props.duration, duration = _a === void 0 ? 0.25 : _a, _b = props.keepMounted, keepMounted = _b === void 0 ? false : _b, animateTo = props.animateTo, animateFrom = props.animateFrom, className = props.className, style = props.style, rest = __rest(props, ["animated", "duration", "keepMounted", "animateTo", "animateFrom", "className", "style"]);
|
|
28
29
|
var _c = useState(animated || keepMounted), shouldRender = _c[0], setShouldRender = _c[1];
|
|
29
30
|
var _d = useState(false), isAnimatingForward = _d[0], setIsAnimatingForward = _d[1];
|
|
30
31
|
var timeoutRef = useRef(null);
|
|
@@ -69,6 +70,6 @@ var Animated = React.forwardRef(function (props, ref) {
|
|
|
69
70
|
if (!shouldRender)
|
|
70
71
|
return null;
|
|
71
72
|
var currentAnimation = isAnimatingForward ? animateTo : animateFrom;
|
|
72
|
-
return (_jsx(
|
|
73
|
+
return (_jsx(Box, __assign({ className: classNames(className, currentAnimation === null || currentAnimation === void 0 ? void 0 : currentAnimation.className), style: __assign(__assign({ transition: "all ".concat(duration, "s ease-in-out") }, style), currentAnimation === null || currentAnimation === void 0 ? void 0 : currentAnimation.style) }, rest, { ref: ref })));
|
|
73
74
|
});
|
|
74
75
|
export default Animated;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type { ContentType, CornerType
|
|
3
|
-
type
|
|
2
|
+
import type { ContentType, CornerType } from "../../utils/types";
|
|
3
|
+
import { type BoxProps } from "../Box/Box";
|
|
4
|
+
type Props = BoxProps & {
|
|
4
5
|
/**
|
|
5
6
|
* The type of badge to display.
|
|
6
7
|
*/
|
|
@@ -23,8 +23,9 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
23
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
24
|
import React from "react";
|
|
25
25
|
import classNames from "../../functions/classNames";
|
|
26
|
+
import Box from "../Box/Box";
|
|
26
27
|
var Badge = React.forwardRef(function (_a, ref) {
|
|
27
28
|
var type = _a.type, className = _a.className, _b = _a.corners, corners = _b === void 0 ? "rounded" : _b, rest = __rest(_a, ["type", "className", "corners"]);
|
|
28
|
-
return (_jsx(
|
|
29
|
+
return (_jsx(Box, __assign({}, rest, { className: classNames("aui-badge aui-content--".concat(type, " aui-corners--").concat(corners), className), ref: ref })));
|
|
29
30
|
});
|
|
30
31
|
export default Badge;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type { ContentType
|
|
3
|
-
type
|
|
2
|
+
import type { ContentType } from "../../utils/types";
|
|
3
|
+
import { type BoxProps } from "../Box/Box";
|
|
4
|
+
type Props = BoxProps & {
|
|
4
5
|
/**
|
|
5
6
|
* The type of badge to display.
|
|
6
7
|
*/
|
|
@@ -23,8 +23,9 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
23
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
24
|
import React from "react";
|
|
25
25
|
import classNames from "../../functions/classNames";
|
|
26
|
+
import Box from "../Box/Box";
|
|
26
27
|
var Banner = React.forwardRef(function (_a, ref) {
|
|
27
28
|
var type = _a.type, className = _a.className, rest = __rest(_a, ["type", "className"]);
|
|
28
|
-
return (_jsx(
|
|
29
|
+
return (_jsx(Box, __assign({}, rest, { className: classNames("aui-content--".concat(type, " aui-banner"), className), ref: ref })));
|
|
29
30
|
});
|
|
30
31
|
export default Banner;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "react";
|
|
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;
|
|
8
|
+
/**
|
|
9
|
+
* The organization of the container and its children.
|
|
10
|
+
*/
|
|
11
|
+
layout?: Layout;
|
|
12
|
+
};
|
|
13
|
+
declare const Box: React.ForwardRefExoticComponent<Omit<Props, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
14
|
+
export type { Props as BoxProps };
|
|
15
|
+
export default Box;
|
|
@@ -0,0 +1,66 @@
|
|
|
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 { classNames } from "../../functions";
|
|
26
|
+
var Box = React.forwardRef(function (_a, ref) {
|
|
27
|
+
var layout = _a.layout, className = _a.className, style = _a.style, rest = __rest(_a, ["layout", "className", "style"]);
|
|
28
|
+
var transformedLayout = transformLayout(layout);
|
|
29
|
+
return (_jsx("div", __assign({}, rest, { className: classNames(transformedLayout.className, className), style: __assign(__assign({}, transformedLayout.style), style), ref: ref })));
|
|
30
|
+
});
|
|
31
|
+
function transformLayout(layout) {
|
|
32
|
+
if (!layout)
|
|
33
|
+
return { className: undefined, style: undefined };
|
|
34
|
+
var axis = layout.axis, gap = layout.gap, align = layout.align, justify = layout.justify, padding = layout.padding, margin = layout.margin, wrap = layout.wrap;
|
|
35
|
+
var style = {};
|
|
36
|
+
var className = "aui-flex-".concat(axis);
|
|
37
|
+
if (align) {
|
|
38
|
+
className = classNames(className, "aui-align-".concat(align));
|
|
39
|
+
}
|
|
40
|
+
if (justify) {
|
|
41
|
+
className = classNames(className, "aui-justify-".concat(justify));
|
|
42
|
+
}
|
|
43
|
+
if (wrap) {
|
|
44
|
+
className = classNames(className, "aui-flex-wrap");
|
|
45
|
+
}
|
|
46
|
+
if (gap) {
|
|
47
|
+
if (typeof gap === "number")
|
|
48
|
+
style.gap = gap;
|
|
49
|
+
else
|
|
50
|
+
className = classNames(className, "aui-gap-".concat(gap));
|
|
51
|
+
}
|
|
52
|
+
if (padding) {
|
|
53
|
+
if (typeof padding === "number")
|
|
54
|
+
style.padding = padding;
|
|
55
|
+
else
|
|
56
|
+
className = classNames(className, "aui-pa-".concat(padding));
|
|
57
|
+
}
|
|
58
|
+
if (margin) {
|
|
59
|
+
if (typeof margin === "number")
|
|
60
|
+
style.margin = margin;
|
|
61
|
+
else
|
|
62
|
+
className = classNames(className, "aui-ma-".concat(margin));
|
|
63
|
+
}
|
|
64
|
+
return { className: className, style: style };
|
|
65
|
+
}
|
|
66
|
+
export default Box;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { type CustomLinkElement } from "../Link/Link";
|
|
3
|
-
import type { CornerType } from "../../types";
|
|
3
|
+
import type { CornerType } from "../../utils/types";
|
|
4
4
|
type DefaultButtonProps = React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement> & {
|
|
5
5
|
/**
|
|
6
6
|
* [Optional] This can be used as a link if the `to` prop is provided
|
|
@@ -14,13 +14,6 @@ type DefaultButtonProps = React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTM
|
|
|
14
14
|
*/
|
|
15
15
|
LinkElement?: CustomLinkElement;
|
|
16
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
17
|
type ButtonProps = DefaultButtonProps & {
|
|
25
18
|
/**
|
|
26
19
|
* Type of button
|
|
@@ -39,6 +32,5 @@ type ButtonProps = DefaultButtonProps & {
|
|
|
39
32
|
size?: "regular" | "small";
|
|
40
33
|
};
|
|
41
34
|
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
35
|
declare const Button: React.ForwardRefExoticComponent<Omit<ButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
44
36
|
export default Button;
|
|
@@ -26,18 +26,14 @@ import { UnstyledLink } from "../Link/Link";
|
|
|
26
26
|
import classNames from "../../functions/classNames";
|
|
27
27
|
export var UnstyledButton = forwardRef(function (_a, ref) {
|
|
28
28
|
var to = _a.to, LinkElement = _a.LinkElement, className = _a.className, props = __rest(_a, ["to", "LinkElement", "className"]);
|
|
29
|
-
className = classNames("
|
|
29
|
+
className = classNames("aui-button-base", className);
|
|
30
30
|
if (to) {
|
|
31
31
|
return (_jsx(UnstyledLink, { to: to, className: className, style: props.style, role: "button", LinkElement: LinkElement, "aria-label": props["aria-label"], children: props.children }));
|
|
32
32
|
}
|
|
33
|
-
return (_jsx("button", __assign({}, props, { className: classNames("
|
|
34
|
-
});
|
|
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("ajui-icon-button", className), ref: ref, children: icon })));
|
|
33
|
+
return (_jsx("button", __assign({}, props, { className: classNames("aui-action", className), ref: ref })));
|
|
38
34
|
});
|
|
39
35
|
var Button = forwardRef(function (_a, ref) {
|
|
40
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"]);
|
|
41
|
-
return (_jsx(UnstyledButton, __assign({}, rest, { className: classNames("
|
|
37
|
+
return (_jsx(UnstyledButton, __assign({}, rest, { className: classNames("aui-button--".concat(variant, " aui-button-size--").concat(size, " aui-corners--").concat(corners), className), ref: ref })));
|
|
42
38
|
});
|
|
43
39
|
export default Button;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import Button, { UnstyledButton
|
|
2
|
-
export { UnstyledButton
|
|
1
|
+
import Button, { UnstyledButton } from "./Button";
|
|
2
|
+
export { UnstyledButton };
|
|
3
3
|
export default Button;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import Button, { UnstyledButton
|
|
2
|
-
export { UnstyledButton
|
|
1
|
+
import Button, { UnstyledButton } from "./Button";
|
|
2
|
+
export { UnstyledButton };
|
|
3
3
|
export default Button;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type {
|
|
2
|
+
import type { Children, Style } from "../../utils/types";
|
|
3
|
+
import { type BoxProps } from "../Box/Box";
|
|
3
4
|
type ButtonProps = {
|
|
4
5
|
/**
|
|
5
6
|
* Children to render inside the button
|
|
6
7
|
*/
|
|
7
|
-
children?:
|
|
8
|
+
children?: Children;
|
|
8
9
|
/**
|
|
9
10
|
* Additional class name to apply to the button
|
|
10
11
|
*/
|
|
@@ -14,7 +15,7 @@ type ButtonProps = {
|
|
|
14
15
|
*/
|
|
15
16
|
style?: Style;
|
|
16
17
|
};
|
|
17
|
-
type Props =
|
|
18
|
+
type Props = BoxProps & {
|
|
18
19
|
/**
|
|
19
20
|
* The child elements/slides of the carousel
|
|
20
21
|
*/
|
|
@@ -24,14 +24,16 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
24
24
|
import React, { useState, useEffect, useRef, useCallback } from "react";
|
|
25
25
|
import { classNames } from "../../functions";
|
|
26
26
|
import Button from "../Button";
|
|
27
|
+
import Box from "../Box/Box";
|
|
28
|
+
import Icon from "../Icon";
|
|
27
29
|
var DEFAULT_DURATION_S = 1;
|
|
28
|
-
var Carousel = React.forwardRef(function (
|
|
29
|
-
var
|
|
30
|
-
var children =
|
|
30
|
+
var Carousel = React.forwardRef(function (_a, ref) {
|
|
31
|
+
var _b, _c;
|
|
32
|
+
var children = _a.children, className = _a.className, hideArrows = _a.hideArrows, hideDots = _a.hideDots, dotProps = _a.dotProps, leftArrowProps = _a.leftArrowProps, rightArrowProps = _a.rightArrowProps, autoplayInterval = _a.autoplayInterval, duration = _a.duration, rest = __rest(_a, ["children", "className", "hideArrows", "hideDots", "dotProps", "leftArrowProps", "rightArrowProps", "autoplayInterval", "duration"]);
|
|
31
33
|
// min duration
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
? Math.max(duration,
|
|
34
|
+
duration = Math.max(duration !== null && duration !== void 0 ? duration : DEFAULT_DURATION_S, 0.1);
|
|
35
|
+
autoplayInterval = autoplayInterval
|
|
36
|
+
? Math.max(duration, autoplayInterval)
|
|
35
37
|
: undefined;
|
|
36
38
|
var length = children.length;
|
|
37
39
|
var _d = useState({
|
|
@@ -79,7 +81,7 @@ var Carousel = React.forwardRef(function (props, ref) {
|
|
|
79
81
|
transition: "transform ".concat(duration, "s ease-in-out"),
|
|
80
82
|
}
|
|
81
83
|
: undefined;
|
|
82
|
-
return (_jsxs(
|
|
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)); }) }))] }))] })));
|
|
83
85
|
});
|
|
84
86
|
function safeMod(n, m) {
|
|
85
87
|
return ((n % m) + m) % m;
|
|
@@ -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;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { InputProps } from "./Input";
|
|
3
|
-
import type { CornerType, Style } from "../../types";
|
|
3
|
+
import type { CornerType, Style } from "../../utils/types";
|
|
4
4
|
type IconInputProps = {
|
|
5
5
|
/**
|
|
6
6
|
* [Optional] Icon to display at the start of the input
|
|
@@ -12,8 +12,9 @@ var __assign = (this && this.__assign) || function () {
|
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import { forwardRef } from "react";
|
|
14
14
|
import classNames from "../../functions/classNames";
|
|
15
|
+
import Box from "../Box";
|
|
15
16
|
var IconInput = forwardRef(function (_a, ref) {
|
|
16
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;
|
|
17
|
-
return (_jsxs("
|
|
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
19
|
});
|
|
19
20
|
export default IconInput;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type { CornerType } from "../../types";
|
|
2
|
+
import type { CornerType } from "../../utils/types";
|
|
3
3
|
type Props = React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement> & {
|
|
4
4
|
/**
|
|
5
5
|
* Type of corners on the input
|
|
@@ -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("
|
|
28
|
+
return (_jsx("input", __assign({}, props, { ref: ref, className: classNames("aui-input-base aui-input-default aui-corners--".concat(corners), className) })));
|
|
29
29
|
});
|
|
30
30
|
export default Input;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type { CornerType } from "../../types";
|
|
2
|
+
import type { CornerType } from "../../utils/types";
|
|
3
3
|
type TextAreaProps = React.DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement> & {
|
|
4
4
|
/**
|
|
5
5
|
* Type of corners on the text area
|
|
@@ -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("
|
|
28
|
+
return (_jsx("textarea", __assign({}, props, { ref: ref, className: classNames("aui-input-base aui-input-default 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
|
-
import type
|
|
3
|
-
type Props<T extends React.ElementType> = Omit<
|
|
2
|
+
import { type BoxProps } from "../Box/Box";
|
|
3
|
+
type Props<T extends React.ElementType> = Omit<BoxProps, "children"> & {
|
|
4
4
|
/**
|
|
5
5
|
* Callback that fires when the user clicks outside the layer
|
|
6
6
|
*/
|
|
@@ -24,6 +24,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
24
24
|
import React, { useEffect } from "react";
|
|
25
25
|
import { useFocusTrap, useScrollLock } from "../../hooks";
|
|
26
26
|
import classNames from "../../functions/classNames";
|
|
27
|
+
import Box from "../Box/Box";
|
|
27
28
|
var BaseLayer = function (_a) {
|
|
28
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;
|
|
29
30
|
var focusRef = useFocusTrap(visible);
|
|
@@ -40,7 +41,7 @@ var BaseLayer = function (_a) {
|
|
|
40
41
|
document.removeEventListener("keydown", handleEscape);
|
|
41
42
|
};
|
|
42
43
|
}, [onClose, disableEscape]);
|
|
43
|
-
return (_jsx("
|
|
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
45
|
ref: focusRef,
|
|
45
46
|
onMouseDown: function (e) {
|
|
46
47
|
var _a, _b;
|