react-simplikit 0.0.36 → 0.0.38

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.
@@ -270,20 +270,21 @@ function mergeRefs(...refs) {
270
270
 
271
271
  // src/components/ImpressionArea/ImpressionArea.tsx
272
272
  var import_jsx_runtime = require("react/jsx-runtime");
273
- var ImpressionArea = (0, import_react7.forwardRef)(
274
- ({ as, rootMargin, areaThreshold, timeThreshold, onImpressionStart, onImpressionEnd, ...props }, ref) => {
275
- const Component = as ?? "div";
276
- const impressionRef = useImpressionRef({
277
- onImpressionStart,
278
- onImpressionEnd,
279
- areaThreshold,
280
- timeThreshold,
281
- rootMargin
282
- });
283
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { ref: mergeRefs(ref, impressionRef), ...props });
284
- }
285
- );
286
- ImpressionArea.displayName = "ImpressionArea";
273
+ var ImpressionArea = (0, import_react7.forwardRef)(ImpressionAreaImpl);
274
+ function ImpressionAreaImpl({ as, rootMargin, areaThreshold, timeThreshold, onImpressionStart, onImpressionEnd, ...props }, ref) {
275
+ const Component = as ?? "div";
276
+ const impressionRef = useImpressionRef({
277
+ onImpressionStart,
278
+ onImpressionEnd,
279
+ areaThreshold,
280
+ timeThreshold,
281
+ rootMargin
282
+ });
283
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { ref: mergeRefs(ref, impressionRef), ...props });
284
+ }
285
+ Object.assign(ImpressionArea, {
286
+ displayName: "ImpressionArea"
287
+ });
287
288
  // Annotate the CommonJS export names for ESM import in node:
288
289
  0 && (module.exports = {
289
290
  ImpressionArea
@@ -1,10 +1,9 @@
1
- import * as react from 'react';
2
- import { ElementType, Ref, ReactNode } from 'react';
1
+ import { ElementType, ReactNode, Ref } from 'react';
3
2
  import { UseImpressionRefOptions } from '../../hooks/useImpressionRef/index.cjs';
4
3
 
4
+ type Element<T extends ElementType, InstrinsicElements = T extends keyof React.JSX.IntrinsicElements ? React.JSX.IntrinsicElements[T] : HTMLElement> = InstrinsicElements extends React.ClassAttributes<infer E extends HTMLElement> ? E : HTMLElement;
5
5
  type Props<Tag extends ElementType> = React.ComponentPropsWithoutRef<Tag> & UseImpressionRefOptions & {
6
6
  as?: Tag;
7
- ref?: Ref<HTMLElement>;
8
7
  children?: ReactNode;
9
8
  className?: string;
10
9
  };
@@ -14,13 +13,14 @@ type Props<Tag extends ElementType> = React.ComponentPropsWithoutRef<Tag> & UseI
14
13
  * and executes callbacks when the element enters or exits the viewport. This component uses the `useImpressionRef`
15
14
  * hook to track the element's visibility.
16
15
  *
17
- * @param {ElementType} [as='div'] - The HTML tag to render. Defaults to `div`.
16
+ * @template {ElementType} T - The HTML tag to render. Defaults to `div`.
17
+ * @param {T} [as='div'] - The HTML tag to render. Defaults to `div`.
18
18
  * @param {string} [rootMargin] - Margin to adjust the detection area.
19
19
  * @param {number} [areaThreshold] - Minimum ratio of the element that must be visible (0 to 1).
20
20
  * @param {number} [timeThreshold] - Minimum time the element must be visible (in milliseconds).
21
21
  * @param {() => void} [onImpressionStart] - Callback function executed when the element enters the view.
22
22
  * @param {() => void} [onImpressionEnd] - Callback function executed when the element exits the view.
23
- * @param {Ref<HTMLElement>} [ref] - Reference to the element.
23
+ * @param {Ref<Element<T>>} [ref] - Reference to the element.
24
24
  * @param {React.ReactNode} [children] - Child elements to be rendered inside the component.
25
25
  * @param {string} [className] - Additional class names for styling.
26
26
  *
@@ -40,6 +40,8 @@ type Props<Tag extends ElementType> = React.ComponentPropsWithoutRef<Tag> & UseI
40
40
  * );
41
41
  * }
