diff --git a/Makefile b/Makefile index a47a0ea..ec4e03f 100644 --- a/Makefile +++ b/Makefile @@ -1,25 +1,25 @@ -SHELL := /bin/bash +NPM_BIN = ./node_modules/.bin +export PATH := $(NPM_BIN):$(PATH) + .PHONY: install test build publish install: yarn +clean: + ./node_modules/.bin/rimraf dist es lib types + test: - yarn run test + ./node_modules/.bin/jest --coverage -build: test +build: clean test ./node_modules/.bin/rollup -c publish: build npx standard-version npm publish -docz-dev: - yarn run docz:dev - -docz-build: +deploy_docs: yarn run docz:build - -docz-deploy: docz-build firebase deploy diff --git a/docs/examples.mdx b/docs/examples.mdx index 2f3e0bd..1de02f6 100644 --- a/docs/examples.mdx +++ b/docs/examples.mdx @@ -3,7 +3,7 @@ name: Examples --- import { Playground } from "docz" import "./examples.css" -import CTE from "../dist/index.cjs.js" +import CTE from "../lib/index.js" ## Article diff --git a/package.json b/package.json index 0945600..e848102 100644 --- a/package.json +++ b/package.json @@ -9,9 +9,7 @@ "scripts": { "docz:dev": "docz dev", "docz:build": "docz build", - "docz:serve": "docz serve", - "build": "rollup -c", - "test": "jest --coverage" + "docz:serve": "docz serve" }, "husky": { "hooks": { diff --git a/src/__tests__/index.tsx b/src/__tests__/index.tsx index c7b54aa..d23cf2f 100644 --- a/src/__tests__/index.tsx +++ b/src/__tests__/index.tsx @@ -50,7 +50,7 @@ test("leave editing mode when pressing the enter key", () => { wrapper.find("span").simulate("click"); const inputWrapper = wrapper.find("input").at(0); inputWrapper.simulate("keypress", { - keyCode: 13 + code: "Enter" }); expect(mock).toHaveBeenCalledTimes(1); expect(mock).toHaveBeenCalledWith("HELLO"); diff --git a/src/index.tsx b/src/index.tsx index ac00d5b..f6f702a 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -35,10 +35,7 @@ const ClickToEdit: React.FC = (props) => { const handleKeyPress = (e: KeyboardEvent) => { if ( - e.keyCode === 13 || - e.charCode === 13 || - e.keyCode === 27 || - e.charCode === 27 + e.code === "Escape" || e.code === "Enter" ) { getOffEditMode(); } diff --git a/yarn.lock b/yarn.lock index 98a96f2..df1bd17 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13917,7 +13917,7 @@ rimraf@^2.5.4, rimraf@^2.6.1, rimraf@^2.6.2, rimraf@^2.6.3, rimraf@^2.7.1: dependencies: glob "^7.1.3" -rimraf@^3.0.0: +rimraf@^3.0.0, rimraf@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==