@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,39 +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.PillIconButton = void 0;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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");
|
|
13
|
+
const button_1 = require("@workday/canvas-kit-react/button");
|
|
14
|
+
const getIconColors = () => {
|
|
37
15
|
return {
|
|
38
16
|
default: {
|
|
39
17
|
icon: tokens_1.colors.licorice200,
|
|
@@ -56,9 +34,9 @@ var getIconColors = function () {
|
|
|
56
34
|
},
|
|
57
35
|
};
|
|
58
36
|
};
|
|
59
|
-
|
|
37
|
+
const StyledIconButton = common_1.styled(button_1.BaseButton)({
|
|
60
38
|
marginInlineEnd: '-7px',
|
|
61
|
-
marginInlineStart:
|
|
39
|
+
marginInlineStart: `-2px`,
|
|
62
40
|
overflow: 'visible',
|
|
63
41
|
'::after': {
|
|
64
42
|
content: '""',
|
|
@@ -74,8 +52,7 @@ var StyledIconButton = common_1.styled(button_1.BaseButton)({
|
|
|
74
52
|
});
|
|
75
53
|
exports.PillIconButton = common_1.createSubcomponent('button')({
|
|
76
54
|
modelHook: usePillModel_1.usePillModel,
|
|
77
|
-
})(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
react_1.default.createElement(icon_1.SystemIcon, { "aria-label": ariaLabel, id: "removable-" + model.state.id, icon: icon, size: tokens_1.space.m, "aria-hidden": true, role: "img" })));
|
|
55
|
+
})(({ size, icon = canvas_system_icons_web_1.xSmallIcon, maxWidth, children, 'aria-label': ariaLabel = 'remove', ...elemProps }, Element, model) => {
|
|
56
|
+
return (react_1.default.createElement(StyledIconButton, Object.assign({ borderRadius: "s", height: 20, width: 20, padding: "zero", disabled: model.state.disabled, colors: getIconColors(), "aria-labelledby": `removable-${model.state.id} label-${model.state.id}`, as: Element, position: "relative" }, elemProps),
|
|
57
|
+
react_1.default.createElement(icon_1.SystemIcon, { "aria-label": ariaLabel, id: `removable-${model.state.id}`, icon: icon, size: tokens_1.space.m, "aria-hidden": true, role: "img" })));
|
|
81
58
|
});
|
|
@@ -1,38 +1,16 @@
|
|
|
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.PillLabel = void 0;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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 tooltip_1 = require("@workday/canvas-kit-react/tooltip");
|
|
11
|
+
const usePillModel_1 = require("./usePillModel");
|
|
12
|
+
const tokens_1 = require("@workday/canvas-kit-react/tokens");
|
|
13
|
+
const StyledLabelContainer = common_1.styled(layout_1.Box.as('span'))({
|
|
36
14
|
whiteSpace: 'nowrap',
|
|
37
15
|
overflow: 'hidden',
|
|
38
16
|
textOverflow: 'ellipsis',
|
|
@@ -40,8 +18,7 @@ var StyledLabelContainer = common_1.styled(layout_1.Box.as('span'))({
|
|
|
40
18
|
});
|
|
41
19
|
exports.PillLabel = common_1.createSubcomponent('span')({
|
|
42
20
|
modelHook: usePillModel_1.usePillModel,
|
|
43
|
-
})(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
react_1.default.createElement(StyledLabelContainer, __assign({ color: model.state.disabled ? tokens_1.colors.licorice100 : 'inherit', maxWidth: model.state.maxWidth, as: Element, id: "label-" + model.state.id }, elemProps), elemProps.children)));
|
|
21
|
+
})(({ tooltipProps, ...elemProps }, Element, model) => {
|
|
22
|
+
return (react_1.default.createElement(tooltip_1.OverflowTooltip, Object.assign({}, tooltipProps),
|
|
23
|
+
react_1.default.createElement(StyledLabelContainer, Object.assign({ color: model.state.disabled ? tokens_1.colors.licorice100 : 'inherit', maxWidth: model.state.maxWidth, as: Element, id: `label-${model.state.id}` }, elemProps), elemProps.children)));
|
|
47
24
|
});
|
|
@@ -1,18 +1,7 @@
|
|
|
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
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
3
|
exports.usePillModel = void 0;
|
|
15
|
-
|
|
4
|
+
const common_1 = require("@workday/canvas-kit-react/common");
|
|
16
5
|
exports.usePillModel = common_1.createModelHook({
|
|
17
6
|
defaultConfig: {
|
|
18
7
|
/**
|
|
@@ -30,8 +19,11 @@ exports.usePillModel = common_1.createModelHook({
|
|
|
30
19
|
*/
|
|
31
20
|
id: '',
|
|
32
21
|
},
|
|
33
|
-
})(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
22
|
+
})(config => {
|
|
23
|
+
const id = common_1.useUniqueId(config.id);
|
|
24
|
+
const state = {
|
|
25
|
+
...config,
|
|
26
|
+
id,
|
|
27
|
+
};
|
|
28
|
+
return { state, events: {} };
|
|
37
29
|
});
|
|
@@ -4,11 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.SegmentedControl = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const common_1 = require("@workday/canvas-kit-react/common");
|
|
9
|
+
const useSegmentedControlModel_1 = require("./hooks/useSegmentedControlModel");
|
|
10
|
+
const SegmentedControlList_1 = require("./SegmentedControlList");
|
|
11
|
+
const SegmentedControlItem_1 = require("./SegmentedControlItem");
|
|
12
12
|
/**
|
|
13
13
|
* `SegmentedControl` is a container component that is responsible for creating a
|
|
14
14
|
* {@link SegmentedControlModel} and sharing it with its subcomponents using React context. It does
|
|
@@ -52,7 +52,6 @@ exports.SegmentedControl = common_1.createContainer()({
|
|
|
52
52
|
*/
|
|
53
53
|
Item: SegmentedControlItem_1.SegmentedControlItem,
|
|
54
54
|
},
|
|
55
|
-
})(
|
|
56
|
-
var children = _a.children;
|
|
55
|
+
})(({ children }) => {
|
|
57
56
|
return react_1.default.createElement(react_1.default.Fragment, null, children);
|
|
58
57
|
});
|
|
@@ -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,28 +18,17 @@ 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.SegmentedControlItem = void 0;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
23
|
+
const React = __importStar(require("react"));
|
|
24
|
+
const tokens_1 = require("@workday/canvas-kit-react/tokens");
|
|
25
|
+
const common_1 = require("@workday/canvas-kit-react/common");
|
|
26
|
+
const tooltip_1 = require("@workday/canvas-kit-react/tooltip");
|
|
27
|
+
const button_1 = require("@workday/canvas-kit-react/button");
|
|
28
|
+
const useSegmentedControlModel_1 = require("./hooks/useSegmentedControlModel");
|
|
29
|
+
const text_1 = require("@workday/canvas-kit-react/text");
|
|
30
|
+
const useSegmentedControlItem_1 = require("./hooks/useSegmentedControlItem");
|
|
31
|
+
const getButtonSize = (size) => {
|
|
54
32
|
switch (size) {
|
|
55
33
|
case 'large':
|
|
56
34
|
return 'medium';
|
|
@@ -62,7 +40,7 @@ var getButtonSize = function (size) {
|
|
|
62
40
|
return 'medium';
|
|
63
41
|
}
|
|
64
42
|
};
|
|
65
|
-
|
|
43
|
+
const getIconButtonColors = (toggled) => {
|
|
66
44
|
return {
|
|
67
45
|
default: {
|
|
68
46
|
background: toggled ? tokens_1.colors.frenchVanilla100 : tokens_1.colors.soap200,
|
|
@@ -87,44 +65,41 @@ var getIconButtonColors = function (toggled) {
|
|
|
87
65
|
},
|
|
88
66
|
};
|
|
89
67
|
};
|
|
90
|
-
|
|
68
|
+
const getPaddingStyles = (children, size, icon) => {
|
|
91
69
|
if (!children) {
|
|
92
70
|
return 0;
|
|
93
71
|
}
|
|
94
72
|
switch (size) {
|
|
95
73
|
case 'large':
|
|
96
|
-
return icon ?
|
|
74
|
+
return icon ? `0 ${tokens_1.space.m} 0 20px` : `0 ${tokens_1.space.m}`;
|
|
97
75
|
case 'medium':
|
|
98
|
-
return icon ?
|
|
76
|
+
return icon ? `0 20px 0 ${tokens_1.space.s}` : `0 ${tokens_1.space.s}`;
|
|
99
77
|
case 'small':
|
|
100
|
-
return icon ?
|
|
78
|
+
return icon ? `0 ${tokens_1.space.xs} 0 ${tokens_1.space.xxs}` : `0 ${tokens_1.space.xs}`;
|
|
101
79
|
default:
|
|
102
|
-
return icon ?
|
|
80
|
+
return icon ? `0 20px 0 ${tokens_1.space.s}` : `0 ${tokens_1.space.s}`;
|
|
103
81
|
}
|
|
104
82
|
};
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
83
|
+
const geButtonStyles = (size, children, icon) => {
|
|
84
|
+
const buttonSize = getButtonSize(size);
|
|
85
|
+
const minWidthValue = button_1.getMinWidthStyles(children, children ? size : buttonSize);
|
|
108
86
|
return {
|
|
109
87
|
height: button_1.getMinWidthStyles(false, buttonSize),
|
|
110
88
|
minWidth: minWidthValue,
|
|
111
89
|
padding: getPaddingStyles(children, size, icon),
|
|
112
90
|
};
|
|
113
91
|
};
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
return tooltipProps ? (React.createElement(tooltip_1.Tooltip, __assign({}, tooltipProps), children)) : (React.createElement(React.Fragment, null, children));
|
|
92
|
+
const Container = ({ tooltipProps, children, }) => {
|
|
93
|
+
return tooltipProps ? (React.createElement(tooltip_1.Tooltip, Object.assign({}, tooltipProps), children)) : (React.createElement(React.Fragment, null, children));
|
|
117
94
|
};
|
|
118
95
|
exports.SegmentedControlItem = common_1.createSubcomponent('button')({
|
|
119
96
|
displayName: 'SegmentedControl.Item',
|
|
120
97
|
modelHook: useSegmentedControlModel_1.useSegmentedControlModel,
|
|
121
98
|
elemPropsHook: useSegmentedControlItem_1.useSegmentedControlItem,
|
|
122
|
-
})(
|
|
123
|
-
|
|
124
|
-
var children = _a.children, icon = _a.icon, tooltipProps = _a.tooltipProps, elemProps = __rest(_a, ["children", "icon", "tooltipProps"]);
|
|
125
|
-
var _c = tokens_1.type.levels.subtext[size === 'small' ? 'medium' : 'large'], color = _c.color, textStyles = __rest(_c, ["color"]);
|
|
99
|
+
})(({ children, icon, tooltipProps, ...elemProps }, Element, { state: { size } }) => {
|
|
100
|
+
const { color, ...textStyles } = tokens_1.type.levels.subtext[size === 'small' ? 'medium' : 'large'];
|
|
126
101
|
return (React.createElement(Container, { tooltipProps: tooltipProps },
|
|
127
|
-
React.createElement(button_1.BaseButton,
|
|
102
|
+
React.createElement(button_1.BaseButton, Object.assign({ as: Element, borderRadius: "m", colors: getIconButtonColors(elemProps['aria-pressed']) }, geButtonStyles(size, children, icon), elemProps),
|
|
128
103
|
icon && (React.createElement(button_1.BaseButton.Icon, { size: size === 'small' ? 'extraSmall' : 'medium', icon: icon, shouldMirrorIcon: common_1.useIsRTL() })),
|
|
129
|
-
children && (React.createElement(text_1.Text,
|
|
104
|
+
children && (React.createElement(text_1.Text, Object.assign({}, textStyles, { fontWeight: "bold", textAlign: "left" }), children)))));
|
|
130
105
|
});
|
|
@@ -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,38 +18,24 @@ 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.SegmentedControlList = exports.useSegmentedControlList = void 0;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
exports.useSegmentedControlList = common_1.createElemPropsHook(useSegmentedControlModel_1.useSegmentedControlModel)(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
_b.opacity = disabled ? 0.4 : undefined,
|
|
57
|
-
_b;
|
|
23
|
+
const React = __importStar(require("react"));
|
|
24
|
+
const common_1 = require("@workday/canvas-kit-react/common");
|
|
25
|
+
const layout_1 = require("@workday/canvas-kit-react/layout");
|
|
26
|
+
const collection_1 = require("@workday/canvas-kit-react/collection");
|
|
27
|
+
const useSegmentedControlModel_1 = require("./hooks/useSegmentedControlModel");
|
|
28
|
+
exports.useSegmentedControlList = common_1.createElemPropsHook(useSegmentedControlModel_1.useSegmentedControlModel)(({ state: { orientation, disabled, items } }) => {
|
|
29
|
+
const directionName = orientation === 'vertical' ? 'Row' : 'Column';
|
|
30
|
+
return {
|
|
31
|
+
[`gridTemplate${directionName}s`]: `repeat(${items.length}, 1fr)`,
|
|
32
|
+
opacity: disabled ? 0.4 : undefined,
|
|
33
|
+
};
|
|
58
34
|
});
|
|
59
35
|
exports.SegmentedControlList = common_1.createSubcomponent('div')({
|
|
60
36
|
displayName: 'SegmentedControl.List',
|
|
61
37
|
modelHook: useSegmentedControlModel_1.useSegmentedControlModel,
|
|
62
38
|
elemPropsHook: exports.useSegmentedControlList,
|
|
63
|
-
})(
|
|
64
|
-
|
|
65
|
-
return (React.createElement(layout_1.Grid, __assign({ as: Element, display: "inline-grid", role: "group", backgroundColor: "soap200", border: "1px solid transparent", borderColor: "licorice200", borderRadius: "l", padding: "3px", gridGap: "xxs" }, elemProps), collection_1.useListRenderItems(model, children)));
|
|
39
|
+
})(({ children, ...elemProps }, Element, model) => {
|
|
40
|
+
return (React.createElement(layout_1.Grid, Object.assign({ as: Element, display: "inline-grid", role: "group", backgroundColor: "soap200", border: "1px solid transparent", borderColor: "licorice200", borderRadius: "l", padding: "3px", gridGap: "xxs" }, elemProps), collection_1.useListRenderItems(model, children)));
|
|
66
41
|
});
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useSegmentedControlItem = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
exports.useSegmentedControlItem = common_1.composeHooks(collection_1.useListItemSelect, common_1.createElemPropsHook(useSegmentedControlModel_1.useSegmentedControlModel)(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var selected = !!name && collection_1.isSelected(name, model.state);
|
|
4
|
+
const common_1 = require("@workday/canvas-kit-react/common");
|
|
5
|
+
const collection_1 = require("@workday/canvas-kit-react/collection");
|
|
6
|
+
const useSegmentedControlModel_1 = require("./useSegmentedControlModel");
|
|
7
|
+
exports.useSegmentedControlItem = common_1.composeHooks(collection_1.useListItemSelect, common_1.createElemPropsHook(useSegmentedControlModel_1.useSegmentedControlModel)((model, _, elemProps = {}) => {
|
|
8
|
+
const name = elemProps['data-id'] || '';
|
|
9
|
+
const selected = !!name && collection_1.isSelected(name, model.state);
|
|
11
10
|
return {
|
|
12
|
-
id: model.state.id
|
|
11
|
+
id: `${model.state.id}-${name}`,
|
|
13
12
|
'aria-pressed': selected,
|
|
14
13
|
};
|
|
15
|
-
}), collection_1.useListItemRegister, common_1.createElemPropsHook(useSegmentedControlModel_1.useSegmentedControlModel)(
|
|
16
|
-
var state = _a.state;
|
|
14
|
+
}), collection_1.useListItemRegister, common_1.createElemPropsHook(useSegmentedControlModel_1.useSegmentedControlModel)(({ state }) => {
|
|
17
15
|
return {
|
|
18
16
|
// override the default disabled functionality of `useListItemRegister`
|
|
19
17
|
// it shouldn't allow to set disabled state only for one button
|
|
@@ -1,61 +1,52 @@
|
|
|
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.useSegmentedControlModel = void 0;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const common_1 = require("@workday/canvas-kit-react/common");
|
|
9
|
+
const collection_1 = require("@workday/canvas-kit-react/collection");
|
|
21
10
|
exports.useSegmentedControlModel = common_1.createModelHook({
|
|
22
|
-
defaultConfig:
|
|
11
|
+
defaultConfig: {
|
|
12
|
+
...collection_1.useListModel.defaultConfig,
|
|
23
13
|
/**
|
|
24
14
|
* Optional id for the whole `SegmentedControl` group. If not provided, a unique id will be created.
|
|
25
15
|
* @default useUniqueId()
|
|
26
16
|
*/
|
|
27
|
-
id: '',
|
|
17
|
+
id: '',
|
|
28
18
|
/**
|
|
29
19
|
* An initially selected value. This value must match the `data-id` of the `SegmentedControl.Item` component.
|
|
30
20
|
* If not provided, the first value will be selected.
|
|
31
21
|
*/
|
|
32
|
-
initialValue: '',
|
|
22
|
+
initialValue: '',
|
|
33
23
|
/**
|
|
34
24
|
* Sets disabled state for all segmented control buttons
|
|
35
25
|
* @default false
|
|
36
26
|
*/
|
|
37
|
-
disabled: false,
|
|
27
|
+
disabled: false,
|
|
38
28
|
/**
|
|
39
29
|
* Sets the size of the segmented control container and its buttons. Can be `small`, `medium` or `large`.
|
|
40
30
|
* @default 'medium'
|
|
41
31
|
*/
|
|
42
|
-
size: 'medium',
|
|
32
|
+
size: 'medium',
|
|
43
33
|
/**
|
|
44
34
|
* The SegmentedControl can rendered in a horizontal or vertical orientation.
|
|
45
35
|
* We suggest to use the `vertical` orientation only for icon only variant.
|
|
46
36
|
* @default 'horizontal'
|
|
47
37
|
*/
|
|
48
|
-
orientation: 'horizontal'
|
|
38
|
+
orientation: 'horizontal',
|
|
39
|
+
},
|
|
49
40
|
requiredConfig: collection_1.useListModel.requiredConfig,
|
|
50
|
-
})(
|
|
41
|
+
})(config => {
|
|
51
42
|
var _a;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
43
|
+
const getId = config.getId || collection_1.defaultGetId;
|
|
44
|
+
const initialSelectedRef = react_1.default.useRef(config.initialValue);
|
|
45
|
+
const items = config.items;
|
|
46
|
+
const model = collection_1.useListModel(collection_1.useListModel.mergeConfig(config, {
|
|
56
47
|
orientation: config.orientation || 'horizontal',
|
|
57
|
-
items
|
|
58
|
-
onRegisterItem
|
|
48
|
+
items,
|
|
49
|
+
onRegisterItem(data) {
|
|
59
50
|
if (!initialSelectedRef.current) {
|
|
60
51
|
initialSelectedRef.current = getId(data.item);
|
|
61
52
|
events.select({ id: initialSelectedRef.current });
|
|
@@ -68,8 +59,17 @@ exports.useSegmentedControlModel = common_1.createModelHook({
|
|
|
68
59
|
: [],
|
|
69
60
|
shouldVirtualize: false,
|
|
70
61
|
}));
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
62
|
+
const state = {
|
|
63
|
+
...model.state,
|
|
64
|
+
disabled: config.disabled,
|
|
65
|
+
size: config.size,
|
|
66
|
+
};
|
|
67
|
+
const events = {
|
|
68
|
+
...model.events,
|
|
69
|
+
};
|
|
70
|
+
return {
|
|
71
|
+
...model,
|
|
72
|
+
state,
|
|
73
|
+
events,
|
|
74
|
+
};
|
|
75
75
|
});
|