@lemonadejs/dropdown 3.0.3 → 3.0.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/dist/index.d.ts CHANGED
@@ -1,10 +1,8 @@
1
1
  interface DropdownItem {
2
2
  /** Value of the selected item. */
3
- id?: string | number;
4
- /** Label for the selected item. */
5
- name?: string;
3
+ value?: string | number;
6
4
  /** Description of the item */
7
- title?: string;
5
+ text?: string;
8
6
  /** Icon of the item */
9
7
  image?: string;
10
8
  /** Name of the group where the item belongs to */
@@ -18,8 +16,6 @@ interface DropdownItem {
18
16
  }
19
17
 
20
18
  interface DropdownOptions {
21
- /** Endpoint to fetch data from a remote server */
22
- url?: string;
23
19
  /** Preloaded data items for the dropdown */
24
20
  data?: DropdownItem[];
25
21
  /** Format type of the data, typically { id: name } or { value: text } */
@@ -28,16 +24,10 @@ interface DropdownOptions {
28
24
  multiple?: boolean;
29
25
  /** Enables the autocomplete feature for user input */
30
26
  autocomplete?: boolean;
31
- /** Allows remote search for options */
32
- remoteSearch?: boolean;
33
- /** Enables the lazy loading feature for handling a large number of options */
34
- lazyLoading?: boolean;
35
27
  /** Rendering style of the dropdown: 'default', 'picker', or 'searchbar' */
36
28
  type?: 'default' | 'picker' | 'searchbar',
37
29
  /** Defines the dropdown's width */
38
30
  width?: number;
39
- /** Sets the maximum width of the dropdown */
40
- maxWidth?: number;
41
31
  /** Determines if the dropdown is opened when initialized */
42
32
  opened?: boolean;
43
33
  /** The initial value of the dropdown */
package/dist/index.js CHANGED
@@ -309,7 +309,7 @@ if (!lazyloading && typeof (require) === 'function') {
309
309
  }
310
310
 
311
311
  return `<div class="lm-dropdown" data-type="{{self.type}}" data-state="{{self.state}}">
312
- <div class="lm-dropdown-input" onkeydown="self.toggle" onfocus="self.open" placeholder="{{self.placeholder}}" :ref="self.input" tabindex="0"></div>
312
+ <div class="lm-dropdown-input" onmousedown="self.toggle" onfocus="self.open" placeholder="{{self.placeholder}}" :ref="self.input" tabindex="0"></div>
313
313
  <Modal :ref="self.modal" :closed="true" :onclose="self.onclose" :onopen="self.onopen" :width="self.width" :animation="self.animation">
314
314
  <Lazyloading :data="self.data" :ref="self.lazyLoading" :height="330">
315
315
  <div class="lm-dropdown-item" onclick="self.parent.parent.parent.select" data-cursor="{{self.cursor}}" data-selected="{{self.selected}}" data-group="{{self.parent.parent.parent.getGroup(self.group)}}">
package/dist/react.js CHANGED
@@ -1,13 +1,10 @@
1
1
  // @ts-nocheck
2
- import React, { useRef, useEffect } from "react";
2
+ import React, { useRef, useEffect } from "react";
3
3
  import Component from './index';
4
4
 
5
- import "./style.css";
6
- import "@lemonadejs/modal/dist/style.css"
7
- import "@lemonadejs/lazy-loading/dist/style.css"
8
5
 
9
6
  // @ts-ignore
10
- const Dropdown = React.forwardRef((props, mainReference) => {
7
+ export default React.forwardRef((props, mainReference) => {
11
8
  // Dom element
12
9
  const Ref = useRef(null);
13
10
 
@@ -16,17 +13,25 @@ const Dropdown = React.forwardRef((props, mainReference) => {
16
13
 
17
14
  useEffect(() => {
18
15
  // @ts-ignore
19
- if (! Ref.current.innerHTML) {
16
+ if (!Ref.current.innerHTML) {
20
17
  mainReference.current = Component(Ref.current, options);
21
18
  }
22
19
  }, []);
23
20
 
21
+ useEffect(() => {
22
+ for (let key in props) {
23
+ if (props.hasOwnProperty(key) && mainReference.current.hasOwnProperty(key)) {
24
+ if (props[key] !== mainReference.current[key]) {
25
+ mainReference.current[key] = props[key];
26
+ }
27
+ }
28
+ }
29
+ }, [props])
30
+
24
31
  let prop = {
25
32
  ref: Ref,
26
33
  style: { height: '100%', width: '100%' }
27
34
  };
28
35
 
29
36
  return React.createElement("div", prop);
30
- })
31
-
32
- export default Dropdown;
37
+ })
package/dist/vue.js CHANGED
@@ -1,16 +1,12 @@
1
- import { h, getCurrentInstance } from 'vue';
1
+ import { h } from 'vue';
2
2
  import component from "./index";
3
3
 
4
- import "./style.css";
5
- import "@lemonadejs/modal/dist/style.css"
6
4
 
7
- export const Calendar = {
5
+ export default {
8
6
  inheritAttrs: false,
9
7
  mounted() {
10
- const { attrs } = getCurrentInstance();
11
-
12
8
  let options = {
13
- ...attrs
9
+ ...this.$attrs
14
10
  };
15
11
 
16
12
  this.el = this.$refs.container;
@@ -26,7 +22,24 @@ export const Calendar = {
26
22
  }
27
23
  };
28
24
  return () => h('div', containerProps);
25
+ },
26
+ watch: {
27
+ $attrs: {
28
+ deep: true,
29
+ handler() {
30
+ this.updateState();
31
+ }
32
+ }
33
+ },
34
+ methods: {
35
+ updateState() {
36
+ for (let key in this.$attrs) {
37
+ if (this.$attrs.hasOwnProperty(key) && this.current.hasOwnProperty(key)) {
38
+ if (this.$attrs[key] !== this.current[key]) {
39
+ this.current[key] = this.$attrs[key];
40
+ }
41
+ }
42
+ }
43
+ }
29
44
  }
30
45
  }
31
-
32
- export default Calendar;
package/package.json CHANGED
@@ -14,10 +14,10 @@
14
14
  "javascript plugins"
15
15
  ],
16
16
  "dependencies": {
17
- "lemonadejs": "^3.4.0",
17
+ "lemonadejs": "^4.0.6",
18
18
  "@lemonadejs/modal": "2.3.3",
19
19
  "@lemonadejs/lazy-loading": "1.0.0"
20
20
  },
21
21
  "main": "dist/index.js",
22
- "version": "3.0.3"
22
+ "version": "3.0.4"
23
23
  }