jb-select 7.0.1 → 7.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.
@@ -1,17 +1,18 @@
1
- import { JBSelectWebComponent, type ValidationValue } from "jb-select";
2
- import { type ValidationItem } from "jb-validation";
3
- import { RefObject, useEffect } from "react";
1
+ import type { JBSelectWebComponent, ValidationValue } from "jb-select";
2
+ import type { ValidationItem } from "jb-validation";
3
+ import { type RefObject, useEffect } from "react";
4
4
 
5
5
  export type JBSelectAttributes<TValue> = {
6
6
  validationList?: ValidationItem<ValidationValue<TValue>>[],
7
7
  name?: string,
8
8
  label?: string,
9
9
  error?: string,
10
- value?: any,
10
+ value?: TValue,
11
11
  message?: string,
12
12
  placeholder?: string,
13
13
  searchPlaceholder?: string,
14
14
  required?: boolean,
15
+ hideClear?:boolean,
15
16
  getSelectedValueDOM?: (option: any) => HTMLElement,
16
17
 
17
18
  }
@@ -23,18 +24,20 @@ export function useJBSelectAttribute<TValue>(element: RefObject<JBSelectWebCompo
23
24
  element.current?.removeAttribute("message");
24
25
  }
25
26
  }, [props.message]);
27
+
26
28
  useEffect(() => {
27
- if (element && element.current) {
29
+ if (element?.current) {
28
30
  element.current.validation.list = props.validationList || [];
29
31
  }
30
- }, [props.validationList]);
32
+ }, [element.current, props.validationList]);
33
+
31
34
  useEffect(() => {
32
35
  if (props.label !== null && props.label !== undefined) {
33
36
  element.current?.setAttribute("label", props.label);
34
37
  } else {
35
38
  element.current?.removeAttribute("label");
36
39
  }
37
- }, [props.label]);
40
+ }, [props.label, element.current]);
38
41
 
39
42
  useEffect(() => {
40
43
  if (props.required !== null && props.required !== undefined) {
@@ -42,13 +45,22 @@ export function useJBSelectAttribute<TValue>(element: RefObject<JBSelectWebCompo
42
45
  } else {
43
46
  element.current?.removeAttribute("required");
44
47
  }
45
- }, [props.required]);
48
+ }, [props.required, element]);
49
+
50
+ useEffect(() => {
51
+ if (props.hideClear !== null && props.hideClear !== undefined) {
52
+ element.current?.setAttribute("hide-clear", "");
53
+ } else {
54
+ element.current?.removeAttribute("hide-clear");
55
+ }
56
+ }, [props.hideClear, element]);
46
57
 
47
58
  useEffect(() => {
48
59
  if (props.placeholder !== null && props.placeholder !== undefined) {
49
60
  element.current?.setAttribute("placeholder", props.placeholder);
50
61
  }
51
- }, [props.placeholder]);
62
+ }, [props.placeholder,element]);
63
+
52
64
  useEffect(() => {
53
65
  if (props.searchPlaceholder !== null && props.searchPlaceholder !== undefined) {
54
66
  element.current?.setAttribute("search-placeholder", props.searchPlaceholder);
@@ -1,5 +1,5 @@
1
1
  import { useEvent } from "jb-core/react";
2
- import { RefObject } from "react";
2
+ import type { RefObject } from "react";
3
3
  import type { JBSelectWebComponent, JBSelectEventType } from 'jb-select';
4
4
 
5
5
  export type EventProps = {