@react-spectrum/buttongroup 3.5.1-nightly.3599 → 3.5.1-nightly.3603

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.js CHANGED
@@ -12,7 +12,28 @@ function $parcel$interopDefault(a) {
12
12
  }
13
13
 
14
14
  $parcel$export(module.exports, "ButtonGroup", () => $d384d3249418a107$export$69b1032f2ecdf404);
15
-
15
+ /*
16
+ * Copyright 2020 Adobe. All rights reserved.
17
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
18
+ * you may not use this file except in compliance with the License. You may obtain a copy
19
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
20
+ *
21
+ * Unless required by applicable law or agreed to in writing, software distributed under
22
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
23
+ * OF ANY KIND, either express or implied. See the License for the specific language
24
+ * governing permissions and limitations under the License.
25
+ */ /// <reference types="css-module-types" />
26
+ /*
27
+ * Copyright 2020 Adobe. All rights reserved.
28
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
29
+ * you may not use this file except in compliance with the License. You may obtain a copy
30
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
31
+ *
32
+ * Unless required by applicable law or agreed to in writing, software distributed under
33
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
34
+ * OF ANY KIND, either express or implied. See the License for the specific language
35
+ * governing permissions and limitations under the License.
36
+ */
16
37
 
17
38
 
18
39
 
@@ -36,26 +57,25 @@ $2e9803b3bbead7d0$export$84d9c0e1917a4eaf = "spectrum-ButtonGroup--vertical_b10c
36
57
 
37
58
 
