@onesy/ui-react 1.0.44 → 1.0.46
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/Emojis/Emojis.js +2 -1
- package/SmartTextField/SmartTextField.js +3 -3
- package/esm/Emojis/Emojis.js +2 -0
- package/esm/SmartTextField/SmartTextField.js +4 -4
- package/esm/index.js +1 -1
- package/esm/utils.js +5 -1
- package/package.json +1 -1
- package/utils.d.ts +1 -0
- package/utils.js +6 -1
package/Emojis/Emojis.js
CHANGED
@@ -225,6 +225,7 @@ const Emojis = react_1.default.forwardRef((props_, ref) => {
|
|
225
225
|
setOpen(false);
|
226
226
|
setTimeout(() => {
|
227
227
|
setOpenElement(null);
|
228
|
+
setSearch('');
|
228
229
|
}, 140);
|
229
230
|
}, []);
|
230
231
|
const onSelect = react_1.default.useCallback((valueNew) => {
|
@@ -293,7 +294,7 @@ const Emojis = react_1.default.forwardRef((props_, ref) => {
|
|
293
294
|
const label = ((0, jsx_runtime_1.jsx)(Line, Object.assign({ tonal: tonal, color: color, Component: Surface, className: (0, style_react_1.classNames)([
|
294
295
|
classes.wrapper,
|
295
296
|
classes[`size_${size}`]
|
296
|
-
]) }, { children: (0, jsx_runtime_1.jsx)(SpyScroll, Object.assign({ ids: categoriesUsedIDs, parent: openElement, onActive: onActiveTab }, { children: (0, jsx_runtime_1.jsxs)(Line, Object.assign({ gap: 0, align: 'unset', justify: 'unset', fullWidth: true, className: classes.categories }, { children: [(search_ || tabs_) && ((0, jsx_runtime_1.jsxs)(Line, Object.assign({ gap: 1, fullWidth: true, className: classes.header }, { children: [search_ && ((0, jsx_runtime_1.jsx)(TextField, { name: 'Search', version: 'outlined', onChange: onChangeSearch, size: ['small', 'regular'].includes(size) ? 'small' : 'regular', fullWidth: true, clear: true })), tabs_ && !!categoriesUsed.length && ((0, jsx_runtime_1.jsx)(Tabs, Object.assign({ valueDefault: tab, value: tab, onChange: onChangeTabs, size: 'small', initialLineUpdateTimeout: 440, noDivider: true, className: classes.tabs }, { children: tabs.map((item, index) => ((0, jsx_runtime_1.jsx)(Tab, Object.assign({ value: item.value, onClick: () => onTabClick(item.value), "data-onesy-spy-scroll": categoryToID(item.value), className: (0, style_react_1.classNames)([
|
297
|
+
]) }, { children: (0, jsx_runtime_1.jsx)(SpyScroll, Object.assign({ ids: categoriesUsedIDs, parent: openElement, onActive: onActiveTab }, { children: (0, jsx_runtime_1.jsxs)(Line, Object.assign({ gap: 0, align: 'unset', justify: 'unset', fullWidth: true, className: classes.categories }, { children: [(search_ || tabs_) && ((0, jsx_runtime_1.jsxs)(Line, Object.assign({ gap: 1, fullWidth: true, className: classes.header }, { children: [search_ && ((0, jsx_runtime_1.jsx)(TextField, { name: 'Search', version: 'outlined', value: search || '', onChange: onChangeSearch, size: ['small', 'regular'].includes(size) ? 'small' : 'regular', fullWidth: true, clear: true })), tabs_ && !!categoriesUsed.length && ((0, jsx_runtime_1.jsx)(Tabs, Object.assign({ valueDefault: tab, value: tab, onChange: onChangeTabs, size: 'small', initialLineUpdateTimeout: 440, noDivider: true, className: classes.tabs }, { children: tabs.map((item, index) => ((0, jsx_runtime_1.jsx)(Tab, Object.assign({ value: item.value, onClick: () => onTabClick(item.value), "data-onesy-spy-scroll": categoryToID(item.value), className: (0, style_react_1.classNames)([
|
297
298
|
classes.tab,
|
298
299
|
classes[`tab_size_${size}`]
|
299
300
|
]) }, { children: react_1.default.cloneElement(item.name, {
|
@@ -200,7 +200,7 @@ const SmartTextField = react_1.default.forwardRef((props_, ref) => {
|
|
200
200
|
setOptionsMention([...(optionsMention_ || [])]);
|
201
201
|
}, [(0, utils_1.hash)(optionsMention_)]);
|
202
202
|
react_1.default.useEffect(() => {
|
203
|
-
const valuePrevious = (refs.root.current.innerHTML || '').replaceAll(' ', ' ');
|
203
|
+
const valuePrevious = (0, utils_2.decodeHTMLEntities)(refs.root.current.innerHTML || '').replaceAll(' ', ' ');
|
204
204
|
const valueNew = (0, utils_1.textToInnerHTML)(value_);
|
205
205
|
if (value_ !== undefined && valuePrevious !== valueNew)
|
206
206
|
validate(!value_ ? '' : (0, utils_2.sanitize)(value_));
|
@@ -287,7 +287,7 @@ const SmartTextField = react_1.default.forwardRef((props_, ref) => {
|
|
287
287
|
refs.search.current = getAtSearchData();
|
288
288
|
const onInput = react_1.default.useCallback((event) => {
|
289
289
|
if (refs.root.current) {
|
290
|
-
let valueInput = refs.root.current.innerHTML || '';
|
290
|
+
let valueInput = (0, utils_2.decodeHTMLEntities)(refs.root.current.innerHTML || '');
|
291
291
|
if (refs.root.current.textContent === '') {
|
292
292
|
valueInput = '';
|
293
293
|
refs.root.current.innerHTML = '';
|
@@ -453,7 +453,7 @@ const SmartTextField = react_1.default.forwardRef((props_, ref) => {
|
|
453
453
|
// Remove the text node
|
454
454
|
textNode.remove();
|
455
455
|
// Invoke onChange method with new value
|
456
|
-
const valueInput = (0, utils_1.innerHTMLToText)(refs.root.current.innerHTML);
|
456
|
+
const valueInput = (0, utils_1.innerHTMLToText)((0, utils_2.decodeHTMLEntities)(refs.root.current.innerHTML));
|
457
457
|
if ((0, utils_1.is)('function', refs.onChange.current))
|
458
458
|
refs.onChange.current(valueInput, { target: refs.root.current });
|
459
459
|
// Update the caret position to be outside the span mention
|
package/esm/Emojis/Emojis.js
CHANGED
@@ -222,6 +222,7 @@ const Emojis = /*#__PURE__*/React.forwardRef((props_, ref) => {
|
|
222
222
|
setOpen(false);
|
223
223
|
setTimeout(() => {
|
224
224
|
setOpenElement(null);
|
225
|
+
setSearch('');
|
225
226
|
}, 140);
|
226
227
|
}, []);
|
227
228
|
const onSelect = React.useCallback(valueNew => {
|
@@ -303,6 +304,7 @@ const Emojis = /*#__PURE__*/React.forwardRef((props_, ref) => {
|
|
303
304
|
}, search_ && /*#__PURE__*/React.createElement(TextField, {
|
304
305
|
name: "Search",
|
305
306
|
version: "outlined",
|
307
|
+
value: search || '',
|
306
308
|
onChange: onChangeSearch,
|
307
309
|
size: ['small', 'regular'].includes(size) ? 'small' : 'regular',
|
308
310
|
fullWidth: true,
|
@@ -32,7 +32,7 @@ import ToggleButtonElement from '../ToggleButton';
|
|
32
32
|
import ClickListenerElement from '../ClickListener';
|
33
33
|
import ToggleButtonsElement from '../ToggleButtons';
|
34
34
|
import MenuElement from '../Menu';
|
35
|
-
import { sanitize, caret, keyboardStyleCommands, staticClassName } from '../utils';
|
35
|
+
import { sanitize, caret, keyboardStyleCommands, staticClassName, decodeHTMLEntities } from '../utils';
|
36
36
|
const useStyle = styleMethod(theme => ({
|
37
37
|
root: {
|
38
38
|
minHeight: '20px',
|
@@ -226,7 +226,7 @@ const SmartTextField = /*#__PURE__*/React.forwardRef((props_, ref) => {
|
|
226
226
|
setOptionsMention([...(optionsMention_ || [])]);
|
227
227
|
}, [hash(optionsMention_)]);
|
228
228
|
React.useEffect(() => {
|
229
|
-
const valuePrevious = (refs.root.current.innerHTML || '').replaceAll(' ', ' ');
|
229
|
+
const valuePrevious = decodeHTMLEntities(refs.root.current.innerHTML || '').replaceAll(' ', ' ');
|
230
230
|
const valueNew = textToInnerHTML(value_);
|
231
231
|
if (value_ !== undefined && valuePrevious !== valueNew) validate(!value_ ? '' : sanitize(value_));
|
232
232
|
}, [value_]);
|
@@ -306,7 +306,7 @@ const SmartTextField = /*#__PURE__*/React.forwardRef((props_, ref) => {
|
|
306
306
|
refs.search.current = getAtSearchData();
|
307
307
|
const onInput = React.useCallback(event => {
|
308
308
|
if (refs.root.current) {
|
309
|
-
let valueInput = refs.root.current.innerHTML || '';
|
309
|
+
let valueInput = decodeHTMLEntities(refs.root.current.innerHTML || '');
|
310
310
|
if (refs.root.current.textContent === '') {
|
311
311
|
valueInput = '';
|
312
312
|
refs.root.current.innerHTML = '';
|
@@ -471,7 +471,7 @@ const SmartTextField = /*#__PURE__*/React.forwardRef((props_, ref) => {
|
|
471
471
|
textNode.remove();
|
472
472
|
|
473
473
|
// Invoke onChange method with new value
|
474
|
-
const valueInput = innerHTMLToText(refs.root.current.innerHTML);
|
474
|
+
const valueInput = innerHTMLToText(decodeHTMLEntities(refs.root.current.innerHTML));
|
475
475
|
if (is('function', refs.onChange.current)) refs.onChange.current(valueInput, {
|
476
476
|
target: refs.root.current
|
477
477
|
});
|
package/esm/index.js
CHANGED
package/esm/utils.js
CHANGED
@@ -1253,4 +1253,8 @@ export const currencies = [{
|
|
1253
1253
|
rounding: 0,
|
1254
1254
|
code: 'ZMK',
|
1255
1255
|
name_plural: 'Zambian kwachas'
|
1256
|
-
}];
|
1256
|
+
}];
|
1257
|
+
export const decodeHTMLEntities = html => {
|
1258
|
+
const document = new DOMParser().parseFromString(html, 'text/html');
|
1259
|
+
return document.documentElement.textContent || '';
|
1260
|
+
};
|
package/package.json
CHANGED
package/utils.d.ts
CHANGED
package/utils.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.currencies = exports.iconFontSize = exports.formats = exports.toNumber = exports.caret = exports.keyboardStyleCommands = exports.keyboardStandardCommands = exports.getOverflowParent = exports.importIframeStyles = exports.replace = exports.sanitize = exports.minMaxBetweenNumbers = exports.controlPoint = exports.line = exports.angleToCoordinates = exports.matches = exports.save = exports.print = exports.canvasOldPhoto = exports.canvasInvert = exports.canvasFade = exports.canvasSaturation = exports.canvasContrast = exports.canvasBrightness = exports.image = exports.valueBreakpoints = exports.iconSizeToFontSize = exports.staticClassName = exports.reflow = void 0;
|
3
|
+
exports.decodeHTMLEntities = exports.currencies = exports.iconFontSize = exports.formats = exports.toNumber = exports.caret = exports.keyboardStyleCommands = exports.keyboardStandardCommands = exports.getOverflowParent = exports.importIframeStyles = exports.replace = exports.sanitize = exports.minMaxBetweenNumbers = exports.controlPoint = exports.line = exports.angleToCoordinates = exports.matches = exports.save = exports.print = exports.canvasOldPhoto = exports.canvasInvert = exports.canvasFade = exports.canvasSaturation = exports.canvasContrast = exports.canvasBrightness = exports.image = exports.valueBreakpoints = exports.iconSizeToFontSize = exports.staticClassName = exports.reflow = void 0;
|
4
4
|
const utils_1 = require("@onesy/utils");
|
5
5
|
function reflow(element) {
|
6
6
|
element === null || element === void 0 ? void 0 : element.offsetHeight;
|
@@ -1420,3 +1420,8 @@ exports.currencies = [
|
|
1420
1420
|
name_plural: 'Zambian kwachas'
|
1421
1421
|
}
|
1422
1422
|
];
|
1423
|
+
const decodeHTMLEntities = (html) => {
|
1424
|
+
const document = new DOMParser().parseFromString(html, 'text/html');
|
1425
|
+
return document.documentElement.textContent || '';
|
1426
|
+
};
|
1427
|
+
exports.decodeHTMLEntities = decodeHTMLEntities;
|