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.
- package/components/Accordion.js +171 -205
- package/components/BurgerButton.js +40 -94
- package/components/Carousel.js +87 -123
- package/components/Collection.js +84 -120
- package/components/Counter.js +32 -63
- package/components/CoverImage.js +24 -68
- package/components/CoverVideo.js +25 -69
- package/components/DebugConsole.js +27 -79
- package/components/Dial.js +28 -65
- package/components/Dropdown.js +86 -98
- package/components/FlatSVG.js +22 -71
- package/components/Image.js +21 -50
- package/components/MasonryGrid.js +122 -257
- package/components/Panorama.js +48 -92
- package/components/PanoramaSlider.js +57 -113
- package/components/RangeSlider.js +125 -182
- package/components/RotatingGallery.js +28 -59
- package/components/SelectableButton.js +10 -54
- package/components/Slider.js +108 -159
- package/components/StepwiseSlider.js +124 -176
- package/components/SwipeContainer.js +30 -73
- package/components/TextField.js +12 -49
- package/components/Video.js +31 -61
- package/components/WithTooltip.js +117 -111
- package/components/index.js +24 -0
- package/hooks/index.js +17 -0
- package/hooks/useClickOutsideEffect.js +8 -38
- package/hooks/useDragEffect.js +20 -53
- package/hooks/useDragValueEffect.js +31 -81
- package/hooks/useImageSize.js +16 -38
- package/hooks/useInterval.js +9 -41
- package/hooks/useLoadImageEffect.js +15 -48
- package/hooks/useLoadVideoMetadataEffect.js +15 -48
- package/hooks/useMounted.js +5 -25
- package/hooks/usePrevious.js +4 -9
- package/hooks/useRect.js +9 -29
- package/hooks/useResizeEffect.js +10 -44
- package/hooks/useScrollPositionEffect.js +19 -50
- package/hooks/useSearchParamState.js +12 -34
- package/hooks/useSize.js +9 -29
- package/hooks/useTimeout.js +8 -38
- package/hooks/useVideoSize.js +16 -38
- package/hooks/useViewportSize.js +7 -27
- package/operators/Conditional.js +6 -11
- package/operators/Each.js +6 -14
- package/operators/ExtractChild.js +9 -36
- package/operators/ExtractChildren.js +7 -34
- package/operators/Repeat.js +4 -37
- package/operators/index.js +5 -0
- package/package.json +27 -41
- package/providers/ScrollPositionProvider.js +37 -60
- package/providers/index.js +1 -0
- package/utils/asClassNameDict.js +1 -5
- package/utils/asComponentDict.js +11 -16
- package/utils/asStyleDict.js +1 -5
- package/utils/cloneStyledElement.js +14 -61
- package/utils/index.js +5 -22
- package/utils/styles.js +5 -21
- package/components/Accordion.d.ts +0 -219
- package/components/Accordion.js.map +0 -1
- package/components/BurgerButton.d.ts +0 -34
- package/components/BurgerButton.js.map +0 -1
- package/components/Carousel.d.ts +0 -53
- package/components/Carousel.js.map +0 -1
- package/components/Collection.d.ts +0 -171
- package/components/Collection.js.map +0 -1
- package/components/Counter.d.ts +0 -11
- package/components/Counter.js.map +0 -1
- package/components/CoverImage.d.ts +0 -28
- package/components/CoverImage.js.map +0 -1
- package/components/CoverVideo.d.ts +0 -28
- package/components/CoverVideo.js.map +0 -1
- package/components/DebugConsole.d.ts +0 -15
- package/components/DebugConsole.js.map +0 -1
- package/components/Dial.d.ts +0 -79
- package/components/Dial.js.map +0 -1
- package/components/Dropdown.d.ts +0 -109
- package/components/Dropdown.js.map +0 -1
- package/components/FlatSVG.d.ts +0 -72
- package/components/FlatSVG.js.map +0 -1
- package/components/Image.d.ts +0 -144
- package/components/Image.js.map +0 -1
- package/components/MasonryGrid.d.ts +0 -29
- package/components/MasonryGrid.js.map +0 -1
- package/components/Panorama.d.ts +0 -77
- package/components/Panorama.js.map +0 -1
- package/components/PanoramaSlider.d.ts +0 -71
- package/components/PanoramaSlider.js.map +0 -1
- package/components/RangeSlider.d.ts +0 -34
- package/components/RangeSlider.js.map +0 -1
- package/components/RotatingGallery.d.ts +0 -91
- package/components/RotatingGallery.js.map +0 -1
- package/components/SelectableButton.d.ts +0 -19
- package/components/SelectableButton.js.map +0 -1
- package/components/Slider.d.ts +0 -160
- package/components/Slider.js.map +0 -1
- package/components/StepwiseSlider.d.ts +0 -215
- package/components/StepwiseSlider.js.map +0 -1
- package/components/SwipeContainer.d.ts +0 -21
- package/components/SwipeContainer.js.map +0 -1
- package/components/TextField.d.ts +0 -21
- package/components/TextField.js.map +0 -1
- package/components/Video.d.ts +0 -38
- package/components/Video.js.map +0 -1
- package/components/WithTooltip.d.ts +0 -32
- package/components/WithTooltip.js.map +0 -1
- package/hooks/useClickOutsideEffect.d.ts +0 -2
- package/hooks/useClickOutsideEffect.js.map +0 -1
- package/hooks/useDragEffect.d.ts +0 -48
- package/hooks/useDragEffect.js.map +0 -1
- package/hooks/useDragValueEffect.d.ts +0 -56
- package/hooks/useDragValueEffect.js.map +0 -1
- package/hooks/useImageSize.d.ts +0 -21
- package/hooks/useImageSize.js.map +0 -1
- package/hooks/useInterval.d.ts +0 -18
- package/hooks/useInterval.js.map +0 -1
- package/hooks/useLoadImageEffect.d.ts +0 -43
- package/hooks/useLoadImageEffect.js.map +0 -1
- package/hooks/useLoadVideoMetadataEffect.d.ts +0 -35
- package/hooks/useLoadVideoMetadataEffect.js.map +0 -1
- package/hooks/useMounted.d.ts +0 -1
- package/hooks/useMounted.js.map +0 -1
- package/hooks/usePrevious.d.ts +0 -19
- package/hooks/usePrevious.js.map +0 -1
- package/hooks/useRect.d.ts +0 -11
- package/hooks/useRect.js.map +0 -1
- package/hooks/useResizeEffect.d.ts +0 -17
- package/hooks/useResizeEffect.js.map +0 -1
- package/hooks/useScrollPositionEffect.d.ts +0 -13
- package/hooks/useScrollPositionEffect.js.map +0 -1
- package/hooks/useSearchParamState.d.ts +0 -34
- package/hooks/useSearchParamState.js.map +0 -1
- package/hooks/useSize.d.ts +0 -10
- package/hooks/useSize.js.map +0 -1
- package/hooks/useTimeout.d.ts +0 -10
- package/hooks/useTimeout.js.map +0 -1
- package/hooks/useVideoSize.d.ts +0 -21
- package/hooks/useVideoSize.js.map +0 -1
- package/hooks/useViewportSize.d.ts +0 -7
- package/hooks/useViewportSize.js.map +0 -1
- package/operators/Conditional.d.ts +0 -5
- package/operators/Conditional.js.map +0 -1
- package/operators/Each.d.ts +0 -7
- package/operators/Each.js.map +0 -1
- package/operators/ExtractChild.d.ts +0 -8
- package/operators/ExtractChild.js.map +0 -1
- package/operators/ExtractChildren.d.ts +0 -6
- package/operators/ExtractChildren.js.map +0 -1
- package/operators/Repeat.d.ts +0 -11
- package/operators/Repeat.js.map +0 -1
- package/providers/ScrollPositionProvider.d.ts +0 -15
- package/providers/ScrollPositionProvider.js.map +0 -1
- package/utils/asClassNameDict.d.ts +0 -3
- package/utils/asClassNameDict.js.map +0 -1
- package/utils/asComponentDict.d.ts +0 -5
- package/utils/asComponentDict.js.map +0 -1
- package/utils/asStyleDict.d.ts +0 -4
- package/utils/asStyleDict.js.map +0 -1
- package/utils/cloneStyledElement.d.ts +0 -18
- package/utils/cloneStyledElement.js.map +0 -1
- package/utils/index.d.ts +0 -5
- package/utils/index.js.map +0 -1
- package/utils/styles.d.ts +0 -2
- package/utils/styles.js.map +0 -1
package/hooks/useSize.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useSize.js","sourceRoot":"/","sources":["hooks/useSize.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAWA,0BAeC;AA1BD,+BAAgD;AAChD,+BAAuC;AACvC,qDAAmD;AAEnD;;;;;;GAMG;AACH,SAAgB,OAAO,CAAC,SAAiC;IACjD,IAAA,KAAA,OAAkB,IAAA,gBAAQ,EAAO,IAAI,YAAI,EAAE,CAAC,IAAA,EAA3C,IAAI,QAAA,EAAE,OAAO,QAA8B,CAAA;IAElD,IAAM,YAAY,GAAG,UAAC,OAAoB;QACxC,IAAM,OAAO,GAAG,YAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAClC,IAAI,CAAC,OAAO;YAAE,OAAM;QAEpB,OAAO,CAAC,OAAO,CAAC,CAAA;IAClB,CAAC,CAAA;IAED,IAAA,iCAAe,EAAC,SAAS,EAAE;QACzB,QAAQ,EAAE,UAAA,OAAO,IAAI,OAAA,YAAY,CAAC,OAAO,CAAC,EAArB,CAAqB;KAC3C,CAAC,CAAA;IAEF,OAAO,IAAI,CAAC,IAAI,CAAA;AAClB,CAAC","sourcesContent":["import { useState, type RefObject } from 'react'\nimport { Rect, type Size } from 'spase'\nimport { useResizeEffect } from './useResizeEffect'\n\n/**\n * Hook for monitoring changes in and returning the size of the target element.\n *\n * @param targetRef Reference to the target element.\n *\n * @returns The most current {@link Size} of the target element.\n */\nexport function useSize(targetRef: RefObject<HTMLElement>): Size {\n const [rect, setRect] = useState<Rect>(new Rect())\n\n const handleResize = (element: HTMLElement) => {\n const newRect = Rect.from(element)\n if (!newRect) return\n\n setRect(newRect)\n }\n\n useResizeEffect(targetRef, {\n onResize: element => handleResize(element),\n })\n\n return rect.size\n}\n"]}
|
package/hooks/useTimeout.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type DependencyList } from 'react';
|
|
2
|
-
/**
|
|
3
|
-
* Hoook for invoking a method after a set timeout.
|
|
4
|
-
*
|
|
5
|
-
* @param handler The method to invoke.
|
|
6
|
-
* @param timeout Time (in milliseconds) for the timeout. If the value is
|
|
7
|
-
* `undefined` or less than 0, the timeout is disabled.
|
|
8
|
-
* @param deps Dependencies that trigger this effect.
|
|
9
|
-
*/
|
|
10
|
-
export declare function useTimeout(handler: () => void, timeout?: number, deps?: DependencyList): void;
|
package/hooks/useTimeout.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useTimeout.js","sourceRoot":"/","sources":["hooks/useTimeout.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,gCAcC;AAxBD,+BAA8D;AAE9D;;;;;;;GAOG;AACH,SAAgB,UAAU,CAAC,OAAmB,EAAE,OAAgB,EAAE,IAAyB;IAAzB,qBAAA,EAAA,SAAyB;IACzF,IAAM,UAAU,GAAG,IAAA,cAAM,GAAgB,CAAA;IAEzC,IAAA,iBAAS,EAAC;QACR,UAAU,CAAC,OAAO,GAAG,OAAO,CAAA;IAC9B,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAA;IAEb,IAAA,iBAAS,EAAC;QACR,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,GAAG,CAAC;YAAE,OAAM;QAEhD,IAAM,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,sBAAM,OAAA,MAAA,UAAU,CAAC,OAAO,0DAAI,CAAA,EAAA,EAAE,OAAO,CAAC,CAAA;QAEtE,OAAO,cAAM,OAAA,YAAY,CAAC,KAAK,CAAC,EAAnB,CAAmB,CAAA;IAClC,CAAC,iBAAG,OAAO,UAAK,IAAI,UAAE,CAAA;AACxB,CAAC","sourcesContent":["import { useEffect, useRef, type DependencyList } from 'react'\n\n/**\n * Hoook for invoking a method after a set timeout.\n *\n * @param handler The method to invoke.\n * @param timeout Time (in milliseconds) for the timeout. If the value is\n * `undefined` or less than 0, the timeout is disabled.\n * @param deps Dependencies that trigger this effect.\n */\nexport function useTimeout(handler: () => void, timeout?: number, deps: DependencyList = []) {\n const handlerRef = useRef<(() => void)>()\n\n useEffect(() => {\n handlerRef.current = handler\n }, [handler])\n\n useEffect(() => {\n if (timeout === undefined || timeout < 0) return\n\n const timer = window.setTimeout(() => handlerRef.current?.(), timeout)\n\n return () => clearTimeout(timer)\n }, [timeout, ...deps])\n}\n"]}
|
package/hooks/useVideoSize.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Size } from 'spase';
|
|
2
|
-
import { type UseLoadVideoMetadataEffectOptions, type UseLoadVideoMetadataEffectParams } from './useLoadVideoMetadataEffect';
|
|
3
|
-
type Params = UseLoadVideoMetadataEffectParams;
|
|
4
|
-
type Options = UseLoadVideoMetadataEffectOptions & {
|
|
5
|
-
/**
|
|
6
|
-
* If `false`, the size will be reset to `undefined` when the video begins
|
|
7
|
-
* loading or when an error occurs. Defaults to `true`.
|
|
8
|
-
*/
|
|
9
|
-
preservesSizeBetweenLoads?: boolean;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Hook for retrieving the size of a video.
|
|
13
|
-
*
|
|
14
|
-
* @param params See {@link Params}.
|
|
15
|
-
* @param options See {@link Options}.
|
|
16
|
-
*
|
|
17
|
-
* @returns The actual size of the video if loading was successful, `undefined`
|
|
18
|
-
* otherwise.
|
|
19
|
-
*/
|
|
20
|
-
export declare function useVideoSize({ src }: Params, { preservesSizeBetweenLoads, onLoadStart, onLoadComplete, onLoadError }?: Options): Size | undefined;
|
|
21
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useVideoSize.js","sourceRoot":"/","sources":["hooks/useVideoSize.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAuBA,oCA4BC;AAnDD,+BAAgC;AAChC,+BAA4B;AAC5B,2EAAwJ;AAYxJ;;;;;;;;GAQG;AACH,SAAgB,YAAY,CAAC,EAAe,EAAE,EAA4F;QAA3G,GAAG,SAAA;QAAY,qBAA0F,EAAE,KAAA,EAA1F,iCAAgC,EAAhC,yBAAyB,mBAAG,IAAI,KAAA,EAAE,WAAW,iBAAA,EAAE,cAAc,oBAAA,EAAE,WAAW,iBAAA;IACxH,IAAM,UAAU,GAAG,UAAC,OAAyB;QAC3C,IAAI,CAAC,yBAAyB;YAAE,OAAO,CAAC,SAAS,CAAC,CAAA;QAElD,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAG,OAAO,CAAC,CAAA;IACxB,CAAC,CAAA;IAED,IAAM,kBAAkB,GAAG,UAAC,OAAyB;QACnD,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAA;QAEzB,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAG,OAAO,CAAC,CAAA;IAC3B,CAAC,CAAA;IAED,IAAM,eAAe,GAAG,UAAC,OAAyB;QAChD,IAAI,CAAC,yBAAyB;YAAE,OAAO,CAAC,SAAS,CAAC,CAAA;QAElD,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAG,OAAO,CAAC,CAAA;IACxB,CAAC,CAAA;IAEK,IAAA,KAAA,OAAkB,IAAA,gBAAQ,EAAmB,SAAS,CAAC,IAAA,EAAtD,IAAI,QAAA,EAAE,OAAO,QAAyC,CAAA;IAE7D,IAAA,uDAA0B,EAAC,EAAE,GAAG,KAAA,EAAE,EAAE;QAClC,WAAW,EAAE,UAAA,CAAC,IAAI,OAAA,UAAU,CAAC,CAAC,CAAC,EAAb,CAAa;QAC/B,cAAc,EAAE,UAAA,CAAC,IAAI,OAAA,kBAAkB,CAAC,CAAC,CAAC,EAArB,CAAqB;QAC1C,WAAW,EAAE,UAAA,CAAC,IAAI,OAAA,eAAe,CAAC,CAAC,CAAC,EAAlB,CAAkB;KACrC,CAAC,CAAA;IAEF,OAAO,IAAI,CAAA;AACb,CAAC;AAED,SAAS,OAAO,CAAC,OAA0B;IACzC,IAAI,CAAC,OAAO;QAAE,OAAO,SAAS,CAAA;IAC9B,IAAI,OAAO,OAAO,CAAC,UAAU,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAA;IAC5D,IAAI,OAAO,OAAO,CAAC,WAAW,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAA;IAE7D,OAAO,IAAI,YAAI,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC,CAAA;AAC5D,CAAC","sourcesContent":["import { useState } from 'react'\nimport { Size } from 'spase'\nimport { useLoadVideoMetadataEffect, type UseLoadVideoMetadataEffectOptions, type UseLoadVideoMetadataEffectParams } from './useLoadVideoMetadataEffect'\n\ntype Params = UseLoadVideoMetadataEffectParams\n\ntype Options = UseLoadVideoMetadataEffectOptions & {\n /**\n * If `false`, the size will be reset to `undefined` when the video begins\n * loading or when an error occurs. Defaults to `true`.\n */\n preservesSizeBetweenLoads?: boolean\n}\n\n/**\n * Hook for retrieving the size of a video.\n *\n * @param params See {@link Params}.\n * @param options See {@link Options}.\n *\n * @returns The actual size of the video if loading was successful, `undefined`\n * otherwise.\n */\nexport function useVideoSize({ src }: Params, { preservesSizeBetweenLoads = true, onLoadStart, onLoadComplete, onLoadError }: Options = {}): Size | undefined {\n const handleLoad = (element: HTMLVideoElement) => {\n if (!preservesSizeBetweenLoads) setSize(undefined)\n\n onLoadStart?.(element)\n }\n\n const handleLoadComplete = (element: HTMLVideoElement) => {\n setSize(getSize(element))\n\n onLoadComplete?.(element)\n }\n\n const handleLoadError = (element: HTMLVideoElement) => {\n if (!preservesSizeBetweenLoads) setSize(undefined)\n\n onLoadError?.(element)\n }\n\n const [size, setSize] = useState<Size | undefined>(undefined)\n\n useLoadVideoMetadataEffect({ src }, {\n onLoadStart: t => handleLoad(t),\n onLoadComplete: t => handleLoadComplete(t),\n onLoadError: t => handleLoadError(t),\n })\n\n return size\n}\n\nfunction getSize(element?: HTMLVideoElement): Size | undefined {\n if (!element) return undefined\n if (typeof element.videoWidth !== 'number') return undefined\n if (typeof element.videoHeight !== 'number') return undefined\n\n return new Size([element.videoWidth, element.videoHeight])\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useViewportSize.js","sourceRoot":"/","sources":["hooks/useViewportSize.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAQA,0CAiBC;AAzBD,+BAA2C;AAC3C,+BAAkC;AAElC;;;;GAIG;AACH,SAAgB,eAAe;IACvB,IAAA,KAAA,OAAkB,IAAA,gBAAQ,EAAO,IAAI,YAAI,EAAE,CAAC,IAAA,EAA3C,IAAI,QAAA,EAAE,OAAO,QAA8B,CAAA;IAElD,IAAA,iBAAS,EAAC;QACR,SAAS,gBAAgB;YACvB,IAAM,YAAY,GAAG,YAAI,CAAC,YAAY,EAAE,CAAC,IAAI,CAAA;YAC7C,OAAO,CAAC,YAAY,CAAC,CAAA;QACvB,CAAC;QAED,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAA;QAEnD,gBAAgB,EAAE,CAAA;QAElB,OAAO,cAAM,OAAA,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,EAAtD,CAAsD,CAAA;IACrE,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import { useEffect, useState } from 'react'\nimport { Rect, Size } from 'spase'\n\n/**\n * Hook for returning the size of the viewport whenever it changes.\n *\n * @returns The most current viewport size.\n */\nexport function useViewportSize() {\n const [size, setSize] = useState<Size>(new Size())\n\n useEffect(() => {\n function onViewportResize() {\n const viewportSize = Rect.fromViewport().size\n setSize(viewportSize)\n }\n\n window.addEventListener('resize', onViewportResize)\n\n onViewportResize()\n\n return () => window.removeEventListener('resize', onViewportResize)\n }, [])\n\n return size\n}\n"]}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { type PropsWithChildren } from 'react';
|
|
2
|
-
export type ConditionalProps = PropsWithChildren<{
|
|
3
|
-
if: boolean | (() => boolean);
|
|
4
|
-
}>;
|
|
5
|
-
export declare function Conditional({ children, if: boolOrExpression }: ConditionalProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Conditional.js","sourceRoot":"/","sources":["operators/Conditional.tsx"],"names":[],"mappings":";;AAMA,kCAWC;;AAXD,SAAgB,WAAW,CAAC,EAAoD;QAAlD,QAAQ,cAAA,EAAM,gBAAgB,QAAA;IAC1D,QAAQ,OAAO,gBAAgB,EAAE,CAAC;QAChC,KAAK,SAAS;YACZ,OAAO,gBAAgB,CAAC,CAAC,CAAC,2DAAG,QAAQ,GAAI,CAAC,CAAC,CAAC,kDAAK,CAAA;QACnD,KAAK,UAAU;YACb,OAAO,gBAAgB,EAAE,CAAC,CAAC,CAAC,2DAAG,QAAQ,GAAI,CAAC,CAAC,CAAC,kDAAK,CAAA;QACrD;YACE,OAAO,CAAC,KAAK,CAAC,+DAAwD,gBAAgB,uBAAoB,CAAC,CAAA;YAE3G,OAAO,kDAAK,CAAA;IAChB,CAAC;AACH,CAAC;AAED,MAAM,CAAC,cAAc,CAAC,WAAW,EAAE,aAAa,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAA","sourcesContent":["import { type PropsWithChildren } from 'react'\n\nexport type ConditionalProps = PropsWithChildren<{\n if: boolean | (() => boolean)\n}>\n\nexport function Conditional({ children, if: boolOrExpression }: ConditionalProps) {\n switch (typeof boolOrExpression) {\n case 'boolean':\n return boolOrExpression ? <>{children}</> : <></>\n case 'function':\n return boolOrExpression() ? <>{children}</> : <></>\n default:\n console.error(`[etudes::Conditional] The type of provided condition ${boolOrExpression} is not supported.`)\n\n return <></>\n }\n}\n\nObject.defineProperty(Conditional, 'displayName', { value: 'Conditional', writable: false })\n"]}
|
package/operators/Each.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type ReactNode } from 'react';
|
|
2
|
-
export type EachProps<T> = {
|
|
3
|
-
children?: ReactNode | ((value: T, index: number) => ReactNode);
|
|
4
|
-
in?: T[];
|
|
5
|
-
render?: (value: T, index: number) => ReactNode;
|
|
6
|
-
};
|
|
7
|
-
export declare function Each<T>({ in: array, children, render, }: Readonly<EachProps<T>>): import("react/jsx-runtime").JSX.Element;
|
package/operators/Each.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Each.js","sourceRoot":"/","sources":["operators/Each.tsx"],"names":[],"mappings":";;AAQA,oBAiBC;;AAzBD,+BAAgD;AAQhD,SAAgB,IAAI,CAAI,EAIC;QAHnB,KAAK,QAAA,EACT,QAAQ,cAAA,EACR,MAAM,YAAA;IAEN,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,kDAAK,CAAA;IACvD,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC;QAAE,MAAM,SAAS,CAAC,yBAAkB,KAAK,sBAAmB,CAAC,CAAA;IAE1F,OAAO,CACL,2DACG,KAAK,CAAC,GAAG,CAAC,UAAC,CAAC,EAAE,CAAC;;YAAK,OAAA,CACnB,uBAAC,gBAAQ,cACN,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAG,CAAC,EAAE,CAAC,CAAC,mCAAI,CAAC,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IADlE,eAAQ,CAAC,CAAE,CAEf,CACZ,CAAA;SAAA,CAAC,GACD,CACJ,CAAA;AACH,CAAC;AAED,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,aAAa,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAA","sourcesContent":["import { Fragment, type ReactNode } from 'react'\n\nexport type EachProps<T> = {\n children?: ReactNode | ((value: T, index: number) => ReactNode)\n in?: T[]\n render?: (value: T, index: number) => ReactNode\n}\n\nexport function Each<T>({\n in: array,\n children,\n render,\n}: Readonly<EachProps<T>>) {\n if (array === undefined || array === null) return <></>\n if (!(array instanceof Array)) throw TypeError(`Provided list <${array}> is not an array`)\n\n return (\n <>\n {array.map((v, i) => (\n <Fragment key={`item-${i}`}>\n {render?.(v, i) ?? (typeof children === 'function' ? children(v, i) : children)}\n </Fragment>\n ))}\n </>\n )\n}\n\nObject.defineProperty(Each, 'displayName', { value: 'Each', writable: false })\n"]}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { type HTMLAttributes } from 'react';
|
|
2
|
-
export type ExtractChildProps = HTMLAttributes<HTMLElement>;
|
|
3
|
-
/**
|
|
4
|
-
* Extracts a single child of a parent component into its own component. If the
|
|
5
|
-
* parent component has multiple children, only the first one will be extracted,
|
|
6
|
-
* the rest will be ignored.
|
|
7
|
-
*/
|
|
8
|
-
export declare const ExtractChild: import("react").ForwardRefExoticComponent<ExtractChildProps & import("react").RefAttributes<HTMLElement>>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ExtractChild.js","sourceRoot":"/","sources":["operators/ExtractChild.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAAiF;AACjF,kCAA6C;AAI7C;;;;GAIG;AACU,QAAA,YAAY,GAAG,IAAA,kBAAU,EAAiC,UAAC,EAGvE,EAAE,GAAG;IAFJ,IAAA,QAAQ,cAAA,EACL,KAAK,cAF8D,YAGvE,CADS;IAER,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,OAAO,CAAC,KAAK,CAAC,uEAAgE,QAAQ,CAAC,MAAM,sEAAmE,CAAC,CAAA;IACnK,CAAC;IAED,OAAO,CACL,2DACG,gBAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,UAAC,KAAK,EAAE,GAAG;YACjC,IAAI,GAAG,GAAG,CAAC,EAAE,CAAC;gBACZ,OAAO,SAAS,CAAA;YAClB,CAAC;iBACI,IAAI,IAAA,sBAAc,EAAC,KAAK,CAAC,EAAE,CAAC;gBAC/B,OAAO,IAAA,0BAAkB,EAAC,KAAK,EAAE,sBAAK,KAAK,KAAE,GAAG,KAAA,GAAS,CAAC,CAAA;YAC5D,CAAC;iBACI,CAAC;gBACJ,OAAO,KAAK,CAAA;YACd,CAAC;QACH,CAAC,CAAC,GACD,CACJ,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,MAAM,CAAC,cAAc,CAAC,oBAAY,EAAE,aAAa,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAA","sourcesContent":["import { Children, forwardRef, isValidElement, type HTMLAttributes } from 'react'\nimport { cloneStyledElement } from '../utils'\n\nexport type ExtractChildProps = HTMLAttributes<HTMLElement>\n\n/**\n * Extracts a single child of a parent component into its own component. If the\n * parent component has multiple children, only the first one will be extracted,\n * the rest will be ignored.\n */\nexport const ExtractChild = forwardRef<HTMLElement, ExtractChildProps>(({\n children,\n ...props\n}, ref) => {\n if (Array.isArray(children)) {\n console.error(`[etudes::ExtractChild] Only one child is expected, but found ${children.length}. Only the first child is extracted while the rest are discarded.`)\n }\n\n return (\n <>\n {Children.map(children, (child, idx) => {\n if (idx > 0) {\n return undefined\n }\n else if (isValidElement(child)) {\n return cloneStyledElement(child, { ...props, ref } as any)\n }\n else {\n return child\n }\n })}\n </>\n )\n})\n\nObject.defineProperty(ExtractChild, 'displayName', { value: 'ExtractChild', writable: false })\n"]}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { type HTMLAttributes } from 'react';
|
|
2
|
-
export type ExtractChildrenProps = HTMLAttributes<HTMLElement>;
|
|
3
|
-
/**
|
|
4
|
-
* Extracts all children of a parent component into its own component.
|
|
5
|
-
*/
|
|
6
|
-
export declare function ExtractChildren({ children, ...props }: Readonly<ExtractChildrenProps>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ExtractChildren.js","sourceRoot":"/","sources":["operators/ExtractChildren.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAQA,0CAgBC;;AAxBD,+BAAqE;AACrE,kCAA6C;AAI7C;;GAEG;AACH,SAAgB,eAAe,CAAC,EAGC;IAF/B,IAAA,QAAQ,cAAA,EACL,KAAK,cAFsB,YAG/B,CADS;IAER,OAAO,CACL,2DACG,gBAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,UAAA,KAAK;YAC3B,IAAI,IAAA,sBAAc,EAAC,KAAK,CAAC,EAAE,CAAC;gBAC1B,OAAO,IAAA,0BAAkB,EAAC,KAAK,eAAO,KAAK,EAAG,CAAA;YAChD,CAAC;iBACI,CAAC;gBACJ,OAAO,KAAK,CAAA;YACd,CAAC;QACH,CAAC,CAAC,GACD,CACJ,CAAA;AACH,CAAC;AAED,MAAM,CAAC,cAAc,CAAC,eAAe,EAAE,aAAa,EAAE,EAAE,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAA","sourcesContent":["import { Children, isValidElement, type HTMLAttributes } from 'react'\nimport { cloneStyledElement } from '../utils'\n\nexport type ExtractChildrenProps = HTMLAttributes<HTMLElement>\n\n/**\n * Extracts all children of a parent component into its own component.\n */\nexport function ExtractChildren({\n children,\n ...props\n}: Readonly<ExtractChildrenProps>) {\n return (\n <>\n {Children.map(children, child => {\n if (isValidElement(child)) {\n return cloneStyledElement(child, { ...props })\n }\n else {\n return child\n }\n })}\n </>\n )\n}\n\nObject.defineProperty(ExtractChildren, 'displayName', { value: 'ExtractChildren', writable: false })\n"]}
|
package/operators/Repeat.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type ReactNode } from 'react';
|
|
2
|
-
export type RepeatProps = {
|
|
3
|
-
children?: ReactNode | ((index: number) => ReactNode);
|
|
4
|
-
count?: number;
|
|
5
|
-
render?: (index: number) => ReactNode;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* A tag-less component that repeats its children, automatically assigning each
|
|
9
|
-
* a unique key.
|
|
10
|
-
*/
|
|
11
|
-
export declare function Repeat({ count, children, render, }: Readonly<RepeatProps>): import("react/jsx-runtime").JSX.Element;
|
package/operators/Repeat.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Repeat.js","sourceRoot":"/","sources":["operators/Repeat.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,wBAcC;;AA1BD,+BAAgD;AAQhD;;;GAGG;AACH,SAAgB,MAAM,CAAC,EAIC;QAHtB,aAAS,EAAT,KAAK,mBAAG,CAAC,KAAA,EACT,QAAQ,cAAA,EACR,MAAM,YAAA;IAEN,OAAO,CACL,2DACG,yBAAI,KAAK,CAAC,KAAK,CAAC,UAAE,GAAG,CAAC,UAAC,CAAC,EAAE,CAAC;;YAAK,OAAA,CAC/B,uBAAC,gBAAQ,cACN,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAG,CAAC,CAAC,mCAAI,CAAC,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAD5D,kBAAW,CAAC,CAAE,CAElB,CACZ,CAAA;SAAA,CAAC,GACD,CACJ,CAAA;AACH,CAAC;AAED,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,aAAa,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAA","sourcesContent":["import { Fragment, type ReactNode } from 'react'\n\nexport type RepeatProps = {\n children?: ReactNode | ((index: number) => ReactNode)\n count?: number\n render?: (index: number) => ReactNode\n}\n\n/**\n * A tag-less component that repeats its children, automatically assigning each\n * a unique key.\n */\nexport function Repeat({\n count = 1,\n children,\n render,\n}: Readonly<RepeatProps>) {\n return (\n <>\n {[...Array(count)].map((v, i) => (\n <Fragment key={`element-${i}`}>\n {render?.(i) ?? (typeof children === 'function' ? children(i) : children)}\n </Fragment>\n ))}\n </>\n )\n}\n\nObject.defineProperty(Repeat, 'displayName', { value: 'Repeat', writable: false })\n"]}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { type PropsWithChildren, type RefObject } from 'react';
|
|
2
|
-
import { Point } from 'spase';
|
|
3
|
-
type ScrollPosition = {
|
|
4
|
-
pos: Point;
|
|
5
|
-
step: Point;
|
|
6
|
-
};
|
|
7
|
-
type ScrollPositionContextValue = ScrollPosition & {
|
|
8
|
-
minPos: Point;
|
|
9
|
-
maxPos: Point;
|
|
10
|
-
};
|
|
11
|
-
type ScrollPositionProviderProps = PropsWithChildren;
|
|
12
|
-
export declare const ScrollPositionContext: import("react").Context<ScrollPositionContextValue | undefined>;
|
|
13
|
-
export declare function ScrollPositionProvider({ children, }: Readonly<ScrollPositionProviderProps>): import("react/jsx-runtime").JSX.Element;
|
|
14
|
-
export declare function useScrollPosition(targetRef?: RefObject<Element>): ScrollPosition;
|
|
15
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ScrollPositionProvider.js","sourceRoot":"/","sources":["providers/ScrollPositionProvider.tsx"],"names":[],"mappings":"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","sourcesContent":["import { createContext, useContext, useEffect, useState, type PropsWithChildren, type RefObject } from 'react'\nimport { Point, Rect } from 'spase'\n\ntype ScrollPosition = {\n pos: Point\n step: Point\n}\n\ntype ScrollPositionContextValue = ScrollPosition & {\n minPos: Point\n maxPos: Point\n}\n\ntype ScrollPositionProviderProps = PropsWithChildren\n\nexport const ScrollPositionContext = createContext<ScrollPositionContextValue | undefined>(undefined)\n\nexport function ScrollPositionProvider({\n children,\n}: Readonly<ScrollPositionProviderProps>) {\n const [value, setValue] = useState<ScrollPositionContextValue>({\n minPos: new Point(),\n maxPos: new Point(),\n pos: new Point(),\n step: new Point(),\n })\n\n useEffect(() => {\n const updateScrollPosition = () => {\n const refRect = Rect.fromViewport()\n const refRectMin = refRect.clone({ x: 0, y: 0 })\n const refRectFull = Rect.from(window, { overflow: true })\n\n if (!refRectFull) return\n\n const refRectMax = refRectMin.clone({ x: refRectFull.width - refRect.width, y: refRectFull.height - refRect.height })\n const step = new Point([refRect.left / refRectMax.left, refRect.top / refRectMax.top])\n\n setValue({\n minPos: new Point([refRectMin.left, refRectMin.top]),\n maxPos: new Point([refRectMax.left, refRectMax.top]),\n pos: new Point([refRect.left, refRect.top]),\n step,\n })\n }\n\n window.addEventListener('scroll', updateScrollPosition)\n window.addEventListener('resize', updateScrollPosition)\n window.addEventListener('orientationchange', updateScrollPosition)\n\n updateScrollPosition()\n\n return () => {\n window.removeEventListener('scroll', updateScrollPosition)\n window.removeEventListener('resize', updateScrollPosition)\n window.removeEventListener('orientationchange', updateScrollPosition)\n }\n }, [])\n\n return (\n <ScrollPositionContext.Provider value={value}>\n {children}\n </ScrollPositionContext.Provider>\n )\n}\n\nexport function useScrollPosition(targetRef?: RefObject<Element>): ScrollPosition {\n const context = useContext(ScrollPositionContext)\n if (!context) throw Error('Cannot fetch the current scroll position context, is the corresponding provider instated?')\n\n if (!targetRef) {\n return {\n pos: context.pos,\n step: context.step,\n }\n }\n\n const element = targetRef.current\n\n const refRect = Rect.fromViewport()\n const rect = Rect.from(element)\n\n if (!refRect || !rect) {\n return {\n pos: new Point(),\n step: new Point(),\n }\n }\n\n const posX = refRect.right - rect.left\n const posY = refRect.bottom - rect.top\n const stepX = posX / rect.width\n const stepY = posY / rect.height\n\n return {\n pos: new Point([posX, posY]),\n step: new Point([stepX, stepY]),\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"asClassNameDict.js","sourceRoot":"/","sources":["utils/asClassNameDict.ts"],"names":[],"mappings":";;AAAA,0CAEC;AAFD,SAAgB,eAAe,CAAI,IAAgC;IACjE,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["export function asClassNameDict<T>(dict: { [K in keyof T]: string }) {\n return dict\n}\n"]}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { type JSXElementConstructor, type ReactNode } from 'react';
|
|
2
|
-
type ComponentTypeDict = Record<string, JSXElementConstructor<any>>;
|
|
3
|
-
type ComponentElementDict<T extends ComponentTypeDict> = Record<keyof T, JSX.Element>;
|
|
4
|
-
export declare function asComponentDict<T extends ComponentTypeDict>(children?: ReactNode, typeDict?: T): Partial<ComponentElementDict<T>>;
|
|
5
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"asComponentDict.js","sourceRoot":"/","sources":["utils/asComponentDict.ts"],"names":[],"mappings":";;AAMA,0CAkBC;AAxBD,+BAA4F;AAM5F,SAAgB,eAAe,CAA8B,QAAoB,EAAE,QAAqB;IAArB,yBAAA,EAAA,WAAc,EAAO;IACtG,IAAM,IAAI,GAAgB,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAC/C,IAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IACrC,IAAM,UAAU,GAAqC,EAAE,CAAA;IAEvD,gBAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,UAAA,KAAK;QAC9B,IAAI,CAAC,IAAA,sBAAc,EAAC,KAAK,CAAC;YAAE,MAAM,KAAK,CAAC,wBAAwB,CAAC,CAAA;QAEjE,IAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAW,CAAC,CAAA;QAC9C,IAAI,KAAK,GAAG,CAAC;YAAE,MAAM,KAAK,CAAC,sEAA+D,KAAK,CAAE,CAAC,CAAA;QAElG,IAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAA;QACvB,IAAI,UAAU,CAAC,GAAG,CAAC;YAAE,MAAM,KAAK,CAAC,mBAAY,KAAK,CAAC,KAAK,CAAC,gCAA6B,CAAC,CAAA;QAEvF,UAAU,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;IACzB,CAAC,CAAC,CAAA;IAEF,OAAO,UAAU,CAAA;AACnB,CAAC","sourcesContent":["import { Children, isValidElement, type JSXElementConstructor, type ReactNode } from 'react'\n\ntype ComponentTypeDict = Record<string, JSXElementConstructor<any>>\n\ntype ComponentElementDict<T extends ComponentTypeDict> = Record<keyof T, JSX.Element>\n\nexport function asComponentDict<T extends ComponentTypeDict>(children?: ReactNode, typeDict: T = {} as T): Partial<ComponentElementDict<T>> {\n const keys: (keyof T)[] = Object.keys(typeDict)\n const types = Object.values(typeDict)\n const components: Partial<ComponentElementDict<T>> = {}\n\n Children.forEach(children, child => {\n if (!isValidElement(child)) throw Error('Invalid child detected')\n\n const index = types.indexOf(child.type as any)\n if (index < 0) throw Error(`Unsupported child, only the following children are allowed: ${types}`)\n\n const key = keys[index]\n if (components[key]) throw Error(`Only one ${types[index]} can be provided as a child`)\n\n components[key] = child\n })\n\n return components\n}\n"]}
|
package/utils/asStyleDict.d.ts
DELETED
package/utils/asStyleDict.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"asStyleDict.js","sourceRoot":"/","sources":["utils/asStyleDict.ts"],"names":[],"mappings":";;AAEA,kCAEC;AAFD,SAAgB,WAAW,CAAI,IAAuC;IACpE,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import { type CSSProperties } from 'react'\n\nexport function asStyleDict<T>(dict: { [K in keyof T]: CSSProperties }) {\n return dict\n}\n"]}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { type Attributes, type CElement, type ClassAttributes, type Component, type ComponentState, type FunctionComponentElement, type ReactElement, type ReactNode } from 'react';
|
|
2
|
-
/**
|
|
3
|
-
* Wrapper for {@link cloneElement} but instead of overwriting `className` and
|
|
4
|
-
* `style` of the cloned element with the values specified in the `props`
|
|
5
|
-
* argument, they are merged.
|
|
6
|
-
*
|
|
7
|
-
* @param element The target element to clone.
|
|
8
|
-
* @param props The props to apply to the cloned element. Overlapping props are
|
|
9
|
-
* overwritten with the exception of `className` and `style`, which
|
|
10
|
-
* are merged.
|
|
11
|
-
* @param children Optional child elements add into the cloned element.
|
|
12
|
-
*
|
|
13
|
-
* @returns The cloned element.
|
|
14
|
-
*/
|
|
15
|
-
declare function cloneStyledElement<P>(element: FunctionComponentElement<P>, props?: Partial<P> & Attributes, ...children: ReactNode[]): FunctionComponentElement<P>;
|
|
16
|
-
declare function cloneStyledElement<P, T extends Component<P, ComponentState>>(element: CElement<P, T>, props?: Partial<P> & ClassAttributes<T>, ...children: ReactNode[]): CElement<P, T>;
|
|
17
|
-
declare function cloneStyledElement<P>(element: ReactElement<P>, props?: Partial<P> & Attributes, ...children: ReactNode[]): ReactElement<P>;
|
|
18
|
-
export { cloneStyledElement };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cloneStyledElement.js","sourceRoot":"/","sources":["utils/cloneStyledElement.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCS,gDAAkB;AArC3B,+BAAiM;AAkBjM,SAAS,kBAAkB,CACzB,OAAuE,EACvE,KAAqE;IAArE,sBAAA,EAAA,UAAqE;IACrE,kBAAwB;SAAxB,UAAwB,EAAxB,qBAAwB,EAAxB,IAAwB;QAAxB,iCAAwB;;IAExB,IAAM,KAAsC,KAAY,EAAhD,SAAS,eAAA,EAAE,KAAK,WAAA,EAAK,UAAU,cAAjC,sBAAmC,CAAe,CAAA;IACxD,IAAM,KAA6E,OAAO,CAAC,KAAY,EAApF,gBAAgB,eAAA,EAAS,YAAY,WAAA,EAAK,iBAAiB,cAAxE,sBAA0E,CAAuB,CAAA;IAEvG,OAAO,oBAAY,8BAAC,OAAO,sBACzB,SAAS,EAAE,UAAG,gBAAgB,aAAhB,gBAAgB,cAAhB,gBAAgB,GAAI,EAAE,cAAI,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,EAAE,CAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAC9F,KAAK,wBACA,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,EAAE,GAClB,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,KAEb,iBAAiB,GACjB,UAAU,WACT,QAAQ,WAAC;AACjB,CAAC","sourcesContent":["import { cloneElement, type Attributes, type CElement, type ClassAttributes, type Component, type ComponentState, type FunctionComponentElement, type ReactElement, type ReactNode } from 'react'\n\n/**\n * Wrapper for {@link cloneElement} but instead of overwriting `className` and\n * `style` of the cloned element with the values specified in the `props`\n * argument, they are merged.\n *\n * @param element The target element to clone.\n * @param props The props to apply to the cloned element. Overlapping props are\n * overwritten with the exception of `className` and `style`, which\n * are merged.\n * @param children Optional child elements add into the cloned element.\n *\n * @returns The cloned element.\n */\nfunction cloneStyledElement<P>(element: FunctionComponentElement<P>, props?: Partial<P> & Attributes, ...children: ReactNode[]): FunctionComponentElement<P>\nfunction cloneStyledElement<P, T extends Component<P, ComponentState>>(element: CElement<P, T>, props?: Partial<P> & ClassAttributes<T>, ...children: ReactNode[]): CElement<P, T>\nfunction cloneStyledElement<P>(element: ReactElement<P>, props?: Partial<P> & Attributes, ...children: ReactNode[]): ReactElement<P>\nfunction cloneStyledElement<P, T extends Component<P, ComponentState> = never>(\n element: FunctionComponentElement<P> | CElement<P, T> | ReactElement<P>,\n props: Partial<P> & Attributes | Partial<P> & ClassAttributes<T> = {},\n ...children: ReactNode[]\n) {\n const { className, style, ...otherProps } = props as any\n const { className: elementClassName, style: elementStyle, ...otherElementProps } = element.props as any\n\n return cloneElement(element, {\n className: `${elementClassName ?? ''} ${className ?? ''}`.split(' ').filter(Boolean).join(' '),\n style: {\n ...elementStyle ?? {},\n ...style ?? {},\n },\n ...otherElementProps,\n ...otherProps,\n }, ...children)\n}\n\nexport { cloneStyledElement }\n"]}
|
package/utils/index.d.ts
DELETED
package/utils/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAiC;AACjC,oDAAiC;AACjC,gDAA6B;AAC7B,uDAAoC;AACpC,2CAAwB","sourcesContent":["export * from './asClassNameDict'\nexport * from './asComponentDict'\nexport * from './asStyleDict'\nexport * from './cloneStyledElement'\nexport * from './styles'\n"]}
|
package/utils/styles.d.ts
DELETED
package/utils/styles.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sourceRoot":"/","sources":["utils/styles.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAEA,wBAKC;AALD,SAAgB,MAAM;IAAC,cAA8C;SAA9C,UAA8C,EAA9C,qBAA8C,EAA9C,IAA8C;QAA9C,yBAA8C;;IACnE,OAAO,IAAI,CAAC,MAAM,CAAgB,UAAC,GAAG,EAAE,IAAI,IAAK,OAAA,uBAC5C,GAAG,GACH,IAAI,IAAI,EAAE,EACb,EAH+C,CAG/C,EAAE,EAAE,CAAC,CAAA;AACT,CAAC","sourcesContent":["import { type CSSProperties } from 'react'\n\nexport function styles(...args: (CSSProperties | undefined | false)[]): CSSProperties {\n return args.reduce<CSSProperties>((out, curr) => ({\n ...out,\n ...curr || {},\n }), {})\n}\n"]}
|