etudes 32.3.0 → 32.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/etudes.js +399 -385
- package/build/etudes.umd.cjs +1 -1
- package/build/hooks/useImageLoader.d.ts +9 -19
- package/build/hooks/useImageSize.d.ts +10 -7
- package/build/hooks/useRightClick.d.ts +24 -0
- package/build/index.d.ts +1 -0
- package/package.json +12 -12
|
@@ -1,20 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Type describing the parameters of {@link useImageLoader}.
|
|
3
|
-
*/
|
|
4
|
-
export type UseImageLoaderParams = {
|
|
5
|
-
/**
|
|
6
|
-
* `src` attribute of the image.
|
|
7
|
-
*/
|
|
8
|
-
src: string;
|
|
9
|
-
/**
|
|
10
|
-
* `srcSet` attribute of the image.
|
|
11
|
-
*/
|
|
12
|
-
srcSet?: string;
|
|
13
|
-
/**
|
|
14
|
-
* `sizes` attribute of the image.
|
|
15
|
-
*/
|
|
16
|
-
sizes?: string;
|
|
17
|
-
};
|
|
1
|
+
import { ImageSource } from '../types/ImageSource.js';
|
|
18
2
|
/**
|
|
19
3
|
* Type describing the options of {@link useImageLoader}.
|
|
20
4
|
*/
|
|
@@ -41,7 +25,13 @@ export type UseImageLoaderOptions = {
|
|
|
41
25
|
/**
|
|
42
26
|
* Hook for preloading an image.
|
|
43
27
|
*
|
|
44
|
-
* @param
|
|
28
|
+
* @param source Either a string URL or a tuple of the form `[src,
|
|
29
|
+
* ImageSource]`, where `src` is a fallback image URL and
|
|
30
|
+
* `ImageSource` provides additional information for responsive
|
|
31
|
+
* images. If a tuple is provided, the `src` will be used as the
|
|
32
|
+
* `src` attribute of the `<img>` element, while the properties of
|
|
33
|
+
* `ImageSource` will be used to set the `sizes` and `srcSet`
|
|
34
|
+
* attributes.
|
|
45
35
|
* @param options See {@link UseImageLoaderOptions}.
|
|
46
36
|
*/
|
|
47
|
-
export declare function useImageLoader(
|
|
37
|
+
export declare function useImageLoader(source: [string, Omit<ImageSource, 'media' | 'type'>] | string, { onError, onLoad, onLoadStart }?: UseImageLoaderOptions): void;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { Size } from 'spase';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
* Type describing the parameters of {@link useImageSize}.
|
|
5
|
-
*/
|
|
6
|
-
export type UseImageSizeParams = UseImageLoaderParams;
|
|
2
|
+
import { ImageSource } from '../types/ImageSource.js';
|
|
3
|
+
import { UseImageLoaderOptions } from './useImageLoader.js';
|
|
7
4
|
/**
|
|
8
5
|
* Type describing the options of {@link useImageSize}.
|
|
9
6
|
*/
|
|
@@ -17,10 +14,16 @@ export type UseImageSizeOptions = {
|
|
|
17
14
|
/**
|
|
18
15
|
* Hook for retrieving the size of an image.
|
|
19
16
|
*
|
|
20
|
-
* @param
|
|
17
|
+
* @param source Either a string URL or a tuple of the form `[src,
|
|
18
|
+
* ImageSource]`, where `src` is a fallback image URL and
|
|
19
|
+
* `ImageSource` provides additional information for responsive
|
|
20
|
+
* images. If a tuple is provided, the `src` will be used as the
|
|
21
|
+
* `src` attribute of the `<img>` element, while the properties of
|
|
22
|
+
* `ImageSource` will be used to set the `sizes` and `srcSet`
|
|
23
|
+
* attributes.
|
|
21
24
|
* @param options See {@link UseImageSizeOptions}.
|
|
22
25
|
*
|
|
23
26
|
* @returns The actual size of the image if loading was successful, `undefined`
|
|
24
27
|
* otherwise.
|
|
25
28
|
*/
|
|
26
|
-
export declare function useImageSize(
|
|
29
|
+
export declare function useImageSize(source: [string, Omit<ImageSource, 'media' | 'type'>] | string, { preservesSizeBetweenLoads, onError, onLoad, onLoadStart, }?: UseImageSizeOptions): Size.Size | undefined;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
type Target = HTMLElement | null | RefObject<HTMLElement> | RefObject<HTMLElement | null> | RefObject<HTMLElement | undefined> | undefined;
|
|
3
|
+
type Options = {
|
|
4
|
+
isEnabled?: boolean;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Hook for overriding the browser-default right click context menu action on
|
|
8
|
+
* the window.
|
|
9
|
+
*
|
|
10
|
+
* @param action The function to invoke instead.
|
|
11
|
+
* @param options See {@link Options}.
|
|
12
|
+
*/
|
|
13
|
+
export declare function useRightClick(action: () => void, options?: Options): void;
|
|
14
|
+
/**
|
|
15
|
+
* Hook for overriding the browser-default right click context menu action for
|
|
16
|
+
* an element.
|
|
17
|
+
*
|
|
18
|
+
* @param targetRef The target to override. If undefined, the window will be
|
|
19
|
+
* used.
|
|
20
|
+
* @param action The function to invoke instead.
|
|
21
|
+
* @param options See {@link Options}.
|
|
22
|
+
*/
|
|
23
|
+
export declare function useRightClick(targetRef: Target, action?: () => void, options?: Options): void;
|
|
24
|
+
export {};
|
package/build/index.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export * from './hooks/useMouseLeave.js';
|
|
|
32
32
|
export * from './hooks/useOS.js';
|
|
33
33
|
export * from './hooks/usePrevious.js';
|
|
34
34
|
export * from './hooks/useRect.js';
|
|
35
|
+
export * from './hooks/useRightClick.js';
|
|
35
36
|
export * from './hooks/useScrollPositionObserver.js';
|
|
36
37
|
export * from './hooks/useSessionCache.js';
|
|
37
38
|
export * from './hooks/useSize.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "etudes",
|
|
3
|
-
"version": "32.
|
|
3
|
+
"version": "32.5.0",
|
|
4
4
|
"description": "A study of headless React components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -47,29 +47,29 @@
|
|
|
47
47
|
"@eslint/js": "^10.0.1",
|
|
48
48
|
"@semantic-release/git": "^10.0.1",
|
|
49
49
|
"@stylistic/eslint-plugin": "^5.10.0",
|
|
50
|
-
"@tailwindcss/vite": "^4.3.
|
|
50
|
+
"@tailwindcss/vite": "^4.3.1",
|
|
51
51
|
"@testing-library/react": "^16.3.2",
|
|
52
52
|
"@testing-library/user-event": "^14.6.1",
|
|
53
|
-
"@types/node": "^25.9.
|
|
54
|
-
"@types/react": "^19.2.
|
|
53
|
+
"@types/node": "^25.9.3",
|
|
54
|
+
"@types/react": "^19.2.17",
|
|
55
55
|
"@types/react-dom": "^19.2.3",
|
|
56
56
|
"@vitejs/plugin-react": "^6.0.2",
|
|
57
|
-
"@vitest/coverage-v8": "^4.1.
|
|
57
|
+
"@vitest/coverage-v8": "^4.1.9",
|
|
58
58
|
"concurrently": "^10.0.3",
|
|
59
|
-
"eslint": "^10.
|
|
60
|
-
"eslint-plugin-perfectionist": "^5.9.
|
|
61
|
-
"happy-dom": "^20.
|
|
59
|
+
"eslint": "^10.5.0",
|
|
60
|
+
"eslint-plugin-perfectionist": "^5.9.1",
|
|
61
|
+
"happy-dom": "^20.10.5",
|
|
62
62
|
"react": "^19.2.7",
|
|
63
63
|
"react-dom": "^19.2.7",
|
|
64
64
|
"rimraf": "^6.1.3",
|
|
65
|
-
"semantic-release": "^25.0.
|
|
66
|
-
"tailwindcss": "^4.3.
|
|
65
|
+
"semantic-release": "^25.0.5",
|
|
66
|
+
"tailwindcss": "^4.3.1",
|
|
67
67
|
"typescript": "^6.0.3",
|
|
68
|
-
"typescript-eslint": "^8.
|
|
68
|
+
"typescript-eslint": "^8.61.1",
|
|
69
69
|
"vite": "^8.0.16",
|
|
70
70
|
"vite-plugin-dts": "^5.0.2",
|
|
71
71
|
"vite-plugin-svgr": "^5.2.0",
|
|
72
|
-
"vitest": "^4.1.
|
|
72
|
+
"vitest": "^4.1.9",
|
|
73
73
|
"wait-on": "^9.0.10"
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|