38
59
  function $d384d3249418a107$var$ButtonGroup(props, ref) {
39
- let { scale: scale } = $fJaYF$reactspectrumprovider.useProvider();
40
- props = $fJaYF$reactspectrumprovider.useProviderProps(props);
41
- props = $fJaYF$reactspectrumutils.useSlotProps(props, 'buttonGroup');
42
- let { children: children , orientation: orientation = 'horizontal' , isDisabled: isDisabled , align: align = 'start' , ...otherProps } = props;
43
- let { styleProps: styleProps } = $fJaYF$reactspectrumutils.useStyleProps(otherProps);
44
- let domRef = $fJaYF$reactspectrumutils.useDOMRef(ref);
45
- let [hasOverflow, setHasOverflow] = $fJaYF$reactariautils.useValueEffect(false);
46
- let checkForOverflow = $fJaYF$react.useCallback(()=>{
60
+ let { scale: scale } = (0, $fJaYF$reactspectrumprovider.useProvider)();
61
+ props = (0, $fJaYF$reactspectrumprovider.useProviderProps)(props);
62
+ props = (0, $fJaYF$reactspectrumutils.useSlotProps)(props, "buttonGroup");
63
+ let { children: children , orientation: orientation = "horizontal" , isDisabled: isDisabled , align: align = "start" , ...otherProps } = props;
64
+ let { styleProps: styleProps } = (0, $fJaYF$reactspectrumutils.useStyleProps)(otherProps);
65
+ let domRef = (0, $fJaYF$reactspectrumutils.useDOMRef)(ref);
66
+ let [hasOverflow, setHasOverflow] = (0, $fJaYF$reactariautils.useValueEffect)(false);
67
+ let checkForOverflow = (0, $fJaYF$react.useCallback)(()=>{
47
68
  let computeHasOverflow = ()=>{
48
- if (domRef.current && orientation === 'horizontal') {
69
+ if (domRef.current && orientation === "horizontal") {
49
70
  let buttonGroupChildren = Array.from(domRef.current.children);
50
71
  let maxX = domRef.current.offsetWidth + 1; // + 1 to account for rounding errors
51
72
  // If any buttons have negative X positions (align="end") or extend beyond
52
73
  // the width of the button group (align="start"), then switch to vertical.
53
- if (buttonGroupChildren.some((child)=>child.offsetLeft < 0 || child.offsetLeft + child.offsetWidth > maxX
54
- )) return true;
74
+ if (buttonGroupChildren.some((child)=>child.offsetLeft < 0 || child.offsetLeft + child.offsetWidth > maxX)) return true;
55
75
  return false;
56
76
  }
57
77
  };
58
- if (orientation === 'horizontal') setHasOverflow(function*() {
78
+ if (orientation === "horizontal") setHasOverflow(function*() {
59
79
  // Force to horizontal for measurement.
60
80
  yield false;
61
81
  // Measure, and update if there is overflow.
@@ -71,45 +91,45 @@ function $d384d3249418a107$var$ButtonGroup(props, ref) {
71
91
  ]);
72
92
  // There are two main reasons we need to remeasure:
73
93
  // 1. Internal changes: Check for initial overflow or when orientation/scale/children change (from checkForOverflow dep array)
74
- $fJaYF$reactariautils.useLayoutEffect(()=>{
94
+ (0, $fJaYF$reactariautils.useLayoutEffect)(()=>{
75
95
  checkForOverflow();
76
96
  }, [
77
97
  checkForOverflow
78
98
  ]);
79
99
  // 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 = $fJaYF$react.useRef();
81
- $fJaYF$reactariautils.useLayoutEffect(()=>{
100
+ let parent = (0, $fJaYF$react.useRef)();
101
+ (0, $fJaYF$reactariautils.useLayoutEffect)(()=>{
82
102
  if (domRef.current) parent.current = domRef.current.parentElement;
83
103
  // eslint-disable-next-line react-hooks/exhaustive-deps
84
104
  }, [
85
105
  domRef.current
86
106
  ]);
87
- $fJaYF$reactspectrumutils.useResizeObserver({
107
+ (0, $fJaYF$reactspectrumutils.useResizeObserver)({
88
108
  ref: parent,
89
109
  onResize: checkForOverflow
90
110
  });
91
- return(/*#__PURE__*/ ($parcel$interopDefault($fJaYF$react)).createElement("div", {
92
- ...$fJaYF$reactariautils.filterDOMProps(otherProps),
111
+ return /*#__PURE__*/ (0, ($parcel$interopDefault($fJaYF$react))).createElement("div", {
112
+ ...(0, $fJaYF$reactariautils.filterDOMProps)(otherProps),
93
113
  ...styleProps,
94
114
  ref: domRef,
95
- className: $fJaYF$reactspectrumutils.classNames((/*@__PURE__*/$parcel$interopDefault($2e9803b3bbead7d0$exports)), 'spectrum-ButtonGroup', {
96
- 'spectrum-ButtonGroup--vertical': orientation === 'vertical' || hasOverflow,
97
- 'spectrum-ButtonGroup--alignEnd': align === 'end',
98
- 'spectrum-ButtonGroup--alignCenter': align === 'center'
115
+ className: (0, $fJaYF$reactspectrumutils.classNames)((0, (/*@__PURE__*/$parcel$interopDefault($2e9803b3bbead7d0$exports))), "spectrum-ButtonGroup", {
116
+ "spectrum-ButtonGroup--vertical": orientation === "vertical" || hasOverflow,
117
+ "spectrum-ButtonGroup--alignEnd": align === "end",
118
+ "spectrum-ButtonGroup--alignCenter": align === "center"
99
119
  }, styleProps.className)
100
- }, /*#__PURE__*/ ($parcel$interopDefault($fJaYF$react)).createElement($fJaYF$reactspectrumutils.SlotProvider, {
120
+ }, /*#__PURE__*/ (0, ($parcel$interopDefault($fJaYF$react))).createElement((0, $fJaYF$reactspectrumutils.SlotProvider), {
101
121
  slots: {
102
122
  button: {
103
- UNSAFE_className: $fJaYF$reactspectrumutils.classNames((/*@__PURE__*/$parcel$interopDefault($2e9803b3bbead7d0$exports)), 'spectrum-ButtonGroup-Button')
123
+ UNSAFE_className: (0, $fJaYF$reactspectrumutils.classNames)((0, (/*@__PURE__*/$parcel$interopDefault($2e9803b3bbead7d0$exports))), "spectrum-ButtonGroup-Button")
104
124
  }
105
125
  }
106
- }, /*#__PURE__*/ ($parcel$interopDefault($fJaYF$react)).createElement($fJaYF$reactspectrumprovider.Provider, {
126
+ }, /*#__PURE__*/ (0, ($parcel$interopDefault($fJaYF$react))).createElement((0, $fJaYF$reactspectrumprovider.Provider), {
107
127
  isDisabled: isDisabled
108
- }, children))));
128
+ }, children)));
109
129
  }
110
130
  /**
111
131
  * ButtonGroup handles overflow for a grouping of buttons whose actions are related to each other.
112
- */ let $d384d3249418a107$export$69b1032f2ecdf404 = /*#__PURE__*/ ($parcel$interopDefault($fJaYF$react)).forwardRef($d384d3249418a107$var$ButtonGroup);
132
+ */ let $d384d3249418a107$export$69b1032f2ecdf404 = /*#__PURE__*/ (0, ($parcel$interopDefault($fJaYF$react))).forwardRef($d384d3249418a107$var$ButtonGroup);
113
133
 
114
134
 
115
135
 
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AEAA,GAAsC;AACtC,GAA6C;AAC7C,GAAgD;AAChD,GAAmD;AACnD,GAAgD;AAJhD,yCAAsC,GA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;YACN,MAAM,EAAE,CAAC;gBACP,gBAAgB,EAAE,oCAAU,CAAC,gEAAM,EAAE,CAA6B;YACpE,CAAC;QACH,CAAC;0EACA,qCAAQ;QAAC,UAAU,EAAE,UAAU;OAC7B,QAAQ;AAKnB,CAAC;AAED,EAEG,AAFH;;CAEG,AAFH,EAEG,CACH,GAAG,CAAC,yCAAY,iBAAG,sCAAK,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/// <reference types=\"css-module-types\" />\nexport {ButtonGroup} from './ButtonGroup';\nexport type {SpectrumButtonGroupProps} from '@react-types/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, useLayoutEffect, useValueEffect} from '@react-aria/utils';\nimport {Provider, useProvider, useProviderProps} from '@react-spectrum/provider';\nimport React, {useCallback, 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 // eslint-disable-next-line react-hooks/exhaustive-deps\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 useLayoutEffect(() => {\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 useLayoutEffect(() => {\n if (domRef.current) {\n parent.current = domRef.current.parentElement as HTMLElement;\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\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"}
1
+ {"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC,GACD,0CAA0C;ACX1C;;;;;;;;;;CAUC,GAED;;;;;;;;;;;ACZA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AAJA,4CAAyC;AACzC,4CAAgD;AAChD,4CAAmD;AACnD,2CAAsD;AACtD,4CAAmD;;;ADuBnD,SAAS,kCAAY,KAA+B,EAAE,GAA2B,EAAE;IACjF,IAAI,SAAC,MAAK,EAAC,GAAG,CAAA,GAAA,wCAAW,AAAD;IACxB,QAAQ,CAAA,GAAA,6CAAe,EAAE;IACzB,QAAQ,CAAA,GAAA,sCAAY,AAAD,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,GAAA,2CAAiB,AAAD,EAAE;QAAC,KAAK;QAAQ,UAAU;IAAgB;IAE1D,qBACE,0DAAC;QACE,GAAG,CAAA,GAAA,oCAAc,AAAD,EAAE,WAAW;QAC7B,GAAG,UAAU;QACd,KAAK;QACL,WACE,CAAA,GAAA,oCAAS,EACP,CAAA,GAAA,yDAAM,OAAD,GACL,wBACA;YACE,kCAAkC,gBAAgB,cAAc;YAChE,kCAAkC,UAAU;YAC5C,qCAAqC,UAAU;QACjD,GACA,WAAW,SAAS;qBAGxB,0DAAC,CAAA,GAAA,sCAAW;QACV,OAAO;YACL,QAAQ;gBACN,kBAAkB,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,gEAAM,AAAD,GAAG;YACvC;QACF;qBACA,0DAAC,CAAA,GAAA,qCAAO;QAAE,YAAY;OACnB;AAKX;AAEA;;CAEC,GACD,IAAI,0DAAe,CAAA,GAAA,sCAAI,EAAE,UAAU,CAAC;;AD3GpC","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/// <reference types=\"css-module-types\" />\nexport {ButtonGroup} from './ButtonGroup';\nexport type {SpectrumButtonGroupProps} from '@react-types/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, useLayoutEffect, useValueEffect} from '@react-aria/utils';\nimport {Provider, useProvider, useProviderProps} from '@react-spectrum/provider';\nimport React, {useCallback, 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 // eslint-disable-next-line react-hooks/exhaustive-deps\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 useLayoutEffect(() => {\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 useLayoutEffect(() => {\n if (domRef.current) {\n parent.current = domRef.current.parentElement as HTMLElement;\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\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.mjs CHANGED
@@ -10,7 +10,28 @@ function $parcel$interopDefault(a) {
10
10
  function $parcel$export(e, n, v, s) {
11
11
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
12
12
  }
13
-
13
+ /*
14
+ * Copyright 2020 Adobe. All rights reserved.
15
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
16
+ * you may not use this file except in compliance with the License. You may obtain a copy
17
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
18
+ *
19
+ * Unless required by applicable law or agreed to in writing, software distributed under
20
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
21
+ * OF ANY KIND, either express or implied. See the License for the specific language
22
+ * governing permissions and limitations under the License.
23
+ */ /// <reference types="css-module-types" />
24
+ /*
25
+ * Copyright 2020 Adobe. All rights reserved.
26
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
27
+ * you may not use this file except in compliance with the License. You may obtain a copy
28
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
29
+ *
30
+ * Unless required by applicable law or agreed to in writing, software distributed under
31
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
32
+ * OF ANY KIND, either express or implied. See the License for the specific language
33
+ * governing permissions and limitations under the License.
34
+ */
14
35
 
15
36
 
16
37
 
@@ -34,26 +55,25 @@ $fddc5368d2db28a6$export$84d9c0e1917a4eaf = "spectrum-ButtonGroup--vertical_b10c
34
55
 
35
56
 
36
57
  function $bd4bfa55854eb3bf$var$ButtonGroup(props, ref) {
37
- let { scale: scale } = $3Yfv0$useProvider();
38
- props = $3Yfv0$useProviderProps(props);
39
- props = $3Yfv0$useSlotProps(props, 'buttonGroup');
40
- let { children: children , orientation: orientation = 'horizontal' , isDisabled: isDisabled , align: align = 'start' , ...otherProps } = props;
41
- let { styleProps: styleProps } = $3Yfv0$useStyleProps(otherProps);
42
- let domRef = $3Yfv0$useDOMRef(ref);
43
- let [hasOverflow, setHasOverflow] = $3Yfv0$useValueEffect(false);
44
- let checkForOverflow = $3Yfv0$useCallback(()=>{
58
+ let { scale: scale } = (0, $3Yfv0$useProvider)();
59
+ props = (0, $3Yfv0$useProviderProps)(props);
60
+ props = (0, $3Yfv0$useSlotProps)(props, "buttonGroup");
61
+ let { children: children , orientation: orientation = "horizontal" , isDisabled: isDisabled , align: align = "start" , ...otherProps } = props;
62
+ let { styleProps: styleProps } = (0, $3Yfv0$useStyleProps)(otherProps);
63
+ let domRef = (0, $3Yfv0$useDOMRef)(ref);
64
+ let [hasOverflow, setHasOverflow] = (0, $3Yfv0$useValueEffect)(false);
65
+ let checkForOverflow = (0, $3Yfv0$useCallback)(()=>{
45
66
  let computeHasOverflow = ()=>{
46
- if (domRef.current && orientation === 'horizontal') {
67
+ if (domRef.current && orientation === "horizontal") {
47
68
  let buttonGroupChildren = Array.from(domRef.current.children);
48
69
  let maxX = domRef.current.offsetWidth + 1; // + 1 to account for rounding errors
49
70
  // If any buttons have negative X positions (align="end") or extend beyond
50
71
  // the width of the button group (align="start"), then switch to vertical.
51
- if (buttonGroupChildren.some((child)=>child.offsetLeft < 0 || child.offsetLeft + child.offsetWidth > maxX
52
- )) return true;
72
+ if (buttonGroupChildren.some((child)=>child.offsetLeft < 0 || child.offsetLeft + child.offsetWidth > maxX)) return true;
53
73
  return false;
54
74
  }
55
75
  };
56
- if (orientation === 'horizontal') setHasOverflow(function*() {
76
+ if (orientation === "horizontal") setHasOverflow(function*() {
57
77
  // Force to horizontal for measurement.
58
78
  yield false;
59
79
  // Measure, and update if there is overflow.
@@ -69,45 +89,45 @@ function $bd4bfa55854eb3bf$var$ButtonGroup(props, ref) {
69
89
  ]);
70
90
  // There are two main reasons we need to remeasure:
71
91
  // 1. Internal changes: Check for initial overflow or when orientation/scale/children change (from checkForOverflow dep array)
72
- $3Yfv0$useLayoutEffect(()=>{
92
+ (0, $3Yfv0$useLayoutEffect)(()=>{
73
93
  checkForOverflow();
74
94
  }, [
75
95
  checkForOverflow
76
96
  ]);
77
97
  // 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
78
- let parent = $3Yfv0$useRef();
79
- $3Yfv0$useLayoutEffect(()=>{
98
+ let parent = (0, $3Yfv0$useRef)();
99
+ (0, $3Yfv0$useLayoutEffect)(()=>{
80
100
  if (domRef.current) parent.current = domRef.current.parentElement;
81
101
  // eslint-disable-next-line react-hooks/exhaustive-deps
82
102
  }, [
83
103
  domRef.current
84
104
  ]);
85
- $3Yfv0$useResizeObserver({
105
+ (0, $3Yfv0$useResizeObserver)({
86
106
  ref: parent,
87
107
  onResize: checkForOverflow
88
108
  });
89
- return(/*#__PURE__*/ $3Yfv0$react.createElement("div", {
90
- ...$3Yfv0$filterDOMProps(otherProps),
109
+ return /*#__PURE__*/ (0, $3Yfv0$react).createElement("div", {
110
+ ...(0, $3Yfv0$filterDOMProps)(otherProps),
91
111
  ...styleProps,
92
112
  ref: domRef,
93
- className: $3Yfv0$classNames((/*@__PURE__*/$parcel$interopDefault($fddc5368d2db28a6$exports)), 'spectrum-ButtonGroup', {
94
- 'spectrum-ButtonGroup--vertical': orientation === 'vertical' || hasOverflow,
95
- 'spectrum-ButtonGroup--alignEnd': align === 'end',
96
- 'spectrum-ButtonGroup--alignCenter': align === 'center'
113
+ className: (0, $3Yfv0$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($fddc5368d2db28a6$exports))), "spectrum-ButtonGroup", {
114
+ "spectrum-ButtonGroup--vertical": orientation === "vertical" || hasOverflow,
115
+ "spectrum-ButtonGroup--alignEnd": align === "end",
116
+ "spectrum-ButtonGroup--alignCenter": align === "center"
97
117
  }, styleProps.className)
98
- }, /*#__PURE__*/ $3Yfv0$react.createElement($3Yfv0$SlotProvider, {
118
+ }, /*#__PURE__*/ (0, $3Yfv0$react).createElement((0, $3Yfv0$SlotProvider), {
99
119
  slots: {
100
120
  button: {
101
- UNSAFE_className: $3Yfv0$classNames((/*@__PURE__*/$parcel$interopDefault($fddc5368d2db28a6$exports)), 'spectrum-ButtonGroup-Button')
121
+ UNSAFE_className: (0, $3Yfv0$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($fddc5368d2db28a6$exports))), "spectrum-ButtonGroup-Button")
102
122
  }
103
123
  }
104
- }, /*#__PURE__*/ $3Yfv0$react.createElement($3Yfv0$Provider, {
124
+ }, /*#__PURE__*/ (0, $3Yfv0$react).createElement((0, $3Yfv0$Provider), {
105
125
  isDisabled: isDisabled
106
- }, children))));
126
+ }, children)));
107
127
  }
108
128
  /**
109
129
  * ButtonGroup handles overflow for a grouping of buttons whose actions are related to each other.
110
- */ let $bd4bfa55854eb3bf$export$69b1032f2ecdf404 = /*#__PURE__*/ $3Yfv0$react.forwardRef($bd4bfa55854eb3bf$var$ButtonGroup);
130
+ */ let $bd4bfa55854eb3bf$export$69b1032f2ecdf404 = /*#__PURE__*/ (0, $3Yfv0$react).forwardRef($bd4bfa55854eb3bf$var$ButtonGroup);
111
131
 
112
132
 
113
133
 
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;AEAA,GAAsC;AACtC,GAA6C;AAC7C,GAAgD;AAChD,GAAmD;AACnD,GAAgD;AAJhD,yCAAsC,GAAG,CAA6B;AACtE,yCAA6C,GAAG,CAAoC;AACpF,yCAAgD,GAAG,CAAuC;AAC1F,wCAAmD,GAAG,CAA0C;AAChG,yCAAgD,GAAG,CAAuC;;;SDuBjF,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,gB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M,GAAG,aAAM;IACnB,sBAAe,KAAO,CAAC;QACrB,EAAE,EAAE,MAAM,CAAC,OAAO,EAChB,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,aAAa;IAEjD,EAAuD,AAAvD,qDAAuD;IACvD,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/// <reference types=\"css-module-types\" />\nexport {ButtonGroup} from './ButtonGroup';\nexport type {SpectrumButtonGroupProps} from '@react-types/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, useLayoutEffect, useValueEffect} from '@react-aria/utils';\nimport {Provider, useProvider, useProviderProps} from '@react-spectrum/provider';\nimport React, {useCallback, 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 // eslint-disable-next-line react-hooks/exhaustive-deps\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 useLayoutEffect(() => {\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 useLayoutEffect(() => {\n if (domRef.current) {\n parent.current = domRef.current.parentElement as HTMLElement;\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\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.mjs.map"}
1
+ {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC,GACD,0CAA0C;ACX1C;;;;;;;;;;CAUC,GAED;;;;;;;;;;;ACZA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AAJA,4CAAyC;AACzC,4CAAgD;AAChD,4CAAmD;AACnD,2CAAsD;AACtD,4CAAmD;;;ADuBnD,SAAS,kCAAY,KAA+B,EAAE,GAA2B,EAAE;IACjF,IAAI,SAAC,MAAK,EAAC,GAAG,CAAA,GAAA,kBAAW,AAAD;IACxB,QAAQ,CAAA,GAAA,uBAAe,EAAE;IACzB,QAAQ,CAAA,GAAA,mBAAY,AAAD,EAAE,OAAO;IAE5B,IAAI,YACF,SAAQ,eACR,cAAc,2BACd,WAAU,SACV,QAAQ,UACR,GAAG,YACJ,GAAG;IAEJ,IAAI,cAAC,WAAU,EAAC,GAAG,CAAA,GAAA,oBAAa,AAAD,EAAE;IACjC,IAAI,SAAS,CAAA,GAAA,gBAAQ,EAAE;IACvB,IAAI,CAAC,aAAa,eAAe,GAAG,CAAA,GAAA,qBAAa,EAAE,KAAK;IAExD,IAAI,mBAAmB,CAAA,GAAA,kBAAU,EAAE,IAAM;QACvC,IAAI,qBAAqB,IAAM;YAC7B,IAAI,OAAO,OAAO,IAAI,gBAAgB,cAAc;gBAClD,IAAI,sBAAsB,MAAM,IAAI,CAAC,OAAO,OAAO,CAAC,QAAQ;gBAC5D,IAAI,OAAO,OAAO,OAAO,CAAC,WAAW,GAAG,GAAG,qCAAqC;gBAChF,0EAA0E;gBAC1E,0EAA0E;gBAC1E,IA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AU,CAAC;;AD3GpC","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/// <reference types=\"css-module-types\" />\nexport {ButtonGroup} from './ButtonGroup';\nexport type {SpectrumButtonGroupProps} from '@react-types/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, useLayoutEffect, useValueEffect} from '@react-aria/utils';\nimport {Provider, useProvider, useProviderProps} from '@react-spectrum/provider';\nimport React, {useCallback, 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 // eslint-disable-next-line react-hooks/exhaustive-deps\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 useLayoutEffect(() => {\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 useLayoutEffect(() => {\n if (domRef.current) {\n parent.current = domRef.current.parentElement as HTMLElement;\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\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.mjs.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-spectrum/buttongroup",
3
- "version": "3.5.1-nightly.3599+b35d5c02f",
3
+ "version": "3.5.1-nightly.3603+22cb32d32",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -36,17 +36,17 @@
36
36
  "url": "https://github.com/adobe/react-spectrum"
37
37
  },
38
38
  "dependencies": {
39
- "@babel/runtime": "^7.6.2",
40
- "@react-aria/utils": "3.0.0-nightly.1899+b35d5c02f",
41
- "@react-spectrum/button": "3.0.0-nightly.1899+b35d5c02f",
42
- "@react-spectrum/text": "3.3.4-nightly.3599+b35d5c02f",
43
- "@react-spectrum/utils": "3.0.0-nightly.1899+b35d5c02f",
44
- "@react-types/buttongroup": "3.2.6-nightly.3599+b35d5c02f",
45
- "@react-types/shared": "3.0.0-nightly.1899+b35d5c02f"
39
+ "@react-aria/utils": "3.0.0-nightly.1903+22cb32d32",
40
+ "@react-spectrum/button": "3.0.0-nightly.1903+22cb32d32",
41
+ "@react-spectrum/text": "3.3.4-nightly.3603+22cb32d32",
42
+ "@react-spectrum/utils": "3.0.0-nightly.1903+22cb32d32",
43
+ "@react-types/buttongroup": "3.2.6-nightly.3603+22cb32d32",
44
+ "@react-types/shared": "3.0.0-nightly.1903+22cb32d32",
45
+ "@swc/helpers": "^0.4.14"
46
46
  },
47
47
  "devDependencies": {
48
- "@adobe/spectrum-css-temp": "3.0.0-nightly.1899+b35d5c02f",
49
- "@spectrum-icons/workflow": "3.0.0-nightly.1899+b35d5c02f"
48
+ "@adobe/spectrum-css-temp": "3.0.0-nightly.1903+22cb32d32",
49
+ "@spectrum-icons/workflow": "3.0.0-nightly.1903+22cb32d32"
50
50
  },
51
51
  "peerDependencies": {
52
52
  "@react-spectrum/provider": "^3.0.0",
@@ -55,5 +55,5 @@
55
55
  "publishConfig": {
56
56
  "access": "public"
57
57
  },
58
- "gitHead": "b35d5c02fe900badccd0cf1a8f23bb593419f238"
58
+ "gitHead": "22cb32d329e66c60f55d4fc4025d1d44bb015d71"
59
59
  }