etudes 5.2.0 → 5.3.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 (164) hide show
  1. package/components/Accordion.js +171 -205
  2. package/components/BurgerButton.js +40 -94
  3. package/components/Carousel.js +87 -123
  4. package/components/Collection.js +84 -120
  5. package/components/Counter.js +32 -63
  6. package/components/CoverImage.js +24 -68
  7. package/components/CoverVideo.js +25 -69
  8. package/components/DebugConsole.js +27 -79
  9. package/components/Dial.js +28 -65
  10. package/components/Dropdown.js +86 -98
  11. package/components/FlatSVG.js +22 -71
  12. package/components/Image.js +21 -50
  13. package/components/MasonryGrid.js +122 -257
  14. package/components/Panorama.js +48 -92
  15. package/components/PanoramaSlider.js +57 -113
  16. package/components/RangeSlider.js +125 -182
  17. package/components/RotatingGallery.js +28 -59
  18. package/components/SelectableButton.js +10 -54
  19. package/components/Slider.js +108 -159
  20. package/components/StepwiseSlider.js +124 -176
  21. package/components/SwipeContainer.js +30 -73
  22. package/components/TextField.js +12 -49
  23. package/components/Video.js +31 -61
  24. package/components/WithTooltip.js +117 -111
  25. package/components/index.js +24 -0
  26. package/hooks/index.js +17 -0
  27. package/hooks/useClickOutsideEffect.js +8 -38
  28. package/hooks/useDragEffect.js +20 -53
  29. package/hooks/useDragValueEffect.js +31 -81
  30. package/hooks/useImageSize.js +16 -38
  31. package/hooks/useInterval.js +9 -41
  32. package/hooks/useLoadImageEffect.js +15 -48
  33. package/hooks/useLoadVideoMetadataEffect.js +15 -48
  34. package/hooks/useMounted.js +5 -25
  35. package/hooks/usePrevious.js +4 -9
  36. package/hooks/useRect.js +9 -29
  37. package/hooks/useResizeEffect.js +10 -44
  38. package/hooks/useScrollPositionEffect.js +19 -50
  39. package/hooks/useSearchParamState.js +12 -34
  40. package/hooks/useSize.js +9 -29
  41. package/hooks/useTimeout.js +8 -38
  42. package/hooks/useVideoSize.js +16 -38
  43. package/hooks/useViewportSize.js +7 -27
  44. package/operators/Conditional.js +6 -11
  45. package/operators/Each.js +6 -14
  46. package/operators/ExtractChild.js +9 -36
  47. package/operators/ExtractChildren.js +7 -34
  48. package/operators/Repeat.js +4 -37
  49. package/operators/index.js +5 -0
  50. package/package.json +27 -41
  51. package/providers/ScrollPositionProvider.js +37 -60
  52. package/providers/index.js +1 -0
  53. package/utils/asClassNameDict.js +1 -5
  54. package/utils/asComponentDict.js +11 -16
  55. package/utils/asStyleDict.js +1 -5
  56. package/utils/cloneStyledElement.js +14 -61
  57. package/utils/index.js +5 -22
  58. package/utils/styles.js +5 -21
  59. package/components/Accordion.d.ts +0 -219
  60. package/components/Accordion.js.map +0 -1
  61. package/components/BurgerButton.d.ts +0 -34
  62. package/components/BurgerButton.js.map +0 -1
  63. package/components/Carousel.d.ts +0 -53
  64. package/components/Carousel.js.map +0 -1
  65. package/components/Collection.d.ts +0 -171
  66. package/components/Collection.js.map +0 -1
  67. package/components/Counter.d.ts +0 -11
  68. package/components/Counter.js.map +0 -1
  69. package/components/CoverImage.d.ts +0 -28
  70. package/components/CoverImage.js.map +0 -1
  71. package/components/CoverVideo.d.ts +0 -28
  72. package/components/CoverVideo.js.map +0 -1
  73. package/components/DebugConsole.d.ts +0 -15
  74. package/components/DebugConsole.js.map +0 -1
  75. package/components/Dial.d.ts +0 -79
  76. package/components/Dial.js.map +0 -1
  77. package/components/Dropdown.d.ts +0 -109
  78. package/components/Dropdown.js.map +0 -1
  79. package/components/FlatSVG.d.ts +0 -72
  80. package/components/FlatSVG.js.map +0 -1
  81. package/components/Image.d.ts +0 -144
  82. package/components/Image.js.map +0 -1
  83. package/components/MasonryGrid.d.ts +0 -29
  84. package/components/MasonryGrid.js.map +0 -1
  85. package/components/Panorama.d.ts +0 -77
  86. package/components/Panorama.js.map +0 -1
  87. package/components/PanoramaSlider.d.ts +0 -71
  88. package/components/PanoramaSlider.js.map +0 -1
  89. package/components/RangeSlider.d.ts +0 -34
  90. package/components/RangeSlider.js.map +0 -1
  91. package/components/RotatingGallery.d.ts +0 -91
  92. package/components/RotatingGallery.js.map +0 -1
  93. package/components/SelectableButton.d.ts +0 -19
  94. package/components/SelectableButton.js.map +0 -1
  95. package/components/Slider.d.ts +0 -160
  96. package/components/Slider.js.map +0 -1
  97. package/components/StepwiseSlider.d.ts +0 -215
  98. package/components/StepwiseSlider.js.map +0 -1
  99. package/components/SwipeContainer.d.ts +0 -21
  100. package/components/SwipeContainer.js.map +0 -1
  101. package/components/TextField.d.ts +0 -21
  102. package/components/TextField.js.map +0 -1
  103. package/components/Video.d.ts +0 -38
  104. package/components/Video.js.map +0 -1
  105. package/components/WithTooltip.d.ts +0 -32
  106. package/components/WithTooltip.js.map +0 -1
  107. package/hooks/useClickOutsideEffect.d.ts +0 -2
  108. package/hooks/useClickOutsideEffect.js.map +0 -1
  109. package/hooks/useDragEffect.d.ts +0 -48
  110. package/hooks/useDragEffect.js.map +0 -1
  111. package/hooks/useDragValueEffect.d.ts +0 -56
  112. package/hooks/useDragValueEffect.js.map +0 -1
  113. package/hooks/useImageSize.d.ts +0 -21
  114. package/hooks/useImageSize.js.map +0 -1
  115. package/hooks/useInterval.d.ts +0 -18
  116. package/hooks/useInterval.js.map +0 -1
  117. package/hooks/useLoadImageEffect.d.ts +0 -43
  118. package/hooks/useLoadImageEffect.js.map +0 -1
  119. package/hooks/useLoadVideoMetadataEffect.d.ts +0 -35
  120. package/hooks/useLoadVideoMetadataEffect.js.map +0 -1
  121. package/hooks/useMounted.d.ts +0 -1
  122. package/hooks/useMounted.js.map +0 -1
  123. package/hooks/usePrevious.d.ts +0 -19
  124. package/hooks/usePrevious.js.map +0 -1
  125. package/hooks/useRect.d.ts +0 -11
  126. package/hooks/useRect.js.map +0 -1
  127. package/hooks/useResizeEffect.d.ts +0 -17
  128. package/hooks/useResizeEffect.js.map +0 -1
  129. package/hooks/useScrollPositionEffect.d.ts +0 -13
  130. package/hooks/useScrollPositionEffect.js.map +0 -1
  131. package/hooks/useSearchParamState.d.ts +0 -34
  132. package/hooks/useSearchParamState.js.map +0 -1
  133. package/hooks/useSize.d.ts +0 -10
  134. package/hooks/useSize.js.map +0 -1
  135. package/hooks/useTimeout.d.ts +0 -10
  136. package/hooks/useTimeout.js.map +0 -1
  137. package/hooks/useVideoSize.d.ts +0 -21
  138. package/hooks/useVideoSize.js.map +0 -1
  139. package/hooks/useViewportSize.d.ts +0 -7
  140. package/hooks/useViewportSize.js.map +0 -1
  141. package/operators/Conditional.d.ts +0 -5
  142. package/operators/Conditional.js.map +0 -1
  143. package/operators/Each.d.ts +0 -7
  144. package/operators/Each.js.map +0 -1
  145. package/operators/ExtractChild.d.ts +0 -8
  146. package/operators/ExtractChild.js.map +0 -1
  147. package/operators/ExtractChildren.d.ts +0 -6
  148. package/operators/ExtractChildren.js.map +0 -1
  149. package/operators/Repeat.d.ts +0 -11
  150. package/operators/Repeat.js.map +0 -1
  151. package/providers/ScrollPositionProvider.d.ts +0 -15
  152. package/providers/ScrollPositionProvider.js.map +0 -1
  153. package/utils/asClassNameDict.d.ts +0 -3
  154. package/utils/asClassNameDict.js.map +0 -1
  155. package/utils/asComponentDict.d.ts +0 -5
  156. package/utils/asComponentDict.js.map +0 -1
  157. package/utils/asStyleDict.d.ts +0 -4
  158. package/utils/asStyleDict.js.map +0 -1
  159. package/utils/cloneStyledElement.d.ts +0 -18
  160. package/utils/cloneStyledElement.js.map +0 -1
  161. package/utils/index.d.ts +0 -5
  162. package/utils/index.js.map +0 -1
  163. package/utils/styles.d.ts +0 -2
  164. package/utils/styles.js.map +0 -1
