etudes 31.0.0 → 32.0.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.
Files changed (28) hide show
  1. package/build/components/CoverImage.d.ts +2 -2
  2. package/build/components/CoverVideo.d.ts +2 -2
  3. package/build/etudes.js +1654 -1716
  4. package/build/etudes.umd.cjs +1 -1
  5. package/build/hooks/useDrag.d.ts +0 -1
  6. package/build/hooks/{useScrollPosition.d.ts → useScrollPositionObserver.d.ts} +2 -2
  7. package/build/index.d.ts +2 -1
  8. package/build/primitives/Image.d.ts +8 -9
  9. package/build/primitives/Picture.d.ts +3 -3
  10. package/build/primitives/RangeSlider.d.ts +1 -1
  11. package/build/primitives/Slider.d.ts +1 -1
  12. package/build/primitives/StepSlider.d.ts +1 -1
  13. package/build/primitives/Video.d.ts +3 -3
  14. package/build/providers/ScrollPositionProvider.d.ts +40 -0
  15. package/build/types/ImageSource.d.ts +24 -0
  16. package/package.json +1 -1
  17. package/build/utils/createLocalCache.spec.d.ts +0 -1
  18. package/build/utils/createSessionCache.spec.d.ts +0 -1
  19. /package/build/hooks/{useClickOutside.spec.d.ts → __tests__/useClickOutside.spec.d.ts} +0 -0
  20. /package/build/hooks/{useInterval.spec.d.ts → __tests__/useInterval.spec.d.ts} +0 -0
  21. /package/build/hooks/{useKeyboardShortcut.spec.d.ts → __tests__/useKeyboardShortcut.spec.d.ts} +0 -0
  22. /package/build/hooks/{useLatest.spec.d.ts → __tests__/useLatest.spec.d.ts} +0 -0
  23. /package/build/hooks/{usePrevious.spec.d.ts → __tests__/usePrevious.spec.d.ts} +0 -0
  24. /package/build/hooks/{useTimeout.spec.d.ts → __tests__/useTimeout.spec.d.ts} +0 -0
  25. /package/build/utils/{cloneStyledElement.spec.d.ts → __tests__/cloneStyledElement.spec.d.ts} +0 -0
  26. /package/build/utils/{createKey.spec.d.ts → __tests__/createKey.spec.d.ts} +0 -0
  27. /package/build/utils/{createKeyDeep.spec.d.ts → __tests__/createKeyDeep.spec.d.ts} +0 -0
  28. /package/build/utils/{styles.spec.d.ts → __tests__/styles.spec.d.ts} +0 -0
