@conduction/components 2.0.34 → 2.1.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.
package/README.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Changelog
4
4
 
5
+ - **Version 2.1 (breaking changes from 2.0.x)**
6
+
7
+ - 2.1.0: InputDate now includes Den Haag InputDate component, requiring react-hook-form controls.
8
+
5
9
  - **Version 2**
6
10
 
7
11
  - 2.0.34: SelectMultiple and SelectCreate update to include defaultValue in react-hook-form controller.
@@ -1,11 +1,13 @@
1
1
  import * as React from "react";
2
2
  import { IReactHookFormProps } from "./types";
3
+ import { Control, FieldValues } from "react-hook-form";
3
4
  export interface IInputProps {
4
5
  name: string;
5
6
  disabled?: boolean;
6
7
  defaultValue?: string;
7
8
  icon?: JSX.Element;
8
9
  placeholder?: string;
10
+ control?: Control<FieldValues, any>;
9
11
  }
10
12
  export declare const InputPassword: React.FC<IInputProps & IReactHookFormProps>;
11
13
  export declare const InputText: React.FC<IInputProps & IReactHookFormProps>;
@@ -1,7 +1,8 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
- import { TextField } from "@gemeente-denhaag/components-react";
3
+ import { Datepicker, TextField } from "@gemeente-denhaag/components-react";
4
4
  import { ShowIcon, HideIcon } from "@gemeente-denhaag/icons";
5
+ import { Controller } from "react-hook-form";
5
6
  export const InputPassword = ({ disabled, name, validation, register, placeholder, errors, }) => {
6
7
  const [showPassword, setShowPassword] = React.useState(false);
7
8
  return (_jsx(TextField, { type: showPassword ? "text" : "password", ...{ disabled, placeholder }, ...register(name, { ...validation }), invalid: errors[name], icon: _jsx("span", { onClick: () => setShowPassword(!showPassword), children: showPassword ? _jsx(HideIcon, {}) : _jsx(ShowIcon, {}) }) }));
@@ -9,7 +10,9 @@ export const InputPassword = ({ disabled, name, validation, register, placeholde
9
10
  export const InputText = ({ disabled, name, defaultValue, validation, register, icon, placeholder, errors, }) => (_jsx(TextField, { type: "text", ...{ defaultValue, disabled, placeholder, icon }, ...register(name, { ...validation }), invalid: errors[name] }));
10
11
  export const InputEmail = ({ disabled, name, defaultValue, validation, register, icon, placeholder, errors, }) => (_jsx(TextField, { type: "email", ...{ defaultValue, disabled, placeholder, icon }, ...register(name, { ...validation }), invalid: errors[name] }));
11
12
  export const InputURL = ({ disabled, name, defaultValue, validation, register, icon, placeholder, errors, }) => (_jsx(TextField, { type: "url", ...{ defaultValue, disabled, placeholder, icon }, ...register(name, { ...validation }), invalid: errors[name] }));
12
- export const InputDate = ({ disabled, name, defaultValue, validation, register, errors, }) => (_jsx(TextField, { type: "date", ...{ defaultValue, disabled }, ...register(name, { ...validation }), invalid: errors[name] }));
13
+ export const InputDate = ({ disabled, name, defaultValue, validation, errors, control, }) => (_jsx(Controller, { ...{ control, name, defaultValue }, rules: validation, render: ({ field: { onChange, value } }) => {
14
+ return _jsx(Datepicker, { ...{ value, onChange, disabled }, error: !!errors[name] });
15
+ } }));
13
16
  export const InputDateTime = ({ disabled, name, defaultValue, validation, register, errors, }) => (_jsx(TextField, { type: "datetime-local", ...{ defaultValue, disabled }, ...register(name, { ...validation }), invalid: errors[name] }));
14
17
  export const InputNumber = ({ disabled, name, defaultValue, validation, register, icon, placeholder, errors, }) => (_jsx(TextField, { type: "number", ...{ defaultValue, disabled, placeholder, icon }, ...register(name, { ...validation, valueAsNumber: true }), invalid: errors[name] }));
15
18
  export const InputFloat = ({ disabled, name, defaultValue, validation, register, icon, placeholder, errors, }) => (_jsx(TextField, { type: "number", step: ".01", ...{ disabled, placeholder, icon, defaultValue }, ...register(name, { ...validation, valueAsNumber: true }), invalid: errors[name] }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@conduction/components",
3
- "version": "2.0.34",
3
+ "version": "2.1.0",
4
4
  "description": "React (Gatsby) components used within the Conduction Skeleton Application (and its implementations)",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -1,7 +1,8 @@
1
1
  import * as React from "react";
2
- import { TextField } from "@gemeente-denhaag/components-react";
2
+ import { Datepicker, TextField } from "@gemeente-denhaag/components-react";
3
3
  import { ShowIcon, HideIcon } from "@gemeente-denhaag/icons";
4
4
  import { IReactHookFormProps } from "./types";
5
+ import { Control, FieldValues, Controller } from "react-hook-form";
5
6
 
6
7
  export interface IInputProps {
7
8
  name: string;
@@ -9,6 +10,7 @@ export interface IInputProps {
9
10
  defaultValue?: string;
10
11
  icon?: JSX.Element;
11
12
  placeholder?: string;
13
+ control?: Control<FieldValues, any>;
12
14
  }
13
15
 
14
16
  export const InputPassword: React.FC<IInputProps & IReactHookFormProps> = ({
@@ -91,14 +93,15 @@ export const InputDate: React.FC<IInputProps & IReactHookFormProps> = ({
91
93
  name,
92
94
  defaultValue,
93
95
  validation,
94
- register,
95
96
  errors,
97
+ control,
96
98
  }) => (
97
- <TextField
98
- type="date"
99
- {...{ defaultValue, disabled }}
100
- {...register(name, { ...validation })}
101
- invalid={errors[name]}
99
+ <Controller
100
+ {...{ control, name, defaultValue }}
101
+ rules={validation}
102
+ render={({ field: { onChange, value } }) => {
103
+ return <Datepicker {...{ value, onChange, disabled }} error={!!errors[name]} />;
104
+ }}
102
105
  />
103
106
  );
104
107