@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,15 +1,4 @@
|
|
|
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
3
|
if (k2 === undefined) k2 = k;
|
|
15
4
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
@@ -29,37 +18,29 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
29
18
|
__setModuleDefault(result, mod);
|
|
30
19
|
return result;
|
|
31
20
|
};
|
|
32
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
33
|
-
var t = {};
|
|
34
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
35
|
-
t[p] = s[p];
|
|
36
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
37
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
38
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
39
|
-
t[p[i]] = s[p[i]];
|
|
40
|
-
}
|
|
41
|
-
return t;
|
|
42
|
-
};
|
|
43
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
22
|
exports.SelectOption = void 0;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
23
|
+
const React = __importStar(require("react"));
|
|
24
|
+
const common_1 = require("@workday/canvas-kit-react/common");
|
|
25
|
+
const tokens_1 = require("@workday/canvas-kit-react/tokens");
|
|
26
|
+
const optionPadding = 6;
|
|
27
|
+
const activeStyles = (theme) => {
|
|
28
|
+
const activeBgColor = theme.canvas.palette.primary.main;
|
|
51
29
|
return {
|
|
52
30
|
backgroundColor: activeBgColor,
|
|
53
31
|
color: common_1.pickForegroundColor(activeBgColor),
|
|
54
32
|
};
|
|
55
33
|
};
|
|
56
|
-
|
|
34
|
+
const Option = common_1.styled('li')({
|
|
35
|
+
...tokens_1.type.levels.subtext.large,
|
|
36
|
+
cursor: 'default',
|
|
57
37
|
// Apply listStyle at the list item style to ensure it's styled properly
|
|
58
38
|
// in Visual Testing States
|
|
59
|
-
listStyle: 'none',
|
|
39
|
+
listStyle: 'none',
|
|
60
40
|
// In case the content of the option is empty/undefined for some reason
|
|
61
|
-
minHeight: tokens_1.type.levels.subtext.large.lineHeight,
|
|
62
|
-
|
|
41
|
+
minHeight: tokens_1.type.levels.subtext.large.lineHeight,
|
|
42
|
+
textAlign: 'left',
|
|
43
|
+
}, ({ 'aria-disabled': disabled, focused, interactive, theme }) => {
|
|
63
44
|
if (disabled) {
|
|
64
45
|
// If the option is disabled, return disabled styles...
|
|
65
46
|
return {
|
|
@@ -68,36 +49,41 @@ var Option = common_1.styled('li')(__assign(__assign({}, tokens_1.type.levels.su
|
|
|
68
49
|
}
|
|
69
50
|
else if (focused) {
|
|
70
51
|
// ...else if the option is focused, return focused styles...
|
|
71
|
-
return
|
|
52
|
+
return {
|
|
53
|
+
...activeStyles(theme),
|
|
54
|
+
};
|
|
72
55
|
}
|
|
73
56
|
else {
|
|
74
57
|
// ...else return hover and selected (via aria-selected) styles
|
|
75
|
-
|
|
76
|
-
|
|
58
|
+
const selectedBgColor = theme.canvas.palette.primary.lightest;
|
|
59
|
+
const selectedStyles = {
|
|
77
60
|
'&[aria-selected="true"]': {
|
|
78
61
|
backgroundColor: selectedBgColor,
|
|
79
62
|
color: common_1.pickForegroundColor(selectedBgColor),
|
|
80
63
|
},
|
|
81
64
|
};
|
|
82
65
|
// Only display interactive (hover/active) styles if the option is interactive
|
|
83
|
-
|
|
66
|
+
const interactiveStyles = interactive
|
|
84
67
|
? {
|
|
85
68
|
'&:hover': {
|
|
86
69
|
backgroundColor: tokens_1.commonColors.hoverBackground,
|
|
87
70
|
},
|
|
88
|
-
'&:active, &:active[aria-selected="true"]':
|
|
71
|
+
'&:active, &:active[aria-selected="true"]': {
|
|
72
|
+
...activeStyles(theme),
|
|
73
|
+
},
|
|
89
74
|
}
|
|
90
75
|
: {};
|
|
91
|
-
return
|
|
76
|
+
return {
|
|
77
|
+
// Place selected styles after interactive styles to have selected styles
|
|
78
|
+
// override interactive styles (subject to CSS specificity rules)
|
|
79
|
+
...interactiveStyles,
|
|
80
|
+
...selectedStyles,
|
|
81
|
+
};
|
|
92
82
|
}
|
|
93
|
-
},
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
var SelectOption = function (_a) {
|
|
100
|
-
var children = _a.children, _b = _a.focused, focused = _b === void 0 ? false : _b, _c = _a.interactive, interactive = _c === void 0 ? true : _c, optionRef = _a.optionRef, value = _a.value, elemProps = __rest(_a, ["children", "focused", "interactive", "optionRef", "value"]);
|
|
101
|
-
return (React.createElement(Option, __assign({ "data-value": value, focused: focused, interactive: interactive, ref: optionRef, role: "option" }, elemProps), children));
|
|
83
|
+
}, ({ error }) => ({
|
|
84
|
+
padding: `${optionPadding}px ${error === common_1.ErrorType.Alert ? optionPadding - 1 : optionPadding}px`,
|
|
85
|
+
}));
|
|
86
|
+
const SelectOption = ({ children, focused = false, interactive = true, optionRef, value, ...elemProps }) => {
|
|
87
|
+
return (React.createElement(Option, Object.assign({ "data-value": value, focused: focused, interactive: interactive, ref: optionRef, role: "option" }, elemProps), children));
|
|
102
88
|
};
|
|
103
89
|
exports.SelectOption = SelectOption;
|
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.scrollIntoViewIfNeeded = void 0;
|
|
4
4
|
// Modified from https://gist.github.com/hsablonniere/2581101
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var parent = elem.parentElement;
|
|
5
|
+
const scrollIntoViewIfNeeded = (elem, centerIfNeeded = true) => {
|
|
6
|
+
const parent = elem.parentElement;
|
|
8
7
|
if (elem && parent) {
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const parentComputedStyle = window.getComputedStyle(parent, null);
|
|
9
|
+
const parentBorderTopWidth = parseInt(parentComputedStyle.getPropertyValue('border-top-width'), 10);
|
|
11
10
|
// Check if elem is out of view at the top edge of the parent's viewport
|
|
12
|
-
|
|
11
|
+
const overTop = elem.offsetTop < parent.scrollTop + parentBorderTopWidth;
|
|
13
12
|
// Check if elem is out of view at the bottom edge of the parent's viewport
|
|
14
|
-
|
|
13
|
+
const overBottom = elem.offsetTop + elem.offsetHeight >
|
|
15
14
|
parent.scrollTop + parentBorderTopWidth + parent.clientHeight;
|
|
16
15
|
if ((overTop || overBottom) && centerIfNeeded) {
|
|
17
16
|
parent.scrollTop = Math.floor(elem.offsetTop - parent.clientHeight / 2 - parentBorderTopWidth + elem.clientHeight / 2);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getCorrectedIndexByValue = exports.getIndexByValue = void 0;
|
|
4
|
-
|
|
4
|
+
const getIndexByValue = (options, value) => {
|
|
5
5
|
if (!options || value === undefined) {
|
|
6
6
|
return -1;
|
|
7
7
|
}
|
|
8
|
-
for (
|
|
8
|
+
for (let i = 0; i < options.length; i++) {
|
|
9
9
|
if (options[i].value === value) {
|
|
10
10
|
return i;
|
|
11
11
|
}
|
|
@@ -14,8 +14,8 @@ var getIndexByValue = function (options, value) {
|
|
|
14
14
|
};
|
|
15
15
|
exports.getIndexByValue = getIndexByValue;
|
|
16
16
|
// If the value doesn't exist in the options, return index 0
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
const getCorrectedIndexByValue = (options, value) => {
|
|
18
|
+
const indexByValue = exports.getIndexByValue(options, value);
|
|
19
19
|
return indexByValue === -1 ? 0 : indexByValue;
|
|
20
20
|
};
|
|
21
21
|
exports.getCorrectedIndexByValue = getCorrectedIndexByValue;
|
|
@@ -1,19 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
-
return cooked;
|
|
5
|
-
};
|
|
6
|
-
var __assign = (this && this.__assign) || function () {
|
|
7
|
-
__assign = Object.assign || function(t) {
|
|
8
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
9
|
-
s = arguments[i];
|
|
10
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
11
|
-
t[p] = s[p];
|
|
12
|
-
}
|
|
13
|
-
return t;
|
|
14
|
-
};
|
|
15
|
-
return __assign.apply(this, arguments);
|
|
16
|
-
};
|
|
17
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
3
|
if (k2 === undefined) k2 = k;
|
|
19
4
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
@@ -33,41 +18,43 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
33
18
|
__setModuleDefault(result, mod);
|
|
34
19
|
return result;
|
|
35
20
|
};
|
|
36
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
37
|
-
var t = {};
|
|
38
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
39
|
-
t[p] = s[p];
|
|
40
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
41
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
42
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
43
|
-
t[p[i]] = s[p[i]];
|
|
44
|
-
}
|
|
45
|
-
return t;
|
|
46
|
-
};
|
|
47
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
22
|
exports.SidePanel = void 0;
|
|
49
23
|
/** @jsxRuntime classic */
|
|
50
24
|
/** @jsx jsx */
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
25
|
+
const React = __importStar(require("react"));
|
|
26
|
+
const common_1 = require("@workday/canvas-kit-react/common");
|
|
27
|
+
const react_1 = require("@emotion/react");
|
|
28
|
+
const tokens_1 = require("@workday/canvas-kit-react/tokens");
|
|
29
|
+
const hooks_1 = require("./hooks");
|
|
30
|
+
const SidePanelToggleButton_1 = require("./SidePanelToggleButton");
|
|
31
|
+
const createKeyframes = (from, to) => {
|
|
32
|
+
const normalized = {
|
|
59
33
|
from: typeof from === 'number' ? from + 'px' : from,
|
|
60
34
|
to: typeof to === 'number' ? to + 'px' : to,
|
|
61
35
|
};
|
|
62
|
-
return react_1.keyframes
|
|
36
|
+
return react_1.keyframes `
|
|
37
|
+
from {
|
|
38
|
+
width: ${normalized.from};
|
|
39
|
+
min-width: ${normalized.from};
|
|
40
|
+
max-width: ${normalized.from};
|
|
41
|
+
} to {
|
|
42
|
+
width: ${normalized.to};
|
|
43
|
+
min-width: ${normalized.to};
|
|
44
|
+
max-width: ${normalized.to};
|
|
45
|
+
}
|
|
46
|
+
`;
|
|
63
47
|
};
|
|
64
|
-
|
|
65
|
-
alternate:
|
|
48
|
+
const containerVariantStyle = {
|
|
49
|
+
alternate: {
|
|
50
|
+
backgroundColor: tokens_1.colors.frenchVanilla100,
|
|
51
|
+
...tokens_1.depth[5],
|
|
52
|
+
},
|
|
66
53
|
standard: {
|
|
67
54
|
backgroundColor: tokens_1.colors.soap100,
|
|
68
55
|
},
|
|
69
56
|
};
|
|
70
|
-
|
|
57
|
+
const Panel = common_1.styled('section')({
|
|
71
58
|
overflow: 'hidden',
|
|
72
59
|
position: 'relative',
|
|
73
60
|
boxSizing: 'border-box',
|
|
@@ -75,24 +62,23 @@ var Panel = common_1.styled('section')({
|
|
|
75
62
|
});
|
|
76
63
|
exports.SidePanel = common_1.createComponent('section')({
|
|
77
64
|
displayName: 'SidePanel',
|
|
78
|
-
Component
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
React.useEffect(function () {
|
|
65
|
+
Component({ children, collapsedWidth = 64, expanded = true, expandedWidth = 320, onAnimationEnd, onAnimationStart, onExpandedChange, onStateTransition, origin = 'left', variant = 'standard', touched, ...elemProps }, ref, Element) {
|
|
66
|
+
const [state, setState] = React.useState(expanded ? 'expanded' : 'collapsed');
|
|
67
|
+
React.useEffect(() => {
|
|
82
68
|
if (typeof onExpandedChange !== 'undefined') {
|
|
83
69
|
onExpandedChange(expanded);
|
|
84
70
|
}
|
|
85
71
|
}, [expanded, onExpandedChange]);
|
|
86
|
-
React.useEffect(
|
|
72
|
+
React.useEffect(() => {
|
|
87
73
|
if (typeof onStateTransition !== 'undefined') {
|
|
88
74
|
onStateTransition(state);
|
|
89
75
|
}
|
|
90
76
|
}, [state, onStateTransition]);
|
|
91
|
-
|
|
77
|
+
const motion = {
|
|
92
78
|
collapse: createKeyframes(expandedWidth, collapsedWidth),
|
|
93
79
|
expand: createKeyframes(collapsedWidth, expandedWidth),
|
|
94
80
|
};
|
|
95
|
-
|
|
81
|
+
const handleAnimationEnd = (event) => {
|
|
96
82
|
if (event.currentTarget === event.target) {
|
|
97
83
|
if (event.animationName === motion.collapse.name) {
|
|
98
84
|
setState('collapsed');
|
|
@@ -105,7 +91,7 @@ exports.SidePanel = common_1.createComponent('section')({
|
|
|
105
91
|
onAnimationEnd(event);
|
|
106
92
|
}
|
|
107
93
|
};
|
|
108
|
-
|
|
94
|
+
const handleAnimationStart = (event) => {
|
|
109
95
|
if (event.currentTarget === event.target) {
|
|
110
96
|
if (event.animationName === motion.collapse.name ||
|
|
111
97
|
event.animationName === motion.expand.name) {
|
|
@@ -116,21 +102,21 @@ exports.SidePanel = common_1.createComponent('section')({
|
|
|
116
102
|
onAnimationStart(event);
|
|
117
103
|
}
|
|
118
104
|
};
|
|
119
|
-
return (react_1.jsx(Panel,
|
|
105
|
+
return (react_1.jsx(Panel, Object.assign({ ref: ref, as: Element, css: [
|
|
120
106
|
{
|
|
121
107
|
width: expanded ? expandedWidth : collapsedWidth,
|
|
122
108
|
maxWidth: expanded ? expandedWidth : collapsedWidth,
|
|
123
109
|
// mounted.current will be false on the first render, thus you won't get an unwanted animation here
|
|
124
110
|
// Will animate again if you force a re-render (like in Storybook)
|
|
125
111
|
animation: touched
|
|
126
|
-
?
|
|
112
|
+
? `${expanded ? motion.expand : motion.collapse} 200ms ease-out`
|
|
127
113
|
: undefined,
|
|
128
114
|
},
|
|
129
115
|
containerVariantStyle[variant],
|
|
130
116
|
], onAnimationEnd: handleAnimationEnd, onAnimationStart: handleAnimationStart }, elemProps),
|
|
131
117
|
react_1.jsx(hooks_1.SidePanelContext.Provider, { value: {
|
|
132
|
-
state
|
|
133
|
-
origin
|
|
118
|
+
state,
|
|
119
|
+
origin,
|
|
134
120
|
} }, children)));
|
|
135
121
|
},
|
|
136
122
|
subComponents: {
|
|
@@ -146,4 +132,3 @@ exports.SidePanel = common_1.createComponent('section')({
|
|
|
146
132
|
ToggleButton: SidePanelToggleButton_1.SidePanelToggleButton,
|
|
147
133
|
},
|
|
148
134
|
});
|
|
149
|
-
var templateObject_1;
|
|
@@ -1,15 +1,4 @@
|
|
|
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
3
|
if (k2 === undefined) k2 = k;
|
|
15
4
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
@@ -29,39 +18,27 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
29
18
|
__setModuleDefault(result, mod);
|
|
30
19
|
return result;
|
|
31
20
|
};
|
|
32
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
33
|
-
var t = {};
|
|
34
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
35
|
-
t[p] = s[p];
|
|
36
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
37
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
38
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
39
|
-
t[p[i]] = s[p[i]];
|
|
40
|
-
}
|
|
41
|
-
return t;
|
|
42
|
-
};
|
|
43
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
22
|
exports.SidePanelToggleButton = void 0;
|
|
45
23
|
/** @jsxRuntime classic */
|
|
46
24
|
/** @jsx jsx */
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
25
|
+
const React = __importStar(require("react"));
|
|
26
|
+
const common_1 = require("@workday/canvas-kit-react/common");
|
|
27
|
+
const react_1 = require("@emotion/react");
|
|
28
|
+
const button_1 = require("@workday/canvas-kit-react/button");
|
|
29
|
+
const tokens_1 = require("@workday/canvas-kit-react/tokens");
|
|
30
|
+
const canvas_system_icons_web_1 = require("@workday/canvas-system-icons-web");
|
|
31
|
+
const tooltip_1 = require("@workday/canvas-kit-react/tooltip");
|
|
32
|
+
const hooks_1 = require("./hooks");
|
|
55
33
|
/**
|
|
56
34
|
* A toggle button styled specifically for the side panel container.
|
|
57
35
|
*/
|
|
58
36
|
exports.SidePanelToggleButton = common_1.createComponent('button')({
|
|
59
37
|
displayName: 'SidePanel.ToggleButton',
|
|
60
|
-
Component
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
var isRTL = common_1.useIsRTL();
|
|
38
|
+
Component({ variant = undefined, icon = canvas_system_icons_web_1.transformationImportIcon, tooltipTextExpand = 'Expand', tooltipTextCollapse = 'Collapse', ...elemProps }) {
|
|
39
|
+
const context = React.useContext(hooks_1.SidePanelContext);
|
|
40
|
+
const useRTLOrigin = () => {
|
|
41
|
+
const isRTL = common_1.useIsRTL();
|
|
65
42
|
// if the direction is set to RTl, flip the origin
|
|
66
43
|
if (isRTL) {
|
|
67
44
|
return context.origin === 'left' ? 'right' : 'left';
|
|
@@ -69,9 +46,9 @@ exports.SidePanelToggleButton = common_1.createComponent('button')({
|
|
|
69
46
|
// Otherwise, default to returning the origin
|
|
70
47
|
return context.origin;
|
|
71
48
|
};
|
|
72
|
-
|
|
49
|
+
const rtlOrigin = useRTLOrigin();
|
|
73
50
|
// Note: Depending on the collapsed width, the button could "jump" to it's final position.
|
|
74
|
-
|
|
51
|
+
const buttonStyle = react_1.css({
|
|
75
52
|
position: 'absolute',
|
|
76
53
|
top: tokens_1.space.m,
|
|
77
54
|
width: tokens_1.space.l,
|
|
@@ -79,10 +56,10 @@ exports.SidePanelToggleButton = common_1.createComponent('button')({
|
|
|
79
56
|
left: context.state === 'collapsed' ? 0 : rtlOrigin === 'right' ? tokens_1.space.s : undefined,
|
|
80
57
|
margin: context.state === 'collapsed' ? 'auto' : 0,
|
|
81
58
|
transform: context.state === 'collapsed' || context.state === 'collapsing'
|
|
82
|
-
?
|
|
83
|
-
:
|
|
59
|
+
? `scaleX(${rtlOrigin === 'left' ? '1' : '-1'})`
|
|
60
|
+
: `scaleX(${rtlOrigin === 'left' ? '-1' : '1'})`,
|
|
84
61
|
});
|
|
85
62
|
return (react_1.jsx(tooltip_1.Tooltip, { title: context.state === 'collapsed' ? tooltipTextExpand : tooltipTextCollapse, type: "muted" },
|
|
86
|
-
react_1.jsx(button_1.TertiaryButton,
|
|
63
|
+
react_1.jsx(button_1.TertiaryButton, Object.assign({ type: "button", css: buttonStyle, icon: icon, variant: variant }, elemProps))));
|
|
87
64
|
},
|
|
88
65
|
});
|
|
@@ -20,12 +20,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
22
|
exports.useSidePanel = exports.SidePanelContext = void 0;
|
|
23
|
-
|
|
23
|
+
const React = __importStar(require("react"));
|
|
24
24
|
exports.SidePanelContext = React.createContext({
|
|
25
25
|
state: 'expanded',
|
|
26
26
|
origin: 'left',
|
|
27
27
|
});
|
|
28
|
-
|
|
28
|
+
const common_1 = require("@workday/canvas-kit-react/common");
|
|
29
29
|
/**
|
|
30
30
|
*
|
|
31
31
|
* This hook manages the state and `aria-` attributes for the SidePanel. It takes an optional
|
|
@@ -41,53 +41,53 @@ var common_1 = require("@workday/canvas-kit-react/common");
|
|
|
41
41
|
* });
|
|
42
42
|
* ```
|
|
43
43
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
const useSidePanel = (config) => {
|
|
45
|
+
const [touched, setTouched] = React.useState(false);
|
|
46
|
+
const configParams = config
|
|
47
47
|
? config
|
|
48
48
|
: {
|
|
49
49
|
initialExpanded: true,
|
|
50
50
|
panelId: undefined,
|
|
51
51
|
labelId: undefined,
|
|
52
52
|
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
const { initialExpanded = true, panelId: panelIdParam, labelId: labelIdParam } = configParams;
|
|
54
|
+
const [expanded, setExpanded] = React.useState(initialExpanded);
|
|
55
|
+
const panelId = common_1.useUniqueId(panelIdParam);
|
|
56
|
+
const labelId = common_1.useUniqueId(labelIdParam);
|
|
57
57
|
// This prevents keyframes animations from rendering prematurely
|
|
58
|
-
|
|
58
|
+
const handleSetTouched = () => {
|
|
59
59
|
if (touched === false) {
|
|
60
60
|
setTouched(true);
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
|
-
|
|
63
|
+
const handleClick = () => {
|
|
64
64
|
handleSetExpanded(!expanded);
|
|
65
65
|
};
|
|
66
|
-
|
|
66
|
+
const handleSetExpanded = (newExpandedState) => {
|
|
67
67
|
handleSetTouched();
|
|
68
68
|
setExpanded(newExpandedState);
|
|
69
69
|
};
|
|
70
|
-
|
|
70
|
+
const panelProps = {
|
|
71
71
|
expanded: expanded,
|
|
72
72
|
id: panelId,
|
|
73
73
|
'aria-labelledby': labelId,
|
|
74
|
-
touched
|
|
74
|
+
touched,
|
|
75
75
|
};
|
|
76
|
-
|
|
76
|
+
const labelProps = {
|
|
77
77
|
id: labelId,
|
|
78
78
|
};
|
|
79
|
-
|
|
79
|
+
const controlProps = {
|
|
80
80
|
'aria-controls': panelId,
|
|
81
81
|
'aria-expanded': expanded,
|
|
82
82
|
'aria-labelledby': labelId,
|
|
83
83
|
onClick: handleClick,
|
|
84
84
|
};
|
|
85
85
|
return {
|
|
86
|
-
expanded
|
|
86
|
+
expanded,
|
|
87
87
|
setExpanded: handleSetExpanded,
|
|
88
|
-
panelProps
|
|
89
|
-
labelProps
|
|
90
|
-
controlProps
|
|
88
|
+
panelProps,
|
|
89
|
+
labelProps,
|
|
90
|
+
controlProps,
|
|
91
91
|
};
|
|
92
92
|
};
|
|
93
93
|
exports.useSidePanel = useSidePanel;
|
|
@@ -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.StatusIndicator = exports.useStatusIndicator = void 0;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
exports.useStatusIndicator = common_1.createElemPropsHook(hooks_1.useStatusIndicatorModel)(
|
|
36
|
-
|
|
37
|
-
var colors = StatusIndicatorIcon_1.statusIndicatorColors[state.variant][state.emphasis];
|
|
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 StatusIndicatorIcon_1 = require("./StatusIndicatorIcon");
|
|
11
|
+
const StatusIndicatorLabel_1 = require("./StatusIndicatorLabel");
|
|
12
|
+
const hooks_1 = require("./hooks");
|
|
13
|
+
exports.useStatusIndicator = common_1.createElemPropsHook(hooks_1.useStatusIndicatorModel)(({ state }) => {
|
|
14
|
+
const colors = StatusIndicatorIcon_1.statusIndicatorColors[state.variant][state.emphasis];
|
|
38
15
|
return {
|
|
39
16
|
opacity: state.variant === 'transparent' ? '0.85' : undefined,
|
|
40
17
|
color: colors.text,
|
|
@@ -75,7 +52,6 @@ exports.StatusIndicator = common_1.createContainer('div')({
|
|
|
75
52
|
*/
|
|
76
53
|
Icon: StatusIndicatorIcon_1.StatusIndicatorIcon,
|
|
77
54
|
},
|
|
78
|
-
})(
|
|
79
|
-
|
|
80
|
-
return (react_1.default.createElement(layout_1.Flex, __assign({ gap: "xxxs", as: Element, maxWidth: 200, paddingX: "xxxs", display: "inline-flex", alignItems: "center", height: 20, borderRadius: "s" }, elemProps), children));
|
|
55
|
+
})(({ children, ...elemProps }, Element, model) => {
|
|
56
|
+
return (react_1.default.createElement(layout_1.Flex, Object.assign({ gap: "xxxs", as: Element, maxWidth: 200, paddingX: "xxxs", display: "inline-flex", alignItems: "center", height: 20, borderRadius: "s" }, elemProps), children));
|
|
81
57
|
});
|
|
@@ -1,25 +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
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.StatusIndicatorIcon = exports.useStatusIndicatorIcon = exports.statusIndicatorColors = void 0;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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 hooks_1 = require("./hooks");
|
|
11
|
+
const tokens_1 = require("@workday/canvas-kit-react/tokens");
|
|
23
12
|
exports.statusIndicatorColors = {
|
|
24
13
|
gray: {
|
|
25
14
|
high: {
|
|
@@ -82,9 +71,8 @@ exports.statusIndicatorColors = {
|
|
|
82
71
|
},
|
|
83
72
|
},
|
|
84
73
|
};
|
|
85
|
-
exports.useStatusIndicatorIcon = common_1.createElemPropsHook(hooks_1.useStatusIndicatorModel)(
|
|
86
|
-
|
|
87
|
-
var colors = exports.statusIndicatorColors[state.variant][state.emphasis];
|
|
74
|
+
exports.useStatusIndicatorIcon = common_1.createElemPropsHook(hooks_1.useStatusIndicatorModel)(({ state }) => {
|
|
75
|
+
const colors = exports.statusIndicatorColors[state.variant][state.emphasis];
|
|
88
76
|
return {
|
|
89
77
|
color: colors.text,
|
|
90
78
|
colorHover: colors.background,
|
|
@@ -93,6 +81,6 @@ exports.useStatusIndicatorIcon = common_1.createElemPropsHook(hooks_1.useStatusI
|
|
|
93
81
|
exports.StatusIndicatorIcon = common_1.createSubcomponent('span')({
|
|
94
82
|
modelHook: hooks_1.useStatusIndicatorModel,
|
|
95
83
|
elemPropsHook: exports.useStatusIndicatorIcon,
|
|
96
|
-
})(
|
|
97
|
-
return react_1.default.createElement(icon_1.SystemIcon,
|
|
84
|
+
})((elemProps, Element, model) => {
|
|
85
|
+
return react_1.default.createElement(icon_1.SystemIcon, Object.assign({ as: Element, size: 20, role: "img" }, elemProps));
|
|
98
86
|
});
|