@trackunit/react-form-components 0.0.20 → 0.0.22

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/index.cjs CHANGED
@@ -196,22 +196,6 @@ const InputContainer$1 = tailwindStyledComponents.tw.label `
196
196
  ${({ $fieldSize }) => ($fieldSize === "small" ? tailwindStyledComponents.tws `tu-input--small` : null)}
197
197
  `;
198
198
 
199
- /**
200
- * The Label component is used for labels for input fields.
201
- * This component is **not used directly**, but is part of the FormGroup and Field components.
202
- *
203
- * @param {LabelProps} props - The props for the Label component
204
- * @returns {JSX.Element} Label component
205
- */
206
- const Label$1 = ({ id, htmlFor, children, className, dataTestId, disabled, isInvalid, }) => {
207
- return (jsxRuntime.jsx(Root$2, Object.assign({ id: id || "", htmlFor: htmlFor || "", className: className, "data-testid": dataTestId, "$disabled": disabled, "$isInvalid": isInvalid }, { children: children })));
208
- };
209
- const Root$2 = tailwindStyledComponents.tw.label `
210
- tu-label
211
- ${({ $disabled }) => $disabled && tailwindStyledComponents.tws `tu-label--disabled`}
212
- ${({ $isInvalid }) => $isInvalid && tailwindStyledComponents.tws `tu-label--invalid`}
213
- `;
214
-
215
199
  /**
216
200
  * The CheckIcon component is used by the checkbox to display the checked state.
217
201
  *
@@ -245,18 +229,22 @@ const IndeterminateIcon = ({ className }) => (jsxRuntime.jsx("svg", Object.assig
245
229
  * @returns {JSX.Element} Checkbox component
246
230
  */
247
231
  const Checkbox = React__namespace.forwardRef((_a, ref) => {
248
- var { className, dataTestId, onChange, checked = false, disabled = false, isInvalid = false, readOnly, indeterminate = false, children, label, tabIndex = 0 } = _a, rest = __rest(_a, ["className", "dataTestId", "onChange", "checked", "disabled", "isInvalid", "readOnly", "indeterminate", "children", "label", "tabIndex"]);
232
+ var { className, dataTestId, onChange, checked = false, disabled = false, isInvalid = false, readOnly, indeterminate = false, suffix, label, tabIndex = 0 } = _a, rest = __rest(_a, ["className", "dataTestId", "onChange", "checked", "disabled", "isInvalid", "readOnly", "indeterminate", "suffix", "label", "tabIndex"]);
249
233
  const icon = indeterminate ? jsxRuntime.jsx(StyledIndeterminateIcon, {}) : checked && jsxRuntime.jsx(StyledCheckIcon, {});
250
234
  const internalRef = React__namespace.useRef(null);
251
235
  const isReadonly = disabled || readOnly;
252
236
  const onKeyPress = e => {
253
- var _a;
237
+ var _a, _b;
238
+ e.preventDefault();
254
239
  if ("Space" === e.code) {
255
240
  (_a = internalRef === null || internalRef === void 0 ? void 0 : internalRef.current) === null || _a === void 0 ? void 0 : _a.click();
256
241
  }
242
+ if ("Enter" === e.code) {
243
+ (_b = internalRef === null || internalRef === void 0 ? void 0 : internalRef.current) === null || _b === void 0 ? void 0 : _b.click();
244
+ }
257
245
  };
258
246
  const uuid = rest.id || dataTestId;
259
- return (jsxRuntime.jsxs(CheckboxContainer, Object.assign({ "data-testid": dataTestId && `${dataTestId}Container`, htmlFor: uuid, className: className }, { children: [jsxRuntime.jsx(HiddenInput$1, Object.assign({ type: "checkbox", checked: !indeterminate && checked, onChange: onChange, disabled: disabled, "data-testid": dataTestId, readOnly: readOnly, "aria-checked": !indeterminate && checked, role: "checkbox", id: uuid }, rest, { ref: ref })), jsxRuntime.jsx(CheckboxWrapper, Object.assign({ id: uuid, "$disabled": isReadonly, "$checked": checked, "$indeterminate": indeterminate, "$isInvalid": isReadonly ? false : isInvalid, tabIndex: isReadonly ? -1 : tabIndex, onKeyPress: onKeyPress }, { children: icon })), label && (jsxRuntime.jsx(Label$1, Object.assign({ className: tailwindStyledComponents.tws `cursor-pointer`, htmlFor: uuid, disabled: isReadonly, isInvalid: isReadonly ? false : isInvalid, dataTestId: dataTestId && `${dataTestId}-Label` }, { children: label }))), children] })));
247
+ return (jsxRuntime.jsxs(CheckboxContainer, Object.assign({ "data-testid": dataTestId && `${dataTestId}Container`, htmlFor: uuid, className: className, ref: internalRef, onKeyPress: onKeyPress }, { children: [jsxRuntime.jsx(HiddenInput$1, Object.assign({ type: "checkbox", checked: !indeterminate && checked, onChange: onChange, disabled: disabled, "data-testid": dataTestId, readOnly: readOnly, "aria-checked": !indeterminate && checked, role: "checkbox", id: uuid }, rest, { ref: ref })), jsxRuntime.jsx(CheckboxWrapper, Object.assign({ id: uuid, "$disabled": isReadonly, "$checked": checked, "$indeterminate": indeterminate, "$isInvalid": isReadonly ? false : isInvalid, tabIndex: isReadonly ? -1 : tabIndex }, { children: icon })), label && (jsxRuntime.jsx(Label$2, Object.assign({ className: tailwindStyledComponents.tws `cursor-pointer`, "$disabled": isReadonly, "$isInvalid": isReadonly ? false : isInvalid }, { children: label }))), suffix] })));
260
248
  });
