@adamjanicki/ui 1.5.9 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,76 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { classNames } from "../functions";
13
+ // Prefix maps for padding and margin keys
14
+ var spacingPrefixMap = {
15
+ padding: "pa",
16
+ paddingTop: "pt",
17
+ paddingBottom: "pb",
18
+ paddingLeft: "pl",
19
+ paddingRight: "pr",
20
+ margin: "ma",
21
+ marginTop: "mt",
22
+ marginBottom: "mb",
23
+ marginLeft: "ml",
24
+ marginRight: "mr",
25
+ };
26
+ var dimensionPrefixMap = {
27
+ width: "w",
28
+ maxWidth: "mw",
29
+ height: "h",
30
+ maxHeight: "mh",
31
+ };
32
+ export default function transformLayout(layout) {
33
+ if (!layout)
34
+ return null;
35
+ var axis = layout.axis, gap = layout.gap, align = layout.align, justify = layout.justify, wrap = layout.wrap, padding = layout.padding, paddingTop = layout.paddingTop, paddingBottom = layout.paddingBottom, paddingLeft = layout.paddingLeft, paddingRight = layout.paddingRight, paddingX = layout.paddingX, paddingY = layout.paddingY, margin = layout.margin, marginTop = layout.marginTop, marginBottom = layout.marginBottom, marginLeft = layout.marginLeft, marginRight = layout.marginRight, marginX = layout.marginX, marginY = layout.marginY, rest = __rest(layout, ["axis", "gap", "align", "justify", "wrap", "padding", "paddingTop", "paddingBottom", "paddingLeft", "paddingRight", "paddingX", "paddingY", "margin", "marginTop", "marginBottom", "marginLeft", "marginRight", "marginX", "marginY"]);
36
+ var className = axis ? "aui-flex-".concat(axis) : null;
37
+ if (wrap)
38
+ className = classNames(className, "aui-flex-wrap");
39
+ if (align)
40
+ className = classNames(className, "aui-align-".concat(align));
41
+ if (justify)
42
+ className = classNames(className, "aui-justify-".concat(justify));
43
+ // Gap
44
+ if (gap) {
45
+ className = classNames(className, "aui-gap-".concat(gap));
46
+ }
47
+ // Padding & margin
48
+ var spacingProps = [
49
+ ["padding", padding],
50
+ ["paddingTop", paddingTop !== null && paddingTop !== void 0 ? paddingTop : paddingY],
51
+ ["paddingBottom", paddingBottom !== null && paddingBottom !== void 0 ? paddingBottom : paddingY],
52
+ ["paddingLeft", paddingLeft !== null && paddingLeft !== void 0 ? paddingLeft : paddingX],
53
+ ["paddingRight", paddingRight !== null && paddingRight !== void 0 ? paddingRight : paddingX],
54
+ ["margin", margin],
55
+ ["marginTop", marginTop !== null && marginTop !== void 0 ? marginTop : marginY],
56
+ ["marginBottom", marginBottom !== null && marginBottom !== void 0 ? marginBottom : marginY],
57
+ ["marginLeft", marginLeft !== null && marginLeft !== void 0 ? marginLeft : marginX],
58
+ ["marginRight", marginRight !== null && marginRight !== void 0 ? marginRight : marginX],
59
+ ];
60
+ spacingProps.forEach(function (_a) {
61
+ var prop = _a[0], value = _a[1];
62
+ if (value) {
63
+ var prefix = spacingPrefixMap[prop];
64
+ className = classNames(className, "aui-".concat(prefix, "-").concat(value));
65
+ }
66
+ });
67
+ var dimensionProps = ["width", "height", "maxWidth", "maxHeight"];
68
+ dimensionProps.forEach(function (prop) {
69
+ var value = rest[prop];
70
+ if (value) {
71
+ var prefix = dimensionPrefixMap[prop];
72
+ className = classNames(className, "aui-".concat(prefix, "-").concat(value));
73
+ }
74
+ });
75
+ return className;
76
+ }
package/utils/types.d.ts CHANGED
@@ -16,47 +16,64 @@ export type ContentType = "success" | "warning" | "error" | "info" | "static";
16
16
  */
17
17
  export type Style = React.CSSProperties;
18
18
  /**
19
- * Size variants used for CSS.
19
+ * Used for width and height
20
20
  */
