lkd-web-kit 0.8.4 → 0.9.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 (195) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +30 -30
  3. package/dist/components/EmptyState/index.cjs +1 -1
  4. package/dist/components/EmptyState/index.d.ts +16 -0
  5. package/dist/components/EmptyState/index.d.ts.map +1 -0
  6. package/dist/components/EmptyState/index.js +1 -1
  7. package/dist/components/Icon.d.ts +43 -0
  8. package/dist/components/Icon.d.ts.map +1 -0
  9. package/dist/components/InfinityLoadMoreButton/index.cjs +1 -1
  10. package/dist/components/InfinityLoadMoreButton/index.d.ts +17 -0
  11. package/dist/components/InfinityLoadMoreButton/index.d.ts.map +1 -0
  12. package/dist/components/InfinityLoadMoreButton/index.js +1 -1
  13. package/dist/components/InfinitySelect/index.cjs +79 -24
  14. package/dist/components/InfinitySelect/index.d.ts +35 -0
  15. package/dist/components/InfinitySelect/index.d.ts.map +1 -0
  16. package/dist/components/InfinitySelect/index.js +80 -25
  17. package/dist/components/InfinitySelect/index.test.d.ts +2 -0
  18. package/dist/components/InfinitySelect/index.test.d.ts.map +1 -0
  19. package/dist/components/MyCheckboxGroup/index.cjs +1 -1
  20. package/dist/components/MyCheckboxGroup/index.d.ts +9 -0
  21. package/dist/components/MyCheckboxGroup/index.d.ts.map +1 -0
  22. package/dist/components/MyCheckboxGroup/index.js +1 -1
  23. package/dist/components/MyDateInput/index.d.ts +6 -0
  24. package/dist/components/MyDateInput/index.d.ts.map +1 -0
  25. package/dist/components/MyDatePickerInput/CalendarIcon.d.ts +7 -0
  26. package/dist/components/MyDatePickerInput/CalendarIcon.d.ts.map +1 -0
  27. package/dist/components/MyDatePickerInput/index.d.ts +6 -0
  28. package/dist/components/MyDatePickerInput/index.d.ts.map +1 -0
  29. package/dist/components/MyDateTimePicker/index.d.ts +6 -0
  30. package/dist/components/MyDateTimePicker/index.d.ts.map +1 -0
  31. package/dist/components/MyMonthPickerInput/index.d.ts +6 -0
  32. package/dist/components/MyMonthPickerInput/index.d.ts.map +1 -0
  33. package/dist/components/MyMultiSelect/index.cjs +1 -1
  34. package/dist/components/MyMultiSelect/index.d.ts +6 -0
  35. package/dist/components/MyMultiSelect/index.d.ts.map +1 -0
  36. package/dist/components/MyMultiSelect/index.js +1 -1
  37. package/dist/components/MyNotifications/index.d.ts +5 -0
  38. package/dist/components/MyNotifications/index.d.ts.map +1 -0
  39. package/dist/components/MyNumberInput/index.cjs +1 -1
  40. package/dist/components/MyNumberInput/index.d.ts +6 -0
  41. package/dist/components/MyNumberInput/index.d.ts.map +1 -0
  42. package/dist/components/MyNumberInput/index.js +1 -1
  43. package/dist/components/MyRadioGroup/index.cjs +1 -1
  44. package/dist/components/MyRadioGroup/index.d.ts +9 -0
  45. package/dist/components/MyRadioGroup/index.d.ts.map +1 -0
  46. package/dist/components/MyRadioGroup/index.js +1 -1
  47. package/dist/components/MySelect/index.cjs +1 -1
  48. package/dist/components/MySelect/index.d.ts +6 -0
  49. package/dist/components/MySelect/index.d.ts.map +1 -0
  50. package/dist/components/MySelect/index.js +1 -1
  51. package/dist/components/MyTextInput/index.cjs +1 -1
  52. package/dist/components/MyTextInput/index.d.ts +6 -0
  53. package/dist/components/MyTextInput/index.d.ts.map +1 -0
  54. package/dist/components/MyTextInput/index.js +1 -1
  55. package/dist/components/MyTextarea/index.cjs +1 -1
  56. package/dist/components/MyTextarea/index.d.ts +6 -0
  57. package/dist/components/MyTextarea/index.d.ts.map +1 -0
  58. package/dist/components/MyTextarea/index.js +1 -1
  59. package/dist/components/MyTimeInput/index.cjs +1 -1
  60. package/dist/components/MyTimeInput/index.d.ts +6 -0
  61. package/dist/components/MyTimeInput/index.d.ts.map +1 -0
  62. package/dist/components/MyTimeInput/index.js +1 -1
  63. package/dist/components/NavItems.cjs +1 -1
  64. package/dist/components/NavItems.d.ts +17 -0
  65. package/dist/components/NavItems.d.ts.map +1 -0
  66. package/dist/components/NavItems.js +1 -1
  67. package/dist/components/index.d.ts +19 -0
  68. package/dist/components/index.d.ts.map +1 -0
  69. package/dist/consts/http-status.d.ts +64 -0
  70. package/dist/consts/http-status.d.ts.map +1 -0
  71. package/dist/consts/index.d.ts +3 -0
  72. package/dist/consts/index.d.ts.map +1 -0
  73. package/dist/consts/revalidate.d.ts +8 -0
  74. package/dist/consts/revalidate.d.ts.map +1 -0
  75. package/dist/contexts/NavigationHistoryContext/hook.d.ts +11 -0
  76. package/dist/contexts/NavigationHistoryContext/hook.d.ts.map +1 -0
  77. package/dist/contexts/NavigationHistoryContext/index.d.ts +11 -0
  78. package/dist/contexts/NavigationHistoryContext/index.d.ts.map +1 -0
  79. package/dist/contexts/PageDataContext/index.d.ts +8 -0
  80. package/dist/contexts/PageDataContext/index.d.ts.map +1 -0
  81. package/dist/contexts/index.d.ts +4 -0
  82. package/dist/contexts/index.d.ts.map +1 -0
  83. package/dist/form/Form.cjs +1 -1
  84. package/dist/form/Form.d.ts +10 -0
  85. package/dist/form/Form.d.ts.map +1 -0
  86. package/dist/form/Form.js +1 -1
  87. package/dist/form/FormSubmitButton.cjs +1 -1
  88. package/dist/form/FormSubmitButton.d.ts +6 -0
  89. package/dist/form/FormSubmitButton.d.ts.map +1 -0
  90. package/dist/form/FormSubmitButton.js +1 -1
  91. package/dist/form/base/FormCheckbox.cjs +1 -1
  92. package/dist/form/base/FormCheckbox.d.ts +8 -0
  93. package/dist/form/base/FormCheckbox.d.ts.map +1 -0
  94. package/dist/form/base/FormCheckbox.js +1 -1
  95. package/dist/form/base/FormCheckboxGroup.d.ts +8 -0
  96. package/dist/form/base/FormCheckboxGroup.d.ts.map +1 -0
  97. package/dist/form/base/FormDateInput.d.ts +9 -0
  98. package/dist/form/base/FormDateInput.d.ts.map +1 -0
  99. package/dist/form/base/FormDatePickerInput.d.ts +9 -0
  100. package/dist/form/base/FormDatePickerInput.d.ts.map +1 -0
  101. package/dist/form/base/FormDateTimePicker.d.ts +9 -0
  102. package/dist/form/base/FormDateTimePicker.d.ts.map +1 -0
  103. package/dist/form/base/FormMonthPickerInput.d.ts +9 -0
  104. package/dist/form/base/FormMonthPickerInput.d.ts.map +1 -0
  105. package/dist/form/base/FormMultiSelect.d.ts +8 -0
  106. package/dist/form/base/FormMultiSelect.d.ts.map +1 -0
  107. package/dist/form/base/FormNumberInput.d.ts +6 -0
  108. package/dist/form/base/FormNumberInput.d.ts.map +1 -0
  109. package/dist/form/base/FormRadioGroup.d.ts +8 -0
  110. package/dist/form/base/FormRadioGroup.d.ts.map +1 -0
  111. package/dist/form/base/FormSelect.d.ts +9 -0
  112. package/dist/form/base/FormSelect.d.ts.map +1 -0
  113. package/dist/form/base/FormSelectInfinity.d.ts +6 -0
  114. package/dist/form/base/FormSelectInfinity.d.ts.map +1 -0
  115. package/dist/form/base/FormTextInput.d.ts +8 -0
  116. package/dist/form/base/FormTextInput.d.ts.map +1 -0
  117. package/dist/form/base/FormTextarea.d.ts +9 -0
  118. package/dist/form/base/FormTextarea.d.ts.map +1 -0
  119. package/dist/form/base/FormTimeInput.d.ts +11 -0
  120. package/dist/form/base/FormTimeInput.d.ts.map +1 -0
  121. package/dist/form/index.d.ts +21 -0
  122. package/dist/form/index.d.ts.map +1 -0
  123. package/dist/form/utils/nullable-but-required.d.ts +3 -0
  124. package/dist/form/utils/nullable-but-required.d.ts.map +1 -0
  125. package/dist/form/utils/optional-but-required.d.ts +3 -0
  126. package/dist/form/utils/optional-but-required.d.ts.map +1 -0
  127. package/dist/form/utils/zodValidator.d.ts +3 -0
  128. package/dist/form/utils/zodValidator.d.ts.map +1 -0
  129. package/dist/hocs/index.d.ts +3 -0
  130. package/dist/hocs/index.d.ts.map +1 -0
  131. package/dist/hocs/withController.d.ts +26 -0
  132. package/dist/hocs/withController.d.ts.map +1 -0
  133. package/dist/hocs/withModalManager.d.ts +11 -0
  134. package/dist/hocs/withModalManager.d.ts.map +1 -0
  135. package/dist/hooks/index.d.ts +6 -0
  136. package/dist/hooks/index.d.ts.map +1 -0
  137. package/dist/hooks/useBreakpoint.d.ts +3 -0
  138. package/dist/hooks/useBreakpoint.d.ts.map +1 -0
  139. package/dist/hooks/useFetchNextPageOnScroll.d.ts +12 -0
  140. package/dist/hooks/useFetchNextPageOnScroll.d.ts.map +1 -0
  141. package/dist/hooks/useOnScrollProgress.d.ts +9 -0
  142. package/dist/hooks/useOnScrollProgress.d.ts.map +1 -0
  143. package/dist/hooks/useUpdateSearchParams.d.ts +6 -0
  144. package/dist/hooks/useUpdateSearchParams.d.ts.map +1 -0
  145. package/dist/hooks/useZodConfig.d.ts +2 -0
  146. package/dist/hooks/useZodConfig.d.ts.map +1 -0
  147. package/dist/index.cjs +33 -33
  148. package/dist/index.d.ts +10 -646
  149. package/dist/index.d.ts.map +1 -0
  150. package/dist/index.js +12 -12
  151. package/dist/mantine/breakpoints-with-px.d.ts +9 -0
  152. package/dist/mantine/breakpoints-with-px.d.ts.map +1 -0
  153. package/dist/mantine/index.d.ts +4 -0
  154. package/dist/mantine/index.d.ts.map +1 -0
  155. package/dist/mantine/my-default-theme.d.ts +3 -0
  156. package/dist/mantine/my-default-theme.d.ts.map +1 -0
  157. package/dist/mantine/to-tailwind-colors.d.ts +3 -0
  158. package/dist/mantine/to-tailwind-colors.d.ts.map +1 -0
  159. package/dist/test/setup.d.ts +1 -0
  160. package/dist/test/setup.d.ts.map +1 -0
  161. package/dist/types/api-list.d.ts +4 -0
  162. package/dist/types/api-list.d.ts.map +1 -0
  163. package/dist/types/api-pagination.d.ts +4 -0
  164. package/dist/types/api-pagination.d.ts.map +1 -0
  165. package/dist/types/index.d.ts +6 -0
  166. package/dist/types/index.d.ts.map +1 -0
  167. package/dist/types/page-props.d.ts +14 -0
  168. package/dist/types/page-props.d.ts.map +1 -0
  169. package/dist/types/setter.d.ts +3 -0
  170. package/dist/types/setter.d.ts.map +1 -0
  171. package/dist/types/utils/deep-partial.d.ts +4 -0
  172. package/dist/types/utils/deep-partial.d.ts.map +1 -0
  173. package/dist/utils/array/groupBy.d.ts +6 -0
  174. package/dist/utils/array/groupBy.d.ts.map +1 -0
  175. package/dist/utils/array/shuffleArray.d.ts +2 -0
  176. package/dist/utils/array/shuffleArray.d.ts.map +1 -0
  177. package/dist/utils/formatBytes.d.ts +2 -0
  178. package/dist/utils/formatBytes.d.ts.map +1 -0
  179. package/dist/utils/get-path-value.d.ts +2 -0
  180. package/dist/utils/get-path-value.d.ts.map +1 -0
  181. package/dist/utils/index.d.ts +10 -0
  182. package/dist/utils/index.d.ts.map +1 -0
  183. package/dist/utils/isInfinityEmpty.d.ts +5 -0
  184. package/dist/utils/isInfinityEmpty.d.ts.map +1 -0
  185. package/dist/utils/ky/addBodyJsonHook.d.ts +8 -0
  186. package/dist/utils/ky/addBodyJsonHook.d.ts.map +1 -0
  187. package/dist/utils/ky/parseJson.d.ts +3 -0
  188. package/dist/utils/ky/parseJson.d.ts.map +1 -0
  189. package/dist/utils/new-route.d.ts +28 -0
  190. package/dist/utils/new-route.d.ts.map +1 -0
  191. package/dist/utils/query-stringify.d.ts +2 -0
  192. package/dist/utils/query-stringify.d.ts.map +1 -0
  193. package/dist/utils/virtual-styles.d.ts +14 -0
  194. package/dist/utils/virtual-styles.d.ts.map +1 -0
  195. package/package.json +17 -13
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 Rayyamhk
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Rayyamhk
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,30 +1,30 @@
1
- # LKD WebKit
2
-
3
- ## Features
4
-
5
- - React: A JavaScript library for web and native user interfaces.
6
- - TypeScript: A strongly typed superset of JavaScript.
7
- <!-- - Storybook: A frontend workshop for building UI components and pages in isolation. -->
8
- - Vite: A next generation frontend tooling that runs and builds your library incredibly fast.
9
- - Vitest: A next generation testing framework.
10
- - ESLint: A tool that finds and fixes problems in your code.
11
- - Prettier: A code formatter.
12
-
13
- ## Get Started
14
-
15
- 1. Clone this repository
16
- 2. Install dependencies using `npm i`
17
-
18
- ## Scripts
19
-
20
- <!-- - `dev`: Starts the local Storybook server, use this to develop and preview your components. -->
21
-
22
- - `test`: Runs all your tests with vitest.
23
- - `test:watch`: Runs tests in watch mode.
24
- - `build`: Builds your component library with Vite.
25
- - `lint`: Runs ESLint.
26
- - `format`: Formats your code with Prettier.
27
-
28
- ## License
29
-
30
- MIT
1
+ # LKD WebKit
2
+
3
+ ## Features
4
+
5
+ - React: A JavaScript library for web and native user interfaces.
6
+ - TypeScript: A strongly typed superset of JavaScript.
7
+ <!-- - Storybook: A frontend workshop for building UI components and pages in isolation. -->
8
+ - Vite: A next generation frontend tooling that runs and builds your library incredibly fast.
9
+ - Vitest: A next generation testing framework.
10
+ - ESLint: A tool that finds and fixes problems in your code.
11
+ - Prettier: A code formatter.
12
+
13
+ ## Get Started
14
+
15
+ 1. Clone this repository
16
+ 2. Install dependencies using `npm i`
17
+
18
+ ## Scripts
19
+
20
+ <!-- - `dev`: Starts the local Storybook server, use this to develop and preview your components. -->
21
+
22
+ - `test`: Runs all your tests with vitest.
23
+ - `test:watch`: Runs tests in watch mode.
24
+ - `build`: Builds your component library with Vite.
25
+ - `lint`: Runs ESLint.
26
+ - `format`: Formats your code with Prettier.
27
+
28
+ ## License
29
+
30
+ MIT
@@ -1,7 +1,7 @@
1
1
  require("../../_virtual/_rolldown/runtime.cjs");