261
249
  const StyledCheckIcon = tailwindStyledComponents.twx(CheckIcon) `tu-checkbox--icon`;
262
250
  const StyledIndeterminateIcon = tailwindStyledComponents.twx(IndeterminateIcon) `tu-checkbox--icon`;
@@ -276,6 +264,11 @@ const CheckboxWrapper = tailwindStyledComponents.tw.span `
276
264
  }}
277
265
 
278
266
  ${({ $isInvalid }) => $isInvalid && tailwindStyledComponents.tws `tu-checkbox--invalid`}
267
+ `;
268
+ const Label$2 = tailwindStyledComponents.tw.span `
269
+ tu-label
270
+ ${({ $disabled }) => $disabled && tailwindStyledComponents.tws `tu-label--disabled`}
271
+ ${({ $isInvalid }) => $isInvalid && tailwindStyledComponents.tws `tu-label--invalid`}
279
272
  `;
280
273
 
281
274
  /**
@@ -291,6 +284,22 @@ const DateInput = React.forwardRef((_a, ref) => {
291
284
  return (jsxRuntime.jsx(BaseInput, Object.assign({ type: "date", value: formatDateToInputString(value), defaultValue: formatDateToInputString(defaultValue), min: formatDateToInputString(min), max: formatDateToInputString(max), ref: ref, suffix: showIcon && jsxRuntime.jsx(reactComponents.Icon, { dataTestId: "calendar", name: "CalendarIcon", size: "medium", type: "solid" }) }, rest)));
292
285
  });
293
286
 
287
+ /**
288
+ * The Label component is used for labels for input fields.
289
+ * This component is **not used directly**, but is part of the FormGroup and Field components.
290
+ *
291
+ * @param {LabelProps} props - The props for the Label component
292
+ * @returns {JSX.Element} Label component
293
+ */
294
+ const Label$1 = ({ id, htmlFor, children, className, dataTestId, disabled, isInvalid, }) => {
295
+ return (jsxRuntime.jsx(Root$2, Object.assign({ id: id || "", htmlFor: htmlFor || "", className: className, "data-testid": dataTestId, "$disabled": disabled, "$isInvalid": isInvalid }, { children: children })));
296
+ };
297
+ const Root$2 = tailwindStyledComponents.tw.label `
298
+ tu-label
299
+ ${({ $disabled }) => $disabled && tailwindStyledComponents.tws `tu-label--disabled`}
300
+ ${({ $isInvalid }) => $isInvalid && tailwindStyledComponents.tws `tu-label--invalid`}
301
+ `;
302
+
294
303
  /**
295
304
  * The FormGroup component should be used to wrap any Input element that needs a label.
296
305
  * Besides a label the component supplies an optional Tip, HelpText and HelpAddon support.
package/index.js CHANGED
@@ -166,22 +166,6 @@ const InputContainer$1 = tw.label `
166
166
  ${({ $fieldSize }) => ($fieldSize === "small" ? tws `tu-input--small` : null)}
167
167
  `;
168
168
 
169
- /**
170
- * The Label component is used for labels for input fields.
171
- * This component is **not used directly**, but is part of the FormGroup and Field components.
172
- *
173
- * @param {LabelProps} props - The props for the Label component
174
- * @returns {JSX.Element} Label component
175
- */
176
- const Label$1 = ({ id, htmlFor, children, className, dataTestId, disabled, isInvalid, }) => {
177
- return (jsx(Root$2, Object.assign({ id: id || "", htmlFor: htmlFor || "", className: className, "data-testid": dataTestId, "$disabled": disabled, "$isInvalid": isInvalid }, { children: children })));
178
- };
179
- const Root$2 = tw.label `
180
- tu-label
181
- ${({ $disabled }) => $disabled && tws `tu-label--disabled`}
182
- ${({ $isInvalid }) => $isInvalid && tws `tu-label--invalid`}
183
- `;
184
-
185
169
  /**
186
170
  * The CheckIcon component is used by the checkbox to display the checked state.
187
171
  *
@@ -215,18 +199,22 @@ const IndeterminateIcon = ({ className }) => (jsx("svg", Object.assign({ xmlns:
215
199
  * @returns {JSX.Element} Checkbox component
216
200
  */
