@agility/plenum-ui 2.0.0-rc11 → 2.0.0-rc13

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.
@@ -0,0 +1,61 @@
1
+ import React from "react"
2
+ import { default as cn } from "classnames"
3
+
4
+ import TextArea, { ITextareaProps } from "@/stories/molecules/inputs/textArea"
5
+
6
+ export interface IAnimatedLabelTextAreaProps extends ITextareaProps {
7
+ id: string
8
+ containerStyles?: string
9
+ message?: string
10
+ required?: boolean
11
+ isError?: boolean
12
+ handleChange: (value: string) => void
13
+ }
14
+
15
+ const AnimatedLabelTextArea: React.FC<IAnimatedLabelTextAreaProps> = (props: IAnimatedLabelTextAreaProps) => {
16
+ const { id, containerStyles, message, required, isError, label, value, handleChange, ...input } = props
17
+
18
+ const [hasValue, setHasValue] = React.useState<boolean>(!!value)
19
+
20
+ return (
21
+ <div className={cn("group relative", containerStyles ? containerStyles : "")}>
22
+ <TextArea
23
+ id={id}
24
+ isError={isError}
25
+ value={value}
26
+ onChange={(v) => {
27
+ setHasValue(!!v)
28
+ if (handleChange) handleChange(v)
29
+ }}
30
+ {...input}
31
+ label={undefined}
32
+ />
33
+ <label
34
+ className={cn(
35
+ "absolute z-10 ml-[3px] inline-block bg-white text-sm transition-all text-gray-500 left-1 px-1",
36
+ hasValue ? "!-top-[8px] !ml-[.172rem] !text-xs text-gray-600" : "top-[9px]",
37
+ "peer-placeholder-shown:!-top-[8px] peer-placeholder-shown:!ml-[.172rem] peer-placeholder-shown:!text-xs peer-placeholder-shown:text-gray-600",
38
+ "group-focus-within:!-top-[8px] group-focus-within:!ml-[.172rem] group-focus-within:!text-xs group-focus-within:text-gray-600",
39
+
40
+ isError && "!text-red-600"
41
+ )}
42
+ htmlFor={id}
43
+ >
44
+ {label}
45
+ {required && <span className="text-red-600 ml-1">*</span>}
46
+ </label>
47
+
48
+ <div className="flex flex-row space-x-3">
49
+ <div className="grow transition-all">
50
+ {message && (
51
+ <span className={cn("mt-1 block text-sm", isError ? "text-red-500" : "text-gray-500")}>
52
+ {message}
53
+ </span>
54
+ )}
55
+ </div>
56
+ </div>
57
+ </div>
58
+ )
59
+ }
60
+
61
+ export default AnimatedLabelTextArea
@@ -0,0 +1,3 @@
1
+ import AnimatedLabelTextArea, { IAnimatedLabelTextAreaProps } from "./AnimatedLabelTextArea"
2
+ export type { IAnimatedLabelTextAreaProps }
3
+ export default AnimatedLabelTextArea
@@ -1,4 +1,5 @@
1
1
  import AnimatedLabelInput, { IAnimatedLabelInputProps } from "./AnimatedLabelInput"
2
+ import AnimatedLabelTextArea, { IAnimatedLabelTextAreaProps } from "./AnimatedLabelTextArea"
2
3
  import ButtonDropdown, { IButtonDropdownProps } from "./ButtonDropdown"
3
4
  import Dropdown, { IDropdownClassnames, IDropdownProps, IItemProp } from "./DropdownComponent"
4
5
  import EmptySectionPlaceholder, { IEmptySectionPlaceholderProps } from "./EmptySectionPlaceholder"
@@ -7,6 +8,7 @@ import TextInputSelect, { ITextInputSelectProps } from "./TextInputSelect"
7
8
 
8
9
  export type {
9
10
  IAnimatedLabelInputProps,
11
+ IAnimatedLabelTextAreaProps,
10
12
  IButtonDropdownProps,
11
13
  IDropdownClassnames,
12
14
  IDropdownProps,
@@ -15,4 +17,4 @@ export type {
15
17
  IFormInputWithAddonsProps,
16
18
  ITextInputSelectProps
17
19
  }
18
- export { AnimatedLabelInput, ButtonDropdown, Dropdown, EmptySectionPlaceholder, FormInputWithAddons, TextInputSelect }
20
+ export { AnimatedLabelInput, AnimatedLabelTextArea, ButtonDropdown, Dropdown, EmptySectionPlaceholder, FormInputWithAddons, TextInputSelect }