@telus-uds/components-web 1.2.0 → 1.3.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 +13 -2
- package/lib/OrderedList/Item.js +162 -0
- package/lib/OrderedList/ItemBase.js +42 -0
- package/lib/OrderedList/OrderedList.js +94 -0
- package/lib/OrderedList/OrderedListBase.js +68 -0
- package/lib/OrderedList/constants.js +9 -0
- package/lib/OrderedList/index.js +16 -0
- package/lib/index.js +9 -0
- package/lib-module/OrderedList/Item.js +139 -0
- package/lib-module/OrderedList/ItemBase.js +28 -0
- package/lib-module/OrderedList/OrderedList.js +71 -0
- package/lib-module/OrderedList/OrderedListBase.js +48 -0
- package/lib-module/OrderedList/constants.js +2 -0
- package/lib-module/OrderedList/index.js +4 -0
- package/lib-module/index.js +1 -0
- package/package.json +4 -3
- package/src/OrderedList/Item.jsx +121 -0
- package/src/OrderedList/ItemBase.jsx +18 -0
- package/src/OrderedList/OrderedList.jsx +61 -0
- package/src/OrderedList/OrderedListBase.jsx +38 -0
- package/src/OrderedList/constants.js +2 -0
- package/src/OrderedList/index.js +6 -0
- package/src/index.js +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
# Change Log - @telus-uds/components-web
|
|
2
2
|
|
|
3
|
-
This log was last generated on Tue, 04 Apr 2023
|
|
3
|
+
This log was last generated on Tue, 04 Apr 2023 19:53:51 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 1.3.0
|
|
8
|
+
|
|
9
|
+
Tue, 04 Apr 2023 19:53:51 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- feat: move 'OrderedList' into components-web & pass variants to children(list items) (kyle.king2@telus.com)
|
|
14
|
+
- Bump @telus-uds/components-base to v1.33.0
|
|
15
|
+
- Bump @telus-uds/system-theme-tokens to v2.17.0
|
|
16
|
+
- Bump @telus-uds/palette-allium to v2.12.3
|
|
17
|
+
|
|
7
18
|
## 1.2.0
|
|
8
19
|
|
|
9
|
-
Tue, 04 Apr 2023 14:45
|
|
20
|
+
Tue, 04 Apr 2023 14:52:45 GMT
|
|
10
21
|
|
|
11
22
|
### Minor changes
|
|
12
23
|
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
13
|
+
|
|
14
|
+
var _componentsBase = require("@telus-uds/components-base");
|
|
15
|
+
|
|
16
|
+
var _ItemBase = _interopRequireDefault(require("./ItemBase"));
|
|
17
|
+
|
|
18
|
+
var _utils = require("../utils");
|
|
19
|
+
|
|
20
|
+
var _constants = require("./constants");
|
|
21
|
+
|
|
22
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
23
|
+
|
|
24
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
+
|
|
26
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
27
|
+
|
|
28
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
|
+
|
|
30
|
+
const [selectProps, selectedSystemPropTypes] = (0, _componentsBase.selectSystemProps)([_utils.htmlAttrs]);
|
|
31
|
+
|
|
32
|
+
const selectItemTextStyles = (_ref, themeOptions) => {
|
|
33
|
+
let {
|
|
34
|
+
itemFontWeight,
|
|
35
|
+
itemFontSize,
|
|
36
|
+
itemLineHeight,
|
|
37
|
+
itemFontName,
|
|
38
|
+
itemColor
|
|
39
|
+
} = _ref;
|
|
40
|
+
return (0, _componentsBase.applyTextStyles)({
|
|
41
|
+
fontWeight: itemFontWeight,
|
|
42
|
+
fontSize: itemFontSize,
|
|
43
|
+
fontName: itemFontName,
|
|
44
|
+
color: itemColor,
|
|
45
|
+
themeOptions,
|
|
46
|
+
lineHeight: itemLineHeight
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const StyledItemBase = /*#__PURE__*/(0, _styledComponents.default)(_ItemBase.default).withConfig({
|
|
51
|
+
displayName: "Item__StyledItemBase",
|
|
52
|
+
componentId: "components-web__sc-7jzwcq-0"
|
|
53
|
+
})(_ref2 => {
|
|
54
|
+
let {
|
|
55
|
+
interItemMargin,
|
|
56
|
+
itemBulletContainerWidth,
|
|
57
|
+
itemBulletContainerAlign,
|
|
58
|
+
itemFontWeight,
|
|
59
|
+
itemFontSize,
|
|
60
|
+
itemFontName,
|
|
61
|
+
itemLineHeight,
|
|
62
|
+
themeOptions,
|
|
63
|
+
listGutter,
|
|
64
|
+
itemColor
|
|
65
|
+
} = _ref2;
|
|
66
|
+
return {
|
|
67
|
+
counterIncrement: _constants.OL_COUNTER_NAME,
|
|
68
|
+
'::before': {
|
|
69
|
+
content: `counter(${_constants.OL_COUNTER_NAME})'.'`,
|
|
70
|
+
display: 'inline-flex',
|
|
71
|
+
color: itemColor,
|
|
72
|
+
width: itemBulletContainerWidth,
|
|
73
|
+
paddingRight: listGutter,
|
|
74
|
+
textAlign: itemBulletContainerAlign,
|
|
75
|
+
...(0, _componentsBase.applyTextStyles)({
|
|
76
|
+
fontWeight: itemFontWeight,
|
|
77
|
+
fontSize: itemFontSize,
|
|
78
|
+
fontName: itemFontName,
|
|
79
|
+
themeOptions
|
|
80
|
+
}),
|
|
81
|
+
lineHeight: `${itemLineHeight * itemFontSize}px`
|
|
82
|
+
},
|
|
83
|
+
':not(:last-child)': {
|
|
84
|
+
marginBottom: interItemMargin
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const ItemContent = /*#__PURE__*/_styledComponents.default.div.withConfig({
|
|
90
|
+
displayName: "Item__ItemContent",
|
|
91
|
+
componentId: "components-web__sc-7jzwcq-1"
|
|
92
|
+
})({
|
|
93
|
+
flex: 1
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const Item = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) => {
|
|
97
|
+
let {
|
|
98
|
+
children,
|
|
99
|
+
counterName,
|
|
100
|
+
title,
|
|
101
|
+
tokens,
|
|
102
|
+
variant,
|
|
103
|
+
...rest
|
|
104
|
+
} = _ref3;
|
|
105
|
+
// We are reusing some tokens from the list component here in order to provide a unified
|
|
106
|
+
// experience
|
|
107
|
+
const themeTokens = (0, _componentsBase.useThemeTokens)('OrderedList', tokens, variant);
|
|
108
|
+
const headingTokens = title && {
|
|
109
|
+
lineHeight: themeTokens.itemLineHeight,
|
|
110
|
+
fontSize: themeTokens.itemFontSize,
|
|
111
|
+
color: themeTokens.itemColor,
|
|
112
|
+
fontName: themeTokens.headerFontName,
|
|
113
|
+
fontWeight: themeTokens.headerFontWeight
|
|
114
|
+
};
|
|
115
|
+
const {
|
|
116
|
+
themeOptions
|
|
117
|
+
} = (0, _componentsBase.useTheme)();
|
|
118
|
+
const itemContent = (0, _componentsBase.wrapStringsInText)(children, {
|
|
119
|
+
style: selectItemTextStyles(themeTokens, themeOptions)
|
|
120
|
+
});
|
|
121
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledItemBase, {
|
|
122
|
+
ref: ref,
|
|
123
|
+
themeOptions: themeOptions,
|
|
124
|
+
...themeTokens,
|
|
125
|
+
...selectProps(rest),
|
|
126
|
+
children: title ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_componentsBase.StackView, {
|
|
127
|
+
tokens: {
|
|
128
|
+
flexShrink: 1
|
|
129
|
+
},
|
|
130
|
+
space: 0,
|
|
131
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Typography, {
|
|
132
|
+
variant: {
|
|
133
|
+
size: 'h4'
|
|
134
|
+
},
|
|
135
|
+
tokens: headingTokens,
|
|
136
|
+
children: title
|
|
137
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(ItemContent, { ...themeTokens,
|
|
138
|
+
children: itemContent
|
|
139
|
+
})]
|
|
140
|
+
}) : itemContent
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
Item.displayName = 'OrderedListItem';
|
|
144
|
+
Item.propTypes = { ...selectedSystemPropTypes,
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Item content
|
|
148
|
+
*/
|
|
149
|
+
children: _propTypes.default.node.isRequired,
|
|
150
|
+
title: _propTypes.default.string,
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Item tokens
|
|
154
|
+
*/
|
|
155
|
+
tokens: (0, _componentsBase.getTokensPropType)('List')
|
|
156
|
+
};
|
|
157
|
+
Item.defaultProps = {
|
|
158
|
+
title: undefined,
|
|
159
|
+
tokens: {}
|
|
160
|
+
};
|
|
161
|
+
var _default = Item;
|
|
162
|
+
exports.default = _default;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
13
|
+
|
|
14
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
|
|
18
|
+
const StyledItem = /*#__PURE__*/_styledComponents.default.li.withConfig({
|
|
19
|
+
displayName: "ItemBase__StyledItem",
|
|
20
|
+
componentId: "components-web__sc-o0oiv5-0"
|
|
21
|
+
})({
|
|
22
|
+
display: 'flex'
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const Item = _ref => {
|
|
26
|
+
let {
|
|
27
|
+
children,
|
|
28
|
+
...rest
|
|
29
|
+
} = _ref;
|
|
30
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledItem, { ...rest,
|
|
31
|
+
children: children
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
Item.propTypes = {
|
|
36
|
+
/**
|
|
37
|
+
* Item content
|
|
38
|
+
*/
|
|
39
|
+
children: _propTypes.default.node.isRequired
|
|
40
|
+
};
|
|
41
|
+
var _default = Item;
|
|
42
|
+
exports.default = _default;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
13
|
+
|
|
14
|
+
var _componentsBase = require("@telus-uds/components-base");
|
|
15
|
+
|
|
16
|
+
var _utils = require("../utils");
|
|
17
|
+
|
|
18
|
+
var _OrderedListBase = _interopRequireDefault(require("./OrderedListBase"));
|
|
19
|
+
|
|
20
|
+
var _Item = _interopRequireDefault(require("./Item"));
|
|
21
|
+
|
|
22
|
+
var _constants = require("./constants");
|
|
23
|
+
|
|
24
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
25
|
+
|
|
26
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
+
|
|
28
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
29
|
+
|
|
30
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
31
|
+
|
|
32
|
+
const [selectProps, selectedSystemPropTypes] = (0, _componentsBase.selectSystemProps)([_utils.htmlAttrs]);
|
|
33
|
+
const StyledOrderedListBase = /*#__PURE__*/(0, _styledComponents.default)(_OrderedListBase.default).withConfig({
|
|
34
|
+
displayName: "OrderedList__StyledOrderedListBase",
|
|
35
|
+
componentId: "components-web__sc-t5az8z-0"
|
|
36
|
+
})(_ref => {
|
|
37
|
+
let {
|
|
38
|
+
start
|
|
39
|
+
} = _ref;
|
|
40
|
+
return {
|
|
41
|
+
// Using CSS counters here to have better control over the number styling
|
|
42
|
+
listStyle: 'none',
|
|
43
|
+
counterReset: `${_constants.OL_COUNTER_NAME} ${start - 1}`
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
/**
|
|
47
|
+
* Themed semantic ordered list.
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
const OrderedList = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
|
|
51
|
+
let {
|
|
52
|
+
children,
|
|
53
|
+
start,
|
|
54
|
+
variant,
|
|
55
|
+
...rest
|
|
56
|
+
} = _ref2;
|
|
57
|
+
// Pass any variants "OrderedList" receives down to the individual list items.
|
|
58
|
+
const childrenWithParentVariants = variant ? children.map(child => {
|
|
59
|
+
var _child$props;
|
|
60
|
+
|
|
61
|
+
const existingChildVariants = ((_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.variant) ?? {};
|
|
62
|
+
return { ...child,
|
|
63
|
+
props: { ...child.props,
|
|
64
|
+
variant: { ...existingChildVariants,
|
|
65
|
+
...variant
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}) : children;
|
|
70
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledOrderedListBase, { ...selectProps(rest),
|
|
71
|
+
ref: ref,
|
|
72
|
+
start: start,
|
|
73
|
+
children: childrenWithParentVariants
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
OrderedList.displayName = 'OrderedList';
|
|
77
|
+
OrderedList.propTypes = { ...selectedSystemPropTypes,
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* A list of ordered items wrapped in `OrderedList.Item`.
|
|
81
|
+
*/
|
|
82
|
+
children: _propTypes.default.node.isRequired,
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The position to start the list with.
|
|
86
|
+
*/
|
|
87
|
+
start: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string])
|
|
88
|
+
};
|
|
89
|
+
OrderedList.defaultProps = {
|
|
90
|
+
start: 1
|
|
91
|
+
};
|
|
92
|
+
OrderedList.Item = _Item.default;
|
|
93
|
+
var _default = OrderedList;
|
|
94
|
+
exports.default = _default;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
13
|
+
|
|
14
|
+
var _ItemBase = _interopRequireDefault(require("./ItemBase"));
|
|
15
|
+
|
|
16
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
|
+
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
|
|
20
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
|
+
|
|
22
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
|
+
|
|
24
|
+
const StyledList = /*#__PURE__*/_styledComponents.default.ol.withConfig({
|
|
25
|
+
displayName: "OrderedListBase__StyledList",
|
|
26
|
+
componentId: "components-web__sc-4m9lgj-0"
|
|
27
|
+
})({
|
|
28
|
+
display: 'flex',
|
|
29
|
+
flexDirection: 'column',
|
|
30
|
+
listStylePosition: 'inside',
|
|
31
|
+
margin: 0,
|
|
32
|
+
padding: 0
|
|
33
|
+
});
|
|
34
|
+
/**
|
|
35
|
+
* Semantic ordered list.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
const OrderedListBase = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
40
|
+
let {
|
|
41
|
+
children,
|
|
42
|
+
start,
|
|
43
|
+
...rest
|
|
44
|
+
} = _ref;
|
|
45
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledList, { ...rest,
|
|
46
|
+
ref: ref,
|
|
47
|
+
start: start,
|
|
48
|
+
children: children
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
OrderedListBase.displayName = 'OrderedList';
|
|
52
|
+
OrderedListBase.propTypes = {
|
|
53
|
+
/**
|
|
54
|
+
* A list of ordered items wrapped in `OrderedListBase.Item`.
|
|
55
|
+
*/
|
|
56
|
+
children: _propTypes.default.node.isRequired,
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The position to start the list with.
|
|
60
|
+
*/
|
|
61
|
+
start: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string])
|
|
62
|
+
};
|
|
63
|
+
OrderedListBase.defaultProps = {
|
|
64
|
+
start: 1
|
|
65
|
+
};
|
|
66
|
+
OrderedListBase.Item = _ItemBase.default;
|
|
67
|
+
var _default = OrderedListBase;
|
|
68
|
+
exports.default = _default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.OL_COUNTER_NAME = void 0;
|
|
7
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
8
|
+
const OL_COUNTER_NAME = 'allium-ordered-list-counter';
|
|
9
|
+
exports.OL_COUNTER_NAME = OL_COUNTER_NAME;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _OrderedList = _interopRequireDefault(require("./OrderedList"));
|
|
9
|
+
|
|
10
|
+
var _Item = _interopRequireDefault(require("./Item"));
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
_OrderedList.default.Item = _Item.default;
|
|
15
|
+
var _default = _OrderedList.default;
|
|
16
|
+
exports.default = _default;
|
package/lib/index.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
var _exportNames = {
|
|
7
7
|
Badge: true,
|
|
8
|
+
OrderedList: true,
|
|
8
9
|
Ribbon: true,
|
|
9
10
|
transformGradient: true
|
|
10
11
|
};
|
|
@@ -14,6 +15,12 @@ Object.defineProperty(exports, "Badge", {
|
|
|
14
15
|
return _Badge.default;
|
|
15
16
|
}
|
|
16
17
|
});
|
|
18
|
+
Object.defineProperty(exports, "OrderedList", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _OrderedList.default;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
17
24
|
Object.defineProperty(exports, "Ribbon", {
|
|
18
25
|
enumerable: true,
|
|
19
26
|
get: function () {
|
|
@@ -29,6 +36,8 @@ Object.defineProperty(exports, "transformGradient", {
|
|
|
29
36
|
|
|
30
37
|
var _Badge = _interopRequireDefault(require("./Badge"));
|
|
31
38
|
|
|
39
|
+
var _OrderedList = _interopRequireDefault(require("./OrderedList"));
|
|
40
|
+
|
|
32
41
|
var _Ribbon = _interopRequireDefault(require("./Ribbon"));
|
|
33
42
|
|
|
34
43
|
var _utils = require("./utils");
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { applyTextStyles, getTokensPropType, selectSystemProps, StackView, Typography, useTheme, useThemeTokens, wrapStringsInText } from '@telus-uds/components-base';
|
|
5
|
+
import ItemBase from './ItemBase';
|
|
6
|
+
import { htmlAttrs } from '../utils';
|
|
7
|
+
import { OL_COUNTER_NAME } from './constants';
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs]);
|
|
11
|
+
|
|
12
|
+
const selectItemTextStyles = (_ref, themeOptions) => {
|
|
13
|
+
let {
|
|
14
|
+
itemFontWeight,
|
|
15
|
+
itemFontSize,
|
|
16
|
+
itemLineHeight,
|
|
17
|
+
itemFontName,
|
|
18
|
+
itemColor
|
|
19
|
+
} = _ref;
|
|
20
|
+
return applyTextStyles({
|
|
21
|
+
fontWeight: itemFontWeight,
|
|
22
|
+
fontSize: itemFontSize,
|
|
23
|
+
fontName: itemFontName,
|
|
24
|
+
color: itemColor,
|
|
25
|
+
themeOptions,
|
|
26
|
+
lineHeight: itemLineHeight
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const StyledItemBase = /*#__PURE__*/styled(ItemBase).withConfig({
|
|
31
|
+
displayName: "Item__StyledItemBase",
|
|
32
|
+
componentId: "components-web__sc-7jzwcq-0"
|
|
33
|
+
})(_ref2 => {
|
|
34
|
+
let {
|
|
35
|
+
interItemMargin,
|
|
36
|
+
itemBulletContainerWidth,
|
|
37
|
+
itemBulletContainerAlign,
|
|
38
|
+
itemFontWeight,
|
|
39
|
+
itemFontSize,
|
|
40
|
+
itemFontName,
|
|
41
|
+
itemLineHeight,
|
|
42
|
+
themeOptions,
|
|
43
|
+
listGutter,
|
|
44
|
+
itemColor
|
|
45
|
+
} = _ref2;
|
|
46
|
+
return {
|
|
47
|
+
counterIncrement: OL_COUNTER_NAME,
|
|
48
|
+
'::before': {
|
|
49
|
+
content: `counter(${OL_COUNTER_NAME})'.'`,
|
|
50
|
+
display: 'inline-flex',
|
|
51
|
+
color: itemColor,
|
|
52
|
+
width: itemBulletContainerWidth,
|
|
53
|
+
paddingRight: listGutter,
|
|
54
|
+
textAlign: itemBulletContainerAlign,
|
|
55
|
+
...applyTextStyles({
|
|
56
|
+
fontWeight: itemFontWeight,
|
|
57
|
+
fontSize: itemFontSize,
|
|
58
|
+
fontName: itemFontName,
|
|
59
|
+
themeOptions
|
|
60
|
+
}),
|
|
61
|
+
lineHeight: `${itemLineHeight * itemFontSize}px`
|
|
62
|
+
},
|
|
63
|
+
':not(:last-child)': {
|
|
64
|
+
marginBottom: interItemMargin
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
const ItemContent = /*#__PURE__*/styled.div.withConfig({
|
|
69
|
+
displayName: "Item__ItemContent",
|
|
70
|
+
componentId: "components-web__sc-7jzwcq-1"
|
|
71
|
+
})({
|
|
72
|
+
flex: 1
|
|
73
|
+
});
|
|
74
|
+
const Item = /*#__PURE__*/forwardRef((_ref3, ref) => {
|
|
75
|
+
let {
|
|
76
|
+
children,
|
|
77
|
+
counterName,
|
|
78
|
+
title,
|
|
79
|
+
tokens,
|
|
80
|
+
variant,
|
|
81
|
+
...rest
|
|
82
|
+
} = _ref3;
|
|
83
|
+
// We are reusing some tokens from the list component here in order to provide a unified
|
|
84
|
+
// experience
|
|
85
|
+
const themeTokens = useThemeTokens('OrderedList', tokens, variant);
|
|
86
|
+
const headingTokens = title && {
|
|
87
|
+
lineHeight: themeTokens.itemLineHeight,
|
|
88
|
+
fontSize: themeTokens.itemFontSize,
|
|
89
|
+
color: themeTokens.itemColor,
|
|
90
|
+
fontName: themeTokens.headerFontName,
|
|
91
|
+
fontWeight: themeTokens.headerFontWeight
|
|
92
|
+
};
|
|
93
|
+
const {
|
|
94
|
+
themeOptions
|
|
95
|
+
} = useTheme();
|
|
96
|
+
const itemContent = wrapStringsInText(children, {
|
|
97
|
+
style: selectItemTextStyles(themeTokens, themeOptions)
|
|
98
|
+
});
|
|
99
|
+
return /*#__PURE__*/_jsx(StyledItemBase, {
|
|
100
|
+
ref: ref,
|
|
101
|
+
themeOptions: themeOptions,
|
|
102
|
+
...themeTokens,
|
|
103
|
+
...selectProps(rest),
|
|
104
|
+
children: title ? /*#__PURE__*/_jsxs(StackView, {
|
|
105
|
+
tokens: {
|
|
106
|
+
flexShrink: 1
|
|
107
|
+
},
|
|
108
|
+
space: 0,
|
|
109
|
+
children: [/*#__PURE__*/_jsx(Typography, {
|
|
110
|
+
variant: {
|
|
111
|
+
size: 'h4'
|
|
112
|
+
},
|
|
113
|
+
tokens: headingTokens,
|
|
114
|
+
children: title
|
|
115
|
+
}), /*#__PURE__*/_jsx(ItemContent, { ...themeTokens,
|
|
116
|
+
children: itemContent
|
|
117
|
+
})]
|
|
118
|
+
}) : itemContent
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
Item.displayName = 'OrderedListItem';
|
|
122
|
+
Item.propTypes = { ...selectedSystemPropTypes,
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Item content
|
|
126
|
+
*/
|
|
127
|
+
children: PropTypes.node.isRequired,
|
|
128
|
+
title: PropTypes.string,
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Item tokens
|
|
132
|
+
*/
|
|
133
|
+
tokens: getTokensPropType('List')
|
|
134
|
+
};
|
|
135
|
+
Item.defaultProps = {
|
|
136
|
+
title: undefined,
|
|
137
|
+
tokens: {}
|
|
138
|
+
};
|
|
139
|
+
export default Item;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
const StyledItem = /*#__PURE__*/styled.li.withConfig({
|
|
6
|
+
displayName: "ItemBase__StyledItem",
|
|
7
|
+
componentId: "components-web__sc-o0oiv5-0"
|
|
8
|
+
})({
|
|
9
|
+
display: 'flex'
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const Item = _ref => {
|
|
13
|
+
let {
|
|
14
|
+
children,
|
|
15
|
+
...rest
|
|
16
|
+
} = _ref;
|
|
17
|
+
return /*#__PURE__*/_jsx(StyledItem, { ...rest,
|
|
18
|
+
children: children
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
Item.propTypes = {
|
|
23
|
+
/**
|
|
24
|
+
* Item content
|
|
25
|
+
*/
|
|
26
|
+
children: PropTypes.node.isRequired
|
|
27
|
+
};
|
|
28
|
+
export default Item;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { selectSystemProps } from '@telus-uds/components-base';
|
|
5
|
+
import { htmlAttrs } from '../utils';
|
|
6
|
+
import OrderedListBase from './OrderedListBase';
|
|
7
|
+
import Item from './Item';
|
|
8
|
+
import { OL_COUNTER_NAME } from './constants';
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs]);
|
|
11
|
+
const StyledOrderedListBase = /*#__PURE__*/styled(OrderedListBase).withConfig({
|
|
12
|
+
displayName: "OrderedList__StyledOrderedListBase",
|
|
13
|
+
componentId: "components-web__sc-t5az8z-0"
|
|
14
|
+
})(_ref => {
|
|
15
|
+
let {
|
|
16
|
+
start
|
|
17
|
+
} = _ref;
|
|
18
|
+
return {
|
|
19
|
+
// Using CSS counters here to have better control over the number styling
|
|
20
|
+
listStyle: 'none',
|
|
21
|
+
counterReset: `${OL_COUNTER_NAME} ${start - 1}`
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* Themed semantic ordered list.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
const OrderedList = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
29
|
+
let {
|
|
30
|
+
children,
|
|
31
|
+
start,
|
|
32
|
+
variant,
|
|
33
|
+
...rest
|
|
34
|
+
} = _ref2;
|
|
35
|
+
// Pass any variants "OrderedList" receives down to the individual list items.
|
|
36
|
+
const childrenWithParentVariants = variant ? children.map(child => {
|
|
37
|
+
var _child$props;
|
|
38
|
+
|
|
39
|
+
const existingChildVariants = ((_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.variant) ?? {};
|
|
40
|
+
return { ...child,
|
|
41
|
+
props: { ...child.props,
|
|
42
|
+
variant: { ...existingChildVariants,
|
|
43
|
+
...variant
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}) : children;
|
|
48
|
+
return /*#__PURE__*/_jsx(StyledOrderedListBase, { ...selectProps(rest),
|
|
49
|
+
ref: ref,
|
|
50
|
+
start: start,
|
|
51
|
+
children: childrenWithParentVariants
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
OrderedList.displayName = 'OrderedList';
|
|
55
|
+
OrderedList.propTypes = { ...selectedSystemPropTypes,
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* A list of ordered items wrapped in `OrderedList.Item`.
|
|
59
|
+
*/
|
|
60
|
+
children: PropTypes.node.isRequired,
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The position to start the list with.
|
|
64
|
+
*/
|
|
65
|
+
start: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
66
|
+
};
|
|
67
|
+
OrderedList.defaultProps = {
|
|
68
|
+
start: 1
|
|
69
|
+
};
|
|
70
|
+
OrderedList.Item = Item;
|
|
71
|
+
export default OrderedList;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import ItemBase from './ItemBase';
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
const StyledList = /*#__PURE__*/styled.ol.withConfig({
|
|
7
|
+
displayName: "OrderedListBase__StyledList",
|
|
8
|
+
componentId: "components-web__sc-4m9lgj-0"
|
|
9
|
+
})({
|
|
10
|
+
display: 'flex',
|
|
11
|
+
flexDirection: 'column',
|
|
12
|
+
listStylePosition: 'inside',
|
|
13
|
+
margin: 0,
|
|
14
|
+
padding: 0
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* Semantic ordered list.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
const OrderedListBase = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
21
|
+
let {
|
|
22
|
+
children,
|
|
23
|
+
start,
|
|
24
|
+
...rest
|
|
25
|
+
} = _ref;
|
|
26
|
+
return /*#__PURE__*/_jsx(StyledList, { ...rest,
|
|
27
|
+
ref: ref,
|
|
28
|
+
start: start,
|
|
29
|
+
children: children
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
OrderedListBase.displayName = 'OrderedList';
|
|
33
|
+
OrderedListBase.propTypes = {
|
|
34
|
+
/**
|
|
35
|
+
* A list of ordered items wrapped in `OrderedListBase.Item`.
|
|
36
|
+
*/
|
|
37
|
+
children: PropTypes.node.isRequired,
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The position to start the list with.
|
|
41
|
+
*/
|
|
42
|
+
start: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
43
|
+
};
|
|
44
|
+
OrderedListBase.defaultProps = {
|
|
45
|
+
start: 1
|
|
46
|
+
};
|
|
47
|
+
OrderedListBase.Item = ItemBase;
|
|
48
|
+
export default OrderedListBase;
|
package/lib-module/index.js
CHANGED
package/package.json
CHANGED
|
@@ -4,13 +4,14 @@
|
|
|
4
4
|
"extends @telus-uds/browserslist-config"
|
|
5
5
|
],
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@telus-uds/components-base": "1.
|
|
7
|
+
"@telus-uds/components-base": "1.33.0",
|
|
8
8
|
"@telus-uds/system-constants": "^1.2.0",
|
|
9
|
-
"@telus-uds/system-theme-tokens": "^2.
|
|
9
|
+
"@telus-uds/system-theme-tokens": "^2.17.0",
|
|
10
10
|
"prop-types": "^15.7.2"
|
|
11
11
|
},
|
|
12
12
|
"description": "UDS mult-brand web components",
|
|
13
13
|
"devDependencies": {
|
|
14
|
+
"@telus-uds/palette-allium": "^2.12.3",
|
|
14
15
|
"@telus-uds/browserslist-config": "^1.0.4",
|
|
15
16
|
"@testing-library/jest-dom": "^5.16.1",
|
|
16
17
|
"@testing-library/react": "^13.3.0",
|
|
@@ -53,5 +54,5 @@
|
|
|
53
54
|
"skip": true
|
|
54
55
|
},
|
|
55
56
|
"types": "types/index.d.ts",
|
|
56
|
-
"version": "1.
|
|
57
|
+
"version": "1.3.0"
|
|
57
58
|
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
import styled from 'styled-components'
|
|
4
|
+
import {
|
|
5
|
+
applyTextStyles,
|
|
6
|
+
getTokensPropType,
|
|
7
|
+
selectSystemProps,
|
|
8
|
+
StackView,
|
|
9
|
+
Typography,
|
|
10
|
+
useTheme,
|
|
11
|
+
useThemeTokens,
|
|
12
|
+
wrapStringsInText
|
|
13
|
+
} from '@telus-uds/components-base'
|
|
14
|
+
import ItemBase from './ItemBase'
|
|
15
|
+
import { htmlAttrs } from '../utils'
|
|
16
|
+
import { OL_COUNTER_NAME } from './constants'
|
|
17
|
+
|
|
18
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs])
|
|
19
|
+
|
|
20
|
+
const selectItemTextStyles = (
|
|
21
|
+
{ itemFontWeight, itemFontSize, itemLineHeight, itemFontName, itemColor },
|
|
22
|
+
themeOptions
|
|
23
|
+
) =>
|
|
24
|
+
applyTextStyles({
|
|
25
|
+
fontWeight: itemFontWeight,
|
|
26
|
+
fontSize: itemFontSize,
|
|
27
|
+
fontName: itemFontName,
|
|
28
|
+
color: itemColor,
|
|
29
|
+
themeOptions,
|
|
30
|
+
lineHeight: itemLineHeight
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
const StyledItemBase = styled(ItemBase)(
|
|
34
|
+
({
|
|
35
|
+
interItemMargin,
|
|
36
|
+
itemBulletContainerWidth,
|
|
37
|
+
itemBulletContainerAlign,
|
|
38
|
+
itemFontWeight,
|
|
39
|
+
itemFontSize,
|
|
40
|
+
itemFontName,
|
|
41
|
+
itemLineHeight,
|
|
42
|
+
themeOptions,
|
|
43
|
+
listGutter,
|
|
44
|
+
itemColor
|
|
45
|
+
}) => ({
|
|
46
|
+
counterIncrement: OL_COUNTER_NAME,
|
|
47
|
+
'::before': {
|
|
48
|
+
content: `counter(${OL_COUNTER_NAME})'.'`,
|
|
49
|
+
display: 'inline-flex',
|
|
50
|
+
color: itemColor,
|
|
51
|
+
width: itemBulletContainerWidth,
|
|
52
|
+
paddingRight: listGutter,
|
|
53
|
+
textAlign: itemBulletContainerAlign,
|
|
54
|
+
...applyTextStyles({
|
|
55
|
+
fontWeight: itemFontWeight,
|
|
56
|
+
fontSize: itemFontSize,
|
|
57
|
+
fontName: itemFontName,
|
|
58
|
+
themeOptions
|
|
59
|
+
}),
|
|
60
|
+
lineHeight: `${itemLineHeight * itemFontSize}px`
|
|
61
|
+
},
|
|
62
|
+
':not(:last-child)': { marginBottom: interItemMargin }
|
|
63
|
+
})
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
const ItemContent = styled.div({
|
|
67
|
+
flex: 1
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
const Item = forwardRef(({ children, counterName, title, tokens, variant, ...rest }, ref) => {
|
|
71
|
+
// We are reusing some tokens from the list component here in order to provide a unified
|
|
72
|
+
// experience
|
|
73
|
+
const themeTokens = useThemeTokens('OrderedList', tokens, variant)
|
|
74
|
+
const headingTokens = title && {
|
|
75
|
+
lineHeight: themeTokens.itemLineHeight,
|
|
76
|
+
fontSize: themeTokens.itemFontSize,
|
|
77
|
+
color: themeTokens.itemColor,
|
|
78
|
+
fontName: themeTokens.headerFontName,
|
|
79
|
+
fontWeight: themeTokens.headerFontWeight
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const { themeOptions } = useTheme()
|
|
83
|
+
const itemContent = wrapStringsInText(children, {
|
|
84
|
+
style: selectItemTextStyles(themeTokens, themeOptions)
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<StyledItemBase ref={ref} themeOptions={themeOptions} {...themeTokens} {...selectProps(rest)}>
|
|
89
|
+
{title ? (
|
|
90
|
+
<StackView tokens={{ flexShrink: 1 }} space={0}>
|
|
91
|
+
<Typography variant={{ size: 'h4' }} tokens={headingTokens}>
|
|
92
|
+
{title}
|
|
93
|
+
</Typography>
|
|
94
|
+
<ItemContent {...themeTokens}>{itemContent}</ItemContent>
|
|
95
|
+
</StackView>
|
|
96
|
+
) : (
|
|
97
|
+
itemContent
|
|
98
|
+
)}
|
|
99
|
+
</StyledItemBase>
|
|
100
|
+
)
|
|
101
|
+
})
|
|
102
|
+
Item.displayName = 'OrderedListItem'
|
|
103
|
+
|
|
104
|
+
Item.propTypes = {
|
|
105
|
+
...selectedSystemPropTypes,
|
|
106
|
+
/**
|
|
107
|
+
* Item content
|
|
108
|
+
*/
|
|
109
|
+
children: PropTypes.node.isRequired,
|
|
110
|
+
title: PropTypes.string,
|
|
111
|
+
/**
|
|
112
|
+
* Item tokens
|
|
113
|
+
*/
|
|
114
|
+
tokens: getTokensPropType('List')
|
|
115
|
+
}
|
|
116
|
+
Item.defaultProps = {
|
|
117
|
+
title: undefined,
|
|
118
|
+
tokens: {}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export default Item
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
import styled from 'styled-components'
|
|
4
|
+
|
|
5
|
+
const StyledItem = styled.li({
|
|
6
|
+
display: 'flex'
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
const Item = ({ children, ...rest }) => <StyledItem {...rest}>{children}</StyledItem>
|
|
10
|
+
|
|
11
|
+
Item.propTypes = {
|
|
12
|
+
/**
|
|
13
|
+
* Item content
|
|
14
|
+
*/
|
|
15
|
+
children: PropTypes.node.isRequired
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default Item
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
import styled from 'styled-components'
|
|
4
|
+
import { selectSystemProps } from '@telus-uds/components-base'
|
|
5
|
+
import { htmlAttrs } from '../utils'
|
|
6
|
+
import OrderedListBase from './OrderedListBase'
|
|
7
|
+
import Item from './Item'
|
|
8
|
+
import { OL_COUNTER_NAME } from './constants'
|
|
9
|
+
|
|
10
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs])
|
|
11
|
+
|
|
12
|
+
const StyledOrderedListBase = styled(OrderedListBase)(({ start }) => ({
|
|
13
|
+
// Using CSS counters here to have better control over the number styling
|
|
14
|
+
listStyle: 'none',
|
|
15
|
+
counterReset: `${OL_COUNTER_NAME} ${start - 1}`
|
|
16
|
+
}))
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Themed semantic ordered list.
|
|
20
|
+
*/
|
|
21
|
+
const OrderedList = forwardRef(({ children, start, variant, ...rest }, ref) => {
|
|
22
|
+
// Pass any variants "OrderedList" receives down to the individual list items.
|
|
23
|
+
const childrenWithParentVariants = variant
|
|
24
|
+
? children.map((child) => {
|
|
25
|
+
const existingChildVariants = child.props?.variant ?? {}
|
|
26
|
+
return {
|
|
27
|
+
...child,
|
|
28
|
+
props: {
|
|
29
|
+
...child.props,
|
|
30
|
+
variant: {
|
|
31
|
+
...existingChildVariants,
|
|
32
|
+
...variant
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
: children
|
|
38
|
+
return (
|
|
39
|
+
<StyledOrderedListBase {...selectProps(rest)} ref={ref} start={start}>
|
|
40
|
+
{childrenWithParentVariants}
|
|
41
|
+
</StyledOrderedListBase>
|
|
42
|
+
)
|
|
43
|
+
})
|
|
44
|
+
OrderedList.displayName = 'OrderedList'
|
|
45
|
+
|
|
46
|
+
OrderedList.propTypes = {
|
|
47
|
+
...selectedSystemPropTypes,
|
|
48
|
+
/**
|
|
49
|
+
* A list of ordered items wrapped in `OrderedList.Item`.
|
|
50
|
+
*/
|
|
51
|
+
children: PropTypes.node.isRequired,
|
|
52
|
+
/**
|
|
53
|
+
* The position to start the list with.
|
|
54
|
+
*/
|
|
55
|
+
start: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
56
|
+
}
|
|
57
|
+
OrderedList.defaultProps = { start: 1 }
|
|
58
|
+
|
|
59
|
+
OrderedList.Item = Item
|
|
60
|
+
|
|
61
|
+
export default OrderedList
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
import styled from 'styled-components'
|
|
4
|
+
import ItemBase from './ItemBase'
|
|
5
|
+
|
|
6
|
+
const StyledList = styled.ol({
|
|
7
|
+
display: 'flex',
|
|
8
|
+
flexDirection: 'column',
|
|
9
|
+
listStylePosition: 'inside',
|
|
10
|
+
margin: 0,
|
|
11
|
+
padding: 0
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Semantic ordered list.
|
|
16
|
+
*/
|
|
17
|
+
const OrderedListBase = forwardRef(({ children, start, ...rest }, ref) => (
|
|
18
|
+
<StyledList {...rest} ref={ref} start={start}>
|
|
19
|
+
{children}
|
|
20
|
+
</StyledList>
|
|
21
|
+
))
|
|
22
|
+
OrderedListBase.displayName = 'OrderedList'
|
|
23
|
+
|
|
24
|
+
OrderedListBase.propTypes = {
|
|
25
|
+
/**
|
|
26
|
+
* A list of ordered items wrapped in `OrderedListBase.Item`.
|
|
27
|
+
*/
|
|
28
|
+
children: PropTypes.node.isRequired,
|
|
29
|
+
/**
|
|
30
|
+
* The position to start the list with.
|
|
31
|
+
*/
|
|
32
|
+
start: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
33
|
+
}
|
|
34
|
+
OrderedListBase.defaultProps = { start: 1 }
|
|
35
|
+
|
|
36
|
+
OrderedListBase.Item = ItemBase
|
|
37
|
+
|
|
38
|
+
export default OrderedListBase
|