@agility/plenum-ui 2.1.19-rc2 → 2.1.20-rc1

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/dist/tailwind.css CHANGED
@@ -1740,6 +1740,10 @@ select {
1740
1740
  margin-bottom: 24rem;
1741
1741
  }
1742
1742
 
1743
+ .\!mb-0 {
1744
+ margin-bottom: 0px !important;
1745
+ }
1746
+
1743
1747
  .\!ml-\[\.172rem\] {
1744
1748
  margin-left: .172rem !important;
1745
1749
  }
@@ -1879,6 +1883,10 @@ select {
1879
1883
  height: 2.25rem;
1880
1884
  }
1881
1885
 
1886
+ .h-\[240px\] {
1887
+ height: 240px;
1888
+ }
1889
+
1882
1890
  .h-\[6px\] {
1883
1891
  height: 6px;
1884
1892
  }
@@ -1891,6 +1899,10 @@ select {
1891
1899
  max-height: 15rem;
1892
1900
  }
1893
1901
 
1902
+ .\!min-h-0 {
1903
+ min-height: 0px !important;
1904
+ }
1905
+
1894
1906
  .min-h-\[38px\] {
1895
1907
  min-height: 38px;
1896
1908
  }
@@ -1967,6 +1979,10 @@ select {
1967
1979
  width: 1px;
1968
1980
  }
1969
1981
 
1982
+ .w-\[200px\] {
1983
+ width: 200px;
1984
+ }
1985
+
1970
1986
  .w-\[6px\] {
1971
1987
  width: 6px;
1972
1988
  }
@@ -50539,6 +50555,11 @@ select {
50539
50555
  padding-bottom: 7px;
50540
50556
  }
50541
50557
 
