@xqmsg/ui-core 0.24.11 → 0.25.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.
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { ReadonlyTableColumns, TableBody, TableColumns, TableHeaders } from './TableTypes';
2
+ import { ReadonlyTableColumns, TableBody, TableColumns, TableColumnsWidths, TableHeaders } from './TableTypes';
3
3
  export interface SimpleTableProps<T extends ReadonlyTableColumns> {
4
4
  columns: TableColumns;
5
5
  headers?: TableHeaders<T>;
@@ -7,8 +7,10 @@ export interface SimpleTableProps<T extends ReadonlyTableColumns> {
7
7
  loading?: boolean;
8
8
  loadMore?: () => void;
9
9
  placeholder?: string;
10
+ layout?: 'fixed' | 'auto';
11
+ columnsWidths?: TableColumnsWidths<T>;
10
12
  }
11
13
  /**
12
14
  * A React component utilized to render the `Table` component
13
15
  */
14
- export declare function SimpleTable<T extends ReadonlyTableColumns>({ columns, headers, body, loading, loadMore, }: SimpleTableProps<T>): React.JSX.Element;
16
+ export declare function SimpleTable<T extends ReadonlyTableColumns>({ columns, headers, body, loading, loadMore, layout, columnsWidths, }: SimpleTableProps<T>): React.JSX.Element;
@@ -4,6 +4,9 @@ export declare type ReadonlyTableColumns = Readonly<TableColumns>;
4
4
  export declare type TableHeaders<K extends ReadonlyTableColumns> = {
5
5
  [k in K[number]]: ReactNode;
6
6
  };
7
+ export declare type TableColumnsWidths<K extends ReadonlyTableColumns> = {
8
+ [k in K[number]]: string | number;
9
+ };
7
10
  export declare type TableRow<K extends ReadonlyTableColumns> = {
8
11
  [k in K[number]]: ReactNode;
9
12
  };
@@ -10,6 +10,7 @@ export interface StackedPilledInputProps extends InputFieldProps {
10
10
  variant?: string;
11
11
  label?: string;
12
12
  truncatePillLength?: number;
13
+ mode?: 'scroll' | 'wrap';
13
14
  }
14
15
  /**
15
16
  * A functional React component utilized to render the `StackedPilledInput` component.
@@ -4,6 +4,8 @@ export interface TokenProps {
4
4
  onDelete: any;
5
5
  isMobile?: boolean;
6
6
  truncateLength?: number;
7
+ showClose?: boolean;
8
+ maxWidth?: string | number;
7
9
  }
8
10
  declare const Token: React.FC<TokenProps>;
9
11
  export default Token;
@@ -27,9 +27,10 @@ export interface InputProps<T extends FieldValues = FieldValues> extends Validat
27
27
  loadingOptions?: boolean;
28
28
  truncatePillLength?: number;
29
29
  searchable?: boolean;
30
+ overflowMode?: 'scroll' | 'wrap';
30
31
  }
31
32
  /**
32
33
  * A functional React component utilized to render the `Input` component. Utilizes a switch statement
33
34
  * to render the correct input based on the `inputType`.
34
35
  */
35
- export declare function Input<T extends FieldValues>({ inputType, label, ariaLabel, className, placeholder, name, helperText, options, tooltipText, isInvalid, errorText, isRequired, maxLength, defaultValue, fullOptions, control, disabled, rightElement, leftElement, variant, onChange, setValue, setError, clearErrors, separators, loadingOptions, truncatePillLength, searchable, }: InputProps<T>): React.JSX.Element;
36
+ export declare function Input<T extends FieldValues>({ inputType, label, ariaLabel, className, placeholder, name, helperText, options, tooltipText, isInvalid, errorText, isRequired, maxLength, defaultValue, fullOptions, control, disabled, rightElement, leftElement, variant, onChange, setValue, setError, clearErrors, separators, loadingOptions, truncatePillLength, searchable, overflowMode, }: InputProps<T>): React.JSX.Element;
@@ -1273,6 +1273,7 @@ var Close = function Close(_ref) {
1273
1273
  return /*#__PURE__*/React__default.createElement(Memo$7, {
1274
1274
  width: boxSize,
1275
1275
  height: boxSize,
1276
+ flexBasis: boxSize,
1276
1277
  onClick: onClick,
1277
1278
  cursor: "pointer"
1278
1279
  });
@@ -1285,7 +1286,11 @@ var Token = function Token(_ref) {
1285
1286
  _ref$isMobile = _ref.isMobile,
1286
1287
  isMobile = _ref$isMobile === void 0 ? false : _ref$isMobile,
1287
1288
  _ref$truncateLength = _ref.truncateLength,
1288
- truncateLength = _ref$truncateLength === void 0 ? 15 : _ref$truncateLength;
1289
+ truncateLength = _ref$truncateLength === void 0 ? 15 : _ref$truncateLength,
1290
+ _ref$showClose = _ref.showClose,
1291
+ showClose = _ref$showClose === void 0 ? true : _ref$showClose,
1292
+ _ref$maxWidth = _ref.maxWidth,
1293
+ maxWidth = _ref$maxWidth === void 0 ? 'auto' : _ref$maxWidth;
1289
1294
  return /*#__PURE__*/React__default.createElement(react.Flex, {
1290
1295
  key: label,
1291
1296
  borderRadius: 'full',
@@ -1293,6 +1298,7 @@ var Token = function Token(_ref) {
1293
1298
  alignItems: "center",
1294
1299
  width: "fit-content",
1295
1300
  w: "auto",
1301
+ maxWidth: maxWidth,
1296
1302
  h: isMobile ? '18px' : '16px',
1297
1303
  pl: "6px",
1298
1304
  pr: "2px",
@@ -1300,13 +1306,17 @@ var Token = function Token(_ref) {
1300
1306
  position: "relative"
1301
1307
  }, /*#__PURE__*/React__default.createElement(react.Text, {
1302
1308
  whiteSpace: "nowrap",
1309
+ wordBreak: "break-word",
1303
1310
  color: colors.label.primary.light,
1304
1311
  fontSize: isMobile ? '17px' : '13px',
1305
- pr: "4px"
1312
+ pr: "4px",
1313
+ maxWidth: maxWidth,
1314
+ overflow: "hidden",
1315
+ textOverflow: "ellipsis"
1306
1316
  }, lodash.truncate(label.trim(), {
1307
1317
  length: truncateLength,
1308
1318
  omission: '...'
1309
- })), /*#__PURE__*/React__default.createElement(Close, {
1319
+ })), showClose && /*#__PURE__*/React__default.createElement(Close, {
1310
1320
  boxSize: isMobile ? '17px' : '11px',
1311
1321
  onClick: onDelete
1312
1322
  }));
@@ -1620,7 +1630,9 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1620
1630
  separators = _ref2$separators === void 0 ? ['Enter', ' ', ',', ';', 'Tab'] : _ref2$separators,
1621
1631
  variant = _ref2.variant,
1622
1632
  label = _ref2.label,
1623
- truncatePillLength = _ref2.truncatePillLength;
1633
+ truncatePillLength = _ref2.truncatePillLength,
1634
+ _ref2$mode = _ref2.mode,
1635
+ mode = _ref2$mode === void 0 ? 'scroll' : _ref2$mode;
1624
1636
  var watchedValue = reactHookForm.useWatch({
1625
1637
  control: control,
1626
1638
  name: name
@@ -1641,6 +1653,7 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1641
1653
  localValue = _useState4[0],
1642
1654
  setLocalValue = _useState4[1];
1643
1655
  var latestTokenElement = document.getElementById(name + "_token_" + (lastestFormValueToArray.length - 1));
1656
+ var scrollMode = mode === 'scroll';
1644
1657
  // gets latest watched form value (common delimited) from RHF state and creates a list
1645
1658
  React.useEffect(function () {
1646
1659
  if (watchedValue !== undefined && !watchedValue.length) {
@@ -1792,11 +1805,13 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1792
1805
  bg: disabled ? colors.fill.light.quaternary : '#ffffff',
1793
1806
  cursor: disabled ? 'not-allowed' : 'pointer',
1794
1807
  ref: inputWrapperRef,
1795
- h: isMobile ? '48px' : '26px'
1808
+ h: isMobile ? '48px' : scrollMode ? '26px' : 'auto',
1809
+ minH: isMobile ? '48px' : '26px'
1796
1810
  }, /*#__PURE__*/React__default.createElement(react.Flex, {
1797
1811
  h: "100%",
1798
1812
  alignItems: "center",
1799
- overflowX: "scroll",
1813
+ overflowX: scrollMode ? 'scroll' : 'hidden',
1814
+ flexWrap: scrollMode ? 'nowrap' : 'wrap',
1800
1815
  overflowY: "hidden",
1801
1816
  maxWidth: isFocussed ? '80%' : '100%',
1802
1817
  style: {
@@ -1820,10 +1835,13 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1820
1835
  onClick: function onClick() {
1821
1836
  return setTokenIndex(index);
1822
1837
  },
1823
- width: "100%",
1838
+ width: scrollMode ? '100%' : 'auto',
1839
+ maxWidth: '100%',
1824
1840
  id: name + "_token_" + index
1825
1841
  }, /*#__PURE__*/React__default.createElement(Token, {
1842
+ maxWidth: '100%',
1826
1843
  label: label,
1844
+ showClose: !isFocussed || tokenIndex === index,
1827
1845
  onDelete: function onDelete(e) {
1828
1846
  e.stopPropagation();
1829
1847
  e.preventDefault();
@@ -1951,7 +1969,9 @@ function Input(_ref) {
1951
1969
  _ref$loadingOptions = _ref.loadingOptions,
1952
1970
  loadingOptions = _ref$loadingOptions === void 0 ? false : _ref$loadingOptions,
1953
1971
  truncatePillLength = _ref.truncatePillLength,
1954
- searchable = _ref.searchable;
1972
+ searchable = _ref.searchable,
1973
+ _ref$overflowMode = _ref.overflowMode,
1974
+ overflowMode = _ref$overflowMode === void 0 ? 'scroll' : _ref$overflowMode;
1955
1975
  function selectedInputField(onChange, onBlur, ref, value) {
1956
1976
  switch (inputType) {
1957
1977
  case 'text':
@@ -2082,7 +2102,8 @@ function Input(_ref) {
2082
2102
  variant: variant,
2083
2103
  label: label,
2084
2104
  separators: separators,
2085
- truncatePillLength: truncatePillLength
2105
+ truncatePillLength: truncatePillLength,
2106
+ mode: overflowMode
2086
2107
  });
2087
2108
  case 'switch':
2088
2109
  return /*#__PURE__*/React__default.createElement(StackedSwitch, {
@@ -3588,7 +3609,10 @@ function SimpleTable(_ref) {
3588
3609
  headers = _ref.headers,
3589
3610
  body = _ref.body,
3590
3611
  loading = _ref.loading,
3591
- loadMore = _ref.loadMore;
3612
+ loadMore = _ref.loadMore,
3613
+ _ref$layout = _ref.layout,
3614
+ layout = _ref$layout === void 0 ? 'auto' : _ref$layout,
3615
+ columnsWidths = _ref.columnsWidths;
3592
3616
  var columnsAsConst = generateTableColumnsAsConst(columns);
3593
3617
  return /*#__PURE__*/React__default.createElement(react.TableContainer, {
3594
3618
  border: "none",
@@ -3600,20 +3624,18 @@ function SimpleTable(_ref) {
3600
3624
  width: "100%",
3601
3625
  style: {
3602
3626
  borderCollapse: 'separate',
3603
- borderSpacing: '0px'
3627
+ borderSpacing: '0px',
3628
+ tableLayout: layout
3604
3629
  }
3605
- }, headers && /*#__PURE__*/React__default.createElement(react.Thead, null, /*#__PURE__*/React__default.createElement(react.Tr, {
3630
+ }, (headers || columnsWidths) && /*#__PURE__*/React__default.createElement(react.Thead, null, /*#__PURE__*/React__default.createElement(react.Tr, {
3606
3631
  _odd: {
3607
3632
  bg: colors.label.primary.dark
3608
3633
  }
3609
3634
  }, columnsAsConst.map(function (column, idx) {
3610
- return (
3611
- /*#__PURE__*/
3612
- // @ts-ignore
3613
- React__default.createElement(react.Th, {
3614
- key: idx
3615
- }, headers[column])
3616
- );
3635
+ return /*#__PURE__*/React__default.createElement(react.Th, {
3636
+ key: idx,
3637
+ width: columnsWidths == null ? void 0 : columnsWidths[column]
3638
+ }, headers && headers[column]);
3617
3639
  }))), /*#__PURE__*/React__default.createElement(react.Tbody, null, body.map(function (row, idx) {
3618
3640
  return /*#__PURE__*/React__default.createElement(react.Tr, {
3619
3641
  key: idx