sea-react-components 1.3.18 → 1.3.19

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 (44) hide show
  1. package/dist/components/notifications-menu/index.d.ts.map +1 -1
  2. package/dist/components/notifications-menu/index.js +3 -3
  3. package/dist/components/select/index.d.ts +2 -1
  4. package/dist/components/select/index.d.ts.map +1 -1
  5. package/dist/components/select/index.js +14 -2
  6. package/dist/utils/validation/index.d.ts.map +1 -1
  7. package/dist/utils/validation/index.js +1 -1
  8. package/package.json +2 -2
  9. package/dist/components/auto-complete/auto-complete-context copy.d.ts +0 -16
  10. package/dist/components/auto-complete/auto-complete-context copy.d.ts.map +0 -1
  11. package/dist/components/auto-complete/auto-complete-context copy.js +0 -8
  12. package/dist/components/auto-complete/component.d.ts +0 -29
  13. package/dist/components/auto-complete/component.d.ts.map +0 -1
  14. package/dist/components/auto-complete/component.js +0 -47
  15. package/dist/components/auto-complete-input copy/index.d.ts +0 -27
  16. package/dist/components/auto-complete-input copy/index.d.ts.map +0 -1
  17. package/dist/components/auto-complete-input copy/index.js +0 -75
  18. package/dist/components/auto-complete-input2/auto-complete-context.d.ts +0 -16
  19. package/dist/components/auto-complete-input2/auto-complete-context.d.ts.map +0 -1
  20. package/dist/components/auto-complete-input2/auto-complete-context.js +0 -8
  21. package/dist/components/auto-complete-input2/auto-complete-dropdown.d.ts +0 -2
  22. package/dist/components/auto-complete-input2/auto-complete-dropdown.d.ts.map +0 -1
  23. package/dist/components/auto-complete-input2/auto-complete-dropdown.js +0 -9
  24. package/dist/components/auto-complete-input2/auto-complete-input copy.d.ts +0 -2
  25. package/dist/components/auto-complete-input2/auto-complete-input copy.d.ts.map +0 -1
  26. package/dist/components/auto-complete-input2/auto-complete-input copy.js +0 -9
  27. package/dist/components/auto-complete-input2/auto-complete-input.d.ts +0 -2
  28. package/dist/components/auto-complete-input2/auto-complete-input.d.ts.map +0 -1
  29. package/dist/components/auto-complete-input2/auto-complete-input.js +0 -9
  30. package/dist/components/auto-complete-input2/auto-complete.d.ts +0 -14
  31. package/dist/components/auto-complete-input2/auto-complete.d.ts.map +0 -1
  32. package/dist/components/auto-complete-input2/auto-complete.js +0 -20
  33. package/dist/components/auto-complete-input2/component.d.ts +0 -29
  34. package/dist/components/auto-complete-input2/component.d.ts.map +0 -1
  35. package/dist/components/auto-complete-input2/component.js +0 -47
  36. package/dist/components/auto-complete-input2/index.d.ts +0 -3
  37. package/dist/components/auto-complete-input2/index.d.ts.map +0 -1
  38. package/dist/components/auto-complete-input2/index.js +0 -2
  39. package/dist/components/auto-complete-input2/use-autocomplete.d.ts +0 -21
  40. package/dist/components/auto-complete-input2/use-autocomplete.d.ts.map +0 -1
  41. package/dist/components/auto-complete-input2/use-autocomplete.js +0 -56
  42. package/dist/components/auto-complete-input2/useAutocomplete.d.ts +0 -21
  43. package/dist/components/auto-complete-input2/useAutocomplete.d.ts.map +0 -1
  44. package/dist/components/auto-complete-input2/useAutocomplete.js +0 -59
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/notifications-menu/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAc,MAAM,sBAAsB,CAAC;AAoB7D,MAAM,MAAM,KAAK,GAAG;IAClB,cAAc,EACV,SAAS,CAAC,WAAW,CAAC,eAAe,GACrC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mBAAmB,EAAE,MAAM,CAAC;IAC5B,oBAAoB,EAAE,OAAO,CAC3B,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,eAAe,EAAE,MAAM,CAAC,CACtD,CAAC;IACF,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC,CAAC;AACF,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACvC,cAAc,EACd,mBAAmB,EACnB,KAAyC,EACzC,oBAAoB,EACpB,QAAQ,GACT,EAAE,KAAK,2CA8UP"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/notifications-menu/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAc,MAAM,sBAAsB,CAAC;AAkB7D,MAAM,MAAM,KAAK,GAAG;IAClB,cAAc,EACV,SAAS,CAAC,WAAW,CAAC,eAAe,GACrC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mBAAmB,EAAE,MAAM,CAAC;IAC5B,oBAAoB,EAAE,OAAO,CAC3B,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,eAAe,EAAE,MAAM,CAAC,CACtD,CAAC;IACF,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC,CAAC;AACF,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACvC,cAAc,EACd,mBAAmB,EACnB,KAAyC,EACzC,oBAAoB,EACpB,QAAQ,GACT,EAAE,KAAK,2CA8UP"}
@@ -109,7 +109,7 @@ export default function NotificationMenu({ applicationKey, notificationBaseUrl,
109
109
  var _a, _b, _c, _d, _e;
110
110
  let title = _jsx(_Fragment, {}), description = _jsx(_Fragment, {}), icon = _jsx(_Fragment, {}), link = undefined;
111
111
  switch (notification.type) {
112
- case CONSTANTS.Notification.NotificationTypes.TaskAssignedToYou: {
112
+ case CONSTANTS.AccountAlertSetting.AlertActions.TaskAssignedToYou: {
113
113
  const task = ((_a = notification.objects) !== null && _a !== void 0 ? _a : {}).task;
114
114
  icon = (_jsx(Icon, { icon: "fluent-mdl2:assign", className: "h-10 w-10 transform" }));
115
115
  title = (_jsx("p", { className: "font-semibold line-clamp-2", children: "New task assigned to you" }));
@@ -117,7 +117,7 @@ export default function NotificationMenu({ applicationKey, notificationBaseUrl,
117
117
  link = `${applicationsBaseUrls[CONSTANTS.Application.ApplicationKeys.StrategyApplication]}/tasks/${task.id}`;
118
118
  break;
119
119
  }
120
- case CONSTANTS.Notification.NotificationTypes.TaskUnassignedFromYou: {
120
+ case CONSTANTS.AccountAlertSetting.AlertActions.TaskUnassignedFromYou: {
121
121
  const task = ((_b = notification.objects) !== null && _b !== void 0 ? _b : {}).task;
122
122
  icon = (_jsx(Icon, { icon: "fluent-mdl2:assign", className: "h-10 w-10 transform scale-x-[-1]" }));
123
123
  title = (_jsx("p", { className: "font-semibold line-clamp-2", children: "Task unassigned from you" }));
@@ -125,7 +125,7 @@ export default function NotificationMenu({ applicationKey, notificationBaseUrl,
125
125
  link = `${applicationsBaseUrls[CONSTANTS.Application.ApplicationKeys.StrategyApplication]}/tasks/${task.id}`;
126
126
  break;
127
127
  }
128
- case CONSTANTS.Notification.NotificationTypes.NewCommentAdded: {
128
+ case CONSTANTS.AccountAlertSetting.AlertActions.NewCommentAdded: {
129
129
  const addedBy = ((_c = notification.objects) !== null && _c !== void 0 ? _c : {})
130
130
  .addedBy;
131
131
  const objectName = ((_d = notification.objects) !== null && _d !== void 0 ? _d : {}).objectName;
@@ -18,6 +18,7 @@ export type Props<T> = {
18
18
  isSearchable?: boolean;
19
19
  required?: boolean;
20
20
  onChangeSearchInput?: (value: string) => void;
21
+ onRemove?: () => void;
21
22
  };
22
- export default function Select<T>({ name, options, values, setValues, errorMessage, buttonClassName, placeholder, multiselect, disabled, label, isSearchable, required, IconPlaceholderLeft, onChangeSearchInput, }: Props<T>): import("react/jsx-runtime").JSX.Element;
23
+ export default function Select<T>({ name, options, values, setValues, errorMessage, buttonClassName, placeholder, multiselect, disabled, label, isSearchable, required, IconPlaceholderLeft, onChangeSearchInput, onRemove, }: Props<T>): import("react/jsx-runtime").JSX.Element;
23
24
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/select/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAI3D,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI;IAC5B,KAAK,EAAE,CAAC,CAAC;IACT,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IAE3B,MAAM,EAAE,CAAC,EAAE,CAAC;IACZ,SAAS,EAAE,CAAC,SAAS,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;IACpC,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mBAAmB,CAAC,EAAE,GAAG,CAAC;IAC1B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,mBAAmB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAC/C,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,CAAC,EAAE,EAChC,IAAI,EACJ,OAAO,EACP,MAAM,EACN,SAAS,EACT,YAAY,EACZ,eAAe,EACf,WAAyB,EACzB,WAAmB,EACnB,QAAgB,EAChB,KAAK,EACL,YAAoB,EACpB,QAAgB,EAChB,mBAAmB,EACnB,mBAAmB,GACpB,EAAE,KAAK,CAAC,CAAC,CAAC,2CAwMV"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/select/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAI3D,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI;IAC5B,KAAK,EAAE,CAAC,CAAC;IACT,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IAE3B,MAAM,EAAE,CAAC,EAAE,CAAC;IACZ,SAAS,EAAE,CAAC,SAAS,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;IACpC,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mBAAmB,CAAC,EAAE,GAAG,CAAC;IAC1B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,mBAAmB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,CAAC,EAAE,EAChC,IAAI,EACJ,OAAO,EACP,MAAM,EACN,SAAS,EACT,YAAY,EACZ,eAAe,EACf,WAAyB,EACzB,WAAmB,EACnB,QAAgB,EAChB,KAAK,EACL,YAAoB,EACpB,QAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,QAAQ,GACT,EAAE,KAAK,CAAC,CAAC,CAAC,2CAoOV"}
@@ -3,7 +3,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useState, useRef, useEffect } from "react";
4
4
  import { Icon } from "@iconify/react";
5
5
  import clsx from "clsx";
6
- export default function Select({ name, options, values, setValues, errorMessage, buttonClassName, placeholder = "Select...", multiselect = false, disabled = false, label, isSearchable = false, required = false, IconPlaceholderLeft, onChangeSearchInput, }) {
6
+ export default function Select({ name, options, values, setValues, errorMessage, buttonClassName, placeholder = "Select...", multiselect = false, disabled = false, label, isSearchable = false, required = false, IconPlaceholderLeft, onChangeSearchInput, onRemove, // <-- NEW
7
+ }) {
7
8
  const [isOpen, setIsOpen] = useState(false);
8
9
  const [show, setShow] = useState(false);
9
10
  const [animate, setAnimate] = useState(false);
@@ -58,6 +59,14 @@ export default function Select({ name, options, values, setValues, errorMessage,
58
59
  return () => clearTimeout(timeout);
59
60
  }
60
61
  }, [isOpen]);
62
+ // Helper: clear all selected values then notify
63
+ const handleClear = (e) => {
64
+ e.stopPropagation();
65
+ if (disabled)
66
+ return;
67
+ setValues([]);
68
+ onRemove === null || onRemove === void 0 ? void 0 : onRemove();
69
+ };
61
70
  return (_jsxs("div", { className: "flex flex-col gap-1", children: [label && (_jsxs("label", { htmlFor: name, className: "pl-1 text-sm text-foreground font-medium mb-2", children: [label, " ", required && _jsx("span", { className: "font-bold", children: "*" })] })), _jsxs("div", { ref: containerRef, className: "relative w-full", children: [_jsxs("div", { onClick: () => !disabled && setIsOpen((o) => !o), className: clsx("text-text flex items-center justify-between gap-2 px-3 py-2 rounded-md border-0.5 hover:border-primary", disabled
62
71
  ? "bg-gray-100 text-gray-400 cursor-not-allowed"
63
72
  : "bg-white cursor-pointer", errorMessage
@@ -67,7 +76,10 @@ export default function Select({ name, options, values, setValues, errorMessage,
67
76
  : "border-gray-200", buttonClassName), children: [multiselect ? (selectedOptions.length ? (_jsx("div", { className: "flex flex-wrap gap-2", id: `${name}`, children: selectedOptions.map((o, i) => (_jsxs("div", { className: "bg-primary bg-opacity-50 px-2 py-1 rounded-2xl flex items-center gap-1", children: [_jsx("div", { className: "text-black text-sm", children: o.label }), !disabled && (_jsx("button", { type: "button", onClick: (e) => {
68
77
  e.stopPropagation();
69
78
  removeSelected(o);
70
- }, children: _jsx(Icon, { icon: "line-md:close-small", className: "w-4 h-4" }) }))] }, `${name}-${i}`))) })) : (_jsxs("div", { className: "flex gap-2 items-center ", children: [IconPlaceholderLeft, _jsx("p", { className: "text-gray-500", children: placeholder })] }))) : selectedOptions[0] ? (_jsx("div", { className: "text-text", children: selectedOptions[0].label })) : (_jsxs("div", { className: "flex gap-2 items-center", children: [IconPlaceholderLeft, _jsx("p", { className: "text-gray-500", children: placeholder })] })), _jsx(Icon, { icon: "iconamoon:arrow-down-2" })] }), show && !disabled && (_jsxs("div", { className: clsx("absolute left-0 mt-1 z-50 bg-white border border-gray-200 rounded-md shadow-lg max-h-64 overflow-auto", "max-w-[360px] min-w-[260px] w-full", "transition-all duration-200 ease-out", animate
79
+ }, children: _jsx(Icon, { icon: "line-md:close-small", className: "w-4 h-4" }) }))] }, `${name}-${i}`))) })) : (_jsxs("div", { className: "flex gap-2 items-center ", children: [IconPlaceholderLeft, _jsx("p", { className: "text-gray-500", children: placeholder })] }))) : selectedOptions[0] ? (_jsx("div", { className: "text-text", children: selectedOptions[0].label })) : (_jsxs("div", { className: "flex gap-2 items-center", children: [IconPlaceholderLeft, _jsx("p", { className: "text-gray-500", children: placeholder })] })), _jsxs("div", { className: "flex items-center gap-1", children: [!disabled &&
80
+ (multiselect
81
+ ? selectedOptions.length > 0
82
+ : !!selectedOptions[0]) && (_jsx("button", { type: "button", onClick: handleClear, "aria-label": "Clear selection", title: "Clear", className: "text-gray-500 hover:text-primary", children: _jsx(Icon, { icon: "line-md:close-small", className: "w-5 h-5" }) })), _jsx(Icon, { icon: "iconamoon:arrow-down-2" })] })] }), show && !disabled && (_jsxs("div", { className: clsx("absolute left-0 mt-1 z-50 bg-white border border-gray-200 rounded-md shadow-lg max-h-64 overflow-auto", "max-w-[360px] min-w-[260px] w-full", "transition-all duration-200 ease-out", animate
71
83
  ? "opacity-100 translate-y-0 scale-[1]"
72
84
  : "opacity-0 translate-y-[-5px] scale-[0.98]"), children: [isSearchable && (_jsxs("div", { className: "sticky top-0 bg-white border-b border-gray-100 px-2 py-1 flex items-center gap-2", onClick: (e) => e.stopPropagation(), children: [_jsx(Icon, { icon: "mdi:magnify", className: "text-gray-500 w-5 h-5" }), _jsx("input", { type: "text", placeholder: "Search...", value: search, onChange: handleSearchInputChange, className: "w-full outline-none text-sm bg-transparent py-1" })] })), filteredOptions.length > 0 ? (filteredOptions.map((o, i) => {
73
85
  const isSelected = selectedOptions.some((s) => Object.is(s.value, o.value));
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/validation/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAG3B,eAAO,MAAM,IAAI,wDAAoD,CAAC;AACtE,eAAO,MAAM,WAAW,wDAAkD,CAAC;AAC3E,eAAO,MAAM,SAAS,wDAAoC,CAAC;AAC3D,eAAO,MAAM,KAAK,wDAA4C,CAAC;AAC/D,eAAO,MAAM,WAAW,wDAKpB,CAAC;AACL,eAAO,MAAM,QAAQ,wDAA2C,CAAC;AACjE,eAAO,MAAM,eAAe,wDAEe,CAAC;AAE5C,eAAO,MAAM,UAAU,wDASpB,CAAC;AAEJ,eAAO,MAAM,OAAO,WAAY,MAAM,2DAGb,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/validation/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAG3B,eAAO,MAAM,IAAI,wDAAoD,CAAC;AACtE,eAAO,MAAM,WAAW,wDAAkD,CAAC;AAC3E,eAAO,MAAM,SAAS,wDAA0B,CAAC;AACjD,eAAO,MAAM,KAAK,wDAA4C,CAAC;AAC/D,eAAO,MAAM,WAAW,wDAKpB,CAAC;AACL,eAAO,MAAM,QAAQ,wDAA2C,CAAC;AACjE,eAAO,MAAM,eAAe,wDAEe,CAAC;AAE5C,eAAO,MAAM,UAAU,wDASpB,CAAC;AAEJ,eAAO,MAAM,OAAO,WAAY,MAAM,2DAGb,CAAC"}
@@ -2,7 +2,7 @@ import * as Yup from "yup";
2
2
  import { Utils } from "sea-platform-helpers";
3
3
  export const name = Yup.string().min(3).max(255).required("Required");
4
4
  export const description = Yup.string().trim().optional().min(3).max(1000);
5
- export const birthDate = Yup.string().required("Required");
5
+ export const birthDate = Yup.string().optional();
6
6
  export const email = Yup.string().email().required("Required");
7
7
  export const phoneNumber = Yup.string()
8
8
  .optional()
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sea-react-components",
3
3
  "description": "SEA react components library",
4
- "version": "1.3.18",
4
+ "version": "1.3.19",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
7
7
  "build": "tsc --build && npx postcss src/styles.css -o dist/styles.css && npx postcss src/components/text-editor/style.css -o dist/components/text-editor/style.css",
@@ -48,7 +48,7 @@
48
48
  "jwt-decode": "^4.0.0",
49
49
  "lowlight": "^3.3.0",
50
50
  "react-dom": "^18.3.1",
51
- "sea-platform-helpers": "^1.5.16",
51
+ "sea-platform-helpers": "^1.5.17",
52
52
  "sea-react-components": "file:",
53
53
  "uuid": "^13.0.0",
54
54
  "yup": "^1.5.0"
@@ -1,16 +0,0 @@
1
- import { SelectOption } from "../select";
2
- export type AutocompleteContextType<T> = {
3
- inputValue: string;
4
- setInputValue: (v: string) => void;
5
- open: boolean;
6
- setOpen: (v: boolean) => void;
7
- filteredOptions: SelectOption<T>[];
8
- select: (option: T) => void;
9
- remove: (option: T) => void;
10
- highlightedIndex: number;
11
- setHighlightedIndex: (i: number) => void;
12
- selected: T[];
13
- };
14
- export declare const AutocompleteContext: import("react").Context<AutocompleteContextType<any>>;
15
- export declare function useAutocompleteContext<T>(): AutocompleteContextType<T>;
16
- //# sourceMappingURL=auto-complete-context%20copy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auto-complete-context copy.d.ts","sourceRoot":"","sources":["../../../src/components/auto-complete/auto-complete-context copy.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,MAAM,MAAM,uBAAuB,CAAC,CAAC,IAAI;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IAC9B,eAAe,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IACnC,MAAM,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,IAAI,CAAC;IAC5B,MAAM,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,IAAI,CAAC;IAC5B,gBAAgB,EAAE,MAAM,CAAC;IACzB,mBAAmB,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,QAAQ,EAAE,CAAC,EAAE,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,mBAAmB,uDAC0B,CAAC;AAE3D,wBAAgB,sBAAsB,CAAC,CAAC,KAMxB,uBAAuB,CAAC,CAAC,CAAC,CACzC"}
@@ -1,8 +0,0 @@
1
- import { createContext, useContext } from "react";
2
- export const AutocompleteContext = createContext(null);
3
- export function useAutocompleteContext() {
4
- const ctx = useContext(AutocompleteContext);
5
- if (!ctx)
6
- throw new Error("Autocomplete compound components must be used within <Autocomplete>");
7
- return ctx;
8
- }
@@ -1,29 +0,0 @@
1
- import React from "react";
2
- import SearchInput from "../search-input";
3
- import { SelectOption } from "../select";
4
- export type Props<T extends string | number | {
5
- id: string;
6
- }> = {
7
- label?: string;
8
- name?: string;
9
- options: SelectOption<T>[];
10
- selectedOptions?: T[];
11
- setSelectedOptions?: (opts: T[]) => void;
12
- onOptionSelect?: (option: SelectOption<T>) => void;
13
- multiselect?: boolean;
14
- loading?: boolean;
15
- renderSelectedOptions?: (selected: T[], remove: (option: T) => void) => React.ReactNode;
16
- renderOption?: (option: SelectOption<T>, isHighlighted: boolean) => React.ReactNode;
17
- renderContainer?: (content: {
18
- input: React.ReactNode;
19
- dropdown: React.ReactNode;
20
- selected: React.ReactNode;
21
- multiselect: boolean;
22
- }) => React.ReactNode;
23
- } & Omit<React.ComponentProps<typeof SearchInput>, "onDebouncedChange"> & {
24
- onDebouncedChange?: (val: string) => void;
25
- };
26
- export default function AutoCompleteInput<T extends string | number | {
27
- id: string;
28
- }>({ label, name, options, selectedOptions, setSelectedOptions, onOptionSelect, value, onChange, onDebouncedChange, loading, multiselect, renderSelectedOptions, renderOption, renderContainer, ...rest }: Props<T>): import("react/jsx-runtime").JSX.Element;
29
- //# sourceMappingURL=component.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/components/auto-complete/component.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA4B,MAAM,OAAO,CAAC;AACjD,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAG1C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAGzC,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,IAAI;IAC9D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3B,eAAe,CAAC,EAAE,CAAC,EAAE,CAAC;IACtB,kBAAkB,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;IACzC,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IACnD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,qBAAqB,CAAC,EAAE,CACtB,QAAQ,EAAE,CAAC,EAAE,EACb,MAAM,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,IAAI,KACxB,KAAK,CAAC,SAAS,CAAC;IACrB,YAAY,CAAC,EAAE,CACb,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,EACvB,aAAa,EAAE,OAAO,KACnB,KAAK,CAAC,SAAS,CAAC;IACrB,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE;QAC1B,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;QACvB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;QAC1B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;QAC1B,WAAW,EAAE,OAAO,CAAC;KACtB,KAAK,KAAK,CAAC,SAAS,CAAC;CACvB,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,WAAW,CAAC,EAAE,mBAAmB,CAAC,GAAG;IACtE,iBAAiB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3C,CAAC;AAEJ,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EAC1C,EACA,KAAK,EACL,IAAI,EACJ,OAAO,EACP,eAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,KAAK,EACL,QAAQ,EACR,iBAAiB,EACjB,OAAe,EACf,WAAkB,EAClB,qBAAqB,EACrB,YAAY,EACZ,eAAe,EACf,GAAG,IAAI,EACR,EAAE,KAAK,CAAC,CAAC,CAAC,2CAsGV"}
@@ -1,47 +0,0 @@
1
- "use client";
2
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useRef, useEffect } from "react";
4
- import SearchInput from "../search-input";
5
- import Loader from "../loader";
6
- import clsx from "clsx";
7
- import { useAutocomplete } from "./use-autocomplete";
8
- export default function AutoCompleteInput({ label, name, options, selectedOptions = [], setSelectedOptions, onOptionSelect, value, onChange, onDebouncedChange, loading = false, multiselect = true, renderSelectedOptions, renderOption, renderContainer, ...rest }) {
9
- const containerRef = useRef(null);
10
- const { inputValue, setInputValue, open, setOpen, filteredOptions, select, remove, highlightedIndex, setHighlightedIndex, selected, } = useAutocomplete({
11
- options,
12
- selected: selectedOptions,
13
- multiselect,
14
- onSelect: setSelectedOptions,
15
- });
16
- // Click outside to close
17
- useEffect(() => {
18
- const handler = (e) => {
19
- var _a;
20
- if (!((_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.target)))
21
- setOpen(false);
22
- };
23
- document.addEventListener("mousedown", handler);
24
- return () => document.removeEventListener("mousedown", handler);
25
- }, []);
26
- const handleOptionSelect = (option) => {
27
- select(option.value);
28
- onOptionSelect === null || onOptionSelect === void 0 ? void 0 : onOptionSelect(option);
29
- };
30
- const input = (_jsx(SearchInput, { label: label, name: name, value: inputValue, onFocus: () => setOpen(true), onChange: (e) => {
31
- setInputValue(e.target.value);
32
- onChange === null || onChange === void 0 ? void 0 : onChange(e);
33
- }, onDebouncedChange: (val) => {
34
- setOpen(true);
35
- onDebouncedChange === null || onDebouncedChange === void 0 ? void 0 : onDebouncedChange(val);
36
- }, autoComplete: "off", ...rest }));
37
- const dropdown = open ? (_jsx("div", { className: "absolute z-10 w-full mt-1 bg-white border rounded shadow max-h-60 overflow-y-auto", children: loading ? (_jsx("div", { className: "p-4 flex justify-center items-center", children: _jsx(Loader, {}) })) : filteredOptions.length > 0 ? (filteredOptions.map((o, i) => (_jsx("div", { className: clsx("px-4 py-2 cursor-pointer custom-animation hover:bg-primary hover:bg-opacity-20", highlightedIndex === i && "bg-gray-100"), onMouseEnter: () => setHighlightedIndex(i), onClick: () => handleOptionSelect(o), children: renderOption ? renderOption(o, highlightedIndex === i) : o.label }, `${name}-option-${i}`)))) : (_jsx("div", { className: "p-4 text-center text-gray-400", children: "No options found" })) })) : null;
38
- const selectedNode = selected.length
39
- ? renderSelectedOptions === null || renderSelectedOptions === void 0 ? void 0 : renderSelectedOptions(selected, remove)
40
- : null;
41
- return (_jsx("div", { ref: containerRef, className: "relative w-full", children: renderContainer ? (renderContainer({
42
- input,
43
- dropdown,
44
- selected: selectedNode,
45
- multiselect,
46
- })) : (_jsxs(_Fragment, { children: [selectedNode, input, dropdown] })) }));
47
- }
@@ -1,27 +0,0 @@
1
- import React from "react";
2
- import SearchInput from "../search-input";
3
- import { SelectOption } from "../select";
4
- export type Props<T extends string | number | {
5
- id: string;
6
- }> = {
7
- label?: string;
8
- options: SelectOption<T>[];
9
- selectedOptions?: T[];
10
- setSelectedOptions?: (opts: T[]) => void;
11
- onOptionSelect?: (option: SelectOption<T>) => void;
12
- multiselect?: boolean;
13
- loading?: boolean;
14
- renderSelectedOptions?: (selected: T[]) => React.ReactNode;
15
- renderContainer?: (content: {
16
- input: React.ReactNode;
17
- dropdown: React.ReactNode;
18
- selected: React.ReactNode;
19
- multiselect: boolean;
20
- }) => React.ReactNode;
21
- } & Omit<React.ComponentProps<typeof SearchInput>, "onDebouncedChange"> & {
22
- onDebouncedChange?: (val: string) => void;
23
- };
24
- export default function AutoCompleteInput<T extends string | number | {
25
- id: string;
26
- }>({ label, name, options, selectedOptions, setSelectedOptions, onOptionSelect, value, onChange, onDebouncedChange, loading, multiselect, renderSelectedOptions, renderContainer, ...rest }: Props<T>): import("react/jsx-runtime").JSX.Element;
27
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/auto-complete-input copy/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAC3D,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAIzC,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,IAAI;IAC9D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3B,eAAe,CAAC,EAAE,CAAC,EAAE,CAAC;IACtB,kBAAkB,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;IACzC,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IACnD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,qBAAqB,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,EAAE,KAAK,KAAK,CAAC,SAAS,CAAC;IAC3D,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE;QAC1B,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;QACvB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;QAC1B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;QAC1B,WAAW,EAAE,OAAO,CAAC;KACtB,KAAK,KAAK,CAAC,SAAS,CAAC;CACvB,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,WAAW,CAAC,EAAE,mBAAmB,CAAC,GAAG;IACtE,iBAAiB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3C,CAAC;AAEJ,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EAC1C,EACA,KAAK,EACL,IAAI,EACJ,OAAO,EACP,eAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,KAAK,EACL,QAAQ,EACR,iBAAiB,EACjB,OAAe,EACf,WAAkB,EAClB,qBAAqB,EACrB,eAAe,EACf,GAAG,IAAI,EACR,EAAE,KAAK,CAAC,CAAC,CAAC,2CAiIV"}
@@ -1,75 +0,0 @@
1
- "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useState, useRef, useEffect } from "react";
4
- import SearchInput from "../search-input";
5
- import clsx from "clsx";
6
- import Loader from "../loader";
7
- export default function AutoCompleteInput({ label, name, options, selectedOptions = [], setSelectedOptions, onOptionSelect, value, onChange, onDebouncedChange, loading = false, multiselect = true, renderSelectedOptions, renderContainer, ...rest }) {
8
- var _a;
9
- const [show, setShow] = useState(false);
10
- const [inputValue, setInputValue] = useState((_a = value === null || value === void 0 ? void 0 : value.toString()) !== null && _a !== void 0 ? _a : "");
11
- const containerRef = useRef(null);
12
- useEffect(() => {
13
- const handler = (e) => {
14
- var _a;
15
- if (!((_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.target))) {
16
- setShow(false);
17
- }
18
- };
19
- document.addEventListener("mousedown", handler);
20
- return () => document.removeEventListener("mousedown", handler);
21
- }, []);
22
- const isAlreadySelected = (option) => {
23
- return selectedOptions.some((selected) => {
24
- if ((typeof selected === "string" || typeof selected === "number") &&
25
- (typeof option.value === "string" || typeof option.value === "number")) {
26
- return selected === option.value;
27
- }
28
- if (typeof selected === "object" &&
29
- typeof option.value === "object" &&
30
- "id" in selected &&
31
- "id" in option.value) {
32
- return selected.id === option.value.id;
33
- }
34
- return false;
35
- });
36
- };
37
- const filteredOptions = multiselect
38
- ? options.filter((o) => !isAlreadySelected(o))
39
- : options;
40
- const handleSelect = (option) => {
41
- setInputValue("");
42
- onChange === null || onChange === void 0 ? void 0 : onChange({ target: { name, value: "" } });
43
- if (multiselect) {
44
- if (!isAlreadySelected(option)) {
45
- setSelectedOptions === null || setSelectedOptions === void 0 ? void 0 : setSelectedOptions([...selectedOptions, option.value]);
46
- }
47
- }
48
- else {
49
- setSelectedOptions === null || setSelectedOptions === void 0 ? void 0 : setSelectedOptions([option.value]); // Only one selection
50
- setShow(false); // Hide dropdown immediately
51
- }
52
- onOptionSelect === null || onOptionSelect === void 0 ? void 0 : onOptionSelect(option);
53
- };
54
- useEffect(() => {
55
- var _a;
56
- setInputValue((_a = value === null || value === void 0 ? void 0 : value.toString()) !== null && _a !== void 0 ? _a : "");
57
- }, [value]);
58
- const input = (_jsx(SearchInput, { label: label, name: name, value: inputValue, onFocus: () => setShow(true), onChange: (e) => {
59
- setInputValue(e.target.value);
60
- onChange === null || onChange === void 0 ? void 0 : onChange(e);
61
- }, onDebouncedChange: (val) => {
62
- setShow(true);
63
- onDebouncedChange === null || onDebouncedChange === void 0 ? void 0 : onDebouncedChange(val);
64
- }, autoComplete: "off", ...rest }));
65
- const dropdown = show && inputValue.trim() !== "" ? (_jsx("div", { className: "absolute z-10 w-full mt-1 bg-white border rounded shadow max-h-60 overflow-y-auto", children: loading ? (_jsx("div", { className: "p-4 flex justify-center items-center", children: _jsx(Loader, {}) })) : filteredOptions.length > 0 ? (filteredOptions.map((o, i) => (_jsx("div", { className: clsx("px-4 py-2 cursor-pointer custom-animation hover:bg-primary hover:bg-opacity-20"), onClick: () => handleSelect(o), children: o.label }, `${name}-option-${i}`)))) : (_jsx("div", { className: "p-4 text-center text-gray-400", children: "No options found" })) })) : null;
66
- const selected = selectedOptions.length
67
- ? renderSelectedOptions === null || renderSelectedOptions === void 0 ? void 0 : renderSelectedOptions(selectedOptions)
68
- : null;
69
- return (_jsx("div", { ref: containerRef, children: renderContainer ? (_jsx("div", { className: "relative", children: renderContainer({
70
- input,
71
- dropdown,
72
- selected,
73
- multiselect,
74
- }) })) : (_jsxs("div", { className: "relative", children: [selected, input, dropdown] })) }));
75
- }
@@ -1,16 +0,0 @@
1
- import { SelectOption } from "../select";
2
- export type AutocompleteContextType<T> = {
3
- inputValue: string;
4
- setInputValue: (v: string) => void;
5
- open: boolean;
6
- setOpen: (v: boolean) => void;
7
- filteredOptions: SelectOption<T>[];
8
- select: (option: T) => void;
9
- remove: (option: T) => void;
10
- highlightedIndex: number;
11
- setHighlightedIndex: (i: number) => void;
12
- selected: T[];
13
- };
14
- export declare const AutocompleteContext: import("react").Context<AutocompleteContextType<any>>;
15
- export declare function useAutocompleteContext<T>(): AutocompleteContextType<T>;
16
- //# sourceMappingURL=auto-complete-context.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auto-complete-context.d.ts","sourceRoot":"","sources":["../../../src/components/auto-complete-input2/auto-complete-context.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,MAAM,MAAM,uBAAuB,CAAC,CAAC,IAAI;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IAC9B,eAAe,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IACnC,MAAM,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,IAAI,CAAC;IAC5B,MAAM,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,IAAI,CAAC;IAC5B,gBAAgB,EAAE,MAAM,CAAC;IACzB,mBAAmB,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,QAAQ,EAAE,CAAC,EAAE,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,mBAAmB,uDAC0B,CAAC;AAE3D,wBAAgB,sBAAsB,CAAC,CAAC,KAMxB,uBAAuB,CAAC,CAAC,CAAC,CACzC"}
@@ -1,8 +0,0 @@
1
- import { createContext, useContext } from "react";
2
- export const AutocompleteContext = createContext(null);
3
- export function useAutocompleteContext() {
4
- const ctx = useContext(AutocompleteContext);
5
- if (!ctx)
6
- throw new Error("Autocomplete compound components must be used within <Autocomplete>");
7
- return ctx;
8
- }
@@ -1,2 +0,0 @@
1
- export declare function Input(): import("react/jsx-runtime").JSX.Element;
2
- //# sourceMappingURL=auto-complete-dropdown.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auto-complete-dropdown.d.ts","sourceRoot":"","sources":["../../../src/components/auto-complete-input2/auto-complete-dropdown.tsx"],"names":[],"mappings":"AAIA,wBAAgB,KAAK,4CAYpB"}
@@ -1,9 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useAutocompleteContext } from "./auto-complete-context";
3
- import SearchInput from "../search-input";
4
- export function Input() {
5
- const { inputValue, setInputValue, setOpen } = useAutocompleteContext();
6
- return (_jsx(SearchInput, { value: inputValue, onFocus: () => setOpen(true),
7
- // onChange={(e) => setInputValue(e.target.value)}
8
- autoComplete: "off", onDebouncedChange: (value) => setInputValue(value) }));
9
- }
@@ -1,2 +0,0 @@
1
- export declare function Input(): import("react/jsx-runtime").JSX.Element;
2
- //# sourceMappingURL=auto-complete-input%20copy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auto-complete-input copy.d.ts","sourceRoot":"","sources":["../../../src/components/auto-complete-input2/auto-complete-input copy.tsx"],"names":[],"mappings":"AAIA,wBAAgB,KAAK,4CAYpB"}
@@ -1,9 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useAutocompleteContext } from "./auto-complete-context";
3
- import SearchInput from "../search-input";
4
- export function Input() {
5
- const { inputValue, setInputValue, setOpen } = useAutocompleteContext();
6
- return (_jsx(SearchInput, { value: inputValue, onFocus: () => setOpen(true),
7
- // onChange={(e) => setInputValue(e.target.value)}
8
- autoComplete: "off", onDebouncedChange: (value) => setInputValue(value) }));
9
- }
@@ -1,2 +0,0 @@
1
- export declare function Input(): import("react/jsx-runtime").JSX.Element;
2
- //# sourceMappingURL=auto-complete-input.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auto-complete-input.d.ts","sourceRoot":"","sources":["../../../src/components/auto-complete-input2/auto-complete-input.tsx"],"names":[],"mappings":"AAIA,wBAAgB,KAAK,4CAYpB"}
@@ -1,9 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useAutocompleteContext } from "./auto-complete-context";
3
- import SearchInput from "../search-input";
4
- export function Input() {
5
- const { inputValue, setInputValue, setOpen } = useAutocompleteContext();
6
- return (_jsx(SearchInput, { value: inputValue, onFocus: () => setOpen(true),
7
- // onChange={(e) => setInputValue(e.target.value)}
8
- autoComplete: "off", onDebouncedChange: (value) => setInputValue(value) }));
9
- }
@@ -1,14 +0,0 @@
1
- import React from "react";
2
- import { SelectOption } from "../select";
3
- export type AutocompleteProps<T> = {
4
- options: SelectOption<T>[];
5
- selected?: T[];
6
- onSelect?: (selected: T[]) => void;
7
- multiselect?: boolean;
8
- loading?: boolean;
9
- children: React.ReactNode;
10
- };
11
- export declare function Autocomplete<T extends string | number | {
12
- id: string;
13
- }>({ options, selected, onSelect, multiselect, loading, children, }: AutocompleteProps<T>): import("react/jsx-runtime").JSX.Element;
14
- //# sourceMappingURL=auto-complete.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auto-complete.d.ts","sourceRoot":"","sources":["../../../src/components/auto-complete-input2/auto-complete.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA4B,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAOzC,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI;IACjC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3B,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;IACf,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;IACnC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAEF,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EAAE,EACvE,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,WAAkB,EAClB,OAAe,EACf,QAAQ,GACT,EAAE,iBAAiB,CAAC,CAAC,CAAC,2CAqBtB"}
@@ -1,20 +0,0 @@
1
- "use client";
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- import { useRef, useEffect } from "react";
4
- import { AutocompleteContext } from "./auto-complete-context";
5
- import { useAutocomplete } from "./use-autocomplete";
6
- export function Autocomplete({ options, selected, onSelect, multiselect = true, loading = false, children, }) {
7
- const containerRef = useRef(null);
8
- const ac = useAutocomplete({ options, selected, multiselect, onSelect });
9
- // Close dropdown on outside click
10
- useEffect(() => {
11
- const handler = (e) => {
12
- var _a;
13
- if (!((_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.target)))
14
- ac.setOpen(false);
15
- };
16
- document.addEventListener("mousedown", handler);
17
- return () => document.removeEventListener("mousedown", handler);
18
- }, [ac]);
19
- return (_jsx(AutocompleteContext.Provider, { value: ac, children: _jsx("div", { ref: containerRef, className: "relative w-full", children: children }) }));
20
- }
@@ -1,29 +0,0 @@
1
- import React from "react";
2
- import SearchInput from "../search-input";
3
- import { SelectOption } from "../select";
4
- export type Props<T extends string | number | {
5
- id: string;
6
- }> = {
7
- label?: string;
8
- name?: string;
9
- options: SelectOption<T>[];
10
- selectedOptions?: T[];
11
- setSelectedOptions?: (opts: T[]) => void;
12
- onOptionSelect?: (option: SelectOption<T>) => void;
13
- multiselect?: boolean;
14
- loading?: boolean;
15
- renderSelectedOptions?: (selected: T[], remove: (option: T) => void) => React.ReactNode;
16
- renderOption?: (option: SelectOption<T>, isHighlighted: boolean) => React.ReactNode;
17
- renderContainer?: (content: {
18
- input: React.ReactNode;
19
- dropdown: React.ReactNode;
20
- selected: React.ReactNode;
21
- multiselect: boolean;
22
- }) => React.ReactNode;
23
- } & Omit<React.ComponentProps<typeof SearchInput>, "onDebouncedChange"> & {
24
- onDebouncedChange?: (val: string) => void;
25
- };
26
- export default function AutoCompleteInput<T extends string | number | {
27
- id: string;
28
- }>({ label, name, options, selectedOptions, setSelectedOptions, onOptionSelect, value, onChange, onDebouncedChange, loading, multiselect, renderSelectedOptions, renderOption, renderContainer, ...rest }: Props<T>): import("react/jsx-runtime").JSX.Element;
29
- //# sourceMappingURL=component.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/components/auto-complete-input2/component.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA4B,MAAM,OAAO,CAAC;AACjD,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAG1C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAGzC,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,IAAI;IAC9D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3B,eAAe,CAAC,EAAE,CAAC,EAAE,CAAC;IACtB,kBAAkB,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;IACzC,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IACnD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,qBAAqB,CAAC,EAAE,CACtB,QAAQ,EAAE,CAAC,EAAE,EACb,MAAM,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,IAAI,KACxB,KAAK,CAAC,SAAS,CAAC;IACrB,YAAY,CAAC,EAAE,CACb,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,EACvB,aAAa,EAAE,OAAO,KACnB,KAAK,CAAC,SAAS,CAAC;IACrB,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE;QAC1B,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;QACvB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;QAC1B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;QAC1B,WAAW,EAAE,OAAO,CAAC;KACtB,KAAK,KAAK,CAAC,SAAS,CAAC;CACvB,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,WAAW,CAAC,EAAE,mBAAmB,CAAC,GAAG;IACtE,iBAAiB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3C,CAAC;AAEJ,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EAC1C,EACA,KAAK,EACL,IAAI,EACJ,OAAO,EACP,eAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,KAAK,EACL,QAAQ,EACR,iBAAiB,EACjB,OAAe,EACf,WAAkB,EAClB,qBAAqB,EACrB,YAAY,EACZ,eAAe,EACf,GAAG,IAAI,EACR,EAAE,KAAK,CAAC,CAAC,CAAC,2CAsGV"}
@@ -1,47 +0,0 @@
1
- "use client";
2
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useRef, useEffect } from "react";
4
- import SearchInput from "../search-input";
5
- import Loader from "../loader";
6
- import clsx from "clsx";
7
- import { useAutocomplete } from "./use-autocomplete";
8
- export default function AutoCompleteInput({ label, name, options, selectedOptions = [], setSelectedOptions, onOptionSelect, value, onChange, onDebouncedChange, loading = false, multiselect = true, renderSelectedOptions, renderOption, renderContainer, ...rest }) {
9
- const containerRef = useRef(null);
10
- const { inputValue, setInputValue, open, setOpen, filteredOptions, select, remove, highlightedIndex, setHighlightedIndex, selected, } = useAutocomplete({
11
- options,
12
- selected: selectedOptions,
13
- multiselect,
14
- onSelect: setSelectedOptions,
15
- });
16
- // Click outside to close
17
- useEffect(() => {
18
- const handler = (e) => {
19
- var _a;
20
- if (!((_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.target)))
21
- setOpen(false);
22
- };
23
- document.addEventListener("mousedown", handler);
24
- return () => document.removeEventListener("mousedown", handler);
25
- }, []);
26
- const handleOptionSelect = (option) => {
27
- select(option.value);
28
- onOptionSelect === null || onOptionSelect === void 0 ? void 0 : onOptionSelect(option);
29
- };
30
- const input = (_jsx(SearchInput, { label: label, name: name, value: inputValue, onFocus: () => setOpen(true), onChange: (e) => {
31
- setInputValue(e.target.value);
32
- onChange === null || onChange === void 0 ? void 0 : onChange(e);
33
- }, onDebouncedChange: (val) => {
34
- setOpen(true);
35
- onDebouncedChange === null || onDebouncedChange === void 0 ? void 0 : onDebouncedChange(val);
36
- }, autoComplete: "off", ...rest }));
37
- const dropdown = open ? (_jsx("div", { className: "absolute z-10 w-full mt-1 bg-white border rounded shadow max-h-60 overflow-y-auto", children: loading ? (_jsx("div", { className: "p-4 flex justify-center items-center", children: _jsx(Loader, {}) })) : filteredOptions.length > 0 ? (filteredOptions.map((o, i) => (_jsx("div", { className: clsx("px-4 py-2 cursor-pointer custom-animation hover:bg-primary hover:bg-opacity-20", highlightedIndex === i && "bg-gray-100"), onMouseEnter: () => setHighlightedIndex(i), onClick: () => handleOptionSelect(o), children: renderOption ? renderOption(o, highlightedIndex === i) : o.label }, `${name}-option-${i}`)))) : (_jsx("div", { className: "p-4 text-center text-gray-400", children: "No options found" })) })) : null;
38
- const selectedNode = selected.length
39
- ? renderSelectedOptions === null || renderSelectedOptions === void 0 ? void 0 : renderSelectedOptions(selected, remove)
40
- : null;
41
- return (_jsx("div", { ref: containerRef, className: "relative w-full", children: renderContainer ? (renderContainer({
42
- input,
43
- dropdown,
44
- selected: selectedNode,
45
- multiselect,
46
- })) : (_jsxs(_Fragment, { children: [selectedNode, input, dropdown] })) }));
47
- }
@@ -1,3 +0,0 @@
1
- export { default as AutoCompleteInput2, Props } from "./component";
2
- export * from "./use-autocomplete";
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/auto-complete-input2/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACnE,cAAc,oBAAoB,CAAC"}
@@ -1,2 +0,0 @@
1
- export { default as AutoCompleteInput2 } from "./component";
2
- export * from "./use-autocomplete";
@@ -1,21 +0,0 @@
1
- import { SelectOption } from "../select";
2
- export declare function useAutocomplete<T extends string | number | {
3
- id: string;
4
- }>(props: {
5
- options: SelectOption<T>[];
6
- selected?: T[];
7
- multiselect?: boolean;
8
- onSelect?: (selected: T[]) => void;
9
- }): {
10
- inputValue: string;
11
- setInputValue: import("react").Dispatch<import("react").SetStateAction<string>>;
12
- open: boolean;
13
- setOpen: import("react").Dispatch<import("react").SetStateAction<boolean>>;
14
- filteredOptions: SelectOption<T>[];
15
- select: (option: T) => void;
16
- remove: (option: T) => void;
17
- highlightedIndex: number;
18
- setHighlightedIndex: import("react").Dispatch<import("react").SetStateAction<number>>;
19
- selected: T[];
20
- };
21
- //# sourceMappingURL=use-autocomplete.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-autocomplete.d.ts","sourceRoot":"","sources":["../../../src/components/auto-complete-input2/use-autocomplete.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,wBAAgB,eAAe,CAC7B,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EAC1C,KAAK,EAAE;IACP,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3B,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;CACpC;;;;;;qBA0ByB,CAAC;qBAWD,CAAC;;;;EA4B1B"}
@@ -1,56 +0,0 @@
1
- import { useState, useMemo } from "react";
2
- export function useAutocomplete(props) {
3
- const { options, selected = [], multiselect = true, onSelect } = props;
4
- const [inputValue, setInputValue] = useState("");
5
- const [open, setOpen] = useState(false);
6
- const [highlightedIndex, setHighlightedIndex] = useState(0);
7
- const filteredOptions = useMemo(() => {
8
- if (!multiselect)
9
- return options;
10
- return options.filter((o) => !selected.some((s) => {
11
- if (typeof s === "string" || typeof s === "number")
12
- return s === o.value;
13
- if (typeof s === "object" &&
14
- "id" in s &&
15
- typeof o.value === "object" &&
16
- "id" in o.value)
17
- return s.id === o.value.id;
18
- return false;
19
- }));
20
- }, [options, selected, multiselect]);
21
- const select = (option) => {
22
- if (multiselect) {
23
- onSelect === null || onSelect === void 0 ? void 0 : onSelect([...selected, option]);
24
- }
25
- else {
26
- onSelect === null || onSelect === void 0 ? void 0 : onSelect([option]);
27
- setOpen(false);
28
- }
29
- setInputValue("");
30
- setHighlightedIndex(0);
31
- };
32
- const remove = (option) => {
33
- onSelect === null || onSelect === void 0 ? void 0 : onSelect(selected.filter((s) => {
34
- if (typeof s === "string" || typeof s === "number")
35
- return s !== option;
36
- if (typeof s === "object" &&
37
- "id" in s &&
38
- typeof option === "object" &&
39
- "id" in option)
40
- return s.id !== option.id;
41
- return true;
42
- }));
43
- };
44
- return {
45
- inputValue,
46
- setInputValue,
47
- open,
48
- setOpen,
49
- filteredOptions,
50
- select,
51
- remove,
52
- highlightedIndex,
53
- setHighlightedIndex,
54
- selected,
55
- };
56
- }
@@ -1,21 +0,0 @@
1
- import { SelectOption } from "../select";
2
- export declare function useAutocomplete<T extends string | number | {
3
- id: string;
4
- }>(props: {
5
- options: SelectOption<T>[];
6
- selected?: T[];
7
- multiselect?: boolean;
8
- onSelect?: (selected: T[]) => void;
9
- }): {
10
- inputValue: string;
11
- setInputValue: import("react").Dispatch<import("react").SetStateAction<string>>;
12
- open: boolean;
13
- setOpen: import("react").Dispatch<import("react").SetStateAction<boolean>>;
14
- filteredOptions: SelectOption<T>[];
15
- select: (option: T) => void;
16
- remove: (option: T) => void;
17
- highlightedIndex: number;
18
- setHighlightedIndex: import("react").Dispatch<import("react").SetStateAction<number>>;
19
- selected: T[];
20
- };
21
- //# sourceMappingURL=useAutocomplete.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useAutocomplete.d.ts","sourceRoot":"","sources":["../../../src/components/auto-complete-input2/useAutocomplete.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,wBAAgB,eAAe,CAC7B,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EAC1C,KAAK,EAAE;IACP,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3B,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;CACpC;;;;;;qBA4ByB,CAAC;qBAWD,CAAC;;;;EA6B1B"}
@@ -1,59 +0,0 @@
1
- import { useState, useMemo } from "react";
2
- export function useAutocomplete(props) {
3
- const { options, selected = [], multiselect = true, onSelect } = props;
4
- const [inputValue, setInputValue] = useState("");
5
- const [open, setOpen] = useState(false);
6
- const [highlightedIndex, setHighlightedIndex] = useState(0);
7
- const filteredOptions = useMemo(() => {
8
- if (!multiselect)
9
- return options;
10
- return options.filter((o) => !selected.some((s) => {
11
- if (typeof s === "string" || typeof s === "number") {
12
- return s === o.value;
13
- }
14
- if (typeof s === "object" &&
15
- "id" in s &&
16
- typeof o.value === "object" &&
17
- "id" in o.value) {
18
- return s.id === o.value.id;
19
- }
20
- return false;
21
- }));
22
- }, [options, selected, multiselect]);
23
- const select = (option) => {
24
- if (multiselect) {
25
- onSelect === null || onSelect === void 0 ? void 0 : onSelect([...selected, option]);
26
- }
27
- else {
28
- onSelect === null || onSelect === void 0 ? void 0 : onSelect([option]);
29
- setOpen(false);
30
- }
31
- setInputValue("");
32
- setHighlightedIndex(0);
33
- };
34
- const remove = (option) => {
35
- onSelect === null || onSelect === void 0 ? void 0 : onSelect(selected.filter((s) => {
36
- if (typeof s === "string" || typeof s === "number")
37
- return s !== option;
38
- if (typeof s === "object" &&
39
- "id" in s &&
40
- typeof option === "object" &&
41
- "id" in option) {
42
- return s.id !== option.id;
43
- }
44
- return true;
45
- }));
46
- };
47
- return {
48
- inputValue,
49
- setInputValue,
50
- open,
51
- setOpen,
52
- filteredOptions,
53
- select,
54
- remove,
55
- highlightedIndex,
56
- setHighlightedIndex,
57
- selected,
58
- };
59
- }