@adamjanicki/ui 1.6.5 → 1.6.6

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.
@@ -43,7 +43,7 @@ var Drawer = function (_a) {
43
43
  }, [open, children]);
44
44
  // TODO: change this to use calc-size when supported
45
45
  // https://developer.mozilla.org/en-US/docs/Web/CSS/calc-size#browser_compatibility
46
- 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: "s", padding: "m" }, children: [_jsx(Icon, { size: "xs", icon: open ? "chevron-down" : "chevron-right", className: "aui-accordion-arrow" }), _jsx("span", { className: "aui-accordion-label", children: item.label })] }) }), _jsx(Animated, { style: { overflow: "hidden" }, keepMounted: true, duration: duration, visible: open, animateFrom: {
46
+ 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: "s", padding: "m" }, children: [_jsx(Icon, { size: "xs", icon: open ? "chevron-down" : "chevron-right", className: "aui-accordion-arrow" }), _jsx(Box, { className: "aui-accordion-label", children: item.label })] }) }), _jsx(Animated, { style: { overflow: "hidden" }, keepMounted: true, duration: duration, visible: open, animateFrom: {
47
47
  style: {
48
48
  visibility: "hidden",
49
49
  height: 0,
@@ -1,15 +1,6 @@
1
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 };
2
+ declare const Box: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
3
+ layout?: import("../../utils/types").Layout;
4
+ }, "ref"> & React.RefAttributes<HTMLDivElement>>;
5
+ export type BoxProps = React.ComponentProps<typeof Box>;
15
6
  export default Box;
@@ -1,31 +1,3 @@
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
- import transformLayout from "../../utils/transformLayout";
27
- var Box = React.forwardRef(function (_a, ref) {
28
- var layout = _a.layout, className = _a.className, rest = __rest(_a, ["layout", "className"]);
29
- return (_jsx("div", __assign({}, rest, { className: classNames(transformLayout(layout), className), ref: ref })));
30
- });
1
+ import ui from "../ui";
2
+ var Box = ui.div;
31
3
  export default Box;
@@ -85,7 +85,7 @@ var Carousel = React.forwardRef(function (_a, ref) {
85
85
  axis: delta >= 0 ? "x" : "-x",
86
86
  width: "full",
87
87
  height: "full",
88
- }, style: animatingStyles, 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: "chevron-left", size: "xs", 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: "chevron-right", size: "xs", style: { marginLeft: 2 } })) })] })), !hideDots && (_jsx(Box, { layout: { axis: "x", align: "center", gap: "xxs" }, 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)); }) }))] }))] })));
88
+ }, style: animatingStyles, 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, { layout: { axis: "x", align: "center", justify: "center" }, className: classNames("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: "chevron-left", size: "xs", style: { marginRight: 2 } })) }), _jsx(Button, { layout: { axis: "x", align: "center", justify: "center" }, className: classNames("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: "chevron-right", size: "xs", style: { marginLeft: 2 } })) })] })), !hideDots && (_jsx(Box, { layout: { axis: "x", align: "center", gap: "xxs" }, 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)); }) }))] }))] })));
89
89
  });
90
90
  function safeMod(n, m) {
91
91
  return ((n % m) + m) % m;
@@ -0,0 +1,16 @@
1
+ import React from "react";
2
+ import type { Layout } from "../utils/types";
3
+ type HtmlTag = keyof React.JSX.IntrinsicElements;
4
+ type Props<T extends HtmlTag> = React.ComponentPropsWithRef<T> & {
5
+ /**
6
+ * The organization of this element and its children.
7
+ * Properties are translated to class names before being applied.
8
+ */
9
+ layout?: Layout;
10
+ };
11
+ declare function createLayoutElement<T extends HtmlTag>(tag: T): React.ForwardRefExoticComponent<React.PropsWithoutRef<Props<T>> & React.RefAttributes<React.ComponentRef<T>>>;
12
+ type HtmlTags = {
13
+ [K in HtmlTag]: ReturnType<typeof createLayoutElement<K>>;
14
+ };
15
+ declare const ui: HtmlTags;
16
+ export default ui;
@@ -0,0 +1,44 @@
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 React from "react";
24
+ import { classNames } from "../functions";
25
+ import transformLayout from "../utils/transformLayout";
26
+ function createLayoutElement(tag) {
27
+ var Component = React.forwardRef(function (_a, ref) {
28
+ var layout = _a.layout, className = _a.className, props = __rest(_a, ["layout", "className"]);
29
+ return React.createElement(tag, __assign(__assign({}, props), { ref: ref, className: classNames(transformLayout(layout), className) }));
30
+ });
31
+ return Component;
32
+ }
33
+ var ui = new Proxy({}, {
34
+ get: function (cache, tag) {
35
+ var cachedComponent = cache[tag];
36
+ if (cachedComponent) {
37
+ return cachedComponent;
38
+ }
39
+ var component = createLayoutElement(tag);
40
+ cache[tag] = component;
41
+ return component;
42
+ },
43
+ });
44
+ export default ui;
package/index.d.ts CHANGED
@@ -20,5 +20,6 @@ export * from "./components/Link";
20
20
  export { default as Modal } from "./components/Modal";
21
21
  export { default as Select } from "./components/Select";
22
22
  export { default as Spinner } from "./components/Spinner";
23
+ export { default as ui } from "./components/ui";
23
24
  export * from "./hooks";
24
25
  export * from "./functions";
package/index.js CHANGED
@@ -21,6 +21,7 @@ export * from "./components/Link";
21
21
  export { default as Modal } from "./components/Modal";
22
22
  export { default as Select } from "./components/Select";
23
23
  export { default as Spinner } from "./components/Spinner";
24
+ export { default as ui } from "./components/ui";
24
25
  // Hooks
25
26
  export * from "./hooks";
26
27
  // Functions
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adamjanicki/ui",
3
- "version": "1.6.5",
3
+ "version": "1.6.6",
4
4
  "description": "Basic UI components and hooks for React in TypeScript",
5
5
  "type": "module",
6
6
  "main": "./index.js",