@telus-uds/components-web 2.26.0 → 2.28.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 +31 -2
- package/lib/DatePicker/DatePicker.js +129 -69
- package/lib/Image/Image.js +20 -44
- package/lib/Image/index.js +11 -1
- package/lib/Image/server.js +12 -0
- package/lib/OptimizeImage/OptimizeImage.js +1 -1
- package/lib/OptimizeImage/utils/getFallbackUrl.js +2 -2
- package/lib/Table/Cell.js +14 -5
- package/lib/baseExports.js +6 -0
- package/lib/index.js +12 -2
- package/lib/server.js +13 -0
- package/lib/utils/theming/get-theme-from-server.js +24 -0
- package/lib/utils/theming/with-client-theme.js +32 -0
- package/lib/utils/theming/with-server-theme.js +34 -0
- package/lib-module/DatePicker/DatePicker.js +132 -72
- package/lib-module/Image/Image.js +17 -41
- package/lib-module/Image/index.js +6 -1
- package/lib-module/Image/server.js +4 -0
- package/lib-module/OptimizeImage/OptimizeImage.js +1 -1
- package/lib-module/OptimizeImage/utils/getFallbackUrl.js +2 -2
- package/lib-module/Table/Cell.js +14 -5
- package/lib-module/baseExports.js +1 -1
- package/lib-module/index.js +3 -1
- package/lib-module/server.js +5 -0
- package/lib-module/utils/theming/get-theme-from-server.js +16 -0
- package/lib-module/utils/theming/with-client-theme.js +24 -0
- package/lib-module/utils/theming/with-server-theme.js +26 -0
- package/package.json +25 -4
- package/src/DatePicker/DatePicker.jsx +125 -63
- package/src/Image/Image.jsx +15 -24
- package/src/Image/index.js +6 -1
- package/src/Image/server.js +5 -0
- package/src/OptimizeImage/OptimizeImage.jsx +1 -1
- package/src/OptimizeImage/utils/getFallbackUrl.js +2 -2
- package/src/Table/Cell.jsx +9 -2
- package/src/baseExports.js +1 -0
- package/src/index.js +3 -1
- package/src/server.js +5 -0
- package/src/utils/theming/get-theme-from-server.js +22 -0
- package/src/utils/theming/with-client-theme.jsx +20 -0
- package/src/utils/theming/with-server-theme.jsx +21 -0
- package/types/WebVideo.d.ts +4 -3
|
@@ -0,0 +1,32 @@
|
|
|
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 _componentsBase = require("@telus-uds/components-base");
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
const withClientTheme = Component => {
|
|
13
|
+
const UdsStyledComponent = _ref => {
|
|
14
|
+
let {
|
|
15
|
+
tokens: tokenOverrides,
|
|
16
|
+
variant,
|
|
17
|
+
...props
|
|
18
|
+
} = _ref;
|
|
19
|
+
const theme = (0, _componentsBase.useThemeTokens)(Component.displayName, variant, tokenOverrides);
|
|
20
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
|
|
21
|
+
theme: theme,
|
|
22
|
+
...props
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
UdsStyledComponent.propTypes = {
|
|
26
|
+
tokens: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object]),
|
|
27
|
+
variant: _propTypes.default.string
|
|
28
|
+
};
|
|
29
|
+
return UdsStyledComponent;
|
|
30
|
+
};
|
|
31
|
+
var _default = withClientTheme;
|
|
32
|
+
exports.default = _default;
|
|
@@ -0,0 +1,34 @@
|
|
|
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 _server = require("@telus-uds/components-base/server");
|
|
10
|
+
var _getThemeFromServer = _interopRequireDefault(require("./get-theme-from-server"));
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
const withServerTheme = (Component, componentName) => {
|
|
14
|
+
const UdsStyledComponent = async _ref => {
|
|
15
|
+
let {
|
|
16
|
+
tokens: tokenOverrides,
|
|
17
|
+
variant,
|
|
18
|
+
...props
|
|
19
|
+
} = _ref;
|
|
20
|
+
const componentTheme = await (0, _getThemeFromServer.default)(componentName);
|
|
21
|
+
const themeTokens = (0, _server.getThemeTokens)(componentTheme, tokenOverrides, variant);
|
|
22
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
|
|
23
|
+
theme: themeTokens,
|
|
24
|
+
...props
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
UdsStyledComponent.propTypes = {
|
|
28
|
+
tokens: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object]),
|
|
29
|
+
variant: _propTypes.default.string
|
|
30
|
+
};
|
|
31
|
+
return UdsStyledComponent;
|
|
32
|
+
};
|
|
33
|
+
var _default = withServerTheme;
|
|
34
|
+
exports.default = _default;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import React, { forwardRef, useEffect, useState } from 'react';
|
|
1
|
+
import React, { forwardRef, useEffect, useState, useRef } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import momentPropTypes from 'react-moment-proptypes';
|
|
5
5
|
import 'react-dates/initialize';
|
|
6
6
|
import SingleDatePicker from 'react-dates/lib/components/SingleDatePicker';
|
|
7
7
|
import DayPickerSingleDateController from 'react-dates/lib/components/DayPickerSingleDateController';
|
|
8
|
-
import { IconButton, TextInput, selectSystemProps, useCopy, useViewport, useThemeTokens, applyTextStyles, getTokensPropType } from '@telus-uds/components-base';
|
|
8
|
+
import { IconButton, TextInput, selectSystemProps, useCopy, useViewport, useThemeTokens, applyTextStyles, getTokensPropType, Portal, useSafeLayoutEffect } from '@telus-uds/components-base';
|
|
9
9
|
import moment from 'moment';
|
|
10
|
-
import { isUndefined } from 'lodash';
|
|
10
|
+
import { isUndefined, throttle } from 'lodash';
|
|
11
11
|
import CalendarContainer from './CalendarContainer';
|
|
12
12
|
import dictionary from './dictionary';
|
|
13
13
|
import { htmlAttrs } from '../utils';
|
|
@@ -47,6 +47,24 @@ const DateInputWrapper = /*#__PURE__*/styled.div.withConfig({
|
|
|
47
47
|
display: 'flex',
|
|
48
48
|
flexDirection: 'column'
|
|
49
49
|
});
|
|
50
|
+
const PortalPositionedContainer = /*#__PURE__*/styled.div.withConfig({
|
|
51
|
+
displayName: "DatePicker__PortalPositionedContainer",
|
|
52
|
+
componentId: "components-web__sc-mz8fi3-2"
|
|
53
|
+
})({
|
|
54
|
+
position: 'absolute',
|
|
55
|
+
left: _ref => {
|
|
56
|
+
let {
|
|
57
|
+
left
|
|
58
|
+
} = _ref;
|
|
59
|
+
return `${left}px`;
|
|
60
|
+
},
|
|
61
|
+
top: _ref2 => {
|
|
62
|
+
let {
|
|
63
|
+
top
|
|
64
|
+
} = _ref2;
|
|
65
|
+
return `${top}px`;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
50
68
|
|
|
51
69
|
/**
|
|
52
70
|
* Use DatePicker to select a date on a calendar.
|
|
@@ -69,7 +87,7 @@ const DateInputWrapper = /*#__PURE__*/styled.div.withConfig({
|
|
|
69
87
|
* - Optimized for keyboard interaction and tablet touch
|
|
70
88
|
* - Recommended for viewports greater than or equal to 576px
|
|
71
89
|
*/
|
|
72
|
-
const DatePicker = /*#__PURE__*/forwardRef((
|
|
90
|
+
const DatePicker = /*#__PURE__*/forwardRef((_ref3, ref) => {
|
|
73
91
|
var _dictionary$copy;
|
|
74
92
|
let {
|
|
75
93
|
copy = 'en',
|
|
@@ -90,9 +108,33 @@ const DatePicker = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
90
108
|
prevTestID,
|
|
91
109
|
nextTestID,
|
|
92
110
|
...rest
|
|
93
|
-
} =
|
|
111
|
+
} = _ref3;
|
|
94
112
|
const [inputDate, setInputDate] = useState(date instanceof moment ? date : undefined);
|
|
95
113
|
const [inputText, setInputText] = useState(date instanceof moment ? date.format(dateFormat) : '');
|
|
114
|
+
const textInputRef = useRef();
|
|
115
|
+
const [datePickerPosition, setDatePickerPosition] = useState({
|
|
116
|
+
left: 0,
|
|
117
|
+
top: 0
|
|
118
|
+
});
|
|
119
|
+
useSafeLayoutEffect(() => {
|
|
120
|
+
const updateDimensions = () => {
|
|
121
|
+
if (inline) return;
|
|
122
|
+
const {
|
|
123
|
+
left,
|
|
124
|
+
top
|
|
125
|
+
} = textInputRef.current.getBoundingClientRect();
|
|
126
|
+
setDatePickerPosition({
|
|
127
|
+
left,
|
|
128
|
+
top: top + textInputRef.current.offsetHeight
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
const throttledUpdateDimensions = throttle(updateDimensions, 100, {
|
|
132
|
+
leading: false
|
|
133
|
+
});
|
|
134
|
+
updateDimensions();
|
|
135
|
+
window.addEventListener('resize', throttledUpdateDimensions);
|
|
136
|
+
return () => window.removeEventListener('resize', throttledUpdateDimensions);
|
|
137
|
+
}, []);
|
|
96
138
|
const [isFocused, setIsFocused] = useState(false);
|
|
97
139
|
const [isClickedInside, setIsClickedInside] = useState(false);
|
|
98
140
|
const getCopy = useCopy({
|
|
@@ -109,10 +151,10 @@ const DatePicker = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
109
151
|
setInputText(date instanceof moment ? date.format(dateFormat) : '');
|
|
110
152
|
}
|
|
111
153
|
}, [date, inputDate]);
|
|
112
|
-
const onFocusChange =
|
|
154
|
+
const onFocusChange = _ref4 => {
|
|
113
155
|
let {
|
|
114
156
|
focused
|
|
115
|
-
} =
|
|
157
|
+
} = _ref4;
|
|
116
158
|
if (!isClickedInside) {
|
|
117
159
|
setIsFocused(focused);
|
|
118
160
|
}
|
|
@@ -157,7 +199,7 @@ const DatePicker = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
157
199
|
const circleSize = getResponsiveCircleSize(inline, viewport);
|
|
158
200
|
const HiddenInputFieldContainer = /*#__PURE__*/styled.div.withConfig({
|
|
159
201
|
displayName: "DatePicker__HiddenInputFieldContainer",
|
|
160
|
-
componentId: "components-web__sc-mz8fi3-
|
|
202
|
+
componentId: "components-web__sc-mz8fi3-3"
|
|
161
203
|
})(["height:", ";width:", ";overflow:hidden;"], props => props.height, props => props.width);
|
|
162
204
|
const {
|
|
163
205
|
hiddenInputFieldContainerHeight,
|
|
@@ -183,10 +225,10 @@ const DatePicker = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
183
225
|
fontName: remainingTokens.dayPickerWeekHeaderFontName,
|
|
184
226
|
fontWeight: remainingTokens.dayPickerWeekHeaderFontWeight
|
|
185
227
|
});
|
|
186
|
-
const renderPrevButton =
|
|
228
|
+
const renderPrevButton = _ref5 => {
|
|
187
229
|
let {
|
|
188
230
|
onClick
|
|
189
|
-
} =
|
|
231
|
+
} = _ref5;
|
|
190
232
|
return /*#__PURE__*/_jsx(IconButton, {
|
|
191
233
|
onPress: () => {
|
|
192
234
|
onClick();
|
|
@@ -198,10 +240,10 @@ const DatePicker = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
198
240
|
testID: prevTestID
|
|
199
241
|
});
|
|
200
242
|
};
|
|
201
|
-
const renderNextButton =
|
|
243
|
+
const renderNextButton = _ref6 => {
|
|
202
244
|
let {
|
|
203
245
|
onClick
|
|
204
|
-
} =
|
|
246
|
+
} = _ref6;
|
|
205
247
|
return /*#__PURE__*/_jsx(IconButton, {
|
|
206
248
|
onPress: () => {
|
|
207
249
|
onClick();
|
|
@@ -213,18 +255,7 @@ const DatePicker = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
213
255
|
testID: nextTestID
|
|
214
256
|
});
|
|
215
257
|
};
|
|
216
|
-
return /*#__PURE__*/_jsx(
|
|
217
|
-
...selectProps(rest),
|
|
218
|
-
daySize: daySize,
|
|
219
|
-
validation: validation,
|
|
220
|
-
remainingTokens: {
|
|
221
|
-
...remainingTokens
|
|
222
|
-
},
|
|
223
|
-
calendarDayDefaultHeight: circleSize,
|
|
224
|
-
calendarDayDefaultWidth: circleSize,
|
|
225
|
-
calendarMonthFontTokens: calendarMonthFontTokens,
|
|
226
|
-
calendarWeekFontTokens: calendarWeekFontTokens,
|
|
227
|
-
defaultFontTokens: defaultFontTokens,
|
|
258
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
228
259
|
children: inline ? /*#__PURE__*/_jsxs(_Fragment, {
|
|
229
260
|
children: [/*#__PURE__*/_jsx(HiddenInputFieldContainer, {
|
|
230
261
|
height: hiddenInputFieldContainerHeight,
|
|
@@ -236,68 +267,33 @@ const DatePicker = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
236
267
|
value: inputText,
|
|
237
268
|
readOnly: true
|
|
238
269
|
})
|
|
239
|
-
}), /*#__PURE__*/_jsx(
|
|
240
|
-
|
|
241
|
-
onDateChange: onChange,
|
|
242
|
-
focused: isFocused,
|
|
243
|
-
onFocusChange: onFocusChange,
|
|
244
|
-
numberOfMonths: 1,
|
|
245
|
-
hideKeyboardShortcutsPanel: true,
|
|
246
|
-
keepOpenOnDateSelect: false,
|
|
270
|
+
}), /*#__PURE__*/_jsx(CalendarContainer, {
|
|
271
|
+
...selectProps(rest),
|
|
247
272
|
daySize: daySize,
|
|
248
|
-
renderNavPrevButton: renderPrevButton,
|
|
249
|
-
renderNavNextButton: renderNextButton,
|
|
250
|
-
isOutsideRange: isDayDisabled,
|
|
251
|
-
phrases: getCopy(),
|
|
252
|
-
renderMonthElement: _ref5 => {
|
|
253
|
-
let {
|
|
254
|
-
month
|
|
255
|
-
} = _ref5;
|
|
256
|
-
return /*#__PURE__*/_jsx(MonthCenterContainer, {
|
|
257
|
-
children: /*#__PURE__*/_jsxs("div", {
|
|
258
|
-
children: [dictionary[copy] ? dictionary[copy].months[month.month()] : month.format('MMMM'), ' ', month.year()]
|
|
259
|
-
})
|
|
260
|
-
});
|
|
261
|
-
},
|
|
262
|
-
renderWeekHeaderElement: day => /*#__PURE__*/_jsx("div", {
|
|
263
|
-
children: dictionary[copy] ? dictionary[copy].weekDays[day] : day
|
|
264
|
-
})
|
|
265
|
-
})]
|
|
266
|
-
}) : /*#__PURE__*/_jsx(DateInputWrapper, {
|
|
267
|
-
onMouseDown: handleMouseDown,
|
|
268
|
-
onFocus: handleFocus,
|
|
269
|
-
children: /*#__PURE__*/_jsx(TextInput, {
|
|
270
|
-
copy: copy,
|
|
271
|
-
feedback: feedback,
|
|
272
|
-
hint: hint,
|
|
273
|
-
placeholder: "DD / MM / YYYY",
|
|
274
|
-
onChange: onChangeInput,
|
|
275
|
-
tooltip: tooltip,
|
|
276
|
-
hintPosition: hintPosition,
|
|
277
|
-
label: ((_dictionary$copy = dictionary[copy]) === null || _dictionary$copy === void 0 ? void 0 : _dictionary$copy.roleDescription) ?? label,
|
|
278
|
-
value: inputText,
|
|
279
273
|
validation: validation,
|
|
280
|
-
|
|
281
|
-
|
|
274
|
+
remainingTokens: remainingTokens,
|
|
275
|
+
calendarDayDefaultHeight: circleSize,
|
|
276
|
+
calendarDayDefaultWidth: circleSize,
|
|
277
|
+
calendarMonthFontTokens: calendarMonthFontTokens,
|
|
278
|
+
calendarWeekFontTokens: calendarWeekFontTokens,
|
|
279
|
+
defaultFontTokens: defaultFontTokens,
|
|
280
|
+
children: /*#__PURE__*/_jsx(DayPickerSingleDateController, {
|
|
282
281
|
date: inputDate,
|
|
283
|
-
disabled: disabled,
|
|
284
282
|
onDateChange: onChange,
|
|
285
283
|
focused: isFocused,
|
|
286
284
|
onFocusChange: onFocusChange,
|
|
287
285
|
numberOfMonths: 1,
|
|
288
286
|
hideKeyboardShortcutsPanel: true,
|
|
289
|
-
keepOpenOnDateSelect:
|
|
287
|
+
keepOpenOnDateSelect: false,
|
|
290
288
|
daySize: daySize,
|
|
291
|
-
ref: ref,
|
|
292
289
|
renderNavPrevButton: renderPrevButton,
|
|
290
|
+
renderNavNextButton: renderNextButton,
|
|
293
291
|
isOutsideRange: isDayDisabled,
|
|
294
292
|
phrases: getCopy(),
|
|
295
|
-
|
|
296
|
-
renderNavNextButton: renderNextButton,
|
|
297
|
-
renderMonthElement: _ref6 => {
|
|
293
|
+
renderMonthElement: _ref7 => {
|
|
298
294
|
let {
|
|
299
295
|
month
|
|
300
|
-
} =
|
|
296
|
+
} = _ref7;
|
|
301
297
|
return /*#__PURE__*/_jsx(MonthCenterContainer, {
|
|
302
298
|
children: /*#__PURE__*/_jsxs("div", {
|
|
303
299
|
children: [dictionary[copy] ? dictionary[copy].months[month.month()] : month.format('MMMM'), ' ', month.year()]
|
|
@@ -308,6 +304,70 @@ const DatePicker = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
308
304
|
children: dictionary[copy] ? dictionary[copy].weekDays[day] : day
|
|
309
305
|
})
|
|
310
306
|
})
|
|
307
|
+
})]
|
|
308
|
+
}) : /*#__PURE__*/_jsx(DateInputWrapper, {
|
|
309
|
+
onMouseDown: handleMouseDown,
|
|
310
|
+
onFocus: handleFocus,
|
|
311
|
+
children: /*#__PURE__*/_jsx(TextInput, {
|
|
312
|
+
copy: copy,
|
|
313
|
+
feedback: feedback,
|
|
314
|
+
hint: hint,
|
|
315
|
+
placeholder: "DD / MM / YYYY",
|
|
316
|
+
onChange: onChangeInput,
|
|
317
|
+
tooltip: tooltip,
|
|
318
|
+
hintPosition: hintPosition,
|
|
319
|
+
label: ((_dictionary$copy = dictionary[copy]) === null || _dictionary$copy === void 0 ? void 0 : _dictionary$copy.roleDescription) ?? label,
|
|
320
|
+
value: inputText,
|
|
321
|
+
validation: validation,
|
|
322
|
+
inactive: disabled,
|
|
323
|
+
ref: textInputRef,
|
|
324
|
+
children: /*#__PURE__*/_jsx(Portal, {
|
|
325
|
+
children: /*#__PURE__*/_jsx(PortalPositionedContainer, {
|
|
326
|
+
top: datePickerPosition.top,
|
|
327
|
+
left: datePickerPosition.left,
|
|
328
|
+
children: /*#__PURE__*/_jsx(CalendarContainer, {
|
|
329
|
+
...selectProps(rest),
|
|
330
|
+
daySize: daySize,
|
|
331
|
+
validation: validation,
|
|
332
|
+
remainingTokens: remainingTokens,
|
|
333
|
+
calendarDayDefaultHeight: circleSize,
|
|
334
|
+
calendarDayDefaultWidth: circleSize,
|
|
335
|
+
calendarMonthFontTokens: calendarMonthFontTokens,
|
|
336
|
+
calendarWeekFontTokens: calendarWeekFontTokens,
|
|
337
|
+
defaultFontTokens: defaultFontTokens,
|
|
338
|
+
children: /*#__PURE__*/_jsx(SingleDatePicker, {
|
|
339
|
+
date: inputDate,
|
|
340
|
+
disabled: disabled,
|
|
341
|
+
onDateChange: onChange,
|
|
342
|
+
focused: isFocused,
|
|
343
|
+
onFocusChange: onFocusChange,
|
|
344
|
+
numberOfMonths: 1,
|
|
345
|
+
hideKeyboardShortcutsPanel: true,
|
|
346
|
+
keepOpenOnDateSelect: true,
|
|
347
|
+
daySize: daySize,
|
|
348
|
+
ref: ref,
|
|
349
|
+
renderNavPrevButton: renderPrevButton,
|
|
350
|
+
isOutsideRange: isDayDisabled,
|
|
351
|
+
phrases: getCopy(),
|
|
352
|
+
id: id,
|
|
353
|
+
renderNavNextButton: renderNextButton,
|
|
354
|
+
renderMonthElement: _ref8 => {
|
|
355
|
+
let {
|
|
356
|
+
month
|
|
357
|
+
} = _ref8;
|
|
358
|
+
return /*#__PURE__*/_jsx(MonthCenterContainer, {
|
|
359
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
360
|
+
children: [dictionary[copy] ? dictionary[copy].months[month.month()] : month.format('MMMM'), ' ', month.year()]
|
|
361
|
+
})
|
|
362
|
+
});
|
|
363
|
+
},
|
|
364
|
+
renderWeekHeaderElement: day => /*#__PURE__*/_jsx("div", {
|
|
365
|
+
children: dictionary[copy] ? dictionary[copy].weekDays[day] : day
|
|
366
|
+
})
|
|
367
|
+
})
|
|
368
|
+
})
|
|
369
|
+
})
|
|
370
|
+
})
|
|
311
371
|
})
|
|
312
372
|
})
|
|
313
373
|
});
|
|
@@ -1,38 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import { htmlAttrs, warn } from '../utils';
|
|
3
|
+
import { htmlAttrs, selectSystemProps, getTokensPropType } from '@telus-uds/components-base/server';
|
|
4
|
+
import { warn } from '../utils/logger';
|
|
6
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
6
|
const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs]);
|
|
8
|
-
const
|
|
9
|
-
displayName: "Image__StyledImage",
|
|
10
|
-
componentId: "components-web__sc-blwu4l-0"
|
|
11
|
-
})(_ref => {
|
|
12
|
-
let {
|
|
13
|
-
height
|
|
14
|
-
} = _ref;
|
|
15
|
-
return {
|
|
16
|
-
height: height ?? 'auto',
|
|
17
|
-
maxWidth: '100%'
|
|
18
|
-
};
|
|
19
|
-
});
|
|
20
|
-
const StyledRoundedImage = /*#__PURE__*/styled(StyledImage).withConfig({
|
|
21
|
-
displayName: "Image__StyledRoundedImage",
|
|
22
|
-
componentId: "components-web__sc-blwu4l-1"
|
|
23
|
-
})(["border-radius:", "px;"], _ref2 => {
|
|
24
|
-
let {
|
|
25
|
-
borderRadius
|
|
26
|
-
} = _ref2;
|
|
27
|
-
return borderRadius;
|
|
28
|
-
});
|
|
29
|
-
const StyledCircularImage = /*#__PURE__*/styled(StyledImage).withConfig({
|
|
30
|
-
displayName: "Image__StyledCircularImage",
|
|
31
|
-
componentId: "components-web__sc-blwu4l-2"
|
|
32
|
-
})({
|
|
33
|
-
borderRadius: '50%'
|
|
34
|
-
});
|
|
35
|
-
const Image = _ref3 => {
|
|
7
|
+
const Image = _ref => {
|
|
36
8
|
let {
|
|
37
9
|
src,
|
|
38
10
|
width,
|
|
@@ -41,29 +13,32 @@ const Image = _ref3 => {
|
|
|
41
13
|
rounded,
|
|
42
14
|
loading = 'eager',
|
|
43
15
|
tokens,
|
|
16
|
+
theme,
|
|
44
17
|
variant,
|
|
45
18
|
...rest
|
|
46
|
-
} =
|
|
47
|
-
|
|
19
|
+
} = _ref;
|
|
20
|
+
let {
|
|
48
21
|
borderRadius
|
|
49
|
-
} =
|
|
22
|
+
} = theme;
|
|
50
23
|
const isCircle = rounded === 'circle';
|
|
51
24
|
const isCorners = rounded === 'corners';
|
|
52
25
|
const isSquare = width === height;
|
|
53
26
|
if (isCircle && !isSquare) {
|
|
54
27
|
warn('Image', 'rounded="circle" is not supported for non-square images. Please provide a square image, otherwise the resulting shape will not be a circle.');
|
|
55
28
|
}
|
|
56
|
-
let ImageComponent;
|
|
57
29
|
if (isCircle) {
|
|
58
|
-
|
|
30
|
+
borderRadius = '50%';
|
|
59
31
|
} else if (isCorners) {
|
|
60
|
-
|
|
61
|
-
} else {
|
|
62
|
-
ImageComponent = StyledImage;
|
|
32
|
+
borderRadius = '4px';
|
|
63
33
|
}
|
|
64
|
-
|
|
34
|
+
const style = {
|
|
35
|
+
borderRadius,
|
|
36
|
+
height: height ?? 'auto',
|
|
37
|
+
maxWidth: '100%'
|
|
38
|
+
};
|
|
39
|
+
return /*#__PURE__*/_jsx("img", {
|
|
65
40
|
...selectProps(rest),
|
|
66
|
-
|
|
41
|
+
style: style,
|
|
67
42
|
src: src,
|
|
68
43
|
width: width,
|
|
69
44
|
height: height,
|
|
@@ -102,4 +77,5 @@ Image.propTypes = {
|
|
|
102
77
|
rounded: PropTypes.oneOf(['circle', 'corners']),
|
|
103
78
|
tokens: getTokensPropType('Image')
|
|
104
79
|
};
|
|
80
|
+
Image.displayName = 'Image';
|
|
105
81
|
export default Image;
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import Image from './Image';
|
|
2
|
-
|
|
2
|
+
import withClientTheme from '../utils/theming/with-client-theme';
|
|
3
|
+
|
|
4
|
+
// Exporting the unwrapped component separately for react-docgen to extract info for docsite
|
|
5
|
+
export { Image as DefaultImage };
|
|
6
|
+
const ClientThemedImage = withClientTheme(Image);
|
|
7
|
+
export default ClientThemedImage;
|
|
@@ -33,7 +33,7 @@ const OptimizeImage = _ref => {
|
|
|
33
33
|
mdSrc: getOptimizedUrl(contentfulAssetUrl, dimension, md, quality, disableRetina, supportsWebp),
|
|
34
34
|
lgSrc: getOptimizedUrl(contentfulAssetUrl, dimension, lg, quality, disableRetina, supportsWebp),
|
|
35
35
|
xlSrc: getOptimizedUrl(contentfulAssetUrl, dimension, xl, quality, disableRetina, supportsWebp),
|
|
36
|
-
fallbackSrc: getFallbackUrl(contentfulAssetUrl, xl, quality)
|
|
36
|
+
fallbackSrc: getFallbackUrl(contentfulAssetUrl, dimension, xl, quality)
|
|
37
37
|
});
|
|
38
38
|
});
|
|
39
39
|
}, [contentfulAssetUrl, dimension, disableRetina, lg, md, quality, sm, xl, xs]);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import isSvgUrl from './isSvgUrl';
|
|
2
|
-
export default function getFallbackUrl(url,
|
|
2
|
+
export default function getFallbackUrl(url, dimension, size, quality) {
|
|
3
3
|
if (!isSvgUrl(url)) {
|
|
4
|
-
return `${url}
|
|
4
|
+
return `${url}?${dimension}=${size}&q=${quality}`;
|
|
5
5
|
}
|
|
6
6
|
return url;
|
|
7
7
|
}
|
package/lib-module/Table/Cell.js
CHANGED
|
@@ -40,23 +40,30 @@ const sharedStyles = /*#__PURE__*/css(["", ""], _ref2 => {
|
|
|
40
40
|
const createStyledCell = htmlElement => styled[htmlElement].withConfig({
|
|
41
41
|
displayName: "Cell__createStyledCell",
|
|
42
42
|
componentId: "components-web__sc-ltgfic-0"
|
|
43
|
-
})(["", ";box-shadow:", ";"], sharedStyles, _ref3 => {
|
|
43
|
+
})(["", ";box-shadow:", ";", ""], sharedStyles, _ref3 => {
|
|
44
44
|
let {
|
|
45
45
|
cellBoxShadowColor,
|
|
46
46
|
type
|
|
47
47
|
} = _ref3;
|
|
48
48
|
return type === HEADER_TYPE.HEADING ? `inset 0 1px 0 ${cellBoxShadowColor}, inset 0 -1px 0 ${cellBoxShadowColor}` : `inset 0 1px 0 ${cellBoxShadowColor}`;
|
|
49
|
+
}, _ref4 => {
|
|
50
|
+
let {
|
|
51
|
+
display
|
|
52
|
+
} = _ref4;
|
|
53
|
+
return display && `*:not(:empty) {
|
|
54
|
+
display: ${display};
|
|
55
|
+
}`;
|
|
49
56
|
});
|
|
50
57
|
const StyledHeaderCell = createStyledCell('th');
|
|
51
58
|
const StyledDataCell = createStyledCell('td');
|
|
52
|
-
const Cell =
|
|
59
|
+
const Cell = _ref5 => {
|
|
53
60
|
let {
|
|
54
61
|
children,
|
|
55
62
|
isFirstInRow,
|
|
56
63
|
align = 'left',
|
|
57
64
|
tokens: cellTokens,
|
|
58
65
|
type = 'default'
|
|
59
|
-
} =
|
|
66
|
+
} = _ref5;
|
|
60
67
|
const {
|
|
61
68
|
text,
|
|
62
69
|
isScrollable: isTableScrollable,
|
|
@@ -81,7 +88,8 @@ const Cell = _ref4 => {
|
|
|
81
88
|
fontSize,
|
|
82
89
|
lineHeight,
|
|
83
90
|
stickyBackgroundColor,
|
|
84
|
-
fontColor
|
|
91
|
+
fontColor,
|
|
92
|
+
display
|
|
85
93
|
} = useThemeTokens('Table', themeTokens, {
|
|
86
94
|
spacing,
|
|
87
95
|
type,
|
|
@@ -98,7 +106,8 @@ const Cell = _ref4 => {
|
|
|
98
106
|
cellPaddingLeft,
|
|
99
107
|
cellPaddingBottom,
|
|
100
108
|
stickyBackgroundColor,
|
|
101
|
-
cellBoxShadowColor
|
|
109
|
+
cellBoxShadowColor,
|
|
110
|
+
display
|
|
102
111
|
};
|
|
103
112
|
const typographyTokens = {
|
|
104
113
|
fontName,
|
|
@@ -5,7 +5,7 @@ export {
|
|
|
5
5
|
/**
|
|
6
6
|
* Most base components should be re-exported as-is.
|
|
7
7
|
*/
|
|
8
|
-
A11yText, ActivityIndicator, Autocomplete, Box, Button, BaseProvider, A11yInfoProvider, ViewportProvider, ThemeProvider, ButtonDropdown, ButtonGroup, ButtonLink, Carousel, CarouselTabs, Checkbox, CheckboxGroup, ChevronLink, Divider, ExpandCollapse, Feedback, FlexGrid, Icon, InputLabel, InputSupports, Link, Listbox, Modal, MultiSelectFilter, Notification, Pagination, QuickLinks, QuickLinksFeature, Radio, RadioGroup, RadioCard, RadioCardGroup, Responsive, Search, Select, SideNav, Skeleton, SkipLink, Spacer, StackView, StackWrap, StepTracker, Tabs, Tags, TextButton, TextArea, TextInput, Timeline, ToggleSwitch, ToggleSwitchGroup, TooltipButton, Tooltip, Typography, Validator,
|
|
8
|
+
A11yText, ActivityIndicator, Autocomplete, Box, Button, BaseProvider, A11yInfoProvider, ViewportProvider, ThemeProvider, ButtonDropdown, ButtonGroup, ButtonLink, Carousel, CarouselTabs, Checkbox, CheckboxGroup, ChevronLink, ColourToggle, Divider, ExpandCollapse, Feedback, FlexGrid, Icon, InputLabel, InputSupports, Link, Listbox, Modal, MultiSelectFilter, Notification, Pagination, QuickLinks, QuickLinksFeature, Radio, RadioGroup, RadioCard, RadioCardGroup, Responsive, Search, Select, SideNav, Skeleton, SkipLink, Spacer, StackView, StackWrap, StepTracker, Tabs, Tags, TextButton, TextArea, TextInput, Timeline, ToggleSwitch, ToggleSwitchGroup, TooltipButton, Tooltip, Typography, Validator,
|
|
9
9
|
/*
|
|
10
10
|
* Most utilities exported from @telus-uds/components-base are for building systems, not apps.
|
|
11
11
|
* Re-export only those utilities with a stable API and known use cases within apps / pages.
|
package/lib-module/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
1
3
|
export { default as Badge } from './Badge';
|
|
2
4
|
export { default as OrderedList } from './OrderedList';
|
|
3
5
|
export { default as PreviewCard } from './PreviewCard';
|
|
@@ -13,6 +15,7 @@ export { default as PriceLockup } from './PriceLockup';
|
|
|
13
15
|
export { default as Footnote } from './Footnote';
|
|
14
16
|
export { default as QuantitySelector } from './QuantitySelector';
|
|
15
17
|
export { default as IconButton } from './IconButton';
|
|
18
|
+
export { default as Image, DefaultImage } from './Image';
|
|
16
19
|
export { transformGradient } from './utils';
|
|
17
20
|
export { default as Breadcrumbs } from './Breadcrumbs';
|
|
18
21
|
export { default as BlockQuote } from './BlockQuote';
|
|
@@ -20,7 +23,6 @@ export { default as OptimizeImage } from './OptimizeImage';
|
|
|
20
23
|
export { default as Testimonial } from './Testimonial';
|
|
21
24
|
export { default as Toast } from './Toast';
|
|
22
25
|
export { default as Table } from './Table';
|
|
23
|
-
export { default as Image } from './Image';
|
|
24
26
|
export { default as WebVideo } from './WebVideo';
|
|
25
27
|
export { default as WaffleGrid } from './WaffleGrid';
|
|
26
28
|
export { default as Spinner } from './Spinner';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const cachedTheme = {};
|
|
2
|
+
const theme = process.env.UDS_THEME;
|
|
3
|
+
async function importTheme(componentName) {
|
|
4
|
+
try {
|
|
5
|
+
cachedTheme[componentName] = await import(`@telus-uds/theme-${theme}/build/rn/${componentName}.js`);
|
|
6
|
+
} catch (_) {
|
|
7
|
+
throw new Error(`An error occurred while trying to import theme-${process.env.UDS_THEME}. Please check that the theme has been installed in your app or that you are not importing a server component inside a client component.`);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export default async function getTheme(componentName) {
|
|
11
|
+
if (cachedTheme[componentName]) {
|
|
12
|
+
return cachedTheme[componentName];
|
|
13
|
+
}
|
|
14
|
+
await importTheme(componentName);
|
|
15
|
+
return cachedTheme[componentName];
|
|
16
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { useThemeTokens } from '@telus-uds/components-base';
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
const withClientTheme = Component => {
|
|
6
|
+
const UdsStyledComponent = _ref => {
|
|
7
|
+
let {
|
|
8
|
+
tokens: tokenOverrides,
|
|
9
|
+
variant,
|
|
10
|
+
...props
|
|
11
|
+
} = _ref;
|
|
12
|
+
const theme = useThemeTokens(Component.displayName, variant, tokenOverrides);
|
|
13
|
+
return /*#__PURE__*/_jsx(Component, {
|
|
14
|
+
theme: theme,
|
|
15
|
+
...props
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
UdsStyledComponent.propTypes = {
|
|
19
|
+
tokens: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
20
|
+
variant: PropTypes.string
|
|
21
|
+
};
|
|
22
|
+
return UdsStyledComponent;
|
|
23
|
+
};
|
|
24
|
+
export default withClientTheme;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { getThemeTokens } from '@telus-uds/components-base/server';
|
|
4
|
+
import getTheme from './get-theme-from-server';
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
const withServerTheme = (Component, componentName) => {
|
|
7
|
+
const UdsStyledComponent = async _ref => {
|
|
8
|
+
let {
|
|
9
|
+
tokens: tokenOverrides,
|
|
10
|
+
variant,
|
|
11
|
+
...props
|
|
12
|
+
} = _ref;
|
|
13
|
+
const componentTheme = await getTheme(componentName);
|
|
14
|
+
const themeTokens = getThemeTokens(componentTheme, tokenOverrides, variant);
|
|
15
|
+
return /*#__PURE__*/_jsx(Component, {
|
|
16
|
+
theme: themeTokens,
|
|
17
|
+
...props
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
UdsStyledComponent.propTypes = {
|
|
21
|
+
tokens: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
22
|
+
variant: PropTypes.string
|
|
23
|
+
};
|
|
24
|
+
return UdsStyledComponent;
|
|
25
|
+
};
|
|
26
|
+
export default withServerTheme;
|