jb-textarea 3.3.2 → 3.5.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.
Files changed (50) hide show
  1. package/README.md +12 -3
  2. package/dist/jb-textarea.cjs.js +2 -2
  3. package/dist/jb-textarea.cjs.js.br +0 -0
  4. package/dist/jb-textarea.cjs.js.gz +0 -0
  5. package/dist/jb-textarea.cjs.js.map +1 -1
  6. package/dist/jb-textarea.d.ts +38 -0
  7. package/dist/jb-textarea.d.ts.map +1 -0
  8. package/dist/jb-textarea.js +2 -2
  9. package/dist/jb-textarea.js.br +0 -0
  10. package/dist/jb-textarea.js.gz +0 -0
  11. package/dist/jb-textarea.js.map +1 -1
  12. package/dist/jb-textarea.umd.js +2 -2
  13. package/dist/jb-textarea.umd.js.br +0 -0
  14. package/dist/jb-textarea.umd.js.gz +0 -0
  15. package/dist/jb-textarea.umd.js.map +1 -1
  16. package/dist/lib/jb-textarea.d.ts +37 -0
  17. package/dist/lib/types.d.ts +10 -0
  18. package/dist/types.d.ts +11 -0
  19. package/dist/types.d.ts.map +1 -0
  20. package/dist/web-component/jb-textarea/lib/jb-textarea.d.ts +1 -2
  21. package/dist/web-component/jb-textarea/lib/types.d.ts +3 -0
  22. package/lib/global.d.ts +15 -0
  23. package/lib/jb-textarea.ts +13 -4
  24. package/lib/types.ts +5 -0
  25. package/package.json +8 -5
  26. package/react/README.md +121 -0
  27. package/react/dist/JBTextarea.cjs.js +2 -0
  28. package/react/dist/JBTextarea.cjs.js.map +1 -0
  29. package/react/dist/JBTextarea.d.ts +36 -0
  30. package/react/dist/JBTextarea.js +2 -0
  31. package/react/dist/JBTextarea.js.map +1 -0
  32. package/react/dist/JBTextarea.umd.js +2 -0
  33. package/react/dist/JBTextarea.umd.js.map +1 -0
  34. package/react/dist/attributes-hook.d.ts +11 -0
  35. package/react/dist/common/hooks/use-event.d.ts +3 -0
  36. package/react/dist/common/hooks/useLazyRef.d.ts +4 -0
  37. package/react/dist/common/hooks/useMobx.d.ts +4 -0
  38. package/react/dist/common/scripts/device-detection.d.ts +1 -0
  39. package/react/dist/common/scripts/persian-helper.d.ts +3 -0
  40. package/react/dist/events-hook.d.ts +20 -0
  41. package/react/dist/lib/JBTextarea.d.ts +44 -0
  42. package/react/dist/lib/events-hook.d.ts +20 -0
  43. package/react/dist/web-component/jb-textarea/react/lib/JBTextarea.d.ts +44 -0
  44. package/react/dist/web-component/jb-textarea/react/lib/events-hook.d.ts +20 -0
  45. package/react/index.js +1 -0
  46. package/react/lib/JBTextarea.tsx +50 -0
  47. package/react/lib/attributes-hook.ts +45 -0
  48. package/react/lib/events-hook.ts +32 -0
  49. package/react/package.json +35 -0
  50. package/react/tsconfig.json +17 -0