217
201
  const Checkbox = React.forwardRef((_a, ref) => {
218
- var { className, dataTestId, onChange, checked = false, disabled = false, isInvalid = false, readOnly, indeterminate = false, children, label, tabIndex = 0 } = _a, rest = __rest(_a, ["className", "dataTestId", "onChange", "checked", "disabled", "isInvalid", "readOnly", "indeterminate", "children", "label", "tabIndex"]);
202
+ var { className, dataTestId, onChange, checked = false, disabled = false, isInvalid = false, readOnly, indeterminate = false, suffix, label, tabIndex = 0 } = _a, rest = __rest(_a, ["className", "dataTestId", "onChange", "checked", "disabled", "isInvalid", "readOnly", "indeterminate", "suffix", "label", "tabIndex"]);
219
203
  const icon = indeterminate ? jsx(StyledIndeterminateIcon, {}) : checked && jsx(StyledCheckIcon, {});
220
204
  const internalRef = React.useRef(null);
221
205
  const isReadonly = disabled || readOnly;
222
206
  const onKeyPress = e => {
223
- var _a;
207
+ var _a, _b;
208
+ e.preventDefault();
224
209
  if ("Space" === e.code) {
225
210
  (_a = internalRef === null || internalRef === void 0 ? void 0 : internalRef.current) === null || _a === void 0 ? void 0 : _a.click();
226
211
  }
212
+ if ("Enter" === e.code) {
213
+ (_b = internalRef === null || internalRef === void 0 ? void 0 : internalRef.current) === null || _b === void 0 ? void 0 : _b.click();
214
+ }
227
215
  };
228
216
  const uuid = rest.id || dataTestId;
229
- return (jsxs(CheckboxContainer, Object.assign({ "data-testid": dataTestId && `${dataTestId}Container`, htmlFor: uuid, className: className }, { children: [jsx(HiddenInput$1, Object.assign({ type: "checkbox", checked: !indeterminate && checked, onChange: onChange, disabled: disabled, "data-testid": dataTestId, readOnly: readOnly, "aria-checked": !indeterminate && checked, role: "checkbox", id: uuid }, rest, { ref: ref })), jsx(CheckboxWrapper, Object.assign({ id: uuid, "$disabled": isReadonly, "$checked": checked, "$indeterminate": indeterminate, "$isInvalid": isReadonly ? false : isInvalid, tabIndex: isReadonly ? -1 : tabIndex, onKeyPress: onKeyPress }, { children: icon })), label && (jsx(Label$1, Object.assign({ className: tws `cursor-pointer`, htmlFor: uuid, disabled: isReadonly, isInvalid: isReadonly ? false : isInvalid, dataTestId: dataTestId && `${dataTestId}-Label` }, { children: label }))), children] })));
217
+ return (jsxs(CheckboxContainer, Object.assign({ "data-testid": dataTestId && `${dataTestId}Container`, htmlFor: uuid, className: className, ref: internalRef, onKeyPress: onKeyPress }, { children: [jsx(HiddenInput$1, Object.assign({ type: "checkbox", checked: !indeterminate && checked, onChange: onChange, disabled: disabled, "data-testid": dataTestId, readOnly: readOnly, "aria-checked": !indeterminate && checked, role: "checkbox", id: uuid }, rest, { ref: ref })), jsx(CheckboxWrapper, Object.assign({ id: uuid, "$disabled": isReadonly, "$checked": checked, "$indeterminate": indeterminate, "$isInvalid": isReadonly ? false : isInvalid, tabIndex: isReadonly ? -1 : tabIndex }, { children: icon })), label && (jsx(Label$2, Object.assign({ className: tws `cursor-pointer`, "$disabled": isReadonly, "$isInvalid": isReadonly ? false : isInvalid }, { children: label }))), suffix] })));
230
218
  });
