@spark-web/stack 2.0.0-rc.0 → 2.0.0-rc.1
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/CHANGELOG.md +14 -0
- package/dist/declarations/src/alignment.d.ts +14 -0
- package/dist/declarations/src/index.d.ts +2 -0
- package/dist/declarations/src/stack.d.ts +21 -0
- package/dist/spark-web-stack.cjs.d.ts +2 -2
- package/dist/spark-web-stack.cjs.dev.js +58 -0
- package/dist/spark-web-stack.cjs.js +6 -15
- package/dist/spark-web-stack.cjs.prod.js +58 -0
- package/dist/spark-web-stack.esm.js +54 -0
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @spark-web/stack
|
|
2
2
|
|
|
3
|
+
## 2.0.0-rc.1
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- rc
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies []:
|
|
12
|
+
- @spark-web/divider@2.0.0-rc.1
|
|
13
|
+
- @spark-web/theme@4.0.0-rc.1
|
|
14
|
+
- @spark-web/utils@2.0.0-rc.1
|
|
15
|
+
- @spark-web/box@2.0.0-rc.1
|
|
16
|
+
|
|
3
17
|
## 2.0.0-rc.0
|
|
4
18
|
|
|
5
19
|
### Major Changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare const alignLookup: {
|
|
2
|
+
readonly left: "start";
|
|
3
|
+
readonly center: "center";
|
|
4
|
+
readonly right: "end";
|
|
5
|
+
readonly stretch: "stretch";
|
|
6
|
+
};
|
|
7
|
+
export declare type Align = keyof typeof alignLookup;
|
|
8
|
+
export declare const alignToAlignItems: (prop?: import("@spark-web/theme").ResponsiveProp<"left" | "right" | "center" | "stretch"> | undefined) => "center" | "start" | "end" | "stretch" | {
|
|
9
|
+
mobile: "center" | "start" | "end" | "stretch" | undefined;
|
|
10
|
+
tablet: "center" | "start" | "end" | "stretch" | undefined;
|
|
11
|
+
desktop: "center" | "start" | "end" | "stretch" | undefined;
|
|
12
|
+
wide: "center" | "start" | "end" | "stretch" | undefined;
|
|
13
|
+
} | undefined;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { BoxProps } from '@spark-web/box';
|
|
2
|
+
import type { ResponsiveProp } from '@spark-web/theme';
|
|
3
|
+
import type { ReactElement } from 'react';
|
|
4
|
+
import type { Align } from "./alignment.js";
|
|
5
|
+
declare type ValidBoxProps = Omit<BoxProps, 'display' | 'className' | 'alignItems' | 'flexDirection' | 'justifyContent' | 'flexWrap'>;
|
|
6
|
+
export declare type StackProps = {
|
|
7
|
+
/** Horizontally align items within the stack. */
|
|
8
|
+
align?: ResponsiveProp<Align>;
|
|
9
|
+
/** Place a divider between each element. */
|
|
10
|
+
dividers?: boolean;
|
|
11
|
+
} & ValidBoxProps;
|
|
12
|
+
export declare const Stack: <Comp extends import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> = "div">(props: {
|
|
13
|
+
as?: Comp | undefined;
|
|
14
|
+
ref?: import("react").Ref<Comp extends "symbol" | "clipPath" | "filter" | "mask" | "marker" | "svg" | "animate" | "animateMotion" | "animateTransform" | "circle" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feDropShadow" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "metadata" | "mpath" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "set" | "stop" | "switch" | "text" | "textPath" | "tspan" | "use" | "view" | keyof HTMLElementTagNameMap ? (HTMLElementTagNameMap & Pick<SVGElementTagNameMap, "symbol" | "clipPath" | "filter" | "mask" | "marker" | "svg" | "animate" | "animateMotion" | "animateTransform" | "circle" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feDropShadow" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "metadata" | "mpath" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "set" | "stop" | "switch" | "text" | "textPath" | "tspan" | "use" | "view">)[Comp] : Comp extends new (...args: any) => any ? InstanceType<Comp> : undefined> | undefined;
|
|
15
|
+
} & Omit<import("react").PropsWithoutRef<import("react").ComponentProps<Comp>>, "as"> & {
|
|
16
|
+
/** Horizontally align items within the stack. */
|
|
17
|
+
align?: ResponsiveProp<"left" | "right" | "center" | "stretch"> | undefined;
|
|
18
|
+
/** Place a divider between each element. */
|
|
19
|
+
dividers?: boolean | undefined;
|
|
20
|
+
} & ValidBoxProps) => ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
21
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "
|
|
2
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
1
|
+
export * from "./declarations/src/index";
|
|
2
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3Bhcmstd2ViLXN0YWNrLmNqcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi9kZWNsYXJhdGlvbnMvc3JjL2luZGV4LmQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEifQ==
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
6
|
+
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
7
|
+
var box = require('@spark-web/box');
|
|
8
|
+
var divider = require('@spark-web/divider');
|
|
9
|
+
var ts = require('@spark-web/utils/ts');
|
|
10
|
+
var react = require('react');
|
|
11
|
+
var theme = require('@spark-web/theme');
|
|
12
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
13
|
+
|
|
14
|
+
var alignLookup = {
|
|
15
|
+
left: 'start',
|
|
16
|
+
center: 'center',
|
|
17
|
+
right: 'end',
|
|
18
|
+
stretch: 'stretch'
|
|
19
|
+
};
|
|
20
|
+
var alignToAlignItems = theme.createResponsiveMapFn(alignLookup);
|
|
21
|
+
|
|
22
|
+
var _excluded = ["align", "children", "data", "dividers"];
|
|
23
|
+
var Stack = ts.forwardRefWithAs(function (_ref, forwardedRef) {
|
|
24
|
+
var _ref$align = _ref.align,
|
|
25
|
+
align = _ref$align === void 0 ? 'stretch' : _ref$align,
|
|
26
|
+
children = _ref.children,
|
|
27
|
+
data = _ref.data,
|
|
28
|
+
dividers = _ref.dividers,
|
|
29
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
30
|
+
var alignItems = alignToAlignItems(align);
|
|
31
|
+
var rootProps = _objectSpread({
|
|
32
|
+
ref: forwardedRef,
|
|
33
|
+
alignItems: alignItems,
|
|
34
|
+
data: data,
|
|
35
|
+
display: 'flex',
|
|
36
|
+
flexDirection: 'column'
|
|
37
|
+
}, props);
|
|
38
|
+
|
|
39
|
+
// bail early w/o dividers to avoid unnecessary map
|
|
40
|
+
if (!dividers) {
|
|
41
|
+
return /*#__PURE__*/jsxRuntime.jsx(box.Box, _objectSpread(_objectSpread({}, rootProps), {}, {
|
|
42
|
+
children: children
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// map over children to insert dividers
|
|
47
|
+
// remove falsy values before mapping, keeps the index in sync
|
|
48
|
+
var childArray = react.Children.toArray(children);
|
|
49
|
+
return /*#__PURE__*/jsxRuntime.jsx(box.Box, _objectSpread(_objectSpread({}, rootProps), {}, {
|
|
50
|
+
children: childArray.map(function (child, idx) {
|
|
51
|
+
return /*#__PURE__*/jsxRuntime.jsxs(react.Fragment, {
|
|
52
|
+
children: [dividers && idx ? /*#__PURE__*/jsxRuntime.jsx(divider.Divider, {}) : null, child]
|
|
53
|
+
}, child.key || idx);
|
|
54
|
+
})
|
|
55
|
+
}));
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
exports.Stack = Stack;
|
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
// this file might look strange and you might be wondering what it's for
|
|
3
|
-
// it's lets you import your source files by importing this entrypoint
|
|
4
|
-
// as you would import it if it was built with preconstruct build
|
|
5
|
-
// this file is slightly different to some others though
|
|
6
|
-
// it has a require hook which compiles your code with Babel
|
|
7
|
-
// this means that you don't have to set up @babel/register or anything like that
|
|
8
|
-
// but you can still require this module and it'll be compiled
|
|
1
|
+
'use strict';
|
|
9
2
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
unregister();
|
|
3
|
+
if (process.env.NODE_ENV === "production") {
|
|
4
|
+
module.exports = require("./spark-web-stack.cjs.prod.js");
|
|
5
|
+
} else {
|
|
6
|
+
module.exports = require("./spark-web-stack.cjs.dev.js");
|
|
7
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
6
|
+
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
7
|
+
var box = require('@spark-web/box');
|
|
8
|
+
var divider = require('@spark-web/divider');
|
|
9
|
+
var ts = require('@spark-web/utils/ts');
|
|
10
|
+
var react = require('react');
|
|
11
|
+
var theme = require('@spark-web/theme');
|
|
12
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
13
|
+
|
|
14
|
+
var alignLookup = {
|
|
15
|
+
left: 'start',
|
|
16
|
+
center: 'center',
|
|
17
|
+
right: 'end',
|
|
18
|
+
stretch: 'stretch'
|
|
19
|
+
};
|
|
20
|
+
var alignToAlignItems = theme.createResponsiveMapFn(alignLookup);
|
|
21
|
+
|
|
22
|
+
var _excluded = ["align", "children", "data", "dividers"];
|
|
23
|
+
var Stack = ts.forwardRefWithAs(function (_ref, forwardedRef) {
|
|
24
|
+
var _ref$align = _ref.align,
|
|
25
|
+
align = _ref$align === void 0 ? 'stretch' : _ref$align,
|
|
26
|
+
children = _ref.children,
|
|
27
|
+
data = _ref.data,
|
|
28
|
+
dividers = _ref.dividers,
|
|
29
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
30
|
+
var alignItems = alignToAlignItems(align);
|
|
31
|
+
var rootProps = _objectSpread({
|
|
32
|
+
ref: forwardedRef,
|
|
33
|
+
alignItems: alignItems,
|
|
34
|
+
data: data,
|
|
35
|
+
display: 'flex',
|
|
36
|
+
flexDirection: 'column'
|
|
37
|
+
}, props);
|
|
38
|
+
|
|
39
|
+
// bail early w/o dividers to avoid unnecessary map
|
|
40
|
+
if (!dividers) {
|
|
41
|
+
return /*#__PURE__*/jsxRuntime.jsx(box.Box, _objectSpread(_objectSpread({}, rootProps), {}, {
|
|
42
|
+
children: children
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// map over children to insert dividers
|
|
47
|
+
// remove falsy values before mapping, keeps the index in sync
|
|
48
|
+
var childArray = react.Children.toArray(children);
|
|
49
|
+
return /*#__PURE__*/jsxRuntime.jsx(box.Box, _objectSpread(_objectSpread({}, rootProps), {}, {
|
|
50
|
+
children: childArray.map(function (child, idx) {
|
|
51
|
+
return /*#__PURE__*/jsxRuntime.jsxs(react.Fragment, {
|
|
52
|
+
children: [dividers && idx ? /*#__PURE__*/jsxRuntime.jsx(divider.Divider, {}) : null, child]
|
|
53
|
+
}, child.key || idx);
|
|
54
|
+
})
|
|
55
|
+
}));
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
exports.Stack = Stack;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import _objectSpread from '@babel/runtime/helpers/esm/objectSpread2';
|
|
2
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
3
|
+
import { Box } from '@spark-web/box';
|
|
4
|
+
import { Divider } from '@spark-web/divider';
|
|
5
|
+
import { forwardRefWithAs } from '@spark-web/utils/ts';
|
|
6
|
+
import { Children, Fragment } from 'react';
|
|
7
|
+
import { createResponsiveMapFn } from '@spark-web/theme';
|
|
8
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
9
|
+
|
|
10
|
+
var alignLookup = {
|
|
11
|
+
left: 'start',
|
|
12
|
+
center: 'center',
|
|
13
|
+
right: 'end',
|
|
14
|
+
stretch: 'stretch'
|
|
15
|
+
};
|
|
16
|
+
var alignToAlignItems = createResponsiveMapFn(alignLookup);
|
|
17
|
+
|
|
18
|
+
var _excluded = ["align", "children", "data", "dividers"];
|
|
19
|
+
var Stack = forwardRefWithAs(function (_ref, forwardedRef) {
|
|
20
|
+
var _ref$align = _ref.align,
|
|
21
|
+
align = _ref$align === void 0 ? 'stretch' : _ref$align,
|
|
22
|
+
children = _ref.children,
|
|
23
|
+
data = _ref.data,
|
|
24
|
+
dividers = _ref.dividers,
|
|
25
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
26
|
+
var alignItems = alignToAlignItems(align);
|
|
27
|
+
var rootProps = _objectSpread({
|
|
28
|
+
ref: forwardedRef,
|
|
29
|
+
alignItems: alignItems,
|
|
30
|
+
data: data,
|
|
31
|
+
display: 'flex',
|
|
32
|
+
flexDirection: 'column'
|
|
33
|
+
}, props);
|
|
34
|
+
|
|
35
|
+
// bail early w/o dividers to avoid unnecessary map
|
|
36
|
+
if (!dividers) {
|
|
37
|
+
return /*#__PURE__*/jsx(Box, _objectSpread(_objectSpread({}, rootProps), {}, {
|
|
38
|
+
children: children
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// map over children to insert dividers
|
|
43
|
+
// remove falsy values before mapping, keeps the index in sync
|
|
44
|
+
var childArray = Children.toArray(children);
|
|
45
|
+
return /*#__PURE__*/jsx(Box, _objectSpread(_objectSpread({}, rootProps), {}, {
|
|
46
|
+
children: childArray.map(function (child, idx) {
|
|
47
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
48
|
+
children: [dividers && idx ? /*#__PURE__*/jsx(Divider, {}) : null, child]
|
|
49
|
+
}, child.key || idx);
|
|
50
|
+
})
|
|
51
|
+
}));
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
export { Stack };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spark-web/stack",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.1",
|
|
4
4
|
"homepage": "https://github.com/brighte-labs/spark-web#readme",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@babel/runtime": "^7.25.0",
|
|
19
19
|
"@emotion/react": "^11.13.5",
|
|
20
|
-
"@spark-web/box": "^2.0.0-rc.
|
|
21
|
-
"@spark-web/divider": "^2.0.0-rc.
|
|
22
|
-
"@spark-web/theme": "^4.0.0-rc.
|
|
23
|
-
"@spark-web/utils": "^2.0.0-rc.
|
|
20
|
+
"@spark-web/box": "^2.0.0-rc.1",
|
|
21
|
+
"@spark-web/divider": "^2.0.0-rc.1",
|
|
22
|
+
"@spark-web/theme": "^4.0.0-rc.1",
|
|
23
|
+
"@spark-web/utils": "^2.0.0-rc.1"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/react": "^18.2.0",
|