@react-spectrum/buttongroup 3.5.3-nightly.3698 → 3.5.3-nightly.3709

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.
Files changed (2) hide show
  1. package/dist/import.mjs +136 -0
  2. package/package.json +15 -10
@@ -0,0 +1,136 @@
1
+ import "./main.css";
2
+ import {useSlotProps as $3Yfv0$useSlotProps, useStyleProps as $3Yfv0$useStyleProps, useDOMRef as $3Yfv0$useDOMRef, useResizeObserver as $3Yfv0$useResizeObserver, classNames as $3Yfv0$classNames, SlotProvider as $3Yfv0$SlotProvider} from "@react-spectrum/utils";
3
+ import {useValueEffect as $3Yfv0$useValueEffect, useLayoutEffect as $3Yfv0$useLayoutEffect, filterDOMProps as $3Yfv0$filterDOMProps} from "@react-aria/utils";
4
+ import {useProvider as $3Yfv0$useProvider, useProviderProps as $3Yfv0$useProviderProps, Provider as $3Yfv0$Provider} from "@react-spectrum/provider";
5
+ import $3Yfv0$react, {useCallback as $3Yfv0$useCallback, useRef as $3Yfv0$useRef} from "react";
6
+
7
+ function $parcel$interopDefault(a) {
8
+ return a && a.__esModule ? a.default : a;
9
+ }
10
+ function $parcel$export(e, n, v, s) {
11
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
12
+ }
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
+ */
35
+
36
+
37
+
38
+ var $fddc5368d2db28a6$exports = {};
39
+
40
+ $parcel$export($fddc5368d2db28a6$exports, "spectrum-ButtonGroup", () => $fddc5368d2db28a6$export$a92faf51352ac608, (v) => $fddc5368d2db28a6$export$a92faf51352ac608 = v);
41
+ $parcel$export($fddc5368d2db28a6$exports, "spectrum-ButtonGroup-Button", () => $fddc5368d2db28a6$export$7184de2337c1927f, (v) => $fddc5368d2db28a6$export$7184de2337c1927f = v);
42
+ $parcel$export($fddc5368d2db28a6$exports, "spectrum-ButtonGroup--alignEnd", () => $fddc5368d2db28a6$export$30e96c53d7beca11, (v) => $fddc5368d2db28a6$export$30e96c53d7beca11 = v);
43
+ $parcel$export($fddc5368d2db28a6$exports, "spectrum-ButtonGroup--alignCenter", () => $fddc5368d2db28a6$export$252bc7c4ae05757, (v) => $fddc5368d2db28a6$export$252bc7c4ae05757 = v);
44
+ $parcel$export($fddc5368d2db28a6$exports, "spectrum-ButtonGroup--vertical", () => $fddc5368d2db28a6$export$84d9c0e1917a4eaf, (v) => $fddc5368d2db28a6$export$84d9c0e1917a4eaf = v);
45
+ var $fddc5368d2db28a6$export$a92faf51352ac608;
46
+ var $fddc5368d2db28a6$export$7184de2337c1927f;
47
+ var $fddc5368d2db28a6$export$30e96c53d7beca11;
48
+ var $fddc5368d2db28a6$export$252bc7c4ae05757;
49
+ var $fddc5368d2db28a6$export$84d9c0e1917a4eaf;
50
+ $fddc5368d2db28a6$export$a92faf51352ac608 = "spectrum-ButtonGroup_b10c2f";
51
+ $fddc5368d2db28a6$export$7184de2337c1927f = "spectrum-ButtonGroup-Button_b10c2f";
52
+ $fddc5368d2db28a6$export$30e96c53d7beca11 = "spectrum-ButtonGroup--alignEnd_b10c2f";
53
+ $fddc5368d2db28a6$export$252bc7c4ae05757 = "spectrum-ButtonGroup--alignCenter_b10c2f";
54
+ $fddc5368d2db28a6$export$84d9c0e1917a4eaf = "spectrum-ButtonGroup--vertical_b10c2f";
55
+
56
+
57
+ function $bd4bfa55854eb3bf$var$ButtonGroup(props, ref) {
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)(()=>{
66
+ let computeHasOverflow = ()=>{
67
+ if (domRef.current && orientation === "horizontal") {
68
+ let buttonGroupChildren = Array.from(domRef.current.children);
69
+ let maxX = domRef.current.offsetWidth + 1; // + 1 to account for rounding errors
70
+ // If any buttons have negative X positions (align="end") or extend beyond
71
+ // the width of the button group (align="start"), then switch to vertical.
72
+ if (buttonGroupChildren.some((child)=>child.offsetLeft < 0 || child.offsetLeft + child.offsetWidth > maxX)) return true;
73
+ return false;
74
+ }
75
+ };
76
+ if (orientation === "horizontal") setHasOverflow(function*() {
77
+ // Force to horizontal for measurement.
78
+ yield false;
79
+ // Measure, and update if there is overflow.
80
+ yield computeHasOverflow();
81
+ });
82
+ // eslint-disable-next-line react-hooks/exhaustive-deps
83
+ }, [
84
+ domRef,
85
+ orientation,
86
+ scale,
87
+ setHasOverflow,
88
+ children
89
+ ]);
90
+ // There are two main reasons we need to remeasure:
91
+ // 1. Internal changes: Check for initial overflow or when orientation/scale/children change (from checkForOverflow dep array)
92
+ (0, $3Yfv0$useLayoutEffect)(()=>{
93
+ checkForOverflow();
94
+ }, [
95
+ checkForOverflow
96
+ ]);
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
98
+ let parent = (0, $3Yfv0$useRef)();
99
+ (0, $3Yfv0$useLayoutEffect)(()=>{
100
+ if (domRef.current) parent.current = domRef.current.parentElement;
101
+ // eslint-disable-next-line react-hooks/exhaustive-deps
102
+ }, [
103
+ domRef.current
104
+ ]);
105
+ (0, $3Yfv0$useResizeObserver)({
106
+ ref: parent,
107
+ onResize: checkForOverflow
108
+ });
109
+ return /*#__PURE__*/ (0, $3Yfv0$react).createElement("div", {
110
+ ...(0, $3Yfv0$filterDOMProps)(otherProps),
111
+ ...styleProps,
112
+ ref: domRef,
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"
117
+ }, styleProps.className)
118
+ }, /*#__PURE__*/ (0, $3Yfv0$react).createElement((0, $3Yfv0$SlotProvider), {
119
+ slots: {
120
+ button: {
121
+ UNSAFE_className: (0, $3Yfv0$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($fddc5368d2db28a6$exports))), "spectrum-ButtonGroup-Button")
122
+ }
123
+ }
124
+ }, /*#__PURE__*/ (0, $3Yfv0$react).createElement((0, $3Yfv0$Provider), {
125
+ isDisabled: isDisabled
126
+ }, children)));
127
+ }
128
+ /**
129
+ * ButtonGroup handles overflow for a grouping of buttons whose actions are related to each other.
130
+ */ let $bd4bfa55854eb3bf$export$69b1032f2ecdf404 = /*#__PURE__*/ (0, $3Yfv0$react).forwardRef($bd4bfa55854eb3bf$var$ButtonGroup);
131
+
132
+
133
+
134
+
135
+ export {$bd4bfa55854eb3bf$export$69b1032f2ecdf404 as ButtonGroup};
136
+ //# sourceMappingURL=module.js.map
package/package.json CHANGED
@@ -1,10 +1,15 @@
1
1
  {
2
2
  "name": "@react-spectrum/buttongroup",
3
- "version": "3.5.3-nightly.3698+72ee92f6d",
3
+ "version": "3.5.3-nightly.3709+0f953cac8",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/module.js",
8
+ "exports": {
9
+ "types": "./dist/types.d.ts",
10
+ "import": "./dist/import.mjs",
11
+ "require": "./dist/main.js"
12
+ },
8
13
  "types": "dist/types.d.ts",
9
14
  "source": "src/index.ts",
10
15
  "files": [
@@ -31,17 +36,17 @@
31
36
  "url": "https://github.com/adobe/react-spectrum"
32
37
  },
33
38
  "dependencies": {
34
- "@react-aria/utils": "3.0.0-nightly.1998+72ee92f6d",
35
- "@react-spectrum/button": "3.0.0-nightly.1998+72ee92f6d",
36
- "@react-spectrum/text": "3.3.5-nightly.3698+72ee92f6d",
37
- "@react-spectrum/utils": "3.0.0-nightly.1998+72ee92f6d",
38
- "@react-types/buttongroup": "3.2.6-nightly.3698+72ee92f6d",
39
- "@react-types/shared": "3.0.0-nightly.1998+72ee92f6d",
39
+ "@react-aria/utils": "3.0.0-nightly.2009+0f953cac8",
40
+ "@react-spectrum/button": "3.0.0-nightly.2009+0f953cac8",
41
+ "@react-spectrum/text": "3.3.5-nightly.3709+0f953cac8",
42
+ "@react-spectrum/utils": "3.0.0-nightly.2009+0f953cac8",
43
+ "@react-types/buttongroup": "3.2.6-nightly.3709+0f953cac8",
44
+ "@react-types/shared": "3.0.0-nightly.2009+0f953cac8",
40
45
  "@swc/helpers": "^0.4.14"
41
46
  },
42
47
  "devDependencies": {
43
- "@adobe/spectrum-css-temp": "3.0.0-nightly.1998+72ee92f6d",
44
- "@spectrum-icons/workflow": "3.0.0-nightly.1998+72ee92f6d"
48
+ "@adobe/spectrum-css-temp": "3.0.0-nightly.2009+0f953cac8",
49
+ "@spectrum-icons/workflow": "3.0.0-nightly.2009+0f953cac8"
45
50
  },
46
51
  "peerDependencies": {
47
52
  "@react-spectrum/provider": "^3.0.0",
@@ -50,5 +55,5 @@
50
55
  "publishConfig": {
51
56
  "access": "public"
52
57
  },
53
- "gitHead": "72ee92f6d497163468a80642ccb96576f822f365"
58
+ "gitHead": "0f953cac84f98cdff29f2348c120ce541ebb6da8"
54
59
  }