@pingux/astro 2.218.0 → 2.219.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.
@@ -36,7 +36,7 @@ import _parseFloat from "@babel/runtime-corejs3/core-js-stable/parse-float";
36
36
  import _sortInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/sort";
37
37
  import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find";
38
38
  function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
39
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context5, _context6; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context5 = ownKeys(Object(t), !0)).call(_context5, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context6 = ownKeys(Object(t))).call(_context6, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
39
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context7, _context8; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context7 = ownKeys(Object(t), !0)).call(_context7, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context8 = ownKeys(Object(t))).call(_context8, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
40
40
  import React, { useRef, useState } from 'react';
41
41
  import { useCollator } from '@react-aria/i18n';
42
42
  import { useAsyncList } from '@react-stately/data';
@@ -421,6 +421,152 @@ export var WithResizableColumns = function WithResizableColumns() {
421
421
  }, ___EmotionJSX(Cell, null, item.type), ___EmotionJSX(Cell, null, item.date), ___EmotionJSX(Cell, null, item.additional_grant), ___EmotionJSX(Cell, null, item.total_grant));
422
422
  })));
423
423
  };
424
+ export var WithSortingAndResizing = function WithSortingAndResizing() {
425
+ var columns = [{
426
+ name: 'Country',
427
+ key: 'country',
428
+ isSortable: true
429
+ }, {
430
+ name: 'Population',
431
+ key: 'population',
432
+ isSortable: true
433
+ }, {
434
+ name: 'Continent',
435
+ key: 'continent',
436
+ isSortable: false
437
+ }];
438
+ var rows = [{
439
+ id: 1,
440
+ country: 'Austria',
441
+ population: '25,000,000',
442
+ continent: 'Oceania'
443
+ }, {
444
+ id: 2,
445
+ country: 'Canada',
446
+ population: '37,000,000',
447
+ continent: 'North America'
448
+ }, {
449
+ id: 3,
450
+ country: 'China',
451
+ population: '1,398,000,000',
452
+ continent: 'Asia'
453
+ }, {
454
+ id: 4,
455
+ country: 'Ethiopia',
456
+ population: '120,000,000',
457
+ continent: 'Africa'
458
+ }, {
459
+ id: 5,
460
+ country: 'France',
461
+ population: '67,000,000',
462
+ continent: 'Europe'
463
+ }, {
464
+ id: 6,
465
+ country: 'Mexico',
466
+ population: '126,000,000',
467
+ continent: 'North America'
468
+ }, {
469
+ id: 7,
470
+ country: 'USA',
471
+ population: '320,000,000',
472
+ continent: 'North America'
473
+ }];
474
+ var collator = useCollator({
475
+ numeric: true
476
+ });
477
+ var list = useAsyncList({
478
+ load: function load() {
479
+ return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
480
+ return _regeneratorRuntime().wrap(function _callee3$(_context5) {
481
+ while (1) switch (_context5.prev = _context5.next) {
482
+ case 0:
483
+ return _context5.abrupt("return", {
484
+ items: rows
485
+ });
486
+ case 1:
487
+ case "end":
488
+ return _context5.stop();
489
+ }
490
+ }, _callee3);
491
+ }))();
492
+ },
493
+ sort: function sort(_ref2) {
494
+ return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
495
+ var items, sortDescriptor, getNumericValue;
496
+ return _regeneratorRuntime().wrap(function _callee4$(_context6) {
497
+ while (1) switch (_context6.prev = _context6.next) {
498
+ case 0:
499
+ items = _ref2.items, sortDescriptor = _ref2.sortDescriptor;
500
+ getNumericValue = function getNumericValue(str) {
501
+ return !_Number$isNaN(str) && _parseFloat(str.replace(/,/g, ''));
502
+ };
503
+ return _context6.abrupt("return", {
504
+ items: _sortInstanceProperty(items).call(items, function (a, b) {
505
+ if (sortDescriptor.column) {
506
+ var first = a[sortDescriptor.column];
507
+ var second = b[sortDescriptor.column];
508
+ var firstNumericValue = getNumericValue(first);
509
+ var secondNumericValue = getNumericValue(second);
510
+ var cmp = firstNumericValue && secondNumericValue ? firstNumericValue - secondNumericValue : collator.compare(first, second);
511
+ return sortDescriptor.direction === 'descending' ? -cmp : cmp;
512
+ }
513
+ return 1;
514
+ })
515
+ });
516
+ case 3:
517
+ case "end":
518
+ return _context6.stop();
519
+ }
520
+ }, _callee4);
521
+ }))();
522
+ },
523
+ initialSortDescriptor: {
524
+ column: 'country',
525
+ direction: 'ascending'
526
+ }
527
+ });
528
+ return ___EmotionJSX(Card, {
529
+ variant: "cards.tableWrapper"
530
+ }, ___EmotionJSX(TableBase, {
531
+ "aria-label": "Table with sorting and resizing enabled together",
532
+ onSortChange: function onSortChange(descriptor) {
533
+ if (descriptor.column) {
534
+ _sortInstanceProperty(list).call(list, descriptor);
535
+ }
536
+ },
537
+ sortDescriptor: list.sortDescriptor
538
+ }, ___EmotionJSX(THead, {
539
+ columns: columns
540
+ }, function (column) {
541
+ return ___EmotionJSX(Column, {
542
+ minWidth: 155,
543
+ allowsSorting: column.isSortable,
544
+ allowsResizing: column.key !== columns[columns.length - 1].key
545
+ }, column.name);
546
+ }), ___EmotionJSX(TBody, {
547
+ items: list.items,
548
+ loadingState: list.loadingState,
549
+ onLoadMore: list.loadMore
550
+ }, function (item) {
551
+ return ___EmotionJSX(Row, {
552
+ key: item.name
553
+ }, function (columnKey) {
554
+ return ___EmotionJSX(Cell, null, item[columnKey]);
555
+ });
556
+ })));
557
+ };
558
+
559
+ // Added to bypass color contrast issue due to virtualizer
560
+ WithSortingAndResizing.parameters = {
561
+ a11y: {
562
+ config: {
563
+ rules: [{
564
+ id: 'color-contrast',
565
+ enabled: false
566
+ }]
567
+ }
568
+ }
569
+ };
424
570
  export var WithMinMaxColumnWidth = function WithMinMaxColumnWidth() {
425
571
  return ___EmotionJSX(Card, {
426
572
  variant: "cards.tableWrapper"
@@ -127,7 +127,11 @@ var head = _objectSpread(_objectSpread({}, text.label), {}, {
127
127
  '&:focus-visible': {
128
128
  outline: 'none'
129
129
  },
130
- '&.is-focused': _objectSpread({}, defaultFocus)
130
+ '&.is-focused': _objectSpread(_objectSpread({}, defaultFocus), {}, {
131
+ '& .resizer': {
132
+ backgroundColor: 'focus'
133
+ }
134
+ })
131
135
  });
132
136
  var resizer = {
133
137
  cursor: 'col-resize',
@@ -135,13 +139,34 @@ var resizer = {
135
139
  width: '2px',
136
140
  height: '100%',
137
141
  backgroundColor: 'neutral.10',
142
+ boxSizing: 'content-box',
143
+ paddingLeft: '0.25rem',
144
+ paddingRight: '0.25rem',
145
+ backgroundClip: 'content-box',
138
146
  position: 'absolute',
139
- right: '0px',
147
+ right: '-0.25rem',
140
148
  top: '0',
141
- '&.is-focused': {
142
- backgroundColor: 'focus'
149
+ '&.is-focused': _objectSpread({}, defaultFocus),
150
+ '&.is-resizing': {
151
+ backgroundColor: 'focus',
152
+ outline: '0px'
143
153
  }
144
154
  };
155
+
156
+ // Resets native <button> chrome so the sort trigger reads as plain header
157
+ // text/icon, matching `head`'s typography, while remaining its own
158
+ // focusable, activatable element (a sibling to the resizer, not a
159
+ // descendant of it, or vice versa).
160
+ var sortButton = _objectSpread(_objectSpread({}, text.label), {}, {
161
+ fontWeight: 500,
162
+ appearance: 'none',
163
+ background: 'none',
164
+ border: 'none',
165
+ padding: 0,
166
+ margin: 0,
167
+ cursor: 'pointer',
168
+ textAlign: 'left'
169
+ });
145
170
  var tbody = {
146
171
  borderBottom: '1px solid',
147
172
  borderBottomColor: 'neutral.80',
@@ -186,5 +211,6 @@ export default {
186
211
  data: data,
187
212
  head: head,
188
213
  row: row,
189
- resizer: resizer
214
+ resizer: resizer,
215
+ sortButton: sortButton
190
216
  };