@telus-uds/components-base 1.48.0 → 1.50.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 +26 -2
- package/component-docs.json +32 -37
- package/lib/ExpandCollapse/Control.js +40 -13
- package/lib/ExpandCollapse/Panel.js +1 -3
- package/lib/List/ListItemBase.js +22 -3
- package/lib/SideNav/Item.js +11 -3
- package/lib/SideNav/ItemContent.js +2 -1
- package/lib/SideNav/ItemsGroup.js +11 -1
- package/lib/TextInput/TextInput.js +17 -15
- package/lib/ThemeProvider/ThemeProvider.js +7 -1
- package/lib-module/ExpandCollapse/Control.js +39 -13
- package/lib-module/ExpandCollapse/Panel.js +1 -3
- package/lib-module/List/ListItemBase.js +21 -3
- package/lib-module/SideNav/Item.js +10 -3
- package/lib-module/SideNav/ItemContent.js +2 -1
- package/lib-module/SideNav/ItemsGroup.js +11 -1
- package/lib-module/TextInput/TextInput.js +19 -15
- package/lib-module/ThemeProvider/ThemeProvider.js +8 -2
- package/package.json +2 -2
- package/src/Card/CardBase.jsx +0 -1
- package/src/ExpandCollapse/Control.jsx +33 -27
- package/src/ExpandCollapse/Panel.jsx +3 -10
- package/src/Link/LinkBase.jsx +1 -0
- package/src/List/ListItemBase.jsx +18 -4
- package/src/SideNav/Item.jsx +8 -5
- package/src/SideNav/ItemContent.jsx +10 -6
- package/src/SideNav/ItemsGroup.jsx +10 -2
- package/src/SideNav/SideNav.jsx +2 -0
- package/src/TextInput/TextInput.jsx +8 -5
- package/src/ThemeProvider/ThemeProvider.jsx +9 -2
- package/src/utils/a11y/semantics.js +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,36 @@
|
|
|
1
1
|
# Change Log - @telus-uds/components-base
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Wed, 14 Jun 2023 00:01:25 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 1.50.0
|
|
8
|
+
|
|
9
|
+
Wed, 14 Jun 2023 00:01:25 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- Datepicker refactor (srikanthkhari@gmail.com)
|
|
14
|
+
- Bump @telus-uds/system-theme-tokens to v2.32.0
|
|
15
|
+
|
|
16
|
+
### Patches
|
|
17
|
+
|
|
18
|
+
- Allow dynamic swap of `defaultTheme` passed to `ThemeProvider` (shahzaibkhalidmalik@outlook.com)
|
|
19
|
+
|
|
20
|
+
## 1.49.0
|
|
21
|
+
|
|
22
|
+
Fri, 09 Jun 2023 00:28:33 GMT
|
|
23
|
+
|
|
24
|
+
### Minor changes
|
|
25
|
+
|
|
26
|
+
- refactored SideNav component for alignment to design intentions (kyle.king2@telus.com)
|
|
27
|
+
- Fixed bullet alignment within ListItemBase (wlsdud194@hotmail.com)
|
|
28
|
+
- expand collpase mini variant introduced (akshay.pandey1@telus.com)
|
|
29
|
+
- Bump @telus-uds/system-theme-tokens to v2.31.0
|
|
30
|
+
|
|
7
31
|
## 1.48.0
|
|
8
32
|
|
|
9
|
-
Tue, 06 Jun 2023 20:
|
|
33
|
+
Tue, 06 Jun 2023 20:46:12 GMT
|
|
10
34
|
|
|
11
35
|
### Minor changes
|
|
12
36
|
|
package/component-docs.json
CHANGED
|
@@ -547,12 +547,6 @@
|
|
|
547
547
|
"calendarMonthCaptionFontWeight": "fontWeight",
|
|
548
548
|
"calendarMonthCaptionLineHeight": "lineHeight",
|
|
549
549
|
"calendarMonthCaptionPaddingBottom": "size",
|
|
550
|
-
"dateInputBorderColor": "color",
|
|
551
|
-
"dateInputBorderRadius": "radius",
|
|
552
|
-
"dateInputFocusBorderColor": "color",
|
|
553
|
-
"dateInputHoverBorderColor": "color",
|
|
554
|
-
"dateInputInsideBorderColor": "color",
|
|
555
|
-
"dateInputInsideColor": "color",
|
|
556
550
|
"dateInputStrokeColor": "color",
|
|
557
551
|
"dayPickerWeekHeaderColor": "color",
|
|
558
552
|
"dayPickerWeekHeaderFontName": "fontName",
|
|
@@ -594,7 +588,12 @@
|
|
|
594
588
|
"paddingBottom": "size",
|
|
595
589
|
"borderWidth": "border",
|
|
596
590
|
"borderColor": "color",
|
|
597
|
-
"backgroundColor": "color"
|
|
591
|
+
"backgroundColor": "color",
|
|
592
|
+
"borderTopLeftRadius": "radius",
|
|
593
|
+
"borderBottomLeftRadius": "radius",
|
|
594
|
+
"borderTopRightRadius": "radius",
|
|
595
|
+
"borderBottomRightRadius": "radius",
|
|
596
|
+
"textLine": "textLine"
|
|
598
597
|
},
|
|
599
598
|
"ExpandCollapseMiniControl": {
|
|
600
599
|
"size": "size",
|
|
@@ -628,20 +627,6 @@
|
|
|
628
627
|
"expandDividerColor": "color",
|
|
629
628
|
"expandDividerWidth": "size"
|
|
630
629
|
},
|
|
631
|
-
"ExpandCollapseMiniPanel": {
|
|
632
|
-
"expandDuration": "duration",
|
|
633
|
-
"collapseDuration": "duration",
|
|
634
|
-
"contentPaddingLeft": "size",
|
|
635
|
-
"contentPaddingRight": "size",
|
|
636
|
-
"contentPaddingTop": "size",
|
|
637
|
-
"contentPaddingBottom": "size",
|
|
638
|
-
"marginBottom": "size",
|
|
639
|
-
"borderColor": "color",
|
|
640
|
-
"borderRadius": "radius",
|
|
641
|
-
"borderWidth": "border",
|
|
642
|
-
"expandDividerColor": "color",
|
|
643
|
-
"expandDividerWidth": "size"
|
|
644
|
-
},
|
|
645
630
|
"Feedback": {
|
|
646
631
|
"backgroundColor": "color",
|
|
647
632
|
"borderColor": "color",
|
|
@@ -2692,6 +2677,16 @@
|
|
|
2692
2677
|
"platforms": [
|
|
2693
2678
|
"rn"
|
|
2694
2679
|
]
|
|
2680
|
+
},
|
|
2681
|
+
"focus": {
|
|
2682
|
+
"description": "Currently only web has good support for this. Applies when an interactive component's focus handler is triggered, such as keyboard tabbing or selection.",
|
|
2683
|
+
"values": [
|
|
2684
|
+
true
|
|
2685
|
+
],
|
|
2686
|
+
"type": "state",
|
|
2687
|
+
"platforms": [
|
|
2688
|
+
"rn"
|
|
2689
|
+
]
|
|
2695
2690
|
}
|
|
2696
2691
|
},
|
|
2697
2692
|
"SideNavItemGroup": {
|
|
@@ -3361,13 +3356,6 @@
|
|
|
3361
3356
|
"required": false,
|
|
3362
3357
|
"description": "Array of the ids of currently open groups"
|
|
3363
3358
|
},
|
|
3364
|
-
"isMiniExpandCollapse": {
|
|
3365
|
-
"defaultValue": {
|
|
3366
|
-
"value": "false",
|
|
3367
|
-
"computed": false
|
|
3368
|
-
},
|
|
3369
|
-
"required": false
|
|
3370
|
-
},
|
|
3371
3359
|
"variant": {
|
|
3372
3360
|
"type": {
|
|
3373
3361
|
"name": "objectOf",
|
|
@@ -3472,7 +3460,12 @@
|
|
|
3472
3460
|
"paddingBottom": "size",
|
|
3473
3461
|
"borderWidth": "border",
|
|
3474
3462
|
"borderColor": "color",
|
|
3475
|
-
"backgroundColor": "color"
|
|
3463
|
+
"backgroundColor": "color",
|
|
3464
|
+
"borderTopLeftRadius": "radius",
|
|
3465
|
+
"borderBottomLeftRadius": "radius",
|
|
3466
|
+
"borderTopRightRadius": "radius",
|
|
3467
|
+
"borderBottomRightRadius": "radius",
|
|
3468
|
+
"textLine": "textLine"
|
|
3476
3469
|
}
|
|
3477
3470
|
},
|
|
3478
3471
|
"required": false,
|
|
@@ -4306,13 +4299,6 @@
|
|
|
4306
4299
|
"required": false,
|
|
4307
4300
|
"description": "Array of the ids of currently open groups"
|
|
4308
4301
|
},
|
|
4309
|
-
"isMiniExpandCollapse": {
|
|
4310
|
-
"defaultValue": {
|
|
4311
|
-
"value": "false",
|
|
4312
|
-
"computed": false
|
|
4313
|
-
},
|
|
4314
|
-
"required": false
|
|
4315
|
-
},
|
|
4316
4302
|
"variant": {
|
|
4317
4303
|
"type": {
|
|
4318
4304
|
"name": "objectOf",
|
|
@@ -4417,7 +4403,12 @@
|
|
|
4417
4403
|
"paddingBottom": "size",
|
|
4418
4404
|
"borderWidth": "border",
|
|
4419
4405
|
"borderColor": "color",
|
|
4420
|
-
"backgroundColor": "color"
|
|
4406
|
+
"backgroundColor": "color",
|
|
4407
|
+
"borderTopLeftRadius": "radius",
|
|
4408
|
+
"borderBottomLeftRadius": "radius",
|
|
4409
|
+
"borderTopRightRadius": "radius",
|
|
4410
|
+
"borderBottomRightRadius": "radius",
|
|
4411
|
+
"textLine": "textLine"
|
|
4421
4412
|
}
|
|
4422
4413
|
},
|
|
4423
4414
|
"required": false,
|
|
@@ -10092,6 +10083,10 @@
|
|
|
10092
10083
|
"themeTokensVersion": {
|
|
10093
10084
|
"name": "string",
|
|
10094
10085
|
"required": true
|
|
10086
|
+
},
|
|
10087
|
+
"name": {
|
|
10088
|
+
"name": "string",
|
|
10089
|
+
"required": true
|
|
10095
10090
|
}
|
|
10096
10091
|
},
|
|
10097
10092
|
"required": true
|
|
@@ -11,6 +11,8 @@ var _Pressable = _interopRequireDefault(require("react-native-web/dist/cjs/expor
|
|
|
11
11
|
|
|
12
12
|
var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
|
|
13
13
|
|
|
14
|
+
var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
|
|
15
|
+
|
|
14
16
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
17
|
|
|
16
18
|
var _ThemeProvider = require("../ThemeProvider");
|
|
@@ -32,25 +34,34 @@ function selectContainerStyles(_ref) {
|
|
|
32
34
|
backgroundColor,
|
|
33
35
|
borderColor,
|
|
34
36
|
borderWidth,
|
|
35
|
-
borderStyle,
|
|
37
|
+
borderStyle = 'solid',
|
|
36
38
|
paddingLeft,
|
|
37
39
|
paddingRight,
|
|
38
40
|
paddingTop,
|
|
39
41
|
paddingBottom,
|
|
40
42
|
justifyContent,
|
|
41
43
|
verticalAlign,
|
|
42
|
-
iconPosition
|
|
44
|
+
iconPosition,
|
|
45
|
+
borderTopRightRadius,
|
|
46
|
+
borderBottomRightRadius,
|
|
47
|
+
borderTopLeftRadius,
|
|
48
|
+
borderBottomLeftRadius
|
|
43
49
|
} = _ref;
|
|
44
50
|
return {
|
|
51
|
+
boxSizing: 'border-box',
|
|
45
52
|
backgroundColor,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
53
|
+
borderColor,
|
|
54
|
+
borderWidth,
|
|
55
|
+
borderStyle,
|
|
49
56
|
paddingLeft,
|
|
50
57
|
paddingRight,
|
|
51
58
|
paddingTop,
|
|
52
59
|
paddingBottom,
|
|
53
60
|
justifyContent,
|
|
61
|
+
borderTopRightRadius,
|
|
62
|
+
borderBottomRightRadius,
|
|
63
|
+
borderTopLeftRadius,
|
|
64
|
+
borderBottomLeftRadius,
|
|
54
65
|
...(0, _ThemeProvider.verticalAlignRow)(verticalAlign, iconPosition === 'right')
|
|
55
66
|
};
|
|
56
67
|
} // TODO: use stack / spacer when available
|
|
@@ -69,6 +80,16 @@ function selectIconContainerStyles(_ref2) {
|
|
|
69
80
|
};
|
|
70
81
|
}
|
|
71
82
|
|
|
83
|
+
function selectTextContainerStyles(_ref3) {
|
|
84
|
+
let {
|
|
85
|
+
textLine
|
|
86
|
+
} = _ref3;
|
|
87
|
+
return {
|
|
88
|
+
textDecorationLine: textLine,
|
|
89
|
+
flex: 1
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
72
93
|
function selectIconTokens(tokens) {
|
|
73
94
|
return {
|
|
74
95
|
color: tokens.iconColor,
|
|
@@ -76,7 +97,7 @@ function selectIconTokens(tokens) {
|
|
|
76
97
|
};
|
|
77
98
|
}
|
|
78
99
|
|
|
79
|
-
const ExpandCollapseControl = /*#__PURE__*/(0, _react.forwardRef)((
|
|
100
|
+
const ExpandCollapseControl = /*#__PURE__*/(0, _react.forwardRef)((_ref4, ref) => {
|
|
80
101
|
let {
|
|
81
102
|
onPress,
|
|
82
103
|
isExpanded,
|
|
@@ -84,10 +105,9 @@ const ExpandCollapseControl = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) =
|
|
|
84
105
|
tokens,
|
|
85
106
|
accessibilityRole = 'button',
|
|
86
107
|
variant,
|
|
87
|
-
isMiniExpandCollapse = false,
|
|
88
108
|
...rest
|
|
89
|
-
} =
|
|
90
|
-
const getTokens = (0, _ThemeProvider.useThemeTokensCallback)(
|
|
109
|
+
} = _ref4;
|
|
110
|
+
const getTokens = (0, _ThemeProvider.useThemeTokensCallback)('ExpandCollapseControl', tokens, variant);
|
|
91
111
|
const selectedProps = selectProps({
|
|
92
112
|
accessibilityRole,
|
|
93
113
|
...rest,
|
|
@@ -96,12 +116,12 @@ const ExpandCollapseControl = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) =
|
|
|
96
116
|
}
|
|
97
117
|
});
|
|
98
118
|
|
|
99
|
-
const getControlState =
|
|
119
|
+
const getControlState = _ref5 => {
|
|
100
120
|
let {
|
|
101
121
|
pressed,
|
|
102
122
|
hovered,
|
|
103
123
|
focused
|
|
104
|
-
} =
|
|
124
|
+
} = _ref5;
|
|
105
125
|
return {
|
|
106
126
|
pressed,
|
|
107
127
|
hover: hovered,
|
|
@@ -112,7 +132,11 @@ const ExpandCollapseControl = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) =
|
|
|
112
132
|
|
|
113
133
|
const getControlTokens = pressableState => getTokens(getControlState(pressableState));
|
|
114
134
|
|
|
115
|
-
const getPressableStyle = pressableState => selectContainerStyles(getControlTokens(pressableState))
|
|
135
|
+
const getPressableStyle = pressableState => ({ ...selectContainerStyles(getControlTokens(pressableState)),
|
|
136
|
+
...(_Platform.default.OS === 'web' ? {
|
|
137
|
+
outline: 'none'
|
|
138
|
+
} : {})
|
|
139
|
+
});
|
|
116
140
|
|
|
117
141
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Pressable.default, {
|
|
118
142
|
ref: ref,
|
|
@@ -129,7 +153,10 @@ const ExpandCollapseControl = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) =
|
|
|
129
153
|
style: selectIconContainerStyles(themeTokens),
|
|
130
154
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(IconComponent, { ...selectIconTokens(themeTokens)
|
|
131
155
|
})
|
|
132
|
-
}),
|
|
156
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
157
|
+
style: selectTextContainerStyles(themeTokens),
|
|
158
|
+
children: typeof children === 'function' ? children(getControlState(pressableState)) : children
|
|
159
|
+
})]
|
|
133
160
|
});
|
|
134
161
|
}
|
|
135
162
|
});
|
|
@@ -70,7 +70,6 @@ const ExpandCollapsePanel = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) =>
|
|
|
70
70
|
children,
|
|
71
71
|
tokens,
|
|
72
72
|
variant,
|
|
73
|
-
isMiniExpandCollapse = false,
|
|
74
73
|
controlRef,
|
|
75
74
|
...rest
|
|
76
75
|
} = _ref2;
|
|
@@ -81,7 +80,7 @@ const ExpandCollapsePanel = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) =>
|
|
|
81
80
|
expanded: isExpanded
|
|
82
81
|
}
|
|
83
82
|
});
|
|
84
|
-
const themeTokens = (0, _ThemeProvider.useThemeTokens)(
|
|
83
|
+
const themeTokens = (0, _ThemeProvider.useThemeTokens)('ExpandCollapsePanel', tokens, variant, {
|
|
85
84
|
expanded: isExpanded
|
|
86
85
|
});
|
|
87
86
|
|
|
@@ -117,7 +116,6 @@ const ExpandCollapsePanel = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) =>
|
|
|
117
116
|
variant: variant,
|
|
118
117
|
onPress: handleControlPress,
|
|
119
118
|
ref: controlRef,
|
|
120
|
-
isMiniExpandCollapse: isMiniExpandCollapse,
|
|
121
119
|
children: control
|
|
122
120
|
}), isExpanded && /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
123
121
|
style: {
|
package/lib/List/ListItemBase.js
CHANGED
|
@@ -23,6 +23,8 @@ var _ListItemMark = _interopRequireDefault(require("./ListItemMark"));
|
|
|
23
23
|
|
|
24
24
|
var _Typography = _interopRequireDefault(require("../Typography"));
|
|
25
25
|
|
|
26
|
+
var _ThemeProvider = require("../ThemeProvider");
|
|
27
|
+
|
|
26
28
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
27
29
|
|
|
28
30
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -79,12 +81,29 @@ const ListItemBase = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) => {
|
|
|
79
81
|
const themeTokens = typeof tokens === 'function' ? tokens() : tokens;
|
|
80
82
|
const itemBlockStyles = selectItemBlockStyles(themeTokens);
|
|
81
83
|
const dividerStyles = selectDividerStyles(themeTokens);
|
|
84
|
+
const {
|
|
85
|
+
iconMarginTop,
|
|
86
|
+
itemIconSize
|
|
87
|
+
} = themeTokens;
|
|
88
|
+
let adjustedIconMarginTop = iconMarginTop;
|
|
89
|
+
const {
|
|
90
|
+
fontSize,
|
|
91
|
+
lineHeight: lineHeightRatio
|
|
92
|
+
} = (0, _ThemeProvider.useThemeTokens)('Typography', {}, {
|
|
93
|
+
size: 'h4',
|
|
94
|
+
bold: true
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
if (title) {
|
|
98
|
+
adjustedIconMarginTop = (fontSize * lineHeightRatio - itemIconSize) / 2;
|
|
99
|
+
}
|
|
82
100
|
/**
|
|
83
101
|
* Function responsible returning styling, in case the item is the last shouldn't
|
|
84
102
|
* add extra margin on the bottom, if "showDivider" is true it should add a divider
|
|
85
103
|
* and custom margin and padding, otherwise just adds a margin to the bottom
|
|
86
104
|
*/
|
|
87
105
|
|
|
106
|
+
|
|
88
107
|
const getContainerStyle = () => {
|
|
89
108
|
if (isLastItem) {
|
|
90
109
|
return undefined;
|
|
@@ -112,11 +131,11 @@ const ListItemBase = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) => {
|
|
|
112
131
|
style: [{
|
|
113
132
|
flex: 1,
|
|
114
133
|
flexDirection: 'row'
|
|
115
|
-
}, !title && {
|
|
116
|
-
alignItems: 'center'
|
|
117
134
|
}],
|
|
118
135
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItemMark.default, {
|
|
119
|
-
tokens: tokens,
|
|
136
|
+
tokens: { ...tokens,
|
|
137
|
+
iconMarginTop: adjustedIconMarginTop
|
|
138
|
+
},
|
|
120
139
|
icon: icon,
|
|
121
140
|
iconColor: iconColor,
|
|
122
141
|
iconSize: iconSize
|
package/lib/SideNav/Item.js
CHANGED
|
@@ -9,6 +9,8 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
9
9
|
|
|
10
10
|
var _Pressable = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Pressable"));
|
|
11
11
|
|
|
12
|
+
var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
|
|
13
|
+
|
|
12
14
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
15
|
|
|
14
16
|
var _utils = require("../utils");
|
|
@@ -94,16 +96,22 @@ const Item = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
|
|
|
94
96
|
|
|
95
97
|
const getAppearanceState = _ref3 => {
|
|
96
98
|
let {
|
|
97
|
-
hovered
|
|
99
|
+
hovered,
|
|
100
|
+
focused
|
|
98
101
|
} = _ref3;
|
|
99
102
|
return {
|
|
100
103
|
hover: hovered,
|
|
101
104
|
active: isActive,
|
|
102
|
-
expanded: isExpanded
|
|
105
|
+
expanded: isExpanded,
|
|
106
|
+
focus: focused
|
|
103
107
|
};
|
|
104
108
|
};
|
|
105
109
|
|
|
106
|
-
const getPressableStyle = pressableState => selectItemStyles(getTokens(getAppearanceState(pressableState)))
|
|
110
|
+
const getPressableStyle = pressableState => ({ ...selectItemStyles(getTokens(getAppearanceState(pressableState))),
|
|
111
|
+
...(_Platform.default.OS === 'web' ? {
|
|
112
|
+
outline: 'none'
|
|
113
|
+
} : {})
|
|
114
|
+
});
|
|
107
115
|
|
|
108
116
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Pressable.default, {
|
|
109
117
|
ref: ref,
|
|
@@ -42,9 +42,10 @@ const ItemContent = _ref => {
|
|
|
42
42
|
children,
|
|
43
43
|
tokens
|
|
44
44
|
} = _ref;
|
|
45
|
+
const typographyTokens = (0, _utils.selectTokens)('Typography', tokens);
|
|
45
46
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
46
47
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
47
|
-
tokens:
|
|
48
|
+
tokens: typographyTokens,
|
|
48
49
|
children: children
|
|
49
50
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
50
51
|
style: [staticStyles.absolute, selectAccentStyles(tokens)]
|
|
@@ -61,7 +61,17 @@ const ItemsGroup = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
61
61
|
|
|
62
62
|
const getGroupTokens = (0, _ThemeProvider.useThemeTokensCallback)('SideNavItemsGroup', tokens, variant);
|
|
63
63
|
|
|
64
|
-
const getPanelTokens = appearance =>
|
|
64
|
+
const getPanelTokens = appearance => {
|
|
65
|
+
const {
|
|
66
|
+
panelBorderColor,
|
|
67
|
+
...itemsGroupTokens
|
|
68
|
+
} = getGroupTokens(getAppearance(appearance));
|
|
69
|
+
const groupTokens = { ...itemsGroupTokens,
|
|
70
|
+
borderWidth: 0,
|
|
71
|
+
marginBottom: 0
|
|
72
|
+
};
|
|
73
|
+
return (0, _utils.selectTokens)('ExpandCollapsePanel', groupTokens);
|
|
74
|
+
};
|
|
65
75
|
|
|
66
76
|
const getItemTokens = (0, _ThemeProvider.useThemeTokensCallback)('SideNavItem', itemTokens, variant);
|
|
67
77
|
|
|
@@ -62,21 +62,23 @@ const TextInput = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
62
62
|
validation: supportsProps.validation
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
|
-
return /*#__PURE__*/(0, _jsxRuntime.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
65
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
66
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_InputSupports.default, {
|
|
67
|
+
nativeID: nativeID,
|
|
68
|
+
...supportsProps,
|
|
69
|
+
children: _ref2 => {
|
|
70
|
+
let {
|
|
71
|
+
inputId,
|
|
72
|
+
...propsFromInputSupports
|
|
73
|
+
} = _ref2;
|
|
74
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextInputBase.default, {
|
|
75
|
+
ref: ref,
|
|
76
|
+
nativeID: inputId,
|
|
77
|
+
...propsFromInputSupports,
|
|
78
|
+
...inputProps
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}), rest.children]
|
|
80
82
|
});
|
|
81
83
|
});
|
|
82
84
|
TextInput.displayName = 'TextInput';
|
|
@@ -45,6 +45,11 @@ const ThemeProvider = _ref => {
|
|
|
45
45
|
themeOptions = {}
|
|
46
46
|
} = _ref;
|
|
47
47
|
const [theme, setTheme] = (0, _react.useState)(defaultTheme);
|
|
48
|
+
(0, _react.useEffect)(() => {
|
|
49
|
+
if (theme.metadata.name !== defaultTheme.metadata.name) {
|
|
50
|
+
setTheme(defaultTheme);
|
|
51
|
+
}
|
|
52
|
+
}, [theme.metadata.name, defaultTheme]);
|
|
48
53
|
const appliedThemeOptions = { ...defaultThemeOptions,
|
|
49
54
|
...themeOptions
|
|
50
55
|
}; // Validate the theme tokens version on every render.
|
|
@@ -67,7 +72,8 @@ ThemeProvider.propTypes = {
|
|
|
67
72
|
children: _propTypes.default.node.isRequired,
|
|
68
73
|
defaultTheme: _propTypes.default.shape({
|
|
69
74
|
metadata: _propTypes.default.shape({
|
|
70
|
-
themeTokensVersion: _propTypes.default.string.isRequired
|
|
75
|
+
themeTokensVersion: _propTypes.default.string.isRequired,
|
|
76
|
+
name: _propTypes.default.string.isRequired
|
|
71
77
|
}).isRequired
|
|
72
78
|
}).isRequired,
|
|
73
79
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
2
|
import Pressable from "react-native-web/dist/exports/Pressable";
|
|
3
3
|
import View from "react-native-web/dist/exports/View";
|
|
4
|
+
import Platform from "react-native-web/dist/exports/Platform";
|
|
4
5
|
import PropTypes from 'prop-types';
|
|
5
6
|
import { useThemeTokensCallback, verticalAlignRow } from '../ThemeProvider';
|
|
6
7
|
import { a11yProps, getTokensPropType, selectSystemProps, variantProp, viewProps } from '../utils';
|
|
@@ -14,25 +15,34 @@ function selectContainerStyles(_ref) {
|
|
|
14
15
|
backgroundColor,
|
|
15
16
|
borderColor,
|
|
16
17
|
borderWidth,
|
|
17
|
-
borderStyle,
|
|
18
|
+
borderStyle = 'solid',
|
|
18
19
|
paddingLeft,
|
|
19
20
|
paddingRight,
|
|
20
21
|
paddingTop,
|
|
21
22
|
paddingBottom,
|
|
22
23
|
justifyContent,
|
|
23
24
|
verticalAlign,
|
|
24
|
-
iconPosition
|
|
25
|
+
iconPosition,
|
|
26
|
+
borderTopRightRadius,
|
|
27
|
+
borderBottomRightRadius,
|
|
28
|
+
borderTopLeftRadius,
|
|
29
|
+
borderBottomLeftRadius
|
|
25
30
|
} = _ref;
|
|
26
31
|
return {
|
|
32
|
+
boxSizing: 'border-box',
|
|
27
33
|
backgroundColor,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
34
|
+
borderColor,
|
|
35
|
+
borderWidth,
|
|
36
|
+
borderStyle,
|
|
31
37
|
paddingLeft,
|
|
32
38
|
paddingRight,
|
|
33
39
|
paddingTop,
|
|
34
40
|
paddingBottom,
|
|
35
41
|
justifyContent,
|
|
42
|
+
borderTopRightRadius,
|
|
43
|
+
borderBottomRightRadius,
|
|
44
|
+
borderTopLeftRadius,
|
|
45
|
+
borderBottomLeftRadius,
|
|
36
46
|
...verticalAlignRow(verticalAlign, iconPosition === 'right')
|
|
37
47
|
};
|
|
38
48
|
} // TODO: use stack / spacer when available
|
|
@@ -51,6 +61,16 @@ function selectIconContainerStyles(_ref2) {
|
|
|
51
61
|
};
|
|
52
62
|
}
|
|
53
63
|
|
|
64
|
+
function selectTextContainerStyles(_ref3) {
|
|
65
|
+
let {
|
|
66
|
+
textLine
|
|
67
|
+
} = _ref3;
|
|
68
|
+
return {
|
|
69
|
+
textDecorationLine: textLine,
|
|
70
|
+
flex: 1
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
54
74
|
function selectIconTokens(tokens) {
|
|
55
75
|
return {
|
|
56
76
|
color: tokens.iconColor,
|
|
@@ -58,7 +78,7 @@ function selectIconTokens(tokens) {
|
|
|
58
78
|
};
|
|
59
79
|
}
|
|
60
80
|
|
|
61
|
-
const ExpandCollapseControl = /*#__PURE__*/forwardRef((
|
|
81
|
+
const ExpandCollapseControl = /*#__PURE__*/forwardRef((_ref4, ref) => {
|
|
62
82
|
let {
|
|
63
83
|
onPress,
|
|
64
84
|
isExpanded,
|
|
@@ -66,10 +86,9 @@ const ExpandCollapseControl = /*#__PURE__*/forwardRef((_ref3, ref) => {
|
|
|
66
86
|
tokens,
|
|
67
87
|
accessibilityRole = 'button',
|
|
68
88
|
variant,
|
|
69
|
-
isMiniExpandCollapse = false,
|
|
70
89
|
...rest
|
|
71
|
-
} =
|
|
72
|
-
const getTokens = useThemeTokensCallback(
|
|
90
|
+
} = _ref4;
|
|
91
|
+
const getTokens = useThemeTokensCallback('ExpandCollapseControl', tokens, variant);
|
|
73
92
|
const selectedProps = selectProps({
|
|
74
93
|
accessibilityRole,
|
|
75
94
|
...rest,
|
|
@@ -78,12 +97,12 @@ const ExpandCollapseControl = /*#__PURE__*/forwardRef((_ref3, ref) => {
|
|
|
78
97
|
}
|
|
79
98
|
});
|
|
80
99
|
|
|
81
|
-
const getControlState =
|
|
100
|
+
const getControlState = _ref5 => {
|
|
82
101
|
let {
|
|
83
102
|
pressed,
|
|
84
103
|
hovered,
|
|
85
104
|
focused
|
|
86
|
-
} =
|
|
105
|
+
} = _ref5;
|
|
87
106
|
return {
|
|
88
107
|
pressed,
|
|
89
108
|
hover: hovered,
|
|
@@ -94,7 +113,11 @@ const ExpandCollapseControl = /*#__PURE__*/forwardRef((_ref3, ref) => {
|
|
|
94
113
|
|
|
95
114
|
const getControlTokens = pressableState => getTokens(getControlState(pressableState));
|
|
96
115
|
|
|
97
|
-
const getPressableStyle = pressableState => selectContainerStyles(getControlTokens(pressableState))
|
|
116
|
+
const getPressableStyle = pressableState => ({ ...selectContainerStyles(getControlTokens(pressableState)),
|
|
117
|
+
...(Platform.OS === 'web' ? {
|
|
118
|
+
outline: 'none'
|
|
119
|
+
} : {})
|
|
120
|
+
});
|
|
98
121
|
|
|
99
122
|
return /*#__PURE__*/_jsx(Pressable, {
|
|
100
123
|
ref: ref,
|
|
@@ -111,7 +134,10 @@ const ExpandCollapseControl = /*#__PURE__*/forwardRef((_ref3, ref) => {
|
|
|
111
134
|
style: selectIconContainerStyles(themeTokens),
|
|
112
135
|
children: /*#__PURE__*/_jsx(IconComponent, { ...selectIconTokens(themeTokens)
|
|
113
136
|
})
|
|
114
|
-
}),
|
|
137
|
+
}), /*#__PURE__*/_jsx(View, {
|
|
138
|
+
style: selectTextContainerStyles(themeTokens),
|
|
139
|
+
children: typeof children === 'function' ? children(getControlState(pressableState)) : children
|
|
140
|
+
})]
|
|
115
141
|
});
|
|
116
142
|
}
|
|
117
143
|
});
|
|
@@ -48,7 +48,6 @@ const ExpandCollapsePanel = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
48
48
|
children,
|
|
49
49
|
tokens,
|
|
50
50
|
variant,
|
|
51
|
-
isMiniExpandCollapse = false,
|
|
52
51
|
controlRef,
|
|
53
52
|
...rest
|
|
54
53
|
} = _ref2;
|
|
@@ -59,7 +58,7 @@ const ExpandCollapsePanel = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
59
58
|
expanded: isExpanded
|
|
60
59
|
}
|
|
61
60
|
});
|
|
62
|
-
const themeTokens = useThemeTokens(
|
|
61
|
+
const themeTokens = useThemeTokens('ExpandCollapsePanel', tokens, variant, {
|
|
63
62
|
expanded: isExpanded
|
|
64
63
|
});
|
|
65
64
|
|
|
@@ -95,7 +94,6 @@ const ExpandCollapsePanel = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
95
94
|
variant: variant,
|
|
96
95
|
onPress: handleControlPress,
|
|
97
96
|
ref: controlRef,
|
|
98
|
-
isMiniExpandCollapse: isMiniExpandCollapse,
|
|
99
97
|
children: control
|
|
100
98
|
}), isExpanded && /*#__PURE__*/_jsx(View, {
|
|
101
99
|
style: {
|
|
@@ -7,6 +7,7 @@ import { a11yProps, getTokensPropType, selectSystemProps, variantProp, viewProps
|
|
|
7
7
|
import ListItemContent from './ListItemContent';
|
|
8
8
|
import ListItemMark from './ListItemMark';
|
|
9
9
|
import Typography from '../Typography';
|
|
10
|
+
import { useThemeTokens } from '../ThemeProvider';
|
|
10
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
12
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
13
|
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
@@ -57,12 +58,29 @@ const ListItemBase = /*#__PURE__*/forwardRef((_ref3, ref) => {
|
|
|
57
58
|
const themeTokens = typeof tokens === 'function' ? tokens() : tokens;
|
|
58
59
|
const itemBlockStyles = selectItemBlockStyles(themeTokens);
|
|
59
60
|
const dividerStyles = selectDividerStyles(themeTokens);
|
|
61
|
+
const {
|
|
62
|
+
iconMarginTop,
|
|
63
|
+
itemIconSize
|
|
64
|
+
} = themeTokens;
|
|
65
|
+
let adjustedIconMarginTop = iconMarginTop;
|
|
66
|
+
const {
|
|
67
|
+
fontSize,
|
|
68
|
+
lineHeight: lineHeightRatio
|
|
69
|
+
} = useThemeTokens('Typography', {}, {
|
|
70
|
+
size: 'h4',
|
|
71
|
+
bold: true
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
if (title) {
|
|
75
|
+
adjustedIconMarginTop = (fontSize * lineHeightRatio - itemIconSize) / 2;
|
|
76
|
+
}
|
|
60
77
|
/**
|
|
61
78
|
* Function responsible returning styling, in case the item is the last shouldn't
|
|
62
79
|
* add extra margin on the bottom, if "showDivider" is true it should add a divider
|
|
63
80
|
* and custom margin and padding, otherwise just adds a margin to the bottom
|
|
64
81
|
*/
|
|
65
82
|
|
|
83
|
+
|
|
66
84
|
const getContainerStyle = () => {
|
|
67
85
|
if (isLastItem) {
|
|
68
86
|
return undefined;
|
|
@@ -90,11 +108,11 @@ const ListItemBase = /*#__PURE__*/forwardRef((_ref3, ref) => {
|
|
|
90
108
|
style: [{
|
|
91
109
|
flex: 1,
|
|
92
110
|
flexDirection: 'row'
|
|
93
|
-
}, !title && {
|
|
94
|
-
alignItems: 'center'
|
|
95
111
|
}],
|
|
96
112
|
children: [/*#__PURE__*/_jsx(ListItemMark, {
|
|
97
|
-
tokens: tokens,
|
|
113
|
+
tokens: { ...tokens,
|
|
114
|
+
iconMarginTop: adjustedIconMarginTop
|
|
115
|
+
},
|
|
98
116
|
icon: icon,
|
|
99
117
|
iconColor: iconColor,
|
|
100
118
|
iconSize: iconSize
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
2
|
import Pressable from "react-native-web/dist/exports/Pressable";
|
|
3
|
+
import Platform from "react-native-web/dist/exports/Platform";
|
|
3
4
|
import PropTypes from 'prop-types';
|
|
4
5
|
import { a11yProps, getTokensPropType, hrefAttrsProp, linkProps, selectSystemProps, variantProp, viewProps } from '../utils';
|
|
5
6
|
import { useThemeTokensCallback, verticalAlignRow } from '../ThemeProvider';
|
|
@@ -73,16 +74,22 @@ const Item = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
73
74
|
|
|
74
75
|
const getAppearanceState = _ref3 => {
|
|
75
76
|
let {
|
|
76
|
-
hovered
|
|
77
|
+
hovered,
|
|
78
|
+
focused
|
|
77
79
|
} = _ref3;
|
|
78
80
|
return {
|
|
79
81
|
hover: hovered,
|
|
80
82
|
active: isActive,
|
|
81
|
-
expanded: isExpanded
|
|
83
|
+
expanded: isExpanded,
|
|
84
|
+
focus: focused
|
|
82
85
|
};
|
|
83
86
|
};
|
|
84
87
|
|
|
85
|
-
const getPressableStyle = pressableState => selectItemStyles(getTokens(getAppearanceState(pressableState)))
|
|
88
|
+
const getPressableStyle = pressableState => ({ ...selectItemStyles(getTokens(getAppearanceState(pressableState))),
|
|
89
|
+
...(Platform.OS === 'web' ? {
|
|
90
|
+
outline: 'none'
|
|
91
|
+
} : {})
|
|
92
|
+
});
|
|
86
93
|
|
|
87
94
|
return /*#__PURE__*/_jsx(Pressable, {
|
|
88
95
|
ref: ref,
|
|
@@ -26,9 +26,10 @@ const ItemContent = _ref => {
|
|
|
26
26
|
children,
|
|
27
27
|
tokens
|
|
28
28
|
} = _ref;
|
|
29
|
+
const typographyTokens = selectTokens('Typography', tokens);
|
|
29
30
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
30
31
|
children: [/*#__PURE__*/_jsx(Typography, {
|
|
31
|
-
tokens:
|
|
32
|
+
tokens: typographyTokens,
|
|
32
33
|
children: children
|
|
33
34
|
}), /*#__PURE__*/_jsx(View, {
|
|
34
35
|
style: [staticStyles.absolute, selectAccentStyles(tokens)]
|
|
@@ -42,7 +42,17 @@ const ItemsGroup = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
42
42
|
|
|
43
43
|
const getGroupTokens = useThemeTokensCallback('SideNavItemsGroup', tokens, variant);
|
|
44
44
|
|
|
45
|
-
const getPanelTokens = appearance =>
|
|
45
|
+
const getPanelTokens = appearance => {
|
|
46
|
+
const {
|
|
47
|
+
panelBorderColor,
|
|
48
|
+
...itemsGroupTokens
|
|
49
|
+
} = getGroupTokens(getAppearance(appearance));
|
|
50
|
+
const groupTokens = { ...itemsGroupTokens,
|
|
51
|
+
borderWidth: 0,
|
|
52
|
+
marginBottom: 0
|
|
53
|
+
};
|
|
54
|
+
return selectTokens('ExpandCollapsePanel', groupTokens);
|
|
55
|
+
};
|
|
46
56
|
|
|
47
57
|
const getItemTokens = useThemeTokensCallback('SideNavItem', itemTokens, variant);
|
|
48
58
|
|
|
@@ -5,6 +5,8 @@ import InputSupports from '../InputSupports';
|
|
|
5
5
|
import TextInputBase from './TextInputBase';
|
|
6
6
|
import textInputPropTypes from './propTypes';
|
|
7
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
9
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
10
|
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, focusHandlerProps, inputSupportsProps, textInputHandlerProps, textInputProps, viewProps]);
|
|
9
11
|
/**
|
|
10
12
|
* A basic text input component. Use in forms or individually to receive user's input.
|
|
@@ -42,21 +44,23 @@ const TextInput = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
42
44
|
validation: supportsProps.validation
|
|
43
45
|
}
|
|
44
46
|
};
|
|
45
|
-
return /*#__PURE__*/
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
47
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
48
|
+
children: [/*#__PURE__*/_jsx(InputSupports, {
|
|
49
|
+
nativeID: nativeID,
|
|
50
|
+
...supportsProps,
|
|
51
|
+
children: _ref2 => {
|
|
52
|
+
let {
|
|
53
|
+
inputId,
|
|
54
|
+
...propsFromInputSupports
|
|
55
|
+
} = _ref2;
|
|
56
|
+
return /*#__PURE__*/_jsx(TextInputBase, {
|
|
57
|
+
ref: ref,
|
|
58
|
+
nativeID: inputId,
|
|
59
|
+
...propsFromInputSupports,
|
|
60
|
+
...inputProps
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}), rest.children]
|
|
60
64
|
});
|
|
61
65
|
});
|
|
62
66
|
TextInput.displayName = 'TextInput';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { createContext, useState } from 'react';
|
|
1
|
+
import React, { createContext, useEffect, useState } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { validateThemeTokensVersion } from './utils';
|
|
4
4
|
import responsiveProps from '../utils/props/responsiveProps';
|
|
@@ -24,6 +24,11 @@ const ThemeProvider = _ref => {
|
|
|
24
24
|
themeOptions = {}
|
|
25
25
|
} = _ref;
|
|
26
26
|
const [theme, setTheme] = useState(defaultTheme);
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (theme.metadata.name !== defaultTheme.metadata.name) {
|
|
29
|
+
setTheme(defaultTheme);
|
|
30
|
+
}
|
|
31
|
+
}, [theme.metadata.name, defaultTheme]);
|
|
27
32
|
const appliedThemeOptions = { ...defaultThemeOptions,
|
|
28
33
|
...themeOptions
|
|
29
34
|
}; // Validate the theme tokens version on every render.
|
|
@@ -46,7 +51,8 @@ ThemeProvider.propTypes = {
|
|
|
46
51
|
children: PropTypes.node.isRequired,
|
|
47
52
|
defaultTheme: PropTypes.shape({
|
|
48
53
|
metadata: PropTypes.shape({
|
|
49
|
-
themeTokensVersion: PropTypes.string.isRequired
|
|
54
|
+
themeTokensVersion: PropTypes.string.isRequired,
|
|
55
|
+
name: PropTypes.string.isRequired
|
|
50
56
|
}).isRequired
|
|
51
57
|
}).isRequired,
|
|
52
58
|
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"@floating-ui/react-native": "^0.8.1",
|
|
12
12
|
"@gorhom/portal": "^1.0.14",
|
|
13
13
|
"@telus-uds/system-constants": "^1.2.1",
|
|
14
|
-
"@telus-uds/system-theme-tokens": "^2.
|
|
14
|
+
"@telus-uds/system-theme-tokens": "^2.32.0",
|
|
15
15
|
"airbnb-prop-types": "^2.16.0",
|
|
16
16
|
"lodash.debounce": "^4.0.8",
|
|
17
17
|
"lodash.merge": "^4.6.2",
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"standard-engine": {
|
|
73
73
|
"skip": true
|
|
74
74
|
},
|
|
75
|
-
"version": "1.
|
|
75
|
+
"version": "1.50.0"
|
|
76
76
|
}
|
package/src/Card/CardBase.jsx
CHANGED
|
@@ -42,7 +42,6 @@ const selectStyles = ({
|
|
|
42
42
|
const CardBase = forwardRef(({ children, tokens, dataSet, ...rest }, ref) => {
|
|
43
43
|
const cardStyle = selectStyles(typeof tokens === 'function' ? tokens() : tokens)
|
|
44
44
|
const props = selectProps(rest)
|
|
45
|
-
|
|
46
45
|
return (
|
|
47
46
|
<View style={cardStyle} dataSet={dataSet} ref={ref} {...props}>
|
|
48
47
|
{children}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react'
|
|
2
|
-
import { Pressable, View } from 'react-native'
|
|
2
|
+
import { Pressable, View, Platform } from 'react-native'
|
|
3
3
|
import PropTypes from 'prop-types'
|
|
4
4
|
|
|
5
5
|
import { useThemeTokensCallback, verticalAlignRow } from '../ThemeProvider'
|
|
@@ -11,25 +11,34 @@ function selectContainerStyles({
|
|
|
11
11
|
backgroundColor,
|
|
12
12
|
borderColor,
|
|
13
13
|
borderWidth,
|
|
14
|
-
borderStyle,
|
|
14
|
+
borderStyle = 'solid',
|
|
15
15
|
paddingLeft,
|
|
16
16
|
paddingRight,
|
|
17
17
|
paddingTop,
|
|
18
18
|
paddingBottom,
|
|
19
19
|
justifyContent,
|
|
20
20
|
verticalAlign,
|
|
21
|
-
iconPosition
|
|
21
|
+
iconPosition,
|
|
22
|
+
borderTopRightRadius,
|
|
23
|
+
borderBottomRightRadius,
|
|
24
|
+
borderTopLeftRadius,
|
|
25
|
+
borderBottomLeftRadius
|
|
22
26
|
}) {
|
|
23
27
|
return {
|
|
28
|
+
boxSizing: 'border-box',
|
|
24
29
|
backgroundColor,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
30
|
+
borderColor,
|
|
31
|
+
borderWidth,
|
|
32
|
+
borderStyle,
|
|
28
33
|
paddingLeft,
|
|
29
34
|
paddingRight,
|
|
30
35
|
paddingTop,
|
|
31
36
|
paddingBottom,
|
|
32
37
|
justifyContent,
|
|
38
|
+
borderTopRightRadius,
|
|
39
|
+
borderBottomRightRadius,
|
|
40
|
+
borderTopLeftRadius,
|
|
41
|
+
borderBottomLeftRadius,
|
|
33
42
|
...verticalAlignRow(verticalAlign, iconPosition === 'right')
|
|
34
43
|
}
|
|
35
44
|
}
|
|
@@ -43,6 +52,13 @@ function selectIconContainerStyles({ iconGap, iconPaddingTop, iconPosition }) {
|
|
|
43
52
|
}
|
|
44
53
|
}
|
|
45
54
|
|
|
55
|
+
function selectTextContainerStyles({ textLine }) {
|
|
56
|
+
return {
|
|
57
|
+
textDecorationLine: textLine,
|
|
58
|
+
flex: 1
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
46
62
|
function selectIconTokens(tokens) {
|
|
47
63
|
return {
|
|
48
64
|
color: tokens.iconColor,
|
|
@@ -52,23 +68,10 @@ function selectIconTokens(tokens) {
|
|
|
52
68
|
|
|
53
69
|
const ExpandCollapseControl = forwardRef(
|
|
54
70
|
(
|
|
55
|
-
{
|
|
56
|
-
onPress,
|
|
57
|
-
isExpanded,
|
|
58
|
-
children,
|
|
59
|
-
tokens,
|
|
60
|
-
accessibilityRole = 'button',
|
|
61
|
-
variant,
|
|
62
|
-
isMiniExpandCollapse = false,
|
|
63
|
-
...rest
|
|
64
|
-
},
|
|
71
|
+
{ onPress, isExpanded, children, tokens, accessibilityRole = 'button', variant, ...rest },
|
|
65
72
|
ref
|
|
66
73
|
) => {
|
|
67
|
-
const getTokens = useThemeTokensCallback(
|
|
68
|
-
isMiniExpandCollapse ? 'ExpandCollapseMiniControl' : 'ExpandCollapseControl',
|
|
69
|
-
tokens,
|
|
70
|
-
variant
|
|
71
|
-
)
|
|
74
|
+
const getTokens = useThemeTokensCallback('ExpandCollapseControl', tokens, variant)
|
|
72
75
|
|
|
73
76
|
const selectedProps = selectProps({
|
|
74
77
|
accessibilityRole,
|
|
@@ -86,14 +89,15 @@ const ExpandCollapseControl = forwardRef(
|
|
|
86
89
|
expanded: isExpanded
|
|
87
90
|
})
|
|
88
91
|
const getControlTokens = (pressableState) => getTokens(getControlState(pressableState))
|
|
89
|
-
const getPressableStyle = (pressableState) =>
|
|
90
|
-
selectContainerStyles(getControlTokens(pressableState))
|
|
92
|
+
const getPressableStyle = (pressableState) => ({
|
|
93
|
+
...selectContainerStyles(getControlTokens(pressableState)),
|
|
94
|
+
...(Platform.OS === 'web' ? { outline: 'none' } : {})
|
|
95
|
+
})
|
|
91
96
|
|
|
92
97
|
return (
|
|
93
98
|
<Pressable ref={ref} {...selectedProps} onPress={onPress} style={getPressableStyle}>
|
|
94
99
|
{(pressableState) => {
|
|
95
100
|
const { icon: IconComponent, ...themeTokens } = getControlTokens(pressableState)
|
|
96
|
-
|
|
97
101
|
return (
|
|
98
102
|
<>
|
|
99
103
|
{IconComponent && (
|
|
@@ -101,9 +105,11 @@ const ExpandCollapseControl = forwardRef(
|
|
|
101
105
|
<IconComponent {...selectIconTokens(themeTokens)} />
|
|
102
106
|
</View>
|
|
103
107
|
)}
|
|
104
|
-
{
|
|
105
|
-
|
|
106
|
-
|
|
108
|
+
<View style={selectTextContainerStyles(themeTokens)}>
|
|
109
|
+
{typeof children === 'function'
|
|
110
|
+
? children(getControlState(pressableState))
|
|
111
|
+
: children}
|
|
112
|
+
</View>
|
|
107
113
|
</>
|
|
108
114
|
)
|
|
109
115
|
}}
|
|
@@ -51,7 +51,6 @@ const ExpandCollapsePanel = forwardRef(
|
|
|
51
51
|
children,
|
|
52
52
|
tokens,
|
|
53
53
|
variant,
|
|
54
|
-
isMiniExpandCollapse = false,
|
|
55
54
|
controlRef,
|
|
56
55
|
...rest
|
|
57
56
|
},
|
|
@@ -68,14 +67,9 @@ const ExpandCollapsePanel = forwardRef(
|
|
|
68
67
|
}
|
|
69
68
|
})
|
|
70
69
|
|
|
71
|
-
const themeTokens = useThemeTokens(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
variant,
|
|
75
|
-
{
|
|
76
|
-
expanded: isExpanded
|
|
77
|
-
}
|
|
78
|
-
)
|
|
70
|
+
const themeTokens = useThemeTokens('ExpandCollapsePanel', tokens, variant, {
|
|
71
|
+
expanded: isExpanded
|
|
72
|
+
})
|
|
79
73
|
|
|
80
74
|
const handleControlPress = (event) => {
|
|
81
75
|
onToggle(panelId, event)
|
|
@@ -106,7 +100,6 @@ const ExpandCollapsePanel = forwardRef(
|
|
|
106
100
|
variant={variant}
|
|
107
101
|
onPress={handleControlPress}
|
|
108
102
|
ref={controlRef}
|
|
109
|
-
isMiniExpandCollapse={isMiniExpandCollapse}
|
|
110
103
|
>
|
|
111
104
|
{control}
|
|
112
105
|
</ExpandCollapseControl>
|
package/src/Link/LinkBase.jsx
CHANGED
|
@@ -6,6 +6,7 @@ import { a11yProps, getTokensPropType, selectSystemProps, variantProp, viewProps
|
|
|
6
6
|
import ListItemContent from './ListItemContent'
|
|
7
7
|
import ListItemMark from './ListItemMark'
|
|
8
8
|
import Typography from '../Typography'
|
|
9
|
+
import { useThemeTokens } from '../ThemeProvider'
|
|
9
10
|
|
|
10
11
|
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps])
|
|
11
12
|
|
|
@@ -43,7 +44,16 @@ const ListItemBase = forwardRef(
|
|
|
43
44
|
|
|
44
45
|
const itemBlockStyles = selectItemBlockStyles(themeTokens)
|
|
45
46
|
const dividerStyles = selectDividerStyles(themeTokens)
|
|
46
|
-
|
|
47
|
+
const { iconMarginTop, itemIconSize } = themeTokens
|
|
48
|
+
let adjustedIconMarginTop = iconMarginTop
|
|
49
|
+
const { fontSize, lineHeight: lineHeightRatio } = useThemeTokens(
|
|
50
|
+
'Typography',
|
|
51
|
+
{},
|
|
52
|
+
{ size: 'h4', bold: true }
|
|
53
|
+
)
|
|
54
|
+
if (title) {
|
|
55
|
+
adjustedIconMarginTop = (fontSize * lineHeightRatio - itemIconSize) / 2
|
|
56
|
+
}
|
|
47
57
|
/**
|
|
48
58
|
* Function responsible returning styling, in case the item is the last shouldn't
|
|
49
59
|
* add extra margin on the bottom, if "showDivider" is true it should add a divider
|
|
@@ -76,11 +86,15 @@ const ListItemBase = forwardRef(
|
|
|
76
86
|
{
|
|
77
87
|
flex: 1,
|
|
78
88
|
flexDirection: 'row'
|
|
79
|
-
}
|
|
80
|
-
!title && { alignItems: 'center' }
|
|
89
|
+
}
|
|
81
90
|
]}
|
|
82
91
|
>
|
|
83
|
-
<ListItemMark
|
|
92
|
+
<ListItemMark
|
|
93
|
+
tokens={{ ...tokens, iconMarginTop: adjustedIconMarginTop }}
|
|
94
|
+
icon={icon}
|
|
95
|
+
iconColor={iconColor}
|
|
96
|
+
iconSize={iconSize}
|
|
97
|
+
/>
|
|
84
98
|
<View style={staticStyles.titleAndContentContainer}>
|
|
85
99
|
{Boolean(title) && (
|
|
86
100
|
<Typography variant={{ size: 'h4', bold: true }}>{title}</Typography>
|
package/src/SideNav/Item.jsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react'
|
|
2
|
-
import { Pressable } from 'react-native'
|
|
2
|
+
import { Pressable, Platform } from 'react-native'
|
|
3
3
|
import PropTypes from 'prop-types'
|
|
4
4
|
import {
|
|
5
5
|
a11yProps,
|
|
@@ -76,13 +76,16 @@ const Item = forwardRef(
|
|
|
76
76
|
})
|
|
77
77
|
|
|
78
78
|
const getTokens = useThemeTokensCallback('SideNavItem', tokens, variant)
|
|
79
|
-
const getAppearanceState = ({ hovered }) => ({
|
|
79
|
+
const getAppearanceState = ({ hovered, focused }) => ({
|
|
80
80
|
hover: hovered,
|
|
81
81
|
active: isActive,
|
|
82
|
-
expanded: isExpanded
|
|
82
|
+
expanded: isExpanded,
|
|
83
|
+
focus: focused
|
|
84
|
+
})
|
|
85
|
+
const getPressableStyle = (pressableState) => ({
|
|
86
|
+
...selectItemStyles(getTokens(getAppearanceState(pressableState))),
|
|
87
|
+
...(Platform.OS === 'web' ? { outline: 'none' } : {})
|
|
83
88
|
})
|
|
84
|
-
const getPressableStyle = (pressableState) =>
|
|
85
|
-
selectItemStyles(getTokens(getAppearanceState(pressableState)))
|
|
86
89
|
|
|
87
90
|
return (
|
|
88
91
|
<Pressable
|
|
@@ -19,12 +19,16 @@ export function selectAccentStyles(tokens) {
|
|
|
19
19
|
/**
|
|
20
20
|
* Content inside an item or control in a SideNav, themed by the SideNavItem theme
|
|
21
21
|
*/
|
|
22
|
-
const ItemContent = ({ children, tokens }) =>
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
const ItemContent = ({ children, tokens }) => {
|
|
23
|
+
const typographyTokens = selectTokens('Typography', tokens)
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<>
|
|
27
|
+
<Typography tokens={typographyTokens}>{children}</Typography>
|
|
28
|
+
<View style={[staticStyles.absolute, selectAccentStyles(tokens)]} />
|
|
29
|
+
</>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
28
32
|
|
|
29
33
|
ItemContent.propTypes = {
|
|
30
34
|
tokens: getTokensPropType('SideNavItem'),
|
|
@@ -37,8 +37,15 @@ const ItemsGroup = forwardRef(
|
|
|
37
37
|
const getItemAppearance = (appearance) => ({ ...getAppearance(appearance), type: 'parent' })
|
|
38
38
|
|
|
39
39
|
const getGroupTokens = useThemeTokensCallback('SideNavItemsGroup', tokens, variant)
|
|
40
|
-
const getPanelTokens = (appearance) =>
|
|
41
|
-
|
|
40
|
+
const getPanelTokens = (appearance) => {
|
|
41
|
+
const { panelBorderColor, ...itemsGroupTokens } = getGroupTokens(getAppearance(appearance))
|
|
42
|
+
const groupTokens = {
|
|
43
|
+
...itemsGroupTokens,
|
|
44
|
+
borderWidth: 0,
|
|
45
|
+
marginBottom: 0
|
|
46
|
+
}
|
|
47
|
+
return selectTokens('ExpandCollapsePanel', groupTokens)
|
|
48
|
+
}
|
|
42
49
|
|
|
43
50
|
const getItemTokens = useThemeTokensCallback('SideNavItem', itemTokens, variant)
|
|
44
51
|
const getControlTokens = (appearance) =>
|
|
@@ -49,6 +56,7 @@ const ItemsGroup = forwardRef(
|
|
|
49
56
|
|
|
50
57
|
const controlContent = (controlState) => {
|
|
51
58
|
const currentItemTokens = getItemTokens(getItemAppearance(controlState))
|
|
59
|
+
|
|
52
60
|
return <ItemContent tokens={currentItemTokens}>{label}</ItemContent>
|
|
53
61
|
}
|
|
54
62
|
|
package/src/SideNav/SideNav.jsx
CHANGED
|
@@ -56,6 +56,7 @@ const SideNav = forwardRef(
|
|
|
56
56
|
onItemPress(...args)
|
|
57
57
|
if (onPress) onPress(...args)
|
|
58
58
|
}
|
|
59
|
+
|
|
59
60
|
return (
|
|
60
61
|
<Item
|
|
61
62
|
{...item.props}
|
|
@@ -78,6 +79,7 @@ const SideNav = forwardRef(
|
|
|
78
79
|
const { groupId = `group-${index}` } = child.props
|
|
79
80
|
const isGroupActive = active.itemId !== undefined && active.groupId === groupId
|
|
80
81
|
const handleToggle = (event) => onToggle(groupId, event)
|
|
82
|
+
|
|
81
83
|
return (
|
|
82
84
|
<ItemsGroup
|
|
83
85
|
{...child.props}
|
|
@@ -52,11 +52,14 @@ const TextInput = forwardRef(({ tokens, nativeID, variant = {}, ...rest }, ref)
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
return (
|
|
55
|
-
|
|
56
|
-
{
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
<>
|
|
56
|
+
<InputSupports nativeID={nativeID} {...supportsProps}>
|
|
57
|
+
{({ inputId, ...propsFromInputSupports }) => (
|
|
58
|
+
<TextInputBase ref={ref} nativeID={inputId} {...propsFromInputSupports} {...inputProps} />
|
|
59
|
+
)}
|
|
60
|
+
</InputSupports>
|
|
61
|
+
{rest.children}
|
|
62
|
+
</>
|
|
60
63
|
)
|
|
61
64
|
})
|
|
62
65
|
TextInput.displayName = 'TextInput'
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { createContext, useState } from 'react'
|
|
1
|
+
import React, { createContext, useEffect, useState } from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import { validateThemeTokensVersion } from './utils'
|
|
4
4
|
import responsiveProps from '../utils/props/responsiveProps'
|
|
@@ -22,6 +22,12 @@ const defaultThemeOptions = {
|
|
|
22
22
|
const ThemeProvider = ({ children, defaultTheme, themeOptions = {} }) => {
|
|
23
23
|
const [theme, setTheme] = useState(defaultTheme)
|
|
24
24
|
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (theme.metadata.name !== defaultTheme.metadata.name) {
|
|
27
|
+
setTheme(defaultTheme)
|
|
28
|
+
}
|
|
29
|
+
}, [theme.metadata.name, defaultTheme])
|
|
30
|
+
|
|
25
31
|
const appliedThemeOptions = { ...defaultThemeOptions, ...themeOptions }
|
|
26
32
|
|
|
27
33
|
// Validate the theme tokens version on every render.
|
|
@@ -42,7 +48,8 @@ ThemeProvider.propTypes = {
|
|
|
42
48
|
children: PropTypes.node.isRequired,
|
|
43
49
|
defaultTheme: PropTypes.shape({
|
|
44
50
|
metadata: PropTypes.shape({
|
|
45
|
-
themeTokensVersion: PropTypes.string.isRequired
|
|
51
|
+
themeTokensVersion: PropTypes.string.isRequired,
|
|
52
|
+
name: PropTypes.string.isRequired
|
|
46
53
|
}).isRequired
|
|
47
54
|
}).isRequired,
|
|
48
55
|
/**
|
|
@@ -23,7 +23,7 @@ import { Platform } from 'react-native'
|
|
|
23
23
|
*/
|
|
24
24
|
// Adding `/** @type {const} */ ({...})` denotes object content as `readonly` in many IDEs
|
|
25
25
|
// eslint-disable-next-line prettier/prettier
|
|
26
|
-
const rolesToTags = /** @type {const} */
|
|
26
|
+
const rolesToTags = /** @type {const} */ {
|
|
27
27
|
article: 'article',
|
|
28
28
|
banner: 'header',
|
|
29
29
|
blockquote: 'blockquote',
|
|
@@ -45,7 +45,7 @@ const rolesToTags = /** @type {const} */ ({
|
|
|
45
45
|
// Add special cases that are in RNW's function logic but not in its mapping object
|
|
46
46
|
label: 'label'
|
|
47
47
|
// eslint-disable-next-line prettier/prettier
|
|
48
|
-
}
|
|
48
|
+
}
|
|
49
49
|
|
|
50
50
|
// Invert React Native Web's mapping, so a tag gets the role that gets that tag
|
|
51
51
|
export const tagsToRoles = Object.fromEntries(
|
|
@@ -57,7 +57,7 @@ export const tagsToRoles = Object.fromEntries(
|
|
|
57
57
|
* to headings on web but without the expectation of a hierarchy of headings within one screen.
|
|
58
58
|
*/
|
|
59
59
|
// eslint-disable-next-line prettier/prettier
|
|
60
|
-
export const headingTags = /** @type {const} */
|
|
60
|
+
export const headingTags = /** @type {const} */ ['h1', 'h2', 'h3', 'h4', 'h5', 'h6']
|
|
61
61
|
/**
|
|
62
62
|
* @typedef {typeof headingTags[number]} HeadingTag
|
|
63
63
|
*/
|
|
@@ -81,7 +81,7 @@ export const supportedTags = [...Object.keys(tagsToRoles), ...headingTags]
|
|
|
81
81
|
* Of these, only headers (h1, h2, ...h5, h6) set a corresponding accessibilityRole in native apps ("heading").
|
|
82
82
|
*/
|
|
83
83
|
// eslint-disable-next-line prettier/prettier
|
|
84
|
-
export const layoutTags = /** @type {const} */
|
|
84
|
+
export const layoutTags = /** @type {const} */ [
|
|
85
85
|
...headingTags,
|
|
86
86
|
'article',
|
|
87
87
|
'aside',
|
|
@@ -97,7 +97,7 @@ export const layoutTags = /** @type {const} */ ([
|
|
|
97
97
|
'section',
|
|
98
98
|
'label'
|
|
99
99
|
// eslint-disable-next-line prettier/prettier
|
|
100
|
-
]
|
|
100
|
+
]
|
|
101
101
|
/**
|
|
102
102
|
* @typedef {typeof layoutTags[number]} LayoutTag
|
|
103
103
|
*/
|
|
@@ -108,7 +108,7 @@ export const layoutTags = /** @type {const} */ ([
|
|
|
108
108
|
* Of these, only headers (h1, h2, ...h5, h6) set a corresponding accessibilityRole in native apps ("heading").
|
|
109
109
|
*/
|
|
110
110
|
// eslint-disable-next-line prettier/prettier
|
|
111
|
-
export const textTags = /** @type {const} */
|
|
111
|
+
export const textTags = /** @type {const} */ [
|
|
112
112
|
...headingTags,
|
|
113
113
|
'blockquote',
|
|
114
114
|
'code',
|
|
@@ -119,7 +119,7 @@ export const textTags = /** @type {const} */ ([
|
|
|
119
119
|
'strong',
|
|
120
120
|
'label'
|
|
121
121
|
// eslint-disable-next-line prettier/prettier
|
|
122
|
-
]
|
|
122
|
+
]
|
|
123
123
|
/**
|
|
124
124
|
* @typedef {typeof layoutTags[number]} TextTag
|
|
125
125
|
*/
|