@cloudscape-design/components-themeable 3.0.589 → 3.0.591
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/lib/internal/manifest.json +1 -1
- package/lib/internal/scss/container/styles.scss +2 -0
- package/lib/internal/scss/table/body-cell/styles.scss +32 -16
- package/lib/internal/template/area-chart/model/use-chart-model.js +1 -1
- package/lib/internal/template/area-chart/model/use-chart-model.js.map +1 -1
- package/lib/internal/template/container/styles.css.js +30 -30
- package/lib/internal/template/container/styles.scoped.css +56 -54
- package/lib/internal/template/container/styles.selectors.js +30 -30
- package/lib/internal/template/internal/environment.js +1 -1
- package/lib/internal/template/internal/environment.json +1 -1
- package/lib/internal/template/internal/hooks/use-virtual/index.d.ts +1 -1
- package/lib/internal/template/internal/hooks/use-virtual/index.d.ts.map +1 -1
- package/lib/internal/template/internal/hooks/use-virtual/index.js +1 -1
- package/lib/internal/template/internal/hooks/use-virtual/index.js.map +1 -1
- package/lib/internal/template/internal/vendor/react-virtual.js +529 -0
- package/lib/internal/template/line-chart/index.d.ts.map +1 -1
- package/lib/internal/template/line-chart/index.js +11 -1
- package/lib/internal/template/line-chart/index.js.map +1 -1
- package/lib/internal/template/mixed-line-bar-chart/hooks/use-mouse-hover.js +1 -1
- package/lib/internal/template/mixed-line-bar-chart/hooks/use-mouse-hover.js.map +1 -1
- package/lib/internal/template/package.json +0 -1
- package/lib/internal/template/select/utils/render-options.d.ts +1 -1
- package/lib/internal/template/select/utils/render-options.d.ts.map +1 -1
- package/lib/internal/template/select/utils/render-options.js.map +1 -1
- package/lib/internal/template/table/body-cell/disabled-inline-editor.d.ts +1 -1
- package/lib/internal/template/table/body-cell/disabled-inline-editor.d.ts.map +1 -1
- package/lib/internal/template/table/body-cell/disabled-inline-editor.js +7 -6
- package/lib/internal/template/table/body-cell/disabled-inline-editor.js.map +1 -1
- package/lib/internal/template/table/body-cell/index.d.ts +1 -0
- package/lib/internal/template/table/body-cell/index.d.ts.map +1 -1
- package/lib/internal/template/table/body-cell/index.js +5 -4
- package/lib/internal/template/table/body-cell/index.js.map +1 -1
- package/lib/internal/template/table/body-cell/styles.css.js +29 -30
- package/lib/internal/template/table/body-cell/styles.scoped.css +113 -84
- package/lib/internal/template/table/body-cell/styles.selectors.js +29 -30
- package/package.json +1 -1
|
@@ -0,0 +1,529 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Name: react-virtual
|
|
3
|
+
* Version: 2.10.4
|
|
4
|
+
* License: MIT
|
|
5
|
+
* Private: false
|
|
6
|
+
* Description: Hooks for virtualizing scrollable elements in React
|
|
7
|
+
* Repository: undefined
|
|
8
|
+
* Homepage: https://github.com/tannerlinsley/react-virtual#readme
|
|
9
|
+
* Author: tannerlinsley
|
|
10
|
+
* License Copyright:
|
|
11
|
+
* ===
|
|
12
|
+
*
|
|
13
|
+
* MIT License
|
|
14
|
+
*
|
|
15
|
+
* Copyright (c) 2019 Tanner Linsley
|
|
16
|
+
*
|
|
17
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
18
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
19
|
+
* in the Software without restriction, including without limitation the rights
|
|
20
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
21
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
22
|
+
* furnished to do so, subject to the following conditions:
|
|
23
|
+
*
|
|
24
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
25
|
+
* copies or substantial portions of the Software.
|
|
26
|
+
*
|
|
27
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
28
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
29
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
30
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
31
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
32
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
33
|
+
* SOFTWARE.
|
|
34
|
+
*/
|
|
35
|
+
import React from 'react';
|
|
36
|
+
|
|
37
|
+
function _extends() {
|
|
38
|
+
_extends = Object.assign || function (target) {
|
|
39
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
40
|
+
var source = arguments[i];
|
|
41
|
+
|
|
42
|
+
for (var key in source) {
|
|
43
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
44
|
+
target[key] = source[key];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return target;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
return _extends.apply(this, arguments);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
56
|
+
if (source == null) return {};
|
|
57
|
+
var target = {};
|
|
58
|
+
var sourceKeys = Object.keys(source);
|
|
59
|
+
var key, i;
|
|
60
|
+
|
|
61
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
62
|
+
key = sourceKeys[i];
|
|
63
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
64
|
+
target[key] = source[key];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return target;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
var props = ['bottom', 'height', 'left', 'right', 'top', 'width'];
|
|
71
|
+
|
|
72
|
+
var rectChanged = function rectChanged(a, b) {
|
|
73
|
+
if (a === void 0) {
|
|
74
|
+
a = {};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (b === void 0) {
|
|
78
|
+
b = {};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return props.some(function (prop) {
|
|
82
|
+
return a[prop] !== b[prop];
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
var observedNodes = /*#__PURE__*/new Map();
|
|
87
|
+
var rafId;
|
|
88
|
+
|
|
89
|
+
var run = function run() {
|
|
90
|
+
var changedStates = [];
|
|
91
|
+
observedNodes.forEach(function (state, node) {
|
|
92
|
+
var newRect = node.getBoundingClientRect();
|
|
93
|
+
|
|
94
|
+
if (rectChanged(newRect, state.rect)) {
|
|
95
|
+
state.rect = newRect;
|
|
96
|
+
changedStates.push(state);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
changedStates.forEach(function (state) {
|
|
100
|
+
state.callbacks.forEach(function (cb) {
|
|
101
|
+
return cb(state.rect);
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
rafId = window.requestAnimationFrame(run);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
function observeRect(node, cb) {
|
|
108
|
+
return {
|
|
109
|
+
observe: function observe() {
|
|
110
|
+
var wasEmpty = observedNodes.size === 0;
|
|
111
|
+
|
|
112
|
+
if (observedNodes.has(node)) {
|
|
113
|
+
observedNodes.get(node).callbacks.push(cb);
|
|
114
|
+
} else {
|
|
115
|
+
observedNodes.set(node, {
|
|
116
|
+
rect: undefined,
|
|
117
|
+
hasRectChanged: false,
|
|
118
|
+
callbacks: [cb]
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (wasEmpty) run();
|
|
123
|
+
},
|
|
124
|
+
unobserve: function unobserve() {
|
|
125
|
+
var state = observedNodes.get(node);
|
|
126
|
+
|
|
127
|
+
if (state) {
|
|
128
|
+
// Remove the callback
|
|
129
|
+
var index = state.callbacks.indexOf(cb);
|
|
130
|
+
if (index >= 0) state.callbacks.splice(index, 1); // Remove the node reference
|
|
131
|
+
|
|
132
|
+
if (!state.callbacks.length) observedNodes["delete"](node); // Stop the loop
|
|
133
|
+
|
|
134
|
+
if (!observedNodes.size) cancelAnimationFrame(rafId);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
var useIsomorphicLayoutEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;
|
|
141
|
+
|
|
142
|
+
function useRect(nodeRef, initialRect) {
|
|
143
|
+
if (initialRect === void 0) {
|
|
144
|
+
initialRect = {
|
|
145
|
+
width: 0,
|
|
146
|
+
height: 0
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
var _React$useState = React.useState(nodeRef.current),
|
|
151
|
+
element = _React$useState[0],
|
|
152
|
+
setElement = _React$useState[1];
|
|
153
|
+
|
|
154
|
+
var _React$useReducer = React.useReducer(rectReducer, initialRect),
|
|
155
|
+
rect = _React$useReducer[0],
|
|
156
|
+
dispatch = _React$useReducer[1];
|
|
157
|
+
|
|
158
|
+
var initialRectSet = React.useRef(false);
|
|
159
|
+
useIsomorphicLayoutEffect(function () {
|
|
160
|
+
if (nodeRef.current !== element) {
|
|
161
|
+
setElement(nodeRef.current);
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
useIsomorphicLayoutEffect(function () {
|
|
165
|
+
if (element && !initialRectSet.current) {
|
|
166
|
+
initialRectSet.current = true;
|
|
167
|
+
|
|
168
|
+
var _rect = element.getBoundingClientRect();
|
|
169
|
+
|
|
170
|
+
dispatch({
|
|
171
|
+
rect: _rect
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}, [element]);
|
|
175
|
+
React.useEffect(function () {
|
|
176
|
+
if (!element) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
var observer = observeRect(element, function (rect) {
|
|
181
|
+
dispatch({
|
|
182
|
+
rect: rect
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
observer.observe();
|
|
186
|
+
return function () {
|
|
187
|
+
observer.unobserve();
|
|
188
|
+
};
|
|
189
|
+
}, [element]);
|
|
190
|
+
return rect;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function rectReducer(state, action) {
|
|
194
|
+
var rect = action.rect;
|
|
195
|
+
|
|
196
|
+
if (state.height !== rect.height || state.width !== rect.width) {
|
|
197
|
+
return rect;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return state;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
var defaultEstimateSize = function defaultEstimateSize() {
|
|
204
|
+
return 50;
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
var defaultKeyExtractor = function defaultKeyExtractor(index) {
|
|
208
|
+
return index;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
var defaultMeasureSize = function defaultMeasureSize(el, horizontal) {
|
|
212
|
+
var key = horizontal ? 'offsetWidth' : 'offsetHeight';
|
|
213
|
+
return el[key];
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
var defaultRangeExtractor = function defaultRangeExtractor(range) {
|
|
217
|
+
var start = Math.max(range.start - range.overscan, 0);
|
|
218
|
+
var end = Math.min(range.end + range.overscan, range.size - 1);
|
|
219
|
+
var arr = [];
|
|
220
|
+
|
|
221
|
+
for (var i = start; i <= end; i++) {
|
|
222
|
+
arr.push(i);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return arr;
|
|
226
|
+
};
|
|
227
|
+
function useVirtual(_ref) {
|
|
228
|
+
var _measurements;
|
|
229
|
+
|
|
230
|
+
var _ref$size = _ref.size,
|
|
231
|
+
size = _ref$size === void 0 ? 0 : _ref$size,
|
|
232
|
+
_ref$estimateSize = _ref.estimateSize,
|
|
233
|
+
estimateSize = _ref$estimateSize === void 0 ? defaultEstimateSize : _ref$estimateSize,
|
|
234
|
+
_ref$overscan = _ref.overscan,
|
|
235
|
+
overscan = _ref$overscan === void 0 ? 1 : _ref$overscan,
|
|
236
|
+
_ref$paddingStart = _ref.paddingStart,
|
|
237
|
+
paddingStart = _ref$paddingStart === void 0 ? 0 : _ref$paddingStart,
|
|
238
|
+
_ref$paddingEnd = _ref.paddingEnd,
|
|
239
|
+
paddingEnd = _ref$paddingEnd === void 0 ? 0 : _ref$paddingEnd,
|
|
240
|
+
parentRef = _ref.parentRef,
|
|
241
|
+
horizontal = _ref.horizontal,
|
|
242
|
+
scrollToFn = _ref.scrollToFn,
|
|
243
|
+
useObserver = _ref.useObserver,
|
|
244
|
+
initialRect = _ref.initialRect,
|
|
245
|
+
onScrollElement = _ref.onScrollElement,
|
|
246
|
+
scrollOffsetFn = _ref.scrollOffsetFn,
|
|
247
|
+
_ref$keyExtractor = _ref.keyExtractor,
|
|
248
|
+
keyExtractor = _ref$keyExtractor === void 0 ? defaultKeyExtractor : _ref$keyExtractor,
|
|
249
|
+
_ref$measureSize = _ref.measureSize,
|
|
250
|
+
measureSize = _ref$measureSize === void 0 ? defaultMeasureSize : _ref$measureSize,
|
|
251
|
+
_ref$rangeExtractor = _ref.rangeExtractor,
|
|
252
|
+
rangeExtractor = _ref$rangeExtractor === void 0 ? defaultRangeExtractor : _ref$rangeExtractor;
|
|
253
|
+
var sizeKey = horizontal ? 'width' : 'height';
|
|
254
|
+
var scrollKey = horizontal ? 'scrollLeft' : 'scrollTop';
|
|
255
|
+
var latestRef = React.useRef({
|
|
256
|
+
scrollOffset: 0,
|
|
257
|
+
measurements: []
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
var _React$useState = React.useState(0),
|
|
261
|
+
scrollOffset = _React$useState[0],
|
|
262
|
+
setScrollOffset = _React$useState[1];
|
|
263
|
+
|
|
264
|
+
latestRef.current.scrollOffset = scrollOffset;
|
|
265
|
+
var useMeasureParent = useObserver || useRect;
|
|
266
|
+
|
|
267
|
+
var _useMeasureParent = useMeasureParent(parentRef, initialRect),
|
|
268
|
+
outerSize = _useMeasureParent[sizeKey];
|
|
269
|
+
|
|
270
|
+
latestRef.current.outerSize = outerSize;
|
|
271
|
+
var defaultScrollToFn = React.useCallback(function (offset) {
|
|
272
|
+
if (parentRef.current) {
|
|
273
|
+
parentRef.current[scrollKey] = offset;
|
|
274
|
+
}
|
|
275
|
+
}, [parentRef, scrollKey]);
|
|
276
|
+
var resolvedScrollToFn = scrollToFn || defaultScrollToFn;
|
|
277
|
+
scrollToFn = React.useCallback(function (offset) {
|
|
278
|
+
resolvedScrollToFn(offset, defaultScrollToFn);
|
|
279
|
+
}, [defaultScrollToFn, resolvedScrollToFn]);
|
|
280
|
+
|
|
281
|
+
var _React$useState2 = React.useState({}),
|
|
282
|
+
measuredCache = _React$useState2[0],
|
|
283
|
+
setMeasuredCache = _React$useState2[1];
|
|
284
|
+
|
|
285
|
+
var measure = React.useCallback(function () {
|
|
286
|
+
return setMeasuredCache({});
|
|
287
|
+
}, []);
|
|
288
|
+
var pendingMeasuredCacheIndexesRef = React.useRef([]);
|
|
289
|
+
var measurements = React.useMemo(function () {
|
|
290
|
+
var min = pendingMeasuredCacheIndexesRef.current.length > 0 ? Math.min.apply(Math, pendingMeasuredCacheIndexesRef.current) : 0;
|
|
291
|
+
pendingMeasuredCacheIndexesRef.current = [];
|
|
292
|
+
var measurements = latestRef.current.measurements.slice(0, min);
|
|
293
|
+
|
|
294
|
+
for (var i = min; i < size; i++) {
|
|
295
|
+
var key = keyExtractor(i);
|
|
296
|
+
var measuredSize = measuredCache[key];
|
|
297
|
+
|
|
298
|
+
var _start = measurements[i - 1] ? measurements[i - 1].end : paddingStart;
|
|
299
|
+
|
|
300
|
+
var _size = typeof measuredSize === 'number' ? measuredSize : estimateSize(i);
|
|
301
|
+
|
|
302
|
+
var _end = _start + _size;
|
|
303
|
+
|
|
304
|
+
measurements[i] = {
|
|
305
|
+
index: i,
|
|
306
|
+
start: _start,
|
|
307
|
+
size: _size,
|
|
308
|
+
end: _end,
|
|
309
|
+
key: key
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
return measurements;
|
|
314
|
+
}, [estimateSize, measuredCache, paddingStart, size, keyExtractor]);
|
|
315
|
+
var totalSize = (((_measurements = measurements[size - 1]) == null ? void 0 : _measurements.end) || paddingStart) + paddingEnd;
|
|
316
|
+
latestRef.current.measurements = measurements;
|
|
317
|
+
latestRef.current.totalSize = totalSize;
|
|
318
|
+
var element = onScrollElement ? onScrollElement.current : parentRef.current;
|
|
319
|
+
var scrollOffsetFnRef = React.useRef(scrollOffsetFn);
|
|
320
|
+
scrollOffsetFnRef.current = scrollOffsetFn;
|
|
321
|
+
useIsomorphicLayoutEffect(function () {
|
|
322
|
+
if (!element) {
|
|
323
|
+
setScrollOffset(0);
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
var onScroll = function onScroll(event) {
|
|
328
|
+
var offset = scrollOffsetFnRef.current ? scrollOffsetFnRef.current(event) : element[scrollKey];
|
|
329
|
+
setScrollOffset(offset);
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
onScroll();
|
|
333
|
+
element.addEventListener('scroll', onScroll, {
|
|
334
|
+
capture: false,
|
|
335
|
+
passive: true
|
|
336
|
+
});
|
|
337
|
+
return function () {
|
|
338
|
+
element.removeEventListener('scroll', onScroll);
|
|
339
|
+
};
|
|
340
|
+
}, [element, scrollKey]);
|
|
341
|
+
|
|
342
|
+
var _calculateRange = calculateRange(latestRef.current),
|
|
343
|
+
start = _calculateRange.start,
|
|
344
|
+
end = _calculateRange.end;
|
|
345
|
+
|
|
346
|
+
var indexes = React.useMemo(function () {
|
|
347
|
+
return rangeExtractor({
|
|
348
|
+
start: start,
|
|
349
|
+
end: end,
|
|
350
|
+
overscan: overscan,
|
|
351
|
+
size: measurements.length
|
|
352
|
+
});
|
|
353
|
+
}, [start, end, overscan, measurements.length, rangeExtractor]);
|
|
354
|
+
var measureSizeRef = React.useRef(measureSize);
|
|
355
|
+
measureSizeRef.current = measureSize;
|
|
356
|
+
var virtualItems = React.useMemo(function () {
|
|
357
|
+
var virtualItems = [];
|
|
358
|
+
|
|
359
|
+
var _loop = function _loop(k, len) {
|
|
360
|
+
var i = indexes[k];
|
|
361
|
+
var measurement = measurements[i];
|
|
362
|
+
|
|
363
|
+
var item = _extends(_extends({}, measurement), {}, {
|
|
364
|
+
measureRef: function measureRef(el) {
|
|
365
|
+
if (el) {
|
|
366
|
+
var measuredSize = measureSizeRef.current(el, horizontal);
|
|
367
|
+
|
|
368
|
+
if (measuredSize !== item.size) {
|
|
369
|
+
var _scrollOffset = latestRef.current.scrollOffset;
|
|
370
|
+
|
|
371
|
+
if (item.start < _scrollOffset) {
|
|
372
|
+
defaultScrollToFn(_scrollOffset + (measuredSize - item.size));
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
pendingMeasuredCacheIndexesRef.current.push(i);
|
|
376
|
+
setMeasuredCache(function (old) {
|
|
377
|
+
var _extends2;
|
|
378
|
+
|
|
379
|
+
return _extends(_extends({}, old), {}, (_extends2 = {}, _extends2[item.key] = measuredSize, _extends2));
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
virtualItems.push(item);
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
for (var k = 0, len = indexes.length; k < len; k++) {
|
|
390
|
+
_loop(k);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
return virtualItems;
|
|
394
|
+
}, [indexes, defaultScrollToFn, horizontal, measurements]);
|
|
395
|
+
var mountedRef = React.useRef(false);
|
|
396
|
+
useIsomorphicLayoutEffect(function () {
|
|
397
|
+
if (mountedRef.current) {
|
|
398
|
+
setMeasuredCache({});
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
mountedRef.current = true;
|
|
402
|
+
}, [estimateSize]);
|
|
403
|
+
var scrollToOffset = React.useCallback(function (toOffset, _temp) {
|
|
404
|
+
var _ref2 = _temp === void 0 ? {} : _temp,
|
|
405
|
+
_ref2$align = _ref2.align,
|
|
406
|
+
align = _ref2$align === void 0 ? 'start' : _ref2$align;
|
|
407
|
+
|
|
408
|
+
var _latestRef$current = latestRef.current,
|
|
409
|
+
scrollOffset = _latestRef$current.scrollOffset,
|
|
410
|
+
outerSize = _latestRef$current.outerSize;
|
|
411
|
+
|
|
412
|
+
if (align === 'auto') {
|
|
413
|
+
if (toOffset <= scrollOffset) {
|
|
414
|
+
align = 'start';
|
|
415
|
+
} else if (toOffset >= scrollOffset + outerSize) {
|
|
416
|
+
align = 'end';
|
|
417
|
+
} else {
|
|
418
|
+
align = 'start';
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
if (align === 'start') {
|
|
423
|
+
scrollToFn(toOffset);
|
|
424
|
+
} else if (align === 'end') {
|
|
425
|
+
scrollToFn(toOffset - outerSize);
|
|
426
|
+
} else if (align === 'center') {
|
|
427
|
+
scrollToFn(toOffset - outerSize / 2);
|
|
428
|
+
}
|
|
429
|
+
}, [scrollToFn]);
|
|
430
|
+
var tryScrollToIndex = React.useCallback(function (index, _temp2) {
|
|
431
|
+
var _ref3 = _temp2 === void 0 ? {} : _temp2,
|
|
432
|
+
_ref3$align = _ref3.align,
|
|
433
|
+
align = _ref3$align === void 0 ? 'auto' : _ref3$align,
|
|
434
|
+
rest = _objectWithoutPropertiesLoose(_ref3, ["align"]);
|
|
435
|
+
|
|
436
|
+
var _latestRef$current2 = latestRef.current,
|
|
437
|
+
measurements = _latestRef$current2.measurements,
|
|
438
|
+
scrollOffset = _latestRef$current2.scrollOffset,
|
|
439
|
+
outerSize = _latestRef$current2.outerSize;
|
|
440
|
+
var measurement = measurements[Math.max(0, Math.min(index, size - 1))];
|
|
441
|
+
|
|
442
|
+
if (!measurement) {
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
if (align === 'auto') {
|
|
447
|
+
if (measurement.end >= scrollOffset + outerSize) {
|
|
448
|
+
align = 'end';
|
|
449
|
+
} else if (measurement.start <= scrollOffset) {
|
|
450
|
+
align = 'start';
|
|
451
|
+
} else {
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
var toOffset = align === 'center' ? measurement.start + measurement.size / 2 : align === 'end' ? measurement.end : measurement.start;
|
|
457
|
+
scrollToOffset(toOffset, _extends({
|
|
458
|
+
align: align
|
|
459
|
+
}, rest));
|
|
460
|
+
}, [scrollToOffset, size]);
|
|
461
|
+
var scrollToIndex = React.useCallback(function () {
|
|
462
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
463
|
+
args[_key] = arguments[_key];
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
// We do a double request here because of
|
|
467
|
+
// dynamic sizes which can cause offset shift
|
|
468
|
+
// and end up in the wrong spot. Unfortunately,
|
|
469
|
+
// we can't know about those dynamic sizes until
|
|
470
|
+
// we try and render them. So double down!
|
|
471
|
+
tryScrollToIndex.apply(void 0, args);
|
|
472
|
+
requestAnimationFrame(function () {
|
|
473
|
+
tryScrollToIndex.apply(void 0, args);
|
|
474
|
+
});
|
|
475
|
+
}, [tryScrollToIndex]);
|
|
476
|
+
return {
|
|
477
|
+
virtualItems: virtualItems,
|
|
478
|
+
totalSize: totalSize,
|
|
479
|
+
scrollToOffset: scrollToOffset,
|
|
480
|
+
scrollToIndex: scrollToIndex,
|
|
481
|
+
measure: measure
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
var findNearestBinarySearch = function findNearestBinarySearch(low, high, getCurrentValue, value) {
|
|
486
|
+
while (low <= high) {
|
|
487
|
+
var middle = (low + high) / 2 | 0;
|
|
488
|
+
var currentValue = getCurrentValue(middle);
|
|
489
|
+
|
|
490
|
+
if (currentValue < value) {
|
|
491
|
+
low = middle + 1;
|
|
492
|
+
} else if (currentValue > value) {
|
|
493
|
+
high = middle - 1;
|
|
494
|
+
} else {
|
|
495
|
+
return middle;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
if (low > 0) {
|
|
500
|
+
return low - 1;
|
|
501
|
+
} else {
|
|
502
|
+
return 0;
|
|
503
|
+
}
|
|
504
|
+
};
|
|
505
|
+
|
|
506
|
+
function calculateRange(_ref4) {
|
|
507
|
+
var measurements = _ref4.measurements,
|
|
508
|
+
outerSize = _ref4.outerSize,
|
|
509
|
+
scrollOffset = _ref4.scrollOffset;
|
|
510
|
+
var size = measurements.length - 1;
|
|
511
|
+
|
|
512
|
+
var getOffset = function getOffset(index) {
|
|
513
|
+
return measurements[index].start;
|
|
514
|
+
};
|
|
515
|
+
|
|
516
|
+
var start = findNearestBinarySearch(0, size, getOffset, scrollOffset);
|
|
517
|
+
var end = start;
|
|
518
|
+
|
|
519
|
+
while (end < size && measurements[end].end < scrollOffset + outerSize) {
|
|
520
|
+
end++;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
return {
|
|
524
|
+
start: start,
|
|
525
|
+
end: end
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
export { useVirtual };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/line-chart/index.tsx"],"names":[],"mappings":";AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAO9C,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B,iBAAS,SAAS,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,IAAI,EAAE,EACnD,MAAW,EACX,MAAY,EACZ,UAAqB,EACrB,UAAqB,EACrB,iBAA4B,EAC5B,UAAuB,EACvB,qBAA4B,EAC5B,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/line-chart/index.tsx"],"names":[],"mappings":";AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAO9C,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B,iBAAS,SAAS,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,IAAI,EAAE,EACnD,MAAW,EACX,MAAY,EACZ,UAAqB,EACrB,UAAqB,EACrB,iBAA4B,EAC5B,UAAuB,EACvB,qBAA4B,EAC5B,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,CAAC,CAAC,eA+BnB;AAID,eAAe,SAAS,CAAC"}
|
|
@@ -10,7 +10,17 @@ import InternalMixedLineBarChart from '../mixed-line-bar-chart/internal';
|
|
|
10
10
|
import useBaseComponent from '../internal/hooks/use-base-component';
|
|
11
11
|
function LineChart(_a) {
|
|
12
12
|
var { series = [], height = 500, xScaleType = 'linear', yScaleType = 'linear', detailPopoverSize = 'medium', statusType = 'finished', emphasizeBaselineAxis = true } = _a, props = __rest(_a, ["series", "height", "xScaleType", "yScaleType", "detailPopoverSize", "statusType", "emphasizeBaselineAxis"]);
|
|
13
|
-
const baseComponentProps = useBaseComponent('LineChart'
|
|
13
|
+
const baseComponentProps = useBaseComponent('LineChart', {
|
|
14
|
+
props: {
|
|
15
|
+
detailPopoverSize,
|
|
16
|
+
emphasizeBaselineAxis,
|
|
17
|
+
fitHeight: props.fitHeight,
|
|
18
|
+
hideFilter: props.hideFilter,
|
|
19
|
+
hideLegend: props.hideLegend,
|
|
20
|
+
xScaleType,
|
|
21
|
+
yScaleType,
|
|
22
|
+
},
|
|
23
|
+
});
|
|
14
24
|
const baseProps = getBaseProps(props);
|
|
15
25
|
const className = clsx(baseProps.className, styles.root);
|
|
16
26
|
return (React.createElement(InternalMixedLineBarChart, Object.assign({}, props, baseComponentProps, { className: className, height: height, xScaleType: xScaleType, yScaleType: yScaleType, stackedBars: false, horizontalBars: false, series: series, detailPopoverSize: detailPopoverSize, statusType: statusType, emphasizeBaselineAxis: emphasizeBaselineAxis })));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/line-chart/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAA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AAC,WAAW,EAAE;QACvD,KAAK,EAAE;YACL,iBAAiB;YACjB,qBAAqB;YACrB,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,UAAU;YACV,UAAU;SACX;KACF,CAAC,CAAC;IACH,MAAM,SAAS,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IACtC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IAEzD,OAAO,CACL,oBAAC,yBAAyB,oBACpB,KAAK,EACL,kBAAkB,IACtB,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,KAAK,EAClB,cAAc,EAAE,KAAK,EACrB,MAAM,EAAE,MAAM,EACd,iBAAiB,EAAE,iBAAiB,EACpC,UAAU,EAAE,UAAU,EACtB,qBAAqB,EAAE,qBAAqB,IAC5C,CACH,CAAC;AACJ,CAAC;AAED,gBAAgB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;AAEzC,eAAe,SAAS,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport clsx from 'clsx';\n\nimport { LineChartProps } from './interfaces';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { getBaseProps } from '../internal/base-component';\nimport styles from './styles.css.js';\nimport InternalMixedLineBarChart from '../mixed-line-bar-chart/internal';\nimport useBaseComponent from '../internal/hooks/use-base-component';\n\nexport { LineChartProps };\n\nfunction LineChart<T extends number | string | Date>({\n series = [],\n height = 500,\n xScaleType = 'linear',\n yScaleType = 'linear',\n detailPopoverSize = 'medium',\n statusType = 'finished',\n emphasizeBaselineAxis = true,\n ...props\n}: LineChartProps<T>) {\n const baseComponentProps = useBaseComponent('LineChart', {\n props: {\n detailPopoverSize,\n emphasizeBaselineAxis,\n fitHeight: props.fitHeight,\n hideFilter: props.hideFilter,\n hideLegend: props.hideLegend,\n xScaleType,\n yScaleType,\n },\n });\n const baseProps = getBaseProps(props);\n const className = clsx(baseProps.className, styles.root);\n\n return (\n <InternalMixedLineBarChart\n {...props}\n {...baseComponentProps}\n className={className}\n height={height}\n xScaleType={xScaleType}\n yScaleType={yScaleType}\n stackedBars={false}\n horizontalBars={false}\n series={series}\n detailPopoverSize={detailPopoverSize}\n statusType={statusType}\n emphasizeBaselineAxis={emphasizeBaselineAxis}\n />\n );\n}\n\napplyDisplayName(LineChart, 'LineChart');\n\nexport default LineChart;\n"]}
|
|
@@ -86,7 +86,7 @@ export function useMouseHover({ plotRef, popoverRef, scaledSeries, barGroups, hi
|
|
|
86
86
|
}
|
|
87
87
|
};
|
|
88
88
|
const onPopoverLeave = (event) => {
|
|
89
|
-
if (!isHandlersDisabled &&
|
|
89
|
+
if (!isHandlersDisabled && nodeContains(plotRef.current.svg, event.relatedTarget)) {
|
|
90
90
|
highlightX(null);
|
|
91
91
|
clearHighlightedSeries();
|
|
92
92
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-mouse-hover.js","sourceRoot":"","sources":["../../../../src/mixed-line-bar-chart/hooks/use-mouse-hover.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAKxE,OAAO,MAAM,MAAM,kBAAkB,CAAC;AAGtC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAC3B,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAe5B,MAAM,UAAU,aAAa,CAAI,EAC/B,OAAO,EACP,UAAU,EACV,YAAY,EACZ,SAAS,EACT,cAAc,EACd,cAAc,EACd,sBAAsB,EACtB,iBA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AAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAC3F;YACA,UAAU,CAAC,IAAI,CAAC,CAAC;YACjB,sBAAsB,EAAE,CAAC;SAC1B;IACH,CAAC,CAAC;IAEF,MAAM,cAAc,GAAG,CAAC,KAAuB,EAAE,EAAE;QACjD,IAAI,CAAC,kBAAkB,IAAI,YAAY,CAAC,OAAO,CAAC,OAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,aAAa,CAAC,EAAE;YAClF,UAAU,CAAC,IAAI,CAAC,CAAC;YACjB,sBAAsB,EAAE,CAAC;SAC1B;IACH,CAAC,CAAC;IAEF,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,CAAC;AAC3D,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { nodeContains } from '@cloudscape-design/component-toolkit/dom';\n\nimport { ScaledBarGroup } from '../make-scaled-bar-groups';\nimport { ScaledPoint } from '../make-scaled-series';\n\nimport styles from '../styles.css.js';\nimport { ChartPlotRef } from '../../internal/components/chart-plot';\nimport { VerticalMarkerX } from '../interfaces';\nimport { isYThreshold } from '../utils';\n\nconst MAX_HOVER_MARGIN = 6;\nconst POPOVER_DEADZONE = 12;\n\nexport interface UseMouseHoverProps<T> {\n plotRef: React.RefObject<ChartPlotRef>;\n popoverRef: React.RefObject<HTMLElement>;\n scaledSeries: ReadonlyArray<ScaledPoint<T>>;\n barGroups: ScaledBarGroup<T>[];\n highlightPoint: (point: ScaledPoint<T> | null) => void;\n highlightGroup: (groupIndex: number) => void;\n clearHighlightedSeries: () => void;\n isGroupNavigation: boolean;\n isHandlersDisabled: boolean;\n highlightX: (verticalMarker: VerticalMarkerX<T> | null) => void;\n}\n\nexport function useMouseHover<T>({\n plotRef,\n popoverRef,\n scaledSeries,\n barGroups,\n highlightPoint,\n highlightGroup,\n clearHighlightedSeries,\n isGroupNavigation,\n isHandlersDisabled,\n highlightX,\n}: UseMouseHoverProps<T>) {\n const isMouseOverPopover = (event: React.MouseEvent<SVGElement, MouseEvent>) => {\n if (popoverRef.current?.firstChild) {\n const popoverPosition = (popoverRef.current.firstChild as HTMLElement).getBoundingClientRect();\n if (\n event.clientX > popoverPosition.x - POPOVER_DEADZONE &&\n event.clientX < popoverPosition.x + popoverPosition.width + POPOVER_DEADZONE &&\n event.clientY > popoverPosition.y - POPOVER_DEADZONE &&\n event.clientY < popoverPosition.y + popoverPosition.height + POPOVER_DEADZONE\n ) {\n return true;\n }\n }\n return false;\n };\n\n const onSeriesMouseMove = (event: React.MouseEvent<SVGElement, MouseEvent>) => {\n const svgRect = (event.target as SVGElement).getBoundingClientRect();\n const offsetX = event.clientX - svgRect.left;\n\n const closestX = scaledSeries\n .map(v => v.x)\n .reduce((prev, curr) => (Math.abs(curr - offsetX) < Math.abs(prev - offsetX) ? curr : prev), -Infinity);\n\n if (isFinite(closestX)) {\n const offsetY = event.clientY - svgRect.top;\n const closestY = scaledSeries\n .filter(v => v.x === closestX || isYThreshold(v.series))\n .map(v => v.y)\n .reduce((prev, curr) => (Math.abs(curr - offsetY) < Math.abs(prev - offsetY) ? curr : prev), -Infinity);\n\n if (\n isFinite(closestY) &&\n Math.abs(offsetX - closestX) < MAX_HOVER_MARGIN &&\n Math.abs(offsetY - closestY) < MAX_HOVER_MARGIN\n ) {\n const [{ color, datum, series }] = scaledSeries.filter(\n s => (s.x === closestX || isYThreshold(s.series)) && s.y === closestY\n );\n highlightPoint({ x: closestX, y: closestY, color, datum, series });\n } else {\n let datumX = null;\n for (const point of scaledSeries) {\n if (point.x === closestX) {\n datumX = point.datum?.x ?? null;\n break;\n }\n }\n highlightX({ scaledX: closestX, label: datumX });\n }\n }\n };\n\n const onGroupMouseMove = (event: React.MouseEvent<SVGElement, MouseEvent>) => {\n const svgRect = (event.target as SVGElement).getBoundingClientRect();\n const offsetX = event.clientX - svgRect.left;\n const offsetY = event.clientY - svgRect.top;\n\n // If hovering over some group - highlight it.\n for (let groupIndex = 0; groupIndex < barGroups.length; groupIndex++) {\n const {\n position: { x, y, width, height },\n } = barGroups[groupIndex];\n\n if (x <= offsetX && offsetX <= x + width && y <= offsetY && offsetY <= y + height) {\n highlightGroup(groupIndex);\n return;\n }\n }\n // Otherwise - clear the highlight.\n clearHighlightedSeries();\n };\n\n const onSVGMouseMove = (event: React.MouseEvent<SVGElement, MouseEvent>) => {\n if (event.target === plotRef.current!.svg && !isHandlersDisabled && !isMouseOverPopover(event)) {\n if (isGroupNavigation) {\n onGroupMouseMove(event);\n } else if (scaledSeries.length > 0) {\n onSeriesMouseMove(event);\n }\n }\n };\n\n const onSVGMouseOut = (event: React.MouseEvent<SVGElement, MouseEvent>) => {\n if (isHandlersDisabled || isMouseOverPopover(event)) {\n return;\n }\n if (\n !nodeContains(plotRef.current!.svg, event.relatedTarget) ||\n (event.relatedTarget && (event.relatedTarget as Element).classList.contains(styles.series))\n ) {\n highlightX(null);\n clearHighlightedSeries();\n }\n };\n\n const onPopoverLeave = (event: React.MouseEvent) => {\n if (!isHandlersDisabled && nodeContains(plotRef.current!.svg, event.relatedTarget)) {\n highlightX(null);\n clearHighlightedSeries();\n }\n };\n\n return { onSVGMouseMove, onSVGMouseOut, onPopoverLeave };\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { VirtualItem } from 'react-virtual';
|
|
2
|
+
import { VirtualItem } from '../../internal/vendor/react-virtual';
|
|
3
3
|
import { DropdownOption } from '../../internal/components/option/interfaces';
|
|
4
4
|
import { HighlightType } from '../../internal/components/options-list/utils/use-highlight-option';
|
|
5
5
|
export interface RenderOptionProps {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-options.d.ts","sourceRoot":"","sources":["../../../../src/select/utils/render-options.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"render-options.d.ts","sourceRoot":"","sources":["../../../../src/select/utils/render-options.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAGlE,OAAO,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAC;AAE7E,OAAO,EAAE,aAAa,EAAE,MAAM,mEAAmE,CAAC;AAElG,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;IACvC,cAAc,EAAE,GAAG,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,aAAa,CAAC;IAC7B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC;IAC7B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,aAAa,qKAWvB,iBAAiB,kBA8BnB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-options.js","sourceRoot":"","sources":["../../../../src/select/utils/render-options.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,IAAI,MAAM,eAAe,CAAC;AACjC,OAAO,eAAe,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAgBhD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAC5B,OAAO,EACP,cAAc,EACd,cAAc,EACd,aAAa,EACb,UAAU,GAAG,KAAK,EAClB,iBAAiB,EACjB,YAAY,EACZ,oBAAoB,EACpB,mBAAmB,EACnB,WAAW,GACO,EAAE,EAAE;IACtB,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;QACnC,MAAM,WAAW,GAAG,YAAY,IAAI,YAAY,CAAC,KAAK,CAAC,CAAC;QACxD,MAAM,WAAW,GAAG,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;QAC5D,MAAM,KAAK,GAAG,YAAY,CAAC;YACzB,MAAM;YACN,KAAK,EAAE,WAAW;YAClB,cAAc;YACd,cAAc;YACd,UAAU;SACX,CAAC,CAAC;QAEH,MAAM,UAAU,GAAG,KAAK,KAAK,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;QAChD,MAAM,SAAS,GAAG,CAAC,iBAAiB,IAAI,UAAU,CAAC;QACnD,MAAM,QAAQ,GAAG,oBAAoB,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC;QAE/D,OAAO,CACL,oBAAC,QAAQ,kBACP,GAAG,EAAE,WAAW,IACZ,KAAK,IACT,eAAe,EAAE,WAAW,IAAI,WAAW,CAAC,KAAK,EACjD,GAAG,EAAE,WAAW,IAAI,WAAW,CAAC,UAAU,EAC1C,SAAS,EAAE,SAAS,EACpB,mBAAmB,EAAE,mBAAmB,EACxC,YAAY,EAAE,WAAW,GAAG,CAAC,EAC7B,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,CAAC,IAAI,IACjC,CACH,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport { VirtualItem } from 'react-virtual';\nimport Item from '../parts/item';\nimport MutliselectItem from '../parts/multiselect-item';\nimport { DropdownOption } from '../../internal/components/option/interfaces';\nimport { getItemProps } from './get-item-props';\nimport { HighlightType } from '../../internal/components/options-list/utils/use-highlight-option';\n\nexport interface RenderOptionProps {\n options: ReadonlyArray<DropdownOption>;\n getOptionProps: any;\n filteringValue: string;\n highlightType: HighlightType;\n checkboxes?: boolean;\n hasDropdownStatus?: boolean;\n virtualItems?: VirtualItem[];\n useInteractiveGroups?: boolean;\n screenReaderContent?: string;\n ariaSetsize?: number;\n}\n\nexport const renderOptions = ({\n options,\n getOptionProps,\n filteringValue,\n highlightType,\n checkboxes = false,\n hasDropdownStatus,\n virtualItems,\n useInteractiveGroups,\n screenReaderContent,\n ariaSetsize,\n}: RenderOptionProps) => {\n return options.map((option, index) => {\n const virtualItem = virtualItems && virtualItems[index];\n const globalIndex = virtualItem ? virtualItem.index : index;\n const props = getItemProps({\n option,\n index: globalIndex,\n getOptionProps,\n filteringValue,\n checkboxes,\n });\n\n const isLastItem = index === options.length - 1;\n const padBottom = !hasDropdownStatus && isLastItem;\n const ListItem = useInteractiveGroups ? MutliselectItem : Item;\n\n return (\n <ListItem\n key={globalIndex}\n {...props}\n virtualPosition={virtualItem && virtualItem.start}\n ref={virtualItem && virtualItem.measureRef}\n padBottom={padBottom}\n screenReaderContent={screenReaderContent}\n ariaPosinset={globalIndex + 1}\n ariaSetsize={ariaSetsize}\n highlightType={highlightType.type}\n />\n );\n });\n};\n"]}
|
|
1
|
+
{"version":3,"file":"render-options.js","sourceRoot":"","sources":["../../../../src/select/utils/render-options.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,IAAI,MAAM,eAAe,CAAC;AACjC,OAAO,eAAe,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAgBhD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAC5B,OAAO,EACP,cAAc,EACd,cAAc,EACd,aAAa,EACb,UAAU,GAAG,KAAK,EAClB,iBAAiB,EACjB,YAAY,EACZ,oBAAoB,EACpB,mBAAmB,EACnB,WAAW,GACO,EAAE,EAAE;IACtB,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;QACnC,MAAM,WAAW,GAAG,YAAY,IAAI,YAAY,CAAC,KAAK,CAAC,CAAC;QACxD,MAAM,WAAW,GAAG,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;QAC5D,MAAM,KAAK,GAAG,YAAY,CAAC;YACzB,MAAM;YACN,KAAK,EAAE,WAAW;YAClB,cAAc;YACd,cAAc;YACd,UAAU;SACX,CAAC,CAAC;QAEH,MAAM,UAAU,GAAG,KAAK,KAAK,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;QAChD,MAAM,SAAS,GAAG,CAAC,iBAAiB,IAAI,UAAU,CAAC;QACnD,MAAM,QAAQ,GAAG,oBAAoB,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC;QAE/D,OAAO,CACL,oBAAC,QAAQ,kBACP,GAAG,EAAE,WAAW,IACZ,KAAK,IACT,eAAe,EAAE,WAAW,IAAI,WAAW,CAAC,KAAK,EACjD,GAAG,EAAE,WAAW,IAAI,WAAW,CAAC,UAAU,EAC1C,SAAS,EAAE,SAAS,EACpB,mBAAmB,EAAE,mBAAmB,EACxC,YAAY,EAAE,WAAW,GAAG,CAAC,EAC7B,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,CAAC,IAAI,IACjC,CACH,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport { VirtualItem } from '../../internal/vendor/react-virtual';\nimport Item from '../parts/item';\nimport MutliselectItem from '../parts/multiselect-item';\nimport { DropdownOption } from '../../internal/components/option/interfaces';\nimport { getItemProps } from './get-item-props';\nimport { HighlightType } from '../../internal/components/options-list/utils/use-highlight-option';\n\nexport interface RenderOptionProps {\n options: ReadonlyArray<DropdownOption>;\n getOptionProps: any;\n filteringValue: string;\n highlightType: HighlightType;\n checkboxes?: boolean;\n hasDropdownStatus?: boolean;\n virtualItems?: VirtualItem[];\n useInteractiveGroups?: boolean;\n screenReaderContent?: string;\n ariaSetsize?: number;\n}\n\nexport const renderOptions = ({\n options,\n getOptionProps,\n filteringValue,\n highlightType,\n checkboxes = false,\n hasDropdownStatus,\n virtualItems,\n useInteractiveGroups,\n screenReaderContent,\n ariaSetsize,\n}: RenderOptionProps) => {\n return options.map((option, index) => {\n const virtualItem = virtualItems && virtualItems[index];\n const globalIndex = virtualItem ? virtualItem.index : index;\n const props = getItemProps({\n option,\n index: globalIndex,\n getOptionProps,\n filteringValue,\n checkboxes,\n });\n\n const isLastItem = index === options.length - 1;\n const padBottom = !hasDropdownStatus && isLastItem;\n const ListItem = useInteractiveGroups ? MutliselectItem : Item;\n\n return (\n <ListItem\n key={globalIndex}\n {...props}\n virtualPosition={virtualItem && virtualItem.start}\n ref={virtualItem && virtualItem.measureRef}\n padBottom={padBottom}\n screenReaderContent={screenReaderContent}\n ariaPosinset={globalIndex + 1}\n ariaSetsize={ariaSetsize}\n highlightType={highlightType.type}\n />\n );\n });\n};\n"]}
|