@workday/canvas-kit-preview-react 9.0.0-alpha.364-next.3 → 9.0.0-alpha.382-next.2
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/dist/commonjs/color-picker/lib/ColorPicker.js +24 -47
- package/dist/commonjs/color-picker/lib/parts/ColorReset.js +32 -23
- package/dist/commonjs/color-picker/lib/parts/SwatchBook.js +26 -39
- package/dist/commonjs/form-field/lib/FormField.js +10 -33
- package/dist/commonjs/form-field/lib/FormFieldHint.js +8 -31
- package/dist/commonjs/form-field/lib/FormFieldInput.js +6 -17
- package/dist/commonjs/form-field/lib/FormFieldLabel.js +8 -31
- package/dist/commonjs/form-field/lib/hooks/useFormFieldHint.js +4 -5
- package/dist/commonjs/form-field/lib/hooks/useFormFieldInput.js +5 -6
- package/dist/commonjs/form-field/lib/hooks/useFormFieldLabel.js +4 -5
- package/dist/commonjs/form-field/lib/hooks/useFormFieldModel.js +8 -16
- package/dist/commonjs/form-field/lib/hooks/useFormFieldOrientation.js +3 -3
- package/dist/commonjs/menu/lib/Menu.js +96 -129
- package/dist/commonjs/menu/lib/MenuItem.js +94 -109
- package/dist/commonjs/pill/lib/Pill.js +55 -60
- package/dist/commonjs/pill/lib/PillAvatar.js +6 -17
- package/dist/commonjs/pill/lib/PillCount.js +7 -30
- package/dist/commonjs/pill/lib/PillIcon.js +8 -31
- package/dist/commonjs/pill/lib/PillIconButton.js +13 -36
- package/dist/commonjs/pill/lib/PillLabel.js +10 -33
- package/dist/commonjs/pill/lib/usePillModel.js +8 -16
- package/dist/commonjs/segmented-control/lib/SegmentedControl.js +6 -7
- package/dist/commonjs/segmented-control/lib/SegmentedControlItem.js +24 -49
- package/dist/commonjs/segmented-control/lib/SegmentedControlList.js +13 -38
- package/dist/commonjs/segmented-control/lib/hooks/useSegmentedControlItem.js +8 -10
- package/dist/commonjs/segmented-control/lib/hooks/useSegmentedControlModel.js +31 -31
- package/dist/commonjs/select/lib/Select.js +147 -189
- package/dist/commonjs/select/lib/SelectBase.js +106 -101
- package/dist/commonjs/select/lib/SelectMenu.js +53 -84
- package/dist/commonjs/select/lib/SelectOption.js +33 -47
- package/dist/commonjs/select/lib/scrolling.js +6 -7
- package/dist/commonjs/select/lib/utils.js +4 -4
- package/dist/commonjs/side-panel/lib/SidePanel.js +36 -51
- package/dist/commonjs/side-panel/lib/SidePanelToggleButton.js +17 -40
- package/dist/commonjs/side-panel/lib/hooks.js +20 -20
- package/dist/commonjs/status-indicator/lib/StatusIndicator.js +10 -34
- package/dist/commonjs/status-indicator/lib/StatusIndicatorIcon.js +9 -21
- package/dist/commonjs/status-indicator/lib/StatusIndicatorLabel.js +5 -28
- package/dist/commonjs/status-indicator/lib/hooks/useStatusIndicatorModel.js +6 -15
- package/dist/commonjs/text-area/lib/TextArea.js +8 -31
- package/dist/commonjs/text-area/lib/TextAreaField.d.ts.map +1 -1
- package/dist/commonjs/text-area/lib/TextAreaField.js +12 -36
- package/dist/commonjs/text-input/lib/TextInput.js +8 -31
- package/dist/commonjs/text-input/lib/TextInputField.d.ts.map +1 -1
- package/dist/commonjs/text-input/lib/TextInputField.js +12 -24
- package/dist/commonjs/text-input/lib/hooks/useTextInputField.js +3 -3
- package/dist/commonjs/text-input/lib/hooks/useTextInputModel.js +1 -1
- package/dist/es6/color-picker/lib/ColorPicker.js +15 -38
- package/dist/es6/color-picker/lib/parts/ColorReset.js +27 -18
- package/dist/es6/color-picker/lib/parts/SwatchBook.js +21 -34
- package/dist/es6/form-field/lib/FormField.js +4 -27
- package/dist/es6/form-field/lib/FormFieldHint.js +4 -27
- package/dist/es6/form-field/lib/FormFieldInput.js +3 -14
- package/dist/es6/form-field/lib/FormFieldLabel.js +4 -27
- package/dist/es6/form-field/lib/hooks/useFormFieldHint.js +2 -3
- package/dist/es6/form-field/lib/hooks/useFormFieldInput.js +3 -4
- package/dist/es6/form-field/lib/hooks/useFormFieldLabel.js +2 -3
- package/dist/es6/form-field/lib/hooks/useFormFieldModel.js +8 -16
- package/dist/es6/form-field/lib/hooks/useFormFieldOrientation.js +2 -2
- package/dist/es6/menu/lib/Menu.js +91 -125
- package/dist/es6/menu/lib/MenuItem.js +90 -106
- package/dist/es6/pill/lib/Pill.js +45 -50
- package/dist/es6/pill/lib/PillAvatar.js +3 -14
- package/dist/es6/pill/lib/PillCount.js +4 -27
- package/dist/es6/pill/lib/PillIcon.js +3 -26
- package/dist/es6/pill/lib/PillIconButton.js +7 -30
- package/dist/es6/pill/lib/PillLabel.js +5 -28
- package/dist/es6/pill/lib/usePillModel.js +8 -16
- package/dist/es6/segmented-control/lib/SegmentedControl.js +2 -3
- package/dist/es6/segmented-control/lib/SegmentedControlItem.js +17 -42
- package/dist/es6/segmented-control/lib/SegmentedControlList.js +9 -34
- package/dist/es6/segmented-control/lib/hooks/useSegmentedControlItem.js +5 -7
- package/dist/es6/segmented-control/lib/hooks/useSegmentedControlModel.js +29 -29
- package/dist/es6/select/lib/Select.js +144 -186
- package/dist/es6/select/lib/SelectBase.js +99 -94
- package/dist/es6/select/lib/SelectMenu.js +49 -80
- package/dist/es6/select/lib/SelectOption.js +30 -44
- package/dist/es6/select/lib/scrolling.js +6 -7
- package/dist/es6/select/lib/utils.js +4 -4
- package/dist/es6/side-panel/lib/SidePanel.js +31 -46
- package/dist/es6/side-panel/lib/SidePanelToggleButton.js +10 -33
- package/dist/es6/side-panel/lib/hooks.js +19 -19
- package/dist/es6/status-indicator/lib/StatusIndicator.js +5 -29
- package/dist/es6/status-indicator/lib/StatusIndicatorIcon.js +6 -18
- package/dist/es6/status-indicator/lib/StatusIndicatorLabel.js +3 -26
- package/dist/es6/status-indicator/lib/hooks/useStatusIndicatorModel.js +6 -15
- package/dist/es6/text-area/lib/TextArea.js +4 -27
- package/dist/es6/text-area/lib/TextAreaField.d.ts.map +1 -1
- package/dist/es6/text-area/lib/TextAreaField.js +9 -33
- package/dist/es6/text-input/lib/TextInput.js +4 -27
- package/dist/es6/text-input/lib/TextInputField.d.ts.map +1 -1
- package/dist/es6/text-input/lib/TextInputField.js +9 -21
- package/dist/es6/text-input/lib/hooks/useTextInputField.js +1 -1
- package/dist/es6/text-input/lib/hooks/useTextInputModel.js +1 -1
- package/package.json +3 -4
- package/text-area/lib/TextAreaField.tsx +6 -2
- package/text-input/lib/TextInputField.tsx +6 -2
|
@@ -1,52 +1,24 @@
|
|
|
1
|
-
var __extends = (this && this.__extends) || (function () {
|
|
2
|
-
var extendStatics = function (d, b) {
|
|
3
|
-
extendStatics = Object.setPrototypeOf ||
|
|
4
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
-
return extendStatics(d, b);
|
|
7
|
-
};
|
|
8
|
-
return function (d, b) {
|
|
9
|
-
if (typeof b !== "function" && b !== null)
|
|
10
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
-
extendStatics(d, b);
|
|
12
|
-
function __() { this.constructor = d; }
|
|
13
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
-
};
|
|
15
|
-
})();
|
|
16
|
-
var __assign = (this && this.__assign) || function () {
|
|
17
|
-
__assign = Object.assign || function(t) {
|
|
18
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
19
|
-
s = arguments[i];
|
|
20
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
21
|
-
t[p] = s[p];
|
|
22
|
-
}
|
|
23
|
-
return t;
|
|
24
|
-
};
|
|
25
|
-
return __assign.apply(this, arguments);
|
|
26
|
-
};
|
|
27
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
28
|
-
var t = {};
|
|
29
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
30
|
-
t[p] = s[p];
|
|
31
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
32
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
33
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
34
|
-
t[p[i]] = s[p[i]];
|
|
35
|
-
}
|
|
36
|
-
return t;
|
|
37
|
-
};
|
|
38
1
|
import * as React from 'react';
|
|
39
2
|
import styled from '@emotion/styled';
|
|
40
3
|
import { colors, commonColors, iconColors, typeColors, space, type, } from '@workday/canvas-kit-react/tokens';
|
|
41
4
|
import { SystemIcon } from '@workday/canvas-kit-react/icon';
|
|
42
|
-
|
|
5
|
+
const Item = styled('li')({
|
|
6
|
+
...type.levels.subtext.large,
|
|
7
|
+
padding: `${space.xxs} ${space.s}`,
|
|
8
|
+
height: space.xl,
|
|
9
|
+
boxSizing: 'border-box',
|
|
10
|
+
cursor: 'pointer',
|
|
11
|
+
color: colors.blackPepper300,
|
|
12
|
+
display: 'flex',
|
|
13
|
+
flexDirection: 'row',
|
|
14
|
+
alignItems: 'center',
|
|
15
|
+
transition: 'background-color 80ms, color 80ms',
|
|
16
|
+
'&:focus': {
|
|
43
17
|
outline: 'none',
|
|
44
|
-
}
|
|
45
|
-
|
|
18
|
+
},
|
|
19
|
+
}, ({ isHeader }) => {
|
|
46
20
|
return { pointerEvents: isHeader ? 'none' : 'all' };
|
|
47
|
-
},
|
|
48
|
-
var _b;
|
|
49
|
-
var isFocused = _a.isFocused, isDisabled = _a.isDisabled;
|
|
21
|
+
}, ({ isFocused, isDisabled }) => {
|
|
50
22
|
if (!isFocused && !isDisabled) {
|
|
51
23
|
return {
|
|
52
24
|
backgroundColor: 'inherit',
|
|
@@ -67,25 +39,26 @@ var Item = styled('li')(__assign(__assign({}, type.levels.subtext.large), { padd
|
|
|
67
39
|
}
|
|
68
40
|
else {
|
|
69
41
|
// Is focused or focused and disabled
|
|
70
|
-
return
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
42
|
+
return {
|
|
43
|
+
backgroundColor: isDisabled ? colors.blueberry200 : commonColors.focusBackground,
|
|
44
|
+
color: typeColors.inverse,
|
|
45
|
+
'span .wd-icon-background ~ .wd-icon-accent, .wd-icon-background ~ .wd-icon-accent2': {
|
|
46
|
+
fill: isDisabled ? iconColors.disabled : iconColors.active,
|
|
47
|
+
},
|
|
48
|
+
'&:hover': {
|
|
49
|
+
'span .wd-icon-fill, span .wd-icon-accent, span .wd-icon-accent2': {
|
|
50
|
+
fill: iconColors.inverse,
|
|
51
|
+
},
|
|
52
|
+
'span .wd-icon-background ~ .wd-icon-accent, span .wd-icon-background ~ .wd-icon-accent2': {
|
|
74
53
|
fill: isDisabled ? iconColors.disabled : iconColors.active,
|
|
75
54
|
},
|
|
76
|
-
'
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
},
|
|
80
|
-
'span .wd-icon-background ~ .wd-icon-accent, span .wd-icon-background ~ .wd-icon-accent2': {
|
|
81
|
-
fill: isDisabled ? iconColors.disabled : iconColors.active,
|
|
82
|
-
},
|
|
83
|
-
'span .wd-icon-background': {
|
|
84
|
-
fill: iconColors.inverse,
|
|
85
|
-
},
|
|
86
|
-
}
|
|
55
|
+
'span .wd-icon-background': {
|
|
56
|
+
fill: iconColors.inverse,
|
|
57
|
+
},
|
|
87
58
|
},
|
|
88
|
-
|
|
59
|
+
[`[data-whatinput='mouse'] &,
|
|
60
|
+
[data-whatinput='touch'] &,
|
|
61
|
+
[data-whatinput='pointer'] &`]: {
|
|
89
62
|
backgroundColor: 'inherit',
|
|
90
63
|
color: colors.blackPepper300,
|
|
91
64
|
'span .wd-icon-background ~ .wd-icon-accent, span .wd-icon-background ~ .wd-icon-accent2': {
|
|
@@ -101,55 +74,67 @@ var Item = styled('li')(__assign(__assign({}, type.levels.subtext.large), { padd
|
|
|
101
74
|
fill: iconColors.standard,
|
|
102
75
|
},
|
|
103
76
|
},
|
|
104
|
-
|
|
77
|
+
};
|
|
105
78
|
}
|
|
106
79
|
});
|
|
107
|
-
|
|
80
|
+
const LabelContainer = styled('span')({
|
|
108
81
|
flex: '1 1 auto',
|
|
109
82
|
overflow: 'hidden',
|
|
110
83
|
whiteSpace: 'nowrap',
|
|
111
84
|
textOverflow: 'ellipsis',
|
|
112
85
|
});
|
|
113
|
-
|
|
86
|
+
const Divider = styled('hr')({
|
|
114
87
|
display: 'block',
|
|
115
88
|
height: 1,
|
|
116
89
|
border: 0,
|
|
117
|
-
borderTop:
|
|
118
|
-
margin: space.xxs
|
|
90
|
+
borderTop: `1px solid ${colors.soap400}`,
|
|
91
|
+
margin: `${space.xxs} 0`,
|
|
119
92
|
});
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
93
|
+
const iconSize = 24;
|
|
94
|
+
const iconPadding = 16;
|
|
95
|
+
const StyledSystemIcon = styled(SystemIcon)({
|
|
123
96
|
minWidth: iconSize + iconPadding, // gives padding between LabelContainer, no matter the direction
|
|
124
97
|
});
|
|
125
|
-
|
|
126
|
-
display:
|
|
98
|
+
const SecondaryStyledSystemIcon = styled(SystemIcon)({
|
|
99
|
+
display: `flex`,
|
|
127
100
|
minWidth: iconSize + iconPadding,
|
|
128
|
-
justifyContent:
|
|
101
|
+
justifyContent: `flex-end`,
|
|
129
102
|
});
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
103
|
+
let iconProps = null;
|
|
104
|
+
let secondaryIconProps = null;
|
|
105
|
+
const setIconProps = (icon, isDisabled, isFocused) => {
|
|
133
106
|
if (!icon) {
|
|
134
107
|
return null;
|
|
135
108
|
}
|
|
136
|
-
|
|
109
|
+
let props = {
|
|
137
110
|
icon: icon,
|
|
138
111
|
size: iconSize,
|
|
139
112
|
};
|
|
140
113
|
if (isDisabled) {
|
|
141
|
-
props =
|
|
114
|
+
props = {
|
|
115
|
+
...props,
|
|
116
|
+
fill: iconColors.disabled,
|
|
117
|
+
fillHover: iconColors.disabled,
|
|
118
|
+
accent: iconColors.disabled,
|
|
119
|
+
accentHover: iconColors.disabled,
|
|
120
|
+
};
|
|
142
121
|
}
|
|
143
122
|
if (isFocused) {
|
|
144
|
-
props =
|
|
123
|
+
props = {
|
|
124
|
+
...props,
|
|
125
|
+
fill: iconColors.inverse,
|
|
126
|
+
fillHover: iconColors.inverse,
|
|
127
|
+
accent: iconColors.inverse,
|
|
128
|
+
accentHover: iconColors.inverse,
|
|
129
|
+
background: iconColors.inverse,
|
|
130
|
+
};
|
|
145
131
|
}
|
|
146
132
|
return props;
|
|
147
133
|
};
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
var parent = elem.parentElement;
|
|
134
|
+
const scrollIntoViewIfNeeded = (elem, centerIfNeeded = true) => {
|
|
135
|
+
const parent = elem.parentElement;
|
|
151
136
|
if (elem && parent) {
|
|
152
|
-
|
|
137
|
+
const parentComputedStyle = window.getComputedStyle(parent, null), parentBorderTopWidth = parseInt(parentComputedStyle.getPropertyValue('border-top-width'), 10), parentBorderLeftWidth = parseInt(parentComputedStyle.getPropertyValue('border-left-width'), 10), overTop = elem.offsetTop - parent.offsetTop < parent.scrollTop, overBottom = elem.offsetTop - parent.offsetTop + elem.clientHeight - parentBorderTopWidth >
|
|
153
138
|
parent.scrollTop + parent.clientHeight, overLeft = elem.offsetLeft - parent.offsetLeft < parent.scrollLeft, overRight = elem.offsetLeft - parent.offsetLeft + elem.clientWidth - parentBorderLeftWidth >
|
|
154
139
|
parent.scrollLeft + parent.clientWidth, alignWithTop = overTop && !overBottom;
|
|
155
140
|
if ((overTop || overBottom) && centerIfNeeded) {
|
|
@@ -191,45 +176,44 @@ var scrollIntoViewIfNeeded = function (elem, centerIfNeeded) {
|
|
|
191
176
|
*
|
|
192
177
|
* @deprecated
|
|
193
178
|
*/
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
scrollIntoViewIfNeeded(_this.ref.current);
|
|
179
|
+
export class DeprecatedMenuItem extends React.Component {
|
|
180
|
+
constructor() {
|
|
181
|
+
super(...arguments);
|
|
182
|
+
this.ref = React.createRef();
|
|
183
|
+
this.componentDidUpdate = (prevProps) => {
|
|
184
|
+
if (!prevProps.isFocused && this.props.isFocused) {
|
|
185
|
+
if (this.ref.current) {
|
|
186
|
+
scrollIntoViewIfNeeded(this.ref.current);
|
|
203
187
|
}
|
|
204
188
|
}
|
|
205
189
|
};
|
|
206
|
-
|
|
207
|
-
if (
|
|
190
|
+
this.handleClick = (event) => {
|
|
191
|
+
if (this.props.isDisabled) {
|
|
208
192
|
return;
|
|
209
193
|
}
|
|
210
|
-
if (
|
|
211
|
-
|
|
194
|
+
if (this.props.onClick) {
|
|
195
|
+
this.props.onClick(event);
|
|
212
196
|
}
|
|
213
197
|
};
|
|
214
|
-
return _this;
|
|
215
198
|
}
|
|
216
|
-
|
|
217
|
-
console.warn(
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
199
|
+
componentDidMount() {
|
|
200
|
+
console.warn(`This component is being deprecated and will be removed in Canvas Kit V9.\n
|
|
201
|
+
For more information, please see the V8 upgrade guide:\n
|
|
202
|
+
https://workday.github.io/canvas-kit/?path=/story/welcome-upgrade-guides-v8-0--page
|
|
203
|
+
`);
|
|
204
|
+
}
|
|
205
|
+
render() {
|
|
206
|
+
const { onClick, children, id, icon, secondaryIcon, hasDivider, isDisabled, isFocused, isHeader, role, ...elemProps } = this.props;
|
|
221
207
|
iconProps = setIconProps(icon, isDisabled, isFocused);
|
|
222
208
|
secondaryIconProps = setIconProps(secondaryIcon, isDisabled, isFocused);
|
|
223
209
|
return (React.createElement(React.Fragment, null,
|
|
224
210
|
hasDivider && React.createElement(Divider, { "aria-hidden": "true" }),
|
|
225
|
-
React.createElement(Item,
|
|
226
|
-
icon && iconProps && React.createElement(StyledSystemIcon,
|
|
211
|
+
React.createElement(Item, Object.assign({ ref: this.ref, tabIndex: -1, id: id, role: isHeader ? 'presentation' : role, "aria-hidden": isHeader ? true : undefined, onClick: this.handleClick, "aria-disabled": isDisabled ? true : undefined, isDisabled: !!isDisabled, isFocused: !!isFocused, isHeader: !!isHeader }, elemProps),
|
|
212
|
+
icon && iconProps && React.createElement(StyledSystemIcon, Object.assign({}, iconProps)),
|
|
227
213
|
React.createElement(LabelContainer, null, children),
|
|
228
|
-
secondaryIcon && secondaryIconProps && (React.createElement(SecondaryStyledSystemIcon,
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
}(React.Component));
|
|
232
|
-
export { DeprecatedMenuItem };
|
|
214
|
+
secondaryIcon && secondaryIconProps && (React.createElement(SecondaryStyledSystemIcon, Object.assign({}, secondaryIconProps))))));
|
|
215
|
+
}
|
|
216
|
+
}
|
|
233
217
|
/**
|
|
234
218
|
* If we destructure props, shouldClose will be undefined because the value is only applied for the render method only.
|
|
235
219
|
* We have to use defaultProps so that the value of shouldClose is applied for every method and therefore references in the Menu component.
|
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
-
var t = {};
|
|
14
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
-
t[p] = s[p];
|
|
16
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
-
t[p[i]] = s[p[i]];
|
|
20
|
-
}
|
|
21
|
-
return t;
|
|
22
|
-
};
|
|
23
1
|
import React from 'react';
|
|
24
2
|
import { BaseButton } from '@workday/canvas-kit-react/button';
|
|
25
3
|
import { createContainer, focusRing, mouseFocusBehavior, styled, } from '@workday/canvas-kit-react/common';
|
|
@@ -31,7 +9,7 @@ import { PillIconButton } from './PillIconButton';
|
|
|
31
9
|
import { PillCount } from './PillCount';
|
|
32
10
|
import { PillAvatar } from './PillAvatar';
|
|
33
11
|
import { PillLabel } from './PillLabel';
|
|
34
|
-
|
|
12
|
+
const getButtonPillColors = () => {
|
|
35
13
|
return {
|
|
36
14
|
default: {
|
|
37
15
|
background: colors.soap300,
|
|
@@ -70,7 +48,7 @@ var getButtonPillColors = function () {
|
|
|
70
48
|
},
|
|
71
49
|
};
|
|
72
50
|
};
|
|
73
|
-
|
|
51
|
+
const getRemovablePillColors = (disabled) => {
|
|
74
52
|
return {
|
|
75
53
|
default: {
|
|
76
54
|
background: disabled ? colors.soap100 : colors.soap300,
|
|
@@ -103,33 +81,51 @@ var getRemovablePillColors = function (disabled) {
|
|
|
103
81
|
disabled: {},
|
|
104
82
|
};
|
|
105
83
|
};
|
|
106
|
-
|
|
107
|
-
|
|
84
|
+
const pillBaseStyles = {
|
|
85
|
+
display: 'inline-flex',
|
|
86
|
+
alignItems: 'center',
|
|
87
|
+
borderRadius: borderRadius.m,
|
|
88
|
+
flexShrink: 0,
|
|
89
|
+
...type.levels.subtext.large,
|
|
90
|
+
color: colors.blackPepper400,
|
|
91
|
+
boxShadow: 'none',
|
|
92
|
+
outline: 'none',
|
|
93
|
+
fontWeight: type.properties.fontWeights.medium,
|
|
94
|
+
WebkitFontSmoothing: 'antialiased',
|
|
95
|
+
MozOsxFontSmoothing: 'grayscale',
|
|
96
|
+
width: 'fit-content',
|
|
97
|
+
padding: `2px ${space.xxs}`,
|
|
98
|
+
height: space.m,
|
|
99
|
+
position: 'relative',
|
|
100
|
+
};
|
|
101
|
+
const StyledBasePill = styled(BaseButton.as('button'))({
|
|
102
|
+
...pillBaseStyles,
|
|
103
|
+
'&:focus': {
|
|
108
104
|
'span[data-count="ck-pill-count"]': {
|
|
109
|
-
borderTop:
|
|
110
|
-
borderBottom:
|
|
111
|
-
borderRight:
|
|
105
|
+
borderTop: `1px solid ${colors.blueberry400}`,
|
|
106
|
+
borderBottom: `1px solid ${colors.blueberry400}`,
|
|
107
|
+
borderRight: `1px solid ${colors.blueberry400}`,
|
|
112
108
|
},
|
|
113
|
-
},
|
|
109
|
+
},
|
|
110
|
+
'&:active, &:active:hover, &:active:focus': {
|
|
114
111
|
'span[data-count="ck-pill-count"]': {
|
|
115
112
|
backgroundColor: colors.soap600,
|
|
116
113
|
border: 'none',
|
|
117
114
|
},
|
|
118
|
-
} }), mouseFocusBehavior({
|
|
119
|
-
'&:focus': {
|
|
120
|
-
'span[data-count="ck-pill-count"]': {
|
|
121
|
-
border: 'none',
|
|
122
|
-
},
|
|
123
115
|
},
|
|
124
|
-
|
|
125
|
-
var variant = _a.variant;
|
|
126
|
-
return ({
|
|
116
|
+
...mouseFocusBehavior({
|
|
127
117
|
'&:focus': {
|
|
128
|
-
|
|
118
|
+
'span[data-count="ck-pill-count"]': {
|
|
119
|
+
border: 'none',
|
|
120
|
+
},
|
|
129
121
|
},
|
|
130
|
-
})
|
|
131
|
-
},
|
|
132
|
-
|
|
122
|
+
}),
|
|
123
|
+
}, ({ variant }) => ({
|
|
124
|
+
'&:focus': {
|
|
125
|
+
borderColor: variant === 'removable' ? undefined : colors.blueberry400,
|
|
126
|
+
},
|
|
127
|
+
}), boxStyleFn);
|
|
128
|
+
const StyledNonInteractivePill = styled(StyledBasePill)({
|
|
133
129
|
cursor: 'default',
|
|
134
130
|
overflow: 'revert',
|
|
135
131
|
position: 'relative',
|
|
@@ -177,7 +173,7 @@ var StyledNonInteractivePill = styled(StyledBasePill)({
|
|
|
177
173
|
* </Pill>
|
|
178
174
|
* ```
|
|
179
175
|
*/
|
|
180
|
-
export
|
|
176
|
+
export const Pill = createContainer('button')({
|
|
181
177
|
displayName: 'Pill',
|
|
182
178
|
modelHook: usePillModel,
|
|
183
179
|
subComponents: {
|
|
@@ -242,20 +238,19 @@ export var Pill = createContainer('button')({
|
|
|
242
238
|
*/
|
|
243
239
|
Label: PillLabel,
|
|
244
240
|
},
|
|
245
|
-
})(
|
|
246
|
-
var _b = _a.variant, variant = _b === void 0 ? 'default' : _b, maxWidth = _a.maxWidth, elemProps = __rest(_a, ["variant", "maxWidth"]);
|
|
241
|
+
})(({ variant = 'default', maxWidth, ...elemProps }, Element, model) => {
|
|
247
242
|
return (React.createElement(React.Fragment, null,
|
|
248
|
-
variant === 'readOnly' && (React.createElement(StyledNonInteractivePill,
|
|
243
|
+
variant === 'readOnly' && (React.createElement(StyledNonInteractivePill, Object.assign({ maxWidth: model.state.maxWidth, as: Element !== 'button' ? Element : 'span', border: `1px solid ${colors.licorice200}`, id: model.state.id }, elemProps),
|
|
249
244
|
React.createElement(PillLabel, null, elemProps.children))),
|
|
250
|
-
variant === 'default' && (React.createElement(StyledBasePill,
|
|
251
|
-
React.createElement(Flex, { gap: "xxxs", display: "inline-flex", alignItems: "center" }, React.Children.map(elemProps.children,
|
|
245
|
+
variant === 'default' && (React.createElement(StyledBasePill, Object.assign({ colors: getButtonPillColors(), as: Element }, elemProps, { disabled: model.state.disabled }),
|
|
246
|
+
React.createElement(Flex, { gap: "xxxs", display: "inline-flex", alignItems: "center" }, React.Children.map(elemProps.children, (child, index) => {
|
|
252
247
|
if (typeof child === 'string') {
|
|
253
248
|
return React.createElement(PillLabel, { key: index }, child);
|
|
254
249
|
}
|
|
255
250
|
return (React.createElement(Flex.Item, { key: index, display: "inline-flex" }, child));
|
|
256
251
|
})))),
|
|
257
|
-
variant === 'removable' && (React.createElement(StyledNonInteractivePill,
|
|
258
|
-
React.createElement(Flex, { gap: "xxxs", display: "inline-flex", alignItems: "center", justifyContent: "center" }, React.Children.map(elemProps.children,
|
|
252
|
+
variant === 'removable' && (React.createElement(StyledNonInteractivePill, Object.assign({ colors: getRemovablePillColors(model.state.disabled), as: Element !== 'button' ? Element : 'span', variant: variant }, elemProps),
|
|
253
|
+
React.createElement(Flex, { gap: "xxxs", display: "inline-flex", alignItems: "center", justifyContent: "center" }, React.Children.map(elemProps.children, (child, index) => {
|
|
259
254
|
if (typeof child === 'string') {
|
|
260
255
|
return React.createElement(PillLabel, { key: index }, child);
|
|
261
256
|
}
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
1
|
import React from 'react';
|
|
13
2
|
import { createSubcomponent } from '@workday/canvas-kit-react/common';
|
|
14
3
|
import { Avatar } from '@workday/canvas-kit-react/avatar';
|
|
@@ -16,8 +5,8 @@ import { usePillModel } from './usePillModel';
|
|
|
16
5
|
// When the component is created, it needs to be a button element to match AvatarProps.
|
|
17
6
|
// Once Avatar becomes a `createComponent` we can default the element type to a `div`
|
|
18
7
|
// and the types should be properly extracted
|
|
19
|
-
export
|
|
8
|
+
export const PillAvatar = createSubcomponent('button')({
|
|
20
9
|
modelHook: usePillModel,
|
|
21
|
-
})(
|
|
22
|
-
return (React.createElement(Avatar,
|
|
10
|
+
})((elemProps, Element, model) => {
|
|
11
|
+
return (React.createElement(Avatar, Object.assign({ style: { opacity: model.state.disabled ? '.7' : '1' }, as: "div", size: 18, altText: undefined }, elemProps, { disabled: model.state.disabled }), elemProps.children));
|
|
23
12
|
});
|
|
@@ -1,39 +1,16 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
-
var t = {};
|
|
14
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
-
t[p] = s[p];
|
|
16
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
-
t[p[i]] = s[p[i]];
|
|
20
|
-
}
|
|
21
|
-
return t;
|
|
22
|
-
};
|
|
23
1
|
import React from 'react';
|
|
24
2
|
import { createComponent, styled } from '@workday/canvas-kit-react/common';
|
|
25
3
|
import { Flex } from '@workday/canvas-kit-react/layout';
|
|
26
4
|
import { borderRadius, colors, space } from '@workday/canvas-kit-react/tokens';
|
|
27
|
-
|
|
5
|
+
const StyledCountContainer = styled(Flex.as('span'))({
|
|
28
6
|
borderTopLeftRadius: borderRadius.zero,
|
|
29
7
|
borderTopRightRadius: borderRadius.m,
|
|
30
8
|
borderBottomLeftRadius: borderRadius.zero,
|
|
31
9
|
borderBottomRightRadius: borderRadius.m,
|
|
32
10
|
});
|
|
33
|
-
export
|
|
11
|
+
export const PillCount = createComponent('span')({
|
|
34
12
|
displayName: 'Pill.Avatar',
|
|
35
|
-
Component:
|
|
36
|
-
|
|
37
|
-
return (React.createElement(StyledCountContainer, __assign({ display: "inline-flex", alignItems: "center", justifyContent: "center", as: Element, height: 22, minWidth: 22, padding: "0 " + space.xxxs, marginInlineEnd: "-" + space.xxs, marginInlineStart: "" + space.xxxs, backgroundColor: colors.soap500, "data-count": "ck-pill-count", ref: ref }, elemProps), children));
|
|
13
|
+
Component: ({ children, ...elemProps }, ref, Element) => {
|
|
14
|
+
return (React.createElement(StyledCountContainer, Object.assign({ display: "inline-flex", alignItems: "center", justifyContent: "center", as: Element, height: 22, minWidth: 22, padding: `0 ${space.xxxs}`, marginInlineEnd: `-${space.xxs}`, marginInlineStart: `${space.xxxs}`, backgroundColor: colors.soap500, "data-count": "ck-pill-count", ref: ref }, elemProps), children));
|
|
38
15
|
},
|
|
39
16
|
});
|
|
@@ -1,34 +1,11 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
-
var t = {};
|
|
14
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
-
t[p] = s[p];
|
|
16
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
-
t[p[i]] = s[p[i]];
|
|
20
|
-
}
|
|
21
|
-
return t;
|
|
22
|
-
};
|
|
23
1
|
import React from 'react';
|
|
24
2
|
import { createSubcomponent } from '@workday/canvas-kit-react/common';
|
|
25
3
|
import { SystemIcon } from '@workday/canvas-kit-react/icon';
|
|
26
4
|
import { usePillModel } from './usePillModel';
|
|
27
5
|
import { plusIcon } from '@workday/canvas-system-icons-web';
|
|
28
6
|
import { space } from '@workday/canvas-kit-react/tokens';
|
|
29
|
-
export
|
|
7
|
+
export const PillIcon = createSubcomponent('span')({
|
|
30
8
|
modelHook: usePillModel,
|
|
31
|
-
})(
|
|
32
|
-
|
|
33
|
-
return (React.createElement(SystemIcon, __assign({ marginInlineStart: "-" + space.xxxs, display: "flex", as: Element, size: 20, role: "img", "aria-label": "add", icon: icon || plusIcon }, elemProps)));
|
|
9
|
+
})(({ size, icon, ...elemProps }, Element) => {
|
|
10
|
+
return (React.createElement(SystemIcon, Object.assign({ marginInlineStart: `-${space.xxxs}`, display: "flex", as: Element, size: 20, role: "img", "aria-label": "add", icon: icon || plusIcon }, elemProps)));
|
|
34
11
|
});
|
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
-
var t = {};
|
|
14
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
-
t[p] = s[p];
|
|
16
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
-
t[p[i]] = s[p[i]];
|
|
20
|
-
}
|
|
21
|
-
return t;
|
|
22
|
-
};
|
|
23
1
|
import React from 'react';
|
|
24
2
|
import { focusRing, styled, createSubcomponent } from '@workday/canvas-kit-react/common';
|
|
25
3
|
import { SystemIcon } from '@workday/canvas-kit-react/icon';
|
|
@@ -27,7 +5,7 @@ import { usePillModel } from './usePillModel';
|
|
|
27
5
|
import { xSmallIcon } from '@workday/canvas-system-icons-web';
|
|
28
6
|
import { colors, space } from '@workday/canvas-kit-react/tokens';
|
|
29
7
|
import { BaseButton } from '@workday/canvas-kit-react/button';
|
|
30
|
-
|
|
8
|
+
const getIconColors = () => {
|
|
31
9
|
return {
|
|
32
10
|
default: {
|
|
33
11
|
icon: colors.licorice200,
|
|
@@ -50,9 +28,9 @@ var getIconColors = function () {
|
|
|
50
28
|
},
|
|
51
29
|
};
|
|
52
30
|
};
|
|
53
|
-
|
|
31
|
+
const StyledIconButton = styled(BaseButton)({
|
|
54
32
|
marginInlineEnd: '-7px',
|
|
55
|
-
marginInlineStart:
|
|
33
|
+
marginInlineStart: `-2px`,
|
|
56
34
|
overflow: 'visible',
|
|
57
35
|
'::after': {
|
|
58
36
|
content: '""',
|
|
@@ -66,10 +44,9 @@ var StyledIconButton = styled(BaseButton)({
|
|
|
66
44
|
cursor: 'pointer',
|
|
67
45
|
},
|
|
68
46
|
});
|
|
69
|
-
export
|
|
47
|
+
export const PillIconButton = createSubcomponent('button')({
|
|
70
48
|
modelHook: usePillModel,
|
|
71
|
-
})(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
React.createElement(SystemIcon, { "aria-label": ariaLabel, id: "removable-" + model.state.id, icon: icon, size: space.m, "aria-hidden": true, role: "img" })));
|
|
49
|
+
})(({ size, icon = xSmallIcon, maxWidth, children, 'aria-label': ariaLabel = 'remove', ...elemProps }, Element, model) => {
|
|
50
|
+
return (React.createElement(StyledIconButton, Object.assign({ borderRadius: "s", height: 20, width: 20, padding: "zero", disabled: model.state.disabled, colors: getIconColors(), "aria-labelledby": `removable-${model.state.id} label-${model.state.id}`, as: Element, position: "relative" }, elemProps),
|
|
51
|
+
React.createElement(SystemIcon, { "aria-label": ariaLabel, id: `removable-${model.state.id}`, icon: icon, size: space.m, "aria-hidden": true, role: "img" })));
|
|
75
52
|
});
|
|
@@ -1,41 +1,18 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
-
var t = {};
|
|
14
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
-
t[p] = s[p];
|
|
16
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
-
t[p[i]] = s[p[i]];
|
|
20
|
-
}
|
|
21
|
-
return t;
|
|
22
|
-
};
|
|
23
1
|
import React from 'react';
|
|
24
2
|
import { createSubcomponent, styled } from '@workday/canvas-kit-react/common';
|
|
25
3
|
import { Box } from '@workday/canvas-kit-react/layout';
|
|
26
4
|
import { OverflowTooltip } from '@workday/canvas-kit-react/tooltip';
|
|
27
5
|
import { usePillModel } from './usePillModel';
|
|
28
6
|
import { colors } from '@workday/canvas-kit-react/tokens';
|
|
29
|
-
|
|
7
|
+
const StyledLabelContainer = styled(Box.as('span'))({
|
|
30
8
|
whiteSpace: 'nowrap',
|
|
31
9
|
overflow: 'hidden',
|
|
32
10
|
textOverflow: 'ellipsis',
|
|
33
11
|
display: 'block',
|
|
34
12
|
});
|
|
35
|
-
export
|
|
13
|
+
export const PillLabel = createSubcomponent('span')({
|
|
36
14
|
modelHook: usePillModel,
|
|
37
|
-
})(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
React.createElement(StyledLabelContainer, __assign({ color: model.state.disabled ? colors.licorice100 : 'inherit', maxWidth: model.state.maxWidth, as: Element, id: "label-" + model.state.id }, elemProps), elemProps.children)));
|
|
15
|
+
})(({ tooltipProps, ...elemProps }, Element, model) => {
|
|
16
|
+
return (React.createElement(OverflowTooltip, Object.assign({}, tooltipProps),
|
|
17
|
+
React.createElement(StyledLabelContainer, Object.assign({ color: model.state.disabled ? colors.licorice100 : 'inherit', maxWidth: model.state.maxWidth, as: Element, id: `label-${model.state.id}` }, elemProps), elemProps.children)));
|
|
41
18
|
});
|