linkedunion-design-kit 1.9.2 → 1.9.4

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 (142) hide show
  1. package/dist/app/layout.jsx +13 -0
  2. package/dist/app/page.jsx +25 -0
  3. package/dist/build/types/app/layout.d.ts +12 -0
  4. package/dist/build/types/app/layout.js +22 -0
  5. package/dist/build/types/app/page.d.ts +12 -0
  6. package/dist/build/types/app/page.js +22 -0
  7. package/dist/index.d.ts +4 -0
  8. package/dist/index.js +4 -0
  9. package/dist/src/components/Accordion/Accordion.stories.jsx +33 -0
  10. package/dist/src/components/Accordion/accordion.jsx +59 -0
  11. package/dist/src/components/Alerts/Alert/alert.jsx +152 -0
  12. package/dist/src/components/Alerts/Alert/alert.stories.jsx +344 -0
  13. package/dist/src/components/Alerts/AlertDialog/alert-dialog.jsx +170 -0
  14. package/dist/src/components/Alerts/AlertDialog/alert-dialog.stories.jsx +552 -0
  15. package/dist/src/components/AppIcons/AndroidIcon.jsx +24 -0
  16. package/dist/src/components/AppIcons/AppIcon.jsx +29 -0
  17. package/dist/src/components/AppIcons/AppIcon.stories.jsx +223 -0
  18. package/dist/src/components/AppIcons/AppleIcon.jsx +31 -0
  19. package/dist/src/components/AppIcons/PlayStoreIcon.jsx +29 -0
  20. package/dist/src/components/Avatar/Avatar/Avatar.jsx +45 -0
  21. package/dist/src/components/Avatar/Avatar/Avatar.stories.jsx +95 -0
  22. package/dist/src/components/Avatar/Avatar/Avatar.test.jsx +9 -0
  23. package/dist/src/components/Avatar/AvatarGroup/AvatarGroup.jsx +17 -0
  24. package/dist/src/components/Avatar/AvatarGroup/AvatarGroup.stories.jsx +32 -0
  25. package/dist/src/components/Avatar/StatusIndicator/StatusIndicator.jsx +20 -0
  26. package/dist/src/components/Avatar/StatusIndicator/StatusIndicator.stories.jsx +50 -0
  27. package/dist/src/components/Badge/Badge.jsx +54 -0
  28. package/dist/src/components/Badge/Badge.stories.jsx +201 -0
  29. package/dist/src/components/Button/Button/Button.d.ts +7 -6
  30. package/dist/src/components/Button/Button/Button.js +32 -9
  31. package/dist/src/components/Button/Button/Button.jsx +101 -0
  32. package/dist/src/components/Button/Button/Button.stories.jsx +283 -0
  33. package/dist/src/components/Button/Button/Button.test.jsx +73 -0
  34. package/dist/src/components/Button/IconButton/IconButton.jsx +63 -0
  35. package/dist/src/components/Button/IconButton/IconButton.stories.jsx +128 -0
  36. package/dist/src/components/Button/IconButton/IconButton.test.jsx +28 -0
  37. package/dist/src/components/Button/index.js +3 -3
  38. package/dist/src/components/Card/MultipleNews/MultiNews.jsx +80 -0
  39. package/dist/src/components/Card/MultipleNews/MultiNews.stories.jsx +104 -0
  40. package/dist/src/components/Card/PostByCategory/PostByCategory.jsx +60 -0
  41. package/dist/src/components/Card/PostByCategory/PostByCategory.stories.jsx +106 -0
  42. package/dist/src/components/Card/SinglePost/SinglePost.jsx +26 -0
  43. package/dist/src/components/Card/SinglePost/SinglePost.stories.jsx +68 -0
  44. package/dist/src/components/Card/card.jsx +36 -0
  45. package/dist/src/components/Card/contactProfile/ContactProfile.jsx +60 -0
  46. package/dist/src/components/Card/contactProfile/ContactProfile.stories.jsx +103 -0
  47. package/dist/src/components/Card/photoAlbum/PhotoAlbum.jsx +41 -0
  48. package/dist/src/components/Card/photoAlbum/PhotoAlbum.stories.jsx +69 -0
  49. package/dist/src/components/Card/photoGallery/PhotoGallery.jsx +17 -0
  50. package/dist/src/components/Card/photoGallery/PhotoGallery.stories.jsx +39 -0
  51. package/dist/src/components/Checkbox/checkbox.jsx +47 -0
  52. package/dist/src/components/Checkbox/checkbox.stories.jsx +113 -0
  53. package/dist/src/components/ColorPicker/ColorPicker.jsx +67 -0
  54. package/dist/src/components/ColorPicker/ColorPicker.stories.jsx +138 -0
  55. package/dist/src/components/Colors/color.jsx +5 -0
  56. package/dist/src/components/Colors/color.stories.jsx +20 -0
  57. package/dist/src/components/Colors/color.test.jsx +23 -0
  58. package/dist/src/components/Dropdown/Combobox/Combobox.jsx +198 -0
  59. package/dist/src/components/Dropdown/Combobox/Combobox.stories.jsx +289 -0
  60. package/dist/src/components/Dropdown/Combobox/utils/renderBadge.jsx +7 -0
  61. package/dist/src/components/Dropdown/DropdownMenu/DropdownMenu.jsx +102 -0
  62. package/dist/src/components/Dropdown/DropdownMenu/DropdownMenu.stories.jsx +464 -0
  63. package/dist/src/components/Dropdown/DropdownMenu/SelectAllSection.jsx +19 -0
  64. package/dist/src/components/Dropdown/Select.stories.jsx +201 -0
  65. package/dist/src/components/Dropdown/select.jsx +93 -0
  66. package/dist/src/components/Icons/LUIcon.jsx +41 -0
  67. package/dist/src/components/Icons/LUIcon.test.jsx +308 -0
  68. package/dist/src/components/Icons/stories/IconDropdown.jsx +67 -0
  69. package/dist/src/components/Icons/stories/IconGallery.jsx +77 -0
  70. package/dist/src/components/Icons/stories/InteractiveIconSelector.jsx +86 -0
  71. package/dist/src/components/Icons/stories/LUIcon.stories.jsx +108 -0
  72. package/dist/src/components/ImageUploader/ImageUploader.stories.jsx +50 -0
  73. package/dist/src/components/ImageUploader/imageUploader.jsx +94 -0
  74. package/dist/src/components/Images/LuImage.jsx +19 -0
  75. package/dist/src/components/Images/LuImage.stories.jsx +154 -0
  76. package/dist/src/components/Images/LuImage.test.jsx +44 -0
  77. package/dist/src/components/Input/Input.stories.jsx +250 -0
  78. package/dist/src/components/Input/input.jsx +110 -0
  79. package/dist/src/components/Label/Label.jsx +32 -0
  80. package/dist/src/components/Label/Label.stories.jsx +30 -0
  81. package/dist/src/components/Pagination/pagination.d.ts +33 -0
  82. package/dist/src/components/Pagination/pagination.js +68 -0
  83. package/dist/src/components/Pagination/pagination.jsx +68 -0
  84. package/dist/src/components/Pagination/pagination.stories.d.ts +74 -0
  85. package/dist/src/components/Pagination/pagination.stories.js +168 -0
  86. package/dist/src/components/Pagination/pagination.stories.jsx +114 -0
  87. package/dist/src/components/RadioGroup/RadioGroup.stories.jsx +146 -0
  88. package/dist/src/components/RadioGroup/radio-group.jsx +49 -0
  89. package/dist/src/components/Skeleton/skeleton.d.ts +117 -0
  90. package/dist/src/components/Skeleton/skeleton.js +140 -0
  91. package/dist/src/components/Skeleton/skeleton.stories.d.ts +153 -0
  92. package/dist/src/components/Skeleton/skeleton.stories.js +404 -0
  93. package/dist/src/components/Slider/Slider.stories.jsx +159 -0
  94. package/dist/src/components/Slider/slider.jsx +31 -0
  95. package/dist/src/components/SweetAlert/SweetAlert.jsx +147 -0
  96. package/dist/src/components/SweetAlert/SweetAlert.stories.jsx +505 -0
  97. package/dist/src/components/Switch/Switch.stories.jsx +66 -0
  98. package/dist/src/components/Switch/switch.jsx +61 -0
  99. package/dist/src/components/Table/Table.d.ts +26 -0
  100. package/dist/src/components/Table/Table.js +186 -0
  101. package/dist/src/components/Table/Table.jsx +221 -0
  102. package/dist/src/components/Table/Table.stories.d.ts +51 -0
  103. package/dist/src/components/Table/Table.stories.js +408 -0
  104. package/dist/src/components/Table/Table.stories.jsx +652 -0
  105. package/dist/src/components/Table/index.d.ts +20 -0
  106. package/dist/src/components/Table/index.js +20 -0
  107. package/dist/src/components/Tabs/Tabs.stories.jsx +29 -0
  108. package/dist/src/components/Tabs/tabs.jsx +32 -0
  109. package/dist/src/components/Title/Title.jsx +8 -0
  110. package/dist/src/components/Title/Title.stories.jsx +37 -0
  111. package/dist/src/components/Title/Title.test.jsx +24 -0
  112. package/dist/src/components/ToolTip/Tooltip.jsx +18 -0
  113. package/dist/src/components/ToolTip/Tooltip.stories.jsx +25 -0
  114. package/dist/src/components/Typography/Body/Body.stories.jsx +34 -0
  115. package/dist/src/components/Typography/Body/body.jsx +52 -0
  116. package/dist/src/components/Typography/Caption/Caption.stories.jsx +24 -0
  117. package/dist/src/components/Typography/Caption/caption.jsx +25 -0
  118. package/dist/src/components/Typography/Display/Display.stories.jsx +24 -0
  119. package/dist/src/components/Typography/Display/display.jsx +39 -0
  120. package/dist/src/components/Typography/Heading/Heading.stories.jsx +37 -0
  121. package/dist/src/components/Typography/Heading/heading.jsx +53 -0
  122. package/dist/src/components/ui/avatar.d.ts +3 -10
  123. package/dist/src/components/ui/avatar.js +12 -27
  124. package/dist/src/components/ui/avatar.jsx +27 -0
  125. package/dist/src/components/ui/button.d.ts +10 -0
  126. package/dist/src/components/ui/button.js +56 -0
  127. package/dist/src/components/ui/button.jsx +45 -0
  128. package/dist/src/components/ui/collapsible.d.ts +5 -0
  129. package/dist/src/components/ui/collapsible.js +5 -0
  130. package/dist/src/components/ui/collapsible.jsx +5 -0
  131. package/dist/src/components/ui/command.jsx +67 -0
  132. package/dist/src/components/ui/dialog.jsx +66 -0
  133. package/dist/src/components/ui/popover.jsx +33 -0
  134. package/dist/src/components/ui/tooltip.jsx +38 -0
  135. package/dist/src/components/ui/typography.jsx +56 -0
  136. package/dist/src/utils/colors.js +11 -11
  137. package/dist/src/utils/iconList.d.ts +4 -0
  138. package/dist/src/utils/iconList.js +4 -0
  139. package/dist/styles/global.css +209 -67
  140. package/package.json +1 -1
  141. package/dist/src/components/Avatar/Avatar/Avatar1.stories.d.ts +0 -17
  142. package/dist/src/components/Avatar/Avatar/Avatar1.stories.js +0 -68
