@agility/plenum-ui 2.1.28 → 2.2.1

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.
Files changed (31) hide show
  1. package/.storybook/preview.tsx +7 -6
  2. package/dist/index.d.ts +111 -5
  3. package/dist/index.js +1 -1
  4. package/dist/index.js.map +4 -4
  5. package/dist/tailwind.css +65 -1
  6. package/dist/types/stories/atoms/Typography/Heading/Heading.d.ts +8 -0
  7. package/dist/types/stories/atoms/Typography/Heading/Heading.stories.d.ts +12 -0
  8. package/dist/types/stories/atoms/Typography/Heading/index.d.ts +3 -0
  9. package/dist/types/stories/atoms/Typography/Label/Label.d.ts +10 -0
  10. package/dist/types/stories/atoms/Typography/Label/Label.stories.d.ts +12 -0
  11. package/dist/types/stories/atoms/Typography/Label/index.d.ts +3 -0
  12. package/dist/types/stories/atoms/Typography/Paragraph/Paragraph.d.ts +10 -0
  13. package/dist/types/stories/atoms/Typography/Paragraph/Paragraph.stories.d.ts +11 -0
  14. package/dist/types/stories/atoms/Typography/Paragraph/index.d.ts +3 -0
  15. package/dist/types/stories/atoms/index.d.ts +5 -2
  16. package/dist/types/stories/index.d.ts +3 -3
  17. package/dist/types/stories/molecules/inputs/TextInput/TextInput.d.ts +4 -0
  18. package/package.json +1 -1
  19. package/stories/atoms/Typography/Heading/Heading.stories.ts +40 -0
  20. package/stories/atoms/Typography/Heading/Heading.tsx +26 -0
  21. package/stories/atoms/Typography/Heading/index.ts +3 -0
  22. package/stories/atoms/Typography/Label/Label.stories.ts +40 -0
  23. package/stories/atoms/Typography/Label/Label.tsx +25 -0
  24. package/stories/atoms/Typography/Label/index.ts +3 -0
  25. package/stories/atoms/Typography/Paragraph/Paragraph.stories.ts +36 -0
  26. package/stories/atoms/Typography/Paragraph/Paragraph.tsx +24 -0
  27. package/stories/atoms/Typography/Paragraph/index.ts +3 -0
  28. package/stories/atoms/index.ts +16 -8
  29. package/stories/index.ts +15 -3
  30. package/stories/molecules/inputs/TextInput/TextInput.tsx +59 -46
  31. package/tailwind.config.js +1 -1
@@ -1,44 +1,49 @@
1
- import React, { forwardRef, useEffect, useId, useRef, useState } from "react"
2
- import { default as cn } from "classnames"
3
- import InputLabel from "../InputLabel"
4
- import InputField, { AcceptedInputTypes } from "../InputField"
5
- import InputCounter from "../InputCounter"
1
+ import React, { forwardRef, useEffect, useId, useRef, useState } from "react";
2
+ import { default as cn } from "classnames";
3
+ import InputLabel from "../InputLabel";
4
+ import InputField, { AcceptedInputTypes } from "../InputField";
5
+ import InputCounter from "../InputCounter";
6
6
 
7
7
  export interface ITextInputProps {
8
8
  /** Input type*/
9
- type: AcceptedInputTypes
9
+ type: AcceptedInputTypes;
10
10
  /** Input ID */
11
- id?: string
11
+ id?: string;
12
12
  /** Input Name */
13
- name?: string
13
+ name?: string;
14
14
  /** Label for the input */
15
- label?: string
15
+ label?: string;
16
16
  /** Force the focus state on the input */
17
- isFocused?: boolean
17
+ isFocused?: boolean;
18
18
  /** Error state */
19
- isError?: boolean
19
+ isError?: boolean;
20
20
  /** If field is required */
21
- isRequired?: boolean
21
+ isRequired?: boolean;
22
22
  /** Disabled state */
23
- isDisabled?: boolean
23
+ isDisabled?: boolean;
24
24
  /** Readonly state */
25
- isReadonly?: boolean
25
+ isReadonly?: boolean;
26
26
  /** Set default value */
27
- defaultValue?: string
27
+ defaultValue?: string;
28
28
  /** Message shown under the text field */
29
- message?: string
29
+ message?: string;
30
30
  /** Input character counter */
31
- isShowCounter?: boolean
31
+ isShowCounter?: boolean;
32
32
  /** Max length of input character */
33
- maxLength?: number
33
+ maxLength?: number;
34
34
  /** Callback on change */
35
- handleChange(value: string): void
35
+ handleChange(value: string): void;
36
36
  /** input value */
37
- value: string
37
+ value: string;
38
38
  /**Placeholder input text*/
39
- placeholder?: string
39
+ placeholder?: string;
40
40
 
41
- className?: string
41
+ className?: string;
42
+
43
+ /** Callback on focus */
44
+ onFocus?: React.FocusEventHandler<HTMLInputElement>;
45
+ /** Callback on blur */
46
+ onBlur?: React.FocusEventHandler<HTMLInputElement>;
42
47
  }
