@nulogy/components 15.1.1 → 15.1.3

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 CHANGED
@@ -52673,9 +52673,6 @@
52673
52673
  var value = _a.value,
52674
52674
  _onChange = _a.onChange,
52675
52675
  defaultValue = _a.defaultValue,
52676
- labelText = _a.labelText,
52677
- requirementText = _a.requirementText,
52678
- helpText = _a.helpText,
52679
52676
  disabled = _a.disabled,
52680
52677
  errorMessage = _a.errorMessage,
52681
52678
  errorList = _a.errorList,
@@ -52703,7 +52700,7 @@
52703
52700
  _a$closeMenuOnSelect = _a.closeMenuOnSelect,
52704
52701
  closeMenuOnSelect = _a$closeMenuOnSelect === void 0 ? true : _a$closeMenuOnSelect,
52705
52702
  noOptionsMessage = _a.noOptionsMessage,
52706
- props = __rest(_a, ["value", "onChange", "defaultValue", "labelText", "requirementText", "helpText", "disabled", "errorMessage", "errorList", "id", "initialIsOpen", "multiselect", "placeholder", "components", "options", "styles", "windowThreshold", "autocomplete", "maxHeight", "required", "menuPosition", "menuPlacement", "classNamePrefix", "closeMenuOnSelect", "noOptionsMessage"]);
52703
+ props = __rest(_a, ["value", "onChange", "defaultValue", "disabled", "errorMessage", "errorList", "id", "initialIsOpen", "multiselect", "placeholder", "components", "options", "styles", "windowThreshold", "autocomplete", "maxHeight", "required", "menuPosition", "menuPlacement", "classNamePrefix", "closeMenuOnSelect", "noOptionsMessage"]);
52707
52704
  var _useTranslation = useTranslation(),
52708
52705
  t = _useTranslation.t;
52709
52706
  var variant = useComponentVariant();
@@ -52715,6 +52712,16 @@
52715
52712
  return calcOptionsLength(options);
52716
52713
  }, [options]);
52717
52714
  var isWindowed = optionsLength >= windowThreshold;
52715
+ var labelText = props.labelText,
52716
+ requirementText = props.requirementText,
52717
+ helpText = props.helpText,
52718
+ hint = props.hint;
52719
+ var fieldLabelProps = {
52720
+ labelText: labelText,
52721
+ requirementText: requirementText,
52722
+ helpText: helpText,
52723
+ hint: hint
52724
+ };
52718
52725
  noOptionsMessage || (noOptionsMessage = function noOptionsMessage() {
52719
52726
  return t("no options");
52720
52727
  });
@@ -52729,11 +52736,7 @@
52729
52736
  maxHeight: maxHeight,
52730
52737
  windowed: options.length > windowThreshold
52731
52738
  });
