@progress/kendo-react-buttons 7.2.4-develop.2 → 7.2.4-develop.4
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/Button.js +8 -0
- package/Button.mjs +124 -0
- package/ButtonGroup.js +8 -0
- package/ButtonGroup.mjs +76 -0
- package/Chip/Chip.js +8 -0
- package/Chip/Chip.mjs +220 -0
- package/Chip/ChipList.js +8 -0
- package/Chip/ChipList.mjs +190 -0
- package/Chip/chip-list-contexts.js +8 -0
- package/Chip/chip-list-contexts.mjs +18 -0
- package/Chip/data-reducer.js +8 -0
- package/Chip/data-reducer.mjs +25 -0
- package/Chip/focus-reducer.js +8 -0
- package/Chip/focus-reducer.mjs +28 -0
- package/Chip/selection-reducer.js +8 -0
- package/Chip/selection-reducer.mjs +47 -0
- package/FloatingActionButton/FloatingActionButton.js +8 -0
- package/FloatingActionButton/FloatingActionButton.mjs +343 -0
- package/FloatingActionButton/FloatingActionButtonItem.js +8 -0
- package/FloatingActionButton/FloatingActionButtonItem.mjs +93 -0
- package/FloatingActionButton/utils.js +8 -0
- package/FloatingActionButton/utils.mjs +46 -0
- package/ListButton/ButtonItem.js +8 -0
- package/ListButton/ButtonItem.mjs +63 -0
- package/ListButton/DropDownButton.js +8 -0
- package/ListButton/DropDownButton.mjs +267 -0
- package/ListButton/DropDownButtonItem.js +8 -0
- package/ListButton/DropDownButtonItem.mjs +31 -0
- package/ListButton/SplitButton.js +8 -0
- package/ListButton/SplitButton.mjs +298 -0
- package/ListButton/SplitButtonItem.js +8 -0
- package/ListButton/SplitButtonItem.mjs +30 -0
- package/ListButton/utils/navigation.js +8 -0
- package/ListButton/utils/navigation.mjs +35 -0
- package/ListButton/utils/popup.js +8 -0
- package/ListButton/utils/popup.mjs +20 -0
- package/dist/cdn/js/kendo-react-buttons.js +8 -5
- package/index.d.mts +2227 -5
- package/index.d.ts +2227 -40
- package/index.js +8 -5
- package/index.mjs +44 -1906
- package/package-metadata.js +8 -0
- package/package-metadata.mjs +19 -0
- package/package.json +3 -3
- package/toolbar/Toolbar.js +8 -0
- package/toolbar/Toolbar.mjs +124 -0
- package/toolbar/tools/ToolbarItem.js +8 -0
- package/toolbar/tools/ToolbarItem.mjs +44 -0
- package/toolbar/tools/ToolbarSeparator.js +8 -0
- package/toolbar/tools/ToolbarSeparator.mjs +21 -0
- package/toolbar/tools/ToolbarSpacer.js +8 -0
- package/toolbar/tools/ToolbarSpacer.mjs +36 -0
- package/util.js +8 -0
- package/util.mjs +36 -0
- package/Button.d.ts +0 -146
- package/ButtonGroup.d.ts +0 -36
- package/ButtonGroupInterface.d.ts +0 -36
- package/ButtonInterface.d.ts +0 -39
- package/Chip/Chip.d.ts +0 -238
- package/Chip/ChipList.d.ts +0 -119
- package/Chip/chip-list-contexts.d.ts +0 -17
- package/Chip/data-reducer.d.ts +0 -26
- package/Chip/focus-reducer.d.ts +0 -28
- package/Chip/selection-reducer.d.ts +0 -34
- package/FloatingActionButton/FloatingActionButton.d.ts +0 -21
- package/FloatingActionButton/FloatingActionButtonItem.d.ts +0 -109
- package/FloatingActionButton/interfaces/FloatingActionButtonHandle.d.ts +0 -17
- package/FloatingActionButton/interfaces/FloatingActionButtonPopupSettings.d.ts +0 -28
- package/FloatingActionButton/interfaces/FloatingActionButtonProps.d.ts +0 -219
- package/FloatingActionButton/models/align-offset.d.ts +0 -24
- package/FloatingActionButton/models/align.d.ts +0 -31
- package/FloatingActionButton/models/events.d.ts +0 -25
- package/FloatingActionButton/models/position-mode.d.ts +0 -13
- package/FloatingActionButton/models/rounded.d.ts +0 -16
- package/FloatingActionButton/models/size.d.ts +0 -15
- package/FloatingActionButton/models/theme-color.d.ts +0 -22
- package/FloatingActionButton/utils.d.ts +0 -31
- package/ListButton/ButtonItem.d.ts +0 -34
- package/ListButton/DropDownButton.d.ts +0 -127
- package/ListButton/DropDownButtonItem.d.ts +0 -34
- package/ListButton/SplitButton.d.ts +0 -129
- package/ListButton/SplitButtonItem.d.ts +0 -29
- package/ListButton/models/ButtonItem.d.ts +0 -38
- package/ListButton/models/ListButtonProps.d.ts +0 -339
- package/ListButton/models/PopupSettings.d.ts +0 -32
- package/ListButton/models/events.d.ts +0 -51
- package/ListButton/utils/navigation.d.ts +0 -9
- package/ListButton/utils/popup.d.ts +0 -13
- package/models/index.d.ts +0 -92
- package/package-metadata.d.ts +0 -9
- package/toolbar/Toolbar.d.ts +0 -175
- package/toolbar/tools/ToolbarItem.d.ts +0 -42
- package/toolbar/tools/ToolbarSeparator.d.ts +0 -20
- package/toolbar/tools/ToolbarSpacer.d.ts +0 -27
- package/util.d.ts +0 -31
package/Button.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("react"),s=require("prop-types"),n=require("@progress/kendo-react-common"),y=require("./package-metadata.js");function T(l){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const t in l)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(l,t);Object.defineProperty(e,t,o.get?o:{enumerable:!0,get:()=>l[t]})}}return e.default=l,Object.freeze(e)}const r=T(P);function N({imageUrl:l,name:e,iconClass:t,svgIcon:o,imageAlt:a}){return l?r.createElement("img",{role:"presentation",className:"k-button-icon",alt:a,src:l}):e||o?r.createElement(n.IconWrap,{className:"k-button-icon",name:e,icon:o}):t?r.createElement("span",{role:"presentation",className:n.classNames("k-button-icon",t)}):null}const i=class i extends r.Component{constructor(e){super(e),this._element=null,this.handleClick=t=>{this.toggleIfApplicable(),this.props.onClick&&this.props.onClick.call(void 0,t)},n.validatePackage(y.packageMetadata),this.state={selected:this.props.togglable===!0&&this.props.selected===!0}}get element(){return this._element}get selected(){return this._selectedTemp!==void 0?this._selectedTemp:this.state.selected}static getDerivedStateFromProps(e,t){return e.togglable&&e.selected!==void 0&&e.selected!==t.selected?{selected:e.selected}:null}render(){const{children:e,togglable:t,icon:o,iconClass:a,svgIcon:m,imageUrl:g,imageAlt:f,className:O,onClick:E,size:d=i.defaultProps.size,rounded:u=i.defaultProps.rounded,fillMode:c=i.defaultProps.fillMode,themeColor:h=i.defaultProps.themeColor,...b}=this.props,k=m!==void 0||o!==void 0||a!==void 0||g!==void 0,v=e!==void 0,C=N({name:o,svgIcon:m,iconClass:a,imageUrl:g,imageAlt:f});return r.createElement("button",{ref:M=>this._element=M,"aria-pressed":t?this.state.selected:void 0,...b,onClick:this.handleClick,className:n.classNames("k-button",{[`k-button-${n.kendoThemeMaps.sizeMap[d]||d}`]:d,[`k-button-${c}`]:c,[`k-button-${c}-${h}`]:!!(c&&h),[`k-rounded-${n.kendoThemeMaps.roundedMap[u]||u}`]:u,"k-icon-button":!v&&k,"k-disabled":this.props.disabled,"k-selected":this.state.selected,"k-rtl":this.props.dir==="rtl"},this.props.className)},C,e&&r.createElement("span",{className:"k-button-text"},e))}toggleIfApplicable(){if(this.props.togglable&&this.props.selected===void 0){const e=!this.state.selected;this._selectedTemp=e,this.setState({selected:e},()=>this._selectedTemp=void 0)}}};i.propTypes={children:s.node,selected:s.bool,togglable:s.bool,icon:s.string,svgIcon:n.svgIconPropType,iconClass:s.string,imageUrl:s.string,imageAlt:s.string,size:s.oneOf([null,"small","medium","large"]),rounded:s.oneOf([null,"small","medium","large","full"]),fillMode:s.oneOf([null,"flat","link","outline","solid"]),themeColor:s.oneOf([null,"base","primary","secondary","tertiary","info","success","warning","error","dark","light","inverse"])},i.defaultProps={togglable:!1,size:"medium",rounded:"medium",fillMode:"solid",themeColor:"base"};let p=i;exports.Button=p;
|
package/Button.mjs
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";
|
|
9
|
+
import * as o from "react";
|
|
10
|
+
import t from "prop-types";
|
|
11
|
+
import { validatePackage as N, svgIconPropType as T, classNames as f, kendoThemeMaps as h, IconWrap as E } from "@progress/kendo-react-common";
|
|
12
|
+
import { packageMetadata as y } from "./package-metadata.mjs";
|
|
13
|
+
function I({ imageUrl: d, name: e, iconClass: s, svgIcon: i, imageAlt: r }) {
|
|
14
|
+
return d ? /* @__PURE__ */ o.createElement("img", { role: "presentation", className: "k-button-icon", alt: r, src: d }) : e || i ? /* @__PURE__ */ o.createElement(E, { className: "k-button-icon", name: e, icon: i }) : s ? /* @__PURE__ */ o.createElement("span", { role: "presentation", className: f("k-button-icon", s) }) : null;
|
|
15
|
+
}
|
|
16
|
+
const l = class l extends o.Component {
|
|
17
|
+
constructor(e) {
|
|
18
|
+
super(e), this._element = null, this.handleClick = (s) => {
|
|
19
|
+
this.toggleIfApplicable(), this.props.onClick && this.props.onClick.call(void 0, s);
|
|
20
|
+
}, N(y), this.state = { selected: this.props.togglable === !0 && this.props.selected === !0 };
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Gets the DOM element of the Button component.
|
|
24
|
+
*/
|
|
25
|
+
get element() {
|
|
26
|
+
return this._element;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Returns `true` when the component is togglable and selected ([see example]({% slug toggleable_button %})).
|
|
30
|
+
* Otherwise, returns `false`.
|
|
31
|
+
*/
|
|
32
|
+
get selected() {
|
|
33
|
+
return this._selectedTemp !== void 0 ? this._selectedTemp : this.state.selected;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* @hidden
|
|
37
|
+
*/
|
|
38
|
+
static getDerivedStateFromProps(e, s) {
|
|
39
|
+
return e.togglable && e.selected !== void 0 && e.selected !== s.selected ? { selected: e.selected } : null;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* @hidden
|
|
43
|
+
*/
|
|
44
|
+
render() {
|
|
45
|
+
const {
|
|
46
|
+
children: e,
|
|
47
|
+
togglable: s,
|
|
48
|
+
icon: i,
|
|
49
|
+
iconClass: r,
|
|
50
|
+
svgIcon: m,
|
|
51
|
+
imageUrl: p,
|
|
52
|
+
imageAlt: b,
|
|
53
|
+
className: z,
|
|
54
|
+
onClick: A,
|
|
55
|
+
size: a = l.defaultProps.size,
|
|
56
|
+
rounded: c = l.defaultProps.rounded,
|
|
57
|
+
fillMode: n = l.defaultProps.fillMode,
|
|
58
|
+
themeColor: u = l.defaultProps.themeColor,
|
|
59
|
+
...k
|
|
60
|
+
} = this.props, v = m !== void 0 || i !== void 0 || r !== void 0 || p !== void 0, C = e !== void 0, P = I({
|
|
61
|
+
name: i,
|
|
62
|
+
svgIcon: m,
|
|
63
|
+
iconClass: r,
|
|
64
|
+
imageUrl: p,
|
|
65
|
+
imageAlt: b
|
|
66
|
+
});
|
|
67
|
+
return /* @__PURE__ */ o.createElement(
|
|
68
|
+
"button",
|
|
69
|
+
{
|
|
70
|
+
ref: (M) => this._element = M,
|
|
71
|
+
"aria-pressed": s ? this.state.selected : void 0,
|
|
72
|
+
...k,
|
|
73
|
+
onClick: this.handleClick,
|
|
74
|
+
className: f(
|
|
75
|
+
"k-button",
|
|
76
|
+
{
|
|
77
|
+
[`k-button-${h.sizeMap[a] || a}`]: a,
|
|
78
|
+
[`k-button-${n}`]: n,
|
|
79
|
+
[`k-button-${n}-${u}`]: !!(n && u),
|
|
80
|
+
[`k-rounded-${h.roundedMap[c] || c}`]: c,
|
|
81
|
+
"k-icon-button": !C && v,
|
|
82
|
+
"k-disabled": this.props.disabled,
|
|
83
|
+
"k-selected": this.state.selected,
|
|
84
|
+
"k-rtl": this.props.dir === "rtl"
|
|
85
|
+
},
|
|
86
|
+
this.props.className
|
|
87
|
+
)
|
|
88
|
+
},
|
|
89
|
+
P,
|
|
90
|
+
e && /* @__PURE__ */ o.createElement("span", { className: "k-button-text" }, e)
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
toggleIfApplicable() {
|
|
94
|
+
if (this.props.togglable && this.props.selected === void 0) {
|
|
95
|
+
const e = !this.state.selected;
|
|
96
|
+
this._selectedTemp = e, this.setState({ selected: e }, () => this._selectedTemp = void 0);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
l.propTypes = {
|
|
101
|
+
children: t.node,
|
|
102
|
+
selected: t.bool,
|
|
103
|
+
togglable: t.bool,
|
|
104
|
+
icon: t.string,
|
|
105
|
+
svgIcon: T,
|
|
106
|
+
iconClass: t.string,
|
|
107
|
+
imageUrl: t.string,
|
|
108
|
+
imageAlt: t.string,
|
|
109
|
+
size: t.oneOf([null, "small", "medium", "large"]),
|
|
110
|
+
rounded: t.oneOf([null, "small", "medium", "large", "full"]),
|
|
111
|
+
fillMode: t.oneOf([null, "flat", "link", "outline", "solid"]),
|
|
112
|
+
// eslint-disable-next-line max-len
|
|
113
|
+
themeColor: t.oneOf([null, "base", "primary", "secondary", "tertiary", "info", "success", "warning", "error", "dark", "light", "inverse"])
|
|
114
|
+
}, l.defaultProps = {
|
|
115
|
+
togglable: !1,
|
|
116
|
+
size: "medium",
|
|
117
|
+
rounded: "medium",
|
|
118
|
+
fillMode: "solid",
|
|
119
|
+
themeColor: "base"
|
|
120
|
+
};
|
|
121
|
+
let g = l;
|
|
122
|
+
export {
|
|
123
|
+
g as Button
|
|
124
|
+
};
|
package/ButtonGroup.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react"),o=require("prop-types"),l=require("@progress/kendo-react-common"),g=require("./package-metadata.js"),f=require("./util.js");function y(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>a[t]})}}return e.default=a,Object.freeze(e)}const n=y(b),i=f.default.styles,d=class d extends n.Component{constructor(e){super(e),this._element=null,l.validatePackage(g.packageMetadata)}render(){const e=this.mapButtons(this.props.children),t=l.classNames([i["button-group"]],{"k-disabled":this.props.disabled,[i["button-group-stretched"]]:!!this.props.width},this.props.className),s={className:t,style:{width:`${this.props.width}`},dir:this.props.dir,role:"group","aria-disabled":this.props.disabled};return n.createElement("div",{ref:r=>{this._element=r},...s,className:t},e)}mapButtons(e){const t=n.Children.count(e),s=this.props.dir!==void 0?this.props.dir==="rtl":this._element&&getComputedStyle(this._element).direction==="rtl"||!1;return n.Children.map(e,(r,p)=>n.isValidElement(r)?this.renderButton(r,p,p===t-1,s):r)}renderButton(e,t,s,r){const p=l.classNames(e.props.className,{[i["group-start"]]:r?s:t===0,[i["group-end"]]:r?t===0:s}),u={...this.props.width?{width:this.props.width}:{},...e.props.style||{}},m=this.props.disabled||e.props.disabled,h={...e.props,...p?{className:p}:{},...Object.keys(u).length?{style:u}:{},...m!==void 0?{disabled:m}:{}};return n.Children.count(e.props.children)>0?n.cloneElement(e,h,e.props.children):n.cloneElement(e,h)}};d.propTypes={children:o.oneOfType([o.arrayOf(o.element),o.element]),className:o.string,disabled:o.bool,width:o.string,dir:o.string};let c=d;exports.ButtonGroup=c;
|
package/ButtonGroup.mjs
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";
|
|
9
|
+
import * as e from "react";
|
|
10
|
+
import r from "prop-types";
|
|
11
|
+
import { validatePackage as u, classNames as c } from "@progress/kendo-react-common";
|
|
12
|
+
import { packageMetadata as b } from "./package-metadata.mjs";
|
|
13
|
+
import g from "./util.mjs";
|
|
14
|
+
const i = g.styles, a = class a extends e.Component {
|
|
15
|
+
constructor(t) {
|
|
16
|
+
super(t), this._element = null, u(b);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* @hidden
|
|
20
|
+
*/
|
|
21
|
+
render() {
|
|
22
|
+
const t = this.mapButtons(this.props.children), o = c(
|
|
23
|
+
[i["button-group"]],
|
|
24
|
+
{
|
|
25
|
+
"k-disabled": this.props.disabled,
|
|
26
|
+
[i["button-group-stretched"]]: !!this.props.width
|
|
27
|
+
},
|
|
28
|
+
this.props.className
|
|
29
|
+
), p = {
|
|
30
|
+
className: o,
|
|
31
|
+
style: { width: `${this.props.width}` },
|
|
32
|
+
dir: this.props.dir,
|
|
33
|
+
// Accessibility properties
|
|
34
|
+
role: "group",
|
|
35
|
+
"aria-disabled": this.props.disabled
|
|
36
|
+
};
|
|
37
|
+
return /* @__PURE__ */ e.createElement(
|
|
38
|
+
"div",
|
|
39
|
+
{
|
|
40
|
+
ref: (s) => {
|
|
41
|
+
this._element = s;
|
|
42
|
+
},
|
|
43
|
+
...p,
|
|
44
|
+
className: o
|
|
45
|
+
},
|
|
46
|
+
t
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
mapButtons(t) {
|
|
50
|
+
const o = e.Children.count(t), p = this.props.dir !== void 0 ? this.props.dir === "rtl" : this._element && getComputedStyle(this._element).direction === "rtl" || !1;
|
|
51
|
+
return e.Children.map(t, (s, n) => e.isValidElement(s) ? this.renderButton(s, n, n === o - 1, p) : s);
|
|
52
|
+
}
|
|
53
|
+
renderButton(t, o, p, s) {
|
|
54
|
+
const n = c(t.props.className, {
|
|
55
|
+
[i["group-start"]]: s ? p : o === 0,
|
|
56
|
+
[i["group-end"]]: s ? o === 0 : p
|
|
57
|
+
}), l = { ...this.props.width ? { width: this.props.width } : {}, ...t.props.style || {} }, d = this.props.disabled || t.props.disabled, m = {
|
|
58
|
+
...t.props,
|
|
59
|
+
...n ? { className: n } : {},
|
|
60
|
+
...Object.keys(l).length ? { style: l } : {},
|
|
61
|
+
...d !== void 0 ? { disabled: d } : {}
|
|
62
|
+
};
|
|
63
|
+
return e.Children.count(t.props.children) > 0 ? e.cloneElement(t, m, t.props.children) : e.cloneElement(t, m);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
a.propTypes = {
|
|
67
|
+
children: r.oneOfType([r.arrayOf(r.element), r.element]),
|
|
68
|
+
className: r.string,
|
|
69
|
+
disabled: r.bool,
|
|
70
|
+
width: r.string,
|
|
71
|
+
dir: r.string
|
|
72
|
+
};
|
|
73
|
+
let h = a;
|
|
74
|
+
export {
|
|
75
|
+
h as ButtonGroup
|
|
76
|
+
};
|
package/Chip/Chip.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("react"),n=require("prop-types"),b=require("./chip-list-contexts.js"),t=require("@progress/kendo-react-common"),x=require("@progress/kendo-svg-icons"),r=require("./focus-reducer.js"),M=require("./data-reducer.js"),g=require("./selection-reducer.js"),R=require("../package-metadata.js");function D(e){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const c in e)if(c!=="default"){const i=Object.getOwnPropertyDescriptor(e,c);Object.defineProperty(s,c,i.get?i:{enumerable:!0,get:()=>e[c]})}}return s.default=e,Object.freeze(s)}const a=D(S),m=a.forwardRef((e,s)=>{t.validatePackage(R.packageMetadata);const c=a.useRef(null),i=a.useRef(null),k=t.useDir(i,e.dir);a.useImperativeHandle(c,()=>({element:i.current,props:e})),a.useImperativeHandle(s,()=>c.current);const[u,d]=a.useContext(b.ChipListSelectionContext),[I,o]=a.useContext(b.ChipListFocusContext),[,C]=a.useContext(b.ChipListDataContext),v=a.useMemo(()=>e.selected||(Array.isArray(u)?u.some(l=>l===e.value):u===e.value),[e.selected,e.value,u]),y=a.useMemo(()=>I===e.value,[e.value,I]);a.useEffect(()=>{y&&i.current&&i.current.focus()},[y]);const h=a.useCallback(l=>{d({type:g.SELECTION_ACTION.toggle,payload:e.value,event:l})},[d,e.value]),f=a.useCallback(l=>{e.removable&&(C({type:M.CHIP_DATA_ACTION.remove,payload:e.value,event:l}),o({type:r.FOCUS_ACTION.reset,payload:e.value,event:l}),d({type:g.SELECTION_ACTION.remove,payload:e.value,event:l}),e.onRemove&&e.onRemove.call(void 0,{target:c.current,syntheticEvent:l}))},[e.onRemove,e.value,e.removable,C,o,d]),N=a.useCallback(l=>{switch(l.keyCode){case t.Keys.left:o({type:r.FOCUS_ACTION.prev,payload:e.value,event:l});break;case t.Keys.right:o({type:r.FOCUS_ACTION.next,payload:e.value,event:l});break;case t.Keys.enter:d({type:g.SELECTION_ACTION.toggle,payload:e.value,event:l});break;case t.Keys.delete:f(l);break}e.onKeyDown&&e.onKeyDown.call(void 0,{target:c.current,syntheticEvent:l})},[e.onKeyDown,e.value,o,d,f]),O=a.useCallback(l=>{o({payload:e.value,type:r.FOCUS_ACTION.current,event:l}),e.onFocus&&e.onFocus.call(void 0,{target:c.current,syntheticEvent:l})},[e.onFocus,e.value,o]),E=a.useCallback(l=>{e.onBlur&&e.onBlur.call(void 0,{target:c.current,syntheticEvent:l})},[e.onBlur]),T=t.useMouse(e,c,{onClick:h});return a.createElement("div",{...T,role:e.role||"button",id:e.value,style:e.style,ref:i,dir:k,tabIndex:t.getTabIndex(e.tabIndex,e.disabled,void 0),className:t.classNames("k-chip",{"k-rtl":k==="rtl","k-disabled":e.disabled,"k-selected":v,"k-focus":y,[`k-chip-${t.kendoThemeMaps.sizeMap[e.size]||e.size}`]:e.size,[`k-rounded-${t.kendoThemeMaps.roundedMap[e.rounded]||e.rounded}`]:e.rounded,[`k-chip-${e.fillMode}`]:e.fillMode,[`k-chip-${e.fillMode}-${e.themeColor}`]:!!(e.fillMode&&e.themeColor)},e.className),"aria-pressed":e.role?void 0:v,"aria-disabled":e.disabled,"aria-describedby":e.ariaDescribedBy,"aria-keyshortcuts":e.removable?"Enter Delete":void 0,onFocus:O,onBlur:E,onKeyDown:N},v&&(e.selectedIcon||e.selectedSvgIcon)&&a.createElement(t.IconWrap,{className:"k-chip-icon",name:e.selectedIcon?t.toIconName(e.selectedIcon):void 0,icon:e.selectedSvgIcon,size:"small"}),(e.icon||e.svgIcon)&&a.createElement(t.IconWrap,{className:"k-chip-icon",name:e.icon?t.toIconName(e.icon):void 0,icon:e.svgIcon,size:"small"}),e.avatar&&a.createElement("div",{className:`k-chip-avatar k-avatar k-rounded-${e.avatar.rounded} k-avatar-md k-avatar-solid k-avatar-solid-primary`,style:e.avatar.style},a.createElement("span",{className:"k-avatar-image"},a.createElement("img",{src:e.avatar.image,alt:e.avatar.imageAlt}))),a.createElement("span",{className:"k-chip-content"},e.children!==void 0?e.children:e.text&&a.createElement("span",{"aria-label":e.ariaLabel||e.text,className:"k-chip-label"},e.text)),e.removable&&a.createElement("span",{className:"k-chip-actions"},a.createElement("span",{className:t.classNames("k-chip-action","k-chip-remove-action"),onClick:f},a.createElement(t.IconWrap,{name:e.removeIcon?t.toIconName(e.removeIcon):void 0,icon:e.removeSvgIcon||x.xCircleIcon,size:"small"}))))}),A={id:n.string,text:n.string,value:n.any,dir:n.oneOf(["ltr","rtl"]),removable:n.bool,removeIcon:n.string,removeIconSvg:t.svgIconPropType,disabled:n.bool,icon:n.string,svgIcon:t.svgIconPropType,selectedIcon:n.string,selectedIconSvg:t.svgIconPropType,onRemove:n.func,dataItem:n.any,selected:n.bool,ariaDescribedBy:n.string,size:n.oneOf([null,"small","medium","large"]),rounded:n.oneOf([null,"small","medium","large","full"]),fillMode:n.oneOf([null,"outline","solid"]),themeColor:n.oneOf([null,"base","info","success","warning","error"])},P={disabled:!1,removable:!1,removeIcon:"k-i-x-circle",dir:"ltr",size:"medium",rounded:"medium",fillMode:"solid",themeColor:"base"};m.displayName="KendoReactChip";m.propTypes=A;m.defaultProps=P;exports.Chip=m;
|
package/Chip/Chip.mjs
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";
|
|
9
|
+
import * as a from "react";
|
|
10
|
+
import t from "prop-types";
|
|
11
|
+
import { ChipListSelectionContext as z, ChipListFocusContext as S, ChipListDataContext as w } from "./chip-list-contexts.mjs";
|
|
12
|
+
import { validatePackage as A, useDir as B, Keys as m, useMouse as F, getTabIndex as K, classNames as E, kendoThemeMaps as x, IconWrap as f, toIconName as y, svgIconPropType as k } from "@progress/kendo-react-common";
|
|
13
|
+
import { xCircleIcon as P } from "@progress/kendo-svg-icons";
|
|
14
|
+
import { FOCUS_ACTION as u } from "./focus-reducer.mjs";
|
|
15
|
+
import { CHIP_DATA_ACTION as $ } from "./data-reducer.mjs";
|
|
16
|
+
import { SELECTION_ACTION as h } from "./selection-reducer.mjs";
|
|
17
|
+
import { packageMetadata as L } from "../package-metadata.mjs";
|
|
18
|
+
const b = a.forwardRef((e, N) => {
|
|
19
|
+
A(L);
|
|
20
|
+
const n = a.useRef(null), o = a.useRef(null), g = B(o, e.dir);
|
|
21
|
+
a.useImperativeHandle(n, () => ({
|
|
22
|
+
element: o.current,
|
|
23
|
+
props: e
|
|
24
|
+
})), a.useImperativeHandle(N, () => n.current);
|
|
25
|
+
const [d, i] = a.useContext(z), [C, c] = a.useContext(S), [, I] = a.useContext(w), r = a.useMemo(
|
|
26
|
+
() => e.selected || (Array.isArray(d) ? d.some((l) => l === e.value) : d === e.value),
|
|
27
|
+
[e.selected, e.value, d]
|
|
28
|
+
), s = a.useMemo(
|
|
29
|
+
() => C === e.value,
|
|
30
|
+
[e.value, C]
|
|
31
|
+
);
|
|
32
|
+
a.useEffect(
|
|
33
|
+
() => {
|
|
34
|
+
s && o.current && o.current.focus();
|
|
35
|
+
},
|
|
36
|
+
[s]
|
|
37
|
+
);
|
|
38
|
+
const M = a.useCallback(
|
|
39
|
+
(l) => {
|
|
40
|
+
i({ type: h.toggle, payload: e.value, event: l });
|
|
41
|
+
},
|
|
42
|
+
[i, e.value]
|
|
43
|
+
), v = a.useCallback(
|
|
44
|
+
(l) => {
|
|
45
|
+
e.removable && (I({ type: $.remove, payload: e.value, event: l }), c({ type: u.reset, payload: e.value, event: l }), i({ type: h.remove, payload: e.value, event: l }), e.onRemove && e.onRemove.call(
|
|
46
|
+
void 0,
|
|
47
|
+
{
|
|
48
|
+
target: n.current,
|
|
49
|
+
syntheticEvent: l
|
|
50
|
+
}
|
|
51
|
+
));
|
|
52
|
+
},
|
|
53
|
+
[e.onRemove, e.value, e.removable, I, c, i]
|
|
54
|
+
), D = a.useCallback(
|
|
55
|
+
(l) => {
|
|
56
|
+
switch (l.keyCode) {
|
|
57
|
+
case m.left:
|
|
58
|
+
c({ type: u.prev, payload: e.value, event: l });
|
|
59
|
+
break;
|
|
60
|
+
case m.right:
|
|
61
|
+
c({ type: u.next, payload: e.value, event: l });
|
|
62
|
+
break;
|
|
63
|
+
case m.enter:
|
|
64
|
+
i({ type: h.toggle, payload: e.value, event: l });
|
|
65
|
+
break;
|
|
66
|
+
case m.delete:
|
|
67
|
+
v(l);
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
e.onKeyDown && e.onKeyDown.call(
|
|
71
|
+
void 0,
|
|
72
|
+
{
|
|
73
|
+
target: n.current,
|
|
74
|
+
syntheticEvent: l
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
},
|
|
78
|
+
[e.onKeyDown, e.value, c, i, v]
|
|
79
|
+
), R = a.useCallback(
|
|
80
|
+
(l) => {
|
|
81
|
+
c({ payload: e.value, type: u.current, event: l }), e.onFocus && e.onFocus.call(
|
|
82
|
+
void 0,
|
|
83
|
+
{
|
|
84
|
+
target: n.current,
|
|
85
|
+
syntheticEvent: l
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
},
|
|
89
|
+
[e.onFocus, e.value, c]
|
|
90
|
+
), T = a.useCallback(
|
|
91
|
+
(l) => {
|
|
92
|
+
e.onBlur && e.onBlur.call(
|
|
93
|
+
void 0,
|
|
94
|
+
{
|
|
95
|
+
target: n.current,
|
|
96
|
+
syntheticEvent: l
|
|
97
|
+
}
|
|
98
|
+
);
|
|
99
|
+
},
|
|
100
|
+
[e.onBlur]
|
|
101
|
+
), O = F(e, n, { onClick: M });
|
|
102
|
+
return /* @__PURE__ */ a.createElement(
|
|
103
|
+
"div",
|
|
104
|
+
{
|
|
105
|
+
...O,
|
|
106
|
+
role: e.role || "button",
|
|
107
|
+
id: e.value,
|
|
108
|
+
style: e.style,
|
|
109
|
+
ref: o,
|
|
110
|
+
dir: g,
|
|
111
|
+
tabIndex: K(e.tabIndex, e.disabled, void 0),
|
|
112
|
+
className: E(
|
|
113
|
+
"k-chip",
|
|
114
|
+
{
|
|
115
|
+
"k-rtl": g === "rtl",
|
|
116
|
+
"k-disabled": e.disabled,
|
|
117
|
+
"k-selected": r,
|
|
118
|
+
"k-focus": s,
|
|
119
|
+
[`k-chip-${x.sizeMap[e.size] || e.size}`]: e.size,
|
|
120
|
+
[`k-rounded-${x.roundedMap[e.rounded] || e.rounded}`]: e.rounded,
|
|
121
|
+
[`k-chip-${e.fillMode}`]: e.fillMode,
|
|
122
|
+
[`k-chip-${e.fillMode}-${e.themeColor}`]: !!(e.fillMode && e.themeColor)
|
|
123
|
+
},
|
|
124
|
+
e.className
|
|
125
|
+
),
|
|
126
|
+
"aria-pressed": e.role ? void 0 : r,
|
|
127
|
+
"aria-disabled": e.disabled,
|
|
128
|
+
"aria-describedby": e.ariaDescribedBy,
|
|
129
|
+
"aria-keyshortcuts": e.removable ? "Enter Delete" : void 0,
|
|
130
|
+
onFocus: R,
|
|
131
|
+
onBlur: T,
|
|
132
|
+
onKeyDown: D
|
|
133
|
+
},
|
|
134
|
+
r && (e.selectedIcon || e.selectedSvgIcon) && /* @__PURE__ */ a.createElement(
|
|
135
|
+
f,
|
|
136
|
+
{
|
|
137
|
+
className: "k-chip-icon",
|
|
138
|
+
name: e.selectedIcon ? y(e.selectedIcon) : void 0,
|
|
139
|
+
icon: e.selectedSvgIcon,
|
|
140
|
+
size: "small"
|
|
141
|
+
}
|
|
142
|
+
),
|
|
143
|
+
(e.icon || e.svgIcon) && /* @__PURE__ */ a.createElement(
|
|
144
|
+
f,
|
|
145
|
+
{
|
|
146
|
+
className: "k-chip-icon",
|
|
147
|
+
name: e.icon ? y(e.icon) : void 0,
|
|
148
|
+
icon: e.svgIcon,
|
|
149
|
+
size: "small"
|
|
150
|
+
}
|
|
151
|
+
),
|
|
152
|
+
e.avatar && /* @__PURE__ */ a.createElement(
|
|
153
|
+
"div",
|
|
154
|
+
{
|
|
155
|
+
className: `k-chip-avatar k-avatar k-rounded-${e.avatar.rounded} k-avatar-md k-avatar-solid k-avatar-solid-primary`,
|
|
156
|
+
style: e.avatar.style
|
|
157
|
+
},
|
|
158
|
+
/* @__PURE__ */ a.createElement("span", { className: "k-avatar-image" }, /* @__PURE__ */ a.createElement(
|
|
159
|
+
"img",
|
|
160
|
+
{
|
|
161
|
+
src: e.avatar.image,
|
|
162
|
+
alt: e.avatar.imageAlt
|
|
163
|
+
}
|
|
164
|
+
))
|
|
165
|
+
),
|
|
166
|
+
/* @__PURE__ */ a.createElement("span", { className: "k-chip-content" }, e.children !== void 0 ? e.children : e.text && /* @__PURE__ */ a.createElement(
|
|
167
|
+
"span",
|
|
168
|
+
{
|
|
169
|
+
"aria-label": e.ariaLabel || e.text,
|
|
170
|
+
className: "k-chip-label"
|
|
171
|
+
},
|
|
172
|
+
e.text
|
|
173
|
+
)),
|
|
174
|
+
e.removable && /* @__PURE__ */ a.createElement("span", { className: "k-chip-actions" }, /* @__PURE__ */ a.createElement("span", { className: E("k-chip-action", "k-chip-remove-action"), onClick: v }, /* @__PURE__ */ a.createElement(
|
|
175
|
+
f,
|
|
176
|
+
{
|
|
177
|
+
name: e.removeIcon ? y(e.removeIcon) : void 0,
|
|
178
|
+
icon: e.removeSvgIcon || P,
|
|
179
|
+
size: "small"
|
|
180
|
+
}
|
|
181
|
+
)))
|
|
182
|
+
);
|
|
183
|
+
}), _ = {
|
|
184
|
+
id: t.string,
|
|
185
|
+
text: t.string,
|
|
186
|
+
value: t.any,
|
|
187
|
+
dir: t.oneOf(["ltr", "rtl"]),
|
|
188
|
+
removable: t.bool,
|
|
189
|
+
removeIcon: t.string,
|
|
190
|
+
removeIconSvg: k,
|
|
191
|
+
disabled: t.bool,
|
|
192
|
+
icon: t.string,
|
|
193
|
+
svgIcon: k,
|
|
194
|
+
selectedIcon: t.string,
|
|
195
|
+
selectedIconSvg: k,
|
|
196
|
+
onRemove: t.func,
|
|
197
|
+
dataItem: t.any,
|
|
198
|
+
selected: t.bool,
|
|
199
|
+
ariaDescribedBy: t.string,
|
|
200
|
+
size: t.oneOf([null, "small", "medium", "large"]),
|
|
201
|
+
rounded: t.oneOf([null, "small", "medium", "large", "full"]),
|
|
202
|
+
fillMode: t.oneOf([null, "outline", "solid"]),
|
|
203
|
+
// eslint-disable-next-line max-len
|
|
204
|
+
themeColor: t.oneOf([null, "base", "info", "success", "warning", "error"])
|
|
205
|
+
}, H = {
|
|
206
|
+
disabled: !1,
|
|
207
|
+
removable: !1,
|
|
208
|
+
removeIcon: "k-i-x-circle",
|
|
209
|
+
dir: "ltr",
|
|
210
|
+
size: "medium",
|
|
211
|
+
rounded: "medium",
|
|
212
|
+
fillMode: "solid",
|
|
213
|
+
themeColor: "base"
|
|
214
|
+
};
|
|
215
|
+
b.displayName = "KendoReactChip";
|
|
216
|
+
b.propTypes = _;
|
|
217
|
+
b.defaultProps = H;
|
|
218
|
+
export {
|
|
219
|
+
b as Chip
|
|
220
|
+
};
|
package/Chip/ChipList.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Q=require("react"),t=require("prop-types"),c=require("@progress/kendo-react-common"),U=require("./selection-reducer.js"),W=require("./focus-reducer.js"),X=require("./data-reducer.js"),x=require("./Chip.js"),S=require("./chip-list-contexts.js"),Y=require("../package-metadata.js");function Z(e){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const l=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(i,n,l.get?l:{enumerable:!0,get:()=>e[n]})}}return i.default=e,Object.freeze(i)}const a=Z(Q),V=(e,i,n)=>{i.selection==="multiple"?Array.isArray(e)||(e=e?[e]:null):i.selection==="single"&&Array.isArray(e)&&(e=e?e.join(""):null);const[l,r]=a.useState(e);return[l,o=>{const u=U.selectionReducer(i.state||l,{...o,...i});n&&n(u,o.event),i.selection!=="none"&&r(u)}]},ee=e=>{const[i,n]=a.useState(null);return[i,r=>{const h=W.focusReducer(r.payload,{...r,...e});n(h)}]},te=(e,i,n)=>{const[l,r]=a.useState(e);return[l,o=>{const u=X.dataReducer(i.state||l,{...o,...i});n&&n(u,o.event),r(u)}]},y=a.forwardRef((e,i)=>{c.validatePackage(Y.packageMetadata);const n=a.useRef(null),l=a.useRef(null),r=c.useDir(l,e.dir),{chip:h,id:o,style:u,tabIndex:P,disabled:g,size:m,className:q,ariaDescribedBy:I,ariaLabelledBy:T,ariaLabel:j,selection:R=p.selection,value:b=p.defaultValue,defaultData:E=p.defaultData,valueField:f=p.valueField,textField:k=p.textField,onChange:C,onDataChange:D}=e,z=a.useMemo(()=>h||x.Chip,[h,x.Chip]);a.useImperativeHandle(n,()=>({element:l.current,props:e})),a.useImperativeHandle(i,()=>n.current);const N=a.useCallback((s,d)=>{C&&n.current&&C.call(void 0,{value:s,target:n.current,syntheticEvent:d})},[C]),[O,w]=V(b||e.defaultValue,{selection:R,state:b},N),A=a.useCallback((s,d)=>{D&&n.current&&D.call(void 0,{value:s,target:n.current,syntheticEvent:d})},[D]),[F,B]=te(e.data||E,{state:e.data,valueField:f},A),L=a.useCallback((s,d)=>(s.push(d[f]),s),[f]),v=a.useMemo(()=>e.data||F,[e.data,F]),_=a.useMemo(()=>b||O,[b,O]),G=a.useMemo(()=>v.reduce(L,[]),[v,L]),M=a.useCallback(s=>c.getter(f)(s),[f]),H=a.useCallback(s=>c.getter(k)(s),[k]),[K,$]=ee({items:G}),J=c.useMouse(e,n);return a.createElement(S.ChipListSelectionContext.Provider,{value:[_,w]},a.createElement(S.ChipListFocusContext.Provider,{value:[K,$]},a.createElement(S.ChipListDataContext.Provider,{value:[v,B]},a.createElement("div",{ref:l,...J,role:g?void 0:"listbox",id:o,dir:r,style:u,tabIndex:c.getTabIndex(P,g,void 0),className:c.classNames("k-chip-list",{"k-rtl":r==="rtl","k-disabled":g,[`k-chip-list-${c.kendoThemeMaps.sizeMap[m]||m}`]:m},q),"aria-label":j,"aria-labelledby":T,"aria-describedby":I,"aria-orientation":"horizontal","aria-multiselectable":R==="multiple"},v.map((s,d)=>a.createElement(z,{role:"option",dataItem:s,size:m,key:[M(s),d].join("-"),text:H(s),value:M(s),ariaLabel:s.ariaLabel,svgIcon:s.svgIcon||void 0}))))))}),ae={id:t.string,className:t.string,tabIndex:t.number,data:t.any,defaultData:t.arrayOf(t.any),onDataChange:t.func,value:t.oneOfType([t.any,t.arrayOf(t.any)]),defaultValue:t.oneOfType([t.any,t.arrayOf(t.any)]),onChange:t.func,selection:t.oneOf(["single","none","multiple"]),textField:t.string,valueField:t.string,disabled:t.bool,dir:t.oneOf(["ltr","rtl"]),ariaLabelledBy:t.string,ariaDescribedBy:t.string,size:t.oneOf([null,"small","medium","large"])},p={chip:x.Chip,size:"medium",disabled:!1,defaultValue:null,defaultData:[],dir:"ltr",selection:"none",textField:"text",valueField:"value",removable:"removable"};y.displayName="KendoReactChipList";y.propTypes=ae;y.defaultProps=p;exports.ChipList=y;
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";
|
|
9
|
+
import * as a from "react";
|
|
10
|
+
import e from "prop-types";
|
|
11
|
+
import { validatePackage as Q, useDir as U, getter as I, useMouse as W, getTabIndex as X, classNames as Y, kendoThemeMaps as Z } from "@progress/kendo-react-common";
|
|
12
|
+
import { selectionReducer as _ } from "./selection-reducer.mjs";
|
|
13
|
+
import { focusReducer as V } from "./focus-reducer.mjs";
|
|
14
|
+
import { dataReducer as ee } from "./data-reducer.mjs";
|
|
15
|
+
import { Chip as D } from "./Chip.mjs";
|
|
16
|
+
import { ChipListSelectionContext as te, ChipListFocusContext as ae, ChipListDataContext as ne } from "./chip-list-contexts.mjs";
|
|
17
|
+
import { packageMetadata as se } from "../package-metadata.mjs";
|
|
18
|
+
const ie = (t, i, s) => {
|
|
19
|
+
i.selection === "multiple" ? Array.isArray(t) || (t = t ? [t] : null) : i.selection === "single" && Array.isArray(t) && (t = t ? t.join("") : null);
|
|
20
|
+
const [l, o] = a.useState(t);
|
|
21
|
+
return [l, (r) => {
|
|
22
|
+
const c = _(i.state || l, { ...r, ...i });
|
|
23
|
+
s && s(c, r.event), i.selection !== "none" && o(c);
|
|
24
|
+
}];
|
|
25
|
+
}, le = (t) => {
|
|
26
|
+
const [i, s] = a.useState(null);
|
|
27
|
+
return [i, (o) => {
|
|
28
|
+
const d = V(o.payload, { ...o, ...t });
|
|
29
|
+
s(d);
|
|
30
|
+
}];
|
|
31
|
+
}, oe = (t, i, s) => {
|
|
32
|
+
const [l, o] = a.useState(t);
|
|
33
|
+
return [l, (r) => {
|
|
34
|
+
const c = ee(i.state || l, { ...r, ...i });
|
|
35
|
+
s && s(c, r.event), o(c);
|
|
36
|
+
}];
|
|
37
|
+
}, g = a.forwardRef((t, i) => {
|
|
38
|
+
Q(se);
|
|
39
|
+
const s = a.useRef(null), l = a.useRef(null), o = U(l, t.dir), {
|
|
40
|
+
chip: d,
|
|
41
|
+
id: r,
|
|
42
|
+
style: c,
|
|
43
|
+
tabIndex: M,
|
|
44
|
+
disabled: y,
|
|
45
|
+
size: h,
|
|
46
|
+
className: O,
|
|
47
|
+
ariaDescribedBy: P,
|
|
48
|
+
ariaLabelledBy: E,
|
|
49
|
+
ariaLabel: T,
|
|
50
|
+
selection: x = m.selection,
|
|
51
|
+
value: f = m.defaultValue,
|
|
52
|
+
defaultData: z = m.defaultData,
|
|
53
|
+
valueField: p = m.valueField,
|
|
54
|
+
textField: S = m.textField,
|
|
55
|
+
onChange: b,
|
|
56
|
+
onDataChange: C
|
|
57
|
+
} = t, N = a.useMemo(
|
|
58
|
+
() => d || D,
|
|
59
|
+
[d, D]
|
|
60
|
+
);
|
|
61
|
+
a.useImperativeHandle(s, () => ({
|
|
62
|
+
element: l.current,
|
|
63
|
+
props: t
|
|
64
|
+
})), a.useImperativeHandle(i, () => s.current);
|
|
65
|
+
const w = a.useCallback(
|
|
66
|
+
(n, u) => {
|
|
67
|
+
b && s.current && b.call(void 0, {
|
|
68
|
+
value: n,
|
|
69
|
+
target: s.current,
|
|
70
|
+
syntheticEvent: u
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
[b]
|
|
74
|
+
), [F, A] = ie(
|
|
75
|
+
f || t.defaultValue,
|
|
76
|
+
{
|
|
77
|
+
selection: x,
|
|
78
|
+
state: f
|
|
79
|
+
},
|
|
80
|
+
w
|
|
81
|
+
), B = a.useCallback(
|
|
82
|
+
(n, u) => {
|
|
83
|
+
C && s.current && C.call(void 0, {
|
|
84
|
+
value: n,
|
|
85
|
+
target: s.current,
|
|
86
|
+
syntheticEvent: u
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
[C]
|
|
90
|
+
), [k, j] = oe(
|
|
91
|
+
t.data || z,
|
|
92
|
+
{
|
|
93
|
+
state: t.data,
|
|
94
|
+
valueField: p
|
|
95
|
+
},
|
|
96
|
+
B
|
|
97
|
+
), L = a.useCallback(
|
|
98
|
+
(n, u) => (n.push(u[p]), n),
|
|
99
|
+
[p]
|
|
100
|
+
), v = a.useMemo(
|
|
101
|
+
() => t.data || k,
|
|
102
|
+
[t.data, k]
|
|
103
|
+
), G = a.useMemo(
|
|
104
|
+
() => f || F,
|
|
105
|
+
[f, F]
|
|
106
|
+
), H = a.useMemo(
|
|
107
|
+
() => v.reduce(L, []),
|
|
108
|
+
[v, L]
|
|
109
|
+
), R = a.useCallback(
|
|
110
|
+
(n) => I(p)(n),
|
|
111
|
+
[p]
|
|
112
|
+
), K = a.useCallback(
|
|
113
|
+
(n) => I(S)(n),
|
|
114
|
+
[S]
|
|
115
|
+
), [$, q] = le({ items: H }), J = W(t, s);
|
|
116
|
+
return /* @__PURE__ */ a.createElement(te.Provider, { value: [G, A] }, /* @__PURE__ */ a.createElement(ae.Provider, { value: [$, q] }, /* @__PURE__ */ a.createElement(ne.Provider, { value: [v, j] }, /* @__PURE__ */ a.createElement(
|
|
117
|
+
"div",
|
|
118
|
+
{
|
|
119
|
+
ref: l,
|
|
120
|
+
...J,
|
|
121
|
+
role: y ? void 0 : "listbox",
|
|
122
|
+
id: r,
|
|
123
|
+
dir: o,
|
|
124
|
+
style: c,
|
|
125
|
+
tabIndex: X(M, y, void 0),
|
|
126
|
+
className: Y(
|
|
127
|
+
"k-chip-list",
|
|
128
|
+
{
|
|
129
|
+
"k-rtl": o === "rtl",
|
|
130
|
+
"k-disabled": y,
|
|
131
|
+
[`k-chip-list-${Z.sizeMap[h] || h}`]: h
|
|
132
|
+
},
|
|
133
|
+
O
|
|
134
|
+
),
|
|
135
|
+
"aria-label": T,
|
|
136
|
+
"aria-labelledby": E,
|
|
137
|
+
"aria-describedby": P,
|
|
138
|
+
"aria-orientation": "horizontal",
|
|
139
|
+
"aria-multiselectable": x === "multiple"
|
|
140
|
+
},
|
|
141
|
+
v.map((n, u) => /* @__PURE__ */ a.createElement(
|
|
142
|
+
N,
|
|
143
|
+
{
|
|
144
|
+
role: "option",
|
|
145
|
+
dataItem: n,
|
|
146
|
+
size: h,
|
|
147
|
+
key: [R(n), u].join("-"),
|
|
148
|
+
text: K(n),
|
|
149
|
+
value: R(n),
|
|
150
|
+
ariaLabel: n.ariaLabel,
|
|
151
|
+
svgIcon: n.svgIcon || void 0
|
|
152
|
+
}
|
|
153
|
+
))
|
|
154
|
+
))));
|
|
155
|
+
}), re = {
|
|
156
|
+
id: e.string,
|
|
157
|
+
className: e.string,
|
|
158
|
+
tabIndex: e.number,
|
|
159
|
+
data: e.any,
|
|
160
|
+
defaultData: e.arrayOf(e.any),
|
|
161
|
+
onDataChange: e.func,
|
|
162
|
+
value: e.oneOfType([e.any, e.arrayOf(e.any)]),
|
|
163
|
+
defaultValue: e.oneOfType([e.any, e.arrayOf(e.any)]),
|
|
164
|
+
onChange: e.func,
|
|
165
|
+
selection: e.oneOf(["single", "none", "multiple"]),
|
|
166
|
+
textField: e.string,
|
|
167
|
+
valueField: e.string,
|
|
168
|
+
disabled: e.bool,
|
|
169
|
+
dir: e.oneOf(["ltr", "rtl"]),
|
|
170
|
+
ariaLabelledBy: e.string,
|
|
171
|
+
ariaDescribedBy: e.string,
|
|
172
|
+
size: e.oneOf([null, "small", "medium", "large"])
|
|
173
|
+
}, m = {
|
|
174
|
+
chip: D,
|
|
175
|
+
size: "medium",
|
|
176
|
+
disabled: !1,
|
|
177
|
+
defaultValue: null,
|
|
178
|
+
defaultData: [],
|
|
179
|
+
dir: "ltr",
|
|
180
|
+
selection: "none",
|
|
181
|
+
textField: "text",
|
|
182
|
+
valueField: "value",
|
|
183
|
+
removable: "removable"
|
|
184
|
+
};
|
|
185
|
+
g.displayName = "KendoReactChipList";
|
|
186
|
+
g.propTypes = re;
|
|
187
|
+
g.defaultProps = m;
|
|
188
|
+
export {
|
|
189
|
+
g as ChipList
|
|
190
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),n=t.createContext([null,e=>{}]),o=t.createContext([null,e=>{}]),i=t.createContext([null,e=>{}]);exports.ChipListDataContext=i;exports.ChipListFocusContext=o;exports.ChipListSelectionContext=n;
|