@hero-design/rn 8.82.2-alpha.2 → 8.83.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/.turbo/turbo-build.log +7 -0
- package/CHANGELOG.md +20 -0
- package/es/index.js +491 -21
- package/lib/index.js +490 -18
- package/package.json +6 -4
- package/rollup.config.mjs +1 -0
- package/src/components/AppCue/StyledAppCue.tsx +46 -0
- package/src/components/AppCue/__tests__/StyledAppCue.tsx +18 -0
- package/src/components/AppCue/__tests__/__snapshots__/StyledAppCue.tsx.snap +200 -0
- package/src/components/AppCue/__tests__/__snapshots__/index.spec.tsx.snap +391 -0
- package/src/components/AppCue/__tests__/index.spec.tsx +61 -0
- package/src/components/AppCue/__tests__/utils.spec.ts +90 -0
- package/src/components/AppCue/index.tsx +188 -0
- package/src/components/AppCue/utils.ts +122 -0
- package/src/components/Chip/StyledChip.tsx +9 -9
- package/src/components/Chip/__tests__/__snapshots__/index.spec.tsx.snap +434 -0
- package/src/components/Chip/__tests__/index.spec.tsx +4 -0
- package/src/components/Chip/index.tsx +32 -5
- package/src/components/Slider/RangeSlider.tsx +187 -0
- package/src/components/Slider/SingleSlider.tsx +89 -0
- package/src/components/Slider/StyledRangeSlider.tsx +16 -0
- package/src/components/Slider/__tests__/RangeSlider.spec.tsx +119 -0
- package/src/components/Slider/__tests__/{index.spec.tsx → SingleSlider.spec.tsx} +1 -1
- package/src/components/Slider/__tests__/__snapshots__/RangeSlider.spec.tsx.snap +252 -0
- package/src/components/Slider/index.tsx +8 -83
- package/src/components/Tabs/StyledScrollableTabs.tsx +2 -1
- package/src/components/Tabs/StyledTabs.tsx +1 -0
- package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabs.spec.tsx.snap +3 -0
- package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabsHeader.spec.tsx.snap +2 -0
- package/src/components/Tabs/__tests__/__snapshots__/index.spec.tsx.snap +3 -0
- package/src/index.ts +2 -0
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +39 -0
- package/src/theme/components/appCue.ts +22 -0
- package/src/theme/components/slider.ts +19 -1
- package/src/theme/components/tabs.ts +1 -0
- package/src/theme/getTheme.ts +3 -0
- package/src/types.ts +2 -0
- package/stats/8.83.0/rn-stats.html +4844 -0
- package/testUtils/setup.tsx +17 -0
- package/types/components/AppCue/StyledAppCue.d.ts +20 -0
- package/types/components/AppCue/__tests__/StyledAppCue.d.ts +1 -0
- package/types/components/AppCue/index.d.ts +21 -0
- package/types/components/AppCue/utils.d.ts +63 -0
- package/types/components/Chip/StyledChip.d.ts +1 -1
- package/types/components/Chip/index.d.ts +2 -2
- package/types/components/Slider/RangeSlider.d.ts +60 -0
- package/types/components/Slider/SingleSlider.d.ts +53 -0
- package/types/components/Slider/StyledRangeSlider.d.ts +10 -0
- package/types/components/Slider/index.d.ts +6 -51
- package/types/index.d.ts +2 -1
- package/types/theme/components/appCue.d.ts +16 -0
- package/types/theme/components/slider.d.ts +24 -0
- package/types/theme/components/tabs.d.ts +1 -0
- package/types/theme/getTheme.d.ts +2 -0
- package/types/types.d.ts +2 -1
- /package/src/components/Slider/__tests__/__snapshots__/{index.spec.tsx.snap → SingleSlider.spec.tsx.snap} +0 -0
|
@@ -1460,6 +1460,214 @@ exports[`Chip renders correctly with variant filled and selected true 1`] = `
|
|
|
1460
1460
|
</View>
|
|
1461
1461
|
`;
|
|
1462
1462
|
|
|
1463
|
+
exports[`Chip renders correctly with variant filter and selected false 1`] = `
|
|
1464
|
+
<View
|
|
1465
|
+
style={
|
|
1466
|
+
{
|
|
1467
|
+
"flex": 1,
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
>
|
|
1471
|
+
<View
|
|
1472
|
+
accessibilityState={
|
|
1473
|
+
{
|
|
1474
|
+
"busy": undefined,
|
|
1475
|
+
"checked": undefined,
|
|
1476
|
+
"disabled": undefined,
|
|
1477
|
+
"expanded": undefined,
|
|
1478
|
+
"selected": undefined,
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
accessibilityValue={
|
|
1482
|
+
{
|
|
1483
|
+
"max": undefined,
|
|
1484
|
+
"min": undefined,
|
|
1485
|
+
"now": undefined,
|
|
1486
|
+
"text": undefined,
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
accessible={true}
|
|
1490
|
+
collapsable={false}
|
|
1491
|
+
focusable={false}
|
|
1492
|
+
onClick={[Function]}
|
|
1493
|
+
onResponderGrant={[Function]}
|
|
1494
|
+
onResponderMove={[Function]}
|
|
1495
|
+
onResponderRelease={[Function]}
|
|
1496
|
+
onResponderTerminate={[Function]}
|
|
1497
|
+
onResponderTerminationRequest={[Function]}
|
|
1498
|
+
onStartShouldSetResponder={[Function]}
|
|
1499
|
+
style={
|
|
1500
|
+
{
|
|
1501
|
+
"alignItems": "center",
|
|
1502
|
+
"alignSelf": "flex-start",
|
|
1503
|
+
"backgroundColor": "#ffffff",
|
|
1504
|
+
"borderColor": "transparent",
|
|
1505
|
+
"borderRadius": 999,
|
|
1506
|
+
"elevation": 3,
|
|
1507
|
+
"flexDirection": "row",
|
|
1508
|
+
"justifyContent": "center",
|
|
1509
|
+
"opacity": 1,
|
|
1510
|
+
"paddingHorizontal": 12,
|
|
1511
|
+
"paddingVertical": 8,
|
|
1512
|
+
"shadowColor": "#001f23",
|
|
1513
|
+
"shadowOffset": {
|
|
1514
|
+
"height": 2,
|
|
1515
|
+
"width": 0,
|
|
1516
|
+
},
|
|
1517
|
+
"shadowOpacity": 0.12,
|
|
1518
|
+
"shadowRadius": 4,
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
testID="chip"
|
|
1522
|
+
>
|
|
1523
|
+
<Text
|
|
1524
|
+
allowFontScaling={false}
|
|
1525
|
+
style={
|
|
1526
|
+
[
|
|
1527
|
+
{
|
|
1528
|
+
"color": "#001f23",
|
|
1529
|
+
"fontFamily": "BeVietnamPro-Regular",
|
|
1530
|
+
"fontSize": 14,
|
|
1531
|
+
"letterSpacing": 0.48,
|
|
1532
|
+
"lineHeight": 22,
|
|
1533
|
+
},
|
|
1534
|
+
undefined,
|
|
1535
|
+
]
|
|
1536
|
+
}
|
|
1537
|
+
themeIntent="body"
|
|
1538
|
+
themeTypeface="neutral"
|
|
1539
|
+
themeVariant="small"
|
|
1540
|
+
>
|
|
1541
|
+
Cover my bills
|
|
1542
|
+
</Text>
|
|
1543
|
+
</View>
|
|
1544
|
+
<View
|
|
1545
|
+
pointerEvents="box-none"
|
|
1546
|
+
position="bottom"
|
|
1547
|
+
style={
|
|
1548
|
+
[
|
|
1549
|
+
{
|
|
1550
|
+
"bottom": 0,
|
|
1551
|
+
"elevation": 9999,
|
|
1552
|
+
"flexDirection": "column-reverse",
|
|
1553
|
+
"left": 0,
|
|
1554
|
+
"paddingHorizontal": 24,
|
|
1555
|
+
"paddingVertical": 16,
|
|
1556
|
+
"position": "absolute",
|
|
1557
|
+
"right": 0,
|
|
1558
|
+
"top": 0,
|
|
1559
|
+
},
|
|
1560
|
+
undefined,
|
|
1561
|
+
]
|
|
1562
|
+
}
|
|
1563
|
+
/>
|
|
1564
|
+
</View>
|
|
1565
|
+
`;
|
|
1566
|
+
|
|
1567
|
+
exports[`Chip renders correctly with variant filter and selected true 1`] = `
|
|
1568
|
+
<View
|
|
1569
|
+
style={
|
|
1570
|
+
{
|
|
1571
|
+
"flex": 1,
|
|
1572
|
+
}
|
|
1573
|
+
}
|
|
1574
|
+
>
|
|
1575
|
+
<View
|
|
1576
|
+
accessibilityState={
|
|
1577
|
+
{
|
|
1578
|
+
"busy": undefined,
|
|
1579
|
+
"checked": undefined,
|
|
1580
|
+
"disabled": undefined,
|
|
1581
|
+
"expanded": undefined,
|
|
1582
|
+
"selected": undefined,
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
accessibilityValue={
|
|
1586
|
+
{
|
|
1587
|
+
"max": undefined,
|
|
1588
|
+
"min": undefined,
|
|
1589
|
+
"now": undefined,
|
|
1590
|
+
"text": undefined,
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
accessible={true}
|
|
1594
|
+
collapsable={false}
|
|
1595
|
+
focusable={false}
|
|
1596
|
+
onClick={[Function]}
|
|
1597
|
+
onResponderGrant={[Function]}
|
|
1598
|
+
onResponderMove={[Function]}
|
|
1599
|
+
onResponderRelease={[Function]}
|
|
1600
|
+
onResponderTerminate={[Function]}
|
|
1601
|
+
onResponderTerminationRequest={[Function]}
|
|
1602
|
+
onStartShouldSetResponder={[Function]}
|
|
1603
|
+
style={
|
|
1604
|
+
{
|
|
1605
|
+
"alignItems": "center",
|
|
1606
|
+
"alignSelf": "flex-start",
|
|
1607
|
+
"backgroundColor": "#ece8ef",
|
|
1608
|
+
"borderColor": "transparent",
|
|
1609
|
+
"borderRadius": 999,
|
|
1610
|
+
"elevation": 3,
|
|
1611
|
+
"flexDirection": "row",
|
|
1612
|
+
"justifyContent": "center",
|
|
1613
|
+
"opacity": 1,
|
|
1614
|
+
"paddingHorizontal": 12,
|
|
1615
|
+
"paddingVertical": 8,
|
|
1616
|
+
"shadowColor": "#001f23",
|
|
1617
|
+
"shadowOffset": {
|
|
1618
|
+
"height": 2,
|
|
1619
|
+
"width": 0,
|
|
1620
|
+
},
|
|
1621
|
+
"shadowOpacity": 0.12,
|
|
1622
|
+
"shadowRadius": 4,
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
testID="chip"
|
|
1626
|
+
>
|
|
1627
|
+
<Text
|
|
1628
|
+
allowFontScaling={false}
|
|
1629
|
+
style={
|
|
1630
|
+
[
|
|
1631
|
+
{
|
|
1632
|
+
"color": "#001f23",
|
|
1633
|
+
"fontFamily": "BeVietnamPro-Regular",
|
|
1634
|
+
"fontSize": 14,
|
|
1635
|
+
"letterSpacing": 0.48,
|
|
1636
|
+
"lineHeight": 22,
|
|
1637
|
+
},
|
|
1638
|
+
undefined,
|
|
1639
|
+
]
|
|
1640
|
+
}
|
|
1641
|
+
themeIntent="body"
|
|
1642
|
+
themeTypeface="neutral"
|
|
1643
|
+
themeVariant="small"
|
|
1644
|
+
>
|
|
1645
|
+
Cover my bills
|
|
1646
|
+
</Text>
|
|
1647
|
+
</View>
|
|
1648
|
+
<View
|
|
1649
|
+
pointerEvents="box-none"
|
|
1650
|
+
position="bottom"
|
|
1651
|
+
style={
|
|
1652
|
+
[
|
|
1653
|
+
{
|
|
1654
|
+
"bottom": 0,
|
|
1655
|
+
"elevation": 9999,
|
|
1656
|
+
"flexDirection": "column-reverse",
|
|
1657
|
+
"left": 0,
|
|
1658
|
+
"paddingHorizontal": 24,
|
|
1659
|
+
"paddingVertical": 16,
|
|
1660
|
+
"position": "absolute",
|
|
1661
|
+
"right": 0,
|
|
1662
|
+
"top": 0,
|
|
1663
|
+
},
|
|
1664
|
+
undefined,
|
|
1665
|
+
]
|
|
1666
|
+
}
|
|
1667
|
+
/>
|
|
1668
|
+
</View>
|
|
1669
|
+
`;
|
|
1670
|
+
|
|
1463
1671
|
exports[`Chip renders correctly with variant outlined and selected false 1`] = `
|
|
1464
1672
|
<View
|
|
1465
1673
|
style={
|
|
@@ -1685,3 +1893,229 @@ exports[`Chip renders correctly with variant outlined and selected true 1`] = `
|
|
|
1685
1893
|
/>
|
|
1686
1894
|
</View>
|
|
1687
1895
|
`;
|
|
1896
|
+
|
|
1897
|
+
exports[`Chip renders correctly with variant selection and selected false 1`] = `
|
|
1898
|
+
<View
|
|
1899
|
+
style={
|
|
1900
|
+
{
|
|
1901
|
+
"flex": 1,
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
>
|
|
1905
|
+
<View
|
|
1906
|
+
accessibilityState={
|
|
1907
|
+
{
|
|
1908
|
+
"busy": undefined,
|
|
1909
|
+
"checked": undefined,
|
|
1910
|
+
"disabled": undefined,
|
|
1911
|
+
"expanded": undefined,
|
|
1912
|
+
"selected": undefined,
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
accessibilityValue={
|
|
1916
|
+
{
|
|
1917
|
+
"max": undefined,
|
|
1918
|
+
"min": undefined,
|
|
1919
|
+
"now": undefined,
|
|
1920
|
+
"text": undefined,
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
accessible={true}
|
|
1924
|
+
collapsable={false}
|
|
1925
|
+
focusable={false}
|
|
1926
|
+
onClick={[Function]}
|
|
1927
|
+
onResponderGrant={[Function]}
|
|
1928
|
+
onResponderMove={[Function]}
|
|
1929
|
+
onResponderRelease={[Function]}
|
|
1930
|
+
onResponderTerminate={[Function]}
|
|
1931
|
+
onResponderTerminationRequest={[Function]}
|
|
1932
|
+
onStartShouldSetResponder={[Function]}
|
|
1933
|
+
style={
|
|
1934
|
+
{
|
|
1935
|
+
"alignItems": "center",
|
|
1936
|
+
"alignSelf": "flex-start",
|
|
1937
|
+
"backgroundColor": "#ffffff",
|
|
1938
|
+
"borderColor": "#bfc1c5",
|
|
1939
|
+
"borderRadius": 999,
|
|
1940
|
+
"borderWidth": 1,
|
|
1941
|
+
"flexDirection": "row",
|
|
1942
|
+
"justifyContent": "center",
|
|
1943
|
+
"opacity": 1,
|
|
1944
|
+
"paddingHorizontal": 12,
|
|
1945
|
+
"paddingVertical": 8,
|
|
1946
|
+
}
|
|
1947
|
+
}
|
|
1948
|
+
testID="chip"
|
|
1949
|
+
>
|
|
1950
|
+
<Text
|
|
1951
|
+
allowFontScaling={false}
|
|
1952
|
+
style={
|
|
1953
|
+
[
|
|
1954
|
+
{
|
|
1955
|
+
"color": "#001f23",
|
|
1956
|
+
"fontFamily": "BeVietnamPro-Regular",
|
|
1957
|
+
"fontSize": 14,
|
|
1958
|
+
"letterSpacing": 0.48,
|
|
1959
|
+
"lineHeight": 22,
|
|
1960
|
+
},
|
|
1961
|
+
undefined,
|
|
1962
|
+
]
|
|
1963
|
+
}
|
|
1964
|
+
themeIntent="body"
|
|
1965
|
+
themeTypeface="neutral"
|
|
1966
|
+
themeVariant="small"
|
|
1967
|
+
>
|
|
1968
|
+
Cover my bills
|
|
1969
|
+
</Text>
|
|
1970
|
+
</View>
|
|
1971
|
+
<View
|
|
1972
|
+
pointerEvents="box-none"
|
|
1973
|
+
position="bottom"
|
|
1974
|
+
style={
|
|
1975
|
+
[
|
|
1976
|
+
{
|
|
1977
|
+
"bottom": 0,
|
|
1978
|
+
"elevation": 9999,
|
|
1979
|
+
"flexDirection": "column-reverse",
|
|
1980
|
+
"left": 0,
|
|
1981
|
+
"paddingHorizontal": 24,
|
|
1982
|
+
"paddingVertical": 16,
|
|
1983
|
+
"position": "absolute",
|
|
1984
|
+
"right": 0,
|
|
1985
|
+
"top": 0,
|
|
1986
|
+
},
|
|
1987
|
+
undefined,
|
|
1988
|
+
]
|
|
1989
|
+
}
|
|
1990
|
+
/>
|
|
1991
|
+
</View>
|
|
1992
|
+
`;
|
|
1993
|
+
|
|
1994
|
+
exports[`Chip renders correctly with variant selection and selected true 1`] = `
|
|
1995
|
+
<View
|
|
1996
|
+
style={
|
|
1997
|
+
{
|
|
1998
|
+
"flex": 1,
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
>
|
|
2002
|
+
<View
|
|
2003
|
+
accessibilityState={
|
|
2004
|
+
{
|
|
2005
|
+
"busy": undefined,
|
|
2006
|
+
"checked": undefined,
|
|
2007
|
+
"disabled": undefined,
|
|
2008
|
+
"expanded": undefined,
|
|
2009
|
+
"selected": undefined,
|
|
2010
|
+
}
|
|
2011
|
+
}
|
|
2012
|
+
accessibilityValue={
|
|
2013
|
+
{
|
|
2014
|
+
"max": undefined,
|
|
2015
|
+
"min": undefined,
|
|
2016
|
+
"now": undefined,
|
|
2017
|
+
"text": undefined,
|
|
2018
|
+
}
|
|
2019
|
+
}
|
|
2020
|
+
accessible={true}
|
|
2021
|
+
collapsable={false}
|
|
2022
|
+
focusable={false}
|
|
2023
|
+
onClick={[Function]}
|
|
2024
|
+
onResponderGrant={[Function]}
|
|
2025
|
+
onResponderMove={[Function]}
|
|
2026
|
+
onResponderRelease={[Function]}
|
|
2027
|
+
onResponderTerminate={[Function]}
|
|
2028
|
+
onResponderTerminationRequest={[Function]}
|
|
2029
|
+
onStartShouldSetResponder={[Function]}
|
|
2030
|
+
style={
|
|
2031
|
+
{
|
|
2032
|
+
"alignItems": "center",
|
|
2033
|
+
"alignSelf": "flex-start",
|
|
2034
|
+
"backgroundColor": "#e8e9ea",
|
|
2035
|
+
"borderColor": "#001f23",
|
|
2036
|
+
"borderRadius": 999,
|
|
2037
|
+
"borderWidth": 1,
|
|
2038
|
+
"flexDirection": "row",
|
|
2039
|
+
"justifyContent": "center",
|
|
2040
|
+
"opacity": 1,
|
|
2041
|
+
"paddingHorizontal": 12,
|
|
2042
|
+
"paddingVertical": 8,
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
testID="chip"
|
|
2046
|
+
>
|
|
2047
|
+
<Text
|
|
2048
|
+
allowFontScaling={false}
|
|
2049
|
+
style={
|
|
2050
|
+
[
|
|
2051
|
+
{
|
|
2052
|
+
"color": "#001f23",
|
|
2053
|
+
"fontFamily": "BeVietnamPro-Regular",
|
|
2054
|
+
"fontSize": 14,
|
|
2055
|
+
"letterSpacing": 0.48,
|
|
2056
|
+
"lineHeight": 22,
|
|
2057
|
+
},
|
|
2058
|
+
undefined,
|
|
2059
|
+
]
|
|
2060
|
+
}
|
|
2061
|
+
themeIntent="body"
|
|
2062
|
+
themeTypeface="neutral"
|
|
2063
|
+
themeVariant="small"
|
|
2064
|
+
>
|
|
2065
|
+
Cover my bills
|
|
2066
|
+
</Text>
|
|
2067
|
+
<View
|
|
2068
|
+
marginLeft="small"
|
|
2069
|
+
style={
|
|
2070
|
+
[
|
|
2071
|
+
{
|
|
2072
|
+
"marginLeft": 8,
|
|
2073
|
+
},
|
|
2074
|
+
undefined,
|
|
2075
|
+
]
|
|
2076
|
+
}
|
|
2077
|
+
>
|
|
2078
|
+
<HeroIcon
|
|
2079
|
+
name="cancel"
|
|
2080
|
+
style={
|
|
2081
|
+
[
|
|
2082
|
+
{
|
|
2083
|
+
"color": "#001f23",
|
|
2084
|
+
"fontSize": 24,
|
|
2085
|
+
},
|
|
2086
|
+
[
|
|
2087
|
+
{
|
|
2088
|
+
"fontSize": 12,
|
|
2089
|
+
},
|
|
2090
|
+
undefined,
|
|
2091
|
+
],
|
|
2092
|
+
]
|
|
2093
|
+
}
|
|
2094
|
+
testID="selected-chip-icon-cancel"
|
|
2095
|
+
themeIntent="text"
|
|
2096
|
+
themeSize="medium"
|
|
2097
|
+
/>
|
|
2098
|
+
</View>
|
|
2099
|
+
</View>
|
|
2100
|
+
<View
|
|
2101
|
+
pointerEvents="box-none"
|
|
2102
|
+
position="bottom"
|
|
2103
|
+
style={
|
|
2104
|
+
[
|
|
2105
|
+
{
|
|
2106
|
+
"bottom": 0,
|
|
2107
|
+
"elevation": 9999,
|
|
2108
|
+
"flexDirection": "column-reverse",
|
|
2109
|
+
"left": 0,
|
|
2110
|
+
"paddingHorizontal": 24,
|
|
2111
|
+
"paddingVertical": 16,
|
|
2112
|
+
"position": "absolute",
|
|
2113
|
+
"right": 0,
|
|
2114
|
+
"top": 0,
|
|
2115
|
+
},
|
|
2116
|
+
undefined,
|
|
2117
|
+
]
|
|
2118
|
+
}
|
|
2119
|
+
/>
|
|
2120
|
+
</View>
|
|
2121
|
+
`;
|
|
@@ -87,6 +87,10 @@ describe('Chip', () => {
|
|
|
87
87
|
${'filled'} | ${false}
|
|
88
88
|
${'outlined'} | ${true}
|
|
89
89
|
${'outlined'} | ${false}
|
|
90
|
+
${'filter'} | ${true}
|
|
91
|
+
${'filter'} | ${false}
|
|
92
|
+
${'selection'} | ${true}
|
|
93
|
+
${'selection'} | ${false}
|
|
90
94
|
${'compact'} | ${true}
|
|
91
95
|
${'compact'} | ${false}
|
|
92
96
|
${'compact-outlined'} | ${true}
|
|
@@ -4,6 +4,7 @@ import Box from '../Box';
|
|
|
4
4
|
import { IconName } from '../Icon';
|
|
5
5
|
import Typography from '../Typography';
|
|
6
6
|
import { StyledChipIcon, StyledChipWrapper } from './StyledChip';
|
|
7
|
+
import { useDeprecation } from '../../utils/hooks';
|
|
7
8
|
|
|
8
9
|
export interface ChipProps extends ViewProps {
|
|
9
10
|
/**
|
|
@@ -11,9 +12,15 @@ export interface ChipProps extends ViewProps {
|
|
|
11
12
|
*/
|
|
12
13
|
label: string | ReactNode;
|
|
13
14
|
/**
|
|
14
|
-
* Variant of the chip.
|
|
15
|
+
* Variant of the chip. `outlined` and `filled` are deprecated.
|
|
15
16
|
*/
|
|
16
|
-
variant?:
|
|
17
|
+
variant?:
|
|
18
|
+
| 'selection'
|
|
19
|
+
| 'filter'
|
|
20
|
+
| 'compact'
|
|
21
|
+
| 'compact-outlined'
|
|
22
|
+
| 'outlined'
|
|
23
|
+
| 'filled';
|
|
17
24
|
/**
|
|
18
25
|
* Whether the chip is selected.
|
|
19
26
|
*/
|
|
@@ -40,17 +47,37 @@ const getChipLabel = (label: string | ReactNode) => {
|
|
|
40
47
|
return label;
|
|
41
48
|
};
|
|
42
49
|
|
|
50
|
+
const getChipVariant = (variant: ChipProps['variant'] = 'selection') => {
|
|
51
|
+
switch (variant) {
|
|
52
|
+
case 'selection':
|
|
53
|
+
case 'filter':
|
|
54
|
+
case 'compact':
|
|
55
|
+
case 'compact-outlined':
|
|
56
|
+
return variant;
|
|
57
|
+
case 'outlined':
|
|
58
|
+
return 'selection';
|
|
59
|
+
case 'filled':
|
|
60
|
+
return 'filter';
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
43
64
|
const Chip = ({
|
|
44
65
|
label,
|
|
45
|
-
variant = '
|
|
66
|
+
variant = 'selection',
|
|
46
67
|
selected = false,
|
|
47
68
|
icon,
|
|
48
69
|
onPress,
|
|
49
70
|
showSelectedIcon = true,
|
|
50
71
|
...otherProps
|
|
51
72
|
}: ChipProps) => {
|
|
73
|
+
useDeprecation(
|
|
74
|
+
'Chip variant `outlined` and `filled` are deprecated.',
|
|
75
|
+
variant === 'outlined' || variant === 'filled'
|
|
76
|
+
);
|
|
77
|
+
const renamedVariant = getChipVariant(variant);
|
|
78
|
+
|
|
52
79
|
const shouldShowSelectedIcon =
|
|
53
|
-
(
|
|
80
|
+
(renamedVariant === 'selection' || renamedVariant === 'compact-outlined') &&
|
|
54
81
|
selected &&
|
|
55
82
|
showSelectedIcon;
|
|
56
83
|
|
|
@@ -59,7 +86,7 @@ const Chip = ({
|
|
|
59
86
|
return (
|
|
60
87
|
<StyledChipWrapper
|
|
61
88
|
onPress={onPress}
|
|
62
|
-
themeVariant={
|
|
89
|
+
themeVariant={renamedVariant}
|
|
63
90
|
themeSelected={selected}
|
|
64
91
|
{...otherProps}
|
|
65
92
|
>
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import React, { useCallback, useMemo, useState } from 'react';
|
|
2
|
+
import MultiSlider from '@ptomasroos/react-native-multi-slider';
|
|
3
|
+
|
|
4
|
+
import { LayoutChangeEvent, StyleProp, View, ViewStyle } from 'react-native';
|
|
5
|
+
import { useTheme } from '../../theme';
|
|
6
|
+
import { StyledMarker } from './StyledRangeSlider';
|
|
7
|
+
|
|
8
|
+
export type SliderRangeValue = {
|
|
9
|
+
start: number;
|
|
10
|
+
end: number;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export interface RangeSliderProps {
|
|
14
|
+
/**
|
|
15
|
+
* Minimum value of the slider.
|
|
16
|
+
*/
|
|
17
|
+
minimumValue: number;
|
|
18
|
+
/**
|
|
19
|
+
* Maximum value of the slider.
|
|
20
|
+
*/
|
|
21
|
+
maximumValue: number;
|
|
22
|
+
/**
|
|
23
|
+
* Step value of the slider.
|
|
24
|
+
* The value should be between 1 and (maximumValue - minimumValue).
|
|
25
|
+
* Defaults to 1.
|
|
26
|
+
*/
|
|
27
|
+
step?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Range value of the slider.
|
|
30
|
+
* Defaults to minimumValue.
|
|
31
|
+
*/
|
|
32
|
+
value?: SliderRangeValue;
|
|
33
|
+
/**
|
|
34
|
+
* Whether the two markers should be allowed to overlap.
|
|
35
|
+
* Defaults to false.
|
|
36
|
+
*/
|
|
37
|
+
allowOverlap?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Callback continuously called while the user is dragging the slider.
|
|
40
|
+
*/
|
|
41
|
+
onValueChange?: (value: SliderRangeValue) => void;
|
|
42
|
+
/**
|
|
43
|
+
* Callback that is called when the user picks up the slider.
|
|
44
|
+
* The initial value is passed as an argument to the callback handler.
|
|
45
|
+
*/
|
|
46
|
+
onSlidingStart?: () => void;
|
|
47
|
+
/**
|
|
48
|
+
* Callback that is called when the user releases the slider, regardless if the value has changed.
|
|
49
|
+
* The current value is passed as an argument to the callback handler.
|
|
50
|
+
*/
|
|
51
|
+
onSlidingComplete?: (value: SliderRangeValue) => void;
|
|
52
|
+
/**
|
|
53
|
+
* Whether the slider is disabled.
|
|
54
|
+
*/
|
|
55
|
+
disabled?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Additional style.
|
|
58
|
+
*/
|
|
59
|
+
style?: StyleProp<ViewStyle>;
|
|
60
|
+
/**
|
|
61
|
+
* Testing id of the component.
|
|
62
|
+
*/
|
|
63
|
+
testID?: string;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const Slider = ({
|
|
67
|
+
minimumValue,
|
|
68
|
+
maximumValue,
|
|
69
|
+
step = 1,
|
|
70
|
+
value,
|
|
71
|
+
onValueChange,
|
|
72
|
+
onSlidingStart,
|
|
73
|
+
onSlidingComplete,
|
|
74
|
+
disabled = false,
|
|
75
|
+
style,
|
|
76
|
+
testID,
|
|
77
|
+
allowOverlap = false,
|
|
78
|
+
}: RangeSliderProps) => {
|
|
79
|
+
const theme = useTheme();
|
|
80
|
+
const handleTwoWaySliderChange = React.useCallback(
|
|
81
|
+
(values: number[]) => {
|
|
82
|
+
if (onValueChange) {
|
|
83
|
+
onValueChange({ start: values[0], end: values[1] });
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
[onValueChange]
|
|
87
|
+
);
|
|
88
|
+
const [layoutSize, setLayoutSize] = useState({ width: 0, height: 0 });
|
|
89
|
+
const nativeValue = useMemo(() => {
|
|
90
|
+
return [value?.start ?? minimumValue, value?.end ?? maximumValue];
|
|
91
|
+
}, [value?.start, value?.end, minimumValue, maximumValue]);
|
|
92
|
+
|
|
93
|
+
const {
|
|
94
|
+
trackBackground,
|
|
95
|
+
disabledTrackBackground,
|
|
96
|
+
thumbTint,
|
|
97
|
+
disabledThumbTint,
|
|
98
|
+
} = theme.__hd__.slider.colors;
|
|
99
|
+
|
|
100
|
+
const { trackHeight } = theme.__hd__.slider.sizes;
|
|
101
|
+
|
|
102
|
+
// Define styles for disabled and enabled states
|
|
103
|
+
const disabledStyles = {
|
|
104
|
+
track: {
|
|
105
|
+
backgroundColor: disabledTrackBackground,
|
|
106
|
+
height: trackHeight,
|
|
107
|
+
},
|
|
108
|
+
selected: {
|
|
109
|
+
backgroundColor: disabledThumbTint,
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const enabledStyles = {
|
|
114
|
+
track: {
|
|
115
|
+
backgroundColor: trackBackground,
|
|
116
|
+
height: trackHeight,
|
|
117
|
+
},
|
|
118
|
+
selected: {
|
|
119
|
+
backgroundColor: thumbTint,
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
// Use styles based on the `disabled` state
|
|
124
|
+
const trackStyle = disabled ? disabledStyles.track : enabledStyles.track;
|
|
125
|
+
const selectedStyle = disabled
|
|
126
|
+
? disabledStyles.selected
|
|
127
|
+
: enabledStyles.selected;
|
|
128
|
+
|
|
129
|
+
const handleOnValueChangeStart = useCallback(() => {
|
|
130
|
+
if (onSlidingStart) {
|
|
131
|
+
onSlidingStart();
|
|
132
|
+
}
|
|
133
|
+
}, [onSlidingStart]);
|
|
134
|
+
|
|
135
|
+
const handleOnValueChangeFinish = useCallback(
|
|
136
|
+
(values: number[]) => {
|
|
137
|
+
if (onSlidingComplete) {
|
|
138
|
+
onSlidingComplete({
|
|
139
|
+
start: values[0],
|
|
140
|
+
end: values[1],
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
[onSlidingComplete]
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
const onLayoutCallback = useCallback((event: LayoutChangeEvent) => {
|
|
148
|
+
setLayoutSize({
|
|
149
|
+
width: event.nativeEvent.layout.width,
|
|
150
|
+
height: event.nativeEvent.layout.height,
|
|
151
|
+
});
|
|
152
|
+
}, []);
|
|
153
|
+
|
|
154
|
+
const CustomMarker = useMemo(() => {
|
|
155
|
+
return () => <StyledMarker themeDisabled={disabled} />;
|
|
156
|
+
}, [disabled]);
|
|
157
|
+
|
|
158
|
+
return (
|
|
159
|
+
<View
|
|
160
|
+
onLayout={onLayoutCallback}
|
|
161
|
+
style={style}
|
|
162
|
+
testID={testID}
|
|
163
|
+
accessibilityState={{
|
|
164
|
+
disabled,
|
|
165
|
+
}}
|
|
166
|
+
>
|
|
167
|
+
<MultiSlider
|
|
168
|
+
values={nativeValue}
|
|
169
|
+
onValuesChange={handleTwoWaySliderChange}
|
|
170
|
+
onValuesChangeStart={handleOnValueChangeStart}
|
|
171
|
+
onValuesChangeFinish={handleOnValueChangeFinish}
|
|
172
|
+
sliderLength={layoutSize.width}
|
|
173
|
+
min={minimumValue}
|
|
174
|
+
max={maximumValue}
|
|
175
|
+
step={step}
|
|
176
|
+
enabledOne={!disabled}
|
|
177
|
+
enabledTwo={!disabled}
|
|
178
|
+
allowOverlap={allowOverlap}
|
|
179
|
+
trackStyle={trackStyle}
|
|
180
|
+
selectedStyle={selectedStyle}
|
|
181
|
+
customMarker={CustomMarker}
|
|
182
|
+
/>
|
|
183
|
+
</View>
|
|
184
|
+
);
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
export default Slider;
|