@addsign/moje-agenda-shared-lib 2.0.40 → 2.0.42

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 (126) hide show
  1. package/dist/Combination-D2GKeTwa.js +1162 -0
  2. package/dist/Combination-D2GKeTwa.js.map +1 -0
  3. package/dist/Dialog-BWa_flly.js +424 -0
  4. package/dist/Dialog-BWa_flly.js.map +1 -0
  5. package/dist/Dialog-CCrUyF91.js +424 -0
  6. package/dist/Dialog-CCrUyF91.js.map +1 -0
  7. package/dist/assets/style.css +61 -8
  8. package/dist/chevron-down-CfJmko7t.js +14 -0
  9. package/dist/chevron-down-CfJmko7t.js.map +1 -0
  10. package/dist/components/Attachments.js +2 -1
  11. package/dist/components/Attachments.js.map +1 -1
  12. package/dist/components/ConfirmationModalDialog.js +1 -1
  13. package/dist/components/ConfirmationModalDialog.js.map +1 -1
  14. package/dist/components/Modal.js +1 -1
  15. package/dist/components/Modal.js.map +1 -1
  16. package/dist/components/datatable/DataTable.js +3 -2
  17. package/dist/components/datatable/DataTable.js.map +1 -1
  18. package/dist/components/datatable/DataTableServer.js +96 -61
  19. package/dist/components/datatable/DataTableServer.js.map +1 -1
  20. package/dist/components/form/AutocompleteSearchBar.js +5 -4
  21. package/dist/components/form/AutocompleteSearchBar.js.map +1 -1
  22. package/dist/components/form/AutocompleteSearchBarServer.js +2 -1
  23. package/dist/components/form/AutocompleteSearchBarServer.js.map +1 -1
  24. package/dist/components/form/DateRangeField.js +2 -2
  25. package/dist/components/form/DateRangeField.js.map +1 -1
  26. package/dist/components/form/FileInput.js +3 -2
  27. package/dist/components/form/FileInput.js.map +1 -1
  28. package/dist/components/form/FileInputMultiple.js +3 -2
  29. package/dist/components/form/FileInputMultiple.js.map +1 -1
  30. package/dist/components/form/FormField.js +8 -7
  31. package/dist/components/form/FormField.js.map +1 -1
  32. package/dist/components/form/InputField.js +3 -2
  33. package/dist/components/form/InputField.js.map +1 -1
  34. package/dist/components/form/PositionsSelectorSingle.js +2 -1
  35. package/dist/components/form/PositionsSelectorSingle.js.map +1 -1
  36. package/dist/components/form/RadioGroup.js +1 -1
  37. package/dist/components/form/RadioGroup.js.map +1 -1
  38. package/dist/components/form/SelectField.js +5 -4
  39. package/dist/components/form/SelectField.js.map +1 -1
  40. package/dist/components/layout/Neoptimizovano.js +2 -1
  41. package/dist/components/layout/Neoptimizovano.js.map +1 -1
  42. package/dist/components/layout/PageTitle.js +1 -1
  43. package/dist/components/layout/PageTitle.js.map +1 -1
  44. package/dist/components/layout/SectionTitle.js +1 -1
  45. package/dist/components/layout/SectionTitle.js.map +1 -1
  46. package/dist/components/profiles/ProfileOverview.js +2 -1
  47. package/dist/components/profiles/ProfileOverview.js.map +1 -1
  48. package/dist/components/ui/Combobox.js +1 -1
  49. package/dist/components/ui/DatePicker.js +1 -1
  50. package/dist/components/ui/DateTimePicker.js +1 -1
  51. package/dist/components/ui/Dialog.js +1 -1
  52. package/dist/components/ui/ScrollArea.js +2 -2
  53. package/dist/components/ui/async-combobox.d.ts +40 -0
  54. package/dist/components/ui/async-combobox.js +5706 -0
  55. package/dist/components/ui/async-combobox.js.map +1 -0
  56. package/dist/components/ui/badge.d.ts +9 -0
  57. package/dist/components/ui/badge.js +27 -0
  58. package/dist/components/ui/badge.js.map +1 -0
  59. package/dist/components/ui/checkbox.js +4 -4
  60. package/dist/components/ui/command.js +2 -2
  61. package/dist/components/ui/multi-select.d.ts +67 -0
  62. package/dist/components/ui/multi-select.js +295 -0
  63. package/dist/components/ui/multi-select.js.map +1 -0
  64. package/dist/components/ui/popover.js +1 -1
  65. package/dist/components/ui/radioGroup.js +5 -5
  66. package/dist/components/ui/select.js +8 -16
  67. package/dist/components/ui/select.js.map +1 -1
  68. package/dist/components/ui/toast.js +5 -5
  69. package/dist/components/ui/tooltip.js +6 -6
  70. package/dist/index-B0wyIFEr.js +47 -0
  71. package/dist/index-B0wyIFEr.js.map +1 -0
  72. package/dist/index-BcR8DnnV.js +234 -0
  73. package/dist/index-BcR8DnnV.js.map +1 -0
  74. package/dist/index-CDptxuif.js +234 -0
  75. package/dist/index-CDptxuif.js.map +1 -0
  76. package/dist/index-CK9QfV6i.js +40 -0
  77. package/dist/index-CK9QfV6i.js.map +1 -0
  78. package/dist/index-CcNKXchf.js +2203 -0
  79. package/dist/index-CcNKXchf.js.map +1 -0
  80. package/dist/index-CpcwEIT_.js +18 -0
  81. package/dist/index-CpcwEIT_.js.map +1 -0
  82. package/dist/index-CulRZKWg.js +2212 -0
  83. package/dist/index-CulRZKWg.js.map +1 -0
  84. package/dist/index-D75exu1X.js +18 -0
  85. package/dist/index-D75exu1X.js.map +1 -0
  86. package/dist/index-DoYsULhE.js +28878 -0
  87. package/dist/index-DoYsULhE.js.map +1 -0
  88. package/dist/index-Dr6Ds0Bg.js +1162 -0
  89. package/dist/index-Dr6Ds0Bg.js.map +1 -0
  90. package/dist/index-DsU1clfi.js +36 -0
  91. package/dist/index-DsU1clfi.js.map +1 -0
  92. package/dist/index-DzfDO78K.js +15 -0
  93. package/dist/index-DzfDO78K.js.map +1 -0
  94. package/dist/index-NZPkObcw.js +110 -0
  95. package/dist/index-NZPkObcw.js.map +1 -0
  96. package/dist/index-Vp9wI6hE.js +2203 -0
  97. package/dist/index-Vp9wI6hE.js.map +1 -0
  98. package/dist/index-qqHvAsVd.js +2266 -0
  99. package/dist/index-qqHvAsVd.js.map +1 -0
  100. package/dist/index-wO-IHm1z.js +131 -0
  101. package/dist/index-wO-IHm1z.js.map +1 -0
  102. package/dist/main.d.ts +1 -0
  103. package/dist/main.js +3 -1
  104. package/dist/main.js.map +1 -1
  105. package/dist/plus-sawBIbEd.js +26 -0
  106. package/dist/plus-sawBIbEd.js.map +1 -0
  107. package/dist/popover-CcrzvSk7.js +319 -0
  108. package/dist/popover-CcrzvSk7.js.map +1 -0
  109. package/dist/popover-DhdNw4fZ.js +319 -0
  110. package/dist/popover-DhdNw4fZ.js.map +1 -0
  111. package/lib/components/ConfirmationModalDialog.tsx +1 -1
  112. package/lib/components/Modal.tsx +1 -1
  113. package/lib/components/datatable/DataTable.tsx +1 -1
  114. package/lib/components/datatable/DataTableServer.tsx +113 -58
  115. package/lib/components/form/AutocompleteSearchBar.tsx +3 -3
  116. package/lib/components/form/DateRangeField.tsx +2 -2
  117. package/lib/components/form/FormField.tsx +6 -6
  118. package/lib/components/form/InputField.tsx +3 -2
  119. package/lib/components/form/RadioGroup.tsx +1 -1
  120. package/lib/components/form/SelectField.tsx +3 -3
  121. package/lib/components/layout/PageTitle.tsx +19 -19
  122. package/lib/components/layout/SectionTitle.tsx +1 -1
  123. package/lib/components/ui/badge.tsx +36 -0
  124. package/lib/components/ui/multi-select.tsx +365 -0
  125. package/lib/main.ts +4 -0
  126. package/package.json +1 -1
