@addsign/moje-agenda-shared-lib 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/Dialog-IPFWYptw.js +421 -0
  2. package/dist/Dialog-IPFWYptw.js.map +1 -0
  3. package/dist/assets/style.css +12 -7
  4. package/dist/components/datatable/DataTable.js +1 -2
  5. package/dist/components/datatable/DataTable.js.map +1 -1
  6. package/dist/components/datatable/DataTableServer.js +1 -2
  7. package/dist/components/datatable/DataTableServer.js.map +1 -1
  8. package/dist/components/form/AutocompleteSearchBar.js +1 -2
  9. package/dist/components/form/AutocompleteSearchBar.js.map +1 -1
  10. package/dist/components/form/AutocompleteSearchBarServer.js +1 -2
  11. package/dist/components/form/AutocompleteSearchBarServer.js.map +1 -1
  12. package/dist/components/form/FileInput.js +1 -2
  13. package/dist/components/form/FileInput.js.map +1 -1
  14. package/dist/components/form/FileInputMultiple.js +1 -2
  15. package/dist/components/form/FileInputMultiple.js.map +1 -1
  16. package/dist/components/form/FormField.js +1 -2
  17. package/dist/components/form/FormField.js.map +1 -1
  18. package/dist/components/form/PositionsSelectorSingle.js +1 -2
  19. package/dist/components/form/PositionsSelectorSingle.js.map +1 -1
  20. package/dist/components/form/SelectField.js +1 -2
  21. package/dist/components/form/SelectField.js.map +1 -1
  22. package/dist/components/profiles/ProfileOverview.js +1 -2
  23. package/dist/components/profiles/ProfileOverview.js.map +1 -1
  24. package/dist/components/ui/Combobox.d.ts +14 -1
  25. package/dist/components/ui/Combobox.js +122 -98
  26. package/dist/components/ui/Combobox.js.map +1 -1
  27. package/dist/components/ui/command.js +1 -1
  28. package/dist/components/ui/command.js.map +1 -1
  29. package/dist/index-BF3Kkq7m.js +2212 -0
  30. package/dist/index-BF3Kkq7m.js.map +1 -0
  31. package/dist/index-Bm-YZac9.js +28864 -0
  32. package/dist/index-Bm-YZac9.js.map +1 -0
  33. package/dist/index-C4pkvuV-.js +1395 -0
  34. package/dist/index-C4pkvuV-.js.map +1 -0
  35. package/dist/index-M6rMtqtn.js +2203 -0
  36. package/dist/index-M6rMtqtn.js.map +1 -0
  37. package/dist/index.es-XWsfbnWC.js +9628 -0
  38. package/dist/index.es-XWsfbnWC.js.map +1 -0
  39. package/dist/jspdf.plugin.autotable-DXW3wQb-.js +11475 -0
  40. package/dist/jspdf.plugin.autotable-DXW3wQb-.js.map +1 -0
  41. package/dist/main.js +1 -4
  42. package/dist/main.js.map +1 -1
  43. package/lib/components/ui/Combobox.tsx +155 -102
  44. package/lib/components/ui/command.tsx +1 -1
  45. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -36,10 +36,7 @@ import { Input } from "./components/ui/input.js";
36
36
  import { Form, FormControl, FormDescription, FormFieldCN, FormItem, FormLabel, FormMessage, useFormField } from "./components/ui/form.js";
37
37
  import { RadioGroupCN, RadioGroupItem } from "./components/ui/radioGroup.js";
38
38
  import { Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut } from "./components/ui/command.js";
39
- import "react/jsx-runtime";
40
- import "react";
41
- import "./components/ui/button.js";
42
- import "./components/ui/popover.js";
39
+ import "./components/ui/Combobox.js";
43
40
  import { C } from "./Calendar-DWT4e7Th.js";
44
41
  import { default as default22 } from "./components/ui/DateTimePicker.js";
45
42
  import { default as default23 } from "./components/ui/DatePicker.js";
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"main.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"main.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
 
3
3
  import * as React from "react";
4
- import { Check, ChevronsUpDown, Plus } from "lucide-react";
4
+ import { Check, ChevronsUpDown, Plus, X } from "lucide-react";
5
5
 
6
6
  import { cn } from "../../utils/utils";
7
7
  import { Button } from "./button";
@@ -14,109 +14,162 @@ import {
14
14
  CommandList,
15
15
  } from "./command";
