react-native-terra-ui 0.11.16 → 0.12.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/CHANGELOG.md +27 -0
- package/lib/module/components/accordion/Accordion.js +109 -0
- package/lib/module/components/accordion/Accordion.js.map +1 -0
- package/lib/module/components/accordion/context.js +34 -0
- package/lib/module/components/accordion/context.js.map +1 -0
- package/lib/module/components/accordion/hooks/use-accordion-core.js +46 -0
- package/lib/module/components/accordion/hooks/use-accordion-core.js.map +1 -0
- package/lib/module/components/accordion/index.js +5 -0
- package/lib/module/components/accordion/index.js.map +1 -0
- package/lib/module/components/accordion/parts/AccordionContent.js +98 -0
- package/lib/module/components/accordion/parts/AccordionContent.js.map +1 -0
- package/lib/module/components/accordion/parts/AccordionIndicator.js +60 -0
- package/lib/module/components/accordion/parts/AccordionIndicator.js.map +1 -0
- package/lib/module/components/accordion/parts/AccordionItem.js +53 -0
- package/lib/module/components/accordion/parts/AccordionItem.js.map +1 -0
- package/lib/module/components/accordion/parts/AccordionTrigger.js +85 -0
- package/lib/module/components/accordion/parts/AccordionTrigger.js.map +1 -0
- package/lib/module/components/accordion/types.js +4 -0
- package/lib/module/components/accordion/types.js.map +1 -0
- package/lib/module/components/accordion/utils.js +15 -0
- package/lib/module/components/accordion/utils.js.map +1 -0
- package/lib/module/components/badge/Badge.js +219 -64
- package/lib/module/components/badge/Badge.js.map +1 -1
- package/lib/module/components/badge/WithBadge.js +94 -0
- package/lib/module/components/badge/WithBadge.js.map +1 -0
- package/lib/module/components/badge/index.js +1 -0
- package/lib/module/components/badge/index.js.map +1 -1
- package/lib/module/components/badge/utils.js +3 -3
- package/lib/module/components/header/parts/HeaderBar.js +34 -7
- package/lib/module/components/header/parts/HeaderBar.js.map +1 -1
- package/lib/module/components/index.js +1 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/components/page-indicator/hooks/use-page-indicator-window.js +60 -0
- package/lib/module/components/page-indicator/hooks/use-page-indicator-window.js.map +1 -0
- package/lib/module/components/page-indicator/utils.js +60 -0
- package/lib/module/components/page-indicator/utils.js.map +1 -1
- package/lib/module/components/page-indicator/variants/DotIndicator/index.js +13 -2
- package/lib/module/components/page-indicator/variants/DotIndicator/index.js.map +1 -1
- package/lib/module/components/page-indicator/variants/PillIndicator/index.js +29 -7
- package/lib/module/components/page-indicator/variants/PillIndicator/index.js.map +1 -1
- package/lib/typescript/src/components/accordion/Accordion.d.ts +33 -0
- package/lib/typescript/src/components/accordion/Accordion.d.ts.map +1 -0
- package/lib/typescript/src/components/accordion/context.d.ts +25 -0
- package/lib/typescript/src/components/accordion/context.d.ts.map +1 -0
- package/lib/typescript/src/components/accordion/hooks/use-accordion-core.d.ts +11 -0
- package/lib/typescript/src/components/accordion/hooks/use-accordion-core.d.ts.map +1 -0
- package/lib/typescript/src/components/accordion/index.d.ts +8 -0
- package/lib/typescript/src/components/accordion/index.d.ts.map +1 -0
- package/lib/typescript/src/components/accordion/parts/AccordionContent.d.ts +8 -0
- package/lib/typescript/src/components/accordion/parts/AccordionContent.d.ts.map +1 -0
- package/lib/typescript/src/components/accordion/parts/AccordionIndicator.d.ts +16 -0
- package/lib/typescript/src/components/accordion/parts/AccordionIndicator.d.ts.map +1 -0
- package/lib/typescript/src/components/accordion/parts/AccordionItem.d.ts +16 -0
- package/lib/typescript/src/components/accordion/parts/AccordionItem.d.ts.map +1 -0
- package/lib/typescript/src/components/accordion/parts/AccordionTrigger.d.ts +11 -0
- package/lib/typescript/src/components/accordion/parts/AccordionTrigger.d.ts.map +1 -0
- package/lib/typescript/src/components/accordion/types.d.ts +65 -0
- package/lib/typescript/src/components/accordion/types.d.ts.map +1 -0
- package/lib/typescript/src/components/accordion/utils.d.ts +8 -0
- package/lib/typescript/src/components/accordion/utils.d.ts.map +1 -0
- package/lib/typescript/src/components/badge/Badge.d.ts +13 -9
- package/lib/typescript/src/components/badge/Badge.d.ts.map +1 -1
- package/lib/typescript/src/components/badge/WithBadge.d.ts +18 -0
- package/lib/typescript/src/components/badge/WithBadge.d.ts.map +1 -0
- package/lib/typescript/src/components/badge/index.d.ts +2 -1
- package/lib/typescript/src/components/badge/index.d.ts.map +1 -1
- package/lib/typescript/src/components/badge/types.d.ts +35 -12
- package/lib/typescript/src/components/badge/types.d.ts.map +1 -1
- package/lib/typescript/src/components/badge/utils.d.ts +3 -3
- package/lib/typescript/src/components/badge/utils.d.ts.map +1 -1
- package/lib/typescript/src/components/header/parts/HeaderBar.d.ts.map +1 -1
- package/lib/typescript/src/components/index.d.ts +1 -0
- package/lib/typescript/src/components/index.d.ts.map +1 -1
- package/lib/typescript/src/components/page-indicator/hooks/use-page-indicator-window.d.ts +34 -0
- package/lib/typescript/src/components/page-indicator/hooks/use-page-indicator-window.d.ts.map +1 -0
- package/lib/typescript/src/components/page-indicator/utils.d.ts +41 -0
- package/lib/typescript/src/components/page-indicator/utils.d.ts.map +1 -1
- package/lib/typescript/src/components/page-indicator/variants/DotIndicator/index.d.ts.map +1 -1
- package/lib/typescript/src/components/page-indicator/variants/PillIndicator/index.d.ts +1 -1
- package/lib/typescript/src/components/page-indicator/variants/PillIndicator/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/accordion/Accordion.tsx +116 -0
- package/src/components/accordion/context.ts +45 -0
- package/src/components/accordion/hooks/use-accordion-core.ts +51 -0
- package/src/components/accordion/index.ts +14 -0
- package/src/components/accordion/parts/AccordionContent.tsx +96 -0
- package/src/components/accordion/parts/AccordionIndicator.tsx +67 -0
- package/src/components/accordion/parts/AccordionItem.tsx +55 -0
- package/src/components/accordion/parts/AccordionTrigger.tsx +88 -0
- package/src/components/accordion/types.ts +71 -0
- package/src/components/accordion/utils.ts +12 -0
- package/src/components/badge/Badge.tsx +177 -59
- package/src/components/badge/WithBadge.tsx +79 -0
- package/src/components/badge/index.ts +2 -1
- package/src/components/badge/types.ts +36 -12
- package/src/components/badge/utils.ts +3 -3
- package/src/components/header/parts/HeaderBar.tsx +41 -8
- package/src/components/index.ts +1 -0
- package/src/components/page-indicator/hooks/use-page-indicator-window.ts +84 -0
- package/src/components/page-indicator/utils.ts +70 -0
- package/src/components/page-indicator/variants/DotIndicator/index.tsx +12 -1
- package/src/components/page-indicator/variants/PillIndicator/index.tsx +32 -2
- package/lib/module/components/badge/parts/BadgeIndicator.js +0 -212
- package/lib/module/components/badge/parts/BadgeIndicator.js.map +0 -1
- package/lib/typescript/src/components/badge/parts/BadgeIndicator.d.ts +0 -19
- package/lib/typescript/src/components/badge/parts/BadgeIndicator.d.ts.map +0 -1
- package/src/components/badge/parts/BadgeIndicator.tsx +0 -178
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import type { BadgeProps } from "./types.js";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* A dot, or a pill carrying a count or short label.
|
|
4
4
|
*
|
|
5
5
|
* ```tsx
|
|
6
|
-
* <
|
|
7
|
-
*
|
|
8
|
-
* </Badge>
|
|
6
|
+
* <Text>Appearing</Text>
|
|
7
|
+
* <Badge color="secondary" size="sm" label={56} />
|
|
9
8
|
* ```
|
|
10
9
|
*
|
|
11
|
-
*
|
|
12
|
-
* the
|
|
13
|
-
*
|
|
10
|
+
* Stands on its own, inline in a row beside the text it counts. To pin one to
|
|
11
|
+
* the corner of an icon or button, wrap that element in `WithBadge`, which
|
|
12
|
+
* renders this and owns only the position.
|
|
13
|
+
*
|
|
14
|
+
* `useUnistyles` is called unconditionally, which is what subscribes this
|
|
15
|
+
* component to theme changes. The background below comes from a variant, which
|
|
16
|
+
* unistyles applies straight to the native node on a theme switch; without a
|
|
17
|
+
* re-render React would go on believing the node holds the previous theme's
|
|
18
|
+
* value. `Chip` documents the same hazard on its root.
|
|
14
19
|
*/
|
|
15
|
-
declare const Badge:
|
|
16
|
-
export { Badge };
|
|
20
|
+
export declare const Badge: ({ label, color, size, ring, accessibilityLabel, style, ...rest }: BadgeProps) => import("react").JSX.Element;
|
|
17
21
|
//# sourceMappingURL=Badge.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Badge.d.ts","sourceRoot":"","sources":["../../../../../src/components/badge/Badge.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Badge.d.ts","sourceRoot":"","sources":["../../../../../src/components/badge/Badge.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,YAAS,CAAC;AAsBrD;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,KAAK,GAAI,kEAQnB,UAAU,gCA4CZ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { WithBadgeProps } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Pins a `Badge` to one corner of the element it wraps.
|
|
4
|
+
*
|
|
5
|
+
* ```tsx
|
|
6
|
+
* <WithBadge placement="top-right" color="danger" label={3}>
|
|
7
|
+
* <Toolbar.Button icon="bell" accessibilityLabel="Notifications" />
|
|
8
|
+
* </WithBadge>
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* The child renders untouched — `WithBadge` contributes the positioning context
|
|
12
|
+
* and the overlay, nothing else. A round child usually wants a negative
|
|
13
|
+
* `offset`, since the corner being anchored to is the bounding box's, not the
|
|
14
|
+
* circle's. For a badge that sits inline beside text, use `Badge` on its own.
|
|
15
|
+
*/
|
|
16
|
+
declare const WithBadge: import("react").ForwardRefExoticComponent<WithBadgeProps & import("react").RefAttributes<import("react-native/types_generated/src/private/webapis/dom/nodes/ReactNativeElement").default>>;
|
|
17
|
+
export { WithBadge };
|
|
18
|
+
//# sourceMappingURL=WithBadge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WithBadge.d.ts","sourceRoot":"","sources":["../../../../../src/components/badge/WithBadge.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAS,CAAC;AAG9C;;;;;;;;;;;;;GAaG;AACH,QAAA,MAAM,SAAS,4LA6Bb,CAAC;AAEH,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { Badge } from "./Badge.js";
|
|
2
|
-
export type { BadgeColor, BadgePlacement, BadgeProps, BadgeSize } from "./types.js";
|
|
2
|
+
export type { BadgeColor, BadgePlacement, BadgeProps, BadgeSize, WithBadgeProps } from "./types.js";
|
|
3
|
+
export { WithBadge } from "./WithBadge.js";
|
|
3
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/badge/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAS,CAAC;AAChC,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/badge/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAS,CAAC;AAChC,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,YAAS,CAAC;AACjG,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAa,CAAC"}
|
|
@@ -1,49 +1,72 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import type { ViewProps } from "react-native";
|
|
3
|
-
/** Corner of the wrapped child
|
|
3
|
+
/** Corner of the wrapped child a `WithBadge` anchors its badge to. */
|
|
4
4
|
export type BadgePlacement = "top-right" | "top-left" | "bottom-right" | "bottom-left";
|
|
5
5
|
/** Scale of the dot, pill, and label. */
|
|
6
6
|
export type BadgeSize = "sm" | "md" | "lg";
|
|
7
7
|
/**
|
|
8
8
|
* Semantic color scheme, or a raw CSS color literal (`#fff`, `rgb(...)`, `hsl(...)`).
|
|
9
|
-
* A literal paints the
|
|
9
|
+
* A literal paints the badge with that exact value and derives a readable
|
|
10
10
|
* foreground for the label.
|
|
11
11
|
*/
|
|
12
12
|
export type BadgeColor = "primary" | "secondary" | "success" | "warning" | "danger" | (string & {});
|
|
13
|
-
export interface BadgeProps extends ViewProps {
|
|
14
|
-
/**
|
|
13
|
+
export interface BadgeProps extends Omit<ViewProps, "children"> {
|
|
14
|
+
/**
|
|
15
|
+
* Text in the badge. Omit it (or pass an empty string) for a dot.
|
|
16
|
+
* `0` renders as a label; a caller hiding a zero count leaves the badge out.
|
|
17
|
+
*/
|
|
18
|
+
label?: string | number;
|
|
19
|
+
/** Semantic scheme or raw color literal. Defaults to `'danger'`. */
|
|
20
|
+
color?: BadgeColor;
|
|
21
|
+
/** Scale of the badge. Defaults to `'md'`. */
|
|
22
|
+
size?: BadgeSize;
|
|
23
|
+
/**
|
|
24
|
+
* Draws a `surface.canvas` ring around the badge, so it stays legible over
|
|
25
|
+
* whatever it overlaps. `WithBadge` turns it on. A badge inline beside text
|
|
26
|
+
* overlaps nothing, so it defaults to `false`: on a card the ring would only
|
|
27
|
+
* read as an outline.
|
|
28
|
+
*/
|
|
29
|
+
ring?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Announced in place of the label. Defaults to the label's own text; an
|
|
32
|
+
* unlabelled dot is hidden from assistive technology.
|
|
33
|
+
*/
|
|
34
|
+
accessibilityLabel?: string;
|
|
35
|
+
}
|
|
36
|
+
export interface WithBadgeProps extends ViewProps {
|
|
37
|
+
/** The element being badged. Rendered untouched; `WithBadge` only adds the overlay. */
|
|
15
38
|
children: ReactNode;
|
|
16
39
|
/**
|
|
17
|
-
* Corner the
|
|
40
|
+
* Corner the badge sits on. Defaults to `'top-right'`.
|
|
18
41
|
*
|
|
19
|
-
* The
|
|
42
|
+
* The badge overhangs the child, so an ancestor that clips — a `Surface`
|
|
20
43
|
* with a radius, or a `Screen` list row — will cut it off. Pad that container
|
|
21
|
-
* by the overhang, or lift the `
|
|
44
|
+
* by the overhang, or lift the `WithBadge` outside it.
|
|
22
45
|
*/
|
|
23
46
|
placement?: BadgePlacement;
|
|
24
47
|
/**
|
|
25
|
-
* Text in the
|
|
48
|
+
* Text in the badge. Omit it (or pass an empty string) for a dot.
|
|
26
49
|
* `0` renders as a label — use `isVisible` to suppress a zero count.
|
|
27
50
|
*/
|
|
28
51
|
label?: string | number;
|
|
29
52
|
/** Semantic scheme or raw color literal. Defaults to `'danger'`. */
|
|
30
53
|
color?: BadgeColor;
|
|
31
|
-
/** Scale of the
|
|
54
|
+
/** Scale of the badge. Defaults to `'md'`. */
|
|
32
55
|
size?: BadgeSize;
|
|
33
56
|
/**
|
|
34
|
-
* Nudges the
|
|
57
|
+
* Nudges the badge along both axes from the corner `placement` picked.
|
|
35
58
|
* Positive moves it away from the child's centre, negative pulls it in.
|
|
36
59
|
* A number applies to both axes; `{ x, y }` sets them separately.
|
|
37
60
|
*
|
|
38
61
|
* The corner it anchors to is the child's **bounding box**, so a round child
|
|
39
|
-
* needs a negative offset to bring the
|
|
62
|
+
* needs a negative offset to bring the badge onto the visible edge — a
|
|
40
63
|
* circle only meets its box at 45°, about `0.21 × width` away. Defaults to `0`.
|
|
41
64
|
*/
|
|
42
65
|
offset?: number | {
|
|
43
66
|
x?: number;
|
|
44
67
|
y?: number;
|
|
45
68
|
};
|
|
46
|
-
/** Renders the
|
|
69
|
+
/** Renders the badge. The child renders either way. Defaults to `true`. */
|
|
47
70
|
isVisible?: boolean;
|
|
48
71
|
/**
|
|
49
72
|
* Stretches the wrapper along its parent's cross axis, so a child that
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/components/badge/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":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;KAAE,CAAC;IAC7C,2EAA2E;IAC3E,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B"}
|
|
@@ -3,7 +3,7 @@ export interface CustomBadgeColors {
|
|
|
3
3
|
bg: string;
|
|
4
4
|
fg: string;
|
|
5
5
|
}
|
|
6
|
-
/** The
|
|
6
|
+
/** The badge's paint for a raw literal: the literal itself, plus a readable label. */
|
|
7
7
|
export declare function getCustomBadgeColors(literal: string): CustomBadgeColors;
|
|
8
8
|
/**
|
|
9
9
|
* `true` when `label` should render as a pill. An empty string and `undefined`
|
|
@@ -12,7 +12,7 @@ export declare function getCustomBadgeColors(literal: string): CustomBadgeColors
|
|
|
12
12
|
*/
|
|
13
13
|
export declare function hasLabel(label: string | number | undefined): label is string | number;
|
|
14
14
|
/**
|
|
15
|
-
* Outer diameter of the dot per size. The
|
|
15
|
+
* Outer diameter of the dot per size. The badge's own stylesheet repeats
|
|
16
16
|
* these as literals — the unistyles Babel plugin reads that object statically,
|
|
17
17
|
* so it cannot reference this table — and `anchorOffsetsMatchDotRadius` in the
|
|
18
18
|
* test suite is what keeps the two in step.
|
|
@@ -25,7 +25,7 @@ export interface AnchorPosition {
|
|
|
25
25
|
left?: number;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
|
-
* Absolute insets for
|
|
28
|
+
* Absolute insets for a `WithBadge`'s badge, in pure arithmetic rather than one
|
|
29
29
|
* compound variant per (placement, size) cell: `offset` is an open-ended number
|
|
30
30
|
* and could never be a variant condition, and nothing here touches the theme.
|
|
31
31
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../src/components/badge/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,YAAS,CAAC;AAMzD,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../src/components/badge/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,YAAS,CAAC;AAMzD,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,sFAAsF;AACtF,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,iBAAiB,CAEvE;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,KAAK,IAAI,MAAM,GAAG,MAAM,CAErF;AAED;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAI9C,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,cAAc,EACzB,IAAI,EAAE,SAAS,EACf,MAAM,GAAE,MAAM,GAAG;IAAE,CAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,CAAC,EAAE,MAAM,CAAA;CAAM,GAC9C,cAAc,CAkBhB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HeaderBar.d.ts","sourceRoot":"","sources":["../../../../../../src/components/header/parts/HeaderBar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,SAAS,EAAY,MAAM,OAAO,CAAC;AAGtE,OAAO,Q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AAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,kBAAkB,CAAC,eAAe,CAAC,CAAC;IACnD,UAAU,CAAC,EAAE,cAAc,CAAC,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC;CAC5D;AAED,2FAA2F;AAC3F,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,OAAO,EACP,QAAQ,EACR,cAAc,EACd,KAAK,EACL,YAAY,EACZ,UAAU,EACV,aAAsB,EACtB,UAAU,EACV,SAAS,GACV,EAAE,cAAc,+BA2EhB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAU,CAAC;AACzB,cAAc,kBAAS,CAAC;AACxB,cAAc,gBAAO,CAAC;AACtB,cAAc,mBAAU,CAAC;AACzB,cAAc,iBAAQ,CAAC;AACvB,cAAc,oBAAW,CAAC;AAC1B,cAAc,wBAAe,CAAC;AAC9B,cAAc,mBAAU,CAAC;AACzB,cAAc,iBAAQ,CAAC;AACvB,cAAc,kBAAS,CAAC;AACxB,cAAc,kBAAS,CAAC;AACxB,cAAc,2BAAkB,CAAC;AACjC,cAAc,mBAAU,CAAC;AACzB,cAAc,sBAAa,CAAC;AAC5B,cAAc,mBAAU,CAAC;AACzB,cAAc,iBAAQ,CAAC;AACvB,cAAc,oBAAW,CAAC;AAC1B,cAAc,oBAAW,CAAC;AAC1B,cAAc,iBAAQ,CAAC;AACvB,cAAc,kBAAS,CAAC;AACxB,cAAc,oBAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAa,CAAC;AAC5B,cAAc,mBAAU,CAAC;AACzB,cAAc,kBAAS,CAAC;AACxB,cAAc,gBAAO,CAAC;AACtB,cAAc,mBAAU,CAAC;AACzB,cAAc,iBAAQ,CAAC;AACvB,cAAc,oBAAW,CAAC;AAC1B,cAAc,wBAAe,CAAC;AAC9B,cAAc,mBAAU,CAAC;AACzB,cAAc,iBAAQ,CAAC;AACvB,cAAc,kBAAS,CAAC;AACxB,cAAc,kBAAS,CAAC;AACxB,cAAc,2BAAkB,CAAC;AACjC,cAAc,mBAAU,CAAC;AACzB,cAAc,sBAAa,CAAC;AAC5B,cAAc,mBAAU,CAAC;AACzB,cAAc,iBAAQ,CAAC;AACvB,cAAc,oBAAW,CAAC;AAC1B,cAAc,oBAAW,CAAC;AAC1B,cAAc,iBAAQ,CAAC;AACvB,cAAc,kBAAS,CAAC;AACxB,cAAc,oBAAW,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type SharedValue } from "react-native-reanimated";
|
|
2
|
+
export interface PageIndicatorWindow {
|
|
3
|
+
/** First dot index to mount, inclusive. */
|
|
4
|
+
start: number;
|
|
5
|
+
/** Last dot index to mount, inclusive. */
|
|
6
|
+
end: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The slice of dots a variant should mount, kept in step with the active page.
|
|
10
|
+
*
|
|
11
|
+
* Both variants clip to a window of `maxVisible` slots and scroll a track
|
|
12
|
+
* behind it, so all but a handful of dots are drawn outside the viewport. This
|
|
13
|
+
* is what lets them skip building those: the range covers the visible window
|
|
14
|
+
* plus a generous overscan, and moves only when the active page leaves it.
|
|
15
|
+
*
|
|
16
|
+
* **Driven by `progress`, not by `current`.** `current` may be a shared value
|
|
17
|
+
* for scroll-linked motion, in which case React never re-renders on a page
|
|
18
|
+
* change and a range derived from props would sit still while the track slid
|
|
19
|
+
* out from under it. `progress` is the one place both spellings of `current`
|
|
20
|
+
* have already been resolved into a single number.
|
|
21
|
+
*
|
|
22
|
+
* The reaction only reaches JS when the page moves *outside* the mounted range
|
|
23
|
+
* — not on every frame, and not on every page. A one-page step normally costs
|
|
24
|
+
* no render at all, because the neighbour was already mounted; a long jump
|
|
25
|
+
* costs one render per window it crosses rather than one per page.
|
|
26
|
+
*
|
|
27
|
+
* Known limit: during a jump of many pages the track slides faster than the
|
|
28
|
+
* range is re-rendered, so dots in the middle of that flight may not be mounted
|
|
29
|
+
* as they pass. They are identical inactive dots moving too fast to read, and
|
|
30
|
+
* the alternative — mounting every page between the two — is the cost this
|
|
31
|
+
* exists to avoid.
|
|
32
|
+
*/
|
|
33
|
+
export declare function usePageIndicatorWindow(count: number, current: number | SharedValue<number> | undefined, progress: SharedValue<number>, slot: number, dotSize: number, maxVisible: number, activeMainSize?: number): PageIndicatorWindow;
|
|
34
|
+
//# sourceMappingURL=use-page-indicator-window.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-page-indicator-window.d.ts","sourceRoot":"","sources":["../../../../../../src/components/page-indicator/hooks/use-page-indicator-window.ts"],"names":[],"mappings":"AAEA,OAAO,EAAW,KAAK,WAAW,EAAuC,MAAM,yBAAyB,CAAC;AAIzG,MAAM,WAAW,mBAAmB;IAClC,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,0CAA0C;IAC1C,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,GAAG,SAAS,EACjD,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,EAC7B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,cAAc,SAAU,GACvB,mBAAmB,CAqCrB"}
|
|
@@ -27,10 +27,51 @@ export declare function pageIndicatorAxisTranslateStyle(vertical: boolean, trans
|
|
|
27
27
|
};
|
|
28
28
|
/** Clips an overflowing track to the visible viewport along the main axis. */
|
|
29
29
|
export declare function pageIndicatorViewportClipStyle(vertical: boolean, viewportMainSize: number, crossSize?: number): ViewStyle;
|
|
30
|
+
/**
|
|
31
|
+
* Holds the room of dots a variant chose not to mount.
|
|
32
|
+
*
|
|
33
|
+
* The track keeps its full width and keeps scrolling by the same amount, so
|
|
34
|
+
* skipped dots still have to occupy their slots — otherwise the mounted ones
|
|
35
|
+
* slide up the track and the window shows the wrong pages.
|
|
36
|
+
*/
|
|
37
|
+
export declare function pageIndicatorSpacerStyle(vertical: boolean, mainSize: number): ViewStyle;
|
|
30
38
|
/** Scale for a slot inside the window given the active slot. */
|
|
31
39
|
export declare function pageIndicatorWindowSlotScale(positionInWindow: number, activeSlot: number, maxVisible: number): number;
|
|
32
40
|
export declare function pageIndicatorTrackMainSize(count: number, slot: number, dotSize: number, activeMainSize?: number): number;
|
|
33
41
|
export declare function pageIndicatorViewportMainSize(count: number, slot: number, dotSize: number, maxVisible: number, activeMainSize?: number): number;
|
|
34
42
|
export declare function computePageIndicatorWindowTranslate(count: number, progress: number, slot: number, dotSize: number, maxVisible: number, activeMainSize?: number): number;
|
|
35
43
|
export declare function pageIndicatorWindowScale(index: number, displayProgress: number, count: number, slot: number, dotSize: number, maxVisible: number, activeMainSize?: number): number;
|
|
44
|
+
/**
|
|
45
|
+
* Dots kept mounted beyond each edge of the visible window.
|
|
46
|
+
*
|
|
47
|
+
* One full window's worth. The window itself is `maxVisible` slots wide, so
|
|
48
|
+
* this leaves a whole screenful of slack on either side — enough that ordinary
|
|
49
|
+
* navigation (a swipe, a few pages at a time) never outruns the mounted range
|
|
50
|
+
* between the page change and React re-rendering with a new one.
|
|
51
|
+
*/
|
|
52
|
+
export declare const PAGE_INDICATOR_WINDOW_OVERSCAN = 5;
|
|
53
|
+
/**
|
|
54
|
+
* Which dot indices are worth mounting, inclusive, for an active page of
|
|
55
|
+
* `anchor`.
|
|
56
|
+
*
|
|
57
|
+
* An indicator draws `maxVisible` slots and clips the rest, and every dot more
|
|
58
|
+
* than one page from the active one is drawn identically — same size, same
|
|
59
|
+
* scale, same opacity, same colour. Mounting one view per page therefore costs
|
|
60
|
+
* an animated style per page to render something nobody can see: at 500 pages
|
|
61
|
+
* that is 500 worklets for five visible dots, and it lands on every page
|
|
62
|
+
* change. Bounding what is mounted is what stops the indicator's cost scaling
|
|
63
|
+
* with the length of the thing it indicates.
|
|
64
|
+
*
|
|
65
|
+
* Derived from `computePageIndicatorWindowTranslate`, the same function that
|
|
66
|
+
* positions the track, so the mounted range and the visible window cannot
|
|
67
|
+
* disagree about where the window is — including at the ends, where the
|
|
68
|
+
* translate clamps and the window stops following the active page.
|
|
69
|
+
*
|
|
70
|
+
* Below the overflow threshold every dot is visible, so the range is the whole
|
|
71
|
+
* track and nothing changes.
|
|
72
|
+
*/
|
|
73
|
+
export declare function pageIndicatorMountedRange(count: number, anchor: number, slot: number, dotSize: number, maxVisible: number, activeMainSize?: number, overscan?: number): {
|
|
74
|
+
start: number;
|
|
75
|
+
end: number;
|
|
76
|
+
};
|
|
36
77
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../src/components/page-indicator/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,uDAAuD;AACvD,eAAO,MAAM,mCAAmC,MAAM,CAAC;AAEvD,0EAA0E;AAC1E,eAAO,MAAM,uCAAuC,MAAM,CAAC;AAE3D,wDAAwD;AACxD,eAAO,MAAM,sCAAsC,MAAM,CAAC;AAE1D,0EAA0E;AAC1E,eAAO,MAAM,kCAAkC,IAAI,CAAC;AAMpD,+CAA+C;AAC/C,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAE9E;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAQ9E;AAED,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,GAClC,KAAK,IAAI,WAAW,CAAC,MAAM,CAAC,CAE9B;AAED,wEAAwE;AACxE,wBAAgB,+BAA+B,CAAC,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM;;;;;;EAKnF;AAED,8EAA8E;AAC9E,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,OAAO,EACjB,gBAAgB,EAAE,MAAM,EACxB,SAAS,CAAC,EAAE,MAAM,GACjB,SAAS,CAcX;AAQD,gEAAgE;AAChE,wBAAgB,4BAA4B,CAC1C,gBAAgB,EAAE,MAAM,EACxB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACjB,MAAM,CA2BR;AAED,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,cAAc,SAAU,GACvB,MAAM,CAER;AAED,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,cAAc,SAAU,GACvB,MAAM,CAGR;AAED,wBAAgB,mCAAmC,CACjD,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,cAAc,SAAU,GACvB,MAAM,CAUR;AAED,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,MAAM,EACb,eAAe,EAAE,MAAM,EACvB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,cAAc,SAAU,GACvB,MAAM,CAiBR"}
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../src/components/page-indicator/utils.ts"],"names":[],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,EAAE,MAAM,EACf,cAAc,SAAU,GACvB,MAAM,CAER;AAED,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,cAAc,SAAU,GACvB,MAAM,CAGR;AAED,wBAAgB,mCAAmC,CACjD,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,cAAc,SAAU,GACvB,MAAM,CAUR;AAED,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,MAAM,EACb,eAAe,EAAE,MAAM,EACvB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,cAAc,SAAU,GACvB,MAAM,CAiBR;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,8BAA8B,IAAI,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,cAAc,SAAU,EACxB,QAAQ,SAAiC,GACxC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAmBhC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/page-indicator/variants/DotIndicator/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAG3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/page-indicator/variants/DotIndicator/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAG3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAiB/C,MAAM,WAAW,iBAAiB;IAChC,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IACvC,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+BAA+B;IAC/B,WAAW,CAAC,EAAE,UAAU,CAAC;IACzB,iCAAiC;IACjC,aAAa,CAAC,EAAE,UAAU,CAAC;IAC3B,gCAAgC;IAChC,YAAY,CAAC,EAAE,UAAU,CAAC;IAC1B,0DAA0D;IAC1D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,qDAAqD;IACrD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B;AAED,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,OAAW,EACX,QAA8C,EAC9C,WAAW,EACX,aAAa,EACb,YAAY,EACZ,OAAe,EACf,QAAgB,EAChB,UAA+C,EAC/C,KAAK,GACN,EAAE,iBAAiB,+BA2EnB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type StyleProp, type ViewStyle } from "react-native";
|
|
2
2
|
import type { SharedValue } from "react-native-reanimated";
|
|
3
3
|
import type { ColorToken } from "../../../../theme/types";
|
|
4
4
|
export interface PillIndicatorProps {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/page-indicator/variants/PillIndicator/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/page-indicator/variants/PillIndicator/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,SAAS,EAAQ,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAEpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAG3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAgB/C,MAAM,WAAW,kBAAkB;IACjC,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IACvC,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+BAA+B;IAC/B,WAAW,CAAC,EAAE,UAAU,CAAC;IACzB,iCAAiC;IACjC,aAAa,CAAC,EAAE,UAAU,CAAC;IAC3B,sDAAsD;IACtD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B;AAED,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,OAAW,EACX,QAA8C,EAC9C,WAAW,EACX,aAAa,EACb,QAAgB,EAChB,UAA+C,EAC/C,KAAK,GACN,EAAE,kBAAkB,+BAqGpB"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Children,
|
|
3
|
+
type ComponentRef,
|
|
4
|
+
Fragment,
|
|
5
|
+
forwardRef,
|
|
6
|
+
isValidElement,
|
|
7
|
+
type ReactNode,
|
|
8
|
+
useMemo,
|
|
9
|
+
} from "react";
|
|
10
|
+
import { View } from "react-native";
|
|
11
|
+
|
|
12
|
+
import { StyleSheet } from "react-native-unistyles";
|
|
13
|
+
|
|
14
|
+
import { Divider } from "../divider";
|
|
15
|
+
import { AccordionContext } from "./context";
|
|
16
|
+
import { useAccordionCore } from "./hooks/use-accordion-core";
|
|
17
|
+
import { AccordionContent } from "./parts/AccordionContent";
|
|
18
|
+
import { AccordionIndicator } from "./parts/AccordionIndicator";
|
|
19
|
+
import { AccordionItem } from "./parts/AccordionItem";
|
|
20
|
+
import { AccordionTrigger } from "./parts/AccordionTrigger";
|
|
21
|
+
import type { AccordionProps } from "./types";
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Puts a rule between each pair of items. The rule is a sibling rather than a
|
|
25
|
+
* border on the item, because an item cannot tell whether it is the last one.
|
|
26
|
+
* A fragment counts as one child, so items spread from a fragment share no rules.
|
|
27
|
+
*/
|
|
28
|
+
function interleaveDividers(children: ReactNode): ReactNode {
|
|
29
|
+
const items = Children.toArray(children).filter(isValidElement);
|
|
30
|
+
return items.map((child, index) => (
|
|
31
|
+
<Fragment key={child.key ?? index}>
|
|
32
|
+
{index > 0 && <Divider />}
|
|
33
|
+
{child}
|
|
34
|
+
</Fragment>
|
|
35
|
+
));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* A vertical stack of headers that each open a panel of content.
|
|
40
|
+
*
|
|
41
|
+
* `'single'` mode (the default) keeps one item open at a time; `'multiple'`
|
|
42
|
+
* lets any number be open. Uncontrolled through `defaultValue`, or controlled
|
|
43
|
+
* through `value` + `onValueChange`.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* <Accordion defaultValue="shipping">
|
|
47
|
+
* <Accordion.Item value="shipping">
|
|
48
|
+
* <Accordion.Trigger>
|
|
49
|
+
* How long does shipping take?
|
|
50
|
+
* <Accordion.Indicator />
|
|
51
|
+
* </Accordion.Trigger>
|
|
52
|
+
* <Accordion.Content>3–5 business days.</Accordion.Content>
|
|
53
|
+
* </Accordion.Item>
|
|
54
|
+
* </Accordion>
|
|
55
|
+
*/
|
|
56
|
+
const AccordionRoot = forwardRef<ComponentRef<typeof View>, AccordionProps>(function Accordion(props, ref) {
|
|
57
|
+
const {
|
|
58
|
+
selectionMode: _selectionMode,
|
|
59
|
+
value: _value,
|
|
60
|
+
defaultValue: _defaultValue,
|
|
61
|
+
onValueChange: _onValueChange,
|
|
62
|
+
isCollapsible: _isCollapsible,
|
|
63
|
+
variant = "plain",
|
|
64
|
+
divided = true,
|
|
65
|
+
isDisabled = false,
|
|
66
|
+
children,
|
|
67
|
+
style,
|
|
68
|
+
...rest
|
|
69
|
+
} = props;
|
|
70
|
+
|
|
71
|
+
const { expanded, toggle } = useAccordionCore(props);
|
|
72
|
+
const context = useMemo(() => ({ expanded, toggle, isDisabled }), [expanded, toggle, isDisabled]);
|
|
73
|
+
|
|
74
|
+
styles.useVariants({ variant });
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<AccordionContext.Provider value={context}>
|
|
78
|
+
<View ref={ref} style={[styles.root, style]} {...rest}>
|
|
79
|
+
{divided ? interleaveDividers(children) : children}
|
|
80
|
+
</View>
|
|
81
|
+
</AccordionContext.Provider>
|
|
82
|
+
);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
type AccordionComponent = typeof AccordionRoot & {
|
|
86
|
+
Item: typeof AccordionItem;
|
|
87
|
+
Trigger: typeof AccordionTrigger;
|
|
88
|
+
Indicator: typeof AccordionIndicator;
|
|
89
|
+
Content: typeof AccordionContent;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export const Accordion = AccordionRoot as AccordionComponent;
|
|
93
|
+
Accordion.Item = AccordionItem;
|
|
94
|
+
Accordion.Trigger = AccordionTrigger;
|
|
95
|
+
Accordion.Indicator = AccordionIndicator;
|
|
96
|
+
Accordion.Content = AccordionContent;
|
|
97
|
+
|
|
98
|
+
// ─── Styles ───────────────────────────────────────────────────────────────────
|
|
99
|
+
|
|
100
|
+
const styles = StyleSheet.create((theme) => ({
|
|
101
|
+
root: {
|
|
102
|
+
variants: {
|
|
103
|
+
variant: {
|
|
104
|
+
plain: {},
|
|
105
|
+
// A fixed radius rather than the registry's `surface` default: the
|
|
106
|
+
// accordion is not a `Surface`, and a configured shadow would sit oddly
|
|
107
|
+
// under a container whose height animates.
|
|
108
|
+
surface: {
|
|
109
|
+
backgroundColor: theme.color["surface.default"],
|
|
110
|
+
borderRadius: theme.radius.xl,
|
|
111
|
+
paddingHorizontal: theme.spacing["4"],
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
}));
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
|
|
3
|
+
import type { AccordionItemContextValue } from "./types";
|
|
4
|
+
|
|
5
|
+
export interface AccordionContextValue {
|
|
6
|
+
/** Open item values. Always an array, whatever the selection mode. */
|
|
7
|
+
expanded: readonly string[];
|
|
8
|
+
toggle: (value: string) => void;
|
|
9
|
+
isDisabled: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const AccordionContext = createContext<AccordionContextValue | null>(null);
|
|
13
|
+
|
|
14
|
+
export const AccordionItemContext = createContext<AccordionItemContextValue | null>(null);
|
|
15
|
+
|
|
16
|
+
export function useAccordionContext(): AccordionContextValue {
|
|
17
|
+
const context = useContext(AccordionContext);
|
|
18
|
+
if (!context) {
|
|
19
|
+
throw new Error("Accordion.Item must be rendered inside <Accordion>.");
|
|
20
|
+
}
|
|
21
|
+
return context;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Reads the enclosing `Accordion.Item`: whether it is open or disabled, and a
|
|
26
|
+
* `toggle` that follows the accordion's selection rules. Use it to build a
|
|
27
|
+
* custom trigger or indicator.
|
|
28
|
+
*
|
|
29
|
+
* @throws When called outside an `Accordion.Item`.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* function PlusMinus() {
|
|
33
|
+
* const { isExpanded } = useAccordionItem();
|
|
34
|
+
* return <Icon name={isExpanded ? 'minus' : 'add'} />;
|
|
35
|
+
* }
|
|
36
|
+
*/
|
|
37
|
+
export function useAccordionItem(): AccordionItemContextValue {
|
|
38
|
+
const context = useContext(AccordionItemContext);
|
|
39
|
+
if (!context) {
|
|
40
|
+
throw new Error(
|
|
41
|
+
"Accordion.Trigger, Accordion.Indicator and Accordion.Content must be rendered inside <Accordion.Item>."
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
return context;
|
|
45
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useCallback, useState } from "react";
|
|
2
|
+
|
|
3
|
+
import type { AccordionProps } from "../types";
|
|
4
|
+
|
|
5
|
+
function toArray(value: string | string[] | null | undefined): string[] {
|
|
6
|
+
if (value == null) return [];
|
|
7
|
+
return Array.isArray(value) ? value : [value];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Owns which items are open. Both modes are stored as an array so the rest of
|
|
12
|
+
* the accordion never branches on `selectionMode`; the mode only decides what a
|
|
13
|
+
* toggle does and what shape `onValueChange` receives.
|
|
14
|
+
*/
|
|
15
|
+
export function useAccordionCore(props: AccordionProps) {
|
|
16
|
+
const isMultiple = props.selectionMode === "multiple";
|
|
17
|
+
const isControlled = props.value !== undefined;
|
|
18
|
+
const isCollapsible = isMultiple || props.isCollapsible !== false;
|
|
19
|
+
|
|
20
|
+
const [internal, setInternal] = useState<string[]>(() => toArray(props.defaultValue));
|
|
21
|
+
const expanded = isControlled ? toArray(props.value) : internal;
|
|
22
|
+
|
|
23
|
+
const { onValueChange } = props;
|
|
24
|
+
|
|
25
|
+
const toggle = useCallback(
|
|
26
|
+
(itemValue: string) => {
|
|
27
|
+
const isOpen = expanded.includes(itemValue);
|
|
28
|
+
let next: string[];
|
|
29
|
+
|
|
30
|
+
if (isMultiple) {
|
|
31
|
+
next = isOpen ? expanded.filter((v) => v !== itemValue) : [...expanded, itemValue];
|
|
32
|
+
} else if (isOpen) {
|
|
33
|
+
if (!isCollapsible) return;
|
|
34
|
+
next = [];
|
|
35
|
+
} else {
|
|
36
|
+
next = [itemValue];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (!isControlled) setInternal(next);
|
|
40
|
+
|
|
41
|
+
if (isMultiple) {
|
|
42
|
+
(onValueChange as ((value: string[]) => void) | undefined)?.(next);
|
|
43
|
+
} else {
|
|
44
|
+
(onValueChange as ((value: string | null) => void) | undefined)?.(next[0] ?? null);
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
[expanded, isMultiple, isCollapsible, isControlled, onValueChange]
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
return { expanded, toggle };
|
|
51
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { Accordion } from "./Accordion";
|
|
2
|
+
export { useAccordionItem } from "./context";
|
|
3
|
+
export type { AccordionContentProps } from "./parts/AccordionContent";
|
|
4
|
+
export type { AccordionIndicatorProps } from "./parts/AccordionIndicator";
|
|
5
|
+
export type { AccordionItemProps } from "./parts/AccordionItem";
|
|
6
|
+
export type { AccordionTriggerProps } from "./parts/AccordionTrigger";
|
|
7
|
+
export type {
|
|
8
|
+
AccordionItemState,
|
|
9
|
+
AccordionMultipleProps,
|
|
10
|
+
AccordionProps,
|
|
11
|
+
AccordionSelectionMode,
|
|
12
|
+
AccordionSingleProps,
|
|
13
|
+
AccordionVariant,
|
|
14
|
+
} from "./types";
|