@pittorica/stack-react 0.8.2
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/.turbo/turbo-build.log +18 -0
- package/LICENSE +21 -0
- package/dist/Stack.d.ts +17 -0
- package/dist/Stack.d.ts.map +1 -0
- package/dist/index.cjs +19985 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19957 -0
- package/dist/index.js.map +1 -0
- package/dist/stack.css.d.ts +80 -0
- package/dist/stack.css.d.ts.map +1 -0
- package/package.json +44 -0
- package/src/Stack.tsx +77 -0
- package/src/index.ts +2 -0
- package/src/stack.css.ts +73 -0
- package/tsconfig.app.json +33 -0
- package/tsconfig.json +7 -0
- package/tsconfig.node.json +26 -0
- package/vite.config.ts +35 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
export declare const stackStyle: import('@vanilla-extract/recipes').RuntimeFn<{
|
|
2
|
+
direction: {
|
|
3
|
+
horizontal: {
|
|
4
|
+
flexDirection: "row";
|
|
5
|
+
};
|
|
6
|
+
'horizontal-reversed': {
|
|
7
|
+
flexDirection: "row-reverse";
|
|
8
|
+
};
|
|
9
|
+
vertical: {
|
|
10
|
+
flexDirection: "column";
|
|
11
|
+
};
|
|
12
|
+
'vertical-reversed': {
|
|
13
|
+
flexDirection: "column-reverse";
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
align: {
|
|
17
|
+
start: {
|
|
18
|
+
alignItems: "flex-start";
|
|
19
|
+
};
|
|
20
|
+
center: {
|
|
21
|
+
alignItems: "center";
|
|
22
|
+
};
|
|
23
|
+
end: {
|
|
24
|
+
alignItems: "flex-end";
|
|
25
|
+
};
|
|
26
|
+
stretch: {
|
|
27
|
+
alignItems: "stretch";
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
justify: {
|
|
31
|
+
start: {
|
|
32
|
+
justifyContent: "flex-start";
|
|
33
|
+
};
|
|
34
|
+
center: {
|
|
35
|
+
justifyContent: "center";
|
|
36
|
+
};
|
|
37
|
+
end: {
|
|
38
|
+
justifyContent: "flex-end";
|
|
39
|
+
};
|
|
40
|
+
spaceBetween: {
|
|
41
|
+
justifyContent: "space-between";
|
|
42
|
+
};
|
|
43
|
+
spaceAround: {
|
|
44
|
+
justifyContent: "space-around";
|
|
45
|
+
};
|
|
46
|
+
spaceEvenly: {
|
|
47
|
+
justifyContent: "space-evenly";
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
gap: {
|
|
51
|
+
none: {
|
|
52
|
+
gap: number;
|
|
53
|
+
};
|
|
54
|
+
xsmall: {
|
|
55
|
+
gap: "0.25rem";
|
|
56
|
+
};
|
|
57
|
+
small: {
|
|
58
|
+
gap: "0.5rem";
|
|
59
|
+
};
|
|
60
|
+
medium: {
|
|
61
|
+
gap: "1rem";
|
|
62
|
+
};
|
|
63
|
+
large: {
|
|
64
|
+
gap: "1.5rem";
|
|
65
|
+
};
|
|
66
|
+
xlarge: {
|
|
67
|
+
gap: "2rem";
|
|
68
|
+
};
|
|
69
|
+
xxlarge: {
|
|
70
|
+
gap: "3rem";
|
|
71
|
+
};
|
|
72
|
+
xxxlarge: {
|
|
73
|
+
gap: "4rem";
|
|
74
|
+
};
|
|
75
|
+
xxxxlarge: {
|
|
76
|
+
gap: "6rem";
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
}>;
|
|
80
|
+
//# sourceMappingURL=stack.css.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stack.css.d.ts","sourceRoot":"","sources":["../src/stack.css.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsErB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pittorica/stack-react",
|
|
3
|
+
"version": "0.8.2",
|
|
4
|
+
"private": false,
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Davide Di Criscito"
|
|
7
|
+
},
|
|
8
|
+
"type": "module",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"main": "./dist/index.js",
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@vanilla-extract/recipes": "^0.5.7",
|
|
19
|
+
"clsx": "^2.1.1",
|
|
20
|
+
"react": "^19.2.3",
|
|
21
|
+
"react-dom": "^19.2.3",
|
|
22
|
+
"@pittorica/box-react": "0.8.2",
|
|
23
|
+
"@pittorica/styles": "0.8.2"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/node": "^25.0.10",
|
|
27
|
+
"@types/react": "^19.2.9",
|
|
28
|
+
"@types/react-dom": "^19.2.3",
|
|
29
|
+
"@vitejs/plugin-react": "^5.1.2",
|
|
30
|
+
"babel-plugin-react-compiler": "^1.0.0",
|
|
31
|
+
"typescript": "~5.9.3",
|
|
32
|
+
"vite": "npm:rolldown-vite@7.3.1",
|
|
33
|
+
"vite-plugin-dts": "^4.5.4"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsc -b && vite build",
|
|
40
|
+
"dev": "vite",
|
|
41
|
+
"lint": "eslint .",
|
|
42
|
+
"preview": "vite preview"
|
|
43
|
+
}
|
|
44
|
+
}
|
package/src/Stack.tsx
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
|
|
5
|
+
import { Box, type BoxProps } from '@pittorica/box-react';
|
|
6
|
+
import { SPACING_TOKENS, type SpacingToken } from '@pittorica/styles';
|
|
7
|
+
|
|
8
|
+
import { stackStyle } from './stack.css.js';
|
|
9
|
+
|
|
10
|
+
export const STACK_DIRECTIONS = [
|
|
11
|
+
'horizontal',
|
|
12
|
+
'horizontal-reversed',
|
|
13
|
+
'vertical',
|
|
14
|
+
'vertical-reversed',
|
|
15
|
+
] as const;
|
|
16
|
+
|
|
17
|
+
export type StackDirection = (typeof STACK_DIRECTIONS)[number];
|
|
18
|
+
|
|
19
|
+
export const STACK_ALIGNS = ['start', 'center', 'end', 'stretch'] as const;
|
|
20
|
+
|
|
21
|
+
export type StackAlign = (typeof STACK_ALIGNS)[number];
|
|
22
|
+
|
|
23
|
+
export const STACK_JUSTIFIES = [
|
|
24
|
+
'start',
|
|
25
|
+
'center',
|
|
26
|
+
'end',
|
|
27
|
+
'spaceBetween',
|
|
28
|
+
'spaceAround',
|
|
29
|
+
'spaceEvenly',
|
|
30
|
+
] as const;
|
|
31
|
+
|
|
32
|
+
export type StackJustify = (typeof STACK_JUSTIFIES)[number];
|
|
33
|
+
|
|
34
|
+
export interface StackProps extends Omit<
|
|
35
|
+
BoxProps,
|
|
36
|
+
'as' | 'display' | 'flexDirection' | 'alignItems' | 'justifyContent' | 'gap'
|
|
37
|
+
> {
|
|
38
|
+
direction?: StackDirection;
|
|
39
|
+
align?: StackAlign;
|
|
40
|
+
justify?: StackJustify;
|
|
41
|
+
gap?: SpacingToken | string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const Stack: React.FC<StackProps> = ({
|
|
45
|
+
direction = 'horizontal',
|
|
46
|
+
align = 'center',
|
|
47
|
+
justify = 'center',
|
|
48
|
+
gap,
|
|
49
|
+
className,
|
|
50
|
+
...props
|
|
51
|
+
}) => {
|
|
52
|
+
const isGapToken = gap && SPACING_TOKENS.includes(gap as SpacingToken);
|
|
53
|
+
const stackClass = isGapToken
|
|
54
|
+
? stackStyle({
|
|
55
|
+
direction,
|
|
56
|
+
align,
|
|
57
|
+
justify,
|
|
58
|
+
gap: gap as SpacingToken,
|
|
59
|
+
})
|
|
60
|
+
: stackStyle({
|
|
61
|
+
direction,
|
|
62
|
+
align,
|
|
63
|
+
justify,
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<Box
|
|
68
|
+
as="div"
|
|
69
|
+
className={clsx(stackClass, className)}
|
|
70
|
+
style={{
|
|
71
|
+
...(!SPACING_TOKENS.includes(gap as SpacingToken) && { gap: gap }),
|
|
72
|
+
...props.style,
|
|
73
|
+
}}
|
|
74
|
+
{...props}
|
|
75
|
+
/>
|
|
76
|
+
);
|
|
77
|
+
};
|
package/src/index.ts
ADDED
package/src/stack.css.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { recipe } from '@vanilla-extract/recipes';
|
|
2
|
+
|
|
3
|
+
export const stackStyle = recipe({
|
|
4
|
+
base: {
|
|
5
|
+
display: 'flex',
|
|
6
|
+
},
|
|
7
|
+
variants: {
|
|
8
|
+
direction: {
|
|
9
|
+
horizontal: {
|
|
10
|
+
flexDirection: 'row',
|
|
11
|
+
},
|
|
12
|
+
'horizontal-reversed': {
|
|
13
|
+
flexDirection: 'row-reverse',
|
|
14
|
+
},
|
|
15
|
+
vertical: {
|
|
16
|
+
flexDirection: 'column',
|
|
17
|
+
},
|
|
18
|
+
'vertical-reversed': {
|
|
19
|
+
flexDirection: 'column-reverse',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
align: {
|
|
23
|
+
start: {
|
|
24
|
+
alignItems: 'flex-start',
|
|
25
|
+
},
|
|
26
|
+
center: {
|
|
27
|
+
alignItems: 'center',
|
|
28
|
+
},
|
|
29
|
+
end: {
|
|
30
|
+
alignItems: 'flex-end',
|
|
31
|
+
},
|
|
32
|
+
stretch: {
|
|
33
|
+
alignItems: 'stretch',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
justify: {
|
|
37
|
+
start: {
|
|
38
|
+
justifyContent: 'flex-start',
|
|
39
|
+
},
|
|
40
|
+
center: {
|
|
41
|
+
justifyContent: 'center',
|
|
42
|
+
},
|
|
43
|
+
end: {
|
|
44
|
+
justifyContent: 'flex-end',
|
|
45
|
+
},
|
|
46
|
+
spaceBetween: {
|
|
47
|
+
justifyContent: 'space-between',
|
|
48
|
+
},
|
|
49
|
+
spaceAround: {
|
|
50
|
+
justifyContent: 'space-around',
|
|
51
|
+
},
|
|
52
|
+
spaceEvenly: {
|
|
53
|
+
justifyContent: 'space-evenly',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
gap: {
|
|
57
|
+
none: { gap: 0 },
|
|
58
|
+
xsmall: { gap: '0.25rem' },
|
|
59
|
+
small: { gap: '0.5rem' },
|
|
60
|
+
medium: { gap: '1rem' },
|
|
61
|
+
large: { gap: '1.5rem' },
|
|
62
|
+
xlarge: { gap: '2rem' },
|
|
63
|
+
xxlarge: { gap: '3rem' },
|
|
64
|
+
xxxlarge: { gap: '4rem' },
|
|
65
|
+
xxxxlarge: { gap: '6rem' },
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
defaultVariants: {
|
|
69
|
+
direction: 'horizontal',
|
|
70
|
+
align: 'center',
|
|
71
|
+
justify: 'center',
|
|
72
|
+
},
|
|
73
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"outDir": "dist",
|
|
4
|
+
"rootDir": "src",
|
|
5
|
+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
|
6
|
+
"target": "ES2022",
|
|
7
|
+
"useDefineForClassFields": true,
|
|
8
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
9
|
+
"module": "ESNext",
|
|
10
|
+
"types": ["vite/client"],
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
|
|
13
|
+
/* Bundler mode */
|
|
14
|
+
"moduleResolution": "bundler",
|
|
15
|
+
"allowImportingTsExtensions": false,
|
|
16
|
+
"verbatimModuleSyntax": true,
|
|
17
|
+
"moduleDetection": "force",
|
|
18
|
+
"noEmit": false,
|
|
19
|
+
"emitDeclarationOnly": true,
|
|
20
|
+
"declaration": true,
|
|
21
|
+
"declarationMap": true,
|
|
22
|
+
"jsx": "react-jsx",
|
|
23
|
+
|
|
24
|
+
/* Linting */
|
|
25
|
+
"strict": true,
|
|
26
|
+
"noUnusedLocals": true,
|
|
27
|
+
"noUnusedParameters": true,
|
|
28
|
+
"erasableSyntaxOnly": true,
|
|
29
|
+
"noFallthroughCasesInSwitch": true,
|
|
30
|
+
"noUncheckedSideEffectImports": true
|
|
31
|
+
},
|
|
32
|
+
"include": ["src"]
|
|
33
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
|
4
|
+
"target": "ES2023",
|
|
5
|
+
"lib": ["ES2023"],
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"types": ["node"],
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
|
|
10
|
+
/* Bundler mode */
|
|
11
|
+
"moduleResolution": "bundler",
|
|
12
|
+
"allowImportingTsExtensions": false,
|
|
13
|
+
"verbatimModuleSyntax": true,
|
|
14
|
+
"moduleDetection": "force",
|
|
15
|
+
"noEmit": true,
|
|
16
|
+
|
|
17
|
+
/* Linting */
|
|
18
|
+
"strict": true,
|
|
19
|
+
"noUnusedLocals": true,
|
|
20
|
+
"noUnusedParameters": true,
|
|
21
|
+
"erasableSyntaxOnly": true,
|
|
22
|
+
"noFallthroughCasesInSwitch": true,
|
|
23
|
+
"noUncheckedSideEffectImports": true
|
|
24
|
+
},
|
|
25
|
+
"include": ["vite.config.ts"]
|
|
26
|
+
}
|
package/vite.config.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
|
|
3
|
+
import { defineConfig } from 'vite';
|
|
4
|
+
import dts from 'vite-plugin-dts';
|
|
5
|
+
import react from '@vitejs/plugin-react';
|
|
6
|
+
|
|
7
|
+
// https://vite.dev/config/
|
|
8
|
+
export default defineConfig({
|
|
9
|
+
plugins: [
|
|
10
|
+
react({
|
|
11
|
+
babel: {
|
|
12
|
+
plugins: [['babel-plugin-react-compiler']],
|
|
13
|
+
},
|
|
14
|
+
}),
|
|
15
|
+
dts({
|
|
16
|
+
insertTypesEntry: true,
|
|
17
|
+
include: ['src'],
|
|
18
|
+
rollupTypes: false,
|
|
19
|
+
outDir: 'dist',
|
|
20
|
+
tsconfigPath: './tsconfig.app.json',
|
|
21
|
+
}),
|
|
22
|
+
],
|
|
23
|
+
|
|
24
|
+
build: {
|
|
25
|
+
lib: {
|
|
26
|
+
entry: path.resolve(import.meta.dirname, 'src/index.ts'),
|
|
27
|
+
name: '@pittorica/stack-react',
|
|
28
|
+
formats: ['es', 'cjs'],
|
|
29
|
+
fileName: (format: string): string =>
|
|
30
|
+
`index.${format === 'es' ? 'js' : 'cjs'}`,
|
|
31
|
+
},
|
|
32
|
+
sourcemap: true,
|
|
33
|
+
minify: false,
|
|
34
|
+
},
|
|
35
|
+
});
|