lkd-web-kit 0.5.18 → 0.6.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.
@@ -28,6 +28,11 @@ const InfinityLoader = ({
28
28
  const hasScroll = el?.scrollHeight > el?.clientHeight;
29
29
  if (!hasScroll) infinity.fetchNextPage();
30
30
  }, [entry?.isIntersecting, infinity.data?.pages.length]);
31
+ const showLoader = infinity.isLoading || infinity.isFetchingNextPage;
32
+ const showEndMessage = infinity.data && infinity.data.pages.length > 1 && !infinity.hasNextPage;
33
+ if (!showLoader && !showEndMessage) {
34
+ return null;
35
+ }
31
36
  return /* @__PURE__ */ jsxRuntime.jsx(
32
37
  core.Center,
33
38
  {
@@ -38,7 +43,7 @@ const InfinityLoader = ({
38
43
  fontSize: "14px",
39
44
  ...props.style
40
45
  },
41
- children: infinity.isLoading || infinity.isFetchingNextPage ? /* @__PURE__ */ jsxRuntime.jsx(core.Loader, { ...loaderProps }) : infinity.data && infinity.data.pages.length > 1 && !infinity.hasNextPage ? endMessage : null
46
+ children: showLoader ? /* @__PURE__ */ jsxRuntime.jsx(core.Loader, { ...loaderProps }) : showEndMessage ? endMessage : null
42
47
  }
43
48
  );
44
49
  };
@@ -24,6 +24,11 @@ const InfinityLoader = ({
24
24
  const hasScroll = el?.scrollHeight > el?.clientHeight;
25
25
  if (!hasScroll) infinity.fetchNextPage();
26
26
  }, [entry?.isIntersecting, infinity.data?.pages.length]);
27
+ const showLoader = infinity.isLoading || infinity.isFetchingNextPage;
28
+ const showEndMessage = infinity.data && infinity.data.pages.length > 1 && !infinity.hasNextPage;
29
+ if (!showLoader && !showEndMessage) {
30
+ return null;
31
+ }
27
32
  return /* @__PURE__ */ jsx(
28
33
  Center,
29
34
  {
@@ -34,7 +39,7 @@ const InfinityLoader = ({
34
39
  fontSize: "14px",
35
40
  ...props.style
36
41
  },
37
- children: infinity.isLoading || infinity.isFetchingNextPage ? /* @__PURE__ */ jsx(Loader, { ...loaderProps }) : infinity.data && infinity.data.pages.length > 1 && !infinity.hasNextPage ? endMessage : null
42
+ children: showLoader ? /* @__PURE__ */ jsx(Loader, { ...loaderProps }) : showEndMessage ? endMessage : null
38
43
  }
39
44
  );
40
45
  };
