@react-aria/grid 3.6.2-nightly.3731 → 3.6.2-nightly.3737

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/import.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import {getNthItem as $cVkRF$getNthItem, getChildNodes as $cVkRF$getChildNodes, getLastItem as $cVkRF$getLastItem, getFirstItem as $cVkRF$getFirstItem} from "@react-stately/collections";
1
2
  import {Rect as $cVkRF$Rect} from "@react-stately/virtualizer";
2
3
  import {useId as $cVkRF$useId, filterDOMProps as $cVkRF$filterDOMProps, mergeProps as $cVkRF$mergeProps, useUpdateEffect as $cVkRF$useUpdateEffect, useDescription as $cVkRF$useDescription, scrollIntoViewport as $cVkRF$scrollIntoViewport, getScrollParent as $cVkRF$getScrollParent} from "@react-aria/utils";
3
4
  import {useMemo as $cVkRF$useMemo, useRef as $cVkRF$useRef} from "react";
@@ -31,6 +32,7 @@ function $parcel$interopDefault(a) {
31
32
  * OF ANY KIND, either express or implied. See the License for the specific language
32
33
  * governing permissions and limitations under the License.
33
34
  */
35
+
34
36
  class $d1c300d9c497e402$export$de9feff04fda126e {
35
37
  isCell(node) {
36
38
  return node.type === "cell";
@@ -42,7 +44,7 @@ class $d1c300d9c497e402$export$de9feff04fda126e {
42
44
  let key = fromKey != null ? this.collection.getKeyBefore(fromKey) : this.collection.getLastKey();
43
45
  while(key != null){
44
46
  let item = this.collection.getItem(key);
45
- if (!pred || pred(item)) return key;
47
+ if (!this.disabledKeys.has(key) && (!pred || pred(item))) return key;
46
48
  key = this.collection.getKeyBefore(key);
47
49
  }
48
50
  }
@@ -50,7 +52,7 @@ class $d1c300d9c497e402$export$de9feff04fda126e {
50
52
  let key = fromKey != null ? this.collection.getKeyAfter(fromKey) : this.collection.getFirstKey();
51
53
  while(key != null){
52
54
  let item = this.collection.getItem(key);
53
- if (!pred || pred(item)) return key;
55
+ if (!this.disabledKeys.has(key) && (!pred || pred(item))) return key;
54
56
  key = this.collection.getKeyAfter(key);
55
57
  }
56
58
  }
@@ -65,9 +67,7 @@ class $d1c300d9c497e402$export$de9feff04fda126e {
65
67
  // If focus was on a cell, focus the cell with the same index in the next row.
66
68
  if (this.isCell(startItem)) {
67
69
  let item = this.collection.getItem(key);
68
- return [
69
- ...item.childNodes
70
- ][startItem.index].key;
70
+ return (0, $cVkRF$getNthItem)((0, $cVkRF$getChildNodes)(item, this.collection), startItem.index).key;
71
71
  }
72
72
  // Otherwise, focus the next row
73
73
  if (this.focusMode === "row") return key;
@@ -84,9 +84,7 @@ class $d1c300d9c497e402$export$de9feff04fda126e {
84
84
  // If focus was on a cell, focus the cell with the same index in the previous row.
85
85
  if (this.isCell(startItem)) {
86
86
  let item = this.collection.getItem(key);
87
- return [
88
- ...item.childNodes
89
- ][startItem.index].key;
87
+ return (0, $cVkRF$getNthItem)((0, $cVkRF$getChildNodes)(item, this.collection), startItem.index).key;
90
88
  }
91
89
  // Otherwise, focus the previous row
92
90
  if (this.focusMode === "row") return key;
@@ -97,19 +95,15 @@ class $d1c300d9c497e402$export$de9feff04fda126e {
97
95
  if (!item) return;
98
96
  // If focus is on a row, focus the first child cell.
99
97
  if (this.isRow(item)) {
100
- let children = [
101
- ...item.childNodes
102
- ];
103
- return this.direction === "rtl" ? children[children.length - 1].key : children[0].key;
98
+ let children = (0, $cVkRF$getChildNodes)(item, this.collection);
99
+ return this.direction === "rtl" ? (0, $cVkRF$getLastItem)(children).key : (0, $cVkRF$getFirstItem)(children).key;
104
100
  }
105
101
  // If focus is on a cell, focus the next cell if any,
106
102
  // otherwise focus the parent row.
107
103
  if (this.isCell(item)) {
108
104
  let parent = this.collection.getItem(item.parentKey);
109
- let children1 = [
110
- ...parent.childNodes
111
- ];
112
- let next = this.direction === "rtl" ? children1[item.index - 1] : children1[item.index + 1];
105
+ let children1 = (0, $cVkRF$getChildNodes)(parent, this.collection);
106
+ let next = this.direction === "rtl" ? (0, $cVkRF$getNthItem)(children1, item.index - 1) : (0, $cVkRF$getNthItem)(children1, item.index + 1);
113
107
  if (next) return next.key;
114
108
  // focus row only if focusMode is set to row
115
109
  if (this.focusMode === "row") return item.parentKey;
@@ -121,19 +115,15 @@ class $d1c300d9c497e402$export$de9feff04fda126e {
121
115
  if (!item) return;
122
116
  // If focus is on a row, focus the last child cell.
123
117
  if (this.isRow(item)) {
124
- let children = [
125
- ...item.childNodes
126
- ];
127
- return this.direction === "rtl" ? children[0].key : children[children.length - 1].key;
118
+ let children = (0, $cVkRF$getChildNodes)(item, this.collection);
119
+ return this.direction === "rtl" ? (0, $cVkRF$getFirstItem)(children).key : (0, $cVkRF$getLastItem)(children).key;
128
120
  }
129
121
  // If focus is on a cell, focus the previous cell if any,
130
122
  // otherwise focus the parent row.
131
123
  if (this.isCell(item)) {
132
124
  let parent = this.collection.getItem(item.parentKey);
133
- let children1 = [
134
- ...parent.childNodes
135
- ];
136
- let prev = this.direction === "rtl" ? children1[item.index + 1] : children1[item.index - 1];
125
+ let children1 = (0, $cVkRF$getChildNodes)(parent, this.collection);
126
+ let prev = this.direction === "rtl" ? (0, $cVkRF$getNthItem)(children1, item.index + 1) : (0, $cVkRF$getNthItem)(children1, item.index - 1);
137
127
  if (prev) return prev.key;
138
128
  // focus row only if focusMode is set to row
139
129
  if (this.focusMode === "row") return item.parentKey;
@@ -149,9 +139,7 @@ class $d1c300d9c497e402$export$de9feff04fda126e {
149
139
  // move focus to the first cell in the parent row.
150
140
  if (this.isCell(item) && !global) {
151
141
  let parent = this.collection.getItem(item.parentKey);
152
- return [
153
- ...parent.childNodes
154
- ][0].key;
142
+ return (0, $cVkRF$getFirstItem)((0, $cVkRF$getChildNodes)(parent, this.collection)).key;
155
143
  }
156
144
  }
157
145
  // Find the first row
@@ -159,9 +147,7 @@ class $d1c300d9c497e402$export$de9feff04fda126e {
159
147
  // If global flag is set (or if focus mode is cell), focus the first cell in the first row.
160
148
  if (key != null && item && this.isCell(item) && global || this.focusMode === "cell") {
161
149
  let item1 = this.collection.getItem(key);
162
- key = [
163
- ...item1.childNodes
164
- ][0].key;
150
+ key = (0, $cVkRF$getFirstItem)((0, $cVkRF$getChildNodes)(item1, this.collection)).key;
165
151
  }
166
152
  // Otherwise, focus the row itself.
167
153
  return key;
@@ -175,10 +161,8 @@ class $d1c300d9c497e402$export$de9feff04fda126e {
175
161
  // move focus to the last cell in the parent row.
176
162
  if (this.isCell(item) && !global) {
177
163
  let parent = this.collection.getItem(item.parentKey);
178
- let children = [
179
- ...parent.childNodes
180
- ];
181
- return children[children.length - 1].key;
164
+ let children = (0, $cVkRF$getChildNodes)(parent, this.collection);
165
+ return (0, $cVkRF$getLastItem)(children).key;
182
166
  }
183
167
  }
184
168
  // Find the last row
@@ -186,10 +170,8 @@ class $d1c300d9c497e402$export$de9feff04fda126e {
186
170
  // If global flag is set (or if focus mode is cell), focus the last cell in the last row.
187
171
  if (key != null && item && this.isCell(item) && global || this.focusMode === "cell") {
188
172
  let item1 = this.collection.getItem(key);
189
- let children1 = [
190
- ...item1.childNodes
191
- ];
192
- key = children1[children1.length - 1].key;
173
+ let children1 = (0, $cVkRF$getChildNodes)(item1, this.collection);
174
+ key = (0, $cVkRF$getLastItem)(children1).key;
193
175
  }
194
176
  // Otherwise, focus the row itself.
195
177
  return key;
@@ -251,9 +233,7 @@ class $d1c300d9c497e402$export$de9feff04fda126e {
251
233
  if (item.textValue) {
252
234
  let substring = item.textValue.slice(0, search.length);
253
235
  if (this.collator.compare(substring, search) === 0) {
254
- if (this.isRow(item) && this.focusMode === "cell") return [
255
- ...item.childNodes
256
- ][0].key;
236
+ if (this.isRow(item) && this.focusMode === "cell") return (0, $cVkRF$getFirstItem)((0, $cVkRF$getChildNodes)(item, this.collection)).key;
257
237
  return item.key;
258
238
  }
259
239
  }
@@ -978,9 +958,10 @@ function $83c6e2eafa584c67$export$f6b86a04e5d66d90(props, state, ref) {
978
958
  sensitivity: "base"
979
959
  });
980
960
  let { direction: direction } = (0, $cVkRF$useLocale)();
961
+ let disabledBehavior = state.selectionManager.disabledBehavior;
981
962
  let delegate = (0, $cVkRF$useMemo)(()=>keyboardDelegate || new (0, $d1c300d9c497e402$export$de9feff04fda126e)({
982
963
  collection: state.collection,
983
- disabledKeys: state.disabledKeys,
964
+ disabledKeys: disabledBehavior === "selection" ? new Set() : state.disabledKeys,
984
965
  ref: ref,
985
966
  direction: direction,
986
967
  collator: collator,
@@ -989,6 +970,7 @@ function $83c6e2eafa584c67$export$f6b86a04e5d66d90(props, state, ref) {
989
970
  keyboardDelegate,
990
971
  state.collection,
991
972
  state.disabledKeys,
973
+ disabledBehavior,
992
974
  ref,
993
975
  direction,
994
976
  collator,
@@ -1068,7 +1050,7 @@ function $83c6e2eafa584c67$export$f6b86a04e5d66d90(props, state, ref) {
1068
1050
  function $4159a7a9cbb0cc18$export$96357d5a73f686fa(props, state, ref) {
1069
1051
  let { node: node , isVirtualized: isVirtualized , shouldSelectOnPressUp: shouldSelectOnPressUp , onAction: onAction } = props;
1070
1052
  let { actions: { onRowAction: onRowAction } } = (0, $1af922eb41e03c8f$export$e6235c0d09b995d0).get(state);
1071
- let { itemProps: itemProps , isPressed: isPressed } = (0, $cVkRF$useSelectableItem)({
1053
+ let { itemProps: itemProps , ...states } = (0, $cVkRF$useSelectableItem)({
1072
1054
  selectionManager: state.selectionManager,
1073
1055
  key: node.key,
1074
1056
  ref: ref,
@@ -1081,12 +1063,13 @@ function $4159a7a9cbb0cc18$export$96357d5a73f686fa(props, state, ref) {
1081
1063
  let rowProps = {
1082
1064
  role: "row",
1083
1065
  "aria-selected": state.selectionManager.selectionMode !== "none" ? isSelected : undefined,
1066
+ "aria-disabled": states.isDisabled || undefined,
1084
1067
  ...itemProps
1085
1068
  };
1086
1069
  if (isVirtualized) rowProps["aria-rowindex"] = node.index + 1; // aria-rowindex is 1 based
1087
1070
  return {
1088
1071
  rowProps: rowProps,
1089
- isPressed: isPressed
1072
+ ...states
1090
1073
  };
1091
1074
  }
1092
1075
 
package/dist/main.js CHANGED
@@ -1,3 +1,4 @@
1
+ var $2oePb$reactstatelycollections = require("@react-stately/collections");
1
2
  var $2oePb$reactstatelyvirtualizer = require("@react-stately/virtualizer");
2
3
  var $2oePb$reactariautils = require("@react-aria/utils");
3
4
  var $2oePb$react = require("react");
@@ -43,6 +44,7 @@ $parcel$export(module.exports, "useGridSelectionAnnouncement", () => $1eb174acfe
43
44
  * OF ANY KIND, either express or implied. See the License for the specific language
44
45
  * governing permissions and limitations under the License.
45
46
  */
47
+
46
48
  class $3187c0e19200cb16$export$de9feff04fda126e {
47
49
  isCell(node) {
48
50
  return node.type === "cell";
@@ -54,7 +56,7 @@ class $3187c0e19200cb16$export$de9feff04fda126e {
54
56
  let key = fromKey != null ? this.collection.getKeyBefore(fromKey) : this.collection.getLastKey();
55
57
  while(key != null){
56
58
  let item = this.collection.getItem(key);
57
- if (!pred || pred(item)) return key;
59
+ if (!this.disabledKeys.has(key) && (!pred || pred(item))) return key;
58
60
  key = this.collection.getKeyBefore(key);
59
61
  }
60
62
  }
@@ -62,7 +64,7 @@ class $3187c0e19200cb16$export$de9feff04fda126e {
62
64
  let key = fromKey != null ? this.collection.getKeyAfter(fromKey) : this.collection.getFirstKey();
63
65
  while(key != null){
64
66
  let item = this.collection.getItem(key);
65
- if (!pred || pred(item)) return key;
67
+ if (!this.disabledKeys.has(key) && (!pred || pred(item))) return key;
66
68
  key = this.collection.getKeyAfter(key);
67
69
  }
68
70
  }
@@ -77,9 +79,7 @@ class $3187c0e19200cb16$export$de9feff04fda126e {
77
79
  // If focus was on a cell, focus the cell with the same index in the next row.
78
80
  if (this.isCell(startItem)) {
79
81
  let item = this.collection.getItem(key);
80
- return [
81
- ...item.childNodes
82
- ][startItem.index].key;
82
+ return (0, $2oePb$reactstatelycollections.getNthItem)((0, $2oePb$reactstatelycollections.getChildNodes)(item, this.collection), startItem.index).key;
83
83
  }
84
84
  // Otherwise, focus the next row
85
85
  if (this.focusMode === "row") return key;
@@ -96,9 +96,7 @@ class $3187c0e19200cb16$export$de9feff04fda126e {
96
96
  // If focus was on a cell, focus the cell with the same index in the previous row.
97
97
  if (this.isCell(startItem)) {
98
98
  let item = this.collection.getItem(key);
99
- return [
100
- ...item.childNodes
101
- ][startItem.index].key;
99
+ return (0, $2oePb$reactstatelycollections.getNthItem)((0, $2oePb$reactstatelycollections.getChildNodes)(item, this.collection), startItem.index).key;
102
100
  }
103
101
  // Otherwise, focus the previous row
104
102
  if (this.focusMode === "row") return key;
@@ -109,19 +107,15 @@ class $3187c0e19200cb16$export$de9feff04fda126e {
109
107
  if (!item) return;
110
108
  // If focus is on a row, focus the first child cell.
111
109
  if (this.isRow(item)) {
112
- let children = [
113
- ...item.childNodes
114
- ];
115
- return this.direction === "rtl" ? children[children.length - 1].key : children[0].key;
110
+ let children = (0, $2oePb$reactstatelycollections.getChildNodes)(item, this.collection);
111
+ return this.direction === "rtl" ? (0, $2oePb$reactstatelycollections.getLastItem)(children).key : (0, $2oePb$reactstatelycollections.getFirstItem)(children).key;
116
112
  }
117
113
  // If focus is on a cell, focus the next cell if any,
118
114
  // otherwise focus the parent row.
119
115
  if (this.isCell(item)) {
120
116
  let parent = this.collection.getItem(item.parentKey);
121
- let children1 = [
122
- ...parent.childNodes
123
- ];
124
- let next = this.direction === "rtl" ? children1[item.index - 1] : children1[item.index + 1];
117
+ let children1 = (0, $2oePb$reactstatelycollections.getChildNodes)(parent, this.collection);
118
+ let next = this.direction === "rtl" ? (0, $2oePb$reactstatelycollections.getNthItem)(children1, item.index - 1) : (0, $2oePb$reactstatelycollections.getNthItem)(children1, item.index + 1);
125
119
  if (next) return next.key;
126
120
  // focus row only if focusMode is set to row
127
121
  if (this.focusMode === "row") return item.parentKey;
@@ -133,19 +127,15 @@ class $3187c0e19200cb16$export$de9feff04fda126e {
133
127
  if (!item) return;
134
128
  // If focus is on a row, focus the last child cell.
135
129
  if (this.isRow(item)) {
136
- let children = [
137
- ...item.childNodes
138
- ];
139
- return this.direction === "rtl" ? children[0].key : children[children.length - 1].key;
130
+ let children = (0, $2oePb$reactstatelycollections.getChildNodes)(item, this.collection);
131
+ return this.direction === "rtl" ? (0, $2oePb$reactstatelycollections.getFirstItem)(children).key : (0, $2oePb$reactstatelycollections.getLastItem)(children).key;
140
132
  }
141
133
  // If focus is on a cell, focus the previous cell if any,
142
134
  // otherwise focus the parent row.
143
135
  if (this.isCell(item)) {
144
136
  let parent = this.collection.getItem(item.parentKey);
145
- let children1 = [
146
- ...parent.childNodes
147
- ];
148
- let prev = this.direction === "rtl" ? children1[item.index + 1] : children1[item.index - 1];
137
+ let children1 = (0, $2oePb$reactstatelycollections.getChildNodes)(parent, this.collection);
138
+ let prev = this.direction === "rtl" ? (0, $2oePb$reactstatelycollections.getNthItem)(children1, item.index + 1) : (0, $2oePb$reactstatelycollections.getNthItem)(children1, item.index - 1);
149
139
  if (prev) return prev.key;
150
140
  // focus row only if focusMode is set to row
151
141
  if (this.focusMode === "row") return item.parentKey;
@@ -161,9 +151,7 @@ class $3187c0e19200cb16$export$de9feff04fda126e {
161
151
  // move focus to the first cell in the parent row.
162
152
  if (this.isCell(item) && !global) {
163
153
  let parent = this.collection.getItem(item.parentKey);
164
- return [
165
- ...parent.childNodes
166
- ][0].key;
154
+ return (0, $2oePb$reactstatelycollections.getFirstItem)((0, $2oePb$reactstatelycollections.getChildNodes)(parent, this.collection)).key;
167
155
  }
168
156
  }
169
157
  // Find the first row
@@ -171,9 +159,7 @@ class $3187c0e19200cb16$export$de9feff04fda126e {
171
159
  // If global flag is set (or if focus mode is cell), focus the first cell in the first row.
172
160
  if (key != null && item && this.isCell(item) && global || this.focusMode === "cell") {
173
161
  let item1 = this.collection.getItem(key);
174
- key = [
175
- ...item1.childNodes
176
- ][0].key;
162
+ key = (0, $2oePb$reactstatelycollections.getFirstItem)((0, $2oePb$reactstatelycollections.getChildNodes)(item1, this.collection)).key;
177
163
  }
178
164
  // Otherwise, focus the row itself.
179
165
  return key;
@@ -187,10 +173,8 @@ class $3187c0e19200cb16$export$de9feff04fda126e {
187
173
  // move focus to the last cell in the parent row.
188
174
  if (this.isCell(item) && !global) {
189
175
  let parent = this.collection.getItem(item.parentKey);
190
- let children = [
191
- ...parent.childNodes
192
- ];
193
- return children[children.length - 1].key;
176
+ let children = (0, $2oePb$reactstatelycollections.getChildNodes)(parent, this.collection);
177
+ return (0, $2oePb$reactstatelycollections.getLastItem)(children).key;
194
178
  }
195
179
  }
196
180
  // Find the last row
@@ -198,10 +182,8 @@ class $3187c0e19200cb16$export$de9feff04fda126e {
198
182
  // If global flag is set (or if focus mode is cell), focus the last cell in the last row.
199
183
  if (key != null && item && this.isCell(item) && global || this.focusMode === "cell") {
200
184
  let item1 = this.collection.getItem(key);
201
- let children1 = [
202
- ...item1.childNodes
203
- ];
204
- key = children1[children1.length - 1].key;
185
+ let children1 = (0, $2oePb$reactstatelycollections.getChildNodes)(item1, this.collection);
186
+ key = (0, $2oePb$reactstatelycollections.getLastItem)(children1).key;
205
187
  }
206
188
  // Otherwise, focus the row itself.
207
189
  return key;
@@ -263,9 +245,7 @@ class $3187c0e19200cb16$export$de9feff04fda126e {
263
245
  if (item.textValue) {
264
246
  let substring = item.textValue.slice(0, search.length);
265
247
  if (this.collator.compare(substring, search) === 0) {
266
- if (this.isRow(item) && this.focusMode === "cell") return [
267
- ...item.childNodes
268
- ][0].key;
248
+ if (this.isRow(item) && this.focusMode === "cell") return (0, $2oePb$reactstatelycollections.getFirstItem)((0, $2oePb$reactstatelycollections.getChildNodes)(item, this.collection)).key;
269
249
  return item.key;
270
250
  }
271
251
  }
@@ -990,9 +970,10 @@ function $11d770dfabe45077$export$f6b86a04e5d66d90(props, state, ref) {
990
970
  sensitivity: "base"
991
971
  });
992
972
  let { direction: direction } = (0, $2oePb$reactariai18n.useLocale)();
973
+ let disabledBehavior = state.selectionManager.disabledBehavior;
993
974
  let delegate = (0, $2oePb$react.useMemo)(()=>keyboardDelegate || new (0, $3187c0e19200cb16$export$de9feff04fda126e)({
994
975
  collection: state.collection,
995
- disabledKeys: state.disabledKeys,
976
+ disabledKeys: disabledBehavior === "selection" ? new Set() : state.disabledKeys,
996
977
  ref: ref,
997
978
  direction: direction,
998
979
  collator: collator,
@@ -1001,6 +982,7 @@ function $11d770dfabe45077$export$f6b86a04e5d66d90(props, state, ref) {
1001
982
  keyboardDelegate,
1002
983
  state.collection,
1003
984
  state.disabledKeys,
985
+ disabledBehavior,
1004
986
  ref,
1005
987
  direction,
1006
988
  collator,
@@ -1080,7 +1062,7 @@ function $11d770dfabe45077$export$f6b86a04e5d66d90(props, state, ref) {
1080
1062
  function $eed398987c639831$export$96357d5a73f686fa(props, state, ref) {
1081
1063
  let { node: node , isVirtualized: isVirtualized , shouldSelectOnPressUp: shouldSelectOnPressUp , onAction: onAction } = props;
1082
1064
  let { actions: { onRowAction: onRowAction } } = (0, $8ee34951196858d0$export$e6235c0d09b995d0).get(state);
1083
- let { itemProps: itemProps , isPressed: isPressed } = (0, $2oePb$reactariaselection.useSelectableItem)({
1065
+ let { itemProps: itemProps , ...states } = (0, $2oePb$reactariaselection.useSelectableItem)({
1084
1066
  selectionManager: state.selectionManager,
1085
1067
  key: node.key,
1086
1068
  ref: ref,
@@ -1093,12 +1075,13 @@ function $eed398987c639831$export$96357d5a73f686fa(props, state, ref) {
1093
1075
  let rowProps = {
1094
1076
  role: "row",
1095
1077
  "aria-selected": state.selectionManager.selectionMode !== "none" ? isSelected : undefined,
1078
+ "aria-disabled": states.isDisabled || undefined,
1096
1079
  ...itemProps
1097
1080
  };
1098
1081
  if (isVirtualized) rowProps["aria-rowindex"] = node.index + 1; // aria-rowindex is 1 based
1099
1082
  return {
1100
1083
  rowProps: rowProps,
1101
- isPressed: isPressed
1084
+ ...states
1102
1085
  };
1103
1086
  }
1104
1087