sccoreui 5.1.4 → 5.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/App.scss CHANGED
@@ -749,7 +749,7 @@ button[aria-expanded="true"] {
749
749
 
750
750
  li {
751
751
  margin: 4px 0 !important;
752
- border-radius: 10px !important;
752
+ border-radius: 4px !important;
753
753
  padding: 8px 14px !important;
754
754
 
755
755
  .item_content {
@@ -779,4 +779,15 @@ button[aria-expanded="true"] {
779
779
  }
780
780
  }
781
781
  }
782
+
783
+ .list_box_chips {
784
+ display: inline-block;
785
+ align-items: center;
786
+ list-style: none;
787
+ li {
788
+ float: left;
789
+ height: 24px;
790
+ }
791
+ }
792
+
782
793
  /////// Custom list_box_dropdown ///////////
@@ -5,15 +5,15 @@ const listbox_1 = require("primereact/listbox");
5
5
  const menu_1 = require("primereact/menu");
6
6
  const react_1 = require("react");
7
7
  const sccoreui_1 = require("sccoreui");
8
- const ListBoxDropdown = ({ onChange, footeTemplate, headerTemplate, labelIcon, labelIconPos, label, labelIconSize, listItems, filter, multiple, filterPlaceholder, optionLabel, listClassName, menuClassName, listBoxParentClassName, listBoxclassName, optionTemplate, values, link, className, scrollElementId, buttonClassName }) => {
9
- const [selectedCities, setSelectedCities] = (0, react_1.useState)();
8
+ const ListBoxDropdown = ({ onChange, footeTemplate, headerTemplate, labelIcon, labelIconPos, label, labelIconSize, listItems, filter, multiple, filterPlaceholder, optionLabel, listClassName, menuClassName, listBoxParentClassName, listBoxclassName, optionTemplate, values, link, className, scrollElementId, buttonClassName, showChilps, chipTemplate, chipClassName, chipsParentClassName, showRemoveIcon, removeIconSize, removeIconClassName, onRemoveItem, isDraggable }) => {
9
+ const [selectedItems, setSelectedItems] = (0, react_1.useState)([]);
10
10
  const optionsMenuRef = (0, react_1.useRef)();
11
11
  const onSelectOption = (e) => {
12
- setSelectedCities(e.value);
12
+ setSelectedItems(e.value);
13
13
  onChange(e);
14
14
  };
15
15
  (0, react_1.useEffect)(() => {
16
- setSelectedCities(values);
16
+ setSelectedItems(values);
17
17
  }, [values]);
18
18
  const handleScroll = (e) => {
19
19
  if (optionsMenuRef === null || optionsMenuRef === void 0 ? void 0 : optionsMenuRef.current)
@@ -26,13 +26,47 @@ const ListBoxDropdown = ({ onChange, footeTemplate, headerTemplate, labelIcon, l
26
26
  elm.addEventListener('scroll', handleScroll);
27
27
  }
28
28
  }, []);
29
+ const handleDragStart = (e, index) => {
30
+ e.dataTransfer.setData('text/plain', index);
31
+ };
32
+ const handleDragOver = (e) => {
33
+ e.preventDefault();
34
+ };
35
+ const handleDrop = (e, targetIndex) => {
36
+ const draggedIndex = e.dataTransfer.getData('text/plain');
37
+ const newItems = [...selectedItems];
38
+ const draggedItem = newItems[draggedIndex];
39
+ newItems.splice(draggedIndex, 1);
40
+ newItems.splice(targetIndex, 0, draggedItem);
41
+ setSelectedItems(newItems);
42
+ // const formValues = {
43
+ // values: newItems,
44
+ // isValid,
45
+ // formIndex: optionValueIndex
46
+ // }
47
+ // handleFormValues(formValues);
48
+ };
29
49
  return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: className }, { children: [(0, jsx_runtime_1.jsx)(menu_1.Menu, { popup: true, className: menuClassName ? menuClassName : '', ref: optionsMenuRef, model: [{
30
50
  template: () => (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: listBoxParentClassName ? listBoxParentClassName + ' list_box_dropdown' : 'list_box_dropdown' }, { children: [headerTemplate &&
31
51
  (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: headerTemplate() }), (0, jsx_runtime_1.jsx)(listbox_1.ListBox, { itemTemplate: (option) => (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: optionTemplate ?
32
52
  optionTemplate(option)
33
53
  :
34
- (0, jsx_runtime_1.jsx)("span", { children: option[`${optionLabel}`] }) }), listClassName: listClassName ? listClassName : '', filter: filter ? true : false, multiple: multiple ? true : false, value: selectedCities, onChange: (e) => onSelectOption(e), options: listItems, optionLabel: optionLabel, className: listBoxclassName ? listBoxclassName : '', filterPlaceholder: filterPlaceholder ? filterPlaceholder : '' }), footeTemplate &&
54
+ (0, jsx_runtime_1.jsx)("span", { children: option[`${optionLabel}`] }) }), listClassName: listClassName ? listClassName : '', filter: filter ? true : false, multiple: multiple ? true : false, value: selectedItems, onChange: (e) => onSelectOption(e), options: listItems, optionLabel: optionLabel, className: listBoxclassName ? listBoxclassName : '', filterPlaceholder: filterPlaceholder ? filterPlaceholder : '' }), footeTemplate &&
35
55
  (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: footeTemplate() })] }))
