@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,14 +1,13 @@
|
|
|
1
1
|
// Modified from https://gist.github.com/hsablonniere/2581101
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
var parent = elem.parentElement;
|
|
2
|
+
export const scrollIntoViewIfNeeded = (elem, centerIfNeeded = true) => {
|
|
3
|
+
const parent = elem.parentElement;
|
|
5
4
|
if (elem && parent) {
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
const parentComputedStyle = window.getComputedStyle(parent, null);
|
|
6
|
+
const parentBorderTopWidth = parseInt(parentComputedStyle.getPropertyValue('border-top-width'), 10);
|
|
8
7
|
// Check if elem is out of view at the top edge of the parent's viewport
|
|
9
|
-
|
|
8
|
+
const overTop = elem.offsetTop < parent.scrollTop + parentBorderTopWidth;
|
|
10
9
|
// Check if elem is out of view at the bottom edge of the parent's viewport
|
|
11
|
-
|
|
10
|
+
const overBottom = elem.offsetTop + elem.offsetHeight >
|
|
12
11
|
parent.scrollTop + parentBorderTopWidth + parent.clientHeight;
|
|
13
12
|
if ((overTop || overBottom) && centerIfNeeded) {
|
|
14
13
|
parent.scrollTop = Math.floor(elem.offsetTop - parent.clientHeight / 2 - parentBorderTopWidth + elem.clientHeight / 2);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const getIndexByValue = (options, value) => {
|
|
2
2
|
if (!options || value === undefined) {
|
|
3
3
|
return -1;
|
|
4
4
|
}
|
|
5
|
-
for (
|
|
5
|
+
for (let i = 0; i < options.length; i++) {
|
|
6
6
|
if (options[i].value === value) {
|
|
7
7
|
return i;
|
|
8
8
|
}
|
|
@@ -10,7 +10,7 @@ export var getIndexByValue = function (options, value) {
|
|
|
10
10
|
return -1;
|
|
11
11
|
};
|
|
12
12
|
// If the value doesn't exist in the options, return index 0
|
|
13
|
-
export
|
|
14
|
-
|
|
13
|
+
export const getCorrectedIndexByValue = (options, value) => {
|
|
14
|
+
const indexByValue = getIndexByValue(options, value);
|
|
15
15
|
return indexByValue === -1 ? 0 : indexByValue;
|
|
16
16
|
};
|
|
@@ -1,29 +1,3 @@
|
|
|
1
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
-
return cooked;
|
|
4
|
-
};
|
|
5
|
-
var __assign = (this && this.__assign) || function () {
|
|
6
|
-
__assign = Object.assign || function(t) {
|
|
7
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
-
s = arguments[i];
|
|
9
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
-
t[p] = s[p];
|
|
11
|
-
}
|
|
12
|
-
return t;
|
|
13
|
-
};
|
|
14
|
-
return __assign.apply(this, arguments);
|
|
15
|
-
};
|
|
16
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
17
|
-
var t = {};
|
|
18
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
19
|
-
t[p] = s[p];
|
|
20
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
21
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
22
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
23
|
-
t[p[i]] = s[p[i]];
|
|
24
|
-
}
|
|
25
|
-
return t;
|
|
26
|
-
};
|
|
27
1
|
/** @jsxRuntime classic */
|
|
28
2
|
/** @jsx jsx */
|
|
29
3
|
import * as React from 'react';
|
|
@@ -32,45 +6,57 @@ import { jsx, keyframes } from '@emotion/react';
|
|
|
32
6
|
import { colors, depth } from '@workday/canvas-kit-react/tokens';
|
|
33
7
|
import { SidePanelContext } from './hooks';
|
|
34
8
|
import { SidePanelToggleButton } from './SidePanelToggleButton';
|
|
35
|
-
|
|
36
|
-
|
|
9
|
+
const createKeyframes = (from, to) => {
|
|
10
|
+
const normalized = {
|
|
37
11
|
from: typeof from === 'number' ? from + 'px' : from,
|
|
38
12
|
to: typeof to === 'number' ? to + 'px' : to,
|
|
39
13
|
};
|
|
40
|
-
return keyframes
|
|
14
|
+
return keyframes `
|
|
15
|
+
from {
|
|
16
|
+
width: ${normalized.from};
|
|
17
|
+
min-width: ${normalized.from};
|
|
18
|
+
max-width: ${normalized.from};
|
|
19
|
+
} to {
|
|
20
|
+
width: ${normalized.to};
|
|
21
|
+
min-width: ${normalized.to};
|
|
22
|
+
max-width: ${normalized.to};
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
41
25
|
};
|
|
42
|
-
|
|
43
|
-
alternate:
|
|
26
|
+
const containerVariantStyle = {
|
|
27
|
+
alternate: {
|
|
28
|
+
backgroundColor: colors.frenchVanilla100,
|
|
29
|
+
...depth[5],
|
|
30
|
+
},
|
|
44
31
|
standard: {
|
|
45
32
|
backgroundColor: colors.soap100,
|
|
46
33
|
},
|
|
47
34
|
};
|
|
48
|
-
|
|
35
|
+
const Panel = styled('section')({
|
|
49
36
|
overflow: 'hidden',
|
|
50
37
|
position: 'relative',
|
|
51
38
|
boxSizing: 'border-box',
|
|
52
39
|
height: '100%',
|
|
53
40
|
});
|
|
54
|
-
export
|
|
41
|
+
export const SidePanel = createComponent('section')({
|
|
55
42
|
displayName: 'SidePanel',
|
|
56
|
-
Component
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
React.useEffect(function () {
|
|
43
|
+
Component({ children, collapsedWidth = 64, expanded = true, expandedWidth = 320, onAnimationEnd, onAnimationStart, onExpandedChange, onStateTransition, origin = 'left', variant = 'standard', touched, ...elemProps }, ref, Element) {
|
|
44
|
+
const [state, setState] = React.useState(expanded ? 'expanded' : 'collapsed');
|
|
45
|
+
React.useEffect(() => {
|
|
60
46
|
if (typeof onExpandedChange !== 'undefined') {
|
|
61
47
|
onExpandedChange(expanded);
|
|
62
48
|
}
|
|
63
49
|
}, [expanded, onExpandedChange]);
|
|
64
|
-
React.useEffect(
|
|
50
|
+
React.useEffect(() => {
|
|
65
51
|
if (typeof onStateTransition !== 'undefined') {
|
|
66
52
|
onStateTransition(state);
|
|
67
53
|
}
|
|
68
54
|
}, [state, onStateTransition]);
|
|
69
|
-
|
|
55
|
+
const motion = {
|
|
70
56
|
collapse: createKeyframes(expandedWidth, collapsedWidth),
|
|
71
57
|
expand: createKeyframes(collapsedWidth, expandedWidth),
|
|
72
58
|
};
|
|
73
|
-
|
|
59
|
+
const handleAnimationEnd = (event) => {
|
|
74
60
|
if (event.currentTarget === event.target) {
|
|
75
61
|
if (event.animationName === motion.collapse.name) {
|
|
76
62
|
setState('collapsed');
|
|
@@ -83,7 +69,7 @@ export var SidePanel = createComponent('section')({
|
|
|
83
69
|
onAnimationEnd(event);
|
|
84
70
|
}
|
|
85
71
|
};
|
|
86
|
-
|
|
72
|
+
const handleAnimationStart = (event) => {
|
|
87
73
|
if (event.currentTarget === event.target) {
|
|
88
74
|
if (event.animationName === motion.collapse.name ||
|
|
89
75
|
event.animationName === motion.expand.name) {
|
|
@@ -94,21 +80,21 @@ export var SidePanel = createComponent('section')({
|
|
|
94
80
|
onAnimationStart(event);
|
|
95
81
|
}
|
|
96
82
|
};
|
|
97
|
-
return (jsx(Panel,
|
|
83
|
+
return (jsx(Panel, Object.assign({ ref: ref, as: Element, css: [
|
|
98
84
|
{
|
|
99
85
|
width: expanded ? expandedWidth : collapsedWidth,
|
|
100
86
|
maxWidth: expanded ? expandedWidth : collapsedWidth,
|
|
101
87
|
// mounted.current will be false on the first render, thus you won't get an unwanted animation here
|
|
102
88
|
// Will animate again if you force a re-render (like in Storybook)
|
|
103
89
|
animation: touched
|
|
104
|
-
?
|
|
90
|
+
? `${expanded ? motion.expand : motion.collapse} 200ms ease-out`
|
|
105
91
|
: undefined,
|
|
106
92
|
},
|
|
107
93
|
containerVariantStyle[variant],
|
|
108
94
|
], onAnimationEnd: handleAnimationEnd, onAnimationStart: handleAnimationStart }, elemProps),
|
|
109
95
|
jsx(SidePanelContext.Provider, { value: {
|
|
110
|
-
state
|
|
111
|
-
origin
|
|
96
|
+
state,
|
|
97
|
+
origin,
|
|
112
98
|
} }, children)));
|
|
113
99
|
},
|
|
114
100
|
subComponents: {
|
|
@@ -124,4 +110,3 @@ export var SidePanel = createComponent('section')({
|
|
|
124
110
|
ToggleButton: SidePanelToggleButton,
|
|
125
111
|
},
|
|
126
112
|
});
|
|
127
|
-
var templateObject_1;
|
|
@@ -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
|
/** @jsxRuntime classic */
|
|
24
2
|
/** @jsx jsx */
|
|
25
3
|
import * as React from 'react';
|
|
@@ -33,13 +11,12 @@ import { SidePanelContext } from './hooks';
|
|
|
33
11
|
/**
|
|
34
12
|
* A toggle button styled specifically for the side panel container.
|
|
35
13
|
*/
|
|
36
|
-
export
|
|
14
|
+
export const SidePanelToggleButton = createComponent('button')({
|
|
37
15
|
displayName: 'SidePanel.ToggleButton',
|
|
38
|
-
Component
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
var isRTL = useIsRTL();
|
|
16
|
+
Component({ variant = undefined, icon = transformationImportIcon, tooltipTextExpand = 'Expand', tooltipTextCollapse = 'Collapse', ...elemProps }) {
|
|
17
|
+
const context = React.useContext(SidePanelContext);
|
|
18
|
+
const useRTLOrigin = () => {
|
|
19
|
+
const isRTL = useIsRTL();
|
|
43
20
|
// if the direction is set to RTl, flip the origin
|
|
44
21
|
if (isRTL) {
|
|
45
22
|
return context.origin === 'left' ? 'right' : 'left';
|
|
@@ -47,9 +24,9 @@ export var SidePanelToggleButton = createComponent('button')({
|
|
|
47
24
|
// Otherwise, default to returning the origin
|
|
48
25
|
return context.origin;
|
|
49
26
|
};
|
|
50
|
-
|
|
27
|
+
const rtlOrigin = useRTLOrigin();
|
|
51
28
|
// Note: Depending on the collapsed width, the button could "jump" to it's final position.
|
|
52
|
-
|
|
29
|
+
const buttonStyle = css({
|
|
53
30
|
position: 'absolute',
|
|
54
31
|
top: space.m,
|
|
55
32
|
width: space.l,
|
|
@@ -57,10 +34,10 @@ export var SidePanelToggleButton = createComponent('button')({
|
|
|
57
34
|
left: context.state === 'collapsed' ? 0 : rtlOrigin === 'right' ? space.s : undefined,
|
|
58
35
|
margin: context.state === 'collapsed' ? 'auto' : 0,
|
|
59
36
|
transform: context.state === 'collapsed' || context.state === 'collapsing'
|
|
60
|
-
?
|
|
61
|
-
:
|
|
37
|
+
? `scaleX(${rtlOrigin === 'left' ? '1' : '-1'})`
|
|
38
|
+
: `scaleX(${rtlOrigin === 'left' ? '-1' : '1'})`,
|
|
62
39
|
});
|
|
63
40
|
return (jsx(Tooltip, { title: context.state === 'collapsed' ? tooltipTextExpand : tooltipTextCollapse, type: "muted" },
|
|
64
|
-
jsx(TertiaryButton,
|
|
41
|
+
jsx(TertiaryButton, Object.assign({ type: "button", css: buttonStyle, icon: icon, variant: variant }, elemProps))));
|
|
65
42
|
},
|
|
66
43
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
export
|
|
2
|
+
export const SidePanelContext = React.createContext({
|
|
3
3
|
state: 'expanded',
|
|
4
4
|
origin: 'left',
|
|
5
5
|
});
|
|
@@ -19,52 +19,52 @@ import { useUniqueId } from '@workday/canvas-kit-react/common';
|
|
|
19
19
|
* });
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
export const useSidePanel = (config) => {
|
|
23
|
+
const [touched, setTouched] = React.useState(false);
|
|
24
|
+
const configParams = config
|
|
25
25
|
? config
|
|
26
26
|
: {
|
|
27
27
|
initialExpanded: true,
|
|
28
28
|
panelId: undefined,
|
|
29
29
|
labelId: undefined,
|
|
30
30
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
const { initialExpanded = true, panelId: panelIdParam, labelId: labelIdParam } = configParams;
|
|
32
|
+
const [expanded, setExpanded] = React.useState(initialExpanded);
|
|
33
|
+
const panelId = useUniqueId(panelIdParam);
|
|
34
|
+
const labelId = useUniqueId(labelIdParam);
|
|
35
35
|
// This prevents keyframes animations from rendering prematurely
|
|
36
|
-
|
|
36
|
+
const handleSetTouched = () => {
|
|
37
37
|
if (touched === false) {
|
|
38
38
|
setTouched(true);
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
|
-
|
|
41
|
+
const handleClick = () => {
|
|
42
42
|
handleSetExpanded(!expanded);
|
|
43
43
|
};
|
|
44
|
-
|
|
44
|
+
const handleSetExpanded = (newExpandedState) => {
|
|
45
45
|
handleSetTouched();
|
|
46
46
|
setExpanded(newExpandedState);
|
|
47
47
|
};
|
|
48
|
-
|
|
48
|
+
const panelProps = {
|
|
49
49
|
expanded: expanded,
|
|
50
50
|
id: panelId,
|
|
51
51
|
'aria-labelledby': labelId,
|
|
52
|
-
touched
|
|
52
|
+
touched,
|
|
53
53
|
};
|
|
54
|
-
|
|
54
|
+
const labelProps = {
|
|
55
55
|
id: labelId,
|
|
56
56
|
};
|
|
57
|
-
|
|
57
|
+
const controlProps = {
|
|
58
58
|
'aria-controls': panelId,
|
|
59
59
|
'aria-expanded': expanded,
|
|
60
60
|
'aria-labelledby': labelId,
|
|
61
61
|
onClick: handleClick,
|
|
62
62
|
};
|
|
63
63
|
return {
|
|
64
|
-
expanded
|
|
64
|
+
expanded,
|
|
65
65
|
setExpanded: handleSetExpanded,
|
|
66
|
-
panelProps
|
|
67
|
-
labelProps
|
|
68
|
-
controlProps
|
|
66
|
+
panelProps,
|
|
67
|
+
labelProps,
|
|
68
|
+
controlProps,
|
|
69
69
|
};
|
|
70
70
|
};
|
|
@@ -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 { createContainer, createElemPropsHook } from '@workday/canvas-kit-react/common';
|
|
25
3
|
import { Flex } from '@workday/canvas-kit-react/layout';
|
|
26
4
|
import { StatusIndicatorIcon, statusIndicatorColors } from './StatusIndicatorIcon';
|
|
27
5
|
import { StatusIndicatorLabel } from './StatusIndicatorLabel';
|
|
28
6
|
import { useStatusIndicatorModel } from './hooks';
|
|
29
|
-
export
|
|
30
|
-
|
|
31
|
-
var colors = statusIndicatorColors[state.variant][state.emphasis];
|
|
7
|
+
export const useStatusIndicator = createElemPropsHook(useStatusIndicatorModel)(({ state }) => {
|
|
8
|
+
const colors = statusIndicatorColors[state.variant][state.emphasis];
|
|
32
9
|
return {
|
|
33
10
|
opacity: state.variant === 'transparent' ? '0.85' : undefined,
|
|
34
11
|
color: colors.text,
|
|
@@ -45,7 +22,7 @@ export var useStatusIndicator = createElemPropsHook(useStatusIndicatorModel)(fun
|
|
|
45
22
|
* </StatusIndicator>
|
|
46
23
|
* ```
|
|
47
24
|
*/
|
|
48
|
-
export
|
|
25
|
+
export const StatusIndicator = createContainer('div')({
|
|
49
26
|
displayName: 'StatusIndicator',
|
|
50
27
|
modelHook: useStatusIndicatorModel,
|
|
51
28
|
elemPropsHook: useStatusIndicator,
|
|
@@ -69,7 +46,6 @@ export var StatusIndicator = createContainer('div')({
|
|
|
69
46
|
*/
|
|
70
47
|
Icon: StatusIndicatorIcon,
|
|
71
48
|
},
|
|
72
|
-
})(
|
|
73
|
-
|
|
74
|
-
return (React.createElement(Flex, __assign({ gap: "xxxs", as: Element, maxWidth: 200, paddingX: "xxxs", display: "inline-flex", alignItems: "center", height: 20, borderRadius: "s" }, elemProps), children));
|
|
49
|
+
})(({ children, ...elemProps }, Element, model) => {
|
|
50
|
+
return (React.createElement(Flex, Object.assign({ gap: "xxxs", as: Element, maxWidth: 200, paddingX: "xxxs", display: "inline-flex", alignItems: "center", height: 20, borderRadius: "s" }, elemProps), children));
|
|
75
51
|
});
|
|
@@ -1,20 +1,9 @@
|
|
|
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 { createElemPropsHook, createSubcomponent } from '@workday/canvas-kit-react/common';
|
|
14
3
|
import { SystemIcon } from '@workday/canvas-kit-react/icon';
|
|
15
4
|
import { useStatusIndicatorModel } from './hooks';
|
|
16
5
|
import { colors } from '@workday/canvas-kit-react/tokens';
|
|
17
|
-
export
|
|
6
|
+
export const statusIndicatorColors = {
|
|
18
7
|
gray: {
|
|
19
8
|
high: {
|
|
20
9
|
text: colors.frenchVanilla100,
|
|
@@ -76,17 +65,16 @@ export var statusIndicatorColors = {
|
|
|
76
65
|
},
|
|
77
66
|
},
|
|
78
67
|
};
|
|
79
|
-
export
|
|
80
|
-
|
|
81
|
-
var colors = statusIndicatorColors[state.variant][state.emphasis];
|
|
68
|
+
export const useStatusIndicatorIcon = createElemPropsHook(useStatusIndicatorModel)(({ state }) => {
|
|
69
|
+
const colors = statusIndicatorColors[state.variant][state.emphasis];
|
|
82
70
|
return {
|
|
83
71
|
color: colors.text,
|
|
84
72
|
colorHover: colors.background,
|
|
85
73
|
};
|
|
86
74
|
});
|
|
87
|
-
export
|
|
75
|
+
export const StatusIndicatorIcon = createSubcomponent('span')({
|
|
88
76
|
modelHook: useStatusIndicatorModel,
|
|
89
77
|
elemPropsHook: useStatusIndicatorIcon,
|
|
90
|
-
})(
|
|
91
|
-
return React.createElement(SystemIcon,
|
|
78
|
+
})((elemProps, Element, model) => {
|
|
79
|
+
return React.createElement(SystemIcon, Object.assign({ as: Element, size: 20, role: "img" }, elemProps));
|
|
92
80
|
});
|
|
@@ -1,32 +1,9 @@
|
|
|
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 } from '@workday/canvas-kit-react/common';
|
|
25
3
|
import { Text } from '@workday/canvas-kit-react/text';
|
|
26
|
-
export
|
|
4
|
+
export const StatusIndicatorLabel = createComponent('span')({
|
|
27
5
|
displayName: 'StatusIndicator.Label',
|
|
28
|
-
Component:
|
|
29
|
-
|
|
30
|
-
return (React.createElement(Text, __assign({ whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis", typeLevel: "subtext.large", fontWeight: "bold", textTransform: "capitalize", ref: ref, color: "inherit", as: Element }, elemProps), children));
|
|
6
|
+
Component: ({ children, ...elemProps }, ref, Element) => {
|
|
7
|
+
return (React.createElement(Text, Object.assign({ whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis", typeLevel: "subtext.large", fontWeight: "bold", textTransform: "capitalize", ref: ref, color: "inherit", as: Element }, elemProps), children));
|
|
31
8
|
},
|
|
32
9
|
});
|
|
@@ -1,16 +1,5 @@
|
|
|
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 { createModelHook } from '@workday/canvas-kit-react/common';
|
|
13
|
-
export
|
|
2
|
+
export const useStatusIndicatorModel = createModelHook({
|
|
14
3
|
defaultConfig: {
|
|
15
4
|
/**
|
|
16
5
|
* Defines the emphasis of the `StatusIndicator`.
|
|
@@ -25,7 +14,9 @@ export var useStatusIndicatorModel = createModelHook({
|
|
|
25
14
|
*/
|
|
26
15
|
variant: 'gray',
|
|
27
16
|
},
|
|
28
|
-
})(
|
|
29
|
-
|
|
30
|
-
|
|
17
|
+
})(config => {
|
|
18
|
+
const state = {
|
|
19
|
+
...config,
|
|
20
|
+
};
|
|
21
|
+
return { state, events: {} };
|
|
31
22
|
});
|
|
@@ -1,31 +1,9 @@
|
|
|
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 { createContainer } from '@workday/canvas-kit-react/common';
|
|
25
3
|
import { FormField, useFormFieldModel, useFormFieldOrientation, } from '@workday/canvas-kit-preview-react/form-field';
|
|
26
4
|
import { Flex } from '@workday/canvas-kit-react/layout';
|
|
27
5
|
import { TextAreaField } from './TextAreaField';
|
|
28
|
-
export
|
|
6
|
+
export const TextArea = createContainer('div')({
|
|
29
7
|
displayName: 'TextArea',
|
|
30
8
|
modelHook: useFormFieldModel,
|
|
31
9
|
subComponents: {
|
|
@@ -33,8 +11,7 @@ export var TextArea = createContainer('div')({
|
|
|
33
11
|
Label: FormField.Label,
|
|
34
12
|
Hint: FormField.Hint,
|
|
35
13
|
},
|
|
36
|
-
})(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return (React.createElement(Flex, __assign({ as: Element }, layoutProps, elemProps), children));
|
|
14
|
+
})(({ children, orientation, ...elemProps }, Element) => {
|
|
15
|
+
const layoutProps = useFormFieldOrientation(orientation);
|
|
16
|
+
return (React.createElement(Flex, Object.assign({ as: Element }, layoutProps, elemProps), children));
|
|
40
17
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextAreaField.d.ts","sourceRoot":"","sources":["../../../../text-area/lib/TextAreaField.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TextAreaField.d.ts","sourceRoot":"","sources":["../../../../text-area/lib/TextAreaField.tsx"],"names":[],"mappings":"AA6CA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;EAgCxB,CAAC"}
|
|
@@ -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
|
/** @jsxRuntime classic */
|
|
24
2
|
/** @jsx jsx */
|
|
25
3
|
import { jsx } from '@emotion/react';
|
|
26
4
|
import { borderRadius, inputColors, spaceNumbers, type, } from '@workday/canvas-kit-react/tokens';
|
|
27
|
-
import { createSubcomponent, useTheme } from '@workday/canvas-kit-react/common';
|
|
28
|
-
import { useThemedRing } from '@workday/canvas-kit-labs-react/common';
|
|
5
|
+
import { createSubcomponent, useTheme, useThemedRing, } from '@workday/canvas-kit-react/common';
|
|
29
6
|
import { FormField } from '@workday/canvas-kit-preview-react/form-field';
|
|
30
7
|
import { useTextInputModel } from '@workday/canvas-kit-preview-react/text-input';
|
|
31
|
-
|
|
8
|
+
const baseStyles = {
|
|
32
9
|
transition: '0.2s box-shadow, 0.2s border-color',
|
|
33
10
|
resize: 'both',
|
|
34
11
|
'&::webkit-resizer': {
|
|
@@ -52,20 +29,19 @@ var baseStyles = {
|
|
|
52
29
|
},
|
|
53
30
|
},
|
|
54
31
|
};
|
|
55
|
-
export
|
|
32
|
+
export const TextAreaField = createSubcomponent('textarea')({
|
|
56
33
|
displayName: 'TextArea.Field',
|
|
57
34
|
modelHook: useTextInputModel,
|
|
58
|
-
})(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
var focusStyles = model.state.hasError
|
|
35
|
+
})(({ ...elemProps }, Element, model) => {
|
|
36
|
+
const theme = useTheme();
|
|
37
|
+
const errorRing = useThemedRing('error');
|
|
38
|
+
const focusStyles = model.state.hasError
|
|
63
39
|
? errorRing
|
|
64
40
|
: {
|
|
65
41
|
'&:focus:not([disabled])': {
|
|
66
42
|
borderColor: theme.canvas.palette.common.focusOutline,
|
|
67
|
-
boxShadow:
|
|
43
|
+
boxShadow: `inset 0 0 0 1px ${theme.canvas.palette.common.focusOutline}`,
|
|
68
44
|
},
|
|
69
45
|
};
|
|
70
|
-
return (jsx(FormField.Input,
|
|
46
|
+
return (jsx(FormField.Input, Object.assign({ as: Element }, type.levels.subtext.large, { css: [baseStyles, focusStyles] }, elemProps, { border: `1px solid ${inputColors.border}`, display: "block", backgroundColor: inputColors.background, borderRadius: borderRadius.m, minHeight: 64, minWidth: 280, padding: spaceNumbers.xxs, margin: 0 })));
|
|
71
47
|
});
|