231
219
  const StyledCheckIcon = twx(CheckIcon) `tu-checkbox--icon`;
232
220
  const StyledIndeterminateIcon = twx(IndeterminateIcon) `tu-checkbox--icon`;
@@ -246,6 +234,11 @@ const CheckboxWrapper = tw.span `
246
234
  }}
247
235
 
248
236
  ${({ $isInvalid }) => $isInvalid && tws `tu-checkbox--invalid`}
237
+ `;
238
+ const Label$2 = tw.span `
239
+ tu-label
240
+ ${({ $disabled }) => $disabled && tws `tu-label--disabled`}
241
+ ${({ $isInvalid }) => $isInvalid && tws `tu-label--invalid`}
249
242
  `;
250
243
 
251
244
  /**
@@ -261,6 +254,22 @@ const DateInput = forwardRef((_a, ref) => {
261
254
  return (jsx(BaseInput, Object.assign({ type: "date", value: formatDateToInputString(value), defaultValue: formatDateToInputString(defaultValue), min: formatDateToInputString(min), max: formatDateToInputString(max), ref: ref, suffix: showIcon && jsx(Icon, { dataTestId: "calendar", name: "CalendarIcon", size: "medium", type: "solid" }) }, rest)));
262
255
  });
263
256
 
257
+ /**
258
+ * The Label component is used for labels for input fields.
259
+ * This component is **not used directly**, but is part of the FormGroup and Field components.
260
+ *
261
+ * @param {LabelProps} props - The props for the Label component
262
+ * @returns {JSX.Element} Label component
263
+ */
264
+ const Label$1 = ({ id, htmlFor, children, className, dataTestId, disabled, isInvalid, }) => {
265
+ return (jsx(Root$2, Object.assign({ id: id || "", htmlFor: htmlFor || "", className: className, "data-testid": dataTestId, "$disabled": disabled, "$isInvalid": isInvalid }, { children: children })));
266
+ };
267
+ const Root$2 = tw.label `
268
+ tu-label
269
+ ${({ $disabled }) => $disabled && tws `tu-label--disabled`}
270
+ ${({ $isInvalid }) => $isInvalid && tws `tu-label--invalid`}
271
+ `;
272
+
264
273
  /**
265
274
  * The FormGroup component should be used to wrap any Input element that needs a label.
266
275
  * Besides a label the component supplies an optional Tip, HelpText and HelpAddon support.
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@trackunit/react-form-components",
3
- "version": "0.0.20",
3
+ "version": "0.0.22",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "dependencies": {
7
- "@trackunit/i18n-library-translation": "0.0.44",
7
+ "@trackunit/i18n-library-translation": "0.0.45",
8
8
  "@trackunit/react-components": "0.1.84",
9
9
  "@trackunit/tailwind-styled-components": "0.0.56",
10
10
  "date-fns": "2.29.3",
11
11
  "libphonenumber-js": "1.10.26",
12
12
  "react": "18.2.0",
13
- "react-select": "5.7.2",
13
+ "react-select": "5.7.3",
14
14
  "uuid": "8.3.2"
15
15
  },
16
16
  "module": "./index.js",
@@ -6,9 +6,9 @@ export interface CheckboxProps extends CommonProps, React.InputHTMLAttributes<HT
6
6
  */
7
7
  label?: React.ReactNode;
8
8
  /**
9
- * Children to be displayed
9
+ * An element to display after the label
10
10
  */
11
- children?: React.ReactNode;
11
+ suffix?: React.ReactNode;
12
12
  /**
13
13
  * An boolean flag to set checkbox to checked state
14
14
  */