jb-select 6.0.5 → 6.1.0
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/README.md +10 -4
- package/dist/index.cjs.js +2 -2
- 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.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -2
- 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 +2 -2
- 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 +22 -0
- package/dist/jb-option/jb-option.d.ts.map +1 -0
- package/dist/jb-option/render.d.ts +2 -0
- package/dist/jb-option/render.d.ts.map +1 -0
- package/dist/jb-option/types.d.ts +5 -0
- package/dist/jb-option/types.d.ts.map +1 -0
- package/dist/jb-option-list/jb-option-list.d.ts +11 -0
- package/dist/jb-option-list/jb-option-list.d.ts.map +1 -0
- package/dist/jb-option-list/types.d.ts +6 -0
- package/dist/jb-option-list/types.d.ts.map +1 -0
- package/dist/jb-select.d.ts +60 -0
- package/dist/jb-select.d.ts.map +1 -0
- package/dist/lib/index.d.ts +7 -0
- package/dist/lib/jb-option/jb-option.d.ts +21 -0
- package/dist/lib/jb-option/render.d.ts +1 -0
- package/dist/lib/jb-option/types.d.ts +4 -0
- package/dist/lib/jb-option-list/jb-option-list.d.ts +10 -0
- package/dist/lib/jb-option-list/types.d.ts +5 -0
- package/dist/lib/jb-select.d.ts +59 -0
- package/dist/lib/types.d.ts +27 -0
- package/dist/types.d.ts +28 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/web-component/jb-select/lib/jb-select.d.ts +3 -0
- package/dist/web-component/jb-select/lib/types.d.ts +4 -1
- package/lib/global.d.ts +15 -0
- package/lib/jb-option/jb-option.ts +4 -0
- package/lib/jb-select.scss +1 -1
- package/lib/jb-select.ts +23 -8
- package/lib/types.ts +6 -3
- package/package.json +8 -4
- package/react/README.md +15 -55
- package/react/dist/JBOption.d.ts +19 -0
- package/react/dist/JBOptionList.d.ts +22 -0
- package/react/dist/JBSelect.d.ts +50 -0
- package/react/dist/events-hook.d.ts +16 -0
- package/react/dist/index.cjs.js +2 -122
- package/react/dist/index.cjs.js.map +1 -1
- package/react/dist/index.d.ts +3 -0
- package/react/dist/index.js +2 -118
- package/react/dist/index.js.map +1 -1
- package/react/dist/index.umd.js +2 -125
- package/react/dist/index.umd.js.map +1 -1
- package/react/dist/lib/JBOption.d.ts +19 -0
- package/react/dist/lib/JBOptionList.d.ts +22 -0
- package/react/dist/lib/JBSelect.d.ts +48 -0
- package/react/dist/lib/events-hook.d.ts +16 -0
- package/react/dist/lib/index.d.ts +3 -0
- package/react/dist/web-component/jb-select/react/lib/JBSelect.d.ts +15 -5
- package/react/dist/web-component/jb-select/react/lib/events-hook.d.ts +16 -0
- package/react/lib/JBSelect.tsx +12 -24
- package/react/lib/events-hook.ts +24 -0
- package/react/package.json +1 -1
- package/react/tsconfig.json +3 -4
- package/dist/jb-select.cjs.js +0 -2
- package/dist/jb-select.cjs.js.br +0 -0
- package/dist/jb-select.cjs.js.gz +0 -0
- package/dist/jb-select.cjs.js.map +0 -1
- package/dist/jb-select.js +0 -2
- package/dist/jb-select.js.br +0 -0
- package/dist/jb-select.js.gz +0 -0
- package/dist/jb-select.js.map +0 -1
- package/dist/jb-select.umd.js +0 -2
- package/dist/jb-select.umd.js.br +0 -0
- package/dist/jb-select.umd.js.gz +0 -0
- package/dist/jb-select.umd.js.map +0 -1
package/react/dist/index.cjs.js
CHANGED
|
@@ -1,122 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var React = require('react');
|
|
4
|
-
require('jb-select');
|
|
5
|
-
|
|
6
|
-
/* eslint-disable react/display-name */
|
|
7
|
-
const JBOptionList = React.forwardRef((props, ref) => {
|
|
8
|
-
const element = React.useRef(null);
|
|
9
|
-
React.useImperativeHandle(ref, () => (element ? element.current : undefined), [element]);
|
|
10
|
-
React.useEffect(() => {
|
|
11
|
-
if (element.current && Array.isArray(props.optionList)) {
|
|
12
|
-
element.current.optionList = props.optionList;
|
|
13
|
-
}
|
|
14
|
-
}, [props.optionList, element]);
|
|
15
|
-
React.useEffect(() => {
|
|
16
|
-
if (element.current && typeof props.getTitle == "function") {
|
|
17
|
-
element.current.setCallback("getTitle", props.getTitle);
|
|
18
|
-
}
|
|
19
|
-
}, [props.getTitle, element]);
|
|
20
|
-
React.useEffect(() => {
|
|
21
|
-
if (element.current && typeof props.getValue == "function") {
|
|
22
|
-
element.current.setCallback("getValue", props.getValue);
|
|
23
|
-
}
|
|
24
|
-
}, [props.getValue, element]);
|
|
25
|
-
React.useEffect(() => {
|
|
26
|
-
if (element.current && typeof props.getContentDOM == "function") {
|
|
27
|
-
element.current.setCallback("getContentDOM", props.getContentDOM);
|
|
28
|
-
}
|
|
29
|
-
}, [props.getContentDOM, element]);
|
|
30
|
-
return (React.createElement("jb-option-list", { ref: element }));
|
|
31
|
-
});
|
|
32
|
-
JBOptionList.displayName = 'JBOptionList';
|
|
33
|
-
|
|
34
|
-
function useBindEvent(ref, event, handler, passive = false) {
|
|
35
|
-
React.useEffect(() => {
|
|
36
|
-
const dom = ref.current;
|
|
37
|
-
if (dom) {
|
|
38
|
-
// initiate the event handler
|
|
39
|
-
dom.addEventListener(event, handler, passive);
|
|
40
|
-
}
|
|
41
|
-
// this will clean up the event every time the component is re-rendered
|
|
42
|
-
return function cleanup() {
|
|
43
|
-
if (dom) {
|
|
44
|
-
dom.removeEventListener(event, handler, passive);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
}, [ref, event, handler, passive]);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/* eslint-disable react/display-name */
|
|
51
|
-
const JBSelect = React.forwardRef((props, ref) => {
|
|
52
|
-
const element = React.useRef(null);
|
|
53
|
-
const [refChangeCount, refChangeCountSetter] = React.useState(0);
|
|
54
|
-
React.useImperativeHandle(ref, () => (element ? element.current : {}), [element]);
|
|
55
|
-
React.useEffect(() => {
|
|
56
|
-
refChangeCountSetter(refChangeCount + 1);
|
|
57
|
-
}, [element.current]);
|
|
58
|
-
React.useEffect(() => {
|
|
59
|
-
if (element.current) {
|
|
60
|
-
element.current.value = props.value;
|
|
61
|
-
}
|
|
62
|
-
}, [props.value]);
|
|
63
|
-
React.useEffect(() => {
|
|
64
|
-
if (typeof props.getSelectedValueDOM == "function" && element.current && element.current) {
|
|
65
|
-
element.current.callbacks.getSelectedValueDOM = props.getSelectedValueDOM;
|
|
66
|
-
}
|
|
67
|
-
}, [props.getSelectedValueDOM]);
|
|
68
|
-
React.useEffect(() => {
|
|
69
|
-
if (props.message !== null && props.message !== undefined) {
|
|
70
|
-
element.current?.setAttribute("message", props.message);
|
|
71
|
-
}
|
|
72
|
-
}, [props.message]);
|
|
73
|
-
React.useEffect(() => {
|
|
74
|
-
if (props.placeholder !== null && props.placeholder !== undefined) {
|
|
75
|
-
element.current?.setAttribute("placeholder", props.placeholder);
|
|
76
|
-
}
|
|
77
|
-
}, [props.placeholder]);
|
|
78
|
-
React.useEffect(() => {
|
|
79
|
-
if (props.searchPlaceholder !== null && props.searchPlaceholder !== undefined) {
|
|
80
|
-
element.current?.setAttribute("search-placeholder", props.searchPlaceholder);
|
|
81
|
-
}
|
|
82
|
-
}, [props.searchPlaceholder]);
|
|
83
|
-
function onKeyup(e) {
|
|
84
|
-
if (typeof props.onKeyup == "function") {
|
|
85
|
-
props.onKeyup(e);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
function onChange(e) {
|
|
89
|
-
if (typeof props.onChange == "function") {
|
|
90
|
-
props.onChange(e);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
function onInput(e) {
|
|
94
|
-
if (typeof props.onInput == "function") {
|
|
95
|
-
props.onInput(e);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
useBindEvent(element, 'keyup', onKeyup);
|
|
99
|
-
useBindEvent(element, 'change', onChange);
|
|
100
|
-
useBindEvent(element, 'input', onInput);
|
|
101
|
-
return (React.createElement("jb-select", { style: props.style ? props.style : undefined, class: props.className ? props.className : "", label: props.label, ref: element, required: props.required || 'false', name: props.name ?? undefined }, props.children));
|
|
102
|
-
});
|
|
103
|
-
JBSelect.displayName = 'JBSelect';
|
|
104
|
-
|
|
105
|
-
/* eslint-disable react/display-name */
|
|
106
|
-
const JBOption = React.forwardRef((props, ref) => {
|
|
107
|
-
const element = React.useRef(null);
|
|
108
|
-
const { value, children, className, ...rest } = props;
|
|
109
|
-
React.useImperativeHandle(ref, () => (element ? element.current : undefined), [element]);
|
|
110
|
-
React.useEffect(() => {
|
|
111
|
-
if (element.current && value !== undefined) {
|
|
112
|
-
element.current.value = value;
|
|
113
|
-
}
|
|
114
|
-
}, [value, element]);
|
|
115
|
-
return (React.createElement("jb-option", { class: className, ref: element, ...rest }, children));
|
|
116
|
-
});
|
|
117
|
-
JBOption.displayName = 'JBOption';
|
|
118
|
-
|
|
119
|
-
exports.JBOption = JBOption;
|
|
120
|
-
exports.JBOptionList = JBOptionList;
|
|
121
|
-
exports.JBSelect = JBSelect;
|
|
122
|
-
//# sourceMappingURL=index.cjs.js.map
|
|
1
|
+
"use strict";var e=Object.create,t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,l=Object.getOwnPropertyNames,u=Object.getPrototypeOf,n=Object.prototype.hasOwnProperty,c=(e,u,c,a)=>{if(u&&"object"==typeof u||"function"==typeof u)for(var o,s=l(u),i=0,f=s.length;i<f;i++)o=s[i],n.call(e,o)||o===c||t(e,o,{get:(e=>u[e]).bind(null,o),enumerable:!(a=r(u,o))||a.enumerable});return e},a=(r,l,n)=>(n=null!=r?e(u(r)):{},c(!l&&r&&r.__esModule?n:t(n,"default",{value:r,enumerable:!0}),r));const o=a(require("react"));require("jb-select");const s=a(require("jb-core/react")),i=o.default.forwardRef((e,t)=>{let r=(0,o.useRef)(null);return(0,o.useImperativeHandle)(t,()=>r?r.current:void 0,[r]),(0,o.useEffect)(()=>{r.current&&Array.isArray(e.optionList)&&(r.current.optionList=e.optionList)},[e.optionList,r]),(0,o.useEffect)(()=>{r.current&&"function"==typeof e.getTitle&&r.current.setCallback("getTitle",e.getTitle)},[e.getTitle,r]),(0,o.useEffect)(()=>{r.current&&"function"==typeof e.getValue&&r.current.setCallback("getValue",e.getValue)},[e.getValue,r]),(0,o.useEffect)(()=>{r.current&&"function"==typeof e.getContentDOM&&r.current.setCallback("getContentDOM",e.getContentDOM)},[e.getContentDOM,r]),o.default.createElement("jb-option-list",{ref:r})});i.displayName="JBOptionList";const f=o.default.forwardRef((e,t)=>{let r=(0,o.useRef)(null),[l,u]=(0,o.useState)(0);return(0,o.useImperativeHandle)(t,()=>r?r.current:{},[r]),(0,o.useEffect)(()=>{u(l+1)},[r.current]),(0,o.useEffect)(()=>{r.current&&(r.current.value=e.value)},[e.value]),(0,o.useEffect)(()=>{"function"==typeof e.getSelectedValueDOM&&r.current&&r.current&&(r.current.callbacks.getSelectedValueDOM=e.getSelectedValueDOM)},[e.getSelectedValueDOM]),(0,o.useEffect)(()=>{null!==e.message&&void 0!==e.message&&r.current?.setAttribute("message",e.message)},[e.message]),(0,o.useEffect)(()=>{null!==e.placeholder&&void 0!==e.placeholder&&r.current?.setAttribute("placeholder",e.placeholder)},[e.placeholder]),(0,o.useEffect)(()=>{null!==e.searchPlaceholder&&void 0!==e.searchPlaceholder&&r.current?.setAttribute("search-placeholder",e.searchPlaceholder)},[e.searchPlaceholder]),(0,o.useEffect)(()=>{e.error?r?.current?.setAttribute("error",e.error):r?.current?.removeAttribute("error")},[e.error]),(0,s.useEvent)(r,"load",e.onLoad,!0),(0,s.useEvent)(r,"init",e.onInit,!0),(0,s.useEvent)(r,"keyup",e.onKeyUp),(0,s.useEvent)(r,"change",e.onChange),(0,s.useEvent)(r,"input",e.onInput),o.default.createElement("jb-select",{style:e.style?e.style:void 0,class:e.className?e.className:"",label:e.label,ref:r,required:e.required||"false",name:e.name??void 0},e.children)});f.displayName="JBSelect";const d=o.default.forwardRef((e,t)=>{let r=(0,o.useRef)(null),{value:l,children:u,className:n,...c}=e;return(0,o.useImperativeHandle)(t,()=>r?r.current:void 0,[r]),(0,o.useEffect)(()=>{r.current&&void 0!==l&&(r.current.value=l)},[l,r]),o.default.createElement("jb-option",{class:n,ref:r,...c},u)});d.displayName="JBOption",exports.JBOption=d,exports.JBOptionList=i,exports.JBSelect=f;
|
|
2
|
+
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../lib/JBOptionList.tsx","../../../../common/hooks/use-event.ts","../lib/JBSelect.tsx","../lib/JBOption.tsx"],"sourcesContent":["/* eslint-disable react/display-name */\r\nimport React, { useEffect, useRef, useImperativeHandle } from 'react';\r\n// eslint-disable-next-line no-duplicate-imports\r\nimport { JBOptionListWebComponent } from 'jb-select';\r\ntype TOption = any;\r\ntype TValue = any;\r\n\r\ndeclare global {\r\n // eslint-disable-next-line @typescript-eslint/no-namespace\r\n namespace JSX {\r\n interface IntrinsicElements {\r\n 'jb-option-list': JBOptionListType;\r\n }\r\n interface JBOptionListType extends React.DetailedHTMLProps<React.HTMLAttributes<JBOptionListWebComponent<TOption, TValue>>, JBOptionListWebComponent<TOption, TValue>> {\r\n class?: string,\r\n // ref:React.RefObject<JBDateInputWebComponent>,\r\n }\r\n }\r\n}\r\nexport const JBOptionList = React.forwardRef((props: JBOptionListProps<TOption,TValue>, ref) => {\r\n const element = useRef<JBOptionListWebComponent<TOption, TValue>>(null);\r\n useImperativeHandle(\r\n ref,\r\n () => (element ? element.current : undefined),\r\n [element],\r\n );\r\n useEffect(() => {\r\n if (element.current && Array.isArray(props.optionList)) {\r\n element.current.optionList = props.optionList;\r\n }\r\n }, [props.optionList, element]);\r\n useEffect(() => {\r\n if (element.current && typeof props.getTitle == \"function\") {\r\n element.current.setCallback(\"getTitle\",props.getTitle);\r\n }\r\n }, [props.getTitle, element]);\r\n useEffect(() => {\r\n if (element.current && typeof props.getValue == \"function\") {\r\n element.current.setCallback(\"getValue\",props.getValue);\r\n }\r\n }, [props.getValue, element]);\r\n useEffect(() => {\r\n if (element.current && typeof props.getContentDOM == \"function\") {\r\n element.current.setCallback(\"getContentDOM\",props.getContentDOM);\r\n }\r\n }, [props.getContentDOM, element]);\r\n return (\r\n <jb-option-list ref={element}>\r\n </jb-option-list>\r\n );\r\n});\r\n\r\nexport type JBOptionListProps<TOption,TValue> = {\r\n optionList: TOption[],\r\n getTitle?: (option: TOption) => string,\r\n getValue?: (option: TOption) => TValue,\r\n getContentDOM?: (option: TOption) => HTMLElement,\r\n}\r\nJBOptionList.displayName = 'JBOptionList';","import { useEffect } from \"react\";\r\n\r\nexport function useEvent(dom:HTMLElement, event:any, handler:any, passive = false) {\r\n useEffect(() => {\r\n if (dom) {\r\n // initiate the event handler\r\n dom.addEventListener(event, handler, passive); \r\n }\r\n // this will clean up the event every time the component is re-rendered\r\n return function cleanup() {\r\n if(dom){\r\n dom.removeEventListener(event, handler, passive);\r\n }\r\n };\r\n });\r\n}\r\nexport function useBindEvent<TRef extends React.MutableRefObject<any|null>,TEvent>(ref:TRef, event:string, handler:(e:TEvent)=>void, passive = false) {\r\n useEffect(() => {\r\n const dom = ref.current;\r\n if (dom) {\r\n // initiate the event handler\r\n dom.addEventListener(event, handler, passive); \r\n }\r\n // this will clean up the event every time the component is re-rendered\r\n return function cleanup() {\r\n if(dom){\r\n dom.removeEventListener(event, handler, passive);\r\n }\r\n };\r\n },[ref,event,handler,passive]);\r\n}","/* eslint-disable react/display-name */\r\nimport React, { useEffect, useRef, useState, useImperativeHandle,CSSProperties } from 'react';\r\nimport 'jb-select';\r\nimport { useBindEvent } from '../../../../common/hooks/use-event.js';\r\n// eslint-disable-next-line no-duplicate-imports\r\nimport { JBSelectWebComponent } from 'jb-select';\r\nexport type JBSelectEventType<T> = T & {\r\n target: JBSelectWebComponent\r\n}\r\ndeclare global {\r\n // eslint-disable-next-line @typescript-eslint/no-namespace\r\n namespace JSX {\r\n interface IntrinsicElements {\r\n 'jb-select': JBSelectType;\r\n }\r\n interface JBSelectType extends React.DetailedHTMLProps<React.HTMLAttributes<JBSelectWebComponent>, JBSelectWebComponent> {\r\n class?:string,\r\n label?: string,\r\n name?:string,\r\n required?:string | boolean,\r\n message?:string,\r\n tabindex?:string,\r\n // ref:React.RefObject<JBDateInputWebComponent>,\r\n }\r\n }\r\n}\r\n\r\nexport const JBSelect = React.forwardRef((props:JBSelectProps, ref) => {\r\n const element = useRef<JBSelectWebComponent>(null);\r\n const [refChangeCount, refChangeCountSetter] = useState(0);\r\n useImperativeHandle(\r\n ref,\r\n () => (element ? element.current : {}),\r\n [element],\r\n );\r\n useEffect(() => {\r\n refChangeCountSetter(refChangeCount + 1);\r\n }, [element.current]);\r\n useEffect(() => {\r\n if(element.current){\r\n element.current.value = props.value;\r\n }\r\n }, [props.value]);\r\n useEffect(() => {\r\n if (typeof props.getSelectedValueDOM == \"function\" && element.current && element.current) {\r\n element.current.callbacks.getSelectedValueDOM = props.getSelectedValueDOM;\r\n }\r\n }, [props.getSelectedValueDOM]);\r\n useEffect(() => {\r\n if (props.message !== null && props.message !== undefined ) {\r\n element.current?.setAttribute(\"message\", props.message);\r\n }\r\n }, [props.message]);\r\n useEffect(() => {\r\n if (props.placeholder !== null && props.placeholder !== undefined) {\r\n element.current?.setAttribute(\"placeholder\", props.placeholder);\r\n }\r\n }, [props.placeholder]);\r\n useEffect(() => {\r\n if (props.searchPlaceholder !== null && props.searchPlaceholder !== undefined) {\r\n element.current?.setAttribute(\"search-placeholder\", props.searchPlaceholder);\r\n }\r\n }, [props.searchPlaceholder]);\r\n function onKeyup(e:JBSelectEventType<KeyboardEvent>) {\r\n if ( typeof props.onKeyup == \"function\") {\r\n props.onKeyup(e);\r\n }\r\n }\r\n function onChange(e:JBSelectEventType<Event>) {\r\n if (typeof props.onChange ==\"function\") {\r\n props.onChange(e);\r\n }\r\n }\r\n function onInput(e:JBSelectEventType<InputEvent>) {\r\n if (typeof props.onInput == \"function\") {\r\n props.onInput(e);\r\n }\r\n }\r\n useBindEvent(element, 'keyup', onKeyup);\r\n useBindEvent(element, 'change', onChange);\r\n useBindEvent(element, 'input', onInput);\r\n return (\r\n <jb-select style={props.style?props.style:undefined} class={props.className?props.className:\"\"} label={props.label} ref={element} required={props.required || 'false'} name={props.name??undefined}>\r\n {props.children}\r\n </jb-select>\r\n );\r\n});\r\n\r\nexport type JBSelectProps = {\r\n style?:CSSProperties,\r\n label?: string,\r\n getSelectedValueDOM?: (option:any)=>HTMLElement,\r\n value?: any,\r\n onChange?: (e:JBSelectEventType<Event>)=>void,\r\n onKeyup?: (e:JBSelectEventType<KeyboardEvent>)=>void,\r\n onInput?: (e:JBSelectEventType<InputEvent>)=>void,\r\n required?: boolean,\r\n message?: string,\r\n placeholder?: string,\r\n searchPlaceholder?: string,\r\n className?: string,\r\n children?:React.ReactNode,\r\n name?:string\r\n}\r\nJBSelect.displayName = 'JBSelect';","/* eslint-disable react/display-name */\r\nimport React, { useEffect, useRef, useImperativeHandle, PropsWithChildren, ComponentProps } from 'react';\r\nimport { JBOptionWebComponent } from 'jb-select';\r\n//TODO: make it generic when remove forward ref\r\ntype TValue = any;\r\n\r\ndeclare global {\r\n // eslint-disable-next-line @typescript-eslint/no-namespace\r\n namespace JSX {\r\n interface IntrinsicElements {\r\n 'jb-option': JBOptionType;\r\n }\r\n interface JBOptionType extends React.DetailedHTMLProps<React.HTMLAttributes<JBOptionWebComponent<TValue>>, JBOptionWebComponent<TValue>> {\r\n class?: string,\r\n }\r\n }\r\n}\r\nexport const JBOption = React.forwardRef((props: JBOptionProps<TValue>, ref) => {\r\n const element = useRef<JBOptionWebComponent<TValue>>(null);\r\n const {value,children,className, ...rest} = props;\r\n useImperativeHandle(\r\n ref,\r\n () => (element ? element.current : undefined),\r\n [element],\r\n );\r\n \r\n useEffect(() => {\r\n if (element.current && value !== undefined) {\r\n element.current.value = value;\r\n }\r\n }, [value, element]);\r\n\r\n return (\r\n <jb-option class={className} ref={element} {...rest}>\r\n {children}\r\n </jb-option>\r\n );\r\n});\r\n\r\ntype Props<TValue> = {\r\n value:TValue\r\n}\r\n\r\nexport type JBOptionProps<TValue> = PropsWithChildren<JSX.JBOptionType & Props<TValue>>\r\nJBOption.displayName = 'JBOption';"],"names":["useRef","useImperativeHandle","useEffect","useState"],"mappings":";;;;;AAAA;AAmBO,MAAM,YAAY,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,KAAwC,EAAE,GAAG,KAAI;AAC7F,IAAA,MAAM,OAAO,GAAGA,YAAM,CAA4C,IAAI,CAAC,CAAC;IACxEC,yBAAmB,CACjB,GAAG,EACH,OAAO,OAAO,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,EAC7C,CAAC,OAAO,CAAC,CACV,CAAC;IACFC,eAAS,CAAC,MAAK;AACb,QAAA,IAAI,OAAO,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE;YACtD,OAAO,CAAC,OAAO,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC;AAC/C,SAAA;KACF,EAAE,CAAC,KAAK,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC;IAChCA,eAAS,CAAC,MAAK;QACb,IAAI,OAAO,CAAC,OAAO,IAAI,OAAO,KAAK,CAAC,QAAQ,IAAI,UAAU,EAAE;YAC1D,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,UAAU,EAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AACxD,SAAA;KACF,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;IAC9BA,eAAS,CAAC,MAAK;QACb,IAAI,OAAO,CAAC,OAAO,IAAI,OAAO,KAAK,CAAC,QAA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"version":3,"file":"index.cjs.js","names":[],"sources":["../lib/JBOptionList.tsx","../lib/events-hook.ts","../lib/JBSelect.tsx","../lib/JBOption.tsx"],"sourcesContent":["","","",""],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;MACY,6BAAuB,cAAA,WAAqB,CAAA,OAAM,QAAO;CAkBrE,MAAO,UAAM,kBAAY,KAAG;AAC1B,gCAAgB,KAAkD,MAAK,UAAA,QAAA,UAAA,WAAA,CACvE,OAKA,EAAA;sBACM,MAAA;MACF,QAAQ,WAAQ,MAAA,QAAa,MAAM,WAAU,CAC/C,SAAA,QAAA,aAAA,MAAA;CAEF,GAAA,CACE,MAAI;AAGN,sBAAU,MAAA;AACV,MAAA,QAAe,kBAAA,MAAA,YAAA,WACT,SAAQ,QAAO,YAAW,YAAc,MAAI,SAAU;KAGxD,MAAM,UACV;sBAEI,MAAA;AACF,MAAA,QAAA,kBAAA,MAAA,YAAA,WACE,SAAM,QAAa,YAAW,YAAA,MAAA,SAAA;CAKlC,GAAA,CAQF,MAAa;;;;;;;;;;ACzCP,SAAU,UAAU,SAA0C,OAAiB;AACnF,6BAAS,SAAS,QAAQ,MAAM,QAAQ,KAAK;AAC7C,6BAAS,SAAS,QAAQ,MAAM,QAAQ,KAAK;AAC7C,6BAAS,SAAS,SAAS,MAAM,QAAQ;AACzC,6BAAS,SAAS,UAAU,MAAM,SAAS;AAC3C,6BAAS,SAAS,SAAS,MAAM,QAAQ;AAC3C;;;;MClBqB,yBAAiB,cAAkB,WAAA,CAAA,OAAA,QAAA;CAsBxD,MAAO,UAAM,kBAAW,KAAM;CAC5B,MAAM,CAAA,gBAAuC,qBAAK,GAAA,oBAAA,EAAA;AAClD,gCAAO,KAAgB,MAAA,UAAA,QAAwB,UAAU,CAAC,GAAA,CAC1D,OAKA,EAAA;sBACE,MAAA;AACE,uBAAiB,iBAAA,EAAA;CACrB,GAAA,CACE,QAAG;sBAEH,MAAA;AACE,MAAA,QAAY,QAChB,SAAe,QAAA,QAAA,MAAA;KAGb,MAAA,KACD,EAAA;AACD,sBAAU,MAAG;AACX,aAAU,MAAO,uBAAmB,cAAY,QAAY,WAAA,QAAA,QAC1D,SAAQ,QAAO,UAAE,sBAA8B,MAAO;CAEzD,GAAE,CACH,MAAU;sBAEN,MAAA;AACF,MAAA,MAAA,YAAA,QAAA,MAAA,YAAA,UACE,SAAM,SAAa,aAAA,WAAA,MAAA,QAAA;WAGnB;AAEJ,sBAAU,MAAA;AACV,MAAA,MAAa,gBAAE,QAAA,MAAA,gBAAA,UACT,SAAM,SAAO,aAAA,eAAA,MAAA,YAAA;WAEV;sBAEP,MAAA;AACE,MAAA,MAAM,sBAAO,QAAA,MAAA,sBAAA,UACjB,SAAU,SAAc,aAAA,sBAAA,MAAA,kBAAA;CAMxB,GAAA,CAgBM,MAAC;;;;;;;;;;;;;;;;;;;MC3FG,yBAAuB,cAAA,WAAmB,CAAqC,OAAM,QAAO;CAgBxG,MAAO,UAAM,kBAAW,KAAM;CAC5B,MAAM,EAAA,OAAO,UAAwC,UAAK,GAAA,MAAA,GAAA;AAC1D,gCAAa,KAAS,MAAA,UAAc,QAAK,UAAQ,WAAA,CACjD,OAMA,EAAA;sBACM,MAAA;MACF,QAAQ,WAAQ,UAAa,UAC/B,SAAA,QAAA,QAAA;CAGF,GAAA,CAKA,OAOM"}
|
package/react/dist/index.js
CHANGED
|
@@ -1,118 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
/* eslint-disable react/display-name */
|
|
5
|
-
const JBOptionList = React.forwardRef((props, ref) => {
|
|
6
|
-
const element = useRef(null);
|
|
7
|
-
useImperativeHandle(ref, () => (element ? element.current : undefined), [element]);
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
if (element.current && Array.isArray(props.optionList)) {
|
|
10
|
-
element.current.optionList = props.optionList;
|
|
11
|
-
}
|
|
12
|
-
}, [props.optionList, element]);
|
|
13
|
-
useEffect(() => {
|
|
14
|
-
if (element.current && typeof props.getTitle == "function") {
|
|
15
|
-
element.current.setCallback("getTitle", props.getTitle);
|
|
16
|
-
}
|
|
17
|
-
}, [props.getTitle, element]);
|
|
18
|
-
useEffect(() => {
|
|
19
|
-
if (element.current && typeof props.getValue == "function") {
|
|
20
|
-
element.current.setCallback("getValue", props.getValue);
|
|
21
|
-
}
|
|
22
|
-
}, [props.getValue, element]);
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
if (element.current && typeof props.getContentDOM == "function") {
|
|
25
|
-
element.current.setCallback("getContentDOM", props.getContentDOM);
|
|
26
|
-
}
|
|
27
|
-
}, [props.getContentDOM, element]);
|
|
28
|
-
return (React.createElement("jb-option-list", { ref: element }));
|
|
29
|
-
});
|
|
30
|
-
JBOptionList.displayName = 'JBOptionList';
|
|
31
|
-
|
|
32
|
-
function useBindEvent(ref, event, handler, passive = false) {
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
const dom = ref.current;
|
|
35
|
-
if (dom) {
|
|
36
|
-
// initiate the event handler
|
|
37
|
-
dom.addEventListener(event, handler, passive);
|
|
38
|
-
}
|
|
39
|
-
// this will clean up the event every time the component is re-rendered
|
|
40
|
-
return function cleanup() {
|
|
41
|
-
if (dom) {
|
|
42
|
-
dom.removeEventListener(event, handler, passive);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
}, [ref, event, handler, passive]);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/* eslint-disable react/display-name */
|
|
49
|
-
const JBSelect = React.forwardRef((props, ref) => {
|
|
50
|
-
const element = useRef(null);
|
|
51
|
-
const [refChangeCount, refChangeCountSetter] = useState(0);
|
|
52
|
-
useImperativeHandle(ref, () => (element ? element.current : {}), [element]);
|
|
53
|
-
useEffect(() => {
|
|
54
|
-
refChangeCountSetter(refChangeCount + 1);
|
|
55
|
-
}, [element.current]);
|
|
56
|
-
useEffect(() => {
|
|
57
|
-
if (element.current) {
|
|
58
|
-
element.current.value = props.value;
|
|
59
|
-
}
|
|
60
|
-
}, [props.value]);
|
|
61
|
-
useEffect(() => {
|
|
62
|
-
if (typeof props.getSelectedValueDOM == "function" && element.current && element.current) {
|
|
63
|
-
element.current.callbacks.getSelectedValueDOM = props.getSelectedValueDOM;
|
|
64
|
-
}
|
|
65
|
-
}, [props.getSelectedValueDOM]);
|
|
66
|
-
useEffect(() => {
|
|
67
|
-
if (props.message !== null && props.message !== undefined) {
|
|
68
|
-
element.current?.setAttribute("message", props.message);
|
|
69
|
-
}
|
|
70
|
-
}, [props.message]);
|
|
71
|
-
useEffect(() => {
|
|
72
|
-
if (props.placeholder !== null && props.placeholder !== undefined) {
|
|
73
|
-
element.current?.setAttribute("placeholder", props.placeholder);
|
|
74
|
-
}
|
|
75
|
-
}, [props.placeholder]);
|
|
76
|
-
useEffect(() => {
|
|
77
|
-
if (props.searchPlaceholder !== null && props.searchPlaceholder !== undefined) {
|
|
78
|
-
element.current?.setAttribute("search-placeholder", props.searchPlaceholder);
|
|
79
|
-
}
|
|
80
|
-
}, [props.searchPlaceholder]);
|
|
81
|
-
function onKeyup(e) {
|
|
82
|
-
if (typeof props.onKeyup == "function") {
|
|
83
|
-
props.onKeyup(e);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
function onChange(e) {
|
|
87
|
-
if (typeof props.onChange == "function") {
|
|
88
|
-
props.onChange(e);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
function onInput(e) {
|
|
92
|
-
if (typeof props.onInput == "function") {
|
|
93
|
-
props.onInput(e);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
useBindEvent(element, 'keyup', onKeyup);
|
|
97
|
-
useBindEvent(element, 'change', onChange);
|
|
98
|
-
useBindEvent(element, 'input', onInput);
|
|
99
|
-
return (React.createElement("jb-select", { style: props.style ? props.style : undefined, class: props.className ? props.className : "", label: props.label, ref: element, required: props.required || 'false', name: props.name ?? undefined }, props.children));
|
|
100
|
-
});
|
|
101
|
-
JBSelect.displayName = 'JBSelect';
|
|
102
|
-
|
|
103
|
-
/* eslint-disable react/display-name */
|
|
104
|
-
const JBOption = React.forwardRef((props, ref) => {
|
|
105
|
-
const element = useRef(null);
|
|
106
|
-
const { value, children, className, ...rest } = props;
|
|
107
|
-
useImperativeHandle(ref, () => (element ? element.current : undefined), [element]);
|
|
108
|
-
useEffect(() => {
|
|
109
|
-
if (element.current && value !== undefined) {
|
|
110
|
-
element.current.value = value;
|
|
111
|
-
}
|
|
112
|
-
}, [value, element]);
|
|
113
|
-
return (React.createElement("jb-option", { class: className, ref: element, ...rest }, children));
|
|
114
|
-
});
|
|
115
|
-
JBOption.displayName = 'JBOption';
|
|
116
|
-
|
|
117
|
-
export { JBOption, JBOptionList, JBSelect };
|
|
118
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import e,{useEffect as t,useImperativeHandle as r,useRef as l,useState as n}from"react";import"jb-select";import{useEvent as a}from"jb-core/react";let o=e.forwardRef((n,a)=>{let o=l(null);return r(a,()=>o?o.current:void 0,[o]),t(()=>{o.current&&Array.isArray(n.optionList)&&(o.current.optionList=n.optionList)},[n.optionList,o]),t(()=>{o.current&&"function"==typeof n.getTitle&&o.current.setCallback("getTitle",n.getTitle)},[n.getTitle,o]),t(()=>{o.current&&"function"==typeof n.getValue&&o.current.setCallback("getValue",n.getValue)},[n.getValue,o]),t(()=>{o.current&&"function"==typeof n.getContentDOM&&o.current.setCallback("getContentDOM",n.getContentDOM)},[n.getContentDOM,o]),e.createElement("jb-option-list",{ref:o})});o.displayName="JBOptionList";let c=e.forwardRef((o,c)=>{let u=l(null),[i,s]=n(0);return r(c,()=>u?u.current:{},[u]),t(()=>{s(i+1)},[u.current]),t(()=>{u.current&&(u.current.value=o.value)},[o.value]),t(()=>{"function"==typeof o.getSelectedValueDOM&&u.current&&u.current&&(u.current.callbacks.getSelectedValueDOM=o.getSelectedValueDOM)},[o.getSelectedValueDOM]),t(()=>{null!==o.message&&void 0!==o.message&&u.current?.setAttribute("message",o.message)},[o.message]),t(()=>{null!==o.placeholder&&void 0!==o.placeholder&&u.current?.setAttribute("placeholder",o.placeholder)},[o.placeholder]),t(()=>{null!==o.searchPlaceholder&&void 0!==o.searchPlaceholder&&u.current?.setAttribute("search-placeholder",o.searchPlaceholder)},[o.searchPlaceholder]),t(()=>{o.error?u?.current?.setAttribute("error",o.error):u?.current?.removeAttribute("error")},[o.error]),a(u,"load",o.onLoad,!0),a(u,"init",o.onInit,!0),a(u,"keyup",o.onKeyUp),a(u,"change",o.onChange),a(u,"input",o.onInput),e.createElement("jb-select",{style:o.style?o.style:void 0,class:o.className?o.className:"",label:o.label,ref:u,required:o.required||"false",name:o.name??void 0},o.children)});c.displayName="JBSelect";let u=e.forwardRef((n,a)=>{let o=l(null),{value:c,children:u,className:i,...s}=n;return r(a,()=>o?o.current:void 0,[o]),t(()=>{o.current&&void 0!==c&&(o.current.value=c)},[c,o]),e.createElement("jb-option",{class:i,ref:o,...s},u)});u.displayName="JBOption";export{u as JBOption,o as JBOptionList,c as JBSelect};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
package/react/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../lib/JBOptionList.tsx","../../../../common/hooks/use-event.ts","../lib/JBSelect.tsx","../lib/JBOption.tsx"],"sourcesContent":["/* eslint-disable react/display-name */\r\nimport React, { useEffect, useRef, useImperativeHandle } from 'react';\r\n// eslint-disable-next-line no-duplicate-imports\r\nimport { JBOptionListWebComponent } from 'jb-select';\r\ntype TOption = any;\r\ntype TValue = any;\r\n\r\ndeclare global {\r\n // eslint-disable-next-line @typescript-eslint/no-namespace\r\n namespace JSX {\r\n interface IntrinsicElements {\r\n 'jb-option-list': JBOptionListType;\r\n }\r\n interface JBOptionListType extends React.DetailedHTMLProps<React.HTMLAttributes<JBOptionListWebComponent<TOption, TValue>>, JBOptionListWebComponent<TOption, TValue>> {\r\n class?: string,\r\n // ref:React.RefObject<JBDateInputWebComponent>,\r\n }\r\n }\r\n}\r\nexport const JBOptionList = React.forwardRef((props: JBOptionListProps<TOption,TValue>, ref) => {\r\n const element = useRef<JBOptionListWebComponent<TOption, TValue>>(null);\r\n useImperativeHandle(\r\n ref,\r\n () => (element ? element.current : undefined),\r\n [element],\r\n );\r\n useEffect(() => {\r\n if (element.current && Array.isArray(props.optionList)) {\r\n element.current.optionList = props.optionList;\r\n }\r\n }, [props.optionList, element]);\r\n useEffect(() => {\r\n if (element.current && typeof props.getTitle == \"function\") {\r\n element.current.setCallback(\"getTitle\",props.getTitle);\r\n }\r\n }, [props.getTitle, element]);\r\n useEffect(() => {\r\n if (element.current && typeof props.getValue == \"function\") {\r\n element.current.setCallback(\"getValue\",props.getValue);\r\n }\r\n }, [props.getValue, element]);\r\n useEffect(() => {\r\n if (element.current && typeof props.getContentDOM == \"function\") {\r\n element.current.setCallback(\"getContentDOM\",props.getContentDOM);\r\n }\r\n }, [props.getContentDOM, element]);\r\n return (\r\n <jb-option-list ref={element}>\r\n </jb-option-list>\r\n );\r\n});\r\n\r\nexport type JBOptionListProps<TOption,TValue> = {\r\n optionList: TOption[],\r\n getTitle?: (option: TOption) => string,\r\n getValue?: (option: TOption) => TValue,\r\n getContentDOM?: (option: TOption) => HTMLElement,\r\n}\r\nJBOptionList.displayName = 'JBOptionList';","import { useEffect } from \"react\";\r\n\r\nexport function useEvent(dom:HTMLElement, event:any, handler:any, passive = false) {\r\n useEffect(() => {\r\n if (dom) {\r\n // initiate the event handler\r\n dom.addEventListener(event, handler, passive); \r\n }\r\n // this will clean up the event every time the component is re-rendered\r\n return function cleanup() {\r\n if(dom){\r\n dom.removeEventListener(event, handler, passive);\r\n }\r\n };\r\n });\r\n}\r\nexport function useBindEvent<TRef extends React.MutableRefObject<any|null>,TEvent>(ref:TRef, event:string, handler:(e:TEvent)=>void, passive = false) {\r\n useEffect(() => {\r\n const dom = ref.current;\r\n if (dom) {\r\n // initiate the event handler\r\n dom.addEventListener(event, handler, passive); \r\n }\r\n // this will clean up the event every time the component is re-rendered\r\n return function cleanup() {\r\n if(dom){\r\n dom.removeEventListener(event, handler, passive);\r\n }\r\n };\r\n },[ref,event,handler,passive]);\r\n}","/* eslint-disable react/display-name */\r\nimport React, { useEffect, useRef, useState, useImperativeHandle,CSSProperties } from 'react';\r\nimport 'jb-select';\r\nimport { useBindEvent } from '../../../../common/hooks/use-event.js';\r\n// eslint-disable-next-line no-duplicate-imports\r\nimport { JBSelectWebComponent } from 'jb-select';\r\nexport type JBSelectEventType<T> = T & {\r\n target: JBSelectWebComponent\r\n}\r\ndeclare global {\r\n // eslint-disable-next-line @typescript-eslint/no-namespace\r\n namespace JSX {\r\n interface IntrinsicElements {\r\n 'jb-select': JBSelectType;\r\n }\r\n interface JBSelectType extends React.DetailedHTMLProps<React.HTMLAttributes<JBSelectWebComponent>, JBSelectWebComponent> {\r\n class?:string,\r\n label?: string,\r\n name?:string,\r\n required?:string | boolean,\r\n message?:string,\r\n tabindex?:string,\r\n // ref:React.RefObject<JBDateInputWebComponent>,\r\n }\r\n }\r\n}\r\n\r\nexport const JBSelect = React.forwardRef((props:JBSelectProps, ref) => {\r\n const element = useRef<JBSelectWebComponent>(null);\r\n const [refChangeCount, refChangeCountSetter] = useState(0);\r\n useImperativeHandle(\r\n ref,\r\n () => (element ? element.current : {}),\r\n [element],\r\n );\r\n useEffect(() => {\r\n refChangeCountSetter(refChangeCount + 1);\r\n }, [element.current]);\r\n useEffect(() => {\r\n if(element.current){\r\n element.current.value = props.value;\r\n }\r\n }, [props.value]);\r\n useEffect(() => {\r\n if (typeof props.getSelectedValueDOM == \"function\" && element.current && element.current) {\r\n element.current.callbacks.getSelectedValueDOM = props.getSelectedValueDOM;\r\n }\r\n }, [props.getSelectedValueDOM]);\r\n useEffect(() => {\r\n if (props.message !== null && props.message !== undefined ) {\r\n element.current?.setAttribute(\"message\", props.message);\r\n }\r\n }, [props.message]);\r\n useEffect(() => {\r\n if (props.placeholder !== null && props.placeholder !== undefined) {\r\n element.current?.setAttribute(\"placeholder\", props.placeholder);\r\n }\r\n }, [props.placeholder]);\r\n useEffect(() => {\r\n if (props.searchPlaceholder !== null && props.searchPlaceholder !== undefined) {\r\n element.current?.setAttribute(\"search-placeholder\", props.searchPlaceholder);\r\n }\r\n }, [props.searchPlaceholder]);\r\n function onKeyup(e:JBSelectEventType<KeyboardEvent>) {\r\n if ( typeof props.onKeyup == \"function\") {\r\n props.onKeyup(e);\r\n }\r\n }\r\n function onChange(e:JBSelectEventType<Event>) {\r\n if (typeof props.onChange ==\"function\") {\r\n props.onChange(e);\r\n }\r\n }\r\n function onInput(e:JBSelectEventType<InputEvent>) {\r\n if (typeof props.onInput == \"function\") {\r\n props.onInput(e);\r\n }\r\n }\r\n useBindEvent(element, 'keyup', onKeyup);\r\n useBindEvent(element, 'change', onChange);\r\n useBindEvent(element, 'input', onInput);\r\n return (\r\n <jb-select style={props.style?props.style:undefined} class={props.className?props.className:\"\"} label={props.label} ref={element} required={props.required || 'false'} name={props.name??undefined}>\r\n {props.children}\r\n </jb-select>\r\n );\r\n});\r\n\r\nexport type JBSelectProps = {\r\n style?:CSSProperties,\r\n label?: string,\r\n getSelectedValueDOM?: (option:any)=>HTMLElement,\r\n value?: any,\r\n onChange?: (e:JBSelectEventType<Event>)=>void,\r\n onKeyup?: (e:JBSelectEventType<KeyboardEvent>)=>void,\r\n onInput?: (e:JBSelectEventType<InputEvent>)=>void,\r\n required?: boolean,\r\n message?: string,\r\n placeholder?: string,\r\n searchPlaceholder?: string,\r\n className?: string,\r\n children?:React.ReactNode,\r\n name?:string\r\n}\r\nJBSelect.displayName = 'JBSelect';","/* eslint-disable react/display-name */\r\nimport React, { useEffect, useRef, useImperativeHandle, PropsWithChildren, ComponentProps } from 'react';\r\nimport { JBOptionWebComponent } from 'jb-select';\r\n//TODO: make it generic when remove forward ref\r\ntype TValue = any;\r\n\r\ndeclare global {\r\n // eslint-disable-next-line @typescript-eslint/no-namespace\r\n namespace JSX {\r\n interface IntrinsicElements {\r\n 'jb-option': JBOptionType;\r\n }\r\n interface JBOptionType extends React.DetailedHTMLProps<React.HTMLAttributes<JBOptionWebComponent<TValue>>, JBOptionWebComponent<TValue>> {\r\n class?: string,\r\n }\r\n }\r\n}\r\nexport const JBOption = React.forwardRef((props: JBOptionProps<TValue>, ref) => {\r\n const element = useRef<JBOptionWebComponent<TValue>>(null);\r\n const {value,children,className, ...rest} = props;\r\n useImperativeHandle(\r\n ref,\r\n () => (element ? element.current : undefined),\r\n [element],\r\n );\r\n \r\n useEffect(() => {\r\n if (element.current && value !== undefined) {\r\n element.current.value = value;\r\n }\r\n }, [value, element]);\r\n\r\n return (\r\n <jb-option class={className} ref={element} {...rest}>\r\n {children}\r\n </jb-option>\r\n );\r\n});\r\n\r\ntype Props<TValue> = {\r\n value:TValue\r\n}\r\n\r\nexport type JBOptionProps<TValue> = PropsWithChildren<JSX.JBOptionType & Props<TValue>>\r\nJBOption.displayName = 'JBOption';"],"names":[],"mappings":";;;AAAA;AAmBO,MAAM,YAAY,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,KAAwC,EAAE,GAAG,KAAI;AAC7F,IAAA,MAAM,OAAO,GAAG,MAAM,CAA4C,IAAI,CAAC,CAAC;IACxE,mBAAmB,CACjB,GAAG,EACH,OAAO,OAAO,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,EAC7C,CAAC,OAAO,CAAC,CACV,CAAC;IACF,SAAS,CAAC,MAAK;AACb,QAAA,IAAI,OAAO,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE;YACtD,OAAO,CAAC,OAAO,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC;AAC/C,SAAA;KACF,EAAE,CAAC,KAAK,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC;IAChC,SAAS,CAAC,MAAK;QACb,IAAI,OAAO,CAAC,OAAO,IAAI,OAAO,KAAK,CAAC,QAAQ,IAAI,UAAU,EAAE;YAC1D,OA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AgB,MAAA,UAAA,QAAwB,UAAU,CAAC,GAAA,CAC1D,OAKA,EAAA;WACE,MAAA;AACE,uBAAiB,iBAAA,EAAA;CACrB,GAAA,CACE,QAAG;WAEH,MAAA;AACE,MAAA,QAAY,QAChB,SAAe,QAAA,QAAA,MAAA;KAGb,MAAA,KACD,EAAA;AACD,WAAU,MAAG;AACX,aAAU,MAAO,uBAAmB,cAAY,QAAY,WAAA,QAAA,QAC1D,SAAQ,QAAO,UAAE,sBAA8B,MAAO;CAEzD,GAAE,CACH,MAAU;WAEN,MAAA;AACF,MAAA,MAAA,YAAA,QAAA,MAAA,YAAA,UACE,SAAM,SAAa,aAAA,WAAA,MAAA,QAAA;WAGnB;AAEJ,WAAU,MAAA;AACV,MAAA,MAAa,gBAAE,QAAA,MAAA,gBAAA,UACT,SAAM,SAAO,aAAA,eAAA,MAAA,YAAA;WAEV;WAEP,MAAA;AACE,MAAA,MAAM,sBAAO,QAAA,MAAA,sBAAA,UACjB,SAAU,SAAc,aAAA,sBAAA,MAAA,kBAAA;CAMxB,GAAA,CAgBM,MAAC;;;;;;;;;;;;;;;;;;;MC3FG,yBAAuB,MAAA,WAAmB,CAAqC,OAAM,QAAO;CAgBxG,MAAO,UAAM,OAAW,KAAM;CAC5B,MAAM,EAAA,OAAO,UAAwC,UAAK,GAAA,MAAA,GAAA;AAC1D,qBAAa,KAAS,MAAA,UAAc,QAAK,UAAQ,WAAA,CACjD,OAMA,EAAA;WACM,MAAA;MACF,QAAQ,WAAQ,UAAa,UAC/B,SAAA,QAAA,QAAA;CAGF,GAAA,CAKA,OAOM"}
|
package/react/dist/index.umd.js
CHANGED
|
@@ -1,125 +1,2 @@
|
|
|
1
|
-
(function (
|
|
2
|
-
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'react', 'jb-select'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.index = {}, global.React));
|
|
5
|
-
})(this, (function (exports, React) { 'use strict';
|
|
6
|
-
|
|
7
|
-
/* eslint-disable react/display-name */
|
|
8
|
-
const JBOptionList = React.forwardRef((props, ref) => {
|
|
9
|
-
const element = React.useRef(null);
|
|
10
|
-
React.useImperativeHandle(ref, () => (element ? element.current : undefined), [element]);
|
|
11
|
-
React.useEffect(() => {
|
|
12
|
-
if (element.current && Array.isArray(props.optionList)) {
|
|
13
|
-
element.current.optionList = props.optionList;
|
|
14
|
-
}
|
|
15
|
-
}, [props.optionList, element]);
|
|
16
|
-
React.useEffect(() => {
|
|
17
|
-
if (element.current && typeof props.getTitle == "function") {
|
|
18
|
-
element.current.setCallback("getTitle", props.getTitle);
|
|
19
|
-
}
|
|
20
|
-
}, [props.getTitle, element]);
|
|
21
|
-
React.useEffect(() => {
|
|
22
|
-
if (element.current && typeof props.getValue == "function") {
|
|
23
|
-
element.current.setCallback("getValue", props.getValue);
|
|
24
|
-
}
|
|
25
|
-
}, [props.getValue, element]);
|
|
26
|
-
React.useEffect(() => {
|
|
27
|
-
if (element.current && typeof props.getContentDOM == "function") {
|
|
28
|
-
element.current.setCallback("getContentDOM", props.getContentDOM);
|
|
29
|
-
}
|
|
30
|
-
}, [props.getContentDOM, element]);
|
|
31
|
-
return (React.createElement("jb-option-list", { ref: element }));
|
|
32
|
-
});
|
|
33
|
-
JBOptionList.displayName = 'JBOptionList';
|
|
34
|
-
|
|
35
|
-
function useBindEvent(ref, event, handler, passive = false) {
|
|
36
|
-
React.useEffect(() => {
|
|
37
|
-
const dom = ref.current;
|
|
38
|
-
if (dom) {
|
|
39
|
-
// initiate the event handler
|
|
40
|
-
dom.addEventListener(event, handler, passive);
|
|
41
|
-
}
|
|
42
|
-
// this will clean up the event every time the component is re-rendered
|
|
43
|
-
return function cleanup() {
|
|
44
|
-
if (dom) {
|
|
45
|
-
dom.removeEventListener(event, handler, passive);
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
}, [ref, event, handler, passive]);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/* eslint-disable react/display-name */
|
|
52
|
-
const JBSelect = React.forwardRef((props, ref) => {
|
|
53
|
-
const element = React.useRef(null);
|
|
54
|
-
const [refChangeCount, refChangeCountSetter] = React.useState(0);
|
|
55
|
-
React.useImperativeHandle(ref, () => (element ? element.current : {}), [element]);
|
|
56
|
-
React.useEffect(() => {
|
|
57
|
-
refChangeCountSetter(refChangeCount + 1);
|
|
58
|
-
}, [element.current]);
|
|
59
|
-
React.useEffect(() => {
|
|
60
|
-
if (element.current) {
|
|
61
|
-
element.current.value = props.value;
|
|
62
|
-
}
|
|
63
|
-
}, [props.value]);
|
|
64
|
-
React.useEffect(() => {
|
|
65
|
-
if (typeof props.getSelectedValueDOM == "function" && element.current && element.current) {
|
|
66
|
-
element.current.callbacks.getSelectedValueDOM = props.getSelectedValueDOM;
|
|
67
|
-
}
|
|
68
|
-
}, [props.getSelectedValueDOM]);
|
|
69
|
-
React.useEffect(() => {
|
|
70
|
-
if (props.message !== null && props.message !== undefined) {
|
|
71
|
-
element.current?.setAttribute("message", props.message);
|
|
72
|
-
}
|
|
73
|
-
}, [props.message]);
|
|
74
|
-
React.useEffect(() => {
|
|
75
|
-
if (props.placeholder !== null && props.placeholder !== undefined) {
|
|
76
|
-
element.current?.setAttribute("placeholder", props.placeholder);
|
|
77
|
-
}
|
|
78
|
-
}, [props.placeholder]);
|
|
79
|
-
React.useEffect(() => {
|
|
80
|
-
if (props.searchPlaceholder !== null && props.searchPlaceholder !== undefined) {
|
|
81
|
-
element.current?.setAttribute("search-placeholder", props.searchPlaceholder);
|
|
82
|
-
}
|
|
83
|
-
}, [props.searchPlaceholder]);
|
|
84
|
-
function onKeyup(e) {
|
|
85
|
-
if (typeof props.onKeyup == "function") {
|
|
86
|
-
props.onKeyup(e);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
function onChange(e) {
|
|
90
|
-
if (typeof props.onChange == "function") {
|
|
91
|
-
props.onChange(e);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
function onInput(e) {
|
|
95
|
-
if (typeof props.onInput == "function") {
|
|
96
|
-
props.onInput(e);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
useBindEvent(element, 'keyup', onKeyup);
|
|
100
|
-
useBindEvent(element, 'change', onChange);
|
|
101
|
-
useBindEvent(element, 'input', onInput);
|
|
102
|
-
return (React.createElement("jb-select", { style: props.style ? props.style : undefined, class: props.className ? props.className : "", label: props.label, ref: element, required: props.required || 'false', name: props.name ?? undefined }, props.children));
|
|
103
|
-
});
|
|
104
|
-
JBSelect.displayName = 'JBSelect';
|
|
105
|
-
|
|
106
|
-
/* eslint-disable react/display-name */
|
|
107
|
-
const JBOption = React.forwardRef((props, ref) => {
|
|
108
|
-
const element = React.useRef(null);
|
|
109
|
-
const { value, children, className, ...rest } = props;
|
|
110
|
-
React.useImperativeHandle(ref, () => (element ? element.current : undefined), [element]);
|
|
111
|
-
React.useEffect(() => {
|
|
112
|
-
if (element.current && value !== undefined) {
|
|
113
|
-
element.current.value = value;
|
|
114
|
-
}
|
|
115
|
-
}, [value, element]);
|
|
116
|
-
return (React.createElement("jb-option", { class: className, ref: element, ...rest }, children));
|
|
117
|
-
});
|
|
118
|
-
JBOption.displayName = 'JBOption';
|
|
119
|
-
|
|
120
|
-
exports.JBOption = JBOption;
|
|
121
|
-
exports.JBOptionList = JBOptionList;
|
|
122
|
-
exports.JBSelect = JBSelect;
|
|
123
|
-
|
|
124
|
-
}));
|
|
125
|
-
//# sourceMappingURL=index.umd.js.map
|
|
1
|
+
var e,t;e=this,t=function(e,t,r,l){"use strict";var n=Object.create,u=Object.defineProperty,a=Object.getOwnPropertyDescriptor,c=Object.getOwnPropertyNames,o=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,f=(e,t,r,l)=>{if(t&&"object"==typeof t||"function"==typeof t)for(var n,o=c(t),f=0,i=o.length;f<i;f++)n=o[f],s.call(e,n)||n===r||u(e,n,{get:(e=>t[e]).bind(null,n),enumerable:!(l=a(t,n))||l.enumerable});return e},i=(e,t,r)=>(r=null!=e?n(o(e)):{},f(!t&&e&&e.__esModule?r:u(r,"default",{value:e,enumerable:!0}),e));t=i(t),l=i(l);let d=t.default.forwardRef((e,r)=>{let l=(0,t.useRef)(null);return(0,t.useImperativeHandle)(r,()=>l?l.current:void 0,[l]),(0,t.useEffect)(()=>{l.current&&Array.isArray(e.optionList)&&(l.current.optionList=e.optionList)},[e.optionList,l]),(0,t.useEffect)(()=>{l.current&&"function"==typeof e.getTitle&&l.current.setCallback("getTitle",e.getTitle)},[e.getTitle,l]),(0,t.useEffect)(()=>{l.current&&"function"==typeof e.getValue&&l.current.setCallback("getValue",e.getValue)},[e.getValue,l]),(0,t.useEffect)(()=>{l.current&&"function"==typeof e.getContentDOM&&l.current.setCallback("getContentDOM",e.getContentDOM)},[e.getContentDOM,l]),t.default.createElement("jb-option-list",{ref:l})});d.displayName="JBOptionList";let p=t.default.forwardRef((e,r)=>{let n=(0,t.useRef)(null),[u,a]=(0,t.useState)(0);return(0,t.useImperativeHandle)(r,()=>n?n.current:{},[n]),(0,t.useEffect)(()=>{a(u+1)},[n.current]),(0,t.useEffect)(()=>{n.current&&(n.current.value=e.value)},[e.value]),(0,t.useEffect)(()=>{"function"==typeof e.getSelectedValueDOM&&n.current&&n.current&&(n.current.callbacks.getSelectedValueDOM=e.getSelectedValueDOM)},[e.getSelectedValueDOM]),(0,t.useEffect)(()=>{null!==e.message&&void 0!==e.message&&n.current?.setAttribute("message",e.message)},[e.message]),(0,t.useEffect)(()=>{null!==e.placeholder&&void 0!==e.placeholder&&n.current?.setAttribute("placeholder",e.placeholder)},[e.placeholder]),(0,t.useEffect)(()=>{null!==e.searchPlaceholder&&void 0!==e.searchPlaceholder&&n.current?.setAttribute("search-placeholder",e.searchPlaceholder)},[e.searchPlaceholder]),(0,t.useEffect)(()=>{e.error?n?.current?.setAttribute("error",e.error):n?.current?.removeAttribute("error")},[e.error]),(0,l.useEvent)(n,"load",e.onLoad,!0),(0,l.useEvent)(n,"init",e.onInit,!0),(0,l.useEvent)(n,"keyup",e.onKeyUp),(0,l.useEvent)(n,"change",e.onChange),(0,l.useEvent)(n,"input",e.onInput),t.default.createElement("jb-select",{style:e.style?e.style:void 0,class:e.className?e.className:"",label:e.label,ref:n,required:e.required||"false",name:e.name??void 0},e.children)});p.displayName="JBSelect";let b=t.default.forwardRef((e,r)=>{let l=(0,t.useRef)(null),{value:n,children:u,className:a,...c}=e;return(0,t.useImperativeHandle)(r,()=>l?l.current:void 0,[l]),(0,t.useEffect)(()=>{l.current&&void 0!==n&&(l.current.value=n)},[n,l]),t.default.createElement("jb-option",{class:a,ref:l,...c},u)});b.displayName="JBOption",e.JBOption=b,e.JBOptionList=d,e.JBSelect=p},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("jb-select"),require("jb-core/react")):"function"==typeof define&&define.amd?define(["exports","react","jb-select","jb-core/react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).JBSelectReact={},e.React,e.JBSelect,e.JBCoreReact);
|
|
2
|
+
//# sourceMappingURL=index.umd.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../lib/JBOptionList.tsx","../../../../common/hooks/use-event.ts","../lib/JBSelect.tsx","../lib/JBOption.tsx"],"sourcesContent":["/* eslint-disable react/display-name */\r\nimport React, { useEffect, useRef, useImperativeHandle } from 'react';\r\n// eslint-disable-next-line no-duplicate-imports\r\nimport { JBOptionListWebComponent } from 'jb-select';\r\ntype TOption = any;\r\ntype TValue = any;\r\n\r\ndeclare global {\r\n // eslint-disable-next-line @typescript-eslint/no-namespace\r\n namespace JSX {\r\n interface IntrinsicElements {\r\n 'jb-option-list': JBOptionListType;\r\n }\r\n interface JBOptionListType extends React.DetailedHTMLProps<React.HTMLAttributes<JBOptionListWebComponent<TOption, TValue>>, JBOptionListWebComponent<TOption, TValue>> {\r\n class?: string,\r\n // ref:React.RefObject<JBDateInputWebComponent>,\r\n }\r\n }\r\n}\r\nexport const JBOptionList = React.forwardRef((props: JBOptionListProps<TOption,TValue>, ref) => {\r\n const element = useRef<JBOptionListWebComponent<TOption, TValue>>(null);\r\n useImperativeHandle(\r\n ref,\r\n () => (element ? element.current : undefined),\r\n [element],\r\n );\r\n useEffect(() => {\r\n if (element.current && Array.isArray(props.optionList)) {\r\n element.current.optionList = props.optionList;\r\n }\r\n }, [props.optionList, element]);\r\n useEffect(() => {\r\n if (element.current && typeof props.getTitle == \"function\") {\r\n element.current.setCallback(\"getTitle\",props.getTitle);\r\n }\r\n }, [props.getTitle, element]);\r\n useEffect(() => {\r\n if (element.current && typeof props.getValue == \"function\") {\r\n element.current.setCallback(\"getValue\",props.getValue);\r\n }\r\n }, [props.getValue, element]);\r\n useEffect(() => {\r\n if (element.current && typeof props.getContentDOM == \"function\") {\r\n element.current.setCallback(\"getContentDOM\",props.getContentDOM);\r\n }\r\n }, [props.getContentDOM, element]);\r\n return (\r\n <jb-option-list ref={element}>\r\n </jb-option-list>\r\n );\r\n});\r\n\r\nexport type JBOptionListProps<TOption,TValue> = {\r\n optionList: TOption[],\r\n getTitle?: (option: TOption) => string,\r\n getValue?: (option: TOption) => TValue,\r\n getContentDOM?: (option: TOption) => HTMLElement,\r\n}\r\nJBOptionList.displayName = 'JBOptionList';","import { useEffect } from \"react\";\r\n\r\nexport function useEvent(dom:HTMLElement, event:any, handler:any, passive = false) {\r\n useEffect(() => {\r\n if (dom) {\r\n // initiate the event handler\r\n dom.addEventListener(event, handler, passive); \r\n }\r\n // this will clean up the event every time the component is re-rendered\r\n return function cleanup() {\r\n if(dom){\r\n dom.removeEventListener(event, handler, passive);\r\n }\r\n };\r\n });\r\n}\r\nexport function useBindEvent<TRef extends React.MutableRefObject<any|null>,TEvent>(ref:TRef, event:string, handler:(e:TEvent)=>void, passive = false) {\r\n useEffect(() => {\r\n const dom = ref.current;\r\n if (dom) {\r\n // initiate the event handler\r\n dom.addEventListener(event, handler, passive); \r\n }\r\n // this will clean up the event every time the component is re-rendered\r\n return function cleanup() {\r\n if(dom){\r\n dom.removeEventListener(event, handler, passive);\r\n }\r\n };\r\n },[ref,event,handler,passive]);\r\n}","/* eslint-disable react/display-name */\r\nimport React, { useEffect, useRef, useState, useImperativeHandle,CSSProperties } from 'react';\r\nimport 'jb-select';\r\nimport { useBindEvent } from '../../../../common/hooks/use-event.js';\r\n// eslint-disable-next-line no-duplicate-imports\r\nimport { JBSelectWebComponent } from 'jb-select';\r\nexport type JBSelectEventType<T> = T & {\r\n target: JBSelectWebComponent\r\n}\r\ndeclare global {\r\n // eslint-disable-next-line @typescript-eslint/no-namespace\r\n namespace JSX {\r\n interface IntrinsicElements {\r\n 'jb-select': JBSelectType;\r\n }\r\n interface JBSelectType extends React.DetailedHTMLProps<React.HTMLAttributes<JBSelectWebComponent>, JBSelectWebComponent> {\r\n class?:string,\r\n label?: string,\r\n name?:string,\r\n required?:string | boolean,\r\n message?:string,\r\n tabindex?:string,\r\n // ref:React.RefObject<JBDateInputWebComponent>,\r\n }\r\n }\r\n}\r\n\r\nexport const JBSelect = React.forwardRef((props:JBSelectProps, ref) => {\r\n const element = useRef<JBSelectWebComponent>(null);\r\n const [refChangeCount, refChangeCountSetter] = useState(0);\r\n useImperativeHandle(\r\n ref,\r\n () => (element ? element.current : {}),\r\n [element],\r\n );\r\n useEffect(() => {\r\n refChangeCountSetter(refChangeCount + 1);\r\n }, [element.current]);\r\n useEffect(() => {\r\n if(element.current){\r\n element.current.value = props.value;\r\n }\r\n }, [props.value]);\r\n useEffect(() => {\r\n if (typeof props.getSelectedValueDOM == \"function\" && element.current && element.current) {\r\n element.current.callbacks.getSelectedValueDOM = props.getSelectedValueDOM;\r\n }\r\n }, [props.getSelectedValueDOM]);\r\n useEffect(() => {\r\n if (props.message !== null && props.message !== undefined ) {\r\n element.current?.setAttribute(\"message\", props.message);\r\n }\r\n }, [props.message]);\r\n useEffect(() => {\r\n if (props.placeholder !== null && props.placeholder !== undefined) {\r\n element.current?.setAttribute(\"placeholder\", props.placeholder);\r\n }\r\n }, [props.placeholder]);\r\n useEffect(() => {\r\n if (props.searchPlaceholder !== null && props.searchPlaceholder !== undefined) {\r\n element.current?.setAttribute(\"search-placeholder\", props.searchPlaceholder);\r\n }\r\n }, [props.searchPlaceholder]);\r\n function onKeyup(e:JBSelectEventType<KeyboardEvent>) {\r\n if ( typeof props.onKeyup == \"function\") {\r\n props.onKeyup(e);\r\n }\r\n }\r\n function onChange(e:JBSelectEventType<Event>) {\r\n if (typeof props.onChange ==\"function\") {\r\n props.onChange(e);\r\n }\r\n }\r\n function onInput(e:JBSelectEventType<InputEvent>) {\r\n if (typeof props.onInput == \"function\") {\r\n props.onInput(e);\r\n }\r\n }\r\n useBindEvent(element, 'keyup', onKeyup);\r\n useBindEvent(element, 'change', onChange);\r\n useBindEvent(element, 'input', onInput);\r\n return (\r\n <jb-select style={props.style?props.style:undefined} class={props.className?props.className:\"\"} label={props.label} ref={element} required={props.required || 'false'} name={props.name??undefined}>\r\n {props.children}\r\n </jb-select>\r\n );\r\n});\r\n\r\nexport type JBSelectProps = {\r\n style?:CSSProperties,\r\n label?: string,\r\n getSelectedValueDOM?: (option:any)=>HTMLElement,\r\n value?: any,\r\n onChange?: (e:JBSelectEventType<Event>)=>void,\r\n onKeyup?: (e:JBSelectEventType<KeyboardEvent>)=>void,\r\n onInput?: (e:JBSelectEventType<InputEvent>)=>void,\r\n required?: boolean,\r\n message?: string,\r\n placeholder?: string,\r\n searchPlaceholder?: string,\r\n className?: string,\r\n children?:React.ReactNode,\r\n name?:string\r\n}\r\nJBSelect.displayName = 'JBSelect';","/* eslint-disable react/display-name */\r\nimport React, { useEffect, useRef, useImperativeHandle, PropsWithChildren, ComponentProps } from 'react';\r\nimport { JBOptionWebComponent } from 'jb-select';\r\n//TODO: make it generic when remove forward ref\r\ntype TValue = any;\r\n\r\ndeclare global {\r\n // eslint-disable-next-line @typescript-eslint/no-namespace\r\n namespace JSX {\r\n interface IntrinsicElements {\r\n 'jb-option': JBOptionType;\r\n }\r\n interface JBOptionType extends React.DetailedHTMLProps<React.HTMLAttributes<JBOptionWebComponent<TValue>>, JBOptionWebComponent<TValue>> {\r\n class?: string,\r\n }\r\n }\r\n}\r\nexport const JBOption = React.forwardRef((props: JBOptionProps<TValue>, ref) => {\r\n const element = useRef<JBOptionWebComponent<TValue>>(null);\r\n const {value,children,className, ...rest} = props;\r\n useImperativeHandle(\r\n ref,\r\n () => (element ? element.current : undefined),\r\n [element],\r\n );\r\n \r\n useEffect(() => {\r\n if (element.current && value !== undefined) {\r\n element.current.value = value;\r\n }\r\n }, [value, element]);\r\n\r\n return (\r\n <jb-option class={className} ref={element} {...rest}>\r\n {children}\r\n </jb-option>\r\n );\r\n});\r\n\r\ntype Props<TValue> = {\r\n value:TValue\r\n}\r\n\r\nexport type JBOptionProps<TValue> = PropsWithChildren<JSX.JBOptionType & Props<TValue>>\r\nJBOption.displayName = 'JBOption';"],"names":["useRef","useImperativeHandle","useEffect","useState"],"mappings":";;;;;;EAAA;AAmBO,QAAM,YAAY,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,KAAwC,EAAE,GAAG,KAAI;EAC7F,IAAA,MAAM,OAAO,GAAGA,YAAM,CAA4C,IAAI,CAAC,CAAC;MACxEC,yBAAmB,CACjB,GAAG,EACH,OAAO,OAAO,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,EAC7C,CAAC,OAAO,CAAC,CACV,CAAC;MACFC,eAAS,CAAC,MAAK;EACb,QAAA,IAAI,OAAO,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE;cACtD,OAAO,CAAC,OAAO,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC;EAC/C,SAAA;OACF,EAAE,CAAC,KAAK,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC;MAChCA,eAAS,CAAC,MAAK;UACb,IAAI,OAAO,CAAC,OAAO,IAAI,OAAO,KAAK,CAAC,QA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
|
+
declare global {
|
|
5
|
+
namespace JSX {
|
|
6
|
+
interface IntrinsicElements {
|
|
7
|
+
'jb-option': JBOptionType;
|
|
8
|
+
}
|
|
9
|
+
interface JBOptionType extends React.DetailedHTMLProps<React.HTMLAttributes<JBOptionWebComponent<TValue>>, JBOptionWebComponent<TValue>> {
|
|
10
|
+
class?: string;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export declare const JBOption: React.ForwardRefExoticComponent<Omit<JBOptionProps<any>, "ref"> & React.RefAttributes<unknown>>;
|
|
15
|
+
type Props<TValue> = {
|
|
16
|
+
value: TValue;
|
|
17
|
+
};
|
|
18
|
+
export type JBOptionProps<TValue> = PropsWithChildren<JSX.JBOptionType & Props<TValue>>;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { JBOptionListWebComponent } from 'jb-select';
|
|
3
|
+
type TOption = any;
|
|
4
|
+
type TValue = any;
|
|
5
|
+
declare global {
|
|
6
|
+
namespace JSX {
|
|
7
|
+
interface IntrinsicElements {
|
|
8
|
+
'jb-option-list': JBOptionListType;
|
|
9
|
+
}
|
|
10
|
+
interface JBOptionListType extends React.DetailedHTMLProps<React.HTMLAttributes<JBOptionListWebComponent<TOption, TValue>>, JBOptionListWebComponent<TOption, TValue>> {
|
|
11
|
+
class?: string;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export declare const JBOptionList: React.ForwardRefExoticComponent<JBOptionListProps<any, any> & React.RefAttributes<unknown>>;
|
|
16
|
+
export type JBOptionListProps<TOption, TValue> = {
|
|
17
|
+
optionList: TOption[];
|
|
18
|
+
getTitle?: (option: TOption) => string;
|
|
19
|
+
getValue?: (option: TOption) => TValue;
|
|
20
|
+
getContentDOM?: (option: TOption) => HTMLElement;
|
|
21
|
+
};
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React, { CSSProperties } from 'react';
|
|
2
|
+
import 'jb-select';
|
|
3
|
+
import { JBSelectWebComponent } from 'jb-select';
|
|
4
|
+
import { EventProps } from './events-hook.js';
|
|
5
|
+
export type JBSelectEventType<T> = T & {
|
|
6
|
+
target: JBSelectWebComponent;
|
|
7
|
+
};
|
|
8
|
+
declare global {
|
|
9
|
+
namespace JSX {
|
|
10
|
+
interface IntrinsicElements {
|
|
11
|
+
'jb-select': JBSelectType;
|
|
12
|
+
}
|
|
13
|
+
interface JBSelectType extends React.DetailedHTMLProps<React.HTMLAttributes<JBSelectWebComponent>, JBSelectWebComponent> {
|
|
14
|
+
class?: string;
|
|
15
|
+
label?: string;
|
|
16
|
+
name?: string;
|
|
17
|
+
required?: string | boolean;
|
|
18
|
+
message?: string;
|
|
19
|
+
tabindex?: string;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export declare const JBSelect: React.ForwardRefExoticComponent<EventProps & {
|
|
24
|
+
style?: CSSProperties;
|
|
25
|
+
label?: string;
|
|
26
|
+
getSelectedValueDOM?: (option: any) => HTMLElement;
|
|
27
|
+
value?: any;
|
|
28
|
+
required?: boolean;
|
|
29
|
+
message?: string;
|
|
30
|
+
placeholder?: string;
|
|
31
|
+
searchPlaceholder?: string;
|
|
32
|
+
className?: string;
|
|
33
|
+
children?: React.ReactNode;
|
|
34
|
+
name?: string;
|
|
35
|
+
} & React.RefAttributes<unknown>>;
|
|
36
|
+
export type Props = EventProps & {
|
|
37
|
+
style?: CSSProperties;
|
|
38
|
+
label?: string;
|
|
39
|
+
getSelectedValueDOM?: (option: any) => HTMLElement;
|
|
40
|
+
value?: any;
|
|
41
|
+
required?: boolean;
|
|
42
|
+
message?: string;
|
|
43
|
+
placeholder?: string;
|
|
44
|
+
searchPlaceholder?: string;
|
|
45
|
+
className?: string;
|
|
46
|
+
children?: React.ReactNode;
|
|
47
|
+
name?: string;
|
|
48
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RefObject } from "react";
|
|
2
|
+
import type { JBSelectWebComponent, JBSelectEventType } from 'jb-select';
|
|
3
|
+
export type EventProps = {
|
|
4
|
+
/**
|
|
5
|
+
* when component loaded, in most cases component is already loaded before react mount so you dont need this but if you load web-component dynamically with lazy load it will be called after react mount
|
|
6
|
+
*/
|
|
7
|
+
onLoad?: (e: JBSelectEventType<CustomEvent>) => void;
|
|
8
|
+
/**
|
|
9
|
+
* when all property set and ready to use, in most cases component is already loaded before react mount so you dont need this but if you load web-component dynamically with lazy load it will be called after react mount
|
|
10
|
+
*/
|
|
11
|
+
onInit?: (e: JBSelectEventType<CustomEvent>) => void;
|
|
12
|
+
onChange?: (e: JBSelectEventType<Event>) => void;
|
|
13
|
+
onKeyUp?: (e: JBSelectEventType<KeyboardEvent>) => void;
|
|
14
|
+
onInput?: (e: JBSelectEventType<InputEvent>) => void;
|
|
15
|
+
};
|
|
16
|
+
export declare function useEvents(element: RefObject<JBSelectWebComponent>, props: EventProps): void;
|