@nulogy/components 6.3.2 → 6.4.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/dist/main.js +84 -0
- package/dist/main.module.js +84 -1
- package/dist/src/SortingTable/SortingTable.d.ts +7 -0
- package/dist/src/SortingTable/SortingTable.story.d.ts +25 -0
- package/dist/src/SortingTable/index.d.ts +1 -0
- package/dist/src/Table/{TableWithSorting.story.d.ts → TableWithCustomSorting.story.d.ts} +1 -1
- package/dist/src/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -52640,6 +52640,89 @@
|
|
|
52640
52640
|
}, props));
|
|
52641
52641
|
};
|
|
52642
52642
|
|
|
52643
|
+
var numericAlphabeticalSort = function numericAlphabeticalSort(a, b, numeric) {
|
|
52644
|
+
return String(a).localeCompare(b, undefined, {
|
|
52645
|
+
numeric: numeric,
|
|
52646
|
+
sensitivity: "base"
|
|
52647
|
+
});
|
|
52648
|
+
};
|
|
52649
|
+
|
|
52650
|
+
var applySort = function applySort(rows, sortColumn, columns) {
|
|
52651
|
+
return [].concat(rows).sort(function (a, b) {
|
|
52652
|
+
var column = columns.find(function (col) {
|
|
52653
|
+
return col.dataKey === sortColumn;
|
|
52654
|
+
});
|
|
52655
|
+
var numeric = column.numeric;
|
|
52656
|
+
return numericAlphabeticalSort(a[sortColumn], b[sortColumn], numeric);
|
|
52657
|
+
});
|
|
52658
|
+
};
|
|
52659
|
+
|
|
52660
|
+
var sortRows = function sortRows(rows, columns, sortState) {
|
|
52661
|
+
var sortedRows = applySort(rows, sortState.sortColumn, columns);
|
|
52662
|
+
return sortState.ascending ? sortedRows : sortedRows.reverse();
|
|
52663
|
+
};
|
|
52664
|
+
|
|
52665
|
+
var SortingTable = function SortingTable(_a) {
|
|
52666
|
+
var incomingColumns = _a.columns,
|
|
52667
|
+
incomingRows = _a.rows,
|
|
52668
|
+
initialSortColumn = _a.initialSortColumn,
|
|
52669
|
+
props = __rest(_a, ["columns", "rows", "initialSortColumn"]);
|
|
52670
|
+
|
|
52671
|
+
var _useState = React.useState({
|
|
52672
|
+
ascending: true,
|
|
52673
|
+
sortColumn: initialSortColumn
|
|
52674
|
+
}),
|
|
52675
|
+
sortState = _useState[0],
|
|
52676
|
+
setSortState = _useState[1];
|
|
52677
|
+
|
|
52678
|
+
var _useState2 = React.useState(function () {
|
|
52679
|
+
return sortRows(incomingRows, incomingColumns, sortState);
|
|
52680
|
+
}),
|
|
52681
|
+
rows = _useState2[0],
|
|
52682
|
+
setRows = _useState2[1];
|
|
52683
|
+
|
|
52684
|
+
var onSortChange = function onSortChange(dataKey) {
|
|
52685
|
+
var newSortState;
|
|
52686
|
+
setSortState(function (previousState) {
|
|
52687
|
+
var ascending = previousState.sortColumn !== dataKey || !previousState.ascending;
|
|
52688
|
+
newSortState = {
|
|
52689
|
+
ascending: ascending,
|
|
52690
|
+
sortColumn: dataKey
|
|
52691
|
+
};
|
|
52692
|
+
return newSortState;
|
|
52693
|
+
});
|
|
52694
|
+
setRows(function (previousState) {
|
|
52695
|
+
return sortRows(previousState, incomingColumns, newSortState);
|
|
52696
|
+
});
|
|
52697
|
+
};
|
|
52698
|
+
|
|
52699
|
+
var transformColumn = function transformColumn(column) {
|
|
52700
|
+
var isAscending = sortState.ascending && column.dataKey === sortState.sortColumn;
|
|
52701
|
+
return Object.assign(Object.assign({}, column), {
|
|
52702
|
+
headerFormatter: function headerFormatter(_ref) {
|
|
52703
|
+
var label = _ref.label,
|
|
52704
|
+
dataKey = _ref.dataKey;
|
|
52705
|
+
return /*#__PURE__*/React__default['default'].createElement(Table.SortingHeader, {
|
|
52706
|
+
onChange: function onChange() {
|
|
52707
|
+
return onSortChange(dataKey);
|
|
52708
|
+
},
|
|
52709
|
+
label: label,
|
|
52710
|
+
ascending: isAscending,
|
|
52711
|
+
active: dataKey === sortState.sortColumn
|
|
52712
|
+
});
|
|
52713
|
+
}
|
|
52714
|
+
});
|
|
52715
|
+
};
|
|
52716
|
+
|
|
52717
|
+
var columns = incomingColumns.map(function (column) {
|
|
52718
|
+
return transformColumn(column);
|
|
52719
|
+
});
|
|
52720
|
+
return /*#__PURE__*/React__default['default'].createElement(Table, Object.assign({
|
|
52721
|
+
columns: columns,
|
|
52722
|
+
rows: rows
|
|
52723
|
+
}, props));
|
|
52724
|
+
};
|
|
52725
|
+
|
|
52643
52726
|
exports.ALL_NDS_LOCALES = ALL_NDS_LOCALES;
|
|
52644
52727
|
exports.Alert = Alert;
|
|
52645
52728
|
exports.AnimatedBox = AnimatedBox;
|
|
@@ -52706,6 +52789,7 @@
|
|
|
52706
52789
|
exports.SelectMultiValue = SelectMultiValue;
|
|
52707
52790
|
exports.SelectOption = SelectOption;
|
|
52708
52791
|
exports.Sidebar = Sidebar;
|
|
52792
|
+
exports.SortingTable = SortingTable;
|
|
52709
52793
|
exports.StatusIndicator = StatusIndicator;
|
|
52710
52794
|
exports.Tab = Tab;
|
|
52711
52795
|
exports.Table = Table;
|
package/dist/main.module.js
CHANGED
|
@@ -52614,4 +52614,87 @@ var Divider = function Divider(_a) {
|
|
|
52614
52614
|
}, props));
|
|
52615
52615
|
};
|
|
52616
52616
|
|
|
52617
|
-
|
|
52617
|
+
var numericAlphabeticalSort = function numericAlphabeticalSort(a, b, numeric) {
|
|
52618
|
+
return String(a).localeCompare(b, undefined, {
|
|
52619
|
+
numeric: numeric,
|
|
52620
|
+
sensitivity: "base"
|
|
52621
|
+
});
|
|
52622
|
+
};
|
|
52623
|
+
|
|
52624
|
+
var applySort = function applySort(rows, sortColumn, columns) {
|
|
52625
|
+
return [].concat(rows).sort(function (a, b) {
|
|
52626
|
+
var column = columns.find(function (col) {
|
|
52627
|
+
return col.dataKey === sortColumn;
|
|
52628
|
+
});
|
|
52629
|
+
var numeric = column.numeric;
|
|
52630
|
+
return numericAlphabeticalSort(a[sortColumn], b[sortColumn], numeric);
|
|
52631
|
+
});
|
|
52632
|
+
};
|
|
52633
|
+
|
|
52634
|
+
var sortRows = function sortRows(rows, columns, sortState) {
|
|
52635
|
+
var sortedRows = applySort(rows, sortState.sortColumn, columns);
|
|
52636
|
+
return sortState.ascending ? sortedRows : sortedRows.reverse();
|
|
52637
|
+
};
|
|
52638
|
+
|
|
52639
|
+
var SortingTable = function SortingTable(_a) {
|
|
52640
|
+
var incomingColumns = _a.columns,
|
|
52641
|
+
incomingRows = _a.rows,
|
|
52642
|
+
initialSortColumn = _a.initialSortColumn,
|
|
52643
|
+
props = __rest(_a, ["columns", "rows", "initialSortColumn"]);
|
|
52644
|
+
|
|
52645
|
+
var _useState = useState({
|
|
52646
|
+
ascending: true,
|
|
52647
|
+
sortColumn: initialSortColumn
|
|
52648
|
+
}),
|
|
52649
|
+
sortState = _useState[0],
|
|
52650
|
+
setSortState = _useState[1];
|
|
52651
|
+
|
|
52652
|
+
var _useState2 = useState(function () {
|
|
52653
|
+
return sortRows(incomingRows, incomingColumns, sortState);
|
|
52654
|
+
}),
|
|
52655
|
+
rows = _useState2[0],
|
|
52656
|
+
setRows = _useState2[1];
|
|
52657
|
+
|
|
52658
|
+
var onSortChange = function onSortChange(dataKey) {
|
|
52659
|
+
var newSortState;
|
|
52660
|
+
setSortState(function (previousState) {
|
|
52661
|
+
var ascending = previousState.sortColumn !== dataKey || !previousState.ascending;
|
|
52662
|
+
newSortState = {
|
|
52663
|
+
ascending: ascending,
|
|
52664
|
+
sortColumn: dataKey
|
|
52665
|
+
};
|
|
52666
|
+
return newSortState;
|
|
52667
|
+
});
|
|
52668
|
+
setRows(function (previousState) {
|
|
52669
|
+
return sortRows(previousState, incomingColumns, newSortState);
|
|
52670
|
+
});
|
|
52671
|
+
};
|
|
52672
|
+
|
|
52673
|
+
var transformColumn = function transformColumn(column) {
|
|
52674
|
+
var isAscending = sortState.ascending && column.dataKey === sortState.sortColumn;
|
|
52675
|
+
return Object.assign(Object.assign({}, column), {
|
|
52676
|
+
headerFormatter: function headerFormatter(_ref) {
|
|
52677
|
+
var label = _ref.label,
|
|
52678
|
+
dataKey = _ref.dataKey;
|
|
52679
|
+
return /*#__PURE__*/React__default.createElement(Table.SortingHeader, {
|
|
52680
|
+
onChange: function onChange() {
|
|
52681
|
+
return onSortChange(dataKey);
|
|
52682
|
+
},
|
|
52683
|
+
label: label,
|
|
52684
|
+
ascending: isAscending,
|
|
52685
|
+
active: dataKey === sortState.sortColumn
|
|
52686
|
+
});
|
|
52687
|
+
}
|
|
52688
|
+
});
|
|
52689
|
+
};
|
|
52690
|
+
|
|
52691
|
+
var columns = incomingColumns.map(function (column) {
|
|
52692
|
+
return transformColumn(column);
|
|
52693
|
+
});
|
|
52694
|
+
return /*#__PURE__*/React__default.createElement(Table, Object.assign({
|
|
52695
|
+
columns: columns,
|
|
52696
|
+
rows: rows
|
|
52697
|
+
}, props));
|
|
52698
|
+
};
|
|
52699
|
+
|
|
52700
|
+
export { ALL_NDS_LOCALES, Alert, AnimatedBox, ApplicationFrame, AsyncSelect, Box, NavBar as BrandedNavBar, Branding, Breadcrumbs, Button, ButtonGroup, Card, CardSet, Checkbox, CheckboxGroup, ControlIcon, DangerButton, DatePicker, DateRange, Divider, DropdownButton, DropdownItem, DropdownLink, DropdownMenu, Field, FieldLabel, Fieldset, Flex, Form, FormSection, Heading1, Heading2, Heading3, Heading4, HelpText, Icon, IconicButton, InlineIcon, InlineValidation, Input$1 as Input, Link, List, ListItem, LoadingAnimation, Modal, NDSProvider, NavBar$1 as NavBar, Overlay, Page, Pagination, PrimaryButton, QuietButton, Radio, RadioGroup, RangeContainer, RequirementText, ReactSelect as Select, SelectClearIndicator, SelectContainer$1 as SelectContainer, SelectControl, SelectDropdownIndicator, SelectInput, SelectMenu, SelectMultiValue, SelectOption, Sidebar, SortingTable, StatusIndicator, Tab, Table, Tabs, Text, Textarea, TimePicker, TimeRange, Toast, ToggleComponent as Toggle, Tooltip, TruncatedText, Theme as theme, useWindowDimensions };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
declare const _default: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: React.FC<import("../Table/BaseTable").BaseTableProps & {
|
|
5
|
+
selectedRows?: string[];
|
|
6
|
+
onRowSelectionChange?: (...args: any[]) => any;
|
|
7
|
+
onRowExpansionChange?: (...args: any[]) => any;
|
|
8
|
+
rowsPerPage?: number;
|
|
9
|
+
onPageChange?: (...args: any[]) => any;
|
|
10
|
+
selectAllAriaLabel?: string;
|
|
11
|
+
deselectAllAriaLabel?: string;
|
|
12
|
+
paginationCss?: any;
|
|
13
|
+
paginationProps?: any;
|
|
14
|
+
expandedRows?: any[];
|
|
15
|
+
hasSelectableRows?: boolean;
|
|
16
|
+
hasExpandableRows?: boolean;
|
|
17
|
+
onSelectRow?: (...args: any[]) => any;
|
|
18
|
+
onSelectHeader?: (...args: any[]) => any;
|
|
19
|
+
isHeaderSelected?: any;
|
|
20
|
+
} & {
|
|
21
|
+
initialSortColumn: string;
|
|
22
|
+
}>;
|
|
23
|
+
};
|
|
24
|
+
export default _default;
|
|
25
|
+
export declare const _SortingTable: () => JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as SortingTable } from "./SortingTable";
|
package/dist/src/index.d.ts
CHANGED