@nulogy/components 6.2.1 → 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 +95 -5
- package/dist/main.module.js +95 -6
- 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/dist/src/theme.type.d.ts +1 -0
- package/package.json +5 -5
package/dist/main.js
CHANGED
|
@@ -191,7 +191,8 @@
|
|
|
191
191
|
|
|
192
192
|
var i18nOptions = _objectSpread$6(_objectSpread$6(_objectSpread$6({}, getDefaults()), i18n.options.react), props);
|
|
193
193
|
|
|
194
|
-
var useSuspense = i18nOptions.useSuspense
|
|
194
|
+
var useSuspense = i18nOptions.useSuspense,
|
|
195
|
+
keyPrefix = i18nOptions.keyPrefix;
|
|
195
196
|
var namespaces = ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS;
|
|
196
197
|
namespaces = typeof namespaces === 'string' ? [namespaces] : namespaces || ['translation'];
|
|
197
198
|
if (i18n.reportNamespaces.addUsedNamespaces) i18n.reportNamespaces.addUsedNamespaces(namespaces);
|
|
@@ -200,7 +201,7 @@
|
|
|
200
201
|
});
|
|
201
202
|
|
|
202
203
|
function getT() {
|
|
203
|
-
return i18n.getFixedT(null, i18nOptions.nsMode === 'fallback' ? namespaces : namespaces[0]);
|
|
204
|
+
return i18n.getFixedT(null, i18nOptions.nsMode === 'fallback' ? namespaces : namespaces[0], keyPrefix);
|
|
204
205
|
}
|
|
205
206
|
|
|
206
207
|
var _useState = React.useState(getT),
|
|
@@ -283,6 +284,7 @@
|
|
|
283
284
|
const color_base_blue = "#216beb";
|
|
284
285
|
const color_base_light_blue = "#e1ebfa";
|
|
285
286
|
const color_base_dark_grey = "#434d59";
|
|
287
|
+
const color_base_mid_grey = "#6c7784";
|
|
286
288
|
const color_base_grey = "#c0c8d1";
|
|
287
289
|
const color_base_light_grey = "#e4e7eb";
|
|
288
290
|
const color_base_white_grey = "#f0f2f5";
|
|
@@ -364,6 +366,7 @@
|
|
|
364
366
|
blue: color_base_blue,
|
|
365
367
|
lightBlue: color_base_light_blue,
|
|
366
368
|
darkGrey: color_base_dark_grey,
|
|
369
|
+
midGrey: color_base_mid_grey,
|
|
367
370
|
grey: color_base_grey,
|
|
368
371
|
lightGrey: color_base_light_grey,
|
|
369
372
|
whiteGrey: color_base_white_grey,
|
|
@@ -20202,6 +20205,11 @@
|
|
|
20202
20205
|
|
|
20203
20206
|
var spaceProps = getSubset(props, propTypes.space);
|
|
20204
20207
|
var restProps = omitSubset(props, propTypes.space);
|
|
20208
|
+
var modifiers = React.useMemo(function () {
|
|
20209
|
+
return transformPropsToModifiers({
|
|
20210
|
+
boundariesElement: boundariesElement
|
|
20211
|
+
});
|
|
20212
|
+
}, [boundariesElement]);
|
|
20205
20213
|
return /*#__PURE__*/React__default['default'].createElement(Popper$1, {
|
|
20206
20214
|
trigger: /*#__PURE__*/React__default['default'].cloneElement(trigger(), Object.assign({
|
|
20207
20215
|
type: "button",
|
|
@@ -20216,9 +20224,7 @@
|
|
|
20216
20224
|
openOnClick: true,
|
|
20217
20225
|
ref: ref,
|
|
20218
20226
|
openOnHover: false,
|
|
20219
|
-
modifiers:
|
|
20220
|
-
boundariesElement: boundariesElement
|
|
20221
|
-
}),
|
|
20227
|
+
modifiers: modifiers,
|
|
20222
20228
|
backgroundColor: backgroundColor,
|
|
20223
20229
|
borderColor: backgroundColor,
|
|
20224
20230
|
openAriaLabel: openAriaLabel,
|
|
@@ -52634,6 +52640,89 @@
|
|
|
52634
52640
|
}, props));
|
|
52635
52641
|
};
|
|
52636
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
|
+
|
|
52637
52726
|
exports.ALL_NDS_LOCALES = ALL_NDS_LOCALES;
|
|
52638
52727
|
exports.Alert = Alert;
|
|
52639
52728
|
exports.AnimatedBox = AnimatedBox;
|
|
@@ -52700,6 +52789,7 @@
|
|
|
52700
52789
|
exports.SelectMultiValue = SelectMultiValue;
|
|
52701
52790
|
exports.SelectOption = SelectOption;
|
|
52702
52791
|
exports.Sidebar = Sidebar;
|
|
52792
|
+
exports.SortingTable = SortingTable;
|
|
52703
52793
|
exports.StatusIndicator = StatusIndicator;
|
|
52704
52794
|
exports.Tab = Tab;
|
|
52705
52795
|
exports.Table = Table;
|
package/dist/main.module.js
CHANGED
|
@@ -165,7 +165,8 @@ function useTranslation(ns) {
|
|
|
165
165
|
|
|
166
166
|
var i18nOptions = _objectSpread$6(_objectSpread$6(_objectSpread$6({}, getDefaults()), i18n.options.react), props);
|
|
167
167
|
|
|
168
|
-
var useSuspense = i18nOptions.useSuspense
|
|
168
|
+
var useSuspense = i18nOptions.useSuspense,
|
|
169
|
+
keyPrefix = i18nOptions.keyPrefix;
|
|
169
170
|
var namespaces = ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS;
|
|
170
171
|
namespaces = typeof namespaces === 'string' ? [namespaces] : namespaces || ['translation'];
|
|
171
172
|
if (i18n.reportNamespaces.addUsedNamespaces) i18n.reportNamespaces.addUsedNamespaces(namespaces);
|
|
@@ -174,7 +175,7 @@ function useTranslation(ns) {
|
|
|
174
175
|
});
|
|
175
176
|
|
|
176
177
|
function getT() {
|
|
177
|
-
return i18n.getFixedT(null, i18nOptions.nsMode === 'fallback' ? namespaces : namespaces[0]);
|
|
178
|
+
return i18n.getFixedT(null, i18nOptions.nsMode === 'fallback' ? namespaces : namespaces[0], keyPrefix);
|
|
178
179
|
}
|
|
179
180
|
|
|
180
181
|
var _useState = useState(getT),
|
|
@@ -257,6 +258,7 @@ const color_base_dark_blue = "#00438f";
|
|
|
257
258
|
const color_base_blue = "#216beb";
|
|
258
259
|
const color_base_light_blue = "#e1ebfa";
|
|
259
260
|
const color_base_dark_grey = "#434d59";
|
|
261
|
+
const color_base_mid_grey = "#6c7784";
|
|
260
262
|
const color_base_grey = "#c0c8d1";
|
|
261
263
|
const color_base_light_grey = "#e4e7eb";
|
|
262
264
|
const color_base_white_grey = "#f0f2f5";
|
|
@@ -338,6 +340,7 @@ var Theme = {
|
|
|
338
340
|
blue: color_base_blue,
|
|
339
341
|
lightBlue: color_base_light_blue,
|
|
340
342
|
darkGrey: color_base_dark_grey,
|
|
343
|
+
midGrey: color_base_mid_grey,
|
|
341
344
|
grey: color_base_grey,
|
|
342
345
|
lightGrey: color_base_light_grey,
|
|
343
346
|
whiteGrey: color_base_white_grey,
|
|
@@ -20176,6 +20179,11 @@ var DropdownMenu = /*#__PURE__*/React__default.forwardRef(function (_a, ref) {
|
|
|
20176
20179
|
|
|
20177
20180
|
var spaceProps = getSubset(props, propTypes.space);
|
|
20178
20181
|
var restProps = omitSubset(props, propTypes.space);
|
|
20182
|
+
var modifiers = useMemo(function () {
|
|
20183
|
+
return transformPropsToModifiers({
|
|
20184
|
+
boundariesElement: boundariesElement
|
|
20185
|
+
});
|
|
20186
|
+
}, [boundariesElement]);
|
|
20179
20187
|
return /*#__PURE__*/React__default.createElement(Popper$1, {
|
|
20180
20188
|
trigger: /*#__PURE__*/React__default.cloneElement(trigger(), Object.assign({
|
|
20181
20189
|
type: "button",
|
|
@@ -20190,9 +20198,7 @@ var DropdownMenu = /*#__PURE__*/React__default.forwardRef(function (_a, ref) {
|
|
|
20190
20198
|
openOnClick: true,
|
|
20191
20199
|
ref: ref,
|
|
20192
20200
|
openOnHover: false,
|
|
20193
|
-
modifiers:
|
|
20194
|
-
boundariesElement: boundariesElement
|
|
20195
|
-
}),
|
|
20201
|
+
modifiers: modifiers,
|
|
20196
20202
|
backgroundColor: backgroundColor,
|
|
20197
20203
|
borderColor: backgroundColor,
|
|
20198
20204
|
openAriaLabel: openAriaLabel,
|
|
@@ -52608,4 +52614,87 @@ var Divider = function Divider(_a) {
|
|
|
52608
52614
|
}, props));
|
|
52609
52615
|
};
|
|
52610
52616
|
|
|
52611
|
-
|
|
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
package/dist/src/theme.type.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nulogy/components",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.4.0",
|
|
4
4
|
"description": "Component library for the Nulogy Design System - http://nulogy.design",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"@storybook/addon-storysource": "^6.1.9",
|
|
75
75
|
"@storybook/addon-viewport": "^6.1.9",
|
|
76
76
|
"@storybook/codemod": "^6.1.9",
|
|
77
|
-
"@storybook/react": "^6.
|
|
77
|
+
"@storybook/react": "^6.3.12",
|
|
78
78
|
"@storybook/theming": "^6.1.9",
|
|
79
79
|
"@testing-library/jest-dom": "5.11.5",
|
|
80
80
|
"@testing-library/react": "^10.0.0",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"babel-plugin-require-context-hook": "1.0.0",
|
|
95
95
|
"babel-plugin-styled-components": "1.10.7",
|
|
96
96
|
"babel-preset-react": "6.24.1",
|
|
97
|
-
"chromatic": "^
|
|
97
|
+
"chromatic": "^6.0.6",
|
|
98
98
|
"concurrently": "^5.2.0",
|
|
99
99
|
"cypress": "^4.0.0",
|
|
100
100
|
"cypress-enter-plugin": "^1.0.1",
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"enzyme-to-json": "3.4.4",
|
|
105
105
|
"eslint": "6.8.0",
|
|
106
106
|
"eslint-plugin-prettier": "^3.1.4",
|
|
107
|
-
"http-server": "0.
|
|
107
|
+
"http-server": "^14.0.0",
|
|
108
108
|
"husky": "^4.3.0",
|
|
109
109
|
"jest": "24.1.0",
|
|
110
110
|
"jest-styled-components": "7",
|
|
@@ -152,7 +152,7 @@
|
|
|
152
152
|
"polished": "3.4.4",
|
|
153
153
|
"react-datepicker": "^4.1.0",
|
|
154
154
|
"react-fast-compare": "^3.2.0",
|
|
155
|
-
"react-i18next": "^11.
|
|
155
|
+
"react-i18next": "^11.14.2",
|
|
156
156
|
"react-input-autosize": "^2.2.2",
|
|
157
157
|
"react-modal": "^3.10.1",
|
|
158
158
|
"react-popper": "1.3.7",
|