@progress/kendo-react-listbox 6.1.1 → 7.0.0-develop.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/LICENSE.md +1 -1
- package/{dist/es/ListBox.d.ts → ListBox.d.ts} +5 -1
- package/{dist/npm/ListBoxToolbar.d.ts → ListBoxToolbar.d.ts} +5 -1
- package/dist/cdn/js/kendo-react-listbox.js +5 -1
- package/index.d.ts +11 -0
- package/index.js +5 -0
- package/index.mjs +294 -0
- package/interfaces/Enums.d.ts +11 -0
- package/{dist/es/interfaces → interfaces}/ListBoxEvents.d.ts +4 -0
- package/{dist/es/interfaces → interfaces}/ListBoxProps.d.ts +4 -0
- package/{dist/es/interfaces → interfaces}/ListBoxToolBarProps.d.ts +4 -0
- package/{dist/es/messages → messages}/index.d.ts +4 -0
- package/package-metadata.d.ts +9 -0
- package/package.json +28 -34
- package/{dist/npm/utils.d.ts → utils.d.ts} +4 -0
- package/about.md +0 -3
- package/dist/es/ListBox.js +0 -141
- package/dist/es/ListBoxToolbar.d.ts +0 -32
- package/dist/es/ListBoxToolbar.js +0 -172
- package/dist/es/interfaces/Enums.d.ts +0 -7
- package/dist/es/interfaces/Enums.js +0 -8
- package/dist/es/interfaces/ListBoxEvents.js +0 -1
- package/dist/es/interfaces/ListBoxProps.js +0 -2
- package/dist/es/interfaces/ListBoxToolBarProps.js +0 -1
- package/dist/es/main.d.ts +0 -7
- package/dist/es/main.js +0 -4
- package/dist/es/messages/index.js +0 -41
- package/dist/es/package-metadata.d.ts +0 -5
- package/dist/es/package-metadata.js +0 -11
- package/dist/es/utils.d.ts +0 -31
- package/dist/es/utils.js +0 -169
- package/dist/npm/ListBox.d.ts +0 -36
- package/dist/npm/ListBox.js +0 -144
- package/dist/npm/ListBoxToolbar.js +0 -175
- package/dist/npm/interfaces/Enums.d.ts +0 -7
- package/dist/npm/interfaces/Enums.js +0 -11
- package/dist/npm/interfaces/ListBoxEvents.d.ts +0 -16
- package/dist/npm/interfaces/ListBoxEvents.js +0 -2
- package/dist/npm/interfaces/ListBoxProps.d.ts +0 -90
- package/dist/npm/interfaces/ListBoxProps.js +0 -3
- package/dist/npm/interfaces/ListBoxToolBarProps.d.ts +0 -36
- package/dist/npm/interfaces/ListBoxToolBarProps.js +0 -2
- package/dist/npm/main.d.ts +0 -7
- package/dist/npm/main.js +0 -11
- package/dist/npm/messages/index.d.ts +0 -40
- package/dist/npm/messages/index.js +0 -44
- package/dist/npm/package-metadata.d.ts +0 -5
- package/dist/npm/package-metadata.js +0 -14
- package/dist/npm/utils.js +0 -175
- package/dist/systemjs/kendo-react-listbox.js +0 -1
- package/e2e-next/basic.tests.ts +0 -24
package/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2023 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { ListBox } from './ListBox';
|
|
6
|
+
import { type ListBoxProps } from './interfaces/ListBoxProps';
|
|
7
|
+
import { ListBoxToolbar } from './ListBoxToolbar';
|
|
8
|
+
import { type ListBoxToolbarProps } from './interfaces/ListBoxToolBarProps';
|
|
9
|
+
import { processListBoxData, moveItem, processListBoxDragAndDrop } from './utils';
|
|
10
|
+
import { type ListBoxDragEvent, type ListBoxItemClickEvent, type ListBoxKeyDownEvent, type ListBoxToolbarClickEvent } from './interfaces/ListBoxEvents';
|
|
11
|
+
export { ListBox, ListBoxProps, ListBoxToolbar, ListBoxToolbarProps, processListBoxData, moveItem, processListBoxDragAndDrop, ListBoxDragEvent, ListBoxItemClickEvent, ListBoxKeyDownEvent, ListBoxToolbarClickEvent };
|
package/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2023 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
5
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("react"),y=require("prop-types"),d=require("@progress/kendo-react-common"),A=require("@progress/kendo-react-buttons"),N=require("@progress/kendo-react-intl"),h=require("@progress/kendo-svg-icons");function C(o){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const t in o)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>o[t]})}}return e.default=o,Object.freeze(e)}const p=C(x),m=C(y);var I=(o=>(o.TOP="top",o.BOTTOM="bottom",o.LEFT="left",o.RIGHT="right",o.NONE="none",o))(I||{});const S={name:"@progress/kendo-react-listbox",productName:"KendoReact",productCodes:["KENDOUIREACT","KENDOUICOMPLETE"],publishDate:1607357111,version:"",licensingDocsUrl:"https://www.telerik.com/kendo-react-ui/components/my-license/"};class k extends p.PureComponent{constructor(e){super(e),this.setSelected=t=>{if(this.props.selectedField)return!!t[this.props.selectedField]},this.renderItem=t=>this.props.textField?t[this.props.textField]:t.toString(),this.handleKeyDown=t=>{this.props.onKeyDown&&d.dispatchEvent(this.props.onKeyDown,t,this,void 0)},this.handleContainerDrop=t=>{t.target.classList.contains("k-list-scroller")&&(this.props.data.length>0?d.dispatchEvent(this.props.onDrop,t,this,{dataItem:this.props.data[this.props.data.length-1]}):d.dispatchEvent(this.props.onDrop,t,this,{dataItem:null}))},this.setToolbarPosition=()=>this.props.toolbarPosition===I.NONE||this.props.toolbar===void 0?"":`k-listbox-actions-${this.props.toolbarPosition}`,this.handleOnDragLeave=t=>{this.props.onDragLeave&&t.target.classList.contains("k-list-scroller")&&d.dispatchEvent(this.props.onDragLeave,t,this,void 0)},d.validatePackage(S)}render(){return p.createElement("div",{className:d.classNames(this.props.className,"k-listbox",this.setToolbarPosition()),style:this.props.style,unselectable:"on"},this.props.toolbar&&this.props.toolbarPosition!=="bottom"&&p.createElement(this.props.toolbar,null),p.createElement("div",{className:"k-list-scroller k-selectable","data-role":"selectable",onDragOver:e=>e.preventDefault(),onDrop:this.handleContainerDrop,onDragLeave:this.handleOnDragLeave},p.createElement("div",{className:d.classNames("k-list",{[`k-list-${d.kendoThemeMaps.sizeMap[this.props.size]||this.props.size}`]:this.props.size})},p.createElement("div",{className:"k-list-content"},p.createElement("ul",{className:"k-list-ul",role:"listbox","aria-label":"listbox-container",tabIndex:0,onKeyDown:this.handleKeyDown},this.props.data.map((e,t)=>{const r=this.setSelected(e),a=d.guid(),c={className:d.classNames("k-list-item",{"k-selected":r}),role:"option","aria-selected":r,key:t,id:a+t,"data-uid":a+t,draggable:this.props.draggable,onDragStart:s=>d.dispatchEvent(this.props.onDragStart,s,this,{dataItem:e}),onDragOver:s=>{s.preventDefault(),d.dispatchEvent(this.props.onDragOver,s,this,{dataItem:e})},onDrop:s=>d.dispatchEvent(this.props.onDrop,s,this,{dataItem:e}),onClick:s=>d.dispatchEvent(this.props.onItemClick,s,this,{dataItem:e})};return this.props.item?p.createElement(this.props.item,{selected:r,dataItem:e,...c},p.createElement("span",{className:"k-list-item-text"},e.name)):p.createElement("li",{...c},p.createElement("span",{className:"k-list-item-text"},this.renderItem(e)))}))))),this.props.toolbar&&this.props.toolbarPosition==="bottom"&&p.createElement(this.props.toolbar,null),p.createElement("select",{style:{display:"none"},multiple:!0,"data-role":"listbox"},this.props.data.map((e,t)=>{const r=e[this.props.valueField||this.props.textField];return p.createElement("option",{key:t,value:r},r)})))}}k.propTypes={size:m.oneOf([null,"small","medium","large"]),toolbarPosition:m.oneOf(["none","top","bottom","left","right"]),textField:m.string,valueField:m.string,selectedField:m.string,data:m.array};k.defaultProps={toolbarPosition:I.RIGHT,draggable:!0,size:"medium"};const w="listbox.moveUp",F="listbox.moveDown",O="listbox.transferTo",P="listbox.transferFrom",R="listbox.transferAllTo",z="listbox.transferAllFrom",U="listbox.remove",K={[w]:"Move Up",[F]:"Move Down",[O]:"Transfer To",[P]:"Transfer From",[R]:"Transfer All To",[z]:"Transfer All From",[U]:"Delete"},L=[{name:"moveUp",iconName:"caret-alt-up",svgIcon:h.caretAltUpIcon},{name:"moveDown",iconName:"caret-alt-down",svgIcon:h.caretAltDownIcon},{name:"transferTo",iconName:"caret-alt-right",svgIcon:h.caretAltRightIcon},{name:"transferFrom",iconName:"caret-alt-left",svgIcon:h.caretAltLeftIcon},{name:"transferAllTo",iconName:"caret-double-alt-right",svgIcon:h.caretDoubleAltRightIcon},{name:"transferAllFrom",iconName:"caret-double-alt-left",svgIcon:h.caretDoubleAltLeftIcon},{name:"remove",iconName:"x",svgIcon:h.xIcon}];class v extends p.PureComponent{constructor(){super(...arguments),this.checkSvgIcon=e=>{switch(e.name){case"caret-alt-right":return h.caretAltLeftIcon;case"caret-alt-left":return h.caretAltRightIcon;case"caret-double-alt-right":return h.caretDoubleAltLeftIcon;case"caret-double-alt-left":return h.caretDoubleAltRightIcon}return e},this.checkFontIcon=e=>{switch(e){case"caret-alt-right":return"caret-alt-left";case"caret-alt-left":return"caret-alt-right";case"caret-double-alt-right":return"caret-double-alt-left";case"caret-double-alt-left":return"caret-double-alt-right"}return e},this.handleToolClick=(e,t)=>{d.dispatchEvent(this.props.onToolClick,e,this,{toolName:t})},this.isItemDisabled=e=>{let t=!0;const r=this.props.selectedField||"selected",a=this.props.data.length,c=this.props.dataConnected.length,s=this.props.data.findIndex(n=>n[r]===!0)>=0,i=this.props.dataConnected.findIndex(n=>n[r]===!0)>=0;switch(e){case"moveUp":s?t=this.props.data.length>0?this.props.data[0].selected:!0:i?t=this.props.dataConnected.length>0?this.props.dataConnected[0].selected:!0:t=!0;break;case"moveDown":s?t=this.props.data[a-1]?this.props.data[a-1].selected:!0:i?t=this.props.dataConnected.length>0?this.props.dataConnected[c-1].selected:!0:t=!0;break;case"transferTo":t=!(this.props.dataConnected&&s);break;case"transferFrom":this.props.dataConnected?t=!(this.props.dataConnected&&i):t=!0;break;case"transferAllTo":t=!(this.props.dataConnected&&this.props.data.length>0);break;case"transferAllFrom":t=!(this.props.dataConnected&&this.props.dataConnected.length>0);break;case"remove":t=!(s||i);break}return t}}get isRtl(){return this.props.dir==="rtl"}render(){const e=N.provideLocalizationService(this);return p.createElement("div",{className:d.classNames("k-listbox-actions")},this.props.tools&&this.props.tools.map((t,r)=>{const a=L.findIndex(l=>l.name===t),c=L[a],s=this.isItemDisabled(c.name),i=`listbox.${c.name}`,n=e.toLanguageString(i,K[i]);return p.createElement(A.Button,{key:r,disabled:s,"data-command":c.name,title:n,"aria-label":n,icon:this.isRtl?this.checkFontIcon(c.iconName):c.iconName,svgIcon:this.isRtl?this.checkSvgIcon(c.svgIcon):c.svgIcon,onClick:l=>{l.preventDefault(),this.handleToolClick(l,c.name||null)}})}))}}v.propTypes={data:m.array,dataConnected:m.array,tools:m.array,selectedField:m.string,dir:m.string};v.defaultProps={data:[],dataConnected:[],selectedField:"selected"};N.registerForLocalization(v);const M=(o=[],e=[],t,r)=>{let a=[],c=[],s=[];const i={listBoxOneData:o,listBoxTwoData:e};switch(t){case"moveUp":a=[...o],a.forEach((n,l)=>{n[r]&&(a=f(l,l-1,a))}),s=[...e],s.forEach((n,l)=>{n[r]&&(s=f(l,l-1,s))}),i.listBoxOneData=a,i.listBoxTwoData=s;break;case"moveDown":a=o.reverse(),a.forEach((n,l)=>{n[r]&&(a=f(l,l-1,a))}),s=e.reverse(),s.forEach((n,l)=>{n[r]&&(s=f(l,l-1,s))}),i.listBoxOneData=[...a].reverse(),i.listBoxTwoData=[...s].reverse();break;case"transferTo":a=o.filter(n=>!n[r]),c=o.filter(n=>n[r]),s=e.concat(c),i.listBoxOneData=a,i.listBoxTwoData=s;break;case"transferFrom":s=e.filter(n=>!n[r]),c=e.filter(n=>n[r]),a=o.concat(c),i.listBoxOneData=a,i.listBoxTwoData=s;break;case"transferAllTo":i.listBoxOneData=[],i.listBoxTwoData=e.concat(o);break;case"transferAllFrom":i.listBoxOneData=e.concat(o),i.listBoxTwoData=[];break;case"remove":s=e.filter(n=>!n[r]),a=o.filter(n=>!n[r]),i.listBoxOneData=a,i.listBoxTwoData=s;break}return i},f=(o,e,t)=>{const r=t.splice(o,1)[0];return t.splice(e,0,r),t},q=(o=[],e=[],t,r,a)=>{const c=o.findIndex(u=>u[a]===t[a]),s=e.findIndex(u=>u[a]===t[a]),i=r!==null?o.findIndex(u=>u[a]===r[a]):-1,n=r!==null?e.findIndex(u=>u[a]===r[a]):-1,l=c>=0,D=s>=0,T=i>=0,E=n>=0,g=[...o],b=[...e];return l&&T?{listBoxOneData:f(c,i,o),listBoxTwoData:e}:D&&E?{listBoxOneData:o,listBoxTwoData:f(s,n,e)}:l&&(E||r===null)?(r===null?b.push(o[c]):b.splice(n+1,0,o[c]),g.splice(c,1),{listBoxOneData:g,listBoxTwoData:b}):D&&(T||r===null)?(r===null?g.push(e[s]):g.splice(i+1,0,e[s]),b.splice(s,1),{listBoxOneData:g,listBoxTwoData:b}):{listBoxOneData:o,listBoxTwoData:e}};exports.ListBox=k;exports.ListBoxToolbar=v;exports.moveItem=f;exports.processListBoxData=M;exports.processListBoxDragAndDrop=q;
|
package/index.mjs
ADDED
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2023 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
5
|
+
import * as p from "react";
|
|
6
|
+
import * as d from "prop-types";
|
|
7
|
+
import { dispatchEvent as h, validatePackage as A, classNames as b, kendoThemeMaps as F, guid as S } from "@progress/kendo-react-common";
|
|
8
|
+
import { Button as w } from "@progress/kendo-react-buttons";
|
|
9
|
+
import { provideLocalizationService as O, registerForLocalization as P } from "@progress/kendo-react-intl";
|
|
10
|
+
import { caretDoubleAltRightIcon as E, caretDoubleAltLeftIcon as L, caretAltRightIcon as N, caretAltLeftIcon as x, caretAltUpIcon as R, caretAltDownIcon as U, xIcon as z } from "@progress/kendo-svg-icons";
|
|
11
|
+
var I = /* @__PURE__ */ ((n) => (n.TOP = "top", n.BOTTOM = "bottom", n.LEFT = "left", n.RIGHT = "right", n.NONE = "none", n))(I || {});
|
|
12
|
+
const K = {
|
|
13
|
+
name: "@progress/kendo-react-listbox",
|
|
14
|
+
productName: "KendoReact",
|
|
15
|
+
productCodes: ["KENDOUIREACT", "KENDOUICOMPLETE"],
|
|
16
|
+
publishDate: 1700573622,
|
|
17
|
+
version: "",
|
|
18
|
+
licensingDocsUrl: "https://www.telerik.com/kendo-react-ui/components/my-license/"
|
|
19
|
+
};
|
|
20
|
+
class y extends p.PureComponent {
|
|
21
|
+
constructor(e) {
|
|
22
|
+
super(e), this.setSelected = (t) => {
|
|
23
|
+
if (this.props.selectedField)
|
|
24
|
+
return !!t[this.props.selectedField];
|
|
25
|
+
}, this.renderItem = (t) => this.props.textField ? t[this.props.textField] : t.toString(), this.handleKeyDown = (t) => {
|
|
26
|
+
this.props.onKeyDown && h(this.props.onKeyDown, t, this, void 0);
|
|
27
|
+
}, this.handleContainerDrop = (t) => {
|
|
28
|
+
t.target.classList.contains("k-list-scroller") && (this.props.data.length > 0 ? h(this.props.onDrop, t, this, { dataItem: this.props.data[this.props.data.length - 1] }) : h(this.props.onDrop, t, this, { dataItem: null }));
|
|
29
|
+
}, this.setToolbarPosition = () => this.props.toolbarPosition === I.NONE || this.props.toolbar === void 0 ? "" : `k-listbox-actions-${this.props.toolbarPosition}`, this.handleOnDragLeave = (t) => {
|
|
30
|
+
this.props.onDragLeave && t.target.classList.contains("k-list-scroller") && h(this.props.onDragLeave, t, this, void 0);
|
|
31
|
+
}, A(K);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* @hidden
|
|
35
|
+
*/
|
|
36
|
+
render() {
|
|
37
|
+
return /* @__PURE__ */ p.createElement(
|
|
38
|
+
"div",
|
|
39
|
+
{
|
|
40
|
+
className: b(
|
|
41
|
+
this.props.className,
|
|
42
|
+
"k-listbox",
|
|
43
|
+
this.setToolbarPosition()
|
|
44
|
+
),
|
|
45
|
+
style: this.props.style,
|
|
46
|
+
unselectable: "on"
|
|
47
|
+
},
|
|
48
|
+
this.props.toolbar && this.props.toolbarPosition !== "bottom" && /* @__PURE__ */ p.createElement(this.props.toolbar, null),
|
|
49
|
+
/* @__PURE__ */ p.createElement(
|
|
50
|
+
"div",
|
|
51
|
+
{
|
|
52
|
+
className: "k-list-scroller k-selectable",
|
|
53
|
+
"data-role": "selectable",
|
|
54
|
+
onDragOver: (e) => e.preventDefault(),
|
|
55
|
+
onDrop: this.handleContainerDrop,
|
|
56
|
+
onDragLeave: this.handleOnDragLeave
|
|
57
|
+
},
|
|
58
|
+
/* @__PURE__ */ p.createElement("div", { className: b("k-list", {
|
|
59
|
+
[`k-list-${F.sizeMap[this.props.size] || this.props.size}`]: this.props.size
|
|
60
|
+
}) }, /* @__PURE__ */ p.createElement("div", { className: "k-list-content" }, /* @__PURE__ */ p.createElement("ul", { className: "k-list-ul", role: "listbox", "aria-label": "listbox-container", tabIndex: 0, onKeyDown: this.handleKeyDown }, this.props.data.map((e, t) => {
|
|
61
|
+
const r = this.setSelected(e), o = S(), l = {
|
|
62
|
+
className: b(
|
|
63
|
+
"k-list-item",
|
|
64
|
+
{
|
|
65
|
+
"k-selected": r
|
|
66
|
+
}
|
|
67
|
+
),
|
|
68
|
+
role: "option",
|
|
69
|
+
"aria-selected": r,
|
|
70
|
+
key: t,
|
|
71
|
+
id: o + t,
|
|
72
|
+
"data-uid": o + t,
|
|
73
|
+
draggable: this.props.draggable,
|
|
74
|
+
onDragStart: (s) => h(this.props.onDragStart, s, this, { dataItem: e }),
|
|
75
|
+
onDragOver: (s) => {
|
|
76
|
+
s.preventDefault(), h(this.props.onDragOver, s, this, { dataItem: e });
|
|
77
|
+
},
|
|
78
|
+
onDrop: (s) => h(this.props.onDrop, s, this, { dataItem: e }),
|
|
79
|
+
onClick: (s) => h(this.props.onItemClick, s, this, { dataItem: e })
|
|
80
|
+
};
|
|
81
|
+
return this.props.item ? /* @__PURE__ */ p.createElement(this.props.item, { selected: r, dataItem: e, ...l }, /* @__PURE__ */ p.createElement("span", { className: "k-list-item-text" }, e.name)) : /* @__PURE__ */ p.createElement("li", { ...l }, /* @__PURE__ */ p.createElement("span", { className: "k-list-item-text" }, this.renderItem(e)));
|
|
82
|
+
}))))
|
|
83
|
+
),
|
|
84
|
+
this.props.toolbar && this.props.toolbarPosition === "bottom" && /* @__PURE__ */ p.createElement(this.props.toolbar, null),
|
|
85
|
+
/* @__PURE__ */ p.createElement("select", { style: { display: "none" }, multiple: !0, "data-role": "listbox" }, this.props.data.map((e, t) => {
|
|
86
|
+
const r = e[this.props.valueField || this.props.textField];
|
|
87
|
+
return /* @__PURE__ */ p.createElement("option", { key: t, value: r }, r);
|
|
88
|
+
}))
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
y.propTypes = {
|
|
93
|
+
size: d.oneOf([null, "small", "medium", "large"]),
|
|
94
|
+
toolbarPosition: d.oneOf(["none", "top", "bottom", "left", "right"]),
|
|
95
|
+
textField: d.string,
|
|
96
|
+
valueField: d.string,
|
|
97
|
+
selectedField: d.string,
|
|
98
|
+
data: d.array
|
|
99
|
+
};
|
|
100
|
+
y.defaultProps = {
|
|
101
|
+
toolbarPosition: I.RIGHT,
|
|
102
|
+
draggable: !0,
|
|
103
|
+
size: "medium"
|
|
104
|
+
};
|
|
105
|
+
const M = "listbox.moveUp", G = "listbox.moveDown", $ = "listbox.transferTo", H = "listbox.transferFrom", V = "listbox.transferAllTo", j = "listbox.transferAllFrom", q = "listbox.remove", J = {
|
|
106
|
+
[M]: "Move Up",
|
|
107
|
+
[G]: "Move Down",
|
|
108
|
+
[$]: "Transfer To",
|
|
109
|
+
[H]: "Transfer From",
|
|
110
|
+
[V]: "Transfer All To",
|
|
111
|
+
[j]: "Transfer All From",
|
|
112
|
+
[q]: "Delete"
|
|
113
|
+
}, C = [
|
|
114
|
+
{ name: "moveUp", iconName: "caret-alt-up", svgIcon: R },
|
|
115
|
+
{ name: "moveDown", iconName: "caret-alt-down", svgIcon: U },
|
|
116
|
+
{ name: "transferTo", iconName: "caret-alt-right", svgIcon: N },
|
|
117
|
+
{ name: "transferFrom", iconName: "caret-alt-left", svgIcon: x },
|
|
118
|
+
{ name: "transferAllTo", iconName: "caret-double-alt-right", svgIcon: E },
|
|
119
|
+
{ name: "transferAllFrom", iconName: "caret-double-alt-left", svgIcon: L },
|
|
120
|
+
{ name: "remove", iconName: "x", svgIcon: z }
|
|
121
|
+
];
|
|
122
|
+
class v extends p.PureComponent {
|
|
123
|
+
constructor() {
|
|
124
|
+
super(...arguments), this.checkSvgIcon = (e) => {
|
|
125
|
+
switch (e.name) {
|
|
126
|
+
case "caret-alt-right":
|
|
127
|
+
return x;
|
|
128
|
+
case "caret-alt-left":
|
|
129
|
+
return N;
|
|
130
|
+
case "caret-double-alt-right":
|
|
131
|
+
return L;
|
|
132
|
+
case "caret-double-alt-left":
|
|
133
|
+
return E;
|
|
134
|
+
}
|
|
135
|
+
return e;
|
|
136
|
+
}, this.checkFontIcon = (e) => {
|
|
137
|
+
switch (e) {
|
|
138
|
+
case "caret-alt-right":
|
|
139
|
+
return "caret-alt-left";
|
|
140
|
+
case "caret-alt-left":
|
|
141
|
+
return "caret-alt-right";
|
|
142
|
+
case "caret-double-alt-right":
|
|
143
|
+
return "caret-double-alt-left";
|
|
144
|
+
case "caret-double-alt-left":
|
|
145
|
+
return "caret-double-alt-right";
|
|
146
|
+
}
|
|
147
|
+
return e;
|
|
148
|
+
}, this.handleToolClick = (e, t) => {
|
|
149
|
+
h(this.props.onToolClick, e, this, { toolName: t });
|
|
150
|
+
}, this.isItemDisabled = (e) => {
|
|
151
|
+
let t = !0;
|
|
152
|
+
const r = this.props.selectedField || "selected", o = this.props.data.length, l = this.props.dataConnected.length, s = this.props.data.findIndex((a) => a[r] === !0) >= 0, i = this.props.dataConnected.findIndex((a) => a[r] === !0) >= 0;
|
|
153
|
+
switch (e) {
|
|
154
|
+
case "moveUp":
|
|
155
|
+
s ? t = this.props.data.length > 0 ? this.props.data[0].selected : !0 : i ? t = this.props.dataConnected.length > 0 ? this.props.dataConnected[0].selected : !0 : t = !0;
|
|
156
|
+
break;
|
|
157
|
+
case "moveDown":
|
|
158
|
+
s ? t = this.props.data[o - 1] ? this.props.data[o - 1].selected : !0 : i ? t = this.props.dataConnected.length > 0 ? this.props.dataConnected[l - 1].selected : !0 : t = !0;
|
|
159
|
+
break;
|
|
160
|
+
case "transferTo":
|
|
161
|
+
t = !(this.props.dataConnected && s);
|
|
162
|
+
break;
|
|
163
|
+
case "transferFrom":
|
|
164
|
+
this.props.dataConnected ? t = !(this.props.dataConnected && i) : t = !0;
|
|
165
|
+
break;
|
|
166
|
+
case "transferAllTo":
|
|
167
|
+
t = !(this.props.dataConnected && this.props.data.length > 0);
|
|
168
|
+
break;
|
|
169
|
+
case "transferAllFrom":
|
|
170
|
+
t = !(this.props.dataConnected && this.props.dataConnected.length > 0);
|
|
171
|
+
break;
|
|
172
|
+
case "remove":
|
|
173
|
+
t = !(s || i);
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
return t;
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
get isRtl() {
|
|
180
|
+
return this.props.dir === "rtl";
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* @hidden
|
|
184
|
+
*/
|
|
185
|
+
render() {
|
|
186
|
+
const e = O(this);
|
|
187
|
+
return /* @__PURE__ */ p.createElement(
|
|
188
|
+
"div",
|
|
189
|
+
{
|
|
190
|
+
className: b(
|
|
191
|
+
"k-listbox-actions"
|
|
192
|
+
)
|
|
193
|
+
},
|
|
194
|
+
this.props.tools && this.props.tools.map((t, r) => {
|
|
195
|
+
const o = C.findIndex((c) => c.name === t), l = C[o], s = this.isItemDisabled(l.name), i = `listbox.${l.name}`, a = e.toLanguageString(i, J[i]);
|
|
196
|
+
return /* @__PURE__ */ p.createElement(
|
|
197
|
+
w,
|
|
198
|
+
{
|
|
199
|
+
key: r,
|
|
200
|
+
disabled: s,
|
|
201
|
+
"data-command": l.name,
|
|
202
|
+
title: a,
|
|
203
|
+
"aria-label": a,
|
|
204
|
+
icon: this.isRtl ? this.checkFontIcon(l.iconName) : l.iconName,
|
|
205
|
+
svgIcon: this.isRtl ? this.checkSvgIcon(l.svgIcon) : l.svgIcon,
|
|
206
|
+
onClick: (c) => {
|
|
207
|
+
c.preventDefault(), this.handleToolClick(c, l.name || null);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
);
|
|
211
|
+
})
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
v.propTypes = {
|
|
216
|
+
data: d.array,
|
|
217
|
+
dataConnected: d.array,
|
|
218
|
+
tools: d.array,
|
|
219
|
+
selectedField: d.string,
|
|
220
|
+
dir: d.string
|
|
221
|
+
};
|
|
222
|
+
v.defaultProps = {
|
|
223
|
+
data: [],
|
|
224
|
+
dataConnected: [],
|
|
225
|
+
selectedField: "selected"
|
|
226
|
+
};
|
|
227
|
+
P(v);
|
|
228
|
+
const Z = (n = [], e = [], t, r) => {
|
|
229
|
+
let o = [], l = [], s = [];
|
|
230
|
+
const i = {
|
|
231
|
+
listBoxOneData: n,
|
|
232
|
+
listBoxTwoData: e
|
|
233
|
+
};
|
|
234
|
+
switch (t) {
|
|
235
|
+
case "moveUp":
|
|
236
|
+
o = [...n], o.forEach((a, c) => {
|
|
237
|
+
a[r] && (o = u(c, c - 1, o));
|
|
238
|
+
}), s = [...e], s.forEach((a, c) => {
|
|
239
|
+
a[r] && (s = u(c, c - 1, s));
|
|
240
|
+
}), i.listBoxOneData = o, i.listBoxTwoData = s;
|
|
241
|
+
break;
|
|
242
|
+
case "moveDown":
|
|
243
|
+
o = n.reverse(), o.forEach((a, c) => {
|
|
244
|
+
a[r] && (o = u(c, c - 1, o));
|
|
245
|
+
}), s = e.reverse(), s.forEach((a, c) => {
|
|
246
|
+
a[r] && (s = u(c, c - 1, s));
|
|
247
|
+
}), i.listBoxOneData = [...o].reverse(), i.listBoxTwoData = [...s].reverse();
|
|
248
|
+
break;
|
|
249
|
+
case "transferTo":
|
|
250
|
+
o = n.filter((a) => !a[r]), l = n.filter((a) => a[r]), s = e.concat(l), i.listBoxOneData = o, i.listBoxTwoData = s;
|
|
251
|
+
break;
|
|
252
|
+
case "transferFrom":
|
|
253
|
+
s = e.filter((a) => !a[r]), l = e.filter((a) => a[r]), o = n.concat(l), i.listBoxOneData = o, i.listBoxTwoData = s;
|
|
254
|
+
break;
|
|
255
|
+
case "transferAllTo":
|
|
256
|
+
i.listBoxOneData = [], i.listBoxTwoData = e.concat(n);
|
|
257
|
+
break;
|
|
258
|
+
case "transferAllFrom":
|
|
259
|
+
i.listBoxOneData = e.concat(n), i.listBoxTwoData = [];
|
|
260
|
+
break;
|
|
261
|
+
case "remove":
|
|
262
|
+
s = e.filter((a) => !a[r]), o = n.filter((a) => !a[r]), i.listBoxOneData = o, i.listBoxTwoData = s;
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
return i;
|
|
266
|
+
}, u = (n, e, t) => {
|
|
267
|
+
const r = t.splice(n, 1)[0];
|
|
268
|
+
return t.splice(e, 0, r), t;
|
|
269
|
+
}, _ = (n = [], e = [], t, r, o) => {
|
|
270
|
+
const l = n.findIndex((m) => m[o] === t[o]), s = e.findIndex((m) => m[o] === t[o]), i = r !== null ? n.findIndex((m) => m[o] === r[o]) : -1, a = r !== null ? e.findIndex((m) => m[o] === r[o]) : -1, c = l >= 0, k = s >= 0, D = i >= 0, T = a >= 0, f = [...n], g = [...e];
|
|
271
|
+
return c && D ? {
|
|
272
|
+
listBoxOneData: u(l, i, n),
|
|
273
|
+
listBoxTwoData: e
|
|
274
|
+
} : k && T ? {
|
|
275
|
+
listBoxOneData: n,
|
|
276
|
+
listBoxTwoData: u(s, a, e)
|
|
277
|
+
} : c && (T || r === null) ? (r === null ? g.push(n[l]) : g.splice(a + 1, 0, n[l]), f.splice(l, 1), {
|
|
278
|
+
listBoxOneData: f,
|
|
279
|
+
listBoxTwoData: g
|
|
280
|
+
}) : k && (D || r === null) ? (r === null ? f.push(e[s]) : f.splice(i + 1, 0, e[s]), g.splice(s, 1), {
|
|
281
|
+
listBoxOneData: f,
|
|
282
|
+
listBoxTwoData: g
|
|
283
|
+
}) : {
|
|
284
|
+
listBoxOneData: n,
|
|
285
|
+
listBoxTwoData: e
|
|
286
|
+
};
|
|
287
|
+
};
|
|
288
|
+
export {
|
|
289
|
+
y as ListBox,
|
|
290
|
+
v as ListBoxToolbar,
|
|
291
|
+
u as moveItem,
|
|
292
|
+
Z as processListBoxData,
|
|
293
|
+
_ as processListBoxDragAndDrop
|
|
294
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2023 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
5
|
+
export declare enum toolbarPosition {
|
|
6
|
+
TOP = "top",
|
|
7
|
+
BOTTOM = "bottom",
|
|
8
|
+
LEFT = "left",
|
|
9
|
+
RIGHT = "right",
|
|
10
|
+
NONE = "none"
|
|
11
|
+
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2023 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
1
5
|
import { BaseEvent } from '@progress/kendo-react-common';
|
|
2
6
|
import { ListBox } from '../ListBox';
|
|
3
7
|
import { ListBoxToolbar } from '../ListBoxToolbar';
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2023 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
1
5
|
import { ComponentType } from 'react';
|
|
2
6
|
import { ListBoxItemClickEvent, ListBoxKeyDownEvent, ListBoxDragEvent, ListBoxDragLeaveEvent } from './ListBoxEvents';
|
|
3
7
|
import { toolbarPosition } from './Enums';
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2023 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
1
5
|
import { ListBoxToolbarClickEvent } from './ListBoxEvents';
|
|
2
6
|
export interface ListBoxToolbarProps {
|
|
3
7
|
/**
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2023 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
1
5
|
/**
|
|
2
6
|
* @hidden
|
|
3
7
|
*/
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2023 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { PackageMetadata } from '@progress/kendo-licensing';
|
|
6
|
+
/**
|
|
7
|
+
* @hidden
|
|
8
|
+
*/
|
|
9
|
+
export declare const packageMetadata: PackageMetadata;
|
package/package.json
CHANGED
|
@@ -1,20 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@progress/kendo-react-listbox",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-develop.2",
|
|
4
4
|
"description": "React ListBox enables you to display a list of items and manage the data between multiple lists. KendoReact ListBox package",
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
"author": "Progress",
|
|
6
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
7
|
+
"homepage": "https://www.telerik.com/kendo-react-ui",
|
|
8
|
+
"main": "./index.js",
|
|
9
|
+
"types": "./index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./index.mjs",
|
|
13
|
+
"require": "./index.js"
|
|
14
|
+
}
|
|
8
15
|
},
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"peerDependencies": {
|
|
18
|
+
"@progress/kendo-licensing": "^1.3.0",
|
|
19
|
+
"@progress/kendo-react-buttons": "7.0.0-develop.2",
|
|
20
|
+
"@progress/kendo-react-common": "7.0.0-develop.2",
|
|
21
|
+
"@progress/kendo-react-intl": "7.0.0-develop.2",
|
|
22
|
+
"@progress/kendo-svg-icons": "^2.0.0",
|
|
23
|
+
"react": "^16.8.2 || ^17.0.0 || ^18.0.0",
|
|
24
|
+
"react-dom": "^16.8.2 || ^17.0.0 || ^18.0.0"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"prop-types": "^15.6.0"
|
|
16
28
|
},
|
|
17
|
-
"homepage": "https://www.telerik.com/kendo-react-ui",
|
|
18
29
|
"keywords": [
|
|
19
30
|
"Kendo UI",
|
|
20
31
|
"React",
|
|
@@ -27,32 +38,15 @@
|
|
|
27
38
|
"React component",
|
|
28
39
|
"Telerik"
|
|
29
40
|
],
|
|
30
|
-
"peerDependencies": {
|
|
31
|
-
"@progress/kendo-licensing": "^1.3.0",
|
|
32
|
-
"@progress/kendo-react-buttons": "^6.0.0",
|
|
33
|
-
"@progress/kendo-react-intl": "^6.0.0",
|
|
34
|
-
"@progress/kendo-svg-icons": "^2.0.0",
|
|
35
|
-
"react": "^16.8.2 || ^17.0.0 || ^18.0.0",
|
|
36
|
-
"react-dom": "^16.8.2 || ^17.0.0 || ^18.0.0"
|
|
37
|
-
},
|
|
38
|
-
"dependencies": {
|
|
39
|
-
"@progress/kendo-react-common": "6.1.1",
|
|
40
|
-
"prop-types": "^15.6.0"
|
|
41
|
-
},
|
|
42
|
-
"devDependencies": {
|
|
43
|
-
"@progress/kendo-licensing": "^1.3.0",
|
|
44
|
-
"@progress/kendo-react-buttons": "6.1.1",
|
|
45
|
-
"@progress/kendo-react-intl": "6.1.1",
|
|
46
|
-
"@progress/kendo-svg-icons": "^2.0.0"
|
|
47
|
-
},
|
|
48
41
|
"@progress": {
|
|
49
42
|
"friendlyName": "ListBox",
|
|
50
43
|
"framework": "KendoReact"
|
|
51
44
|
},
|
|
52
|
-
"author": "Progress",
|
|
53
|
-
"license": "SEE LICENSE IN LICENSE.md",
|
|
54
45
|
"publishConfig": {
|
|
55
46
|
"access": "public"
|
|
56
47
|
},
|
|
57
|
-
"
|
|
58
|
-
|
|
48
|
+
"repository": {
|
|
49
|
+
"type": "git",
|
|
50
|
+
"url": "git+https://github.com/telerik/kendo-react.git"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2023 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
1
5
|
/**
|
|
2
6
|
* Process the data collection/s based on the clicked ListBoxToolbar tool.
|
|
3
7
|
*
|
package/about.md
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
<a href="https://www.telerik.com/kendo-react-ui?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-listbox&utm_content=banner" target="_blank">
|
|
2
|
-
<img src="https://www.telerik.com/kendo-react-ui/components/npm-banner.svg" alt="KendoReact NPM Banner">
|
|
3
|
-
</a>
|
package/dist/es/ListBox.js
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
var __extends = (this && this.__extends) || (function () {
|
|
2
|
-
var extendStatics = function (d, b) {
|
|
3
|
-
extendStatics = Object.setPrototypeOf ||
|
|
4
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
-
return extendStatics(d, b);
|
|
7
|
-
};
|
|
8
|
-
return function (d, b) {
|
|
9
|
-
if (typeof b !== "function" && b !== null)
|
|
10
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
-
extendStatics(d, b);
|
|
12
|
-
function __() { this.constructor = d; }
|
|
13
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
-
};
|
|
15
|
-
})();
|
|
16
|
-
var __assign = (this && this.__assign) || function () {
|
|
17
|
-
__assign = Object.assign || function(t) {
|
|
18
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
19
|
-
s = arguments[i];
|
|
20
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
21
|
-
t[p] = s[p];
|
|
22
|
-
}
|
|
23
|
-
return t;
|
|
24
|
-
};
|
|
25
|
-
return __assign.apply(this, arguments);
|
|
26
|
-
};
|
|
27
|
-
import * as React from 'react';
|
|
28
|
-
import * as PropTypes from 'prop-types';
|
|
29
|
-
import { classNames, guid, dispatchEvent, kendoThemeMaps } from '@progress/kendo-react-common';
|
|
30
|
-
import { toolbarPosition } from './interfaces/Enums';
|
|
31
|
-
import { validatePackage } from '@progress/kendo-react-common';
|
|
32
|
-
import { packageMetadata } from './package-metadata';
|
|
33
|
-
var ListBox = /** @class */ (function (_super) {
|
|
34
|
-
__extends(ListBox, _super);
|
|
35
|
-
function ListBox(props) {
|
|
36
|
-
var _this = _super.call(this, props) || this;
|
|
37
|
-
_this.setSelected = function (item) {
|
|
38
|
-
if (_this.props.selectedField) {
|
|
39
|
-
return item[_this.props.selectedField] ? true : false;
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
_this.renderItem = function (item) {
|
|
43
|
-
return _this.props.textField ? item[_this.props.textField] : item.toString();
|
|
44
|
-
};
|
|
45
|
-
_this.handleKeyDown = function (event) {
|
|
46
|
-
if (_this.props.onKeyDown) {
|
|
47
|
-
dispatchEvent(_this.props.onKeyDown, event, _this, undefined);
|
|
48
|
-
}
|
|
49
|
-
;
|
|
50
|
-
};
|
|
51
|
-
_this.handleContainerDrop = function (event) {
|
|
52
|
-
var targetElement = event.target;
|
|
53
|
-
var isTargetContainer = targetElement.classList.contains('k-list-scroller');
|
|
54
|
-
if (isTargetContainer) {
|
|
55
|
-
_this.props.data.length > 0 ?
|
|
56
|
-
dispatchEvent(_this.props.onDrop, event, _this, { dataItem: _this.props.data[_this.props.data.length - 1] }) :
|
|
57
|
-
dispatchEvent(_this.props.onDrop, event, _this, { dataItem: null });
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
_this.setToolbarPosition = function () {
|
|
61
|
-
if (_this.props.toolbarPosition === toolbarPosition.NONE || _this.props.toolbar === undefined) {
|
|
62
|
-
return '';
|
|
63
|
-
}
|
|
64
|
-
return "k-listbox-actions-".concat(_this.props.toolbarPosition);
|
|
65
|
-
};
|
|
66
|
-
_this.handleOnDragLeave = function (event) {
|
|
67
|
-
if (_this.props.onDragLeave && event.target.classList.contains('k-list-scroller')) {
|
|
68
|
-
dispatchEvent(_this.props.onDragLeave, event, _this, undefined);
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
validatePackage(packageMetadata);
|
|
72
|
-
return _this;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* @hidden
|
|
76
|
-
*/
|
|
77
|
-
ListBox.prototype.render = function () {
|
|
78
|
-
var _a;
|
|
79
|
-
var _this = this;
|
|
80
|
-
return (React.createElement("div", { className: classNames(this.props.className, 'k-listbox', this.setToolbarPosition()), style: this.props.style, unselectable: "on" },
|
|
81
|
-
this.props.toolbar && this.props.toolbarPosition !== 'bottom' && React.createElement(this.props.toolbar, null),
|
|
82
|
-
React.createElement("div", { className: 'k-list-scroller k-selectable', "data-role": 'selectable', onDragOver: function (e) { return e.preventDefault(); }, onDrop: this.handleContainerDrop, onDragLeave: this.handleOnDragLeave },
|
|
83
|
-
React.createElement("div", { className: classNames('k-list', (_a = {},
|
|
84
|
-
_a["k-list-".concat(kendoThemeMaps.sizeMap[this.props.size] || this.props.size)] = this.props.size,
|
|
85
|
-
_a)) },
|
|
86
|
-
React.createElement("div", { className: 'k-list-content' },
|
|
87
|
-
React.createElement("ul", { className: 'k-list-ul', role: 'listbox', "aria-label": 'listbox-container', tabIndex: 0, onKeyDown: this.handleKeyDown }, this.props.data.map(function (item, index) {
|
|
88
|
-
var selectedValue = _this.setSelected(item);
|
|
89
|
-
var itemGuid = guid();
|
|
90
|
-
var itemOptions = {
|
|
91
|
-
className: classNames('k-list-item', {
|
|
92
|
-
'k-selected': selectedValue
|
|
93
|
-
}),
|
|
94
|
-
role: 'option',
|
|
95
|
-
'aria-selected': selectedValue,
|
|
96
|
-
key: index,
|
|
97
|
-
id: itemGuid + index,
|
|
98
|
-
'data-uid': itemGuid + index,
|
|
99
|
-
draggable: _this.props.draggable,
|
|
100
|
-
onDragStart: function (event) { return dispatchEvent(_this.props.onDragStart, event, _this, { dataItem: item }); },
|
|
101
|
-
onDragOver: function (event) {
|
|
102
|
-
event.preventDefault();
|
|
103
|
-
dispatchEvent(_this.props.onDragOver, event, _this, { dataItem: item });
|
|
104
|
-
},
|
|
105
|
-
onDrop: function (event) { return dispatchEvent(_this.props.onDrop, event, _this, { dataItem: item }); },
|
|
106
|
-
onClick: function (event) { return dispatchEvent(_this.props.onItemClick, event, _this, { dataItem: item }); }
|
|
107
|
-
};
|
|
108
|
-
return (_this.props.item
|
|
109
|
-
? React.createElement(_this.props.item, __assign({ selected: selectedValue, dataItem: item }, itemOptions),
|
|
110
|
-
React.createElement("span", { className: 'k-list-item-text' }, item.name))
|
|
111
|
-
: React.createElement("li", __assign({}, itemOptions),
|
|
112
|
-
React.createElement("span", { className: 'k-list-item-text' }, _this.renderItem(item))));
|
|
113
|
-
}))))),
|
|
114
|
-
this.props.toolbar && this.props.toolbarPosition === 'bottom' && React.createElement(this.props.toolbar, null),
|
|
115
|
-
React.createElement("select", { style: { display: 'none' }, multiple: true, "data-role": "listbox" }, this.props.data.map(function (item, index) {
|
|
116
|
-
var value = item[_this.props.valueField || _this.props.textField];
|
|
117
|
-
return React.createElement("option", { key: index, value: value }, value);
|
|
118
|
-
}))));
|
|
119
|
-
};
|
|
120
|
-
/**
|
|
121
|
-
* @hidden
|
|
122
|
-
*/
|
|
123
|
-
ListBox.propTypes = {
|
|
124
|
-
size: PropTypes.oneOf([null, 'small', 'medium', 'large']),
|
|
125
|
-
toolbarPosition: PropTypes.oneOf(['none', 'top', 'bottom', 'left', 'right']),
|
|
126
|
-
textField: PropTypes.string,
|
|
127
|
-
valueField: PropTypes.string,
|
|
128
|
-
selectedField: PropTypes.string,
|
|
129
|
-
data: PropTypes.array
|
|
130
|
-
};
|
|
131
|
-
/**
|
|
132
|
-
* @hidden
|
|
133
|
-
*/
|
|
134
|
-
ListBox.defaultProps = {
|
|
135
|
-
toolbarPosition: toolbarPosition.RIGHT,
|
|
136
|
-
draggable: true,
|
|
137
|
-
size: 'medium'
|
|
138
|
-
};
|
|
139
|
-
return ListBox;
|
|
140
|
-
}(React.PureComponent));
|
|
141
|
-
export { ListBox };
|