@grupor5/raya 0.2.6 → 0.2.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/dist/index.d.mts +109 -2
- package/dist/index.d.ts +109 -2
- package/dist/index.js +356 -0
- package/dist/index.mjs +354 -1
- package/dist/molecules/grid/index.d.mts +194 -0
- package/dist/molecules/grid/index.d.ts +194 -0
- package/dist/molecules/grid/index.js +263 -0
- package/dist/molecules/grid/index.mjs +256 -0
- package/dist/tailwind.css +1 -1
- package/dist/tokens/grids.d.mts +3 -3
- package/dist/tokens/grids.d.ts +3 -3
- package/dist/tokens/grids.js +3 -3
- package/dist/tokens/grids.mjs +3 -3
- package/package.json +1 -1
- package/tailwind.config.js +7 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Responsive value type for breakpoint-specific configuration
|
|
5
|
+
*
|
|
6
|
+
* Allows different values for each breakpoint following the Raya Design System:
|
|
7
|
+
* - **mobile**: 0px and up (4-column grid)
|
|
8
|
+
* - **tablet**: 768px and up (8-column grid)
|
|
9
|
+
* - **desktop**: 1024px and up (12-column grid)
|
|
10
|
+
*
|
|
11
|
+
* @template T The type of value for each breakpoint
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* // Responsive columns
|
|
15
|
+
* const columns: ResponsiveValue<number> = {
|
|
16
|
+
* mobile: 1, // 1 column on mobile
|
|
17
|
+
* tablet: 2, // 2 columns on tablet
|
|
18
|
+
* desktop: 4 // 4 columns on desktop
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* // Responsive gaps
|
|
22
|
+
* const gaps: ResponsiveValue<string> = {
|
|
23
|
+
* mobile: 's', // Small gap on mobile
|
|
24
|
+
* tablet: 'm', // Medium gap on tablet
|
|
25
|
+
* desktop: 'l' // Large gap on desktop
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
interface ResponsiveValue<T> {
|
|
30
|
+
/** Value for mobile breakpoint (0px and up) */
|
|
31
|
+
mobile?: T;
|
|
32
|
+
/** Value for tablet breakpoint (768px and up) */
|
|
33
|
+
tablet?: T;
|
|
34
|
+
/** Value for desktop breakpoint (1024px and up) */
|
|
35
|
+
desktop?: T;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Grid container props
|
|
39
|
+
*/
|
|
40
|
+
interface GridProps {
|
|
41
|
+
/**
|
|
42
|
+
* Whether this is a grid container (default: true)
|
|
43
|
+
* @default true
|
|
44
|
+
*/
|
|
45
|
+
container?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Number of columns per breakpoint. Supports single number or responsive values.
|
|
48
|
+
* Default: { mobile: 4, tablet: 8, desktop: 12 }
|
|
49
|
+
* @example { mobile: 1, tablet: 2, desktop: 3 }
|
|
50
|
+
*/
|
|
51
|
+
cols?: ResponsiveValue<1 | 2 | 3 | 4 | 6 | 8 | 12> | 1 | 2 | 3 | 4 | 6 | 8 | 12;
|
|
52
|
+
/**
|
|
53
|
+
* Gap size between grid items using design system tokens.
|
|
54
|
+
* xs=4px, s=8px, m=16px, l=24px, xl=32px
|
|
55
|
+
* @example { mobile: 'm', tablet: 'l', desktop: 'xl' }
|
|
56
|
+
*/
|
|
57
|
+
gap?: ResponsiveValue<'xs' | 's' | 'm' | 'l' | 'xl'> | 'xs' | 's' | 'm' | 'l' | 'xl';
|
|
58
|
+
/**
|
|
59
|
+
* Whether to apply responsive padding and auto-centering following design system
|
|
60
|
+
* Mobile: 16px, Tablet: 20px, Desktop: 24px
|
|
61
|
+
* @default false
|
|
62
|
+
*/
|
|
63
|
+
margin?: boolean;
|
|
64
|
+
/** Custom CSS classes to apply to the grid container */
|
|
65
|
+
className?: string;
|
|
66
|
+
/** Grid items or content to be rendered inside the grid */
|
|
67
|
+
children: React__default.ReactNode;
|
|
68
|
+
/** ARIA label for accessibility and screen readers */
|
|
69
|
+
'aria-label'?: string;
|
|
70
|
+
/** Data test id for testing purposes */
|
|
71
|
+
'data-testid'?: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Grid item props for responsive layout control
|
|
75
|
+
*/
|
|
76
|
+
interface GridItemProps {
|
|
77
|
+
/**
|
|
78
|
+
* Number of columns this item should span across breakpoints
|
|
79
|
+
* @example { mobile: 12, tablet: 6, desktop: 4 }
|
|
80
|
+
* @example 6 // Static span across all breakpoints
|
|
81
|
+
*/
|
|
82
|
+
span?: ResponsiveValue<number> | number;
|
|
83
|
+
/**
|
|
84
|
+
* Number of rows this item should span across breakpoints
|
|
85
|
+
* @example { mobile: 1, desktop: 2 }
|
|
86
|
+
* @example 2 // Static row span across all breakpoints
|
|
87
|
+
*/
|
|
88
|
+
rowSpan?: ResponsiveValue<number> | number;
|
|
89
|
+
/**
|
|
90
|
+
* Grid column start position (1-based indexing)
|
|
91
|
+
* @example { mobile: 1, desktop: 2 }
|
|
92
|
+
* @example 3 // Start at column 3
|
|
93
|
+
*/
|
|
94
|
+
colStart?: ResponsiveValue<number> | number;
|
|
95
|
+
/**
|
|
96
|
+
* Grid column end position (1-based indexing)
|
|
97
|
+
* @example { mobile: -1, desktop: 5 }
|
|
98
|
+
* @example 6 // End at column 6
|
|
99
|
+
*/
|
|
100
|
+
colEnd?: ResponsiveValue<number> | number;
|
|
101
|
+
/** Custom CSS classes to apply to the grid item */
|
|
102
|
+
className?: string;
|
|
103
|
+
/** Content to be rendered inside the grid item */
|
|
104
|
+
children: React__default.ReactNode;
|
|
105
|
+
/** Data test id for testing purposes */
|
|
106
|
+
'data-testid'?: string;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* # Grid - MANDATORY Responsive Grid System
|
|
110
|
+
*
|
|
111
|
+
* ## 🚨 CRITICAL: ALL LAYOUTS MUST USE THIS COMPONENT
|
|
112
|
+
*
|
|
113
|
+
* This is the **MANDATORY** grid component for all screens and layouts in the Raya Design System.
|
|
114
|
+
* Manual CSS Grid classes are **FORBIDDEN**. Use this component to ensure consistent spacing,
|
|
115
|
+
* responsive behavior, and design system compliance.
|
|
116
|
+
*
|
|
117
|
+
* ### Features
|
|
118
|
+
* - **Responsive by Default**: Automatically adapts to mobile (4 cols), tablet (8 cols), desktop (12 cols)
|
|
119
|
+
* - **Design System Integration**: Consistent margins, gaps, and breakpoints
|
|
120
|
+
* - **Type Safety**: Full TypeScript support with responsive value types
|
|
121
|
+
* - **Accessibility**: ARIA labels and semantic HTML structure
|
|
122
|
+
*
|
|
123
|
+
* ### Breakpoints & Container Sizes
|
|
124
|
+
* - **Mobile**: 0px-767px (4 columns, max-width: 412px, 16px padding/gaps)
|
|
125
|
+
* - **Tablet**: 768px-1023px (8 columns, max-width: 834px, 20px padding/gaps)
|
|
126
|
+
* - **Desktop**: 1024px+ (12 columns, max-width: 1440px, 24px padding/gaps)
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```tsx
|
|
130
|
+
* // ✅ CORRECT - Always use Grid component
|
|
131
|
+
* <Grid cols={{ mobile: 1, tablet: 2, desktop: 3 }} gap="l" margin>
|
|
132
|
+
* <Card>Content 1</Card>
|
|
133
|
+
* <Card>Content 2</Card>
|
|
134
|
+
* <Card>Content 3</Card>
|
|
135
|
+
* </Grid>
|
|
136
|
+
*
|
|
137
|
+
* // ✅ CORRECT - Advanced responsive configuration
|
|
138
|
+
* <Grid cols={12} gap="m" margin>
|
|
139
|
+
* <GridItem span={{ mobile: 12, desktop: 8 }}>
|
|
140
|
+
* <MainContent />
|
|
141
|
+
* </GridItem>
|
|
142
|
+
* <GridItem span={{ mobile: 12, desktop: 4 }}>
|
|
143
|
+
* <Sidebar />
|
|
144
|
+
* </GridItem>
|
|
145
|
+
* </Grid>
|
|
146
|
+
* ```
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```tsx
|
|
150
|
+
* // ❌ FORBIDDEN - Never use manual CSS Grid
|
|
151
|
+
* <div className="grid grid-cols-3 gap-6">
|
|
152
|
+
* <Card>Content</Card>
|
|
153
|
+
* </div>
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
declare const Grid: React__default.ForwardRefExoticComponent<GridProps & React__default.RefAttributes<HTMLDivElement>>;
|
|
157
|
+
/**
|
|
158
|
+
* # GridItem - Responsive Grid Item with Advanced Control
|
|
159
|
+
*
|
|
160
|
+
* Provides fine-grained control over individual grid items including
|
|
161
|
+
* column spans, row spans, and positioning. Use within a Grid component
|
|
162
|
+
* for precise layout control across breakpoints.
|
|
163
|
+
*
|
|
164
|
+
* ### Features
|
|
165
|
+
* - **Responsive Spans**: Different column/row spans per breakpoint
|
|
166
|
+
* - **Positioning**: Control exact grid placement with colStart/colEnd
|
|
167
|
+
* - **Flexible Layout**: Combine with Grid for complex layouts
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```tsx
|
|
171
|
+
* <Grid cols={12} gap="m">
|
|
172
|
+
* <GridItem span={6}>Half width</GridItem>
|
|
173
|
+
* <GridItem span={{ mobile: 12, desktop: 4 }}>Responsive width</GridItem>
|
|
174
|
+
* <GridItem span={3} rowSpan={2}>Tall item spanning 2 rows</GridItem>
|
|
175
|
+
* <GridItem colStart={2} colEnd={5}>Positioned item (cols 2-5)</GridItem>
|
|
176
|
+
* </Grid>
|
|
177
|
+
* ```
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* ```tsx
|
|
181
|
+
* // Content + Sidebar layout
|
|
182
|
+
* <Grid cols={12} margin>
|
|
183
|
+
* <GridItem span={{ mobile: 12, desktop: 8 }}>
|
|
184
|
+
* <MainContent />
|
|
185
|
+
* </GridItem>
|
|
186
|
+
* <GridItem span={{ mobile: 12, desktop: 4 }}>
|
|
187
|
+
* <Sidebar />
|
|
188
|
+
* </GridItem>
|
|
189
|
+
* </Grid>
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
declare const GridItem: React__default.ForwardRefExoticComponent<GridItemProps & React__default.RefAttributes<HTMLDivElement>>;
|
|
193
|
+
|
|
194
|
+
export { Grid, GridItem, type GridItemProps, type GridProps, type ResponsiveValue };
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var clsx = require('clsx');
|
|
5
|
+
var tailwindMerge = require('tailwind-merge');
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
|
|
8
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
|
|
10
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
11
|
+
|
|
12
|
+
var __defProp = Object.defineProperty;
|
|
13
|
+
var __defProps = Object.defineProperties;
|
|
14
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
15
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
16
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
17
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
18
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
19
|
+
var __spreadValues = (a, b) => {
|
|
20
|
+
for (var prop in b || (b = {}))
|
|
21
|
+
if (__hasOwnProp.call(b, prop))
|
|
22
|
+
__defNormalProp(a, prop, b[prop]);
|
|
23
|
+
if (__getOwnPropSymbols)
|
|
24
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
25
|
+
if (__propIsEnum.call(b, prop))
|
|
26
|
+
__defNormalProp(a, prop, b[prop]);
|
|
27
|
+
}
|
|
28
|
+
return a;
|
|
29
|
+
};
|
|
30
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
31
|
+
var __objRest = (source, exclude) => {
|
|
32
|
+
var target = {};
|
|
33
|
+
for (var prop in source)
|
|
34
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
35
|
+
target[prop] = source[prop];
|
|
36
|
+
if (source != null && __getOwnPropSymbols)
|
|
37
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
38
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
39
|
+
target[prop] = source[prop];
|
|
40
|
+
}
|
|
41
|
+
return target;
|
|
42
|
+
};
|
|
43
|
+
function cn(...inputs) {
|
|
44
|
+
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
45
|
+
}
|
|
46
|
+
var getColsClasses = (cols) => {
|
|
47
|
+
if (typeof cols === "number") {
|
|
48
|
+
return `grid-cols-${cols}`;
|
|
49
|
+
}
|
|
50
|
+
if (typeof cols === "object" && cols !== null) {
|
|
51
|
+
const classes = [];
|
|
52
|
+
if (cols.mobile) {
|
|
53
|
+
classes.push(`grid-cols-${cols.mobile}`);
|
|
54
|
+
}
|
|
55
|
+
if (cols.tablet) {
|
|
56
|
+
classes.push(`md:grid-cols-${cols.tablet}`);
|
|
57
|
+
}
|
|
58
|
+
if (cols.desktop) {
|
|
59
|
+
classes.push(`lg:grid-cols-${cols.desktop}`);
|
|
60
|
+
}
|
|
61
|
+
return classes.join(" ");
|
|
62
|
+
}
|
|
63
|
+
return "grid-cols-4 md:grid-cols-8 lg:grid-cols-12";
|
|
64
|
+
};
|
|
65
|
+
var getGapClasses = (gap) => {
|
|
66
|
+
if (typeof gap === "string") {
|
|
67
|
+
const gapMap = {
|
|
68
|
+
xs: "gap-1",
|
|
69
|
+
// 4px
|
|
70
|
+
s: "gap-2",
|
|
71
|
+
// 8px
|
|
72
|
+
m: "gap-4",
|
|
73
|
+
// 16px
|
|
74
|
+
l: "gap-6",
|
|
75
|
+
// 24px
|
|
76
|
+
xl: "gap-8"
|
|
77
|
+
// 32px
|
|
78
|
+
};
|
|
79
|
+
return gapMap[gap] || "gap-4";
|
|
80
|
+
}
|
|
81
|
+
if (typeof gap === "object" && gap !== null) {
|
|
82
|
+
const gapMap = {
|
|
83
|
+
xs: "1",
|
|
84
|
+
s: "2",
|
|
85
|
+
m: "4",
|
|
86
|
+
l: "6",
|
|
87
|
+
xl: "8"
|
|
88
|
+
};
|
|
89
|
+
const classes = [];
|
|
90
|
+
if (gap.mobile) {
|
|
91
|
+
classes.push(`gap-${gapMap[gap.mobile] || "4"}`);
|
|
92
|
+
}
|
|
93
|
+
if (gap.tablet) {
|
|
94
|
+
classes.push(`md:gap-${gapMap[gap.tablet] || "5"}`);
|
|
95
|
+
}
|
|
96
|
+
if (gap.desktop) {
|
|
97
|
+
classes.push(`lg:gap-${gapMap[gap.desktop] || "6"}`);
|
|
98
|
+
}
|
|
99
|
+
return classes.join(" ");
|
|
100
|
+
}
|
|
101
|
+
return "gap-4 md:gap-5 lg:gap-6";
|
|
102
|
+
};
|
|
103
|
+
var getSpanClasses = (span) => {
|
|
104
|
+
if (typeof span === "number") {
|
|
105
|
+
return `col-span-${span}`;
|
|
106
|
+
}
|
|
107
|
+
if (typeof span === "object" && span !== null) {
|
|
108
|
+
const classes = [];
|
|
109
|
+
if (span.mobile) {
|
|
110
|
+
classes.push(`col-span-${span.mobile}`);
|
|
111
|
+
}
|
|
112
|
+
if (span.tablet) {
|
|
113
|
+
classes.push(`md:col-span-${span.tablet}`);
|
|
114
|
+
}
|
|
115
|
+
if (span.desktop) {
|
|
116
|
+
classes.push(`lg:col-span-${span.desktop}`);
|
|
117
|
+
}
|
|
118
|
+
return classes.join(" ");
|
|
119
|
+
}
|
|
120
|
+
return "";
|
|
121
|
+
};
|
|
122
|
+
var getRowSpanClasses = (rowSpan) => {
|
|
123
|
+
if (typeof rowSpan === "number") {
|
|
124
|
+
return `row-span-${rowSpan}`;
|
|
125
|
+
}
|
|
126
|
+
if (typeof rowSpan === "object" && rowSpan !== null) {
|
|
127
|
+
const classes = [];
|
|
128
|
+
if (rowSpan.mobile) {
|
|
129
|
+
classes.push(`row-span-${rowSpan.mobile}`);
|
|
130
|
+
}
|
|
131
|
+
if (rowSpan.tablet) {
|
|
132
|
+
classes.push(`md:row-span-${rowSpan.tablet}`);
|
|
133
|
+
}
|
|
134
|
+
if (rowSpan.desktop) {
|
|
135
|
+
classes.push(`lg:row-span-${rowSpan.desktop}`);
|
|
136
|
+
}
|
|
137
|
+
return classes.join(" ");
|
|
138
|
+
}
|
|
139
|
+
return "";
|
|
140
|
+
};
|
|
141
|
+
var getColPositionClasses = (colStart, colEnd) => {
|
|
142
|
+
const classes = [];
|
|
143
|
+
if (colStart) {
|
|
144
|
+
if (typeof colStart === "number") {
|
|
145
|
+
classes.push(`col-start-${colStart}`);
|
|
146
|
+
} else if (typeof colStart === "object") {
|
|
147
|
+
if (colStart.mobile) classes.push(`col-start-${colStart.mobile}`);
|
|
148
|
+
if (colStart.tablet) classes.push(`md:col-start-${colStart.tablet}`);
|
|
149
|
+
if (colStart.desktop) classes.push(`lg:col-start-${colStart.desktop}`);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (colEnd) {
|
|
153
|
+
if (typeof colEnd === "number") {
|
|
154
|
+
classes.push(`col-end-${colEnd}`);
|
|
155
|
+
} else if (typeof colEnd === "object") {
|
|
156
|
+
if (colEnd.mobile) classes.push(`col-end-${colEnd.mobile}`);
|
|
157
|
+
if (colEnd.tablet) classes.push(`md:col-end-${colEnd.tablet}`);
|
|
158
|
+
if (colEnd.desktop) classes.push(`lg:col-end-${colEnd.desktop}`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return classes.join(" ");
|
|
162
|
+
};
|
|
163
|
+
var Grid = React__default.default.forwardRef(
|
|
164
|
+
(_a, ref) => {
|
|
165
|
+
var _b = _a, {
|
|
166
|
+
container = true,
|
|
167
|
+
cols,
|
|
168
|
+
gap,
|
|
169
|
+
margin = false,
|
|
170
|
+
className,
|
|
171
|
+
children,
|
|
172
|
+
"aria-label": ariaLabel,
|
|
173
|
+
"data-testid": dataTestId
|
|
174
|
+
} = _b, props = __objRest(_b, [
|
|
175
|
+
"container",
|
|
176
|
+
"cols",
|
|
177
|
+
"gap",
|
|
178
|
+
"margin",
|
|
179
|
+
"className",
|
|
180
|
+
"children",
|
|
181
|
+
"aria-label",
|
|
182
|
+
"data-testid"
|
|
183
|
+
]);
|
|
184
|
+
const gridClasses = cn(
|
|
185
|
+
// Base grid styles
|
|
186
|
+
container && "grid",
|
|
187
|
+
// Maximum width containers following design system
|
|
188
|
+
"max-w-grid-mobile",
|
|
189
|
+
// Mobile: 412px max-width
|
|
190
|
+
"md:max-w-grid-tablet",
|
|
191
|
+
// Tablet: 834px max-width
|
|
192
|
+
"lg:max-w-grid-desktop",
|
|
193
|
+
// Desktop: 1440px max-width
|
|
194
|
+
// Center containers when margin is enabled
|
|
195
|
+
margin && "mx-auto",
|
|
196
|
+
// Column configuration
|
|
197
|
+
getColsClasses(cols),
|
|
198
|
+
// Gap configuration
|
|
199
|
+
getGapClasses(gap),
|
|
200
|
+
// Padding configuration (follows design system)
|
|
201
|
+
margin && "px-4 md:px-5 lg:px-6",
|
|
202
|
+
// Custom classes
|
|
203
|
+
className
|
|
204
|
+
);
|
|
205
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
206
|
+
"div",
|
|
207
|
+
__spreadProps(__spreadValues({
|
|
208
|
+
ref,
|
|
209
|
+
className: gridClasses,
|
|
210
|
+
"aria-label": ariaLabel,
|
|
211
|
+
"data-testid": dataTestId
|
|
212
|
+
}, props), {
|
|
213
|
+
children
|
|
214
|
+
})
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
);
|
|
218
|
+
Grid.displayName = "Grid";
|
|
219
|
+
var GridItem = React__default.default.forwardRef(
|
|
220
|
+
(_a, ref) => {
|
|
221
|
+
var _b = _a, {
|
|
222
|
+
span,
|
|
223
|
+
rowSpan,
|
|
224
|
+
colStart,
|
|
225
|
+
colEnd,
|
|
226
|
+
className,
|
|
227
|
+
children,
|
|
228
|
+
"data-testid": dataTestId
|
|
229
|
+
} = _b, props = __objRest(_b, [
|
|
230
|
+
"span",
|
|
231
|
+
"rowSpan",
|
|
232
|
+
"colStart",
|
|
233
|
+
"colEnd",
|
|
234
|
+
"className",
|
|
235
|
+
"children",
|
|
236
|
+
"data-testid"
|
|
237
|
+
]);
|
|
238
|
+
const itemClasses = cn(
|
|
239
|
+
// Span configuration
|
|
240
|
+
getSpanClasses(span),
|
|
241
|
+
// Row span configuration
|
|
242
|
+
getRowSpanClasses(rowSpan),
|
|
243
|
+
// Position configuration
|
|
244
|
+
getColPositionClasses(colStart, colEnd),
|
|
245
|
+
// Custom classes
|
|
246
|
+
className
|
|
247
|
+
);
|
|
248
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
249
|
+
"div",
|
|
250
|
+
__spreadProps(__spreadValues({
|
|
251
|
+
ref,
|
|
252
|
+
className: itemClasses,
|
|
253
|
+
"data-testid": dataTestId
|
|
254
|
+
}, props), {
|
|
255
|
+
children
|
|
256
|
+
})
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
);
|
|
260
|
+
GridItem.displayName = "GridItem";
|
|
261
|
+
|
|
262
|
+
exports.Grid = Grid;
|
|
263
|
+
exports.GridItem = GridItem;
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { clsx } from 'clsx';
|
|
3
|
+
import { twMerge } from 'tailwind-merge';
|
|
4
|
+
import { jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
var __defProp = Object.defineProperty;
|
|
7
|
+
var __defProps = Object.defineProperties;
|
|
8
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
9
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
10
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
+
var __spreadValues = (a, b) => {
|
|
14
|
+
for (var prop in b || (b = {}))
|
|
15
|
+
if (__hasOwnProp.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
if (__getOwnPropSymbols)
|
|
18
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
+
if (__propIsEnum.call(b, prop))
|
|
20
|
+
__defNormalProp(a, prop, b[prop]);
|
|
21
|
+
}
|
|
22
|
+
return a;
|
|
23
|
+
};
|
|
24
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
|
+
var __objRest = (source, exclude) => {
|
|
26
|
+
var target = {};
|
|
27
|
+
for (var prop in source)
|
|
28
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
if (source != null && __getOwnPropSymbols)
|
|
31
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
32
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
33
|
+
target[prop] = source[prop];
|
|
34
|
+
}
|
|
35
|
+
return target;
|
|
36
|
+
};
|
|
37
|
+
function cn(...inputs) {
|
|
38
|
+
return twMerge(clsx(inputs));
|
|
39
|
+
}
|
|
40
|
+
var getColsClasses = (cols) => {
|
|
41
|
+
if (typeof cols === "number") {
|
|
42
|
+
return `grid-cols-${cols}`;
|
|
43
|
+
}
|
|
44
|
+
if (typeof cols === "object" && cols !== null) {
|
|
45
|
+
const classes = [];
|
|
46
|
+
if (cols.mobile) {
|
|
47
|
+
classes.push(`grid-cols-${cols.mobile}`);
|
|
48
|
+
}
|
|
49
|
+
if (cols.tablet) {
|
|
50
|
+
classes.push(`md:grid-cols-${cols.tablet}`);
|
|
51
|
+
}
|
|
52
|
+
if (cols.desktop) {
|
|
53
|
+
classes.push(`lg:grid-cols-${cols.desktop}`);
|
|
54
|
+
}
|
|
55
|
+
return classes.join(" ");
|
|
56
|
+
}
|
|
57
|
+
return "grid-cols-4 md:grid-cols-8 lg:grid-cols-12";
|
|
58
|
+
};
|
|
59
|
+
var getGapClasses = (gap) => {
|
|
60
|
+
if (typeof gap === "string") {
|
|
61
|
+
const gapMap = {
|
|
62
|
+
xs: "gap-1",
|
|
63
|
+
// 4px
|
|
64
|
+
s: "gap-2",
|
|
65
|
+
// 8px
|
|
66
|
+
m: "gap-4",
|
|
67
|
+
// 16px
|
|
68
|
+
l: "gap-6",
|
|
69
|
+
// 24px
|
|
70
|
+
xl: "gap-8"
|
|
71
|
+
// 32px
|
|
72
|
+
};
|
|
73
|
+
return gapMap[gap] || "gap-4";
|
|
74
|
+
}
|
|
75
|
+
if (typeof gap === "object" && gap !== null) {
|
|
76
|
+
const gapMap = {
|
|
77
|
+
xs: "1",
|
|
78
|
+
s: "2",
|
|
79
|
+
m: "4",
|
|
80
|
+
l: "6",
|
|
81
|
+
xl: "8"
|
|
82
|
+
};
|
|
83
|
+
const classes = [];
|
|
84
|
+
if (gap.mobile) {
|
|
85
|
+
classes.push(`gap-${gapMap[gap.mobile] || "4"}`);
|
|
86
|
+
}
|
|
87
|
+
if (gap.tablet) {
|
|
88
|
+
classes.push(`md:gap-${gapMap[gap.tablet] || "5"}`);
|
|
89
|
+
}
|
|
90
|
+
if (gap.desktop) {
|
|
91
|
+
classes.push(`lg:gap-${gapMap[gap.desktop] || "6"}`);
|
|
92
|
+
}
|
|
93
|
+
return classes.join(" ");
|
|
94
|
+
}
|
|
95
|
+
return "gap-4 md:gap-5 lg:gap-6";
|
|
96
|
+
};
|
|
97
|
+
var getSpanClasses = (span) => {
|
|
98
|
+
if (typeof span === "number") {
|
|
99
|
+
return `col-span-${span}`;
|
|
100
|
+
}
|
|
101
|
+
if (typeof span === "object" && span !== null) {
|
|
102
|
+
const classes = [];
|
|
103
|
+
if (span.mobile) {
|
|
104
|
+
classes.push(`col-span-${span.mobile}`);
|
|
105
|
+
}
|
|
106
|
+
if (span.tablet) {
|
|
107
|
+
classes.push(`md:col-span-${span.tablet}`);
|
|
108
|
+
}
|
|
109
|
+
if (span.desktop) {
|
|
110
|
+
classes.push(`lg:col-span-${span.desktop}`);
|
|
111
|
+
}
|
|
112
|
+
return classes.join(" ");
|
|
113
|
+
}
|
|
114
|
+
return "";
|
|
115
|
+
};
|
|
116
|
+
var getRowSpanClasses = (rowSpan) => {
|
|
117
|
+
if (typeof rowSpan === "number") {
|
|
118
|
+
return `row-span-${rowSpan}`;
|
|
119
|
+
}
|
|
120
|
+
if (typeof rowSpan === "object" && rowSpan !== null) {
|
|
121
|
+
const classes = [];
|
|
122
|
+
if (rowSpan.mobile) {
|
|
123
|
+
classes.push(`row-span-${rowSpan.mobile}`);
|
|
124
|
+
}
|
|
125
|
+
if (rowSpan.tablet) {
|
|
126
|
+
classes.push(`md:row-span-${rowSpan.tablet}`);
|
|
127
|
+
}
|
|
128
|
+
if (rowSpan.desktop) {
|
|
129
|
+
classes.push(`lg:row-span-${rowSpan.desktop}`);
|
|
130
|
+
}
|
|
131
|
+
return classes.join(" ");
|
|
132
|
+
}
|
|
133
|
+
return "";
|
|
134
|
+
};
|
|
135
|
+
var getColPositionClasses = (colStart, colEnd) => {
|
|
136
|
+
const classes = [];
|
|
137
|
+
if (colStart) {
|
|
138
|
+
if (typeof colStart === "number") {
|
|
139
|
+
classes.push(`col-start-${colStart}`);
|
|
140
|
+
} else if (typeof colStart === "object") {
|
|
141
|
+
if (colStart.mobile) classes.push(`col-start-${colStart.mobile}`);
|
|
142
|
+
if (colStart.tablet) classes.push(`md:col-start-${colStart.tablet}`);
|
|
143
|
+
if (colStart.desktop) classes.push(`lg:col-start-${colStart.desktop}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (colEnd) {
|
|
147
|
+
if (typeof colEnd === "number") {
|
|
148
|
+
classes.push(`col-end-${colEnd}`);
|
|
149
|
+
} else if (typeof colEnd === "object") {
|
|
150
|
+
if (colEnd.mobile) classes.push(`col-end-${colEnd.mobile}`);
|
|
151
|
+
if (colEnd.tablet) classes.push(`md:col-end-${colEnd.tablet}`);
|
|
152
|
+
if (colEnd.desktop) classes.push(`lg:col-end-${colEnd.desktop}`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return classes.join(" ");
|
|
156
|
+
};
|
|
157
|
+
var Grid = React.forwardRef(
|
|
158
|
+
(_a, ref) => {
|
|
159
|
+
var _b = _a, {
|
|
160
|
+
container = true,
|
|
161
|
+
cols,
|
|
162
|
+
gap,
|
|
163
|
+
margin = false,
|
|
164
|
+
className,
|
|
165
|
+
children,
|
|
166
|
+
"aria-label": ariaLabel,
|
|
167
|
+
"data-testid": dataTestId
|
|
168
|
+
} = _b, props = __objRest(_b, [
|
|
169
|
+
"container",
|
|
170
|
+
"cols",
|
|
171
|
+
"gap",
|
|
172
|
+
"margin",
|
|
173
|
+
"className",
|
|
174
|
+
"children",
|
|
175
|
+
"aria-label",
|
|
176
|
+
"data-testid"
|
|
177
|
+
]);
|
|
178
|
+
const gridClasses = cn(
|
|
179
|
+
// Base grid styles
|
|
180
|
+
container && "grid",
|
|
181
|
+
// Maximum width containers following design system
|
|
182
|
+
"max-w-grid-mobile",
|
|
183
|
+
// Mobile: 412px max-width
|
|
184
|
+
"md:max-w-grid-tablet",
|
|
185
|
+
// Tablet: 834px max-width
|
|
186
|
+
"lg:max-w-grid-desktop",
|
|
187
|
+
// Desktop: 1440px max-width
|
|
188
|
+
// Center containers when margin is enabled
|
|
189
|
+
margin && "mx-auto",
|
|
190
|
+
// Column configuration
|
|
191
|
+
getColsClasses(cols),
|
|
192
|
+
// Gap configuration
|
|
193
|
+
getGapClasses(gap),
|
|
194
|
+
// Padding configuration (follows design system)
|
|
195
|
+
margin && "px-4 md:px-5 lg:px-6",
|
|
196
|
+
// Custom classes
|
|
197
|
+
className
|
|
198
|
+
);
|
|
199
|
+
return /* @__PURE__ */ jsx(
|
|
200
|
+
"div",
|
|
201
|
+
__spreadProps(__spreadValues({
|
|
202
|
+
ref,
|
|
203
|
+
className: gridClasses,
|
|
204
|
+
"aria-label": ariaLabel,
|
|
205
|
+
"data-testid": dataTestId
|
|
206
|
+
}, props), {
|
|
207
|
+
children
|
|
208
|
+
})
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
);
|
|
212
|
+
Grid.displayName = "Grid";
|
|
213
|
+
var GridItem = React.forwardRef(
|
|
214
|
+
(_a, ref) => {
|
|
215
|
+
var _b = _a, {
|
|
216
|
+
span,
|
|
217
|
+
rowSpan,
|
|
218
|
+
colStart,
|
|
219
|
+
colEnd,
|
|
220
|
+
className,
|
|
221
|
+
children,
|
|
222
|
+
"data-testid": dataTestId
|
|
223
|
+
} = _b, props = __objRest(_b, [
|
|
224
|
+
"span",
|
|
225
|
+
"rowSpan",
|
|
226
|
+
"colStart",
|
|
227
|
+
"colEnd",
|
|
228
|
+
"className",
|
|
229
|
+
"children",
|
|
230
|
+
"data-testid"
|
|
231
|
+
]);
|
|
232
|
+
const itemClasses = cn(
|
|
233
|
+
// Span configuration
|
|
234
|
+
getSpanClasses(span),
|
|
235
|
+
// Row span configuration
|
|
236
|
+
getRowSpanClasses(rowSpan),
|
|
237
|
+
// Position configuration
|
|
238
|
+
getColPositionClasses(colStart, colEnd),
|
|
239
|
+
// Custom classes
|
|
240
|
+
className
|
|
241
|
+
);
|
|
242
|
+
return /* @__PURE__ */ jsx(
|
|
243
|
+
"div",
|
|
244
|
+
__spreadProps(__spreadValues({
|
|
245
|
+
ref,
|
|
246
|
+
className: itemClasses,
|
|
247
|
+
"data-testid": dataTestId
|
|
248
|
+
}, props), {
|
|
249
|
+
children
|
|
250
|
+
})
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
);
|
|
254
|
+
GridItem.displayName = "GridItem";
|
|
255
|
+
|
|
256
|
+
export { Grid, GridItem };
|