42
42
  */
43
- declare const ImpressionArea: react.ForwardRefExoticComponent<Omit<Props<ElementType>, "ref"> & react.RefAttributes<Element>>;
43
+ declare const ImpressionArea: <T extends ElementType = "div">(props: Props<T> & {
44
+ ref?: Ref<Element<T>>;
45
+ }) => React.ReactNode;
44
46
 
45
47
  export { ImpressionArea };
@@ -8,18 +8,16 @@ import { ChangeEventHandler } from 'react';
8
8
  * @param {(value: string) => string} [transformValue=(v: string) => v] - A function to transform the input value.
9
9
  * Defaults to an identity function that returns the input unchanged.
10
10
  *
11
- * @returns {[value: string, onChange: (value: string) => void]} A tuple containing:
11
+ * @returns {[value: string, onChange: ChangeEventHandler<HTMLInputElement>]} A tuple containing:
12
12
  * - value `string` - The current state value;
13
- * - onChange `(value: string) => void` - A function to update the state;
13
+ * - onChange `ChangeEventHandler<HTMLInputElement>` - A function to update the state;
14
14
  *
15
15
  * @example
16
16
  * function Example() {
17
- * const [value, setValue] = useInputState('');
18
- * return <input type="text" value={value} onChange={setValue} />;
17
+ * const [value, onChange] = useInputState('');
18
+ * return <input type="text" value={value} onChange={onChange} />;
19
19
  * }
20
20
  */
21
- declare function useInputState(initialValue?: string, transformValue?: (value: string) => string): readonly [string, ChangeEventHandler<HTMLElement & {
22
- value: string;
23
- }>];
21
+ declare function useInputState(initialValue?: string, transformValue?: (value: string) => string): readonly [string, ChangeEventHandler<HTMLInputElement>];
24
22
 
25
23
  export { useInputState };
package/dist/index.cjs CHANGED
@@ -302,20 +302,21 @@ function mergeRefs(...refs) {
302
302
 
303
303
  // src/components/ImpressionArea/ImpressionArea.tsx
304
304
  var import_jsx_runtime = require("react/jsx-runtime");
305
- var ImpressionArea = (0, import_react7.forwardRef)(
306
- ({ as, rootMargin, areaThreshold, timeThreshold, onImpressionStart, onImpressionEnd, ...props }, ref) => {
307
- const Component = as ?? "div";
308
- const impressionRef = useImpressionRef({
309
- onImpressionStart,
310
- onImpressionEnd,
311
- areaThreshold,
312
- timeThreshold,
313
- rootMargin
314
- });
315
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { ref: mergeRefs(ref, impressionRef), ...props });
316
- }
317
- );
318
- ImpressionArea.displayName = "ImpressionArea";
305
+ var ImpressionArea = (0, import_react7.forwardRef)(ImpressionAreaImpl);
306
+ function ImpressionAreaImpl({ as, rootMargin, areaThreshold, timeThreshold, onImpressionStart, onImpressionEnd, ...props }, ref) {
307
+ const Component = as ?? "div";
308
+ const impressionRef = useImpressionRef({
309
+ onImpressionStart,
310
+ onImpressionEnd,
311
+ areaThreshold,
312
+ timeThreshold,
313
+ rootMargin
314
+ });
315
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { ref: mergeRefs(ref, impressionRef), ...props });
316
+ }
317
+ Object.assign(ImpressionArea, {
318
+ displayName: "ImpressionArea"
319
+ });
319
320
 
320
321
  // src/components/Separated/Separated.tsx
321
322
  var import_react8 = require("react");
