jfs-components 0.0.79 → 0.0.85
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 +29 -0
- package/lib/commonjs/components/AppBar/AppBar.js +70 -6
- package/lib/commonjs/components/AreaLineChart/AreaLineChart.js +866 -0
- package/lib/commonjs/components/AreaLineChart/chartMath.js +252 -0
- package/lib/commonjs/components/Attached/Attached.js +76 -7
- package/lib/commonjs/components/BubbleChart/BubbleChart.js +191 -0
- package/lib/commonjs/components/BubbleChart/bubblePacking.js +378 -0
- package/lib/commonjs/components/Checkbox/Checkbox.js +18 -2
- package/lib/commonjs/components/ClusterBubble/ClusterBubble.js +272 -0
- package/lib/commonjs/components/Drawer/Drawer.js +6 -1
- package/lib/commonjs/components/DropdownInput/DropdownInput.js +30 -6
- package/lib/commonjs/components/ExpandableCheckbox/ExpandableCheckbox.js +17 -11
- package/lib/commonjs/components/FormField/FormField.js +1 -14
- package/lib/commonjs/components/FullscreenModal/FullscreenModal.js +5 -1
- package/lib/commonjs/components/ListItem/ListItem.js +6 -11
- package/lib/commonjs/components/MessageField/MessageField.js +1 -13
- package/lib/commonjs/components/MetricLegendItem/MetricLegendItem.js +7 -1
- package/lib/commonjs/components/PaymentFeedback/PaymentFeedback.js +12 -9
- package/lib/commonjs/components/PlanComparisonCard/PlanComparisonCard.js +69 -160
- package/lib/commonjs/components/Spinner/Spinner.js +217 -0
- package/lib/commonjs/components/TextInput/TextInput.js +33 -18
- package/lib/commonjs/components/index.js +34 -0
- package/lib/commonjs/design-tokens/Coin Variables-variables-full.json +1 -1
- package/lib/commonjs/icons/components/IconArrowdown.js +19 -0
- package/lib/commonjs/icons/components/IconArrowup.js +19 -0
- package/lib/commonjs/icons/components/IconChevrondowncircle.js +19 -0
- package/lib/commonjs/icons/components/IconChevronleftcircle.js +19 -0
- package/lib/commonjs/icons/components/IconChevronrightcircle.js +19 -0
- package/lib/commonjs/icons/components/IconChevronupcircle.js +19 -0
- package/lib/commonjs/icons/components/IconOsnavback.js +19 -0
- package/lib/commonjs/icons/components/IconOsnavcenter.js +19 -0
- package/lib/commonjs/icons/components/IconOsnavhome.js +19 -0
- package/lib/commonjs/icons/components/IconOsnavtask.js +19 -0
- package/lib/commonjs/icons/components/IconSignin.js +19 -0
- package/lib/commonjs/icons/components/IconSignout.js +19 -0
- package/lib/commonjs/icons/components/index.js +132 -0
- package/lib/commonjs/icons/registry.js +2 -2
- package/lib/module/components/AppBar/AppBar.js +70 -6
- package/lib/module/components/AreaLineChart/AreaLineChart.js +859 -0
- package/lib/module/components/AreaLineChart/chartMath.js +242 -0
- package/lib/module/components/Attached/Attached.js +76 -7
- package/lib/module/components/BubbleChart/BubbleChart.js +185 -0
- package/lib/module/components/BubbleChart/bubblePacking.js +370 -0
- package/lib/module/components/Checkbox/Checkbox.js +18 -2
- package/lib/module/components/ClusterBubble/ClusterBubble.js +267 -0
- package/lib/module/components/Drawer/Drawer.js +6 -1
- package/lib/module/components/DropdownInput/DropdownInput.js +30 -6
- package/lib/module/components/ExpandableCheckbox/ExpandableCheckbox.js +17 -11
- package/lib/module/components/FormField/FormField.js +3 -16
- package/lib/module/components/FullscreenModal/FullscreenModal.js +5 -1
- package/lib/module/components/ListItem/ListItem.js +6 -11
- package/lib/module/components/MessageField/MessageField.js +3 -15
- package/lib/module/components/MetricLegendItem/MetricLegendItem.js +7 -1
- package/lib/module/components/PaymentFeedback/PaymentFeedback.js +13 -9
- package/lib/module/components/PlanComparisonCard/PlanComparisonCard.js +72 -160
- package/lib/module/components/Spinner/Spinner.js +212 -0
- package/lib/module/components/TextInput/TextInput.js +34 -19
- package/lib/module/components/index.js +4 -0
- package/lib/module/design-tokens/Coin Variables-variables-full.json +1 -1
- package/lib/module/icons/components/IconArrowdown.js +12 -0
- package/lib/module/icons/components/IconArrowup.js +12 -0
- package/lib/module/icons/components/IconChevrondowncircle.js +12 -0
- package/lib/module/icons/components/IconChevronleftcircle.js +12 -0
- package/lib/module/icons/components/IconChevronrightcircle.js +12 -0
- package/lib/module/icons/components/IconChevronupcircle.js +12 -0
- package/lib/module/icons/components/IconOsnavback.js +12 -0
- package/lib/module/icons/components/IconOsnavcenter.js +12 -0
- package/lib/module/icons/components/IconOsnavhome.js +12 -0
- package/lib/module/icons/components/IconOsnavtask.js +12 -0
- package/lib/module/icons/components/IconSignin.js +12 -0
- package/lib/module/icons/components/IconSignout.js +12 -0
- package/lib/module/icons/components/index.js +12 -0
- package/lib/module/icons/registry.js +2 -2
- package/lib/typescript/src/components/AppBar/AppBar.d.ts +12 -1
- package/lib/typescript/src/components/AreaLineChart/AreaLineChart.d.ts +212 -0
- package/lib/typescript/src/components/AreaLineChart/chartMath.d.ts +90 -0
- package/lib/typescript/src/components/Attached/Attached.d.ts +19 -16
- package/lib/typescript/src/components/BubbleChart/BubbleChart.d.ts +81 -0
- package/lib/typescript/src/components/BubbleChart/bubblePacking.d.ts +83 -0
- package/lib/typescript/src/components/ClusterBubble/ClusterBubble.d.ts +76 -0
- package/lib/typescript/src/components/DropdownInput/DropdownInput.d.ts +3 -2
- package/lib/typescript/src/components/ListItem/ListItem.d.ts +3 -3
- package/lib/typescript/src/components/MetricLegendItem/MetricLegendItem.d.ts +7 -1
- package/lib/typescript/src/components/PaymentFeedback/PaymentFeedback.d.ts +5 -1
- package/lib/typescript/src/components/PlanComparisonCard/PlanComparisonCard.d.ts +10 -8
- package/lib/typescript/src/components/Spinner/Spinner.d.ts +45 -0
- package/lib/typescript/src/components/index.d.ts +4 -0
- package/lib/typescript/src/icons/components/IconArrowdown.d.ts +3 -0
- package/lib/typescript/src/icons/components/IconArrowup.d.ts +3 -0
- package/lib/typescript/src/icons/components/IconChevrondowncircle.d.ts +3 -0
- package/lib/typescript/src/icons/components/IconChevronleftcircle.d.ts +3 -0
- package/lib/typescript/src/icons/components/IconChevronrightcircle.d.ts +3 -0
- package/lib/typescript/src/icons/components/IconChevronupcircle.d.ts +3 -0
- package/lib/typescript/src/icons/components/IconOsnavback.d.ts +3 -0
- package/lib/typescript/src/icons/components/IconOsnavcenter.d.ts +3 -0
- package/lib/typescript/src/icons/components/IconOsnavhome.d.ts +3 -0
- package/lib/typescript/src/icons/components/IconOsnavtask.d.ts +3 -0
- package/lib/typescript/src/icons/components/IconSignin.d.ts +3 -0
- package/lib/typescript/src/icons/components/IconSignout.d.ts +3 -0
- package/lib/typescript/src/icons/components/index.d.ts +12 -0
- package/lib/typescript/src/icons/registry.d.ts +1 -1
- package/package.json +3 -2
- package/src/components/AppBar/AppBar.tsx +92 -12
- package/src/components/AreaLineChart/AreaLineChart.tsx +1161 -0
- package/src/components/AreaLineChart/chartMath.ts +265 -0
- package/src/components/Attached/Attached.tsx +94 -7
- package/src/components/BubbleChart/BubbleChart.tsx +319 -0
- package/src/components/BubbleChart/bubblePacking.ts +397 -0
- package/src/components/Checkbox/Checkbox.tsx +14 -2
- package/src/components/ClusterBubble/ClusterBubble.tsx +359 -0
- package/src/components/Drawer/Drawer.tsx +4 -0
- package/src/components/DropdownInput/DropdownInput.tsx +54 -20
- package/src/components/ExpandableCheckbox/ExpandableCheckbox.tsx +13 -9
- package/src/components/FormField/FormField.tsx +3 -19
- package/src/components/FullscreenModal/FullscreenModal.tsx +3 -0
- package/src/components/ListItem/ListItem.tsx +14 -16
- package/src/components/MessageField/MessageField.tsx +3 -18
- package/src/components/MetricLegendItem/MetricLegendItem.tsx +20 -6
- package/src/components/PaymentFeedback/PaymentFeedback.tsx +15 -8
- package/src/components/PlanComparisonCard/PlanComparisonCard.tsx +82 -192
- package/src/components/Spinner/Spinner.tsx +273 -0
- package/src/components/TextInput/TextInput.tsx +37 -19
- package/src/components/index.ts +4 -0
- package/src/design-tokens/Coin Variables-variables-full.json +1 -1
- package/src/icons/components/IconArrowdown.tsx +11 -0
- package/src/icons/components/IconArrowup.tsx +11 -0
- package/src/icons/components/IconChevrondowncircle.tsx +11 -0
- package/src/icons/components/IconChevronleftcircle.tsx +11 -0
- package/src/icons/components/IconChevronrightcircle.tsx +11 -0
- package/src/icons/components/IconChevronupcircle.tsx +11 -0
- package/src/icons/components/IconOsnavback.tsx +11 -0
- package/src/icons/components/IconOsnavcenter.tsx +11 -0
- package/src/icons/components/IconOsnavhome.tsx +11 -0
- package/src/icons/components/IconOsnavtask.tsx +11 -0
- package/src/icons/components/IconSignin.tsx +11 -0
- package/src/icons/components/IconSignout.tsx +11 -0
- package/src/icons/components/index.ts +12 -0
- package/src/icons/registry.ts +49 -1
|
@@ -13,6 +13,12 @@ export type MetricLegendItemProps = {
|
|
|
13
13
|
* `metricLegendItem/indicator/bg` design token.
|
|
14
14
|
*/
|
|
15
15
|
indicatorColor?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Shape of the leading indicator. `'dot'` (default) renders the small
|
|
18
|
+
* circle used in categorical legends; `'line'` renders a short
|
|
19
|
+
* horizontal bar, matching the legend of a line chart.
|
|
20
|
+
*/
|
|
21
|
+
indicatorShape?: 'dot' | 'line';
|
|
16
22
|
/** Design token modes for theming (e.g. `{ 'Color Mode': 'Light' }`). */
|
|
17
23
|
modes?: Record<string, any>;
|
|
18
24
|
/** Override container styles. */
|
|
@@ -32,6 +38,6 @@ export type MetricLegendItemProps = {
|
|
|
32
38
|
* @component
|
|
33
39
|
* @param {MetricLegendItemProps} props
|
|
34
40
|
*/
|
|
35
|
-
declare function MetricLegendItem({ label, value, indicatorColor, modes, style, indicatorStyle, labelStyle, valueStyle, }: MetricLegendItemProps): import("react/jsx-runtime").JSX.Element;
|
|
41
|
+
declare function MetricLegendItem({ label, value, indicatorColor, indicatorShape, modes, style, indicatorStyle, labelStyle, valueStyle, }: MetricLegendItemProps): import("react/jsx-runtime").JSX.Element;
|
|
36
42
|
export default MetricLegendItem;
|
|
37
43
|
//# sourceMappingURL=MetricLegendItem.d.ts.map
|
|
@@ -15,7 +15,11 @@ export type PaymentFeedbackProps = {
|
|
|
15
15
|
iconName?: string;
|
|
16
16
|
/** Optional custom media slot that replaces the default IconCapsule */
|
|
17
17
|
renderMedia?: ReactNode;
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Mode configuration for design tokens. Also drives the default
|
|
20
|
+
* IconCapsule's color — pass `AppearanceSystem: 'positive' | 'warning' |
|
|
21
|
+
* 'negative'` to render a green/orange/red capsule (defaults to `positive`).
|
|
22
|
+
*/
|
|
19
23
|
modes?: Record<string, any>;
|
|
20
24
|
style?: ViewStyle;
|
|
21
25
|
};
|
|
@@ -47,18 +47,20 @@ export type PlanComparisonCardProps = {
|
|
|
47
47
|
columns?: PlanComparisonColumn[];
|
|
48
48
|
/** Feature rows compared across the plan columns. */
|
|
49
49
|
rows?: PlanComparisonRow[];
|
|
50
|
-
/**
|
|
51
|
-
* Minimum flex-grow on the label column when the table is given extra
|
|
52
|
-
* horizontal space. Plan columns always size to their content and never
|
|
53
|
-
* shrink below it.
|
|
54
|
-
* @default 0
|
|
55
|
-
*/
|
|
56
|
-
labelColumnFlex?: number;
|
|
57
50
|
/** Design token modes for theming (e.g. `{ "Color Mode": "Light" }`). */
|
|
58
51
|
modes?: Record<string, any>;
|
|
59
52
|
/** Override the outer container style. */
|
|
60
53
|
style?: StyleProp<ViewStyle>;
|
|
61
54
|
};
|
|
62
|
-
|
|
55
|
+
/**
|
|
56
|
+
* PlanComparisonCard renders a compact comparison table that pits the user's
|
|
57
|
+
* current plan against one or more alternative plans across a set of feature
|
|
58
|
+
* rows. Implementation of Figma node `4498:2968` (`PlanComparisonCard`).
|
|
59
|
+
*
|
|
60
|
+
* Columns use a 1.8fr / 1fr flex ratio (label vs plan), matching the Figma grid.
|
|
61
|
+
*
|
|
62
|
+
* @component
|
|
63
|
+
*/
|
|
64
|
+
declare function PlanComparisonCard({ columns, rows, modes, style, }: PlanComparisonCardProps): import("react/jsx-runtime").JSX.Element;
|
|
63
65
|
export default PlanComparisonCard;
|
|
64
66
|
//# sourceMappingURL=PlanComparisonCard.d.ts.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type StyleProp, type ViewProps, type ViewStyle } from 'react-native';
|
|
2
|
+
/**
|
|
3
|
+
* Per-segment colours, resolved from the Figma `spiner/*` tokens. Consumers can
|
|
4
|
+
* override any subset via the `colors` prop.
|
|
5
|
+
*/
|
|
6
|
+
export type SpinnerColors = {
|
|
7
|
+
/** Leading segment (front of the falling chain). */
|
|
8
|
+
primary?: string;
|
|
9
|
+
/** Middle segment. */
|
|
10
|
+
secondary?: string;
|
|
11
|
+
/** Trailing segment (tail of the chain). */
|
|
12
|
+
tertiary?: string;
|
|
13
|
+
};
|
|
14
|
+
type SpinnerBaseProps = Omit<ViewProps, 'children' | 'style'>;
|
|
15
|
+
export type SpinnerProps = SpinnerBaseProps & {
|
|
16
|
+
/**
|
|
17
|
+
* Diameter in px. The spinner is always rendered at a 1:1 ratio, so a single
|
|
18
|
+
* size controls both width and height. Defaults to the Figma size (72).
|
|
19
|
+
*/
|
|
20
|
+
size?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Duration of one full clockwise revolution of the leading segment, in ms.
|
|
23
|
+
* Lower = faster. Defaults to 2400.
|
|
24
|
+
*/
|
|
25
|
+
durationMs?: number;
|
|
26
|
+
/**
|
|
27
|
+
* "Weightiness" of the fall, in `[0, 0.9]`. 0 = perfectly constant speed;
|
|
28
|
+
* higher values make segments whip faster over the top and ease through the
|
|
29
|
+
* bottom. Kept below 1 so the motion never reverses. Defaults to 0.45.
|
|
30
|
+
*/
|
|
31
|
+
gravity?: number;
|
|
32
|
+
/** Override any subset of the token-driven segment colours. */
|
|
33
|
+
colors?: SpinnerColors;
|
|
34
|
+
/** When false, renders a static resting spinner (also honoured for reduced motion). Defaults to true. */
|
|
35
|
+
animating?: boolean;
|
|
36
|
+
/** Design token modes forwarded to token lookups. */
|
|
37
|
+
modes?: Record<string, any>;
|
|
38
|
+
/** Container style override. */
|
|
39
|
+
style?: StyleProp<ViewStyle>;
|
|
40
|
+
/** Accessibility label announced to assistive tech. Defaults to "Loading". */
|
|
41
|
+
accessibilityLabel?: string;
|
|
42
|
+
};
|
|
43
|
+
declare function Spinner({ size, durationMs, gravity, colors, animating, modes: propModes, style, accessibilityLabel, ...rest }: SpinnerProps): import("react/jsx-runtime").JSX.Element;
|
|
44
|
+
export default Spinner;
|
|
45
|
+
//# sourceMappingURL=Spinner.d.ts.map
|
|
@@ -65,6 +65,7 @@ export { default as Title, type TitleProps } from './Title/Title';
|
|
|
65
65
|
export { default as Screen, type ScreenProps } from './Screen/Screen';
|
|
66
66
|
export { default as Section } from './Section/Section';
|
|
67
67
|
export { default as Slot, type SlotProps, type SlotLayoutDirection } from './Slot/Slot';
|
|
68
|
+
export { default as Spinner, type SpinnerProps, type SpinnerColors } from './Spinner/Spinner';
|
|
68
69
|
export { default as Stepper, type StepperProps } from './Stepper/Stepper';
|
|
69
70
|
export { Step, type StepProps, type StepStatus } from './Stepper/Step';
|
|
70
71
|
export { StepLabel, type StepLabelProps } from './Stepper/StepLabel';
|
|
@@ -100,6 +101,9 @@ export { default as RadioButton, type RadioButtonProps } from './RadioButton/Rad
|
|
|
100
101
|
export { default as RechargeCard, type RechargeCardProps } from './RechargeCard/RechargeCard';
|
|
101
102
|
export { default as SavingsGoalSummary, type SavingsGoalSummaryProps, type SavingsGoalSummaryItem } from './SavingsGoalSummary/SavingsGoalSummary';
|
|
102
103
|
export { default as DonutChart, type DonutChartProps, type DonutChartSegmentData, type DonutChartSegmentProps, DonutChartSegment } from './DonutChart/DonutChart';
|
|
104
|
+
export { default as AreaLineChart, useChart, type AreaLineChartProps, type ChartSeries, type ChartPoint, type ChartInset, type GoalPinConfig, type ChartGridProps, type ChartXAxisProps, type ChartYAxisProps, type ChartGoalPinProps } from './AreaLineChart/AreaLineChart';
|
|
105
|
+
export { default as ClusterBubble, type ClusterBubbleProps, type ClusterBubbleLabelPlacement, type ClusterBubbleLabelDirection } from './ClusterBubble/ClusterBubble';
|
|
106
|
+
export { default as BubbleChart, type BubbleChartProps, type BubbleDatum } from './BubbleChart/BubbleChart';
|
|
103
107
|
export { default as DonutChartSummary, type DonutChartSummaryProps, type DonutChartSummaryItem } from './DonutChartSummary/DonutChartSummary';
|
|
104
108
|
export { default as RangeTrack, type RangeTrackProps, type RangeTrackTab, type RangeTrackItem } from './RangeTrack/RangeTrack';
|
|
105
109
|
export { default as SegmentedTrack, type SegmentedTrackProps, type SegmentedTrackSegmentData, type SegmentedTrackSegmentProps, SegmentedTrackSegment } from './SegmentedTrack/SegmentedTrack';
|
|
@@ -63,10 +63,12 @@ export * from './IconArmed';
|
|
|
63
63
|
export * from './IconArmedoff';
|
|
64
64
|
export * from './IconArmedpartially';
|
|
65
65
|
export * from './IconArrowback';
|
|
66
|
+
export * from './IconArrowdown';
|
|
66
67
|
export * from './IconArrowline';
|
|
67
68
|
export * from './IconArrowlinediagonal';
|
|
68
69
|
export * from './IconArrowlinedot';
|
|
69
70
|
export * from './IconArrownext';
|
|
71
|
+
export * from './IconArrowup';
|
|
70
72
|
export * from './IconArtificialinsemination';
|
|
71
73
|
export * from './IconAssistivegrid';
|
|
72
74
|
export * from './IconAstrology';
|
|
@@ -236,9 +238,13 @@ export * from './IconChemistry';
|
|
|
236
238
|
export * from './IconCherry';
|
|
237
239
|
export * from './IconChestpain';
|
|
238
240
|
export * from './IconChevrondown';
|
|
241
|
+
export * from './IconChevrondowncircle';
|
|
239
242
|
export * from './IconChevronleft';
|
|
243
|
+
export * from './IconChevronleftcircle';
|
|
240
244
|
export * from './IconChevronright';
|
|
245
|
+
export * from './IconChevronrightcircle';
|
|
241
246
|
export * from './IconChevronup';
|
|
247
|
+
export * from './IconChevronupcircle';
|
|
242
248
|
export * from './IconChildrengame';
|
|
243
249
|
export * from './IconCholesterol';
|
|
244
250
|
export * from './IconCleaning';
|
|
@@ -757,6 +763,10 @@ export * from './IconOperatingtable';
|
|
|
757
763
|
export * from './IconOperator';
|
|
758
764
|
export * from './IconOrder';
|
|
759
765
|
export * from './IconOrders';
|
|
766
|
+
export * from './IconOsnavback';
|
|
767
|
+
export * from './IconOsnavcenter';
|
|
768
|
+
export * from './IconOsnavhome';
|
|
769
|
+
export * from './IconOsnavtask';
|
|
760
770
|
export * from './IconOtp';
|
|
761
771
|
export * from './IconOutofstock';
|
|
762
772
|
export * from './IconOutgoing';
|
|
@@ -953,6 +963,8 @@ export * from './IconShutter10s';
|
|
|
953
963
|
export * from './IconShutter3s';
|
|
954
964
|
export * from './IconShutter5s';
|
|
955
965
|
export * from './IconSign';
|
|
966
|
+
export * from './IconSignin';
|
|
967
|
+
export * from './IconSignout';
|
|
956
968
|
export * from './IconSim';
|
|
957
969
|
export * from './IconSim1';
|
|
958
970
|
export * from './IconSim2';
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Auto-generated from SVG files in src/icons/
|
|
5
5
|
* DO NOT EDIT MANUALLY - Run "npm run icons:generate" to regenerate
|
|
6
6
|
*
|
|
7
|
-
* Generated: 2026-
|
|
7
|
+
* Generated: 2026-06-02T15:42:11.888Z
|
|
8
8
|
*/
|
|
9
9
|
export declare const iconRegistry: Record<string, {
|
|
10
10
|
path: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jfs-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.85",
|
|
4
4
|
"description": "React Native Jio Finance Components Library",
|
|
5
5
|
"author": "sunshuaiqi@gmail.com",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,7 +40,8 @@
|
|
|
40
40
|
"icons:generate": "node scripts/generate-icon-registry.js",
|
|
41
41
|
"prepare": "bob build",
|
|
42
42
|
"build": "bob build",
|
|
43
|
-
"prepack": "yarn icons:generate && bob build"
|
|
43
|
+
"prepack": "yarn icons:generate && bob build",
|
|
44
|
+
"push:xpaydemo": "bash scripts/push-to-xpaydemo.sh"
|
|
44
45
|
},
|
|
45
46
|
"react-native-builder-bob": {
|
|
46
47
|
"source": "src",
|
|
@@ -8,6 +8,14 @@ import { cloneChildrenWithModes, EMPTY_MODES } from '../../utils/react-utils'
|
|
|
8
8
|
|
|
9
9
|
type AppBarType = 'MainPage' | 'SubPage'
|
|
10
10
|
|
|
11
|
+
// SubPage "slot wrap" geometry, taken directly from the Figma design
|
|
12
|
+
// (node 449:7876). The middle slot is an absolutely-centered box of a fixed
|
|
13
|
+
// size; its inner content (node 3991:4125) is a `flex: 1 0 0; min-width: 1px`
|
|
14
|
+
// item so it fills / shrinks responsively within that box.
|
|
15
|
+
const SUBPAGE_MIDDLE_DEFAULT_WIDTH = 192
|
|
16
|
+
const SUBPAGE_MIDDLE_HEIGHT = 32
|
|
17
|
+
const SUBPAGE_MIDDLE_PADDING_HORIZONTAL = 21
|
|
18
|
+
|
|
11
19
|
export type AppBarProps = {
|
|
12
20
|
/**
|
|
13
21
|
* Type of the App Bar.
|
|
@@ -26,8 +34,19 @@ export type AppBarProps = {
|
|
|
26
34
|
/**
|
|
27
35
|
* Slot for the middle content.
|
|
28
36
|
* Often used for "Page Title" in SubPage.
|
|
37
|
+
*
|
|
38
|
+
* On `SubPage` this is rendered as an absolutely-centered box (matching the
|
|
39
|
+
* Figma "slot wrap"): it stays centered in the bar regardless of how wide
|
|
40
|
+
* the leading/actions slots are, and its content fills/shrinks responsively
|
|
41
|
+
* within {@link middleSlotWidth}.
|
|
29
42
|
*/
|
|
30
43
|
middleSlot?: React.ReactNode;
|
|
44
|
+
/**
|
|
45
|
+
* Width of the centered `SubPage` middle slot, in px.
|
|
46
|
+
* Defaults to the Figma value (192). Has no effect on `MainPage`.
|
|
47
|
+
* @default 192
|
|
48
|
+
*/
|
|
49
|
+
middleSlotWidth?: number;
|
|
31
50
|
/**
|
|
32
51
|
* Slot for the actions on the right.
|
|
33
52
|
*/
|
|
@@ -52,6 +71,7 @@ export default function AppBar({
|
|
|
52
71
|
type = 'MainPage',
|
|
53
72
|
leadingSlot,
|
|
54
73
|
middleSlot,
|
|
74
|
+
middleSlotWidth = SUBPAGE_MIDDLE_DEFAULT_WIDTH,
|
|
55
75
|
actionsSlot,
|
|
56
76
|
modes: propModes = EMPTY_MODES,
|
|
57
77
|
onLeadingPress,
|
|
@@ -160,13 +180,50 @@ export default function AppBar({
|
|
|
160
180
|
? <View style={actionsStyle}>{cloneChildrenWithModes(React.Children.toArray(actionsSlot), modes)}</View>
|
|
161
181
|
: null
|
|
162
182
|
|
|
163
|
-
//
|
|
164
|
-
//
|
|
165
|
-
//
|
|
166
|
-
|
|
183
|
+
// SubPage centers its middle slot via absolute positioning (see Figma
|
|
184
|
+
// "slot wrap"), so it never participates in the row flow. Only MainPage
|
|
185
|
+
// keeps the legacy in-flow middle slot.
|
|
186
|
+
const hasInFlowMiddle = isMain && !!processedMiddle
|
|
187
|
+
|
|
188
|
+
// With an in-flow middle (MainPage) the middle (flex: 1) absorbs the
|
|
189
|
+
// remaining space, so leading & actions sit at the edges naturally. In all
|
|
190
|
+
// other cases we pin leading & actions to the outer edges with
|
|
191
|
+
// `space-between`; the SubPage middle floats above, centered.
|
|
167
192
|
const wrapperStyle: ViewStyle = {
|
|
168
193
|
...containerStyle,
|
|
169
|
-
justifyContent:
|
|
194
|
+
justifyContent: hasInFlowMiddle ? 'flex-start' : 'space-between',
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Absolutely-positioned overlay for the SubPage middle slot. Instead of
|
|
198
|
+
// centering a fixed-height box with `top/left: 50%` + transform (which on
|
|
199
|
+
// Android resolves the percentage against an intermediate, content-driven
|
|
200
|
+
// parent height and lands a few px too high), the overlay STRETCHES to fill
|
|
201
|
+
// the whole bar (`top/bottom/left/right: 0`) and centers its content with
|
|
202
|
+
// flexbox. This uses the exact same full-height vertical reference as the
|
|
203
|
+
// leading/actions row (`alignItems: 'center'`), so the middle content always
|
|
204
|
+
// sits on the same line as the back arrow and end slot on every platform.
|
|
205
|
+
const subPageMiddleOverlayStyle: ViewStyle = {
|
|
206
|
+
position: 'absolute',
|
|
207
|
+
top: 0,
|
|
208
|
+
left: 0,
|
|
209
|
+
right: 0,
|
|
210
|
+
bottom: 0,
|
|
211
|
+
flexDirection: 'row',
|
|
212
|
+
alignItems: 'center',
|
|
213
|
+
justifyContent: 'center',
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// Fixed-width clipping box (mirrors the Figma "slot wrap" geometry): keeps the
|
|
217
|
+
// middle content from bleeding under the leading/actions slots while staying
|
|
218
|
+
// centered within the overlay above.
|
|
219
|
+
const subPageMiddleBoxStyle: ViewStyle = {
|
|
220
|
+
width: middleSlotWidth,
|
|
221
|
+
height: SUBPAGE_MIDDLE_HEIGHT,
|
|
222
|
+
flexDirection: 'row',
|
|
223
|
+
alignItems: 'center',
|
|
224
|
+
justifyContent: 'center',
|
|
225
|
+
paddingHorizontal: SUBPAGE_MIDDLE_PADDING_HORIZONTAL,
|
|
226
|
+
overflow: 'hidden',
|
|
170
227
|
}
|
|
171
228
|
|
|
172
229
|
return (
|
|
@@ -183,14 +240,12 @@ export default function AppBar({
|
|
|
183
240
|
</View>
|
|
184
241
|
|
|
185
242
|
{/*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
* `minWidth: 0` is required so the flex item can shrink below its
|
|
191
|
-
* content's intrinsic width on platforms that respect it (web).
|
|
243
|
+
* MainPage in-flow middle — occupies the space between leading and
|
|
244
|
+
* actions (`flex: 1`) without overflowing. `minWidth: 0` lets the flex
|
|
245
|
+
* item shrink below its content's intrinsic width on platforms that
|
|
246
|
+
* respect it (web).
|
|
192
247
|
*/}
|
|
193
|
-
{
|
|
248
|
+
{hasInFlowMiddle && (
|
|
194
249
|
<View
|
|
195
250
|
style={{
|
|
196
251
|
flex: 1,
|
|
@@ -209,6 +264,31 @@ export default function AppBar({
|
|
|
209
264
|
<View style={actionsStyle}>
|
|
210
265
|
{processedActions}
|
|
211
266
|
</View>
|
|
267
|
+
|
|
268
|
+
{/*
|
|
269
|
+
* SubPage middle — absolutely centered "slot wrap". The inner wrapper is
|
|
270
|
+
* a responsive `flex: 1` item (matching Figma's `flex-[1_0_0] min-w-px`)
|
|
271
|
+
* so its content fills / shrinks within the fixed-width box.
|
|
272
|
+
*/}
|
|
273
|
+
{isSub && processedMiddle && (
|
|
274
|
+
<View style={subPageMiddleOverlayStyle} pointerEvents="box-none">
|
|
275
|
+
<View style={subPageMiddleBoxStyle} pointerEvents="box-none">
|
|
276
|
+
<View
|
|
277
|
+
style={{
|
|
278
|
+
flex: 1,
|
|
279
|
+
minWidth: 1,
|
|
280
|
+
height: '100%',
|
|
281
|
+
flexDirection: 'row',
|
|
282
|
+
alignItems: 'center',
|
|
283
|
+
justifyContent: 'center',
|
|
284
|
+
}}
|
|
285
|
+
pointerEvents="box-none"
|
|
286
|
+
>
|
|
287
|
+
{processedMiddle}
|
|
288
|
+
</View>
|
|
289
|
+
</View>
|
|
290
|
+
</View>
|
|
291
|
+
)}
|
|
212
292
|
</View>
|
|
213
293
|
)
|
|
214
294
|
}
|