@licklist/design 0.44.506 → 0.44.507
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.
|
@@ -11,7 +11,8 @@ export interface TypeaheadProps {
|
|
|
11
11
|
name: string;
|
|
12
12
|
isMultipleChoise?: boolean;
|
|
13
13
|
noOptionsMessage: string;
|
|
14
|
+
isInvalid?: boolean;
|
|
14
15
|
}
|
|
15
|
-
declare function Typeahead({ options, placeholder, isRequired, isMultipleChoise, name, noOptionsMessage, }: TypeaheadProps): JSX.Element;
|
|
16
|
+
declare function Typeahead({ options, placeholder, isRequired, isMultipleChoise, name, noOptionsMessage, isInvalid, }: TypeaheadProps): JSX.Element;
|
|
16
17
|
export { Typeahead };
|
|
17
18
|
//# sourceMappingURL=Typeahead.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Typeahead.d.ts","sourceRoot":"","sources":["../../src/typeahead/Typeahead.tsx"],"names":[],"mappings":";AAIA,oBAAY,gBAAgB,GAAG;IAC7B,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,KAAK,EAAE,GAAG,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,gBAAgB,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"Typeahead.d.ts","sourceRoot":"","sources":["../../src/typeahead/Typeahead.tsx"],"names":[],"mappings":";AAIA,oBAAY,gBAAgB,GAAG;IAC7B,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,KAAK,EAAE,GAAG,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,iBAAS,SAAS,CAAC,EACjB,OAAO,EACP,WAAW,EACX,UAAkB,EAClB,gBAAgB,EAChB,IAAS,EACT,gBAAqB,EACrB,SAAS,GACV,EAAE,cAAc,eAgChB;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var r=e(require("react")),t=require("react-hook-form"),
|
|
1
|
+
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var r=require("tslib"),n=e(require("react")),t=require("react-hook-form"),o=e(require("react-select"));exports.Typeahead=function(e){var i=e.options,l=e.placeholder,a=e.isRequired,u=void 0!==a&&a,s=e.isMultipleChoise,c=e.name,d=void 0===c?"":c,p=e.noOptionsMessage,f=void 0===p?"":p,v=e.isInvalid,m=t.useFormContext().control;return n.createElement(n.Fragment,null,n.createElement(t.Controller,{name:d,control:m,rules:{required:u},render:function(e){var t=e.field;return n.createElement(o,{placeholder:l,value:t.value,isMulti:s,styles:{control:function(e){return r.__assign(r.__assign({},e),v?{borderColor:"red"}:{})}},onChange:function(e){t.onChange(e)},options:i,noOptionsMessage:function(){return n.createElement("span",null,f)}})}}))};
|
package/package.json
CHANGED
|
@@ -15,6 +15,7 @@ export interface TypeaheadProps {
|
|
|
15
15
|
name: string;
|
|
16
16
|
isMultipleChoise?: boolean;
|
|
17
17
|
noOptionsMessage: string;
|
|
18
|
+
isInvalid?: boolean;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
function Typeahead({
|
|
@@ -24,9 +25,12 @@ function Typeahead({
|
|
|
24
25
|
isMultipleChoise,
|
|
25
26
|
name = "",
|
|
26
27
|
noOptionsMessage = "",
|
|
28
|
+
isInvalid,
|
|
27
29
|
}: TypeaheadProps) {
|
|
28
30
|
const { control } = useFormContext();
|
|
29
31
|
|
|
32
|
+
const getErrorStyle = () => (isInvalid ? { borderColor: "red" } : {});
|
|
33
|
+
|
|
30
34
|
return (
|
|
31
35
|
<>
|
|
32
36
|
<Controller
|
|
@@ -38,6 +42,12 @@ function Typeahead({
|
|
|
38
42
|
placeholder={placeholder}
|
|
39
43
|
value={field.value}
|
|
40
44
|
isMulti={isMultipleChoise}
|
|
45
|
+
styles={{
|
|
46
|
+
control: (base) => ({
|
|
47
|
+
...base,
|
|
48
|
+
...getErrorStyle(),
|
|
49
|
+
}),
|
|
50
|
+
}}
|
|
41
51
|
onChange={(value) => {
|
|
42
52
|
field.onChange(value);
|
|
43
53
|
}}
|