@mks2508/mks-ui 0.2.1 → 0.3.1
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/dist/react-ui/hooks/Animation/UseAutoHeight.js +7 -7
- package/dist/react-ui/hooks/DOM/UseIsInView.js +3 -3
- package/dist/react-ui/hooks/Formatting/UseListFormat.d.ts +49 -0
- package/dist/react-ui/hooks/Formatting/UseListFormat.d.ts.map +1 -0
- package/dist/react-ui/hooks/Formatting/UseListFormat.js +105 -0
- package/dist/react-ui/hooks/State/UseControlledState.js +4 -4
- package/dist/react-ui/hooks/State/UseDataState.js +5 -5
- package/dist/react-ui/hooks/index.d.ts +2 -0
- package/dist/react-ui/hooks/index.d.ts.map +1 -1
- package/dist/react-ui/hooks/index.js +1 -0
- package/dist/react-ui/index.js +22 -2
- package/dist/react-ui/lib/get-strict-context.js +3 -3
- package/dist/react-ui/primitives/CountingNumber/index.js +3 -3
- package/dist/react-ui/primitives/Highlight/index.js +26 -26
- package/dist/react-ui/primitives/Slot/index.js +3 -3
- package/dist/react-ui/primitives/index.d.ts +1 -0
- package/dist/react-ui/primitives/index.d.ts.map +1 -1
- package/dist/react-ui/primitives/index.js +18 -0
- package/dist/react-ui/primitives/waapi/Morph/Morph.types.d.ts +76 -0
- package/dist/react-ui/primitives/waapi/Morph/Morph.types.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Morph/MorphContext.d.ts +11 -0
- package/dist/react-ui/primitives/waapi/Morph/MorphContext.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Morph/MorphContext.js +19 -0
- package/dist/react-ui/primitives/waapi/Morph/index.d.ts +23 -0
- package/dist/react-ui/primitives/waapi/Morph/index.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Morph/index.js +45 -0
- package/dist/react-ui/primitives/waapi/Morph/techniques/index.d.ts +12 -0
- package/dist/react-ui/primitives/waapi/Morph/techniques/index.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Morph/techniques/useCSSGridMorph.d.ts +38 -0
- package/dist/react-ui/primitives/waapi/Morph/techniques/useCSSGridMorph.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Morph/techniques/useCSSGridMorph.js +78 -0
- package/dist/react-ui/primitives/waapi/Morph/techniques/useFLIPClipPath.d.ts +23 -0
- package/dist/react-ui/primitives/waapi/Morph/techniques/useFLIPClipPath.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Morph/techniques/useFLIPClipPath.js +140 -0
- package/dist/react-ui/primitives/waapi/Morph/techniques/useViewTransitions.d.ts +28 -0
- package/dist/react-ui/primitives/waapi/Morph/techniques/useViewTransitions.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Morph/techniques/useViewTransitions.js +77 -0
- package/dist/react-ui/primitives/waapi/Morph/useMorph.d.ts +27 -0
- package/dist/react-ui/primitives/waapi/Morph/useMorph.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Morph/useMorph.js +86 -0
- package/dist/react-ui/primitives/waapi/Reorder/Reorder.types.d.ts +168 -0
- package/dist/react-ui/primitives/waapi/Reorder/Reorder.types.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Reorder/index.d.ts +25 -0
- package/dist/react-ui/primitives/waapi/Reorder/index.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Reorder/index.js +186 -0
- package/dist/react-ui/primitives/waapi/Reorder/useReorder.d.ts +26 -0
- package/dist/react-ui/primitives/waapi/Reorder/useReorder.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Reorder/useReorder.js +48 -0
- package/dist/react-ui/primitives/waapi/Reorder/useReorderPresence.d.ts +33 -0
- package/dist/react-ui/primitives/waapi/Reorder/useReorderPresence.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Reorder/useReorderPresence.js +137 -0
- package/dist/react-ui/primitives/waapi/Reorder/utils/separatorCoordination.d.ts +47 -0
- package/dist/react-ui/primitives/waapi/Reorder/utils/separatorCoordination.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Reorder/utils/separatorCoordination.js +72 -0
- package/dist/react-ui/primitives/waapi/SlidingNumber/SlidingNumber.styles.d.ts +10 -0
- package/dist/react-ui/primitives/waapi/SlidingNumber/SlidingNumber.styles.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/SlidingNumber/SlidingNumber.types.d.ts +74 -0
- package/dist/react-ui/primitives/waapi/SlidingNumber/SlidingNumber.types.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/SlidingNumber/index.d.ts +33 -0
- package/dist/react-ui/primitives/waapi/SlidingNumber/index.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/SlidingNumber/index.js +354 -0
- package/dist/react-ui/primitives/waapi/SlidingText/SlidingText.styles.d.ts +25 -0
- package/dist/react-ui/primitives/waapi/SlidingText/SlidingText.styles.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/SlidingText/SlidingText.types.d.ts +57 -0
- package/dist/react-ui/primitives/waapi/SlidingText/SlidingText.types.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/SlidingText/index.d.ts +26 -0
- package/dist/react-ui/primitives/waapi/SlidingText/index.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/SlidingText/index.js +105 -0
- package/dist/react-ui/primitives/waapi/core/animationConstants.d.ts +156 -0
- package/dist/react-ui/primitives/waapi/core/animationConstants.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/core/animationConstants.js +180 -0
- package/dist/react-ui/primitives/waapi/core/index.d.ts +16 -0
- package/dist/react-ui/primitives/waapi/core/index.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/core/index.js +5 -0
- package/dist/react-ui/primitives/waapi/core/types.d.ts +143 -0
- package/dist/react-ui/primitives/waapi/core/types.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/core/useAnimationOrchestrator.d.ts +32 -0
- package/dist/react-ui/primitives/waapi/core/useAnimationOrchestrator.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/core/useAnimationOrchestrator.js +322 -0
- package/dist/react-ui/primitives/waapi/core/useElementRegistry.d.ts +21 -0
- package/dist/react-ui/primitives/waapi/core/useElementRegistry.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/core/useElementRegistry.js +65 -0
- package/dist/react-ui/primitives/waapi/core/useFLIPAnimation.d.ts +20 -0
- package/dist/react-ui/primitives/waapi/core/useFLIPAnimation.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/core/useFLIPAnimation.js +99 -0
- package/dist/react-ui/primitives/waapi/core/usePositionCapture.d.ts +24 -0
- package/dist/react-ui/primitives/waapi/core/usePositionCapture.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/core/usePositionCapture.js +75 -0
- package/dist/react-ui/primitives/waapi/index.d.ts +33 -0
- package/dist/react-ui/primitives/waapi/index.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/index.js +18 -0
- package/dist/react-ui/ui/Accordion/index.js +3 -3
- package/dist/react-ui/ui/Button/index.js +8 -8
- package/dist/react-ui/ui/Combobox/index.js +2 -2
- package/dist/react-ui/ui/DataCard/DataCard.styles.d.ts +35 -0
- package/dist/react-ui/ui/DataCard/DataCard.styles.d.ts.map +1 -0
- package/dist/react-ui/ui/DataCard/DataCard.styles.js +114 -0
- package/dist/react-ui/ui/DataCard/DataCard.types.d.ts +135 -0
- package/dist/react-ui/ui/DataCard/DataCard.types.d.ts.map +1 -0
- package/dist/react-ui/ui/DataCard/index.d.ts +129 -0
- package/dist/react-ui/ui/DataCard/index.d.ts.map +1 -0
- package/dist/react-ui/ui/DataCard/index.js +276 -0
- package/dist/react-ui/ui/Menu/index.js +2 -2
- package/dist/react-ui/ui/Switch/index.js +3 -3
- package/dist/react-ui/ui/Tabs/index.js +3 -3
- package/dist/react-ui/ui/TextFlow/TextFlow.styles.d.ts +16 -0
- package/dist/react-ui/ui/TextFlow/TextFlow.styles.d.ts.map +1 -0
- package/dist/react-ui/ui/TextFlow/TextFlow.types.d.ts +101 -0
- package/dist/react-ui/ui/TextFlow/TextFlow.types.d.ts.map +1 -0
- package/dist/react-ui/ui/TextFlow/index.d.ts +26 -0
- package/dist/react-ui/ui/TextFlow/index.d.ts.map +1 -0
- package/dist/react-ui/ui/TextFlow/index.js +187 -0
- package/dist/react-ui/ui/index.d.ts +2 -1
- package/dist/react-ui/ui/index.d.ts.map +1 -1
- package/dist/react-ui/ui/index.js +3 -1
- package/package.json +6 -2
- package/src/react-ui/hooks/Formatting/UseListFormat.ts +134 -0
- package/src/react-ui/hooks/index.ts +3 -0
- package/src/react-ui/primitives/index.ts +3 -0
- package/src/react-ui/primitives/waapi/Morph/Morph.types.ts +106 -0
- package/src/react-ui/primitives/waapi/Morph/MorphContext.tsx +21 -0
- package/src/react-ui/primitives/waapi/Morph/index.tsx +56 -0
- package/src/react-ui/primitives/waapi/Morph/techniques/index.ts +12 -0
- package/src/react-ui/primitives/waapi/Morph/techniques/useCSSGridMorph.ts +88 -0
- package/src/react-ui/primitives/waapi/Morph/techniques/useFLIPClipPath.ts +175 -0
- package/src/react-ui/primitives/waapi/Morph/techniques/useViewTransitions.ts +86 -0
- package/src/react-ui/primitives/waapi/Morph/useMorph.ts +100 -0
- package/src/react-ui/primitives/waapi/Reorder/Reorder.types.ts +177 -0
- package/src/react-ui/primitives/waapi/Reorder/index.tsx +260 -0
- package/src/react-ui/primitives/waapi/Reorder/useReorder.ts +46 -0
- package/src/react-ui/primitives/waapi/Reorder/useReorderPresence.ts +208 -0
- package/src/react-ui/primitives/waapi/Reorder/utils/separatorCoordination.ts +104 -0
- package/src/react-ui/primitives/waapi/SlidingNumber/SlidingNumber.styles.ts +14 -0
- package/src/react-ui/primitives/waapi/SlidingNumber/SlidingNumber.types.ts +84 -0
- package/src/react-ui/primitives/waapi/SlidingNumber/index.tsx +474 -0
- package/src/react-ui/primitives/waapi/SlidingText/SlidingText.styles.ts +32 -0
- package/src/react-ui/primitives/waapi/SlidingText/SlidingText.types.ts +69 -0
- package/src/react-ui/primitives/waapi/SlidingText/index.tsx +140 -0
- package/src/react-ui/primitives/waapi/core/animationConstants.ts +215 -0
- package/src/react-ui/primitives/waapi/core/index.ts +53 -0
- package/src/react-ui/primitives/waapi/core/types.ts +200 -0
- package/src/react-ui/primitives/waapi/core/useAnimationOrchestrator.ts +429 -0
- package/src/react-ui/primitives/waapi/core/useElementRegistry.ts +80 -0
- package/src/react-ui/primitives/waapi/core/useFLIPAnimation.ts +137 -0
- package/src/react-ui/primitives/waapi/core/usePositionCapture.ts +105 -0
- package/src/react-ui/primitives/waapi/index.ts +116 -0
- package/src/react-ui/styles/animations.css +369 -0
- package/src/react-ui/ui/DataCard/DataCard.styles.ts +150 -0
- package/src/react-ui/ui/DataCard/DataCard.types.ts +146 -0
- package/src/react-ui/ui/DataCard/index.tsx +406 -0
- package/src/react-ui/ui/TextFlow/TextFlow.styles.ts +36 -0
- package/src/react-ui/ui/TextFlow/TextFlow.types.ts +118 -0
- package/src/react-ui/ui/TextFlow/index.tsx +276 -0
- package/src/react-ui/ui/index.ts +4 -1
- /package/dist/react-ui/components/MorphingPopover/{morphing-popover.module-CgbYV_HS.css → morphing-popover.module-BycNI8nU.css} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import * as React from "react";
|
|
3
|
+
import * as React$1 from "react";
|
|
4
4
|
|
|
5
5
|
//#region src/react-ui/hooks/Animation/UseAutoHeight.tsx
|
|
6
6
|
/**
|
|
@@ -21,10 +21,10 @@ function useAutoHeight(deps = [], options = {
|
|
|
21
21
|
includeParentBox: true,
|
|
22
22
|
includeSelfBox: false
|
|
23
23
|
}) {
|
|
24
|
-
const ref = React.useRef(null);
|
|
25
|
-
const roRef = React.useRef(null);
|
|
26
|
-
const [height, setHeight] = React.useState(0);
|
|
27
|
-
const measure = React.useCallback(() => {
|
|
24
|
+
const ref = React$1.useRef(null);
|
|
25
|
+
const roRef = React$1.useRef(null);
|
|
26
|
+
const [height, setHeight] = React$1.useState(0);
|
|
27
|
+
const measure = React$1.useCallback(() => {
|
|
28
28
|
const el = ref.current;
|
|
29
29
|
if (!el) return 0;
|
|
30
30
|
const base = el.getBoundingClientRect().height || 0;
|
|
@@ -44,7 +44,7 @@ function useAutoHeight(deps = [], options = {
|
|
|
44
44
|
const dpr = typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
|
|
45
45
|
return Math.ceil((base + extra) * dpr) / dpr;
|
|
46
46
|
}, [options.includeParentBox, options.includeSelfBox]);
|
|
47
|
-
React.useLayoutEffect(() => {
|
|
47
|
+
React$1.useLayoutEffect(() => {
|
|
48
48
|
const el = ref.current;
|
|
49
49
|
if (!el) return;
|
|
50
50
|
setHeight(measure());
|
|
@@ -64,7 +64,7 @@ function useAutoHeight(deps = [], options = {
|
|
|
64
64
|
roRef.current = null;
|
|
65
65
|
};
|
|
66
66
|
}, deps);
|
|
67
|
-
React.useLayoutEffect(() => {
|
|
67
|
+
React$1.useLayoutEffect(() => {
|
|
68
68
|
if (height === 0) {
|
|
69
69
|
const next = measure();
|
|
70
70
|
if (next !== 0) setHeight(next);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as React from "react";
|
|
1
|
+
import * as React$1 from "react";
|
|
2
2
|
import { useInView } from "motion/react";
|
|
3
3
|
|
|
4
4
|
//#region src/react-ui/hooks/DOM/UseIsInView.tsx
|
|
@@ -17,8 +17,8 @@ import { useInView } from "motion/react";
|
|
|
17
17
|
*/
|
|
18
18
|
function useIsInView(ref, options = {}) {
|
|
19
19
|
const { inView, inViewOnce = false, inViewMargin = "0px" } = options;
|
|
20
|
-
const localRef = React.useRef(null);
|
|
21
|
-
React.useImperativeHandle(ref, () => localRef.current);
|
|
20
|
+
const localRef = React$1.useRef(null);
|
|
21
|
+
React$1.useImperativeHandle(ref, () => localRef.current);
|
|
22
22
|
const inViewResult = useInView(localRef, {
|
|
23
23
|
once: inViewOnce,
|
|
24
24
|
margin: inViewMargin
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** Intl.ListFormat conjunction/disjunction/unit type */
|
|
2
|
+
export type ListFormatType = 'conjunction' | 'disjunction' | 'unit';
|
|
3
|
+
/** Intl.ListFormat style: long, short, or narrow */
|
|
4
|
+
export type ListFormatStyle = 'long' | 'short' | 'narrow';
|
|
5
|
+
/** Options for useListFormat hook */
|
|
6
|
+
export interface IUseListFormatOptions {
|
|
7
|
+
locale?: string;
|
|
8
|
+
type?: ListFormatType;
|
|
9
|
+
style?: ListFormatStyle;
|
|
10
|
+
separator?: string;
|
|
11
|
+
/** If true, format as if there's one more item (avoids "and" before overflow counter) */
|
|
12
|
+
hasOverflow?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/** A single part of a formatted list (element or separator) */
|
|
15
|
+
export interface IListPart {
|
|
16
|
+
type: 'element' | 'literal';
|
|
17
|
+
value: string;
|
|
18
|
+
index: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Hook for locale-aware list formatting using Intl.ListFormat.
|
|
22
|
+
*
|
|
23
|
+
* Provides parts that can be rendered individually with animations.
|
|
24
|
+
* Uses the browser's Intl.ListFormat API for proper locale handling.
|
|
25
|
+
*
|
|
26
|
+
* @param items - Array of strings to format
|
|
27
|
+
* @param options - Locale, type, style, separator override, overflow flag
|
|
28
|
+
* @returns Array of list parts (elements and literals)
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```tsx
|
|
32
|
+
* // Automatic locale detection
|
|
33
|
+
* const parts = useListFormat(['Apple', 'Banana', 'Cherry']);
|
|
34
|
+
* // en: [{ type: 'element', value: 'Apple' }, { type: 'literal', value: ', ' }, ...]
|
|
35
|
+
*
|
|
36
|
+
* // Spanish
|
|
37
|
+
* const parts = useListFormat(['Apple', 'Banana'], { locale: 'es' });
|
|
38
|
+
*
|
|
39
|
+
* // Disjunction ("or")
|
|
40
|
+
* const parts = useListFormat(['A', 'B', 'C'], { type: 'disjunction' });
|
|
41
|
+
* // en: "A, B, or C"
|
|
42
|
+
*
|
|
43
|
+
* // Manual separator override
|
|
44
|
+
* const parts = useListFormat(['A', 'B', 'C'], { separator: ' | ' });
|
|
45
|
+
* // "A | B | C"
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare function useListFormat(items: string[], options?: IUseListFormatOptions): IListPart[];
|
|
49
|
+
//# sourceMappingURL=UseListFormat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UseListFormat.d.ts","sourceRoot":"","sources":["../../../../src/react-ui/hooks/Formatting/UseListFormat.ts"],"names":[],"mappings":"AAEA,wDAAwD;AACxD,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG,aAAa,GAAG,MAAM,CAAC;AAEpE,oDAAoD;AACpD,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAE1D,qCAAqC;AACrC,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yFAAyF;IACzF,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,+DAA+D;AAC/D,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,SAAS,GAAG,SAAS,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AASD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,EAAE,EACf,OAAO,GAAE,qBAA0B,GAClC,SAAS,EAAE,CAsEb"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/react-ui/hooks/Formatting/UseListFormat.ts
|
|
4
|
+
const getDefaultLocale = () => {
|
|
5
|
+
if (typeof navigator !== "undefined" && navigator.language) return navigator.language;
|
|
6
|
+
return "en";
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Hook for locale-aware list formatting using Intl.ListFormat.
|
|
10
|
+
*
|
|
11
|
+
* Provides parts that can be rendered individually with animations.
|
|
12
|
+
* Uses the browser's Intl.ListFormat API for proper locale handling.
|
|
13
|
+
*
|
|
14
|
+
* @param items - Array of strings to format
|
|
15
|
+
* @param options - Locale, type, style, separator override, overflow flag
|
|
16
|
+
* @returns Array of list parts (elements and literals)
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* // Automatic locale detection
|
|
21
|
+
* const parts = useListFormat(['Apple', 'Banana', 'Cherry']);
|
|
22
|
+
* // en: [{ type: 'element', value: 'Apple' }, { type: 'literal', value: ', ' }, ...]
|
|
23
|
+
*
|
|
24
|
+
* // Spanish
|
|
25
|
+
* const parts = useListFormat(['Apple', 'Banana'], { locale: 'es' });
|
|
26
|
+
*
|
|
27
|
+
* // Disjunction ("or")
|
|
28
|
+
* const parts = useListFormat(['A', 'B', 'C'], { type: 'disjunction' });
|
|
29
|
+
* // en: "A, B, or C"
|
|
30
|
+
*
|
|
31
|
+
* // Manual separator override
|
|
32
|
+
* const parts = useListFormat(['A', 'B', 'C'], { separator: ' | ' });
|
|
33
|
+
* // "A | B | C"
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
function useListFormat(items, options = {}) {
|
|
37
|
+
const { locale, type = "conjunction", style = "long", separator, hasOverflow } = options;
|
|
38
|
+
return useMemo(() => {
|
|
39
|
+
if (items.length === 0) return [];
|
|
40
|
+
if (separator !== void 0) {
|
|
41
|
+
const parts = [];
|
|
42
|
+
items.forEach((item, i) => {
|
|
43
|
+
parts.push({
|
|
44
|
+
type: "element",
|
|
45
|
+
value: item,
|
|
46
|
+
index: i
|
|
47
|
+
});
|
|
48
|
+
if (i < items.length - 1) parts.push({
|
|
49
|
+
type: "literal",
|
|
50
|
+
value: separator,
|
|
51
|
+
index: i
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
return parts;
|
|
55
|
+
}
|
|
56
|
+
const resolvedLocale = locale ?? getDefaultLocale();
|
|
57
|
+
try {
|
|
58
|
+
const formatter = new Intl.ListFormat(resolvedLocale, {
|
|
59
|
+
type,
|
|
60
|
+
style
|
|
61
|
+
});
|
|
62
|
+
const itemsToFormat = hasOverflow && items.length > 1 ? [...items, ""] : items;
|
|
63
|
+
const formatted = formatter.formatToParts(itemsToFormat);
|
|
64
|
+
const partsToProcess = hasOverflow ? formatted.slice(0, -2) : formatted;
|
|
65
|
+
let elementIndex = 0;
|
|
66
|
+
return partsToProcess.map((part) => {
|
|
67
|
+
if (part.type === "element") return {
|
|
68
|
+
type: "element",
|
|
69
|
+
value: part.value,
|
|
70
|
+
index: elementIndex++
|
|
71
|
+
};
|
|
72
|
+
return {
|
|
73
|
+
type: "literal",
|
|
74
|
+
value: part.value,
|
|
75
|
+
index: Math.max(0, elementIndex - 1)
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
} catch {
|
|
79
|
+
const parts = [];
|
|
80
|
+
items.forEach((item, i) => {
|
|
81
|
+
parts.push({
|
|
82
|
+
type: "element",
|
|
83
|
+
value: item,
|
|
84
|
+
index: i
|
|
85
|
+
});
|
|
86
|
+
if (i < items.length - 1) parts.push({
|
|
87
|
+
type: "literal",
|
|
88
|
+
value: ", ",
|
|
89
|
+
index: i
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
return parts;
|
|
93
|
+
}
|
|
94
|
+
}, [
|
|
95
|
+
items,
|
|
96
|
+
locale,
|
|
97
|
+
type,
|
|
98
|
+
style,
|
|
99
|
+
separator,
|
|
100
|
+
hasOverflow
|
|
101
|
+
]);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
//#endregion
|
|
105
|
+
export { useListFormat };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as React from "react";
|
|
1
|
+
import * as React$1 from "react";
|
|
2
2
|
|
|
3
3
|
//#region src/react-ui/hooks/State/UseControlledState.tsx
|
|
4
4
|
/**
|
|
@@ -20,11 +20,11 @@ import * as React from "react";
|
|
|
20
20
|
*/
|
|
21
21
|
function useControlledState(props) {
|
|
22
22
|
const { value, defaultValue, onChange } = props;
|
|
23
|
-
const [state, setInternalState] = React.useState(value !== void 0 ? value : defaultValue);
|
|
24
|
-
React.useEffect(() => {
|
|
23
|
+
const [state, setInternalState] = React$1.useState(value !== void 0 ? value : defaultValue);
|
|
24
|
+
React$1.useEffect(() => {
|
|
25
25
|
if (value !== void 0) setInternalState(value);
|
|
26
26
|
}, [value]);
|
|
27
|
-
return [state, React.useCallback((next, ...args) => {
|
|
27
|
+
return [state, React$1.useCallback((next, ...args) => {
|
|
28
28
|
setInternalState(next);
|
|
29
29
|
onChange?.(next, ...args);
|
|
30
30
|
}, [onChange])];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import * as React from "react";
|
|
3
|
+
import * as React$1 from "react";
|
|
4
4
|
|
|
5
5
|
//#region src/react-ui/hooks/State/UseDataState.tsx
|
|
6
6
|
/**
|
|
@@ -31,8 +31,8 @@ function parseDatasetValue(value) {
|
|
|
31
31
|
* ```
|
|
32
32
|
*/
|
|
33
33
|
function useDataState(key, forwardedRef, onChange) {
|
|
34
|
-
const localRef = React.useRef(null);
|
|
35
|
-
React.useImperativeHandle(forwardedRef, () => localRef.current);
|
|
34
|
+
const localRef = React$1.useRef(null);
|
|
35
|
+
React$1.useImperativeHandle(forwardedRef, () => localRef.current);
|
|
36
36
|
const getSnapshot = () => {
|
|
37
37
|
const el = localRef.current;
|
|
38
38
|
return el ? parseDatasetValue(el.getAttribute(`data-${key}`)) : null;
|
|
@@ -52,8 +52,8 @@ function useDataState(key, forwardedRef, onChange) {
|
|
|
52
52
|
});
|
|
53
53
|
return () => observer.disconnect();
|
|
54
54
|
};
|
|
55
|
-
const value = React.useSyncExternalStore(subscribe, getSnapshot);
|
|
56
|
-
React.useEffect(() => {
|
|
55
|
+
const value = React$1.useSyncExternalStore(subscribe, getSnapshot);
|
|
56
|
+
React$1.useEffect(() => {
|
|
57
57
|
if (onChange) onChange(value);
|
|
58
58
|
}, [value, onChange]);
|
|
59
59
|
return [value, localRef];
|
|
@@ -11,4 +11,6 @@ export { useDataState } from './State/UseDataState';
|
|
|
11
11
|
export type { DataStateValue } from './State/UseDataState';
|
|
12
12
|
export { useIsInView } from './DOM/UseIsInView';
|
|
13
13
|
export type { IUseIsInViewOptions } from './DOM/UseIsInView';
|
|
14
|
+
export { useListFormat } from './Formatting/UseListFormat';
|
|
15
|
+
export type { IUseListFormatOptions, IListPart, ListFormatType, ListFormatStyle } from './Formatting/UseListFormat';
|
|
14
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react-ui/hooks/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,YAAY,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,YAAY,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAExE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,YAAY,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react-ui/hooks/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,YAAY,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,YAAY,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAExE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,YAAY,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,YAAY,EAAE,qBAAqB,EAAE,SAAS,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -2,3 +2,4 @@ import { useAutoHeight } from "./Animation/UseAutoHeight.js";
|
|
|
2
2
|
import { useIsInView } from "./DOM/UseIsInView.js";
|
|
3
3
|
import { useControlledState } from "./State/UseControlledState.js";
|
|
4
4
|
import { useDataState } from "./State/UseDataState.js";
|
|
5
|
+
import { useListFormat } from "./Formatting/UseListFormat.js";
|
package/dist/react-ui/index.js
CHANGED
|
@@ -5,6 +5,23 @@ import { useAutoHeight } from "./hooks/Animation/UseAutoHeight.js";
|
|
|
5
5
|
import { AutoHeight } from "./primitives/AutoHeight/index.js";
|
|
6
6
|
import { useIsInView } from "./hooks/DOM/UseIsInView.js";
|
|
7
7
|
import { CountingNumber } from "./primitives/CountingNumber/index.js";
|
|
8
|
+
import { ANIMATION_CONFIGS, ANIMATION_DEFAULTS, EASINGS, EFFECTS, PRESETS, RESPONSIVE_CONFIGS, TIMING, TRANSFORMS, getResponsiveDuration, getResponsiveStagger } from "./primitives/waapi/core/animationConstants.js";
|
|
9
|
+
import { useElementRegistry } from "./primitives/waapi/core/useElementRegistry.js";
|
|
10
|
+
import { usePositionCapture } from "./primitives/waapi/core/usePositionCapture.js";
|
|
11
|
+
import { useFLIPAnimation } from "./primitives/waapi/core/useFLIPAnimation.js";
|
|
12
|
+
import { useAnimationOrchestrator } from "./primitives/waapi/core/useAnimationOrchestrator.js";
|
|
13
|
+
import { SlidingNumber } from "./primitives/waapi/SlidingNumber/index.js";
|
|
14
|
+
import { SlidingText } from "./primitives/waapi/SlidingText/index.js";
|
|
15
|
+
import { useReorder } from "./primitives/waapi/Reorder/useReorder.js";
|
|
16
|
+
import { ReorderRoot } from "./primitives/waapi/Reorder/index.js";
|
|
17
|
+
import { useReorderPresence } from "./primitives/waapi/Reorder/useReorderPresence.js";
|
|
18
|
+
import { calculateSeparatorCoordination, shouldShowSeparator } from "./primitives/waapi/Reorder/utils/separatorCoordination.js";
|
|
19
|
+
import { useMorphContext } from "./primitives/waapi/Morph/MorphContext.js";
|
|
20
|
+
import { useFLIPClipPath } from "./primitives/waapi/Morph/techniques/useFLIPClipPath.js";
|
|
21
|
+
import { useCSSGridMorph } from "./primitives/waapi/Morph/techniques/useCSSGridMorph.js";
|
|
22
|
+
import { useViewTransitions } from "./primitives/waapi/Morph/techniques/useViewTransitions.js";
|
|
23
|
+
import { useMorph } from "./primitives/waapi/Morph/useMorph.js";
|
|
24
|
+
import { Morph } from "./primitives/waapi/Morph/index.js";
|
|
8
25
|
import "./primitives/index.js";
|
|
9
26
|
import { getStrictContext } from "./lib/get-strict-context.js";
|
|
10
27
|
import { useControlledState } from "./hooks/State/UseControlledState.js";
|
|
@@ -34,7 +51,6 @@ import { Button } from "./ui/Button/index.js";
|
|
|
34
51
|
import { cardVariants } from "./ui/Card/Card.styles.js";
|
|
35
52
|
import { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "./ui/Card/index.js";
|
|
36
53
|
import { Input } from "./ui/Input/index.js";
|
|
37
|
-
import { Textarea } from "./ui/Textarea/index.js";
|
|
38
54
|
import { inputGroupAddonVariants, inputGroupButtonVariants } from "./ui/InputGroup/InputGroup.styles.js";
|
|
39
55
|
import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea } from "./ui/InputGroup/index.js";
|
|
40
56
|
import { Combobox, ComboboxChip, ComboboxChips, ComboboxChipsInput, ComboboxCollection, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxLabel, ComboboxList, ComboboxSeparator, ComboboxTrigger, ComboboxValue, useComboboxAnchor } from "./ui/Combobox/index.js";
|
|
@@ -46,6 +62,10 @@ import { Separator } from "./ui/Separator/index.js";
|
|
|
46
62
|
import { fieldVariants } from "./ui/Field/Field.styles.js";
|
|
47
63
|
import { Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle } from "./ui/Field/index.js";
|
|
48
64
|
import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue } from "./ui/Select/index.js";
|
|
65
|
+
import { dataCardStyles, dataCardVariants } from "./ui/DataCard/DataCard.styles.js";
|
|
66
|
+
import { DataCard, DataCardActions, DataCardBracket, DataCardLabel, DataCardToggle, DataCardValue, useDataCard } from "./ui/DataCard/index.js";
|
|
67
|
+
import { useListFormat } from "./hooks/Formatting/UseListFormat.js";
|
|
68
|
+
import { TextFlow } from "./ui/TextFlow/index.js";
|
|
49
69
|
import "./ui/index.js";
|
|
50
70
|
import { MorphingPopover, MorphingPopoverWithTarget } from "./components/MorphingPopover/index.js";
|
|
51
71
|
import "./components/index.js";
|
|
@@ -85,4 +105,4 @@ import { XIcon } from "./icons/lucide-animated/x.js";
|
|
|
85
105
|
import { HugeIcons } from "./icons/index.js";
|
|
86
106
|
import "./lib/index.js";
|
|
87
107
|
|
|
88
|
-
export { Accordion, AccordionHeader, AccordionItem, AccordionPanel, AccordionStyles, AccordionTrigger, ActivityIcon, AlertDialog, AlertDialogBackdrop, AlertDialogClose, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogPopup, AlertDialogPortal, AlertDialogStyles, AlertDialogTitle, AlertDialogTrigger, ArrowDownToLineIcon, ArrowUpIcon, AutoHeight, Badge, BellElectricIcon, BellIcon, BotIcon, BoxIcon, Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Check, Checkbox, CheckboxIndicator, CircleCheckIcon, Combobox, ComboboxChip, ComboboxChips, ComboboxChipsInput, ComboboxCollection, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxLabel, ComboboxList, ComboboxSeparator, ComboboxTrigger, ComboboxValue, CornerBracket, CountingNumber, DeleteIcon, Dialog, DialogBackdrop, DialogClose, DialogDescription, DialogFooter, DialogHeader, DialogPopup, DialogPortal, DialogTitle, DialogTrigger, DownloadIcon, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Edit2, Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle, Globe, Highlight, HighlightItem, HomeIcon, HugeIcons, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, Label, Layers, LayoutPanelTopIcon, ListIcon, Menu, MenuArrow, MenuCheckboxItem, MenuCheckboxItemIndicator, MenuGroup, MenuGroupLabel, MenuHighlight, MenuHighlightItem, MenuItem, MenuPopup, MenuPortal, MenuPositioner, MenuRadioGroup, MenuRadioItem, MenuRadioItemIndicator, MenuSeparator, MenuShortcut, MenuSubmenu, MenuSubmenuTrigger, MenuTrigger, MorphingPopover, MorphingPopoverWithTarget, Package, Palette, PlusIcon, Popover, PopoverArrow, PopoverBackdrop, PopoverClose, PopoverDescription, PopoverPopup, PopoverPortal, PopoverPositioner, PopoverTitle, PopoverTrigger, Progress, ProgressIndicator, ProgressLabel, ProgressTrack, ProgressValue, RefreshCw, Rocket, Save, SearchIcon, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, SettingsIcon, Slot, Switch, SwitchIcon, SwitchThumb, Tabs, TabsHighlight, TabsHighlightItem, TabsList, TabsPanel, TabsPanels, TabsTab, TerminalIcon,
|
|
108
|
+
export { ANIMATION_CONFIGS, ANIMATION_DEFAULTS, Accordion, AccordionHeader, AccordionItem, AccordionPanel, AccordionStyles, AccordionTrigger, ActivityIcon, AlertDialog, AlertDialogBackdrop, AlertDialogClose, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogPopup, AlertDialogPortal, AlertDialogStyles, AlertDialogTitle, AlertDialogTrigger, ArrowDownToLineIcon, ArrowUpIcon, AutoHeight, Badge, BellElectricIcon, BellIcon, BotIcon, BoxIcon, Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Check, Checkbox, CheckboxIndicator, CircleCheckIcon, Combobox, ComboboxChip, ComboboxChips, ComboboxChipsInput, ComboboxCollection, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxLabel, ComboboxList, ComboboxSeparator, ComboboxTrigger, ComboboxValue, CornerBracket, CountingNumber, DataCard, DataCardActions, DataCardBracket, DataCardLabel, DataCardToggle, DataCardValue, DeleteIcon, Dialog, DialogBackdrop, DialogClose, DialogDescription, DialogFooter, DialogHeader, DialogPopup, DialogPortal, DialogTitle, DialogTrigger, DownloadIcon, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EASINGS, EFFECTS, Edit2, Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle, Globe, Highlight, HighlightItem, HomeIcon, HugeIcons, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, Label, Layers, LayoutPanelTopIcon, ListIcon, Menu, MenuArrow, MenuCheckboxItem, MenuCheckboxItemIndicator, MenuGroup, MenuGroupLabel, MenuHighlight, MenuHighlightItem, MenuItem, MenuPopup, MenuPortal, MenuPositioner, MenuRadioGroup, MenuRadioItem, MenuRadioItemIndicator, MenuSeparator, MenuShortcut, MenuSubmenu, MenuSubmenuTrigger, MenuTrigger, Morph, MorphingPopover, MorphingPopoverWithTarget, PRESETS, Package, Palette, PlusIcon, Popover, PopoverArrow, PopoverBackdrop, PopoverClose, PopoverDescription, PopoverPopup, PopoverPortal, PopoverPositioner, PopoverTitle, PopoverTrigger, Progress, ProgressIndicator, ProgressLabel, ProgressTrack, ProgressValue, RESPONSIVE_CONFIGS, RefreshCw, ReorderRoot as Reorder, Rocket, Save, SearchIcon, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, SettingsIcon, SlidingNumber, SlidingText, Slot, Switch, SwitchIcon, SwitchThumb, TIMING, TRANSFORMS, Tabs, TabsHighlight, TabsHighlightItem, TabsList, TabsPanel, TabsPanels, TabsTab, TerminalIcon, TextFlow, Tooltip, TooltipArrow, TooltipPopup, TooltipPortal, TooltipPositioner, TooltipProvider, TooltipTrigger, Trash2, TrendingDownIcon, TrendingUpIcon, Type, Upload, XIcon, accordionVariants, badgeVariants, bracketVariants, buttonStateStyles, buttonVariants, calculateSeparatorCoordination, cardVariants, checkboxStyles, cn, dataCardStyles, dataCardVariants, dialogStyles, fieldVariants, getResponsiveDuration, getResponsiveStagger, getStrictContext, inputGroupAddonVariants, inputGroupButtonVariants, popoverStyles, progressStyles, shouldShowSeparator, switchStyles, tooltipStyles, useAccordionItem, useAlertDialog, useAnimationOrchestrator, useAutoHeight, useCSSGridMorph, useCheckbox, useComboboxAnchor, useControlledState, useDataCard, useDataState, useDialog, useElementRegistry, useFLIPAnimation, useFLIPClipPath, useHighlight, useIsInView, useListFormat, useMenu, useMenuActiveValue, useMorph, useMorphContext, usePopover, usePositionCapture, useProgress, useReorder, useReorderPresence, useSwitch, useTooltip, useViewTransitions };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as React from "react";
|
|
1
|
+
import * as React$1 from "react";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/react-ui/lib/get-strict-context.tsx
|
|
@@ -23,13 +23,13 @@ import { jsx } from "react/jsx-runtime";
|
|
|
23
23
|
* ```
|
|
24
24
|
*/
|
|
25
25
|
function getStrictContext(name) {
|
|
26
|
-
const Context = React.createContext(void 0);
|
|
26
|
+
const Context = React$1.createContext(void 0);
|
|
27
27
|
const Provider = ({ value, children }) => /* @__PURE__ */ jsx(Context.Provider, {
|
|
28
28
|
value,
|
|
29
29
|
children
|
|
30
30
|
});
|
|
31
31
|
const useSafeContext = () => {
|
|
32
|
-
const ctx = React.useContext(Context);
|
|
32
|
+
const ctx = React$1.useContext(Context);
|
|
33
33
|
if (ctx === void 0) throw new Error(`useContext must be used within ${name ?? "a Provider"}`);
|
|
34
34
|
return ctx;
|
|
35
35
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { useIsInView } from "../../hooks/DOM/UseIsInView.js";
|
|
4
|
-
import * as React from "react";
|
|
4
|
+
import * as React$1 from "react";
|
|
5
5
|
import { useMotionValue, useSpring } from "motion/react";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
7
|
|
|
@@ -38,7 +38,7 @@ function CountingNumber({ ref, number, fromNumber = 0, padStart = false, inView
|
|
|
38
38
|
const decimals = typeof decimalPlaces === "number" ? decimalPlaces : numberStr.includes(".") ? numberStr.split(".")[1]?.length ?? 0 : 0;
|
|
39
39
|
const motionVal = useMotionValue(initiallyStable ? number : fromNumber);
|
|
40
40
|
const springVal = useSpring(motionVal, transition);
|
|
41
|
-
React.useEffect(() => {
|
|
41
|
+
React$1.useEffect(() => {
|
|
42
42
|
const timeoutId = setTimeout(() => {
|
|
43
43
|
if (isInView) motionVal.set(number);
|
|
44
44
|
}, delay);
|
|
@@ -49,7 +49,7 @@ function CountingNumber({ ref, number, fromNumber = 0, padStart = false, inView
|
|
|
49
49
|
motionVal,
|
|
50
50
|
delay
|
|
51
51
|
]);
|
|
52
|
-
React.useEffect(() => {
|
|
52
|
+
React$1.useEffect(() => {
|
|
53
53
|
const unsubscribe = springVal.on("change", (latest) => {
|
|
54
54
|
if (localRef.current) {
|
|
55
55
|
let formatted = decimals > 0 ? latest.toFixed(decimals) : Math.round(latest).toString();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { cn } from "../../lib/utils.js";
|
|
4
|
-
import * as React from "react";
|
|
4
|
+
import * as React$1 from "react";
|
|
5
5
|
import { AnimatePresence, motion } from "motion/react";
|
|
6
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
|
|
@@ -12,7 +12,7 @@ const DEFAULT_BOUNDS_OFFSET = {
|
|
|
12
12
|
width: 0,
|
|
13
13
|
height: 0
|
|
14
14
|
};
|
|
15
|
-
const HighlightContext = React.createContext(void 0);
|
|
15
|
+
const HighlightContext = React$1.createContext(void 0);
|
|
16
16
|
/**
|
|
17
17
|
* Hook to access the Highlight context.
|
|
18
18
|
* Must be used within a Highlight provider.
|
|
@@ -20,7 +20,7 @@ const HighlightContext = React.createContext(void 0);
|
|
|
20
20
|
* @returns The current highlight context
|
|
21
21
|
*/
|
|
22
22
|
function useHighlight() {
|
|
23
|
-
const context = React.useContext(HighlightContext);
|
|
23
|
+
const context = React$1.useContext(HighlightContext);
|
|
24
24
|
if (!context) throw new Error("useHighlight must be used within a HighlightProvider");
|
|
25
25
|
return context;
|
|
26
26
|
}
|
|
@@ -49,20 +49,20 @@ function Highlight({ ref, ...props }) {
|
|
|
49
49
|
stiffness: 350,
|
|
50
50
|
damping: 35
|
|
51
51
|
}, hover = false, click = true, enabled = true, controlledItems, disabled = false, exitDelay = 200, mode = "children" } = props;
|
|
52
|
-
const localRef = React.useRef(null);
|
|
53
|
-
React.useImperativeHandle(ref, () => localRef.current);
|
|
52
|
+
const localRef = React$1.useRef(null);
|
|
53
|
+
React$1.useImperativeHandle(ref, () => localRef.current);
|
|
54
54
|
const boundsOffset = props?.boundsOffset ?? DEFAULT_BOUNDS_OFFSET;
|
|
55
55
|
const boundsOffsetTop = boundsOffset.top ?? 0;
|
|
56
56
|
const boundsOffsetLeft = boundsOffset.left ?? 0;
|
|
57
57
|
const boundsOffsetWidth = boundsOffset.width ?? 0;
|
|
58
58
|
const boundsOffsetHeight = boundsOffset.height ?? 0;
|
|
59
|
-
const boundsOffsetRef = React.useRef({
|
|
59
|
+
const boundsOffsetRef = React$1.useRef({
|
|
60
60
|
top: boundsOffsetTop,
|
|
61
61
|
left: boundsOffsetLeft,
|
|
62
62
|
width: boundsOffsetWidth,
|
|
63
63
|
height: boundsOffsetHeight
|
|
64
64
|
});
|
|
65
|
-
React.useEffect(() => {
|
|
65
|
+
React$1.useEffect(() => {
|
|
66
66
|
boundsOffsetRef.current = {
|
|
67
67
|
top: boundsOffsetTop,
|
|
68
68
|
left: boundsOffsetLeft,
|
|
@@ -75,9 +75,9 @@ function Highlight({ ref, ...props }) {
|
|
|
75
75
|
boundsOffsetWidth,
|
|
76
76
|
boundsOffsetHeight
|
|
77
77
|
]);
|
|
78
|
-
const [activeValue, setActiveValue] = React.useState(value ?? defaultValue ?? null);
|
|
79
|
-
const [boundsState, setBoundsState] = React.useState(null);
|
|
80
|
-
const [activeClassNameState, setActiveClassNameState] = React.useState("");
|
|
78
|
+
const [activeValue, setActiveValue] = React$1.useState(value ?? defaultValue ?? null);
|
|
79
|
+
const [boundsState, setBoundsState] = React$1.useState(null);
|
|
80
|
+
const [activeClassNameState, setActiveClassNameState] = React$1.useState("");
|
|
81
81
|
const safeSetActiveValue = (id) => {
|
|
82
82
|
setActiveValue((prev) => {
|
|
83
83
|
if (prev !== id) {
|
|
@@ -87,8 +87,8 @@ function Highlight({ ref, ...props }) {
|
|
|
87
87
|
return prev;
|
|
88
88
|
});
|
|
89
89
|
};
|
|
90
|
-
const safeSetBoundsRef = React.useRef(void 0);
|
|
91
|
-
React.useEffect(() => {
|
|
90
|
+
const safeSetBoundsRef = React$1.useRef(void 0);
|
|
91
|
+
React$1.useEffect(() => {
|
|
92
92
|
safeSetBoundsRef.current = (bounds) => {
|
|
93
93
|
if (!localRef.current) return;
|
|
94
94
|
const containerRect = localRef.current.getBoundingClientRect();
|
|
@@ -108,15 +108,15 @@ function Highlight({ ref, ...props }) {
|
|
|
108
108
|
const safeSetBounds = (bounds) => {
|
|
109
109
|
safeSetBoundsRef.current?.(bounds);
|
|
110
110
|
};
|
|
111
|
-
const clearBounds = React.useCallback(() => {
|
|
111
|
+
const clearBounds = React$1.useCallback(() => {
|
|
112
112
|
setBoundsState((prev) => prev === null ? prev : null);
|
|
113
113
|
}, []);
|
|
114
|
-
React.useEffect(() => {
|
|
114
|
+
React$1.useEffect(() => {
|
|
115
115
|
if (value !== void 0) setActiveValue(value);
|
|
116
116
|
else if (defaultValue !== void 0) setActiveValue(defaultValue);
|
|
117
117
|
}, [value, defaultValue]);
|
|
118
|
-
const id = React.useId();
|
|
119
|
-
React.useEffect(() => {
|
|
118
|
+
const id = React$1.useId();
|
|
119
|
+
React$1.useEffect(() => {
|
|
120
120
|
if (mode !== "parent") return;
|
|
121
121
|
const container = localRef.current;
|
|
122
122
|
if (!container) return;
|
|
@@ -195,7 +195,7 @@ function Highlight({ ref, ...props }) {
|
|
|
195
195
|
setActiveClassName: setActiveClassNameState,
|
|
196
196
|
forceUpdateBounds: props?.forceUpdateBounds
|
|
197
197
|
},
|
|
198
|
-
children: enabled ? controlledItems ? render(children) : render(React.Children.map(children, (child, index) => /* @__PURE__ */ jsx(HighlightItem, {
|
|
198
|
+
children: enabled ? controlledItems ? render(children) : render(React$1.Children.map(children, (child, index) => /* @__PURE__ */ jsx(HighlightItem, {
|
|
199
199
|
className: props?.itemsClassName,
|
|
200
200
|
children: child
|
|
201
201
|
}, index))) : children
|
|
@@ -223,7 +223,7 @@ function getNonOverridingDataAttributes(element, dataAttributes) {
|
|
|
223
223
|
* ```
|
|
224
224
|
*/
|
|
225
225
|
function HighlightItem({ ref, as, children, id, value, className, style, transition, disabled = false, activeClassName, exitDelay, asChild = false, forceUpdateBounds, ...props }) {
|
|
226
|
-
const itemId = React.useId();
|
|
226
|
+
const itemId = React$1.useId();
|
|
227
227
|
const { activeValue, setActiveValue, mode, setBounds, clearBounds, hover, click, enabled, className: contextClassName, style: contextStyle, transition: contextTransition, id: contextId, disabled: contextDisabled, exitDelay: contextExitDelay, forceUpdateBounds: contextForceUpdateBounds, setActiveClassName } = useHighlight();
|
|
228
228
|
const Component = as ?? "div";
|
|
229
229
|
const element = children;
|
|
@@ -231,12 +231,12 @@ function HighlightItem({ ref, as, children, id, value, className, style, transit
|
|
|
231
231
|
const isActive = activeValue === childValue;
|
|
232
232
|
const isDisabled = disabled === void 0 ? contextDisabled : disabled;
|
|
233
233
|
const itemTransition = transition ?? contextTransition;
|
|
234
|
-
const localRef = React.useRef(null);
|
|
235
|
-
React.useImperativeHandle(ref, () => localRef.current);
|
|
236
|
-
const refCallback = React.useCallback((node) => {
|
|
234
|
+
const localRef = React$1.useRef(null);
|
|
235
|
+
React$1.useImperativeHandle(ref, () => localRef.current);
|
|
236
|
+
const refCallback = React$1.useCallback((node) => {
|
|
237
237
|
localRef.current = node;
|
|
238
238
|
}, []);
|
|
239
|
-
React.useEffect(() => {
|
|
239
|
+
React$1.useEffect(() => {
|
|
240
240
|
if (mode !== "parent") return;
|
|
241
241
|
let rafId;
|
|
242
242
|
let previousBounds = null;
|
|
@@ -270,7 +270,7 @@ function HighlightItem({ ref, as, children, id, value, className, style, transit
|
|
|
270
270
|
forceUpdateBounds,
|
|
271
271
|
contextForceUpdateBounds
|
|
272
272
|
]);
|
|
273
|
-
if (!React.isValidElement(children)) return children;
|
|
273
|
+
if (!React$1.isValidElement(children)) return children;
|
|
274
274
|
const dataAttributes = {
|
|
275
275
|
"data-active": isActive ? "true" : "false",
|
|
276
276
|
"aria-selected": isActive,
|
|
@@ -292,7 +292,7 @@ function HighlightItem({ ref, as, children, id, value, className, style, transit
|
|
|
292
292
|
element.props.onClick?.(e);
|
|
293
293
|
} } : {};
|
|
294
294
|
if (asChild) {
|
|
295
|
-
if (mode === "children") return React.cloneElement(element, {
|
|
295
|
+
if (mode === "children") return React$1.cloneElement(element, {
|
|
296
296
|
key: childValue,
|
|
297
297
|
ref: refCallback,
|
|
298
298
|
className: cn("relative", element.props.className),
|
|
@@ -337,7 +337,7 @@ function HighlightItem({ ref, as, children, id, value, className, style, transit
|
|
|
337
337
|
...dataAttributes,
|
|
338
338
|
children
|
|
339
339
|
})] }));
|
|
340
|
-
return React.cloneElement(element, {
|
|
340
|
+
return React$1.cloneElement(element, {
|
|
341
341
|
ref: refCallback,
|
|
342
342
|
...getNonOverridingDataAttributes(element, {
|
|
343
343
|
...dataAttributes,
|
|
@@ -378,7 +378,7 @@ function HighlightItem({ ref, as, children, id, value, className, style, transit
|
|
|
378
378
|
},
|
|
379
379
|
...dataAttributes
|
|
380
380
|
})
|
|
381
|
-
}), React.cloneElement(element, {
|
|
381
|
+
}), React$1.cloneElement(element, {
|
|
382
382
|
style: {
|
|
383
383
|
position: "relative",
|
|
384
384
|
zIndex: 1
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { cn } from "../../lib/utils.js";
|
|
4
|
-
import * as React from "react";
|
|
4
|
+
import * as React$1 from "react";
|
|
5
5
|
import { isMotionComponent, motion } from "motion/react";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
7
|
|
|
@@ -52,8 +52,8 @@ function mergeProps(childProps, slotProps) {
|
|
|
52
52
|
*/
|
|
53
53
|
function Slot({ children, ref, ...props }) {
|
|
54
54
|
const isAlreadyMotion = typeof children.type === "object" && children.type !== null && isMotionComponent(children.type);
|
|
55
|
-
const Base = React.useMemo(() => isAlreadyMotion ? children.type : motion.create(children.type), [isAlreadyMotion, children.type]);
|
|
56
|
-
if (!React.isValidElement(children)) return null;
|
|
55
|
+
const Base = React$1.useMemo(() => isAlreadyMotion ? children.type : motion.create(children.type), [isAlreadyMotion, children.type]);
|
|
56
|
+
if (!React$1.isValidElement(children)) return null;
|
|
57
57
|
const { ref: childRef, ...childProps } = children.props;
|
|
58
58
|
return /* @__PURE__ */ jsx(Base, {
|
|
59
59
|
...mergeProps(childProps, props),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react-ui/primitives/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react-ui/primitives/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AAGjC,cAAc,SAAS,CAAC"}
|
|
@@ -2,3 +2,21 @@ import { Slot } from "./Slot/index.js";
|
|
|
2
2
|
import { Highlight, HighlightItem, useHighlight } from "./Highlight/index.js";
|
|
3
3
|
import { AutoHeight } from "./AutoHeight/index.js";
|
|
4
4
|
import { CountingNumber } from "./CountingNumber/index.js";
|
|
5
|
+
import { ANIMATION_CONFIGS, ANIMATION_DEFAULTS, EASINGS, EFFECTS, PRESETS, RESPONSIVE_CONFIGS, TIMING, TRANSFORMS, getResponsiveDuration, getResponsiveStagger } from "./waapi/core/animationConstants.js";
|
|
6
|
+
import { useElementRegistry } from "./waapi/core/useElementRegistry.js";
|
|
7
|
+
import { usePositionCapture } from "./waapi/core/usePositionCapture.js";
|
|
8
|
+
import { useFLIPAnimation } from "./waapi/core/useFLIPAnimation.js";
|
|
9
|
+
import { useAnimationOrchestrator } from "./waapi/core/useAnimationOrchestrator.js";
|
|
10
|
+
import { SlidingNumber } from "./waapi/SlidingNumber/index.js";
|
|
11
|
+
import { SlidingText } from "./waapi/SlidingText/index.js";
|
|
12
|
+
import { useReorder } from "./waapi/Reorder/useReorder.js";
|
|
13
|
+
import { ReorderRoot } from "./waapi/Reorder/index.js";
|
|
14
|
+
import { useReorderPresence } from "./waapi/Reorder/useReorderPresence.js";
|
|
15
|
+
import { calculateSeparatorCoordination, shouldShowSeparator } from "./waapi/Reorder/utils/separatorCoordination.js";
|
|
16
|
+
import { useMorphContext } from "./waapi/Morph/MorphContext.js";
|
|
17
|
+
import { useFLIPClipPath } from "./waapi/Morph/techniques/useFLIPClipPath.js";
|
|
18
|
+
import { useCSSGridMorph } from "./waapi/Morph/techniques/useCSSGridMorph.js";
|
|
19
|
+
import { useViewTransitions } from "./waapi/Morph/techniques/useViewTransitions.js";
|
|
20
|
+
import { useMorph } from "./waapi/Morph/useMorph.js";
|
|
21
|
+
import { Morph } from "./waapi/Morph/index.js";
|
|
22
|
+
import "./waapi/index.js";
|