52732
- return /*#__PURE__*/React__default["default"].createElement(Field, Object.assign({}, styledProps), /*#__PURE__*/React__default["default"].createElement(MaybeFieldLabel, {
52733
- labelText: labelText,
52734
- requirementText: requirementText,
52735
- helpText: helpText
52736
- }, /*#__PURE__*/React__default["default"].createElement(StateManagedSelect$1, Object.assign({
52739
+ return /*#__PURE__*/React__default["default"].createElement(Field, Object.assign({}, styledProps), /*#__PURE__*/React__default["default"].createElement(MaybeFieldLabel, Object.assign({}, fieldLabelProps), /*#__PURE__*/React__default["default"].createElement(StateManagedSelect$1, Object.assign({
52737
52740
  ref: ref,
52738
52741
  isSearchable: autocomplete,
52739
52742
  isDisabled: disabled,
@@ -52952,7 +52955,7 @@
52952
52955
  borderCollapse: "collapse"
52953
52956
  });
52954
52957
  });
52955
- var renderRows$1 = function renderRows(rows, columns, keyField, noRowsContent, rowHovers, compact, onRowMouseLeave, onRowMouseEnter, rowBorder) {
52958
+ var renderRows$1 = function renderRows(rows, columns, keyField, rowHovers, noRowsContent, compact, onRowMouseLeave, onRowMouseEnter, rowBorder) {
52956
52959
  return rows.length > 0 ? rows.map(function (row, rowIndex) {
52957
52960
  var rowKey = row[keyField] !== undefined ? row[keyField] : rowIndex;
52958
52961
  return /*#__PURE__*/React__default["default"].createElement(TableBodyRow, {
@@ -53054,7 +53057,7 @@
53054
53057
  rowBorder = _ref6.rowBorder;
53055
53058
  return /*#__PURE__*/React__default["default"].createElement("tbody", {
53056
53059
  "data-testid": "table-body"
53057
- }, !loading ? renderRows$1(rows, columns, keyField, noRowsContent, rowHovers, compact, onRowMouseLeave, onRowMouseEnter, rowBorder) : (/*#__PURE__*/React__default["default"].createElement(LoadingContent, {
53060
+ }, !loading ? renderRows$1(rows, columns, keyField, rowHovers, noRowsContent, compact, onRowMouseLeave, onRowMouseEnter, rowBorder) : (/*#__PURE__*/React__default["default"].createElement(LoadingContent, {
53058
53061
  colSpan: columns.length
53059
53062
  })));
53060
53063
  };
@@ -52656,9 +52656,6 @@ var NDSSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
52656
52656
  var value = _a.value,
52657
52657
  _onChange = _a.onChange,
52658
52658
  defaultValue = _a.defaultValue,
52659
- labelText = _a.labelText,
52660
- requirementText = _a.requirementText,
52661
- helpText = _a.helpText,
52662
52659
  disabled = _a.disabled,
52663
52660
  errorMessage = _a.errorMessage,
52664
52661
  errorList = _a.errorList,
@@ -52686,7 +52683,7 @@ var NDSSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
52686
52683
  _a$closeMenuOnSelect = _a.closeMenuOnSelect,
52687
52684
  closeMenuOnSelect = _a$closeMenuOnSelect === void 0 ? true : _a$closeMenuOnSelect,
52688
52685
  noOptionsMessage = _a.noOptionsMessage,
52689
- props = __rest(_a, ["value", "onChange", "defaultValue", "labelText", "requirementText", "helpText", "disabled", "errorMessage", "errorList", "id", "initialIsOpen", "multiselect", "placeholder", "components", "options", "styles", "windowThreshold", "autocomplete", "maxHeight", "required", "menuPosition", "menuPlacement", "classNamePrefix", "closeMenuOnSelect", "noOptionsMessage"]);
52686
+ props = __rest(_a, ["value", "onChange", "defaultValue", "disabled", "errorMessage", "errorList", "id", "initialIsOpen", "multiselect", "placeholder", "components", "options", "styles", "windowThreshold", "autocomplete", "maxHeight", "required", "menuPosition", "menuPlacement", "classNamePrefix", "closeMenuOnSelect", "noOptionsMessage"]);
52690
52687
  var _useTranslation = useTranslation(),
52691
52688
  t = _useTranslation.t;
52692
52689
  var variant = useComponentVariant();
@@ -52698,6 +52695,16 @@ var NDSSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
52698
52695
  return calcOptionsLength(options);
52699
52696
  }, [options]);
52700
52697
  var isWindowed = optionsLength >= windowThreshold;
52698
+ var labelText = props.labelText,
52699
+ requirementText = props.requirementText,
52700
+ helpText = props.helpText,
52701
+ hint = props.hint;
52702
+ var fieldLabelProps = {
52703
+ labelText: labelText,
52704
+ requirementText: requirementText,
52705
+ helpText: helpText,
52706
+ hint: hint
52707
+ };
52701
52708
  noOptionsMessage || (noOptionsMessage = function noOptionsMessage() {
52702
52709
  return t("no options");
52703
52710
  });
@@ -52712,11 +52719,7 @@ var NDSSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
52712
52719
  maxHeight: maxHeight,
52713
52720
  windowed: options.length > windowThreshold
52714
52721
  });
52715
- return /*#__PURE__*/React__default.createElement(Field, Object.assign({}, styledProps), /*#__PURE__*/React__default.createElement(MaybeFieldLabel, {
52716
- labelText: labelText,
52717
- requirementText: requirementText,
52718
- helpText: helpText
52719
- }, /*#__PURE__*/React__default.createElement(StateManagedSelect$1, Object.assign({
52722
+ return /*#__PURE__*/React__default.createElement(Field, Object.assign({}, styledProps), /*#__PURE__*/React__default.createElement(MaybeFieldLabel, Object.assign({}, fieldLabelProps), /*#__PURE__*/React__default.createElement(StateManagedSelect$1, Object.assign({
52720
52723
  ref: ref,
52721
52724
  isSearchable: autocomplete,
52722
52725
  isDisabled: disabled,
@@ -52935,7 +52938,7 @@ var StyledTr = styled.tr.withConfig({
52935
52938
  borderCollapse: "collapse"
52936
52939
  });
52937
52940
  });
52938
- var renderRows$1 = function renderRows(rows, columns, keyField, noRowsContent, rowHovers, compact, onRowMouseLeave, onRowMouseEnter, rowBorder) {
52941
+ var renderRows$1 = function renderRows(rows, columns, keyField, rowHovers, noRowsContent, compact, onRowMouseLeave, onRowMouseEnter, rowBorder) {
52939
52942
  return rows.length > 0 ? rows.map(function (row, rowIndex) {
52940
52943
  var rowKey = row[keyField] !== undefined ? row[keyField] : rowIndex;
52941
52944
  return /*#__PURE__*/React__default.createElement(TableBodyRow, {
@@ -53037,7 +53040,7 @@ var TableBody = function TableBody(_ref6) {
53037
53040
  rowBorder = _ref6.rowBorder;
53038
53041
  return /*#__PURE__*/React__default.createElement("tbody", {
53039
53042
  "data-testid": "table-body"
53040
- }, !loading ? renderRows$1(rows, columns, keyField, noRowsContent, rowHovers, compact, onRowMouseLeave, onRowMouseEnter, rowBorder) : (/*#__PURE__*/React__default.createElement(LoadingContent, {
53043
+ }, !loading ? renderRows$1(rows, columns, keyField, rowHovers, noRowsContent, compact, onRowMouseLeave, onRowMouseEnter, rowBorder) : (/*#__PURE__*/React__default.createElement(LoadingContent, {
53041
53044
  colSpan: columns.length
53042
53045
  })));
53043
53046
  };
@@ -4,6 +4,7 @@ import { PropsValue } from "react-select";
4
4
  import type { GroupBase, Props, StylesConfig } from "react-select";
5
5
  import { StyledProps } from "../StyledProps";
6
6
  import { CustomOnChangeValue } from "./lib";
7
+ import { FieldLabelProps } from "../FieldLabel/FieldLabel.type";
7
8
  export type NDSOptionValue = string | number | boolean | null;
8
9
  export interface NDSOption {
9
10
  label: ReactNode;
@@ -11,9 +12,10 @@ export interface NDSOption {
11
12
  }
12
13
  interface CustomProps<Option extends NDSOption, IsMulti extends boolean, Group extends GroupBase<Option>> extends StyledProps {
13
14
  autocomplete?: Props<Option, IsMulti, Group>["isSearchable"];
14
- labelText?: string;
15
- requirementText?: string;
16
- helpText?: ReactNode;
15
+ labelText?: FieldLabelProps["labelText"];
16
+ requirementText?: FieldLabelProps["requirementText"];
17
+ hint?: FieldLabelProps["hint"];
18
+ helpText?: FieldLabelProps["helpText"];
17
19
  disabled?: Props<Option, IsMulti, Group>["isDisabled"];
18
20
  errorMessage?: string;
19
21
  errorList?: string[];
@@ -26,7 +26,7 @@ import { SelectOption } from "./SelectOption";
26
26
  import MenuList from "./MenuList";
27
27
  import { calcOptionsLength, checkOptionsAreValid, extractValue, getReactSelectValue } from "./lib";
28
28
  const NDSSelect = forwardRef((_a, ref) => {
29
- var { value, onChange, defaultValue, labelText, requirementText, helpText, disabled, errorMessage, errorList, id, initialIsOpen, multiselect, placeholder, components, options, styles, windowThreshold = 300, autocomplete = true, maxHeight = "248px", required = false, menuPosition = "absolute", menuPlacement = "bottom", classNamePrefix = "ndsSelect", closeMenuOnSelect = true, noOptionsMessage } = _a, props = __rest(_a, ["value", "onChange", "defaultValue", "labelText", "requirementText", "helpText", "disabled", "errorMessage", "errorList", "id", "initialIsOpen", "multiselect", "placeholder", "components", "options", "styles", "windowThreshold", "autocomplete", "maxHeight", "required", "menuPosition", "menuPlacement", "classNamePrefix", "closeMenuOnSelect", "noOptionsMessage"]);
29
+ var { value, onChange, defaultValue, disabled, errorMessage, errorList, id, initialIsOpen, multiselect, placeholder, components, options, styles, windowThreshold = 300, autocomplete = true, maxHeight = "248px", required = false, menuPosition = "absolute", menuPlacement = "bottom", classNamePrefix = "ndsSelect", closeMenuOnSelect = true, noOptionsMessage } = _a, props = __rest(_a, ["value", "onChange", "defaultValue", "disabled", "errorMessage", "errorList", "id", "initialIsOpen", "multiselect", "placeholder", "components", "options", "styles", "windowThreshold", "autocomplete", "maxHeight", "required", "menuPosition", "menuPlacement", "classNamePrefix", "closeMenuOnSelect", "noOptionsMessage"]);
30
30
  const { t } = useTranslation();
31
31
  const variant = useComponentVariant();
32
32
  const theme = useTheme();
@@ -35,6 +35,8 @@ const NDSSelect = forwardRef((_a, ref) => {
35
35
  const optionsRef = React.useRef(options);
36
36
  const optionsLength = React.useMemo(() => calcOptionsLength(options), [options]);
37
37
  const isWindowed = optionsLength >= windowThreshold;
38
+ const { labelText, requirementText, helpText, hint } = props;
39
+ const fieldLabelProps = { labelText, requirementText, helpText, hint };
38
40
  noOptionsMessage || (noOptionsMessage = () => t("no options"));
39
41
  React.useEffect(() => {
40
42
  checkOptionsAreValid(options);
@@ -48,7 +50,7 @@ const NDSSelect = forwardRef((_a, ref) => {
48
50
  windowed: options.length > windowThreshold,
49
51
  });
50
52
  return (React.createElement(Field, Object.assign({}, styledProps),
51
- React.createElement(MaybeFieldLabel, { labelText: labelText, requirementText: requirementText, helpText: helpText },
53
+ React.createElement(MaybeFieldLabel, Object.assign({}, fieldLabelProps),
52
54
  React.createElement(ReactSelect, Object.assign({ ref: ref, isSearchable: autocomplete, isDisabled: disabled, defaultMenuIsOpen: initialIsOpen, isMulti: multiselect, defaultValue: getReactSelectValue(options, defaultValue), value: getReactSelectValue(options, value), options: options, onChange: (newValue) => {
53
55
  if (!onChange)
54
56
  return;
@@ -48,7 +48,7 @@ export declare const Required: {
48
48
  };
49
49
  };
50
50
  export declare const WithAClearButton: () => React.JSX.Element;
51
- export declare const WithHelpText: {
51
+ export declare const WithAllFieldLabelProps: {
52
52
  (): React.JSX.Element;
53
53
  story: {
54
54
  name: string;
@@ -106,9 +106,9 @@ Required.story = {
106
106
  name: "set to required",
107
107
  };
108
108
  export const WithAClearButton = () => (React.createElement(Select, { isClearable: true, placeholder: "Please select inventory status", options: options, labelText: "Inventory status", onChange: action("selection changed"), onBlur: action("blurred"), onInputChange: action("typed input value changed") }));
109
- export const WithHelpText = () => (React.createElement(Select, { placeholder: "Please select inventory status", options: options, labelText: "Inventory status", helpText: "Additional information about input", onChange: action("selection changed"), onBlur: action("blurred"), onInputChange: action("typed input value changed") }));
110
- WithHelpText.story = {
111
- name: "with helpText",
109
+ export const WithAllFieldLabelProps = () => (React.createElement(Select, { placeholder: "Please select inventory status", options: options, labelText: "Inventory status", helpText: "Additional information about input", hint: "This is a hint for the input field", requirementText: "(Required)", onChange: action("selection changed"), onBlur: action("blurred"), onInputChange: action("typed input value changed") }));
110
+ WithAllFieldLabelProps.story = {
111
+ name: "with all field label props",
112
112
  };
113
113
  export const WithCustomId = () => (React.createElement(Select, { id: "my-custom-id", placeholder: "Please select inventory status", options: options, labelText: "Inventory status", helpText: "Additional information about input", onChange: action("selection changed"), onBlur: action("blurred"), onInputChange: action("typed input value changed") }));
114
114
  WithCustomId.story = {
@@ -1,9 +1,9 @@
1
- import React from "react";
1
+ import React, { type ReactNode } from "react";
2
2
  import { RowType, Columns, RowBorder } from "./Table.types";
3
3
  export type BaseTableProps<ColumnMetaData> = {
4
4
  columns: Columns<ColumnMetaData>;
5
5
  rows: RowType[];
6
- noRowsContent?: string;
6
+ noRowsContent?: ReactNode;
7
7
  keyField?: string;
8
8
  id?: string;
9
9
  loading?: boolean;
@@ -72,7 +72,7 @@ declare class StatefulTable<ColumnMetaData> extends Component<StatefulTableProps
72
72
  getControlProps: () => {
73
73
  rows: any;
74
74
  columns: any[];
75
- noRowsContent?: string;
75
+ noRowsContent?: React.ReactNode;
76
76
  keyField?: string;
77
77
  id?: string;
78
78
  loading?: boolean;
@@ -1,16 +1,16 @@
1
- import React from "react";
1
+ import React, { type ReactNode } from "react";
2
2
  import { RowBorder } from "./Table.types";
3
- type TableBodyProps = {
3
+ interface TableBodyProps {
4
4
  rows: any[];
5
5
  columns: any[];
6
6
  keyField?: string;
7
- noRowsContent?: any;
7
+ noRowsContent: ReactNode;
8
8
  loading?: boolean;
9
9
  rowHovers?: boolean;
10
10
  compact?: boolean;
11
- onRowMouseLeave?: any;
12
- onRowMouseEnter?: any;
11
+ onRowMouseLeave?: (...args: any[]) => any;
12
+ onRowMouseEnter?: (...args: any[]) => any;
13
13
  rowBorder?: RowBorder;
14
- };
14
+ }
15
15
  declare const TableBody: ({ rows, columns, keyField, noRowsContent, loading, rowHovers, compact, onRowMouseLeave, onRowMouseEnter, rowBorder, }: TableBodyProps) => React.JSX.Element;
16
16
  export default TableBody;
@@ -15,7 +15,7 @@ const StyledTr = styled.tr(({ rowHovers, rowBorder, theme }) => (Object.assign({
15
15
  borderBottomColor: theme.colors.lightGrey,
16
16
  borderCollapse: "collapse",
17
17
  }))));
18
- const renderRows = (rows, columns, keyField, noRowsContent, rowHovers, compact, onRowMouseLeave, onRowMouseEnter, rowBorder) => rows.length > 0 ? (rows.map((row, rowIndex) => {
18
+ const renderRows = (rows, columns, keyField, rowHovers, noRowsContent, compact, onRowMouseLeave, onRowMouseEnter, rowBorder) => rows.length > 0 ? (rows.map((row, rowIndex) => {
19
19
  const rowKey = row[keyField] !== undefined ? row[keyField] : rowIndex;
20
20
  return (React.createElement(TableBodyRow, { key: rowKey, row: row, columns: columns, keyField: keyField, rowHovers: rowHovers, compact: compact, rowClassName: row.rowClassName, onMouseEnter: (e) => onRowMouseEnter({ row, e }), onMouseLeave: (e) => onRowMouseLeave({ row, e }), rowBorder: rowBorder }));
21
21
  })) : (React.createElement(TableMessageContainer, { colSpan: columns.length }, noRowsContent));
@@ -33,5 +33,5 @@ const TableMessageContainer = ({ colSpan, children }) => (React.createElement("t
33
33
  React.createElement("td", { colSpan: colSpan },
34
34
  React.createElement(StyledMessageContainer, { className: "nds-table__no-rows-content" }, children))));
35
35
  const LoadingContent = ({ colSpan }) => (React.createElement(TableMessageContainer, { colSpan: colSpan }, "Loading..."));
36
- const TableBody = ({ rows, columns, keyField = "id", noRowsContent = "No records have been created for this table.", loading, rowHovers, compact, onRowMouseLeave, onRowMouseEnter, rowBorder, }) => (React.createElement("tbody", { "data-testid": "table-body" }, !loading ? (renderRows(rows, columns, keyField, noRowsContent, rowHovers, compact, onRowMouseLeave, onRowMouseEnter, rowBorder)) : (React.createElement(LoadingContent, { colSpan: columns.length }))));
36
+ const TableBody = ({ rows, columns, keyField = "id", noRowsContent = "No records have been created for this table.", loading, rowHovers, compact, onRowMouseLeave, onRowMouseEnter, rowBorder, }) => (React.createElement("tbody", { "data-testid": "table-body" }, !loading ? (renderRows(rows, columns, keyField, rowHovers, noRowsContent, compact, onRowMouseLeave, onRowMouseEnter, rowBorder)) : (React.createElement(LoadingContent, { colSpan: columns.length }))));
37
37
  export default TableBody;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nulogy/components",
3
- "version": "15.1.1",
3
+ "version": "15.1.3",
4
4
  "description": "Component library for the Nulogy Design System - http://nulogy.design",
5
5
  "private": false,
6
6
  "publishConfig": {