50558
+ .py-\[8px\] {
50559
+ padding-top: 8px;
50560
+ padding-bottom: 8px;
50561
+ }
50562
+
50542
50563
  .py-\[9px\] {
50543
50564
  padding-top: 9px;
50544
50565
  padding-bottom: 9px;
@@ -58781,6 +58802,10 @@ select {
58781
58802
  border-color: rgb(109 40 217 / var(--tw-border-opacity));
58782
58803
  }
58783
58804
 
58805
+ .hover\:bg-\[rgba\(0\2c 0\2c 0\2c 0\.03\)\]:hover {
58806
+ background-color: rgba(0,0,0,0.03);
58807
+ }
58808
+
58784
58809
  .hover\:bg-gray-100:hover {
58785
58810
  --tw-bg-opacity: 1;
58786
58811
  background-color: rgb(243 244 246 / var(--tw-bg-opacity));
@@ -59217,6 +59242,11 @@ select {
59217
59242
  color: rgb(75 85 99 / var(--tw-text-opacity));
59218
59243
  }
59219
59244
 
59245
+ .group[data-open] .group-data-\[open\]\:rotate-180 {
59246
+ --tw-rotate: 180deg;
59247
+ transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
59248
+ }
59249
+
59220
59250
  @media (min-width: 640px) {
59221
59251
  .sm\:text-sm {
59222
59252
  font-size: 0.875rem;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { IDynamicIconProps } from "./DynamicIcon";
3
2
  export interface IIconWithShadowProps extends IDynamicIconProps {
4
3
  }
@@ -1,5 +1,5 @@
1
1
  import { IAvatarProps, IBadgeProps, IButtonProps, ICapsuleProps, IDynamicIconProps, IIconWithShadowProps, ILoaderProps, IRadialProgressProps, UnifiedIconName, IconName, FAIconName, BTNActionType, Avatar, Badge, Button, Capsule, DynamicIcon, IconWithShadow, Loader, RadialProgress, isFAIcon, isHeroIcon, isTablerIcon, isUnifiedIconName } from "./atoms";
2
2
  import { ICheckboxProps, IComboboxProps, IInputFieldProps, IInputLabelProps, INestedInputButtonProps, IRadioProps, ISelectProps, ITextareaProps, IToggleSwitchProps, AcceptedInputTypes, Checkbox, Combobox, InputField, InputLabel, NestedInputButton, Radio, Select, Textarea, ToggleSwitch, TextInput, ITextInputProps, ISimpleSelectOptions } from "./molecules";
3
- import { IAnimatedLabelInputProps, AnimatedLabelTextArea, IAnimatedLabelTextAreaProps, IButtonDropdownProps, IDropdownProps, IEmptySectionPlaceholderProps, IItemProp, IFormInputWithAddonsProps, AnimatedLabelInput, ButtonDropdown, Dropdown, EmptySectionPlaceholder, FormInputWithAddons, TextInputSelect, ITextInputSelectProps, IAnimatedFormInputWithAddons, AnimatedFormInputWithAddons } from "./organisms";
4
- export type { IAvatarProps, IBadgeProps, IButtonProps, ICapsuleProps, ITextInputSelectProps, IDynamicIconProps, IIconWithShadowProps, ILoaderProps, IRadialProgressProps, ICheckboxProps, IComboboxProps, IInputFieldProps, IInputLabelProps, INestedInputButtonProps, IRadioProps, ISelectProps, ITextareaProps, IToggleSwitchProps, AcceptedInputTypes, IAnimatedLabelInputProps, IAnimatedLabelTextAreaProps, IButtonDropdownProps, IDropdownProps, IEmptySectionPlaceholderProps, IItemProp, IFormInputWithAddonsProps, UnifiedIconName, IconName, FAIconName, BTNActionType, ITextInputProps, ISimpleSelectOptions, IAnimatedFormInputWithAddons };
5
- export { Avatar, Checkbox, Combobox, InputField, InputLabel, NestedInputButton, Radio, Select, Textarea, ToggleSwitch, AnimatedLabelInput, AnimatedLabelTextArea, ButtonDropdown, Dropdown, EmptySectionPlaceholder, FormInputWithAddons, Badge, Button, Capsule, DynamicIcon, IconWithShadow, Loader, RadialProgress, isFAIcon, isHeroIcon, isTablerIcon, isUnifiedIconName, TextInput, TextInputSelect, AnimatedFormInputWithAddons };
3
+ import { IAnimatedLabelInputProps, AnimatedLabelTextArea, IAnimatedLabelTextAreaProps, IButtonDropdownProps, IDropdownProps, IEmptySectionPlaceholderProps, IItemProp, IFormInputWithAddonsProps, AnimatedLabelInput, ButtonDropdown, Dropdown, EmptySectionPlaceholder, FormInputWithAddons, TextInputSelect, ITextInputSelectProps, IAnimatedFormInputWithAddons, AnimatedFormInputWithAddons, DropdownWithMultiSelect, MultiSelectItemProps } from "./organisms";
4
+ export type { IAvatarProps, IBadgeProps, IButtonProps, ICapsuleProps, ITextInputSelectProps, IDynamicIconProps, IIconWithShadowProps, ILoaderProps, IRadialProgressProps, ICheckboxProps, IComboboxProps, IInputFieldProps, IInputLabelProps, INestedInputButtonProps, IRadioProps, ISelectProps, ITextareaProps, IToggleSwitchProps, AcceptedInputTypes, IAnimatedLabelInputProps, IAnimatedLabelTextAreaProps, IButtonDropdownProps, IDropdownProps, IEmptySectionPlaceholderProps, IItemProp, IFormInputWithAddonsProps, UnifiedIconName, IconName, FAIconName, BTNActionType, ITextInputProps, ISimpleSelectOptions, IAnimatedFormInputWithAddons, MultiSelectItemProps };
5
+ export { Avatar, Checkbox, Combobox, InputField, InputLabel, NestedInputButton, Radio, Select, Textarea, ToggleSwitch, AnimatedLabelInput, AnimatedLabelTextArea, ButtonDropdown, Dropdown, EmptySectionPlaceholder, FormInputWithAddons, Badge, Button, Capsule, DynamicIcon, IconWithShadow, Loader, RadialProgress, isFAIcon, isHeroIcon, isTablerIcon, isUnifiedIconName, TextInput, TextInputSelect, AnimatedFormInputWithAddons, DropdownWithMultiSelect };
@@ -4,13 +4,21 @@ export interface ISimpleSelectOptions {
4
4
  value: string;
5
5
  }
6
6
  export interface ISelectProps {
7
+ /** Label */
7
8
  label?: string;
9
+ /** Select ID prop */
8
10
  id?: string;
11
+ /** Select name prop */
9
12
  name?: string;
13
+ /** List of options to display in the select menu */
10
14
  options: ISimpleSelectOptions[];
15
+ /** Select name prop */
11
16
  onChange?(value: string): void;
17
+ /** Select disabled state */
12
18
  isDisabled?: boolean;
19
+ /** Select error state */
13
20
  isError?: boolean;
21
+ /** Select required state */
14
22
  isRequired?: boolean;
15
23
  value?: string;
16
24
  className?: string;
@@ -0,0 +1,2 @@
1
+ import { MultiSelectItemProps } from "./DropdownWithMultiSelect";
2
+ export declare const dropdownDataBase: MultiSelectItemProps[];
@@ -0,0 +1,13 @@
1
+ export interface MultiSelectItemProps {
2
+ label: string;
3
+ onClick?(): void;
4
+ key: React.Key;
5
+ isSelected: boolean;
6
+ }
7
+ interface Props {
8
+ label: string;
9
+ options: MultiSelectItemProps[];
10
+ type: "checkbox" | "radio";
11
+ }
12
+ declare const DropdownWithMultiSelect: ({ label, options, type }: Props) => import("react/jsx-runtime").JSX.Element;
13
+ export default DropdownWithMultiSelect;
@@ -6,5 +6,6 @@ import EmptySectionPlaceholder, { IEmptySectionPlaceholderProps } from "./EmptyS
6
6
  import FormInputWithAddons, { IFormInputWithAddonsProps } from "./FormInputWithAddons";
7
7
  import TextInputSelect, { ITextInputSelectProps } from "./TextInputSelect";
8
8
  import AnimatedFormInputWithAddons, { IAnimatedFormInputWithAddons } from "./AnimatedFormInputWithAddons";
9
- export type { IAnimatedLabelInputProps, IAnimatedLabelTextAreaProps, IButtonDropdownProps, IDropdownProps, IEmptySectionPlaceholderProps, IItemProp, IFormInputWithAddonsProps, ITextInputSelectProps, IAnimatedFormInputWithAddons };
10
- export { AnimatedLabelInput, AnimatedLabelTextArea, ButtonDropdown, Dropdown, EmptySectionPlaceholder, FormInputWithAddons, TextInputSelect, AnimatedFormInputWithAddons };
9
+ import DropdownWithMultiSelect, { MultiSelectItemProps } from "./DropdownWithMultiSelect/DropdownWithMultiSelect";
10
+ export type { IAnimatedLabelInputProps, IAnimatedLabelTextAreaProps, IButtonDropdownProps, IDropdownProps, IEmptySectionPlaceholderProps, IItemProp, IFormInputWithAddonsProps, ITextInputSelectProps, IAnimatedFormInputWithAddons, MultiSelectItemProps };
11
+ export { AnimatedLabelInput, AnimatedLabelTextArea, ButtonDropdown, Dropdown, EmptySectionPlaceholder, FormInputWithAddons, TextInputSelect, AnimatedFormInputWithAddons, DropdownWithMultiSelect };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agility/plenum-ui",
3
- "version": "2.1.19-rc2",
3
+ "version": "2.1.20-rc1",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -29,8 +29,8 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@floating-ui/react": "^0.25.0",
32
- "@headlessui/react": "^1.7.10",
33
- "@headlessui/tailwindcss": "^0.1.2",
32
+ "@headlessui/react": "2.1",
33
+ "@headlessui/tailwindcss": "0.2.1",
34
34
  "@heroicons/react": "^1.0.5",
35
35
  "@next/font": "^13.4.12",
36
36
  "@tabler/icons": "^2.26.0",
@@ -62,7 +62,7 @@
62
62
  "@testing-library/jest-dom": "^6.6.2",
63
63
  "@testing-library/react": "^16.0.1",
64
64
  "@types/jest": "^29.5.14",
65
- "@types/node": "18.11.18",
65
+ "@types/node": "^22.10.2",
66
66
  "autoprefixer": "^10.4.13",
67
67
  "esbuild": "^0.18.19",
68
68
  "eslint": "8.32.0",
package/stories/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- //Atomic Components, props, and type gaurds.
1
+ //Atomic Components, props, and type guards.
2
2
  import {
3
3
  IAvatarProps,
4
4
  IBadgeProps,
@@ -24,8 +24,8 @@ import {
24
24
  isHeroIcon,
25
25
  isTablerIcon,
26
26
  isUnifiedIconName
27
- } from "./atoms"
28
- // Molecular Components, props, and type gaurds.
27
+ } from "./atoms";
28
+ // Molecular Components, props, and type guards.
29
29
  import {
30
30
  ICheckboxProps,
31
31
  IComboboxProps,
@@ -49,8 +49,8 @@ import {
49
49
  TextInput,
50
50
  ITextInputProps,
51
51
  ISimpleSelectOptions
52
- } from "./molecules"
53
- // Organism Components, props, and type gaurds.
52
+ } from "./molecules";
53
+ // Organism Components, props, and type guards.
54
54
  import {
55
55
  IAnimatedLabelInputProps,
56
56
  AnimatedLabelTextArea,
@@ -68,8 +68,10 @@ import {
68
68
  TextInputSelect,
69
69
  ITextInputSelectProps,
70
70
  IAnimatedFormInputWithAddons,
71
- AnimatedFormInputWithAddons
72
- } from "./organisms"
71
+ AnimatedFormInputWithAddons,
72
+ DropdownWithMultiSelect,
73
+ MultiSelectItemProps
74
+ } from "./organisms";
73
75
 
74
76
  export type {
75
77
  IAvatarProps,
@@ -104,8 +106,9 @@ export type {
104
106
  BTNActionType,
105
107
  ITextInputProps,
106
108
  ISimpleSelectOptions,
107
- IAnimatedFormInputWithAddons
108
- }
109
+ IAnimatedFormInputWithAddons,
110
+ MultiSelectItemProps
111
+ };
109
112
  export {
110
113
  Avatar,
111
114
  Checkbox,
@@ -136,5 +139,6 @@ export {
136
139
  isUnifiedIconName,
137
140
  TextInput,
138
141
  TextInputSelect,
139
- AnimatedFormInputWithAddons
140
- }
142
+ AnimatedFormInputWithAddons,
143
+ DropdownWithMultiSelect
144
+ };
@@ -8,20 +8,27 @@ export interface ISimpleSelectOptions {
8
8
  value: string;
9
9
  }
10
10
  export interface ISelectProps {
11
+ /** Label */
11
12
  label?: string;
13
+ /** Select ID prop */
12
14
  id?: string;
15
+ /** Select name prop */
13
16
  name?: string;
17
+ /** List of options to display in the select menu */
14
18
  options: ISimpleSelectOptions[];
19
+ /** Select name prop */
15
20
  onChange?(value: string): void;
21
+ /** Select disabled state */
16
22
  isDisabled?: boolean;
23
+ /** Select error state */
17
24
  isError?: boolean;
25
+ /** Select required state */
18
26
  isRequired?: boolean;
19
27
  value?: string;
20
28
  className?: string;
21
29
  onFocus?: () => void;
22
30
  onBlur?: () => void;
23
31
  }
24
-
25
32
  const Select: React.FC<ISelectProps> = ({
26
33
  label,
27
34
  id,
@@ -36,31 +43,22 @@ const Select: React.FC<ISelectProps> = ({
36
43
  onFocus,
37
44
  onBlur
38
45
  }) => {
39
- const getValidVal = (val: string | undefined) => {
40
- const validValue = val && val !== "" ? val : options[0]?.value ?? "select an option";
41
- console.log("valid Val", validValue);
42
- return validValue;
43
- };
44
- const [selectedOption, setSelectedOption] = useState<string>(getValidVal(value));
46
+ const [selectedOption, setSelectedOption] = useState<string>(value || options[0].value);
45
47
  const uniqueID = useId();
46
48
  if (!id) id = `select-${uniqueID}`;
47
49
  if (!name) name = id;
48
50
 
49
51
  useEffect(() => {
50
- // Explicitly handle falsy values
51
- if (value !== undefined) {
52
+ if (value !== undefined && value !== null) {
52
53
  setSelectedOption(value);
53
54
  }
54
55
  }, [value]);
55
56
 
56
57
  const handleChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
57
58
  const targetValue = e.target.value;
58
- if (typeof onChange === "function") {
59
- onChange(targetValue);
60
- }
59
+ typeof onChange == "function" && onChange(targetValue);
61
60
  setSelectedOption(targetValue);
62
61
  };
63
-
64
62
  const wrapperStyle = cn("group", { "opacity-50": isDisabled });
65
63
  return (
66
64
  <div className={wrapperStyle}>
@@ -91,11 +89,13 @@ const Select: React.FC<ISelectProps> = ({
91
89
  onFocus={onFocus}
92
90
  onBlur={onBlur}
93
91
  >
94
- {options.map(({ value, label }) => (
95
- <option key={value} value={value}>
96
- {label}
97
- </option>
98
- ))}
92
+ {options.map(({ value, label }) => {
93
+ return (
94
+ <option key={value} value={value}>
95
+ {label}
96
+ </option>
97
+ );
98
+ })}
99
99
  </select>
100
100
  </div>
101
101
  );
@@ -0,0 +1,219 @@
1
+ import { MultiSelectItemProps } from "./DropdownWithMultiSelect";
2
+
3
+ export const dropdownDataBase: MultiSelectItemProps[] = [
4
+ {
5
+ key: "Copy",
6
+ label: "Copy to Clipboard",
7
+ onClick: () => {
8
+ console.log("Copy action");
9
+ },
10
+ isSelected: false
11
+ },
12
+ {
13
+ label: "Delete",
14
+ onClick: () => {
15
+ console.log("Delete action");
16
+ },
17
+ key: "Delete",
18
+ isSelected: true
19
+ },
20
+ {
21
+ key: "Add to Batch",
22
+ label: "Add to Batch",
23
+ onClick: () => {
24
+ console.log("Add to Batch action");
25
+ },
26
+ isSelected: false
27
+ },
28
+ {
29
+ key: "View Batch",
30
+ label: "View Batch",
31
+ onClick: () => {
32
+ console.log("View Batch action");
33
+ },
34
+ isSelected: false
35
+ },
36
+ {
37
+ key: "Copy",
38
+ label: "Copy to Clipboard",
39
+ onClick: () => {
40
+ console.log("Copy action");
41
+ },
42
+ isSelected: false
43
+ },
44
+ {
45
+ label: "Delete",
46
+ onClick: () => {
47
+ console.log("Delete action");
48
+ },
49
+ key: "Delete",
50
+ isSelected: true
51
+ },
52
+ {
53
+ key: "Add to Batch",
54
+ label: "Add to Batch",
55
+ onClick: () => {
56
+ console.log("Add to Batch action");
57
+ },
58
+ isSelected: false
59
+ },
60
+ {
61
+ key: "View Batch",
62
+ label: "View Batch",
63
+ onClick: () => {
64
+ console.log("View Batch action");
65
+ },
66
+ isSelected: false
67
+ },
68
+ {
69
+ key: "Copy",
70
+ label: "Copy to Clipboard",
71
+ onClick: () => {
72
+ console.log("Copy action");
73
+ },
74
+ isSelected: false
75
+ },
76
+ {
77
+ label: "Delete",
78
+ onClick: () => {
79
+ console.log("Delete action");
80
+ },
81
+ key: "Delete",
82
+ isSelected: true
83
+ },
84
+ {
85
+ key: "Add to Batch",
86
+ label: "Add to Batch",
87
+ onClick: () => {
88
+ console.log("Add to Batch action");
89
+ },
90
+ isSelected: false
91
+ },
92
+ {
93
+ key: "View Batch",
94
+ label: "View Batch",
95
+ onClick: () => {
96
+ console.log("View Batch action");
97
+ },
98
+ isSelected: false
99
+ },
100
+ {
101
+ key: "Copy",
102
+ label: "Copy to Clipboard",
103
+ onClick: () => {
104
+ console.log("Copy action");
105
+ },
106
+ isSelected: false
107
+ },
108
+ {
109
+ label: "Delete",
110
+ onClick: () => {
111
+ console.log("Delete action");
112
+ },
113
+ key: "Delete",
114
+ isSelected: true
115
+ },
116
+ {
117
+ key: "Add to Batch",
118
+ label: "Add to Batch",
119
+ onClick: () => {
120
+ console.log("Add to Batch action");
121
+ },
122
+ isSelected: false
123
+ },
124
+ {
125
+ key: "View Batch",
126
+ label: "View Batch",
127
+ onClick: () => {
128
+ console.log("View Batch action");
129
+ },
130
+ isSelected: false
131
+ }
132
+ ];
133
+
134
+ // export const multipleGroups: MultiSelectItemProps[][] = [
135
+ // [
136
+ // {
137
+ // icon: { icon: "IconArrowUp" },
138
+ // key: "moveUp",
139
+ // label: "Move up",
140
+ // onClick: () => {
141
+ // window.alert("moved up")
142
+ // }
143
+ // },
144
+ // { icon: { icon: "IconArrowDown" }, key: "moveDown", label: "Moved down", onClick: () => {} }
145
+ // ],
146
+ // [
147
+ // { icon: { icon: "IconCheck" }, key: "publish", label: "Publish", onClick: () => {} },
148
+ // { icon: { icon: "IconEyeOff" }, key: "unpublish", label: "Unpublish", onClick: () => {} }
149
+ // ],
150
+ // [
151
+ // { icon: { icon: "IconEyeCheck" }, key: "reqApproval", label: "Request Approval", onClick: () => {} },
152
+ // { icon: { icon: "IconThumbUp" }, key: "approve", label: "Approve", onClick: () => {} },
153
+ // { icon: { icon: "IconBan" }, key: "decline", label: "Decline", onClick: () => {} }
154
+ // ],
155
+ // [{ icon: { icon: "IconCopy" }, key: "Copy", label: "Copy", onClick: () => {} }],
156
+ // [{ icon: { icon: "IconTrash" }, key: "delete", label: "Delete", onClick: () => {} }]
157
+ // ]
158
+
159
+ // export const dropdownDataWithIcons: MultiSelectItemProps[][] = [
160
+ // [
161
+ // {
162
+ // icon: {
163
+ // icon: "IconCopy",
164
+ // className: "h-5 w-5",
165
+ // outline: false
166
+ // },
167
+ // iconPosition: "leading",
168
+ // key: "Copy",
169
+ // label: "Copy Item",
170
+ // onClick: () => {
171
+ // console.log("Copy action")
172
+ // }
173
+ // }
174
+ // ],
175
+ // [
176
+ // {
177
+ // icon: {
178
+ // icon: "IconFolderPlus",
179
+ // className: "h-5 w-5",
180
+ // outline: false
181
+ // },
182
+ // iconPosition: "leading",
183
+ // key: "Add to Batch",
184
+ // label: "Add to Batch",
185
+ // onClick: () => {
186
+ // console.log("Add to Batch action")
187
+ // }
188
+ // },
189
+ // {
190
+ // icon: {
191
+ // icon: "IconEye",
192
+ // className: "h-5 w-5",
193
+ // outline: false
194
+ // },
195
+ // iconPosition: "leading",
196
+ // key: "View Batch",
197
+ // label: "View Batch",
198
+ // onClick: () => {
199
+ // console.log("View Batch action")
200
+ // }
201
+ // }
202
+ // ],
203
+ // [
204
+ // {
205
+ // icon: {
206
+ // icon: "IconTrash",
207
+ // className: "h-5 w-5",
208
+ // outline: false
209
+ // },
210
+ // iconPosition: "leading",
211
+ // key: "Delete",
212
+ // label: "Delete",
213
+ // onClick: () => {
214
+ // console.log("Delete action")
215
+ // },
216
+ // isEmphasized: true
217
+ // }
218
+ // ]
219
+ // ]
@@ -0,0 +1,29 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { DynamicIcon } from "@/stories/atoms/icons";
3
+ import DropdownWithMultiSelect from "../DropdownWithMultiSelect/DropdownWithMultiSelect";
4
+ import { dropdownDataBase } from "./DropdownItems";
5
+
6
+ const meta: Meta<typeof DropdownWithMultiSelect> = {
7
+ title: "Design System/Organisms/Dropdown",
8
+ component: DropdownWithMultiSelect,
9
+ tags: ["autodocs"],
10
+ argTypes: {}
11
+ };
12
+ type Story = StoryObj<typeof DropdownWithMultiSelect>;
13
+
14
+ const IconElement = () => (
15
+ <DynamicIcon className="h-5 w-5 text-gray-400 hover:text-gray-600" icon={"IconDotsVertical"} />
16
+ );
17
+ const defaultArgs: Story["args"] = {
18
+ label: "Filters",
19
+ options: dropdownDataBase,
20
+ type: "checkbox"
21
+ };
22
+
23
+ export const WithMultiSelect: Story = {
24
+ args: {
25
+ ...defaultArgs
26
+ }
27
+ };
28
+
29
+ export default meta;
@@ -0,0 +1,67 @@
1
+ import { Popover, PopoverButton, PopoverPanel } from "@headlessui/react";
2
+ import Checkbox from "@/stories/molecules/inputs/checkbox/Checkbox";
3
+ import Radio from "@/stories/molecules/inputs/radio/Radio";
4
+ import { DynamicIcon } from "@/stories/atoms/icons";
5
+ import { default as cn } from "classnames";
6
+
7
+ export interface MultiSelectItemProps {
8
+ label: string;
9
+ onClick?(): void;
10
+ key: React.Key;
11
+ isSelected: boolean;
12
+ }
13
+
14
+ interface Props {
15
+ label: string;
16
+ options: MultiSelectItemProps[];
17
+ type: "checkbox" | "radio";
18
+ }
19
+
20
+ const DropdownWithMultiSelect = ({ label, options, type = "checkbox" }: Props) => {
21
+ return (
22
+ <Popover className="group">
23
+ <PopoverButton className="flex justify-between gap-4 text-sm py-2 px-4 rounded-[3px] border border-gray-300 bg-white">
24
+ {label}
25
+ <DynamicIcon
26
+ icon="IconChevronDown"
27
+ className="ml-1 h-5 w-5 text-gray-400 stroke-1 group-data-[open]:rotate-180"
28
+ />
29
+ </PopoverButton>
30
+ <PopoverPanel
31
+ transition
32
+ anchor="bottom end"
33
+ className="bg-white h-[240px] w-[200px] rounded-[3px] border border-gray-300 shadow-lg"
34
+ >
35
+ {options.map((option) => {
36
+ const inputWrapperStyles = cn("py-[8px] px-3 text-gray-500 hover:bg-[rgba(0,0,0,0.03)]", {
37
+ "text-gray-700": option.isSelected
38
+ });
39
+ return (
40
+ <div className={inputWrapperStyles}>
41
+ {type === "checkbox" ? (
42
+ <Checkbox
43
+ key={option.key}
44
+ label={option.label}
45
+ isChecked={option.isSelected}
46
+ onChange={option.onClick}
47
+ className="!min-h-0"
48
+ labelClassName="!mb-0"
49
+ />
50
+ ) : (
51
+ <Radio
52
+ key={option.key}
53
+ label={option.label}
54
+ isChecked={option.isSelected}
55
+ onChange={option.onClick}
56
+ onClick={option.onClick}
57
+ />
58
+ )}
59
+ </div>
60
+ );
61
+ })}
62
+ </PopoverPanel>
63
+ </Popover>
64
+ );
65
+ };
66
+
67
+ export default DropdownWithMultiSelect;
@@ -1,11 +1,12 @@
1
- import AnimatedLabelInput, { IAnimatedLabelInputProps } from "./AnimatedLabelInput"
2
- import AnimatedLabelTextArea, { IAnimatedLabelTextAreaProps } from "./AnimatedLabelTextArea"
3
- import ButtonDropdown, { IButtonDropdownProps } from "./ButtonDropdown"
4
- import Dropdown, { IDropdownProps, IItemProp } from "./DropdownComponent"
5
- import EmptySectionPlaceholder, { IEmptySectionPlaceholderProps } from "./EmptySectionPlaceholder"
6
- import FormInputWithAddons, { IFormInputWithAddonsProps } from "./FormInputWithAddons"
7
- import TextInputSelect, { ITextInputSelectProps } from "./TextInputSelect"
8
- import AnimatedFormInputWithAddons, { IAnimatedFormInputWithAddons } from "./AnimatedFormInputWithAddons"
1
+ import AnimatedLabelInput, { IAnimatedLabelInputProps } from "./AnimatedLabelInput";
2
+ import AnimatedLabelTextArea, { IAnimatedLabelTextAreaProps } from "./AnimatedLabelTextArea";
3
+ import ButtonDropdown, { IButtonDropdownProps } from "./ButtonDropdown";
4
+ import Dropdown, { IDropdownProps, IItemProp } from "./DropdownComponent";
5
+ import EmptySectionPlaceholder, { IEmptySectionPlaceholderProps } from "./EmptySectionPlaceholder";
6
+ import FormInputWithAddons, { IFormInputWithAddonsProps } from "./FormInputWithAddons";
7
+ import TextInputSelect, { ITextInputSelectProps } from "./TextInputSelect";
8
+ import AnimatedFormInputWithAddons, { IAnimatedFormInputWithAddons } from "./AnimatedFormInputWithAddons";
9
+ import DropdownWithMultiSelect, { MultiSelectItemProps } from "./DropdownWithMultiSelect/DropdownWithMultiSelect";
9
10
  export type {
10
11
  IAnimatedLabelInputProps,
11
12
  IAnimatedLabelTextAreaProps,
@@ -15,8 +16,9 @@ export type {
15
16
  IItemProp,
16
17
  IFormInputWithAddonsProps,
17
18
  ITextInputSelectProps,
18
- IAnimatedFormInputWithAddons
19
- }
19
+ IAnimatedFormInputWithAddons,
20
+ MultiSelectItemProps
21
+ };
20
22
  export {
21
23
  AnimatedLabelInput,
22
24
  AnimatedLabelTextArea,
@@ -25,5 +27,6 @@ export {
25
27
  EmptySectionPlaceholder,
26
28
  FormInputWithAddons,
27
29
  TextInputSelect,
28
- AnimatedFormInputWithAddons
29
- }
30
+ AnimatedFormInputWithAddons,
31
+ DropdownWithMultiSelect
32
+ };