emoji-picker-react 3.6.1 → 4.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +17 -20
- package/README.md +129 -168
- package/dist/DomUtils/categoryNameFromDom.d.ts +1 -0
- package/dist/DomUtils/scrollCategoryIntoView.d.ts +1 -0
- package/dist/DomUtils/scrollTo.d.ts +1 -0
- package/dist/DomUtils/selectors.d.ts +12 -0
- package/dist/components/Layout/Flex.d.ts +14 -0
- package/dist/components/Layout/Relative.d.ts +7 -0
- package/dist/components/body/Body.d.ts +3 -0
- package/dist/components/body/EmojiCategory.d.ts +10 -0
- package/dist/components/body/EmojiList.d.ts +3 -0
- package/dist/components/body/EmojiVariationPicker.d.ts +3 -0
- package/dist/components/body/RecentlyUsed.d.ts +7 -0
- package/dist/components/context/ElementRefContext.d.ts +17 -0
- package/dist/components/context/PickerConfigContext.d.ts +8 -0
- package/dist/components/context/PickerContext.d.ts +21 -0
- package/dist/components/emoji/Emoji.d.ts +14 -0
- package/dist/components/footer/Preview.d.ts +7 -0
- package/dist/components/header/Header.d.ts +3 -0
- package/dist/components/header/Search.d.ts +3 -0
- package/dist/components/header/SkinTonePicker.d.ts +3 -0
- package/dist/components/main/PickerMain.d.ts +7 -0
- package/dist/components/navigation/CategoryNavigation.d.ts +3 -0
- package/dist/config/categoryConfig.d.ts +21 -0
- package/dist/config/cdnUrls.d.ts +2 -0
- package/dist/config/config.d.ts +39 -0
- package/dist/config/useConfig.d.ts +13 -0
- package/dist/data/emojis.d.ts +40 -0
- package/dist/data/groups.d.ts +2 -0
- package/dist/data/skinToneVariations.d.ts +10 -0
- package/dist/dataUtils/DataTypes.d.ts +8 -0
- package/dist/dataUtils/alphaNumericEmojiIndex.d.ts +4 -0
- package/dist/dataUtils/asEmoji.d.ts +2 -0
- package/dist/dataUtils/emojiSelectors.d.ts +16 -0
- package/dist/dataUtils/parseNativeEmoji.d.ts +1 -0
- package/dist/dataUtils/recentlyUsed.d.ts +11 -0
- package/dist/emoji-picker-react.cjs.development.css +13 -0
- package/dist/emoji-picker-react.cjs.development.js +7425 -0
- package/dist/emoji-picker-react.cjs.development.js.map +1 -0
- package/dist/emoji-picker-react.cjs.production.min.js +2 -0
- package/dist/emoji-picker-react.cjs.production.min.js.map +1 -0
- package/dist/emoji-picker-react.esm.js +7485 -0
- package/dist/emoji-picker-react.esm.js.map +1 -0
- package/dist/hooks/preloadEmoji.d.ts +4 -0
- package/dist/hooks/useActiveCategoryScrollDetection.d.ts +2 -0
- package/dist/hooks/useCloseAllOpenToggles.d.ts +4 -0
- package/dist/hooks/useEmojiElements.d.ts +1 -0
- package/dist/hooks/useEmojiMouseEnter.d.ts +3 -0
- package/dist/hooks/useFilter.d.ts +8 -0
- package/dist/hooks/useInitialLoad.d.ts +2 -0
- package/dist/hooks/useIsEmojiHidden.d.ts +2 -0
- package/dist/hooks/useIsSearchMode.d.ts +1 -0
- package/dist/hooks/useMouseDownHandlers.d.ts +2 -0
- package/dist/hooks/useOnScroll.d.ts +2 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +8 -3
- package/dist/types/exposedTypes.d.ts +10 -0
- package/package.json +72 -52
- package/src/DomUtils/categoryNameFromDom.ts +3 -0
- package/src/DomUtils/scrollCategoryIntoView.ts +18 -0
- package/src/DomUtils/scrollTo.ts +11 -0
- package/src/DomUtils/selectors.ts +93 -0
- package/src/EmojiPickerReact.css +85 -0
- package/src/components/Layout/Flex.css +11 -0
- package/src/components/Layout/Flex.tsx +28 -0
- package/src/components/Layout/Relative.tsx +14 -0
- package/src/components/body/Body.css +6 -0
- package/src/components/body/Body.tsx +24 -0
- package/src/components/body/EmojiCategory.css +38 -0
- package/src/components/body/EmojiCategory.tsx +27 -0
- package/src/components/body/EmojiList.css +5 -0
- package/src/components/body/EmojiList.tsx +101 -0
- package/src/components/body/EmojiVariationPicker.css +65 -0
- package/src/components/body/EmojiVariationPicker.tsx +154 -0
- package/src/components/body/RecentlyUsed.tsx +50 -0
- package/src/components/body/svg/triangle.svg +11 -0
- package/src/components/context/ElementRefContext.tsx +61 -0
- package/src/components/context/PickerConfigContext.tsx +29 -0
- package/src/components/context/PickerContext.tsx +139 -0
- package/src/components/emoji/Emoji.css +44 -0
- package/src/components/emoji/Emoji.tsx +104 -0
- package/src/components/footer/Preview.css +14 -0
- package/src/components/footer/Preview.tsx +80 -0
- package/src/components/header/Header.css +4 -0
- package/src/components/header/Header.tsx +21 -0
- package/src/components/header/Search.css +72 -0
- package/src/components/header/Search.tsx +36 -0
- package/src/components/header/SkinTonePicker.css +86 -0
- package/src/components/header/SkinTonePicker.tsx +55 -0
- package/src/components/header/svg/magnifier.svg +13 -0
- package/src/components/header/svg/times.svg +33 -0
- package/src/components/main/PickerMain.css +11 -0
- package/src/components/main/PickerMain.tsx +42 -0
- package/src/components/navigation/CategoryNavigation.css +82 -0
- package/src/components/navigation/CategoryNavigation.tsx +32 -0
- package/src/components/navigation/svg/CategoryNav.svg +508 -0
- package/src/config/categoryConfig.ts +107 -0
- package/src/config/cdnUrls.ts +24 -0
- package/src/config/config.ts +64 -0
- package/src/config/useConfig.ts +54 -0
- package/src/data/emojis.ts +5350 -0
- package/src/data/groups.ts +12 -0
- package/src/data/skinToneVariations.ts +19 -0
- package/src/dataUtils/DataTypes.ts +10 -0
- package/src/dataUtils/alphaNumericEmojiIndex.ts +23 -0
- package/src/dataUtils/asEmoji.ts +5 -0
- package/src/dataUtils/emojiSelectors.ts +94 -0
- package/src/dataUtils/parseNativeEmoji.ts +6 -0
- package/src/dataUtils/recentlyUsed.ts +62 -0
- package/src/hooks/preloadEmoji.ts +29 -0
- package/src/hooks/useActiveCategoryScrollDetection.ts +46 -0
- package/src/hooks/useCloseAllOpenToggles.ts +26 -0
- package/src/hooks/useEmojiElements.ts +7 -0
- package/src/hooks/useEmojiMouseEnter.ts +59 -0
- package/src/hooks/useFilter.ts +142 -0
- package/src/hooks/useInitialLoad.ts +9 -0
- package/src/hooks/useIsEmojiHidden.ts +16 -0
- package/src/hooks/useIsSearchMode.ts +7 -0
- package/src/hooks/useMouseDownHandlers.ts +161 -0
- package/src/hooks/useOnScroll.ts +28 -0
- package/src/index.tsx +26 -0
- package/src/types/exposedTypes.ts +11 -0
- package/.babelrc +0 -30
- package/.eslintrc.js +0 -37
- package/.github/workflows/npmpublish.yml +0 -30
- package/.prettierignore +0 -2
- package/.storybook/addons.js +0 -2
- package/.storybook/config.js +0 -9
- package/assets/captured.gif +0 -0
- package/dist/index.js.LICENSE.txt +0 -5
- package/dist/index.js.map +0 -1
- package/dist/main.css +0 -206
- package/dist/main.css.map +0 -1
- package/emoji-picker-react.d.ts +0 -45
- package/webpack.config.js +0 -52
package/LICENSE
CHANGED
|
@@ -1,24 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
MIT License
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
distribute this software, either in source code form or as a compiled
|
|
5
|
-
binary, for any purpose, commercial or non-commercial, and by any
|
|
6
|
-
means.
|
|
3
|
+
Copyright (c) 2022 ealush
|
|
7
4
|
|
|
8
|
-
|
|
9
|
-
of this software
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
software under copyright law.
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
15
11
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
-
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
20
|
-
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
21
|
-
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
22
|
-
OTHER DEALINGS IN THE SOFTWARE.
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
23
14
|
|
|
24
|
-
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,220 +1,181 @@
|
|
|
1
|
-
#
|
|
1
|
+
# TSDX React w/ Storybook User Guide
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Congrats! You just saved yourself hours of work by bootstrapping this project with TSDX. Let’s get you oriented with what’s here and how to use it.
|
|
4
4
|
|
|
5
|
-
!
|
|
5
|
+
> This TSDX setup is meant for developing React component libraries (not apps!) that can be published to NPM. If you’re looking to build a React-based app, you should use `create-react-app`, `razzle`, `nextjs`, `gatsby`, or `react-static`.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
> If you’re new to TypeScript and React, checkout [this handy cheatsheet](https://github.com/sw-yx/react-typescript-cheatsheet/)
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
- Unlike previous versions, this version uses Apple emojis.
|
|
11
|
-
- V3 does not support SSR. The assumption is that you mount it only after user interaction in the browser. SSR support may be added in the future.
|
|
9
|
+
## Commands
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
TSDX scaffolds your new library inside `/src`, and also sets up a [Parcel-based](https://parceljs.org) playground for it inside `/example`.
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
The recommended workflow is to run TSDX in one terminal:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm start # or yarn start
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
This builds to `/dist` and runs the project in watch mode so any edits you save inside `src` causes a rebuild to `/dist`.
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
Then run either Storybook or the example playground:
|
|
22
|
+
|
|
23
|
+
### Storybook
|
|
24
|
+
|
|
25
|
+
Run inside another terminal:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
yarn storybook
|
|
23
29
|
```
|
|
24
30
|
|
|
25
|
-
|
|
31
|
+
This loads the stories from `./stories`.
|
|
26
32
|
|
|
27
|
-
|
|
28
|
-
- Apple emojis instead of emojione.
|
|
29
|
-
- Recently used emojis support.
|
|
30
|
-
- Faster load time, improved performance.
|
|
31
|
-
- Ability to set default skin tone.
|
|
33
|
+
> NOTE: Stories should reference the components as if using the library, similar to the example playground. This means importing from the root project directory. This has been aliased in the tsconfig and the storybook webpack config as a helper.
|
|
32
34
|
|
|
33
|
-
|
|
35
|
+
### Example
|
|
34
36
|
|
|
35
|
-
|
|
37
|
+
Then run the example inside another:
|
|
36
38
|
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const App = () => {
|
|
42
|
-
const [chosenEmoji, setChosenEmoji] = useState(null);
|
|
43
|
-
|
|
44
|
-
const onEmojiClick = (event, emojiObject) => {
|
|
45
|
-
setChosenEmoji(emojiObject);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
return (
|
|
49
|
-
<div>
|
|
50
|
-
{chosenEmoji ? (
|
|
51
|
-
<span>You chose: {chosenEmoji.emoji}</span>
|
|
52
|
-
) : (
|
|
53
|
-
<span>No emoji Chosen</span>
|
|
54
|
-
)}
|
|
55
|
-
<Picker onEmojiClick={onEmojiClick} />
|
|
56
|
-
</div>
|
|
57
|
-
);
|
|
58
|
-
};
|
|
39
|
+
```bash
|
|
40
|
+
cd example
|
|
41
|
+
npm i # or yarn to install dependencies
|
|
42
|
+
npm start # or yarn start
|
|
59
43
|
```
|
|
60
44
|
|
|
61
|
-
|
|
45
|
+
The default example imports and live reloads whatever is in `/dist`, so if you are seeing an out of date component, make sure TSDX is running in watch mode like we recommend above. **No symlinking required**, we use [Parcel's aliasing](https://parceljs.org/module_resolution.html#aliases).
|
|
62
46
|
|
|
63
|
-
|
|
64
|
-
| ----------------------- | ---------- | ------------- | --------- | ------------------------------------------------------------------------------------------------------- |
|
|
65
|
-
| `onEmojiClick` | `Function` | `undefined` | Yes | Callback to run when clicking an emoji. |
|
|
66
|
-
| `preload` | `Boolean` | `false` | No | Indicates whether all emojis images, should be preloaded, or only when showing each category. |
|
|
67
|
-
| `skinTone` | `string` | `neutral` | No | Decides the default skit tone for supported emojis. |
|
|
68
|
-
| `disableAutoFocus` | `boolean` | `false` | No | Disables autofocus of the search bar. Useful for safari-iphone devices which zoom in to focused inputs. |
|
|
69
|
-
| `disableSearchBar` | `boolean` | `false` | No | Disables the search bar and the skin tone picker altogether. |
|
|
70
|
-
| `disableSkinTonePicker` | `boolean` | `false` | No | Disables the skin tone picker. |
|
|
71
|
-
| `pickerStyle` | `Object` | `undefined` | No | Overrides style of the component. |
|
|
72
|
-
| `groupNames` | `Object` | `undefined` | No | Specifies alternative category names to use. See Internationalization section. |
|
|
73
|
-
| `groupVisibility` | `Object` | `undefined` | No | Specifies group names to be disabled. |
|
|
74
|
-
| `native` | `Boolean` | `false` | No | Loads system emojis instead of Apple Emoji pngs |
|
|
75
|
-
| `searchPlaceholder` | `string` | `null` | No | Decides the default placeholder for the search input |
|
|
47
|
+
To do a one-off build, use `npm run build` or `yarn build`.
|
|
76
48
|
|
|
77
|
-
|
|
49
|
+
To run tests, use `npm test` or `yarn test`.
|
|
78
50
|
|
|
79
|
-
|
|
51
|
+
## Configuration
|
|
80
52
|
|
|
81
|
-
|
|
82
|
-
2. An emoji object, which contains the following:
|
|
83
|
-
- `emoji`: The emoji symbol. May vary across OSs, in some it may not be visible to you.
|
|
84
|
-
- `unified`: The actual emoji unicode.
|
|
85
|
-
- `activeSkinTone`: The currently selected skin tone, regardless if the current emoji has one or not.
|
|
86
|
-
- `originalUnified`: If the currently selected emoji has a skin tone modifier, `originalUnified` will hold the "neutral" code.
|
|
87
|
-
- `names`: An array of one or more descriptive names for the emoji.
|
|
53
|
+
Code quality is set up for you with `prettier`, `husky`, and `lint-staged`. Adjust the respective fields in `package.json` accordingly.
|
|
88
54
|
|
|
89
|
-
|
|
55
|
+
### Jest
|
|
90
56
|
|
|
91
|
-
|
|
92
|
-
Emoji-picker-react exports descriptive names for all skin variations so you may use them when setting your variations.
|
|
57
|
+
Jest tests are set up to run with `npm test` or `yarn test`.
|
|
93
58
|
|
|
94
|
-
|
|
59
|
+
### Bundle analysis
|
|
95
60
|
|
|
96
|
-
-
|
|
97
|
-
- ✋🏻 SKIN_TONE_LIGHT
|
|
98
|
-
- ✋🏼 SKIN_TONE_MEDIUM_LIGHT
|
|
99
|
-
- ✋🏽 SKIN_TONE_MEDIUM
|
|
100
|
-
- ✋🏾 SKIN_TONE_MEDIUM_DARK
|
|
101
|
-
- ✋🏿 SKIN_TONE_DARK
|
|
61
|
+
Calculates the real cost of your library using [size-limit](https://github.com/ai/size-limit) with `npm run size` and visulize it with `npm run analyze`.
|
|
102
62
|
|
|
103
|
-
|
|
63
|
+
#### Setup Files
|
|
104
64
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
65
|
+
This is the folder structure we set up for you:
|
|
66
|
+
|
|
67
|
+
```txt
|
|
68
|
+
/example
|
|
69
|
+
index.html
|
|
70
|
+
index.tsx # test your component here in a demo app
|
|
71
|
+
package.json
|
|
72
|
+
tsconfig.json
|
|
73
|
+
/src
|
|
74
|
+
index.tsx # EDIT THIS
|
|
75
|
+
/test
|
|
76
|
+
blah.test.tsx # EDIT THIS
|
|
77
|
+
/stories
|
|
78
|
+
Thing.stories.tsx # EDIT THIS
|
|
79
|
+
/.storybook
|
|
80
|
+
main.js
|
|
81
|
+
preview.js
|
|
82
|
+
.gitignore
|
|
83
|
+
package.json
|
|
84
|
+
README.md # EDIT THIS
|
|
85
|
+
tsconfig.json
|
|
122
86
|
```
|
|
123
87
|
|
|
124
|
-
####
|
|
88
|
+
#### React Testing Library
|
|
125
89
|
|
|
126
|
-
|
|
90
|
+
We do not set up `react-testing-library` for you yet, we welcome contributions and documentation on this.
|
|
127
91
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
return (
|
|
140
|
-
<div>
|
|
141
|
-
<Picker onEmojiClick={onEmojiClick} pickerStyle={{ width: '100%' }} />
|
|
142
|
-
</div>
|
|
143
|
-
);
|
|
144
|
-
};
|
|
145
|
-
```
|
|
92
|
+
### Rollup
|
|
93
|
+
|
|
94
|
+
TSDX uses [Rollup](https://rollupjs.org) as a bundler and generates multiple rollup configs for various module formats and build settings. See [Optimizations](#optimizations) for details.
|
|
95
|
+
|
|
96
|
+
### TypeScript
|
|
97
|
+
|
|
98
|
+
`tsconfig.json` is set up to interpret `dom` and `esnext` types, as well as `react` for `jsx`. Adjust according to your needs.
|
|
99
|
+
|
|
100
|
+
## Continuous Integration
|
|
146
101
|
|
|
147
|
-
|
|
102
|
+
### GitHub Actions
|
|
148
103
|
|
|
149
|
-
|
|
150
|
-
|
|
104
|
+
Two actions are added by default:
|
|
105
|
+
|
|
106
|
+
- `main` which installs deps w/ cache, lints, tests, and builds on all pushes against a Node and OS matrix
|
|
107
|
+
- `size` which comments cost comparison of your library on every pull request using [size-limit](https://github.com/ai/size-limit)
|
|
108
|
+
|
|
109
|
+
## Optimizations
|
|
110
|
+
|
|
111
|
+
Please see the main `tsdx` [optimizations docs](https://github.com/palmerhq/tsdx#optimizations). In particular, know that you can take advantage of development-only optimizations:
|
|
151
112
|
|
|
152
113
|
```js
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
objects: 'stuff',
|
|
161
|
-
symbols: 'more stuff',
|
|
162
|
-
flags: 'fun with flags',
|
|
163
|
-
recently_used: 'did I really use those?!',
|
|
164
|
-
}}
|
|
165
|
-
/>
|
|
114
|
+
// ./types/index.d.ts
|
|
115
|
+
declare var __DEV__: boolean;
|
|
116
|
+
|
|
117
|
+
// inside your code...
|
|
118
|
+
if (__DEV__) {
|
|
119
|
+
console.log('foo');
|
|
120
|
+
}
|
|
166
121
|
```
|
|
167
122
|
|
|
168
|
-
|
|
123
|
+
You can also choose to install and use [invariant](https://github.com/palmerhq/tsdx#invariant) and [warning](https://github.com/palmerhq/tsdx#warning) functions.
|
|
169
124
|
|
|
170
|
-
|
|
171
|
-
- animals_nature
|
|
172
|
-
- food_drink
|
|
173
|
-
- travel_places
|
|
174
|
-
- activities
|
|
175
|
-
- objects
|
|
176
|
-
- symbols
|
|
177
|
-
- flags
|
|
178
|
-
- recently_used
|
|
125
|
+
## Module Formats
|
|
179
126
|
|
|
180
|
-
|
|
127
|
+
CJS, ESModules, and UMD module formats are supported.
|
|
181
128
|
|
|
182
|
-
|
|
129
|
+
The appropriate paths are configured in `package.json` and `dist/index.js` accordingly. Please report if any issues are found.
|
|
183
130
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
131
|
+
## Deploying the Example Playground
|
|
132
|
+
|
|
133
|
+
The Playground is just a simple [Parcel](https://parceljs.org) app, you can deploy it anywhere you would normally deploy that. Here are some guidelines for **manually** deploying with the Netlify CLI (`npm i -g netlify-cli`):
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
cd example # if not already in the example folder
|
|
137
|
+
npm run build # builds to dist
|
|
138
|
+
netlify deploy # deploy the dist folder
|
|
190
139
|
```
|
|
191
140
|
|
|
192
|
-
|
|
141
|
+
Alternatively, if you already have a git repo connected, you can set up continuous deployment with Netlify:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
netlify init
|
|
145
|
+
# build command: yarn build && cd example && yarn && yarn build
|
|
146
|
+
# directory to deploy: example/dist
|
|
147
|
+
# pick yes for netlify.toml
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Named Exports
|
|
151
|
+
|
|
152
|
+
Per Palmer Group guidelines, [always use named exports.](https://github.com/palmerhq/typescript#exports) Code split inside your React app instead of your React library.
|
|
153
|
+
|
|
154
|
+
## Including Styles
|
|
155
|
+
|
|
156
|
+
There are many ways to ship styles, including with CSS-in-JS. TSDX has no opinion on this, configure how you like.
|
|
157
|
+
|
|
158
|
+
For vanilla CSS, you can include it at the root directory and add it to the `files` section in your `package.json`, so that it can be imported separately by your users and run through their bundler's loader.
|
|
193
159
|
|
|
194
|
-
|
|
195
|
-
- animals_nature
|
|
196
|
-
- food_drink
|
|
197
|
-
- travel_places
|
|
198
|
-
- activities
|
|
199
|
-
- objects
|
|
200
|
-
- symbols
|
|
201
|
-
- flags
|
|
202
|
-
- recently_used
|
|
160
|
+
## Publishing to NPM
|
|
203
161
|
|
|
204
|
-
|
|
162
|
+
We recommend using [np](https://github.com/sindresorhus/np).
|
|
205
163
|
|
|
206
|
-
|
|
164
|
+
## Usage with Lerna
|
|
207
165
|
|
|
208
|
-
|
|
166
|
+
When creating a new package with TSDX within a project set up with Lerna, you might encounter a `Cannot resolve dependency` error when trying to run the `example` project. To fix that you will need to make changes to the `package.json` file _inside the `example` directory_.
|
|
209
167
|
|
|
210
|
-
|
|
168
|
+
The problem is that due to the nature of how dependencies are installed in Lerna projects, the aliases in the example project's `package.json` might not point to the right place, as those dependencies might have been installed in the root of your Lerna project.
|
|
211
169
|
|
|
212
|
-
|
|
170
|
+
Change the `alias` to point to where those packages are actually installed. This depends on the directory structure of your Lerna project, so the actual path might be different from the diff below.
|
|
213
171
|
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
172
|
+
```diff
|
|
173
|
+
"alias": {
|
|
174
|
+
- "react": "../node_modules/react",
|
|
175
|
+
- "react-dom": "../node_modules/react-dom"
|
|
176
|
+
+ "react": "../../../node_modules/react",
|
|
177
|
+
+ "react-dom": "../../../node_modules/react-dom"
|
|
178
|
+
},
|
|
218
179
|
```
|
|
219
180
|
|
|
220
|
-
to
|
|
181
|
+
An alternative to fixing this problem would be to remove aliases altogether and define the dependencies referenced as aliases as dev dependencies instead. [However, that might cause other problems.](https://github.com/palmerhq/tsdx/issues/64)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function categoryNameFromDom($category: Element | null): string | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function scrollCategoryIntoView(root: HTMLElement | null, category: string): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function scrollTo(root: HTMLElement | null, top?: number): void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DataEmoji } from '../dataUtils/DataTypes';
|
|
2
|
+
export declare function buttonFromEmoji(emojiElement: HTMLElement | null): HTMLButtonElement | null;
|
|
3
|
+
export declare function emojiFromElement(element: HTMLElement | null): DataEmoji | undefined;
|
|
4
|
+
export declare function isEmojiElement(element: HTMLElement | null): boolean;
|
|
5
|
+
export declare function closestCategory(element: HTMLElement | null): HTMLElement | null;
|
|
6
|
+
export declare function categoryLabelFromCategory(category: HTMLElement | null): HTMLElement | null;
|
|
7
|
+
export declare function closestCategoryLabel(element: null | HTMLElement): HTMLElement | null;
|
|
8
|
+
export declare function elementHeight(element: HTMLElement | null): number;
|
|
9
|
+
export declare function emojiTrueOffsetTop(element: HTMLElement | null): number;
|
|
10
|
+
export declare function emojiTruOffsetLeft(element: HTMLElement | null): number;
|
|
11
|
+
export declare function unifiedFromEmojiElement(emoji: HTMLElement | null): string | null;
|
|
12
|
+
export declare function originalUnifiedFromEmojiElement(emoji: HTMLElement | null): string | null;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import './Flex.css';
|
|
3
|
+
export declare enum FlexDirection {
|
|
4
|
+
ROW = "FlexRow",
|
|
5
|
+
COLUMN = "FlexColumn"
|
|
6
|
+
}
|
|
7
|
+
declare type Props = Readonly<{
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
className?: string;
|
|
10
|
+
style?: React.CSSProperties;
|
|
11
|
+
direction?: FlexDirection;
|
|
12
|
+
}>;
|
|
13
|
+
export default function Flex({ children, className, style, direction }: Props): JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { CategoryConfig } from '../../config/categoryConfig';
|
|
3
|
+
import './EmojiCategory.css';
|
|
4
|
+
declare type Props = Readonly<{
|
|
5
|
+
categoryConfig: CategoryConfig;
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
hidden?: boolean;
|
|
8
|
+
}>;
|
|
9
|
+
export declare function EmojiCategory({ categoryConfig, children, hidden }: Props): JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { CategoryConfig } from '../../config/categoryConfig';
|
|
3
|
+
declare type Props = Readonly<{
|
|
4
|
+
categoryConfig: CategoryConfig;
|
|
5
|
+
}>;
|
|
6
|
+
export declare function RecentlyUsed({ categoryConfig }: Props): JSX.Element | null;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export declare function ElementRefContextProvider({ children }: {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
}): JSX.Element;
|
|
5
|
+
export declare type ElementRef = React.MutableRefObject<HTMLElement | null>;
|
|
6
|
+
declare type ElementRefs = {
|
|
7
|
+
PickerMainRef: ElementRef;
|
|
8
|
+
AnchoredEmojiRef: ElementRef;
|
|
9
|
+
BodyRef: React.MutableRefObject<HTMLElement | null>;
|
|
10
|
+
};
|
|
11
|
+
declare type ElementRefKeys = keyof ElementRefs;
|
|
12
|
+
export declare function useElementRef(key: ElementRefKeys): ElementRef | React.MutableRefObject<HTMLElement | null>;
|
|
13
|
+
export declare function usePickerMainRef(): ElementRef | React.MutableRefObject<HTMLElement | null>;
|
|
14
|
+
export declare function useAnchoredEmojiRef(): ElementRef | React.MutableRefObject<HTMLElement | null>;
|
|
15
|
+
export declare function useSetAnchoredEmojiRef(): (target: null | HTMLElement) => void;
|
|
16
|
+
export declare function useBodyRef(): React.MutableRefObject<HTMLDivElement | null>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { PickerConfig, PickerConfigInternal } from '../../config/config';
|
|
3
|
+
declare type Props = PickerConfig & Readonly<{
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
}>;
|
|
6
|
+
export declare function PickerConfigProvider({ children, ...config }: Props): JSX.Element;
|
|
7
|
+
export declare function usePickerConfig(): PickerConfigInternal;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { SkinTones } from '../../data/skinToneVariations';
|
|
3
|
+
import { DataEmoji } from '../../dataUtils/DataTypes';
|
|
4
|
+
import { FilterDict } from '../../hooks/useFilter';
|
|
5
|
+
export declare function PickerContextProvider({ children }: Props): JSX.Element;
|
|
6
|
+
declare type ReactState<T> = [T, React.Dispatch<React.SetStateAction<T>>];
|
|
7
|
+
declare type Props = Readonly<{
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
}>;
|
|
10
|
+
export declare function useFilterRef(): React.MutableRefObject<Record<string, Record<string, DataEmoji>>>;
|
|
11
|
+
export declare function useDisallowClickRef(): React.MutableRefObject<boolean>;
|
|
12
|
+
export declare function useSearchTermState(): ReactState<string>;
|
|
13
|
+
export declare function useActiveCategoryState(): [ActiveCategoryState, (nextActive: string) => void, (nextActive: string) => void];
|
|
14
|
+
export declare function useActiveSkinToneState(): [SkinTones, (skinTone: SkinTones) => void];
|
|
15
|
+
export declare function useEmojisThatFailedToLoadState(): ReactState<Set<string>>;
|
|
16
|
+
export declare function useIsPastInitialLoad(): boolean;
|
|
17
|
+
export declare function useEmojiVariationPickerState(): ReactState<DataEmoji | null>;
|
|
18
|
+
export declare function useSkinToneFanOpenState(): ReactState<boolean>;
|
|
19
|
+
export declare type FilterState = Record<string, FilterDict>;
|
|
20
|
+
declare type ActiveCategoryState = null | string;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { EmojiStyle } from '../../config/config';
|
|
3
|
+
import { DataEmoji } from '../../dataUtils/DataTypes';
|
|
4
|
+
import './Emoji.css';
|
|
5
|
+
declare type Props = Readonly<{
|
|
6
|
+
hidden?: boolean;
|
|
7
|
+
emojiStyle: EmojiStyle;
|
|
8
|
+
emoji: DataEmoji;
|
|
9
|
+
unified: string;
|
|
10
|
+
showVariations?: boolean;
|
|
11
|
+
size?: number;
|
|
12
|
+
}>;
|
|
13
|
+
export declare function Emoji({ emoji, unified, hidden, emojiStyle, showVariations, size }: Props): JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare enum Categories {
|
|
2
|
+
RECENTLY_USED = "recently_used",
|
|
3
|
+
SMILEYS_PEOPLE = "smileys_people",
|
|
4
|
+
ANIMALS_NATURE = "animals_nature",
|
|
5
|
+
FOOD_DRINK = "food_drink",
|
|
6
|
+
TRAVEL_PLACES = "travel_places",
|
|
7
|
+
ACTIVITIES = "activities",
|
|
8
|
+
OBJECTS = "objects",
|
|
9
|
+
SYMBOLS = "symbols",
|
|
10
|
+
FLAGS = "flags"
|
|
11
|
+
}
|
|
12
|
+
export declare const baseCategoriesConfig: CategoryConfig[];
|
|
13
|
+
export declare function categoryFromCategoryConfig(category: CategoryConfig): Categories;
|
|
14
|
+
export declare function categoryNameFromCategoryConfig(category: CategoryConfig): string;
|
|
15
|
+
export declare type CategoriesConfig = CategoryConfig[];
|
|
16
|
+
export declare type CategoryConfig = {
|
|
17
|
+
category: Categories;
|
|
18
|
+
name: string;
|
|
19
|
+
};
|
|
20
|
+
export declare type UserCategoryConfig = Array<Categories | CategoryConfig>;
|
|
21
|
+
export declare function mergeCategoriesConfig(userCategoriesConfig?: UserCategoryConfig): CategoriesConfig;
|