@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,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, useUniqueId } from '@workday/canvas-kit-react/common';
|
|
13
|
-
export
|
|
2
|
+
export const usePillModel = createModelHook({
|
|
14
3
|
defaultConfig: {
|
|
15
4
|
/**
|
|
16
5
|
* Determines the max width of the pill. If the pill text is longer than the max width,
|
|
@@ -27,8 +16,11 @@ export var usePillModel = createModelHook({
|
|
|
27
16
|
*/
|
|
28
17
|
id: '',
|
|
29
18
|
},
|
|
30
|
-
})(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
19
|
+
})(config => {
|
|
20
|
+
const id = useUniqueId(config.id);
|
|
21
|
+
const state = {
|
|
22
|
+
...config,
|
|
23
|
+
id,
|
|
24
|
+
};
|
|
25
|
+
return { state, events: {} };
|
|
34
26
|
});
|
|
@@ -23,7 +23,7 @@ import { SegmentedControlItem } from './SegmentedControlItem';
|
|
|
23
23
|
* <SegmentedControl model={model}>{Child components}</SegmentedControl>;
|
|
24
24
|
* ```
|
|
25
25
|
*/
|
|
26
|
-
export
|
|
26
|
+
export const SegmentedControl = createContainer()({
|
|
27
27
|
displayName: 'SegmentedControl',
|
|
28
28
|
modelHook: useSegmentedControlModel,
|
|
29
29
|
subComponents: {
|
|
@@ -46,7 +46,6 @@ export var SegmentedControl = createContainer()({
|
|
|
46
46
|
*/
|
|
47
47
|
Item: SegmentedControlItem,
|
|
48
48
|
},
|
|
49
|
-
})(
|
|
50
|
-
var children = _a.children;
|
|
49
|
+
})(({ children }) => {
|
|
51
50
|
return React.createElement(React.Fragment, null, children);
|
|
52
51
|
});
|
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
-
var t = {};
|
|
14
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
-
t[p] = s[p];
|
|
16
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
-
t[p[i]] = s[p[i]];
|
|
20
|
-
}
|
|
21
|
-
return t;
|
|
22
|
-
};
|
|
23
1
|
import * as React from 'react';
|
|
24
2
|
import { colors, type, space } from '@workday/canvas-kit-react/tokens';
|
|
25
3
|
import { createSubcomponent, useIsRTL } from '@workday/canvas-kit-react/common';
|
|
@@ -28,7 +6,7 @@ import { BaseButton, getMinWidthStyles, } from '@workday/canvas-kit-react/button
|
|
|
28
6
|
import { useSegmentedControlModel } from './hooks/useSegmentedControlModel';
|
|
29
7
|
import { Text } from '@workday/canvas-kit-react/text';
|
|
30
8
|
import { useSegmentedControlItem } from './hooks/useSegmentedControlItem';
|
|
31
|
-
|
|
9
|
+
const getButtonSize = (size) => {
|
|
32
10
|
switch (size) {
|
|
33
11
|
case 'large':
|
|
34
12
|
return 'medium';
|
|
@@ -40,7 +18,7 @@ var getButtonSize = function (size) {
|
|
|
40
18
|
return 'medium';
|
|
41
19
|
}
|
|
42
20
|
};
|
|
43
|
-
|
|
21
|
+
const getIconButtonColors = (toggled) => {
|
|
44
22
|
return {
|
|
45
23
|
default: {
|
|
46
24
|
background: toggled ? colors.frenchVanilla100 : colors.soap200,
|
|
@@ -65,44 +43,41 @@ var getIconButtonColors = function (toggled) {
|
|
|
65
43
|
},
|
|
66
44
|
};
|
|
67
45
|
};
|
|
68
|
-
|
|
46
|
+
const getPaddingStyles = (children, size, icon) => {
|
|
69
47
|
if (!children) {
|
|
70
48
|
return 0;
|
|
71
49
|
}
|
|
72
50
|
switch (size) {
|
|
73
51
|
case 'large':
|
|
74
|
-
return icon ?
|
|
52
|
+
return icon ? `0 ${space.m} 0 20px` : `0 ${space.m}`;
|
|
75
53
|
case 'medium':
|
|
76
|
-
return icon ?
|
|
54
|
+
return icon ? `0 20px 0 ${space.s}` : `0 ${space.s}`;
|
|
77
55
|
case 'small':
|
|
78
|
-
return icon ?
|
|
56
|
+
return icon ? `0 ${space.xs} 0 ${space.xxs}` : `0 ${space.xs}`;
|
|
79
57
|
default:
|
|
80
|
-
return icon ?
|
|
58
|
+
return icon ? `0 20px 0 ${space.s}` : `0 ${space.s}`;
|
|
81
59
|
}
|
|
82
60
|
};
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
61
|
+
const geButtonStyles = (size, children, icon) => {
|
|
62
|
+
const buttonSize = getButtonSize(size);
|
|
63
|
+
const minWidthValue = getMinWidthStyles(children, children ? size : buttonSize);
|
|
86
64
|
return {
|
|
87
65
|
height: getMinWidthStyles(false, buttonSize),
|
|
88
66
|
minWidth: minWidthValue,
|
|
89
67
|
padding: getPaddingStyles(children, size, icon),
|
|
90
68
|
};
|
|
91
69
|
};
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
return tooltipProps ? (React.createElement(Tooltip, __assign({}, tooltipProps), children)) : (React.createElement(React.Fragment, null, children));
|
|
70
|
+
const Container = ({ tooltipProps, children, }) => {
|
|
71
|
+
return tooltipProps ? (React.createElement(Tooltip, Object.assign({}, tooltipProps), children)) : (React.createElement(React.Fragment, null, children));
|
|
95
72
|
};
|
|
96
|
-
export
|
|
73
|
+
export const SegmentedControlItem = createSubcomponent('button')({
|
|
97
74
|
displayName: 'SegmentedControl.Item',
|
|
98
75
|
modelHook: useSegmentedControlModel,
|
|
99
76
|
elemPropsHook: useSegmentedControlItem,
|
|
100
|
-
})(
|
|
101
|
-
|
|
102
|
-
var children = _a.children, icon = _a.icon, tooltipProps = _a.tooltipProps, elemProps = __rest(_a, ["children", "icon", "tooltipProps"]);
|
|
103
|
-
var _c = type.levels.subtext[size === 'small' ? 'medium' : 'large'], color = _c.color, textStyles = __rest(_c, ["color"]);
|
|
77
|
+
})(({ children, icon, tooltipProps, ...elemProps }, Element, { state: { size } }) => {
|
|
78
|
+
const { color, ...textStyles } = type.levels.subtext[size === 'small' ? 'medium' : 'large'];
|
|
104
79
|
return (React.createElement(Container, { tooltipProps: tooltipProps },
|
|
105
|
-
React.createElement(BaseButton,
|
|
80
|
+
React.createElement(BaseButton, Object.assign({ as: Element, borderRadius: "m", colors: getIconButtonColors(elemProps['aria-pressed']) }, geButtonStyles(size, children, icon), elemProps),
|
|
106
81
|
icon && (React.createElement(BaseButton.Icon, { size: size === 'small' ? 'extraSmall' : 'medium', icon: icon, shouldMirrorIcon: useIsRTL() })),
|
|
107
|
-
children && (React.createElement(Text,
|
|
82
|
+
children && (React.createElement(Text, Object.assign({}, textStyles, { fontWeight: "bold", textAlign: "left" }), children)))));
|
|
108
83
|
});
|
|
@@ -1,44 +1,19 @@
|
|
|
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 * as React from 'react';
|
|
24
2
|
import { createSubcomponent, createElemPropsHook, } from '@workday/canvas-kit-react/common';
|
|
25
3
|
import { Grid } from '@workday/canvas-kit-react/layout';
|
|
26
4
|
import { useListRenderItems } from '@workday/canvas-kit-react/collection';
|
|
27
5
|
import { useSegmentedControlModel } from './hooks/useSegmentedControlModel';
|
|
28
|
-
export
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
_b.opacity = disabled ? 0.4 : undefined,
|
|
35
|
-
_b;
|
|
6
|
+
export const useSegmentedControlList = createElemPropsHook(useSegmentedControlModel)(({ state: { orientation, disabled, items } }) => {
|
|
7
|
+
const directionName = orientation === 'vertical' ? 'Row' : 'Column';
|
|
8
|
+
return {
|
|
9
|
+
[`gridTemplate${directionName}s`]: `repeat(${items.length}, 1fr)`,
|
|
10
|
+
opacity: disabled ? 0.4 : undefined,
|
|
11
|
+
};
|
|
36
12
|
});
|
|
37
|
-
export
|
|
13
|
+
export const SegmentedControlList = createSubcomponent('div')({
|
|
38
14
|
displayName: 'SegmentedControl.List',
|
|
39
15
|
modelHook: useSegmentedControlModel,
|
|
40
16
|
elemPropsHook: useSegmentedControlList,
|
|
41
|
-
})(
|
|
42
|
-
|
|
43
|
-
return (React.createElement(Grid, __assign({ as: Element, display: "inline-grid", role: "group", backgroundColor: "soap200", border: "1px solid transparent", borderColor: "licorice200", borderRadius: "l", padding: "3px", gridGap: "xxs" }, elemProps), useListRenderItems(model, children)));
|
|
17
|
+
})(({ children, ...elemProps }, Element, model) => {
|
|
18
|
+
return (React.createElement(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), useListRenderItems(model, children)));
|
|
44
19
|
});
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { createElemPropsHook, composeHooks } from '@workday/canvas-kit-react/common';
|
|
2
2
|
import { useListItemRegister, isSelected, useListItemSelect, } from '@workday/canvas-kit-react/collection';
|
|
3
3
|
import { useSegmentedControlModel } from './useSegmentedControlModel';
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var selected = !!name && isSelected(name, model.state);
|
|
4
|
+
export const useSegmentedControlItem = composeHooks(useListItemSelect, createElemPropsHook(useSegmentedControlModel)((model, _, elemProps = {}) => {
|
|
5
|
+
const name = elemProps['data-id'] || '';
|
|
6
|
+
const selected = !!name && isSelected(name, model.state);
|
|
8
7
|
return {
|
|
9
|
-
id: model.state.id
|
|
8
|
+
id: `${model.state.id}-${name}`,
|
|
10
9
|
'aria-pressed': selected,
|
|
11
10
|
};
|
|
12
|
-
}), useListItemRegister, createElemPropsHook(useSegmentedControlModel)(
|
|
13
|
-
var state = _a.state;
|
|
11
|
+
}), useListItemRegister, createElemPropsHook(useSegmentedControlModel)(({ state }) => {
|
|
14
12
|
return {
|
|
15
13
|
// override the default disabled functionality of `useListItemRegister`
|
|
16
14
|
// it shouldn't allow to set disabled state only for one button
|
|
@@ -1,55 +1,46 @@
|
|
|
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 { createModelHook } from '@workday/canvas-kit-react/common';
|
|
14
3
|
import { defaultGetId, useListModel } from '@workday/canvas-kit-react/collection';
|
|
15
|
-
export
|
|
16
|
-
defaultConfig:
|
|
4
|
+
export const useSegmentedControlModel = createModelHook({
|
|
5
|
+
defaultConfig: {
|
|
6
|
+
...useListModel.defaultConfig,
|
|
17
7
|
/**
|
|
18
8
|
* Optional id for the whole `SegmentedControl` group. If not provided, a unique id will be created.
|
|
19
9
|
* @default useUniqueId()
|
|
20
10
|
*/
|
|
21
|
-
id: '',
|
|
11
|
+
id: '',
|
|
22
12
|
/**
|
|
23
13
|
* An initially selected value. This value must match the `data-id` of the `SegmentedControl.Item` component.
|
|
24
14
|
* If not provided, the first value will be selected.
|
|
25
15
|
*/
|
|
26
|
-
initialValue: '',
|
|
16
|
+
initialValue: '',
|
|
27
17
|
/**
|
|
28
18
|
* Sets disabled state for all segmented control buttons
|
|
29
19
|
* @default false
|
|
30
20
|
*/
|
|
31
|
-
disabled: false,
|
|
21
|
+
disabled: false,
|
|
32
22
|
/**
|
|
33
23
|
* Sets the size of the segmented control container and its buttons. Can be `small`, `medium` or `large`.
|
|
34
24
|
* @default 'medium'
|
|
35
25
|
*/
|
|
36
|
-
size: 'medium',
|
|
26
|
+
size: 'medium',
|
|
37
27
|
/**
|
|
38
28
|
* The SegmentedControl can rendered in a horizontal or vertical orientation.
|
|
39
29
|
* We suggest to use the `vertical` orientation only for icon only variant.
|
|
40
30
|
* @default 'horizontal'
|
|
41
31
|
*/
|
|
42
|
-
orientation: 'horizontal'
|
|
32
|
+
orientation: 'horizontal',
|
|
33
|
+
},
|
|
43
34
|
requiredConfig: useListModel.requiredConfig,
|
|
44
|
-
})(
|
|
35
|
+
})(config => {
|
|
45
36
|
var _a;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
37
|
+
const getId = config.getId || defaultGetId;
|
|
38
|
+
const initialSelectedRef = React.useRef(config.initialValue);
|
|
39
|
+
const items = config.items;
|
|
40
|
+
const model = useListModel(useListModel.mergeConfig(config, {
|
|
50
41
|
orientation: config.orientation || 'horizontal',
|
|
51
|
-
items
|
|
52
|
-
onRegisterItem
|
|
42
|
+
items,
|
|
43
|
+
onRegisterItem(data) {
|
|
53
44
|
if (!initialSelectedRef.current) {
|
|
54
45
|
initialSelectedRef.current = getId(data.item);
|
|
55
46
|
events.select({ id: initialSelectedRef.current });
|
|
@@ -62,8 +53,17 @@ export var useSegmentedControlModel = createModelHook({
|
|
|
62
53
|
: [],
|
|
63
54
|
shouldVirtualize: false,
|
|
64
55
|
}));
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
56
|
+
const state = {
|
|
57
|
+
...model.state,
|
|
58
|
+
disabled: config.disabled,
|
|
59
|
+
size: config.size,
|
|
60
|
+
};
|
|
61
|
+
const events = {
|
|
62
|
+
...model.events,
|
|
63
|
+
};
|
|
64
|
+
return {
|
|
65
|
+
...model,
|
|
66
|
+
state,
|
|
67
|
+
events,
|
|
68
|
+
};
|
|
69
69
|
});
|