jfs-components 0.1.2 → 0.1.12
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 +45 -0
- package/lib/commonjs/components/Accordion/Accordion.js +2 -1
- package/lib/commonjs/components/AccordionCheckbox/AccordionCheckbox.js +4 -3
- package/lib/commonjs/components/AccountCard/AccountCard.js +4 -3
- package/lib/commonjs/components/AllocationComparisonChart/AllocationComparisonChart.js +9 -6
- package/lib/commonjs/components/AmountInput/AmountInput.js +8 -5
- package/lib/commonjs/components/AreaLineChart/AreaLineChart.js +11 -7
- package/lib/commonjs/components/Badge/Badge.js +47 -8
- package/lib/commonjs/components/BenefitCard/BenefitCard.js +231 -0
- package/lib/commonjs/components/BrandChip/BrandChip.js +3 -3
- package/lib/commonjs/components/Button/Button.js +2 -1
- package/lib/commonjs/components/CardAdvisory/CardAdvisory.js +2 -1
- package/lib/commonjs/components/CardBankAccount/CardBankAccount.js +3 -2
- package/lib/commonjs/components/CardCTA/CardCTA.js +197 -27
- package/lib/commonjs/components/CardInsight/CardInsight.js +5 -1
- package/lib/commonjs/components/CcCard/CcCard.js +470 -0
- package/lib/commonjs/components/Checkbox/Checkbox.js +4 -3
- package/lib/commonjs/components/CheckboxItem/CheckboxItem.js +4 -3
- package/lib/commonjs/components/CircularProgressBar/CircularProgressBar.js +7 -3
- package/lib/commonjs/components/CircularProgressBarDoted/CircularProgressBarDoted.js +3 -2
- package/lib/commonjs/components/CircularRating/CircularRating.js +2 -1
- package/lib/commonjs/components/ClusterBubble/ClusterBubble.js +3 -2
- package/lib/commonjs/components/CompareTable/CompareTable.js +401 -0
- package/lib/commonjs/components/ComparisonBar/ComparisonBar.js +266 -0
- package/lib/commonjs/components/CoverageBarComparison/CoverageBarComparison.js +3 -2
- package/lib/commonjs/components/DonutChart/DonutChart.js +4 -3
- package/lib/commonjs/components/Dropdown/Dropdown.js +3 -2
- package/lib/commonjs/components/DropdownInput/DropdownInput.js +38 -5
- package/lib/commonjs/components/ExpandableCheckbox/ExpandableCheckbox.js +2 -1
- package/lib/commonjs/components/FormField/FormField.js +45 -4
- package/lib/commonjs/components/Gauge/Gauge.js +1 -1
- package/lib/commonjs/components/HoldingsCard/HoldingsCard.js +3 -2
- package/lib/commonjs/components/InputSearch/InputSearch.js +6 -4
- package/lib/commonjs/components/InstitutionBadge/InstitutionBadge.js +2 -1
- package/lib/commonjs/components/ListGroup/ListGroup.js +2 -1
- package/lib/commonjs/components/ListItem/ListItem.js +3 -2
- package/lib/commonjs/components/MediaCard/MediaCard.js +4 -2
- package/lib/commonjs/components/MetricLegendItem/MetricLegendItem.js +3 -2
- package/lib/commonjs/components/MonthlyStatusGrid/MonthlyStatusGrid.js +6 -3
- package/lib/commonjs/components/NoteInput/NoteInput.js +6 -5
- package/lib/commonjs/components/PdpCcCard/PdpCcCard.js +273 -0
- package/lib/commonjs/components/PoweredByLabel/PoweredByLabel.js +3 -2
- package/lib/commonjs/components/ProductMerchandisingCard/ProductMerchandisingCard.js +427 -0
- package/lib/commonjs/components/ProductOverview/ProductOverview.js +4 -3
- package/lib/commonjs/components/ProgressBadge/ProgressBadge.js +2 -2
- package/lib/commonjs/components/ProjectionMarker/ProjectionMarker.js +162 -0
- package/lib/commonjs/components/Radio/Radio.js +5 -5
- package/lib/commonjs/components/Section/Section.js +3 -2
- package/lib/commonjs/components/Slider/Slider.js +474 -0
- package/lib/commonjs/components/Stack/Stack.js +86 -0
- package/lib/commonjs/components/SuggestiveSearch/SuggestiveSearch.js +10 -1
- package/lib/commonjs/components/SummaryTile/SummaryTile.js +3 -2
- package/lib/commonjs/components/Table/Table.js +324 -0
- package/lib/commonjs/components/Text/Text.js +2 -1
- package/lib/commonjs/components/TextInput/TextInput.js +22 -9
- package/lib/commonjs/components/TextSegment/TextSegment.js +119 -0
- package/lib/commonjs/components/ThreadHero/ThreadHero.js +4 -5
- package/lib/commonjs/components/Title/Title.js +2 -1
- package/lib/commonjs/components/Toast/Toast.js +3 -2
- package/lib/commonjs/components/TransactionBubble/TransactionBubble.js +2 -1
- package/lib/commonjs/components/TransactionStatus/TransactionStatus.js +3 -2
- package/lib/commonjs/components/UpiHandle/UpiHandle.js +2 -2
- package/lib/commonjs/components/index.js +107 -0
- package/lib/commonjs/design-tokens/Coin Variables-variables-full.json +1 -1
- package/lib/commonjs/design-tokens/figma-modes.generated.js +39 -9
- package/lib/commonjs/icons/registry.js +1 -1
- package/lib/commonjs/utils/GlassFill/GlassFill.js +271 -0
- package/lib/commonjs/utils/GlassFill/GlassFill.web.js +120 -0
- package/lib/commonjs/utils/react-utils.js +78 -0
- package/lib/commonjs/utils/web-platform-utils.js +59 -0
- package/lib/module/components/Accordion/Accordion.js +3 -2
- package/lib/module/components/AccordionCheckbox/AccordionCheckbox.js +5 -4
- package/lib/module/components/AccountCard/AccountCard.js +5 -4
- package/lib/module/components/AllocationComparisonChart/AllocationComparisonChart.js +10 -7
- package/lib/module/components/AmountInput/AmountInput.js +6 -4
- package/lib/module/components/AreaLineChart/AreaLineChart.js +12 -8
- package/lib/module/components/Badge/Badge.js +49 -10
- package/lib/module/components/BenefitCard/BenefitCard.js +225 -0
- package/lib/module/components/BrandChip/BrandChip.js +4 -4
- package/lib/module/components/Button/Button.js +3 -2
- package/lib/module/components/CardAdvisory/CardAdvisory.js +3 -2
- package/lib/module/components/CardBankAccount/CardBankAccount.js +4 -3
- package/lib/module/components/CardCTA/CardCTA.js +198 -28
- package/lib/module/components/CardInsight/CardInsight.js +5 -1
- package/lib/module/components/CcCard/CcCard.js +464 -0
- package/lib/module/components/Checkbox/Checkbox.js +5 -4
- package/lib/module/components/CheckboxItem/CheckboxItem.js +5 -4
- package/lib/module/components/CircularProgressBar/CircularProgressBar.js +8 -4
- package/lib/module/components/CircularProgressBarDoted/CircularProgressBarDoted.js +4 -3
- package/lib/module/components/CircularRating/CircularRating.js +3 -2
- package/lib/module/components/ClusterBubble/ClusterBubble.js +4 -3
- package/lib/module/components/CompareTable/CompareTable.js +396 -0
- package/lib/module/components/ComparisonBar/ComparisonBar.js +260 -0
- package/lib/module/components/CoverageBarComparison/CoverageBarComparison.js +4 -3
- package/lib/module/components/DonutChart/DonutChart.js +5 -4
- package/lib/module/components/Dropdown/Dropdown.js +4 -3
- package/lib/module/components/DropdownInput/DropdownInput.js +40 -7
- package/lib/module/components/ExpandableCheckbox/ExpandableCheckbox.js +2 -1
- package/lib/module/components/FormField/FormField.js +48 -7
- package/lib/module/components/Gauge/Gauge.js +1 -1
- package/lib/module/components/HoldingsCard/HoldingsCard.js +4 -3
- package/lib/module/components/InputSearch/InputSearch.js +6 -4
- package/lib/module/components/InstitutionBadge/InstitutionBadge.js +3 -2
- package/lib/module/components/ListGroup/ListGroup.js +3 -2
- package/lib/module/components/ListItem/ListItem.js +4 -3
- package/lib/module/components/MediaCard/MediaCard.js +4 -2
- package/lib/module/components/MetricLegendItem/MetricLegendItem.js +4 -3
- package/lib/module/components/MonthlyStatusGrid/MonthlyStatusGrid.js +7 -4
- package/lib/module/components/NoteInput/NoteInput.js +7 -6
- package/lib/module/components/PdpCcCard/PdpCcCard.js +267 -0
- package/lib/module/components/PoweredByLabel/PoweredByLabel.js +4 -3
- package/lib/module/components/ProductMerchandisingCard/ProductMerchandisingCard.js +421 -0
- package/lib/module/components/ProductOverview/ProductOverview.js +5 -4
- package/lib/module/components/ProgressBadge/ProgressBadge.js +3 -3
- package/lib/module/components/ProjectionMarker/ProjectionMarker.js +157 -0
- package/lib/module/components/Radio/Radio.js +5 -4
- package/lib/module/components/Section/Section.js +4 -3
- package/lib/module/components/Slider/Slider.js +469 -0
- package/lib/module/components/Stack/Stack.js +81 -0
- package/lib/module/components/SuggestiveSearch/SuggestiveSearch.js +10 -1
- package/lib/module/components/SummaryTile/SummaryTile.js +4 -3
- package/lib/module/components/Table/Table.js +315 -0
- package/lib/module/components/Text/Text.js +3 -2
- package/lib/module/components/TextInput/TextInput.js +24 -11
- package/lib/module/components/TextSegment/TextSegment.js +114 -0
- package/lib/module/components/ThreadHero/ThreadHero.js +5 -6
- package/lib/module/components/Title/Title.js +3 -2
- package/lib/module/components/Toast/Toast.js +4 -3
- package/lib/module/components/TransactionBubble/TransactionBubble.js +3 -2
- package/lib/module/components/TransactionStatus/TransactionStatus.js +4 -3
- package/lib/module/components/UpiHandle/UpiHandle.js +3 -3
- package/lib/module/components/index.js +11 -0
- package/lib/module/design-tokens/Coin Variables-variables-full.json +1 -1
- package/lib/module/design-tokens/figma-modes.generated.js +39 -9
- package/lib/module/icons/registry.js +1 -1
- package/lib/module/utils/GlassFill/GlassFill.js +265 -0
- package/lib/module/utils/GlassFill/GlassFill.web.js +115 -0
- package/lib/module/utils/react-utils.js +75 -0
- package/lib/module/utils/web-platform-utils.js +58 -0
- package/lib/typescript/src/components/Accordion/Accordion.d.ts +7 -1
- package/lib/typescript/src/components/AccordionCheckbox/AccordionCheckbox.d.ts +7 -1
- package/lib/typescript/src/components/AccountCard/AccountCard.d.ts +7 -1
- package/lib/typescript/src/components/AllocationComparisonChart/AllocationComparisonChart.d.ts +7 -1
- package/lib/typescript/src/components/AmountInput/AmountInput.d.ts +3 -2
- package/lib/typescript/src/components/AreaLineChart/AreaLineChart.d.ts +8 -1
- package/lib/typescript/src/components/Badge/Badge.d.ts +32 -2
- package/lib/typescript/src/components/BenefitCard/BenefitCard.d.ts +93 -0
- package/lib/typescript/src/components/BrandChip/BrandChip.d.ts +7 -1
- package/lib/typescript/src/components/Button/Button.d.ts +7 -1
- package/lib/typescript/src/components/CardAdvisory/CardAdvisory.d.ts +7 -1
- package/lib/typescript/src/components/CardBankAccount/CardBankAccount.d.ts +7 -1
- package/lib/typescript/src/components/CardCTA/CardCTA.d.ts +27 -5
- package/lib/typescript/src/components/CcCard/CcCard.d.ts +137 -0
- package/lib/typescript/src/components/Checkbox/Checkbox.d.ts +3 -2
- package/lib/typescript/src/components/CheckboxItem/CheckboxItem.d.ts +2 -2
- package/lib/typescript/src/components/CircularProgressBar/CircularProgressBar.d.ts +7 -1
- package/lib/typescript/src/components/CircularProgressBarDoted/CircularProgressBarDoted.d.ts +7 -1
- package/lib/typescript/src/components/CircularRating/CircularRating.d.ts +7 -1
- package/lib/typescript/src/components/ClusterBubble/ClusterBubble.d.ts +7 -1
- package/lib/typescript/src/components/CompareTable/CompareTable.d.ts +94 -0
- package/lib/typescript/src/components/ComparisonBar/ComparisonBar.d.ts +118 -0
- package/lib/typescript/src/components/CoverageBarComparison/CoverageBarComparison.d.ts +7 -1
- package/lib/typescript/src/components/DonutChart/DonutChart.d.ts +7 -1
- package/lib/typescript/src/components/Dropdown/Dropdown.d.ts +7 -1
- package/lib/typescript/src/components/DropdownInput/DropdownInput.d.ts +26 -1
- package/lib/typescript/src/components/ExpandableCheckbox/ExpandableCheckbox.d.ts +7 -1
- package/lib/typescript/src/components/FormField/FormField.d.ts +2 -2
- package/lib/typescript/src/components/HoldingsCard/HoldingsCard.d.ts +7 -1
- package/lib/typescript/src/components/InputSearch/InputSearch.d.ts +23 -2
- package/lib/typescript/src/components/InstitutionBadge/InstitutionBadge.d.ts +7 -1
- package/lib/typescript/src/components/ListGroup/ListGroup.d.ts +7 -1
- package/lib/typescript/src/components/ListItem/ListItem.d.ts +7 -1
- package/lib/typescript/src/components/MetricLegendItem/MetricLegendItem.d.ts +7 -1
- package/lib/typescript/src/components/MonthlyStatusGrid/MonthlyStatusGrid.d.ts +14 -2
- package/lib/typescript/src/components/NoteInput/NoteInput.d.ts +19 -2
- package/lib/typescript/src/components/PdpCcCard/PdpCcCard.d.ts +84 -0
- package/lib/typescript/src/components/PoweredByLabel/PoweredByLabel.d.ts +7 -1
- package/lib/typescript/src/components/ProductMerchandisingCard/ProductMerchandisingCard.d.ts +87 -0
- package/lib/typescript/src/components/ProductOverview/ProductOverview.d.ts +7 -1
- package/lib/typescript/src/components/ProgressBadge/ProgressBadge.d.ts +7 -1
- package/lib/typescript/src/components/ProjectionMarker/ProjectionMarker.d.ts +88 -0
- package/lib/typescript/src/components/Radio/Radio.d.ts +3 -2
- package/lib/typescript/src/components/RadioButton/RadioButton.d.ts +2 -2
- package/lib/typescript/src/components/Section/Section.d.ts +7 -1
- package/lib/typescript/src/components/Slider/Slider.d.ts +105 -0
- package/lib/typescript/src/components/Stack/Stack.d.ts +81 -0
- package/lib/typescript/src/components/SummaryTile/SummaryTile.d.ts +7 -1
- package/lib/typescript/src/components/Table/Table.d.ts +139 -0
- package/lib/typescript/src/components/Text/Text.d.ts +7 -1
- package/lib/typescript/src/components/TextInput/TextInput.d.ts +9 -29
- package/lib/typescript/src/components/TextSegment/TextSegment.d.ts +106 -0
- package/lib/typescript/src/components/ThreadHero/ThreadHero.d.ts +7 -1
- package/lib/typescript/src/components/Title/Title.d.ts +7 -1
- package/lib/typescript/src/components/Toast/Toast.d.ts +7 -1
- package/lib/typescript/src/components/TransactionBubble/TransactionBubble.d.ts +7 -1
- package/lib/typescript/src/components/TransactionStatus/TransactionStatus.d.ts +7 -1
- package/lib/typescript/src/components/UpiHandle/UpiHandle.d.ts +7 -1
- package/lib/typescript/src/components/index.d.ts +14 -3
- package/lib/typescript/src/design-tokens/figma-modes.generated.d.ts +22 -2
- package/lib/typescript/src/icons/registry.d.ts +1 -1
- package/lib/typescript/src/utils/GlassFill/GlassFill.d.ts +84 -0
- package/lib/typescript/src/utils/GlassFill/GlassFill.web.d.ts +43 -0
- package/lib/typescript/src/utils/react-utils.d.ts +47 -0
- package/lib/typescript/src/utils/web-platform-utils.d.ts +36 -0
- package/package.json +2 -1
- package/src/components/Accordion/Accordion.tsx +9 -2
- package/src/components/AccordionCheckbox/AccordionCheckbox.tsx +10 -3
- package/src/components/AccountCard/AccountCard.tsx +10 -3
- package/src/components/AllocationComparisonChart/AllocationComparisonChart.tsx +14 -4
- package/src/components/AmountInput/AmountInput.tsx +7 -5
- package/src/components/AreaLineChart/AreaLineChart.tsx +15 -5
- package/src/components/Badge/Badge.tsx +78 -8
- package/src/components/BenefitCard/BenefitCard.tsx +309 -0
- package/src/components/BrandChip/BrandChip.tsx +9 -3
- package/src/components/Button/Button.tsx +9 -2
- package/src/components/CardAdvisory/CardAdvisory.tsx +9 -2
- package/src/components/CardBankAccount/CardBankAccount.tsx +9 -2
- package/src/components/CardCTA/CardCTA.tsx +214 -41
- package/src/components/CardInsight/CardInsight.tsx +7 -1
- package/src/components/CcCard/CcCard.tsx +598 -0
- package/src/components/Checkbox/Checkbox.tsx +5 -4
- package/src/components/CheckboxItem/CheckboxItem.tsx +5 -4
- package/src/components/CircularProgressBar/CircularProgressBar.tsx +14 -4
- package/src/components/CircularProgressBarDoted/CircularProgressBarDoted.tsx +10 -3
- package/src/components/CircularRating/CircularRating.tsx +9 -2
- package/src/components/ClusterBubble/ClusterBubble.tsx +9 -2
- package/src/components/CompareTable/CompareTable.tsx +525 -0
- package/src/components/ComparisonBar/ComparisonBar.tsx +356 -0
- package/src/components/CoverageBarComparison/CoverageBarComparison.tsx +9 -2
- package/src/components/DonutChart/DonutChart.tsx +10 -3
- package/src/components/Dropdown/Dropdown.tsx +9 -2
- package/src/components/DropdownInput/DropdownInput.tsx +64 -5
- package/src/components/ExpandableCheckbox/ExpandableCheckbox.tsx +8 -1
- package/src/components/FormField/FormField.tsx +52 -6
- package/src/components/Gauge/Gauge.tsx +1 -1
- package/src/components/HoldingsCard/HoldingsCard.tsx +9 -2
- package/src/components/InputSearch/InputSearch.tsx +8 -5
- package/src/components/InstitutionBadge/InstitutionBadge.tsx +9 -2
- package/src/components/ListGroup/ListGroup.tsx +9 -2
- package/src/components/ListItem/ListItem.tsx +10 -3
- package/src/components/MediaCard/MediaCard.tsx +2 -2
- package/src/components/MetricLegendItem/MetricLegendItem.tsx +9 -2
- package/src/components/MonthlyStatusGrid/MonthlyStatusGrid.tsx +17 -2
- package/src/components/NoteInput/NoteInput.tsx +8 -6
- package/src/components/PdpCcCard/PdpCcCard.tsx +356 -0
- package/src/components/PoweredByLabel/PoweredByLabel.tsx +9 -2
- package/src/components/ProductMerchandisingCard/ProductMerchandisingCard.tsx +490 -0
- package/src/components/ProductOverview/ProductOverview.tsx +10 -3
- package/src/components/ProgressBadge/ProgressBadge.tsx +9 -3
- package/src/components/ProjectionMarker/ProjectionMarker.tsx +284 -0
- package/src/components/Radio/Radio.tsx +5 -4
- package/src/components/Section/Section.tsx +10 -3
- package/src/components/Slider/Slider.tsx +635 -0
- package/src/components/Stack/Stack.tsx +131 -0
- package/src/components/SuggestiveSearch/SuggestiveSearch.tsx +10 -1
- package/src/components/SummaryTile/SummaryTile.tsx +9 -2
- package/src/components/Table/Table.tsx +449 -0
- package/src/components/Text/Text.tsx +9 -2
- package/src/components/TextInput/TextInput.tsx +22 -12
- package/src/components/TextSegment/TextSegment.tsx +173 -0
- package/src/components/ThreadHero/ThreadHero.tsx +10 -3
- package/src/components/Title/Title.tsx +9 -2
- package/src/components/Toast/Toast.tsx +9 -2
- package/src/components/TransactionBubble/TransactionBubble.tsx +9 -2
- package/src/components/TransactionStatus/TransactionStatus.tsx +9 -2
- package/src/components/UpiHandle/UpiHandle.tsx +9 -3
- package/src/components/index.ts +33 -3
- package/src/design-tokens/Coin Variables-variables-full.json +1 -1
- package/src/design-tokens/figma-modes.generated.ts +39 -9
- package/src/icons/registry.ts +1 -1
- package/src/utils/GlassFill/GlassFill.tsx +305 -0
- package/src/utils/GlassFill/GlassFill.web.tsx +148 -0
- package/src/utils/react-utils.ts +84 -0
- package/src/utils/web-platform-utils.ts +68 -0
- package/lib/commonjs/components/MediaCard/GlassFill.js +0 -62
- package/lib/commonjs/components/MediaCard/GlassFill.web.js +0 -48
- package/lib/module/components/MediaCard/GlassFill.js +0 -57
- package/lib/module/components/MediaCard/GlassFill.web.js +0 -43
- package/lib/typescript/scripts/extract-component-tokens.d.ts +0 -9
- package/lib/typescript/scripts/generate-component-docs.d.ts +0 -9
- package/lib/typescript/scripts/generate-icon-registry.d.ts +0 -3
- package/lib/typescript/scripts/generate-mode-types.d.ts +0 -2
- package/lib/typescript/scripts/retype-modes.d.cts +0 -2
- package/lib/typescript/src/components/MediaCard/GlassFill.d.ts +0 -47
- package/lib/typescript/src/components/MediaCard/GlassFill.web.d.ts +0 -20
- package/src/components/MediaCard/GlassFill.tsx +0 -89
- package/src/components/MediaCard/GlassFill.web.tsx +0 -53
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { View, Text, Pressable, ScrollView, Platform } from 'react-native';
|
|
5
|
+
import { getVariableByName } from '../../design-tokens/figma-variables-resolver';
|
|
6
|
+
import { EMPTY_MODES, cloneChildrenWithModes } from '../../utils/react-utils';
|
|
7
|
+
|
|
8
|
+
/* -------------------------------------------------------------------------------------------------
|
|
9
|
+
* Shared types & token resolution
|
|
10
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
11
|
+
|
|
12
|
+
/** Resolved styling for a header cell and a body cell, derived from design tokens. */
|
|
13
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
const toWeight = w => typeof w === 'number' ? `${w}` : w;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Resolve every token the table family needs in one place. Sub-components call
|
|
18
|
+
* this with their cascaded `modes` so they render correctly both inside a
|
|
19
|
+
* `Table` and when used standalone. Fallbacks mirror the Figma node values
|
|
20
|
+
* (`tableCell/*`, `tableHeader/*`) so the component is faithful even before the
|
|
21
|
+
* tokens are published to the local store.
|
|
22
|
+
*/
|
|
23
|
+
function resolveTableTokens(modes) {
|
|
24
|
+
const headerFontFamily = getVariableByName('tableHeader/label/fontfamily', modes) ?? 'JioType Var';
|
|
25
|
+
const headerFontSize = getVariableByName('tableHeader/label/fontsize', modes) ?? 14;
|
|
26
|
+
const headerFontWeight = getVariableByName('tableHeader/label/fontweight', modes) ?? 600;
|
|
27
|
+
const cellFontFamily = getVariableByName('tableCell/label/fontfamily', modes) ?? 'JioType Var';
|
|
28
|
+
const cellFontSize = getVariableByName('tableCell/label/fontsize', modes) ?? 14;
|
|
29
|
+
const cellFontWeight = getVariableByName('tableCell/label/fontweight', modes) ?? 400;
|
|
30
|
+
return {
|
|
31
|
+
headerBg: getVariableByName('tableHeader/background/color', modes) ?? '#f5f5f5',
|
|
32
|
+
headerPaddingH: getVariableByName('tableHeader/padding/horizontal', modes) ?? 12,
|
|
33
|
+
headerPaddingV: getVariableByName('tableHeader/padding/vertical', modes) ?? 12,
|
|
34
|
+
headerText: {
|
|
35
|
+
color: getVariableByName('tableHeader/label/color', modes) ?? '#000000',
|
|
36
|
+
fontFamily: headerFontFamily,
|
|
37
|
+
fontSize: headerFontSize,
|
|
38
|
+
fontWeight: toWeight(headerFontWeight),
|
|
39
|
+
lineHeight: 20
|
|
40
|
+
},
|
|
41
|
+
cellBg: getVariableByName('tableCell/background/color', modes) ?? '#ffffff',
|
|
42
|
+
cellPaddingH: getVariableByName('tableCell/padding/horizontal', modes) ?? 12,
|
|
43
|
+
cellPaddingV: getVariableByName('tableCell/padding/vertical', modes) ?? 12,
|
|
44
|
+
cellText: {
|
|
45
|
+
color: getVariableByName('tableCell/label/color', modes) ?? '#000000',
|
|
46
|
+
fontFamily: cellFontFamily,
|
|
47
|
+
fontSize: cellFontSize,
|
|
48
|
+
fontWeight: toWeight(cellFontWeight),
|
|
49
|
+
lineHeight: 20
|
|
50
|
+
},
|
|
51
|
+
borderColor: getVariableByName('tableCell/border/color', modes) ?? '#eeeeee',
|
|
52
|
+
borderSize: getVariableByName('tableCell/border/size', modes) ?? 1
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
const alignToJustify = align => align === 'center' ? 'center' : align === 'right' ? 'flex-end' : 'flex-start';
|
|
56
|
+
|
|
57
|
+
/** Renders text children through the resolved label style; passes elements through untouched. */
|
|
58
|
+
function renderCellContent(children, textStyle, align, modes) {
|
|
59
|
+
if (children == null || children === false) return null;
|
|
60
|
+
if (typeof children === 'string' || typeof children === 'number') {
|
|
61
|
+
return /*#__PURE__*/_jsx(Text, {
|
|
62
|
+
style: [textStyle, {
|
|
63
|
+
textAlign: align
|
|
64
|
+
}],
|
|
65
|
+
children: children
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return cloneChildrenWithModes(children, modes);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/* -------------------------------------------------------------------------------------------------
|
|
72
|
+
* Table.Cell — body cell (Figma `table-cell`, node 603:23)
|
|
73
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* A single body cell. White background with a bottom + right divider, matching
|
|
77
|
+
* the Figma `table-cell` sub-component. String/number children are rendered
|
|
78
|
+
* with the token label style; any element is rendered as-is.
|
|
79
|
+
*/
|
|
80
|
+
function TableCell({
|
|
81
|
+
children,
|
|
82
|
+
align = 'left',
|
|
83
|
+
width,
|
|
84
|
+
flex = 1,
|
|
85
|
+
isLastColumn = false,
|
|
86
|
+
isLastRow = false,
|
|
87
|
+
modes = EMPTY_MODES,
|
|
88
|
+
style
|
|
89
|
+
}) {
|
|
90
|
+
const t = resolveTableTokens(modes);
|
|
91
|
+
return /*#__PURE__*/_jsx(View, {
|
|
92
|
+
style: [{
|
|
93
|
+
backgroundColor: t.cellBg,
|
|
94
|
+
flexDirection: 'row',
|
|
95
|
+
alignItems: 'center',
|
|
96
|
+
justifyContent: alignToJustify(align),
|
|
97
|
+
paddingHorizontal: t.cellPaddingH,
|
|
98
|
+
paddingVertical: t.cellPaddingV,
|
|
99
|
+
borderColor: t.borderColor,
|
|
100
|
+
borderBottomWidth: isLastRow ? 0 : t.borderSize,
|
|
101
|
+
borderRightWidth: isLastColumn ? 0 : t.borderSize,
|
|
102
|
+
...(width != null ? {
|
|
103
|
+
width
|
|
104
|
+
} : {
|
|
105
|
+
flex,
|
|
106
|
+
minWidth: 0
|
|
107
|
+
})
|
|
108
|
+
}, style],
|
|
109
|
+
children: renderCellContent(children, t.cellText, align, modes)
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/* -------------------------------------------------------------------------------------------------
|
|
114
|
+
* Table.HeaderCell — header cell (Figma `table header wrap`, node 603:21)
|
|
115
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* A single header cell. Muted background with the bold token label style,
|
|
119
|
+
* matching the Figma `table header wrap` sub-component. Header cells carry no
|
|
120
|
+
* dividers; the header row draws a single bottom divider beneath them.
|
|
121
|
+
*/
|
|
122
|
+
function TableHeaderCell({
|
|
123
|
+
children,
|
|
124
|
+
align = 'left',
|
|
125
|
+
width,
|
|
126
|
+
flex = 1,
|
|
127
|
+
modes = EMPTY_MODES,
|
|
128
|
+
style
|
|
129
|
+
}) {
|
|
130
|
+
const t = resolveTableTokens(modes);
|
|
131
|
+
return /*#__PURE__*/_jsx(View, {
|
|
132
|
+
style: [{
|
|
133
|
+
backgroundColor: t.headerBg,
|
|
134
|
+
flexDirection: 'row',
|
|
135
|
+
alignItems: 'center',
|
|
136
|
+
justifyContent: alignToJustify(align),
|
|
137
|
+
paddingHorizontal: t.headerPaddingH,
|
|
138
|
+
paddingVertical: t.headerPaddingV,
|
|
139
|
+
...(width != null ? {
|
|
140
|
+
width
|
|
141
|
+
} : {
|
|
142
|
+
flex,
|
|
143
|
+
minWidth: 0
|
|
144
|
+
})
|
|
145
|
+
}, style],
|
|
146
|
+
children: renderCellContent(children, t.headerText, align, modes)
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/* -------------------------------------------------------------------------------------------------
|
|
151
|
+
* Table.Header — row of header cells with a bottom divider
|
|
152
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
153
|
+
|
|
154
|
+
function TableHeader({
|
|
155
|
+
children,
|
|
156
|
+
modes = EMPTY_MODES,
|
|
157
|
+
style
|
|
158
|
+
}) {
|
|
159
|
+
const t = resolveTableTokens(modes);
|
|
160
|
+
return /*#__PURE__*/_jsx(View, {
|
|
161
|
+
style: [{
|
|
162
|
+
flexDirection: 'row',
|
|
163
|
+
width: '100%',
|
|
164
|
+
borderBottomWidth: t.borderSize,
|
|
165
|
+
borderBottomColor: t.borderColor
|
|
166
|
+
}, style],
|
|
167
|
+
children: cloneChildrenWithModes(children, modes)
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/* -------------------------------------------------------------------------------------------------
|
|
172
|
+
* Table.Row — row of body cells
|
|
173
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
174
|
+
|
|
175
|
+
function TableRow({
|
|
176
|
+
children,
|
|
177
|
+
onPress,
|
|
178
|
+
modes = EMPTY_MODES,
|
|
179
|
+
style
|
|
180
|
+
}) {
|
|
181
|
+
const rowStyle = {
|
|
182
|
+
flexDirection: 'row',
|
|
183
|
+
width: '100%'
|
|
184
|
+
};
|
|
185
|
+
const content = cloneChildrenWithModes(children, modes);
|
|
186
|
+
if (onPress) {
|
|
187
|
+
return /*#__PURE__*/_jsx(Pressable, {
|
|
188
|
+
onPress: onPress,
|
|
189
|
+
accessibilityRole: "button",
|
|
190
|
+
style: ({
|
|
191
|
+
pressed
|
|
192
|
+
}) => [rowStyle, pressed ? {
|
|
193
|
+
opacity: 0.6
|
|
194
|
+
} : null, style],
|
|
195
|
+
children: content
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
return /*#__PURE__*/_jsx(View, {
|
|
199
|
+
style: [rowStyle, style],
|
|
200
|
+
children: content
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/* -------------------------------------------------------------------------------------------------
|
|
205
|
+
* Table.Body — column container for rows
|
|
206
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
207
|
+
|
|
208
|
+
function TableBody({
|
|
209
|
+
children,
|
|
210
|
+
modes = EMPTY_MODES,
|
|
211
|
+
style
|
|
212
|
+
}) {
|
|
213
|
+
return /*#__PURE__*/_jsx(View, {
|
|
214
|
+
style: [{
|
|
215
|
+
width: '100%'
|
|
216
|
+
}, style],
|
|
217
|
+
children: cloneChildrenWithModes(children, modes)
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/* -------------------------------------------------------------------------------------------------
|
|
222
|
+
* Table — root (Figma `Table`, node 5732:3710)
|
|
223
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Column definition for the data-driven `Table` API. `T` is the shape of one
|
|
227
|
+
* row record.
|
|
228
|
+
*/
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Table renders structured rows and columns. It supports two complementary
|
|
232
|
+
* usage styles that share the same token-driven styling:
|
|
233
|
+
*
|
|
234
|
+
* 1. **Data-driven** (recommended): pass `columns` + `data`. The header and body
|
|
235
|
+
* are built for you, columns stay aligned, and per-column `align`/`width`/
|
|
236
|
+
* `flex`/`render` give full control.
|
|
237
|
+
*
|
|
238
|
+
* 2. **Composition**: pass `Table.Header` / `Table.Body` / `Table.Row` /
|
|
239
|
+
* `Table.Cell` / `Table.HeaderCell` as children for bespoke layouts. These
|
|
240
|
+
* sub-components are also exported standalone.
|
|
241
|
+
*
|
|
242
|
+
* Implementation of Figma node `5732:3710` (`Table`) with sub-components
|
|
243
|
+
* `603:23` (`table-cell`) and `603:21` (`table header wrap`).
|
|
244
|
+
*
|
|
245
|
+
* @component
|
|
246
|
+
*/
|
|
247
|
+
function Table({
|
|
248
|
+
columns,
|
|
249
|
+
data,
|
|
250
|
+
children,
|
|
251
|
+
showHeader = true,
|
|
252
|
+
getRowKey,
|
|
253
|
+
onRowPress,
|
|
254
|
+
scrollable = false,
|
|
255
|
+
accessibilityLabel,
|
|
256
|
+
modes = EMPTY_MODES,
|
|
257
|
+
style
|
|
258
|
+
}) {
|
|
259
|
+
const isComposition = children != null;
|
|
260
|
+
const body = isComposition ? cloneChildrenWithModes(children, modes) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
261
|
+
children: [showHeader && columns && columns.length > 0 && /*#__PURE__*/_jsx(TableHeader, {
|
|
262
|
+
modes: modes,
|
|
263
|
+
children: columns.map(col => /*#__PURE__*/_jsx(TableHeaderCell, {
|
|
264
|
+
align: col.headerAlign ?? col.align ?? 'left',
|
|
265
|
+
width: col.width,
|
|
266
|
+
flex: col.flex ?? 1,
|
|
267
|
+
modes: modes,
|
|
268
|
+
children: col.header ?? col.key
|
|
269
|
+
}, col.key))
|
|
270
|
+
}), columns && data && data.length > 0 && /*#__PURE__*/_jsx(TableBody, {
|
|
271
|
+
modes: modes,
|
|
272
|
+
children: data.map((row, rowIndex) => {
|
|
273
|
+
const isLastRow = rowIndex === data.length - 1;
|
|
274
|
+
return /*#__PURE__*/_jsx(TableRow, {
|
|
275
|
+
onPress: onRowPress ? () => onRowPress(row, rowIndex) : undefined,
|
|
276
|
+
modes: modes,
|
|
277
|
+
children: columns.map((col, colIndex) => /*#__PURE__*/_jsx(TableCell, {
|
|
278
|
+
align: col.align ?? 'left',
|
|
279
|
+
width: col.width,
|
|
280
|
+
flex: col.flex ?? 1,
|
|
281
|
+
isLastColumn: colIndex === columns.length - 1,
|
|
282
|
+
isLastRow: isLastRow,
|
|
283
|
+
modes: modes,
|
|
284
|
+
children: col.render ? col.render(row, rowIndex) : row[col.key]
|
|
285
|
+
}, col.key))
|
|
286
|
+
}, getRowKey?.(row, rowIndex) ?? rowIndex);
|
|
287
|
+
})
|
|
288
|
+
})]
|
|
289
|
+
});
|
|
290
|
+
const container = /*#__PURE__*/_jsx(View, {
|
|
291
|
+
accessibilityRole: Platform.OS === 'web' ? 'table' : undefined,
|
|
292
|
+
accessibilityLabel: accessibilityLabel,
|
|
293
|
+
style: [{
|
|
294
|
+
overflow: 'hidden'
|
|
295
|
+
}, !scrollable && {
|
|
296
|
+
width: '100%'
|
|
297
|
+
}, style],
|
|
298
|
+
children: body
|
|
299
|
+
});
|
|
300
|
+
if (scrollable) {
|
|
301
|
+
return /*#__PURE__*/_jsx(ScrollView, {
|
|
302
|
+
horizontal: true,
|
|
303
|
+
showsHorizontalScrollIndicator: false,
|
|
304
|
+
children: container
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
return container;
|
|
308
|
+
}
|
|
309
|
+
Table.Header = TableHeader;
|
|
310
|
+
Table.HeaderCell = TableHeaderCell;
|
|
311
|
+
Table.Body = TableBody;
|
|
312
|
+
Table.Row = TableRow;
|
|
313
|
+
Table.Cell = TableCell;
|
|
314
|
+
export { TableHeader, TableHeaderCell, TableBody, TableRow, TableCell };
|
|
315
|
+
export default Table;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { Text as RNText } from 'react-native';
|
|
5
5
|
import { getVariableByName } from '../../design-tokens/figma-variables-resolver';
|
|
6
|
-
import { EMPTY_MODES } from '../../utils/react-utils';
|
|
6
|
+
import { EMPTY_MODES, resolveTruncation } from '../../utils/react-utils';
|
|
7
7
|
import Skeleton from '../../skeleton/Skeleton';
|
|
8
8
|
import { useSkeleton } from '../../skeleton/SkeletonGroup';
|
|
9
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -18,6 +18,7 @@ function Text({
|
|
|
18
18
|
modes = EMPTY_MODES,
|
|
19
19
|
style,
|
|
20
20
|
numberOfLines,
|
|
21
|
+
disableTruncation,
|
|
21
22
|
loading,
|
|
22
23
|
skeletonWidth,
|
|
23
24
|
skeletonLines
|
|
@@ -70,7 +71,7 @@ function Text({
|
|
|
70
71
|
const content = children !== undefined && children !== null && children !== false ? children : text !== undefined ? text : 'Korem ipsum ';
|
|
71
72
|
return /*#__PURE__*/_jsx(RNText, {
|
|
72
73
|
style: [textStyle, style],
|
|
73
|
-
|
|
74
|
+
...resolveTruncation(disableTruncation, numberOfLines),
|
|
74
75
|
children: content
|
|
75
76
|
});
|
|
76
77
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import React, { useRef, useState } from 'react';
|
|
3
|
+
import React, { forwardRef, useRef, useState } from 'react';
|
|
4
4
|
import { Platform, Pressable, View, TextInput as RNTextInput } from 'react-native';
|
|
5
5
|
import { getVariableByName } from '../../design-tokens/figma-variables-resolver';
|
|
6
6
|
import Icon from '../../icons/Icon';
|
|
7
|
-
import { EMPTY_MODES, cloneChildrenWithModes } from '../../utils/react-utils';
|
|
7
|
+
import { EMPTY_MODES, cloneChildrenWithModes, mergeRefs } from '../../utils/react-utils';
|
|
8
8
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
9
|
/**
|
|
10
10
|
* TextInput component that mirrors the Figma "textInput" component.
|
|
@@ -95,7 +95,7 @@ function makePlaceholderColor(color, opacity = 0.5) {
|
|
|
95
95
|
// Fallback: return original color
|
|
96
96
|
return color;
|
|
97
97
|
}
|
|
98
|
-
function TextInput({
|
|
98
|
+
const TextInputBase = /*#__PURE__*/forwardRef(function TextInput({
|
|
99
99
|
placeholder = '',
|
|
100
100
|
value = '',
|
|
101
101
|
onChangeText,
|
|
@@ -110,7 +110,7 @@ function TextInput({
|
|
|
110
110
|
accessibilityLabel,
|
|
111
111
|
accessibilityHint,
|
|
112
112
|
...rest
|
|
113
|
-
}) {
|
|
113
|
+
}, ref) {
|
|
114
114
|
// Track focus state to hide placeholder when focused
|
|
115
115
|
const [isFocused, setIsFocused] = useState(false);
|
|
116
116
|
const [isHovered, setIsHovered] = useState(false);
|
|
@@ -166,7 +166,15 @@ function TextInput({
|
|
|
166
166
|
flex: 1,
|
|
167
167
|
color: textColor,
|
|
168
168
|
fontSize,
|
|
169
|
-
lineHeight
|
|
169
|
+
// iOS-only quirk: a single-line RNTextInput with an explicit `lineHeight`
|
|
170
|
+
// larger than `fontSize` puts all the extra space ABOVE the glyphs, so the
|
|
171
|
+
// text/placeholder sits below center (iOS native font-metrics bug — see
|
|
172
|
+
// facebook/react-native#39145 / #28012). The container centers via
|
|
173
|
+
// `alignItems: 'center'` + `minHeight`, so omit lineHeight on iOS
|
|
174
|
+
// (UITextField centers natively) and keep it on Android/Web where it's fine.
|
|
175
|
+
...(Platform.OS === 'ios' ? null : {
|
|
176
|
+
lineHeight
|
|
177
|
+
}),
|
|
170
178
|
fontFamily,
|
|
171
179
|
fontWeight,
|
|
172
180
|
padding: 0,
|
|
@@ -225,7 +233,7 @@ function TextInput({
|
|
|
225
233
|
importantForAccessibility: "no",
|
|
226
234
|
children: processedLeading
|
|
227
235
|
}), /*#__PURE__*/_jsx(RNTextInput, {
|
|
228
|
-
ref: inputRef,
|
|
236
|
+
ref: mergeRefs(inputRef, ref),
|
|
229
237
|
accessibilityLabel: undefined,
|
|
230
238
|
accessibilityHint: accessibilityHint,
|
|
231
239
|
placeholder: displayPlaceholder,
|
|
@@ -258,7 +266,7 @@ function TextInput({
|
|
|
258
266
|
style: containerStyleArray,
|
|
259
267
|
children: inner
|
|
260
268
|
});
|
|
261
|
-
}
|
|
269
|
+
});
|
|
262
270
|
|
|
263
271
|
/**
|
|
264
272
|
* TextInput.Search component that mirrors the Figma "textInput.search" component.
|
|
@@ -280,7 +288,7 @@ function TextInput({
|
|
|
280
288
|
* @param {Object} [props.rest] - Additional props passed to the underlying TextInput
|
|
281
289
|
*/
|
|
282
290
|
|
|
283
|
-
function TextInputSearch({
|
|
291
|
+
const TextInputSearch = /*#__PURE__*/forwardRef(function TextInputSearch({
|
|
284
292
|
placeholder = 'Search',
|
|
285
293
|
value = '',
|
|
286
294
|
onChangeText,
|
|
@@ -293,7 +301,7 @@ function TextInputSearch({
|
|
|
293
301
|
onFocus,
|
|
294
302
|
onBlur,
|
|
295
303
|
...rest
|
|
296
|
-
}) {
|
|
304
|
+
}, ref) {
|
|
297
305
|
// Resolve icon tokens for default search icon
|
|
298
306
|
const iconColor = getVariableByName('textInput/icon/color', modes) || '#24262b';
|
|
299
307
|
const iconSize = getVariableByName('textInput/icon/size', modes) || 18;
|
|
@@ -330,10 +338,15 @@ function TextInputSearch({
|
|
|
330
338
|
textInputProps.accessibilityHint = accessibilityHint;
|
|
331
339
|
}
|
|
332
340
|
return /*#__PURE__*/_jsx(TextInput, {
|
|
341
|
+
ref: ref,
|
|
333
342
|
...textInputProps
|
|
334
343
|
});
|
|
335
|
-
}
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
// Attach Search as a property of TextInput using namespace pattern. The base
|
|
347
|
+
// component is created via forwardRef, so we compose the static onto a typed
|
|
348
|
+
// alias to keep `TextInput.Search` strongly typed.
|
|
336
349
|
|
|
337
|
-
|
|
350
|
+
const TextInput = TextInputBase;
|
|
338
351
|
TextInput.Search = TextInputSearch;
|
|
339
352
|
export default TextInput;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React, { useMemo } from 'react';
|
|
4
|
+
import { Text as RNText } from 'react-native';
|
|
5
|
+
import { getVariableByName } from '../../design-tokens/figma-variables-resolver';
|
|
6
|
+
import { EMPTY_MODES, cloneChildrenWithModes, resolveTruncation } from '../../utils/react-utils';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A single coloured run inside a {@link TextSegment}. Each run can carry its own
|
|
10
|
+
* `modes`, so individual fragments of the same paragraph can resolve different
|
|
11
|
+
* design tokens (most commonly a different `text/foreground` colour) while still
|
|
12
|
+
* flowing — and wrapping — inline as one continuous line of text.
|
|
13
|
+
*/
|
|
14
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
+
const TEXT_ALIGN_MAP = {
|
|
16
|
+
Left: 'left',
|
|
17
|
+
Center: 'center'
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Resolves the `text/*` design tokens for a given modes object into an RN
|
|
22
|
+
* `TextStyle`. Shared by the outer paragraph and every inline run so a run that
|
|
23
|
+
* only overrides colour still inherits the family/size/weight/spacing.
|
|
24
|
+
*/
|
|
25
|
+
function resolveTextStyle(modes) {
|
|
26
|
+
return {
|
|
27
|
+
color: getVariableByName('text/foreground', modes) ?? '#000000',
|
|
28
|
+
fontFamily: getVariableByName('text/fontFamily', modes) ?? 'JioType',
|
|
29
|
+
fontSize: getVariableByName('text/fontSize', modes) ?? 14,
|
|
30
|
+
fontWeight: String(getVariableByName('text/fontWeight', modes) ?? '500'),
|
|
31
|
+
lineHeight: getVariableByName('text/lineHeight', modes) ?? 20,
|
|
32
|
+
letterSpacing: getVariableByName('text/letterSpacing', modes) ?? -0.5
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* TextSegment — composes several differently-styled text runs into a single
|
|
38
|
+
* paragraph that wraps as one continuous line.
|
|
39
|
+
*
|
|
40
|
+
* On the web you would reach for `<span>`s inside a `<p>`; the React Native
|
|
41
|
+
* equivalent is nesting `<Text>` inside a parent `<Text>`. That nesting is the
|
|
42
|
+
* whole trick: sibling `<View>`s would lay out as flex blocks and break onto
|
|
43
|
+
* rigid rows, but nested `<Text>` nodes flow inline and wrap naturally at word
|
|
44
|
+
* boundaries — exactly like a real paragraph — while each nested run keeps its
|
|
45
|
+
* own colour/weight resolved from its own `modes`.
|
|
46
|
+
*
|
|
47
|
+
* Two equivalent ways to author content:
|
|
48
|
+
* - **`segments` prop** — declarative array of `{ text, modes }` runs.
|
|
49
|
+
* - **`children`** — pass library `Text` elements (or strings); the parent
|
|
50
|
+
* `modes` cascade down and each child may override its own.
|
|
51
|
+
*
|
|
52
|
+
* @example Data-driven
|
|
53
|
+
* ```tsx
|
|
54
|
+
* <TextSegment
|
|
55
|
+
* segments={[
|
|
56
|
+
* { text: 'Upsell message ' },
|
|
57
|
+
* { text: 'JioFinance+', modes: { 'Text Appearance': 'Primary' } },
|
|
58
|
+
* ]}
|
|
59
|
+
* />
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* @example Compositional
|
|
63
|
+
* ```tsx
|
|
64
|
+
* <TextSegment numberOfLines={2}>
|
|
65
|
+
* <Text>Pay with </Text>
|
|
66
|
+
* <Text modes={{ 'Text Appearance': 'Primary' }}>JioFinance+</Text>
|
|
67
|
+
* <Text> and earn rewards on every transaction.</Text>
|
|
68
|
+
* </TextSegment>
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
function TextSegment({
|
|
72
|
+
segments,
|
|
73
|
+
children,
|
|
74
|
+
textAlign = 'Left',
|
|
75
|
+
numberOfLines,
|
|
76
|
+
disableTruncation,
|
|
77
|
+
modes = EMPTY_MODES,
|
|
78
|
+
style
|
|
79
|
+
}) {
|
|
80
|
+
const baseStyle = useMemo(() => ({
|
|
81
|
+
...resolveTextStyle(modes),
|
|
82
|
+
textAlign: TEXT_ALIGN_MAP[textAlign]
|
|
83
|
+
}), [modes, textAlign]);
|
|
84
|
+
|
|
85
|
+
// children win over `segments` so the compositional API can always override.
|
|
86
|
+
const hasChildren = children !== undefined && children !== null && children !== false;
|
|
87
|
+
const renderedSegments = useMemo(() => {
|
|
88
|
+
if (hasChildren || !segments?.length) return null;
|
|
89
|
+
return segments.map((run, index) => {
|
|
90
|
+
// Parent modes first, then the run's own modes override them — mirrors the
|
|
91
|
+
// merge order used by `cloneChildrenWithModes` for the children API.
|
|
92
|
+
const runModes = run.modes ? {
|
|
93
|
+
...modes,
|
|
94
|
+
...run.modes
|
|
95
|
+
} : modes;
|
|
96
|
+
const runStyle = run.modes ? resolveTextStyle(runModes) : undefined;
|
|
97
|
+
return /*#__PURE__*/_jsx(RNText, {
|
|
98
|
+
style: [runStyle, run.style],
|
|
99
|
+
children: run.text
|
|
100
|
+
}, index);
|
|
101
|
+
});
|
|
102
|
+
}, [segments, hasChildren, modes]);
|
|
103
|
+
|
|
104
|
+
// The cascade: every child (and its descendants) receives the parent modes so
|
|
105
|
+
// nested library `Text` runs resolve their tokens against the same baseline,
|
|
106
|
+
// while still honouring any per-child `modes` override.
|
|
107
|
+
const content = hasChildren ? cloneChildrenWithModes(children, modes) : renderedSegments;
|
|
108
|
+
return /*#__PURE__*/_jsx(RNText, {
|
|
109
|
+
style: [baseStyle, style],
|
|
110
|
+
...resolveTruncation(disableTruncation, numberOfLines),
|
|
111
|
+
children: content
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
export default /*#__PURE__*/React.memo(TextSegment);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import React, { isValidElement, cloneElement } from 'react';
|
|
4
4
|
import { View, Text } from 'react-native';
|
|
5
5
|
import { getVariableByName } from '../../design-tokens/figma-variables-resolver';
|
|
6
|
-
import { EMPTY_MODES } from '../../utils/react-utils';
|
|
6
|
+
import { EMPTY_MODES, resolveTruncation } from '../../utils/react-utils';
|
|
7
7
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
8
|
/**
|
|
9
9
|
* ThreadHero component displaying a central identity with avatar, title, subtitle, and caption.
|
|
@@ -14,7 +14,8 @@ export default function ThreadHero({
|
|
|
14
14
|
caption,
|
|
15
15
|
renderAvatar,
|
|
16
16
|
modes = EMPTY_MODES,
|
|
17
|
-
style
|
|
17
|
+
style,
|
|
18
|
+
disableTruncation
|
|
18
19
|
}) {
|
|
19
20
|
// Container Gaps
|
|
20
21
|
const containerGap = Number(getVariableByName('threadHero/gap', modes)) || 8;
|
|
@@ -95,14 +96,12 @@ export default function ThreadHero({
|
|
|
95
96
|
children: title
|
|
96
97
|
}) : null, subtitle ? /*#__PURE__*/_jsx(Text, {
|
|
97
98
|
style: subtitleStyle,
|
|
98
|
-
|
|
99
|
-
ellipsizeMode: "tail",
|
|
99
|
+
...resolveTruncation(disableTruncation, 1, 'tail'),
|
|
100
100
|
children: subtitle
|
|
101
101
|
}) : null]
|
|
102
102
|
}), caption ? /*#__PURE__*/_jsx(Text, {
|
|
103
103
|
style: captionStyle,
|
|
104
|
-
|
|
105
|
-
ellipsizeMode: "tail",
|
|
104
|
+
...resolveTruncation(disableTruncation, 1, 'tail'),
|
|
106
105
|
children: caption
|
|
107
106
|
}) : null]
|
|
108
107
|
});
|
|
@@ -4,7 +4,7 @@ import React from 'react';
|
|
|
4
4
|
import { View, Text } from 'react-native';
|
|
5
5
|
import { getVariableByName } from '../../design-tokens/figma-variables-resolver';
|
|
6
6
|
import { useTokens } from '../../design-tokens/JFSThemeProvider';
|
|
7
|
-
import { EMPTY_MODES } from '../../utils/react-utils';
|
|
7
|
+
import { EMPTY_MODES, resolveTruncation } from '../../utils/react-utils';
|
|
8
8
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
9
|
const TEXT_ALIGN_MAP = {
|
|
10
10
|
Left: 'left',
|
|
@@ -19,6 +19,7 @@ function Title({
|
|
|
19
19
|
textStyle,
|
|
20
20
|
subtitleStyle,
|
|
21
21
|
numberOfLines,
|
|
22
|
+
disableTruncation,
|
|
22
23
|
accessibilityLabel,
|
|
23
24
|
accessibilityHint,
|
|
24
25
|
...rest
|
|
@@ -88,7 +89,7 @@ function Title({
|
|
|
88
89
|
...rest,
|
|
89
90
|
children: [/*#__PURE__*/_jsx(Text, {
|
|
90
91
|
style: [titleTextStyle, textStyle],
|
|
91
|
-
|
|
92
|
+
...resolveTruncation(disableTruncation, numberOfLines !== undefined ? numberOfLines : 1),
|
|
92
93
|
accessibilityElementsHidden: true,
|
|
93
94
|
importantForAccessibility: "no",
|
|
94
95
|
children: title
|
|
@@ -5,7 +5,7 @@ import { StyleSheet, Text } from 'react-native';
|
|
|
5
5
|
import Animated, { FadeOut, SlideInDown, SlideInUp } from 'react-native-reanimated';
|
|
6
6
|
import { getVariableByName } from '../../design-tokens/figma-variables-resolver';
|
|
7
7
|
import { closeToast } from './useToast';
|
|
8
|
-
import { EMPTY_MODES } from '../../utils/react-utils';
|
|
8
|
+
import { EMPTY_MODES, resolveTruncation } from '../../utils/react-utils';
|
|
9
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
10
|
const ANIMATION_DURATION = 250;
|
|
11
11
|
function Toast({
|
|
@@ -15,7 +15,8 @@ function Toast({
|
|
|
15
15
|
onClose,
|
|
16
16
|
modes = EMPTY_MODES,
|
|
17
17
|
placement = 'bottom',
|
|
18
|
-
style
|
|
18
|
+
style,
|
|
19
|
+
disableTruncation
|
|
19
20
|
}) {
|
|
20
21
|
const timerRef = useRef(null);
|
|
21
22
|
useEffect(() => {
|
|
@@ -73,7 +74,7 @@ function Toast({
|
|
|
73
74
|
accessibilityLiveRegion: "assertive",
|
|
74
75
|
children: /*#__PURE__*/_jsx(Text, {
|
|
75
76
|
style: textStyle,
|
|
76
|
-
|
|
77
|
+
...resolveTruncation(disableTruncation, 2),
|
|
77
78
|
children: title
|
|
78
79
|
})
|
|
79
80
|
});
|
|
@@ -6,7 +6,7 @@ import { getVariableByName } from '../../design-tokens/figma-variables-resolver'
|
|
|
6
6
|
import MoneyValue from '../MoneyValue/MoneyValue';
|
|
7
7
|
import TransactionStatus from '../TransactionStatus/TransactionStatus';
|
|
8
8
|
import NavArrow from '../NavArrow/NavArrow';
|
|
9
|
-
import { EMPTY_MODES, cloneChildrenWithModes } from '../../utils/react-utils';
|
|
9
|
+
import { EMPTY_MODES, cloneChildrenWithModes, resolveTruncation } from '../../utils/react-utils';
|
|
10
10
|
import { usePressableWebSupport } from '../../utils/web-platform-utils';
|
|
11
11
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
12
|
/**
|
|
@@ -40,6 +40,7 @@ function TransactionBubble({
|
|
|
40
40
|
accessibilityLabel,
|
|
41
41
|
accessibilityHint,
|
|
42
42
|
webAccessibilityProps,
|
|
43
|
+
disableTruncation,
|
|
43
44
|
...rest
|
|
44
45
|
}) {
|
|
45
46
|
const resolvedModes = {
|
|
@@ -109,7 +110,7 @@ function TransactionBubble({
|
|
|
109
110
|
},
|
|
110
111
|
children: [/*#__PURE__*/_jsx(Text, {
|
|
111
112
|
style: descriptionStyle,
|
|
112
|
-
|
|
113
|
+
...resolveTruncation(disableTruncation, 1),
|
|
113
114
|
children: description
|
|
114
115
|
}), /*#__PURE__*/_jsx(MoneyValue, {
|
|
115
116
|
value: value,
|