@mtes-mct/monitor-ui 1.6.0 → 1.7.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/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # [1.6.0](https://github.com/MTES-MCT/monitor-ui/compare/v1.5.1...v1.6.0) (2022-11-29)
2
+
3
+
4
+ ### Features
5
+
6
+ * **fields:** add MultiCheckbox ([#37](https://github.com/MTES-MCT/monitor-ui/issues/37)) ([405ce01](https://github.com/MTES-MCT/monitor-ui/commit/405ce013e2eeac7d6143c1fab4f6d241133042e5))
7
+ * **fields:** add MultiRadio ([#38](https://github.com/MTES-MCT/monitor-ui/issues/38)) ([de205f9](https://github.com/MTES-MCT/monitor-ui/commit/de205f9431a527bd5baf6dd85ac92d0126546c07))
8
+
1
9
  ## [1.5.1](https://github.com/MTES-MCT/monitor-ui/compare/v1.5.0...v1.5.1) (2022-11-29)
2
10
 
3
11
 
@@ -1,3 +1,7 @@
1
1
  import type { LabelHTMLAttributes } from 'react';
2
- export declare type LabelProps = LabelHTMLAttributes<HTMLLabelElement>;
3
- export declare const Label: import("styled-components").StyledComponent<"label", import("styled-components").DefaultTheme, {}, never>;
2
+ export declare type LabelProps = LabelHTMLAttributes<HTMLLabelElement> & {
3
+ isHidden: boolean;
4
+ };
5
+ export declare const Label: import("styled-components").StyledComponent<"label", import("styled-components").DefaultTheme, {
6
+ isHidden?: boolean | undefined;
7
+ }, never>;
@@ -3,6 +3,3 @@ export declare type LegendProps = HTMLAttributes<HTMLLegendElement> & {
3
3
  isHidden?: boolean;
4
4
  };
5
5
  export declare function Legend({ isHidden, ...nativeProps }: LegendProps): JSX.Element;
6
- export declare const StyledLabel: import("styled-components").StyledComponent<"label", import("styled-components").DefaultTheme, {
7
- isHidden: boolean;
8
- }, never>;
@@ -1,6 +1,6 @@
1
1
  import type { CheckboxProps as RsuiteCheckboxProps } from 'rsuite';
2
2
  import type { Promisable } from 'type-fest';
3
- export declare type CheckboxProps = Omit<RsuiteCheckboxProps, 'checked' | 'onChange'> & {
3
+ export declare type CheckboxProps = Omit<RsuiteCheckboxProps, 'checked' | 'id' | 'onChange'> & {
4
4
  label: string;
5
5
  name: string;
6
6
  onChange?: (isCheched: boolean) => Promisable<void>;
@@ -1,12 +1,14 @@
1
1
  import type { Option } from '../types';
2
2
  import type { TagPickerProps } from 'rsuite';
3
3
  import type { Promisable } from 'type-fest';
4
- export declare type MultiSelectProps = Omit<TagPickerProps, 'as' | 'data' | 'defaultValue' | 'onChange' | 'value'> & {
4
+ export declare type MultiSelectProps = Omit<TagPickerProps, 'as' | 'data' | 'defaultValue' | 'id' | 'onChange' | 'value'> & {
5
5
  defaultValue?: string[];
6
6
  /** Width in REM */
7
7
  fixedWidth?: number;
8
+ isLabelHidden?: boolean;
9
+ label: string;
8
10
  name: string;
9
11
  onChange?: (nextValue: string[] | undefined) => Promisable<void>;
10
12
  options: Option[];
11
13
  };
12
- export declare function MultiSelect({ fixedWidth, onChange, options, searchable, ...originalProps }: MultiSelectProps): JSX.Element;
14
+ export declare function MultiSelect({ fixedWidth, isLabelHidden, label, onChange, options, searchable, ...originalProps }: MultiSelectProps): JSX.Element;
@@ -1,10 +1,12 @@
1
1
  import type { Option } from '../types';
2
2
  import type { SelectPickerProps } from 'rsuite';
3
3
  import type { Promisable } from 'type-fest';
4
- export declare type SelectProps = Omit<SelectPickerProps<any>, 'as' | 'data' | 'defaultValue' | 'onChange' | 'value'> & {
4
+ export declare type SelectProps = Omit<SelectPickerProps<any>, 'as' | 'data' | 'defaultValue' | 'id' | 'onChange' | 'value'> & {
5
5
  defaultValue?: string;
6
+ isLabelHidden?: boolean;
7
+ label: string;
6
8
  name: string;
7
9
  onChange?: (nextValue: string | undefined) => Promisable<void>;
8
10
  options: Option[];
9
11
  };
10
- export declare function Select({ onChange, options, searchable, ...originalProps }: SelectProps): JSX.Element;
12
+ export declare function Select({ isLabelHidden, label, onChange, options, searchable, ...originalProps }: SelectProps): JSX.Element;
@@ -1,9 +1,11 @@
1
1
  import type { InputProps } from 'rsuite';
2
2
  import type { Promisable } from 'type-fest';
3
- export declare type TextInputProps = Omit<InputProps, 'as' | 'defaultValue' | 'onChange' | 'value'> & {
3
+ export declare type TextInputProps = Omit<InputProps, 'as' | 'defaultValue' | 'id' | 'onChange' | 'value'> & {
4
4
  defaultValue?: string;
5
+ isLabelHidden?: boolean;
6
+ label: string;
5
7
  name: string;
6
8
  onChange?: (nextValue: string | undefined) => Promisable<void>;
7
9
  };
8
- export declare function TextInput({ onChange, ...originalProps }: TextInputProps): JSX.Element;
10
+ export declare function TextInput({ isLabelHidden, label, onChange, ...originalProps }: TextInputProps): JSX.Element;
9
11
  export declare const StyledInput: import("styled-components").StyledComponent<import("rsuite/esm/@types/common").RsRefForwardingComponent<"input", InputProps>, import("styled-components").DefaultTheme, {}, never>;
@@ -1,9 +1,11 @@
1
1
  import type { TextareaHTMLAttributes } from 'react';
2
2
  import type { Promisable } from 'type-fest';
3
- export declare type TextareaProps = Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'defaultValue' | 'onChange' | 'value'> & {
3
+ export declare type TextareaProps = Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'defaultValue' | 'id' | 'onChange' | 'value'> & {
4
4
  defaultValue?: string;
5
+ isLabelHidden?: boolean;
6
+ label: string;
5
7
  name: string;
6
8
  onChange?: (nextValue: string | undefined) => Promisable<void>;
7
9
  };
8
- export declare function Textarea({ onChange, rows, ...originalProps }: TextareaProps): JSX.Element;
10
+ export declare function Textarea({ isLabelHidden, label, onChange, rows, ...originalProps }: TextareaProps): JSX.Element;
9
11
  export declare const StyledInput: import("styled-components").StyledComponent<import("rsuite/esm/@types/common").RsRefForwardingComponent<"input", import("rsuite").InputProps>, import("styled-components").DefaultTheme, {}, never>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mtes-mct/monitor-ui",
3
3
  "description": "Common React UI components and styles for Monitorfish and Monitorenv.",
4
- "version": "1.6.0",
4
+ "version": "1.7.0",
5
5
  "license": "AGPL-3.0",
6
6
  "engines": {
7
7
  "node": "18",
@@ -2,6 +2,7 @@ import styled from 'styled-components';
2
2
 
3
3
  const Label = styled.label `
4
4
  color: ${p => p.theme.color.slateGray};
5
+ display: ${p => (p.isHidden ? 'none' : 'table')};
5
6
  font-size: 13px;
6
7
  line-height: 1.4;
7
8
  margin-bottom: 0.5rem;
@@ -1 +1 @@
1
- {"version":3,"file":"Label.js","sources":["../../../src/elements/Label.tsx"],"sourcesContent":["import styled from 'styled-components'\n\nimport type { LabelHTMLAttributes } from 'react'\n\nexport type LabelProps = LabelHTMLAttributes<HTMLLabelElement>\nexport const Label = styled.label`\n color: ${p => p.theme.color.slateGray};\n font-size: 13px;\n line-height: 1.4;\n margin-bottom: 0.5rem;\n`\n"],"names":[],"mappings":";;AAKa,MAAA,KAAK,GAAG,MAAM,CAAC,KAAK,CAAA,CAAA;WACtB,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAA;;;;;;;;"}
1
+ {"version":3,"file":"Label.js","sources":["../../../src/elements/Label.tsx"],"sourcesContent":["import styled from 'styled-components'\n\nimport type { LabelHTMLAttributes } from 'react'\n\nexport type LabelProps = LabelHTMLAttributes<HTMLLabelElement> & {\n isHidden: boolean\n}\nexport const Label = styled.label<{\n isHidden?: boolean\n}>`\n color: ${p => p.theme.color.slateGray};\n display: ${p => (p.isHidden ? 'none' : 'table')};\n font-size: 13px;\n line-height: 1.4;\n margin-bottom: 0.5rem;\n`\n"],"names":[],"mappings":";;AAOa,MAAA,KAAK,GAAG,MAAM,CAAC,KAAK,CAE/B,CAAA;WACS,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAA;AAC1B,WAAA,EAAA,CAAC,KAAK,CAAC,CAAC,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC,CAAA;;;;;;;;"}
@@ -1,13 +1,9 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
- import styled from 'styled-components';
3
2
  import { Label } from './Label.js';
4
3
 
5
4
  function Legend({ isHidden = false, ...nativeProps }) {
6
- return jsx(StyledLabel, { as: "legend", isHidden: isHidden, ...nativeProps });
5
+ return jsx(Label, { as: "legend", isHidden: isHidden, ...nativeProps });
7
6
  }
8
- const StyledLabel = styled(Label) `
9
- display: ${p => (p.isHidden ? 'none' : 'table')};
10
- `;
11
7
 
12
- export { Legend, StyledLabel };
8
+ export { Legend };
13
9
  //# sourceMappingURL=Legend.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Legend.js","sources":["../../../src/elements/Legend.tsx"],"sourcesContent":["import styled from 'styled-components'\n\nimport { Label } from './Label'\n\nimport type { HTMLAttributes } from 'react'\n\nexport type LegendProps = HTMLAttributes<HTMLLegendElement> & {\n isHidden?: boolean\n}\nexport function Legend({ isHidden = false, ...nativeProps }: LegendProps) {\n return <StyledLabel as=\"legend\" isHidden={isHidden} {...nativeProps} />\n}\n\nexport const StyledLabel = styled(Label)<{\n isHidden: boolean\n}>`\n display: ${p => (p.isHidden ? 'none' : 'table')};\n`\n"],"names":["_jsx"],"mappings":";;;;AASM,SAAU,MAAM,CAAC,EAAE,QAAQ,GAAG,KAAK,EAAE,GAAG,WAAW,EAAe,EAAA;AACtE,IAAA,OAAOA,GAAC,CAAA,WAAW,EAAC,EAAA,EAAE,EAAC,QAAQ,EAAC,QAAQ,EAAE,QAAQ,EAAM,GAAA,WAAW,GAAI,CAAA;AACzE,CAAC;MAEY,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,CAEtC,CAAA;AACW,WAAA,EAAA,CAAC,KAAK,CAAC,CAAC,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC,CAAA;;;;;"}
1
+ {"version":3,"file":"Legend.js","sources":["../../../src/elements/Legend.tsx"],"sourcesContent":["import { Label } from './Label'\n\nimport type { HTMLAttributes } from 'react'\n\nexport type LegendProps = HTMLAttributes<HTMLLegendElement> & {\n isHidden?: boolean\n}\nexport function Legend({ isHidden = false, ...nativeProps }: LegendProps) {\n return <Label as=\"legend\" isHidden={isHidden} {...nativeProps} />\n}\n"],"names":["_jsx"],"mappings":";;;AAOM,SAAU,MAAM,CAAC,EAAE,QAAQ,GAAG,KAAK,EAAE,GAAG,WAAW,EAAe,EAAA;AACtE,IAAA,OAAOA,GAAC,CAAA,KAAK,EAAC,EAAA,EAAE,EAAC,QAAQ,EAAC,QAAQ,EAAE,QAAQ,EAAM,GAAA,WAAW,GAAI,CAAA;AACnE;;;;"}
@@ -10,7 +10,7 @@ function Checkbox({ label, onChange, ...originalProps }) {
10
10
  }
11
11
  onChange(isChecked);
12
12
  }, [onChange]);
13
- return (jsx(Checkbox$1, { onChange: handleChange, ...originalProps, children: label }, key));
13
+ return (jsx(Checkbox$1, { id: originalProps.name, onChange: handleChange, ...originalProps, children: label }, key));
14
14
  }
15
15
 
16
16
  export { Checkbox };
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.js","sources":["../../../src/fields/Checkbox.tsx"],"sourcesContent":["import { useCallback, useMemo } from 'react'\nimport { Checkbox as RsuiteCheckbox } from 'rsuite'\n\nimport type { CheckboxProps as RsuiteCheckboxProps } from 'rsuite'\nimport type { ValueType } from 'rsuite/esm/Checkbox'\nimport type { Promisable } from 'type-fest'\n\nexport type CheckboxProps = Omit<RsuiteCheckboxProps, 'checked' | 'onChange'> & {\n label: string\n name: string\n onChange?: (isCheched: boolean) => Promisable<void>\n}\nexport function Checkbox({ label, onChange, ...originalProps }: CheckboxProps) {\n const key = useMemo(\n () => `${originalProps.name}-${String(originalProps.defaultChecked)}`,\n [originalProps.defaultChecked, originalProps.name]\n )\n\n const handleChange = useCallback(\n (_: ValueType | undefined, isChecked: boolean) => {\n if (!onChange) {\n return\n }\n\n onChange(isChecked)\n },\n [onChange]\n )\n\n return (\n <RsuiteCheckbox key={key} onChange={handleChange} {...originalProps}>\n {label}\n </RsuiteCheckbox>\n )\n}\n"],"names":["_jsx","RsuiteCheckbox"],"mappings":";;;;AAYM,SAAU,QAAQ,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,aAAa,EAAiB,EAAA;AAC3E,IAAA,MAAM,GAAG,GAAG,OAAO,CACjB,MAAM,CAAA,EAAG,aAAa,CAAC,IAAI,CAAA,CAAA,EAAI,MAAM,CAAC,aAAa,CAAC,cAAc,CAAC,CAAA,CAAE,EACrE,CAAC,aAAa,CAAC,cAAc,EAAE,aAAa,CAAC,IAAI,CAAC,CACnD,CAAA;IAED,MAAM,YAAY,GAAG,WAAW,CAC9B,CAAC,CAAwB,EAAE,SAAkB,KAAI;QAC/C,IAAI,CAAC,QAAQ,EAAE;YACb,OAAM;AACP,SAAA;QAED,QAAQ,CAAC,SAAS,CAAC,CAAA;AACrB,KAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAA;AAED,IAAA,QACEA,GAAA,CAACC,UAAc,EAAA,EAAW,QAAQ,EAAE,YAAY,EAAM,GAAA,aAAa,YAChE,KAAK,EAAA,EADa,GAAG,CAEP,EAClB;AACH;;;;"}
1
+ {"version":3,"file":"Checkbox.js","sources":["../../../src/fields/Checkbox.tsx"],"sourcesContent":["import { useCallback, useMemo } from 'react'\nimport { Checkbox as RsuiteCheckbox } from 'rsuite'\n\nimport type { CheckboxProps as RsuiteCheckboxProps } from 'rsuite'\nimport type { ValueType } from 'rsuite/esm/Checkbox'\nimport type { Promisable } from 'type-fest'\n\nexport type CheckboxProps = Omit<RsuiteCheckboxProps, 'checked' | 'id' | 'onChange'> & {\n label: string\n name: string\n onChange?: (isCheched: boolean) => Promisable<void>\n}\nexport function Checkbox({ label, onChange, ...originalProps }: CheckboxProps) {\n const key = useMemo(\n () => `${originalProps.name}-${String(originalProps.defaultChecked)}`,\n [originalProps.defaultChecked, originalProps.name]\n )\n\n const handleChange = useCallback(\n (_: ValueType | undefined, isChecked: boolean) => {\n if (!onChange) {\n return\n }\n\n onChange(isChecked)\n },\n [onChange]\n )\n\n return (\n <RsuiteCheckbox key={key} id={originalProps.name} onChange={handleChange} {...originalProps}>\n {label}\n </RsuiteCheckbox>\n )\n}\n"],"names":["_jsx","RsuiteCheckbox"],"mappings":";;;;AAYM,SAAU,QAAQ,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,aAAa,EAAiB,EAAA;AAC3E,IAAA,MAAM,GAAG,GAAG,OAAO,CACjB,MAAM,CAAA,EAAG,aAAa,CAAC,IAAI,CAAA,CAAA,EAAI,MAAM,CAAC,aAAa,CAAC,cAAc,CAAC,CAAA,CAAE,EACrE,CAAC,aAAa,CAAC,cAAc,EAAE,aAAa,CAAC,IAAI,CAAC,CACnD,CAAA;IAED,MAAM,YAAY,GAAG,WAAW,CAC9B,CAAC,CAAwB,EAAE,SAAkB,KAAI;QAC/C,IAAI,CAAC,QAAQ,EAAE;YACb,OAAM;AACP,SAAA;QAED,QAAQ,CAAC,SAAS,CAAC,CAAA;AACrB,KAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAA;IAED,QACEA,IAACC,UAAc,EAAA,EAAW,EAAE,EAAE,aAAa,CAAC,IAAI,EAAE,QAAQ,EAAE,YAAY,KAAM,aAAa,EAAA,QAAA,EACxF,KAAK,EADa,EAAA,GAAG,CAEP,EAClB;AACH;;;;"}
@@ -1,9 +1,11 @@
1
- import { jsx } from 'react/jsx-runtime';
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
2
  import { useMemo, useCallback } from 'react';
3
3
  import { TagPicker } from 'rsuite';
4
4
  import styled from 'styled-components';
5
+ import { Field } from '../elements/Field.js';
6
+ import { Label } from '../elements/Label.js';
5
7
 
6
- function MultiSelect({ fixedWidth = 5, onChange, options,
8
+ function MultiSelect({ fixedWidth = 5, isLabelHidden = false, label, onChange, options,
7
9
  // eslint-disable-next-line @typescript-eslint/naming-convention
8
10
  searchable = false, ...originalProps }) {
9
11
  const key = useMemo(() => `${originalProps.name}-${JSON.stringify(originalProps.defaultValue)}`, [originalProps.defaultValue, originalProps.name]);
@@ -14,7 +16,7 @@ searchable = false, ...originalProps }) {
14
16
  const normalizedNextValue = !nextValue || !nextValue.length ? undefined : nextValue;
15
17
  onChange(normalizedNextValue);
16
18
  }, [onChange]);
17
- return (jsx(StyledTagPicker, { data: options, fixedWidth: fixedWidth, onChange: handleChange, searchable: searchable, ...originalProps }, key));
19
+ return (jsxs(Field, { children: [jsx(Label, { htmlFor: originalProps.name, isHidden: isLabelHidden, children: label }), jsx(StyledTagPicker, { data: options, fixedWidth: fixedWidth, id: originalProps.name, onChange: handleChange, searchable: searchable, ...originalProps }, key)] }));
18
20
  }
19
21
  // TODO A width seems to be mandatory in rsuite which is a very dirty behavior.
20
22
  // We should hack that.
@@ -1 +1 @@
1
- {"version":3,"file":"MultiSelect.js","sources":["../../../src/fields/MultiSelect.tsx"],"sourcesContent":["import { useCallback, useMemo } from 'react'\nimport { TagPicker } from 'rsuite'\nimport styled from 'styled-components'\n\nimport type { Option } from '../types'\nimport type { TagPickerProps } from 'rsuite'\nimport type { Promisable } from 'type-fest'\n\nexport type MultiSelectProps = Omit<TagPickerProps, 'as' | 'data' | 'defaultValue' | 'onChange' | 'value'> & {\n defaultValue?: string[]\n /** Width in REM */\n fixedWidth?: number\n name: string\n onChange?: (nextValue: string[] | undefined) => Promisable<void>\n options: Option[]\n}\nexport function MultiSelect({\n fixedWidth = 5,\n onChange,\n options,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n searchable = false,\n ...originalProps\n}: MultiSelectProps) {\n const key = useMemo(\n () => `${originalProps.name}-${JSON.stringify(originalProps.defaultValue)}`,\n [originalProps.defaultValue, originalProps.name]\n )\n\n const handleChange = useCallback(\n (nextValue: string[] | null) => {\n if (!onChange) {\n return\n }\n\n const normalizedNextValue = !nextValue || !nextValue.length ? undefined : nextValue\n\n onChange(normalizedNextValue)\n },\n [onChange]\n )\n\n return (\n <StyledTagPicker\n key={key}\n data={options}\n fixedWidth={fixedWidth}\n onChange={handleChange}\n searchable={searchable}\n {...originalProps}\n />\n )\n}\n\n// TODO A width seems to be mandatory in rsuite which is a very dirty behavior.\n// We should hack that.\nconst StyledTagPicker = styled(TagPicker)<{\n fixedWidth: number\n}>`\n cursor: pointer;\n width: ${p => p.fixedWidth}rem;\n\n > .rs-picker-toggle {\n cursor: inherit;\n }\n`\n"],"names":["_jsx"],"mappings":";;;;;AAgBM,SAAU,WAAW,CAAC,EAC1B,UAAU,GAAG,CAAC,EACd,QAAQ,EACR,OAAO;AACP;AACA,UAAU,GAAG,KAAK,EAClB,GAAG,aAAa,EACC,EAAA;AACjB,IAAA,MAAM,GAAG,GAAG,OAAO,CACjB,MAAM,CAAG,EAAA,aAAa,CAAC,IAAI,CAAI,CAAA,EAAA,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,YAAY,CAAC,CAAE,CAAA,EAC3E,CAAC,aAAa,CAAC,YAAY,EAAE,aAAa,CAAC,IAAI,CAAC,CACjD,CAAA;AAED,IAAA,MAAM,YAAY,GAAG,WAAW,CAC9B,CAAC,SAA0B,KAAI;QAC7B,IAAI,CAAC,QAAQ,EAAE;YACb,OAAM;AACP,SAAA;AAED,QAAA,MAAM,mBAAmB,GAAG,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,SAAS,GAAG,SAAS,CAAA;QAEnF,QAAQ,CAAC,mBAAmB,CAAC,CAAA;AAC/B,KAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAA;IAED,QACEA,GAAC,CAAA,eAAe,EAEd,EAAA,IAAI,EAAE,OAAO,EACb,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,YAAY,EACtB,UAAU,EAAE,UAAU,EAClB,GAAA,aAAa,EALZ,EAAA,GAAG,CAMR,EACH;AACH,CAAC;AAED;AACA;AACA,MAAM,eAAe,GAAG,MAAM,CAAC,SAAS,CAAC,CAEvC,CAAA;;AAES,SAAA,EAAA,CAAC,IAAI,CAAC,CAAC,UAAU,CAAA;;;;;CAK3B;;;;"}
1
+ {"version":3,"file":"MultiSelect.js","sources":["../../../src/fields/MultiSelect.tsx"],"sourcesContent":["import { useCallback, useMemo } from 'react'\nimport { TagPicker } from 'rsuite'\nimport styled from 'styled-components'\n\nimport { Field } from '../elements/Field'\nimport { Label } from '../elements/Label'\n\nimport type { Option } from '../types'\nimport type { TagPickerProps } from 'rsuite'\nimport type { Promisable } from 'type-fest'\n\nexport type MultiSelectProps = Omit<TagPickerProps, 'as' | 'data' | 'defaultValue' | 'id' | 'onChange' | 'value'> & {\n defaultValue?: string[]\n /** Width in REM */\n fixedWidth?: number\n isLabelHidden?: boolean\n label: string\n name: string\n onChange?: (nextValue: string[] | undefined) => Promisable<void>\n options: Option[]\n}\nexport function MultiSelect({\n fixedWidth = 5,\n isLabelHidden = false,\n label,\n onChange,\n options,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n searchable = false,\n ...originalProps\n}: MultiSelectProps) {\n const key = useMemo(\n () => `${originalProps.name}-${JSON.stringify(originalProps.defaultValue)}`,\n [originalProps.defaultValue, originalProps.name]\n )\n\n const handleChange = useCallback(\n (nextValue: string[] | null) => {\n if (!onChange) {\n return\n }\n\n const normalizedNextValue = !nextValue || !nextValue.length ? undefined : nextValue\n\n onChange(normalizedNextValue)\n },\n [onChange]\n )\n\n return (\n <Field>\n <Label htmlFor={originalProps.name} isHidden={isLabelHidden}>\n {label}\n </Label>\n\n <StyledTagPicker\n key={key}\n data={options}\n fixedWidth={fixedWidth}\n id={originalProps.name}\n onChange={handleChange}\n searchable={searchable}\n {...originalProps}\n />\n </Field>\n )\n}\n\n// TODO A width seems to be mandatory in rsuite which is a very dirty behavior.\n// We should hack that.\nconst StyledTagPicker = styled(TagPicker)<{\n fixedWidth: number\n}>`\n cursor: pointer;\n width: ${p => p.fixedWidth}rem;\n\n > .rs-picker-toggle {\n cursor: inherit;\n }\n`\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;SAqBgB,WAAW,CAAC,EAC1B,UAAU,GAAG,CAAC,EACd,aAAa,GA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s, jsx } from 'react/jsx-runtime';
2
2
  import { useMemo, useCallback } from 'react';
3
3
  import { SelectPicker } from 'rsuite';
4
4
  import styled from 'styled-components';
5
+ import { Field } from '../elements/Field.js';
6
+ import { Label } from '../elements/Label.js';
5
7
 
6
- function Select({ onChange, options,
8
+ function Select({ isLabelHidden = false, label, onChange, options,
7
9
  // eslint-disable-next-line @typescript-eslint/naming-convention
8
10
  searchable = false, ...originalProps }) {
9
11
  const key = useMemo(() => `${originalProps.name}-${JSON.stringify(originalProps.defaultValue)}`, [originalProps.defaultValue, originalProps.name]);
@@ -14,10 +16,10 @@ searchable = false, ...originalProps }) {
14
16
  const normalizedNextValue = nextValue ?? undefined;
15
17
  onChange(normalizedNextValue);
16
18
  }, [onChange]);
17
- return (jsx(StyledSelectPicker, { data: options,
18
- // The `unknown` type from Rsuite library is wrong. It should be inferred from `data` prop type.
19
- // `onChange: ((value: unknown, event: React.SyntheticEvent<Element, Event>) => void) | undefined`
20
- onChange: handleChange, searchable: searchable, ...originalProps }, key));
19
+ return (jsxs(Field, { children: [jsx(Label, { htmlFor: originalProps.name, isHidden: isLabelHidden, children: label }), jsx(StyledSelectPicker, { data: options, id: originalProps.name,
20
+ // The `unknown` type from Rsuite library is wrong. It should be inferred from `data` prop type.
21
+ // `onChange: ((value: unknown, event: React.SyntheticEvent<Element, Event>) => void) | undefined`
22
+ onChange: handleChange, searchable: searchable, ...originalProps }, key)] }));
21
23
  }
22
24
  const StyledSelectPicker = styled(SelectPicker) ``;
23
25
 
@@ -1 +1 @@
1
- {"version":3,"file":"Select.js","sources":["../../../src/fields/Select.tsx"],"sourcesContent":["import { useCallback, useMemo } from 'react'\nimport { SelectPicker } from 'rsuite'\nimport styled from 'styled-components'\n\nimport type { Option } from '../types'\nimport type { SelectPickerProps } from 'rsuite'\nimport type { Promisable } from 'type-fest'\n\nexport type SelectProps = Omit<SelectPickerProps<any>, 'as' | 'data' | 'defaultValue' | 'onChange' | 'value'> & {\n defaultValue?: string\n name: string\n onChange?: (nextValue: string | undefined) => Promisable<void>\n options: Option[]\n}\nexport function Select({\n onChange,\n options,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n searchable = false,\n ...originalProps\n}: SelectProps) {\n const key = useMemo(\n () => `${originalProps.name}-${JSON.stringify(originalProps.defaultValue)}`,\n [originalProps.defaultValue, originalProps.name]\n )\n\n const handleChange = useCallback(\n (nextValue: string | null) => {\n if (!onChange) {\n return\n }\n\n const normalizedNextValue = nextValue ?? undefined\n\n onChange(normalizedNextValue)\n },\n [onChange]\n )\n\n return (\n <StyledSelectPicker\n key={key}\n data={options}\n // The `unknown` type from Rsuite library is wrong. It should be inferred from `data` prop type.\n // `onChange: ((value: unknown, event: React.SyntheticEvent<Element, Event>) => void) | undefined`\n onChange={handleChange as any}\n searchable={searchable}\n {...originalProps}\n />\n )\n}\n\nconst StyledSelectPicker = styled(SelectPicker)``\n"],"names":["_jsx"],"mappings":";;;;;SAcgB,MAAM,CAAC,EACrB,QAAQ,EACR,OAAO;AACP;AACA,UAAU,GAAG,KAAK,EAClB,GAAG,aAAa,EACJ,EAAA;AACZ,IAAA,MAAM,GAAG,GAAG,OAAO,CACjB,MAAM,CAAG,EAAA,aAAa,CAAC,IAAI,CAAI,CAAA,EAAA,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,YAAY,CAAC,CAAE,CAAA,EAC3E,CAAC,aAAa,CAAC,YAAY,EAAE,aAAa,CAAC,IAAI,CAAC,CACjD,CAAA;AAED,IAAA,MAAM,YAAY,GAAG,WAAW,CAC9B,CAAC,SAAwB,KAAI;QAC3B,IAAI,CAAC,QAAQ,EAAE;YACb,OAAM;AACP,SAAA;AAED,QAAA,MAAM,mBAAmB,GAAG,SAAS,IAAI,SAAS,CAAA;QAElD,QAAQ,CAAC,mBAAmB,CAAC,CAAA;AAC/B,KAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAA;AAED,IAAA,QACEA,GAAC,CAAA,kBAAkB,EAEjB,EAAA,IAAI,EAAE,OAAO;;;AAGb,QAAA,QAAQ,EAAE,YAAmB,EAC7B,UAAU,EAAE,UAAU,EAClB,GAAA,aAAa,EANZ,EAAA,GAAG,CAOR,EACH;AACH,CAAC;AAED,MAAM,kBAAkB,GAAG,MAAM,CAAC,YAAY,CAAC,CAAA,EAAE;;;;"}
1
+ {"version":3,"file":"Select.js","sources":["../../../src/fields/Select.tsx"],"sourcesContent":["import { useCallback, useMemo } from 'react'\nimport { SelectPicker } from 'rsuite'\nimport styled from 'styled-components'\n\nimport { Field } from '../elements/Field'\nimport { Label } from '../elements/Label'\n\nimport type { Option } from '../types'\nimport type { SelectPickerProps } from 'rsuite'\nimport type { Promisable } from 'type-fest'\n\nexport type SelectProps = Omit<SelectPickerProps<any>, 'as' | 'data' | 'defaultValue' | 'id' | 'onChange' | 'value'> & {\n defaultValue?: string\n isLabelHidden?: boolean\n label: string\n name: string\n onChange?: (nextValue: string | undefined) => Promisable<void>\n options: Option[]\n}\nexport function Select({\n isLabelHidden = false,\n label,\n onChange,\n options,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n searchable = false,\n ...originalProps\n}: SelectProps) {\n const key = useMemo(\n () => `${originalProps.name}-${JSON.stringify(originalProps.defaultValue)}`,\n [originalProps.defaultValue, originalProps.name]\n )\n\n const handleChange = useCallback(\n (nextValue: string | null) => {\n if (!onChange) {\n return\n }\n\n const normalizedNextValue = nextValue ?? undefined\n\n onChange(normalizedNextValue)\n },\n [onChange]\n )\n\n return (\n <Field>\n <Label htmlFor={originalProps.name} isHidden={isLabelHidden}>\n {label}\n </Label>\n\n <StyledSelectPicker\n key={key}\n data={options}\n id={originalProps.name}\n // The `unknown` type from Rsuite library is wrong. It should be inferred from `data` prop type.\n // `onChange: ((value: unknown, event: React.SyntheticEvent<Element, Event>) => void) | undefined`\n onChange={handleChange as any}\n searchable={searchable}\n {...originalProps}\n />\n </Field>\n )\n}\n\nconst StyledSelectPicker = styled(SelectPicker)``\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;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
  import { Input } from 'rsuite';
4
4
  import styled from 'styled-components';
5
+ import { Field } from '../elements/Field.js';
6
+ import { Label } from '../elements/Label.js';
5
7
 
6
- function TextInput({ onChange, ...originalProps }) {
8
+ function TextInput({ isLabelHidden = false, label, onChange, ...originalProps }) {
7
9
  const key = useMemo(() => `${originalProps.name}-${JSON.stringify(originalProps.defaultValue)}`, [originalProps.defaultValue, originalProps.name]);
8
10
  const handleChange = useCallback((nextValue) => {
9
11
  if (!onChange) {
@@ -12,10 +14,11 @@ function TextInput({ onChange, ...originalProps }) {
12
14
  const normalizedNextValue = nextValue && nextValue.trim().length ? nextValue : undefined;
13
15
  onChange(normalizedNextValue);
14
16
  }, [onChange]);
15
- return jsx(StyledInput, { onChange: handleChange, ...originalProps }, key);
17
+ return (jsxs(Field, { children: [jsx(Label, { htmlFor: originalProps.name, isHidden: isLabelHidden, children: label }), jsx(StyledInput, { id: originalProps.name, onChange: handleChange, ...originalProps }, key)] }));
16
18
  }
17
19
  const StyledInput = styled(Input) `
18
- background-color: ${p => p.theme.color.white};
20
+ background-color: ${p => p.theme.color.gainsboro};
21
+ width: 100%;
19
22
  `;
20
23
 
21
24
  export { StyledInput, TextInput };
@@ -1 +1 @@
1
- {"version":3,"file":"TextInput.js","sources":["../../../src/fields/TextInput.tsx"],"sourcesContent":["import { useCallback, useMemo } from 'react'\nimport { Input } from 'rsuite'\nimport styled from 'styled-components'\n\nimport type { InputProps } from 'rsuite'\nimport type { Promisable } from 'type-fest'\n\nexport type TextInputProps = Omit<InputProps, 'as' | 'defaultValue' | 'onChange' | 'value'> & {\n defaultValue?: string\n name: string\n onChange?: (nextValue: string | undefined) => Promisable<void>\n}\nexport function TextInput({ onChange, ...originalProps }: TextInputProps) {\n const key = useMemo(\n () => `${originalProps.name}-${JSON.stringify(originalProps.defaultValue)}`,\n [originalProps.defaultValue, originalProps.name]\n )\n\n const handleChange = useCallback(\n (nextValue: string | null) => {\n if (!onChange) {\n return\n }\n\n const normalizedNextValue = nextValue && nextValue.trim().length ? nextValue : undefined\n\n onChange(normalizedNextValue)\n },\n [onChange]\n )\n\n return <StyledInput key={key} onChange={handleChange} {...originalProps} />\n}\n\nexport const StyledInput = styled(Input)`\n background-color: ${p => p.theme.color.white};\n`\n"],"names":["_jsx"],"mappings":";;;;;AAYM,SAAU,SAAS,CAAC,EAAE,QAAQ,EAAE,GAAG,aAAa,EAAkB,EAAA;AACtE,IAAA,MAAM,GAAG,GAAG,OAAO,CACjB,MAAM,CAAG,EAAA,aAAa,CAAC,IAAI,CAAI,CAAA,EAAA,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,YAAY,CAAC,CAAE,CAAA,EAC3E,CAAC,aAAa,CAAC,YAAY,EAAE,aAAa,CAAC,IAAI,CAAC,CACjD,CAAA;AAED,IAAA,MAAM,YAAY,GAAG,WAAW,CAC9B,CAAC,SAAwB,KAAI;QAC3B,IAAI,CAAC,QAAQ,EAAE;YACb,OAAM;AACP,SAAA;AAED,QAAA,MAAM,mBAAmB,GAAG,SAAS,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,SAAS,GAAG,SAAS,CAAA;QAExF,QAAQ,CAAC,mBAAmB,CAAC,CAAA;AAC/B,KAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAA;IAED,OAAOA,GAAA,CAAC,WAAW,EAAA,EAAW,QAAQ,EAAE,YAAY,EAAA,GAAM,aAAa,EAAA,EAA9C,GAAG,CAA+C,CAAA;AAC7E,CAAC;MAEY,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA,CAAA;sBAClB,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAA;;;;;"}
1
+ {"version":3,"file":"TextInput.js","sources":["../../../src/fields/TextInput.tsx"],"sourcesContent":["import { useCallback, useMemo } from 'react'\nimport { Input } from 'rsuite'\nimport styled from 'styled-components'\n\nimport { Field } from '../elements/Field'\nimport { Label } from '../elements/Label'\n\nimport type { InputProps } from 'rsuite'\nimport type { Promisable } from 'type-fest'\n\nexport type TextInputProps = Omit<InputProps, 'as' | 'defaultValue' | 'id' | 'onChange' | 'value'> & {\n defaultValue?: string\n isLabelHidden?: boolean\n label: string\n name: string\n onChange?: (nextValue: string | undefined) => Promisable<void>\n}\nexport function TextInput({ isLabelHidden = false, label, onChange, ...originalProps }: TextInputProps) {\n const key = useMemo(\n () => `${originalProps.name}-${JSON.stringify(originalProps.defaultValue)}`,\n [originalProps.defaultValue, originalProps.name]\n )\n\n const handleChange = useCallback(\n (nextValue: string | null) => {\n if (!onChange) {\n return\n }\n\n const normalizedNextValue = nextValue && nextValue.trim().length ? nextValue : undefined\n\n onChange(normalizedNextValue)\n },\n [onChange]\n )\n\n return (\n <Field>\n <Label htmlFor={originalProps.name} isHidden={isLabelHidden}>\n {label}\n </Label>\n\n <StyledInput key={key} id={originalProps.name} onChange={handleChange} {...originalProps} />\n </Field>\n )\n}\n\nexport const StyledInput = styled(Input)`\n background-color: ${p => p.theme.color.gainsboro};\n width: 100%;\n`\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;AAiBgB,SAAA,SAAS,CAAC,EAAE,aAAa,GAAG,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,aAAa,EAAkB,EAAA;AACpG,IAAA,MAAM,GAAG,GAAG,OAAO,CACjB,MAAM,CAAG,EAAA,aAAa,CAAC,IAAI,CAAI,CAAA,EAAA,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,YAAY,CAAC,CAAE,CAAA,EAC3E,CAAC,aAAa,CAAC,YAAY,EAAE,aAAa,CAAC,IAAI,CAAC,CACjD,CAAA;AAED,IAAA,MAAM,YAAY,GAAG,WAAW,CAC9B,CAAC,SAAwB,KAAI;QAC3B,IAAI,CAAC,QAAQ,EAAE;YACb,OAAM;AACP,SAAA;AAED,QAAA,MAAM,mBAAmB,GAAG,SAAS,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,SAAS,GAAG,SAAS,CAAA;QAExF,QAAQ,CAAC,mBAAmB,CAAC,CAAA;AAC/B,KAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAA;AAED,IAAA,QACEA,IAAC,CAAA,KAAK,EACJ,EAAA,QAAA,EAAA,CAAAC,GAAA,CAAC,KAAK,EAAC,EAAA,OAAO,EAAE,aAAa,CAAC,IAAI,EAAE,QAAQ,EAAE,aAAa,YACxD,KAAK,EAAA,CACA,EAERA,GAAA,CAAC,WAAW,EAAW,EAAA,EAAE,EAAE,aAAa,CAAC,IAAI,EAAE,QAAQ,EAAE,YAAY,KAAM,aAAa,EAAA,EAAtE,GAAG,CAAuE,CAAA,EAAA,CACtF,EACT;AACH,CAAC;MAEY,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA,CAAA;sBAClB,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAA;;;;;;"}
@@ -1,9 +1,11 @@
1
- import { jsx } from 'react/jsx-runtime';
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
2
  import { useRef, useMemo, useCallback } from 'react';
3
3
  import { Input } from 'rsuite';
4
4
  import styled from 'styled-components';
5
+ import { Field } from '../elements/Field.js';
6
+ import { Label } from '../elements/Label.js';
5
7
 
6
- function Textarea({ onChange, rows = 3, ...originalProps }) {
8
+ function Textarea({ isLabelHidden = false, label, onChange, rows = 3, ...originalProps }) {
7
9
  const inputRef = useRef();
8
10
  const key = useMemo(() => `${originalProps.name}-${JSON.stringify(originalProps.defaultValue)}`, [originalProps.defaultValue, originalProps.name]);
9
11
  const handleChange = useCallback(() => {
@@ -14,9 +16,13 @@ function Textarea({ onChange, rows = 3, ...originalProps }) {
14
16
  const normalizedNextValue = nextValue.length ? nextValue : undefined;
15
17
  onChange(normalizedNextValue);
16
18
  }, [onChange]);
17
- return jsx(StyledInput, { ref: inputRef, as: "textarea", onChange: handleChange, rows: rows, ...originalProps }, key);
19
+ return (jsxs(Field, { children: [jsx(Label, { htmlFor: originalProps.name, isHidden: isLabelHidden, children: label }), jsx(StyledInput, { ref: inputRef, as: "textarea", id: originalProps.name, onChange: handleChange, rows: rows, ...originalProps }, key)] }));
18
20
  }
19
- const StyledInput = styled(Input) ``;
21
+ const StyledInput = styled(Input) `
22
+ background-color: ${p => p.theme.color.gainsboro};
23
+ border: 0;
24
+ width: 100%;
25
+ `;
20
26
 
21
27
  export { StyledInput, Textarea };
22
28
  //# sourceMappingURL=Textarea.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Textarea.js","sources":["../../../src/fields/Textarea.tsx"],"sourcesContent":["import { useCallback, useMemo, useRef } from 'react'\nimport { Input } from 'rsuite'\nimport styled from 'styled-components'\n\nimport type { MutableRefObject, TextareaHTMLAttributes } from 'react'\nimport type { Promisable } from 'type-fest'\n\nexport type TextareaProps = Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'defaultValue' | 'onChange' | 'value'> & {\n defaultValue?: string\n name: string\n onChange?: (nextValue: string | undefined) => Promisable<void>\n}\nexport function Textarea({ onChange, rows = 3, ...originalProps }: TextareaProps) {\n const inputRef = useRef() as MutableRefObject<HTMLTextAreaElement>\n\n const key = useMemo(\n () => `${originalProps.name}-${JSON.stringify(originalProps.defaultValue)}`,\n [originalProps.defaultValue, originalProps.name]\n )\n\n const handleChange = useCallback(() => {\n if (!onChange) {\n return\n }\n\n const nextValue = inputRef.current.value.trim()\n const normalizedNextValue = nextValue.length ? nextValue : undefined\n\n onChange(normalizedNextValue)\n }, [onChange])\n\n return <StyledInput key={key} ref={inputRef} as=\"textarea\" onChange={handleChange} rows={rows} {...originalProps} />\n}\n\nexport const StyledInput = styled(Input)``\n"],"names":["_jsx"],"mappings":";;;;;AAYgB,SAAA,QAAQ,CAAC,EAAE,QAAQ,EAAE,IAAI,GAAG,CAAC,EAAE,GAAG,aAAa,EAAiB,EAAA;AAC9E,IAAA,MAAM,QAAQ,GAAG,MAAM,EAA2C,CAAA;AAElE,IAAA,MAAM,GAAG,GAAG,OAAO,CACjB,MAAM,CAAG,EAAA,aAAa,CAAC,IAAI,CAAI,CAAA,EAAA,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,YAAY,CAAC,CAAE,CAAA,EAC3E,CAAC,aAAa,CAAC,YAAY,EAAE,aAAa,CAAC,IAAI,CAAC,CACjD,CAAA;AAED,IAAA,MAAM,YAAY,GAAG,WAAW,CAAC,MAAK;QACpC,IAAI,CAAC,QAAQ,EAAE;YACb,OAAM;AACP,SAAA;QAED,MAAM,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,CAAA;AAC/C,QAAA,MAAM,mBAAmB,GAAG,SAAS,CAAC,MAAM,GAAG,SAAS,GAAG,SAAS,CAAA;QAEpE,QAAQ,CAAC,mBAAmB,CAAC,CAAA;AAC/B,KAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAA;IAEd,OAAOA,GAAA,CAAC,WAAW,EAAW,EAAA,GAAG,EAAE,QAAQ,EAAE,EAAE,EAAC,UAAU,EAAC,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,KAAM,aAAa,EAAA,EAAvF,GAAG,CAAwF,CAAA;AACtH,CAAC;AAEY,MAAA,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"Textarea.js","sources":["../../../src/fields/Textarea.tsx"],"sourcesContent":["import { useCallback, useMemo, useRef } from 'react'\nimport { Input } from 'rsuite'\nimport styled from 'styled-components'\n\nimport { Field } from '../elements/Field'\nimport { Label } from '../elements/Label'\n\nimport type { MutableRefObject, TextareaHTMLAttributes } from 'react'\nimport type { Promisable } from 'type-fest'\n\nexport type TextareaProps = Omit<\n TextareaHTMLAttributes<HTMLTextAreaElement>,\n 'defaultValue' | 'id' | 'onChange' | 'value'\n> & {\n defaultValue?: string\n isLabelHidden?: boolean\n label: string\n name: string\n onChange?: (nextValue: string | undefined) => Promisable<void>\n}\nexport function Textarea({ isLabelHidden = false, label, onChange, rows = 3, ...originalProps }: TextareaProps) {\n const inputRef = useRef() as MutableRefObject<HTMLTextAreaElement>\n\n const key = useMemo(\n () => `${originalProps.name}-${JSON.stringify(originalProps.defaultValue)}`,\n [originalProps.defaultValue, originalProps.name]\n )\n\n const handleChange = useCallback(() => {\n if (!onChange) {\n return\n }\n\n const nextValue = inputRef.current.value.trim()\n const normalizedNextValue = nextValue.length ? nextValue : undefined\n\n onChange(normalizedNextValue)\n }, [onChange])\n\n return (\n <Field>\n <Label htmlFor={originalProps.name} isHidden={isLabelHidden}>\n {label}\n </Label>\n\n <StyledInput\n key={key}\n ref={inputRef}\n as=\"textarea\"\n id={originalProps.name}\n onChange={handleChange}\n rows={rows}\n {...originalProps}\n />\n </Field>\n )\n}\n\nexport const StyledInput = styled(Input)`\n background-color: ${p => p.theme.color.gainsboro};\n border: 0;\n width: 100%;\n`\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;SAoBgB,QAAQ,CAAC,EAAE,aAAa,GAAG,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,GAAG,CAAC,EAAE,GAAG,aAAa,EAAiB,EAAA;AAC5G,IAAA,MAAM,QAAQ,GAAG,MAAM,EAA2C,CAAA;AAElE,IAAA,MAAM,GAAG,GAAG,OAAO,CACjB,MAAM,CAAG,EAAA,aAAa,CAAC,IAAI,CAAI,CAAA,EAAA,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,YAAY,CAAC,CAAE,CAAA,EAC3E,CAAC,aAAa,CAAC,YAAY,EAAE,aAAa,CAAC,IAAI,CAAC,CACjD,CAAA;AAED,IAAA,MAAM,YAAY,GAAG,WAAW,CAAC,MAAK;QACpC,IAAI,CAAC,QAAQ,EAAE;YACb,OAAM;AACP,SAAA;QAED,MAAM,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,CAAA;AAC/C,QAAA,MAAM,mBAAmB,GAAG,SAAS,CAAC,MAAM,GAAG,SAAS,GA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