@workday/canvas-kit-preview-react 9.0.0-alpha.368-next.6 → 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,30 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __assign = (this && this.__assign) || function () {
|
|
18
|
-
__assign = Object.assign || function(t) {
|
|
19
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
-
s = arguments[i];
|
|
21
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
-
t[p] = s[p];
|
|
23
|
-
}
|
|
24
|
-
return t;
|
|
25
|
-
};
|
|
26
|
-
return __assign.apply(this, arguments);
|
|
27
|
-
};
|
|
28
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
29
3
|
if (k2 === undefined) k2 = k;
|
|
30
4
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
@@ -44,34 +18,32 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
44
18
|
__setModuleDefault(result, mod);
|
|
45
19
|
return result;
|
|
46
20
|
};
|
|
47
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
48
|
-
var t = {};
|
|
49
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
50
|
-
t[p] = s[p];
|
|
51
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
52
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
53
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
54
|
-
t[p[i]] = s[p[i]];
|
|
55
|
-
}
|
|
56
|
-
return t;
|
|
57
|
-
};
|
|
58
21
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
59
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
60
23
|
};
|
|
61
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
25
|
exports.DeprecatedMenuItem = void 0;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
26
|
+
const React = __importStar(require("react"));
|
|
27
|
+
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
28
|
+
const tokens_1 = require("@workday/canvas-kit-react/tokens");
|
|
29
|
+
const icon_1 = require("@workday/canvas-kit-react/icon");
|
|
30
|
+
const Item = styled_1.default('li')({
|
|
31
|
+
...tokens_1.type.levels.subtext.large,
|
|
32
|
+
padding: `${tokens_1.space.xxs} ${tokens_1.space.s}`,
|
|
33
|
+
height: tokens_1.space.xl,
|
|
34
|
+
boxSizing: 'border-box',
|
|
35
|
+
cursor: 'pointer',
|
|
36
|
+
color: tokens_1.colors.blackPepper300,
|
|
37
|
+
display: 'flex',
|
|
38
|
+
flexDirection: 'row',
|
|
39
|
+
alignItems: 'center',
|
|
40
|
+
transition: 'background-color 80ms, color 80ms',
|
|
41
|
+
'&:focus': {
|
|
68
42
|
outline: 'none',
|
|
69
|
-
}
|
|
70
|
-
|
|
43
|
+
},
|
|
44
|
+
}, ({ isHeader }) => {
|
|
71
45
|
return { pointerEvents: isHeader ? 'none' : 'all' };
|
|
72
|
-
},
|
|
73
|
-
var _b;
|
|
74
|
-
var isFocused = _a.isFocused, isDisabled = _a.isDisabled;
|
|
46
|
+
}, ({ isFocused, isDisabled }) => {
|
|
75
47
|
if (!isFocused && !isDisabled) {
|
|
76
48
|
return {
|
|
77
49
|
backgroundColor: 'inherit',
|
|
@@ -92,25 +64,26 @@ var Item = styled_1.default('li')(__assign(__assign({}, tokens_1.type.levels.sub
|
|
|
92
64
|
}
|
|
93
65
|
else {
|
|
94
66
|
// Is focused or focused and disabled
|
|
95
|
-
return
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
67
|
+
return {
|
|
68
|
+
backgroundColor: isDisabled ? tokens_1.colors.blueberry200 : tokens_1.commonColors.focusBackground,
|
|
69
|
+
color: tokens_1.typeColors.inverse,
|
|
70
|
+
'span .wd-icon-background ~ .wd-icon-accent, .wd-icon-background ~ .wd-icon-accent2': {
|
|
71
|
+
fill: isDisabled ? tokens_1.iconColors.disabled : tokens_1.iconColors.active,
|
|
72
|
+
},
|
|
73
|
+
'&:hover': {
|
|
74
|
+
'span .wd-icon-fill, span .wd-icon-accent, span .wd-icon-accent2': {
|
|
75
|
+
fill: tokens_1.iconColors.inverse,
|
|
76
|
+
},
|
|
77
|
+
'span .wd-icon-background ~ .wd-icon-accent, span .wd-icon-background ~ .wd-icon-accent2': {
|
|
99
78
|
fill: isDisabled ? tokens_1.iconColors.disabled : tokens_1.iconColors.active,
|
|
100
79
|
},
|
|
101
|
-
'
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
},
|
|
105
|
-
'span .wd-icon-background ~ .wd-icon-accent, span .wd-icon-background ~ .wd-icon-accent2': {
|
|
106
|
-
fill: isDisabled ? tokens_1.iconColors.disabled : tokens_1.iconColors.active,
|
|
107
|
-
},
|
|
108
|
-
'span .wd-icon-background': {
|
|
109
|
-
fill: tokens_1.iconColors.inverse,
|
|
110
|
-
},
|
|
111
|
-
}
|
|
80
|
+
'span .wd-icon-background': {
|
|
81
|
+
fill: tokens_1.iconColors.inverse,
|
|
82
|
+
},
|
|
112
83
|
},
|
|
113
|
-
|
|
84
|
+
[`[data-whatinput='mouse'] &,
|
|
85
|
+
[data-whatinput='touch'] &,
|
|
86
|
+
[data-whatinput='pointer'] &`]: {
|
|
114
87
|
backgroundColor: 'inherit',
|
|
115
88
|
color: tokens_1.colors.blackPepper300,
|
|
116
89
|
'span .wd-icon-background ~ .wd-icon-accent, span .wd-icon-background ~ .wd-icon-accent2': {
|
|
@@ -126,55 +99,67 @@ var Item = styled_1.default('li')(__assign(__assign({}, tokens_1.type.levels.sub
|
|
|
126
99
|
fill: tokens_1.iconColors.standard,
|
|
127
100
|
},
|
|
128
101
|
},
|
|
129
|
-
|
|
102
|
+
};
|
|
130
103
|
}
|
|
131
104
|
});
|
|
132
|
-
|
|
105
|
+
const LabelContainer = styled_1.default('span')({
|
|
133
106
|
flex: '1 1 auto',
|
|
134
107
|
overflow: 'hidden',
|
|
135
108
|
whiteSpace: 'nowrap',
|
|
136
109
|
textOverflow: 'ellipsis',
|
|
137
110
|
});
|
|
138
|
-
|
|
111
|
+
const Divider = styled_1.default('hr')({
|
|
139
112
|
display: 'block',
|
|
140
113
|
height: 1,
|
|
141
114
|
border: 0,
|
|
142
|
-
borderTop:
|
|
143
|
-
margin: tokens_1.space.xxs
|
|
115
|
+
borderTop: `1px solid ${tokens_1.colors.soap400}`,
|
|
116
|
+
margin: `${tokens_1.space.xxs} 0`,
|
|
144
117
|
});
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
118
|
+
const iconSize = 24;
|
|
119
|
+
const iconPadding = 16;
|
|
120
|
+
const StyledSystemIcon = styled_1.default(icon_1.SystemIcon)({
|
|
148
121
|
minWidth: iconSize + iconPadding, // gives padding between LabelContainer, no matter the direction
|
|
149
122
|
});
|
|
150
|
-
|
|
151
|
-
display:
|
|
123
|
+
const SecondaryStyledSystemIcon = styled_1.default(icon_1.SystemIcon)({
|
|
124
|
+
display: `flex`,
|
|
152
125
|
minWidth: iconSize + iconPadding,
|
|
153
|
-
justifyContent:
|
|
126
|
+
justifyContent: `flex-end`,
|
|
154
127
|
});
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
128
|
+
let iconProps = null;
|
|
129
|
+
let secondaryIconProps = null;
|
|
130
|
+
const setIconProps = (icon, isDisabled, isFocused) => {
|
|
158
131
|
if (!icon) {
|
|
159
132
|
return null;
|
|
160
133
|
}
|
|
161
|
-
|
|
134
|
+
let props = {
|
|
162
135
|
icon: icon,
|
|
163
136
|
size: iconSize,
|
|
164
137
|
};
|
|
165
138
|
if (isDisabled) {
|
|
166
|
-
props =
|
|
139
|
+
props = {
|
|
140
|
+
...props,
|
|
141
|
+
fill: tokens_1.iconColors.disabled,
|
|
142
|
+
fillHover: tokens_1.iconColors.disabled,
|
|
143
|
+
accent: tokens_1.iconColors.disabled,
|
|
144
|
+
accentHover: tokens_1.iconColors.disabled,
|
|
145
|
+
};
|
|
167
146
|
}
|
|
168
147
|
if (isFocused) {
|
|
169
|
-
props =
|
|
148
|
+
props = {
|
|
149
|
+
...props,
|
|
150
|
+
fill: tokens_1.iconColors.inverse,
|
|
151
|
+
fillHover: tokens_1.iconColors.inverse,
|
|
152
|
+
accent: tokens_1.iconColors.inverse,
|
|
153
|
+
accentHover: tokens_1.iconColors.inverse,
|
|
154
|
+
background: tokens_1.iconColors.inverse,
|
|
155
|
+
};
|
|
170
156
|
}
|
|
171
157
|
return props;
|
|
172
158
|
};
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
var parent = elem.parentElement;
|
|
159
|
+
const scrollIntoViewIfNeeded = (elem, centerIfNeeded = true) => {
|
|
160
|
+
const parent = elem.parentElement;
|
|
176
161
|
if (elem && parent) {
|
|
177
|
-
|
|
162
|
+
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 >
|
|
178
163
|
parent.scrollTop + parent.clientHeight, overLeft = elem.offsetLeft - parent.offsetLeft < parent.scrollLeft, overRight = elem.offsetLeft - parent.offsetLeft + elem.clientWidth - parentBorderLeftWidth >
|
|
179
164
|
parent.scrollLeft + parent.clientWidth, alignWithTop = overTop && !overBottom;
|
|
180
165
|
if ((overTop || overBottom) && centerIfNeeded) {
|
|
@@ -216,44 +201,44 @@ var scrollIntoViewIfNeeded = function (elem, centerIfNeeded) {
|
|
|
216
201
|
*
|
|
217
202
|
* @deprecated
|
|
218
203
|
*/
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
scrollIntoViewIfNeeded(_this.ref.current);
|
|
204
|
+
class DeprecatedMenuItem extends React.Component {
|
|
205
|
+
constructor() {
|
|
206
|
+
super(...arguments);
|
|
207
|
+
this.ref = React.createRef();
|
|
208
|
+
this.componentDidUpdate = (prevProps) => {
|
|
209
|
+
if (!prevProps.isFocused && this.props.isFocused) {
|
|
210
|
+
if (this.ref.current) {
|
|
211
|
+
scrollIntoViewIfNeeded(this.ref.current);
|
|
228
212
|
}
|
|
229
213
|
}
|
|
230
214
|
};
|
|
231
|
-
|
|
232
|
-
if (
|
|
215
|
+
this.handleClick = (event) => {
|
|
216
|
+
if (this.props.isDisabled) {
|
|
233
217
|
return;
|
|
234
218
|
}
|
|
235
|
-
if (
|
|
236
|
-
|
|
219
|
+
if (this.props.onClick) {
|
|
220
|
+
this.props.onClick(event);
|
|
237
221
|
}
|
|
238
222
|
};
|
|
239
|
-
return _this;
|
|
240
223
|
}
|
|
241
|
-
|
|
242
|
-
console.warn(
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
224
|
+
componentDidMount() {
|
|
225
|
+
console.warn(`This component is being deprecated and will be removed in Canvas Kit V9.\n
|
|
226
|
+
For more information, please see the V8 upgrade guide:\n
|
|
227
|
+
https://workday.github.io/canvas-kit/?path=/story/welcome-upgrade-guides-v8-0--page
|
|
228
|
+
`);
|
|
229
|
+
}
|
|
230
|
+
render() {
|
|
231
|
+
const { onClick, children, id, icon, secondaryIcon, hasDivider, isDisabled, isFocused, isHeader, role, ...elemProps } = this.props;
|
|
246
232
|
iconProps = setIconProps(icon, isDisabled, isFocused);
|
|
247
233
|
secondaryIconProps = setIconProps(secondaryIcon, isDisabled, isFocused);
|
|
248
234
|
return (React.createElement(React.Fragment, null,
|
|
249
235
|
hasDivider && React.createElement(Divider, { "aria-hidden": "true" }),
|
|
250
|
-
React.createElement(Item,
|
|
251
|
-
icon && iconProps && React.createElement(StyledSystemIcon,
|
|
236
|
+
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),
|
|
237
|
+
icon && iconProps && React.createElement(StyledSystemIcon, Object.assign({}, iconProps)),
|
|
252
238
|
React.createElement(LabelContainer, null, children),
|
|
253
|
-
secondaryIcon && secondaryIconProps && (React.createElement(SecondaryStyledSystemIcon,
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
}(React.Component));
|
|
239
|
+
secondaryIcon && secondaryIconProps && (React.createElement(SecondaryStyledSystemIcon, Object.assign({}, secondaryIconProps))))));
|
|
240
|
+
}
|
|
241
|
+
}
|
|
257
242
|
exports.DeprecatedMenuItem = DeprecatedMenuItem;
|
|
258
243
|
/**
|
|
259
244
|
* If we destructure props, shouldClose will be undefined because the value is only applied for the render method only.
|
|
@@ -1,43 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
-
var t = {};
|
|
15
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
-
t[p] = s[p];
|
|
17
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
-
t[p[i]] = s[p[i]];
|
|
21
|
-
}
|
|
22
|
-
return t;
|
|
23
|
-
};
|
|
24
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
4
|
};
|
|
27
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
6
|
exports.Pill = void 0;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const button_1 = require("@workday/canvas-kit-react/button");
|
|
9
|
+
const common_1 = require("@workday/canvas-kit-react/common");
|
|
10
|
+
const layout_1 = require("@workday/canvas-kit-react/layout");
|
|
11
|
+
const tokens_1 = require("@workday/canvas-kit-react/tokens");
|
|
12
|
+
const usePillModel_1 = require("./usePillModel");
|
|
13
|
+
const PillIcon_1 = require("./PillIcon");
|
|
14
|
+
const PillIconButton_1 = require("./PillIconButton");
|
|
15
|
+
const PillCount_1 = require("./PillCount");
|
|
16
|
+
const PillAvatar_1 = require("./PillAvatar");
|
|
17
|
+
const PillLabel_1 = require("./PillLabel");
|
|
18
|
+
const getButtonPillColors = () => {
|
|
41
19
|
return {
|
|
42
20
|
default: {
|
|
43
21
|
background: tokens_1.colors.soap300,
|
|
@@ -76,7 +54,7 @@ var getButtonPillColors = function () {
|
|
|
76
54
|
},
|
|
77
55
|
};
|
|
78
56
|
};
|
|
79
|
-
|
|
57
|
+
const getRemovablePillColors = (disabled) => {
|
|
80
58
|
return {
|
|
81
59
|
default: {
|
|
82
60
|
background: disabled ? tokens_1.colors.soap100 : tokens_1.colors.soap300,
|
|
@@ -109,33 +87,51 @@ var getRemovablePillColors = function (disabled) {
|
|
|
109
87
|
disabled: {},
|
|
110
88
|
};
|
|
111
89
|
};
|
|
112
|
-
|
|
113
|
-
|
|
90
|
+
const pillBaseStyles = {
|
|
91
|
+
display: 'inline-flex',
|
|
92
|
+
alignItems: 'center',
|
|
93
|
+
borderRadius: tokens_1.borderRadius.m,
|
|
94
|
+
flexShrink: 0,
|
|
95
|
+
...tokens_1.type.levels.subtext.large,
|
|
96
|
+
color: tokens_1.colors.blackPepper400,
|
|
97
|
+
boxShadow: 'none',
|
|
98
|
+
outline: 'none',
|
|
99
|
+
fontWeight: tokens_1.type.properties.fontWeights.medium,
|
|
100
|
+
WebkitFontSmoothing: 'antialiased',
|
|
101
|
+
MozOsxFontSmoothing: 'grayscale',
|
|
102
|
+
width: 'fit-content',
|
|
103
|
+
padding: `2px ${tokens_1.space.xxs}`,
|
|
104
|
+
height: tokens_1.space.m,
|
|
105
|
+
position: 'relative',
|
|
106
|
+
};
|
|
107
|
+
const StyledBasePill = common_1.styled(button_1.BaseButton.as('button'))({
|
|
108
|
+
...pillBaseStyles,
|
|
109
|
+
'&:focus': {
|
|
114
110
|
'span[data-count="ck-pill-count"]': {
|
|
115
|
-
borderTop:
|
|
116
|
-
borderBottom:
|
|
117
|
-
borderRight:
|
|
111
|
+
borderTop: `1px solid ${tokens_1.colors.blueberry400}`,
|
|
112
|
+
borderBottom: `1px solid ${tokens_1.colors.blueberry400}`,
|
|
113
|
+
borderRight: `1px solid ${tokens_1.colors.blueberry400}`,
|
|
118
114
|
},
|
|
119
|
-
},
|
|
115
|
+
},
|
|
116
|
+
'&:active, &:active:hover, &:active:focus': {
|
|
120
117
|
'span[data-count="ck-pill-count"]': {
|
|
121
118
|
backgroundColor: tokens_1.colors.soap600,
|
|
122
119
|
border: 'none',
|
|
123
120
|
},
|
|
124
|
-
} }), common_1.mouseFocusBehavior({
|
|
125
|
-
'&:focus': {
|
|
126
|
-
'span[data-count="ck-pill-count"]': {
|
|
127
|
-
border: 'none',
|
|
128
|
-
},
|
|
129
121
|
},
|
|
130
|
-
|
|
131
|
-
var variant = _a.variant;
|
|
132
|
-
return ({
|
|
122
|
+
...common_1.mouseFocusBehavior({
|
|
133
123
|
'&:focus': {
|
|
134
|
-
|
|
124
|
+
'span[data-count="ck-pill-count"]': {
|
|
125
|
+
border: 'none',
|
|
126
|
+
},
|
|
135
127
|
},
|
|
136
|
-
})
|
|
137
|
-
},
|
|
138
|
-
|
|
128
|
+
}),
|
|
129
|
+
}, ({ variant }) => ({
|
|
130
|
+
'&:focus': {
|
|
131
|
+
borderColor: variant === 'removable' ? undefined : tokens_1.colors.blueberry400,
|
|
132
|
+
},
|
|
133
|
+
}), layout_1.boxStyleFn);
|
|
134
|
+
const StyledNonInteractivePill = common_1.styled(StyledBasePill)({
|
|
139
135
|
cursor: 'default',
|
|
140
136
|
overflow: 'revert',
|
|
141
137
|
position: 'relative',
|
|
@@ -248,20 +244,19 @@ exports.Pill = common_1.createContainer('button')({
|
|
|
248
244
|
*/
|
|
249
245
|
Label: PillLabel_1.PillLabel,
|
|
250
246
|
},
|
|
251
|
-
})(
|
|
252
|
-
var _b = _a.variant, variant = _b === void 0 ? 'default' : _b, maxWidth = _a.maxWidth, elemProps = __rest(_a, ["variant", "maxWidth"]);
|
|
247
|
+
})(({ variant = 'default', maxWidth, ...elemProps }, Element, model) => {
|
|
253
248
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
254
|
-
variant === 'readOnly' && (react_1.default.createElement(StyledNonInteractivePill,
|
|
249
|
+
variant === 'readOnly' && (react_1.default.createElement(StyledNonInteractivePill, Object.assign({ maxWidth: model.state.maxWidth, as: Element !== 'button' ? Element : 'span', border: `1px solid ${tokens_1.colors.licorice200}`, id: model.state.id }, elemProps),
|
|
255
250
|
react_1.default.createElement(PillLabel_1.PillLabel, null, elemProps.children))),
|
|
256
|
-
variant === 'default' && (react_1.default.createElement(StyledBasePill,
|
|
257
|
-
react_1.default.createElement(layout_1.Flex, { gap: "xxxs", display: "inline-flex", alignItems: "center" }, react_1.default.Children.map(elemProps.children,
|
|
251
|
+
variant === 'default' && (react_1.default.createElement(StyledBasePill, Object.assign({ colors: getButtonPillColors(), as: Element }, elemProps, { disabled: model.state.disabled }),
|
|
252
|
+
react_1.default.createElement(layout_1.Flex, { gap: "xxxs", display: "inline-flex", alignItems: "center" }, react_1.default.Children.map(elemProps.children, (child, index) => {
|
|
258
253
|
if (typeof child === 'string') {
|
|
259
254
|
return react_1.default.createElement(PillLabel_1.PillLabel, { key: index }, child);
|
|
260
255
|
}
|
|
261
256
|
return (react_1.default.createElement(layout_1.Flex.Item, { key: index, display: "inline-flex" }, child));
|
|
262
257
|
})))),
|
|
263
|
-
variant === 'removable' && (react_1.default.createElement(StyledNonInteractivePill,
|
|
264
|
-
react_1.default.createElement(layout_1.Flex, { gap: "xxxs", display: "inline-flex", alignItems: "center", justifyContent: "center" }, react_1.default.Children.map(elemProps.children,
|
|
258
|
+
variant === 'removable' && (react_1.default.createElement(StyledNonInteractivePill, Object.assign({ colors: getRemovablePillColors(model.state.disabled), as: Element !== 'button' ? Element : 'span', variant: variant }, elemProps),
|
|
259
|
+
react_1.default.createElement(layout_1.Flex, { gap: "xxxs", display: "inline-flex", alignItems: "center", justifyContent: "center" }, react_1.default.Children.map(elemProps.children, (child, index) => {
|
|
265
260
|
if (typeof child === 'string') {
|
|
266
261
|
return react_1.default.createElement(PillLabel_1.PillLabel, { key: index }, child);
|
|
267
262
|
}
|
|
@@ -1,29 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
4
|
};
|
|
16
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
6
|
exports.PillAvatar = void 0;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const common_1 = require("@workday/canvas-kit-react/common");
|
|
9
|
+
const avatar_1 = require("@workday/canvas-kit-react/avatar");
|
|
10
|
+
const usePillModel_1 = require("./usePillModel");
|
|
22
11
|
// When the component is created, it needs to be a button element to match AvatarProps.
|
|
23
12
|
// Once Avatar becomes a `createComponent` we can default the element type to a `div`
|
|
24
13
|
// and the types should be properly extracted
|
|
25
14
|
exports.PillAvatar = common_1.createSubcomponent('button')({
|
|
26
15
|
modelHook: usePillModel_1.usePillModel,
|
|
27
|
-
})(
|
|
28
|
-
return (react_1.default.createElement(avatar_1.Avatar,
|
|
16
|
+
})((elemProps, Element, model) => {
|
|
17
|
+
return (react_1.default.createElement(avatar_1.Avatar, Object.assign({ style: { opacity: model.state.disabled ? '.7' : '1' }, as: "div", size: 18, altText: undefined }, elemProps, { disabled: model.state.disabled }), elemProps.children));
|
|
29
18
|
});
|
|
@@ -1,36 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
-
var t = {};
|
|
15
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
-
t[p] = s[p];
|
|
17
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
-
t[p[i]] = s[p[i]];
|
|
21
|
-
}
|
|
22
|
-
return t;
|
|
23
|
-
};
|
|
24
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
4
|
};
|
|
27
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
6
|
exports.PillCount = void 0;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const common_1 = require("@workday/canvas-kit-react/common");
|
|
9
|
+
const layout_1 = require("@workday/canvas-kit-react/layout");
|
|
10
|
+
const tokens_1 = require("@workday/canvas-kit-react/tokens");
|
|
11
|
+
const StyledCountContainer = common_1.styled(layout_1.Flex.as('span'))({
|
|
34
12
|
borderTopLeftRadius: tokens_1.borderRadius.zero,
|
|
35
13
|
borderTopRightRadius: tokens_1.borderRadius.m,
|
|
36
14
|
borderBottomLeftRadius: tokens_1.borderRadius.zero,
|
|
@@ -38,8 +16,7 @@ var StyledCountContainer = common_1.styled(layout_1.Flex.as('span'))({
|
|
|
38
16
|
});
|
|
39
17
|
exports.PillCount = common_1.createComponent('span')({
|
|
40
18
|
displayName: 'Pill.Avatar',
|
|
41
|
-
Component:
|
|
42
|
-
|
|
43
|
-
return (react_1.default.createElement(StyledCountContainer, __assign({ display: "inline-flex", alignItems: "center", justifyContent: "center", as: Element, height: 22, minWidth: 22, padding: "0 " + tokens_1.space.xxxs, marginInlineEnd: "-" + tokens_1.space.xxs, marginInlineStart: "" + tokens_1.space.xxxs, backgroundColor: tokens_1.colors.soap500, "data-count": "ck-pill-count", ref: ref }, elemProps), children));
|
|
19
|
+
Component: ({ children, ...elemProps }, ref, Element) => {
|
|
20
|
+
return (react_1.default.createElement(StyledCountContainer, Object.assign({ display: "inline-flex", alignItems: "center", justifyContent: "center", as: Element, height: 22, minWidth: 22, padding: `0 ${tokens_1.space.xxxs}`, marginInlineEnd: `-${tokens_1.space.xxs}`, marginInlineStart: `${tokens_1.space.xxxs}`, backgroundColor: tokens_1.colors.soap500, "data-count": "ck-pill-count", ref: ref }, elemProps), children));
|
|
44
21
|
},
|
|
45
22
|
});
|
|
@@ -1,40 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
-
var t = {};
|
|
15
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
-
t[p] = s[p];
|
|
17
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
-
t[p[i]] = s[p[i]];
|
|
21
|
-
}
|
|
22
|
-
return t;
|
|
23
|
-
};
|
|
24
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
4
|
};
|
|
27
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
6
|
exports.PillIcon = void 0;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const common_1 = require("@workday/canvas-kit-react/common");
|
|
9
|
+
const icon_1 = require("@workday/canvas-kit-react/icon");
|
|
10
|
+
const usePillModel_1 = require("./usePillModel");
|
|
11
|
+
const canvas_system_icons_web_1 = require("@workday/canvas-system-icons-web");
|
|
12
|
+
const tokens_1 = require("@workday/canvas-kit-react/tokens");
|
|
35
13
|
exports.PillIcon = common_1.createSubcomponent('span')({
|
|
36
14
|
modelHook: usePillModel_1.usePillModel,
|
|
37
|
-
})(
|
|
38
|
-
|
|
39
|
-
return (react_1.default.createElement(icon_1.SystemIcon, __assign({ marginInlineStart: "-" + tokens_1.space.xxxs, display: "flex", as: Element, size: 20, role: "img", "aria-label": "add", icon: icon || canvas_system_icons_web_1.plusIcon }, elemProps)));
|
|
15
|
+
})(({ size, icon, ...elemProps }, Element) => {
|
|
16
|
+
return (react_1.default.createElement(icon_1.SystemIcon, Object.assign({ marginInlineStart: `-${tokens_1.space.xxxs}`, display: "flex", as: Element, size: 20, role: "img", "aria-label": "add", icon: icon || canvas_system_icons_web_1.plusIcon }, elemProps)));
|
|
40
17
|
});
|