@telus-uds/components-base 1.70.0 → 1.72.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 +30 -2
- package/jest.setup.js +7 -0
- package/lib/Autocomplete/Autocomplete.js +3 -13
- package/lib/Card/Card.js +68 -7
- package/lib/Card/PressableCardBase.js +2 -0
- package/lib/ColourToggle/ColourBubble.js +135 -0
- package/lib/ColourToggle/ColourToggle.js +101 -0
- package/lib/ColourToggle/index.js +10 -0
- package/lib/FlexGrid/Col/Col.js +50 -64
- package/lib/FlexGrid/FlexGrid.js +37 -40
- package/lib/FlexGrid/Row/Row.js +43 -44
- package/lib/Icon/IconText.js +9 -2
- package/lib/Link/LinkBase.js +10 -3
- package/lib/Modal/ModalContent.js +4 -6
- package/lib/OrderedList/Item.js +180 -0
- package/lib/OrderedList/ItemBase.js +48 -0
- package/lib/OrderedList/OrderedList.js +71 -0
- package/lib/OrderedList/OrderedListBase.js +47 -0
- package/lib/OrderedList/index.js +10 -0
- package/lib/index.js +16 -0
- package/lib/utils/ssr-media-query/create-stylesheet/create-stylesheet-mobile.js +56 -0
- package/lib/utils/ssr-media-query/create-stylesheet/index.android.js +10 -0
- package/lib/utils/ssr-media-query/create-stylesheet/index.ios.js +10 -0
- package/lib/utils/ssr-media-query/create-stylesheet/index.js +44 -0
- package/lib/utils/ssr-media-query/utils/inject.js +13 -0
- package/lib-module/Autocomplete/Autocomplete.js +3 -13
- package/lib-module/Card/Card.js +71 -8
- package/lib-module/Card/PressableCardBase.js +2 -0
- package/lib-module/ColourToggle/ColourBubble.js +125 -0
- package/lib-module/ColourToggle/ColourToggle.js +92 -0
- package/lib-module/ColourToggle/index.js +2 -0
- package/lib-module/FlexGrid/Col/Col.js +51 -65
- package/lib-module/FlexGrid/FlexGrid.js +38 -41
- package/lib-module/FlexGrid/Row/Row.js +44 -45
- package/lib-module/Icon/IconText.js +9 -2
- package/lib-module/Link/LinkBase.js +10 -3
- package/lib-module/Modal/ModalContent.js +4 -6
- package/lib-module/OrderedList/Item.js +171 -0
- package/lib-module/OrderedList/ItemBase.js +37 -0
- package/lib-module/OrderedList/OrderedList.js +61 -0
- package/lib-module/OrderedList/OrderedListBase.js +36 -0
- package/lib-module/OrderedList/index.js +2 -0
- package/lib-module/index.js +2 -0
- package/lib-module/utils/ssr-media-query/create-stylesheet/create-stylesheet-mobile.js +48 -0
- package/lib-module/utils/ssr-media-query/create-stylesheet/index.android.js +2 -0
- package/lib-module/utils/ssr-media-query/create-stylesheet/index.ios.js +2 -0
- package/lib-module/utils/ssr-media-query/create-stylesheet/index.js +36 -0
- package/lib-module/utils/ssr-media-query/utils/inject.js +13 -0
- package/package.json +2 -2
- package/src/Autocomplete/Autocomplete.jsx +14 -21
- package/src/Card/Card.jsx +73 -11
- package/src/Card/PressableCardBase.jsx +2 -0
- package/src/ColourToggle/ColourBubble.jsx +111 -0
- package/src/ColourToggle/ColourToggle.jsx +83 -0
- package/src/ColourToggle/index.js +3 -0
- package/src/FlexGrid/Col/Col.jsx +48 -80
- package/src/FlexGrid/FlexGrid.jsx +36 -44
- package/src/FlexGrid/Row/Row.jsx +38 -56
- package/src/Icon/IconText.jsx +11 -1
- package/src/Link/ChevronLink.jsx +1 -0
- package/src/Link/LinkBase.jsx +16 -6
- package/src/Modal/ModalContent.jsx +4 -6
- package/src/OrderedList/Item.jsx +152 -0
- package/src/OrderedList/ItemBase.jsx +31 -0
- package/src/OrderedList/OrderedList.jsx +61 -0
- package/src/OrderedList/OrderedListBase.jsx +33 -0
- package/src/OrderedList/index.js +3 -0
- package/src/index.js +2 -0
- package/src/utils/ssr-media-query/create-stylesheet/create-stylesheet-mobile.js +41 -0
- package/src/utils/ssr-media-query/create-stylesheet/index.android.js +3 -0
- package/src/utils/ssr-media-query/create-stylesheet/index.ios.js +3 -0
- package/src/utils/ssr-media-query/create-stylesheet/index.js +33 -0
- package/src/utils/ssr-media-query/utils/inject.js +13 -0
- package/types/Badge.d.ts +28 -0
- package/types/Box.d.ts +52 -0
- package/types/ChevronLink.d.ts +47 -0
- package/types/Common.d.ts +106 -0
- package/types/Divider.d.ts +19 -0
- package/types/ExpandCollapse.d.ts +65 -0
- package/types/HorizontalScrollButton.d.ts +16 -0
- package/types/Icon.d.ts +21 -0
- package/types/Link.d.ts +48 -0
- package/types/List.d.ts +48 -0
- package/types/Search.d.ts +38 -0
- package/types/Select.d.ts +57 -0
- package/types/Spacer.d.ts +5 -0
- package/types/StackView.d.ts +28 -0
- package/types/Tabs.d.ts +46 -0
- package/types/TextButton.d.ts +11 -0
- package/types/ToggleSwitch.d.ts +54 -0
- package/types/ToolTip.d.ts +40 -0
- package/types/Typography.d.ts +39 -0
- package/types/index.d.ts +62 -0
- package/lib/utils/ssr-media-query/create-stylesheet.js +0 -76
- package/lib-module/utils/ssr-media-query/create-stylesheet.js +0 -68
- package/src/utils/ssr-media-query/create-stylesheet.js +0 -61
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import React, { forwardRef, useContext } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import Platform from "react-native-web/dist/exports/Platform";
|
|
4
|
-
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
5
|
-
import { viewports } from '@telus-uds/system-constants';
|
|
6
4
|
import GutterContext from '../providers/GutterContext';
|
|
7
|
-
import { useViewport } from '../../ViewportProvider';
|
|
8
5
|
import applyInheritance from '../helpers';
|
|
9
|
-
import { responsiveProps, BaseView } from '../../utils';
|
|
6
|
+
import { responsiveProps, BaseView, StyleSheet, createMediaQueryStyles } from '../../utils';
|
|
10
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
8
|
const Col = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
12
9
|
let {
|
|
@@ -26,7 +23,6 @@ const Col = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
26
23
|
...viewProps
|
|
27
24
|
} = _ref;
|
|
28
25
|
const gutter = useContext(GutterContext);
|
|
29
|
-
const viewPort = useViewport();
|
|
30
26
|
const hiddenLevels = applyInheritance([xs, sm, md, lg, xl]);
|
|
31
27
|
const getHorizontalAlignLevel = () => {
|
|
32
28
|
if (typeof horizontalAlign === 'object') {
|
|
@@ -67,60 +63,11 @@ const Col = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
67
63
|
}
|
|
68
64
|
return {};
|
|
69
65
|
};
|
|
70
|
-
const sizeStyles = sizes => {
|
|
71
|
-
const currViewport = Object.keys(sizes).find(key => key.startsWith(viewPort));
|
|
72
|
-
const currSize = sizes[currViewport];
|
|
73
|
-
return {
|
|
74
|
-
...calculateWidth(currSize)
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
const offsetStyles = offsets => {
|
|
78
|
-
const currViewport = Object.keys(offsets).find(key => key.startsWith(viewPort));
|
|
79
|
-
const currOffset = offsets[currViewport];
|
|
80
|
-
return {
|
|
81
|
-
...calculateOffset(currOffset)
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
const gutterPadding = {
|
|
85
|
-
paddingLeft: gutter ? 16 : 0,
|
|
86
|
-
paddingRight: gutter ? 16 : 0
|
|
87
|
-
};
|
|
88
|
-
let hidingStyles = {};
|
|
89
66
|
|
|
90
67
|
// TODO: consider setting this to always 'flex' in a major release.
|
|
91
68
|
// `display: block` is invalid in native apps.
|
|
92
69
|
// See https://telusdigital.atlassian.net/browse/UDS1-92
|
|
93
70
|
const shown = !flex && Platform.OS === 'web' ? 'block' : 'flex';
|
|
94
|
-
if (viewPort === viewports.xs) {
|
|
95
|
-
hidingStyles = {
|
|
96
|
-
display: hiddenLevels[0] === 0 ? 'none' : shown,
|
|
97
|
-
textAlign: horizontalAlignLevel[0]
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
if (viewPort === viewports.sm) {
|
|
101
|
-
hidingStyles = {
|
|
102
|
-
display: hiddenLevels[1] === 0 ? 'none' : shown,
|
|
103
|
-
textAlign: horizontalAlignLevel[1]
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
if (viewPort === viewports.md) {
|
|
107
|
-
hidingStyles = {
|
|
108
|
-
display: hiddenLevels[2] === 0 ? 'none' : shown,
|
|
109
|
-
textAlign: horizontalAlignLevel[2]
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
if (viewPort === viewports.lg) {
|
|
113
|
-
hidingStyles = {
|
|
114
|
-
display: hiddenLevels[3] === 0 ? 'none' : shown,
|
|
115
|
-
textAlign: horizontalAlignLevel[3]
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
if (viewPort === viewports.xl) {
|
|
119
|
-
hidingStyles = {
|
|
120
|
-
display: hiddenLevels[4] === 0 ? 'none' : shown,
|
|
121
|
-
textAlign: horizontalAlignLevel[4]
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
71
|
const sizesArray = [xs, sm, md, lg, xl];
|
|
125
72
|
const offSetsArray = [xsOffset, smOffset, mdOffset, lgOffset, xlOffset];
|
|
126
73
|
const sizesWithIheritance = applyInheritance(sizesArray);
|
|
@@ -139,24 +86,63 @@ const Col = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
139
86
|
lg: offsetsWithIheritance[3],
|
|
140
87
|
xl: offsetsWithIheritance[4]
|
|
141
88
|
};
|
|
89
|
+
const mediaQueryStyles = createMediaQueryStyles({
|
|
90
|
+
xs: {
|
|
91
|
+
display: hiddenLevels[0] === 0 ? 'none' : shown,
|
|
92
|
+
textAlign: horizontalAlignLevel[0],
|
|
93
|
+
...calculateWidth(sizes.xs),
|
|
94
|
+
...calculateOffset(offsets.xs)
|
|
95
|
+
},
|
|
96
|
+
sm: {
|
|
97
|
+
display: hiddenLevels[1] === 0 ? 'none' : shown,
|
|
98
|
+
textAlign: horizontalAlignLevel[1],
|
|
99
|
+
...calculateWidth(sizes.sm),
|
|
100
|
+
...calculateOffset(offsets.sm)
|
|
101
|
+
},
|
|
102
|
+
md: {
|
|
103
|
+
display: hiddenLevels[2] === 0 ? 'none' : shown,
|
|
104
|
+
textAlign: horizontalAlignLevel[2],
|
|
105
|
+
...calculateWidth(sizes.md),
|
|
106
|
+
...calculateOffset(offsets.md)
|
|
107
|
+
},
|
|
108
|
+
lg: {
|
|
109
|
+
display: hiddenLevels[3] === 0 ? 'none' : shown,
|
|
110
|
+
textAlign: horizontalAlignLevel[3],
|
|
111
|
+
...calculateWidth(sizes.lg),
|
|
112
|
+
...calculateOffset(offsets.lg)
|
|
113
|
+
},
|
|
114
|
+
xl: {
|
|
115
|
+
display: hiddenLevels[4] === 0 ? 'none' : shown,
|
|
116
|
+
textAlign: horizontalAlignLevel[4],
|
|
117
|
+
...calculateWidth(sizes.xl),
|
|
118
|
+
...calculateOffset(offsets.xl)
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
const {
|
|
122
|
+
ids,
|
|
123
|
+
styles
|
|
124
|
+
} = StyleSheet.create({
|
|
125
|
+
col: {
|
|
126
|
+
flexGrow: 1,
|
|
127
|
+
flexShrink: 0,
|
|
128
|
+
flexBasis: 'auto',
|
|
129
|
+
maxWidth: '100%',
|
|
130
|
+
paddingLeft: gutter ? 16 : 0,
|
|
131
|
+
paddingRight: gutter ? 16 : 0,
|
|
132
|
+
...mediaQueryStyles
|
|
133
|
+
}
|
|
134
|
+
});
|
|
142
135
|
return /*#__PURE__*/_jsx(BaseView, {
|
|
143
136
|
ref: ref,
|
|
144
137
|
...viewProps,
|
|
145
|
-
style: [styles.col,
|
|
146
|
-
|
|
147
|
-
|
|
138
|
+
style: [styles.col],
|
|
139
|
+
dataSet: {
|
|
140
|
+
media: ids.col
|
|
141
|
+
},
|
|
148
142
|
children: children
|
|
149
143
|
});
|
|
150
144
|
});
|
|
151
145
|
Col.displayName = 'Col';
|
|
152
|
-
const styles = StyleSheet.create({
|
|
153
|
-
col: {
|
|
154
|
-
flexGrow: 1,
|
|
155
|
-
flexShrink: 0,
|
|
156
|
-
flexBasis: 'auto',
|
|
157
|
-
maxWidth: '100%'
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
146
|
|
|
161
147
|
/*
|
|
162
148
|
* We're disabling default props since passing undefined props to
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
4
3
|
import { viewports } from '@telus-uds/system-constants';
|
|
5
|
-
import { a11yProps, viewProps, getA11yPropsFromHtmlTag, layoutTags, selectSystemProps, BaseView } from '../utils';
|
|
4
|
+
import { a11yProps, viewProps, getA11yPropsFromHtmlTag, layoutTags, selectSystemProps, BaseView, StyleSheet, createMediaQueryStyles } from '../utils';
|
|
6
5
|
import Row from './Row';
|
|
7
6
|
import Col from './Col';
|
|
8
|
-
import { useViewport } from '../ViewportProvider';
|
|
9
7
|
import GutterContext from './providers/GutterContext';
|
|
10
8
|
import applyInheritance from './helpers';
|
|
11
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -30,33 +28,40 @@ const FlexGrid = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
30
28
|
children,
|
|
31
29
|
...rest
|
|
32
30
|
} = _ref;
|
|
33
|
-
const viewPort = useViewport();
|
|
34
31
|
const reverseLevel = applyInheritance([xsReverse, smReverse, mdReverse, lgReverse, xlReverse]);
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
32
|
+
const mediaQueryStyles = createMediaQueryStyles({
|
|
33
|
+
xs: {
|
|
34
|
+
flexDirection: reverseLevel[0] ? 'column-reverse' : 'column'
|
|
35
|
+
},
|
|
36
|
+
sm: {
|
|
37
|
+
maxWidth: limitWidth && viewports.map.get('sm'),
|
|
38
|
+
flexDirection: reverseLevel[1] ? 'column-reverse' : 'column'
|
|
39
|
+
},
|
|
40
|
+
md: {
|
|
41
|
+
maxWidth: limitWidth && viewports.map.get('md'),
|
|
42
|
+
flexDirection: reverseLevel[2] ? 'column-reverse' : 'column'
|
|
43
|
+
},
|
|
44
|
+
lg: {
|
|
45
|
+
maxWidth: limitWidth && viewports.map.get('lg'),
|
|
46
|
+
flexDirection: reverseLevel[3] ? 'column-reverse' : 'column'
|
|
47
|
+
},
|
|
48
|
+
xl: {
|
|
49
|
+
maxWidth: limitWidth && viewports.map.get('xl'),
|
|
50
|
+
flexDirection: reverseLevel[4] ? 'column-reverse' : 'column'
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
const {
|
|
54
|
+
ids,
|
|
55
|
+
styles
|
|
56
|
+
} = StyleSheet.create({
|
|
57
|
+
flexgrid: {
|
|
58
|
+
flexWrap: 'wrap',
|
|
59
|
+
width: outsideGutter ? '100%' : 'auto',
|
|
60
|
+
marginVertical: 0,
|
|
61
|
+
marginHorizontal: outsideGutter ? 'auto' : -16,
|
|
62
|
+
...mediaQueryStyles
|
|
63
|
+
}
|
|
64
|
+
});
|
|
60
65
|
const props = {
|
|
61
66
|
accessibilityRole,
|
|
62
67
|
...getA11yPropsFromHtmlTag(tag, accessibilityRole),
|
|
@@ -67,23 +72,15 @@ const FlexGrid = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
67
72
|
children: /*#__PURE__*/_jsx(BaseView, {
|
|
68
73
|
ref: ref,
|
|
69
74
|
...props,
|
|
70
|
-
style: [styles.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
flexDirection,
|
|
75
|
-
maxWidth
|
|
76
|
-
}],
|
|
75
|
+
style: [styles.flexgrid],
|
|
76
|
+
dataSet: {
|
|
77
|
+
media: ids.flexgrid
|
|
78
|
+
},
|
|
77
79
|
children: children
|
|
78
80
|
})
|
|
79
81
|
});
|
|
80
82
|
});
|
|
81
83
|
FlexGrid.displayName = 'FlexGrid';
|
|
82
|
-
const styles = StyleSheet.create({
|
|
83
|
-
grid: {
|
|
84
|
-
flexWrap: 'wrap'
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
84
|
FlexGrid.propTypes = {
|
|
88
85
|
...selectedSystemPropTypes,
|
|
89
86
|
/**
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
4
|
-
import { viewports } from '@telus-uds/system-constants';
|
|
5
|
-
import { useViewport } from '../../ViewportProvider';
|
|
6
3
|
import applyInheritance from '../helpers';
|
|
7
|
-
import { BaseView } from '../../utils';
|
|
4
|
+
import { BaseView, StyleSheet, createMediaQueryStyles } from '../../utils';
|
|
8
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
6
|
const horizontalAlignStyles = horizontalAlign => {
|
|
10
7
|
switch (horizontalAlign) {
|
|
@@ -72,55 +69,57 @@ const Row = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
72
69
|
children,
|
|
73
70
|
...rest
|
|
74
71
|
} = _ref;
|
|
75
|
-
const viewPort = useViewport();
|
|
76
72
|
const reverseLevel = applyInheritance([xsReverse, smReverse, mdReverse, lgReverse, xlReverse]);
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
73
|
+
const mediaQueryStyles = createMediaQueryStyles({
|
|
74
|
+
xs: {
|
|
75
|
+
flexDirection: reverseLevel[0] ? 'row-reverse' : 'row',
|
|
76
|
+
flexWrap: reverseLevel[0] ? 'wrap-reverse' : 'wrap'
|
|
77
|
+
},
|
|
78
|
+
sm: {
|
|
79
|
+
flexDirection: reverseLevel[1] ? 'row-reverse' : 'row',
|
|
80
|
+
flexWrap: reverseLevel[1] ? 'wrap-reverse' : 'wrap'
|
|
81
|
+
},
|
|
82
|
+
md: {
|
|
83
|
+
flexDirection: reverseLevel[2] ? 'row-reverse' : 'row',
|
|
84
|
+
flexWrap: reverseLevel[2] ? 'wrap-reverse' : 'wrap'
|
|
85
|
+
},
|
|
86
|
+
lg: {
|
|
87
|
+
flexDirection: reverseLevel[3] ? 'row-reverse' : 'row',
|
|
88
|
+
flexWrap: reverseLevel[3] ? 'wrap-reverse' : 'wrap'
|
|
89
|
+
},
|
|
90
|
+
xl: {
|
|
91
|
+
flexDirection: reverseLevel[4] ? 'row-reverse' : 'row',
|
|
92
|
+
flexWrap: reverseLevel[4] ? 'wrap-reverse' : 'wrap'
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
const {
|
|
96
|
+
ids,
|
|
97
|
+
styles
|
|
98
|
+
} = StyleSheet.create({
|
|
99
|
+
row: {
|
|
100
|
+
width: '100%',
|
|
101
|
+
marginVertical: 0,
|
|
102
|
+
marginHorizontal: 'auto',
|
|
103
|
+
flexGrow: 0,
|
|
104
|
+
flexShrink: 1,
|
|
105
|
+
flexBasis: 'auto',
|
|
106
|
+
...horizontalAlignStyles(horizontalAlign),
|
|
107
|
+
...verticalAlignStyles(verticalAlign),
|
|
108
|
+
...distributeStyles(distribute),
|
|
109
|
+
...mediaQueryStyles
|
|
110
|
+
}
|
|
111
|
+
});
|
|
99
112
|
return /*#__PURE__*/_jsx(BaseView, {
|
|
100
113
|
ref: ref,
|
|
101
114
|
...rest,
|
|
102
|
-
style: [styles.row,
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
...verticalAlignStyles(verticalAlign),
|
|
107
|
-
...distributeStyles(distribute)
|
|
108
|
-
}],
|
|
115
|
+
style: [styles.row],
|
|
116
|
+
dataSet: {
|
|
117
|
+
media: ids.row
|
|
118
|
+
},
|
|
109
119
|
children: children
|
|
110
120
|
});
|
|
111
121
|
});
|
|
112
122
|
Row.displayName = 'Row';
|
|
113
|
-
const styles = StyleSheet.create({
|
|
114
|
-
row: {
|
|
115
|
-
width: '100%',
|
|
116
|
-
marginVertical: 0,
|
|
117
|
-
marginHorizontal: 'auto',
|
|
118
|
-
flexGrow: 0,
|
|
119
|
-
flexShrink: 1,
|
|
120
|
-
flexBasis: 'auto',
|
|
121
|
-
flexDirection: 'row'
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
123
|
Row.propTypes = {
|
|
125
124
|
/**
|
|
126
125
|
* Align columns horizontally within their row.
|
|
@@ -16,7 +16,7 @@ import { spacingProps } from '../utils';
|
|
|
16
16
|
*/
|
|
17
17
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
18
|
const IconText = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
19
|
-
var _iconProps$tokens;
|
|
19
|
+
var _iconProps$tokens, _iconProps$tokens2;
|
|
20
20
|
let {
|
|
21
21
|
space,
|
|
22
22
|
iconPosition = 'left',
|
|
@@ -34,6 +34,13 @@ const IconText = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
34
34
|
// Inline images on Android are always baseline-aligned which makes them look misaligned - offset it.
|
|
35
35
|
// See abandoned issue https://github.com/facebook/react-native/issues/6529
|
|
36
36
|
const size = (iconProps === null || iconProps === void 0 ? void 0 : (_iconProps$tokens = iconProps.tokens) === null || _iconProps$tokens === void 0 ? void 0 : _iconProps$tokens.size) ?? 0;
|
|
37
|
+
const valueTranslateY = iconProps === null || iconProps === void 0 ? void 0 : (_iconProps$tokens2 = iconProps.tokens) === null || _iconProps$tokens2 === void 0 ? void 0 : _iconProps$tokens2.translateY;
|
|
38
|
+
/**
|
|
39
|
+
* These calculations were carried out using a set of linear equations to calculate that the
|
|
40
|
+
* position of the icon "->"" is aligned to the first line of the tooltip text on IOS and Android.
|
|
41
|
+
* The issue was mainly on IOS, the translateY style didn't match with the old calculations.
|
|
42
|
+
*/
|
|
43
|
+
const resultY = valueTranslateY ? Math.floor(-1 * (valueTranslateY - 4)) : 0;
|
|
37
44
|
const iconAdjustedAndriod = /*#__PURE__*/_jsx(View, {
|
|
38
45
|
style: {
|
|
39
46
|
transform: [{
|
|
@@ -45,7 +52,7 @@ const IconText = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
45
52
|
const iconAdjustedIOS = /*#__PURE__*/_jsx(View, {
|
|
46
53
|
style: {
|
|
47
54
|
transform: [{
|
|
48
|
-
translateY: size * 0.01
|
|
55
|
+
translateY: valueTranslateY ? resultY : size * 0.01
|
|
49
56
|
}]
|
|
50
57
|
},
|
|
51
58
|
children: iconContent
|
|
@@ -91,13 +91,20 @@ const selectIconTokens = _ref5 => {
|
|
|
91
91
|
let {
|
|
92
92
|
color,
|
|
93
93
|
iconSize,
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
blockFontSize,
|
|
95
|
+
iconTranslateX
|
|
96
96
|
} = _ref5;
|
|
97
|
+
/**
|
|
98
|
+
* These calculations were carried out using a set of linear equations to calculate that the
|
|
99
|
+
* position of the icon "->"" is aligned to the first line of the tooltip text.
|
|
100
|
+
* The base equation is: X/4 + Y/4 - 4 - |X - Y| = Z
|
|
101
|
+
* where X = blockFontSize, Y = iconSize and Z = translateY
|
|
102
|
+
*/
|
|
103
|
+
const translateY = blockFontSize / 4 + iconSize / 4 - 4 - Math.abs(iconSize - blockFontSize);
|
|
97
104
|
return {
|
|
98
105
|
color,
|
|
99
106
|
translateX: iconTranslateX,
|
|
100
|
-
translateY:
|
|
107
|
+
translateY: translateY < 0 ? 0 : translateY,
|
|
101
108
|
size: iconSize
|
|
102
109
|
};
|
|
103
110
|
};
|
|
@@ -31,14 +31,16 @@ const ModalContent = _ref => {
|
|
|
31
31
|
children,
|
|
32
32
|
onCancel
|
|
33
33
|
} = _ref;
|
|
34
|
+
const viewport = useViewport();
|
|
34
35
|
const {
|
|
35
36
|
headingColor,
|
|
36
37
|
cancelButtonColor,
|
|
37
38
|
...themeTokens
|
|
38
|
-
} = useThemeTokens('Modal', tokens, variant
|
|
39
|
+
} = useThemeTokens('Modal', tokens, variant, {
|
|
40
|
+
viewport
|
|
41
|
+
});
|
|
39
42
|
const [scrollContainerHeight, setScrollContainerHeight] = useState(0);
|
|
40
43
|
const [scrollContentHeight, setScrollContentHeight] = useState(0);
|
|
41
|
-
const viewport = useViewport();
|
|
42
44
|
const handleContainerLayout = _ref2 => {
|
|
43
45
|
let {
|
|
44
46
|
nativeEvent: {
|
|
@@ -133,7 +135,6 @@ const ModalContent = _ref => {
|
|
|
133
135
|
onPress: onConfirm,
|
|
134
136
|
children: confirmButtonText
|
|
135
137
|
}), hasCancelButton ? /*#__PURE__*/_jsx(View, {
|
|
136
|
-
style: styles.styledTextButtonContainer,
|
|
137
138
|
children: /*#__PURE__*/_jsx(CancelButton, {
|
|
138
139
|
tokens: {
|
|
139
140
|
color: cancelButtonColor
|
|
@@ -150,9 +151,6 @@ const styles = StyleSheet.create({
|
|
|
150
151
|
flex: 1,
|
|
151
152
|
flexDirection: 'column',
|
|
152
153
|
minHeight: Platform.OS === 'web' ? '100%' : 'auto'
|
|
153
|
-
},
|
|
154
|
-
styledTextButtonContainer: {
|
|
155
|
-
flex: 1
|
|
156
154
|
}
|
|
157
155
|
});
|
|
158
156
|
ModalContent.propTypes = {
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import View from "react-native-web/dist/exports/View";
|
|
4
|
+
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
5
|
+
import { getTokensPropType, htmlAttrs, selectSystemProps, variantProp, viewProps, wrapStringsInText } from '../utils';
|
|
6
|
+
import { applyTextStyles, useTheme, useThemeTokens } from '../ThemeProvider';
|
|
7
|
+
import StackView from '../StackView';
|
|
8
|
+
import Typography from '../Typography';
|
|
9
|
+
import ItemBase from './ItemBase';
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs, viewProps]);
|
|
13
|
+
const selectItemTextStyles = (_ref, themeOptions) => {
|
|
14
|
+
let {
|
|
15
|
+
itemFontHeight,
|
|
16
|
+
itemFontSize,
|
|
17
|
+
itemLineHeight,
|
|
18
|
+
itemFontName,
|
|
19
|
+
itemColor
|
|
20
|
+
} = _ref;
|
|
21
|
+
return applyTextStyles({
|
|
22
|
+
fontWeight: itemFontHeight,
|
|
23
|
+
fontSize: itemFontSize,
|
|
24
|
+
fontName: itemFontName,
|
|
25
|
+
color: itemColor,
|
|
26
|
+
themeOptions,
|
|
27
|
+
lineHeight: itemLineHeight
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
const selectItemCounterStyles = _ref2 => {
|
|
31
|
+
let {
|
|
32
|
+
itemBulletContainerWidth,
|
|
33
|
+
itemBulletContainerAlign,
|
|
34
|
+
itemFontWeight,
|
|
35
|
+
itemFontSize,
|
|
36
|
+
itemFontName,
|
|
37
|
+
itemLineHeight,
|
|
38
|
+
themeOptions,
|
|
39
|
+
listGutter,
|
|
40
|
+
itemColor
|
|
41
|
+
} = _ref2;
|
|
42
|
+
return {
|
|
43
|
+
color: itemColor,
|
|
44
|
+
width: itemBulletContainerWidth,
|
|
45
|
+
paddingRight: listGutter,
|
|
46
|
+
textAlign: itemBulletContainerAlign,
|
|
47
|
+
...applyTextStyles({
|
|
48
|
+
fontWeight: itemFontWeight,
|
|
49
|
+
fontSize: itemFontSize,
|
|
50
|
+
fontName: itemFontName,
|
|
51
|
+
themeOptions
|
|
52
|
+
}),
|
|
53
|
+
lineHeight: itemLineHeight * itemFontSize
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
const selectItemContentStyles = (_ref3, isLastChild) => {
|
|
57
|
+
let {
|
|
58
|
+
interItemMargin,
|
|
59
|
+
...themeTokens
|
|
60
|
+
} = _ref3;
|
|
61
|
+
return {
|
|
62
|
+
...themeTokens,
|
|
63
|
+
marginBottom: !isLastChild ? interItemMargin : 0
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
const Item = /*#__PURE__*/forwardRef((_ref4, ref) => {
|
|
67
|
+
let {
|
|
68
|
+
children,
|
|
69
|
+
index,
|
|
70
|
+
isLastChild,
|
|
71
|
+
title,
|
|
72
|
+
tokens,
|
|
73
|
+
variant,
|
|
74
|
+
...rest
|
|
75
|
+
} = _ref4;
|
|
76
|
+
const themeTokens = useThemeTokens('OrderedList', tokens, variant);
|
|
77
|
+
const headingTokens = title && {
|
|
78
|
+
lineHeight: themeTokens.itemLineHeight,
|
|
79
|
+
fontSize: themeTokens.itemFontSize,
|
|
80
|
+
color: themeTokens.itemColor,
|
|
81
|
+
fontName: themeTokens.headerFontName,
|
|
82
|
+
fontWeight: themeTokens.headerFontWeight
|
|
83
|
+
};
|
|
84
|
+
const {
|
|
85
|
+
themeOptions
|
|
86
|
+
} = useTheme();
|
|
87
|
+
const itemContent = wrapStringsInText(children, {
|
|
88
|
+
style: selectItemTextStyles(themeTokens, themeOptions)
|
|
89
|
+
});
|
|
90
|
+
const itemCounter = wrapStringsInText(`${index}.`, {
|
|
91
|
+
style: selectItemTextStyles(themeTokens, themeOptions)
|
|
92
|
+
});
|
|
93
|
+
return /*#__PURE__*/_jsxs(ItemBase, {
|
|
94
|
+
ref: ref,
|
|
95
|
+
style: {
|
|
96
|
+
...staticStyles.container,
|
|
97
|
+
...themeTokens
|
|
98
|
+
},
|
|
99
|
+
...selectProps(rest),
|
|
100
|
+
children: [/*#__PURE__*/_jsx(View, {
|
|
101
|
+
style: [staticStyles.itemCounter, selectItemCounterStyles(themeTokens)],
|
|
102
|
+
children: itemCounter
|
|
103
|
+
}), /*#__PURE__*/_jsx(View, {
|
|
104
|
+
style: staticStyles.itemContent,
|
|
105
|
+
children: title ? /*#__PURE__*/_jsxs(StackView, {
|
|
106
|
+
tokens: {
|
|
107
|
+
flexShrink: 1
|
|
108
|
+
},
|
|
109
|
+
space: 0,
|
|
110
|
+
children: [/*#__PURE__*/_jsx(Typography, {
|
|
111
|
+
variant: {
|
|
112
|
+
size: 'h4'
|
|
113
|
+
},
|
|
114
|
+
tokens: headingTokens,
|
|
115
|
+
children: title
|
|
116
|
+
}), /*#__PURE__*/_jsx(View, {
|
|
117
|
+
style: selectItemContentStyles(themeTokens, isLastChild),
|
|
118
|
+
children: itemContent
|
|
119
|
+
})]
|
|
120
|
+
}) : /*#__PURE__*/_jsx(View, {
|
|
121
|
+
style: selectItemContentStyles(themeTokens, isLastChild),
|
|
122
|
+
children: itemContent
|
|
123
|
+
})
|
|
124
|
+
})]
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
Item.propTypes = {
|
|
128
|
+
...selectedSystemPropTypes,
|
|
129
|
+
/**
|
|
130
|
+
* Item content
|
|
131
|
+
*/
|
|
132
|
+
children: PropTypes.node.isRequired,
|
|
133
|
+
/**
|
|
134
|
+
* Item index
|
|
135
|
+
*/
|
|
136
|
+
index: PropTypes.number,
|
|
137
|
+
/**
|
|
138
|
+
* If true, the item is the last one on the list
|
|
139
|
+
*/
|
|
140
|
+
isLastChild: PropTypes.bool,
|
|
141
|
+
/**
|
|
142
|
+
* Defines the title of the `OrderedList.Item`
|
|
143
|
+
*/
|
|
144
|
+
title: PropTypes.string,
|
|
145
|
+
/**
|
|
146
|
+
* Item tokens
|
|
147
|
+
*/
|
|
148
|
+
tokens: getTokensPropType('List'),
|
|
149
|
+
/**
|
|
150
|
+
* Item variant
|
|
151
|
+
*/
|
|
152
|
+
variant: variantProp.propType
|
|
153
|
+
};
|
|
154
|
+
Item.displayName = 'OrderedListItem';
|
|
155
|
+
Item.defaultProps = {
|
|
156
|
+
title: undefined,
|
|
157
|
+
tokens: {}
|
|
158
|
+
};
|
|
159
|
+
export default Item;
|
|
160
|
+
const staticStyles = StyleSheet.create({
|
|
161
|
+
container: {
|
|
162
|
+
flexDirection: 'row'
|
|
163
|
+
},
|
|
164
|
+
itemCounter: {
|
|
165
|
+
flexWrap: 'wrap'
|
|
166
|
+
},
|
|
167
|
+
itemContent: {
|
|
168
|
+
flexDirection: 'column',
|
|
169
|
+
marginLeft: 8
|
|
170
|
+
}
|
|
171
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/* eslint-disable react-native-a11y/has-valid-accessibility-role */
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import View from "react-native-web/dist/exports/View";
|
|
5
|
+
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
const Item = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
8
|
+
let {
|
|
9
|
+
children,
|
|
10
|
+
style,
|
|
11
|
+
...rest
|
|
12
|
+
} = _ref;
|
|
13
|
+
return /*#__PURE__*/_jsx(View, {
|
|
14
|
+
accessibilityRole: "listitem",
|
|
15
|
+
ref: ref,
|
|
16
|
+
style: [staticStyles.container, style],
|
|
17
|
+
...rest,
|
|
18
|
+
children: children
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
Item.propTypes = {
|
|
22
|
+
/**
|
|
23
|
+
* Item content
|
|
24
|
+
*/
|
|
25
|
+
children: PropTypes.node.isRequired,
|
|
26
|
+
/**
|
|
27
|
+
* Item custom styles
|
|
28
|
+
*/
|
|
29
|
+
style: PropTypes.object
|
|
30
|
+
};
|
|
31
|
+
Item.displayName = 'OrderedListItem';
|
|
32
|
+
export default Item;
|
|
33
|
+
const staticStyles = StyleSheet.create({
|
|
34
|
+
container: {
|
|
35
|
+
display: 'flex'
|
|
36
|
+
}
|
|
37
|
+
});
|