react-native-terra-ui 0.11.17 → 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 +17 -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/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/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/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
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { AccordionItemContextValue } from "./types.js";
|
|
2
|
+
export interface AccordionContextValue {
|
|
3
|
+
/** Open item values. Always an array, whatever the selection mode. */
|
|
4
|
+
expanded: readonly string[];
|
|
5
|
+
toggle: (value: string) => void;
|
|
6
|
+
isDisabled: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const AccordionContext: import("react").Context<AccordionContextValue | null>;
|
|
9
|
+
export declare const AccordionItemContext: import("react").Context<AccordionItemContextValue | null>;
|
|
10
|
+
export declare function useAccordionContext(): AccordionContextValue;
|
|
11
|
+
/**
|
|
12
|
+
* Reads the enclosing `Accordion.Item`: whether it is open or disabled, and a
|
|
13
|
+
* `toggle` that follows the accordion's selection rules. Use it to build a
|
|
14
|
+
* custom trigger or indicator.
|
|
15
|
+
*
|
|
16
|
+
* @throws When called outside an `Accordion.Item`.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* function PlusMinus() {
|
|
20
|
+
* const { isExpanded } = useAccordionItem();
|
|
21
|
+
* return <Icon name={isExpanded ? 'minus' : 'add'} />;
|
|
22
|
+
* }
|
|
23
|
+
*/
|
|
24
|
+
export declare function useAccordionItem(): AccordionItemContextValue;
|
|
25
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../../src/components/accordion/context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,YAAS,CAAC;AAEzD,MAAM,WAAW,qBAAqB;IACpC,sEAAsE;IACtE,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,gBAAgB,uDAAoD,CAAC;AAElF,eAAO,MAAM,oBAAoB,2DAAwD,CAAC;AAE1F,wBAAgB,mBAAmB,IAAI,qBAAqB,CAM3D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,IAAI,yBAAyB,CAQ5D"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AccordionProps } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Owns which items are open. Both modes are stored as an array so the rest of
|
|
4
|
+
* the accordion never branches on `selectionMode`; the mode only decides what a
|
|
5
|
+
* toggle does and what shape `onValueChange` receives.
|
|
6
|
+
*/
|
|
7
|
+
export declare function useAccordionCore(props: AccordionProps): {
|
|
8
|
+
expanded: string[];
|
|
9
|
+
toggle: (itemValue: string) => void;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=use-accordion-core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-accordion-core.d.ts","sourceRoot":"","sources":["../../../../../../src/components/accordion/hooks/use-accordion-core.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAU,CAAC;AAO/C;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,cAAc;;wBAWtC,MAAM;EAyBrB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { Accordion } from "./Accordion.js";
|
|
2
|
+
export { useAccordionItem } from "./context.js";
|
|
3
|
+
export type { AccordionContentProps } from "./parts/AccordionContent.js";
|
|
4
|
+
export type { AccordionIndicatorProps } from "./parts/AccordionIndicator.js";
|
|
5
|
+
export type { AccordionItemProps } from "./parts/AccordionItem.js";
|
|
6
|
+
export type { AccordionTriggerProps } from "./parts/AccordionTrigger.js";
|
|
7
|
+
export type { AccordionItemState, AccordionMultipleProps, AccordionProps, AccordionSelectionMode, AccordionSingleProps, AccordionVariant, } from "./types.js";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/accordion/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAa,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAW,CAAC;AAC7C,YAAY,EAAE,qBAAqB,EAAE,MAAM,6BAA0B,CAAC;AACtE,YAAY,EAAE,uBAAuB,EAAE,MAAM,+BAA4B,CAAC;AAC1E,YAAY,EAAE,kBAAkB,EAAE,MAAM,0BAAuB,CAAC;AAChE,YAAY,EAAE,qBAAqB,EAAE,MAAM,6BAA0B,CAAC;AACtE,YAAY,EACV,kBAAkB,EAClB,sBAAsB,EACtB,cAAc,EACd,sBAAsB,EACtB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,YAAS,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { type ViewProps } from "react-native";
|
|
3
|
+
export interface AccordionContentProps extends ViewProps {
|
|
4
|
+
/** The panel body. Strings and numbers are wrapped in body text. */
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export declare const AccordionContent: import("react").ForwardRefExoticComponent<AccordionContentProps & import("react").RefAttributes<import("react-native/types_generated/src/private/webapis/dom/nodes/ReactNativeElement").default>>;
|
|
8
|
+
//# sourceMappingURL=AccordionContent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccordionContent.d.ts","sourceRoot":"","sources":["../../../../../../src/components/accordion/parts/AccordionContent.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA2C,KAAK,SAAS,EAAuB,MAAM,OAAO,CAAC;AACrG,OAAO,EAAgC,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAU5E,MAAM,WAAW,qBAAsB,SAAQ,SAAS;IACtD,oEAAoE;IACpE,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAsBD,eAAO,MAAM,gBAAgB,mMA+C5B,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import type { ViewProps } from "react-native";
|
|
3
|
+
import type { ColorToken } from "../../../theme/types";
|
|
4
|
+
export interface AccordionIndicatorProps extends Omit<ViewProps, "children"> {
|
|
5
|
+
/** Chevron color. Ignored with custom `children`. Defaults to `'text.secondary'`. */
|
|
6
|
+
color?: ColorToken;
|
|
7
|
+
/** Chevron size in dp. Ignored with custom `children`. Defaults to `20`. */
|
|
8
|
+
size?: number;
|
|
9
|
+
/**
|
|
10
|
+
* Replaces the chevron. Custom content does not rotate — read `isExpanded`
|
|
11
|
+
* from the item's render function or `useAccordionItem()` to swap it instead.
|
|
12
|
+
*/
|
|
13
|
+
children?: ReactNode;
|
|
14
|
+
}
|
|
15
|
+
export declare const AccordionIndicator: import("react").ForwardRefExoticComponent<AccordionIndicatorProps & import("react").RefAttributes<import("react-native/types_generated/src/private/webapis/dom/nodes/ReactNativeElement").default>>;
|
|
16
|
+
//# sourceMappingURL=AccordionIndicator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccordionIndicator.d.ts","sourceRoot":"","sources":["../../../../../../src/components/accordion/parts/AccordionIndicator.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiC,KAAK,SAAS,EAAa,MAAM,OAAO,CAAC;AACjF,OAAO,KAAK,EAAQ,SAAS,EAAE,MAAM,cAAc,CAAC;AAKpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAK/C,MAAM,WAAW,uBAAwB,SAAQ,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC;IAC1E,qFAAqF;IACrF,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,4EAA4E;IAC5E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,eAAO,MAAM,kBAAkB,qMA+B9B,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { type ViewProps } from "react-native";
|
|
3
|
+
import type { AccordionItemState } from "../types.js";
|
|
4
|
+
export interface AccordionItemProps extends Omit<ViewProps, "children"> {
|
|
5
|
+
/** Identifies the item in the accordion's `value`. Unique within one accordion. */
|
|
6
|
+
value: string;
|
|
7
|
+
/** Disables this item only. Defaults to `false`. */
|
|
8
|
+
isDisabled?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* The item's trigger and content, or a function that receives the item's
|
|
11
|
+
* `{ isExpanded, isDisabled }` and returns them.
|
|
12
|
+
*/
|
|
13
|
+
children?: ReactNode | ((state: AccordionItemState) => ReactNode);
|
|
14
|
+
}
|
|
15
|
+
export declare const AccordionItem: import("react").ForwardRefExoticComponent<AccordionItemProps & import("react").RefAttributes<import("react-native/types_generated/src/private/webapis/dom/nodes/ReactNativeElement").default>>;
|
|
16
|
+
//# sourceMappingURL=AccordionItem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccordionItem.d.ts","sourceRoot":"","sources":["../../../../../../src/components/accordion/parts/AccordionItem.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiC,KAAK,SAAS,EAAwB,MAAM,OAAO,CAAC;AAC5F,OAAO,EAAQ,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAKpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAU,CAAC;AAEnD,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC;IACrE,mFAAmF;IACnF,KAAK,EAAE,MAAM,CAAC;IACd,oDAAoD;IACpD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,QAAQ,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC,KAAK,EAAE,kBAAkB,KAAK,SAAS,CAAC,CAAC;CACnE;AAED,eAAO,MAAM,aAAa,gMAyBxB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { type PressableProps } from "react-native";
|
|
3
|
+
export interface AccordionTriggerProps extends Omit<PressableProps, "children" | "disabled"> {
|
|
4
|
+
/**
|
|
5
|
+
* The header row. Strings and numbers become the item's title; put an
|
|
6
|
+
* `Accordion.Indicator` last to show the open state.
|
|
7
|
+
*/
|
|
8
|
+
children?: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
export declare const AccordionTrigger: import("react").ForwardRefExoticComponent<AccordionTriggerProps & import("react").RefAttributes<import("react-native/types_generated/src/private/webapis/dom/nodes/ReactNativeElement").default>>;
|
|
11
|
+
//# sourceMappingURL=AccordionTrigger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccordionTrigger.d.ts","sourceRoot":"","sources":["../../../../../../src/components/accordion/parts/AccordionTrigger.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA2C,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAChF,OAAO,EAAyC,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAO1F,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CAAC,cAAc,EAAE,UAAU,GAAG,UAAU,CAAC;IAC1F;;;OAGG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAsBD,eAAO,MAAM,gBAAgB,mMA4B5B,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { ViewProps } from "react-native";
|
|
3
|
+
export type AccordionSelectionMode = "single" | "multiple";
|
|
4
|
+
export type AccordionVariant = "plain" | "surface";
|
|
5
|
+
interface AccordionBaseProps extends Omit<ViewProps, "children"> {
|
|
6
|
+
/**
|
|
7
|
+
* Visual treatment. `'plain'` draws the items straight onto whatever sits
|
|
8
|
+
* behind the accordion; `'surface'` puts them in a filled, rounded container.
|
|
9
|
+
* Defaults to `'plain'`.
|
|
10
|
+
*/
|
|
11
|
+
variant?: AccordionVariant;
|
|
12
|
+
/** Draws a hairline rule between items. Defaults to `true`. */
|
|
13
|
+
divided?: boolean;
|
|
14
|
+
/** Disables every item. Defaults to `false`. */
|
|
15
|
+
isDisabled?: boolean;
|
|
16
|
+
/** `Accordion.Item` elements. */
|
|
17
|
+
children?: ReactNode;
|
|
18
|
+
}
|
|
19
|
+
export interface AccordionSingleProps extends AccordionBaseProps {
|
|
20
|
+
/**
|
|
21
|
+
* `'single'` keeps at most one item open; opening another closes the current
|
|
22
|
+
* one. Defaults to `'single'`.
|
|
23
|
+
*/
|
|
24
|
+
selectionMode?: "single";
|
|
25
|
+
/**
|
|
26
|
+
* The open item, controlled. `null` means none is open — `undefined` leaves
|
|
27
|
+
* the accordion uncontrolled.
|
|
28
|
+
*/
|
|
29
|
+
value?: string | null;
|
|
30
|
+
/** The item open on first render, uncontrolled. Defaults to `undefined`. */
|
|
31
|
+
defaultValue?: string;
|
|
32
|
+
/** Called with the newly open item, or `null` when the open item closes. */
|
|
33
|
+
onValueChange?: (value: string | null) => void;
|
|
34
|
+
/**
|
|
35
|
+
* Lets the open item close by pressing its trigger again. `false` keeps one
|
|
36
|
+
* item open at all times once any has been opened. Defaults to `true`.
|
|
37
|
+
*/
|
|
38
|
+
isCollapsible?: boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface AccordionMultipleProps extends AccordionBaseProps {
|
|
41
|
+
/** `'multiple'` lets any number of items be open at once. */
|
|
42
|
+
selectionMode: "multiple";
|
|
43
|
+
/** The open items, controlled. */
|
|
44
|
+
value?: string[];
|
|
45
|
+
/** The items open on first render, uncontrolled. Defaults to `[]`. */
|
|
46
|
+
defaultValue?: string[];
|
|
47
|
+
/** Called with every open item after one is toggled. */
|
|
48
|
+
onValueChange?: (value: string[]) => void;
|
|
49
|
+
/** Multiple mode can always close an item. */
|
|
50
|
+
isCollapsible?: never;
|
|
51
|
+
}
|
|
52
|
+
export type AccordionProps = AccordionSingleProps | AccordionMultipleProps;
|
|
53
|
+
export interface AccordionItemState {
|
|
54
|
+
/** Whether the item's content is open. */
|
|
55
|
+
isExpanded: boolean;
|
|
56
|
+
/** Whether the item, or the whole accordion, is disabled. */
|
|
57
|
+
isDisabled: boolean;
|
|
58
|
+
}
|
|
59
|
+
export interface AccordionItemContextValue extends AccordionItemState {
|
|
60
|
+
value: string;
|
|
61
|
+
/** Opens or closes this item, following the accordion's selection rules. */
|
|
62
|
+
toggle: () => void;
|
|
63
|
+
}
|
|
64
|
+
export {};
|
|
65
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/components/accordion/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,MAAM,sBAAsB,GAAG,QAAQ,GAAG,UAAU,CAAC;AAE3D,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,SAAS,CAAC;AAEnD,UAAU,kBAAmB,SAAQ,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC;IAC9D;;;;OAIG;IACH,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,+DAA+D;IAC/D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gDAAgD;IAChD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,iCAAiC;IACjC,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,MAAM,WAAW,oBAAqB,SAAQ,kBAAkB;IAC9D;;;OAGG;IACH,aAAa,CAAC,EAAE,QAAQ,CAAC;IACzB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,4EAA4E;IAC5E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,4EAA4E;IAC5E,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAC/C;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,sBAAuB,SAAQ,kBAAkB;IAChE,6DAA6D;IAC7D,aAAa,EAAE,UAAU,CAAC;IAC1B,kCAAkC;IAClC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,sEAAsE;IACtE,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,wDAAwD;IACxD,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAC1C,8CAA8C;IAC9C,aAAa,CAAC,EAAE,KAAK,CAAC;CACvB;AAED,MAAM,MAAM,cAAc,GAAG,oBAAoB,GAAG,sBAAsB,CAAC;AAE3E,MAAM,WAAW,kBAAkB;IACjC,0CAA0C;IAC1C,UAAU,EAAE,OAAO,CAAC;IACpB,6DAA6D;IAC7D,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,yBAA0B,SAAQ,kBAAkB;IACnE,KAAK,EAAE,MAAM,CAAC;IACd,4EAA4E;IAC5E,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type WithTimingConfig } from "react-native-reanimated";
|
|
2
|
+
/**
|
|
3
|
+
* Shared by the content's height and the indicator's rotation so the chevron
|
|
4
|
+
* finishes turning as the panel finishes opening. Honours the system
|
|
5
|
+
* reduce-motion setting, which makes both jump straight to their end state.
|
|
6
|
+
*/
|
|
7
|
+
export declare const ACCORDION_TIMING: WithTimingConfig;
|
|
8
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../src/components/accordion/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEtF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAE,gBAI9B,CAAC"}
|
|
@@ -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":"","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,sEAAsE;AACtE,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,UAAU,GAAG,cAAc,GAAG,aAAa,CAAC;AAEvF,yCAAyC;AACzC,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE3C;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAClB,SAAS,GACT,WAAW,GACX,SAAS,GACT,SAAS,GACT,QAAQ,GAER,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAElB,MAAM,WAAW,UAAW,SAAQ,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC;IAC7D;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,oEAAoE;IACpE,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,8CAA8C;IAC9C,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,cAAe,SAAQ,SAAS;IAC/C,uFAAuF;IACvF,QAAQ,EAAE,SAAS,CAAC;IACpB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,oEAAoE;IACpE,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,8CAA8C;IAC9C,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG;QAAE,CAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,CAAC,EAAE,MAAM,CAAA;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,QAAQ,MAAM,yBAAyB,CAAC;AAO/C,OAAO,EAAuB,KAAK,kBAAkB,EAAE,MAAM,sBAAmB,CAAC;AAEjF,OAAO,EAAiB,KAAK,kBAAkB,EAAE,MAAM,oBAAiB,CAAC;AAGzE,UAAU,cAAe,SAAQ,kBAAkB;IACjD,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,cAAc,EAAE,QAAQ,GAAG,MAAM,CAAC;IAClC,KAAK,EAAE,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,+
|
|
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,QAAQ,MAAM,yBAAyB,CAAC;AAO/C,OAAO,EAAuB,KAAK,kBAAkB,EAAE,MAAM,sBAAmB,CAAC;AAEjF,OAAO,EAAiB,KAAK,kBAAkB,EAAE,MAAM,oBAAiB,CAAC;AAGzE,UAAU,cAAe,SAAQ,kBAAkB;IACjD,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,cAAc,EAAE,QAAQ,GAAG,MAAM,CAAC;IAClC,KAAK,EAAE,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"}
|
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
|
+
}
|