@cdx-ui/components 0.0.1-beta.110 → 0.0.1-beta.112
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/lib/commonjs/components/Box/Box.js +1 -11
- package/lib/commonjs/components/Box/Box.js.map +1 -1
- package/lib/commonjs/components/Carousel/index.js +153 -0
- package/lib/commonjs/components/Carousel/index.js.map +1 -0
- package/lib/commonjs/components/Carousel/paginationNavigation.js +35 -0
- package/lib/commonjs/components/Carousel/paginationNavigation.js.map +1 -0
- package/lib/commonjs/components/Carousel/styles.js +21 -0
- package/lib/commonjs/components/Carousel/styles.js.map +1 -0
- package/lib/commonjs/components/Link/index.js.map +1 -1
- package/lib/commonjs/components/index.js +12 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/module/components/Box/Box.js +1 -11
- package/lib/module/components/Box/Box.js.map +1 -1
- package/lib/module/components/Carousel/index.js +147 -0
- package/lib/module/components/Carousel/index.js.map +1 -0
- package/lib/module/components/Carousel/paginationNavigation.js +31 -0
- package/lib/module/components/Carousel/paginationNavigation.js.map +1 -0
- package/lib/module/components/Carousel/styles.js +18 -0
- package/lib/module/components/Carousel/styles.js.map +1 -0
- package/lib/module/components/Link/index.js.map +1 -1
- package/lib/module/components/index.js +1 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/typescript/components/Box/Box.d.ts +0 -3
- package/lib/typescript/components/Box/Box.d.ts.map +1 -1
- package/lib/typescript/components/Carousel/index.d.ts +70 -0
- package/lib/typescript/components/Carousel/index.d.ts.map +1 -0
- package/lib/typescript/components/Carousel/paginationNavigation.d.ts +12 -0
- package/lib/typescript/components/Carousel/paginationNavigation.d.ts.map +1 -0
- package/lib/typescript/components/Carousel/styles.d.ts +8 -0
- package/lib/typescript/components/Carousel/styles.d.ts.map +1 -0
- package/lib/typescript/components/Link/index.d.ts +1 -0
- package/lib/typescript/components/Link/index.d.ts.map +1 -1
- package/lib/typescript/components/index.d.ts +1 -0
- package/lib/typescript/components/index.d.ts.map +1 -1
- package/package.json +6 -5
- package/src/components/Box/Box.tsx +3 -7
- package/src/components/Carousel/index.tsx +263 -0
- package/src/components/Carousel/paginationNavigation.ts +32 -0
- package/src/components/Carousel/styles.ts +18 -0
- package/src/components/Link/index.tsx +1 -0
- package/src/components/index.ts +1 -0
- package/lib/commonjs/utils/WrapStringChild.js +0 -22
- package/lib/commonjs/utils/WrapStringChild.js.map +0 -1
- package/lib/module/utils/WrapStringChild.js +0 -18
- package/lib/module/utils/WrapStringChild.js.map +0 -1
- package/lib/typescript/utils/WrapStringChild.d.ts +0 -10
- package/lib/typescript/utils/WrapStringChild.d.ts.map +0 -1
- package/src/utils/WrapStringChild.tsx +0 -25
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["forwardRef","Platform","Text","View","LinkRoot","LinkRootPrimitive","Slot","dataAttributes","mergeDataAttributes","useLinkInteractionContext","cn","Icon","linkIconVariants","linkLabelVariants","linkNativeUnderlineVariants","linkRootVariants","jsx","_jsx","LinkProvider","className","children","style","props","ref","rootClassName","slot","displayName","LinkLabel","asChild","visited","computedClassName","Comp","textElement","OS","LinkIcon","as","Link","Object","assign","Label"],"sourceRoot":"../../../../src","sources":["components/Link/index.tsx"],"mappings":";;AAAA,SAASA,UAAU,QAAwB,OAAO;AAClD,SAASC,QAAQ,EAAEC,IAAI,EAAEC,IAAI,QAAwB,cAAc;AACnE,SACEC,QAAQ,IAAIC,iBAAiB,EAC7BC,IAAI,EACJC,cAAc,EACdC,mBAAmB,EACnBC,yBAAyB,QAEpB,oBAAoB;AAC3B,SAASC,EAAE,QAAQ,eAAe;AAClC,SAASC,IAAI,QAAwB,SAAS;AAC9C,SACEC,gBAAgB,EAChBC,iBAAiB,EACjBC,2BAA2B,EAC3BC,gBAAgB,QACX,UAAU;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAElB,SAASC,YAAY,QAA0C,oBAAoB;;AAEnF;AACA;AACA;;
|
|
1
|
+
{"version":3,"names":["forwardRef","Platform","Text","View","LinkRoot","LinkRootPrimitive","Slot","dataAttributes","mergeDataAttributes","useLinkInteractionContext","cn","Icon","linkIconVariants","linkLabelVariants","linkNativeUnderlineVariants","linkRootVariants","jsx","_jsx","LinkProvider","className","children","style","props","ref","rootClassName","slot","displayName","LinkLabel","asChild","visited","computedClassName","Comp","textElement","OS","LinkIcon","as","Link","Object","assign","Label"],"sourceRoot":"../../../../src","sources":["components/Link/index.tsx"],"mappings":";;AAAA,SAASA,UAAU,QAAwB,OAAO;AAClD,SAASC,QAAQ,EAAEC,IAAI,EAAEC,IAAI,QAAwB,cAAc;AACnE,SACEC,QAAQ,IAAIC,iBAAiB,EAC7BC,IAAI,EACJC,cAAc,EACdC,mBAAmB,EACnBC,yBAAyB,QAEpB,oBAAoB;AAC3B,SAASC,EAAE,QAAQ,eAAe;AAClC,SAASC,IAAI,QAAwB,SAAS;AAC9C,SACEC,gBAAgB,EAChBC,iBAAiB,EACjBC,2BAA2B,EAC3BC,gBAAgB,QACX,UAAU;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAElB,SAASC,YAAY,QAA0C,oBAAoB;;AAEnF;AACA;AACA;;AAQA,MAAMd,QAAQ,gBAAGJ,UAAU,CAAkB,CAAC;EAAEmB,SAAS;EAAEC,QAAQ;EAAEC,KAAK;EAAE,GAAGC;AAAM,CAAC,EAAEC,GAAG,KAAK;EAC9F,MAAMC,aAAa,GAAGd,EAAE,CAACK,gBAAgB,CAAC,CAAC,EAAEI,SAAS,CAAC;EAEvD,oBACEF,IAAA,CAACZ,iBAAiB;IAChBkB,GAAG,EAAEA,GAAI;IACTJ,SAAS,EAAEK,aAAc;IACzBH,KAAK,EAAEA,KAAM;IAAA,GACTC,KAAK;IAAA,GACLd,mBAAmB,CAACc,KAAK,EAAEf,cAAc,CAAC;MAAEkB,IAAI,EAAE;IAAO,CAAC,CAAC,CAAC;IAAAL,QAAA,EAE/DA;EAAQ,CACQ,CAAC;AAExB,CAAC,CAAC;AAEFhB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C;IAAEiB;EAAQ,CAAC,CAAC,EAAEV,SAAS,CAAC;EAEtE,oBACEF,IAAA,CAACN,IAAI;IACHwB,EAAE,EAAEA,EAAG;IACPhB,SAAS,EAAEW,iBAAkB;IAC7BT,KAAK,EAAEA,KAAM;IAAA,GACTC,KAAK;IAAA,GACLd,mBAAmB,CAACc,KAAK,EAAEf,cAAc,CAAC;MAAEkB,IAAI,EAAE;IAAY,CAAC,CAAC;EAAC,CACtE,CAAC;AAEN,CAAC;AAEDS,QAAQ,CAACR,WAAW,GAAG,WAAW;;AAElC;AACA;AACA;;AAOA,OAAO,MAAMU,IAAI,GAAGC,MAAM,CAACC,MAAM,CAAClC,QAAQ,EAAE;EAC1CmC,KAAK,EAAEZ,SAAS;EAChBhB,IAAI,EAAEuB;AACR,CAAC,CAA0B","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["HStack","VStack"],"sourceRoot":"../../../src","sources":["components/index.ts"],"mappings":";;AAAA,cAAc,SAAS;AACvB,cAAc,eAAe;AAC7B,cAAc,UAAU;AACxB,cAAc,SAAS;AACvB,cAAc,eAAe;AAC7B,cAAc,OAAO;AACrB,cAAc,UAAU;AACxB,cAAc,QAAQ;AACtB,cAAc,YAAY;AAC1B,cAAc,QAAQ;AACtB,cAAc,iBAAiB;AAC/B,cAAc,UAAU;AACxB,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,QAAQ;AACtB,cAAc,SAAS;AACvB,cAAc,uBAAuB;AACrC,cAAc,SAAS;AACvB,cAAc,YAAY;AAC1B,cAAc,QAAQ;AACtB,cAAc,YAAY;AAC1B,cAAc,eAAe;AAC7B,cAAc,YAAY;AAC1B,cAAc,qBAAqB;AACnC,cAAc,SAAS;AACvB,cAAc,eAAe;AAC7B,cAAc,UAAU;AACxB,cAAc,mBAAmB;AACjC,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,QAAQ;AACtB,cAAc,SAAS;AACvB,SAASA,MAAM,EAAEC,MAAM,QAAQ,SAAS;AACxC,cAAc,WAAW;AACzB,cAAc,QAAQ;AACtB,cAAc,QAAQ;AACtB,cAAc,cAAc;AAC5B,cAAc,qBAAqB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["HStack","VStack"],"sourceRoot":"../../../src","sources":["components/index.ts"],"mappings":";;AAAA,cAAc,SAAS;AACvB,cAAc,eAAe;AAC7B,cAAc,UAAU;AACxB,cAAc,SAAS;AACvB,cAAc,eAAe;AAC7B,cAAc,OAAO;AACrB,cAAc,UAAU;AACxB,cAAc,QAAQ;AACtB,cAAc,YAAY;AAC1B,cAAc,YAAY;AAC1B,cAAc,QAAQ;AACtB,cAAc,iBAAiB;AAC/B,cAAc,UAAU;AACxB,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,QAAQ;AACtB,cAAc,SAAS;AACvB,cAAc,uBAAuB;AACrC,cAAc,SAAS;AACvB,cAAc,YAAY;AAC1B,cAAc,QAAQ;AACtB,cAAc,YAAY;AAC1B,cAAc,eAAe;AAC7B,cAAc,YAAY;AAC1B,cAAc,qBAAqB;AACnC,cAAc,SAAS;AACvB,cAAc,eAAe;AAC7B,cAAc,UAAU;AACxB,cAAc,mBAAmB;AACjC,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,QAAQ;AACtB,cAAc,SAAS;AACvB,SAASA,MAAM,EAAEC,MAAM,QAAQ,SAAS;AACxC,cAAc,WAAW;AACzB,cAAc,QAAQ;AACtB,cAAc,QAAQ;AACtB,cAAc,cAAc;AAC5B,cAAc,qBAAqB","ignoreList":[]}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { View, type ViewProps } from 'react-native';
|
|
2
|
-
import type { TextProps } from '../Text';
|
|
3
2
|
export interface BoxProps extends ViewProps {
|
|
4
3
|
className?: string;
|
|
5
|
-
textProps?: TextProps;
|
|
6
4
|
}
|
|
7
|
-
/** @deprecated Use View instead */
|
|
8
5
|
export declare const Box: import("react").ForwardRefExoticComponent<BoxProps & import("react").RefAttributes<View>>;
|
|
9
6
|
//# sourceMappingURL=Box.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Box.d.ts","sourceRoot":"","sources":["../../../../src/components/Box/Box.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAEpD,
|
|
1
|
+
{"version":3,"file":"Box.d.ts","sourceRoot":"","sources":["../../../../src/components/Box/Box.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,WAAW,QAAS,SAAQ,SAAS;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,GAAG,2FAQf,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type ReactElement, type ReactNode, type Ref, type RefObject } from 'react';
|
|
2
|
+
import type { AccessibilityRole, AccessibilityState } from 'react-native';
|
|
3
|
+
import type { SharedValue } from 'react-native-reanimated';
|
|
4
|
+
import { type ICarouselInstance, type TCarouselProps } from 'react-native-reanimated-carousel';
|
|
5
|
+
export type CarouselRef = ICarouselInstance;
|
|
6
|
+
/**
|
|
7
|
+
* Full passthrough of `react-native-reanimated-carousel`'s own props (per `01-api-design.md`,
|
|
8
|
+
* Resolved Question #1) — re-exported under a Forge-owned name so consumers never import the
|
|
9
|
+
* adopted library directly. A type alias (not `interface extends`) because `TCarouselProps<T>`
|
|
10
|
+
* is itself a union-containing type (vertical/mode discriminants), which interfaces cannot extend.
|
|
11
|
+
*/
|
|
12
|
+
export type CarouselProps<T> = TCarouselProps<T> & {
|
|
13
|
+
className?: string;
|
|
14
|
+
/** Rendered inside the carousel's progress-sharing provider — use to compose `Carousel.Pagination`. */
|
|
15
|
+
children?: ReactNode;
|
|
16
|
+
};
|
|
17
|
+
declare const CarouselRoot: <T>(props: CarouselProps<T> & {
|
|
18
|
+
ref?: Ref<ICarouselInstance>;
|
|
19
|
+
}) => ReactElement | null;
|
|
20
|
+
export interface CarouselPaginationItemAccessibilityOverrides {
|
|
21
|
+
accessibilityLabel?: string;
|
|
22
|
+
accessibilityHint?: string;
|
|
23
|
+
accessibilityRole?: AccessibilityRole;
|
|
24
|
+
accessibilityState?: AccessibilityState;
|
|
25
|
+
}
|
|
26
|
+
export interface CarouselPaginationProps<T = unknown> {
|
|
27
|
+
/** Carousel items — must be the same array (or same length) passed to `Carousel`'s `data`. */
|
|
28
|
+
data: T[];
|
|
29
|
+
/** Lay dots out vertically instead of horizontally. @default true (horizontal) */
|
|
30
|
+
horizontal?: boolean;
|
|
31
|
+
/** Custom content per dot; defaults to the library's built-in dot rendering. */
|
|
32
|
+
renderItem?: (item: T, index: number) => ReactNode;
|
|
33
|
+
/** Dot size in pixels (both width and height). */
|
|
34
|
+
size?: number;
|
|
35
|
+
/** Included in the default accessibility label, e.g. `"Slide 1 of 4 - {carouselName}"`. */
|
|
36
|
+
carouselName?: string;
|
|
37
|
+
/** Per-dot accessibility overrides. Defaults to `"Slide N of M"` / `"Go to Slide N of M"`. */
|
|
38
|
+
paginationItemAccessibility?: (index: number, length: number) => CarouselPaginationItemAccessibilityOverrides;
|
|
39
|
+
className?: string;
|
|
40
|
+
/** Explicit progress value — only required when rendered outside `<Carousel>` (sibling composition). */
|
|
41
|
+
progress?: SharedValue<number>;
|
|
42
|
+
/** Explicit carousel ref for the default press-to-navigate behavior — only required outside `<Carousel>`. */
|
|
43
|
+
carouselRef?: RefObject<ICarouselInstance | null>;
|
|
44
|
+
/**
|
|
45
|
+
* Mirrors `Carousel`'s `loop` prop for shortest-path dot navigation.
|
|
46
|
+
* Defaults to `true` (same as `Carousel`) when omitted outside context.
|
|
47
|
+
*/
|
|
48
|
+
loop?: boolean;
|
|
49
|
+
/** Overrides the default press-to-navigate behavior (`scrollTo({ index })`). */
|
|
50
|
+
onPress?: (index: number) => void;
|
|
51
|
+
}
|
|
52
|
+
declare const CarouselPagination: <T>(props: CarouselPaginationProps<T>) => ReactElement | null;
|
|
53
|
+
type CarouselCompoundComponent = typeof CarouselRoot & {
|
|
54
|
+
Pagination: typeof CarouselPagination;
|
|
55
|
+
};
|
|
56
|
+
export declare const Carousel: CarouselCompoundComponent;
|
|
57
|
+
export interface UseCarouselOptions {
|
|
58
|
+
/** Seed `progress` to match `Carousel`'s `defaultIndex` in sibling composition. @default 0 */
|
|
59
|
+
defaultIndex?: number;
|
|
60
|
+
}
|
|
61
|
+
export declare function useCarousel(options?: UseCarouselOptions): {
|
|
62
|
+
ref: RefObject<ICarouselInstance | null>;
|
|
63
|
+
/** Bind to `Carousel`'s `onProgressChange` and sibling `Carousel.Pagination`'s `progress`. */
|
|
64
|
+
progress: SharedValue<number>;
|
|
65
|
+
next: (opts?: Parameters<ICarouselInstance["next"]>[0]) => void | undefined;
|
|
66
|
+
prev: (opts?: Parameters<ICarouselInstance["prev"]>[0]) => void | undefined;
|
|
67
|
+
scrollTo: (opts?: Parameters<ICarouselInstance["scrollTo"]>[0]) => void | undefined;
|
|
68
|
+
};
|
|
69
|
+
export {};
|
|
70
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/Carousel/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,GAAG,EACR,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAa,MAAM,cAAc,CAAC;AAErF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAmB,EAEjB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACpB,MAAM,kCAAkC,CAAC;AAM1C,MAAM,MAAM,WAAW,GAAG,iBAAiB,CAAC;AAE5C;;;;;GAKG;AACH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AAC,EAAE,OAAO,CAAC;IACf,gFAAgF;IAChF,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAgFD,QAAA,MAAM,kBAAkB,EAAkC,CAAC,CAAC,EAC1D,KAAK,EAAE,uBAAuB,CAAC,CAAC,CAAC,KAC9B,YAAY,GAAG,IAAI,CAAC;AAEzB,KAAK,yBAAyB,GAAG,OAAO,YAAY,GAAG;IACrD,UAAU,EAAE,OAAO,kBAAkB,CAAC;CACvC,CAAC;AAEF,eAAO,MAAM,QAAQ,EAEf,yBAAyB,CAAC;AAMhC,MAAM,WAAW,kBAAkB;IACjC,8FAA8F;IAC9F,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,kBAAkB;;IAKpD,8FAA8F;;kBAEhF,UAAU,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;kBACxC,UAAU,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;sBACpC,UAAU,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;EAEjE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ICarouselInstance } from 'react-native-reanimated-carousel';
|
|
2
|
+
type CarouselPaginationScrollAction = NonNullable<Parameters<ICarouselInstance['scrollTo']>[0]>;
|
|
3
|
+
/**
|
|
4
|
+
* Resolves the shortest `scrollTo` action for pagination dot presses.
|
|
5
|
+
*
|
|
6
|
+
* In loop mode the library's absolute `scrollTo({ index })` can animate through every
|
|
7
|
+
* slide when the current index is past the halfway point of the loop buffer (e.g. index 2 → 3
|
|
8
|
+
* with four items). Relative `count` navigation avoids that wrap-around path.
|
|
9
|
+
*/
|
|
10
|
+
export declare function resolveCarouselPaginationScrollAction(currentIndex: number, targetIndex: number, dataLength: number, loop: boolean): CarouselPaginationScrollAction | null;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=paginationNavigation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paginationNavigation.d.ts","sourceRoot":"","sources":["../../../../src/components/Carousel/paginationNavigation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAE1E,KAAK,8BAA8B,GAAG,WAAW,CAAC,UAAU,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAEhG;;;;;;GAMG;AACH,wBAAgB,qCAAqC,CACnD,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,OAAO,GACZ,8BAA8B,GAAG,IAAI,CAevC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type VariantProps } from 'class-variance-authority';
|
|
2
|
+
/** Small default gap between dots — the library ships no default spacing between pagination items. */
|
|
3
|
+
export declare const carouselPaginationContainerClassName = "gap-2 py-1";
|
|
4
|
+
export declare const carouselPaginationDotVariants: (props?: ({
|
|
5
|
+
active?: boolean | null | undefined;
|
|
6
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
|
+
export type CarouselPaginationDotVariants = VariantProps<typeof carouselPaginationDotVariants>;
|
|
8
|
+
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../src/components/Carousel/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAElE,sGAAsG;AACtG,eAAO,MAAM,oCAAoC,eAAe,CAAC;AAEjE,eAAO,MAAM,6BAA6B;;8EAUxC,CAAC;AAEH,MAAM,MAAM,6BAA6B,GAAG,YAAY,CAAC,OAAO,6BAA6B,CAAC,CAAC"}
|
|
@@ -4,6 +4,7 @@ import { type ILinkProps } from '@cdx-ui/primitives';
|
|
|
4
4
|
import { type IconProps } from '../Icon';
|
|
5
5
|
export { LinkProvider, type LinkConfig, type LinkAction } from '@cdx-ui/primitives';
|
|
6
6
|
export interface LinkProps extends ILinkProps {
|
|
7
|
+
asChild?: boolean;
|
|
7
8
|
className?: string;
|
|
8
9
|
children?: ReactNode;
|
|
9
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/Link/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EAAY,IAAI,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAML,KAAK,UAAU,EAChB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAQ,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AAQ/C,OAAO,EAAE,YAAY,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAMpF,MAAM,WAAW,SAAU,SAAQ,UAAU;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,QAAA,MAAM,QAAQ,4FAcZ,CAAC;AAQH,MAAM,WAAW,cAAe,SAAQ,SAAS;IAC/C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,QAAA,MAAM,SAAS,iGAwBd,CAAC;AAQF,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC;CAAG;AAErE,QAAA,MAAM,QAAQ;yCAAwC,aAAa;;CAalE,CAAC;AAQF,KAAK,qBAAqB,GAAG,OAAO,QAAQ,GAAG;IAC7C,KAAK,EAAE,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,uBAAuB,CAAC;AACtC,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACzC,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,uBAAuB,CAAC;AACtC,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACzC,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cdx-ui/components",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.112",
|
|
4
4
|
"main": "lib/commonjs/index.js",
|
|
5
5
|
"module": "lib/module/index.js",
|
|
6
6
|
"react-native": "src/index.ts",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@shopify/flash-list": ">=2.0.0",
|
|
46
46
|
"react": "^18.2.0 || ^19.0.0",
|
|
47
47
|
"react-native": ">=0.76.0",
|
|
48
|
-
"react-native-reanimated": ">=
|
|
48
|
+
"react-native-reanimated": ">=4.0.0",
|
|
49
49
|
"react-native-safe-area-context": ">=4.0.0",
|
|
50
50
|
"react-native-web": ">=0.19.0"
|
|
51
51
|
},
|
|
@@ -66,10 +66,11 @@
|
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"@gorhom/bottom-sheet": "^5.2.6",
|
|
68
68
|
"class-variance-authority": "^0.7.1",
|
|
69
|
+
"react-native-reanimated-carousel": "5.0.0-beta.5",
|
|
69
70
|
"uniwind": "1.10.0",
|
|
70
|
-
"@cdx-ui/
|
|
71
|
-
"@cdx-ui/
|
|
72
|
-
"@cdx-ui/
|
|
71
|
+
"@cdx-ui/utils": "0.0.1-beta.112",
|
|
72
|
+
"@cdx-ui/icons": "0.0.1-beta.112",
|
|
73
|
+
"@cdx-ui/primitives": "0.0.1-beta.112"
|
|
73
74
|
},
|
|
74
75
|
"devDependencies": {
|
|
75
76
|
"@react-navigation/bottom-tabs": "*",
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import { type ForwardedRef, forwardRef } from 'react';
|
|
2
2
|
import { View, type ViewProps } from 'react-native';
|
|
3
|
-
import { WrapStringChild } from '../../utils/WrapStringChild';
|
|
4
|
-
import type { TextProps } from '../Text';
|
|
5
3
|
|
|
6
4
|
export interface BoxProps extends ViewProps {
|
|
7
5
|
className?: string;
|
|
8
|
-
textProps?: TextProps;
|
|
9
6
|
}
|
|
10
7
|
|
|
11
|
-
/** @deprecated Use View instead */
|
|
12
8
|
export const Box = forwardRef<View, BoxProps>(
|
|
13
|
-
({
|
|
9
|
+
({ children, ...restProps }, ref: ForwardedRef<View>) => {
|
|
14
10
|
return (
|
|
15
|
-
<View ref={ref}
|
|
16
|
-
|
|
11
|
+
<View ref={ref} {...restProps}>
|
|
12
|
+
{children}
|
|
17
13
|
</View>
|
|
18
14
|
);
|
|
19
15
|
},
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import {
|
|
2
|
+
forwardRef,
|
|
3
|
+
useCallback,
|
|
4
|
+
useRef,
|
|
5
|
+
type ReactElement,
|
|
6
|
+
type ReactNode,
|
|
7
|
+
type Ref,
|
|
8
|
+
type RefObject,
|
|
9
|
+
} from 'react';
|
|
10
|
+
import type { AccessibilityRole, AccessibilityState, ViewStyle } from 'react-native';
|
|
11
|
+
import { useSharedValue } from 'react-native-reanimated';
|
|
12
|
+
import type { SharedValue } from 'react-native-reanimated';
|
|
13
|
+
import RNCarousel, {
|
|
14
|
+
Pagination as RNCarouselPagination,
|
|
15
|
+
type ICarouselInstance,
|
|
16
|
+
type TCarouselProps,
|
|
17
|
+
} from 'react-native-reanimated-carousel';
|
|
18
|
+
import { useResolveClassNames } from 'uniwind';
|
|
19
|
+
import { cn, createContext, mergeRefs } from '@cdx-ui/utils';
|
|
20
|
+
import { resolveCarouselPaginationScrollAction } from './paginationNavigation';
|
|
21
|
+
import { carouselPaginationContainerClassName, carouselPaginationDotVariants } from './styles';
|
|
22
|
+
|
|
23
|
+
export type CarouselRef = ICarouselInstance;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Full passthrough of `react-native-reanimated-carousel`'s own props (per `01-api-design.md`,
|
|
27
|
+
* Resolved Question #1) — re-exported under a Forge-owned name so consumers never import the
|
|
28
|
+
* adopted library directly. A type alias (not `interface extends`) because `TCarouselProps<T>`
|
|
29
|
+
* is itself a union-containing type (vertical/mode discriminants), which interfaces cannot extend.
|
|
30
|
+
*/
|
|
31
|
+
export type CarouselProps<T> = TCarouselProps<T> & {
|
|
32
|
+
className?: string;
|
|
33
|
+
/** Rendered inside the carousel's progress-sharing provider — use to compose `Carousel.Pagination`. */
|
|
34
|
+
children?: ReactNode;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/** Mirrors the adopted library's private `DotStyle` shape (not exported) without importing it. */
|
|
38
|
+
type CarouselDotStyle = Omit<ViewStyle, 'width' | 'height' | 'backgroundColor' | 'borderRadius'> & {
|
|
39
|
+
width?: number;
|
|
40
|
+
height?: number;
|
|
41
|
+
backgroundColor?: string;
|
|
42
|
+
borderRadius?: number;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
interface CarouselContextValue {
|
|
46
|
+
progress: SharedValue<number>;
|
|
47
|
+
carouselRef: RefObject<ICarouselInstance | null>;
|
|
48
|
+
loop: boolean;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const [CarouselProgressProvider, useCarouselProgressContext] = createContext<CarouselContextValue>(
|
|
52
|
+
'CarouselProgress',
|
|
53
|
+
{ strict: false },
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
function isSharedValueProgress(value: unknown): value is SharedValue<number> {
|
|
57
|
+
return typeof value === 'object' && value !== null && 'value' in value;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function CarouselInner<T>(
|
|
61
|
+
{
|
|
62
|
+
className,
|
|
63
|
+
style,
|
|
64
|
+
onProgressChange,
|
|
65
|
+
children,
|
|
66
|
+
loop = true,
|
|
67
|
+
defaultIndex = 0,
|
|
68
|
+
...rest
|
|
69
|
+
}: CarouselProps<T>,
|
|
70
|
+
ref: Ref<ICarouselInstance>,
|
|
71
|
+
) {
|
|
72
|
+
const internalRef = useRef<ICarouselInstance>(null);
|
|
73
|
+
const internalProgress = useSharedValue(defaultIndex);
|
|
74
|
+
const resolvedClassNameStyle = useResolveClassNames(cn(className));
|
|
75
|
+
|
|
76
|
+
const handleProgressChange = useCallback(
|
|
77
|
+
(offsetProgress: number, absoluteProgress: number) => {
|
|
78
|
+
internalProgress.value = absoluteProgress;
|
|
79
|
+
if (typeof onProgressChange === 'function') {
|
|
80
|
+
onProgressChange(offsetProgress, absoluteProgress);
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
[onProgressChange, internalProgress],
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
const consumerProgress = isSharedValueProgress(onProgressChange) ? onProgressChange : undefined;
|
|
87
|
+
const contextValue: CarouselContextValue = {
|
|
88
|
+
progress: consumerProgress ?? internalProgress,
|
|
89
|
+
carouselRef: internalRef,
|
|
90
|
+
loop,
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<CarouselProgressProvider value={contextValue}>
|
|
95
|
+
<RNCarousel
|
|
96
|
+
ref={mergeRefs(ref, internalRef)}
|
|
97
|
+
style={[resolvedClassNameStyle, style]}
|
|
98
|
+
onProgressChange={consumerProgress ?? handleProgressChange}
|
|
99
|
+
loop={loop}
|
|
100
|
+
defaultIndex={defaultIndex}
|
|
101
|
+
{...rest}
|
|
102
|
+
/>
|
|
103
|
+
{children}
|
|
104
|
+
</CarouselProgressProvider>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const CarouselRoot = forwardRef(CarouselInner) as <T>(
|
|
109
|
+
props: CarouselProps<T> & { ref?: Ref<ICarouselInstance> },
|
|
110
|
+
) => ReactElement | null;
|
|
111
|
+
|
|
112
|
+
// =============================================================================
|
|
113
|
+
// PAGINATION
|
|
114
|
+
// =============================================================================
|
|
115
|
+
|
|
116
|
+
export interface CarouselPaginationItemAccessibilityOverrides {
|
|
117
|
+
accessibilityLabel?: string;
|
|
118
|
+
accessibilityHint?: string;
|
|
119
|
+
accessibilityRole?: AccessibilityRole;
|
|
120
|
+
accessibilityState?: AccessibilityState;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export interface CarouselPaginationProps<T = unknown> {
|
|
124
|
+
/** Carousel items — must be the same array (or same length) passed to `Carousel`'s `data`. */
|
|
125
|
+
data: T[];
|
|
126
|
+
/** Lay dots out vertically instead of horizontally. @default true (horizontal) */
|
|
127
|
+
horizontal?: boolean;
|
|
128
|
+
/** Custom content per dot; defaults to the library's built-in dot rendering. */
|
|
129
|
+
renderItem?: (item: T, index: number) => ReactNode;
|
|
130
|
+
/** Dot size in pixels (both width and height). */
|
|
131
|
+
size?: number;
|
|
132
|
+
/** Included in the default accessibility label, e.g. `"Slide 1 of 4 - {carouselName}"`. */
|
|
133
|
+
carouselName?: string;
|
|
134
|
+
/** Per-dot accessibility overrides. Defaults to `"Slide N of M"` / `"Go to Slide N of M"`. */
|
|
135
|
+
paginationItemAccessibility?: (
|
|
136
|
+
index: number,
|
|
137
|
+
length: number,
|
|
138
|
+
) => CarouselPaginationItemAccessibilityOverrides;
|
|
139
|
+
className?: string;
|
|
140
|
+
/** Explicit progress value — only required when rendered outside `<Carousel>` (sibling composition). */
|
|
141
|
+
progress?: SharedValue<number>;
|
|
142
|
+
/** Explicit carousel ref for the default press-to-navigate behavior — only required outside `<Carousel>`. */
|
|
143
|
+
carouselRef?: RefObject<ICarouselInstance | null>;
|
|
144
|
+
/**
|
|
145
|
+
* Mirrors `Carousel`'s `loop` prop for shortest-path dot navigation.
|
|
146
|
+
* Defaults to `true` (same as `Carousel`) when omitted outside context.
|
|
147
|
+
*/
|
|
148
|
+
loop?: boolean;
|
|
149
|
+
/** Overrides the default press-to-navigate behavior (`scrollTo({ index })`). */
|
|
150
|
+
onPress?: (index: number) => void;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function CarouselPaginationComponent<T extends object>({
|
|
154
|
+
className,
|
|
155
|
+
progress: progressProp,
|
|
156
|
+
carouselRef: carouselRefProp,
|
|
157
|
+
loop: loopProp,
|
|
158
|
+
onPress,
|
|
159
|
+
...rest
|
|
160
|
+
}: CarouselPaginationProps<T>) {
|
|
161
|
+
// `strict: false` with no `defaultValue` means this returns `undefined` outside a
|
|
162
|
+
// `<Carousel>` provider at runtime; cast to communicate that to TypeScript, since
|
|
163
|
+
// `createContext`'s helper type always reports `T` (see `@cdx-ui/utils`).
|
|
164
|
+
const context = useCarouselProgressContext() as CarouselContextValue | undefined;
|
|
165
|
+
const progress = progressProp ?? context?.progress;
|
|
166
|
+
const carouselRef = carouselRefProp ?? context?.carouselRef;
|
|
167
|
+
const loop = loopProp ?? context?.loop ?? true;
|
|
168
|
+
|
|
169
|
+
if (!progress) {
|
|
170
|
+
throw new Error(
|
|
171
|
+
'Carousel.Pagination must be rendered inside <Carousel> or receive an explicit `progress` prop.',
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (!onPress && !carouselRef) {
|
|
176
|
+
throw new Error(
|
|
177
|
+
'Carousel.Pagination must be rendered inside <Carousel> or receive an explicit `carouselRef` prop (or a custom `onPress`).',
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const handlePress = useCallback(
|
|
182
|
+
(index: number) => {
|
|
183
|
+
if (onPress) {
|
|
184
|
+
onPress(index);
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const carousel = carouselRef?.current;
|
|
189
|
+
if (!carousel) return;
|
|
190
|
+
|
|
191
|
+
const scrollAction = resolveCarouselPaginationScrollAction(
|
|
192
|
+
carousel.getCurrentIndex(),
|
|
193
|
+
index,
|
|
194
|
+
rest.data.length,
|
|
195
|
+
loop,
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
if (scrollAction) {
|
|
199
|
+
carousel.scrollTo(scrollAction);
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
[onPress, carouselRef, loop, rest.data.length],
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
const containerStyle = useResolveClassNames(cn(carouselPaginationContainerClassName, className));
|
|
206
|
+
const dotStyle = useResolveClassNames(carouselPaginationDotVariants({ active: false }));
|
|
207
|
+
const activeDotStyle = useResolveClassNames(carouselPaginationDotVariants({ active: true }));
|
|
208
|
+
|
|
209
|
+
return (
|
|
210
|
+
<RNCarouselPagination.Custom
|
|
211
|
+
{...rest}
|
|
212
|
+
progress={progress}
|
|
213
|
+
onPress={handlePress}
|
|
214
|
+
containerStyle={containerStyle}
|
|
215
|
+
dotStyle={{
|
|
216
|
+
width: 6,
|
|
217
|
+
height: 6,
|
|
218
|
+
...(dotStyle as CarouselDotStyle),
|
|
219
|
+
}}
|
|
220
|
+
activeDotStyle={{
|
|
221
|
+
width: 18,
|
|
222
|
+
height: 6,
|
|
223
|
+
...(activeDotStyle as CarouselDotStyle),
|
|
224
|
+
}}
|
|
225
|
+
/>
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
CarouselPaginationComponent.displayName = 'Carousel.Pagination';
|
|
230
|
+
|
|
231
|
+
const CarouselPagination = CarouselPaginationComponent as <T>(
|
|
232
|
+
props: CarouselPaginationProps<T>,
|
|
233
|
+
) => ReactElement | null;
|
|
234
|
+
|
|
235
|
+
type CarouselCompoundComponent = typeof CarouselRoot & {
|
|
236
|
+
Pagination: typeof CarouselPagination;
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
export const Carousel = Object.assign(CarouselRoot, {
|
|
240
|
+
Pagination: CarouselPagination,
|
|
241
|
+
}) as CarouselCompoundComponent;
|
|
242
|
+
|
|
243
|
+
// =============================================================================
|
|
244
|
+
// HOOK
|
|
245
|
+
// =============================================================================
|
|
246
|
+
|
|
247
|
+
export interface UseCarouselOptions {
|
|
248
|
+
/** Seed `progress` to match `Carousel`'s `defaultIndex` in sibling composition. @default 0 */
|
|
249
|
+
defaultIndex?: number;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export function useCarousel(options?: UseCarouselOptions) {
|
|
253
|
+
const ref = useRef<ICarouselInstance>(null);
|
|
254
|
+
const progress = useSharedValue(options?.defaultIndex ?? 0);
|
|
255
|
+
return {
|
|
256
|
+
ref,
|
|
257
|
+
/** Bind to `Carousel`'s `onProgressChange` and sibling `Carousel.Pagination`'s `progress`. */
|
|
258
|
+
progress,
|
|
259
|
+
next: (opts?: Parameters<ICarouselInstance['next']>[0]) => ref.current?.next(opts),
|
|
260
|
+
prev: (opts?: Parameters<ICarouselInstance['prev']>[0]) => ref.current?.prev(opts),
|
|
261
|
+
scrollTo: (opts?: Parameters<ICarouselInstance['scrollTo']>[0]) => ref.current?.scrollTo(opts),
|
|
262
|
+
};
|
|
263
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ICarouselInstance } from 'react-native-reanimated-carousel';
|
|
2
|
+
|
|
3
|
+
type CarouselPaginationScrollAction = NonNullable<Parameters<ICarouselInstance['scrollTo']>[0]>;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Resolves the shortest `scrollTo` action for pagination dot presses.
|
|
7
|
+
*
|
|
8
|
+
* In loop mode the library's absolute `scrollTo({ index })` can animate through every
|
|
9
|
+
* slide when the current index is past the halfway point of the loop buffer (e.g. index 2 → 3
|
|
10
|
+
* with four items). Relative `count` navigation avoids that wrap-around path.
|
|
11
|
+
*/
|
|
12
|
+
export function resolveCarouselPaginationScrollAction(
|
|
13
|
+
currentIndex: number,
|
|
14
|
+
targetIndex: number,
|
|
15
|
+
dataLength: number,
|
|
16
|
+
loop: boolean,
|
|
17
|
+
): CarouselPaginationScrollAction | null {
|
|
18
|
+
if (currentIndex === targetIndex) return null;
|
|
19
|
+
|
|
20
|
+
if (!loop) {
|
|
21
|
+
return { index: targetIndex, animated: true };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const forwardDelta = (targetIndex - currentIndex + dataLength) % dataLength;
|
|
25
|
+
const backwardDelta = (currentIndex - targetIndex + dataLength) % dataLength;
|
|
26
|
+
|
|
27
|
+
if (forwardDelta <= backwardDelta) {
|
|
28
|
+
return { count: forwardDelta, animated: true };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return { count: -backwardDelta, animated: true };
|
|
32
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
2
|
+
|
|
3
|
+
/** Small default gap between dots — the library ships no default spacing between pagination items. */
|
|
4
|
+
export const carouselPaginationContainerClassName = 'gap-2 py-1';
|
|
5
|
+
|
|
6
|
+
export const carouselPaginationDotVariants = cva('rounded-full', {
|
|
7
|
+
variants: {
|
|
8
|
+
active: {
|
|
9
|
+
true: 'bg-surface-neutral-strong',
|
|
10
|
+
false: 'bg-surface-neutral-subtle',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
defaultVariants: {
|
|
14
|
+
active: false,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export type CarouselPaginationDotVariants = VariantProps<typeof carouselPaginationDotVariants>;
|
|
@@ -24,6 +24,7 @@ export { LinkProvider, type LinkConfig, type LinkAction } from '@cdx-ui/primitiv
|
|
|
24
24
|
// =============================================================================
|
|
25
25
|
|
|
26
26
|
export interface LinkProps extends ILinkProps {
|
|
27
|
+
asChild?: boolean;
|
|
27
28
|
className?: string;
|
|
28
29
|
children?: ReactNode;
|
|
29
30
|
}
|
package/src/components/index.ts
CHANGED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.WrapStringChild = WrapStringChild;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
var _Text = require("../components/Text");
|
|
9
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
|
-
/** @deprecated Users should wrap their own children in a Text component themselves */
|
|
11
|
-
function WrapStringChild({
|
|
12
|
-
children,
|
|
13
|
-
textProps
|
|
14
|
-
}) {
|
|
15
|
-
return _react.Children.map(children, child => {
|
|
16
|
-
return typeof child === 'string' || typeof child === 'number' || /*#__PURE__*/(0, _react.isValidElement)(child) && child.type === _react.Fragment && child.props && typeof child.props === 'object' && 'children' in child.props && (typeof child.props.children === 'string' || typeof child.props.children === 'number') ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.Text, {
|
|
17
|
-
...textProps,
|
|
18
|
-
children: child
|
|
19
|
-
}) : child;
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=WrapStringChild.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_Text","_jsxRuntime","WrapStringChild","children","textProps","Children","map","child","isValidElement","type","Fragment","props","jsx","Text"],"sourceRoot":"../../../src","sources":["utils/WrapStringChild.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAA0D,IAAAE,WAAA,GAAAF,OAAA;AAO1D;AACO,SAASG,eAAeA,CAAC;EAAEC,QAAQ;EAAEC;AAAgC,CAAC,EAAa;EACxF,OAAOC,eAAQ,CAACC,GAAG,CAACH,QAAQ,EAAGI,KAAK,IAAK;IACvC,OAAO,OAAOA,KAAK,KAAK,QAAQ,IAC9B,OAAOA,KAAK,KAAK,QAAQ,IACxB,iBAAAC,qBAAc,EAACD,KAAK,CAAC,IACpBA,KAAK,CAACE,IAAI,KAAKC,eAAQ,IACvBH,KAAK,CAACI,KAAK,IACX,OAAOJ,KAAK,CAACI,KAAK,KAAK,QAAQ,IAC/B,UAAU,IAAIJ,KAAK,CAACI,KAAK,KACxB,OAAOJ,KAAK,CAACI,KAAK,CAACR,QAAQ,KAAK,QAAQ,IAAI,OAAOI,KAAK,CAACI,KAAK,CAACR,QAAQ,KAAK,QAAQ,CAAE,gBACzF,IAAAF,WAAA,CAAAW,GAAA,EAACZ,KAAA,CAAAa,IAAI;MAAA,GAAKT,SAAS;MAAAD,QAAA,EAAGI;IAAK,CAAO,CAAC,GAEnCA,KACD;EACH,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { Children, Fragment, isValidElement } from 'react';
|
|
4
|
-
import { Text } from '../components/Text';
|
|
5
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
-
/** @deprecated Users should wrap their own children in a Text component themselves */
|
|
7
|
-
export function WrapStringChild({
|
|
8
|
-
children,
|
|
9
|
-
textProps
|
|
10
|
-
}) {
|
|
11
|
-
return Children.map(children, child => {
|
|
12
|
-
return typeof child === 'string' || typeof child === 'number' || /*#__PURE__*/isValidElement(child) && child.type === Fragment && child.props && typeof child.props === 'object' && 'children' in child.props && (typeof child.props.children === 'string' || typeof child.props.children === 'number') ? /*#__PURE__*/_jsx(Text, {
|
|
13
|
-
...textProps,
|
|
14
|
-
children: child
|
|
15
|
-
}) : child;
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=WrapStringChild.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["Children","Fragment","isValidElement","Text","jsx","_jsx","WrapStringChild","children","textProps","map","child","type","props"],"sourceRoot":"../../../src","sources":["utils/WrapStringChild.tsx"],"mappings":";;AAAA,SAASA,QAAQ,EAAEC,QAAQ,EAAEC,cAAc,QAAwB,OAAO;AAC1E,SAASC,IAAI,QAAwB,oBAAoB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAO1D;AACA,OAAO,SAASC,eAAeA,CAAC;EAAEC,QAAQ;EAAEC;AAAgC,CAAC,EAAa;EACxF,OAAOR,QAAQ,CAACS,GAAG,CAACF,QAAQ,EAAGG,KAAK,IAAK;IACvC,OAAO,OAAOA,KAAK,KAAK,QAAQ,IAC9B,OAAOA,KAAK,KAAK,QAAQ,IACxB,aAAAR,cAAc,CAACQ,KAAK,CAAC,IACpBA,KAAK,CAACC,IAAI,KAAKV,QAAQ,IACvBS,KAAK,CAACE,KAAK,IACX,OAAOF,KAAK,CAACE,KAAK,KAAK,QAAQ,IAC/B,UAAU,IAAIF,KAAK,CAACE,KAAK,KACxB,OAAOF,KAAK,CAACE,KAAK,CAACL,QAAQ,KAAK,QAAQ,IAAI,OAAOG,KAAK,CAACE,KAAK,CAACL,QAAQ,KAAK,QAAQ,CAAE,gBACzFF,IAAA,CAACF,IAAI;MAAA,GAAKK,SAAS;MAAAD,QAAA,EAAGG;IAAK,CAAO,CAAC,GAEnCA,KACD;EACH,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type ReactNode } from 'react';
|
|
2
|
-
import { type TextProps } from '../components/Text';
|
|
3
|
-
interface WrapStringChildProps {
|
|
4
|
-
children: ReactNode;
|
|
5
|
-
textProps?: TextProps;
|
|
6
|
-
}
|
|
7
|
-
/** @deprecated Users should wrap their own children in a Text component themselves */
|
|
8
|
-
export declare function WrapStringChild({ children, textProps }: WrapStringChildProps): ReactNode;
|
|
9
|
-
export {};
|
|
10
|
-
//# sourceMappingURL=WrapStringChild.d.ts.map
|