@antscorp/antsomi-ui 1.3.5-beta.753 → 1.3.5-beta.755

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.
@@ -29,6 +29,7 @@ export declare const parseTagString: (input: string, acceptableTagPattern: Array
29
29
  */
30
30
  export declare function convertInputString(input: string): string;
31
31
  export declare const getLinkLineURLImage: (productId?: string, code?: string) => string;
32
+ export declare const getImageSourceViberEmoji: (fileName?: string) => any;
32
33
  /**
33
34
  * Processes the input text to replace emojis based on the specified collection type.
34
35
  *
@@ -4,7 +4,6 @@ import stringReplaceToArray from 'string-replace-to-array';
4
4
  import { CUSTOM_FN, EMOJI, EMOJI_COLLECTIONS, PREFIX_PATTERN_LINE_MESSAGE, PROMOTION_CODE, SHORT_LINK, } from './constants';
5
5
  import { iconsViber } from './iconsViber';
6
6
  // Utils
7
- import { getImagePath } from './generateImagePath';
8
7
  import { acceptablePatternChecking, getCachedRegex, patternHandlers } from './patternHandlers';
9
8
  /**
10
9
  * Parses the input string and replaces matching patterns with processed tags.
@@ -102,24 +101,20 @@ export function convertInputString(input) {
102
101
  return result.trim(); // Remove any trailing whitespace
103
102
  }
104
103
  export const getLinkLineURLImage = (productId = '', code = '') => `https://stickershop.line-scdn.net/sticonshop/v1/sticon/${productId}/android/${code}.png?detect-emoji=line-message&v=1`;
104
+ export const getImageSourceViberEmoji = (fileName = '') => {
105
+ // eslint-disable-next-line global-require, import/no-dynamic-require
106
+ const src = require(`../../../assets/images/viber/96x96/${fileName}`);
107
+ return src.default || src;
108
+ };
105
109
  /**
106
110
  * Creates a renderer function for Viber emojis that maps specific filenames to emojis.
107
111
  *
108
112
  * @returns {Function} A function that takes a filename extension and returns a corresponding image source URL
109
113
  * or undefined if the image path is not found.
110
114
  *
111
- * The renderer replaces certain filenames with their corresponding special characters (e.g., 'exclamation' with '!').
112
115
  */
113
116
  const makeViberEmojiRenderer = () => function renderViberEmoji(fileNameExtension) {
114
- const findIndexOfDot = fileNameExtension.indexOf('.');
115
- let fileNameWithoutExtension = fileNameExtension.slice(0, findIndexOfDot);
116
- if (fileNameWithoutExtension === 'exclamation') {
117
- fileNameWithoutExtension = '!';
118
- }
119
- if (fileNameWithoutExtension === 'dollars') {
120
- fileNameWithoutExtension = '$';
121
- }
122
- const src = getImagePath(fileNameWithoutExtension);
117
+ const src = getImageSourceViberEmoji(fileNameExtension);
123
118
  return src;
124
119
  };
125
120
  /**
@@ -25,9 +25,6 @@ import { THEME } from '@antscorp/antsomi-ui/es/constants';
25
25
  // Style
26
26
  import '@antscorp/antsomi-ui/es/assets/css/main.scss';
27
27
  import { GlobalStyle } from './GlobalStyle';
28
- // Initialize languages
29
- // import '@antscorp/antsomi-ui/es/locales/i18n';
30
- import i18next from '@antscorp/antsomi-ui/es/locales/i18n';
31
28
  import 'animate.css';
32
29
  import { AppConfigProvider } from '../AppConfigProvider';
33
30
  // Hooks
@@ -82,11 +79,11 @@ const ConfigProvider = props => {
82
79
  characterDataOldValue: true,
83
80
  });
84
81
  // Effects
85
- useEffect(() => {
86
- if (locale) {
87
- i18next.changeLanguage(locale);
88
- }
89
- }, [locale]);
82
+ // useEffect(() => {
83
+ // if (locale) {
84
+ // i18next.changeLanguage(locale);
85
+ // }
86
+ // }, [locale]);
90
87
  useEffect(() => {
91
88
  const containers = document.getElementsByClassName('antsomi-scroll-box');
92
89
  handleScrollAction(Array.from(containers));
@@ -1,4 +1,5 @@
1
1
  import { useQuery } from '@tanstack/react-query';
2
+ import i18next from '@antscorp/antsomi-ui/es/locales/i18n';
2
3
  // Services
3
4
  import { userServices } from '../../services/User';
4
5
  import { PORTAL_KEYS, QUERY_KEYS } from '../../constants';
@@ -9,5 +10,6 @@ export const useGetLoggedUser = (params) => {
9
10
  UserAndPortalDefaultConfig.setPartial({
10
11
  [PORTAL_KEYS.USER_LANGUAGE]: data.language,
11
12
  });
13
+ i18next.changeLanguage(`${data.language || 'en'}`.toLowerCase());
12
14
  } }, options));
13
15
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.5-beta.753",
3
+ "version": "1.3.5-beta.755",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",
@@ -1 +0,0 @@
1
- export declare function getImagePath(fileName: string): string | undefined;
@@ -1,43 +0,0 @@
1
- var _a;
2
- // Utility function to determine if running in Vite environment
3
- function isVite() {
4
- console.log('import meta', import.meta);
5
- return typeof import.meta !== 'undefined';
6
- }
7
- // Utility function to determine if running in Webpack environment
8
- function isWebpack() {
9
- console.log('typeof require', typeof require);
10
- return typeof require !== 'undefined' && typeof require.context === 'function';
11
- }
12
- // Create an image map based on the detected environment
13
- const imageMap = {};
14
- if (isVite()) {
15
- // Vite environment: Use import.meta.glob to preload images
16
- const images = import.meta.glob('../../../assets/images/viber/96x96/*.png', {
17
- eager: true,
18
- import: 'default',
19
- });
20
- for (const path in images) {
21
- const fileName = (_a = path.split('/').pop()) === null || _a === void 0 ? void 0 : _a.split('.').shift();
22
- if (fileName) {
23
- imageMap[fileName] = images[path];
24
- }
25
- }
26
- }
27
- else if (isWebpack()) {
28
- // Webpack environment: Use require.context to preload images
29
- const images = require.context('../../../assets/images/viber/96x96', false, /\.png$/);
30
- images.keys().forEach(key => {
31
- var _a;
32
- const fileName = (_a = key.split('/').pop()) === null || _a === void 0 ? void 0 : _a.split('.').shift();
33
- if (fileName) {
34
- imageMap[fileName] = images(key).default || images(key);
35
- }
36
- });
37
- }
38
- else {
39
- console.error('Unsupported environment: This code must run in either Vite or Webpack.');
40
- }
41
- export function getImagePath(fileName) {
42
- return imageMap[fileName]; // Return the correct image path
43
- }