@lovince/ui-react 1.0.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/dist/index.d.ts +19 -0
- package/dist/index.js +50 -0
- package/dist/index.js.map +1 -0
- package/package.json +32 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MyButtonProps, MyInputProps } from '@lovince/ui-shared';
|
|
3
|
+
|
|
4
|
+
interface MyButtonComponentProps extends MyButtonProps {
|
|
5
|
+
onButtonClick?: (detail: {
|
|
6
|
+
variant: string;
|
|
7
|
+
}) => void;
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
declare const MyButton: React.ForwardRefExoticComponent<MyButtonComponentProps & React.RefAttributes<HTMLElement>>;
|
|
11
|
+
|
|
12
|
+
interface MyInputComponentProps extends MyInputProps {
|
|
13
|
+
onInputChange?: (detail: {
|
|
14
|
+
value: string;
|
|
15
|
+
}) => void;
|
|
16
|
+
}
|
|
17
|
+
declare const MyInput: React.ForwardRefExoticComponent<MyInputComponentProps & React.RefAttributes<HTMLElement>>;
|
|
18
|
+
|
|
19
|
+
export { MyButton, type MyButtonComponentProps, MyInput, type MyInputComponentProps };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// src/MyButton.tsx
|
|
2
|
+
import React, { useRef, useEffect, forwardRef } from "react";
|
|
3
|
+
var MyButton = forwardRef(
|
|
4
|
+
({ onButtonClick, children, ...props }, ref) => {
|
|
5
|
+
const internalRef = useRef(null);
|
|
6
|
+
const elementRef = ref || internalRef;
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
const element = elementRef.current;
|
|
9
|
+
if (!element) return;
|
|
10
|
+
Object.assign(element, props);
|
|
11
|
+
const handleButtonClick = (event) => {
|
|
12
|
+
onButtonClick?.(event.detail);
|
|
13
|
+
};
|
|
14
|
+
element.addEventListener("button-click", handleButtonClick);
|
|
15
|
+
return () => {
|
|
16
|
+
element.removeEventListener("button-click", handleButtonClick);
|
|
17
|
+
};
|
|
18
|
+
}, [props, onButtonClick]);
|
|
19
|
+
return React.createElement("my-button", { ref: elementRef }, children);
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
MyButton.displayName = "MyButton";
|
|
23
|
+
|
|
24
|
+
// src/MyInput.tsx
|
|
25
|
+
import React2, { useRef as useRef2, useEffect as useEffect2, forwardRef as forwardRef2 } from "react";
|
|
26
|
+
var MyInput = forwardRef2(
|
|
27
|
+
({ onInputChange, ...props }, ref) => {
|
|
28
|
+
const internalRef = useRef2(null);
|
|
29
|
+
const elementRef = ref || internalRef;
|
|
30
|
+
useEffect2(() => {
|
|
31
|
+
const element = elementRef.current;
|
|
32
|
+
if (!element) return;
|
|
33
|
+
Object.assign(element, props);
|
|
34
|
+
const handleInputChange = (event) => {
|
|
35
|
+
onInputChange?.(event.detail);
|
|
36
|
+
};
|
|
37
|
+
element.addEventListener("input-change", handleInputChange);
|
|
38
|
+
return () => {
|
|
39
|
+
element.removeEventListener("input-change", handleInputChange);
|
|
40
|
+
};
|
|
41
|
+
}, [props, onInputChange]);
|
|
42
|
+
return React2.createElement("my-input", { ref: elementRef });
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
MyInput.displayName = "MyInput";
|
|
46
|
+
export {
|
|
47
|
+
MyButton,
|
|
48
|
+
MyInput
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/MyButton.tsx","../src/MyInput.tsx"],"sourcesContent":["import React, { useRef, useEffect, forwardRef } from 'react';\nimport { MyButtonProps } from '@lovince/ui-shared';\n\nexport interface MyButtonComponentProps extends MyButtonProps {\n onButtonClick?: (detail: { variant: string }) => void;\n children?: React.ReactNode;\n}\n\nexport const MyButton = forwardRef<HTMLElement, MyButtonComponentProps>(\n ({ onButtonClick, children, ...props }, ref) => {\n const internalRef = useRef<HTMLElement>(null);\n const elementRef = (ref as React.RefObject<HTMLElement>) || internalRef;\n\n useEffect(() => {\n const element = elementRef.current;\n if (!element) return;\n\n // Update element properties\n Object.assign(element, props);\n\n // Handle events\n const handleButtonClick = (event: CustomEvent) => {\n onButtonClick?.(event.detail);\n };\n\n element.addEventListener('button-click', handleButtonClick as EventListener);\n\n return () => {\n element.removeEventListener('button-click', handleButtonClick as EventListener);\n };\n }, [props, onButtonClick]);\n\n return React.createElement('my-button', { ref: elementRef }, children);\n }\n);\n\nMyButton.displayName = 'MyButton';\n","import React, { useRef, useEffect, forwardRef } from 'react';\nimport { MyInputProps } from '@lovince/ui-shared';\n\nexport interface MyInputComponentProps extends MyInputProps {\n onInputChange?: (detail: { value: string }) => void;\n}\n\nexport const MyInput = forwardRef<HTMLElement, MyInputComponentProps>(\n ({ onInputChange, ...props }, ref) => {\n const internalRef = useRef<HTMLElement>(null);\n const elementRef = (ref as React.RefObject<HTMLElement>) || internalRef;\n\n useEffect(() => {\n const element = elementRef.current;\n if (!element) return;\n\n // Update element properties\n Object.assign(element, props);\n\n // Handle events\n const handleInputChange = (event: CustomEvent) => {\n onInputChange?.(event.detail);\n };\n\n element.addEventListener('input-change', handleInputChange as EventListener);\n\n return () => {\n element.removeEventListener('input-change', handleInputChange as EventListener);\n };\n }, [props, onInputChange]);\n\n return React.createElement('my-input', { ref: elementRef });\n }\n);\n\nMyInput.displayName = 'MyInput';\n"],"mappings":";AAAA,OAAO,SAAS,QAAQ,WAAW,kBAAkB;AAQ9C,IAAM,WAAW;AAAA,EACtB,CAAC,EAAE,eAAe,UAAU,GAAG,MAAM,GAAG,QAAQ;AAC9C,UAAM,cAAc,OAAoB,IAAI;AAC5C,UAAM,aAAc,OAAwC;AAE5D,cAAU,MAAM;AACd,YAAM,UAAU,WAAW;AAC3B,UAAI,CAAC,QAAS;AAGd,aAAO,OAAO,SAAS,KAAK;AAG5B,YAAM,oBAAoB,CAAC,UAAuB;AAChD,wBAAgB,MAAM,MAAM;AAAA,MAC9B;AAEA,cAAQ,iBAAiB,gBAAgB,iBAAkC;AAE3E,aAAO,MAAM;AACX,gBAAQ,oBAAoB,gBAAgB,iBAAkC;AAAA,MAChF;AAAA,IACF,GAAG,CAAC,OAAO,aAAa,CAAC;AAEzB,WAAO,MAAM,cAAc,aAAa,EAAE,KAAK,WAAW,GAAG,QAAQ;AAAA,EACvE;AACF;AAEA,SAAS,cAAc;;;ACpCvB,OAAOA,UAAS,UAAAC,SAAQ,aAAAC,YAAW,cAAAC,mBAAkB;AAO9C,IAAM,UAAUA;AAAA,EACrB,CAAC,EAAE,eAAe,GAAG,MAAM,GAAG,QAAQ;AACpC,UAAM,cAAcF,QAAoB,IAAI;AAC5C,UAAM,aAAc,OAAwC;AAE5D,IAAAC,WAAU,MAAM;AACd,YAAM,UAAU,WAAW;AAC3B,UAAI,CAAC,QAAS;AAGd,aAAO,OAAO,SAAS,KAAK;AAG5B,YAAM,oBAAoB,CAAC,UAAuB;AAChD,wBAAgB,MAAM,MAAM;AAAA,MAC9B;AAEA,cAAQ,iBAAiB,gBAAgB,iBAAkC;AAE3E,aAAO,MAAM;AACX,gBAAQ,oBAAoB,gBAAgB,iBAAkC;AAAA,MAChF;AAAA,IACF,GAAG,CAAC,OAAO,aAAa,CAAC;AAEzB,WAAOF,OAAM,cAAc,YAAY,EAAE,KAAK,WAAW,CAAC;AAAA,EAC5D;AACF;AAEA,QAAQ,cAAc;","names":["React","useRef","useEffect","forwardRef"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lovince/ui-react",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "React wrappers for UI components",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsup",
|
|
19
|
+
"dev": "tsup --watch"
|
|
20
|
+
},
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"@lovince/ui-core": "^1.0.0",
|
|
23
|
+
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@lovince/ui-shared": "^1.0.0",
|
|
27
|
+
"@types/react": "^18.0.0",
|
|
28
|
+
"react": "^18.0.0",
|
|
29
|
+
"tsup": "^8.5.1",
|
|
30
|
+
"typescript": "^5.9.3"
|
|
31
|
+
}
|
|
32
|
+
}
|