emoji-picker-react 3.6.1 → 4.0.0-rc.3

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.
Files changed (135) hide show
  1. package/LICENSE +17 -20
  2. package/README.md +129 -168
  3. package/dist/DomUtils/categoryNameFromDom.d.ts +1 -0
  4. package/dist/DomUtils/scrollCategoryIntoView.d.ts +1 -0
  5. package/dist/DomUtils/scrollTo.d.ts +1 -0
  6. package/dist/DomUtils/selectors.d.ts +12 -0
  7. package/dist/components/Layout/Flex.d.ts +14 -0
  8. package/dist/components/Layout/Relative.d.ts +7 -0
  9. package/dist/components/body/Body.d.ts +3 -0
  10. package/dist/components/body/EmojiCategory.d.ts +10 -0
  11. package/dist/components/body/EmojiList.d.ts +3 -0
  12. package/dist/components/body/EmojiVariationPicker.d.ts +3 -0
  13. package/dist/components/body/RecentlyUsed.d.ts +7 -0
  14. package/dist/components/context/ElementRefContext.d.ts +17 -0
  15. package/dist/components/context/PickerConfigContext.d.ts +8 -0
  16. package/dist/components/context/PickerContext.d.ts +21 -0
  17. package/dist/components/emoji/Emoji.d.ts +14 -0
  18. package/dist/components/footer/Preview.d.ts +7 -0
  19. package/dist/components/header/Header.d.ts +3 -0
  20. package/dist/components/header/Search.d.ts +3 -0
  21. package/dist/components/header/SkinTonePicker.d.ts +3 -0
  22. package/dist/components/main/PickerMain.d.ts +7 -0
  23. package/dist/components/navigation/CategoryNavigation.d.ts +3 -0
  24. package/dist/config/categoryConfig.d.ts +21 -0
  25. package/dist/config/cdnUrls.d.ts +2 -0
  26. package/dist/config/config.d.ts +26 -0
  27. package/dist/config/useConfig.d.ts +11 -0
  28. package/dist/data/emojis.d.ts +40 -0
  29. package/dist/data/groups.d.ts +2 -0
  30. package/dist/data/skinToneVariations.d.ts +3 -0
  31. package/dist/dataUtils/DataTypes.d.ts +8 -0
  32. package/dist/dataUtils/alphaNumericEmojiIndex.d.ts +4 -0
  33. package/dist/dataUtils/asEmoji.d.ts +2 -0
  34. package/dist/dataUtils/emojiSelectors.d.ts +15 -0
  35. package/dist/dataUtils/parseNativeEmoji.d.ts +1 -0
  36. package/dist/dataUtils/recentlyUsed.d.ts +11 -0
  37. package/dist/emoji-picker-react.cjs.development.css +13 -0
  38. package/dist/emoji-picker-react.cjs.development.js +7419 -0
  39. package/dist/emoji-picker-react.cjs.development.js.map +1 -0
  40. package/dist/emoji-picker-react.cjs.production.min.js +2 -0
  41. package/dist/emoji-picker-react.cjs.production.min.js.map +1 -0
  42. package/dist/emoji-picker-react.esm.js +7485 -0
  43. package/dist/emoji-picker-react.esm.js.map +1 -0
  44. package/dist/hooks/preloadEmoji.d.ts +4 -0
  45. package/dist/hooks/useActiveCategoryScrollDetection.d.ts +2 -0
  46. package/dist/hooks/useCloseAllOpenToggles.d.ts +4 -0
  47. package/dist/hooks/useEmojiElements.d.ts +1 -0
  48. package/dist/hooks/useEmojiMouseEnter.d.ts +3 -0
  49. package/dist/hooks/useFilter.d.ts +8 -0
  50. package/dist/hooks/useInitialLoad.d.ts +2 -0
  51. package/dist/hooks/useIsEmojiHidden.d.ts +2 -0
  52. package/dist/hooks/useIsSearchMode.d.ts +1 -0
  53. package/dist/hooks/useMouseDownHandlers.d.ts +2 -0
  54. package/dist/hooks/useOnScroll.d.ts +2 -0
  55. package/dist/index.d.ts +7 -0
  56. package/dist/index.js +8 -3
  57. package/dist/types/exposedTypes.d.ts +28 -0
  58. package/package.json +72 -52
  59. package/src/DomUtils/categoryNameFromDom.ts +3 -0
  60. package/src/DomUtils/scrollCategoryIntoView.ts +18 -0
  61. package/src/DomUtils/scrollTo.ts +11 -0
  62. package/src/DomUtils/selectors.ts +93 -0
  63. package/src/EmojiPickerReact.css +85 -0
  64. package/src/components/Layout/Flex.css +11 -0
  65. package/src/components/Layout/Flex.tsx +28 -0
  66. package/src/components/Layout/Relative.tsx +14 -0
  67. package/src/components/body/Body.css +6 -0
  68. package/src/components/body/Body.tsx +24 -0
  69. package/src/components/body/EmojiCategory.css +38 -0
  70. package/src/components/body/EmojiCategory.tsx +27 -0
  71. package/src/components/body/EmojiList.css +5 -0
  72. package/src/components/body/EmojiList.tsx +101 -0
  73. package/src/components/body/EmojiVariationPicker.css +65 -0
  74. package/src/components/body/EmojiVariationPicker.tsx +154 -0
  75. package/src/components/body/RecentlyUsed.tsx +50 -0
  76. package/src/components/body/svg/triangle.svg +11 -0
  77. package/src/components/context/ElementRefContext.tsx +61 -0
  78. package/src/components/context/PickerConfigContext.tsx +29 -0
  79. package/src/components/context/PickerContext.tsx +139 -0
  80. package/src/components/emoji/Emoji.css +44 -0
  81. package/src/components/emoji/Emoji.tsx +104 -0
  82. package/src/components/footer/Preview.css +14 -0
  83. package/src/components/footer/Preview.tsx +80 -0
  84. package/src/components/header/Header.css +4 -0
  85. package/src/components/header/Header.tsx +21 -0
  86. package/src/components/header/Search.css +72 -0
  87. package/src/components/header/Search.tsx +36 -0
  88. package/src/components/header/SkinTonePicker.css +86 -0
  89. package/src/components/header/SkinTonePicker.tsx +55 -0
  90. package/src/components/header/svg/magnifier.svg +13 -0
  91. package/src/components/header/svg/times.svg +33 -0
  92. package/src/components/main/PickerMain.css +11 -0
  93. package/src/components/main/PickerMain.tsx +42 -0
  94. package/src/components/navigation/CategoryNavigation.css +82 -0
  95. package/src/components/navigation/CategoryNavigation.tsx +32 -0
  96. package/src/components/navigation/svg/CategoryNav.svg +508 -0
  97. package/src/config/categoryConfig.ts +107 -0
  98. package/src/config/cdnUrls.ts +24 -0
  99. package/src/config/config.ts +50 -0
  100. package/src/config/useConfig.ts +52 -0
  101. package/src/data/emojis.ts +5350 -0
  102. package/src/data/groups.ts +12 -0
  103. package/src/data/skinToneVariations.ts +12 -0
  104. package/src/dataUtils/DataTypes.ts +10 -0
  105. package/src/dataUtils/alphaNumericEmojiIndex.ts +23 -0
  106. package/src/dataUtils/asEmoji.ts +5 -0
  107. package/src/dataUtils/emojiSelectors.ts +94 -0
  108. package/src/dataUtils/parseNativeEmoji.ts +6 -0
  109. package/src/dataUtils/recentlyUsed.ts +61 -0
  110. package/src/hooks/preloadEmoji.ts +29 -0
  111. package/src/hooks/useActiveCategoryScrollDetection.ts +46 -0
  112. package/src/hooks/useCloseAllOpenToggles.ts +26 -0
  113. package/src/hooks/useEmojiElements.ts +7 -0
  114. package/src/hooks/useEmojiMouseEnter.ts +59 -0
  115. package/src/hooks/useFilter.ts +142 -0
  116. package/src/hooks/useInitialLoad.ts +9 -0
  117. package/src/hooks/useIsEmojiHidden.ts +16 -0
  118. package/src/hooks/useIsSearchMode.ts +7 -0
  119. package/src/hooks/useMouseDownHandlers.ts +160 -0
  120. package/src/hooks/useOnScroll.ts +28 -0
  121. package/src/index.tsx +27 -0
  122. package/src/types/exposedTypes.ts +31 -0
  123. package/.babelrc +0 -30
  124. package/.eslintrc.js +0 -37
  125. package/.github/workflows/npmpublish.yml +0 -30
  126. package/.prettierignore +0 -2
  127. package/.storybook/addons.js +0 -2
  128. package/.storybook/config.js +0 -9
  129. package/assets/captured.gif +0 -0
  130. package/dist/index.js.LICENSE.txt +0 -5
  131. package/dist/index.js.map +0 -1
  132. package/dist/main.css +0 -206
  133. package/dist/main.css.map +0 -1
  134. package/emoji-picker-react.d.ts +0 -45
  135. package/webpack.config.js +0 -52
