@hero-design/rn 8.108.2 → 8.109.0
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/.turbo/turbo-build.log +3 -9
- package/CHANGELOG.md +6 -0
- package/es/index.js +182 -95
- package/lib/index.js +182 -95
- package/package.json +1 -1
- package/src/components/RichTextEditor/BaseRichTextEditor.tsx +301 -0
- package/src/components/RichTextEditor/EditorToolbar.tsx +11 -20
- package/src/components/RichTextEditor/MentionList.tsx +2 -2
- package/src/components/RichTextEditor/RichTextEditor.tsx +42 -261
- package/src/components/RichTextEditor/StyledRichTextEditor.ts +0 -1
- package/src/components/RichTextEditor/__tests__/RichTextEditor.spec.tsx +8 -8
- package/src/components/RichTextEditor/__tests__/__snapshots__/RichTextEditor.spec.tsx.snap +7 -9
- package/src/components/RichTextEditor/constants.ts +5 -0
- package/src/components/RichTextEditor/hooks/useRichTextEditorEvents.ts +60 -0
- package/src/components/RichTextEditor/index.tsx +10 -2
- package/stats/8.108.2/rn-stats.html +3 -1
- package/stats/8.109.0/rn-stats.html +4844 -0
- package/types/components/RichTextEditor/BaseRichTextEditor.d.ts +69 -0
- package/types/components/RichTextEditor/RichTextEditor.d.ts +2 -45
- package/types/components/RichTextEditor/constants.d.ts +4 -0
- package/types/components/RichTextEditor/hooks/useRichTextEditorEvents.d.ts +21 -0
- package/types/components/RichTextEditor/index.d.ts +14 -2
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(node:
|
|
1
|
+
(node:3326) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
|
|
2
2
|
(Use `node --trace-warnings ...` to show where the warning was created)
|
|
3
3
|
[36m
|
|
4
4
|
[1msrc/index.ts[22m → [1mlib/index.js, es/index.js[22m...[39m
|
|
@@ -8,16 +8,10 @@ node_modules/d3-selection/src/selection/index.js -> node_modules/d3-selection/sr
|
|
|
8
8
|
node_modules/d3-selection/src/selection/index.js -> node_modules/d3-selection/src/selection/filter.js -> node_modules/d3-selection/src/selection/index.js
|
|
9
9
|
...and 12 more
|
|
10
10
|
[1m[33m(!) [plugin replace] @rollup/plugin-replace: 'preventAssignment' currently defaults to false. It is recommended to set this option to `true`, as the next major version will default this option to `true`.[39m[22m
|
|
11
|
-
[1m[33m(!) [plugin typescript] src/components/RichTextEditor/__tests__/RichTextEditor.spec.tsx (61:35): @rollup/plugin-typescript TS2307: Cannot find module '../../../../types' or its corresponding type declarations.[39m[22m
|
|
12
|
-
[1m/home/runner/work/hero-design/hero-design/packages/rn/src/components/RichTextEditor/__tests__/RichTextEditor.spec.tsx:61:35[22m
|
|
13
|
-
[90m
|
|
14
|
-
[7m61[0m import { RichTextEditorRef } from '../../../../types';
|
|
15
|
-
[7m [0m [91m ~~~~~~~~~~~~~~~~~~~[0m
|
|
16
|
-
[39m
|
|
17
11
|
[1m[33m(!) [plugin node-resolve] preferring built-in module 'events' over local alternative at '/home/runner/work/hero-design/hero-design/node_modules/events/events.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning.or passing a function to 'preferBuiltins' to provide more fine-grained control over which built-in modules to prefer.[39m[22m
|
|
18
|
-
[32mcreated [1mlib/index.js, es/index.js[22m in [1m1m 12.
|
|
12
|
+
[32mcreated [1mlib/index.js, es/index.js[22m in [1m1m 12.1s[22m[39m
|
|
19
13
|
[36m
|
|
20
14
|
[1m/home/runner/work/hero-design/hero-design/packages/rn/src/locales/en_AU.ts, /home/runner/work/hero-design/hero-design/packages/rn/src/locales/en_CA.ts, /home/runner/work/hero-design/hero-design/packages/rn/src/locales/index.ts, /home/runner/work/hero-design/hero-design/packages/rn/src/locales/types.ts[22m → [1m., .[22m...[39m
|
|
21
15
|
[1m[33m(!) Generated empty chunks[39m[22m
|
|
22
16
|
"locales/types" and "locales/types"
|
|
23
|
-
[32mcreated [1m., .[22m in [
|
|
17
|
+
[32mcreated [1m., .[22m in [1m20.9s[22m[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @hero-design/rn
|
|
2
2
|
|
|
3
|
+
## 8.109.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#4220](https://github.com/Thinkei/hero-design/pull/4220) [`c7a8a34a159cec6ce2097614ae47c6d6a575a794`](https://github.com/Thinkei/hero-design/commit/c7a8a34a159cec6ce2097614ae47c6d6a575a794) Thanks [@khoaddtran](https://github.com/khoaddtran)! - [RichTextEditor] Introduce RichTextEditor.Base and `useRichTextEditorEvents` hook
|
|
8
|
+
|
|
3
9
|
## 8.108.2
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/es/index.js
CHANGED
|
@@ -28364,9 +28364,11 @@ var ToolbarEvents;
|
|
|
28364
28364
|
ToolbarEvents["HeadingOne"] = "heading-one";
|
|
28365
28365
|
ToolbarEvents["HeadingTwo"] = "heading-two";
|
|
28366
28366
|
})(ToolbarEvents || (ToolbarEvents = {}));
|
|
28367
|
-
|
|
28368
|
-
|
|
28369
|
-
|
|
28367
|
+
var EditorEvents;
|
|
28368
|
+
(function (EditorEvents) {
|
|
28369
|
+
EditorEvents["EditorFocus"] = "editor-focus";
|
|
28370
|
+
EditorEvents["EditorBlur"] = "editor-blur";
|
|
28371
|
+
})(EditorEvents || (EditorEvents = {}));
|
|
28370
28372
|
|
|
28371
28373
|
var StyledToolbarButton = index$c(TouchableOpacity)(function (_ref) {
|
|
28372
28374
|
var theme = _ref.theme,
|
|
@@ -28412,6 +28414,40 @@ var on = function on(emitter, eventName, listener) {
|
|
|
28412
28414
|
};
|
|
28413
28415
|
};
|
|
28414
28416
|
|
|
28417
|
+
var emitter = new EventEmitter();
|
|
28418
|
+
emitter.setMaxListeners(20);
|
|
28419
|
+
|
|
28420
|
+
/**
|
|
28421
|
+
* Hook to subscribe to events for a rich text editor
|
|
28422
|
+
* @param editorName - The name of the editor to subscribe to events for
|
|
28423
|
+
* @returns An object with two functions: emitEvent and subscribeToEvents
|
|
28424
|
+
* @example
|
|
28425
|
+
* const { emitEvent, subscribeToEvents } = useRichTextEditorEvents('editorName');
|
|
28426
|
+
* subscribeToEvents(EditorEvents.EditorFocus, () => {
|
|
28427
|
+
* console.log('Editor focused');
|
|
28428
|
+
* });
|
|
28429
|
+
* emitEvent({ type: EditorEvents.EditorFocus, data: null });
|
|
28430
|
+
*/
|
|
28431
|
+
var useRichTextEditorEvents = function useRichTextEditorEvents(editorName) {
|
|
28432
|
+
var normalizeEventName = useCallback(function (event) {
|
|
28433
|
+
return "".concat(editorName, "/").concat(event);
|
|
28434
|
+
}, [editorName]);
|
|
28435
|
+
var subscribeToEvents = useCallback(function (eventName, onEvent) {
|
|
28436
|
+
return on(emitter, normalizeEventName(eventName), function (eventData) {
|
|
28437
|
+
onEvent(eventData);
|
|
28438
|
+
});
|
|
28439
|
+
}, [normalizeEventName]);
|
|
28440
|
+
var emitEvent = useCallback(function (_ref) {
|
|
28441
|
+
var type = _ref.type,
|
|
28442
|
+
data = _ref.data;
|
|
28443
|
+
emit(emitter, normalizeEventName(type), data);
|
|
28444
|
+
}, [normalizeEventName]);
|
|
28445
|
+
return {
|
|
28446
|
+
emitEvent: emitEvent,
|
|
28447
|
+
subscribeToEvents: subscribeToEvents
|
|
28448
|
+
};
|
|
28449
|
+
};
|
|
28450
|
+
|
|
28415
28451
|
var ToolbarButton = function ToolbarButton(_ref) {
|
|
28416
28452
|
var icon = _ref.icon,
|
|
28417
28453
|
onPress = _ref.onPress,
|
|
@@ -28481,14 +28517,14 @@ var EditorToolbar = function EditorToolbar(_ref2) {
|
|
|
28481
28517
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
28482
28518
|
toolbarButtonArray = _useState4[0],
|
|
28483
28519
|
setToolbarButtonArray = _useState4[1];
|
|
28484
|
-
var
|
|
28485
|
-
|
|
28486
|
-
|
|
28520
|
+
var _useRichTextEditorEve = useRichTextEditorEvents(name),
|
|
28521
|
+
emitEvent = _useRichTextEditorEve.emitEvent,
|
|
28522
|
+
subscribeToEvents = _useRichTextEditorEve.subscribeToEvents;
|
|
28487
28523
|
useEffect(function () {
|
|
28488
|
-
var removeFocusListener =
|
|
28524
|
+
var removeFocusListener = subscribeToEvents(EditorEvents.EditorFocus, function () {
|
|
28489
28525
|
return setShow(true);
|
|
28490
28526
|
});
|
|
28491
|
-
var removeBlurListener =
|
|
28527
|
+
var removeBlurListener = subscribeToEvents(EditorEvents.EditorBlur, function () {
|
|
28492
28528
|
return setShow(false);
|
|
28493
28529
|
});
|
|
28494
28530
|
return function () {
|
|
@@ -28531,7 +28567,10 @@ var EditorToolbar = function EditorToolbar(_ref2) {
|
|
|
28531
28567
|
icon: config.icon,
|
|
28532
28568
|
onPress: function onPress() {
|
|
28533
28569
|
toggleToolbarButton(button);
|
|
28534
|
-
|
|
28570
|
+
emitEvent({
|
|
28571
|
+
type: config.eventName,
|
|
28572
|
+
data: null
|
|
28573
|
+
});
|
|
28535
28574
|
},
|
|
28536
28575
|
selected: button.selected
|
|
28537
28576
|
});
|
|
@@ -28553,7 +28592,7 @@ var isEmptyString = function isEmptyString(s) {
|
|
|
28553
28592
|
var MentionList = function MentionList(_ref) {
|
|
28554
28593
|
var eventPrefix = _ref.name,
|
|
28555
28594
|
render = _ref.render;
|
|
28556
|
-
var theme = useTheme
|
|
28595
|
+
var theme = useTheme();
|
|
28557
28596
|
var _useState = useState(''),
|
|
28558
28597
|
_useState2 = _slicedToArray(_useState, 2),
|
|
28559
28598
|
search = _useState2[0],
|
|
@@ -28586,7 +28625,7 @@ var MentionList = function MentionList(_ref) {
|
|
|
28586
28625
|
var highlighted = options.highlighted,
|
|
28587
28626
|
meta = options.meta;
|
|
28588
28627
|
var highlightStyle = {
|
|
28589
|
-
color: theme.colors.
|
|
28628
|
+
color: theme.colors.primary,
|
|
28590
28629
|
borderRadius: theme.__hd__.richTextEditor.radii.mention,
|
|
28591
28630
|
padding: highlighted ? theme.__hd__.richTextEditor.space.mention : 0,
|
|
28592
28631
|
background: highlighted ? theme.colors.highlightedSurface : 'transparent',
|
|
@@ -47311,8 +47350,7 @@ var StyledWebView = index$c(WebView)(function (_ref2) {
|
|
|
47311
47350
|
minHeight: theme.__hd__.richTextEditor.sizes.editorMinHeight,
|
|
47312
47351
|
backgroundColor: 'transparent',
|
|
47313
47352
|
textAlignVertical: 'center',
|
|
47314
|
-
fontSize: theme.__hd__.textInput.fontSizes.text
|
|
47315
|
-
marginHorizontal: theme.__hd__.textInput.space.inputHorizontalMargin
|
|
47353
|
+
fontSize: theme.__hd__.textInput.fontSizes.text
|
|
47316
47354
|
};
|
|
47317
47355
|
});
|
|
47318
47356
|
|
|
@@ -47324,13 +47362,13 @@ var postMessage = function postMessage(element, message) {
|
|
|
47324
47362
|
element.injectJavaScript("window.postMessage(".concat(messageString, ", '*');"));
|
|
47325
47363
|
};
|
|
47326
47364
|
|
|
47327
|
-
var defaultValue = [{
|
|
47365
|
+
var defaultValue$1 = [{
|
|
47328
47366
|
type: 'paragraph',
|
|
47329
47367
|
children: [{
|
|
47330
47368
|
text: ''
|
|
47331
47369
|
}]
|
|
47332
47370
|
}];
|
|
47333
|
-
var
|
|
47371
|
+
var BaseRichTextEditor = function BaseRichTextEditor(_ref) {
|
|
47334
47372
|
var _ref$autoFocus = _ref.autoFocus,
|
|
47335
47373
|
autoFocus = _ref$autoFocus === void 0 ? true : _ref$autoFocus,
|
|
47336
47374
|
name = _ref.name,
|
|
@@ -47338,18 +47376,15 @@ var RichTextEditor = function RichTextEditor(_ref) {
|
|
|
47338
47376
|
placeholder = _ref$placeholder === void 0 ? '' : _ref$placeholder,
|
|
47339
47377
|
onChange = _ref.onChange,
|
|
47340
47378
|
onCursorChange = _ref.onCursorChange,
|
|
47341
|
-
_ref$error = _ref.error,
|
|
47342
|
-
error = _ref$error === void 0 ? '' : _ref$error,
|
|
47343
47379
|
_ref$style = _ref.style,
|
|
47344
47380
|
style = _ref$style === void 0 ? {} : _ref$style,
|
|
47345
|
-
label = _ref.label,
|
|
47346
|
-
helpText = _ref.helpText,
|
|
47347
|
-
required = _ref.required,
|
|
47348
47381
|
testID = _ref.testID,
|
|
47349
|
-
|
|
47382
|
+
editorRef = _ref.editorRef,
|
|
47350
47383
|
_ref$value = _ref.value,
|
|
47351
|
-
value = _ref$value === void 0 ? defaultValue : _ref$value
|
|
47352
|
-
|
|
47384
|
+
value = _ref$value === void 0 ? defaultValue$1 : _ref$value,
|
|
47385
|
+
onFocus = _ref.onFocus,
|
|
47386
|
+
onBlur = _ref.onBlur;
|
|
47387
|
+
var theme = useTheme();
|
|
47353
47388
|
var webview = useRef(null);
|
|
47354
47389
|
var _useState = useState(),
|
|
47355
47390
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -47359,18 +47394,6 @@ var RichTextEditor = function RichTextEditor(_ref) {
|
|
|
47359
47394
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
47360
47395
|
isFocused = _useState4[0],
|
|
47361
47396
|
setIsFocused = _useState4[1];
|
|
47362
|
-
var isEmptyValue = useMemo(function () {
|
|
47363
|
-
return libExports.isEmptyContent(value);
|
|
47364
|
-
}, [value]);
|
|
47365
|
-
var state = useMemo(function () {
|
|
47366
|
-
if (error) {
|
|
47367
|
-
return 'error';
|
|
47368
|
-
}
|
|
47369
|
-
if (isEmptyValue) {
|
|
47370
|
-
return 'filled';
|
|
47371
|
-
}
|
|
47372
|
-
return 'default';
|
|
47373
|
-
}, [isFocused, error, isEmptyValue]);
|
|
47374
47397
|
var normalizeEventName = function normalizeEventName(event) {
|
|
47375
47398
|
return "".concat(name, "/").concat(event);
|
|
47376
47399
|
};
|
|
@@ -47379,45 +47402,6 @@ var RichTextEditor = function RichTextEditor(_ref) {
|
|
|
47379
47402
|
postMessage(webview.current, message);
|
|
47380
47403
|
}
|
|
47381
47404
|
};
|
|
47382
|
-
var _React$useState = React__default.useState({
|
|
47383
|
-
height: 0,
|
|
47384
|
-
width: 0
|
|
47385
|
-
}),
|
|
47386
|
-
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
47387
|
-
inputSize = _React$useState2[0],
|
|
47388
|
-
setInputSize = _React$useState2[1];
|
|
47389
|
-
var focusAnimation = useRef(new Animated.Value(0)).current;
|
|
47390
|
-
useEffect(function () {
|
|
47391
|
-
Animated.timing(focusAnimation, {
|
|
47392
|
-
toValue: isFocused || !isEmptyValue ? 1 : 0,
|
|
47393
|
-
duration: LABEL_ANIMATION_DURATION,
|
|
47394
|
-
easing: Easing.bezier(0.4, 0, 0.2, 1),
|
|
47395
|
-
useNativeDriver: true
|
|
47396
|
-
}).start();
|
|
47397
|
-
}, [focusAnimation, isEmptyValue, isFocused]);
|
|
47398
|
-
var onLayout = useCallback(function (event) {
|
|
47399
|
-
var _event$nativeEvent$la = event.nativeEvent.layout,
|
|
47400
|
-
height = _event$nativeEvent$la.height,
|
|
47401
|
-
width = _event$nativeEvent$la.width;
|
|
47402
|
-
setInputSize(function (prev) {
|
|
47403
|
-
return _objectSpread2(_objectSpread2({}, prev), {}, {
|
|
47404
|
-
height: height,
|
|
47405
|
-
width: width
|
|
47406
|
-
});
|
|
47407
|
-
});
|
|
47408
|
-
}, []);
|
|
47409
|
-
useEffect(function () {
|
|
47410
|
-
var removeFocusListener = on(emitter, normalizeEventName('editor-focus'), function () {
|
|
47411
|
-
return setIsFocused(true);
|
|
47412
|
-
});
|
|
47413
|
-
var removeBlurListener = on(emitter, normalizeEventName('editor-blur'), function () {
|
|
47414
|
-
return setIsFocused(false);
|
|
47415
|
-
});
|
|
47416
|
-
return function () {
|
|
47417
|
-
removeFocusListener();
|
|
47418
|
-
removeBlurListener();
|
|
47419
|
-
};
|
|
47420
|
-
}, []);
|
|
47421
47405
|
var html = useMemo(function () {
|
|
47422
47406
|
var initialValueString = JSON.stringify(value);
|
|
47423
47407
|
return "\n <!DOCTYPE html>\n <html>\n <head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0\">\n <style>\n body {\n margin: 0;\n }\n </style>\n </head>\n <body>\n <div id=\"root\"></div>\n <script>\n window.__editorConfigs = {\n placeholder: \"".concat(placeholder, "\",\n initialValue: ").concat(initialValueString, ",\n isAndroid: ").concat(isAndroid ? 'true' : 'false', ",\n autoFocus: ").concat(autoFocus, ",\n style: {\n padding: '0 !important',\n fontSize: ").concat(theme.__hd__.richTextEditor.fontSizes.editor, ",\n color: '").concat(theme.__hd__.richTextEditor.colors.text, "'\n }\n };\n ").concat(heroEditorApp, "\n </script>\n </body>\n </html>\n ");
|
|
@@ -47451,7 +47435,7 @@ var RichTextEditor = function RichTextEditor(_ref) {
|
|
|
47451
47435
|
}
|
|
47452
47436
|
});
|
|
47453
47437
|
}, []);
|
|
47454
|
-
useImperativeHandle(
|
|
47438
|
+
useImperativeHandle(editorRef, function () {
|
|
47455
47439
|
return {
|
|
47456
47440
|
requestBlur: requestBlur,
|
|
47457
47441
|
insertNodes: insertNodes,
|
|
@@ -47499,9 +47483,13 @@ var RichTextEditor = function RichTextEditor(_ref) {
|
|
|
47499
47483
|
var messageData = message === null || message === void 0 ? void 0 : message.data;
|
|
47500
47484
|
switch (messageType) {
|
|
47501
47485
|
case '@hero-editor/webview/editor-focus':
|
|
47486
|
+
onFocus === null || onFocus === void 0 || onFocus();
|
|
47487
|
+
setIsFocused(true);
|
|
47502
47488
|
emit(emitter, normalizeEventName('editor-focus'), undefined);
|
|
47503
47489
|
break;
|
|
47504
47490
|
case '@hero-editor/webview/editor-blur':
|
|
47491
|
+
onBlur === null || onBlur === void 0 || onBlur();
|
|
47492
|
+
setIsFocused(false);
|
|
47505
47493
|
emit(emitter, normalizeEventName('editor-blur'), undefined);
|
|
47506
47494
|
break;
|
|
47507
47495
|
case '@hero-editor/webview/mention-search':
|
|
@@ -47519,7 +47507,107 @@ var RichTextEditor = function RichTextEditor(_ref) {
|
|
|
47519
47507
|
handleEditorLayoutEvent(messageData);
|
|
47520
47508
|
break;
|
|
47521
47509
|
}
|
|
47510
|
+
}, [onFocus, onBlur]);
|
|
47511
|
+
return /*#__PURE__*/React__default.createElement(TouchableWithoutFeedback, {
|
|
47512
|
+
onPress: function onPress(e) {
|
|
47513
|
+
return e.stopPropagation();
|
|
47514
|
+
}
|
|
47515
|
+
}, /*#__PURE__*/React__default.createElement(StyledWebView, {
|
|
47516
|
+
hideKeyboardAccessoryView: true,
|
|
47517
|
+
ref: webview,
|
|
47518
|
+
testID: testID,
|
|
47519
|
+
source: {
|
|
47520
|
+
html: html
|
|
47521
|
+
},
|
|
47522
|
+
onMessage: onMessage,
|
|
47523
|
+
scrollEnabled: false,
|
|
47524
|
+
originWhitelist: ['*'],
|
|
47525
|
+
keyboardDisplayRequiresUserAction: false,
|
|
47526
|
+
style: StyleSheet$1.flatten([style, {
|
|
47527
|
+
height: webviewHeight
|
|
47528
|
+
}])
|
|
47529
|
+
}));
|
|
47530
|
+
};
|
|
47531
|
+
|
|
47532
|
+
var defaultValue = [{
|
|
47533
|
+
type: 'paragraph',
|
|
47534
|
+
children: [{
|
|
47535
|
+
text: ''
|
|
47536
|
+
}]
|
|
47537
|
+
}];
|
|
47538
|
+
var RichTextEditor = function RichTextEditor(_ref) {
|
|
47539
|
+
var _ref$autoFocus = _ref.autoFocus,
|
|
47540
|
+
autoFocus = _ref$autoFocus === void 0 ? true : _ref$autoFocus,
|
|
47541
|
+
name = _ref.name,
|
|
47542
|
+
_ref$placeholder = _ref.placeholder,
|
|
47543
|
+
placeholder = _ref$placeholder === void 0 ? '' : _ref$placeholder,
|
|
47544
|
+
onChange = _ref.onChange,
|
|
47545
|
+
onCursorChange = _ref.onCursorChange,
|
|
47546
|
+
_ref$error = _ref.error,
|
|
47547
|
+
error = _ref$error === void 0 ? '' : _ref$error,
|
|
47548
|
+
_ref$style = _ref.style,
|
|
47549
|
+
style = _ref$style === void 0 ? {} : _ref$style,
|
|
47550
|
+
label = _ref.label,
|
|
47551
|
+
helpText = _ref.helpText,
|
|
47552
|
+
required = _ref.required,
|
|
47553
|
+
testID = _ref.testID,
|
|
47554
|
+
onFocus = _ref.onFocus,
|
|
47555
|
+
onBlur = _ref.onBlur,
|
|
47556
|
+
forwardedRef = _ref.forwardedRef,
|
|
47557
|
+
_ref$value = _ref.value,
|
|
47558
|
+
value = _ref$value === void 0 ? defaultValue : _ref$value;
|
|
47559
|
+
var theme = useTheme();
|
|
47560
|
+
var _useState = useState(false),
|
|
47561
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
47562
|
+
isFocused = _useState2[0],
|
|
47563
|
+
setIsFocused = _useState2[1];
|
|
47564
|
+
var isEmptyValue = useMemo(function () {
|
|
47565
|
+
return libExports.isEmptyContent(value);
|
|
47566
|
+
}, [value]);
|
|
47567
|
+
var state = useMemo(function () {
|
|
47568
|
+
if (error) {
|
|
47569
|
+
return 'error';
|
|
47570
|
+
}
|
|
47571
|
+
if (isEmptyValue) {
|
|
47572
|
+
return 'filled';
|
|
47573
|
+
}
|
|
47574
|
+
return 'default';
|
|
47575
|
+
}, [isFocused, error, isEmptyValue]);
|
|
47576
|
+
var _React$useState = React__default.useState({
|
|
47577
|
+
height: 0,
|
|
47578
|
+
width: 0
|
|
47579
|
+
}),
|
|
47580
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
47581
|
+
inputSize = _React$useState2[0],
|
|
47582
|
+
setInputSize = _React$useState2[1];
|
|
47583
|
+
var focusAnimation = useRef(new Animated.Value(0)).current;
|
|
47584
|
+
useEffect(function () {
|
|
47585
|
+
Animated.timing(focusAnimation, {
|
|
47586
|
+
toValue: isFocused || !isEmptyValue ? 1 : 0,
|
|
47587
|
+
duration: LABEL_ANIMATION_DURATION,
|
|
47588
|
+
easing: Easing.bezier(0.4, 0, 0.2, 1),
|
|
47589
|
+
useNativeDriver: true
|
|
47590
|
+
}).start();
|
|
47591
|
+
}, [focusAnimation, isEmptyValue, isFocused]);
|
|
47592
|
+
var onLayout = useCallback(function (event) {
|
|
47593
|
+
var _event$nativeEvent$la = event.nativeEvent.layout,
|
|
47594
|
+
height = _event$nativeEvent$la.height,
|
|
47595
|
+
width = _event$nativeEvent$la.width;
|
|
47596
|
+
setInputSize(function (prev) {
|
|
47597
|
+
return _objectSpread2(_objectSpread2({}, prev), {}, {
|
|
47598
|
+
height: height,
|
|
47599
|
+
width: width
|
|
47600
|
+
});
|
|
47601
|
+
});
|
|
47522
47602
|
}, []);
|
|
47603
|
+
var handleEditorFocus = useCallback(function () {
|
|
47604
|
+
onFocus === null || onFocus === void 0 || onFocus();
|
|
47605
|
+
setIsFocused(true);
|
|
47606
|
+
}, [onFocus]);
|
|
47607
|
+
var handleEditorBlur = useCallback(function () {
|
|
47608
|
+
onBlur === null || onBlur === void 0 || onBlur();
|
|
47609
|
+
setIsFocused(false);
|
|
47610
|
+
}, [onBlur]);
|
|
47523
47611
|
return /*#__PURE__*/React__default.createElement(StyledContainer$6, {
|
|
47524
47612
|
testID: testID
|
|
47525
47613
|
}, /*#__PURE__*/React__default.createElement(StyledLabelContainerInsideTextInput, {
|
|
@@ -47561,27 +47649,22 @@ var RichTextEditor = function RichTextEditor(_ref) {
|
|
|
47561
47649
|
themeState: state,
|
|
47562
47650
|
themeFocused: isFocused
|
|
47563
47651
|
}), /*#__PURE__*/React__default.createElement(StyledTextInputAndLabelContainer, {
|
|
47564
|
-
style: {
|
|
47565
|
-
height: webviewHeight
|
|
47566
|
-
},
|
|
47567
47652
|
testID: "webViewWrapper"
|
|
47568
|
-
}, /*#__PURE__*/React__default.createElement(
|
|
47569
|
-
|
|
47570
|
-
|
|
47571
|
-
|
|
47572
|
-
|
|
47573
|
-
|
|
47653
|
+
}, /*#__PURE__*/React__default.createElement(BaseRichTextEditor, {
|
|
47654
|
+
name: name,
|
|
47655
|
+
value: value,
|
|
47656
|
+
style: [style, {
|
|
47657
|
+
marginHorizontal: theme.__hd__.textInput.space.inputHorizontalMargin
|
|
47658
|
+
}],
|
|
47574
47659
|
testID: "webview",
|
|
47575
|
-
|
|
47576
|
-
|
|
47577
|
-
|
|
47578
|
-
|
|
47579
|
-
|
|
47580
|
-
|
|
47581
|
-
|
|
47582
|
-
|
|
47583
|
-
keyboardDisplayRequiresUserAction: false
|
|
47584
|
-
})))), /*#__PURE__*/React__default.createElement(StyledErrorAndHelpTextContainer, null, /*#__PURE__*/React__default.createElement(StyledErrorAndMaxLengthContainer, null, error ? /*#__PURE__*/React__default.createElement(StyledErrorContainer$2, null, /*#__PURE__*/React__default.createElement(Icon, {
|
|
47660
|
+
onChange: onChange,
|
|
47661
|
+
autoFocus: autoFocus,
|
|
47662
|
+
editorRef: forwardedRef,
|
|
47663
|
+
placeholder: placeholder,
|
|
47664
|
+
onBlur: handleEditorBlur,
|
|
47665
|
+
onFocus: handleEditorFocus,
|
|
47666
|
+
onCursorChange: onCursorChange
|
|
47667
|
+
}))), /*#__PURE__*/React__default.createElement(StyledErrorAndHelpTextContainer, null, /*#__PURE__*/React__default.createElement(StyledErrorAndMaxLengthContainer, null, error ? /*#__PURE__*/React__default.createElement(StyledErrorContainer$2, null, /*#__PURE__*/React__default.createElement(Icon, {
|
|
47585
47668
|
testID: "input-error-icon",
|
|
47586
47669
|
icon: "circle-info",
|
|
47587
47670
|
size: "xsmall",
|
|
@@ -47598,8 +47681,12 @@ var RichTextEditorWithRef = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
47598
47681
|
RichTextEditorWithRef.displayName = 'RichTextEditor';
|
|
47599
47682
|
|
|
47600
47683
|
var index = Object.assign(RichTextEditorWithRef, {
|
|
47684
|
+
Toolbar: EditorToolbar,
|
|
47601
47685
|
MentionList: MentionList,
|
|
47602
|
-
|
|
47686
|
+
EditorEvents: EditorEvents,
|
|
47687
|
+
ToolbarEvents: ToolbarEvents,
|
|
47688
|
+
useRichTextEditorEvents: useRichTextEditorEvents,
|
|
47689
|
+
Base: BaseRichTextEditor
|
|
47603
47690
|
});
|
|
47604
47691
|
|
|
47605
47692
|
var LAST_BREAKPOINT = 100;
|