@telus-uds/components-base 1.73.0 → 1.75.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 +27 -3
- package/lib/ExpandCollapse/Panel.js +1 -1
- package/lib/Footnote/Footnote.js +328 -0
- package/lib/Footnote/FootnoteLink.js +108 -0
- package/lib/Footnote/dictionary.js +19 -0
- package/lib/Footnote/index.js +12 -0
- package/lib/Notification/Notification.js +213 -35
- package/lib/Responsive/Responsive.js +8 -0
- package/lib/Responsive/ResponsiveWithMediaQueryStyleSheet.js +6 -3
- package/lib/Typography/Typography.js +3 -1
- package/lib/index.js +8 -0
- package/lib/utils/ssr-media-query/create-stylesheet/index.js +1 -2
- package/lib-module/ExpandCollapse/Panel.js +1 -1
- package/lib-module/Footnote/Footnote.js +319 -0
- package/lib-module/Footnote/FootnoteLink.js +101 -0
- package/lib-module/Footnote/dictionary.js +12 -0
- package/lib-module/Footnote/index.js +4 -0
- package/lib-module/Notification/Notification.js +216 -38
- package/lib-module/Responsive/Responsive.js +8 -0
- package/lib-module/Responsive/ResponsiveWithMediaQueryStyleSheet.js +6 -3
- package/lib-module/Typography/Typography.js +3 -1
- package/lib-module/index.js +1 -0
- package/lib-module/utils/ssr-media-query/create-stylesheet/index.js +1 -2
- package/package.json +2 -2
- package/src/ExpandCollapse/Panel.jsx +1 -1
- package/src/Footnote/Footnote.jsx +316 -0
- package/src/Footnote/FootnoteLink.jsx +95 -0
- package/src/Footnote/dictionary.js +12 -0
- package/src/Footnote/index.js +6 -0
- package/src/Notification/Notification.jsx +213 -34
- package/src/Responsive/Responsive.jsx +8 -2
- package/src/Responsive/ResponsiveWithMediaQueryStyleSheet.jsx +6 -4
- package/src/Typography/Typography.jsx +6 -1
- package/src/index.js +1 -0
- package/src/utils/ssr-media-query/create-stylesheet/index.js +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,19 +1,43 @@
|
|
|
1
1
|
# Change Log - @telus-uds/components-base
|
|
2
2
|
|
|
3
|
-
This log was last generated on Mon,
|
|
3
|
+
This log was last generated on Mon, 29 Jan 2024 18:26:01 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 1.75.0
|
|
8
|
+
|
|
9
|
+
Mon, 29 Jan 2024 18:26:01 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- Styles changed in notification component to be SSR (35577399+JoshHC@users.noreply.github.com)
|
|
14
|
+
- Bump @telus-uds/system-theme-tokens to v2.50.1
|
|
15
|
+
|
|
16
|
+
## 1.74.0
|
|
17
|
+
|
|
18
|
+
Thu, 18 Jan 2024 22:55:53 GMT
|
|
19
|
+
|
|
20
|
+
### Minor changes
|
|
21
|
+
|
|
22
|
+
- refactor footnote component for multi-platform (guillermo.peitzner@telus.com)
|
|
23
|
+
- introducing inheritedStyles prop for responsive (srikanthkhari@gmail.com)
|
|
24
|
+
- Bump @telus-uds/system-theme-tokens to v2.50.0
|
|
25
|
+
|
|
26
|
+
### Patches
|
|
27
|
+
|
|
28
|
+
- expandcollapse doesn't expand in react native (guillermo.peitzner@telus.com)
|
|
29
|
+
- Typography ignoring viewport-based theme rules with enableMediaQueryStylesheet set to false Fixed. (srikanthkhari@gmail.com)
|
|
30
|
+
|
|
7
31
|
## 1.73.0
|
|
8
32
|
|
|
9
|
-
Mon, 08 Jan 2024 20:
|
|
33
|
+
Mon, 08 Jan 2024 20:16:06 GMT
|
|
10
34
|
|
|
11
35
|
### Minor changes
|
|
12
36
|
|
|
13
37
|
- RNMQ integration to Responsive component (srikanthkhari@gmail.com)
|
|
14
38
|
- Changes in the Notification component (35577399+JoshHC@users.noreply.github.com)
|
|
15
39
|
- Support server component (wlsdud194@hotmail.com)
|
|
16
|
-
- Changes to the box component for allow gradient in mobile
|
|
40
|
+
- Changes to the box component for allow gradient in mobile (35577399+JoshHC@users.noreply.github.com)
|
|
17
41
|
- update story for badge to include subtle variant (evander.owusu@telus.com)
|
|
18
42
|
- Bump @telus-uds/system-theme-tokens to v2.49.0
|
|
19
43
|
|
|
@@ -174,7 +174,7 @@ const ExpandCollapsePanel = /*#__PURE__*/(0, _react.forwardRef)((_ref4, ref) =>
|
|
|
174
174
|
},
|
|
175
175
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
176
176
|
style: selectContainerStyles(themeTokens),
|
|
177
|
-
children:
|
|
177
|
+
children: children
|
|
178
178
|
})
|
|
179
179
|
})
|
|
180
180
|
})]
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
|
|
10
|
+
var _Text = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Text"));
|
|
11
|
+
var _Dimensions = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Dimensions"));
|
|
12
|
+
var _TouchableWithoutFeedback = _interopRequireDefault(require("react-native-web/dist/cjs/exports/TouchableWithoutFeedback"));
|
|
13
|
+
var _Modal = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Modal"));
|
|
14
|
+
var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
|
|
15
|
+
var _SafeAreaView = _interopRequireDefault(require("react-native-web/dist/cjs/exports/SafeAreaView"));
|
|
16
|
+
var _ScrollView = _interopRequireDefault(require("react-native-web/dist/cjs/exports/ScrollView"));
|
|
17
|
+
var _dictionary = _interopRequireDefault(require("./dictionary"));
|
|
18
|
+
var _utils = require("../utils");
|
|
19
|
+
var _ViewportProvider = require("../ViewportProvider");
|
|
20
|
+
var _ThemeProvider = require("../ThemeProvider");
|
|
21
|
+
var _Typography = _interopRequireDefault(require("../Typography"));
|
|
22
|
+
var _Icon = _interopRequireDefault(require("../Icon"));
|
|
23
|
+
var _OrderedList = _interopRequireDefault(require("../OrderedList"));
|
|
24
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
25
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
26
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
27
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
28
|
+
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.htmlAttrs, _utils.viewProps]);
|
|
29
|
+
const selectFootnoteStyle = _ref => {
|
|
30
|
+
let {
|
|
31
|
+
screenHeight,
|
|
32
|
+
footnoteBackground,
|
|
33
|
+
isVisible,
|
|
34
|
+
footnoteBorderTopSizeMd,
|
|
35
|
+
footnoteBorderColorMd
|
|
36
|
+
} = _ref;
|
|
37
|
+
return {
|
|
38
|
+
left: 0,
|
|
39
|
+
backgroundColor: footnoteBackground,
|
|
40
|
+
display: isVisible ? 'flex' : 'none',
|
|
41
|
+
height: screenHeight,
|
|
42
|
+
borderTopColor: footnoteBorderColorMd,
|
|
43
|
+
borderTopWidth: footnoteBorderTopSizeMd
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
const selectFootnoteHeaderContentStyle = _ref2 => {
|
|
47
|
+
let {
|
|
48
|
+
footnoteHeaderPaddingTop,
|
|
49
|
+
footnoteHeaderPaddingBottom,
|
|
50
|
+
footnoteHeaderPaddingRight,
|
|
51
|
+
footnoteHeaderPaddingLeft,
|
|
52
|
+
headerMargin
|
|
53
|
+
} = _ref2;
|
|
54
|
+
return {
|
|
55
|
+
paddingTop: footnoteHeaderPaddingTop,
|
|
56
|
+
paddingBottom: footnoteHeaderPaddingBottom,
|
|
57
|
+
paddingRight: footnoteHeaderPaddingRight,
|
|
58
|
+
paddingLeft: footnoteHeaderPaddingLeft,
|
|
59
|
+
marginRight: headerMargin
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
const selectFootnoteCloseButtonStyle = _ref3 => {
|
|
63
|
+
let {
|
|
64
|
+
closeButtonBorderSize,
|
|
65
|
+
closeButtonBorderColor,
|
|
66
|
+
closeButtonHeight,
|
|
67
|
+
closeButtonBackgroundColor,
|
|
68
|
+
closeButtonMarginTop,
|
|
69
|
+
closeButtonMarginRight,
|
|
70
|
+
closeButtonMarginBottom,
|
|
71
|
+
closeButtonMarginLeft,
|
|
72
|
+
closeButtonWidth
|
|
73
|
+
} = _ref3;
|
|
74
|
+
return {
|
|
75
|
+
backgroundColor: closeButtonBackgroundColor,
|
|
76
|
+
borderWidth: closeButtonBorderSize,
|
|
77
|
+
borderColor: closeButtonBorderColor,
|
|
78
|
+
height: closeButtonHeight,
|
|
79
|
+
marginTop: closeButtonMarginTop,
|
|
80
|
+
marginRight: closeButtonMarginRight,
|
|
81
|
+
marginBottom: closeButtonMarginBottom,
|
|
82
|
+
marginLeft: closeButtonMarginLeft,
|
|
83
|
+
width: closeButtonWidth
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
const selectFootnoteBodyStyle = _ref4 => {
|
|
87
|
+
let {
|
|
88
|
+
maxWidth,
|
|
89
|
+
footnoteBodyBackground,
|
|
90
|
+
footnoteBodyPaddingTop,
|
|
91
|
+
footnoteBodyPaddingRight,
|
|
92
|
+
footnoteBodyPaddingBottom,
|
|
93
|
+
footnoteBodyPaddingLeft,
|
|
94
|
+
screenWidth
|
|
95
|
+
} = _ref4;
|
|
96
|
+
return {
|
|
97
|
+
maxWidth,
|
|
98
|
+
backgroundColor: footnoteBodyBackground,
|
|
99
|
+
paddingTop: footnoteBodyPaddingTop,
|
|
100
|
+
paddingRight: footnoteBodyPaddingRight * 2,
|
|
101
|
+
paddingBottom: footnoteBodyPaddingBottom,
|
|
102
|
+
paddingLeft: footnoteBodyPaddingLeft,
|
|
103
|
+
width: screenWidth
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
const selectCustomContentFontStyle = _ref5 => {
|
|
107
|
+
let {
|
|
108
|
+
listItemColor,
|
|
109
|
+
listItemFontSize,
|
|
110
|
+
listItemLineHeight,
|
|
111
|
+
listItemPaddingLeft,
|
|
112
|
+
listItemFontName,
|
|
113
|
+
listItemFontWeight
|
|
114
|
+
} = _ref5;
|
|
115
|
+
return {
|
|
116
|
+
fontSize: listItemFontSize,
|
|
117
|
+
lineHeight: listItemLineHeight * listItemFontSize,
|
|
118
|
+
paddingLeft: listItemPaddingLeft,
|
|
119
|
+
color: listItemColor,
|
|
120
|
+
fontName: listItemFontName,
|
|
121
|
+
fontWeight: listItemFontWeight
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Use `Footnote` to display a single legal content.
|
|
127
|
+
*
|
|
128
|
+
* ## Usage Criteria
|
|
129
|
+
*
|
|
130
|
+
* - Use `Footnote` to display a single legal statement
|
|
131
|
+
* - Display on top of all UI, including other sticky elements such as Cart Summary
|
|
132
|
+
* - Dismiss by clicking on the close button, clicking anywhere outside of the `Footnote`
|
|
133
|
+
* - Use copy to set language, ‘en’ for English or ‘fr’ for French
|
|
134
|
+
*
|
|
135
|
+
* ## Accessibility requirements
|
|
136
|
+
*
|
|
137
|
+
* - Only one instance of `Footnote` should display at a time
|
|
138
|
+
* - Place `Footnote` as the last element in the body or main
|
|
139
|
+
* - When `Footnote` is open, the inert prop must be set on all children of body excluding the Footnote
|
|
140
|
+
* - When `Footnote` is closed, focus must return to the initiating element
|
|
141
|
+
*/
|
|
142
|
+
const Footnote = _ref6 => {
|
|
143
|
+
let {
|
|
144
|
+
copy = 'en',
|
|
145
|
+
number = undefined,
|
|
146
|
+
content = undefined,
|
|
147
|
+
onClose,
|
|
148
|
+
isOpen = false,
|
|
149
|
+
tokens,
|
|
150
|
+
variant = {},
|
|
151
|
+
dictionary = _dictionary.default,
|
|
152
|
+
...rest
|
|
153
|
+
} = _ref6;
|
|
154
|
+
const viewport = (0, _ViewportProvider.useViewport)();
|
|
155
|
+
const themeTokens = (0, _ThemeProvider.useThemeTokens)('Footnote', tokens, variant, {
|
|
156
|
+
viewport
|
|
157
|
+
});
|
|
158
|
+
const themeOptions = (0, _ThemeProvider.useTheme)();
|
|
159
|
+
const getCopy = (0, _utils.useCopy)({
|
|
160
|
+
dictionary,
|
|
161
|
+
copy
|
|
162
|
+
});
|
|
163
|
+
const [isVisible, setIsVisible] = (0, _react.useState)(false);
|
|
164
|
+
const screenHeight = _Dimensions.default.get('screen').height;
|
|
165
|
+
const screenWidth = _Dimensions.default.get('screen').width;
|
|
166
|
+
const getFootnoteBodyContent = (0, _react.useCallback)(() => {
|
|
167
|
+
if (!number || !content) {
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
if ( /*#__PURE__*/_react.default.isValidElement(content)) {
|
|
171
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
172
|
+
style: selectCustomContentFontStyle(themeTokens),
|
|
173
|
+
children: content
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
return (
|
|
177
|
+
/*#__PURE__*/
|
|
178
|
+
// TODO: Extract the OrderedList.Item from the array when the issue #4361 is fixed
|
|
179
|
+
(0, _jsxRuntime.jsx)(_OrderedList.default, {
|
|
180
|
+
start: number,
|
|
181
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_OrderedList.default.Item, {
|
|
182
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
|
|
183
|
+
style: selectCustomContentFontStyle(themeTokens),
|
|
184
|
+
children: content
|
|
185
|
+
})
|
|
186
|
+
}, number)]
|
|
187
|
+
})
|
|
188
|
+
);
|
|
189
|
+
}, [content, number, themeTokens]);
|
|
190
|
+
(0, _react.useEffect)(() => {
|
|
191
|
+
if (isOpen) {
|
|
192
|
+
setIsVisible(true);
|
|
193
|
+
}
|
|
194
|
+
}, [isOpen]);
|
|
195
|
+
const closeFootnote = (0, _react.useCallback)((event, options) => {
|
|
196
|
+
onClose(event, options);
|
|
197
|
+
setIsVisible(false);
|
|
198
|
+
}, [onClose]);
|
|
199
|
+
const handleClose = event => closeFootnote(event, {
|
|
200
|
+
returnFocus: true
|
|
201
|
+
});
|
|
202
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
203
|
+
...selectProps(rest),
|
|
204
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Modal.default, {
|
|
205
|
+
visible: isVisible,
|
|
206
|
+
animationType: "slide",
|
|
207
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_SafeAreaView.default, {
|
|
208
|
+
style: staticStyles.container,
|
|
209
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScrollView.default, {
|
|
210
|
+
style: selectFootnoteStyle({
|
|
211
|
+
screenHeight,
|
|
212
|
+
isVisible,
|
|
213
|
+
...themeTokens
|
|
214
|
+
}),
|
|
215
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
|
|
216
|
+
style: staticStyles.content,
|
|
217
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
|
|
218
|
+
style: [selectFootnoteHeaderContentStyle(themeTokens), staticStyles.headerContent],
|
|
219
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
220
|
+
tokens: {
|
|
221
|
+
fontSize: themeTokens === null || themeTokens === void 0 ? void 0 : themeTokens.headerFontSize,
|
|
222
|
+
lineHeight: themeTokens === null || themeTokens === void 0 ? void 0 : themeTokens.headerLineHeight
|
|
223
|
+
},
|
|
224
|
+
variant: {
|
|
225
|
+
size: 'h4'
|
|
226
|
+
},
|
|
227
|
+
children: getCopy('heading')
|
|
228
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_TouchableWithoutFeedback.default, {
|
|
229
|
+
onPress: handleClose,
|
|
230
|
+
accessibilityLabel: getCopy('close'),
|
|
231
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
232
|
+
style: [selectFootnoteCloseButtonStyle(themeTokens), staticStyles.closeButton],
|
|
233
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.default, {
|
|
234
|
+
icon: themeTokens === null || themeTokens === void 0 ? void 0 : themeTokens.closeIcon,
|
|
235
|
+
tokens: {
|
|
236
|
+
size: themeTokens === null || themeTokens === void 0 ? void 0 : themeTokens.closeButtonIconSize
|
|
237
|
+
}
|
|
238
|
+
})
|
|
239
|
+
})
|
|
240
|
+
})]
|
|
241
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
242
|
+
style: selectFootnoteBodyStyle({
|
|
243
|
+
maxWidth: themeOptions.contentMaxWidth,
|
|
244
|
+
screenWidth,
|
|
245
|
+
...themeTokens
|
|
246
|
+
}),
|
|
247
|
+
children: getFootnoteBodyContent()
|
|
248
|
+
})]
|
|
249
|
+
})
|
|
250
|
+
})
|
|
251
|
+
})
|
|
252
|
+
})
|
|
253
|
+
});
|
|
254
|
+
};
|
|
255
|
+
const copyShape = _propTypes.default.shape({
|
|
256
|
+
close: _propTypes.default.string.isRequired,
|
|
257
|
+
heading: _propTypes.default.string.isRequired
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
// If a language dictionary entry is provided, it must contain every key
|
|
261
|
+
const dictionaryContentShape = _propTypes.default.shape({
|
|
262
|
+
a11yLabel: _propTypes.default.string.isRequired,
|
|
263
|
+
close: _propTypes.default.string.isRequired,
|
|
264
|
+
heading: _propTypes.default.string.isRequired
|
|
265
|
+
});
|
|
266
|
+
Footnote.propTypes = {
|
|
267
|
+
...selectedSystemPropTypes,
|
|
268
|
+
tokens: (0, _utils.getTokensPropType)('Footnote'),
|
|
269
|
+
/**
|
|
270
|
+
* The content.
|
|
271
|
+
*/
|
|
272
|
+
content: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.element]),
|
|
273
|
+
/**
|
|
274
|
+
* Use the `copy` prop to either select provided English or French copy by passing 'en' or 'fr' respectively.
|
|
275
|
+
* To provide your own, pass a JSON object with the keys `heading` and `close`.
|
|
276
|
+
*/
|
|
277
|
+
copy: _propTypes.default.oneOfType([_propTypes.default.oneOf(['en', 'fr']), copyShape]),
|
|
278
|
+
/**
|
|
279
|
+
* A boolean flag used hide or show the `Footnote`. Set to `true` to open the `Footnote`.
|
|
280
|
+
*/
|
|
281
|
+
isOpen: _propTypes.default.bool,
|
|
282
|
+
/**
|
|
283
|
+
* The number, must match the number of the `FootnoteLink` that initiated the `Footnote`.
|
|
284
|
+
*/
|
|
285
|
+
number: _propTypes.default.number,
|
|
286
|
+
/**
|
|
287
|
+
* A callback function to handle the closing of the footnote.
|
|
288
|
+
*
|
|
289
|
+
* @param {SyntheticEvent} event The React `SyntheticEvent`
|
|
290
|
+
* @param {Object} options Custom options
|
|
291
|
+
* @param {boolean} options.returnFocus Should the `Footnote` return focus on close
|
|
292
|
+
*/
|
|
293
|
+
onClose: _propTypes.default.func.isRequired,
|
|
294
|
+
/**
|
|
295
|
+
* Override the default dictionary, by passing the complete dictionary object for `en` and `fr`
|
|
296
|
+
*/
|
|
297
|
+
dictionary: _propTypes.default.shape({
|
|
298
|
+
en: dictionaryContentShape,
|
|
299
|
+
fr: dictionaryContentShape
|
|
300
|
+
})
|
|
301
|
+
};
|
|
302
|
+
var _default = Footnote;
|
|
303
|
+
exports.default = _default;
|
|
304
|
+
const staticStyles = _StyleSheet.default.create({
|
|
305
|
+
container: {
|
|
306
|
+
flex: 1
|
|
307
|
+
},
|
|
308
|
+
content: {
|
|
309
|
+
marginLeft: 'auto',
|
|
310
|
+
marginRight: 'auto',
|
|
311
|
+
left: 0,
|
|
312
|
+
right: 0,
|
|
313
|
+
maxWidth: 1200,
|
|
314
|
+
paddingBottom: 100
|
|
315
|
+
},
|
|
316
|
+
headerContent: {
|
|
317
|
+
alignItems: 'center',
|
|
318
|
+
display: 'flex',
|
|
319
|
+
flexDirection: 'row',
|
|
320
|
+
justifyContent: 'space-between'
|
|
321
|
+
},
|
|
322
|
+
closeButton: {
|
|
323
|
+
alignItems: 'center',
|
|
324
|
+
borderRadius: 50,
|
|
325
|
+
display: 'flex',
|
|
326
|
+
justifyContent: 'center'
|
|
327
|
+
}
|
|
328
|
+
});
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
|
|
10
|
+
var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
|
|
11
|
+
var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
|
|
12
|
+
var _TouchableWithoutFeedback = _interopRequireDefault(require("react-native-web/dist/cjs/exports/TouchableWithoutFeedback"));
|
|
13
|
+
var _dictionary = _interopRequireDefault(require("./dictionary"));
|
|
14
|
+
var _utils = require("../utils");
|
|
15
|
+
var _ThemeProvider = require("../ThemeProvider");
|
|
16
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
+
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.htmlAttrs, _utils.viewProps]);
|
|
19
|
+
|
|
20
|
+
// The top property varies between devices due to how devices render the viewport.
|
|
21
|
+
const selectTextStyle = _ref => {
|
|
22
|
+
let {
|
|
23
|
+
fontSize,
|
|
24
|
+
lineHeight
|
|
25
|
+
} = _ref;
|
|
26
|
+
return {
|
|
27
|
+
fontSize,
|
|
28
|
+
lineHeight: lineHeight !== 1 ? lineHeight : fontSize * 2,
|
|
29
|
+
..._Platform.default.select({
|
|
30
|
+
ios: {
|
|
31
|
+
top: -fontSize / 2
|
|
32
|
+
},
|
|
33
|
+
android: {
|
|
34
|
+
top: fontSize / 4
|
|
35
|
+
},
|
|
36
|
+
web: {
|
|
37
|
+
top: -fontSize / 2.8
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
const FootnoteLink = _ref2 => {
|
|
43
|
+
let {
|
|
44
|
+
copy = 'en',
|
|
45
|
+
content = [],
|
|
46
|
+
onClick,
|
|
47
|
+
tokens,
|
|
48
|
+
variant = {},
|
|
49
|
+
...rest
|
|
50
|
+
} = _ref2;
|
|
51
|
+
const themeTokens = (0, _ThemeProvider.useThemeTokens)('FootnoteLink', tokens, variant);
|
|
52
|
+
const textStyles = (0, _ThemeProvider.applyTextStyles)(themeTokens);
|
|
53
|
+
const numbers = Array.isArray(content) ? content : [content];
|
|
54
|
+
const refs = numbers.map(() => /*#__PURE__*/_react.default.createRef());
|
|
55
|
+
const handleOnClick = index => {
|
|
56
|
+
onClick(numbers[index], refs[index]);
|
|
57
|
+
};
|
|
58
|
+
const getCopy = (0, _utils.useCopy)({
|
|
59
|
+
dictionary: _dictionary.default,
|
|
60
|
+
copy
|
|
61
|
+
});
|
|
62
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
63
|
+
children: numbers.map((num, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
64
|
+
accessibilityLabel: getCopy('a11yLabel'),
|
|
65
|
+
ref: refs[index],
|
|
66
|
+
...selectProps(rest),
|
|
67
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_TouchableWithoutFeedback.default, {
|
|
68
|
+
onPress: handleOnClick,
|
|
69
|
+
accessibilityRole: "button",
|
|
70
|
+
children: (0, _utils.wrapStringsInText)(`${num}${index !== numbers.length - 1 ? ',' : ''}`, {
|
|
71
|
+
style: {
|
|
72
|
+
...textStyles,
|
|
73
|
+
...staticStyles.text,
|
|
74
|
+
...selectTextStyle(themeTokens)
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
})
|
|
78
|
+
}, num))
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
const copyShape = _propTypes.default.shape({
|
|
82
|
+
a11yLabel: _propTypes.default.string.isRequired
|
|
83
|
+
});
|
|
84
|
+
FootnoteLink.propTypes = {
|
|
85
|
+
...selectedSystemPropTypes,
|
|
86
|
+
/**
|
|
87
|
+
* Use the `copy` prop to either select provided English or French copy by passing 'en' or 'fr' respectively.
|
|
88
|
+
* To provide your own, pass a JSON object with the key `a11yLabel`.
|
|
89
|
+
*/
|
|
90
|
+
copy: _propTypes.default.oneOfType([_propTypes.default.oneOf(['en', 'fr']), copyShape]),
|
|
91
|
+
/**
|
|
92
|
+
* The footnote number, or multiple numbers if passed as an array.
|
|
93
|
+
* If using an array, a comma-separated group of numbers will be rendered as superscript.
|
|
94
|
+
*/
|
|
95
|
+
content: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.arrayOf(_propTypes.default.number), _propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]).isRequired,
|
|
96
|
+
/**
|
|
97
|
+
* A callback function to handle the click of a FootnoteLink.
|
|
98
|
+
*/
|
|
99
|
+
onClick: _propTypes.default.func.isRequired
|
|
100
|
+
};
|
|
101
|
+
var _default = FootnoteLink;
|
|
102
|
+
exports.default = _default;
|
|
103
|
+
const staticStyles = _StyleSheet.default.create({
|
|
104
|
+
text: {
|
|
105
|
+
position: 'relative',
|
|
106
|
+
textDecorationLine: 'underline'
|
|
107
|
+
}
|
|
108
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = {
|
|
8
|
+
en: {
|
|
9
|
+
a11yLabel: 'Read legal footnote',
|
|
10
|
+
close: 'close',
|
|
11
|
+
heading: 'Terms and conditions'
|
|
12
|
+
},
|
|
13
|
+
fr: {
|
|
14
|
+
a11yLabel: 'Lire la note de bas de page légale',
|
|
15
|
+
close: 'fermer',
|
|
16
|
+
heading: 'Modalités et conditions'
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
exports.default = _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _Footnote = _interopRequireDefault(require("./Footnote"));
|
|
8
|
+
var _FootnoteLink = _interopRequireDefault(require("./FootnoteLink"));
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
_Footnote.default.Link = _FootnoteLink.default;
|
|
11
|
+
var _default = _Footnote.default;
|
|
12
|
+
exports.default = _default;
|