@@ -28,11 +28,12 @@ function InfinitySelect({
28
28
  selectedOption,
29
29
  comboboxProps,
30
30
  searchable = true,
31
+ defaultSelectedOption = null,
31
32
  ...props
32
33
  }) {
33
34
  const combobox = core.useCombobox();
34
35
  const [_selectedOption, handleSelectedOption] = hooks.useUncontrolled({
35
- defaultValue: null,
36
+ defaultValue: defaultSelectedOption,
36
37
  value: selectedOption,
37
38
  onChange: onSelectedOptionChange
38
39
  });
@@ -24,11 +24,12 @@ function InfinitySelect({
24
24
  selectedOption,
25
25
  comboboxProps,
26
26
  searchable = true,
27
+ defaultSelectedOption = null,
27
28
  ...props
28
29
  }) {
29
30
  const combobox = useCombobox();
30
31
  const [_selectedOption, handleSelectedOption] = useUncontrolled({
31
- defaultValue: null,
32
+ defaultValue: defaultSelectedOption,
32
33
  value: selectedOption,
33
34
  onChange: onSelectedOptionChange
34
35
  });
@@ -32,6 +32,10 @@ const withController = (WrappedComponent, getControllerProps) => {
32
32
  },
33
33
  field: {
34
34
  ...renderProps.field,
35
+ onChange: (...value) => {
36
+ renderProps.field.onChange(...value);
37
+ props.onValueChange?.(...value);
38
+ },
35
39
  label,
36
40
  placeholder,
37
41
  description,
@@ -28,6 +28,10 @@ const withController = (WrappedComponent, getControllerProps) => {
28
28
  },
29
29
  field: {
30
30
  ...renderProps.field,
31
+ onChange: (...value) => {
32
+ renderProps.field.onChange(...value);
33
+ props.onValueChange?.(...value);
34
+ },
31
35
  label,
32
36
  placeholder,
33
37
  description,
package/dist/index.d.ts CHANGED
@@ -2,7 +2,9 @@ import { BeforeErrorHook } from 'ky';
2
2
  import { BoxProps } from '@mantine/core';
3
3
  import { ButtonProps } from '@mantine/core';
4
4
  import { CenterProps } from '@mantine/core';
5
+ import { ChangeEventHandler } from 'react';
5
6
  import { CheckboxProps } from '@mantine/core';
7
+ import { ComboboxItem } from '@mantine/core';
6
8
  import { ComboboxProps } from '@mantine/core';
7
9
  import { ComboboxStore } from '@mantine/core';
8
10
  import { ComponentProps } from 'react';
@@ -10,6 +12,8 @@ import { ComponentPropsWithoutRef } from 'react';
10
12
  import { ControllerProps } from 'react-hook-form';
11
13
  import { DateInputProps } from '@mantine/dates';
12
14
  import { DatePickerInputProps } from '@mantine/dates';
15
+ import { DatesRangeValue } from '@mantine/dates';
16
+ import { DateStringValue } from '@mantine/dates';
13
17
  import { DateTimePickerProps } from '@mantine/dates';
14
18
  import { default as default_2 } from 'react';
15
19
  import { DefaultMantineColor } from '@mantine/core';
@@ -115,19 +119,27 @@ export declare interface FormButtonSubmitProps extends ButtonProps, ElementProps
115
119
  disabledWhenSuccess?: boolean;
116
120
  }
117
121
 
118
- export declare const FormCheckbox: FC<CheckboxProps & WithControllerProps>;
122
+ export declare const FormCheckbox: FC<CheckboxProps & WithControllerProps & {
123
+ onValueChange?: ChangeEventHandler<HTMLInputElement> | undefined;
124
+ }>;
119
125
 
120
126
  export declare type FormCheckboxProps = CheckboxProps & WithControllerProps;
121
127
 
122
- export declare const FormDateInput: FC<WithControllerProps & MyDateInputProps>;
128
+ export declare const FormDateInput: FC<WithControllerProps & MyDateInputProps & {
129
+ onValueChange?: ((value: DateStringValue | null) => void) | undefined;
130
+ }>;
123
131
 
124
132
  export declare type FormDateInputProps = WithControllerProps & MyDateInputProps;
125
133
 
126
- export declare const FormDatePickerInput: FC<WithControllerProps & MyDatePickerInputProps>;
134
+ export declare const FormDatePickerInput: FC<WithControllerProps & MyDatePickerInputProps & {
135
+ onValueChange?: ((value: string | string[] | DatesRangeValue<string> | null) => void) | undefined;
136
+ }>;
127
137
 
128
138
  export declare type FormDatePickerInputProps = WithControllerProps & MyDatePickerInputProps;
129
139
 
130
- export declare const FormDateTimePicker: FC<DateTimePickerProps & WithControllerProps>;
140
+ export declare const FormDateTimePicker: FC<DateTimePickerProps & WithControllerProps & {
141
+ onValueChange?: ((value: DateStringValue | null) => void) | undefined;
142
+ }>;
131
143
 
132
144
  export declare type FormDateTimePickerProps = WithControllerProps & MyDateTimePickerProps;
133
145
 
@@ -145,15 +157,21 @@ export declare const FormInfinitySelect: <T>(props: FormInfinitySelectProps<T>)
145
157
 
146
158
  export declare type FormInfinitySelectProps<T = unknown> = InfinitySelectProps<T> & WithControllerProps;
147
159
 
148
- export declare const FormMonthPickerInput: FC<MyMonthPickerInputProps & WithControllerProps>;
160
+ export declare const FormMonthPickerInput: FC<MyMonthPickerInputProps & WithControllerProps & {
161
+ onValueChange?: ((value: string | string[] | DatesRangeValue<string> | null) => void) | undefined;
162
+ }>;
149
163
 
150
164
  export declare type FormMonthPickerInputProps = WithControllerProps & MyMonthPickerInputProps;
151
165
 
152
- export declare const FormMultiSelect: FC<MyMultiSelectProps & WithControllerProps>;
166
+ export declare const FormMultiSelect: FC<MyMultiSelectProps & WithControllerProps & {
167
+ onValueChange?: ((value: string[]) => void) | undefined;
168
+ }>;
153
169
 
154
170
  export declare type FormMultiSelectProps = MyMultiSelectProps & WithControllerProps;
155
171
 
156
- export declare const FormNumberInput: FC<MyNumberInputProps & WithControllerProps>;
172
+ export declare const FormNumberInput: FC<MyNumberInputProps & WithControllerProps & {
173
+ onValueChange?: ((value: number | string) => void) | undefined;
174
+ }>;
157
175
 
158
176
  export declare type FormNumberInputProps = MyNumberInputProps & WithControllerProps;
159
177
 
@@ -163,25 +181,35 @@ declare interface FormProps<T extends FieldValues, TContext = any, TT extends T
163
181
  onSubmitError?: SubmitErrorHandler<T>;
164
182
  }
165
183
 
166
- export declare const FormRadioGroup: FC<MyRadioGroupProps & WithControllerProps>;
184
+ export declare const FormRadioGroup: FC<MyRadioGroupProps & WithControllerProps & {
185
+ onValueChange?: ((value: string) => void) | undefined;
186
+ }>;
167
187
 
168
188
  export declare type FormRadioGroupProps = MyRadioGroupProps & WithControllerProps;
169
189
 
170
- export declare const FormSelect: FC<MySelectProps & WithControllerProps>;
190
+ export declare const FormSelect: FC<MySelectProps & WithControllerProps & {
191
+ onValueChange?: ((value: string | null, option: ComboboxItem) => void) | undefined;
192
+ }>;
171
193
 
172
194
  export declare type FormSelectProps = MySelectProps & WithControllerProps;
173
195
 
174
- export declare const FormTextarea: FC<TextareaProps & WithControllerProps>;
196
+ export declare const FormTextarea: FC<TextareaProps & WithControllerProps & {
197
+ onValueChange?: ChangeEventHandler<HTMLTextAreaElement> | undefined;
198
+ }>;
175
199
 
176
200
  export declare type FormTextareaProps = MyTextareaProps & WithControllerProps;
177
201
 
178
- export declare const FormTextInput: FC<WithControllerProps & MyTextInputProps>;
202
+ export declare const FormTextInput: FC<WithControllerProps & MyTextInputProps & {
203
+ onValueChange?: ChangeEventHandler<HTMLInputElement> | undefined;
204
+ }>;
179
205
 
180
206
  export declare type FormTextInputProps = WithControllerProps & MyTextInputProps;
181
207
 
182
208
  export declare type FormTimeInput = MyTimeInputProps & WithControllerProps;
183
209
 
184
- export declare const FormTimeInput: FC<TimeInputProps & WithControllerProps>;
210
+ export declare const FormTimeInput: FC<TimeInputProps & WithControllerProps & {
211
+ onValueChange?: ChangeEventHandler<HTMLInputElement> | undefined;
212
+ }>;
185
213
 
186
214
  export declare const getVirtualContainerProps: (virtualizer: {
187
215
  getTotalSize: () => number;
@@ -287,7 +315,7 @@ export declare function indexBy<T, K, C extends string>(arr: T[], getKey: (item:
287
315
 
288
316
  export declare type IndexByResult<T> = Record<string, T | undefined>;
289
317
 
290
- export declare const InfinityLoader: ({ root, infinity, rootMargin, endMessage, loaderProps, ...props }: InfinityLoaderProps) => JSX.Element;
318
+ export declare const InfinityLoader: ({ root, infinity, rootMargin, endMessage, loaderProps, ...props }: InfinityLoaderProps) => JSX.Element | null;
291
319
 
292
320
  export declare interface InfinityLoaderProps extends CenterProps {
293
321
  infinity: InfiniteQueryHookResult<InfiniteData<{
@@ -299,7 +327,7 @@ export declare interface InfinityLoaderProps extends CenterProps {
299
327
  loaderProps?: LoaderProps;
300
328
  }
301
329
 
302
- export declare function InfinitySelect<T = unknown>({ value, searchValue, defaultSearchValue, nothingFoundMessage, infinity, defaultValue, onChange, onSearchChange, renderOption, onOptionSubmit, getOptionLabel, getOptionValue, onSelectedOptionChange, selectedOption, comboboxProps, searchable, ...props }: InfinitySelectProps<T>): JSX.Element;
330
+ export declare function InfinitySelect<T = unknown>({ value, searchValue, defaultSearchValue, nothingFoundMessage, infinity, defaultValue, onChange, onSearchChange, renderOption, onOptionSubmit, getOptionLabel, getOptionValue, onSelectedOptionChange, selectedOption, comboboxProps, searchable, defaultSelectedOption, ...props }: InfinitySelectProps<T>): JSX.Element;
303
331
 
304
332
  export declare interface InfinitySelectProps<T = unknown> extends InputBaseProps, ElementProps<'input', keyof InputBaseProps | 'value' | 'onChange'> {
305
333
  value?: string | null;
@@ -312,6 +340,7 @@ export declare interface InfinitySelectProps<T = unknown> extends InputBaseProps
312
340
  infinity: InfiniteQueryHookResult<InfiniteData<{
313
341
  data: T[];
314
342
  }, number>, Error>;
343
+ defaultSelectedOption?: T | null;
315
344
  selectedOption?: T | null;
316
345
  onSelectedOptionChange?: (option: T | null) => void;
317
346
  onSearchChange?: (value: string) => void;
@@ -576,7 +605,11 @@ export declare const useUpdateSearchParams: () => {
576
605
 
577
606
  export declare const useZodConfig: () => void;
578
607
 
579
- export declare const withController: <P extends unknown>(WrappedComponent: React.ComponentType<FormFieldProps<P>>, getControllerProps?: (fieldProps: P) => Omit<Partial<ControllerProps>, "render">) => FC<P & WithControllerProps>;
608
+ export declare const withController: <P extends {
609
+ onChange?: any;
610
+ }>(WrappedComponent: React.ComponentType<FormFieldProps<P>>, getControllerProps?: (fieldProps: P) => Omit<Partial<ControllerProps>, "render">) => FC<P & WithControllerProps & {
611
+ onValueChange?: P["onChange"];
612
+ }>;
580
613
 
581
614
  export declare interface WithControllerProps {
582
615
  name?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lkd-web-kit",
3
- "version": "0.5.18",
3
+ "version": "0.6.1",
4
4
  "description": "A template for creating React component libraries with Vite.",
5
5
  "author": "LKD",
6
6
  "license": "MIT",
@@ -28,27 +28,27 @@
28
28
  "prepublishOnly": "npm run build"
29
29
  },
30
30
  "devDependencies": {
31
- "@testing-library/jest-dom": "^6.6.3",
31
+ "@testing-library/jest-dom": "^6.8.0",
32
32
  "@testing-library/react": "^16.3.0",
33
33
  "@testing-library/user-event": "^14.6.1",
34
- "@types/node": "^22.15.33",
35
- "@types/react": "^19.1.8",
36
- "@types/react-dom": "^19.1.6",
37
- "@typescript-eslint/eslint-plugin": "^8.35.0",
38
- "@typescript-eslint/parser": "^8.35.0",
39
- "@vitejs/plugin-react-swc": "^3.10.2",
34
+ "@types/node": "^22.17.2",
35
+ "@types/react": "^19.1.10",
36
+ "@types/react-dom": "^19.1.7",
37
+ "@typescript-eslint/eslint-plugin": "^8.40.0",
38
+ "@typescript-eslint/parser": "^8.40.0",
39
+ "@vitejs/plugin-react-swc": "^3.11.0",
40
40
  "@vitest/coverage-v8": "^3.2.4",
41
- "eslint": "^9.29.0",
42
- "eslint-config-prettier": "^10.1.5",
41
+ "eslint": "^9.33.0",
42
+ "eslint-config-prettier": "^10.1.8",
43
43
  "eslint-plugin-jest-dom": "^5.5.0",
44
44
  "eslint-plugin-react": "^7.37.5",
45
45
  "eslint-plugin-react-hooks": "^5.2.0",
46
46
  "eslint-plugin-react-refresh": "^0.4.20",
47
47
  "jsdom": "^26.1.0",
48
- "prettier": "^3.6.1",
48
+ "prettier": "^3.6.2",
49
49
  "rollup-preserve-directives": "^1.1.3",
50
- "typescript": "^5.8.3",
51
- "vite": "^7.0.0",
50
+ "typescript": "^5.9.2",
51
+ "vite": "^7.1.3",
52
52
  "vite-plugin-dts": "^4.5.4",
53
53
  "vitest": "^3.2.4"
54
54
  },