jb-select 7.1.0 → 7.1.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/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.br +0 -0
- package/dist/index.cjs.js.gz +0 -0
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.br +0 -0
- package/dist/index.js.gz +0 -0
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.br +0 -0
- package/dist/index.umd.js.gz +0 -0
- package/dist/index.umd.js.map +1 -1
- package/dist/jb-option/jb-option.d.ts +2 -2
- package/dist/jb-option/jb-option.d.ts.map +1 -1
- package/dist/jb-option/types.d.ts +7 -0
- package/dist/jb-option/types.d.ts.map +1 -1
- package/dist/jb-option-list/jb-option-list.d.ts +1 -1
- package/dist/jb-option-list/jb-option-list.d.ts.map +1 -1
- package/dist/jb-select.d.ts +6 -5
- package/dist/jb-select.d.ts.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/lib/jb-option/jb-option.ts +7 -7
- package/lib/jb-option/types.ts +8 -0
- package/lib/jb-option-list/jb-option-list.ts +5 -3
- package/lib/jb-select.ts +41 -35
- package/lib/types.ts +1 -1
- package/lib/variables.css +1 -1
- package/package.json +3 -3
- package/react/dist/JBOption.d.ts +5 -11
- package/react/dist/JBSelect.d.ts +2 -21
- package/react/dist/attributes-hook.d.ts +1 -1
- package/react/dist/events-hook.d.ts +1 -1
- package/react/dist/index.cjs.js +1 -1
- package/react/dist/index.cjs.js.map +1 -1
- package/react/dist/index.js +1 -1
- package/react/dist/index.js.map +1 -1
- package/react/dist/index.umd.js +1 -1
- package/react/dist/index.umd.js.map +1 -1
- package/react/dist/module-declaration.d.ts +22 -0
- package/react/lib/JBOption.tsx +12 -26
- package/react/lib/JBSelect.tsx +6 -24
- package/react/lib/attributes-hook.ts +1 -1
- package/react/lib/events-hook.ts +1 -1
- package/react/lib/module-declaration.ts +23 -0
- package/react/tsconfig.json +1 -1
package/react/lib/JBSelect.tsx
CHANGED
|
@@ -7,35 +7,18 @@ import type { JBSelectWebComponent, SizeVariants } from 'jb-select';
|
|
|
7
7
|
import { type EventProps, useEvents } from './events-hook.js';
|
|
8
8
|
import { useJBSelectAttribute, type JBSelectAttributes } from './attributes-hook.js';
|
|
9
9
|
import type { JBElementStandardProps } from 'jb-core/react';
|
|
10
|
+
import './module-declaration.js';
|
|
10
11
|
export type JBSelectEventType<T> = T & {
|
|
11
12
|
target: JBSelectWebComponent
|
|
12
13
|
}
|
|
13
|
-
declare module "react" {
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
15
|
-
namespace JSX {
|
|
16
|
-
interface IntrinsicElements {
|
|
17
|
-
'jb-select': JBSelectType;
|
|
18
|
-
}
|
|
19
|
-
interface JBSelectType extends React.DetailedHTMLProps<React.HTMLAttributes<JBSelectWebComponent>, JBSelectWebComponent> {
|
|
20
|
-
class?: string,
|
|
21
|
-
label?: string,
|
|
22
|
-
name?: string,
|
|
23
|
-
required?: string | boolean,
|
|
24
|
-
message?: string,
|
|
25
|
-
tabindex?: string,
|
|
26
|
-
size?: string,
|
|
27
|
-
"hide-clean"?: string,
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
14
|
export function JBSelect<TValue>(props: Props<TValue>) {
|
|
32
15
|
const element = useRef<JBSelectWebComponent>(null);
|
|
16
|
+
const { onChange, onInit, onInput, onKeyUp, onLoad, ref, error, getSelectedValueDOM, label, required, message, placeholder, searchPlaceholder, validationList, value, hideClear, ...otherProps } = props;
|
|
33
17
|
useImperativeHandle(
|
|
34
|
-
|
|
35
|
-
() => (element
|
|
18
|
+
ref,
|
|
19
|
+
() => (element.current??undefined),
|
|
36
20
|
[element],
|
|
37
21
|
);
|
|
38
|
-
const { onChange, onInit, onInput, onKeyUp, onLoad, error, getSelectedValueDOM, label, required, message, placeholder, searchPlaceholder, validationList, value, hideClear, ...otherProps } = props;
|
|
39
22
|
useEvents(element, { onChange, onInit, onInput, onKeyUp, onLoad });
|
|
40
23
|
useJBSelectAttribute(element, { error, getSelectedValueDOM, label, required, message, placeholder, searchPlaceholder, validationList, value, hideClear });
|
|
41
24
|
return (
|
|
@@ -46,9 +29,8 @@ export function JBSelect<TValue>(props: Props<TValue>) {
|
|
|
46
29
|
};
|
|
47
30
|
|
|
48
31
|
export type Props<TValue> = PropsWithChildren<EventProps & JBSelectAttributes<TValue>> & JBElementStandardProps<JBSelectWebComponent, keyof EventProps & JBSelectAttributes<TValue>> & {
|
|
49
|
-
ref?: React.
|
|
32
|
+
ref?: React.ForwardedRef<JBSelectWebComponent|null|undefined>,
|
|
50
33
|
size?: SizeVariants,
|
|
51
34
|
name?: string,
|
|
52
35
|
disabled?:boolean,
|
|
53
|
-
}
|
|
54
|
-
JBSelect.displayName = 'JBSelect';
|
|
36
|
+
}
|
|
@@ -15,7 +15,7 @@ export type JBSelectAttributes<TValue> = {
|
|
|
15
15
|
getSelectedValueDOM?: (option: any) => HTMLElement,
|
|
16
16
|
|
|
17
17
|
}
|
|
18
|
-
export function useJBSelectAttribute<TValue>(element: RefObject<JBSelectWebComponent>, props: JBSelectAttributes<TValue>) {
|
|
18
|
+
export function useJBSelectAttribute<TValue>(element: RefObject<JBSelectWebComponent|null>, props: JBSelectAttributes<TValue>) {
|
|
19
19
|
useEffect(() => {
|
|
20
20
|
if (props.message !== null && props.message !== undefined) {
|
|
21
21
|
element.current?.setAttribute("message", props.message);
|
package/react/lib/events-hook.ts
CHANGED
|
@@ -15,7 +15,7 @@ export type EventProps = {
|
|
|
15
15
|
onKeyUp?: (e: JBSelectEventType<KeyboardEvent>) => void,
|
|
16
16
|
onInput?: (e: JBSelectEventType<InputEvent>) => void,
|
|
17
17
|
}
|
|
18
|
-
export function useEvents(element: RefObject<JBSelectWebComponent>, props: EventProps) {
|
|
18
|
+
export function useEvents(element: RefObject<JBSelectWebComponent|null>, props: EventProps) {
|
|
19
19
|
useEvent(element, 'load', props.onLoad, true);
|
|
20
20
|
useEvent(element, 'init', props.onInit, true);
|
|
21
21
|
useEvent(element, 'keyup', props.onKeyUp);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { JBOptionWebComponent, JBSelectWebComponent } from "jb-select";
|
|
2
|
+
|
|
3
|
+
declare module "react" {
|
|
4
|
+
namespace JSX {
|
|
5
|
+
interface IntrinsicElements {
|
|
6
|
+
'jb-option': JBOptionType;
|
|
7
|
+
'jb-select': JBSelectType;
|
|
8
|
+
}
|
|
9
|
+
interface JBOptionType extends React.DetailedHTMLProps<React.HTMLAttributes<JBOptionWebComponent<any>>, JBOptionWebComponent<any>> {
|
|
10
|
+
class?: string,
|
|
11
|
+
}
|
|
12
|
+
interface JBSelectType extends React.DetailedHTMLProps<React.HTMLAttributes<JBSelectWebComponent>, JBSelectWebComponent> {
|
|
13
|
+
class?: string,
|
|
14
|
+
label?: string,
|
|
15
|
+
name?: string,
|
|
16
|
+
required?: string | boolean,
|
|
17
|
+
message?: string,
|
|
18
|
+
tabindex?: string,
|
|
19
|
+
size?: string,
|
|
20
|
+
"hide-clean"?: string,
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|