@commonsku/styles 1.17.22 → 1.17.24

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/index.d.ts CHANGED
@@ -15,7 +15,7 @@ import { GroupBase, StylesConfig, SelectInstance } from 'react-select';
15
15
  export { components, createFilter, mergeStyles } from 'react-select';
16
16
  import * as react_select_dist_declarations_src_Select from 'react-select/dist/declarations/src/Select';
17
17
  import { ReactDatePickerProps } from 'react-datepicker';
18
- import { HeaderGroup, UseSortByColumnProps, UseTableRowProps, UseExpandedRowProps, UseGroupByRowProps, UseRowSelectRowProps, UseRowStateRowProps, Column as Column$1, SortingRule, Cell } from 'react-table';
18
+ import { UseTableRowProps, UseExpandedRowProps, UseGroupByRowProps, UseRowSelectRowProps, UseRowStateRowProps, Column as Column$1, SortingRule, Cell, UseSortByState } from 'react-table';
19
19
  import { ListOnScrollProps } from 'react-window';
20
20
  import * as react_tooltip from 'react-tooltip';
21
21
 
@@ -2938,12 +2938,6 @@ type InputStepperStyledProps = Omit<NumberInputProps, 'onChange'> & {
2938
2938
  declare function InputStepperStyled(props: InputStepperStyledProps): React__default.JSX.Element;
2939
2939
  declare function InputStepper(props: InputStepperProps): React__default.JSX.Element;
2940
2940
 
2941
- interface BaseSortByHeaderGroup<D extends object = {}> extends HeaderGroup<D>, UseSortByColumnProps<D> {
2942
- containerProps?: object;
2943
- style?: React__default.CSSProperties;
2944
- className?: string;
2945
- }
2946
-
2947
2941
  interface Row<D extends Record<string, unknown> = Record<string, unknown>> extends UseTableRowProps<D>, UseExpandedRowProps<D>, UseGroupByRowProps<D>, UseRowSelectRowProps<D>, UseRowStateRowProps<D> {
2948
2942
  }
2949
2943
 
@@ -2984,9 +2978,6 @@ type VirtualTableProps<RowType extends Record<string, unknown>, TableProps, Tabl
2984
2978
  [key: string]: any;
2985
2979
  }>) => React__default.ReactElement;
2986
2980
  renderRowSubComponent?: <P = unknown>(props: React__default.PropsWithChildren<P>) => React__default.ReactElement;
2987
- onSort?: (value: {
2988
- column: BaseSortByHeaderGroup<RowType>;
2989
- }) => void;
2990
2981
  onResize?: VoidFunction;
2991
2982
  rowGroupStyles?: (value: {
2992
2983
  row: Row<RowType>;
@@ -2997,6 +2988,7 @@ type VirtualTableProps<RowType extends Record<string, unknown>, TableProps, Tabl
2997
2988
  style: React__default.CSSProperties;
2998
2989
  }) => React__default.CSSProperties;
2999
2990
  gutterSize?: number;
2991
+ onSortChange?: (sortState: UseSortByState<RowType>) => void;
3000
2992
  };
3001
2993
  declare const VirtualTable: <RowType extends Record<string, unknown>, TableProps, TableFooterProps>(props: VirtualTableProps<RowType, TableProps, TableFooterProps>) => React__default.JSX.Element;
3002
2994
 