43
48
 
44
49
  const TextInput = (
@@ -60,48 +65,56 @@ const TextInput = (
60
65
  placeholder,
61
66
  value: externalValue,
62
67
  className,
68
+ onFocus,
69
+ onBlur,
63
70
  ...props
64
71
  }: ITextInputProps,
65
72
  ref: React.Ref<HTMLInputElement>
66
73
  ) => {
67
- const uniqueID = useId()
68
- const [isFocus, setIsFocus] = useState<boolean>(Boolean(isFocused))
74
+ const uniqueID = useId();
75
+ const [isFocus, setIsFocus] = useState<boolean>(Boolean(isFocused));
69
76
 
70
- const [value, setValue] = useState<string>(externalValue || defaultValue || "")
71
- const inputRef = useRef<HTMLInputElement>(null)
77
+ const [value, setValue] = useState<string>(externalValue || defaultValue || "");
78
+ const inputRef = useRef<HTMLInputElement>(null);
72
79
 
73
80
  useEffect(() => {
74
81
  //if the external value is updated by the parent component, reset the value in here...
75
82
  if (externalValue !== undefined && externalValue !== null) {
76
- setValue(externalValue)
83
+ setValue(externalValue);
77
84
  }
78
- }, [externalValue])
85
+ }, [externalValue]);
79
86
 
80
87
  // set force focus
81
88
  useEffect(() => {
82
- const input = inputRef.current
83
- if (!input || isFocus === undefined || isDisabled) return
89
+ const input = inputRef.current;
90
+ if (!input || isFocus === undefined || isDisabled) return;
84
91
  if (isFocus) {
85
- input.focus()
92
+ input.focus();
86
93
  } else {
87
- input.blur()
94
+ input.blur();
88
95
  }
89
96
  // eslint-disable-next-line react-hooks/exhaustive-deps
90
- }, [isFocus])
97
+ }, [isFocus]);
91
98
 
92
99
  // set label as active if default value is set
93
100
  useEffect(() => {
94
- const input = inputRef.current
95
- if (!input || defaultValue === undefined || defaultValue === "") return
96
- }, [defaultValue])
101
+ const input = inputRef.current;
102
+ if (!input || defaultValue === undefined || defaultValue === "") return;
103
+ }, [defaultValue]);
97
104
 
98
- const handleInputFocus = () => setIsFocus(true)
105
+ const handleInputFocus = (e: React.FocusEvent<HTMLInputElement>) => {
106
+ setIsFocus(true);
107
+ if (onFocus) onFocus(e);
108
+ };
99
109
  // add other focus effects here
100
110
 
101
- const handleInputBlur = () => setIsFocus(false)
111
+ const handleInputBlur = (e: React.FocusEvent<HTMLInputElement>) => {
112
+ setIsFocus(false);
113
+ if (onBlur) onBlur(e);
114
+ };
102
115
 
103
- if (!id) id = `input-${uniqueID}`
104
- if (!name) name = id
116
+ if (!id) id = `input-${uniqueID}`;
117
+ if (!name) name = id;
105
118
 
106
119
  return (
107
120
  <div className="relative group">
@@ -118,8 +131,8 @@ const TextInput = (
118
131
  onFocus={handleInputFocus}
119
132
  onBlur={handleInputBlur}
120
133
  handleChange={(v: string) => {
121
- setValue(v)
122
- handleChange(v)
134
+ setValue(v);
135
+ handleChange(v);
123
136
  }}
124
137
  ref={ref}
125
138
  type={type}
@@ -163,8 +176,8 @@ const TextInput = (
163
176
  )}
164
177
  </div>
165
178
  </div>
166
- )
167
- }
179
+ );
180
+ };
168
181
 
169
- const _TextInput = forwardRef<HTMLInputElement, ITextInputProps>(TextInput)
170
- export default _TextInput
182
+ const _TextInput = forwardRef<HTMLInputElement, ITextInputProps>(TextInput);
183
+ export default _TextInput;
@@ -218,7 +218,7 @@ module.exports = {
218
218
  "rose-900": "#881337"
219
219
  },
220
220
  fontWeight: {
221
- medium: 600
221
+ medium: 500
222
222
  },
223
223
  fontSize: {
224
224
  xs: ["0.75rem", "1rem"],