@react-spectrum/buttongroup 3.2.4-nightly.3036 → 3.2.4-nightly.3047
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/main.css +1 -2
- package/dist/main.js +120 -123
- package/dist/main.js.map +1 -1
- package/dist/module.js +98 -87
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +10 -10
- package/dist/main.css.map +0 -1
package/dist/main.css
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
._spectrum-
|
|
2
|
-
/*# sourceMappingURL=main.css.map */
|
|
1
|
+
._spectrum-ButtonGroup_b10c2f{-ms-flex-align:start;align-items:flex-start;display:-ms-inline-flexbox;display:inline-flex;position:relative}._spectrum-ButtonGroup_b10c2f ._spectrum-ButtonGroup-Button_b10c2f{-ms-flex-negative:0;flex-shrink:0}[dir=ltr] ._spectrum-ButtonGroup_b10c2f ._spectrum-ButtonGroup-Button_b10c2f+._spectrum-ButtonGroup-Button_b10c2f{margin-left:var(--spectrum-buttongroup-button-gap-x,var(--spectrum-global-dimension-static-size-200))}[dir=rtl] ._spectrum-ButtonGroup_b10c2f ._spectrum-ButtonGroup-Button_b10c2f+._spectrum-ButtonGroup-Button_b10c2f{margin-right:var(--spectrum-buttongroup-button-gap-x,var(--spectrum-global-dimension-static-size-200))}._spectrum-ButtonGroup_b10c2f._spectrum-ButtonGroup--alignEnd_b10c2f{-ms-flex-pack:end;justify-content:flex-end}._spectrum-ButtonGroup_b10c2f._spectrum-ButtonGroup--alignCenter_b10c2f{-ms-flex-pack:center;justify-content:center}._spectrum-ButtonGroup--vertical_b10c2f{display:-ms-inline-flexbox;display:inline-flex;-ms-flex-direction:column;flex-direction:column}[dir=ltr] ._spectrum-ButtonGroup--vertical_b10c2f ._spectrum-ButtonGroup-Button_b10c2f+._spectrum-ButtonGroup-Button_b10c2f{margin-left:0}[dir=rtl] ._spectrum-ButtonGroup--vertical_b10c2f ._spectrum-ButtonGroup-Button_b10c2f+._spectrum-ButtonGroup-Button_b10c2f{margin-right:0}._spectrum-ButtonGroup--vertical_b10c2f ._spectrum-ButtonGroup-Button_b10c2f+._spectrum-ButtonGroup-Button_b10c2f{margin-top:var(--spectrum-buttongroup-button-gap-y,var(--spectrum-global-dimension-static-size-200))}._spectrum-ButtonGroup--vertical_b10c2f._spectrum-ButtonGroup--alignEnd_b10c2f{-ms-flex-align:end;align-items:flex-end}._spectrum-ButtonGroup--vertical_b10c2f._spectrum-ButtonGroup--alignCenter_b10c2f{-ms-flex-align:center;align-items:center}
|
package/dist/main.js
CHANGED
|
@@ -1,136 +1,133 @@
|
|
|
1
|
-
var _react2 = require("react");
|
|
2
|
-
|
|
3
|
-
var _react = $parcel$interopDefault(_react2);
|
|
4
|
-
|
|
5
|
-
var {
|
|
6
|
-
useCallback,
|
|
7
|
-
useEffect,
|
|
8
|
-
useRef
|
|
9
|
-
} = _react2;
|
|
10
|
-
|
|
11
|
-
var {
|
|
12
|
-
Provider,
|
|
13
|
-
useProvider,
|
|
14
|
-
useProviderProps
|
|
15
|
-
} = require("@react-spectrum/provider");
|
|
16
|
-
|
|
17
|
-
var {
|
|
18
|
-
filterDOMProps,
|
|
19
|
-
useValueEffect
|
|
20
|
-
} = require("@react-aria/utils");
|
|
21
|
-
|
|
22
|
-
var {
|
|
23
|
-
classNames,
|
|
24
|
-
SlotProvider,
|
|
25
|
-
useDOMRef,
|
|
26
|
-
useResizeObserver,
|
|
27
|
-
useSlotProps,
|
|
28
|
-
useStyleProps
|
|
29
|
-
} = require("@react-spectrum/utils");
|
|
30
|
-
|
|
31
|
-
var _babelRuntimeHelpersObjectWithoutPropertiesLoose = $parcel$interopDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
32
|
-
|
|
33
|
-
var _babelRuntimeHelpersExtends = $parcel$interopDefault(require("@babel/runtime/helpers/extends"));
|
|
34
|
-
|
|
35
1
|
require("./main.css");
|
|
2
|
+
var $fadik$reactspectrumutils = require("@react-spectrum/utils");
|
|
3
|
+
var $fadik$reactariautils = require("@react-aria/utils");
|
|
4
|
+
var $fadik$reactspectrumprovider = require("@react-spectrum/provider");
|
|
5
|
+
var $fadik$react = require("react");
|
|
6
|
+
|
|
7
|
+
function $parcel$exportWildcard(dest, source) {
|
|
8
|
+
Object.keys(source).forEach(function(key) {
|
|
9
|
+
if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
Object.defineProperty(dest, key, {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function get() {
|
|
16
|
+
return source[key];
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
});
|
|
36
20
|
|
|
21
|
+
return dest;
|
|
22
|
+
}
|
|
37
23
|
function $parcel$interopDefault(a) {
|
|
38
24
|
return a && a.__esModule ? a.default : a;
|
|
39
25
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
$
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
var $
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
let
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
26
|
+
function $parcel$export(e, n, v, s) {
|
|
27
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
28
|
+
}
|
|
29
|
+
var $c30474aa2e2ed478$exports = {};
|
|
30
|
+
|
|
31
|
+
$parcel$export($c30474aa2e2ed478$exports, "ButtonGroup", () => $c30474aa2e2ed478$export$69b1032f2ecdf404);
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
var $53a033bfcc659fdc$exports = {};
|
|
37
|
+
|
|
38
|
+
$parcel$export($53a033bfcc659fdc$exports, "spectrum-ButtonGroup", () => $53a033bfcc659fdc$export$a92faf51352ac608, (v) => $53a033bfcc659fdc$export$a92faf51352ac608 = v);
|
|
39
|
+
$parcel$export($53a033bfcc659fdc$exports, "spectrum-ButtonGroup-Button", () => $53a033bfcc659fdc$export$7184de2337c1927f, (v) => $53a033bfcc659fdc$export$7184de2337c1927f = v);
|
|
40
|
+
$parcel$export($53a033bfcc659fdc$exports, "spectrum-ButtonGroup--alignEnd", () => $53a033bfcc659fdc$export$30e96c53d7beca11, (v) => $53a033bfcc659fdc$export$30e96c53d7beca11 = v);
|
|
41
|
+
$parcel$export($53a033bfcc659fdc$exports, "spectrum-ButtonGroup--alignCenter", () => $53a033bfcc659fdc$export$252bc7c4ae05757, (v) => $53a033bfcc659fdc$export$252bc7c4ae05757 = v);
|
|
42
|
+
$parcel$export($53a033bfcc659fdc$exports, "spectrum-ButtonGroup--vertical", () => $53a033bfcc659fdc$export$84d9c0e1917a4eaf, (v) => $53a033bfcc659fdc$export$84d9c0e1917a4eaf = v);
|
|
43
|
+
var $53a033bfcc659fdc$export$a92faf51352ac608;
|
|
44
|
+
var $53a033bfcc659fdc$export$7184de2337c1927f;
|
|
45
|
+
var $53a033bfcc659fdc$export$30e96c53d7beca11;
|
|
46
|
+
var $53a033bfcc659fdc$export$252bc7c4ae05757;
|
|
47
|
+
var $53a033bfcc659fdc$export$84d9c0e1917a4eaf;
|
|
48
|
+
$53a033bfcc659fdc$export$a92faf51352ac608 = "_spectrum-ButtonGroup_b10c2f";
|
|
49
|
+
$53a033bfcc659fdc$export$7184de2337c1927f = "_spectrum-ButtonGroup-Button_b10c2f";
|
|
50
|
+
$53a033bfcc659fdc$export$30e96c53d7beca11 = "_spectrum-ButtonGroup--alignEnd_b10c2f";
|
|
51
|
+
$53a033bfcc659fdc$export$252bc7c4ae05757 = "_spectrum-ButtonGroup--alignCenter_b10c2f";
|
|
52
|
+
$53a033bfcc659fdc$export$84d9c0e1917a4eaf = "_spectrum-ButtonGroup--vertical_b10c2f";
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
function $c30474aa2e2ed478$var$ButtonGroup(props, ref) {
|
|
56
|
+
let { scale: scale } = $fadik$reactspectrumprovider.useProvider();
|
|
57
|
+
props = $fadik$reactspectrumprovider.useProviderProps(props);
|
|
58
|
+
props = $fadik$reactspectrumutils.useSlotProps(props, 'buttonGroup');
|
|
59
|
+
let { children: children , orientation: orientation = 'horizontal' , isDisabled: isDisabled , align: align = 'start' , ...otherProps } = props;
|
|
60
|
+
let { styleProps: styleProps } = $fadik$reactspectrumutils.useStyleProps(otherProps);
|
|
61
|
+
let domRef = $fadik$reactspectrumutils.useDOMRef(ref);
|
|
62
|
+
let [hasOverflow, setHasOverflow] = $fadik$reactariautils.useValueEffect(false);
|
|
63
|
+
let checkForOverflow = $fadik$react.useCallback(()=>{
|
|
64
|
+
let computeHasOverflow = ()=>{
|
|
65
|
+
if (domRef.current && orientation === 'horizontal') {
|
|
66
|
+
let buttonGroupChildren = Array.from(domRef.current.children);
|
|
67
|
+
let maxX = domRef.current.offsetWidth + 1; // + 1 to account for rounding errors
|
|
68
|
+
// If any buttons have negative X positions (align="end") or extend beyond
|
|
69
|
+
// the width of the button group (align="start"), then switch to vertical.
|
|
70
|
+
if (buttonGroupChildren.some((child)=>child.offsetLeft < 0 || child.offsetLeft + child.offsetWidth > maxX
|
|
71
|
+
)) return true;
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
if (orientation === 'horizontal') setHasOverflow(function*() {
|
|
76
|
+
// Force to horizontal for measurement.
|
|
77
|
+
yield false;
|
|
78
|
+
// Measure, and update if there is overflow.
|
|
79
|
+
yield computeHasOverflow();
|
|
80
|
+
});
|
|
81
|
+
}, [
|
|
82
|
+
domRef,
|
|
83
|
+
orientation,
|
|
84
|
+
scale,
|
|
85
|
+
setHasOverflow,
|
|
86
|
+
children
|
|
87
|
+
]);
|
|
88
|
+
// There are two main reasons we need to remeasure:
|
|
89
|
+
// 1. Internal changes: Check for initial overflow or when orientation/scale/children change (from checkForOverflow dep array)
|
|
90
|
+
$fadik$react.useEffect(()=>{
|
|
91
|
+
checkForOverflow();
|
|
92
|
+
}, [
|
|
93
|
+
checkForOverflow
|
|
94
|
+
]);
|
|
95
|
+
// 2. External changes: buttongroup won't change size due to any parents changing size, so listen to its container for size changes to figure out if we should remeasure
|
|
96
|
+
let parent = $fadik$react.useRef();
|
|
97
|
+
$fadik$react.useEffect(()=>{
|
|
98
|
+
parent.current = domRef.current.parentElement;
|
|
99
|
+
}, [
|
|
100
|
+
domRef.current
|
|
101
|
+
]);
|
|
102
|
+
$fadik$reactspectrumutils.useResizeObserver({
|
|
103
|
+
ref: parent,
|
|
104
|
+
onResize: checkForOverflow
|
|
105
|
+
});
|
|
106
|
+
return(/*#__PURE__*/ ($parcel$interopDefault($fadik$react)).createElement("div", {
|
|
107
|
+
...$fadik$reactariautils.filterDOMProps(otherProps),
|
|
108
|
+
...styleProps,
|
|
109
|
+
ref: domRef,
|
|
110
|
+
className: $fadik$reactspectrumutils.classNames((/*@__PURE__*/$parcel$interopDefault($53a033bfcc659fdc$exports)), 'spectrum-ButtonGroup', {
|
|
111
|
+
'spectrum-ButtonGroup--vertical': orientation === 'vertical' || hasOverflow,
|
|
112
|
+
'spectrum-ButtonGroup--alignEnd': align === 'end',
|
|
113
|
+
'spectrum-ButtonGroup--alignCenter': align === 'center'
|
|
114
|
+
}, styleProps.className)
|
|
115
|
+
}, /*#__PURE__*/ ($parcel$interopDefault($fadik$react)).createElement($fadik$reactspectrumutils.SlotProvider, {
|
|
116
|
+
slots: {
|
|
117
|
+
button: {
|
|
118
|
+
UNSAFE_className: $fadik$reactspectrumutils.classNames((/*@__PURE__*/$parcel$interopDefault($53a033bfcc659fdc$exports)), 'spectrum-ButtonGroup-Button')
|
|
119
|
+
}
|
|
82
120
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
if (orientation === 'horizontal') {
|
|
89
|
-
setHasOverflow(function* () {
|
|
90
|
-
// Force to horizontal for measurement.
|
|
91
|
-
yield false; // Measure, and update if there is overflow.
|
|
92
|
-
|
|
93
|
-
yield computeHasOverflow();
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
}, [domRef, orientation, scale, setHasOverflow, children]); // There are two main reasons we need to remeasure:
|
|
97
|
-
// 1. Internal changes: Check for initial overflow or when orientation/scale/children change (from checkForOverflow dep array)
|
|
98
|
-
|
|
99
|
-
useEffect(() => {
|
|
100
|
-
checkForOverflow();
|
|
101
|
-
}, [checkForOverflow]); // 2. External changes: buttongroup won't change size due to any parents changing size, so listen to its container for size changes to figure out if we should remeasure
|
|
102
|
-
|
|
103
|
-
let parent = useRef();
|
|
104
|
-
useEffect(() => {
|
|
105
|
-
parent.current = domRef.current.parentElement;
|
|
106
|
-
}, [domRef.current]);
|
|
107
|
-
useResizeObserver({
|
|
108
|
-
ref: parent,
|
|
109
|
-
onResize: checkForOverflow
|
|
110
|
-
});
|
|
111
|
-
return /*#__PURE__*/_react.createElement("div", _babelRuntimeHelpersExtends({}, filterDOMProps(otherProps), styleProps, {
|
|
112
|
-
ref: domRef,
|
|
113
|
-
className: classNames($e5350288554758da1efde2be1e5df5d4$$interop$default, 'spectrum-ButtonGroup', {
|
|
114
|
-
'spectrum-ButtonGroup--vertical': orientation === 'vertical' || hasOverflow,
|
|
115
|
-
'spectrum-ButtonGroup--alignEnd': align === 'end',
|
|
116
|
-
'spectrum-ButtonGroup--alignCenter': align === 'center'
|
|
117
|
-
}, styleProps.className)
|
|
118
|
-
}), /*#__PURE__*/_react.createElement(SlotProvider, {
|
|
119
|
-
slots: {
|
|
120
|
-
button: {
|
|
121
|
-
UNSAFE_className: classNames($e5350288554758da1efde2be1e5df5d4$$interop$default, 'spectrum-ButtonGroup-Button')
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}, /*#__PURE__*/_react.createElement(Provider, {
|
|
125
|
-
isDisabled: isDisabled
|
|
126
|
-
}, children)));
|
|
121
|
+
}, /*#__PURE__*/ ($parcel$interopDefault($fadik$react)).createElement($fadik$reactspectrumprovider.Provider, {
|
|
122
|
+
isDisabled: isDisabled
|
|
123
|
+
}, children))));
|
|
127
124
|
}
|
|
128
125
|
/**
|
|
129
126
|
* ButtonGroup handles overflow for a grouping of buttons whose actions are related to each other.
|
|
130
|
-
*/
|
|
127
|
+
*/ let $c30474aa2e2ed478$export$69b1032f2ecdf404 = /*#__PURE__*/ ($parcel$interopDefault($fadik$react)).forwardRef($c30474aa2e2ed478$var$ButtonGroup);
|
|
128
|
+
|
|
131
129
|
|
|
130
|
+
$parcel$exportWildcard(module.exports, $c30474aa2e2ed478$exports);
|
|
132
131
|
|
|
133
|
-
let ButtonGroup = /*#__PURE__*/_react.forwardRef($b8c4ebb5d2445e152b6571d47036dd$var$ButtonGroup);
|
|
134
132
|
|
|
135
|
-
exports.ButtonGroup = ButtonGroup;
|
|
136
133
|
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AEAA,GAAsC;AACtC,GAA6C;AAC7C,GAAgD;AAChD,GAAmD;AACnD,GAAgD;AAJhD,yCAAsC,GAAG,CAA8B;AACvE,yCAA6C,GAAG,CAAqC;AACrF,yCAAgD,GAAG,CAAwC;AAC3F,wCAAmD,GAAG,CAA2C;AACjG,yCAAgD,GAAG,CAAwC;;;SDuBlF,iCAAW,CAAC,KAA+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UAAU,CAAC,iCAAW","sources":["packages/@react-spectrum/buttongroup/src/index.ts","packages/@react-spectrum/buttongroup/src/ButtonGroup.tsx","packages/@adobe/spectrum-css-temp/components/buttongroup/vars.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 * from './ButtonGroup';\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 classNames,\n SlotProvider,\n useDOMRef,\n useResizeObserver,\n useSlotProps,\n useStyleProps\n} from '@react-spectrum/utils';\nimport {DOMRef} from '@react-types/shared';\nimport {filterDOMProps, useValueEffect} from '@react-aria/utils';\nimport {Provider, useProvider, useProviderProps} from '@react-spectrum/provider';\nimport React, {useCallback, useEffect, useRef} from 'react';\nimport {SpectrumButtonGroupProps} from '@react-types/buttongroup';\nimport styles from '@adobe/spectrum-css-temp/components/buttongroup/vars.css';\n\nfunction ButtonGroup(props: SpectrumButtonGroupProps, ref: DOMRef<HTMLDivElement>) {\n let {scale} = useProvider();\n props = useProviderProps(props);\n props = useSlotProps(props, 'buttonGroup');\n\n let {\n children,\n orientation = 'horizontal',\n isDisabled,\n align = 'start',\n ...otherProps\n } = props;\n\n let {styleProps} = useStyleProps(otherProps);\n let domRef = useDOMRef(ref);\n let [hasOverflow, setHasOverflow] = useValueEffect(false);\n\n let checkForOverflow = useCallback(() => {\n let computeHasOverflow = () => {\n if (domRef.current && orientation === 'horizontal') {\n let buttonGroupChildren = Array.from(domRef.current.children) as HTMLElement[];\n let maxX = domRef.current.offsetWidth + 1; // + 1 to account for rounding errors\n // If any buttons have negative X positions (align=\"end\") or extend beyond\n // the width of the button group (align=\"start\"), then switch to vertical.\n if (buttonGroupChildren.some(child => child.offsetLeft < 0 || child.offsetLeft + child.offsetWidth > maxX)) {\n return true;\n }\n return false;\n }\n };\n if (orientation === 'horizontal') {\n setHasOverflow(function* () {\n // Force to horizontal for measurement.\n yield false;\n\n // Measure, and update if there is overflow.\n yield computeHasOverflow();\n });\n }\n }, [domRef, orientation, scale, setHasOverflow, children]);\n\n // There are two main reasons we need to remeasure:\n // 1. Internal changes: Check for initial overflow or when orientation/scale/children change (from checkForOverflow dep array)\n useEffect(() => {\n checkForOverflow();\n }, [checkForOverflow]);\n\n // 2. External changes: buttongroup won't change size due to any parents changing size, so listen to its container for size changes to figure out if we should remeasure\n let parent = useRef<HTMLElement>();\n useEffect(() => {\n parent.current = domRef.current.parentElement;\n }, [domRef.current]);\n useResizeObserver({ref: parent, onResize: checkForOverflow});\n\n return (\n <div\n {...filterDOMProps(otherProps)}\n {...styleProps}\n ref={domRef}\n className={\n classNames(\n styles,\n 'spectrum-ButtonGroup',\n {\n 'spectrum-ButtonGroup--vertical': orientation === 'vertical' || hasOverflow,\n 'spectrum-ButtonGroup--alignEnd': align === 'end',\n 'spectrum-ButtonGroup--alignCenter': align === 'center'\n },\n styleProps.className\n )\n }>\n <SlotProvider\n slots={{\n button: {\n UNSAFE_className: classNames(styles, 'spectrum-ButtonGroup-Button')\n }\n }}>\n <Provider isDisabled={isDisabled}>\n {children}\n </Provider>\n </SlotProvider>\n </div>\n );\n}\n\n/**\n * ButtonGroup handles overflow for a grouping of buttons whose actions are related to each other.\n */\nlet _ButtonGroup = React.forwardRef(ButtonGroup);\nexport {_ButtonGroup as ButtonGroup};\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@import './index.css';\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -1,106 +1,117 @@
|
|
|
1
|
-
import _react, { useCallback, useEffect, useRef } from "react";
|
|
2
|
-
import { Provider, useProvider, useProviderProps } from "@react-spectrum/provider";
|
|
3
|
-
import { filterDOMProps, useValueEffect } from "@react-aria/utils";
|
|
4
|
-
import { classNames, SlotProvider, useDOMRef, useResizeObserver, useSlotProps, useStyleProps } from "@react-spectrum/utils";
|
|
5
|
-
import _babelRuntimeHelpersEsmObjectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
6
|
-
import _babelRuntimeHelpersEsmExtends from "@babel/runtime/helpers/esm/extends";
|
|
7
1
|
import "./main.css";
|
|
2
|
+
import {useSlotProps as $dNanD$useSlotProps, useStyleProps as $dNanD$useStyleProps, useDOMRef as $dNanD$useDOMRef, useResizeObserver as $dNanD$useResizeObserver, classNames as $dNanD$classNames, SlotProvider as $dNanD$SlotProvider} from "@react-spectrum/utils";
|
|
3
|
+
import {useValueEffect as $dNanD$useValueEffect, filterDOMProps as $dNanD$filterDOMProps} from "@react-aria/utils";
|
|
4
|
+
import {useProvider as $dNanD$useProvider, useProviderProps as $dNanD$useProviderProps, Provider as $dNanD$Provider} from "@react-spectrum/provider";
|
|
5
|
+
import $dNanD$react, {useCallback as $dNanD$useCallback, useEffect as $dNanD$useEffect, useRef as $dNanD$useRef} from "react";
|
|
8
6
|
|
|
9
7
|
function $parcel$interopDefault(a) {
|
|
10
8
|
return a && a.__esModule ? a.default : a;
|
|
11
9
|
}
|
|
10
|
+
function $parcel$export(e, n, v, s) {
|
|
11
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
12
|
+
}
|
|
13
|
+
var $089be6ba315700f8$exports = {};
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
var $f9f91d1c186d99c6f3073$exports = {};
|
|
15
|
-
$f9f91d1c186d99c6f3073$exports = {
|
|
16
|
-
"spectrum-ButtonGroup": "_spectrum-ButtonGroup_f2c99",
|
|
17
|
-
"spectrum-ButtonGroup-Button": "_spectrum-ButtonGroup-Button_f2c99",
|
|
18
|
-
"spectrum-ButtonGroup--alignEnd": "_spectrum-ButtonGroup--alignEnd_f2c99",
|
|
19
|
-
"spectrum-ButtonGroup--alignCenter": "_spectrum-ButtonGroup--alignCenter_f2c99",
|
|
20
|
-
"spectrum-ButtonGroup--vertical": "_spectrum-ButtonGroup--vertical_f2c99"
|
|
21
|
-
};
|
|
22
|
-
var $f9f91d1c186d99c6f3073$$interop$default = $parcel$interopDefault($f9f91d1c186d99c6f3073$exports);
|
|
23
|
-
|
|
24
|
-
function $acd6f0f772cf1ee18dc9ae3c3d09f4fe$var$ButtonGroup(props, ref) {
|
|
25
|
-
let {
|
|
26
|
-
scale
|
|
27
|
-
} = useProvider();
|
|
28
|
-
props = useProviderProps(props);
|
|
29
|
-
props = useSlotProps(props, 'buttonGroup');
|
|
30
|
-
|
|
31
|
-
let {
|
|
32
|
-
children,
|
|
33
|
-
orientation = 'horizontal',
|
|
34
|
-
isDisabled,
|
|
35
|
-
align = 'start'
|
|
36
|
-
} = props,
|
|
37
|
-
otherProps = _babelRuntimeHelpersEsmObjectWithoutPropertiesLoose(props, ["children", "orientation", "isDisabled", "align"]);
|
|
15
|
+
$parcel$export($089be6ba315700f8$exports, "ButtonGroup", () => $089be6ba315700f8$export$69b1032f2ecdf404);
|
|
38
16
|
|
|
39
|
-
let {
|
|
40
|
-
styleProps
|
|
41
|
-
} = useStyleProps(otherProps);
|
|
42
|
-
let domRef = useDOMRef(ref);
|
|
43
|
-
let [hasOverflow, setHasOverflow] = useValueEffect(false);
|
|
44
|
-
let checkForOverflow = useCallback(() => {
|
|
45
|
-
let computeHasOverflow = () => {
|
|
46
|
-
if (domRef.current && orientation === 'horizontal') {
|
|
47
|
-
let buttonGroupChildren = Array.from(domRef.current.children);
|
|
48
|
-
let maxX = domRef.current.offsetWidth + 1; // + 1 to account for rounding errors
|
|
49
|
-
// If any buttons have negative X positions (align="end") or extend beyond
|
|
50
|
-
// the width of the button group (align="start"), then switch to vertical.
|
|
51
17
|
|
|
52
|
-
if (buttonGroupChildren.some(child => child.offsetLeft < 0 || child.offsetLeft + child.offsetWidth > maxX)) {
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
18
|
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
19
|
|
|
60
|
-
|
|
61
|
-
setHasOverflow(function* () {
|
|
62
|
-
// Force to horizontal for measurement.
|
|
63
|
-
yield false; // Measure, and update if there is overflow.
|
|
20
|
+
var $5bb6a3062fd4dc2f$exports = {};
|
|
64
21
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
22
|
+
$parcel$export($5bb6a3062fd4dc2f$exports, "spectrum-ButtonGroup", () => $5bb6a3062fd4dc2f$export$a92faf51352ac608, (v) => $5bb6a3062fd4dc2f$export$a92faf51352ac608 = v);
|
|
23
|
+
$parcel$export($5bb6a3062fd4dc2f$exports, "spectrum-ButtonGroup-Button", () => $5bb6a3062fd4dc2f$export$7184de2337c1927f, (v) => $5bb6a3062fd4dc2f$export$7184de2337c1927f = v);
|
|
24
|
+
$parcel$export($5bb6a3062fd4dc2f$exports, "spectrum-ButtonGroup--alignEnd", () => $5bb6a3062fd4dc2f$export$30e96c53d7beca11, (v) => $5bb6a3062fd4dc2f$export$30e96c53d7beca11 = v);
|
|
25
|
+
$parcel$export($5bb6a3062fd4dc2f$exports, "spectrum-ButtonGroup--alignCenter", () => $5bb6a3062fd4dc2f$export$252bc7c4ae05757, (v) => $5bb6a3062fd4dc2f$export$252bc7c4ae05757 = v);
|
|
26
|
+
$parcel$export($5bb6a3062fd4dc2f$exports, "spectrum-ButtonGroup--vertical", () => $5bb6a3062fd4dc2f$export$84d9c0e1917a4eaf, (v) => $5bb6a3062fd4dc2f$export$84d9c0e1917a4eaf = v);
|
|
27
|
+
var $5bb6a3062fd4dc2f$export$a92faf51352ac608;
|
|
28
|
+
var $5bb6a3062fd4dc2f$export$7184de2337c1927f;
|
|
29
|
+
var $5bb6a3062fd4dc2f$export$30e96c53d7beca11;
|
|
30
|
+
var $5bb6a3062fd4dc2f$export$252bc7c4ae05757;
|
|
31
|
+
var $5bb6a3062fd4dc2f$export$84d9c0e1917a4eaf;
|
|
32
|
+
$5bb6a3062fd4dc2f$export$a92faf51352ac608 = "_spectrum-ButtonGroup_b10c2f";
|
|
33
|
+
$5bb6a3062fd4dc2f$export$7184de2337c1927f = "_spectrum-ButtonGroup-Button_b10c2f";
|
|
34
|
+
$5bb6a3062fd4dc2f$export$30e96c53d7beca11 = "_spectrum-ButtonGroup--alignEnd_b10c2f";
|
|
35
|
+
$5bb6a3062fd4dc2f$export$252bc7c4ae05757 = "_spectrum-ButtonGroup--alignCenter_b10c2f";
|
|
36
|
+
$5bb6a3062fd4dc2f$export$84d9c0e1917a4eaf = "_spectrum-ButtonGroup--vertical_b10c2f";
|
|
70
37
|
|
|
71
|
-
useEffect(() => {
|
|
72
|
-
checkForOverflow();
|
|
73
|
-
}, [checkForOverflow]); // 2. External changes: buttongroup won't change size due to any parents changing size, so listen to its container for size changes to figure out if we should remeasure
|
|
74
38
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
39
|
+
function $089be6ba315700f8$var$ButtonGroup(props, ref) {
|
|
40
|
+
let { scale: scale } = $dNanD$useProvider();
|
|
41
|
+
props = $dNanD$useProviderProps(props);
|
|
42
|
+
props = $dNanD$useSlotProps(props, 'buttonGroup');
|
|
43
|
+
let { children: children , orientation: orientation = 'horizontal' , isDisabled: isDisabled , align: align = 'start' , ...otherProps } = props;
|
|
44
|
+
let { styleProps: styleProps } = $dNanD$useStyleProps(otherProps);
|
|
45
|
+
let domRef = $dNanD$useDOMRef(ref);
|
|
46
|
+
let [hasOverflow, setHasOverflow] = $dNanD$useValueEffect(false);
|
|
47
|
+
let checkForOverflow = $dNanD$useCallback(()=>{
|
|
48
|
+
let computeHasOverflow = ()=>{
|
|
49
|
+
if (domRef.current && orientation === 'horizontal') {
|
|
50
|
+
let buttonGroupChildren = Array.from(domRef.current.children);
|
|
51
|
+
let maxX = domRef.current.offsetWidth + 1; // + 1 to account for rounding errors
|
|
52
|
+
// If any buttons have negative X positions (align="end") or extend beyond
|
|
53
|
+
// the width of the button group (align="start"), then switch to vertical.
|
|
54
|
+
if (buttonGroupChildren.some((child)=>child.offsetLeft < 0 || child.offsetLeft + child.offsetWidth > maxX
|
|
55
|
+
)) return true;
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
if (orientation === 'horizontal') setHasOverflow(function*() {
|
|
60
|
+
// Force to horizontal for measurement.
|
|
61
|
+
yield false;
|
|
62
|
+
// Measure, and update if there is overflow.
|
|
63
|
+
yield computeHasOverflow();
|
|
64
|
+
});
|
|
65
|
+
}, [
|
|
66
|
+
domRef,
|
|
67
|
+
orientation,
|
|
68
|
+
scale,
|
|
69
|
+
setHasOverflow,
|
|
70
|
+
children
|
|
71
|
+
]);
|
|
72
|
+
// There are two main reasons we need to remeasure:
|
|
73
|
+
// 1. Internal changes: Check for initial overflow or when orientation/scale/children change (from checkForOverflow dep array)
|
|
74
|
+
$dNanD$useEffect(()=>{
|
|
75
|
+
checkForOverflow();
|
|
76
|
+
}, [
|
|
77
|
+
checkForOverflow
|
|
78
|
+
]);
|
|
79
|
+
// 2. External changes: buttongroup won't change size due to any parents changing size, so listen to its container for size changes to figure out if we should remeasure
|
|
80
|
+
let parent = $dNanD$useRef();
|
|
81
|
+
$dNanD$useEffect(()=>{
|
|
82
|
+
parent.current = domRef.current.parentElement;
|
|
83
|
+
}, [
|
|
84
|
+
domRef.current
|
|
85
|
+
]);
|
|
86
|
+
$dNanD$useResizeObserver({
|
|
87
|
+
ref: parent,
|
|
88
|
+
onResize: checkForOverflow
|
|
89
|
+
});
|
|
90
|
+
return(/*#__PURE__*/ $dNanD$react.createElement("div", {
|
|
91
|
+
...$dNanD$filterDOMProps(otherProps),
|
|
92
|
+
...styleProps,
|
|
93
|
+
ref: domRef,
|
|
94
|
+
className: $dNanD$classNames((/*@__PURE__*/$parcel$interopDefault($5bb6a3062fd4dc2f$exports)), 'spectrum-ButtonGroup', {
|
|
95
|
+
'spectrum-ButtonGroup--vertical': orientation === 'vertical' || hasOverflow,
|
|
96
|
+
'spectrum-ButtonGroup--alignEnd': align === 'end',
|
|
97
|
+
'spectrum-ButtonGroup--alignCenter': align === 'center'
|
|
98
|
+
}, styleProps.className)
|
|
99
|
+
}, /*#__PURE__*/ $dNanD$react.createElement($dNanD$SlotProvider, {
|
|
100
|
+
slots: {
|
|
101
|
+
button: {
|
|
102
|
+
UNSAFE_className: $dNanD$classNames((/*@__PURE__*/$parcel$interopDefault($5bb6a3062fd4dc2f$exports)), 'spectrum-ButtonGroup-Button')
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}, /*#__PURE__*/ $dNanD$react.createElement($dNanD$Provider, {
|
|
106
|
+
isDisabled: isDisabled
|
|
107
|
+
}, children))));
|
|
99
108
|
}
|
|
100
109
|
/**
|
|
101
110
|
* ButtonGroup handles overflow for a grouping of buttons whose actions are related to each other.
|
|
102
|
-
*/
|
|
111
|
+
*/ let $089be6ba315700f8$export$69b1032f2ecdf404 = /*#__PURE__*/ $dNanD$react.forwardRef($089be6ba315700f8$var$ButtonGroup);
|
|
112
|
+
|
|
113
|
+
|
|
103
114
|
|
|
104
115
|
|
|
105
|
-
export
|
|
116
|
+
export {$089be6ba315700f8$export$69b1032f2ecdf404 as ButtonGroup};
|
|
106
117
|
//# sourceMappingURL=module.js.map
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AEAA,GAAsC;AACtC,GAA6C;AAC7C,GAAgD;AAChD,GAAmD;AACnD,GAAgD;AAJhD,yCAAsC,GAAG,CAA8B;AACvE,yCAA6C,GAAG,CAAqC;AACrF,yCAAgD,GAAG,CAAwC;AAC3F,wCAAmD,GAAG,CAA2C;AACjG,yCAAgD,GAAG,CAAwC;;;SDuBlF,iCAAW,CAAC,KAA+B,EAAE,GAA2B,EAAE,CAAC;IAClF,GAAG,CAAC,CAAC,QAAA,KAAK,EAAA,CAAC,GAAG,kBAAW;IACzB,KAAK,GAAG,uBAAgB,CAAC,KAAK;IAC9B,KAAK,GAAG,mBAAY,CAAC,KAAK,EAAE,CAAa;IAEzC,GAAG,CAAC,CAAC,WACH,QAAQ,gBACR,WAAW,GAAG,CAAY,0BAC1B,UAAU,UACV,KAAK,GAAG,CAAO,YACZ,UAAU,CACf,CAAC,GAAG,KAAK;IAET,GAAG,CAAC,CAAC,aAAA,UAAU,EAAA,CAAC,GAAG,oBAAa,CAAC,UAAU;IAC3C,GAAG,CAAC,MAAM,GAAG,gBAAS,CAAC,GAAG;IAC1B,GAA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AAO,GAAG,MAAM,CAAC,OAAO,CAAC,aAAa;IAC/C,CAAC,EAAE,CAAC;QAAA,MAAM,CAAC,OAAO;IAAA,CAAC;IACnB,wBAAiB,CAAC,CAAC;QAAA,GAAG,EAAE,MAAM;QAAE,QAAQ,EAAE,gBAAgB;IAAA,CAAC;IAE3D,MAAM,0CACH,CAAG;WACE,qBAAc,CAAC,UAAU;WACzB,UAAU;QACd,GAAG,EAAE,MAAM;QACX,SAAS,EACP,iBAAU,CACR,gEAAM,EACN,CAAsB,uBACtB,CAAC;YACC,CAAgC,iCAAE,WAAW,KAAK,CAAU,aAAI,WAAW;YAC3E,CAAgC,iCAAE,KAAK,KAAK,CAAK;YACjD,CAAmC,oCAAE,KAAK,KAAK,CAAQ;QACzD,CAAC,EACD,UAAU,CAAC,SAAS;gDAGvB,mBAAY;QACX,KAAK,EAAE,CAAC;YACN,MAAM,EAAE,CAAC;gBACP,gBAAgB,EAAE,iBAAU,CAAC,gEAAM,EAAE,CAA6B;YACpE,CAAC;QACH,CAAC;gDACA,eAAQ;QAAC,UAAU,EAAE,UAAU;OAC7B,QAAQ;AAKnB,CAAC;AAED,EAEG,AAFH;;CAEG,AAFH,EAEG,CACH,GAAG,CAAC,yCAAY,iBAAG,YAAK,CAAC,UAAU,CAAC,iCAAW","sources":["packages/@react-spectrum/buttongroup/src/index.ts","packages/@react-spectrum/buttongroup/src/ButtonGroup.tsx","packages/@adobe/spectrum-css-temp/components/buttongroup/vars.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 * from './ButtonGroup';\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 classNames,\n SlotProvider,\n useDOMRef,\n useResizeObserver,\n useSlotProps,\n useStyleProps\n} from '@react-spectrum/utils';\nimport {DOMRef} from '@react-types/shared';\nimport {filterDOMProps, useValueEffect} from '@react-aria/utils';\nimport {Provider, useProvider, useProviderProps} from '@react-spectrum/provider';\nimport React, {useCallback, useEffect, useRef} from 'react';\nimport {SpectrumButtonGroupProps} from '@react-types/buttongroup';\nimport styles from '@adobe/spectrum-css-temp/components/buttongroup/vars.css';\n\nfunction ButtonGroup(props: SpectrumButtonGroupProps, ref: DOMRef<HTMLDivElement>) {\n let {scale} = useProvider();\n props = useProviderProps(props);\n props = useSlotProps(props, 'buttonGroup');\n\n let {\n children,\n orientation = 'horizontal',\n isDisabled,\n align = 'start',\n ...otherProps\n } = props;\n\n let {styleProps} = useStyleProps(otherProps);\n let domRef = useDOMRef(ref);\n let [hasOverflow, setHasOverflow] = useValueEffect(false);\n\n let checkForOverflow = useCallback(() => {\n let computeHasOverflow = () => {\n if (domRef.current && orientation === 'horizontal') {\n let buttonGroupChildren = Array.from(domRef.current.children) as HTMLElement[];\n let maxX = domRef.current.offsetWidth + 1; // + 1 to account for rounding errors\n // If any buttons have negative X positions (align=\"end\") or extend beyond\n // the width of the button group (align=\"start\"), then switch to vertical.\n if (buttonGroupChildren.some(child => child.offsetLeft < 0 || child.offsetLeft + child.offsetWidth > maxX)) {\n return true;\n }\n return false;\n }\n };\n if (orientation === 'horizontal') {\n setHasOverflow(function* () {\n // Force to horizontal for measurement.\n yield false;\n\n // Measure, and update if there is overflow.\n yield computeHasOverflow();\n });\n }\n }, [domRef, orientation, scale, setHasOverflow, children]);\n\n // There are two main reasons we need to remeasure:\n // 1. Internal changes: Check for initial overflow or when orientation/scale/children change (from checkForOverflow dep array)\n useEffect(() => {\n checkForOverflow();\n }, [checkForOverflow]);\n\n // 2. External changes: buttongroup won't change size due to any parents changing size, so listen to its container for size changes to figure out if we should remeasure\n let parent = useRef<HTMLElement>();\n useEffect(() => {\n parent.current = domRef.current.parentElement;\n }, [domRef.current]);\n useResizeObserver({ref: parent, onResize: checkForOverflow});\n\n return (\n <div\n {...filterDOMProps(otherProps)}\n {...styleProps}\n ref={domRef}\n className={\n classNames(\n styles,\n 'spectrum-ButtonGroup',\n {\n 'spectrum-ButtonGroup--vertical': orientation === 'vertical' || hasOverflow,\n 'spectrum-ButtonGroup--alignEnd': align === 'end',\n 'spectrum-ButtonGroup--alignCenter': align === 'center'\n },\n styleProps.className\n )\n }>\n <SlotProvider\n slots={{\n button: {\n UNSAFE_className: classNames(styles, 'spectrum-ButtonGroup-Button')\n }\n }}>\n <Provider isDisabled={isDisabled}>\n {children}\n </Provider>\n </SlotProvider>\n </div>\n );\n}\n\n/**\n * ButtonGroup handles overflow for a grouping of buttons whose actions are related to each other.\n */\nlet _ButtonGroup = React.forwardRef(ButtonGroup);\nexport {_ButtonGroup as ButtonGroup};\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@import './index.css';\n"],"names":[],"version":3,"file":"module.js.map"}
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;AAgHA;;GAEG;AACH,OAAA,IAAI,uJAA4C,CAAC","sources":["packages/@react-spectrum/buttongroup/src/packages/@react-spectrum/buttongroup/src/ButtonGroup.tsx","packages/@react-spectrum/buttongroup/src/packages/@react-spectrum/buttongroup/src/index.ts","packages/@react-spectrum/buttongroup/src/index.ts"],"sourcesContent":[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 * from './ButtonGroup';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-spectrum/buttongroup",
|
|
3
|
-
"version": "3.2.4-nightly.
|
|
3
|
+
"version": "3.2.4-nightly.3047+87960ad25",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -32,16 +32,16 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@babel/runtime": "^7.6.2",
|
|
35
|
-
"@react-aria/utils": "3.0.0-nightly.
|
|
36
|
-
"@react-spectrum/button": "3.0.0-nightly.
|
|
37
|
-
"@react-spectrum/text": "3.1.4-nightly.
|
|
38
|
-
"@react-spectrum/utils": "3.0.0-nightly.
|
|
39
|
-
"@react-types/buttongroup": "3.1.3-nightly.
|
|
40
|
-
"@react-types/shared": "3.0.0-nightly.
|
|
35
|
+
"@react-aria/utils": "3.0.0-nightly.1356+87960ad25",
|
|
36
|
+
"@react-spectrum/button": "3.0.0-nightly.1356+87960ad25",
|
|
37
|
+
"@react-spectrum/text": "3.1.4-nightly.3047+87960ad25",
|
|
38
|
+
"@react-spectrum/utils": "3.0.0-nightly.1356+87960ad25",
|
|
39
|
+
"@react-types/buttongroup": "3.1.3-nightly.3047+87960ad25",
|
|
40
|
+
"@react-types/shared": "3.0.0-nightly.1356+87960ad25"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@adobe/spectrum-css-temp": "3.0.0-nightly.
|
|
44
|
-
"@spectrum-icons/workflow": "3.0.0-nightly.
|
|
43
|
+
"@adobe/spectrum-css-temp": "3.0.0-nightly.1356+87960ad25",
|
|
44
|
+
"@spectrum-icons/workflow": "3.0.0-nightly.1356+87960ad25"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@react-spectrum/provider": "^3.0.0",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"publishConfig": {
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "87960ad25c26bc4cd6af506bb5e7e0f06621556c"
|
|
54
54
|
}
|
package/dist/main.css.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"AAgBA,6BACE,0BAAoB,CAApB,mBAAoB,CACpB,oBAAuB,CAAvB,sBAAuB,CAEvB,iBAiBF,CAfE,iEACE,mBAAc,CAAd,aACF,CAEA,+GACE,iEACF,CAFA,+GACE,kEACF,CAEA,mEACE,iBAAyB,CAAzB,wBACF,CAEA,sEACE,oBAAuB,CAAvB,sBACF,CAGF,uCACE,0BAAoB,CAApB,mBAAoB,CACpB,yBAAsB,CAAtB,qBAcF,CAZE,yHAEE,aACF,CAHA,yHAEE,cACF,CAHA,+GACE,gEAEF,CAEA,6EACE,kBAAqB,CAArB,oBACF,CAEA,gFACE,qBAAmB,CAAnB,kBACF","sources":["./node_modules/@adobe/spectrum-css-temp/components/buttongroup/index.css"],"sourcesContent":["/*\nCopyright 2019 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\n:root {\n --spectrum-buttongroup-button-gap-reset: 0;\n}\n\n.spectrum-ButtonGroup {\n display: inline-flex;\n align-items: flex-start;\n /* necessary so that offsetLeft on button children is correct */\n position: relative;\n\n .spectrum-ButtonGroup-Button {\n flex-shrink: 0;\n }\n\n .spectrum-ButtonGroup-Button + .spectrum-ButtonGroup-Button {\n margin-inline-start: var(--spectrum-buttongroup-button-gap-x);\n }\n\n &.spectrum-ButtonGroup--alignEnd {\n justify-content: flex-end;\n }\n\n &.spectrum-ButtonGroup--alignCenter {\n justify-content: center;\n }\n}\n\n.spectrum-ButtonGroup--vertical {\n display: inline-flex;\n flex-direction: column;\n\n .spectrum-ButtonGroup-Button + .spectrum-ButtonGroup-Button {\n margin-block-start: var(--spectrum-buttongroup-button-gap-y);\n margin-inline-start: var(--spectrum-buttongroup-button-gap-reset);\n }\n\n &.spectrum-ButtonGroup--alignEnd {\n align-items: flex-end;\n }\n\n &.spectrum-ButtonGroup--alignCenter {\n align-items: center;\n }\n}\n"],"names":[],"version":3,"file":"main.css.map"}
|