@@ -43,7 +43,6 @@ export type UseDragOptions = {
43
43
  *
44
44
  * @param target The target element or reference
45
45
  * @param options Additional options.
46
- * @param deps Dependencies that trigger this effect.
47
46
  *
48
47
  * @returns The states created for this effect.
49
48
  */
@@ -15,6 +15,6 @@ type Target = HTMLElement | null | RefObject<HTMLElement> | RefObject<HTMLElemen
15
15
  * @param onChange Handler invoked when the scroll position changes.
16
16
  * @param deps Optional dependency list to control when the hook should re-run.
17
17
  */
18
- export declare function useScrollPosition(target: Target, onChange: (newInfo: ScrollPositionInfo, oldInfo: ScrollPositionInfo | undefined) => void, deps?: DependencyList): void;
19
- export declare function useScrollPosition(onChange: (newInfo: ScrollPositionInfo, oldInfo: ScrollPositionInfo | undefined) => void, deps?: DependencyList): void;
18
+ export declare function useScrollPositionObserver(target: Target, onChange: (newInfo: ScrollPositionInfo, oldInfo: ScrollPositionInfo | undefined) => void, deps?: DependencyList): void;
19
+ export declare function useScrollPositionObserver(onChange: (newInfo: ScrollPositionInfo, oldInfo: ScrollPositionInfo | undefined) => void, deps?: DependencyList): void;
20
20
  export {};
package/build/index.d.ts CHANGED
@@ -32,7 +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/useScrollPosition.js';
35
+ export * from './hooks/useScrollPositionObserver.js';
36
36
  export * from './hooks/useSessionCache.js';
37
37
  export * from './hooks/useSize.js';
38
38
  export * from './hooks/useSizeObserver.js';
@@ -65,6 +65,7 @@ export * from './primitives/TextArea.js';
65
65
  export * from './primitives/TextField.js';
66
66
  export * from './primitives/Toggle.js';
67
67
  export * from './primitives/Video.js';
68
+ export * from './providers/ScrollPositionProvider.js';
68
69
  export * from './types/ImageSource.js';
69
70
  export * from './utils/asClassNameDict.js';
70
71
  export * from './utils/asComponentDict.js';
@@ -19,15 +19,14 @@ export declare namespace Image {
19
19
  */
20
20
  loadingMode?: 'eager' | 'lazy';
21
21
  /**
22
- * Optional image source. If provided, this will be used to set the `sizes`
23
- * and `srcSet` attributes of the `<img>` element.
22
+ * Either a string URL or a tuple of the form `[src, ImageSource]`, where
23
+ * `src` is a fallback image URL and `ImageSource` provides additional
24
+ * information for responsive images. If a tuple is provided, the `src` will
25
+ * be used as the `src` attribute of the `<img>` element, while the
26
+ * properties of `ImageSource` will be used to set the `sizes` and `srcSet`
27
+ * attributes.
24
28
  */
25
- source?: Omit<ImageSource, 'media' | 'type'>;
26
- /**
27
- * Fallback image URL for browsers that do not support the `srcSet`
28
- * attribute.
29
- */
30
- src: string;
29
+ source: [string, Omit<ImageSource, 'media' | 'type'>] | string;
31
30
  /**
32
31
  * Handler invoked when image load begins.
33
32
  */
@@ -52,7 +51,7 @@ export declare namespace Image {
52
51
  * A component that renders an image with support for lazy loading, `srcSet`,
53
52
  * and `sizes` attributes.
54
53
  */
55
- export declare function Image({ ref, alt, loadingMode, source, src: fallbackSrc, onError, onLoad, onLoadStart, onSizeChange, ...props }: Image.Props): import("react/jsx-runtime").JSX.Element;
54
+ export declare function Image({ ref, alt, loadingMode, source, onError, onLoad, onLoadStart, onSizeChange, ...props }: Image.Props): import("react/jsx-runtime").JSX.Element;
56
55
  export declare namespace Image {
57
56
  var displayName: string;
58
57
  }
@@ -10,10 +10,10 @@ export declare namespace Picture {
10
10
  * Reference to the root element.
11
11
  */
12
12
  ref?: Ref<HTMLPictureElement>;
13
- sources?: ImageSource[];
14
- } & HTMLAttributes<HTMLPictureElement> & Pick<Image.Props, 'alt' | 'loadingMode' | 'onError' | 'onLoad' | 'onLoadStart' | 'onSizeChange' | 'src'>;
13
+ source: [string, ...ImageSource[]] | string;
14
+ } & HTMLAttributes<HTMLPictureElement> & Pick<Image.Props, 'alt' | 'loadingMode' | 'onError' | 'onLoad' | 'onLoadStart' | 'onSizeChange'>;
15
15
  }
16
- export declare function Picture({ ref, alt, loadingMode, sources, src, onError, onLoad, onLoadStart, onSizeChange, ...props }: Picture.Props): import("react/jsx-runtime").JSX.Element;
16
+ export declare function Picture({ ref, alt, loadingMode, source, onError, onLoad, onLoadStart, onSizeChange, ...props }: Picture.Props): import("react/jsx-runtime").JSX.Element;
17
17
  export declare namespace Picture {
18
18
  var displayName: string;
19
19
  }
@@ -8,7 +8,7 @@ import { HTMLAttributes, Ref } from 'react';
8
8
  * @exports RangeSlider.Track Component for the track.
9
9
  * @exports RangeSlider.TrackHighlight Component for the track highlight.
10
10
  */
11
- export declare function RangeSlider({ className, ref, children, knobHeight, knobPadding, knobWidth, max: maxValue, min: minValue, orientation, range, steps, isClipped, formatLabel, onChange, onDragEnd, onDragStart, ...props }: RangeSlider.Props): import("react/jsx-runtime").JSX.Element;
11
+ export declare function RangeSlider({ ref, children, knobHeight, knobPadding, knobWidth, max: maxValue, min: minValue, orientation, range, steps, isClipped, formatLabel, onChange, onDragEnd, onDragStart, ...props }: RangeSlider.Props): import("react/jsx-runtime").JSX.Element;
12
12
  export declare namespace RangeSlider {
13
13
  var displayName: string;
14
14
  }
@@ -13,7 +13,7 @@ import { HTMLAttributes, Ref } from 'react';
13
13
  * @exports Slider.Track Component for the slide track on either side of the
14
14
  * knob.
15
15
  */
16
- export declare function Slider({ className, ref, children, knobHeight, knobPadding, knobWidth, orientation, position, trackPadding, isClipped, isInverted, isTrackInteractive, formatLabel, onChange, onDragEnd, onDragStart, ...props }: Readonly<Slider.Props>): import("react/jsx-runtime").JSX.Element;
16
+ export declare function Slider({ ref, children, knobHeight, knobPadding, knobWidth, orientation, position, trackPadding, isClipped, isInverted, isTrackInteractive, formatLabel, onChange, onDragEnd, onDragStart, ...props }: Readonly<Slider.Props>): import("react/jsx-runtime").JSX.Element;
17
17
  export declare namespace Slider {
18
18
  var displayName: string;
19
19
  }
@@ -18,7 +18,7 @@ import { HTMLAttributes, Ref } from 'react';
18
18
  * @exports StepSlider.Track Component for the slide track on either side of the
19
19
  * knob.
20
20
  */
21
- export declare function StepSlider({ className, ref, children, index, knobHeight, knobPadding, knobWidth, orientation, steps, trackPadding, isClipped, isInverted, isTrackInteractive, formatLabel: labelProvider, onDragEnd, onDragStart, onIndexChange, onPositionChange, ...props }: StepSlider.Props): import("react/jsx-runtime").JSX.Element;
21
+ export declare function StepSlider({ ref, children, index, knobHeight, knobPadding, knobWidth, orientation, steps, trackPadding, isClipped, isInverted, isTrackInteractive, formatLabel: labelProvider, onDragEnd, onDragStart, onIndexChange, onPositionChange, ...props }: StepSlider.Props): import("react/jsx-runtime").JSX.Element;
22
22
  export declare namespace StepSlider {
23
23
  var displayName: string;
24
24
  }
@@ -28,7 +28,7 @@ export declare namespace Video {
28
28
  /**
29
29
  * The URL of the video poster when video is unavailable or loading.
30
30
  */
31
- posterSrc?: string;
31
+ poster?: string;
32
32
  /**
33
33
  * Reference to the root element.
34
34
  */
@@ -36,7 +36,7 @@ export declare namespace Video {
36
36
  /**
37
37
  * The URL of the video to play.
38
38
  */
39
- src: string;
39
+ source: string;
40
40
  /**
41
41
  * Handler invoked when the video is ready to play.
42
42
  */
@@ -98,7 +98,7 @@ export declare namespace Video {
98
98
  *
99
99
  * @see {@link https://www.npmjs.com/package/hls.js}
100
100
  */
101
- export declare function Video({ ref, autoLoop, autoPlay, playsInline, posterSrc, src, hasControls, isMuted, onCanPlay, onEnd, onFullscreenChange, onLoadMetadata, onLoadMetadataComplete, onLoadMetadataError, onPause, onPlay, onSizeChange, onTimeUpdate, ...props }: Video.Props): import("react/jsx-runtime").JSX.Element;
101
+ export declare function Video({ ref, autoLoop, autoPlay, playsInline, poster, source, hasControls, isMuted, onCanPlay, onEnd, onFullscreenChange, onLoadMetadata, onLoadMetadataComplete, onLoadMetadataError, onPause, onPlay, onSizeChange, onTimeUpdate, ...props }: Video.Props): import("react/jsx-runtime").JSX.Element;
102
102
  export declare namespace Video {
103
103
  var displayName: string;
104
104
  }
@@ -0,0 +1,40 @@
1
+ import { PropsWithChildren, RefObject } from 'react';
2
+ import { Point } from 'spase';
3
+ type Target = HTMLElement | null | RefObject<HTMLElement> | RefObject<HTMLElement | null> | RefObject<HTMLElement | undefined> | undefined;
4
+ type ContextValue = {
5
+ current: Point.Point;
6
+ end: Point.Point;
7
+ progress: Point.Point;
8
+ start: Point.Point;
9
+ };
10
+ type ProviderProps = PropsWithChildren<{
11
+ target?: Target;
12
+ }>;
13
+ /**
14
+ * Provides scroll position information to its descendants.
15
+ */
16
+ export declare function ScrollPositionProvider({ children, target, }: ProviderProps): import("react/jsx-runtime").JSX.Element;
17
+ /**
18
+ * Hook to determine if the scroll position is at the top of the scrollable
19
+ * area.
20
+ *
21
+ * @returns `true` if the scroll position is at the top, `false` otherwise.
22
+ */
23
+ export declare function useIsScrollTop(): boolean;
24
+ /**
25
+ * Hook to determine if the scroll position is at the bottom of the scrollable
26
+ * area.
27
+ *
28
+ * @returns `true` if the scroll position is at the bottom, `false` otherwise.
29
+ */
30
+ export declare function useIsScrollBottom(): boolean;
31
+ /**
32
+ * Hook to access the current scroll position information from the nearest
33
+ * `ScrollPositionProvider` in the component tree.
34
+ *
35
+ * @returns The current scroll position information, including the current
36
+ * scroll position. If the hook is used outside of a
37
+ * `ScrollPositionProvider`, it will return zero values.
38
+ */
39
+ export declare function useScrollPosition(): ContextValue;
40
+ export {};
@@ -53,6 +53,30 @@ export type ImageSource = {
53
53
  type?: string;
54
54
  };
55
55
  export declare namespace ImageSource {
56
+ /**
57
+ * Convenience function to create an `ImageSource` object from a list of image
58
+ * sources and a size descriptor.
59
+ *
60
+ * @param size A CSS size value indicating the size of the image's slot on the
61
+ * page, i.e. `100px`, `100vw`, `50%`, etc.
62
+ * @param srcSet A list of tuples, where each tuple contains a URL specifying
63
+ * an image location and either an intrinsic width (in pixels)
64
+ * of the image expressed as a positive integer or a pixel
65
+ * density of the image expressed as a positive floating number.
66
+ *
67
+ * @returns An `ImageSource` object with the specified size and image sources.
68
+ */
69
+ function make(size: string, srcSet: [string, number][]): ImageSource;
70
+ /**
71
+ * Converts an `ImageSource` object into props that can be spread onto a
72
+ * `<source>` or `<img>` element, including validation of the `ImageSource`
73
+ * object.
74
+ *
75
+ * @param imageSource The `ImageSource` object to convert into props.
76
+ *
77
+ * @returns An object containing the props to spread onto a `<source>` or
78
+ * `<img>` element.
79
+ */
56
80
  function asProps(imageSource: ImageSource): {
57
81
  media: string | undefined;
58
82
  sizes: string | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "etudes",
3
- "version": "31.0.0",
3
+ "version": "32.0.0",
4
4
  "description": "A study of headless React components",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};