@ayasofyazilim/ui 0.0.0

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 (236) hide show
  1. package/__mocks__/canvas.ts +8 -0
  2. package/components.json +21 -0
  3. package/eslint.config.js +4 -0
  4. package/jest-environment.js +37 -0
  5. package/jest.config.ts +47 -0
  6. package/jest.setup.ts +69 -0
  7. package/package.json +124 -0
  8. package/postcss.config.mjs +6 -0
  9. package/src/aria/index.tsx +1 -0
  10. package/src/aria/number-field.tsx +41 -0
  11. package/src/components/.gitkeep +0 -0
  12. package/src/components/accordion.tsx +66 -0
  13. package/src/components/alert-dialog.tsx +157 -0
  14. package/src/components/alert.tsx +70 -0
  15. package/src/components/aspect-ratio.tsx +11 -0
  16. package/src/components/avatar.tsx +53 -0
  17. package/src/components/badge.tsx +67 -0
  18. package/src/components/breadcrumb.tsx +109 -0
  19. package/src/components/button-group.tsx +83 -0
  20. package/src/components/button.tsx +68 -0
  21. package/src/components/calendar.tsx +219 -0
  22. package/src/components/card.tsx +92 -0
  23. package/src/components/carousel.tsx +241 -0
  24. package/src/components/chart.tsx +363 -0
  25. package/src/components/checkbox.tsx +32 -0
  26. package/src/components/collapsible.tsx +33 -0
  27. package/src/components/command.tsx +184 -0
  28. package/src/components/context-menu.tsx +252 -0
  29. package/src/components/dialog.tsx +144 -0
  30. package/src/components/drawer.tsx +135 -0
  31. package/src/components/dropdown-menu.tsx +258 -0
  32. package/src/components/empty.tsx +100 -0
  33. package/src/components/field.tsx +248 -0
  34. package/src/components/form.tsx +169 -0
  35. package/src/components/hover-card.tsx +44 -0
  36. package/src/components/input-group.tsx +170 -0
  37. package/src/components/input-otp.tsx +77 -0
  38. package/src/components/input.tsx +21 -0
  39. package/src/components/item.tsx +193 -0
  40. package/src/components/kbd.tsx +28 -0
  41. package/src/components/label.tsx +24 -0
  42. package/src/components/menubar.tsx +276 -0
  43. package/src/components/navigation-menu.tsx +168 -0
  44. package/src/components/pagination.tsx +130 -0
  45. package/src/components/popover.tsx +88 -0
  46. package/src/components/progress.tsx +31 -0
  47. package/src/components/radio-group.tsx +45 -0
  48. package/src/components/resizable.tsx +56 -0
  49. package/src/components/scroll-area.tsx +58 -0
  50. package/src/components/select.tsx +189 -0
  51. package/src/components/separator.tsx +28 -0
  52. package/src/components/sheet.tsx +140 -0
  53. package/src/components/sidebar.tsx +862 -0
  54. package/src/components/skeleton.tsx +13 -0
  55. package/src/components/slider.tsx +63 -0
  56. package/src/components/sonner.tsx +40 -0
  57. package/src/components/spinner.tsx +16 -0
  58. package/src/components/stepper.tsx +291 -0
  59. package/src/components/switch.tsx +31 -0
  60. package/src/components/table.tsx +133 -0
  61. package/src/components/tabs.tsx +66 -0
  62. package/src/components/textarea.tsx +18 -0
  63. package/src/components/toggle-group.tsx +83 -0
  64. package/src/components/toggle.tsx +47 -0
  65. package/src/components/tooltip.tsx +66 -0
  66. package/src/custom/action-button.tsx +48 -0
  67. package/src/custom/async-select.tsx +287 -0
  68. package/src/custom/awesome-not-found.tsx +116 -0
  69. package/src/custom/charts/area-chart.tsx +147 -0
  70. package/src/custom/charts/bar-chart.tsx +233 -0
  71. package/src/custom/charts/chart-card.tsx +103 -0
  72. package/src/custom/charts/index.tsx +16 -0
  73. package/src/custom/charts/pie-chart.tsx +168 -0
  74. package/src/custom/charts/radar-chart.tsx +126 -0
  75. package/src/custom/checkbox-tree.tsx +100 -0
  76. package/src/custom/combobox.tsx +296 -0
  77. package/src/custom/confirm-dialog.tsx +102 -0
  78. package/src/custom/country-selector.tsx +204 -0
  79. package/src/custom/date-picker/calendar-rac.tsx +109 -0
  80. package/src/custom/date-picker/datefield-rac.tsx +84 -0
  81. package/src/custom/date-picker/index.tsx +273 -0
  82. package/src/custom/date-picker/types/index.ts +4 -0
  83. package/src/custom/date-picker/utils/index.ts +42 -0
  84. package/src/custom/date-picker-old.tsx +50 -0
  85. package/src/custom/date-tooltip.tsx +98 -0
  86. package/src/custom/document-scanner/consts.ts +5 -0
  87. package/src/custom/document-scanner/corner-adjustment/action-buttons.tsx +33 -0
  88. package/src/custom/document-scanner/corner-adjustment/corner-handle.tsx +43 -0
  89. package/src/custom/document-scanner/corner-adjustment/hooks/use-corner-drag.ts +85 -0
  90. package/src/custom/document-scanner/corner-adjustment/index.tsx +125 -0
  91. package/src/custom/document-scanner/corner-adjustment/types.ts +53 -0
  92. package/src/custom/document-scanner/corner-adjustment/utils/clip-path.ts +22 -0
  93. package/src/custom/document-scanner/corner-adjustment/zoom-magnifier.tsx +115 -0
  94. package/src/custom/document-scanner/hooks/use-document-capture.ts +81 -0
  95. package/src/custom/document-scanner/hooks/use-document-scanner.ts +80 -0
  96. package/src/custom/document-scanner/hooks/use-perspective-crop.ts +38 -0
  97. package/src/custom/document-scanner/index.tsx +255 -0
  98. package/src/custom/document-scanner/lib.ts +407 -0
  99. package/src/custom/document-scanner/types.ts +205 -0
  100. package/src/custom/document-scanner/utils/perspective-correction.ts +139 -0
  101. package/src/custom/document-viewer/controllers.tsx +98 -0
  102. package/src/custom/document-viewer/index.tsx +43 -0
  103. package/src/custom/document-viewer/renderers/image.tsx +37 -0
  104. package/src/custom/document-viewer/renderers/index.tsx +2 -0
  105. package/src/custom/document-viewer/renderers/pdf.tsx +105 -0
  106. package/src/custom/email-input/domains.json +159 -0
  107. package/src/custom/email-input/email.tsx +229 -0
  108. package/src/custom/email-input/index.tsx +4 -0
  109. package/src/custom/email-input/types.ts +104 -0
  110. package/src/custom/file-uploader.tsx +541 -0
  111. package/src/custom/filter-component/fields/async-select.tsx +33 -0
  112. package/src/custom/filter-component/fields/date.tsx +60 -0
  113. package/src/custom/filter-component/fields/multi-select.tsx +30 -0
  114. package/src/custom/filter-component/index.tsx +217 -0
  115. package/src/custom/image-canvas.tsx +260 -0
  116. package/src/custom/json-editor.tsx +22 -0
  117. package/src/custom/master-data-grid/components/dialogs/column-settings-dialog.tsx +100 -0
  118. package/src/custom/master-data-grid/components/dialogs/index.ts +1 -0
  119. package/src/custom/master-data-grid/components/filters/client-filter.tsx +368 -0
  120. package/src/custom/master-data-grid/components/filters/filter-input.tsx +256 -0
  121. package/src/custom/master-data-grid/components/filters/index.ts +3 -0
  122. package/src/custom/master-data-grid/components/filters/inline-column-filter.tsx +233 -0
  123. package/src/custom/master-data-grid/components/filters/multi-filter-dialog.tsx +90 -0
  124. package/src/custom/master-data-grid/components/filters/server-filter.tsx +255 -0
  125. package/src/custom/master-data-grid/components/master-data-grid.tsx +472 -0
  126. package/src/custom/master-data-grid/components/pagination/index.ts +1 -0
  127. package/src/custom/master-data-grid/components/pagination/pagination.tsx +178 -0
  128. package/src/custom/master-data-grid/components/table/cell-renderer.tsx +634 -0
  129. package/src/custom/master-data-grid/components/table/header-cell.tsx +162 -0
  130. package/src/custom/master-data-grid/components/table/index.ts +4 -0
  131. package/src/custom/master-data-grid/components/table/table-body-renderer.tsx +113 -0
  132. package/src/custom/master-data-grid/components/table/virtual-body.tsx +138 -0
  133. package/src/custom/master-data-grid/components/toolbar/index.ts +1 -0
  134. package/src/custom/master-data-grid/components/toolbar/toolbar.tsx +314 -0
  135. package/src/custom/master-data-grid/hooks/index.ts +3 -0
  136. package/src/custom/master-data-grid/hooks/use-columns.tsx +332 -0
  137. package/src/custom/master-data-grid/hooks/use-editing.ts +106 -0
  138. package/src/custom/master-data-grid/hooks/use-table-state-reducer.ts +157 -0
  139. package/src/custom/master-data-grid/hooks/use-table-state.ts +31 -0
  140. package/src/custom/master-data-grid/index.ts +16 -0
  141. package/src/custom/master-data-grid/types.ts +466 -0
  142. package/src/custom/master-data-grid/utils/column-generator.tsx +306 -0
  143. package/src/custom/master-data-grid/utils/export-utils.ts +67 -0
  144. package/src/custom/master-data-grid/utils/filter-fns.ts +290 -0
  145. package/src/custom/master-data-grid/utils/index.ts +8 -0
  146. package/src/custom/master-data-grid/utils/pinning-utils.ts +88 -0
  147. package/src/custom/master-data-grid/utils/translation-utils.ts +42 -0
  148. package/src/custom/multi-select.tsx +432 -0
  149. package/src/custom/password-input.tsx +194 -0
  150. package/src/custom/phone-input.tsx +172 -0
  151. package/src/custom/schema-form/custom/index.tsx +1 -0
  152. package/src/custom/schema-form/custom/label.tsx +53 -0
  153. package/src/custom/schema-form/fields/base-input-field.tsx +82 -0
  154. package/src/custom/schema-form/fields/field.tsx +67 -0
  155. package/src/custom/schema-form/fields/index.tsx +5 -0
  156. package/src/custom/schema-form/fields/object.tsx +12 -0
  157. package/src/custom/schema-form/fields/table-array/array-field-item.tsx +90 -0
  158. package/src/custom/schema-form/fields/table-array/array-field-template.tsx +115 -0
  159. package/src/custom/schema-form/index.tsx +259 -0
  160. package/src/custom/schema-form/templates/description.tsx +20 -0
  161. package/src/custom/schema-form/templates/index.tsx +2 -0
  162. package/src/custom/schema-form/templates/submit.tsx +32 -0
  163. package/src/custom/schema-form/types.ts +64 -0
  164. package/src/custom/schema-form/utils/index.ts +4 -0
  165. package/src/custom/schema-form/utils/schema-dependency.ts +655 -0
  166. package/src/custom/schema-form/utils/schemas.ts +289 -0
  167. package/src/custom/schema-form/utils/validation.ts +23 -0
  168. package/src/custom/schema-form/widgets/boolean.tsx +77 -0
  169. package/src/custom/schema-form/widgets/combobox.tsx +274 -0
  170. package/src/custom/schema-form/widgets/date.tsx +59 -0
  171. package/src/custom/schema-form/widgets/email.tsx +34 -0
  172. package/src/custom/schema-form/widgets/index.tsx +10 -0
  173. package/src/custom/schema-form/widgets/password.tsx +40 -0
  174. package/src/custom/schema-form/widgets/phone.tsx +40 -0
  175. package/src/custom/schema-form/widgets/select.tsx +105 -0
  176. package/src/custom/schema-form/widgets/selectable.tsx +25 -0
  177. package/src/custom/schema-form/widgets/string-array.tsx +296 -0
  178. package/src/custom/schema-form/widgets/url.tsx +56 -0
  179. package/src/custom/section-layout-v2.tsx +212 -0
  180. package/src/custom/select-tabs.tsx +109 -0
  181. package/src/custom/selectable.tsx +316 -0
  182. package/src/custom/stepper.tsx +236 -0
  183. package/src/custom/tab-layout.tsx +213 -0
  184. package/src/custom/tanstack-table/fields/index.tsx +12 -0
  185. package/src/custom/tanstack-table/fields/tanstack-table-action-dialogs.tsx +89 -0
  186. package/src/custom/tanstack-table/fields/tanstack-table-column-header.tsx +66 -0
  187. package/src/custom/tanstack-table/fields/tanstack-table-filter-date.tsx +180 -0
  188. package/src/custom/tanstack-table/fields/tanstack-table-filter-faceted.tsx +158 -0
  189. package/src/custom/tanstack-table/fields/tanstack-table-filter-text.tsx +76 -0
  190. package/src/custom/tanstack-table/fields/tanstack-table-pagination.tsx +136 -0
  191. package/src/custom/tanstack-table/fields/tanstack-table-plain-table.tsx +142 -0
  192. package/src/custom/tanstack-table/fields/tanstack-table-row-actions-confirmation.tsx +77 -0
  193. package/src/custom/tanstack-table/fields/tanstack-table-row-actions-custom-dialog.tsx +87 -0
  194. package/src/custom/tanstack-table/fields/tanstack-table-row-actions.tsx +151 -0
  195. package/src/custom/tanstack-table/fields/tanstack-table-table-actions-custom-dialog.tsx +88 -0
  196. package/src/custom/tanstack-table/fields/tanstack-table-table-actions-schemaform-dialog.tsx +47 -0
  197. package/src/custom/tanstack-table/fields/tanstack-table-toolbar.tsx +143 -0
  198. package/src/custom/tanstack-table/fields/tanstack-table-view-options.tsx +171 -0
  199. package/src/custom/tanstack-table/index.tsx +244 -0
  200. package/src/custom/tanstack-table/types/index.ts +328 -0
  201. package/src/custom/tanstack-table/utils/cell-with-actions.tsx +21 -0
  202. package/src/custom/tanstack-table/utils/column-names.ts +26 -0
  203. package/src/custom/tanstack-table/utils/columns-by-row-data.tsx +312 -0
  204. package/src/custom/tanstack-table/utils/editable-columns-by-row-data.tsx +219 -0
  205. package/src/custom/tanstack-table/utils/faceted-boolean-options.tsx +22 -0
  206. package/src/custom/tanstack-table/utils/index.tsx +10 -0
  207. package/src/custom/tanstack-table/utils/pinning-styles.ts +57 -0
  208. package/src/custom/tanstack-table/utils/table.tsx +83 -0
  209. package/src/custom/tanstack-table/utils/test-conditions.ts +17 -0
  210. package/src/custom/timeline.tsx +208 -0
  211. package/src/custom/tree.tsx +200 -0
  212. package/src/custom/tscanify/browser.ts +66 -0
  213. package/src/custom/tscanify/index.ts +51 -0
  214. package/src/custom/tscanify/tscanify-browser.ts +522 -0
  215. package/src/custom/tscanify/tscanify.ts +262 -0
  216. package/src/custom/tscanify/types.ts +22 -0
  217. package/src/custom/webcam.tsx +737 -0
  218. package/src/hooks/.gitkeep +0 -0
  219. package/src/hooks/use-callback-ref.ts +27 -0
  220. package/src/hooks/use-controllable-state.ts +67 -0
  221. package/src/hooks/use-debounce.ts +19 -0
  222. package/src/hooks/use-is-visible.ts +23 -0
  223. package/src/hooks/use-media-query.ts +21 -0
  224. package/src/hooks/use-mobile.ts +21 -0
  225. package/src/hooks/use-on-window-resize.ts +15 -0
  226. package/src/hooks/use-scroll.tsx +22 -0
  227. package/src/lib/utils.ts +61 -0
  228. package/src/lib/zod.ts +2 -0
  229. package/src/styles/core.css +57 -0
  230. package/src/styles/globals.css +130 -0
  231. package/src/test/email-input.test.tsx +217 -0
  232. package/src/test/password-input.test.tsx +92 -0
  233. package/src/test/select-tabs.test.tsx +302 -0
  234. package/src/test/selectable.test.tsx +1093 -0
  235. package/tsconfig.json +13 -0
  236. package/tsconfig.lint.json +8 -0