2
2
  const require_Icon = require("../Icon.cjs");
3
- let react_jsx_runtime = require("react/jsx-runtime");
4
3
  let _mantine_core = require("@mantine/core");
4
+ let react_jsx_runtime = require("react/jsx-runtime");
5
5
  //#region src/components/EmptyState/index.tsx
6
6
  var pxBySize = {
7
7
  sm: 48,
@@ -0,0 +1,16 @@
1
+ import { ComponentProps, ReactNode } from 'react';
2
+ import { IconFC } from '../Icon';
3
+ export interface EmptyProps extends ComponentProps<'div'> {
4
+ label: ReactNode;
5
+ action?: ReactNode;
6
+ icon?: IconFC;
7
+ size?: keyof typeof pxBySize;
8
+ }
9
+ declare const pxBySize: {
10
+ sm: number;
11
+ md: number;
12
+ lg: number;
13
+ };
14
+ export declare const EmptyState: ({ label, action, icon, size, ...props }: EmptyProps) => import("react/jsx-runtime").JSX.Element;
15
+ export {};
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/EmptyState/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjD,OAAO,EAAQ,MAAM,EAAE,MAAM,SAAS,CAAA;AAEtC,MAAM,WAAW,UAAW,SAAQ,cAAc,CAAC,KAAK,CAAC;IACvD,KAAK,EAAE,SAAS,CAAA;IAChB,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,OAAO,QAAQ,CAAA;CAC7B;AAED,QAAA,MAAM,QAAQ;;;;CAIb,CAAA;AAED,eAAO,MAAM,UAAU,GAAI,yCAAgD,UAAU,4CAkCpF,CAAA"}
@@ -1,6 +1,6 @@
1
1
  import { Icon } from "../Icon.js";
2
- import { jsx, jsxs } from "react/jsx-runtime";
3
2
  import { Text, useMantineTheme } from "@mantine/core";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
4
  //#region src/components/EmptyState/index.tsx
5
5
  var pxBySize = {
6
6
  sm: 48,
@@ -0,0 +1,43 @@
1
+ import { default as React, ComponentPropsWithoutRef } from 'react';
2
+ export type IconFC = React.FC<ComponentPropsWithoutRef<'svg'>>;
3
+ export interface IconProps extends ComponentPropsWithoutRef<'svg'> {
4
+ i: IconFC;
5
+ /**
6
+ * @property xs: 16px
7
+ * @property sm: 20px
8
+ * @property md: 24px
9
+ * @property lg: 28px
10
+ * @property xl: 32px
11
+ * @property 2xl: 40px
12
+ */
13
+ size?: keyof typeof stylesBySize | number;
14
+ }
15
+ export declare const Icon: ({ i: I, size, style, rotate, ...rest }: IconProps) => import("react/jsx-runtime").JSX.Element;
16
+ declare const stylesBySize: {
17
+ xs: {
18
+ height: number;
19
+ width: number;
20
+ };
21
+ sm: {
22
+ height: number;
23
+ width: number;
24
+ };
25
+ md: {
26
+ height: number;
27
+ width: number;
28
+ };
29
+ lg: {
30
+ height: number;
31
+ width: number;
32
+ };
33
+ xl: {
34
+ height: number;
35
+ width: number;
36
+ };
37
+ "2xl": {
38
+ height: number;
39
+ width: number;
40
+ };
41
+ };
42
+ export {};
43
+ //# sourceMappingURL=Icon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Icon.d.ts","sourceRoot":"","sources":["../../src/components/Icon.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,wBAAwB,EAAE,MAAM,OAAO,CAAA;AAEvD,MAAM,MAAM,MAAM,GAAG,KAAK,CAAC,EAAE,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC,CAAA;AAC9D,MAAM,WAAW,SAAU,SAAQ,wBAAwB,CAAC,KAAK,CAAC;IAChE,CAAC,EAAE,MAAM,CAAA;IACT;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,MAAM,OAAO,YAAY,GAAG,MAAM,CAAA;CAC1C;AAED,eAAO,MAAM,IAAI,GAAI,wCAA+C,SAAS,4CAkB5E,CAAA;AAED,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;CAyBjB,CAAA"}
@@ -1,7 +1,7 @@
1
1
  const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
2
+ let _mantine_core = require("@mantine/core");
2
3
  let react = require("react");
3
4
  let react_jsx_runtime = require("react/jsx-runtime");
4
- let _mantine_core = require("@mantine/core");
5
5
  let _mantine_hooks = require("@mantine/hooks");
6
6
  let clsx = require("clsx");
7
7
  clsx = require_runtime.__toESM(clsx, 1);
@@ -0,0 +1,17 @@
1
+ import { ButtonProps } from '@mantine/core';
2
+ import { InfiniteData } from '@tanstack/react-query';
3
+ import { RefObject } from 'react';
4
+ import { InfiniteQueryHookResult } from 'react-query-kit';
5
+ export interface InfinityLoadMoreButtonProps<T> extends ButtonProps {
6
+ infinity: InfiniteQueryHookResult<InfiniteData<{
7
+ data?: T[];
8
+ }, number>, Error>;
9
+ parentRef?: RefObject<HTMLElement | null>;
10
+ loader?: React.ReactNode;
11
+ labels?: {
12
+ loadMore?: string;
13
+ end?: string;
14
+ };
15
+ }
16
+ export declare const InfinityLoadMoreButton: <T>({ infinity, labels, parentRef, loader, ...props }: InfinityLoadMoreButtonProps<T>) => import("react/jsx-runtime").JSX.Element;
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/InfinityLoadMoreButton/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,eAAe,CAAA;AAExD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAEzD,OAAO,EAAE,KAAK,SAAS,EAAa,MAAM,OAAO,CAAA;AACjD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAA;AAE9D,MAAM,WAAW,2BAA2B,CAAC,CAAC,CAAE,SAAQ,WAAW;IACjE,QAAQ,EAAE,uBAAuB,CAAC,YAAY,CAAC;QAAE,IAAI,CAAC,EAAE,CAAC,EAAE,CAAA;KAAE,EAAE,MAAM,CAAC,EAAE,KAAK,CAAC,CAAA;IAC9E,SAAS,CAAC,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;IACzC,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACxB,MAAM,CAAC,EAAE;QACP,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,GAAG,CAAC,EAAE,MAAM,CAAA;KACb,CAAA;CACF;AAED,eAAO,MAAM,sBAAsB,GAAI,CAAC,EAAG,mDAMxC,2BAA2B,CAAC,CAAC,CAAC,4CA8BhC,CAAA"}
@@ -1,6 +1,6 @@
1
+ import { Button } from "@mantine/core";
1
2
  import { useEffect } from "react";
2
3
  import { jsx } from "react/jsx-runtime";
3
- import { Button } from "@mantine/core";
4
4
  import { useIntersection } from "@mantine/hooks";
5
5
  import clsx from "clsx";
6
6
  //#region src/components/InfinityLoadMoreButton/index.tsx
@@ -2,14 +2,15 @@
2
2
  require("../../_virtual/_rolldown/runtime.cjs");
3
3
  const require_index = require("../InfinityLoadMoreButton/index.cjs");
4
4
  const require_virtual_styles = require("../../utils/virtual-styles.cjs");
5
+ let _mantine_core = require("@mantine/core");
5
6
  let react = require("react");
6
7
  let react_jsx_runtime = require("react/jsx-runtime");
7
- let _mantine_core = require("@mantine/core");
8
8
  let _mantine_hooks = require("@mantine/hooks");
9
9
  let _tanstack_react_virtual = require("@tanstack/react-virtual");
10
10
  //#region src/components/InfinitySelect/index.tsx
11
- function InfinitySelect({ value, searchValue, defaultSearchValue, nothingFoundMessage, infinity, defaultValue, onChange, onSearchChange, renderOption, onOptionSubmit, getOptionLabel, getOptionValue, onSelectedOptionChange, selectedOption, comboboxProps, searchable = true, defaultSelectedOption = null, loadMoreButtonProps, ...props }) {
12
- const combobox = (0, _mantine_core.useCombobox)();
11
+ var OPTION_HEIGHT = 40;
12
+ function InfinitySelect({ value, searchValue, defaultSearchValue, nothingFoundMessage, infinity, defaultValue, onChange, onSearchChange, renderOption, onOptionSubmit, getOptionLabel, getOptionValue, onSelectedOptionChange, selectedOption, comboboxProps, searchable = true, defaultSelectedOption = null, loadMoreButtonProps, resetPageParam, readOnly, ...props }) {
13
+ const isReadOnly = !searchable || readOnly;
13
14
  const [_selectedOption, handleSelectedOption] = (0, _mantine_hooks.useUncontrolled)({
14
15
  defaultValue: defaultSelectedOption,
15
16
  value: selectedOption,
@@ -25,14 +26,23 @@ function InfinitySelect({ value, searchValue, defaultSearchValue, nothingFoundMe
25
26
  value: searchValue,
26
27
  onChange: onSearchChange
27
28
  });
28
- const data = infinity.data?.pages.flatMap((page) => page.data) ?? [];
29
- const _reset = () => {
29
+ const data = (0, react.useMemo)(() => infinity.data?.pages.flatMap((page) => page.data ?? []) ?? [], [infinity.data]);
30
+ const scrollRef = (0, react.useRef)(null);
31
+ const [selectedOptionIndex, setSelectedOptionIndex] = (0, react.useState)(-1);
32
+ const [activeOptionIndex, setActiveOptionIndex] = (0, react.useState)(-1);
33
+ const resetSelection = (options) => {
30
34
  handleSearch("");
31
35
  handleValue(null);
32
36
  handleSelectedOption(null);
37
+ setActiveOptionIndex(-1);
38
+ setSelectedOptionIndex(-1);
39
+ if (options?.resetPage) resetPageParam?.();
40
+ };
41
+ const _reset = () => {
42
+ resetSelection({ resetPage: true });
33
43
  };
34
44
  const setSearchAndValue = (option) => {
35
- if (option === null) _reset();
45
+ if (option === null) resetSelection();
36
46
  else {
37
47
  handleSearch(getOptionLabel(option));
38
48
  handleValue(getOptionValue(option));
@@ -43,42 +53,85 @@ function InfinitySelect({ value, searchValue, defaultSearchValue, nothingFoundMe
43
53
  }, [_selectedOption]);
44
54
  const virtualizer = (0, _tanstack_react_virtual.useVirtualizer)({
45
55
  count: data.length,
46
- estimateSize: () => 40,
56
+ estimateSize: () => OPTION_HEIGHT,
57
+ getItemKey: (index) => getOptionValue(data[index]),
47
58
  overscan: 7,
48
59
  getScrollElement: () => scrollRef.current
49
60
  });
50
- const scrollRef = (0, react.useRef)(null);
61
+ const combobox = (0, _mantine_core.useVirtualizedCombobox)({
62
+ onDropdownOpen: () => {
63
+ if (activeOptionIndex >= 0 && activeOptionIndex < data.length) {
64
+ setSelectedOptionIndex(activeOptionIndex);
65
+ requestAnimationFrame(() => {
66
+ virtualizer.scrollToIndex(activeOptionIndex, { align: "auto" });
67
+ });
68
+ } else setSelectedOptionIndex(-1);
69
+ },
70
+ onDropdownClose: () => setSelectedOptionIndex(-1),
71
+ totalOptionsCount: data.length,
72
+ isOptionDisabled: (index) => index < 0 || index >= data.length,
73
+ getOptionId: (index) => {
74
+ return index >= 0 && index < data.length ? getOptionValue(data[index]) : null;
75
+ },
76
+ selectedOptionIndex,
77
+ activeOptionIndex,
78
+ setSelectedOptionIndex: (index) => {
79
+ setSelectedOptionIndex(index);
80
+ if (index !== -1) virtualizer.scrollToIndex(index, { align: "auto" });
81
+ },
82
+ onSelectedOptionSubmit: handleOptionSubmit
83
+ });
84
+ (0, react.useEffect)(() => {
85
+ setActiveOptionIndex(_value ? data.findIndex((option) => getOptionValue(option) === _value) : -1);
86
+ }, [
87
+ _value,
88
+ data,
89
+ getOptionValue
90
+ ]);
91
+ (0, react.useEffect)(() => {
92
+ setSelectedOptionIndex(-1);
93
+ scrollRef.current?.scrollTo({ top: 0 });
94
+ }, [_search]);
95
+ (0, react.useEffect)(() => {
96
+ if (selectedOptionIndex >= data.length) setSelectedOptionIndex(-1);
97
+ }, [selectedOptionIndex, data.length]);
98
+ function handleOptionSubmit(index) {
99
+ if (index < 0 || index >= data.length) return;
100
+ const selectedOption = data[index];
101
+ const selectedValue = getOptionValue(selectedOption);
102
+ setSearchAndValue(selectedOption);
103
+ handleSelectedOption(selectedOption);
104
+ setActiveOptionIndex(index);
105
+ onOptionSubmit?.(selectedValue, selectedOption);
106
+ combobox.closeDropdown();
107
+ combobox.resetSelectedOption();
108
+ }
51
109
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_mantine_core.Combobox, {
52
110
  store: combobox,
53
111
  middlewares: { shift: { crossAxis: true } },
54
- onOptionSubmit: (val) => {
55
- const selectedOption = data.find((i) => i && getOptionValue(i) === val);
56
- if (selectedOption) {
57
- setSearchAndValue(selectedOption);
58
- handleSelectedOption(selectedOption);
59
- onOptionSubmit?.(val, selectedOption);
60
- }
61
- combobox.closeDropdown();
62
- },
112
+ resetSelectionOnOptionHover: false,
113
+ keepMounted: true,
63
114
  ...comboboxProps,
64
115
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mantine_core.Combobox.Target, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mantine_core.InputBase, {
65
- rightSection: props.readOnly ? null : value ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mantine_core.Input.ClearButton, { onClick: _reset }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mantine_core.Combobox.Chevron, {}),
116
+ rightSection: readOnly ? null : _value ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mantine_core.Input.ClearButton, { onClick: _reset }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mantine_core.Combobox.Chevron, {}),
66
117
  component: "input",
67
- rightSectionPointerEvents: value ? void 0 : "none",
68
- readOnly: !searchable || props.readOnly,
118
+ rightSectionPointerEvents: _value ? void 0 : "none",
119
+ readOnly: isReadOnly,
69
120
  pointer: !searchable,
70
121
  value: searchable ? _search : _selectedOption ? getOptionLabel(_selectedOption) : "",
71
122
  onChange: searchable ? (event) => {
72
123
  if (event.currentTarget.value) combobox.openDropdown();
73
124
  else combobox.closeDropdown();
125
+ setSelectedOptionIndex(-1);
74
126
  handleSearch(event.currentTarget.value);
127
+ resetPageParam?.();
75
128
  } : void 0,
76
129
  onClick: (event) => {
77
- if (!props.readOnly) searchable ? combobox.openDropdown() : combobox.toggleDropdown();
130
+ if (!readOnly) searchable ? combobox.openDropdown() : combobox.toggleDropdown();
78
131
  props.onClick?.(event);
79
132
  },
80
133
  onFocus: (event) => {
81
- if (!props.readOnly && searchable) combobox.openDropdown();
134
+ if (!readOnly && searchable) combobox.openDropdown();
82
135
  props.onFocus?.(event);
83
136
  },
84
137
  onBlur: (event) => {
@@ -87,7 +140,7 @@ function InfinitySelect({ value, searchValue, defaultSearchValue, nothingFoundMe
87
140
  props.onBlur?.(event);
88
141
  },
89
142
  ...props,
90
- variant: props.readOnly ? "filled" : "default"
143
+ variant: readOnly ? "filled" : "default"
91
144
  }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mantine_core.Combobox.Dropdown, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mantine_core.Combobox.Options, {
92
145
  mih: 50,
93
146
  mah: 200,
@@ -98,10 +151,12 @@ function InfinitySelect({ value, searchValue, defaultSearchValue, nothingFoundMe
98
151
  children: virtualizer.getVirtualItems().map((virtualItem) => {
99
152
  const option = data[virtualItem.index];
100
153
  const virtualItemProps = require_virtual_styles.getVirtualItemProps(virtualItem, virtualizer);
101
- if (!option) return null;
102
154
  return /* @__PURE__ */ (0, react.createElement)(_mantine_core.Combobox.Option, {
103
155
  value: getOptionValue(option),
104
156
  ...virtualItemProps,
157
+ active: virtualItem.index === activeOptionIndex,
158
+ selected: virtualItem.index === selectedOptionIndex,
159
+ onClick: () => handleOptionSubmit(virtualItem.index),
105
160
  key: virtualItemProps.key,
106
161
  style: {
107
162
  ...virtualItemProps.style,
@@ -0,0 +1,35 @@
1
+ import { ComboboxProps, ComboboxStore, ElementProps, InputBaseProps } from '@mantine/core';
2
+ import { InfiniteData } from '@tanstack/react-query';
3
+ import { ReactNode } from 'react';
4
+ import { InfiniteQueryHookResult } from 'react-query-kit';
5
+ import { InfinityLoadMoreButtonProps } from '../InfinityLoadMoreButton';
6
+ export interface InfinitySelectProps<T = unknown> extends InputBaseProps, ElementProps<'input', keyof InputBaseProps | 'value' | 'onChange'> {
7
+ value?: string | null;
8
+ defaultValue?: string;
9
+ searchValue?: string;
10
+ defaultSearchValue?: string;
11
+ nothingFoundMessage?: ReactNode | ((data: {
12
+ combobox: ComboboxStore;
13
+ }) => ReactNode);
14
+ infinity: InfiniteQueryHookResult<InfiniteData<{
15
+ data?: T[];
16
+ }, number>, Error>;
17
+ defaultSelectedOption?: T | null;
18
+ selectedOption?: T | null;
19
+ onSelectedOptionChange?: (option: T | null) => void;
20
+ onSearchChange?: (value: string) => void;
21
+ onChange?: (value: string | null) => void;
22
+ renderOption?: (args: {
23
+ option: T;
24
+ }) => React.ReactNode;
25
+ onOptionSubmit?: (value: string, option: T) => void;
26
+ getOptionLabel: (option: T) => string;
27
+ getOptionValue: (option: T) => string;
28
+ resetPageParam?: () => Promise<void>;
29
+ comboboxProps?: ComboboxProps;
30
+ searchable?: boolean;
31
+ ref?: React.Ref<HTMLInputElement>;
32
+ loadMoreButtonProps?: Partial<InfinityLoadMoreButtonProps<T>>;
33
+ }
34
+ export declare function InfinitySelect<T = unknown>({ value, searchValue, defaultSearchValue, nothingFoundMessage, infinity, defaultValue, onChange, onSearchChange, renderOption, onOptionSubmit, getOptionLabel, getOptionValue, onSelectedOptionChange, selectedOption, comboboxProps, searchable, defaultSelectedOption, loadMoreButtonProps, resetPageParam, readOnly, ...props }: InfinitySelectProps<T>): import("react/jsx-runtime").JSX.Element;
35
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/InfinitySelect/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,YAAY,EAGjB,KAAK,cAAc,EAEpB,MAAM,eAAe,CAAA;AAEtB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAEzD,OAAO,EAAE,KAAK,SAAS,EAAwC,MAAM,OAAO,CAAA;AAC5E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAA;AAE9D,OAAO,EAA0B,KAAK,2BAA2B,EAAE,MAAM,2BAA2B,CAAA;AAIpG,MAAM,WAAW,mBAAmB,CAAC,CAAC,GAAG,OAAO,CAC9C,SAAQ,cAAc,EACpB,YAAY,CAAC,OAAO,EAAE,MAAM,cAAc,GAAG,OAAO,GAAG,UAAU,CAAC;IACpE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,mBAAmB,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC,IAAI,EAAE;QAAE,QAAQ,EAAE,aAAa,CAAA;KAAE,KAAK,SAAS,CAAC,CAAA;IACpF,QAAQ,EAAE,uBAAuB,CAAC,YAAY,CAAC;QAAE,IAAI,CAAC,EAAE,CAAC,EAAE,CAAA;KAAE,EAAE,MAAM,CAAC,EAAE,KAAK,CAAC,CAAA;IAC9E,qBAAqB,CAAC,EAAE,CAAC,GAAG,IAAI,CAAA;IAChC,cAAc,CAAC,EAAE,CAAC,GAAG,IAAI,CAAA;IACzB,sBAAsB,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,KAAK,IAAI,CAAA;IACnD,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACxC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;IACzC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,CAAC,CAAA;KAAE,KAAK,KAAK,CAAC,SAAS,CAAA;IACvD,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,KAAK,IAAI,CAAA;IACnD,cAAc,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,MAAM,CAAA;IACrC,cAAc,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,MAAM,CAAA;IACrC,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IACpC,aAAa,CAAC,EAAE,aAAa,CAAA;IAC7B,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAA;IACjC,mBAAmB,CAAC,EAAE,OAAO,CAAC,2BAA2B,CAAC,CAAC,CAAC,CAAC,CAAA;CAC9D;AAED,wBAAgB,cAAc,CAAC,CAAC,GAAG,OAAO,EAAE,EAC1C,KAAK,EACL,WAAW,EACX,kBAAkB,EAClB,mBAAmB,EACnB,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,cAAc,EACd,cAAc,EACd,cAAc,EACd,sBAAsB,EACtB,cAAc,EACd,aAAa,EACb,UAAiB,EACjB,qBAA4B,EAC5B,mBAAmB,EACnB,cAAc,EACd,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,mBAAmB,CAAC,CAAC,CAAC,2CA8OxB"}
@@ -1,14 +1,15 @@
1
1
  "use client";
2
2
  import { InfinityLoadMoreButton } from "../InfinityLoadMoreButton/index.js";
3
3
  import { getVirtualContainerProps, getVirtualItemProps } from "../../utils/virtual-styles.js";
4
- import { createElement, useEffect, useRef } from "react";
4
+ import { Center, Combobox, Input, InputBase, useVirtualizedCombobox } from "@mantine/core";
5
+ import { createElement, useEffect, useMemo, useRef, useState } from "react";
5
6
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
- import { Center, Combobox, Input, InputBase, useCombobox } from "@mantine/core";
7
7
  import { useUncontrolled } from "@mantine/hooks";
8
8
  import { useVirtualizer } from "@tanstack/react-virtual";
9
9
  //#region src/components/InfinitySelect/index.tsx
10
- function InfinitySelect({ value, searchValue, defaultSearchValue, nothingFoundMessage, infinity, defaultValue, onChange, onSearchChange, renderOption, onOptionSubmit, getOptionLabel, getOptionValue, onSelectedOptionChange, selectedOption, comboboxProps, searchable = true, defaultSelectedOption = null, loadMoreButtonProps, ...props }) {
11
- const combobox = useCombobox();
10
+ var OPTION_HEIGHT = 40;
11
+ function InfinitySelect({ value, searchValue, defaultSearchValue, nothingFoundMessage, infinity, defaultValue, onChange, onSearchChange, renderOption, onOptionSubmit, getOptionLabel, getOptionValue, onSelectedOptionChange, selectedOption, comboboxProps, searchable = true, defaultSelectedOption = null, loadMoreButtonProps, resetPageParam, readOnly, ...props }) {
12
+ const isReadOnly = !searchable || readOnly;
12
13
  const [_selectedOption, handleSelectedOption] = useUncontrolled({
13
14
  defaultValue: defaultSelectedOption,
14
15
  value: selectedOption,
@@ -24,14 +25,23 @@ function InfinitySelect({ value, searchValue, defaultSearchValue, nothingFoundMe
24
25
  value: searchValue,
25
26
  onChange: onSearchChange
26
27
  });
27
- const data = infinity.data?.pages.flatMap((page) => page.data) ?? [];
28
- const _reset = () => {
28
+ const data = useMemo(() => infinity.data?.pages.flatMap((page) => page.data ?? []) ?? [], [infinity.data]);
29
+ const scrollRef = useRef(null);
30
+ const [selectedOptionIndex, setSelectedOptionIndex] = useState(-1);
31
+ const [activeOptionIndex, setActiveOptionIndex] = useState(-1);
32
+ const resetSelection = (options) => {
29
33
  handleSearch("");
30
34
  handleValue(null);
31
35
  handleSelectedOption(null);
36
+ setActiveOptionIndex(-1);
37
+ setSelectedOptionIndex(-1);
38
+ if (options?.resetPage) resetPageParam?.();
39
+ };
40
+ const _reset = () => {
41
+ resetSelection({ resetPage: true });
32
42
  };
33
43
  const setSearchAndValue = (option) => {
34
- if (option === null) _reset();
44
+ if (option === null) resetSelection();
35
45
  else {
36
46
  handleSearch(getOptionLabel(option));
37
47
  handleValue(getOptionValue(option));
@@ -42,42 +52,85 @@ function InfinitySelect({ value, searchValue, defaultSearchValue, nothingFoundMe
42
52
  }, [_selectedOption]);
43
53
  const virtualizer = useVirtualizer({
44
54
  count: data.length,
45
- estimateSize: () => 40,
55
+ estimateSize: () => OPTION_HEIGHT,
56
+ getItemKey: (index) => getOptionValue(data[index]),
46
57
  overscan: 7,
47
58
  getScrollElement: () => scrollRef.current
48
59
  });
49
- const scrollRef = useRef(null);
60
+ const combobox = useVirtualizedCombobox({
61
+ onDropdownOpen: () => {
62
+ if (activeOptionIndex >= 0 && activeOptionIndex < data.length) {
63
+ setSelectedOptionIndex(activeOptionIndex);
64
+ requestAnimationFrame(() => {
65
+ virtualizer.scrollToIndex(activeOptionIndex, { align: "auto" });
66
+ });
67
+ } else setSelectedOptionIndex(-1);
68
+ },
69
+ onDropdownClose: () => setSelectedOptionIndex(-1),
70
+ totalOptionsCount: data.length,
71
+ isOptionDisabled: (index) => index < 0 || index >= data.length,
72
+ getOptionId: (index) => {
73
+ return index >= 0 && index < data.length ? getOptionValue(data[index]) : null;
74
+ },
75
+ selectedOptionIndex,
76
+ activeOptionIndex,
77
+ setSelectedOptionIndex: (index) => {
78
+ setSelectedOptionIndex(index);
79
+ if (index !== -1) virtualizer.scrollToIndex(index, { align: "auto" });
80
+ },
81
+ onSelectedOptionSubmit: handleOptionSubmit
82
+ });
83
+ useEffect(() => {
84
+ setActiveOptionIndex(_value ? data.findIndex((option) => getOptionValue(option) === _value) : -1);
85
+ }, [
86
+ _value,
87
+ data,
88
+ getOptionValue
89
+ ]);
90
+ useEffect(() => {
91
+ setSelectedOptionIndex(-1);
92
+ scrollRef.current?.scrollTo({ top: 0 });
93
+ }, [_search]);
94
+ useEffect(() => {
95
+ if (selectedOptionIndex >= data.length) setSelectedOptionIndex(-1);
96
+ }, [selectedOptionIndex, data.length]);
97
+ function handleOptionSubmit(index) {
98
+ if (index < 0 || index >= data.length) return;
99
+ const selectedOption = data[index];
100
+ const selectedValue = getOptionValue(selectedOption);
101
+ setSearchAndValue(selectedOption);
102
+ handleSelectedOption(selectedOption);
103
+ setActiveOptionIndex(index);
104
+ onOptionSubmit?.(selectedValue, selectedOption);
105
+ combobox.closeDropdown();
106
+ combobox.resetSelectedOption();
107
+ }
50
108
  return /* @__PURE__ */ jsxs(Combobox, {
51
109
  store: combobox,
52
110
  middlewares: { shift: { crossAxis: true } },
53
- onOptionSubmit: (val) => {
54
- const selectedOption = data.find((i) => i && getOptionValue(i) === val);
55
- if (selectedOption) {
56
- setSearchAndValue(selectedOption);
57
- handleSelectedOption(selectedOption);
58
- onOptionSubmit?.(val, selectedOption);
59
- }
60
- combobox.closeDropdown();
61
- },
111
+ resetSelectionOnOptionHover: false,
112
+ keepMounted: true,
62
113
  ...comboboxProps,
63
114
  children: [/* @__PURE__ */ jsx(Combobox.Target, { children: /* @__PURE__ */ jsx(InputBase, {
64
- rightSection: props.readOnly ? null : value ? /* @__PURE__ */ jsx(Input.ClearButton, { onClick: _reset }) : /* @__PURE__ */ jsx(Combobox.Chevron, {}),
115
+ rightSection: readOnly ? null : _value ? /* @__PURE__ */ jsx(Input.ClearButton, { onClick: _reset }) : /* @__PURE__ */ jsx(Combobox.Chevron, {}),
65
116
  component: "input",
66
- rightSectionPointerEvents: value ? void 0 : "none",
67
- readOnly: !searchable || props.readOnly,
117
+ rightSectionPointerEvents: _value ? void 0 : "none",
118
+ readOnly: isReadOnly,
68
119
  pointer: !searchable,
69
120
  value: searchable ? _search : _selectedOption ? getOptionLabel(_selectedOption) : "",
70
121
  onChange: searchable ? (event) => {
71
122
  if (event.currentTarget.value) combobox.openDropdown();
72
123
  else combobox.closeDropdown();
124
+ setSelectedOptionIndex(-1);
73
125
  handleSearch(event.currentTarget.value);
126
+ resetPageParam?.();
74
127
  } : void 0,
75
128
  onClick: (event) => {
76
- if (!props.readOnly) searchable ? combobox.openDropdown() : combobox.toggleDropdown();
129
+ if (!readOnly) searchable ? combobox.openDropdown() : combobox.toggleDropdown();
77
130
  props.onClick?.(event);
78
131
  },
79
132
  onFocus: (event) => {
80
- if (!props.readOnly && searchable) combobox.openDropdown();
133
+ if (!readOnly && searchable) combobox.openDropdown();
81
134
  props.onFocus?.(event);
82
135
  },
83
136
  onBlur: (event) => {
@@ -86,7 +139,7 @@ function InfinitySelect({ value, searchValue, defaultSearchValue, nothingFoundMe
86
139
  props.onBlur?.(event);
87
140
  },
88
141
  ...props,
89
- variant: props.readOnly ? "filled" : "default"
142
+ variant: readOnly ? "filled" : "default"
90
143
  }) }), /* @__PURE__ */ jsx(Combobox.Dropdown, { children: /* @__PURE__ */ jsx(Combobox.Options, {
91
144
  mih: 50,
92
145
  mah: 200,
@@ -97,10 +150,12 @@ function InfinitySelect({ value, searchValue, defaultSearchValue, nothingFoundMe
97
150
  children: virtualizer.getVirtualItems().map((virtualItem) => {
98
151
  const option = data[virtualItem.index];
99
152
  const virtualItemProps = getVirtualItemProps(virtualItem, virtualizer);
100
- if (!option) return null;
101
153
  return /* @__PURE__ */ createElement(Combobox.Option, {
102
154
  value: getOptionValue(option),
103
155
  ...virtualItemProps,
156
+ active: virtualItem.index === activeOptionIndex,
157
+ selected: virtualItem.index === selectedOptionIndex,
158
+ onClick: () => handleOptionSubmit(virtualItem.index),
104
159
  key: virtualItemProps.key,
105
160
  style: {
106
161
  ...virtualItemProps.style,
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../src/components/InfinitySelect/index.test.tsx"],"names":[],"mappings":""}
@@ -1,6 +1,6 @@
1
1
  require("../../_virtual/_rolldown/runtime.cjs");
2
- let react_jsx_runtime = require("react/jsx-runtime");
3
2
  let _mantine_core = require("@mantine/core");
3
+ let react_jsx_runtime = require("react/jsx-runtime");
4
4
  //#region src/components/MyCheckboxGroup/index.tsx
5
5
  var MyCheckboxGroup = ({ options, orientation = "horizontal", gap = "md", ...checkboxGroupProps }) => {
6
6
  const Container = orientation === "horizontal" ? _mantine_core.Group : _mantine_core.Stack;
@@ -0,0 +1,9 @@
1
+ import { CheckboxGroupProps, CheckboxProps, MantineSpacing } from '@mantine/core';
2
+ export interface MyCheckboxGroupProps extends Omit<CheckboxGroupProps, 'children'> {
3
+ options: CheckboxProps[];
4
+ orientation?: 'horizontal' | 'vertical';
5
+ gap?: MantineSpacing;
6
+ disabled?: boolean;
7
+ }
8
+ export declare const MyCheckboxGroup: ({ options, orientation, gap, ...checkboxGroupProps }: MyCheckboxGroupProps) => import("react/jsx-runtime").JSX.Element;
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/MyCheckboxGroup/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,kBAAkB,EAClB,aAAa,EAEb,cAAc,EAIf,MAAM,eAAe,CAAA;AAEtB,MAAM,WAAW,oBAAqB,SAAQ,IAAI,CAAC,kBAAkB,EAAE,UAAU,CAAC;IAChF,OAAO,EAAE,aAAa,EAAE,CAAA;IACxB,WAAW,CAAC,EAAE,YAAY,GAAG,UAAU,CAAA;IACvC,GAAG,CAAC,EAAE,cAAc,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,eAAO,MAAM,eAAe,GAAI,sDAK7B,oBAAoB,4CAWtB,CAAA"}