@agility/plenum-ui 2.0.0-rc5 → 2.0.0-rc50

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 (102) hide show
  1. package/README.md +104 -31
  2. package/build.js +30 -25
  3. package/dist/index.d.ts +219 -96
  4. package/dist/index.js +1 -6103
  5. package/dist/index.js.map +4 -4
  6. package/dist/{lib/tailwind.css → tailwind.css} +3717 -8116
  7. package/dist/types/stories/atoms/buttons/Button/Alternative/Alternative.stories.d.ts +1 -0
  8. package/dist/types/stories/atoms/buttons/Button/Button.d.ts +3 -7
  9. package/dist/types/stories/atoms/buttons/Button/Danger/Danger.stories.d.ts +1 -0
  10. package/dist/types/stories/atoms/buttons/Button/Primary/Primary.stories.d.ts +1 -0
  11. package/dist/types/stories/atoms/buttons/Button/Secondary/Secondary.stories.d.ts +1 -0
  12. package/dist/types/stories/atoms/buttons/Capsule/Capsule.d.ts +1 -1
  13. package/dist/types/stories/atoms/icons/DynamicIcon.d.ts +2 -2
  14. package/dist/types/stories/atoms/icons/TablerIcon.d.ts +1 -1
  15. package/dist/types/stories/index.d.ts +4 -4
  16. package/dist/types/stories/molecules/index.d.ts +3 -3
  17. package/dist/types/stories/molecules/inputs/InputField/InputField.d.ts +8 -8
  18. package/dist/types/stories/molecules/inputs/TextInput/TextInput.d.ts +1 -1
  19. package/dist/types/stories/molecules/inputs/index.d.ts +4 -4
  20. package/dist/types/stories/molecules/inputs/select/Select.d.ts +4 -2
  21. package/dist/types/stories/molecules/inputs/textArea/TextArea.d.ts +34 -21
  22. package/dist/types/stories/molecules/inputs/textArea/TextArea.stories.d.ts +4 -4
  23. package/dist/types/stories/molecules/inputs/textArea/index.d.ts +3 -3
  24. package/dist/types/stories/molecules/inputs/toggleSwitch/ToggleSwitch.d.ts +10 -7
  25. package/dist/types/stories/organisms/AnimatedLabelInput/AnimatedLabelInput.d.ts +3 -5
  26. package/dist/types/stories/organisms/AnimatedLabelInput/index.d.ts +1 -1
  27. package/dist/types/stories/organisms/AnimatedLabelTextArea/AnimatedLabelTextArea.d.ts +12 -0
  28. package/dist/types/stories/organisms/AnimatedLabelTextArea/index.d.ts +3 -0
  29. package/dist/types/stories/organisms/DropdownComponent/DropdownComponent.d.ts +24 -13
  30. package/dist/types/stories/organisms/DropdownComponent/index.d.ts +2 -2
  31. package/dist/types/stories/organisms/EmptySectionPlaceholder/index.d.ts +1 -1
  32. package/dist/types/stories/organisms/TextInputSelect/InputSelect.d.ts +16 -0
  33. package/dist/types/stories/organisms/TextInputSelect/TextInputSelect.d.ts +48 -0
  34. package/dist/types/stories/organisms/TextInputSelect/index.d.ts +3 -0
  35. package/dist/types/stories/organisms/index.d.ts +5 -3
  36. package/local.sh +100 -0
  37. package/package.json +35 -18
  38. package/rollup.config.mjs +42 -0
  39. package/stories/atoms/badges/Badge.tsx +1 -1
  40. package/stories/atoms/buttons/Button/Alternative/Alternative.stories.ts +10 -0
  41. package/stories/atoms/buttons/Button/Button.tsx +110 -24
  42. package/stories/atoms/buttons/Button/Danger/Danger.stories.ts +14 -2
  43. package/stories/atoms/buttons/Button/Primary/Primary.stories.ts +14 -2
  44. package/stories/atoms/buttons/Button/Secondary/Secondary.stories.ts +13 -1
  45. package/stories/atoms/buttons/Button/defaultArgs.ts +1 -1
  46. package/stories/atoms/buttons/Capsule/Capsule.tsx +2 -1
  47. package/stories/atoms/icons/DynamicIcon.stories.ts +1 -1
  48. package/stories/atoms/icons/DynamicIcon.tsx +7 -7
  49. package/stories/atoms/icons/IconWithShadow.stories.ts +3 -3
  50. package/stories/atoms/icons/TablerIcon.tsx +1 -1
  51. package/stories/atoms/loaders/Loader.tsx +12 -6
  52. package/stories/atoms/loaders/NProgress/RadialProgress.tsx +0 -2
  53. package/stories/index.ts +22 -10
  54. package/stories/molecules/index.ts +22 -6
  55. package/stories/molecules/inputs/InputField/InputField.tsx +31 -28
  56. package/stories/molecules/inputs/TextInput/TextInput.tsx +6 -3
  57. package/stories/molecules/inputs/checkbox/Checkbox.stories.ts +1 -1
  58. package/stories/molecules/inputs/checkbox/Checkbox.tsx +1 -2
  59. package/stories/molecules/inputs/combobox/ComboBox.tsx +126 -135
  60. package/stories/molecules/inputs/index.ts +5 -4
  61. package/stories/molecules/inputs/radio/Radio.stories.ts +2 -2
  62. package/stories/molecules/inputs/select/Select.tsx +10 -2
  63. package/stories/molecules/inputs/textArea/TextArea.stories.ts +7 -5
  64. package/stories/molecules/inputs/textArea/TextArea.tsx +139 -48
  65. package/stories/molecules/inputs/textArea/index.ts +3 -3
  66. package/stories/molecules/inputs/toggleSwitch/ToggleSwitch.stories.tsx +15 -16
  67. package/stories/molecules/inputs/toggleSwitch/ToggleSwitch.tsx +63 -57
  68. package/stories/molecules/tabs/index.tsx +2 -3
  69. package/stories/organisms/AnimatedLabelInput/AnimatedLabelInput.stories.tsx +10 -1
  70. package/stories/organisms/AnimatedLabelInput/AnimatedLabelInput.tsx +43 -37
  71. package/stories/organisms/AnimatedLabelInput/index.tsx +1 -1
  72. package/stories/organisms/AnimatedLabelTextArea/AnimatedLabelTextArea.stories.tsx +26 -0
  73. package/stories/organisms/AnimatedLabelTextArea/AnimatedLabelTextArea.tsx +61 -0
  74. package/stories/organisms/AnimatedLabelTextArea/index.tsx +3 -0
  75. package/stories/organisms/ButtonDropdown/ButtonDropdown.stories.tsx +65 -58
  76. package/stories/organisms/ButtonDropdown/ButtonDropdown.tsx +26 -21
  77. package/stories/organisms/DropdownComponent/Dropdown.stories.tsx +26 -2
  78. package/stories/organisms/DropdownComponent/DropdownComponent.tsx +225 -179
  79. package/stories/organisms/DropdownComponent/dropdownItems.ts +30 -9
  80. package/stories/organisms/DropdownComponent/index.ts +2 -2
  81. package/stories/organisms/EmptySectionPlaceholder/EmptySectionPlaceholder.stories.tsx +3 -3
  82. package/stories/organisms/EmptySectionPlaceholder/index.tsx +2 -1
  83. package/stories/organisms/FormInputWithAddons/FormInputWithAddons.stories.tsx +1 -1
  84. package/stories/organisms/FormInputWithAddons/FormInputWithAddons.tsx +7 -2
  85. package/stories/organisms/TextInputSelect/InputSelect.tsx +59 -0
  86. package/stories/organisms/TextInputSelect/TextInputSelect.stories.tsx +33 -0
  87. package/stories/organisms/TextInputSelect/TextInputSelect.tsx +186 -0
  88. package/stories/organisms/TextInputSelect/index.tsx +3 -0
  89. package/stories/organisms/index.ts +15 -4
  90. package/tailwind.config.js +81 -37
  91. package/tsconfig.lib.json +13 -6
  92. package/watch.js +49 -0
  93. package/.yarnrc.yml +0 -1
  94. package/dist/types/stories/layouts/index.d.ts +0 -0
  95. package/stories/layouts/CardLayout/CardLayout.stories.tsx +0 -18
  96. package/stories/layouts/CardLayout/CardLayout.tsx +0 -22
  97. package/stories/layouts/CardLayout/index.tsx +0 -3
  98. package/stories/layouts/ModalLayout/ModalLayout.stories.tsx +0 -18
  99. package/stories/layouts/ModalLayout/ModalLayout.tsx +0 -22
  100. package/stories/layouts/ModalLayout/index.tsx +0 -3
  101. package/stories/layouts/index.ts +0 -0
  102. package/stories/organisms/DropdownComponent/Dropdown.test.tsx +0 -0
