@abgov/react-components 4.0.0-alpha.72 → 4.0.0-alpha.73
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/lib/input/input.d.ts +11 -7
- package/package.json +1 -1
- package/react-components.esm.js +51 -45
- package/react-components.umd.js +55 -45
package/lib/input/input.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
2
|
import { GoAIconType } from '../..';
|
|
3
|
+
export declare type GoADate = Date | string;
|
|
3
4
|
declare type GoAInputType = "text" | "password" | "email" | "number" | "date" | "datetime-local" | "month" | "range" | "search" | "tel" | "time" | "url" | "week";
|
|
4
5
|
declare type GoAAutoCapitalize = "on" | "off" | "none" | "sentences" | "words" | "characters";
|
|
5
6
|
interface WCProps {
|
|
@@ -55,25 +56,28 @@ interface BaseProps {
|
|
|
55
56
|
suffix?: string;
|
|
56
57
|
testId?: string;
|
|
57
58
|
}
|
|
59
|
+
declare type OnChange = (name: string, value: string) => void;
|
|
58
60
|
export interface InputProps extends BaseProps {
|
|
59
|
-
onChange:
|
|
61
|
+
onChange: OnChange;
|
|
60
62
|
value: string;
|
|
61
63
|
min?: number | string;
|
|
62
64
|
max?: number | string;
|
|
63
65
|
step?: number;
|
|
64
66
|
}
|
|
67
|
+
declare type OnNumberChange = (name: string, value: number) => void;
|
|
65
68
|
interface NumberInputProps extends BaseProps {
|
|
66
|
-
onChange:
|
|
69
|
+
onChange: OnNumberChange;
|
|
67
70
|
value: number;
|
|
68
71
|
min?: number;
|
|
69
72
|
max?: number;
|
|
70
73
|
step?: number;
|
|
71
74
|
}
|
|
75
|
+
declare type OnDateChange = (name: string, value: GoADate) => void;
|
|
72
76
|
interface DateInputProps extends BaseProps {
|
|
73
|
-
onChange:
|
|
74
|
-
value:
|
|
75
|
-
min?:
|
|
76
|
-
max?:
|
|
77
|
+
onChange: OnDateChange;
|
|
78
|
+
value: GoADate;
|
|
79
|
+
min?: GoADate;
|
|
80
|
+
max?: GoADate;
|
|
77
81
|
step?: number;
|
|
78
82
|
}
|
|
79
83
|
export declare const GoAInput: FC<InputProps & {
|
|
@@ -82,7 +86,7 @@ export declare const GoAInput: FC<InputProps & {
|
|
|
82
86
|
export declare const GoAInputText: FC<InputProps>;
|
|
83
87
|
export declare const GoAInputPassword: FC<InputProps>;
|
|
84
88
|
export declare const GoAInputDate: FC<DateInputProps>;
|
|
85
|
-
export declare const GoAInputTime: FC<
|
|
89
|
+
export declare const GoAInputTime: FC<InputProps>;
|
|
86
90
|
export declare const GoAInputDateTime: FC<DateInputProps>;
|
|
87
91
|
export declare const GoAInputEmail: FC<InputProps>;
|
|
88
92
|
export declare const GoAInputSearch: FC<InputProps>;
|
package/package.json
CHANGED
package/react-components.esm.js
CHANGED
|
@@ -14839,6 +14839,45 @@ const GoAInput = ({
|
|
|
14839
14839
|
handletrailingiconclick: !!onTrailingIconClick
|
|
14840
14840
|
}, void 0);
|
|
14841
14841
|
};
|
|
14842
|
+
|
|
14843
|
+
const onDateChangeHandler = onChange => {
|
|
14844
|
+
return (name, value) => {
|
|
14845
|
+
if (!value) {
|
|
14846
|
+
onChange(name, new Date(0));
|
|
14847
|
+
return;
|
|
14848
|
+
}
|
|
14849
|
+
|
|
14850
|
+
onChange(name, parseISO(value));
|
|
14851
|
+
};
|
|
14852
|
+
};
|
|
14853
|
+
|
|
14854
|
+
const onTimeChangeHandler = onChange => {
|
|
14855
|
+
return (name, value) => {
|
|
14856
|
+
if (!value) {
|
|
14857
|
+
onChange(name, "");
|
|
14858
|
+
return;
|
|
14859
|
+
}
|
|
14860
|
+
|
|
14861
|
+
onChange(name, value);
|
|
14862
|
+
};
|
|
14863
|
+
};
|
|
14864
|
+
|
|
14865
|
+
function toString(value, tmpl = "yyyy-MM-dd") {
|
|
14866
|
+
if (!value) {
|
|
14867
|
+
return "";
|
|
14868
|
+
}
|
|
14869
|
+
|
|
14870
|
+
if (typeof value === "string") {
|
|
14871
|
+
return format(parseISO(value), tmpl);
|
|
14872
|
+
}
|
|
14873
|
+
|
|
14874
|
+
if (value.toISOString() === new Date(0).toISOString()) {
|
|
14875
|
+
return "";
|
|
14876
|
+
}
|
|
14877
|
+
|
|
14878
|
+
return format(value, tmpl);
|
|
14879
|
+
}
|
|
14880
|
+
|
|
14842
14881
|
const GoAInputText = props => {
|
|
14843
14882
|
return jsx(GoAInput, Object.assign({}, props, {
|
|
14844
14883
|
type: "text"
|
|
@@ -14857,26 +14896,12 @@ const GoAInputDate = _a => {
|
|
|
14857
14896
|
} = _a,
|
|
14858
14897
|
props = __rest(_a, ["value", "min", "max"]);
|
|
14859
14898
|
|
|
14860
|
-
const _format = value => {
|
|
14861
|
-
return format(value, "yyyy-MM-dd");
|
|
14862
|
-
};
|
|
14863
|
-
|
|
14864
|
-
const _value = _format(typeof value === "string" ? parseISO(value) : value);
|
|
14865
|
-
|
|
14866
|
-
const _min = min && _format(typeof min === "string" ? parseISO(min) : min);
|
|
14867
|
-
|
|
14868
|
-
const _max = max && _format(typeof max === "string" ? parseISO(max) : max);
|
|
14869
|
-
|
|
14870
|
-
const onDateChange = (name, value) => {
|
|
14871
|
-
props.onChange(name, parseISO(value));
|
|
14872
|
-
};
|
|
14873
|
-
|
|
14874
14899
|
return jsx(GoAInput, Object.assign({}, props, {
|
|
14875
|
-
|
|
14876
|
-
|
|
14877
|
-
|
|
14878
|
-
|
|
14879
|
-
|
|
14900
|
+
type: "date",
|
|
14901
|
+
onChange: onDateChangeHandler(props.onChange),
|
|
14902
|
+
min: toString(min),
|
|
14903
|
+
max: toString(max),
|
|
14904
|
+
value: toString(value)
|
|
14880
14905
|
}), void 0);
|
|
14881
14906
|
};
|
|
14882
14907
|
const GoAInputTime = _a => {
|
|
@@ -14887,24 +14912,11 @@ const GoAInputTime = _a => {
|
|
|
14887
14912
|
} = _a,
|
|
14888
14913
|
props = __rest(_a, ["value", "min", "max"]);
|
|
14889
14914
|
|
|
14890
|
-
|
|
14891
|
-
props.onChange
|
|
14892
|
-
|
|
14893
|
-
|
|
14894
|
-
|
|
14895
|
-
const d = typeof value === "string" ? parseISO(value) : value;
|
|
14896
|
-
return jsx(GoAInput, Object.assign({}, props, {
|
|
14897
|
-
onChange: onDateChange,
|
|
14898
|
-
value: format(d, "hh:mm"),
|
|
14899
|
-
type: "time"
|
|
14900
|
-
}), void 0);
|
|
14901
|
-
} catch (e) {
|
|
14902
|
-
return jsx(GoAInput, Object.assign({}, props, {
|
|
14903
|
-
onChange: onDateChange,
|
|
14904
|
-
value: value,
|
|
14905
|
-
type: "time"
|
|
14906
|
-
}), void 0);
|
|
14907
|
-
}
|
|
14915
|
+
return jsx(GoAInput, Object.assign({}, props, {
|
|
14916
|
+
onChange: onTimeChangeHandler(props.onChange),
|
|
14917
|
+
value: value,
|
|
14918
|
+
type: "time"
|
|
14919
|
+
}), void 0);
|
|
14908
14920
|
};
|
|
14909
14921
|
const GoAInputDateTime = _a => {
|
|
14910
14922
|
var {
|
|
@@ -14914,15 +14926,9 @@ const GoAInputDateTime = _a => {
|
|
|
14914
14926
|
} = _a,
|
|
14915
14927
|
props = __rest(_a, ["value", "min", "max"]);
|
|
14916
14928
|
|
|
14917
|
-
const d = typeof value === "string" ? parseISO(value) : value;
|
|
14918
|
-
|
|
14919
|
-
const onDateChange = (name, value) => {
|
|
14920
|
-
props.onChange(name, parseISO(value));
|
|
14921
|
-
};
|
|
14922
|
-
|
|
14923
14929
|
return jsx(GoAInput, Object.assign({}, props, {
|
|
14924
|
-
onChange:
|
|
14925
|
-
value:
|
|
14930
|
+
onChange: onDateChangeHandler(props.onChange),
|
|
14931
|
+
value: toString(value, "yyyy-MM-dd'T'hh:mm"),
|
|
14926
14932
|
type: "datetime-local"
|
|
14927
14933
|
}), void 0);
|
|
14928
14934
|
};
|
package/react-components.umd.js
CHANGED
|
@@ -14885,6 +14885,49 @@
|
|
|
14885
14885
|
handletrailingiconclick: !!onTrailingIconClick
|
|
14886
14886
|
}, void 0);
|
|
14887
14887
|
};
|
|
14888
|
+
|
|
14889
|
+
var onDateChangeHandler = function onDateChangeHandler(onChange) {
|
|
14890
|
+
return function (name, value) {
|
|
14891
|
+
if (!value) {
|
|
14892
|
+
onChange(name, new Date(0));
|
|
14893
|
+
return;
|
|
14894
|
+
}
|
|
14895
|
+
|
|
14896
|
+
onChange(name, dateFns.parseISO(value));
|
|
14897
|
+
};
|
|
14898
|
+
};
|
|
14899
|
+
|
|
14900
|
+
var onTimeChangeHandler = function onTimeChangeHandler(onChange) {
|
|
14901
|
+
return function (name, value) {
|
|
14902
|
+
if (!value) {
|
|
14903
|
+
onChange(name, "");
|
|
14904
|
+
return;
|
|
14905
|
+
}
|
|
14906
|
+
|
|
14907
|
+
onChange(name, value);
|
|
14908
|
+
};
|
|
14909
|
+
};
|
|
14910
|
+
|
|
14911
|
+
function toString(value, tmpl) {
|
|
14912
|
+
if (tmpl === void 0) {
|
|
14913
|
+
tmpl = "yyyy-MM-dd";
|
|
14914
|
+
}
|
|
14915
|
+
|
|
14916
|
+
if (!value) {
|
|
14917
|
+
return "";
|
|
14918
|
+
}
|
|
14919
|
+
|
|
14920
|
+
if (typeof value === "string") {
|
|
14921
|
+
return dateFns.format(dateFns.parseISO(value), tmpl);
|
|
14922
|
+
}
|
|
14923
|
+
|
|
14924
|
+
if (value.toISOString() === new Date(0).toISOString()) {
|
|
14925
|
+
return "";
|
|
14926
|
+
}
|
|
14927
|
+
|
|
14928
|
+
return dateFns.format(value, tmpl);
|
|
14929
|
+
}
|
|
14930
|
+
|
|
14888
14931
|
var GoAInputText = function GoAInputText(props) {
|
|
14889
14932
|
return jsxRuntime.jsx(GoAInput, __assign({}, props, {
|
|
14890
14933
|
type: "text"
|
|
@@ -14903,26 +14946,12 @@
|
|
|
14903
14946
|
max = _c === void 0 ? "" : _c,
|
|
14904
14947
|
props = __rest(_a, ["value", "min", "max"]);
|
|
14905
14948
|
|
|
14906
|
-
var _format = function _format(value) {
|
|
14907
|
-
return dateFns.format(value, "yyyy-MM-dd");
|
|
14908
|
-
};
|
|
14909
|
-
|
|
14910
|
-
var _value = _format(typeof value === "string" ? dateFns.parseISO(value) : value);
|
|
14911
|
-
|
|
14912
|
-
var _min = min && _format(typeof min === "string" ? dateFns.parseISO(min) : min);
|
|
14913
|
-
|
|
14914
|
-
var _max = max && _format(typeof max === "string" ? dateFns.parseISO(max) : max);
|
|
14915
|
-
|
|
14916
|
-
var onDateChange = function onDateChange(name, value) {
|
|
14917
|
-
props.onChange(name, dateFns.parseISO(value));
|
|
14918
|
-
};
|
|
14919
|
-
|
|
14920
14949
|
return jsxRuntime.jsx(GoAInput, __assign({}, props, {
|
|
14921
|
-
|
|
14922
|
-
|
|
14923
|
-
|
|
14924
|
-
|
|
14925
|
-
|
|
14950
|
+
type: "date",
|
|
14951
|
+
onChange: onDateChangeHandler(props.onChange),
|
|
14952
|
+
min: toString(min),
|
|
14953
|
+
max: toString(max),
|
|
14954
|
+
value: toString(value)
|
|
14926
14955
|
}), void 0);
|
|
14927
14956
|
};
|
|
14928
14957
|
var GoAInputTime = function GoAInputTime(_a) {
|
|
@@ -14931,24 +14960,11 @@
|
|
|
14931
14960
|
_a.max;
|
|
14932
14961
|
var props = __rest(_a, ["value", "min", "max"]);
|
|
14933
14962
|
|
|
14934
|
-
|
|
14935
|
-
props.onChange
|
|
14936
|
-
|
|
14937
|
-
|
|
14938
|
-
|
|
14939
|
-
var d = typeof value === "string" ? dateFns.parseISO(value) : value;
|
|
14940
|
-
return jsxRuntime.jsx(GoAInput, __assign({}, props, {
|
|
14941
|
-
onChange: onDateChange,
|
|
14942
|
-
value: dateFns.format(d, "hh:mm"),
|
|
14943
|
-
type: "time"
|
|
14944
|
-
}), void 0);
|
|
14945
|
-
} catch (e) {
|
|
14946
|
-
return jsxRuntime.jsx(GoAInput, __assign({}, props, {
|
|
14947
|
-
onChange: onDateChange,
|
|
14948
|
-
value: value,
|
|
14949
|
-
type: "time"
|
|
14950
|
-
}), void 0);
|
|
14951
|
-
}
|
|
14963
|
+
return jsxRuntime.jsx(GoAInput, __assign({}, props, {
|
|
14964
|
+
onChange: onTimeChangeHandler(props.onChange),
|
|
14965
|
+
value: value,
|
|
14966
|
+
type: "time"
|
|
14967
|
+
}), void 0);
|
|
14952
14968
|
};
|
|
14953
14969
|
var GoAInputDateTime = function GoAInputDateTime(_a) {
|
|
14954
14970
|
var value = _a.value;
|
|
@@ -14956,15 +14972,9 @@
|
|
|
14956
14972
|
_a.max;
|
|
14957
14973
|
var props = __rest(_a, ["value", "min", "max"]);
|
|
14958
14974
|
|
|
14959
|
-
var d = typeof value === "string" ? dateFns.parseISO(value) : value;
|
|
14960
|
-
|
|
14961
|
-
var onDateChange = function onDateChange(name, value) {
|
|
14962
|
-
props.onChange(name, dateFns.parseISO(value));
|
|
14963
|
-
};
|
|
14964
|
-
|
|
14965
14975
|
return jsxRuntime.jsx(GoAInput, __assign({}, props, {
|
|
14966
|
-
onChange:
|
|
14967
|
-
value:
|
|
14976
|
+
onChange: onDateChangeHandler(props.onChange),
|
|
14977
|
+
value: toString(value, "yyyy-MM-dd'T'hh:mm"),
|
|
14968
14978
|
type: "datetime-local"
|
|
14969
14979
|
}), void 0);
|
|
14970
14980
|
};
|