@versini/ui-system 5.1.0 → 6.0.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.
- package/README.md +2 -1
- package/dist/common/constants.d.ts +4 -0
- package/dist/common/constants.js +8 -0
- package/dist/components/Flexgrid/Flexgrid.d.ts +3 -0
- package/dist/components/Flexgrid/Flexgrid.js +60 -38
- package/dist/components/Flexgrid/FlexgridContext.d.ts +5 -0
- package/dist/components/Flexgrid/FlexgridContext.js +12 -0
- package/dist/components/Flexgrid/FlexgridItem.d.ts +7 -0
- package/dist/components/Flexgrid/FlexgridItem.js +42 -116
- package/dist/components/Flexgrid/utilities.d.ts +16 -0
- package/dist/components/Flexgrid/utilities.js +123 -0
- package/dist/components/ThemeProvider/ThemeProvider.d.ts +2 -0
- package/dist/components/ThemeProvider/ThemeProvider.js +44 -20
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.js +17 -0
- package/package.json +24 -12
- package/dist/chunks/FlexgridContext.W67Qim_P.js +0 -8
- package/dist/chunks/constants.Gcd2KXZh.js +0 -7
- package/dist/index.d.ts +0 -137
- package/dist/index.js +0 -17
package/README.md
CHANGED
|
@@ -32,7 +32,8 @@ npm install @versini/ui-system
|
|
|
32
32
|
### Basic Grid Layout
|
|
33
33
|
|
|
34
34
|
```tsx
|
|
35
|
-
import { Flexgrid
|
|
35
|
+
import { Flexgrid } from "@versini/ui-system/flexgrid";
|
|
36
|
+
import { FlexgridItem } from "@versini/ui-system/flexgrid-item";
|
|
36
37
|
|
|
37
38
|
function App() {
|
|
38
39
|
return (
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
|
|
2
|
+
;// CONCATENATED MODULE: ./src/common/constants.ts
|
|
3
|
+
const FLEXGRID_CLASSNAME = "av-flexgrid";
|
|
4
|
+
const FLEXGRID_ITEM_CLASSNAME = "av-flexgrid-item";
|
|
5
|
+
const THEMEPROVIDER_CLASSNAME = "av-theme-provider";
|
|
6
|
+
const FLEXGRID_GAP_RATIO = 0.25;
|
|
7
|
+
|
|
8
|
+
export { FLEXGRID_CLASSNAME, FLEXGRID_GAP_RATIO, FLEXGRID_ITEM_CLASSNAME, THEMEPROVIDER_CLASSNAME };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { FlexgridProps } from "./FlexgridTypes";
|
|
2
|
+
export declare const Flexgrid: ({ children, className, columnGap, rowGap, height, width, direction, alignHorizontal, alignVertical, ...otherProps }: FlexgridProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export default Flexgrid;
|
|
@@ -1,39 +1,61 @@
|
|
|
1
|
-
import { jsx
|
|
2
|
-
import
|
|
3
|
-
import { FLEXGRID_CLASSNAME
|
|
4
|
-
import { FlexgridContext
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
import { FLEXGRID_CLASSNAME, FLEXGRID_GAP_RATIO } from "../../common/constants.js";
|
|
4
|
+
import { FlexgridContext } from "./FlexgridContext.js";
|
|
5
|
+
|
|
6
|
+
;// CONCATENATED MODULE: external "react/jsx-runtime"
|
|
7
|
+
|
|
8
|
+
;// CONCATENATED MODULE: external "clsx"
|
|
9
|
+
|
|
10
|
+
;// CONCATENATED MODULE: external "../../common/constants.js"
|
|
11
|
+
|
|
12
|
+
;// CONCATENATED MODULE: external "./FlexgridContext.js"
|
|
13
|
+
|
|
14
|
+
;// CONCATENATED MODULE: ./src/components/Flexgrid/Flexgrid.tsx
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
const Flexgrid = ({ children, className, columnGap = 1, rowGap = 0, height = "auto", width = "auto", direction = "row", alignHorizontal = "normal", alignVertical = "normal", ...otherProps })=>{
|
|
20
|
+
const cssRoot = {
|
|
21
|
+
flexDirection: direction,
|
|
22
|
+
justifyContent: alignHorizontal,
|
|
23
|
+
alignItems: alignVertical,
|
|
24
|
+
height,
|
|
25
|
+
width,
|
|
26
|
+
/**
|
|
27
|
+
* Trick to account for the extra space taken
|
|
28
|
+
* by the columnGap and rowGap that will be applied
|
|
29
|
+
* to all FlexgridItems (see context and paddings).
|
|
30
|
+
*/ marginLeft: columnGap * -1 * FLEXGRID_GAP_RATIO + "rem",
|
|
31
|
+
marginTop: rowGap * -1 * FLEXGRID_GAP_RATIO + "rem"
|
|
32
|
+
};
|
|
33
|
+
const flexgridClassName = clsx(FLEXGRID_CLASSNAME, "box-border flex flex-wrap");
|
|
34
|
+
const context = {
|
|
35
|
+
columnGap,
|
|
36
|
+
rowGap
|
|
37
|
+
};
|
|
38
|
+
return className ? /*#__PURE__*/ jsx("div", {
|
|
39
|
+
className: className,
|
|
40
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
41
|
+
className: flexgridClassName,
|
|
42
|
+
style: cssRoot,
|
|
43
|
+
...otherProps,
|
|
44
|
+
children: /*#__PURE__*/ jsx(FlexgridContext.Provider, {
|
|
45
|
+
value: context,
|
|
46
|
+
children: children
|
|
47
|
+
})
|
|
48
|
+
})
|
|
49
|
+
}) : /*#__PURE__*/ jsx("div", {
|
|
50
|
+
className: flexgridClassName,
|
|
51
|
+
style: cssRoot,
|
|
52
|
+
...otherProps,
|
|
53
|
+
children: /*#__PURE__*/ jsx(FlexgridContext.Provider, {
|
|
54
|
+
value: context,
|
|
55
|
+
children: children
|
|
56
|
+
})
|
|
57
|
+
});
|
|
39
58
|
};
|
|
59
|
+
/* export default */ const Flexgrid_Flexgrid = (Flexgrid);
|
|
60
|
+
|
|
61
|
+
export { Flexgrid, Flexgrid_Flexgrid as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import react from "react";
|
|
2
|
+
|
|
3
|
+
;// CONCATENATED MODULE: external "react"
|
|
4
|
+
|
|
5
|
+
;// CONCATENATED MODULE: ./src/components/Flexgrid/FlexgridContext.ts
|
|
6
|
+
|
|
7
|
+
const FlexgridContext = react.createContext({
|
|
8
|
+
columnGap: 0,
|
|
9
|
+
rowGap: 0
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export { FlexgridContext };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { FlexgridItemProps } from "./FlexgridTypes";
|
|
2
|
+
/**
|
|
3
|
+
* FlexgridItem is a child of Flexgrid. It is used to define the width of a
|
|
4
|
+
* column in a Flexgrid. It can be used to span across multiple columns in a
|
|
5
|
+
* Flexgrid by providing a number of columns or "auto" value to the `span` prop.
|
|
6
|
+
*/
|
|
7
|
+
export declare const FlexgridItem: ({ children, className, span, ...otherProps }: FlexgridItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,119 +1,45 @@
|
|
|
1
|
-
import { jsx
|
|
2
|
-
import { useContext
|
|
3
|
-
import {
|
|
4
|
-
import { FlexgridContext
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"2xl:basis-5/12": l === 5 && s === "2xl",
|
|
37
|
-
"basis-6/12": l === 6 && !s,
|
|
38
|
-
"sm:basis-6/12": l === 6 && s === "sm",
|
|
39
|
-
"md:basis-6/12": l === 6 && s === "md",
|
|
40
|
-
"lg:basis-6/12": l === 6 && s === "lg",
|
|
41
|
-
"xl:basis-6/12": l === 6 && s === "xl",
|
|
42
|
-
"2xl:basis-6/12": l === 6 && s === "2xl",
|
|
43
|
-
"basis-7/12": l === 7 && !s,
|
|
44
|
-
"sm:basis-7/12": l === 7 && s === "sm",
|
|
45
|
-
"md:basis-7/12": l === 7 && s === "md",
|
|
46
|
-
"lg:basis-7/12": l === 7 && s === "lg",
|
|
47
|
-
"xl:basis-7/12": l === 7 && s === "xl",
|
|
48
|
-
"2xl:basis-7/12": l === 7 && s === "2xl",
|
|
49
|
-
"basis-8/12": l === 8 && !s,
|
|
50
|
-
"sm:basis-8/12": l === 8 && s === "sm",
|
|
51
|
-
"md:basis-8/12": l === 8 && s === "md",
|
|
52
|
-
"lg:basis-8/12": l === 8 && s === "lg",
|
|
53
|
-
"xl:basis-8/12": l === 8 && s === "xl",
|
|
54
|
-
"2xl:basis-8/12": l === 8 && s === "2xl",
|
|
55
|
-
"basis-9/12": l === 9 && !s,
|
|
56
|
-
"sm:basis-9/12": l === 9 && s === "sm",
|
|
57
|
-
"md:basis-9/12": l === 9 && s === "md",
|
|
58
|
-
"lg:basis-9/12": l === 9 && s === "lg",
|
|
59
|
-
"xl:basis-9/12": l === 9 && s === "xl",
|
|
60
|
-
"2xl:basis-9/12": l === 9 && s === "2xl",
|
|
61
|
-
"basis-10/12": l === 10 && !s,
|
|
62
|
-
"sm:basis-10/12": l === 10 && s === "sm",
|
|
63
|
-
"md:basis-10/12": l === 10 && s === "md",
|
|
64
|
-
"lg:basis-10/12": l === 10 && s === "lg",
|
|
65
|
-
"xl:basis-10/12": l === 10 && s === "xl",
|
|
66
|
-
"2xl:basis-10/12": l === 10 && s === "2xl",
|
|
67
|
-
"basis-11/12": l === 11 && !s,
|
|
68
|
-
"sm:basis-11/12": l === 11 && s === "sm",
|
|
69
|
-
"md:basis-11/12": l === 11 && s === "md",
|
|
70
|
-
"lg:basis-11/12": l === 11 && s === "lg",
|
|
71
|
-
"xl:basis-11/12": l === 11 && s === "xl",
|
|
72
|
-
"2xl:basis-11/12": l === 11 && s === "2xl",
|
|
73
|
-
"basis-full": l === 12 && !s,
|
|
74
|
-
"sm:basis-full": l === 12 && s === "sm",
|
|
75
|
-
"md:basis-full": l === 12 && s === "md",
|
|
76
|
-
"lg:basis-full": l === 12 && s === "lg",
|
|
77
|
-
"xl:basis-full": l === 12 && s === "xl",
|
|
78
|
-
"2xl:basis-full": l === 12 && s === "2xl"
|
|
79
|
-
}), w = ({
|
|
80
|
-
className: l,
|
|
81
|
-
span: s
|
|
82
|
-
}) => {
|
|
83
|
-
if (!s)
|
|
84
|
-
return m(l, g, "box-border basis-auto");
|
|
85
|
-
if (typeof s == "number")
|
|
86
|
-
return m(l, g, "box-border max-w-full", {
|
|
87
|
-
[`${i(s)}`]: !0
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useContext } from "react";
|
|
3
|
+
import { FLEXGRID_GAP_RATIO } from "../../common/constants.js";
|
|
4
|
+
import { FlexgridContext } from "./FlexgridContext.js";
|
|
5
|
+
import { getFlexItemClasses } from "./utilities.js";
|
|
6
|
+
|
|
7
|
+
;// CONCATENATED MODULE: external "react/jsx-runtime"
|
|
8
|
+
|
|
9
|
+
;// CONCATENATED MODULE: external "react"
|
|
10
|
+
|
|
11
|
+
;// CONCATENATED MODULE: external "../../common/constants.js"
|
|
12
|
+
|
|
13
|
+
;// CONCATENATED MODULE: external "./FlexgridContext.js"
|
|
14
|
+
|
|
15
|
+
;// CONCATENATED MODULE: external "./utilities.js"
|
|
16
|
+
|
|
17
|
+
;// CONCATENATED MODULE: ./src/components/Flexgrid/FlexgridItem.tsx
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* FlexgridItem is a child of Flexgrid. It is used to define the width of a
|
|
25
|
+
* column in a Flexgrid. It can be used to span across multiple columns in a
|
|
26
|
+
* Flexgrid by providing a number of columns or "auto" value to the `span` prop.
|
|
27
|
+
*/ const FlexgridItem = ({ children, className, span, ...otherProps })=>{
|
|
28
|
+
const { columnGap, rowGap } = useContext(FlexgridContext);
|
|
29
|
+
const cssRoot = {
|
|
30
|
+
paddingLeft: columnGap * FLEXGRID_GAP_RATIO + "rem",
|
|
31
|
+
paddingTop: rowGap * FLEXGRID_GAP_RATIO + "rem"
|
|
32
|
+
};
|
|
33
|
+
const flexgridItemClassName = getFlexItemClasses({
|
|
34
|
+
className,
|
|
35
|
+
span
|
|
88
36
|
});
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
37
|
+
return /*#__PURE__*/ jsx("div", {
|
|
38
|
+
className: flexgridItemClassName,
|
|
39
|
+
style: cssRoot,
|
|
40
|
+
...otherProps,
|
|
41
|
+
children: children
|
|
92
42
|
});
|
|
93
|
-
if (typeof s == "object") {
|
|
94
|
-
const f = Object.entries(s).map(([x, d]) => x === "fallback" ? i(d) : i(d, x));
|
|
95
|
-
return m(
|
|
96
|
-
l,
|
|
97
|
-
g,
|
|
98
|
-
"box-border",
|
|
99
|
-
f
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
}, j = ({
|
|
103
|
-
children: l,
|
|
104
|
-
className: s,
|
|
105
|
-
span: f,
|
|
106
|
-
...x
|
|
107
|
-
}) => {
|
|
108
|
-
const { columnGap: d, rowGap: b } = F(G), c = {
|
|
109
|
-
paddingLeft: d * u + "rem",
|
|
110
|
-
paddingTop: b * u + "rem"
|
|
111
|
-
}, C = w({
|
|
112
|
-
className: s,
|
|
113
|
-
span: f
|
|
114
|
-
});
|
|
115
|
-
return /* @__PURE__ */ I("div", { className: C, style: c, ...x, children: l });
|
|
116
|
-
};
|
|
117
|
-
export {
|
|
118
|
-
j as FlexgridItem
|
|
119
43
|
};
|
|
44
|
+
|
|
45
|
+
export { FlexgridItem };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the classes for a FlexgridItem component.
|
|
3
|
+
* @param className - The class name to be applied to the FlexgridItem.
|
|
4
|
+
* @param span - The number of columns to span across in the Flexgrid.
|
|
5
|
+
* @returns The classes for a FlexgridItem component.
|
|
6
|
+
*/
|
|
7
|
+
export declare const getFlexItemClasses: ({ className, span, }: {
|
|
8
|
+
className?: string;
|
|
9
|
+
span?: number | "auto" | {
|
|
10
|
+
fallback?: number;
|
|
11
|
+
lg?: number;
|
|
12
|
+
md?: number;
|
|
13
|
+
sm?: number;
|
|
14
|
+
xl?: number;
|
|
15
|
+
};
|
|
16
|
+
}) => string | undefined;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import clsx from "clsx";
|
|
2
|
+
import { FLEXGRID_ITEM_CLASSNAME } from "../../common/constants.js";
|
|
3
|
+
|
|
4
|
+
;// CONCATENATED MODULE: external "clsx"
|
|
5
|
+
|
|
6
|
+
;// CONCATENATED MODULE: external "../../common/constants.js"
|
|
7
|
+
|
|
8
|
+
;// CONCATENATED MODULE: ./src/components/Flexgrid/utilities.ts
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
const getBasisClass = (span, breakpoint)=>{
|
|
12
|
+
return clsx({
|
|
13
|
+
"basis-1/12": span === 1 && !breakpoint,
|
|
14
|
+
"sm:basis-1/12": span === 1 && breakpoint === "sm",
|
|
15
|
+
"md:basis-1/12": span === 1 && breakpoint === "md",
|
|
16
|
+
"lg:basis-1/12": span === 1 && breakpoint === "lg",
|
|
17
|
+
"xl:basis-1/12": span === 1 && breakpoint === "xl",
|
|
18
|
+
"2xl:basis-1/12": span === 1 && breakpoint === "2xl",
|
|
19
|
+
"basis-2/12": span === 2 && !breakpoint,
|
|
20
|
+
"sm:basis-2/12": span === 2 && breakpoint === "sm",
|
|
21
|
+
"md:basis-2/12": span === 2 && breakpoint === "md",
|
|
22
|
+
"lg:basis-2/12": span === 2 && breakpoint === "lg",
|
|
23
|
+
"xl:basis-2/12": span === 2 && breakpoint === "xl",
|
|
24
|
+
"2xl:basis-2/12": span === 2 && breakpoint === "2xl",
|
|
25
|
+
"basis-3/12": span === 3 && !breakpoint,
|
|
26
|
+
"sm:basis-3/12": span === 3 && breakpoint === "sm",
|
|
27
|
+
"md:basis-3/12": span === 3 && breakpoint === "md",
|
|
28
|
+
"lg:basis-3/12": span === 3 && breakpoint === "lg",
|
|
29
|
+
"xl:basis-3/12": span === 3 && breakpoint === "xl",
|
|
30
|
+
"2xl:basis-3/12": span === 3 && breakpoint === "2xl",
|
|
31
|
+
"basis-4/12": span === 4 && !breakpoint,
|
|
32
|
+
"sm:basis-4/12": span === 4 && breakpoint === "sm",
|
|
33
|
+
"md:basis-4/12": span === 4 && breakpoint === "md",
|
|
34
|
+
"lg:basis-4/12": span === 4 && breakpoint === "lg",
|
|
35
|
+
"xl:basis-4/12": span === 4 && breakpoint === "xl",
|
|
36
|
+
"2xl:basis-4/12": span === 4 && breakpoint === "2xl",
|
|
37
|
+
"basis-5/12": span === 5 && !breakpoint,
|
|
38
|
+
"sm:basis-5/12": span === 5 && breakpoint === "sm",
|
|
39
|
+
"md:basis-5/12": span === 5 && breakpoint === "md",
|
|
40
|
+
"lg:basis-5/12": span === 5 && breakpoint === "lg",
|
|
41
|
+
"xl:basis-5/12": span === 5 && breakpoint === "xl",
|
|
42
|
+
"2xl:basis-5/12": span === 5 && breakpoint === "2xl",
|
|
43
|
+
"basis-6/12": span === 6 && !breakpoint,
|
|
44
|
+
"sm:basis-6/12": span === 6 && breakpoint === "sm",
|
|
45
|
+
"md:basis-6/12": span === 6 && breakpoint === "md",
|
|
46
|
+
"lg:basis-6/12": span === 6 && breakpoint === "lg",
|
|
47
|
+
"xl:basis-6/12": span === 6 && breakpoint === "xl",
|
|
48
|
+
"2xl:basis-6/12": span === 6 && breakpoint === "2xl",
|
|
49
|
+
"basis-7/12": span === 7 && !breakpoint,
|
|
50
|
+
"sm:basis-7/12": span === 7 && breakpoint === "sm",
|
|
51
|
+
"md:basis-7/12": span === 7 && breakpoint === "md",
|
|
52
|
+
"lg:basis-7/12": span === 7 && breakpoint === "lg",
|
|
53
|
+
"xl:basis-7/12": span === 7 && breakpoint === "xl",
|
|
54
|
+
"2xl:basis-7/12": span === 7 && breakpoint === "2xl",
|
|
55
|
+
"basis-8/12": span === 8 && !breakpoint,
|
|
56
|
+
"sm:basis-8/12": span === 8 && breakpoint === "sm",
|
|
57
|
+
"md:basis-8/12": span === 8 && breakpoint === "md",
|
|
58
|
+
"lg:basis-8/12": span === 8 && breakpoint === "lg",
|
|
59
|
+
"xl:basis-8/12": span === 8 && breakpoint === "xl",
|
|
60
|
+
"2xl:basis-8/12": span === 8 && breakpoint === "2xl",
|
|
61
|
+
"basis-9/12": span === 9 && !breakpoint,
|
|
62
|
+
"sm:basis-9/12": span === 9 && breakpoint === "sm",
|
|
63
|
+
"md:basis-9/12": span === 9 && breakpoint === "md",
|
|
64
|
+
"lg:basis-9/12": span === 9 && breakpoint === "lg",
|
|
65
|
+
"xl:basis-9/12": span === 9 && breakpoint === "xl",
|
|
66
|
+
"2xl:basis-9/12": span === 9 && breakpoint === "2xl",
|
|
67
|
+
"basis-10/12": span === 10 && !breakpoint,
|
|
68
|
+
"sm:basis-10/12": span === 10 && breakpoint === "sm",
|
|
69
|
+
"md:basis-10/12": span === 10 && breakpoint === "md",
|
|
70
|
+
"lg:basis-10/12": span === 10 && breakpoint === "lg",
|
|
71
|
+
"xl:basis-10/12": span === 10 && breakpoint === "xl",
|
|
72
|
+
"2xl:basis-10/12": span === 10 && breakpoint === "2xl",
|
|
73
|
+
"basis-11/12": span === 11 && !breakpoint,
|
|
74
|
+
"sm:basis-11/12": span === 11 && breakpoint === "sm",
|
|
75
|
+
"md:basis-11/12": span === 11 && breakpoint === "md",
|
|
76
|
+
"lg:basis-11/12": span === 11 && breakpoint === "lg",
|
|
77
|
+
"xl:basis-11/12": span === 11 && breakpoint === "xl",
|
|
78
|
+
"2xl:basis-11/12": span === 11 && breakpoint === "2xl",
|
|
79
|
+
"basis-full": span === 12 && !breakpoint,
|
|
80
|
+
"sm:basis-full": span === 12 && breakpoint === "sm",
|
|
81
|
+
"md:basis-full": span === 12 && breakpoint === "md",
|
|
82
|
+
"lg:basis-full": span === 12 && breakpoint === "lg",
|
|
83
|
+
"xl:basis-full": span === 12 && breakpoint === "xl",
|
|
84
|
+
"2xl:basis-full": span === 12 && breakpoint === "2xl"
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Returns the classes for a FlexgridItem component.
|
|
89
|
+
* @param className - The class name to be applied to the FlexgridItem.
|
|
90
|
+
* @param span - The number of columns to span across in the Flexgrid.
|
|
91
|
+
* @returns The classes for a FlexgridItem component.
|
|
92
|
+
*/ const getFlexItemClasses = ({ className, span })=>{
|
|
93
|
+
if (!span) {
|
|
94
|
+
return clsx(className, FLEXGRID_ITEM_CLASSNAME, "box-border basis-auto");
|
|
95
|
+
}
|
|
96
|
+
if (typeof span === "number") {
|
|
97
|
+
return clsx(className, FLEXGRID_ITEM_CLASSNAME, "box-border max-w-full", {
|
|
98
|
+
[`${getBasisClass(span)}`]: true
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
if (typeof span === "string") {
|
|
102
|
+
return clsx(className, FLEXGRID_ITEM_CLASSNAME, "box-border basis-auto", {
|
|
103
|
+
"max-w-full grow": span === "auto"
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* If span is an object, it means it's a responsive prop.
|
|
108
|
+
* For example:
|
|
109
|
+
* { fallback: 12, sm: 6, md: 3, lg: 3, xl: 12 }
|
|
110
|
+
* should be converted to:
|
|
111
|
+
* "basis-full sm:basis-6/12 md:basis-3/12 lg:basis-3/12 xl:basis-full"
|
|
112
|
+
*/ /* v8 ignore start - responsive span object handling */ if (typeof span === "object") {
|
|
113
|
+
const responsiveClasses = Object.entries(span).map(([key, value])=>{
|
|
114
|
+
if (key === "fallback") {
|
|
115
|
+
return getBasisClass(value);
|
|
116
|
+
}
|
|
117
|
+
return getBasisClass(value, key);
|
|
118
|
+
});
|
|
119
|
+
return clsx(className, FLEXGRID_ITEM_CLASSNAME, "box-border", responsiveClasses);
|
|
120
|
+
}
|
|
121
|
+
/* v8 ignore stop */ };
|
|
122
|
+
|
|
123
|
+
export { getFlexItemClasses };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { ThemeProviderProps } from "./ThemeProviderTypes";
|
|
2
|
+
export declare const ThemeProvider: ({ customTheme, children, global, className, }: ThemeProviderProps) => string | number | bigint | boolean | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
@@ -1,21 +1,45 @@
|
|
|
1
|
-
import { jsx
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { THEMEPROVIDER_CLASSNAME
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
import { useEffect, useRef } from "react";
|
|
4
|
+
import { THEMEPROVIDER_CLASSNAME } from "../../common/constants.js";
|
|
5
|
+
|
|
6
|
+
;// CONCATENATED MODULE: external "react/jsx-runtime"
|
|
7
|
+
|
|
8
|
+
;// CONCATENATED MODULE: external "clsx"
|
|
9
|
+
|
|
10
|
+
;// CONCATENATED MODULE: external "react"
|
|
11
|
+
|
|
12
|
+
;// CONCATENATED MODULE: external "../../common/constants.js"
|
|
13
|
+
|
|
14
|
+
;// CONCATENATED MODULE: ./src/components/ThemeProvider/ThemeProvider.tsx
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
const ThemeProvider = ({ customTheme, children, global, className })=>{
|
|
20
|
+
const wrapperRef = useRef(null);
|
|
21
|
+
const wrapperClass = clsx(THEMEPROVIDER_CLASSNAME, "contents", className);
|
|
22
|
+
useEffect(()=>{
|
|
23
|
+
const wrapper = global ? document.documentElement.style : wrapperRef?.current?.style;
|
|
24
|
+
if (!wrapper || !customTheme) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
for (const [key, value] of Object.entries(customTheme)){
|
|
28
|
+
wrapper.setProperty(key, value);
|
|
29
|
+
}
|
|
30
|
+
}, [
|
|
31
|
+
customTheme,
|
|
32
|
+
global
|
|
33
|
+
]);
|
|
34
|
+
// If global is true and no customTheme, just return children without wrapper
|
|
35
|
+
if (global && !customTheme) {
|
|
36
|
+
return children;
|
|
37
|
+
}
|
|
38
|
+
return /*#__PURE__*/ jsx("div", {
|
|
39
|
+
ref: wrapperRef,
|
|
40
|
+
className: wrapperClass,
|
|
41
|
+
children: children
|
|
42
|
+
});
|
|
21
43
|
};
|
|
44
|
+
|
|
45
|
+
export { ThemeProvider };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Flexgrid } from "./Flexgrid/Flexgrid.js";
|
|
2
|
+
import { FlexgridItem } from "./Flexgrid/FlexgridItem.js";
|
|
3
|
+
import { ThemeProvider } from "./ThemeProvider/ThemeProvider.js";
|
|
4
|
+
|
|
5
|
+
;// CONCATENATED MODULE: external "./Flexgrid/Flexgrid.js"
|
|
6
|
+
|
|
7
|
+
;// CONCATENATED MODULE: external "./Flexgrid/FlexgridItem.js"
|
|
8
|
+
|
|
9
|
+
;// CONCATENATED MODULE: external "./ThemeProvider/ThemeProvider.js"
|
|
10
|
+
|
|
11
|
+
;// CONCATENATED MODULE: ./src/components/index.ts
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
export { Flexgrid, FlexgridItem, ThemeProvider };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@versini/ui-system",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Arno Versini",
|
|
6
6
|
"publishConfig": {
|
|
@@ -12,8 +12,20 @@
|
|
|
12
12
|
"url": "git@github.com:aversini/ui-components.git"
|
|
13
13
|
},
|
|
14
14
|
"type": "module",
|
|
15
|
-
"
|
|
16
|
-
|
|
15
|
+
"exports": {
|
|
16
|
+
"./flexgrid": {
|
|
17
|
+
"types": "./dist/components/Flexgrid/Flexgrid.d.ts",
|
|
18
|
+
"import": "./dist/components/Flexgrid/Flexgrid.js"
|
|
19
|
+
},
|
|
20
|
+
"./flexgrid-item": {
|
|
21
|
+
"types": "./dist/components/Flexgrid/FlexgridItem.d.ts",
|
|
22
|
+
"import": "./dist/components/Flexgrid/FlexgridItem.js"
|
|
23
|
+
},
|
|
24
|
+
"./theme-provider": {
|
|
25
|
+
"types": "./dist/components/ThemeProvider/ThemeProvider.d.ts",
|
|
26
|
+
"import": "./dist/components/ThemeProvider/ThemeProvider.js"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
17
29
|
"bin": {
|
|
18
30
|
"flexgrid-to-tw": "dist/cli/flexgrid-to-tw.js"
|
|
19
31
|
},
|
|
@@ -24,13 +36,13 @@
|
|
|
24
36
|
"scripts": {
|
|
25
37
|
"build:check": "tsc",
|
|
26
38
|
"build:cli": "vite build --config vite.cli.config.ts",
|
|
27
|
-
"build:js": "
|
|
28
|
-
"build:types": "
|
|
29
|
-
"build": "npm-run-all --serial clean build:check build:js build:cli
|
|
30
|
-
"clean": "rimraf dist tmp",
|
|
31
|
-
"dev:js": "
|
|
32
|
-
"dev:types": "
|
|
33
|
-
"dev": "
|
|
39
|
+
"build:js": "rslib build",
|
|
40
|
+
"build:types": "echo 'Types now built with rslib'",
|
|
41
|
+
"build": "npm-run-all --serial clean build:check build:js build:cli",
|
|
42
|
+
"clean": "rimraf dist tmp coverage",
|
|
43
|
+
"dev:js": "rslib build --watch",
|
|
44
|
+
"dev:types": "echo 'Types now watched with rslib'",
|
|
45
|
+
"dev": "rslib build --watch",
|
|
34
46
|
"lint": "biome lint src",
|
|
35
47
|
"lint:fix": "biome check src --write --no-errors-on-unmatched",
|
|
36
48
|
"prettier": "biome check --write --no-errors-on-unmatched",
|
|
@@ -42,7 +54,7 @@
|
|
|
42
54
|
},
|
|
43
55
|
"devDependencies": {
|
|
44
56
|
"@testing-library/jest-dom": "6.9.1",
|
|
45
|
-
"@versini/ui-types": "8.1.
|
|
57
|
+
"@versini/ui-types": "8.1.1"
|
|
46
58
|
},
|
|
47
59
|
"dependencies": {
|
|
48
60
|
"clsx": "2.1.1",
|
|
@@ -51,5 +63,5 @@
|
|
|
51
63
|
"sideEffects": [
|
|
52
64
|
"**/*.css"
|
|
53
65
|
],
|
|
54
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "6c08c752fd230a10f88c1bf315be99d714d55b08"
|
|
55
67
|
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import * as react from 'react';
|
|
3
|
-
|
|
4
|
-
type FlexgridProps = {
|
|
5
|
-
/**
|
|
6
|
-
* Children of the Flexgrid (FlexgridItem(s) or any other nodes).
|
|
7
|
-
*/
|
|
8
|
-
children: React.ReactNode;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Equivalent to "justify-content" in flexbox, this prop defines
|
|
12
|
-
* the alignment along the main axis (horizontal).
|
|
13
|
-
*/
|
|
14
|
-
alignHorizontal?:
|
|
15
|
-
| "normal"
|
|
16
|
-
| "flex-start"
|
|
17
|
-
| "center"
|
|
18
|
-
| "flex-end"
|
|
19
|
-
| "space-between"
|
|
20
|
-
| "space-around"
|
|
21
|
-
| "space-evenly";
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Equivalent to "align-items" in flexbox, this prop defines
|
|
25
|
-
* the alignment along the cross axis (vertical).
|
|
26
|
-
*/
|
|
27
|
-
alignVertical?:
|
|
28
|
-
| "normal"
|
|
29
|
-
| "flex-start"
|
|
30
|
-
| "center"
|
|
31
|
-
| "flex-end"
|
|
32
|
-
| "stretch"
|
|
33
|
-
| "baseline";
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* The class name of the Flexgrid.
|
|
37
|
-
* It follows the [CSS class name property](https://developer.mozilla.org/en-US/docs/Web/CSS/class).
|
|
38
|
-
*/
|
|
39
|
-
className?: string;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Width of the gutters between the columns.
|
|
43
|
-
* See the “Customization -> Spacing” section for
|
|
44
|
-
* more information about this unit.
|
|
45
|
-
*/
|
|
46
|
-
columnGap?: number;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Equivalent to "flex-direction" in flexbox, this prop
|
|
50
|
-
* establishes the main-axis, thus defining the direction
|
|
51
|
-
* flex items are placed in the flex container. Flexbox is
|
|
52
|
-
* (aside from optional wrapping) a single-direction layout
|
|
53
|
-
* concept. Think of flex items as primarily laying out
|
|
54
|
-
* either in horizontal rows or vertical columns.
|
|
55
|
-
*/
|
|
56
|
-
direction?: "row" | "row-reverse" | "column" | "column-reverse";
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* The height of the Flexgrid.
|
|
60
|
-
* It follows the [CSS height property](https://developer.mozilla.org/en-US/docs/Web/CSS/height).
|
|
61
|
-
*/
|
|
62
|
-
height?: string;
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Width of the gutters between the rows.
|
|
66
|
-
* See the “Customization -> Spacing” section for
|
|
67
|
-
* more information about this unit.
|
|
68
|
-
*/
|
|
69
|
-
rowGap?: number;
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* The width of the Flexgrid.
|
|
73
|
-
* It follows the [CSS width property](https://developer.mozilla.org/en-US/docs/Web/CSS/width).
|
|
74
|
-
*/
|
|
75
|
-
width?: string;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
type FlexgridItemProps = {
|
|
79
|
-
/** Children of the FlexgridItem. */
|
|
80
|
-
children?: React.ReactNode;
|
|
81
|
-
|
|
82
|
-
/** Classname to apply to the FlexgridItem. */
|
|
83
|
-
className?: string;
|
|
84
|
-
|
|
85
|
-
/** The item will span across the provided number of grid tracks. */
|
|
86
|
-
span?:
|
|
87
|
-
| number
|
|
88
|
-
| "auto"
|
|
89
|
-
| {
|
|
90
|
-
fallback?: number;
|
|
91
|
-
lg?: number;
|
|
92
|
-
md?: number;
|
|
93
|
-
sm?: number;
|
|
94
|
-
xl?: number;
|
|
95
|
-
};
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
declare const Flexgrid: ({ children, className, columnGap, rowGap, height, width, direction, alignHorizontal, alignVertical, ...otherProps }: FlexgridProps) => react_jsx_runtime.JSX.Element;
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* FlexgridItem is a child of Flexgrid. It is used to define the width of a
|
|
102
|
-
* column in a Flexgrid. It can be used to span across multiple columns in a
|
|
103
|
-
* Flexgrid by providing a number of columns or "auto" value to the `span` prop.
|
|
104
|
-
*/
|
|
105
|
-
declare const FlexgridItem: ({ children, className, span, ...otherProps }: FlexgridItemProps) => react_jsx_runtime.JSX.Element;
|
|
106
|
-
|
|
107
|
-
type ThemeProviderProps = {
|
|
108
|
-
/**
|
|
109
|
-
* The children to render.
|
|
110
|
-
*/
|
|
111
|
-
children: React.ReactNode;
|
|
112
|
-
/**
|
|
113
|
-
* CSS class(es) to add to the main component wrapper.
|
|
114
|
-
*/
|
|
115
|
-
className?: string;
|
|
116
|
-
/**
|
|
117
|
-
* An object specifying custom properties impacting the base theme.
|
|
118
|
-
* Not all custom properties need to be specified.
|
|
119
|
-
* @example
|
|
120
|
-
* ```tsx
|
|
121
|
-
* // this will change the color of the button to red.
|
|
122
|
-
* <ThemeProvider customTheme={{ '--av-action-dark': 'red' }}>
|
|
123
|
-
* <Button kind="dark">Click me</Button>
|
|
124
|
-
* </ThemeProvider>
|
|
125
|
-
* ```
|
|
126
|
-
*/
|
|
127
|
-
customTheme?: Record<string, string>;
|
|
128
|
-
/**
|
|
129
|
-
* Whether to apply the theme globally or not.
|
|
130
|
-
* @default false
|
|
131
|
-
*/
|
|
132
|
-
global?: boolean;
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
declare const ThemeProvider: ({ customTheme, children, global, className, }: ThemeProviderProps) => string | number | bigint | boolean | Iterable<react.ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<react.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
136
|
-
|
|
137
|
-
export { Flexgrid, FlexgridItem, ThemeProvider };
|
package/dist/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Flexgrid as o } from "./components/Flexgrid/Flexgrid.js";
|
|
2
|
-
import { FlexgridItem as m } from "./components/Flexgrid/FlexgridItem.js";
|
|
3
|
-
import { ThemeProvider as I } from "./components/ThemeProvider/ThemeProvider.js";
|
|
4
|
-
try {
|
|
5
|
-
window.__VERSINI_UI_SYSTEM__ || (window.__VERSINI_UI_SYSTEM__ = {
|
|
6
|
-
version: "5.1.0",
|
|
7
|
-
buildTime: "12/25/2025 10:40 AM EST",
|
|
8
|
-
homepage: "https://www.npmjs.com/package/@versini/ui-system",
|
|
9
|
-
license: "MIT"
|
|
10
|
-
});
|
|
11
|
-
} catch {
|
|
12
|
-
}
|
|
13
|
-
export {
|
|
14
|
-
o as Flexgrid,
|
|
15
|
-
m as FlexgridItem,
|
|
16
|
-
I as ThemeProvider
|
|
17
|
-
};
|