@react-spectrum/layout 3.5.7-nightly.4220 → 3.5.7
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/dist/import.mjs +48 -0
- package/dist/main.js +48 -0
- package/dist/main.js.map +1 -1
- package/dist/module.js +48 -0
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/Flex.tsx +59 -0
package/dist/import.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import "./main.css";
|
|
|
2
2
|
import {baseStyleProps as $9LQqs$baseStyleProps, passthroughStyle as $9LQqs$passthroughStyle, dimensionValue as $9LQqs$dimensionValue, useStyleProps as $9LQqs$useStyleProps, useDOMRef as $9LQqs$useDOMRef, useBreakpoint as $9LQqs$useBreakpoint, responsiveDimensionValue as $9LQqs$responsiveDimensionValue, classNames as $9LQqs$classNames} from "@react-spectrum/utils";
|
|
3
3
|
import {filterDOMProps as $9LQqs$filterDOMProps} from "@react-aria/utils";
|
|
4
4
|
import $9LQqs$react, {forwardRef as $9LQqs$forwardRef} from "react";
|
|
5
|
+
import {useIsSSR as $9LQqs$useIsSSR} from "@react-aria/ssr";
|
|
5
6
|
|
|
6
7
|
function $parcel$interopDefault(a) {
|
|
7
8
|
return a && a.__esModule ? a.default : a;
|
|
@@ -151,6 +152,7 @@ $01dd1839b5376a46$export$69d7a39fa31a000b = `NW91UW_flex-container`;
|
|
|
151
152
|
$01dd1839b5376a46$export$31a9da8b58047a44 = `NW91UW_flex-gap`;
|
|
152
153
|
|
|
153
154
|
|
|
155
|
+
|
|
154
156
|
const $884c64d19340d345$var$flexStyleProps = {
|
|
155
157
|
direction: [
|
|
156
158
|
"flexDirection",
|
|
@@ -182,6 +184,31 @@ function $884c64d19340d345$var$Flex(props, ref) {
|
|
|
182
184
|
let { styleProps: styleProps } = (0, $9LQqs$useStyleProps)(otherProps);
|
|
183
185
|
let { styleProps: flexStyle } = (0, $9LQqs$useStyleProps)(otherProps, $884c64d19340d345$var$flexStyleProps);
|
|
184
186
|
let domRef = (0, $9LQqs$useDOMRef)(ref);
|
|
187
|
+
let isSSR = (0, $9LQqs$useIsSSR)();
|
|
188
|
+
// If a gap property is specified, and there is no native support or we're in SSR, use a shim.
|
|
189
|
+
// Two divs are required for this: the outer one contains most style properties, and the inner
|
|
190
|
+
// one is the flex container. Each item inside the flex container gets a margin around it based
|
|
191
|
+
// on the gap, and the flex container has a negative margin to counteract this. The outer container
|
|
192
|
+
// is necessary to allow nesting of flex containers with gaps, so that the inner CSS variable doesn't
|
|
193
|
+
// override the outer one.
|
|
194
|
+
if ((props.gap || props.rowGap || props.columnGap) && (isSSR || !$884c64d19340d345$var$isFlexGapSupported())) {
|
|
195
|
+
let style = {
|
|
196
|
+
...flexStyle.style,
|
|
197
|
+
"--column-gap": props.columnGap != null ? (0, $9LQqs$responsiveDimensionValue)(props.columnGap, matchedBreakpoints) : undefined,
|
|
198
|
+
"--row-gap": props.rowGap != null ? (0, $9LQqs$responsiveDimensionValue)(props.rowGap, matchedBreakpoints) : undefined,
|
|
199
|
+
"--gap": props.gap != null ? (0, $9LQqs$responsiveDimensionValue)(props.gap, matchedBreakpoints) : undefined
|
|
200
|
+
};
|
|
201
|
+
return /*#__PURE__*/ (0, $9LQqs$react).createElement("div", {
|
|
202
|
+
...(0, $9LQqs$filterDOMProps)(otherProps),
|
|
203
|
+
...styleProps,
|
|
204
|
+
className: (0, $9LQqs$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($01dd1839b5376a46$exports))), "flex-container", styleProps.className),
|
|
205
|
+
ref: domRef
|
|
206
|
+
}, /*#__PURE__*/ (0, $9LQqs$react).createElement("div", {
|
|
207
|
+
className: (0, $9LQqs$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($01dd1839b5376a46$exports))), "flex", "flex-gap"),
|
|
208
|
+
style: style
|
|
209
|
+
}, children));
|
|
210
|
+
}
|
|
211
|
+
// If no gaps, or native support exists, then we only need to render a single div.
|
|
185
212
|
let style = {
|
|
186
213
|
...styleProps.style,
|
|
187
214
|
...flexStyle.style
|
|
@@ -210,6 +237,27 @@ function $884c64d19340d345$var$Flex(props, ref) {
|
|
|
210
237
|
if (typeof value === "boolean") return value ? "wrap" : "nowrap";
|
|
211
238
|
return value;
|
|
212
239
|
}
|
|
240
|
+
// Original licensing for the following method can be found in the
|
|
241
|
+
// NOTICE file in the root directory of this source tree.
|
|
242
|
+
// See https://github.com/Modernizr/Modernizr/blob/7efb9d0edd66815fb115fdce95fabaf019ce8db5/feature-detects/css/flexgap.js
|
|
243
|
+
let $884c64d19340d345$var$_isFlexGapSupported = null;
|
|
244
|
+
function $884c64d19340d345$var$isFlexGapSupported() {
|
|
245
|
+
if ($884c64d19340d345$var$_isFlexGapSupported != null) return $884c64d19340d345$var$_isFlexGapSupported;
|
|
246
|
+
if (typeof document === "undefined") return false;
|
|
247
|
+
// create flex container with row-gap set
|
|
248
|
+
var flex = document.createElement("div");
|
|
249
|
+
flex.style.display = "flex";
|
|
250
|
+
flex.style.flexDirection = "column";
|
|
251
|
+
flex.style.rowGap = "1px";
|
|
252
|
+
// create two, elements inside it
|
|
253
|
+
flex.appendChild(document.createElement("div"));
|
|
254
|
+
flex.appendChild(document.createElement("div"));
|
|
255
|
+
// append to the DOM (needed to obtain scrollHeight)
|
|
256
|
+
document.body.appendChild(flex);
|
|
257
|
+
$884c64d19340d345$var$_isFlexGapSupported = flex.scrollHeight === 1; // flex container should be 1px high from the row-gap
|
|
258
|
+
flex.parentNode.removeChild(flex);
|
|
259
|
+
return $884c64d19340d345$var$_isFlexGapSupported;
|
|
260
|
+
}
|
|
213
261
|
/**
|
|
214
262
|
* A layout container using flexbox. Provides Spectrum dimension values, and supports the gap
|
|
215
263
|
* property to define consistent spacing between items.
|
package/dist/main.js
CHANGED
|
@@ -2,6 +2,7 @@ require("./main.css");
|
|
|
2
2
|
var $aBO7d$reactspectrumutils = require("@react-spectrum/utils");
|
|
3
3
|
var $aBO7d$reactariautils = require("@react-aria/utils");
|
|
4
4
|
var $aBO7d$react = require("react");
|
|
5
|
+
var $aBO7d$reactariassr = require("@react-aria/ssr");
|
|
5
6
|
|
|
6
7
|
function $parcel$export(e, n, v, s) {
|
|
7
8
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
@@ -157,6 +158,7 @@ $12be0ef8be5abc46$export$69d7a39fa31a000b = `NW91UW_flex-container`;
|
|
|
157
158
|
$12be0ef8be5abc46$export$31a9da8b58047a44 = `NW91UW_flex-gap`;
|
|
158
159
|
|
|
159
160
|
|
|
161
|
+
|
|
160
162
|
const $a2ef5497697e8437$var$flexStyleProps = {
|
|
161
163
|
direction: [
|
|
162
164
|
"flexDirection",
|
|
@@ -188,6 +190,31 @@ function $a2ef5497697e8437$var$Flex(props, ref) {
|
|
|
188
190
|
let { styleProps: styleProps } = (0, $aBO7d$reactspectrumutils.useStyleProps)(otherProps);
|
|
189
191
|
let { styleProps: flexStyle } = (0, $aBO7d$reactspectrumutils.useStyleProps)(otherProps, $a2ef5497697e8437$var$flexStyleProps);
|
|
190
192
|
let domRef = (0, $aBO7d$reactspectrumutils.useDOMRef)(ref);
|
|
193
|
+
let isSSR = (0, $aBO7d$reactariassr.useIsSSR)();
|
|
194
|
+
// If a gap property is specified, and there is no native support or we're in SSR, use a shim.
|
|
195
|
+
// Two divs are required for this: the outer one contains most style properties, and the inner
|
|
196
|
+
// one is the flex container. Each item inside the flex container gets a margin around it based
|
|
197
|
+
// on the gap, and the flex container has a negative margin to counteract this. The outer container
|
|
198
|
+
// is necessary to allow nesting of flex containers with gaps, so that the inner CSS variable doesn't
|
|
199
|
+
// override the outer one.
|
|
200
|
+
if ((props.gap || props.rowGap || props.columnGap) && (isSSR || !$a2ef5497697e8437$var$isFlexGapSupported())) {
|
|
201
|
+
let style = {
|
|
202
|
+
...flexStyle.style,
|
|
203
|
+
"--column-gap": props.columnGap != null ? (0, $aBO7d$reactspectrumutils.responsiveDimensionValue)(props.columnGap, matchedBreakpoints) : undefined,
|
|
204
|
+
"--row-gap": props.rowGap != null ? (0, $aBO7d$reactspectrumutils.responsiveDimensionValue)(props.rowGap, matchedBreakpoints) : undefined,
|
|
205
|
+
"--gap": props.gap != null ? (0, $aBO7d$reactspectrumutils.responsiveDimensionValue)(props.gap, matchedBreakpoints) : undefined
|
|
206
|
+
};
|
|
207
|
+
return /*#__PURE__*/ (0, ($parcel$interopDefault($aBO7d$react))).createElement("div", {
|
|
208
|
+
...(0, $aBO7d$reactariautils.filterDOMProps)(otherProps),
|
|
209
|
+
...styleProps,
|
|
210
|
+
className: (0, $aBO7d$reactspectrumutils.classNames)((0, (/*@__PURE__*/$parcel$interopDefault($12be0ef8be5abc46$exports))), "flex-container", styleProps.className),
|
|
211
|
+
ref: domRef
|
|
212
|
+
}, /*#__PURE__*/ (0, ($parcel$interopDefault($aBO7d$react))).createElement("div", {
|
|
213
|
+
className: (0, $aBO7d$reactspectrumutils.classNames)((0, (/*@__PURE__*/$parcel$interopDefault($12be0ef8be5abc46$exports))), "flex", "flex-gap"),
|
|
214
|
+
style: style
|
|
215
|
+
}, children));
|
|
216
|
+
}
|
|
217
|
+
// If no gaps, or native support exists, then we only need to render a single div.
|
|
191
218
|
let style = {
|
|
192
219
|
...styleProps.style,
|
|
193
220
|
...flexStyle.style
|
|
@@ -216,6 +243,27 @@ function $a2ef5497697e8437$var$Flex(props, ref) {
|
|
|
216
243
|
if (typeof value === "boolean") return value ? "wrap" : "nowrap";
|
|
217
244
|
return value;
|
|
218
245
|
}
|
|
246
|
+
// Original licensing for the following method can be found in the
|
|
247
|
+
// NOTICE file in the root directory of this source tree.
|
|
248
|
+
// See https://github.com/Modernizr/Modernizr/blob/7efb9d0edd66815fb115fdce95fabaf019ce8db5/feature-detects/css/flexgap.js
|
|
249
|
+
let $a2ef5497697e8437$var$_isFlexGapSupported = null;
|
|
250
|
+
function $a2ef5497697e8437$var$isFlexGapSupported() {
|
|
251
|
+
if ($a2ef5497697e8437$var$_isFlexGapSupported != null) return $a2ef5497697e8437$var$_isFlexGapSupported;
|
|
252
|
+
if (typeof document === "undefined") return false;
|
|
253
|
+
// create flex container with row-gap set
|
|
254
|
+
var flex = document.createElement("div");
|
|
255
|
+
flex.style.display = "flex";
|
|
256
|
+
flex.style.flexDirection = "column";
|
|
257
|
+
flex.style.rowGap = "1px";
|
|
258
|
+
// create two, elements inside it
|
|
259
|
+
flex.appendChild(document.createElement("div"));
|
|
260
|
+
flex.appendChild(document.createElement("div"));
|
|
261
|
+
// append to the DOM (needed to obtain scrollHeight)
|
|
262
|
+
document.body.appendChild(flex);
|
|
263
|
+
$a2ef5497697e8437$var$_isFlexGapSupported = flex.scrollHeight === 1; // flex container should be 1px high from the row-gap
|
|
264
|
+
flex.parentNode.removeChild(flex);
|
|
265
|
+
return $a2ef5497697e8437$var$_isFlexGapSupported;
|
|
266
|
+
}
|
|
219
267
|
/**
|
|
220
268
|
* A layout container using flexbox. Provides Spectrum dimension values, and supports the gap
|
|
221
269
|
* property to define consistent spacing between items.
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,0CAA0C;ACZ1C;;;;;;;;;;CAUC;;;AAeD,MAAM,uCAAgC;IACpC,GAAG,CAAA,GAAA,wCAAa,CAAC;IACjB,UAAU;QAAC;QAAgB,CAAA,GAAA,0CAAe;KAAE;IAC5C,aAAa;QAAC;QAAmB;KAAmB;IACpD,UAAU;QAAC;QAAgB;KAAmB;IAC9C,OAAO;QAAC;QAAqB;KAAuB;IACpD,SAAS;QAAC;QAAuB;KAAkB;IACnD,MAAM;QAAC;QAAoB;KAAkB;IAC7C,KAAK;QAAC;QAAO,CAAA,GAAA,wCAAa;KAAE;IAC5B,QAAQ;QAAC;QAAU,CAAA,GAAA,wCAAa;KAAE;IAClC,WAAW;QAAC;QAAa,CAAA,GAAA,wCAAa;KAAE;IACxC,cAAc;QAAC;QAAg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EAAE,CAAA,GAAA,gEAAK,GAAG,QAAQ,WAAW;QAAY,OAAO;QAAO,KAAK;OAClH;AAGP;AAEA;;;CAGC,GACD,SAAS,qCAAe,KAAK;IAC3B,IAAI,UAAU,SACZ,OAAO;IAGT,IAAI,UAAU,OACZ,OAAO;IAGT,OAAO;AACT;AAEA;;CAEC,GACD,SAAS,oCAAc,KAAK;IAC1B,IAAI,OAAO,UAAU,WACnB,OAAO,QAAQ,SAAS;IAG1B,OAAO;AACT;AAEA;;;CAGC,GACD,MAAM,0DAAQ,CAAA,GAAA,uBAAS,EAAE;;","sources":["packages/@react-spectrum/layout/src/index.ts","packages/@react-spectrum/layout/src/Grid.tsx","packages/@react-spectrum/layout/src/Flex.tsx","packages/@react-spectrum/layout/src/flex-gap.css"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n/// <reference types=\"css-module-types\" />\n\nexport {repeat, minmax, fitContent, Grid} from './Grid';\nexport {Flex} from './Flex';\nexport type {DimensionValue} from '@react-types/shared';\nexport type {FlexProps, GridProps} from '@react-types/layout';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n baseStyleProps,\n dimensionValue,\n passthroughStyle,\n StyleHandlers,\n useDOMRef,\n useStyleProps\n} from '@react-spectrum/utils';\nimport {DimensionValue, DOMRef} from '@react-types/shared';\nimport {filterDOMProps} from '@react-aria/utils';\nimport {GridProps} from '@react-types/layout';\nimport React, {forwardRef} from 'react';\n\nconst gridStyleProps: StyleHandlers = {\n ...baseStyleProps,\n autoFlow: ['gridAutoFlow', passthroughStyle],\n autoColumns: ['gridAutoColumns', gridDimensionValue],\n autoRows: ['gridAutoRows', gridDimensionValue],\n areas: ['gridTemplateAreas', gridTemplateAreasValue],\n columns: ['gridTemplateColumns', gridTemplateValue],\n rows: ['gridTemplateRows', gridTemplateValue],\n gap: ['gap', dimensionValue],\n rowGap: ['rowGap', dimensionValue],\n columnGap: ['columnGap', dimensionValue],\n justifyItems: ['justifyItems', passthroughStyle],\n justifyContent: ['justifyContent', passthroughStyle],\n alignItems: ['alignItems', passthroughStyle],\n alignContent: ['alignContent', passthroughStyle]\n};\n\nfunction Grid(props: GridProps, ref: DOMRef<HTMLDivElement>) {\n let {\n children,\n ...otherProps\n } = props;\n let {styleProps} = useStyleProps(otherProps, gridStyleProps);\n styleProps.style.display = 'grid'; // inline-grid?\n let domRef = useDOMRef(ref);\n\n return (\n <div {...filterDOMProps(otherProps)} {...styleProps} ref={domRef}>\n {children}\n </div>\n );\n}\n\n/**\n * Can be used to make a repeating fragment of the columns or rows list.\n * See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/repeat).\n * @param count - The number of times to repeat the fragment.\n * @param repeat - The fragment to repeat.\n */\nexport function repeat(count: number | 'auto-fill' | 'auto-fit', repeat: DimensionValue | DimensionValue[]): string {\n return `repeat(${count}, ${gridTemplateValue(repeat)})`;\n}\n\n/**\n * Defines a size range greater than or equal to min and less than or equal to max.\n * See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/minmax).\n * @param min - The minimum size.\n * @param max - The maximum size.\n */\nexport function minmax(min: DimensionValue, max: DimensionValue): string {\n return `minmax(${gridDimensionValue(min)}, ${gridDimensionValue(max)})`;\n}\n\n/**\n * Clamps a given size to an available size.\n * See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/fit-content).\n * @param dimension - The size to clamp.\n */\nexport function fitContent(dimension: DimensionValue): string {\n return `fit-content(${gridDimensionValue(dimension)})`;\n}\n\nfunction gridTemplateAreasValue(value) {\n return value.map(v => `\"${v}\"`).join('\\n');\n}\n\nfunction gridDimensionValue(value) {\n if (/^max-content|min-content|minmax|auto|fit-content|repeat|subgrid/.test(value)) {\n return value;\n }\n\n return dimensionValue(value);\n}\n\nfunction gridTemplateValue(value) {\n if (Array.isArray(value)) {\n return value.map(gridDimensionValue).join(' ');\n }\n\n return gridDimensionValue(value);\n}\n\n/**\n * A layout container using CSS grid. Supports Spectrum dimensions as values to\n * ensure consistent and adaptive sizing and spacing.\n */\nconst _Grid = forwardRef(Grid);\nexport {_Grid as Grid};\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {classNames, passthroughStyle, responsiveDimensionValue, StyleHandlers, useBreakpoint, useDOMRef, useStyleProps} from '@react-spectrum/utils';\nimport {DOMRef} from '@react-types/shared';\nimport {filterDOMProps} from '@react-aria/utils';\nimport {FlexProps} from '@react-types/layout';\nimport React, {forwardRef} from 'react';\nimport styles from './flex-gap.css';\n\nconst flexStyleProps: StyleHandlers = {\n direction: ['flexDirection', passthroughStyle],\n wrap: ['flexWrap', flexWrapValue],\n justifyContent: ['justifyContent', flexAlignValue],\n alignItems: ['alignItems', flexAlignValue],\n alignContent: ['alignContent', flexAlignValue]\n};\n\nfunction Flex(props: FlexProps, ref: DOMRef<HTMLDivElement>) {\n let {\n children,\n ...otherProps\n } = props;\n let breakpointProvider = useBreakpoint();\n let matchedBreakpoints = breakpointProvider?.matchedBreakpoints || ['base'];\n let {styleProps} = useStyleProps(otherProps);\n let {styleProps: flexStyle} = useStyleProps(otherProps, flexStyleProps);\n let domRef = useDOMRef(ref);\n\n let style = {\n ...styleProps.style,\n ...flexStyle.style\n };\n\n if (props.gap != null) {\n style.gap = responsiveDimensionValue(props.gap, matchedBreakpoints);\n }\n\n if (props.columnGap != null) {\n style.columnGap = responsiveDimensionValue(props.columnGap, matchedBreakpoints);\n }\n\n if (props.rowGap != null) {\n style.rowGap = responsiveDimensionValue(props.rowGap, matchedBreakpoints);\n }\n\n return (\n <div {...filterDOMProps(otherProps)} className={classNames(styles, 'flex', styleProps.className)} style={style} ref={domRef}>\n {children}\n </div>\n );\n}\n\n/**\n * Normalize 'start' and 'end' alignment values to 'flex-start' and 'flex-end'\n * in flex containers for browser compatibility.\n */\nfunction flexAlignValue(value) {\n if (value === 'start') {\n return 'flex-start';\n }\n\n if (value === 'end') {\n return 'flex-end';\n }\n\n return value;\n}\n\n/**\n * Takes a boolean and translates it to flex wrap or nowrap.\n */\nfunction flexWrapValue(value) {\n if (typeof value === 'boolean') {\n return value ? 'wrap' : 'nowrap';\n }\n\n return value;\n}\n\n/**\n * A layout container using flexbox. Provides Spectrum dimension values, and supports the gap\n * property to define consistent spacing between items.\n */\nconst _Flex = forwardRef(Flex);\nexport {_Flex as Flex};\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n.flex-container {\n /* this is necessary so that the inner margins don't affect anything outside */\n display: flex;\n}\n\n.flex {\n display: flex;\n}\n\n.flex-gap {\n --gap: 0px;\n --column-gap: var(--gap);\n --row-gap: var(--gap);\n\n /* apply a negative margin to counteract the margin on each item at the edges */\n margin: calc(var(--row-gap) / -2) calc(var(--column-gap) / -2);\n\n /* increase the width and height to account for this margin */\n /* Add 1px to fix rounding error in Safari (╯°□°)╯︵ ┻━┻ */\n width: calc(100% + calc(var(--column-gap) + 1px));\n height: calc(100% + var(--row-gap));\n}\n\n/* If the selector was .flex-gap > *, it wouldn't override when components have a margin 0 specified by a single\n * class selector, specificity is equal. Both are one class. Neither > nor * contribute to specificity.\n * We need to make it more specific, so we raise it by 1 class.\n */\n.flex-container .flex-gap > * {\n /* apply half of the gap to each side of every item */\n margin: calc(var(--row-gap) / 2) calc(var(--column-gap) / 2);\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,0CAA0C;ACZ1C;;;;;;;;;;CAUC;;;AAeD,MAAM,uCAAgC;IACpC,GAAG,CAAA,GAAA,wCAAa,CAAC;IACjB,UAAU;QAAC;QAAgB,CAAA,GAAA,0CAAe;KAAE;IAC5C,aAAa;QAAC;QAAmB;KAAmB;IACpD,UAAU;QAAC;QAAgB;KAAmB;IAC9C,OAAO;QAAC;QAAqB;KAAuB;IACpD,SAAS;QAAC;QAAuB;KAAkB;IACnD,MAAM;QAAC;QAAoB;KAAkB;IAC7C,KAAK;QAAC;QAAO,CAAA,GAAA,wCAAa;KAAE;IAC5B,QAAQ;QAAC;QAAU,CAAA,GAAA,wCAAa;KAAE;IAClC,WAAW;QAAC;QAAa,CAAA,GAAA,wCAAa;KAAE;IACxC,cAAc;QAAC;QAAgB,CAAA,GAAA,0CAAe;KAAE;IAChD,gBAAgB;QAAC;QAAkB,CAAA,GAAA,0CAAe;KAAE;IACpD,YAAY;QAAC;QAAc,CAAA,GAA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BAAgB;IAC3B,KAAK,MAAM,SAAS;IAEpB,iCAAiC;IACjC,KAAK,YAAY,SAAS,cAAc;IACxC,KAAK,YAAY,SAAS,cAAc;IAExC,oDAAoD;IACpD,SAAS,KAAK,YAAY;IAC1B,4CAAsB,KAAK,iBAAiB,GAAG,qDAAqD;IACpG,KAAK,WAAW,YAAY;IAE5B,OAAO;AACT;AAEA;;;CAGC,GACD,MAAM,0DAAQ,CAAA,GAAA,uBAAS,EAAE;;","sources":["packages/@react-spectrum/layout/src/index.ts","packages/@react-spectrum/layout/src/Grid.tsx","packages/@react-spectrum/layout/src/Flex.tsx","packages/@react-spectrum/layout/src/flex-gap.css"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n/// <reference types=\"css-module-types\" />\n\nexport {repeat, minmax, fitContent, Grid} from './Grid';\nexport {Flex} from './Flex';\nexport type {DimensionValue} from '@react-types/shared';\nexport type {FlexProps, GridProps} from '@react-types/layout';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n baseStyleProps,\n dimensionValue,\n passthroughStyle,\n StyleHandlers,\n useDOMRef,\n useStyleProps\n} from '@react-spectrum/utils';\nimport {DimensionValue, DOMRef} from '@react-types/shared';\nimport {filterDOMProps} from '@react-aria/utils';\nimport {GridProps} from '@react-types/layout';\nimport React, {forwardRef} from 'react';\n\nconst gridStyleProps: StyleHandlers = {\n ...baseStyleProps,\n autoFlow: ['gridAutoFlow', passthroughStyle],\n autoColumns: ['gridAutoColumns', gridDimensionValue],\n autoRows: ['gridAutoRows', gridDimensionValue],\n areas: ['gridTemplateAreas', gridTemplateAreasValue],\n columns: ['gridTemplateColumns', gridTemplateValue],\n rows: ['gridTemplateRows', gridTemplateValue],\n gap: ['gap', dimensionValue],\n rowGap: ['rowGap', dimensionValue],\n columnGap: ['columnGap', dimensionValue],\n justifyItems: ['justifyItems', passthroughStyle],\n justifyContent: ['justifyContent', passthroughStyle],\n alignItems: ['alignItems', passthroughStyle],\n alignContent: ['alignContent', passthroughStyle]\n};\n\nfunction Grid(props: GridProps, ref: DOMRef<HTMLDivElement>) {\n let {\n children,\n ...otherProps\n } = props;\n let {styleProps} = useStyleProps(otherProps, gridStyleProps);\n styleProps.style.display = 'grid'; // inline-grid?\n let domRef = useDOMRef(ref);\n\n return (\n <div {...filterDOMProps(otherProps)} {...styleProps} ref={domRef}>\n {children}\n </div>\n );\n}\n\n/**\n * Can be used to make a repeating fragment of the columns or rows list.\n * See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/repeat).\n * @param count - The number of times to repeat the fragment.\n * @param repeat - The fragment to repeat.\n */\nexport function repeat(count: number | 'auto-fill' | 'auto-fit', repeat: DimensionValue | DimensionValue[]): string {\n return `repeat(${count}, ${gridTemplateValue(repeat)})`;\n}\n\n/**\n * Defines a size range greater than or equal to min and less than or equal to max.\n * See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/minmax).\n * @param min - The minimum size.\n * @param max - The maximum size.\n */\nexport function minmax(min: DimensionValue, max: DimensionValue): string {\n return `minmax(${gridDimensionValue(min)}, ${gridDimensionValue(max)})`;\n}\n\n/**\n * Clamps a given size to an available size.\n * See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/fit-content).\n * @param dimension - The size to clamp.\n */\nexport function fitContent(dimension: DimensionValue): string {\n return `fit-content(${gridDimensionValue(dimension)})`;\n}\n\nfunction gridTemplateAreasValue(value) {\n return value.map(v => `\"${v}\"`).join('\\n');\n}\n\nfunction gridDimensionValue(value) {\n if (/^max-content|min-content|minmax|auto|fit-content|repeat|subgrid/.test(value)) {\n return value;\n }\n\n return dimensionValue(value);\n}\n\nfunction gridTemplateValue(value) {\n if (Array.isArray(value)) {\n return value.map(gridDimensionValue).join(' ');\n }\n\n return gridDimensionValue(value);\n}\n\n/**\n * A layout container using CSS grid. Supports Spectrum dimensions as values to\n * ensure consistent and adaptive sizing and spacing.\n */\nconst _Grid = forwardRef(Grid);\nexport {_Grid as Grid};\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {classNames, passthroughStyle, responsiveDimensionValue, StyleHandlers, useBreakpoint, useDOMRef, useStyleProps} from '@react-spectrum/utils';\nimport {DOMRef} from '@react-types/shared';\nimport {filterDOMProps} from '@react-aria/utils';\nimport {FlexProps} from '@react-types/layout';\nimport React, {forwardRef} from 'react';\nimport styles from './flex-gap.css';\nimport {useIsSSR} from '@react-aria/ssr';\n\nconst flexStyleProps: StyleHandlers = {\n direction: ['flexDirection', passthroughStyle],\n wrap: ['flexWrap', flexWrapValue],\n justifyContent: ['justifyContent', flexAlignValue],\n alignItems: ['alignItems', flexAlignValue],\n alignContent: ['alignContent', flexAlignValue]\n};\n\nfunction Flex(props: FlexProps, ref: DOMRef<HTMLDivElement>) {\n let {\n children,\n ...otherProps\n } = props;\n let breakpointProvider = useBreakpoint();\n let matchedBreakpoints = breakpointProvider?.matchedBreakpoints || ['base'];\n let {styleProps} = useStyleProps(otherProps);\n let {styleProps: flexStyle} = useStyleProps(otherProps, flexStyleProps);\n let domRef = useDOMRef(ref);\n let isSSR = useIsSSR();\n\n // If a gap property is specified, and there is no native support or we're in SSR, use a shim.\n // Two divs are required for this: the outer one contains most style properties, and the inner\n // one is the flex container. Each item inside the flex container gets a margin around it based\n // on the gap, and the flex container has a negative margin to counteract this. The outer container\n // is necessary to allow nesting of flex containers with gaps, so that the inner CSS variable doesn't\n // override the outer one.\n if ((props.gap || props.rowGap || props.columnGap) && (isSSR || !isFlexGapSupported())) {\n let style = {\n ...flexStyle.style,\n '--column-gap': props.columnGap != null ? responsiveDimensionValue(props.columnGap, matchedBreakpoints) : undefined,\n '--row-gap': props.rowGap != null ? responsiveDimensionValue(props.rowGap, matchedBreakpoints) : undefined,\n '--gap': props.gap != null ? responsiveDimensionValue(props.gap, matchedBreakpoints) : undefined\n };\n\n return (\n <div {...filterDOMProps(otherProps)} {...styleProps} className={classNames(styles, 'flex-container', styleProps.className)} ref={domRef}>\n <div className={classNames(styles, 'flex', 'flex-gap')} style={style}>\n {children}\n </div>\n </div>\n );\n }\n\n // If no gaps, or native support exists, then we only need to render a single div.\n let style = {\n ...styleProps.style,\n ...flexStyle.style\n };\n\n if (props.gap != null) {\n style.gap = responsiveDimensionValue(props.gap, matchedBreakpoints);\n }\n\n if (props.columnGap != null) {\n style.columnGap = responsiveDimensionValue(props.columnGap, matchedBreakpoints);\n }\n\n if (props.rowGap != null) {\n style.rowGap = responsiveDimensionValue(props.rowGap, matchedBreakpoints);\n }\n\n return (\n <div {...filterDOMProps(otherProps)} className={classNames(styles, 'flex', styleProps.className)} style={style} ref={domRef}>\n {children}\n </div>\n );\n}\n\n/**\n * Normalize 'start' and 'end' alignment values to 'flex-start' and 'flex-end'\n * in flex containers for browser compatibility.\n */\nfunction flexAlignValue(value) {\n if (value === 'start') {\n return 'flex-start';\n }\n\n if (value === 'end') {\n return 'flex-end';\n }\n\n return value;\n}\n\n/**\n * Takes a boolean and translates it to flex wrap or nowrap.\n */\nfunction flexWrapValue(value) {\n if (typeof value === 'boolean') {\n return value ? 'wrap' : 'nowrap';\n }\n\n return value;\n}\n\n\n// Original licensing for the following method can be found in the\n// NOTICE file in the root directory of this source tree.\n// See https://github.com/Modernizr/Modernizr/blob/7efb9d0edd66815fb115fdce95fabaf019ce8db5/feature-detects/css/flexgap.js\n\nlet _isFlexGapSupported = null;\nfunction isFlexGapSupported() {\n if (_isFlexGapSupported != null) {\n return _isFlexGapSupported;\n }\n\n if (typeof document === 'undefined') {\n return false;\n }\n\n // create flex container with row-gap set\n var flex = document.createElement('div');\n flex.style.display = 'flex';\n flex.style.flexDirection = 'column';\n flex.style.rowGap = '1px';\n\n // create two, elements inside it\n flex.appendChild(document.createElement('div'));\n flex.appendChild(document.createElement('div'));\n\n // append to the DOM (needed to obtain scrollHeight)\n document.body.appendChild(flex);\n _isFlexGapSupported = flex.scrollHeight === 1; // flex container should be 1px high from the row-gap\n flex.parentNode.removeChild(flex);\n\n return _isFlexGapSupported;\n}\n\n/**\n * A layout container using flexbox. Provides Spectrum dimension values, and supports the gap\n * property to define consistent spacing between items.\n */\nconst _Flex = forwardRef(Flex);\nexport {_Flex as Flex};\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n.flex-container {\n /* this is necessary so that the inner margins don't affect anything outside */\n display: flex;\n}\n\n.flex {\n display: flex;\n}\n\n.flex-gap {\n --gap: 0px;\n --column-gap: var(--gap);\n --row-gap: var(--gap);\n\n /* apply a negative margin to counteract the margin on each item at the edges */\n margin: calc(var(--row-gap) / -2) calc(var(--column-gap) / -2);\n\n /* increase the width and height to account for this margin */\n /* Add 1px to fix rounding error in Safari (╯°□°)╯︵ ┻━┻ */\n width: calc(100% + calc(var(--column-gap) + 1px));\n height: calc(100% + var(--row-gap));\n}\n\n/* If the selector was .flex-gap > *, it wouldn't override when components have a margin 0 specified by a single\n * class selector, specificity is equal. Both are one class. Neither > nor * contribute to specificity.\n * We need to make it more specific, so we raise it by 1 class.\n */\n.flex-container .flex-gap > * {\n /* apply half of the gap to each side of every item */\n margin: calc(var(--row-gap) / 2) calc(var(--column-gap) / 2);\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -2,6 +2,7 @@ import "./main.css";
|
|
|
2
2
|
import {baseStyleProps as $9LQqs$baseStyleProps, passthroughStyle as $9LQqs$passthroughStyle, dimensionValue as $9LQqs$dimensionValue, useStyleProps as $9LQqs$useStyleProps, useDOMRef as $9LQqs$useDOMRef, useBreakpoint as $9LQqs$useBreakpoint, responsiveDimensionValue as $9LQqs$responsiveDimensionValue, classNames as $9LQqs$classNames} from "@react-spectrum/utils";
|
|
3
3
|
import {filterDOMProps as $9LQqs$filterDOMProps} from "@react-aria/utils";
|
|
4
4
|
import $9LQqs$react, {forwardRef as $9LQqs$forwardRef} from "react";
|
|
5
|
+
import {useIsSSR as $9LQqs$useIsSSR} from "@react-aria/ssr";
|
|
5
6
|
|
|
6
7
|
function $parcel$interopDefault(a) {
|
|
7
8
|
return a && a.__esModule ? a.default : a;
|
|
@@ -151,6 +152,7 @@ $01dd1839b5376a46$export$69d7a39fa31a000b = `NW91UW_flex-container`;
|
|
|
151
152
|
$01dd1839b5376a46$export$31a9da8b58047a44 = `NW91UW_flex-gap`;
|
|
152
153
|
|
|
153
154
|
|
|
155
|
+
|
|
154
156
|
const $884c64d19340d345$var$flexStyleProps = {
|
|
155
157
|
direction: [
|
|
156
158
|
"flexDirection",
|
|
@@ -182,6 +184,31 @@ function $884c64d19340d345$var$Flex(props, ref) {
|
|
|
182
184
|
let { styleProps: styleProps } = (0, $9LQqs$useStyleProps)(otherProps);
|
|
183
185
|
let { styleProps: flexStyle } = (0, $9LQqs$useStyleProps)(otherProps, $884c64d19340d345$var$flexStyleProps);
|
|
184
186
|
let domRef = (0, $9LQqs$useDOMRef)(ref);
|
|
187
|
+
let isSSR = (0, $9LQqs$useIsSSR)();
|
|
188
|
+
// If a gap property is specified, and there is no native support or we're in SSR, use a shim.
|
|
189
|
+
// Two divs are required for this: the outer one contains most style properties, and the inner
|
|
190
|
+
// one is the flex container. Each item inside the flex container gets a margin around it based
|
|
191
|
+
// on the gap, and the flex container has a negative margin to counteract this. The outer container
|
|
192
|
+
// is necessary to allow nesting of flex containers with gaps, so that the inner CSS variable doesn't
|
|
193
|
+
// override the outer one.
|
|
194
|
+
if ((props.gap || props.rowGap || props.columnGap) && (isSSR || !$884c64d19340d345$var$isFlexGapSupported())) {
|
|
195
|
+
let style = {
|
|
196
|
+
...flexStyle.style,
|
|
197
|
+
"--column-gap": props.columnGap != null ? (0, $9LQqs$responsiveDimensionValue)(props.columnGap, matchedBreakpoints) : undefined,
|
|
198
|
+
"--row-gap": props.rowGap != null ? (0, $9LQqs$responsiveDimensionValue)(props.rowGap, matchedBreakpoints) : undefined,
|
|
199
|
+
"--gap": props.gap != null ? (0, $9LQqs$responsiveDimensionValue)(props.gap, matchedBreakpoints) : undefined
|
|
200
|
+
};
|
|
201
|
+
return /*#__PURE__*/ (0, $9LQqs$react).createElement("div", {
|
|
202
|
+
...(0, $9LQqs$filterDOMProps)(otherProps),
|
|
203
|
+
...styleProps,
|
|
204
|
+
className: (0, $9LQqs$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($01dd1839b5376a46$exports))), "flex-container", styleProps.className),
|
|
205
|
+
ref: domRef
|
|
206
|
+
}, /*#__PURE__*/ (0, $9LQqs$react).createElement("div", {
|
|
207
|
+
className: (0, $9LQqs$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($01dd1839b5376a46$exports))), "flex", "flex-gap"),
|
|
208
|
+
style: style
|
|
209
|
+
}, children));
|
|
210
|
+
}
|
|
211
|
+
// If no gaps, or native support exists, then we only need to render a single div.
|
|
185
212
|
let style = {
|
|
186
213
|
...styleProps.style,
|
|
187
214
|
...flexStyle.style
|
|
@@ -210,6 +237,27 @@ function $884c64d19340d345$var$Flex(props, ref) {
|
|
|
210
237
|
if (typeof value === "boolean") return value ? "wrap" : "nowrap";
|
|
211
238
|
return value;
|
|
212
239
|
}
|
|
240
|
+
// Original licensing for the following method can be found in the
|
|
241
|
+
// NOTICE file in the root directory of this source tree.
|
|
242
|
+
// See https://github.com/Modernizr/Modernizr/blob/7efb9d0edd66815fb115fdce95fabaf019ce8db5/feature-detects/css/flexgap.js
|
|
243
|
+
let $884c64d19340d345$var$_isFlexGapSupported = null;
|
|
244
|
+
function $884c64d19340d345$var$isFlexGapSupported() {
|
|
245
|
+
if ($884c64d19340d345$var$_isFlexGapSupported != null) return $884c64d19340d345$var$_isFlexGapSupported;
|
|
246
|
+
if (typeof document === "undefined") return false;
|
|
247
|
+
// create flex container with row-gap set
|
|
248
|
+
var flex = document.createElement("div");
|
|
249
|
+
flex.style.display = "flex";
|
|
250
|
+
flex.style.flexDirection = "column";
|
|
251
|
+
flex.style.rowGap = "1px";
|
|
252
|
+
// create two, elements inside it
|
|
253
|
+
flex.appendChild(document.createElement("div"));
|
|
254
|
+
flex.appendChild(document.createElement("div"));
|
|
255
|
+
// append to the DOM (needed to obtain scrollHeight)
|
|
256
|
+
document.body.appendChild(flex);
|
|
257
|
+
$884c64d19340d345$var$_isFlexGapSupported = flex.scrollHeight === 1; // flex container should be 1px high from the row-gap
|
|
258
|
+
flex.parentNode.removeChild(flex);
|
|
259
|
+
return $884c64d19340d345$var$_isFlexGapSupported;
|
|
260
|
+
}
|
|
213
261
|
/**
|
|
214
262
|
* A layout container using flexbox. Provides Spectrum dimension values, and supports the gap
|
|
215
263
|
* property to define consistent spacing between items.
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,0CAA0C;ACZ1C;;;;;;;;;;CAUC;;;AAeD,MAAM,uCAAgC;IACpC,GAAG,CAAA,GAAA,qBAAa,CAAC;IACjB,UAAU;QAAC;QAAgB,CAAA,GAAA,uBAAe;KAAE;IAC5C,aAAa;QAAC;QAAmB;KAAmB;IACpD,UAAU;QAAC;QAAgB;KAAmB;IAC9C,OAAO;QAAC;QAAqB;KAAuB;IACpD,SAAS;QAAC;QAAuB;KAAkB;IACnD,MAAM;QAAC;QAAoB;KAAkB;IAC7C,KAAK;QAAC;QAAO,CAAA,GAAA,qBAAa;KAAE;IAC5B,QAAQ;QAAC;QAAU,CAAA,GAAA,qBAAa;KAAE;IAClC,WAAW;QAAC;QAAa,CAAA,GAAA,qBAAa;KAAE;IACxC,cAAc;QAAC;QAAgB,CAAA,GAAA,uBAAe;KAAE;IAChD,gBAAgB;QAAC;QAAkB,CAAA,GAAA,uBAAe;KAAE;IACpD,YAAY;QAAC;QAAc,CAAA,GAAA,uBAAe;KAAE;IAC5C,cAAc;QAAC;QAAgB,CAAA,GAAA,uBAAe;KAAE;AAClD;AAEA,SAAS,2BAAK,KAAgB,EAAE,GAA2B;IACzD,IAAI,YACF,QAAQ,EACR,GAAG,YACJ,GAAG;IACJ,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,oBAAY,EAAE,YAAY;IAC7C,WAAW,MAAM,UAAU,QAAQ,eAAe;IAClD,IAAI,SAAS,CAAA,GAAA,gBAAQ,EAAE;IAEvB,qBACE,gCAAC;QAAK,GAAG,CAAA,GAAA,qBAAa,EAAE,WAAW;QAAG,GAAG,UAAU;QAAE,KAAK;OACvD;AAGP;AAQO,SAAS,0CAAO,KAAwC,EAAE,MAAyC;IACxG,OA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BAAA,gCAAA,KAAA,IAAA,mBAAoB,kBAAiB,KAAK;QAAC;KAAO;IAC3E,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,oBAAY,EAAE;IACjC,IAAI,EAAC,YAAY,SAAS,EAAC,GAAG,CAAA,GAAA,oBAAY,EAAE,YAAY;IACxD,IAAI,SAAS,CAAA,GAAA,gBAAQ,EAAE;IAEvB,IAAI,QAAQ;QACV,GAAG,WAAW,KAAK;QACnB,GAAG,UAAU,KAAK;IACpB;IAEA,IAAI,MAAM,OAAO,MACf,MAAM,MAAM,CAAA,GAAA,+BAAuB,EAAE,MAAM,KAAK;IAGlD,IAAI,MAAM,aAAa,MACrB,MAAM,YAAY,CAAA,GAAA,+BAAuB,EAAE,MAAM,WAAW;IAG9D,IAAI,MAAM,UAAU,MAClB,MAAM,SAAS,CAAA,GAAA,+BAAuB,EAAE,MAAM,QAAQ;IAGxD,qBACE,gCAAC;QAAK,GAAG,CAAA,GAAA,qBAAa,EAAE,WAAW;QAAE,WAAW,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,gEAAK,GAAG,QAAQ,WAAW;QAAY,OAAO;QAAO,KAAK;OAClH;AAGP;AAEA;;;CAGC,GACD,SAAS,qCAAe,KAAK;IAC3B,IAAI,UAAU,SACZ,OAAO;IAGT,IAAI,UAAU,OACZ,OAAO;IAGT,OAAO;AACT;AAEA;;CAEC,GACD,SAAS,oCAAc,KAAK;IAC1B,IAAI,OAAO,UAAU,WACnB,OAAO,QAAQ,SAAS;IAG1B,OAAO;AACT;AAEA;;;CAGC,GACD,MAAM,0DAAQ,CAAA,GAAA,iBAAS,EAAE;;","sources":["packages/@react-spectrum/layout/src/index.ts","packages/@react-spectrum/layout/src/Grid.tsx","packages/@react-spectrum/layout/src/Flex.tsx","packages/@react-spectrum/layout/src/flex-gap.css"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n/// <reference types=\"css-module-types\" />\n\nexport {repeat, minmax, fitContent, Grid} from './Grid';\nexport {Flex} from './Flex';\nexport type {DimensionValue} from '@react-types/shared';\nexport type {FlexProps, GridProps} from '@react-types/layout';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n baseStyleProps,\n dimensionValue,\n passthroughStyle,\n StyleHandlers,\n useDOMRef,\n useStyleProps\n} from '@react-spectrum/utils';\nimport {DimensionValue, DOMRef} from '@react-types/shared';\nimport {filterDOMProps} from '@react-aria/utils';\nimport {GridProps} from '@react-types/layout';\nimport React, {forwardRef} from 'react';\n\nconst gridStyleProps: StyleHandlers = {\n ...baseStyleProps,\n autoFlow: ['gridAutoFlow', passthroughStyle],\n autoColumns: ['gridAutoColumns', gridDimensionValue],\n autoRows: ['gridAutoRows', gridDimensionValue],\n areas: ['gridTemplateAreas', gridTemplateAreasValue],\n columns: ['gridTemplateColumns', gridTemplateValue],\n rows: ['gridTemplateRows', gridTemplateValue],\n gap: ['gap', dimensionValue],\n rowGap: ['rowGap', dimensionValue],\n columnGap: ['columnGap', dimensionValue],\n justifyItems: ['justifyItems', passthroughStyle],\n justifyContent: ['justifyContent', passthroughStyle],\n alignItems: ['alignItems', passthroughStyle],\n alignContent: ['alignContent', passthroughStyle]\n};\n\nfunction Grid(props: GridProps, ref: DOMRef<HTMLDivElement>) {\n let {\n children,\n ...otherProps\n } = props;\n let {styleProps} = useStyleProps(otherProps, gridStyleProps);\n styleProps.style.display = 'grid'; // inline-grid?\n let domRef = useDOMRef(ref);\n\n return (\n <div {...filterDOMProps(otherProps)} {...styleProps} ref={domRef}>\n {children}\n </div>\n );\n}\n\n/**\n * Can be used to make a repeating fragment of the columns or rows list.\n * See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/repeat).\n * @param count - The number of times to repeat the fragment.\n * @param repeat - The fragment to repeat.\n */\nexport function repeat(count: number | 'auto-fill' | 'auto-fit', repeat: DimensionValue | DimensionValue[]): string {\n return `repeat(${count}, ${gridTemplateValue(repeat)})`;\n}\n\n/**\n * Defines a size range greater than or equal to min and less than or equal to max.\n * See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/minmax).\n * @param min - The minimum size.\n * @param max - The maximum size.\n */\nexport function minmax(min: DimensionValue, max: DimensionValue): string {\n return `minmax(${gridDimensionValue(min)}, ${gridDimensionValue(max)})`;\n}\n\n/**\n * Clamps a given size to an available size.\n * See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/fit-content).\n * @param dimension - The size to clamp.\n */\nexport function fitContent(dimension: DimensionValue): string {\n return `fit-content(${gridDimensionValue(dimension)})`;\n}\n\nfunction gridTemplateAreasValue(value) {\n return value.map(v => `\"${v}\"`).join('\\n');\n}\n\nfunction gridDimensionValue(value) {\n if (/^max-content|min-content|minmax|auto|fit-content|repeat|subgrid/.test(value)) {\n return value;\n }\n\n return dimensionValue(value);\n}\n\nfunction gridTemplateValue(value) {\n if (Array.isArray(value)) {\n return value.map(gridDimensionValue).join(' ');\n }\n\n return gridDimensionValue(value);\n}\n\n/**\n * A layout container using CSS grid. Supports Spectrum dimensions as values to\n * ensure consistent and adaptive sizing and spacing.\n */\nconst _Grid = forwardRef(Grid);\nexport {_Grid as Grid};\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {classNames, passthroughStyle, responsiveDimensionValue, StyleHandlers, useBreakpoint, useDOMRef, useStyleProps} from '@react-spectrum/utils';\nimport {DOMRef} from '@react-types/shared';\nimport {filterDOMProps} from '@react-aria/utils';\nimport {FlexProps} from '@react-types/layout';\nimport React, {forwardRef} from 'react';\nimport styles from './flex-gap.css';\n\nconst flexStyleProps: StyleHandlers = {\n direction: ['flexDirection', passthroughStyle],\n wrap: ['flexWrap', flexWrapValue],\n justifyContent: ['justifyContent', flexAlignValue],\n alignItems: ['alignItems', flexAlignValue],\n alignContent: ['alignContent', flexAlignValue]\n};\n\nfunction Flex(props: FlexProps, ref: DOMRef<HTMLDivElement>) {\n let {\n children,\n ...otherProps\n } = props;\n let breakpointProvider = useBreakpoint();\n let matchedBreakpoints = breakpointProvider?.matchedBreakpoints || ['base'];\n let {styleProps} = useStyleProps(otherProps);\n let {styleProps: flexStyle} = useStyleProps(otherProps, flexStyleProps);\n let domRef = useDOMRef(ref);\n\n let style = {\n ...styleProps.style,\n ...flexStyle.style\n };\n\n if (props.gap != null) {\n style.gap = responsiveDimensionValue(props.gap, matchedBreakpoints);\n }\n\n if (props.columnGap != null) {\n style.columnGap = responsiveDimensionValue(props.columnGap, matchedBreakpoints);\n }\n\n if (props.rowGap != null) {\n style.rowGap = responsiveDimensionValue(props.rowGap, matchedBreakpoints);\n }\n\n return (\n <div {...filterDOMProps(otherProps)} className={classNames(styles, 'flex', styleProps.className)} style={style} ref={domRef}>\n {children}\n </div>\n );\n}\n\n/**\n * Normalize 'start' and 'end' alignment values to 'flex-start' and 'flex-end'\n * in flex containers for browser compatibility.\n */\nfunction flexAlignValue(value) {\n if (value === 'start') {\n return 'flex-start';\n }\n\n if (value === 'end') {\n return 'flex-end';\n }\n\n return value;\n}\n\n/**\n * Takes a boolean and translates it to flex wrap or nowrap.\n */\nfunction flexWrapValue(value) {\n if (typeof value === 'boolean') {\n return value ? 'wrap' : 'nowrap';\n }\n\n return value;\n}\n\n/**\n * A layout container using flexbox. Provides Spectrum dimension values, and supports the gap\n * property to define consistent spacing between items.\n */\nconst _Flex = forwardRef(Flex);\nexport {_Flex as Flex};\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n.flex-container {\n /* this is necessary so that the inner margins don't affect anything outside */\n display: flex;\n}\n\n.flex {\n display: flex;\n}\n\n.flex-gap {\n --gap: 0px;\n --column-gap: var(--gap);\n --row-gap: var(--gap);\n\n /* apply a negative margin to counteract the margin on each item at the edges */\n margin: calc(var(--row-gap) / -2) calc(var(--column-gap) / -2);\n\n /* increase the width and height to account for this margin */\n /* Add 1px to fix rounding error in Safari (╯°□°)╯︵ ┻━┻ */\n width: calc(100% + calc(var(--column-gap) + 1px));\n height: calc(100% + var(--row-gap));\n}\n\n/* If the selector was .flex-gap > *, it wouldn't override when components have a margin 0 specified by a single\n * class selector, specificity is equal. Both are one class. Neither > nor * contribute to specificity.\n * We need to make it more specific, so we raise it by 1 class.\n */\n.flex-container .flex-gap > * {\n /* apply half of the gap to each side of every item */\n margin: calc(var(--row-gap) / 2) calc(var(--column-gap) / 2);\n}\n"],"names":[],"version":3,"file":"module.js.map"}
|
|
1
|
+
{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MAAM,QAAQ;IAGxD,qBACE,gCAAC;QAAK,GAAG,CAAA,GAAA,qBAAa,EAAE,WAAW;QAAE,WAAW,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,gEAAK,GAAG,QAAQ,WAAW;QAAY,OAAO;QAAO,KAAK;OAClH;AAGP;AAEA;;;CAGC,GACD,SAAS,qCAAe,KAAK;IAC3B,IAAI,UAAU,SACZ,OAAO;IAGT,IAAI,UAAU,OACZ,OAAO;IAGT,OAAO;AACT;AAEA;;CAEC,GACD,SAAS,oCAAc,KAAK;IAC1B,IAAI,OAAO,UAAU,WACnB,OAAO,QAAQ,SAAS;IAG1B,OAAO;AACT;AAGA,kEAAkE;AAClE,yDAAyD;AACzD,0HAA0H;AAE1H,IAAI,4CAAsB;AAC1B,SAAS;IACP,IAAI,6CAAuB,MACzB,OAAO;IAGT,IAAI,OAAO,aAAa,aACtB,OAAO;IAGT,yCAAyC;IACzC,IAAI,OAAO,SAAS,cAAc;IAClC,KAAK,MAAM,UAAU;IACrB,KAAK,MAAM,gBAAgB;IAC3B,KAAK,MAAM,SAAS;IAEpB,iCAAiC;IACjC,KAAK,YAAY,SAAS,cAAc;IACxC,KAAK,YAAY,SAAS,cAAc;IAExC,oDAAoD;IACpD,SAAS,KAAK,YAAY;IAC1B,4CAAsB,KAAK,iBAAiB,GAAG,qDAAqD;IACpG,KAAK,WAAW,YAAY;IAE5B,OAAO;AACT;AAEA;;;CAGC,GACD,MAAM,0DAAQ,CAAA,GAAA,iBAAS,EAAE;;","sources":["packages/@react-spectrum/layout/src/index.ts","packages/@react-spectrum/layout/src/Grid.tsx","packages/@react-spectrum/layout/src/Flex.tsx","packages/@react-spectrum/layout/src/flex-gap.css"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n/// <reference types=\"css-module-types\" />\n\nexport {repeat, minmax, fitContent, Grid} from './Grid';\nexport {Flex} from './Flex';\nexport type {DimensionValue} from '@react-types/shared';\nexport type {FlexProps, GridProps} from '@react-types/layout';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n baseStyleProps,\n dimensionValue,\n passthroughStyle,\n StyleHandlers,\n useDOMRef,\n useStyleProps\n} from '@react-spectrum/utils';\nimport {DimensionValue, DOMRef} from '@react-types/shared';\nimport {filterDOMProps} from '@react-aria/utils';\nimport {GridProps} from '@react-types/layout';\nimport React, {forwardRef} from 'react';\n\nconst gridStyleProps: StyleHandlers = {\n ...baseStyleProps,\n autoFlow: ['gridAutoFlow', passthroughStyle],\n autoColumns: ['gridAutoColumns', gridDimensionValue],\n autoRows: ['gridAutoRows', gridDimensionValue],\n areas: ['gridTemplateAreas', gridTemplateAreasValue],\n columns: ['gridTemplateColumns', gridTemplateValue],\n rows: ['gridTemplateRows', gridTemplateValue],\n gap: ['gap', dimensionValue],\n rowGap: ['rowGap', dimensionValue],\n columnGap: ['columnGap', dimensionValue],\n justifyItems: ['justifyItems', passthroughStyle],\n justifyContent: ['justifyContent', passthroughStyle],\n alignItems: ['alignItems', passthroughStyle],\n alignContent: ['alignContent', passthroughStyle]\n};\n\nfunction Grid(props: GridProps, ref: DOMRef<HTMLDivElement>) {\n let {\n children,\n ...otherProps\n } = props;\n let {styleProps} = useStyleProps(otherProps, gridStyleProps);\n styleProps.style.display = 'grid'; // inline-grid?\n let domRef = useDOMRef(ref);\n\n return (\n <div {...filterDOMProps(otherProps)} {...styleProps} ref={domRef}>\n {children}\n </div>\n );\n}\n\n/**\n * Can be used to make a repeating fragment of the columns or rows list.\n * See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/repeat).\n * @param count - The number of times to repeat the fragment.\n * @param repeat - The fragment to repeat.\n */\nexport function repeat(count: number | 'auto-fill' | 'auto-fit', repeat: DimensionValue | DimensionValue[]): string {\n return `repeat(${count}, ${gridTemplateValue(repeat)})`;\n}\n\n/**\n * Defines a size range greater than or equal to min and less than or equal to max.\n * See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/minmax).\n * @param min - The minimum size.\n * @param max - The maximum size.\n */\nexport function minmax(min: DimensionValue, max: DimensionValue): string {\n return `minmax(${gridDimensionValue(min)}, ${gridDimensionValue(max)})`;\n}\n\n/**\n * Clamps a given size to an available size.\n * See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/fit-content).\n * @param dimension - The size to clamp.\n */\nexport function fitContent(dimension: DimensionValue): string {\n return `fit-content(${gridDimensionValue(dimension)})`;\n}\n\nfunction gridTemplateAreasValue(value) {\n return value.map(v => `\"${v}\"`).join('\\n');\n}\n\nfunction gridDimensionValue(value) {\n if (/^max-content|min-content|minmax|auto|fit-content|repeat|subgrid/.test(value)) {\n return value;\n }\n\n return dimensionValue(value);\n}\n\nfunction gridTemplateValue(value) {\n if (Array.isArray(value)) {\n return value.map(gridDimensionValue).join(' ');\n }\n\n return gridDimensionValue(value);\n}\n\n/**\n * A layout container using CSS grid. Supports Spectrum dimensions as values to\n * ensure consistent and adaptive sizing and spacing.\n */\nconst _Grid = forwardRef(Grid);\nexport {_Grid as Grid};\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {classNames, passthroughStyle, responsiveDimensionValue, StyleHandlers, useBreakpoint, useDOMRef, useStyleProps} from '@react-spectrum/utils';\nimport {DOMRef} from '@react-types/shared';\nimport {filterDOMProps} from '@react-aria/utils';\nimport {FlexProps} from '@react-types/layout';\nimport React, {forwardRef} from 'react';\nimport styles from './flex-gap.css';\nimport {useIsSSR} from '@react-aria/ssr';\n\nconst flexStyleProps: StyleHandlers = {\n direction: ['flexDirection', passthroughStyle],\n wrap: ['flexWrap', flexWrapValue],\n justifyContent: ['justifyContent', flexAlignValue],\n alignItems: ['alignItems', flexAlignValue],\n alignContent: ['alignContent', flexAlignValue]\n};\n\nfunction Flex(props: FlexProps, ref: DOMRef<HTMLDivElement>) {\n let {\n children,\n ...otherProps\n } = props;\n let breakpointProvider = useBreakpoint();\n let matchedBreakpoints = breakpointProvider?.matchedBreakpoints || ['base'];\n let {styleProps} = useStyleProps(otherProps);\n let {styleProps: flexStyle} = useStyleProps(otherProps, flexStyleProps);\n let domRef = useDOMRef(ref);\n let isSSR = useIsSSR();\n\n // If a gap property is specified, and there is no native support or we're in SSR, use a shim.\n // Two divs are required for this: the outer one contains most style properties, and the inner\n // one is the flex container. Each item inside the flex container gets a margin around it based\n // on the gap, and the flex container has a negative margin to counteract this. The outer container\n // is necessary to allow nesting of flex containers with gaps, so that the inner CSS variable doesn't\n // override the outer one.\n if ((props.gap || props.rowGap || props.columnGap) && (isSSR || !isFlexGapSupported())) {\n let style = {\n ...flexStyle.style,\n '--column-gap': props.columnGap != null ? responsiveDimensionValue(props.columnGap, matchedBreakpoints) : undefined,\n '--row-gap': props.rowGap != null ? responsiveDimensionValue(props.rowGap, matchedBreakpoints) : undefined,\n '--gap': props.gap != null ? responsiveDimensionValue(props.gap, matchedBreakpoints) : undefined\n };\n\n return (\n <div {...filterDOMProps(otherProps)} {...styleProps} className={classNames(styles, 'flex-container', styleProps.className)} ref={domRef}>\n <div className={classNames(styles, 'flex', 'flex-gap')} style={style}>\n {children}\n </div>\n </div>\n );\n }\n\n // If no gaps, or native support exists, then we only need to render a single div.\n let style = {\n ...styleProps.style,\n ...flexStyle.style\n };\n\n if (props.gap != null) {\n style.gap = responsiveDimensionValue(props.gap, matchedBreakpoints);\n }\n\n if (props.columnGap != null) {\n style.columnGap = responsiveDimensionValue(props.columnGap, matchedBreakpoints);\n }\n\n if (props.rowGap != null) {\n style.rowGap = responsiveDimensionValue(props.rowGap, matchedBreakpoints);\n }\n\n return (\n <div {...filterDOMProps(otherProps)} className={classNames(styles, 'flex', styleProps.className)} style={style} ref={domRef}>\n {children}\n </div>\n );\n}\n\n/**\n * Normalize 'start' and 'end' alignment values to 'flex-start' and 'flex-end'\n * in flex containers for browser compatibility.\n */\nfunction flexAlignValue(value) {\n if (value === 'start') {\n return 'flex-start';\n }\n\n if (value === 'end') {\n return 'flex-end';\n }\n\n return value;\n}\n\n/**\n * Takes a boolean and translates it to flex wrap or nowrap.\n */\nfunction flexWrapValue(value) {\n if (typeof value === 'boolean') {\n return value ? 'wrap' : 'nowrap';\n }\n\n return value;\n}\n\n\n// Original licensing for the following method can be found in the\n// NOTICE file in the root directory of this source tree.\n// See https://github.com/Modernizr/Modernizr/blob/7efb9d0edd66815fb115fdce95fabaf019ce8db5/feature-detects/css/flexgap.js\n\nlet _isFlexGapSupported = null;\nfunction isFlexGapSupported() {\n if (_isFlexGapSupported != null) {\n return _isFlexGapSupported;\n }\n\n if (typeof document === 'undefined') {\n return false;\n }\n\n // create flex container with row-gap set\n var flex = document.createElement('div');\n flex.style.display = 'flex';\n flex.style.flexDirection = 'column';\n flex.style.rowGap = '1px';\n\n // create two, elements inside it\n flex.appendChild(document.createElement('div'));\n flex.appendChild(document.createElement('div'));\n\n // append to the DOM (needed to obtain scrollHeight)\n document.body.appendChild(flex);\n _isFlexGapSupported = flex.scrollHeight === 1; // flex container should be 1px high from the row-gap\n flex.parentNode.removeChild(flex);\n\n return _isFlexGapSupported;\n}\n\n/**\n * A layout container using flexbox. Provides Spectrum dimension values, and supports the gap\n * property to define consistent spacing between items.\n */\nconst _Flex = forwardRef(Flex);\nexport {_Flex as Flex};\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n.flex-container {\n /* this is necessary so that the inner margins don't affect anything outside */\n display: flex;\n}\n\n.flex {\n display: flex;\n}\n\n.flex-gap {\n --gap: 0px;\n --column-gap: var(--gap);\n --row-gap: var(--gap);\n\n /* apply a negative margin to counteract the margin on each item at the edges */\n margin: calc(var(--row-gap) / -2) calc(var(--column-gap) / -2);\n\n /* increase the width and height to account for this margin */\n /* Add 1px to fix rounding error in Safari (╯°□°)╯︵ ┻━┻ */\n width: calc(100% + calc(var(--column-gap) + 1px));\n height: calc(100% + var(--row-gap));\n}\n\n/* If the selector was .flex-gap > *, it wouldn't override when components have a margin 0 specified by a single\n * class selector, specificity is equal. Both are one class. Neither > nor * contribute to specificity.\n * We need to make it more specific, so we raise it by 1 class.\n */\n.flex-container .flex-gap > * {\n /* apply half of the gap to each side of every item */\n margin: calc(var(--row-gap) / 2) calc(var(--column-gap) / 2);\n}\n"],"names":[],"version":3,"file":"module.js.map"}
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;AA0DA;;;;;GAKG;AACH,uBAAuB,KAAK,EAAE,MAAM,GAAG,WAAW,GAAG,UAAU,EAAE,QAAQ,cAAc,GAAG,cAAc,EAAE,GAAG,MAAM,CAElH;AAED;;;;;GAKG;AACH,uBAAuB,GAAG,EAAE,cAAc,EAAE,GAAG,EAAE,cAAc,GAAG,MAAM,CAEvE;AAED;;;;GAIG;AACH,2BAA2B,SAAS,EAAE,cAAc,GAAG,MAAM,CAE5D;AAsBD;;;GAGG;AACH,OAAA,MAAM,iIAAwB,CAAC;
|
|
1
|
+
{"mappings":";;;AA0DA;;;;;GAKG;AACH,uBAAuB,KAAK,EAAE,MAAM,GAAG,WAAW,GAAG,UAAU,EAAE,QAAQ,cAAc,GAAG,cAAc,EAAE,GAAG,MAAM,CAElH;AAED;;;;;GAKG;AACH,uBAAuB,GAAG,EAAE,cAAc,EAAE,GAAG,EAAE,cAAc,GAAG,MAAM,CAEvE;AAED;;;;GAIG;AACH,2BAA2B,SAAS,EAAE,cAAc,GAAG,MAAM,CAE5D;AAsBD;;;GAGG;AACH,OAAA,MAAM,iIAAwB,CAAC;ACqC/B;;;GAGG;AACH,OAAA,MAAM,iIAAwB,CAAC;ACxI/B,YAAY,EAAC,cAAc,EAAC,MAAM,qBAAqB,CAAC;AACxD,YAAY,EAAC,SAAS,EAAE,SAAS,EAAC,MAAM,qBAAqB,CAAC","sources":["packages/@react-spectrum/layout/src/packages/@react-spectrum/layout/src/Grid.tsx","packages/@react-spectrum/layout/src/packages/@react-spectrum/layout/src/Flex.tsx","packages/@react-spectrum/layout/src/packages/@react-spectrum/layout/src/index.ts","packages/@react-spectrum/layout/src/index.ts"],"sourcesContent":[null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n/// <reference types=\"css-module-types\" />\n\nexport {repeat, minmax, fitContent, Grid} from './Grid';\nexport {Flex} from './Flex';\nexport type {DimensionValue} from '@react-types/shared';\nexport type {FlexProps, GridProps} from '@react-types/layout';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-spectrum/layout",
|
|
3
|
-
"version": "3.5.7
|
|
3
|
+
"version": "3.5.7",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -36,16 +36,16 @@
|
|
|
36
36
|
"url": "https://github.com/adobe/react-spectrum"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@react-aria/ssr": "3.8.
|
|
40
|
-
"@react-aria/utils": "3.
|
|
41
|
-
"@react-spectrum/utils": "3.
|
|
42
|
-
"@react-types/layout": "3.3.
|
|
43
|
-
"@react-types/shared": "3.
|
|
39
|
+
"@react-aria/ssr": "^3.8.0",
|
|
40
|
+
"@react-aria/utils": "^3.21.1",
|
|
41
|
+
"@react-spectrum/utils": "^3.11.1",
|
|
42
|
+
"@react-types/layout": "^3.3.11",
|
|
43
|
+
"@react-types/shared": "^3.21.0",
|
|
44
44
|
"@swc/helpers": "^0.5.0",
|
|
45
45
|
"clsx": "^1.1.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@adobe/spectrum-css-temp": "3.0.0-
|
|
48
|
+
"@adobe/spectrum-css-temp": "3.0.0-alpha.1"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"@react-spectrum/provider": "^3.0.0",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "3ecf62dcceea437cb12df1851636dd491bb6591c"
|
|
58
58
|
}
|
package/src/Flex.tsx
CHANGED
|
@@ -16,6 +16,7 @@ import {filterDOMProps} from '@react-aria/utils';
|
|
|
16
16
|
import {FlexProps} from '@react-types/layout';
|
|
17
17
|
import React, {forwardRef} from 'react';
|
|
18
18
|
import styles from './flex-gap.css';
|
|
19
|
+
import {useIsSSR} from '@react-aria/ssr';
|
|
19
20
|
|
|
20
21
|
const flexStyleProps: StyleHandlers = {
|
|
21
22
|
direction: ['flexDirection', passthroughStyle],
|
|
@@ -35,7 +36,32 @@ function Flex(props: FlexProps, ref: DOMRef<HTMLDivElement>) {
|
|
|
35
36
|
let {styleProps} = useStyleProps(otherProps);
|
|
36
37
|
let {styleProps: flexStyle} = useStyleProps(otherProps, flexStyleProps);
|
|
37
38
|
let domRef = useDOMRef(ref);
|
|
39
|
+
let isSSR = useIsSSR();
|
|
38
40
|
|
|
41
|
+
// If a gap property is specified, and there is no native support or we're in SSR, use a shim.
|
|
42
|
+
// Two divs are required for this: the outer one contains most style properties, and the inner
|
|
43
|
+
// one is the flex container. Each item inside the flex container gets a margin around it based
|
|
44
|
+
// on the gap, and the flex container has a negative margin to counteract this. The outer container
|
|
45
|
+
// is necessary to allow nesting of flex containers with gaps, so that the inner CSS variable doesn't
|
|
46
|
+
// override the outer one.
|
|
47
|
+
if ((props.gap || props.rowGap || props.columnGap) && (isSSR || !isFlexGapSupported())) {
|
|
48
|
+
let style = {
|
|
49
|
+
...flexStyle.style,
|
|
50
|
+
'--column-gap': props.columnGap != null ? responsiveDimensionValue(props.columnGap, matchedBreakpoints) : undefined,
|
|
51
|
+
'--row-gap': props.rowGap != null ? responsiveDimensionValue(props.rowGap, matchedBreakpoints) : undefined,
|
|
52
|
+
'--gap': props.gap != null ? responsiveDimensionValue(props.gap, matchedBreakpoints) : undefined
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<div {...filterDOMProps(otherProps)} {...styleProps} className={classNames(styles, 'flex-container', styleProps.className)} ref={domRef}>
|
|
57
|
+
<div className={classNames(styles, 'flex', 'flex-gap')} style={style}>
|
|
58
|
+
{children}
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// If no gaps, or native support exists, then we only need to render a single div.
|
|
39
65
|
let style = {
|
|
40
66
|
...styleProps.style,
|
|
41
67
|
...flexStyle.style
|
|
@@ -87,6 +113,39 @@ function flexWrapValue(value) {
|
|
|
87
113
|
return value;
|
|
88
114
|
}
|
|
89
115
|
|
|
116
|
+
|
|
117
|
+
// Original licensing for the following method can be found in the
|
|
118
|
+
// NOTICE file in the root directory of this source tree.
|
|
119
|
+
// See https://github.com/Modernizr/Modernizr/blob/7efb9d0edd66815fb115fdce95fabaf019ce8db5/feature-detects/css/flexgap.js
|
|
120
|
+
|
|
121
|
+
let _isFlexGapSupported = null;
|
|
122
|
+
function isFlexGapSupported() {
|
|
123
|
+
if (_isFlexGapSupported != null) {
|
|
124
|
+
return _isFlexGapSupported;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (typeof document === 'undefined') {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// create flex container with row-gap set
|
|
132
|
+
var flex = document.createElement('div');
|
|
133
|
+
flex.style.display = 'flex';
|
|
134
|
+
flex.style.flexDirection = 'column';
|
|
135
|
+
flex.style.rowGap = '1px';
|
|
136
|
+
|
|
137
|
+
// create two, elements inside it
|
|
138
|
+
flex.appendChild(document.createElement('div'));
|
|
139
|
+
flex.appendChild(document.createElement('div'));
|
|
140
|
+
|
|
141
|
+
// append to the DOM (needed to obtain scrollHeight)
|
|
142
|
+
document.body.appendChild(flex);
|
|
143
|
+
_isFlexGapSupported = flex.scrollHeight === 1; // flex container should be 1px high from the row-gap
|
|
144
|
+
flex.parentNode.removeChild(flex);
|
|
145
|
+
|
|
146
|
+
return _isFlexGapSupported;
|
|
147
|
+
}
|
|
148
|
+
|
|
90
149
|
/**
|
|
91
150
|
* A layout container using flexbox. Provides Spectrum dimension values, and supports the gap
|
|
92
151
|
* property to define consistent spacing between items.
|