@@ -0,0 +1,44 @@
1
+ import React, { CSSProperties } from 'react';
2
+ import 'jb-textarea';
3
+ import { JBTextareaWebComponent, type ValidationValue } from 'jb-textarea';
4
+ import { type ValidationItem } from "jb-validation";
5
+ import { EventProps } from './events-hook.js';
6
+ declare global {
7
+ namespace JSX {
8
+ interface IntrinsicElements {
9
+ 'jb-textarea': JBTextareaType;
10
+ }
11
+ interface JBTextareaType extends React.DetailedHTMLProps<React.HTMLAttributes<JBTextareaWebComponent>, JBTextareaWebComponent> {
12
+ class?: string;
13
+ label?: string;
14
+ name?: string;
15
+ message?: string;
16
+ placeholder?: string;
17
+ }
18
+ }
19
+ }
20
+ declare const JBTextarea: React.ForwardRefExoticComponent<EventProps & {
21
+ label?: string;
22
+ value?: string | null | undefined;
23
+ placeholder?: string;
24
+ className?: string;
25
+ style?: CSSProperties;
26
+ validationList?: ValidationItem<ValidationValue>[];
27
+ autoHeight?: boolean;
28
+ message?: string;
29
+ name?: string;
30
+ required?: boolean;
31
+ } & React.RefAttributes<unknown>>;
32
+ export type Props = EventProps & {
33
+ label?: string;
34
+ value?: string | null | undefined;
35
+ placeholder?: string;
36
+ className?: string;
37
+ style?: CSSProperties;
38
+ validationList?: ValidationItem<ValidationValue>[];
39
+ autoHeight?: boolean;
40
+ message?: string;
41
+ name?: string;
42
+ required?: boolean;
43
+ };
44
+ export { JBTextarea };
@@ -0,0 +1,20 @@
1
+ import { RefObject } from "react";
2
+ import type { JBTextareaWebComponent, JBTextareaEventType } from 'jb-textarea';
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: JBTextareaEventType<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: JBTextareaEventType<CustomEvent>) => void;
12
+ onChange?: (e: JBTextareaEventType<Event>) => void;
13
+ onFocus?: (e: JBTextareaEventType<FocusEvent>) => void;
14
+ onBlur?: (e: JBTextareaEventType<FocusEvent>) => void;
15
+ onKeyDown?: (e: JBTextareaEventType<KeyboardEvent>) => void;
16
+ onKeyUp?: (e: JBTextareaEventType<KeyboardEvent>) => void;
17
+ onInput?: (e: JBTextareaEventType<InputEvent>) => void;
18
+ onBeforeinput?: (e: JBTextareaEventType<InputEvent>) => void;
19
+ };
20
+ export declare function useEvents(element: RefObject<JBTextareaWebComponent>, props: EventProps): void;
@@ -0,0 +1,44 @@
1
+ import React, { CSSProperties } from 'react';
2
+ import 'jb-textarea';
3
+ import { JBTextareaWebComponent, type ValidationValue } from 'jb-textarea';
4
+ import { type ValidationItem } from "jb-validation";
5
+ import { EventProps } from './events-hook.js';
6
+ declare global {
7
+ namespace JSX {
8
+ interface IntrinsicElements {
9
+ 'jb-textarea': JBTextareaType;
10
+ }
11
+ interface JBTextareaType extends React.DetailedHTMLProps<React.HTMLAttributes<JBTextareaWebComponent>, JBTextareaWebComponent> {
12
+ class?: string;
13
+ label?: string;
14
+ name?: string;
15
+ message?: string;
16
+ placeholder?: string;
17
+ }
18
+ }
19
+ }
20
+ declare const JBTextarea: React.ForwardRefExoticComponent<EventProps & {
21
+ label?: string;
22
+ value?: string | null | undefined;
23
+ placeholder?: string;
24
+ className?: string;
25
+ style?: CSSProperties;
26
+ validationList?: ValidationItem<ValidationValue>[];
27
+ autoHeight?: boolean;
28
+ message?: string;
29
+ name?: string;
30
+ required?: boolean;
31
+ } & React.RefAttributes<unknown>>;
32
+ export type Props = EventProps & {
33
+ label?: string;
34
+ value?: string | null | undefined;
35
+ placeholder?: string;
36
+ className?: string;
37
+ style?: CSSProperties;
38
+ validationList?: ValidationItem<ValidationValue>[];
39
+ autoHeight?: boolean;
40
+ message?: string;
41
+ name?: string;
42
+ required?: boolean;
43
+ };
44
+ export { JBTextarea };
@@ -0,0 +1,20 @@
1
+ import { RefObject } from "react";
2
+ import type { JBTextareaWebComponent, JBTextareaEventType } from 'jb-textarea';
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: JBTextareaEventType<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: JBTextareaEventType<CustomEvent>) => void;
12
+ onChange?: (e: JBTextareaEventType<Event>) => void;
13
+ onFocus?: (e: JBTextareaEventType<FocusEvent>) => void;
14
+ onBlur?: (e: JBTextareaEventType<FocusEvent>) => void;
15
+ onKeyDown?: (e: JBTextareaEventType<KeyboardEvent>) => void;
16
+ onKeyUp?: (e: JBTextareaEventType<KeyboardEvent>) => void;
17
+ onInput?: (e: JBTextareaEventType<InputEvent>) => void;
18
+ onBeforeinput?: (e: JBTextareaEventType<InputEvent>) => void;
19
+ };
20
+ export declare function useEvents(element: RefObject<JBTextareaWebComponent>, props: EventProps): void;
package/react/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/JBTextarea.js';
@@ -0,0 +1,50 @@
1
+ /* eslint-disable no-inner-declarations */
2
+ import React, { useRef, useImperativeHandle, CSSProperties } from 'react';
3
+ import 'jb-textarea';
4
+ // eslint-disable-next-line no-duplicate-imports
5
+ import {JBTextareaWebComponent} from 'jb-textarea';
6
+ import { EventProps, useEvents } from './events-hook.js';
7
+ import { JBTextareaAttributes, useJBTextareaAttribute } from './attributes-hook.js';
8
+ declare global {
9
+ // eslint-disable-next-line @typescript-eslint/no-namespace
10
+ namespace JSX {
11
+ interface IntrinsicElements {
12
+ 'jb-textarea': JBTextareaType;
13
+ }
14
+ interface JBTextareaType extends React.DetailedHTMLProps<React.HTMLAttributes<JBTextareaWebComponent>, JBTextareaWebComponent> {
15
+ class?:string,
16
+ label?: string,
17
+ name?:string,
18
+ message?:string,
19
+ placeholder?:string,
20
+ // ref:React.RefObject<JBDateInputWebComponent>,
21
+ }
22
+ }
23
+ }
24
+ // eslint-disable-next-line react/display-name
25
+ const JBTextarea = React.forwardRef((props:Props, ref) => {
26
+ {
27
+ //we set this state so when ref change we have a render and our event listener will be updated
28
+ const element = useRef<JBTextareaWebComponent>(null);
29
+ useImperativeHandle(
30
+ ref,
31
+ () => (element ? element.current : undefined),
32
+ [element],
33
+ );
34
+ useJBTextareaAttribute(element, props);
35
+ useEvents(element,props);
36
+ return (
37
+ <jb-textarea placeholder={props.placeholder} class={props.className} style={props.style} ref={element} label={props.label} message={props.message} name={props.name}></jb-textarea>
38
+ );
39
+ }
40
+ });
41
+
42
+ export type Props = EventProps & JBTextareaAttributes & {
43
+ label?: string,
44
+ placeholder?:string,
45
+ className?: string,
46
+ message?:string,
47
+ style?:CSSProperties,
48
+ name?:string,
49
+ }
50
+ export {JBTextarea};
@@ -0,0 +1,45 @@
1
+ import { JBTextareaWebComponent, type ValidationValue } from "jb-textarea";
2
+ import { type ValidationItem } from "jb-validation";
3
+ import { RefObject, useEffect } from "react";
4
+
5
+ export type JBTextareaAttributes = {
6
+ value?: string | null | undefined,
7
+ validationList?:ValidationItem<ValidationValue>[],
8
+ autoHeight?: boolean,
9
+ required?:boolean
10
+ error?: string,
11
+ }
12
+ export function useJBTextareaAttribute(element: RefObject<JBTextareaWebComponent>, props: JBTextareaAttributes) {
13
+
14
+ useEffect(() => {
15
+ const value:string = props.value || '';
16
+ if(element.current){
17
+ element.current.value = value;
18
+ }
19
+ }, [props.value]);
20
+
21
+ useEffect(() => {
22
+ if(element.current){
23
+ element.current.validation.list = props.validationList || [];
24
+ }
25
+ }, [props.validationList]);
26
+ useEffect(() => {
27
+ if(element.current && props.required!== undefined){
28
+ props.required?element.current.setAttribute("required",''):element.current.removeAttribute("required");
29
+ }
30
+ }, [props.required]);
31
+
32
+ useEffect(() => {
33
+ if(element.current){
34
+ element.current.autoHeight = props.autoHeight || false;
35
+ }
36
+ }, [props.autoHeight]);
37
+
38
+ useEffect(() => {
39
+ if (props.error) {
40
+ element?.current?.setAttribute('error', props.error);
41
+ } else {
42
+ element?.current?.removeAttribute('error');
43
+ }
44
+ }, [props.error]);
45
+ }
@@ -0,0 +1,32 @@
1
+ import { useEvent } from "jb-core/react";
2
+ import { RefObject } from "react";
3
+ import type { JBTextareaWebComponent, JBTextareaEventType } from 'jb-textarea';
4
+
5
+ export type EventProps = {
6
+ /**
7
+ * 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
8
+ */
9
+ onLoad?: (e: JBTextareaEventType<CustomEvent>) => void,
10
+ /**
11
+ * 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
12
+ */
13
+ onInit?: (e: JBTextareaEventType<CustomEvent>) => void,
14
+ onChange?: (e: JBTextareaEventType<Event>) => void,
15
+ onFocus?: (e: JBTextareaEventType<FocusEvent>) => void,
16
+ onBlur?: (e: JBTextareaEventType<FocusEvent>) => void,
17
+ onKeyDown?: (e: JBTextareaEventType<KeyboardEvent>) => void,
18
+ onKeyUp?: (e: JBTextareaEventType<KeyboardEvent>) => void,
19
+ onInput?: (e: JBTextareaEventType<InputEvent>) => void,
20
+ onBeforeinput?: (e: JBTextareaEventType<InputEvent>) => void,
21
+
22
+ }
23
+ export function useEvents(element: RefObject<JBTextareaWebComponent>, props: EventProps) {
24
+ useEvent(element, 'load', props.onLoad, true);
25
+ useEvent(element, 'init', props.onInit, true);
26
+ useEvent(element, 'change', props.onChange);
27
+ useEvent(element, 'keydown', props.onKeyDown);
28
+ useEvent(element, 'input', props.onInput);
29
+ useEvent(element, 'keyup', props.onKeyUp);
30
+ useEvent(element, 'focus', props.onFocus);
31
+ useEvent(element, 'blur', props.onBlur);
32
+ }
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "jb-textarea-react",
3
+ "description": "textarea react component",
4
+ "type": "module",
5
+ "author": {
6
+ "name": "mohammad javad bathaei",
7
+ "email": "javadbat@gmail.com"
8
+ },
9
+ "keywords": [
10
+ "jb",
11
+ "jb-textarea",
12
+ "textarea",
13
+ "long input",
14
+ "multiline input",
15
+ "react component"
16
+ ],
17
+ "version": "3.2.0",
18
+ "bugs": "https://github.com/javadbat/jb-textarea/issues",
19
+ "license": "MIT",
20
+ "files": [
21
+ "LICENSE",
22
+ "README.md",
23
+ "lib/",
24
+ "dist/"
25
+ ],
26
+ "main": "index.js",
27
+ "types": "./dist/JBTextarea.d.ts",
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git@github.com:javadbat/jb-textarea.git"
31
+ },
32
+ "dependencies": {
33
+ "jb-textarea": ">=3.2.0"
34
+ }
35
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "baseUrl": ".",
4
+ "rootDir": "./lib",
5
+ "declarationDir": "./dist"
6
+ },
7
+ "include": [
8
+ "lib/**/*.ts",
9
+ "lib/**/*.tsx"
10
+ ],
11
+ "exclude": [
12
+ "node_modules",
13
+ "**/*.spec.ts",
14
+ "dist",
15
+ ],
16
+ "extends":"jb-core/configs/tsconfig-react.json"
17
+ }