21
- type SizeToken = "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl";
21
+ export type SizeDimension = "full" | "fit" | "min" | "max";
22
22
  /**
23
- * Size prop used to transform into a CSS class or style value if a number.
23
+ * Size variants used for CSS.
24
24
  */
25
- type Size = SizeToken | number;
25
+ type SizeToken = "none" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl";
26
26
  /**
27
- * Layout props for a box component.
27
+ * Used for margin
28
28
  */
29
+ type AutoSize = SizeToken | "auto";
30
+ /** Layout props for a component */
29
31
  export type Layout = {
30
- /**
31
- * Direction the box spans; along the x-axis or y-axis
32
- * (Equivalent to flex-direction)
33
- */
34
- axis: "x" | "y";
35
- /**
36
- * Spacing between children of the box
37
- */
38
- gap?: Size;
39
- /**
40
- * Alignment orthogonal to the selected axis
41
- * (Equivalent to align-items)
42
- */
32
+ /** Direction the layout spans; along the x-axis or y-axis (Equivalent to flex-direction) */
33
+ axis?: "x" | "y" | "-x" | "-y";
34
+ /** Spacing between children of the layout */
35
+ gap?: SizeToken;
36
+ /** Alignment orthogonal to the selected axis (Equivalent to align-items) */
43
37
  align?: "start" | "center" | "end";
44
- /**
45
- * How to layout the children
46
- * (Equivalent to justify-content)
47
- */
48
- justify?: "start" | "center" | "between" | "end";
49
- /**
50
- * Padding on the inside of the box
51
- */
52
- padding?: Size;
53
- /**
54
- * Margin on the outside of the box
55
- */
56
- margin?: Size;
57
- /**
58
- * Whether to allow wrapping of box children
59
- */
38
+ /** How to layout the children (Equivalent to justify-content) */
39
+ justify?: "start" | "center" | "between" | "around" | "end";
40
+ /** Whether to allow wrapping of layout children */
60
41
  wrap?: boolean;
42
+ /** Padding inside the layout */
43
+ padding?: SizeToken;
44
+ /** Horizontal padding inside the layout */
45
+ paddingX?: SizeToken;
46
+ /** Vertical padding inside the layout */
47
+ paddingY?: SizeToken;
48
+ /** Top padding inside the layout */
49
+ paddingTop?: SizeToken;
50
+ /** Bottom padding inside the layout */
51
+ paddingBottom?: SizeToken;
52
+ /** Left padding inside the layout */
53
+ paddingLeft?: SizeToken;
54
+ /** Right padding inside the layout */
55
+ paddingRight?: SizeToken;
56
+ /** Margin outside the layout */
57
+ margin?: AutoSize;
58
+ /** Horizontal margin outside the layout */
59
+ marginX?: AutoSize;
60
+ /** Vertical margin outside the layout */
61
+ marginY?: AutoSize;
62
+ /** Top margin outside the layout */
63
+ marginTop?: AutoSize;
64
+ /** Bottom margin outside the layout */
65
+ marginBottom?: AutoSize;
66
+ /** Left margin outside the layout */
67
+ marginLeft?: AutoSize;
68
+ /** Right margin outside the layout */
69
+ marginRight?: AutoSize;
70
+ /** Width of the layout */
71
+ width?: SizeDimension;
72
+ /** Maximum width of the layout */
73
+ maxWidth?: SizeDimension;
74
+ /** Height of the laout */
75
+ height?: SizeDimension;
76
+ /** Maximum of the layout */
77
+ maxHeight?: SizeDimension;
61
78
  };
62
79
  export {};
package/vite.config.ts ADDED
@@ -0,0 +1,23 @@
1
+ import { defineConfig } from "vite";
2
+ import react from "@vitejs/plugin-react";
3
+
4
+ export default defineConfig({
5
+ plugins: [react()],
6
+ build: {
7
+ lib: {
8
+ entry: "src/index.tsx",
9
+ name: "Aui",
10
+ formats: ["es", "cjs", "umd"],
11
+ fileName: (format) => `aui.${format}.js`,
12
+ },
13
+ rollupOptions: {
14
+ external: ["react", "react-dom"],
15
+ output: {
16
+ globals: {
17
+ react: "React",
18
+ "react-dom": "ReactDOM",
19
+ },
20
+ },
21
+ },
22
+ },
23
+ });