From 758537b185c2cad8f6990f9e0a2b107966dc831e Mon Sep 17 00:00:00 2001 From: maddie <715921+megamaddu@users.noreply.github.com> Date: Sat, 14 May 2022 21:38:07 -0700 Subject: [PATCH 1/6] gitlab ci --- .github/workflows/ci.yml | 64 ++++++++++++++++++++++++++++++++++++++++ .travis.yml | 15 ---------- package.json | 7 +---- packages.dhall | 4 +-- 4 files changed, 67 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..8e8feaa --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,64 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Set up PureScript toolchain + uses: purescript-contrib/setup-purescript@v2.0.0 + with: + purescript: "0.15.0" + purs-tidy: "latest" + + - name: Cache PureScript dependencies + uses: actions/cache@v2 + with: + key: ${{ runner.os }}-spago-${{ hashFiles('**/*.dhall') }} + path: | + .spago + output + - name: Set up Node toolchain + uses: actions/setup-node@v2 + with: + node-version: "14.x" + + - name: Cache NPM dependencies + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + with: + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + - name: Install NPM dependencies + run: npm install + + - name: Build the project + run: npm run build + + - name: Run tests + run: npm run test + + # - name: Check formatting + # run: purs-tidy check src test + + - name: Verify Bower & Pulp + run: | + npm install bower pulp@16.0.0-0 + npx bower install + npx pulp build -- --censor-lib --strict + if [ -d "test" ]; then + npx pulp test + fi diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c7b9196..0000000 --- a/.travis.yml +++ /dev/null @@ -1,15 +0,0 @@ -dist: trusty -sudo: required -language: node_js -node_js: - - node - - "lts/*" - -cache: npm - -install: - - npm ci - - npm run deps - -script: - - npm run build diff --git a/package.json b/package.json index 9da024c..7d57c3c 100644 --- a/package.json +++ b/package.json @@ -24,12 +24,7 @@ "react": "^18.1.0" }, "scripts": { - "deps": "run-s deps:*", - "deps:spago": "spago install", - "deps:pulp": "bower install", - "build": "run-s build:*", - "build:spago": "spago build", - "build:pulp": "pulp build -o output-pulp", + "build": "spago build", "clean": "rm -rf .spago bower_components output output-pulp node_modules" } } diff --git a/packages.dhall b/packages.dhall index c4df593..e51832b 100644 --- a/packages.dhall +++ b/packages.dhall @@ -1,5 +1,5 @@ let upstream = - https://github.com/purescript/package-sets/releases/download/psc-0.15.0-20220510/packages.dhall - sha256:0b0d4db1f2f0acd3b37fa53220644ac6f64cf9b5d0226fd097c0593df563d5be + https://github.com/purescript/package-sets/releases/download/psc-0.15.0-20220513/packages.dhall + sha256:1ed784f37ae6131d99acd542d058d5ce39954ccaacc3adba5cc7cf1549d2bffa in upstream From d9402514fcd53eda97e0d96a61be55d0ae80b55b Mon Sep 17 00:00:00 2001 From: Jun Matsushita Date: Mon, 16 May 2022 19:50:40 +0200 Subject: [PATCH 2/6] Point to upgraded examples (#138) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dc8fd85..170dff1 100644 --- a/README.md +++ b/README.md @@ -48,4 +48,4 @@ If you were using [`react-basic-hooks`](https://github.com/spicydonuts/purescrip ## Where did the examples folder go? -Because this library no longer contains a specific implementation and the example structure contained a fair bit of boilerplate, they've been removed in favor of a consolidated documentation site (linked above). This is still a work in progress but you can refer to the [v14 examples](https://github.com/lumihq/purescript-react-basic/tree/v14.0.0/examples) in the meantime. +Because this library no longer contains a specific implementation and the example structure contained a fair bit of boilerplate, they've been moved to the `react-basic-classic` repository, in the [`examples` folder](https://github.com/lumihq/purescript-react-basic-classic/tree/main/examples). In addtion, a consolidated documentation site (linked above) is being worked on. \ No newline at end of file From d43a68efa03383d48ec92028f87109d49fe0b414 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Jul 2022 10:40:24 -0700 Subject: [PATCH 3/6] Bump shell-quote from 1.7.2 to 1.7.3 (#148) Bumps [shell-quote](https://github.com/substack/node-shell-quote) from 1.7.2 to 1.7.3. - [Release notes](https://github.com/substack/node-shell-quote/releases) - [Changelog](https://github.com/substack/node-shell-quote/blob/master/CHANGELOG.md) - [Commits](https://github.com/substack/node-shell-quote/compare/v1.7.2...1.7.3) --- updated-dependencies: - dependency-name: shell-quote dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2ddfb5c..d6bf34a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3783,9 +3783,9 @@ } }, "node_modules/shell-quote": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.7.2.tgz", - "integrity": "sha512-mRz/m/JVscCrkMyPqHc/bczi3OQHkLTqXHEFu0zDhK/qfv3UcOA4SVmRCLmos4bhjr9ekVQubj/R7waKapmiQg==", + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.7.3.tgz", + "integrity": "sha512-Vpfqwm4EnqGdlsBFNmHhxhElJYrdfcxPThu+ryKS5J8L/fhAwLazFZtq+S+TWZ9ANj2piSQLGj6NQg+lKPmxrw==", "dev": true }, "node_modules/signal-exit": { @@ -7705,9 +7705,9 @@ "dev": true }, "shell-quote": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.7.2.tgz", - "integrity": "sha512-mRz/m/JVscCrkMyPqHc/bczi3OQHkLTqXHEFu0zDhK/qfv3UcOA4SVmRCLmos4bhjr9ekVQubj/R7waKapmiQg==", + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.7.3.tgz", + "integrity": "sha512-Vpfqwm4EnqGdlsBFNmHhxhElJYrdfcxPThu+ryKS5J8L/fhAwLazFZtq+S+TWZ9ANj2piSQLGj6NQg+lKPmxrw==", "dev": true }, "signal-exit": { From 3b0617649f18c2e273e70d1ac450d3529204ec7b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Jul 2022 10:40:36 -0700 Subject: [PATCH 4/6] Bump hosted-git-info from 2.8.8 to 2.8.9 (#143) Bumps [hosted-git-info](https://github.com/npm/hosted-git-info) from 2.8.8 to 2.8.9. - [Release notes](https://github.com/npm/hosted-git-info/releases) - [Changelog](https://github.com/npm/hosted-git-info/blob/v2.8.9/CHANGELOG.md) - [Commits](https://github.com/npm/hosted-git-info/compare/v2.8.8...v2.8.9) --- updated-dependencies: - dependency-name: hosted-git-info dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index d6bf34a..845cf84 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1771,9 +1771,9 @@ } }, "node_modules/hosted-git-info": { - "version": "2.8.8", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz", - "integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==", + "version": "2.8.9", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", + "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==", "dev": true }, "node_modules/htmlescape": { @@ -6082,9 +6082,9 @@ } }, "hosted-git-info": { - "version": "2.8.8", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz", - "integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==", + "version": "2.8.9", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", + "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==", "dev": true }, "htmlescape": { From 074fc7782cc5dc1de5e4ebdad5147290471d2f91 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Jul 2022 10:40:51 -0700 Subject: [PATCH 5/6] Bump path-parse from 1.0.6 to 1.0.7 (#140) Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7. - [Release notes](https://github.com/jbgutierrez/path-parse/releases) - [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7) --- updated-dependencies: - dependency-name: path-parse dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 845cf84..4ed1c2e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3166,9 +3166,9 @@ } }, "node_modules/path-parse": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", - "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", "dev": true }, "node_modules/path-platform": { @@ -7193,9 +7193,9 @@ "dev": true }, "path-parse": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", - "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", "dev": true }, "path-platform": { From b33e284d87d7820d612f509e725867ce83258cf4 Mon Sep 17 00:00:00 2001 From: Russians tortured my 18yo friend Ivan bc of ukr flag in mobile phone Date: Sun, 27 Apr 2025 17:13:05 +0700 Subject: [PATCH 6/6] feat: migrate to spago@next (#154) * feat: update to spago@next * feat: update github ci * feat: purs-tidy * refactor: use lambdas * refactor: review changes --- .github/ISSUE_TEMPLATE/bug-report.md | 19 ++++++ .github/ISSUE_TEMPLATE/change-request.md | 21 +++++++ .github/ISSUE_TEMPLATE/config.yml | 8 +++ .github/PULL_REQUEST_TEMPLATE.md | 11 ++++ .github/workflows/ci.yml | 53 +++++------------ bower.json | 21 ------- package.json | 10 +--- packages.dhall | 5 -- spago.dhall | 11 ---- spago.lock | 74 ++++++++++++++++++++++++ spago.yaml | 13 +++++ src/React/Basic.js | 57 +++++++----------- src/React/Basic.purs | 36 ++++++------ src/React/Basic/Events.purs | 18 +++--- src/React/Basic/StrictMode.js | 3 +- 15 files changed, 210 insertions(+), 150 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/bug-report.md create mode 100644 .github/ISSUE_TEMPLATE/change-request.md create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 bower.json delete mode 100644 packages.dhall delete mode 100644 spago.dhall create mode 100644 spago.lock create mode 100644 spago.yaml diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md new file mode 100644 index 0000000..b79b995 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -0,0 +1,19 @@ +--- +name: Bug report +about: Report an issue +title: "" +labels: bug +assignees: "" +--- + +**Describe the bug** +A clear and concise description of the bug. + +**To Reproduce** +A minimal code example (preferably a runnable example on [Try PureScript](https://try.purescript.org)!) or steps to reproduce the issue. + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/change-request.md b/.github/ISSUE_TEMPLATE/change-request.md new file mode 100644 index 0000000..a2ee685 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/change-request.md @@ -0,0 +1,21 @@ +--- +name: Change request +about: Propose an improvement to this library +title: "" +labels: "" +assignees: "" +--- + +**Is your change request related to a problem? Please describe.** +A clear and concise description of the problem. + +Examples: + +- It's frustrating to have to [...] +- I was looking for a function to [...] + +**Describe the solution you'd like** +A clear and concise description of what a good solution to you looks like, including any solutions you've already considered. + +**Additional context** +Add any other context about the change request here. diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..8d7661e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,8 @@ +blank_issues_enabled: false +contact_links: + - name: PureScript Discourse + url: https://discourse.purescript.org/ + about: Ask and answer questions on the PureScript discussion forum. + - name: PureScript Discord + url: https://purescript.org/chat + about: Ask and answer questions on the PureScript chat. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..d8780f7 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,11 @@ +**Description of the change** +Clearly and concisely describe the purpose of the pull request. If this PR relates to an existing issue or change proposal, please link to it. Include any other background context that would help reviewers understand the motivation for this PR. + +--- + +**Checklist:** + +- [ ] Added the change to the changelog's "Unreleased" section with a link to this PR and your username +- [ ] Linked any existing issues or proposals that this pull request should close +- [ ] Updated or added relevant documentation in the README and/or documentation directory +- [ ] Added a test for the contribution (if applicable) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8e8feaa..b557cf7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,56 +9,29 @@ on: jobs: build: runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up PureScript toolchain - uses: purescript-contrib/setup-purescript@v2.0.0 + uses: purescript-contrib/setup-purescript@main with: - purescript: "0.15.0" - purs-tidy: "latest" + purescript: "latest" + purs-tidy: "0.11.0" # "latest" + spago: "unstable" - name: Cache PureScript dependencies - uses: actions/cache@v2 + uses: actions/cache@v4 with: - key: ${{ runner.os }}-spago-${{ hashFiles('**/*.dhall') }} + key: ${{ runner.os }}-spago-${{ hashFiles('**/spago.lock') }} path: | .spago output - - name: Set up Node toolchain - uses: actions/setup-node@v2 - with: - node-version: "14.x" - - - name: Cache NPM dependencies - uses: actions/cache@v2 - env: - cache-name: cache-node-modules - with: - path: ~/.npm - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - name: Install NPM dependencies - run: npm install - - - name: Build the project - run: npm run build - - name: Run tests - run: npm run test + - name: Build source + run: spago build --censor-stats --strict --ensure-ranges --pedantic-packages - # - name: Check formatting - # run: purs-tidy check src test + # - name: Run tests + # run: spago test --offline --censor-stats --strict --pedantic-packages - - name: Verify Bower & Pulp - run: | - npm install bower pulp@16.0.0-0 - npx bower install - npx pulp build -- --censor-lib --strict - if [ -d "test" ]; then - npx pulp test - fi + - name: Verify formatting + run: purs-tidy check src test \ No newline at end of file diff --git a/bower.json b/bower.json deleted file mode 100644 index ecd760b..0000000 --- a/bower.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "purescript-react-basic", - "license": [ - "Apache-2.0" - ], - "repository": { - "type": "git", - "url": "https://github.com/lumihq/purescript-react-basic" - }, - "ignore": [ - "**/.*", - "node_modules", - "bower_components", - "output" - ], - "dependencies": { - "purescript-effect": "^v4.0.0", - "purescript-prelude": "^v6.0.0", - "purescript-record": "^v4.0.0" - } -} diff --git a/package.json b/package.json index 7d57c3c..c8f5f08 100644 --- a/package.json +++ b/package.json @@ -14,17 +14,13 @@ }, "homepage": "https://github.com/lumihq/purescript-react-basic#readme", "devDependencies": { - "bower": "^1.8.14", - "npm-run-all": "^4.1.5", - "pulp": "^16.0.1", - "purescript": "^0.15.0", - "spago": "^0.20.9" + "npm-run-all": "^4.1.5" }, "dependencies": { - "react": "^18.1.0" + "react": "^19.0.0" }, "scripts": { "build": "spago build", "clean": "rm -rf .spago bower_components output output-pulp node_modules" } -} +} \ No newline at end of file diff --git a/packages.dhall b/packages.dhall deleted file mode 100644 index e51832b..0000000 --- a/packages.dhall +++ /dev/null @@ -1,5 +0,0 @@ -let upstream = - https://github.com/purescript/package-sets/releases/download/psc-0.15.0-20220513/packages.dhall - sha256:1ed784f37ae6131d99acd542d058d5ce39954ccaacc3adba5cc7cf1549d2bffa - -in upstream diff --git a/spago.dhall b/spago.dhall deleted file mode 100644 index d58c6dd..0000000 --- a/spago.dhall +++ /dev/null @@ -1,11 +0,0 @@ -{- -Welcome to a Spago project! -You can edit this file as you like. --} -{ name = "react-basic" -, dependencies = [ "effect", "prelude", "record" ] -, packages = ./packages.dhall -, sources = [ "src/**/*.purs" ] -, license = "Apache-2.0" -, repository = "https://github.com/lumihq/purescript-react-basic" -} diff --git a/spago.lock b/spago.lock new file mode 100644 index 0000000..bead828 --- /dev/null +++ b/spago.lock @@ -0,0 +1,74 @@ +{ + "workspace": { + "packages": { + "react-basic": { + "path": "./", + "core": { + "dependencies": [ + { + "effect": ">=4.0.0 <5.0.0" + }, + { + "prelude": ">=6.0.2 <7.0.0" + }, + { + "record": ">=4.0.0 <5.0.0" + } + ], + "build_plan": [ + "effect", + "functions", + "prelude", + "record", + "unsafe-coerce" + ] + }, + "test": { + "dependencies": [], + "build_plan": [] + } + } + }, + "extra_packages": {} + }, + "packages": { + "effect": { + "type": "registry", + "version": "4.0.0", + "integrity": "sha256-eBtZu+HZcMa5HilvI6kaDyVX3ji8p0W9MGKy2K4T6+M=", + "dependencies": [ + "prelude" + ] + }, + "functions": { + "type": "registry", + "version": "6.0.0", + "integrity": "sha256-adMyJNEnhGde2unHHAP79gPtlNjNqzgLB8arEOn9hLI=", + "dependencies": [ + "prelude" + ] + }, + "prelude": { + "type": "registry", + "version": "6.0.2", + "integrity": "sha256-kiAPZxihtAel8uRiTNdccf4qylp/9J3jNkEHNAD0MsE=", + "dependencies": [] + }, + "record": { + "type": "registry", + "version": "4.0.0", + "integrity": "sha256-Za5U85bTRJEfGK5Sk4hM41oXy84YQI0I8TL3WUn1Qzg=", + "dependencies": [ + "functions", + "prelude", + "unsafe-coerce" + ] + }, + "unsafe-coerce": { + "type": "registry", + "version": "6.0.0", + "integrity": "sha256-IqIYW4Vkevn8sI+6aUwRGvd87tVL36BBeOr0cGAE7t0=", + "dependencies": [] + } + } +} diff --git a/spago.yaml b/spago.yaml new file mode 100644 index 0000000..9bd1052 --- /dev/null +++ b/spago.yaml @@ -0,0 +1,13 @@ +package: + name: react-basic + publish: + license: Apache-2.0 + version: 17.0.0 + location: + githubOwner: purescript-react + githubRepo: purescript-react-basic + dependencies: + - effect: ">=4.0.0 <5.0.0" + - prelude: ">=6.0.2 <7.0.0" + - record: ">=4.0.0 <5.0.0" +workspace: {} \ No newline at end of file diff --git a/src/React/Basic.js b/src/React/Basic.js index 264d3b3..7c67cde 100644 --- a/src/React/Basic.js +++ b/src/React/Basic.js @@ -1,39 +1,24 @@ -import React from "react"; -const createElement = React.createElement; -const Fragment = React.Fragment; +import * as React from "react"; export const empty = null; -export function keyed(key) { - return (child) => - createElement(Fragment, { key: key }, child); -} - -export function element(component) { - return (props) => - Array.isArray(props.children) - ? createElement.apply(null, [component, props].concat(props.children)) - : createElement(component, props); -} - -export function elementKeyed(component) { - return (props) => - createElement(component, props); -} - -export function fragment(children) { - return createElement.apply(null, [Fragment, null].concat(children)); -} - -export function createContext(defaultValue) { - return () => - React.createContext(defaultValue); -} - -export function contextProvider(context) { - return context.Provider; -} - -export function contextConsumer(context) { - return context.Consumer; -} +export const keyed = (key) => (child) => + React.createElement(React.Fragment, { key: key }, child); + +export const element = (component) => (props) => + Array.isArray(props.children) + ? React.createElement.apply(null, [component, props].concat(props.children)) + : React.createElement(component, props); + +export const elementKeyed = (component) => (props) => + React.createElement(component, props); + +export const fragment = (children) => + React.createElement.apply(null, [React.Fragment, null].concat(children)); + +export const createContext = (defaultValue) => () => + React.createContext(defaultValue); + +export const contextProvider = (context) => context.Provider; + +export const contextConsumer = (context) => context.Consumer; \ No newline at end of file diff --git a/src/React/Basic.purs b/src/React/Basic.purs index 2753832..a0b745f 100644 --- a/src/React/Basic.purs +++ b/src/React/Basic.purs @@ -45,20 +45,20 @@ foreign import fragment :: Array JSX -> JSX -- | Create a `JSX` node from a `ReactComponent`, by providing the props. -- | -- | __*See also:* `ReactComponent`, `elementKeyed`__ -foreign import element :: - forall props. - ReactComponent { | props } -> - { | props } -> - JSX +foreign import element + :: forall props + . ReactComponent { | props } + -> { | props } + -> JSX -- | Create a `JSX` node from a `ReactComponent`, by providing the props and a key. -- | -- | __*See also:* `ReactComponent`, `element`, React's documentation regarding the special `key` prop__ -foreign import elementKeyed :: - forall props. - ReactComponent { | props } -> - { key :: String | props } -> - JSX +foreign import elementKeyed + :: forall props + . ReactComponent { | props } + -> { key :: String | props } + -> JSX -- | Represents a traditional React component. Useful for JavaScript interop and -- | FFI. For example: @@ -82,15 +82,15 @@ foreign import data ReactContext :: Type -> Type -- | __*See also:* `provider`, `consumer`, React's documentation regarding Context__ foreign import createContext :: forall a. a -> Effect (ReactContext a) -foreign import contextProvider :: - forall a. - ReactContext a -> - ReactComponent { value :: a, children :: Array JSX } +foreign import contextProvider + :: forall a + . ReactContext a + -> ReactComponent { value :: a, children :: Array JSX } -foreign import contextConsumer :: - forall a. - ReactContext a -> - ReactComponent { children :: a -> Array JSX } +foreign import contextConsumer + :: forall a + . ReactContext a + -> ReactComponent { children :: a -> Array JSX } -- | Create a provider `JSX` given a context value and children. -- | diff --git a/src/React/Basic/Events.purs b/src/React/Basic/Events.purs index 115c134..4e6f7af 100644 --- a/src/React/Basic/Events.purs +++ b/src/React/Basic/Events.purs @@ -22,8 +22,7 @@ import Type.Proxy (Proxy(..)) -- | An event handler, which receives a `SyntheticEvent` and performs some -- | effects in return. -type EventHandler - = EffectFn1 SyntheticEvent Unit +type EventHandler = EffectFn1 SyntheticEvent Unit -- | Event data that we receive from React. foreign import data SyntheticEvent :: Type @@ -38,8 +37,7 @@ foreign import data SyntheticEvent :: Type -- | \value -> setState \_ -> { value } -- | } -- | ``` -newtype EventFn a b - = EventFn (a -> b) +newtype EventFn a b = EventFn (a -> b) -- | Unsafely create an `EventFn`. This function should be avoided as it can allow -- | a `SyntheticEvent` to escape its scope. Accessing a React event's properties is only @@ -114,10 +112,10 @@ instance mergeCons :: -- | \{ targetValue, timeStamp } -> setState \_ -> { ... } -- | } -- | ``` -merge :: - forall a fns fns_list r. - RowToList fns fns_list => - Merge fns_list fns a r => - Record fns -> - EventFn a (Record r) +merge + :: forall a fns fns_list r + . RowToList fns fns_list + => Merge fns_list fns a r + => Record fns + -> EventFn a (Record r) merge = mergeImpl (Proxy :: Proxy fns_list) diff --git a/src/React/Basic/StrictMode.js b/src/React/Basic/StrictMode.js index f4fad04..d785e2b 100644 --- a/src/React/Basic/StrictMode.js +++ b/src/React/Basic/StrictMode.js @@ -1,2 +1 @@ -import React from "react"; -export const strictMode_ = React.StrictMode; +export { StrictMode as strictMode_ } from "react"; \ No newline at end of file