@react-spectrum/s2 3.0.0-nightly-b0f156972-241202 → 3.0.0-nightly-e94e36431-241203

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/Tabs.cjs CHANGED
@@ -1,25 +1,32 @@
1
1
  require("./Tabs.css");
2
2
  var $e991cbcdf82ced71$exports = require("./CenterBaseline.cjs");
3
3
  var $bde97c91243ed164$exports = require("../icons/Icon.cjs");
4
+ var $4526404114e78c80$exports = require("./intlStrings.cjs");
5
+ var $9d2c38978395d44a$exports = require("./TabsPicker.cjs");
4
6
  var $6367bc87eb7d24ad$exports = require("./Content.cjs");
5
7
  var $ac757a4c2bd72aee$exports = require("../icons/useSpectrumContextProps.cjs");
6
8
  var $5oxdw$reactjsxruntime = require("react/jsx-runtime");
7
- var $5oxdw$reactariacomponents = require("react-aria-components");
8
9
  var $5oxdw$react = require("react");
10
+ var $5oxdw$reactariacomponents = require("react-aria-components");
11
+ var $5oxdw$reactstatelyutils = require("@react-stately/utils");
9
12
  var $5oxdw$reactspectrumutils = require("@react-spectrum/utils");
10
13
  var $5oxdw$reactariautils = require("@react-aria/utils");
11
14
  var $5oxdw$reactariai18n = require("@react-aria/i18n");
12
15
 
13
16
 
17
+ function $parcel$interopDefault(a) {
18
+ return a && a.__esModule ? a.default : a;
19
+ }
20
+
14
21
  function $parcel$export(e, n, v, s) {
15
22
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
16
23
  }
17
24
 
18
25
  $parcel$export(module.exports, "TabsContext", () => $b27519d6a701105b$export$cfa7aa87c26e7d1f);
19
- $parcel$export(module.exports, "TabPanel", () => $b27519d6a701105b$export$3d96ec278d3efce4);
20
- $parcel$export(module.exports, "Tab", () => $b27519d6a701105b$export$3e41faf802a29e71);
21
- $parcel$export(module.exports, "TabList", () => $b27519d6a701105b$export$e51a686c67fdaa2d);
22
26
  $parcel$export(module.exports, "Tabs", () => $b27519d6a701105b$export$b2539bed5023c21c);
27
+ $parcel$export(module.exports, "TabList", () => $b27519d6a701105b$export$e51a686c67fdaa2d);
28
+ $parcel$export(module.exports, "Tab", () => $b27519d6a701105b$export$3e41faf802a29e71);
29
+ $parcel$export(module.exports, "TabPanel", () => $b27519d6a701105b$export$3d96ec278d3efce4);
23
30
  /*
24
31
  * Copyright 2024 Adobe. All rights reserved.
25
32
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -40,135 +47,92 @@ $parcel$export(module.exports, "Tabs", () => $b27519d6a701105b$export$b2539bed50
40
47
 
41
48
 
42
49
 
50
+
51
+
52
+
43
53
  const $b27519d6a701105b$export$cfa7aa87c26e7d1f = /*#__PURE__*/ (0, $5oxdw$react.createContext)(null);