@@ -0,0 +1,229 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import { cn } from "@repo/ayasofyazilim-ui/lib/utils";
5
+ import { Input } from "@repo/ayasofyazilim-ui/components/input";
6
+ import { Label } from "@repo/ayasofyazilim-ui/components/label";
7
+ import { Button } from "@repo/ayasofyazilim-ui/components/button";
8
+ import domains from "./domains.json";
9
+
10
+ interface EmailInputProps
11
+ extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "type"> {
12
+ label?: string;
13
+ suggestions?: string[];
14
+ onValueChange?: (value: string) => void;
15
+ }
16
+
17
+ const EmailInput = React.forwardRef<HTMLInputElement, EmailInputProps>(
18
+ (
19
+ {
20
+ id,
21
+ className,
22
+ label,
23
+ suggestions = [],
24
+ onValueChange,
25
+ disabled,
26
+ required,
27
+ ...props
28
+ },
29
+ ref
30
+ ) => {
31
+ const allSuggestions = React.useMemo(() => {
32
+ const combined = [...domains, ...suggestions];
33
+ return combined.filter((item, index) => combined.indexOf(item) === index);
34
+ }, [suggestions]);
35
+
36
+ const [value, setValue] = React.useState(props.value?.toString() || "");
37
+ const [open, setOpen] = React.useState(false);
38
+ const [filteredSuggestions, setFilteredSuggestions] = React.useState<
39
+ string[]
40
+ >([]);
41
+ const [selectedIndex, setSelectedIndex] = React.useState(-1);
42
+
43
+ const inputRef = React.useRef<HTMLInputElement>(null);
44
+ const containerRef = React.useRef<HTMLDivElement>(null);
45
+
46
+ React.useImperativeHandle(ref, () => inputRef.current!);
47
+
48
+ const updateSuggestions = React.useCallback(
49
+ (inputValue: string) => {
50
+ const atIndex = inputValue.lastIndexOf("@");
51
+
52
+ if (atIndex === -1) {
53
+ setOpen(false);
54
+ setFilteredSuggestions([]);
55
+ setSelectedIndex(-1);
56
+ return;
57
+ }
58
+
59
+ const beforeAt = inputValue.substring(0, atIndex + 1);
60
+ const afterAt = inputValue.substring(atIndex + 1);
61
+
62
+ if (afterAt.length === 0) {
63
+ const topSuggestions = allSuggestions
64
+ .slice(0, 5)
65
+ .map((domain) => beforeAt + domain);
66
+ setFilteredSuggestions(topSuggestions);
67
+ setOpen(true);
68
+ setSelectedIndex(-1);
69
+ } else {
70
+ const filtered = allSuggestions
71
+ .filter((domain) =>
72
+ domain.toLowerCase().startsWith(afterAt.toLowerCase())
73
+ )
74
+ .map((domain) => beforeAt + domain);
75
+
76
+ if (filtered.length > 0) {
77
+ setFilteredSuggestions(filtered);
78
+ setOpen(true);
79
+ setSelectedIndex(-1);
80
+ } else {
81
+ setOpen(false);
82
+ setFilteredSuggestions([]);
83
+ setSelectedIndex(-1);
84
+ }
85
+ }
86
+ },
87
+ [allSuggestions]
88
+ );
89
+
90
+ const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
91
+ const newValue = e.target.value;
92
+ setValue(newValue);
93
+ onValueChange?.(newValue);
94
+ updateSuggestions(newValue);
95
+ };
96
+
97
+ const applySuggestion = (suggestion: string) => {
98
+ setValue(suggestion);
99
+ onValueChange?.(suggestion);
100
+ setOpen(false);
101
+ setSelectedIndex(-1);
102
+ inputRef.current?.focus();
103
+ };
104
+
105
+ const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
106
+ if (!open || filteredSuggestions.length === 0) {
107
+ if (e.key === "Escape") {
108
+ setOpen(false);
109
+ }
110
+ return;
111
+ }
112
+
113
+ switch (e.key) {
114
+ case "ArrowDown":
115
+ e.preventDefault();
116
+ setSelectedIndex((prev) =>
117
+ prev < filteredSuggestions.length - 1 ? prev + 1 : 0
118
+ );
119
+ break;
120
+ case "ArrowUp":
121
+ e.preventDefault();
122
+ setSelectedIndex((prev) =>
123
+ prev > 0 ? prev - 1 : filteredSuggestions.length - 1
124
+ );
125
+ break;
126
+ case "Enter":
127
+ e.preventDefault();
128
+ if (
129
+ selectedIndex >= 0 &&
130
+ selectedIndex < filteredSuggestions.length
131
+ ) {
132
+ applySuggestion(filteredSuggestions?.[selectedIndex] || "");
133
+ }
134
+ break;
135
+ case "Escape":
136
+ setOpen(false);
137
+ setSelectedIndex(-1);
138
+ break;
139
+ default:
140
+ setOpen(false);
141
+ break;
142
+ }
143
+ };
144
+
145
+ React.useEffect(() => {
146
+ const handleClickOutside = (event: MouseEvent) => {
147
+ if (
148
+ containerRef.current &&
149
+ !containerRef.current.contains(event.target as Node)
150
+ ) {
151
+ setOpen(false);
152
+ setSelectedIndex(-1);
153
+ }
154
+ };
155
+
156
+ document.addEventListener("mousedown", handleClickOutside);
157
+ return () =>
158
+ document.removeEventListener("mousedown", handleClickOutside);
159
+ }, []);
160
+
161
+ React.useEffect(() => {
162
+ if (props.value !== undefined) {
163
+ setValue(props.value.toString());
164
+ }
165
+ }, [props.value]);
166
+
167
+ return (
168
+ <div className="w-full" ref={containerRef}>
169
+ {label && (
170
+ <Label
171
+ className={cn(
172
+ "mb-2 block",
173
+ required &&
174
+ "after:content-['*'] after:ml-0.5 after:text-destructive"
175
+ )}
176
+ >
177
+ {label}
178
+ </Label>
179
+ )}
180
+
181
+ <div className="relative">
182
+ <Input
183
+ type="email"
184
+ id={id}
185
+ data-testid={id}
186
+ className={className}
187
+ ref={inputRef}
188
+ value={value}
189
+ onChange={handleInputChange}
190
+ onKeyDown={handleKeyDown}
191
+ disabled={disabled}
192
+ required={required}
193
+ {...props}
194
+ />
195
+
196
+ {open && filteredSuggestions.length > 0 && (
197
+ <div className="absolute top-full left-0 right-0 z-999 mt-1 bg-popover border border-border rounded-md shadow-md">
198
+ <div className="p-1 flex flex-col">
199
+ {filteredSuggestions.map((suggestion, index) => (
200
+ <Button
201
+ variant="ghost"
202
+ data-testid={`${id}_suggestion_${index}`}
203
+ key={suggestion}
204
+ className={cn(
205
+ "w-full justify-start text-left px-2 py-1.5 text-sm cursor-pointer rounded-sm transition-colors gap-0",
206
+ "hover:bg-accent hover:text-accent-foreground",
207
+ index === selectedIndex &&
208
+ "bg-accent text-accent-foreground"
209
+ )}
210
+ onClick={() => applySuggestion(suggestion)}
211
+ >
212
+ <span>{suggestion.split("@")[0]}</span>
213
+ <span className="text-primary font-semibold">
214
+ @{suggestion.split("@")[1]}
215
+ </span>
216
+ </Button>
217
+ ))}
218
+ </div>
219
+ </div>
220
+ )}
221
+ </div>
222
+ </div>
223
+ );
224
+ }
225
+ );
226
+
227
+ EmailInput.displayName = "EmailInput";
228
+
229
+ export { EmailInput };
@@ -0,0 +1,4 @@
1
+ export { default as domains } from "./domains.json";
2
+ export { EmailInput } from "./email";
3
+
4
+ export * from "./types";
@@ -0,0 +1,104 @@
1
+ import * as React from "react";
2
+
3
+ export type Maybe<T> = T | null;
4
+
5
+ export enum Elements {
6
+ Domain = "domain",
7
+ Dropdown = "dropdown",
8
+ Input = "input",
9
+ Suggestion = "suggestion",
10
+ Username = "username",
11
+ Wrapper = "wrapper",
12
+ }
13
+
14
+ export type ClassNames = Partial<Record<Elements, string>>;
15
+
16
+ export type OnSelectData = {
17
+ value: string;
18
+ keyboard: boolean;
19
+ position: number;
20
+ };
21
+
22
+ export type Values = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
23
+
24
+ export type OnChange =
25
+ | React.Dispatch<React.SetStateAction<string>>
26
+ | ((newValue: string) => void | Promise<void>);
27
+ export type OnSelect = (object: OnSelectData) => void | Promise<void>;
28
+
29
+ export type Props = {
30
+ /** State or portion of state to hold the email. */
31
+ value: string | undefined;
32
+ /** State setter or custom dispatcher to update the email. */
33
+ onChange: OnChange;
34
+ /** Domains to suggest while typing the username. */
35
+ baseList: string[];
36
+ /** Domains to refine suggestions after typing @. */
37
+ refineList?: string[];
38
+ /** Custom callback to invoke on suggestion select. */
39
+ onSelect?: OnSelect;
40
+ /** Minimum chars required to display suggestions. */
41
+ minChars?: Values;
42
+ /** Maximum number of suggestions to display. */
43
+ maxResults?: Omit<Values, 1>;
44
+ /** Class names for each element. */
45
+ classNames?: ClassNames;
46
+ /** Class name of the wrapper element. */
47
+ className?: string;
48
+ /** Dropdown `aria-label` value */
49
+ dropdownAriaLabel?: string;
50
+ /** Value of the `data-` attribute to be set on the focuesed/hovered suggestion. Defaults to `data-active-email`. */
51
+ activeDataAttr?: `data-${string}`;
52
+ children?: React.ReactNode;
53
+ /** Dropdown placement.
54
+ *
55
+ * @deprecated Since version 1.0.0 dropdown is always placed below the input.
56
+ */
57
+ placement?: "auto" | "bottom";
58
+ /** Custom prefix for dropdown unique ID.
59
+ *
60
+ * @deprecated Since version 1.2.0 it is generated automatically.
61
+ */
62
+ customPrefix?: string;
63
+ /** DOM ID of the wrapper element.
64
+ *
65
+ * @deprecated Since version 1.2.0
66
+ */
67
+ wrapperId?: string;
68
+ /** Input field validity state for assistive technologies.
69
+ *
70
+ * @deprecated Since version 1.2.0. Use `aria-invalid` instead.
71
+ */
72
+ isInvalid?: boolean;
73
+
74
+ autoComplete?: string;
75
+ };
76
+
77
+ export type Events = {
78
+ onFocus?: React.FocusEventHandler<HTMLInputElement>;
79
+ onBlur?: React.FocusEventHandler<HTMLInputElement>;
80
+ onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>;
81
+ onInput?: React.FormEventHandler<HTMLInputElement>;
82
+ };
83
+
84
+ export type InternalInputProps =
85
+ | "ref"
86
+ | "aria-expanded"
87
+ | "type"
88
+ | "role"
89
+ | "autoComplete"
90
+ | "aria-autocomplete"
91
+ | "aria-controls";
92
+
93
+ export type EmailProps = Props &
94
+ Events &
95
+ Partial<
96
+ Omit<
97
+ React.HTMLProps<HTMLInputElement>,
98
+ keyof Props | keyof Events | InternalInputProps
99
+ >
100
+ >;
101
+
102
+ export type LocalizedList = {
103
+ default: string[];
104
+ } & Record<string, string[]>;