diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 389707c..2982891 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -36,9 +36,11 @@ jobs: key: yarn-${{ hashFiles('**/yarn.lock') }} - name: Installs Nix - uses: cachix/install-nix-action@v18 + uses: cachix/install-nix-action@v22 with: + nix_path: nixpkgs=channel:nixos-23.05 extra_nix_config: | + experimental-features = nix-command flakes access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} - name: Imports Nix store cache @@ -61,7 +63,7 @@ jobs: - name: Publishes the lib working-directory: lib - run: nix develop -c yarn publish --access public + run: nix develop -k NODE_AUTH_TOKEN -c yarn publish --access public env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 220664d..93918bf 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -27,8 +27,12 @@ jobs: path: '**/node_modules' key: yarn-${{ hashFiles('**/yarn.lock') }} - - name: Installs Nix - uses: cachix/install-nix-action@v18 + - name: Install Nix + uses: cachix/install-nix-action@v22 + with: + nix_path: nixpkgs=channel:nixos-23.05 + extra_nix_config: | + experimental-features = nix-command flakes - name: Imports Nix store cache if: ${{ steps.nix-cache.outputs.cache-hit == 'true' }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ac1067..b762cd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,164 +8,159 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +## [3.1.4] - 2023-09-09 + +### Fixed + +- Fixed pasting code on Firefox Android [#63]. + ## [3.1.3] - 2023-02-09 ### Changed -* Upgraded all packages and license year. +- Upgraded all packages and license year. ## [3.1.2] - 2022-12-13 ### Fixed -* Fixed CI publish script. +- Fixed CI publish script. ## [3.1.1] - 2022-12-13 ### Fixed -* Fixed local `dir` prop override [#71]. +- Fixed local `dir` prop override [#71]. ## [3.1.0] - 2022-12-13 ### Changed -* Upgraded all packages to the latest versions (react 18.2, node - 18.12, cypress 10.10). +- Upgraded all packages to the latest versions (react 18.2, node 18.12, cypress 10.10). ## [3.0.16] - 2022-07-05 ### Fixed -* Fixed swipe style keyboard entry [#62] -* Fixed pasting code from messages on iOS [#63] +- Fixed swipe style keyboard entry [#62]. +- ~~Fixed pasting code from messages on iOS [#63].~~ ## [3.0.15] - 2022-06-12 ### Changed -* Upgraded `react-use-bireducer` to the latest version. +- Upgraded `react-use-bireducer` to the latest version. ### Fixed -* Fixed README tests section. -* Fixed CHANGELOG links. +- Fixed README tests section. +- Fixed CHANGELOG links. ## [3.0.14] - 2022-05-27 ### Changed -* Model-view-updater (as known as `mvu` in the code) is now handled by - the lib - [react-use-bireducer](https://github.com/soywod/react-use-bireducer). -* Upgraded all packages to the latest version. +- Model-view-updater (as known as `mvu` in the code) is now handled by the lib [react-use-bireducer](https://github.com/soywod/react-use-bireducer). +- Upgraded all packages to the latest version. ## [3.0.13] - 2022-05-24 ### Added -* Added tests in CI. +- Added tests in CI. ### Changed -* Updated readme badges. +- Updated readme badges. ### Fixed -* Fixed broken links in the readme. +- Fixed broken links in the readme. ## [3.0.12] - 2022-05-23 ### Deprecated -* Deprecated the `debug` mode (no longer exists). +- Deprecated the `debug` mode (no longer exists). ## [3.0.11] - 2022-05-22 -Revert the lib state from `v1.0.6`. The native web component used in -the `v2.0.0` was too hard to maintain. It led to many issues. +Revert the lib state from `v1.0.6`. The native web component used in the `v2.0.0` was too hard to maintain. It led to many issues. ## [2.0.0-beta.0] - 2021-04-15 -React PIN Field is now a React wrapper for [PIN -Field](https://github.com/soywod/pin-field), a native web component -for entering PIN codes. +React PIN Field is now a React wrapper for [PIN Field](https://github.com/soywod/pin-field), a native web component for entering PIN codes. ### Changed -* `@soywod/pin-field` needs to be installed, since it became a peer - dependency of React PIN Field. -* The ref contains now an instance of the class - [`PinField`](https://github.com/soywod/pin-field/blob/master/lib/pin-field.ts). - Inputs are accessible via the `inputs` prop. +- `@soywod/pin-field` needs to be installed, since it became a peer dependency of React PIN Field. +- The ref contains now an instance of the class [`PinField`](https://github.com/soywod/pin-field/blob/master/lib/pin-field.ts). Inputs are accessible via the `inputs` prop. ## [1.1.0] - 2021-03-14 ### Fixed -* Added support for all browsers [#19] and mobile [#26]. +- Added support for all browsers [#19] and mobile [#26]. ### Deprecated -* Deprecated classes `-{index}`, `-focus`, `-success` and `-error` - (replaced by standard pseudo-classes `:nth-of-type`, `:focus`, - `:valid` and `:invalid`). +- Deprecated classes `-{index}`, `-focus`, `-success` and `-error` (replaced by standard pseudo-classes `:nth-of-type`, `:focus`, `:valid` and `:invalid`). ## [1.0.6] - 2021-02-10 ### Changed -* Upgraded React version to `^17` [#23]. +- Upgraded React version to `^17` [#23]. ## [1.0.5] - 2020-10-02 ### Removed -* Removed lodash. +- Removed lodash. ## [1.0.4] - 2020-08-20 ### Fixed -* Fixed tsconfig module type [#20]. +- Fixed tsconfig module type [#20]. ## [1.0.3] - 2020-03-28 ### Fixed -* Kept previous val on reject key [#16]. +- Kept previous val on reject key [#16]. ## [1.0.2] - 2020-03-27 ### Fixed -* Fixed missing delete key [#15]. +- Fixed missing delete key [#15]. ## [1.0.1] - 2020-03-19 ### Changed -* Added npm version badge and missing icons in docs. -* Remove test files from npm pack. +- Added npm version badge and missing icons in docs. +- Remove test files from npm pack. ## [1.0.0] - 2020-03-15 ### Added -* Added docs (readme, license, changelog). -* Adedd new event onReceiveKey. -* Added end-to-end tests with Cypress [#3]. -* Added unit tests with Jest + Enzyme [#2]. -* Handled clipboard paste event [#11]. -* Added Right-to-left support [#9]. -* Added ref support [#14]. +- Added docs (readme, license, changelog). +- Adedd new event onReceiveKey. +- Added end-to-end tests with Cypress [#3]. +- Added unit tests with Jest + Enzyme [#2]. +- Handled clipboard paste event [#11]. +- Added Right-to-left support [#9]. +- Added ref support [#14]. ### Fixed -* Fixed base system on evt.key instead of evt.keyCode, to avoid +- Fixed base system on evt.key instead of evt.keyCode, to avoid conflicts (uppercase/lowercase, numeric keypad) [#1]. -* Fixed unnecessary re-renders (useMVU). -* Fixed paste on MacOS [#13]. +- Fixed unnecessary re-renders (useMVU). +- Fixed paste on MacOS [#13]. [unreleased]: https://github.com/soywod/react-pin-field/compare/v3.1.3...HEAD [3.1.3]: https://github.com/soywod/react-pin-field/compare/v3.1.2...v3.1.3 diff --git a/demo/package.json b/demo/package.json index 8db6a7d..38f2667 100644 --- a/demo/package.json +++ b/demo/package.json @@ -3,7 +3,7 @@ "description": "Demo for react-pin-field.", "author": "soywod ", "license": "MIT", - "version": "3.1.3", + "version": "3.1.4", "private": false, "browserslist": { "production": [ @@ -28,7 +28,7 @@ "classnames": "^2.3.2", "react": "^18.2.0", "react-dom": "^18.2.0", - "react-pin-field": "^3.1.2", + "react-pin-field": "^3.1.4", "react-scripts": "^5.0.1", "sass": "^1.58.0", "typescript": "^4.9.5", diff --git a/flake.lock b/flake.lock index 83b9676..b5ae204 100644 --- a/flake.lock +++ b/flake.lock @@ -3,11 +3,11 @@ "flake-compat": { "flake": false, "locked": { - "lastModified": 1668681692, - "narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=", + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", "owner": "edolstra", "repo": "flake-compat", - "rev": "009399224d5e398d03b22badca40a37ac85412a1", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", "type": "github" }, "original": { @@ -18,16 +18,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1670841420, - "narHash": "sha256-mSEia1FzrsHbfqjorMyYiX8NXdDVeR1Pw1k55jMJlJY=", + "lastModified": 1694048570, + "narHash": "sha256-PEQptwFCVaJ+jLFJgrZll2shQ9VI/7xVhrCYkJo8iIw=", "owner": "nixos", "repo": "nixpkgs", - "rev": "33e0d99cbedf2acfd7340d2150837fbb28039a64", + "rev": "4f77ea639305f1de0a14d9d41eef83313360638c", "type": "github" }, "original": { "owner": "nixos", - "ref": "nixos-unstable", + "ref": "nixos-23.05", "repo": "nixpkgs", "type": "github" } @@ -39,13 +39,31 @@ "utils": "utils" } }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "utils": { + "inputs": { + "systems": "systems" + }, "locked": { - "lastModified": 1667395993, - "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "lastModified": 1692799911, + "narHash": "sha256-3eihraek4qL744EvQXsK1Ha6C3CR7nnT8X2qWap4RNk=", "owner": "numtide", "repo": "flake-utils", - "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "rev": "f9e7cf818399d17d347f847525c5a5a8032e4e44", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 69330dc..eb59802 100644 --- a/flake.nix +++ b/flake.nix @@ -2,7 +2,7 @@ description = "React component for entering PIN codes."; inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05"; utils.url = "github:numtide/flake-utils"; flake-compat = { url = "github:edolstra/flake-compat"; diff --git a/lib/package.json b/lib/package.json index e663b6a..d3d6a14 100644 --- a/lib/package.json +++ b/lib/package.json @@ -3,7 +3,7 @@ "description": "React component for entering PIN codes.", "author": "soywod ", "license": "MIT", - "version": "3.1.3", + "version": "3.1.4", "private": false, "keywords": [ "react", @@ -44,7 +44,7 @@ "@types/react": "^18.0.27", "@types/react-dom": "^18.0.10", "classnames": "^2.3.2", - "cypress": "^12.5.1", + "cypress": "=10.10.0", "husky": "^8.0.3", "jest": "^29.4.2", "jest-environment-jsdom": "^29.4.2", diff --git a/lib/src/pin-field/pin-field.test.ts b/lib/src/pin-field/pin-field.test.ts index 07f9f5b..f48140f 100644 --- a/lib/src/pin-field/pin-field.test.ts +++ b/lib/src/pin-field/pin-field.test.ts @@ -323,7 +323,12 @@ describe("state reducer", () => { ); expect(state).toMatchObject({fallback: null}); - expect(eff).toEqual([]); + expect(eff).toEqual([ + {type: "set-input-val", idx: 0, val: "a"}, + {type: "resolve-key", idx: 0, key: "a"}, + {type: "focus-input", idx: 1}, + {type: "handle-code-change"}, + ]); }); }); @@ -568,9 +573,9 @@ describe("effect reducer", () => { current: [inputA.ref, inputB.ref, inputC.ref], }; const propsWithDir = {...propsMock, dir: "ltr"}; - const notify = useEffectReducer({ ...propsWithDir, refs }); + const notify = useEffectReducer({...propsWithDir, refs}); - notify({ type: "handle-code-change" }, noop); + notify({type: "handle-code-change"}, noop); expect(propsMock.onChange).toHaveBeenCalledTimes(1); expect(propsMock.onChange).toHaveBeenCalledWith("abc"); diff --git a/lib/src/pin-field/pin-field.tsx b/lib/src/pin-field/pin-field.tsx index 365536a..6d06103 100644 --- a/lib/src/pin-field/pin-field.tsx +++ b/lib/src/pin-field/pin-field.tsx @@ -105,7 +105,8 @@ export const stateReducer: StateReducer = (state, action) switch (action.type) { case "handle-key-down": { switch (action.key) { - case "Unidentified": { + case "Unidentified": + case "Process": { return [{...state, fallback: {idx: state.focusIdx, val: action.val}}, NO_EFFECTS]; } @@ -166,7 +167,7 @@ export const stateReducer: StateReducer = (state, action) if (prevVal === "" && val === "") { effects.push({type: "handle-delete", idx}, {type: "handle-code-change"}); - } else if (prevVal === "" && val !== "") { + } else if (val !== "") { return pasteReducer(nextState, idx, val); } diff --git a/yarn.lock b/yarn.lock index 8bc3c11..bfb9eb2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4830,10 +4830,10 @@ csstype@^3.0.2: resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.1.1.tgz#841b532c45c758ee546a11d5bd7b7b473c8c30b9" integrity sha512-DJR/VvkAvSZW9bTouZue2sSxDwdTN92uHjqeKVm+0dAqdfNykRzQ95tay8aXMBAAPpUiq4Qcug2L7neoRh2Egw== -cypress@^12.5.1: - version "12.5.1" - resolved "https://registry.yarnpkg.com/cypress/-/cypress-12.5.1.tgz#effdcccdd5a6187d61d497300903d4f3b5b21b6e" - integrity sha512-ZmCmJ3lsyeOpBfh410m5+AO2CO1AxAzFBt7k6/uVbNcrNZje1vdiwYTpj2ksPKg9mjr9lR6V8tmlDNMvr4H/YQ== +cypress@=10.10.0: + version "10.10.0" + resolved "https://registry.yarnpkg.com/cypress/-/cypress-10.10.0.tgz#fd671297b2ca3e64dfffd55fe3857c388cfbb695" + integrity sha512-bU8r44x1NIYAUNNXt3CwJpLOVth7HUv2hUhYCxZmgZ1IugowDvuHNpevnoZRQx1KKOEisLvIJW+Xen5Pjn41pg== dependencies: "@cypress/request" "^2.88.10" "@cypress/xvfb" "^1.2.4" @@ -9094,23 +9094,18 @@ json-stringify-safe@~5.0.1: resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" integrity sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA== -json5@2.x, json5@^2.1.2, json5@^2.2.0, json5@^2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.1.tgz#655d50ed1e6f95ad1a3caababd2b0efda10b395c" - integrity sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA== +json5@2.x, json5@^2.1.2, json5@^2.2.0, json5@^2.2.1, json5@^2.2.3: + version "2.2.3" + resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283" + integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg== json5@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.1.tgz#779fb0018604fa854eacbf6252180d83543e3dbe" - integrity sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow== + version "1.0.2" + resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.2.tgz#63d98d60f21b313b77c4d6da18bfa69d80e1d593" + integrity sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA== dependencies: minimist "^1.2.0" -json5@^2.2.3: - version "2.2.3" - resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283" - integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg== - jsonfile@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb"