@conduction/components 2.1.22 → 2.1.23

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/README.md CHANGED
@@ -4,6 +4,7 @@
4
4
 
5
5
  - **Version 2.1 (breaking changes from 2.0.x)**
6
6
 
7
+ - 2.1.23: Added optional error messages to CreateKeyValue and unused classname removed warning.
7
8
  - 2.1.22: Added optional error messages to textarea, select and input fields.
8
9
  - 2.1.21: Added optional copy button and refactored delete button in CreateKeyValue.
9
10
  - 2.1.20: Updated react.fc code and github actions added.
@@ -13,10 +13,11 @@ interface CreateKeyValueProps {
13
13
  canCopy: boolean;
14
14
  onCopied?: () => any;
15
15
  };
16
+ hideErrorMessage?: boolean;
16
17
  }
17
18
  export interface IKeyValue {
18
19
  key: string;
19
20
  value: string;
20
21
  }
21
- export declare const CreateKeyValue: ({ name, errors, control, validation, defaultValue, disabled, copyValue, }: CreateKeyValueProps & IReactHookFormProps) => JSX.Element;
22
+ export declare const CreateKeyValue: ({ name, errors, control, validation, defaultValue, disabled, copyValue, hideErrorMessage, }: CreateKeyValueProps & IReactHookFormProps) => JSX.Element;
22
23
  export {};
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
3
  import * as styles from "./CreateKeyValue.module.css";
4
4
  import { Controller } from "react-hook-form";
@@ -8,9 +8,10 @@ import { ToolTip } from "../../toolTip/ToolTip";
8
8
  import clsx from "clsx";
9
9
  import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
10
10
  import { faCopy, faTrash } from "@fortawesome/free-solid-svg-icons";
