@progress/kendo-react-listbox 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/index.d.ts CHANGED
@@ -1,12 +1,271 @@
1
- /**-----------------------------------------------------------------------------------------
2
- * Copyright © 2024 Progress Software Corporation. All rights reserved.
3
- * Licensed under commercial license. See LICENSE.md in the package root for more information
4
- *-------------------------------------------------------------------------------------------*/
5
- import { type ListBoxProps } from './interfaces/ListBoxProps';
6
- import { ListBoxToolbar } from './ListBoxToolbar';
7
- import { type ListBoxToolbarProps } from './interfaces/ListBoxToolBarProps';
8
- import { processListBoxData, moveItem, processListBoxDragAndDrop } from './utils';
9
- import { type ListBoxDragEvent, type ListBoxItemClickEvent, type ListBoxKeyDownEvent, type ListBoxToolbarClickEvent } from './interfaces/ListBoxEvents';
10
- /** @hidden */
11
- declare const ListBox: import("react").ForwardRefExoticComponent<ListBoxProps & import("react").RefAttributes<any>>;
12
- export { ListBox, ListBoxProps, ListBoxToolbar, ListBoxToolbarProps, processListBoxData, moveItem, processListBoxDragAndDrop, ListBoxDragEvent, ListBoxItemClickEvent, ListBoxKeyDownEvent, ListBoxToolbarClickEvent };
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
+ import { BaseEvent } from '@progress/kendo-react-common';
9
+ import { ComponentType } from 'react';
10
+ import { ForwardRefExoticComponent } from 'react';
11
+ import { JSX as JSX_2 } from 'react/jsx-runtime';
12
+ import PropTypes from 'prop-types';
13
+ import * as React_2 from 'react';
14
+ import { RefAttributes } from 'react';
15
+
16
+ /** @hidden */
17
+ export declare const ListBox: ForwardRefExoticComponent<ListBoxProps & RefAttributes<any>>;
18
+
19
+ declare class ListBox_2 extends React_2.PureComponent<ListBoxProps, {}> {
20
+ /**
21
+ * @hidden
22
+ */
23
+ static propTypes: {
24
+ size: PropTypes.Requireable<string | null>;
25
+ toolbarPosition: PropTypes.Requireable<string>;
26
+ textField: PropTypes.Requireable<string>;
27
+ valueField: PropTypes.Requireable<string>;
28
+ selectedField: PropTypes.Requireable<string>;
29
+ data: PropTypes.Requireable<any[]>;
30
+ };
31
+ /**
32
+ * @hidden
33
+ */
34
+ static defaultProps: {
35
+ toolbarPosition: toolbarPosition;
36
+ draggable: boolean;
37
+ size: string;
38
+ };
39
+ private get itemGuid();
40
+ constructor(props: ListBoxProps);
41
+ /**
42
+ * @hidden
43
+ */
44
+ render(): JSX_2.Element;
45
+ private setSelected;
46
+ private renderItem;
47
+ private handleKeyDown;
48
+ private handleContainerDrop;
49
+ private setToolbarPosition;
50
+ private handleOnDragLeave;
51
+ }
52
+
53
+ export declare interface ListBoxDragEvent extends BaseEvent<ListBox_2> {
54
+ dataItem?: any;
55
+ }
56
+
57
+ declare interface ListBoxDragLeaveEvent extends BaseEvent<ListBox_2> {
58
+ }
59
+
60
+ export declare interface ListBoxItemClickEvent extends BaseEvent<ListBox_2> {
61
+ dataItem?: any;
62
+ }
63
+
64
+ export declare interface ListBoxKeyDownEvent extends BaseEvent<ListBox_2> {
65
+ }
66
+
67
+ /**
68
+ * Represents the props of the [KendoReact ListBox component]({% slug overview_listbox %}).
69
+ */
70
+ export declare interface ListBoxProps {
71
+ /**
72
+ * Sets a `class` of the ListBox container.
73
+ */
74
+ className?: string;
75
+ /**
76
+ * Sets a `id` of the ListBox container.
77
+ */
78
+ id?: string;
79
+ /**
80
+ * Configures the `size` of the ListBox.
81
+ *
82
+ * The available options are:
83
+ * - small
84
+ * - medium
85
+ * - large
86
+ * - null&mdash;Does not set a size `className`.
87
+ *
88
+ * @default `medium`
89
+ */
90
+ size?: null | 'small' | 'medium' | 'large';
91
+ /**
92
+ * Specifies the styles which are set to the ListBox container.
93
+ */
94
+ style?: React.CSSProperties;
95
+ /**
96
+ * Set the data of the ListBox.
97
+ */
98
+ data: Array<any>;
99
+ /**
100
+ * Makes the items of the ListBox draggable. The items are draggable by default.
101
+ */
102
+ draggable?: boolean;
103
+ /**
104
+ * Set the selected field of the ListBox. Based on that value of that field, an item will be selected or not.
105
+ */
106
+ selectedField?: string;
107
+ /**
108
+ * Sets the data item field that represents the item text. If the data contains only primitive values, do not define it.
109
+ */
110
+ textField: string;
111
+ /**
112
+ * The field that be used during form submit. Defaults to the textField if not set.
113
+ */
114
+ valueField?: string;
115
+ /**
116
+ * Sets the position of the toolbar of the ListBox if one is set. The ListBox may have no toolbar.
117
+ * * The possible values are:
118
+ * * `top`
119
+ * * `bottom`
120
+ * * `left`
121
+ * * `right` (Default)
122
+ * * `none`
123
+ */
124
+ toolbarPosition?: toolbarPosition | string;
125
+ /**
126
+ * Renders a toolbar component next to the ListBox.
127
+ */
128
+ toolbar?: null | ComponentType<any>;
129
+ /**
130
+ * Defines the component that will be rendered for each item of the data collection.
131
+ */
132
+ item?: React.ComponentType<any>;
133
+ /**
134
+ * Fires when an item from the ListBox is clicked. Contains the clicked item.
135
+ */
136
+ onItemClick?: (event: ListBoxItemClickEvent) => void;
137
+ /**
138
+ * Fires on keydown over the ListBox list items. It can be use to add keyboard extra keyboard navigation option.
139
+ */
140
+ onKeyDown?: (event: ListBoxKeyDownEvent) => void;
141
+ /**
142
+ * Fires when an the user start to drag an item from the ListBox. The event contains information for the item that is being dragged.
143
+ */
144
+ onDragStart?: (event: ListBoxDragEvent) => void;
145
+ /**
146
+ * Fires when an the user drags over an item from the ListBox. The event contains information for the item that is dragged over.
147
+ */
148
+ onDragOver?: (event: ListBoxDragEvent) => void;
149
+ /**
150
+ * Fires when an the user drops an item. The event contains information for the drop target item.
151
+ */
152
+ onDrop?: (event: ListBoxDragEvent) => void;
153
+ /**
154
+ * Fires when a dragged element or text selection leaves the ListBox element.
155
+ */
156
+ onDragLeave?: (event: ListBoxDragLeaveEvent) => void;
157
+ }
158
+
159
+ export declare class ListBoxToolbar extends React_2.PureComponent<ListBoxToolbarProps, {}> {
160
+ /**
161
+ * @hidden
162
+ */
163
+ static propTypes: {
164
+ data: PropTypes.Requireable<any[]>;
165
+ dataConnected: PropTypes.Requireable<any[]>;
166
+ tools: PropTypes.Requireable<any[]>;
167
+ selectedField: PropTypes.Requireable<string>;
168
+ dir: PropTypes.Requireable<string>;
169
+ };
170
+ /**
171
+ * @hidden
172
+ */
173
+ static defaultProps: {
174
+ data: never[];
175
+ dataConnected: never[];
176
+ selectedField: string;
177
+ };
178
+ private get isRtl();
179
+ /**
180
+ * @hidden
181
+ */
182
+ render(): JSX_2.Element;
183
+ private checkSvgIcon;
184
+ private checkFontIcon;
185
+ private handleToolClick;
186
+ private isItemDisabled;
187
+ }
188
+
189
+ export declare interface ListBoxToolbarClickEvent extends BaseEvent<ListBoxToolbar> {
190
+ toolName?: string;
191
+ }
192
+
193
+ export declare interface ListBoxToolbarProps {
194
+ /**
195
+ * Sets the tools of the ListBoxToolbar. By default, the ListBoxToolbar renders no tools.
196
+ * The built-in tools are:
197
+ * * `moveUp`
198
+ * * `moveDown`
199
+ * * `transferTo`
200
+ * * `transferFrom`
201
+ * * `transferAllTo`
202
+ * * `transferAllFrom`
203
+ * * `remove`
204
+ */
205
+ tools?: Array<string>;
206
+ /**
207
+ * The data of the main ListBox.
208
+ */
209
+ data: Array<any>;
210
+ /**
211
+ * The data of the connected ListBox.
212
+ */
213
+ dataConnected: Array<any>;
214
+ /**
215
+ * Set the selected field of the ListBoxToolbar.
216
+ * Based on that value of that field the ListBoxToolbar will determine which actions are allowed and which disabled.
217
+ */
218
+ selectedField?: string;
219
+ /**
220
+ * Fires when one of the ListBoxToolbar tools is clicked.
221
+ */
222
+ onToolClick?: (event: ListBoxToolbarClickEvent) => void;
223
+ /**
224
+ * @hidden
225
+ */
226
+ dir?: string;
227
+ }
228
+
229
+ /**
230
+ * @hidden
231
+ */
232
+ export declare const moveItem: (from: number, to: number, data: Array<any>) => any[];
233
+
234
+ /**
235
+ * Process the data collection/s based on the clicked ListBoxToolbar tool.
236
+ *
237
+ * @param {T[]} listBoxOneData - The first data collection.
238
+ * @param {T[]} listBoxTwoData - The second data collection. Pass an empty array if there is only one ListBox.
239
+ * @param {string} toolName - The tool that was clicked.
240
+ * @param {string} selectedField - The field that contains the selected information in the data object.
241
+ * @returns {{listBoxOneData: T[], listBoxTwoData: t[]}} - The object that contains the new data collections.
242
+ */
243
+ export declare const processListBoxData: (listBoxOneData: any[] | undefined, listBoxTwoData: any[] | undefined, toolName: string, selectedField: string) => {
244
+ listBoxOneData: any[];
245
+ listBoxTwoData: any[];
246
+ };
247
+
248
+ /**
249
+ * Process the data collection/s based on the dragged and drop item.
250
+ *
251
+ * @param {T[]} listBoxOneData - The first data collection.
252
+ * @param {T[]} listBoxTwoData - The second data collection. Pass an empty array if there is only one ListBox.
253
+ * @param {any} dragItem - The item that was dragged.
254
+ * @param {any} dropItem - The drop target item.
255
+ * @param {string} valueField - The field which points to the unique value of each data item.
256
+ * @returns {{listBoxOneData: T[], listBoxTwoData: t[]}} - The object that contains the new data collections.
257
+ */
258
+ export declare const processListBoxDragAndDrop: (listBoxOneData: any[] | undefined, listBoxTwoData: any[] | undefined, dragItem: any, dropItem: any, valueField: string) => {
259
+ listBoxOneData: any[];
260
+ listBoxTwoData: any[];
261
+ };
262
+
263
+ declare enum toolbarPosition {
264
+ TOP = "top",
265
+ BOTTOM = "bottom",
266
+ LEFT = "left",
267
+ RIGHT = "right",
268
+ NONE = "none"
269
+ }
270
+
271
+ export { }
package/index.js CHANGED
@@ -1,5 +1,8 @@
1
- /**-----------------------------------------------------------------------------------------
2
- * Copyright © 2024 Progress Software Corporation. All rights reserved.
3
- * Licensed under commercial license. See LICENSE.md in the package root for more information
4
- *-------------------------------------------------------------------------------------------*/
5
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("react"),m=require("prop-types"),d=require("@progress/kendo-react-common"),C=require("@progress/kendo-react-buttons"),x=require("@progress/kendo-react-intl"),h=require("@progress/kendo-svg-icons");function A(o){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const t in o)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>o[t]})}}return e.default=o,Object.freeze(e)}const p=A(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/"};let k=class 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-content")&&(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-content")&&d.dispatchEvent(this.props.onDragLeave,t,this,void 0)},d.validatePackage(S)}get itemGuid(){return this.props.id+"-accessibility-id"}render(){return p.createElement("div",{id:this.props.id,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 s=this.setSelected(e),r={className:d.classNames("k-list-item",{"k-selected":s}),role:"option","aria-selected":s,key:t,id:this.itemGuid+t,"data-uid":this.itemGuid+t,draggable:this.props.draggable,onDragStart:a=>d.dispatchEvent(this.props.onDragStart,a,this,{dataItem:e}),onDragOver:a=>{a.preventDefault(),d.dispatchEvent(this.props.onDragOver,a,this,{dataItem:e})},onDrop:a=>d.dispatchEvent(this.props.onDrop,a,this,{dataItem:e}),onClick:a=>d.dispatchEvent(this.props.onItemClick,a,this,{dataItem:e})};return this.props.item?p.createElement(this.props.item,{selected:s,dataItem:e,...r,key:r.key},p.createElement("span",{className:"k-list-item-text"},e.name)):p.createElement("li",{...r,key:r.key},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 s=e[this.props.valueField||this.props.textField];return p.createElement("option",{key:t,value:s},s)})))}};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",R="listbox.transferFrom",P="listbox.transferAllTo",z="listbox.transferAllFrom",K="listbox.remove",U={[w]:"Move Up",[F]:"Move Down",[O]:"Transfer To",[R]:"Transfer From",[P]:"Transfer All To",[z]:"Transfer All From",[K]:"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 s=this.props.selectedField||"selected",r=this.props.data.length,a=this.props.dataConnected.length,i=this.props.data.findIndex(n=>n[s]===!0)>=0,c=this.props.dataConnected.findIndex(n=>n[s]===!0)>=0;switch(e){case"moveUp":i?t=this.props.data.length>0?this.props.data[0].selected:!0:c?t=this.props.dataConnected.length>0?this.props.dataConnected[0].selected:!0:t=!0;break;case"moveDown":i?t=this.props.data[r-1]?this.props.data[r-1].selected:!0:c?t=this.props.dataConnected.length>0?this.props.dataConnected[a-1].selected:!0:t=!0;break;case"transferTo":t=!(this.props.dataConnected&&i);break;case"transferFrom":this.props.dataConnected?t=!(this.props.dataConnected&&c):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=!(i||c);break}return t}}get isRtl(){return this.props.dir==="rtl"}render(){const e=x.provideLocalizationService(this);return p.createElement("div",{className:d.classNames("k-listbox-actions")},this.props.tools&&this.props.tools.map((t,s)=>{const r=L.findIndex(l=>l.name===t),a=L[r],i=this.isItemDisabled(a.name),c=`listbox.${a.name}`,n=e.toLanguageString(c,U[c]);return p.createElement(C.Button,{key:s,disabled:i,"data-command":a.name,title:n,"aria-label":n,icon:this.isRtl?this.checkFontIcon(a.iconName):a.iconName,svgIcon:this.isRtl?this.checkSvgIcon(a.svgIcon):a.svgIcon,onClick:l=>{l.preventDefault(),this.handleToolClick(l,a.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"};x.registerForLocalization(v);const M=(o=[],e=[],t,s)=>{let r=[],a=[],i=[];const c={listBoxOneData:o,listBoxTwoData:e};switch(t){case"moveUp":r=[...o],r.forEach((n,l)=>{n[s]&&(r=f(l,l-1,r))}),i=[...e],i.forEach((n,l)=>{n[s]&&(i=f(l,l-1,i))}),c.listBoxOneData=r,c.listBoxTwoData=i;break;case"moveDown":r=o.reverse(),r.forEach((n,l)=>{n[s]&&(r=f(l,l-1,r))}),i=e.reverse(),i.forEach((n,l)=>{n[s]&&(i=f(l,l-1,i))}),c.listBoxOneData=[...r].reverse(),c.listBoxTwoData=[...i].reverse();break;case"transferTo":r=o.filter(n=>!n[s]),a=o.filter(n=>n[s]),i=e.concat(a),c.listBoxOneData=r,c.listBoxTwoData=i;break;case"transferFrom":i=e.filter(n=>!n[s]),a=e.filter(n=>n[s]),r=o.concat(a),c.listBoxOneData=r,c.listBoxTwoData=i;break;case"transferAllTo":c.listBoxOneData=[],c.listBoxTwoData=e.concat(o);break;case"transferAllFrom":c.listBoxOneData=e.concat(o),c.listBoxTwoData=[];break;case"remove":i=e.filter(n=>!n[s]),r=o.filter(n=>!n[s]),c.listBoxOneData=r,c.listBoxTwoData=i;break}return c},f=(o,e,t)=>{const s=t.splice(o,1)[0];return t.splice(e,0,s),t},q=(o=[],e=[],t,s,r)=>{const a=o.findIndex(u=>u[r]===t[r]),i=e.findIndex(u=>u[r]===t[r]),c=s!==null?o.findIndex(u=>u[r]===s[r]):-1,n=s!==null?e.findIndex(u=>u[r]===s[r]):-1,l=a>=0,D=i>=0,E=c>=0,T=n>=0,g=[...o],b=[...e];return l&&E?{listBoxOneData:f(a,c,o),listBoxTwoData:e}:D&&T?{listBoxOneData:o,listBoxTwoData:f(i,n,e)}:l&&(T||s===null)?(s===null?b.push(o[a]):b.splice(n+1,0,o[a]),g.splice(a,1),{listBoxOneData:g,listBoxTwoData:b}):D&&(E||s===null)?(s===null?g.push(e[i]):g.splice(c+1,0,e[i]),b.splice(i,1),{listBoxOneData:g,listBoxTwoData:b}):{listBoxOneData:o,listBoxTwoData:e}},N=d.withIdHOC(k);N.displayName="KendoReactListBox";exports.ListBox=N;exports.ListBoxToolbar=v;exports.moveItem=f;exports.processListBoxData=M;exports.processListBoxDragAndDrop=q;
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 e=require("./ListBox.js"),s=require("./ListBoxToolbar.js"),o=require("./utils.js"),i=require("@progress/kendo-react-common"),t=i.withIdHOC(e.ListBox);t.displayName="KendoReactListBox";exports.ListBoxToolbar=s.ListBoxToolbar;exports.moveItem=o.moveItem;exports.processListBoxData=o.processListBoxData;exports.processListBoxDragAndDrop=o.processListBoxDragAndDrop;exports.ListBox=t;
package/index.mjs CHANGED
@@ -1,300 +1,21 @@
1
- /**-----------------------------------------------------------------------------------------
2
- * Copyright © 2024 Progress Software Corporation. All rights reserved.
3
- * Licensed under commercial license. See LICENSE.md in the package root for more information
4
- *-------------------------------------------------------------------------------------------*/
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
+ */
5
8
  "use client";
6
- import * as p from "react";
7
- import d from "prop-types";
8
- import { dispatchEvent as h, validatePackage as A, classNames as b, kendoThemeMaps as w, withIdHOC as F } from "@progress/kendo-react-common";
9
- import { Button as S } from "@progress/kendo-react-buttons";
10
- import { provideLocalizationService as O, registerForLocalization as P } from "@progress/kendo-react-intl";
11
- import { caretDoubleAltRightIcon as x, caretDoubleAltLeftIcon as E, caretAltRightIcon as N, caretAltLeftIcon as y, caretAltUpIcon as R, caretAltDownIcon as K, xIcon as U } from "@progress/kendo-svg-icons";
12
- var I = /* @__PURE__ */ ((n) => (n.TOP = "top", n.BOTTOM = "bottom", n.LEFT = "left", n.RIGHT = "right", n.NONE = "none", n))(I || {});
13
- const z = {
14
- name: "@progress/kendo-react-listbox",
15
- productName: "KendoReact",
16
- productCodes: ["KENDOUIREACT", "KENDOUICOMPLETE"],
17
- publishDate: 1709198444,
18
- version: "",
19
- licensingDocsUrl: "https://www.telerik.com/kendo-react-ui/components/my-license/"
20
- };
21
- let k = class extends p.PureComponent {
22
- constructor(t) {
23
- super(t), this.setSelected = (e) => {
24
- if (this.props.selectedField)
25
- return !!e[this.props.selectedField];
26
- }, this.renderItem = (e) => this.props.textField ? e[this.props.textField] : e.toString(), this.handleKeyDown = (e) => {
27
- this.props.onKeyDown && h(this.props.onKeyDown, e, this, void 0);
28
- }, this.handleContainerDrop = (e) => {
29
- e.target.classList.contains("k-list-content") && (this.props.data.length > 0 ? h(this.props.onDrop, e, this, { dataItem: this.props.data[this.props.data.length - 1] }) : h(this.props.onDrop, e, this, { dataItem: null }));
30
- }, this.setToolbarPosition = () => this.props.toolbarPosition === I.NONE || this.props.toolbar === void 0 ? "" : `k-listbox-actions-${this.props.toolbarPosition}`, this.handleOnDragLeave = (e) => {
31
- this.props.onDragLeave && e.target.classList.contains("k-list-content") && h(this.props.onDragLeave, e, this, void 0);
32
- }, A(z);
33
- }
34
- get itemGuid() {
35
- return this.props.id + "-accessibility-id";
36
- }
37
- /**
38
- * @hidden
39
- */
40
- render() {
41
- return /* @__PURE__ */ p.createElement(
42
- "div",
43
- {
44
- id: this.props.id,
45
- className: b(
46
- this.props.className,
47
- "k-listbox",
48
- this.setToolbarPosition()
49
- ),
50
- style: this.props.style,
51
- unselectable: "on"
52
- },
53
- this.props.toolbar && this.props.toolbarPosition !== "bottom" && /* @__PURE__ */ p.createElement(this.props.toolbar, null),
54
- /* @__PURE__ */ p.createElement(
55
- "div",
56
- {
57
- className: "k-list-scroller k-selectable",
58
- "data-role": "selectable",
59
- onDragOver: (t) => t.preventDefault(),
60
- onDrop: this.handleContainerDrop,
61
- onDragLeave: this.handleOnDragLeave
62
- },
63
- /* @__PURE__ */ p.createElement("div", { className: b("k-list", {
64
- [`k-list-${w.sizeMap[this.props.size] || this.props.size}`]: this.props.size
65
- }) }, /* @__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((t, e) => {
66
- const r = this.setSelected(t), s = {
67
- className: b(
68
- "k-list-item",
69
- {
70
- "k-selected": r
71
- }
72
- ),
73
- role: "option",
74
- "aria-selected": r,
75
- key: e,
76
- id: this.itemGuid + e,
77
- "data-uid": this.itemGuid + e,
78
- draggable: this.props.draggable,
79
- onDragStart: (o) => h(this.props.onDragStart, o, this, { dataItem: t }),
80
- onDragOver: (o) => {
81
- o.preventDefault(), h(this.props.onDragOver, o, this, { dataItem: t });
82
- },
83
- onDrop: (o) => h(this.props.onDrop, o, this, { dataItem: t }),
84
- onClick: (o) => h(this.props.onItemClick, o, this, { dataItem: t })
85
- };
86
- return this.props.item ? /* @__PURE__ */ p.createElement(this.props.item, { selected: r, dataItem: t, ...s, key: s.key }, /* @__PURE__ */ p.createElement("span", { className: "k-list-item-text" }, t.name)) : /* @__PURE__ */ p.createElement("li", { ...s, key: s.key }, /* @__PURE__ */ p.createElement("span", { className: "k-list-item-text" }, this.renderItem(t)));
87
- }))))
88
- ),
89
- this.props.toolbar && this.props.toolbarPosition === "bottom" && /* @__PURE__ */ p.createElement(this.props.toolbar, null),
90
- /* @__PURE__ */ p.createElement("select", { style: { display: "none" }, multiple: !0, "data-role": "listbox" }, this.props.data.map((t, e) => {
91
- const r = t[this.props.valueField || this.props.textField];
92
- return /* @__PURE__ */ p.createElement("option", { key: e, value: r }, r);
93
- }))
94
- );
95
- }
96
- };
97
- k.propTypes = {
98
- size: d.oneOf([null, "small", "medium", "large"]),
99
- toolbarPosition: d.oneOf(["none", "top", "bottom", "left", "right"]),
100
- textField: d.string,
101
- valueField: d.string,
102
- selectedField: d.string,
103
- data: d.array
104
- };
105
- k.defaultProps = {
106
- toolbarPosition: I.RIGHT,
107
- draggable: !0,
108
- size: "medium"
109
- };
110
- const M = "listbox.moveUp", G = "listbox.moveDown", $ = "listbox.transferTo", H = "listbox.transferFrom", V = "listbox.transferAllTo", j = "listbox.transferAllFrom", q = "listbox.remove", J = {
111
- [M]: "Move Up",
112
- [G]: "Move Down",
113
- [$]: "Transfer To",
114
- [H]: "Transfer From",
115
- [V]: "Transfer All To",
116
- [j]: "Transfer All From",
117
- [q]: "Delete"
118
- }, L = [
119
- { name: "moveUp", iconName: "caret-alt-up", svgIcon: R },
120
- { name: "moveDown", iconName: "caret-alt-down", svgIcon: K },
121
- { name: "transferTo", iconName: "caret-alt-right", svgIcon: N },
122
- { name: "transferFrom", iconName: "caret-alt-left", svgIcon: y },
123
- { name: "transferAllTo", iconName: "caret-double-alt-right", svgIcon: x },
124
- { name: "transferAllFrom", iconName: "caret-double-alt-left", svgIcon: E },
125
- { name: "remove", iconName: "x", svgIcon: U }
126
- ];
127
- class v extends p.PureComponent {
128
- constructor() {
129
- super(...arguments), this.checkSvgIcon = (t) => {
130
- switch (t.name) {
131
- case "caret-alt-right":
132
- return y;
133
- case "caret-alt-left":
134
- return N;
135
- case "caret-double-alt-right":
136
- return E;
137
- case "caret-double-alt-left":
138
- return x;
139
- }
140
- return t;
141
- }, this.checkFontIcon = (t) => {
142
- switch (t) {
143
- case "caret-alt-right":
144
- return "caret-alt-left";
145
- case "caret-alt-left":
146
- return "caret-alt-right";
147
- case "caret-double-alt-right":
148
- return "caret-double-alt-left";
149
- case "caret-double-alt-left":
150
- return "caret-double-alt-right";
151
- }
152
- return t;
153
- }, this.handleToolClick = (t, e) => {
154
- h(this.props.onToolClick, t, this, { toolName: e });
155
- }, this.isItemDisabled = (t) => {
156
- let e = !0;
157
- const r = this.props.selectedField || "selected", s = this.props.data.length, o = this.props.dataConnected.length, i = this.props.data.findIndex((a) => a[r] === !0) >= 0, l = this.props.dataConnected.findIndex((a) => a[r] === !0) >= 0;
158
- switch (t) {
159
- case "moveUp":
160
- i ? e = this.props.data.length > 0 ? this.props.data[0].selected : !0 : l ? e = this.props.dataConnected.length > 0 ? this.props.dataConnected[0].selected : !0 : e = !0;
161
- break;
162
- case "moveDown":
163
- i ? e = this.props.data[s - 1] ? this.props.data[s - 1].selected : !0 : l ? e = this.props.dataConnected.length > 0 ? this.props.dataConnected[o - 1].selected : !0 : e = !0;
164
- break;
165
- case "transferTo":
166
- e = !(this.props.dataConnected && i);
167
- break;
168
- case "transferFrom":
169
- this.props.dataConnected ? e = !(this.props.dataConnected && l) : e = !0;
170
- break;
171
- case "transferAllTo":
172
- e = !(this.props.dataConnected && this.props.data.length > 0);
173
- break;
174
- case "transferAllFrom":
175
- e = !(this.props.dataConnected && this.props.dataConnected.length > 0);
176
- break;
177
- case "remove":
178
- e = !(i || l);
179
- break;
180
- }
181
- return e;
182
- };
183
- }
184
- get isRtl() {
185
- return this.props.dir === "rtl";
186
- }
187
- /**
188
- * @hidden
189
- */
190
- render() {
191
- const t = O(this);
192
- return /* @__PURE__ */ p.createElement(
193
- "div",
194
- {
195
- className: b(
196
- "k-listbox-actions"
197
- )
198
- },
199
- this.props.tools && this.props.tools.map((e, r) => {
200
- const s = L.findIndex((c) => c.name === e), o = L[s], i = this.isItemDisabled(o.name), l = `listbox.${o.name}`, a = t.toLanguageString(l, J[l]);
201
- return /* @__PURE__ */ p.createElement(
202
- S,
203
- {
204
- key: r,
205
- disabled: i,
206
- "data-command": o.name,
207
- title: a,
208
- "aria-label": a,
209
- icon: this.isRtl ? this.checkFontIcon(o.iconName) : o.iconName,
210
- svgIcon: this.isRtl ? this.checkSvgIcon(o.svgIcon) : o.svgIcon,
211
- onClick: (c) => {
212
- c.preventDefault(), this.handleToolClick(c, o.name || null);
213
- }
214
- }
215
- );
216
- })
217
- );
218
- }
219
- }
220
- v.propTypes = {
221
- data: d.array,
222
- dataConnected: d.array,
223
- tools: d.array,
224
- selectedField: d.string,
225
- dir: d.string
226
- };
227
- v.defaultProps = {
228
- data: [],
229
- dataConnected: [],
230
- selectedField: "selected"
231
- };
232
- P(v);
233
- const tt = (n = [], t = [], e, r) => {
234
- let s = [], o = [], i = [];
235
- const l = {
236
- listBoxOneData: n,
237
- listBoxTwoData: t
238
- };
239
- switch (e) {
240
- case "moveUp":
241
- s = [...n], s.forEach((a, c) => {
242
- a[r] && (s = u(c, c - 1, s));
243
- }), i = [...t], i.forEach((a, c) => {
244
- a[r] && (i = u(c, c - 1, i));
245
- }), l.listBoxOneData = s, l.listBoxTwoData = i;
246
- break;
247
- case "moveDown":
248
- s = n.reverse(), s.forEach((a, c) => {
249
- a[r] && (s = u(c, c - 1, s));
250
- }), i = t.reverse(), i.forEach((a, c) => {
251
- a[r] && (i = u(c, c - 1, i));
252
- }), l.listBoxOneData = [...s].reverse(), l.listBoxTwoData = [...i].reverse();
253
- break;
254
- case "transferTo":
255
- s = n.filter((a) => !a[r]), o = n.filter((a) => a[r]), i = t.concat(o), l.listBoxOneData = s, l.listBoxTwoData = i;
256
- break;
257
- case "transferFrom":
258
- i = t.filter((a) => !a[r]), o = t.filter((a) => a[r]), s = n.concat(o), l.listBoxOneData = s, l.listBoxTwoData = i;
259
- break;
260
- case "transferAllTo":
261
- l.listBoxOneData = [], l.listBoxTwoData = t.concat(n);
262
- break;
263
- case "transferAllFrom":
264
- l.listBoxOneData = t.concat(n), l.listBoxTwoData = [];
265
- break;
266
- case "remove":
267
- i = t.filter((a) => !a[r]), s = n.filter((a) => !a[r]), l.listBoxOneData = s, l.listBoxTwoData = i;
268
- break;
269
- }
270
- return l;
271
- }, u = (n, t, e) => {
272
- const r = e.splice(n, 1)[0];
273
- return e.splice(t, 0, r), e;
274
- }, et = (n = [], t = [], e, r, s) => {
275
- const o = n.findIndex((m) => m[s] === e[s]), i = t.findIndex((m) => m[s] === e[s]), l = r !== null ? n.findIndex((m) => m[s] === r[s]) : -1, a = r !== null ? t.findIndex((m) => m[s] === r[s]) : -1, c = o >= 0, D = i >= 0, T = l >= 0, C = a >= 0, f = [...n], g = [...t];
276
- return c && T ? {
277
- listBoxOneData: u(o, l, n),
278
- listBoxTwoData: t
279
- } : D && C ? {
280
- listBoxOneData: n,
281
- listBoxTwoData: u(i, a, t)
282
- } : c && (C || r === null) ? (r === null ? g.push(n[o]) : g.splice(a + 1, 0, n[o]), f.splice(o, 1), {
283
- listBoxOneData: f,
284
- listBoxTwoData: g
285
- }) : D && (T || r === null) ? (r === null ? f.push(t[i]) : f.splice(l + 1, 0, t[i]), g.splice(i, 1), {
286
- listBoxOneData: f,
287
- listBoxTwoData: g
288
- }) : {
289
- listBoxOneData: n,
290
- listBoxTwoData: t
291
- };
292
- }, Q = F(k);
293
- Q.displayName = "KendoReactListBox";
9
+ import { ListBox as o } from "./ListBox.mjs";
10
+ import { ListBoxToolbar as m } from "./ListBoxToolbar.mjs";
11
+ import { moveItem as a, processListBoxData as B, processListBoxDragAndDrop as L } from "./utils.mjs";
12
+ import { withIdHOC as t } from "@progress/kendo-react-common";
13
+ const s = t(o);
14
+ s.displayName = "KendoReactListBox";
294
15
  export {
295
- Q as ListBox,
296
- v as ListBoxToolbar,
297
- u as moveItem,
298
- tt as processListBoxData,
299
- et as processListBoxDragAndDrop
16
+ s as ListBox,
17
+ m as ListBoxToolbar,
18
+ a as moveItem,
19
+ B as processListBoxData,
20
+ L as processListBoxDragAndDrop
300
21
  };
@@ -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"});var t=(e=>(e.TOP="top",e.BOTTOM="bottom",e.LEFT="left",e.RIGHT="right",e.NONE="none",e))(t||{});exports.toolbarPosition=t;
@@ -0,0 +1,12 @@
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
+ var T = /* @__PURE__ */ ((e) => (e.TOP = "top", e.BOTTOM = "bottom", e.LEFT = "left", e.RIGHT = "right", e.NONE = "none", e))(T || {});
10
+ export {
11
+ T as toolbarPosition
12
+ };
@@ -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 o="listbox.moveUp",r="listbox.moveDown",e="listbox.transferTo",s="listbox.transferFrom",t="listbox.transferAllTo",n="listbox.transferAllFrom",l="listbox.remove",a={[o]:"Move Up",[r]:"Move Down",[e]:"Transfer To",[s]:"Transfer From",[t]:"Transfer All To",[n]:"Transfer All From",[l]:"Delete"};exports.messages=a;exports.moveDown=r;exports.moveUp=o;exports.remove=l;exports.transferAllFrom=n;exports.transferAllTo=t;exports.transferFrom=s;exports.transferTo=e;