44
- const $b27519d6a701105b$var$tabPanel = function anonymous(props, overrides) {
54
+ const $b27519d6a701105b$var$InternalTabsContext = /*#__PURE__*/ (0, $5oxdw$react.createContext)({
55
+ onFocus: ()=>{}
56
+ });
57
+ const $b27519d6a701105b$var$tabs = function anonymous(props, overrides) {
45
58
  let rules = " .";
46
59
  let matches = (overrides || '').match(/(?:^|\s)(?:y|z|A|B|_9|_8|h|_5|_4|__A|__c|__d|__a|__b|U|__Q|X|Z|V|W|l|q|r|k|o|p)[^\s]+/g) || [];
47
60
  rules += matches.join('');
48
- let $A = false;
49
- let $_9 = false;
50
- let $h = false;
51
- let $o = false;
52
- let $q = false;
53
- for (let p of matches){
54
- if (/^\s*A/.test(p)) $A = true;
55
- if (/^\s*_9/.test(p)) $_9 = true;
56
- if (/^\s*h/.test(p)) $h = true;
57
- if (/^\s*o/.test(p)) $o = true;
58
- if (/^\s*q/.test(p)) $q = true;
59
- }
60
- if (!$A) rules += ' Ac';
61
- rules += ' an';
62
- if (!$_9) rules += ' _9-3t1y';
63
- if (!$h) rules += ' h-3hmsa';
64
- if (!$o) rules += ' oo';
65
- if (!$q) rules += ' qo';
66
- return rules;
67
- };
68
- function $b27519d6a701105b$export$3d96ec278d3efce4(props) {
69
- return /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)((0, $5oxdw$reactariacomponents.TabPanel), {
70
- ...props,
71
- style: props.UNSAFE_style,
72
- className: (props.UNSAFE_className || '') + $b27519d6a701105b$var$tabPanel(null, props.styles)
73
- });
74
- }
75
- const $b27519d6a701105b$var$tab = function anonymous(props, overrides) {
76
- let rules = " .";
77
- let matches = (overrides || '').match(/(?:^|\s)(?:y|z|A|B|_9|_8|h|_5|_4|__A|__c|__d|__a|__b|U|__Q|X|Z|V|W|l|q|r)[^\s]+/g) || [];
78
- rules += matches.join('');
79
- let $U = false;
80
61
  let $_8 = false;
81
- for (let p of matches){
82
- if (/^\s*U/.test(p)) $U = true;
83
- if (/^\s*_8/.test(p)) $_8 = true;
84
- }
85
- if (props.isFocusVisible) rules += ' _Lb';
86
- else rules += ' _La';
87
- rules += ' da_____z';
88
- rules += ' dx';
89
- rules += ' _Nc';
90
- rules += ' _M-3t1z';
62
+ for (let p of matches)if (/^\s*_8/.test(p)) $_8 = true;
91
63
  rules += ' _Zd';
92
- if (props.isDisabled) rules += ' aa_____B';
93
- else if (props.isSelected) rules += ' aa_____z';
94
- if (props.isDisabled) rules += ' aj';
95
- else if (props.isHovered) {
96
- if (props.isPressed) rules += ' an';
97
- else if (props.isFocusVisible) rules += ' an';
98
- else if (props.isHovered) rules += ' an';
99
- else rules += ' am';
100
- } else if (props.isSelected) {
101
- if (props.isPressed) rules += ' ao';
102
- else if (props.isFocusVisible) rules += ' ao';
103
- else rules += ' an';
104
- } else {
105
- if (props.isPressed) rules += ' an';
106
- else if (props.isFocusVisible) rules += ' an';
107
- else rules += ' am';
108
- }
109
- rules += ' _vb';
110
- rules += ' _wb';
111
- rules += ' _xb';
112
- rules += ' _yb';
113
- rules += ' ibH';
114
- rules += ' iG';
115
- rules += ' jbH';
116
- rules += ' jG';
117
- if (props.density === "regular") rules += ' k_a';
118
- else if (props.density === "compact") rules += ' kU';
119
- rules += ' _1c';
120
- if (!$U) rules += ' Uc';
121
- rules += ' __Hb';
122
64
  if (!$_8) rules += ' _8-3t1x';
123
- rules += ' _Oa';
124
- rules += ' _Q-375x7f';
125
- rules += ' _Ra';
65
+ rules += ' _c-bc1l9oh';
66
+ rules += ' _c-1uotwbwg';
67
+ rules += ' _c-eo0c6sf';
68
+ rules += ' _c-enzzrge';
69
+ rules += ' _c-enzykdd';
70
+ rules += ' _c-enzwzjc';
71
+ rules += ' _c-enzrfpb';
72
+ rules += ' _ca';
73
+ rules += ' _dbf';
74
+ rules += ' _de';
75
+ rules += ' _eb';
76
+ rules += ' _f-1x99dlob';
77
+ rules += ' _fa';
78
+ rules += ' an';
79
+ if (props.orientation === "horizontal") rules += ' _6b';
126
80
  return rules;
127
81
  };
