@spark-web/box 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,320 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ var theme = require('@spark-web/theme');
7
+ var _extends = require('@babel/runtime/helpers/esm/extends');
8
+ var _objectWithoutProperties = require('@babel/runtime/helpers/esm/objectWithoutProperties');
9
+ var css = require('@emotion/css');
10
+ var internal = require('@spark-web/utils/internal');
11
+ var ts = require('@spark-web/utils/ts');
12
+ var _defineProperty = require('@babel/runtime/helpers/esm/defineProperty');
13
+
14
+ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
15
+
16
+ var React__default = /*#__PURE__*/_interopDefault(React);
17
+
18
+ var __jsx$1 = React__default["default"].createElement;
19
+ // prepare context
20
+ var backgroundContext = /*#__PURE__*/React.createContext('body');
21
+ var InternalBackgroundProvider = backgroundContext.Provider;
22
+ var useBackground = function useBackground() {
23
+ return React.useContext(backgroundContext);
24
+ }; // conditional provider
25
+
26
+ function renderBackgroundProvider(background, element) {
27
+ return background ? __jsx$1(InternalBackgroundProvider, {
28
+ value: background
29
+ }, element) : element;
30
+ } // a11y contrast utility
31
+
32
+ var useBackgroundLightness = function useBackgroundLightness(backgroundOverride) {
33
+ var backgroundFromContext = useBackground();
34
+ var background = backgroundOverride || backgroundFromContext;
35
+
36
+ var _useTheme = theme.useTheme(),
37
+ backgroundLightness = _useTheme.backgroundLightness;
38
+
39
+ var defaultLightness = backgroundLightness.body; // used by the consumer-facing/external BackgroundProvider
40
+
41
+ if (background === 'UNKNOWN_DARK') {
42
+ return 'dark';
43
+ }
44
+
45
+ if (background === 'UNKNOWN_LIGHT') {
46
+ return 'light';
47
+ }
48
+
49
+ return background ? backgroundLightness[background] || defaultLightness : defaultLightness;
50
+ };
51
+
52
+ /** Enforce background "lightness" without applying a background color. */
53
+ var BackgroundProvider = function BackgroundProvider(_ref) {
54
+ var type = _ref.type,
55
+ children = _ref.children;
56
+ return renderBackgroundProvider(type === 'dark' ? 'UNKNOWN_DARK' : 'UNKNOWN_LIGHT', children);
57
+ };
58
+
59
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
60
+
61
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
62
+ // TODO: review responsive props! Now that we're using object syntax, un-mapped properties don't behave as expected
63
+ // types
64
+
65
+ // Hook
66
+ // ------------------------------
67
+ var useBoxStyles = function useBoxStyles(_ref) {
68
+ var alignItems = _ref.alignItems,
69
+ alignSelf = _ref.alignSelf,
70
+ background = _ref.background,
71
+ border = _ref.border,
72
+ borderRadius = _ref.borderRadius,
73
+ _ref$borderWidth = _ref.borderWidth,
74
+ borderWidth = _ref$borderWidth === void 0 ? 'standard' : _ref$borderWidth,
75
+ bottom = _ref.bottom,
76
+ cursor = _ref.cursor,
77
+ display = _ref.display,
78
+ flex = _ref.flex,
79
+ flexDirection = _ref.flexDirection,
80
+ flexGrow = _ref.flexGrow,
81
+ flexShrink = _ref.flexShrink,
82
+ flexWrap = _ref.flexWrap,
83
+ gap = _ref.gap,
84
+ height = _ref.height,
85
+ justifyContent = _ref.justifyContent,
86
+ left = _ref.left,
87
+ margin = _ref.margin,
88
+ marginBottom = _ref.marginBottom,
89
+ marginLeft = _ref.marginLeft,
90
+ marginRight = _ref.marginRight,
91
+ marginTop = _ref.marginTop,
92
+ marginX = _ref.marginX,
93
+ marginY = _ref.marginY,
94
+ minHeight = _ref.minHeight,
95
+ minWidth = _ref.minWidth,
96
+ opacity = _ref.opacity,
97
+ overflow = _ref.overflow,
98
+ padding = _ref.padding,
99
+ paddingBottom = _ref.paddingBottom,
100
+ paddingLeft = _ref.paddingLeft,
101
+ paddingRight = _ref.paddingRight,
102
+ paddingTop = _ref.paddingTop,
103
+ paddingX = _ref.paddingX,
104
+ paddingY = _ref.paddingY,
105
+ position = _ref.position,
106
+ right = _ref.right,
107
+ shadow = _ref.shadow,
108
+ top = _ref.top,
109
+ userSelect = _ref.userSelect,
110
+ width = _ref.width,
111
+ zIndex = _ref.zIndex;
112
+ var theme$1 = theme.useTheme();
113
+ var unresponsiveProps = {
114
+ background: background ? theme$1.color.background[background] : undefined,
115
+ boxShadow: shadow ? theme$1.shadow[shadow] : undefined,
116
+ cursor: cursor,
117
+ minHeight: minHeight,
118
+ minWidth: minWidth,
119
+ opacity: opacity,
120
+ overflow: overflow,
121
+ userSelect: userSelect
122
+ };
123
+ var conditionalBorderStyles = border ? {
124
+ borderStyle: 'solid',
125
+ borderColor: theme$1.utils.mapResponsiveScale(border, theme$1.border.color),
126
+ borderWidth: theme$1.utils.mapResponsiveScale(borderWidth, theme$1.border.width)
127
+ } : null;
128
+ return theme$1.utils.resolveResponsiveProps(_objectSpread(_objectSpread(_objectSpread({}, unresponsiveProps), conditionalBorderStyles), {}, {
129
+ // allow padding and height/width props to play nice
130
+ display: theme$1.utils.mapResponsiveProp(display),
131
+ // margin
132
+ marginBottom: theme$1.utils.mapResponsiveScale(marginBottom || marginY || margin, theme$1.spacing),
133
+ marginTop: theme$1.utils.mapResponsiveScale(marginTop || marginY || margin, theme$1.spacing),
134
+ marginLeft: theme$1.utils.mapResponsiveScale(marginLeft || marginX || margin, theme$1.spacing),
135
+ marginRight: theme$1.utils.mapResponsiveScale(marginRight || marginX || margin, theme$1.spacing),
136
+ // padding
137
+ paddingBottom: theme$1.utils.mapResponsiveScale(paddingBottom || paddingY || padding, theme$1.spacing),
138
+ paddingTop: theme$1.utils.mapResponsiveScale(paddingTop || paddingY || padding, theme$1.spacing),
139
+ paddingLeft: theme$1.utils.mapResponsiveScale(paddingLeft || paddingX || padding, theme$1.spacing),
140
+ paddingRight: theme$1.utils.mapResponsiveScale(paddingRight || paddingX || padding, theme$1.spacing),
141
+ // border
142
+ borderRadius: theme$1.utils.mapResponsiveScale(borderRadius, theme$1.border.radius),
143
+ // flex: parent
144
+ alignItems: theme$1.utils.mapResponsiveScale(alignItems, flexMap.alignItems),
145
+ gap: theme$1.utils.mapResponsiveScale(gap, theme$1.spacing),
146
+ flexDirection: theme$1.utils.mapResponsiveScale(flexDirection, flexMap.flexDirection),
147
+ justifyContent: theme$1.utils.mapResponsiveScale(justifyContent, flexMap.justifyContent),
148
+ flexWrap: theme$1.utils.mapResponsiveProp(flexWrap),
149
+ // flex: child
150
+ alignSelf: theme$1.utils.mapResponsiveScale(alignSelf, flexMap.alignItems),
151
+ flex: theme$1.utils.mapResponsiveProp(flex),
152
+ flexGrow: theme$1.utils.mapResponsiveProp(flexGrow),
153
+ flexShrink: theme$1.utils.mapResponsiveProp(flexShrink),
154
+ // dimension
155
+ height: theme$1.utils.mapResponsiveScale(height, theme$1.sizing),
156
+ width: theme$1.utils.mapResponsiveScale(width, theme$1.sizing),
157
+ // position
158
+ position: theme$1.utils.mapResponsiveProp(position),
159
+ bottom: theme$1.utils.mapResponsiveProp(bottom),
160
+ left: theme$1.utils.mapResponsiveProp(left),
161
+ right: theme$1.utils.mapResponsiveProp(right),
162
+ top: theme$1.utils.mapResponsiveProp(top),
163
+ zIndex: theme$1.utils.mapResponsiveScale(zIndex, theme$1.elevation)
164
+ }));
165
+ }; // Flex shorthand / adjustments
166
+ // ------------------------------
167
+
168
+ var flexMap = {
169
+ alignItems: {
170
+ start: 'flex-start',
171
+ center: 'center',
172
+ end: 'flex-end',
173
+ stretch: 'stretch'
174
+ },
175
+ justifyContent: {
176
+ start: 'flex-start',
177
+ center: 'center',
178
+ end: 'flex-end',
179
+ spaceBetween: 'space-between',
180
+ stretch: 'stretch'
181
+ },
182
+ flexDirection: {
183
+ row: 'row',
184
+ rowReverse: 'row-reverse',
185
+ column: 'column',
186
+ columnReverse: 'column-reverse'
187
+ }
188
+ };
189
+
190
+ var _excluded$1 = ["alignItems", "alignSelf", "background", "border", "borderRadius", "borderWidth", "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"];
191
+ /** Separate the style properties from the element attributes. */
192
+
193
+ function useBoxProps(props) {
194
+ var alignItems = props.alignItems,
195
+ alignSelf = props.alignSelf,
196
+ background = props.background,
197
+ border = props.border,
198
+ borderRadius = props.borderRadius,
199
+ borderWidth = props.borderWidth,
200
+ bottom = props.bottom,
201
+ cursor = props.cursor,
202
+ display = props.display,
203
+ flex = props.flex,
204
+ flexDirection = props.flexDirection,
205
+ flexGrow = props.flexGrow,
206
+ flexShrink = props.flexShrink,
207
+ flexWrap = props.flexWrap,
208
+ gap = props.gap,
209
+ height = props.height,
210
+ justifyContent = props.justifyContent,
211
+ left = props.left,
212
+ margin = props.margin,
213
+ marginBottom = props.marginBottom,
214
+ marginLeft = props.marginLeft,
215
+ marginRight = props.marginRight,
216
+ marginTop = props.marginTop,
217
+ marginX = props.marginX,
218
+ marginY = props.marginY,
219
+ minHeight = props.minHeight,
220
+ minWidth = props.minWidth,
221
+ opacity = props.opacity,
222
+ overflow = props.overflow,
223
+ padding = props.padding,
224
+ paddingBottom = props.paddingBottom,
225
+ paddingLeft = props.paddingLeft,
226
+ paddingRight = props.paddingRight,
227
+ paddingTop = props.paddingTop,
228
+ paddingX = props.paddingX,
229
+ paddingY = props.paddingY,
230
+ position = props.position,
231
+ right = props.right,
232
+ shadow = props.shadow,
233
+ top = props.top,
234
+ userSelect = props.userSelect,
235
+ width = props.width,
236
+ zIndex = props.zIndex,
237
+ attributes = _objectWithoutProperties(props, _excluded$1);
238
+
239
+ var styles = useBoxStyles({
240
+ alignItems: alignItems,
241
+ alignSelf: alignSelf,
242
+ background: background,
243
+ border: border,
244
+ borderRadius: borderRadius,
245
+ borderWidth: borderWidth,
246
+ bottom: bottom,
247
+ cursor: cursor,
248
+ display: display,
249
+ flex: flex,
250
+ flexDirection: flexDirection,
251
+ flexGrow: flexGrow,
252
+ flexShrink: flexShrink,
253
+ flexWrap: flexWrap,
254
+ gap: gap,
255
+ height: height,
256
+ justifyContent: justifyContent,
257
+ left: left,
258
+ margin: margin,
259
+ marginBottom: marginBottom,
260
+ marginLeft: marginLeft,
261
+ marginRight: marginRight,
262
+ marginTop: marginTop,
263
+ marginX: marginX,
264
+ marginY: marginY,
265
+ minHeight: minHeight,
266
+ minWidth: minWidth,
267
+ opacity: opacity,
268
+ overflow: overflow,
269
+ padding: padding,
270
+ paddingBottom: paddingBottom,
271
+ paddingLeft: paddingLeft,
272
+ paddingRight: paddingRight,
273
+ paddingTop: paddingTop,
274
+ paddingX: paddingX,
275
+ paddingY: paddingY,
276
+ position: position,
277
+ right: right,
278
+ shadow: shadow,
279
+ top: top,
280
+ userSelect: userSelect,
281
+ width: width,
282
+ zIndex: zIndex
283
+ });
284
+ return {
285
+ styles: styles,
286
+ attributes: attributes
287
+ };
288
+ }
289
+
290
+ var _excluded = ["as", "asElement", "className", "id"];
291
+ var __jsx = React__default["default"].createElement;
292
+
293
+ /** Exposes a prop-based API for adding styles to a view, within the constraints of the theme. */
294
+ var Box = ts.forwardRefWithAs(function (_ref, forwardedRef) {
295
+ var _ref$as = _ref.as,
296
+ Tag = _ref$as === void 0 ? 'div' : _ref$as,
297
+ asElement = _ref.asElement,
298
+ className = _ref.className,
299
+ id = _ref.id,
300
+ props = _objectWithoutProperties(_ref, _excluded);
301
+
302
+ var _useBoxProps = useBoxProps(props),
303
+ styles = _useBoxProps.styles,
304
+ attributes = _useBoxProps.attributes;
305
+
306
+ var resetStyles = internal.resetElementStyles(asElement !== null && asElement !== void 0 ? asElement : Tag);
307
+
308
+ var element = __jsx(Tag, _extends({
309
+ ref: forwardedRef,
310
+ id: id,
311
+ className: css.cx(css.css(resetStyles), css.css(styles), className)
312
+ }, attributes));
313
+
314
+ return renderBackgroundProvider(props.background, element);
315
+ });
316
+
317
+ exports.BackgroundProvider = BackgroundProvider;
318
+ exports.Box = Box;
319
+ exports.useBackground = useBackground;
320
+ exports.useBackgroundLightness = useBackgroundLightness;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ if (process.env.NODE_ENV === "production") {
4
+ module.exports = require("./spark-web-box.cjs.prod.js");
5
+ } else {
6
+ module.exports = require("./spark-web-box.cjs.dev.js");
7
+ }
@@ -0,0 +1,320 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ var theme = require('@spark-web/theme');
7
+ var _extends = require('@babel/runtime/helpers/esm/extends');
8
+ var _objectWithoutProperties = require('@babel/runtime/helpers/esm/objectWithoutProperties');
9
+ var css = require('@emotion/css');
10
+ var internal = require('@spark-web/utils/internal');
11
+ var ts = require('@spark-web/utils/ts');
12
+ var _defineProperty = require('@babel/runtime/helpers/esm/defineProperty');
13
+
14
+ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
15
+
16
+ var React__default = /*#__PURE__*/_interopDefault(React);
17
+
18
+ var __jsx$1 = React__default["default"].createElement;
19
+ // prepare context
20
+ var backgroundContext = /*#__PURE__*/React.createContext('body');
21
+ var InternalBackgroundProvider = backgroundContext.Provider;
22
+ var useBackground = function useBackground() {
23
+ return React.useContext(backgroundContext);
24
+ }; // conditional provider
25
+
26
+ function renderBackgroundProvider(background, element) {
27
+ return background ? __jsx$1(InternalBackgroundProvider, {
28
+ value: background
29
+ }, element) : element;
30
+ } // a11y contrast utility
31
+
32
+ var useBackgroundLightness = function useBackgroundLightness(backgroundOverride) {
33
+ var backgroundFromContext = useBackground();
34
+ var background = backgroundOverride || backgroundFromContext;
35
+
36
+ var _useTheme = theme.useTheme(),
37
+ backgroundLightness = _useTheme.backgroundLightness;
38
+
39
+ var defaultLightness = backgroundLightness.body; // used by the consumer-facing/external BackgroundProvider
40
+
41
+ if (background === 'UNKNOWN_DARK') {
42
+ return 'dark';
43
+ }
44
+
45
+ if (background === 'UNKNOWN_LIGHT') {
46
+ return 'light';
47
+ }
48
+
49
+ return background ? backgroundLightness[background] || defaultLightness : defaultLightness;
50
+ };
51
+
52
+ /** Enforce background "lightness" without applying a background color. */
53
+ var BackgroundProvider = function BackgroundProvider(_ref) {
54
+ var type = _ref.type,
55
+ children = _ref.children;
56
+ return renderBackgroundProvider(type === 'dark' ? 'UNKNOWN_DARK' : 'UNKNOWN_LIGHT', children);
57
+ };
58
+
59
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
60
+
61
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
62
+ // TODO: review responsive props! Now that we're using object syntax, un-mapped properties don't behave as expected
63
+ // types
64
+
65
+ // Hook
66
+ // ------------------------------
67
+ var useBoxStyles = function useBoxStyles(_ref) {
68
+ var alignItems = _ref.alignItems,
69
+ alignSelf = _ref.alignSelf,
70
+ background = _ref.background,
71
+ border = _ref.border,
72
+ borderRadius = _ref.borderRadius,
73
+ _ref$borderWidth = _ref.borderWidth,
74
+ borderWidth = _ref$borderWidth === void 0 ? 'standard' : _ref$borderWidth,
75
+ bottom = _ref.bottom,
76
+ cursor = _ref.cursor,
77
+ display = _ref.display,
78
+ flex = _ref.flex,
79
+ flexDirection = _ref.flexDirection,
80
+ flexGrow = _ref.flexGrow,
81
+ flexShrink = _ref.flexShrink,
82
+ flexWrap = _ref.flexWrap,
83
+ gap = _ref.gap,
84
+ height = _ref.height,
85
+ justifyContent = _ref.justifyContent,
86
+ left = _ref.left,
87
+ margin = _ref.margin,
88
+ marginBottom = _ref.marginBottom,
89
+ marginLeft = _ref.marginLeft,
90
+ marginRight = _ref.marginRight,
91
+ marginTop = _ref.marginTop,
92
+ marginX = _ref.marginX,
93
+ marginY = _ref.marginY,
94
+ minHeight = _ref.minHeight,
95
+ minWidth = _ref.minWidth,
96
+ opacity = _ref.opacity,
97
+ overflow = _ref.overflow,
98
+ padding = _ref.padding,
99
+ paddingBottom = _ref.paddingBottom,
100
+ paddingLeft = _ref.paddingLeft,
101
+ paddingRight = _ref.paddingRight,
102
+ paddingTop = _ref.paddingTop,
103
+ paddingX = _ref.paddingX,
104
+ paddingY = _ref.paddingY,
105
+ position = _ref.position,
106
+ right = _ref.right,
107
+ shadow = _ref.shadow,
108
+ top = _ref.top,
109
+ userSelect = _ref.userSelect,
110
+ width = _ref.width,
111
+ zIndex = _ref.zIndex;
112
+ var theme$1 = theme.useTheme();
113
+ var unresponsiveProps = {
114
+ background: background ? theme$1.color.background[background] : undefined,
115
+ boxShadow: shadow ? theme$1.shadow[shadow] : undefined,
116
+ cursor: cursor,
117
+ minHeight: minHeight,
118
+ minWidth: minWidth,
119
+ opacity: opacity,
120
+ overflow: overflow,
121
+ userSelect: userSelect
122
+ };
123
+ var conditionalBorderStyles = border ? {
124
+ borderStyle: 'solid',
125
+ borderColor: theme$1.utils.mapResponsiveScale(border, theme$1.border.color),
126
+ borderWidth: theme$1.utils.mapResponsiveScale(borderWidth, theme$1.border.width)
127
+ } : null;
128
+ return theme$1.utils.resolveResponsiveProps(_objectSpread(_objectSpread(_objectSpread({}, unresponsiveProps), conditionalBorderStyles), {}, {
129
+ // allow padding and height/width props to play nice
130
+ display: theme$1.utils.mapResponsiveProp(display),
131
+ // margin
132
+ marginBottom: theme$1.utils.mapResponsiveScale(marginBottom || marginY || margin, theme$1.spacing),
133
+ marginTop: theme$1.utils.mapResponsiveScale(marginTop || marginY || margin, theme$1.spacing),
134
+ marginLeft: theme$1.utils.mapResponsiveScale(marginLeft || marginX || margin, theme$1.spacing),
135
+ marginRight: theme$1.utils.mapResponsiveScale(marginRight || marginX || margin, theme$1.spacing),
136
+ // padding
137
+ paddingBottom: theme$1.utils.mapResponsiveScale(paddingBottom || paddingY || padding, theme$1.spacing),
138
+ paddingTop: theme$1.utils.mapResponsiveScale(paddingTop || paddingY || padding, theme$1.spacing),
139
+ paddingLeft: theme$1.utils.mapResponsiveScale(paddingLeft || paddingX || padding, theme$1.spacing),
140
+ paddingRight: theme$1.utils.mapResponsiveScale(paddingRight || paddingX || padding, theme$1.spacing),
141
+ // border
142
+ borderRadius: theme$1.utils.mapResponsiveScale(borderRadius, theme$1.border.radius),
143
+ // flex: parent
144
+ alignItems: theme$1.utils.mapResponsiveScale(alignItems, flexMap.alignItems),
145
+ gap: theme$1.utils.mapResponsiveScale(gap, theme$1.spacing),
146
+ flexDirection: theme$1.utils.mapResponsiveScale(flexDirection, flexMap.flexDirection),
147
+ justifyContent: theme$1.utils.mapResponsiveScale(justifyContent, flexMap.justifyContent),
148
+ flexWrap: theme$1.utils.mapResponsiveProp(flexWrap),
149
+ // flex: child
150
+ alignSelf: theme$1.utils.mapResponsiveScale(alignSelf, flexMap.alignItems),
151
+ flex: theme$1.utils.mapResponsiveProp(flex),
152
+ flexGrow: theme$1.utils.mapResponsiveProp(flexGrow),
153
+ flexShrink: theme$1.utils.mapResponsiveProp(flexShrink),
154
+ // dimension
155
+ height: theme$1.utils.mapResponsiveScale(height, theme$1.sizing),
156
+ width: theme$1.utils.mapResponsiveScale(width, theme$1.sizing),
157
+ // position
158
+ position: theme$1.utils.mapResponsiveProp(position),
159
+ bottom: theme$1.utils.mapResponsiveProp(bottom),
160
+ left: theme$1.utils.mapResponsiveProp(left),
161
+ right: theme$1.utils.mapResponsiveProp(right),
162
+ top: theme$1.utils.mapResponsiveProp(top),
163
+ zIndex: theme$1.utils.mapResponsiveScale(zIndex, theme$1.elevation)
164
+ }));
165
+ }; // Flex shorthand / adjustments
166
+ // ------------------------------
167
+
168
+ var flexMap = {
169
+ alignItems: {
170
+ start: 'flex-start',
171
+ center: 'center',
172
+ end: 'flex-end',
173
+ stretch: 'stretch'
174
+ },
175
+ justifyContent: {
176
+ start: 'flex-start',
177
+ center: 'center',
178
+ end: 'flex-end',
179
+ spaceBetween: 'space-between',
180
+ stretch: 'stretch'
181
+ },
182
+ flexDirection: {
183
+ row: 'row',
184
+ rowReverse: 'row-reverse',
185
+ column: 'column',
186
+ columnReverse: 'column-reverse'
187
+ }
188
+ };
189
+
190
+ var _excluded$1 = ["alignItems", "alignSelf", "background", "border", "borderRadius", "borderWidth", "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"];
191
+ /** Separate the style properties from the element attributes. */
192
+
193
+ function useBoxProps(props) {
194
+ var alignItems = props.alignItems,
195
+ alignSelf = props.alignSelf,
196
+ background = props.background,
197
+ border = props.border,
198
+ borderRadius = props.borderRadius,
199
+ borderWidth = props.borderWidth,
200
+ bottom = props.bottom,
201
+ cursor = props.cursor,
202
+ display = props.display,
203
+ flex = props.flex,
204
+ flexDirection = props.flexDirection,
205
+ flexGrow = props.flexGrow,
206
+ flexShrink = props.flexShrink,
207
+ flexWrap = props.flexWrap,
208
+ gap = props.gap,
209
+ height = props.height,
210
+ justifyContent = props.justifyContent,
211
+ left = props.left,
212
+ margin = props.margin,
213
+ marginBottom = props.marginBottom,
214
+ marginLeft = props.marginLeft,
215
+ marginRight = props.marginRight,
216
+ marginTop = props.marginTop,
217
+ marginX = props.marginX,
218
+ marginY = props.marginY,
219
+ minHeight = props.minHeight,
220
+ minWidth = props.minWidth,
221
+ opacity = props.opacity,
222
+ overflow = props.overflow,
223
+ padding = props.padding,
224
+ paddingBottom = props.paddingBottom,
225
+ paddingLeft = props.paddingLeft,
226
+ paddingRight = props.paddingRight,
227
+ paddingTop = props.paddingTop,
228
+ paddingX = props.paddingX,
229
+ paddingY = props.paddingY,
230
+ position = props.position,
231
+ right = props.right,
232
+ shadow = props.shadow,
233
+ top = props.top,
234
+ userSelect = props.userSelect,
235
+ width = props.width,
236
+ zIndex = props.zIndex,
237
+ attributes = _objectWithoutProperties(props, _excluded$1);
238
+
239
+ var styles = useBoxStyles({
240
+ alignItems: alignItems,
241
+ alignSelf: alignSelf,
242
+ background: background,
243
+ border: border,
244
+ borderRadius: borderRadius,
245
+ borderWidth: borderWidth,
246
+ bottom: bottom,
247
+ cursor: cursor,
248
+ display: display,
249
+ flex: flex,
250
+ flexDirection: flexDirection,
251
+ flexGrow: flexGrow,
252
+ flexShrink: flexShrink,
253
+ flexWrap: flexWrap,
254
+ gap: gap,
255
+ height: height,
256
+ justifyContent: justifyContent,
257
+ left: left,
258
+ margin: margin,
259
+ marginBottom: marginBottom,
260
+ marginLeft: marginLeft,
261
+ marginRight: marginRight,
262
+ marginTop: marginTop,
263
+ marginX: marginX,
264
+ marginY: marginY,
265
+ minHeight: minHeight,
266
+ minWidth: minWidth,
267
+ opacity: opacity,
268
+ overflow: overflow,
269
+ padding: padding,
270
+ paddingBottom: paddingBottom,
271
+ paddingLeft: paddingLeft,
272
+ paddingRight: paddingRight,
273
+ paddingTop: paddingTop,
274
+ paddingX: paddingX,
275
+ paddingY: paddingY,
276
+ position: position,
277
+ right: right,
278
+ shadow: shadow,
279
+ top: top,
280
+ userSelect: userSelect,
281
+ width: width,
282
+ zIndex: zIndex
283
+ });
284
+ return {
285
+ styles: styles,
286
+ attributes: attributes
287
+ };
288
+ }
289
+
290
+ var _excluded = ["as", "asElement", "className", "id"];
291
+ var __jsx = React__default["default"].createElement;
292
+
293
+ /** Exposes a prop-based API for adding styles to a view, within the constraints of the theme. */
294
+ var Box = ts.forwardRefWithAs(function (_ref, forwardedRef) {
295
+ var _ref$as = _ref.as,
296
+ Tag = _ref$as === void 0 ? 'div' : _ref$as,
297
+ asElement = _ref.asElement,
298
+ className = _ref.className,
299
+ id = _ref.id,
300
+ props = _objectWithoutProperties(_ref, _excluded);
301
+
302
+ var _useBoxProps = useBoxProps(props),
303
+ styles = _useBoxProps.styles,
304
+ attributes = _useBoxProps.attributes;
305
+
306
+ var resetStyles = internal.resetElementStyles(asElement !== null && asElement !== void 0 ? asElement : Tag);
307
+
308
+ var element = __jsx(Tag, _extends({
309
+ ref: forwardedRef,
310
+ id: id,
311
+ className: css.cx(css.css(resetStyles), css.css(styles), className)
312
+ }, attributes));
313
+
314
+ return renderBackgroundProvider(props.background, element);
315
+ });
316
+
317
+ exports.BackgroundProvider = BackgroundProvider;
318
+ exports.Box = Box;
319
+ exports.useBackground = useBackground;
320
+ exports.useBackgroundLightness = useBackgroundLightness;