@@ -3290,16 +3282,17 @@ type GearIconProps = SVGIconProps & {
3290
3282
  declare function GearIcon({ color, filled, size, altText, ...props }: GearIconProps): React__default.JSX.Element;
3291
3283
 
3292
3284
  type CircleProgressIconProps = SVGIconProps & {
3293
- sqSize?: number;
3294
3285
  strokeWidth?: number;
3295
3286
  percentage?: number;
3296
3287
  strokeColor?: string;
3297
3288
  textColor?: string;
3298
3289
  text?: string;
3299
- viewBox?: string;
3300
3290
  textStyle?: React__default.CSSProperties;
3291
+ showCheckMarkOnComplete?: boolean;
3292
+ size?: "tiny" | "small" | "medium" | "large" | "huge";
3293
+ altText?: string;
3301
3294
  };
3302
- declare function CircleProgressIcon({ sqSize, strokeWidth, percentage, strokeColor, textColor, text, textStyle, color, size, altText, ...props }: CircleProgressIconProps): React__default.JSX.Element;
3295
+ declare function CircleProgressIcon({ strokeWidth, percentage, strokeColor, textColor, text, textStyle, showCheckMarkOnComplete, size, altText, ...props }: CircleProgressIconProps): React__default.JSX.Element;
3303
3296
 
3304
3297
  declare function Loading({ height, width, animationDuration, barWidth, barRadius, colorful, bars, viewBox, rotate, startColor, endColor, ...props }: {
3305
3298
  height?: number;
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import _, { map, pick, keys, isUndefined, get, uniqueId, assign, range as range$1, isEmpty, tail, toNumber, isString, filter, round, partial, debounce } from 'lodash';
2
2
  import styled, { css, createGlobalStyle, ThemeProvider, keyframes } from 'styled-components';
3
- import React, { useMemo, Fragment, useState, useEffect, useRef, useCallback, useImperativeHandle, Component, useLayoutEffect, forwardRef, createContext, memo } from 'react';
3
+ import React, { useCallback, useMemo, Fragment, useState, useEffect, useRef, useImperativeHandle, Component, useLayoutEffect, forwardRef, createContext, memo } from 'react';
4
4
  import { useDropzone } from 'react-dropzone';
5
5
  import BaseSelect from 'react-select';
6
6
  export { components, createFilter, mergeStyles } from 'react-select';
@@ -1421,58 +1421,86 @@ var Theme = function (_a) {
1421
1421
  children));
1422
1422
  };
1423
1423
 
1424
+ var iconSizes$9 = {
1425
+ tiny: {
1426
+ width: 32,
1427
+ height: 32,
1428
+ viewBox: "0 0 32 32",
1429
+ fontSize: ".6em",
1430
+ defaultStrokeWidth: 3,
1431
+ },
1432
+ small: {
1433
+ width: 40,
1434
+ height: 40,
1435
+ viewBox: "0 0 40 40",
1436
+ fontSize: ".6em",
1437
+ defaultStrokeWidth: 3,
1438
+ },
1439
+ medium: {
1440
+ width: 48,
1441
+ height: 48,
1442
+ viewBox: "0 0 48 48",
1443
+ fontSize: ".8em",
1444
+ defaultStrokeWidth: 5,
1445
+ },
1446
+ large: {
1447
+ width: 72,
1448
+ height: 72,
1449
+ viewBox: "0 0 72 72",
1450
+ fontSize: "1em",
1451
+ defaultStrokeWidth: 5,
1452
+ },
1453
+ huge: {
1454
+ width: 96,
1455
+ height: 96,
1456
+ viewBox: "0 0 96 96",
1457
+ fontSize: "1em",
1458
+ defaultStrokeWidth: 5,
1459
+ },
1460
+ default: {
1461
+ height: 48,
1462
+ width: 48,
1463
+ viewBox: "0 0 48 48",
1464
+ fontSize: ".8em",
1465
+ defaultStrokeWidth: 5,
1466
+ },
1467
+ };
1424
1468
  function CircleProgressIcon(_a) {
1425
- var sqSize = _a.sqSize, strokeWidth = _a.strokeWidth, _b = _a.percentage, percentage = _b === void 0 ? 0 : _b, _c = _a.strokeColor, strokeColor = _c === void 0 ? teal.main : _c, _d = _a.textColor, textColor = _d === void 0 ? teal.main : _d, _e = _a.text, text = _e === void 0 ? '' : _e, _f = _a.textStyle, textStyle = _f === void 0 ? {} : _f, _g = _a.color; _g === void 0 ? teal.main : _g; var _h = _a.size, size = _h === void 0 ? "medium" : _h, _j = _a.altText, altText = _j === void 0 ? "Progress level" : _j, props = __rest(_a, ["sqSize", "strokeWidth", "percentage", "strokeColor", "textColor", "text", "textStyle", "color", "size", "altText"]);
1426
- var iconSizes = {
1427
- tiny: {
1428
- width: 32,
1429
- height: 32,
1430
- viewBox: "0 0 32 32",
1431
- },
1432
- small: {
1433
- width: 40,
1434
- height: 40,
1435
- viewBox: "0 0 40 40",
1436
- },
1437
- medium: {
1438
- width: 48,
1439
- height: 48,
1440
- viewBox: "0 0 48 48",
1441
- },
1442
- large: {
1443
- width: 72,
1444
- height: 72,
1445
- viewBox: "0 0 72 72",
1446
- },
1447
- huge: {
1448
- width: 96,
1449
- height: 96,
1450
- viewBox: "0 0 96 96",
1451
- },
1452
- default: {
1453
- height: 48,
1454
- width: 48,
1455
- viewBox: "0 0 48 48",
1456
- },
1457
- };
1458
- sqSize = iconSizes[size]["width"];
1459
- strokeWidth = size === "tiny" || size === "small" ? 3 : 5;
1460
- var radius = (sqSize - strokeWidth) / 2;
1461
- // const viewBox = `0 0 ${sqSize} ${sqSize}`;
1469
+ var strokeWidth = _a.strokeWidth, _b = _a.percentage, percentage = _b === void 0 ? 0 : _b, _c = _a.strokeColor, strokeColor = _c === void 0 ? teal.main : _c, _d = _a.textColor, textColor = _d === void 0 ? teal.main : _d, _e = _a.text, text = _e === void 0 ? "" : _e, _f = _a.textStyle, textStyle = _f === void 0 ? {} : _f, _g = _a.showCheckMarkOnComplete, showCheckMarkOnComplete = _g === void 0 ? false : _g, _h = _a.size, size = _h === void 0 ? "medium" : _h, _j = _a.altText, altText = _j === void 0 ? "Progress level" : _j, props = __rest(_a, ["strokeWidth", "percentage", "strokeColor", "textColor", "text", "textStyle", "showCheckMarkOnComplete", "size", "altText"]);
1470
+ var _k = iconSizes$9[size], width = _k.width, defaultStrokeWidth = _k.defaultStrokeWidth, fontSize = _k.fontSize; _k.viewBox;
1471
+ strokeWidth = strokeWidth || defaultStrokeWidth;
1472
+ var squareSize = width;
1473
+ var radius = (squareSize - strokeWidth) / 2;
1462
1474
  var dashArray = radius * Math.PI * 2;
1463
- var dashOffset = dashArray - dashArray * percentage / 100;
1464
- return React.createElement(SVG$1, __assign({ size: size, iconSizes: iconSizes, "aria-labelledby": "CircleProgressIcon" }, props),
1465
- React.createElement("title", { id: "CircleProgressIcon" }, text !== '' ? "".concat(text, " stage") : percentage ? "".concat(percentage, "% completed") : altText),
1466
- React.createElement("circle", { className: "circle-background", cx: sqSize / 2, cy: sqSize / 2, r: radius, strokeWidth: "".concat(strokeWidth, "px"), style: { fill: 'none', stroke: colors$1.disabledButtonBorder, } }),
1467
- React.createElement("circle", { className: "circle-progress", cx: sqSize / 2, cy: sqSize / 2, r: radius, strokeWidth: "".concat(strokeWidth, "px"), transform: "rotate(-90 ".concat(sqSize / 2, " ").concat(sqSize / 2, ")"), style: {
1475
+ var dashOffset = dashArray - (dashArray * percentage) / 100;
1476
+ var isComplete = percentage === 100;
1477
+ var renderInnerText = useCallback(function () { return (React.createElement("text", { className: "circle-text", x: "50%", y: "50%", dy: ".3em", textAnchor: "middle", style: __assign({ fontSize: fontSize, fontWeight: "bold", fill: textColor }, textStyle) }, text || "".concat(percentage, "%"))); }, [fontSize, textColor, textStyle, text, percentage]);
1478
+ var renderCheckMark = useCallback(function () {
1479
+ var preferredViewBox = 40;
1480
+ var scale = squareSize / preferredViewBox;
1481
+ var scaledPath = [
1482
+ { x: 12.0006 * scale, y: 21.599 * scale },
1483
+ { x: 17.5629 * scale, y: 27.1617 * scale },
1484
+ { x: 29.1621 * scale, y: 15.5625 * scale },
1485
+ ]
1486
+ .map(function (p) { return "".concat(p.x, ",").concat(p.y); })
1487
+ .join(" L");
1488
+ return (React.createElement("path", { d: "M".concat(scaledPath), stroke: strokeColor, strokeWidth: "".concat(strokeWidth, "px"), fill: "none" }));
1489
+ }, [squareSize, strokeColor, strokeWidth]);
1490
+ return (React.createElement(SVG$1, __assign({ size: size, iconSizes: iconSizes$9, "aria-labelledby": "CircleProgressIcon" }, props),
1491
+ React.createElement("title", { id: "CircleProgressIcon" }, altText || (text ? "".concat(text, " stage") : "".concat(percentage, "% completed"))),
1492
+ React.createElement("circle", { className: "circle-background", cx: squareSize / 2, cy: squareSize / 2, r: radius, strokeWidth: "".concat(strokeWidth, "px"), style: { fill: "none", stroke: colors$1.disabledButtonBorder } }),
1493
+ React.createElement("circle", { className: "circle-progress", cx: squareSize / 2, cy: squareSize / 2, r: radius, strokeWidth: "".concat(strokeWidth, "px"), transform: "rotate(-90 ".concat(squareSize / 2, " ").concat(squareSize / 2, ")"), style: {
1468
1494
  strokeDasharray: dashArray,
1469
1495
  strokeDashoffset: dashOffset,
1470
- fill: 'none',
1496
+ fill: "none",
1471
1497
  stroke: strokeColor,
1472
- strokeLinecap: 'round',
1473
- strokeLinejoin: 'round',
1498
+ strokeLinecap: "round",
1499
+ strokeLinejoin: "round",
1474
1500
  } }),
1475
- React.createElement("text", { className: "circle-text", x: "50%", y: "50%", dy: ".3em", textAnchor: "middle", style: __assign({ fontSize: size === "small" || size === "tiny" ? ".6em" : size === "medium" ? ".8em" : "1em", fontWeight: 'bold', fill: textColor }, textStyle) }, text || "".concat(percentage, "%")));
1501
+ showCheckMarkOnComplete && isComplete
1502
+ ? renderCheckMark()
1503
+ : renderInnerText()));
1476
1504
  }
1477
1505
 
1478
1506
  var SVG = styled.svg(templateObject_1$Y || (templateObject_1$Y = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), SharedStyles);
@@ -7144,7 +7172,7 @@ function InputStepper(props) {
7144
7172
  var templateObject_1$c, templateObject_2$1, templateObject_3, templateObject_4;
7145
7173
 
7146
7174
  var VirtualTable = function (props) {
7147
- var columns = props.columns, data = props.data, itemSize = props.itemSize, _a = props.height, height = _a === void 0 ? 500 : _a, _b = props.minWidth, minWidth = _b === void 0 ? 140 : _b, _c = props.maxWidth, maxWidth = _c === void 0 ? 500 : _c, defaultSort = props.defaultSort, onClickRow = props.onClickRow, onScroll = props.onScroll, onUpdateData = props.onUpdateData, _d = props.useTableProps, useTableProps = _d === void 0 ? {} : _d, _e = props.tableHeaderProps, tableHeaderProps = _e === void 0 ? {} : _e, _f = props.tableFooterProps, tableFooterProps = _f === void 0 ? {} : _f, _g = props.hideFooter, hideFooter = _g === void 0 ? true : _g, _h = props.hideHeader, hideHeader = _h === void 0 ? false : _h, _j = props.className, className = _j === void 0 ? '' : _j, NoRowsFound = props.NoRowsFound, renderRowSubComponent = props.renderRowSubComponent, onSort = props.onSort; props.onResize; var rowGroupStyles = props.rowGroupStyles, rowStyles = props.rowStyles, _k = props.gutterSize, gutterSize = _k === void 0 ? 0 : _k, _l = props.customTableFooterProps, customTableFooterProps = _l === void 0 ? {} : _l, TableFooter = props.TableFooter;
7175
+ var columns = props.columns, data = props.data, itemSize = props.itemSize, _a = props.height, height = _a === void 0 ? 500 : _a, _b = props.minWidth, minWidth = _b === void 0 ? 140 : _b, _c = props.maxWidth, maxWidth = _c === void 0 ? 500 : _c, defaultSort = props.defaultSort, onClickRow = props.onClickRow, onScroll = props.onScroll, onUpdateData = props.onUpdateData, _d = props.useTableProps, useTableProps = _d === void 0 ? {} : _d, _e = props.tableHeaderProps, tableHeaderProps = _e === void 0 ? {} : _e, _f = props.tableFooterProps, tableFooterProps = _f === void 0 ? {} : _f, _g = props.hideFooter, hideFooter = _g === void 0 ? true : _g, _h = props.hideHeader, hideHeader = _h === void 0 ? false : _h, _j = props.className, className = _j === void 0 ? '' : _j, NoRowsFound = props.NoRowsFound, renderRowSubComponent = props.renderRowSubComponent; props.onResize; var rowGroupStyles = props.rowGroupStyles, rowStyles = props.rowStyles, _k = props.gutterSize, gutterSize = _k === void 0 ? 0 : _k, _l = props.customTableFooterProps, customTableFooterProps = _l === void 0 ? {} : _l, TableFooter = props.TableFooter, onSortChange = props.onSortChange;
7148
7176
  var defaultColumn = useMemo(function () { return ({
7149
7177
  minWidth: minWidth,
7150
7178
  maxWidth: maxWidth,
@@ -7159,6 +7187,7 @@ var VirtualTable = function (props) {
7159
7187
  var footerRef = useRef(null);
7160
7188
  var rowsRef = useRef(null);
7161
7189
  var listRef = useRef(null);
7190
+ var sortBy = tableData.state.sortBy;
7162
7191
  function resetList(index) {
7163
7192
  if (index === void 0) { index = 0; }
7164
7193
  listRef.current && listRef.current.resetAfterIndex(index);
@@ -7174,8 +7203,7 @@ var VirtualTable = function (props) {
7174
7203
  var _a;
7175
7204
  listRef.current && listRef.current.resetAfterIndex(0);
7176
7205
  (_a = column.toggleSortBy) === null || _a === void 0 ? void 0 : _a.call(column);
7177
- onSort && onSort({ column: column });
7178
- }, [onSort]);
7206
+ }, []);
7179
7207
  function onListScroll(e) {
7180
7208
  if (headerRef.current && e && e.target) {
7181
7209
  var target = e.target;
@@ -7253,11 +7281,27 @@ var VirtualTable = function (props) {
7253
7281
  setScrolledToBottom(Math.round(rows.scrollTop) >= rows.scrollHeight - rows.offsetHeight);
7254
7282
  }
7255
7283
  }, [onScroll]);
7256
- return (React.createElement("div", __assign({}, getTableProps(), { className: "table ".concat(className || '') }),
7257
- React.createElement("div", __assign({}, tableHeaderProps, { className: "thead ".concat(tableHeaderProps.className || ''), style: __assign(__assign({}, (tableHeaderProps.style || {})), (hideHeader ? { display: 'none' } : {})) }), headerGroups.map(function (headerGroup) { return (React.createElement("div", __assign({}, getHeaderGroupProps(headerGroup, false), { ref: headerRef, style: { width: tableWidth, } }), headerGroup.headers.map(function (column) { return (React.createElement("div", __assign({}, getHeaderProps(column, false), { className: "th", onClick: function () { return handleSort(column); } }),
7284
+ var renderTableHeader = useCallback(function () {
7285
+ var sortIconDirection = function (column) { return column.isSorted
7286
+ ? sortDirection(column)
7287
+ : "updown"; };
7288
+ return (React.createElement("div", __assign({}, tableHeaderProps, { className: "thead ".concat(tableHeaderProps.className || ""), style: __assign(__assign({}, (tableHeaderProps.style || {})), (hideHeader ? { display: "none" } : {})) }), headerGroups.map(function (headerGroup) { return (React.createElement("div", __assign({}, getHeaderGroupProps(headerGroup, false), { ref: headerRef, style: { width: tableWidth } }), headerGroup.headers.map(function (column) { return (React.createElement("div", __assign({}, getHeaderProps(column, false), { className: "th", onClick: function () { return handleSort(column); } }),
7258
7289
  column.render("Header"),
7259
- React.createElement("span", null, column.canSort &&
7260
- React.createElement(FilledChevronIcon, { direction: column.isSorted ? sortDirection(column) : 'updown', size: "medium", style: { verticalAlign: 'middle' } })))); }))); })),
7290
+ React.createElement("span", null, column.canSort && (React.createElement(FilledChevronIcon, { direction: sortIconDirection(column), size: "medium", style: { verticalAlign: "middle" } }))))); }))); })));
7291
+ }, [
7292
+ getHeaderGroupProps,
7293
+ getHeaderProps,
7294
+ handleSort,
7295
+ headerGroups,
7296
+ hideHeader,
7297
+ tableHeaderProps,
7298
+ tableWidth,
7299
+ ]);
7300
+ useEffect(function () {
7301
+ onSortChange && onSortChange({ sortBy: sortBy });
7302
+ }, [sortBy]);
7303
+ return (React.createElement("div", __assign({}, getTableProps(), { className: "table ".concat(className || '') }),
7304
+ renderTableHeader(),
7261
7305
  React.createElement("div", __assign({ className: "tbody" }, getTableBodyProps()), rows.length === 0 && NoRowsFound ? React.createElement(NoRowsFound, null) :
7262
7306
  React.createElement("div", { className: "scroll-container" },
7263
7307
  !scrolledToTop &&