128
- const $b27519d6a701105b$var$icon = " . _8-3t1x -rwx0fg_e-b";
129
- function $b27519d6a701105b$export$3e41faf802a29e71(props) {
130
- let { density: density } = (0, $5oxdw$reactariacomponents.useSlottedContext)($b27519d6a701105b$export$cfa7aa87c26e7d1f) ?? {};
131
- return /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)((0, $5oxdw$reactariacomponents.Tab), {
132
- ...props,
133
- style: props.UNSAFE_style,
134
- className: (renderProps)=>(props.UNSAFE_className || '') + $b27519d6a701105b$var$tab({
135
- ...renderProps,
136
- density: density
137
- }, props.styles),
138
- children: /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)((0, $5oxdw$reactariacomponents.Provider), {
139
- values: [
140
- [
141
- (0, $6367bc87eb7d24ad$exports.TextContext),
142
- {
143
- styles: " . __A-3t1y"
144
- }
145
- ],
146
- [
147
- (0, $bde97c91243ed164$exports.IconContext),
148
- {
149
- render: (0, $e991cbcdf82ced71$exports.centerBaseline)({
150
- slot: 'icon',
151
- styles: " . __A-3t1x"
152
- }),
153
- styles: $b27519d6a701105b$var$icon
154
- }
155
- ]
156
- ],
157
- children: typeof props.children === 'string' ? /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)((0, $6367bc87eb7d24ad$exports.Text), {
82
+ const $b27519d6a701105b$export$b2539bed5023c21c = /*#__PURE__*/ (0, $5oxdw$react.forwardRef)(function Tabs(props, ref) {
83
+ [props, ref] = (0, $ac757a4c2bd72aee$exports.useSpectrumContextProps)(props, ref, $b27519d6a701105b$export$cfa7aa87c26e7d1f);
84
+ let { density: density = 'regular', isDisabled: isDisabled, disabledKeys: disabledKeys, orientation: orientation = 'horizontal', iconOnly: iconOnly = false } = props;
85
+ let domRef = (0, $5oxdw$reactspectrumutils.useDOMRef)(ref);
86
+ let [value, setValue] = (0, $5oxdw$reactstatelyutils.useControlledState)(props.selectedKey, props.defaultSelectedKey ?? null, props.onSelectionChange);
87
+ let pickerRef = (0, $5oxdw$react.useRef)(null);
88
+ return /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)((0, $5oxdw$reactariacomponents.Provider), {
89
+ values: [
90
+ [
91
+ $b27519d6a701105b$var$InternalTabsContext,
92
+ {
93
+ density: density,
94
+ isDisabled: isDisabled,
95
+ orientation: orientation,
96
+ disabledKeys: disabledKeys,
97
+ selectedKey: value,
98
+ onSelectionChange: setValue,
99
+ iconOnly: iconOnly,
100
+ onFocus: ()=>pickerRef.current?.focus(),
101
+ pickerRef: pickerRef
102
+ }
103
+ ]
104
+ ],
105
+ children: /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)($b27519d6a701105b$var$CollapsingCollection, {
106
+ containerRef: domRef,
107
+ children: /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)((0, $5oxdw$reactariacomponents.Tabs), {
108
+ ...props,
109
+ ref: domRef,
110
+ selectedKey: value,
111
+ onSelectionChange: setValue,
112
+ style: props.UNSAFE_style,
113
+ className: (renderProps)=>(props.UNSAFE_className || '') + $b27519d6a701105b$var$tabs({
114
+ ...renderProps
115
+ }, props.styles),
158
116
  children: props.children
159
- }) : props.children
117
+ })
160
118
  })
161
119
  });
162
- }
120
+ });
163
121
  const $b27519d6a701105b$var$tablist = function anonymous(props) {
164
122
  let rules = " .";
165
123
  rules += ' _Zd';
166
124
  if (props.orientation === "horizontal") {
167
- if (props.density === "regular") rules += ' ij';
125
+ if (props.isIconOnly) {
126
+ if (props.density === "regular") rules += ' ih';
127
+ else if (props.density === "compact") rules += ' if';
128
+ } else if (props.density === "regular") rules += ' ij';
168
129
  else if (props.density === "compact") rules += ' ih';
169
130
  }
170
131
  if (props.orientation === "horizontal") {
171
- if (props.density === "regular") rules += ' jj';
132
+ if (props.isIconOnly) {
133
+ if (props.density === "regular") rules += ' jh';
134
+ else if (props.density === "compact") rules += ' jf';
135
+ } else if (props.density === "regular") rules += ' jj';
172
136
  else if (props.density === "compact") rules += ' jh';
173
137
  }
174
138
  if (props.orientation === "vertical") rules += ' _6b';
@@ -179,18 +143,32 @@ const $b27519d6a701105b$var$tablist = function anonymous(props) {
179
143
  return rules;
180
144
  };
181
145
  function $b27519d6a701105b$export$e51a686c67fdaa2d(props1) {
182
- let { density: density, isDisabled: isDisabled, disabledKeys: disabledKeys, orientation: orientation } = (0, $5oxdw$reactariacomponents.useSlottedContext)($b27519d6a701105b$export$cfa7aa87c26e7d1f) ?? {};
146
+ let { density: density, isDisabled: isDisabled, disabledKeys: disabledKeys, orientation: orientation, iconOnly: iconOnly, onFocus: onFocus } = (0, $5oxdw$react.useContext)($b27519d6a701105b$var$InternalTabsContext) ?? {};
147
+ let { showItems: showItems } = (0, $5oxdw$react.useContext)($b27519d6a701105b$var$CollapseContext) ?? {};
183
148
  let state = (0, $5oxdw$react.useContext)((0, $5oxdw$reactariacomponents.TabListStateContext));
184
149
  let [selectedTab, setSelectedTab] = (0, $5oxdw$react.useState)(undefined);
185
150
  let tablistRef = (0, $5oxdw$react.useRef)(null);
186
151
  (0, $5oxdw$reactariautils.useLayoutEffect)(()=>{
187
- if (tablistRef?.current) {
152
+ if (tablistRef?.current && showItems) {
188
153
  let tab = tablistRef.current.querySelector('[role=tab][data-selected=true]');
189
154
  if (tab != null) setSelectedTab(tab);
155
+ } else if (tablistRef?.current) {
156
+ let picker = tablistRef.current.querySelector('button');
157
+ if (picker != null) setSelectedTab(picker);
190
158
  }
191
159
  }, [
192
160
  tablistRef,
193
- state?.selectedItem?.key
161
+ state?.selectedItem?.key,
162
+ showItems
163
+ ]);
164
+ let prevFocused = (0, $5oxdw$react.useRef)(false);
165
+ (0, $5oxdw$reactariautils.useLayoutEffect)(()=>{
166
+ if (!showItems && !prevFocused.current && state?.selectionManager.isFocused) onFocus();
167
+ prevFocused.current = state?.selectionManager.isFocused;
168
+ }, [
169
+ state?.selectionManager.isFocused,
170
+ state?.selectionManager.focusedKey,
171
+ showItems
194
172
  ]);
195
173
  return /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsxs)("div", {
196
174
  style: props1.UNSAFE_style,
@@ -204,7 +182,7 @@ function $b27519d6a701105b$export$e51a686c67fdaa2d(props1) {
204
182
  return rules;
205
183
  }(null, props1.styles),
206
184
  children: [
207
- orientation === 'vertical' && /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)($b27519d6a701105b$var$TabLine, {
185
+ showItems && orientation === 'vertical' && /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)($b27519d6a701105b$var$TabLine, {
208
186
  disabledKeys: disabledKeys,
209
187
  isDisabled: isDisabled,
210
188
  selectedTab: selectedTab,
@@ -216,10 +194,12 @@ function $b27519d6a701105b$export$e51a686c67fdaa2d(props1) {
216
194
  ref: tablistRef,
217
195
  className: (renderProps)=>$b27519d6a701105b$var$tablist({
218
196
  ...renderProps,
197
+ isIconOnly: iconOnly,
219
198
  density: density
220
199
  })
221
200
  }),
222
201
  orientation === 'horizontal' && /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)($b27519d6a701105b$var$TabLine, {
202
+ showItems: showItems,
223
203
  disabledKeys: disabledKeys,
224
204
  isDisabled: isDisabled,
225
205
  selectedTab: selectedTab,
@@ -229,21 +209,6 @@ function $b27519d6a701105b$export$e51a686c67fdaa2d(props1) {
229
209
  ]
230
210
  });
231
211
  }
232
- function $b27519d6a701105b$var$isAllTabsDisabled(collection, disabledKeys) {
233
- let testKey = null;
234
- if (collection && collection.size > 0) {
235
- testKey = collection.getFirstKey();
236
- let index = 0;
237
- while(testKey && index < collection.size){
238
- // We have to check if the item in the collection has a key in disabledKeys or has the isDisabled prop set directly on it
239
- if (!disabledKeys.has(testKey) && !collection.getItem(testKey)?.props?.isDisabled) return false;
240
- testKey = collection.getKeyAfter(testKey);
241
- index++;
242
- }
243
- return true;
244
- }
245
- return false;
246
- }
247
212
  const $b27519d6a701105b$var$selectedIndicator = function anonymous(props) {
248
213
  let rules = " .";
249
214
  rules += ' Ua';
@@ -272,16 +237,12 @@ function $b27519d6a701105b$var$TabLine(props) {
272
237
  let { disabledKeys: disabledKeys, isDisabled: isTabsDisabled, selectedTab: selectedTab, orientation: orientation, density: density } = props;
273
238
  let { direction: direction } = (0, $5oxdw$reactariai18n.useLocale)();
274
239
  let state = (0, $5oxdw$react.useContext)((0, $5oxdw$reactariacomponents.TabListStateContext));
275
- // We want to add disabled styling to the selection indicator only if all the Tabs are disabled
276
- let [isDisabled, setIsDisabled] = (0, $5oxdw$react.useState)(false);
277
- (0, $5oxdw$react.useEffect)(()=>{
278
- let isDisabled = isTabsDisabled || $b27519d6a701105b$var$isAllTabsDisabled(state?.collection || null, disabledKeys ? new Set(disabledKeys) : new Set(null));
279
- setIsDisabled(isDisabled);
240
+ let isDisabled = (0, $5oxdw$react.useMemo)(()=>{
241
+ return isTabsDisabled || $b27519d6a701105b$var$isAllTabsDisabled(state?.collection, disabledKeys ? new Set(disabledKeys) : new Set());
280
242
  }, [
281
243
  state?.collection,
282
244
  disabledKeys,
283
- isTabsDisabled,
284
- setIsDisabled
245
+ isTabsDisabled
285
246
  ]);
286
247
  let [style, setStyle] = (0, $5oxdw$react.useState)({
287
248
  transform: undefined,
@@ -327,53 +288,313 @@ function $b27519d6a701105b$var$TabLine(props) {
327
288
  })
328
289
  });
329
290
  }
330
- const $b27519d6a701105b$var$tabs = function anonymous(props, overrides) {
291
+ const $b27519d6a701105b$var$tab = function anonymous(props, overrides) {
331
292
  let rules = " .";
332
- let matches = (overrides || '').match(/(?:^|\s)(?:y|z|A|B|_9|_8|h|_5|_4|__A|__c|__d|__a|__b|U|__Q|X|Z|V|W|l|q|r|k|o|p)[^\s]+/g) || [];
293
+ let matches = (overrides || '').match(/(?:^|\s)(?:y|z|A|B|_9|_8|h|_5|_4|__A|__c|__d|__a|__b|U|__Q|X|Z|V|W|l|q|r)[^\s]+/g) || [];
333
294
  rules += matches.join('');
295
+ let $U = false;
334
296
  let $_8 = false;
335
- for (let p of matches)if (/^\s*_8/.test(p)) $_8 = true;
297
+ for (let p of matches){
298
+ if (/^\s*U/.test(p)) $U = true;
299
+ if (/^\s*_8/.test(p)) $_8 = true;
300
+ }
301
+ if (props.isFocusVisible) rules += ' _Lb';
302
+ else rules += ' _La';
303
+ rules += ' da_____z';
304
+ rules += ' dx';
305
+ rules += ' _Nc';
306
+ rules += ' _M-3t1z';
336
307
  rules += ' _Zd';
308
+ if (props.isDisabled) rules += ' aa_____B';
309
+ else if (props.isSelected) rules += ' aa_____z';
310
+ if (props.isDisabled) rules += ' aj';
311
+ else if (props.isHovered) {
312
+ if (props.isPressed) rules += ' an';
313
+ else if (props.isFocusVisible) rules += ' an';
314
+ else if (props.isHovered) rules += ' an';
315
+ else rules += ' am';
316
+ } else if (props.isSelected) {
317
+ if (props.isPressed) rules += ' ao';
318
+ else if (props.isFocusVisible) rules += ' ao';
319
+ else rules += ' an';
320
+ } else {
321
+ if (props.isPressed) rules += ' an';
322
+ else if (props.isFocusVisible) rules += ' an';
323
+ else rules += ' am';
324
+ }
325
+ rules += ' _vb';
326
+ rules += ' _wb';
327
+ rules += ' _xb';
328
+ rules += ' _yb';
329
+ rules += ' ibH';
330
+ rules += ' iG';
331
+ rules += ' jbH';
332
+ rules += ' jG';
333
+ if (props.density === "regular") rules += ' k_a';
334
+ else if (props.density === "compact") rules += ' kU';
335
+ rules += ' _1c';
336
+ if (!$U) rules += ' Uc';
337
+ rules += ' __Hb';
337
338
  if (!$_8) rules += ' _8-3t1x';
338
- rules += ' _c-bc1l9oh';
339
- rules += ' _c-1uotwbwg';
340
- rules += ' _c-eo0c6sf';
341
- rules += ' _c-enzzrge';
342
- rules += ' _c-enzykdd';
343
- rules += ' _c-enzwzjc';
344
- rules += ' _c-enzrfpb';
345
- rules += ' _ca';
346
- rules += ' _eb';
347
- if (props.orientation === "horizontal") rules += ' _6b';
339
+ rules += ' _Oa';
340
+ rules += ' _Q-375x7f';
341
+ rules += ' _Ra';
348
342
  return rules;
349
343
  };
350
- const $b27519d6a701105b$export$b2539bed5023c21c = /*#__PURE__*/ (0, $5oxdw$react.forwardRef)(function Tabs(props, ref) {
351
- [props, ref] = (0, $ac757a4c2bd72aee$exports.useSpectrumContextProps)(props, ref, $b27519d6a701105b$export$cfa7aa87c26e7d1f);
352
- let { density: density = 'regular', isDisabled: isDisabled, disabledKeys: disabledKeys, orientation: orientation = 'horizontal' } = props;
353
- let domRef = (0, $5oxdw$reactspectrumutils.useDOMRef)(ref);
354
- return /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)((0, $5oxdw$reactariacomponents.Tabs), {
344
+ const $b27519d6a701105b$var$icon = " . _Za _8-3t1x -rwx0fg_e-b";
345
+ function $b27519d6a701105b$export$3e41faf802a29e71(props1) {
346
+ let { density: density, iconOnly: iconOnly } = (0, $5oxdw$react.useContext)($b27519d6a701105b$var$InternalTabsContext) ?? {};
347
+ return /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)((0, $5oxdw$reactariacomponents.Tab), {
348
+ ...props1,
349
+ // @ts-ignore
350
+ originalProps: props1,
351
+ style: props1.UNSAFE_style,
352
+ className: (renderProps)=>(props1.UNSAFE_className || '') + $b27519d6a701105b$var$tab({
353
+ ...renderProps,
354
+ density: density
355
+ }, props1.styles),
356
+ children: ({ isMenu: // @ts-ignore
357
+ isMenu })=>{
358
+ if (isMenu) return props1.children;
359
+ else return /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)((0, $5oxdw$reactariacomponents.Provider), {
360
+ values: [
361
+ [
362
+ (0, $6367bc87eb7d24ad$exports.TextContext),
363
+ {
364
+ styles: function anonymous(props) {
365
+ let rules = " .";
366
+ rules += ' __A-3t1y';
367
+ if (props.isIconOnly) rules += ' _Zj';
368
+ return rules;
369
+ }({
370
+ isIconOnly: iconOnly
371
+ })
372
+ }
373
+ ],
374
+ [
375
+ (0, $bde97c91243ed164$exports.IconContext),
376
+ {
377
+ render: (0, $e991cbcdf82ced71$exports.centerBaseline)({
378
+ slot: 'icon',
379
+ styles: " . __A-3t1x"
380
+ }),
381
+ styles: $b27519d6a701105b$var$icon
382
+ }
383
+ ]
384
+ ],
385
+ children: typeof props1.children === 'string' ? /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)((0, $6367bc87eb7d24ad$exports.Text), {
386
+ children: props1.children
387
+ }) : props1.children
388
+ });
389
+ }
390
+ });
391
+ }
392
+ const $b27519d6a701105b$var$tabPanel = function anonymous(props, overrides) {
393
+ let rules = " .";
394
+ let matches = (overrides || '').match(/(?:^|\s)(?:y|z|A|B|_9|_8|h|_5|_4|__A|__c|__d|__a|__b|U|__Q|X|Z|V|W|l|q|r|k|o|p)[^\s]+/g) || [];
395
+ rules += matches.join('');
396
+ let $A = false;
397
+ let $_9 = false;
398
+ let $h = false;
399
+ let $o = false;
400
+ let $q = false;
401
+ for (let p of matches){
402
+ if (/^\s*A/.test(p)) $A = true;
403
+ if (/^\s*_9/.test(p)) $_9 = true;
404
+ if (/^\s*h/.test(p)) $h = true;
405
+ if (/^\s*o/.test(p)) $o = true;
406
+ if (/^\s*q/.test(p)) $q = true;
407
+ }
408
+ if (!$A) rules += ' Ac';
409
+ rules += ' an';
410
+ if (!$_9) rules += ' _9-3t1y';
411
+ if (!$h) rules += ' h-3hmsa';
412
+ if (!$o) rules += ' oo';
413
+ if (!$q) rules += ' qo';
414
+ return rules;
415
+ };
416
+ function $b27519d6a701105b$export$3d96ec278d3efce4(props) {
417
+ return /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)((0, $5oxdw$reactariacomponents.TabPanel), {
355
418
  ...props,
356
- ref: domRef,
357
419
  style: props.UNSAFE_style,
358
- className: (renderProps)=>(props.UNSAFE_className || '') + $b27519d6a701105b$var$tabs({
359
- ...renderProps
360
- }, props.styles),
361
- children: /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)((0, $5oxdw$reactariacomponents.Provider), {
362
- values: [
363
- [
364
- $b27519d6a701105b$export$cfa7aa87c26e7d1f,
365
- {
420
+ className: (props.UNSAFE_className || '') + $b27519d6a701105b$var$tabPanel(null, props.styles)
421
+ });
422
+ }
423
+ function $b27519d6a701105b$var$isAllTabsDisabled(collection, disabledKeys) {
424
+ let testKey = null;
425
+ if (collection && collection.size > 0) {
426
+ testKey = collection.getFirstKey();
427
+ let index = 0;
428
+ while(testKey && index < collection.size){
429
+ // We have to check if the item in the collection has a key in disabledKeys or has the isDisabled prop set directly on it
430
+ if (!disabledKeys.has(testKey) && !collection.getItem(testKey)?.props?.isDisabled) return false;
431
+ testKey = collection.getKeyAfter(testKey);
432
+ index++;
433
+ }
434
+ return true;
435
+ }
436
+ return false;
437
+ }
438
+ let $b27519d6a701105b$var$HiddenTabs = function(props) {
439
+ let { listRef: listRef, items: items, size: size, density: density } = props;
440
+ return /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)("div", {
441
+ // @ts-ignore
442
+ inert: "true",
443
+ ref: listRef,
444
+ className: " . _Z-17zqamw _6-17zqamw i-17zqamw j-17zqamw _7-17zqamw Ua Xa Za Va Wa __Eb __vb __wb _K-3t1x",
445
+ children: items.map((item)=>{
446
+ // pull off individual props as an allow list, don't want refs or other props getting through
447
+ return /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)("div", {
448
+ "data-hidden-tab": true,
449
+ style: item.props.UNSAFE_style,
450
+ className: item.props.className({
451
+ size: size,
452
+ density: density
453
+ }),
454
+ children: item.props.children({
455
+ size: size,
456
+ density: density
457
+ })
458
+ }, item.key);
459
+ })
460
+ });
461
+ };
462
+ let $b27519d6a701105b$var$TabsMenu = (props1)=>{
463
+ let stringFormatter = (0, $5oxdw$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($4526404114e78c80$exports))), '@react-spectrum/s2');
464
+ let { items: items } = props1;
465
+ let { density: density, onSelectionChange: onSelectionChange, selectedKey: selectedKey, isDisabled: isDisabled, disabledKeys: disabledKeys, pickerRef: pickerRef } = (0, $5oxdw$react.useContext)($b27519d6a701105b$var$InternalTabsContext);
466
+ let state = (0, $5oxdw$react.useContext)((0, $5oxdw$reactariacomponents.TabListStateContext));
467
+ let allKeysDisabled = (0, $5oxdw$react.useMemo)(()=>{
468
+ return $b27519d6a701105b$var$isAllTabsDisabled(state?.collection, disabledKeys ? new Set(disabledKeys) : new Set());
469
+ }, [
470
+ state?.collection,
471
+ disabledKeys
472
+ ]);
473
+ return /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)((0, $5oxdw$reactariacomponents.UNSTABLE_CollectionRendererContext).Provider, {
474
+ value: (0, $5oxdw$reactariacomponents.UNSTABLE_DefaultCollectionRenderer),
475
+ children: /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)("div", {
476
+ className: function anonymous(props) {
477
+ let rules = " .";
478
+ rules += ' _Zd';
479
+ rules += ' _1c';
480
+ if (props.density === "regular") rules += ' k_a';
481
+ else if (props.density === "compact") rules += ' kU';
482
+ return rules;
483
+ }({
484
+ density: density
485
+ }),
486
+ children: /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)((0, $9d2c38978395d44a$exports.Picker), {
487
+ ref: pickerRef ? pickerRef : undefined,
488
+ isDisabled: isDisabled || allKeysDisabled,
489
+ density: density,
490
+ items: items,
491
+ disabledKeys: disabledKeys,
492
+ selectedKey: selectedKey,
493
+ onSelectionChange: onSelectionChange,
494
+ "aria-label": stringFormatter.format('tabs.selectorLabel'),
495
+ children: (item)=>{
496
+ // need to determine the best way to handle icon only -> icon and text
497
+ // good enough to aria-label the picker item?
498
+ return /*#__PURE__*/ (0, $5oxdw$react.createElement)((0, $9d2c38978395d44a$exports.PickerItem), {
499
+ ...item.props.originalProps,
500
+ isDisabled: isDisabled || allKeysDisabled,
501
+ key: item.key
502
+ }, item.props.children({
366
503
  density: density,
367
- isDisabled: isDisabled,
368
- disabledKeys: disabledKeys,
369
- orientation: orientation
370
- }
371
- ]
372
- ],
373
- children: props.children
504
+ isMenu: true
505
+ }));
506
+ }
507
+ })
374
508
  })
375
509
  });
376
- });
510
+ };
511
+ // Context for passing the count for the custom renderer
512
+ let $b27519d6a701105b$var$CollapseContext = /*#__PURE__*/ (0, $5oxdw$react.createContext)(null);
513
+ function $b27519d6a701105b$var$CollapsingCollection({ children: children, containerRef: containerRef }) {
514
+ let [showItems, _setShowItems] = (0, $5oxdw$react.useState)(true);
515
+ let { orientation: orientation } = (0, $5oxdw$react.useContext)($b27519d6a701105b$var$InternalTabsContext);
516
+ let setShowItems = (0, $5oxdw$react.useCallback)((value)=>{
517
+ if (orientation === 'vertical') // if orientation is vertical, we always show the items
518
+ _setShowItems(true);
519
+ else _setShowItems(value);
520
+ }, [
521
+ orientation
522
+ ]);
523
+ return /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)($b27519d6a701105b$var$CollapseContext.Provider, {
524
+ value: {
525
+ containerRef: containerRef,
526
+ showItems: orientation === 'vertical' ? true : showItems,
527
+ setShowItems: setShowItems
528
+ },
529
+ children: /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)((0, $5oxdw$reactariacomponents.UNSTABLE_CollectionRendererContext).Provider, {
530
+ value: $b27519d6a701105b$var$CollapsingCollectionRenderer,
531
+ children: children
532
+ })
533
+ });
534
+ }
535
+ let $b27519d6a701105b$var$CollapsingCollectionRenderer = {
536
+ CollectionRoot ({ collection: collection }) {
537
+ return $b27519d6a701105b$var$useCollectionRender(collection);
538
+ },
539
+ CollectionBranch ({ collection: collection }) {
540
+ return $b27519d6a701105b$var$useCollectionRender(collection);
541
+ }
542
+ };
543
+ let $b27519d6a701105b$var$useCollectionRender = (collection)=>{
544
+ let { containerRef: containerRef, showItems: showItems, setShowItems: setShowItems } = (0, $5oxdw$react.useContext)($b27519d6a701105b$var$CollapseContext) ?? {};
545
+ let { density: density = 'regular', orientation: orientation = 'horizontal', onSelectionChange: onSelectionChange } = (0, $5oxdw$react.useContext)($b27519d6a701105b$var$InternalTabsContext);
546
+ let { direction: direction } = (0, $5oxdw$reactariai18n.useLocale)();
547
+ let children = (0, $5oxdw$react.useMemo)(()=>{
548
+ let result = [];
549
+ for (let key of collection.getKeys())result.push(collection.getItem(key));
550
+ return result;
551
+ }, [
552
+ collection
553
+ ]);
554
+ let listRef = (0, $5oxdw$react.useRef)(null);
555
+ let updateOverflow = (0, $5oxdw$reactariautils.useEffectEvent)(()=>{
556
+ if (orientation === 'vertical' || !listRef.current || !containerRef?.current) return;
557
+ let container = listRef.current;
558
+ let containerRect = container.getBoundingClientRect();
559
+ let tabs = container.querySelectorAll('[data-hidden-tab]');
560
+ let lastTab = tabs[tabs.length - 1];
561
+ let lastTabRect = lastTab.getBoundingClientRect();
562
+ if (direction === 'ltr') setShowItems?.(lastTabRect.right <= containerRect.right);
563
+ else setShowItems?.(lastTabRect.left >= containerRect.left);
564
+ });
565
+ (0, $5oxdw$reactariautils.useResizeObserver)({
566
+ ref: containerRef,
567
+ onResize: updateOverflow
568
+ });
569
+ (0, $5oxdw$reactariautils.useLayoutEffect)(()=>{
570
+ if (collection.size > 0) queueMicrotask(updateOverflow);
571
+ }, [
572
+ collection.size,
573
+ updateOverflow
574
+ ]);
575
+ (0, $5oxdw$react.useEffect)(()=>{
576
+ // Recalculate visible tags when fonts are loaded.
577
+ document.fonts?.ready.then(()=>updateOverflow());
578
+ // eslint-disable-next-line react-hooks/exhaustive-deps
579
+ }, []);
580
+ return /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsxs)((0, $5oxdw$reactjsxruntime.Fragment), {
581
+ children: [
582
+ /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)($b27519d6a701105b$var$HiddenTabs, {
583
+ items: children,
584
+ density: density,
585
+ listRef: listRef
586
+ }),
587
+ showItems ? children.map((node)=>/*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)((0, $5oxdw$react.Fragment), {
588
+ children: node.render?.(node)
589
+ }, node.key)) : /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)((0, $5oxdw$reactjsxruntime.Fragment), {
590
+ children: /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)($b27519d6a701105b$var$TabsMenu, {
591
+ items: children,
592
+ onSelectionChange: onSelectionChange
593
+ })
594
+ })
595
+ ]
596
+ });
597
+ };
377
598
 
378
599
 
379
600
  //# sourceMappingURL=Tabs.cjs.map