@telus-uds/components-base 1.51.1 → 1.52.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/component-docs.json +264 -93
- package/lib/Listbox/ListboxContext.js +20 -0
- package/lib/Listbox/PressableItem.js +170 -0
- package/lib/Listbox/index.js +32 -0
- package/lib/Modal/Modal.js +1 -2
- package/lib/MultiSelectFilter/MultiSelectFilter.js +19 -5
- package/lib/Timeline/Timeline.js +2 -2
- package/lib/index.js +14 -0
- package/lib/utils/htmlAttrs.js +33 -0
- package/lib/utils/index.js +10 -1
- package/lib-module/Listbox/ListboxContext.js +6 -0
- package/lib-module/Listbox/PressableItem.js +150 -0
- package/lib-module/Listbox/index.js +2 -0
- package/lib-module/Modal/Modal.js +2 -3
- package/lib-module/MultiSelectFilter/MultiSelectFilter.js +15 -5
- package/lib-module/Timeline/Timeline.js +2 -2
- package/lib-module/index.js +1 -0
- package/lib-module/utils/htmlAttrs.js +22 -0
- package/lib-module/utils/index.js +2 -1
- package/package.json +2 -2
- package/src/Listbox/ListboxContext.js +6 -0
- package/src/Listbox/PressableItem.jsx +143 -0
- package/src/Listbox/index.js +2 -0
- package/src/Modal/Modal.jsx +1 -3
- package/src/MultiSelectFilter/MultiSelectFilter.jsx +10 -4
- package/src/Timeline/Timeline.jsx +2 -2
- package/src/index.js +1 -0
- package/src/utils/htmlAttrs.js +29 -0
- package/src/utils/index.js +1 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useListboxContext = exports.ListboxContext = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
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); }
|
|
11
|
+
|
|
12
|
+
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; }
|
|
13
|
+
|
|
14
|
+
const ListboxContext = /*#__PURE__*/_react.default.createContext({});
|
|
15
|
+
|
|
16
|
+
exports.ListboxContext = ListboxContext;
|
|
17
|
+
|
|
18
|
+
const useListboxContext = () => (0, _react.useContext)(ListboxContext);
|
|
19
|
+
|
|
20
|
+
exports.useListboxContext = useListboxContext;
|
|
@@ -0,0 +1,170 @@
|
|
|
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 _Pressable = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Pressable"));
|
|
13
|
+
|
|
14
|
+
var _Text = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Text"));
|
|
15
|
+
|
|
16
|
+
var _utils = require("../utils");
|
|
17
|
+
|
|
18
|
+
var _ListboxContext = require("./ListboxContext");
|
|
19
|
+
|
|
20
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
|
+
|
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
+
|
|
24
|
+
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); }
|
|
25
|
+
|
|
26
|
+
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; }
|
|
27
|
+
|
|
28
|
+
/* eslint-disable react/require-default-props */
|
|
29
|
+
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.htmlAttrs]);
|
|
30
|
+
|
|
31
|
+
const getItemStyles = _ref => {
|
|
32
|
+
let {
|
|
33
|
+
groupFontName,
|
|
34
|
+
groupFontWeight,
|
|
35
|
+
itemFontSize,
|
|
36
|
+
itemPaddingTop,
|
|
37
|
+
itemPaddingBottom,
|
|
38
|
+
itemPaddingLeft,
|
|
39
|
+
itemBorderLeftWidth,
|
|
40
|
+
itemPaddingRight,
|
|
41
|
+
itemBackgroundColor,
|
|
42
|
+
itemColor,
|
|
43
|
+
itemDisplay,
|
|
44
|
+
itemOutline,
|
|
45
|
+
itemTextDecoration,
|
|
46
|
+
itemBorderLeftColor,
|
|
47
|
+
itemBorderRightWidth,
|
|
48
|
+
itemBorderRightColor,
|
|
49
|
+
itemBorderTopWidth,
|
|
50
|
+
itemBorderTopColor,
|
|
51
|
+
itemBorderBottomWidth,
|
|
52
|
+
itemBorderBottomColor,
|
|
53
|
+
itemBorderRadius,
|
|
54
|
+
itemHeight
|
|
55
|
+
} = _ref;
|
|
56
|
+
return {
|
|
57
|
+
fontFamily: `${groupFontName}${groupFontWeight}normal`,
|
|
58
|
+
fontSize: itemFontSize,
|
|
59
|
+
paddingTop: itemPaddingTop - itemBorderTopWidth,
|
|
60
|
+
paddingBottom: itemPaddingBottom - itemBorderBottomWidth,
|
|
61
|
+
paddingLeft: itemPaddingLeft - itemBorderLeftWidth,
|
|
62
|
+
paddingRight: itemPaddingRight - itemBorderRightWidth,
|
|
63
|
+
width: '100%',
|
|
64
|
+
backgroundColor: itemBackgroundColor,
|
|
65
|
+
color: itemColor,
|
|
66
|
+
display: itemDisplay,
|
|
67
|
+
outline: itemOutline,
|
|
68
|
+
textDecoration: itemTextDecoration,
|
|
69
|
+
borderLeft: `${itemBorderLeftWidth}px solid ${itemBorderLeftColor}`,
|
|
70
|
+
borderRight: `${itemBorderRightWidth}px solid ${itemBorderRightColor}`,
|
|
71
|
+
borderTop: `${itemBorderTopWidth}px solid ${itemBorderTopColor}`,
|
|
72
|
+
borderBottom: `${itemBorderBottomWidth}px solid ${itemBorderBottomColor}`,
|
|
73
|
+
borderRadius: itemBorderRadius,
|
|
74
|
+
height: itemHeight,
|
|
75
|
+
justifyContent: 'center'
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const PressableItem = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
|
|
80
|
+
let {
|
|
81
|
+
children,
|
|
82
|
+
href,
|
|
83
|
+
isChild = false,
|
|
84
|
+
onBlur,
|
|
85
|
+
onPress,
|
|
86
|
+
tabIndex = 0,
|
|
87
|
+
nextItemRef,
|
|
88
|
+
prevItemRef,
|
|
89
|
+
tokens,
|
|
90
|
+
id,
|
|
91
|
+
...rest
|
|
92
|
+
} = _ref2;
|
|
93
|
+
const {
|
|
94
|
+
selectedId,
|
|
95
|
+
setSelectedId
|
|
96
|
+
} = (0, _ListboxContext.useListboxContext)();
|
|
97
|
+
|
|
98
|
+
const selectTextStyles = _ref3 => {
|
|
99
|
+
let {
|
|
100
|
+
groupFontName,
|
|
101
|
+
groupFontWeight,
|
|
102
|
+
itemFontSize,
|
|
103
|
+
itemColor,
|
|
104
|
+
lineHeight
|
|
105
|
+
} = _ref3;
|
|
106
|
+
return {
|
|
107
|
+
fontFamily: `${groupFontName}${groupFontWeight}normal`,
|
|
108
|
+
fontSize: itemFontSize,
|
|
109
|
+
color: itemColor,
|
|
110
|
+
lineHeight: lineHeight * itemFontSize
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const resolveButtonTokens = pressableState => {
|
|
115
|
+
const themeTokens = (0, _utils.resolvePressableTokens)(tokens, pressableState, {
|
|
116
|
+
isChild,
|
|
117
|
+
current: id === selectedId && id !== undefined
|
|
118
|
+
});
|
|
119
|
+
return themeTokens;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const handleKeyPress = event => {
|
|
123
|
+
if (['Enter', ' '].includes(event === null || event === void 0 ? void 0 : event.key)) {
|
|
124
|
+
onPress === null || onPress === void 0 ? void 0 : onPress(event);
|
|
125
|
+
} else if ((event === null || event === void 0 ? void 0 : event.key) === 'ArrowDown') {
|
|
126
|
+
nextItemRef.current.focus();
|
|
127
|
+
} else if ((event === null || event === void 0 ? void 0 : event.key) === 'ArrowUp' && prevItemRef !== null && prevItemRef !== void 0 && prevItemRef.current) {
|
|
128
|
+
prevItemRef.current.focus();
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Pressable.default, {
|
|
133
|
+
isChild: isChild,
|
|
134
|
+
style: pressableState => getItemStyles(resolveButtonTokens(pressableState)),
|
|
135
|
+
onBlur: onBlur,
|
|
136
|
+
onClick: onPress,
|
|
137
|
+
onKeyPress: handleKeyPress,
|
|
138
|
+
ref: ref,
|
|
139
|
+
tabIndex: tabIndex,
|
|
140
|
+
...(href && {
|
|
141
|
+
href
|
|
142
|
+
}),
|
|
143
|
+
...(onPress && {
|
|
144
|
+
onClick: onPress
|
|
145
|
+
}),
|
|
146
|
+
...selectProps(rest),
|
|
147
|
+
onPress: () => {
|
|
148
|
+
setSelectedId(id);
|
|
149
|
+
onPress();
|
|
150
|
+
},
|
|
151
|
+
children: pressableState => {
|
|
152
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Text.default, {
|
|
153
|
+
style: selectTextStyles(resolveButtonTokens(pressableState)),
|
|
154
|
+
children: [children, " "]
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
PressableItem.displayName = 'PressableItem';
|
|
160
|
+
PressableItem.propTypes = { ...selectedSystemPropTypes,
|
|
161
|
+
href: _propTypes.default.string,
|
|
162
|
+
isChild: _propTypes.default.bool,
|
|
163
|
+
children: _propTypes.default.node.isRequired,
|
|
164
|
+
onBlur: _propTypes.default.func,
|
|
165
|
+
onPress: _propTypes.default.func,
|
|
166
|
+
nextItemRef: _propTypes.default.object,
|
|
167
|
+
prevItemRef: _propTypes.default.object
|
|
168
|
+
};
|
|
169
|
+
var _default = PressableItem;
|
|
170
|
+
exports.default = _default;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
PressableItem: true
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "PressableItem", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () {
|
|
12
|
+
return _PressableItem.default;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
var _ListboxContext = require("./ListboxContext");
|
|
17
|
+
|
|
18
|
+
Object.keys(_ListboxContext).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
21
|
+
if (key in exports && exports[key] === _ListboxContext[key]) return;
|
|
22
|
+
Object.defineProperty(exports, key, {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function () {
|
|
25
|
+
return _ListboxContext[key];
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
var _PressableItem = _interopRequireDefault(require("./PressableItem"));
|
|
31
|
+
|
|
32
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
package/lib/Modal/Modal.js
CHANGED
|
@@ -183,8 +183,7 @@ const Modal = /*#__PURE__*/(0, _react.forwardRef)((_ref5, ref) => {
|
|
|
183
183
|
onPress: handleClose,
|
|
184
184
|
icon: CloseIconComponent,
|
|
185
185
|
accessibilityRole: "button",
|
|
186
|
-
accessibilityLabel: closeLabel
|
|
187
|
-
tokens: (0, _utils.selectTokens)('IconButton', themeTokens, 'close')
|
|
186
|
+
accessibilityLabel: closeLabel
|
|
188
187
|
})
|
|
189
188
|
}), children]
|
|
190
189
|
})
|
|
@@ -9,6 +9,10 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
9
9
|
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
|
12
|
+
var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
|
|
13
|
+
|
|
14
|
+
var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
|
|
15
|
+
|
|
12
16
|
var _ThemeProvider = require("../ThemeProvider");
|
|
13
17
|
|
|
14
18
|
var _utils = require("../utils");
|
|
@@ -311,11 +315,14 @@ const MultiSelectFilter = _ref3 => {
|
|
|
311
315
|
isReady: isReady,
|
|
312
316
|
onLayout: onTargetLayout,
|
|
313
317
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
|
|
314
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
318
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
319
|
+
style: styles.textContainerStyle,
|
|
320
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
321
|
+
tokens: { ...headerStyles,
|
|
322
|
+
lineHeight: headerLineHeight
|
|
323
|
+
},
|
|
324
|
+
children: getCopy('filterByLabel').replace(/%\{filterCategory\}/g, label.toLowerCase())
|
|
325
|
+
})
|
|
319
326
|
})
|
|
320
327
|
}), subtitle && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
321
328
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Spacer.default, {
|
|
@@ -384,6 +391,13 @@ const MultiSelectFilter = _ref3 => {
|
|
|
384
391
|
};
|
|
385
392
|
|
|
386
393
|
MultiSelectFilter.displayName = 'MultiSelectFilter';
|
|
394
|
+
|
|
395
|
+
const styles = _StyleSheet.default.create({
|
|
396
|
+
textContainerStyle: {
|
|
397
|
+
marginRight: 52
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
|
|
387
401
|
MultiSelectFilter.propTypes = {
|
|
388
402
|
/**
|
|
389
403
|
* The text displayed to the user in a ButtonDropdown.
|
package/lib/Timeline/Timeline.js
CHANGED
|
@@ -44,14 +44,14 @@ const selectDotStyles = _ref => {
|
|
|
44
44
|
|
|
45
45
|
const selectConnectorStyles = _ref2 => {
|
|
46
46
|
let {
|
|
47
|
-
|
|
47
|
+
timelineConnectorColor,
|
|
48
48
|
connectorHeight,
|
|
49
49
|
connectorWidth
|
|
50
50
|
} = _ref2;
|
|
51
51
|
return {
|
|
52
52
|
width: connectorWidth,
|
|
53
53
|
height: connectorHeight,
|
|
54
|
-
backgroundColor:
|
|
54
|
+
backgroundColor: timelineConnectorColor
|
|
55
55
|
};
|
|
56
56
|
};
|
|
57
57
|
|
package/lib/index.js
CHANGED
|
@@ -476,6 +476,20 @@ Object.keys(_Carousel).forEach(function (key) {
|
|
|
476
476
|
});
|
|
477
477
|
});
|
|
478
478
|
|
|
479
|
+
var _Listbox = require("./Listbox");
|
|
480
|
+
|
|
481
|
+
Object.keys(_Listbox).forEach(function (key) {
|
|
482
|
+
if (key === "default" || key === "__esModule") return;
|
|
483
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
484
|
+
if (key in exports && exports[key] === _Listbox[key]) return;
|
|
485
|
+
Object.defineProperty(exports, key, {
|
|
486
|
+
enumerable: true,
|
|
487
|
+
get: function () {
|
|
488
|
+
return _Listbox[key];
|
|
489
|
+
}
|
|
490
|
+
});
|
|
491
|
+
});
|
|
492
|
+
|
|
479
493
|
var _Checkbox = _interopRequireWildcard(require("./Checkbox"));
|
|
480
494
|
|
|
481
495
|
Object.keys(_Checkbox).forEach(function (key) {
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
const htmlAttrTypes = {
|
|
13
|
+
dataSet: _propTypes.default.object,
|
|
14
|
+
id: _propTypes.default.string,
|
|
15
|
+
loading: _propTypes.default.oneOf(['eager', 'lazy']),
|
|
16
|
+
// @todo figure out if we need to enum all the possible roles or maybe use
|
|
17
|
+
// an npm package
|
|
18
|
+
role: _propTypes.default.string,
|
|
19
|
+
src: _propTypes.default.string,
|
|
20
|
+
tabIndex: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
21
|
+
testID: _propTypes.default.string,
|
|
22
|
+
title: _propTypes.default.string
|
|
23
|
+
};
|
|
24
|
+
var _default = {
|
|
25
|
+
types: htmlAttrTypes,
|
|
26
|
+
select: props => Object.entries(props).reduce((items, _ref) => {
|
|
27
|
+
let [key, value] = _ref;
|
|
28
|
+
return Object.keys(htmlAttrTypes).includes(key) || /^(data|aria)-/.test(key) ? { ...items,
|
|
29
|
+
[key]: value
|
|
30
|
+
} : items;
|
|
31
|
+
}, {})
|
|
32
|
+
};
|
|
33
|
+
exports.default = _default;
|
package/lib/utils/index.js
CHANGED
|
@@ -15,7 +15,8 @@ var _exportNames = {
|
|
|
15
15
|
useUniqueId: true,
|
|
16
16
|
withLinkRouter: true,
|
|
17
17
|
containUniqueFields: true,
|
|
18
|
-
BaseView: true
|
|
18
|
+
BaseView: true,
|
|
19
|
+
htmlAttrs: true
|
|
19
20
|
};
|
|
20
21
|
Object.defineProperty(exports, "BaseView", {
|
|
21
22
|
enumerable: true,
|
|
@@ -29,6 +30,12 @@ Object.defineProperty(exports, "containUniqueFields", {
|
|
|
29
30
|
return _containUniqueFields.default;
|
|
30
31
|
}
|
|
31
32
|
});
|
|
33
|
+
Object.defineProperty(exports, "htmlAttrs", {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: function () {
|
|
36
|
+
return _htmlAttrs.default;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
32
39
|
Object.defineProperty(exports, "info", {
|
|
33
40
|
enumerable: true,
|
|
34
41
|
get: function () {
|
|
@@ -224,6 +231,8 @@ var _containUniqueFields = _interopRequireDefault(require("./containUniqueFields
|
|
|
224
231
|
|
|
225
232
|
var _BaseView = _interopRequireDefault(require("./BaseView"));
|
|
226
233
|
|
|
234
|
+
var _htmlAttrs = _interopRequireDefault(require("./htmlAttrs"));
|
|
235
|
+
|
|
227
236
|
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); }
|
|
228
237
|
|
|
229
238
|
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; }
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/* eslint-disable react/require-default-props */
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import Pressable from "react-native-web/dist/exports/Pressable";
|
|
5
|
+
import Text from "react-native-web/dist/exports/Text";
|
|
6
|
+
import { selectSystemProps, resolvePressableTokens, htmlAttrs } from '../utils';
|
|
7
|
+
import { useListboxContext } from './ListboxContext';
|
|
8
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs]);
|
|
11
|
+
|
|
12
|
+
const getItemStyles = _ref => {
|
|
13
|
+
let {
|
|
14
|
+
groupFontName,
|
|
15
|
+
groupFontWeight,
|
|
16
|
+
itemFontSize,
|
|
17
|
+
itemPaddingTop,
|
|
18
|
+
itemPaddingBottom,
|
|
19
|
+
itemPaddingLeft,
|
|
20
|
+
itemBorderLeftWidth,
|
|
21
|
+
itemPaddingRight,
|
|
22
|
+
itemBackgroundColor,
|
|
23
|
+
itemColor,
|
|
24
|
+
itemDisplay,
|
|
25
|
+
itemOutline,
|
|
26
|
+
itemTextDecoration,
|
|
27
|
+
itemBorderLeftColor,
|
|
28
|
+
itemBorderRightWidth,
|
|
29
|
+
itemBorderRightColor,
|
|
30
|
+
itemBorderTopWidth,
|
|
31
|
+
itemBorderTopColor,
|
|
32
|
+
itemBorderBottomWidth,
|
|
33
|
+
itemBorderBottomColor,
|
|
34
|
+
itemBorderRadius,
|
|
35
|
+
itemHeight
|
|
36
|
+
} = _ref;
|
|
37
|
+
return {
|
|
38
|
+
fontFamily: `${groupFontName}${groupFontWeight}normal`,
|
|
39
|
+
fontSize: itemFontSize,
|
|
40
|
+
paddingTop: itemPaddingTop - itemBorderTopWidth,
|
|
41
|
+
paddingBottom: itemPaddingBottom - itemBorderBottomWidth,
|
|
42
|
+
paddingLeft: itemPaddingLeft - itemBorderLeftWidth,
|
|
43
|
+
paddingRight: itemPaddingRight - itemBorderRightWidth,
|
|
44
|
+
width: '100%',
|
|
45
|
+
backgroundColor: itemBackgroundColor,
|
|
46
|
+
color: itemColor,
|
|
47
|
+
display: itemDisplay,
|
|
48
|
+
outline: itemOutline,
|
|
49
|
+
textDecoration: itemTextDecoration,
|
|
50
|
+
borderLeft: `${itemBorderLeftWidth}px solid ${itemBorderLeftColor}`,
|
|
51
|
+
borderRight: `${itemBorderRightWidth}px solid ${itemBorderRightColor}`,
|
|
52
|
+
borderTop: `${itemBorderTopWidth}px solid ${itemBorderTopColor}`,
|
|
53
|
+
borderBottom: `${itemBorderBottomWidth}px solid ${itemBorderBottomColor}`,
|
|
54
|
+
borderRadius: itemBorderRadius,
|
|
55
|
+
height: itemHeight,
|
|
56
|
+
justifyContent: 'center'
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const PressableItem = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
61
|
+
let {
|
|
62
|
+
children,
|
|
63
|
+
href,
|
|
64
|
+
isChild = false,
|
|
65
|
+
onBlur,
|
|
66
|
+
onPress,
|
|
67
|
+
tabIndex = 0,
|
|
68
|
+
nextItemRef,
|
|
69
|
+
prevItemRef,
|
|
70
|
+
tokens,
|
|
71
|
+
id,
|
|
72
|
+
...rest
|
|
73
|
+
} = _ref2;
|
|
74
|
+
const {
|
|
75
|
+
selectedId,
|
|
76
|
+
setSelectedId
|
|
77
|
+
} = useListboxContext();
|
|
78
|
+
|
|
79
|
+
const selectTextStyles = _ref3 => {
|
|
80
|
+
let {
|
|
81
|
+
groupFontName,
|
|
82
|
+
groupFontWeight,
|
|
83
|
+
itemFontSize,
|
|
84
|
+
itemColor,
|
|
85
|
+
lineHeight
|
|
86
|
+
} = _ref3;
|
|
87
|
+
return {
|
|
88
|
+
fontFamily: `${groupFontName}${groupFontWeight}normal`,
|
|
89
|
+
fontSize: itemFontSize,
|
|
90
|
+
color: itemColor,
|
|
91
|
+
lineHeight: lineHeight * itemFontSize
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const resolveButtonTokens = pressableState => {
|
|
96
|
+
const themeTokens = resolvePressableTokens(tokens, pressableState, {
|
|
97
|
+
isChild,
|
|
98
|
+
current: id === selectedId && id !== undefined
|
|
99
|
+
});
|
|
100
|
+
return themeTokens;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const handleKeyPress = event => {
|
|
104
|
+
if (['Enter', ' '].includes(event === null || event === void 0 ? void 0 : event.key)) {
|
|
105
|
+
onPress === null || onPress === void 0 ? void 0 : onPress(event);
|
|
106
|
+
} else if ((event === null || event === void 0 ? void 0 : event.key) === 'ArrowDown') {
|
|
107
|
+
nextItemRef.current.focus();
|
|
108
|
+
} else if ((event === null || event === void 0 ? void 0 : event.key) === 'ArrowUp' && prevItemRef !== null && prevItemRef !== void 0 && prevItemRef.current) {
|
|
109
|
+
prevItemRef.current.focus();
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
return /*#__PURE__*/_jsx(Pressable, {
|
|
114
|
+
isChild: isChild,
|
|
115
|
+
style: pressableState => getItemStyles(resolveButtonTokens(pressableState)),
|
|
116
|
+
onBlur: onBlur,
|
|
117
|
+
onClick: onPress,
|
|
118
|
+
onKeyPress: handleKeyPress,
|
|
119
|
+
ref: ref,
|
|
120
|
+
tabIndex: tabIndex,
|
|
121
|
+
...(href && {
|
|
122
|
+
href
|
|
123
|
+
}),
|
|
124
|
+
...(onPress && {
|
|
125
|
+
onClick: onPress
|
|
126
|
+
}),
|
|
127
|
+
...selectProps(rest),
|
|
128
|
+
onPress: () => {
|
|
129
|
+
setSelectedId(id);
|
|
130
|
+
onPress();
|
|
131
|
+
},
|
|
132
|
+
children: pressableState => {
|
|
133
|
+
return /*#__PURE__*/_jsxs(Text, {
|
|
134
|
+
style: selectTextStyles(resolveButtonTokens(pressableState)),
|
|
135
|
+
children: [children, " "]
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
PressableItem.displayName = 'PressableItem';
|
|
141
|
+
PressableItem.propTypes = { ...selectedSystemPropTypes,
|
|
142
|
+
href: PropTypes.string,
|
|
143
|
+
isChild: PropTypes.bool,
|
|
144
|
+
children: PropTypes.node.isRequired,
|
|
145
|
+
onBlur: PropTypes.func,
|
|
146
|
+
onPress: PropTypes.func,
|
|
147
|
+
nextItemRef: PropTypes.object,
|
|
148
|
+
prevItemRef: PropTypes.object
|
|
149
|
+
};
|
|
150
|
+
export default PressableItem;
|
|
@@ -6,7 +6,7 @@ import NativeModal from "react-native-web/dist/exports/Modal";
|
|
|
6
6
|
import Platform from "react-native-web/dist/exports/Platform";
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import { applyShadowToken, useThemeTokens } from '../ThemeProvider';
|
|
9
|
-
import { a11yProps, copyPropTypes, getTokensPropType, selectSystemProps, useCopy, variantProp, viewProps
|
|
9
|
+
import { a11yProps, copyPropTypes, getTokensPropType, selectSystemProps, useCopy, variantProp, viewProps } from '../utils';
|
|
10
10
|
import { useViewport } from '../ViewportProvider';
|
|
11
11
|
import IconButton from '../IconButton';
|
|
12
12
|
import dictionary from './dictionary';
|
|
@@ -157,8 +157,7 @@ const Modal = /*#__PURE__*/forwardRef((_ref5, ref) => {
|
|
|
157
157
|
onPress: handleClose,
|
|
158
158
|
icon: CloseIconComponent,
|
|
159
159
|
accessibilityRole: "button",
|
|
160
|
-
accessibilityLabel: closeLabel
|
|
161
|
-
tokens: selectTokens('IconButton', themeTokens, 'close')
|
|
160
|
+
accessibilityLabel: closeLabel
|
|
162
161
|
})
|
|
163
162
|
}), children]
|
|
164
163
|
})
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React, { useState, useEffect } from 'react';
|
|
2
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";
|
|
3
5
|
import { useThemeTokens, useThemeTokensCallback, applyTextStyles } from '../ThemeProvider';
|
|
4
6
|
import { containUniqueFields, getTokensPropType, getPressHandlersWithArgs, selectTokens, useOverlaidPosition, useCopy, useMultipleInputValues, useResponsiveProp, variantProp } from '../utils';
|
|
5
7
|
import dictionary from './dictionary';
|
|
@@ -282,11 +284,14 @@ const MultiSelectFilter = _ref3 => {
|
|
|
282
284
|
isReady: isReady,
|
|
283
285
|
onLayout: onTargetLayout,
|
|
284
286
|
children: [/*#__PURE__*/_jsx(Row, {
|
|
285
|
-
children: /*#__PURE__*/_jsx(
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
287
|
+
children: /*#__PURE__*/_jsx(View, {
|
|
288
|
+
style: styles.textContainerStyle,
|
|
289
|
+
children: /*#__PURE__*/_jsx(Typography, {
|
|
290
|
+
tokens: { ...headerStyles,
|
|
291
|
+
lineHeight: headerLineHeight
|
|
292
|
+
},
|
|
293
|
+
children: getCopy('filterByLabel').replace(/%\{filterCategory\}/g, label.toLowerCase())
|
|
294
|
+
})
|
|
290
295
|
})
|
|
291
296
|
}), subtitle && /*#__PURE__*/_jsxs(_Fragment, {
|
|
292
297
|
children: [/*#__PURE__*/_jsx(Spacer, {
|
|
@@ -355,6 +360,11 @@ const MultiSelectFilter = _ref3 => {
|
|
|
355
360
|
};
|
|
356
361
|
|
|
357
362
|
MultiSelectFilter.displayName = 'MultiSelectFilter';
|
|
363
|
+
const styles = StyleSheet.create({
|
|
364
|
+
textContainerStyle: {
|
|
365
|
+
marginRight: 52
|
|
366
|
+
}
|
|
367
|
+
});
|
|
358
368
|
MultiSelectFilter.propTypes = {
|
|
359
369
|
/**
|
|
360
370
|
* The text displayed to the user in a ButtonDropdown.
|
|
@@ -26,14 +26,14 @@ const selectDotStyles = _ref => {
|
|
|
26
26
|
|
|
27
27
|
const selectConnectorStyles = _ref2 => {
|
|
28
28
|
let {
|
|
29
|
-
|
|
29
|
+
timelineConnectorColor,
|
|
30
30
|
connectorHeight,
|
|
31
31
|
connectorWidth
|
|
32
32
|
} = _ref2;
|
|
33
33
|
return {
|
|
34
34
|
width: connectorWidth,
|
|
35
35
|
height: connectorHeight,
|
|
36
|
-
backgroundColor:
|
|
36
|
+
backgroundColor: timelineConnectorColor
|
|
37
37
|
};
|
|
38
38
|
};
|
|
39
39
|
|
package/lib-module/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export { default as Box } from './Box';
|
|
|
4
4
|
export * from './Button';
|
|
5
5
|
export { default as Card, PressableCardBase } from './Card';
|
|
6
6
|
export * from './Carousel';
|
|
7
|
+
export * from './Listbox';
|
|
7
8
|
export { default as Checkbox } from './Checkbox';
|
|
8
9
|
export * from './Checkbox';
|
|
9
10
|
export { default as Divider } from './Divider';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
const htmlAttrTypes = {
|
|
3
|
+
dataSet: PropTypes.object,
|
|
4
|
+
id: PropTypes.string,
|
|
5
|
+
loading: PropTypes.oneOf(['eager', 'lazy']),
|
|
6
|
+
// @todo figure out if we need to enum all the possible roles or maybe use
|
|
7
|
+
// an npm package
|
|
8
|
+
role: PropTypes.string,
|
|
9
|
+
src: PropTypes.string,
|
|
10
|
+
tabIndex: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
11
|
+
testID: PropTypes.string,
|
|
12
|
+
title: PropTypes.string
|
|
13
|
+
};
|
|
14
|
+
export default {
|
|
15
|
+
types: htmlAttrTypes,
|
|
16
|
+
select: props => Object.entries(props).reduce((items, _ref) => {
|
|
17
|
+
let [key, value] = _ref;
|
|
18
|
+
return Object.keys(htmlAttrTypes).includes(key) || /^(data|aria)-/.test(key) ? { ...items,
|
|
19
|
+
[key]: value
|
|
20
|
+
} : items;
|
|
21
|
+
}, {})
|
|
22
|
+
};
|
|
@@ -17,4 +17,5 @@ export { default as useUniqueId } from './useUniqueId';
|
|
|
17
17
|
export { default as withLinkRouter } from './withLinkRouter';
|
|
18
18
|
export * from './ssr';
|
|
19
19
|
export { default as containUniqueFields } from './containUniqueFields';
|
|
20
|
-
export { default as BaseView } from './BaseView';
|
|
20
|
+
export { default as BaseView } from './BaseView';
|
|
21
|
+
export { default as htmlAttrs } from './htmlAttrs';
|