@telus-uds/components-base 1.81.0 → 1.82.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -2
- package/lib/Autocomplete/Autocomplete.js +3 -1
- package/lib/Icon/Icon.js +24 -2
- package/lib/Listbox/Listbox.js +7 -1
- package/lib/Modal/Modal.js +40 -4
- package/lib/Modal/WebModal.js +73 -0
- package/lib/PriceLockup/PriceLockup.js +4 -1
- package/lib/PriceLockup/utils/renderFootnoteContent.js +2 -2
- package/lib/PriceLockup/utils/renderFootnoteLinks.js +2 -2
- package/lib/PriceLockup/utils/renderPrice.js +2 -2
- package/lib/PriceLockup/utils/renderTypography.js +1 -1
- package/lib/ProductCard/ProductCard.js +238 -0
- package/lib/ProductCard/dictionary.js +45 -0
- package/lib/ProductCard/index.js +10 -0
- package/lib/ProductCardGroup/ProductCardGroup.js +79 -0
- package/lib/ProductCardGroup/index.js +10 -0
- package/lib/index.js +16 -0
- package/lib-module/Autocomplete/Autocomplete.js +3 -1
- package/lib-module/Icon/Icon.js +24 -2
- package/lib-module/Listbox/Listbox.js +7 -1
- package/lib-module/Modal/Modal.js +42 -5
- package/lib-module/Modal/WebModal.js +65 -0
- package/lib-module/PriceLockup/PriceLockup.js +4 -1
- package/lib-module/PriceLockup/utils/renderFootnoteContent.js +2 -2
- package/lib-module/PriceLockup/utils/renderFootnoteLinks.js +2 -2
- package/lib-module/PriceLockup/utils/renderPrice.js +2 -2
- package/lib-module/PriceLockup/utils/renderTypography.js +1 -1
- package/lib-module/ProductCard/ProductCard.js +231 -0
- package/lib-module/ProductCard/dictionary.js +38 -0
- package/lib-module/ProductCard/index.js +2 -0
- package/lib-module/ProductCardGroup/ProductCardGroup.js +69 -0
- package/lib-module/ProductCardGroup/index.js +2 -0
- package/lib-module/index.js +2 -0
- package/package.json +2 -2
- package/src/Autocomplete/Autocomplete.jsx +4 -1
- package/src/Icon/Icon.jsx +30 -2
- package/src/Listbox/Listbox.jsx +6 -1
- package/src/Modal/Modal.jsx +42 -3
- package/src/Modal/WebModal.jsx +60 -0
- package/src/PriceLockup/PriceLockup.jsx +8 -2
- package/src/PriceLockup/utils/renderFootnoteContent.jsx +2 -2
- package/src/PriceLockup/utils/renderFootnoteLinks.jsx +2 -2
- package/src/PriceLockup/utils/renderPrice.jsx +2 -2
- package/src/PriceLockup/utils/renderTypography.jsx +1 -1
- package/src/ProductCard/ProductCard.jsx +193 -0
- package/src/ProductCard/dictionary.js +38 -0
- package/src/ProductCard/index.js +3 -0
- package/src/ProductCardGroup/ProductCardGroup.jsx +75 -0
- package/src/ProductCardGroup/index.js +3 -0
- package/src/index.js +2 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
en: {
|
|
3
|
+
badgeText: '',
|
|
4
|
+
brandName: 'Brand name',
|
|
5
|
+
productName: 'Product name',
|
|
6
|
+
primaryPrice: {
|
|
7
|
+
price: '00',
|
|
8
|
+
signDirection: 'left',
|
|
9
|
+
rateText: '/month'
|
|
10
|
+
},
|
|
11
|
+
secondaryPrice: {
|
|
12
|
+
price: '',
|
|
13
|
+
signDirection: 'left',
|
|
14
|
+
rateText: 'Upfront'
|
|
15
|
+
},
|
|
16
|
+
term: '24 months | 0% APR Bring-it-Back applied',
|
|
17
|
+
buttonLabel: 'Select this phone',
|
|
18
|
+
selectedButtonLabel: 'Selected phone'
|
|
19
|
+
},
|
|
20
|
+
fr: {
|
|
21
|
+
badgeText: '',
|
|
22
|
+
brandName: 'Brand name',
|
|
23
|
+
productName: 'Product name',
|
|
24
|
+
primaryPrice: {
|
|
25
|
+
price: '00',
|
|
26
|
+
signDirection: 'right',
|
|
27
|
+
rateText: '/mois'
|
|
28
|
+
},
|
|
29
|
+
secondaryPrice: {
|
|
30
|
+
price: '',
|
|
31
|
+
signDirection: 'right',
|
|
32
|
+
rateText: "d'acompte"
|
|
33
|
+
},
|
|
34
|
+
term: '24 mois | TAP de 0% | avec Option retour',
|
|
35
|
+
buttonLabel: 'Sélectionner ce téléphone',
|
|
36
|
+
selectedButtonLabel: 'Téléphone sélectionné'
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
import { View } from 'react-native'
|
|
4
|
+
import { selectSystemProps, htmlAttrs, viewProps, a11yProps } from '../utils'
|
|
5
|
+
|
|
6
|
+
import ProductCard from '../ProductCard'
|
|
7
|
+
import { StackWrap } from '../StackView'
|
|
8
|
+
|
|
9
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs, viewProps, a11yProps])
|
|
10
|
+
|
|
11
|
+
const ProductCardGroup = ({ productCards, maxSelection = 1, ...rest }) => {
|
|
12
|
+
const [selectedCardIds, setSelectedCardIds] = useState([])
|
|
13
|
+
|
|
14
|
+
const handleSelect = (id) => {
|
|
15
|
+
const isAlreadySelected = selectedCardIds.includes(id)
|
|
16
|
+
let updatedSelectedCardIds
|
|
17
|
+
|
|
18
|
+
if (isAlreadySelected) {
|
|
19
|
+
updatedSelectedCardIds = selectedCardIds.filter((cardId) => cardId !== id)
|
|
20
|
+
} else if (maxSelection && selectedCardIds.length >= maxSelection) {
|
|
21
|
+
updatedSelectedCardIds = selectedCardIds.filter((_, index) => index !== 0).concat(id)
|
|
22
|
+
} else {
|
|
23
|
+
updatedSelectedCardIds = [...selectedCardIds, id]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
setSelectedCardIds(updatedSelectedCardIds)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<View {...selectProps(rest)}>
|
|
31
|
+
<StackWrap direction={{ xs: 'column', lg: 'row' }} space={4}>
|
|
32
|
+
{productCards.map((cardProperties, index) => {
|
|
33
|
+
const cardId = cardProperties.id || index
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<View key={cardId}>
|
|
37
|
+
<ProductCard
|
|
38
|
+
key={cardId}
|
|
39
|
+
cardId={cardId}
|
|
40
|
+
isSelected={selectedCardIds.includes(cardId)}
|
|
41
|
+
onSelect={handleSelect}
|
|
42
|
+
{...cardProperties}
|
|
43
|
+
/>
|
|
44
|
+
</View>
|
|
45
|
+
)
|
|
46
|
+
})}
|
|
47
|
+
</StackWrap>
|
|
48
|
+
</View>
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
ProductCardGroup.displayName = 'ProductCardGroup'
|
|
53
|
+
|
|
54
|
+
ProductCardGroup.propTypes = {
|
|
55
|
+
...selectedSystemPropTypes,
|
|
56
|
+
/**
|
|
57
|
+
* The maximum number of ProductCards a user may select at once. Defaults to 1.
|
|
58
|
+
* To have no limit and allow any number of selections, pass `null`.
|
|
59
|
+
*/
|
|
60
|
+
maxSelection: PropTypes.number,
|
|
61
|
+
/**
|
|
62
|
+
* Props to be passed to the `ProductCard` component.
|
|
63
|
+
* id is required for each card.
|
|
64
|
+
* You may also pass in a custom dictionary object.
|
|
65
|
+
*/
|
|
66
|
+
productCards: PropTypes.arrayOf(
|
|
67
|
+
PropTypes.shape({
|
|
68
|
+
id: PropTypes.string.isRequired,
|
|
69
|
+
image: PropTypes.object,
|
|
70
|
+
dictionary: PropTypes.object
|
|
71
|
+
})
|
|
72
|
+
).isRequired
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export default ProductCardGroup
|
package/src/index.js
CHANGED
|
@@ -33,6 +33,8 @@ export { default as Notification } from './Notification'
|
|
|
33
33
|
export { default as OrderedList } from './OrderedList'
|
|
34
34
|
export { default as Pagination } from './Pagination'
|
|
35
35
|
export { default as PriceLockup } from './PriceLockup'
|
|
36
|
+
export { default as ProductCard } from './ProductCard'
|
|
37
|
+
export { default as ProductCardGroup } from './ProductCardGroup'
|
|
36
38
|
export { default as Progress } from './Progress'
|
|
37
39
|
export { default as QuickLinks } from './QuickLinks'
|
|
38
40
|
export { default as QuickLinksFeature } from './QuickLinksFeature'
|