@react-spectrum/buttongroup 3.6.14-nightly.4674 → 3.6.14-nightly.4681

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.
@@ -71,7 +71,7 @@ function $d384d3249418a107$var$ButtonGroup(props, ref) {
71
71
  checkForOverflow
72
72
  ]);
73
73
  // 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
- let parent = (0, $6iGPs$react.useRef)();
74
+ let parent = (0, $6iGPs$react.useRef)(undefined);
75
75
  (0, $6iGPs$reactariautils.useLayoutEffect)(()=>{
76
76
  if (domRef.current) parent.current = domRef.current.parentElement;
77
77
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAiBD,SAAS,kCAAY,KAA+B,EAAE,GAA2B;IAC/E,IAAI,SAAC,KAAK,EAAC,GAAG,CAAA,GAAA,wCAAU;IACxB,QAAQ,CAAA,GAAA,6CAAe,EAAE;IACzB,QAAQ,CAAA,GAAA,sCAAW,EAAE,OAAO;IAE5B,IAAI,YACF,QAAQ,eACR,cAAc,0BACd,UAAU,SACV,QAAQ,SACR,GAAG,YACJ,GAAG;IAEJ,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,uCAAY,EAAE;IACjC,IAAI,SAAS,CAAA,GAAA,mCAAQ,EAAE;IACvB,IAAI,CAAC,aAAa,eAAe,GAAG,CAAA,GAAA,oCAAa,EAAE;IAEnD,IAAI,mBAAmB,CAAA,GAAA,wBAAU,EAAE;QACjC,IAAI,qBAAqB;YACvB,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,0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* 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"],"names":[],"version":3,"file":"ButtonGroup.main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAiBD,SAAS,kCAAY,KAA+B,EAAE,GAA2B;IAC/E,IAAI,SAAC,KAAK,EAAC,GAAG,CAAA,GAAA,wCAAU;IACxB,QAAQ,CAAA,GAAA,6CAAe,EAAE;IACzB,QAAQ,CAAA,GAAA,sCAAW,EAAE,OAAO;IAE5B,I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EAAE,WAAW;QAC7B,GAAG,UAAU;QACd,KAAK;QACL,WACE,CAAA,GAAA,oCAAS,EACP,CAAA,GAAA,mDAAK,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,mDAAK,GAAG;YACvC;QACF;qBACA,0DAAC,CAAA,GAAA,qCAAO;QAAE,YAAY;OACnB;AAKX;AAEA;;CAEC,GACD,IAAI,0DAAe,CAAA,GAAA,sCAAI,EAAE,UAAU,CAAC","sources":["packages/@react-spectrum/buttongroup/src/ButtonGroup.tsx"],"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\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>(undefined);\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"],"names":[],"version":3,"file":"ButtonGroup.main.js.map"}
@@ -65,7 +65,7 @@ function $bd4bfa55854eb3bf$var$ButtonGroup(props, ref) {
65
65
  checkForOverflow
66
66
  ]);
67
67
  // 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
68
- let parent = (0, $i2wAT$useRef)();
68
+ let parent = (0, $i2wAT$useRef)(undefined);
69
69
  (0, $i2wAT$useLayoutEffect)(()=>{
70
70
  if (domRef.current) parent.current = domRef.current.parentElement;
71
71
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -65,7 +65,7 @@ function $bd4bfa55854eb3bf$var$ButtonGroup(props, ref) {
65
65
  checkForOverflow
66
66
  ]);
67
67
  // 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
68
- let parent = (0, $i2wAT$useRef)();
68
+ let parent = (0, $i2wAT$useRef)(undefined);
69
69
  (0, $i2wAT$useLayoutEffect)(()=>{
70
70
  if (domRef.current) parent.current = domRef.current.parentElement;
71
71
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAiBD,SAAS,kCAAY,KAA+B,EAAE,GAA2B;IAC/E,IAAI,SAAC,KAAK,EAAC,GAAG,CAAA,GAAA,kBAAU;IACxB,QAAQ,CAAA,GAAA,uBAAe,EAAE;IACzB,QAAQ,CAAA,GAAA,mBAAW,EAAE,OAAO;IAE5B,IAAI,YACF,QAAQ,eACR,cAAc,0BACd,UAAU,SACV,QAAQ,SACR,GAAG,YAC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ACP,CAAA,GAAA,6DAAK,GACL,wBACA;YACE,kCAAkC,gBAAgB,cAAc;YAChE,kCAAkC,UAAU;YAC5C,qCAAqC,UAAU;QACjD,GACA,WAAW,SAAS;qBAGxB,gCAAC,CAAA,GAAA,mBAAW;QACV,OAAO;YACL,QAAQ;gBACN,kBAAkB,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,6DAAK,GAAG;YACvC;QACF;qBACA,gCAAC,CAAA,GAAA,eAAO;QAAE,YAAY;OACnB;AAKX;AAEA;;CAEC,GACD,IAAI,0DAAe,CAAA,GAAA,YAAI,EAAE,UAAU,CAAC","sources":["packages/@react-spectrum/buttongroup/src/ButtonGroup.tsx"],"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\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"],"names":[],"version":3,"file":"ButtonGroup.module.js.map"}
1
+ {"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAiBD,SAAS,kCAAY,KAA+B,EAAE,GAA2B;IAC/E,IAAI,SAAC,KAAK,EAAC,GAAG,CAAA,GAAA,kBAAU;IACxB,QAAQ,CAAA,GAAA,uBAAe,EAAE;IACzB,QAAQ,CAAA,GAAA,mBAAW,EAAE,OAAO;IAE5B,IAAI,YACF,QAAQ,eACR,cAAc,0BACd,UAAU,SACV,QAAQ,SACR,GAAG,YACJ,GAAG;IAEJ,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,oBAAY,EAAE;IACjC,IAAI,SAAS,CAAA,GAAA,gBAAQ,EAAE;IACvB,IAAI,CAAC,aAAa,eAAe,GAAG,CAAA,GAAA,qBAAa,EAAE;IAEnD,IAAI,mBAAmB,CAAA,GAAA,kBAAU,EAAE;QACjC,IAAI,qBAAqB;YACvB,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,IAAI,oBAAoB,IAAI,CAAC,CAAA,QAAS,MAAM,UAAU,GAAG,KAAK,MAAM,UAAU,GAAG,MAAM,WAAW,GAAG,OACnG,OAAO;gBAET,OAAO;YACT;QACF;QACA,IAAI,gBAAgB,cAClB,eAAe;YACb,uCAAuC;YACvC,MAAM;YAEN,4CAA4C;YAC5C,MAAM;QACR;IAEJ,uDAAuD;IACvD,GAAG;QAAC;QAAQ;QAAa;QAAO;QAAgB;KAAS;IAEzD,mDAAmD;IACnD,8HAA8H;IAC9H,CAAA,GAAA,sBAAc,EAAE;QACd;IACF,GAAG;QAAC;KAAiB;IAErB,wKAAwK;IACxK,IAAI,SAAS,CAAA,GAAA,aAAK,EAAe;IACjC,CAAA,GAAA,sBAAc,EAAE;QACd,IAAI,OAAO,OAAO,EAChB,OAAO,OAAO,GAAG,OAAO,OAAO,CAAC,aAAa;IAEjD,uDAAuD;IACvD,GAAG;QAAC,OAAO,OAAO;KAAC;IACnB,CAAA,GAAA,wBAAgB,EAAE;QAAC,KAAK;QAAQ,UAAU;IAAgB;IAE1D,qBACE,gCAAC;QACE,GAAG,CAAA,GAAA,qBAAa,EAAE,WAAW;QAC7B,GAAG,UAAU;QACd,KAAK;QACL,WACE,CAAA,GAAA,iBAAS,EACP,CAAA,GAAA,6DAAK,GACL,wBACA;YACE,kCAAkC,gBAAgB,cAAc;YAChE,kCAAkC,UAAU;YAC5C,qCAAqC,UAAU;QACjD,GACA,WAAW,SAAS;qBAGxB,gCAAC,CAAA,GAAA,mBAAW;QACV,OAAO;YACL,QAAQ;gBACN,kBAAkB,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,6DAAK,GAAG;YACvC;QACF;qBACA,gCAAC,CAAA,GAAA,eAAO;QAAE,YAAY;OACnB;AAKX;AAEA;;CAEC,GACD,IAAI,0DAAe,CAAA,GAAA,YAAI,EAAE,UAAU,CAAC","sources":["packages/@react-spectrum/buttongroup/src/ButtonGroup.tsx"],"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\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>(undefined);\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"],"names":[],"version":3,"file":"ButtonGroup.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-spectrum/buttongroup",
3
- "version": "3.6.14-nightly.4674+59136f78e",
3
+ "version": "3.6.14-nightly.4681+2fd87d9f1",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -36,22 +36,22 @@
36
36
  "url": "https://github.com/adobe/react-spectrum"
37
37
  },
38
38
  "dependencies": {
39
- "@react-aria/utils": "3.0.0-nightly.2962+59136f78e",
40
- "@react-spectrum/utils": "3.0.0-nightly.2962+59136f78e",
41
- "@react-types/buttongroup": "3.3.10-nightly.4674+59136f78e",
42
- "@react-types/shared": "3.0.0-nightly.2962+59136f78e",
39
+ "@react-aria/utils": "3.0.0-nightly.2969+2fd87d9f1",
40
+ "@react-spectrum/utils": "3.0.0-nightly.2969+2fd87d9f1",
41
+ "@react-types/buttongroup": "3.3.10-nightly.4681+2fd87d9f1",
42
+ "@react-types/shared": "3.0.0-nightly.2969+2fd87d9f1",
43
43
  "@swc/helpers": "^0.5.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@adobe/spectrum-css-temp": "3.0.0-nightly.2962+59136f78e",
47
- "@spectrum-icons/workflow": "3.0.0-nightly.2962+59136f78e"
46
+ "@adobe/spectrum-css-temp": "3.0.0-nightly.2969+2fd87d9f1",
47
+ "@spectrum-icons/workflow": "3.0.0-nightly.2969+2fd87d9f1"
48
48
  },
49
49
  "peerDependencies": {
50
50
  "@react-spectrum/provider": "^3.0.0",
51
- "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
51
+ "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
52
52
  },
53
53
  "publishConfig": {
54
54
  "access": "public"
55
55
  },
56
- "gitHead": "59136f78e853e97bb4067a1268750c9f85900bf6"
56
+ "gitHead": "2fd87d9f1d894e6b00a595cce73c6e8828029132"
57
57
  }
@@ -74,7 +74,7 @@ function ButtonGroup(props: SpectrumButtonGroupProps, ref: DOMRef<HTMLDivElement
74
74
  }, [checkForOverflow]);
75
75
 
76
76
  // 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
77
- let parent = useRef<HTMLElement>();
77
+ let parent = useRef<HTMLElement>(undefined);
78
78
  useLayoutEffect(() => {
79
79
  if (domRef.current) {
80
80
  parent.current = domRef.current.parentElement as HTMLElement;