@@ -0,0 +1,198 @@
1
+ "use client";
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
+ if (ar || !(i in from)) {
5
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
+ ar[i] = from[i];
7
+ }
8
+ }
9
+ return to.concat(ar || Array.prototype.slice.call(from));
10
+ };
11
+ import { useRef, useState, useEffect, useMemo } from "react";
12
+ import { cn } from "../../../lib/utils";
13
+ import { Badge } from "../../../components/Badge/Badge";
14
+ import { renderBadge } from "./utils/renderBadge";
15
+ import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, } from "../../../components/ui/command";
16
+ import { Popover, PopoverContent, PopoverTrigger, } from "../../../components/ui/popover";
17
+ import { Button } from "../../../components/Button/Button/Button";
18
+ import LUIcon from "../../../components/Icons/LUIcon";
19
+ import { Checkbox } from "../../../components/Checkbox/checkbox";
20
+ import { comboboxColor, comboboxSelectType, comboboxShapes, comboboxSizes, iconSizeMap, } from ".";
21
+ import { Label } from "../../../components/Label/Label";
22
+ import { Caption } from "../../../components/Typography/Caption/caption";
23
+ import { empty_message } from "../../../utils/constants";
24
+ import Tooltip from "../../../components/ToolTip/Tooltip";
25
+ import { useResponsiveBadges } from "./utils/useResponsiveBadge";
26
+ import { getLabelVariant } from "./utils/getLabelVariant";
27
+ var Combobox = function (props) {
28
+ var _a = props.size, size = _a === void 0 ? "md" : _a, _b = props.placeholder, placeholder = _b === void 0 ? "Select Options" : _b, _c = props.shape, shape = _c === void 0 ? "rectangular" : _c, _d = props.variant, variant = _d === void 0 ? "fill" : _d, _e = props.color, color = _e === void 0 ? "default" : _e, options = props.options, _f = props.isSearch, isSearch = _f === void 0 ? false : _f, _g = props.isMulti, isMulti = _g === void 0 ? false : _g, onSelect = props.onSelect, renderOption = props.renderOption, _h = props.disabled, disabled = _h === void 0 ? false : _h, defaultValue = props.defaultValue;
29
+ var _j = useState(false), open = _j[0], setOpen = _j[1];
30
+ var _k = useState(""), singleValue = _k[0], setSingleValue = _k[1];
31
+ var _l = useState([]), multiValue = _l[0], setMultiValue = _l[1];
32
+ var buttonRef = useRef(null);
33
+ var _m = useState(), popoverWidth = _m[0], setPopoverWidth = _m[1];
34
+ var maxVisibleBadges = useResponsiveBadges();
35
+ useEffect(function () {
36
+ if (isMulti && Array.isArray(defaultValue)) {
37
+ setMultiValue(defaultValue);
38
+ }
39
+ else {
40
+ setSingleValue(defaultValue);
41
+ }
42
+ }, [defaultValue, isMulti]);
43
+ useEffect(function () {
44
+ if (open && buttonRef.current) {
45
+ setPopoverWidth("".concat(buttonRef.current.offsetWidth, "px"));
46
+ }
47
+ }, [open]);
48
+ var handleSelect = function (currentValue) {
49
+ if (isMulti) {
50
+ setMultiValue(function (prev) {
51
+ var newValue = prev.includes(currentValue)
52
+ ? prev.filter(function (v) { return v !== currentValue; })
53
+ : __spreadArray(__spreadArray([], prev, true), [currentValue], false);
54
+ onSelect === null || onSelect === void 0 ? void 0 : onSelect(newValue);
55
+ return newValue;
56
+ });
57
+ }
58
+ else {
59
+ var newValue = currentValue === singleValue ? "" : currentValue;
60
+ setSingleValue(newValue);
61
+ onSelect === null || onSelect === void 0 ? void 0 : onSelect(newValue);
62
+ setOpen(false);
63
+ }
64
+ };
65
+ var handleSelectAll = function () {
66
+ if (!options)
67
+ return;
68
+ var allValues = options.map(function (option) {
69
+ return typeof option === "string" ? option : option.value;
70
+ });
71
+ var newValues = multiValue.length === allValues.length ? [] : allValues;
72
+ setMultiValue(newValues);
73
+ onSelect === null || onSelect === void 0 ? void 0 : onSelect(newValues);
74
+ };
75
+ var getDisplay = useMemo(function () {
76
+ var handleRemove = function (value) {
77
+ if (isMulti) {
78
+ var newValues = multiValue.filter(function (val) { return val !== value; });
79
+ setMultiValue(newValues);
80
+ onSelect === null || onSelect === void 0 ? void 0 : onSelect(newValues);
81
+ }
82
+ else {
83
+ setSingleValue("");
84
+ onSelect === null || onSelect === void 0 ? void 0 : onSelect("");
85
+ }
86
+ };
87
+ if (!options)
88
+ return placeholder;
89
+ if (isMulti) {
90
+ if (!multiValue.length)
91
+ return placeholder;
92
+ var selectedOptions = options.filter(function (option) {
93
+ return typeof option === "string"
94
+ ? multiValue.includes(option)
95
+ : multiValue.includes(option.value);
96
+ });
97
+ if (selectedOptions.length <= maxVisibleBadges) {
98
+ return (<div className="flex flex-wrap gap-1">
99
+ {selectedOptions.map(function (option) {
100
+ return renderBadge(typeof option === "string"
101
+ ? { key: option, value: option }
102
+ : option, handleRemove);
103
+ })}
104
+ </div>);
105
+ }
106
+ var remainingCount = selectedOptions.length - maxVisibleBadges;
107
+ var remainingOptions = selectedOptions.slice(maxVisibleBadges);
108
+ return (<div className="flex flex-wrap gap-1">
109
+ {selectedOptions
110
+ .slice(0, maxVisibleBadges)
111
+ .map(function (option) {
112
+ return renderBadge(typeof option === "string"
113
+ ? { key: option, value: option }
114
+ : option, handleRemove);
115
+ })}
116
+ {/* TODO: Update Tooltip design */}
117
+ <Tooltip title={remainingOptions
118
+ .map(function (option) {
119
+ return typeof option === "string" ? option : option.key;
120
+ })
121
+ .join(", ")}>
122
+ <Badge color="light-blue" className="cursor-help">
123
+ +{remainingCount}
124
+ </Badge>
125
+ </Tooltip>
126
+ </div>);
127
+ }
128
+ else {
129
+ if (!singleValue)
130
+ return placeholder;
131
+ var isMatch = function (option) {
132
+ return typeof option === "string"
133
+ ? option === singleValue
134
+ : option.value === singleValue;
135
+ };
136
+ var found = options.find(isMatch);
137
+ return found
138
+ ? renderBadge(typeof found === "string" ? { key: found, value: found } : found, handleRemove)
139
+ : placeholder;
140
+ }
141
+ }, [
142
+ options,
143
+ placeholder,
144
+ isMulti,
145
+ multiValue,
146
+ singleValue,
147
+ maxVisibleBadges,
148
+ onSelect,
149
+ setMultiValue,
150
+ setSingleValue,
151
+ ]);
152
+ var normalizedOptions = useMemo(function () { return (Array.isArray(options) ? options : []); }, [options]);
153
+ return (<Popover open={open} onOpenChange={setOpen}>
154
+ <PopoverTrigger asChild>
155
+ <Button ref={buttonRef} variant="outline" role="combobox" color="light-gray" aria-expanded={open} className={cn("w-full justify-between !py-3 !px-4 font-normal !leading-normal hover:!bg-transparent active:!bg-transparent", comboboxSizes[size], comboboxSelectType[variant], comboboxColor[variant][color], open && comboboxColor[variant]["blue"], disabled && [
156
+ variant === "fill" && "bg-gray-100",
157
+ "border border-gray-300 cursor-not-allowed pointer-events-none",
158
+ ], "min-h-[42px]")} shape={comboboxShapes[shape]} disabled={disabled} tabIndex={disabled ? -1 : 0}>
159
+ <div className="flex-grow flex items-center">{getDisplay}</div>
160
+ <LUIcon icon="angle-down" size={iconSizeMap[size]} color="light-gray"/>
161
+ </Button>
162
+ </PopoverTrigger>
163
+ <PopoverContent className="p-0" style={popoverWidth ? { width: popoverWidth } : {}}>
164
+ <Command>
165
+ {isSearch && (<CommandInput placeholder="Search" className={comboboxSizes[size]}/>)}
166
+ {isMulti && normalizedOptions.length > 0 && (<div className="flex flex-col gap-1 !px-4 !py-3 rounded-sm bg-gray-50 text-gray-800">
167
+ <div className="flex items-center gap-2">
168
+ <Checkbox id="select-all" checked={multiValue.length === normalizedOptions.length} onCheckedChange={handleSelectAll} size={size}/>
169
+ <Label variant={getLabelVariant(size)}>Select All</Label>
170
+ </div>
171
+ <Caption variant="sm" className="text-gray-500">
172
+ Selected ({multiValue.length})
173
+ </Caption>
174
+ </div>)}
175
+ <CommandList>
176
+ <CommandEmpty>{empty_message}</CommandEmpty>
177
+ <CommandGroup>
178
+ {normalizedOptions.map(function (option) {
179
+ var normalizedOption = typeof option === "string"
180
+ ? { key: option, value: option }
181
+ : option;
182
+ var selected = isMulti
183
+ ? multiValue.includes(normalizedOption.value)
184
+ : singleValue === normalizedOption.value;
185
+ return (<CommandItem key={normalizedOption.value} value={normalizedOption.value} onSelect={function () { return handleSelect(normalizedOption.value); }} size={size} className={cn(selected &&
186
+ "bg-blue-50 text-blue-600 hover:text-blue-600")}>
187
+ {renderOption
188
+ ? renderOption(normalizedOption)
189
+ : normalizedOption.key}
190
+ </CommandItem>);
191
+ })}
192
+ </CommandGroup>
193
+ </CommandList>
194
+ </Command>
195
+ </PopoverContent>
196
+ </Popover>);
197
+ };
198
+ export default Combobox;
@@ -0,0 +1,289 @@
1
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3
+ if (ar || !(i in from)) {
4
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5
+ ar[i] = from[i];
6
+ }
7
+ }
8
+ return to.concat(ar || Array.prototype.slice.call(from));
9
+ };
10
+ import { useState } from "react";
11
+ import Combobox from "./Combobox";
12
+ import { comboboxColor, comboboxSelectType, comboboxShapes, comboboxSizes, } from ".";
13
+ import LUIcon from "../../../components/Icons/LUIcon";
14
+ import { Label } from "../../../components/Label/Label";
15
+ import Tooltip from "../../../components/ToolTip/Tooltip";
16
+ import { Caption } from "../../../components/Typography/Caption/caption";
17
+ import { Button } from "../../../components/Button/Button/Button";
18
+ import { Checkbox } from "../../../components/Checkbox/checkbox";
19
+ import { Badge } from "../../../components/Badge/Badge";
20
+ export default {
21
+ title: "Components/Dropdown/Combobox",
22
+ component: Combobox,
23
+ tags: ["autodocs"],
24
+ argTypes: {
25
+ options: {
26
+ control: { type: "object" },
27
+ description: "Options for the combobox dropdown",
28
+ table: {
29
+ type: { summary: "Array<{ value: string; label: string }>" },
30
+ defaultValue: { summary: "See default" },
31
+ },
32
+ },
33
+ size: {
34
+ control: { type: "select" },
35
+ options: Object.keys(comboboxSizes),
36
+ description: "Size of the combobox button",
37
+ table: {
38
+ type: { summary: "comboboxSizes" },
39
+ defaultValue: { summary: "md" },
40
+ },
41
+ },
42
+ placeholder: {
43
+ control: { type: "text" },
44
+ description: "Placeholder text for the combobox",
45
+ table: {
46
+ type: { summary: "string" },
47
+ defaultValue: { summary: "Select Options" },
48
+ },
49
+ },
50
+ shape: {
51
+ control: { type: "select" },
52
+ options: Object.keys(comboboxShapes),
53
+ description: "Shape of the combobox button",
54
+ table: {
55
+ type: { summary: "comboboxShapes" },
56
+ defaultValue: { summary: "rectangular" },
57
+ },
58
+ },
59
+ variant: {
60
+ control: { type: "select" },
61
+ options: Object.keys(comboboxSelectType),
62
+ description: "Type of the combobox",
63
+ table: {
64
+ type: { summary: "comboboxSelectType" },
65
+ defaultValue: { summary: "fill" },
66
+ },
67
+ },
68
+ color: {
69
+ control: { type: "select" },
70
+ options: Object.keys(comboboxColor.fill),
71
+ description: "Color of the combobox",
72
+ table: {
73
+ type: { summary: "comboboxColor" },
74
+ defaultValue: { summary: "default" },
75
+ },
76
+ },
77
+ isSearch: {
78
+ control: { type: "boolean" },
79
+ description: "Enable search functionality",
80
+ table: {
81
+ type: { summary: "boolean" },
82
+ defaultValue: { summary: "false" },
83
+ },
84
+ },
85
+ isMulti: {
86
+ control: { type: "boolean" },
87
+ description: "Enable multi-select functionality",
88
+ table: {
89
+ type: { summary: "boolean" },
90
+ defaultValue: { summary: "false" },
91
+ },
92
+ },
93
+ onSelect: {
94
+ control: false,
95
+ description: "Callback fired when an option is selected",
96
+ table: {
97
+ type: { summary: "(selected: any) => void" },
98
+ },
99
+ },
100
+ disabled: {
101
+ control: { type: "boolean" },
102
+ description: "Disable the combobox",
103
+ table: {
104
+ type: { summary: "boolean" },
105
+ defaultValue: { summary: "false" },
106
+ },
107
+ },
108
+ renderOption: {
109
+ control: false,
110
+ description: "Custom render function for options",
111
+ table: {
112
+ type: { summary: "(option: any) => ReactNode" },
113
+ },
114
+ },
115
+ defaultValue: {
116
+ control: { type: "text" },
117
+ description: "Default value for the combobox",
118
+ table: {
119
+ type: { summary: "string | string[]" },
120
+ },
121
+ },
122
+ },
123
+ };
124
+ var Template = function (args) { return <Combobox {...args}/>; };
125
+ export var Default = Template.bind({});
126
+ Default.args = {
127
+ size: "md",
128
+ placeholder: "Select Options",
129
+ shape: "rectangular",
130
+ options: [
131
+ { key: "next.js", value: "Next.js" },
132
+ { key: "sveltekit", value: "SvelteKit" },
133
+ { key: "nest.js", value: "Nest.js" },
134
+ { key: "remix", value: "Remix" },
135
+ { key: "astro", value: "Astro" },
136
+ { key: "react", value: "React" },
137
+ { key: "nest", value: "Nest" },
138
+ { key: "python", value: "Python" },
139
+ { key: "ai", value: "AI" },
140
+ ],
141
+ isSearch: true,
142
+ isMulti: true,
143
+ renderOption: function (option) { return (<>
144
+ {option.icon && <LUIcon icon={option.icon} size="md"/>}
145
+ <span>{option.key}</span>
146
+ </>); },
147
+ onSelect: function (value) { return console.log(value); },
148
+ };
149
+ export var Basic = function () { return (<Combobox options={[
150
+ { key: "React", value: "react" },
151
+ { key: "Vue", value: "vue" },
152
+ ]} onSelect={function (value) { return console.log(value); }}/>); };
153
+ export var ComboboxSize = function () { return (<div className="space-y-4">
154
+ <Combobox size="sm" options={[
155
+ { key: "React", value: "react" },
156
+ { key: "Vue", value: "vue" },
157
+ ]} onSelect={function (value) { return console.log(value); }}/>
158
+ <Combobox size="md" options={[
159
+ { key: "React", value: "react" },
160
+ { key: "Vue", value: "vue" },
161
+ ]} onSelect={function (value) { return console.log(value); }}/>
162
+ <Combobox size="lg" options={[
163
+ { key: "React", value: "react" },
164
+ { key: "Vue", value: "vue" },
165
+ ]} onSelect={function (value) { return console.log(value); }}/>
166
+ </div>); };
167
+ export var ComboboxType = function () { return (<div className="space-y-4">
168
+ <Label variant="label-sm">Text</Label>
169
+ <Combobox isMulti options={["React", "Vue", "Angular"]} renderOption={function (option) { return <span>{option.value}</span>; }}/>
170
+
171
+ <Label variant="label-sm">Text With Right Icon</Label>
172
+ <Combobox isMulti options={["React", "Vue", "Angular"]} renderOption={function (option) { return (<div className="flex items-center justify-between w-full">
173
+ <span>{option.value}</span>
174
+ <LUIcon icon="plus"/>
175
+ </div>); }}/>
176
+
177
+ <Label variant="label-sm">Text With Left Icon</Label>
178
+ <Combobox isMulti options={[
179
+ { key: "next.js", value: "Next.js", icon: "plus" },
180
+ { key: "sveltekit", value: "SvelteKit", icon: "star" },
181
+ { key: "nest.js", value: "Nest.js", icon: "check" },
182
+ { key: "remix", value: "Remix", icon: "minus" },
183
+ { key: "astro", value: "Astro", icon: "plus" },
184
+ ]} renderOption={function (option) { return (<div className="flex items-center gap-2 w-full">
185
+ <LUIcon icon={option.icon}/>
186
+ <span>{option.value}</span>
187
+ </div>); }}/>
188
+
189
+ <Label variant="label-sm">Badge</Label>
190
+ <Combobox isMulti options={["React", "Vue", "Angular"]} renderOption={function (option) { return (<Badge startIcon="star" color="light-blue">
191
+ {option.value}
192
+ </Badge>); }}/>
193
+
194
+ <Label variant="label-sm">Text+Counter</Label>
195
+ <Combobox isMulti options={["React", "Vue", "Angular"]} renderOption={function (option) { return (<div className="flex items-center justify-between w-full">
196
+ <span>{option.value}</span>
197
+ <Badge color="light-blue">{+3}</Badge>
198
+ </div>); }}/>
199
+ </div>); };
200
+ export var ComboboxWithCheckbox = function () {
201
+ var _a = useState([]), selected = _a[0], setSelected = _a[1];
202
+ var options = ["React", "Vue", "Angular"];
203
+ var onCheckChange = function (value) {
204
+ setSelected(function (prev) {
205
+ return prev.includes(value) ? prev.filter(function (v) { return v !== value; }) : __spreadArray(__spreadArray([], prev, true), [value], false);
206
+ });
207
+ };
208
+ return (<Combobox isMulti options={options} onSelect={function (value) {
209
+ if (Array.isArray(value)) {
210
+ setSelected(value);
211
+ }
212
+ }} renderOption={function (option) { return (<div className="flex items-center gap-2 w-full">
213
+ <Checkbox id={"checkbox-".concat(option.value)} checked={selected.includes(option.value)} onCheckedChange={function () {
214
+ onCheckChange(option.value);
215
+ }}/>
216
+ <span>{option.value}</span>
217
+ </div>); }}/>);
218
+ };
219
+ export var ComboboxWithUserIcon = function () { return (<Combobox isMulti options={["React", "Vue", "Angular", "Nest", "Next"]} renderOption={function (option) { return (<div className="flex items-center gap-2 w-full">
220
+ {/* TODO: Replace it with Avatar */}
221
+ <LUIcon icon="user" variant="padded"/>
222
+ <span>{option.value}</span>
223
+ </div>); }}/>); };
224
+ export var ComboboxWithDefaultValue = function () { return (<div className="space-y-4">
225
+ <Label variant="label-sm">Multiple Default Values in Multiple Select</Label>
226
+ <Combobox isMulti isSearch options={["React", "Vue", "Angular", "Nest", "Next"]} defaultValue={["React", "Vue"]} renderOption={function (option) { return (<div className="flex items-center gap-2 w-full">
227
+ <LUIcon icon="plus"/>
228
+ <span>{option.value}</span>
229
+ </div>); }}/>
230
+
231
+ <Label variant="label-sm">Single Default Value in Multiple Select</Label>
232
+ <Combobox isMulti isSearch options={["React", "Vue", "Angular", "Nest", "Next"]} defaultValue={["React"]} renderOption={function (option) { return (<div className="flex items-center gap-2 w-full">
233
+ <LUIcon icon="plus"/>
234
+ <span>{option.value}</span>
235
+ </div>); }}/>
236
+
237
+ <Label variant="label-sm">Single Default Value in Single Select</Label>
238
+ <Combobox isSearch options={["React", "Vue", "Angular", "Nest", "Next"]} defaultValue={"React"} renderOption={function (option) { return (<div className="flex items-center gap-2 w-full">
239
+ <LUIcon icon="plus"/>
240
+ <span>{option.value}</span>
241
+ </div>); }}/>
242
+ </div>); };
243
+ export var ListOfArray = function () { return (<Combobox isMulti isSearch options={["React", "Vue", "Angular", "Nest", "Next"]} renderOption={function (option) { return (<div className="flex items-center gap-2 w-full">
244
+ <LUIcon icon="plus"/>
245
+ <span>{option.value}</span>
246
+ </div>); }}/>); };
247
+ export var ComboboxValidation = function () {
248
+ var _a = useState(""), selected = _a[0], setSelected = _a[1];
249
+ var _b = useState(false), error = _b[0], setError = _b[1];
250
+ var handleSelect = function (value) {
251
+ // Since isMulti is false, value will be string
252
+ if (typeof value === "string") {
253
+ setSelected(value);
254
+ if (value && error)
255
+ setError(false);
256
+ }
257
+ };
258
+ var handleSubmit = function (e) {
259
+ e.preventDefault();
260
+ if (!selected) {
261
+ setError(true);
262
+ }
263
+ else {
264
+ setError(false);
265
+ }
266
+ };
267
+ return (<form className="space-y-4" onSubmit={handleSubmit}>
268
+ <div className="flex items-center gap-2 mb-2">
269
+ <Label variant="label-sm">Select Category</Label>
270
+ <span className="text-red-600">*</span>
271
+ <Tooltip title="Select Option">
272
+ <LUIcon variant="padded" size="xs" shape="rounded" icon="question" color="light-blue"/>
273
+ </Tooltip>
274
+ </div>
275
+ <div>
276
+ <Combobox placeholder="Select framework..." size="md" options={[
277
+ { key: "next.js", value: "Next.js" },
278
+ { key: "sveltekit", value: "SvelteKit" },
279
+ { key: "nest.js", value: "Nest.js" },
280
+ { key: "remix", value: "Remix" },
281
+ { key: "astro", value: "Astro" },
282
+ ]} isSearch onSelect={handleSelect} color={error ? "red" : "default"} renderOption={function (option) { return <span>{option.value}</span>; }}/>
283
+ {error && (<Caption variant="md" className="mt-1 text-red-600">
284
+ field is required
285
+ </Caption>)}
286
+ </div>
287
+ <Button type="submit">Submit</Button>
288
+ </form>);
289
+ };
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ import { Badge } from "../../../../components/Badge/Badge";
3
+ export var renderBadge = function (option, handleRemove) {
4
+ return (<Badge key={option.value} color="light-blue" startIcon={option.icon} onRemove={function () { return handleRemove(option.value); }}>
5
+ {option.key}
6
+ </Badge>);
7
+ };
@@ -0,0 +1,102 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import * as React from "react";
13
+ import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
14
+ import { ChevronRight, Circle } from "lucide-react";
15
+ import { cn } from "../../../lib/utils";
16
+ import { checkBoxSize, dropdownMenuIconSize, dropDownMenuItemSize, dropdownMenuSize, } from ".";
17
+ import { Checkbox } from "../../../components/Checkbox/checkbox";
18
+ // Provide size from Content to all items
19
+ var DropdownMenuSizeContext = React.createContext("md");
20
+ var DropdownMenu = DropdownMenuPrimitive.Root;
21
+ var DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
22
+ var DropdownMenuGroup = DropdownMenuPrimitive.Group;
23
+ var DropdownMenuPortal = DropdownMenuPrimitive.Portal;
24
+ var DropdownMenuSub = DropdownMenuPrimitive.Sub;
25
+ var DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
26
+ var DropdownMenuSubTrigger = React.forwardRef(function (_a, ref) {
27
+ var className = _a.className, inset = _a.inset, children = _a.children, props = __rest(_a, ["className", "inset", "children"]);
28
+ return (<DropdownMenuPrimitive.SubTrigger ref={ref} className={cn("flex cursor-default select-none items-center gap-2 rounded-sm p-2 outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0", inset && "pl-8", className)} {...props}>
29
+ {children}
30
+ <ChevronRight className="ml-auto"/>
31
+ </DropdownMenuPrimitive.SubTrigger>);
32
+ });
33
+ DropdownMenuSubTrigger.displayName =
34
+ DropdownMenuPrimitive.SubTrigger.displayName;
35
+ var DropdownMenuSubContent = React.forwardRef(function (_a, ref) {
36
+ var _b;
37
+ var className = _a.className, size = _a.size, props = __rest(_a, ["className", "size"]);
38
+ var inheritedSize = React.useContext(DropdownMenuSizeContext);
39
+ var effectiveSize = (_b = size !== null && size !== void 0 ? size : inheritedSize) !== null && _b !== void 0 ? _b : "md";
40
+ return (<DropdownMenuPrimitive.SubContent ref={ref} className={cn("z-50 min-w-[8rem] overflow-hidden rounded-sm bg-white text-gray-900 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]", className, dropDownMenuItemSize[effectiveSize])} {...props}/>);
41
+ });
42
+ DropdownMenuSubContent.displayName =
43
+ DropdownMenuPrimitive.SubContent.displayName;
44
+ var DropdownMenuContent = React.forwardRef(function (_a, ref) {
45
+ var className = _a.className, _b = _a.sideOffset, sideOffset = _b === void 0 ? 4 : _b, _c = _a.size, size = _c === void 0 ? "md" : _c, _d = _a.align, align = _d === void 0 ? "start" : _d, props = __rest(_a, ["className", "sideOffset", "size", "align"]);
46
+ return (<DropdownMenuPrimitive.Portal>
47
+ <DropdownMenuSizeContext.Provider value={size}>
48
+ <DropdownMenuPrimitive.Content ref={ref} sideOffset={sideOffset} align={align} // Pass align prop to DropdownMenuPrimitive.Content
49
+ className={cn("z-50 max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-sm bg-white p-2 text-gray-900 shadow-backdrop-shadow-lg", "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]", dropdownMenuSize[size], className)} {...props}/>
50
+ </DropdownMenuSizeContext.Provider>
51
+ </DropdownMenuPrimitive.Portal>);
52
+ });
53
+ DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
54
+ var DropdownMenuItem = React.forwardRef(function (_a, ref) {
55
+ var _b;
56
+ var className = _a.className, inset = _a.inset, selected = _a.selected, size = _a.size, props = __rest(_a, ["className", "inset", "selected", "size"]);
57
+ var inheritedSize = React.useContext(DropdownMenuSizeContext);
58
+ var effectiveSize = (_b = size !== null && size !== void 0 ? size : inheritedSize) !== null && _b !== void 0 ? _b : "md";
59
+ return (<DropdownMenuPrimitive.Item ref={ref} className={cn("relative flex cursor-pointer select-none items-center gap-2 rounded-sm outline-none transition-colors text-gray-900 hover:bg-blue-50 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[disabled]:bg-gray-100 data-[disabled]:text-gray-300 [&>svg]:shrink-0", dropdownMenuIconSize[effectiveSize], dropdownMenuSize[effectiveSize], dropDownMenuItemSize[effectiveSize], inset && "pl-8", selected && "bg-blue-50 text-blue-600", // Apply styles for selected item
60
+ className)} {...props}/>);
61
+ });
62
+ DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
63
+ var DropdownMenuCheckboxItem = React.forwardRef(function (_a, ref) {
64
+ var _b;
65
+ var className = _a.className, children = _a.children, checked = _a.checked, size = _a.size, props = __rest(_a, ["className", "children", "checked", "size"]);
66
+ var inheritedSize = React.useContext(DropdownMenuSizeContext);
67
+ var effectiveSize = (_b = size !== null && size !== void 0 ? size : inheritedSize) !== null && _b !== void 0 ? _b : "md";
68
+ return (<DropdownMenuPrimitive.CheckboxItem ref={ref} className={cn("relative flex cursor-default select-none items-center gap-2 rounded-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", className, dropDownMenuItemSize[effectiveSize])} checked={checked} {...props}>
69
+ <Checkbox size={checkBoxSize[effectiveSize]} checked={!!checked} className="pointer-events-none"/>
70
+ {children}
71
+ </DropdownMenuPrimitive.CheckboxItem>);
72
+ });
73
+ DropdownMenuCheckboxItem.displayName =
74
+ DropdownMenuPrimitive.CheckboxItem.displayName;
75
+ var DropdownMenuRadioItem = React.forwardRef(function (_a, ref) {
76
+ var className = _a.className, children = _a.children, props = __rest(_a, ["className", "children"]);
77
+ return (<DropdownMenuPrimitive.RadioItem ref={ref} className={cn("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", className)} {...props}>
78
+ <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
79
+ <DropdownMenuPrimitive.ItemIndicator>
80
+ <Circle className="h-2 w-2 fill-current"/>
81
+ </DropdownMenuPrimitive.ItemIndicator>
82
+ </span>
83
+ {children}
84
+ </DropdownMenuPrimitive.RadioItem>);
85
+ });
86
+ DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
87
+ var DropdownMenuLabel = React.forwardRef(function (_a, ref) {
88
+ var className = _a.className, inset = _a.inset, props = __rest(_a, ["className", "inset"]);
89
+ return (<DropdownMenuPrimitive.Label ref={ref} className={cn("px-2 py-1.5 text-sm font-semibold", inset && "pl-8", className)} {...props}/>);
90
+ });
91
+ DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
92
+ var DropdownMenuSeparator = React.forwardRef(function (_a, ref) {
93
+ var className = _a.className, props = __rest(_a, ["className"]);
94
+ return (<DropdownMenuPrimitive.Separator ref={ref} className={cn("-mx-1 my-1 h-px bg-muted", className)} {...props}/>);
95
+ });
96
+ DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
97
+ var DropdownMenuShortcut = function (_a) {
98
+ var className = _a.className, props = __rest(_a, ["className"]);
99
+ return (<span className={cn("ml-auto text-xs tracking-widest opacity-60", className)} {...props}/>);
100
+ };
101
+ DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
102
+ export { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuCheckboxItem, DropdownMenuRadioItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuGroup, DropdownMenuPortal, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuRadioGroup, };