@@ -1,10 +1,9 @@
1
- import * as react from 'react';
2
- import { ElementType, Ref, ReactNode } from 'react';
1
+ import { ElementType, ReactNode, Ref } from 'react';
3
2
  import { UseImpressionRefOptions } from '../../hooks/useImpressionRef/index.js';
4
3
 
4
+ type Element<T extends ElementType, InstrinsicElements = T extends keyof React.JSX.IntrinsicElements ? React.JSX.IntrinsicElements[T] : HTMLElement> = InstrinsicElements extends React.ClassAttributes<infer E extends HTMLElement> ? E : HTMLElement;
5
5
  type Props<Tag extends ElementType> = React.ComponentPropsWithoutRef<Tag> & UseImpressionRefOptions & {
6
6
  as?: Tag;
7
- ref?: Ref<HTMLElement>;
8
7
  children?: ReactNode;
9
8
  className?: string;
10
9
  };
@@ -14,13 +13,14 @@ type Props<Tag extends ElementType> = React.ComponentPropsWithoutRef<Tag> & UseI
14
13
  * and executes callbacks when the element enters or exits the viewport. This component uses the `useImpressionRef`
15
14
  * hook to track the element's visibility.
16
15
  *
17
- * @param {ElementType} [as='div'] - The HTML tag to render. Defaults to `div`.
16
+ * @template {ElementType} T - The HTML tag to render. Defaults to `div`.
17
+ * @param {T} [as='div'] - The HTML tag to render. Defaults to `div`.
18
18
  * @param {string} [rootMargin] - Margin to adjust the detection area.
19
19
  * @param {number} [areaThreshold] - Minimum ratio of the element that must be visible (0 to 1).
20
20
  * @param {number} [timeThreshold] - Minimum time the element must be visible (in milliseconds).
21
21
  * @param {() => void} [onImpressionStart] - Callback function executed when the element enters the view.
22
22
  * @param {() => void} [onImpressionEnd] - Callback function executed when the element exits the view.
23
- * @param {Ref<HTMLElement>} [ref] - Reference to the element.
23
+ * @param {Ref<Element<T>>} [ref] - Reference to the element.
24
24
  * @param {React.ReactNode} [children] - Child elements to be rendered inside the component.
25
25
  * @param {string} [className] - Additional class names for styling.
26
26
  *
@@ -40,6 +40,8 @@ type Props<Tag extends ElementType> = React.ComponentPropsWithoutRef<Tag> & UseI
40
40
  * );
41
41
  * }
42
42
  */
43
- declare const ImpressionArea: react.ForwardRefExoticComponent<Omit<Props<ElementType>, "ref"> & react.RefAttributes<Element>>;
43
+ declare const ImpressionArea: <T extends ElementType = "div">(props: Props<T> & {
44
+ ref?: Ref<Element<T>>;
45
+ }) => React.ReactNode;
44
46
 
45
47
  export { ImpressionArea };