package/stories/index.ts CHANGED
@@ -34,7 +34,7 @@ import {
34
34
  INestedInputButtonProps,
35
35
  IRadioProps,
36
36
  ISelectProps,
37
- ITextAreaFieldProps,
37
+ ITextareaProps,
38
38
  IToggleSwitchProps,
39
39
  AcceptedInputTypes,
40
40
  Checkbox,
@@ -44,14 +44,18 @@ import {
44
44
  NestedInputButton,
45
45
  Radio,
46
46
  Select,
47
- TextAreaField,
48
- ToggleSwitch
47
+ Textarea,
48
+ ToggleSwitch,
49
+ TextInput,
50
+ ITextInputProps,
51
+ ISimpleSelectOptions
49
52
  } from "./molecules"
50
53
  // Organism Components, props, and type gaurds.
51
54
  import {
52
55
  IAnimatedLabelInputProps,
56
+ AnimatedLabelTextArea,
57
+ IAnimatedLabelTextAreaProps,
53
58
  IButtonDropdownProps,
54
- IDropdownClassnames,
55
59
  IDropdownProps,
56
60
  IEmptySectionPlaceholderProps,
57
61
  IItemProp,
@@ -60,7 +64,9 @@ import {
60
64
  ButtonDropdown,
61
65
  Dropdown,
62
66
  EmptySectionPlaceholder,
63
- FormInputWithAddons
67
+ FormInputWithAddons,
68
+ TextInputSelect,
69
+ ITextInputSelectProps
64
70
  } from "./organisms"
65
71
 
66
72
  export type {
@@ -68,6 +74,7 @@ export type {
68
74
  IBadgeProps,
69
75
  IButtonProps,
70
76
  ICapsuleProps,
77
+ ITextInputSelectProps,
71
78
  IDynamicIconProps,
72
79
  IIconWithShadowProps,
73
80
  ILoaderProps,
@@ -79,12 +86,12 @@ export type {
79
86
  INestedInputButtonProps,
80
87
  IRadioProps,
81
88
  ISelectProps,
82
- ITextAreaFieldProps,
89
+ ITextareaProps,
83
90
  IToggleSwitchProps,
84
91
  AcceptedInputTypes,
85
92
  IAnimatedLabelInputProps,
93
+ IAnimatedLabelTextAreaProps,
86
94
  IButtonDropdownProps,
87
- IDropdownClassnames,
88
95
  IDropdownProps,
89
96
  IEmptySectionPlaceholderProps,
90
97
  IItemProp,
@@ -92,7 +99,9 @@ export type {
92
99
  UnifiedIconName,
93
100
  IconName,
94
101
  FAIconName,
95
- BTNActionType
102
+ BTNActionType,
103
+ ITextInputProps,
104
+ ISimpleSelectOptions
96
105
  }
97
106
  export {
98
107
  Avatar,
@@ -103,9 +112,10 @@ export {
103
112
  NestedInputButton,
104
113
  Radio,
105
114
  Select,
106
- TextAreaField,
115
+ Textarea,
107
116
  ToggleSwitch,
108
117
  AnimatedLabelInput,
118
+ AnimatedLabelTextArea,
109
119
  ButtonDropdown,
110
120
  Dropdown,
111
121
  EmptySectionPlaceholder,
@@ -120,5 +130,7 @@ export {
120
130
  isFAIcon,
121
131
  isHeroIcon,
122
132
  isTablerIcon,
123
- isUnifiedIconName
133
+ isUnifiedIconName,
134
+ TextInput,
135
+ TextInputSelect
124
136
  }
@@ -6,7 +6,8 @@ import {
6
6
  INestedInputButtonProps,
7
7
  IRadioProps,
8
8
  ISelectProps,
9
- ITextAreaFieldProps,
9
+ ISimpleSelectOptions,
10
+ ITextareaProps,
10
11
  IToggleSwitchProps,
11
12
  AcceptedInputTypes,
12
13
  Checkbox,
@@ -16,8 +17,10 @@ import {
16
17
  NestedInputButton,
17
18
  Radio,
18
19
  Select,
19
- TextAreaField,
20
- ToggleSwitch
20
+ Textarea,
21
+ ToggleSwitch,
22
+ ITextInputProps,
23
+ TextInput
21
24
  } from "./inputs"
22
25
 
23
26
  export type {
@@ -28,8 +31,21 @@ export type {
28
31
  INestedInputButtonProps,
29
32
  IRadioProps,
30
33
  ISelectProps,
31
- ITextAreaFieldProps,
34
+ ISimpleSelectOptions,
35
+ ITextareaProps,
32
36
  IToggleSwitchProps,
33
- AcceptedInputTypes
37
+ AcceptedInputTypes,
38
+ ITextInputProps
39
+ }
40
+ export {
41
+ Checkbox,
42
+ Combobox,
43
+ InputField,
44
+ InputLabel,
45
+ NestedInputButton,
46
+ Radio,
47
+ Select,
48
+ Textarea,
49
+ ToggleSwitch,
50
+ TextInput
34
51
  }
35
- export { Checkbox, Combobox, InputField, InputLabel, NestedInputButton, Radio, Select, TextAreaField, ToggleSwitch }
@@ -1,4 +1,4 @@
1
- import React from "react"
1
+ import React, { forwardRef } from "react"
2
2
  import { default as cn } from "classnames"
3
3
 
4
4
  export type AcceptedInputTypes =
@@ -13,14 +13,15 @@ export type AcceptedInputTypes =
13
13
  | "tel"
14
14
  | "text"
15
15
  | "url"
16
+ | "currency"
16
17
 
17
- export interface IInputFieldProps extends React.ComponentPropsWithoutRef<"input"> {
18
+ export interface IInputFieldProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange"> {
18
19
  /** Callback on change */
19
20
  handleChange: (value: string) => void
20
21
  /** Input ID*/
21
- id: string
22
+ id?: string
22
23
  /** Input Name */
23
- name: string
24
+ name?: string
24
25
  /** Force the focus state on the input */
25
26
  isFocused?: boolean
26
27
  /** Error condition */
@@ -37,44 +38,45 @@ export interface IInputFieldProps extends React.ComponentPropsWithoutRef<"input"
37
38
  required?: boolean
38
39
  /** use input psuedo classes for :valid and :invalid styles. on by default */
39
40
  clientSideCheck?: boolean
41
+ /** Placeholder text */
42
+ placeholder?: string
40
43
  /**ref for input */
41
- ref?: React.Ref<HTMLInputElement>
42
44
  }
43
45
 
44
- const InputField: React.FC<IInputFieldProps> = ({
45
- type,
46
- id,
47
- name,
48
- value,
49
- isFocused,
50
- isError,
51
- isReadonly,
52
- isDisabled,
53
- handleChange,
54
- required,
55
- clientSideCheck = true,
56
- placeholder,
57
- className,
58
- ref,
59
- ...rest
60
- }) => {
61
-
46
+ const InputField = (
47
+ {
48
+ type,
49
+ id,
50
+ name,
51
+ value,
52
+ isFocused,
53
+ isError,
54
+ isReadonly,
55
+ isDisabled,
56
+ handleChange,
57
+ required,
58
+ clientSideCheck = true,
59
+ className,
60
+ placeholder,
61
+ ...rest
62
+ }: IInputFieldProps,
63
+ ref: React.Ref<HTMLInputElement>
64
+ ) => {
62
65
  return (
63
66
  <input
64
67
  {...{
68
+ ref,
65
69
  type,
66
70
  id,
67
- ref,
68
71
  name,
69
72
  value,
70
73
  onChange: (e) => {
71
- console.log(e)
72
- handleChange(e.target.value)
74
+ if (handleChange) handleChange(e.target.value)
73
75
  },
74
76
  autoFocus: isFocused,
75
77
  readOnly: isReadonly,
76
78
  disabled: isDisabled,
77
- placeholder: placeholder || " ",
79
+ placeholder: placeholder || undefined,
78
80
  required,
79
81
  "aria-invalid": isError,
80
82
  "aria-disabled": isDisabled,
@@ -90,4 +92,5 @@ const InputField: React.FC<IInputFieldProps> = ({
90
92
  )
91
93
  }
92
94
 
93
- export default InputField
95
+ const _InputField = forwardRef<HTMLInputElement, IInputFieldProps>(InputField)
96
+ export default _InputField
@@ -32,7 +32,7 @@ export interface ITextInputProps {
32
32
  /** Max length of input character */
33
33
  maxLength?: number
34
34
  /** Callback on change */
35
- onChange(value: string): void
35
+ handleChange(value: string): void
36
36
  /** input value */
37
37
  value: string
38
38
  /**Placeholder input text*/
@@ -56,7 +56,7 @@ const TextInput = (
56
56
  message,
57
57
  isShowCounter,
58
58
  maxLength,
59
- onChange,
59
+ handleChange,
60
60
  placeholder,
61
61
  value: externalValue,
62
62
  className,
@@ -116,7 +116,10 @@ const TextInput = (
116
116
  <InputField
117
117
  onFocus={handleInputFocus}
118
118
  onBlur={handleInputBlur}
119
- handleChange={(v) => setValue(v)}
119
+ handleChange={(v: string) => {
120
+ setValue(v)
121
+ handleChange(v)
122
+ }}
120
123
  ref={ref}
121
124
  type={type}
122
125
  name={name}
@@ -16,7 +16,7 @@ export const DefaultCheckbox: Story = {
16
16
  isError: false,
17
17
  message: "",
18
18
  onChange: (value: string) => {
19
- console.log(`onChange ${value}`)
19
+
20
20
  }
21
21
  }
22
22
  }
@@ -53,13 +53,12 @@ const Checkbox: FC<ICheckboxProps> = ({
53
53
  const wrapperStyles = cn(
54
54
  "relative flex items-center min-h-[38px]",
55
55
  { "opacity-50": isDisabled },
56
- { "rounded-sm ring-1 px-3 ring-gray-300": hasBorder },
56
+ { "rounded-sm border border-1 px-3 border-gray-200": hasBorder },
57
57
  { "py-3": hasBorder && message },
58
58
  className
59
59
  )
60
60
 
61
61
  const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
62
- console.log(e)
63
62
  const targetValue = e.target.value
64
63
  const targetChecked = e.target.checked
65
64
  typeof onChange === "function" && onChange(targetValue, targetChecked)
@@ -44,151 +44,142 @@ function classNames(...classes: string[]) {
44
44
  return classes.filter(Boolean).join(" ")
45
45
  }
46
46
 
47
- const Combobox = <T extends Record<string, unknown>>({
48
- label,
49
- items,
50
- displayProperty,
51
- displayValue,
52
- keyProperty,
53
- onChange,
54
- placeholder,
55
- message,
56
- isDisabled,
57
- isError,
58
- isRequired,
59
- id,
60
- nullable
61
- }: IComboboxProps<T>) => {
62
- const [query, setQuery] = useState<string>("")
63
- const [selectedItem, setSelectedItem] = useState<T | undefined>()
47
+ const Combobox = <T extends Record<string, unknown>>({
48
+ label,
49
+ items,
50
+ displayProperty,
51
+ displayValue,
52
+ keyProperty,
53
+ onChange,
54
+ placeholder,
55
+ message,
56
+ isDisabled,
57
+ isError,
58
+ isRequired,
59
+ id,
60
+ nullable
61
+ }: IComboboxProps<T>) => {
62
+ const [query, setQuery] = useState<string>("")
63
+ const [selectedItem, setSelectedItem] = useState<T | undefined>()
64
64
 
65
- const onChangeValue = (value: T | undefined) => {
66
- if (value && selectedItem && value[keyProperty] === selectedItem[keyProperty]) {
67
- setSelectedItem(undefined)
68
- } else {
69
- setSelectedItem(value)
70
- }
65
+ const onChangeValue = (value: T | undefined) => {
66
+ if (value && selectedItem && value[keyProperty] === selectedItem[keyProperty]) {
67
+ setSelectedItem(undefined)
68
+ } else {
69
+ setSelectedItem(value)
71
70
  }
71
+ }
72
72
 
73
- useEffect(() => {
74
- if (displayValue) {
75
- const dv = items.find((i) => i[displayProperty] === displayValue)
76
- setSelectedItem(dv)
77
- }
78
- }, [displayValue])
73
+ useEffect(() => {
74
+ if (displayValue) {
75
+ const dv = items.find((i) => i[displayProperty] === displayValue)
76
+ setSelectedItem(dv)
77
+ }
78
+ }, [displayValue])
79
79
 
80
- useEffect(() => {
81
- typeof onChange === "function" && onChange(selectedItem)
82
- }, [selectedItem])
80
+ useEffect(() => {
81
+ typeof onChange === "function" && onChange(selectedItem)
82
+ }, [selectedItem])
83
83
 
84
- const filteredItems =
85
- query === ""
86
- ? items
87
- : items.filter((item) => {
88
- return `${item[displayProperty]}`.toLowerCase().includes(query.toLowerCase())
89
- })
90
- const labelStyles = cn("block text-sm font-medium text-gray-700")
91
- const buttonStyles = cn("absolute inset-y-0 right-0 flex items-center rounded-r px-2 focus:outline-none")
92
- const optionStyles = cn(
93
- "absolute z-30 mt-1 max-h-60 w-full overflow-auto rounded bg-white py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm"
94
- )
95
- return (
96
- <HeadlessUICombobox
97
- as="div"
98
- value={selectedItem}
99
- onChange={(e: T | undefined) => onChangeValue(e)}
100
- disabled={isDisabled}
101
- nullable={nullable ? undefined : false}
102
- >
103
- {label && (
104
- <HeadlessUICombobox.Label className={labelStyles}>
105
- <InputLabel
106
- isPlaceholder
107
- isActive
108
- label={label}
109
- isRequired={isRequired}
110
- id={id}
111
- isError={isError}
112
- isDisabled={isDisabled}
113
- />
114
- </HeadlessUICombobox.Label>
115
- )}
84
+ const filteredItems =
85
+ query === ""
86
+ ? items
87
+ : items.filter((item) => {
88
+ return `${item[displayProperty]}`.toLowerCase().includes(query.toLowerCase())
89
+ })
90
+ const labelStyles = cn("block text-sm font-medium text-gray-700")
91
+ const buttonStyles = cn("absolute inset-y-0 right-0 flex items-center rounded-r px-2 focus:outline-none")
92
+ const optionStyles = cn(
93
+ "absolute z-30 mt-1 max-h-60 w-full overflow-auto rounded bg-white py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm"
94
+ )
95
+ return (
96
+ <HeadlessUICombobox
97
+ as="div"
98
+ value={selectedItem}
99
+ onChange={(e: T | undefined) => onChangeValue(e)}
100
+ disabled={isDisabled}
101
+ nullable={nullable ? undefined : false}
102
+ >
103
+ {label && (
104
+ <HeadlessUICombobox.Label className={labelStyles}>
105
+ <InputLabel
106
+ isPlaceholder
107
+ isActive
108
+ label={label}
109
+ isRequired={isRequired}
110
+ id={id}
111
+ isError={isError}
112
+ isDisabled={isDisabled}
113
+ />
114
+ </HeadlessUICombobox.Label>
115
+ )}
116
+ <div className="relative">
116
117
  <div className="relative">
117
- <div className="relative">
118
- <HeadlessUICombobox.Input
119
- className={`w-full rounded border border-gray-300 focus:border-purple-500 focus:outline-none focus:ring-1 focus:ring-purple-500 sm:text-sm ${
120
- isError ? "border-red-500" : ""
121
- }`}
122
- onChange={(event) => setQuery(event.target.value)}
123
- displayValue={(item: Record<string, unknown>) => `${item ? item[displayProperty] : ""}`}
124
- placeholder={placeholder}
125
- />
126
- {selectedItem && nullable && (
127
- <button
128
- className="absolute right-8 top-[1px] h-9 w-5 text-gray-400 hover:text-gray-500"
129
- onClick={() => setSelectedItem(undefined)}
118
+ <HeadlessUICombobox.Input
119
+ className={`w-full rounded border border-gray-300 focus:border-purple-500 focus:outline-none focus:ring-1 focus:ring-purple-500 sm:text-sm ${
120
+ isError ? "border-red-500" : ""
121
+ }`}
122
+ onChange={(event) => setQuery(event.target.value)}
123
+ displayValue={(item: Record<string, unknown>) => `${item ? item[displayProperty] : ""}`}
124
+ placeholder={placeholder}
125
+ />
126
+ {selectedItem && nullable && (
127
+ <button
128
+ className="absolute right-8 top-[1px] h-9 w-5 text-gray-400 hover:text-gray-500"
129
+ onClick={() => setSelectedItem(undefined)}
130
+ >
131
+ <DynamicIcon icon="IconX" className="h-4 w-4 " aria-hidden="true" />
132
+ </button>
133
+ )}
134
+ </div>
135
+ <HeadlessUICombobox.Button className={buttonStyles}>
136
+ <DynamicIcon icon="IconSelector" className="h-5 w-5 text-gray-400" aria-hidden="true" />
137
+ </HeadlessUICombobox.Button>
138
+
139
+ {filteredItems.length > 0 && (
140
+ <HeadlessUICombobox.Options className={optionStyles}>
141
+ {filteredItems.map((item, index) => (
142
+ <HeadlessUICombobox.Option
143
+ key={`${item[keyProperty]}-${index}`}
144
+ value={item}
145
+ className={({ active }) =>
146
+ classNames(
147
+ "relative cursor-default select-none py-2 pl-3 pr-9",
148
+ active ? "bg-purple-600 text-white" : "text-gray-900"
149
+ )
150
+ }
130
151
  >
131
- <DynamicIcon icon="XIcon" className="h-4 w-4 " aria-hidden="true" />
132
- </button>
133
- )}
134
- </div>
135
- <HeadlessUICombobox.Button className={buttonStyles}>
136
- <DynamicIcon icon="SelectorIcon" className="h-5 w-5 text-gray-400" aria-hidden="true" />
137
- </HeadlessUICombobox.Button>
152
+ {({ active, selected }) => (
153
+ <>
154
+ <span className={classNames("block truncate", selected ? "font-semibold" : "")}>
155
+ {`${item[displayProperty]}`}
156
+ </span>
138
157
 
139
- {filteredItems.length > 0 && (
140
- <HeadlessUICombobox.Options className={optionStyles}>
141
- {filteredItems.map((item, index) => (
142
- <HeadlessUICombobox.Option
143
- key={`${item[keyProperty]}-${index}`}
144
- value={item}
145
- className={({ active }) =>
146
- classNames(
147
- "relative cursor-default select-none py-2 pl-3 pr-9",
148
- active ? "bg-purple-600 text-white" : "text-gray-900"
149
- )
150
- }
151
- >
152
- {({ active, selected }) => (
153
- <>
158
+ {selected && (
154
159
  <span
155
160
  className={classNames(
156
- "block truncate",
157
- selected ? "font-semibold" : ""
161
+ "absolute inset-y-0 right-0 flex items-center pr-4",
162
+ active ? "text-white" : "text-purple-600"
158
163
  )}
159
164
  >
160
- {`${item[displayProperty]}`}
165
+ <DynamicIcon icon="IconCheck" className="h-5 w-5" aria-hidden="true" />
161
166
  </span>
162
-
163
- {selected && (
164
- <span
165
- className={classNames(
166
- "absolute inset-y-0 right-0 flex items-center pr-4",
167
- active ? "text-white" : "text-purple-600"
168
- )}
169
- >
170
- <DynamicIcon
171
- icon="CheckIcon"
172
- className="h-5 w-5"
173
- aria-hidden="true"
174
- />
175
- </span>
176
- )}
177
- </>
178
- )}
179
- </HeadlessUICombobox.Option>
180
- ))}
181
- </HeadlessUICombobox.Options>
182
- )}
183
- </div>
184
- <div className="grow">
185
- {message && (
186
- <span className={`mt-1 block text-sm ${isError ? `text-red-500` : `text-gray-500`}`}>
187
- {message}
188
- </span>
189
- )}
190
- </div>
191
- </HeadlessUICombobox>
192
- )
193
- }
194
- export default Combobox
167
+ )}
168
+ </>
169
+ )}
170
+ </HeadlessUICombobox.Option>
171
+ ))}
172
+ </HeadlessUICombobox.Options>
173
+ )}
174
+ </div>
175
+ <div className="grow">
176
+ {message && (
177
+ <span className={`mt-1 block text-sm ${isError ? `text-red-500` : `text-gray-500`}`}>
178
+ {message}
179
+ </span>
180
+ )}
181
+ </div>
182
+ </HeadlessUICombobox>
183
+ )
184
+ }
185
+ export default Combobox
@@ -4,8 +4,8 @@ import InputField, { AcceptedInputTypes, IInputFieldProps } from "./InputField"
4
4
  import InputLabel, { IInputLabelProps } from "./InputLabel"
5
5
  import NestedInputButton, { INestedInputButtonProps } from "./NestedInputButton"
6
6
  import Radio, { IRadioProps } from "./radio"
7
- import Select, { ISelectProps } from "./select"
8
- import TextAreaField, { ITextAreaFieldProps } from "./textArea"
7
+ import Select, { ISelectProps, ISimpleSelectOptions } from "./select"
8
+ import Textarea, { ITextareaProps } from "./textArea"
9
9
  import TextInput, { ITextInputProps } from "./TextInput"
10
10
  import ToggleSwitch, { IToggleSwitchProps } from "./toggleSwitch"
11
11
 
@@ -17,7 +17,8 @@ export type {
17
17
  INestedInputButtonProps,
18
18
  IRadioProps,
19
19
  ISelectProps,
20
- ITextAreaFieldProps,
20
+ ISimpleSelectOptions,
21
+ ITextareaProps,
21
22
  ITextInputProps,
22
23
  IToggleSwitchProps,
23
24
  AcceptedInputTypes
@@ -31,7 +32,7 @@ export {
31
32
  NestedInputButton,
32
33
  Radio,
33
34
  Select,
34
- TextAreaField,
35
+ Textarea,
35
36
  ToggleSwitch,
36
37
  TextInput
37
38
  }
@@ -17,10 +17,10 @@ export const DefaultRadio: Story = {
17
17
  message: "",
18
18
  name: "radio-group",
19
19
  onChange: (value: string, checked: boolean) => {
20
- console.log(`onChange ${value} ${checked}`)
20
+
21
21
  },
22
22
  onClick: (value: string, checked: boolean) => {
23
- console.log(`onClick ${value} ${checked}`)
23
+
24
24
  }
25
25
  }
26
26
  }
@@ -3,7 +3,7 @@ import InputLabel from "@/stories/molecules/inputs/InputLabel"
3
3
  import { useId } from "@/utils/useId"
4
4
  import { default as cn } from "classnames"
5
5
 
6
- export type ISimpleSelectOptions = {
6
+ export interface ISimpleSelectOptions {
7
7
  label: string
8
8
  value: string
9
9
  }
@@ -28,6 +28,10 @@ export interface ISelectProps {
28
28
  value?: string
29
29
 
30
30
  className?: string
31
+
32
+ onFocus?: () => void
33
+
34
+ onBlur?: () => void
31
35
  }
32
36
  const Select: React.FC<ISelectProps> = ({
33
37
  label,
@@ -39,7 +43,9 @@ const Select: React.FC<ISelectProps> = ({
39
43
  isError,
40
44
  isRequired,
41
45
  value,
42
- className
46
+ className,
47
+ onFocus,
48
+ onBlur
43
49
  }) => {
44
50
  const [selectedOption, setSelectedOption] = useState<string>(value || options[0].value)
45
51
  const uniqueID = useId()
@@ -84,6 +90,8 @@ const Select: React.FC<ISelectProps> = ({
84
90
  onChange={handleChange}
85
91
  disabled={isDisabled}
86
92
  value={selectedOption}
93
+ onFocus={onFocus}
94
+ onBlur={onBlur}
87
95
  >
88
96
  {options.map(({ value, label }) => {
89
97
  return (