Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added export for react component #59

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions js-timezone-selector-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
"files": [
"dist"
],
"exports": {
".": "./dist/index.es.js",
"./react": "./dist/index.es2.js"
},
"scripts": {
"dev": "vite",
"build": "vite build"
Expand Down
20 changes: 20 additions & 0 deletions js-timezone-selector-plugin/react/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React, { useCallback } from 'react'

import NeetoTimezoneSelect from "../src/main";

const NeetoTimezoneSelector = (options = {}) => {


const ref = useCallback(node => {
if (node !== null) {
new NeetoTimezoneSelector(node, options);
}
}, []);


return (
<div id="element" ref={ref}></div>
)
}

export default NeetoTimezoneSelector
6 changes: 4 additions & 2 deletions js-timezone-selector-plugin/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ import './styles.css';
class Plugin {
element: Element;

constructor(element: Element) {
constructor(element: Element, options: any) {
this.element = element
this.options = options;

this.render()
}

render() {

render(<Selector />, this.element);
render(<Selector {...this.options} />, this.element);
}
}

Expand Down
4 changes: 2 additions & 2 deletions js-timezone-selector-plugin/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export default defineConfig({
emptyOutDir: true,

lib: {
entry: path.resolve(__dirname, "./src/main.tsx"),
formats: ["iife", "es"],
entry: [path.resolve(__dirname, "./src/main.tsx"), path.resolve(__dirname, "./react/index.tsx")],
formats: ["es"],
name: "NeetoTimezoneSelector",
fileName: (format) => `index.${format}.js`,
},
Expand Down