Skip to content

Commit b8daa4f

Browse files
committed
Feat: added type declarations
1 parent c719db3 commit b8daa4f

File tree

29 files changed

+71
-46
lines changed

29 files changed

+71
-46
lines changed

bun.lockb

1.84 KB
Binary file not shown.

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,23 @@
44
"description": "React UI library to design and render seat layouts",
55
"main": "dist/index.js",
66
"module": "dist/index.js",
7+
"types": "dist/index.d.ts",
78
"private": false,
89
"exports": {
910
".": "./dist/index.js",
10-
"./styles": "./dist/index.css"
11+
"./styles": "./dist/index.css",
12+
"./types": "./dist/types/index.d.ts"
1113
},
1214
"scripts": {
13-
"build": "bun run ./esbuild.config.js && bun build:css",
15+
"build": "bun run ./esbuild.config.js",
1416
"build:css": "bunx tailwindcss -i src/styles/index.css -o ./dist/index.css --minify",
17+
"build:types": "bunx tsc --project ./tsconfig.declaration.json && tsc-alias --project ./tsconfig.declaration.json && cd dist && ls -d */ | grep -v 'types' | xargs rm -rf",
1518
"bump-version": "bunx --bun automatic-versioning --disable-auto-sync --recursive $(if [ \"$TAG\" != \"latest\" ]; then echo --prerelease; fi) --prerelease-branch=development --prerelease-tag=$TAG --name=@mezh-hq/react-seat-toolkit --ignore-prefixes=ci",
1619
"format": "bunx prettier --write --cache \"**/*.{js,jsx,ts,tsx,md,css,yml}\"",
1720
"lint": "bun run --bun eslint . --ext js,jsx,ts,tsx,mdx --ignore-path .gitignore --fix --cache --report-unused-disable-directives",
1821
"storybook": "NODE_ENV=storybook storybook dev -p 6006",
1922
"build-storybook": "storybook build",
23+
"postbuild": "bun build:css & bun build:types",
2024
"postinstall": "patch-package",
2125
"prepare": "lefthook install",
2226
"release": "bunx github:akalanka47000/bunpublish --tag=${TAG:=latest} --provenance",
@@ -108,6 +112,7 @@
108112
"storybook-addon-react-router-v6": "1.0.2",
109113
"tailwindcss": "3.4.1",
110114
"tailwindcss-animate": "1.0.6",
115+
"tsc-alias": "1.8.8",
111116
"vite": "4.3.9"
112117
},
113118
"overrides": {

src/components/controls/select/seats/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { useSelector } from "react-redux";
22
import { Label, RadioGroup, RadioGroupItem } from "@/components/core";
3-
import { SeatStatus, dataAttributes, seatStatusColors } from "@/constants";
3+
import { dataAttributes, seatStatusColors } from "@/constants";
44
import { store } from "@/store";
55
import { updateSeat } from "@/store/reducers/editor";
6+
import { SeatStatus } from "@/types/elements";
67
import { d3Extended } from "@/utils";
78
import { default as ControlInput } from "../../control-input";
89
import { default as Categorizer } from "./categorizer";

src/components/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { STKMode } from "@/constants";
21
import { useEvents, useInteractions } from "@/hooks";
3-
import type { ISTKProps } from "@/types";
2+
import { type ISTKProps, STKMode } from "@/types";
43
import { default as Controls } from "./controls";
54
import { default as Footer } from "./footer";
65
import { default as Operations } from "./operations";

src/components/operations/index.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ const Operations = () => {
2828
};
2929

3030
const onExportJson = () => {
31-
console.log(stateToJSON());
31+
const json = stateToJSON();
32+
console.log(json);
33+
navigator.clipboard.writeText(JSON.stringify(json));
3234
};
3335

3436
return (

src/components/workspace/elements/booth.jsx renamed to src/components/workspace/elements/booth.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { forwardRef } from "react";
22

33
export const boothSize = 39;
44

5-
const Booth = forwardRef(({ id, x, y, ...props }, ref) => {
5+
const Booth: React.FC<any> = forwardRef(({ id, x, y, ...props }, ref: any) => {
66
return <rect ref={ref} id={id} x={x} y={y} width={boothSize} height={boothSize} rx={5} ry={5} {...props} />;
77
});
88

src/components/workspace/elements/image.jsx renamed to src/components/workspace/elements/image.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { forwardRef } from "react";
22
import { twMerge } from "tailwind-merge";
33

4-
const Image = forwardRef(({ x, y, id, href, width, height, ...props }, ref) => {
4+
const Image: React.FC<any> = forwardRef(({ x, y, id, href, width, height, ...props }, ref: any) => {
55
return (
66
<image
77
ref={ref}

src/components/workspace/elements/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import { memo, useEffect, useMemo, useRef } from "react";
22
import * as d3 from "d3";
33
import { isEqual } from "lodash";
44
import { twMerge } from "tailwind-merge";
5-
import { STKMode, dataAttributes } from "@/constants";
5+
import { dataAttributes } from "@/constants";
66
import { store } from "@/store";
77
import { clearAndSelectElements, deselectElement, selectElement } from "@/store/reducers/editor";
8+
import { STKMode } from "@/types";
89
import { d3Extended } from "@/utils";
910
import { Tool } from "../../toolbar/data";
1011
import {

src/components/workspace/elements/polyline.jsx renamed to src/components/workspace/elements/polyline.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { forwardRef } from "react";
22
import { twMerge } from "tailwind-merge";
33
import { dataAttributes } from "@/constants";
44

5-
const Polyline = forwardRef(({ id, points, color, stroke, section, ...props }, ref) => {
5+
const Polyline: React.FC<any> = forwardRef(({ id, points, color, stroke, section, ...props }, ref: any) => {
66
return (
77
<polyline
88
ref={ref}

src/components/workspace/elements/seat.jsx renamed to src/components/workspace/elements/seat.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import { forwardRef, useEffect, useMemo } from "react";
22
import { twMerge } from "tailwind-merge";
3-
import { SeatStatus, dataAttributes, seatStatusColors } from "@/constants";
3+
import { dataAttributes, seatStatusColors } from "@/constants";
4+
import { SeatStatus } from "@/types/elements";
45
import { d3Extended } from "@/utils";
56

67
export const seatSize = 28;
78

89
export const seatLabelFontSize = seatSize / 3;
910

10-
const Seat = forwardRef(
11-
({ x, y, id, label, categories, category, status, onClick, options, element, ...props }, ref) => {
11+
const Seat: React.FC<any> = forwardRef(
12+
({ x, y, id, label, categories, category, status, onClick, options, element, ...props }, ref: any) => {
1213
const categoryObject = useMemo(() => categories?.find?.((c) => c.id === category), [categories, category]);
1314

1415
const textX = useMemo(() => {

0 commit comments

Comments
 (0)