@hero-design/rn 8.108.3-alpha.0 → 8.109.1
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 -5
- package/es/index.js +186 -96
- package/lib/index.js +186 -96
- package/package.json +2 -2
- package/src/components/Button/Button.tsx +3 -2
- package/src/components/Button/__tests__/Button.spec.tsx +9 -0
- 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.109.0/rn-stats.html +4842 -0
- package/stats/8.109.1/rn-stats.html +4842 -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:3341) 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
|
+
[32mcreated [1mlib/index.js, es/index.js[22m in [1m1m 12.6s[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 [1m21.
|
|
17
|
+
[32mcreated [1m., .[22m in [1m21.1s[22m[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
# @hero-design/rn
|
|
2
2
|
|
|
3
|
-
## 8.
|
|
3
|
+
## 8.109.1
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
- [#
|
|
7
|
+
- [#4236](https://github.com/Thinkei/hero-design/pull/4236) [`a873d35cddd56b5302bd4d0f95a2dfa887be995e`](https://github.com/Thinkei/hero-design/commit/a873d35cddd56b5302bd4d0f95a2dfa887be995e) Thanks [@cuongnguyeneh](https://github.com/cuongnguyeneh)! - [Button] call onPress callback with no args
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## 8.109.0
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#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
|
|
13
14
|
|
|
14
15
|
## 8.108.2
|
|
15
16
|
|
package/es/index.js
CHANGED
|
@@ -10932,6 +10932,9 @@ var Button = function Button(_ref) {
|
|
|
10932
10932
|
_useState2 = _slicedToArray(_useState, 2),
|
|
10933
10933
|
isPressed = _useState2[0],
|
|
10934
10934
|
setIsPressed = _useState2[1];
|
|
10935
|
+
var handlePress = useCallback(function () {
|
|
10936
|
+
return onPress();
|
|
10937
|
+
}, [onPress]);
|
|
10935
10938
|
useDeprecation("Button variant ".concat(deprecatedVariants.join(', '), " are deprecated."), deprecatedVariants.includes(themeVariant));
|
|
10936
10939
|
var isCompactVariant = ['filled-compact', 'outlined-compact', 'text-compact', 'inline-text-compact'].includes(variant);
|
|
10937
10940
|
var isMediumVariant = ['filled-medium', 'outlined-medium', 'text-medium'].includes(variant);
|
|
@@ -10981,7 +10984,7 @@ var Button = function Button(_ref) {
|
|
|
10981
10984
|
accessibilityLabel: accessibilityLabel,
|
|
10982
10985
|
disabled: disabled || loading,
|
|
10983
10986
|
loading: loading,
|
|
10984
|
-
onPress:
|
|
10987
|
+
onPress: handlePress,
|
|
10985
10988
|
testID: testID,
|
|
10986
10989
|
themeButtonVariant: themeVariant,
|
|
10987
10990
|
style: style,
|
|
@@ -28364,9 +28367,11 @@ var ToolbarEvents;
|
|
|
28364
28367
|
ToolbarEvents["HeadingOne"] = "heading-one";
|
|
28365
28368
|
ToolbarEvents["HeadingTwo"] = "heading-two";
|
|
28366
28369
|
})(ToolbarEvents || (ToolbarEvents = {}));
|
|
28367
|
-
|
|
28368
|
-
|
|
28369
|
-
|
|
28370
|
+
var EditorEvents;
|
|
28371
|
+
(function (EditorEvents) {
|
|
28372
|
+
EditorEvents["EditorFocus"] = "editor-focus";
|
|
28373
|
+
EditorEvents["EditorBlur"] = "editor-blur";
|
|
28374
|
+
})(EditorEvents || (EditorEvents = {}));
|
|
28370
28375
|
|
|
28371
28376
|
var StyledToolbarButton = index$c(TouchableOpacity)(function (_ref) {
|
|
28372
28377
|
var theme = _ref.theme,
|
|
@@ -28412,6 +28417,40 @@ var on = function on(emitter, eventName, listener) {
|
|
|
28412
28417
|
};
|
|
28413
28418
|
};
|
|
28414
28419
|
|
|
28420
|
+
var emitter = new EventEmitter();
|
|
28421
|
+
emitter.setMaxListeners(20);
|
|
28422
|
+
|
|
28423
|
+
/**
|
|
28424
|
+
* Hook to subscribe to events for a rich text editor
|
|
28425
|
+
* @param editorName - The name of the editor to subscribe to events for
|
|
28426
|
+
* @returns An object with two functions: emitEvent and subscribeToEvents
|
|
28427
|
+
* @example
|
|
28428
|
+
* const { emitEvent, subscribeToEvents } = useRichTextEditorEvents('editorName');
|
|
28429
|
+
* subscribeToEvents(EditorEvents.EditorFocus, () => {
|
|
28430
|
+
* console.log('Editor focused');
|
|
28431
|
+
* });
|
|
28432
|
+
* emitEvent({ type: EditorEvents.EditorFocus, data: null });
|
|
28433
|
+
*/
|
|
28434
|
+
var useRichTextEditorEvents = function useRichTextEditorEvents(editorName) {
|
|
28435
|
+
var normalizeEventName = useCallback(function (event) {
|
|
28436
|
+
return "".concat(editorName, "/").concat(event);
|
|
28437
|
+
}, [editorName]);
|
|
28438
|
+
var subscribeToEvents = useCallback(function (eventName, onEvent) {
|
|
28439
|
+
return on(emitter, normalizeEventName(eventName), function (eventData) {
|
|
28440
|
+
onEvent(eventData);
|
|
28441
|
+
});
|
|
28442
|
+
}, [normalizeEventName]);
|
|
28443
|
+
var emitEvent = useCallback(function (_ref) {
|
|
28444
|
+
var type = _ref.type,
|
|
28445
|
+
data = _ref.data;
|
|
28446
|
+
emit(emitter, normalizeEventName(type), data);
|
|
28447
|
+
}, [normalizeEventName]);
|
|
28448
|
+
return {
|
|
28449
|
+
emitEvent: emitEvent,
|
|
28450
|
+
subscribeToEvents: subscribeToEvents
|
|
28451
|
+
};
|
|
28452
|
+
};
|
|
28453
|
+
|
|
28415
28454
|
var ToolbarButton = function ToolbarButton(_ref) {
|
|
28416
28455
|
var icon = _ref.icon,
|
|
28417
28456
|
onPress = _ref.onPress,
|
|
@@ -28481,14 +28520,14 @@ var EditorToolbar = function EditorToolbar(_ref2) {
|
|
|
28481
28520
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
28482
28521
|
toolbarButtonArray = _useState4[0],
|
|
28483
28522
|
setToolbarButtonArray = _useState4[1];
|
|
28484
|
-
var
|
|
28485
|
-
|
|
28486
|
-
|
|
28523
|
+
var _useRichTextEditorEve = useRichTextEditorEvents(name),
|
|
28524
|
+
emitEvent = _useRichTextEditorEve.emitEvent,
|
|
28525
|
+
subscribeToEvents = _useRichTextEditorEve.subscribeToEvents;
|
|
28487
28526
|
useEffect(function () {
|
|
28488
|
-
var removeFocusListener =
|
|
28527
|
+
var removeFocusListener = subscribeToEvents(EditorEvents.EditorFocus, function () {
|
|
28489
28528
|
return setShow(true);
|
|
28490
28529
|
});
|
|
28491
|
-
var removeBlurListener =
|
|
28530
|
+
var removeBlurListener = subscribeToEvents(EditorEvents.EditorBlur, function () {
|
|
28492
28531
|
return setShow(false);
|
|
28493
28532
|
});
|
|
28494
28533
|
return function () {
|
|
@@ -28531,7 +28570,10 @@ var EditorToolbar = function EditorToolbar(_ref2) {
|
|
|
28531
28570
|
icon: config.icon,
|
|
28532
28571
|
onPress: function onPress() {
|
|
28533
28572
|
toggleToolbarButton(button);
|
|
28534
|
-
|
|
28573
|
+
emitEvent({
|
|
28574
|
+
type: config.eventName,
|
|
28575
|
+
data: null
|
|
28576
|
+
});
|
|
28535
28577
|
},
|
|
28536
28578
|
selected: button.selected
|
|
28537
28579
|
});
|
|
@@ -28553,7 +28595,7 @@ var isEmptyString = function isEmptyString(s) {
|
|
|
28553
28595
|
var MentionList = function MentionList(_ref) {
|
|
28554
28596
|
var eventPrefix = _ref.name,
|
|
28555
28597
|
render = _ref.render;
|
|
28556
|
-
var theme = useTheme
|
|
28598
|
+
var theme = useTheme();
|
|
28557
28599
|
var _useState = useState(''),
|
|
28558
28600
|
_useState2 = _slicedToArray(_useState, 2),
|
|
28559
28601
|
search = _useState2[0],
|
|
@@ -28586,7 +28628,7 @@ var MentionList = function MentionList(_ref) {
|
|
|
28586
28628
|
var highlighted = options.highlighted,
|
|
28587
28629
|
meta = options.meta;
|
|
28588
28630
|
var highlightStyle = {
|
|
28589
|
-
color: theme.colors.
|
|
28631
|
+
color: theme.colors.primary,
|
|
28590
28632
|
borderRadius: theme.__hd__.richTextEditor.radii.mention,
|
|
28591
28633
|
padding: highlighted ? theme.__hd__.richTextEditor.space.mention : 0,
|
|
28592
28634
|
background: highlighted ? theme.colors.highlightedSurface : 'transparent',
|
|
@@ -47311,8 +47353,7 @@ var StyledWebView = index$c(WebView)(function (_ref2) {
|
|
|
47311
47353
|
minHeight: theme.__hd__.richTextEditor.sizes.editorMinHeight,
|
|
47312
47354
|
backgroundColor: 'transparent',
|
|
47313
47355
|
textAlignVertical: 'center',
|
|
47314
|
-
fontSize: theme.__hd__.textInput.fontSizes.text
|
|
47315
|
-
marginHorizontal: theme.__hd__.textInput.space.inputHorizontalMargin
|
|
47356
|
+
fontSize: theme.__hd__.textInput.fontSizes.text
|
|
47316
47357
|
};
|
|
47317
47358
|
});
|
|
47318
47359
|
|
|
@@ -47324,13 +47365,13 @@ var postMessage = function postMessage(element, message) {
|
|
|
47324
47365
|
element.injectJavaScript("window.postMessage(".concat(messageString, ", '*');"));
|
|
47325
47366
|
};
|
|
47326
47367
|
|
|
47327
|
-
var defaultValue = [{
|
|
47368
|
+
var defaultValue$1 = [{
|
|
47328
47369
|
type: 'paragraph',
|
|
47329
47370
|
children: [{
|
|
47330
47371
|
text: ''
|
|
47331
47372
|
}]
|
|
47332
47373
|
}];
|
|
47333
|
-
var
|
|
47374
|
+
var BaseRichTextEditor = function BaseRichTextEditor(_ref) {
|
|
47334
47375
|
var _ref$autoFocus = _ref.autoFocus,
|
|
47335
47376
|
autoFocus = _ref$autoFocus === void 0 ? true : _ref$autoFocus,
|
|
47336
47377
|
name = _ref.name,
|
|
@@ -47338,18 +47379,15 @@ var RichTextEditor = function RichTextEditor(_ref) {
|
|
|
47338
47379
|
placeholder = _ref$placeholder === void 0 ? '' : _ref$placeholder,
|
|
47339
47380
|
onChange = _ref.onChange,
|
|
47340
47381
|
onCursorChange = _ref.onCursorChange,
|
|
47341
|
-
_ref$error = _ref.error,
|
|
47342
|
-
error = _ref$error === void 0 ? '' : _ref$error,
|
|
47343
47382
|
_ref$style = _ref.style,
|
|
47344
47383
|
style = _ref$style === void 0 ? {} : _ref$style,
|
|
47345
|
-
label = _ref.label,
|
|
47346
|
-
helpText = _ref.helpText,
|
|
47347
|
-
required = _ref.required,
|
|
47348
47384
|
testID = _ref.testID,
|
|
47349
|
-
|
|
47385
|
+
editorRef = _ref.editorRef,
|
|
47350
47386
|
_ref$value = _ref.value,
|
|
47351
|
-
value = _ref$value === void 0 ? defaultValue : _ref$value
|
|
47352
|
-
|
|
47387
|
+
value = _ref$value === void 0 ? defaultValue$1 : _ref$value,
|
|
47388
|
+
onFocus = _ref.onFocus,
|
|
47389
|
+
onBlur = _ref.onBlur;
|
|
47390
|
+
var theme = useTheme();
|
|
47353
47391
|
var webview = useRef(null);
|
|
47354
47392
|
var _useState = useState(),
|
|
47355
47393
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -47359,18 +47397,6 @@ var RichTextEditor = function RichTextEditor(_ref) {
|
|
|
47359
47397
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
47360
47398
|
isFocused = _useState4[0],
|
|
47361
47399
|
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
47400
|
var normalizeEventName = function normalizeEventName(event) {
|
|
47375
47401
|
return "".concat(name, "/").concat(event);
|
|
47376
47402
|
};
|
|
@@ -47379,45 +47405,6 @@ var RichTextEditor = function RichTextEditor(_ref) {
|
|
|
47379
47405
|
postMessage(webview.current, message);
|
|
47380
47406
|
}
|
|
47381
47407
|
};
|
|
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
47408
|
var html = useMemo(function () {
|
|
47422
47409
|
var initialValueString = JSON.stringify(value);
|
|
47423
47410
|
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 +47438,7 @@ var RichTextEditor = function RichTextEditor(_ref) {
|
|
|
47451
47438
|
}
|
|
47452
47439
|
});
|
|
47453
47440
|
}, []);
|
|
47454
|
-
useImperativeHandle(
|
|
47441
|
+
useImperativeHandle(editorRef, function () {
|
|
47455
47442
|
return {
|
|
47456
47443
|
requestBlur: requestBlur,
|
|
47457
47444
|
insertNodes: insertNodes,
|
|
@@ -47499,9 +47486,13 @@ var RichTextEditor = function RichTextEditor(_ref) {
|
|
|
47499
47486
|
var messageData = message === null || message === void 0 ? void 0 : message.data;
|
|
47500
47487
|
switch (messageType) {
|
|
47501
47488
|
case '@hero-editor/webview/editor-focus':
|
|
47489
|
+
onFocus === null || onFocus === void 0 || onFocus();
|
|
47490
|
+
setIsFocused(true);
|
|
47502
47491
|
emit(emitter, normalizeEventName('editor-focus'), undefined);
|
|
47503
47492
|
break;
|
|
47504
47493
|
case '@hero-editor/webview/editor-blur':
|
|
47494
|
+
onBlur === null || onBlur === void 0 || onBlur();
|
|
47495
|
+
setIsFocused(false);
|
|
47505
47496
|
emit(emitter, normalizeEventName('editor-blur'), undefined);
|
|
47506
47497
|
break;
|
|
47507
47498
|
case '@hero-editor/webview/mention-search':
|
|
@@ -47519,7 +47510,107 @@ var RichTextEditor = function RichTextEditor(_ref) {
|
|
|
47519
47510
|
handleEditorLayoutEvent(messageData);
|
|
47520
47511
|
break;
|
|
47521
47512
|
}
|
|
47513
|
+
}, [onFocus, onBlur]);
|
|
47514
|
+
return /*#__PURE__*/React__default.createElement(TouchableWithoutFeedback, {
|
|
47515
|
+
onPress: function onPress(e) {
|
|
47516
|
+
return e.stopPropagation();
|
|
47517
|
+
}
|
|
47518
|
+
}, /*#__PURE__*/React__default.createElement(StyledWebView, {
|
|
47519
|
+
hideKeyboardAccessoryView: true,
|
|
47520
|
+
ref: webview,
|
|
47521
|
+
testID: testID,
|
|
47522
|
+
source: {
|
|
47523
|
+
html: html
|
|
47524
|
+
},
|
|
47525
|
+
onMessage: onMessage,
|
|
47526
|
+
scrollEnabled: false,
|
|
47527
|
+
originWhitelist: ['*'],
|
|
47528
|
+
keyboardDisplayRequiresUserAction: false,
|
|
47529
|
+
style: StyleSheet$1.flatten([style, {
|
|
47530
|
+
height: webviewHeight
|
|
47531
|
+
}])
|
|
47532
|
+
}));
|
|
47533
|
+
};
|
|
47534
|
+
|
|
47535
|
+
var defaultValue = [{
|
|
47536
|
+
type: 'paragraph',
|
|
47537
|
+
children: [{
|
|
47538
|
+
text: ''
|
|
47539
|
+
}]
|
|
47540
|
+
}];
|
|
47541
|
+
var RichTextEditor = function RichTextEditor(_ref) {
|
|
47542
|
+
var _ref$autoFocus = _ref.autoFocus,
|
|
47543
|
+
autoFocus = _ref$autoFocus === void 0 ? true : _ref$autoFocus,
|
|
47544
|
+
name = _ref.name,
|
|
47545
|
+
_ref$placeholder = _ref.placeholder,
|
|
47546
|
+
placeholder = _ref$placeholder === void 0 ? '' : _ref$placeholder,
|
|
47547
|
+
onChange = _ref.onChange,
|
|
47548
|
+
onCursorChange = _ref.onCursorChange,
|
|
47549
|
+
_ref$error = _ref.error,
|
|
47550
|
+
error = _ref$error === void 0 ? '' : _ref$error,
|
|
47551
|
+
_ref$style = _ref.style,
|
|
47552
|
+
style = _ref$style === void 0 ? {} : _ref$style,
|
|
47553
|
+
label = _ref.label,
|
|
47554
|
+
helpText = _ref.helpText,
|
|
47555
|
+
required = _ref.required,
|
|
47556
|
+
testID = _ref.testID,
|
|
47557
|
+
onFocus = _ref.onFocus,
|
|
47558
|
+
onBlur = _ref.onBlur,
|
|
47559
|
+
forwardedRef = _ref.forwardedRef,
|
|
47560
|
+
_ref$value = _ref.value,
|
|
47561
|
+
value = _ref$value === void 0 ? defaultValue : _ref$value;
|
|
47562
|
+
var theme = useTheme();
|
|
47563
|
+
var _useState = useState(false),
|
|
47564
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
47565
|
+
isFocused = _useState2[0],
|
|
47566
|
+
setIsFocused = _useState2[1];
|
|
47567
|
+
var isEmptyValue = useMemo(function () {
|
|
47568
|
+
return libExports.isEmptyContent(value);
|
|
47569
|
+
}, [value]);
|
|
47570
|
+
var state = useMemo(function () {
|
|
47571
|
+
if (error) {
|
|
47572
|
+
return 'error';
|
|
47573
|
+
}
|
|
47574
|
+
if (isEmptyValue) {
|
|
47575
|
+
return 'filled';
|
|
47576
|
+
}
|
|
47577
|
+
return 'default';
|
|
47578
|
+
}, [isFocused, error, isEmptyValue]);
|
|
47579
|
+
var _React$useState = React__default.useState({
|
|
47580
|
+
height: 0,
|
|
47581
|
+
width: 0
|
|
47582
|
+
}),
|
|
47583
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
47584
|
+
inputSize = _React$useState2[0],
|
|
47585
|
+
setInputSize = _React$useState2[1];
|
|
47586
|
+
var focusAnimation = useRef(new Animated.Value(0)).current;
|
|
47587
|
+
useEffect(function () {
|
|
47588
|
+
Animated.timing(focusAnimation, {
|
|
47589
|
+
toValue: isFocused || !isEmptyValue ? 1 : 0,
|
|
47590
|
+
duration: LABEL_ANIMATION_DURATION,
|
|
47591
|
+
easing: Easing.bezier(0.4, 0, 0.2, 1),
|
|
47592
|
+
useNativeDriver: true
|
|
47593
|
+
}).start();
|
|
47594
|
+
}, [focusAnimation, isEmptyValue, isFocused]);
|
|
47595
|
+
var onLayout = useCallback(function (event) {
|
|
47596
|
+
var _event$nativeEvent$la = event.nativeEvent.layout,
|
|
47597
|
+
height = _event$nativeEvent$la.height,
|
|
47598
|
+
width = _event$nativeEvent$la.width;
|
|
47599
|
+
setInputSize(function (prev) {
|
|
47600
|
+
return _objectSpread2(_objectSpread2({}, prev), {}, {
|
|
47601
|
+
height: height,
|
|
47602
|
+
width: width
|
|
47603
|
+
});
|
|
47604
|
+
});
|
|
47522
47605
|
}, []);
|
|
47606
|
+
var handleEditorFocus = useCallback(function () {
|
|
47607
|
+
onFocus === null || onFocus === void 0 || onFocus();
|
|
47608
|
+
setIsFocused(true);
|
|
47609
|
+
}, [onFocus]);
|
|
47610
|
+
var handleEditorBlur = useCallback(function () {
|
|
47611
|
+
onBlur === null || onBlur === void 0 || onBlur();
|
|
47612
|
+
setIsFocused(false);
|
|
47613
|
+
}, [onBlur]);
|
|
47523
47614
|
return /*#__PURE__*/React__default.createElement(StyledContainer$6, {
|
|
47524
47615
|
testID: testID
|
|
47525
47616
|
}, /*#__PURE__*/React__default.createElement(StyledLabelContainerInsideTextInput, {
|
|
@@ -47561,27 +47652,22 @@ var RichTextEditor = function RichTextEditor(_ref) {
|
|
|
47561
47652
|
themeState: state,
|
|
47562
47653
|
themeFocused: isFocused
|
|
47563
47654
|
}), /*#__PURE__*/React__default.createElement(StyledTextInputAndLabelContainer, {
|
|
47564
|
-
style: {
|
|
47565
|
-
height: webviewHeight
|
|
47566
|
-
},
|
|
47567
47655
|
testID: "webViewWrapper"
|
|
47568
|
-
}, /*#__PURE__*/React__default.createElement(
|
|
47569
|
-
|
|
47570
|
-
|
|
47571
|
-
|
|
47572
|
-
|
|
47573
|
-
|
|
47656
|
+
}, /*#__PURE__*/React__default.createElement(BaseRichTextEditor, {
|
|
47657
|
+
name: name,
|
|
47658
|
+
value: value,
|
|
47659
|
+
style: [style, {
|
|
47660
|
+
marginHorizontal: theme.__hd__.textInput.space.inputHorizontalMargin
|
|
47661
|
+
}],
|
|
47574
47662
|
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, {
|
|
47663
|
+
onChange: onChange,
|
|
47664
|
+
autoFocus: autoFocus,
|
|
47665
|
+
editorRef: forwardedRef,
|
|
47666
|
+
placeholder: placeholder,
|
|
47667
|
+
onBlur: handleEditorBlur,
|
|
47668
|
+
onFocus: handleEditorFocus,
|
|
47669
|
+
onCursorChange: onCursorChange
|
|
47670
|
+
}))), /*#__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
47671
|
testID: "input-error-icon",
|
|
47586
47672
|
icon: "circle-info",
|
|
47587
47673
|
size: "xsmall",
|
|
@@ -47598,8 +47684,12 @@ var RichTextEditorWithRef = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
47598
47684
|
RichTextEditorWithRef.displayName = 'RichTextEditor';
|
|
47599
47685
|
|
|
47600
47686
|
var index = Object.assign(RichTextEditorWithRef, {
|
|
47687
|
+
Toolbar: EditorToolbar,
|
|
47601
47688
|
MentionList: MentionList,
|
|
47602
|
-
|
|
47689
|
+
EditorEvents: EditorEvents,
|
|
47690
|
+
ToolbarEvents: ToolbarEvents,
|
|
47691
|
+
useRichTextEditorEvents: useRichTextEditorEvents,
|
|
47692
|
+
Base: BaseRichTextEditor
|
|
47603
47693
|
});
|
|
47604
47694
|
|
|
47605
47695
|
var LAST_BREAKPOINT = 100;
|