@workday/canvas-kit-react 7.2.0-next.0 → 7.2.0
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/action-bar/lib/ActionBarList.tsx +2 -9
- package/action-bar/package.json +2 -1
- package/avatar/package.json +2 -1
- package/badge/package.json +2 -1
- package/banner/package.json +2 -1
- package/button/lib/TertiaryButton.tsx +18 -7
- package/button/package.json +2 -1
- package/card/package.json +2 -1
- package/checkbox/package.json +2 -1
- package/collection/index.ts +2 -0
- package/collection/lib/useBaseListModel.tsx +1 -1
- package/collection/lib/useCursorListModel.tsx +88 -20
- package/collection/lib/useGridModel.ts +34 -0
- package/collection/lib/useListItemRovingFocus.tsx +6 -4
- package/collection/package.json +2 -1
- package/color-picker/package.json +2 -1
- package/common/package.json +2 -1
- package/dialog/package.json +2 -1
- package/disclosure/package.json +2 -1
- package/dist/commonjs/action-bar/lib/ActionBarList.d.ts +0 -58
- package/dist/commonjs/action-bar/lib/ActionBarList.d.ts.map +1 -1
- package/dist/commonjs/action-bar/lib/ActionBarList.js +2 -3
- package/dist/commonjs/button/lib/TertiaryButton.d.ts +9 -0
- package/dist/commonjs/button/lib/TertiaryButton.d.ts.map +1 -1
- package/dist/commonjs/button/lib/TertiaryButton.js +9 -8
- package/dist/commonjs/collection/index.d.ts +2 -0
- package/dist/commonjs/collection/index.d.ts.map +1 -1
- package/dist/commonjs/collection/index.js +5 -1
- package/dist/commonjs/collection/lib/useBaseListModel.js +1 -1
- package/dist/commonjs/collection/lib/useCursorListModel.d.ts +64 -101
- package/dist/commonjs/collection/lib/useCursorListModel.d.ts.map +1 -1
- package/dist/commonjs/collection/lib/useCursorListModel.js +64 -23
- package/dist/commonjs/collection/lib/useGridModel.d.ts +955 -0
- package/dist/commonjs/collection/lib/useGridModel.d.ts.map +1 -0
- package/dist/commonjs/collection/lib/useGridModel.js +52 -0
- package/dist/commonjs/collection/lib/useListItemRovingFocus.d.ts.map +1 -1
- package/dist/commonjs/collection/lib/useListItemRovingFocus.js +6 -4
- package/dist/commonjs/pagination/lib/Pagination/PageButton.d.ts.map +1 -1
- package/dist/commonjs/pagination/lib/Pagination/PageButton.js +0 -1
- package/dist/commonjs/pagination/lib/Pagination/common/useLiveRegion.d.ts +0 -1
- package/dist/commonjs/pagination/lib/Pagination/common/useLiveRegion.d.ts.map +1 -1
- package/dist/commonjs/pagination/lib/Pagination/common/useLiveRegion.js +1 -1
- package/dist/commonjs/radio/lib/RadioGroup.d.ts.map +1 -1
- package/dist/commonjs/radio/lib/RadioGroup.js +5 -1
- package/dist/es6/action-bar/lib/ActionBarList.d.ts +0 -58
- package/dist/es6/action-bar/lib/ActionBarList.d.ts.map +1 -1
- package/dist/es6/action-bar/lib/ActionBarList.js +3 -4
- package/dist/es6/button/lib/TertiaryButton.d.ts +9 -0
- package/dist/es6/button/lib/TertiaryButton.d.ts.map +1 -1
- package/dist/es6/button/lib/TertiaryButton.js +9 -8
- package/dist/es6/collection/index.d.ts +2 -0
- package/dist/es6/collection/index.d.ts.map +1 -1
- package/dist/es6/collection/index.js +2 -0
- package/dist/es6/collection/lib/useBaseListModel.js +1 -1
- package/dist/es6/collection/lib/useCursorListModel.d.ts +64 -101
- package/dist/es6/collection/lib/useCursorListModel.d.ts.map +1 -1
- package/dist/es6/collection/lib/useCursorListModel.js +64 -23
- package/dist/es6/collection/lib/useGridModel.d.ts +955 -0
- package/dist/es6/collection/lib/useGridModel.d.ts.map +1 -0
- package/dist/es6/collection/lib/useGridModel.js +49 -0
- package/dist/es6/collection/lib/useListItemRovingFocus.d.ts.map +1 -1
- package/dist/es6/collection/lib/useListItemRovingFocus.js +6 -4
- package/dist/es6/pagination/lib/Pagination/PageButton.d.ts.map +1 -1
- package/dist/es6/pagination/lib/Pagination/PageButton.js +0 -1
- package/dist/es6/pagination/lib/Pagination/common/useLiveRegion.d.ts +0 -1
- package/dist/es6/pagination/lib/Pagination/common/useLiveRegion.d.ts.map +1 -1
- package/dist/es6/pagination/lib/Pagination/common/useLiveRegion.js +1 -1
- package/dist/es6/radio/lib/RadioGroup.d.ts.map +1 -1
- package/dist/es6/radio/lib/RadioGroup.js +5 -1
- package/form-field/package.json +2 -1
- package/icon/package.json +2 -1
- package/layout/package.json +2 -1
- package/loading-animation/package.json +2 -1
- package/menu/package.json +2 -1
- package/modal/package.json +2 -1
- package/package.json +5 -5
- package/pagination/lib/Pagination/PageButton.tsx +0 -1
- package/pagination/lib/Pagination/common/useLiveRegion.tsx +0 -2
- package/pagination/package.json +2 -1
- package/popup/package.json +2 -1
- package/radio/lib/RadioGroup.tsx +5 -1
- package/radio/package.json +2 -1
- package/segmented-control/package.json +2 -1
- package/select/package.json +2 -1
- package/side-panel/package.json +2 -1
- package/skeleton/package.json +2 -1
- package/status-indicator/package.json +2 -1
- package/switch/package.json +2 -1
- package/table/package.json +2 -1
- package/tabs/package.json +2 -1
- package/text-area/package.json +2 -1
- package/text-input/package.json +2 -1
- package/toast/package.json +2 -1
- package/tokens/package.json +2 -1
- package/tooltip/package.json +2 -1
|
@@ -59,8 +59,8 @@ exports.getLast = getLast;
|
|
|
59
59
|
var getFirstOfRow = function (id, _a) {
|
|
60
60
|
var state = _a.state;
|
|
61
61
|
if (state.columnCount) {
|
|
62
|
-
var
|
|
63
|
-
var currentIndex =
|
|
62
|
+
var item = getItem(id, { state: state });
|
|
63
|
+
var currentIndex = item.index;
|
|
64
64
|
var offset = currentIndex % state.columnCount;
|
|
65
65
|
return state.items[currentIndex - offset];
|
|
66
66
|
}
|
|
@@ -73,10 +73,14 @@ exports.getFirstOfRow = getFirstOfRow;
|
|
|
73
73
|
var getLastOfRow = function (id, _a) {
|
|
74
74
|
var state = _a.state;
|
|
75
75
|
if (state.columnCount) {
|
|
76
|
-
var
|
|
77
|
-
var currentIndex =
|
|
76
|
+
var item = getItem(id, { state: state });
|
|
77
|
+
var currentIndex = item.index;
|
|
78
78
|
var offset = (currentIndex % state.columnCount) - state.columnCount + 1;
|
|
79
|
-
|
|
79
|
+
var nextIndex = currentIndex - offset;
|
|
80
|
+
if (nextIndex >= state.items.length) {
|
|
81
|
+
nextIndex = state.items.length - 1;
|
|
82
|
+
}
|
|
83
|
+
return state.items[nextIndex];
|
|
80
84
|
}
|
|
81
85
|
return exports.getLast(id, { state: state });
|
|
82
86
|
};
|
|
@@ -88,8 +92,8 @@ exports.getLastOfRow = getLastOfRow;
|
|
|
88
92
|
var getPreviousPage = function (id, _a) {
|
|
89
93
|
var state = _a.state;
|
|
90
94
|
if (state.columnCount) {
|
|
91
|
-
var
|
|
92
|
-
var currentIndex =
|
|
95
|
+
var item = getItem(id, { state: state });
|
|
96
|
+
var currentIndex = item.index;
|
|
93
97
|
return state.items[currentIndex % state.columnCount];
|
|
94
98
|
}
|
|
95
99
|
return exports.getFirst(id, { state: state });
|
|
@@ -102,8 +106,8 @@ exports.getPreviousPage = getPreviousPage;
|
|
|
102
106
|
var getNextPage = function (id, _a) {
|
|
103
107
|
var state = _a.state;
|
|
104
108
|
if (state.columnCount) {
|
|
105
|
-
var
|
|
106
|
-
var currentIndex =
|
|
109
|
+
var item = getItem(id, { state: state });
|
|
110
|
+
var currentIndex = item.index;
|
|
107
111
|
var lastRowIndex = state.items.length - state.columnCount;
|
|
108
112
|
return state.items[lastRowIndex + (currentIndex % state.columnCount)];
|
|
109
113
|
}
|
|
@@ -121,13 +125,40 @@ var getWrappingOffsetItem = function (offset) { return function (id, _a, tries)
|
|
|
121
125
|
if (tries === void 0) { tries = state.items.length; }
|
|
122
126
|
var items = state.items;
|
|
123
127
|
var item = getItem(id, { state: state });
|
|
124
|
-
var currentIndex =
|
|
128
|
+
var currentIndex = item.index;
|
|
125
129
|
var nextIndex = currentIndex + offset;
|
|
130
|
+
// calculate idealLength as in if the grid was a perfect rectangle
|
|
131
|
+
var rows = Math.ceil(items.length / state.columnCount);
|
|
132
|
+
var idealLength = rows * state.columnCount;
|
|
126
133
|
if (nextIndex < 0) {
|
|
127
|
-
|
|
134
|
+
if (offset === -1) {
|
|
135
|
+
// if the offset is -1, we want to wrap to the end
|
|
136
|
+
nextIndex = items.length - 1;
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
// if the offset is smaller than -1, we want to wrap by column
|
|
140
|
+
if (idealLength + nextIndex >= items.length) {
|
|
141
|
+
// we'll overflow the grid because there isn't enough items. Move `nextIndex` up so we wrap in
|
|
142
|
+
// the right spot
|
|
143
|
+
nextIndex -= state.columnCount;
|
|
144
|
+
}
|
|
145
|
+
nextIndex = idealLength + nextIndex;
|
|
146
|
+
}
|
|
128
147
|
}
|
|
129
148
|
else if (nextIndex >= items.length) {
|
|
130
|
-
|
|
149
|
+
if (offset === 1) {
|
|
150
|
+
// if the offset is 1, we want to wrap to the beginning
|
|
151
|
+
nextIndex = 0;
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
// if the offset is larger than 1, we want to wrap by column
|
|
155
|
+
if (nextIndex - idealLength < 0) {
|
|
156
|
+
// we're going to overflow the grid because there isn't enough items. Move `nextIndex` down to
|
|
157
|
+
// the missing item in the next row. This way we'll end up wrapping in the right spot
|
|
158
|
+
nextIndex += state.columnCount;
|
|
159
|
+
}
|
|
160
|
+
nextIndex = nextIndex - idealLength;
|
|
161
|
+
}
|
|
131
162
|
}
|
|
132
163
|
if (state.nonInteractiveIds.includes(useBaseListModel_1.defaultGetId(items[nextIndex])) && tries > 0) {
|
|
133
164
|
// The next item is disabled, try again, but only if we haven't already tried everything.
|
|
@@ -142,7 +173,7 @@ var getOffsetItem = function (offset) { return function (id, _a, tries) {
|
|
|
142
173
|
if (tries === void 0) { tries = state.items.length; }
|
|
143
174
|
var items = state.items, columnCount = state.columnCount;
|
|
144
175
|
var item = getItem(id, { state: state });
|
|
145
|
-
var currentIndex =
|
|
176
|
+
var currentIndex = item.index;
|
|
146
177
|
var nextIndex = currentIndex + offset;
|
|
147
178
|
if (Math.abs(offset) < columnCount) {
|
|
148
179
|
// if we're here, the columnCount is non-zero and the absolute value of offset is less than the
|
|
@@ -160,8 +191,13 @@ var getOffsetItem = function (offset) { return function (id, _a, tries) {
|
|
|
160
191
|
if (nextRow < 0 || nextRow >= columnCount) {
|
|
161
192
|
nextIndex = currentIndex;
|
|
162
193
|
}
|
|
194
|
+
// make sure we don't go out of bounds if the grid isn't a perfect rectangle
|
|
195
|
+
if (nextIndex > items.length - 1) {
|
|
196
|
+
nextIndex = currentIndex;
|
|
197
|
+
}
|
|
163
198
|
}
|
|
164
|
-
|
|
199
|
+
// make sure we're always in bounds
|
|
200
|
+
if (nextIndex < 0) {
|
|
165
201
|
nextIndex = 0;
|
|
166
202
|
}
|
|
167
203
|
else if (nextIndex >= items.length) {
|
|
@@ -176,7 +212,9 @@ var getOffsetItem = function (offset) { return function (id, _a, tries) {
|
|
|
176
212
|
}; };
|
|
177
213
|
exports.getOffsetItem = getOffsetItem;
|
|
178
214
|
/**
|
|
179
|
-
* The default navigation manager of lists
|
|
215
|
+
* The default navigation manager of lists. This navigation manager will wrap around when the edge
|
|
216
|
+
* is hit. For example, if the user is the the right-most item in a list or right-most item in a
|
|
217
|
+
* row, the cursor will wrap around to the beginning or the next row.
|
|
180
218
|
*/
|
|
181
219
|
exports.wrappingNavigationManager = exports.createNavigationManager({
|
|
182
220
|
getFirst: exports.getFirst,
|
|
@@ -185,18 +223,22 @@ exports.wrappingNavigationManager = exports.createNavigationManager({
|
|
|
185
223
|
getNext: exports.getWrappingOffsetItem(1),
|
|
186
224
|
getNextRow: function (id, _a) {
|
|
187
225
|
var state = _a.state;
|
|
188
|
-
return exports.getWrappingOffsetItem(
|
|
226
|
+
return exports.getWrappingOffsetItem(state.columnCount)(id, { state: state });
|
|
189
227
|
},
|
|
190
228
|
getPrevious: exports.getWrappingOffsetItem(-1),
|
|
191
229
|
getPreviousRow: function (id, _a) {
|
|
192
230
|
var state = _a.state;
|
|
193
|
-
return exports.getWrappingOffsetItem(state.columnCount)(id, { state: state });
|
|
231
|
+
return exports.getWrappingOffsetItem(-state.columnCount)(id, { state: state });
|
|
194
232
|
},
|
|
195
233
|
getPreviousPage: exports.getPreviousPage,
|
|
196
234
|
getNextPage: exports.getNextPage,
|
|
197
235
|
getFirstOfRow: exports.getFirstOfRow,
|
|
198
236
|
getLastOfRow: exports.getLastOfRow,
|
|
199
237
|
});
|
|
238
|
+
/**
|
|
239
|
+
* The default navigation of grids. This navigation manager will not wrap, but will stop when an
|
|
240
|
+
* edge is detected. This could be the last item in a list or the last item of a row in a grid.
|
|
241
|
+
*/
|
|
200
242
|
exports.navigationManager = exports.createNavigationManager({
|
|
201
243
|
getFirst: exports.getFirst,
|
|
202
244
|
getLast: exports.getLast,
|
|
@@ -204,12 +246,12 @@ exports.navigationManager = exports.createNavigationManager({
|
|
|
204
246
|
getNext: exports.getOffsetItem(1),
|
|
205
247
|
getNextRow: function (id, _a) {
|
|
206
248
|
var state = _a.state;
|
|
207
|
-
return exports.getOffsetItem(
|
|
249
|
+
return exports.getOffsetItem(state.columnCount)(id, { state: state });
|
|
208
250
|
},
|
|
209
251
|
getPrevious: exports.getOffsetItem(-1),
|
|
210
252
|
getPreviousRow: function (id, _a) {
|
|
211
253
|
var state = _a.state;
|
|
212
|
-
return exports.getOffsetItem(state.columnCount)(id, { state: state });
|
|
254
|
+
return exports.getOffsetItem(-state.columnCount)(id, { state: state });
|
|
213
255
|
},
|
|
214
256
|
getPreviousPage: exports.getPreviousPage,
|
|
215
257
|
getNextPage: exports.getNextPage,
|
|
@@ -238,9 +280,7 @@ exports.useCursorListModel = common_1.createModelHook({
|
|
|
238
280
|
* (left-to-right or right-to-left) and call the correct navigation method. In our example, a
|
|
239
281
|
* left-to-right language would send a `getNext`. The navigation manager may return the next item
|
|
240
282
|
* in the list. Different managers can be created for slightly different use cases. The default
|
|
241
|
-
* navigation manager will accept `orientation` and directionality to determine mapping.
|
|
242
|
-
* `columnCount` is non-zero, it will use a grid mode where `orientation` is ignored and only
|
|
243
|
-
* directionality matters.
|
|
283
|
+
* navigation manager will accept `orientation` and directionality to determine mapping.
|
|
244
284
|
*
|
|
245
285
|
* An example override might be a tab list with an overflow menu that is meant to be transparent
|
|
246
286
|
* to screen reader users. This would require the overflow menu to accept both up/down keys as
|
|
@@ -254,15 +294,16 @@ exports.useCursorListModel = common_1.createModelHook({
|
|
|
254
294
|
var columnCount = config.columnCount || 0;
|
|
255
295
|
var list = useBaseListModel_1.useBaseListModel(config);
|
|
256
296
|
var initialCurrentRef = react_1.default.useRef(config.initialCursorId || (((_a = config.items) === null || _a === void 0 ? void 0 : _a.length) ? useBaseListModel_1.defaultGetId(config.items[0]) : ''));
|
|
297
|
+
var navigation = config.navigation;
|
|
257
298
|
var state = __assign(__assign({}, list.state), {
|
|
258
299
|
/** The id of the list item the cursor is pointing to */
|
|
259
300
|
cursorId: cursorId,
|
|
260
301
|
/**
|
|
261
302
|
* Any positive non-zero value treats the list like a grid with rows and columns
|
|
262
303
|
* @default 0
|
|
304
|
+
* @private Use useGridModel instead to make a grid instead of a list
|
|
263
305
|
*/
|
|
264
306
|
columnCount: columnCount });
|
|
265
|
-
var navigation = config.navigation || exports.wrappingNavigationManager;
|
|
266
307
|
var events = __assign(__assign({}, list.events), {
|
|
267
308
|
/**
|
|
268
309
|
* Register an item to the list. Takes in an identifier, a React.Ref and an optional index. This
|