@@ -0,0 +1,365 @@
1
+ // src/components/multi-select.tsx
2
+
3
+ import * as React from "react";
4
+ import { cva, type VariantProps } from "class-variance-authority";
5
+ import { CheckIcon, XCircle, ChevronDown, XIcon } from "lucide-react";
6
+
7
+ import { cn } from "../../utils/utils";
8
+ import { Separator } from "./separator";
9
+ import { Button } from "./button";
10
+ import { Badge } from "./badge";
11
+ import { Popover, PopoverContent, PopoverTrigger } from "./popover";
12
+ import {
13
+ Command,
14
+ CommandEmpty,
15
+ CommandGroup,
16
+ CommandInput,
17
+ CommandItem,
18
+ CommandList,
19
+ CommandSeparator,
20
+ } from "./command";
21
+ import { IOptionItem } from "../../types";
22
+
23
+ /**
24
+ * Variants for the multi-select component to handle different styles.
25
+ * Uses class-variance-authority (cva) to define different styles based on "variant" prop.
26
+ */
27
+ const multiSelectVariants = cva("m-1 transition ease-in-out delay-150 ", {
28
+ variants: {
29
+ variant: {
30
+ default:
31
+ "border-foreground/10 text-foreground bg-card hover:bg-card/80 font-normal",
32
+ secondary:
33
+ "border-foreground/10 bg-secondary text-secondary-foreground hover:bg-secondary/80 font-normal",
34
+ destructive:
35
+ "border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80 font-normal",
36
+ inverted: "inverted",
37
+ },
38
+ },
39
+ defaultVariants: {
40
+ variant: "default",
41
+ },
42
+ });
43
+
44
+ /**
45
+ * Props for MultiSelect component
46
+ */
47
+ interface MultiSelectProps
48
+ extends Omit<
49
+ React.ButtonHTMLAttributes<HTMLButtonElement>,
50
+ "onChange" | "value"
51
+ >,
52
+ VariantProps<typeof multiSelectVariants> {
53
+ /**
54
+ * An array of option objects to be displayed in the multi-select component.
55
+ * Each option object has a label, value, and an optional icon.
56
+ */
57
+ options: IOptionItem[];
58
+
59
+ /**
60
+ * Callback function triggered when the selected values change.
61
+ * Receives an array of the new selected values.
62
+ */
63
+ onChange: (value: string[]) => void;
64
+
65
+ /** The controlled value of the component */
66
+ value?: string[];
67
+
68
+ /** The default selected values when the component mounts (uncontrolled mode) */
69
+ defaultValue?: string[];
70
+
71
+ /**
72
+ * Placeholder text to be displayed when no values are selected.
73
+ * Optional, defaults to "Select options".
74
+ */
75
+ placeholder?: string;
76
+
77
+ /**
78
+ * Placeholder text to be displayed when no values are selected.
79
+ * Optional, defaults to "Select options".
80
+ */
81
+ placeholderSearch?: string;
82
+
83
+ /**
84
+ * Maximum number of items to display. Extra selected items will be summarized.
85
+ * Optional, defaults to 3.
86
+ */
87
+ maxCount?: number;
88
+
89
+ /**
90
+ * The modality of the popover. When set to true, interaction with outside elements
91
+ * will be disabled and only popover content will be visible to screen readers.
92
+ * Optional, defaults to false.
93
+ */
94
+ modalPopover?: boolean;
95
+
96
+ /**
97
+ * If true, renders the multi-select component as a child of another component.
98
+ * Optional, defaults to false.
99
+ */
100
+ asChild?: boolean;
101
+
102
+ /**
103
+ * Additional class names to apply custom styles to the multi-select component.
104
+ * Optional, can be used to add custom styles.
105
+ */
106
+ className?: string;
107
+
108
+ /**
109
+ * If true, the multi-select component will be disabled.
110
+ * Optional, defaults to false.
111
+ */
112
+ disabled?: boolean;
113
+
114
+ /**
115
+ * value?: string;
116
+ onChange?: (value: string | undefined) => void;
117
+ */
118
+ }
119
+
120
+ export const MultiSelect = React.forwardRef<
121
+ HTMLButtonElement,
122
+ MultiSelectProps
123
+ >(
124
+ (
125
+ {
126
+ options,
127
+ onChange,
128
+ value: propValue,
129
+ variant,
130
+ defaultValue = [],
131
+ placeholder = "Vyberte možnosti",
132
+ placeholderSearch = "Vyhledejte",
133
+ maxCount = 3,
134
+ modalPopover = false,
135
+ asChild = false,
136
+ className,
137
+ ...props
138
+ },
139
+ ref
140
+ ) => {
141
+ const [selectedValues, setSelectedValues] = React.useState<string[]>(
142
+ propValue ?? defaultValue
143
+ );
144
+ const [isPopoverOpen, setIsPopoverOpen] = React.useState(false);
145
+
146
+ // Update internal state when controlled value changes
147
+ React.useEffect(() => {
148
+ if (propValue !== undefined) {
149
+ setSelectedValues(propValue);
150
+ }
151
+ }, [propValue]);
152
+
153
+ const handleValueChange = (newValues: string[]) => {
154
+ setSelectedValues(newValues);
155
+ onChange(newValues);
156
+ };
157
+
158
+ const handleTogglePopover = () => {
159
+ setIsPopoverOpen((prev) => !prev);
160
+ };
161
+
162
+ const toggleOption = (option: string | number | null) => {
163
+ if (option === null) return;
164
+ const optionStr = String(option);
165
+ const newSelectedValues = selectedValues.includes(optionStr)
166
+ ? selectedValues.filter((value) => value !== optionStr)
167
+ : [...selectedValues, optionStr];
168
+ handleValueChange(newSelectedValues);
169
+ };
170
+
171
+ const handleClear = () => {
172
+ handleValueChange([]);
173
+ };
174
+
175
+ const clearExtraOptions = () => {
176
+ const newSelectedValues = selectedValues.slice(0, maxCount);
177
+ handleValueChange(newSelectedValues);
178
+ };
179
+
180
+ const toggleAll = () => {
181
+ if (selectedValues.length === options.length) {
182
+ handleClear();
183
+ } else {
184
+ const allValues = options.map((option) => option.value as string);
185
+ handleValueChange(allValues);
186
+ }
187
+ };
188
+
189
+ return (
190
+ <Popover
191
+ open={isPopoverOpen}
192
+ onOpenChange={setIsPopoverOpen}
193
+ modal={modalPopover}
194
+ >
195
+ <PopoverTrigger asChild>
196
+ <Button
197
+ ref={ref}
198
+ {...props}
199
+ onClick={handleTogglePopover}
200
+ className={cn(
201
+ "flex w-full p-1 rounded-md border min-h-10 h-auto items-center justify-between hover:bg-inherit [&_svg]:pointer-events-auto font-normal bg-background text-muted-foreground",
202
+ className
203
+ )}
204
+ >
205
+ {selectedValues.length > 0 ? (
206
+ <div className="flex justify-between items-center w-full">
207
+ <div className="flex flex-wrap items-center">
208
+ {selectedValues.slice(0, maxCount).map((value) => {
209
+ const option = options.find((o) => o.value === value);
210
+ return (
211
+ <Badge
212
+ key={value}
213
+ className={cn(multiSelectVariants({ variant }))}
214
+ >
215
+ {option?.label}
216
+ <XCircle
217
+ className="ml-2 h-4 w-4 cursor-pointer text-muted-foreground"
218
+ onClick={(event) => {
219
+ event.stopPropagation();
220
+ toggleOption(value);
221
+ }}
222
+ />
223
+ </Badge>
224
+ );
225
+ })}
226
+ {selectedValues.length > maxCount && (
227
+ <Badge
228
+ className={cn(
229
+ "bg-transparent text-foreground border-foreground/1 hover:bg-transparent",
230
+ multiSelectVariants({ variant })
231
+ )}
232
+ >
233
+ {`+ ${selectedValues.length - maxCount} další`}
234
+ <XCircle
235
+ className="ml-2 h-4 w-4 cursor-pointer text-muted-foreground"
236
+ onClick={(event) => {
237
+ event.stopPropagation();
238
+ clearExtraOptions();
239
+ }}
240
+ />
241
+ </Badge>
242
+ )}
243
+ </div>
244
+ <div className="flex items-center justify-between">
245
+ <XIcon
246
+ className="h-4 mx-2 cursor-pointer text-muted-foreground"
247
+ onClick={(event) => {
248
+ event.stopPropagation();
249
+ handleClear();
250
+ }}
251
+ />
252
+ <Separator
253
+ orientation="vertical"
254
+ className="flex min-h-6 h-full"
255
+ />
256
+ <ChevronDown className="h-4 mx-2 cursor-pointer text-muted-foreground" />
257
+ </div>
258
+ </div>
259
+ ) : (
260
+ <div className="flex items-center justify-between w-full mx-auto">
261
+ <span className="text-sm text-muted-foreground mx-3">
262
+ {placeholder}
263
+ </span>
264
+ <ChevronDown className="h-4 cursor-pointer text-muted-foreground mx-2" />
265
+ </div>
266
+ )}
267
+ </Button>
268
+ </PopoverTrigger>
269
+ <PopoverContent
270
+ className="w-auto p-0"
271
+ align="start"
272
+ onEscapeKeyDown={() => setIsPopoverOpen(false)}
273
+ >
274
+ <Command>
275
+ <CommandInput
276
+ placeholder={placeholderSearch}
277
+ onKeyDown={(e: React.KeyboardEvent<HTMLInputElement>) => {
278
+ if (e.key === "Enter") {
279
+ setIsPopoverOpen(true);
280
+ } else if (e.key === "Backspace" && !e.currentTarget.value) {
281
+ const newSelectedValues = [...selectedValues];
282
+ newSelectedValues.pop();
283
+ handleValueChange(newSelectedValues);
284
+ }
285
+ }}
286
+ />
287
+ <CommandList>
288
+ <CommandEmpty>No results found.</CommandEmpty>
289
+ <CommandGroup>
290
+ <CommandItem
291
+ key="all"
292
+ onSelect={toggleAll}
293
+ className="cursor-pointer"
294
+ >
295
+ <div
296
+ className={cn(
297
+ "mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",
298
+ selectedValues.length === options.length
299
+ ? "bg-primary text-primary-foreground"
300
+ : "opacity-50 [&_svg]:invisible"
301
+ )}
302
+ >
303
+ <CheckIcon className="h-4 w-4" />
304
+ </div>
305
+ <span>(Vyberte vše)</span>
306
+ </CommandItem>
307
+ {options.map((option) => {
308
+ const optionStr = String(option.value);
309
+ const isSelected = selectedValues.includes(optionStr);
310
+ return (
311
+ <CommandItem
312
+ key={optionStr}
313
+ onSelect={() => toggleOption(option.value)}
314
+ className="cursor-pointer"
315
+ >
316
+ <div
317
+ className={cn(
318
+ "mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",
319
+ isSelected
320
+ ? "bg-primary text-primary-foreground"
321
+ : "opacity-50 [&_svg]:invisible"
322
+ )}
323
+ >
324
+ <CheckIcon className="h-4 w-4" />
325
+ </div>
326
+
327
+ <span>{option.label}</span>
328
+ </CommandItem>
329
+ );
330
+ })}
331
+ </CommandGroup>
332
+ <CommandSeparator />
333
+ <CommandGroup>
334
+ <div className="flex items-center justify-between">
335
+ {selectedValues.length > 0 && (
336
+ <>
337
+ <CommandItem
338
+ onSelect={handleClear}
339
+ className="flex-1 justify-center cursor-pointer"
340
+ >
341
+ Odebrat vše
342
+ </CommandItem>
343
+ <Separator
344
+ orientation="vertical"
345
+ className="flex min-h-6 h-full"
346
+ />
347
+ </>
348
+ )}
349
+ <CommandItem
350
+ onSelect={() => setIsPopoverOpen(false)}
351
+ className="flex-1 justify-center cursor-pointer max-w-full"
352
+ >
353
+ Zavřít
354
+ </CommandItem>
355
+ </div>
356
+ </CommandGroup>
357
+ </CommandList>
358
+ </Command>
359
+ </PopoverContent>
360
+ </Popover>
361
+ );
362
+ }
363
+ );
364
+
365
+ MultiSelect.displayName = "MultiSelect";
package/lib/main.ts CHANGED
@@ -67,6 +67,10 @@ export * from "./components/ui/tooltip.tsx";
67
67
  export * from "./components/ui/separator.tsx";
68
68
  export * from "./components/ui/textarea.tsx";
69
69
  export * from "./components/ui/checkbox.tsx";
70
+
71
+ export * from "./components/ui/multi-select.tsx";
72
+
73
+
70
74
  export { Button as ButtonCN, buttonVariants } from "./components/ui/button.tsx";
71
75
 
72
76
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@addsign/moje-agenda-shared-lib",
3
3
  "private": false,
4
- "version": "2.0.40",
4
+ "version": "2.0.42",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",
7
7
  "types": "dist/main.d.ts",