@dialpad/dialtone 9.34.4 → 9.34.6
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/README.md +28 -117
- package/dist/css/dialtone.css +2 -2
- package/dist/tokens/css/variables-dark.css +1 -1
- package/dist/tokens/css/variables-expressive-dark.css +1 -1
- package/dist/tokens/css/variables-expressive-light.css +1 -1
- package/dist/tokens/css/variables-expressive-sm-dark.css +1 -1
- package/dist/tokens/css/variables-expressive-sm-light.css +1 -1
- package/dist/tokens/css/variables-light.css +1 -1
- package/dist/tokens/css/variables-tmo-dark.css +1 -1
- package/dist/tokens/css/variables-tmo-light.css +1 -1
- package/dist/tokens/less/variables-dark.less +1 -1
- package/dist/tokens/less/variables-expressive-dark.less +1 -1
- package/dist/tokens/less/variables-expressive-light.less +1 -1
- package/dist/tokens/less/variables-expressive-sm-dark.less +1 -1
- package/dist/tokens/less/variables-expressive-sm-light.less +1 -1
- package/dist/tokens/less/variables-light.less +1 -1
- package/dist/tokens/less/variables-tmo-dark.less +1 -1
- package/dist/tokens/less/variables-tmo-light.less +1 -1
- package/dist/vue2/common/emoji.cjs +4 -1
- package/dist/vue2/common/emoji.cjs.map +1 -1
- package/dist/vue2/common/emoji.js +4 -1
- package/dist/vue2/common/emoji.js.map +1 -1
- package/dist/vue2/dialtone-vue.cjs +1 -0
- package/dist/vue2/dialtone-vue.cjs.map +1 -1
- package/dist/vue2/dialtone-vue.js +2 -1
- package/dist/vue2/lib/datepicker.cjs +4 -4
- package/dist/vue2/lib/datepicker.cjs.map +1 -1
- package/dist/vue2/lib/datepicker.js +4 -4
- package/dist/vue2/lib/datepicker.js.map +1 -1
- package/dist/vue2/lib/rich-text-editor.cjs +22 -9
- package/dist/vue2/lib/rich-text-editor.cjs.map +1 -1
- package/dist/vue2/lib/rich-text-editor.js +22 -9
- package/dist/vue2/lib/rich-text-editor.js.map +1 -1
- package/dist/vue2/types/common/emoji/index.d.ts +11 -2
- package/dist/vue2/types/common/emoji/index.d.ts.map +1 -1
- package/dist/vue2/types/components/rich_text_editor/extensions/emoji/emoji.d.ts +0 -1
- package/dist/vue2/types/components/rich_text_editor/extensions/emoji/emoji.d.ts.map +1 -1
- package/dist/vue2/types/components/rich_text_editor/rich_text_editor.vue.d.ts +1 -1
- package/dist/vue2/types/components/rich_text_editor/rich_text_editor.vue.d.ts.map +1 -1
- package/dist/vue3/common/emoji.cjs +4 -1
- package/dist/vue3/common/emoji.cjs.map +1 -1
- package/dist/vue3/common/emoji.js +4 -1
- package/dist/vue3/common/emoji.js.map +1 -1
- package/dist/vue3/dialtone-vue.cjs +1 -0
- package/dist/vue3/dialtone-vue.cjs.map +1 -1
- package/dist/vue3/dialtone-vue.js +2 -1
- package/dist/vue3/lib/datepicker.cjs +8 -4
- package/dist/vue3/lib/datepicker.cjs.map +1 -1
- package/dist/vue3/lib/datepicker.js +8 -4
- package/dist/vue3/lib/datepicker.js.map +1 -1
- package/dist/vue3/lib/message-input.cjs +32 -3
- package/dist/vue3/lib/message-input.cjs.map +1 -1
- package/dist/vue3/lib/message-input.js +32 -3
- package/dist/vue3/lib/message-input.js.map +1 -1
- package/dist/vue3/lib/rich-text-editor.cjs +271 -35
- package/dist/vue3/lib/rich-text-editor.cjs.map +1 -1
- package/dist/vue3/lib/rich-text-editor.js +272 -36
- package/dist/vue3/lib/rich-text-editor.js.map +1 -1
- package/dist/vue3/types/common/emoji/index.d.ts +1 -0
- package/dist/vue3/types/common/emoji/index.d.ts.map +1 -1
- package/dist/vue3/types/components/rich_text_editor/extensions/emoji/emoji.d.ts +0 -1
- package/dist/vue3/types/components/rich_text_editor/extensions/emoji/emoji.d.ts.map +1 -1
- package/dist/vue3/types/components/rich_text_editor/extensions/slash_command/SlashCommandComponent.vue.d.ts +73 -0
- package/dist/vue3/types/components/rich_text_editor/extensions/slash_command/SlashCommandComponent.vue.d.ts.map +1 -0
- package/dist/vue3/types/components/rich_text_editor/extensions/slash_command/SlashCommandSuggestion.vue.d.ts +17 -0
- package/dist/vue3/types/components/rich_text_editor/extensions/slash_command/SlashCommandSuggestion.vue.d.ts.map +1 -0
- package/dist/vue3/types/components/rich_text_editor/extensions/slash_command/slash_command.d.ts +2 -0
- package/dist/vue3/types/components/rich_text_editor/extensions/slash_command/slash_command.d.ts.map +1 -0
- package/dist/vue3/types/components/rich_text_editor/extensions/slash_command/suggestion.d.ts +12 -0
- package/dist/vue3/types/components/rich_text_editor/extensions/slash_command/suggestion.d.ts.map +1 -0
- package/dist/vue3/types/components/rich_text_editor/rich_text_editor.vue.d.ts +38 -1
- package/dist/vue3/types/components/rich_text_editor/rich_text_editor.vue.d.ts.map +1 -1
- package/dist/vue3/types/components/rich_text_editor/slash_command_suggestion.d.ts +15 -0
- package/dist/vue3/types/components/rich_text_editor/slash_command_suggestion.d.ts.map +1 -0
- package/dist/vue3/types/recipes/conversation_view/message_input/message_input.vue.d.ts +38 -1
- package/dist/vue3/types/recipes/conversation_view/message_input/message_input.vue.d.ts.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -11,13 +11,13 @@ All packages of the monorepo are combined into a single Dialtone package for eas
|
|
|
11
11
|
#### Vue 3
|
|
12
12
|
|
|
13
13
|
```shell
|
|
14
|
-
npm install @dialpad/dialtone@
|
|
14
|
+
npm install @dialpad/dialtone@latest @tiptap/vue-3
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
#### Vue 2
|
|
18
18
|
|
|
19
19
|
```shell
|
|
20
|
-
npm install @dialpad/dialtone@
|
|
20
|
+
npm install @dialpad/dialtone@latest @linusborg/vue-simple-portal @tiptap/vue-2
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
### Import packages:
|
|
@@ -100,6 +100,32 @@ import { DtButton } from "@dialpad/dialtone/vue3"
|
|
|
100
100
|
import { DtButton } from "@dialpad/dialtone/vue3/lib/button"
|
|
101
101
|
```
|
|
102
102
|
|
|
103
|
+
#### Dialtone Tokens
|
|
104
|
+
|
|
105
|
+
Dialtone tokens doesn't have a default export, so you need to access
|
|
106
|
+
the files directly as following:
|
|
107
|
+
|
|
108
|
+
- CSS
|
|
109
|
+
|
|
110
|
+
```css
|
|
111
|
+
@import "@dialpad/dialtone/tokens/variables-light.css" // Light tokens
|
|
112
|
+
@import "@dialpad/dialtone/tokens/variables-dark.css" // Dark tokens
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
- LESS
|
|
116
|
+
|
|
117
|
+
```less
|
|
118
|
+
@import "@dialpad/dialtone/tokens/variables-light.less" // Light tokens
|
|
119
|
+
@import "@dialpad/dialtone/tokens/variables-dark.less" // Dark tokens
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
- JSON
|
|
123
|
+
|
|
124
|
+
```js
|
|
125
|
+
import "@dialpad/dialtone/tokens/tokens-light.json" // Light tokens
|
|
126
|
+
import "@dialpad/dialtone/tokens/tokens-dark.json" // Dark tokens
|
|
127
|
+
```
|
|
128
|
+
|
|
103
129
|
## About this repo
|
|
104
130
|
|
|
105
131
|
The @dialpad/dialtone repository is a monorepo composed of Dialtone NPM packages and apps.
|
|
@@ -370,118 +396,3 @@ This will trigger the [release action](.github/workflows/release.yml), release c
|
|
|
370
396
|
|
|
371
397
|
1. Run the `nx release` on selected packages (all if `package` is empty).
|
|
372
398
|
2. An [action](https://github.com/dialpad/dialtone/actions/workflows/publish.yml) will publish the packages with its corresponding tag.
|
|
373
|
-
|
|
374
|
-
## Usage
|
|
375
|
-
|
|
376
|
-
### Install it via NPM:
|
|
377
|
-
|
|
378
|
-
#### Vue 3
|
|
379
|
-
|
|
380
|
-
```shell
|
|
381
|
-
npm install @dialpad/dialtone@next @tiptap/vue-3
|
|
382
|
-
```
|
|
383
|
-
|
|
384
|
-
#### Vue 2
|
|
385
|
-
|
|
386
|
-
```shell
|
|
387
|
-
npm install @dialpad/dialtone@next @linusborg/vue-simple-portal @tiptap/vue-2
|
|
388
|
-
```
|
|
389
|
-
|
|
390
|
-
### Import packages:
|
|
391
|
-
|
|
392
|
-
#### Dialtone CSS
|
|
393
|
-
|
|
394
|
-
- CSS
|
|
395
|
-
|
|
396
|
-
```css
|
|
397
|
-
@import "@dialpad/dialtone/css";
|
|
398
|
-
```
|
|
399
|
-
|
|
400
|
-
- Javascript
|
|
401
|
-
|
|
402
|
-
```js
|
|
403
|
-
import "@dialpad/dialtone/css";
|
|
404
|
-
```
|
|
405
|
-
|
|
406
|
-
#### Dialtone eslint-plugin
|
|
407
|
-
|
|
408
|
-
```js
|
|
409
|
-
import dialtone from "@dialpad/dialtone/eslint-plugin"
|
|
410
|
-
```
|
|
411
|
-
|
|
412
|
-
#### Dialtone icons
|
|
413
|
-
|
|
414
|
-
- Importing for Vue 2:
|
|
415
|
-
|
|
416
|
-
```js
|
|
417
|
-
// Named import
|
|
418
|
-
import { DtIconArrowUp } from '@dialpad/dialtone-icons/vue2';
|
|
419
|
-
|
|
420
|
-
// Default import (Prefered if using webpack as it is tree-shakeable by default)
|
|
421
|
-
import DtIconArrowUp from '@dialpad/dialtone-icons/vue2/arrow-up';
|
|
422
|
-
```
|
|
423
|
-
|
|
424
|
-
- Importing for Vue 3:
|
|
425
|
-
|
|
426
|
-
```js
|
|
427
|
-
// Named import
|
|
428
|
-
import { DtIconArrowUp } from '@dialpad/dialtone-icons/vue3';
|
|
429
|
-
|
|
430
|
-
// Default import (Prefered if using webpack as it is tree-shakeable by default)
|
|
431
|
-
import DtIconArrowUp from '@dialpad/dialtone-icons/vue3/arrow-up';
|
|
432
|
-
```
|
|
433
|
-
|
|
434
|
-
- Importing json files
|
|
435
|
-
|
|
436
|
-
```js
|
|
437
|
-
import keywords from '@dialpad/dialtone-icons/keywords.json';
|
|
438
|
-
import iconsList from '@dialpad/dialtone-icons/icons.json';
|
|
439
|
-
```
|
|
440
|
-
|
|
441
|
-
#### Dialtone Vue
|
|
442
|
-
|
|
443
|
-
- Vue 2
|
|
444
|
-
|
|
445
|
-
```js
|
|
446
|
-
// Named import
|
|
447
|
-
import { DtButton } from "@dialpad/dialtone/vue2"
|
|
448
|
-
|
|
449
|
-
// Default import (Prefered if using webpack as it is tree-shakeable by default)
|
|
450
|
-
import { DtButton } from "@dialpad/dialtone/vue2/lib/button"
|
|
451
|
-
```
|
|
452
|
-
|
|
453
|
-
- Vue 3
|
|
454
|
-
|
|
455
|
-
```js
|
|
456
|
-
// Named import
|
|
457
|
-
import { DtButton } from "@dialpad/dialtone/vue3"
|
|
458
|
-
|
|
459
|
-
// Default import (Prefered if using webpack as it is tree-shakeable by default)
|
|
460
|
-
import { DtButton } from "@dialpad/dialtone/vue3/lib/button"
|
|
461
|
-
```
|
|
462
|
-
|
|
463
|
-
#### Dialtone Tokens
|
|
464
|
-
|
|
465
|
-
Dialtone tokens doesn't have a default export, so you need to access
|
|
466
|
-
the files directly as following:
|
|
467
|
-
|
|
468
|
-
- CSS
|
|
469
|
-
|
|
470
|
-
```css
|
|
471
|
-
@import "@dialpad/dialtone/tokens/variables-light.css" // Light tokens
|
|
472
|
-
@import "@dialpad/dialtone/tokens/variables-dark.css" // Dark tokens
|
|
473
|
-
```
|
|
474
|
-
|
|
475
|
-
- LESS
|
|
476
|
-
|
|
477
|
-
```less
|
|
478
|
-
@import "@dialpad/dialtone/tokens/variables-light.less" // Light tokens
|
|
479
|
-
@import "@dialpad/dialtone/tokens/variables-dark.less" // Dark tokens
|
|
480
|
-
```
|
|
481
|
-
|
|
482
|
-
- JSON
|
|
483
|
-
|
|
484
|
-
```js
|
|
485
|
-
import "@dialpad/dialtone/tokens/tokens-light.json" // Light tokens
|
|
486
|
-
import "@dialpad/dialtone/tokens/tokens-dark.json" // Dark tokens
|
|
487
|
-
```
|
package/dist/css/dialtone.css
CHANGED
|
@@ -7485,7 +7485,7 @@ body {
|
|
|
7485
7485
|
}
|
|
7486
7486
|
/**
|
|
7487
7487
|
* Do not edit directly
|
|
7488
|
-
* Generated on
|
|
7488
|
+
* Generated on Wed, 15 May 2024 21:42:14 GMT
|
|
7489
7489
|
*/
|
|
7490
7490
|
|
|
7491
7491
|
.dialtone-theme-light {
|
|
@@ -8302,7 +8302,7 @@ body {
|
|
|
8302
8302
|
|
|
8303
8303
|
/**
|
|
8304
8304
|
* Do not edit directly
|
|
8305
|
-
* Generated on
|
|
8305
|
+
* Generated on Wed, 15 May 2024 21:42:14 GMT
|
|
8306
8306
|
*/
|
|
8307
8307
|
|
|
8308
8308
|
.dialtone-theme-dark {
|
|
@@ -10,6 +10,7 @@ exports.emojiFileExtensionSmall = ".png";
|
|
|
10
10
|
exports.emojiImageUrlLarge = defaultEmojiAssetUrl;
|
|
11
11
|
exports.emojiFileExtensionLarge = ".png";
|
|
12
12
|
const emojiJson = emojiJsonLocal;
|
|
13
|
+
const emojiShortCodeRegex = new RegExp("(^| |(?<=:))(:\\w+:)", "g");
|
|
13
14
|
function getEmojiData() {
|
|
14
15
|
return emojiJson;
|
|
15
16
|
}
|
|
@@ -121,6 +122,7 @@ function stringToUnicode(str) {
|
|
|
121
122
|
return result;
|
|
122
123
|
}
|
|
123
124
|
function codeToEmojiData(code) {
|
|
125
|
+
code = code == null ? void 0 : code.trim();
|
|
124
126
|
if (code.startsWith(":") && code.endsWith(":")) {
|
|
125
127
|
return shortcodeToEmojiData(code);
|
|
126
128
|
} else {
|
|
@@ -132,7 +134,7 @@ function codeToEmojiData(code) {
|
|
|
132
134
|
}
|
|
133
135
|
}
|
|
134
136
|
function findShortCodes(textContent) {
|
|
135
|
-
const shortcodes = textContent.match(
|
|
137
|
+
const shortcodes = (textContent.match(emojiShortCodeRegex) || []).map((code) => code.trim());
|
|
136
138
|
return filterValidShortCodes(shortcodes);
|
|
137
139
|
}
|
|
138
140
|
function filterValidShortCodes(shortcodes) {
|
|
@@ -147,6 +149,7 @@ function findEmojis(textContent) {
|
|
|
147
149
|
exports.codeToEmojiData = codeToEmojiData;
|
|
148
150
|
exports.defaultEmojiAssetUrl = defaultEmojiAssetUrl;
|
|
149
151
|
exports.emojiJson = emojiJson;
|
|
152
|
+
exports.emojiShortCodeRegex = emojiShortCodeRegex;
|
|
150
153
|
exports.emojiVersion = emojiVersion;
|
|
151
154
|
exports.filterValidShortCodes = filterValidShortCodes;
|
|
152
155
|
exports.findEmojis = findEmojis;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emoji.cjs","sources":["../../common/emoji/index.js"],"sourcesContent":["import emojiRegex from 'emoji-regex';\nimport emojiJsonLocal from 'emoji-toolkit/emoji_strategy.json';\n\nexport const emojiVersion = '8.0';\nexport const defaultEmojiAssetUrl = 'https://cdn.jsdelivr.net/joypixels/assets/' + emojiVersion + '/png/unicode/32/';\nexport let customEmojiAssetUrl = null;\n\n// Used for emoji 16px and smaller\nexport let emojiImageUrlSmall = defaultEmojiAssetUrl;\nexport let emojiFileExtensionSmall = '.png';\n\n// Used for emoji larger than 16px\nexport let emojiImageUrlLarge = defaultEmojiAssetUrl;\nexport let emojiFileExtensionLarge = '.png';\n\nexport const emojiJson = emojiJsonLocal;\n\nexport function getEmojiData () {\n return emojiJson;\n}\n\nexport function setEmojiAssetUrlSmall (url, fileExtension = '.png') {\n if (!url.endsWith('/')) {\n url = url + '/';\n }\n emojiImageUrlSmall = url;\n emojiFileExtensionSmall = fileExtension;\n}\n\nexport function setEmojiAssetUrlLarge (url, fileExtension = '.svg') {\n if (!url.endsWith('/')) {\n url = url + '/';\n }\n emojiImageUrlLarge = url;\n emojiFileExtensionLarge = fileExtension;\n}\n\nexport function setCustomEmojiUrl (url) {\n customEmojiAssetUrl = url;\n}\n\nexport function setCustomEmojiJson (json) {\n validateCustomEmojiJson(json);\n}\n\n/**\n * Validate custom emoji json\n */\nexport function validateCustomEmojiJson (json) {\n const customEmojiProps = ['extension', 'custom'];\n const customEmojiRequiredProps = [\n 'name',\n 'category',\n 'shortname',\n 'extension',\n 'custom',\n ];\n\n /**\n * Update single emoji properties.\n * If the property exists in emojiData, it'll add the values if the property is an array, otherwise will overwrite.\n * If not exists, will add the property to the emojiData object.\n */\n const _updateNativeEmojiData = (emojiData, propName, propValue) => {\n if (emojiData[propName] === undefined) {\n if (!customEmojiProps.includes(propName)) {\n return;\n }\n\n // new property to add\n emojiData[propName] = propValue;\n } else {\n if (Array.isArray(emojiData[propName])) {\n emojiData[propName] = emojiData[propName].concat(propValue);\n } else {\n emojiData[propName] = propValue;\n }\n }\n };\n\n Object.entries(json).forEach((item) => {\n const [customEmojiKey, customEmojiValue] = item;\n\n if (customEmojiKey in emojiJson) {\n // custom emoji exists in emoji json which means to update some data in the native emoji\n const emojiData = emojiJson[customEmojiKey];\n\n for (const customEmojiPropertyName in customEmojiValue) {\n const customEmojiPropertyValue = customEmojiValue[customEmojiPropertyName];\n\n _updateNativeEmojiData(emojiData, customEmojiPropertyName, customEmojiPropertyValue);\n }\n } else {\n // new custom emoji\n const _validateRequiredProps = () =>\n customEmojiRequiredProps.every((val) => {\n return customEmojiValue[val] !== undefined;\n });\n\n if (_validateRequiredProps()) {\n emojiJson[customEmojiKey] = customEmojiValue;\n } else {\n console.error(\n 'The following custom emoji doesn\\'t contain the required properties:',\n customEmojiValue,\n );\n }\n }\n });\n}\n\n// recursively searches the emoji data object containing data for all emojis\n// and returns the object with the specified shortcode.\nexport function shortcodeToEmojiData (shortcode) {\n // eslint-disable-next-line complexity\n function f (o, key) {\n if (!o || typeof o !== 'object') {\n return;\n }\n if ('shortname' in o) {\n if (o.shortname === shortcode || o.shortname_alternates.includes(shortcode)) {\n o.key = key;\n reference = o;\n return true;\n }\n }\n Object.keys(o).some(function (k) {\n return f(o[k], k);\n });\n }\n\n let reference;\n f(getEmojiData(), null);\n return reference;\n}\n\n// Takes in an emoji unicode character(s) and converts it to an emoji string in the format the emoji data object expects\n// as a key. There can be multiple unicode characters in an emoji to denote the emoji itself, skin tone, gender\n// and such. Note that this function does NOT return variation selectors (fe0f) or zero width joiners (200d), as these\n// are not included as part of the key in the emoji.json.\n//\n// Example:\n// return value for smile emoji (no skin tone): 1f600\n// return value for left facing fist (light skin tone): 1f91b-1f3fb\nexport function unicodeToString (emoji) {\n let key = '';\n for (const codePoint of emoji) {\n const codepoint = codePoint.codePointAt(0).toString(16).padStart(4, '0');\n\n // skip 200d and fe0f as these are not included in emoji_strategy.json keys\n if (['200d', 'fe0f'].includes(codepoint)) continue;\n if (key !== '') { key = key + '-'; }\n key = key + codepoint;\n }\n return key;\n}\n\n// Takes in unicode in string form ex: '1f91b-1f3fb' and converts it to an actual unicode character.\nexport function stringToUnicode (str) {\n const uChars = str.split('-');\n let result = '';\n uChars.forEach((uChar) => {\n result = result + String.fromCodePoint(parseInt(uChar, 16));\n });\n return result;\n}\n\n// Takes in a code (which could be unicode or shortcode) and returns the emoji data for it.\nexport function codeToEmojiData (code) {\n if (code.startsWith(':') && code.endsWith(':')) {\n return shortcodeToEmojiData(code);\n } else {\n const unicodeString = unicodeToString(code);\n\n const result = emojiJson[unicodeString];\n if (result) result.key = unicodeString;\n return result;\n }\n}\n\n// Finds every shortcode in slot text\n// filters only the existing codes in emojiJson\n// removes duplicates.\n// @returns {string[]}\nexport function findShortCodes (textContent) {\n const shortcodes = textContent.match(
|
|
1
|
+
{"version":3,"file":"emoji.cjs","sources":["../../common/emoji/index.js"],"sourcesContent":["import emojiRegex from 'emoji-regex';\nimport emojiJsonLocal from 'emoji-toolkit/emoji_strategy.json';\n\nexport const emojiVersion = '8.0';\nexport const defaultEmojiAssetUrl = 'https://cdn.jsdelivr.net/joypixels/assets/' + emojiVersion + '/png/unicode/32/';\nexport let customEmojiAssetUrl = null;\n\n// Used for emoji 16px and smaller\nexport let emojiImageUrlSmall = defaultEmojiAssetUrl;\nexport let emojiFileExtensionSmall = '.png';\n\n// Used for emoji larger than 16px\nexport let emojiImageUrlLarge = defaultEmojiAssetUrl;\nexport let emojiFileExtensionLarge = '.png';\n\nexport const emojiJson = emojiJsonLocal;\n\nexport const emojiShortCodeRegex = /(^| |(?<=:))(:\\w+:)/g;\n\nexport function getEmojiData () {\n return emojiJson;\n}\n\nexport function setEmojiAssetUrlSmall (url, fileExtension = '.png') {\n if (!url.endsWith('/')) {\n url = url + '/';\n }\n emojiImageUrlSmall = url;\n emojiFileExtensionSmall = fileExtension;\n}\n\nexport function setEmojiAssetUrlLarge (url, fileExtension = '.svg') {\n if (!url.endsWith('/')) {\n url = url + '/';\n }\n emojiImageUrlLarge = url;\n emojiFileExtensionLarge = fileExtension;\n}\n\nexport function setCustomEmojiUrl (url) {\n customEmojiAssetUrl = url;\n}\n\nexport function setCustomEmojiJson (json) {\n validateCustomEmojiJson(json);\n}\n\n/**\n * Validate custom emoji json\n */\nexport function validateCustomEmojiJson (json) {\n const customEmojiProps = ['extension', 'custom'];\n const customEmojiRequiredProps = [\n 'name',\n 'category',\n 'shortname',\n 'extension',\n 'custom',\n ];\n\n /**\n * Update single emoji properties.\n * If the property exists in emojiData, it'll add the values if the property is an array, otherwise will overwrite.\n * If not exists, will add the property to the emojiData object.\n */\n const _updateNativeEmojiData = (emojiData, propName, propValue) => {\n if (emojiData[propName] === undefined) {\n if (!customEmojiProps.includes(propName)) {\n return;\n }\n\n // new property to add\n emojiData[propName] = propValue;\n } else {\n if (Array.isArray(emojiData[propName])) {\n emojiData[propName] = emojiData[propName].concat(propValue);\n } else {\n emojiData[propName] = propValue;\n }\n }\n };\n\n Object.entries(json).forEach((item) => {\n const [customEmojiKey, customEmojiValue] = item;\n\n if (customEmojiKey in emojiJson) {\n // custom emoji exists in emoji json which means to update some data in the native emoji\n const emojiData = emojiJson[customEmojiKey];\n\n for (const customEmojiPropertyName in customEmojiValue) {\n const customEmojiPropertyValue = customEmojiValue[customEmojiPropertyName];\n\n _updateNativeEmojiData(emojiData, customEmojiPropertyName, customEmojiPropertyValue);\n }\n } else {\n // new custom emoji\n const _validateRequiredProps = () =>\n customEmojiRequiredProps.every((val) => {\n return customEmojiValue[val] !== undefined;\n });\n\n if (_validateRequiredProps()) {\n emojiJson[customEmojiKey] = customEmojiValue;\n } else {\n console.error(\n 'The following custom emoji doesn\\'t contain the required properties:',\n customEmojiValue,\n );\n }\n }\n });\n}\n\n// recursively searches the emoji data object containing data for all emojis\n// and returns the object with the specified shortcode.\nexport function shortcodeToEmojiData (shortcode) {\n // eslint-disable-next-line complexity\n function f (o, key) {\n if (!o || typeof o !== 'object') {\n return;\n }\n if ('shortname' in o) {\n if (o.shortname === shortcode || o.shortname_alternates.includes(shortcode)) {\n o.key = key;\n reference = o;\n return true;\n }\n }\n Object.keys(o).some(function (k) {\n return f(o[k], k);\n });\n }\n\n let reference;\n f(getEmojiData(), null);\n return reference;\n}\n\n// Takes in an emoji unicode character(s) and converts it to an emoji string in the format the emoji data object expects\n// as a key. There can be multiple unicode characters in an emoji to denote the emoji itself, skin tone, gender\n// and such. Note that this function does NOT return variation selectors (fe0f) or zero width joiners (200d), as these\n// are not included as part of the key in the emoji.json.\n//\n// Example:\n// return value for smile emoji (no skin tone): 1f600\n// return value for left facing fist (light skin tone): 1f91b-1f3fb\nexport function unicodeToString (emoji) {\n let key = '';\n for (const codePoint of emoji) {\n const codepoint = codePoint.codePointAt(0).toString(16).padStart(4, '0');\n\n // skip 200d and fe0f as these are not included in emoji_strategy.json keys\n if (['200d', 'fe0f'].includes(codepoint)) continue;\n if (key !== '') { key = key + '-'; }\n key = key + codepoint;\n }\n return key;\n}\n\n// Takes in unicode in string form ex: '1f91b-1f3fb' and converts it to an actual unicode character.\nexport function stringToUnicode (str) {\n const uChars = str.split('-');\n let result = '';\n uChars.forEach((uChar) => {\n result = result + String.fromCodePoint(parseInt(uChar, 16));\n });\n return result;\n}\n\n// Takes in a code (which could be unicode or shortcode) and returns the emoji data for it.\nexport function codeToEmojiData (code) {\n code = code?.trim();\n if (code.startsWith(':') && code.endsWith(':')) {\n return shortcodeToEmojiData(code);\n } else {\n const unicodeString = unicodeToString(code);\n\n const result = emojiJson[unicodeString];\n if (result) result.key = unicodeString;\n return result;\n }\n}\n\n// Finds every shortcode in slot text\n// filters only the existing codes in emojiJson\n// removes duplicates.\n// @returns {string[]}\nexport function findShortCodes (textContent) {\n const shortcodes = (\n textContent.match(emojiShortCodeRegex) || []\n ).map(code => code.trim());\n return filterValidShortCodes(shortcodes);\n}\n\nexport function filterValidShortCodes (shortcodes) {\n const filtered = shortcodes ? shortcodes.filter(code => shortcodeToEmojiData(code)) : [];\n return new Set(filtered);\n}\n\n// Finds every emoji in slot text\n// removes duplicates\n// @returns {string[]}\nexport function findEmojis (textContent) {\n const matches = [...textContent.matchAll(emojiRegex())];\n const emojis = matches.length ? matches.map(match => match[0]) : [];\n return new Set(emojis);\n}\n"],"names":["customEmojiAssetUrl","emojiImageUrlSmall","emojiFileExtensionSmall","emojiImageUrlLarge","emojiFileExtensionLarge"],"mappings":";;;;AAGY,MAAC,eAAe;AAChB,MAAC,uBAAuB,+CAA+C,eAAe;AACvFA,QAAAA,sBAAsB;AAGtBC,QAAAA,qBAAqB;AACrBC,QAAAA,0BAA0B;AAG1BC,QAAAA,qBAAqB;AACrBC,QAAAA,0BAA0B;AAEzB,MAAC,YAAY;AAEb,MAAC,sBAAsB,WAAuB,wBAAA,GAAA;AAEnD,SAAS,eAAgB;AAC9B,SAAO;AACT;AAEO,SAAS,sBAAuB,KAAK,gBAAgB,QAAQ;AAClE,MAAI,CAAC,IAAI,SAAS,GAAG,GAAG;AACtB,UAAM,MAAM;AAAA,EACb;AACDH,UAAAA,qBAAqB;AACrBC,UAAAA,0BAA0B;AAC5B;AAEO,SAAS,sBAAuB,KAAK,gBAAgB,QAAQ;AAClE,MAAI,CAAC,IAAI,SAAS,GAAG,GAAG;AACtB,UAAM,MAAM;AAAA,EACb;AACDC,UAAAA,qBAAqB;AACrBC,UAAAA,0BAA0B;AAC5B;AAEO,SAAS,kBAAmB,KAAK;AACtCJ,UAAAA,sBAAsB;AACxB;AAEO,SAAS,mBAAoB,MAAM;AACxC,0BAAwB,IAAI;AAC9B;AAKO,SAAS,wBAAyB,MAAM;AAC7C,QAAM,mBAAmB,CAAC,aAAa,QAAQ;AAC/C,QAAM,2BAA2B;AAAA,IAC/B;AAAA,IACA;AAAA,IACA;AAAA,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SAAS,WAAY,aAAa;AACvC,QAAM,UAAU,CAAC,GAAG,YAAY,SAAS,WAAY,CAAA,CAAC;AACtD,QAAM,SAAS,QAAQ,SAAS,QAAQ,IAAI,WAAS,MAAM,CAAC,CAAC,IAAI;AACjE,SAAO,IAAI,IAAI,MAAM;AACvB;;;;;;;;;;;;;;;;;;"}
|
|
@@ -8,6 +8,7 @@ let emojiFileExtensionSmall = ".png";
|
|
|
8
8
|
let emojiImageUrlLarge = defaultEmojiAssetUrl;
|
|
9
9
|
let emojiFileExtensionLarge = ".png";
|
|
10
10
|
const emojiJson = emojiJsonLocal;
|
|
11
|
+
const emojiShortCodeRegex = new RegExp("(^| |(?<=:))(:\\w+:)", "g");
|
|
11
12
|
function getEmojiData() {
|
|
12
13
|
return emojiJson;
|
|
13
14
|
}
|
|
@@ -119,6 +120,7 @@ function stringToUnicode(str) {
|
|
|
119
120
|
return result;
|
|
120
121
|
}
|
|
121
122
|
function codeToEmojiData(code) {
|
|
123
|
+
code = code == null ? void 0 : code.trim();
|
|
122
124
|
if (code.startsWith(":") && code.endsWith(":")) {
|
|
123
125
|
return shortcodeToEmojiData(code);
|
|
124
126
|
} else {
|
|
@@ -130,7 +132,7 @@ function codeToEmojiData(code) {
|
|
|
130
132
|
}
|
|
131
133
|
}
|
|
132
134
|
function findShortCodes(textContent) {
|
|
133
|
-
const shortcodes = textContent.match(
|
|
135
|
+
const shortcodes = (textContent.match(emojiShortCodeRegex) || []).map((code) => code.trim());
|
|
134
136
|
return filterValidShortCodes(shortcodes);
|
|
135
137
|
}
|
|
136
138
|
function filterValidShortCodes(shortcodes) {
|
|
@@ -151,6 +153,7 @@ export {
|
|
|
151
153
|
emojiImageUrlLarge,
|
|
152
154
|
emojiImageUrlSmall,
|
|
153
155
|
emojiJson,
|
|
156
|
+
emojiShortCodeRegex,
|
|
154
157
|
emojiVersion,
|
|
155
158
|
filterValidShortCodes,
|
|
156
159
|
findEmojis,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emoji.js","sources":["../../common/emoji/index.js"],"sourcesContent":["import emojiRegex from 'emoji-regex';\nimport emojiJsonLocal from 'emoji-toolkit/emoji_strategy.json';\n\nexport const emojiVersion = '8.0';\nexport const defaultEmojiAssetUrl = 'https://cdn.jsdelivr.net/joypixels/assets/' + emojiVersion + '/png/unicode/32/';\nexport let customEmojiAssetUrl = null;\n\n// Used for emoji 16px and smaller\nexport let emojiImageUrlSmall = defaultEmojiAssetUrl;\nexport let emojiFileExtensionSmall = '.png';\n\n// Used for emoji larger than 16px\nexport let emojiImageUrlLarge = defaultEmojiAssetUrl;\nexport let emojiFileExtensionLarge = '.png';\n\nexport const emojiJson = emojiJsonLocal;\n\nexport function getEmojiData () {\n return emojiJson;\n}\n\nexport function setEmojiAssetUrlSmall (url, fileExtension = '.png') {\n if (!url.endsWith('/')) {\n url = url + '/';\n }\n emojiImageUrlSmall = url;\n emojiFileExtensionSmall = fileExtension;\n}\n\nexport function setEmojiAssetUrlLarge (url, fileExtension = '.svg') {\n if (!url.endsWith('/')) {\n url = url + '/';\n }\n emojiImageUrlLarge = url;\n emojiFileExtensionLarge = fileExtension;\n}\n\nexport function setCustomEmojiUrl (url) {\n customEmojiAssetUrl = url;\n}\n\nexport function setCustomEmojiJson (json) {\n validateCustomEmojiJson(json);\n}\n\n/**\n * Validate custom emoji json\n */\nexport function validateCustomEmojiJson (json) {\n const customEmojiProps = ['extension', 'custom'];\n const customEmojiRequiredProps = [\n 'name',\n 'category',\n 'shortname',\n 'extension',\n 'custom',\n ];\n\n /**\n * Update single emoji properties.\n * If the property exists in emojiData, it'll add the values if the property is an array, otherwise will overwrite.\n * If not exists, will add the property to the emojiData object.\n */\n const _updateNativeEmojiData = (emojiData, propName, propValue) => {\n if (emojiData[propName] === undefined) {\n if (!customEmojiProps.includes(propName)) {\n return;\n }\n\n // new property to add\n emojiData[propName] = propValue;\n } else {\n if (Array.isArray(emojiData[propName])) {\n emojiData[propName] = emojiData[propName].concat(propValue);\n } else {\n emojiData[propName] = propValue;\n }\n }\n };\n\n Object.entries(json).forEach((item) => {\n const [customEmojiKey, customEmojiValue] = item;\n\n if (customEmojiKey in emojiJson) {\n // custom emoji exists in emoji json which means to update some data in the native emoji\n const emojiData = emojiJson[customEmojiKey];\n\n for (const customEmojiPropertyName in customEmojiValue) {\n const customEmojiPropertyValue = customEmojiValue[customEmojiPropertyName];\n\n _updateNativeEmojiData(emojiData, customEmojiPropertyName, customEmojiPropertyValue);\n }\n } else {\n // new custom emoji\n const _validateRequiredProps = () =>\n customEmojiRequiredProps.every((val) => {\n return customEmojiValue[val] !== undefined;\n });\n\n if (_validateRequiredProps()) {\n emojiJson[customEmojiKey] = customEmojiValue;\n } else {\n console.error(\n 'The following custom emoji doesn\\'t contain the required properties:',\n customEmojiValue,\n );\n }\n }\n });\n}\n\n// recursively searches the emoji data object containing data for all emojis\n// and returns the object with the specified shortcode.\nexport function shortcodeToEmojiData (shortcode) {\n // eslint-disable-next-line complexity\n function f (o, key) {\n if (!o || typeof o !== 'object') {\n return;\n }\n if ('shortname' in o) {\n if (o.shortname === shortcode || o.shortname_alternates.includes(shortcode)) {\n o.key = key;\n reference = o;\n return true;\n }\n }\n Object.keys(o).some(function (k) {\n return f(o[k], k);\n });\n }\n\n let reference;\n f(getEmojiData(), null);\n return reference;\n}\n\n// Takes in an emoji unicode character(s) and converts it to an emoji string in the format the emoji data object expects\n// as a key. There can be multiple unicode characters in an emoji to denote the emoji itself, skin tone, gender\n// and such. Note that this function does NOT return variation selectors (fe0f) or zero width joiners (200d), as these\n// are not included as part of the key in the emoji.json.\n//\n// Example:\n// return value for smile emoji (no skin tone): 1f600\n// return value for left facing fist (light skin tone): 1f91b-1f3fb\nexport function unicodeToString (emoji) {\n let key = '';\n for (const codePoint of emoji) {\n const codepoint = codePoint.codePointAt(0).toString(16).padStart(4, '0');\n\n // skip 200d and fe0f as these are not included in emoji_strategy.json keys\n if (['200d', 'fe0f'].includes(codepoint)) continue;\n if (key !== '') { key = key + '-'; }\n key = key + codepoint;\n }\n return key;\n}\n\n// Takes in unicode in string form ex: '1f91b-1f3fb' and converts it to an actual unicode character.\nexport function stringToUnicode (str) {\n const uChars = str.split('-');\n let result = '';\n uChars.forEach((uChar) => {\n result = result + String.fromCodePoint(parseInt(uChar, 16));\n });\n return result;\n}\n\n// Takes in a code (which could be unicode or shortcode) and returns the emoji data for it.\nexport function codeToEmojiData (code) {\n if (code.startsWith(':') && code.endsWith(':')) {\n return shortcodeToEmojiData(code);\n } else {\n const unicodeString = unicodeToString(code);\n\n const result = emojiJson[unicodeString];\n if (result) result.key = unicodeString;\n return result;\n }\n}\n\n// Finds every shortcode in slot text\n// filters only the existing codes in emojiJson\n// removes duplicates.\n// @returns {string[]}\nexport function findShortCodes (textContent) {\n const shortcodes = textContent.match(
|
|
1
|
+
{"version":3,"file":"emoji.js","sources":["../../common/emoji/index.js"],"sourcesContent":["import emojiRegex from 'emoji-regex';\nimport emojiJsonLocal from 'emoji-toolkit/emoji_strategy.json';\n\nexport const emojiVersion = '8.0';\nexport const defaultEmojiAssetUrl = 'https://cdn.jsdelivr.net/joypixels/assets/' + emojiVersion + '/png/unicode/32/';\nexport let customEmojiAssetUrl = null;\n\n// Used for emoji 16px and smaller\nexport let emojiImageUrlSmall = defaultEmojiAssetUrl;\nexport let emojiFileExtensionSmall = '.png';\n\n// Used for emoji larger than 16px\nexport let emojiImageUrlLarge = defaultEmojiAssetUrl;\nexport let emojiFileExtensionLarge = '.png';\n\nexport const emojiJson = emojiJsonLocal;\n\nexport const emojiShortCodeRegex = /(^| |(?<=:))(:\\w+:)/g;\n\nexport function getEmojiData () {\n return emojiJson;\n}\n\nexport function setEmojiAssetUrlSmall (url, fileExtension = '.png') {\n if (!url.endsWith('/')) {\n url = url + '/';\n }\n emojiImageUrlSmall = url;\n emojiFileExtensionSmall = fileExtension;\n}\n\nexport function setEmojiAssetUrlLarge (url, fileExtension = '.svg') {\n if (!url.endsWith('/')) {\n url = url + '/';\n }\n emojiImageUrlLarge = url;\n emojiFileExtensionLarge = fileExtension;\n}\n\nexport function setCustomEmojiUrl (url) {\n customEmojiAssetUrl = url;\n}\n\nexport function setCustomEmojiJson (json) {\n validateCustomEmojiJson(json);\n}\n\n/**\n * Validate custom emoji json\n */\nexport function validateCustomEmojiJson (json) {\n const customEmojiProps = ['extension', 'custom'];\n const customEmojiRequiredProps = [\n 'name',\n 'category',\n 'shortname',\n 'extension',\n 'custom',\n ];\n\n /**\n * Update single emoji properties.\n * If the property exists in emojiData, it'll add the values if the property is an array, otherwise will overwrite.\n * If not exists, will add the property to the emojiData object.\n */\n const _updateNativeEmojiData = (emojiData, propName, propValue) => {\n if (emojiData[propName] === undefined) {\n if (!customEmojiProps.includes(propName)) {\n return;\n }\n\n // new property to add\n emojiData[propName] = propValue;\n } else {\n if (Array.isArray(emojiData[propName])) {\n emojiData[propName] = emojiData[propName].concat(propValue);\n } else {\n emojiData[propName] = propValue;\n }\n }\n };\n\n Object.entries(json).forEach((item) => {\n const [customEmojiKey, customEmojiValue] = item;\n\n if (customEmojiKey in emojiJson) {\n // custom emoji exists in emoji json which means to update some data in the native emoji\n const emojiData = emojiJson[customEmojiKey];\n\n for (const customEmojiPropertyName in customEmojiValue) {\n const customEmojiPropertyValue = customEmojiValue[customEmojiPropertyName];\n\n _updateNativeEmojiData(emojiData, customEmojiPropertyName, customEmojiPropertyValue);\n }\n } else {\n // new custom emoji\n const _validateRequiredProps = () =>\n customEmojiRequiredProps.every((val) => {\n return customEmojiValue[val] !== undefined;\n });\n\n if (_validateRequiredProps()) {\n emojiJson[customEmojiKey] = customEmojiValue;\n } else {\n console.error(\n 'The following custom emoji doesn\\'t contain the required properties:',\n customEmojiValue,\n );\n }\n }\n });\n}\n\n// recursively searches the emoji data object containing data for all emojis\n// and returns the object with the specified shortcode.\nexport function shortcodeToEmojiData (shortcode) {\n // eslint-disable-next-line complexity\n function f (o, key) {\n if (!o || typeof o !== 'object') {\n return;\n }\n if ('shortname' in o) {\n if (o.shortname === shortcode || o.shortname_alternates.includes(shortcode)) {\n o.key = key;\n reference = o;\n return true;\n }\n }\n Object.keys(o).some(function (k) {\n return f(o[k], k);\n });\n }\n\n let reference;\n f(getEmojiData(), null);\n return reference;\n}\n\n// Takes in an emoji unicode character(s) and converts it to an emoji string in the format the emoji data object expects\n// as a key. There can be multiple unicode characters in an emoji to denote the emoji itself, skin tone, gender\n// and such. Note that this function does NOT return variation selectors (fe0f) or zero width joiners (200d), as these\n// are not included as part of the key in the emoji.json.\n//\n// Example:\n// return value for smile emoji (no skin tone): 1f600\n// return value for left facing fist (light skin tone): 1f91b-1f3fb\nexport function unicodeToString (emoji) {\n let key = '';\n for (const codePoint of emoji) {\n const codepoint = codePoint.codePointAt(0).toString(16).padStart(4, '0');\n\n // skip 200d and fe0f as these are not included in emoji_strategy.json keys\n if (['200d', 'fe0f'].includes(codepoint)) continue;\n if (key !== '') { key = key + '-'; }\n key = key + codepoint;\n }\n return key;\n}\n\n// Takes in unicode in string form ex: '1f91b-1f3fb' and converts it to an actual unicode character.\nexport function stringToUnicode (str) {\n const uChars = str.split('-');\n let result = '';\n uChars.forEach((uChar) => {\n result = result + String.fromCodePoint(parseInt(uChar, 16));\n });\n return result;\n}\n\n// Takes in a code (which could be unicode or shortcode) and returns the emoji data for it.\nexport function codeToEmojiData (code) {\n code = code?.trim();\n if (code.startsWith(':') && code.endsWith(':')) {\n return shortcodeToEmojiData(code);\n } else {\n const unicodeString = unicodeToString(code);\n\n const result = emojiJson[unicodeString];\n if (result) result.key = unicodeString;\n return result;\n }\n}\n\n// Finds every shortcode in slot text\n// filters only the existing codes in emojiJson\n// removes duplicates.\n// @returns {string[]}\nexport function findShortCodes (textContent) {\n const shortcodes = (\n textContent.match(emojiShortCodeRegex) || []\n ).map(code => code.trim());\n return filterValidShortCodes(shortcodes);\n}\n\nexport function filterValidShortCodes (shortcodes) {\n const filtered = shortcodes ? shortcodes.filter(code => shortcodeToEmojiData(code)) : [];\n return new Set(filtered);\n}\n\n// Finds every emoji in slot text\n// removes duplicates\n// @returns {string[]}\nexport function findEmojis (textContent) {\n const matches = [...textContent.matchAll(emojiRegex())];\n const emojis = matches.length ? matches.map(match => match[0]) : [];\n return new Set(emojis);\n}\n"],"names":[],"mappings":";;AAGY,MAAC,eAAe;AAChB,MAAC,uBAAuB,+CAA+C,eAAe;AACxF,IAAC,sBAAsB;AAGvB,IAAC,qBAAqB;AACtB,IAAC,0BAA0B;AAG3B,IAAC,qBAAqB;AACtB,IAAC,0BAA0B;AAEzB,MAAC,YAAY;AAEb,MAAC,sBAAsB,WAAuB,wBAAA,GAAA;AAEnD,SAAS,eAAgB;AAC9B,SAAO;AACT;AAEO,SAAS,sBAAuB,KAAK,gBAAgB,QAAQ;AAClE,MAAI,CAAC,IAAI,SAAS,GAAG,GAAG;AACtB,UAAM,MAAM;AAAA,EACb;AACD,uBAAqB;AACrB,4BAA0B;AAC5B;AAEO,SAAS,sBAAuB,KAAK,gBAAgB,QAAQ;AAClE,MAAI,CAAC,IAAI,SAAS,GAAG,GAAG;AACtB,UAAM,MAAM;AAAA,EACb;AACD,uBAAqB;AACrB,4BAA0B;AAC5B;AAEO,SAAS,kBAAmB,KAAK;AACtC,wBAAsB;AACxB;AAEO,SAAS,mBAAoB,MAAM;AACxC,0BAAwB,IAAI;AAC9B;AAKO,SAAS,wBAAyB,MAAM;AAC7C,QAAM,mBAAmB,CAAC,aAAa,QAAQ;AAC/C,QAAM,2BAA2B;AAAA,IAC/B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACJ;AAOE,QAAM,yBAAyB,CAAC,WAAW,UAAU,cAAc;AACjE,QAAI,UAAU,QAAQ,MAAM,QAAW;AACrC,UAAI,CAAC,iBAAiB,SAAS,QAAQ,GAAG;AACxC;AAAA,MACD;AAGD,gBAAU,QAAQ,IAAI;AAAA,IAC5B,OAAW;AACL,UAAI,MAAM,QAAQ,UAAU,QAAQ,CAAC,GAAG;AACtC,kBAAU,QAAQ,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all
|
|
158
158
|
});
|
|
159
159
|
exports.emojiJson = common_emoji.emojiJson;
|
|
160
|
+
exports.emojiShortCodeRegex = common_emoji.emojiShortCodeRegex;
|
|
160
161
|
exports.emojiVersion = common_emoji.emojiVersion;
|
|
161
162
|
exports.filterValidShortCodes = common_emoji.filterValidShortCodes;
|
|
162
163
|
exports.findEmojis = common_emoji.findEmojis;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialtone-vue.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dialtone-vue.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -2,7 +2,7 @@ import { DEFAULT_VALIDATION_MESSAGE_TYPE, DESCRIPTION_SIZE_TYPES, VALIDATION_MES
|
|
|
2
2
|
import { validationMessageValidator } from "./common/validators.js";
|
|
3
3
|
import { filterFormattedMessages, formatMessages, getUniqueString, getValidationState } from "./common/utils.js";
|
|
4
4
|
import { durationInHHMM, getDateMedium, relativeDate, setDateLocale } from "./common/dates.js";
|
|
5
|
-
import { codeToEmojiData, customEmojiAssetUrl, defaultEmojiAssetUrl, emojiFileExtensionLarge, emojiFileExtensionSmall, emojiImageUrlLarge, emojiImageUrlSmall, emojiJson, emojiVersion, filterValidShortCodes, findEmojis, findShortCodes, getEmojiData, setCustomEmojiJson, setCustomEmojiUrl, setEmojiAssetUrlLarge, setEmojiAssetUrlSmall, shortcodeToEmojiData, stringToUnicode, unicodeToString, validateCustomEmojiJson } from "./common/emoji.js";
|
|
5
|
+
import { codeToEmojiData, customEmojiAssetUrl, defaultEmojiAssetUrl, emojiFileExtensionLarge, emojiFileExtensionSmall, emojiImageUrlLarge, emojiImageUrlSmall, emojiJson, emojiShortCodeRegex, emojiVersion, filterValidShortCodes, findEmojis, findShortCodes, getEmojiData, setCustomEmojiJson, setCustomEmojiUrl, setEmojiAssetUrlLarge, setEmojiAssetUrlSmall, shortcodeToEmojiData, stringToUnicode, unicodeToString, validateCustomEmojiJson } from "./common/emoji.js";
|
|
6
6
|
import { CheckableMixin, GroupableMixin, InputMixin } from "./chunks/input-6kbd8Pju.js";
|
|
7
7
|
import { InputGroupMixin } from "./chunks/input_group-qVZaS5Bb.js";
|
|
8
8
|
import { KeyboardNavigation } from "./chunks/keyboard_list_navigation-ScXhrxya.js";
|
|
@@ -330,6 +330,7 @@ export {
|
|
|
330
330
|
emojiImageUrlLarge,
|
|
331
331
|
emojiImageUrlSmall,
|
|
332
332
|
emojiJson,
|
|
333
|
+
emojiShortCodeRegex,
|
|
333
334
|
emojiVersion,
|
|
334
335
|
filterFormattedMessages,
|
|
335
336
|
filterValidShortCodes,
|
|
@@ -266,25 +266,25 @@ const _sfc_main$2 = {
|
|
|
266
266
|
};
|
|
267
267
|
var _sfc_render$2 = function render() {
|
|
268
268
|
var _vm = this, _c = _vm._self._c;
|
|
269
|
-
return _c("dt-stack", { staticClass: "d-datepicker__month-year", attrs: { "direction": "row", "gap": "300" } }, [_c("dt-stack", { staticClass: "d-datepicker__nav", attrs: { "as": "nav", "direction": "row", "gap": "200" } }, [_c("dt-tooltip", { attrs: { "message": _vm.prevYearLabel, "placement": "top" }, scopedSlots: _vm._u([{ key: "anchor", fn: function() {
|
|
269
|
+
return _c("dt-stack", { staticClass: "d-datepicker__month-year", attrs: { "direction": "row", "gap": "300" } }, [_c("dt-stack", { staticClass: "d-datepicker__nav", attrs: { "as": "nav", "direction": "row", "gap": "200" } }, [_c("dt-tooltip", { attrs: { "message": _vm.prevYearLabel, "placement": "top", "fallback-placements": ["top-start", "auto"] }, scopedSlots: _vm._u([{ key: "anchor", fn: function() {
|
|
270
270
|
return [_c("dt-button", { ref: _vm.refNames[0], staticClass: "d-datepicker__nav-btn", attrs: { "id": "prevYearButton", "size": "xs", "importance": "clear", "kind": "muted", "circle": true, "type": "button", "aria-label": `${_vm.changeToLabel} ${_vm.prevYearLabel} ${_vm.selectYear - 1}` }, on: { "click": function($event) {
|
|
271
271
|
return _vm.changeYear(-1);
|
|
272
272
|
}, "keydown": function($event) {
|
|
273
273
|
return _vm.handleKeyDown($event);
|
|
274
274
|
} } }, [_c("dt-icon", { attrs: { "name": "chevrons-left", "size": "200" } })], 1)];
|
|
275
|
-
}, proxy: true }]) }), _c("dt-tooltip", { attrs: { "message": _vm.prevMonthLabel, "placement": "top" }, scopedSlots: _vm._u([{ key: "anchor", fn: function() {
|
|
275
|
+
}, proxy: true }]) }), _c("dt-tooltip", { attrs: { "message": _vm.prevMonthLabel, "placement": "top", "fallback-placements": ["top-end", "auto"] }, scopedSlots: _vm._u([{ key: "anchor", fn: function() {
|
|
276
276
|
return [_c("dt-button", { ref: _vm.refNames[1], staticClass: "d-datepicker__nav-btn", attrs: { "id": "prevMonthButton", "size": "xs", "importance": "clear", "kind": "muted", "circle": true, "type": "button", "aria-label": `${_vm.changeToLabel} ${_vm.prevMonthLabel} ${_vm.formattedMonth(_vm.selectMonth - 1)}` }, on: { "click": function($event) {
|
|
277
277
|
return _vm.changeMonth(-1);
|
|
278
278
|
}, "keydown": function($event) {
|
|
279
279
|
return _vm.handleKeyDown($event);
|
|
280
280
|
} } }, [_c("dt-icon", { attrs: { "name": "chevron-left", "size": "200" } })], 1)];
|
|
281
|
-
}, proxy: true }]) })], 1), _c("div", { staticClass: "d-datepicker__month-year-title", attrs: { "id": "calendar-heading" } }, [_vm._v(" " + _vm._s(_vm.formattedMonth(_vm.selectMonth)) + " " + _vm._s(_vm.selectYear) + " ")]), _c("dt-stack", { staticClass: "d-datepicker__nav", attrs: { "as": "nav", "direction": "row", "gap": "200" } }, [_c("dt-tooltip", { attrs: { "message": _vm.nextMonthLabel, "placement": "top" }, scopedSlots: _vm._u([{ key: "anchor", fn: function() {
|
|
281
|
+
}, proxy: true }]) })], 1), _c("div", { staticClass: "d-datepicker__month-year-title", attrs: { "id": "calendar-heading" } }, [_vm._v(" " + _vm._s(_vm.formattedMonth(_vm.selectMonth)) + " " + _vm._s(_vm.selectYear) + " ")]), _c("dt-stack", { staticClass: "d-datepicker__nav", attrs: { "as": "nav", "direction": "row", "gap": "200" } }, [_c("dt-tooltip", { attrs: { "message": _vm.nextMonthLabel, "placement": "top", "fallback-placements": ["top-start", "auto"] }, scopedSlots: _vm._u([{ key: "anchor", fn: function() {
|
|
282
282
|
return [_c("dt-button", { ref: _vm.refNames[2], staticClass: "d-datepicker__nav-btn", attrs: { "id": "nextMonthButton", "size": "xs", "importance": "clear", "circle": true, "kind": "muted", "type": "button", "aria-label": `${_vm.changeToLabel} ${_vm.nextMonthLabel} ${_vm.formattedMonth(_vm.selectMonth + 1)}` }, on: { "click": function($event) {
|
|
283
283
|
return _vm.changeMonth(1);
|
|
284
284
|
}, "keydown": function($event) {
|
|
285
285
|
return _vm.handleKeyDown($event);
|
|
286
286
|
} } }, [_c("dt-icon", { attrs: { "name": "chevron-right", "size": "200" } })], 1)];
|
|
287
|
-
}, proxy: true }]) }), _c("dt-tooltip", { attrs: { "message": _vm.nextYearLabel, "placement": "top" }, scopedSlots: _vm._u([{ key: "anchor", fn: function() {
|
|
287
|
+
}, proxy: true }]) }), _c("dt-tooltip", { attrs: { "message": _vm.nextYearLabel, "placement": "top", "fallback-placements": ["top-end", "auto"] }, scopedSlots: _vm._u([{ key: "anchor", fn: function() {
|
|
288
288
|
return [_c("dt-button", { ref: _vm.refNames[3], staticClass: "d-datepicker__nav-btn", attrs: { "id": "nextYearButton", "size": "xs", "kind": "muted", "circle": true, "importance": "clear", "type": "button", "aria-label": `${_vm.changeToLabel} ${_vm.nextYearLabel} ${_vm.selectYear + 1}` }, on: { "click": function($event) {
|
|
289
289
|
return _vm.changeYear(1);
|
|
290
290
|
}, "keydown": function($event) {
|