16
16
  import { Popover, PopoverContent, PopoverTrigger } from "./popover";
17
+ import { IOptionItem } from "../../types";
17
18
 
18
- const predefinedFrameworks = [
19
- {
20
- value: "next.js",
21
- label: "Next.js",
22
- },
23
- {
24
- value: "sveltekit",
25
- label: "SvelteKit",
26
- },
27
- {
28
- value: "nuxt.js",
29
- label: "Nuxt.js",
30
- },
31
- {
32
- value: "remix",
33
- label: "Remix",
34
- },
35
- {
36
- value: "astro",
37
- label: "Astro",
38
- },
39
- ];
19
+ interface ComboboxProps {
20
+ value?: string;
21
+ onChange?: (value: string | undefined) => void;
22
+ className?: string;
23
+ placeholder?: string;
24
+ placeholderSearch?: string;
25
+ clearable?: boolean;
26
+ options?: IOptionItem[];
27
+ allowAddNew?: boolean;
28
+ }
40
29
 
41
- export default function ComboboxDemo() {
42
- const [open, setOpen] = React.useState(false);
43
- const [value, setValue] = React.useState("");
44
- const [inputValue, setInputValue] = React.useState("");
45
- const [frameworks, setFrameworks] = React.useState(predefinedFrameworks);
30
+ const Combobox = React.forwardRef<HTMLButtonElement, ComboboxProps>(
31
+ (
32
+ {
33
+ value: propValue,
34
+ onChange: propOnChange,
35
+ className,
36
+ placeholder,
37
+ placeholderSearch = "Vyhledejte položku",
38
+ clearable = false,
39
+ options = [],
40
+ allowAddNew = false,
41
+ },
42
+ ref
43
+ ) => {
44
+ const [open, setOpen] = React.useState(false);
45
+ const [value, setValue] = React.useState(propValue || "");
46
+ const [inputValue, setInputValue] = React.useState("");
47
+ const [frameworks, setFrameworks] = React.useState<IOptionItem[]>(options);
46
48
 
47
- const handleSelect = (currentValue: string) => {
48
- if (currentValue === "add-custom") {
49
- if (
50
- inputValue &&
51
- !frameworks.some((f) => f.value === inputValue.toLowerCase())
52
- ) {
53
- const newFramework = {
54
- value: inputValue.toLowerCase(),
55
- label: inputValue,
56
- };
57
- setFrameworks([...frameworks, newFramework]);
58
- setValue(newFramework.value);
49
+ React.useEffect(() => {
50
+ if (propValue !== undefined) {
51
+ setValue(propValue);
59
52
  }
60
- } else {
61
- setValue(currentValue === value ? "" : currentValue);
62
- }
63
- setOpen(false);
64
- };
53
+ }, [propValue]);
65
54
 
66
- return (
67
- <Popover open={open} onOpenChange={setOpen}>
68
- <PopoverTrigger asChild>
69
- <Button
70
- variant="outline"
71
- role="combobox"
72
- aria-expanded={open}
73
- className="w-[200px] justify-between"
74
- >
75
- {value
76
- ? frameworks.find((framework) => framework.value === value)?.label
77
- : "Select framework..."}
78
- <ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />
79
- </Button>
80
- </PopoverTrigger>
81
- <PopoverContent className="w-[200px] p-0">
82
- <Command>
83
- <CommandInput
84
- placeholder="Search framework..."
85
- className="h-9"
86
- value={inputValue}
87
- onValueChange={setInputValue}
88
- />
89
- <CommandList>
90
- <CommandEmpty>
91
- <Button
92
- variant="ghost"
93
- className="w-full justify-start"
94
- onClick={() => handleSelect("add-custom")}
95
- >
96
- <Plus className="mr-2 h-4 w-4" />
97
- Add "{inputValue}"
98
- </Button>
99
- </CommandEmpty>
100
- <CommandGroup>
101
- {frameworks.map((framework) => (
102
- <CommandItem
103
- key={framework.value}
104
- value={framework.value}
105
- onSelect={handleSelect}
106
- >
107
- {framework.label}
108
- <Check
109
- className={cn(
110
- "ml-auto h-4 w-4",
111
- value === framework.value ? "opacity-100" : "opacity-0"
112
- )}
113
- />
114
- </CommandItem>
115
- ))}
116
- </CommandGroup>
117
- </CommandList>
118
- </Command>
119
- </PopoverContent>
120
- </Popover>
121
- );
122
- }
55
+ React.useEffect(() => {
56
+ setFrameworks(options);
57
+ }, [options]);
58
+
59
+ const handleSelect = (currentValue: string) => {
60
+ if (currentValue === "add-custom") {
61
+ if (
62
+ inputValue &&
63
+ !frameworks.some((f) => f.value === inputValue.toLowerCase())
64
+ ) {
65
+ const newFramework = {
66
+ value: inputValue.toLowerCase(),
67
+ label: inputValue,
68
+ };
69
+
70
+ setFrameworks([...frameworks, newFramework]);
71
+ updateValue(newFramework.value);
72
+ }
73
+ } else {
74
+ updateValue(currentValue === value ? "" : currentValue);
75
+ }
76
+ setOpen(false);
77
+ };
78
+
79
+ const updateValue = (newValue: string) => {
80
+ setValue(newValue);
81
+ propOnChange?.(newValue || undefined);
82
+ };
83
+
84
+ const handleClear = (e: React.MouseEvent) => {
85
+ e.stopPropagation();
86
+ updateValue("");
87
+ setInputValue("");
88
+ setOpen(false);
89
+ };
90
+
91
+ value;
92
+ return (
93
+ <Popover open={open} onOpenChange={setOpen}>
94
+ <div className="relative w-full">
95
+ <PopoverTrigger asChild>
96
+ <Button
97
+ ref={ref}
98
+ type="button"
99
+ variant="outline"
100
+ role="combobox"
101
+ aria-expanded={open}
102
+ className={cn("w-full justify-between", className)}
103
+ >
104
+ {value ? (
105
+ frameworks.find((framework) => framework.value === value)?.label
106
+ ) : (
107
+ <div className="text-muted-foreground font-normal">
108
+ {placeholder}
109
+ </div>
110
+ )}
111
+ <ChevronsUpDown className="h-4 w-4 shrink-0 opacity-50 ml-6" />
112
+ </Button>
113
+ </PopoverTrigger>
114
+ {clearable && value && (
115
+ <Button
116
+ type="button"
117
+ variant="ghost"
118
+ size="sm"
119
+ className="absolute right-6 top-0 h-full px-3 py-2 hover:bg-transparent"
120
+ onClick={handleClear}
121
+ >
122
+ <X className="h-4 w-4 shrink-0 opacity-50 hover:opacity-100" />
123
+ </Button>
124
+ )}
125
+ </div>
126
+ <PopoverContent className="min-w-[200px] w-full p-0">
127
+ <Command>
128
+ <CommandInput
129
+ placeholder={placeholderSearch}
130
+ className="h-9"
131
+ value={inputValue}
132
+ onValueChange={setInputValue}
133
+ />
134
+ <CommandList>
135
+ <CommandEmpty>
136
+ {allowAddNew && (
137
+ <Button
138
+ variant="ghost"
139
+ className="w-full justify-start"
140
+ onClick={() => handleSelect("add-custom")}
141
+ >
142
+ <Plus className="mr-2 h-4 w-4" />
143
+ Přidat "{inputValue}"
144
+ </Button>
145
+ )}
146
+ </CommandEmpty>
147
+
148
+ <CommandGroup>
149
+ {frameworks.map((framework) => (
150
+ <CommandItem
151
+ key={framework.value}
152
+ value={framework.value as string}
153
+ onSelect={handleSelect}
154
+ >
155
+ {framework.label}
156
+ <Check
157
+ className={cn(
158
+ "ml-auto h-4 w-4",
159
+ value === framework.value ? "opacity-100" : "opacity-0"
160
+ )}
161
+ />
162
+ </CommandItem>
163
+ ))}
164
+ </CommandGroup>
165
+ </CommandList>
166
+ </Command>
167
+ </PopoverContent>
168
+ </Popover>
169
+ );
170
+ }
171
+ );
172
+
173
+ Combobox.displayName = "Combobox";
174
+
175
+ export default Combobox;
@@ -73,7 +73,7 @@ const CommandEmpty = React.forwardRef<
73
73
  >((props, ref) => (
74
74
  <CommandPrimitive.Empty
75
75
  ref={ref}
76
- className="py-6 text-center text-sm"
76
+ className="py-0 text-center text-sm"
77
77
  {...props}
78
78
  />
79
79
  ));
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.0",
4
+ "version": "2.0.1",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",
7
7
  "types": "dist/main.d.ts",