@progress/kendo-react-buttons 4.14.1 → 5.0.0-dev.202201182040
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/cdn/js/kendo-react-buttons.js +1 -1
- package/dist/es/Button.d.ts +79 -5
- package/dist/es/Button.js +30 -31
- package/dist/es/ButtonGroup.js +1 -1
- package/dist/es/ButtonInterface.d.ts +0 -13
- package/dist/es/Chip/Chip.d.ts +51 -9
- package/dist/es/Chip/Chip.js +34 -37
- package/dist/es/Chip/ChipList.d.ts +12 -0
- package/dist/es/Chip/ChipList.js +15 -13
- package/dist/es/FloatingActionButton/FloatingActionButton.js +26 -18
- package/dist/es/FloatingActionButton/interfaces/FloatingActionButtonProps.d.ts +18 -4
- package/dist/es/FloatingActionButton/models/rounded.d.ts +12 -0
- package/dist/es/{buttonLook.js → FloatingActionButton/models/rounded.js} +0 -0
- package/dist/es/FloatingActionButton/models/shape.d.ts +2 -1
- package/dist/es/FloatingActionButton/models/size.d.ts +2 -1
- package/dist/es/FloatingActionButton/models/theme-color.d.ts +2 -1
- package/dist/es/ListButton/ButtonItem.d.ts +6 -5
- package/dist/es/ListButton/ButtonItem.js +24 -44
- package/dist/es/ListButton/DropDownButton.d.ts +2 -4
- package/dist/es/ListButton/DropDownButton.js +14 -13
- package/dist/es/ListButton/SplitButton.d.ts +0 -1
- package/dist/es/ListButton/SplitButton.js +13 -13
- package/dist/es/ListButton/models/ListButtonProps.d.ts +125 -13
- package/dist/es/main.d.ts +3 -3
- package/dist/es/models/index.d.ts +0 -16
- package/dist/es/package-metadata.js +1 -1
- package/dist/es/util.js +3 -3
- package/dist/npm/Button.d.ts +79 -5
- package/dist/npm/Button.js +29 -30
- package/dist/npm/ButtonGroup.js +1 -1
- package/dist/npm/ButtonInterface.d.ts +0 -13
- package/dist/npm/Chip/Chip.d.ts +51 -9
- package/dist/npm/Chip/Chip.js +33 -36
- package/dist/npm/Chip/ChipList.d.ts +12 -0
- package/dist/npm/Chip/ChipList.js +14 -12
- package/dist/npm/FloatingActionButton/FloatingActionButton.js +25 -17
- package/dist/npm/FloatingActionButton/interfaces/FloatingActionButtonProps.d.ts +18 -4
- package/dist/npm/FloatingActionButton/models/rounded.d.ts +12 -0
- package/dist/npm/{buttonLook.js → FloatingActionButton/models/rounded.js} +0 -0
- package/dist/npm/FloatingActionButton/models/shape.d.ts +2 -1
- package/dist/npm/FloatingActionButton/models/size.d.ts +2 -1
- package/dist/npm/FloatingActionButton/models/theme-color.d.ts +2 -1
- package/dist/npm/ListButton/ButtonItem.d.ts +6 -5
- package/dist/npm/ListButton/ButtonItem.js +24 -44
- package/dist/npm/ListButton/DropDownButton.d.ts +2 -4
- package/dist/npm/ListButton/DropDownButton.js +13 -12
- package/dist/npm/ListButton/SplitButton.d.ts +0 -1
- package/dist/npm/ListButton/SplitButton.js +12 -12
- package/dist/npm/ListButton/models/ListButtonProps.d.ts +125 -13
- package/dist/npm/main.d.ts +3 -3
- package/dist/npm/models/index.d.ts +0 -16
- package/dist/npm/package-metadata.js +1 -1
- package/dist/npm/util.js +3 -3
- package/dist/systemjs/kendo-react-buttons.js +1 -1
- package/package.json +11 -10
- package/dist/es/buttonLook.d.ts +0 -14
- package/dist/npm/buttonLook.d.ts +0 -14
package/dist/es/Button.d.ts
CHANGED
|
@@ -10,6 +10,74 @@ export interface ButtonProps extends ButtonInterface, React.ButtonHTMLAttributes
|
|
|
10
10
|
* @hidden
|
|
11
11
|
*/
|
|
12
12
|
children?: React.ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* Configures the `size` of the Button.
|
|
15
|
+
*
|
|
16
|
+
* The available options are:
|
|
17
|
+
* - small
|
|
18
|
+
* - medium
|
|
19
|
+
* - large
|
|
20
|
+
* - null—Does not set a size `className`.
|
|
21
|
+
*
|
|
22
|
+
* @default `medium`
|
|
23
|
+
*/
|
|
24
|
+
size?: null | 'small' | 'medium' | 'large';
|
|
25
|
+
/**
|
|
26
|
+
* Configures the `shape` of the Button.
|
|
27
|
+
*
|
|
28
|
+
* The available options are:
|
|
29
|
+
* - rectangle
|
|
30
|
+
* - square
|
|
31
|
+
* - null—Does not set a shape `className`.
|
|
32
|
+
*
|
|
33
|
+
* @default `rectangle`
|
|
34
|
+
*/
|
|
35
|
+
shape?: null | 'rectangle' | 'square';
|
|
36
|
+
/**
|
|
37
|
+
* Configures the `roundness` of the Button.
|
|
38
|
+
*
|
|
39
|
+
* The available options are:
|
|
40
|
+
* - small
|
|
41
|
+
* - medium
|
|
42
|
+
* - large
|
|
43
|
+
* - full
|
|
44
|
+
* - null—Does not set a rounded `className`.
|
|
45
|
+
*
|
|
46
|
+
* @default `medium`
|
|
47
|
+
*/
|
|
48
|
+
rounded?: null | 'small' | 'medium' | 'large' | 'full';
|
|
49
|
+
/**
|
|
50
|
+
* Configures the `fillMode` of the Button.
|
|
51
|
+
*
|
|
52
|
+
* The available options are:
|
|
53
|
+
* - solid
|
|
54
|
+
* - outline
|
|
55
|
+
* - flat
|
|
56
|
+
* - link
|
|
57
|
+
* - null—Does not set a fillMode `className`.
|
|
58
|
+
*
|
|
59
|
+
* @default `solid`
|
|
60
|
+
*/
|
|
61
|
+
fillMode?: null | 'solid' | 'outline' | 'flat' | 'link';
|
|
62
|
+
/**
|
|
63
|
+
* Configures the `themeColor` of the Button.
|
|
64
|
+
*
|
|
65
|
+
* The available options are:
|
|
66
|
+
* - base
|
|
67
|
+
* - primary
|
|
68
|
+
* - secondary
|
|
69
|
+
* - tertiary
|
|
70
|
+
* - info
|
|
71
|
+
* - success
|
|
72
|
+
* - warning
|
|
73
|
+
* - dark
|
|
74
|
+
* - light
|
|
75
|
+
* - inverse
|
|
76
|
+
* - null—Does not set a themeColor `className`.
|
|
77
|
+
*
|
|
78
|
+
* @default `base`
|
|
79
|
+
*/
|
|
80
|
+
themeColor?: null | 'base' | 'primary' | 'secondary' | 'tertiary' | 'info' | 'success' | 'warning' | 'dark' | 'light' | 'inverse';
|
|
13
81
|
}
|
|
14
82
|
/**
|
|
15
83
|
* @hidden
|
|
@@ -23,22 +91,28 @@ export default class Button extends React.Component<ButtonProps, ButtonState> {
|
|
|
23
91
|
*/
|
|
24
92
|
static propTypes: {
|
|
25
93
|
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
26
|
-
look: PropTypes.Requireable<string>;
|
|
27
|
-
primary: PropTypes.Requireable<boolean>;
|
|
28
94
|
selected: PropTypes.Requireable<boolean>;
|
|
29
95
|
togglable: PropTypes.Requireable<boolean>;
|
|
30
96
|
icon: PropTypes.Requireable<string>;
|
|
31
97
|
iconClass: PropTypes.Requireable<string>;
|
|
32
98
|
imageUrl: PropTypes.Requireable<string>;
|
|
33
99
|
imageAlt: PropTypes.Requireable<string>;
|
|
100
|
+
size: PropTypes.Requireable<string>;
|
|
101
|
+
shape: PropTypes.Requireable<string>;
|
|
102
|
+
rounded: PropTypes.Requireable<string>;
|
|
103
|
+
fillMode: PropTypes.Requireable<string>;
|
|
104
|
+
themeColor: PropTypes.Requireable<string>;
|
|
34
105
|
};
|
|
35
106
|
/**
|
|
36
107
|
* @hidden
|
|
37
108
|
*/
|
|
38
109
|
static defaultProps: {
|
|
39
|
-
look: string;
|
|
40
|
-
primary: boolean;
|
|
41
110
|
togglable: boolean;
|
|
111
|
+
size: string;
|
|
112
|
+
shape: string;
|
|
113
|
+
rounded: string;
|
|
114
|
+
fillMode: string;
|
|
115
|
+
themeColor: string;
|
|
42
116
|
};
|
|
43
117
|
/**
|
|
44
118
|
* @hidden
|
|
@@ -55,7 +129,7 @@ export default class Button extends React.Component<ButtonProps, ButtonState> {
|
|
|
55
129
|
* Otherwise, returns `false`.
|
|
56
130
|
*/
|
|
57
131
|
readonly selected: boolean;
|
|
58
|
-
constructor(props:
|
|
132
|
+
constructor(props: any);
|
|
59
133
|
/**
|
|
60
134
|
* @hidden
|
|
61
135
|
*/
|
package/dist/es/Button.js
CHANGED
|
@@ -33,25 +33,23 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
33
33
|
};
|
|
34
34
|
import * as React from 'react';
|
|
35
35
|
import * as PropTypes from 'prop-types';
|
|
36
|
-
import { classNames } from '@progress/kendo-react-common';
|
|
36
|
+
import { classNames, kendoThemeMaps } from '@progress/kendo-react-common';
|
|
37
37
|
import { validatePackage } from '@progress/kendo-react-common';
|
|
38
38
|
import { packageMetadata } from './package-metadata';
|
|
39
|
-
import util from './util';
|
|
40
|
-
var styles = util.styles;
|
|
41
39
|
/**
|
|
42
40
|
* @hidden
|
|
43
41
|
*/
|
|
44
42
|
function iconElement(_a) {
|
|
45
43
|
var imageUrl = _a.imageUrl, icon = _a.icon, iconClass = _a.iconClass, imageAlt = _a.imageAlt;
|
|
46
44
|
if (imageUrl) {
|
|
47
|
-
return (React.createElement("img", { role: "presentation", className: 'k-
|
|
45
|
+
return (React.createElement("img", { role: "presentation", className: 'k-button-icon', alt: imageAlt, src: imageUrl }));
|
|
48
46
|
}
|
|
49
47
|
else if (icon) {
|
|
50
|
-
var iconClasses = classNames('k-icon', 'k-i-' + icon);
|
|
48
|
+
var iconClasses = classNames('k-button-icon k-icon', 'k-i-' + icon);
|
|
51
49
|
return (React.createElement("span", { role: "presentation", className: iconClasses }));
|
|
52
50
|
}
|
|
53
51
|
else if (iconClass) {
|
|
54
|
-
return (React.createElement("span", { role: "presentation", className: iconClass }));
|
|
52
|
+
return (React.createElement("span", { role: "presentation", className: classNames('k-button-icon', iconClass) }));
|
|
55
53
|
}
|
|
56
54
|
return null;
|
|
57
55
|
}
|
|
@@ -106,34 +104,28 @@ var Button = /** @class */ (function (_super) {
|
|
|
106
104
|
Button.prototype.render = function () {
|
|
107
105
|
var _this = this;
|
|
108
106
|
var _a;
|
|
109
|
-
var _b = this.props, children = _b.children,
|
|
107
|
+
var _b = this.props, children = _b.children, togglable = _b.togglable, icon = _b.icon, iconClass = _b.iconClass, imageUrl = _b.imageUrl, imageAlt = _b.imageAlt, className = _b.className, onClick = _b.onClick, _c = _b.size, size = _c === void 0 ? Button.defaultProps.size : _c, _d = _b.shape, shape = _d === void 0 ? Button.defaultProps.shape : _d, _e = _b.rounded, rounded = _e === void 0 ? Button.defaultProps.rounded : _e, _f = _b.fillMode, fillMode = _f === void 0 ? Button.defaultProps.fillMode : _f, _g = _b.themeColor, themeColor = _g === void 0 ? Button.defaultProps.themeColor : _g, htmlAttributes = __rest(_b, ["children", "togglable", "icon", "iconClass", "imageUrl", "imageAlt", "className", "onClick", "size", "shape", "rounded", "fillMode", "themeColor"]);
|
|
110
108
|
var hasIcon = (icon !== undefined || iconClass !== undefined || imageUrl !== undefined);
|
|
111
109
|
var hasChildren = children !== undefined;
|
|
112
|
-
var buttonClasses = classNames([styles.button], (_a = {},
|
|
113
|
-
_a[styles["" + look]] = look !== 'default',
|
|
114
|
-
_a[styles.primary] = primary,
|
|
115
|
-
_a[styles['state-disabled']] = this.props.disabled,
|
|
116
|
-
_a[styles['state-selected']] = this.state.selected,
|
|
117
|
-
_a[styles['button-icon']] = !hasChildren && hasIcon,
|
|
118
|
-
_a[styles['button-icontext']] = hasChildren && hasIcon,
|
|
119
|
-
_a), [styles["" + this.props.dir]], className);
|
|
120
|
-
var buttonProps = {
|
|
121
|
-
className: buttonClasses,
|
|
122
|
-
onClick: this.handleClick,
|
|
123
|
-
// Accessibility properties
|
|
124
|
-
role: togglable ? 'checkbox' : undefined,
|
|
125
|
-
'aria-disabled': this.props.disabled || undefined,
|
|
126
|
-
'aria-checked': togglable ? this.state.selected : undefined
|
|
127
|
-
};
|
|
128
110
|
var iconEl = iconElement({
|
|
129
111
|
icon: icon,
|
|
130
112
|
iconClass: iconClass,
|
|
131
113
|
imageUrl: imageUrl,
|
|
132
114
|
imageAlt: imageAlt
|
|
133
115
|
});
|
|
134
|
-
return (React.createElement("button", __assign({
|
|
116
|
+
return (React.createElement("button", __assign({ ref: function (button) { return _this._element = button; }, role: togglable ? 'checkbox' : undefined, "aria-disabled": this.props.disabled || undefined, "aria-checked": togglable ? this.state.selected : undefined }, htmlAttributes, { onClick: this.handleClick, className: classNames('k-button', (_a = {},
|
|
117
|
+
_a["k-button-" + (kendoThemeMaps.sizeMap[size] || size)] = size,
|
|
118
|
+
_a["k-button-" + shape] = shape,
|
|
119
|
+
_a["k-button-" + fillMode] = fillMode,
|
|
120
|
+
_a["k-button-" + fillMode + "-" + themeColor] = Boolean(fillMode && themeColor),
|
|
121
|
+
_a["k-rounded-" + (kendoThemeMaps.roundedMap[rounded] || rounded)] = rounded,
|
|
122
|
+
_a['k-icon-button'] = !hasChildren && hasIcon,
|
|
123
|
+
_a['k-disabled'] = this.props.disabled,
|
|
124
|
+
_a['k-selected'] = this.state.selected,
|
|
125
|
+
_a['k-rtl'] = this.props.dir === 'rtl',
|
|
126
|
+
_a), this.props.className) }),
|
|
135
127
|
iconEl,
|
|
136
|
-
children));
|
|
128
|
+
children && (React.createElement("span", { className: "k-button-text" }, children))));
|
|
137
129
|
};
|
|
138
130
|
Button.prototype.toggleIfApplicable = function () {
|
|
139
131
|
var _this = this;
|
|
@@ -148,22 +140,29 @@ var Button = /** @class */ (function (_super) {
|
|
|
148
140
|
*/
|
|
149
141
|
Button.propTypes = {
|
|
150
142
|
children: PropTypes.node,
|
|
151
|
-
look: PropTypes.oneOf(['default', 'flat', 'outline', 'clear']),
|
|
152
|
-
primary: PropTypes.bool,
|
|
153
143
|
selected: PropTypes.bool,
|
|
154
144
|
togglable: PropTypes.bool,
|
|
155
145
|
icon: PropTypes.string,
|
|
156
146
|
iconClass: PropTypes.string,
|
|
157
147
|
imageUrl: PropTypes.string,
|
|
158
|
-
imageAlt: PropTypes.string
|
|
148
|
+
imageAlt: PropTypes.string,
|
|
149
|
+
size: PropTypes.oneOf([null, 'small', 'medium', 'large']),
|
|
150
|
+
shape: PropTypes.oneOf([null, 'rectangle', 'square']),
|
|
151
|
+
rounded: PropTypes.oneOf([null, 'small', 'medium', 'large', 'full']),
|
|
152
|
+
fillMode: PropTypes.oneOf([null, 'flat', 'link', 'outline', 'solid']),
|
|
153
|
+
// eslint-disable-next-line max-len
|
|
154
|
+
themeColor: PropTypes.oneOf([null, 'base', 'dark', 'error', 'info', 'inverse', 'inverse', 'light', 'primary', 'secondary', 'success', 'tertiary', 'warning'])
|
|
159
155
|
};
|
|
160
156
|
/**
|
|
161
157
|
* @hidden
|
|
162
158
|
*/
|
|
163
159
|
Button.defaultProps = {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
160
|
+
togglable: false,
|
|
161
|
+
size: 'medium',
|
|
162
|
+
shape: 'rectangle',
|
|
163
|
+
rounded: 'medium',
|
|
164
|
+
fillMode: 'solid',
|
|
165
|
+
themeColor: 'base'
|
|
167
166
|
};
|
|
168
167
|
return Button;
|
|
169
168
|
}(React.Component));
|
package/dist/es/ButtonGroup.js
CHANGED
|
@@ -45,7 +45,7 @@ var ButtonGroup = /** @class */ (function (_super) {
|
|
|
45
45
|
var _a;
|
|
46
46
|
var buttons = this.mapButtons(this.props.children);
|
|
47
47
|
var groupClasses = classNames([styles['button-group']], (_a = {},
|
|
48
|
-
_a[
|
|
48
|
+
_a['k-state-disabled'] = this.props.disabled,
|
|
49
49
|
_a[styles['button-group-stretched']] = !!this.props.width,
|
|
50
50
|
_a), this.props.className);
|
|
51
51
|
var groupProps = {
|
|
@@ -1,20 +1,7 @@
|
|
|
1
|
-
import { ButtonLook } from './buttonLook';
|
|
2
1
|
/**
|
|
3
2
|
* Inherits the native HTML Button. Represents the properties which can be set to a Button.
|
|
4
3
|
*/
|
|
5
4
|
export interface ButtonInterface {
|
|
6
|
-
/**
|
|
7
|
-
* Changes the visual appearance by using alternative styling options ([more information and examples]({% slug appearance_button %})).
|
|
8
|
-
*
|
|
9
|
-
* The available values are:
|
|
10
|
-
* * [`ButtonLook`]({% slug api_buttons_buttonlook %}) = `flat` | `outline`
|
|
11
|
-
* * `clear`
|
|
12
|
-
*/
|
|
13
|
-
look?: ButtonLook | 'clear';
|
|
14
|
-
/**
|
|
15
|
-
* Adds visual weight to the Button and makes it primary ([see example]({% slug primary_button %})).
|
|
16
|
-
*/
|
|
17
|
-
primary?: boolean;
|
|
18
5
|
/**
|
|
19
6
|
* Specifies if the Button is disabled ([see example]({% slug disabled_button %})). Defaults to `false`.
|
|
20
7
|
*/
|
package/dist/es/Chip/Chip.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { ChipRemoveEvent, ChipMouseEvent, ChipFocusEvent, ChipKeyboardEvent
|
|
2
|
+
import { ChipRemoveEvent, ChipMouseEvent, ChipFocusEvent, ChipKeyboardEvent } from './../models/index';
|
|
3
3
|
/**
|
|
4
4
|
* Represents the properties of [Chip]({% slug api_buttons_chip %}) component.
|
|
5
5
|
*/
|
|
@@ -32,10 +32,6 @@ export interface ChipProps {
|
|
|
32
32
|
* Sets the `id` value of the Chip.
|
|
33
33
|
*/
|
|
34
34
|
value?: any;
|
|
35
|
-
/**
|
|
36
|
-
* Sets the `type` of the Chip element - 'warning', 'error', 'success', 'info', by default - 'none'.
|
|
37
|
-
*/
|
|
38
|
-
type?: string;
|
|
39
35
|
/**
|
|
40
36
|
* The Chip direction 'ltr' as default or 'rtl'.
|
|
41
37
|
*/
|
|
@@ -60,10 +56,6 @@ export interface ChipProps {
|
|
|
60
56
|
* Determines if the Chip has custom selection `icon`.
|
|
61
57
|
*/
|
|
62
58
|
selectedIcon?: string;
|
|
63
|
-
/**
|
|
64
|
-
* Determines if the Chip has `solid` or `outline` appearance. Defaults to `solid`.
|
|
65
|
-
*/
|
|
66
|
-
look?: ChipLook;
|
|
67
59
|
/**
|
|
68
60
|
* Triggered on Chip removing.
|
|
69
61
|
*/
|
|
@@ -133,6 +125,56 @@ export interface ChipProps {
|
|
|
133
125
|
* @hidden
|
|
134
126
|
*/
|
|
135
127
|
role?: string;
|
|
128
|
+
/**
|
|
129
|
+
* Configures the `size` of the Chip.
|
|
130
|
+
*
|
|
131
|
+
* The available options are:
|
|
132
|
+
* - small
|
|
133
|
+
* - medium
|
|
134
|
+
* - large
|
|
135
|
+
* - null—Does not set a size `className`.
|
|
136
|
+
*
|
|
137
|
+
* @default `medium`
|
|
138
|
+
*/
|
|
139
|
+
size?: null | 'small' | 'medium' | 'large';
|
|
140
|
+
/**
|
|
141
|
+
* Configures the `roundness` of the Chip.
|
|
142
|
+
*
|
|
143
|
+
* The available options are:
|
|
144
|
+
* - small
|
|
145
|
+
* - medium
|
|
146
|
+
* - large
|
|
147
|
+
* - full
|
|
148
|
+
* - null—Does not set a rounded `className`.
|
|
149
|
+
*
|
|
150
|
+
* @default `medium`
|
|
151
|
+
*/
|
|
152
|
+
rounded?: null | 'small' | 'medium' | 'large' | 'full';
|
|
153
|
+
/**
|
|
154
|
+
* Configures the `fillMode` of the Chip.
|
|
155
|
+
*
|
|
156
|
+
* The available options are:
|
|
157
|
+
* - solid
|
|
158
|
+
* - outline
|
|
159
|
+
* - null—Does not set a fillMode `className`.
|
|
160
|
+
*
|
|
161
|
+
* @default `solid`
|
|
162
|
+
*/
|
|
163
|
+
fillMode?: null | 'solid' | 'outline';
|
|
164
|
+
/**
|
|
165
|
+
* Configures the `themeColor` of the Chip.
|
|
166
|
+
*
|
|
167
|
+
* The available options are:
|
|
168
|
+
* - base
|
|
169
|
+
* - info
|
|
170
|
+
* - success
|
|
171
|
+
* - warning
|
|
172
|
+
* - error
|
|
173
|
+
* - null—Does not set a themeColor `className`.
|
|
174
|
+
*
|
|
175
|
+
* @default `base`
|
|
176
|
+
*/
|
|
177
|
+
themeColor?: null | 'base' | 'info' | 'success' | 'warning' | 'error';
|
|
136
178
|
}
|
|
137
179
|
/**
|
|
138
180
|
* Represents the target(element and props) of the ChipRemoveEvent.
|
package/dist/es/Chip/Chip.js
CHANGED
|
@@ -12,7 +12,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
12
12
|
import * as React from 'react';
|
|
13
13
|
import * as PropTypes from 'prop-types';
|
|
14
14
|
import { ChipListSelectionContext, ChipListFocusContext, ChipListDataContext } from './ChipList';
|
|
15
|
-
import { classNames, useDir, getTabIndex, Keys } from '@progress/kendo-react-common';
|
|
15
|
+
import { classNames, useDir, getTabIndex, Keys, kendoThemeMaps } from '@progress/kendo-react-common';
|
|
16
16
|
import { FOCUS_ACTION } from './focus-reducer';
|
|
17
17
|
import { DATA_ACTION } from './data-reducer';
|
|
18
18
|
import { SELECTION_ACTION } from './selection-reducer';
|
|
@@ -23,6 +23,7 @@ import { useMouse } from '@progress/kendo-react-common';
|
|
|
23
23
|
* Represents the Chip component.
|
|
24
24
|
*/
|
|
25
25
|
export var Chip = React.forwardRef(function (props, ref) {
|
|
26
|
+
var _a;
|
|
26
27
|
validatePackage(packageMetadata);
|
|
27
28
|
var target = React.useRef(null);
|
|
28
29
|
var chipRef = React.useRef(null);
|
|
@@ -32,22 +33,24 @@ export var Chip = React.forwardRef(function (props, ref) {
|
|
|
32
33
|
props: props
|
|
33
34
|
}); });
|
|
34
35
|
React.useImperativeHandle(ref, function () { return target.current; });
|
|
35
|
-
var
|
|
36
|
-
var
|
|
37
|
-
var
|
|
36
|
+
var _b = React.useContext(ChipListSelectionContext), selection = _b[0], dispatchSelection = _b[1];
|
|
37
|
+
var _c = React.useContext(ChipListFocusContext), focus = _c[0], dispatchFocus = _c[1];
|
|
38
|
+
var _d = React.useContext(ChipListDataContext), dispatchData = _d[1];
|
|
38
39
|
var selected = React.useMemo(function () {
|
|
39
40
|
return (props.selected || (Array.isArray(selection)
|
|
40
41
|
? selection.some(function (i) { return i === props.value; })
|
|
41
42
|
: selection === props.value));
|
|
42
43
|
}, [props.selected, props.value, selection]);
|
|
43
44
|
var focused = React.useMemo(function () { return focus === props.value; }, [props.value, focus]);
|
|
44
|
-
|
|
45
|
+
/* const look = React.useMemo(
|
|
46
|
+
() => props.look || defaultProps.look,
|
|
47
|
+
[props.look]
|
|
48
|
+
); */
|
|
45
49
|
React.useEffect(function () {
|
|
46
50
|
if (focused && chipRef.current) {
|
|
47
51
|
chipRef.current.focus();
|
|
48
52
|
}
|
|
49
53
|
}, [focused]);
|
|
50
|
-
// React.useEffect(() => dispatchItemsContext({type: FOCUS_ACTION.register, payload: target }), []);
|
|
51
54
|
var handleClick = React.useCallback(function (event) {
|
|
52
55
|
dispatchSelection({ type: SELECTION_ACTION.toggle, payload: props.value, event: event });
|
|
53
56
|
}, [props.onClick, dispatchSelection, props.value]);
|
|
@@ -107,61 +110,55 @@ export var Chip = React.forwardRef(function (props, ref) {
|
|
|
107
110
|
}
|
|
108
111
|
}, [props.onBlur]);
|
|
109
112
|
var mouseProps = useMouse(props, target, { onClick: handleClick });
|
|
110
|
-
return (React.createElement("div", __assign({}, mouseProps, { role: props.role, id: props.value, style: props.style, ref: chipRef, dir: dir, tabIndex: getTabIndex(props.tabIndex, props.disabled, undefined), className: classNames('k-chip', {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}, props.className), "aria-checked": selected, "aria-disabled": props.disabled, "aria-describedby": props.ariaDescribedBy, onFocus: handleFocus, onBlur: handleBlur, onKeyDown: handleKeyDown }),
|
|
124
|
-
selected && React.createElement("span", { className: 'k-selected-icon-wrapper' },
|
|
125
|
-
React.createElement("span", { className: "k-selected-icon k-icon " + (props.selectedIcon || defaultProps.selectedIcon) })),
|
|
126
|
-
props.icon && React.createElement("span", { className: "k-icon k-chip-icon " + props.icon }),
|
|
113
|
+
return (React.createElement("div", __assign({}, mouseProps, { role: props.role, id: props.value, style: props.style, ref: chipRef, dir: dir, tabIndex: getTabIndex(props.tabIndex, props.disabled, undefined), className: classNames('k-chip', (_a = {
|
|
114
|
+
'k-rtl': dir === 'rtl',
|
|
115
|
+
'k-disabled': props.disabled,
|
|
116
|
+
'k-selected': selected,
|
|
117
|
+
'k-focus': focused
|
|
118
|
+
},
|
|
119
|
+
_a["k-chip-" + (kendoThemeMaps.sizeMap[props.size] || props.size)] = props.size,
|
|
120
|
+
_a["k-rounded-" + (kendoThemeMaps.roundedMap[props.rounded] || props.rounded)] = props.rounded,
|
|
121
|
+
_a["k-chip-" + props.fillMode] = props.fillMode,
|
|
122
|
+
_a["k-chip-" + props.fillMode + "-" + props.themeColor] = Boolean(props.fillMode && props.themeColor),
|
|
123
|
+
_a), props.className), "aria-checked": selected, "aria-disabled": props.disabled, "aria-describedby": props.ariaDescribedBy, onFocus: handleFocus, onBlur: handleBlur, onKeyDown: handleKeyDown }),
|
|
124
|
+
(selected && props.selectedIcon) && React.createElement("span", { className: classNames('k-chip-icon', 'k-icon', props.selectedIcon) }),
|
|
125
|
+
props.icon && React.createElement("span", { className: classNames('k-chip-icon', 'k-icon', props.icon) }),
|
|
127
126
|
React.createElement("span", { className: 'k-chip-content' }, props.children !== undefined
|
|
128
127
|
? props.children
|
|
129
128
|
: props.text &&
|
|
130
129
|
React.createElement("span", { "aria-label": props.text, className: 'k-chip-label' }, props.text)),
|
|
131
130
|
props.removable &&
|
|
132
|
-
React.createElement("span", { className: 'k-
|
|
133
|
-
React.createElement("span", { className: "k-icon " + props.removeIcon }))));
|
|
131
|
+
React.createElement("span", { className: classNames('k-chip-icon', 'k-icon', props.removeIcon), onClick: handleRemove })));
|
|
134
132
|
});
|
|
135
133
|
var propTypes = {
|
|
136
134
|
id: PropTypes.string,
|
|
137
135
|
text: PropTypes.string,
|
|
138
136
|
value: PropTypes.any,
|
|
139
|
-
type: PropTypes.oneOf([
|
|
140
|
-
'none',
|
|
141
|
-
'success',
|
|
142
|
-
'warning',
|
|
143
|
-
'error',
|
|
144
|
-
'info'
|
|
145
|
-
]),
|
|
146
137
|
dir: PropTypes.oneOf(['ltr', 'rtl']),
|
|
147
138
|
removable: PropTypes.bool,
|
|
148
139
|
removeIcon: PropTypes.string,
|
|
149
140
|
disabled: PropTypes.bool,
|
|
150
141
|
icon: PropTypes.string,
|
|
151
142
|
selectedIcon: PropTypes.string,
|
|
152
|
-
look: PropTypes.string,
|
|
153
143
|
onRemove: PropTypes.func,
|
|
154
144
|
dataItem: PropTypes.any,
|
|
155
145
|
selected: PropTypes.bool,
|
|
156
|
-
ariaDescribedBy: PropTypes.string
|
|
146
|
+
ariaDescribedBy: PropTypes.string,
|
|
147
|
+
size: PropTypes.oneOf([null, 'small', 'medium', 'large']),
|
|
148
|
+
rounded: PropTypes.oneOf([null, 'small', 'medium', 'large', 'full']),
|
|
149
|
+
fillMode: PropTypes.oneOf([null, 'outline', 'solid']),
|
|
150
|
+
// eslint-disable-next-line max-len
|
|
151
|
+
themeColor: PropTypes.oneOf([null, 'base', 'info', 'success', 'warning', 'error'])
|
|
157
152
|
};
|
|
158
153
|
var defaultProps = {
|
|
159
154
|
disabled: false,
|
|
160
155
|
removable: false,
|
|
161
|
-
selectedIcon: 'k-i-check',
|
|
162
|
-
look: 'solid',
|
|
163
156
|
removeIcon: 'k-i-close-circle',
|
|
164
|
-
dir: 'ltr'
|
|
157
|
+
dir: 'ltr',
|
|
158
|
+
size: 'medium',
|
|
159
|
+
rounded: 'medium',
|
|
160
|
+
fillMode: 'solid',
|
|
161
|
+
themeColor: 'base'
|
|
165
162
|
};
|
|
166
163
|
Chip.displayName = 'KendoReactChip';
|
|
167
164
|
// TODO: delete casting when @types/react is updated!
|
|
@@ -79,6 +79,18 @@ export interface ChipListProps extends FormComponentProps, KendoMouse<ChipListHa
|
|
|
79
79
|
* Identifies the element(s) which will label the component.
|
|
80
80
|
*/
|
|
81
81
|
ariaLabelledBy?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Configures the `size` of the ChipList.
|
|
84
|
+
*
|
|
85
|
+
* The available options are:
|
|
86
|
+
* - small
|
|
87
|
+
* - medium
|
|
88
|
+
* - large
|
|
89
|
+
* - null—Does not set a size `className`.
|
|
90
|
+
*
|
|
91
|
+
* @default `medium`
|
|
92
|
+
*/
|
|
93
|
+
size?: null | 'small' | 'medium' | 'large';
|
|
82
94
|
}
|
|
83
95
|
/**
|
|
84
96
|
* Represents the target(element and props) of the ChipListChangeEvent.
|
package/dist/es/Chip/ChipList.js
CHANGED
|
@@ -11,7 +11,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
};
|
|
12
12
|
import * as React from 'react';
|
|
13
13
|
import * as PropTypes from 'prop-types';
|
|
14
|
-
import { useDir, getter, getTabIndex, classNames, useMouse } from '@progress/kendo-react-common';
|
|
14
|
+
import { useDir, getter, getTabIndex, classNames, useMouse, kendoThemeMaps } from '@progress/kendo-react-common';
|
|
15
15
|
import { selectionReducer } from './selection-reducer';
|
|
16
16
|
import { focusReducer } from './focus-reducer';
|
|
17
17
|
import { dataReducer } from './data-reducer';
|
|
@@ -79,6 +79,7 @@ var useData = function (defaultData, args, callback) {
|
|
|
79
79
|
* Represents the ChipList component.
|
|
80
80
|
*/
|
|
81
81
|
export var ChipList = React.forwardRef(function (props, ref) {
|
|
82
|
+
var _a;
|
|
82
83
|
validatePackage(packageMetadata);
|
|
83
84
|
var target = React.useRef(null);
|
|
84
85
|
var chipListRef = React.useRef(null);
|
|
@@ -99,10 +100,10 @@ export var ChipList = React.forwardRef(function (props, ref) {
|
|
|
99
100
|
});
|
|
100
101
|
}
|
|
101
102
|
}, [props.onChange]);
|
|
102
|
-
var
|
|
103
|
+
var _b = useSelection(props.value || props.defaultValue, {
|
|
103
104
|
selection: selection,
|
|
104
105
|
state: props.value
|
|
105
|
-
}, handleChange), stateValue =
|
|
106
|
+
}, handleChange), stateValue = _b[0], dispatchStateValue = _b[1];
|
|
106
107
|
var handleDataChange = React.useCallback(function (newData, event) {
|
|
107
108
|
if (props.onDataChange && target.current) {
|
|
108
109
|
props.onDataChange.call(undefined, {
|
|
@@ -112,10 +113,10 @@ export var ChipList = React.forwardRef(function (props, ref) {
|
|
|
112
113
|
});
|
|
113
114
|
}
|
|
114
115
|
}, [props.onDataChange]);
|
|
115
|
-
var
|
|
116
|
+
var _c = useData(props.data || props.defaultData || defaultProps.defaultData, {
|
|
116
117
|
state: props.data,
|
|
117
118
|
valueField: props.valueField || defaultProps.valueField
|
|
118
|
-
}, handleDataChange), stateData =
|
|
119
|
+
}, handleDataChange), stateData = _c[0], dispatchData = _c[1];
|
|
119
120
|
var itemsReducer = React.useCallback(function (acc, current) {
|
|
120
121
|
acc.push(current[props.valueField || defaultProps.valueField]);
|
|
121
122
|
return acc;
|
|
@@ -123,18 +124,18 @@ export var ChipList = React.forwardRef(function (props, ref) {
|
|
|
123
124
|
var data = React.useMemo(function () { return props.data || stateData; }, [props.data, stateData]);
|
|
124
125
|
var value = React.useMemo(function () { return props.value || stateValue; }, [props.value, stateValue]);
|
|
125
126
|
var items = React.useMemo(function () { return data.reduce(itemsReducer, []); }, [data, itemsReducer]);
|
|
126
|
-
var
|
|
127
|
+
var _d = useFocus({ items: items }), focus = _d[0], dispatchFocus = _d[1];
|
|
127
128
|
var mouseProps = useMouse(props, target);
|
|
128
129
|
return (React.createElement(ChipListSelectionContext.Provider, { value: [value, dispatchStateValue] },
|
|
129
130
|
React.createElement(ChipListFocusContext.Provider, { value: [focus, dispatchFocus] },
|
|
130
131
|
React.createElement(ChipListDataContext.Provider, { value: [data, dispatchData] },
|
|
131
|
-
React.createElement("div", __assign({ ref: chipListRef }, mouseProps, { role: 'listbox', id: props.id, dir: dir, style: props.style, tabIndex: getTabIndex(props.tabIndex, props.disabled, undefined), className: classNames('k-chip-list', {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
return (React.createElement(ChipComponent, { role: 'option', dataItem: item, key: getter(props.valueField || defaultProps.valueField)(item), text: getter(props.textField || defaultProps.textField)(item), value: getter(props.valueField || defaultProps.valueField)(item) }));
|
|
132
|
+
React.createElement("div", __assign({ ref: chipListRef }, mouseProps, { role: 'listbox', id: props.id, dir: dir, style: props.style, tabIndex: getTabIndex(props.tabIndex, props.disabled, undefined), className: classNames('k-chip-list', (_a = {
|
|
133
|
+
'k-rtl': dir === 'rtl',
|
|
134
|
+
'k-disabled': props.disabled
|
|
135
|
+
},
|
|
136
|
+
_a["k-chip-list-" + (kendoThemeMaps.sizeMap[props.size] || props.size)] = props.size,
|
|
137
|
+
_a), props.className), "aria-labelledby": props.ariaLabelledBy, "aria-describedby": props.ariaDescribedBy }), data.map(function (item) {
|
|
138
|
+
return (React.createElement(ChipComponent, { role: 'option', dataItem: item, size: props.size, key: getter(props.valueField || defaultProps.valueField)(item), text: getter(props.textField || defaultProps.textField)(item), value: getter(props.valueField || defaultProps.valueField)(item) }));
|
|
138
139
|
}))))));
|
|
139
140
|
});
|
|
140
141
|
var propTypes = {
|
|
@@ -157,6 +158,7 @@ var propTypes = {
|
|
|
157
158
|
};
|
|
158
159
|
var defaultProps = {
|
|
159
160
|
chip: Chip,
|
|
161
|
+
size: 'medium',
|
|
160
162
|
disabled: false,
|
|
161
163
|
defaultValue: null,
|
|
162
164
|
defaultData: [],
|