36
- }] }), (0, jsx_runtime_1.jsx)(sccoreui_1.Button, { type: "button", className: `focus:shadow-none ${buttonClassName}`, link: link ? true : false, icon: labelIcon ? labelIcon : '', size: labelIconSize ? labelIconSize : '', iconPos: labelIconPos ? labelIconPos : '', label: label, onClick: (event) => optionsMenuRef.current.toggle(event) })] })) }));
56
+ }] }), !showChilps ?
57
+ (0, jsx_runtime_1.jsx)(sccoreui_1.Button, { type: "button", className: `focus:shadow-none ${buttonClassName}`, link: link ? true : false, icon: labelIcon ? labelIcon : '', size: labelIconSize ? labelIconSize : '', iconPos: labelIconPos ? labelIconPos : '', label: label, onClick: (event) => optionsMenuRef.current.toggle(event) })
58
+ :
59
+ (0, jsx_runtime_1.jsxs)("ul", Object.assign({ className: `list_box_chips ${chipsParentClassName}` }, { children: [(0, jsx_runtime_1.jsx)("li", Object.assign({ className: `cursor-pointer min-w-max mx-2 max-w-max ${buttonClassName}` }, { children: (0, jsx_runtime_1.jsx)(sccoreui_1.Button, { type: "button", className: `focus:shadow-none p-0 h-max`, link: link ? true : false, icon: labelIcon ? labelIcon : '', size: labelIconSize ? labelIconSize : '', iconPos: labelIconPos ? labelIconPos : '', label: label, onClick: (event) => optionsMenuRef.current.toggle(event) }) })), selectedItems && (selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.map((item, index) => {
60
+ return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: isDraggable !== undefined ?
61
+ (0, jsx_runtime_1.jsx)("li", Object.assign({ draggable: isDraggable, onDragStart: (e) => handleDragStart(e, index), onDragOver: (e) => handleDragOver(e), onDrop: (e) => handleDrop(e, index), className: `${chipClassName} ${showRemoveIcon ? 'pr-6 relative' : ''}` }, { children: chipTemplate ?
62
+ chipTemplate(item)
63
+ :
64
+ (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { children: [" ", item[`${optionLabel}`]] }), showRemoveIcon && (0, jsx_runtime_1.jsxs)("span", Object.assign({ onClick: () => onRemoveItem(item), className: `absolute right-0 p-1 ${removeIconClassName}` }, { children: [" ", (0, jsx_runtime_1.jsx)(sccoreui_1.SvgComponent, { icon: showRemoveIcon, size: removeIconSize ? removeIconSize : 20 })] }))] }) }))
65
+ :
66
+ (0, jsx_runtime_1.jsx)("li", Object.assign({ className: `${chipClassName} ${showRemoveIcon ? 'pr-6 relative' : ''}` }, { children: chipTemplate ?
67
+ chipTemplate(item)
68
+ :
69
+ (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { children: [" ", item[`${optionLabel}`]] }), showRemoveIcon && (0, jsx_runtime_1.jsxs)("span", Object.assign({ onClick: () => onRemoveItem(item), className: `absolute right-0 p-1 ${removeIconClassName}` }, { children: [" ", (0, jsx_runtime_1.jsx)(sccoreui_1.SvgComponent, { icon: showRemoveIcon, size: removeIconSize ? removeIconSize : 20 })] }))] }) })) }));
70
+ }))] }))] })) }));
37
71
  };
38
72
  exports.default = ListBoxDropdown;
@@ -1,3 +1,3 @@
1
1
  import { ListBoxDropdownTypes } from "../types/type";
2
- declare const ListBoxDropdown: ({ onChange, footeTemplate, headerTemplate, labelIcon, labelIconPos, label, labelIconSize, listItems, filter, multiple, filterPlaceholder, optionLabel, listClassName, menuClassName, listBoxParentClassName, listBoxclassName, optionTemplate, values, link, className, scrollElementId, buttonClassName }: ListBoxDropdownTypes) => import("react/jsx-runtime").JSX.Element;
2
+ declare const ListBoxDropdown: ({ onChange, footeTemplate, headerTemplate, labelIcon, labelIconPos, label, labelIconSize, listItems, filter, multiple, filterPlaceholder, optionLabel, listClassName, menuClassName, listBoxParentClassName, listBoxclassName, optionTemplate, values, link, className, scrollElementId, buttonClassName, showChilps, chipTemplate, chipClassName, chipsParentClassName, showRemoveIcon, removeIconSize, removeIconClassName, onRemoveItem, isDraggable }: ListBoxDropdownTypes) => import("react/jsx-runtime").JSX.Element;
3
3
  export default ListBoxDropdown;
@@ -206,6 +206,15 @@ export interface ListBoxDropdownTypes {
206
206
  className?: string;
207
207
  scrollElementId?: string;
208
208
  buttonClassName?: string;
209
+ showChilps?: boolean;
210
+ chipsParentClassName?: string;
211
+ chipClassName?: string;
212
+ chipTemplate?: any;
213
+ showRemoveIcon?: string;
214
+ removeIconSize?: number;
215
+ removeIconClassName?: any;
216
+ onRemoveItem?: any;
217
+ isDraggable?: boolean;
209
218
  }
210
219
  export interface DatePickerTypes {
211
220
  value: any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sccoreui",
3
- "version": "5.1.4",
3
+ "version": "5.1.6",
4
4
  "description": "ui-sccore",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",