-
-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
70 changed files
with
1,140 additions
and
2,631 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
declare module 'ink-spinner' { | ||
import { Chalk } from 'chalk'; | ||
import * as cliSpinners from 'cli-spinners'; | ||
import { Component } from 'react'; | ||
|
||
type StringifyPartial<T> = { | ||
[P in keyof T]?: string; | ||
}; | ||
|
||
type BooleansPartial<T> = { | ||
[P in keyof T]?: boolean; | ||
}; | ||
|
||
type TupleOfNumbersPartial<T> = { | ||
[P in keyof T]?: [number, number, number]; | ||
}; | ||
// Omit taken from https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html | ||
type Omit<T, K> = Pick<T, Exclude<keyof T, K>>; | ||
|
||
type ChalkColorModels = Pick<Chalk, 'rgb' | 'hsl' | 'hsv' | 'hwb' | 'bgRgb' | 'bgHsl' | 'bgHsv' | 'bgHwb'>; | ||
type ChalkKeywordsAndHexes = Pick<Chalk, 'keyword' | 'hex' | 'bgKeyword' | 'bgHex'>; | ||
type ChalkCommons = Omit< | ||
Chalk, | ||
keyof ChalkColorModels | keyof ChalkKeywordsAndHexes | 'constructor' | 'level' | 'enabled' | ||
>; | ||
|
||
interface SpinnerProps { | ||
type?: cliSpinners.SpinnerName; | ||
} | ||
|
||
type ChalkProps = BooleansPartial<ChalkCommons> & | ||
StringifyPartial<ChalkKeywordsAndHexes> & | ||
TupleOfNumbersPartial<ChalkColorModels>; | ||
|
||
declare class Spinner extends Component<SpinnerProps & ChalkProps> {} | ||
|
||
export = Spinner; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
@remirror/react-hooks/__mocks__/resize-observer-polyfill.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const observers = new Map<HTMLElement, true>(); | ||
|
||
export const fakeResizeObserverPolyfill = Object.freeze({ | ||
observe: jest.fn((el: HTMLElement) => observers.set(el, true)), | ||
unobserve: jest.fn((el: HTMLElement) => observers.delete(el)), | ||
disconnect: jest.fn(() => observers.clear()), | ||
}); | ||
|
||
let callback: any; | ||
const defaultBounds = { x: 0, y: 0, width: 0, height: 0, top: 0, right: 0, bottom: 0, left: 0 }; | ||
|
||
export const triggerChange = (bounds: Partial<typeof defaultBounds> = {}, el: HTMLElement) => { | ||
const target = observers.get(el); | ||
|
||
if (callback && target) { | ||
callback([Object.freeze({ target, contentRect: { defaultBounds, ...bounds } })]); | ||
} | ||
}; | ||
|
||
export default jest.fn(cb => { | ||
callback = cb; | ||
return fakeResizeObserverPolyfill; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const config = require('../../support/jest/jest.config'); | ||
|
||
module.exports = { | ||
...config, | ||
name: '@remirror/react-hooks', | ||
displayName: 'react-hooks', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"name": "@remirror/react-hooks", | ||
"description": "React hooks for remirror", | ||
"license": "MIT", | ||
"author": "Ifiok Jr. <ifiokotung@gmail.com>", | ||
"homepage": "https://github.com/ifiokjr/remirror/tree/master/@remirror/react-hooks", | ||
"repository": "https://github.com/ifiokjr/remirror/tree/master/@remirror/react-hooks", | ||
"version": "0.4.2-canary.2", | ||
"main": "lib/index.js", | ||
"module": "lib/dist/react-hooks.esm.js", | ||
"files": [ | ||
"lib", | ||
"src" | ||
], | ||
"scripts": { | ||
"build": "run-p build:*", | ||
"build:babel": "babel src --out-dir lib --root-mode=upward --extensions \".ts,.tsx\" -s", | ||
"build:declaration": "tsc -p ./tsconfig.prod.json --emitDeclarationOnly --declarationMap", | ||
"dev": "run-p dev:*", | ||
"dev:babel": "babel src --out-dir lib --root-mode=upward --extensions \".ts,.tsx\" -s --watch", | ||
"dev:declaration": "tsc -p ./tsconfig.prod.json --emitDeclarationOnly --declarationMap --watch", | ||
"lint": "tslint --project tsconfig.lint.json --config ../../tslint.json", | ||
"typecheck": "tsc -p ./tsconfig.json --noEmit" | ||
}, | ||
"types": "lib/index.d.ts", | ||
"dependencies": { | ||
"@babel/runtime": "^7.5.5", | ||
"@remirror/core-helpers": "0.4.2-canary.2", | ||
"@remirror/core-types": "0.4.2-canary.2", | ||
"resize-observer-polyfill": "^1.5.1" | ||
}, | ||
"peerDependencies": { | ||
"@emotion/core": "^10", | ||
"@types/react": "^16.8.0", | ||
"react": "^16.8.0" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"cjs": "lib/dist/react-hooks.cjs.js", | ||
"meta": { | ||
"sizeLimit": "65 KB" | ||
}, | ||
"sideEffects": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<div align="center"> | ||
<br /> | ||
<div align="center"> | ||
<img width="300" src="https://cdn.jsdelivr.net/gh/ifiokjr/remirror/support/assets/logo-icon.svg" alt="remirror" /> | ||
</div> | ||
<br /> | ||
<br /> | ||
<br /> | ||
<br /> | ||
</div> | ||
|
||
[![npm bundle size (scoped)](https://img.shields.io/bundlephobia/minzip/@remirror/react-hooks.svg?style=for-the-badge)](https://bundlephobia.com/result?p=@remirror/react-hooks) [![npm](https://img.shields.io/npm/dm/@remirror/react-hooks.svg?style=for-the-badge&logo=npm)](https://www.npmjs.com/package/@remirror/react-hooks) [![Dependencies (path)](https://img.shields.io/david/ifiokjr/remirror.svg?logo=npm&path=@remirror%2Freact-hooks&style=for-the-badge)](https://github.com/ifiokjr/remirror/blob/master/@remirror/react-hooks/package.json) [![NPM](https://img.shields.io/npm/l/@remirror/react-hooks.svg?style=for-the-badge)](https://github.com/ifiokjr/remirror/blob/master/LICENSE) [![GitHub issues by-label](https://img.shields.io/github/issues/ifiokjr/remirror/@remirror/react-hooks.svg?label=Open%20Issues&logo=github&style=for-the-badge)](https://github.com/ifiokjr/remirror/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%40remirror%2Freact-hooks) [![GitHub pull requests by-label](https://img.shields.io/github/issues-pr/ifiokjr/remirror/@remirror/react-hooks.svg?label=Open%20Pull%20Requests&logo=github&style=for-the-badge)](https://github.com/ifiokjr/remirror/pulls?utf8=%E2%9C%93&q=is%3Apr+is%3Aopen+sort%3Aupdated-desc+label%3A%40remirror%2Freact-hooks) | ||
|
||
Some helper react hooks for the remirror library. | ||
|
||
## Installation | ||
|
||
```bash | ||
yarn add @remirror/react-hooks | ||
``` | ||
|
||
## Usage | ||
|
||
For in depth usage with proper code example see the [docs](https://docs.remirror.org) |
Oops, something went wrong.