11
- export const CreateKeyValue = ({ name, errors, control, validation, defaultValue, disabled, copyValue, }) => {
11
+ import { ErrorMessage } from "../errorMessage/ErrorMessage";
12
+ export const CreateKeyValue = ({ name, errors, control, validation, defaultValue, disabled, copyValue, hideErrorMessage, }) => {
12
13
  return (_jsx(Controller, { ...{ control, name, errors }, rules: validation, render: ({ field: { onChange } }) => {
13
- return _jsx(KeyValueComponent, { handleChange: onChange, ...{ defaultValue, errors, disabled, copyValue } });
14
+ return (_jsxs(_Fragment, { children: [_jsx(KeyValueComponent, { handleChange: onChange, ...{ defaultValue, errors, disabled, copyValue } }), errors[name] && !hideErrorMessage && _jsx(ErrorMessage, { message: errors[name].message })] }));
14
15
  } }));
15
16
  };
16
17
  const KeyValueComponent = ({ defaultValue, handleChange, disabled, copyValue, }) => {
@@ -37,5 +38,5 @@ const KeyValueComponent = ({ defaultValue, handleChange, disabled, copyValue, })
37
38
  React.useEffect(() => {
38
39
  handleChange(keyValues);
39
40
  }, [keyValues]);
40
- return (_jsxs("div", { className: styles.keyValue, children: [keyValues && (_jsxs(Table, { className: styles.table, children: [_jsx(TableHead, { children: _jsxs(TableRow, { children: [_jsx(TableHeader, { children: "Key" }), _jsx(TableHeader, { children: "Value" }), _jsx(TableHeader, {})] }) }), _jsx(TableBody, { children: keyValues.map((keyValue, idx) => (_jsxs(TableRow, { children: [_jsx(TableCell, { children: keyValue.key }), _jsx(TableCell, { children: keyValue.value }), _jsx(TableCell, { children: _jsxs("div", { className: styles.buttonsContainer, children: [copyValue && (_jsx(ToolTip, { tooltip: "Copy value", children: _jsx(Button, { ...{ disabled }, className: styles.copyButton, onClick: () => handleCopyToClipboard(keyValue.value, idx), variant: currentCopyIdx === idx ? "secondary-action" : "primary-action", children: _jsx(FontAwesomeIcon, { icon: faCopy }) }) })), _jsx(ToolTip, { tooltip: "Delete value", children: _jsx(Button, { ...{ disabled }, onClick: () => setKeyValues(keyValues.filter((_keyValue) => _keyValue !== keyValue)), className: clsx(styles.deleteButton), children: _jsx(FontAwesomeIcon, { icon: faTrash }) }) })] }) })] }, `${keyValue.key}${keyValue.value}${idx}`))) })] })), _jsxs("div", { className: styles.form, children: [_jsx("input", { type: "text", placeholder: "Key", value: currentKey, ref: currentKeyRef, className: "denhaag-textfield__input", onChange: (e) => setCurrentKey(e.target.value), ...{ disabled } }), _jsx("input", { type: "text", placeholder: "Value", value: currentValue, ref: currentValueRef, className: "denhaag-textfield__input", onChange: (e) => setCurrentValue(e.target.value), ...{ disabled } }), _jsx(Button, { onClick: handleCreate, disabled: !currentKey || !currentValue || disabled, children: "Add" })] })] }));
41
+ return (_jsxs("div", { className: styles.keyValue, children: [keyValues && (_jsxs(Table, { className: styles.table, children: [_jsx(TableHead, { children: _jsxs(TableRow, { children: [_jsx(TableHeader, { children: "Key" }), _jsx(TableHeader, { children: "Value" }), _jsx(TableHeader, {})] }) }), _jsx(TableBody, { children: keyValues.map((keyValue, idx) => (_jsxs(TableRow, { children: [_jsx(TableCell, { children: keyValue.key }), _jsx(TableCell, { children: keyValue.value }), _jsx(TableCell, { children: _jsxs("div", { className: styles.buttonsContainer, children: [copyValue && (_jsx(ToolTip, { tooltip: "Copy value", children: _jsx(Button, { ...{ disabled }, onClick: () => handleCopyToClipboard(keyValue.value, idx), variant: currentCopyIdx === idx ? "secondary-action" : "primary-action", children: _jsx(FontAwesomeIcon, { icon: faCopy }) }) })), _jsx(ToolTip, { tooltip: "Delete value", children: _jsx(Button, { ...{ disabled }, onClick: () => setKeyValues(keyValues.filter((_keyValue) => _keyValue !== keyValue)), className: clsx(styles.deleteButton), children: _jsx(FontAwesomeIcon, { icon: faTrash }) }) })] }) })] }, `${keyValue.key}${keyValue.value}${idx}`))) })] })), _jsxs("div", { className: styles.form, children: [_jsx("input", { type: "text", placeholder: "Key", value: currentKey, ref: currentKeyRef, className: "denhaag-textfield__input", onChange: (e) => setCurrentKey(e.target.value), ...{ disabled } }), _jsx("input", { type: "text", placeholder: "Value", value: currentValue, ref: currentValueRef, className: "denhaag-textfield__input", onChange: (e) => setCurrentValue(e.target.value), ...{ disabled } }), _jsx(Button, { onClick: handleCreate, disabled: !currentKey || !currentValue || disabled, children: "Add" })] })] }));
41
42
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@conduction/components",
3
- "version": "2.1.22",
3
+ "version": "2.1.23",
4
4
  "description": "React (Gatsby) components used within the Conduction Skeleton Application (and its implementations)",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -8,6 +8,7 @@ import { ToolTip } from "../../toolTip/ToolTip";
8
8
  import clsx from "clsx";
9
9
  import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
10
10
  import { faCopy, faTrash } from "@fortawesome/free-solid-svg-icons";
11
+ import { ErrorMessage } from "../errorMessage/ErrorMessage";
11
12
 
12
13
  /**
13
14
  * Export KeyValue input component (wrapped in FormFieldGroup)
@@ -21,6 +22,7 @@ interface CreateKeyValueProps {
21
22
  canCopy: boolean;
22
23
  onCopied?: () => any;
23
24
  };
25
+ hideErrorMessage?: boolean;
24
26
  }
25
27
 
26
28
  export interface IKeyValue {
@@ -36,13 +38,19 @@ export const CreateKeyValue = ({
36
38
  defaultValue,
37
39
  disabled,
38
40
  copyValue,
41
+ hideErrorMessage,
39
42
  }: CreateKeyValueProps & IReactHookFormProps): JSX.Element => {
40
43
  return (
41
44
  <Controller
42
45
  {...{ control, name, errors }}
43
46
  rules={validation}
44
47
  render={({ field: { onChange } }) => {
45
- return <KeyValueComponent handleChange={onChange} {...{ defaultValue, errors, disabled, copyValue }} />;
48
+ return (
49
+ <>
50
+ <KeyValueComponent handleChange={onChange} {...{ defaultValue, errors, disabled, copyValue }} />
51
+ {errors[name] && !hideErrorMessage && <ErrorMessage message={errors[name].message} />}
52
+ </>
53
+ );
46
54
  }}
47
55
  />
48
56
  );
@@ -120,7 +128,6 @@ const KeyValueComponent = ({
120
128
  <ToolTip tooltip="Copy value">
121
129
  <Button
122
130
  {...{ disabled }}
123
- className={styles.copyButton}
124
131
  onClick={() => handleCopyToClipboard(keyValue.value, idx)}
125
132
  variant={currentCopyIdx === idx ? "secondary-action" : "primary-action"}
126
133
  >