@spark-web/box 1.1.0 → 1.2.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/CHANGELOG.md +16 -0
- package/dist/declarations/src/box.d.ts +3 -3
- package/dist/spark-web-box.cjs.dev.js +119 -118
- package/dist/spark-web-box.cjs.prod.js +119 -118
- package/dist/spark-web-box.esm.js +119 -118
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @spark-web/box
|
|
2
2
|
|
|
3
|
+
## 1.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#382](https://github.com/brighte-labs/spark-web/pull/382)
|
|
8
|
+
[`955bf5d`](https://github.com/brighte-labs/spark-web/commit/955bf5d7698bfdf45e7f317aa3e726c81d3444c0)
|
|
9
|
+
Thanks [@dilipt-brighte](https://github.com/dilipt-brighte)! - Updates React
|
|
10
|
+
version to latest (18.2.0)
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
[[`955bf5d`](https://github.com/brighte-labs/spark-web/commit/955bf5d7698bfdf45e7f317aa3e726c81d3444c0)]:
|
|
16
|
+
- @spark-web/theme@3.2.0
|
|
17
|
+
- @spark-web/utils@1.3.0
|
|
18
|
+
|
|
3
19
|
## 1.1.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
|
@@ -20,7 +20,7 @@ export declare type BoxProps = {
|
|
|
20
20
|
/** Exposes a prop-based API for adding styles to a view, within the constraints of the theme. */
|
|
21
21
|
export declare const Box: <Comp extends import("react").ElementType<any> = "div">(props: {
|
|
22
22
|
as?: Comp | undefined;
|
|
23
|
-
ref?: import("react").Ref<Comp extends "symbol" | "svg" | "animate" | "animateMotion" | "animateTransform" | "circle" | "
|
|
23
|
+
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" | "stop" | "switch" | "text" | "textPath" | "tspan" | "use" | "view" | keyof HTMLElementTagNameMap | "set" ? (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" | "stop" | "switch" | "text" | "textPath" | "tspan" | "use" | "view" | "set">)[Comp] : Comp extends new (...args: any) => any ? InstanceType<Comp> : undefined> | undefined;
|
|
24
24
|
} & Omit<import("react").PropsWithoutRef<import("react").ComponentProps<Comp>>, "as"> & {
|
|
25
25
|
/** Children element to be rendered inside the component. */
|
|
26
26
|
children?: ReactNode;
|
|
@@ -37,11 +37,11 @@ export declare const Box: <Comp extends import("react").ElementType<any> = "div"
|
|
|
37
37
|
*/
|
|
38
38
|
asElement?: keyof HTMLElementTagNameMap | undefined;
|
|
39
39
|
} & {
|
|
40
|
-
background?: "body" | "input" | "infoLight" | "criticalLight" | "positiveLight" | "cautionLight" | "muted" | "
|
|
40
|
+
background?: "body" | "input" | "disabled" | "infoLight" | "criticalLight" | "positiveLight" | "cautionLight" | "muted" | "backdrop" | "surface" | "surfaceMuted" | "surfacePressed" | "fieldAccent" | "inputPressed" | "inputDisabled" | "accent" | "accentMuted" | "neutral" | "neutralLow" | "primary" | "primaryLow" | "primaryMuted" | "secondary" | "secondaryLow" | "secondaryMuted" | "caution" | "cautionLow" | "cautionMuted" | "critical" | "criticalLow" | "criticalMuted" | "info" | "infoLow" | "infoMuted" | "positive" | "positiveLow" | "positiveMuted" | undefined;
|
|
41
41
|
cursor?: "default" | "pointer" | undefined;
|
|
42
42
|
minHeight?: 0 | undefined;
|
|
43
43
|
minWidth?: 0 | undefined;
|
|
44
|
-
overflow?: "
|
|
44
|
+
overflow?: "auto" | "hidden" | "scroll" | "visible" | undefined;
|
|
45
45
|
shadow?: "small" | "large" | "medium" | undefined;
|
|
46
46
|
userSelect?: "none" | undefined;
|
|
47
47
|
} & import("./use-box-styles").ResponsiveBoxProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
@@ -12,97 +12,104 @@ var internal = require('@spark-web/utils/internal');
|
|
|
12
12
|
var ts = require('@spark-web/utils/ts');
|
|
13
13
|
|
|
14
14
|
// prepare context
|
|
15
|
+
|
|
15
16
|
var backgroundContext = /*#__PURE__*/react.createContext('body');
|
|
16
17
|
var InternalBackgroundProvider = backgroundContext.Provider;
|
|
17
18
|
var useBackground = function useBackground() {
|
|
18
19
|
return react.useContext(backgroundContext);
|
|
19
|
-
};
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// conditional provider
|
|
20
23
|
|
|
21
24
|
function renderBackgroundProvider(background, element) {
|
|
22
25
|
return background ? /*#__PURE__*/jsxRuntime.jsx(InternalBackgroundProvider, {
|
|
23
26
|
value: background,
|
|
24
27
|
children: element
|
|
25
28
|
}) : element;
|
|
26
|
-
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// a11y contrast utility
|
|
27
32
|
|
|
28
33
|
var useBackgroundLightness = function useBackgroundLightness(backgroundOverride) {
|
|
29
34
|
var backgroundFromContext = useBackground();
|
|
30
35
|
var background = backgroundOverride || backgroundFromContext;
|
|
31
36
|
var theme$1 = theme.useTheme();
|
|
32
|
-
var defaultLightness = theme$1.backgroundLightness.body;
|
|
37
|
+
var defaultLightness = theme$1.backgroundLightness.body;
|
|
33
38
|
|
|
39
|
+
// used by the consumer-facing/external BackgroundProvider
|
|
34
40
|
if (background === 'UNKNOWN_DARK') {
|
|
35
41
|
return 'dark';
|
|
36
42
|
}
|
|
37
|
-
|
|
38
43
|
if (background === 'UNKNOWN_LIGHT') {
|
|
39
44
|
return 'light';
|
|
40
45
|
}
|
|
41
|
-
|
|
42
46
|
return background ? theme$1.backgroundLightness[background] || defaultLightness : defaultLightness;
|
|
43
47
|
};
|
|
44
48
|
|
|
45
49
|
/** Enforce background "lightness" without applying a background color. */
|
|
46
50
|
var BackgroundProvider = function BackgroundProvider(_ref) {
|
|
47
51
|
var type = _ref.type,
|
|
48
|
-
|
|
52
|
+
children = _ref.children;
|
|
49
53
|
return renderBackgroundProvider(type === 'dark' ? 'UNKNOWN_DARK' : 'UNKNOWN_LIGHT', children);
|
|
50
54
|
};
|
|
51
55
|
|
|
56
|
+
// TODO perf review
|
|
52
57
|
// TODO: review responsive props! Now that we're using object syntax, un-mapped properties don't behave as expected
|
|
58
|
+
|
|
53
59
|
// types
|
|
54
60
|
|
|
55
61
|
// Hook
|
|
56
62
|
// ------------------------------
|
|
63
|
+
|
|
57
64
|
var useBoxStyles = function useBoxStyles(_ref) {
|
|
58
65
|
var alignItems = _ref.alignItems,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
66
|
+
alignSelf = _ref.alignSelf,
|
|
67
|
+
background = _ref.background,
|
|
68
|
+
border = _ref.border,
|
|
69
|
+
borderTop = _ref.borderTop,
|
|
70
|
+
borderBottom = _ref.borderBottom,
|
|
71
|
+
borderLeft = _ref.borderLeft,
|
|
72
|
+
borderRight = _ref.borderRight,
|
|
73
|
+
borderRadius = _ref.borderRadius,
|
|
74
|
+
_ref$borderWidth = _ref.borderWidth,
|
|
75
|
+
borderWidth = _ref$borderWidth === void 0 ? 'standard' : _ref$borderWidth,
|
|
76
|
+
bottom = _ref.bottom,
|
|
77
|
+
cursor = _ref.cursor,
|
|
78
|
+
display = _ref.display,
|
|
79
|
+
flex = _ref.flex,
|
|
80
|
+
flexDirection = _ref.flexDirection,
|
|
81
|
+
flexGrow = _ref.flexGrow,
|
|
82
|
+
flexShrink = _ref.flexShrink,
|
|
83
|
+
flexWrap = _ref.flexWrap,
|
|
84
|
+
gap = _ref.gap,
|
|
85
|
+
height = _ref.height,
|
|
86
|
+
justifyContent = _ref.justifyContent,
|
|
87
|
+
left = _ref.left,
|
|
88
|
+
margin = _ref.margin,
|
|
89
|
+
marginBottom = _ref.marginBottom,
|
|
90
|
+
marginLeft = _ref.marginLeft,
|
|
91
|
+
marginRight = _ref.marginRight,
|
|
92
|
+
marginTop = _ref.marginTop,
|
|
93
|
+
marginX = _ref.marginX,
|
|
94
|
+
marginY = _ref.marginY,
|
|
95
|
+
minHeight = _ref.minHeight,
|
|
96
|
+
minWidth = _ref.minWidth,
|
|
97
|
+
opacity = _ref.opacity,
|
|
98
|
+
overflow = _ref.overflow,
|
|
99
|
+
padding = _ref.padding,
|
|
100
|
+
paddingBottom = _ref.paddingBottom,
|
|
101
|
+
paddingLeft = _ref.paddingLeft,
|
|
102
|
+
paddingRight = _ref.paddingRight,
|
|
103
|
+
paddingTop = _ref.paddingTop,
|
|
104
|
+
paddingX = _ref.paddingX,
|
|
105
|
+
paddingY = _ref.paddingY,
|
|
106
|
+
position = _ref.position,
|
|
107
|
+
right = _ref.right,
|
|
108
|
+
shadow = _ref.shadow,
|
|
109
|
+
top = _ref.top,
|
|
110
|
+
userSelect = _ref.userSelect,
|
|
111
|
+
width = _ref.width,
|
|
112
|
+
zIndex = _ref.zIndex;
|
|
106
113
|
var theme$1 = theme.useTheme();
|
|
107
114
|
var unresponsiveProps = {
|
|
108
115
|
background: background ? theme$1.color.background[background] : undefined,
|
|
@@ -114,7 +121,6 @@ var useBoxStyles = function useBoxStyles(_ref) {
|
|
|
114
121
|
overflow: overflow,
|
|
115
122
|
userSelect: userSelect
|
|
116
123
|
};
|
|
117
|
-
|
|
118
124
|
var conditionalBorderStyles = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, border ? {
|
|
119
125
|
borderStyle: 'solid',
|
|
120
126
|
borderColor: theme$1.utils.mapResponsiveScale(border, theme$1.border.color),
|
|
@@ -136,7 +142,6 @@ var useBoxStyles = function useBoxStyles(_ref) {
|
|
|
136
142
|
borderRightColor: theme$1.utils.mapResponsiveScale(borderRight, theme$1.border.color),
|
|
137
143
|
borderRightWidth: theme$1.utils.mapResponsiveScale(borderWidth, theme$1.border.width)
|
|
138
144
|
} : {});
|
|
139
|
-
|
|
140
145
|
return theme$1.utils.resolveResponsiveProps(_objectSpread(_objectSpread(_objectSpread({}, unresponsiveProps), conditionalBorderStyles), {}, {
|
|
141
146
|
// allow padding and height/width props to play nice
|
|
142
147
|
display: theme$1.utils.mapResponsiveProp(display),
|
|
@@ -174,7 +179,9 @@ var useBoxStyles = function useBoxStyles(_ref) {
|
|
|
174
179
|
top: theme$1.utils.mapResponsiveProp(top),
|
|
175
180
|
zIndex: theme$1.utils.mapResponsiveScale(zIndex, theme$1.elevation)
|
|
176
181
|
}));
|
|
177
|
-
};
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
// Flex shorthand / adjustments
|
|
178
185
|
// ------------------------------
|
|
179
186
|
|
|
180
187
|
var flexMap = {
|
|
@@ -200,58 +207,57 @@ var flexMap = {
|
|
|
200
207
|
};
|
|
201
208
|
|
|
202
209
|
var _excluded$1 = ["alignItems", "alignSelf", "background", "border", "borderRadius", "borderWidth", "borderTop", "borderBottom", "borderLeft", "borderRight", "bottom", "cursor", "display", "flex", "flexDirection", "flexGrow", "flexShrink", "flexWrap", "gap", "height", "justifyContent", "left", "margin", "marginBottom", "marginLeft", "marginRight", "marginTop", "marginX", "marginY", "minHeight", "minWidth", "opacity", "overflow", "padding", "paddingBottom", "paddingLeft", "paddingRight", "paddingTop", "paddingX", "paddingY", "position", "right", "shadow", "top", "userSelect", "width", "zIndex"];
|
|
203
|
-
/** Separate the style properties from the element attributes. */
|
|
204
210
|
|
|
211
|
+
/** Separate the style properties from the element attributes. */
|
|
205
212
|
function useBoxProps(props) {
|
|
206
213
|
var alignItems = props.alignItems,
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
214
|
+
alignSelf = props.alignSelf,
|
|
215
|
+
background = props.background,
|
|
216
|
+
border = props.border,
|
|
217
|
+
borderRadius = props.borderRadius,
|
|
218
|
+
borderWidth = props.borderWidth,
|
|
219
|
+
borderTop = props.borderTop,
|
|
220
|
+
borderBottom = props.borderBottom,
|
|
221
|
+
borderLeft = props.borderLeft,
|
|
222
|
+
borderRight = props.borderRight,
|
|
223
|
+
bottom = props.bottom,
|
|
224
|
+
cursor = props.cursor,
|
|
225
|
+
display = props.display,
|
|
226
|
+
flex = props.flex,
|
|
227
|
+
flexDirection = props.flexDirection,
|
|
228
|
+
flexGrow = props.flexGrow,
|
|
229
|
+
flexShrink = props.flexShrink,
|
|
230
|
+
flexWrap = props.flexWrap,
|
|
231
|
+
gap = props.gap,
|
|
232
|
+
height = props.height,
|
|
233
|
+
justifyContent = props.justifyContent,
|
|
234
|
+
left = props.left,
|
|
235
|
+
margin = props.margin,
|
|
236
|
+
marginBottom = props.marginBottom,
|
|
237
|
+
marginLeft = props.marginLeft,
|
|
238
|
+
marginRight = props.marginRight,
|
|
239
|
+
marginTop = props.marginTop,
|
|
240
|
+
marginX = props.marginX,
|
|
241
|
+
marginY = props.marginY,
|
|
242
|
+
minHeight = props.minHeight,
|
|
243
|
+
minWidth = props.minWidth,
|
|
244
|
+
opacity = props.opacity,
|
|
245
|
+
overflow = props.overflow,
|
|
246
|
+
padding = props.padding,
|
|
247
|
+
paddingBottom = props.paddingBottom,
|
|
248
|
+
paddingLeft = props.paddingLeft,
|
|
249
|
+
paddingRight = props.paddingRight,
|
|
250
|
+
paddingTop = props.paddingTop,
|
|
251
|
+
paddingX = props.paddingX,
|
|
252
|
+
paddingY = props.paddingY,
|
|
253
|
+
position = props.position,
|
|
254
|
+
right = props.right,
|
|
255
|
+
shadow = props.shadow,
|
|
256
|
+
top = props.top,
|
|
257
|
+
userSelect = props.userSelect,
|
|
258
|
+
width = props.width,
|
|
259
|
+
zIndex = props.zIndex,
|
|
260
|
+
attributes = _objectWithoutProperties(props, _excluded$1);
|
|
255
261
|
var styles = useBoxStyles({
|
|
256
262
|
alignItems: alignItems,
|
|
257
263
|
alignSelf: alignSelf,
|
|
@@ -308,29 +314,24 @@ function useBoxProps(props) {
|
|
|
308
314
|
}
|
|
309
315
|
|
|
310
316
|
var _excluded = ["as", "asElement", "className", "data", "id"];
|
|
311
|
-
|
|
312
317
|
/** Exposes a prop-based API for adding styles to a view, within the constraints of the theme. */
|
|
313
318
|
var Box = ts.forwardRefWithAs(function (_ref, forwardedRef) {
|
|
314
319
|
var _ref$as = _ref.as,
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
320
|
+
Tag = _ref$as === void 0 ? 'div' : _ref$as,
|
|
321
|
+
asElement = _ref.asElement,
|
|
322
|
+
className = _ref.className,
|
|
323
|
+
data = _ref.data,
|
|
324
|
+
id = _ref.id,
|
|
325
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
322
326
|
var _useBoxProps = useBoxProps(props),
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
327
|
+
styles = _useBoxProps.styles,
|
|
328
|
+
attributes = _useBoxProps.attributes;
|
|
326
329
|
var resetStyles = internal.resetElementStyles(asElement !== null && asElement !== void 0 ? asElement : Tag);
|
|
327
|
-
|
|
328
330
|
var element = /*#__PURE__*/jsxRuntime.jsx(Tag, _objectSpread(_objectSpread({}, data ? internal.buildDataAttributes(data) : undefined), {}, {
|
|
329
331
|
ref: forwardedRef,
|
|
330
332
|
id: id,
|
|
331
333
|
className: css.cx(css.css(resetStyles), css.css(styles), className)
|
|
332
334
|
}, attributes));
|
|
333
|
-
|
|
334
335
|
return renderBackgroundProvider(props.background, element);
|
|
335
336
|
});
|
|
336
337
|
|
|
@@ -12,97 +12,104 @@ var internal = require('@spark-web/utils/internal');
|
|
|
12
12
|
var ts = require('@spark-web/utils/ts');
|
|
13
13
|
|
|
14
14
|
// prepare context
|
|
15
|
+
|
|
15
16
|
var backgroundContext = /*#__PURE__*/react.createContext('body');
|
|
16
17
|
var InternalBackgroundProvider = backgroundContext.Provider;
|
|
17
18
|
var useBackground = function useBackground() {
|
|
18
19
|
return react.useContext(backgroundContext);
|
|
19
|
-
};
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// conditional provider
|
|
20
23
|
|
|
21
24
|
function renderBackgroundProvider(background, element) {
|
|
22
25
|
return background ? /*#__PURE__*/jsxRuntime.jsx(InternalBackgroundProvider, {
|
|
23
26
|
value: background,
|
|
24
27
|
children: element
|
|
25
28
|
}) : element;
|
|
26
|
-
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// a11y contrast utility
|
|
27
32
|
|
|
28
33
|
var useBackgroundLightness = function useBackgroundLightness(backgroundOverride) {
|
|
29
34
|
var backgroundFromContext = useBackground();
|
|
30
35
|
var background = backgroundOverride || backgroundFromContext;
|
|
31
36
|
var theme$1 = theme.useTheme();
|
|
32
|
-
var defaultLightness = theme$1.backgroundLightness.body;
|
|
37
|
+
var defaultLightness = theme$1.backgroundLightness.body;
|
|
33
38
|
|
|
39
|
+
// used by the consumer-facing/external BackgroundProvider
|
|
34
40
|
if (background === 'UNKNOWN_DARK') {
|
|
35
41
|
return 'dark';
|
|
36
42
|
}
|
|
37
|
-
|
|
38
43
|
if (background === 'UNKNOWN_LIGHT') {
|
|
39
44
|
return 'light';
|
|
40
45
|
}
|
|
41
|
-
|
|
42
46
|
return background ? theme$1.backgroundLightness[background] || defaultLightness : defaultLightness;
|
|
43
47
|
};
|
|
44
48
|
|
|
45
49
|
/** Enforce background "lightness" without applying a background color. */
|
|
46
50
|
var BackgroundProvider = function BackgroundProvider(_ref) {
|
|
47
51
|
var type = _ref.type,
|
|
48
|
-
|
|
52
|
+
children = _ref.children;
|
|
49
53
|
return renderBackgroundProvider(type === 'dark' ? 'UNKNOWN_DARK' : 'UNKNOWN_LIGHT', children);
|
|
50
54
|
};
|
|
51
55
|
|
|
56
|
+
// TODO perf review
|
|
52
57
|
// TODO: review responsive props! Now that we're using object syntax, un-mapped properties don't behave as expected
|
|
58
|
+
|
|
53
59
|
// types
|
|
54
60
|
|
|
55
61
|
// Hook
|
|
56
62
|
// ------------------------------
|
|
63
|
+
|
|
57
64
|
var useBoxStyles = function useBoxStyles(_ref) {
|
|
58
65
|
var alignItems = _ref.alignItems,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
66
|
+
alignSelf = _ref.alignSelf,
|
|
67
|
+
background = _ref.background,
|
|
68
|
+
border = _ref.border,
|
|
69
|
+
borderTop = _ref.borderTop,
|
|
70
|
+
borderBottom = _ref.borderBottom,
|
|
71
|
+
borderLeft = _ref.borderLeft,
|
|
72
|
+
borderRight = _ref.borderRight,
|
|
73
|
+
borderRadius = _ref.borderRadius,
|
|
74
|
+
_ref$borderWidth = _ref.borderWidth,
|
|
75
|
+
borderWidth = _ref$borderWidth === void 0 ? 'standard' : _ref$borderWidth,
|
|
76
|
+
bottom = _ref.bottom,
|
|
77
|
+
cursor = _ref.cursor,
|
|
78
|
+
display = _ref.display,
|
|
79
|
+
flex = _ref.flex,
|
|
80
|
+
flexDirection = _ref.flexDirection,
|
|
81
|
+
flexGrow = _ref.flexGrow,
|
|
82
|
+
flexShrink = _ref.flexShrink,
|
|
83
|
+
flexWrap = _ref.flexWrap,
|
|
84
|
+
gap = _ref.gap,
|
|
85
|
+
height = _ref.height,
|
|
86
|
+
justifyContent = _ref.justifyContent,
|
|
87
|
+
left = _ref.left,
|
|
88
|
+
margin = _ref.margin,
|
|
89
|
+
marginBottom = _ref.marginBottom,
|
|
90
|
+
marginLeft = _ref.marginLeft,
|
|
91
|
+
marginRight = _ref.marginRight,
|
|
92
|
+
marginTop = _ref.marginTop,
|
|
93
|
+
marginX = _ref.marginX,
|
|
94
|
+
marginY = _ref.marginY,
|
|
95
|
+
minHeight = _ref.minHeight,
|
|
96
|
+
minWidth = _ref.minWidth,
|
|
97
|
+
opacity = _ref.opacity,
|
|
98
|
+
overflow = _ref.overflow,
|
|
99
|
+
padding = _ref.padding,
|
|
100
|
+
paddingBottom = _ref.paddingBottom,
|
|
101
|
+
paddingLeft = _ref.paddingLeft,
|
|
102
|
+
paddingRight = _ref.paddingRight,
|
|
103
|
+
paddingTop = _ref.paddingTop,
|
|
104
|
+
paddingX = _ref.paddingX,
|
|
105
|
+
paddingY = _ref.paddingY,
|
|
106
|
+
position = _ref.position,
|
|
107
|
+
right = _ref.right,
|
|
108
|
+
shadow = _ref.shadow,
|
|
109
|
+
top = _ref.top,
|
|
110
|
+
userSelect = _ref.userSelect,
|
|
111
|
+
width = _ref.width,
|
|
112
|
+
zIndex = _ref.zIndex;
|
|
106
113
|
var theme$1 = theme.useTheme();
|
|
107
114
|
var unresponsiveProps = {
|
|
108
115
|
background: background ? theme$1.color.background[background] : undefined,
|
|
@@ -114,7 +121,6 @@ var useBoxStyles = function useBoxStyles(_ref) {
|
|
|
114
121
|
overflow: overflow,
|
|
115
122
|
userSelect: userSelect
|
|
116
123
|
};
|
|
117
|
-
|
|
118
124
|
var conditionalBorderStyles = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, border ? {
|
|
119
125
|
borderStyle: 'solid',
|
|
120
126
|
borderColor: theme$1.utils.mapResponsiveScale(border, theme$1.border.color),
|
|
@@ -136,7 +142,6 @@ var useBoxStyles = function useBoxStyles(_ref) {
|
|
|
136
142
|
borderRightColor: theme$1.utils.mapResponsiveScale(borderRight, theme$1.border.color),
|
|
137
143
|
borderRightWidth: theme$1.utils.mapResponsiveScale(borderWidth, theme$1.border.width)
|
|
138
144
|
} : {});
|
|
139
|
-
|
|
140
145
|
return theme$1.utils.resolveResponsiveProps(_objectSpread(_objectSpread(_objectSpread({}, unresponsiveProps), conditionalBorderStyles), {}, {
|
|
141
146
|
// allow padding and height/width props to play nice
|
|
142
147
|
display: theme$1.utils.mapResponsiveProp(display),
|
|
@@ -174,7 +179,9 @@ var useBoxStyles = function useBoxStyles(_ref) {
|
|
|
174
179
|
top: theme$1.utils.mapResponsiveProp(top),
|
|
175
180
|
zIndex: theme$1.utils.mapResponsiveScale(zIndex, theme$1.elevation)
|
|
176
181
|
}));
|
|
177
|
-
};
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
// Flex shorthand / adjustments
|
|
178
185
|
// ------------------------------
|
|
179
186
|
|
|
180
187
|
var flexMap = {
|
|
@@ -200,58 +207,57 @@ var flexMap = {
|
|
|
200
207
|
};
|
|
201
208
|
|
|
202
209
|
var _excluded$1 = ["alignItems", "alignSelf", "background", "border", "borderRadius", "borderWidth", "borderTop", "borderBottom", "borderLeft", "borderRight", "bottom", "cursor", "display", "flex", "flexDirection", "flexGrow", "flexShrink", "flexWrap", "gap", "height", "justifyContent", "left", "margin", "marginBottom", "marginLeft", "marginRight", "marginTop", "marginX", "marginY", "minHeight", "minWidth", "opacity", "overflow", "padding", "paddingBottom", "paddingLeft", "paddingRight", "paddingTop", "paddingX", "paddingY", "position", "right", "shadow", "top", "userSelect", "width", "zIndex"];
|
|
203
|
-
/** Separate the style properties from the element attributes. */
|
|
204
210
|
|
|
211
|
+
/** Separate the style properties from the element attributes. */
|
|
205
212
|
function useBoxProps(props) {
|
|
206
213
|
var alignItems = props.alignItems,
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
214
|
+
alignSelf = props.alignSelf,
|
|
215
|
+
background = props.background,
|
|
216
|
+
border = props.border,
|
|
217
|
+
borderRadius = props.borderRadius,
|
|
218
|
+
borderWidth = props.borderWidth,
|
|
219
|
+
borderTop = props.borderTop,
|
|
220
|
+
borderBottom = props.borderBottom,
|
|
221
|
+
borderLeft = props.borderLeft,
|
|
222
|
+
borderRight = props.borderRight,
|
|
223
|
+
bottom = props.bottom,
|
|
224
|
+
cursor = props.cursor,
|
|
225
|
+
display = props.display,
|
|
226
|
+
flex = props.flex,
|
|
227
|
+
flexDirection = props.flexDirection,
|
|
228
|
+
flexGrow = props.flexGrow,
|
|
229
|
+
flexShrink = props.flexShrink,
|
|
230
|
+
flexWrap = props.flexWrap,
|
|
231
|
+
gap = props.gap,
|
|
232
|
+
height = props.height,
|
|
233
|
+
justifyContent = props.justifyContent,
|
|
234
|
+
left = props.left,
|
|
235
|
+
margin = props.margin,
|
|
236
|
+
marginBottom = props.marginBottom,
|
|
237
|
+
marginLeft = props.marginLeft,
|
|
238
|
+
marginRight = props.marginRight,
|
|
239
|
+
marginTop = props.marginTop,
|
|
240
|
+
marginX = props.marginX,
|
|
241
|
+
marginY = props.marginY,
|
|
242
|
+
minHeight = props.minHeight,
|
|
243
|
+
minWidth = props.minWidth,
|
|
244
|
+
opacity = props.opacity,
|
|
245
|
+
overflow = props.overflow,
|
|
246
|
+
padding = props.padding,
|
|
247
|
+
paddingBottom = props.paddingBottom,
|
|
248
|
+
paddingLeft = props.paddingLeft,
|
|
249
|
+
paddingRight = props.paddingRight,
|
|
250
|
+
paddingTop = props.paddingTop,
|
|
251
|
+
paddingX = props.paddingX,
|
|
252
|
+
paddingY = props.paddingY,
|
|
253
|
+
position = props.position,
|
|
254
|
+
right = props.right,
|
|
255
|
+
shadow = props.shadow,
|
|
256
|
+
top = props.top,
|
|
257
|
+
userSelect = props.userSelect,
|
|
258
|
+
width = props.width,
|
|
259
|
+
zIndex = props.zIndex,
|
|
260
|
+
attributes = _objectWithoutProperties(props, _excluded$1);
|
|
255
261
|
var styles = useBoxStyles({
|
|
256
262
|
alignItems: alignItems,
|
|
257
263
|
alignSelf: alignSelf,
|
|
@@ -308,29 +314,24 @@ function useBoxProps(props) {
|
|
|
308
314
|
}
|
|
309
315
|
|
|
310
316
|
var _excluded = ["as", "asElement", "className", "data", "id"];
|
|
311
|
-
|
|
312
317
|
/** Exposes a prop-based API for adding styles to a view, within the constraints of the theme. */
|
|
313
318
|
var Box = ts.forwardRefWithAs(function (_ref, forwardedRef) {
|
|
314
319
|
var _ref$as = _ref.as,
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
320
|
+
Tag = _ref$as === void 0 ? 'div' : _ref$as,
|
|
321
|
+
asElement = _ref.asElement,
|
|
322
|
+
className = _ref.className,
|
|
323
|
+
data = _ref.data,
|
|
324
|
+
id = _ref.id,
|
|
325
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
322
326
|
var _useBoxProps = useBoxProps(props),
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
327
|
+
styles = _useBoxProps.styles,
|
|
328
|
+
attributes = _useBoxProps.attributes;
|
|
326
329
|
var resetStyles = internal.resetElementStyles(asElement !== null && asElement !== void 0 ? asElement : Tag);
|
|
327
|
-
|
|
328
330
|
var element = /*#__PURE__*/jsxRuntime.jsx(Tag, _objectSpread(_objectSpread({}, data ? internal.buildDataAttributes(data) : undefined), {}, {
|
|
329
331
|
ref: forwardedRef,
|
|
330
332
|
id: id,
|
|
331
333
|
className: css.cx(css.css(resetStyles), css.css(styles), className)
|
|
332
334
|
}, attributes));
|
|
333
|
-
|
|
334
335
|
return renderBackgroundProvider(props.background, element);
|
|
335
336
|
});
|
|
336
337
|
|
|
@@ -8,97 +8,104 @@ import { resetElementStyles, buildDataAttributes } from '@spark-web/utils/intern
|
|
|
8
8
|
import { forwardRefWithAs } from '@spark-web/utils/ts';
|
|
9
9
|
|
|
10
10
|
// prepare context
|
|
11
|
+
|
|
11
12
|
var backgroundContext = /*#__PURE__*/createContext('body');
|
|
12
13
|
var InternalBackgroundProvider = backgroundContext.Provider;
|
|
13
14
|
var useBackground = function useBackground() {
|
|
14
15
|
return useContext(backgroundContext);
|
|
15
|
-
};
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// conditional provider
|
|
16
19
|
|
|
17
20
|
function renderBackgroundProvider(background, element) {
|
|
18
21
|
return background ? /*#__PURE__*/jsx(InternalBackgroundProvider, {
|
|
19
22
|
value: background,
|
|
20
23
|
children: element
|
|
21
24
|
}) : element;
|
|
22
|
-
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// a11y contrast utility
|
|
23
28
|
|
|
24
29
|
var useBackgroundLightness = function useBackgroundLightness(backgroundOverride) {
|
|
25
30
|
var backgroundFromContext = useBackground();
|
|
26
31
|
var background = backgroundOverride || backgroundFromContext;
|
|
27
32
|
var theme = useTheme();
|
|
28
|
-
var defaultLightness = theme.backgroundLightness.body;
|
|
33
|
+
var defaultLightness = theme.backgroundLightness.body;
|
|
29
34
|
|
|
35
|
+
// used by the consumer-facing/external BackgroundProvider
|
|
30
36
|
if (background === 'UNKNOWN_DARK') {
|
|
31
37
|
return 'dark';
|
|
32
38
|
}
|
|
33
|
-
|
|
34
39
|
if (background === 'UNKNOWN_LIGHT') {
|
|
35
40
|
return 'light';
|
|
36
41
|
}
|
|
37
|
-
|
|
38
42
|
return background ? theme.backgroundLightness[background] || defaultLightness : defaultLightness;
|
|
39
43
|
};
|
|
40
44
|
|
|
41
45
|
/** Enforce background "lightness" without applying a background color. */
|
|
42
46
|
var BackgroundProvider = function BackgroundProvider(_ref) {
|
|
43
47
|
var type = _ref.type,
|
|
44
|
-
|
|
48
|
+
children = _ref.children;
|
|
45
49
|
return renderBackgroundProvider(type === 'dark' ? 'UNKNOWN_DARK' : 'UNKNOWN_LIGHT', children);
|
|
46
50
|
};
|
|
47
51
|
|
|
52
|
+
// TODO perf review
|
|
48
53
|
// TODO: review responsive props! Now that we're using object syntax, un-mapped properties don't behave as expected
|
|
54
|
+
|
|
49
55
|
// types
|
|
50
56
|
|
|
51
57
|
// Hook
|
|
52
58
|
// ------------------------------
|
|
59
|
+
|
|
53
60
|
var useBoxStyles = function useBoxStyles(_ref) {
|
|
54
61
|
var alignItems = _ref.alignItems,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
62
|
+
alignSelf = _ref.alignSelf,
|
|
63
|
+
background = _ref.background,
|
|
64
|
+
border = _ref.border,
|
|
65
|
+
borderTop = _ref.borderTop,
|
|
66
|
+
borderBottom = _ref.borderBottom,
|
|
67
|
+
borderLeft = _ref.borderLeft,
|
|
68
|
+
borderRight = _ref.borderRight,
|
|
69
|
+
borderRadius = _ref.borderRadius,
|
|
70
|
+
_ref$borderWidth = _ref.borderWidth,
|
|
71
|
+
borderWidth = _ref$borderWidth === void 0 ? 'standard' : _ref$borderWidth,
|
|
72
|
+
bottom = _ref.bottom,
|
|
73
|
+
cursor = _ref.cursor,
|
|
74
|
+
display = _ref.display,
|
|
75
|
+
flex = _ref.flex,
|
|
76
|
+
flexDirection = _ref.flexDirection,
|
|
77
|
+
flexGrow = _ref.flexGrow,
|
|
78
|
+
flexShrink = _ref.flexShrink,
|
|
79
|
+
flexWrap = _ref.flexWrap,
|
|
80
|
+
gap = _ref.gap,
|
|
81
|
+
height = _ref.height,
|
|
82
|
+
justifyContent = _ref.justifyContent,
|
|
83
|
+
left = _ref.left,
|
|
84
|
+
margin = _ref.margin,
|
|
85
|
+
marginBottom = _ref.marginBottom,
|
|
86
|
+
marginLeft = _ref.marginLeft,
|
|
87
|
+
marginRight = _ref.marginRight,
|
|
88
|
+
marginTop = _ref.marginTop,
|
|
89
|
+
marginX = _ref.marginX,
|
|
90
|
+
marginY = _ref.marginY,
|
|
91
|
+
minHeight = _ref.minHeight,
|
|
92
|
+
minWidth = _ref.minWidth,
|
|
93
|
+
opacity = _ref.opacity,
|
|
94
|
+
overflow = _ref.overflow,
|
|
95
|
+
padding = _ref.padding,
|
|
96
|
+
paddingBottom = _ref.paddingBottom,
|
|
97
|
+
paddingLeft = _ref.paddingLeft,
|
|
98
|
+
paddingRight = _ref.paddingRight,
|
|
99
|
+
paddingTop = _ref.paddingTop,
|
|
100
|
+
paddingX = _ref.paddingX,
|
|
101
|
+
paddingY = _ref.paddingY,
|
|
102
|
+
position = _ref.position,
|
|
103
|
+
right = _ref.right,
|
|
104
|
+
shadow = _ref.shadow,
|
|
105
|
+
top = _ref.top,
|
|
106
|
+
userSelect = _ref.userSelect,
|
|
107
|
+
width = _ref.width,
|
|
108
|
+
zIndex = _ref.zIndex;
|
|
102
109
|
var theme = useTheme();
|
|
103
110
|
var unresponsiveProps = {
|
|
104
111
|
background: background ? theme.color.background[background] : undefined,
|
|
@@ -110,7 +117,6 @@ var useBoxStyles = function useBoxStyles(_ref) {
|
|
|
110
117
|
overflow: overflow,
|
|
111
118
|
userSelect: userSelect
|
|
112
119
|
};
|
|
113
|
-
|
|
114
120
|
var conditionalBorderStyles = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, border ? {
|
|
115
121
|
borderStyle: 'solid',
|
|
116
122
|
borderColor: theme.utils.mapResponsiveScale(border, theme.border.color),
|
|
@@ -132,7 +138,6 @@ var useBoxStyles = function useBoxStyles(_ref) {
|
|
|
132
138
|
borderRightColor: theme.utils.mapResponsiveScale(borderRight, theme.border.color),
|
|
133
139
|
borderRightWidth: theme.utils.mapResponsiveScale(borderWidth, theme.border.width)
|
|
134
140
|
} : {});
|
|
135
|
-
|
|
136
141
|
return theme.utils.resolveResponsiveProps(_objectSpread(_objectSpread(_objectSpread({}, unresponsiveProps), conditionalBorderStyles), {}, {
|
|
137
142
|
// allow padding and height/width props to play nice
|
|
138
143
|
display: theme.utils.mapResponsiveProp(display),
|
|
@@ -170,7 +175,9 @@ var useBoxStyles = function useBoxStyles(_ref) {
|
|
|
170
175
|
top: theme.utils.mapResponsiveProp(top),
|
|
171
176
|
zIndex: theme.utils.mapResponsiveScale(zIndex, theme.elevation)
|
|
172
177
|
}));
|
|
173
|
-
};
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
// Flex shorthand / adjustments
|
|
174
181
|
// ------------------------------
|
|
175
182
|
|
|
176
183
|
var flexMap = {
|
|
@@ -196,58 +203,57 @@ var flexMap = {
|
|
|
196
203
|
};
|
|
197
204
|
|
|
198
205
|
var _excluded$1 = ["alignItems", "alignSelf", "background", "border", "borderRadius", "borderWidth", "borderTop", "borderBottom", "borderLeft", "borderRight", "bottom", "cursor", "display", "flex", "flexDirection", "flexGrow", "flexShrink", "flexWrap", "gap", "height", "justifyContent", "left", "margin", "marginBottom", "marginLeft", "marginRight", "marginTop", "marginX", "marginY", "minHeight", "minWidth", "opacity", "overflow", "padding", "paddingBottom", "paddingLeft", "paddingRight", "paddingTop", "paddingX", "paddingY", "position", "right", "shadow", "top", "userSelect", "width", "zIndex"];
|
|
199
|
-
/** Separate the style properties from the element attributes. */
|
|
200
206
|
|
|
207
|
+
/** Separate the style properties from the element attributes. */
|
|
201
208
|
function useBoxProps(props) {
|
|
202
209
|
var alignItems = props.alignItems,
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
210
|
+
alignSelf = props.alignSelf,
|
|
211
|
+
background = props.background,
|
|
212
|
+
border = props.border,
|
|
213
|
+
borderRadius = props.borderRadius,
|
|
214
|
+
borderWidth = props.borderWidth,
|
|
215
|
+
borderTop = props.borderTop,
|
|
216
|
+
borderBottom = props.borderBottom,
|
|
217
|
+
borderLeft = props.borderLeft,
|
|
218
|
+
borderRight = props.borderRight,
|
|
219
|
+
bottom = props.bottom,
|
|
220
|
+
cursor = props.cursor,
|
|
221
|
+
display = props.display,
|
|
222
|
+
flex = props.flex,
|
|
223
|
+
flexDirection = props.flexDirection,
|
|
224
|
+
flexGrow = props.flexGrow,
|
|
225
|
+
flexShrink = props.flexShrink,
|
|
226
|
+
flexWrap = props.flexWrap,
|
|
227
|
+
gap = props.gap,
|
|
228
|
+
height = props.height,
|
|
229
|
+
justifyContent = props.justifyContent,
|
|
230
|
+
left = props.left,
|
|
231
|
+
margin = props.margin,
|
|
232
|
+
marginBottom = props.marginBottom,
|
|
233
|
+
marginLeft = props.marginLeft,
|
|
234
|
+
marginRight = props.marginRight,
|
|
235
|
+
marginTop = props.marginTop,
|
|
236
|
+
marginX = props.marginX,
|
|
237
|
+
marginY = props.marginY,
|
|
238
|
+
minHeight = props.minHeight,
|
|
239
|
+
minWidth = props.minWidth,
|
|
240
|
+
opacity = props.opacity,
|
|
241
|
+
overflow = props.overflow,
|
|
242
|
+
padding = props.padding,
|
|
243
|
+
paddingBottom = props.paddingBottom,
|
|
244
|
+
paddingLeft = props.paddingLeft,
|
|
245
|
+
paddingRight = props.paddingRight,
|
|
246
|
+
paddingTop = props.paddingTop,
|
|
247
|
+
paddingX = props.paddingX,
|
|
248
|
+
paddingY = props.paddingY,
|
|
249
|
+
position = props.position,
|
|
250
|
+
right = props.right,
|
|
251
|
+
shadow = props.shadow,
|
|
252
|
+
top = props.top,
|
|
253
|
+
userSelect = props.userSelect,
|
|
254
|
+
width = props.width,
|
|
255
|
+
zIndex = props.zIndex,
|
|
256
|
+
attributes = _objectWithoutProperties(props, _excluded$1);
|
|
251
257
|
var styles = useBoxStyles({
|
|
252
258
|
alignItems: alignItems,
|
|
253
259
|
alignSelf: alignSelf,
|
|
@@ -304,29 +310,24 @@ function useBoxProps(props) {
|
|
|
304
310
|
}
|
|
305
311
|
|
|
306
312
|
var _excluded = ["as", "asElement", "className", "data", "id"];
|
|
307
|
-
|
|
308
313
|
/** Exposes a prop-based API for adding styles to a view, within the constraints of the theme. */
|
|
309
314
|
var Box = forwardRefWithAs(function (_ref, forwardedRef) {
|
|
310
315
|
var _ref$as = _ref.as,
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
316
|
+
Tag = _ref$as === void 0 ? 'div' : _ref$as,
|
|
317
|
+
asElement = _ref.asElement,
|
|
318
|
+
className = _ref.className,
|
|
319
|
+
data = _ref.data,
|
|
320
|
+
id = _ref.id,
|
|
321
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
318
322
|
var _useBoxProps = useBoxProps(props),
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
323
|
+
styles = _useBoxProps.styles,
|
|
324
|
+
attributes = _useBoxProps.attributes;
|
|
322
325
|
var resetStyles = resetElementStyles(asElement !== null && asElement !== void 0 ? asElement : Tag);
|
|
323
|
-
|
|
324
326
|
var element = /*#__PURE__*/jsx(Tag, _objectSpread(_objectSpread({}, data ? buildDataAttributes(data) : undefined), {}, {
|
|
325
327
|
ref: forwardedRef,
|
|
326
328
|
id: id,
|
|
327
329
|
className: cx(css(resetStyles), css(styles), className)
|
|
328
330
|
}, attributes));
|
|
329
|
-
|
|
330
331
|
return renderBackgroundProvider(props.background, element);
|
|
331
332
|
});
|
|
332
333
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spark-web/box",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"homepage": "https://github.com/brighte-labs/spark-web#readme",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@babel/runtime": "^7.19.0",
|
|
19
19
|
"@emotion/css": "^11.9.0",
|
|
20
|
-
"@spark-web/theme": "^3.
|
|
21
|
-
"@spark-web/utils": "^1.
|
|
20
|
+
"@spark-web/theme": "^3.2.0",
|
|
21
|
+
"@spark-web/utils": "^1.3.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@types/react": "^
|
|
25
|
-
"react": "^
|
|
24
|
+
"@types/react": "^18.2.0",
|
|
25
|
+
"react": "^18.2.0"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"react": ">=17.0.2"
|