@@ -244,20 +244,21 @@ function mergeRefs(...refs) {
244
244
 
245
245
  // src/components/ImpressionArea/ImpressionArea.tsx
246
246
  import { jsx } from "react/jsx-runtime";
247
- var ImpressionArea = forwardRef(
248
- ({ as, rootMargin, areaThreshold, timeThreshold, onImpressionStart, onImpressionEnd, ...props }, ref) => {
249
- const Component = as ?? "div";
250
- const impressionRef = useImpressionRef({
251
- onImpressionStart,
252
- onImpressionEnd,
253
- areaThreshold,
254
- timeThreshold,
255
- rootMargin
256
- });
257
- return /* @__PURE__ */ jsx(Component, { ref: mergeRefs(ref, impressionRef), ...props });
258
- }
259
- );
260
- ImpressionArea.displayName = "ImpressionArea";
247
+ var ImpressionArea = forwardRef(ImpressionAreaImpl);
248
+ function ImpressionAreaImpl({ as, rootMargin, areaThreshold, timeThreshold, onImpressionStart, onImpressionEnd, ...props }, ref) {
249
+ const Component = as ?? "div";
250
+ const impressionRef = useImpressionRef({
251
+ onImpressionStart,
252
+ onImpressionEnd,
253
+ areaThreshold,
254
+ timeThreshold,
255
+ rootMargin
256
+ });
257
+ return /* @__PURE__ */ jsx(Component, { ref: mergeRefs(ref, impressionRef), ...props });
258
+ }
259
+ Object.assign(ImpressionArea, {
260
+ displayName: "ImpressionArea"
261
+ });
261
262
  export {
262
263
  ImpressionArea
263
264
  };
@@ -8,18 +8,16 @@ import { ChangeEventHandler } from 'react';
8
8
  * @param {(value: string) => string} [transformValue=(v: string) => v] - A function to transform the input value.
9
9
  * Defaults to an identity function that returns the input unchanged.
10
10
  *
11
- * @returns {[value: string, onChange: (value: string) => void]} A tuple containing:
11
+ * @returns {[value: string, onChange: ChangeEventHandler<HTMLInputElement>]} A tuple containing:
12
12
  * - value `string` - The current state value;
13
- * - onChange `(value: string) => void` - A function to update the state;
13
+ * - onChange `ChangeEventHandler<HTMLInputElement>` - A function to update the state;
14
14
  *
15
15
  * @example
16
16
  * function Example() {
17
- * const [value, setValue] = useInputState('');
18
- * return <input type="text" value={value} onChange={setValue} />;
17
+ * const [value, onChange] = useInputState('');
18
+ * return <input type="text" value={value} onChange={onChange} />;
19
19
  * }
20
20
  */
21
- declare function useInputState(initialValue?: string, transformValue?: (value: string) => string): readonly [string, ChangeEventHandler<HTMLElement & {
22
- value: string;
23
- }>];
21
+ declare function useInputState(initialValue?: string, transformValue?: (value: string) => string): readonly [string, ChangeEventHandler<HTMLInputElement>];
24
22
 
25
23
  export { useInputState };
package/esm/index.js CHANGED
@@ -244,20 +244,21 @@ function mergeRefs(...refs) {
244
244
 
245
245
  // src/components/ImpressionArea/ImpressionArea.tsx
246
246
  import { jsx } from "react/jsx-runtime";
247
- var ImpressionArea = forwardRef(
248
- ({ as, rootMargin, areaThreshold, timeThreshold, onImpressionStart, onImpressionEnd, ...props }, ref) => {
249
- const Component = as ?? "div";
250
- const impressionRef = useImpressionRef({
251
- onImpressionStart,
252
- onImpressionEnd,
253
- areaThreshold,
254
- timeThreshold,
255
- rootMargin
256
- });
257
- return /* @__PURE__ */ jsx(Component, { ref: mergeRefs(ref, impressionRef), ...props });
258
- }
259
- );
260
- ImpressionArea.displayName = "ImpressionArea";
247
+ var ImpressionArea = forwardRef(ImpressionAreaImpl);
248
+ function ImpressionAreaImpl({ as, rootMargin, areaThreshold, timeThreshold, onImpressionStart, onImpressionEnd, ...props }, ref) {
249
+ const Component = as ?? "div";
250
+ const impressionRef = useImpressionRef({
251
+ onImpressionStart,
252
+ onImpressionEnd,
253
+ areaThreshold,
254
+ timeThreshold,
255
+ rootMargin
256
+ });
257
+ return /* @__PURE__ */ jsx(Component, { ref: mergeRefs(ref, impressionRef), ...props });
258
+ }
259
+ Object.assign(ImpressionArea, {
260
+ displayName: "ImpressionArea"
261
+ });
261
262
 
262
263
  // src/components/Separated/Separated.tsx
263
264
  import { Children, Fragment, isValidElement } from "react";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-simplikit",
3
- "version": "0.0.36",
3
+ "version": "0.0.38",
4
4
  "main": "./dist/index.cjs",
5
5
  "type": "module",
6
6
  "sideEffects": false,