@onesy/ui-react 1.0.13 → 1.0.15
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.
@@ -197,9 +197,8 @@ const SmartTextField = react_1.default.forwardRef((props_, ref) => {
|
|
197
197
|
init();
|
198
198
|
}, []);
|
199
199
|
react_1.default.useEffect(() => {
|
200
|
-
|
201
|
-
|
202
|
-
}, [optionsMention_]);
|
200
|
+
setOptionsMention([...(optionsMention_ || [])]);
|
201
|
+
}, [(0, utils_1.hash)(optionsMention_)]);
|
203
202
|
react_1.default.useEffect(() => {
|
204
203
|
const valuePrevious = (refs.root.current.innerHTML || '').replaceAll(' ', ' ');
|
205
204
|
const valueNew = (0, utils_1.textToInnerHTML)(value_);
|
@@ -472,7 +471,7 @@ const SmartTextField = react_1.default.forwardRef((props_, ref) => {
|
|
472
471
|
if (mention) {
|
473
472
|
if (refs.openMenu.current && !optionsMention.length)
|
474
473
|
onCloseSearch();
|
475
|
-
else if (!refs.openMenu.current &&
|
474
|
+
else if (!refs.openMenu.current && !!optionsMention.length)
|
476
475
|
onOpenSearch();
|
477
476
|
}
|
478
477
|
}, [mention, optionsMention]);
|
@@ -493,14 +492,11 @@ const SmartTextField = react_1.default.forwardRef((props_, ref) => {
|
|
493
492
|
react_1.default.useEffect(() => {
|
494
493
|
// setError(error_);
|
495
494
|
}, [error_]);
|
496
|
-
const label = react_1.default.useCallback(() => {
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
return ((0, jsx_runtime_1.jsx)(ListItem, { start: ((0, jsx_runtime_1.jsx)(Avatar, Object.assign({ color: (0, utils_1.stringToColor)(item.name), size: 'small' }, { children: (_a = item.name) === null || _a === void 0 ? void 0 : _a.slice(0, 1) }))), primary: ((0, jsx_runtime_1.jsx)(Type, Object.assign({ version: 'l3' }, { children: item.name }))), onClick: () => addTag(item), button: true }, index));
|
502
|
-
}) })) })));
|
503
|
-
}, []);
|
495
|
+
const label = react_1.default.useCallback(() => ((0, utils_1.is)('function', mentionLabel) ? mentionLabel(optionsMention, { addTag }) :
|
496
|
+
(0, jsx_runtime_1.jsx)(Line, Object.assign({ className: classes.menu }, { children: (0, jsx_runtime_1.jsx)(List, Object.assign({ size: 'small', className: classes.list }, { children: optionsMention === null || optionsMention === void 0 ? void 0 : optionsMention.map((item, index) => {
|
497
|
+
var _a;
|
498
|
+
return ((0, jsx_runtime_1.jsx)(ListItem, { start: ((0, jsx_runtime_1.jsx)(Avatar, Object.assign({ color: (0, utils_1.stringToColor)(item.name), size: 'small' }, { children: (_a = item.name) === null || _a === void 0 ? void 0 : _a.slice(0, 1) }))), primary: ((0, jsx_runtime_1.jsx)(Type, Object.assign({ version: 'l3' }, { children: item.name }))), onClick: () => addTag(item), button: true }, index));
|
499
|
+
}) })) }))), [optionsMention]);
|
504
500
|
const paste = async () => {
|
505
501
|
const valueClipboard = await navigator.clipboard.read();
|
506
502
|
if (valueClipboard) {
|
@@ -728,7 +724,7 @@ const SmartTextField = react_1.default.forwardRef((props_, ref) => {
|
|
728
724
|
}, [open, textSelection, textSelected]);
|
729
725
|
const menu = react_1.default.useMemo(() => {
|
730
726
|
return ((0, jsx_runtime_1.jsx)(Menu, { open: openMenu, position: 'top', alignment: 'start', offset: offset, anchor: selectionMenu, onClose: onCloseSearch, label: label(), interactive: true }));
|
731
|
-
}, [openMenu, selectionMenu, label]);
|
727
|
+
}, [openMenu, optionsMention, selectionMenu, label]);
|
732
728
|
let main = ((0, jsx_runtime_1.jsx)(TextField, Object.assign({ ref: (item) => {
|
733
729
|
if (ref) {
|
734
730
|
if ((0, utils_1.is)('function', ref))
|
@@ -8,7 +8,7 @@ const _excluded = ["version", "size", "valueDefault", "value", "inputProps", "on
|
|
8
8
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
9
9
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
10
10
|
import React from 'react';
|
11
|
-
import { innerHTMLToText, is, isEnvironment, parse, stringToColor, textToInnerHTML } from '@onesy/utils';
|
11
|
+
import { hash, innerHTMLToText, is, isEnvironment, parse, stringToColor, textToInnerHTML } from '@onesy/utils';
|
12
12
|
import { classNames, style as styleMethod, useOnesyTheme } from '@onesy/style-react';
|
13
13
|
import IconMaterialFormatItalic from '@onesy/icons-material-rounded-react/IconMaterialFormatItalicW100';
|
14
14
|
import IconMaterialFormatUnderlined from '@onesy/icons-material-rounded-react/IconMaterialFormatUnderlinedW100';
|
@@ -223,8 +223,8 @@ const SmartTextField = /*#__PURE__*/React.forwardRef((props_, ref) => {
|
|
223
223
|
init();
|
224
224
|
}, []);
|
225
225
|
React.useEffect(() => {
|
226
|
-
|
227
|
-
}, [optionsMention_]);
|
226
|
+
setOptionsMention([...(optionsMention_ || [])]);
|
227
|
+
}, [hash(optionsMention_)]);
|
228
228
|
React.useEffect(() => {
|
229
229
|
const valuePrevious = (refs.root.current.innerHTML || '').replaceAll(' ', ' ');
|
230
230
|
const valueNew = textToInnerHTML(value_);
|
@@ -491,7 +491,7 @@ const SmartTextField = /*#__PURE__*/React.forwardRef((props_, ref) => {
|
|
491
491
|
// else if no users response & opened, close the search
|
492
492
|
React.useEffect(() => {
|
493
493
|
if (mention) {
|
494
|
-
if (refs.openMenu.current && !optionsMention.length) onCloseSearch();else if (!refs.openMenu.current &&
|
494
|
+
if (refs.openMenu.current && !optionsMention.length) onCloseSearch();else if (!refs.openMenu.current && !!optionsMention.length) onOpenSearch();
|
495
495
|
}
|
496
496
|
}, [mention, optionsMention]);
|
497
497
|
React.useEffect(() => {
|
@@ -511,14 +511,14 @@ const SmartTextField = /*#__PURE__*/React.forwardRef((props_, ref) => {
|
|
511
511
|
React.useEffect(() => {
|
512
512
|
// setError(error_);
|
513
513
|
}, [error_]);
|
514
|
-
const label = React.useCallback(() => is('function', mentionLabel) ? mentionLabel(
|
514
|
+
const label = React.useCallback(() => is('function', mentionLabel) ? mentionLabel(optionsMention, {
|
515
515
|
addTag
|
516
516
|
}) : /*#__PURE__*/React.createElement(Line, {
|
517
517
|
className: classes.menu
|
518
518
|
}, /*#__PURE__*/React.createElement(List, {
|
519
519
|
size: "small",
|
520
520
|
className: classes.list
|
521
|
-
},
|
521
|
+
}, optionsMention?.map((item, index) => /*#__PURE__*/React.createElement(ListItem, {
|
522
522
|
key: index,
|
523
523
|
start: /*#__PURE__*/React.createElement(Avatar, {
|
524
524
|
color: stringToColor(item.name),
|
@@ -529,7 +529,7 @@ const SmartTextField = /*#__PURE__*/React.forwardRef((props_, ref) => {
|
|
529
529
|
}, item.name),
|
530
530
|
onClick: () => addTag(item),
|
531
531
|
button: true
|
532
|
-
})))), []);
|
532
|
+
})))), [optionsMention]);
|
533
533
|
const paste = async () => {
|
534
534
|
const valueClipboard = await navigator.clipboard.read();
|
535
535
|
if (valueClipboard) {
|
@@ -882,7 +882,7 @@ const SmartTextField = /*#__PURE__*/React.forwardRef((props_, ref) => {
|
|
882
882
|
label: label(),
|
883
883
|
interactive: true
|
884
884
|
});
|
885
|
-
}, [openMenu, selectionMenu, label]);
|
885
|
+
}, [openMenu, optionsMention, selectionMenu, label]);
|
886
886
|
let main = /*#__PURE__*/React.createElement(TextField, _extends({
|
887
887
|
ref: item => {
|
888
888
|
if (ref) {
|
package/esm/index.js
CHANGED