@spark-web/box 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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @spark-web/box
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/theme@4.0.0-rc.1
13
+ - @spark-web/utils@2.0.0-rc.1
14
+
3
15
  ## 2.0.0-rc.0
4
16
 
5
17
  ### Major Changes
@@ -0,0 +1,7 @@
1
+ import type { ReactElement } from 'react';
2
+ export declare type BackgroundProviderProps = {
3
+ type: 'light' | 'dark';
4
+ children: ReactElement;
5
+ };
6
+ /** Enforce background "lightness" without applying a background color. */
7
+ export declare const BackgroundProvider: ({ type, children, }: BackgroundProviderProps) => import("@emotion/react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,47 @@
1
+ import type { DataAttributeMap } from '@spark-web/utils/internal';
2
+ import type { ReactNode } from 'react';
3
+ import type { BoxStyleProps } from "./use-box-styles.js";
4
+ export declare type BoxProps = {
5
+ /** Children element to be rendered inside the component. */
6
+ children?: ReactNode;
7
+ /** Sets data attributes on the component. */
8
+ data?: DataAttributeMap;
9
+ /** An identifier which must be unique in the whole document. */
10
+ id?: string;
11
+ /** Custom css styles. */
12
+ className?: string;
13
+ /**
14
+ * When providing a component using the "as" prop, optionally tell the system
15
+ * what the underlying element will be. Used internally to manage reset
16
+ * styles.
17
+ */
18
+ asElement?: keyof HTMLElementTagNameMap;
19
+ } & BoxStyleProps;
20
+ /** Exposes a prop-based API for adding styles to a view, within the constraints of the theme. */
21
+ export declare const Box: <Comp extends import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> = "div">(props: {
22
+ as?: Comp | undefined;
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" | "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;
24
+ } & Omit<import("react").PropsWithoutRef<import("react").ComponentProps<Comp>>, "as"> & {
25
+ /** Children element to be rendered inside the component. */
26
+ children?: ReactNode;
27
+ /** Sets data attributes on the component. */
28
+ data?: DataAttributeMap | undefined;
29
+ /** An identifier which must be unique in the whole document. */
30
+ id?: string | undefined;
31
+ /** Custom css styles. */
32
+ className?: string | undefined;
33
+ /**
34
+ * When providing a component using the "as" prop, optionally tell the system
35
+ * what the underlying element will be. Used internally to manage reset
36
+ * styles.
37
+ */
38
+ asElement?: keyof HTMLElementTagNameMap | undefined;
39
+ } & {
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
+ cursor?: "default" | "pointer" | undefined;
42
+ minHeight?: 0 | undefined;
43
+ minWidth?: 0 | undefined;
44
+ overflow?: "auto" | "hidden" | "scroll" | "visible" | undefined;
45
+ shadow?: "small" | "large" | "medium" | undefined;
46
+ userSelect?: "none" | undefined;
47
+ } & import("./use-box-styles.js").ResponsiveBoxProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
@@ -0,0 +1,7 @@
1
+ import type { ReactElement } from 'react';
2
+ import type { BoxStyleProps } from "./use-box-styles.js";
3
+ export declare type BackgroundVariant = NonNullable<BoxStyleProps['background']> | 'UNKNOWN_DARK' | 'UNKNOWN_LIGHT';
4
+ export declare const InternalBackgroundProvider: import("react").Provider<BackgroundVariant>;
5
+ export declare const useBackground: () => BackgroundVariant;
6
+ export declare function renderBackgroundProvider(background: BackgroundVariant | undefined, element: ReactElement | null): import("@emotion/react/jsx-runtime").JSX.Element | null;
7
+ export declare const useBackgroundLightness: (backgroundOverride?: ReturnType<typeof useBackground>) => "light" | "dark";
@@ -0,0 +1,5 @@
1
+ export { BackgroundProvider } from "./background-provider.js";
2
+ export { Box } from "./box.js";
3
+ export { useBackground, useBackgroundLightness } from "./context.js";
4
+ export type { BackgroundProviderProps } from "./background-provider.js";
5
+ export type { BoxProps } from "./box.js";
@@ -0,0 +1,227 @@
1
+ import type { BrighteTheme, ResponsiveProp } from '@spark-web/theme';
2
+ declare type ValidGapKeys = keyof Omit<BrighteTheme['spacing'], 'none' | 'full'>;
3
+ declare type ResponsiveSpacing = ResponsiveProp<keyof BrighteTheme['spacing']>;
4
+ declare type ResponsiveSizing = ResponsiveProp<keyof BrighteTheme['sizing']>;
5
+ export declare type ResponsiveBoxProps = {
6
+ /**
7
+ * The `margin` shorthand property sets the margin area on all four sides of
8
+ * an element at once.
9
+ */
10
+ margin?: ResponsiveSpacing;
11
+ /**
12
+ * The `marginTop` property sets the margin area on the top side of an
13
+ * element.
14
+ */
15
+ marginTop?: ResponsiveSpacing;
16
+ /**
17
+ * The `marginRight` property sets the margin area on the right side of an
18
+ * element.
19
+ */
20
+ marginRight?: ResponsiveSpacing;
21
+ /**
22
+ * The `marginBottom` property sets the margin area on the bottom side of an
23
+ * element.
24
+ */
25
+ marginBottom?: ResponsiveSpacing;
26
+ /**
27
+ * The `marginLeft` property sets the margin area on the left side of an
28
+ * element.
29
+ */
30
+ marginLeft?: ResponsiveSpacing;
31
+ /**
32
+ * The `marginY` shorthand property sets the margin area on the top and
33
+ * bottom of the element.
34
+ */
35
+ marginY?: ResponsiveSpacing;
36
+ /**
37
+ * The `marginY` shorthand property sets the margin area on the left and
38
+ * right of the element.
39
+ */
40
+ marginX?: ResponsiveSpacing;
41
+ /**
42
+ * The `padding` shorthand property sets the padding area on all four sides
43
+ * of an element at once.
44
+ */
45
+ padding?: ResponsiveSpacing;
46
+ /**
47
+ * The `paddingTop` property sets the height of the padding area on the top
48
+ * of an element.
49
+ */
50
+ paddingTop?: ResponsiveSpacing;
51
+ /**
52
+ * The `paddingRight` property sets the width of the padding area on the
53
+ * right of an element.
54
+ */
55
+ paddingRight?: ResponsiveSpacing;
56
+ /**
57
+ * The `paddingBottom` property sets the height of the padding area on the
58
+ * bottom of an element.
59
+ */
60
+ paddingBottom?: ResponsiveSpacing;
61
+ /**
62
+ * The `paddingLeft` property sets the width of the padding area on the left
63
+ * of an element.
64
+ */
65
+ paddingLeft?: ResponsiveSpacing;
66
+ /**
67
+ * The `paddingY` shorthand property sets the padding area on the top and
68
+ * bottom of the element.
69
+ */
70
+ paddingY?: ResponsiveSpacing;
71
+ /**
72
+ * The `paddingX` shorthand property sets the padding area on the left and
73
+ * right of the element.
74
+ */
75
+ paddingX?: ResponsiveSpacing;
76
+ /** The `border` property sets the color of an element's border. */
77
+ border?: ResponsiveProp<keyof BrighteTheme['border']['color']>;
78
+ /** The `border` property sets the color of an element's border on the top side. */
79
+ borderTop?: ResponsiveProp<keyof BrighteTheme['border']['color']>;
80
+ /** The `border` property sets the color of an element's border on the bottom side. */
81
+ borderBottom?: ResponsiveProp<keyof BrighteTheme['border']['color']>;
82
+ /** The `border` property sets the color of an element's border on the left side. */
83
+ borderLeft?: ResponsiveProp<keyof BrighteTheme['border']['color']>;
84
+ /** The `border` property sets the color of an element's border on the right side. */
85
+ borderRight?: ResponsiveProp<keyof BrighteTheme['border']['color']>;
86
+ /**
87
+ * The `borderRadius` property rounds the corners of an element's outer
88
+ * border edge.
89
+ */
90
+ borderRadius?: ResponsiveProp<keyof BrighteTheme['border']['radius']>;
91
+ /**
92
+ * The `borderWidth` property sets the width of an element's border.
93
+ */
94
+ borderWidth?: ResponsiveProp<keyof BrighteTheme['border']['width']>;
95
+ /** Sets the element's height. */
96
+ height?: ResponsiveSizing;
97
+ /** Sets the element's width. */
98
+ width?: ResponsiveSizing;
99
+ /** Controls the alignment of items on the cross axis. */
100
+ alignItems?: ResponsiveProp<keyof typeof flexMap.alignItems>;
101
+ /** The size of the gap between each child element. */
102
+ gap?: ResponsiveProp<ValidGapKeys>;
103
+ /** Defines the main axis, or how the children are placed. */
104
+ flexDirection?: ResponsiveProp<keyof typeof flexMap.flexDirection>;
105
+ /**
106
+ * defines how the browser distributes space between and around content items
107
+ * along the main-axis.
108
+ */
109
+ justifyContent?: ResponsiveProp<keyof typeof flexMap.justifyContent>;
110
+ /** Allow flex items to flow onto multiple lines. */
111
+ flexWrap?: ResponsiveProp<'nowrap' | 'wrap'>;
112
+ /**
113
+ * Overrides the parent's `align-items` value. Controls the alignment of
114
+ * item's on the cross axis.
115
+ */
116
+ alignSelf?: ResponsiveProp<keyof typeof flexMap.alignItems>;
117
+ /**
118
+ * The `flex` shorthand property sets how a flex item will grow or shrink to
119
+ * fit the space available in its flex container.
120
+ */
121
+ flex?: ResponsiveProp<0 | 1>;
122
+ /** The `flexGrow` property sets the flex grow factor of a flex item main size. */
123
+ flexGrow?: ResponsiveProp<0 | 1>;
124
+ /**
125
+ * The `flexShrink` property sets the flex shrink factor of a flex item. If
126
+ * the size of all flex items is larger than the flex container, items shrink
127
+ * to fit according to `flex-shrink`.
128
+ */
129
+ flexShrink?: ResponsiveProp<0 | 1>;
130
+ /**
131
+ * The `position` property sets how an element is positioned in a document.
132
+ * The `top`, `right`, `bottom`, and `left` properties determine the final
133
+ * location of positioned elements.
134
+ */
135
+ position?: ResponsiveProp<'absolute' | 'fixed' | 'relative' | 'sticky'>;
136
+ /**
137
+ * The `top` property participates in specifying the vertical position of a
138
+ * positioned element. It has no effect on non-positioned elements.
139
+ */
140
+ top?: ResponsiveProp<0>;
141
+ /**
142
+ * The `right` property participates in specifying the horizontal position of
143
+ * a positioned element. It has no effect on non-positioned elements.
144
+ */
145
+ right?: ResponsiveProp<0>;
146
+ /**
147
+ * The `bottom` property participates in setting the vertical position of a
148
+ * positioned element. It has no effect on non-positioned elements.
149
+ */
150
+ bottom?: ResponsiveProp<0>;
151
+ /**
152
+ * The `left` property participates in specifying the horizontal position of a
153
+ * positioned element. It has no effect on non-positioned elements.
154
+ */
155
+ left?: ResponsiveProp<0>;
156
+ /**
157
+ * The `zIndex` property sets the "z-order" of a positioned element and its
158
+ * descendants or flex items. Overlapping elements with a larger z-index cover
159
+ * those with a smaller one.
160
+ */
161
+ zIndex?: ResponsiveProp<keyof BrighteTheme['elevation']>;
162
+ /**
163
+ * Sets whether an element is treated as a block or inline element and the
164
+ * layout used for its children.
165
+ */
166
+ display?: ResponsiveProp<'block' | 'flex' | 'inline' | 'inline-block' | 'inline-flex' | 'none'>;
167
+ /**
168
+ * Sets the opacity of the element. Opacity is the degree to which content
169
+ * behind an element is hidden, and is the opposite of transparency.
170
+ */
171
+ opacity?: ResponsiveProp<number>;
172
+ };
173
+ declare type UnresponsiveBoxProps = {
174
+ /** The `background` property sets the background color of an element. */
175
+ background?: keyof BrighteTheme['color']['background'];
176
+ /**
177
+ * The `cursor` property sets the type of mouse cursor, if any, to show when
178
+ * the mouse pointer is over an element.
179
+ */
180
+ cursor?: 'default' | 'pointer';
181
+ /**
182
+ * The `minHeight` property sets the minimum height of an element. It prevents
183
+ * the used value of the height property from becoming smaller than the value
184
+ * specified for `minHeight`.
185
+ */
186
+ minHeight?: 0;
187
+ /**
188
+ * The `minWidth` property sets the minimum width of an element. It prevents
189
+ * the used value of the width property from becoming smaller than the value
190
+ * specified for `minWidth`.
191
+ */
192
+ minWidth?: 0;
193
+ /**
194
+ * The `overflow` shorthand property sets the desired behavior for an
195
+ * element's overflow — i.e. when an element's content is too big to fit in
196
+ * its block formatting context — in both directions.
197
+ */
198
+ overflow?: 'hidden' | 'scroll' | 'visible' | 'auto';
199
+ /** The `boxShadow` property adds shadow effects around an element's frame. */
200
+ shadow?: keyof BrighteTheme['shadow'];
201
+ /** The `userSelect` property controls whether the user can select text. */
202
+ userSelect?: 'none';
203
+ };
204
+ export declare type BoxStyleProps = UnresponsiveBoxProps & ResponsiveBoxProps;
205
+ export declare const useBoxStyles: ({ alignItems, alignSelf, background, border, borderTop, borderBottom, borderLeft, borderRight, 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, }: BoxStyleProps) => import("facepaint").DynamicStyle[];
206
+ declare const flexMap: {
207
+ readonly alignItems: {
208
+ readonly start: "flex-start";
209
+ readonly center: "center";
210
+ readonly end: "flex-end";
211
+ readonly stretch: "stretch";
212
+ };
213
+ readonly justifyContent: {
214
+ readonly start: "flex-start";
215
+ readonly center: "center";
216
+ readonly end: "flex-end";
217
+ readonly spaceBetween: "space-between";
218
+ readonly stretch: "stretch";
219
+ };
220
+ readonly flexDirection: {
221
+ readonly row: "row";
222
+ readonly rowReverse: "row-reverse";
223
+ readonly column: "column";
224
+ readonly columnReverse: "column-reverse";
225
+ };
226
+ };
227
+ export {};
@@ -1,2 +1,2 @@
1
- export * from "../src/index";
2
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3Bhcmstd2ViLWJveC5janMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9
1
+ export * from "./declarations/src/index";
2
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3Bhcmstd2ViLWJveC5janMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4vZGVjbGFyYXRpb25zL3NyYy9pbmRleC5kLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBIn0=
@@ -0,0 +1,347 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var theme = require('@spark-web/theme');
6
+ var react = require('react');
7
+ var jsxRuntime = require('react/jsx-runtime');
8
+ var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
9
+ var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
10
+ var react$1 = require('@emotion/react');
11
+ var internal = require('@spark-web/utils/internal');
12
+ var ts = require('@spark-web/utils/ts');
13
+
14
+ // prepare context
15
+
16
+ var backgroundContext = /*#__PURE__*/react.createContext('body');
17
+ var InternalBackgroundProvider = backgroundContext.Provider;
18
+ var useBackground = function useBackground() {
19
+ return react.useContext(backgroundContext);
20
+ };
21
+
22
+ // conditional provider
23
+
24
+ function renderBackgroundProvider(background, element) {
25
+ return background ? /*#__PURE__*/jsxRuntime.jsx(InternalBackgroundProvider, {
26
+ value: background,
27
+ children: element
28
+ }) : element;
29
+ }
30
+
31
+ // a11y contrast utility
32
+
33
+ var useBackgroundLightness = function useBackgroundLightness(backgroundOverride) {
34
+ var backgroundFromContext = useBackground();
35
+ var background = backgroundOverride || backgroundFromContext;
36
+ var theme$1 = theme.useTheme();
37
+ var defaultLightness = theme$1.backgroundLightness.body;
38
+
39
+ // used by the consumer-facing/external BackgroundProvider
40
+ if (background === 'UNKNOWN_DARK') {
41
+ return 'dark';
42
+ }
43
+ if (background === 'UNKNOWN_LIGHT') {
44
+ return 'light';
45
+ }
46
+ return background ? theme$1.backgroundLightness[background] || defaultLightness : defaultLightness;
47
+ };
48
+
49
+ /** Enforce background "lightness" without applying a background color. */
50
+ var BackgroundProvider = function BackgroundProvider(_ref) {
51
+ var type = _ref.type,
52
+ children = _ref.children;
53
+ return renderBackgroundProvider(type === 'dark' ? 'UNKNOWN_DARK' : 'UNKNOWN_LIGHT', children);
54
+ };
55
+
56
+ // TODO perf review
57
+ // TODO: review responsive props! Now that we're using object syntax, un-mapped properties don't behave as expected
58
+
59
+ // types
60
+
61
+ // Hook
62
+ // ------------------------------
63
+
64
+ var useBoxStyles = function useBoxStyles(_ref) {
65
+ var alignItems = _ref.alignItems,
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;
113
+ var theme$1 = theme.useTheme();
114
+ var unresponsiveProps = {
115
+ background: background ? theme$1.color.background[background] : undefined,
116
+ boxShadow: shadow ? theme$1.shadow[shadow] : undefined,
117
+ cursor: cursor,
118
+ minHeight: minHeight,
119
+ minWidth: minWidth,
120
+ opacity: opacity,
121
+ overflow: overflow,
122
+ userSelect: userSelect
123
+ };
124
+ var conditionalBorderStyles = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, border ? {
125
+ borderStyle: 'solid',
126
+ borderColor: theme$1.utils.mapResponsiveScale(border, theme$1.border.color),
127
+ borderWidth: theme$1.utils.mapResponsiveScale(borderWidth, theme$1.border.width)
128
+ } : {}), borderTop ? {
129
+ borderTopStyle: 'solid',
130
+ borderTopColor: theme$1.utils.mapResponsiveScale(borderTop, theme$1.border.color),
131
+ borderTopWidth: theme$1.utils.mapResponsiveScale(borderWidth, theme$1.border.width)
132
+ } : {}), borderBottom ? {
133
+ borderBottomStyle: 'solid',
134
+ borderBottomColor: theme$1.utils.mapResponsiveScale(borderBottom, theme$1.border.color),
135
+ borderBottomWidth: theme$1.utils.mapResponsiveScale(borderWidth, theme$1.border.width)
136
+ } : {}), borderLeft ? {
137
+ borderLeftStyle: 'solid',
138
+ borderLeftColor: theme$1.utils.mapResponsiveScale(borderLeft, theme$1.border.color),
139
+ borderLeftWidth: theme$1.utils.mapResponsiveScale(borderWidth, theme$1.border.width)
140
+ } : {}), borderRight ? {
141
+ borderRightStyle: 'solid',
142
+ borderRightColor: theme$1.utils.mapResponsiveScale(borderRight, theme$1.border.color),
143
+ borderRightWidth: theme$1.utils.mapResponsiveScale(borderWidth, theme$1.border.width)
144
+ } : {});
145
+ return theme$1.utils.resolveResponsiveProps(_objectSpread(_objectSpread(_objectSpread({}, unresponsiveProps), conditionalBorderStyles), {}, {
146
+ // allow padding and height/width props to play nice
147
+ display: theme$1.utils.mapResponsiveProp(display),
148
+ // margin
149
+ marginBottom: theme$1.utils.mapResponsiveScale(marginBottom || marginY || margin, theme$1.spacing),
150
+ marginTop: theme$1.utils.mapResponsiveScale(marginTop || marginY || margin, theme$1.spacing),
151
+ marginLeft: theme$1.utils.mapResponsiveScale(marginLeft || marginX || margin, theme$1.spacing),
152
+ marginRight: theme$1.utils.mapResponsiveScale(marginRight || marginX || margin, theme$1.spacing),
153
+ // padding
154
+ paddingBottom: theme$1.utils.mapResponsiveScale(paddingBottom || paddingY || padding, theme$1.spacing),
155
+ paddingTop: theme$1.utils.mapResponsiveScale(paddingTop || paddingY || padding, theme$1.spacing),
156
+ paddingLeft: theme$1.utils.mapResponsiveScale(paddingLeft || paddingX || padding, theme$1.spacing),
157
+ paddingRight: theme$1.utils.mapResponsiveScale(paddingRight || paddingX || padding, theme$1.spacing),
158
+ // border
159
+ borderRadius: theme$1.utils.mapResponsiveScale(borderRadius, theme$1.border.radius),
160
+ // flex: parent
161
+ alignItems: theme$1.utils.mapResponsiveScale(alignItems, flexMap.alignItems),
162
+ gap: theme$1.utils.mapResponsiveScale(gap, theme$1.spacing),
163
+ flexDirection: theme$1.utils.mapResponsiveScale(flexDirection, flexMap.flexDirection),
164
+ justifyContent: theme$1.utils.mapResponsiveScale(justifyContent, flexMap.justifyContent),
165
+ flexWrap: theme$1.utils.mapResponsiveProp(flexWrap),
166
+ // flex: child
167
+ alignSelf: theme$1.utils.mapResponsiveScale(alignSelf, flexMap.alignItems),
168
+ flex: theme$1.utils.mapResponsiveProp(flex),
169
+ flexGrow: theme$1.utils.mapResponsiveProp(flexGrow),
170
+ flexShrink: theme$1.utils.mapResponsiveProp(flexShrink),
171
+ // dimension
172
+ height: theme$1.utils.mapResponsiveScale(height, theme$1.sizing),
173
+ width: theme$1.utils.mapResponsiveScale(width, theme$1.sizing),
174
+ // position
175
+ position: theme$1.utils.mapResponsiveProp(position),
176
+ bottom: theme$1.utils.mapResponsiveProp(bottom),
177
+ left: theme$1.utils.mapResponsiveProp(left),
178
+ right: theme$1.utils.mapResponsiveProp(right),
179
+ top: theme$1.utils.mapResponsiveProp(top),
180
+ zIndex: theme$1.utils.mapResponsiveScale(zIndex, theme$1.elevation)
181
+ }));
182
+ };
183
+
184
+ // Flex shorthand / adjustments
185
+ // ------------------------------
186
+
187
+ var flexMap = {
188
+ alignItems: {
189
+ start: 'flex-start',
190
+ center: 'center',
191
+ end: 'flex-end',
192
+ stretch: 'stretch'
193
+ },
194
+ justifyContent: {
195
+ start: 'flex-start',
196
+ center: 'center',
197
+ end: 'flex-end',
198
+ spaceBetween: 'space-between',
199
+ stretch: 'stretch'
200
+ },
201
+ flexDirection: {
202
+ row: 'row',
203
+ rowReverse: 'row-reverse',
204
+ column: 'column',
205
+ columnReverse: 'column-reverse'
206
+ }
207
+ };
208
+
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"];
210
+
211
+ /** Separate the style properties from the element attributes. */
212
+ function useBoxProps(props) {
213
+ var alignItems = props.alignItems,
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);
261
+ var styles = useBoxStyles({
262
+ alignItems: alignItems,
263
+ alignSelf: alignSelf,
264
+ background: background,
265
+ border: border,
266
+ borderRadius: borderRadius,
267
+ borderWidth: borderWidth,
268
+ borderBottom: borderBottom,
269
+ borderLeft: borderLeft,
270
+ borderRight: borderRight,
271
+ borderTop: borderTop,
272
+ bottom: bottom,
273
+ cursor: cursor,
274
+ display: display,
275
+ flex: flex,
276
+ flexDirection: flexDirection,
277
+ flexGrow: flexGrow,
278
+ flexShrink: flexShrink,
279
+ flexWrap: flexWrap,
280
+ gap: gap,
281
+ height: height,
282
+ justifyContent: justifyContent,
283
+ left: left,
284
+ margin: margin,
285
+ marginBottom: marginBottom,
286
+ marginLeft: marginLeft,
287
+ marginRight: marginRight,
288
+ marginTop: marginTop,
289
+ marginX: marginX,
290
+ marginY: marginY,
291
+ minHeight: minHeight,
292
+ minWidth: minWidth,
293
+ opacity: opacity,
294
+ overflow: overflow,
295
+ padding: padding,
296
+ paddingBottom: paddingBottom,
297
+ paddingLeft: paddingLeft,
298
+ paddingRight: paddingRight,
299
+ paddingTop: paddingTop,
300
+ paddingX: paddingX,
301
+ paddingY: paddingY,
302
+ position: position,
303
+ right: right,
304
+ shadow: shadow,
305
+ top: top,
306
+ userSelect: userSelect,
307
+ width: width,
308
+ zIndex: zIndex
309
+ });
310
+ return {
311
+ styles: styles,
312
+ attributes: attributes
313
+ };
314
+ }
315
+
316
+ var _excluded = ["as", "asElement", "className", "data", "id"];
317
+ /** Exposes a prop-based API for adding styles to a view, within the constraints of the theme. */
318
+ var Box = ts.forwardRefWithAs(function (_ref, forwardedRef) {
319
+ var _ref$as = _ref.as,
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);
326
+ var _useBoxProps = useBoxProps(props),
327
+ styles = _useBoxProps.styles,
328
+ attributes = _useBoxProps.attributes;
329
+ var resetStyles = internal.resetElementStyles(asElement !== null && asElement !== void 0 ? asElement : Tag);
330
+ var element = /*#__PURE__*/jsxRuntime.jsx(react$1.ClassNames, {
331
+ children: function children(_ref2) {
332
+ var css = _ref2.css,
333
+ cx = _ref2.cx;
334
+ return /*#__PURE__*/jsxRuntime.jsx(Tag, _objectSpread(_objectSpread({}, data ? internal.buildDataAttributes(data) : undefined), {}, {
335
+ ref: forwardedRef,
336
+ id: id,
337
+ className: cx(css(resetStyles), css(styles), className)
338
+ }, attributes));
339
+ }
340
+ });
341
+ return renderBackgroundProvider(props.background, element);
342
+ });
343
+
344
+ exports.BackgroundProvider = BackgroundProvider;
345
+ exports.Box = Box;
346
+ exports.useBackground = useBackground;
347
+ exports.useBackgroundLightness = useBackgroundLightness;