package/LICENSE CHANGED
@@ -1,24 +1,21 @@
1
- This is free and unencumbered software released into the public domain.
1
+ MIT License
2
2
 
3
- Anyone is free to copy, modify, publish, use, compile, sell, or
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
- In jurisdictions that recognize copyright laws, the author or authors
9
- of this software dedicate any and all copyright interest in the
10
- software to the public domain. We make this dedication for the benefit
11
- of the public at large and to the detriment of our heirs and
12
- successors. We intend this dedication to be an overt act of
13
- relinquishment in perpetuity of all present and future rights to this
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
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
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
- For more information, please refer to <http://unlicense.org/>
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
- # emoji-picker-react
1
+ # TSDX React w/ Storybook User Guide
2
2
 
3
- [Live Demo](https://stackblitz.com/edit/emoji-picker-react?file=index.js)
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
- ![Preview](/assets/captured.gif)
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
- ## What you need to know before installing?
7
+ > If you’re new to TypeScript and React, checkout [this handy cheatsheet](https://github.com/sw-yx/react-typescript-cheatsheet/)
8
8
 
9
- - Version 3 uses React hooks, which means you need to use React 16.8 or higher.
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
- ## Installation
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
- npm i emoji-picker-react
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
- Or
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
- yarn add emoji-picker-react
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
- ## New v3 features
31
+ This loads the stories from `./stories`.
26
32
 
27
- - Larger emoji library.
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
- ## Usage
35
+ ### Example
34
36
 
35
- Emoji-picker-react comes ready to use out of the box, zero conf needed. The only thing you need to do is add your own emoji click callback.
37
+ Then run the example inside another:
36
38
 
37
- ```js
38
- import React, { useState } from 'react';
39
- import Picker from 'emoji-picker-react';
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
- ### Accepted props
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
- | Name | Type | Default Value | Required? | Description |
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
- #### onEmojiClick Arguments
49
+ To run tests, use `npm test` or `yarn test`.
78
50
 
79
- `onEmojiClick` is a regular click handler for any of the emojis in the app. It takes two arguments:
51
+ ## Configuration
80
52
 
81
- 1. The click event.
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
- #### Setting a default skin tone modifier
55
+ ### Jest
90
56
 
91
- You may choose an alternative skin tone as the default skin tone to show for supported emojis (such as the 🤘 rocker hand emoji).
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
- The following are exported:
59
+ ### Bundle analysis
95
60
 
96
- - ✋ SKIN_TONE_NEUTRAL
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
- Use them like this:
63
+ #### Setup Files
104
64
 
105
- ```js
106
- import React, { useState } from 'react';
107
- import Picker, { SKIN_TONE_MEDIUM_DARK } from 'emoji-picker-react';
108
-
109
- const App = () => {
110
- const [chosenEmoji, setChosenEmoji] = useState(null);
111
-
112
- const onEmojiClick = (event, emojiObject) => {
113
- setChosenEmoji(emojiObject);
114
- };
115
-
116
- return (
117
- <div>
118
- <Picker onEmojiClick={onEmojiClick} skinTone={SKIN_TONE_MEDIUM_DARK} />
119
- </div>
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
- #### Customize Styling
88
+ #### React Testing Library
125
89
 
126
- You can override the style of emoji-picker-react with **pickerStyle** props.
90
+ We do not set up `react-testing-library` for you yet, we welcome contributions and documentation on this.
127
91
 
128
- ```js
129
- import React, { useState } from 'react';
130
- import Picker from 'emoji-picker-react';
131
-
132
- const App = () => {
133
- const [chosenEmoji, setChosenEmoji] = useState(null);
134
-
135
- const onEmojiClick = (event, emojiObject) => {
136
- setChosenEmoji(emojiObject);
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
- ## Internationalization
102
+ ### GitHub Actions
148
103
 
149
- The emoji names cannot be translated as they come from an external library, but it is possible to rename the categories.
150
- To rename the categories, pass a prop called `groupNames` which contains an object of group keys and their names as strings. For example:
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
- <Picker
154
- groupNames={{
155
- smileys_people: 'yellow faces',
156
- animals_nature: 'cute dogs and also trees',
157
- food_drink: 'milkshakes and more',
158
- travel_places: 'I love trains',
159
- activities: 'lets play a game',
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
- The complete list of keys is:
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
- - smileys_people
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
- ## Disabling categories
127
+ CJS, ESModules, and UMD module formats are supported.
181
128
 
182
- It is possible to disable certain categories by setting the `groupVisibility` prop. The groupVisibility prop takes an object of group names, and a boolean indicating whether they should be shown or not. For example, if you'd like to disable the flags category, set it to false like this:
129
+ The appropriate paths are configured in `package.json` and `dist/index.js` accordingly. Please report if any issues are found.
183
130
 
184
- ```js
185
- <Picker
186
- groupVisibility={{
187
- flags: false,
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
- The complete list of keys is:
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
- - smileys_people
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
- ## UI Customizations
162
+ We recommend using [np](https://github.com/sindresorhus/np).
205
163
 
206
- In general, UI customizations can be done directly via CSS. Descriptive classnames were added in order for you to be able to easily target whatever it is you want to change, and the markup is guaranteed to stay unchanged until the next major version (4).
164
+ ## Usage with Lerna
207
165
 
208
- # Troubleshooting
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
- ## How to use in Vite project
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
- For reference, if you only need to shim global, you can add
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
- ```html
215
- <script>
216
- window.global = window;
217
- </script>
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 your index.html
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,7 @@
1
+ import * as React from 'react';
2
+ declare type Props = Readonly<{
3
+ children: React.ReactNode;
4
+ className?: string;
5
+ }>;
6
+ export default function Relative({ children, className }: Props): JSX.Element;
7
+ export {};
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import './Body.css';
3
+ export declare function Body(): JSX.Element;
@@ -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,3 @@
1
+ /// <reference types="react" />
2
+ import './EmojiList.css';
3
+ export declare function EmojiList(): JSX.Element;
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import './EmojiVariationPicker.css';
3
+ export declare function EmojiVariationPicker(): JSX.Element;
@@ -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 { DataEmoji } from '../../dataUtils/DataTypes';
3
+ import { FilterDict } from '../../hooks/useFilter';
4
+ import { SkinTones } from '../../types/exposedTypes';
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 { DataEmoji } from '../../dataUtils/DataTypes';
3
+ import { EmojiStyle } from '../../types/exposedTypes';
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,7 @@
1
+ /// <reference types="react" />
2
+ import './Preview.css';
3
+ export declare function Preview(): JSX.Element | null;
4
+ export declare type HoveredEmoji = null | {
5
+ unified: string;
6
+ originalUnified: string;
7
+ };
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import './Header.css';
3
+ export declare function Header(): JSX.Element;
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import './Search.css';
3
+ export declare function Search(): JSX.Element;
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import './SkinTonePicker.css';
3
+ export declare function SkinTonePicker(): JSX.Element | null;
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ import './PickerMain.css';
3
+ declare type Props = Readonly<{
4
+ children: React.ReactNode;
5
+ }>;
6
+ export default function PickerMain({ children }: Props): JSX.Element;
7
+ export {};
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import './CategoryNavigation.css';
3
+ export declare function CategoryNavigation(): JSX.Element;
@@ -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;
@@ -0,0 +1,2 @@
1
+ import { EmojiStyle } from "../types/exposedTypes";
2
+ export declare function cdnUrl(emojiStyle: EmojiStyle): string;
@@ -0,0 +1,26 @@
1
+ import { EmojiClickData, EmojiStyle, SkinTones, Theme } from '../types/exposedTypes';
2
+ import { CategoriesConfig } from './categoryConfig';
3
+ export declare function mergeConfig(userConfig?: PickerConfig): {
4
+ categories: CategoriesConfig;
5
+ searchPlaceHolder: string;
6
+ defaultSkinTone: SkinTones;
7
+ skinTonesDisabled: boolean;
8
+ autoFocusSearch: boolean;
9
+ emojiStyle: EmojiStyle;
10
+ onEmojiClick: (event: MouseEvent, emoji: EmojiClickData) => void;
11
+ showPreview: boolean;
12
+ theme: Theme;
13
+ };
14
+ export declare function basePickerConfig(): PickerConfigInternal;
15
+ export declare type PickerConfigInternal = {
16
+ searchPlaceHolder: string;
17
+ defaultSkinTone: SkinTones;
18
+ skinTonesDisabled: boolean;
19
+ autoFocusSearch: boolean;
20
+ emojiStyle: EmojiStyle;
21
+ categories: CategoriesConfig;
22
+ onEmojiClick: (event: MouseEvent, emoji: EmojiClickData) => void;
23
+ showPreview: boolean;
24
+ theme: Theme;
25
+ };
26
+ export declare type PickerConfig = Partial<PickerConfigInternal>;