@@ -1,144 +0,0 @@
1
- import { type HTMLAttributes } from 'react';
2
- import { type Size } from 'spase';
3
- export type ImageProps = Omit<HTMLAttributes<HTMLImageElement>, 'alt' | 'srcSet' | 'sizes' | 'src' | 'loading' | 'onLoadStart'> & {
4
- /**
5
- * Optional alt text.
6
- */
7
- alt?: string;
8
- /**
9
- * Loading mode for the image.
10
- */
11
- loadingMode?: 'none' | 'lazy' | 'preload';
12
- /**
13
- * Descriptor for the `srcset` attribute of the `<img>` element. If `sizes` is
14
- * also provided, then each entry in this list must have a `width` value and
15
- * no `pixelDensity` value.
16
- */
17
- srcSet?: {
18
- /**
19
- * A URL specifying an image location.
20
- */
21
- src: string;
22
- /**
23
- * Optional intrinsic width (in pixels) of the image expressed as a positive
24
- * integer. If set, leave `pixelDensity` unspecified (only one of `width` or
25
- * `pixelDensity` can be specified).
26
- */
27
- width?: number;
28
- /**
29
- * Optional pixel density of the image expressed as a positive floating
30
- * number. If set, leave `width` unspecified (only one of `width` or
31
- * `pixelDensity` can be specified.
32
- */
33
- pixelDensity?: number;
34
- }[];
35
- /**
36
- * Descriptor for the `sizes` attribute of the `<img>` element.
37
- */
38
- sizes?: {
39
- /**
40
- * Optional media query condition (without brackets, i.e. `max-width:
41
- * 100px`). Note that this must be omitted for the last item in this list of
42
- * sizes.
43
- */
44
- mediaCondition?: string;
45
- /**
46
- * A CSS size value indicating the size of the image's slot on the page,
47
- * i.e. `100px`, `100vw`, `50%`, etc.
48
- */
49
- width: string;
50
- }[];
51
- /**
52
- * Fallback image URL for browsers that do not support the `srcset` attribute.
53
- */
54
- src?: string;
55
- /**
56
- * Handler invoked when image load begins.
57
- */
58
- onLoadStart?: () => void;
59
- /**
60
- * Handler invoked when image load completes.
61
- */
62
- onLoadComplete?: () => void;
63
- /**
64
- * Handler invoked when image load encounters an error.
65
- */
66
- onLoadError?: () => void;
67
- /**
68
- * Handler invoked when the size of the loaded image changes.
69
- *
70
- * @param size Size of the loaded image.
71
- */
72
- onSizeChange?: (size?: Size) => void;
73
- };
74
- export declare const Image: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLImageElement>, "src" | "srcSet" | "sizes" | "onLoadStart" | "alt" | "loading"> & {
75
- /**
76
- * Optional alt text.
77
- */
78
- alt?: string;
79
- /**
80
- * Loading mode for the image.
81
- */
82
- loadingMode?: "none" | "lazy" | "preload";
83
- /**
84
- * Descriptor for the `srcset` attribute of the `<img>` element. If `sizes` is
85
- * also provided, then each entry in this list must have a `width` value and
86
- * no `pixelDensity` value.
87
- */
88
- srcSet?: {
89
- /**
90
- * A URL specifying an image location.
91
- */
92
- src: string;
93
- /**
94
- * Optional intrinsic width (in pixels) of the image expressed as a positive
95
- * integer. If set, leave `pixelDensity` unspecified (only one of `width` or
96
- * `pixelDensity` can be specified).
97
- */
98
- width?: number;
99
- /**
100
- * Optional pixel density of the image expressed as a positive floating
101
- * number. If set, leave `width` unspecified (only one of `width` or
102
- * `pixelDensity` can be specified.
103
- */
104
- pixelDensity?: number;
105
- }[];
106
- /**
107
- * Descriptor for the `sizes` attribute of the `<img>` element.
108
- */
109
- sizes?: {
110
- /**
111
- * Optional media query condition (without brackets, i.e. `max-width:
112
- * 100px`). Note that this must be omitted for the last item in this list of
113
- * sizes.
114
- */
115
- mediaCondition?: string;
116
- /**
117
- * A CSS size value indicating the size of the image's slot on the page,
118
- * i.e. `100px`, `100vw`, `50%`, etc.
119
- */
120
- width: string;
121
- }[];
122
- /**
123
- * Fallback image URL for browsers that do not support the `srcset` attribute.
124
- */
125
- src?: string;
126
- /**
127
- * Handler invoked when image load begins.
128
- */
129
- onLoadStart?: () => void;
130
- /**
131
- * Handler invoked when image load completes.
132
- */
133
- onLoadComplete?: () => void;
134
- /**
135
- * Handler invoked when image load encounters an error.
136
- */
137
- onLoadError?: () => void;
138
- /**
139
- * Handler invoked when the size of the loaded image changes.
140
- *
141
- * @param size Size of the loaded image.
142
- */
143
- onSizeChange?: (size?: Size) => void;
144
- } & import("react").RefAttributes<HTMLImageElement>>;
@@ -1 +0,0 @@
1
- {"version":3,"file":"Image.js","sourceRoot":"/","sources":["components/Image.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAAkE;AAElE,sDAAoD;AAqFvC,QAAA,KAAK,GAAG,IAAA,kBAAU,EAA+B,UAAC,EAW9D,EAAE,GAAG;IAVJ,IAAA,GAAG,SAAA,EACH,mBAAuB,EAAvB,WAAW,mBAAG,SAAS,KAAA,EACv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;YAA5B,cAAc,oBAAA,EAAE,KAAK,WAAA;QACpD,IAAM,MAAM,GAAG,GAAG,KAAK,KAAK,CAAC,MAAM,GAAG,CAAC,CAAA;QACvC,IAAI,CAAC,GAAG,KAAK,CAAA;QAEb,IAAI,MAAM,IAAI,cAAc;YAAE,MAAM,KAAK,CAAC,sEAAsE,CAAC,CAAA;QACjH,IAAI,cAAc;YAAE,CAAC,GAAG,UAAG,cAAc,cAAI,CAAC,CAAE,CAAA;QAEhD,OAAO,CAAC,CAAA;IACV,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;IAEb,IAAM,IAAI,GAAG,IAAA,2BAAY,EAAC;QACxB,GAAG,EAAE,WAAW;QAChB,MAAM,EAAE,WAAW;QACnB,KAAK,EAAE,UAAU;KAClB,EAAE;QACD,WAAW,aAAA;QACX,cAAc,gBAAA;QACd,WAAW,aAAA;KACZ,CAAC,CAAA;IAEF,IAAA,iBAAS,EAAC;QACR,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAG,IAAI,CAAC,CAAA;IACtB,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;IAEV,OAAO,CACL,2CACM,KAAK,IACT,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,oBACO,OAAO,EACtB,OAAO,EAAE,WAAW,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAClD,KAAK,EAAE,UAAU,EACjB,GAAG,EAAE,WAAW,EAChB,MAAM,EAAE,WAAW,IACnB,CACH,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,MAAM,CAAC,cAAc,CAAC,aAAK,EAAE,aAAa,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAA","sourcesContent":["import { forwardRef, useEffect, type HTMLAttributes } from 'react'\nimport { type Size } from 'spase'\nimport { useImageSize } from '../hooks/useImageSize'\n\nexport type ImageProps = Omit<HTMLAttributes<HTMLImageElement>, 'alt' | 'srcSet' | 'sizes' | 'src' | 'loading' | 'onLoadStart'> & {\n /**\n * Optional alt text.\n */\n alt?: string\n\n /**\n * Loading mode for the image.\n */\n loadingMode?: 'none' | 'lazy' | 'preload'\n\n /**\n * Descriptor for the `srcset` attribute of the `<img>` element. If `sizes` is\n * also provided, then each entry in this list must have a `width` value and\n * no `pixelDensity` value.\n */\n srcSet?: {\n /**\n * A URL specifying an image location.\n */\n src: string\n\n /**\n * Optional intrinsic width (in pixels) of the image expressed as a positive\n * integer. If set, leave `pixelDensity` unspecified (only one of `width` or\n * `pixelDensity` can be specified).\n */\n width?: number\n\n /**\n * Optional pixel density of the image expressed as a positive floating\n * number. If set, leave `width` unspecified (only one of `width` or\n * `pixelDensity` can be specified.\n */\n pixelDensity?: number\n }[]\n\n /**\n * Descriptor for the `sizes` attribute of the `<img>` element.\n */\n sizes?: {\n /**\n * Optional media query condition (without brackets, i.e. `max-width:\n * 100px`). Note that this must be omitted for the last item in this list of\n * sizes.\n */\n mediaCondition?: string\n\n /**\n * A CSS size value indicating the size of the image's slot on the page,\n * i.e. `100px`, `100vw`, `50%`, etc.\n */\n width: string\n }[]\n\n /**\n * Fallback image URL for browsers that do not support the `srcset` attribute.\n */\n src?: string\n\n /**\n * Handler invoked when image load begins.\n */\n onLoadStart?: () => void\n\n /**\n * Handler invoked when image load completes.\n */\n onLoadComplete?: () => void\n\n /**\n * Handler invoked when image load encounters an error.\n */\n onLoadError?: () => void\n\n /**\n * Handler invoked when the size of the loaded image changes.\n *\n * @param size Size of the loaded image.\n */\n onSizeChange?: (size?: Size) => void\n}\n\nexport const Image = forwardRef<HTMLImageElement, ImageProps>(({\n alt,\n loadingMode = 'preload',\n sizes,\n src: fallbackSrc,\n srcSet,\n onLoadStart,\n onLoadComplete,\n onLoadError,\n onSizeChange,\n ...props\n}, ref) => {\n const srcSetValue = srcSet?.map(({ pixelDensity, src, width }) => {\n if (sizes && width === undefined) throw Error('`width` must be specified if `sizes` is specified')\n if (width !== undefined && pixelDensity !== undefined) throw Error('Only one of `width` or `pixelDensity` can be specified.')\n\n let t = src\n\n if (width !== undefined) {\n const w = Math.floor(width)\n\n if (!isFinite(w) || String(w) !== String(width) || w <= 0) throw Error('The specified width must be a positive integer greater than 0')\n\n t += ` ${w}w`\n }\n else if (pixelDensity !== undefined) {\n if (!isFinite(pixelDensity) || pixelDensity <= 0) throw Error('The specified pixel density must be a positive floating number than 0')\n\n t += ` ${pixelDensity}x`\n }\n\n return t\n }).join(', ')\n\n const sizesValue = sizes?.map(({ mediaCondition, width }, idx) => {\n const isLast = idx === sizes.length - 1\n let t = width\n\n if (isLast && mediaCondition) throw Error('The last item in `sizes` must not have a `mediaCondition` specified.')\n if (mediaCondition) t = `${mediaCondition} ${t}`\n\n return t\n }).join(', ')\n\n const size = useImageSize({\n src: fallbackSrc,\n srcSet: srcSetValue,\n sizes: sizesValue,\n }, {\n onLoadStart,\n onLoadComplete,\n onLoadError,\n })\n\n useEffect(() => {\n onSizeChange?.(size)\n }, [size])\n\n return (\n <img\n {...props}\n ref={ref}\n alt={alt}\n data-component='image'\n loading={loadingMode === 'lazy' ? 'lazy' : 'eager'}\n sizes={sizesValue}\n src={fallbackSrc}\n srcSet={srcSetValue}\n />\n )\n})\n\nObject.defineProperty(Image, 'displayName', { value: 'Image', writable: false })\n"]}
@@ -1,29 +0,0 @@
1
- import { type HTMLAttributes } from 'react';
2
- type Orientation = 'horizontal' | 'vertical';
3
- export type MasonryGridProps = {
4
- areSectionsAligned?: boolean;
5
- horizontalSpacing?: number;
6
- isReversed?: boolean;
7
- orientation?: Orientation;
8
- sections?: number;
9
- verticalSpacing?: number;
10
- };
11
- /**
12
- * This is a React component that arranges all of its immediate children in a
13
- * masonry grid. Refrain from assigning CSS styles to it via `className` or
14
- * `style` property, though they are still handled if absolutely necessary.
15
- * Customize the grid via its supported properties. The grid can be in either
16
- * vertical or horizontal orientation. The length of every child element
17
- * *parallel to the direction of the orientation* is automatically set according
18
- * to the number of sections specified for the grid. This means that in an
19
- * horizontally oriented grid, the *width* of each child element is
20
- * automatically set, whereas in a vertically oriented grid the *height* of each
21
- * child element is automatically set. Additionally, the *number of sections*
22
- * corresponds to the maximum the number of child elements present in the
23
- * direction that is parallel to the orientation of the grid. Hence, in a
24
- * vertically oriented grid, *number of secitons* refers to the *number of
25
- * rows*, whereas in a horizontally oriented grid, *number of sections* refers
26
- * to the *number of columns*.
27
- */
28
- export declare const MasonryGrid: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & MasonryGridProps & import("react").RefAttributes<HTMLDivElement>>;
29
- export {};
@@ -1 +0,0 @@
1
- {"version":3,"file":"MasonryGrid.js","sourceRoot":"/","sources":["components/MasonryGrid.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAuB;AACvB,+BAAoF;AACpF,+BAAkC;AAClC,4DAA0D;AAC1D,kCAAuD;AAavD,IAAM,0BAA0B,GAAG,OAAO,CAAA;AAE1C;;;;;;;;;;;;;;;;GAgBG;AACU,QAAA,WAAW,GAAG,IAAA,kBAAU,EAAoE,UAAC,EAUzG,EAAE,GAAG;IATJ,IAAA,0BAA0B,EAA1B,kBAAkB,mBAAG,KAAK,KAAA,EAC1B,QAAQ,cAAA,EACR,SAAS,eAAA,EACT,yBAAqB,EAArB,iBAAiB,mBAAG,CAAC,KAAA,EACrB,kBAAkB,EAAlB,UAAU,mBAAG,KAAK,KAAA,EAClB,mBAAwB,EAAxB,WAAW,mBAAG,UAAU,KAAA,EACxB,gBAAY,EAAZ,QAAQ,mBAAG,CAAC,KAAA,EACZ,uBAAmB,EAAnB,eAAe,mBAAG,CAAC,KAAA,EAChB,KAAK,cATgG,gIAUzG,CADS;IAER,IAAM,OAAO,GAAG,IAAA,cAAM,EAAiB,IAAI,CAAC,CAAA;IAEtC,IAAA,KAAA,OAA0B,IAAA,gBAAQ,EAAC,GAAG,CA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AK,CAAC,IAAI,CAAC;oBAAE,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,WAAW,CAAC,CAAA;YACnE,CAAC;QACH,CAAC;;;;;;;;;IAED,OAAO,CAAC,CAAA;AACV,CAAC;AAED;;;;;;GAMG;AACH,SAAS,kBAAkB,CAAC,UAAmB;;;IAC7C,IAAI,CAAC,UAAU;QAAE,OAAO,EAAE,CAAA;IAE1B,IAAM,QAAQ,GAAG,2BAA2B,CAAA;IAC5C,IAAM,QAAQ,GAAG,0BAA0B,CAAA;IAC3C,IAAM,SAAS,GAAG,MAAA,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,mCAAI,EAAE,CAAA;IAEjD,IAAM,GAAG,GAAa,EAAE,CAAA;;QAExB,KAAkB,IAAA,cAAA,SAAA,SAAS,CAAA,oCAAA,2DAAE,CAAC;YAAzB,IAAM,GAAG,sBAAA;YACZ,IAAM,GAAG,GAAG,MAAA,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,0CAAG,CAAC,CAAC,CAAA;YAEnC,IAAI,CAAC,GAAG;gBAAE,SAAQ;YAElB,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACf,CAAC;;;;;;;;;IAED,OAAO,GAAG,CAAA;AACZ,CAAC","sourcesContent":["import clsx from 'clsx'\nimport { forwardRef, useEffect, useRef, useState, type HTMLAttributes } from 'react'\nimport { Rect, Size } from 'spase'\nimport { useResizeEffect } from '../hooks/useResizeEffect'\nimport { asClassNameDict, asStyleDict } from '../utils'\n\ntype Orientation = 'horizontal' | 'vertical'\n\nexport type MasonryGridProps = {\n areSectionsAligned?: boolean\n horizontalSpacing?: number\n isReversed?: boolean\n orientation?: Orientation\n sections?: number\n verticalSpacing?: number\n}\n\nconst BASE_MODIFIER_CLASS_PREFIX = 'base-'\n\n/**\n * This is a React component that arranges all of its immediate children in a\n * masonry grid. Refrain from assigning CSS styles to it via `className` or\n * `style` property, though they are still handled if absolutely necessary.\n * Customize the grid via its supported properties. The grid can be in either\n * vertical or horizontal orientation. The length of every child element\n * *parallel to the direction of the orientation* is automatically set according\n * to the number of sections specified for the grid. This means that in an\n * horizontally oriented grid, the *width* of each child element is\n * automatically set, whereas in a vertically oriented grid the *height* of each\n * child element is automatically set. Additionally, the *number of sections*\n * corresponds to the maximum the number of child elements present in the\n * direction that is parallel to the orientation of the grid. Hence, in a\n * vertically oriented grid, *number of secitons* refers to the *number of\n * rows*, whereas in a horizontally oriented grid, *number of sections* refers\n * to the *number of columns*.\n */\nexport const MasonryGrid = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement> & MasonryGridProps>(({\n areSectionsAligned = false,\n children,\n className,\n horizontalSpacing = 0,\n isReversed = false,\n orientation = 'vertical',\n sections = 3,\n verticalSpacing = 0,\n ...props\n}, ref) => {\n const bodyRef = useRef<HTMLDivElement>(null)\n\n const [minWidth, setMinWidth] = useState(NaN)\n const [minHeight, setMinHeight] = useState(NaN)\n const [maxWidth, setMaxWidth] = useState(NaN)\n const [maxHeight, setMaxHeight] = useState(NaN)\n\n const getCurrentWidth = () => Rect.from(bodyRef.current)?.width ?? 0\n\n const getCurrentHeight = () => Rect.from(bodyRef.current)?.height ?? 0\n\n const repositionChildren = () => {\n const rootNode = bodyRef.current\n\n if (!rootNode) return\n\n const nodes = rootNode.children\n const numSections = sections\n\n if (numSections <= 0) throw new Error('You must specifiy a minimum of 1 section(s) (a.k.a. row(s) for horizontal orientation, column(s) for vertical orientation) for a MasonryGrid instance')\n\n if (orientation === 'vertical') {\n const sectionHeights: number[] = [...new Array(numSections)].map(() => 0)\n\n for (const child of Array.from(nodes)) {\n if (!(child instanceof HTMLElement)) continue\n\n const base = computeBaseFromElement(child, sections)\n const [colIdx, y] = computeNextAvailableSectionAndLengthByBase(sectionHeights, base)\n\n child.style.position = 'absolute'\n child.style.width = `calc(${100 / numSections * base}% - ${horizontalSpacing * (numSections - 1) / numSections * base}px + ${horizontalSpacing * (base - 1)}px)`\n child.style.height = ''\n child.style.left = `calc(${100 / numSections * colIdx}% - ${horizontalSpacing * (numSections - 1) / numSections * colIdx}px + ${horizontalSpacing * colIdx}px)`\n child.style.top = `${y + (y === 0 ? 0 : verticalSpacing)}px`\n\n for (let j = 0; j < base; j++) {\n sectionHeights[colIdx + j] = y + (y === 0 ? 0 : verticalSpacing) + (Rect.from(child)?.height ?? 0)\n }\n\n if (areSectionsAligned && colIdx + base === numSections) {\n const m = computeMaxLength(sectionHeights)\n\n for (let j = 0; j < numSections; j++) {\n sectionHeights[j] = m\n }\n }\n }\n\n const w = getCurrentWidth()\n const h = computeMaxLength(sectionHeights, numSections)\n\n setMinWidth(w)\n setMinHeight(h)\n\n if (!isNaN(h)) rootNode.style.height = `${h}px`\n\n if (isReversed) {\n for (const child of Array.from(nodes)) {\n if (!(child instanceof HTMLElement)) continue\n\n const x = parseFloat(child.style.left)\n\n child.style.left = `${w - x - parseFloat(child.style.width)}px`\n }\n }\n }\n else {\n const sectionWidths: number[] = [...new Array(numSections)].map(() => 0)\n\n for (const child of Array.from(nodes)) {\n if (!(child instanceof HTMLElement)) continue\n\n const base = computeBaseFromElement(child, sections)\n const [rowIdx, x] = computeNextAvailableSectionAndLengthByBase(sectionWidths, base)\n\n child.style.position = 'absolute'\n child.style.width = ''\n child.style.height = `calc(${100 / numSections * base}% - ${verticalSpacing * (numSections - 1) / numSections * base}px + ${verticalSpacing * (base - 1)}px)`\n child.style.top = `calc(${100 / numSections * rowIdx}% - ${verticalSpacing * (numSections - 1) / numSections * rowIdx}px + ${verticalSpacing * rowIdx}px)`\n child.style.left = `${x + (x === 0 ? 0 : horizontalSpacing)}px`\n\n for (let j = 0; j < base; j++) {\n sectionWidths[rowIdx + j] = x + (x === 0 ? 0 : horizontalSpacing) + (Rect.from(child)?.width ?? 0)\n }\n\n if (areSectionsAligned && rowIdx + base === numSections) {\n const m = computeMaxLength(sectionWidths)\n\n for (let j = 0; j < numSections; j++) {\n sectionWidths[j] = m\n }\n }\n }\n\n const h = getCurrentHeight()\n const w = computeMaxLength(sectionWidths, numSections)\n\n setMinHeight(h)\n setMinWidth(w)\n\n if (!isNaN(w)) rootNode.style.width = `${w}px`\n\n if (isReversed) {\n for (const child of Array.from(nodes)) {\n if (!(child instanceof HTMLElement)) continue\n\n const y = parseFloat(child.style.top)\n\n child.style.top = `${h - y - parseFloat(child.style.height)}px`\n }\n }\n }\n }\n\n useResizeEffect(bodyRef, {\n onResize: element => {\n const maxSize = Rect.from(element)?.size ?? new Size()\n const currWidth = getCurrentWidth()\n const currHeight = getCurrentHeight()\n\n if (minWidth !== currWidth || minHeight !== currHeight || maxSize.width !== maxWidth || maxSize.height !== maxHeight) {\n repositionChildren()\n setMaxWidth(maxSize.width)\n setMaxHeight(maxSize.height)\n }\n },\n }, [areSectionsAligned, horizontalSpacing, isReversed, sections, verticalSpacing])\n\n useEffect(() => {\n const imageSources = getAllImageSources(bodyRef.current?.innerHTML)\n\n if (imageSources.length === 0) return repositionChildren()\n\n const numImages = imageSources.length\n\n for (let i = 0; i < numImages; i++) {\n const src = imageSources[i]\n const image = new Image()\n image.src = src\n image.onload = () => repositionChildren()\n }\n }, [children])\n\n const fixedClassNames = getFixedClassNames({ orientation })\n const fixedStyles = getFixedStyles({ orientation, minHeight, minWidth })\n\n return (\n <div {...props} ref={ref} className={clsx(className, fixedClassNames.root)} data-component='masonry-grid'>\n <div ref={bodyRef} style={fixedStyles.body}>\n {children}\n </div>\n </div>\n )\n})\n\nObject.defineProperty(MasonryGrid, 'displayName', { value: 'MasonryGrid', writable: false })\n\nfunction getFixedClassNames({ orientation = 'horizontal' }) {\n return asClassNameDict({\n root: clsx(orientation),\n })\n}\n\nfunction getFixedStyles({ orientation = 'horizontal', minHeight = NaN, minWidth = NaN }) {\n return asStyleDict({\n body: {\n height: orientation === 'horizontal' ? '100%' : 'auto',\n minHeight: orientation === 'vertical' && !isNaN(minHeight) ? `${minHeight}px` : '',\n minWidth: orientation === 'horizontal' && !isNaN(minWidth) ? `${minWidth}px` : '',\n padding: '0',\n width: orientation === 'horizontal' ? 'auto' : '100%',\n },\n })\n}\n\n/**\n * Computes the index and current length of the next available section for a\n * specific base value, based on a provided array of existing section lengths.\n *\n * @param currentSectionLengths An array of the current section lengths.\n * @param base The base value of the item to be inserted into the grid, and to\n * be used to evaluate the next available section.\n *\n * @returns An array consiting of the computed section index and its to-be\n * length if a new item were to be placed in it.\n */\nfunction computeNextAvailableSectionAndLengthByBase(currentSectionLengths: number[], base: number): [number, number] {\n const numSections = currentSectionLengths.length\n\n let sectionIdx = NaN\n let minLength = Infinity\n\n for (let i = 0; i < numSections; i++) {\n const length = currentSectionLengths[i]\n const isShorter = length < minLength\n const isEligibleSection = i + base <= numSections\n let hasRoomInSubsequentSections = true\n\n for (let j = 1; j < base; j++) {\n if (currentSectionLengths[i + j] > length) {\n hasRoomInSubsequentSections = false\n }\n }\n\n if (isShorter && isEligibleSection && hasRoomInSubsequentSections) {\n sectionIdx = i\n minLength = length\n }\n }\n\n if (isNaN(sectionIdx)) {\n return [0, computeMaxLength(currentSectionLengths, base)]\n }\n else {\n return [sectionIdx, minLength]\n }\n}\n\n/**\n * A helper function that computes the max section length of an array of section\n * lengths. Only the first n = `base` sections are inspected.\n *\n * @param currentSectionLengths An array of section lengths.\n * @param base The number representing the first n sections to inspect. Any\n * non-numerical values will be ignored and return value will be\n * based on all sections. A `base` value will be clamped between 1\n * and the maximum length of the array of section lengths.\n *\n * @returns The max section length.\n */\nfunction computeMaxLength(currentSectionLengths: number[], base?: number): number {\n let arr = currentSectionLengths\n\n if (base !== undefined && base !== null && !isNaN(base)) {\n arr = arr.slice(0, Math.max(1, Math.min(base, currentSectionLengths.length)))\n }\n\n return arr.reduce((out, curr, i) => curr > out ? curr : out, 0)\n}\n\n/**\n * Computes the base value of an element from its classes.\n *\n * @param element The HTML element.\n * @param numSections Total number of sections.\n *\n * @returns The computed base value that is clamped between 1 and max number of\n * sections.\n */\nfunction computeBaseFromElement(element: HTMLElement, numSections: number): number {\n const classList = element.classList\n\n for (const c of Array.from(classList)) {\n if (c.startsWith(BASE_MODIFIER_CLASS_PREFIX)) {\n const base = parseFloat(c.replace(BASE_MODIFIER_CLASS_PREFIX, ''))\n if (!isNaN(base)) return Math.min(Math.max(base, 1), numSections)\n }\n }\n\n return 1\n}\n\n/**\n * Scans an HTML string and returns all the image sources.\n *\n * @param htmlString The HTML string.\n *\n * @returns The image sources.\n */\nfunction getAllImageSources(htmlString?: string): string[] {\n if (!htmlString) return []\n\n const regexImg = /<img.*?src=([\"'])(.*?)\\1/g\n const regexSrc = /<img.*?src=([\"'])(.*?)\\1/\n const imageTags = regexImg.exec(htmlString) ?? []\n\n const out: string[] = []\n\n for (const tag of imageTags) {\n const src = regexSrc.exec(tag)?.[2]\n\n if (!src) continue\n\n out.push(src)\n }\n\n return out\n}\n"]}
@@ -1,77 +0,0 @@
1
- import { type HTMLAttributes } from 'react';
2
- import { Size } from 'spase';
3
- export type PanoramaHTMLAttributes = Omit<HTMLAttributes<HTMLDivElement>, 'onResize'>;
4
- export type PanoramaProps = {
5
- /**
6
- * The current angle in degrees, 0.0 - 360.0, inclusive. When angle is 0 or
7
- * 360, the `zeroAnchor` position of the image is at the left bound of the
8
- * component.
9
- */
10
- angle?: number;
11
- /**
12
- * The panning speed. This is expressed a multiplier of the number of pixels
13
- * dragged, i.e. when set to 1, the image will shift the same amount of pixels
14
- * that were dragged.
15
- */
16
- speed?: number;
17
- /**
18
- * The source URL of the image.
19
- */
20
- src?: string;
21
- /**
22
- * A decimal percentage of the image width indicating where 0° should be,
23
- * i.e. if `zeroAnchor` is `0`, the `angle` would be 0° when the left edge of
24
- * the image is at the left edge of the component.
25
- */
26
- zeroAnchor?: number;
27
- /**
28
- * Handler invoked when the positionchanges. This can either be invoked from
29
- * the `angle` prop being changed or from the image being dragged.
30
- *
31
- * @param position The current position.
32
- * @param isDragging Specifies if the position change is due to dragging.
33
- */
34
- onPositionChange?: (position: number, isDragging: boolean) => void;
35
- /**
36
- * Handler invoked when the angle changes. This can either be invoked from the
37
- * `angle` prop being changed or from the image being dragged. When `angle` is
38
- * being double-binded, ensure that the value is only being set by this
39
- * handler when `isDragging` is `true` to avoid potential update overflow.
40
- *
41
- * @param angle The current angle.
42
- * @param isDragging Specifies if the angle change is due to dragging.
43
- */
44
- onAngleChange?: (angle: number, isDragging: boolean) => void;
45
- /**
46
- * Handler invoked when dragging starts.
47
- */
48
- onDragStart?: () => void;
49
- /**
50
- * Handler invoked when dragging ends.
51
- */
52
- onDragEnd?: () => void;
53
- /**
54
- * Handler invoked when the image begins loading.
55
- */
56
- onLoadImageStart?: () => void;
57
- /**
58
- * Handler invoked when the image is done loading.
59
- */
60
- onLoadImageComplete?: () => void;
61
- /**
62
- * Handler invoked when there is an error loading the image.
63
- */
64
- onLoadImageError?: () => void;
65
- /**
66
- * Handler invoked when the image size changes. This is the actual size of the
67
- * loaded image. When no images are loaded yet, the size is `undefined`.
68
- *
69
- * @param size The actual size of the loaded iamge. If no images are loaded
70
- * yet, the size is `undefined`.
71
- */
72
- onImageSizeChange?: (size?: Size) => void;
73
- };
74
- /**
75
- * A component containing a pannable 360° panorama image. The angle supports two-way binding.
76
- */
77
- export declare const Panorama: import("react").ForwardRefExoticComponent<PanoramaHTMLAttributes & PanoramaProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -1 +0,0 @@
1
- {"version":3,"file":"Panorama.js","sourceRoot":"/","sources":["components/Panorama.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAAoF;AACpF,+BAA4B;AAC5B,kEAAgE;AAChE,sDAAoD;AACpD,4CAA0C;AAC1C,kCAAsC;AAsFtC;;GAEG;AACU,QAAA,QAAQ,GAAG,IAAA,kBAAU,EAAyD,UAAC,EAc3F,EAAE,GAAG;IAbJ,IAAA,aAAwB,EAAjB,aAAa,mBAAG,CAAC,KAAA,EACxB,aAAS,EAAT,KAA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wBAAwB,CAAC,KAAa,EAAE,iBAAuB,EAAE,aAAmB,EAAE,UAAkB;IACvG,IAAO,UAAU,GAAK,kBAAkB,CAAC,iBAAiB,EAAE,aAAa,CAAC,MAAzD,CAAyD;IAC1E,IAAO,cAAc,GAAK,aAAa,MAAlB,CAAkB;IAC/C,IAAM,MAAM,GAAG,cAAc,GAAG,UAAU,CAAA;IAE1C,OAAO,KAAK,GAAG,GAAG,GAAG,UAAU,GAAG,MAAM,CAAA;AAC1C,CAAC;AAED,SAAS,wBAAwB,CAAC,YAAoB,EAAE,iBAAuB,EAAE,aAAmB,EAAE,UAAkB;IAC9G,IAAO,UAAU,GAAK,kBAAkB,CAAC,iBAAiB,EAAE,aAAa,CAAC,MAAzD,CAAyD;IAC1E,IAAO,cAAc,GAAK,aAAa,MAAlB,CAAkB;IAC/C,IAAM,MAAM,GAAG,cAAc,GAAG,UAAU,CAAA;IAE1C,IAAI,KAAK,GAAG,CAAC,YAAY,GAAG,MAAM,CAAC,GAAG,UAAU,GAAG,UAAU,GAAG,GAAG,CAAA;IACnE,OAAO,KAAK,GAAG,CAAC;QAAE,KAAK,IAAI,GAAG,CAAA;IAE9B,OAAO,KAAK,CAAA;AACd,CAAC","sourcesContent":["import { forwardRef, useEffect, useRef, useState, type HTMLAttributes } from 'react'\nimport { Size } from 'spase'\nimport { useDragValueEffect } from '../hooks/useDragValueEffect'\nimport { useImageSize } from '../hooks/useImageSize'\nimport { useRect } from '../hooks/useRect'\nimport { asStyleDict } from '../utils'\n\nexport type PanoramaHTMLAttributes = Omit<HTMLAttributes<HTMLDivElement>, 'onResize'>\n\nexport type PanoramaProps = {\n /**\n * The current angle in degrees, 0.0 - 360.0, inclusive. When angle is 0 or\n * 360, the `zeroAnchor` position of the image is at the left bound of the\n * component.\n */\n angle?: number\n\n /**\n * The panning speed. This is expressed a multiplier of the number of pixels\n * dragged, i.e. when set to 1, the image will shift the same amount of pixels\n * that were dragged.\n */\n speed?: number\n\n /**\n * The source URL of the image.\n */\n src?: string\n\n /**\n * A decimal percentage of the image width indicating where 0° should be,\n * i.e. if `zeroAnchor` is `0`, the `angle` would be 0° when the left edge of\n * the image is at the left edge of the component.\n */\n zeroAnchor?: number\n\n /**\n * Handler invoked when the positionchanges. This can either be invoked from\n * the `angle` prop being changed or from the image being dragged.\n *\n * @param position The current position.\n * @param isDragging Specifies if the position change is due to dragging.\n */\n onPositionChange?: (position: number, isDragging: boolean) => void\n\n /**\n * Handler invoked when the angle changes. This can either be invoked from the\n * `angle` prop being changed or from the image being dragged. When `angle` is\n * being double-binded, ensure that the value is only being set by this\n * handler when `isDragging` is `true` to avoid potential update overflow.\n *\n * @param angle The current angle.\n * @param isDragging Specifies if the angle change is due to dragging.\n */\n onAngleChange?: (angle: number, isDragging: boolean) => void\n\n /**\n * Handler invoked when dragging starts.\n */\n onDragStart?: () => void\n\n /**\n * Handler invoked when dragging ends.\n */\n onDragEnd?: () => void\n\n /**\n * Handler invoked when the image begins loading.\n */\n onLoadImageStart?: () => void\n\n /**\n * Handler invoked when the image is done loading.\n */\n onLoadImageComplete?: () => void\n\n /**\n * Handler invoked when there is an error loading the image.\n */\n onLoadImageError?: () => void\n\n /**\n * Handler invoked when the image size changes. This is the actual size of the\n * loaded image. When no images are loaded yet, the size is `undefined`.\n *\n * @param size The actual size of the loaded iamge. If no images are loaded\n * yet, the size is `undefined`.\n */\n onImageSizeChange?: (size?: Size) => void\n}\n\n/**\n * A component containing a pannable 360° panorama image. The angle supports two-way binding.\n */\nexport const Panorama = forwardRef<HTMLDivElement, PanoramaHTMLAttributes & PanoramaProps>(({\n angle: externalAngle = 0,\n speed = 1,\n src,\n zeroAnchor = 0,\n onAngleChange,\n onPositionChange,\n onDragStart,\n onDragEnd,\n onLoadImageStart,\n onLoadImageComplete,\n onLoadImageError,\n onImageSizeChange,\n ...props\n}, ref) => {\n const mapDragPositionToDisplacement = (currentPosition: number, dx: number, dy: number): number => {\n const newDisplacement = currentPosition - dx * speed\n\n return newDisplacement\n }\n\n const bodyRef = useRef<HTMLDivElement>(null)\n const bodyRect = useRect(bodyRef)\n const imageSize = useImageSize({ src }, {\n onLoadStart: onLoadImageStart,\n onLoadComplete: onLoadImageComplete,\n onLoadError: onLoadImageError,\n })\n const [angle, setAngle] = useState(externalAngle)\n\n const { isDragging: [isDragging], value: [displacement, setDisplacement] } = useDragValueEffect(bodyRef, {\n initialValue: 0,\n transform: mapDragPositionToDisplacement,\n onDragStart,\n onDragEnd,\n })\n\n useEffect(() => {\n if (isDragging || !imageSize) return\n\n const newDisplacement = getDisplacementFromAngle(externalAngle, imageSize, bodyRect.size, zeroAnchor)\n\n if (newDisplacement !== displacement) {\n setDisplacement(newDisplacement)\n }\n\n if (externalAngle !== angle) {\n setAngle(externalAngle)\n }\n }, [externalAngle, imageSize, bodyRect.width, bodyRect.height, zeroAnchor])\n\n useEffect(() => {\n if (!isDragging || !imageSize) return\n\n const newAngle = getAngleFromDisplacement(displacement, imageSize, bodyRect.size, zeroAnchor)\n\n if (angle !== newAngle) {\n setAngle(newAngle)\n }\n }, [displacement, imageSize, bodyRect.width, bodyRect.height, zeroAnchor])\n\n useEffect(() => {\n onAngleChange?.(angle, isDragging)\n onPositionChange?.(angle / 360, isDragging)\n }, [angle])\n\n useEffect(() => {\n onImageSizeChange?.(imageSize)\n }, [imageSize?.width, imageSize?.height])\n\n const fixedStyles = getFixedStyles({ src, displacement })\n\n return (\n <div {...props} ref={ref} data-component='panorama'>\n <div ref={bodyRef} style={fixedStyles.body}/>\n </div>\n )\n})\n\nObject.defineProperty(Panorama, 'displayName', { value: 'Panorama', writable: false })\n\nfunction getFixedStyles({ src = '', displacement = NaN }) {\n return asStyleDict({\n body: {\n backgroundImage: `url(${src})`,\n backgroundPositionX: `${-displacement}px`,\n backgroundRepeat: 'repeat',\n backgroundSize: 'auto 100%',\n height: '100%',\n touchAction: 'none',\n width: '100%',\n },\n })\n}\n\nfunction getFilledImageSize(originalSize: Size, sizeToFill: Size): Size {\n const { width: originalWidth, height: originalHeight } = originalSize\n const { height: filledHeignt } = sizeToFill\n\n if (originalHeight <= 0) return new Size()\n\n const aspectRatio = filledHeignt / originalHeight\n const filledWidth = aspectRatio * originalWidth\n\n return new Size([filledWidth, filledHeignt])\n}\n\nfunction getDisplacementFromAngle(angle: number, originalImageSize: Size, componentSize: Size, zeroAnchor: number): number {\n const { width: imageWidth } = getFilledImageSize(originalImageSize, componentSize)\n const { width: componentWidth } = componentSize\n const offset = componentWidth * zeroAnchor\n\n return angle / 360 * imageWidth - offset\n}\n\nfunction getAngleFromDisplacement(displacement: number, originalImageSize: Size, componentSize: Size, zeroAnchor: number): number {\n const { width: imageWidth } = getFilledImageSize(originalImageSize, componentSize)\n const { width: componentWidth } = componentSize\n const offset = componentWidth * zeroAnchor\n\n let angle = (displacement + offset) % imageWidth / imageWidth * 360\n while (angle < 0) angle += 360\n\n return angle\n}\n"]}
@@ -1,71 +0,0 @@
1
- import { type HTMLAttributes, type PropsWithChildren } from 'react';
2
- import { type Size } from 'spase';
3
- import { type PanoramaProps } from './Panorama';
4
- export type PanoramaSliderProps = PanoramaProps & PropsWithChildren<{
5
- /**
6
- * Field-of-view (0.0 - 360.0 degrees, inclusive) that represents the size of
7
- * the reticle. 360 indicates the reticle covers the entire image. If this is
8
- * unspecified, the component will attempt to automatically calculate the FOV
9
- * using the `viewportSize` prop.
10
- */
11
- fov?: number;
12
- /**
13
- * Specifies which length (width or height) should be automatically
14
- * calculated. The counterpart must be known (if `width` is specified here,
15
- * the component's height must be known, i.e. it is specified in the CSS).
16
- * Defaults to `width`.
17
- */
18
- autoDimension?: 'width' | 'height';
19
- /**
20
- * Size of the viewport that this component is controlling. A viewport can be
21
- * thought of as a DOM element containing an aspect-filled image. This is used
22
- * to automatically calculate the FOV if `fov` prop is not specified. If it
23
- * is, this prop is ignored.
24
- */
25
- viewportSize?: Size;
26
- /**
27
- * Specifies if the component should use default styles.
28
- */
29
- usesDefaultStyles?: boolean;
30
- }>;
31
- /**
32
- * A slider for a {@link Panorama} component.
33
- *
34
- * @exports PanoramaSliderIndicator The indicator that appears when the slider
35
- * is being dragged.
36
- * @exports PanoramaSliderReticle The reticle that indicates the FOV of the
37
- * backing {@link Panorama}.
38
- * @exports PanoramaSliderTrack The slide track.
39
- */
40
- export declare const PanoramaSlider: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & PanoramaProps & {
41
- /**
42
- * Field-of-view (0.0 - 360.0 degrees, inclusive) that represents the size of
43
- * the reticle. 360 indicates the reticle covers the entire image. If this is
44
- * unspecified, the component will attempt to automatically calculate the FOV
45
- * using the `viewportSize` prop.
46
- */
47
- fov?: number;
48
- /**
49
- * Specifies which length (width or height) should be automatically
50
- * calculated. The counterpart must be known (if `width` is specified here,
51
- * the component's height must be known, i.e. it is specified in the CSS).
52
- * Defaults to `width`.
53
- */
54
- autoDimension?: "width" | "height";
55
- /**
56
- * Size of the viewport that this component is controlling. A viewport can be
57
- * thought of as a DOM element containing an aspect-filled image. This is used
58
- * to automatically calculate the FOV if `fov` prop is not specified. If it
59
- * is, this prop is ignored.
60
- */
61
- viewportSize?: Size;
62
- /**
63
- * Specifies if the component should use default styles.
64
- */
65
- usesDefaultStyles?: boolean;
66
- } & {
67
- children?: import("react").ReactNode | undefined;
68
- } & import("react").RefAttributes<HTMLDivElement>>;
69
- export declare const PanoramaSliderTrack: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement>>;
70
- export declare const PanoramaSliderReticle: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement>>;
71
- export declare const PanoramaSliderIndicator: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement>>;
@@ -1 +0,0 @@
1
- {"version":3,"file":"PanoramaSlider.js","sourceRoot":"/","sources":["components/PanoramaSlider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AC7G,OAAO,IAAA,mBAAW,EAAC;QACjB,IAAI,eACC,aAAa,KAAK,OAAO,CAAC,CAAC,CAAC;YAC7B,KAAK,EAAE,UAAG,YAAY,CAAC,MAAM,GAAG,WAAW,OAAI;SAChD,CAAC,CAAC,CAAC;YACF,MAAM,EAAE,UAAG,YAAY,CAAC,KAAK,GAAG,WAAW,OAAI;SAChD,CACF;QACD,IAAI,EAAE;YACJ,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,GAAG;YACT,QAAQ,EAAE,QAAQ;YAClB,aAAa,EAAE,MAAM;YACrB,QAAQ,EAAE,UAAU;YACpB,GAAG,EAAE,GAAG;YACR,KAAK,EAAE,MAAM;SACd;QACD,QAAQ,EAAE;YACR,MAAM,EAAE,MAAM;YACd,KAAK,EAAE,MAAM;SACd;QACD,QAAQ,EAAE;YACR,UAAU,EAAE,QAAQ;YACpB,OAAO,EAAE,MAAM;YACf,MAAM,EAAE,MAAM;YACd,cAAc,EAAE,YAAY;YAC5B,IAAI,EAAE,GAAG;YACT,QAAQ,EAAE,SAAS;YACnB,QAAQ,EAAE,UAAU;YACpB,GAAG,EAAE,GAAG;YACR,KAAK,EAAE,MAAM;SACd;QACD,KAAK,EAAE;YACL,IAAI,EAAE,UAAU;SACjB;QACD,OAAO,EAAE;YACP,KAAK,EAAE,UAAG,YAAY,OAAI;SAC3B;QACD,SAAS,EAAE;YACT,KAAK,EAAE,UAAG,YAAY,OAAI;SAC3B;KACF,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import clsx from 'clsx'\nimport { forwardRef, useRef, useState, type HTMLAttributes, type PropsWithChildren } from 'react'\nimport { Rect, type Size } from 'spase'\nimport { useRect } from '../hooks/useRect'\nimport { asComponentDict, asStyleDict, cloneStyledElement, styles } from '../utils'\nimport { Panorama, type PanoramaProps } from './Panorama'\n\nexport type PanoramaSliderProps = PanoramaProps & PropsWithChildren<{\n /**\n * Field-of-view (0.0 - 360.0 degrees, inclusive) that represents the size of\n * the reticle. 360 indicates the reticle covers the entire image. If this is\n * unspecified, the component will attempt to automatically calculate the FOV\n * using the `viewportSize` prop.\n */\n fov?: number\n\n /**\n * Specifies which length (width or height) should be automatically\n * calculated. The counterpart must be known (if `width` is specified here,\n * the component's height must be known, i.e. it is specified in the CSS).\n * Defaults to `width`.\n */\n autoDimension?: 'width' | 'height'\n\n /**\n * Size of the viewport that this component is controlling. A viewport can be\n * thought of as a DOM element containing an aspect-filled image. This is used\n * to automatically calculate the FOV if `fov` prop is not specified. If it\n * is, this prop is ignored.\n */\n viewportSize?: Size\n\n /**\n * Specifies if the component should use default styles.\n */\n usesDefaultStyles?: boolean\n}>\n\n/**\n * A slider for a {@link Panorama} component.\n *\n * @exports PanoramaSliderIndicator The indicator that appears when the slider\n * is being dragged.\n * @exports PanoramaSliderReticle The reticle that indicates the FOV of the\n * backing {@link Panorama}.\n * @exports PanoramaSliderTrack The slide track.\n */\nexport const PanoramaSlider = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement> & PanoramaSliderProps>(({\n className,\n style,\n angle = 0,\n autoDimension = 'width',\n children,\n fov,\n speed = 1,\n src,\n usesDefaultStyles = false,\n viewportSize,\n zeroAnchor = 0,\n onAngleChange,\n onDragEnd,\n onDragStart,\n onLoadImageComplete,\n onLoadImageError,\n onLoadImageStart,\n onImageSizeChange,\n onPositionChange,\n ...props\n}, ref) => {\n const getAspectRatio = () => {\n if (!imageSize) return 0\n const { width, height } = imageSize\n if (height === 0) return 0\n\n return width / height\n }\n\n const getReticleWidth = () => {\n const deg = Math.min(360, Math.max(0, fov ?? (viewportSize ? viewportSize.width / (viewportSize.height * aspectRatio) * 360 : 0)))\n\n return panoramaRect.width * (deg / 360)\n }\n\n const getAdjustedZeroAnchor = () => {\n if (panoramaRect.width <= 0) return zeroAnchor\n\n return ((panoramaRect.width - reticleWidth) * 0.5 + zeroAnchor * reticleWidth) / panoramaRect.width\n }\n\n const dragStartHandler = () => {\n setIsDragging(true)\n onDragStart?.()\n }\n\n const dragEndHandler = () => {\n setIsDragging(false)\n onDragEnd?.()\n }\n\n const panoramaRef = useRef<HTMLDivElement>(null)\n const panoramaRect = useRect(panoramaRef)\n\n const [imageSize, setImageSize] = useState<Size | undefined>()\n const [isDragging, setIsDragging] = useState(false)\n\n const aspectRatio = getAspectRatio()\n const reticleWidth = getReticleWidth()\n const adjustedZeroAnchor = getAdjustedZeroAnchor()\n\n const components = asComponentDict(children, {\n track: PanoramaSliderTrack,\n reticle: PanoramaSliderReticle,\n indicator: PanoramaSliderIndicator,\n })\n\n const fixedStyles = getFixedStyles({ autoDimension, panoramaRect, aspectRatio, reticleWidth })\n const defaultStyles = usesDefaultStyles ? getDefaultStyles({ isDragging }) : undefined\n\n return (\n <div {...props} ref={ref} className={clsx(className, { dragging: isDragging })} data-component='panorama-slider' style={styles(style, fixedStyles.root)}>\n <Panorama\n ref={panoramaRef}\n angle={angle}\n speed={speed}\n src={src}\n style={fixedStyles.panorama}\n zeroAnchor={adjustedZeroAnchor}\n onAngleChange={onAngleChange}\n onDragEnd={dragEndHandler}\n onDragStart={dragStartHandler}\n onImageSizeChange={setImageSize}\n onLoadImageComplete={onLoadImageComplete}\n onLoadImageError={onLoadImageError}\n onLoadImageStart={onLoadImageStart}\n onPositionChange={onPositionChange}\n />\n <div style={fixedStyles.body}>\n <div style={fixedStyles.controls}>\n {cloneStyledElement(components.track ?? <PanoramaSliderTrack style={defaultStyles?.track}/>, {\n style: styles(fixedStyles.track),\n })}\n {cloneStyledElement(components.reticle ?? <PanoramaSliderReticle style={defaultStyles?.reticle}/>, {\n style: styles(fixedStyles.reticle),\n })}\n {cloneStyledElement(components.track ?? <PanoramaSliderTrack style={defaultStyles?.track}/>, {\n style: styles(fixedStyles.track),\n })}\n </div>\n </div>\n {cloneStyledElement(components.indicator ?? <PanoramaSliderIndicator style={defaultStyles?.indicator}/>, {\n style: styles(fixedStyles.indicator),\n })}\n </div>\n )\n})\n\nObject.defineProperty(PanoramaSlider, 'displayName', { value: 'PanoramaSlider', writable: false })\n\nexport const PanoramaSliderTrack = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(({ ...props }, ref) => <div {...props} ref={ref} data-child='track'/>)\n\nexport const PanoramaSliderReticle = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(({ ...props }, ref) => <div {...props} ref={ref} data-child='reticle'/>)\n\nexport const PanoramaSliderIndicator = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(({ ...props }, ref) => <div {...props} ref={ref} data-child='indicator'/>)\n\nfunction getDefaultStyles({ isDragging = false }) {\n return asStyleDict({\n track: {\n background: 'rgba(0, 0, 0, .7)',\n height: '100%',\n },\n reticle: {\n background: `rgba(0, 0, 0, ${isDragging ? 0 : 0.3})`,\n flex: '0 0 auto',\n height: '100%',\n transitionDuration: '100ms',\n transitionProperty: 'background',\n transitionTimingFunction: 'ease-out',\n },\n indicator: {\n background: '#fff',\n borderRadius: '2px',\n bottom: '-10px',\n boxSizing: 'border-box',\n display: 'block',\n height: '2px',\n left: '0',\n margin: '0 auto',\n opacity: isDragging ? 1 : 0,\n position: 'absolute',\n right: '0',\n transition: 'opacity .3s ease-out',\n },\n })\n}\n\nfunction getFixedStyles({ autoDimension = 'width', panoramaRect = new Rect(), aspectRatio = 0, reticleWidth = 0 }) {\n return asStyleDict({\n root: {\n ...autoDimension === 'width' ? {\n width: `${panoramaRect.height * aspectRatio}px`,\n } : {\n height: `${panoramaRect.width / aspectRatio}px`,\n },\n },\n body: {\n height: '100%',\n left: '0',\n overflow: 'hidden',\n pointerEvents: 'none',\n position: 'absolute',\n top: '0',\n width: '100%',\n },\n panorama: {\n height: '100%',\n width: '100%',\n },\n controls: {\n alignItems: 'center',\n display: 'flex',\n height: '100%',\n justifyContent: 'flex-start',\n left: '0',\n overflow: 'visible',\n position: 'absolute',\n top: '0',\n width: '100%',\n },\n track: {\n flex: '1 0 auto',\n },\n reticle: {\n width: `${reticleWidth}px`,\n },\n indicator: {\n width: `${reticleWidth}px`,\n },\n })\n}\n"]}
@@ -1,34 +0,0 @@
1
- import { type HTMLAttributes, type PropsWithChildren } from 'react';
2
- type Orientation = 'horizontal' | 'vertical';
3
- type Range = [number, number];
4
- export type RangeSliderProps = PropsWithChildren<{
5
- areLabelsVisible?: boolean;
6
- decimalPlaces?: number;
7
- knobPadding?: number;
8
- max: number;
9
- min: number;
10
- orientation?: Orientation;
11
- range?: Range;
12
- steps?: number;
13
- usesDefaultStyles?: boolean;
14
- onRangeChange?: (range: Range) => void;
15
- }>;
16
- export declare const RangeSlider: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & {
17
- areLabelsVisible?: boolean;
18
- decimalPlaces?: number;
19
- knobPadding?: number;
20
- max: number;
21
- min: number;
22
- orientation?: Orientation;
23
- range?: Range;
24
- steps?: number;
25
- usesDefaultStyles?: boolean;
26
- onRangeChange?: (range: Range) => void;
27
- } & {
28
- children?: import("react").ReactNode | undefined;
29
- } & import("react").RefAttributes<HTMLDivElement>>;
30
- export declare const RangeSliderGutter: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement>>;
31
- export declare const RangeSliderLabel: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement>>;
32
- export declare const RangeSliderHighlight: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement>>;
33
- export declare const RangeSliderKnob: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement>>;
34
- export {};
@@ -1 +0,0 @@
1
- {"version":3,"file":"RangeSlider.js","sourceRoot":"/","sources":["components/RangeSlider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAuB;AACvB,gEAA+C;AAC/C,+BAA4G;AAC5G,kEAAgE;AAChE,4CAA0C;AAC1C,kCAA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equal/react'\nimport { forwardRef, useEffect, useRef, useState, type HTMLAttributes, type PropsWithChildren } from 'react'\nimport { useDragValueEffect } from '../hooks/useDragValueEffect'\nimport { useRect } from '../hooks/useRect'\nimport { asComponentDict, asStyleDict, cloneStyledElement, styles } from '../utils'\n\ntype Orientation = 'horizontal' | 'vertical'\n\ntype Range = [number, number]\n\nexport type RangeSliderProps = PropsWithChildren<{\n areLabelsVisible?: boolean\n decimalPlaces?: number\n knobPadding?: number\n max: number\n min: number\n orientation?: Orientation\n range?: Range\n steps?: number\n usesDefaultStyles?: boolean\n onRangeChange?: (range: Range) => void\n}>\n\nexport const RangeSlider = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement> & RangeSliderProps>(({\n children,\n className,\n areLabelsVisible = true,\n decimalPlaces = 2,\n knobPadding = 20,\n max: maxValue,\n min: minValue,\n orientation = 'vertical',\n range: externalRange,\n steps = -1,\n usesDefaultStyles = false,\n onRangeChange,\n ...props\n}, ref) => {\n const getPositionByValue = (value: number) => (value - minValue) / (maxValue - minValue)\n const getPositionByDisplacement = (displacement: number) => displacement / (orientation === 'horizontal' ? bodyRect.width : bodyRect.height)\n const getValueByPosition = (position: number) => position * (maxValue - minValue) + minValue\n const getValueByDisplacement = (displacement: number) => getValueByPosition(getPositionByDisplacement(displacement))\n const getDisplacementByPosition = (position: number) => position * (orientation === 'horizontal' ? bodyRect.width : bodyRect.height)\n const getDisplacementByValue = (value: number) => getDisplacementByPosition(getPositionByValue(value))\n\n const getClosestSteppedValue = (value: number) => {\n const n = breakpoints.length\n let idx = 0\n let diff = Infinity\n\n for (let i = 0; i < n; i++) {\n const t = breakpoints[i]\n const d = Math.abs(value - t)\n\n if (d < diff) {\n diff = d\n idx = i\n }\n }\n\n return breakpoints[idx]\n }\n\n const bodyRef = useRef<HTMLDivElement>(null)\n const bodyRect = useRect(bodyRef)\n const startKnobRef = useRef<HTMLDivElement>(null)\n const endKnobRef = useRef<HTMLDivElement>(null)\n const [range, setRange] = useState<Range>(externalRange ?? [minValue, maxValue])\n\n const { isDragging: [isDraggingStartKnob], isReleasing: [isReleasingStartKnob], value: [startValue, setStartValue] } = useDragValueEffect(startKnobRef, {\n initialValue: externalRange?.[0] ?? minValue,\n transform: (value: number, dx: number, dy: number) => {\n const delta = orientation === 'horizontal' ? dx : dy\n const dMin = getDisplacementByValue(minValue)\n const dMax = getDisplacementByValue(range[1])\n const dCurr = getDisplacementByValue(value) + delta\n\n return getValueByDisplacement(Math.max(dMin, Math.min(dMax, dCurr)))\n },\n }, [minValue, orientation, bodyRect.size.width, bodyRect.size.height, range[1]])\n\n const { isDragging: [isDraggingEndKnob], isReleasing: [isReleasingEndKnob], value: [endValue, setEndValue] } = useDragValueEffect(endKnobRef, {\n initialValue: externalRange?.[1] ?? maxValue,\n transform: (value: number, dx: number, dy: number) => {\n const delta = orientation === 'horizontal' ? dx : dy\n const dMin = getDisplacementByValue(range[0])\n const dMax = getDisplacementByValue(maxValue)\n const dCurr = getDisplacementByValue(value) + delta\n\n return getValueByDisplacement(Math.max(dMin, Math.min(dMax, dCurr)))\n },\n }, [maxValue, orientation, bodyRect.size.width, bodyRect.size.height, range[0]])\n\n const breakpoints = [minValue, ...[...Array(steps)].map((v, i) => minValue + (i + 1) * (maxValue - minValue) / (1 + steps)), maxValue]\n const [start, end] = range.map(getDisplacementByValue)\n const highlightLength = end - start\n\n useEffect(() => {\n if (range[0] === startValue) return\n setRange([startValue, range[1]])\n onRangeChange?.(range)\n }, [startValue])\n\n useEffect(() => {\n if (range[1] === endValue) return\n setRange([range[0], endValue])\n onRangeChange?.(range)\n }, [endValue])\n\n useEffect(() => {\n if (isDraggingStartKnob || isDraggingEndKnob || isDeepEqual(externalRange, range)) return\n setRange(externalRange ?? [minValue, maxValue])\n }, [externalRange])\n\n useEffect(() => {\n if (steps < 0) return\n setStartValue(getClosestSteppedValue(startValue))\n }, [isReleasingStartKnob])\n\n useEffect(() => {\n if (steps < 0 || !isReleasingEndKnob) return\n setEndValue(getClosestSteppedValue(endValue))\n }, [isReleasingEndKnob])\n\n const components = asComponentDict(children, {\n gutter: RangeSliderGutter,\n highlight: RangeSliderHighlight,\n knob: RangeSliderKnob,\n label: RangeSliderLabel,\n })\n\n const fixedStyles = getFixedStyles({ orientation, highlightLength, start, knobPadding })\n const defaultStyles = usesDefaultStyles ? getDefaultStyles({ isReleasingStartKnob, isReleasingEndKnob, orientation }) : undefined\n\n return (\n <div {...props} ref={ref} className={clsx(className, orientation)} data-component='range-slider'>\n <div ref={bodyRef} style={fixedStyles.body}>\n {cloneStyledElement(components.gutter ?? <RangeSliderGutter style={defaultStyles?.gutter}/>, {\n style: styles(fixedStyles.gutter),\n })}\n {cloneStyledElement(components.highlight ?? <RangeSliderHighlight style={defaultStyles?.highlight}/>, {\n style: styles(fixedStyles.highlight),\n })}\n {cloneStyledElement(components.knob ?? <RangeSliderKnob\n style={styles(defaultStyles?.knob, {\n transitionProperty: isReleasingStartKnob ? 'opacity, transform' : 'opacity',\n })}\n />, {\n ref: startKnobRef,\n disabled: isDeepEqual([startValue, endValue], [maxValue, maxValue]),\n className: clsx({\n dragging: isDraggingStartKnob,\n releasing: isReleasingStartKnob,\n }),\n style: styles(fixedStyles.knob, {\n pointerEvents: isDeepEqual([startValue, endValue], [minValue, minValue]) ? 'none' : 'auto',\n }, orientation === 'horizontal' ? {\n marginLeft: `${start}px`,\n } : {\n marginTop: `${start}px`,\n }),\n }, <div style={fixedStyles.knobHitbox}/>, areLabelsVisible && cloneStyledElement(components.label ?? <RangeSliderLabel\n style={styles(defaultStyles?.label, {\n transitionProperty: isReleasingStartKnob ? 'opacity, transform' : 'opacity',\n })}\n />, {\n className: clsx({\n dragging: isDraggingStartKnob || isDraggingEndKnob,\n releasing: isReleasingStartKnob || isReleasingEndKnob,\n }),\n style: styles(fixedStyles.label),\n }, Number(startValue.toFixed(decimalPlaces)).toLocaleString()))}\n {cloneStyledElement(components.knob ?? <RangeSliderKnob\n style={styles(defaultStyles?.knob, {\n transitionProperty: isReleasingEndKnob ? 'opacity, transform' : 'opacity',\n })}\n />, {\n ref: endKnobRef,\n disabled: isDeepEqual([startValue, endValue], [maxValue, maxValue]),\n className: clsx({\n dragging: isDraggingEndKnob,\n releasing: isDraggingEndKnob,\n }),\n style: styles(fixedStyles.knob, {\n pointerEvents: isDeepEqual([startValue, endValue], [maxValue, maxValue]) ? 'none' : 'auto',\n }, orientation === 'horizontal' ? {\n marginLeft: `${end}px`,\n } : {\n marginTop: `${end}px`,\n }),\n }, <div style={fixedStyles.knobHitbox}/>, areLabelsVisible && cloneStyledElement(components.label ?? <RangeSliderLabel\n style={styles(defaultStyles?.label, {\n transitionProperty: isReleasingEndKnob ? 'opacity, transform' : 'opacity',\n })}\n />, {\n className: clsx({\n dragging: isDraggingEndKnob,\n releasing: isReleasingEndKnob,\n }),\n style: styles(fixedStyles.label),\n }, Number(endValue.toFixed(decimalPlaces)).toLocaleString()))}\n </div>\n </div>\n )\n})\n\nObject.defineProperty(RangeSlider, 'displayName', { value: 'RangeSlider', writable: false })\n\nexport const RangeSliderGutter = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(({ ...props }, ref) => <div {...props} ref={ref} data-child='gutter'/>)\n\nexport const RangeSliderLabel = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(({ ...props }, ref) => <div {...props} ref={ref} data-child='label'/>)\n\nexport const RangeSliderHighlight = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(({ ...props }, ref) => <div {...props} ref={ref} data-child='highlight'/>)\n\nexport const RangeSliderKnob = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(({ ...props }, ref) => <div {...props} ref={ref} data-child='knob'/>)\n\nfunction getFixedStyles({ orientation = 'horizontal', highlightLength = 0, start = 0, knobPadding = 0 }) {\n return asStyleDict({\n body: {\n height: '100%',\n width: '100%',\n },\n gutter: {\n display: 'block',\n top: '0',\n left: '0',\n position: 'absolute',\n width: '100%',\n height: '100%',\n },\n highlight: {\n height: '100%',\n left: '0',\n position: 'absolute',\n top: '0',\n ...orientation === 'horizontal' ? {\n width: `${highlightLength}px`,\n transform: `translate3d(${start}px, 0, 0)`,\n } : {\n height: `${highlightLength}px`,\n transform: `translate3d(0, ${start}px, 0)`,\n },\n },\n knob: {\n bottom: '0',\n left: '0',\n margin: 'auto',\n position: 'absolute',\n right: '0',\n top: '0',\n touchAction: 'none',\n zIndex: '1',\n },\n knobHitbox: {\n background: 'transparent',\n height: `calc(100% + ${knobPadding * 2}px)`,\n left: `-${knobPadding}px`,\n padding: `${knobPadding}px`,\n position: 'absolute',\n top: `-${knobPadding}px`,\n width: `calc(100% + ${knobPadding * 2}px)`,\n },\n label: {\n pointerEvents: 'none',\n position: 'relative',\n userSelect: 'none',\n },\n })\n}\n\nfunction getDefaultStyles({ isReleasingStartKnob = false, isReleasingEndKnob = false, orientation = 'horizontal' }) {\n return asStyleDict({\n gutter: {\n background: 'rgba(255, 255, 255, .2)',\n },\n highlight: {\n background: '#fff',\n transitionDuration: '100ms',\n transitionProperty: (isReleasingStartKnob ? !isReleasingEndKnob : isReleasingEndKnob) ? 'opacity, width, transform' : 'opacity',\n transitionTimingFunction: 'ease-out',\n },\n knob: {\n alignItems: 'center',\n background: '#fff',\n borderRadius: '10px',\n boxSizing: 'border-box',\n display: 'flex',\n height: '20px',\n justifyContent: 'center',\n transitionDuration: '100ms',\n transitionTimingFunction: 'ease-out',\n width: '20px',\n },\n label: {\n background: 'transparent',\n color: '#fff',\n textAlign: 'center',\n transitionDuration: '100ms',\n transitionTimingFunction: 'ease-out',\n ...orientation === 'horizontal' ? {\n top: 'calc(100% + 10px)',\n } : {\n left: 'calc(100% + 10px)',\n },\n },\n })\n}\n"]}
@@ -1,91 +0,0 @@
1
- import { type ComponentType, type HTMLAttributes, type PropsWithChildren } from 'react';
2
- export type RotatingGalleryImageProps = HTMLAttributes<HTMLElement> & {
3
- index: number;
4
- isVisible: boolean;
5
- src: string;
6
- };
7
- export type RotatingGalleryProps = HTMLAttributes<HTMLDivElement> & PropsWithChildren<{
8
- /**
9
- * Current image index. An error is thrown if the index is invalid (must be
10
- * between 0 and length of `srcs` - 1, inclusive). This prop supports two-way
11
- * binding.
12
- */
13
- index?: number;
14
- /**
15
- * Specifies if lazy loading of images should be enabled.
16
- */
17
- lazy?: boolean;
18
- /**
19
- * The duration of one rotation in milliseconds (how long one image stays
20
- * before transitioning to the next). Specifying `NaN` or a negative number
21
- * will prevent the component from automatically rotating.
22
- */
23
- rotationDuration?: number;
24
- /**
25
- * An array of image paths.
26
- */
27
- srcs?: string[];
28
- /**
29
- * The duration of an image transition in milliseconds.
30
- */
31
- transitionDuration?: number;
32
- /**
33
- * Specifies if the component should use default styles.
34
- */
35
- usesDefaultStyles?: boolean;
36
- /**
37
- * Handler invoked when the image index changes.
38
- *
39
- * @param index The current image index.
40
- */
41
- onIndexChange?: (index: number) => void;
42
- /**
43
- * Component type for generating images in this collection.
44
- */
45
- ImageComponent?: ComponentType<RotatingGalleryImageProps>;
46
- }>;
47
- /**
48
- * A component displaying rotating images.
49
- */
50
- export declare const RotatingGallery: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & {
51
- /**
52
- * Current image index. An error is thrown if the index is invalid (must be
53
- * between 0 and length of `srcs` - 1, inclusive). This prop supports two-way
54
- * binding.
55
- */
56
- index?: number;
57
- /**
58
- * Specifies if lazy loading of images should be enabled.
59
- */
60
- lazy?: boolean;
61
- /**
62
- * The duration of one rotation in milliseconds (how long one image stays
63
- * before transitioning to the next). Specifying `NaN` or a negative number
64
- * will prevent the component from automatically rotating.
65
- */
66
- rotationDuration?: number;
67
- /**
68
- * An array of image paths.
69
- */
70
- srcs?: string[];
71
- /**
72
- * The duration of an image transition in milliseconds.
73
- */
74
- transitionDuration?: number;
75
- /**
76
- * Specifies if the component should use default styles.
77
- */
78
- usesDefaultStyles?: boolean;
79
- /**
80
- * Handler invoked when the image index changes.
81
- *
82
- * @param index The current image index.
83
- */
84
- onIndexChange?: (index: number) => void;
85
- /**
86
- * Component type for generating images in this collection.
87
- */
88
- ImageComponent?: ComponentType<RotatingGalleryImageProps>;
89
- } & {
90
- children?: import("react").ReactNode | undefined;
91
- } & import("react").RefAttributes<HTMLDivElement>>;